Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions GPU/Common/GPUCommonDefAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,7 @@
#define GPUbarrier() barrier(CLK_LOCAL_MEM_FENCE | CLK_GLOBAL_MEM_FENCE)
#define GPUbarrierWarp() sub_group_barrier(CLK_LOCAL_MEM_FENCE | CLK_GLOBAL_MEM_FENCE)
#define GPUbarrierWarpAlive()
#if defined(__OPENCL__) && defined(GPUCA_OPENCL_CLANG_C11_ATOMICS)
namespace o2 { namespace gpu {
template <class T> struct oclAtomic;
template <> struct oclAtomic<uint32_t> {typedef atomic_uint t;};
static_assert(sizeof(oclAtomic<uint32_t>::t) == sizeof(uint32_t), "Invalid size of atomic type");
}}
#define GPUAtomic(type) o2::gpu::oclAtomic<type>::t
#else
#define GPUAtomic(type) volatile type
#endif
#define GPUAtomic(type) volatile type
#endif
#if !defined(__OPENCL__) // Other special defines for OpenCL 1
#define GPUCA_USE_TEMPLATE_ADDRESS_SPACES // TODO: check if we can make this (partially, where it is already implemented) compatible with OpenCL CPP
Expand Down
2 changes: 0 additions & 2 deletions GPU/Common/GPUCommonDefSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
#error Please include GPUCommonDef.h!
#endif

//#define GPUCA_OPENCL_CLANG_C11_ATOMICS // Use C11 atomic instead of old style atomics for OpenCL C++ in clang (OpenCL 2.2 C++ will use C++11 atomics irrespectively)

//#define GPUCA_CUDA_NO_CONSTANT_MEMORY // Do not use constant memory for CUDA
//#define GPUCA_HIP_NO_CONSTANT_MEMORY // Do not use constant memory for HIP
#define GPUCA_OPENCL_NO_CONSTANT_MEMORY // Do not use constant memory for OpenCL C++ - MANDATORY as OpenCL cannot cast between __constant and __generic yet!
Expand Down
28 changes: 7 additions & 21 deletions GPU/Common/GPUCommonMath.h
Original file line number Diff line number Diff line change
Expand Up @@ -605,9 +605,7 @@ GPUdi() device metal::atomic<T>* GPUCommonMathMetalAtomic(T* p)
template <class S, class T>
GPUdi() uint32_t GPUCommonMath::AtomicExchInternal(S* addr, T val)
{
#if defined(GPUCA_GPUCODE) && defined(__OPENCL__) && (!defined(__clang__) || defined(GPUCA_OPENCL_CLANG_C11_ATOMICS))
return ::atomic_exchange(addr, val);
#elif defined(GPUCA_GPUCODE) && defined(__OPENCL__)
#if defined(GPUCA_GPUCODE) && defined(__OPENCL__)
return ::atomic_xchg(addr, val);
#elif defined(GPUCA_GPUCODE) && (defined(__CUDACC__) || defined(__HIPCC__))
return ::atomicExch(addr, val);
Expand All @@ -625,9 +623,7 @@ GPUdi() uint32_t GPUCommonMath::AtomicExchInternal(S* addr, T val)
template <class S, class T>
GPUdi() bool GPUCommonMath::AtomicCASInternal(S* addr, T cmp, T val)
{
#if defined(GPUCA_GPUCODE) && defined(__OPENCL__) && (!defined(__clang__) || defined(GPUCA_OPENCL_CLANG_C11_ATOMICS))
return ::atomic_compare_exchange(addr, cmp, val) == cmp;
#elif defined(GPUCA_GPUCODE) && defined(__OPENCL__)
#if defined(GPUCA_GPUCODE) && defined(__OPENCL__)
return ::atomic_cmpxchg(addr, cmp, val) == cmp;
#elif defined(GPUCA_GPUCODE) && (defined(__CUDACC__) || defined(__HIPCC__))
return ::atomicCAS(addr, cmp, val) == cmp;
Expand All @@ -643,9 +639,7 @@ GPUdi() bool GPUCommonMath::AtomicCASInternal(S* addr, T cmp, T val)
template <class S, class T>
GPUdi() uint32_t GPUCommonMath::AtomicAddInternal(S* addr, T val)
{
#if defined(GPUCA_GPUCODE) && defined(__OPENCL__) && (!defined(__clang__) || defined(GPUCA_OPENCL_CLANG_C11_ATOMICS))
return ::atomic_fetch_add(addr, val);
#elif defined(GPUCA_GPUCODE) && defined(__OPENCL__)
#if defined(GPUCA_GPUCODE) && defined(__OPENCL__)
return ::atomic_add(addr, val);
#elif defined(GPUCA_GPUCODE) && (defined(__CUDACC__) || defined(__HIPCC__))
return ::atomicAdd(addr, val);
Expand All @@ -661,9 +655,7 @@ GPUdi() uint32_t GPUCommonMath::AtomicAddInternal(S* addr, T val)
template <class S, class T>
GPUdi() void GPUCommonMath::AtomicMaxInternal(S* addr, T val)
{
#if defined(GPUCA_GPUCODE) && defined(__OPENCL__) && (!defined(__clang__) || defined(GPUCA_OPENCL_CLANG_C11_ATOMICS))
::atomic_fetch_max(addr, val);
#elif defined(GPUCA_GPUCODE) && defined(__OPENCL__)
#if defined(GPUCA_GPUCODE) && defined(__OPENCL__)
::atomic_max(addr, val);
#elif defined(GPUCA_GPUCODE) && (defined(__CUDACC__) || defined(__HIPCC__))
::atomicMax(addr, val);
Expand All @@ -679,9 +671,7 @@ GPUdi() void GPUCommonMath::AtomicMaxInternal(S* addr, T val)
template <class S, class T>
GPUdi() void GPUCommonMath::AtomicMinInternal(S* addr, T val)
{
#if defined(GPUCA_GPUCODE) && defined(__OPENCL__) && (!defined(__clang__) || defined(GPUCA_OPENCL_CLANG_C11_ATOMICS))
::atomic_fetch_min(addr, val);
#elif defined(GPUCA_GPUCODE) && defined(__OPENCL__)
#if defined(GPUCA_GPUCODE) && defined(__OPENCL__)
::atomic_min(addr, val);
#elif defined(GPUCA_GPUCODE) && (defined(__CUDACC__) || defined(__HIPCC__))
::atomicMin(addr, val);
Expand All @@ -697,9 +687,7 @@ GPUdi() void GPUCommonMath::AtomicMinInternal(S* addr, T val)
template <class T, class S>
GPUdi() T GPUCommonMath::AtomicLoadInternal(S* addr)
{
#if defined(GPUCA_GPUCODE) && defined(__OPENCL__) && (!defined(__clang__) || defined(GPUCA_OPENCL_CLANG_C11_ATOMICS))
return ::atomic_load_explicit(addr, memory_order_relaxed);
#elif defined(GPUCA_GPUCODE) && (defined(__OPENCL__) || defined(__CUDACC__) || defined(__HIPCC__))
#if defined(GPUCA_GPUCODE) && (defined(__OPENCL__) || defined(__CUDACC__) || defined(__HIPCC__))
return *(volatile S*)addr;
#elif defined(GPUCA_GPUCODE) && defined(__METAL__)
return atomic_load_explicit(GPUCommonMathMetalAtomic(addr), memory_order_relaxed);
Expand All @@ -715,9 +703,7 @@ GPUdi() T GPUCommonMath::AtomicLoadInternal(S* addr)
template <class S, class T>
GPUdi() void GPUCommonMath::AtomicStoreInternal(S* addr, T val)
{
#if defined(GPUCA_GPUCODE) && defined(__OPENCL__) && (!defined(__clang__) || defined(GPUCA_OPENCL_CLANG_C11_ATOMICS))
::atomic_store_explicit(addr, val, memory_order_relaxed);
#elif defined(GPUCA_GPUCODE) && (defined(__OPENCL__) || defined(__CUDACC__) || defined(__HIPCC__))
#if defined(GPUCA_GPUCODE) && (defined(__OPENCL__) || defined(__CUDACC__) || defined(__HIPCC__))
*(volatile S*)addr = val;
#elif defined(GPUCA_GPUCODE) && defined(__METAL__)
atomic_store_explicit(GPUCommonMathMetalAtomic(addr), val, memory_order_relaxed);
Expand Down
13 changes: 13 additions & 0 deletions GPU/GPUTracking/Base/GPUReconstruction.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "GPUConstantMem.h"
#include "GPUCommonHelpers.h"
#include "GPUSettings.h"
#include "GPUDefParametersRuntime.h"

#include "GPUMemoryResource.h"
#include "GPUChain.h"
Expand Down Expand Up @@ -443,6 +444,18 @@ void GPUReconstruction::WriteConstantParams(int32_t stream)
}
}

int32_t GPUReconstruction::GetTPCCompressionGatherMode() const
{
int32_t mode = GetProcessingSettings().tpcCompressionGatherMode; // TODO: Move this to GPUChainTracking, once the interface allows for SetPointers...
if (mode == -1) {
mode = getGPUParameters(GetRecoStepsGPU() & gpudatatypes::RecoStep::TPCCompression).par_COMP_GATHER_MODE;
if (mode == 1 && GetProcessingSettings().doublePipeline) {
mode = 0;
}
}
return mode;
}

int32_t GPUReconstruction::Finalize()
{
for (uint32_t i = 0; i < mChains.size(); i++) {
Expand Down
1 change: 1 addition & 0 deletions GPU/GPUTracking/Base/GPUReconstruction.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ class GPUReconstruction
uint32_t NStreams() const { return mNStreams; }
const void* DeviceMemoryBase() const { return mDeviceMemoryBase; }
virtual const GPUDefParameters& getGPUParameters(bool doGPU) const = 0;
int32_t GetTPCCompressionGatherMode() const; // tpcCompressionGatherMode with -1 (auto) resolved

RecoStepField GetRecoSteps() const { return mRecoSteps.steps; }
RecoStepField GetRecoStepsGPU() const { return mRecoSteps.stepsGPUMask; }
Expand Down
2 changes: 0 additions & 2 deletions GPU/GPUTracking/Base/opencl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,12 @@ endif()

if(OPENCL_ENABLED_SPIRV) # BUILD OpenCL intermediate code for SPIR-V target
# executes clang to create llvm IL code
# Add -fintegrated-objemitter once we switch to clang >= 17
cmake_path(GET LLVM_SPIRV PARENT_PATH TMP_LLVM_SPIRV_PATH)
add_custom_command(
OUTPUT ${CL_BIN}.spirv
COMMAND ${CMAKE_COMMAND} -E env "PATH=${TMP_LLVM_SPIRV_PATH}:\$$PATH" ${LLVM_CLANG}
-O0
--target=spirv64v${GPUCA_OCL_SPIRV_VERSION}
-fno-integrated-objemitter
-ferror-limit=1000 -Wno-invalid-constexpr -Wno-unused-command-line-argument
${OCL_FLAGS}
${OCL_DEFINECL}
Expand Down
6 changes: 3 additions & 3 deletions GPU/GPUTracking/DataCompression/GPUTPCCompression.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void* GPUTPCCompression::SetPointersOutputHost(void* mem)

void* GPUTPCCompression::SetPointersScratch(void* mem)
{
int32_t gatherMode = mRec->GetProcessingSettings().tpcCompressionGatherMode == -1 ? mRec->getGPUParameters(mRec->GetRecoStepsGPU() & gpudatatypes::RecoStep::TPCCompression).par_COMP_GATHER_MODE : mRec->GetProcessingSettings().tpcCompressionGatherMode;
int32_t gatherMode = mRec->GetTPCCompressionGatherMode();
computePointerWithAlignment(mem, mClusterStatus, mMaxClusters);
if (gatherMode >= 2) {
computePointerWithAlignment(mem, mAttachedClusterFirstIndex, mMaxTracks);
Expand All @@ -50,7 +50,7 @@ void* GPUTPCCompression::SetPointersScratch(void* mem)

void* GPUTPCCompression::SetPointersOutput(void* mem)
{
int32_t gatherMode = mRec->GetProcessingSettings().tpcCompressionGatherMode == -1 ? mRec->getGPUParameters(mRec->GetRecoStepsGPU() & gpudatatypes::RecoStep::TPCCompression).par_COMP_GATHER_MODE : mRec->GetProcessingSettings().tpcCompressionGatherMode;
int32_t gatherMode = mRec->GetTPCCompressionGatherMode();
computePointerWithAlignment(mem, mAttachedClusterFirstIndex, mMaxTrackClusters);
if (gatherMode == 1) {
SetPointersCompressedClusters(mem, mPtrs, mMaxTrackClusters, mMaxTracks, mMaxClustersInCache, false);
Expand Down Expand Up @@ -105,7 +105,7 @@ void* GPUTPCCompression::SetPointersMemory(void* mem)
void GPUTPCCompression::RegisterMemoryAllocation()
{
AllocateAndInitializeLate();
int32_t gatherMode = mRec->GetProcessingSettings().tpcCompressionGatherMode == -1 ? mRec->getGPUParameters(mRec->GetRecoStepsGPU() & gpudatatypes::RecoStep::TPCCompression).par_COMP_GATHER_MODE : mRec->GetProcessingSettings().tpcCompressionGatherMode;
int32_t gatherMode = mRec->GetTPCCompressionGatherMode();
mMemoryResOutputHost = mRec->RegisterMemoryAllocation(this, &GPUTPCCompression::SetPointersOutputHost, GPUMemoryResource::MEMORY_OUTPUT_FLAG | GPUMemoryResource::MEMORY_HOST | GPUMemoryResource::MEMORY_CUSTOM, "TPCCompressionOutputHost");
if (gatherMode == 3) {
mMemoryResOutputGPU = mRec->RegisterMemoryAllocation(this, &GPUTPCCompression::SetPointersOutputGPU, GPUMemoryResource::MEMORY_SCRATCH | GPUMemoryResource::MEMORY_GPU | GPUMemoryResource::MEMORY_CUSTOM | GPUMemoryResource::MEMORY_STACK, "TPCCompressionOutputGPU");
Expand Down
4 changes: 2 additions & 2 deletions GPU/GPUTracking/Global/GPUChainTracking.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ void GPUChainTracking::RegisterGPUProcessors()

void GPUChainTracking::MemorySize(size_t& gpuMem, size_t& pageLockedHostMem)
{
const int32_t gatherMode = mRec->GetProcessingSettings().tpcCompressionGatherMode == -1 ? mRec->getGPUParameters(mRec->GetRecoStepsGPU() & gpudatatypes::RecoStep::TPCCompression).par_COMP_GATHER_MODE : mRec->GetProcessingSettings().tpcCompressionGatherMode;
const int32_t gatherMode = mRec->GetTPCCompressionGatherMode();
gpuMem = constants::GPU_DEFAULT_MEMORY_SIZE;
pageLockedHostMem = constants::GPU_DEFAULT_HOST_MEMORY_SIZE * (gatherMode < 2 ? 2 : 1) + (gatherMode == 1 ? 2 * 1024 * 1024 * 1024ull : 0); // Gather mode 1 gathers the compressed clusters in host memory
}
Expand Down Expand Up @@ -259,7 +259,7 @@ bool GPUChainTracking::ValidateSteps()

bool GPUChainTracking::ValidateSettings()
{
int32_t gatherMode = mRec->GetProcessingSettings().tpcCompressionGatherMode == -1 ? mRec->getGPUParameters(mRec->GetRecoStepsGPU() & gpudatatypes::RecoStep::TPCCompression).par_COMP_GATHER_MODE : mRec->GetProcessingSettings().tpcCompressionGatherMode;
int32_t gatherMode = mRec->GetTPCCompressionGatherMode();
if (param().rec.tpc.rebuildTrackInFit && (param().rec.tpc.rebuildTrackInFitClusterCandidates == 0 || param().rec.tpc.rebuildTrackInFitClusterCandidates > 13)) {
GPUError("Need between 1 and 13 cluster candidates to rebuild tracks during fit");
return false;
Expand Down
2 changes: 1 addition & 1 deletion GPU/GPUTracking/Global/GPUChainTrackingCompression.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ int32_t GPUChainTracking::RunTPCCompression()
mRec->PushNonPersistentMemory(qStr2Tag("TPCCOMPR"));
RecoStep myStep = RecoStep::TPCCompression;
bool doGPU = GetRecoStepsGPU() & RecoStep::TPCCompression;
int32_t gatherMode = mRec->GetProcessingSettings().tpcCompressionGatherMode == -1 ? mRec->getGPUParameters(doGPU).par_COMP_GATHER_MODE : mRec->GetProcessingSettings().tpcCompressionGatherMode;
int32_t gatherMode = mRec->GetTPCCompressionGatherMode();
GPUTPCCompression& Compressor = processors()->tpcCompressor;
GPUTPCCompression& CompressorShadow = doGPU ? processorsShadow()->tpcCompressor : Compressor;
const auto& holdContext = GetThreadContext();
Expand Down