Reference Guide
2.5.0
|
Public Member Functions | |
def | __init__ (self, skip_nodes=False, indent_string=" ", initial_indent_depth=0, kernels_local_size=1) |
def | gen_id_variable (self, symbol, dimension_index) |
def | gen_declaration (self, symbol) |
def | gen_array_length_variables (self, symbol, symtab=None) |
def | kernelschedule_node (self, node) |
Public Member Functions inherited from psyclone.psyir.backend.c.CWriter | |
def | gen_indices (self, indices, var_name=None) |
def | gen_local_variable (self, symbol) |
def | assignment_node (self, node) |
def | literal_node (self, node) |
def | ifblock_node (self, node) |
def | unaryoperation_node (self, node) |
def | binaryoperation_node (self, node) |
def | intrinsiccall_node (self, node) |
def | return_node (self, _) |
def | codeblock_node (self, _) |
def | loop_node (self, node) |
def | regiondirective_node (self, node) |
def | standalonedirective_node (self, node) |
def | filecontainer_node (self, node) |
Public Member Functions inherited from psyclone.psyir.backend.language_writer.LanguageWriter | |
def | __init__ (self, array_parenthesis, structure_character, skip_nodes=False, indent_string=" ", initial_indent_depth=0, check_global_constraints=True) |
def | array_parenthesis (self) |
def | structure_character (self) |
def | arrayreference_node (self, node) |
def | structurereference_node (self, node) |
def | member_node (self, node) |
def | arrayofstructuresreference_node (self, node) |
def | clause_node (self, node) |
Public Member Functions inherited from psyclone.psyir.backend.visitor.PSyIRVisitor | |
def | reference_node (self, node) |
def | __call__ (self, node) |
Implements a PSyIR-to-OpenCL back-end for the PSyIR AST. This writer produces OpenCL code conforming to Version 1.2 of the specification (https://www.khronos.org/registry/OpenCL/specs/opencl-1.2.pdf). :param bool skip_nodes: if skip_nodes is False then an exception \ is raised if a visitor method for a PSyIR node has not been \ implemented, otherwise the visitor silently continues. This is an \ optional argument which defaults to False. :param str indent_string: specifies what to use for indentation. This \ is an optional argument that defaults to two spaces. :param int initial_indent_depth: specifies how much indentation to \ start with. This is an optional argument that defaults to 0. :param int kernel_local_size: uses the given local_size when generating \ OpenCL kernels. :raises TypeError: if kernel_local_size is not an integer. :raises ValueError: if kernel_local_size is not positive.
def psyclone.psyir.backend.opencl.OpenCLWriter.gen_array_length_variables | ( | self, | |
symbol, | |||
symtab = None |
|||
) |
Generate length variable declaration and initialisation for each array dimension of the given symbol. By convention they are named: <name>LEN<DIM>, and initialised using the function: `size_t get_global_size(uint dimindx)`. :param symbol: The symbol instance. :type symbol: :py:class:`psyclone.psyir.symbols.DataSymbol` :param symtab: The symbol table from the given symbol context to \ check for name clashes. :type symtab: :py:class:`psyclone.psyir.symbols.SymbolTable` :return: OpenCL declaration and initialisation of length variables. :rtype: str :raises VisitorError: if the array length variable name clashes \ with another symbol name.
Definition at line 150 of file opencl.py.
References psyclone.psyir.backend.visitor.PSyIRVisitor._nindent().
def psyclone.psyir.backend.opencl.OpenCLWriter.gen_declaration | ( | self, | |
symbol | |||
) |
Generate the declaration of an OpenCL variable. This can be either a local variable or a routine argument, so no indention or punctuation is generated by this method. Memory buffers reside in specific levels of the memory hierarchy, and pointers are annotated with the region qualifiers __global, __local, __constant, and __private, reflecting this. At the moment all memory buffers (PSyIR arrays) are allocated at the global address space. :param symbol: The symbol instance. :type symbol: :py:class:`psyclone.psyir.symbols.DataSymbol` :returns: The OpenCL declaration of the given of the symbol. :rtype: str :raises VisitorError: if an array is encountered that does not have \ a lower bound of 1 for all of its dimensions.
Reimplemented from psyclone.psyir.backend.c.CWriter.
Definition at line 113 of file opencl.py.
def psyclone.psyir.backend.opencl.OpenCLWriter.gen_id_variable | ( | self, | |
symbol, | |||
dimension_index | |||
) |
Generate the declaration and initialisation of a variable identifying an OpenCL work-item. IDs are initialised by the OpenCL function: `size_t get_global_id(uint dimindx)` :param symbol: The symbol instance. :type symbol: :py:class:`psyclone.psyir.symbols.DataSymbol` :param int dimension_index: Dimension which the given symbol will \ iterate on. :returns: OpenCL declaration of an OpenCL id variable. :rtype: str :raises VisitorError: if symbol is not a scalar integer
Definition at line 86 of file opencl.py.
References psyclone.psyir.backend.visitor.PSyIRVisitor._nindent().
def psyclone.psyir.backend.opencl.OpenCLWriter.kernelschedule_node | ( | self, | |
node | |||
) |
This method is called when a KernelSchedule instance is found in the PSyIR tree. :param node: A KernelSchedule PSyIR node. :type node: :py:class:`psyclone.psyir.nodes.KernelSchedule` :returns: The OpenCL code as a string. :rtype: str :raises VisitorError: if a non-precision symbol is found with a \ UnresolvedInterface.
Definition at line 188 of file opencl.py.
References psyclone.psyir.backend.visitor.PSyIRVisitor._depth, psyclone.psyir.backend.opencl.OpenCLWriter._kernels_local_size, psyclone.psyir.backend.visitor.PSyIRVisitor._nindent(), psyclone.psyir.backend.visitor.PSyIRVisitor._visit(), psyclone.psyir.backend.opencl.OpenCLWriter.gen_array_length_variables(), psyclone.psyir.backend.c.CWriter.gen_declaration(), psyclone.psyir.backend.opencl.OpenCLWriter.gen_declaration(), psyclone.psyir.backend.opencl.OpenCLWriter.gen_id_variable(), and psyclone.psyir.backend.c.CWriter.gen_local_variable().