Skip to content

Instantly share code, notes, and snippets.

@cacharle
Created May 15, 2020 16:43
Show Gist options
  • Save cacharle/29752078050396ef0339c5b8fe0ef56a to your computer and use it in GitHub Desktop.
Save cacharle/29752078050396ef0339c5b8fe0ef56a to your computer and use it in GitHub Desktop.
opencl test
__kernel void function(__global char *data)
{
data[0] = 'H';
data[1] = 'e';
data[2] = 'l';
data[3] = 'l';
data[4] = 'o';
data[5] = '\n';
data[6] = '\0';
}
#include <vector>
#include <iostream>
#include <fstream>
#include <CL/cl.hpp>
int main()
{
std::vector<cl::Platform> platforms;
cl::Platform::get(&platforms);
std::cout << platforms.size() << std::endl;
for (auto p : platforms)
{
std::vector<cl::Device> devices;
p.getDevices(CL_DEVICE_TYPE_ALL, &devices);
std::cout << devices.size() << std::endl;
for (auto device : devices)
{
auto vendor = device.getInfo<CL_DEVICE_VENDOR>();
auto version = device.getInfo<CL_DEVICE_VERSION>();
std::cout << vendor << std::endl;
std::cout << version << std::endl;
}
std::cout << std::endl;
}
// std::ifstream kernelFile("kernel.cl");
// std::string src(std::ifstreambuf_iterator<char>(kernelFile),
// std::ifstreambuf_iterator<char>(kernelFile.end()));
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment