diff --git a/benchmark/benchmark.py b/benchmark/benchmark.py new file mode 100644 index 0000000000000000000000000000000000000000..935b717d9d769f707aa18610ccb59e44a1bcf8f8 --- /dev/null +++ b/benchmark/benchmark.py @@ -0,0 +1,181 @@ +__copyright__ = "Copyright (C) 2019 Andreas Kloeckner, Timothy A. Smith" + +__license__ = """ +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +""" + +import numpy as np # noqa: F401 +import numpy.linalg as la # noqa: F401 +import pyopencl as cl +import pyopencl.array # noqa +import pyopencl.tools # noqa +import pyopencl.clrandom # noqa +import loopy as lp # noqa +import sys + +import logging + + +_WENO_PRG = {} + +project_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + + +def get_queue(ctx_factory): + return cl.CommandQueue(ctx_factory()) + + +def get_weno_program(): + def parse_weno(): + fn = os.path.join(project_root, "WENO.F90") + + with open(fn, "r") as infile: + infile_content = infile.read() + + prg = lp.parse_transformed_fortran(infile_content, filename=fn) + _WENO_PRG["default"] = prg + + + if not _WENO_PRG: + parse_weno() + return _WENO_PRG["default"] + + +def transform_weno_for_gpu(prg, print_kernel=False): + knl = prg["compute_flux_derivatives"] + + for suffix in ["", "_1", "_2", "_3", "_4", "_5"]: + knl = lp.split_iname(knl, "i"+suffix, 16, + outer_tag="g.0", inner_tag="l.0") + knl = lp.split_iname(knl, "j"+suffix, 16, + outer_tag="g.1", inner_tag="l.1") + + knl = lp.add_barrier(knl, "tag:flux_x_compute", "tag:flux_x_diff") + knl = lp.add_barrier(knl, "tag:flux_x_diff", "tag:flux_y_compute") + knl = lp.add_barrier(knl, "tag:flux_y_compute", "tag:flux_y_diff") + knl = lp.add_barrier(knl, "tag:flux_y_diff", "tag:flux_z_compute") + knl = lp.add_barrier(knl, "tag:flux_z_compute", "tag:flux_z_diff") + + prg = prg.with_kernel(knl) + + if print_kernel: + print(prg["convert_to_generalized_frozen"]) + 1/0 + + return prg + + +def empty_array_on_device(queue, *shape): + return cl.array.empty(queue, shape, dtype=np.float64, order="F") + + +def random_array_on_device(queue, *shape): + ary = empty_array_on_device(queue, *shape) + cl.clrandom.fill_rand(ary) + return ary + + +def write_target_device_code(prg, outfilename="gen-code.cl"): + with open(outfilename, "w") as outf: + outf.write(lp.generate_code_v2(prg).device_code()) + + +def benchmark_compute_flux_derivatives_gpu(ctx_factory, write_code=False): + logging.basicConfig(level="INFO") + + prg = get_weno_program() + prg = transform_weno_for_gpu(prg) + + queue = get_queue(ctx_factory) + prg = prg.copy(target=lp.PyOpenCLTarget(queue.device)) + prg = lp.set_options(prg, no_numpy=True) + prg = lp.set_options(prg, ignore_boostable_into=True) + #prg = lp.set_options(prg, write_wrapper=True) + #op_map = lp.get_op_map(prg, count_redundant_work=False) + #print(op_map) + + ndim = 3 + nvars = 5 + n = 16*16 + nx = n + ny = n + nz = n + + print("ARRAY GEN") + states = random_array_on_device(queue, nvars, nx+6, ny+6, nz+6) + fluxes = random_array_on_device(queue, nvars, ndim, nx+6, ny+6, nz+6) + metrics = random_array_on_device(queue, ndim, ndim, nx+6, ny+6, nz+6) + metric_jacobians = random_array_on_device(queue, nx+6, ny+6, nz+6) + print("END ARRAY GEN") + + flux_derivatives_dev = empty_array_on_device( + queue, nvars, ndim, nx+6, ny+6, nz+6) + + if write_code: + write_target_device_code(prg) + + allocator = pyopencl.tools.MemoryPool(pyopencl.tools.ImmediateAllocator(queue)) + + from functools import partial + run = partial(prg, queue, nvars=nvars, ndim=ndim, + states=states, fluxes=fluxes, metrics=metrics, + metric_jacobians=metric_jacobians, + flux_derivatives=flux_derivatives_dev, + allocator=allocator) + + # {{{ monkeypatch enqueue_nd_range_kernel to trace + + if 0: + old_enqueue_nd_range_kernel = cl.enqueue_nd_range_kernel + + def enqueue_nd_range_kernel_wrapper(queue, ker, *args, **kwargs): + print(f"Enqueueing {ker.function_name}") + return old_enqueue_nd_range_kernel(queue, ker, *args, **kwargs) + + cl.enqueue_nd_range_kernel = enqueue_nd_range_kernel_wrapper + + # }}} + + print("warmup") + for iwarmup_round in range(2): + run() + + nrounds = 10 + + queue.finish() + print("timing") + from time import time + start = time() + + for iround in range(nrounds): + run() + + queue.finish() + one_round = (time() - start)/nrounds + + print(f"M RHSs/s: {ndim*nvars*n**3/one_round/1e6}") + print(f"elapsed per round: {one_round} s") + print(f"Output size: {flux_derivatives_dev.nbytes/1e6} MB") + + +if __name__ == "__main__": + if len(sys.argv) > 1: + exec(sys.argv[1]) + else: + benchmark_compute_flux_derivatives_gpu(cl._csc) diff --git a/test/benchmark.py b/test/benchmark.py deleted file mode 100644 index cf49ddd6ffe56868d1ee7b3ea26458522209a3e3..0000000000000000000000000000000000000000 --- a/test/benchmark.py +++ /dev/null @@ -1,97 +0,0 @@ -import numpy as np # noqa: F401 -import numpy.linalg as la # noqa: F401 -import pyopencl as cl -import pyopencl.array # noqa -import pyopencl.tools # noqa -import pyopencl.clrandom # noqa -import loopy as lp # noqa -import sys - -import logging - -import utilities as u - - -def benchmark_compute_flux_derivatives_gpu(ctx_factory, write_code=False): - logging.basicConfig(level="INFO") - - prg = u.get_weno_program() - prg = u.transform_weno_for_gpu(prg) - - queue = u.get_queue(ctx_factory) - prg = prg.copy(target=lp.PyOpenCLTarget(queue.device)) - prg = lp.set_options(prg, no_numpy=True) - prg = lp.set_options(prg, ignore_boostable_into=True) - #prg = lp.set_options(prg, write_wrapper=True) - #op_map = lp.get_op_map(prg, count_redundant_work=False) - #print(op_map) - - ndim = 3 - nvars = 5 - n = 16*16 - nx = n - ny = n - nz = n - - print("ARRAY GEN") - states = u.random_array_on_device(queue, nvars, nx+6, ny+6, nz+6) - fluxes = u.random_array_on_device(queue, nvars, ndim, nx+6, ny+6, nz+6) - metrics = u.random_array_on_device(queue, ndim, ndim, nx+6, ny+6, nz+6) - metric_jacobians = u.random_array_on_device(queue, nx+6, ny+6, nz+6) - print("END ARRAY GEN") - - flux_derivatives_dev = u.empty_array_on_device( - queue, nvars, ndim, nx+6, ny+6, nz+6) - - if write_code: - u.write_target_device_code(prg) - - allocator = pyopencl.tools.MemoryPool(pyopencl.tools.ImmediateAllocator(queue)) - - from functools import partial - run = partial(prg, queue, nvars=nvars, ndim=ndim, - states=states, fluxes=fluxes, metrics=metrics, - metric_jacobians=metric_jacobians, - flux_derivatives=flux_derivatives_dev, - allocator=allocator) - - # {{{ monkeypatch enqueue_nd_range_kernel to trace - - if 0: - old_enqueue_nd_range_kernel = cl.enqueue_nd_range_kernel - - def enqueue_nd_range_kernel_wrapper(queue, ker, *args, **kwargs): - print(f"Enqueueing {ker.function_name}") - return old_enqueue_nd_range_kernel(queue, ker, *args, **kwargs) - - cl.enqueue_nd_range_kernel = enqueue_nd_range_kernel_wrapper - - # }}} - - print("warmup") - for iwarmup_round in range(2): - run() - - nrounds = 10 - - queue.finish() - print("timing") - from time import time - start = time() - - for iround in range(nrounds): - run() - - queue.finish() - one_round = (time() - start)/nrounds - - print(f"M RHSs/s: {ndim*nvars*n**3/one_round/1e6}") - print(f"elapsed per round: {one_round} s") - print(f"Output size: {flux_derivatives_dev.nbytes/1e6} MB") - - -if __name__ == "__main__": - if len(sys.argv) > 1: - exec(sys.argv[1]) - else: - benchmark_compute_flux_derivatives_gpu(cl._csc) diff --git a/test/conftest.py b/test/conftest.py index de6aa263f57f11eab184eb487a2e9707e84d25ba..32cf14b15f509f2a1b12292054c42bd09172890f 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -1,3 +1,28 @@ +__copyright__ = """ +Copyright (C) 2010-2019 Timothy A. Smith, Andreas Kloeckner, +Holger Krekel and pytest-dev team +""" + +__license__ = """ +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +""" + import pytest import pyopencl as cl # noqa: F401 from pyopencl.tools import ( @@ -9,9 +34,9 @@ import utilities as u # {{{ mark for slow tests -# setup to mark slow tests with @pytest.mark.slow, so that they don't run by +# Setup to mark slow tests with @pytest.mark.slow, so that they don't run by # default, but can be forced to run with the command-line option --runslow -# taken from +# Taken from # https://docs.pytest.org/en/latest/example/simple.html#control-skipping-of-tests-according-to-command-line-option def pytest_addoption(parser): @@ -32,6 +57,9 @@ def pytest_collection_modifyitems(config, items): # {{{ pytest_generate_tests +# pytest_generate_tests borrows heavily from +# pyopencl.tools.pytest_generate_tests_for_pyopencl + def pytest_generate_tests(metafunc): class ContextFactory: def __init__(self, device): diff --git a/test/data_for_test.py b/test/data_for_test.py index 8a8f47429ce1f2a8c1cfaa94d30330f78d082dad..3bba73debd927eb3fd65b504cbf0f5bf494ecfe8 100644 --- a/test/data_for_test.py +++ b/test/data_for_test.py @@ -1,3 +1,25 @@ +__copyright__ = "Copyright (C) 2019 Timothy A. Smith" + +__license__ = """ +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +""" + import numpy as np import pytest import utilities as u diff --git a/test/ideal_gas.py b/test/ideal_gas.py index 12b8c0011fd7ebb961e60e9d7666dbaccf9a1848..a062acb14260e027962b5d6bbb96b200233f8764 100644 --- a/test/ideal_gas.py +++ b/test/ideal_gas.py @@ -1,3 +1,25 @@ +__copyright__ = "Copyright (C) 2019 Timothy A. Smith" + +__license__ = """ +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +""" + import numpy as np import numpy.linalg as la # noqa: F401 import pyopencl as cl # noqa: F401 diff --git a/test/test_eigensystem.py b/test/test_eigensystem.py index 84d03bdc9bc6ae2689b681b874b9f967bf3f1888..bc7df0a0e44a89b1cf3451576be91ed1c4ecf23a 100644 --- a/test/test_eigensystem.py +++ b/test/test_eigensystem.py @@ -1,3 +1,25 @@ +__copyright__ = "Copyright (C) 2019 Timothy A. Smith" + +__license__ = """ +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +""" + import numpy as np import numpy.linalg as la # noqa: F401 import pyopencl as cl # noqa: F401 diff --git a/test/test_flux_derivatives.py b/test/test_flux_derivatives.py index 252fa5205b66c61757fb6d9e099f16389794d687..33b84303b3af166d13feb0970890d9b7c5e2c63f 100644 --- a/test/test_flux_derivatives.py +++ b/test/test_flux_derivatives.py @@ -1,3 +1,25 @@ +__copyright__ = "Copyright (C) 2019 Timothy A. Smith" + +__license__ = """ +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +""" + import numpy as np import numpy.linalg as la # noqa: F401 import pyopencl as cl # noqa: F401 @@ -41,33 +63,6 @@ def test_compute_flux_derivatives_uniform_grid(queue, cfd_test_data_fixture): u.compare_arrays(flux_derivatives_dev.get(), data.flux_derivatives) -@pytest.mark.slow -def test_compute_flux_derivatives(ctx_factory): - prg = u.get_weno_program() - - queue = u.get_queue(ctx_factory) - prg = prg.copy(target=lp.PyOpenCLTarget(queue.device)) - - lp.auto_test_vs_ref(prg, ctx_factory(), warmup_rounds=0, - parameters=dict(ndim=3, nvars=5, nx=16, ny=16, nz=16, d=0)) - - -@pytest.mark.slow -def test_compute_flux_derivatives_gpu(ctx_factory, write_code=False): - prg = u.get_weno_program() - prg = u.transform_weno_for_gpu(prg) - - queue = u.get_queue(ctx_factory) - prg = prg.copy(target=lp.PyOpenCLTarget(queue.device)) - prg = lp.set_options(prg, no_numpy=True) - - if write_code: - u.write_target_device_code(prg) - - lp.auto_test_vs_ref(prg, ctx_factory(), warmup_rounds=0, - parameters=dict(ndim=3, nvars=5, nx=16, ny=16, nz=16, d=0)) - - # This lets you run 'python test.py test_case(cl._csc)' without pytest. if __name__ == "__main__": if len(sys.argv) > 1: diff --git a/test/test_weno_flux.py b/test/test_weno_flux.py index 4a4d6822e7e8e7bca05d1466b6c344c408287b1d..40f9b2f5636e0ba833b7c257a4bcf7f84b6b3cb4 100644 --- a/test/test_weno_flux.py +++ b/test/test_weno_flux.py @@ -1,3 +1,25 @@ +__copyright__ = "Copyright (C) 2019 Timothy A. Smith" + +__license__ = """ +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +""" + import numpy as np import numpy.linalg as la # noqa: F401 import pyopencl as cl # noqa: F401 diff --git a/test/utilities.py b/test/utilities.py index dbfcc25ee5fc3697463491f0f7e22b9189ba8fc2..f69fb0f23f19bac57751a6f352616c7895b43f75 100644 --- a/test/utilities.py +++ b/test/utilities.py @@ -1,3 +1,25 @@ +__copyright__ = "Copyright (C) 2019 Timothy A. Smith" + +__license__ = """ +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +""" + import numpy as np import numpy.linalg as la # noqa: F401 import pyopencl as cl @@ -128,35 +150,6 @@ def get_weno_program_with_root_kernel(knl): setup_weno_program_with_root_kernel(knl) return _WENO_PRG[knl] - -def transform_weno_for_gpu(prg, print_kernel=False): - knl = prg["compute_flux_derivatives"] - - for suffix in ["", "_1", "_2", "_3", "_4", "_5"]: - knl = lp.split_iname(knl, "i"+suffix, 16, - outer_tag="g.0", inner_tag="l.0") - knl = lp.split_iname(knl, "j"+suffix, 16, - outer_tag="g.1", inner_tag="l.1") - - knl = lp.add_barrier(knl, "tag:flux_x_compute", "tag:flux_x_diff") - knl = lp.add_barrier(knl, "tag:flux_x_diff", "tag:flux_y_compute") - knl = lp.add_barrier(knl, "tag:flux_y_compute", "tag:flux_y_diff") - knl = lp.add_barrier(knl, "tag:flux_y_diff", "tag:flux_z_compute") - knl = lp.add_barrier(knl, "tag:flux_z_compute", "tag:flux_z_diff") - - prg = prg.with_kernel(knl) - - if print_kernel: - print(prg["convert_to_generalized_frozen"]) - 1/0 - - return prg - - -def write_target_device_code(prg, outfilename="gen-code.cl"): - with open(outfilename, "w") as outf: - outf.write(lp.generate_code_v2(prg).device_code()) - # }}} # vim: foldmethod=marker diff --git a/test/weno_reference_implementation.py b/test/weno_reference_implementation.py index b4cd3d88e965f5d5f26b3fb8bf413a7dcc8e52b5..bd4f7bcf7f62521eb9229a50a48ca262c6b69900 100644 --- a/test/weno_reference_implementation.py +++ b/test/weno_reference_implementation.py @@ -1,3 +1,25 @@ +__copyright__ = "Copyright (C) 2019 Timothy A. Smith" + +__license__ = """ +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +""" + import numpy as np import numpy.linalg as la # noqa: F401 import pyopencl as cl # noqa: F401