Changeset 01c8d9e in sasmodels for sasmodels/kernel_iq.c
- Timestamp:
- Aug 7, 2018 12:32:18 PM (6 years ago)
- Branches:
- master, core_shell_microgels, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
- Children:
- c11d09f
- Parents:
- 707cbdb
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/kernel_iq.c
r7c35fda r01c8d9e 36 36 // PROJECTION : equirectangular=1, sinusoidal=2 37 37 // see explore/jitter.py for definitions. 38 38 39 39 40 #ifndef _PAR_BLOCK_ // protected block so we can include this code twice. … … 270 271 #endif // _QABC_SECTION 271 272 272 273 273 // ==================== KERNEL CODE ======================== 274 275 274 kernel 276 275 void KERNEL_NAME( … … 339 338 // The code differs slightly between opencl and dll since opencl is only 340 339 // seeing one q value (stored in the variable "this_result") while the dll 341 // version must loop over all q. 340 // version must loop over all q 341 #if BETA 342 double *beta_result = &(result[nq+1]); // = result + nq + 1 343 double weight_norm = (pd_start == 0 ? 0.0 : result[2*nq+1]); 344 #endif 342 345 #ifdef USE_OPENCL 343 346 double pd_norm = (pd_start == 0 ? 0.0 : result[nq]); 344 347 double this_result = (pd_start == 0 ? 0.0 : result[q_index]); 348 #if BETA 349 double this_beta_result = (pd_start == 0 ? 0.0 : result[nq + q_index]; 345 350 #else // !USE_OPENCL 346 double pd_norm = (pd_start == 0 ? 0.0 : result[nq]); 351 double pd_norm = (pd_start == 0 ? 0.0 : result[nq]); 347 352 if (pd_start == 0) { 348 353 #ifdef USE_OPENMP … … 350 355 #endif 351 356 for (int q_index=0; q_index < nq; q_index++) result[q_index] = 0.0; 357 #if BETA 358 for (int q_index=0; q_index < nq; q_index++) beta_result[q_index] = 0.0; 359 #endif 352 360 } 353 361 //if (q_index==0) printf("start %d %g %g\n", pd_start, pd_norm, result[0]); 354 362 #endif // !USE_OPENCL 363 364 365 355 366 356 367 … … 442 453 // inner loop and defines the macros that use them. 443 454 455 444 456 #if defined(CALL_IQ) 445 457 // unoriented 1D 446 458 double qk; 447 #define FETCH_Q() do { qk = q[q_index]; } while (0) 448 #define BUILD_ROTATION() do {} while(0) 449 #define APPLY_ROTATION() do {} while(0) 450 #define CALL_KERNEL() CALL_IQ(qk, local_values.table) 459 #if BETA == 0 460 #define FETCH_Q() do { qk = q[q_index]; } while (0) 461 #define BUILD_ROTATION() do {} while(0) 462 #define APPLY_ROTATION() do {} while(0) 463 #define CALL_KERNEL() CALL_IQ(qk,local_values.table) 464 465 // unoriented 1D Beta 466 #elif BETA == 1 467 double F1, F2; 468 #define FETCH_Q() do { qk = q[q_index]; } while (0) 469 #define BUILD_ROTATION() do {} while(0) 470 #define APPLY_ROTATION() do {} while(0) 471 #define CALL_KERNEL() CALL_IQ(qk,F1,F2,local_values.table) 472 #endif 451 473 452 474 #elif defined(CALL_IQ_A) … … 647 669 pd_norm += weight * CALL_VOLUME(local_values.table); 648 670 BUILD_ROTATION(); 649 671 #if BETA 672 if (weight > cutoff) { 673 weight_norm += weight;} 674 #endif 650 675 #ifndef USE_OPENCL 651 676 // DLL needs to explicitly loop over the q values. … … 693 718 } 694 719 #else // !MAGNETIC 695 const double scattering = CALL_KERNEL(); 720 #if defined(CALL_IQ) && BETA == 1 721 CALL_KERNEL(); 722 const double scatteringF1 = F1; 723 const double scatteringF2 = F2; 724 #else 725 const double scattering = CALL_KERNEL(); 726 #endif 696 727 #endif // !MAGNETIC 697 728 //printf("q_index:%d %g %g %g %g\n", q_index, scattering, weight0); 698 729 699 730 #ifdef USE_OPENCL 700 this_result += weight * scattering; 731 #if defined(CALL_IQ)&& BETA == 1 732 this_result += weight * scatteringF2; 733 this_beta_result += weight * scatteringF1; 734 #else 735 this_result += weight * scattering; 736 #endif 701 737 #else // !USE_OPENCL 702 result[q_index] += weight * scattering; 738 #if defined(CALL_IQ)&& BETA == 1 739 result[q_index] += weight * scatteringF2; 740 beta_result[q_index] += weight * scatteringF1; 741 #endif 742 #else 743 result[q_index] += weight * scattering; 744 #endif 703 745 #endif // !USE_OPENCL 704 746 } 705 747 } 706 748 } 707 708 749 // close nested loops 709 750 ++step; … … 728 769 result[q_index] = this_result; 729 770 if (q_index == 0) result[nq] = pd_norm; 771 #if BETA 772 beta_result[q_index] = this_beta_result; 773 #endif 774 if (q_index == 0) result[nq] = pd_norm; 775 730 776 //if (q_index == 0) printf("res: %g/%g\n", result[0], pd_norm); 731 777 #else // !USE_OPENCL 732 778 result[nq] = pd_norm; 779 #if BETA 780 result[2*nq+1] = weight_norm; 781 #endif 733 782 //printf("res: %g/%g\n", result[0], pd_norm); 734 783 #endif // !USE_OPENCL
Note: See TracChangeset
for help on using the changeset viewer.