Please, help us to better know about our user community by answering the following short survey:
https://forms.gle/wpyrxWi18ox9Z5ae9
Eigen-unsupported
3.4.0
TensorGpuHipCudaDefines.h
1
// This file is part of Eigen, a lightweight C++ template library
2
// for linear algebra.
3
//
4
// Copyright (C) 2014 Benoit Steiner <benoit.steiner.goog@gmail.com>
5
// Copyright (C) 2018 Deven Desai <deven.desai.amd@gmail.com>
6
//
7
// This Source Code Form is subject to the terms of the Mozilla
8
// Public License v. 2.0. If a copy of the MPL was not distributed
9
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
10
11
#if defined(EIGEN_USE_GPU) && !defined(EIGEN_CXX11_TENSOR_GPU_HIP_CUDA_DEFINES_H)
12
#define EIGEN_CXX11_TENSOR_GPU_HIP_CUDA_DEFINES_H
13
14
// Note that we are using EIGEN_USE_HIP here instead of EIGEN_HIPCC...this is by design
15
// There is code in the Tensorflow codebase that will define EIGEN_USE_GPU, but
16
// for some reason gets sent to the gcc/host compiler instead of the gpu/nvcc/hipcc compiler
17
// When compiling such files, gcc will end up trying to pick up the CUDA headers by
18
// default (see the code within "unsupported/Eigen/CXX11/Tensor" that is guarded by EIGEN_USE_GPU)
19
// This will obviously not work when trying to compile tensorflow on a system with no CUDA
20
// To work around this issue for HIP systems (and leave the default behaviour intact), the
21
// HIP tensorflow build defines EIGEN_USE_HIP when compiling all source files, and
22
// "unsupported/Eigen/CXX11/Tensor" has been updated to use HIP header when EIGEN_USE_HIP is
23
// defined. In continuation of that requirement, the guard here needs to be EIGEN_USE_HIP as well
24
25
#if defined(EIGEN_USE_HIP)
26
27
#define gpuStream_t hipStream_t
28
#define gpuDeviceProp_t hipDeviceProp_t
29
#define gpuError_t hipError_t
30
#define gpuSuccess hipSuccess
31
#define gpuErrorNotReady hipErrorNotReady
32
#define gpuGetDeviceCount hipGetDeviceCount
33
#define gpuGetLastError hipGetLastError
34
#define gpuPeekAtLastError hipPeekAtLastError
35
#define gpuGetErrorName hipGetErrorName
36
#define gpuGetErrorString hipGetErrorString
37
#define gpuGetDeviceProperties hipGetDeviceProperties
38
#define gpuStreamDefault hipStreamDefault
39
#define gpuGetDevice hipGetDevice
40
#define gpuSetDevice hipSetDevice
41
#define gpuMalloc hipMalloc
42
#define gpuFree hipFree
43
#define gpuMemsetAsync hipMemsetAsync
44
#define gpuMemcpyAsync hipMemcpyAsync
45
#define gpuMemcpyDeviceToDevice hipMemcpyDeviceToDevice
46
#define gpuMemcpyDeviceToHost hipMemcpyDeviceToHost
47
#define gpuMemcpyHostToDevice hipMemcpyHostToDevice
48
#define gpuStreamQuery hipStreamQuery
49
#define gpuSharedMemConfig hipSharedMemConfig
50
#define gpuDeviceSetSharedMemConfig hipDeviceSetSharedMemConfig
51
#define gpuStreamSynchronize hipStreamSynchronize
52
#define gpuDeviceSynchronize hipDeviceSynchronize
53
#define gpuMemcpy hipMemcpy
54
55
#else
56
57
#define gpuStream_t cudaStream_t
58
#define gpuDeviceProp_t cudaDeviceProp
59
#define gpuError_t cudaError_t
60
#define gpuSuccess cudaSuccess
61
#define gpuErrorNotReady cudaErrorNotReady
62
#define gpuGetDeviceCount cudaGetDeviceCount
63
#define gpuGetLastError cudaGetLastError
64
#define gpuPeekAtLastError cudaPeekAtLastError
65
#define gpuGetErrorName cudaGetErrorName
66
#define gpuGetErrorString cudaGetErrorString
67
#define gpuGetDeviceProperties cudaGetDeviceProperties
68
#define gpuStreamDefault cudaStreamDefault
69
#define gpuGetDevice cudaGetDevice
70
#define gpuSetDevice cudaSetDevice
71
#define gpuMalloc cudaMalloc
72
#define gpuFree cudaFree
73
#define gpuMemsetAsync cudaMemsetAsync
74
#define gpuMemcpyAsync cudaMemcpyAsync
75
#define gpuMemcpyDeviceToDevice cudaMemcpyDeviceToDevice
76
#define gpuMemcpyDeviceToHost cudaMemcpyDeviceToHost
77
#define gpuMemcpyHostToDevice cudaMemcpyHostToDevice
78
#define gpuStreamQuery cudaStreamQuery
79
#define gpuSharedMemConfig cudaSharedMemConfig
80
#define gpuDeviceSetSharedMemConfig cudaDeviceSetSharedMemConfig
81
#define gpuStreamSynchronize cudaStreamSynchronize
82
#define gpuDeviceSynchronize cudaDeviceSynchronize
83
#define gpuMemcpy cudaMemcpy
84
85
#endif
86
87
// gpu_assert can be overridden
88
#ifndef gpu_assert
89
90
#if defined(EIGEN_HIP_DEVICE_COMPILE)
91
// HIPCC do not support the use of assert on the GPU side.
92
#define gpu_assert(COND)
93
#else
94
#define gpu_assert(COND) assert(COND)
95
#endif
96
97
#endif // gpu_assert
98
99
#endif // EIGEN_CXX11_TENSOR_GPU_HIP_CUDA_DEFINES_H
unsupported
Eigen
CXX11
src
Tensor
TensorGpuHipCudaDefines.h
Generated by
1.8.13