:loudspeaker: Annoucement
Python API released!
Check it out at [libocca/occa.py](https://github.com/libocca/occa.py) or install running
sh
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:
python
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]
↓
cpp
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
- [54f400321cf129f5cdc0768f53b1e4da8a3cd0fe] Added dtypes which can be optionally used for runtime type checking
- New class `occa::dtype_t`
- Optional typed `occa::memory` allocation
cpp
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
c
occaMalloc(10 * sizeof(float), NULL, occaDefault); // Regular malloc
occaTypedMalloc(10, occaDtypeFloat, NULL, occaDefault); // Typed malloc
- API for creating custom dtypes, for example:
cpp
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_);
- [994eb2a5fed533d16392b96465036a2c07fa1459] Added more kernel methods for the C API
c
void occaKernelPushArg(occaKernel kernel,
occaType arg);
void occaKernelClearArgs(occaKernel kernel);
void occaKernelRunFromArgs(occaKernel kernel);
void occaKernelVaRun(occaKernel kernel,
const int argc,
va_list args);
- [f6333f2c808ddd29399b1f7ea0def461050d9d0c] Custom kernel library paths, for example:
cpp
// Application code
occa::io::addLibraryPath("mylibrary", "./path/to/kernels/dir");
occa::io::addLibraryPath("mylibrary", "${MY_LIBRARY_DIR}");
// Kernel
include "occa://mylibrary/kernel.okl"
🐛 Bugs Fixed
- [0c975e18088df5495bc4d63f4f3000c5415cf9a0] Modes can run a check before registering themselves, letting badly installed OpenCL/CUDA/HIP become disabled at runtime
- [f5f0e81d271837b2132dc34c90bd4163ed58f95e] OpenCL in newer MacOS versions don't seem to support loading program binaries. We now avoid storing the binary in these cases