v1.0.8
📢 Annoucement
Python API released!
Check it out at libocca/occa.py or install running
pip install occa
- Most of the core API is ported to Python
- Numpy arrays are used seamlessly with
occa.memory
objects - First steps to supporting JIT-compiled Python functions as OKL kernels:
@okl.kernel
def py_add_vectors(a: Const[List[np.float32]],
b: Const[List[np.float32]],
ab: List[np.float32]) -> None:
for i in okl.range(entries).tile(16):
ab[i] = a[i] + b[i]
↓
@kernel void py_add_vectors(const float *a,
const float *b,
float *ab) {
for (int i = 0; i < entries; ++i; @tile(16, @outer, @inner)) {
ab[i] = a[i] + b[i];
}
}
⭐️ Features
-
[54f4003] Added dtypes which can be optionally used for runtime type checking
- New class
occa::dtype_t
- Optional typed
occa::memory
allocation
occa::malloc(10 * sizeof(float)); // Regular malloc occa::malloc(10, occa::dtype::float_); // Typed malloc occa::malloc(10, occa::dtype::get<float>()); // Templated typed malloc
occaMalloc(10 * sizeof(float), NULL, occaDefault); // Regular malloc occaTypedMalloc(10, occaDtypeFloat, NULL, occaDefault); // Typed malloc
- API for creating custom dtypes, for example:
occa::dtype_t vec3; // { float x, y, z } vec3.addField("x", occa::dtype::float_); vec3.addField("y", occa::dtype::float_); vec3.addField("z", occa::dtype::float_);
- New class
-
[994eb2a] Added more kernel methods for the C API
void occaKernelPushArg(occaKernel kernel, occaType arg); void occaKernelClearArgs(occaKernel kernel); void occaKernelRunFromArgs(occaKernel kernel); void occaKernelVaRun(occaKernel kernel, const int argc, va_list args);
-
[f6333f2] Custom kernel library paths, for example:
// Application code occa::io::addLibraryPath("mylibrary", "./path/to/kernels/dir"); occa::io::addLibraryPath("mylibrary", "${MY_LIBRARY_DIR}"); // Kernel #include "occa://mylibrary/kernel.okl"