1 /*===---- __clang_hip_runtime_wrapper.h - HIP runtime support ---------------=== 2 * 3 * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 * See https://llvm.org/LICENSE.txt for license information. 5 * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 * 7 *===-----------------------------------------------------------------------=== 8 */ 9 10 /* 11 * WARNING: This header is intended to be directly -include'd by 12 * the compiler and is not supposed to be included by users. 13 * 14 */ 15 16 #ifndef __CLANG_HIP_RUNTIME_WRAPPER_H__ 17 #define __CLANG_HIP_RUNTIME_WRAPPER_H__ 18 19 #if __HIP__ 20 21 #include <cmath> 22 #include <cstdlib> 23 #include <stdlib.h> 24 25 #define __host__ __attribute__((host)) 26 #define __device__ __attribute__((device)) 27 #define __global__ __attribute__((global)) 28 #define __shared__ __attribute__((shared)) 29 #define __constant__ __attribute__((constant)) 30 31 #if __HIP_ENABLE_DEVICE_MALLOC__ 32 extern "C" __device__ void *__hip_malloc(size_t __size); 33 extern "C" __device__ void *__hip_free(void *__ptr); malloc(size_t __size)34static inline __device__ void *malloc(size_t __size) { 35 return __hip_malloc(__size); 36 } free(void * __ptr)37static inline __device__ void *free(void *__ptr) { return __hip_free(__ptr); } 38 #else malloc(size_t __size)39static inline __device__ void *malloc(size_t __size) { 40 __builtin_trap(); 41 return nullptr; 42 } free(void * __ptr)43static inline __device__ void *free(void *__ptr) { 44 __builtin_trap(); 45 return nullptr; 46 } 47 #endif 48 49 #include <__clang_hip_libdevice_declares.h> 50 #include <__clang_hip_math.h> 51 52 #if !_OPENMP || __HIP_ENABLE_CUDA_WRAPPER_FOR_OPENMP__ 53 #include <__clang_cuda_math_forward_declares.h> 54 #include <__clang_cuda_complex_builtins.h> 55 56 #include <algorithm> 57 #include <complex> 58 #include <new> 59 #endif // !_OPENMP || __HIP_ENABLE_CUDA_WRAPPER_FOR_OPENMP__ 60 61 #define __CLANG_HIP_RUNTIME_WRAPPER_INCLUDED__ 1 62 63 #endif // __HIP__ 64 #endif // __CLANG_HIP_RUNTIME_WRAPPER_H__ 65