Skip to content

Commit f7a0d25

Browse files
authored
Add OpenMP support in CMakeList (#939)
Useful for CPU based inference, but also for Cublas lowvram inference (TG)
1 parent fdca385 commit f7a0d25

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ set(LLAMA_CUDA_PEER_MAX_BATCH_SIZE "128" CACHE STRING
5151
"llama: max. batch size for using peer access")
5252
option(LLAMA_HIPBLAS "llama: use hipBLAS" OFF)
5353

54+
# Other
55+
option(LLAMA_OPENMP "llama: use OpenMP" OFF)
5456

5557
#
5658
# Compile flags
@@ -286,6 +288,17 @@ if (LLAMA_LTO)
286288
endif()
287289
endif()
288290

291+
if (LLAMA_OPENMP)
292+
find_package(OpenMP)
293+
if (OpenMP_FOUND)
294+
message(STATUS "OpenMP found")
295+
add_compile_definitions(GGML_USE_OPENMP)
296+
set(LLAMA_EXTRA_LIBS ${LLAMA_EXTRA_LIBS} OpenMP::OpenMP_C OpenMP::OpenMP_CXX)
297+
else()
298+
message(WARNING "OpenMP not found")
299+
endif()
300+
endif()
301+
289302
# this version of Apple ld64 is buggy
290303
execute_process(
291304
COMMAND ${CMAKE_C_COMPILER} ${CMAKE_EXE_LINKER_FLAGS} -Wl,-v

0 commit comments

Comments
 (0)