libocca/occa.py

@okl.kernel

Closed this issue · 0 comments

Python OKL

Create ast parser to convert a restricted Python function to an OKL kernel

@okl.kernel
def add_vectors(a: [float],
                b: [float],
                ab: [float]):
    for i in okl.range(len(a)).tile(16):
      ab[i] = a[i] + b[i]

shorthand for

@okl.kernel
def add_vectors(a: [float],
                b: [float],
                ab: [float]):
    for block in okl.range(0, len(a), 16).outer:
        for i in okl.range(block, block + 16).inner:
            ab[i] = a[i] + b[i]

API

Have props be a restricted kwarg

add_vectors[device](a, b, ab, props={})
# or
add_vectors(a, b, ab, props={})