aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorgios Pinitas <georgios.pinitas@arm.com>2021-03-12 18:40:30 +0000
committerSheri Zhang <sheri.zhang@arm.com>2021-03-15 12:24:50 +0000
commit42bd26560daa799dbb825a7c6aade61c7ca132a2 (patch)
tree0ca27bc3a92f859baeba97ebc96896ad5f0aaf45
parent3b131ab38fa337af7818d78200b0e7bdf89c5e69 (diff)
downloadComputeLibrary-42bd26560daa799dbb825a7c6aade61c7ca132a2.tar.gz
Revert "Close loaded library on OpenCL symbols destruction"
This reverts commit d62ef4d0df239790a3ccb304ce6dd85ed399fa74. Change-Id: I55614b157a72cb4a6bc180d1e46cafa81e526996 Signed-off-by: Georgios Pinitas <georgios.pinitas@arm.com> Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/5264 Tested-by: Arm Jenkins <bsgcomp@arm.com> Reviewed-by: Sheri Zhang <sheri.zhang@arm.com>
-rw-r--r--arm_compute/core/CL/OpenCL.h7
-rw-r--r--src/core/CL/OpenCL.cpp113
2 files changed, 52 insertions, 68 deletions
diff --git a/arm_compute/core/CL/OpenCL.h b/arm_compute/core/CL/OpenCL.h
index 64b24dba8f..155c3e4eef 100644
--- a/arm_compute/core/CL/OpenCL.h
+++ b/arm_compute/core/CL/OpenCL.h
@@ -63,12 +63,6 @@ class CLSymbols final
public:
/** Default Constructor */
CLSymbols() noexcept(false);
- /** Destructor */
- ~CLSymbols();
- /** Prevent instances of this class from being copied (As this class contains pointers) */
- CLSymbols(const CLSymbols &) = delete;
- /** Prevent instances of this class from being copied (As this class contains pointers) */
- CLSymbols &operator=(const CLSymbols &) = delete;
/** Load OpenCL symbols from handle
*
* @param[in] handle Handle to load symbols from
@@ -150,7 +144,6 @@ public:
private:
std::pair<bool, bool> _loaded;
- void *_handle;
};
} // namespace arm_compute
#endif /* ARM_COMPUTE_OPENCL_H */
diff --git a/src/core/CL/OpenCL.cpp b/src/core/CL/OpenCL.cpp
index 152759b4df..aff6285697 100644
--- a/src/core/CL/OpenCL.cpp
+++ b/src/core/CL/OpenCL.cpp
@@ -38,19 +38,10 @@ CLSymbols::CLSymbols() noexcept(false)
: _loaded(
{
false, false
-}),
-_handle(nullptr)
+})
{
}
-CLSymbols::~CLSymbols()
-{
- if(_handle != nullptr)
- {
- dlclose(_handle);
- }
-}
-
CLSymbols &CLSymbols::get()
{
static CLSymbols symbols;
@@ -84,9 +75,9 @@ bool CLSymbols::load_default()
bool CLSymbols::load(const std::string &library)
{
- _handle = dlopen(library.c_str(), RTLD_LAZY | RTLD_LOCAL);
+ void *handle = dlopen(library.c_str(), RTLD_LAZY | RTLD_LOCAL);
- if(_handle == nullptr)
+ if(handle == nullptr)
{
std::cerr << "Can't load " << library << ": " << dlerror() << "\n";
// Set status of loading to failed
@@ -97,60 +88,60 @@ bool CLSymbols::load(const std::string &library)
#define LOAD_FUNCTION_PTR(func_name, handle) \
func_name##_ptr = reinterpret_cast<decltype(func_name) *>(dlsym(handle, #func_name));
- LOAD_FUNCTION_PTR(clCreateContext, _handle);
- LOAD_FUNCTION_PTR(clCreateContextFromType, _handle);
- LOAD_FUNCTION_PTR(clCreateCommandQueue, _handle);
- LOAD_FUNCTION_PTR(clGetContextInfo, _handle);
- LOAD_FUNCTION_PTR(clBuildProgram, _handle);
- LOAD_FUNCTION_PTR(clEnqueueNDRangeKernel, _handle);
- LOAD_FUNCTION_PTR(clSetKernelArg, _handle);
- LOAD_FUNCTION_PTR(clReleaseKernel, _handle);
- LOAD_FUNCTION_PTR(clCreateProgramWithSource, _handle);
- LOAD_FUNCTION_PTR(clCreateBuffer, _handle);
- LOAD_FUNCTION_PTR(clRetainKernel, _handle);
- LOAD_FUNCTION_PTR(clCreateKernel, _handle);
- LOAD_FUNCTION_PTR(clGetProgramInfo, _handle);
- LOAD_FUNCTION_PTR(clFlush, _handle);
- LOAD_FUNCTION_PTR(clFinish, _handle);
- LOAD_FUNCTION_PTR(clReleaseProgram, _handle);
- LOAD_FUNCTION_PTR(clRetainContext, _handle);
- LOAD_FUNCTION_PTR(clCreateProgramWithBinary, _handle);
- LOAD_FUNCTION_PTR(clReleaseCommandQueue, _handle);
- LOAD_FUNCTION_PTR(clEnqueueMapBuffer, _handle);
- LOAD_FUNCTION_PTR(clRetainProgram, _handle);
- LOAD_FUNCTION_PTR(clGetProgramBuildInfo, _handle);
- LOAD_FUNCTION_PTR(clEnqueueReadBuffer, _handle);
- LOAD_FUNCTION_PTR(clEnqueueWriteBuffer, _handle);
- LOAD_FUNCTION_PTR(clReleaseEvent, _handle);
- LOAD_FUNCTION_PTR(clReleaseContext, _handle);
- LOAD_FUNCTION_PTR(clRetainCommandQueue, _handle);
- LOAD_FUNCTION_PTR(clEnqueueUnmapMemObject, _handle);
- LOAD_FUNCTION_PTR(clRetainMemObject, _handle);
- LOAD_FUNCTION_PTR(clReleaseMemObject, _handle);
- LOAD_FUNCTION_PTR(clGetDeviceInfo, _handle);
- LOAD_FUNCTION_PTR(clGetDeviceIDs, _handle);
- LOAD_FUNCTION_PTR(clGetMemObjectInfo, _handle);
- LOAD_FUNCTION_PTR(clRetainEvent, _handle);
- LOAD_FUNCTION_PTR(clGetPlatformIDs, _handle);
- LOAD_FUNCTION_PTR(clGetKernelWorkGroupInfo, _handle);
- LOAD_FUNCTION_PTR(clGetCommandQueueInfo, _handle);
- LOAD_FUNCTION_PTR(clGetKernelInfo, _handle);
- LOAD_FUNCTION_PTR(clGetEventProfilingInfo, _handle);
- LOAD_FUNCTION_PTR(clSVMAlloc, _handle);
- LOAD_FUNCTION_PTR(clSVMFree, _handle);
- LOAD_FUNCTION_PTR(clEnqueueSVMMap, _handle);
- LOAD_FUNCTION_PTR(clEnqueueSVMUnmap, _handle);
- LOAD_FUNCTION_PTR(clEnqueueMarker, _handle);
- LOAD_FUNCTION_PTR(clWaitForEvents, _handle);
- LOAD_FUNCTION_PTR(clCreateImage, _handle);
- LOAD_FUNCTION_PTR(clSetKernelExecInfo, _handle);
+ LOAD_FUNCTION_PTR(clCreateContext, handle);
+ LOAD_FUNCTION_PTR(clCreateContextFromType, handle);
+ LOAD_FUNCTION_PTR(clCreateCommandQueue, handle);
+ LOAD_FUNCTION_PTR(clGetContextInfo, handle);
+ LOAD_FUNCTION_PTR(clBuildProgram, handle);
+ LOAD_FUNCTION_PTR(clEnqueueNDRangeKernel, handle);
+ LOAD_FUNCTION_PTR(clSetKernelArg, handle);
+ LOAD_FUNCTION_PTR(clReleaseKernel, handle);
+ LOAD_FUNCTION_PTR(clCreateProgramWithSource, handle);
+ LOAD_FUNCTION_PTR(clCreateBuffer, handle);
+ LOAD_FUNCTION_PTR(clRetainKernel, handle);
+ LOAD_FUNCTION_PTR(clCreateKernel, handle);
+ LOAD_FUNCTION_PTR(clGetProgramInfo, handle);
+ LOAD_FUNCTION_PTR(clFlush, handle);
+ LOAD_FUNCTION_PTR(clFinish, handle);
+ LOAD_FUNCTION_PTR(clReleaseProgram, handle);
+ LOAD_FUNCTION_PTR(clRetainContext, handle);
+ LOAD_FUNCTION_PTR(clCreateProgramWithBinary, handle);
+ LOAD_FUNCTION_PTR(clReleaseCommandQueue, handle);
+ LOAD_FUNCTION_PTR(clEnqueueMapBuffer, handle);
+ LOAD_FUNCTION_PTR(clRetainProgram, handle);
+ LOAD_FUNCTION_PTR(clGetProgramBuildInfo, handle);
+ LOAD_FUNCTION_PTR(clEnqueueReadBuffer, handle);
+ LOAD_FUNCTION_PTR(clEnqueueWriteBuffer, handle);
+ LOAD_FUNCTION_PTR(clReleaseEvent, handle);
+ LOAD_FUNCTION_PTR(clReleaseContext, handle);
+ LOAD_FUNCTION_PTR(clRetainCommandQueue, handle);
+ LOAD_FUNCTION_PTR(clEnqueueUnmapMemObject, handle);
+ LOAD_FUNCTION_PTR(clRetainMemObject, handle);
+ LOAD_FUNCTION_PTR(clReleaseMemObject, handle);
+ LOAD_FUNCTION_PTR(clGetDeviceInfo, handle);
+ LOAD_FUNCTION_PTR(clGetDeviceIDs, handle);
+ LOAD_FUNCTION_PTR(clGetMemObjectInfo, handle);
+ LOAD_FUNCTION_PTR(clRetainEvent, handle);
+ LOAD_FUNCTION_PTR(clGetPlatformIDs, handle);
+ LOAD_FUNCTION_PTR(clGetKernelWorkGroupInfo, handle);
+ LOAD_FUNCTION_PTR(clGetCommandQueueInfo, handle);
+ LOAD_FUNCTION_PTR(clGetKernelInfo, handle);
+ LOAD_FUNCTION_PTR(clGetEventProfilingInfo, handle);
+ LOAD_FUNCTION_PTR(clSVMAlloc, handle);
+ LOAD_FUNCTION_PTR(clSVMFree, handle);
+ LOAD_FUNCTION_PTR(clEnqueueSVMMap, handle);
+ LOAD_FUNCTION_PTR(clEnqueueSVMUnmap, handle);
+ LOAD_FUNCTION_PTR(clEnqueueMarker, handle);
+ LOAD_FUNCTION_PTR(clWaitForEvents, handle);
+ LOAD_FUNCTION_PTR(clCreateImage, handle);
+ LOAD_FUNCTION_PTR(clSetKernelExecInfo, handle);
// Third-party extensions
- LOAD_FUNCTION_PTR(clImportMemoryARM, _handle);
+ LOAD_FUNCTION_PTR(clImportMemoryARM, handle);
#undef LOAD_FUNCTION_PTR
- //Don't call dlclose(_handle) or all the symbols will be unloaded !
+ //Don't call dlclose(handle) or all the symbols will be unloaded !
// Disable default loading and set status to successful
_loaded = std::make_pair(true, true);