|
| 1 | +# Copyright 2019-2026 CERN and copyright holders of ALICE O2. |
| 2 | +# See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. |
| 3 | +# All rights not expressly granted are reserved. |
| 4 | +# |
| 5 | +# This software is distributed under the terms of the GNU General Public |
| 6 | +# License v3 (GPL Version 3), copied verbatim in the file "COPYING". |
| 7 | +# |
| 8 | +# In applying this license CERN does not waive the privileges and immunities |
| 9 | +# granted to it by virtue of its status as an Intergovernmental Organization |
| 10 | +# or submit itself to any jurisdiction. |
| 11 | + |
| 12 | +set(MODULE GPUTrackingCPUDevice) |
| 13 | + |
| 14 | +set(SRCS GPUReconstructionCPUDevice.cxx GPUReconstructionCPUDeviceGenRTC.cxx) |
| 15 | +set(HDRS GPUReconstructionCPUDevice.h GPUReconstructionCPUDeviceInternals.h GPUReconstructionCPUDeviceIncludesSystem.h) |
| 16 | + |
| 17 | +if(CMAKE_SYSTEM_NAME STREQUAL "Linux") |
| 18 | + set(GPUCA_CPUDEVICE_RTC ON) |
| 19 | +else() |
| 20 | + set(GPUCA_CPUDEVICE_RTC OFF) |
| 21 | +endif() |
| 22 | +message(STATUS "Building GPUTracking with CPUDevice support (RTC: ${GPUCA_CPUDEVICE_RTC})") |
| 23 | + |
| 24 | +if(ALIGPU_BUILD_TYPE STREQUAL "O2") |
| 25 | + set(defineIncludeSrc "O2::${MODULE}") |
| 26 | +else() |
| 27 | + set(defineIncludeSrc "${MODULE}") |
| 28 | +endif() |
| 29 | + |
| 30 | +if(GPUCA_CPUDEVICE_RTC) # RTC compiles the kernels with the host compiler and the host compiler flags, and loads them via dlopen |
| 31 | + enable_language(ASM) |
| 32 | + if(ALIGPU_BUILD_TYPE STREQUAL "Standalone") |
| 33 | + get_filename_component(GPUDIR ${CMAKE_SOURCE_DIR}/../ ABSOLUTE) |
| 34 | + else() |
| 35 | + set(GPUDIR ${CMAKE_SOURCE_DIR}/GPU/GPUTracking) |
| 36 | + endif() |
| 37 | + string(TOUPPER "${CMAKE_BUILD_TYPE}" TMP_BUILD_TYPE_UPPER) |
| 38 | + set(GPU_RTC_DEFINES "-D$<JOIN:$<TARGET_PROPERTY:${defineIncludeSrc},COMPILE_DEFINITIONS>,$<SEMICOLON>-D>") |
| 39 | + set(GPU_RTC_INCLUDES "-I$<JOIN:$<FILTER:$<TARGET_PROPERTY:${defineIncludeSrc},INCLUDE_DIRECTORIES>,EXCLUDE,^/usr/include/?>,$<SEMICOLON>-I>" |
| 40 | + -I${CMAKE_SOURCE_DIR}/Detectors/Base/src |
| 41 | + -I${CMAKE_SOURCE_DIR}/Detectors/TRD/base/src |
| 42 | + ) |
| 43 | + separate_arguments(GPU_RTC_FLAGS NATIVE_COMMAND "-std=c++${CMAKE_CXX_STANDARD} ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${TMP_BUILD_TYPE_UPPER}} -w") |
| 44 | + set(GPU_RTC_LINK_FLAGS -fPIC -shared -fvisibility=hidden -fvisibility-inlines-hidden -static-libstdc++ -static-libgcc -Wl,--exclude-libs,ALL -Wl,-Bsymbolic -Wl,-z,defs) # Self-contained library, only the kernels are exported (version script at runtime) |
| 45 | + set(GPU_RTC_SRC ${GPUDIR}/Base/cpudevice/GPUReconstructionCPUDevicertc.cxx) |
| 46 | + set(GPU_RTC_BIN ${CMAKE_CURRENT_BINARY_DIR}/GPUReconstructionCPUDevicertc) |
| 47 | + |
| 48 | + add_custom_command( |
| 49 | + OUTPUT ${GPU_RTC_BIN}.src |
| 50 | + COMMAND cp ${GPUDIR}/Base/GPUStdSystemHeaders.h ${GPU_RTC_BIN}.src |
| 51 | + COMMAND cat ${GPUDIR}/Base/cpudevice/GPUReconstructionCPUDeviceIncludesSystem.h | grep -v GPUStdSystemHeaders.h >> ${GPU_RTC_BIN}.src |
| 52 | + COMMAND ${CMAKE_CXX_COMPILER} ${GPU_RTC_DEFINES} ${GPU_RTC_INCLUDES} ${GPU_RTC_FLAGS} -x c++ -nostdinc -P -E -MD -MT ${GPU_RTC_BIN}.src -MF ${GPU_RTC_BIN}.src.d ${GPU_RTC_SRC} >> ${GPU_RTC_BIN}.src |
| 53 | + DEPENDS ${GPU_RTC_SRC} ${GPUDIR}/Base/GPUStdSystemHeaders.h ${GPUDIR}/Base/cpudevice/GPUReconstructionCPUDeviceIncludesSystem.h |
| 54 | + DEPFILE ${GPU_RTC_BIN}.src.d |
| 55 | + COMMAND_EXPAND_LISTS |
| 56 | + COMMENT "Preparing CPUDevice RTC source file ${GPU_RTC_BIN}.src" |
| 57 | + ) |
| 58 | + add_custom_command( |
| 59 | + OUTPUT ${GPU_RTC_BIN}.command |
| 60 | + COMMAND echo -n "${CMAKE_CXX_COMPILER} ${GPU_RTC_FLAGS} ${GPU_RTC_LINK_FLAGS}" > ${GPU_RTC_BIN}.command |
| 61 | + COMMAND_EXPAND_LISTS VERBATIM |
| 62 | + COMMENT "Preparing CPUDevice RTC command file ${GPU_RTC_BIN}.command" |
| 63 | + ) |
| 64 | + add_custom_command( |
| 65 | + OUTPUT ${GPU_RTC_BIN}.command.no_fast_math |
| 66 | + COMMAND echo -n "${GPUCA_CXX_NO_FAST_MATH_FLAGS}" > ${GPU_RTC_BIN}.command.no_fast_math |
| 67 | + COMMAND_EXPAND_LISTS VERBATIM |
| 68 | + COMMENT "Preparing CPUDevice RTC NO_FAST_MATH command file ${GPU_RTC_BIN}.command.no_fast_math" |
| 69 | + ) |
| 70 | + foreach(TMP_RESOURCE src command command.no_fast_math) |
| 71 | + create_binary_resource(${GPU_RTC_BIN}.${TMP_RESOURCE} ${GPU_RTC_BIN}.${TMP_RESOURCE}.o) |
| 72 | + list(APPEND SRCS ${GPU_RTC_BIN}.${TMP_RESOURCE}.o) |
| 73 | + endforeach() |
| 74 | +endif() |
| 75 | + |
| 76 | +if(ALIGPU_BUILD_TYPE STREQUAL "O2") |
| 77 | + o2_add_library( |
| 78 | + ${MODULE} |
| 79 | + SOURCES ${SRCS} |
| 80 | + PUBLIC_LINK_LIBRARIES O2::GPUTracking |
| 81 | + PRIVATE_INCLUDE_DIRECTORIES |
| 82 | + ${CMAKE_SOURCE_DIR}/Detectors/Base/src |
| 83 | + ${CMAKE_SOURCE_DIR}/Detectors/TRD/base/src |
| 84 | + ${CMAKE_SOURCE_DIR}/DataFormats/Reconstruction/src |
| 85 | + ${CMAKE_CURRENT_SOURCE_DIR} |
| 86 | + TARGETVARNAME targetName) |
| 87 | +endif() |
| 88 | + |
| 89 | +if(ALIGPU_BUILD_TYPE STREQUAL "Standalone") |
| 90 | + set(targetName "${MODULE}") |
| 91 | + add_library(${MODULE} SHARED ${SRCS}) |
| 92 | + add_library(O2::${MODULE} ALIAS ${MODULE}) |
| 93 | + target_link_libraries(${MODULE} PUBLIC O2::GPUTracking) |
| 94 | + install(TARGETS ${MODULE}) |
| 95 | + include_directories(${CMAKE_CURRENT_SOURCE_DIR}) |
| 96 | +endif() |
| 97 | + |
| 98 | +install(FILES ${HDRS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/GPU) |
| 99 | + |
| 100 | +target_compile_definitions(${targetName} PRIVATE $<TARGET_PROPERTY:O2::GPUTracking,COMPILE_DEFINITIONS>) |
| 101 | +target_link_libraries(${targetName} PRIVATE TBB::tbb) |
| 102 | +if(GPUCA_CPUDEVICE_RTC) |
| 103 | + target_compile_definitions(${targetName} PRIVATE GPUCA_CPUDEVICE_RTC) |
| 104 | + target_link_libraries(${targetName} PRIVATE ${CMAKE_DL_LIBS}) |
| 105 | +endif() |
0 commit comments