Changes in sasmodels/kernel_iq.cl [56547a8:4f1f876] in sasmodels
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/kernel_iq.cl
r56547a8 r4f1f876 28 28 } ProblemDetails; 29 29 30 // Intel HD 4000 needs private arrays to be a multiple of 4 long 30 31 typedef struct { 31 32 PARAMETER_TABLE 33 } ParameterTable; 34 typedef union { 35 ParameterTable table; 36 double vector[4*((NUM_PARS+3)/4)]; 32 37 } ParameterBlock; 33 38 #endif // _PAR_BLOCK_ … … 87 92 // walk the polydispersity cube. local_values will be aliased to pvec. 88 93 ParameterBlock local_values; 89 double *pvec = (double *)&local_values;90 94 91 95 // Fill in the initial variables 92 96 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]); 95 99 } 96 100 97 101 #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. 99 103 // These parameters are updated with the effective sld due to magnetism. 100 104 #if NUM_MAGNETIC > 3 … … 166 170 167 171 168 double spherical_correction=1.0; 172 #if MAX_PD>0 169 173 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; 173 177 #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; 175 181 #endif 176 182 … … 181 187 const double weight5 = 1.0; 182 188 while (i4 < n4) { 183 pvec[p4] = v4[i4];189 local_values.vector[p4] = v4[i4]; 184 190 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); 186 192 #elif MAX_PD>3 187 193 const double weight4 = 1.0; … … 189 195 #if MAX_PD>3 190 196 while (i3 < n3) { 191 pvec[p3] = v3[i3];197 local_values.vector[p3] = v3[i3]; 192 198 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); 194 200 #elif MAX_PD>2 195 201 const double weight3 = 1.0; … … 197 203 #if MAX_PD>2 198 204 while (i2 < n2) { 199 pvec[p2] = v2[i2];205 local_values.vector[p2] = v2[i2]; 200 206 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); 202 208 #elif MAX_PD>1 203 209 const double weight2 = 1.0; … … 205 211 #if MAX_PD>1 206 212 while (i1 < n1) { 207 pvec[p1] = v1[i1];213 local_values.vector[p1] = v1[i1]; 208 214 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); 210 216 #elif MAX_PD>0 211 217 const double weight1 = 1.0; 212 218 #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 } 217 223 while(i0 < n0) { 218 pvec[p0] = v0[i0];224 local_values.vector[p0] = v0[i0]; 219 225 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); 221 227 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); 223 229 } 224 230 #else … … 226 232 #endif 227 233 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"); } 229 235 //if (q_index == 0) printf("sphcor: %g\n", spherical_correction); 230 236 231 237 #ifdef INVALID 232 if (!INVALID(local_values ))238 if (!INVALID(local_values.table)) 233 239 #endif 234 240 { … … 239 245 // would be problems looking at models with theta=90. 240 246 const double weight = weight0 * spherical_correction; 241 pd_norm += weight * CALL_VOLUME(local_values );247 pd_norm += weight * CALL_VOLUME(local_values.table); 242 248 243 249 #if defined(MAGNETIC) && NUM_MAGNETIC > 0 … … 265 271 #define M3 NUM_PARS+13 266 272 #define SLD(_M_offset, _sld_offset) \ 267 pvec[_sld_offset] = xs * (axis \273 local_values.vector[_sld_offset] = xs * (axis \ 268 274 ? (index==1 ? -values[_M_offset+2] : values[_M_offset+2]) \ 269 275 : mag_sld(qx, qy, pk, values[_M_offset], values[_M_offset+1], \ … … 283 289 } 284 290 #endif 285 scattering += CALL_IQ(q, q_index, local_values );291 scattering += CALL_IQ(q, q_index, local_values.table); 286 292 } 287 293 } … … 289 295 } 290 296 #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); 292 298 #endif // !MAGNETIC 293 299 this_result += weight * scattering;
Note: See TracChangeset
for help on using the changeset viewer.