Spaces:
Running
vulkan : cmake integration (llama/8119)
Browse files* Add Vulkan to CMake pkg
* Add Sycl to CMake pkg
* Add OpenMP to CMake pkg
* Split generated shader file into separate translation unit
* Add CMake target for Vulkan shaders
* Update README.md
* Add make target for Vulkan shaders
* Use pkg-config to locate vulkan library
* Add vulkan SDK dep to ubuntu-22-cmake-vulkan workflow
* Clean up tabs
* Move sudo to apt-key invocation
* Forward GGML_EXTRA_LIBS to CMake config pkg
* Update vulkan obj file paths
* Add shaderc to nix pkg
* Add python3 to Vulkan nix build
* Link against ggml in cmake pkg
* Remove Python dependency from Vulkan build
* code review changes
* Remove trailing newline
* Add cflags from pkg-config to fix w64devkit build
* Update README.md
* Remove trailing whitespace
* Update README.md
* Remove trailing whitespace
* Fix doc heading
* Make glslc required Vulkan component
* remove clblast from nix pkg
- ggml/src/CMakeLists.txt +32 -5
|
@@ -527,14 +527,11 @@ if (GGML_RPC)
|
|
| 527 |
endif()
|
| 528 |
|
| 529 |
if (GGML_VULKAN)
|
| 530 |
-
find_package(Vulkan)
|
| 531 |
|
| 532 |
if (Vulkan_FOUND)
|
| 533 |
message(STATUS "Vulkan found")
|
| 534 |
|
| 535 |
-
set(GGML_HEADERS_VULKAN ../include/ggml-vulkan.h)
|
| 536 |
-
set(GGML_SOURCES_VULKAN ggml-vulkan.cpp)
|
| 537 |
-
|
| 538 |
list(APPEND GGML_CDEF_PUBLIC GGML_USE_VULKAN)
|
| 539 |
|
| 540 |
# Workaround to the "can't dereference invalidated vector iterator" bug in clang-cl debug build
|
|
@@ -563,7 +560,37 @@ if (GGML_VULKAN)
|
|
| 563 |
add_compile_definitions(GGML_VULKAN_RUN_TESTS)
|
| 564 |
endif()
|
| 565 |
|
| 566 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 567 |
else()
|
| 568 |
message(WARNING "Vulkan not found")
|
| 569 |
endif()
|
|
|
|
| 527 |
endif()
|
| 528 |
|
| 529 |
if (GGML_VULKAN)
|
| 530 |
+
find_package(Vulkan COMPONENTS glslc REQUIRED)
|
| 531 |
|
| 532 |
if (Vulkan_FOUND)
|
| 533 |
message(STATUS "Vulkan found")
|
| 534 |
|
|
|
|
|
|
|
|
|
|
| 535 |
list(APPEND GGML_CDEF_PUBLIC GGML_USE_VULKAN)
|
| 536 |
|
| 537 |
# Workaround to the "can't dereference invalidated vector iterator" bug in clang-cl debug build
|
|
|
|
| 560 |
add_compile_definitions(GGML_VULKAN_RUN_TESTS)
|
| 561 |
endif()
|
| 562 |
|
| 563 |
+
add_subdirectory(vulkan-shaders)
|
| 564 |
+
|
| 565 |
+
set (_ggml_vk_genshaders_cmd vulkan-shaders-gen)
|
| 566 |
+
set (_ggml_vk_header ${CMAKE_CURRENT_BINARY_DIR}/ggml-vulkan-shaders.hpp)
|
| 567 |
+
set (_ggml_vk_source ${CMAKE_CURRENT_BINARY_DIR}/ggml-vulkan-shaders.cpp)
|
| 568 |
+
set (_ggml_vk_input_dir ${CMAKE_CURRENT_SOURCE_DIR}/vulkan-shaders)
|
| 569 |
+
set (_ggml_vk_output_dir ${CMAKE_CURRENT_BINARY_DIR}/vulkan-shaders.spv)
|
| 570 |
+
|
| 571 |
+
file(GLOB _ggml_vk_shader_deps "${_ggml_vk_input_dir}/*.comp")
|
| 572 |
+
|
| 573 |
+
add_custom_command(
|
| 574 |
+
OUTPUT ${_ggml_vk_header}
|
| 575 |
+
${_ggml_vk_source}
|
| 576 |
+
|
| 577 |
+
COMMAND ${_ggml_vk_genshaders_cmd}
|
| 578 |
+
--glslc ${Vulkan_GLSLC_EXECUTABLE}
|
| 579 |
+
--input-dir ${_ggml_vk_input_dir}
|
| 580 |
+
--output-dir ${_ggml_vk_output_dir}
|
| 581 |
+
--target-hpp ${_ggml_vk_header}
|
| 582 |
+
--target-cpp ${_ggml_vk_source}
|
| 583 |
+
--no-clean
|
| 584 |
+
|
| 585 |
+
DEPENDS ${_ggml_vk_shader_deps}
|
| 586 |
+
COMMENT "Generate vulkan shaders"
|
| 587 |
+
)
|
| 588 |
+
|
| 589 |
+
set(GGML_HEADERS_VULKAN ${CMAKE_CURRENT_SOURCE_DIR}/../include/ggml-vulkan.h ${_ggml_vk_header})
|
| 590 |
+
set(GGML_SOURCES_VULKAN ggml-vulkan.cpp ${_ggml_vk_source})
|
| 591 |
+
|
| 592 |
+
set(GGML_EXTRA_LIBS ${GGML_EXTRA_LIBS} Vulkan::Vulkan)
|
| 593 |
+
set(GGML_EXTRA_INCLUDES ${GGML_EXTRA_INCLUDES} ${CMAKE_CURRENT_BINARY_DIR})
|
| 594 |
else()
|
| 595 |
message(WARNING "Vulkan not found")
|
| 596 |
endif()
|