1 /* Copyright 2019 The TensorFlow Authors. All Rights Reserved. 2 3 Licensed under the Apache License, Version 2.0 (the "License"); 4 you may not use this file except in compliance with the License. 5 You may obtain a copy of the License at 6 7 http://www.apache.org/licenses/LICENSE-2.0 8 9 Unless required by applicable law or agreed to in writing, software 10 distributed under the License is distributed on an "AS IS" BASIS, 11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 See the License for the specific language governing permissions and 13 limitations under the License. 14 ==============================================================================*/ 15 16 // GPU (ROCm / CUDA) specific type handle resolution 17 18 #ifndef TENSORFLOW_STREAM_EXECUTOR_GPU_GPU_TYPES_H_ 19 #define TENSORFLOW_STREAM_EXECUTOR_GPU_GPU_TYPES_H_ 20 21 #if TENSORFLOW_USE_ROCM 22 23 #define __HIP_DISABLE_CPP_FUNCTIONS__ 24 25 #include "rocm/include/hip/hip_complex.h" 26 #include "rocm/include/hip/hip_runtime.h" 27 #include "rocm/include/hiprand/hiprand.h" 28 29 #else // CUDA 30 31 #include "third_party/gpus/cuda/include/cuComplex.h" 32 #include "third_party/gpus/cuda/include/cuda.h" 33 34 // cannot include curand.h here 35 // because it triggers the #error in cuda/cuda_gpu_executor.cc 36 // (because curand.h includes cuda_runtime.h) 37 // so explicitly adding the lone typedef we need from that file 38 typedef struct curandGenerator_st* curandGenerator_t; 39 40 #endif 41 42 namespace stream_executor { 43 namespace gpu { 44 45 #if TENSORFLOW_USE_ROCM 46 47 using GpuStreamHandle = hipStream_t; 48 using GpuEventHandle = hipEvent_t; 49 using GpuFunctionHandle = hipFunction_t; 50 using GpuFunctionAttribute = hipDeviceAttribute_t; // not a typo! 51 using GpuDeviceHandle = hipDevice_t; 52 using GpuDevicePtr = hipDeviceptr_t; 53 using GpuDeviceAttribute = hipDeviceAttribute_t; 54 using GpuDeviceProperty = hipDeviceProp_t; 55 using GpuModuleHandle = hipModule_t; 56 using GpuStatus = hipError_t; 57 using GpuFuncCachePreference = hipFuncCache_t; 58 using GpuSharedMemConfig = hipSharedMemConfig; 59 using GpuComplexType = hipComplex; 60 using GpuDoubleComplexType = hipDoubleComplex; 61 using GpuRngHandle = hiprandGenerator_t; 62 63 #else // CUDA 64 65 using GpuStreamHandle = CUstream; 66 using GpuEventHandle = CUevent; 67 using GpuFunctionHandle = CUfunction; 68 using GpuFunctionAttribute = CUfunction_attribute; 69 using GpuDeviceHandle = CUdevice; 70 using GpuDevicePtr = CUdeviceptr; 71 using GpuDeviceAttribute = CUdevice_attribute; 72 using GpuDeviceProperty = CUdevprop; 73 using GpuModuleHandle = CUmodule; 74 using GpuStatus = CUresult; 75 using GpuFuncCachePreference = CUfunc_cache; 76 using GpuSharedMemConfig = CUsharedconfig; 77 using GpuComplexType = cuComplex; 78 using GpuDoubleComplexType = cuDoubleComplex; 79 using GpuRngHandle = curandGenerator_t; 80 81 #endif 82 83 } // namespace gpu 84 } // namespace stream_executor 85 86 #endif // TENSORFLOW_STREAM_EXECUTOR_GPU_GPU_TYPES_H_ 87