forked from celeritas-project/celeritas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
device_runtime_api.h
67 lines (60 loc) · 2.22 KB
/
device_runtime_api.h
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
/*-----------------------------------*-C-*-----------------------------------
* Copyright 2022-2024 UT-Battelle, LLC, and other Celeritas developers.
* See the top-level COPYRIGHT file for details.
* SPDX-License-Identifier: (Apache-2.0 OR MIT)
*---------------------------------------------------------------------------*/
/*!
* \file corecel/device_runtime_api.h
* Include CUDA or HIP runtime APIs for compiling with host/cc compiler.
*/
#ifndef CELERITAS_DEVICE_RUNTIME_API_H
#define CELERITAS_DEVICE_RUNTIME_API_H
#include "celeritas_config.h"
#if CELERITAS_USE_HIP && !defined(__HIPCC__)
/* Assume we're on an AMD system but not being invoked by the rocm compiler */
# define __HIP_PLATFORM_AMD__ 1
# define __HIP_PLATFORM_HCC__ 1
#endif
#if CELERITAS_USE_CUDA
# include <cuda_runtime_api.h>
# define THRUST_DEVICE_SYSTEM THRUST_DEVICE_SYSTEM_CUDA
#elif CELERITAS_USE_HIP
# include <hip/hip_runtime.h>
# define THRUST_DEVICE_SYSTEM THRUST_DEVICE_SYSTEM_HIP
#endif
#if CELERITAS_USE_CUDA || CELERITAS_USE_HIP
# include <thrust/mr/memory_resource.h>
#endif
/*!
* \def CELER_EU_PER_CU
*
* Execution units per compute unit. AMD multiprocessors each have 4 SIMD
* units per compute unit, but there is no device attribute or
* compiler definition that provides this information.
* For CUDA, each streaming multiprocessor (MP) is a single "execution unit"
* and a "compute unit".
*/
#if CELERITAS_USE_CUDA
# define CELER_EU_PER_CU 1
#elif CELERITAS_USE_HIP
# if defined(__HIP_PLATFORM_AMD__) || defined(__HIP_PLATFORM_HCC__)
# define CELER_EU_PER_CU 4
# elif defined(__HIP_PLATFORM_NVIDIA__) || defined(__HIP_PLATFORM_NVCC__)
# define CELER_EU_PER_CU 1
# else
# warning "Unknown HIP device configuration"
# define CELER_EU_PER_CU 0
# endif
#else
/* HIP and CUDA are disabled */
# define CELER_EU_PER_CU 0
#endif
/*!
* Declare a dummy variable to be referenced in disabled \c CELER_BLAH calls.
*
* With this declaration, the build will fail if this include is missing.
* (Unfortunately, since the use of this symbol is embedded in a macro, IWYU
* won't include this file automatically.)
*/
extern int celeritas_device_runtime_api_h_;
#endif /* CELERITAS_DEVICE_RUNTIME_API_H */