Skip to content
Snippets Groups Projects
Commit 60cd3aad authored by Andreas Klöckner's avatar Andreas Klöckner
Browse files

Introduce a notion of 'scope' for temporary variables, in preparation for global temporaries

parent 8d294c35
No related branches found
No related tags found
No related merge requests found
...@@ -345,6 +345,8 @@ Temporary Variables ...@@ -345,6 +345,8 @@ Temporary Variables
Temporary variables model OpenCL's ``private`` and ``local`` address spaces. Both Temporary variables model OpenCL's ``private`` and ``local`` address spaces. Both
have the lifetime of a kernel invocation. have the lifetime of a kernel invocation.
.. autoclass:: temp_var_scope
.. autoclass:: TemporaryVariable .. autoclass:: TemporaryVariable
:members: :members:
:undoc-members: :undoc-members:
......
...@@ -42,7 +42,7 @@ from loopy.kernel.data import ( ...@@ -42,7 +42,7 @@ from loopy.kernel.data import (
ValueArg, GlobalArg, ConstantArg, ImageArg, ValueArg, GlobalArg, ConstantArg, ImageArg,
memory_ordering, memory_scope, VarAtomicity, AtomicInit, AtomicUpdate, memory_ordering, memory_scope, VarAtomicity, AtomicInit, AtomicUpdate,
InstructionBase, Assignment, ExpressionInstruction, CInstruction, InstructionBase, Assignment, ExpressionInstruction, CInstruction,
TemporaryVariable, temp_var_scope, TemporaryVariable,
SubstitutionRule) SubstitutionRule)
from loopy.kernel import LoopKernel, kernel_state from loopy.kernel import LoopKernel, kernel_state
...@@ -129,7 +129,7 @@ __all__ = [ ...@@ -129,7 +129,7 @@ __all__ = [
"memory_ordering", "memory_scope", "VarAtomicity", "memory_ordering", "memory_scope", "VarAtomicity",
"AtomicInit", "AtomicUpdate", "AtomicInit", "AtomicUpdate",
"ValueArg", "ScalarArg", "GlobalArg", "ArrayArg", "ConstantArg", "ImageArg", "ValueArg", "ScalarArg", "GlobalArg", "ArrayArg", "ConstantArg", "ImageArg",
"TemporaryVariable", "temp_var_scope", "TemporaryVariable",
"SubstitutionRule", "SubstitutionRule",
"InstructionBase", "Assignment", "ExpressionInstruction", "CInstruction", "InstructionBase", "Assignment", "ExpressionInstruction", "CInstruction",
......
...@@ -267,6 +267,19 @@ class ValueArg(KernelArgument): ...@@ -267,6 +267,19 @@ class ValueArg(KernelArgument):
# {{{ temporary variable # {{{ temporary variable
class temp_var_scope:
"""Storage location of a temporary
.. attribute:: PRIVATE
.. attribute:: LOCAL
.. attribute:: GLOBAL
"""
PRIVATE = 0
LOCAL = 1
GLOBAL = 2
class TemporaryVariable(ArrayBase): class TemporaryVariable(ArrayBase):
__doc__ = ArrayBase.__doc__ + """ __doc__ = ArrayBase.__doc__ + """
.. attribute:: storage_shape .. attribute:: storage_shape
...@@ -281,6 +294,8 @@ class TemporaryVariable(ArrayBase): ...@@ -281,6 +294,8 @@ class TemporaryVariable(ArrayBase):
The name of a storage array that is to be used to actually The name of a storage array that is to be used to actually
hold the data in this temporary. hold the data in this temporary.
.. autoattribute:: scope
""" """
min_target_axes = 0 min_target_axes = 0
...@@ -318,6 +333,15 @@ class TemporaryVariable(ArrayBase): ...@@ -318,6 +333,15 @@ class TemporaryVariable(ArrayBase):
storage_shape=storage_shape, storage_shape=storage_shape,
base_storage=base_storage) base_storage=base_storage)
@property
def scope(self):
"""One of :class:`loopy.temp_var_scope`."""
if self.is_local:
return temp_var_scope.LOCAL
else:
return temp_var_scope.PRIVATE
@property @property
def nbytes(self): def nbytes(self):
shape = self.shape shape = self.shape
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment