diff options
Diffstat (limited to 'lid_driven_cavity')
-rw-r--r-- | lid_driven_cavity/cpp/ldc.cpp.mako | 2 | ||||
-rw-r--r-- | lid_driven_cavity/opencl/ldc_2d.py | 13 | ||||
-rw-r--r-- | lid_driven_cavity/opencl/simulation.py | 6 |
3 files changed, 12 insertions, 9 deletions
diff --git a/lid_driven_cavity/cpp/ldc.cpp.mako b/lid_driven_cavity/cpp/ldc.cpp.mako index 5d480de..c66679f 100644 --- a/lid_driven_cavity/cpp/ldc.cpp.mako +++ b/lid_driven_cavity/cpp/ldc.cpp.mako @@ -132,8 +132,10 @@ void simulate(std::size_t nStep) std::cout << "#steps : " << nStep << std::endl; std::cout << std::endl; +#pragma omp parallel for for (std::size_t iCell = 0; iCell < ${geometry.volume}; ++iCell) { equilibrilize(f_prev, f_next, iCell); + equilibrilize(f_next, f_prev, iCell); } const auto start = std::chrono::high_resolution_clock::now(); diff --git a/lid_driven_cavity/opencl/ldc_2d.py b/lid_driven_cavity/opencl/ldc_2d.py index 755ace0..c080284 100644 --- a/lid_driven_cavity/opencl/ldc_2d.py +++ b/lid_driven_cavity/opencl/ldc_2d.py @@ -48,18 +48,19 @@ generator = Generator( kernel_src = generator.kernel(geometry, functions, extras) kernel_src += generator.custom(geometry, """ -__kernel void equilibrilize(__global ${float_type}* f_next, - __global ${float_type}* f_prev) +__kernel void equilibrilize_all(__global ${float_type}* f_next, + __global ${float_type}* f_prev) { const unsigned int gid = ${index.gid('get_global_id(0)', 'get_global_id(1)')}; - equilibrilize_gid(f_next, f_prev, gid); + equilibrilize(f_next, f_prev, gid); + equilibrilize(f_prev, f_next, gid); } -__kernel void collect_moments(__global ${float_type}* f, - __global ${float_type}* moments) +__kernel void collect_moments_all(__global ${float_type}* f, + __global ${float_type}* moments) { const unsigned int gid = ${index.gid('get_global_id(0)', 'get_global_id(1)')}; - collect_moments_gid(f, moments, gid); + collect_moments(f, gid, moments); } """) diff --git a/lid_driven_cavity/opencl/simulation.py b/lid_driven_cavity/opencl/simulation.py index 7625609..37aab5b 100644 --- a/lid_driven_cavity/opencl/simulation.py +++ b/lid_driven_cavity/opencl/simulation.py @@ -66,7 +66,7 @@ class Lattice: self.build_kernel(kernel_src) - self.program.equilibrilize( + self.program.equilibrilize_all( self.queue, self.geometry.size(), self.layout, self.memory.cl_pop_a, self.memory.cl_pop_b).wait() self.tasks = [] @@ -94,10 +94,10 @@ class Lattice: moments = numpy.ndarray(shape=(self.memory.volume*(self.descriptor.d+1),1), dtype=self.float_type[0]) if self.tick: - self.program.collect_moments( + self.program.collect_moments_all( self.queue, self.geometry.size(), self.layout, self.memory.cl_pop_b, self.memory.cl_moments) else: - self.program.collect_moments( + self.program.collect_moments_all( self.queue, self.geometry.size(), self.layout, self.memory.cl_pop_a, self.memory.cl_moments) cl.enqueue_copy(self.queue, moments, self.memory.cl_moments).wait(); |