aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/diffraction.cl39
-rw-r--r--src/diffraction-gpu.c38
2 files changed, 20 insertions, 57 deletions
diff --git a/data/diffraction.cl b/data/diffraction.cl
index 4262a1ec..ff07edff 100644
--- a/data/diffraction.cl
+++ b/data/diffraction.cl
@@ -24,39 +24,8 @@ const sampler_t sampler_c = CLK_NORMALIZED_COORDS_TRUE | CLK_ADDRESS_REPEAT
| CLK_FILTER_LINEAR;
-float4 quat_rot(float4 q, float4 z)
-{
- float4 res;
- float t01, t02, t03, t11, t12, t13, t22, t23, t33;
-
- t01 = z.x*z.y;
- t02 = z.x*z.z;
- t03 = z.x*z.w;
- t11 = z.y*z.y;
- t12 = z.y*z.z;
- t13 = z.y*z.w;
- t22 = z.z*z.z;
- t23 = z.z*z.w;
- t33 = z.w*z.w;
-
- res.x = (1.0 - 2.0 * (t22 + t33)) * q.x
- + (2.0 * (t12 + t03)) * q.y
- + (2.0 * (t13 - t02)) * q.z;
-
- res.y = (2.0 * (t12 - t03)) * q.x
- + (1.0 - 2.0 * (t11 + t33)) * q.y
- + (2.0 * (t01 + t23)) * q.z;
-
- res.z = (2.0 * (t02 + t13)) * q.x
- + (2.0 * (t23 - t01)) * q.y
- + (1.0 - 2.0 * (t11 + t22)) * q.z;
-
- return res;
-}
-
-
float4 get_q(int x, int y, float cx, float cy, float res, float clen, float k,
- float *ttp, float4 z, int sampling)
+ float *ttp, int sampling)
{
float rx, ry, r;
float az, tt;
@@ -76,7 +45,7 @@ float4 get_q(int x, int y, float cx, float cy, float res, float clen, float k,
k*native_sin(tt)*native_sin(az),
k*(native_cos(tt)-1.0), 0.0);
- return quat_rot(q, z);
+ return q;
}
@@ -135,7 +104,7 @@ float get_intensity(global float *intensities, float16 cell, float4 q)
kernel void diffraction(global float *diff, global float *tt, float klow,
int w, float cx, float cy,
float res, float clen, float16 cell,
- global float *intensities, float4 z,
+ global float *intensities,
int xmin, int ymin, int sampling, local float *tmp,
float kstep,
read_only image2d_t func_a,
@@ -157,7 +126,7 @@ kernel void diffraction(global float *diff, global float *tt, float klow,
float intensity;
/* Calculate value */
- q = get_q(x, y, cx, cy, res, clen, k, &ttv, z, sampling);
+ q = get_q(x, y, cx, cy, res, clen, k, &ttv, sampling);
f_lattice = lattice_factor(cell, q, func_a, func_b, func_c);
I_molecule = get_intensity(intensities, cell, q);
I_lattice = pow(f_lattice, 2.0f);
diff --git a/src/diffraction-gpu.c b/src/diffraction-gpu.c
index 6e73a52c..c210cab9 100644
--- a/src/diffraction-gpu.c
+++ b/src/diffraction-gpu.c
@@ -120,7 +120,6 @@ void get_diffraction_gpu(struct gpu_context *gctx, struct image *image,
int x, y;
cl_float16 cell;
float *diff_ptr;
- cl_float4 orientation;
cl_int4 ncells;
const int sampling = SAMPLING;
cl_float bwstep;
@@ -180,48 +179,43 @@ void get_diffraction_gpu(struct gpu_context *gctx, struct image *image,
ERROR("Couldn't set arg 9: %s\n", clError(err));
return;
}
- clSetKernelArg(gctx->kern, 10, sizeof(cl_float4), &orientation);
+ clSetKernelArg(gctx->kern, 12, sizeof(cl_int), &sampling);
if ( err != CL_SUCCESS ) {
- ERROR("Couldn't set arg 10: %s\n", clError(err));
- return;
- }
- clSetKernelArg(gctx->kern, 13, sizeof(cl_int), &sampling);
- if ( err != CL_SUCCESS ) {
- ERROR("Couldn't set arg 13: %s\n", clError(err));
+ ERROR("Couldn't set arg 12: %s\n", clError(err));
return;
}
/* Local memory for reduction */
- clSetKernelArg(gctx->kern, 14,
+ clSetKernelArg(gctx->kern, 13,
BWSAMPLING*SAMPLING*SAMPLING*sizeof(cl_float), NULL);
if ( err != CL_SUCCESS ) {
- ERROR("Couldn't set arg 14: %s\n", clError(err));
+ ERROR("Couldn't set arg 13: %s\n", clError(err));
return;
}
/* Bandwidth sampling step */
- clSetKernelArg(gctx->kern, 15, sizeof(cl_float), &bwstep);
+ clSetKernelArg(gctx->kern, 14, sizeof(cl_float), &bwstep);
if ( err != CL_SUCCESS ) {
- ERROR("Couldn't set arg 15: %s\n", clError(err));
+ ERROR("Couldn't set arg 14: %s\n", clError(err));
return;
}
/* LUT in 'a' direction */
- clSetKernelArg(gctx->kern, 16, sizeof(cl_mem), &gctx->sinc_luts[na-1]);
+ clSetKernelArg(gctx->kern, 15, sizeof(cl_mem), &gctx->sinc_luts[na-1]);
if ( err != CL_SUCCESS ) {
- ERROR("Couldn't set arg 16: %s\n", clError(err));
+ ERROR("Couldn't set arg 15: %s\n", clError(err));
return;
}
/* LUT in 'b' direction */
- clSetKernelArg(gctx->kern, 17, sizeof(cl_mem), &gctx->sinc_luts[nb-1]);
+ clSetKernelArg(gctx->kern, 16, sizeof(cl_mem), &gctx->sinc_luts[nb-1]);
if ( err != CL_SUCCESS ) {
- ERROR("Couldn't set arg 17: %s\n", clError(err));
+ ERROR("Couldn't set arg 16: %s\n", clError(err));
return;
}
/* LUT in 'c' direction */
- clSetKernelArg(gctx->kern, 18, sizeof(cl_mem), &gctx->sinc_luts[nc-1]);
+ clSetKernelArg(gctx->kern, 17, sizeof(cl_mem), &gctx->sinc_luts[nc-1]);
if ( err != CL_SUCCESS ) {
- ERROR("Couldn't set arg 18: %s\n", clError(err));
+ ERROR("Couldn't set arg 17: %s\n", clError(err));
return;
}
@@ -264,16 +258,16 @@ void get_diffraction_gpu(struct gpu_context *gctx, struct image *image,
ERROR("Couldn't set arg 7: %s\n", clError(err));
return;
}
- clSetKernelArg(gctx->kern, 11, sizeof(cl_int),
+ clSetKernelArg(gctx->kern, 10, sizeof(cl_int),
&image->det->panels[p].min_x);
if ( err != CL_SUCCESS ) {
- ERROR("Couldn't set arg 11: %s\n", clError(err));
+ ERROR("Couldn't set arg 10: %s\n", clError(err));
return;
}
- clSetKernelArg(gctx->kern, 12, sizeof(cl_int),
+ clSetKernelArg(gctx->kern, 11, sizeof(cl_int),
&image->det->panels[p].min_y);
if ( err != CL_SUCCESS ) {
- ERROR("Couldn't set arg 12: %s\n", clError(err));
+ ERROR("Couldn't set arg 11: %s\n", clError(err));
return;
}