Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/e253/zig-ocl
Zig package for the OpenCL ICD Loader
https://github.com/e253/zig-ocl
Last synced: 29 days ago
JSON representation
Zig package for the OpenCL ICD Loader
- Host: GitHub
- URL: https://github.com/e253/zig-ocl
- Owner: e253
- Created: 2024-06-15T08:24:12.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-06-15T08:30:38.000Z (6 months ago)
- Last Synced: 2024-08-03T23:23:40.977Z (4 months ago)
- Language: Zig
- Homepage:
- Size: 4.88 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-zig - e253/zig-ocl
README
### Zig Build for the OpenCL ICD Loader
This project builds the [OpenCL ICD](https://github.com/KhronosGroup/OpenCL-ICD-Loader) with the Zig Build System. The OpenCL ICD takes care of finding appropriate drivers across different hardware and operating systems.
Traditionally, you install the ICD on your system with `sudo apt install ocl-icd-opencl-dev` and use `$(CC) ... -lOpenCL` to build your program.
This is not desirable becuase the linking is dynamic against `libOpenCL.so`.
Static linking with zig provides better portability and reliability.
### Usage
Add the right release to your `build.zig.zon`
```
zig fetch --save https://github.com/e253/zig-ocl/archive/refs/tags/v3.0.16.tar.gz
```and add the following to your `build.zig`
```zig
pub fn build(b: *std.Build) void {
const ocl_icd = b.dependency("zig-ocl", .{
.target = target,
.optimize = optimize
});
your_compilation.linkLibrary(ocl_icd.artifact("opencl"));
}
```Also, see how `test.c` is built in the `build.zig` of this repository.
### Supported Platforms
Tested on
- [x] Windows
- [x] Linux (Ubuntu 22.04 WSL)
- [ ] MacOS