Skip to content

Commit c79cdea

Browse files
committed
GPU: Some work to prepare using <type_traits> and <array> headers from system for GPU
1 parent 073cd16 commit c79cdea

File tree

15 files changed

+71
-19
lines changed

15 files changed

+71
-19
lines changed

Common/MathUtils/include/MathUtils/SMatrixGPU.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@
2929
#include "GPUCommonMath.h"
3030
#include "GPUCommonAlgorithm.h"
3131
#include "GPUCommonLogger.h"
32-
#include "GPUCommonTypeTraits.h"
32+
#ifndef GPUCA_GPUCODE_DEVICE
33+
#include <type_traits>
34+
#endif
3335

3436
namespace o2::math_utils::detail
3537
{

DataFormats/common/include/CommonDataFormat/AbstractRef.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@
1818

1919
#include "GPUCommonDef.h"
2020
#include "GPUCommonRtypes.h"
21-
#include "GPUCommonTypeTraits.h"
21+
#ifndef GPUCA_GPUCODE_DEVICE
22+
#include <type_traits>
23+
#endif
24+
2225

2326
namespace o2::dataformats
2427
{

Detectors/Raw/include/DetectorsRaw/RDHUtils.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,15 @@
1919
#include "GPUCommonRtypes.h"
2020
#include "Headers/RAWDataHeader.h"
2121
#include "Headers/RDHAny.h"
22-
#include "GPUCommonTypeTraits.h"
22+
#ifndef GPUCA_GPUCODE_DEVICE
23+
#include <type_traits>
24+
#endif
2325
#if !defined(GPUCA_GPUCODE)
2426
#include "CommonDataFormat/InteractionRecord.h"
2527
#endif
2628
#if !defined(GPUCA_GPUCODE) && !defined(GPUCA_STANDALONE)
2729
#include "Headers/DAQID.h"
28-
#endif // GPUCA_GPUCODE / GPUCA_STANDALONE
30+
#endif
2931

3032
namespace o2
3133
{
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright 2019-2020 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+
/// \file GPUStdSystemHeaders.h
13+
/// \author David Rohr
14+
15+
#ifndef GPUSTDSYSTEMHEADERS_H
16+
#define GPUSTDSYSTEMHEADERS_H
17+
18+
#include <string>
19+
#include <cstddef>
20+
#include <cstdint>
21+
#include <cfloat>
22+
#include <cmath>
23+
#include <type_traits>
24+
25+
#endif

GPU/GPUTracking/Base/cuda/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ set(GPU_RTC_BIN ${CMAKE_CURRENT_BINARY_DIR}/GPUReconstructionCUDArtc)
6767
# cmake-format: off
6868
add_custom_command(
6969
OUTPUT ${GPU_RTC_BIN}.src
70-
COMMAND cp ${GPUDIR}/Base/cuda/GPUReconstructionCUDAIncludesSystem.h ${GPU_RTC_BIN}.src
70+
COMMAND cp ${GPUDIR}/Base/GPUStdSystemHeaders.h ${GPU_RTC_BIN}.src
71+
COMMAND cat ${GPUDIR}/Base/cuda/GPUReconstructionCUDAIncludesSystem.h | grep -v GPUStdSystemHeaders.h >> ${GPU_RTC_BIN}.src
72+
COMMAND cat ${GPUDIR}/Base/GPUStdSystemHeaders.h >> ${GPU_RTC_BIN}.src
7173
COMMAND ${CMAKE_CUDA_COMPILER} ${GPU_RTC_DEFINES} ${GPU_RTC_INCLUDES} -std=c++${CMAKE_CUDA_STANDARD} -D__CUDA_ARCH__=${RTC_CUDA_ARCH} -D__CUDACC__ -x c++ -E -Xcompiler "-nostdinc -P" ${GPU_RTC_SRC} >> ${GPU_RTC_BIN}.src
7274
MAIN_DEPENDENCY ${GPU_RTC_SRC}
7375
IMPLICIT_DEPENDS CXX ${GPU_RTC_SRC}

GPU/GPUTracking/Base/cuda/GPUReconstructionCUDAIncludesSystem.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@
1515
#ifndef O2_GPU_GPURECONSTRUCTIONCUDAINCLUDESSYSTEM_H
1616
#define O2_GPU_GPURECONSTRUCTIONCUDAINCLUDESSYSTEM_H
1717

18-
#include <cstdint>
19-
#include <type_traits>
20-
#include <string>
18+
#ifndef GPUCA_GPUCODE_GENRTC
19+
#include "GPUStdSystemHeaders.h"
20+
#endif
21+
2122
#include <cuda_runtime.h>
2223
#include <cuda.h>
2324
#include <cooperative_groups.h>

GPU/GPUTracking/Base/hip/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ set(GPU_RTC_BIN ${CMAKE_CURRENT_BINARY_DIR}/GPUReconstructionHIPrtc)
114114
# cmake-format: off
115115
add_custom_command(
116116
OUTPUT ${GPU_RTC_BIN}.src
117-
COMMAND cp ${GPUDIR}/Base/hip/GPUReconstructionHIPIncludesSystem.h ${GPU_RTC_BIN}.src
117+
COMMAND cp ${GPUDIR}/Base/GPUStdSystemHeaders.h ${GPU_RTC_BIN}.src
118+
COMMAND cat ${GPUDIR}/Base/hip/GPUReconstructionHIPIncludesSystem.h | grep -v GPUStdSystemHeaders.h >> ${GPU_RTC_BIN}.src
118119
COMMAND ${CMAKE_HIP_COMPILER} ${GPU_RTC_DEFINES} ${GPU_RTC_INCLUDES} -std=c++${CMAKE_HIP_STANDARD} -D__HIPCC__ -D__HIP_DEVICE_COMPILE__ -x c++ -nostdinc -E -P ${GPU_RTC_SRC} >> ${GPU_RTC_BIN}.src
119120
MAIN_DEPENDENCY ${GPU_RTC_SRC}
120121
IMPLICIT_DEPENDS CXX ${GPU_RTC_SRC}

GPU/GPUTracking/Base/hip/GPUReconstructionHIPIncludesSystem.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
#ifndef O2_GPU_RECONSTRUCTIONHIPINCLUDESSYSTEM_H
1616
#define O2_GPU_RECONSTRUCTIONHIPINCLUDESSYSTEM_H
1717

18+
#ifndef GPUCA_GPUCODE_GENRTC
19+
#include "GPUStdSystemHeaders.h"
20+
#endif
21+
1822
#include <hip/hip_runtime.h>
1923
#include <hip/hip_ext.h>
2024
#include <hipcub/hipcub.hpp>

GPU/GPUTracking/Base/opencl/CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ endif()
2323
set(CL_SRC ${GPUDIR}/Base/opencl/GPUReconstructionOCL.cl)
2424
set(CL_BIN ${CMAKE_CURRENT_BINARY_DIR}/GPUReconstructionOCLCode)
2525

26-
set(OCL_FLAGS -Dcl_clang_storage_class_specifiers -cl-std=CLC++2021 ${GPUCA_OCL_DENORMALS_FLAGS})
26+
set(OCL_FLAGS -Dcl_clang_storage_class_specifiers -x cl -cl-std=CLC++2021 ${GPUCA_OCL_DENORMALS_FLAGS})
2727
if(NOT GPUCA_DETERMINISTIC_MODE GREATER_EQUAL ${GPUCA_DETERMINISTIC_MODE_MAP_NO_FAST_MATH})
2828
set(OCL_FLAGS ${OCL_FLAGS} -cl-mad-enable -cl-no-signed-zeros -cl-fast-relaxed-math)
2929
else()
@@ -43,6 +43,11 @@ if (NOT DEFINED GPUCA_OCL_SPIRV_VERSION)
4343
set(GPUCA_OCL_SPIRV_VERSION 1.2)
4444
endif()
4545

46+
# execute_process(COMMAND bash -c "${LLVM_CLANG} -stdlib=libc++ -E -H -x c++ - <<< '#include <type_traits>' 2>&1 1>/dev/null | grep type_traits | head -n 1 | sed 's/^\\.* *//'"
47+
# OUTPUT_VARIABLE CLANG_STD_INCLUDE_DIR)
48+
# get_filename_component(CLANG_STD_INCLUDE_DIR "${CLANG_STD_INCLUDE_DIR}" DIRECTORY)
49+
# get_filename_component(CLANG_STD_INCLUDE_DIR "${CLANG_STD_INCLUDE_DIR}" ABSOLUTE) # TODO: For using <type_traits> in OpenCL, we would need to add -I${CLANG_STD_INCLUDE_DIR}
50+
4651
if(OPENCL_ENABLED_SPIRV) # BUILD OpenCL intermediate code for SPIR-V target
4752
# executes clang to create llvm IL code
4853
# Add -fintegrated-objemitter once we switch to clang >= 17
@@ -71,6 +76,7 @@ if(OPENCL_ENABLED) # BUILD OpenCL source code for runtime compilation target
7176
add_custom_command(
7277
OUTPUT ${CL_BIN}.src
7378
COMMAND ${LLVM_CLANG}
79+
-target spir64
7480
-Wno-unused-command-line-argument
7581
${OCL_FLAGS}
7682
${OCL_DEFINECL}

GPU/GPUTracking/Base/opencl/GPUReconstructionOCL.cl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ typedef signed char int8_t;
7070
#endif
7171
#define assert(param)
7272

73+
#include "GPUCommonDef.h"
74+
#include "GPUCommonTypeTraits.h" // TODO: Once possible in OpenCL, should use GPUStdSystemHeaders.h here
7375
#include "GPUConstantMem.h"
7476
#include "GPUReconstructionIncludesDeviceAll.h"
7577

0 commit comments

Comments
 (0)