diff --git a/src/framework/cl/open_cl/cl.h b/src/framework/cl/CL/cl.h similarity index 100% rename from src/framework/cl/open_cl/cl.h rename to src/framework/cl/CL/cl.h diff --git a/src/framework/cl/open_cl/cl_d3d10.h b/src/framework/cl/CL/cl_d3d10.h similarity index 100% rename from src/framework/cl/open_cl/cl_d3d10.h rename to src/framework/cl/CL/cl_d3d10.h diff --git a/src/framework/cl/open_cl/cl_d3d11.h b/src/framework/cl/CL/cl_d3d11.h similarity index 100% rename from src/framework/cl/open_cl/cl_d3d11.h rename to src/framework/cl/CL/cl_d3d11.h diff --git a/src/framework/cl/open_cl/cl_dx9_media_sharing.h b/src/framework/cl/CL/cl_dx9_media_sharing.h similarity index 100% rename from src/framework/cl/open_cl/cl_dx9_media_sharing.h rename to src/framework/cl/CL/cl_dx9_media_sharing.h diff --git a/src/framework/cl/open_cl/cl_dx9_media_sharing_intel.h b/src/framework/cl/CL/cl_dx9_media_sharing_intel.h similarity index 100% rename from src/framework/cl/open_cl/cl_dx9_media_sharing_intel.h rename to src/framework/cl/CL/cl_dx9_media_sharing_intel.h diff --git a/src/framework/cl/open_cl/cl_egl.h b/src/framework/cl/CL/cl_egl.h similarity index 100% rename from src/framework/cl/open_cl/cl_egl.h rename to src/framework/cl/CL/cl_egl.h diff --git a/src/framework/cl/open_cl/cl_ext.h b/src/framework/cl/CL/cl_ext.h similarity index 100% rename from src/framework/cl/open_cl/cl_ext.h rename to src/framework/cl/CL/cl_ext.h diff --git a/src/framework/cl/open_cl/cl_ext_intel.h b/src/framework/cl/CL/cl_ext_intel.h similarity index 100% rename from src/framework/cl/open_cl/cl_ext_intel.h rename to src/framework/cl/CL/cl_ext_intel.h diff --git a/src/framework/cl/open_cl/cl_gl.h b/src/framework/cl/CL/cl_gl.h similarity index 100% rename from src/framework/cl/open_cl/cl_gl.h rename to src/framework/cl/CL/cl_gl.h diff --git a/src/framework/cl/open_cl/cl_gl_ext.h b/src/framework/cl/CL/cl_gl_ext.h similarity index 100% rename from src/framework/cl/open_cl/cl_gl_ext.h rename to src/framework/cl/CL/cl_gl_ext.h diff --git a/src/framework/cl/open_cl/cl_platform.h b/src/framework/cl/CL/cl_platform.h similarity index 100% rename from src/framework/cl/open_cl/cl_platform.h rename to src/framework/cl/CL/cl_platform.h diff --git a/src/framework/cl/open_cl/cl_va_api_media_sharing_intel.h b/src/framework/cl/CL/cl_va_api_media_sharing_intel.h similarity index 100% rename from src/framework/cl/open_cl/cl_va_api_media_sharing_intel.h rename to src/framework/cl/CL/cl_va_api_media_sharing_intel.h diff --git a/src/framework/cl/open_cl/cl_version.h b/src/framework/cl/CL/cl_version.h similarity index 100% rename from src/framework/cl/open_cl/cl_version.h rename to src/framework/cl/CL/cl_version.h diff --git a/src/framework/cl/open_cl/opencl.h b/src/framework/cl/CL/opencl.h similarity index 100% rename from src/framework/cl/open_cl/opencl.h rename to src/framework/cl/CL/opencl.h diff --git a/src/framework/cl/cl_deleter.h b/src/framework/cl/cl_deleter.h index 2f1e06bf0550d84fc565428b4e32ca446e3891d9..ce8bf5ac0020a33b6d48fea5409dabe5ac379fee 100644 --- a/src/framework/cl/cl_deleter.h +++ b/src/framework/cl/cl_deleter.h @@ -14,7 +14,7 @@ limitations under the License. */ #pragma once -#include "framework/cl/open_cl/cl.h" +#include "framework/cl/CL/cl.h" struct CLKernelDeleter { template diff --git a/src/framework/cl/cl_engine.cpp b/src/framework/cl/cl_engine.cpp index 7c91d6f8fb58d0225b04bf04c3053f6b8fdad77d..9ac67a1ce5680de21f7a0c98d006de0cbbbbe941 100644 --- a/src/framework/cl/cl_engine.cpp +++ b/src/framework/cl/cl_engine.cpp @@ -12,9 +12,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +#include "framework/cl/CL/cl.h" #include "framework/cl/cl_tool.h" #include "framework/cl/cl_engine.h" -#include "framework/cl/cl_header/cl.h" #include #include @@ -71,11 +71,6 @@ bool CLEngine::SetPlatform() { } } -//bool CLEngine::SetClContext() { -// context_.reset(clCreateContext(NULL, 1, devices_, NULL, NULL, NULL)); -// return true; -//} - bool CLEngine::SetClDeviceId() { cl_uint numDevices = 0; devices_ = NULL; @@ -92,6 +87,11 @@ bool CLEngine::SetClDeviceId() { return false; } +//bool CLEngine::SetClContext() { +// context_.reset(clCreateContext(NULL, 1, devices_, NULL, NULL, NULL)); +// return true; +//} + //bool CLEngine::LoadKernelFromFile(const char *kernel_file) { // size_t size; // char *str; diff --git a/src/framework/cl/cl_engine.h b/src/framework/cl/cl_engine.h index 9a778443f9c250b383a8ba2a9cd99b42b4b9d971..691c9a4f73d89819b851a4391cc0a7e8d8c0434a 100644 --- a/src/framework/cl/cl_engine.h +++ b/src/framework/cl/cl_engine.h @@ -20,7 +20,7 @@ limitations under the License. */ #include "common/enforce.h" #include "framework/cl/cl_deleter.h" -#include "framework/cl/open_cl/cl.h" +#include "framework/cl/CL/cl.h" namespace paddle_mobile { namespace framework { diff --git a/src/framework/cl/cl_image.h b/src/framework/cl/cl_image.h index 72bc1c338da24fef9336010f361bf53df138f7b5..eab4bd87e38c9afe118b482011b9bca446d396ac 100644 --- a/src/framework/cl/cl_image.h +++ b/src/framework/cl/cl_image.h @@ -16,7 +16,7 @@ limitations under the License. */ #include "framework/ddim.h" #include "framework/tensor.h" -#include "framework/cl/open_cl/cl.h" +#include "framework/cl/CL/cl.h" namespace paddle_mobile { namespace framework { diff --git a/src/framework/cl/cl_scope.h b/src/framework/cl/cl_scope.h index 7e49522dba1978e02a4c36602ac96090e87b9b8b..5772010f596fedc512a3fa4c242040b5977cffbb 100644 --- a/src/framework/cl/cl_scope.h +++ b/src/framework/cl/cl_scope.h @@ -21,7 +21,7 @@ limitations under the License. */ #include "framework/cl/cl_tool.h" #include "framework/cl/cl_engine.h" #include "framework/cl/cl_deleter.h" -#include "framework/cl/open_cl/cl.h" +#include "framework/cl/CL/cl.h" namespace paddle_mobile { namespace framework { diff --git a/src/framework/cl/cl_tensor.h b/src/framework/cl/cl_tensor.h index 63eddf2ab7db00a6efbdf5701b071b2be2e96351..b31c3fce0aafe244e97e1b0c6eb8c0ad9a0bdf09 100644 --- a/src/framework/cl/cl_tensor.h +++ b/src/framework/cl/cl_tensor.h @@ -21,7 +21,7 @@ limitations under the License. */ #include "framework/tensor_base.h" #include "framework/cl/cl_engine.h" #include "framework/cl/cl_deleter.h" -#include "framework/cl/open_cl/cl.h" +#include "framework/cl/CL/cl.h" namespace paddle_mobile { namespace framework { diff --git a/src/framework/cl/cl_tool.cpp b/src/framework/cl/cl_tool.cpp new file mode 100644 index 0000000000000000000000000000000000000000..993b63743b2697922d40dbfb594594c47c67498a --- /dev/null +++ b/src/framework/cl/cl_tool.cpp @@ -0,0 +1,82 @@ +/* Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. */ + +#include "cl_tool.h" + +namespace paddle_mobile { +namespace framework { + +const char *opencl_error_to_str(cl_int error) { +#define CASE_CL_CONSTANT(NAME) case NAME: return #NAME; + // Suppose that no combinations are possible. + switch (error) { + CASE_CL_CONSTANT(CL_SUCCESS) + CASE_CL_CONSTANT(CL_DEVICE_NOT_FOUND) + CASE_CL_CONSTANT(CL_DEVICE_NOT_AVAILABLE) + CASE_CL_CONSTANT(CL_COMPILER_NOT_AVAILABLE) + CASE_CL_CONSTANT(CL_MEM_OBJECT_ALLOCATION_FAILURE) + CASE_CL_CONSTANT(CL_OUT_OF_RESOURCES) + CASE_CL_CONSTANT(CL_OUT_OF_HOST_MEMORY) + CASE_CL_CONSTANT(CL_PROFILING_INFO_NOT_AVAILABLE) + CASE_CL_CONSTANT(CL_MEM_COPY_OVERLAP) + CASE_CL_CONSTANT(CL_IMAGE_FORMAT_MISMATCH) + CASE_CL_CONSTANT(CL_IMAGE_FORMAT_NOT_SUPPORTED) + CASE_CL_CONSTANT(CL_BUILD_PROGRAM_FAILURE) + CASE_CL_CONSTANT(CL_MAP_FAILURE) + CASE_CL_CONSTANT(CL_MISALIGNED_SUB_BUFFER_OFFSET) + CASE_CL_CONSTANT(CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST) + CASE_CL_CONSTANT(CL_INVALID_VALUE) + CASE_CL_CONSTANT(CL_INVALID_DEVICE_TYPE) + CASE_CL_CONSTANT(CL_INVALID_PLATFORM) + CASE_CL_CONSTANT(CL_INVALID_DEVICE) + CASE_CL_CONSTANT(CL_INVALID_CONTEXT) + CASE_CL_CONSTANT(CL_INVALID_QUEUE_PROPERTIES) + CASE_CL_CONSTANT(CL_INVALID_COMMAND_QUEUE) + CASE_CL_CONSTANT(CL_INVALID_HOST_PTR) + CASE_CL_CONSTANT(CL_INVALID_MEM_OBJECT) + CASE_CL_CONSTANT(CL_INVALID_IMAGE_FORMAT_DESCRIPTOR) + CASE_CL_CONSTANT(CL_INVALID_IMAGE_SIZE) + CASE_CL_CONSTANT(CL_INVALID_SAMPLER) + CASE_CL_CONSTANT(CL_INVALID_BINARY) + CASE_CL_CONSTANT(CL_INVALID_BUILD_OPTIONS) + CASE_CL_CONSTANT(CL_INVALID_PROGRAM) + CASE_CL_CONSTANT(CL_INVALID_PROGRAM_EXECUTABLE) + CASE_CL_CONSTANT(CL_INVALID_KERNEL_NAME) + CASE_CL_CONSTANT(CL_INVALID_KERNEL_DEFINITION) + CASE_CL_CONSTANT(CL_INVALID_KERNEL) + CASE_CL_CONSTANT(CL_INVALID_ARG_INDEX) + CASE_CL_CONSTANT(CL_INVALID_ARG_VALUE) + CASE_CL_CONSTANT(CL_INVALID_ARG_SIZE) + CASE_CL_CONSTANT(CL_INVALID_KERNEL_ARGS) + CASE_CL_CONSTANT(CL_INVALID_WORK_DIMENSION) + CASE_CL_CONSTANT(CL_INVALID_WORK_GROUP_SIZE) + CASE_CL_CONSTANT(CL_INVALID_WORK_ITEM_SIZE) + CASE_CL_CONSTANT(CL_INVALID_GLOBAL_OFFSET) + CASE_CL_CONSTANT(CL_INVALID_EVENT_WAIT_LIST) + CASE_CL_CONSTANT(CL_INVALID_EVENT) + CASE_CL_CONSTANT(CL_INVALID_OPERATION) + CASE_CL_CONSTANT(CL_INVALID_GL_OBJECT) + CASE_CL_CONSTANT(CL_INVALID_BUFFER_SIZE) + CASE_CL_CONSTANT(CL_INVALID_MIP_LEVEL) + CASE_CL_CONSTANT(CL_INVALID_GLOBAL_WORK_SIZE) + CASE_CL_CONSTANT(CL_INVALID_PROPERTY) + + default: + return "UNKNOWN ERROR CODE"; + } +#undef CASE_CL_CONSTANT +} + +} +} diff --git a/src/framework/cl/cl_tool.h b/src/framework/cl/cl_tool.h index fa66e5a641208435a132a6b0c81c62c4d17d43d1..aceee00173ce3b5e784a46077386b74f34d31901 100644 --- a/src/framework/cl/cl_tool.h +++ b/src/framework/cl/cl_tool.h @@ -14,11 +14,13 @@ limitations under the License. */ #pragma once -#include "framework/cl/cl_header/cl.h" +#include "framework/cl/CL/cl.h" namespace paddle_mobile { namespace framework { +const char* opencl_error_to_str (cl_int error); + #define CL_CHECK_ERRORS(ERR) \ if(ERR != CL_SUCCESS) \ { \