From 621dec0f2b7a982c958cce4d7baa4ccd3994606a Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Fri, 19 Jun 2020 21:30:34 +0200 Subject: Use OpenCL buffer to access moments in streamline impl --- template/kernel.mako | 2 +- template/streamline.mako | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) (limited to 'template') diff --git a/template/kernel.mako b/template/kernel.mako index dd8eaee..2e26124 100644 --- a/template/kernel.mako +++ b/template/kernel.mako @@ -105,4 +105,4 @@ __kernel void collect_moments(__global ${float_type}* f, % for i, expr in enumerate(moments_assignment): moments[${pop_offset(i)} + gid] = ${ccode(expr.rhs)}; % endfor -} +} \ No newline at end of file diff --git a/template/streamline.mako b/template/streamline.mako index 73c80e2..adf5efd 100644 --- a/template/streamline.mako +++ b/template/streamline.mako @@ -31,7 +31,7 @@ float3 blueRedPalette(float x) { ); } -__kernel void draw_streamline(__global float4* moments, +__kernel void draw_streamline(__global float* moments, __global int* material, __global float2* origins, __read_write image2d_t streamlines) @@ -40,14 +40,12 @@ __kernel void draw_streamline(__global float4* moments, for (int i = 0; i < ${2*memory.size_x}; ++i) { const unsigned int gid = round(particle.y)*${memory.size_x} + round(particle.x); - const float4 moment = moments[gid]; - if (material[gid] != 1) { break; } - particle.x += 0.5 * moment.y / 0.01; - particle.y += 0.5 * moment.z / 0.01; + particle.x += 0.5 * moments[${1*memory.volume}+gid] / 0.01; + particle.y += 0.5 * moments[${2*memory.volume}+gid] / 0.01; const int2 pos = (int2)(round(particle.x), round(particle.y)); @@ -56,4 +54,4 @@ __kernel void draw_streamline(__global float4* moments, write_imagef(streamlines, pos, color); } -} +} \ No newline at end of file -- cgit v1.2.3