-
Notifications
You must be signed in to change notification settings - Fork 499
Expand file tree
/
Copy pathGPUDef.h
More file actions
84 lines (74 loc) · 2.99 KB
/
GPUDef.h
File metadata and controls
84 lines (74 loc) · 2.99 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
// Copyright CERN and copyright holders of ALICE O2. This software is
// distributed under the terms of the GNU General Public License v3 (GPL
// Version 3), copied verbatim in the file "COPYING".
//
// See http://alice-o2.web.cern.ch/license for full licensing information.
//
// 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 GPUDef.h
/// \author David Rohr, Sergey Gorbunov
// clang-format off
#ifndef GPUDEF_H
#define GPUDEF_H
#include "GPUCommonDef.h"
#include "GPUDefConstantsAndSettings.h"
#include "GPUDefGPUParameters.h"
#include "GPUDefOpenCL12Templates.h"
#include "GPUCommonRtypes.h"
// Macros for masking ptrs in OpenCL kernel calls as unsigned long (The API only allows us to pass buffer objects)
#ifdef __OPENCL__
#define GPUPtr1(a, b) unsigned long b
#define GPUPtr2(a, b) ((__global a) (a) b)
#else
#define GPUPtr1(a, b) a b
#define GPUPtr2(a, b) b
#endif
#ifdef GPUCA_FULL_CLUSTERDATA
#define GPUCA_EVDUMP_FILE "event_full"
#else
#define GPUCA_EVDUMP_FILE "event"
#endif
#ifdef GPUCA_GPUCODE
#define CA_MAKE_SHARED_REF(vartype, varname, varglobal, varshared) const GPUsharedref() MEM_LOCAL(vartype) & __restrict__ varname = varshared;
#define CA_SHARED_STORAGE(storage) storage
#define CA_SHARED_CACHE(target, src, size) \
static_assert((size) % sizeof(int) == 0, "Invalid shared cache size"); \
for (unsigned int i_shared_cache = get_local_id(0); i_shared_cache < (size) / sizeof(int); i_shared_cache += get_local_size(0)) { \
reinterpret_cast<GPUsharedref() int*>(target)[i_shared_cache] = reinterpret_cast<GPUglobalref() const int*>(src)[i_shared_cache]; \
}
#define CA_SHARED_CACHE_REF(target, src, size, reftype, ref) \
CA_SHARED_CACHE(target, src, size) \
GPUsharedref() const reftype* __restrict__ ref = (target)
#else
#define CA_MAKE_SHARED_REF(vartype, varname, varglobal, varshared) const GPUglobalref() MEM_GLOBAL(vartype) & __restrict__ varname = varglobal;
#define CA_SHARED_STORAGE(storage)
#define CA_SHARED_CACHE(target, src, size)
#define CA_SHARED_CACHE_REF(target, src, size, reftype, ref) GPUglobalref() const reftype* __restrict__ ref = src
#endif
#ifdef GPUCA_TEXTURE_FETCH_CONSTRUCTOR
#define CA_TEXTURE_FETCH(type, texture, address, entry) tex1Dfetch(texture, ((char*) address - tracker.Data().GPUTextureBase()) / sizeof(type) + entry);
#else
#define CA_TEXTURE_FETCH(type, texture, address, entry) address[entry];
#endif
#endif //GPUTPCDEF_H
#ifdef GPUCA_CADEBUG
#ifdef CADEBUG
#undef CADEBUG
#endif
#ifdef GPUCA_CADEBUG_ENABLED
#undef GPUCA_CADEBUG_ENABLED
#endif
#if GPUCA_CADEBUG == 1 && !defined(GPUCA_GPUCODE)
#define CADEBUG(...) __VA_ARGS__
#define CADEBUG2(cmd, ...) {__VA_ARGS__; cmd;}
#define GPUCA_CADEBUG_ENABLED
#endif
#undef GPUCA_CADEBUG
#endif
#ifndef CADEBUG
#define CADEBUG(...)
#define CADEBUG2(cmd, ...) {cmd;}
#endif
// clang-format on