Project
Loading...
Searching...
No Matches
GPUDef.h
Go to the documentation of this file.
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
14
15// clang-format off
16#ifndef GPUDEF_H
17#define GPUDEF_H
18
19#include "GPUCommonDef.h"
21#include "GPUDefGPUParameters.h"
22#include "GPUCommonRtypes.h"
23
24// Macros for masking ptrs in OpenCL kernel calls as uint64_t (The API only allows us to pass buffer objects)
25#ifdef __OPENCL__
26 #define GPUPtr1(a, b) uint64_t b
27 #ifdef __OPENCL__
28 #define GPUPtr2(a, b) ((__generic a) (a) b)
29 #else
30 #define GPUPtr2(a, b) ((__global a) (a) b)
31 #endif
32#else
33 #define GPUPtr1(a, b) a b
34 #define GPUPtr2(a, b) b
35#endif
36
37#ifdef GPUCA_FULL_CLUSTERDATA
38 #define GPUCA_EVDUMP_FILE "event_full"
39#else
40 #define GPUCA_EVDUMP_FILE "event"
41#endif
42
43#ifdef GPUCA_GPUCODE
44 #define CA_MAKE_SHARED_REF(vartype, varname, varglobal, varshared) const GPUsharedref() vartype& __restrict__ varname = varshared;
45 #define CA_SHARED_STORAGE(storage) storage
46 #define CA_SHARED_CACHE(target, src, size) \
47 static_assert((size) % sizeof(int32_t) == 0, "Invalid shared cache size"); \
48 for (uint32_t i_shared_cache = get_local_id(0); i_shared_cache < (size) / sizeof(int32_t); i_shared_cache += get_local_size(0)) { \
49 reinterpret_cast<GPUsharedref() int32_t*>(target)[i_shared_cache] = reinterpret_cast<GPUglobalref() const int32_t*>(src)[i_shared_cache]; \
50 }
51 #define CA_SHARED_CACHE_REF(target, src, size, reftype, ref) \
52 CA_SHARED_CACHE(target, src, size) \
53 GPUsharedref() const reftype* __restrict__ ref = (target)
54#else
55 #define CA_MAKE_SHARED_REF(vartype, varname, varglobal, varshared) const GPUglobalref() vartype & __restrict__ varname = varglobal;
56 #define CA_SHARED_STORAGE(storage)
57 #define CA_SHARED_CACHE(target, src, size)
58 #define CA_SHARED_CACHE_REF(target, src, size, reftype, ref) GPUglobalref() const reftype* __restrict__ ref = src
59#endif
60
61#ifdef GPUCA_TEXTURE_FETCH_CONSTRUCTOR
62 #define CA_TEXTURE_FETCH(type, texture, address, entry) tex1Dfetch(texture, ((char*) address - tracker.Data().GPUTextureBase()) / sizeof(type) + entry);
63#else
64 #define CA_TEXTURE_FETCH(type, texture, address, entry) address[entry];
65#endif
66
67#endif //GPUTPCDEF_H
68
69#ifdef GPUCA_CADEBUG
70 #ifdef CADEBUG
71 #undef CADEBUG
72 #endif
73 #ifdef GPUCA_CADEBUG_ENABLED
74 #undef GPUCA_CADEBUG_ENABLED
75 #endif
76 #if GPUCA_CADEBUG == 1 && !defined(GPUCA_GPUCODE)
77 #define CADEBUG(...) __VA_ARGS__
78 #define CADEBUG2(cmd, ...) {__VA_ARGS__; cmd;}
79 #define GPUCA_CADEBUG_ENABLED
80 #endif
81 #undef GPUCA_CADEBUG
82#endif
83
84#ifndef CADEBUG
85 #define CADEBUG(...)
86 #define CADEBUG2(cmd, ...) {cmd;}
87#endif
88// clang-format on