-
Notifications
You must be signed in to change notification settings - Fork 496
Expand file tree
/
Copy pathGPUGeneralKernels.h
More file actions
116 lines (100 loc) · 3.86 KB
/
GPUGeneralKernels.h
File metadata and controls
116 lines (100 loc) · 3.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
/// \file GPUGeneralKernels.h
/// \author David Rohr
#ifndef GPUGENERALKERNELS_H
#define GPUGENERALKERNELS_H
#include "GPUDef.h"
#include "GPUDataTypesIO.h"
#include "GPUDataTypesConfig.h"
#if defined(GPUCA_GPUCODE) && !defined(GPUCA_GPUCODE_COMPILEKERNELS) && !defined(GPUCA_GPUCODE_HOSTONLY)
#if defined(__CUDACC__)
#include <cub/cub.cuh>
#elif defined(__HIPCC__)
#include <hipcub/hipcub.hpp>
#endif
#endif
#if defined(__HIPCC__)
#define GPUCA_CUB_NAMESPACE hipcub
#else
#define GPUCA_CUB_NAMESPACE cub
#endif
namespace o2::gpu
{
struct GPUConstantMem;
class GPUKernelTemplate
{
public:
enum K { defaultKernel = 0,
step0 = 0,
step1 = 1,
step2 = 2,
step3 = 3,
step4 = 4,
step5 = 5 };
struct GPUSharedMemory {
};
template <class T, int32_t I>
struct GPUSharedMemoryWarpScan64 {
// Provides the shared memory resources for warp wide CUB collectives
#if (defined(__CUDACC__) || defined(__HIPCC__)) && defined(GPUCA_GPUCODE) && !defined(GPUCA_GPUCODE_HOSTONLY)
typedef GPUCA_CUB_NAMESPACE::WarpScan<T> WarpScan;
union {
typename WarpScan::TempStorage cubWarpTmpMem;
};
#endif
};
template <class T, int32_t I>
struct GPUSharedMemoryScan64 {
// Provides the shared memory resources for CUB collectives
#if (defined(__CUDACC__) || defined(__HIPCC__)) && defined(GPUCA_GPUCODE) && !defined(GPUCA_GPUCODE_HOSTONLY)
typedef GPUCA_CUB_NAMESPACE::BlockScan<T, I> BlockScan;
typedef GPUCA_CUB_NAMESPACE::BlockReduce<T, I> BlockReduce;
typedef GPUCA_CUB_NAMESPACE::WarpScan<T> WarpScan;
union {
typename BlockScan::TempStorage cubTmpMem;
typename BlockReduce::TempStorage cubReduceTmpMem;
typename WarpScan::TempStorage cubWarpTmpMem;
int32_t tmpBroadcast;
int32_t warpPredicateSum[I / GPUCA_WARP_SIZE];
};
#endif
};
typedef GPUconstantref() GPUConstantMem processorType;
GPUhdi() constexpr static gpudatatypes::RecoStep GetRecoStep() { return gpudatatypes::RecoStep::NoRecoStep; }
GPUhdi() static processorType* Processor(GPUConstantMem& processors)
{
return &processors;
}
template <int32_t iKernel, typename... Args>
GPUd() static void Thread(int32_t nBlocks, int32_t nThreads, int32_t iBlock, int32_t iThread, GPUsharedref() GPUSharedMemory& smem, processorType& processors, Args... args)
{
}
};
// Clean memory, ptr multiple of 16, size will be extended to multiple of 16
class GPUMemClean16 : public GPUKernelTemplate
{
public:
GPUhdi() constexpr static gpudatatypes::RecoStep GetRecoStep() { return gpudatatypes::RecoStep::NoRecoStep; }
template <int32_t iKernel = defaultKernel>
GPUd() static void Thread(int32_t nBlocks, int32_t nThreads, int32_t iBlock, int32_t iThread, GPUsharedref() GPUSharedMemory& smem, processorType& processors, GPUglobalref() void* ptr, uint64_t size);
};
// Fill with incrementing sequnce of integers
class GPUitoa : public GPUKernelTemplate
{
public:
GPUhdi() constexpr static gpudatatypes::RecoStep GetRecoStep() { return gpudatatypes::RecoStep::NoRecoStep; }
template <int32_t iKernel = defaultKernel>
GPUd() static void Thread(int32_t nBlocks, int32_t nThreads, int32_t iBlock, int32_t iThread, GPUsharedref() GPUSharedMemory& smem, processorType& processors, GPUglobalref() int32_t* ptr, uint64_t size);
};
} // namespace o2::gpu
#undef GPUCA_CUB_NAMESPACE
#endif