使用事件在opencl中乱序执行
我是opencl编程范式的新手,所以如果我做的不好,请多多包涵。 我试图创建一个std :: vector并在enququemigratemem和enquuekernel中使用它,但是它要么因无效事件而失败,要么CPU仿真失败。
// defined the events variables as global variables
cl::Event new_event;
std::vector<cl::Event> write_event(3);
std::vector<cl::Event> read_event(3);
// in a allocator function I am pushing the new event in here
A()
{
for (int i = 0 ; i < 2 ; i++){
(write_event).push_back(new_event);
(read_event).push_back(new_event);
}
}
// top function calling the kernel function.
top()
{
for(i=0;i,50;i++)
{
func1()
}
}
// actual exectuion
func1()
{
cl_int err;
int falgs = k%2+1;
for(int i=0;i<N;i++)
{
S[i] = i[i];
}
OCL_CHECK(err, buffer_source[falgs] = cl::Buffer(context,
CL_MEM_USE_HOST_PTR | CL_MEM_READ_ONLY,
sizeof(uint16_t) * PatternLength, S, &err));
OCL_CHECK(err, buffer_output[falgs] =
cl::Buffer(context,CL_MEM_USE_HOST_PTR | CL_MEM_WRITE_ONLY,
sizeof(uint32_t), result, &err));
uint16_t set =0;
OCL_CHECK(err, err =
q.enqueueMigrateMemObjects({buffer_source[falgs]},
0,NULL,&write_event[falgs]));
OCL_CHECK(err, err = krnl_cluster.setArg(0, buffer_source[falgs]));
OCL_CHECK(err, err = krnl_cluster.setArg(5, buffer_output[falgs]));
OCL_CHECK(err, err = krnl_cluster.setArg(6, PatternLength));
OCL_CHECK(err, err = krnl_cluster.setArg(7, MaxTrialsForPV));
OCL_CHECK(err, err = krnl_cluster.setArg(8, set));
std::cout<<" 3 "<<std::endl;
OCL_CHECK(err, err = q.enqueueTask(krnl_cluster, &write_event ));
//, &kernel_events[falgs]));
std::cout<<"after the enqueue teask"<<std::endl;
q.finish();
OCL_CHECK(err, err =
q.enqueueMigrateMemObjects({buffer_output[falgs]},
CL_MIGRATE_MEM_OBJECT_HOST));
//,&eventList,&read_event[falgs][0]));
}
我正在尝试执行乱序执行,我有以下问题:
非常感谢您的帮助。