From 8fb71ffd070703d1450ccb4543ce0f6803f037ee Mon Sep 17 00:00:00 2001 From: rhoarau Date: Sun, 9 Jun 2019 16:05:09 +0200 Subject: [PATCH 1/3] Initial SYCL support: The core and some ext functions should work. --- glm/detail/setup.hpp | 43 +++++++++++++++++++++++++++++++++++++++++++ glm/simd/platform.h | 7 +++++++ readme.md | 1 + 3 files changed, 51 insertions(+) diff --git a/glm/detail/setup.hpp b/glm/detail/setup.hpp index d59808e7..ec2f991b 100644 --- a/glm/detail/setup.hpp +++ b/glm/detail/setup.hpp @@ -410,6 +410,7 @@ #if GLM_COMPILER & GLM_COMPILER_CUDA # define GLM_CUDA_FUNC_DEF __device__ __host__ # define GLM_CUDA_FUNC_DECL __device__ __host__ +#error "oops cuda shit" #else # define GLM_CUDA_FUNC_DEF # define GLM_CUDA_FUNC_DECL @@ -529,6 +530,48 @@ # define GLM_EXPLICIT #endif +/////////////////////////////////////////////////////////////////////////////////// +// SYCL + +#if GLM_COMPILER==GLM_COMPILER_SYCL + +#include +#include + +namespace glm { +namespace std { + // import sycl function into the namespace glm::std to force their usages. + // It's important to use the builtin intrinsics (sin, exp, ...) + // of sycl instead the std ones. + using namespace cl::sycl; + + /////////////////////////////////////////////////////////////////////////////// + // Import some "harmless" std's stuffs used by glm into + // the new glm::std namespace. + template + using numeric_limits = ::std::numeric_limits; + + using ::std::size_t; + + using ::std::uint8_t; + using ::std::uint16_t; + using ::std::uint32_t; + using ::std::uint64_t; + + using ::std::int8_t; + using ::std::int16_t; + using ::std::int32_t; + using ::std::int64_t; + + using ::std::make_unsigned; + /////////////////////////////////////////////////////////////////////////////// +} //namespace std +} //namespace glm + +#endif + +/////////////////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////////////// // Length type: all length functions returns a length_t type. // When GLM_FORCE_SIZE_T_LENGTH is defined, length_t is a typedef of size_t otherwise diff --git a/glm/simd/platform.h b/glm/simd/platform.h index f74b8c7f..58168205 100644 --- a/glm/simd/platform.h +++ b/glm/simd/platform.h @@ -81,6 +81,9 @@ #define GLM_COMPILER_CUDA75 0x100000B0 #define GLM_COMPILER_CUDA80 0x100000C0 +// SYCL +#define GLM_COMPILER_SYCL 0x00300000 + // Clang #define GLM_COMPILER_CLANG 0x20000000 #define GLM_COMPILER_CLANG34 0x20000050 @@ -129,6 +132,10 @@ # error "GLM requires CUDA 7.0 or higher" # endif +// SYCL +#elif defined(__SYCL_DEVICE_ONLY__) +# define GLM_COMPILER GLM_COMPILER_SYCL + // Clang #elif defined(__clang__) # if defined(__apple_build_version__) diff --git a/readme.md b/readme.md index 59e24734..96410811 100644 --- a/readme.md +++ b/readme.md @@ -15,6 +15,7 @@ This library works perfectly with *[OpenGL](https://www.opengl.org)* but it also - [LLVM](http://llvm.org/) 3.4 and higher - [Visual C++](http://www.visualstudio.com/) 2013 and higher - [CUDA](https://developer.nvidia.com/about-cuda) 7.0 and higher (experimental) +- [SYCL](https://www.khronos.org/sycl/) 1.2.1 and higher (experimental: only [ComputeCpp](https://codeplay.com/products/computesuite/computecpp) has been tested). - Any C++11 compiler For more information about *GLM*, please have a look at the [manual](manual.md) and the [API reference documentation](http://glm.g-truc.net/0.9.8/api/index.html). From 1079444f7ef5d9150323c78dd64883b7a05baf1e Mon Sep 17 00:00:00 2001 From: rhoarau Date: Sun, 9 Jun 2019 17:25:43 +0200 Subject: [PATCH 2/3] Remove a preprocessor debug message and correct the readme --- glm/detail/setup.hpp | 1 - readme.md | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/glm/detail/setup.hpp b/glm/detail/setup.hpp index ec2f991b..549ef2e7 100644 --- a/glm/detail/setup.hpp +++ b/glm/detail/setup.hpp @@ -410,7 +410,6 @@ #if GLM_COMPILER & GLM_COMPILER_CUDA # define GLM_CUDA_FUNC_DEF __device__ __host__ # define GLM_CUDA_FUNC_DECL __device__ __host__ -#error "oops cuda shit" #else # define GLM_CUDA_FUNC_DEF # define GLM_CUDA_FUNC_DECL diff --git a/readme.md b/readme.md index 96410811..b37782ca 100644 --- a/readme.md +++ b/readme.md @@ -15,7 +15,7 @@ This library works perfectly with *[OpenGL](https://www.opengl.org)* but it also - [LLVM](http://llvm.org/) 3.4 and higher - [Visual C++](http://www.visualstudio.com/) 2013 and higher - [CUDA](https://developer.nvidia.com/about-cuda) 7.0 and higher (experimental) -- [SYCL](https://www.khronos.org/sycl/) 1.2.1 and higher (experimental: only [ComputeCpp](https://codeplay.com/products/computesuite/computecpp) has been tested). +- [SYCL](https://www.khronos.org/sycl/) (experimental: only [ComputeCpp](https://codeplay.com/products/computesuite/computecpp) implementation has been tested). - Any C++11 compiler For more information about *GLM*, please have a look at the [manual](manual.md) and the [API reference documentation](http://glm.g-truc.net/0.9.8/api/index.html). From 2a8822865c4843e4cc040e9500e55ceb69eed45d Mon Sep 17 00:00:00 2001 From: rhoarau Date: Sun, 16 Jun 2019 13:33:02 +0200 Subject: [PATCH 3/3] Fix typos and code style (space to tab). --- glm/detail/setup.hpp | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/glm/detail/setup.hpp b/glm/detail/setup.hpp index 549ef2e7..1eae6a22 100644 --- a/glm/detail/setup.hpp +++ b/glm/detail/setup.hpp @@ -539,31 +539,31 @@ namespace glm { namespace std { - // import sycl function into the namespace glm::std to force their usages. - // It's important to use the builtin intrinsics (sin, exp, ...) - // of sycl instead the std ones. - using namespace cl::sycl; + // Import SYCL's functions into the namespace glm::std to force their usages. + // It's important to use the math built-in function (sin, exp, ...) + // of SYCL instead the std ones. + using namespace cl::sycl; - /////////////////////////////////////////////////////////////////////////////// - // Import some "harmless" std's stuffs used by glm into - // the new glm::std namespace. - template - using numeric_limits = ::std::numeric_limits; + /////////////////////////////////////////////////////////////////////////////// + // Import some "harmless" std's stuffs used by glm into + // the new glm::std namespace. + template + using numeric_limits = ::std::numeric_limits; - using ::std::size_t; + using ::std::size_t; - using ::std::uint8_t; - using ::std::uint16_t; - using ::std::uint32_t; - using ::std::uint64_t; + using ::std::uint8_t; + using ::std::uint16_t; + using ::std::uint32_t; + using ::std::uint64_t; - using ::std::int8_t; - using ::std::int16_t; - using ::std::int32_t; - using ::std::int64_t; + using ::std::int8_t; + using ::std::int16_t; + using ::std::int32_t; + using ::std::int64_t; - using ::std::make_unsigned; - /////////////////////////////////////////////////////////////////////////////// + using ::std::make_unsigned; + /////////////////////////////////////////////////////////////////////////////// } //namespace std } //namespace glm