![]() |
|
|||
File indexing completed on 2025-09-15 08:55:08
0001 //------------------------------- -*- C++ -*- -------------------------------// 0002 // Copyright Celeritas contributors: see top-level COPYRIGHT file for details 0003 // SPDX-License-Identifier: (Apache-2.0 OR MIT) 0004 //---------------------------------------------------------------------------// 0005 //! \file corecel/DeviceRuntimeApi.hh 0006 //! \brief Include CUDA or HIP runtime APIs for compiling with host/cc 0007 //! compiler. 0008 //---------------------------------------------------------------------------// 0009 #pragma once 0010 0011 #include "corecel/Config.hh" 0012 0013 #if CELERITAS_USE_CUDA 0014 # include <cuda_runtime_api.h> 0015 #elif CELERITAS_USE_HIP 0016 # ifndef __HIPCC__ 0017 /* Assume we're on an AMD system but not being invoked by the rocm compiler */ 0018 # define __HIP_PLATFORM_AMD__ 1 0019 # define __HIP_PLATFORM_HCC__ 1 0020 # endif 0021 # include <hip/hip_runtime.h> 0022 #endif 0023 0024 /*! 0025 * \def CELER_DEVICE_PLATFORM 0026 * 0027 * API prefix token for the device offloading type. 0028 */ 0029 /*! 0030 * \def CELER_DEVICE_API_SYMBOL 0031 * 0032 * Add a prefix "hip" or "cuda" to a code token. 0033 */ 0034 /*! 0035 * \def CELER_EU_PER_CU 0036 * 0037 * Execution units per compute unit. AMD multiprocessors each have 4 SIMD 0038 * units per compute unit, but there is no device attribute or 0039 * compiler definition that provides this information. 0040 * For CUDA, each streaming multiprocessor (MP) is a single "execution unit" 0041 * and a "compute unit". 0042 */ 0043 #if CELERITAS_USE_CUDA 0044 # define CELER_DEVICE_PLATFORM cuda 0045 # define CELER_DEVICE_PLATFORM_UPPER_STR "CUDA" 0046 # define CELER_DEVICE_API_SYMBOL(TOK) cuda##TOK 0047 # define CELER_EU_PER_CU 1 0048 #elif CELERITAS_USE_HIP 0049 # define CELER_DEVICE_PLATFORM hip 0050 # define CELER_DEVICE_PLATFORM_UPPER_STR "HIP" 0051 # define CELER_DEVICE_API_SYMBOL(TOK) hip##TOK 0052 # if defined(__HIP_PLATFORM_AMD__) || defined(__HIP_PLATFORM_HCC__) 0053 # define CELER_EU_PER_CU 4 0054 # elif defined(__HIP_PLATFORM_NVIDIA__) || defined(__HIP_PLATFORM_NVCC__) 0055 # define CELER_EU_PER_CU 1 0056 # else 0057 # define CELER_EU_PER_CU 0 0058 # endif 0059 #else 0060 # define CELER_DEVICE_PLATFORM none 0061 # define CELER_DEVICE_PLATFORM_UPPER_STR "" 0062 # define CELER_DEVICE_API_SYMBOL(TOK) void 0063 # define CELER_EU_PER_CU 0 0064 #endif 0065 0066 /*! 0067 * This macro informs downstream Celeritas code (namely, Stream) that it's safe 0068 * to use types from the device APIs. 0069 */ 0070 #define CELER_DEVICE_RUNTIME_INCLUDED 0071 0072 /*! 0073 * Declare a dummy variable for disabled \c CELER_DEVICE_API_CALL calls. 0074 * 0075 * With this declaration, the build will fail if this include is missing. 0076 * (Unfortunately, since the use of this symbol is embedded in a macro, IWYU 0077 * won't include this file automatically.) 0078 */ 0079 extern int const CorecelDeviceRuntimeApiHh;
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |