diff --git a/sycl/include/CL/sycl/accessor.hpp b/sycl/include/CL/sycl/accessor.hpp index d54c43b6a4811..5bad3b36e1ede 100755 --- a/sycl/include/CL/sycl/accessor.hpp +++ b/sycl/include/CL/sycl/accessor.hpp @@ -834,6 +834,8 @@ class accessor : #endif // __SYCL_DEVICE_ONLY__ size_t Result = 0; + // Unroll the following loop for both host and device code + __SYCL_UNROLL(3) for (int I = 0; I < Dims; ++I) Result = Result * getMemoryRange()[I] + getOffset()[I] + Id[I]; return Result; diff --git a/sycl/include/CL/sycl/detail/common.hpp b/sycl/include/CL/sycl/detail/common.hpp index 8cb2e3ab384a0..c4592a475b1cd 100644 --- a/sycl/include/CL/sycl/detail/common.hpp +++ b/sycl/include/CL/sycl/detail/common.hpp @@ -10,15 +10,13 @@ #include #include +#include #include #include #include #include -#define __SYCL_STRINGIFY_LINE_HELP(s) #s -#define __SYCL_STRINGIFY_LINE(s) __SYCL_STRINGIFY_LINE_HELP(s) - // Default signature enables the passing of user code location information to // public methods as a default argument. If the end-user wants to disable the // code location information, they must compile the code with @@ -106,8 +104,8 @@ static inline std::string codeToString(cl_int code) { #define __SYCL_OCL_ERROR_REPORT \ "Native API failed. " /*__FILE__*/ \ /* TODO: replace __FILE__ to report only relative path*/ \ - /* ":" __SYCL_STRINGIFY_LINE(__LINE__) ": " */ \ - "Native API returns: " + /* ":" __SYCL_STRINGIFY(__LINE__) ": " */ \ + "Native API returns: " #ifndef __SYCL_SUPPRESS_OCL_ERROR_REPORT #include diff --git a/sycl/include/CL/sycl/detail/defines_elementary.hpp b/sycl/include/CL/sycl/detail/defines_elementary.hpp index f7168c35dfcde..ac967fec2edea 100644 --- a/sycl/include/CL/sycl/detail/defines_elementary.hpp +++ b/sycl/include/CL/sycl/detail/defines_elementary.hpp @@ -87,10 +87,14 @@ #endif #endif // __SYCL_FALLTHROUGH +// Stringify an argument to pass it in _Pragma directive below. +#ifndef __SYCL_STRINGIFY +#define __SYCL_STRINGIFY(x) #x +#endif // __SYCL_STRINGIFY + // define __SYCL_WARNING convenience macro to report compiler warnings #if defined(__GNUC__) -#define __SYCL_GCC_PRAGMA(x) _Pragma(#x) -#define __SYCL_WARNING(msg) __SYCL_GCC_PRAGMA(GCC warning msg) +#define __SYCL_WARNING(msg) _Pragma(__SYCL_STRINGIFY(GCC warning msg)) #elif defined(_MSC_VER) && !defined(__clang__) #define __SYCL_QUOTE1(x) #x #define __SYCL_QUOTE(x) __SYCL_QUOTE1(x) @@ -100,3 +104,17 @@ // clang emits "warning:" in the message pragma output #define __SYCL_WARNING(msg) __pragma(message(msg)) #endif // __GNUC__ + +// Define __SYCL_UNROLL to add pragma/attribute unroll to a loop. +#ifndef __SYCL_UNROLL +#if defined(__INTEL_COMPILER) || defined(__INTEL_LLVM_COMPILER) +#define __SYCL_UNROLL(x) _Pragma(__SYCL_STRINGIFY(unroll x)) +#elif defined(__clang__) +#define __SYCL_UNROLL(x) _Pragma(__SYCL_STRINGIFY(unroll x)) +#elif (defined(__GNUC__) && __GNUC__ >= 8) || \ + (defined(__GNUG__) && __GNUG__ >= 8) +#define __SYCL_UNROLL(x) _Pragma(__SYCL_STRINGIFY(GCC unroll x)) +#else +#define __SYCL_UNROLL(x) +#endif // compiler switch +#endif // __SYCL_UNROLL diff --git a/sycl/source/detail/config.cpp b/sycl/source/detail/config.cpp index 9a9f4963803c1..8dab8a598149a 100644 --- a/sycl/source/detail/config.cpp +++ b/sycl/source/detail/config.cpp @@ -7,6 +7,7 @@ //===----------------------------------------------------------------------===// #include +#include #include #include @@ -27,9 +28,8 @@ namespace detail { const char *SYCLConfigBase::MValueFromFile = nullptr; \ char SYCLConfigBase::MStorage[MaxSize + 1]; \ const char *const SYCLConfigBase::MCompileTimeDef = \ - getStrOrNullptr(__SYCL_STRINGIFY_LINE(CompileTimeDef)); \ - const char *const SYCLConfigBase::MConfigName = \ - __SYCL_STRINGIFY_LINE(Name); + getStrOrNullptr(__SYCL_STRINGIFY(CompileTimeDef)); \ + const char *const SYCLConfigBase::MConfigName = __SYCL_STRINGIFY(Name); #include "detail/config.def" #undef CONFIG