Home

Awesome

CLT - An OpenCL Toolkit

CLT is a toolkit that makes managing large-scale OpenCL codebases easier.

Features

Usage

  1. Add CLT as a git submodule, include clt.hpp
  2. Call clt::initialize() (or initialize OpenCL manually)
  3. Create a kernel class that extends clt::Kernel:
    class MyKernel : public clt::Kernel {
    public:
        MyKernel (void) : Kernel("kernel.cl", "mainFunc") {};
        std::string getAdditionalBuildOptions() override {
            return " -DCONFIG_POWER=" + std::to_string(global_variable);
        }
        void setArgs() override {
            setArg("input", inputArr);
            setArg("output", outputArr);
        }
        CLT_KERNEL_IMPL(
        kernel void mainFunc(global int* input, global int* output) {
            // Optional inline source, can also be read from file
            uint gid = get_global_id(0);
            output[gid] = pow(input[gid], CONFIG_POWER);
        })
    };
    
  4. Call mykernel.build()
  5. Call mykernel.rebuild() whenever configuration changes (only recompiled if needed)

See example/ for a usage example.
Check out Fluctus to see CLT in use in a large-scale OpenCL codebase.

Configuration

CLT can be configured to use cl.hpp instead of cl2.hpp (for compatibility with older projects). This is done by adding set(CLT_USE_LEGACY_HEADER ON CACHE BOOL " " FORCE) and add_definitions(-DCLT_CL_LEGACY_HEADER) to CMakeLists.txt

License

See the LICENSE file for license rights and limitations (MIT).