16#ifndef FORTRAN_RUNTIME_API_ATTRS_H_
17#define FORTRAN_RUNTIME_API_ATTRS_H_
26#ifndef RT_EXT_API_GROUP_BEGIN
27#if defined(OMP_NOHOST_BUILD)
28#define RT_EXT_API_GROUP_BEGIN \
29 _Pragma("omp begin declare target device_type(nohost)")
30#elif defined(OMP_OFFLOAD_BUILD)
31#define RT_EXT_API_GROUP_BEGIN _Pragma("omp declare target")
33#define RT_EXT_API_GROUP_BEGIN
37#ifndef RT_EXT_API_GROUP_END
38#if defined(OMP_NOHOST_BUILD) || defined(OMP_OFFLOAD_BUILD)
39#define RT_EXT_API_GROUP_END _Pragma("omp end declare target")
41#define RT_EXT_API_GROUP_END
54#define RT_OFFLOAD_API_GROUP_BEGIN RT_EXT_API_GROUP_BEGIN
55#define RT_OFFLOAD_API_GROUP_END RT_EXT_API_GROUP_END
63#define RT_OFFLOAD_VAR_GROUP_BEGIN RT_EXT_API_GROUP_BEGIN
64#define RT_OFFLOAD_VAR_GROUP_END RT_EXT_API_GROUP_END
73#ifndef RT_VAR_GROUP_BEGIN
74#define RT_VAR_GROUP_BEGIN RT_EXT_API_GROUP_BEGIN
77#ifndef RT_VAR_GROUP_END
78#define RT_VAR_GROUP_END RT_EXT_API_GROUP_END
90#if defined(__CUDACC__) || defined(__CUDA__)
91#define RT_API_ATTRS __host__ __device__
104#ifndef RT_CONST_VAR_ATTRS
105#if (defined(__CUDACC__) || defined(__CUDA__)) && defined(__CUDA_ARCH__)
106#define RT_CONST_VAR_ATTRS __constant__
108#define RT_CONST_VAR_ATTRS
117#if (defined(__CUDACC__) || defined(__CUDA__)) && defined(__CUDA_ARCH__)
118#define RT_VAR_ATTRS __device__
129#if ((defined(__CUDACC__) || defined(__CUDA__)) && defined(__CUDA_ARCH__)) || \
130 (defined(_OPENMP) && (defined(__AMDGCN__) || defined(__NVPTX__)))
131#define RT_DEVICE_COMPILATION 1
133#undef RT_DEVICE_COMPILATION
142#if defined(__AMDGPU__) || defined(__NVPTX__)
143#define RT_GPU_TARGET 1
156#if RT_GPU_TARGET && !defined(RT_DEVICE_COMPILATION)
166#if (defined(__CUDACC__) || defined(__CUDA__)) && defined(__CUDA_ARCH__)
167#define RT_DEVICE_AVOID_RECURSION 1
169#undef RT_DEVICE_AVOID_RECURSION
172#if defined(__CUDACC__)
173#define RT_DIAG_PUSH _Pragma("nv_diagnostic push")
174#define RT_DIAG_POP _Pragma("nv_diagnostic pop")
175#define RT_DIAG_DISABLE_CALL_HOST_FROM_DEVICE_WARN \
176 _Pragma("nv_diag_suppress 20011") _Pragma("nv_diag_suppress 20014")
180#define RT_DIAG_DISABLE_CALL_HOST_FROM_DEVICE_WARN
189#ifndef __has_attribute
190#define __has_attribute(x) 0
192#if __has_attribute(noinline)
193#define RT_NOINLINE_ATTR __attribute__((noinline))
195#define RT_NOINLINE_ATTR
204#if defined(_MSC_VER) && !defined(__clang__)
205#define RT_FORCE_INLINE_ATTR __forceinline
206#elif defined(__has_attribute)
207#if __has_attribute(always_inline)
208#define RT_FORCE_INLINE_ATTR inline __attribute__((always_inline))
210#define RT_FORCE_INLINE_ATTR inline
213#define RT_FORCE_INLINE_ATTR inline
216#if (defined(__CUDACC__) || defined(__CUDA__)) && defined(__CUDA_ARCH__)
217#define RT_DEVICE_NOINLINE RT_NOINLINE_ATTR
218#define RT_DEVICE_NOINLINE_HOST_INLINE
220#define RT_DEVICE_NOINLINE
221#define RT_DEVICE_NOINLINE_HOST_INLINE inline
225#if __has_attribute(optimize)
227#define RT_OPTNONE_ATTR __attribute__((optimize("O0")))
228#elif __has_attribute(optnone)
230#define RT_OPTNONE_ATTR __attribute__((optnone))
232#define RT_OPTNONE_ATTR
236#if !defined(FLANG_LITTLE_ENDIAN) && !defined(FLANG_BIG_ENDIAN)
240#if defined(_MSC_VER) || defined(_WIN32)
241#define FLANG_LITTLE_ENDIAN 1
242#elif defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
243#define FLANG_LITTLE_ENDIAN 1
244#elif defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
245#define FLANG_BIG_ENDIAN 1
247#error "Unknown or unsupported endianness."