adjust gene_opencl sh to cmake
This commit is contained in:
parent
d9395e8b71
commit
87d3ff903b
1
build.sh
1
build.sh
|
@ -625,7 +625,6 @@ build_lite()
|
|||
echo "============ Start building MindSpore Lite ${VERSION_STR} ============"
|
||||
if [ "${ENABLE_GPU}" == "on" ] && [ "${LITE_PLATFORM}" == "arm64" ]; then
|
||||
echo "start build opencl"
|
||||
build_opencl
|
||||
fi
|
||||
if [ "${ENABLE_NPU}" == "on" ]; then
|
||||
checkddk
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
if (ENABLE_GITEE)
|
||||
set(REQ_URL "https://gitee.com/mirrors/flatbuffers/repository/archive/v2020.06.16.tar.gz")
|
||||
set(MD5 "fc7627b5a8a95ecbe3d5df43bc88aa44")
|
||||
set(PKG_GIT_TAG "")
|
||||
__download_pkg_with_git(OpenCL-Headers ${REQ_URL} ${PKG_GIT_TAG} ${MD5})
|
||||
set(REQ_URL "https://gitee.com/mirrors/flatbuffers/repository/archive/v2.0.12.tar.gz")
|
||||
set(MD5 "bd00fca8f861b3b65660d719f00a58dd")
|
||||
set(PKG_GIT_TAG "")
|
||||
__download_pkg_with_git(OpenCL-CLHPP ${REQ_URL} ${PKG_GIT_TAG} ${MD5})
|
||||
else()
|
||||
set(REQ_URL "https://github.com/KhronosGroup/OpenCL-Headers/archive/v2020.06.16.tar.gz")
|
||||
set(MD5 "fc7627b5a8a95ecbe3d5df43bc88aa44")
|
||||
__download_pkg(OpenCL-Headers ${REQ_URL} ${MD5})
|
||||
set(REQ_URL "https://github.com/KhronosGroup/OpenCL-CLHPP/archive/v2.0.12.tar.gz")
|
||||
set(MD5 "bd00fca8f861b3b65660d719f00a58dd")
|
||||
__download_pkg(OpenCL-CLHPP ${REQ_URL} ${MD5})
|
||||
endif ()
|
||||
|
||||
function(gene_opencl BASEPATH)
|
||||
string(CONCAT CL_SRC_DIR "${BASEPATH}" "/src/runtime/kernel/opencl/cl")
|
||||
message(STATUS "**********gene opencl*********base path: " "${BASEPATH}" ", cl path: " "${CL_SRC_DIR}")
|
||||
if(NOT EXISTS ${CL_SRC_DIR})
|
||||
return()
|
||||
endif()
|
||||
file(GLOB_RECURSE CL_LIST ${CL_SRC_DIR}/*.cl)
|
||||
foreach(file_path ${CL_LIST})
|
||||
file(REMOVE ${file_path}.inc)
|
||||
string(REGEX REPLACE ".+/(.+)\\..*" "\\1" kernel_name "${file_path}")
|
||||
set(inc_file_ex "${kernel_name}.cl.inc")
|
||||
execute_process(
|
||||
COMMAND bash -c "sed 's/\\\\/\\\\\\\\/g' "
|
||||
COMMAND bash -c "sed 's/\\\"/\\\\\\\"/g' "
|
||||
COMMAND bash -c "sed 's/$/\\\\n\\\" \\\\/' "
|
||||
COMMAND bash -c "sed 's/^/\\\"/' "
|
||||
WORKING_DIRECTORY ${CL_SRC_DIR}
|
||||
INPUT_FILE ${file_path}
|
||||
OUTPUT_FILE ${inc_file_ex}
|
||||
RESULT_VARIABLE RESULT)
|
||||
if(NOT RESULT EQUAL "0")
|
||||
message(FATAL_ERROR "error! when generate ${inc_file_ex}")
|
||||
endif()
|
||||
__exec_cmd(COMMAND sed -i "1i\\static const char *${kernel_name}_source =\\\"\\\\n\\\" \\\\" ${inc_file_ex} WORKING_DIRECTORY ${CL_SRC_DIR})
|
||||
__exec_cmd(COMMAND sed -i "$a\\\\\;" ${inc_file_ex} WORKING_DIRECTORY ${CL_SRC_DIR})
|
||||
endforeach()
|
||||
endfunction()
|
|
@ -114,6 +114,7 @@ include(${TOP_DIR}/cmake/utils.cmake)
|
|||
include(${TOP_DIR}/cmake/dependency_utils.cmake)
|
||||
include(${TOP_DIR}/cmake/dependency_securec.cmake)
|
||||
include(${TOP_DIR}/cmake/external_libs/flatbuffers.cmake)
|
||||
include(${TOP_DIR}/cmake/external_libs/opencl.cmake)
|
||||
|
||||
if (ENABLE_CONVERTER OR BUILD_MINDDATA STREQUAL "full")
|
||||
include(${TOP_DIR}/cmake/external_libs/json.cmake)
|
||||
|
@ -152,6 +153,7 @@ if (ENABLE_FP16)
|
|||
add_compile_definitions(ENABLE_FP16)
|
||||
endif ()
|
||||
if (SUPPORT_GPU)
|
||||
gene_opencl(${CMAKE_CURRENT_SOURCE_DIR})
|
||||
add_definitions(-DUSE_OPENCL_WRAPPER)
|
||||
add_definitions(-DMS_OPENCL_PROFILE=false)
|
||||
add_definitions(-DCL_HPP_TARGET_OPENCL_VERSION=200)
|
||||
|
|
Loading…
Reference in New Issue