Skip to content
Snippets Groups Projects

Volatile-memory-accces OpenCL target

Merged Andreas Klöckner requested to merge volatile-opencl-target into master
2 files
+ 54
0
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 39
0
@@ -647,4 +647,43 @@ class OpenCLCASTBuilder(CASTBuilder):
# }}}
# {{{ volatile mem acccess target
class VolatileMemExpressionToOpenCLCExpressionMapper(
ExpressionToOpenCLCExpressionMapper):
def make_subscript(self, array, base_expr, subscript):
registry = self.codegen_state.ast_builder.target.get_dtype_registry()
from loopy.kernel.data import AddressSpace
if array.address_space == AddressSpace.GLOBAL:
aspace = "__global "
elif array.address_space == AddressSpace.GLOBAL:
aspace = "__local "
elif array.address_space == AddressSpace.PRIVATE:
aspace = ""
else:
raise ValueError("unexpected value of address space")
from pymbolic import var
return var(
"(%s volatile %s *) "
% (
registry.dtype_to_ctype(array.dtype),
aspace,
)
)(base_expr)[subscript]
class VolatileMemOpenCLCASTBuilder(OpenCLCASTBuilder):
def get_expression_to_c_expression_mapper(self, codegen_state):
return VolatileMemExpressionToOpenCLCExpressionMapper(codegen_state)
class VolatileMemOpenCLTarget(OpenCLTarget):
def get_device_ast_builder(self):
return VolatileMemOpenCLCASTBuilder(self)
# }}}
# vim: foldmethod=marker
Loading