|
|
|
@ -627,13 +627,13 @@ static void* initOpenCLAndLoad(const char* funcname) |
|
|
|
|
{ |
|
|
|
|
handle = LoadLibraryA("OpenCL.dll"); |
|
|
|
|
initialized = true; |
|
|
|
|
g_haveOpenCL = handle != 0 && GetProcAddressA(handle, oclFuncToCheck) != 0; |
|
|
|
|
g_haveOpenCL = handle != 0 && GetProcAddress(handle, oclFuncToCheck) != 0; |
|
|
|
|
} |
|
|
|
|
if(!handle) |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return funcname ? (void*)GetProcAddressA(handle, funcname) : 0; |
|
|
|
|
return funcname ? (void*)GetProcAddress(handle, funcname) : 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#elif defined(__linux) |
|
|
|
@ -649,9 +649,9 @@ static void* initOpenCLAndLoad(const char* funcname) |
|
|
|
|
{ |
|
|
|
|
if(!initialized) |
|
|
|
|
{ |
|
|
|
|
handle = dlopen("libOpenCL.so"); |
|
|
|
|
handle = dlopen("libOpenCL.so", RTLD_LAZY); |
|
|
|
|
if(!handle) |
|
|
|
|
handle = dlopen("libCL.so"); |
|
|
|
|
handle = dlopen("libCL.so", RTLD_LAZY); |
|
|
|
|
initialized = true; |
|
|
|
|
g_haveOpenCL = handle != 0 && dlsym(handle, oclFuncToCheck) != 0; |
|
|
|
|
} |
|
|
|
@ -1107,7 +1107,7 @@ OCL_FUNC(cl_int, clEnqueueWriteBufferRect, |
|
|
|
|
region, buffer_row_pitch, buffer_slice_pitch, host_row_pitch, |
|
|
|
|
host_slice_pitch, ptr, num_events_in_wait_list, event_wait_list, event)) |
|
|
|
|
|
|
|
|
|
OCL_FUNC(cl_int, clEnqueueFillBuffer, |
|
|
|
|
/*OCL_FUNC(cl_int, clEnqueueFillBuffer,
|
|
|
|
|
(cl_command_queue command_queue, |
|
|
|
|
cl_mem buffer, |
|
|
|
|
const void * pattern, |
|
|
|
@ -1118,7 +1118,7 @@ OCL_FUNC(cl_int, clEnqueueFillBuffer, |
|
|
|
|
const cl_event * event_wait_list, |
|
|
|
|
cl_event * event), |
|
|
|
|
(command_queue, buffer, pattern, pattern_size, offset, size, |
|
|
|
|
num_events_in_wait_list, event_wait_list, event)) |
|
|
|
|
num_events_in_wait_list, event_wait_list, event))*/ |
|
|
|
|
|
|
|
|
|
OCL_FUNC(cl_int, clEnqueueCopyBuffer, |
|
|
|
|
(cl_command_queue command_queue, |
|
|
|
@ -1737,7 +1737,6 @@ struct Context::Impl |
|
|
|
|
|
|
|
|
|
cl_context handle; |
|
|
|
|
std::vector<Device> devices; |
|
|
|
|
int dtype; |
|
|
|
|
bool initialized; |
|
|
|
|
|
|
|
|
|
typedef ProgramSource::hash_t hash_t; |
|
|
|
@ -1766,11 +1765,6 @@ Context::Context(int dtype) |
|
|
|
|
create(dtype); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int Context::dtype() const |
|
|
|
|
{ |
|
|
|
|
return p ? p->dtype : 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool Context::create(int dtype0) |
|
|
|
|
{ |
|
|
|
|
if( !haveOpenCL() ) |
|
|
|
@ -2113,9 +2107,8 @@ int Kernel::set(int i, const KernelArg& arg) |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
clSetKernelArg(p->handle, (cl_uint)(i+1), sizeof(size_t), &arg.m->offset); |
|
|
|
|
clSetKernelArg(p->handle, (cl_uint)(i+1), sizeof(size_t)*(dims-1), &arg.m->step.p[0]); |
|
|
|
|
clSetKernelArg(p->handle, (cl_uint)(i+2), sizeof(cl_int)*dims, &arg.m->size.p[0]); |
|
|
|
|
clSetKernelArg(p->handle, (cl_uint)(i+2), sizeof(size_t)*(dims-1), &arg.m->step.p[0]); |
|
|
|
|
clSetKernelArg(p->handle, (cl_uint)(i+3), sizeof(cl_int)*dims, &arg.m->size.p[0]); |
|
|
|
|
return i + 4; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -2249,13 +2242,13 @@ struct Program::Impl |
|
|
|
|
const Context& ctx = Context::getDefault(); |
|
|
|
|
const Device& dev = Device::getDefault(); |
|
|
|
|
const char* pos0 = _buf.c_str(); |
|
|
|
|
char* pos1 = strchr(pos0, '\n'); |
|
|
|
|
const char* pos1 = strchr(pos0, '\n'); |
|
|
|
|
if(!pos1) |
|
|
|
|
return; |
|
|
|
|
char* pos2 = strchr(pos1+1, '\n'); |
|
|
|
|
const char* pos2 = strchr(pos1+1, '\n'); |
|
|
|
|
if(!pos2) |
|
|
|
|
return; |
|
|
|
|
char* pos3 = strchr(pos2+1, '\n'); |
|
|
|
|
const char* pos3 = strchr(pos2+1, '\n'); |
|
|
|
|
if(!pos3) |
|
|
|
|
return; |
|
|
|
|
size_t prefixlen = (pos3 - pos0)+1; |
|
|
|
@ -2580,6 +2573,9 @@ public: |
|
|
|
|
u->markHostCopyObsolete(false); |
|
|
|
|
clReleaseMemObject((cl_mem)u->handle); |
|
|
|
|
u->currAllocator = u->prevAllocator; |
|
|
|
|
if(u->data && u->copyOnMap()) |
|
|
|
|
fastFree(u->data); |
|
|
|
|
u->data = u->origdata; |
|
|
|
|
if(u->refcount == 0) |
|
|
|
|
u->currAllocator->deallocate(u); |
|
|
|
|
} |
|
|
|
@ -2898,4 +2894,3 @@ MatAllocator* getOpenCLAllocator() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}} |
|
|
|
|
|
|
|
|
|