diff --git a/glm/detail/compute_common.hpp b/glm/detail/compute_common.hpp index cc24b9e6..7267a497 100644 --- a/glm/detail/compute_common.hpp +++ b/glm/detail/compute_common.hpp @@ -24,7 +24,7 @@ namespace detail } }; -#if GLM_COMPILER & GLM_COMPILER_CUDA +#if (GLM_COMPILER & GLM_COMPILER_CUDA) || (GLM_COMPILER & GLM_COMPILER_HIP) template<> struct compute_abs { diff --git a/glm/detail/func_common.inl b/glm/detail/func_common.inl index 4b5f1441..86560be9 100644 --- a/glm/detail/func_common.inl +++ b/glm/detail/func_common.inl @@ -401,7 +401,7 @@ namespace detail template GLM_FUNC_QUALIFIER genType mod(genType x, genType y) { -# if GLM_COMPILER & GLM_COMPILER_CUDA +# if (GLM_COMPILER & GLM_COMPILER_CUDA) || (GLM_COMPILER & GLM_COMPILER_HIP) // Another Cuda compiler bug https://github.com/g-truc/glm/issues/530 vec<1, genType, defaultp> Result(mod(vec<1, genType, defaultp>(x), y)); return Result.x; @@ -601,7 +601,7 @@ namespace detail # endif # elif (GLM_COMPILER & (GLM_COMPILER_GCC | GLM_COMPILER_CLANG)) && (GLM_PLATFORM & GLM_PLATFORM_ANDROID) && __cplusplus < 201103L return _isnan(x) != 0; -# elif GLM_COMPILER & GLM_COMPILER_CUDA +# elif (GLM_COMPILER & GLM_COMPILER_CUDA) || (GLM_COMPILER & GLM_COMPILER_HIP) return ::isnan(x) != 0; # else return std::isnan(x); @@ -642,7 +642,7 @@ namespace detail # else return std::isinf(x); # endif -# elif GLM_COMPILER & GLM_COMPILER_CUDA +# elif (GLM_COMPILER & GLM_COMPILER_CUDA) || (GLM_COMPILER & GLM_COMPILER_HIP) // http://developer.download.nvidia.com/compute/cuda/4_2/rel/toolkit/docs/online/group__CUDA__MATH__DOUBLE_g13431dd2b40b51f9139cbb7f50c18fab.html#g13431dd2b40b51f9139cbb7f50c18fab return ::isinf(double(x)) != 0; # else diff --git a/glm/detail/setup.hpp b/glm/detail/setup.hpp index bb098552..51a6f490 100644 --- a/glm/detail/setup.hpp +++ b/glm/detail/setup.hpp @@ -144,6 +144,8 @@ # define GLM_HAS_CXX11_STL 0 #elif (GLM_COMPILER & GLM_COMPILER_CUDA_RTC) == GLM_COMPILER_CUDA_RTC # define GLM_HAS_CXX11_STL 0 +#elif (GLM_COMPILER & GLM_COMPILER_HIP) +# define GLM_HAS_CXX11_STL 0 #elif GLM_COMPILER & GLM_COMPILER_CLANG # if (defined(_LIBCPP_VERSION) || (GLM_LANG & GLM_LANG_CXX11_FLAG) || defined(GLM_LANG_STL11_FORCED)) # define GLM_HAS_CXX11_STL 1 @@ -167,7 +169,8 @@ #else # define GLM_HAS_STATIC_ASSERT ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\ ((GLM_COMPILER & GLM_COMPILER_CUDA)) || \ - ((GLM_COMPILER & GLM_COMPILER_VC)))) + ((GLM_COMPILER & GLM_COMPILER_VC)) || \ + ((GLM_COMPILER & GLM_COMPILER_HIP)))) #endif // N1988 @@ -177,7 +180,8 @@ # define GLM_HAS_EXTENDED_INTEGER_TYPE (\ ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (GLM_COMPILER & GLM_COMPILER_VC)) || \ ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (GLM_COMPILER & GLM_COMPILER_CUDA)) || \ - ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (GLM_COMPILER & GLM_COMPILER_CLANG))) + ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (GLM_COMPILER & GLM_COMPILER_CLANG)) || \ + ((GLM_COMPILER & GLM_COMPILER_HIP))) #endif // N2672 Initializer lists http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2672.htm @@ -189,7 +193,8 @@ # define GLM_HAS_INITIALIZER_LISTS ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\ ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC15)) || \ ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_COMPILER >= GLM_COMPILER_INTEL14)) || \ - ((GLM_COMPILER & GLM_COMPILER_CUDA)))) + ((GLM_COMPILER & GLM_COMPILER_CUDA)) || \ + ((GLM_COMPILER & GLM_COMPILER_HIP)))) #endif // N2544 Unrestricted unions http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2544.pdf @@ -200,7 +205,8 @@ #else # define GLM_HAS_UNRESTRICTED_UNIONS (GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\ (GLM_COMPILER & GLM_COMPILER_VC) || \ - ((GLM_COMPILER & GLM_COMPILER_CUDA))) + ((GLM_COMPILER & GLM_COMPILER_CUDA)) || \ + ((GLM_COMPILER & GLM_COMPILER_HIP))) #endif // N2346 @@ -212,7 +218,8 @@ # define GLM_HAS_DEFAULTED_FUNCTIONS ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\ ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC12)) || \ ((GLM_COMPILER & GLM_COMPILER_INTEL)) || \ - (GLM_COMPILER & GLM_COMPILER_CUDA))) + (GLM_COMPILER & GLM_COMPILER_CUDA)) || \ + ((GLM_COMPILER & GLM_COMPILER_HIP))) #endif // N2118 @@ -223,7 +230,8 @@ #else # define GLM_HAS_RVALUE_REFERENCES ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\ ((GLM_COMPILER & GLM_COMPILER_VC)) || \ - ((GLM_COMPILER & GLM_COMPILER_CUDA)))) + ((GLM_COMPILER & GLM_COMPILER_CUDA)) || \ + ((GLM_COMPILER & GLM_COMPILER_HIP)))) #endif // N2437 http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2437.pdf @@ -235,7 +243,8 @@ # define GLM_HAS_EXPLICIT_CONVERSION_OPERATORS ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\ ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_COMPILER >= GLM_COMPILER_INTEL14)) || \ ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC12)) || \ - ((GLM_COMPILER & GLM_COMPILER_CUDA)))) + ((GLM_COMPILER & GLM_COMPILER_CUDA)) || \ + ((GLM_COMPILER & GLM_COMPILER_HIP)))) #endif // N2258 http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2258.pdf @@ -247,7 +256,8 @@ # define GLM_HAS_TEMPLATE_ALIASES ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\ ((GLM_COMPILER & GLM_COMPILER_INTEL)) || \ ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC12)) || \ - ((GLM_COMPILER & GLM_COMPILER_CUDA)))) + ((GLM_COMPILER & GLM_COMPILER_CUDA)) || \ + ((GLM_COMPILER & GLM_COMPILER_HIP)))) #endif // N2930 http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2930.html @@ -259,7 +269,8 @@ # define GLM_HAS_RANGE_FOR ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\ ((GLM_COMPILER & GLM_COMPILER_INTEL)) || \ ((GLM_COMPILER & GLM_COMPILER_VC)) || \ - ((GLM_COMPILER & GLM_COMPILER_CUDA)))) + ((GLM_COMPILER & GLM_COMPILER_CUDA)) || \ + ((GLM_COMPILER & GLM_COMPILER_HIP)))) #endif // N2341 http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2341.pdf @@ -271,7 +282,8 @@ # define GLM_HAS_ALIGNOF ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\ ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_COMPILER >= GLM_COMPILER_INTEL15)) || \ ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC14)) || \ - ((GLM_COMPILER & GLM_COMPILER_CUDA)))) + ((GLM_COMPILER & GLM_COMPILER_CUDA)) || \ + ((GLM_COMPILER & GLM_COMPILER_HIP)))) #endif // N2235 Generalized Constant Expressions http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2235.pdf @@ -335,7 +347,8 @@ #else # define GLM_HAS_MAKE_SIGNED ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\ ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC12)) || \ - ((GLM_COMPILER & GLM_COMPILER_CUDA)))) + ((GLM_COMPILER & GLM_COMPILER_CUDA)) || \ + ((GLM_COMPILER & GLM_COMPILER_HIP)))) #endif // @@ -410,7 +423,7 @@ /////////////////////////////////////////////////////////////////////////////////// // Qualifiers -#if GLM_COMPILER & GLM_COMPILER_CUDA +#if (GLM_COMPILER & GLM_COMPILER_CUDA) || (GLM_COMPILER & GLM_COMPILER_HIP) # define GLM_CUDA_FUNC_DEF __device__ __host__ # define GLM_CUDA_FUNC_DECL __device__ __host__ #else @@ -425,7 +438,7 @@ # elif GLM_COMPILER & (GLM_COMPILER_GCC | GLM_COMPILER_CLANG) # define GLM_INLINE inline __attribute__((__always_inline__)) # define GLM_NEVER_INLINE __attribute__((__noinline__)) -# elif GLM_COMPILER & GLM_COMPILER_CUDA +# elif (GLM_COMPILER & GLM_COMPILER_CUDA) || (GLM_COMPILER & GLM_COMPILER_HIP) # define GLM_INLINE __forceinline__ # define GLM_NEVER_INLINE __noinline__ # else @@ -512,7 +525,7 @@ #elif GLM_COMPILER & (GLM_COMPILER_GCC | GLM_COMPILER_CLANG | GLM_COMPILER_INTEL) # define GLM_DEPRECATED __attribute__((__deprecated__)) # define GLM_ALIGNED_TYPEDEF(type, name, alignment) typedef type name __attribute__((aligned(alignment))) -#elif GLM_COMPILER & GLM_COMPILER_CUDA +#elif (GLM_COMPILER & GLM_COMPILER_CUDA) || (GLM_COMPILER & GLM_COMPILER_HIP) # define GLM_DEPRECATED # define GLM_ALIGNED_TYPEDEF(type, name, alignment) typedef type name __align__(x) #else @@ -970,6 +983,8 @@ namespace detail // Report compiler detection # if GLM_COMPILER & GLM_COMPILER_CUDA # pragma message("GLM: CUDA compiler detected") +# elif GLM_COMPILER & GLM_COMPILER_HIP +# pragma message("GLM: HIP compiler detected") # elif GLM_COMPILER & GLM_COMPILER_VC # pragma message("GLM: Visual C++ compiler detected") # elif GLM_COMPILER & GLM_COMPILER_CLANG diff --git a/glm/ext.hpp b/glm/ext.hpp index 6a6e10f0..39cabc3b 100644 --- a/glm/ext.hpp +++ b/glm/ext.hpp @@ -235,7 +235,7 @@ #include "./gtx/rotate_vector.hpp" #include "./gtx/spline.hpp" #include "./gtx/std_based_type.hpp" -#if !(GLM_COMPILER & GLM_COMPILER_CUDA) +#if !((GLM_COMPILER & GLM_COMPILER_CUDA) || (GLM_COMPILER & GLM_COMPILER_HIP)) # include "./gtx/string_cast.hpp" #endif #include "./gtx/transform.hpp" diff --git a/glm/simd/platform.h b/glm/simd/platform.h index d1495299..12a7b726 100644 --- a/glm/simd/platform.h +++ b/glm/simd/platform.h @@ -97,6 +97,9 @@ #define GLM_COMPILER_CLANG41 0x200000C0 #define GLM_COMPILER_CLANG42 0x200000D0 +// HIP +#define GLM_COMPILER_HIP 0x40000000 + // Build model #define GLM_MODEL_32 0x00000010 #define GLM_MODEL_64 0x00000020 @@ -135,6 +138,10 @@ # error "GLM requires CUDA 7.0 or higher" # endif +// HIP +#elif defined(__HIP__) +# define GLM_COMPILER GLM_COMPILER_HIP + // SYCL #elif defined(__SYCL_DEVICE_ONLY__) # define GLM_COMPILER GLM_COMPILER_SYCL