From 01d36382ec4d67af04a4eade7008db107be8c053 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner <inform@tiker.net> Date: Tue, 17 May 2016 19:15:49 -0500 Subject: [PATCH] Don't use local classes in C AST (not picklable) --- loopy/target/c/__init__.py | 18 ++++++++++-------- loopy/version.py | 2 +- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/loopy/target/c/__init__.py b/loopy/target/c/__init__.py index d9f420405..493cef063 100644 --- a/loopy/target/c/__init__.py +++ b/loopy/target/c/__init__.py @@ -29,6 +29,7 @@ import six import numpy as np # noqa from loopy.target import TargetBase, ASTBuilderBase, DummyHostASTBuilder from loopy.diagnostic import LoopyError +from cgen import Pointer from pytools import memoize_method @@ -176,6 +177,12 @@ class CTarget(TargetBase): # }}} +class _ConstRestrictPointer(Pointer): + def get_decl_pair(self): + sub_tp, sub_decl = self.subdecl.get_decl_pair() + return sub_tp, ("*const restrict %s" % sub_decl) + + class CASTBuilder(ASTBuilderBase): # {{{ library @@ -238,12 +245,7 @@ class CASTBuilder(ASTBuilderBase): base_storage_to_scope = {} base_storage_to_align_bytes = {} - from cgen import ArrayOf, Pointer, Initializer, AlignedAttribute, Value, Line - - class ConstRestrictPointer(Pointer): - def get_decl_pair(self): - sub_tp, sub_decl = self.subdecl.get_decl_pair() - return sub_tp, ("*const restrict %s" % sub_decl) + from cgen import ArrayOf, Initializer, AlignedAttribute, Value, Line for tv in sorted( six.itervalues(kernel.temporary_variables), @@ -286,8 +288,8 @@ class CASTBuilder(ASTBuilderBase): # not use them to shovel data from one representation to the # other. That counts, right? - cast_decl = ConstRestrictPointer(cast_decl) - temp_var_decl = ConstRestrictPointer(temp_var_decl) + cast_decl = _ConstRestrictPointer(cast_decl) + temp_var_decl = _ConstRestrictPointer(temp_var_decl) cast_tp, cast_d = cast_decl.get_decl_pair() temp_var_decl = Initializer( diff --git a/loopy/version.py b/loopy/version.py index 7aaa9ca79..ce1cf3089 100644 --- a/loopy/version.py +++ b/loopy/version.py @@ -32,4 +32,4 @@ except ImportError: else: _islpy_version = islpy.version.VERSION_TEXT -DATA_MODEL_VERSION = "v31-islpy%s" % _islpy_version +DATA_MODEL_VERSION = "v32-islpy%s" % _islpy_version -- GitLab