You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A modern abstraction layer for creating OpenCL applications.
WIP ;)
The code is still WIP; major changes may happen to the structure and function signatures.
Example
Here I will give examples for how to use this library. Two CPP code sections are shown, see the long version for descriptions and examples of some extra functionality.
////CPP FILE
#include<clw_context.hpp>
#include<clw_vector.hpp>
#include<clw_function.hpp>
#include<vector>intmain(){
clw::context test_context; //Create context (device 0 is always selected for now)//Create array of int with 1 << 14 elements, and don't push to device (i.e GPU) memoryconstexprconstint size = 1 << 14;
clw::vector<int> data(test_context, size, false/*do not push to device on init.*/);
//Give each value in data a unqiue valuefor(int i = 0; i < size; ++i){
data[i] = i;
}
//Push data to device (i.e GPU) memory
data.push();
//Create a function (kernel) object from the function called run in file quick_test.cl
clw::function f(test_context, "path/to/quick_test.cl", "run", "#define SOME_RANDOM_STUFF");
//Run the function (kernel) f on the device (i.e GPU) with:// Global size (size, 0, 0) = (size, 1, 1)// Local size (32, 0, 0) = (32, 1, 1)// First parameter = data (the array defined previously)// Second parameter = size// Third parameter = 42
f.execute({size,0,0}, {32,0,0}, data, size, 42);
//Pull data into host memory
data.pull();
//Check if kernel executed correctlyfor(int i = 0; i < size; ++i){
if(data[i] != i + 42) return1;
}
return0;
}