add more crash points

This commit is contained in:
gfuse
2021-08-23 16:07:26 +02:00
parent a06820e803
commit cc1c49ed37
+7 -6
View File
@@ -51,7 +51,9 @@ public:
template<typename T>
int32_t reload(size_t id,T* buf,cl::CommandQueue* queue){
for(auto&& i:_buffers)if(i.second==id){
T* Map_buf=(T*)queue->enqueueMapBuffer(i.first.first,CL_TRUE,CL_MAP_WRITE,0,sizeof(T) * i.first.second);
cl_int error;
T* Map_buf=(T*)queue->enqueueMapBuffer(i.first.first,CL_TRUE,CL_MAP_WRITE,0,sizeof(T) * i.first.second,NULL,NULL,&error);
assert(error == CL_SUCCESS);
memcpy(Map_buf,buf,sizeof(T) * i.first.second);
if(queue->enqueueUnmapMemObject(i.first.first,Map_buf)!=CL_SUCCESS)std::cerr<<"Reload buffer on GPU failed"<<'\n';
}
@@ -60,18 +62,17 @@ public:
int32_t reload(size_t id,cv::Mat& buf,cl::Context* context){
try{
for(auto&& i:_images)if(i.second==id){
cl_int error;
i.first.setDestructorCallback((void (*)(_cl_mem *, void *))notify, NULL);
i.first=cl::Image2D(*context, CL_MEM_READ_ONLY | CL_MEM_USE_HOST_PTR,
cl::ImageFormat(CL_R, CL_UNSIGNED_INT8),
buf.size().width,
buf.size().height,
0,
reinterpret_cast<uchar*>(buf.data));
reinterpret_cast<uchar*>(buf.data),&error);
assert(error == CL_SUCCESS);
cl_int err=_kernel->setArg(id,i.first);
if(err!=0){
std::cerr<<"Error C:Kernel, F:write image, L:setArg ID:\t"<<id<<"\t"<<err<<'\n';
return err;
}
assert(err == CL_SUCCESS);
}
return CL_SUCCESS;
}catch (std::exception& err){