summaryrefslogtreecommitdiff
path: root/src/kernel.cu
diff options
context:
space:
mode:
Diffstat (limited to 'src/kernel.cu')
-rw-r--r--src/kernel.cu34
1 files changed, 19 insertions, 15 deletions
diff --git a/src/kernel.cu b/src/kernel.cu
index 82efe88..17b829c 100644
--- a/src/kernel.cu
+++ b/src/kernel.cu
@@ -260,7 +260,9 @@ __global__ void ray_trace(int nthreads, float3 *positions, float3 *directions, i
} // ray_trace
-__global__ void propagate(int nthreads, curandState *rng_states, float3 *positions, float3 *directions, float *wavelengths, float3 *polarizations, float *times, unsigned int *histories, int *last_hit_triangles, int max_steps)
+__global__ void propagate(int first_photon, int nthreads, int *photon_offsets, curandState *rng_states,
+ float3 *positions, float3 *directions, float *wavelengths, float3 *polarizations, float *times,
+ unsigned int *histories, int *last_hit_triangles, int max_steps)
{
int id = blockIdx.x*blockDim.x + threadIdx.x;
@@ -269,16 +271,18 @@ __global__ void propagate(int nthreads, curandState *rng_states, float3 *positio
curandState rng = rng_states[id];
+ int photon_id = photon_offsets[first_photon + id];
+
Photon p;
- p.position = positions[id];
- p.direction = directions[id];
+ p.position = positions[photon_id];
+ p.direction = directions[photon_id];
p.direction /= norm(p.direction);
- p.polarization = polarizations[id];
+ p.polarization = polarizations[photon_id];
p.polarization /= norm(p.polarization);
- p.wavelength = wavelengths[id];
- p.time = times[id];
- p.last_hit_triangle = last_hit_triangles[id];
- p.history = histories[id];
+ p.wavelength = wavelengths[photon_id];
+ p.time = times[photon_id];
+ p.last_hit_triangle = last_hit_triangles[photon_id];
+ p.history = histories[photon_id];
if (p.history & (NO_HIT | BULK_ABSORB | SURFACE_DETECT | SURFACE_ABSORB))
return;
@@ -321,13 +325,13 @@ __global__ void propagate(int nthreads, curandState *rng_states, float3 *positio
} // while (steps < max_steps)
rng_states[id] = rng;
- positions[id] = p.position;
- directions[id] = p.direction;
- polarizations[id] = p.polarization;
- wavelengths[id] = p.wavelength;
- times[id] = p.time;
- histories[id] = p.history;
- last_hit_triangles[id] = p.last_hit_triangle;
+ positions[photon_id] = p.position;
+ directions[photon_id] = p.direction;
+ polarizations[photon_id] = p.polarization;
+ wavelengths[photon_id] = p.wavelength;
+ times[photon_id] = p.time;
+ histories[photon_id] = p.history;
+ last_hit_triangles[photon_id] = p.last_hit_triangle;
} // propagate