Guest User

Hugh's OpenCL test snippet

a guest
Feb 5th, 2018
67
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <CL/cl.hpp>
  3. #include <vector>
  4. #include <string>
  5. using std::cout; using std::endl;
  6. using std::vector;
  7. using std::string;
  8.  
  9. int main(void)
  10. {
  11.     // query the number of platforms available to us
  12.     vector<cl::Platform> platforms;
  13.     cl::Platform::get(&platforms);
  14.  
  15.     // pick the first platform from the list
  16.     auto platform = platforms.front();
  17.  
  18.     // query the number of devices available to us
  19.     vector<cl::Device> devices;
  20.     platform.getDevices(CL_DEVICE_TYPE_ALL, &devices);
  21.  
  22.     // pick the first device from the list
  23.     auto device = devices.front();
  24.  
  25.     // get the name of the vendor
  26.     string vendor = device.getInfo<CL_DEVICE_VENDOR>();
  27.  
  28.     cout << vendor << endl;
  29.  
  30.     return 0;
  31. }
RAW Paste Data