Project
Loading...
Searching...
No Matches
GPUCommonDef.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// This is the base header to be included by all files that should feature GPU suppurt.
16// Incompatible code that cannot compile on GPU must be protected by one of the checks below.
17// The usual approach would be to protect with GPUCA_GPUCODE. This will be sufficient for all functions. If header includes still show errors, use GPUCA_ALIGPUCODE
18
19// The following checks are increasingly more strict hiding the code in more and more cases:
20// #ifndef __OPENCL__ : Hide from OpenCL kernel code. All system headers and usage thereof must be protected like this, or stronger.
21// #ifndef GPUCA_GPUCODE_DEVICE : Hide from kernel code on all GPU architectures. This includes the __OPENCL__ case and bodies of all GPU device functions (GPUd(), etc.)
22// #ifndef GPUCA_GPUCODE : Hide from compilation with GPU compiler. This includes the kernel case of GPUCA_GPUCODE_DEVICE but also all host code compiled by the GPU compiler, e.g. for management.
23// #ifndef GPUCA_ALIGPUCODE : Code is completely invisible to the GPUCATracking library, irrespective of GPU or CPU compilation or which compiler.
24
25#ifndef GPUCOMMONDEF_H
26#define GPUCOMMONDEF_H
27
28// clang-format off
29
30//Some GPU configuration settings, must be included first
32
33#if !(defined(__CLING__) || defined(__ROOTCLING__) || defined(G__ROOT)) // No GPU code for ROOT
34 #if defined(__CUDACC__) || defined(__OPENCL__) || defined(__HIPCC__) || defined(__OPENCL_HOST__)
35 #define GPUCA_GPUCODE // Compiled by GPU compiler
36 #endif
37
38 #if defined(__CUDA_ARCH__) || defined(__OPENCL__) || defined(__HIP_DEVICE_COMPILE__)
39 #define GPUCA_GPUCODE_DEVICE // Executed on device
40 #endif
41#endif
42
43#if defined(GPUCA_STANDALONE) || (defined(GPUCA_O2_LIB) && !defined(GPUCA_O2_INTERFACE)) || defined (GPUCA_GPUCODE)
44 #define GPUCA_ALIGPUCODE
45#endif
46
47#if (defined(__CUDACC__) && defined(GPUCA_CUDA_NO_CONSTANT_MEMORY)) || (defined(__HIPCC__) && defined(GPUCA_HIP_NO_CONSTANT_MEMORY)) || (defined(__OPENCL__) && defined(GPUCA_OPENCL_NO_CONSTANT_MEMORY))
48 #define GPUCA_NO_CONSTANT_MEMORY
49#elif defined(__CUDACC__) || defined(__HIPCC__)
50 #define GPUCA_HAS_GLOBAL_SYMBOL_CONSTANT_MEM
51#endif
52
53#if !defined(GPUCA_GPUCODE) && !defined(GPUCA_STANDALONE) && defined(DEBUG_STREAMER)
54#define GPUCA_DEBUG_STREAMER_CHECK(...) __VA_ARGS__
55#else
56#define GPUCA_DEBUG_STREAMER_CHECK(...)
57#endif
58
59#ifndef GPUCA_RTC_SPECIAL_CODE
60#define GPUCA_RTC_SPECIAL_CODE(...)
61#endif
62
63// API Definitions for GPU Compilation
64#include "GPUCommonDefAPI.h"
65
66// clang-format on
67
68#endif