Changes in sasmodels/kernel_iq.cl [56547a8:4f1f876] in sasmodels


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/kernel_iq.cl

    r56547a8 r4f1f876  
    2828} ProblemDetails; 
    2929 
     30// Intel HD 4000 needs private arrays to be a multiple of 4 long 
    3031typedef struct { 
    3132    PARAMETER_TABLE 
     33} ParameterTable; 
     34typedef union { 
     35    ParameterTable table; 
     36    double vector[4*((NUM_PARS+3)/4)]; 
    3237} ParameterBlock; 
    3338#endif // _PAR_BLOCK_ 
     
    8792  // walk the polydispersity cube.  local_values will be aliased to pvec. 
    8893  ParameterBlock local_values; 
    89   double *pvec = (double *)&local_values; 
    9094 
    9195  // Fill in the initial variables 
    9296  for (int i=0; i < NUM_PARS; i++) { 
    93     pvec[i] = values[2+i]; 
    94 //if (q_index==0) printf("p%d = %g\n",i, pvec[i]); 
     97    local_values.vector[i] = values[2+i]; 
     98//if (q_index==0) printf("p%d = %g\n",i, local_values.vector[i]); 
    9599  } 
    96100 
    97101#if defined(MAGNETIC) && NUM_MAGNETIC>0 
    98   // Location of the sld parameters in the parameter pvec. 
     102  // Location of the sld parameters in the parameter vector. 
    99103  // These parameters are updated with the effective sld due to magnetism. 
    100104  #if NUM_MAGNETIC > 3 
     
    166170 
    167171 
    168   double spherical_correction=1.0; 
     172#if MAX_PD>0 
    169173  const int theta_par = details->theta_par; 
    170 #if MAX_PD>0 
    171   const int fast_theta = (theta_par == p0); 
    172   const int slow_theta = (theta_par >= 0 && !fast_theta); 
     174  const bool fast_theta = (theta_par == p0); 
     175  const bool slow_theta = (theta_par >= 0 && !fast_theta); 
     176  double spherical_correction = 1.0; 
    173177#else 
    174   const int slow_theta = (theta_par >= 0); 
     178  // Note: if not polydisperse the weights cancel and we don't need the 
     179  // spherical correction. 
     180  const double spherical_correction = 1.0; 
    175181#endif 
    176182 
     
    181187  const double weight5 = 1.0; 
    182188  while (i4 < n4) { 
    183     pvec[p4] = v4[i4]; 
     189    local_values.vector[p4] = v4[i4]; 
    184190    double weight4 = w4[i4] * weight5; 
    185 //if (q_index == 0) printf("step:%d level %d: p:%d i:%d n:%d value:%g weight:%g\n", step, 4, p4, i4, n4, pvec[p4], weight4); 
     191//if (q_index == 0) printf("step:%d level %d: p:%d i:%d n:%d value:%g weight:%g\n", step, 4, p4, i4, n4, local_values.vector[p4], weight4); 
    186192#elif MAX_PD>3 
    187193    const double weight4 = 1.0; 
     
    189195#if MAX_PD>3 
    190196  while (i3 < n3) { 
    191     pvec[p3] = v3[i3]; 
     197    local_values.vector[p3] = v3[i3]; 
    192198    double weight3 = w3[i3] * weight4; 
    193 //if (q_index == 0) printf("step:%d level %d: p:%d i:%d n:%d value:%g weight:%g\n", step, 3, p3, i3, n3, pvec[p3], weight3); 
     199//if (q_index == 0) printf("step:%d level %d: p:%d i:%d n:%d value:%g weight:%g\n", step, 3, p3, i3, n3, local_values.vector[p3], weight3); 
    194200#elif MAX_PD>2 
    195201    const double weight3 = 1.0; 
     
    197203#if MAX_PD>2 
    198204  while (i2 < n2) { 
    199     pvec[p2] = v2[i2]; 
     205    local_values.vector[p2] = v2[i2]; 
    200206    double weight2 = w2[i2] * weight3; 
    201 //if (q_index == 0) printf("step:%d level %d: p:%d i:%d n:%d value:%g weight:%g\n", step, 2, p2, i2, n2, pvec[p2], weight2); 
     207//if (q_index == 0) printf("step:%d level %d: p:%d i:%d n:%d value:%g weight:%g\n", step, 2, p2, i2, n2, local_values.vector[p2], weight2); 
    202208#elif MAX_PD>1 
    203209    const double weight2 = 1.0; 
     
    205211#if MAX_PD>1 
    206212  while (i1 < n1) { 
    207     pvec[p1] = v1[i1]; 
     213    local_values.vector[p1] = v1[i1]; 
    208214    double weight1 = w1[i1] * weight2; 
    209 //if (q_index == 0) printf("step:%d level %d: p:%d i:%d n:%d value:%g weight:%g\n", step, 1, p1, i1, n1, pvec[p1], weight1); 
     215//if (q_index == 0) printf("step:%d level %d: p:%d i:%d n:%d value:%g weight:%g\n", step, 1, p1, i1, n1, local_values.vector[p1], weight1); 
    210216#elif MAX_PD>0 
    211217    const double weight1 = 1.0; 
    212218#endif 
    213     if (slow_theta) { // Theta is not in inner loop 
    214       spherical_correction = fmax(fabs(cos(M_PI_180*pvec[theta_par])), 1.e-6); 
    215     } 
    216 #if MAX_PD>0 
     219#if MAX_PD>0 
     220  if (slow_theta) { // Theta is not in inner loop 
     221    spherical_correction = fmax(fabs(cos(M_PI_180*local_values.vector[theta_par])), 1.e-6); 
     222  } 
    217223  while(i0 < n0) { 
    218     pvec[p0] = v0[i0]; 
     224    local_values.vector[p0] = v0[i0]; 
    219225    double weight0 = w0[i0] * weight1; 
    220 //if (q_index == 0) printf("step:%d level %d: p:%d i:%d n:%d value:%g weight:%g\n", step, 0, p0, i0, n0, pvec[p0], weight0); 
     226//if (q_index == 0) printf("step:%d level %d: p:%d i:%d n:%d value:%g weight:%g\n", step, 0, p0, i0, n0, local_values.vector[p0], weight0); 
    221227    if (fast_theta) { // Theta is in inner loop 
    222       spherical_correction = fmax(fabs(cos(M_PI_180*pvec[p0])), 1.e-6); 
     228      spherical_correction = fmax(fabs(cos(M_PI_180*local_values.vector[p0])), 1.e-6); 
    223229    } 
    224230#else 
     
    226232#endif 
    227233 
    228 //if (q_index == 0) {printf("step:%d of %d, pars:",step,pd_stop); for (int i=0; i < NUM_PARS; i++) printf("p%d=%g ",i, pvec[i]); printf("\n"); } 
     234//if (q_index == 0) {printf("step:%d of %d, pars:",step,pd_stop); for (int i=0; i < NUM_PARS; i++) printf("p%d=%g ",i, local_values.vector[i]); printf("\n"); } 
    229235//if (q_index == 0) printf("sphcor: %g\n", spherical_correction); 
    230236 
    231237    #ifdef INVALID 
    232     if (!INVALID(local_values)) 
     238    if (!INVALID(local_values.table)) 
    233239    #endif 
    234240    { 
     
    239245        // would be problems looking at models with theta=90. 
    240246        const double weight = weight0 * spherical_correction; 
    241         pd_norm += weight * CALL_VOLUME(local_values); 
     247        pd_norm += weight * CALL_VOLUME(local_values.table); 
    242248 
    243249#if defined(MAGNETIC) && NUM_MAGNETIC > 0 
     
    265271                #define M3 NUM_PARS+13 
    266272                #define SLD(_M_offset, _sld_offset) \ 
    267                     pvec[_sld_offset] = xs * (axis \ 
     273                    local_values.vector[_sld_offset] = xs * (axis \ 
    268274                    ? (index==1 ? -values[_M_offset+2] : values[_M_offset+2]) \ 
    269275                    : mag_sld(qx, qy, pk, values[_M_offset], values[_M_offset+1], \ 
     
    283289                } 
    284290                #endif 
    285                 scattering += CALL_IQ(q, q_index, local_values); 
     291                scattering += CALL_IQ(q, q_index, local_values.table); 
    286292              } 
    287293            } 
     
    289295        } 
    290296#else  // !MAGNETIC 
    291         const double scattering = CALL_IQ(q, q_index, local_values); 
     297        const double scattering = CALL_IQ(q, q_index, local_values.table); 
    292298#endif // !MAGNETIC 
    293299        this_result += weight * scattering; 
Note: See TracChangeset for help on using the changeset viewer.