本文整理汇总了C++中CLKernel::run方法的典型用法代码示例。如果您正苦于以下问题:C++ CLKernel::run方法的具体用法?C++ CLKernel::run怎么用?C++ CLKernel::run使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CLKernel
的用法示例。
在下文中一共展示了CLKernel::run方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: exit
TEST(testqueues, defaultqueue) {
cout << "start" << endl;
if(!EasyCL::isOpenCLAvailable()) {
cout << "opencl library not found" << endl;
exit(-1);
}
cout << "found opencl library" << endl;
EasyCL *cl = EasyCL::createForFirstGpuOtherwiseCpu();
CLKernel *kernel = cl->buildKernelFromString(getKernel(), "test", "");
float in[5];
float out[5];
for(int i = 0; i < 5; i++) {
in[i] = i * 3;
out[i] = 0;
}
kernel->input(5, in);
kernel->output(5, out);
size_t global = 5;
size_t local = 5;
kernel->run(1, &global, &local);
cl->finish();
assertEquals(out[0] , 7);
assertEquals(out[1] , 10);
assertEquals(out[2] , 13);
assertEquals(out[3] , 16);
assertEquals(out[4] , 19);
for(int i = 0; i < 5; i++) {
in[i] = i * 3;
out[i] = 0;
}
cout << "cl->queue " << (void *)cl->queue << endl;
cout << "*cl->queue " << (void *)*cl->queue << endl;
cout << "cl->default_queue->queue" << (void *)cl->default_queue->queue << endl;
kernel->input(5, in);
kernel->output(5, out);
kernel->run(cl->default_queue, 1, &global, &local);
cl->finish();
assertEquals(out[0] , 7);
assertEquals(out[1] , 10);
assertEquals(out[2] , 13);
assertEquals(out[3] , 16);
assertEquals(out[4] , 19);
cout << "tests completed ok" << endl;
}
示例2: exit
TEST(testinout, main) {
if(!EasyCL::isOpenCLAvailable()) {
cout << "opencl library not found" << endl;
exit(-1);
}
cout << "found opencl library" << endl;
EasyCL *cl = EasyCL::createForFirstGpuOtherwiseCpu();
CLKernel *kernel = cl->buildKernelFromString(getKernel(), "test", "");
float inout[5];
for(int i = 0; i < 5; i++) {
inout[i] = i * 3;
}
kernel->inout(5, inout);
size_t global = 5;
size_t local = 5;
kernel->run(1, &global, &local);
assertEquals(inout[0] , 7);
assertEquals(inout[1] , 10);
assertEquals(inout[2] , 13);
assertEquals(inout[3] , 16);
assertEquals(inout[4] , 19);
cout << "tests completed ok" << endl;
delete kernel;
delete cl;
}
示例3: main
int main(int argc, char *argv[])
{
const int test_size = 128;
std::random_device rd;
std::seed_seq s{ rd(), rd(), rd(), rd(), rd(), rd(), rd(), rd() };
std::mt19937 mt(s);
EasyCL *cl = EasyCL::createForFirstGpuOtherwiseCpu();
CLKernel *kern = cl->buildKernel("test.cl", "test");
std::vector<uint32_t> inbuf(test_size*4), outbuf(test_size), compare(test_size);
std::generate(inbuf.begin(), inbuf.end(), mt);
std::cout << "Running CL implementation" << std::endl;
kern->in(inbuf.size(), &inbuf[0]);
kern->out(outbuf.size(), &outbuf[0]);
size_t global_size[] = { test_size };
kern->run(1, global_size, nullptr);
delete kern;
std::cout << "Running local implementation" << std::endl;
for (int i = 0; i < compare.size(); ++i) {
compare[i] = inbuf[i] ^ inbuf[i + 1] ^ inbuf[i + 2] ^ inbuf[i + 3];
}
std::cout << "Comparing CL test with local implementation" << std::endl;
for (int i = 0; i < compare.size(); ++i) {
if (outbuf[i] != compare[i]) {
std::cout << "Error in index " << i << " " << outbuf[i] << " != " << compare[i] << std::endl;
}
}
return 0;
}