#pragma once
#if !defined(_CRT_SECURE_NO_WARNINGS)
#define _CRT_SECURE_NO_WARNINGS
#endif
#include <cstddef>
#include <cassert>
#include <cstdlib>
#include <cstdio>
#include <memory>
#include <stdexcept>
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <cstring>
#include <stdint.h>
#include <functional>
#include <mutex>
#if defined(EMBREE_SYCL_SUPPORT)
#define __SYCL_USE_NON_VARIADIC_SPIRV_OCL_PRINTF__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#pragma clang diagnostic ignored "-W#pragma-messages"
#include <sycl/sycl.hpp>
#pragma clang diagnostic pop
#include "sycl.h"
#if defined(EMBREE_SYCL_SUPPORT) && defined(__SYCL_DEVICE_ONLY__)
#define CONSTANT …
#else
#define CONSTANT
#endif
#endif
#if defined(__x86_64__) || defined(__ia64__) || defined(_M_X64)
#define __X86_64__
#define __X86_ASM__
#elif defined(__i386__) || defined(_M_IX86)
#define __X86_ASM__
#endif
#if defined(__X86_64__) || defined(__aarch64__)
#define __64BIT__
#endif
#if defined(linux) || defined(__linux__) || defined(__LINUX__)
# if !defined(__LINUX__)
#define __LINUX__
# endif
# if !defined(__UNIX__)
#define __UNIX__
# endif
#endif
#if defined(__FreeBSD__) || defined(__FREEBSD__)
# if !defined(__FREEBSD__)
#define __FREEBSD__
# endif
# if !defined(__UNIX__)
#define __UNIX__
# endif
#endif
#if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)) && !defined(__CYGWIN__)
# if !defined(__WIN32__)
#define __WIN32__
# endif
#endif
#if defined(__CYGWIN__)
# if !defined(__UNIX__)
#define __UNIX__
# endif
#endif
#if defined(__APPLE__) || defined(MACOSX) || defined(__MACOSX__)
# if !defined(__MACOSX__)
#define __MACOSX__
# endif
# if !defined(__UNIX__)
#define __UNIX__
# endif
#endif
#if defined(__unix__) || defined (unix) || defined(__unix) || defined(_unix)
# if !defined(__UNIX__)
#define __UNIX__
# endif
#endif
#ifdef __WIN32__
# if defined(EMBREE_STATIC_LIB)
#define dll_export
#define dll_import
# else
#define dll_export …
#define dll_import …
# endif
#else
#define dll_export …
#define dll_import
#endif
#if defined(__WIN32__) && !defined(__MINGW32__)
#if !defined(__noinline)
#define __noinline …
#endif
#if defined(__INTEL_COMPILER)
#define __restrict__ __restrict
#else
#define __restrict__
#endif
#if !defined(__thread) && !defined(__INTEL_LLVM_COMPILER)
#define __thread __declspec(thread)
#endif
#if !defined(__aligned)
#define __aligned …
#endif
#define debugbreak …
#else
#if !defined(__noinline)
#define __noinline …
#endif
#if !defined(__forceinline)
#define __forceinline …
#endif
#if !defined(__aligned)
#define __aligned(...) …
#endif
#if !defined(__FUNCTION__)
#define __FUNCTION__ __PRETTY_FUNCTION__
#endif
#define debugbreak() …
#endif
#if defined(__clang__) || defined(__GNUC__)
#define MAYBE_UNUSED …
#else
#define MAYBE_UNUSED
#endif
#if !defined(_unused)
#define _unused(x) …
#endif
#if defined(_MSC_VER) && (_MSC_VER < 1900)
#define DELETED
#else
#define DELETED …
#endif
#if !defined(likely)
#if defined(_MSC_VER) && !defined(__INTEL_COMPILER) || defined(__SYCL_DEVICE_ONLY__)
#define likely …
#define unlikely …
#else
#define likely(expr) …
#define unlikely(expr) …
#endif
#endif
#define STRING(x) …
#define TOSTRING(x) …
#define PING …
#define PRINT(x) …
#define PRINT2(x,y) …
#define PRINT3(x,y,z) …
#define PRINT4(x,y,z,w) …
#define UPRINT(x) …
#define UPRINT2(x,y) …
#define UPRINT3(x,y,z) …
#define UPRINT4(x,y,z,w) …
#if defined(DEBUG)
#define THROW_RUNTIME_ERROR …
#else
#define THROW_RUNTIME_ERROR(str) …
#endif
#define FATAL(x) …
#define WARNING(x) …
#define NOT_IMPLEMENTED …
namespace embree {
real;
}
#if defined(__WIN32__)
#if defined(__64BIT__)
typedef int64_t ssize_t;
#else
typedef int32_t ssize_t;
#endif
#endif
__forceinline std::string toString(long long value) { … }
#if defined(__INTEL_COMPILER)
#pragma warning(disable:2196)
#pragma warning(disable:15335)
#endif
#if defined(_MSC_VER)
#pragma warning(disable:4800)
#pragma warning(disable:4244)
#pragma warning(disable:4267)
#pragma warning(disable:4503)
#pragma warning(disable:4180)
#pragma warning(disable:4258)
# if _MSC_VER < 1910
# pragma warning(disable:4101)
# pragma warning(disable:4789)
# endif
#endif
#if defined(__clang__) && !defined(__INTEL_COMPILER)
#endif
#if defined(__GNUC__) && !defined(__INTEL_COMPILER) && !defined(__clang__)
#pragma GCC diagnostic ignored "-Wpragmas"
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#pragma GCC diagnostic ignored "-Wattributes"
#pragma GCC diagnostic ignored "-Wmisleading-indentation"
#pragma GCC diagnostic ignored "-Wsign-compare"
#pragma GCC diagnostic ignored "-Wparentheses"
#endif
#if defined(__clang__) && defined(__WIN32__)
#pragma clang diagnostic ignored "-Wunused-parameter"
#pragma clang diagnostic ignored "-Wmicrosoft-cast"
#pragma clang diagnostic ignored "-Wmicrosoft-enum-value"
#pragma clang diagnostic ignored "-Wmicrosoft-include"
#pragma clang diagnostic ignored "-Wunused-function"
#pragma clang diagnostic ignored "-Wunknown-pragmas"
#endif
#if defined(__WIN32__) && defined(__INTEL_COMPILER)
#define DISABLE_DEPRECATED_WARNING …
#define ENABLE_DEPRECATED_WARNING …
#elif defined(__INTEL_COMPILER)
#define DISABLE_DEPRECATED_WARNING …
#define ENABLE_DEPRECATED_WARNING …
#elif defined(__clang__)
#define DISABLE_DEPRECATED_WARNING …
#define ENABLE_DEPRECATED_WARNING …
#elif defined(__GNUC__)
#define DISABLE_DEPRECATED_WARNING …
#define ENABLE_DEPRECATED_WARNING …
#elif defined(_MSC_VER)
#define DISABLE_DEPRECATED_WARNING …
#define ENABLE_DEPRECATED_WARNING …
#endif
#if defined(EMBREE_SYCL_SUPPORT) && defined(__SYCL_DEVICE_ONLY__)
#define sycl_printf0 …
#define sycl_printf0_ …
#else
#define sycl_printf0(format, ...) …
#define sycl_printf0_(format) …
#endif
#define sycl_printf(format, ...) …
#define sycl_printf_(format) …
#if defined(EMBREE_SYCL_SUPPORT) && defined(__SYCL_DEVICE_ONLY__)
namespace embree
{
struct sycl_ostream_ {
sycl_ostream_ (bool uniform) : uniform(uniform) {}
bool uniform = false;
};
struct sycl_endl_ {};
#define embree_ostream …
#define embree_cout …
#define embree_cout_uniform …
#define embree_endl …
inline sycl_ostream_ operator <<(sycl_ostream_ cout, int i)
{
if (cout.uniform) {
if (get_sub_group_local_id() == sycl::ctz(intel_sub_group_ballot(true)))
sycl_printf("%i",i);
}
else
sycl_printf("%i ",i);
return cout;
}
inline sycl_ostream_ operator <<(sycl_ostream_ cout, unsigned int i)
{
if (cout.uniform) {
if (get_sub_group_local_id() == sycl::ctz(intel_sub_group_ballot(true)))
sycl_printf("%u",i);
} else
sycl_printf("%u ",i);
return cout;
}
inline sycl_ostream_ operator <<(sycl_ostream_ cout, float f)
{
if (cout.uniform) {
if (get_sub_group_local_id() == sycl::ctz(intel_sub_group_ballot(true)))
sycl_printf("%f",f);
} else
sycl_printf("%f ",f);
return cout;
}
inline sycl_ostream_ operator <<(sycl_ostream_ cout, double d)
{
if (cout.uniform) {
if (get_sub_group_local_id() == sycl::ctz(intel_sub_group_ballot(true)))
sycl_printf("%f",d);
} else
sycl_printf("%f ",d);
return cout;
}
inline sycl_ostream_ operator <<(sycl_ostream_ cout, uint64_t l)
{
if (cout.uniform) {
if (get_sub_group_local_id() == sycl::ctz(intel_sub_group_ballot(true)))
sycl_printf("%lu",l);
} else
sycl_printf("%lu ",l);
return cout;
}
inline sycl_ostream_ operator <<(sycl_ostream_ cout, long l)
{
if (cout.uniform) {
if (get_sub_group_local_id() == sycl::ctz(intel_sub_group_ballot(true)))
sycl_printf("%l",l);
} else
sycl_printf("%l ",l);
return cout;
}
inline sycl_ostream_ operator <<(sycl_ostream_ cout, void* p)
{
if (cout.uniform) {
if (get_sub_group_local_id() == sycl::ctz(intel_sub_group_ballot(true)))
sycl_printf("%p",p);
} else
sycl_printf("%p ",p);
return cout;
}
inline sycl_ostream_ operator <<(sycl_ostream_ cout, const char* c)
{
if (get_sub_group_local_id() == sycl::ctz(intel_sub_group_ballot(true)))
sycl_printf("%s",c);
return cout;
}
inline sycl_ostream_ operator <<(sycl_ostream_ cout, sycl_endl_)
{
if (get_sub_group_local_id() == sycl::ctz(intel_sub_group_ballot(true)))
sycl_printf_("\n");
return cout;
}
}
#else
#define embree_ostream …
#define embree_cout …
#define embree_cout_uniform …
#define embree_endl …
#endif
#if defined(EMBREE_SYCL_SUPPORT)
__forceinline embree_ostream operator<<(embree_ostream out, const sycl::float4& v) {
return out << "(" << v.x() << "," << v.y() << "," << v.z() << "," << v.w() << ")";
}
__forceinline embree_ostream operator<<(embree_ostream out, const sycl::float3& v) {
return out << "(" << v.x() << "," << v.y() << "," << v.z() << ")";
}
__forceinline embree_ostream operator<<(embree_ostream out, const sycl::float2& v) {
return out << "(" << v.x() << "," << v.y() << ")";
}
__forceinline embree_ostream operator<<(embree_ostream out, const sycl::int4& v) {
return out << "(" << v.x() << "," << v.y() << "," << v.z() << "," << v.w() << ")";
}
__forceinline embree_ostream operator<<(embree_ostream out, const sycl::int3& v) {
return out << "(" << v.x() << "," << v.y() << "," << v.z() << ")";
}
__forceinline embree_ostream operator<<(embree_ostream out, const sycl::int2& v) {
return out << "(" << v.x() << "," << v.y() << ")";
}
__forceinline embree_ostream operator<<(embree_ostream out, const sycl::uint4& v) {
return out << "(" << v.x() << "," << v.y() << "," << v.z() << "," << v.w() << ")";
}
__forceinline embree_ostream operator<<(embree_ostream out, const sycl::uint3& v) {
return out << "(" << v.x() << "," << v.y() << "," << v.z() << ")";
}
__forceinline embree_ostream operator<<(embree_ostream out, const sycl::uint2& v) {
return out << "(" << v.x() << "," << v.y() << ")";
}
#endif
inline void tab(std::ostream& cout, int n) { … }
inline std::string tab(int depth) { … }
#if defined (__GNUC__)
#define IACA_SSC_MARK( MARK_ID ) …
#define IACA_UD_BYTES …
#else
#define IACA_UD_BYTES …
#define IACA_SSC_MARK …
#define IACA_VC64_START …
#define IACA_VC64_END …
#endif
#define IACA_START …
#define IACA_END …
namespace embree
{
template<typename Closure>
struct OnScopeExitHelper
{ … };
template <typename Closure>
OnScopeExitHelper<Closure> OnScopeExit(const Closure f) { … }
#define STRING_JOIN2(arg1, arg2) …
#define DO_STRING_JOIN2(arg1, arg2) …
#define ON_SCOPE_EXIT(code) …
template<typename Ty>
std::unique_ptr<Ty> make_unique(Ty* ptr) { … }
}