Browse Source

Merge pull request #914 from rhoarau/sycl

SYCL support #914
Christophe 6 years ago
parent
commit
6cd38b9b02
3 changed files with 50 additions and 0 deletions
  1. 42 0
      glm/detail/setup.hpp
  2. 7 0
      glm/simd/platform.h
  3. 1 0
      readme.md

+ 42 - 0
glm/detail/setup.hpp

@@ -529,6 +529,48 @@
 #	define GLM_EXPLICIT
 #	define GLM_EXPLICIT
 #endif
 #endif
 
 
+///////////////////////////////////////////////////////////////////////////////////
+// SYCL
+
+#if GLM_COMPILER==GLM_COMPILER_SYCL
+
+#include <CL/sycl.hpp>
+#include <limits>
+
+namespace glm {
+namespace std {
+	// 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<typename T>
+	using numeric_limits = ::std::numeric_limits<T>;
+
+	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.
 // 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
 // When GLM_FORCE_SIZE_T_LENGTH is defined, length_t is a typedef of size_t otherwise

+ 7 - 0
glm/simd/platform.h

@@ -81,6 +81,9 @@
 #define GLM_COMPILER_CUDA75			0x100000B0
 #define GLM_COMPILER_CUDA75			0x100000B0
 #define GLM_COMPILER_CUDA80			0x100000C0
 #define GLM_COMPILER_CUDA80			0x100000C0
 
 
+// SYCL
+#define GLM_COMPILER_SYCL			0x00300000
+
 // Clang
 // Clang
 #define GLM_COMPILER_CLANG			0x20000000
 #define GLM_COMPILER_CLANG			0x20000000
 #define GLM_COMPILER_CLANG34		0x20000050
 #define GLM_COMPILER_CLANG34		0x20000050
@@ -129,6 +132,10 @@
 #		error "GLM requires CUDA 7.0 or higher"
 #		error "GLM requires CUDA 7.0 or higher"
 #	endif
 #	endif
 
 
+// SYCL
+#elif defined(__SYCL_DEVICE_ONLY__)
+#	define GLM_COMPILER GLM_COMPILER_SYCL
+
 // Clang
 // Clang
 #elif defined(__clang__)
 #elif defined(__clang__)
 #	if defined(__apple_build_version__)
 #	if defined(__apple_build_version__)

+ 1 - 0
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
 - [LLVM](http://llvm.org/) 3.4 and higher
 - [Visual C++](http://www.visualstudio.com/) 2013 and higher
 - [Visual C++](http://www.visualstudio.com/) 2013 and higher
 - [CUDA](https://developer.nvidia.com/about-cuda) 7.0 and higher (experimental)
 - [CUDA](https://developer.nvidia.com/about-cuda) 7.0 and higher (experimental)
+- [SYCL](https://www.khronos.org/sycl/) (experimental: only [ComputeCpp](https://codeplay.com/products/computesuite/computecpp) implementation has been tested).
 - Any C++11 compiler
 - 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).
 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).