c++ - Running OpenCL under Windows 10 -
i want run opencl application under windows 10 using gtx970 graphics card. following code doesn't work =(
#define __cl_enable_exceptions #include <cl/cl.hpp> #include <cl/cl.h> #include <vector> #include <fstream> #include <iostream> #include <iomanip> int main() { std::vector<cl::platform> platforms; std::vector<cl::device> devices; try { cl::platform::get(&platforms); std::cout << platforms.size() << std::endl; (cl_uint = 0; < platforms.size(); ++i) { platforms[i].getdevices(cl_device_type_gpu, &devices); } std::cout << devices.size() << std::endl; } catch (cl::error e) { std::cout << std::endl << e.what() << " : " << e.err() << std::endl; } return 0; } it gives me error code -1. using visual studio 2015 community edition launch installed nvidia cuda sdk v8.0 , configured paths, compiler , linker knows sdk.
can please explain what's wrong snippet?
thanks in advance!
edit: can explain me, why when try debug code falls when getting platform id, however, when not debug code prints have 2 platforms(my gpu card , integerated gpu)
probably igpu intel(i assume did combo of gtx970 + intel cpu gaming) has experimental opencl 2.1 platform support give error opencl 1.2 app @ device picking or platform picking(i had similar problem).
you should check returned error codes opencl api commands. give better info happened.
for example, system has 2 platforms intel, 1 being experimental 2.1 cpu , 1 being normal 1.2 both gpu , cpu.
to check that, query platform version , check parameter-returned 7th , 9th char values against 1 , 2 1.2 or 2 , 0 2.0. should elliminate experimental 2.1 gives 2 @ 7th char , "1" @ 9th char (where indexing starts @ 0 ofcourse)
https://www.khronos.org/registry/cl/sdk/1.0/docs/man/xhtml/clgetplatforminfo.html
cl_platform_version
check both numpad number keycodes , left hand side numbers keycodes.
nvidia must have 1.2 support already.
if i'm right, may query cpu devices , have 2 intel , 1 nvidia(if has any) in return.
Comments
Post a Comment