opencl_backend.py 596 Bytes
Newer Older
Stephan Seitz's avatar
Stephan Seitz committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
from pystencils.backends.cuda_backend import CudaBackend
from pystencils.backends.cbackend import generate_c
from pystencils.astnodes import Node

def generate_opencl(astnode: Node, signature_only: bool = False) -> str:
    """Prints an abstract syntax tree node as CUDA code.

    Args:
        astnode: KernelFunction node to generate code for
        signature_only: if True only the signature is printed

    Returns:
        C-like code for the ast node and its descendants
    """
    return generate_c(astnode, signature_only, dialect='opencl')


class OpenCLBackend(CudaBackend):
    pass