Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "kompute"]
path = ggml/src/ggml-kompute/kompute
url = https://github.com/nomic-ai/kompute.git
[submodule "ggml-tsi-kernel"]
path = ggml-tsi-kernel
url = [email protected]:tsisw/ggml-tsi-kernel.git
62 changes: 60 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,59 @@ include(CheckIncludeFileCXX)
#set(CMAKE_WARN_DEPRECATED YES)
set(CMAKE_WARN_UNUSED_CLI YES)

if (GGML_TSAVORITE)
if (NOT DEFINED GGML_TSAVORITE_TARGET)
set(GGML_TSAVORITE_TARGET "posix")
endif()
if (NOT ${GGML_TSAVORITE_TARGET} STREQUAL fpga)
set(GGML_TSAVORITE_TARGET "posix")
endif()

if (NOT DEFINED MLIR_COMPILER_DIR)
if (NOT DEFINED $ENV{MLIR_SDK_VERSION})
set (MLIR_COMPILER_DIR /proj/work/rel/sw/sdk-r.0.1.0/compiler)
else()
set (MLIR_COMPILER_DIR $ENV{MLIR_SDK_VERSION}/compiler)
endif()
endif()

if (NOT DEFINED RUNTIME_DIR)
if (NOT DEFINED $ENV{MLIR_SDK_VERSION})
set (RUNTIME_DIR /proj/work/rel/sw/sdk-r.0.1.0/${GGML_TSAVORITE_TARGET}/runtime)
else()
set (RUNTIME_DIR $ENV{MLIR_SDK_VERSION}/${GGML_TSAVORITE_TARGET}/runtime)
endif()
endif()

if (NOT DEFINED GGML_TSI_KERNEL_DIR)
set (GGML_TSI_KERNEL_DIR ${CMAKE_SOURCE_DIR}/ggml-tsi-kernel/${GGML_TSAVORITE_TARGET})
endif()

file(GLOB TLIBS "${RUNTIME_DIR}/lib/*.so" "${GGML_TSI_KERNEL_DIR}/host/*.o")

if (${GGML_TSAVORITE_TARGET} STREQUAL fpga)
set(CMAKE_CROSSCOMPILING ON)
set(ARCH_FLAGS -march=armv8-a)
message("Setting target as fpga")
elseif (${GGML_TSAVORITE_TARGET} STREQUAL "posix")
list(APPEND TLIBS "${MLIR_COMPILER_DIR}/lib/libFFMDeviceShim.so")
message("Setting target as posix for tsavorite")
endif()

set(GGML_TSAVORITE_TARGET "${GGML_TSAVORITE_TARGET}" CACHE STRING "Target for tsavorite")
set (TSAVORITE_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/ggml/src/ggml-tsavorite/include)

include_directories(${TSAVORITE_INCLUDE_DIR})
include_directories(${MLIR_COMPILER_DIR}/include/runtime/shim)
include_directories(${RUNTIME_DIR}/include)
message("tsavorite backend is enabled")
endif()

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

if (NOT XCODE AND NOT MSVC AND NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE)
#set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE)
set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build type" FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()

Expand Down Expand Up @@ -82,9 +131,18 @@ option(LLAMA_BUILD_EXAMPLES "llama: build examples" ${LLAMA_STANDALONE})
option(LLAMA_BUILD_SERVER "llama: build server example" ${LLAMA_STANDALONE})

# 3rd party libs
option(LLAMA_CURL "llama: use libcurl to download model from an URL" ON)
option(LLAMA_LLGUIDANCE "llama-common: include LLGuidance library for structured output in common utils" OFF)

if (GGML_TSAVORITE)
if (${GGML_TSAVORITE_TARGET} STREQUAL fpga)
option(LLAMA_CURL "llama: use libcurl to download model from an URL" OFF)
else()
option(LLAMA_CURL "llama: use libcurl to download model from an URL" ON)
endif()
else()
option(LLAMA_CURL "llama: use libcurl to download model from an URL" ON)
endif()

# Required for relocatable CMake package
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/build-info.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/common.cmake)
Expand Down
10 changes: 9 additions & 1 deletion common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,16 @@ endif ()

target_include_directories(${TARGET} PUBLIC .)
target_compile_features (${TARGET} PUBLIC cxx_std_17)
target_link_libraries (${TARGET} PRIVATE ${LLAMA_COMMON_EXTRA_LIBS} PUBLIC llama Threads::Threads)

if (GGML_TSAVORITE)
if (${GGML_TSAVORITE_TARGET} STREQUAL fpga)
target_link_libraries (${TARGET} PRIVATE ${LLAMA_COMMON_EXTRA_LIBS} ${TLIBS} PUBLIC llama Threads::Threads)
else()
target_link_libraries (${TARGET} PRIVATE ${LLAMA_COMMON_EXTRA_LIBS} PUBLIC llama Threads::Threads)
endif()
else()
target_link_libraries (${TARGET} PRIVATE ${LLAMA_COMMON_EXTRA_LIBS} PUBLIC llama Threads::Threads)
endif()

#
# copy the license files
Expand Down
1 change: 1 addition & 0 deletions examples/gguf-hash/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
set(TARGET llama-gguf-hash)
add_executable(${TARGET} gguf-hash.cpp)
target_link_libraries(${TARGET} PRIVATE ${TLIBS})
install(TARGETS ${TARGET} RUNTIME)

# clibs dependencies
Expand Down
2 changes: 1 addition & 1 deletion examples/gguf/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
set(TARGET llama-gguf)
add_executable(${TARGET} gguf.cpp)
install(TARGETS ${TARGET} RUNTIME)
target_link_libraries(${TARGET} PRIVATE ggml ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries(${TARGET} PRIVATE ggml ${CMAKE_THREAD_LIBS_INIT} ${TLIBS})
target_compile_features(${TARGET} PRIVATE cxx_std_17)
8 changes: 4 additions & 4 deletions examples/lookup/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
set(TARGET llama-lookup)
add_executable(${TARGET} lookup.cpp)
install(TARGETS ${TARGET} RUNTIME)
target_link_libraries(${TARGET} PRIVATE common llama ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries(${TARGET} PRIVATE common llama ${CMAKE_THREAD_LIBS_INIT} ${TLIBS})
target_compile_features(${TARGET} PRIVATE cxx_std_17)

set(TARGET llama-lookup-create)
add_executable(${TARGET} lookup-create.cpp)
install(TARGETS ${TARGET} RUNTIME)
target_link_libraries(${TARGET} PRIVATE common llama ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries(${TARGET} PRIVATE common llama ${CMAKE_THREAD_LIBS_INIT} ${TLIBS})
target_compile_features(${TARGET} PRIVATE cxx_std_17)

set(TARGET llama-lookup-merge)
add_executable(${TARGET} lookup-merge.cpp)
install(TARGETS ${TARGET} RUNTIME)
target_link_libraries(${TARGET} PRIVATE common llama ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries(${TARGET} PRIVATE common llama ${CMAKE_THREAD_LIBS_INIT} ${TLIBS})
target_compile_features(${TARGET} PRIVATE cxx_std_17)

set(TARGET llama-lookup-stats)
add_executable(${TARGET} lookup-stats.cpp)
install(TARGETS ${TARGET} RUNTIME)
target_link_libraries(${TARGET} PRIVATE common llama ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries(${TARGET} PRIVATE common llama ${CMAKE_THREAD_LIBS_INIT} ${TLIBS})
target_compile_features(${TARGET} PRIVATE cxx_std_17)
2 changes: 1 addition & 1 deletion examples/simple-chat/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
set(TARGET llama-simple-chat)
add_executable(${TARGET} simple-chat.cpp)
install(TARGETS ${TARGET} RUNTIME)
target_link_libraries(${TARGET} PRIVATE llama ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries(${TARGET} PRIVATE llama ${CMAKE_THREAD_LIBS_INIT} ${TLIBS})
target_compile_features(${TARGET} PRIVATE cxx_std_17)
21 changes: 20 additions & 1 deletion examples/simple/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
#
# simple-ctx
set(TARGET llama-simple)
add_executable(${TARGET} simple.cpp)
install(TARGETS ${TARGET} RUNTIME)
target_link_libraries(${TARGET} PRIVATE llama ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries(${TARGET} PRIVATE llama ${TLIBS} ${CMAKE_THREAD_LIBS_INIT})
target_compile_features(${TARGET} PRIVATE cxx_std_17)

#
if (GGML_TSAVORITE)
#
# tsavorite backend test cases
if (${GGML_TSAVORITE_TARGET} STREQUAL fpga)
file(GLOB TLIBS "${RUNTIME_DIR}/lib/*.so" "../../${GGML_TSI_KERNEL_DIR}/host/*.o")
else()
file(GLOB TLIBS "${RUNTIME_DIR}/lib/*.so" "${MLIR_COMPILER_DIR}/lib/libFFMDeviceShim.so" "../../${GGML_TSI_KERNEL_DIR}/host/*.o")
endif()
#
# simple-backend-tsi

set(TEST_TARGET simple-backend-tsi)
add_executable(${TEST_TARGET} simple-backend-tsi.cpp)
target_link_libraries(${TEST_TARGET} PRIVATE ggml ${TLIBS} dl rt)
endif()
Loading