From 112064d1d737924db4b275dbec98085cb42a70b5 Mon Sep 17 00:00:00 2001 From: "Timothy A. Smith" <tasmith4@illinois.edu> Date: Tue, 28 May 2019 23:54:02 -0500 Subject: [PATCH] cleanup and minor rearrangement --- kernel_fixtures.py | 6 ------ setup_fixtures.py | 1 + test.py | 1 - transform_fixtures.py | 37 +++++++++++++------------------------ 4 files changed, 14 insertions(+), 31 deletions(-) diff --git a/kernel_fixtures.py b/kernel_fixtures.py index c2b9f30..1ff71ac 100644 --- a/kernel_fixtures.py +++ b/kernel_fixtures.py @@ -1,11 +1,5 @@ -import numpy as np -import pyopencl as cl -import pyopencl.array # noqa import loopy as lp # noqa -import device_fixtures as device -import program_fixtures as program -import transform_fixtures as transform import setup_fixtures as setup diff --git a/setup_fixtures.py b/setup_fixtures.py index 255adfc..bcecb9e 100644 --- a/setup_fixtures.py +++ b/setup_fixtures.py @@ -1,5 +1,6 @@ import numpy as np import pyopencl as cl +import pyopencl.array # noqa import device_fixtures as device diff --git a/test.py b/test.py index 8e883b8..146e052 100644 --- a/test.py +++ b/test.py @@ -39,7 +39,6 @@ def test_compute_flux_derivatives(ctx_factory): def test_compute_flux_derivatives_gpu(ctx_factory): queue = device.get_queue(ctx_factory) prg = program.get_weno() - prg = transform.weno_for_gpu(prg) prg = transform.compute_flux_derivative_gpu(queue, prg) params = setup.flux_derivative_params(ndim=3, nvars=5, n=10) diff --git a/transform_fixtures.py b/transform_fixtures.py index a985e97..f69581a 100644 --- a/transform_fixtures.py +++ b/transform_fixtures.py @@ -16,28 +16,10 @@ def compute_flux_derivative_basic(prg): return prg.with_kernel(cfd) -def compute_flux_derivative_gpu(queue, prg): - prg = prg.copy(target=lp.PyOpenCLTarget(queue.device)) - - if 1: - with open("gen-code.cl", "w") as outf: - outf.write(lp.generate_code_v2(prg).device_code()) - - prg = lp.set_options(prg, no_numpy=True) - return prg - - def weno_for_gpu(prg): - cfd = prg["compute_flux_derivatives"] + prg = compute_flux_derivative_basic(prg) - cfd = lp.assume(cfd, "nx > 0 and ny > 0 and nz > 0") - - cfd = lp.set_temporary_scope(cfd, "flux_derivatives_generalized", - lp.AddressSpace.GLOBAL) - cfd = lp.set_temporary_scope(cfd, "generalized_fluxes", - lp.AddressSpace.GLOBAL) - cfd = lp.set_temporary_scope(cfd, "weno_flux_tmp", - lp.AddressSpace.GLOBAL) + cfd = prg["compute_flux_derivatives"] for suffix in ["", "_1", "_2", "_3", "_4", "_5", "_6", "_7"]: cfd = lp.split_iname(cfd, "i"+suffix, 16, @@ -70,7 +52,14 @@ def weno_for_gpu(prg): return prg -def get_gpu_transformed_weno(): - import program_fixtures as program - prg = program.get_weno() - return weno_for_gpu(prg) +def compute_flux_derivative_gpu(queue, prg): + prg = weno_for_gpu(prg) + + prg = prg.copy(target=lp.PyOpenCLTarget(queue.device)) + + if 1: + with open("gen-code.cl", "w") as outf: + outf.write(lp.generate_code_v2(prg).device_code()) + + prg = lp.set_options(prg, no_numpy=True) + return prg -- GitLab