From 523111f4509aa1ce09b22fe15b15b8ec34550daf Mon Sep 17 00:00:00 2001 From: Nick Date: Wed, 15 Aug 2018 14:53:03 -0400 Subject: [PATCH 1/2] ensure to_loopy_type returns a dtype with correct target set, if specified --- loopy/types.py | 3 +++ test/test_loopy.py | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/loopy/types.py b/loopy/types.py index 8f0f310c3..7deb7608d 100644 --- a/loopy/types.py +++ b/loopy/types.py @@ -211,6 +211,9 @@ def to_loopy_type(dtype, allow_auto=False, allow_none=False, for_atomic=False, raise LoopyError("do not know how to convert '%s' to an atomic type" % dtype) + if target and not dtype.target: + return dtype.with_target(target) + return dtype elif numpy_dtype is not None: diff --git a/test/test_loopy.py b/test/test_loopy.py index accf9c1df..9bc4aeaca 100644 --- a/test/test_loopy.py +++ b/test/test_loopy.py @@ -2908,6 +2908,14 @@ def test_dep_cycle_printing_and_error(): print(lp.generate_code(knl)[0]) +def test_to_loopy_type_target_specification(): + arg = lp.GlobalArg('test', dtype=np.int32, shape=(1,)) + # convert dtype w/ to_loopy_type + from loopy.types import to_loopy_type + assert to_loopy_type(arg.dtype, target=lp.OpenCLTarget()).target == \ + lp.OpenCLTarget() + + if __name__ == "__main__": if len(sys.argv) > 1: exec(sys.argv[1]) -- GitLab From 2667aa671d8aee25d1664a0e58fb6568d4adfdd2 Mon Sep 17 00:00:00 2001 From: Nick Date: Mon, 12 Nov 2018 14:04:24 -0500 Subject: [PATCH 2/2] flake --- test/test_loopy.py | 1 - 1 file changed, 1 deletion(-) diff --git a/test/test_loopy.py b/test/test_loopy.py index 65908bea3..3fb1316ee 100644 --- a/test/test_loopy.py +++ b/test/test_loopy.py @@ -2935,7 +2935,6 @@ def test_to_loopy_type_target_specification(): lp.OpenCLTarget() - if __name__ == "__main__": if len(sys.argv) > 1: exec(sys.argv[1]) -- GitLab