OpenCL-Wrapper  by ProjectPhysX

Lightweight OpenCL wrapper for simplified C++ development

created 3 years ago
415 stars

Top 71.7% on sourcepulse

GitHubView on GitHub
Project Summary

This project provides a C++ wrapper for OpenCL, aiming to simplify development by abstracting away boilerplate code and common complexities. It targets C++ developers who need to leverage GPU acceleration via OpenCL but find the native C++ bindings cumbersome. The wrapper offers a more streamlined API for device selection, memory management, and kernel execution, potentially reducing development time and improving code readability.

How It Works

The wrapper simplifies OpenCL by providing high-level C++ objects for Device, Memory, and Kernel. Device handles platform and device selection, including automatic compilation of embedded OpenCL C code and device-specific workarounds. Memory unifies host and device memory management, simplifying data transfers and tracking memory usage. Kernel abstracts kernel parameter linking and execution, allowing for chained calls and automatic error checking against parameter mismatches. OpenCL C code is embedded directly within C++ source files using a stringification macro, preserving syntax highlighting and simplifying the build process.

Quick Start & Requirements

  • Install: Compile with make.sh (Linux/macOS/Android) or open OpenCL-Wrapper.sln in Visual Studio Community (Windows).
  • Prerequisites: C++17 compiler (g++ >= 8), GPU drivers with OpenCL runtime installed. Detailed OS-specific driver installation instructions are provided for Windows, Linux, and Android.
  • Setup: Requires installing GPU drivers and OpenCL runtimes, which can be time-consuming depending on the OS and hardware.
  • Links: Official Documentation

Highlighted Details

  • Simplifies device selection (e.g., fastest device, most memory).
  • Unified host/device memory management with automatic zero-copy for CPUs/iGPUs.
  • Embedded OpenCL C code with syntax highlighting and simplified stringification.
  • Includes numerous device-specific workarounds and patches for cross-compatibility.
  • Example usage demonstrates a significant reduction in code lines compared to native OpenCL C++ bindings.

Maintenance & Community

The project is maintained by ProjectPhysX. No specific community channels (Discord, Slack) or roadmap are explicitly mentioned in the README.

Licensing & Compatibility

The project appears to be licensed under the MIT License, which is permissive for commercial use and closed-source linking.

Limitations & Caveats

The README notes that unbalanced round brackets () and arbitrarily long string literals within the embedded OpenCL C code require specific handling using the )+R( syntax. Preprocessor replacement macros within the embedded code are not supported and must be passed as arguments to the Device constructor.

Health Check
Last commit

3 weeks ago

Responsiveness

Inactive

Pull Requests (30d)
0
Issues (30d)
0
Star History
21 stars in the last 90 days

Explore Similar Projects

Starred by Andrej Karpathy Andrej Karpathy(Founder of Eureka Labs; Formerly at Tesla, OpenAI; Author of CS 231n), Georgios Konstantopoulos Georgios Konstantopoulos(CTO, General Partner at Paradigm), and
7 more.

ThunderKittens by HazyResearch

0.6%
3k
CUDA kernel framework for fast deep learning primitives
created 1 year ago
updated 6 days ago
Starred by Andrej Karpathy Andrej Karpathy(Founder of Eureka Labs; Formerly at Tesla, OpenAI; Author of CS 231n), Georgios Konstantopoulos Georgios Konstantopoulos(CTO, General Partner at Paradigm), and
2 more.

gpu.cpp by AnswerDotAI

0.2%
4k
C++ library for portable GPU computation using WebGPU
created 1 year ago
updated 2 weeks ago
Feedback? Help us improve.