-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
317 additions
and
283 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,174 @@ | ||
cmake_minimum_required(VERSION 3.13) | ||
project(LCI | ||
DESCRIPTION "Lightweight Communication Interface" | ||
HOMEPAGE_URL "https://github.com/uiuc-hpc/LC" | ||
LANGUAGES C | ||
) | ||
|
||
include(GNUInstallDirs) | ||
|
||
set(CMAKE_THREAD_PREFER_PTHREAD TRUE) | ||
set(THREADS_PREFER_PTHREAD_FLAG TRUE) | ||
find_package(Threads REQUIRED) | ||
find_package(PkgConfig) | ||
|
||
set(LC_SERVER psm CACHE STRING "Fabric") | ||
set_property(CACHE LC_SERVER PROPERTY STRINGS ofi ibv psm) | ||
option(LC_SERVER_DEBUG "Server debug" OFF) | ||
option(LC_USE_DREG "Use registration cache (only affects ibv -- only use when not-so-dynamic allocation)" ON) | ||
set(LC_EP_AR dynamic explicit CACHE STRING "Addressing mode (dynamic, explicit, immediate)") | ||
set(LC_EP_CE sync cq CACHE STRING "Completion mechanism (sync, cq, am, glob)") | ||
set(LC_MAX_DEV 1 CACHE STRING "Maximum number of devices") | ||
set(LC_MAX_EP 8 CACHE STRING "Maximum number of EP") | ||
|
||
if(LC_SERVER STREQUAL "ofi") | ||
set(LC_USE_SERVER_OFI ON) | ||
elseif(LC_SERVER STREQUAL "ibv") | ||
set(LC_USE_SERVER_IBV ON) | ||
elseif(LC_SERVER STREQUAL "psm") | ||
set(LC_USE_SERVER_PSM ON) | ||
endif() | ||
|
||
if("dynamic" IN_LIST LC_EP_AR) | ||
set(LC_SERVER_HAS_DYN ON) | ||
endif() | ||
if("explicit" IN_LIST LC_EP_AR) | ||
set(LC_SERVER_HAS_EXP ON) | ||
endif() | ||
if("immediate" IN_LIST LC_EP_AR) | ||
set(LC_SERVER_HAS_IMM ON) | ||
endif() | ||
|
||
if("sync" IN_LIST LC_EP_CE) | ||
set(LC_SERVER_HAS_SYNC ON) | ||
endif() | ||
if("cq" IN_LIST LC_EP_CE) | ||
set(LC_SERVER_HAS_CQ ON) | ||
endif() | ||
if("am" IN_LIST LC_EP_CE) | ||
set(LC_SERVER_HAS_AM ON) | ||
endif() | ||
if("glob" IN_LIST LC_EP_CE) | ||
set(LC_SERVER_HAS_GLOB ON) | ||
endif() | ||
|
||
set(USE_AFFI ON CACHE BOOL "CPU affinity") | ||
mark_as_advanced(USE_AFFI) | ||
if(USE_AFFI) | ||
set(AFF_DEBUG ON) | ||
add_compile_definitions(USE_AFFI AFF_DEBUG) | ||
endif() | ||
|
||
set(USE_DREG ${LC_USE_DREG}) | ||
|
||
#NOTE(danghvu): These numbers are tweaked for performance and some alignment. | ||
#Update at our own risk. | ||
if(LC_USE_SERVER_OFI) | ||
set(LC_PACKET_SIZE "(32 * 1024 + 4096)") | ||
else() | ||
set(LC_PACKET_SIZE "(8 * 1024 + 4096)") | ||
endif() | ||
set(LC_PACKET_SIZE ${LC_PACKET_SIZE} CACHE STRING "Size of packet") | ||
set(LC_MAX_INLINE 128 CACHE STRING "Max inline message size") | ||
set(LC_DEV_MEM_SIZE "(8*1024*1024)" CACHE STRING "Size of device memory") | ||
set(LC_SERVER_MAX_RCVS 64 CACHE STRING "Max posted recvs") | ||
set(LC_SERVER_NUM_PKTS 1024 CACHE STRING "Number of packets") | ||
set(LC_CACHE_LINE 64 CACHE STRING "Size of cache line (bytes)") | ||
mark_as_advanced( | ||
LC_PACKET_SIZE | ||
LC_MAX_INLINE | ||
LC_DEV_MEM_SIZE | ||
LC_SERVER_MAX_RCVS | ||
LC_SERVER_NUM_PKTS | ||
LC_CACHE_LINE | ||
) | ||
|
||
|
||
|
||
|
||
|
||
if(LC_USE_SERVER_OFI) | ||
if(PKG_CONFIG_FOUND) | ||
pkg_check_modules(OFI libfabric IMPORTED_TARGET GLOBAL) | ||
endif() | ||
if(OFI_FOUND) | ||
add_library(OFI ALIAS PkgConfig::OFI) | ||
set(PKGCONFIG_REQUIRES_PRIVATE libfabric) | ||
else() | ||
add_library(OFI INTERFACE IMPORTED GLOBAL) | ||
set_target_properties(OFI PROPERTIES IMPORTED_LIBNAME fabric) | ||
set(PKGCONFIG_LIBS_PRIVATE "-lfabric") | ||
endif() | ||
add_library(Fabric::Fabric ALIAS OFI) | ||
elseif(LC_USE_SERVER_IBV) | ||
if(PKG_CONFIG_FOUND) | ||
pkg_check_modules(IBV libibverbs IMPORTED_TARGET GLOBAL) | ||
endif() | ||
if(IBV_FOUND) | ||
add_library(IBV ALIAS PkgConfig::IBV) | ||
set(PKGCONFIG_REQUIRES_PRIVATE libibverbs) | ||
else() | ||
add_library(IBV INTERFACE IMPORTED GLOBAL) | ||
set_target_properties(IBV PROPERTIES IMPORTED_LIBNAME ibverbs) | ||
set(PKGCONFIG_LIBS_PRIVATE "-libverbs") | ||
endif() | ||
add_library(Fabric::Fabric ALIAS IBV) | ||
elseif(LC_USE_SERVER_PSM) | ||
if(PKG_CONFIG_FOUND) | ||
pkg_check_modules(PSM libpsm2 IMPORTED_TARGET GLOBAL) | ||
endif() | ||
if(PSM_FOUND) | ||
add_library(PSM ALIAS PkgConfig::PSM) | ||
set(PKGCONFIG_REQUIRES_PRIVATE libpsm2) | ||
else() | ||
add_library(PSM INTERFACE IMPORTED GLOBAL) | ||
set_target_properties(PSM PROPERTIES IMPORTED_LIBNAME psm2) | ||
set(PKGCONFIG_LIBS_PRIVATE "-lpsm2") | ||
endif() | ||
add_library(Fabric::Fabric ALIAS PSM) | ||
endif() | ||
|
||
|
||
|
||
|
||
|
||
add_library(lci-obj OBJECT) | ||
set_target_properties(lci-obj PROPERTIES | ||
POSITION_INDEPENDENT_CODE ON | ||
C_VISIBILITY_PRESET hidden | ||
C_STANDARD 99 | ||
C_EXTENSIONS ON | ||
) | ||
target_compile_definitions(lci-obj PRIVATE _GNU_SOURCE) | ||
target_include_directories(lci-obj PUBLIC include) | ||
target_link_libraries(lci-obj PUBLIC | ||
Threads::Threads | ||
Fabric::Fabric | ||
) | ||
|
||
add_library(lci_shared SHARED) | ||
add_library(lci_static STATIC) | ||
target_link_libraries(lci_shared PRIVATE lci-obj) | ||
target_link_libraries(lci_static PRIVATE lci-obj) | ||
target_include_directories(lci_shared INTERFACE include) | ||
target_include_directories(lci_static INTERFACE include) | ||
set_target_properties(lci_shared lci_static PROPERTIES OUTPUT_NAME lci) | ||
|
||
add_subdirectory(src) | ||
add_subdirectory(examples) | ||
|
||
|
||
|
||
|
||
|
||
configure_file(liblci.pc.in liblci.pc @ONLY) | ||
|
||
install(TARGETS lci_shared lci_static DESTINATION ${CMAKE_INSTALL_LIBDIR}) | ||
install(DIRECTORY include/ | ||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} | ||
FILES_MATCHING PATTERN "*.h" | ||
) | ||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/liblci.pc | ||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig | ||
) | ||
install(PROGRAMS lcrun DESTINATION ${CMAKE_INSTALL_BINDIR}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
function(add_example NAME) | ||
add_executable(${NAME} ${NAME}.c) | ||
target_compile_definitions(${NAME} PRIVATE _GNU_SOURCE) | ||
target_link_libraries(${NAME} PRIVATE | ||
Threads::Threads | ||
lci_static | ||
) | ||
target_link_options(${NAME} PRIVATE | ||
LINKER:-z,now | ||
LINKER:-z,relro | ||
) | ||
set_target_properties(${NAME} PROPERTIES | ||
C_STANDARD 99 | ||
C_EXTENSIONS ON | ||
) | ||
install(TARGETS ${NAME} DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/lc) | ||
endfunction() | ||
|
||
function(add_all_examples) | ||
foreach(example ${ARGN}) | ||
add_example(${example}) | ||
endforeach() | ||
endfunction() | ||
|
||
add_all_examples( | ||
init | ||
tshort | ||
tmed | ||
tlong | ||
qshort | ||
qmed | ||
qlong | ||
qmed_dup | ||
qmed_dup_2hw | ||
puts | ||
putm | ||
putl | ||
putss | ||
putms | ||
putls | ||
putsam | ||
tag | ||
ibarrier | ||
ialreduce | ||
) |
Oops, something went wrong.