• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1if(ENABLE_GITEE)
2    set(REQ_URL "https://gitee.com/mirrors/OpenCL-Headers/repository/archive/v2020.12.18.tar.gz")
3    set(MD5 "34e4ec0a23aaa7960523a0ab4853b647")
4    set(PKG_GIT_TAG "")
5    __download_pkg_with_git(OpenCL-Headers ${REQ_URL} ${PKG_GIT_TAG} ${MD5})
6    set(REQ_URL "https://gitee.com/mirrors/OpenCL-CLHPP/repository/archive/v2.0.12.tar.gz")
7    set(MD5 "7a07baf1c9776e40e93abaf8f4ac2859")
8    set(PKG_GIT_TAG "")
9    __download_pkg_with_git(OpenCL-CLHPP ${REQ_URL} ${PKG_GIT_TAG} ${MD5})
10else()
11    set(REQ_URL "https://github.com/KhronosGroup/OpenCL-Headers/archive/v2020.12.18.tar.gz")
12    set(MD5 "ea0296fb79951f43082b742234f26c9a")
13    __download_pkg(OpenCL-Headers ${REQ_URL} ${MD5})
14    set(REQ_URL "https://github.com/KhronosGroup/OpenCL-CLHPP/archive/v2.0.12.tar.gz")
15    set(MD5 "bd00fca8f861b3b65660d719f00a58dd")
16    __download_pkg(OpenCL-CLHPP ${REQ_URL} ${MD5})
17endif()
18
19function(gene_opencl CL_SRC_DIR)
20    message(STATUS "**********gene opencl********* cl path: " "${CL_SRC_DIR}")
21    if(NOT EXISTS ${CL_SRC_DIR})
22        return()
23    endif()
24    file(GLOB_RECURSE CL_LIST ${CL_SRC_DIR}/*.cl)
25    foreach(file_path ${CL_LIST})
26        file(REMOVE ${file_path}.inc)
27        string(REGEX REPLACE ".+/(.+)\\..*" "\\1" kernel_name "${file_path}")
28        set(inc_file_ex "${file_path}.inc")
29        execute_process(
30                COMMAND bash -c "sed 's/\\\\/\\\\\\\\/g' "
31                COMMAND bash -c "sed 's/\\\"/\\\\\\\"/g' "
32                COMMAND bash -c "sed 's/$/\\\\n\\\" \\\\/' "
33                COMMAND bash -c "sed 's/^/\\\"/' "
34                WORKING_DIRECTORY ${CL_SRC_DIR}
35                INPUT_FILE ${file_path}
36                OUTPUT_FILE ${inc_file_ex}
37                RESULT_VARIABLE RESULT)
38        if(NOT RESULT EQUAL "0")
39            message(FATAL_ERROR "error! when generate ${inc_file_ex}")
40        endif()
41        __exec_cmd(COMMAND sed -i "1i\\static const char *${kernel_name}_source =\\\"\\\\n\\\" \\\\"
42          ${inc_file_ex} WORKING_DIRECTORY ${CL_SRC_DIR})
43        __exec_cmd(COMMAND sed -i "$a\\\\\;" ${inc_file_ex} WORKING_DIRECTORY ${CL_SRC_DIR})
44    endforeach()
45endfunction()
46