diff options
Diffstat (limited to 'llama.cpp/ggml/src/ggml-zendnn/CMakeLists.txt')
| -rw-r--r-- | llama.cpp/ggml/src/ggml-zendnn/CMakeLists.txt | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/llama.cpp/ggml/src/ggml-zendnn/CMakeLists.txt b/llama.cpp/ggml/src/ggml-zendnn/CMakeLists.txt new file mode 100644 index 0000000..f5cf6ee --- /dev/null +++ b/llama.cpp/ggml/src/ggml-zendnn/CMakeLists.txt | |||
| @@ -0,0 +1,92 @@ | |||
| 1 | ggml_add_backend_library(ggml-zendnn | ||
| 2 | ggml-zendnn.cpp) | ||
| 3 | |||
| 4 | # Get ZenDNN path | ||
| 5 | if (NOT DEFINED ZENDNN_ROOT OR ZENDNN_ROOT STREQUAL "") | ||
| 6 | set(ZENDNN_ROOT "$ENV{ZENDNN_ROOT}") | ||
| 7 | endif() | ||
| 8 | |||
| 9 | # Check if path is still empty or OFF | ||
| 10 | if (NOT ZENDNN_ROOT OR ZENDNN_ROOT STREQUAL "" OR ZENDNN_ROOT STREQUAL "OFF") | ||
| 11 | message(STATUS "ZENDNN_ROOT not set. Automatically downloading and building ZenDNN...") | ||
| 12 | message(STATUS "This will take several minutes on first build...") | ||
| 13 | |||
| 14 | include(ExternalProject) | ||
| 15 | |||
| 16 | set(ZENDNN_PREFIX ${CMAKE_BINARY_DIR}/_deps/zendnn-prefix) | ||
| 17 | set(ZENDNN_SOURCE_DIR ${ZENDNN_PREFIX}/src/zendnn) | ||
| 18 | set(ZENDNN_BUILD_DIR ${ZENDNN_PREFIX}/build) | ||
| 19 | set(ZENDNN_INSTALL_DIR ${ZENDNN_BUILD_DIR}/install) | ||
| 20 | |||
| 21 | ExternalProject_Add( | ||
| 22 | zendnn | ||
| 23 | GIT_REPOSITORY https://github.com/amd/ZenDNN.git | ||
| 24 | GIT_TAG 21ce8f7879c86bf3637f707fae6f29e0951db5fe | ||
| 25 | PREFIX ${ZENDNN_PREFIX} | ||
| 26 | SOURCE_DIR ${ZENDNN_SOURCE_DIR} | ||
| 27 | BINARY_DIR ${ZENDNN_BUILD_DIR} | ||
| 28 | CMAKE_ARGS | ||
| 29 | -DCMAKE_BUILD_TYPE=Release | ||
| 30 | -DCMAKE_INSTALL_PREFIX=${ZENDNN_INSTALL_DIR} | ||
| 31 | -DZENDNNL_BUILD_EXAMPLES=OFF | ||
| 32 | -DZENDNNL_BUILD_DOXYGEN=OFF | ||
| 33 | -DZENDNNL_BUILD_GTEST=OFF | ||
| 34 | -DZENDNNL_BUILD_BENCHDNN=OFF | ||
| 35 | # Enable ALL matmul algorithm backends | ||
| 36 | -DZENDNNL_DEPENDS_AOCLDLP=ON | ||
| 37 | -DZENDNNL_DEPENDS_ONEDNN=ON | ||
| 38 | -DZENDNNL_DEPENDS_LIBXSMM=ON | ||
| 39 | BUILD_COMMAND ${CMAKE_COMMAND} --build ${ZENDNN_BUILD_DIR} --target zendnnl | ||
| 40 | INSTALL_COMMAND ${CMAKE_COMMAND} --build ${ZENDNN_BUILD_DIR} --target install | ||
| 41 | BUILD_ALWAYS OFF | ||
| 42 | LOG_DOWNLOAD ON | ||
| 43 | LOG_CONFIGURE ON | ||
| 44 | LOG_BUILD ON | ||
| 45 | LOG_INSTALL ON | ||
| 46 | ) | ||
| 47 | |||
| 48 | # Add dependency so ZenDNN builds before our library | ||
| 49 | add_dependencies(ggml-zendnn zendnn) | ||
| 50 | |||
| 51 | # Set ZENDNN_ROOT to the installation directory | ||
| 52 | set(ZENDNN_ROOT ${ZENDNN_INSTALL_DIR}) | ||
| 53 | |||
| 54 | message(STATUS "ZenDNN will be built to: ${ZENDNN_ROOT}") | ||
| 55 | else() | ||
| 56 | message(STATUS "Using custom ZenDNN installation at: ${ZENDNN_ROOT}") | ||
| 57 | endif() | ||
| 58 | |||
| 59 | # ZenDNN headers + libs | ||
| 60 | target_include_directories(ggml-zendnn PRIVATE | ||
| 61 | ${ZENDNN_ROOT}/zendnnl/include | ||
| 62 | ${ZENDNN_ROOT}/deps/aocldlp/include | ||
| 63 | ${ZENDNN_ROOT}/deps/aoclutils/include | ||
| 64 | ${ZENDNN_ROOT}/deps/json/include | ||
| 65 | ${ZENDNN_ROOT}/deps/libxsmm/include | ||
| 66 | ${ZENDNN_ROOT}/deps/onednn/include | ||
| 67 | ) | ||
| 68 | |||
| 69 | target_link_directories(ggml-zendnn PRIVATE | ||
| 70 | ${ZENDNN_ROOT}/zendnnl/lib | ||
| 71 | ${ZENDNN_ROOT}/deps/aocldlp/lib | ||
| 72 | ${ZENDNN_ROOT}/deps/aoclutils/lib | ||
| 73 | ${ZENDNN_ROOT}/deps/libxsmm/lib | ||
| 74 | ${ZENDNN_ROOT}/deps/onednn/lib | ||
| 75 | ) | ||
| 76 | |||
| 77 | target_link_libraries(ggml-zendnn PRIVATE | ||
| 78 | zendnnl_archive # ZenDNN main | ||
| 79 | aocl-dlp # AOCL libraries | ||
| 80 | aoclutils | ||
| 81 | au_cpuid | ||
| 82 | dnnl # OneDNN | ||
| 83 | xsmm # libxsmm small matrix math | ||
| 84 | xsmmext | ||
| 85 | xsmmnoblas | ||
| 86 | m | ||
| 87 | pthread | ||
| 88 | ) | ||
| 89 | |||
| 90 | if (GGML_OPENMP) | ||
| 91 | target_link_libraries(ggml-zendnn PRIVATE OpenMP::OpenMP_CXX) | ||
| 92 | endif() | ||
