Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorGpuHipCudaDefines.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // This file is part of Eigen, a lightweight C++ template library
0002 // for linear algebra.
0003 //
0004 // Copyright (C) 2014 Benoit Steiner <benoit.steiner.goog@gmail.com>
0005 // Copyright (C) 2018 Deven Desai <deven.desai.amd@gmail.com>
0006 //
0007 // This Source Code Form is subject to the terms of the Mozilla
0008 // Public License v. 2.0. If a copy of the MPL was not distributed
0009 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
0010 
0011 #if defined(EIGEN_USE_GPU) && !defined(EIGEN_CXX11_TENSOR_GPU_HIP_CUDA_DEFINES_H)
0012 #define EIGEN_CXX11_TENSOR_GPU_HIP_CUDA_DEFINES_H
0013 
0014 // Note that we are using EIGEN_USE_HIP here instead of EIGEN_HIPCC...this is by design
0015 // There is code in the Tensorflow codebase that will define EIGEN_USE_GPU,  but
0016 // for some reason gets sent to the gcc/host compiler instead of the gpu/nvcc/hipcc compiler
0017 // When compiling such files, gcc will end up trying to pick up the CUDA headers by 
0018 // default (see the code within "unsupported/Eigen/CXX11/Tensor" that is guarded by EIGEN_USE_GPU)
0019 // This will obviously not work when trying to compile tensorflow on a system with no CUDA
0020 // To work around this issue for HIP systems (and leave the default behaviour intact), the
0021 // HIP tensorflow build defines EIGEN_USE_HIP when compiling all source files, and 
0022 // "unsupported/Eigen/CXX11/Tensor" has been updated to use HIP header when EIGEN_USE_HIP is
0023 // defined. In continuation of that requirement, the guard here needs to be EIGEN_USE_HIP as well
0024 
0025 #if defined(EIGEN_USE_HIP)
0026 
0027 #define gpuStream_t hipStream_t
0028 #define gpuDeviceProp_t hipDeviceProp_t
0029 #define gpuError_t hipError_t
0030 #define gpuSuccess hipSuccess
0031 #define gpuErrorNotReady hipErrorNotReady
0032 #define gpuGetDeviceCount hipGetDeviceCount
0033 #define gpuGetLastError hipGetLastError
0034 #define gpuPeekAtLastError hipPeekAtLastError
0035 #define gpuGetErrorName hipGetErrorName
0036 #define gpuGetErrorString hipGetErrorString
0037 #define gpuGetDeviceProperties hipGetDeviceProperties
0038 #define gpuStreamDefault hipStreamDefault
0039 #define gpuGetDevice hipGetDevice
0040 #define gpuSetDevice hipSetDevice
0041 #define gpuMalloc hipMalloc
0042 #define gpuFree hipFree
0043 #define gpuMemsetAsync hipMemsetAsync
0044 #define gpuMemcpyAsync hipMemcpyAsync
0045 #define gpuMemcpyDeviceToDevice hipMemcpyDeviceToDevice
0046 #define gpuMemcpyDeviceToHost hipMemcpyDeviceToHost
0047 #define gpuMemcpyHostToDevice hipMemcpyHostToDevice
0048 #define gpuStreamQuery hipStreamQuery
0049 #define gpuSharedMemConfig hipSharedMemConfig
0050 #define gpuDeviceSetSharedMemConfig hipDeviceSetSharedMemConfig
0051 #define gpuStreamSynchronize hipStreamSynchronize
0052 #define gpuDeviceSynchronize hipDeviceSynchronize
0053 #define gpuMemcpy hipMemcpy
0054 
0055 #else
0056 
0057 #define gpuStream_t cudaStream_t
0058 #define gpuDeviceProp_t cudaDeviceProp
0059 #define gpuError_t cudaError_t
0060 #define gpuSuccess cudaSuccess
0061 #define gpuErrorNotReady cudaErrorNotReady
0062 #define gpuGetDeviceCount cudaGetDeviceCount
0063 #define gpuGetLastError cudaGetLastError
0064 #define gpuPeekAtLastError cudaPeekAtLastError
0065 #define gpuGetErrorName cudaGetErrorName
0066 #define gpuGetErrorString cudaGetErrorString
0067 #define gpuGetDeviceProperties cudaGetDeviceProperties
0068 #define gpuStreamDefault cudaStreamDefault
0069 #define gpuGetDevice cudaGetDevice
0070 #define gpuSetDevice cudaSetDevice
0071 #define gpuMalloc cudaMalloc
0072 #define gpuFree cudaFree
0073 #define gpuMemsetAsync cudaMemsetAsync
0074 #define gpuMemcpyAsync cudaMemcpyAsync
0075 #define gpuMemcpyDeviceToDevice cudaMemcpyDeviceToDevice
0076 #define gpuMemcpyDeviceToHost cudaMemcpyDeviceToHost
0077 #define gpuMemcpyHostToDevice cudaMemcpyHostToDevice
0078 #define gpuStreamQuery cudaStreamQuery
0079 #define gpuSharedMemConfig cudaSharedMemConfig
0080 #define gpuDeviceSetSharedMemConfig cudaDeviceSetSharedMemConfig
0081 #define gpuStreamSynchronize cudaStreamSynchronize
0082 #define gpuDeviceSynchronize cudaDeviceSynchronize
0083 #define gpuMemcpy cudaMemcpy
0084 
0085 #endif
0086 
0087 // gpu_assert can be overridden
0088 #ifndef gpu_assert
0089 
0090 #if defined(EIGEN_HIP_DEVICE_COMPILE)
0091 // HIPCC do not support the use of assert on the GPU side.
0092 #define gpu_assert(COND)
0093 #else
0094 #define gpu_assert(COND) assert(COND)
0095 #endif
0096 
0097 #endif // gpu_assert
0098 
0099 #endif  // EIGEN_CXX11_TENSOR_GPU_HIP_CUDA_DEFINES_H