Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 39 additions & 1 deletion .github/workflows/public.continuous.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,42 @@ jobs:
cmake -D BUILD_TBB_FROM_SOURCE=ON -D EMBREE_EXTRA_OPTIONS="-DBUILD_TESTING=ON -DEMBREE_TUTORIALS=ON -DEMBREE_ISPC_SUPPORT=ON -DEMBREE_TESTING_INTENSITY=3" ../superbuild
cmake --build .
cd embree/build
ctest
ctest

windows-11-arm:
runs-on: windows-11-arm
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Build and Run
shell: pwsh
run: |
$opts = "-DBUILD_TESTING=ON"
$opts += " -DEMBREE_TUTORIALS=ON"
$opts += " -DEMBREE_ISPC_SUPPORT=OFF"
$opts += " -DEMBREE_TASKING_SYSTEM=INTERNAL"
$opts += " -DEMBREE_TESTING_INTENSITY=2"

cmake -B build -G "Visual Studio 17 2022" -A ARM64 $opts.Split(" ") .
cmake --build build --config Release
ctest --test-dir build -C Release --output-on-failure

windows-11:
runs-on: windows-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Build and Run
shell: pwsh
run: |
$opts = "-DBUILD_TESTING=ON"
$opts += " -DEMBREE_TUTORIALS=ON"
$opts += " -DEMBREE_ISPC_SUPPORT=OFF"
$opts += " -DEMBREE_TASKING_SYSTEM=INTERNAL"
$opts += " -DEMBREE_TESTING_INTENSITY=2"

cmake -B build -G "Visual Studio 17 2022" $opts.Split(" ") .
cmake --build build --config Release
ctest --test-dir build -C Release --output-on-failure
53 changes: 53 additions & 0 deletions common/simd/arm/simd_wrapper_types.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Copyright 2009-2024 Intel Corporation
// SPDX-License-Identifier: Apache-2.0

#pragma once

#include <immintrin.h>
#include "../../sys/platform.h"

namespace embree
{
#if defined(_MSC_VER) && defined(_ARM64_)
// On ARM64 MSVC, __m128 and __m128i are both aliased to __n128 in arm_neon.h,
// causing C++ overload ambiguity. We wrap them in unique types to disambiguate.

struct __m128_wrapper {
__m128 data;
__forceinline __m128_wrapper() {}
__forceinline __m128_wrapper(__m128 v) : data(v) {}
__forceinline operator __m128() const { return data; }
__forceinline operator __m128&() { return data; }
};

struct __m128i_wrapper {
__m128i data;
__forceinline __m128i_wrapper() {}
__forceinline __m128i_wrapper(__m128i v) : data(v) {}
__forceinline operator __m128i() const { return data; }
__forceinline operator __m128i&() { return data; }
};

struct __m128d_wrapper {
__m128d data;
__forceinline __m128d_wrapper() {}
__forceinline __m128d_wrapper(__m128d v) : data(v) {}
__forceinline operator __m128d() const { return data; }
__forceinline operator __m128d&() { return data; }
};

#else
// On other platforms, use identity "wrappers" that compile away to nothing
template<typename T> struct identity_wrapper {
T data;
__forceinline identity_wrapper() {}
__forceinline identity_wrapper(T v) : data(v) {}
__forceinline operator T() const { return data; }
__forceinline operator T&() { return data; }
};

using __m128_wrapper = identity_wrapper<__m128>;
using __m128i_wrapper = identity_wrapper<__m128i>;
using __m128d_wrapper = identity_wrapper<__m128d>;
#endif
}
4 changes: 4 additions & 0 deletions common/simd/arm/sse2neon.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@
#define _sse2neon_likely(x) __builtin_expect(!!(x), 1)
#define _sse2neon_unlikely(x) __builtin_expect(!!(x), 0)
#else /* non-GNU / non-clang compilers */
#if defined(_MSC_VER)
#pragma message("Macro name collisions may happen with unsupported compiler.")
#else
#warning "Macro name collisions may happen with unsupported compiler."
#endif
#ifndef FORCE_INLINE
#define FORCE_INLINE static inline
#endif
Expand Down
16 changes: 9 additions & 7 deletions common/simd/vboolf4_sse2.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#pragma once

#include "arm/simd_wrapper_types.h"

#define vboolf vboolf_impl
#define vboold vboold_impl
#define vint vint_impl
Expand All @@ -23,8 +25,8 @@ namespace embree
typedef vint4 Int;
typedef vfloat4 Float;

enum { size = 4 }; // number of SIMD elements
union { __m128 v; int i[4]; }; // data
enum { size = 4 }; // number of SIMD elements
union { __m128_wrapper v; int i[4]; }; // data

////////////////////////////////////////////////////////////////////////////////
/// Constructors, Assignment & Cast Operators
Expand All @@ -35,10 +37,10 @@ namespace embree
__forceinline vboolf4& operator =(const vboolf4& other) { v = other.v; return *this; }

__forceinline vboolf(__m128 input) : v(input) {}
__forceinline operator const __m128&() const { return v; }
__forceinline operator const __m128&() const { return v.data; }
#if !defined(__EMSCRIPTEN__)
__forceinline operator const __m128i() const { return _mm_castps_si128(v); }
__forceinline operator const __m128d() const { return _mm_castps_pd(v); }
__forceinline operator const __m128i() const { return _mm_castps_si128(v.data); }
__forceinline operator const __m128d() const { return _mm_castps_pd(v.data); }
#endif

__forceinline vboolf(bool a)
Expand All @@ -52,7 +54,7 @@ namespace embree

/* return int32 mask */
__forceinline __m128i mask32() const {
return _mm_castps_si128(v);
return _mm_castps_si128(v.data);
}

////////////////////////////////////////////////////////////////////////////////
Expand All @@ -66,7 +68,7 @@ namespace embree
/// Array Access
////////////////////////////////////////////////////////////////////////////////

__forceinline bool operator [](size_t index) const { assert(index < 4); return (_mm_movemask_ps(v) >> index) & 1; }
__forceinline bool operator [](size_t index) const { assert(index < 4); return (_mm_movemask_ps(v.data) >> index) & 1; }
__forceinline int& operator [](size_t index) { assert(index < 4); return i[index]; }
};

Expand Down
10 changes: 6 additions & 4 deletions common/simd/vfloat4_sse2.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#pragma once

#include "arm/simd_wrapper_types.h"

#define vboolf vboolf_impl
#define vboold vboold_impl
#define vint vint_impl
Expand All @@ -23,8 +25,8 @@ namespace embree
typedef vint4 Int;
typedef vfloat4 Float;

enum { size = 4 }; // number of SIMD elements
union { __m128 v; float f[4]; int i[4]; }; // data
enum { size = 4 }; // number of SIMD elements
union { __m128_wrapper v; float f[4]; int i[4]; }; // data

////////////////////////////////////////////////////////////////////////////////
/// Constructors, Assignment & Cast Operators
Expand All @@ -37,8 +39,8 @@ namespace embree
__forceinline vfloat4& operator =(const vfloat4& other) { v = other.v; return *this; }

__forceinline vfloat(__m128 a) : v(a) {}
__forceinline operator const __m128&() const { return v; }
__forceinline operator __m128&() { return v; }
__forceinline operator const __m128&() const { return v.data; }
__forceinline operator __m128&() { return v.data; }

__forceinline vfloat(float a) : v(_mm_set1_ps(a)) {}
__forceinline vfloat(float a, float b, float c, float d) : v(_mm_set_ps(d, c, b, a)) {}
Expand Down
9 changes: 5 additions & 4 deletions common/simd/vint4_sse2.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#pragma once

#include "arm/simd_wrapper_types.h"
#include "../math/emath.h"

#define vboolf vboolf_impl
Expand All @@ -25,8 +26,8 @@ namespace embree
typedef vint4 Int;
typedef vfloat4 Float;

enum { size = 4 }; // number of SIMD elements
union { __m128i v; int i[4]; }; // data
enum { size = 4 }; // number of SIMD elements
union { __m128i_wrapper v; int i[4]; }; // data

////////////////////////////////////////////////////////////////////////////////
/// Constructors, Assignment & Cast Operators
Expand All @@ -37,8 +38,8 @@ namespace embree
__forceinline vint4& operator =(const vint4& a) { v = a.v; return *this; }

__forceinline vint(__m128i a) : v(a) {}
__forceinline operator const __m128i&() const { return v; }
__forceinline operator __m128i&() { return v; }
__forceinline operator const __m128i&() const { return v.data; }
__forceinline operator __m128i&() { return v.data; }

__forceinline vint(int a) : v(_mm_set1_epi32(a)) {}
__forceinline vint(int a, int b, int c, int d) : v(_mm_set_epi32(d, c, b, a)) {}
Expand Down
7 changes: 4 additions & 3 deletions common/simd/vuint4_sse2.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#pragma once

#include "arm/simd_wrapper_types.h"
#include "../math/emath.h"

#define vboolf vboolf_impl
Expand All @@ -26,7 +27,7 @@ namespace embree
typedef vfloat4 Float;

enum { size = 4 }; // number of SIMD elements
union { __m128i v; unsigned int i[4]; }; // data
union { __m128i_wrapper v; unsigned int i[4]; }; // data

////////////////////////////////////////////////////////////////////////////////
/// Constructors, Assignment & Cast Operators
Expand All @@ -37,8 +38,8 @@ namespace embree
__forceinline vuint4& operator =(const vuint4& a) { v = a.v; return *this; }

__forceinline vuint(const __m128i a) : v(a) {}
__forceinline operator const __m128i&() const { return v; }
__forceinline operator __m128i&() { return v; }
__forceinline operator const __m128i&() const { return v.data; }
__forceinline operator __m128i&() { return v.data; }


__forceinline vuint(unsigned int a) : v(_mm_set1_epi32(a)) {}
Expand Down
2 changes: 1 addition & 1 deletion common/sys/intrinsics.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <intrin.h>
#endif

#if defined(__ARM_NEON)
#if defined(__ARM_NEON) || defined(__aarch64__)
#include "../simd/arm/emulation.h"
#else
#include <immintrin.h>
Expand Down
5 changes: 5 additions & 0 deletions common/sys/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@
#define __X86_ASM__
#endif

/* normalize ARM64 platform macro */
#if defined(_M_ARM64) || defined(_M_ARM64EC)
#define __aarch64__
#endif

/* detect 64 bit platform */
#if defined(__X86_64__) || defined(__aarch64__)
#define __64BIT__
Expand Down
2 changes: 1 addition & 1 deletion superbuild/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

## Global settings ##

cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.5)

set(CMAKE_MODULE_PATH
${CMAKE_MODULE_PATH}
Expand Down
Loading