From cc1c49ed37c8f69318a9d636d106bc082cd9bf00 Mon Sep 17 00:00:00 2001 From: gfuse Date: Mon, 23 Aug 2021 16:07:26 +0200 Subject: [PATCH] add more crash points --- include/cl_class.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/include/cl_class.h b/include/cl_class.h index da7ee57..7bd1149 100644 --- a/include/cl_class.h +++ b/include/cl_class.h @@ -51,7 +51,9 @@ public: template 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(buf.data)); + reinterpret_cast(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"<