diff --git a/loopy/auto_test.py b/loopy/auto_test.py index db29d51307392d72eca2e381b0b9143964ddf6cf..537e65fb356295cb4370dc12d9f304da32d2298c 100644 --- a/loopy/auto_test.py +++ b/loopy/auto_test.py @@ -451,12 +451,12 @@ def auto_test_vs_ref( print(get_highlighted_code(ref_compiled.get_code())) print(75*"-") - ref_cl_kernel_info = ref_compiled.cl_kernel_info(frozenset()) + ref_kernel_info = ref_compiled.kernel_info(frozenset()) try: ref_args, ref_arg_data = \ make_ref_args(ref_sched_kernel, - ref_cl_kernel_info.implemented_data_info, + ref_kernel_info.implemented_data_info, ref_queue, parameters) ref_args["out_host"] = False except cl.RuntimeError as e: @@ -541,10 +541,10 @@ def auto_test_vs_ref( compiled = CompiledKernel(ctx, kernel) if args is None: - cl_kernel_info = compiled.cl_kernel_info(frozenset()) + kernel_info = compiled.kernel_info(frozenset()) args = make_args(kernel, - cl_kernel_info.implemented_data_info, + kernel_info.implemented_data_info, queue, ref_arg_data, parameters) args["out_host"] = False diff --git a/loopy/target/c/c_execution.py b/loopy/target/c/c_execution.py index a4562163a102413221fdf9f5a9aa80744b67dcfb..e6a1bd0d6c43c98a7db6b168d951a63e70806449 100644 --- a/loopy/target/c/c_execution.py +++ b/loopy/target/c/c_execution.py @@ -27,8 +27,7 @@ import cgen import os import subprocess -from loopy.execution import (KernelExecutorBase, _Kernels, - _KernelInfo, ExecutionWrapperGeneratorBase) +from loopy.execution import (KernelExecutorBase, _KernelInfo) from pytools import memoize_method import weakref diff --git a/test/test_c_execution.py b/test/test_c_execution.py new file mode 100644 index 0000000000000000000000000000000000000000..914e2a14401a999c91975536eddf9e5e71de8a00 --- /dev/null +++ b/test/test_c_execution.py @@ -0,0 +1,90 @@ +from __future__ import division, absolute_import, print_function + +__copyright__ = "Copyright (C) 2012 Andreas Kloeckner" + +__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 sys +import numpy as np +import loopy as lp +import pyopencl.clmath # noqa +import pyopencl.clrandom # noqa +import pytest + +import logging +logger = logging.getLogger(__name__) + +try: + import faulthandler +except ImportError: + pass +else: + faulthandler.enable() + + +def test_c_target(): + from loopy.target.c import CTarget + + knl = lp.make_kernel( + "{ [i]: 0<=i<n }", + "out[i] = 2*a[i]", + [ + lp.GlobalArg("out", np.float32, shape=lp.auto), + lp.GlobalArg("a", np.float32, shape=lp.auto), + "..." + ], + target=CTarget()) + + assert np.allclose(knl(a=np.arange(16, dtype=np.float32))[1], + 2 * np.arange(16, dtype=np.float32)) + + +def test_c_target_strides(): + from loopy.target.c import CTarget + + def __get_kernel(order='C'): + return lp.make_kernel( + "{ [i,j]: 0<=i,j<n }", + "out[i, j] = 2*a[i, j]", + [ + lp.GlobalArg("out", np.float32, shape=('n', 'n'), order=order), + lp.GlobalArg("a", np.float32, shape=('n', 'n'), order=order), + "..." + ], + target=CTarget()) + + + # test with C-order + knl = __get_kernel('C') + a_np = np.reshape(np.arange(16 * 16, dtype=np.float32), (16, -1), + order='C') + + assert np.allclose(knl(a=a_np)[1], + 2 * a_np) + + + # test with F-order + knl = __get_kernel('F') + a_np = np.reshape(np.arange(16 * 16, dtype=np.float32), (16, -1), + order='F') + + assert np.allclose(knl(a=a_np)[1], + 2 * a_np) diff --git a/test/test_loopy.py b/test/test_loopy.py index 1218847a7c42bd420a993d86a7534f066c2ab20e..8aaca0f6aad313ac57658c4da5a99aa33f1c0717 100644 --- a/test/test_loopy.py +++ b/test/test_loopy.py @@ -595,7 +595,7 @@ def test_vector_ilp_with_prefetch(ctx_factory): knl = lp.add_prefetch(knl, "a", ["i_inner", "i_outer_inner"]) cknl = lp.CompiledKernel(ctx, knl) - cknl.cl_kernel_info() + cknl.kernel_info() import re code = cknl.get_code()