From ccd0fc6bb23dd3b98961ffb3a3cb396261192926 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Tue, 28 May 2019 18:00:01 +0200 Subject: Pull streaming for local writes --- implosion.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/implosion.py b/implosion.py index b786461..8e75921 100644 --- a/implosion.py +++ b/implosion.py @@ -74,15 +74,20 @@ __kernel void collide_and_stream(__global float* pop_a, const unsigned int gid = get_global_id(0); const uint2 cell = cellAtGid(gid); - float d = density(&pop_b[gid*9]); - float2 v = velocity(&pop_b[gid*9],d); - const int m = material[gid]; + if ( m == 0 ) { + return; + } + + const float d = density(&pop_b[gid*9]); + const float2 v = velocity(&pop_b[gid*9],d); + for ( int i = -1; i <= 1; ++i ) { for ( int j = -1; j <= 1; ++j ) { - pop_a[gidOfCell(cell.x+m*i, cell.y+m*j)*9 + indexOfDirection(m*i,m*j)] = - pop_b[gid*9 + indexOfDirection(i,j)] + $tau * (equilibrium(d,v,i,j) - pop_b[gid*9 + indexOfDirection(i,j)]); + const unsigned int ngid = gidOfCell(cell.x-i, cell.y-j); + pop_a[gid*9 + indexOfDirection(m*i,m*j)] = + pop_b[ngid*9 + indexOfDirection(i,j)] + $tau * (equilibrium(d,v,i,j) - pop_b[ngid*9 + indexOfDirection(i,j)]); } } }""" -- cgit v1.2.3