From 020315cf36485dab79c2ffc786675bbf587cfdf0 Mon Sep 17 00:00:00 2001 From: Stephan Seitz <stephan.seitz@fau.de> Date: Sun, 23 Feb 2020 18:06:42 +0100 Subject: [PATCH] Actually test GPU in test_boundary_handling.test_simple Was only allocating buffers for GPU but then doing boundary handling on CPU --- lbmpy_tests/test_boundary_handling.py | 28 +++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/lbmpy_tests/test_boundary_handling.py b/lbmpy_tests/test_boundary_handling.py index cc88ffa6..7142f97f 100644 --- a/lbmpy_tests/test_boundary_handling.py +++ b/lbmpy_tests/test_boundary_handling.py @@ -1,5 +1,4 @@ import numpy as np - import pytest from lbmpy.boundaries import UBB, NeumannByCopy, NoSlip, StreamInConstant @@ -10,15 +9,24 @@ from lbmpy.lbstep import LatticeBoltzmannStep from pystencils import create_data_handling, make_slice -@pytest.mark.parametrize("gpu", [True, False]) -def test_simple(gpu): - import pytest - pytest.importorskip('pycuda') - dh = create_data_handling((10, 5), parallel=False) - dh.add_array('pdfs', values_per_cell=9, cpu=True, gpu=gpu) - lb_func = create_lb_function(stencil='D2Q9', compressible=False, relaxation_rate=1.8) - - bh = LatticeBoltzmannBoundaryHandling(lb_func.method, dh, 'pdfs') +@pytest.mark.parametrize("target", ['cpu', 'gpu', 'opencl']) +def test_simple(target): + if target == 'gpu': + import pytest + pytest.importorskip('pycuda') + elif target == 'opencl': + import pytest + pytest.importorskip('pyopencl') + import pystencils.opencl.autoinit + + dh = create_data_handling((10, 5), parallel=False, default_target=target) + dh.add_array('pdfs', values_per_cell=9, cpu=True, gpu=target!='cpu') + lb_func = create_lb_function(stencil='D2Q9', + compressible=False, + relaxation_rate=1.8, + optimization={'target': target}) + + bh = LatticeBoltzmannBoundaryHandling(lb_func.method, dh, 'pdfs', target=target) wall = NoSlip() moving_wall = UBB((0.001, 0)) -- GitLab