Skip to content

Commit

Permalink
GPU: Reorganize some files, split OCL code in kernel and non-kernel r…
Browse files Browse the repository at this point in the history
…elated parts
  • Loading branch information
davidrohr committed Feb 25, 2025
1 parent e7f1bd1 commit b241b90
Show file tree
Hide file tree
Showing 16 changed files with 351 additions and 298 deletions.
4 changes: 2 additions & 2 deletions GPU/GPUTracking/Base/cuda/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ endif()
message(STATUS "Building GPUTracking with CUDA support ${TMP_TARGET}")

set(SRCS GPUReconstructionCUDA.cu GPUReconstructionCUDAGenRTC.cxx GPUReconstructionCUDAKernels.cu)
set(HDRS GPUReconstructionCUDA.h GPUReconstructionCUDAInternals.h GPUReconstructionCUDADef.h GPUReconstructionCUDAIncludes.h CUDAThrustHelpers.h)
set(HDRS GPUReconstructionCUDA.h GPUReconstructionCUDAInternals.h GPUReconstructionCUDADef.h GPUReconstructionCUDAIncludesHost.h CUDAThrustHelpers.h)
# -------------------------------- Prepare RTC -------------------------------------------------------
enable_language(ASM)
if(ALIGPU_BUILD_TYPE STREQUAL "O2")
Expand Down Expand Up @@ -67,7 +67,7 @@ set(GPU_RTC_BIN ${CMAKE_CURRENT_BINARY_DIR}/GPUReconstructionCUDArtc)
# cmake-format: off
add_custom_command(
OUTPUT ${GPU_RTC_BIN}.src
COMMAND cat ${GPUDIR}/Base/cuda/GPUReconstructionCUDAIncludes.h > ${GPU_RTC_BIN}.src
COMMAND cp ${GPUDIR}/Base/cuda/GPUReconstructionCUDAIncludesHost.h ${GPU_RTC_BIN}.src
COMMAND ${CMAKE_CXX_COMPILER} ${GPU_RTC_DEFINES} ${GPU_RTC_INCLUDES} -std=c++${CMAKE_CUDA_STANDARD} -D__CUDA_ARCH__=${RTC_CUDA_ARCH} -D__CUDACC__ -x c++ -nostdinc -E ${GPU_RTC_SRC} >> ${GPU_RTC_BIN}.src
MAIN_DEPENDENCY ${GPU_RTC_SRC}
IMPLICIT_DEPENDS CXX ${GPU_RTC_SRC}
Expand Down
3 changes: 1 addition & 2 deletions GPU/GPUTracking/Base/cuda/GPUReconstructionCUDA.cu
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
/// \author David Rohr

#define GPUCA_GPUCODE_HOSTONLY
#include "GPUReconstructionCUDADef.h"
#include "GPUReconstructionCUDAIncludes.h"
#include "GPUReconstructionCUDAIncludesHost.h"

#include <cuda_profiler_api.h>

Expand Down
2 changes: 1 addition & 1 deletion GPU/GPUTracking/Base/cuda/GPUReconstructionCUDADef.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.

/// \file GPUReconstructionCUDDef.h
/// \file GPUReconstructionCUDADef.h
/// \author David Rohr

#ifndef O2_GPU_GPURECONSTRUCTIONCUDADEF_H
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
/// \file GPUReconstructionCUDAExternalProvider.cu
/// \author David Rohr

#include "GPUReconstructionCUDADef.h"
#include "GPUReconstructionCUDAIncludes.h"
#include "GPUReconstructionCUDAIncludesHost.h"

#include "GPUReconstructionCUDA.h"
#include "GPUReconstructionCUDAInternals.h"
Expand Down
4 changes: 3 additions & 1 deletion GPU/GPUTracking/Base/cuda/GPUReconstructionCUDAGenRTC.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ QGET_LD_BINARY_SYMBOLS(GPUReconstructionCUDArtc_command_arch);

int32_t GPUReconstructionCUDA::genRTC(std::string& filename, uint32_t& nCompile)
{
std::string rtcparam = std::string(mProcessingSettings.rtc.optSpecialCode ? "#define GPUCA_RTC_SPECIAL_CODE(...) __VA_ARGS__\n" : "#define GPUCA_RTC_SPECIAL_CODE(...)\n") + GPUParamRTC::generateRTCCode(param(), mProcessingSettings.rtc.optConstexpr);
std::string rtcparam = std::string("#define GPUCA_RTC_CODE\n") +
std::string(mProcessingSettings.rtc.optSpecialCode ? "#define GPUCA_RTC_SPECIAL_CODE(...) __VA_ARGS__\n" : "#define GPUCA_RTC_SPECIAL_CODE(...)\n") +
GPUParamRTC::generateRTCCode(param(), mProcessingSettings.rtc.optConstexpr);
if (filename == "") {
filename = "/tmp/o2cagpu_rtc_";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,8 @@
#include <sm_20_atomic_functions.h>
#include <cuda_fp16.h>

#ifndef GPUCA_RTC_CODE
#include "GPUReconstructionCUDADef.h"
#endif

#endif
3 changes: 1 addition & 2 deletions GPU/GPUTracking/Base/cuda/GPUReconstructionCUDAKernels.cu
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
/// \file GPUReconstructionCUDAKernels.cu
/// \author David Rohr

#include "GPUReconstructionCUDADef.h"
#include "GPUReconstructionCUDAIncludes.h"
#include "GPUReconstructionCUDAIncludesHost.h"

#include "GPUReconstructionCUDA.h"
#include "GPUReconstructionCUDAInternals.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
/// \author David Rohr

#define GPUCA_GPUCODE_COMPILEKERNELS
#include "GPUReconstructionCUDAIncludes.h"
#include "GPUReconstructionCUDADef.h"
#include "GPUReconstructionCUDAIncludesHost.h"
#define GPUCA_KRNL_REG(args) __launch_bounds__(GPUCA_M_MAX2_3(GPUCA_M_STRIP(args)))
#define GPUCA_KRNL(...) GPUCA_KRNL_WRAP(GPUCA_KRNL_LOAD_, __VA_ARGS__)
#define GPUCA_KRNL_LOAD_single(...) GPUCA_KRNLGPU_SINGLE(__VA_ARGS__);
Expand Down
6 changes: 3 additions & 3 deletions GPU/GPUTracking/Base/hip/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ if(NOT DEFINED GPUCA_HIP_HIPIFY_FROM_CUDA OR "${GPUCA_HIP_HIPIFY_FROM_CUDA}")
set(GPUCA_HIP_SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/hipify)
file(MAKE_DIRECTORY ${GPUCA_HIP_SOURCE_DIR})
set(GPUCA_HIP_FILE_LIST GPUReconstructionCUDA.cu GPUReconstructionCUDAExternalProvider.cu GPUReconstructionCUDA.h GPUReconstructionCUDAInternals.h GPUReconstructionCUDAkernel.template.cu CUDAThrustHelpers.h GPUReconstructionCUDADef.h GPUReconstructionCUDAGenRTC.cxx GPUReconstructionCUDAKernels.cu GPUReconstructionCUDArtc.cu)
set(GPUCA_HIP_LOCAL_FILE_LIST GPUReconstructionHIPIncludes.h)
set(GPUCA_HIP_LOCAL_FILE_LIST GPUReconstructionHIPIncludesHost.h)
set(HIP_SOURCES "")
foreach(file ${GPUCA_HIP_FILE_LIST})
get_filename_component(ABS_CUDA_SORUCE ../cuda/${file} ABSOLUTE)
Expand Down Expand Up @@ -63,7 +63,7 @@ endif()

set(SRCS ${GPUCA_HIP_SOURCE_DIR}/GPUReconstructionHIP.hip ${GPUCA_HIP_SOURCE_DIR}/GPUReconstructionHIPKernels.hip)
set(SRCS_CXX ${GPUCA_HIP_SOURCE_DIR}/GPUReconstructionHIPGenRTC.cxx)
set(HDRS ${GPUCA_HIP_SOURCE_DIR}/GPUReconstructionHIP.h ${GPUCA_HIP_SOURCE_DIR}/GPUReconstructionHIPInternals.h ${GPUCA_HIP_SOURCE_DIR}/GPUReconstructionHIPDef.h ${GPUCA_HIP_SOURCE_DIR}/GPUReconstructionHIPIncludes.h ${GPUCA_HIP_SOURCE_DIR}/HIPThrustHelpers.h)
set(HDRS ${GPUCA_HIP_SOURCE_DIR}/GPUReconstructionHIP.h ${GPUCA_HIP_SOURCE_DIR}/GPUReconstructionHIPInternals.h ${GPUCA_HIP_SOURCE_DIR}/GPUReconstructionHIPDef.h ${GPUCA_HIP_SOURCE_DIR}/GPUReconstructionHIPIncludesHost.h ${GPUCA_HIP_SOURCE_DIR}/HIPThrustHelpers.h)

# -------------------------------- Prepare RTC -------------------------------------------------------
enable_language(ASM)
Expand Down Expand Up @@ -104,7 +104,7 @@ set(GPU_RTC_BIN ${CMAKE_CURRENT_BINARY_DIR}/GPUReconstructionHIPrtc)
# cmake-format: off
add_custom_command(
OUTPUT ${GPU_RTC_BIN}.src
COMMAND cat ${GPUDIR}/Base/hip/GPUReconstructionHIPIncludes.h > ${GPU_RTC_BIN}.src
COMMAND cp ${GPUDIR}/Base/hip/GPUReconstructionHIPIncludesHost.h ${GPU_RTC_BIN}.src
COMMAND ${CMAKE_CXX_COMPILER} ${GPU_RTC_DEFINES} ${GPU_RTC_INCLUDES} -std=c++${CMAKE_HIP_STANDARD} -D__HIPCC__ -D__HIP_DEVICE_COMPILE__ -x c++ -nostdinc -E ${GPU_RTC_SRC} >> ${GPU_RTC_BIN}.src
MAIN_DEPENDENCY ${GPU_RTC_SRC}
IMPLICIT_DEPENDS CXX ${GPU_RTC_SRC}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.

/// \file GPUReconstructionHIPInclude.h
/// \file GPUReconstructionHIPIncludesHost.h
/// \author David Rohr

#ifndef O2_GPU_RECONSTRUCTIONHIPINCLUDES_H
Expand All @@ -27,4 +27,8 @@
#include <thrust/device_ptr.h>
#pragma GCC diagnostic pop

#ifndef GPUCA_RTC_CODE
#include "GPUReconstructionHIPDef.h"
#endif

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
/// \author David Rohr

#define GPUCA_GPUCODE_COMPILEKERNELS
#include "GPUReconstructionHIPIncludes.h"
#include "GPUReconstructionHIPDef.h"
#include "GPUReconstructionHIPIncludesHost.h"
#define GPUCA_KRNL_REG(args) __launch_bounds__(GPUCA_M_MAX2_3(GPUCA_M_STRIP(args)))
#define GPUCA_KRNL(...) GPUCA_KRNL_WRAP(GPUCA_KRNL_LOAD_, __VA_ARGS__)
#define GPUCA_KRNL_LOAD_single(...) GPUCA_KRNLGPU_SINGLE(__VA_ARGS__);
Expand Down
4 changes: 2 additions & 2 deletions GPU/GPUTracking/Base/opencl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ set(OCL_DEFINECL "-D$<JOIN:$<TARGET_PROPERTY:O2::GPUTracking,COMPILE_DEFINITIONS
-I${CMAKE_SOURCE_DIR}/DataFormats/Reconstruction/src
)

set(SRCS GPUReconstructionOCL.cxx)
set(HDRS GPUReconstructionOCL.h)
set(SRCS GPUReconstructionOCL.cxx GPUReconstructionOCLKernels.cxx)
set(HDRS GPUReconstructionOCL.h GPUReconstructionOCLIncludesHost.h)

if (NOT DEFINED GPUCA_OCL_SPIRV_VERSION)
set(GPUCA_OCL_SPIRV_VERSION 1.2)
Expand Down
Loading

0 comments on commit b241b90

Please sign in to comment.