Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
82ac34a2d6 | ||
|
|
e80450780c | ||
|
|
4d0329fe71 | ||
|
|
c3ff7ab7b5 | ||
|
|
b3d327b24e | ||
|
|
969e751525 | ||
|
|
6dc16f6ed2 | ||
|
|
e9c241fe29 | ||
|
|
6cb9789951 | ||
|
|
6a3ebf7871 | ||
|
|
8d3e0ec658 | ||
|
|
a303bccf07 | ||
|
|
905f55ae26 | ||
|
|
fe03dcf15a | ||
|
|
db3a9009c0 | ||
|
|
5b65aa7f74 | ||
|
|
d3c7621b02 | ||
|
|
a095872b94 | ||
|
|
9675800bfd | ||
|
|
02e08538df | ||
|
|
72513cd242 | ||
|
|
212be4e85d | ||
|
|
c2923b8db1 | ||
|
|
c0adf11eca | ||
|
|
ae933bc838 | ||
|
|
68e1be6f74 | ||
|
|
73dbc25652 | ||
|
|
52985f445e | ||
|
|
d6921ccb95 | ||
|
|
29a75f3bc1 | ||
|
|
88932255c0 | ||
|
|
ba9ef506e2 | ||
|
|
0d07cb4c85 | ||
|
|
0ea1424d5c | ||
|
|
d5729dea0f | ||
|
|
08af796183 | ||
|
|
2bbe5f6b95 | ||
|
|
9144d1e922 | ||
|
|
d334b0aa28 | ||
|
|
7eff2b710d | ||
|
|
4635412713 | ||
|
|
79b4d9acd7 | ||
|
|
3ec24c2a76 | ||
|
|
908ecb984f | ||
|
|
152cf7e05e | ||
|
|
09580c66f0 | ||
|
|
f7123c27a5 | ||
|
|
c1406f791c | ||
|
|
8fea89369d | ||
|
|
120f529e21 | ||
|
|
09ac15fbb7 | ||
|
|
9464ea90be | ||
|
|
8f95000bd4 | ||
|
|
caadb6d2c8 | ||
|
|
4830e6667c | ||
|
|
62aba5dc83 | ||
|
|
a018d36d8a | ||
|
|
2a8a3a3cfa | ||
|
|
bb0abc10f6 | ||
|
|
95e6ae6c32 | ||
|
|
ba28fb7200 | ||
|
|
06d1363ec0 |
No files matched your search
+54
-203
@@ -1,181 +1,12 @@
|
||||
Version History
|
||||
---------------
|
||||
|
||||
### New Features in Embree 2.16.5
|
||||
- Bugfix in the robust triangle intersector that rarely caused NaNs.
|
||||
- Fixed bug in hybrid traversal kernel when BVH leaf was entered with no
|
||||
active rays. This rarely caused crashes when used with instancing.
|
||||
- Fixed bug introduced in Embree 2.16.2 which caused instancing not to
|
||||
work properly when a smaller than the native SIMD width was
|
||||
used in ray packet mode.
|
||||
- Fixed bug in the curve geometry intersector that caused rendering
|
||||
artefacts for Bézier curves with p0=p1 and/or p2=p3.
|
||||
- Fixed bug in the curve geometry intersector that caused hit results
|
||||
with NaNs to be reported.
|
||||
- Fixed masking bug that caused rare cracks in curve geometry.
|
||||
- Enabled support for SSE2 in precompiled binaries again.
|
||||
|
||||
### New Features in Embree 2.16.4
|
||||
- Bugfix in the ribbon intersector for hair primitives. Non-normalized
|
||||
rays caused wrong intersection distance to be reported.
|
||||
|
||||
### New Features in Embree 2.16.3
|
||||
- Increased accuracy for handling subdivision surfaces. This fixes
|
||||
cracks when using displacement mapping but reduces performance
|
||||
at irregular vertices.
|
||||
- Fixed a bug where subdivision geometry was not properly updated
|
||||
when modifying only the tesselation rate and vertex array.
|
||||
|
||||
### New Features in Embree 2.16.2
|
||||
- Fixed bug that caused NULL intersection context in intersection
|
||||
filter when instancing was used.
|
||||
- Fixed an issue where uv's where outside the triangle (or quad) for
|
||||
very small triangles (or quads). In robust mode we improved the uv
|
||||
calculation to avoid that issue, in fast mode we accept that
|
||||
inconsistency for better performance.
|
||||
- Changed UV encoding for non-quad subdivision patches to
|
||||
allow a subpatch UV range of `[-0.5,1.5[`. Using this new encoding
|
||||
one can use finite differences to calculate derivatives if required.
|
||||
Please adjust your code in case you rely on the old encoding.
|
||||
|
||||
### New Features in Embree 2.16.1
|
||||
- Workaround for compile issues with Visual Studio 2017
|
||||
- Fixed bug in subdiv code for static scenes when using tessellation
|
||||
levels larger than 50.
|
||||
- Fixed low performance when adding many geometries to a scene.
|
||||
- Fixed high memory consumption issue when using instances in
|
||||
dynamic scene (by disabling two level builder for user geometries
|
||||
and instances).
|
||||
|
||||
### New Features in Embree 2.16.0
|
||||
- Improved multi-segment motion blur support for scenes with
|
||||
different number of time steps per mesh.
|
||||
- New top level BVH builder that improves build times and BVH quality
|
||||
of two-level BVHs.
|
||||
- Added support to enable only a single ISA. Previously code was
|
||||
always compiled for SSE2.
|
||||
- Improved single ray tracing performance for incoherent rays on
|
||||
AVX-512 architectures by 5-10%.
|
||||
- Improved packet/hybrid ray tracing performance for incoherent rays
|
||||
on AVX-512 architectures by 10-30%.
|
||||
- Improved stream ray tracing performance for coherent rays in
|
||||
structure-of-pointers layout by 40-70%.
|
||||
- BVH builder for compact scenes of triangles and quads needs
|
||||
essentially no temporary memory anymore. This doubles the
|
||||
maximal scene size that can be rendered in compact mode.
|
||||
- Triangles no longer store the geometry normal in fast/default mode
|
||||
which reduces memory consumption by up to 20%.
|
||||
- Compact mode uses BVH4 now consistently which reduces memory
|
||||
consumption by up to 10%.
|
||||
- Reduced memory consumption for small scenes (of 10k-100k primitives)
|
||||
and dynamic scenes.
|
||||
- Improved performance of user geometries and instances through BVH8
|
||||
support.
|
||||
- The API supports now specifying the geometry ID of a geometry at
|
||||
construction time. This way matching the geometry ID used by
|
||||
Embree and the application is simplified.
|
||||
- Fixed a bug that would have caused a failure of the BVH builder
|
||||
for dynamic scenes when run on a machine with more then 1000 threads.
|
||||
- Fixed a bug that could have been triggered when reaching the maximal
|
||||
number of mappings under Linux (`vm.max_map_count`). This could have
|
||||
happened when creating a large number of small static scenes.
|
||||
- Added huge page support for Windows and MacOSX (experimental).
|
||||
- Added support for Visual Studio 2017.
|
||||
- Removed support for Visual Studio 2012.
|
||||
- Precompiled binaries now require a CPU supporting at least the
|
||||
SSE4.2 ISA.
|
||||
- We no longer provide precompiled binaries for 32 bit on Windows.
|
||||
- Under Windows one now has to use the platform toolset option in
|
||||
CMake to switch to Clang or the Intel® Compiler.
|
||||
- Fixed a bug for subdivision meshes when using the incoherent scene
|
||||
flag.
|
||||
- Fixed a bug in the line geometry intersection, that caused reporting
|
||||
an invalid line segment intersection with primID -1.
|
||||
- Buffer stride for vertex buffers of different time steps of triangle
|
||||
and quad meshes have to be identical now.
|
||||
- Fixed a bug in the curve geometry intersection code when passed a
|
||||
perfect cylinder.
|
||||
|
||||
### New Features in Embree 2.15.0
|
||||
|
||||
- Added `rtcCommitJoin` mode that allows thread to join a build
|
||||
operation. When using the internal tasking system this allows
|
||||
Embree to solely use the threads that called `rtcCommitJoin` to
|
||||
build the scene, while previously also normal worker threads
|
||||
participated in the build. You should no longer use `rtcCommit`
|
||||
to join a build.
|
||||
- Added `rtcDeviceSetErrorFunction2` API call, which sets an error
|
||||
callback function which additionally gets passed a user provided
|
||||
pointer (`rtcDeviceSetErrorFunction` is now deprecated).
|
||||
- Added `rtcDeviceSetMemoryMonitorFunction2` API call, which sets a
|
||||
memory monitor callback function which additionally get passed a
|
||||
user provided pointer. (`rtcDeviceSetMemoryMonitorFunction` is now
|
||||
deprecated).
|
||||
- Build performance for hair geometry improved by up to 2×.
|
||||
- Standard BVH build performance increased by 5%.
|
||||
- Added API extension to use internal Morton-code based builder, the
|
||||
standard binned-SAH builder, and the spatial split-based SAH builder.
|
||||
- Added support for BSpline hair and curves. Embree uses
|
||||
either the Bézier or BSpline basis internally, and converts other
|
||||
curves, which requires more memory during rendering. For reduced
|
||||
memory consumption set the `EMBREE_NATIVE_SPLINE_BASIS` to the basis
|
||||
your application uses (which is set to `BEZIER` by default).
|
||||
- Setting the number of threads through `tbb::taskscheduler_init`
|
||||
object on the application side is now working properly.
|
||||
- Windows and Linux releases are build using AVX-512 support.
|
||||
- Implemented hybrid traversal for hair and line segments for
|
||||
improved ray packet performance.
|
||||
- AVX-512 code compiles with Clang 4.0.0
|
||||
- Fixed crash when ray packets were disabled in CMake.
|
||||
|
||||
### New Features in Embree 2.14.0
|
||||
|
||||
- Added `ignore_config_files` option to init flags that allows the
|
||||
application to ignore Embree configuration files.
|
||||
- Face-varying interpolation is now supported for subdivision surfaces.
|
||||
- Up to 16 user vertex buffers are supported for vertex
|
||||
attribute interpolation.
|
||||
- Deprecated `rtcSetBoundaryMode` function, please use the new
|
||||
`rtcSetSubdivisionMode` function.
|
||||
- Added `RTC_SUBDIV_PIN_BOUNDARY` mode for handling boundaries of
|
||||
subdivision meshes.
|
||||
- Added `RTC_SUBDIV_PIN_ALL` mode to enforce linear interpolation
|
||||
for subdivision meshes.
|
||||
- Optimized object generation performance for dynamic scenes.
|
||||
- Reduced memory consumption when using lots of small dynamic objects.
|
||||
- Fixed bug for subdivision surfaces using low tessellation rates.
|
||||
- Hair geometry now uses a new ribbon intersector that intersects with
|
||||
ray-facing quads. The new intersector also returns the v-coordinate
|
||||
of the hair intersection, and fixes artefacts at junction points
|
||||
between segments, at the cost of a small performance hit.
|
||||
- Added `rtcSetBuffer2` function, that additionally gets the number of
|
||||
elements of a buffer. In dynamic scenes, this function allows to
|
||||
quickly change buffer sizes, making it possible to change the number
|
||||
of primitives of a mesh or the number of crease features for
|
||||
subdivision surfaces.
|
||||
- Added simple 'viewer_anim' tutorial for rendering key
|
||||
frame animations and 'buildbench' for measuring BVH (re-)build
|
||||
performance for static and dynamic scenes.
|
||||
- Added more AVX-512 optimizations for future architectures.
|
||||
|
||||
### New Features in Embree 2.13.0
|
||||
|
||||
- Improved performance for compact (but not robust) scenes.
|
||||
- Added robust mode for motion blurred triangles and quads.
|
||||
- Added fast dynamic mode for user geometries.
|
||||
- Up to 20% faster BVH build performance on the second generation
|
||||
Intel® Xeon Phi™ processor codenamed Knights Landing.
|
||||
- Improved quality of the spatial split builder.
|
||||
- Improved performance for coherent streams of ray packets (SOA
|
||||
layout), e.g. for fast primary visibility.
|
||||
- Various bug fixes in tessellation cache, quad-based spatial
|
||||
split builder, etc.
|
||||
|
||||
### New Features in Embree 2.12.0
|
||||
|
||||
- Added support for multi-segment motion blur for all primitive types.
|
||||
- API support for stream of pointers to single rays (`rtcIntersect1Mp`
|
||||
and `rtcOccluded1Mp`)
|
||||
- Added support for multi-segment motion blur for all primitive
|
||||
types.
|
||||
- API support for stream of pointers to single rays (rtcIntersect1Mp and
|
||||
rtcOccluded1Mp)
|
||||
- Improved BVH refitting performance for dynamic scenes.
|
||||
- Improved high-quality mode for quads (added spatial split builder
|
||||
for quads)
|
||||
@@ -183,34 +14,34 @@ Version History
|
||||
enabled machines.
|
||||
- Performance and correctness bugfix in optimization for streams of
|
||||
coherent (single) rays.
|
||||
- Fixed large memory consumption (issue introduced in Embree v2.11.0).
|
||||
If you use Embree v2.11.0 please upgrade to Embree v2.12.0.
|
||||
- Reduced memory consumption for dynamic scenes containing small
|
||||
meshes.
|
||||
- Fixed large memory consumption (issue introduced in Embree
|
||||
v2.11.0). If you use Embree v2.11.0 please upgrade to Embree
|
||||
v2.12.0.
|
||||
- Reduced memory consumption for dynamic scenes containing small meshes.
|
||||
- Added support to start and affinitize TBB worker threads by passing
|
||||
"`start_threads=1,set_affinity=1`" to `rtcNewDevice`. These settings
|
||||
"start_threads=1,set_affinity=1" to rtcNewDevice. These settings
|
||||
are recommended on systems with a high thread count.
|
||||
- `rtcInterpolate2` can now be called within a displacement shader.
|
||||
- Added initial support for Microsoft's Parallel Pattern Library (PPL)
|
||||
as tasking system alternative (for optimal performance TBB is
|
||||
highly recommended).
|
||||
- Updated to TBB 2017 which is released under the Apache v2.0 license.
|
||||
- Dropped support for Visual Studio 2012 Win32 compiler. Visual Studio
|
||||
2012 x64 is still supported.
|
||||
- rtcInterpolate2 can now be called within a displacement shader.
|
||||
- Added initial support for Microsoft's Parallel Pattern Library (PPL) as
|
||||
tasking system alternative (for optimial performance TBB is highly recommended).
|
||||
- Updated to TBB 2017 which is released under the Apache v2.0
|
||||
license.
|
||||
- Dropped support for Visual Studio 2012 Win32 compiler. Visual
|
||||
Studio 2012 x64 is still supported.
|
||||
|
||||
### New Features in Embree 2.11.0
|
||||
|
||||
- Improved performance for streams of coherent (single) rays flagged
|
||||
with `RTC_INTERSECT_COHERENT`. For such coherent ray streams, e.g.
|
||||
primary rays, the performance typically improves by 1.3-2×.
|
||||
- New spatial split BVH builder for triangles, which is 2-6× faster
|
||||
primary rays, the performance typically improves by 1.3–2×.
|
||||
- New spatial split BVH builder for triangles, which is 2–6× faster
|
||||
than the previous version and more memory conservative.
|
||||
- Improved performance and scalability of all standard BVH builders on
|
||||
systems with large core counts.
|
||||
- Fixed `rtcGetBounds` for motion blur scenes.
|
||||
- Thread affinity is now on by default when running on the latest
|
||||
Intel® Xeon Phi™ processor.
|
||||
- Added AVX-512 support for future Intel® Xeon processors.
|
||||
- Added AVX512 support for future Intel® Xeon processors.
|
||||
|
||||
### New Features in Embree 2.10.0
|
||||
|
||||
@@ -220,12 +51,12 @@ Version History
|
||||
- Geometry types can get disabled at compile time.
|
||||
- Modified and extended the ray stream API.
|
||||
- Added new callback mechanism for the ray stream API.
|
||||
- Improved ray stream performance (up to 5-10%).
|
||||
- Improved ray stream performance (up to 5–10%).
|
||||
- Up to 20% faster morton builder on machines with large core counts.
|
||||
- Lots of optimizations for the second generation Intel® Xeon Phi™
|
||||
processor codenamed Knights Landing.
|
||||
- Added experimental support for compressed BVH nodes (reduces node
|
||||
size to 56-62% of uncompressed size). Compression introduces a
|
||||
size to 56–62% of uncompressed size). Compression introduces a
|
||||
typical performance overhead of ~10%.
|
||||
- Bugfix in backface culling mode. We do now properly cull the
|
||||
backfaces and not the frontfaces.
|
||||
@@ -236,8 +67,8 @@ Version History
|
||||
|
||||
### New Features in Embree 2.9.0
|
||||
|
||||
- Improved shadow ray performance (10-100% depending on the scene).
|
||||
- Added initial support for ray streams (10-30% higher performance
|
||||
- Improved shadow ray performance (10–100% depending on the scene).
|
||||
- Added initial support for ray streams (10–30% higher performance
|
||||
depending on ray coherence in the stream).
|
||||
- Added support to calculate second order derivatives using the
|
||||
`rtcInterpolate2` function.
|
||||
@@ -257,30 +88,27 @@ Version History
|
||||
- Added support for line segment geometry.
|
||||
- Added support for quad geometry (replaces triangle-pairs feature).
|
||||
- Added support for linear motion blur of user geometries.
|
||||
- Improved performance through AVX-512 optimizations.
|
||||
- Improved performance of lazy scene build (when using TBB 4.4 update
|
||||
2).
|
||||
- Improved performance through AVX512 optimizations.
|
||||
- Improved performance of lazy scene build (when using TBB 4.4 update 2).
|
||||
- Improved performance through huge page support under linux.
|
||||
|
||||
### New Features in Embree 2.7.1
|
||||
|
||||
- Internal tasking system supports cancellation of build operations.
|
||||
- ISPC mode for robust and compact scenes got significantly faster
|
||||
(implemented hybrid traversal for bvh4.triangle4v and
|
||||
bvh4.triangle4i).
|
||||
(implemented hybrid traversal for bvh4.triangle4v and bvh4.triangle4i).
|
||||
- Hair rendering got faster as we fixed some issues with the SAH
|
||||
heuristic cost factors.
|
||||
- BVH8 got slight faster for single ray traversal (improved sorting
|
||||
when hitting more than 4 boxes).
|
||||
- BVH build performance got up to 30% faster on CPUs with high core
|
||||
counts (improved parallel partition code).
|
||||
- High quality build mode again working properly (spatial splits had
|
||||
been deactivated in v2.7.0 due to some bug).
|
||||
- High quality build mode again working properly (spatial splits had been
|
||||
deactivated in v2.7.0 due to some bug).
|
||||
- Support for merging two adjacent triangles sharing a common edge
|
||||
into a triangle-pair primitive (can reduce memory consumption and
|
||||
BVH build times by up to 50% for mostly quad-based input meshes).
|
||||
- Internal cleanups (reduced number of traversal kernels by more
|
||||
templating).
|
||||
- Internal cleanups (reduced number of traversal kernels by more templating)
|
||||
- Reduced stack size requirements of BVH builders.
|
||||
- Fixed crash for dynamic scenes, triggered by deleting all
|
||||
geometries from the scene.
|
||||
@@ -308,7 +136,7 @@ Version History
|
||||
- Reduced virtual address space usage for static geometries.
|
||||
- Fixed some AVX2 code paths when compiling with GCC or Clang.
|
||||
- Bugfix for subdiv patches with non-matching winding order.
|
||||
- Bugfix in ISA detection of AVX-512.
|
||||
- Bugfix in ISA detection of AVX512.
|
||||
|
||||
### New Features in Embree 2.6.1
|
||||
|
||||
@@ -316,7 +144,7 @@ Version History
|
||||
e.g. up to 2× faster for scenes where only the tessellation levels
|
||||
are changing per frame, and up to 3× faster for scenes with lots of
|
||||
crease features
|
||||
- Initial support for architectures supporting the new 16-wide AVX-512
|
||||
- Initial support for architectures supporting the new 16-wide AVX512
|
||||
ISA
|
||||
- Implemented intersection filter callback support for subdivision
|
||||
surfaces
|
||||
@@ -450,6 +278,29 @@ Version History
|
||||
- New variant of the SAH-based builder using triangle pre-splits
|
||||
(Xeon Phi)
|
||||
|
||||
### Example Performance Numbers for Embree 2.1
|
||||
|
||||
BVH rebuild performance (including triangle accel generation, excluding
|
||||
memory allocation) for scenes with 2–12 million triangles:
|
||||
|
||||
- Intel® Core™ i7 (Haswell-based CPU, 4 cores @ 3.0 GHz)
|
||||
- 7–8 million triangles/s for the SAH-based BVH builder
|
||||
- 30–36 million triangles/s for the Morton code-based BVH builder
|
||||
- Intel® Xeon Phi™ 7120
|
||||
- 37–40 million triangles/s for the SAH-based BVH builder
|
||||
- 140–160 million triangles/s for the Morton code-based BVH
|
||||
builder
|
||||
|
||||
Rendering of the Crown model (`crown.ecs`) with 4 samples per pixel
|
||||
(`-spp 4`):
|
||||
|
||||
- Intel® Core™ i7 (Haswell-based CPU, 4 cores CPU @ 3.0 GHz)
|
||||
- 1024×1024 resolution: 7.8 million rays per sec
|
||||
- 1920×1080 resolution: 9.9 million rays per sec
|
||||
- Intel® Xeon Phi™ 7120
|
||||
- 1024×1024 resolution: 47.1 million rays per sec
|
||||
- 1920×1080 resolution: 61.1 million rays per sec
|
||||
|
||||
### New Features in Embree 2.0
|
||||
|
||||
- Support for the Intel® Xeon Phi™ coprocessor platform
|
||||
|
||||
+105
-170
@@ -1,5 +1,5 @@
|
||||
## ======================================================================== ##
|
||||
## Copyright 2009-2017 Intel Corporation ##
|
||||
## Copyright 2009-2016 Intel Corporation ##
|
||||
## ##
|
||||
## Licensed under the Apache License, Version 2.0 (the "License"); ##
|
||||
## you may not use this file except in compliance with the License. ##
|
||||
@@ -15,9 +15,9 @@
|
||||
## ======================================================================== ##
|
||||
|
||||
SET(EMBREE_VERSION_MAJOR 2)
|
||||
SET(EMBREE_VERSION_MINOR 17)
|
||||
SET(EMBREE_VERSION_MINOR 13)
|
||||
SET(EMBREE_VERSION_PATCH 0)
|
||||
SET(EMBREE_VERSION_NOTE "-alpha.0")
|
||||
SET(EMBREE_VERSION_NOTE "-apha.0")
|
||||
SET(EMBREE_VERSION ${EMBREE_VERSION_MAJOR}.${EMBREE_VERSION_MINOR}.${EMBREE_VERSION_PATCH})
|
||||
MATH(EXPR EMBREE_VERSION_NUMBER "10000*${EMBREE_VERSION_MAJOR} + 100*${EMBREE_VERSION_MINOR} + ${EMBREE_VERSION_PATCH}")
|
||||
SET(CPACK_RPM_PACKAGE_RELEASE 1)
|
||||
@@ -42,12 +42,8 @@ IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git)
|
||||
ENDIF()
|
||||
|
||||
CONFIGURE_FILE(
|
||||
"${PROJECT_SOURCE_DIR}/kernels/rtcore_version.h.in"
|
||||
"${PROJECT_SOURCE_DIR}/include/embree2/rtcore_version.h"
|
||||
)
|
||||
CONFIGURE_FILE(
|
||||
"${PROJECT_SOURCE_DIR}/kernels/hash.h.in"
|
||||
"${PROJECT_BINARY_DIR}/hash.h"
|
||||
"${PROJECT_SOURCE_DIR}/kernels/version.h.in"
|
||||
"${PROJECT_BINARY_DIR}/version.h"
|
||||
)
|
||||
FILE(WRITE "${PROJECT_BINARY_DIR}/hash" "${EMBREE_HASH}")
|
||||
|
||||
@@ -78,14 +74,7 @@ INCLUDE(test)
|
||||
# Embree configuration
|
||||
##############################################################
|
||||
|
||||
GET_PROPERTY(SHARED_LIBS_SUPPORTED GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS)
|
||||
IF(SHARED_LIBS_SUPPORTED)
|
||||
OPTION(EMBREE_STATIC_LIB "Build Embree as a static library.")
|
||||
MARK_AS_ADVANCED(CLEAR EMBREE_STATIC_LIB)
|
||||
ELSE()
|
||||
SET(EMBREE_STATIC_LIB ON CACHE BOOL "Build Embree as a static library." FORCE)
|
||||
MARK_AS_ADVANCED(EMBREE_STATIC_LIB)
|
||||
ENDIF()
|
||||
OPTION(EMBREE_STATIC_LIB "Build Embree as a static library." OFF)
|
||||
IF (EMBREE_STATIC_LIB)
|
||||
SET(EMBREE_LIB_TYPE STATIC)
|
||||
ADD_DEFINITIONS(-DEMBREE_STATIC_LIB)
|
||||
@@ -100,7 +89,6 @@ OPTION(EMBREE_TUTORIALS "Enable to build Embree tutorials" ON)
|
||||
# Configurations (add configurations also to common/cmake/embree-config-default.cmake)
|
||||
|
||||
OPTION(EMBREE_STAT_COUNTERS "Enables statistic counters.")
|
||||
OPTION(EMBREE_STACK_PROTECTOR "When enabled Embree compiles with stack protection against return address overrides." OFF)
|
||||
|
||||
OPTION(EMBREE_RAY_MASK "Enables ray mask support.")
|
||||
OPTION(EMBREE_BACKFACE_CULLING "Enables backface culling.")
|
||||
@@ -116,39 +104,24 @@ OPTION(EMBREE_GEOMETRY_SUBDIV "Enables support for subdiv geometries." ON)
|
||||
OPTION(EMBREE_GEOMETRY_USER "Enables support for user geometries." ON)
|
||||
OPTION(EMBREE_RAY_PACKETS "Enabled support for ray packets." ON)
|
||||
|
||||
SET(EMBREE_NATIVE_SPLINE_BASIS BEZIER CACHE STRING "Sets the basis for curves which Embree uses internally. Other types are converted and need more memory.")
|
||||
SET_PROPERTY(CACHE EMBREE_NATIVE_SPLINE_BASIS PROPERTY STRINGS BSPLINE BEZIER)
|
||||
IF (EMBREE_NATIVE_SPLINE_BASIS STREQUAL "BSPLINE")
|
||||
SET(EMBREE_NATIVE_CURVE_BSPLINE ON)
|
||||
ELSE()
|
||||
SET(EMBREE_NATIVE_CURVE_BSPLINE OFF)
|
||||
ENDIF()
|
||||
|
||||
SET(EMBREE_TASKING_SYSTEM "TBB" CACHE STRING "Selects tasking system")
|
||||
IF (WIN32)
|
||||
SET_PROPERTY(CACHE EMBREE_TASKING_SYSTEM PROPERTY STRINGS TBB INTERNAL PPL)
|
||||
ELSE()
|
||||
SET_PROPERTY(CACHE EMBREE_TASKING_SYSTEM PROPERTY STRINGS TBB INTERNAL)
|
||||
ENDIF()
|
||||
SET_PROPERTY(CACHE EMBREE_TASKING_SYSTEM PROPERTY STRINGS TBB INTERNAL PPL)
|
||||
|
||||
IF (EMBREE_TASKING_SYSTEM STREQUAL "TBB")
|
||||
SET(TASKING_TBB ON )
|
||||
SET(TASKING_INTERNAL OFF)
|
||||
SET(TASKING_PPL OFF )
|
||||
ADD_DEFINITIONS(-DTASKING_TBB)
|
||||
LIST(APPEND ISPC_DEFINITIONS -DTASKING_TBB)
|
||||
ELSEIF (EMBREE_TASKING_SYSTEM STREQUAL "PPL")
|
||||
SET(TASKING_PPL ON )
|
||||
SET(TASKING_TBB OFF )
|
||||
SET(TASKING_INTERNAL OFF)
|
||||
ADD_DEFINITIONS(-DTASKING_PPL)
|
||||
LIST(APPEND ISPC_DEFINITIONS -DTASKING_PPL)
|
||||
ELSE()
|
||||
SET(TASKING_INTERNAL ON )
|
||||
SET(TASKING_TBB OFF)
|
||||
SET(TASKING_PPL OFF )
|
||||
ADD_DEFINITIONS(-DTASKING_INTERNAL)
|
||||
LIST(APPEND ISPC_DEFINITIONS -DTASKING_INTERNAL)
|
||||
ENDIF()
|
||||
|
||||
CONFIGURE_FILE(
|
||||
@@ -157,81 +130,9 @@ CONFIGURE_FILE(
|
||||
)
|
||||
|
||||
##############################################################
|
||||
# ISA configuration
|
||||
# Create Binary Packages (uses above config options)
|
||||
##############################################################
|
||||
|
||||
IF(CMAKE_CXX_COMPILER_WRAPPER STREQUAL "CrayPrgEnv")
|
||||
SET(EMBREE_MAX_ISA "NONE" CACHE STRING "Selects highest ISA to support.")
|
||||
ELSE()
|
||||
SET(EMBREE_MAX_ISA "AVX2" CACHE STRING "Selects highest ISA to support.")
|
||||
ENDIF()
|
||||
SET_PROPERTY(CACHE EMBREE_MAX_ISA PROPERTY STRINGS NONE SSE2 SSE4.2 AVX AVX2 AVX512KNL AVX512SKX)
|
||||
|
||||
IF (EMBREE_MAX_ISA STREQUAL "NONE")
|
||||
OPTION(EMBREE_ISA_SSE2 "Enables SSE2 ISA.")
|
||||
OPTION(EMBREE_ISA_SSE42 "Enables SSE4.2 ISA.")
|
||||
OPTION(EMBREE_ISA_AVX "Enables AVX ISA.")
|
||||
OPTION(EMBREE_ISA_AVX2 "Enables AVX2 ISA.")
|
||||
OPTION(EMBREE_ISA_AVX512KNL "Enables AVX512 ISA for Knights Landing.")
|
||||
OPTION(EMBREE_ISA_AVX512SKX "Enables AVX512 ISA for Skylake.")
|
||||
IF(NOT (EMBREE_ISA_SSE2 OR EMBREE_ISA_SSE42 OR EMBREE_ISA_AVX OR
|
||||
EMBREE_ISA_AVX2 OR EMBREE_ISA_AVX512KNL OR EMBREE_ISA_AVX512SKX))
|
||||
MESSAGE(STATUS "Detecting default ISA:")
|
||||
INCLUDE(check_isa_default)
|
||||
CHECK_ISA_DEFAULT(EMBREE_ISA_DEFAULT)
|
||||
MESSAGE(STATUS "Detecting default ISA: ${EMBREE_ISA_DEFAULT}")
|
||||
SET(EMBREE_ISA_${EMBREE_ISA_DEFAULT} ON)
|
||||
ENDIF()
|
||||
ELSE()
|
||||
UNSET(EMBREE_ISA_SSE2 CACHE)
|
||||
UNSET(EMBREE_ISA_SSE42 CACHE)
|
||||
UNSET(EMBREE_ISA_AVX CACHE)
|
||||
UNSET(EMBREE_ISA_AVX2 CACHE)
|
||||
UNSET(EMBREE_ISA_AVX512KNL CACHE)
|
||||
UNSET(EMBREE_ISA_AVX512SKX CACHE)
|
||||
|
||||
IF(EMBREE_MAX_ISA STREQUAL "SSE2")
|
||||
SET(ISA 1)
|
||||
ELSEIF(EMBREE_MAX_ISA STREQUAL "SSE4.2")
|
||||
SET(ISA 2)
|
||||
ELSEIF(EMBREE_MAX_ISA STREQUAL "AVX")
|
||||
SET(ISA 3)
|
||||
ELSEIF(EMBREE_MAX_ISA STREQUAL "AVX2")
|
||||
SET(ISA 4)
|
||||
ELSEIF(EMBREE_MAX_ISA STREQUAL "AVX512KNL")
|
||||
SET(ISA 5)
|
||||
ELSEIF(EMBREE_MAX_ISA STREQUAL "AVX512SKX")
|
||||
SET(ISA 6)
|
||||
ELSE()
|
||||
MESSAGE(FATAL_ERROR "Unsupported ISA specified: " ${EMBREE_MAX_ISA})
|
||||
ENDIF()
|
||||
|
||||
SET(EMBREE_ISA_SSE2 OFF)
|
||||
SET(EMBREE_ISA_SSE42 OFF)
|
||||
SET(EMBREE_ISA_AVX OFF)
|
||||
SET(EMBREE_ISA_AVX2 OFF)
|
||||
SET(EMBREE_ISA_AVX512KNL OFF)
|
||||
SET(EMBREE_ISA_AVX512SKX OFF)
|
||||
|
||||
IF (ISA GREATER 0)
|
||||
SET(EMBREE_ISA_SSE2 ON)
|
||||
ENDIF ()
|
||||
IF (ISA GREATER 1)
|
||||
SET(EMBREE_ISA_SSE42 ON)
|
||||
ENDIF ()
|
||||
IF (ISA GREATER 2)
|
||||
SET(EMBREE_ISA_AVX ON)
|
||||
ENDIF ()
|
||||
IF (ISA GREATER 3)
|
||||
SET(EMBREE_ISA_AVX2 ON)
|
||||
ENDIF ()
|
||||
IF (ISA GREATER 4)
|
||||
SET(EMBREE_ISA_AVX512KNL ON)
|
||||
ENDIF ()
|
||||
IF (ISA GREATER 5)
|
||||
SET(EMBREE_ISA_AVX512SKX ON)
|
||||
ENDIF ()
|
||||
ENDIF()
|
||||
include(package)
|
||||
|
||||
##############################################################
|
||||
# Compiler
|
||||
@@ -247,22 +148,13 @@ IF (WIN32)
|
||||
SET_PROPERTY(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||
|
||||
IF (${CMAKE_GENERATOR_TOOLSET} MATCHES "^LLVM" )
|
||||
MESSAGE("CLANG detected")
|
||||
INCLUDE(clang)
|
||||
ELSEIF(${CMAKE_GENERATOR_TOOLSET} MATCHES "^Intel")
|
||||
MESSAGE("Intel Compiler detected")
|
||||
INCLUDE (icc)
|
||||
ELSE()
|
||||
IF (EMBREE_ISA_AVX512KNL OR EMBREE_ISA_AVX512SKX)
|
||||
MESSAGE(FATAL_ERROR "Microsoft Visual C++ Compiler does not support AVX512. Please use Intel Compiler or Clang.")
|
||||
ENDIF()
|
||||
INCLUDE (msvc)
|
||||
ENDIF()
|
||||
|
||||
ELSE (WIN32)
|
||||
IF(CMAKE_CXX_COMPILER_WRAPPER STREQUAL "CrayPrgEnv")
|
||||
INCLUDE(crayprgenv)
|
||||
ELSEIF (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
|
||||
IF (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
|
||||
INCLUDE (gcc)
|
||||
ELSEIF (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
|
||||
INCLUDE (clang)
|
||||
@@ -283,79 +175,122 @@ ELSE (WIN32)
|
||||
ENDIF (WIN32)
|
||||
|
||||
##############################################################
|
||||
# ISA configuration continued
|
||||
# ISA configuration
|
||||
##############################################################
|
||||
|
||||
SET(SSE2 0)
|
||||
SET(SSE42 1)
|
||||
SET(AVX 2)
|
||||
SET(AVX2 3)
|
||||
SET(AVX512KNL 4)
|
||||
SET(AVX512SKX 5)
|
||||
IF(APPLE)
|
||||
SET(EMBREE_MAX_ISA "AVX2" CACHE STRING "Selects highest ISA to support.")
|
||||
ELSEIF(NOT COMPILER STREQUAL "ICC")
|
||||
SET(EMBREE_MAX_ISA "AVX2" CACHE STRING "Selects highest ISA to support.")
|
||||
ELSE()
|
||||
SET(EMBREE_MAX_ISA "AVX512SKX" CACHE STRING "Selects highest ISA to support.")
|
||||
ENDIF ()
|
||||
|
||||
UNSET(FLAGS_LOWEST)
|
||||
SET_PROPERTY(CACHE EMBREE_MAX_ISA PROPERTY STRINGS SSE2 SSE3 SSSE3 SSE4.1 SSE4.2 AVX AVX-I AVX2 AVX512KNL AVX512SKX)
|
||||
|
||||
IF (EMBREE_ISA_SSE2)
|
||||
ADD_DEFINITIONS(-DEMBREE_TARGET_SSE2)
|
||||
LIST(APPEND ISPC_TARGETS "sse2")
|
||||
IF(NOT FLAGS_LOWEST)
|
||||
SET(ISA_LOWEST ${SSE2})
|
||||
SET(FLAGS_LOWEST ${FLAGS_SSE2})
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
IF (EMBREE_MAX_ISA STREQUAL "SSE2")
|
||||
SET(ISA 1)
|
||||
ENDIF ()
|
||||
|
||||
IF (EMBREE_ISA_SSE42)
|
||||
ADD_DEFINITIONS(-DEMBREE_TARGET_SSE42)
|
||||
IF (EMBREE_MAX_ISA STREQUAL "SSE3")
|
||||
SET(ISA 2)
|
||||
ENDIF ()
|
||||
|
||||
IF (EMBREE_MAX_ISA STREQUAL "SSSE3")
|
||||
SET(ISA 3)
|
||||
ENDIF ()
|
||||
|
||||
IF (EMBREE_MAX_ISA STREQUAL "SSE4.1")
|
||||
SET(ISA 4)
|
||||
ENDIF ()
|
||||
|
||||
IF (EMBREE_MAX_ISA STREQUAL "SSE4.2")
|
||||
SET(ISA 5)
|
||||
ENDIF ()
|
||||
|
||||
IF (EMBREE_MAX_ISA STREQUAL "AVX")
|
||||
SET(ISA 6)
|
||||
ENDIF ()
|
||||
|
||||
IF (EMBREE_MAX_ISA STREQUAL "AVX-I")
|
||||
SET(ISA 7)
|
||||
ENDIF ()
|
||||
|
||||
IF (EMBREE_MAX_ISA STREQUAL "AVX2")
|
||||
SET(ISA 8)
|
||||
ENDIF ()
|
||||
|
||||
IF (EMBREE_MAX_ISA STREQUAL "AVX512KNL")
|
||||
SET(ISA 9)
|
||||
ENDIF ()
|
||||
|
||||
IF (EMBREE_MAX_ISA STREQUAL "AVX512SKX")
|
||||
SET(ISA 10)
|
||||
ENDIF ()
|
||||
|
||||
SET(TARGET_SSE2 OFF)
|
||||
SET(TARGET_SSE3 OFF)
|
||||
SET(TARGET_SSSE3 OFF)
|
||||
SET(TARGET_SSE41 OFF)
|
||||
SET(TARGET_SSE42 OFF)
|
||||
SET(TARGET_AVX OFF)
|
||||
SET(TARGET_AVX2 OFF)
|
||||
SET(TARGET_AVX512KNL OFF)
|
||||
SET(TARGET_AVX512SKX OFF)
|
||||
|
||||
IF (ISA GREATER 0)
|
||||
SET(TARGET_SSE2 ON)
|
||||
SET(ISPC_TARGETS "sse2")
|
||||
ADD_DEFINITIONS(-D__TARGET_SSE2__)
|
||||
ENDIF ()
|
||||
|
||||
IF (ISA GREATER 1)
|
||||
SET(TARGET_SSE3 ON)
|
||||
ADD_DEFINITIONS(-D__TARGET_SSE3__)
|
||||
ENDIF ()
|
||||
|
||||
IF (ISA GREATER 2)
|
||||
SET(TARGET_SSSE3 ON)
|
||||
ADD_DEFINITIONS(-D__TARGET_SSSE3__)
|
||||
ENDIF ()
|
||||
|
||||
IF (ISA GREATER 3)
|
||||
SET(TARGET_SSE41 ON)
|
||||
ADD_DEFINITIONS(-D__TARGET_SSE41__)
|
||||
LIST(APPEND ISPC_TARGETS "sse4")
|
||||
IF(NOT FLAGS_LOWEST)
|
||||
SET(ISA_LOWEST ${SSE42})
|
||||
SET(FLAGS_LOWEST ${FLAGS_SSE42})
|
||||
ENDIF()
|
||||
ENDIF ()
|
||||
|
||||
IF (EMBREE_ISA_AVX)
|
||||
ADD_DEFINITIONS(-DEMBREE_TARGET_AVX)
|
||||
IF (ISA GREATER 4)
|
||||
SET(TARGET_SSE42 ON)
|
||||
ADD_DEFINITIONS(-D__TARGET_SSE42__)
|
||||
ENDIF ()
|
||||
|
||||
IF (ISA GREATER 5)
|
||||
SET(TARGET_AVX ON)
|
||||
ADD_DEFINITIONS(-D__TARGET_AVX__)
|
||||
LIST(APPEND ISPC_TARGETS "avx")
|
||||
IF(NOT FLAGS_LOWEST)
|
||||
SET(ISA_LOWEST ${AVX})
|
||||
SET(FLAGS_LOWEST ${FLAGS_AVX})
|
||||
ENDIF()
|
||||
ENDIF ()
|
||||
|
||||
IF (EMBREE_ISA_AVX2)
|
||||
ADD_DEFINITIONS(-DEMBREE_TARGET_AVX2)
|
||||
IF (ISA GREATER 7)
|
||||
SET(TARGET_AVX2 ON)
|
||||
ADD_DEFINITIONS(-D__TARGET_AVX2__)
|
||||
LIST(APPEND ISPC_TARGETS "avx2")
|
||||
IF(NOT FLAGS_LOWEST)
|
||||
SET(ISA_LOWEST ${AVX2})
|
||||
SET(FLAGS_LOWEST ${FLAGS_AVX2})
|
||||
ENDIF()
|
||||
ENDIF ()
|
||||
|
||||
IF (EMBREE_ISA_AVX512KNL)
|
||||
ADD_DEFINITIONS(-DEMBREE_TARGET_AVX512KNL)
|
||||
IF (ISA GREATER 8)
|
||||
SET(TARGET_AVX512KNL ON)
|
||||
ADD_DEFINITIONS(-D__TARGET_AVX512KNL__)
|
||||
LIST(APPEND ISPC_TARGETS "avx512knl-i32x16")
|
||||
IF(NOT FLAGS_LOWEST)
|
||||
SET(ISA_LOWEST ${AVX512KNL})
|
||||
SET(FLAGS_LOWEST ${FLAGS_AVX512KNL})
|
||||
ENDIF()
|
||||
ENDIF ()
|
||||
|
||||
IF (EMBREE_ISA_AVX512SKX)
|
||||
ADD_DEFINITIONS(-DEMBREE_TARGET_AVX512SKX)
|
||||
IF (ISA GREATER 9)
|
||||
SET(TARGET_AVX512SKX ON)
|
||||
ADD_DEFINITIONS(-D__TARGET_AVX512SKX__)
|
||||
LIST(APPEND ISPC_TARGETS "avx512skx-i32x16")
|
||||
IF(NOT FLAGS_LOWEST)
|
||||
SET(ISA_LOWEST ${AVX512SKX})
|
||||
SET(FLAGS_LOWEST ${FLAGS_AVX512SKX})
|
||||
ENDIF()
|
||||
ENDIF ()
|
||||
|
||||
INCLUDE (ispc)
|
||||
|
||||
##############################################################
|
||||
# Create Binary Packages (uses above config options)
|
||||
##############################################################
|
||||
include(package)
|
||||
|
||||
##############################################################
|
||||
# Search paths
|
||||
##############################################################
|
||||
@@ -398,7 +333,7 @@ add_custom_target(uninstall
|
||||
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/uninstall.cmake)
|
||||
|
||||
SET_PROPERTY(TARGET uninstall PROPERTY FOLDER CMakePredefinedTargets)
|
||||
|
||||
|
||||
##############################################################
|
||||
# Has to be last
|
||||
##############################################################
|
||||
|
||||
+3
-6
@@ -1,5 +1,5 @@
|
||||
## ======================================================================== ##
|
||||
## Copyright 2009-2017 Intel Corporation ##
|
||||
## Copyright 2009-2016 Intel Corporation ##
|
||||
## ##
|
||||
## Licensed under the Apache License, Version 2.0 (the "License"); ##
|
||||
## you may not use this file except in compliance with the License. ##
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
set(CTEST_PROJECT_NAME "Embree")
|
||||
set(CTEST_NIGHTLY_START_TIME "22:00:00 UTC")
|
||||
set(TEST_MODELS_HASH 01ada7ec1ace15ddba73aaab3f53ac6aac6a0309)
|
||||
set(TEST_MODELS_HASH 99ec031b11b08afec271357e4cb9326cf8ac9942)
|
||||
|
||||
IF (NOT CTEST_DROP_SITE)
|
||||
set(CTEST_DROP_METHOD "http")
|
||||
@@ -26,8 +26,5 @@ IF (NOT CTEST_DROP_SITE)
|
||||
endif()
|
||||
|
||||
list (APPEND CTEST_CUSTOM_WARNING_EXCEPTION "warning #1478") # deprecated function used
|
||||
#list (APPEND CTEST_CUSTOM_WARNING_EXCEPTION "warning #10237") # -lcilkrts linked in dynamically, static library not available")
|
||||
list (APPEND CTEST_CUSTOM_WARNING_EXCEPTION "warning #10237") # -lcilkrts linked in dynamically, static library not available")
|
||||
list (APPEND CTEST_CUSTOM_WARNING_EXCEPTION "-Wextern-initializer")
|
||||
|
||||
SET(CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE 200000)
|
||||
SET(CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE 800000)
|
||||
@@ -1,5 +1,5 @@
|
||||
## ======================================================================== ##
|
||||
## Copyright 2009-2017 Intel Corporation ##
|
||||
## Copyright 2009-2016 Intel Corporation ##
|
||||
## ##
|
||||
## Licensed under the Apache License, Version 2.0 (the "License"); ##
|
||||
## you may not use this file except in compliance with the License. ##
|
||||
@@ -15,7 +15,6 @@
|
||||
## ======================================================================== ##
|
||||
|
||||
ADD_SUBDIRECTORY(sys)
|
||||
ADD_SUBDIRECTORY(math)
|
||||
ADD_SUBDIRECTORY(simd)
|
||||
ADD_SUBDIRECTORY(lexers)
|
||||
ADD_SUBDIRECTORY(tasking)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
## ======================================================================== ##
|
||||
## Copyright 2009-2017 Intel Corporation ##
|
||||
## Copyright 2009-2016 Intel Corporation ##
|
||||
## ##
|
||||
## Licensed under the Apache License, Version 2.0 (the "License"); ##
|
||||
## you may not use this file except in compliance with the License. ##
|
||||
@@ -24,7 +24,6 @@ ADD_LIBRARY(algorithms OBJECT
|
||||
parallel_sort.cpp
|
||||
parallel_set.cpp
|
||||
parallel_map.cpp
|
||||
parallel_filter.cpp
|
||||
)
|
||||
|
||||
SET_PROPERTY(TARGET algorithms PROPERTY FOLDER common)
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
// ======================================================================== //
|
||||
// Copyright 2009-2017 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
// You may obtain a copy of the License at //
|
||||
// //
|
||||
// http://www.apache.org/licenses/LICENSE-2.0 //
|
||||
// //
|
||||
// Unless required by applicable law or agreed to in writing, software //
|
||||
// distributed under the License is distributed on an "AS IS" BASIS, //
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. //
|
||||
// See the License for the specific language governing permissions and //
|
||||
// limitations under the License. //
|
||||
// ======================================================================== //
|
||||
|
||||
#include "parallel_filter.h"
|
||||
#include "../sys/regression.h"
|
||||
#include <map>
|
||||
|
||||
namespace embree
|
||||
{
|
||||
struct parallel_filter_regression_test : public RegressionTest
|
||||
{
|
||||
parallel_filter_regression_test(const char* name) : RegressionTest(name) {
|
||||
registerRegressionTest(this);
|
||||
}
|
||||
|
||||
bool run ()
|
||||
{
|
||||
bool passed = true;
|
||||
auto pred = [&]( uint32_t v ) { return (v & 0x3) == 0; };
|
||||
|
||||
for (size_t N=10; N<1000000; N=size_t(2.1*N))
|
||||
{
|
||||
/* initialize array with random numbers */
|
||||
std::vector<uint32_t> src(N);
|
||||
std::map<uint32_t,int> m;
|
||||
for (size_t i=0; i<N; i++) src[i] = rand();
|
||||
|
||||
/* count elements up */
|
||||
for (size_t i=0; i<N; i++)
|
||||
if (pred(src[i]))
|
||||
m[src[i]] = 0;
|
||||
for (size_t i=0; i<N; i++)
|
||||
if (pred(src[i]))
|
||||
m[src[i]]++;
|
||||
|
||||
/* filter array */
|
||||
//size_t_t M = sequential_filter(src.data(),size_t(0),N,pred);
|
||||
size_t M = parallel_filter(src.data(),size_t(0),N,size_t(1024),pred);
|
||||
|
||||
/* check if filtered data is correct */
|
||||
for (size_t i=0; i<M; i++) {
|
||||
passed &= pred(src[i]);
|
||||
m[src[i]]--;
|
||||
}
|
||||
for (size_t i=0; i<M; i++)
|
||||
passed &= (m[src[i]] == 0);
|
||||
}
|
||||
|
||||
return passed;
|
||||
}
|
||||
};
|
||||
|
||||
parallel_filter_regression_test parallel_filter_regression("parallel_filter_regression");
|
||||
}
|
||||
@@ -1,103 +0,0 @@
|
||||
// ======================================================================== //
|
||||
// Copyright 2009-2017 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
// You may obtain a copy of the License at //
|
||||
// //
|
||||
// http://www.apache.org/licenses/LICENSE-2.0 //
|
||||
// //
|
||||
// Unless required by applicable law or agreed to in writing, software //
|
||||
// distributed under the License is distributed on an "AS IS" BASIS, //
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. //
|
||||
// See the License for the specific language governing permissions and //
|
||||
// limitations under the License. //
|
||||
// ======================================================================== //
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "parallel_for.h"
|
||||
|
||||
namespace embree
|
||||
{
|
||||
template<typename Ty, typename Index, typename Predicate>
|
||||
inline Index sequential_filter( Ty* data, const Index first, const Index last, const Predicate& predicate)
|
||||
{
|
||||
Index j = first;
|
||||
for (Index i=first; i<last; i++)
|
||||
if (predicate(data[i]))
|
||||
data[j++] = data[i];
|
||||
|
||||
return j;
|
||||
}
|
||||
|
||||
template<typename Ty, typename Index, typename Predicate>
|
||||
inline Index parallel_filter( Ty* data, const Index begin, const Index end, const Index minStepSize, const Predicate& predicate)
|
||||
{
|
||||
/* sequential fallback */
|
||||
if (end-begin <= minStepSize)
|
||||
return sequential_filter(data,begin,end,predicate);
|
||||
|
||||
/* calculate number of tasks to use */
|
||||
enum { MAX_TASKS = 512 };
|
||||
const Index numThreads = TaskScheduler::threadCount();
|
||||
const Index numBlocks = (end-begin+minStepSize-1)/minStepSize;
|
||||
const Index taskCount = min(numThreads,numBlocks,(Index)MAX_TASKS);
|
||||
|
||||
/* filter blocks */
|
||||
Index nused[MAX_TASKS];
|
||||
Index nfree[MAX_TASKS];
|
||||
parallel_for(taskCount, [&](const Index taskIndex)
|
||||
{
|
||||
const Index i0 = begin+(taskIndex+0)*(end-begin)/taskCount;
|
||||
const Index i1 = begin+(taskIndex+1)*(end-begin)/taskCount;
|
||||
const Index i2 = sequential_filter(data,i0,i1,predicate);
|
||||
nused[taskIndex] = i2-i0;
|
||||
nfree[taskIndex] = i1-i2;
|
||||
});
|
||||
|
||||
/* calculate offsets */
|
||||
Index sused=0;
|
||||
Index sfree=0;
|
||||
Index pfree[MAX_TASKS];
|
||||
for (Index i=0; i<taskCount; i++)
|
||||
{
|
||||
sused+=nused[i];
|
||||
Index cfree = nfree[i]; pfree[i] = sfree; sfree+=cfree;
|
||||
}
|
||||
|
||||
/* return if we did not filter out any element */
|
||||
assert(sfree <= end-begin);
|
||||
assert(sused <= end-begin);
|
||||
if (sused == end-begin)
|
||||
return end;
|
||||
|
||||
/* otherwise we have to copy misplaced elements around */
|
||||
parallel_for(taskCount, [&](const Index taskIndex)
|
||||
{
|
||||
/* destination to write elements to */
|
||||
Index dst = (taskIndex+0)*(end-begin)/taskCount+nused[taskIndex];
|
||||
Index dst_end = min(dst+nfree[taskIndex],sused);
|
||||
if (dst_end <= dst) return;
|
||||
|
||||
/* range of misplaced elements to copy to destination */
|
||||
Index r0 = pfree[taskIndex];
|
||||
Index r1 = r0+dst_end-dst;
|
||||
|
||||
/* find range in misplaced elements in back to front order */
|
||||
Index k0=0;
|
||||
for (Index i=taskCount-1; i>0; i--)
|
||||
{
|
||||
if (k0 > r1) break;
|
||||
Index k1 = k0+nused[i];
|
||||
Index src = begin+(i+0)*(end-begin)/taskCount+nused[i];
|
||||
for (Index i=max(r0,k0); i<min(r1,k1); i++) {
|
||||
data[dst++] = data[src-i+k0-1];
|
||||
}
|
||||
k0 = k1;
|
||||
}
|
||||
});
|
||||
|
||||
return begin+sused;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
// ======================================================================== //
|
||||
// Copyright 2009-2017 Intel Corporation //
|
||||
// Copyright 2009-2016 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ======================================================================== //
|
||||
// Copyright 2009-2017 Intel Corporation //
|
||||
// Copyright 2009-2016 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
@@ -71,7 +71,7 @@ namespace embree
|
||||
throw std::runtime_error("task cancelled");
|
||||
|
||||
#elif defined(TASKING_PPL)
|
||||
concurrency::parallel_for(first, last, Index(1) /*minStepSize*/, [&](Index i) {
|
||||
concurrency::parallel_for(first, last, minStepSize, [&](Index i) {
|
||||
func(range<Index>(i,i+1));
|
||||
});
|
||||
|
||||
@@ -87,47 +87,4 @@ namespace embree
|
||||
assert(first <= last);
|
||||
parallel_for(first,last,(Index)1,func);
|
||||
}
|
||||
|
||||
#if defined(TASKING_TBB) && (TBB_INTERFACE_VERSION > 4001)
|
||||
|
||||
template<typename Index, typename Func>
|
||||
__forceinline void parallel_for_static( const Index N, const Func& func)
|
||||
{
|
||||
tbb::parallel_for(Index(0),N,Index(1),[&](Index i) {
|
||||
func(i);
|
||||
},tbb::simple_partitioner());
|
||||
if (tbb::task::self().is_cancelled())
|
||||
throw std::runtime_error("task cancelled");
|
||||
}
|
||||
|
||||
typedef tbb::affinity_partitioner affinity_partitioner;
|
||||
|
||||
template<typename Index, typename Func>
|
||||
__forceinline void parallel_for_affinity( const Index N, const Func& func, tbb::affinity_partitioner& ap)
|
||||
{
|
||||
tbb::parallel_for(Index(0),N,Index(1),[&](Index i) {
|
||||
func(i);
|
||||
},ap);
|
||||
if (tbb::task::self().is_cancelled())
|
||||
throw std::runtime_error("task cancelled");
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
template<typename Index, typename Func>
|
||||
__forceinline void parallel_for_static( const Index N, const Func& func)
|
||||
{
|
||||
parallel_for(N,func);
|
||||
}
|
||||
|
||||
struct affinity_partitioner {
|
||||
};
|
||||
|
||||
template<typename Index, typename Func>
|
||||
__forceinline void parallel_for_affinity( const Index N, const Func& func, affinity_partitioner& ap)
|
||||
{
|
||||
parallel_for(N,func);
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
// ======================================================================== //
|
||||
// Copyright 2009-2017 Intel Corporation //
|
||||
// Copyright 2009-2016 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ======================================================================== //
|
||||
// Copyright 2009-2017 Intel Corporation //
|
||||
// Copyright 2009-2016 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
@@ -35,7 +35,7 @@ namespace embree
|
||||
{
|
||||
public:
|
||||
|
||||
enum { MAX_TASKS = 512 };
|
||||
enum { MAX_TASKS = MAX_THREADS };
|
||||
|
||||
__forceinline ParallelForForState ()
|
||||
: taskCount(0) {}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ======================================================================== //
|
||||
// Copyright 2009-2017 Intel Corporation //
|
||||
// Copyright 2009-2016 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
@@ -50,7 +50,7 @@ namespace embree
|
||||
ParallelForForPrefixSumState<size_t> state(array2,size_t(1));
|
||||
|
||||
/* dry run only counts */
|
||||
size_t S = parallel_for_for_prefix_sum0( state, array2, size_t(0), [&](std::vector<size_t>* v, const range<size_t>& r, size_t k) -> size_t
|
||||
size_t S = parallel_for_for_prefix_sum( state, array2, size_t(0), [&](std::vector<size_t>* v, const range<size_t>& r, size_t k, const size_t base) -> size_t
|
||||
{
|
||||
size_t s = 0;
|
||||
for (size_t i=r.begin(); i<r.end(); i++) {
|
||||
@@ -62,10 +62,10 @@ namespace embree
|
||||
|
||||
/* create properly sized output array */
|
||||
flattened.resize(S);
|
||||
for (auto& a : flattened) a.store(0);
|
||||
memset(flattened.data(),0,sizeof(atomic<size_t>)*S);
|
||||
|
||||
/* now we actually fill the flattened array */
|
||||
parallel_for_for_prefix_sum1( state, array2, size_t(0), [&](std::vector<size_t>* v, const range<size_t>& r, size_t k, const size_t base) -> size_t
|
||||
parallel_for_for_prefix_sum( state, array2, size_t(0), [&](std::vector<size_t>* v, const range<size_t>& r, size_t k, const size_t base) -> size_t
|
||||
{
|
||||
size_t s = 0;
|
||||
for (size_t i=r.begin(); i<r.end(); i++) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ======================================================================== //
|
||||
// Copyright 2009-2017 Intel Corporation //
|
||||
// Copyright 2009-2016 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
@@ -34,46 +34,8 @@ namespace embree
|
||||
};
|
||||
|
||||
template<typename ArrayArray, typename Index, typename Value, typename Func, typename Reduction>
|
||||
__forceinline Value parallel_for_for_prefix_sum0( ParallelForForPrefixSumState<Value>& state, ArrayArray& array2, Index minStepSize,
|
||||
const Value& identity, const Func& func, const Reduction& reduction)
|
||||
{
|
||||
/* calculate number of tasks to use */
|
||||
const size_t taskCount = state.taskCount;
|
||||
/* perform parallel prefix sum */
|
||||
parallel_for(taskCount, [&](const size_t taskIndex)
|
||||
{
|
||||
const size_t k0 = (taskIndex+0)*state.size()/taskCount;
|
||||
const size_t k1 = (taskIndex+1)*state.size()/taskCount;
|
||||
size_t i0 = state.i0[taskIndex];
|
||||
size_t j0 = state.j0[taskIndex];
|
||||
|
||||
/* iterate over arrays */
|
||||
size_t k=k0;
|
||||
Value N=identity;
|
||||
for (size_t i=i0; k<k1; i++) {
|
||||
const size_t size = array2[i] ? array2[i]->size() : 0;
|
||||
const size_t r0 = j0, r1 = min(size,r0+k1-k);
|
||||
if (r1 > r0) N = reduction(N, func(array2[i],range<size_t>(r0,r1),k));
|
||||
k+=r1-r0; j0 = 0;
|
||||
}
|
||||
state.prefix_state.counts[taskIndex] = N;
|
||||
});
|
||||
|
||||
/* calculate prefix sum */
|
||||
Value sum=identity;
|
||||
for (size_t i=0; i<taskCount; i++)
|
||||
{
|
||||
const Value c = state.prefix_state.counts[i];
|
||||
state.prefix_state.sums[i] = sum;
|
||||
sum=reduction(sum,c);
|
||||
}
|
||||
|
||||
return sum;
|
||||
}
|
||||
|
||||
template<typename ArrayArray, typename Index, typename Value, typename Func, typename Reduction>
|
||||
__forceinline Value parallel_for_for_prefix_sum1( ParallelForForPrefixSumState<Value>& state, ArrayArray& array2, Index minStepSize,
|
||||
const Value& identity, const Func& func, const Reduction& reduction)
|
||||
__forceinline Value parallel_for_for_prefix_sum( ParallelForForPrefixSumState<Value>& state, ArrayArray& array2, Index minStepSize,
|
||||
const Value& identity, const Func& func, const Reduction& reduction)
|
||||
{
|
||||
/* calculate number of tasks to use */
|
||||
const size_t taskCount = state.taskCount;
|
||||
@@ -109,17 +71,10 @@ namespace embree
|
||||
return sum;
|
||||
}
|
||||
|
||||
template<typename ArrayArray, typename Value, typename Func, typename Reduction>
|
||||
__forceinline Value parallel_for_for_prefix_sum0( ParallelForForPrefixSumState<Value>& state, ArrayArray& array2,
|
||||
template<typename ArrayArray, typename Value, typename Func, typename Reduction>
|
||||
__forceinline Value parallel_for_for_prefix_sum( ParallelForForPrefixSumState<Value>& state, ArrayArray& array2,
|
||||
const Value& identity, const Func& func, const Reduction& reduction)
|
||||
{
|
||||
return parallel_for_for_prefix_sum0(state,array2,size_t(1),identity,func,reduction);
|
||||
}
|
||||
|
||||
template<typename ArrayArray, typename Value, typename Func, typename Reduction>
|
||||
__forceinline Value parallel_for_for_prefix_sum1( ParallelForForPrefixSumState<Value>& state, ArrayArray& array2,
|
||||
const Value& identity, const Func& func, const Reduction& reduction)
|
||||
{
|
||||
return parallel_for_for_prefix_sum1(state,array2,size_t(1),identity,func,reduction);
|
||||
return parallel_for_for_prefix_sum(state,array2,size_t(1),identity,func,reduction);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
// ======================================================================== //
|
||||
// Copyright 2009-2017 Intel Corporation //
|
||||
// Copyright 2009-2016 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ======================================================================== //
|
||||
// Copyright 2009-2017 Intel Corporation //
|
||||
// Copyright 2009-2016 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ======================================================================== //
|
||||
// Copyright 2009-2017 Intel Corporation //
|
||||
// Copyright 2009-2016 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ======================================================================== //
|
||||
// Copyright 2009-2017 Intel Corporation //
|
||||
// Copyright 2009-2016 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
@@ -39,14 +39,18 @@ namespace embree
|
||||
/* *l < pivot */
|
||||
while (likely(l <= r && is_left(*l) ))
|
||||
{
|
||||
//prefetchw(l+4); // FIXME: enable?
|
||||
#if defined(__AVX512F__)
|
||||
prefetch<PFHINT_L1EX>(l+4);
|
||||
#endif
|
||||
reduction_t(leftReduction,*l);
|
||||
++l;
|
||||
}
|
||||
/* *r >= pivot) */
|
||||
while (likely(l <= r && !is_left(*r)))
|
||||
{
|
||||
//prefetchw(r-4); FIXME: enable?
|
||||
#if defined(__AVX512F__)
|
||||
prefetch<PFHINT_L1EX>(r-4);
|
||||
#endif
|
||||
reduction_t(rightReduction,*r);
|
||||
--r;
|
||||
}
|
||||
@@ -250,29 +254,4 @@ namespace embree
|
||||
return begin+p->partition(leftReduction,rightReduction);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T, typename V, typename Vi, typename IsLeft, typename Reduction_T, typename Reduction_V>
|
||||
__noinline size_t parallel_partitioning(T* array,
|
||||
const size_t begin,
|
||||
const size_t end,
|
||||
const Vi &identity,
|
||||
V &leftReduction,
|
||||
V &rightReduction,
|
||||
const IsLeft& is_left,
|
||||
const Reduction_T& reduction_t,
|
||||
const Reduction_V& reduction_v,
|
||||
size_t BLOCK_SIZE,
|
||||
size_t PARALLEL_THRESHOLD)
|
||||
{
|
||||
/* fall back to single threaded partitioning for small N */
|
||||
if (unlikely(end-begin < PARALLEL_THRESHOLD))
|
||||
return serial_partitioning(array,begin,end,leftReduction,rightReduction,is_left,reduction_t);
|
||||
|
||||
/* otherwise use parallel code */
|
||||
else {
|
||||
typedef parallel_partition_task<T,V,Vi,IsLeft,Reduction_T,Reduction_V> partition_task;
|
||||
std::unique_ptr<partition_task> p(new partition_task(&array[begin],end-begin,identity,is_left,reduction_t,reduction_v,BLOCK_SIZE));
|
||||
return begin+p->partition(leftReduction,rightReduction);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
// ======================================================================== //
|
||||
// Copyright 2009-2017 Intel Corporation //
|
||||
// Copyright 2009-2016 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
@@ -41,7 +41,7 @@ namespace embree
|
||||
|
||||
/* calculate parallel prefix sum */
|
||||
std::vector<uint32_t> dst(N);
|
||||
for (auto& v : dst) v = 0;
|
||||
memset(dst.data(),0,N*sizeof(uint32_t));
|
||||
|
||||
for (size_t i=0; i<M; i++) {
|
||||
uint32_t sum1 = parallel_prefix_sum(src,dst,N,0,std::plus<uint32_t>());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ======================================================================== //
|
||||
// Copyright 2009-2017 Intel Corporation //
|
||||
// Copyright 2009-2016 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
@@ -23,7 +23,7 @@ namespace embree
|
||||
template<typename Value>
|
||||
struct ParallelPrefixSumState
|
||||
{
|
||||
enum { MAX_TASKS = 512 };
|
||||
enum { MAX_TASKS = MAX_THREADS };
|
||||
Value counts[MAX_TASKS];
|
||||
Value sums [MAX_TASKS];
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ======================================================================== //
|
||||
// Copyright 2009-2017 Intel Corporation //
|
||||
// Copyright 2009-2016 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ======================================================================== //
|
||||
// Copyright 2009-2017 Intel Corporation //
|
||||
// Copyright 2009-2016 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
@@ -35,21 +35,21 @@ namespace embree
|
||||
template<typename Index, typename Value, typename Func, typename Reduction>
|
||||
__noinline Value parallel_reduce_internal( Index taskCount, const Index first, const Index last, const Index minStepSize, const Value& identity, const Func& func, const Reduction& reduction )
|
||||
{
|
||||
const Index maxTasks = 512;
|
||||
const Index threadCount = (Index) TaskScheduler::threadCount();
|
||||
const size_t maxTasks = MAX_THREADS;
|
||||
const size_t threadCount = TaskScheduler::threadCount();
|
||||
taskCount = min(taskCount,threadCount,maxTasks);
|
||||
|
||||
/* parallel invokation of all tasks */
|
||||
dynamic_large_stack_array(Value,values,taskCount,4096); // consumes at most 4096 bytes on the stack
|
||||
parallel_for(taskCount, [&](const Index taskIndex) {
|
||||
const Index k0 = first+(taskIndex+0)*(last-first)/taskCount;
|
||||
const Index k1 = first+(taskIndex+1)*(last-first)/taskCount;
|
||||
parallel_for(taskCount, [&](const size_t taskIndex) {
|
||||
const size_t k0 = first+(taskIndex+0)*(last-first)/taskCount;
|
||||
const size_t k1 = first+(taskIndex+1)*(last-first)/taskCount;
|
||||
values[taskIndex] = func(range<Index>(k0,k1));
|
||||
});
|
||||
|
||||
/* perform reduction over all tasks */
|
||||
Value v = identity;
|
||||
for (Index i=0; i<taskCount; i++) v = reduction(v,values[i]);
|
||||
for (size_t i=0; i<taskCount; i++) v = reduction(v,values[i]);
|
||||
return v;
|
||||
}
|
||||
|
||||
@@ -73,77 +73,49 @@ namespace embree
|
||||
throw std::runtime_error("task cancelled");
|
||||
return v;
|
||||
#else // TASKING_PPL
|
||||
struct AlignedValue
|
||||
{
|
||||
char storage[__alignof(Value)+sizeof(Value)];
|
||||
static uintptr_t alignUp(uintptr_t p, size_t a) { return p + (~(p - 1) % a); };
|
||||
Value* getValuePtr() { return reinterpret_cast<Value*>(alignUp(uintptr_t(storage), __alignof(Value))); }
|
||||
const Value* getValuePtr() const { return reinterpret_cast<Value*>(alignUp(uintptr_t(storage), __alignof(Value))); }
|
||||
AlignedValue(const Value& v) { new(getValuePtr()) Value(v); }
|
||||
AlignedValue(const AlignedValue& v) { new(getValuePtr()) Value(*v.getValuePtr()); }
|
||||
AlignedValue(const AlignedValue&& v) { new(getValuePtr()) Value(*v.getValuePtr()); };
|
||||
AlignedValue& operator = (const AlignedValue& v) { *getValuePtr() = *v.getValuePtr(); return *this; };
|
||||
AlignedValue& operator = (const AlignedValue&& v) { *getValuePtr() = *v.getValuePtr(); return *this; };
|
||||
operator Value() const { return *getValuePtr(); }
|
||||
};
|
||||
|
||||
struct Iterator_Index
|
||||
{
|
||||
Index v;
|
||||
typedef std::forward_iterator_tag iterator_category;
|
||||
typedef AlignedValue value_type;
|
||||
typedef Index difference_type;
|
||||
typedef Index distance_type;
|
||||
typedef AlignedValue* pointer;
|
||||
typedef AlignedValue& reference;
|
||||
__forceinline Iterator_Index() {}
|
||||
__forceinline Iterator_Index(Index v) : v(v) {}
|
||||
__forceinline bool operator== (Iterator_Index other) { return v == other.v; }
|
||||
__forceinline bool operator!= (Iterator_Index other) { return v != other.v; }
|
||||
__forceinline Iterator_Index operator++() { return Iterator_Index(++v); }
|
||||
__forceinline Iterator_Index operator++(int) { return Iterator_Index(v++); }
|
||||
};
|
||||
|
||||
auto range_reduction = [&](Iterator_Index begin, Iterator_Index end, const AlignedValue& start) {
|
||||
assert(begin.v < end.v);
|
||||
return reduction(start, func(range<Index>(begin.v, end.v)));
|
||||
};
|
||||
const Value v = concurrency::parallel_reduce(Iterator_Index(first), Iterator_Index(last), AlignedValue(identity), range_reduction, reduction);
|
||||
return v;
|
||||
struct AlignedValue
|
||||
{
|
||||
char storage[__alignof(Value)+sizeof(Value)];
|
||||
static uintptr_t alignUp(uintptr_t p, size_t a) { return p + (~(p - 1) % a); };
|
||||
Value* getValuePtr() { return reinterpret_cast<Value*>(alignUp(uintptr_t(storage), __alignof(Value))); }
|
||||
const Value* getValuePtr() const { return reinterpret_cast<Value*>(alignUp(uintptr_t(storage), __alignof(Value))); }
|
||||
AlignedValue(const Value& v) { new(getValuePtr()) Value(v); }
|
||||
AlignedValue(const AlignedValue& v) { new(getValuePtr()) Value(*v.getValuePtr()); }
|
||||
AlignedValue(const AlignedValue&& v) { new(getValuePtr()) Value(*v.getValuePtr()); };
|
||||
AlignedValue& operator = (const AlignedValue& v) { *getValuePtr() = *v.getValuePtr(); return *this; };
|
||||
AlignedValue& operator = (const AlignedValue&& v) { *getValuePtr() = *v.getValuePtr(); return *this; };
|
||||
operator Value() const { return *getValuePtr(); }
|
||||
};
|
||||
|
||||
struct Iterator_size_t
|
||||
{
|
||||
size_t v;
|
||||
typedef std::forward_iterator_tag iterator_category;
|
||||
typedef AlignedValue value_type;
|
||||
typedef size_t difference_type;
|
||||
typedef size_t distance_type;
|
||||
typedef AlignedValue* pointer;
|
||||
typedef AlignedValue& reference;
|
||||
__forceinline Iterator_size_t() {}
|
||||
__forceinline Iterator_size_t(size_t v) : v(v) {}
|
||||
__forceinline bool operator== (Iterator_size_t other) { return v == other.v; }
|
||||
__forceinline bool operator!= (Iterator_size_t other) { return v != other.v; }
|
||||
__forceinline Iterator_size_t operator++() { return Iterator_size_t(++v); }
|
||||
__forceinline Iterator_size_t operator++(int) { return Iterator_size_t(v++); }
|
||||
};
|
||||
|
||||
auto range_reduction = [&](Iterator_size_t begin, Iterator_size_t end, const AlignedValue& start) {
|
||||
assert(begin.v < end.v);
|
||||
return reduction(start, func(range<Index>(begin.v, end.v)));
|
||||
};
|
||||
const Value v = concurrency::parallel_reduce(Iterator_size_t(first), Iterator_size_t(last), AlignedValue(identity), range_reduction, reduction);
|
||||
return v;
|
||||
#endif
|
||||
}
|
||||
|
||||
template<typename Index, typename Value, typename Func, typename Reduction>
|
||||
__forceinline Value parallel_reduce( const Index first, const Index last, const Index minStepSize, const Index parallel_threshold, const Value& identity, const Func& func, const Reduction& reduction )
|
||||
{
|
||||
if (likely(last-first < parallel_threshold)) {
|
||||
return func(range<Index>(first,last));
|
||||
} else {
|
||||
return parallel_reduce(first,last,minStepSize,identity,func,reduction);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename Index, typename Value, typename Func, typename Reduction>
|
||||
__forceinline Value parallel_reduce( const range<Index> range, const Index minStepSize, const Index parallel_threshold, const Value& identity, const Func& func, const Reduction& reduction )
|
||||
{
|
||||
return parallel_reduce(range.begin(),range.end(),minStepSize,parallel_threshold,identity,func,reduction);
|
||||
}
|
||||
|
||||
template<typename Index, typename Value, typename Func, typename Reduction>
|
||||
__forceinline Value parallel_reduce( const Index first, const Index last, const Value& identity, const Func& func, const Reduction& reduction )
|
||||
{
|
||||
auto funcr = [&] ( const range<Index> r ) {
|
||||
Value v = identity;
|
||||
for (Index i=r.begin(); i<r.end(); i++)
|
||||
v = reduction(v,func(i));
|
||||
return v;
|
||||
};
|
||||
return parallel_reduce(first,last,Index(1),identity,funcr,reduction);
|
||||
}
|
||||
|
||||
template<typename Index, typename Value, typename Func, typename Reduction>
|
||||
__forceinline Value parallel_reduce( const range<Index> range, const Value& identity, const Func& func, const Reduction& reduction )
|
||||
{
|
||||
return parallel_reduce(range.begin(),range.end(),Index(1),identity,func,reduction);
|
||||
return parallel_reduce(first,last,Index(1),identity,func,reduction);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
// ======================================================================== //
|
||||
// Copyright 2009-2017 Intel Corporation //
|
||||
// Copyright 2009-2016 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ======================================================================== //
|
||||
// Copyright 2009-2017 Intel Corporation //
|
||||
// Copyright 2009-2016 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ======================================================================== //
|
||||
// Copyright 2009-2017 Intel Corporation //
|
||||
// Copyright 2009-2016 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ======================================================================== //
|
||||
// Copyright 2009-2017 Intel Corporation //
|
||||
// Copyright 2009-2016 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../simd/simd.h"
|
||||
#include "parallel_for.h"
|
||||
#include <algorithm>
|
||||
|
||||
@@ -189,84 +188,10 @@ namespace embree
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
static void radixsort32(T* const morton, const size_t num, const unsigned int shift = 3*8)
|
||||
{
|
||||
static const unsigned int BITS = 8;
|
||||
static const unsigned int BUCKETS = (1 << BITS);
|
||||
static const unsigned int CMP_SORT_THRESHOLD = 16;
|
||||
|
||||
__aligned(64) unsigned int count[BUCKETS];
|
||||
|
||||
/* clear buckets */
|
||||
for (size_t i=0;i<BUCKETS;i++) count[i] = 0;
|
||||
|
||||
/* count buckets */
|
||||
#if defined(__INTEL_COMPILER)
|
||||
#pragma nounroll
|
||||
#endif
|
||||
for (size_t i=0;i<num;i++)
|
||||
count[(unsigned(morton[i]) >> shift) & (BUCKETS-1)]++;
|
||||
|
||||
/* prefix sums */
|
||||
__aligned(64) unsigned int head[BUCKETS];
|
||||
__aligned(64) unsigned int tail[BUCKETS];
|
||||
|
||||
head[0] = 0;
|
||||
for (size_t i=1; i<BUCKETS; i++)
|
||||
head[i] = head[i-1] + count[i-1];
|
||||
|
||||
for (size_t i=0; i<BUCKETS-1; i++)
|
||||
tail[i] = head[i+1];
|
||||
|
||||
tail[BUCKETS-1] = head[BUCKETS-1] + count[BUCKETS-1];
|
||||
|
||||
assert(tail[BUCKETS-1] == head[BUCKETS-1] + count[BUCKETS-1]);
|
||||
assert(tail[BUCKETS-1] == num);
|
||||
|
||||
/* in-place swap */
|
||||
for (size_t i=0;i<BUCKETS;i++)
|
||||
{
|
||||
/* process bucket */
|
||||
while(head[i] < tail[i])
|
||||
{
|
||||
T v = morton[head[i]];
|
||||
while(1)
|
||||
{
|
||||
const size_t b = (unsigned(v) >> shift) & (BUCKETS-1);
|
||||
if (b == i) break;
|
||||
std::swap(v,morton[head[b]++]);
|
||||
}
|
||||
assert((unsigned(v) >> shift & (BUCKETS-1)) == i);
|
||||
morton[head[i]++] = v;
|
||||
}
|
||||
}
|
||||
if (shift == 0) return;
|
||||
|
||||
size_t offset = 0;
|
||||
for (size_t i=0;i<BUCKETS;i++)
|
||||
if (count[i])
|
||||
{
|
||||
|
||||
for (size_t j=offset;j<offset+count[i]-1;j++)
|
||||
assert(((unsigned(morton[j]) >> shift) & (BUCKETS-1)) == i);
|
||||
|
||||
if (unlikely(count[i] < CMP_SORT_THRESHOLD))
|
||||
insertionsort_ascending(morton + offset, count[i]);
|
||||
else
|
||||
radixsort32(morton + offset, count[i], shift-BITS);
|
||||
|
||||
for (size_t j=offset;j<offset+count[i]-1;j++)
|
||||
assert(morton[j] <= morton[j+1]);
|
||||
|
||||
offset += count[i];
|
||||
}
|
||||
}
|
||||
|
||||
template<typename Ty, typename Key>
|
||||
class ParallelRadixSort
|
||||
{
|
||||
static const size_t MAX_TASKS = 512;
|
||||
static const size_t MAX_TASKS = MAX_THREADS;
|
||||
static const size_t BITS = 8;
|
||||
static const size_t BUCKETS = (1 << BITS);
|
||||
typedef unsigned int TyRadixCount[BUCKETS];
|
||||
@@ -313,19 +238,10 @@ namespace embree
|
||||
/* count how many items go into the buckets */
|
||||
for (size_t i=0; i<BUCKETS; i++)
|
||||
radixCount[threadIndex][i] = 0;
|
||||
|
||||
/* iterate over src array and count buckets */
|
||||
unsigned int * __restrict const count = radixCount[threadIndex];
|
||||
#if defined(__INTEL_COMPILER)
|
||||
#pragma nounroll
|
||||
#endif
|
||||
|
||||
for (size_t i=startID; i<endID; i++) {
|
||||
#if defined(__X86_64__)
|
||||
const size_t index = ((size_t)(Key)src[i] >> (size_t)shift) & (size_t)mask;
|
||||
#else
|
||||
const Key index = ((Key)src[i] >> shift) & mask;
|
||||
#endif
|
||||
count[index]++;
|
||||
radixCount[threadIndex][index]++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -342,22 +258,12 @@ namespace embree
|
||||
|
||||
/* calculate total number of items for each bucket */
|
||||
__aligned(64) unsigned int total[BUCKETS];
|
||||
/*
|
||||
for (size_t i=0; i<BUCKETS; i++)
|
||||
total[i] = 0;
|
||||
*/
|
||||
for (size_t i=0; i<BUCKETS; i+=VSIZEX)
|
||||
vintx::store(&total[i], zero);
|
||||
|
||||
for (size_t i=0; i<threadCount; i++)
|
||||
{
|
||||
/*
|
||||
for (size_t j=0; j<BUCKETS; j++)
|
||||
total[j] += radixCount[i][j];
|
||||
*/
|
||||
for (size_t j=0; j<BUCKETS; j+=VSIZEX)
|
||||
vintx::store(&total[j], vintx::load(&total[j]) + vintx::load(&radixCount[i][j]));
|
||||
}
|
||||
|
||||
/* calculate start offset of each bucket */
|
||||
__aligned(64) unsigned int offset[BUCKETS];
|
||||
@@ -367,26 +273,13 @@ namespace embree
|
||||
|
||||
/* calculate start offset of each bucket for this thread */
|
||||
for (size_t i=0; i<threadIndex; i++)
|
||||
{
|
||||
/*
|
||||
for (size_t j=0; j<BUCKETS; j++)
|
||||
offset[j] += radixCount[i][j];
|
||||
*/
|
||||
for (size_t j=0; j<BUCKETS; j+=VSIZEX)
|
||||
vintx::store(&offset[j], vintx::load(&offset[j]) + vintx::load(&radixCount[i][j]));
|
||||
}
|
||||
|
||||
/* copy items into their buckets */
|
||||
#if defined(__INTEL_COMPILER)
|
||||
#pragma nounroll
|
||||
#endif
|
||||
for (size_t i=startID; i<endID; i++) {
|
||||
const Ty elt = src[i];
|
||||
#if defined(__X86_64__)
|
||||
const size_t index = ((size_t)(Key)src[i] >> (size_t)shift) & (size_t)mask;
|
||||
#else
|
||||
const size_t index = ((Key)src[i] >> shift) & mask;
|
||||
#endif
|
||||
const Key index = ((Key)src[i] >> shift) & mask;
|
||||
dst[offset[index]++] = elt;
|
||||
}
|
||||
}
|
||||
@@ -395,9 +288,8 @@ namespace embree
|
||||
const Ty* __restrict src, Ty* __restrict dst,
|
||||
const size_t numTasks)
|
||||
{
|
||||
affinity_partitioner ap;
|
||||
parallel_for_affinity(numTasks,[&] (size_t taskIndex) { tbbRadixIteration0(shift,src,dst,taskIndex,numTasks); },ap);
|
||||
parallel_for_affinity(numTasks,[&] (size_t taskIndex) { tbbRadixIteration1(shift,src,dst,taskIndex,numTasks); },ap);
|
||||
parallel_for(numTasks,[&] (size_t taskIndex) { tbbRadixIteration0(shift,src,dst,taskIndex,numTasks); });
|
||||
parallel_for(numTasks,[&] (size_t taskIndex) { tbbRadixIteration1(shift,src,dst,taskIndex,numTasks); });
|
||||
}
|
||||
|
||||
void tbbRadixSort(const size_t numTasks)
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
## ======================================================================== ##
|
||||
## Copyright 2009-2016 Intel Corporation ##
|
||||
## ##
|
||||
## Licensed under the Apache License, Version 2.0 (the "License"); ##
|
||||
## you may not use this file except in compliance with the License. ##
|
||||
## You may obtain a copy of the License at ##
|
||||
## ##
|
||||
## http://www.apache.org/licenses/LICENSE-2.0 ##
|
||||
## ##
|
||||
## Unless required by applicable law or agreed to in writing, software ##
|
||||
## distributed under the License is distributed on an "AS IS" BASIS, ##
|
||||
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ##
|
||||
## See the License for the specific language governing permissions and ##
|
||||
## limitations under the License. ##
|
||||
## ======================================================================== ##
|
||||
|
||||
SET(LIBRARY_PATHS
|
||||
/usr/lib /usr/local/lib /opt/local/lib)
|
||||
|
||||
FIND_PATH(OPENEXR_INCLUDE_DIR ImfHeader.h
|
||||
/usr/include /usr/include/OpenEXR
|
||||
/usr/local/include /usr/local/include/OpenEXR
|
||||
/opt/local/include /opt/local/include/OpenEXR)
|
||||
|
||||
FIND_LIBRARY(OPENEXR_HALF_LIBRARY NAMES Half PATHS ${LIBRARY_PATHS})
|
||||
FIND_LIBRARY(OPENEXR_IEX_LIBRARY NAMES Iex PATHS ${LIBRARY_PATHS})
|
||||
FIND_LIBRARY(OPENEXR_IMATH_LIBRARY NAMES Imath PATHS ${LIBRARY_PATHS})
|
||||
FIND_LIBRARY(OPENEXR_ILMIMF_LIBRARY NAMES IlmImf PATHS ${LIBRARY_PATHS})
|
||||
FIND_LIBRARY(OPENEXR_ILMTHREAD_LIBRARY NAMES IlmThread PATHS ${LIBRARY_PATHS})
|
||||
|
||||
SET(OPENEXR_INCLUDE_DIRS ${OPENEXR_INCLUDE_DIR})
|
||||
SET(OPENEXR_LIBRARIES ${OPENEXR_HALF_LIBRARY} ${OPENEXR_IEX_LIBRARY} ${OPENEXR_IMATH_LIBRARY} ${OPENEXR_ILMIMF_LIBRARY} ${OPENEXR_ILMTHREAD_LIBRARY})
|
||||
|
||||
INCLUDE(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(OPENEXR DEFAULT_MSG OPENEXR_INCLUDE_DIR OPENEXR_HALF_LIBRARY OPENEXR_IEX_LIBRARY OPENEXR_IMATH_LIBRARY OPENEXR_ILMIMF_LIBRARY OPENEXR_ILMTHREAD_LIBRARY)
|
||||
|
||||
MARK_AS_ADVANCED(
|
||||
OPENEXR_INCLUDE_DIR
|
||||
OPENEXR_HALF_LIBRARY
|
||||
OPENEXR_IEX_LIBRARY
|
||||
OPENEXR_IMATH_LIBRARY
|
||||
OPENEXR_ILMIMF_LIBRARY
|
||||
OPENEXR_ILMTHREAD_LIBRARY
|
||||
)
|
||||
@@ -1,5 +1,5 @@
|
||||
## ======================================================================== ##
|
||||
## Copyright 2009-2017 Intel Corporation ##
|
||||
## Copyright 2009-2016 Intel Corporation ##
|
||||
## ##
|
||||
## Licensed under the Apache License, Version 2.0 (the "License"); ##
|
||||
## you may not use this file except in compliance with the License. ##
|
||||
@@ -14,10 +14,13 @@
|
||||
## limitations under the License. ##
|
||||
## ======================================================================== ##
|
||||
|
||||
# use default install config
|
||||
INCLUDE(${CMAKE_CURRENT_LIST_DIR}/embree-config-install.cmake)
|
||||
FIND_PATH( OPENSUBDIV_INCLUDE_DIR NAMES opensubdiv/version.h )
|
||||
FIND_LIBRARY( OPENSUBDIV_LIBRARY NAMES osdCPU)
|
||||
|
||||
# and override path variables to match for build directory
|
||||
SET(EMBREE_INCLUDE_DIRS @PROJECT_SOURCE_DIR@/include)
|
||||
SET(EMBREE_LIBRARY @PROJECT_BINARY_DIR@/@EMBREE_LIBRARY_NAME@)
|
||||
SET(EMBREE_LIBRARIES ${EMBREE_LIBRARY})
|
||||
SET(OPENSUBDIV_LIBRARIES ${OPENSUBDIV_LIBRARY} )
|
||||
SET(OPENSUBDIV_INCLUDE_DIRS ${OPENSUBDIV_INCLUDE_DIR} )
|
||||
|
||||
INCLUDE(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(OPENSUBDIV DEFAULT_MSG OPENSUBDIV_INCLUDE_DIR OPENSUBDIV_LIBRARY)
|
||||
|
||||
MARK_AS_ADVANCED(OPENSUBDIV_INCLUDE_DIR OPENSUBDIV_LIBRARY)
|
||||
@@ -1,5 +1,5 @@
|
||||
## ======================================================================== ##
|
||||
## Copyright 2009-2017 Intel Corporation ##
|
||||
## Copyright 2009-2016 Intel Corporation ##
|
||||
## ##
|
||||
## Licensed under the Apache License, Version 2.0 (the "License"); ##
|
||||
## you may not use this file except in compliance with the License. ##
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
## ======================================================================== ##
|
||||
## Copyright 2009-2017 Intel Corporation ##
|
||||
## Copyright 2009-2016 Intel Corporation ##
|
||||
## ##
|
||||
## Licensed under the Apache License, Version 2.0 (the "License"); ##
|
||||
## you may not use this file except in compliance with the License. ##
|
||||
@@ -56,7 +56,7 @@ ELSE ()
|
||||
|
||||
FIND_PATH(EMBREE_TBB_ROOT include/tbb/tbb.h
|
||||
DOC "Root of TBB installation"
|
||||
PATHS ${PROJECT_SOURCE_DIR}/tbb /opt/intel/tbb
|
||||
PATHS ${PROJECT_SOURCE_DIR}/tbb /opt/intel/composerxe/tbb
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
FIND_PATH(EMBREE_TBB_ROOT include/tbb/tbb.h)
|
||||
@@ -65,23 +65,6 @@ ELSE ()
|
||||
FIND_PATH(TBB_INCLUDE_DIR tbb/task_scheduler_init.h)
|
||||
FIND_LIBRARY(TBB_LIBRARY tbb)
|
||||
FIND_LIBRARY(TBB_LIBRARY_MALLOC tbbmalloc)
|
||||
|
||||
ELSEIF (EXISTS ${EMBREE_TBB_ROOT}/src)
|
||||
OPTION(EMBREE_TBB_STATIC_LIB "Build TBB as a static library (building TBB as a static library is NOT recommended)")
|
||||
if (EMBREE_TBB_STATIC_LIB)
|
||||
include(${EMBREE_TBB_ROOT}/cmake/TBBBuild.cmake)
|
||||
tbb_build(TBB_ROOT ${EMBREE_TBB_ROOT} CONFIG_DIR TBB_DIR MAKE_ARGS extra_inc=big_iron.inc)
|
||||
SET(TBB_INCLUDE_DIR ${EMBREE_TBB_ROOT}/include)
|
||||
SET(TBB_LIBRARY ${PROJECT_BINARY_DIR}/tbb_cmake_build/tbb_cmake_build_subdir_release/libtbb.a)
|
||||
SET(TBB_LIBRARY_MALLOC ${PROJECT_BINARY_DIR}/tbb_cmake_build/tbb_cmake_build_subdir_release/libtbbmalloc.a)
|
||||
else()
|
||||
include(${EMBREE_TBB_ROOT}/cmake/TBBBuild.cmake)
|
||||
tbb_build(TBB_ROOT ${EMBREE_TBB_ROOT} CONFIG_DIR TBB_DIR)
|
||||
SET(TBB_INCLUDE_DIR ${EMBREE_TBB_ROOT}/include)
|
||||
SET(TBB_LIBRARY ${PROJECT_BINARY_DIR}/tbb_cmake_build/tbb_cmake_build_subdir_release/libtbb.so.2)
|
||||
SET(TBB_LIBRARY_MALLOC ${PROJECT_BINARY_DIR}/tbb_cmake_build/tbb_cmake_build_subdir_release/libtbbmalloc.so.2)
|
||||
endif()
|
||||
|
||||
ELSE()
|
||||
SET(TBB_INCLUDE_DIR TBB_INCLUDE_DIR-NOTFOUND)
|
||||
SET(TBB_LIBRARY TBB_LIBRARY-NOTFOUND)
|
||||
@@ -118,7 +101,6 @@ MARK_AS_ADVANCED(TBB_LIBRARY_MALLOC)
|
||||
IF (WIN32)
|
||||
INSTALL(PROGRAMS ${TBB_BINDIR}/tbb.dll ${TBB_BINDIR}/tbbmalloc.dll DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT examples)
|
||||
INSTALL(PROGRAMS ${TBB_BINDIR}/tbb.dll ${TBB_BINDIR}/tbbmalloc.dll DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT lib)
|
||||
INSTALL(PROGRAMS ${TBB_LIBDIR}/tbb.lib ${TBB_LIBDIR}/tbbmalloc.lib DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT lib)
|
||||
ELSEIF (EMBREE_ZIP_MODE)
|
||||
IF (APPLE)
|
||||
INSTALL(PROGRAMS ${EMBREE_TBB_ROOT}/lib/libtbb.dylib ${EMBREE_TBB_ROOT}/lib/libtbbmalloc.dylib DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT lib)
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
## ======================================================================== ##
|
||||
## Copyright 2009-2017 Intel Corporation ##
|
||||
## ##
|
||||
## Licensed under the Apache License, Version 2.0 (the "License"); ##
|
||||
## you may not use this file except in compliance with the License. ##
|
||||
## You may obtain a copy of the License at ##
|
||||
## ##
|
||||
## http://www.apache.org/licenses/LICENSE-2.0 ##
|
||||
## ##
|
||||
## Unless required by applicable law or agreed to in writing, software ##
|
||||
## distributed under the License is distributed on an "AS IS" BASIS, ##
|
||||
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ##
|
||||
## See the License for the specific language governing permissions and ##
|
||||
## limitations under the License. ##
|
||||
## ======================================================================== ##
|
||||
|
||||
IF (WIN32 OR APPLE)
|
||||
return()
|
||||
ENDIF()
|
||||
|
||||
execute_process(COMMAND objdump -C -t ${file} OUTPUT_VARIABLE output)
|
||||
string(REPLACE "\n" ";" output ${output})
|
||||
|
||||
foreach (line ${output})
|
||||
if ("${line}" MATCHES "O .bss")
|
||||
if (NOT "${line}" MATCHES "std::__ioinit" AND # this is caused by iostream initialization and is likely also ok
|
||||
NOT "${line}" MATCHES "\\(\\)::") # this matches a static inside a function which is fine
|
||||
message(WARNING "\nProblematic global variable in non-SSE code:\n" ${line})
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
@@ -1,40 +0,0 @@
|
||||
// ======================================================================== //
|
||||
// Copyright 2017 Kitware, Inc. //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
// You may obtain a copy of the License at //
|
||||
// //
|
||||
// http://www.apache.org/licenses/LICENSE-2.0 //
|
||||
// //
|
||||
// Unless required by applicable law or agreed to in writing, software //
|
||||
// distributed under the License is distributed on an "AS IS" BASIS, //
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. //
|
||||
// See the License for the specific language governing permissions and //
|
||||
// limitations under the License. //
|
||||
// ======================================================================== //
|
||||
|
||||
#if \
|
||||
defined(__AVX512F__) && defined(__AVX512CD__) && \
|
||||
defined(__AVX512DQ__) && defined(__AVX512BW__) && defined(__AVX512VL__)
|
||||
char const *info_isa = "ISA" ":" "AVX512SKX";
|
||||
#elif \
|
||||
defined(__AVX512F__) && defined(__AVX512CD__) && \
|
||||
defined(__AVX512ER__) && defined(__AVX512PF__)
|
||||
char const *info_isa = "ISA" ":" "AVX512KNL";
|
||||
#elif defined(__AVX2__)
|
||||
char const *info_isa = "ISA" ":" "AVX2";
|
||||
#elif defined(__AVX__)
|
||||
char const *info_isa = "ISA" ":" "AVX";
|
||||
#elif defined(__SSE4_2__)
|
||||
char const *info_isa = "ISA" ":" "SSE42";
|
||||
#else // defined(__SSE2__)
|
||||
char const *info_isa = "ISA" ":" "SSE2";
|
||||
#endif
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int require = 0;
|
||||
require += info_isa[argc];
|
||||
return require;
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
## ======================================================================== ##
|
||||
## Copyright 2017 Kitware, Inc. ##
|
||||
## ##
|
||||
## Licensed under the Apache License, Version 2.0 (the "License"); ##
|
||||
## you may not use this file except in compliance with the License. ##
|
||||
## You may obtain a copy of the License at ##
|
||||
## ##
|
||||
## http://www.apache.org/licenses/LICENSE-2.0 ##
|
||||
## ##
|
||||
## Unless required by applicable law or agreed to in writing, software ##
|
||||
## distributed under the License is distributed on an "AS IS" BASIS, ##
|
||||
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ##
|
||||
## See the License for the specific language governing permissions and ##
|
||||
## limitations under the License. ##
|
||||
## ======================================================================== ##
|
||||
|
||||
SET(CHECK_ISA_DIR ${CMAKE_CURRENT_LIST_DIR})
|
||||
FUNCTION(CHECK_ISA_DEFAULT OUTVAR)
|
||||
SET(ISA_DEFAULT_BIN ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/check_isa_default.bin)
|
||||
SET(SRC ${CHECK_ISA_DIR}/check_isa.cpp)
|
||||
TRY_COMPILE(ISA_DEFAULT_COMPILE
|
||||
${CMAKE_BINARY_DIR}
|
||||
${SRC}
|
||||
COPY_FILE ${ISA_DEFAULT_BIN}
|
||||
)
|
||||
IF(NOT ISA_DEFAULT_COMPILE)
|
||||
SET(ISA_DEFAULT "SSE2")
|
||||
RETURN()
|
||||
ENDIF()
|
||||
FILE(STRINGS ${ISA_DEFAULT_BIN} ISA_DEFAULT REGEX "^ISA:")
|
||||
STRING(REPLACE "ISA:" "" ISA_DEFAULT "${ISA_DEFAULT}")
|
||||
SET(${OUTVAR} ${ISA_DEFAULT} PARENT_SCOPE)
|
||||
ENDFUNCTION()
|
||||
+16
-87
@@ -1,5 +1,5 @@
|
||||
## ======================================================================== ##
|
||||
## Copyright 2009-2017 Intel Corporation ##
|
||||
## Copyright 2009-2016 Intel Corporation ##
|
||||
## ##
|
||||
## Licensed under the Apache License, Version 2.0 (the "License"); ##
|
||||
## you may not use this file except in compliance with the License. ##
|
||||
@@ -26,95 +26,24 @@ SET(FLAGS_AVX512SKX "-march=skx")
|
||||
|
||||
IF (WIN32)
|
||||
|
||||
SET(COMMON_CXX_FLAGS "")
|
||||
SET(COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} /EHsc") # catch C++ exceptions only and extern "C" functions never throw a C++ exception
|
||||
# SET(COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} /MP") # compile source files in parallel
|
||||
SET(COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} /GR") # enable runtime type information (on by default)
|
||||
SET(COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} -Xclang -fcxx-exceptions") # enable C++ exceptions in Clang
|
||||
IF (EMBREE_STACK_PROTECTOR)
|
||||
SET(COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} /GS") # protects against return address overrides
|
||||
ELSE()
|
||||
SET(COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} /GS-") # do not protect against return address overrides
|
||||
ENDIF()
|
||||
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${COMMON_CXX_FLAGS}")
|
||||
SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /DEBUG") # generate debug information
|
||||
SET(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} /DEBUG") # generate debug information
|
||||
SET(COMMON_CXX_FLAGS "/EHsc /GR -Xclang -fcxx-exceptions")
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${COMMON_CXX_FLAGS} /DTBB_USE_DEBUG")
|
||||
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${COMMON_CXX_FLAGS} /Ox /fp:fast /Oi /Gy")
|
||||
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${COMMON_CXX_FLAGS} /Ox /fp:fast /Oi /Gy /DTBB_USE_DEBUG")
|
||||
|
||||
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${COMMON_CXX_FLAGS}")
|
||||
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Ox") # enable full optimizations
|
||||
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Oi") # inline intrinsic functions
|
||||
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Gy") # package individual functions
|
||||
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fno-vectorize") # disable auto vectorization
|
||||
|
||||
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${COMMON_CXX_FLAGS}")
|
||||
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /Ox") # enable full optimizations
|
||||
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /Oi") # inline intrinsic functions
|
||||
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /Gy") # package individual functions
|
||||
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -fno-vectorize") # disable auto vectorization
|
||||
SET(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} /DEBUG") # generate debug information
|
||||
SET(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO} /DEBUG") # generate debug information
|
||||
|
||||
SET(SECURE_LINKER_FLAGS "")
|
||||
SET(SECURE_LINKER_FLAGS "${SECURE_LINKER_FLAGS} /NXCompat") # compatible with data execution prevention (on by default)
|
||||
SET(SECURE_LINKER_FLAGS "${SECURE_LINKER_FLAGS} /DynamicBase") # random rebase of executable at load time
|
||||
IF (CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||
SET(SECURE_LINKER_FLAGS "${SECURE_LINKER_FLAGS} /SafeSEH") # invoke known exception handlers (Win32 only, x64 exception handlers are safe by design)
|
||||
ENDIF()
|
||||
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${SECURE_LINKER_FLAGS}")
|
||||
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${SECURE_LINKER_FLAGS}")
|
||||
|
||||
INCLUDE(msvc_post)
|
||||
SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /DEBUG")
|
||||
SET(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} /DEBUG")
|
||||
|
||||
ELSE()
|
||||
|
||||
OPTION(EMBREE_IGNORE_CMAKE_CXX_FLAGS "When enabled Embree ignores default CMAKE_CXX_FLAGS." ON)
|
||||
IF (EMBREE_IGNORE_CMAKE_CXX_FLAGS)
|
||||
SET(CMAKE_CXX_FLAGS "")
|
||||
ENDIF()
|
||||
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") # enables most warnings
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wformat -Wformat-security") # enables string format vulnerability warnings
|
||||
IF (NOT APPLE)
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIE") # enables support for more secure position independent execution
|
||||
ENDIF()
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") # generate position independent code suitable for shared libraries
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") # enables C++11 features
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden") # makes all symbols hidden by default
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility-inlines-hidden") # makes all inline symbols hidden by default
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing") # disables strict aliasing rules
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_FORTIFY_SOURCE=2") # perform extra security checks for some standard library calls
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-tree-vectorize") # disable auto vectorizer
|
||||
IF (EMBREE_STACK_PROTECTOR)
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector") # protects against return address overrides
|
||||
ENDIF()
|
||||
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "")
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG") # enable assertions
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DTBB_USE_DEBUG") # configure TBB in debug mode
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g") # generate debug information
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0") # disable optimizations
|
||||
|
||||
SET(CMAKE_CXX_FLAGS_RELEASE "")
|
||||
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG") # disable assertions
|
||||
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3") # enable full optimizations
|
||||
|
||||
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "")
|
||||
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -DDEBUG") # enable assertions
|
||||
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -DTBB_USE_DEBUG") # configure TBB in debug mode
|
||||
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -g") # generate debug information
|
||||
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -O3") # enable full optimizations
|
||||
|
||||
IF (APPLE)
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.7") # makes sure code runs on older MacOSX versions
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") # link against libc++ which supports C++11 features
|
||||
ELSE(APPLE)
|
||||
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined") # issues link error for undefined symbols in shared library
|
||||
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -z noexecstack") # we do not need an executable stack
|
||||
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -z relro -z now") # re-arranges data sections to increase security
|
||||
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -z noexecstack") # we do not need an executable stack
|
||||
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -z relro -z now") # re-arranges data sections to increase security
|
||||
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie") # enables position independent execution for executable
|
||||
ENDIF(APPLE)
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fPIC -std=c++11 -fvisibility-inlines-hidden -fvisibility=hidden -fno-strict-aliasing")
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "-DDEBUG -DTBB_USE_DEBUG -g -O0")
|
||||
SET(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG -O3")
|
||||
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-DDEBUG -DTBB_USE_DEBUG -g -O3")
|
||||
|
||||
ENDIF()
|
||||
|
||||
IF (APPLE)
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.7 ") # we only use MacOSX 10.7 features
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++" ) # link against C++11 stdlib
|
||||
ENDIF (APPLE)
|
||||
@@ -1,5 +1,5 @@
|
||||
## ======================================================================== ##
|
||||
## Copyright 2009-2017 Intel Corporation ##
|
||||
## Copyright 2009-2016 Intel Corporation ##
|
||||
## ##
|
||||
## Licensed under the Apache License, Version 2.0 (the "License"); ##
|
||||
## you may not use this file except in compliance with the License. ##
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
## ======================================================================== ##
|
||||
## Copyright 2009-2017 Intel Corporation ##
|
||||
## Copyright 2009-2016 Intel Corporation ##
|
||||
## ##
|
||||
## Licensed under the Apache License, Version 2.0 (the "License"); ##
|
||||
## you may not use this file except in compliance with the License. ##
|
||||
@@ -14,15 +14,6 @@
|
||||
## limitations under the License. ##
|
||||
## ======================================================================== ##
|
||||
|
||||
SET(EMBREE_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/@EMBREE_RELATIV_ROOT_DIR@)
|
||||
GET_FILENAME_COMPONENT(EMBREE_ROOT_DIR "${EMBREE_ROOT_DIR}" ABSOLUTE)
|
||||
|
||||
SET(EMBREE_INCLUDE_DIRS ${EMBREE_ROOT_DIR}/@CMAKE_INSTALL_INCLUDEDIR@)
|
||||
SET(EMBREE_LIBRARY ${EMBREE_ROOT_DIR}/@CMAKE_INSTALL_LIBDIR@/@EMBREE_LIBRARY_NAME@)
|
||||
SET(EMBREE_LIBRARIES ${EMBREE_LIBRARY})
|
||||
|
||||
MARK_AS_ADVANCED(embree_DIR)
|
||||
|
||||
SET(EMBREE_VERSION @EMBREE_VERSION@)
|
||||
SET(EMBREE_VERSION_MAJOR @EMBREE_VERSION_MAJOR@)
|
||||
SET(EMBREE_VERSION_MINOR @EMBREE_VERSION_MINOR@)
|
||||
@@ -30,13 +21,6 @@ SET(EMBREE_VERSION_PATCH @EMBREE_VERSION_PATCH@)
|
||||
SET(EMBREE_VERSION_NOTE "@EMBREE_VERSION_NOTE@")
|
||||
|
||||
SET(EMBREE_MAX_ISA @EMBREE_MAX_ISA@)
|
||||
SET(EMBREE_ISA_SSE2 @EMBREE_ISA_SSE2@)
|
||||
SET(EMBREE_ISA_SSE42 @EMBREE_ISA_SSE42@)
|
||||
SET(EMBREE_ISA_AVX @EMBREE_ISA_AVX@)
|
||||
SET(EMBREE_ISA_AVX2 @EMBREE_ISA_AVX2@)
|
||||
SET(EMBREE_ISA_AVX512KNL @EMBREE_ISA_AVX512KNL@)
|
||||
SET(EMBREE_ISA_AVX512SKX @EMBREE_ISA_AVX512SKX@)
|
||||
|
||||
SET(EMBREE_BUILD_TYPE @CMAKE_BUILD_TYPE@)
|
||||
SET(EMBREE_ISPC_SUPPORT @EMBREE_ISPC_SUPPORT@)
|
||||
SET(EMBREE_STATIC_LIB @EMBREE_STATIC_LIB@)
|
||||
+22
-19
@@ -1,5 +1,5 @@
|
||||
## ======================================================================== ##
|
||||
## Copyright 2009-2017 Intel Corporation ##
|
||||
## Copyright 2009-2016 Intel Corporation ##
|
||||
## ##
|
||||
## Licensed under the Apache License, Version 2.0 (the "License"); ##
|
||||
## you may not use this file except in compliance with the License. ##
|
||||
@@ -14,24 +14,27 @@
|
||||
## limitations under the License. ##
|
||||
## ======================================================================== ##
|
||||
|
||||
IF (WIN32 OR APPLE)
|
||||
return()
|
||||
SET(EMBREE_INCLUDE_DIRS ${CMAKE_CURRENT_LIST_DIR}/../../../@CMAKE_INSTALL_INCLUDEDIR@)
|
||||
SET(EMBREE_LIBRARY ${CMAKE_CURRENT_LIST_DIR}/../../@CMAKE_SHARED_LIBRARY_PREFIX@embree@CMAKE_SHARED_LIBRARY_SUFFIX@.@EMBREE_CONFIG_VERSION@)
|
||||
|
||||
SET(EMBREE_TASKING_TBB @TASKING_TBB@)
|
||||
SET(EMBREE_USE_PACKAGED_TBB @EMBREE_ZIP_MODE@)
|
||||
|
||||
IF (${EMBREE_TASKING_TBB} AND ${EMBREE_USE_PACKAGED_TBB})
|
||||
SET(EMBREE_TBB_LIBRARY ${CMAKE_CURRENT_LIST_DIR}/../../@CMAKE_SHARED_LIBRARY_PREFIX@tbb@CMAKE_SHARED_LIBRARY_SUFFIX@.2)
|
||||
SET(EMBREE_TBB_LIBRARY_MALLOC ${CMAKE_CURRENT_LIST_DIR}/../../@CMAKE_SHARED_LIBRARY_PREFIX@tbbmalloc@CMAKE_SHARED_LIBRARY_SUFFIX@.2)
|
||||
ELSE()
|
||||
SET(EMBREE_USE_PACKAGED_TBB OFF)
|
||||
UNSET(EMBREE_TBB_LIBRARY)
|
||||
UNSET(EMBREE_TBB_LIBRARY_MALLOC)
|
||||
ENDIF()
|
||||
|
||||
execute_process(COMMAND objdump -d ${file} OUTPUT_VARIABLE output)
|
||||
string(REPLACE "\n" ";" output ${output})
|
||||
SET(EMBREE_LIBRARIES
|
||||
${EMBREE_LIBRARY}
|
||||
${EMBREE_TBB_LIBRARY}
|
||||
${EMBREE_TBB_LIBRARY_MALLOC}
|
||||
)
|
||||
|
||||
SET(lastfunc "")
|
||||
foreach (line ${output})
|
||||
if ("${line}" MATCHES "^.*<([^>]*)>:$")
|
||||
SET(lastfunc ${CMAKE_MATCH_1})
|
||||
endif()
|
||||
if ("${line}" MATCHES ".*sub[ ]+[$]([^,]*),%rsp.*")
|
||||
set(bytes ${CMAKE_MATCH_1})
|
||||
if ("${bytes}" GREATER "4096")
|
||||
if ("${lastfunc}" MATCHES ".*recurse.*")
|
||||
message(WARNING "Large stack space requirement: ${lastfunc} size: ${bytes}")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
MARK_AS_ADVANCED(embree_DIR)
|
||||
|
||||
INCLUDE(${CMAKE_CURRENT_LIST_DIR}/embree-config-default.cmake)
|
||||
@@ -1,5 +1,5 @@
|
||||
## ======================================================================== ##
|
||||
## Copyright 2017 Kitware, Inc. ##
|
||||
## Copyright 2009-2016 Intel Corporation ##
|
||||
## ##
|
||||
## Licensed under the Apache License, Version 2.0 (the "License"); ##
|
||||
## you may not use this file except in compliance with the License. ##
|
||||
@@ -14,9 +14,9 @@
|
||||
## limitations under the License. ##
|
||||
## ======================================================================== ##
|
||||
|
||||
SET(FLAGS_SSE2 "-target-cpu=xeon")
|
||||
SET(FLAGS_SSE42 "-target-cpu=interlagos")
|
||||
SET(FLAGS_AVX "-target-cpu=sandybridge")
|
||||
SET(FLAGS_AVX2 "-target-cpu=haswell")
|
||||
SET(FLAGS_AVX512KNL "-target-cpu=mic-knl")
|
||||
SET(FLAGS_AVX512SKX "-target-cpu=x86-skylake")
|
||||
SET(EMBREE_INCLUDE_DIRS ${CMAKE_CURRENT_LIST_DIR}/../../../@CMAKE_INSTALL_INCLUDEDIR@)
|
||||
SET(EMBREE_LIBRARY ${CMAKE_CURRENT_LIST_DIR}/../../libembree.@EMBREE_CONFIG_VERSION@.dylib)
|
||||
|
||||
MARK_AS_ADVANCED(embree_DIR)
|
||||
|
||||
INCLUDE(${CMAKE_CURRENT_LIST_DIR}/embree-config-default.cmake)
|
||||
@@ -1,5 +1,5 @@
|
||||
## ======================================================================== ##
|
||||
## Copyright 2009-2017 Intel Corporation ##
|
||||
## Copyright 2009-2016 Intel Corporation ##
|
||||
## ##
|
||||
## Licensed under the Apache License, Version 2.0 (the "License"); ##
|
||||
## you may not use this file except in compliance with the License. ##
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
## ======================================================================== ##
|
||||
## Copyright 2009-2017 Intel Corporation ##
|
||||
## Copyright 2009-2016 Intel Corporation ##
|
||||
## ##
|
||||
## Licensed under the Apache License, Version 2.0 (the "License"); ##
|
||||
## you may not use this file except in compliance with the License. ##
|
||||
@@ -14,7 +14,9 @@
|
||||
## limitations under the License. ##
|
||||
## ======================================================================== ##
|
||||
|
||||
INCLUDE(tutorial)
|
||||
ADD_TUTORIAL(viewer_anim)
|
||||
SET(EMBREE_INCLUDE_DIRS ${CMAKE_CURRENT_LIST_DIR}/../../../@CMAKE_INSTALL_INCLUDEDIR@)
|
||||
SET(EMBREE_LIBRARY ${CMAKE_CURRENT_LIST_DIR}/../../embree.lib)
|
||||
|
||||
MARK_AS_ADVANCED(embree_DIR)
|
||||
|
||||
INCLUDE(${CMAKE_CURRENT_LIST_DIR}/embree-config-default.cmake)
|
||||
+14
-49
@@ -1,5 +1,5 @@
|
||||
## ======================================================================== ##
|
||||
## Copyright 2009-2017 Intel Corporation ##
|
||||
## Copyright 2009-2016 Intel Corporation ##
|
||||
## ##
|
||||
## Licensed under the Apache License, Version 2.0 (the "License"); ##
|
||||
## you may not use this file except in compliance with the License. ##
|
||||
@@ -15,58 +15,23 @@
|
||||
## ======================================================================== ##
|
||||
|
||||
SET(FLAGS_SSE2 "-msse2")
|
||||
SET(FLAGS_SSE3 "-msse3")
|
||||
SET(FLAGS_SSSE3 "-mssse3")
|
||||
SET(FLAGS_SSE41 "-msse4.1")
|
||||
SET(FLAGS_SSE42 "-msse4.2")
|
||||
SET(FLAGS_AVX "-mavx")
|
||||
SET(FLAGS_AVX2 "-mf16c -mavx2 -mfma -mlzcnt -mbmi -mbmi2")
|
||||
SET(FLAGS_AVX512KNL "-mavx512f -mavx512pf -mavx512er -mavx512cd -mf16c -mavx2 -mfma -mlzcnt -mbmi -mbmi2")
|
||||
SET(FLAGS_AVX512SKX "-mavx512f -mavx512dq -mavx512cd -mavx512bw -mavx512vl -mf16c -mavx2 -mfma -mlzcnt -mbmi -mbmi2")
|
||||
SET(FLAGS_AVX512KNL "-mavx512f -mavx512pf -mavx512er -mavx512cd")
|
||||
SET(FLAGS_AVX512SKX "-mavx512f -mavx512dq -mavx512cd -mavx512bw -mavx512vl")
|
||||
|
||||
OPTION(EMBREE_IGNORE_CMAKE_CXX_FLAGS "When enabled Embree ignores default CMAKE_CXX_FLAGS." ON)
|
||||
IF (EMBREE_IGNORE_CMAKE_CXX_FLAGS)
|
||||
SET(CMAKE_CXX_FLAGS "")
|
||||
ENDIF()
|
||||
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") # enables most warnings
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wformat -Wformat-security") # enables string format vulnerability warnings
|
||||
IF (NOT APPLE)
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIE") # enables support for more secure position independent execution
|
||||
ENDIF()
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") # generate position independent code suitable for shared libraries
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") # enables C++11 features
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden") # makes all symbols hidden by default
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility-inlines-hidden") # makes all inline symbols hidden by default
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing") # disables strict aliasing rules
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_FORTIFY_SOURCE=2") # perform extra security checks for some standard library calls
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-tree-vectorize") # disable auto vectorizer
|
||||
IF (EMBREE_STACK_PROTECTOR)
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector") # protects against return address overrides
|
||||
ENDIF()
|
||||
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "")
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG") # enable assertions
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DTBB_USE_DEBUG") # configure TBB in debug mode
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g") # generate debug information
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0") # disable optimizations
|
||||
|
||||
SET(CMAKE_CXX_FLAGS_RELEASE "")
|
||||
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG") # disable assertions
|
||||
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3") # enable full optimizations
|
||||
|
||||
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "")
|
||||
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -DDEBUG") # enable assertions
|
||||
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -DTBB_USE_DEBUG") # configure TBB in debug mode
|
||||
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -g") # generate debug information
|
||||
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -O3") # enable full optimizations
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fPIC -std=c++11 -fvisibility-inlines-hidden -fvisibility=hidden -fno-strict-aliasing")
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "-DDEBUG -DTBB_USE_DEBUG -g -O0")
|
||||
SET(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG -O3")
|
||||
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-DDEBUG -DTBB_USE_DEBUG -g -O3")
|
||||
SET(CMAKE_EXE_LINKER_FLAGS "")
|
||||
|
||||
IF (APPLE)
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.7") # makes sure code runs on older MacOSX versions
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") # link against libc++ which supports C++11 features
|
||||
ELSE(APPLE)
|
||||
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined") # issues link error for undefined symbols in shared library
|
||||
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -z noexecstack") # we do not need an executable stack
|
||||
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -z relro -z now") # re-arranges data sections to increase security
|
||||
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -z noexecstack") # we do not need an executable stack
|
||||
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -z relro -z now") # re-arranges data sections to increase security
|
||||
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie") # enables position independent execution for executable
|
||||
ENDIF(APPLE)
|
||||
SET (CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS_INIT} -dynamiclib)
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.7 -stdlib=libc++")
|
||||
ENDIF (APPLE)
|
||||
|
||||
+22
-131
@@ -1,5 +1,5 @@
|
||||
## ======================================================================== ##
|
||||
## Copyright 2009-2017 Intel Corporation ##
|
||||
## Copyright 2009-2016 Intel Corporation ##
|
||||
## ##
|
||||
## Licensed under the Apache License, Version 2.0 (the "License"); ##
|
||||
## you may not use this file except in compliance with the License. ##
|
||||
@@ -14,139 +14,30 @@
|
||||
## limitations under the License. ##
|
||||
## ======================================================================== ##
|
||||
|
||||
IF (WIN32)
|
||||
SET(FLAGS_SSE2 "-xsse2")
|
||||
SET(FLAGS_SSE3 "-xsse3")
|
||||
SET(FLAGS_SSSE3 "-xssse3")
|
||||
SET(FLAGS_SSE41 "-xsse4.1")
|
||||
SET(FLAGS_SSE42 "-xsse4.2")
|
||||
SET(FLAGS_AVX "-xAVX")
|
||||
SET(FLAGS_AVX2 "-xCORE-AVX2")
|
||||
SET(FLAGS_AVX512KNL "-xMIC-AVX512")
|
||||
SET(FLAGS_AVX512SKX "-xCORE-AVX512")
|
||||
|
||||
SET(FLAGS_SSE2 "/QxSSE2")
|
||||
SET(FLAGS_SSE42 "/QxSSE4.2")
|
||||
SET(FLAGS_AVX "/arch:AVX")
|
||||
SET(FLAGS_AVX2 "/QxCORE-AVX2")
|
||||
SET(FLAGS_AVX512KNL "/QxMIC-AVX512")
|
||||
SET(FLAGS_AVX512SKX "/QxCORE-AVX512")
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fPIC -std=c++11 -fvisibility-inlines-hidden -fvisibility=hidden -no-ansi-alias -fasm-blocks")
|
||||
|
||||
SET(COMMON_CXX_FLAGS "")
|
||||
SET(COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} /EHsc") # catch C++ exceptions only and extern "C" functions never throw a C++ exception
|
||||
SET(COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} /MP") # compile source files in parallel
|
||||
SET(COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} /GR") # enable runtime type information (on by default)
|
||||
SET(COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} /Qvec-") # disable auto vectorizer
|
||||
IF (EMBREE_STACK_PROTECTOR)
|
||||
SET(COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} /GS") # protects against return address overrides
|
||||
ELSE()
|
||||
SET(COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} /GS-") # do not protect against return address overrides
|
||||
ENDIF()
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "-DDEBUG -DTBB_USE_DEBUG -g -O0")
|
||||
SET(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG -O3 -restrict -no-inline-max-total-size -inline-factor=200")
|
||||
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-DDEBUG -DTBB_USE_DEBUG -g -O3 -restrict -no-inline-max-total-size -inline-factor=200")
|
||||
|
||||
SET(COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} /Qdiag-disable:11074 ") # remark #11074: Inlining inhibited by limit max-size
|
||||
SET(COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} /Qdiag-disable:11075 ") # remark #11075: To get full report use -Qopt-report:4 -Qopt-report-phase ipo
|
||||
# enable -static-intel and avoid to export ICC specific symbols from Embree
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-intel -no-intel-extensions")
|
||||
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${COMMON_CXX_FLAGS}")
|
||||
SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /DEBUG") # generate debug information
|
||||
SET(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} /DEBUG") # generate debug information
|
||||
#SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -g -debug inline-debug-info")
|
||||
#SET(CMAKE_EXE_LINKER_FLAGS "-g")
|
||||
|
||||
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${COMMON_CXX_FLAGS}")
|
||||
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Ox") # enable full optimizations
|
||||
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Oi") # inline intrinsic functions
|
||||
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Gy") # package individual functions
|
||||
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Qinline-max-total-size-") # no size limit when performing inlining
|
||||
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Qinline-factor=200") # increase default inline factors by 2x
|
||||
IF (APPLE)
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.7 ") # we only use MacOSX 10.7 features
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++" ) # link against C++11 stdlib
|
||||
ENDIF (APPLE)
|
||||
|
||||
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${COMMON_CXX_FLAGS}")
|
||||
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /Ox") # enable full optimizations
|
||||
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /Oi") # inline intrinsic functions
|
||||
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /Gy") # package individual functions
|
||||
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /Qinline-max-total-size-") # no size limit when performing inlining
|
||||
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /Qinline-factor=200") # increase default inline factors by 2x
|
||||
SET(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} /DEBUG") # generate debug information
|
||||
SET(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO} /DEBUG") # generate debug information
|
||||
|
||||
SET(SECURE_LINKER_FLAGS "")
|
||||
SET(SECURE_LINKER_FLAGS "${SECURE_LINKER_FLAGS} /NXCompat") # compatible with data execution prevention (on by default)
|
||||
SET(SECURE_LINKER_FLAGS "${SECURE_LINKER_FLAGS} /DynamicBase") # random rebase of executable at load time
|
||||
IF (CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||
SET(SECURE_LINKER_FLAGS "${SECURE_LINKER_FLAGS} /SafeSEH") # invoke known exception handlers (Win32 only, x64 exception handlers are safe by design)
|
||||
ENDIF()
|
||||
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${SECURE_LINKER_FLAGS}")
|
||||
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${SECURE_LINKER_FLAGS}")
|
||||
|
||||
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /IGNORE:4217") # locally defined symbol XXX imported in function YYY (happens as the ISPC API layer uses exported library functions)
|
||||
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /IGNORE:4049") # warning LNK4049: locally defined symbol _rtcOccluded1M imported
|
||||
|
||||
INCLUDE(msvc_post)
|
||||
|
||||
ELSE()
|
||||
|
||||
IF (APPLE)
|
||||
SET(FLAGS_SSE2 "-xssse3") # on MacOSX ICC does not support SSE2
|
||||
ELSE()
|
||||
SET(FLAGS_SSE2 "-xsse2")
|
||||
ENDIF()
|
||||
SET(FLAGS_SSE42 "-xsse4.2")
|
||||
SET(FLAGS_AVX "-xAVX")
|
||||
SET(FLAGS_AVX2 "-xCORE-AVX2")
|
||||
SET(FLAGS_AVX512KNL "-xMIC-AVX512")
|
||||
SET(FLAGS_AVX512SKX "-xCORE-AVX512")
|
||||
|
||||
OPTION(EMBREE_IGNORE_CMAKE_CXX_FLAGS "When enabled Embree ignores default CMAKE_CXX_FLAGS." ON)
|
||||
IF (EMBREE_IGNORE_CMAKE_CXX_FLAGS)
|
||||
SET(CMAKE_CXX_FLAGS "")
|
||||
ENDIF()
|
||||
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") # enables most warnings
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wformat -Wformat-security") # enables string format vulnerability warnings
|
||||
IF (NOT APPLE)
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIE") # enables support for more secure position independent execution
|
||||
ENDIF()
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") # generate position independent code suitable for shared libraries
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") # enables C++11 features
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden") # makes all symbols hidden by default
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility-inlines-hidden") # makes all inline symbols hidden by default
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -no-ansi-alias") # disables strict aliasing rules
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_FORTIFY_SOURCE=2") # perform extra security checks for some standard library calls
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -no-vec") # disable auto vectorizer
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fasm-blocks") # enable assembly blocks
|
||||
IF (EMBREE_STACK_PROTECTOR)
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector") # protects against return address overrides
|
||||
ENDIF()
|
||||
IF(NOT CMAKE_CXX_COMPILER_WRAPPER STREQUAL "CrayPrgEnv")
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-intel") # links intel runtime statically
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -no-intel-extensions") # disables some intel extensions which cause symbols to be exported
|
||||
ENDIF()
|
||||
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "")
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG") # enables assertions
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DTBB_USE_DEBUG") # configures TBB in debug mode
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g") # generate debug information
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0") # disable all optimizations
|
||||
|
||||
SET(CMAKE_CXX_FLAGS_RELEASE "")
|
||||
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG") # disable assertions
|
||||
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3") # full optimizations
|
||||
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -restrict") # enable restrict keyword
|
||||
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -no-inline-max-total-size") # no size limit when performing inlining
|
||||
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -no-inline-max-per-compile") # no maximal number of inlinings per compilation unit
|
||||
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -inline-factor=200") # increase default inline factors limits by 2x
|
||||
|
||||
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "")
|
||||
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -DDEBUG") # enables assertions
|
||||
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -DTBB_USE_DEBUG") # configures TBB in debug mode
|
||||
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -g") # generate debug information
|
||||
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -O3") # full optimizations
|
||||
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -restrict") # enable restrict keyword
|
||||
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -no-inline-max-total-size") # no size limit when performing inlining
|
||||
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -no-inline-max-per-compile") # no maximal number of inlinings per compilation unit
|
||||
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -inline-factor=200") # increase default inline factors by 2x
|
||||
|
||||
#SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -g -debug inline-debug-info")
|
||||
#SET(CMAKE_EXE_LINKER_FLAGS "-g")
|
||||
|
||||
IF (APPLE)
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.7") # makes sure code runs on older MacOSX versions
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") # link against libc++ which supports C++11 features
|
||||
ELSE(APPLE)
|
||||
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined") # issues link error for undefined symbols in shared library
|
||||
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -z noexecstack") # we do not need an executable stack
|
||||
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -z relro -z now") # re-arranges data sections to increase security
|
||||
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -z noexecstack") # we do not need an executable stack
|
||||
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -z relro -z now") # re-arranges data sections to increase security
|
||||
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie") # enables position independent execution for executable
|
||||
ENDIF(APPLE)
|
||||
|
||||
ENDIF()
|
||||
@@ -1,5 +1,5 @@
|
||||
## ======================================================================== ##
|
||||
## Copyright 2009-2017 Intel Corporation ##
|
||||
## Copyright 2009-2016 Intel Corporation ##
|
||||
## ##
|
||||
## Licensed under the Apache License, Version 2.0 (the "License"); ##
|
||||
## you may not use this file except in compliance with the License. ##
|
||||
@@ -146,7 +146,6 @@ MACRO (ISPC_COMPILE)
|
||||
COMMAND ${EMBREE_ISPC_EXECUTABLE}
|
||||
-I ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${ISPC_INCLUDE_DIR_PARMS}
|
||||
${ISPC_DEFINITIONS}
|
||||
--arch=${ISPC_ARCHITECTURE}
|
||||
--addressing=${EMBREE_ISPC_ADDRESSING}
|
||||
${ISPC_OPT_FLAGS}
|
||||
|
||||
+37
-37
@@ -1,5 +1,5 @@
|
||||
## ======================================================================== ##
|
||||
## Copyright 2009-2017 Intel Corporation ##
|
||||
## Copyright 2009-2016 Intel Corporation ##
|
||||
## ##
|
||||
## Licensed under the Apache License, Version 2.0 (the "License"); ##
|
||||
## you may not use this file except in compliance with the License. ##
|
||||
@@ -14,49 +14,49 @@
|
||||
## limitations under the License. ##
|
||||
## ======================================================================== ##
|
||||
|
||||
SET(FLAGS_SSE2 "/D__SSE__ /D__SSE2__")
|
||||
SET(FLAGS_SSE42 "${FLAGS_SSE2} /D__SSE3__ /D__SSSE3__ /D__SSE4_1__ /D__SSE4_2__")
|
||||
SET(FLAGS_AVX "${FLAGS_SSE42} /arch:AVX")
|
||||
SET(FLAGS_AVX2 "${FLAGS_SSE42} /arch:AVX2")
|
||||
# the /QxXXX flags are meant for the Intel Compiler, MSVC ignores them
|
||||
SET(FLAGS_SSE2 "/QxSSE2")
|
||||
SET(FLAGS_SSE3 "/QxSSE3")
|
||||
SET(FLAGS_SSSE3 "/QxSSSE3")
|
||||
SET(FLAGS_SSE41 "/DCONFIG_SSE41 /QxSSE4.1")
|
||||
SET(FLAGS_SSE42 "/DCONFIG_SSE42 /QxSSE4.2")
|
||||
SET(FLAGS_AVX "/arch:AVX /DCONFIG_AVX")
|
||||
|
||||
SET(COMMON_CXX_FLAGS "")
|
||||
SET(COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} /EHsc") # catch C++ exceptions only and extern "C" functions never throw a C++ exception
|
||||
SET(COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} /MP") # compile source files in parallel
|
||||
SET(COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} /GR") # enable runtime type information (on by default)
|
||||
IF (EMBREE_STACK_PROTECTOR)
|
||||
SET(COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} /GS") # protects against return address overrides
|
||||
# Intel Compiler 15, Update 1 unfortunately cannot handle /arch:AVX2
|
||||
IF (${CMAKE_CXX_COMPILER_ID} STREQUAL "Intel")
|
||||
SET(FLAGS_AVX2 "/DCONFIG_AVX2 /QxCORE-AVX2")
|
||||
ELSE()
|
||||
SET(COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} /GS-") # do not protect against return address overrides
|
||||
SET(FLAGS_AVX2 "/arch:AVX2 /DCONFIG_AVX2 /QxCORE-AVX2")
|
||||
ENDIF()
|
||||
SET(COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} ${FLAGS_SSE2}")
|
||||
SET(FLAGS_AVX512KNL "")
|
||||
SET(FLAGS_AVX512SKX "")
|
||||
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${COMMON_CXX_FLAGS}")
|
||||
SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /DEBUG") # generate debug information
|
||||
SET(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} /DEBUG") # generate debug information
|
||||
|
||||
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${COMMON_CXX_FLAGS}")
|
||||
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Ox") # enable full optimizations
|
||||
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Oi") # inline intrinsic functions
|
||||
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Gy") # package individual functions
|
||||
|
||||
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${COMMON_CXX_FLAGS}")
|
||||
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /Ox") # enable full optimizations
|
||||
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /Oi") # inline intrinsic functions
|
||||
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /Gy") # package individual functions
|
||||
SET(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} /DEBUG") # generate debug information
|
||||
SET(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO} /DEBUG") # generate debug information
|
||||
|
||||
SET(SECURE_LINKER_FLAGS "")
|
||||
SET(SECURE_LINKER_FLAGS "${SECURE_LINKER_FLAGS} /NXCompat") # compatible with data execution prevention (on by default)
|
||||
SET(SECURE_LINKER_FLAGS "${SECURE_LINKER_FLAGS} /DynamicBase") # random rebase of executable at load time
|
||||
IF (CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||
SET(SECURE_LINKER_FLAGS "${SECURE_LINKER_FLAGS} /SafeSEH") # invoke known exception handlers (Win32 only, x64 exception handlers are safe by design)
|
||||
SET(COMMON_CXX_FLAGS "/EHsc /MP /GR /GS-")
|
||||
IF (${CMAKE_CXX_COMPILER_ID} STREQUAL "Intel")
|
||||
SET(COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} /Qdiag-disable:11074 ") # remark #11074: Inlining inhibited by limit max-size
|
||||
SET(COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} /Qdiag-disable:11075 ") # remark #11075: To get full report use -Qopt-report:4 -Qopt-report-phase ipo
|
||||
ENDIF()
|
||||
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${SECURE_LINKER_FLAGS}")
|
||||
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${SECURE_LINKER_FLAGS}")
|
||||
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${COMMON_CXX_FLAGS}")
|
||||
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${COMMON_CXX_FLAGS} /Ox /fp:fast /Oi /Gy /Qinline-max-total-size- /Qinline-factor=200 ")
|
||||
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${COMMON_CXX_FLAGS} /Ox /fp:fast /Oi /Gy /Qinline-max-total-size- /Qinline-factor=200 ")
|
||||
|
||||
SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /DEBUG")
|
||||
|
||||
IF (${CMAKE_CXX_COMPILER_ID} STREQUAL "Intel")
|
||||
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /Qdiag-disable:11082 ") # warning #11082: locally defined symbol XXX imported
|
||||
ENDIF()
|
||||
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /IGNORE:4217") # locally defined symbol XXX imported in function YYY (happens as the ISPC API layer uses exported library functions)
|
||||
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /IGNORE:4049") # warning LNK4049: locally defined symbol _rtcOccluded1M imported
|
||||
SET(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} /DEBUG")
|
||||
|
||||
INCLUDE(msvc_post)
|
||||
# optionally use static runtime library
|
||||
OPTION(EMBREE_STATIC_RUNTIME "Use the static version of the C/C++ runtime library." ON)
|
||||
IF (EMBREE_STATIC_RUNTIME)
|
||||
STRING(REPLACE "/MDd" "/MTd" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
|
||||
STRING(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELWITHDEBINFO ${CMAKE_CXX_FLAGS_RELWITHDEBINFO})
|
||||
STRING(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE})
|
||||
ENDIF()
|
||||
|
||||
# remove define NDEBUG and instead set define DEBUG for config RelWithDebInfo
|
||||
STRING(REPLACE "NDEBUG" "DEBUG" CMAKE_CXX_FLAGS_RELWITHDEBINFO ${CMAKE_CXX_FLAGS_RELWITHDEBINFO})
|
||||
@@ -1,26 +0,0 @@
|
||||
## ======================================================================== ##
|
||||
## Copyright 2009-2017 Intel Corporation ##
|
||||
## ##
|
||||
## Licensed under the Apache License, Version 2.0 (the "License"); ##
|
||||
## you may not use this file except in compliance with the License. ##
|
||||
## You may obtain a copy of the License at ##
|
||||
## ##
|
||||
## http://www.apache.org/licenses/LICENSE-2.0 ##
|
||||
## ##
|
||||
## Unless required by applicable law or agreed to in writing, software ##
|
||||
## distributed under the License is distributed on an "AS IS" BASIS, ##
|
||||
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ##
|
||||
## See the License for the specific language governing permissions and ##
|
||||
## limitations under the License. ##
|
||||
## ======================================================================== ##
|
||||
|
||||
# optionally use static runtime library
|
||||
OPTION(EMBREE_STATIC_RUNTIME "Use the static version of the C/C++ runtime library." ON)
|
||||
IF (EMBREE_STATIC_RUNTIME)
|
||||
STRING(REPLACE "/MDd" "/MTd" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
|
||||
STRING(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELWITHDEBINFO ${CMAKE_CXX_FLAGS_RELWITHDEBINFO})
|
||||
STRING(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE})
|
||||
ENDIF()
|
||||
|
||||
# remove define NDEBUG and instead set define DEBUG for config RelWithDebInfo
|
||||
STRING(REPLACE "NDEBUG" "DEBUG" CMAKE_CXX_FLAGS_RELWITHDEBINFO ${CMAKE_CXX_FLAGS_RELWITHDEBINFO})
|
||||
+18
-54
@@ -1,5 +1,5 @@
|
||||
## ======================================================================== ##
|
||||
## Copyright 2009-2017 Intel Corporation ##
|
||||
## Copyright 2009-2016 Intel Corporation ##
|
||||
## ##
|
||||
## Licensed under the Apache License, Version 2.0 (the "License"); ##
|
||||
## you may not use this file except in compliance with the License. ##
|
||||
@@ -25,21 +25,20 @@ IF (NOT EMBREE_ZIP_MODE AND NOT WIN32 AND NOT APPLE)
|
||||
SET(CMAKE_INSTALL_FULL_BINDIR ${CMAKE_INSTALL_FULL_BINDIR}/embree${EMBREE_VERSION_MAJOR})
|
||||
ENDIF()
|
||||
|
||||
# use full absolute path as install name
|
||||
# use full absolute path as install name for PKG installer under MacOSX
|
||||
IF (NOT EMBREE_ZIP_MODE)
|
||||
SET(CMAKE_INSTALL_NAME_DIR ${CMAKE_INSTALL_FULL_LIBDIR})
|
||||
ELSE()
|
||||
IF(APPLE)
|
||||
SET(CMAKE_INSTALL_RPATH "@loader_path/../lib")
|
||||
ELSE()
|
||||
SET(CMAKE_INSTALL_RPATH "$ORIGIN/../lib")
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
##############################################################
|
||||
# Install Headers
|
||||
##############################################################
|
||||
|
||||
INSTALL(DIRECTORY include/embree2 DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT devel)
|
||||
CONFIGURE_FILE(include/embree2/rtcore.h rtcore.h @ONLY)
|
||||
CONFIGURE_FILE(include/embree2/rtcore.isph rtcore.isph @ONLY)
|
||||
INSTALL(FILES ${PROJECT_BINARY_DIR}/rtcore.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/embree2 COMPONENT devel)
|
||||
INSTALL(FILES ${PROJECT_BINARY_DIR}/rtcore.isph DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/embree2 COMPONENT devel)
|
||||
|
||||
##############################################################
|
||||
# Install Models
|
||||
@@ -94,32 +93,19 @@ IF (APPLE AND NOT EMBREE_ZIP_MODE)
|
||||
INSTALL(PROGRAMS "${PROJECT_BINARY_DIR}/uninstall.command" DESTINATION ${CMAKE_INSTALL_BINDIR}/.. COMPONENT lib)
|
||||
ENDIF()
|
||||
|
||||
# why does this have to be so complicated...
|
||||
IF (WIN32)
|
||||
SET(EMBREE_LIBRARY_NAME ${CMAKE_IMPORT_LIBRARY_PREFIX}embree${CMAKE_IMPORT_LIBRARY_SUFFIX})
|
||||
CONFIGURE_FILE(common/cmake/embree-config-windows.cmake embree-config.cmake @ONLY)
|
||||
ELSEIF (APPLE)
|
||||
SET(EMBREE_LIBRARY_NAME ${CMAKE_SHARED_LIBRARY_PREFIX}embree.${EMBREE_CONFIG_VERSION}${CMAKE_SHARED_LIBRARY_SUFFIX})
|
||||
CONFIGURE_FILE(common/cmake/embree-config-macosx.cmake embree-config.cmake @ONLY)
|
||||
ELSE()
|
||||
SET(EMBREE_LIBRARY_NAME ${CMAKE_SHARED_LIBRARY_PREFIX}embree${CMAKE_SHARED_LIBRARY_SUFFIX}.${EMBREE_CONFIG_VERSION})
|
||||
CONFIGURE_FILE(common/cmake/embree-config-linux.cmake embree-config.cmake @ONLY)
|
||||
ENDIF()
|
||||
|
||||
IF (WIN32 OR EMBREE_ZIP_MODE)
|
||||
# for local "installs" and on Windows we want the cmake config files placed
|
||||
# in the install root, such that users can point the CMake variable
|
||||
# embree_DIR just to the install folder
|
||||
SET(EMBREE_CMAKECONFIG_DIR ".")
|
||||
SET(EMBREE_RELATIV_ROOT_DIR ".")
|
||||
ELSE()
|
||||
SET(EMBREE_CMAKECONFIG_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/embree-${EMBREE_VERSION}")
|
||||
SET(EMBREE_RELATIV_ROOT_DIR "../../..")
|
||||
ENDIF()
|
||||
CONFIGURE_FILE(common/cmake/embree-config.cmake embree-config-install.cmake @ONLY)
|
||||
CONFIGURE_FILE(common/cmake/embree-config-default.cmake embree-config-default.cmake @ONLY)
|
||||
CONFIGURE_FILE(common/cmake/embree-config-version.cmake embree-config-version.cmake @ONLY)
|
||||
# create a config file for the build directory
|
||||
CONFIGURE_FILE(common/cmake/embree-config-builddir.cmake embree-config.cmake @ONLY)
|
||||
|
||||
INSTALL(FILES "${PROJECT_BINARY_DIR}/embree-config-install.cmake" DESTINATION ${EMBREE_CMAKECONFIG_DIR} RENAME "embree-config.cmake" COMPONENT devel)
|
||||
INSTALL(FILES "${PROJECT_BINARY_DIR}/embree-config-version.cmake" DESTINATION ${EMBREE_CMAKECONFIG_DIR} COMPONENT devel)
|
||||
INSTALL(FILES "${PROJECT_BINARY_DIR}/embree-config.cmake" DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/embree-${EMBREE_VERSION}" COMPONENT devel)
|
||||
INSTALL(FILES "${PROJECT_BINARY_DIR}/embree-config-default.cmake" DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/embree-${EMBREE_VERSION}" COMPONENT devel)
|
||||
INSTALL(FILES "${PROJECT_BINARY_DIR}/embree-config-version.cmake" DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/embree-${EMBREE_VERSION}" COMPONENT devel)
|
||||
|
||||
##############################################################
|
||||
# CPack specific stuff
|
||||
@@ -129,7 +115,7 @@ SET(CPACK_PACKAGE_NAME "Embree")
|
||||
SET(CPACK_PACKAGE_FILE_NAME "embree-${EMBREE_VERSION}")
|
||||
#SET(CPACK_PACKAGE_ICON ${PROJECT_SOURCE_DIR}/embree-doc/images/icon.png)
|
||||
#SET(CPACK_PACKAGE_RELOCATABLE TRUE)
|
||||
SET(CPACK_STRIP_FILES TRUE)
|
||||
#SET(CPACK_STRIP_FILES TRUE) # keep symbols, useful for bug reports
|
||||
|
||||
SET(CPACK_PACKAGE_VERSION_MAJOR ${EMBREE_VERSION_MAJOR})
|
||||
SET(CPACK_PACKAGE_VERSION_MINOR ${EMBREE_VERSION_MINOR})
|
||||
@@ -188,16 +174,10 @@ IF(WIN32)
|
||||
#SET(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS ${CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS} "\n ${UNINSTALL_LIST}\n RMDir \\\"$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\documentation\\\"")
|
||||
#SET(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS ${CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS} "\n ${UNINSTALL_LIST}\n RMDir \\\"$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\tutorials\\\"")
|
||||
#SET(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS ${CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS} "\n ${UNINSTALL_LIST}\n RMDir \\\"$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\"\n")
|
||||
IF (EMBREE_TESTING_PACKAGE)
|
||||
ADD_TEST(NAME "BuildPackage" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${PROJECT_SOURCE_DIR}/scripts/package_win.bat ${CPACK_PACKAGE_FILE_NAME}.exe ${CMAKE_BUILD_TYPE})
|
||||
ENDIF()
|
||||
ELSE()
|
||||
SET(CPACK_GENERATOR ZIP)
|
||||
SET(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}.${ARCH}.windows")
|
||||
SET(CPACK_MONOLITHIC_INSTALL 1)
|
||||
IF (EMBREE_TESTING_PACKAGE)
|
||||
ADD_TEST(NAME "BuildPackage" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${PROJECT_SOURCE_DIR}/scripts/package_win.bat ${CPACK_PACKAGE_FILE_NAME}.zip ${CMAKE_BUILD_TYPE})
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
# MacOSX specific settings
|
||||
@@ -215,16 +195,10 @@ ELSEIF(APPLE)
|
||||
SET(CPACK_PACKAGE_NAME embree-${EMBREE_VERSION})
|
||||
SET(CPACK_PACKAGE_VENDOR "intel") # creates short name com.intel.embree2.xxx in pkgutil
|
||||
SET(CPACK_OSX_PACKAGE_VERSION 10.7)
|
||||
IF (EMBREE_TESTING_PACKAGE)
|
||||
ADD_TEST(NAME "BuildPackage" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${PROJECT_SOURCE_DIR}/scripts/package_macosx.sh ${CMAKE_BUILD_TYPE} ${CPACK_PACKAGE_FILE_NAME}.dmg)
|
||||
ENDIF()
|
||||
ELSE()
|
||||
SET(CPACK_GENERATOR TGZ)
|
||||
SET(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}.x86_64.macosx")
|
||||
SET(CPACK_MONOLITHIC_INSTALL 1)
|
||||
IF (EMBREE_TESTING_PACKAGE)
|
||||
ADD_TEST(NAME "BuildPackage" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${PROJECT_SOURCE_DIR}/scripts/package_macosx.sh ${CMAKE_BUILD_TYPE} ${CPACK_PACKAGE_FILE_NAME}.tgz)
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
# Linux specific settings
|
||||
@@ -234,33 +208,23 @@ ELSE()
|
||||
IF (NOT EMBREE_ZIP_MODE)
|
||||
|
||||
SET(CPACK_GENERATOR RPM)
|
||||
SET(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}-${CPACK_RPM_PACKAGE_RELEASE}.x86_64")
|
||||
SET(CPACK_COMPONENTS_ALL devel lib examples)
|
||||
SET(CPACK_RPM_COMPONENT_INSTALL ON)
|
||||
SET(CPACK_RPM_FILE_NAME RPM-DEFAULT)
|
||||
SET(CPACK_RPM_devel_PACKAGE_ARCHITECTURE noarch)
|
||||
SET(CPACK_RPM_PACKAGE_LICENSE "ASL 2.0") # Apache Software License, Version 2.0
|
||||
SET(CPACK_RPM_PACKAGE_GROUP "Development/Libraries")
|
||||
SET(CPACK_RPM_CHANGELOG_FILE ${CMAKE_BINARY_DIR}/rpm_changelog.txt) # ChangeLog of the RPM
|
||||
STRING(TIMESTAMP CHANGELOG_DATE "%a %b %d %Y")
|
||||
SET(RPM_CHANGELOG "* ${CHANGELOG_DATE} Johannes Günther <johannes.guenther@intel.com> - ${EMBREE_VERSION}-${CPACK_RPM_PACKAGE_RELEASE}\n- First package")
|
||||
FILE(WRITE ${CPACK_RPM_CHANGELOG_FILE} ${RPM_CHANGELOG})
|
||||
#SET(CPACK_RPM_CHANGELOG_FILE "") # ChangeLog of the RPM; also CHANGELOG.md is not in the required format
|
||||
SET(CPACK_RPM_PACKAGE_ARCHITECTURE x86_64)
|
||||
SET(CPACK_RPM_PACKAGE_URL http://embree.github.io/)
|
||||
SET(CPACK_RPM_DEFAULT_DIR_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) # otherwise cmake directory has wrong 775 permissions
|
||||
|
||||
# post install and uninstall scripts
|
||||
SET(CPACK_RPM_lib_POST_INSTALL_SCRIPT_FILE ${PROJECT_SOURCE_DIR}/common/cmake/rpm_ldconfig.sh)
|
||||
SET(CPACK_RPM_lib_POST_UNINSTALL_SCRIPT_FILE ${PROJECT_SOURCE_DIR}/common/cmake/rpm_ldconfig.sh)
|
||||
IF (EMBREE_TESTING_PACKAGE)
|
||||
ADD_TEST(NAME "BuildPackage" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${PROJECT_SOURCE_DIR}/scripts/package_linux.sh ${EMBREE_ZIP_MODE} ${EMBREE_VERSION})
|
||||
ENDIF()
|
||||
ELSE()
|
||||
|
||||
SET(CPACK_GENERATOR TGZ)
|
||||
SET(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}.x86_64.linux")
|
||||
SET(CPACK_MONOLITHIC_INSTALL 1)
|
||||
IF (EMBREE_TESTING_PACKAGE)
|
||||
ADD_TEST(NAME "BuildPackage" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${PROJECT_SOURCE_DIR}/scripts/package_linux.sh ${EMBREE_ZIP_MODE} ${EMBREE_VERSION})
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
ENDIF()
|
||||
+2
-14
@@ -1,5 +1,5 @@
|
||||
## ======================================================================== ##
|
||||
## Copyright 2009-2017 Intel Corporation ##
|
||||
## Copyright 2009-2016 Intel Corporation ##
|
||||
## ##
|
||||
## Licensed under the Apache License, Version 2.0 (the "License"); ##
|
||||
## you may not use this file except in compliance with the License. ##
|
||||
@@ -24,16 +24,11 @@ IF (BUILD_TESTING)
|
||||
|
||||
CMAKE_HOST_SYSTEM_INFORMATION(RESULT memory QUERY TOTAL_PHYSICAL_MEMORY)
|
||||
|
||||
SET(EMBREE_TESTING_MODEL_DIR "${PROJECT_SOURCE_DIR}/models" CACHE PATH "Path to the folder containing the Embree models for regression testing.")
|
||||
SET(EMBREE_TESTING_MODEL_DIR "${PROJECT_SOURCE_DIR}/models" CACHE FILEPATH "Path to the folder containing the Embree models for regression testing.")
|
||||
SET(EMBREE_TESTING_INTENSIVE OFF CACHE BOOL "Turns intensive testing on.")
|
||||
SET(EMBREE_TESTING_MEMCHECK OFF CACHE BOOL "Turns on memory checking for some tests.")
|
||||
SET(EMBREE_TESTING_BENCHMARK OFF CACHE BOOL "Turns benchmarking on.")
|
||||
SET(EMBREE_TESTING_BENCHMARK_DATABASE "${PROJECT_BINARY_DIR}" CACHE PATH "Path to database for benchmarking.")
|
||||
SET(EMBREE_TESTING_PACKAGE OFF CACHE BOOL "Packages release as test.")
|
||||
SET(EMBREE_TESTING_KLOCWORK OFF CACHE BOOL "Runs Kocwork as test.")
|
||||
|
||||
SET(EMBREE_TESTING_SDE OFF CACHE STRING "Uses SDE to run tests for specified CPU.")
|
||||
SET_PROPERTY(CACHE EMBREE_TESTING_SDE PROPERTY STRINGS OFF pnr nhm wsm snb ivb hsw bdw knl skl skx cnl)
|
||||
|
||||
IF( NOT EXISTS "${EMBREE_TESTING_MODEL_DIR}/embree-models-subdiv.txt"
|
||||
OR NOT EXISTS "${EMBREE_TESTING_MODEL_DIR}/embree-models-small-win32.txt"
|
||||
@@ -78,7 +73,6 @@ IF (BUILD_TESTING)
|
||||
--modeldir ${EMBREE_TESTING_MODEL_DIR}
|
||||
--reference ${reference}
|
||||
--model ${model}
|
||||
--sde ${EMBREE_TESTING_SDE}
|
||||
--execute ${MY_PROJECT_BINARY_DIR}/${executable} ${args})
|
||||
|
||||
IF (EMBREE_ISPC_SUPPORT AND EMBREE_RAY_PACKETS)
|
||||
@@ -89,7 +83,6 @@ IF (BUILD_TESTING)
|
||||
--modeldir ${EMBREE_TESTING_MODEL_DIR}
|
||||
--reference ${reference}
|
||||
--model ${model}
|
||||
--sde ${EMBREE_TESTING_SDE}
|
||||
--execute ${MY_PROJECT_BINARY_DIR}/${executable}_ispc ${args})
|
||||
ENDIF()
|
||||
ENDMACRO()
|
||||
@@ -110,11 +103,6 @@ IF (BUILD_TESTING)
|
||||
ENDFOREACH()
|
||||
ENDMACRO()
|
||||
|
||||
IF (EMBREE_TESTING_KLOCWORK)
|
||||
ADD_TEST(NAME Klocwork WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${PROJECT_SOURCE_DIR}/scripts/klocwork.sh)
|
||||
SET_TESTS_PROPERTIES(Klocwork PROPERTIES TIMEOUT 2400)
|
||||
ENDIF()
|
||||
|
||||
ELSE()
|
||||
|
||||
MACRO (ADD_EMBREE_MODEL_TEST name reference executable args model)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
## ======================================================================== ##
|
||||
## Copyright 2009-2017 Intel Corporation ##
|
||||
## Copyright 2009-2016 Intel Corporation ##
|
||||
## ##
|
||||
## Licensed under the Apache License, Version 2.0 (the "License"); ##
|
||||
## you may not use this file except in compliance with the License. ##
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
## ======================================================================== ##
|
||||
## Copyright 2009-2017 Intel Corporation ##
|
||||
## Copyright 2009-2016 Intel Corporation ##
|
||||
## ##
|
||||
## Licensed under the Apache License, Version 2.0 (the "License"); ##
|
||||
## you may not use this file except in compliance with the License. ##
|
||||
@@ -18,5 +18,6 @@ ADD_LIBRARY(lexers STATIC
|
||||
stringstream.cpp
|
||||
tokenstream.cpp
|
||||
)
|
||||
TARGET_LINK_LIBRARIES(lexers sys math)
|
||||
|
||||
TARGET_LINK_LIBRARIES(lexers sys)
|
||||
SET_PROPERTY(TARGET lexers PROPERTY FOLDER common)
|
||||
@@ -1,5 +1,5 @@
|
||||
// ======================================================================== //
|
||||
// Copyright 2009-2017 Intel Corporation //
|
||||
// Copyright 2009-2016 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
|
||||
+43
-40
@@ -1,5 +1,5 @@
|
||||
// ======================================================================== //
|
||||
// Copyright 2009-2017 Intel Corporation //
|
||||
// Copyright 2009-2016 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
@@ -28,25 +28,31 @@
|
||||
|
||||
namespace embree
|
||||
{
|
||||
class String : public RefCount {
|
||||
public:
|
||||
String(std::string str) : str(str) {}
|
||||
std::string str;
|
||||
};
|
||||
|
||||
/*! stores the location of a stream element in the source */
|
||||
class ParseLocation
|
||||
{
|
||||
public:
|
||||
ParseLocation () : lineNumber(-1), colNumber(-1), charNumber(-1) {}
|
||||
ParseLocation (std::shared_ptr<std::string> fileName, ssize_t lineNumber, ssize_t colNumber, ssize_t charNumber)
|
||||
ParseLocation () : fileName(nullptr), lineNumber(-1), colNumber(-1), charNumber(-1) {}
|
||||
ParseLocation (Ref<String> fileName, ssize_t lineNumber, ssize_t colNumber, ssize_t charNumber)
|
||||
: fileName(fileName), lineNumber(lineNumber), colNumber(colNumber), charNumber(charNumber) {}
|
||||
|
||||
std::string str() const
|
||||
{
|
||||
std::string str = "unknown";
|
||||
if (fileName) str = *fileName;
|
||||
if (fileName) str = fileName->str;
|
||||
if (lineNumber >= 0) str += " line " + toString(lineNumber);
|
||||
if (lineNumber >= 0 && colNumber >= 0) str += " character " + toString(colNumber);
|
||||
return str;
|
||||
}
|
||||
|
||||
private:
|
||||
std::shared_ptr<std::string> fileName; /// name of the file (or stream) the token is from
|
||||
Ref<String> fileName; /// name of the file (or stream) the token is from
|
||||
ssize_t lineNumber; /// the line number the token is from
|
||||
ssize_t colNumber; /// the character number in the current line
|
||||
ssize_t charNumber; /// the character in the file
|
||||
@@ -56,33 +62,33 @@ namespace embree
|
||||
template<typename T> class Stream : public RefCount
|
||||
{
|
||||
enum { BUF_SIZE = 1024 };
|
||||
|
||||
|
||||
private:
|
||||
virtual T next() = 0;
|
||||
virtual ParseLocation location() = 0;
|
||||
__forceinline std::pair<T,ParseLocation> nextHelper() {
|
||||
ParseLocation l = location();
|
||||
T v = next();
|
||||
return std::pair<T,ParseLocation>(v,l);
|
||||
}
|
||||
__forceinline void push_back(const std::pair<T,ParseLocation>& v) {
|
||||
if (past+future == BUF_SIZE) pop_front();
|
||||
int end = (start+past+future++)%BUF_SIZE;
|
||||
buffer[end] = v;
|
||||
}
|
||||
__forceinline void pop_front() {
|
||||
if (past == 0) THROW_RUNTIME_ERROR("stream buffer empty");
|
||||
start = (start+1)%BUF_SIZE; past--;
|
||||
}
|
||||
__forceinline std::pair<T,ParseLocation> nextHelper() {
|
||||
ParseLocation l = location();
|
||||
T v = next();
|
||||
return std::pair<T,ParseLocation>(v,l);
|
||||
}
|
||||
__forceinline void push_back(const std::pair<T,ParseLocation>& v) {
|
||||
if (past+future == BUF_SIZE) pop_front();
|
||||
int end = (start+past+future++)%BUF_SIZE;
|
||||
buffer[end] = v;
|
||||
}
|
||||
__forceinline void pop_front() {
|
||||
if (past == 0) THROW_RUNTIME_ERROR("stream buffer empty");
|
||||
start = (start+1)%BUF_SIZE; past--;
|
||||
}
|
||||
public:
|
||||
Stream () : start(0), past(0), future(0), buffer(BUF_SIZE) {}
|
||||
virtual ~Stream() {}
|
||||
|
||||
Stream () : start(0), past(0), future(0), buffer(BUF_SIZE) {}
|
||||
virtual ~Stream() {}
|
||||
|
||||
public:
|
||||
|
||||
const ParseLocation& loc() {
|
||||
if (future == 0) push_back(nextHelper());
|
||||
return buffer[(start+past)%BUF_SIZE].second;
|
||||
|
||||
const ParseLocation& loc() {
|
||||
if (future == 0) push_back(nextHelper());
|
||||
return buffer[(start+past)%BUF_SIZE].second;
|
||||
}
|
||||
T get() {
|
||||
if (future == 0) push_back(nextHelper());
|
||||
@@ -107,13 +113,13 @@ namespace embree
|
||||
size_t start,past,future;
|
||||
std::vector<std::pair<T,ParseLocation> > buffer;
|
||||
};
|
||||
|
||||
|
||||
/*! warps an iostream stream */
|
||||
class StdStream : public Stream<int>
|
||||
{
|
||||
public:
|
||||
StdStream (std::istream& cin, const std::string& name = "std::stream")
|
||||
: cin(cin), lineNumber(1), colNumber(0), charNumber(0), name(std::shared_ptr<std::string>(new std::string(name))) {}
|
||||
: cin(cin), lineNumber(1), colNumber(0), charNumber(0), name(new String(name)) {}
|
||||
~StdStream() {}
|
||||
ParseLocation location() {
|
||||
return ParseLocation(name,lineNumber,colNumber,charNumber);
|
||||
@@ -129,7 +135,7 @@ namespace embree
|
||||
ssize_t lineNumber; /// the line number the token is from
|
||||
ssize_t colNumber; /// the character number in the current line
|
||||
ssize_t charNumber; /// the character in the file
|
||||
std::shared_ptr<std::string> name; /// name of buffer
|
||||
Ref<String> name; /// name of buffer
|
||||
};
|
||||
|
||||
/*! creates a stream from a file */
|
||||
@@ -138,10 +144,10 @@ namespace embree
|
||||
public:
|
||||
|
||||
FileStream (FILE* file, const std::string& name = "file")
|
||||
: file(file), lineNumber(1), colNumber(0), charNumber(0), name(std::shared_ptr<std::string>(new std::string(name))) {}
|
||||
: file(file), lineNumber(1), colNumber(0), charNumber(0), name(new String(name)) {}
|
||||
|
||||
FileStream (const FileName& fileName)
|
||||
: lineNumber(1), colNumber(0), charNumber(0), name(std::shared_ptr<std::string>(new std::string(fileName.str())))
|
||||
: lineNumber(1), colNumber(0), charNumber(0), name(new String(fileName.str()))
|
||||
{
|
||||
file = fopen(fileName.c_str(),"r");
|
||||
if (file == nullptr) THROW_RUNTIME_ERROR("cannot open file " + fileName.str());
|
||||
@@ -165,7 +171,7 @@ namespace embree
|
||||
ssize_t lineNumber; /// the line number the token is from
|
||||
ssize_t colNumber; /// the character number in the current line
|
||||
ssize_t charNumber; /// the character in the file
|
||||
std::shared_ptr<std::string> name; /// name of buffer
|
||||
Ref<String> name; /// name of buffer
|
||||
};
|
||||
|
||||
/*! creates a stream from a string */
|
||||
@@ -178,7 +184,7 @@ namespace embree
|
||||
|
||||
public:
|
||||
ParseLocation location() {
|
||||
return ParseLocation(std::shared_ptr<std::string>(),lineNumber,colNumber,charNumber);
|
||||
return ParseLocation(nullptr,lineNumber,colNumber,charNumber);
|
||||
}
|
||||
|
||||
int next() {
|
||||
@@ -201,12 +207,9 @@ namespace embree
|
||||
{
|
||||
public:
|
||||
CommandLineStream (int argc, char** argv, const std::string& name = "command line")
|
||||
: i(0), j(0), charNumber(0), name(std::shared_ptr<std::string>(new std::string(name)))
|
||||
: i(0), j(0), charNumber(0), name(new String(name))
|
||||
{
|
||||
if (argc > 0) {
|
||||
for (size_t i=0; argv[0][i] && i<1024; i++) charNumber++;
|
||||
charNumber++;
|
||||
}
|
||||
if (argc > 0) charNumber = strlen(argv[0])+1;
|
||||
for (ssize_t k=1; k<argc; k++) args.push_back(argv[k]);
|
||||
}
|
||||
~CommandLineStream() {}
|
||||
@@ -224,6 +227,6 @@ namespace embree
|
||||
size_t i,j;
|
||||
std::vector<std::string> args;
|
||||
ssize_t charNumber; /// the character in the file
|
||||
std::shared_ptr<std::string> name; /// name of buffer
|
||||
Ref<String> name; /// name of buffer
|
||||
};
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
// ======================================================================== //
|
||||
// Copyright 2009-2017 Intel Corporation //
|
||||
// Copyright 2009-2016 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ======================================================================== //
|
||||
// Copyright 2009-2017 Intel Corporation //
|
||||
// Copyright 2009-2016 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ======================================================================== //
|
||||
// Copyright 2009-2017 Intel Corporation //
|
||||
// Copyright 2009-2016 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ======================================================================== //
|
||||
// Copyright 2009-2017 Intel Corporation //
|
||||
// Copyright 2009-2016 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ======================================================================== //
|
||||
// Copyright 2009-2017 Intel Corporation //
|
||||
// Copyright 2009-2016 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
@@ -107,7 +107,7 @@ namespace embree
|
||||
if (t.ty == TY_INT) return cout << "Int(" << t.i << ")";
|
||||
if (t.ty == TY_FLOAT) return cout << "Float(" << t.f << ")";
|
||||
if (t.ty == TY_IDENTIFIER) return cout << "Id(" << t.str << ")";
|
||||
if (t.ty == TY_STRING) return cout << "String(" << t.str << ")";
|
||||
if (t.ty == TY_STRING) return cout << "String(" + t.str + ")";
|
||||
if (t.ty == TY_SYMBOL) return cout << "Symbol(" << t.str << ")";
|
||||
return cout << "unknown";
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ======================================================================== //
|
||||
// Copyright 2009-2017 Intel Corporation //
|
||||
// Copyright 2009-2016 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
@@ -132,20 +132,6 @@ namespace embree
|
||||
template<typename L> __forceinline bool operator ==( const AffineSpaceT<L>& a, const AffineSpaceT<L>& b ) { return a.l == b.l && a.p == b.p; }
|
||||
template<typename L> __forceinline bool operator !=( const AffineSpaceT<L>& a, const AffineSpaceT<L>& b ) { return a.l != b.l || a.p != b.p; }
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// Select
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template<typename L> __forceinline AffineSpaceT<L> select ( const typename L::Vector::Scalar::Bool& s, const AffineSpaceT<L>& t, const AffineSpaceT<L>& f ) {
|
||||
return AffineSpaceT<L>(select(s,t.l,f.l),select(s,t.p,f.p));
|
||||
}
|
||||
|
||||
/*! blending */
|
||||
template<typename T>
|
||||
__forceinline AffineSpaceT<T> lerp(const AffineSpaceT<T>& l0, const AffineSpaceT<T>& l1, const float t) {
|
||||
return AffineSpaceT<T>(lerp(l0.l,l1.l,t),lerp(l0.p,l1.p,t));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Output Operators
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
+1
-122
@@ -1,5 +1,5 @@
|
||||
// ======================================================================== //
|
||||
// Copyright 2009-2017 Intel Corporation //
|
||||
// Copyright 2009-2016 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
@@ -56,11 +56,6 @@ namespace embree
|
||||
/*! computes twice the center of the box */
|
||||
__forceinline T center2() const { return lower+upper; }
|
||||
|
||||
/*! merges two boxes */
|
||||
__forceinline static const BBox merge (const BBox& a, const BBox& b) {
|
||||
return BBox(min(a.lower, b.lower), max(a.upper, b.upper));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// Constants
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -118,10 +113,6 @@ namespace embree
|
||||
|
||||
template<typename Vec> __forceinline float safeArea( const BBox<Vec>& b ) { if (b.empty()) return 0.0f; else return area(b); }
|
||||
|
||||
template<typename T> __forceinline float expectedApproxHalfArea(const BBox<T>& box) {
|
||||
return halfArea(box);
|
||||
}
|
||||
|
||||
/*! merges bounding boxes and points */
|
||||
template<typename T> __forceinline const BBox<T> merge( const BBox<T>& a, const T& b ) { return BBox<T>(min(a.lower, b ), max(a.upper, b )); }
|
||||
template<typename T> __forceinline const BBox<T> merge( const T& a, const BBox<T>& b ) { return BBox<T>(min(a , b.lower), max(a , b.upper)); }
|
||||
@@ -184,12 +175,6 @@ namespace embree
|
||||
return true;
|
||||
}
|
||||
|
||||
/*! blending */
|
||||
template<typename T>
|
||||
__forceinline BBox<T> lerp(const BBox<T>& b0, const BBox<T>& b1, const float t) {
|
||||
return BBox<T>(lerp(b0.lower,b1.lower,t),lerp(b0.upper,b1.upper,t));
|
||||
}
|
||||
|
||||
/*! output operator */
|
||||
template<typename T> __forceinline std::ostream& operator<<(std::ostream& cout, const BBox<T>& box) {
|
||||
return cout << "[" << box.lower << "; " << box.upper << "]";
|
||||
@@ -201,109 +186,3 @@ namespace embree
|
||||
typedef BBox<Vec3f> BBox3f;
|
||||
typedef BBox<Vec3fa> BBox3fa;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// SSE / AVX / MIC specializations
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if defined __SSE__
|
||||
#include "../simd/sse.h"
|
||||
#endif
|
||||
|
||||
#if defined __AVX__
|
||||
#include "../simd/avx.h"
|
||||
#endif
|
||||
|
||||
#if defined(__AVX512F__)
|
||||
#include "../simd/avx512.h"
|
||||
#endif
|
||||
|
||||
namespace embree
|
||||
{
|
||||
template<int N>
|
||||
__forceinline BBox<Vec3<vfloat<N>>> transpose(const BBox3fa* bounds);
|
||||
|
||||
template<>
|
||||
__forceinline BBox<Vec3<vfloat4>> transpose<4>(const BBox3fa* bounds)
|
||||
{
|
||||
BBox<Vec3<vfloat4>> dest;
|
||||
|
||||
transpose((vfloat4&)bounds[0].lower,
|
||||
(vfloat4&)bounds[1].lower,
|
||||
(vfloat4&)bounds[2].lower,
|
||||
(vfloat4&)bounds[3].lower,
|
||||
dest.lower.x,
|
||||
dest.lower.y,
|
||||
dest.lower.z);
|
||||
|
||||
transpose((vfloat4&)bounds[0].upper,
|
||||
(vfloat4&)bounds[1].upper,
|
||||
(vfloat4&)bounds[2].upper,
|
||||
(vfloat4&)bounds[3].upper,
|
||||
dest.upper.x,
|
||||
dest.upper.y,
|
||||
dest.upper.z);
|
||||
|
||||
return dest;
|
||||
}
|
||||
|
||||
#if defined(__AVX__)
|
||||
template<>
|
||||
__forceinline BBox<Vec3<vfloat8>> transpose<8>(const BBox3fa* bounds)
|
||||
{
|
||||
BBox<Vec3<vfloat8>> dest;
|
||||
|
||||
transpose((vfloat4&)bounds[0].lower,
|
||||
(vfloat4&)bounds[1].lower,
|
||||
(vfloat4&)bounds[2].lower,
|
||||
(vfloat4&)bounds[3].lower,
|
||||
(vfloat4&)bounds[4].lower,
|
||||
(vfloat4&)bounds[5].lower,
|
||||
(vfloat4&)bounds[6].lower,
|
||||
(vfloat4&)bounds[7].lower,
|
||||
dest.lower.x,
|
||||
dest.lower.y,
|
||||
dest.lower.z);
|
||||
|
||||
transpose((vfloat4&)bounds[0].upper,
|
||||
(vfloat4&)bounds[1].upper,
|
||||
(vfloat4&)bounds[2].upper,
|
||||
(vfloat4&)bounds[3].upper,
|
||||
(vfloat4&)bounds[4].upper,
|
||||
(vfloat4&)bounds[5].upper,
|
||||
(vfloat4&)bounds[6].upper,
|
||||
(vfloat4&)bounds[7].upper,
|
||||
dest.upper.x,
|
||||
dest.upper.y,
|
||||
dest.upper.z);
|
||||
|
||||
return dest;
|
||||
}
|
||||
#endif
|
||||
|
||||
template<int N>
|
||||
__forceinline BBox3fa merge(const BBox3fa* bounds);
|
||||
|
||||
template<>
|
||||
__forceinline BBox3fa merge<4>(const BBox3fa* bounds)
|
||||
{
|
||||
const Vec3fa lower = min(min(bounds[0].lower,bounds[1].lower),
|
||||
min(bounds[2].lower,bounds[3].lower));
|
||||
const Vec3fa upper = max(max(bounds[0].upper,bounds[1].upper),
|
||||
max(bounds[2].upper,bounds[3].upper));
|
||||
return BBox3fa(lower,upper);
|
||||
}
|
||||
|
||||
#if defined(__AVX__)
|
||||
template<>
|
||||
__forceinline BBox3fa merge<8>(const BBox3fa* bounds)
|
||||
{
|
||||
const Vec3fa lower = min(min(min(bounds[0].lower,bounds[1].lower),min(bounds[2].lower,bounds[3].lower)),
|
||||
min(min(bounds[4].lower,bounds[5].lower),min(bounds[6].lower,bounds[7].lower)));
|
||||
const Vec3fa upper = max(max(max(bounds[0].upper,bounds[1].upper),max(bounds[2].upper,bounds[3].upper)),
|
||||
max(max(bounds[4].upper,bounds[5].upper),max(bounds[6].upper,bounds[7].upper)));
|
||||
return BBox3fa(lower,upper);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
// ======================================================================== //
|
||||
// Copyright 2009-2017 Intel Corporation //
|
||||
// Copyright 2009-2016 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
// ======================================================================== //
|
||||
// Copyright 2009-2017 Intel Corporation //
|
||||
// Copyright 2009-2016 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
|
||||
+8
-14
@@ -1,5 +1,5 @@
|
||||
// ======================================================================== //
|
||||
// Copyright 2009-2017 Intel Corporation //
|
||||
// Copyright 2009-2016 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
@@ -163,22 +163,12 @@ namespace embree
|
||||
const __m128 mask = _mm_castsi128_ps(_mm_set1_epi32(0x7fffffff));
|
||||
return _mm_and_ps(a.m128, mask);
|
||||
}
|
||||
__forceinline const Color rcp ( const Color& a )
|
||||
{
|
||||
#if defined(__AVX512VL__)
|
||||
const Color r = _mm_rcp14_ps(a.m128);
|
||||
#else
|
||||
__forceinline const Color rcp ( const Color& a ) {
|
||||
const Color r = _mm_rcp_ps(a.m128);
|
||||
#endif
|
||||
return _mm_sub_ps(_mm_add_ps(r, r), _mm_mul_ps(_mm_mul_ps(r, r), a));
|
||||
}
|
||||
__forceinline const Color rsqrt( const Color& a )
|
||||
{
|
||||
#if defined(__AVX512VL__)
|
||||
__m128 r = _mm_rsqrt14_ps(a.m128);
|
||||
#else
|
||||
__forceinline const Color rsqrt( const Color& a ) {
|
||||
__m128 r = _mm_rsqrt_ps(a.m128);
|
||||
#endif
|
||||
return _mm_add_ps(_mm_mul_ps(_mm_set1_ps(1.5f),r), _mm_mul_ps(_mm_mul_ps(_mm_mul_ps(a, _mm_set1_ps(-0.5f)), r), _mm_mul_ps(r, r)));
|
||||
}
|
||||
__forceinline const Color sqrt ( const Color& a ) { return _mm_sqrt_ps(a.m128); }
|
||||
@@ -245,7 +235,11 @@ namespace embree
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/*! computes luminance of a color */
|
||||
__forceinline float luminance (const Color& a) { return madd(0.212671f,a.r,madd(0.715160f,a.g,0.072169f*a.b)); }
|
||||
__forceinline float luminance (const Color& a) { return 0.212671f*a.r + 0.715160f*a.g + 0.072169f*a.b; }
|
||||
|
||||
__forceinline Color exp (const Color& a) { return Color(exp_ps(a.m128)); }
|
||||
__forceinline Color log (const Color& a) { return Color(log_ps(a.m128)); }
|
||||
__forceinline Color pow (const Color& a, const float& b) { return Color(select(vfloat4(a)<=vfloat4(zero),vfloat4(zero),vfloat4(exp_ps(log(a)*b)))); }
|
||||
|
||||
/*! output operator */
|
||||
inline std::ostream& operator<<(std::ostream& cout, const Color& a) {
|
||||
|
||||
+37
-74
@@ -1,5 +1,5 @@
|
||||
// ======================================================================== //
|
||||
// Copyright 2009-2017 Intel Corporation //
|
||||
// Copyright 2009-2016 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
@@ -32,19 +32,15 @@ namespace embree
|
||||
/* we consider floating point numbers in that range as valid input numbers */
|
||||
static float FLT_LARGE = 1.844E18f;
|
||||
|
||||
struct TrueTy {
|
||||
static struct TrueTy {
|
||||
__forceinline operator bool( ) const { return true; }
|
||||
};
|
||||
} True MAYBE_UNUSED;
|
||||
|
||||
extern MAYBE_UNUSED TrueTy True;
|
||||
|
||||
struct FalseTy {
|
||||
static struct FalseTy {
|
||||
__forceinline operator bool( ) const { return false; }
|
||||
};
|
||||
|
||||
extern MAYBE_UNUSED FalseTy False;
|
||||
} False MAYBE_UNUSED;
|
||||
|
||||
struct ZeroTy
|
||||
static struct ZeroTy
|
||||
{
|
||||
__forceinline operator double ( ) const { return 0; }
|
||||
__forceinline operator float ( ) const { return 0; }
|
||||
@@ -58,11 +54,9 @@ namespace embree
|
||||
__forceinline operator unsigned short ( ) const { return 0; }
|
||||
__forceinline operator char ( ) const { return 0; }
|
||||
__forceinline operator unsigned char ( ) const { return 0; }
|
||||
};
|
||||
} zero MAYBE_UNUSED;
|
||||
|
||||
extern MAYBE_UNUSED ZeroTy zero;
|
||||
|
||||
struct OneTy
|
||||
static struct OneTy
|
||||
{
|
||||
__forceinline operator double ( ) const { return 1; }
|
||||
__forceinline operator float ( ) const { return 1; }
|
||||
@@ -76,11 +70,9 @@ namespace embree
|
||||
__forceinline operator unsigned short ( ) const { return 1; }
|
||||
__forceinline operator char ( ) const { return 1; }
|
||||
__forceinline operator unsigned char ( ) const { return 1; }
|
||||
};
|
||||
} one MAYBE_UNUSED;
|
||||
|
||||
extern MAYBE_UNUSED OneTy one;
|
||||
|
||||
struct NegInfTy
|
||||
static struct NegInfTy
|
||||
{
|
||||
__forceinline operator double ( ) const { return -std::numeric_limits<double>::infinity(); }
|
||||
__forceinline operator float ( ) const { return -std::numeric_limits<float>::infinity(); }
|
||||
@@ -95,11 +87,9 @@ namespace embree
|
||||
__forceinline operator char ( ) const { return std::numeric_limits<char>::min(); }
|
||||
__forceinline operator unsigned char ( ) const { return std::numeric_limits<unsigned char>::min(); }
|
||||
|
||||
};
|
||||
} neg_inf MAYBE_UNUSED;
|
||||
|
||||
extern MAYBE_UNUSED NegInfTy neg_inf;
|
||||
|
||||
struct PosInfTy
|
||||
static struct PosInfTy
|
||||
{
|
||||
__forceinline operator double ( ) const { return std::numeric_limits<double>::infinity(); }
|
||||
__forceinline operator float ( ) const { return std::numeric_limits<float>::infinity(); }
|
||||
@@ -113,92 +103,65 @@ namespace embree
|
||||
__forceinline operator unsigned short ( ) const { return std::numeric_limits<unsigned short>::max(); }
|
||||
__forceinline operator char ( ) const { return std::numeric_limits<char>::max(); }
|
||||
__forceinline operator unsigned char ( ) const { return std::numeric_limits<unsigned char>::max(); }
|
||||
};
|
||||
} inf MAYBE_UNUSED, pos_inf MAYBE_UNUSED;
|
||||
|
||||
extern MAYBE_UNUSED PosInfTy inf;
|
||||
extern MAYBE_UNUSED PosInfTy pos_inf;
|
||||
|
||||
struct NaNTy
|
||||
static struct NaNTy
|
||||
{
|
||||
__forceinline operator double( ) const { return std::numeric_limits<double>::quiet_NaN(); }
|
||||
__forceinline operator float ( ) const { return std::numeric_limits<float>::quiet_NaN(); }
|
||||
};
|
||||
} nan MAYBE_UNUSED;
|
||||
|
||||
extern MAYBE_UNUSED NaNTy nan;
|
||||
|
||||
struct UlpTy
|
||||
static struct UlpTy
|
||||
{
|
||||
__forceinline operator double( ) const { return std::numeric_limits<double>::epsilon(); }
|
||||
__forceinline operator float ( ) const { return std::numeric_limits<float>::epsilon(); }
|
||||
};
|
||||
} ulp MAYBE_UNUSED;
|
||||
|
||||
extern MAYBE_UNUSED UlpTy ulp;
|
||||
|
||||
struct PiTy
|
||||
static struct PiTy
|
||||
{
|
||||
__forceinline operator double( ) const { return double(M_PI); }
|
||||
__forceinline operator float ( ) const { return float(M_PI); }
|
||||
};
|
||||
} pi MAYBE_UNUSED;
|
||||
|
||||
extern MAYBE_UNUSED PiTy pi;
|
||||
|
||||
struct OneOverPiTy
|
||||
static struct OneOverPiTy
|
||||
{
|
||||
__forceinline operator double( ) const { return double(M_1_PI); }
|
||||
__forceinline operator float ( ) const { return float(M_1_PI); }
|
||||
};
|
||||
} one_over_pi MAYBE_UNUSED;
|
||||
|
||||
extern MAYBE_UNUSED OneOverPiTy one_over_pi;
|
||||
|
||||
struct TwoPiTy
|
||||
static struct TwoPiTy
|
||||
{
|
||||
__forceinline operator double( ) const { return double(2.0*M_PI); }
|
||||
__forceinline operator float ( ) const { return float(2.0*M_PI); }
|
||||
};
|
||||
} two_pi MAYBE_UNUSED;
|
||||
|
||||
extern MAYBE_UNUSED TwoPiTy two_pi;
|
||||
|
||||
struct OneOverTwoPiTy
|
||||
static struct OneOverTwoPiTy
|
||||
{
|
||||
__forceinline operator double( ) const { return double(0.5*M_1_PI); }
|
||||
__forceinline operator float ( ) const { return float(0.5*M_1_PI); }
|
||||
};
|
||||
} one_over_two_pi MAYBE_UNUSED;
|
||||
|
||||
extern MAYBE_UNUSED OneOverTwoPiTy one_over_two_pi;
|
||||
|
||||
struct FourPiTy
|
||||
static struct FourPiTy
|
||||
{
|
||||
__forceinline operator double( ) const { return double(4.0*M_PI); }
|
||||
__forceinline operator float ( ) const { return float(4.0*M_PI); }
|
||||
};
|
||||
} four_pi MAYBE_UNUSED;
|
||||
|
||||
extern MAYBE_UNUSED FourPiTy four_pi;
|
||||
|
||||
struct OneOverFourPiTy
|
||||
static struct OneOverFourPiTy
|
||||
{
|
||||
__forceinline operator double( ) const { return double(0.25*M_1_PI); }
|
||||
__forceinline operator float ( ) const { return float(0.25*M_1_PI); }
|
||||
};
|
||||
} one_over_four_pi MAYBE_UNUSED;
|
||||
|
||||
extern MAYBE_UNUSED OneOverFourPiTy one_over_four_pi;
|
||||
static struct StepTy {
|
||||
} step MAYBE_UNUSED;
|
||||
|
||||
struct StepTy {
|
||||
};
|
||||
static struct ReverseStepTy {
|
||||
} reverse_step MAYBE_UNUSED;
|
||||
|
||||
extern MAYBE_UNUSED StepTy step;
|
||||
static struct EmptyTy {
|
||||
} empty MAYBE_UNUSED;
|
||||
|
||||
struct ReverseStepTy {
|
||||
};
|
||||
|
||||
extern MAYBE_UNUSED ReverseStepTy reverse_step;
|
||||
|
||||
struct EmptyTy {
|
||||
};
|
||||
|
||||
extern MAYBE_UNUSED EmptyTy empty;
|
||||
|
||||
struct FullTy {
|
||||
};
|
||||
|
||||
extern MAYBE_UNUSED FullTy full;
|
||||
static struct FullTy {
|
||||
} full MAYBE_UNUSED;
|
||||
}
|
||||
+2
-134
@@ -1,5 +1,5 @@
|
||||
// ======================================================================== //
|
||||
// Copyright 2009-2017 Intel Corporation //
|
||||
// Copyright 2009-2016 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
@@ -17,19 +17,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "bbox.h"
|
||||
#include "range.h"
|
||||
|
||||
namespace embree
|
||||
{
|
||||
template<typename T>
|
||||
__forceinline std::pair<T,T> globalLinear(const std::pair<T,T>& v, const BBox1f& dt)
|
||||
{
|
||||
const float rcp_dt_size = float(1.0f)/dt.size();
|
||||
const T g0 = lerp(v.first,v.second,-dt.lower*rcp_dt_size);
|
||||
const T g1 = lerp(v.first,v.second,(1.0f-dt.lower)*rcp_dt_size);
|
||||
return std::make_pair(g0,g1);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
struct LBBox
|
||||
{
|
||||
@@ -68,78 +58,7 @@ namespace embree
|
||||
bounds0 = b0;
|
||||
bounds1 = b1;
|
||||
}
|
||||
|
||||
/*! calculates the linear bounds of a primitive for the specified time range */
|
||||
template<typename BoundsFunc>
|
||||
__forceinline LBBox(const BoundsFunc& bounds, const BBox1f& time_range, float numTimeSegments)
|
||||
{
|
||||
const float lower = time_range.lower*numTimeSegments;
|
||||
const float upper = time_range.upper*numTimeSegments;
|
||||
const float ilowerf = floor(lower);
|
||||
const float iupperf = ceil(upper);
|
||||
const int ilower = (int)ilowerf;
|
||||
const int iupper = (int)iupperf;
|
||||
|
||||
const BBox<T> blower0 = bounds(ilower);
|
||||
const BBox<T> bupper1 = bounds(iupper);
|
||||
|
||||
if (iupper-ilower == 1) {
|
||||
bounds0 = lerp(blower0, bupper1, lower-ilowerf);
|
||||
bounds1 = lerp(bupper1, blower0, iupperf-upper);
|
||||
return;
|
||||
}
|
||||
|
||||
const BBox<T> blower1 = bounds(ilower+1);
|
||||
const BBox<T> bupper0 = bounds(iupper-1);
|
||||
BBox<T> b0 = lerp(blower0, blower1, lower-ilowerf);
|
||||
BBox<T> b1 = lerp(bupper1, bupper0, iupperf-upper);
|
||||
|
||||
for (int i = ilower+1; i < iupper; i++)
|
||||
{
|
||||
const float f = (float(i)/numTimeSegments - time_range.lower) / time_range.size();
|
||||
const BBox<T> bt = lerp(b0, b1, f);
|
||||
const BBox<T> bi = bounds(i);
|
||||
const T dlower = min(bi.lower-bt.lower, T(zero));
|
||||
const T dupper = max(bi.upper-bt.upper, T(zero));
|
||||
b0.lower += dlower; b1.lower += dlower;
|
||||
b0.upper += dupper; b1.upper += dupper;
|
||||
}
|
||||
|
||||
bounds0 = b0;
|
||||
bounds1 = b1;
|
||||
}
|
||||
|
||||
/*! calculates the linear bounds of a primitive for the specified time range */
|
||||
template<typename BoundsFunc>
|
||||
__forceinline LBBox(const BoundsFunc& bounds, const range<int>& time_range, int numTimeSegments)
|
||||
{
|
||||
const int ilower = time_range.begin();
|
||||
const int iupper = time_range.end();
|
||||
|
||||
BBox<T> b0 = bounds(ilower);
|
||||
BBox<T> b1 = bounds(iupper);
|
||||
|
||||
if (iupper-ilower == 1) {
|
||||
bounds0 = b0;
|
||||
bounds1 = b1;
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = ilower+1; i<iupper; i++)
|
||||
{
|
||||
const float f = float(i - time_range.begin()) / float(time_range.size());
|
||||
const BBox<T> bt = lerp(b0, b1, f);
|
||||
const BBox<T> bi = bounds(i);
|
||||
const T dlower = min(bi.lower-bt.lower, T(zero));
|
||||
const T dupper = max(bi.upper-bt.upper, T(zero));
|
||||
b0.lower += dlower; b1.lower += dlower;
|
||||
b0.upper += dupper; b1.upper += dupper;
|
||||
}
|
||||
|
||||
bounds0 = b0;
|
||||
bounds1 = b1;
|
||||
}
|
||||
|
||||
|
||||
public:
|
||||
|
||||
__forceinline bool empty() const {
|
||||
@@ -154,34 +73,11 @@ namespace embree
|
||||
return lerp(bounds0,bounds1,t);
|
||||
}
|
||||
|
||||
__forceinline LBBox<T> interpolate( const BBox1f& dt ) const {
|
||||
return LBBox<T>(interpolate(dt.lower),interpolate(dt.upper));
|
||||
}
|
||||
|
||||
__forceinline void extend( const LBBox& other ) {
|
||||
bounds0.extend(other.bounds0);
|
||||
bounds1.extend(other.bounds1);
|
||||
}
|
||||
|
||||
__forceinline float expectedHalfArea() const;
|
||||
|
||||
__forceinline float expectedHalfArea(const BBox1f& dt) const {
|
||||
return interpolate(dt).expectedHalfArea();
|
||||
}
|
||||
|
||||
__forceinline float expectedApproxHalfArea() const {
|
||||
return 0.5f*(halfArea(bounds0) + halfArea(bounds1));
|
||||
}
|
||||
|
||||
/* calculates bounds for [0,1] time range from bounds in dt time range */
|
||||
__forceinline LBBox global(const BBox1f& dt) const
|
||||
{
|
||||
const float rcp_dt_size = 1.0f/dt.size();
|
||||
const BBox<T> b0 = interpolate(-dt.lower*rcp_dt_size);
|
||||
const BBox<T> b1 = interpolate((1.0f-dt.lower)*rcp_dt_size);
|
||||
return LBBox(b0,b1);
|
||||
}
|
||||
|
||||
/*! Comparison Operators */
|
||||
template<typename TT> friend __forceinline bool operator==( const LBBox<TT>& a, const LBBox<TT>& b ) { return a.bounds0 == b.bounds0 && a.bounds1 == b.bounds1; }
|
||||
template<typename TT> friend __forceinline bool operator!=( const LBBox<TT>& a, const LBBox<TT>& b ) { return a.bounds0 != b.bounds0 || a.bounds1 != b.bounds1; }
|
||||
@@ -195,34 +91,6 @@ namespace embree
|
||||
BBox<T> bounds0, bounds1;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
__forceinline T expectedArea(const T& a0, const T& a1, const T& b0, const T& b1)
|
||||
{
|
||||
const T da = a1-a0;
|
||||
const T db = b1-b0;
|
||||
return a0*b0+(a0*db+da*b0)*T(0.5f) + da*db*T(1.0f/3.0f);
|
||||
}
|
||||
|
||||
template<> __forceinline float LBBox<Vec3fa>::expectedHalfArea() const
|
||||
{
|
||||
const Vec3fa d0 = bounds0.size();
|
||||
const Vec3fa d1 = bounds1.size();
|
||||
return reduce_add(expectedArea(Vec3fa(d0.x,d0.y,d0.z),
|
||||
Vec3fa(d1.x,d1.y,d1.z),
|
||||
Vec3fa(d0.y,d0.z,d0.x),
|
||||
Vec3fa(d1.y,d1.z,d1.x)));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
__forceinline float expectedApproxHalfArea(const LBBox<T>& box) {
|
||||
return box.expectedApproxHalfArea();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
__forceinline LBBox<T> merge(const LBBox<T>& a, const LBBox<T>& b) {
|
||||
return LBBox<T>(merge(a.bounds0, b.bounds0), merge(a.bounds1, b.bounds1));
|
||||
}
|
||||
|
||||
/*! default template instantiations */
|
||||
typedef LBBox<float> LBBox1f;
|
||||
typedef LBBox<Vec2f> LBBox2f;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ======================================================================== //
|
||||
// Copyright 2009-2017 Intel Corporation //
|
||||
// Copyright 2009-2016 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ======================================================================== //
|
||||
// Copyright 2009-2017 Intel Corporation //
|
||||
// Copyright 2009-2016 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
@@ -156,7 +156,7 @@ namespace embree
|
||||
template<typename T> __forceinline LinearSpace3<T> operator -( const LinearSpace3<T>& a, const LinearSpace3<T>& b ) { return LinearSpace3<T>(a.vx-b.vx,a.vy-b.vy,a.vz-b.vz); }
|
||||
|
||||
template<typename T> __forceinline LinearSpace3<T> operator*(const typename T::Scalar & a, const LinearSpace3<T>& b) { return LinearSpace3<T>(a*b.vx, a*b.vy, a*b.vz); }
|
||||
template<typename T> __forceinline T operator*(const LinearSpace3<T>& a, const T & b) { return madd(T(b.x),a.vx,madd(T(b.y),a.vy,T(b.z)*a.vz)); }
|
||||
template<typename T> __forceinline T operator*(const LinearSpace3<T>& a, const T & b) { return b.x*a.vx + b.y*a.vy + b.z*a.vz; }
|
||||
template<typename T> __forceinline LinearSpace3<T> operator*(const LinearSpace3<T>& a, const LinearSpace3<T>& b) { return LinearSpace3<T>(a*b.vx, a*b.vy, a*b.vz); }
|
||||
|
||||
template<typename T> __forceinline LinearSpace3<T> operator/(const LinearSpace3<T>& a, const typename T::Scalar & b) { return LinearSpace3<T>(a.vx/b, a.vy/b, a.vz/b); }
|
||||
@@ -176,23 +176,6 @@ namespace embree
|
||||
template<typename T> __forceinline bool operator ==( const LinearSpace3<T>& a, const LinearSpace3<T>& b ) { return a.vx == b.vx && a.vy == b.vy && a.vz == b.vz; }
|
||||
template<typename T> __forceinline bool operator !=( const LinearSpace3<T>& a, const LinearSpace3<T>& b ) { return a.vx != b.vx || a.vy != b.vy || a.vz != b.vz; }
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// Select
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template<typename T> __forceinline LinearSpace3<T> select ( const typename T::Scalar::Bool& s, const LinearSpace3<T>& t, const LinearSpace3<T>& f ) {
|
||||
return LinearSpace3<T>(select(s,t.vx,f.vx),select(s,t.vy,f.vy),select(s,t.vz,f.vz));
|
||||
}
|
||||
|
||||
/*! blending */
|
||||
template<typename T>
|
||||
__forceinline LinearSpace3<T> lerp(const LinearSpace3<T>& l0, const LinearSpace3<T>& l1, const float t)
|
||||
{
|
||||
return LinearSpace3<T>(lerp(l0.vx,l1.vx,t),
|
||||
lerp(l0.vy,l1.vy,t),
|
||||
lerp(l0.vz,l1.vz,t));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// Output Operators
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
+10
-48
@@ -1,5 +1,5 @@
|
||||
// ======================================================================== //
|
||||
// Copyright 2009-2017 Intel Corporation //
|
||||
// Copyright 2009-2016 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
@@ -17,13 +17,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "../sys/platform.h"
|
||||
#include "../sys/intrinsics.h"
|
||||
#include "constants.h"
|
||||
#include <cmath>
|
||||
|
||||
#include <emmintrin.h>
|
||||
#include <xmmintrin.h>
|
||||
#include <immintrin.h>
|
||||
|
||||
#if defined(__WIN32__)
|
||||
#if (__MSV_VER <= 1700)
|
||||
@@ -60,17 +58,11 @@ namespace embree
|
||||
__forceinline float rcp ( const float x )
|
||||
{
|
||||
const __m128 a = _mm_set_ss(x);
|
||||
|
||||
#if defined(__AVX512VL__)
|
||||
const __m128 r = _mm_rcp14_ss(_mm_set_ss(0.0f),a);
|
||||
#else
|
||||
const __m128 r = _mm_rcp_ss(a);
|
||||
#endif
|
||||
|
||||
const __m128 r = _mm_rcp_ps(a);
|
||||
#if defined(__AVX2__)
|
||||
return _mm_cvtss_f32(_mm_mul_ss(r,_mm_fnmadd_ss(r, a, _mm_set_ss(2.0f))));
|
||||
return _mm_cvtss_f32(_mm_mul_ps(r,_mm_fnmadd_ps(r, a, _mm_set_ss(2.0f))));
|
||||
#else
|
||||
return _mm_cvtss_f32(_mm_mul_ss(r,_mm_sub_ss(_mm_set_ss(2.0f), _mm_mul_ss(r, a))));
|
||||
return _mm_cvtss_f32(_mm_mul_ps(r,_mm_sub_ps(_mm_set_ss(2.0f), _mm_mul_ps(r, a))));
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -83,23 +75,17 @@ namespace embree
|
||||
__forceinline float andf( const float x, const unsigned y ) {
|
||||
return _mm_cvtss_f32(_mm_and_ps(_mm_set_ss(x),_mm_castsi128_ps(_mm_set1_epi32(y))));
|
||||
}
|
||||
__forceinline float rsqrt( const float x )
|
||||
{
|
||||
__forceinline float rsqrt( const float x ) {
|
||||
const __m128 a = _mm_set_ss(x);
|
||||
#if defined(__AVX512VL__)
|
||||
const __m128 r = _mm_rsqrt14_ss(_mm_set_ss(0.0f),a);
|
||||
#else
|
||||
const __m128 r = _mm_rsqrt_ss(a);
|
||||
#endif
|
||||
const __m128 c = _mm_add_ss(_mm_mul_ss(_mm_set_ss(1.5f), r),
|
||||
_mm_mul_ss(_mm_mul_ss(_mm_mul_ss(a, _mm_set_ss(-0.5f)), r), _mm_mul_ss(r, r)));
|
||||
const __m128 r = _mm_rsqrt_ps(a);
|
||||
const __m128 c = _mm_add_ps(_mm_mul_ps(_mm_set_ps(1.5f, 1.5f, 1.5f, 1.5f), r),
|
||||
_mm_mul_ps(_mm_mul_ps(_mm_mul_ps(a, _mm_set_ps(-0.5f, -0.5f, -0.5f, -0.5f)), r), _mm_mul_ps(r, r)));
|
||||
return _mm_cvtss_f32(c);
|
||||
}
|
||||
|
||||
#if defined(__WIN32__) && (__MSC_VER <= 1700)
|
||||
__forceinline float nextafter(float x, float y) { if ((x<y) == (x>0)) return x*(1.1f+float(ulp)); else return x*(0.9f-float(ulp)); }
|
||||
__forceinline double nextafter(double x, double y) { return _nextafter(x, y); }
|
||||
__forceinline int roundf(float f) { return (int)(f + 0.5f); }
|
||||
#else
|
||||
__forceinline float nextafter(float x, float y) { return ::nextafterf(x, y); }
|
||||
__forceinline double nextafter(double x, double y) { return ::nextafter(x, y); }
|
||||
@@ -168,9 +154,6 @@ namespace embree
|
||||
}
|
||||
#endif
|
||||
|
||||
template<typename T>
|
||||
__forceinline T twice(const T& a) { return a+a; }
|
||||
|
||||
__forceinline int min(int a, int b) { return a<b ? a:b; }
|
||||
__forceinline unsigned min(unsigned a, unsigned b) { return a<b ? a:b; }
|
||||
__forceinline int64_t min(int64_t a, int64_t b) { return a<b ? a:b; }
|
||||
@@ -184,10 +167,6 @@ namespace embree
|
||||
template<typename T> __forceinline T min(const T& a, const T& b, const T& c, const T& d) { return min(min(a,b),min(c,d)); }
|
||||
template<typename T> __forceinline T min(const T& a, const T& b, const T& c, const T& d, const T& e) { return min(min(min(a,b),min(c,d)),e); }
|
||||
|
||||
template<typename T> __forceinline T mini(const T& a, const T& b, const T& c) { return mini(mini(a,b),c); }
|
||||
template<typename T> __forceinline T mini(const T& a, const T& b, const T& c, const T& d) { return mini(mini(a,b),mini(c,d)); }
|
||||
template<typename T> __forceinline T mini(const T& a, const T& b, const T& c, const T& d, const T& e) { return mini(mini(mini(a,b),mini(c,d)),e); }
|
||||
|
||||
__forceinline int max(int a, int b) { return a<b ? b:a; }
|
||||
__forceinline unsigned max(unsigned a, unsigned b) { return a<b ? b:a; }
|
||||
__forceinline int64_t max(int64_t a, int64_t b) { return a<b ? b:a; }
|
||||
@@ -201,10 +180,6 @@ namespace embree
|
||||
template<typename T> __forceinline T max(const T& a, const T& b, const T& c, const T& d) { return max(max(a,b),max(c,d)); }
|
||||
template<typename T> __forceinline T max(const T& a, const T& b, const T& c, const T& d, const T& e) { return max(max(max(a,b),max(c,d)),e); }
|
||||
|
||||
template<typename T> __forceinline T maxi(const T& a, const T& b, const T& c) { return maxi(maxi(a,b),c); }
|
||||
template<typename T> __forceinline T maxi(const T& a, const T& b, const T& c, const T& d) { return maxi(maxi(a,b),maxi(c,d)); }
|
||||
template<typename T> __forceinline T maxi(const T& a, const T& b, const T& c, const T& d, const T& e) { return maxi(maxi(maxi(a,b),maxi(c,d)),e); }
|
||||
|
||||
#if defined(__MACOSX__)
|
||||
__forceinline ssize_t min(ssize_t a, ssize_t b) { return a<b ? a:b; }
|
||||
__forceinline ssize_t max(ssize_t a, ssize_t b) { return a<b ? b:a; }
|
||||
@@ -272,12 +247,12 @@ namespace embree
|
||||
|
||||
template<typename V>
|
||||
__forceinline V lerp(const V& v0, const V& v1, const float t) {
|
||||
return madd(V(1.0f-t),v0,t*v1);
|
||||
return (1.0f-t)*v0 + t*v1;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
__forceinline T lerp2(const float x0, const float x1, const float x2, const float x3, const T& u, const T& v) {
|
||||
return madd((1.0f-u),madd((1.0f-v),T(x0),v*T(x2)),u*madd((1.0f-v),T(x1),v*T(x3)));
|
||||
return (1.0f-u)*(1.0f-v)*x0 + u*(1.0f-v)*x1 + (1.0f-u)*v*x2 + u*v*x3;
|
||||
}
|
||||
|
||||
/*! exchange */
|
||||
@@ -319,19 +294,6 @@ namespace embree
|
||||
return x | (y << 1) | (z << 2);
|
||||
}
|
||||
|
||||
#if defined(__AVX2__)
|
||||
|
||||
template<>
|
||||
__forceinline unsigned int bitInterleave(const unsigned int &xi, const unsigned int& yi, const unsigned int& zi)
|
||||
{
|
||||
const unsigned int xx = pdep(xi,0x49249249 /* 0b01001001001001001001001001001001 */ );
|
||||
const unsigned int yy = pdep(yi,0x92492492 /* 0b10010010010010010010010010010010 */);
|
||||
const unsigned int zz = pdep(zi,0x24924924 /* 0b00100100100100100100100100100100 */);
|
||||
return xx | yy | zz;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*! bit interleave operation for 64bit data types*/
|
||||
template<class T>
|
||||
__forceinline T bitInterleave64(const T& xin, const T& yin, const T& zin){
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
// ======================================================================== //
|
||||
// Copyright 2009-2017 Intel Corporation //
|
||||
// Copyright 2009-2016 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ======================================================================== //
|
||||
// Copyright 2009-2017 Intel Corporation //
|
||||
// Copyright 2009-2016 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
|
||||
+34
-47
@@ -1,5 +1,5 @@
|
||||
// ======================================================================== //
|
||||
// Copyright 2009-2017 Intel Corporation //
|
||||
// Copyright 2009-2016 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
@@ -24,27 +24,13 @@ namespace embree
|
||||
template<typename Ty>
|
||||
struct range
|
||||
{
|
||||
__forceinline range() {}
|
||||
__forceinline range () {}
|
||||
|
||||
__forceinline range(const Ty& begin)
|
||||
: _begin(begin), _end(begin+1) {}
|
||||
__forceinline range (const Ty& begin)
|
||||
: _begin(begin), _end(begin+1) {}
|
||||
|
||||
__forceinline range(const Ty& begin, const Ty& end)
|
||||
: _begin(begin), _end(end) {}
|
||||
|
||||
__forceinline range(const range& other)
|
||||
: _begin(other._begin), _end(other._end) {}
|
||||
|
||||
template<typename T1>
|
||||
__forceinline range(const range<T1>& other)
|
||||
: _begin(Ty(other._begin)), _end(Ty(other._end)) {}
|
||||
|
||||
template<typename T1>
|
||||
__forceinline range& operator =(const range<T1>& other) {
|
||||
_begin = other._begin;
|
||||
_end = other._end;
|
||||
return *this;
|
||||
}
|
||||
__forceinline range (const Ty& begin, const Ty& end)
|
||||
: _begin(begin), _end(end) {}
|
||||
|
||||
__forceinline Ty begin() const {
|
||||
return _begin;
|
||||
@@ -66,23 +52,12 @@ namespace embree
|
||||
return _end <= _begin;
|
||||
}
|
||||
|
||||
__forceinline Ty center() const {
|
||||
return (_begin + _end)/2;
|
||||
}
|
||||
|
||||
__forceinline std::pair<range,range> split() const
|
||||
{
|
||||
const Ty _center = center();
|
||||
const Ty _center = (_begin+_end)/2;
|
||||
return std::make_pair(range(_begin,_center),range(_center,_end));
|
||||
}
|
||||
|
||||
__forceinline void split(range& left_o, range& right_o) const
|
||||
{
|
||||
const Ty _center = center();
|
||||
left_o = range(_begin,_center);
|
||||
right_o = range(_center,_end);
|
||||
}
|
||||
|
||||
__forceinline friend bool operator< (const range& r0, const range& r1) {
|
||||
return r0.size() < r1.size();
|
||||
}
|
||||
@@ -100,44 +75,56 @@ namespace embree
|
||||
}
|
||||
|
||||
template<typename Ty>
|
||||
struct extended_range : public range<Ty>
|
||||
struct extended_range
|
||||
{
|
||||
__forceinline extended_range () {}
|
||||
|
||||
__forceinline extended_range (const Ty& begin)
|
||||
: range<Ty>(begin), _ext_end(begin+1) {}
|
||||
__forceinline extended_range (const Ty& begin)
|
||||
: _begin(begin), _end(begin+1), _ext_end(begin+1) {}
|
||||
|
||||
__forceinline extended_range (const Ty& begin, const Ty& end)
|
||||
: range<Ty>(begin,end), _ext_end(end) {}
|
||||
__forceinline extended_range (const Ty& begin, const Ty& end)
|
||||
: _begin(begin), _end(end), _ext_end(end) {}
|
||||
|
||||
__forceinline extended_range (const Ty& begin, const Ty& end, const Ty& ext_end)
|
||||
: range<Ty>(begin,end), _ext_end(ext_end) {}
|
||||
__forceinline extended_range (const Ty& begin, const Ty& end, const Ty& ext_end)
|
||||
: _begin(begin), _end(end), _ext_end(ext_end) {}
|
||||
|
||||
__forceinline Ty begin() const {
|
||||
return _begin;
|
||||
}
|
||||
|
||||
__forceinline Ty end() const {
|
||||
return _end;
|
||||
}
|
||||
|
||||
__forceinline Ty ext_end() const {
|
||||
return _ext_end;
|
||||
}
|
||||
|
||||
__forceinline Ty size() const {
|
||||
return _end - _begin;
|
||||
}
|
||||
|
||||
__forceinline Ty ext_size() const {
|
||||
return _ext_end - range<Ty>::_begin;
|
||||
return _ext_end - _begin;
|
||||
}
|
||||
|
||||
__forceinline Ty ext_range_size() const {
|
||||
return _ext_end - range<Ty>::_end;
|
||||
return _ext_end - _end;
|
||||
}
|
||||
|
||||
__forceinline bool has_ext_range() const {
|
||||
assert(_ext_end >= range<Ty>::_end);
|
||||
return (_ext_end - range<Ty>::_end) > 0;
|
||||
assert(_ext_end >= _end);
|
||||
return (_ext_end - _end) > 0;
|
||||
}
|
||||
|
||||
__forceinline void set_ext_range(const size_t ext_end){
|
||||
assert(ext_end >= range<Ty>::_end);
|
||||
assert(ext_end >= _end);
|
||||
_ext_end = ext_end;
|
||||
}
|
||||
|
||||
__forceinline void move_right(const size_t plus){
|
||||
range<Ty>::_begin += plus;
|
||||
range<Ty>::_end += plus;
|
||||
_begin += plus;
|
||||
_end += plus;
|
||||
_ext_end += plus;
|
||||
}
|
||||
|
||||
@@ -145,6 +132,6 @@ namespace embree
|
||||
return cout << "extended_range [" << r.begin() << ", " << r.end() << " (" << r.ext_end() << ")]";
|
||||
}
|
||||
|
||||
Ty _ext_end;
|
||||
Ty _begin, _end, _ext_end;
|
||||
};
|
||||
}
|
||||
+1
-6
@@ -1,5 +1,5 @@
|
||||
// ======================================================================== //
|
||||
// Copyright 2009-2017 Intel Corporation //
|
||||
// Copyright 2009-2016 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
@@ -97,11 +97,6 @@ namespace embree
|
||||
template<typename T> __forceinline const Vec2<T> nmadd ( const Vec2<T>& a, const Vec2<T>& b, const Vec2<T>& c) { return Vec2<T>(nmadd(a.x,b.x,c.x),nmadd(a.y,b.y,c.y) ); }
|
||||
template<typename T> __forceinline const Vec2<T> nmsub ( const Vec2<T>& a, const Vec2<T>& b, const Vec2<T>& c) { return Vec2<T>(nmsub(a.x,b.x,c.x),nmsub(a.y,b.y,c.y) ); }
|
||||
|
||||
template<typename T> __forceinline const Vec2<T> madd ( const T& a, const Vec2<T>& b, const Vec2<T>& c) { return Vec2<T>( madd(a,b.x,c.x), madd(a,b.y,c.y) ); }
|
||||
template<typename T> __forceinline const Vec2<T> msub ( const T& a, const Vec2<T>& b, const Vec2<T>& c) { return Vec2<T>( msub(a,b.x,c.x), msub(a,b.y,c.y) ); }
|
||||
template<typename T> __forceinline const Vec2<T> nmadd ( const T& a, const Vec2<T>& b, const Vec2<T>& c) { return Vec2<T>(nmadd(a,b.x,c.x),nmadd(a,b.y,c.y) ); }
|
||||
template<typename T> __forceinline const Vec2<T> nmsub ( const T& a, const Vec2<T>& b, const Vec2<T>& c) { return Vec2<T>(nmsub(a,b.x,c.x),nmsub(a,b.y,c.y) ); }
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// Assignment Operators
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
+6
-16
@@ -1,5 +1,5 @@
|
||||
// ======================================================================== //
|
||||
// Copyright 2009-2017 Intel Corporation //
|
||||
// Copyright 2009-2016 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
@@ -107,11 +107,6 @@ namespace embree
|
||||
template<typename T> __forceinline const Vec3<T> nmadd ( const Vec3<T>& a, const Vec3<T>& b, const Vec3<T>& c) { return Vec3<T>(nmadd(a.x,b.x,c.x),nmadd(a.y,b.y,c.y),nmadd(a.z,b.z,c.z));}
|
||||
template<typename T> __forceinline const Vec3<T> nmsub ( const Vec3<T>& a, const Vec3<T>& b, const Vec3<T>& c) { return Vec3<T>(nmsub(a.x,b.x,c.x),nmsub(a.y,b.y,c.y),nmsub(a.z,b.z,c.z)); }
|
||||
|
||||
template<typename T> __forceinline const Vec3<T> madd ( const T& a, const Vec3<T>& b, const Vec3<T>& c) { return Vec3<T>( madd(a,b.x,c.x), madd(a,b.y,c.y), madd(a,b.z,c.z)); }
|
||||
template<typename T> __forceinline const Vec3<T> msub ( const T& a, const Vec3<T>& b, const Vec3<T>& c) { return Vec3<T>( msub(a,b.x,c.x), msub(a,b.y,c.y), msub(a,b.z,c.z)); }
|
||||
template<typename T> __forceinline const Vec3<T> nmadd ( const T& a, const Vec3<T>& b, const Vec3<T>& c) { return Vec3<T>(nmadd(a,b.x,c.x),nmadd(a,b.y,c.y),nmadd(a,b.z,c.z));}
|
||||
template<typename T> __forceinline const Vec3<T> nmsub ( const T& a, const Vec3<T>& b, const Vec3<T>& c) { return Vec3<T>(nmsub(a,b.x,c.x),nmsub(a,b.y,c.y),nmsub(a,b.z,c.z)); }
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// Assignment Operators
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -162,7 +157,7 @@ namespace embree
|
||||
|
||||
template<typename T>
|
||||
__forceinline Vec3<T> lerp(const Vec3<T>& v0, const Vec3<T>& v1, const T& t) {
|
||||
return madd(Vec3<T>(T(1.0f)-t),v0,t*v1);
|
||||
return (T(1.0f)-t)*v0 + t*v1;
|
||||
}
|
||||
|
||||
template<typename T> __forceinline int maxDim ( const Vec3<T>& a )
|
||||
@@ -213,7 +208,7 @@ namespace embree
|
||||
|
||||
template<typename T> __forceinline T sum ( const Vec3<T>& a ) { return a.x+a.y+a.z; }
|
||||
|
||||
template<typename T> __forceinline T halfArea ( const Vec3<T>& d ) { return madd(d.x,(d.y+d.z),d.y*d.z); }
|
||||
template<typename T> __forceinline T halfArea ( const Vec3<T>& d ) { return d.x*(d.y+d.z)+d.y*d.z; }
|
||||
template<typename T> __forceinline T area ( const Vec3<T>& d ) { return 2.0f*halfArea(d); }
|
||||
|
||||
template<typename T> __forceinline Vec3<T> normalize_safe( const Vec3<T>& a ) {
|
||||
@@ -276,17 +271,10 @@ namespace embree
|
||||
|
||||
template<> __forceinline Vec3<float>::Vec3( const Vec3fa& a ) { x = a.x; y = a.y; z = a.z; }
|
||||
|
||||
#if defined(__AVX__)
|
||||
template<> __forceinline Vec3<vfloat4>::Vec3( const Vec3fa& a ) {
|
||||
x = a.x; y = a.y; z = a.z;
|
||||
}
|
||||
#elif defined(__SSE__)
|
||||
#if defined (__SSE__)
|
||||
template<> __forceinline Vec3<vfloat4>::Vec3( const Vec3fa& a ) {
|
||||
const vfloat4 v = vfloat4(a); x = shuffle<0,0,0,0>(v); y = shuffle<1,1,1,1>(v); z = shuffle<2,2,2,2>(v);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(__SSE__)
|
||||
__forceinline Vec3<vfloat4> broadcast4f( const Vec3<vfloat4>& a, const size_t k ) {
|
||||
return Vec3<vfloat4>(vfloat4::broadcast(&a.x[k]), vfloat4::broadcast(&a.y[k]), vfloat4::broadcast(&a.z[k]));
|
||||
}
|
||||
@@ -299,6 +287,7 @@ namespace embree
|
||||
template<size_t i0, size_t i1, size_t i2, size_t i3> __forceinline const Vec3<vfloat4> shuffle( const Vec3<vfloat4>& b ) {
|
||||
return Vec3<vfloat4>(shuffle<i0,i1,i2,i3>(b.x),shuffle<i0,i1,i2,i3>(b.y),shuffle<i0,i1,i2,i3>(b.z));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(__AVX__)
|
||||
@@ -327,6 +316,7 @@ namespace embree
|
||||
template<size_t i0, size_t i1, size_t i2, size_t i3> __forceinline const Vec3<vfloat8> shuffle( const Vec3<vfloat8>& b ) {
|
||||
return Vec3<vfloat8>(shuffle<i0,i1,i2,i3>(b.x),shuffle<i0,i1,i2,i3>(b.y),shuffle<i0,i1,i2,i3>(b.z));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(__AVX512F__)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ======================================================================== //
|
||||
// Copyright 2009-2017 Intel Corporation //
|
||||
// Copyright 2009-2016 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
|
||||
+4
-25
@@ -1,5 +1,5 @@
|
||||
// ======================================================================== //
|
||||
// Copyright 2009-2017 Intel Corporation //
|
||||
// Copyright 2009-2016 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
@@ -121,38 +121,22 @@ namespace embree
|
||||
__forceinline const Vec3fa sign ( const Vec3fa& a ) {
|
||||
return blendv_ps(Vec3fa(one), -Vec3fa(one), _mm_cmplt_ps (a,Vec3fa(zero)));
|
||||
}
|
||||
|
||||
__forceinline const Vec3fa rcp ( const Vec3fa& a )
|
||||
{
|
||||
#if defined(__AVX512VL__)
|
||||
const Vec3fa r = _mm_rcp14_ps(a.m128);
|
||||
#else
|
||||
__forceinline const Vec3fa rcp ( const Vec3fa& a ) {
|
||||
const Vec3fa r = _mm_rcp_ps(a.m128);
|
||||
#endif
|
||||
|
||||
#if defined(__AVX2__)
|
||||
const Vec3fa res = _mm_mul_ps(r,_mm_fnmadd_ps(r, a, vfloat4(2.0f)));
|
||||
#else
|
||||
const Vec3fa res = _mm_mul_ps(r,_mm_sub_ps(vfloat4(2.0f), _mm_mul_ps(r, a)));
|
||||
//return _mm_sub_ps(_mm_add_ps(r, r), _mm_mul_ps(_mm_mul_ps(r, r), a));
|
||||
#endif
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
__forceinline const Vec3fa sqrt ( const Vec3fa& a ) { return _mm_sqrt_ps(a.m128); }
|
||||
__forceinline const Vec3fa sqr ( const Vec3fa& a ) { return _mm_mul_ps(a,a); }
|
||||
|
||||
__forceinline const Vec3fa rsqrt( const Vec3fa& a )
|
||||
{
|
||||
#if defined(__AVX512VL__)
|
||||
__m128 r = _mm_rsqrt14_ps(a.m128);
|
||||
#else
|
||||
__forceinline const Vec3fa rsqrt( const Vec3fa& a ) {
|
||||
__m128 r = _mm_rsqrt_ps(a.m128);
|
||||
#endif
|
||||
return _mm_add_ps(_mm_mul_ps(_mm_set1_ps(1.5f),r), _mm_mul_ps(_mm_mul_ps(_mm_mul_ps(a, _mm_set1_ps(-0.5f)), r), _mm_mul_ps(r, r)));
|
||||
}
|
||||
|
||||
__forceinline const Vec3fa zero_fix(const Vec3fa& a) {
|
||||
return blendv_ps(a, _mm_set1_ps(min_rcp_input), _mm_cmplt_ps (abs(a).m128, _mm_set1_ps(min_rcp_input)));
|
||||
}
|
||||
@@ -221,11 +205,6 @@ namespace embree
|
||||
__forceinline Vec3fa nmsub ( const Vec3fa& a, const Vec3fa& b, const Vec3fa& c) { return -a*b-c; }
|
||||
#endif
|
||||
|
||||
__forceinline Vec3fa madd ( const float a, const Vec3fa& b, const Vec3fa& c) { return madd(Vec3fa(a),b,c); }
|
||||
__forceinline Vec3fa msub ( const float a, const Vec3fa& b, const Vec3fa& c) { return msub(Vec3fa(a),b,c); }
|
||||
__forceinline Vec3fa nmadd ( const float a, const Vec3fa& b, const Vec3fa& c) { return nmadd(Vec3fa(a),b,c); }
|
||||
__forceinline Vec3fa nmsub ( const float a, const Vec3fa& b, const Vec3fa& c) { return nmsub(Vec3fa(a),b,c); }
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// Assignment Operators
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -297,7 +276,7 @@ namespace embree
|
||||
__forceinline float length ( const Vec3fa& a ) { return sqrt(dot(a,a)); }
|
||||
__forceinline Vec3fa normalize( const Vec3fa& a ) { return a*rsqrt(dot(a,a)); }
|
||||
__forceinline float distance ( const Vec3fa& a, const Vec3fa& b ) { return length(a-b); }
|
||||
__forceinline float halfArea ( const Vec3fa& d ) { return madd(d.x,(d.y+d.z),d.y*d.z); }
|
||||
__forceinline float halfArea ( const Vec3fa& d ) { return d.x*(d.y+d.z)+d.y*d.z; }
|
||||
__forceinline float area ( const Vec3fa& d ) { return 2.0f*halfArea(d); }
|
||||
|
||||
__forceinline Vec3fa normalize_safe( const Vec3fa& a ) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ======================================================================== //
|
||||
// Copyright 2009-2017 Intel Corporation //
|
||||
// Copyright 2009-2016 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
|
||||
+2
-28
@@ -1,5 +1,5 @@
|
||||
// ======================================================================== //
|
||||
// Copyright 2009-2017 Intel Corporation //
|
||||
// Copyright 2009-2016 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
@@ -95,20 +95,6 @@ namespace embree
|
||||
template<typename T> __forceinline Vec4<T> min(const Vec4<T>& a, const Vec4<T>& b) { return Vec4<T>(min(a.x, b.x), min(a.y, b.y), min(a.z, b.z), min(a.w, b.w)); }
|
||||
template<typename T> __forceinline Vec4<T> max(const Vec4<T>& a, const Vec4<T>& b) { return Vec4<T>(max(a.x, b.x), max(a.y, b.y), max(a.z, b.z), max(a.w, b.w)); }
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// Ternary Operators
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template<typename T> __forceinline const Vec4<T> madd ( const Vec4<T>& a, const Vec4<T>& b, const Vec4<T>& c) { return Vec4<T>( madd(a.x,b.x,c.x), madd(a.y,b.y,c.y), madd(a.z,b.z,c.z), madd(a.w,b.w,c.w)); }
|
||||
template<typename T> __forceinline const Vec4<T> msub ( const Vec4<T>& a, const Vec4<T>& b, const Vec4<T>& c) { return Vec4<T>( msub(a.x,b.x,c.x), msub(a.y,b.y,c.y), msub(a.z,b.z,c.z), msub(a.w,b.w,c.w)); }
|
||||
template<typename T> __forceinline const Vec4<T> nmadd ( const Vec4<T>& a, const Vec4<T>& b, const Vec4<T>& c) { return Vec4<T>(nmadd(a.x,b.x,c.x),nmadd(a.y,b.y,c.y),nmadd(a.z,b.z,c.z),nmadd(a.w,b.w,c.w)); }
|
||||
template<typename T> __forceinline const Vec4<T> nmsub ( const Vec4<T>& a, const Vec4<T>& b, const Vec4<T>& c) { return Vec4<T>(nmsub(a.x,b.x,c.x),nmsub(a.y,b.y,c.y),nmsub(a.z,b.z,c.z),nmsub(a.w,b.w,c.w)); }
|
||||
|
||||
template<typename T> __forceinline const Vec4<T> madd ( const T& a, const Vec4<T>& b, const Vec4<T>& c) { return Vec4<T>( madd(a,b.x,c.x), madd(a,b.y,c.y), madd(a,b.z,c.z), madd(a,b.w,c.w)); }
|
||||
template<typename T> __forceinline const Vec4<T> msub ( const T& a, const Vec4<T>& b, const Vec4<T>& c) { return Vec4<T>( msub(a,b.x,c.x), msub(a,b.y,c.y), msub(a,b.z,c.z), msub(a,b.w,c.w)); }
|
||||
template<typename T> __forceinline const Vec4<T> nmadd ( const T& a, const Vec4<T>& b, const Vec4<T>& c) { return Vec4<T>(nmadd(a,b.x,c.x),nmadd(a,b.y,c.y),nmadd(a,b.z,c.z),nmadd(a,b.w,c.w)); }
|
||||
template<typename T> __forceinline const Vec4<T> nmsub ( const T& a, const Vec4<T>& b, const Vec4<T>& c) { return Vec4<T>(nmsub(a,b.x,c.x),nmsub(a,b.y,c.y),nmsub(a,b.z,c.z),nmsub(a,b.w,c.w)); }
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// Assignment Operators
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -175,11 +161,6 @@ namespace embree
|
||||
return Vec4<T>(select(s,t.x,f.x),select(s,t.y,f.y),select(s,t.z,f.z),select(s,t.w,f.w));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
__forceinline Vec4<T> lerp(const Vec4<T>& v0, const Vec4<T>& v1, const T& t) {
|
||||
return madd(Vec4<T>(T(1.0f)-t),v0,t*v1);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// Output Operators
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -222,17 +203,10 @@ namespace embree
|
||||
{
|
||||
template<> __forceinline Vec4<float>::Vec4( const Vec3fa& a ) { x = a.x; y = a.y; z = a.z; w = a.w; }
|
||||
|
||||
#if defined(__AVX__)
|
||||
template<> __forceinline Vec4<vfloat4>::Vec4( const Vec3fa& a ) {
|
||||
x = a.x; y = a.y; z = a.z; w = a.w;
|
||||
}
|
||||
#elif defined(__SSE__)
|
||||
#if defined (__SSE__)
|
||||
template<> __forceinline Vec4<vfloat4>::Vec4( const Vec3fa& a ) {
|
||||
const vfloat4 v = vfloat4(a); x = shuffle<0,0,0,0>(v); y = shuffle<1,1,1,1>(v); z = shuffle<2,2,2,2>(v); w = shuffle<3,3,3,3>(v);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(__SSE__)
|
||||
__forceinline Vec4<vfloat4> broadcast4f( const Vec4<vfloat4>& a, const size_t k ) {
|
||||
return Vec4<vfloat4>(vfloat4::broadcast(&a.x[k]), vfloat4::broadcast(&a.y[k]), vfloat4::broadcast(&a.z[k]), vfloat4::broadcast(&a.w[k]));
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
## ======================================================================== ##
|
||||
## Copyright 2009-2017 Intel Corporation ##
|
||||
## Copyright 2009-2016 Intel Corporation ##
|
||||
## ##
|
||||
## Licensed under the Apache License, Version 2.0 (the "License"); ##
|
||||
## you may not use this file except in compliance with the License. ##
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
// ======================================================================== //
|
||||
// Copyright 2009-2017 Intel Corporation //
|
||||
// Copyright 2009-2016 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
@@ -29,7 +29,7 @@
|
||||
#if defined(__AVX2__)
|
||||
#include "vint8_avx2.h"
|
||||
#if defined(__X86_64__)
|
||||
#include "vllong4_avx2.h"
|
||||
#include "vlong4_avx2.h"
|
||||
#endif
|
||||
#else
|
||||
#include "vint8_avx.h"
|
||||
|
||||
+71
-2
@@ -1,5 +1,5 @@
|
||||
// ======================================================================== //
|
||||
// Copyright 2009-2017 Intel Corporation //
|
||||
// Copyright 2009-2016 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
@@ -21,13 +21,18 @@
|
||||
#include "../math/constants.h"
|
||||
#include "varying.h"
|
||||
|
||||
#if !defined(_MM_SHUF_PERM)
|
||||
#define _MM_SHUF_PERM(e3, e2, e1, e0) ((_MM_PERM_ENUM)((e3)*64 + (e2)*16 + (e1)*4 + (e0)))
|
||||
#define _MM_SHUF_PERM_NONE _MM_SHUF_PERM(3,2,1,0)
|
||||
#endif
|
||||
|
||||
#include "vboolf16_avx512.h"
|
||||
#include "vint16_avx512.h"
|
||||
#include "vfloat16_avx512.h"
|
||||
|
||||
#include "vuint16_avx512.h"
|
||||
#include "vboold8_avx512.h"
|
||||
#include "vllong8_avx512.h"
|
||||
#include "vlong8_avx512.h"
|
||||
#include "vdouble8_avx512.h"
|
||||
|
||||
namespace embree
|
||||
@@ -39,6 +44,9 @@ namespace embree
|
||||
#define PFHINT_L1 0
|
||||
#define PFHINT_L2 1
|
||||
#define PFHINT_NT 2
|
||||
#define PFHINT_L1EX 3
|
||||
#define PFHINT_L2EX 4
|
||||
#define PFHINT_NTEX 5
|
||||
|
||||
template<const unsigned int mode>
|
||||
__forceinline void prefetch(const void * __restrict__ const m)
|
||||
@@ -49,5 +57,66 @@ namespace embree
|
||||
_mm_prefetch((const char*)m,_MM_HINT_T1);
|
||||
else if (mode == PFHINT_NT)
|
||||
_mm_prefetch((const char*)m,_MM_HINT_NTA);
|
||||
else if (mode == PFHINT_L1EX)
|
||||
_mm_prefetch((const char*)m,_MM_HINT_ET0);
|
||||
else if (mode == PFHINT_L2EX)
|
||||
_mm_prefetch((const char*)m,_MM_HINT_ET2);
|
||||
else if (mode == PFHINT_NTEX)
|
||||
_mm_prefetch((const char*)m,_MM_HINT_ENTA);
|
||||
}
|
||||
|
||||
__forceinline void gather_prefetch(const vboolf16 &m_active,
|
||||
const void *const ptr,
|
||||
const vint16 index,
|
||||
const int mode = _MM_HINT_T2,
|
||||
const _MM_INDEX_SCALE_ENUM scale = _MM_SCALE_4,
|
||||
const _MM_UPCONV_PS_ENUM up = _MM_UPCONV_PS_NONE)
|
||||
{
|
||||
#if defined(__AVX512PF__)
|
||||
_mm512_mask_prefetch_i32extgather_ps(index,m_active,ptr,up,scale,mode);
|
||||
#endif
|
||||
}
|
||||
|
||||
__forceinline void scatter_prefetch(const vboolf16 &m_active,
|
||||
void *const ptr,
|
||||
const vint16 index,
|
||||
const int mode = _MM_HINT_ET2,
|
||||
const _MM_INDEX_SCALE_ENUM scale = _MM_SCALE_4,
|
||||
const _MM_UPCONV_PS_ENUM up = _MM_UPCONV_PS_NONE)
|
||||
{
|
||||
#if defined(__AVX512PF__)
|
||||
_mm512_mask_prefetch_i32extscatter_ps(ptr,m_active,index,up,scale,mode);
|
||||
#endif
|
||||
}
|
||||
|
||||
template<const int D, const int C, const int B, const int A>
|
||||
__forceinline vfloat16 lshuf(const vfloat16 &in)
|
||||
{
|
||||
return _mm512_permute4f128_ps(in,(_MM_PERM_ENUM)_MM_SHUF_PERM(D,C,B,A));
|
||||
}
|
||||
|
||||
|
||||
template<const int D, const int C, const int B, const int A>
|
||||
__forceinline vfloat16 lshuf(const vboolf16 &mask, vfloat16 &dest, const vfloat16 &in)
|
||||
{
|
||||
return _mm512_mask_permute4f128_ps(dest,mask,in,(_MM_PERM_ENUM) _MM_SHUF_PERM(D,C,B,A));
|
||||
}
|
||||
|
||||
template<const int lane>
|
||||
__forceinline vfloat16 lane_shuffle_gather(const vfloat16 &v0,const vfloat16 &v1,const vfloat16 &v2,const vfloat16 &v3)
|
||||
{
|
||||
vfloat16 t = lshuf<lane,lane,lane,lane>(v0);
|
||||
t = lshuf<lane,lane,lane,lane>(0xf0,t,v1);
|
||||
t = lshuf<lane,lane,lane,lane>(0xf00,t,v2);
|
||||
t = lshuf<lane,lane,lane,lane>(0xf000,t,v3);
|
||||
return t;
|
||||
}
|
||||
|
||||
__forceinline vint16 mul_uint64_t( const vint16& a, const vint16& b) {
|
||||
const vint16 low = _mm512_mullo_epi32(a, b);
|
||||
const vint16 high = _mm512_mulhi_epu32(a, b);
|
||||
return select(0x5555,low,high);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
+1
-1
@@ -1,5 +1,5 @@
|
||||
// ======================================================================== //
|
||||
// Copyright 2009-2017 Intel Corporation //
|
||||
// Copyright 2009-2016 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
|
||||
+2
-3
@@ -1,5 +1,5 @@
|
||||
// ======================================================================== //
|
||||
// Copyright 2009-2017 Intel Corporation //
|
||||
// Copyright 2009-2016 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
@@ -16,8 +16,7 @@
|
||||
|
||||
#include "sse.h"
|
||||
|
||||
namespace embree
|
||||
{
|
||||
namespace embree {
|
||||
const __m128 _mm_lookupmask_ps[16] = {
|
||||
_mm_castsi128_ps(_mm_set_epi32( 0, 0, 0, 0)),
|
||||
_mm_castsi128_ps(_mm_set_epi32( 0, 0, 0,-1)),
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
// ======================================================================== //
|
||||
// Copyright 2009-2017 Intel Corporation //
|
||||
// Copyright 2009-2016 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "../sys/intrinsics.h"
|
||||
#include "../math/constants.h"
|
||||
#include "varying.h"
|
||||
#include "sse_special.h"
|
||||
|
||||
namespace embree
|
||||
{
|
||||
@@ -43,5 +44,4 @@ namespace embree
|
||||
#include "vboolf4_sse2.h"
|
||||
#endif
|
||||
#include "vint4_sse2.h"
|
||||
#include "vuint4_sse2.h"
|
||||
#include "vfloat4_sse2.h"
|
||||
@@ -0,0 +1,761 @@
|
||||
/* SIMD (SSE1+MMX or SSE2) implementation of sin, cos, exp and log
|
||||
|
||||
Inspired by Intel Approximate Math library, and based on the
|
||||
corresponding algorithms of the cephes math library
|
||||
|
||||
The default is to use the SSE1 version. If you define USE_SSE2 the
|
||||
the SSE2 intrinsics will be used in place of the MMX intrinsics. Do
|
||||
not expect any significant performance improvement with SSE2.
|
||||
*/
|
||||
|
||||
/* Copyright (C) 2007 Julien Pommier
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
(this is the zlib license)
|
||||
*/
|
||||
|
||||
#include <xmmintrin.h>
|
||||
|
||||
/* yes I know, the top of this file is quite ugly */
|
||||
|
||||
#ifdef _MSC_VER /* visual c++ */
|
||||
# define ALIGN16_BEG __declspec(align(16))
|
||||
# define ALIGN16_END
|
||||
# define USE_SSE2
|
||||
#else /* gcc or icc */
|
||||
# define ALIGN16_BEG
|
||||
# define ALIGN16_END __attribute__((aligned(16)))
|
||||
#endif
|
||||
|
||||
/* __m128 is ugly to write */
|
||||
typedef __m128 v4sf; // vector of 4 float (sse1)
|
||||
|
||||
#ifdef USE_SSE2
|
||||
# include <emmintrin.h>
|
||||
typedef __m128i v4si; // vector of 4 int (sse2)
|
||||
#else
|
||||
typedef __m64 v2si; // vector of 2 int (mmx)
|
||||
#endif
|
||||
|
||||
/* declare some SSE constants -- why can't I figure a better way to do that? */
|
||||
#define _PS_CONST(Name, Val) \
|
||||
static const ALIGN16_BEG float _ps_##Name[4] ALIGN16_END = { Val, Val, Val, Val }
|
||||
#define _PI32_CONST(Name, Val) \
|
||||
static const ALIGN16_BEG int _pi32_##Name[4] ALIGN16_END = { Val, Val, Val, Val }
|
||||
#define _PS_CONST_TYPE(Name, Type, Val) \
|
||||
static const ALIGN16_BEG Type _ps_##Name[4] ALIGN16_END = { Val, Val, Val, Val }
|
||||
|
||||
_PS_CONST(1 , 1.0f);
|
||||
_PS_CONST(0p5, 0.5f);
|
||||
/* the smallest non denormalized float number */
|
||||
_PS_CONST_TYPE(min_norm_pos, int, int(0x00800000));
|
||||
_PS_CONST_TYPE(mant_mask, int, int(0x7f800000));
|
||||
_PS_CONST_TYPE(inv_mant_mask, int, int(~0x7f800000));
|
||||
|
||||
_PS_CONST_TYPE(sign_mask, int, int(0x80000000));
|
||||
_PS_CONST_TYPE(inv_sign_mask, int, int(~0x80000000));
|
||||
|
||||
_PI32_CONST(1, 1);
|
||||
_PI32_CONST(inv1, ~1);
|
||||
_PI32_CONST(2, 2);
|
||||
_PI32_CONST(4, 4);
|
||||
_PI32_CONST(0x7f, 0x7f);
|
||||
|
||||
_PS_CONST(cephes_SQRTHF, 0.707106781186547524f);
|
||||
_PS_CONST(cephes_log_p0, 7.0376836292E-2f);
|
||||
_PS_CONST(cephes_log_p1, - 1.1514610310E-1f);
|
||||
_PS_CONST(cephes_log_p2, 1.1676998740E-1f);
|
||||
_PS_CONST(cephes_log_p3, - 1.2420140846E-1f);
|
||||
_PS_CONST(cephes_log_p4, + 1.4249322787E-1f);
|
||||
_PS_CONST(cephes_log_p5, - 1.6668057665E-1f);
|
||||
_PS_CONST(cephes_log_p6, + 2.0000714765E-1f);
|
||||
_PS_CONST(cephes_log_p7, - 2.4999993993E-1f);
|
||||
_PS_CONST(cephes_log_p8, + 3.3333331174E-1f);
|
||||
_PS_CONST(cephes_log_q1, -2.12194440e-4f);
|
||||
_PS_CONST(cephes_log_q2, 0.693359375f);
|
||||
|
||||
#if defined (__MINGW32__)
|
||||
|
||||
/* the ugly part below: many versions of gcc used to be completely buggy with respect to some intrinsics
|
||||
The movehl_ps is fixed in mingw 3.4.5, but I found out that all the _mm_cmp* intrinsics were completely
|
||||
broken on my mingw gcc 3.4.5 ...
|
||||
|
||||
Note that the bug on _mm_cmp* does occur only at -O0 optimization level
|
||||
*/
|
||||
|
||||
inline __m128 my_movehl_ps(__m128 a, const __m128 b) {
|
||||
asm (
|
||||
"movhlps %2,%0\n\t"
|
||||
: "=x" (a)
|
||||
: "0" (a), "x"(b)
|
||||
);
|
||||
return a; }
|
||||
#warning "redefined _mm_movehl_ps (see gcc bug 21179)"
|
||||
#define _mm_movehl_ps my_movehl_ps
|
||||
|
||||
inline __m128 my_cmplt_ps(__m128 a, const __m128 b) {
|
||||
asm (
|
||||
"cmpltps %2,%0\n\t"
|
||||
: "=x" (a)
|
||||
: "0" (a), "x"(b)
|
||||
);
|
||||
return a;
|
||||
}
|
||||
inline __m128 my_cmpgt_ps(__m128 a, const __m128 b) {
|
||||
asm (
|
||||
"cmpnleps %2,%0\n\t"
|
||||
: "=x" (a)
|
||||
: "0" (a), "x"(b)
|
||||
);
|
||||
return a;
|
||||
}
|
||||
inline __m128 my_cmpeq_ps(__m128 a, const __m128 b) {
|
||||
asm (
|
||||
"cmpeqps %2,%0\n\t"
|
||||
: "=x" (a)
|
||||
: "0" (a), "x"(b)
|
||||
);
|
||||
return a;
|
||||
}
|
||||
#warning "redefined _mm_cmpxx_ps functions..."
|
||||
#define _mm_cmplt_ps my_cmplt_ps
|
||||
#define _mm_cmpgt_ps my_cmpgt_ps
|
||||
#define _mm_cmpeq_ps my_cmpeq_ps
|
||||
#endif
|
||||
|
||||
#ifndef USE_SSE2
|
||||
typedef union xmm_mm_union {
|
||||
__m128 xmm;
|
||||
__m64 mm[2];
|
||||
} xmm_mm_union;
|
||||
|
||||
#define COPY_XMM_TO_MM(xmm_, mm0_, mm1_) { \
|
||||
xmm_mm_union u; u.xmm = xmm_; \
|
||||
mm0_ = u.mm[0]; \
|
||||
mm1_ = u.mm[1]; \
|
||||
}
|
||||
|
||||
#define COPY_MM_TO_XMM(mm0_, mm1_, xmm_) { \
|
||||
xmm_mm_union u; u.mm[0]=mm0_; u.mm[1]=mm1_; xmm_ = u.xmm; \
|
||||
}
|
||||
|
||||
#endif // USE_SSE2
|
||||
|
||||
/* natural logarithm computed for 4 simultaneous float
|
||||
return NaN for x <= 0
|
||||
*/
|
||||
inline v4sf log_ps(v4sf x) {
|
||||
#ifdef USE_SSE2
|
||||
v4si emm0;
|
||||
#else
|
||||
v2si mm0, mm1;
|
||||
#endif
|
||||
v4sf one = *(v4sf*)_ps_1;
|
||||
|
||||
v4sf invalid_mask = _mm_cmple_ps(x, _mm_setzero_ps());
|
||||
|
||||
x = _mm_max_ps(x, *(v4sf*)_ps_min_norm_pos); /* cut off denormalized stuff */
|
||||
|
||||
#ifndef USE_SSE2
|
||||
/* part 1: x = frexpf(x, &e); */
|
||||
COPY_XMM_TO_MM(x, mm0, mm1);
|
||||
mm0 = _mm_srli_pi32(mm0, 23);
|
||||
mm1 = _mm_srli_pi32(mm1, 23);
|
||||
#else
|
||||
emm0 = _mm_srli_epi32(_mm_castps_si128(x), 23);
|
||||
#endif
|
||||
/* keep only the fractional part */
|
||||
x = _mm_and_ps(x, *(v4sf*)_ps_inv_mant_mask);
|
||||
x = _mm_or_ps(x, *(v4sf*)_ps_0p5);
|
||||
|
||||
#ifndef USE_SSE2
|
||||
/* now e=mm0:mm1 contain the really base-2 exponent */
|
||||
mm0 = _mm_sub_pi32(mm0, *(v2si*)_pi32_0x7f);
|
||||
mm1 = _mm_sub_pi32(mm1, *(v2si*)_pi32_0x7f);
|
||||
v4sf e = _mm_cvtpi32x2_ps(mm0, mm1);
|
||||
_mm_empty(); /* bye bye mmx */
|
||||
#else
|
||||
emm0 = _mm_sub_epi32(emm0, *(v4si*)_pi32_0x7f);
|
||||
v4sf e = _mm_cvtepi32_ps(emm0);
|
||||
#endif
|
||||
|
||||
e = _mm_add_ps(e, one);
|
||||
|
||||
/* part2:
|
||||
if( x < SQRTHF ) {
|
||||
e -= 1;
|
||||
x = x + x - 1.0;
|
||||
} else { x = x - 1.0; }
|
||||
*/
|
||||
v4sf mask = _mm_cmplt_ps(x, *(v4sf*)_ps_cephes_SQRTHF);
|
||||
v4sf tmp = _mm_and_ps(x, mask);
|
||||
x = _mm_sub_ps(x, one);
|
||||
e = _mm_sub_ps(e, _mm_and_ps(one, mask));
|
||||
x = _mm_add_ps(x, tmp);
|
||||
|
||||
|
||||
v4sf z = _mm_mul_ps(x,x);
|
||||
|
||||
v4sf y = *(v4sf*)_ps_cephes_log_p0;
|
||||
y = _mm_mul_ps(y, x);
|
||||
y = _mm_add_ps(y, *(v4sf*)_ps_cephes_log_p1);
|
||||
y = _mm_mul_ps(y, x);
|
||||
y = _mm_add_ps(y, *(v4sf*)_ps_cephes_log_p2);
|
||||
y = _mm_mul_ps(y, x);
|
||||
y = _mm_add_ps(y, *(v4sf*)_ps_cephes_log_p3);
|
||||
y = _mm_mul_ps(y, x);
|
||||
y = _mm_add_ps(y, *(v4sf*)_ps_cephes_log_p4);
|
||||
y = _mm_mul_ps(y, x);
|
||||
y = _mm_add_ps(y, *(v4sf*)_ps_cephes_log_p5);
|
||||
y = _mm_mul_ps(y, x);
|
||||
y = _mm_add_ps(y, *(v4sf*)_ps_cephes_log_p6);
|
||||
y = _mm_mul_ps(y, x);
|
||||
y = _mm_add_ps(y, *(v4sf*)_ps_cephes_log_p7);
|
||||
y = _mm_mul_ps(y, x);
|
||||
y = _mm_add_ps(y, *(v4sf*)_ps_cephes_log_p8);
|
||||
y = _mm_mul_ps(y, x);
|
||||
|
||||
y = _mm_mul_ps(y, z);
|
||||
|
||||
|
||||
tmp = _mm_mul_ps(e, *(v4sf*)_ps_cephes_log_q1);
|
||||
y = _mm_add_ps(y, tmp);
|
||||
|
||||
|
||||
tmp = _mm_mul_ps(z, *(v4sf*)_ps_0p5);
|
||||
y = _mm_sub_ps(y, tmp);
|
||||
|
||||
tmp = _mm_mul_ps(e, *(v4sf*)_ps_cephes_log_q2);
|
||||
x = _mm_add_ps(x, y);
|
||||
x = _mm_add_ps(x, tmp);
|
||||
x = _mm_or_ps(x, invalid_mask); // negative arg will be NAN
|
||||
return x;
|
||||
}
|
||||
|
||||
_PS_CONST(exp_hi, 88.3762626647949f);
|
||||
_PS_CONST(exp_lo, -88.3762626647949f);
|
||||
|
||||
_PS_CONST(cephes_LOG2EF, 1.44269504088896341f);
|
||||
_PS_CONST(cephes_exp_C1, 0.693359375f);
|
||||
_PS_CONST(cephes_exp_C2, -2.12194440e-4f);
|
||||
|
||||
_PS_CONST(cephes_exp_p0, 1.9875691500E-4f);
|
||||
_PS_CONST(cephes_exp_p1, 1.3981999507E-3f);
|
||||
_PS_CONST(cephes_exp_p2, 8.3334519073E-3f);
|
||||
_PS_CONST(cephes_exp_p3, 4.1665795894E-2f);
|
||||
_PS_CONST(cephes_exp_p4, 1.6666665459E-1f);
|
||||
_PS_CONST(cephes_exp_p5, 5.0000001201E-1f);
|
||||
|
||||
inline v4sf exp_ps(v4sf x) {
|
||||
v4sf tmp = _mm_setzero_ps(), fx;
|
||||
#ifdef USE_SSE2
|
||||
v4si emm0;
|
||||
#else
|
||||
v2si mm0, mm1;
|
||||
#endif
|
||||
v4sf one = *(v4sf*)_ps_1;
|
||||
|
||||
x = _mm_min_ps(x, *(v4sf*)_ps_exp_hi);
|
||||
x = _mm_max_ps(x, *(v4sf*)_ps_exp_lo);
|
||||
|
||||
/* express exp(x) as exp(g + n*log(2)) */
|
||||
fx = _mm_mul_ps(x, *(v4sf*)_ps_cephes_LOG2EF);
|
||||
fx = _mm_add_ps(fx, *(v4sf*)_ps_0p5);
|
||||
|
||||
/* how to perform a floorf with SSE: just below */
|
||||
#ifndef USE_SSE2
|
||||
/* step 1 : cast to int */
|
||||
tmp = _mm_movehl_ps(tmp, fx);
|
||||
mm0 = _mm_cvttps_pi32(fx);
|
||||
mm1 = _mm_cvttps_pi32(tmp);
|
||||
/* step 2 : cast back to float */
|
||||
tmp = _mm_cvtpi32x2_ps(mm0, mm1);
|
||||
#else
|
||||
emm0 = _mm_cvttps_epi32(fx);
|
||||
tmp = _mm_cvtepi32_ps(emm0);
|
||||
#endif
|
||||
/* if greater, substract 1 */
|
||||
v4sf mask = _mm_cmpgt_ps(tmp, fx);
|
||||
mask = _mm_and_ps(mask, one);
|
||||
fx = _mm_sub_ps(tmp, mask);
|
||||
|
||||
tmp = _mm_mul_ps(fx, *(v4sf*)_ps_cephes_exp_C1);
|
||||
v4sf z = _mm_mul_ps(fx, *(v4sf*)_ps_cephes_exp_C2);
|
||||
x = _mm_sub_ps(x, tmp);
|
||||
x = _mm_sub_ps(x, z);
|
||||
|
||||
z = _mm_mul_ps(x,x);
|
||||
|
||||
v4sf y = *(v4sf*)_ps_cephes_exp_p0;
|
||||
y = _mm_mul_ps(y, x);
|
||||
y = _mm_add_ps(y, *(v4sf*)_ps_cephes_exp_p1);
|
||||
y = _mm_mul_ps(y, x);
|
||||
y = _mm_add_ps(y, *(v4sf*)_ps_cephes_exp_p2);
|
||||
y = _mm_mul_ps(y, x);
|
||||
y = _mm_add_ps(y, *(v4sf*)_ps_cephes_exp_p3);
|
||||
y = _mm_mul_ps(y, x);
|
||||
y = _mm_add_ps(y, *(v4sf*)_ps_cephes_exp_p4);
|
||||
y = _mm_mul_ps(y, x);
|
||||
y = _mm_add_ps(y, *(v4sf*)_ps_cephes_exp_p5);
|
||||
y = _mm_mul_ps(y, z);
|
||||
y = _mm_add_ps(y, x);
|
||||
y = _mm_add_ps(y, one);
|
||||
|
||||
/* build 2^n */
|
||||
#ifndef USE_SSE2
|
||||
z = _mm_movehl_ps(z, fx);
|
||||
mm0 = _mm_cvttps_pi32(fx);
|
||||
mm1 = _mm_cvttps_pi32(z);
|
||||
mm0 = _mm_add_pi32(mm0, *(v2si*)_pi32_0x7f);
|
||||
mm1 = _mm_add_pi32(mm1, *(v2si*)_pi32_0x7f);
|
||||
mm0 = _mm_slli_pi32(mm0, 23);
|
||||
mm1 = _mm_slli_pi32(mm1, 23);
|
||||
|
||||
v4sf pow2n;
|
||||
COPY_MM_TO_XMM(mm0, mm1, pow2n);
|
||||
_mm_empty();
|
||||
#else
|
||||
emm0 = _mm_cvttps_epi32(fx);
|
||||
emm0 = _mm_add_epi32(emm0, *(v4si*)_pi32_0x7f);
|
||||
emm0 = _mm_slli_epi32(emm0, 23);
|
||||
v4sf pow2n = _mm_castsi128_ps(emm0);
|
||||
#endif
|
||||
y = _mm_mul_ps(y, pow2n);
|
||||
return y;
|
||||
}
|
||||
|
||||
_PS_CONST(minus_cephes_DP1, -0.78515625f);
|
||||
_PS_CONST(minus_cephes_DP2, -2.4187564849853515625e-4f);
|
||||
_PS_CONST(minus_cephes_DP3, -3.77489497744594108e-8f);
|
||||
_PS_CONST(sincof_p0, -1.9515295891E-4f);
|
||||
_PS_CONST(sincof_p1, 8.3321608736E-3f);
|
||||
_PS_CONST(sincof_p2, -1.6666654611E-1f);
|
||||
_PS_CONST(coscof_p0, 2.443315711809948E-005f);
|
||||
_PS_CONST(coscof_p1, -1.388731625493765E-003f);
|
||||
_PS_CONST(coscof_p2, 4.166664568298827E-002f);
|
||||
_PS_CONST(cephes_FOPI, 1.27323954473516f); // 4 / M_PI
|
||||
|
||||
|
||||
/* evaluation of 4 sines at onces, using only SSE1+MMX intrinsics so
|
||||
it runs also on old athlons XPs and the pentium III of your grand
|
||||
mother.
|
||||
|
||||
The code is the exact rewriting of the cephes sinf function.
|
||||
Precision is excellent as long as x < 8192 (I did not bother to
|
||||
take into account the special handling they have for greater values
|
||||
-- it does not return garbage for arguments over 8192, though, but
|
||||
the extra precision is missing).
|
||||
|
||||
Note that it is such that sinf((float)M_PI) = 8.74e-8, which is the
|
||||
surprising but correct result.
|
||||
|
||||
Performance is also surprisingly good, 1.33 times faster than the
|
||||
macos vsinf SSE2 function, and 1.5 times faster than the
|
||||
__vrs4_sinf of amd's ACML (which is only available in 64 bits). Not
|
||||
too bad for an SSE1 function (with no special tuning) !
|
||||
However the latter libraries probably have a much better handling of NaN,
|
||||
Inf, denormalized and other special arguments..
|
||||
|
||||
On my core 1 duo, the execution of this function takes approximately 95 cycles.
|
||||
|
||||
From what I have observed on the experiments with Intel AMath lib, switching to an
|
||||
SSE2 version would improve the perf by only 10%.
|
||||
|
||||
Since it is based on SSE intrinsics, it has to be compiled at -O2 to
|
||||
deliver full speed.
|
||||
*/
|
||||
inline v4sf sin_ps(v4sf x) { // any x
|
||||
v4sf xmm1, xmm2 = _mm_setzero_ps(), xmm3, sign_bit, y;
|
||||
|
||||
#ifdef USE_SSE2
|
||||
v4si emm0, emm2;
|
||||
#else
|
||||
v2si mm0, mm1, mm2, mm3;
|
||||
#endif
|
||||
sign_bit = x;
|
||||
/* take the absolute value */
|
||||
x = _mm_and_ps(x, *(v4sf*)_ps_inv_sign_mask);
|
||||
/* extract the sign bit (upper one) */
|
||||
sign_bit = _mm_and_ps(sign_bit, *(v4sf*)_ps_sign_mask);
|
||||
|
||||
/* scale by 4/Pi */
|
||||
y = _mm_mul_ps(x, *(v4sf*)_ps_cephes_FOPI);
|
||||
|
||||
//printf("plop:"); print4(y);
|
||||
#ifdef USE_SSE2
|
||||
/* store the integer part of y in mm0 */
|
||||
emm2 = _mm_cvttps_epi32(y);
|
||||
/* j=(j+1) & (~1) (see the cephes sources) */
|
||||
emm2 = _mm_add_epi32(emm2, *(v4si*)_pi32_1);
|
||||
emm2 = _mm_and_si128(emm2, *(v4si*)_pi32_inv1);
|
||||
y = _mm_cvtepi32_ps(emm2);
|
||||
/* get the swap sign flag */
|
||||
emm0 = _mm_and_si128(emm2, *(v4si*)_pi32_4);
|
||||
emm0 = _mm_slli_epi32(emm0, 29);
|
||||
/* get the polynom selection mask
|
||||
there is one polynom for 0 <= x <= Pi/4
|
||||
and another one for Pi/4<x<=Pi/2
|
||||
|
||||
Both branches will be computed.
|
||||
*/
|
||||
emm2 = _mm_and_si128(emm2, *(v4si*)_pi32_2);
|
||||
emm2 = _mm_cmpeq_epi32(emm2, _mm_setzero_si128());
|
||||
|
||||
v4sf swap_sign_bit = _mm_castsi128_ps(emm0);
|
||||
v4sf poly_mask = _mm_castsi128_ps(emm2);
|
||||
sign_bit = _mm_xor_ps(sign_bit, swap_sign_bit);
|
||||
#else
|
||||
/* store the integer part of y in mm0:mm1 */
|
||||
xmm2 = _mm_movehl_ps(xmm2, y);
|
||||
mm2 = _mm_cvttps_pi32(y);
|
||||
mm3 = _mm_cvttps_pi32(xmm2);
|
||||
/* j=(j+1) & (~1) (see the cephes sources) */
|
||||
mm2 = _mm_add_pi32(mm2, *(v2si*)_pi32_1);
|
||||
mm3 = _mm_add_pi32(mm3, *(v2si*)_pi32_1);
|
||||
mm2 = _mm_and_si64(mm2, *(v2si*)_pi32_inv1);
|
||||
mm3 = _mm_and_si64(mm3, *(v2si*)_pi32_inv1);
|
||||
y = _mm_cvtpi32x2_ps(mm2, mm3);
|
||||
/* get the swap sign flag */
|
||||
mm0 = _mm_and_si64(mm2, *(v2si*)_pi32_4);
|
||||
mm1 = _mm_and_si64(mm3, *(v2si*)_pi32_4);
|
||||
mm0 = _mm_slli_pi32(mm0, 29);
|
||||
mm1 = _mm_slli_pi32(mm1, 29);
|
||||
/* get the polynom selection mask */
|
||||
mm2 = _mm_and_si64(mm2, *(v2si*)_pi32_2);
|
||||
mm3 = _mm_and_si64(mm3, *(v2si*)_pi32_2);
|
||||
mm2 = _mm_cmpeq_pi32(mm2, _mm_setzero_si64());
|
||||
mm3 = _mm_cmpeq_pi32(mm3, _mm_setzero_si64());
|
||||
v4sf swap_sign_bit, poly_mask;
|
||||
COPY_MM_TO_XMM(mm0, mm1, swap_sign_bit);
|
||||
COPY_MM_TO_XMM(mm2, mm3, poly_mask);
|
||||
sign_bit = _mm_xor_ps(sign_bit, swap_sign_bit);
|
||||
_mm_empty(); /* good-bye mmx */
|
||||
#endif
|
||||
|
||||
/* The magic pass: "Extended precision modular arithmetic"
|
||||
x = ((x - y * DP1) - y * DP2) - y * DP3; */
|
||||
xmm1 = *(v4sf*)_ps_minus_cephes_DP1;
|
||||
xmm2 = *(v4sf*)_ps_minus_cephes_DP2;
|
||||
xmm3 = *(v4sf*)_ps_minus_cephes_DP3;
|
||||
xmm1 = _mm_mul_ps(y, xmm1);
|
||||
xmm2 = _mm_mul_ps(y, xmm2);
|
||||
xmm3 = _mm_mul_ps(y, xmm3);
|
||||
x = _mm_add_ps(x, xmm1);
|
||||
x = _mm_add_ps(x, xmm2);
|
||||
x = _mm_add_ps(x, xmm3);
|
||||
|
||||
/* Evaluate the first polynom (0 <= x <= Pi/4) */
|
||||
y = *(v4sf*)_ps_coscof_p0;
|
||||
v4sf z = _mm_mul_ps(x,x);
|
||||
|
||||
y = _mm_mul_ps(y, z);
|
||||
y = _mm_add_ps(y, *(v4sf*)_ps_coscof_p1);
|
||||
y = _mm_mul_ps(y, z);
|
||||
y = _mm_add_ps(y, *(v4sf*)_ps_coscof_p2);
|
||||
y = _mm_mul_ps(y, z);
|
||||
y = _mm_mul_ps(y, z);
|
||||
v4sf tmp = _mm_mul_ps(z, *(v4sf*)_ps_0p5);
|
||||
y = _mm_sub_ps(y, tmp);
|
||||
y = _mm_add_ps(y, *(v4sf*)_ps_1);
|
||||
|
||||
/* Evaluate the second polynom (Pi/4 <= x <= 0) */
|
||||
|
||||
v4sf y2 = *(v4sf*)_ps_sincof_p0;
|
||||
y2 = _mm_mul_ps(y2, z);
|
||||
y2 = _mm_add_ps(y2, *(v4sf*)_ps_sincof_p1);
|
||||
y2 = _mm_mul_ps(y2, z);
|
||||
y2 = _mm_add_ps(y2, *(v4sf*)_ps_sincof_p2);
|
||||
y2 = _mm_mul_ps(y2, z);
|
||||
y2 = _mm_mul_ps(y2, x);
|
||||
y2 = _mm_add_ps(y2, x);
|
||||
|
||||
/* select the correct result from the two polynoms */
|
||||
xmm3 = poly_mask;
|
||||
y2 = _mm_and_ps(xmm3, y2); //, xmm3);
|
||||
y = _mm_andnot_ps(xmm3, y);
|
||||
y = _mm_add_ps(y,y2);
|
||||
/* update the sign */
|
||||
y = _mm_xor_ps(y, sign_bit);
|
||||
|
||||
return y;
|
||||
}
|
||||
|
||||
/* almost the same as sin_ps */
|
||||
inline v4sf cos_ps(v4sf x) { // any x
|
||||
v4sf xmm1, xmm2 = _mm_setzero_ps(), xmm3, y;
|
||||
#ifdef USE_SSE2
|
||||
v4si emm0, emm2;
|
||||
#else
|
||||
v2si mm0, mm1, mm2, mm3;
|
||||
#endif
|
||||
/* take the absolute value */
|
||||
x = _mm_and_ps(x, *(v4sf*)_ps_inv_sign_mask);
|
||||
|
||||
/* scale by 4/Pi */
|
||||
y = _mm_mul_ps(x, *(v4sf*)_ps_cephes_FOPI);
|
||||
|
||||
#ifdef USE_SSE2
|
||||
/* store the integer part of y in mm0 */
|
||||
emm2 = _mm_cvttps_epi32(y);
|
||||
/* j=(j+1) & (~1) (see the cephes sources) */
|
||||
emm2 = _mm_add_epi32(emm2, *(v4si*)_pi32_1);
|
||||
emm2 = _mm_and_si128(emm2, *(v4si*)_pi32_inv1);
|
||||
y = _mm_cvtepi32_ps(emm2);
|
||||
|
||||
emm2 = _mm_sub_epi32(emm2, *(v4si*)_pi32_2);
|
||||
|
||||
/* get the swap sign flag */
|
||||
emm0 = _mm_andnot_si128(emm2, *(v4si*)_pi32_4);
|
||||
emm0 = _mm_slli_epi32(emm0, 29);
|
||||
/* get the polynom selection mask */
|
||||
emm2 = _mm_and_si128(emm2, *(v4si*)_pi32_2);
|
||||
emm2 = _mm_cmpeq_epi32(emm2, _mm_setzero_si128());
|
||||
|
||||
v4sf sign_bit = _mm_castsi128_ps(emm0);
|
||||
v4sf poly_mask = _mm_castsi128_ps(emm2);
|
||||
#else
|
||||
/* store the integer part of y in mm0:mm1 */
|
||||
xmm2 = _mm_movehl_ps(xmm2, y);
|
||||
mm2 = _mm_cvttps_pi32(y);
|
||||
mm3 = _mm_cvttps_pi32(xmm2);
|
||||
|
||||
/* j=(j+1) & (~1) (see the cephes sources) */
|
||||
mm2 = _mm_add_pi32(mm2, *(v2si*)_pi32_1);
|
||||
mm3 = _mm_add_pi32(mm3, *(v2si*)_pi32_1);
|
||||
mm2 = _mm_and_si64(mm2, *(v2si*)_pi32_inv1);
|
||||
mm3 = _mm_and_si64(mm3, *(v2si*)_pi32_inv1);
|
||||
|
||||
y = _mm_cvtpi32x2_ps(mm2, mm3);
|
||||
|
||||
|
||||
mm2 = _mm_sub_pi32(mm2, *(v2si*)_pi32_2);
|
||||
mm3 = _mm_sub_pi32(mm3, *(v2si*)_pi32_2);
|
||||
|
||||
/* get the swap sign flag in mm0:mm1 and the
|
||||
polynom selection mask in mm2:mm3 */
|
||||
|
||||
mm0 = _mm_andnot_si64(mm2, *(v2si*)_pi32_4);
|
||||
mm1 = _mm_andnot_si64(mm3, *(v2si*)_pi32_4);
|
||||
mm0 = _mm_slli_pi32(mm0, 29);
|
||||
mm1 = _mm_slli_pi32(mm1, 29);
|
||||
|
||||
mm2 = _mm_and_si64(mm2, *(v2si*)_pi32_2);
|
||||
mm3 = _mm_and_si64(mm3, *(v2si*)_pi32_2);
|
||||
|
||||
mm2 = _mm_cmpeq_pi32(mm2, _mm_setzero_si64());
|
||||
mm3 = _mm_cmpeq_pi32(mm3, _mm_setzero_si64());
|
||||
|
||||
v4sf sign_bit, poly_mask;
|
||||
COPY_MM_TO_XMM(mm0, mm1, sign_bit);
|
||||
COPY_MM_TO_XMM(mm2, mm3, poly_mask);
|
||||
_mm_empty(); /* good-bye mmx */
|
||||
#endif
|
||||
/* The magic pass: "Extended precision modular arithmetic"
|
||||
x = ((x - y * DP1) - y * DP2) - y * DP3; */
|
||||
xmm1 = *(v4sf*)_ps_minus_cephes_DP1;
|
||||
xmm2 = *(v4sf*)_ps_minus_cephes_DP2;
|
||||
xmm3 = *(v4sf*)_ps_minus_cephes_DP3;
|
||||
xmm1 = _mm_mul_ps(y, xmm1);
|
||||
xmm2 = _mm_mul_ps(y, xmm2);
|
||||
xmm3 = _mm_mul_ps(y, xmm3);
|
||||
x = _mm_add_ps(x, xmm1);
|
||||
x = _mm_add_ps(x, xmm2);
|
||||
x = _mm_add_ps(x, xmm3);
|
||||
|
||||
/* Evaluate the first polynom (0 <= x <= Pi/4) */
|
||||
y = *(v4sf*)_ps_coscof_p0;
|
||||
v4sf z = _mm_mul_ps(x,x);
|
||||
|
||||
y = _mm_mul_ps(y, z);
|
||||
y = _mm_add_ps(y, *(v4sf*)_ps_coscof_p1);
|
||||
y = _mm_mul_ps(y, z);
|
||||
y = _mm_add_ps(y, *(v4sf*)_ps_coscof_p2);
|
||||
y = _mm_mul_ps(y, z);
|
||||
y = _mm_mul_ps(y, z);
|
||||
v4sf tmp = _mm_mul_ps(z, *(v4sf*)_ps_0p5);
|
||||
y = _mm_sub_ps(y, tmp);
|
||||
y = _mm_add_ps(y, *(v4sf*)_ps_1);
|
||||
|
||||
/* Evaluate the second polynom (Pi/4 <= x <= 0) */
|
||||
|
||||
v4sf y2 = *(v4sf*)_ps_sincof_p0;
|
||||
y2 = _mm_mul_ps(y2, z);
|
||||
y2 = _mm_add_ps(y2, *(v4sf*)_ps_sincof_p1);
|
||||
y2 = _mm_mul_ps(y2, z);
|
||||
y2 = _mm_add_ps(y2, *(v4sf*)_ps_sincof_p2);
|
||||
y2 = _mm_mul_ps(y2, z);
|
||||
y2 = _mm_mul_ps(y2, x);
|
||||
y2 = _mm_add_ps(y2, x);
|
||||
|
||||
/* select the correct result from the two polynoms */
|
||||
xmm3 = poly_mask;
|
||||
y2 = _mm_and_ps(xmm3, y2); //, xmm3);
|
||||
y = _mm_andnot_ps(xmm3, y);
|
||||
y = _mm_add_ps(y,y2);
|
||||
/* update the sign */
|
||||
y = _mm_xor_ps(y, sign_bit);
|
||||
|
||||
return y;
|
||||
}
|
||||
|
||||
/* since sin_ps and cos_ps are almost identical, sincos_ps could replace both of them..
|
||||
it is almost as fast, and gives you a free cosine with your sine */
|
||||
inline void sincos_ps(v4sf x, v4sf *s, v4sf *c) {
|
||||
v4sf xmm1, xmm2, xmm3 = _mm_setzero_ps(), sign_bit_sin, y;
|
||||
#ifdef USE_SSE2
|
||||
v4si emm0, emm2, emm4;
|
||||
#else
|
||||
v2si mm0, mm1, mm2, mm3, mm4, mm5;
|
||||
#endif
|
||||
sign_bit_sin = x;
|
||||
/* take the absolute value */
|
||||
x = _mm_and_ps(x, *(v4sf*)_ps_inv_sign_mask);
|
||||
/* extract the sign bit (upper one) */
|
||||
sign_bit_sin = _mm_and_ps(sign_bit_sin, *(v4sf*)_ps_sign_mask);
|
||||
|
||||
/* scale by 4/Pi */
|
||||
y = _mm_mul_ps(x, *(v4sf*)_ps_cephes_FOPI);
|
||||
|
||||
#ifdef USE_SSE2
|
||||
/* store the integer part of y in emm2 */
|
||||
emm2 = _mm_cvttps_epi32(y);
|
||||
|
||||
/* j=(j+1) & (~1) (see the cephes sources) */
|
||||
emm2 = _mm_add_epi32(emm2, *(v4si*)_pi32_1);
|
||||
emm2 = _mm_and_si128(emm2, *(v4si*)_pi32_inv1);
|
||||
y = _mm_cvtepi32_ps(emm2);
|
||||
|
||||
emm4 = emm2;
|
||||
|
||||
/* get the swap sign flag for the sine */
|
||||
emm0 = _mm_and_si128(emm2, *(v4si*)_pi32_4);
|
||||
emm0 = _mm_slli_epi32(emm0, 29);
|
||||
v4sf swap_sign_bit_sin = _mm_castsi128_ps(emm0);
|
||||
|
||||
/* get the polynom selection mask for the sine*/
|
||||
emm2 = _mm_and_si128(emm2, *(v4si*)_pi32_2);
|
||||
emm2 = _mm_cmpeq_epi32(emm2, _mm_setzero_si128());
|
||||
v4sf poly_mask = _mm_castsi128_ps(emm2);
|
||||
#else
|
||||
/* store the integer part of y in mm2:mm3 */
|
||||
xmm3 = _mm_movehl_ps(xmm3, y);
|
||||
mm2 = _mm_cvttps_pi32(y);
|
||||
mm3 = _mm_cvttps_pi32(xmm3);
|
||||
|
||||
/* j=(j+1) & (~1) (see the cephes sources) */
|
||||
mm2 = _mm_add_pi32(mm2, *(v2si*)_pi32_1);
|
||||
mm3 = _mm_add_pi32(mm3, *(v2si*)_pi32_1);
|
||||
mm2 = _mm_and_si64(mm2, *(v2si*)_pi32_inv1);
|
||||
mm3 = _mm_and_si64(mm3, *(v2si*)_pi32_inv1);
|
||||
|
||||
y = _mm_cvtpi32x2_ps(mm2, mm3);
|
||||
|
||||
mm4 = mm2;
|
||||
mm5 = mm3;
|
||||
|
||||
/* get the swap sign flag for the sine */
|
||||
mm0 = _mm_and_si64(mm2, *(v2si*)_pi32_4);
|
||||
mm1 = _mm_and_si64(mm3, *(v2si*)_pi32_4);
|
||||
mm0 = _mm_slli_pi32(mm0, 29);
|
||||
mm1 = _mm_slli_pi32(mm1, 29);
|
||||
v4sf swap_sign_bit_sin;
|
||||
COPY_MM_TO_XMM(mm0, mm1, swap_sign_bit_sin);
|
||||
|
||||
/* get the polynom selection mask for the sine */
|
||||
|
||||
mm2 = _mm_and_si64(mm2, *(v2si*)_pi32_2);
|
||||
mm3 = _mm_and_si64(mm3, *(v2si*)_pi32_2);
|
||||
mm2 = _mm_cmpeq_pi32(mm2, _mm_setzero_si64());
|
||||
mm3 = _mm_cmpeq_pi32(mm3, _mm_setzero_si64());
|
||||
v4sf poly_mask;
|
||||
COPY_MM_TO_XMM(mm2, mm3, poly_mask);
|
||||
#endif
|
||||
|
||||
/* The magic pass: "Extended precision modular arithmetic"
|
||||
x = ((x - y * DP1) - y * DP2) - y * DP3; */
|
||||
xmm1 = *(v4sf*)_ps_minus_cephes_DP1;
|
||||
xmm2 = *(v4sf*)_ps_minus_cephes_DP2;
|
||||
xmm3 = *(v4sf*)_ps_minus_cephes_DP3;
|
||||
xmm1 = _mm_mul_ps(y, xmm1);
|
||||
xmm2 = _mm_mul_ps(y, xmm2);
|
||||
xmm3 = _mm_mul_ps(y, xmm3);
|
||||
x = _mm_add_ps(x, xmm1);
|
||||
x = _mm_add_ps(x, xmm2);
|
||||
x = _mm_add_ps(x, xmm3);
|
||||
|
||||
#ifdef USE_SSE2
|
||||
emm4 = _mm_sub_epi32(emm4, *(v4si*)_pi32_2);
|
||||
emm4 = _mm_andnot_si128(emm4, *(v4si*)_pi32_4);
|
||||
emm4 = _mm_slli_epi32(emm4, 29);
|
||||
v4sf sign_bit_cos = _mm_castsi128_ps(emm4);
|
||||
#else
|
||||
/* get the sign flag for the cosine */
|
||||
mm4 = _mm_sub_pi32(mm4, *(v2si*)_pi32_2);
|
||||
mm5 = _mm_sub_pi32(mm5, *(v2si*)_pi32_2);
|
||||
mm4 = _mm_andnot_si64(mm4, *(v2si*)_pi32_4);
|
||||
mm5 = _mm_andnot_si64(mm5, *(v2si*)_pi32_4);
|
||||
mm4 = _mm_slli_pi32(mm4, 29);
|
||||
mm5 = _mm_slli_pi32(mm5, 29);
|
||||
v4sf sign_bit_cos;
|
||||
COPY_MM_TO_XMM(mm4, mm5, sign_bit_cos);
|
||||
_mm_empty(); /* good-bye mmx */
|
||||
#endif
|
||||
|
||||
sign_bit_sin = _mm_xor_ps(sign_bit_sin, swap_sign_bit_sin);
|
||||
|
||||
|
||||
/* Evaluate the first polynom (0 <= x <= Pi/4) */
|
||||
v4sf z = _mm_mul_ps(x,x);
|
||||
y = *(v4sf*)_ps_coscof_p0;
|
||||
|
||||
y = _mm_mul_ps(y, z);
|
||||
y = _mm_add_ps(y, *(v4sf*)_ps_coscof_p1);
|
||||
y = _mm_mul_ps(y, z);
|
||||
y = _mm_add_ps(y, *(v4sf*)_ps_coscof_p2);
|
||||
y = _mm_mul_ps(y, z);
|
||||
y = _mm_mul_ps(y, z);
|
||||
v4sf tmp = _mm_mul_ps(z, *(v4sf*)_ps_0p5);
|
||||
y = _mm_sub_ps(y, tmp);
|
||||
y = _mm_add_ps(y, *(v4sf*)_ps_1);
|
||||
|
||||
/* Evaluate the second polynom (Pi/4 <= x <= 0) */
|
||||
|
||||
v4sf y2 = *(v4sf*)_ps_sincof_p0;
|
||||
y2 = _mm_mul_ps(y2, z);
|
||||
y2 = _mm_add_ps(y2, *(v4sf*)_ps_sincof_p1);
|
||||
y2 = _mm_mul_ps(y2, z);
|
||||
y2 = _mm_add_ps(y2, *(v4sf*)_ps_sincof_p2);
|
||||
y2 = _mm_mul_ps(y2, z);
|
||||
y2 = _mm_mul_ps(y2, x);
|
||||
y2 = _mm_add_ps(y2, x);
|
||||
|
||||
/* select the correct result from the two polynoms */
|
||||
xmm3 = poly_mask;
|
||||
v4sf ysin2 = _mm_and_ps(xmm3, y2);
|
||||
v4sf ysin1 = _mm_andnot_ps(xmm3, y);
|
||||
y2 = _mm_sub_ps(y2,ysin2);
|
||||
y = _mm_sub_ps(y, ysin1);
|
||||
|
||||
xmm1 = _mm_add_ps(ysin1,ysin2);
|
||||
xmm2 = _mm_add_ps(y,y2);
|
||||
|
||||
/* update the sign */
|
||||
*s = _mm_xor_ps(xmm1, sign_bit_sin);
|
||||
*c = _mm_xor_ps(xmm2, sign_bit_cos);
|
||||
}
|
||||
|
||||
+21
-13
@@ -1,5 +1,5 @@
|
||||
// ======================================================================== //
|
||||
// Copyright 2009-2017 Intel Corporation //
|
||||
// Copyright 2009-2016 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
@@ -32,7 +32,7 @@ namespace embree
|
||||
template<int N>
|
||||
struct vdouble
|
||||
{
|
||||
union { double f[N]; long long i[N]; };
|
||||
union { double f[N]; int64_t i[N]; };
|
||||
__forceinline const double& operator [](size_t index) const { assert(index < N); return f[index]; }
|
||||
__forceinline double& operator [](size_t index) { assert(index < N); return f[index]; }
|
||||
};
|
||||
@@ -54,20 +54,29 @@ namespace embree
|
||||
};
|
||||
|
||||
template<int N>
|
||||
struct vllong
|
||||
struct vlong
|
||||
{
|
||||
long long i[N];
|
||||
__forceinline const long long& operator [](size_t index) const { assert(index < N); return i[index]; }
|
||||
__forceinline long long& operator [](size_t index) { assert(index < N); return i[index]; }
|
||||
int64_t i[N];
|
||||
__forceinline const int64_t& operator [](size_t index) const { assert(index < N); return i[index]; }
|
||||
__forceinline int64_t& operator [](size_t index) { assert(index < N); return i[index]; }
|
||||
};
|
||||
|
||||
#if !defined(_MSC_VER) || _MSC_VER >= 1800
|
||||
/* Varying bool types */
|
||||
template<int N> struct vboolf { int i[N]; }; // for float/int
|
||||
template<int N> struct vboold { long long i[N]; }; // for double/long long
|
||||
template<int N> struct vboolf { int i[N]; }; // for float/int
|
||||
template<int N> struct vboold { int64_t i[N]; }; // for double/long
|
||||
|
||||
/* Aliases to default types */
|
||||
template<int N> using vreal = vfloat<N>;
|
||||
template<int N> using vbool = vboolf<N>;
|
||||
#else
|
||||
/* Workaround for VS2012 */
|
||||
#define vreal vfloat
|
||||
#define vboolf vbool
|
||||
|
||||
template<int N> struct vboolf { int i[N]; };
|
||||
template<int N> struct vboold { int64_t i[N]; };
|
||||
#endif
|
||||
|
||||
/* Maximum supported varying size */
|
||||
#if defined(__AVX512F__)
|
||||
@@ -98,8 +107,7 @@ namespace embree
|
||||
typedef vdouble<4> vdouble4;
|
||||
typedef vreal<4> vreal4;
|
||||
typedef vint<4> vint4;
|
||||
typedef vuint<4> vuint4;
|
||||
typedef vllong<4> vllong4;
|
||||
typedef vlong<4> vlong4;
|
||||
typedef vbool<4> vbool4;
|
||||
typedef vboolf<4> vboolf4;
|
||||
typedef vboold<4> vboold4;
|
||||
@@ -109,7 +117,7 @@ namespace embree
|
||||
typedef vdouble<8> vdouble8;
|
||||
typedef vreal<8> vreal8;
|
||||
typedef vint<8> vint8;
|
||||
typedef vllong<8> vllong8;
|
||||
typedef vlong<8> vlong8;
|
||||
typedef vbool<8> vbool8;
|
||||
typedef vboolf<8> vboolf8;
|
||||
typedef vboold<8> vboold8;
|
||||
@@ -120,7 +128,7 @@ namespace embree
|
||||
typedef vreal<16> vreal16;
|
||||
typedef vint<16> vint16;
|
||||
typedef vuint<16> vuint16;
|
||||
typedef vllong<16> vllong16;
|
||||
typedef vlong<16> vlong16;
|
||||
typedef vbool<16> vbool16;
|
||||
typedef vboolf<16> vboolf16;
|
||||
typedef vboold<16> vboold16;
|
||||
@@ -130,7 +138,7 @@ namespace embree
|
||||
typedef vdouble<VSIZEX> vdoublex;
|
||||
typedef vreal<VSIZEX> vrealx;
|
||||
typedef vint<VSIZEX> vintx;
|
||||
typedef vllong<VSIZEX> vllongx;
|
||||
typedef vlong<VSIZEX> vlongx;
|
||||
typedef vbool<VSIZEX> vboolx;
|
||||
typedef vboolf<VSIZEX> vboolfx;
|
||||
typedef vboold<VSIZEX> vbooldx;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ======================================================================== //
|
||||
// Copyright 2009-2017 Intel Corporation //
|
||||
// Copyright 2009-2016 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
@@ -28,8 +28,8 @@ namespace embree
|
||||
union { // data
|
||||
__m256d v;
|
||||
struct { __m128d vl,vh; };
|
||||
long long i[4];
|
||||
};
|
||||
int64_t i[4];
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// Constructors, Assignment & Cast Operators
|
||||
@@ -73,8 +73,8 @@ namespace embree
|
||||
/// Array Access
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
__forceinline bool operator []( const size_t index ) const { assert(index < 4); return (_mm256_movemask_pd(v) >> index) & 1; }
|
||||
__forceinline long long& operator []( const size_t index ) { assert(index < 4); return i[index]; }
|
||||
__forceinline bool operator []( const size_t index ) const { assert(index < 4); return (_mm256_movemask_pd(v) >> index) & 1; }
|
||||
__forceinline int64_t& operator []( const size_t index ) { assert(index < 4); return i[index]; }
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ======================================================================== //
|
||||
// Copyright 2009-2017 Intel Corporation //
|
||||
// Copyright 2009-2016 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
@@ -114,13 +114,13 @@ namespace embree
|
||||
__forceinline int none( const vboold4& valid, const vboold4& b ) { return none(valid & b); }
|
||||
|
||||
__forceinline size_t movemask( const vboold4& a ) { return _mm512_kmov(a); }
|
||||
__forceinline size_t popcnt ( const vboold4& a ) { return __popcnt(a.v); }
|
||||
__forceinline size_t popcnt ( const vboold4& a ) { return _mm_countbits_64(a.v); }
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// Conversion Operations
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
__forceinline unsigned int toInt(const vboold4 &a) { return mm512_mask2int(a); }
|
||||
__forceinline unsigned int toInt(const vboold4 &a) { return _mm512_mask2int(a); }
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// Get/Set Functions
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ======================================================================== //
|
||||
// Copyright 2009-2017 Intel Corporation //
|
||||
// Copyright 2009-2016 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
@@ -48,8 +48,8 @@ namespace embree
|
||||
#if defined(__AVX512BW__)
|
||||
return _mm_movm_epi8(v);
|
||||
#else
|
||||
const __m512i f = _mm512_set1_epi64(0);
|
||||
const __m512i t = _mm512_set1_epi64(-1);
|
||||
const __m512i f = _mm512_set_1to8_epi64(0);
|
||||
const __m512i t = _mm512_set_1to8_epi64(-1);
|
||||
const __m512i m = _mm512_mask_or_epi64(f,v,t,t);
|
||||
return _mm512_cvtepi64_epi8(m);
|
||||
#endif
|
||||
@@ -60,8 +60,8 @@ namespace embree
|
||||
#if defined(__AVX512DQ__)
|
||||
return _mm512_movm_epi64(v);
|
||||
#else
|
||||
const __m512i f = _mm512_set1_epi64(0);
|
||||
const __m512i t = _mm512_set1_epi64(-1);
|
||||
const __m512i f = _mm512_set_1to8_epi64(0);
|
||||
const __m512i t = _mm512_set_1to8_epi64(-1);
|
||||
return _mm512_mask_or_epi64(f,v,t,t);
|
||||
#endif
|
||||
}
|
||||
@@ -122,13 +122,13 @@ namespace embree
|
||||
__forceinline int none( const vboold8& valid, const vboold8& b ) { return none(valid & b); }
|
||||
|
||||
__forceinline size_t movemask( const vboold8& a ) { return _mm512_kmov(a); }
|
||||
__forceinline size_t popcnt ( const vboold8& a ) { return __popcnt(a.v); }
|
||||
__forceinline size_t popcnt ( const vboold8& a ) { return _mm_countbits_64(a.v); }
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// Conversion Operations
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
__forceinline unsigned int toInt(const vboold8 &a) { return mm512_mask2int(a); }
|
||||
__forceinline unsigned int toInt(const vboold8 &a) { return _mm512_mask2int(a); }
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// Get/Set Functions
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ======================================================================== //
|
||||
// Copyright 2009-2017 Intel Corporation //
|
||||
// Copyright 2009-2016 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
@@ -79,7 +79,7 @@ namespace embree
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
__forceinline bool operator []( const size_t index ) const {
|
||||
assert(index < 16); return (mm512_mask2int(v) >> index) & 1;
|
||||
assert(index < 16); return (_mm512_mask2int(v) >> index) & 1;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -131,14 +131,14 @@ namespace embree
|
||||
__forceinline int none( const vboolf16& valid, const vboolf16& b ) { return none(valid & b); }
|
||||
|
||||
__forceinline size_t movemask( const vboolf16& a ) { return _mm512_kmov(a); }
|
||||
__forceinline size_t popcnt ( const vboolf16& a ) { return __popcnt(a.v); }
|
||||
__forceinline size_t popcnt ( const vboolf16& a ) { return _mm_countbits_32(a.v); }
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// Convertion Operations
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
__forceinline unsigned int toInt (const vboolf16 &a) { return mm512_mask2int(a); }
|
||||
__forceinline vboolf16 toMask(const int &a) { return mm512_int2mask(a); }
|
||||
__forceinline unsigned int toInt (const vboolf16 &a) { return _mm512_mask2int(a); }
|
||||
__forceinline vboolf16 toMask(const int &a) { return _mm512_int2mask(a); }
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// Get/Set Functions
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ======================================================================== //
|
||||
// Copyright 2009-2017 Intel Corporation //
|
||||
// Copyright 2009-2016 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
@@ -114,13 +114,13 @@ namespace embree
|
||||
__forceinline int none( const vboolf4& valid, const vboolf4& b ) { return none(valid & b); }
|
||||
|
||||
__forceinline size_t movemask( const vboolf4& a ) { return _mm512_kmov(a); }
|
||||
__forceinline size_t popcnt ( const vboolf4& a ) { return __popcnt(a.v); }
|
||||
__forceinline size_t popcnt ( const vboolf4& a ) { return _mm_countbits_64(a.v); }
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// Conversion Operations
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
__forceinline unsigned int toInt(const vboolf4 &a) { return mm512_mask2int(a); }
|
||||
__forceinline unsigned int toInt(const vboolf4 &a) { return _mm512_mask2int(a); }
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// Get/Set Functions
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ======================================================================== //
|
||||
// Copyright 2009-2017 Intel Corporation //
|
||||
// Copyright 2009-2016 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
@@ -48,8 +48,10 @@ namespace embree
|
||||
: v(_mm_lookupmask_ps[(size_t(b) << 3) | (size_t(a) << 2) | (size_t(b) << 1) | size_t(a)]) {}
|
||||
__forceinline vboolf( bool a, bool b, bool c, bool d )
|
||||
: v(_mm_lookupmask_ps[(size_t(d) << 3) | (size_t(c) << 2) | (size_t(b) << 1) | size_t(a)]) {}
|
||||
__forceinline vboolf( int mask ) { assert(mask >= 0 && mask < 16); v = _mm_lookupmask_ps[mask]; }
|
||||
__forceinline vboolf( unsigned mask ) { assert(mask >= 0 && mask < 16); v = _mm_lookupmask_ps[mask]; }
|
||||
__forceinline vboolf( int mask ) {
|
||||
assert(mask >= 0 && mask < 16);
|
||||
v = _mm_lookupmask_ps[mask];
|
||||
}
|
||||
|
||||
/* return int32 mask */
|
||||
__forceinline __m128i mask32() const {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ======================================================================== //
|
||||
// Copyright 2009-2017 Intel Corporation //
|
||||
// Copyright 2009-2016 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ======================================================================== //
|
||||
// Copyright 2009-2017 Intel Corporation //
|
||||
// Copyright 2009-2016 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
@@ -114,13 +114,13 @@ namespace embree
|
||||
__forceinline int none( const vboolf8& valid, const vboolf8& b ) { return none(valid & b); }
|
||||
|
||||
__forceinline size_t movemask( const vboolf8& a ) { return _mm512_kmov(a); }
|
||||
__forceinline size_t popcnt ( const vboolf8& a ) { return __popcnt(a.v); }
|
||||
__forceinline size_t popcnt ( const vboolf8& a ) { return _mm_countbits_64(a.v); }
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// Conversion Operations
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
__forceinline unsigned int toInt(const vboolf8 &a) { return mm512_mask2int(a); }
|
||||
__forceinline unsigned int toInt(const vboolf8 &a) { return _mm512_mask2int(a); }
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// Get/Set Functions
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ======================================================================== //
|
||||
// Copyright 2009-2017 Intel Corporation //
|
||||
// Copyright 2009-2016 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
@@ -180,12 +180,12 @@ namespace embree
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if defined(__AVX512VL__)
|
||||
__forceinline const vboold4 operator ==( const vdouble4& a, const vdouble4& b ) { return _mm256_cmp_pd_mask(a,b,_MM_CMPINT_EQ); }
|
||||
__forceinline const vboold4 operator !=( const vdouble4& a, const vdouble4& b ) { return _mm256_cmp_pd_mask(a,b,_MM_CMPINT_NE); }
|
||||
__forceinline const vboold4 operator < ( const vdouble4& a, const vdouble4& b ) { return _mm256_cmp_pd_mask(a,b,_MM_CMPINT_LT); }
|
||||
__forceinline const vboold4 operator >=( const vdouble4& a, const vdouble4& b ) { return _mm256_cmp_pd_mask(a,b,_MM_CMPINT_GE); }
|
||||
__forceinline const vboold4 operator > ( const vdouble4& a, const vdouble4& b ) { return _mm256_cmp_pd_mask(a,b,_MM_CMPINT_GT); }
|
||||
__forceinline const vboold4 operator <=( const vdouble4& a, const vdouble4& b ) { return _mm256_cmp_pd_mask(a,b,_MM_CMPINT_LE); }
|
||||
__forceinline const vboold4 operator ==( const vdouble4& a, const vdouble4& b ) { return _mm256_cmp_pd_mask(a,b,_CMP_EQ_UQ); }
|
||||
__forceinline const vboold4 operator !=( const vdouble4& a, const vdouble4& b ) { return _mm256_cmp_pd_mask(a,b,_CMP_NEQ_UQ); }
|
||||
__forceinline const vboold4 operator < ( const vdouble4& a, const vdouble4& b ) { return _mm256_cmp_pd_mask(a,b,_CMP_LT_OQ); }
|
||||
__forceinline const vboold4 operator >=( const vdouble4& a, const vdouble4& b ) { return _mm256_cmp_pd_mask(a,b,_CMP_GE_OQ); }
|
||||
__forceinline const vboold4 operator > ( const vdouble4& a, const vdouble4& b ) { return _mm256_cmp_pd_mask(a,b,_CMP_GT_OQ); }
|
||||
__forceinline const vboold4 operator <=( const vdouble4& a, const vdouble4& b ) { return _mm256_cmp_pd_mask(a,b,_CMP_LE_OQ); }
|
||||
#else
|
||||
__forceinline const vboold4 operator ==( const vdouble4& a, const vdouble4& b ) { return _mm256_cmp_pd(a,b,_CMP_EQ_UQ); }
|
||||
__forceinline const vboold4 operator !=( const vdouble4& a, const vdouble4& b ) { return _mm256_cmp_pd(a,b,_CMP_NEQ_UQ); }
|
||||
@@ -219,22 +219,6 @@ namespace embree
|
||||
__forceinline vboold4 ge(const vdouble4& a, const vdouble4& b) { return a >= b; }
|
||||
__forceinline vboold4 gt(const vdouble4& a, const vdouble4& b) { return a > b; }
|
||||
__forceinline vboold4 le(const vdouble4& a, const vdouble4& b) { return a <= b; }
|
||||
|
||||
#if defined(__AVX512VL__)
|
||||
__forceinline vboold4 eq(const vboold4& mask, const vdouble4& a, const vdouble4& b) { return _mm256_mask_cmp_pd_mask(mask, a, b, _MM_CMPINT_EQ); }
|
||||
__forceinline vboold4 ne(const vboold4& mask, const vdouble4& a, const vdouble4& b) { return _mm256_mask_cmp_pd_mask(mask, a, b, _MM_CMPINT_NE); }
|
||||
__forceinline vboold4 lt(const vboold4& mask, const vdouble4& a, const vdouble4& b) { return _mm256_mask_cmp_pd_mask(mask, a, b, _MM_CMPINT_LT); }
|
||||
__forceinline vboold4 ge(const vboold4& mask, const vdouble4& a, const vdouble4& b) { return _mm256_mask_cmp_pd_mask(mask, a, b, _MM_CMPINT_GE); }
|
||||
__forceinline vboold4 gt(const vboold4& mask, const vdouble4& a, const vdouble4& b) { return _mm256_mask_cmp_pd_mask(mask, a, b, _MM_CMPINT_GT); }
|
||||
__forceinline vboold4 le(const vboold4& mask, const vdouble4& a, const vdouble4& b) { return _mm256_mask_cmp_pd_mask(mask, a, b, _MM_CMPINT_LE); }
|
||||
#else
|
||||
__forceinline vboold4 eq(const vboold4& mask, const vdouble4& a, const vdouble4& b) { return mask & (a == b); }
|
||||
__forceinline vboold4 ne(const vboold4& mask, const vdouble4& a, const vdouble4& b) { return mask & (a != b); }
|
||||
__forceinline vboold4 lt(const vboold4& mask, const vdouble4& a, const vdouble4& b) { return mask & (a < b); }
|
||||
__forceinline vboold4 ge(const vboold4& mask, const vdouble4& a, const vdouble4& b) { return mask & (a >= b); }
|
||||
__forceinline vboold4 gt(const vboold4& mask, const vdouble4& a, const vdouble4& b) { return mask & (a > b); }
|
||||
__forceinline vboold4 le(const vboold4& mask, const vdouble4& a, const vdouble4& b) { return mask & (a <= b); }
|
||||
#endif
|
||||
|
||||
__forceinline const vdouble4 select( const vboold4& m, const vdouble4& t, const vdouble4& f ) {
|
||||
#if defined(__AVX512VL__)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ======================================================================== //
|
||||
// Copyright 2009-2017 Intel Corporation //
|
||||
// Copyright 2009-2016 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
@@ -17,7 +17,7 @@
|
||||
#pragma once
|
||||
|
||||
namespace embree
|
||||
{
|
||||
{
|
||||
/* 8-wide AVX-512 64bit double type */
|
||||
template<>
|
||||
struct vdouble<8>
|
||||
@@ -26,14 +26,14 @@ namespace embree
|
||||
|
||||
enum { size = 8 }; // number of SIMD elements
|
||||
union { // data
|
||||
__m512d v;
|
||||
double i[8];
|
||||
__m512d v;
|
||||
double i[8];
|
||||
};
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// Constructors, Assignment & Cast Operators
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
__forceinline vdouble() {}
|
||||
__forceinline vdouble(const vdouble8& t) { v = t.v; }
|
||||
__forceinline vdouble8& operator=(const vdouble8& f) { v = f.v; return *this; }
|
||||
@@ -43,59 +43,60 @@ namespace embree
|
||||
__forceinline operator __m256d () const { return _mm512_castpd512_pd256(v); }
|
||||
|
||||
__forceinline vdouble(const double i) {
|
||||
v = _mm512_set1_pd(i);
|
||||
v = _mm512_set_1to8_pd(i);
|
||||
}
|
||||
|
||||
|
||||
__forceinline vdouble(const double a, const double b, const double c, const double d) {
|
||||
v = _mm512_set4_pd(d,c,b,a);
|
||||
v = _mm512_set_4to8_pd(d,c,b,a);
|
||||
}
|
||||
|
||||
__forceinline vdouble(const double a0 , const double a1 , const double a2 , const double a3,
|
||||
__forceinline vdouble(const double a0 , const double a1 , const double a2 , const double a3,
|
||||
const double a4 , const double a5 , const double a6 , const double a7)
|
||||
{
|
||||
v = _mm512_set_pd(a7,a6,a5,a4,a3,a2,a1,a0);
|
||||
v = _mm512_set_8to8_pd(a7,a6,a5,a4,a3,a2,a1,a0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// Constants
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
__forceinline vdouble( ZeroTy ) : v(_mm512_setzero_pd()) {}
|
||||
__forceinline vdouble( OneTy ) : v(_mm512_set1_pd(1)) {}
|
||||
__forceinline vdouble( StepTy ) : v(_mm512_set_pd(7.0,6.0,5.0,4.0,3.0,2.0,1.0,0.0)) {}
|
||||
__forceinline vdouble( OneTy ) : v(_mm512_set_1to8_pd(1)) {}
|
||||
__forceinline vdouble( StepTy ) : v(_mm512_set_8to8_pd(7.0,6.0,5.0,4.0,3.0,2.0,1.0,0.0)) {}
|
||||
__forceinline vdouble( ReverseStepTy ) : v(_mm512_setr_pd(7.0,6.0,5.0,4.0,3.0,2.0,1.0,0.0)) {}
|
||||
|
||||
__forceinline static vdouble8 zero() { return _mm512_setzero_pd(); }
|
||||
__forceinline static vdouble8 one () { return _mm512_set1_pd(1); }
|
||||
__forceinline static vdouble8 neg_one () { return _mm512_set1_pd(-1); }
|
||||
__forceinline static vdouble8 one () { return _mm512_set_1to8_pd(1); }
|
||||
__forceinline static vdouble8 neg_one () { return _mm512_set_1to8_pd(-1); }
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// Loads and Stores
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static __forceinline void store_nt(void *__restrict__ ptr, const vdouble8& a) {
|
||||
_mm512_stream_pd((double*)ptr,a);
|
||||
_mm512_stream_si512(ptr,_mm512_castpd_si512(a));
|
||||
}
|
||||
|
||||
static __forceinline vdouble8 loadu(const void* addr) {
|
||||
return _mm512_loadu_pd((double*)addr);
|
||||
static __forceinline vdouble8 loadu(const void* addr)
|
||||
{
|
||||
return _mm512_loadu_si512(addr);
|
||||
}
|
||||
|
||||
static __forceinline vdouble8 load(const vdouble8* addr) {
|
||||
return _mm512_load_pd((double*)addr);
|
||||
return _mm512_load_si512(addr);
|
||||
}
|
||||
|
||||
static __forceinline vdouble8 load(const double* addr) {
|
||||
return _mm512_load_pd(addr);
|
||||
return _mm512_load_si512(addr);
|
||||
}
|
||||
|
||||
static __forceinline void store(void* ptr, const vdouble8& v) {
|
||||
_mm512_store_pd(ptr,v);
|
||||
_mm512_store_si512(ptr,_mm512_castpd_si512(v));
|
||||
}
|
||||
|
||||
static __forceinline void storeu(void* ptr, const vdouble8& v ) {
|
||||
_mm512_storeu_pd(ptr,v);
|
||||
_mm512_storeu_si512(ptr,_mm512_castpd_si512(v));
|
||||
}
|
||||
|
||||
static __forceinline void storeu(const vboold8& mask, double* ptr, const vdouble8& f ) {
|
||||
@@ -106,7 +107,7 @@ namespace embree
|
||||
_mm512_mask_store_pd(addr,mask,v2);
|
||||
}
|
||||
|
||||
/* pass by value to avoid compiler generating inefficient code */
|
||||
/* pass by value to avoid compiler generating inefficient code */
|
||||
static __forceinline void storeu_compact(const vboold8 mask,void * addr, const vdouble8& reg) {
|
||||
_mm512_mask_compressstoreu_pd(addr,mask,reg);
|
||||
}
|
||||
@@ -127,17 +128,17 @@ namespace embree
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// Array Access
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
__forceinline double& operator[](const size_t index) { assert(index < 8); return i[index]; }
|
||||
__forceinline const double& operator[](const size_t index) const { assert(index < 8); return i[index]; }
|
||||
|
||||
};
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// Unary Operators
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
__forceinline const vdouble8 asDouble ( const __m512& a ) { return _mm512_castps_pd(a); }
|
||||
__forceinline const vdouble8 asDouble ( const __m512& a ) { return _mm512_castps_si512(a); }
|
||||
__forceinline const vdouble8 operator +( const vdouble8& a ) { return a; }
|
||||
__forceinline const vdouble8 operator -( const vdouble8& a ) { return _mm512_sub_pd(_mm512_setzero_pd(), a); }
|
||||
|
||||
@@ -172,13 +173,13 @@ namespace embree
|
||||
__forceinline const vdouble8 operator <<( const vdouble8& a, const unsigned int n ) { return _mm512_castsi512_pd(_mm512_slli_epi64(_mm512_castpd_si512(a), n)); }
|
||||
__forceinline const vdouble8 operator >>( const vdouble8& a, const unsigned int n ) { return _mm512_castsi512_pd(_mm512_srai_epi64(_mm512_castpd_si512(a), n)); }
|
||||
|
||||
__forceinline const vdouble8 operator <<( const vdouble8& a, const vllong8& n ) { return _mm512_castsi512_pd(_mm512_sllv_epi64(_mm512_castpd_si512(a), n)); }
|
||||
__forceinline const vdouble8 operator >>( const vdouble8& a, const vllong8& n ) { return _mm512_castsi512_pd(_mm512_srav_epi64(_mm512_castpd_si512(a), n)); }
|
||||
__forceinline const vdouble8 operator <<( const vdouble8& a, const vlong8& n ) { return _mm512_castsi512_pd(_mm512_sllv_epi64(_mm512_castpd_si512(a), n)); }
|
||||
__forceinline const vdouble8 operator >>( const vdouble8& a, const vlong8& n ) { return _mm512_castsi512_pd(_mm512_srav_epi64(_mm512_castpd_si512(a), n)); }
|
||||
|
||||
__forceinline const vdouble8 sll ( const vdouble8& a, const unsigned int b ) { return _mm512_castsi512_pd(_mm512_slli_epi64(_mm512_castpd_si512(a), b)); }
|
||||
__forceinline const vdouble8 sra ( const vdouble8& a, const unsigned int b ) { return _mm512_castsi512_pd(_mm512_srai_epi64(_mm512_castpd_si512(a), b)); }
|
||||
__forceinline const vdouble8 srl ( const vdouble8& a, const unsigned int b ) { return _mm512_castsi512_pd(_mm512_srli_epi64(_mm512_castpd_si512(a), b)); }
|
||||
|
||||
|
||||
__forceinline const vdouble8 min( const vdouble8& a, const vdouble8& b ) { return _mm512_min_pd(a, b); }
|
||||
__forceinline const vdouble8 min( const vdouble8& a, const double b ) { return min(a,vdouble8(b)); }
|
||||
__forceinline const vdouble8 min( const double a, const vdouble8& b ) { return min(vdouble8(a),b); }
|
||||
@@ -186,7 +187,7 @@ namespace embree
|
||||
__forceinline const vdouble8 max( const vdouble8& a, const vdouble8& b ) { return _mm512_max_pd(a, b); }
|
||||
__forceinline const vdouble8 max( const vdouble8& a, const double b ) { return max(a,vdouble8(b)); }
|
||||
__forceinline const vdouble8 max( const double a, const vdouble8& b ) { return max(vdouble8(a),b); }
|
||||
|
||||
|
||||
__forceinline const vdouble8 mask_add(const vboold8& mask, vdouble8& c, const vdouble8& a, const vdouble8& b) { return _mm512_mask_add_pd(c,mask,a,b); }
|
||||
__forceinline const vdouble8 mask_sub(const vboold8& mask, vdouble8& c, const vdouble8& a, const vdouble8& b) { return _mm512_mask_sub_pd(c,mask,a,b); }
|
||||
|
||||
@@ -199,19 +200,19 @@ namespace embree
|
||||
|
||||
__forceinline vdouble8& operator +=( vdouble8& a, const vdouble8& b ) { return a = a + b; }
|
||||
__forceinline vdouble8& operator +=( vdouble8& a, const double b ) { return a = a + b; }
|
||||
|
||||
|
||||
__forceinline vdouble8& operator -=( vdouble8& a, const vdouble8& b ) { return a = a - b; }
|
||||
__forceinline vdouble8& operator -=( vdouble8& a, const double b ) { return a = a - b; }
|
||||
|
||||
__forceinline vdouble8& operator *=( vdouble8& a, const vdouble8& b ) { return a = a * b; }
|
||||
__forceinline vdouble8& operator *=( vdouble8& a, const double b ) { return a = a * b; }
|
||||
|
||||
|
||||
__forceinline vdouble8& operator &=( vdouble8& a, const vdouble8& b ) { return a = a & b; }
|
||||
__forceinline vdouble8& operator &=( vdouble8& a, const double b ) { return a = a & b; }
|
||||
|
||||
|
||||
__forceinline vdouble8& operator |=( vdouble8& a, const vdouble8& b ) { return a = a | b; }
|
||||
__forceinline vdouble8& operator |=( vdouble8& a, const double b ) { return a = a | b; }
|
||||
|
||||
|
||||
__forceinline vdouble8& operator <<=( vdouble8& a, const double b ) { return a = a << b; }
|
||||
__forceinline vdouble8& operator >>=( vdouble8& a, const double b ) { return a = a >> b; }
|
||||
|
||||
@@ -223,15 +224,15 @@ namespace embree
|
||||
__forceinline const vboold8 operator ==( const vdouble8& a, const vdouble8& b ) { return _mm512_cmp_pd_mask(a,b,_MM_CMPINT_EQ); }
|
||||
__forceinline const vboold8 operator ==( const vdouble8& a, const double b ) { return a == vdouble8(b); }
|
||||
__forceinline const vboold8 operator ==( const double a, const vdouble8& b ) { return vdouble8(a) == b; }
|
||||
|
||||
|
||||
__forceinline const vboold8 operator !=( const vdouble8& a, const vdouble8& b ) { return _mm512_cmp_pd_mask(a,b,_MM_CMPINT_NE); }
|
||||
__forceinline const vboold8 operator !=( const vdouble8& a, const double b ) { return a != vdouble8(b); }
|
||||
__forceinline const vboold8 operator !=( const double a, const vdouble8& b ) { return vdouble8(a) != b; }
|
||||
|
||||
|
||||
__forceinline const vboold8 operator < ( const vdouble8& a, const vdouble8& b ) { return _mm512_cmp_pd_mask(a,b,_MM_CMPINT_LT); }
|
||||
__forceinline const vboold8 operator < ( const vdouble8& a, const double b ) { return a < vdouble8(b); }
|
||||
__forceinline const vboold8 operator < ( const double a, const vdouble8& b ) { return vdouble8(a) < b; }
|
||||
|
||||
|
||||
__forceinline const vboold8 operator >=( const vdouble8& a, const vdouble8& b ) { return _mm512_cmp_pd_mask(a,b,_MM_CMPINT_GE); }
|
||||
__forceinline const vboold8 operator >=( const vdouble8& a, const double b ) { return a >= vdouble8(b); }
|
||||
__forceinline const vboold8 operator >=( const double a, const vdouble8& b ) { return vdouble8(a) >= b; }
|
||||
@@ -244,22 +245,26 @@ namespace embree
|
||||
__forceinline const vboold8 operator <=( const vdouble8& a, const double b ) { return a <= vdouble8(b); }
|
||||
__forceinline const vboold8 operator <=( const double a, const vdouble8& b ) { return vdouble8(a) <= b; }
|
||||
|
||||
__forceinline vboold8 eq(const vdouble8& a, const vdouble8& b) { return _mm512_cmp_pd_mask(a,b,_MM_CMPINT_EQ); }
|
||||
__forceinline vboold8 ne(const vdouble8& a, const vdouble8& b) { return _mm512_cmp_pd_mask(a,b,_MM_CMPINT_NE); }
|
||||
__forceinline vboold8 lt(const vdouble8& a, const vdouble8& b) { return _mm512_cmp_pd_mask(a,b,_MM_CMPINT_LT); }
|
||||
__forceinline vboold8 ge(const vdouble8& a, const vdouble8& b) { return _mm512_cmp_pd_mask(a,b,_MM_CMPINT_GE); }
|
||||
__forceinline vboold8 gt(const vdouble8& a, const vdouble8& b) { return _mm512_cmp_pd_mask(a,b,_MM_CMPINT_GT); }
|
||||
__forceinline vboold8 le(const vdouble8& a, const vdouble8& b) { return _mm512_cmp_pd_mask(a,b,_MM_CMPINT_LE); }
|
||||
|
||||
__forceinline vboold8 eq( const vdouble8& a, const vdouble8& b) { return _mm512_cmp_pd_mask(a,b,_MM_CMPINT_EQ); }
|
||||
__forceinline vboold8 eq(const vboold8 mask, const vdouble8& a, const vdouble8& b) { return _mm512_mask_cmp_pd_mask(mask,a,b,_MM_CMPINT_EQ); }
|
||||
|
||||
__forceinline vboold8 ne( const vdouble8& a, const vdouble8& b) { return _mm512_cmp_pd_mask(a,b,_MM_CMPINT_NE); }
|
||||
__forceinline vboold8 ne(const vboold8 mask, const vdouble8& a, const vdouble8& b) { return _mm512_mask_cmp_pd_mask(mask,a,b,_MM_CMPINT_NE); }
|
||||
__forceinline vboold8 lt(const vboold8 mask, const vdouble8& a, const vdouble8& b) { return _mm512_mask_cmp_pd_mask(mask,a,b,_MM_CMPINT_LT); }
|
||||
__forceinline vboold8 ge(const vboold8 mask, const vdouble8& a, const vdouble8& b) { return _mm512_mask_cmp_pd_mask(mask,a,b,_MM_CMPINT_GE); }
|
||||
__forceinline vboold8 gt(const vboold8 mask, const vdouble8& a, const vdouble8& b) { return _mm512_mask_cmp_pd_mask(mask,a,b,_MM_CMPINT_GT); }
|
||||
__forceinline vboold8 le(const vboold8 mask, const vdouble8& a, const vdouble8& b) { return _mm512_mask_cmp_pd_mask(mask,a,b,_MM_CMPINT_LE); }
|
||||
|
||||
__forceinline vboold8 lt( const vdouble8& a, const vdouble8& b) { return _mm512_cmp_pd_mask(a,b,_MM_CMPINT_LT); }
|
||||
__forceinline vboold8 lt(const vboold8 mask, const vdouble8& a, const vdouble8& b) { return _mm512_mask_cmp_pd_mask(mask,a,b,_MM_CMPINT_LT); }
|
||||
|
||||
__forceinline vboold8 ge( const vdouble8& a, const vdouble8& b) { return _mm512_cmp_pd_mask(a,b,_MM_CMPINT_GE); }
|
||||
__forceinline vboold8 ge(const vboold8 mask, const vdouble8& a, const vdouble8& b) { return _mm512_mask_cmp_pd_mask(mask,a,b,_MM_CMPINT_GE); }
|
||||
|
||||
__forceinline vboold8 gt( const vdouble8& a, const vdouble8& b) { return _mm512_cmp_pd_mask(a,b,_MM_CMPINT_GT); }
|
||||
__forceinline vboold8 gt(const vboold8 mask, const vdouble8& a, const vdouble8& b) { return _mm512_mask_cmp_pd_mask(mask,a,b,_MM_CMPINT_GT); }
|
||||
|
||||
__forceinline vboold8 le( const vdouble8& a, const vdouble8& b) { return _mm512_cmp_pd_mask(a,b,_MM_CMPINT_LE); }
|
||||
__forceinline vboold8 le(const vboold8 mask, const vdouble8& a, const vdouble8& b) { return _mm512_mask_cmp_pd_mask(mask,a,b,_MM_CMPINT_LE); }
|
||||
|
||||
__forceinline const vdouble8 select( const vboold8& m, const vdouble8& t, const vdouble8& f ) {
|
||||
return _mm512_mask_or_pd(f,m,t,t);
|
||||
return _mm512_mask_or_pd(f,m,t,t);
|
||||
}
|
||||
|
||||
__forceinline void xchg(const vboold8& m, vdouble8& a, vdouble8& b) {
|
||||
@@ -278,72 +283,70 @@ namespace embree
|
||||
// Movement/Shifting/Shuffling Functions
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template<size_t i>
|
||||
__forceinline const vdouble8 shuffle( const vdouble8& a ) {
|
||||
return _mm512_permute_pd(a, _MM_SHUFFLE(i, i, i, i));
|
||||
}
|
||||
|
||||
template<int A, int B, int C, int D>
|
||||
__forceinline vdouble8 shuffle (const vdouble8& v) {
|
||||
return _mm512_permute_pd(v,_MM_SHUFFLE(D,C,B,A));
|
||||
}
|
||||
|
||||
template<int i>
|
||||
__forceinline vdouble8 shuffle4(const vdouble8& x) {
|
||||
return _mm512_shuffle_f64x2(x,x,_MM_SHUFFLE(i,i,i,i));
|
||||
}
|
||||
|
||||
template<int A, int B>
|
||||
__forceinline vdouble8 shuffle4(const vdouble8& x) {
|
||||
return _mm512_shuffle_f64x2(x,x,_MM_SHUFFLE(0,0,B,A));
|
||||
}
|
||||
__forceinline vdouble8 shuffle (const vdouble8& x,int perm32 ) { return _mm512_permutex_pd(x,perm32); }
|
||||
__forceinline vdouble8 shuffle4(const vdouble8& x,int perm128) { return _mm512_shuffle_f64x2(x,x,perm128); }
|
||||
|
||||
template<int D, int C, int B, int A> __forceinline vdouble8 shuffle (const vdouble8& v) { return _mm512_permutex_pd(v,(int)_MM_SHUF_PERM(D,C,B,A)); }
|
||||
template<int A> __forceinline vdouble8 shuffle (const vdouble8& x) { return shuffle<A,A,A,A>(v); }
|
||||
|
||||
template<int D, int C, int B, int A> __forceinline vdouble8 shuffle4(const vdouble8& v) { return shuffle4(v,(int)_MM_SHUF_PERM(D,C,B,A)); }
|
||||
template<int A> __forceinline vdouble8 shuffle4(const vdouble8& x) { return shuffle4<A,A,A,A>(x); }
|
||||
|
||||
template<int i>
|
||||
__forceinline vdouble8 align_shift_right(const vdouble8& a, const vdouble8& b)
|
||||
{
|
||||
return _mm512_castsi512_pd(_mm512_alignr_epi64(_mm512_castpd_si512(a),_mm512_castpd_si512(b),i));
|
||||
}
|
||||
return _mm512_alignr_pd(a,b,i);
|
||||
};
|
||||
|
||||
__forceinline double toScalar(const vdouble8& a) {
|
||||
return _mm_cvtsd_f64(_mm512_castpd512_pd128(a));
|
||||
__forceinline double toScalar(const vdouble8& a)
|
||||
{
|
||||
return _mm256_cvtsd_f64(_mm512_castpd512_pd256(a));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// Reductions
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
__forceinline vdouble8 vreduce_add2(vdouble8 x) { return x + shuffle<1,0,3,2>(x); }
|
||||
__forceinline vdouble8 vreduce_add4(vdouble8 x) { x = vreduce_add2(x); return x + shuffle<2,3,0,1>(x); }
|
||||
__forceinline vdouble8 vreduce_add (vdouble8 x) { x = vreduce_add4(x); return x + shuffle4<1,0>(x); }
|
||||
__forceinline double reduce_add(const vdouble8& a) { return _mm512_reduce_add_pd(a); }
|
||||
__forceinline double reduce_min(const vdouble8& a) { return _mm512_reduce_min_pd(a); }
|
||||
__forceinline double reduce_max(const vdouble8& a) { return _mm512_reduce_max_pd(a); }
|
||||
|
||||
__forceinline vdouble8 vreduce_min2(const vdouble8& x) { return min(x,shuffle(x,_MM_SHUF_PERM(2,3,0,1))); }
|
||||
__forceinline vdouble8 vreduce_min4(const vdouble8& y) { const vdouble8 x = vreduce_min2(y); return min(x,shuffle(x,_MM_SHUF_PERM(1,0,3,2))); }
|
||||
__forceinline vdouble8 vreduce_min (const vdouble8& y) { const vdouble8 x = vreduce_min4(y); return min(x,shuffle4(x,_MM_SHUF_PERM(1,0,3,2))); }
|
||||
|
||||
__forceinline vdouble8 vreduce_min2(vdouble8 x) { return min(x,shuffle<1,0,3,2>(x)); }
|
||||
__forceinline vdouble8 vreduce_min4(vdouble8 x) { x = vreduce_min2(x); return min(x,shuffle<2,3,0,1>(x)); }
|
||||
__forceinline vdouble8 vreduce_min (vdouble8 x) { x = vreduce_min4(x); return min(x,shuffle4<1,0>(x)); }
|
||||
__forceinline vdouble8 vreduce_max2(const vdouble8& x) { return max(x,shuffle(x,_MM_SHUF_PERM(1,0,3,2))); }
|
||||
__forceinline vdouble8 vreduce_max4(const vdouble8& y) { const vdouble8 x = vreduce_max2(y); return max(x,shuffle(x,_MM_SHUF_PERM(2,3,0,1))); }
|
||||
__forceinline vdouble8 vreduce_max (const vdouble8& y) { const vdouble8 x = vreduce_max4(y); return max(x,shuffle4(x,_MM_SHUF_PERM(1,0,3,2))); }
|
||||
|
||||
__forceinline vdouble8 vreduce_max2(vdouble8 x) { return max(x,shuffle<1,0,3,2>(x)); }
|
||||
__forceinline vdouble8 vreduce_max4(vdouble8 x) { x = vreduce_max2(x); return max(x,shuffle<2,3,0,1>(x)); }
|
||||
__forceinline vdouble8 vreduce_max (vdouble8 x) { x = vreduce_max4(x); return max(x,shuffle4<1,0>(x)); }
|
||||
__forceinline vdouble8 vreduce_and2(const vdouble8& x) { return x & shuffle(x,_MM_SHUF_PERM(1,0,3,2)); }
|
||||
__forceinline vdouble8 vreduce_and4(const vdouble8& y) { const vdouble8 x = vreduce_and2(y); return x & shuffle(x,_MM_SHUF_PERM(2,3,0,1)); }
|
||||
__forceinline vdouble8 vreduce_and (const vdouble8& y) { const vdouble8 x = vreduce_and4(y); return x & shuffle4(x,_MM_SHUF_PERM(1,0,3,2)); }
|
||||
|
||||
__forceinline double reduce_add(const vdouble8& v) { return toScalar(vreduce_add(v)); }
|
||||
__forceinline double reduce_min(const vdouble8& v) { return toScalar(vreduce_min(v)); }
|
||||
__forceinline double reduce_max(const vdouble8& v) { return toScalar(vreduce_max(v)); }
|
||||
__forceinline vdouble8 vreduce_or2(const vdouble8& x) { return x | shuffle(x,_MM_SHUF_PERM(1,0,3,2)); }
|
||||
__forceinline vdouble8 vreduce_or4(const vdouble8& y) { const vdouble8 x = vreduce_or2(y); return x | shuffle(x,_MM_SHUF_PERM(2,3,0,1)); }
|
||||
__forceinline vdouble8 vreduce_or (const vdouble8& y) { const vdouble8 x = vreduce_or4(y); return x | shuffle4(x,_MM_SHUF_PERM(1,0,3,2)); }
|
||||
|
||||
__forceinline vdouble8 vreduce_add2(const vdouble8& x) { return x + shuffle(x,_MM_SHUF_PERM(1,0,3,2)); }
|
||||
__forceinline vdouble8 vreduce_add4(const vdouble8& y) { const vdouble8 x = vreduce_add2(y); return x + shuffle(x,_MM_SHUF_PERM(2,3,0,1)); }
|
||||
__forceinline vdouble8 vreduce_add (const vdouble8& y) { const vdouble8 x = vreduce_add4(y); return x + shuffle4(x,_MM_SHUF_PERM(1,0,3,2)); }
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// Memory load and store operations
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
__forceinline vdouble8 permute(const vdouble8& v, const vllong8& index) {
|
||||
return _mm512_permutexvar_pd(index,v);
|
||||
__forceinline vdouble8 permute(const vdouble8& v, const vlong8& index) {
|
||||
return _mm512_permutexvar_pd(index,v);
|
||||
}
|
||||
|
||||
__forceinline vdouble8 reverse(const vdouble8& a) {
|
||||
return permute(a,vllong8(reverse_step));
|
||||
return permute(a,vlong8(reverse_step));
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// Output Operators
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
__forceinline std::ostream& operator<<(std::ostream& cout, const vdouble8& v)
|
||||
{
|
||||
cout << "<" << v[0];
|
||||
|
||||
+386
-156
@@ -1,5 +1,5 @@
|
||||
// ======================================================================== //
|
||||
// Copyright 2009-2017 Intel Corporation //
|
||||
// Copyright 2009-2016 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
@@ -46,10 +46,10 @@ namespace embree
|
||||
__forceinline operator __m256 () const { return _mm512_castps512_ps256(v); }
|
||||
|
||||
__forceinline vfloat(const float& f) {
|
||||
v = _mm512_set1_ps(f);
|
||||
v = _mm512_set_1to16_ps(f);
|
||||
}
|
||||
__forceinline vfloat(const float& a, const float& b, const float& c, const float& d) {
|
||||
v = _mm512_set4_ps(a,b,c,d);
|
||||
v = _mm512_set_4to16_ps(a,b,c,d);
|
||||
}
|
||||
|
||||
__forceinline vfloat(const vfloat4 &i) {
|
||||
@@ -106,7 +106,7 @@ namespace embree
|
||||
static __forceinline void storeu(const vboolf16& mask, void* ptr, const vfloat16& v) { _mm512_mask_storeu_ps((float*)ptr,mask,v); }
|
||||
|
||||
static __forceinline void store_nt(void *__restrict__ ptr, const vfloat16& a) {
|
||||
_mm512_stream_ps((float*)ptr,a);
|
||||
_mm512_stream_ps(ptr,a);
|
||||
}
|
||||
|
||||
static __forceinline vfloat16 broadcast(const float *const f) {
|
||||
@@ -116,14 +116,10 @@ namespace embree
|
||||
static __forceinline vfloat16 compact(const vboolf16& mask, vfloat16 &v) {
|
||||
return _mm512_mask_compress_ps(v,mask,v);
|
||||
}
|
||||
static __forceinline vfloat16 compact(const vboolf16& mask, vfloat16 &a, const vfloat16 &b) {
|
||||
static __forceinline vfloat16 compact(const vboolf16& mask, const vfloat16 &a, vfloat16 &b) {
|
||||
return _mm512_mask_compress_ps(a,mask,b);
|
||||
}
|
||||
|
||||
static __forceinline vfloat16 expand(const vboolf16& mask, const vfloat16& a, vfloat16& b) {
|
||||
return _mm512_mask_expand_ps(b,mask,a);
|
||||
}
|
||||
|
||||
static __forceinline vfloat16 loadu_compact(const vboolf16& mask, const void *const ptr) {
|
||||
return _mm512_mask_expandloadu_ps(vfloat16::undefined(),mask,(float*)ptr);
|
||||
}
|
||||
@@ -134,7 +130,7 @@ namespace embree
|
||||
|
||||
static __forceinline void storeu_compact_single(const vboolf16& mask, float * addr, const vfloat16 ®) {
|
||||
//_mm512_mask_compressstoreu_ps(addr,mask,reg);
|
||||
*addr = mm512_cvtss_f32(_mm512_mask_compress_ps(reg,mask,reg));
|
||||
*addr = _mm512_cvtss_f32(_mm512_mask_compress_ps(reg,mask,reg));
|
||||
}
|
||||
|
||||
|
||||
@@ -143,18 +139,18 @@ namespace embree
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
__forceinline vfloat( ZeroTy ) : v(_mm512_setzero_ps()) {}
|
||||
__forceinline vfloat( OneTy ) : v(_mm512_set1_ps(1.0f)) {}
|
||||
__forceinline vfloat( PosInfTy ) : v(_mm512_set1_ps(pos_inf)) {}
|
||||
__forceinline vfloat( NegInfTy ) : v(_mm512_set1_ps(neg_inf)) {}
|
||||
__forceinline vfloat( StepTy ) : v(_mm512_set_ps(15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0)) {}
|
||||
__forceinline vfloat( NaNTy ) : v(_mm512_set1_ps(nan)) {}
|
||||
__forceinline vfloat( OneTy ) : v(_mm512_set_1to16_ps(1.0f)) {}
|
||||
__forceinline vfloat( PosInfTy ) : v(_mm512_set_1to16_ps(pos_inf)) {}
|
||||
__forceinline vfloat( NegInfTy ) : v(_mm512_set_1to16_ps(neg_inf)) {}
|
||||
__forceinline vfloat( StepTy ) : v(_mm512_set_16to16_ps(15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0)) {}
|
||||
__forceinline vfloat( NaNTy ) : v(_mm512_set_1to16_ps(nan)) {}
|
||||
|
||||
__forceinline static vfloat16 undefined() { return _mm512_undefined_ps(); }
|
||||
__forceinline static vfloat16 undefined() { return _mm512_undefined(); }
|
||||
__forceinline static vfloat16 zero() { return _mm512_setzero_ps(); }
|
||||
__forceinline static vfloat16 one () { return _mm512_set1_ps(1.0f); }
|
||||
__forceinline static vfloat16 ulp () { return _mm512_set1_ps(embree::ulp); }
|
||||
__forceinline static vfloat16 inf () { return _mm512_set1_ps((float)pos_inf); }
|
||||
__forceinline static vfloat16 minus_inf () { return _mm512_set1_ps((float)neg_inf); }
|
||||
__forceinline static vfloat16 one () { return _mm512_set_1to16_ps(1.0f); }
|
||||
__forceinline static vfloat16 ulp () { return _mm512_set_1to16_ps(embree::ulp); }
|
||||
__forceinline static vfloat16 inf () { return _mm512_set_1to16_ps((float)pos_inf); }
|
||||
__forceinline static vfloat16 minus_inf () { return _mm512_set_1to16_ps((float)neg_inf); }
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// Array Access
|
||||
@@ -171,7 +167,8 @@ namespace embree
|
||||
__forceinline const vfloat16 asFloat ( const __m512i& a ) { return _mm512_castsi512_ps(a); }
|
||||
__forceinline const vfloat16 operator +( const vfloat16& a ) { return a; }
|
||||
__forceinline const vfloat16 operator -( const vfloat16& a ) { return _mm512_mul_ps(a,vfloat16(-1)); }
|
||||
__forceinline const vfloat16 abs ( const vfloat16& a ) { return _mm512_castsi512_ps(_mm512_and_epi32(_mm512_castps_si512(a),_mm512_set1_epi32(0x7FFFFFFF))); }
|
||||
__forceinline const vfloat16 abs ( const vfloat16& a ) { return _mm512_abs_ps(a); }
|
||||
|
||||
__forceinline const vfloat16 signmsk ( const vfloat16& a ) { return _mm512_castsi512_ps(_mm512_and_epi32(_mm512_castps_si512(a),_mm512_set1_epi32(0x80000000))); }
|
||||
|
||||
__forceinline const vfloat16 rcp(const vfloat16& a) {
|
||||
@@ -185,18 +182,33 @@ namespace embree
|
||||
|
||||
__forceinline const vfloat16 sqr ( const vfloat16& a ) { return _mm512_mul_ps(a,a); }
|
||||
__forceinline const vfloat16 sqrt ( const vfloat16& a ) { return _mm512_sqrt_ps(a); }
|
||||
__forceinline const vfloat16 rsqrt( const vfloat16& a ) { return _mm512_invsqrt_ps(a); }
|
||||
|
||||
__forceinline const vfloat16 rsqrt( const vfloat16& a )
|
||||
{
|
||||
#if defined(__AVX512VL__)
|
||||
const vfloat16 r = _mm512_rsqrt14_ps(a.v);
|
||||
return _mm512_fmadd_ps(_mm512_set1_ps(1.5f), r,
|
||||
_mm512_mul_ps(_mm512_mul_ps(_mm512_mul_ps(a, _mm512_set1_ps(-0.5f)), r), _mm512_mul_ps(r, r)));
|
||||
#else
|
||||
return _mm512_rsqrt28_ps(a.v);
|
||||
#endif
|
||||
}
|
||||
|
||||
__forceinline vfloat16 exp(const vfloat16& a) { return _mm512_exp_ps(a); }
|
||||
__forceinline vfloat16 exp2(const vfloat16& a) { return _mm512_exp2_ps(a); }
|
||||
__forceinline vfloat16 pow(const vfloat16& a, vfloat16 b) { return _mm512_pow_ps(a,b); }
|
||||
|
||||
__forceinline vfloat16 log(const vfloat16& a) { return _mm512_log_ps(a); }
|
||||
__forceinline vfloat16 log2(const vfloat16& a) { return _mm512_log2_ps(a); }
|
||||
__forceinline vfloat16 log10(const vfloat16& a) { return _mm512_log10_ps(a); }
|
||||
|
||||
__forceinline vfloat16 sin(const vfloat16& a) { return _mm512_sin_ps(a); }
|
||||
__forceinline vfloat16 cos(const vfloat16& a) { return _mm512_cos_ps(a); }
|
||||
__forceinline vfloat16 tan(const vfloat16& a) { return _mm512_tan_ps(a); }
|
||||
|
||||
__forceinline vfloat16 asin(const vfloat16& a) { return _mm512_asin_ps(a); }
|
||||
__forceinline vfloat16 acos(const vfloat16& a) { return _mm512_acos_ps(a); }
|
||||
__forceinline vfloat16 atan(const vfloat16& a) { return _mm512_atan_ps(a); }
|
||||
__forceinline vfloat16 atan2(const vfloat16& a, vfloat16 b) { return _mm512_atan2_ps(a,b); }
|
||||
|
||||
__forceinline vfloat16 sinh(const vfloat16& a) { return _mm512_sinh_ps(a); }
|
||||
__forceinline vfloat16 cosh(const vfloat16& a) { return _mm512_cosh_ps(a); }
|
||||
__forceinline vfloat16 tanh(const vfloat16& a) { return _mm512_tan_ps(a); }
|
||||
|
||||
__forceinline vfloat16 asinh(const vfloat16& a) { return _mm512_asinh_ps(a); }
|
||||
__forceinline vfloat16 acosh(const vfloat16& a) { return _mm512_acosh_ps(a); }
|
||||
__forceinline vfloat16 atanh(const vfloat16& a) { return _mm512_atanh_ps(a); }
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// Binary Operators
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -250,25 +262,10 @@ namespace embree
|
||||
};
|
||||
|
||||
__forceinline vfloat16 mini(const vfloat16& a, const vfloat16& b) {
|
||||
#if !defined(__AVX512ER__) // SKX
|
||||
const vint16 ai = _mm512_castps_si512(a);
|
||||
const vint16 bi = _mm512_castps_si512(b);
|
||||
const vint16 ci = _mm512_min_epi32(ai,bi);
|
||||
return _mm512_castsi512_ps(ci);
|
||||
#else // KNL
|
||||
return min(a,b);
|
||||
#endif
|
||||
}
|
||||
|
||||
__forceinline vfloat16 maxi(const vfloat16& a, const vfloat16& b) {
|
||||
#if !defined(__AVX512ER__) // SKX
|
||||
const vint16 ai = _mm512_castps_si512(a);
|
||||
const vint16 bi = _mm512_castps_si512(b);
|
||||
const vint16 ci = _mm512_max_epi32(ai,bi);
|
||||
return _mm512_castsi512_ps(ci);
|
||||
#else // KNL
|
||||
return max(a,b);
|
||||
#endif
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -292,32 +289,32 @@ namespace embree
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// Operators with rounding
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
__forceinline vfloat16 madd_round_down (const vfloat16& a, const vfloat16& b, const vfloat16& c) { return _mm512_fmadd_round_ps(a,b,c,_MM_FROUND_TO_NEG_INF); }
|
||||
|
||||
__forceinline vfloat16 madd_round_up (const vfloat16& a, const vfloat16& b, const vfloat16& c) { return _mm512_fmadd_round_ps(a,b,c,_MM_FROUND_TO_POS_INF); }
|
||||
|
||||
__forceinline vfloat16 mul_round_down (const vfloat16& a, const vfloat16& b) { return _mm512_mul_round_ps(a,b,_MM_FROUND_TO_NEG_INF); }
|
||||
__forceinline vfloat16 mul_round_up (const vfloat16& a, const vfloat16& b) { return _mm512_mul_round_ps(a,b,_MM_FROUND_TO_POS_INF); }
|
||||
|
||||
__forceinline vfloat16 add_round_down (const vfloat16& a, const vfloat16& b) { return _mm512_add_round_ps(a,b,_MM_FROUND_TO_NEG_INF); }
|
||||
__forceinline vfloat16 add_round_up (const vfloat16& a, const vfloat16& b) { return _mm512_add_round_ps(a,b,_MM_FROUND_TO_POS_INF); }
|
||||
|
||||
__forceinline vfloat16 sub_round_down (const vfloat16& a, const vfloat16& b) { return _mm512_sub_round_ps(a,b,_MM_FROUND_TO_NEG_INF); }
|
||||
__forceinline vfloat16 sub_round_up (const vfloat16& a, const vfloat16& b) { return _mm512_sub_round_ps(a,b,_MM_FROUND_TO_POS_INF); }
|
||||
|
||||
__forceinline vfloat16 div_round_down (const vfloat16& a, const vfloat16& b) { return _mm512_div_round_ps(a,b,_MM_FROUND_TO_NEG_INF); }
|
||||
__forceinline vfloat16 div_round_up (const vfloat16& a, const vfloat16& b) { return _mm512_div_round_ps(a,b,_MM_FROUND_TO_POS_INF); }
|
||||
|
||||
__forceinline vfloat16 mask_msub_round_down (const vboolf16& mask,const vfloat16& a, const vfloat16& b, const vfloat16& c) { return _mm512_mask_fmsub_round_ps(a,mask,b,c,_MM_FROUND_TO_NEG_INF); }
|
||||
__forceinline vfloat16 mask_msub_round_up (const vboolf16& mask,const vfloat16& a, const vfloat16& b, const vfloat16& c) { return _mm512_mask_fmsub_round_ps(a,mask,b,c,_MM_FROUND_TO_POS_INF); }
|
||||
|
||||
__forceinline vfloat16 madd_round_down (const vfloat16& a, const vfloat16& b, const vfloat16& c) { return _mm512_fmadd_round_ps(a,b,c,_MM_FROUND_TO_NEG_INF | _MM_FROUND_NO_EXC); }
|
||||
__forceinline vfloat16 madd_round_up (const vfloat16& a, const vfloat16& b, const vfloat16& c) { return _mm512_fmadd_round_ps(a,b,c,_MM_FROUND_TO_POS_INF | _MM_FROUND_NO_EXC); }
|
||||
__forceinline vfloat16 mask_mul_round_down (const vboolf16& mask,const vfloat16& a, const vfloat16& b, const vfloat16& c) { return _mm512_mask_mul_round_ps(a,mask,b,c,_MM_FROUND_TO_NEG_INF); }
|
||||
__forceinline vfloat16 mask_mul_round_up (const vboolf16& mask,const vfloat16& a, const vfloat16& b, const vfloat16& c) { return _mm512_mask_mul_round_ps(a,mask,b,c,_MM_FROUND_TO_POS_INF); }
|
||||
|
||||
__forceinline vfloat16 mul_round_down (const vfloat16& a, const vfloat16& b) { return _mm512_mul_round_ps(a,b,_MM_FROUND_TO_NEG_INF | _MM_FROUND_NO_EXC); }
|
||||
__forceinline vfloat16 mul_round_up (const vfloat16& a, const vfloat16& b) { return _mm512_mul_round_ps(a,b,_MM_FROUND_TO_POS_INF | _MM_FROUND_NO_EXC); }
|
||||
__forceinline vfloat16 mask_sub_round_down (const vboolf16& mask,const vfloat16& a, const vfloat16& b, const vfloat16& c) { return _mm512_mask_sub_round_ps(a,mask,b,c,_MM_FROUND_TO_NEG_INF); }
|
||||
__forceinline vfloat16 mask_sub_round_up (const vboolf16& mask,const vfloat16& a, const vfloat16& b, const vfloat16& c) { return _mm512_mask_sub_round_ps(a,mask,b,c,_MM_FROUND_TO_POS_INF); }
|
||||
|
||||
__forceinline vfloat16 add_round_down (const vfloat16& a, const vfloat16& b) { return _mm512_add_round_ps(a,b,_MM_FROUND_TO_NEG_INF | _MM_FROUND_NO_EXC); }
|
||||
__forceinline vfloat16 add_round_up (const vfloat16& a, const vfloat16& b) { return _mm512_add_round_ps(a,b,_MM_FROUND_TO_POS_INF | _MM_FROUND_NO_EXC); }
|
||||
|
||||
__forceinline vfloat16 sub_round_down (const vfloat16& a, const vfloat16& b) { return _mm512_sub_round_ps(a,b,_MM_FROUND_TO_NEG_INF | _MM_FROUND_NO_EXC); }
|
||||
__forceinline vfloat16 sub_round_up (const vfloat16& a, const vfloat16& b) { return _mm512_sub_round_ps(a,b,_MM_FROUND_TO_POS_INF | _MM_FROUND_NO_EXC); }
|
||||
|
||||
__forceinline vfloat16 div_round_down (const vfloat16& a, const vfloat16& b) { return _mm512_div_round_ps(a,b,_MM_FROUND_TO_NEG_INF | _MM_FROUND_NO_EXC); }
|
||||
__forceinline vfloat16 div_round_up (const vfloat16& a, const vfloat16& b) { return _mm512_div_round_ps(a,b,_MM_FROUND_TO_POS_INF | _MM_FROUND_NO_EXC); }
|
||||
|
||||
__forceinline vfloat16 mask_msub_round_down (const vboolf16& mask,const vfloat16& a, const vfloat16& b, const vfloat16& c) { return _mm512_mask_fmsub_round_ps(a,mask,b,c,_MM_FROUND_TO_NEG_INF | _MM_FROUND_NO_EXC); }
|
||||
__forceinline vfloat16 mask_msub_round_up (const vboolf16& mask,const vfloat16& a, const vfloat16& b, const vfloat16& c) { return _mm512_mask_fmsub_round_ps(a,mask,b,c,_MM_FROUND_TO_POS_INF | _MM_FROUND_NO_EXC); }
|
||||
|
||||
__forceinline vfloat16 mask_mul_round_down (const vboolf16& mask,const vfloat16& a, const vfloat16& b, const vfloat16& c) { return _mm512_mask_mul_round_ps(a,mask,b,c,_MM_FROUND_TO_NEG_INF | _MM_FROUND_NO_EXC); }
|
||||
__forceinline vfloat16 mask_mul_round_up (const vboolf16& mask,const vfloat16& a, const vfloat16& b, const vfloat16& c) { return _mm512_mask_mul_round_ps(a,mask,b,c,_MM_FROUND_TO_POS_INF | _MM_FROUND_NO_EXC); }
|
||||
|
||||
__forceinline vfloat16 mask_sub_round_down (const vboolf16& mask,const vfloat16& a, const vfloat16& b, const vfloat16& c) { return _mm512_mask_sub_round_ps(a,mask,b,c,_MM_FROUND_TO_NEG_INF | _MM_FROUND_NO_EXC); }
|
||||
__forceinline vfloat16 mask_sub_round_up (const vboolf16& mask,const vfloat16& a, const vfloat16& b, const vfloat16& c) { return _mm512_mask_sub_round_ps(a,mask,b,c,_MM_FROUND_TO_POS_INF | _MM_FROUND_NO_EXC); }
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// Assignment Operators
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -362,26 +359,30 @@ namespace embree
|
||||
__forceinline const vboolf16 operator <=( const vfloat16& a, const float& b ) { return a <= vfloat16(b); }
|
||||
__forceinline const vboolf16 operator <=( const float& a, const vfloat16& b ) { return vfloat16(a) <= b; }
|
||||
|
||||
__forceinline vboolf16 eq(const vfloat16& a, const vfloat16& b) { return _mm512_cmp_ps_mask(a,b,_MM_CMPINT_EQ); }
|
||||
__forceinline vboolf16 ne(const vfloat16& a, const vfloat16& b) { return _mm512_cmp_ps_mask(a,b,_MM_CMPINT_NE); }
|
||||
__forceinline vboolf16 lt(const vfloat16& a, const vfloat16& b) { return _mm512_cmp_ps_mask(a,b,_MM_CMPINT_LT); }
|
||||
__forceinline vboolf16 ge(const vfloat16& a, const vfloat16& b) { return _mm512_cmp_ps_mask(a,b,_MM_CMPINT_GE); }
|
||||
__forceinline vboolf16 gt(const vfloat16& a, const vfloat16& b) { return _mm512_cmp_ps_mask(a,b,_MM_CMPINT_GT); }
|
||||
__forceinline vboolf16 le(const vfloat16& a, const vfloat16& b) { return _mm512_cmp_ps_mask(a,b,_MM_CMPINT_LE); }
|
||||
|
||||
__forceinline vboolf16 eq( const vfloat16& a, const vfloat16& b) { return _mm512_cmp_ps_mask(a,b,_MM_CMPINT_EQ); }
|
||||
__forceinline vboolf16 eq(const vboolf16& mask, const vfloat16& a, const vfloat16& b) { return _mm512_mask_cmp_ps_mask(mask,a,b,_MM_CMPINT_EQ); }
|
||||
|
||||
__forceinline vboolf16 ne( const vfloat16& a, const vfloat16& b) { return _mm512_cmp_ps_mask(a,b,_MM_CMPINT_NE); }
|
||||
__forceinline vboolf16 ne(const vboolf16& mask, const vfloat16& a, const vfloat16& b) { return _mm512_mask_cmp_ps_mask(mask,a,b,_MM_CMPINT_NE); }
|
||||
|
||||
__forceinline vboolf16 lt( const vfloat16& a, const vfloat16& b) { return _mm512_cmp_ps_mask(a,b,_MM_CMPINT_LT); }
|
||||
__forceinline vboolf16 lt(const vboolf16& mask, const vfloat16& a, const vfloat16& b) { return _mm512_mask_cmp_ps_mask(mask,a,b,_MM_CMPINT_LT); }
|
||||
|
||||
__forceinline vboolf16 ge( const vfloat16& a, const vfloat16& b) { return _mm512_cmp_ps_mask(a,b,_MM_CMPINT_GE); }
|
||||
__forceinline vboolf16 ge(const vboolf16& mask, const vfloat16& a, const vfloat16& b) { return _mm512_mask_cmp_ps_mask(mask,a,b,_MM_CMPINT_GE); }
|
||||
|
||||
__forceinline vboolf16 gt( const vfloat16& a, const vfloat16& b) { return _mm512_cmp_ps_mask(a,b,_MM_CMPINT_GT); }
|
||||
__forceinline vboolf16 gt(const vboolf16& mask, const vfloat16& a, const vfloat16& b) { return _mm512_mask_cmp_ps_mask(mask,a,b,_MM_CMPINT_GT); }
|
||||
|
||||
__forceinline vboolf16 le( const vfloat16& a, const vfloat16& b) { return _mm512_cmp_ps_mask(a,b,_MM_CMPINT_LE); }
|
||||
__forceinline vboolf16 le(const vboolf16& mask, const vfloat16& a, const vfloat16& b) { return _mm512_mask_cmp_ps_mask(mask,a,b,_MM_CMPINT_LE); }
|
||||
|
||||
__forceinline const vfloat16 select( const vboolf16& s, const vfloat16& t, const vfloat16& f ) {
|
||||
return _mm512_mask_blend_ps(s, f, t);
|
||||
}
|
||||
|
||||
__forceinline vfloat16 lerp(const vfloat16& a, const vfloat16& b, const vfloat16& t) {
|
||||
return madd(t,b-a,a);
|
||||
__forceinline vfloat16 lerp(const vfloat16& a, const vfloat16& b, const vfloat16& t) {
|
||||
return madd(t, b, madd(-t, a, a));
|
||||
}
|
||||
|
||||
__forceinline void xchg(vboolf16 m, vfloat16& a, vfloat16& b)
|
||||
@@ -390,7 +391,6 @@ namespace embree
|
||||
a = select(m,b,a);
|
||||
b = select(m,c,b);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// Rounding Functions
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -401,37 +401,68 @@ namespace embree
|
||||
__forceinline vfloat16 ceil (const vfloat16& a) {
|
||||
return _mm512_ceil_ps(a);
|
||||
}
|
||||
__forceinline vfloat16 trunc(const vfloat16& a) {
|
||||
return _mm512_trunc_ps(a);
|
||||
}
|
||||
|
||||
__forceinline vint16 floori (const vfloat16& a) {
|
||||
return _mm512_cvt_roundps_epi32(a, _MM_FROUND_TO_NEG_INF | _MM_FROUND_NO_EXC);
|
||||
}
|
||||
|
||||
|
||||
__forceinline vfloat16 frac( const vfloat16& a ) { return a-trunc(a); }
|
||||
|
||||
__forceinline const vfloat16 rcp_nr( const vfloat16& a ) {
|
||||
const vfloat16 ra = rcp(a);
|
||||
return (ra+ra) - (ra * a * ra);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// Movement/Shifting/Shuffling Functions
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template<size_t i>
|
||||
__forceinline const vfloat16 shuffle( const vfloat16& a ) {
|
||||
return _mm512_permute_ps(a, _MM_SHUFFLE(i, i, i, i));
|
||||
__forceinline vfloat16 shuffle(const vfloat16& x, _MM_SWIZZLE_ENUM perm32) {
|
||||
return _mm512_swizzle_ps(x,perm32);
|
||||
}
|
||||
__forceinline vfloat16 shuffle4(const vfloat16& x, _MM_PERM_ENUM perm128) { return _mm512_permute4f128_ps(x, perm128); }
|
||||
|
||||
template<int D, int C, int B, int A> __forceinline vfloat16 shuffle (const vfloat16& v) {
|
||||
return _mm512_permute_ps(v,_MM_SHUF_PERM(D,C,B,A));
|
||||
}
|
||||
template<int A> __forceinline vfloat16 shuffle (const vfloat16& x) { return shuffle<A,A,A,A>(v); }
|
||||
template<> __forceinline vfloat16 shuffle<0>(const vfloat16& x) { return shuffle(x,_MM_SWIZ_REG_AAAA); }
|
||||
template<> __forceinline vfloat16 shuffle<1>(const vfloat16& x) { return shuffle(x,_MM_SWIZ_REG_BBBB); }
|
||||
template<> __forceinline vfloat16 shuffle<2>(const vfloat16& x) { return shuffle(x,_MM_SWIZ_REG_CCCC); }
|
||||
template<> __forceinline vfloat16 shuffle<3>(const vfloat16& x) { return shuffle(x,_MM_SWIZ_REG_DDDD); }
|
||||
|
||||
template<int D, int C, int B, int A> __forceinline vfloat16 shuffle4(const vfloat16& v) { return shuffle4(v,_MM_SHUF_PERM(D,C,B,A)); }
|
||||
template<int A> __forceinline vfloat16 shuffle4(const vfloat16& x) { return shuffle4<A,A,A,A>(x); }
|
||||
|
||||
__forceinline vfloat16 shuffle(const vfloat16& x,_MM_PERM_ENUM perm128, _MM_SWIZZLE_ENUM perm32) { return shuffle(shuffle4(x,perm128),perm32); }
|
||||
|
||||
__forceinline vfloat16 shuffle(const vboolf16& mask, vfloat16& v, const vfloat16& x,_MM_PERM_ENUM perm128, _MM_SWIZZLE_ENUM perm32) {
|
||||
return _mm512_mask_swizzle_ps(_mm512_mask_permute4f128_ps(v,mask,x,perm128),mask,x,perm32);
|
||||
}
|
||||
|
||||
template<int A, int B, int C, int D>
|
||||
__forceinline vfloat16 shuffle (const vfloat16& v) {
|
||||
return _mm512_permute_ps(v,_MM_SHUFFLE(D,C,B,A));
|
||||
__forceinline vfloat16 swAAAA(const vfloat16 &x) {
|
||||
return shuffle(x,_MM_SWIZ_REG_AAAA);
|
||||
}
|
||||
|
||||
template<int i>
|
||||
__forceinline vfloat16 shuffle4(const vfloat16& x) {
|
||||
return _mm512_shuffle_f32x4(x,x,_MM_SHUFFLE(i,i,i,i));
|
||||
__forceinline vfloat16 swBBBB(const vfloat16 &x) {
|
||||
return shuffle(x,_MM_SWIZ_REG_BBBB);
|
||||
}
|
||||
|
||||
template<int A, int B, int C, int D>
|
||||
__forceinline vfloat16 shuffle4(const vfloat16& x) {
|
||||
return _mm512_shuffle_f32x4(x,x,_MM_SHUFFLE(D,C,B,A));
|
||||
__forceinline vfloat16 swCCCC(const vfloat16 &x) {
|
||||
return shuffle(x,_MM_SWIZ_REG_CCCC);
|
||||
}
|
||||
|
||||
__forceinline vfloat16 swDDDD(const vfloat16 &x) {
|
||||
return shuffle(x,_MM_SWIZ_REG_DDDD);
|
||||
}
|
||||
|
||||
__forceinline vfloat16 permute(vfloat16 v,__m512i index)
|
||||
{
|
||||
return _mm512_castsi512_ps(_mm512_permutexvar_epi32(index,_mm512_castps_si512(v)));
|
||||
return _mm512_castsi512_ps(_mm512_permutevar_epi32(index,_mm512_castps_si512(v)));
|
||||
}
|
||||
|
||||
__forceinline vfloat16 reverse(const vfloat16 &a)
|
||||
@@ -451,60 +482,49 @@ namespace embree
|
||||
return _mm512_castsi512_ps(_mm512_mask_alignr_epi32(_mm512_castps_si512(c),mask,_mm512_castps_si512(a),_mm512_castps_si512(b),i));
|
||||
};
|
||||
|
||||
__forceinline vfloat16 shift_left_1(const vfloat16 &a) {
|
||||
__forceinline vfloat16 shl1_zero_extend(const vfloat16 &a)
|
||||
{
|
||||
vfloat16 z = vfloat16::zero();
|
||||
return mask_align_shift_right<15>(0xfffe,z,a,a);
|
||||
}
|
||||
|
||||
__forceinline vfloat16 shift_right_1( const vfloat16& x) {
|
||||
return align_shift_right<1>(zero,x);
|
||||
__forceinline vfloat16 shift_right_1( const vfloat16& x)
|
||||
{
|
||||
__m512 t0 = _mm512_permute_ps(x,_MM_PERM_ADCB);
|
||||
__m512 t1 = _mm512_permute4f128_ps(t0,_MM_PERM_ADCB);
|
||||
__m512 y = _mm512_mask_blend_ps(0x8888,t0,t1);
|
||||
return y;
|
||||
}
|
||||
|
||||
__forceinline float toScalar(const vfloat16& a) { return mm512_cvtss_f32(a); }
|
||||
__forceinline float toScalar(const vfloat16& a) { return _mm512_cvtss_f32(a); }
|
||||
|
||||
|
||||
template<int i> __forceinline const vfloat16 insert4(const vfloat16& a, const vfloat4& b) { return _mm512_insertf32x4(a, b, i); }
|
||||
|
||||
template<int N, int i>
|
||||
vfloat<N> extractN(const vfloat16& v);
|
||||
|
||||
template<> __forceinline vfloat4 extractN<4,0>(const vfloat16& v) { return _mm512_castps512_ps128(v); }
|
||||
template<> __forceinline vfloat4 extractN<4,1>(const vfloat16& v) { return _mm512_extractf32x4_ps(v, 1); }
|
||||
template<> __forceinline vfloat4 extractN<4,2>(const vfloat16& v) { return _mm512_extractf32x4_ps(v, 2); }
|
||||
template<> __forceinline vfloat4 extractN<4,3>(const vfloat16& v) { return _mm512_extractf32x4_ps(v, 3); }
|
||||
|
||||
template<> __forceinline vfloat8 extractN<8,0>(const vfloat16& v) { return _mm512_castps512_ps256(v); }
|
||||
template<> __forceinline vfloat8 extractN<8,1>(const vfloat16& v) { return _mm512_extractf32x8_ps(v, 1); }
|
||||
|
||||
template<int i> __forceinline vfloat4 extract4 (const vfloat16& v) { return _mm512_extractf32x4_ps(v, i); }
|
||||
template<> __forceinline vfloat4 extract4<0>(const vfloat16& v) { return _mm512_castps512_ps128(v); }
|
||||
|
||||
template<int i> __forceinline vfloat8 extract8 (const vfloat16& v) { return _mm512_extractf32x8_ps(v, i); }
|
||||
template<> __forceinline vfloat8 extract8<0>(const vfloat16& v) { return _mm512_castps512_ps256(v); }
|
||||
template<size_t i> __forceinline const vfloat16 insert4(const vfloat16& a, const vfloat4& b) { return _mm512_insertf32x4(a, b, i); }
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// Reductions
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
__forceinline vfloat16 vreduce_add2(vfloat16 x) { return x + shuffle<1,0,3,2>(x); }
|
||||
__forceinline vfloat16 vreduce_add4(vfloat16 x) { x = vreduce_add2(x); return x + shuffle<2,3,0,1>(x); }
|
||||
__forceinline vfloat16 vreduce_add8(vfloat16 x) { x = vreduce_add4(x); return x + shuffle4<1,0,3,2>(x); }
|
||||
__forceinline vfloat16 vreduce_add (vfloat16 x) { x = vreduce_add8(x); return x + shuffle4<2,3,0,1>(x); }
|
||||
__forceinline float reduce_add(const vfloat16 &a) { return _mm512_reduce_add_ps(a); }
|
||||
__forceinline float reduce_mul(const vfloat16 &a) { return _mm512_reduce_mul_ps(a); }
|
||||
__forceinline float reduce_min(const vfloat16 &a) { return _mm512_reduce_min_ps(a); }
|
||||
__forceinline float reduce_max(const vfloat16 &a) { return _mm512_reduce_max_ps(a); }
|
||||
|
||||
__forceinline vfloat16 vreduce_min2(vfloat16 x) { return min(x,shuffle<1,0,3,2>(x)); }
|
||||
__forceinline vfloat16 vreduce_min4(vfloat16 x) { x = vreduce_min2(x); return min(x,shuffle<2,3,0,1>(x)); }
|
||||
__forceinline vfloat16 vreduce_min8(vfloat16 x) { x = vreduce_min4(x); return min(x,shuffle4<1,0,3,2>(x)); }
|
||||
__forceinline vfloat16 vreduce_min (vfloat16 x) { x = vreduce_min8(x); return min(x,shuffle4<2,3,0,1>(x)); }
|
||||
__forceinline vfloat16 vreduce_min2(vfloat16 x) { return min(x,shuffle(x,_MM_SWIZ_REG_BADC)); }
|
||||
__forceinline vfloat16 vreduce_min4(vfloat16 x) { x = vreduce_min2(x); return min(x,shuffle(x,_MM_SWIZ_REG_CDAB)); }
|
||||
__forceinline vfloat16 vreduce_min8(vfloat16 x) { x = vreduce_min4(x); return min(x,shuffle4(x,_MM_SHUF_PERM(2,3,0,1))); }
|
||||
__forceinline vfloat16 vreduce_min (vfloat16 x) { x = vreduce_min8(x); return min(x,shuffle4(x,_MM_SHUF_PERM(1,0,3,2))); }
|
||||
|
||||
__forceinline vfloat16 vreduce_max2(vfloat16 x) { return max(x,shuffle<1,0,3,2>(x)); }
|
||||
__forceinline vfloat16 vreduce_max4(vfloat16 x) { x = vreduce_max2(x); return max(x,shuffle<2,3,0,1>(x)); }
|
||||
__forceinline vfloat16 vreduce_max8(vfloat16 x) { x = vreduce_max4(x); return max(x,shuffle4<1,0,3,2>(x)); }
|
||||
__forceinline vfloat16 vreduce_max (vfloat16 x) { x = vreduce_max8(x); return max(x,shuffle4<2,3,0,1>(x)); }
|
||||
__forceinline vfloat16 vreduce_max2(vfloat16 x) { return max(x,shuffle(x,_MM_SWIZ_REG_BADC)); }
|
||||
__forceinline vfloat16 vreduce_max4(vfloat16 x) { x = vreduce_max2(x); return max(x,shuffle(x,_MM_SWIZ_REG_CDAB)); }
|
||||
__forceinline vfloat16 vreduce_max8(vfloat16 x) { x = vreduce_max4(x); return max(x,shuffle4(x,_MM_SHUF_PERM(2,3,0,1))); }
|
||||
__forceinline vfloat16 vreduce_max (vfloat16 x) { x = vreduce_max8(x); return max(x,shuffle4(x,_MM_SHUF_PERM(1,0,3,2))); }
|
||||
|
||||
__forceinline vfloat16 vreduce_add2(vfloat16 x) { return x + shuffle(x,_MM_SWIZ_REG_BADC); }
|
||||
__forceinline vfloat16 vreduce_add4(vfloat16 x) { x = vreduce_add2(x); return x + shuffle(x,_MM_SWIZ_REG_CDAB); }
|
||||
__forceinline vfloat16 vreduce_add8(vfloat16 x) { x = vreduce_add4(x); return x + shuffle4(x,_MM_SHUF_PERM(2,3,0,1)); }
|
||||
__forceinline vfloat16 vreduce_add (vfloat16 x) { x = vreduce_add8(x); return x + shuffle4(x,_MM_SHUF_PERM(1,0,3,2)); }
|
||||
|
||||
__forceinline float reduce_add(const vfloat16& v) { return toScalar(vreduce_add(v)); }
|
||||
__forceinline float reduce_min(const vfloat16& v) { return toScalar(vreduce_min(v)); }
|
||||
__forceinline float reduce_max(const vfloat16& v) { return toScalar(vreduce_max(v)); }
|
||||
|
||||
__forceinline size_t select_min(const vfloat16& v) {
|
||||
return __bsf(_mm512_kmov(_mm512_cmp_epi32_mask(_mm512_castps_si512(v),_mm512_castps_si512(vreduce_min(v)),_MM_CMPINT_EQ)));
|
||||
}
|
||||
@@ -551,66 +571,186 @@ namespace embree
|
||||
|
||||
__forceinline vfloat16 prefix_min(const vfloat16& a)
|
||||
{
|
||||
const vfloat16 z(pos_inf);
|
||||
const vint16 perm0(0,1,2,3,3,3,3,3,8,9,10,11,11,11,11,11);
|
||||
const vint16 perm1(0,1,2,3,4,5,6,7,7,7,7,7,7,7,7,7);
|
||||
vfloat16 v = a;
|
||||
v = min(v,align_shift_right<16-1>(v,z));
|
||||
v = min(v,align_shift_right<16-2>(v,z));
|
||||
v = min(v,align_shift_right<16-4>(v,z));
|
||||
v = min(v,align_shift_right<16-8>(v,z));
|
||||
v = min(v,shuffle<2,2,0,0>(v));
|
||||
v = min(v,shuffle<1,1,1,0>(v));
|
||||
v = min(v,permute(v,perm0));
|
||||
v = min(v,permute(v,perm1));
|
||||
return v;
|
||||
}
|
||||
|
||||
__forceinline vfloat16 prefix_max(const vfloat16& a)
|
||||
{
|
||||
const vfloat16 z(neg_inf);
|
||||
const vint16 perm0(0,1,2,3,3,3,3,3,8,9,10,11,11,11,11,11);
|
||||
const vint16 perm1(0,1,2,3,4,5,6,7,7,7,7,7,7,7,7,7);
|
||||
vfloat16 v = a;
|
||||
v = max(v,align_shift_right<16-1>(v,z));
|
||||
v = max(v,align_shift_right<16-2>(v,z));
|
||||
v = max(v,align_shift_right<16-4>(v,z));
|
||||
v = max(v,align_shift_right<16-8>(v,z));
|
||||
v = max(v,shuffle<2,2,0,0>(v));
|
||||
v = max(v,shuffle<1,1,1,0>(v));
|
||||
v = max(v,permute(v,perm0));
|
||||
v = max(v,permute(v,perm1));
|
||||
return v;
|
||||
}
|
||||
|
||||
|
||||
__forceinline vfloat16 reverse_prefix_min(const vfloat16& a)
|
||||
{
|
||||
const vfloat16 z(pos_inf);
|
||||
const vint16 perm0(4,4,4,4,4,5,6,7,12,12,12,12,12,13,14,15);
|
||||
const vint16 perm1(8,8,8,8,8,8,8,8,8,9,10,11,12,13,14,15);
|
||||
vfloat16 v = a;
|
||||
v = min(v,align_shift_right<1>(z,v));
|
||||
v = min(v,align_shift_right<2>(z,v));
|
||||
v = min(v,align_shift_right<4>(z,v));
|
||||
v = min(v,align_shift_right<8>(z,v));
|
||||
v = min(v,shuffle<3,3,1,1>(v));
|
||||
v = min(v,shuffle<3,2,2,2>(v));
|
||||
v = min(v,permute(v,perm0));
|
||||
v = min(v,permute(v,perm1));
|
||||
return v;
|
||||
}
|
||||
|
||||
__forceinline vfloat16 reverse_prefix_max(const vfloat16& a)
|
||||
{
|
||||
const vfloat16 z(neg_inf);
|
||||
const vint16 perm0(4,4,4,4,4,5,6,7,12,12,12,12,12,13,14,15);
|
||||
const vint16 perm1(8,8,8,8,8,8,8,8,8,9,10,11,12,13,14,15);
|
||||
vfloat16 v = a;
|
||||
v = max(v,align_shift_right<1>(z,v));
|
||||
v = max(v,align_shift_right<2>(z,v));
|
||||
v = max(v,align_shift_right<4>(z,v));
|
||||
v = max(v,align_shift_right<8>(z,v));
|
||||
v = max(v,shuffle<3,3,1,1>(v));
|
||||
v = max(v,shuffle<3,2,2,2>(v));
|
||||
v = max(v,permute(v,perm0));
|
||||
v = max(v,permute(v,perm1));
|
||||
return v;
|
||||
}
|
||||
|
||||
__forceinline vfloat16 set_min4(vfloat16 x) {
|
||||
x = min(x,shuffle(x,_MM_SWIZ_REG_BADC));
|
||||
x = min(x,shuffle(x,_MM_SWIZ_REG_CDAB));
|
||||
return x;
|
||||
}
|
||||
|
||||
__forceinline vfloat16 set_min_lanes(vfloat16 x) {
|
||||
x = min(x,_mm512_permute4f128_ps(x, _MM_PERM_CDAB));
|
||||
x = min(x,_mm512_permute4f128_ps(x, _MM_PERM_BADC));
|
||||
return x;
|
||||
}
|
||||
|
||||
__forceinline vfloat16 set_max_lanes(vfloat16 x) {
|
||||
x = max(x,_mm512_permute4f128_ps(x, _MM_PERM_CDAB));
|
||||
x = max(x,_mm512_permute4f128_ps(x, _MM_PERM_BADC));
|
||||
return x;
|
||||
}
|
||||
|
||||
__forceinline vfloat16 set_min16(vfloat16 x) {
|
||||
return set_min_lanes(set_min4(x));
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// Memory load and store operations
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
__forceinline vfloat16 broadcast4to16f(const void *f) {
|
||||
return _mm512_extload_ps(f,_MM_UPCONV_PS_NONE,_MM_BROADCAST_4X16,0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
__forceinline vfloat16 gather16f_4f(const float *__restrict__ const ptr0,
|
||||
const float *__restrict__ const ptr1,
|
||||
const float *__restrict__ const ptr2,
|
||||
const float *__restrict__ const ptr3)
|
||||
{
|
||||
vfloat16 v = broadcast4to16f(ptr0);
|
||||
v = select((vboolf16)0x00f0,broadcast4to16f(ptr1),v);
|
||||
v = select((vboolf16)0x0f00,broadcast4to16f(ptr2),v);
|
||||
v = select((vboolf16)0xf000,broadcast4to16f(ptr3),v);
|
||||
return v;
|
||||
}
|
||||
|
||||
__forceinline vfloat16 gather16f_4f(const vfloat16& v0,
|
||||
const vfloat16& v1,
|
||||
const vfloat16& v2,
|
||||
const vfloat16& v3)
|
||||
{
|
||||
vfloat16 v = v0;
|
||||
v = select((vboolf16)0xf0 ,v1,v);
|
||||
v = select((vboolf16)0xf00 ,v2,v);
|
||||
v = select((vboolf16)0xf000,v3,v);
|
||||
return v;
|
||||
}
|
||||
|
||||
__forceinline vfloat16 gather_4f_zlc(const vint16 &v_mask,
|
||||
const void *__restrict__ const ptr0,
|
||||
const void *__restrict__ const ptr1,
|
||||
const void *__restrict__ const ptr2,
|
||||
const void *__restrict__ const ptr3)
|
||||
{
|
||||
const vboolf16 m_00f0 = 0x00f0;
|
||||
const vboolf16 m_0f00 = 0x0f00;
|
||||
const vboolf16 m_f000 = 0xf000;
|
||||
|
||||
vint16 v = v_mask & broadcast4to16i((const int*)ptr0);
|
||||
v = mask_and(m_00f0,v,v_mask, broadcast4to16i((const int*)ptr1));
|
||||
v = mask_and(m_0f00,v,v_mask, broadcast4to16i((const int*)ptr2));
|
||||
v = mask_and(m_f000,v,v_mask, broadcast4to16i((const int*)ptr3));
|
||||
return asFloat(v);
|
||||
}
|
||||
|
||||
__forceinline vfloat16 gather_2f_zlc(const vint16 &v_mask,
|
||||
const vboolf16 &mask,
|
||||
const void *__restrict__ const ptr0,
|
||||
const void *__restrict__ const ptr1)
|
||||
{
|
||||
vint16 v = v_mask & broadcast4to16i((const int*)ptr0);
|
||||
v = mask_and(mask,v,v_mask, broadcast4to16i((const int*)ptr1));
|
||||
return asFloat(v);
|
||||
}
|
||||
|
||||
|
||||
__forceinline vfloat16 gather16f_4f_align(const void *__restrict__ const ptr0,
|
||||
const void *__restrict__ const ptr1,
|
||||
const void *__restrict__ const ptr2,
|
||||
const void *__restrict__ const ptr3)
|
||||
{
|
||||
vfloat16 v = broadcast4to16f(ptr3);
|
||||
v = align_shift_right<12>(v,broadcast4to16f(ptr2));
|
||||
v = align_shift_right<12>(v,broadcast4to16f(ptr1));
|
||||
v = align_shift_right<12>(v,broadcast4to16f(ptr0));
|
||||
return v;
|
||||
}
|
||||
|
||||
|
||||
__forceinline vfloat16 gather16f_4f_align(const vfloat16& v0,
|
||||
const vfloat16& v1,
|
||||
const vfloat16& v2,
|
||||
const vfloat16& v3)
|
||||
{
|
||||
vfloat16 v = v3;
|
||||
v = align_shift_right<12>(v,v2);
|
||||
v = align_shift_right<12>(v,v1);
|
||||
v = align_shift_right<12>(v,v0);
|
||||
return v;
|
||||
}
|
||||
|
||||
__forceinline vfloat16 gather_4f_zlc_align(const vint16 &v_mask,
|
||||
const void *__restrict__ const ptr0,
|
||||
const void *__restrict__ const ptr1,
|
||||
const void *__restrict__ const ptr2,
|
||||
const void *__restrict__ const ptr3)
|
||||
{
|
||||
vfloat16 v = gather16f_4f_align(ptr0,ptr1,ptr2,ptr3);
|
||||
return asFloat(asInt(v) & v_mask);
|
||||
}
|
||||
|
||||
__forceinline void compactustore16f_low(const vboolf16& mask, float * addr, const vfloat16 ®) {
|
||||
_mm512_mask_compressstoreu_ps(addr,mask,reg);
|
||||
}
|
||||
|
||||
template<int scale = 4>
|
||||
__forceinline vfloat16 gather16f(const vboolf16& mask, const float *const ptr, __m512i index) {
|
||||
__forceinline vfloat16 gather16f(const vboolf16& mask, const float *const ptr, __m512i index, const int scale= 4 ) {
|
||||
vfloat16 r = vfloat16::undefined();
|
||||
return _mm512_mask_i32gather_ps(r,mask,index,ptr,scale);
|
||||
}
|
||||
|
||||
template<int scale = 4>
|
||||
__forceinline void scatter16f(const vboolf16& mask,const float *const ptr, const __m512i index,const vfloat16 v) {
|
||||
_mm512_mask_i32scatter_ps(ptr,mask,index,v,scale);
|
||||
__forceinline void scatter16f(const vboolf16& mask,const float *const ptr, const __m512i index,const vfloat16 v, const int scale = 4) {
|
||||
_mm512_mask_i32scatter_ps((void*)ptr,mask,index,v,scale);
|
||||
}
|
||||
|
||||
__forceinline vfloat16 loadAOS4to16f(const float& x,const float& y, const float& z)
|
||||
@@ -647,10 +787,100 @@ namespace embree
|
||||
return f;
|
||||
}
|
||||
|
||||
__forceinline vfloat16 gather16f_4f_unalign(const void *__restrict__ const ptr0,
|
||||
const void *__restrict__ const ptr1,
|
||||
const void *__restrict__ const ptr2,
|
||||
const void *__restrict__ const ptr3)
|
||||
{
|
||||
vfloat16 v = shuffle4<0>(vfloat16::loadu((float*)ptr3));
|
||||
v = align_shift_right<12>(v,shuffle4<0>(vfloat16::loadu((float*)ptr2)));
|
||||
v = align_shift_right<12>(v,shuffle4<0>(vfloat16::loadu((float*)ptr1)));
|
||||
v = align_shift_right<12>(v,shuffle4<0>(vfloat16::loadu((float*)ptr0)));
|
||||
return v;
|
||||
}
|
||||
|
||||
|
||||
__forceinline vfloat16 rcp_safe( const vfloat16& a ) {
|
||||
return rcp(select(a != vfloat16::zero(),a,vfloat16(min_rcp_input)));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// Euclidian Space Operators
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
__forceinline vfloat16 lcross_zxy(const vfloat16 &ao, const vfloat16 &bo) {
|
||||
vfloat16 ao_bo = bo * shuffle(ao,_MM_SWIZ_REG_DACB);
|
||||
ao_bo = msub231(ao_bo,ao,shuffle(bo,_MM_SWIZ_REG_DACB));
|
||||
return ao_bo;
|
||||
}
|
||||
|
||||
__forceinline vfloat16 ldot16_zxy(const vfloat16 &a,const vfloat16 &v0, const vfloat16 &v1, const vfloat16 &v2)
|
||||
{
|
||||
vfloat16 v = v0 * shuffle(a,_MM_SWIZ_REG_BBBB);
|
||||
v = madd231(v,v1,shuffle(a,_MM_SWIZ_REG_CCCC));
|
||||
v = madd231(v,v2,shuffle(a,_MM_SWIZ_REG_AAAA));
|
||||
return v;
|
||||
}
|
||||
|
||||
__forceinline vfloat16 ldot16_xyz(const vfloat16 &a,const vfloat16 &v0, const vfloat16 &v1, const vfloat16 &v2)
|
||||
{
|
||||
vfloat16 v = v0 * shuffle(a,_MM_SWIZ_REG_AAAA);
|
||||
v = madd231(v, v1,shuffle(a,_MM_SWIZ_REG_BBBB));
|
||||
v = madd231(v, v2,shuffle(a,_MM_SWIZ_REG_CCCC));
|
||||
return v;
|
||||
}
|
||||
|
||||
__forceinline vfloat16 lcross_xyz(const vfloat16 &a, const vfloat16 &b)
|
||||
{
|
||||
vfloat16 c = b * shuffle(a,_MM_SWIZ_REG_DACB);
|
||||
c = msub231(c,a,shuffle(b,_MM_SWIZ_REG_DACB));
|
||||
c = shuffle(c,_MM_SWIZ_REG_DACB);
|
||||
return c;
|
||||
}
|
||||
|
||||
__forceinline vfloat16 ldot3_xyz(const vfloat16 &ao, const vfloat16 &normal)
|
||||
{
|
||||
vfloat16 vv = ao * normal;
|
||||
vv = _mm512_add_ps(vv,shuffle(vv,_MM_SWIZ_REG_CDAB));
|
||||
vv = _mm512_add_ps(vv,shuffle(vv,_MM_SWIZ_REG_BADC));
|
||||
return vv;
|
||||
}
|
||||
|
||||
__forceinline vfloat16 lsum3_xyz(const vfloat16 &v)
|
||||
{
|
||||
vfloat16 vv = v;
|
||||
vv = _mm512_add_ps(vv,shuffle(vv,_MM_SWIZ_REG_CDAB));
|
||||
vv = _mm512_add_ps(vv,shuffle(vv,_MM_SWIZ_REG_BADC));
|
||||
return vv;
|
||||
}
|
||||
|
||||
__forceinline vfloat16 ldot3_xyz(const vboolf16 &m_mask, const vfloat16 &ao, const vfloat16 &normal)
|
||||
{
|
||||
vfloat16 vv = _mm512_mask_mul_ps(ao,m_mask,ao,normal);
|
||||
vv = _mm512_add_ps(vv,shuffle(vv,_MM_SWIZ_REG_CDAB));
|
||||
vv = _mm512_add_ps(vv,shuffle(vv,_MM_SWIZ_REG_BADC));
|
||||
return vv;
|
||||
}
|
||||
|
||||
__forceinline vfloat16 ldot3_zxy(const vfloat16 &ao, const vfloat16 &normal)
|
||||
{
|
||||
vfloat16 vv = ao * shuffle(normal,_MM_SWIZ_REG_DACB);
|
||||
vv = _mm512_add_ps(vv,shuffle(vv,_MM_SWIZ_REG_CDAB));
|
||||
vv = _mm512_add_ps(vv,shuffle(vv,_MM_SWIZ_REG_BADC));
|
||||
return vv;
|
||||
}
|
||||
|
||||
|
||||
static __forceinline vfloat4 extractf128bit(const vfloat16& v)
|
||||
{
|
||||
return _mm512_castps512_ps128(v);
|
||||
}
|
||||
|
||||
static __forceinline vfloat8 extractf256bit(const vfloat16& v)
|
||||
{
|
||||
return _mm512_castps512_ps256(v);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// Output Operators
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
+41
-95
@@ -1,5 +1,5 @@
|
||||
// ======================================================================== //
|
||||
// Copyright 2009-2017 Intel Corporation //
|
||||
// Copyright 2009-2016 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
@@ -125,11 +125,10 @@ namespace embree
|
||||
#endif
|
||||
}
|
||||
|
||||
template<int scale>
|
||||
static __forceinline void scatter(const vboolf4& mask, void* ptr, const vint4& ofs, const vfloat4& v)
|
||||
static __forceinline void store(const vboolf4& mask, void* ptr, const vint4& ofs, const vfloat4& v, const int scale = 1)
|
||||
{
|
||||
#if defined(__AVX512VL__)
|
||||
_mm_mask_i32scatter_ps((float*)ptr,mask,ofs,v,scale);
|
||||
_mm_mask_i32scatter_ps(ptr,mask,ofs,v,scale);
|
||||
#else
|
||||
if (likely(mask[0])) *(float*)(((char*)ptr)+scale*ofs[0]) = v[0];
|
||||
if (likely(mask[1])) *(float*)(((char*)ptr)+scale*ofs[1]) = v[1];
|
||||
@@ -139,10 +138,10 @@ namespace embree
|
||||
}
|
||||
|
||||
static __forceinline void store(const vboolf4& mask, char* ptr, const vint4& ofs, const vfloat4& v) {
|
||||
scatter<1>(mask,ptr,ofs,v);
|
||||
store(mask,ptr,ofs,v,1);
|
||||
}
|
||||
static __forceinline void store(const vboolf4& mask, float* ptr, const vint4& ofs, const vfloat4& v) {
|
||||
scatter<4>(mask,ptr,ofs,v);
|
||||
store(mask,ptr,ofs,v,4);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -179,14 +178,8 @@ namespace embree
|
||||
#endif
|
||||
__forceinline const vfloat4 signmsk ( const vfloat4& a ) { return _mm_and_ps(a.v,_mm_castsi128_ps(_mm_set1_epi32(0x80000000))); }
|
||||
|
||||
__forceinline const vfloat4 rcp ( const vfloat4& a )
|
||||
{
|
||||
#if defined(__AVX512VL__)
|
||||
const vfloat4 r = _mm_rcp14_ps(a.v);
|
||||
#else
|
||||
__forceinline const vfloat4 rcp ( const vfloat4& a ) {
|
||||
const vfloat4 r = _mm_rcp_ps(a.v);
|
||||
#endif
|
||||
|
||||
#if defined(__AVX2__)
|
||||
return _mm_mul_ps(r,_mm_fnmadd_ps(r, a, vfloat4(2.0f)));
|
||||
#else
|
||||
@@ -195,24 +188,11 @@ namespace embree
|
||||
}
|
||||
__forceinline const vfloat4 sqr ( const vfloat4& a ) { return _mm_mul_ps(a,a); }
|
||||
__forceinline const vfloat4 sqrt ( const vfloat4& a ) { return _mm_sqrt_ps(a.v); }
|
||||
|
||||
__forceinline const vfloat4 rsqrt( const vfloat4& a )
|
||||
{
|
||||
#if defined(__AVX512VL__)
|
||||
const vfloat4 r = _mm_rsqrt14_ps(a.v);
|
||||
#else
|
||||
__forceinline const vfloat4 rsqrt( const vfloat4& a ) {
|
||||
const vfloat4 r = _mm_rsqrt_ps(a.v);
|
||||
#endif
|
||||
|
||||
#if defined(__AVX2__)
|
||||
return _mm_fmadd_ps(_mm_set1_ps(1.5f), r,
|
||||
_mm_mul_ps(_mm_mul_ps(_mm_mul_ps(a, _mm_set1_ps(-0.5f)), r), _mm_mul_ps(r, r)));
|
||||
#else
|
||||
return _mm_add_ps(_mm_mul_ps(_mm_set1_ps(1.5f), r),
|
||||
_mm_mul_ps(_mm_mul_ps(_mm_mul_ps(a, _mm_set1_ps(-0.5f)), r), _mm_mul_ps(r, r)));
|
||||
#endif
|
||||
return _mm_add_ps(_mm_mul_ps(_mm_set_ps(1.5f, 1.5f, 1.5f, 1.5f), r),
|
||||
_mm_mul_ps(_mm_mul_ps(_mm_mul_ps(a, _mm_set_ps(-0.5f, -0.5f, -0.5f, -0.5f)), r), _mm_mul_ps(r, r)));
|
||||
}
|
||||
|
||||
__forceinline const vboolf4 isnan( const vfloat4& a ) {
|
||||
const vfloat4 b = _mm_and_ps(a.v, _mm_castsi128_ps(_mm_set1_epi32(0x7fffffff)));
|
||||
#if defined(__AVX512VL__)
|
||||
@@ -326,19 +306,19 @@ namespace embree
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if defined(__AVX512VL__)
|
||||
__forceinline const vboolf4 operator ==( const vfloat4& a, const vfloat4& b ) { return _mm_cmp_ps_mask(a, b, _MM_CMPINT_EQ); }
|
||||
__forceinline const vboolf4 operator !=( const vfloat4& a, const vfloat4& b ) { return _mm_cmp_ps_mask(a, b, _MM_CMPINT_NE); }
|
||||
__forceinline const vboolf4 operator < ( const vfloat4& a, const vfloat4& b ) { return _mm_cmp_ps_mask(a, b, _MM_CMPINT_LT); }
|
||||
__forceinline const vboolf4 operator >=( const vfloat4& a, const vfloat4& b ) { return _mm_cmp_ps_mask(a, b, _MM_CMPINT_GE); }
|
||||
__forceinline const vboolf4 operator > ( const vfloat4& a, const vfloat4& b ) { return _mm_cmp_ps_mask(a, b, _MM_CMPINT_GT); }
|
||||
__forceinline const vboolf4 operator <=( const vfloat4& a, const vfloat4& b ) { return _mm_cmp_ps_mask(a, b, _MM_CMPINT_LE); }
|
||||
__forceinline const vboolf4 operator ==( const vfloat4& a, const vfloat4& b ) { return _mm_cmp_ps_mask(a.v, b.v, _CMP_EQ_OQ ); }
|
||||
__forceinline const vboolf4 operator !=( const vfloat4& a, const vfloat4& b ) { return _mm_cmp_ps_mask(a.v, b.v, _CMP_NEQ_OQ); }
|
||||
__forceinline const vboolf4 operator < ( const vfloat4& a, const vfloat4& b ) { return _mm_cmp_ps_mask(a.v, b.v, _CMP_LT_OQ ); }
|
||||
__forceinline const vboolf4 operator >=( const vfloat4& a, const vfloat4& b ) { return _mm_cmp_ps_mask(a.v, b.v, _CMP_GE_OQ ); }
|
||||
__forceinline const vboolf4 operator > ( const vfloat4& a, const vfloat4& b ) { return _mm_cmp_ps_mask(a.v, b.v, _CMP_GT_OQ ); }
|
||||
__forceinline const vboolf4 operator <=( const vfloat4& a, const vfloat4& b ) { return _mm_cmp_ps_mask(a.v, b.v, _CMP_LE_OQ ); }
|
||||
#else
|
||||
__forceinline const vboolf4 operator ==( const vfloat4& a, const vfloat4& b ) { return _mm_cmpeq_ps (a, b); }
|
||||
__forceinline const vboolf4 operator !=( const vfloat4& a, const vfloat4& b ) { return _mm_cmpneq_ps(a, b); }
|
||||
__forceinline const vboolf4 operator < ( const vfloat4& a, const vfloat4& b ) { return _mm_cmplt_ps (a, b); }
|
||||
__forceinline const vboolf4 operator >=( const vfloat4& a, const vfloat4& b ) { return _mm_cmpnlt_ps(a, b); }
|
||||
__forceinline const vboolf4 operator > ( const vfloat4& a, const vfloat4& b ) { return _mm_cmpnle_ps(a, b); }
|
||||
__forceinline const vboolf4 operator <=( const vfloat4& a, const vfloat4& b ) { return _mm_cmple_ps (a, b); }
|
||||
__forceinline const vboolf4 operator ==( const vfloat4& a, const vfloat4& b ) { return _mm_cmpeq_ps (a.v, b.v); }
|
||||
__forceinline const vboolf4 operator !=( const vfloat4& a, const vfloat4& b ) { return _mm_cmpneq_ps(a.v, b.v); }
|
||||
__forceinline const vboolf4 operator < ( const vfloat4& a, const vfloat4& b ) { return _mm_cmplt_ps (a.v, b.v); }
|
||||
__forceinline const vboolf4 operator >=( const vfloat4& a, const vfloat4& b ) { return _mm_cmpnlt_ps(a.v, b.v); }
|
||||
__forceinline const vboolf4 operator > ( const vfloat4& a, const vfloat4& b ) { return _mm_cmpnle_ps(a.v, b.v); }
|
||||
__forceinline const vboolf4 operator <=( const vfloat4& a, const vfloat4& b ) { return _mm_cmple_ps (a.v, b.v); }
|
||||
#endif
|
||||
|
||||
__forceinline const vboolf4 operator ==( const vfloat4& a, const float& b ) { return a == vfloat4(b); }
|
||||
@@ -359,41 +339,25 @@ namespace embree
|
||||
__forceinline const vboolf4 operator <=( const vfloat4& a, const float& b ) { return a <= vfloat4(b); }
|
||||
__forceinline const vboolf4 operator <=( const float& a, const vfloat4& b ) { return vfloat4(a) <= b; }
|
||||
|
||||
__forceinline vboolf4 eq(const vfloat4& a, const vfloat4& b) { return a == b; }
|
||||
__forceinline vboolf4 ne(const vfloat4& a, const vfloat4& b) { return a != b; }
|
||||
__forceinline vboolf4 lt(const vfloat4& a, const vfloat4& b) { return a < b; }
|
||||
__forceinline vboolf4 ge(const vfloat4& a, const vfloat4& b) { return a >= b; }
|
||||
__forceinline vboolf4 gt(const vfloat4& a, const vfloat4& b) { return a > b; }
|
||||
__forceinline vboolf4 le(const vfloat4& a, const vfloat4& b) { return a <= b; }
|
||||
|
||||
#if defined(__AVX512VL__)
|
||||
__forceinline vboolf4 eq(const vboolf4& mask, const vfloat4& a, const vfloat4& b) { return _mm_mask_cmp_ps_mask(mask, a, b, _MM_CMPINT_EQ); }
|
||||
__forceinline vboolf4 ne(const vboolf4& mask, const vfloat4& a, const vfloat4& b) { return _mm_mask_cmp_ps_mask(mask, a, b, _MM_CMPINT_NE); }
|
||||
__forceinline vboolf4 lt(const vboolf4& mask, const vfloat4& a, const vfloat4& b) { return _mm_mask_cmp_ps_mask(mask, a, b, _MM_CMPINT_LT); }
|
||||
__forceinline vboolf4 ge(const vboolf4& mask, const vfloat4& a, const vfloat4& b) { return _mm_mask_cmp_ps_mask(mask, a, b, _MM_CMPINT_GE); }
|
||||
__forceinline vboolf4 gt(const vboolf4& mask, const vfloat4& a, const vfloat4& b) { return _mm_mask_cmp_ps_mask(mask, a, b, _MM_CMPINT_GT); }
|
||||
__forceinline vboolf4 le(const vboolf4& mask, const vfloat4& a, const vfloat4& b) { return _mm_mask_cmp_ps_mask(mask, a, b, _MM_CMPINT_LE); }
|
||||
#else
|
||||
__forceinline vboolf4 eq(const vboolf4& mask, const vfloat4& a, const vfloat4& b) { return mask & (a == b); }
|
||||
__forceinline vboolf4 ne(const vboolf4& mask, const vfloat4& a, const vfloat4& b) { return mask & (a != b); }
|
||||
__forceinline vboolf4 lt(const vboolf4& mask, const vfloat4& a, const vfloat4& b) { return mask & (a < b); }
|
||||
__forceinline vboolf4 ge(const vboolf4& mask, const vfloat4& a, const vfloat4& b) { return mask & (a >= b); }
|
||||
__forceinline vboolf4 gt(const vboolf4& mask, const vfloat4& a, const vfloat4& b) { return mask & (a > b); }
|
||||
__forceinline vboolf4 le(const vboolf4& mask, const vfloat4& a, const vfloat4& b) { return mask & (a <= b); }
|
||||
#endif
|
||||
|
||||
template<int mask>
|
||||
__forceinline const vfloat4 select(const vfloat4& t, const vfloat4& f)
|
||||
{
|
||||
#if defined(__SSE4_1__)
|
||||
return _mm_blend_ps(f, t, mask);
|
||||
#else
|
||||
#if defined(__clang__) && !defined(__INTEL_COMPILER) || defined(_MSC_VER) && !defined(__INTEL_COMPILER) || defined(__INTEL_COMPILER) && defined(_DEBUG)
|
||||
__forceinline const vfloat4 select(const int mask, const vfloat4& t, const vfloat4& f) {
|
||||
return select(vboolf4(mask), t, f);
|
||||
#endif
|
||||
}
|
||||
|
||||
#else
|
||||
__forceinline const vfloat4 select(const int mask, const vfloat4& t, const vfloat4& f) {
|
||||
return _mm_blend_ps(f, t, mask);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
__forceinline vfloat4 lerp(const vfloat4& a, const vfloat4& b, const vfloat4& t) {
|
||||
return madd(t,b-a,a);
|
||||
#if defined(__AVX2__)
|
||||
return madd(t, b, madd(-t, a, a));
|
||||
#else
|
||||
return a + t*(b-a);
|
||||
#endif
|
||||
}
|
||||
|
||||
__forceinline bool isvalid ( const vfloat4& v ) {
|
||||
@@ -424,7 +388,7 @@ namespace embree
|
||||
__forceinline const vfloat4 frac ( const vfloat4& a ) { return a-floor(a); }
|
||||
|
||||
__forceinline vint4 floori (const vfloat4& a) {
|
||||
#if defined(__SSE4_1__)
|
||||
#if defined (__SSE4_1__)
|
||||
return vint4(floor(a));
|
||||
#else
|
||||
return vint4(a-vfloat4(0.5f));
|
||||
@@ -501,39 +465,21 @@ namespace embree
|
||||
/// Sorting Network
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
__forceinline vfloat4 sort_ascending(const vfloat4& v)
|
||||
__forceinline vfloat4 sortNetwork(const vfloat4& v)
|
||||
{
|
||||
const vfloat4 a0 = v;
|
||||
const vfloat4 b0 = shuffle<1,0,3,2>(a0);
|
||||
const vfloat4 c0 = min(a0,b0);
|
||||
const vfloat4 d0 = max(a0,b0);
|
||||
const vfloat4 a1 = select<0x5 /* 0b0101 */>(c0,d0);
|
||||
const vfloat4 a1 = select(0x5 /* 0b0101 */,c0,d0);
|
||||
const vfloat4 b1 = shuffle<2,3,0,1>(a1);
|
||||
const vfloat4 c1 = min(a1,b1);
|
||||
const vfloat4 d1 = max(a1,b1);
|
||||
const vfloat4 a2 = select<0x3 /* 0b0011 */>(c1,d1);
|
||||
const vfloat4 a2 = select(0x3 /* 0b0011 */,c1,d1);
|
||||
const vfloat4 b2 = shuffle<0,2,1,3>(a2);
|
||||
const vfloat4 c2 = min(a2,b2);
|
||||
const vfloat4 d2 = max(a2,b2);
|
||||
const vfloat4 a3 = select<0x2 /* 0b0010 */>(c2,d2);
|
||||
return a3;
|
||||
}
|
||||
|
||||
__forceinline vfloat4 sort_descending(const vfloat4& v)
|
||||
{
|
||||
const vfloat4 a0 = v;
|
||||
const vfloat4 b0 = shuffle<1,0,3,2>(a0);
|
||||
const vfloat4 c0 = max(a0,b0);
|
||||
const vfloat4 d0 = min(a0,b0);
|
||||
const vfloat4 a1 = select<0x5 /* 0b0101 */>(c0,d0);
|
||||
const vfloat4 b1 = shuffle<2,3,0,1>(a1);
|
||||
const vfloat4 c1 = max(a1,b1);
|
||||
const vfloat4 d1 = min(a1,b1);
|
||||
const vfloat4 a2 = select<0x3 /* 0b0011 */>(c1,d1);
|
||||
const vfloat4 b2 = shuffle<0,2,1,3>(a2);
|
||||
const vfloat4 c2 = max(a2,b2);
|
||||
const vfloat4 d2 = min(a2,b2);
|
||||
const vfloat4 a3 = select<0x2 /* 0b0010 */>(c2,d2);
|
||||
const vfloat4 a3 = select(0x2 /* 0b0010 */,c2,d2);
|
||||
return a3;
|
||||
}
|
||||
|
||||
|
||||
+49
-118
@@ -1,5 +1,5 @@
|
||||
// ======================================================================== //
|
||||
// Copyright 2009-2017 Intel Corporation //
|
||||
// Copyright 2009-2016 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
@@ -123,11 +123,10 @@ namespace embree
|
||||
_mm256_stream_ps((float*)ptr,v);
|
||||
}
|
||||
|
||||
template<int scale>
|
||||
static __forceinline void scatter(const vboolf8& mask, void* ptr, const vint8& ofs, const vfloat8& v)
|
||||
static __forceinline void store(const vboolf8& mask, void* ptr, const vint8& ofs, const vfloat8& v, const int scale = 1)
|
||||
{
|
||||
#if defined(__AVX512VL__)
|
||||
_mm256_mask_i32scatter_ps((float*)ptr,mask,ofs,v,scale);
|
||||
_mm256_mask_i32scatter_ps(ptr,mask,ofs,v,scale);
|
||||
#else
|
||||
if (likely(mask[0])) *(float*)(((char*)ptr)+scale*ofs[0]) = v[0];
|
||||
if (likely(mask[1])) *(float*)(((char*)ptr)+scale*ofs[1]) = v[1];
|
||||
@@ -141,10 +140,10 @@ namespace embree
|
||||
}
|
||||
|
||||
static __forceinline void store(const vboolf8& mask, char* ptr, const vint8& ofs, const vfloat8& v) {
|
||||
scatter<1>(mask,ptr,ofs,v);
|
||||
store(mask,ptr,ofs,v,1);
|
||||
}
|
||||
static __forceinline void store(const vboolf8& mask, float* ptr, const vint8& ofs, const vfloat8& v) {
|
||||
scatter<4>(mask,ptr,ofs,v);
|
||||
store(mask,ptr,ofs,v,4);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -175,14 +174,8 @@ namespace embree
|
||||
__forceinline const vfloat8 signmsk ( const vfloat8& a ) { return _mm256_and_ps(a.v,_mm256_castsi256_ps(_mm256_set1_epi32(0x80000000))); }
|
||||
|
||||
|
||||
__forceinline const vfloat8 rcp(const vfloat8& a)
|
||||
{
|
||||
#if defined(__AVX512VL__)
|
||||
const vfloat8 r = _mm256_rcp14_ps(a.v);
|
||||
#else
|
||||
const vfloat8 r = _mm256_rcp_ps(a.v);
|
||||
#endif
|
||||
|
||||
__forceinline const vfloat8 rcp ( const vfloat8& a ) {
|
||||
const vfloat8 r = _mm256_rcp_ps(a.v);
|
||||
#if defined(__AVX2__)
|
||||
return _mm256_mul_ps(r,_mm256_fnmadd_ps(r, a, vfloat8(2.0f)));
|
||||
#else
|
||||
@@ -191,22 +184,9 @@ namespace embree
|
||||
}
|
||||
__forceinline const vfloat8 sqr ( const vfloat8& a ) { return _mm256_mul_ps(a,a); }
|
||||
__forceinline const vfloat8 sqrt ( const vfloat8& a ) { return _mm256_sqrt_ps(a.v); }
|
||||
|
||||
__forceinline const vfloat8 rsqrt( const vfloat8& a )
|
||||
{
|
||||
#if defined(__AVX512VL__)
|
||||
const vfloat8 r = _mm256_rsqrt14_ps(a.v);
|
||||
#else
|
||||
__forceinline const vfloat8 rsqrt( const vfloat8& a ) {
|
||||
const vfloat8 r = _mm256_rsqrt_ps(a.v);
|
||||
#endif
|
||||
|
||||
#if defined(__AVX2__)
|
||||
return _mm256_fmadd_ps(_mm256_set1_ps(1.5f), r,
|
||||
_mm256_mul_ps(_mm256_mul_ps(_mm256_mul_ps(a, _mm256_set1_ps(-0.5f)), r), _mm256_mul_ps(r, r)));
|
||||
#else
|
||||
return _mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(1.5f), r),
|
||||
_mm256_mul_ps(_mm256_mul_ps(_mm256_mul_ps(a, _mm256_set1_ps(-0.5f)), r), _mm256_mul_ps(r, r)));
|
||||
#endif
|
||||
return _mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(1.5f), r), _mm256_mul_ps(_mm256_mul_ps(_mm256_mul_ps(a, _mm256_set1_ps(-0.5f)), r), _mm256_mul_ps(r, r)));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -316,33 +296,38 @@ namespace embree
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if defined(__AVX512VL__)
|
||||
__forceinline const vboolf8 operator ==( const vfloat8& a, const vfloat8& b ) { return _mm256_cmp_ps_mask(a, b, _MM_CMPINT_EQ); }
|
||||
__forceinline const vboolf8 operator !=( const vfloat8& a, const vfloat8& b ) { return _mm256_cmp_ps_mask(a, b, _MM_CMPINT_NE); }
|
||||
__forceinline const vboolf8 operator < ( const vfloat8& a, const vfloat8& b ) { return _mm256_cmp_ps_mask(a, b, _MM_CMPINT_LT); }
|
||||
__forceinline const vboolf8 operator >=( const vfloat8& a, const vfloat8& b ) { return _mm256_cmp_ps_mask(a, b, _MM_CMPINT_GE); }
|
||||
__forceinline const vboolf8 operator > ( const vfloat8& a, const vfloat8& b ) { return _mm256_cmp_ps_mask(a, b, _MM_CMPINT_GT); }
|
||||
__forceinline const vboolf8 operator <=( const vfloat8& a, const vfloat8& b ) { return _mm256_cmp_ps_mask(a, b, _MM_CMPINT_LE); }
|
||||
__forceinline const vboolf8 operator ==( const vfloat8& a, const vfloat8& b ) { return _mm256_cmp_ps_mask(a.v, b.v, _CMP_EQ_OQ ); }
|
||||
__forceinline const vboolf8 operator !=( const vfloat8& a, const vfloat8& b ) { return _mm256_cmp_ps_mask(a.v, b.v, _CMP_NEQ_OQ); }
|
||||
__forceinline const vboolf8 operator < ( const vfloat8& a, const vfloat8& b ) { return _mm256_cmp_ps_mask(a.v, b.v, _CMP_LT_OQ ); }
|
||||
__forceinline const vboolf8 operator >=( const vfloat8& a, const vfloat8& b ) { return _mm256_cmp_ps_mask(a.v, b.v, _CMP_GE_OQ ); }
|
||||
__forceinline const vboolf8 operator > ( const vfloat8& a, const vfloat8& b ) { return _mm256_cmp_ps_mask(a.v, b.v, _CMP_GT_OQ ); }
|
||||
__forceinline const vboolf8 operator <=( const vfloat8& a, const vfloat8& b ) { return _mm256_cmp_ps_mask(a.v, b.v, _CMP_LE_OQ ); }
|
||||
|
||||
__forceinline const vfloat8 select( const vboolf8& m, const vfloat8& t, const vfloat8& f ) {
|
||||
return _mm256_mask_blend_ps(m, f, t);
|
||||
}
|
||||
#else
|
||||
__forceinline const vboolf8 operator ==( const vfloat8& a, const vfloat8& b ) { return _mm256_cmp_ps(a, b, _CMP_EQ_OQ ); }
|
||||
__forceinline const vboolf8 operator !=( const vfloat8& a, const vfloat8& b ) { return _mm256_cmp_ps(a, b, _CMP_NEQ_OQ); }
|
||||
__forceinline const vboolf8 operator < ( const vfloat8& a, const vfloat8& b ) { return _mm256_cmp_ps(a, b, _CMP_LT_OQ ); }
|
||||
__forceinline const vboolf8 operator >=( const vfloat8& a, const vfloat8& b ) { return _mm256_cmp_ps(a, b, _CMP_GE_OQ ); }
|
||||
__forceinline const vboolf8 operator > ( const vfloat8& a, const vfloat8& b ) { return _mm256_cmp_ps(a, b, _CMP_GT_OQ ); }
|
||||
__forceinline const vboolf8 operator <=( const vfloat8& a, const vfloat8& b ) { return _mm256_cmp_ps(a, b, _CMP_LE_OQ ); }
|
||||
__forceinline const vboolf8 operator ==( const vfloat8& a, const vfloat8& b ) { return _mm256_cmp_ps(a.v, b.v, _CMP_EQ_OQ ); }
|
||||
__forceinline const vboolf8 operator !=( const vfloat8& a, const vfloat8& b ) { return _mm256_cmp_ps(a.v, b.v, _CMP_NEQ_OQ); }
|
||||
__forceinline const vboolf8 operator < ( const vfloat8& a, const vfloat8& b ) { return _mm256_cmp_ps(a.v, b.v, _CMP_LT_OQ ); }
|
||||
__forceinline const vboolf8 operator >=( const vfloat8& a, const vfloat8& b ) { return _mm256_cmp_ps(a.v, b.v, _CMP_GE_OQ ); }
|
||||
__forceinline const vboolf8 operator > ( const vfloat8& a, const vfloat8& b ) { return _mm256_cmp_ps(a.v, b.v, _CMP_GT_OQ ); }
|
||||
__forceinline const vboolf8 operator <=( const vfloat8& a, const vfloat8& b ) { return _mm256_cmp_ps(a.v, b.v, _CMP_LE_OQ ); }
|
||||
|
||||
__forceinline const vfloat8 select( const vboolf8& m, const vfloat8& t, const vfloat8& f ) {
|
||||
return _mm256_blendv_ps(f, t, m);
|
||||
}
|
||||
#endif
|
||||
|
||||
template<int mask>
|
||||
__forceinline const vfloat8 select( const vfloat8& t, const vfloat8& f ) {
|
||||
return _mm256_blend_ps(f, t, mask);
|
||||
#if defined(__clang__) && !defined(__INTEL_COMPILER) || defined(_MSC_VER) && !defined(__INTEL_COMPILER)
|
||||
__forceinline const vfloat8 select(const int m, const vfloat8& t, const vfloat8& f) {
|
||||
return select(vboolf8(m), t, f); // workaround for clang and Microsoft compiler bugs
|
||||
}
|
||||
#else
|
||||
__forceinline const vfloat8 select( const int m, const vfloat8& t, const vfloat8& f ) {
|
||||
return _mm256_blend_ps(f, t, m);
|
||||
}
|
||||
#endif
|
||||
|
||||
__forceinline const vboolf8 operator ==( const vfloat8& a, const float& b ) { return a == vfloat8(b); }
|
||||
__forceinline const vboolf8 operator ==( const float& a, const vfloat8& b ) { return vfloat8(a) == b; }
|
||||
@@ -362,31 +347,13 @@ namespace embree
|
||||
__forceinline const vboolf8 operator <=( const vfloat8& a, const float& b ) { return a <= vfloat8(b); }
|
||||
__forceinline const vboolf8 operator <=( const float& a, const vfloat8& b ) { return vfloat8(a) <= b; }
|
||||
|
||||
__forceinline vboolf8 eq(const vfloat8& a, const vfloat8& b) { return a == b; }
|
||||
__forceinline vboolf8 ne(const vfloat8& a, const vfloat8& b) { return a != b; }
|
||||
__forceinline vboolf8 lt(const vfloat8& a, const vfloat8& b) { return a < b; }
|
||||
__forceinline vboolf8 ge(const vfloat8& a, const vfloat8& b) { return a >= b; }
|
||||
__forceinline vboolf8 gt(const vfloat8& a, const vfloat8& b) { return a > b; }
|
||||
__forceinline vboolf8 le(const vfloat8& a, const vfloat8& b) { return a <= b; }
|
||||
|
||||
#if defined(__AVX512VL__)
|
||||
__forceinline vboolf8 eq(const vboolf8& mask, const vfloat8& a, const vfloat8& b) { return _mm256_mask_cmp_ps_mask(mask, a, b, _MM_CMPINT_EQ); }
|
||||
__forceinline vboolf8 ne(const vboolf8& mask, const vfloat8& a, const vfloat8& b) { return _mm256_mask_cmp_ps_mask(mask, a, b, _MM_CMPINT_NE); }
|
||||
__forceinline vboolf8 lt(const vboolf8& mask, const vfloat8& a, const vfloat8& b) { return _mm256_mask_cmp_ps_mask(mask, a, b, _MM_CMPINT_LT); }
|
||||
__forceinline vboolf8 ge(const vboolf8& mask, const vfloat8& a, const vfloat8& b) { return _mm256_mask_cmp_ps_mask(mask, a, b, _MM_CMPINT_GE); }
|
||||
__forceinline vboolf8 gt(const vboolf8& mask, const vfloat8& a, const vfloat8& b) { return _mm256_mask_cmp_ps_mask(mask, a, b, _MM_CMPINT_GT); }
|
||||
__forceinline vboolf8 le(const vboolf8& mask, const vfloat8& a, const vfloat8& b) { return _mm256_mask_cmp_ps_mask(mask, a, b, _MM_CMPINT_LE); }
|
||||
#else
|
||||
__forceinline vboolf8 eq(const vboolf8& mask, const vfloat8& a, const vfloat8& b) { return mask & (a == b); }
|
||||
__forceinline vboolf8 ne(const vboolf8& mask, const vfloat8& a, const vfloat8& b) { return mask & (a != b); }
|
||||
__forceinline vboolf8 lt(const vboolf8& mask, const vfloat8& a, const vfloat8& b) { return mask & (a < b); }
|
||||
__forceinline vboolf8 ge(const vboolf8& mask, const vfloat8& a, const vfloat8& b) { return mask & (a >= b); }
|
||||
__forceinline vboolf8 gt(const vboolf8& mask, const vfloat8& a, const vfloat8& b) { return mask & (a > b); }
|
||||
__forceinline vboolf8 le(const vboolf8& mask, const vfloat8& a, const vfloat8& b) { return mask & (a <= b); }
|
||||
#endif
|
||||
|
||||
__forceinline vfloat8 lerp(const vfloat8& a, const vfloat8& b, const vfloat8& t) {
|
||||
return madd(t,b-a,a);
|
||||
#if defined(__AVX2__)
|
||||
return madd(t, b, madd(-t, a, a));
|
||||
#else
|
||||
return a + t*(b-a);
|
||||
#endif
|
||||
}
|
||||
|
||||
__forceinline bool isvalid ( const vfloat8& v ) {
|
||||
@@ -454,12 +421,10 @@ namespace embree
|
||||
__forceinline vfloat8 permute(const vfloat8 &a, const __m256i &index) {
|
||||
return _mm256_permutevar8x32_ps(a,index);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(__AVX512VL__)
|
||||
template<int i>
|
||||
__forceinline vfloat8 align_shift_right(const vfloat8 &a, const vfloat8 &b) {
|
||||
return _mm256_castsi256_ps(_mm256_alignr_epi32(_mm256_castps_si256(a), _mm256_castps_si256(b), i));
|
||||
return _mm256_castsi256_ps(_mm256_alignr_epi8(_mm256_castps_si256(a), _mm256_castps_si256(b), i));
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -482,17 +447,13 @@ namespace embree
|
||||
return vfloat8::broadcast(&a[k]);
|
||||
}
|
||||
|
||||
#if defined(__AVX512VL__)
|
||||
__forceinline vfloat8 shift_right_1( const vfloat8& x) {
|
||||
return align_shift_right<1>(zero,x);
|
||||
__forceinline vfloat8 shift_right_1( const vfloat8& x)
|
||||
{
|
||||
__m256 t0 = _mm256_permute_ps(x,0x39);
|
||||
__m256 t1 = _mm256_permute2f128_ps(t0,t0,0x81);
|
||||
__m256 y = _mm256_blend_ps(t0,t1,0x88);
|
||||
return y;
|
||||
}
|
||||
#else
|
||||
__forceinline vfloat8 shift_right_1( const vfloat8& x) {
|
||||
const vfloat8 t0 = shuffle<1,2,3,0>(x);
|
||||
const vfloat8 t1 = shuffle4<1,0>(t0);
|
||||
return _mm256_blend_ps(t0,t1,0x88);
|
||||
}
|
||||
#endif
|
||||
|
||||
__forceinline vint8 floori (const vfloat8& a) {
|
||||
return vint8(floor(a));
|
||||
@@ -607,7 +568,7 @@ namespace embree
|
||||
//__forceinline float length ( const vfloat<8>& a ) { return sqrt(dot(a,a)); }
|
||||
__forceinline vfloat<8> normalize( const vfloat<8>& a ) { return a*rsqrt(dot(a,a)); }
|
||||
//__forceinline float distance ( const vfloat<8>& a, const vfloat<8>& b ) { return length(a-b); }
|
||||
//__forceinline float halfArea ( const vfloat<8>& d ) { return madd(d.x,(d.y+d.z),d.y*d.z); }
|
||||
//__forceinline float halfArea ( const vfloat<8>& d ) { return d.x*(d.y+d.z)+d.y*d.z; }
|
||||
//__forceinline float area ( const vfloat<8>& d ) { return 2.0f*halfArea(d); }
|
||||
//__forceinline vfloat<8> reflect ( const vfloat<8>& V, const vfloat<8>& N ) { return 2.0f*dot(V,N)*N-V; }
|
||||
|
||||
@@ -619,63 +580,33 @@ namespace embree
|
||||
/// In Register Sorting
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
__forceinline vfloat8 sort_ascending(const vfloat8& v)
|
||||
__forceinline vfloat8 sortNetwork(const vfloat8& v)
|
||||
{
|
||||
const vfloat8 a0 = v;
|
||||
const vfloat8 b0 = shuffle<1,0,3,2>(a0);
|
||||
const vfloat8 c0 = min(a0,b0);
|
||||
const vfloat8 d0 = max(a0,b0);
|
||||
const vfloat8 a1 = select<0x99 /* 0b10011001 */>(c0,d0);
|
||||
const vfloat8 a1 = select(0x99 /* 0b10011001 */,c0,d0);
|
||||
const vfloat8 b1 = shuffle<2,3,0,1>(a1);
|
||||
const vfloat8 c1 = min(a1,b1);
|
||||
const vfloat8 d1 = max(a1,b1);
|
||||
const vfloat8 a2 = select<0xc3 /* 0b11000011 */>(c1,d1);
|
||||
const vfloat8 a2 = select(0xc3 /* 0b11000011 */,c1,d1);
|
||||
const vfloat8 b2 = shuffle<1,0,3,2>(a2);
|
||||
const vfloat8 c2 = min(a2,b2);
|
||||
const vfloat8 d2 = max(a2,b2);
|
||||
const vfloat8 a3 = select<0xa5 /* 0b10100101 */>(c2,d2);
|
||||
const vfloat8 a3 = select(0xa5 /* 0b10100101 */,c2,d2);
|
||||
const vfloat8 b3 = shuffle4<1,0>(a3);
|
||||
const vfloat8 c3 = min(a3,b3);
|
||||
const vfloat8 d3 = max(a3,b3);
|
||||
const vfloat8 a4 = select<0xf /* 0b00001111 */>(c3,d3);
|
||||
const vfloat8 a4 = select(0xf /* 0b00001111 */,c3,d3);
|
||||
const vfloat8 b4 = shuffle<2,3,0,1>(a4);
|
||||
const vfloat8 c4 = min(a4,b4);
|
||||
const vfloat8 d4 = max(a4,b4);
|
||||
const vfloat8 a5 = select<0x33 /* 0b00110011 */>(c4,d4);
|
||||
const vfloat8 a5 = select(0x33 /* 0b00110011 */,c4,d4);
|
||||
const vfloat8 b5 = shuffle<1,0,3,2>(a5);
|
||||
const vfloat8 c5 = min(a5,b5);
|
||||
const vfloat8 d5 = max(a5,b5);
|
||||
const vfloat8 a6 = select<0x55 /* 0b01010101 */>(c5,d5);
|
||||
return a6;
|
||||
}
|
||||
|
||||
__forceinline vfloat8 sort_descending(const vfloat8& v)
|
||||
{
|
||||
const vfloat8 a0 = v;
|
||||
const vfloat8 b0 = shuffle<1,0,3,2>(a0);
|
||||
const vfloat8 c0 = max(a0,b0);
|
||||
const vfloat8 d0 = min(a0,b0);
|
||||
const vfloat8 a1 = select<0x99 /* 0b10011001 */>(c0,d0);
|
||||
const vfloat8 b1 = shuffle<2,3,0,1>(a1);
|
||||
const vfloat8 c1 = max(a1,b1);
|
||||
const vfloat8 d1 = min(a1,b1);
|
||||
const vfloat8 a2 = select<0xc3 /* 0b11000011 */>(c1,d1);
|
||||
const vfloat8 b2 = shuffle<1,0,3,2>(a2);
|
||||
const vfloat8 c2 = max(a2,b2);
|
||||
const vfloat8 d2 = min(a2,b2);
|
||||
const vfloat8 a3 = select<0xa5 /* 0b10100101 */>(c2,d2);
|
||||
const vfloat8 b3 = shuffle4<1,0>(a3);
|
||||
const vfloat8 c3 = max(a3,b3);
|
||||
const vfloat8 d3 = min(a3,b3);
|
||||
const vfloat8 a4 = select<0xf /* 0b00001111 */>(c3,d3);
|
||||
const vfloat8 b4 = shuffle<2,3,0,1>(a4);
|
||||
const vfloat8 c4 = max(a4,b4);
|
||||
const vfloat8 d4 = min(a4,b4);
|
||||
const vfloat8 a5 = select<0x33 /* 0b00110011 */>(c4,d4);
|
||||
const vfloat8 b5 = shuffle<1,0,3,2>(a5);
|
||||
const vfloat8 c5 = max(a5,b5);
|
||||
const vfloat8 d5 = min(a5,b5);
|
||||
const vfloat8 a6 = select<0x55 /* 0b01010101 */>(c5,d5);
|
||||
const vfloat8 a6 = select(0x55 /* 0b01010101 */,c5,d5);
|
||||
return a6;
|
||||
}
|
||||
|
||||
|
||||
+182
-102
@@ -1,5 +1,5 @@
|
||||
// ======================================================================== //
|
||||
// Copyright 2009-2017 Intel Corporation //
|
||||
// Copyright 2009-2016 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
@@ -45,11 +45,11 @@ namespace embree
|
||||
__forceinline operator __m256i () const { return _mm512_castsi512_si256(v); }
|
||||
|
||||
__forceinline vint(const int i) {
|
||||
v = _mm512_set1_epi32(i);
|
||||
v = _mm512_set_1to16_epi32(i);
|
||||
}
|
||||
|
||||
__forceinline vint(const int a, const int b, const int c, const int d) {
|
||||
v = _mm512_set4_epi32(d,c,b,a);
|
||||
v = _mm512_set_4to16_epi32(d,c,b,a);
|
||||
}
|
||||
|
||||
__forceinline vint(const int a0 , const int a1 , const int a2 , const int a3,
|
||||
@@ -57,7 +57,7 @@ namespace embree
|
||||
const int a8 , const int a9 , const int a10, const int a11,
|
||||
const int a12, const int a13, const int a14, const int a15)
|
||||
{
|
||||
v = _mm512_set_epi32(a15,a14,a13,a12,a11,a10,a9,a8,a7,a6,a5,a4,a3,a2,a1,a0);
|
||||
v = _mm512_set_16to16_epi32(a15,a14,a13,a12,a11,a10,a9,a8,a7,a6,a5,a4,a3,a2,a1,a0);
|
||||
}
|
||||
|
||||
__forceinline vint(const vint4& i) {
|
||||
@@ -77,16 +77,16 @@ namespace embree
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
__forceinline vint( ZeroTy ) : v(_mm512_setzero_epi32()) {}
|
||||
__forceinline vint( OneTy ) : v(_mm512_set1_epi32(1)) {}
|
||||
__forceinline vint( PosInfTy ) : v(_mm512_set1_epi32(pos_inf)) {}
|
||||
__forceinline vint( NegInfTy ) : v(_mm512_set1_epi32(neg_inf)) {}
|
||||
__forceinline vint( StepTy ) : v(_mm512_set_epi32(15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0)) {}
|
||||
__forceinline vint( OneTy ) : v(_mm512_set_1to16_epi32(1)) {}
|
||||
__forceinline vint( PosInfTy ) : v(_mm512_set_1to16_epi32(pos_inf)) {}
|
||||
__forceinline vint( NegInfTy ) : v(_mm512_set_1to16_epi32(neg_inf)) {}
|
||||
__forceinline vint( StepTy ) : v(_mm512_set_16to16_epi32(15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0)) {}
|
||||
|
||||
__forceinline vint( ReverseStepTy ) : v(_mm512_setr_epi32(15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0)) {}
|
||||
|
||||
__forceinline static vint16 zero() { return _mm512_setzero_epi32(); }
|
||||
__forceinline static vint16 one () { return _mm512_set1_epi32(1); }
|
||||
__forceinline static vint16 neg_one () { return _mm512_set1_epi32(-1); }
|
||||
__forceinline static vint16 one () { return _mm512_set_1to16_epi32(1); }
|
||||
__forceinline static vint16 neg_one () { return _mm512_set_1to16_epi32(-1); }
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// Loads and Stores
|
||||
@@ -94,8 +94,7 @@ namespace embree
|
||||
|
||||
static __forceinline vint16 load (const void* addr) { return _mm512_load_si512((int*)addr); }
|
||||
|
||||
static __forceinline const vint16 load( const unsigned char* const ptr ) { return _mm512_cvtepu8_epi32(_mm_load_si128((__m128i*)ptr)); }
|
||||
static __forceinline const vint16 load( const unsigned short* const ptr ) { return _mm512_cvtepu16_epi32(*(__m256i*)ptr); }
|
||||
static __forceinline const vint16 load( const unsigned char* const ptr ) { return _mm512_cvtepu8_epi32(_mm_load_si128((__m128i*)ptr)); }
|
||||
|
||||
static __forceinline vint16 loadu(const void* addr) { return _mm512_loadu_si512(addr); }
|
||||
|
||||
@@ -108,7 +107,7 @@ namespace embree
|
||||
static __forceinline void store (const vboolf16& mask, void* addr, const vint16& v2) { _mm512_mask_store_epi32(addr,mask,v2); }
|
||||
static __forceinline void storeu(const vboolf16& mask, void* ptr, const vint16& f ) { _mm512_mask_storeu_epi32((int*)ptr,mask,f); }
|
||||
|
||||
static __forceinline void store_nt(void *__restrict__ ptr, const vint16& a) { _mm512_stream_si512((__m512i*)ptr,a); }
|
||||
static __forceinline void store_nt(void *__restrict__ ptr, const vint16& a) { _mm512_stream_si512(ptr,a); }
|
||||
|
||||
/* pass by value to avoid compiler generating inefficient code */
|
||||
static __forceinline void storeu_compact(const vboolf16 mask,void * addr, const vint16 reg) {
|
||||
@@ -117,9 +116,10 @@ namespace embree
|
||||
|
||||
static __forceinline void storeu_compact_single(const vboolf16 mask,void * addr, const vint16 reg) {
|
||||
//_mm512_mask_compressstoreu_epi32(addr,mask,reg);
|
||||
*(float*)addr = mm512_cvtss_f32(_mm512_mask_compress_ps(_mm512_castsi512_ps(reg),mask,_mm512_castsi512_ps(reg)));
|
||||
*(float*)addr = _mm512_cvtss_f32(_mm512_mask_compress_ps(_mm512_castsi512_ps(reg),mask,_mm512_castsi512_ps(reg)));
|
||||
}
|
||||
|
||||
|
||||
static __forceinline vint16 compact64bit(const vboolf16& mask, vint16 &v) {
|
||||
return _mm512_mask_compress_epi64(v,mask,v);
|
||||
}
|
||||
@@ -132,14 +132,22 @@ namespace embree
|
||||
return _mm512_mask_compress_epi32(a,mask,b);
|
||||
}
|
||||
|
||||
static __forceinline vint16 expand(const vboolf16& mask, const vint16& a, vint16& b) {
|
||||
return _mm512_mask_expand_epi32(b,mask,a);
|
||||
}
|
||||
|
||||
static __forceinline vint16 broadcast64bit(size_t v) {
|
||||
return _mm512_set1_epi64(v);
|
||||
}
|
||||
|
||||
static __forceinline size_t extracti64bit(const vint16& v) {
|
||||
return _mm_cvtsi128_si64(_mm512_castsi512_si128(v));
|
||||
}
|
||||
|
||||
static __forceinline vint4 extracti128bit(const vint16& v) {
|
||||
return _mm512_castsi512_si128(v);
|
||||
}
|
||||
|
||||
static __forceinline vint8 extracti256bit(const vint16& v) {
|
||||
return _mm512_castsi512_si256(v);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// Array Access
|
||||
@@ -266,22 +274,29 @@ namespace embree
|
||||
__forceinline const vboolf16 operator <=( const vint16& a, const int b ) { return a <= vint16(b); }
|
||||
__forceinline const vboolf16 operator <=( const int a, const vint16& b ) { return vint16(a) <= b; }
|
||||
|
||||
__forceinline vboolf16 eq(const vint16& a, const vint16& b) { return _mm512_cmp_epi32_mask(a,b,_MM_CMPINT_EQ); }
|
||||
__forceinline vboolf16 ne(const vint16& a, const vint16& b) { return _mm512_cmp_epi32_mask(a,b,_MM_CMPINT_NE); }
|
||||
__forceinline vboolf16 lt(const vint16& a, const vint16& b) { return _mm512_cmp_epi32_mask(a,b,_MM_CMPINT_LT); }
|
||||
__forceinline vboolf16 ge(const vint16& a, const vint16& b) { return _mm512_cmp_epi32_mask(a,b,_MM_CMPINT_GE); }
|
||||
__forceinline vboolf16 gt(const vint16& a, const vint16& b) { return _mm512_cmp_epi32_mask(a,b,_MM_CMPINT_GT); }
|
||||
__forceinline vboolf16 le(const vint16& a, const vint16& b) { return _mm512_cmp_epi32_mask(a,b,_MM_CMPINT_LE); }
|
||||
__forceinline vboolf16 uint_le(const vint16& a, const vint16& b) { return _mm512_cmp_epu32_mask(a,b,_MM_CMPINT_LE); }
|
||||
__forceinline vboolf16 uint_gt(const vint16& a, const vint16& b) { return _mm512_cmp_epu32_mask(a,b,_MM_CMPINT_GT); }
|
||||
|
||||
__forceinline vboolf16 eq( const vint16& a, const vint16& b) { return _mm512_cmp_epi32_mask(a,b,_MM_CMPINT_EQ); }
|
||||
__forceinline vboolf16 eq(const vboolf16 mask, const vint16& a, const vint16& b) { return _mm512_mask_cmp_epi32_mask(mask,a,b,_MM_CMPINT_EQ); }
|
||||
|
||||
__forceinline vboolf16 ne( const vint16& a, const vint16& b) { return _mm512_cmp_epi32_mask(a,b,_MM_CMPINT_NE); }
|
||||
__forceinline vboolf16 ne(const vboolf16 mask, const vint16& a, const vint16& b) { return _mm512_mask_cmp_epi32_mask(mask,a,b,_MM_CMPINT_NE); }
|
||||
|
||||
__forceinline vboolf16 lt( const vint16& a, const vint16& b) { return _mm512_cmp_epi32_mask(a,b,_MM_CMPINT_LT); }
|
||||
__forceinline vboolf16 lt(const vboolf16 mask, const vint16& a, const vint16& b) { return _mm512_mask_cmp_epi32_mask(mask,a,b,_MM_CMPINT_LT); }
|
||||
|
||||
__forceinline vboolf16 ge( const vint16& a, const vint16& b) { return _mm512_cmp_epi32_mask(a,b,_MM_CMPINT_GE); }
|
||||
__forceinline vboolf16 ge(const vboolf16 mask, const vint16& a, const vint16& b) { return _mm512_mask_cmp_epi32_mask(mask,a,b,_MM_CMPINT_GE); }
|
||||
|
||||
__forceinline vboolf16 gt( const vint16& a, const vint16& b) { return _mm512_cmp_epi32_mask(a,b,_MM_CMPINT_GT); }
|
||||
__forceinline vboolf16 gt(const vboolf16 mask, const vint16& a, const vint16& b) { return _mm512_mask_cmp_epi32_mask(mask,a,b,_MM_CMPINT_GT); }
|
||||
|
||||
__forceinline vboolf16 le( const vint16& a, const vint16& b) { return _mm512_cmp_epi32_mask(a,b,_MM_CMPINT_LE); }
|
||||
__forceinline vboolf16 le(const vboolf16 mask, const vint16& a, const vint16& b) { return _mm512_mask_cmp_epi32_mask(mask,a,b,_MM_CMPINT_LE); }
|
||||
|
||||
|
||||
__forceinline vboolf16 uint_le( const vint16& a, const vint16& b) { return _mm512_cmp_epu32_mask(a,b,_MM_CMPINT_LE); }
|
||||
__forceinline vboolf16 uint_le(const vboolf16 mask, const vint16& a, const vint16& b) { return _mm512_mask_cmp_epu32_mask(mask,a,b,_MM_CMPINT_LE); }
|
||||
|
||||
__forceinline vboolf16 uint_gt( const vint16& a, const vint16& b) { return _mm512_cmp_epu32_mask(a,b,_MM_CMPINT_GT); }
|
||||
__forceinline vboolf16 uint_gt(const vboolf16 mask, const vint16& a, const vint16& b) { return _mm512_mask_cmp_epu32_mask(mask,a,b,_MM_CMPINT_GT); }
|
||||
|
||||
|
||||
@@ -308,24 +323,39 @@ namespace embree
|
||||
__forceinline vint16 unpacklo( const vint16& a, const vint16& b ) { return _mm512_unpacklo_epi32(a.v, b.v); }
|
||||
__forceinline vint16 unpackhi( const vint16& a, const vint16& b ) { return _mm512_unpackhi_epi32(a.v, b.v); }
|
||||
|
||||
template<size_t i>
|
||||
__forceinline const vint16 shuffle( const vint16& a ) {
|
||||
return _mm512_castps_si512(_mm512_permute_ps(_mm512_castsi512_ps(a), _MM_SHUFFLE(i, i, i, i)));
|
||||
__forceinline vint16 shuffle(const vint16& x,_MM_SWIZZLE_ENUM perm32 ) { return _mm512_swizzle_epi32(x,perm32); }
|
||||
__forceinline vint16 shuffle4(const vint16& x,_MM_PERM_ENUM perm128) { return _mm512_permute4f128_epi32(x,perm128); }
|
||||
|
||||
template<int D, int C, int B, int A> __forceinline vint16 shuffle (const vint16& v) { return _mm512_shuffle_epi32(v,_MM_SHUF_PERM(D,C,B,A)); }
|
||||
template<int A> __forceinline vint16 shuffle (const vint16& x) { return shuffle<A,A,A,A>(v); }
|
||||
template<> __forceinline vint16 shuffle<0>(const vint16& x) { return shuffle(x,_MM_SWIZ_REG_AAAA); }
|
||||
template<> __forceinline vint16 shuffle<1>(const vint16& x) { return shuffle(x,_MM_SWIZ_REG_BBBB); }
|
||||
template<> __forceinline vint16 shuffle<2>(const vint16& x) { return shuffle(x,_MM_SWIZ_REG_CCCC); }
|
||||
template<> __forceinline vint16 shuffle<3>(const vint16& x) { return shuffle(x,_MM_SWIZ_REG_DDDD); }
|
||||
|
||||
template<int D, int C, int B, int A> __forceinline vint16 shuffle4(const vint16& v) { return shuffle4(v,_MM_SHUF_PERM(D,C,B,A)); }
|
||||
template<int A> __forceinline vint16 shuffle4(const vint16& x) { return shuffle4<A,A,A,A>(x); }
|
||||
|
||||
__forceinline vint16 shuffle(const vint16& x,_MM_PERM_ENUM perm128, _MM_SWIZZLE_ENUM perm32) { return shuffle(shuffle4(x,perm128),perm32); }
|
||||
|
||||
__forceinline vint16 shuffle(const vboolf16& mask, vint16& v, const vint16& x,_MM_PERM_ENUM perm128, _MM_SWIZZLE_ENUM perm32) {
|
||||
return _mm512_mask_swizzle_epi32(_mm512_mask_permute4f128_epi32(v,mask,x,perm128),mask,x,perm32);
|
||||
}
|
||||
|
||||
template<int A, int B, int C, int D>
|
||||
__forceinline vint16 shuffle (const vint16& v) {
|
||||
return _mm512_castps_si512(_mm512_permute_ps(_mm512_castsi512_ps(v),_MM_SHUFFLE(D,C,B,A)));
|
||||
__forceinline vint16 swAAAA(const vint16& x) {
|
||||
return shuffle(x,_MM_SWIZ_REG_AAAA);
|
||||
}
|
||||
|
||||
template<int i>
|
||||
__forceinline vint16 shuffle4(const vint16& x) {
|
||||
return _mm512_castps_si512(_mm512_shuffle_f32x4(_mm512_castsi512_ps(x),_mm512_castsi512_ps(x),_MM_SHUFFLE(i,i,i,i)));
|
||||
__forceinline vint16 swBBBB(const vint16& x) {
|
||||
return shuffle(x,_MM_SWIZ_REG_BBBB);
|
||||
}
|
||||
|
||||
template<int A, int B, int C, int D>
|
||||
__forceinline vint16 shuffle4(const vint16& x) {
|
||||
return _mm512_castps_si512(_mm512_shuffle_f32x4(_mm512_castsi512_ps(x),_mm512_castsi512_ps(x),_MM_SHUFFLE(D,C,B,A)));
|
||||
__forceinline vint16 swCCCC(const vint16& x) {
|
||||
return shuffle(x,_MM_SWIZ_REG_CCCC);
|
||||
}
|
||||
|
||||
__forceinline vint16 swDDDD(const vint16& x) {
|
||||
return shuffle(x,_MM_SWIZ_REG_DDDD);
|
||||
}
|
||||
|
||||
template<int i>
|
||||
@@ -339,80 +369,98 @@ namespace embree
|
||||
return _mm_cvtsi128_si32(_mm512_castsi512_si128(a));
|
||||
}
|
||||
|
||||
template<int i> __forceinline const vint16 insert4(const vint16& a, const vint4& b) { return _mm512_inserti32x4(a, b, i); }
|
||||
|
||||
__forceinline size_t extract64bit(const vint16& v) {
|
||||
return _mm_cvtsi128_si64(_mm512_castsi512_si128(v));
|
||||
}
|
||||
|
||||
template<int N, int i>
|
||||
vint<N> extractN(const vint16& v);
|
||||
|
||||
template<> __forceinline vint4 extractN<4,0>(const vint16& v) { return _mm512_castsi512_si128(v); }
|
||||
template<> __forceinline vint4 extractN<4,1>(const vint16& v) { return _mm512_extracti32x4_epi32(v, 1); }
|
||||
template<> __forceinline vint4 extractN<4,2>(const vint16& v) { return _mm512_extracti32x4_epi32(v, 2); }
|
||||
template<> __forceinline vint4 extractN<4,3>(const vint16& v) { return _mm512_extracti32x4_epi32(v, 3); }
|
||||
|
||||
template<> __forceinline vint8 extractN<8,0>(const vint16& v) { return _mm512_castsi512_si256(v); }
|
||||
template<> __forceinline vint8 extractN<8,1>(const vint16& v) { return _mm512_extracti32x8_epi32(v, 1); }
|
||||
|
||||
template<int i> __forceinline vint4 extract4 (const vint16& v) { return _mm512_extracti32x4_epi32(v, i); }
|
||||
template<> __forceinline vint4 extract4<0>(const vint16& v) { return _mm512_castsi512_si128(v); }
|
||||
|
||||
template<int i> __forceinline vint8 extract8 (const vint16& v) { return _mm512_extracti32x8_epi32(v, i); }
|
||||
template<> __forceinline vint8 extract8<0>(const vint16& v) { return _mm512_castsi512_si256(v); }
|
||||
template<size_t i> __forceinline const vint16 insert4(const vint16& a, const vint4& b) { return _mm512_inserti32x4(a, b, i); }
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// Reductions
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
__forceinline vint16 vreduce_min2(vint16 x) { return min(x,shuffle<1,0,3,2>(x)); }
|
||||
__forceinline vint16 vreduce_min4(vint16 x) { x = vreduce_min2(x); return min(x,shuffle<2,3,0,1>(x)); }
|
||||
__forceinline vint16 vreduce_min8(vint16 x) { x = vreduce_min4(x); return min(x,shuffle4<1,0,3,2>(x)); }
|
||||
__forceinline vint16 vreduce_min (vint16 x) { x = vreduce_min8(x); return min(x,shuffle4<2,3,0,1>(x)); }
|
||||
|
||||
__forceinline vint16 vreduce_max2(vint16 x) { return max(x,shuffle<1,0,3,2>(x)); }
|
||||
__forceinline vint16 vreduce_max4(vint16 x) { x = vreduce_max2(x); return max(x,shuffle<2,3,0,1>(x)); }
|
||||
__forceinline vint16 vreduce_max8(vint16 x) { x = vreduce_max4(x); return max(x,shuffle4<1,0,3,2>(x)); }
|
||||
__forceinline vint16 vreduce_max (vint16 x) { x = vreduce_max8(x); return max(x,shuffle4<2,3,0,1>(x)); }
|
||||
|
||||
__forceinline vint16 vreduce_and2(vint16 x) { return x & shuffle<1,0,3,2>(x); }
|
||||
__forceinline vint16 vreduce_and4(vint16 x) { x = vreduce_and2(x); return x & shuffle<2,3,0,1>(x); }
|
||||
__forceinline vint16 vreduce_and8(vint16 x) { x = vreduce_and4(x); return x & shuffle4<1,0,3,2>(x); }
|
||||
__forceinline vint16 vreduce_and (vint16 x) { x = vreduce_and8(x); return x & shuffle4<2,3,0,1>(x); }
|
||||
|
||||
__forceinline vint16 vreduce_or2(vint16 x) { return x | shuffle<1,0,3,2>(x); }
|
||||
__forceinline vint16 vreduce_or4(vint16 x) { x = vreduce_or2(x); return x | shuffle<2,3,0,1>(x); }
|
||||
__forceinline vint16 vreduce_or8(vint16 x) { x = vreduce_or4(x); return x | shuffle4<1,0,3,2>(x); }
|
||||
__forceinline vint16 vreduce_or (vint16 x) { x = vreduce_or8(x); return x | shuffle4<2,3,0,1>(x); }
|
||||
|
||||
__forceinline vint16 vreduce_add2(vint16 x) { return x + shuffle<1,0,3,2>(x); }
|
||||
__forceinline vint16 vreduce_add4(vint16 x) { x = vreduce_add2(x); return x + shuffle<2,3,0,1>(x); }
|
||||
__forceinline vint16 vreduce_add8(vint16 x) { x = vreduce_add4(x); return x + shuffle4<1,0,3,2>(x); }
|
||||
__forceinline vint16 vreduce_add (vint16 x) { x = vreduce_add8(x); return x + shuffle4<2,3,0,1>(x); }
|
||||
|
||||
__forceinline int reduce_min(const vint16& v) { return toScalar(vreduce_min(v)); }
|
||||
__forceinline int reduce_max(const vint16& v) { return toScalar(vreduce_max(v)); }
|
||||
__forceinline int reduce_and(const vint16& v) { return toScalar(vreduce_and(v)); }
|
||||
__forceinline int reduce_or (const vint16& v) { return toScalar(vreduce_or (v)); }
|
||||
__forceinline int reduce_add(const vint16& v) { return toScalar(vreduce_add(v)); }
|
||||
__forceinline int reduce_add(vint16 a) { return _mm512_reduce_add_epi32(a); }
|
||||
__forceinline int reduce_mul(vint16 a) { return _mm512_reduce_mul_epi32(a); }
|
||||
__forceinline int reduce_min(vint16 a) { return _mm512_reduce_min_epi32(a); }
|
||||
__forceinline int reduce_max(vint16 a) { return _mm512_reduce_max_epi32(a); }
|
||||
__forceinline int reduce_and(vint16 a) { return _mm512_reduce_and_epi32(a); }
|
||||
|
||||
__forceinline vint16 vreduce_min2(vint16 x) { return min(x,shuffle(x,_MM_SWIZ_REG_BADC)); }
|
||||
__forceinline vint16 vreduce_min4(vint16 x) { x = vreduce_min2(x); return min(x,shuffle(x,_MM_SWIZ_REG_CDAB)); }
|
||||
__forceinline vint16 vreduce_min8(vint16 x) { x = vreduce_min4(x); return min(x,shuffle4(x,_MM_SHUF_PERM(2,3,0,1))); }
|
||||
__forceinline vint16 vreduce_min (vint16 x) { x = vreduce_min8(x); return min(x,shuffle4(x,_MM_SHUF_PERM(1,0,3,2))); }
|
||||
|
||||
__forceinline vint16 vreduce_max2(vint16 x) { return max(x,shuffle(x,_MM_SWIZ_REG_BADC)); }
|
||||
__forceinline vint16 vreduce_max4(vint16 x) { x = vreduce_max2(x); return max(x,shuffle(x,_MM_SWIZ_REG_CDAB)); }
|
||||
__forceinline vint16 vreduce_max8(vint16 x) { x = vreduce_max4(x); return max(x,shuffle4(x,_MM_SHUF_PERM(2,3,0,1))); }
|
||||
__forceinline vint16 vreduce_max (vint16 x) { x = vreduce_max8(x); return max(x,shuffle4(x,_MM_SHUF_PERM(1,0,3,2))); }
|
||||
|
||||
__forceinline vint16 vreduce_and2(vint16 x) { return x & shuffle(x,_MM_SWIZ_REG_BADC); }
|
||||
__forceinline vint16 vreduce_and4(vint16 x) { x = vreduce_and2(x); return x & shuffle(x,_MM_SWIZ_REG_CDAB); }
|
||||
__forceinline vint16 vreduce_and8(vint16 x) { x = vreduce_and4(x); return x & shuffle4(x,_MM_SHUF_PERM(2,3,0,1)); }
|
||||
__forceinline vint16 vreduce_and (vint16 x) { x = vreduce_and8(x); return x & shuffle4(x,_MM_SHUF_PERM(1,0,3,2)); }
|
||||
|
||||
__forceinline vint16 vreduce_or2(vint16 x) { return x | shuffle(x,_MM_SWIZ_REG_BADC); }
|
||||
__forceinline vint16 vreduce_or4(vint16 x) { x = vreduce_or2(x); return x | shuffle(x,_MM_SWIZ_REG_CDAB); }
|
||||
__forceinline vint16 vreduce_or8(vint16 x) { x = vreduce_or4(x); return x | shuffle4(x,_MM_SHUF_PERM(2,3,0,1)); }
|
||||
__forceinline vint16 vreduce_or (vint16 x) { x = vreduce_or8(x); return x | shuffle4(x,_MM_SHUF_PERM(1,0,3,2)); }
|
||||
|
||||
__forceinline vint16 vreduce_add2(vint16 x) { return x + shuffle(x,_MM_SWIZ_REG_BADC); }
|
||||
__forceinline vint16 vreduce_add4(vint16 x) { x = vreduce_add2(x); return x + shuffle(x,_MM_SWIZ_REG_CDAB); }
|
||||
__forceinline vint16 vreduce_add8(vint16 x) { x = vreduce_add4(x); return x + shuffle4(x,_MM_SHUF_PERM(2,3,0,1)); }
|
||||
__forceinline vint16 vreduce_add (vint16 x) { x = vreduce_add8(x); return x + shuffle4(x,_MM_SHUF_PERM(1,0,3,2)); }
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// Memory load and store operations
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template<int scale = 4>
|
||||
__forceinline vint16 gather16i(const vboolf16& mask, const int *const ptr, const vint16& index) {
|
||||
__forceinline vint16 broadcast4to16i(const int *const ptr) {
|
||||
return _mm512_extload_epi32(ptr,_MM_UPCONV_EPI32_NONE,_MM_BROADCAST_4X16,_MM_HINT_NONE);
|
||||
}
|
||||
|
||||
__forceinline vint16 gather16i_4i(const int *__restrict__ const ptr0,
|
||||
const int *__restrict__ const ptr1,
|
||||
const int *__restrict__ const ptr2,
|
||||
const int *__restrict__ const ptr3)
|
||||
{
|
||||
vint16 v = broadcast4to16i(ptr0);
|
||||
v = select((vboolf16)0xf0 , broadcast4to16i(ptr1),v);
|
||||
v = select((vboolf16)0xf00 , broadcast4to16i(ptr2),v);
|
||||
v = select((vboolf16)0xf000, broadcast4to16i(ptr3),v);
|
||||
return v;
|
||||
}
|
||||
|
||||
|
||||
__forceinline vint16 gather16i_4i_align(const void *__restrict__ const ptr0,
|
||||
const void *__restrict__ const ptr1,
|
||||
const void *__restrict__ const ptr2,
|
||||
const void *__restrict__ const ptr3)
|
||||
{
|
||||
vint16 v = broadcast4to16i((const int*)ptr3);
|
||||
v = align_shift_right<12>(v,broadcast4to16i((const int*)ptr2));
|
||||
v = align_shift_right<12>(v,broadcast4to16i((const int*)ptr1));
|
||||
v = align_shift_right<12>(v,broadcast4to16i((const int*)ptr0));
|
||||
return v;
|
||||
}
|
||||
|
||||
__forceinline vint16 gather16i_4i_align(const vint16& v0,
|
||||
const vint16& v1,
|
||||
const vint16& v2,
|
||||
const vint16& v3)
|
||||
{
|
||||
vint16 v = v3;
|
||||
v = align_shift_right<12>(v,v2);
|
||||
v = align_shift_right<12>(v,v1);
|
||||
v = align_shift_right<12>(v,v0);
|
||||
return v;
|
||||
}
|
||||
|
||||
|
||||
__forceinline vint16 gather16i(const vboolf16& mask, const int *const ptr, const vint16& index,const int scale = 4) {
|
||||
return _mm512_mask_i32gather_epi32(_mm512_undefined_epi32(),mask,index,ptr,scale);
|
||||
}
|
||||
|
||||
template<int scale = 4>
|
||||
__forceinline vint16 gather16i(const vboolf16& mask, vint16& dest, const int *const ptr, const vint16& index) {
|
||||
__forceinline vint16 gather16i(const vboolf16& mask, vint16& dest, const int *const ptr, const vint16& index,const int scale = 4) {
|
||||
return _mm512_mask_i32gather_epi32(dest,mask,index,ptr,scale);
|
||||
}
|
||||
|
||||
template<int scale = 4>
|
||||
__forceinline void scatter16i(const vboolf16& mask,int *const ptr, const vint16& index,const vint16& v) {
|
||||
__forceinline void scatter16i(const vboolf16& mask,int *const ptr, const vint16& index,const vint16& v, const int scale = 4) {
|
||||
_mm512_mask_i32scatter_epi32((int*)ptr,mask,index,v,scale);
|
||||
}
|
||||
|
||||
@@ -435,11 +483,13 @@ namespace embree
|
||||
return _mm512_cvtps_epu32(f);
|
||||
}
|
||||
|
||||
__forceinline vint16 permute(vint16 v, vint16 index) {
|
||||
return _mm512_permutexvar_epi32(index,v);
|
||||
__forceinline vint16 permute(vint16 v,vint16 index)
|
||||
{
|
||||
return _mm512_permutev_epi32(index,v);
|
||||
}
|
||||
|
||||
__forceinline vint16 reverse(const vint16 &a) {
|
||||
__forceinline vint16 reverse(const vint16 &a)
|
||||
{
|
||||
return permute(a,vint16(reverse_step));
|
||||
}
|
||||
|
||||
@@ -466,13 +516,43 @@ namespace embree
|
||||
}
|
||||
|
||||
/* this should use a vbool8 and a vint8_64...*/
|
||||
template<int scale = 1, int hint = _MM_HINT_T0>
|
||||
__forceinline void gather_prefetch64(void const* base_addr,const vbool16 &mask, const vint16& offset)
|
||||
__forceinline void gather_prefetch64(void const* base_addr,const vbool16 &mask, const vint16& offset, const int scale = 1, const int hint = _MM_HINT_T0)
|
||||
{
|
||||
#if defined(__AVX512PF__)
|
||||
_mm512_mask_prefetch_i64gather_pd(offset,mask,base_addr,scale,hint);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
__forceinline vint16 sortNetwork(const vint16& v)
|
||||
{
|
||||
const vint16 a0 = v;
|
||||
const vint16 b0 = shuffle<1,0,3,2>(a0);
|
||||
const vint16 c0 = umin(a0,b0);
|
||||
const vint16 d0 = umax(a0,b0);
|
||||
const vint16 a1 = select(0x99 /* 0b10011001 */,c0,d0);
|
||||
const vint16 b1 = shuffle<2,3,0,1>(a1);
|
||||
const vint16 c1 = umin(a1,b1);
|
||||
const vint16 d1 = umax(a1,b1);
|
||||
const vint16 a2 = select(0xc3 /* 0b11000011 */,c1,d1);
|
||||
const vint16 b2 = shuffle<1,0,3,2>(a2);
|
||||
const vint16 c2 = umin(a2,b2);
|
||||
const vint16 d2 = umax(a2,b2);
|
||||
const vint16 a3 = select(0xa5 /* 0b10100101 */,c2,d2);
|
||||
const vint16 b3 = shuffle4<1,0,1,0>(a3);
|
||||
const vint16 c3 = umin(a3,b3);
|
||||
const vint16 d3 = umax(a3,b3);
|
||||
const vint16 a4 = select(0xf /* 0b00001111 */,c3,d3);
|
||||
const vint16 b4 = shuffle<2,3,0,1>(a4);
|
||||
const vint16 c4 = umin(a4,b4);
|
||||
const vint16 d4 = umax(a4,b4);
|
||||
const vint16 a5 = select(0x33 /* 0b00110011 */,c4,d4);
|
||||
const vint16 b5 = shuffle<1,0,3,2>(a5);
|
||||
const vint16 c5 = umin(a5,b5);
|
||||
const vint16 d5 = umax(a5,b5);
|
||||
const vint16 a6 = select(0x55 /* 0b01010101 */,c5,d5);
|
||||
return a6;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// Output Operators
|
||||
|
||||
+33
-115
@@ -1,5 +1,5 @@
|
||||
// ======================================================================== //
|
||||
// Copyright 2009-2017 Intel Corporation //
|
||||
// Copyright 2009-2016 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
@@ -119,7 +119,7 @@ namespace embree
|
||||
#endif
|
||||
}
|
||||
|
||||
static __forceinline void store( unsigned char* const ptr, const vint4& v ) {
|
||||
static __forceinline void store_uchar( unsigned char* const ptr, const vint4& v ) {
|
||||
#if defined(__SSE4_1__)
|
||||
__m128i x = v;
|
||||
x = _mm_packus_epi32(x, x);
|
||||
@@ -131,11 +131,6 @@ namespace embree
|
||||
#endif
|
||||
}
|
||||
|
||||
static __forceinline void store( unsigned short* const ptr, const vint4& v ) {
|
||||
for (size_t i=0;i<4;i++)
|
||||
ptr[i] = (unsigned short)v[i];
|
||||
}
|
||||
|
||||
static __forceinline vint4 load_nt (void* ptr) {
|
||||
#if defined(__SSE4_1__)
|
||||
return _mm_stream_load_si128((__m128i*)ptr);
|
||||
@@ -224,6 +219,23 @@ namespace embree
|
||||
__forceinline const vint4 sra ( const vint4& a, const int& b ) { return _mm_srai_epi32(a.v, b); }
|
||||
__forceinline const vint4 srl ( const vint4& a, const int& b ) { return _mm_srli_epi32(a.v, b); }
|
||||
|
||||
#if defined(__SSE4_1__)
|
||||
__forceinline const vint4 min( const vint4& a, const vint4& b ) { return _mm_min_epi32(a.v, b.v); }
|
||||
__forceinline const vint4 max( const vint4& a, const vint4& b ) { return _mm_max_epi32(a.v, b.v); }
|
||||
|
||||
__forceinline const vint4 umin( const vint4& a, const vint4& b ) { return _mm_min_epu32(a.v, b.v); }
|
||||
__forceinline const vint4 umax( const vint4& a, const vint4& b ) { return _mm_max_epu32(a.v, b.v); }
|
||||
|
||||
#else
|
||||
__forceinline const vint4 min( const vint4& a, const vint4& b ) { return vint4(min(a[0],b[0]),min(a[1],b[1]),min(a[2],b[2]),min(a[3],b[3])); }
|
||||
__forceinline const vint4 max( const vint4& a, const vint4& b ) { return vint4(max(a[0],b[0]),max(a[1],b[1]),max(a[2],b[2]),max(a[3],b[3])); }
|
||||
#endif
|
||||
|
||||
__forceinline const vint4 min( const vint4& a, const int& b ) { return min(a,vint4(b)); }
|
||||
__forceinline const vint4 min( const int& a, const vint4& b ) { return min(vint4(a),b); }
|
||||
__forceinline const vint4 max( const vint4& a, const int& b ) { return max(a,vint4(b)); }
|
||||
__forceinline const vint4 max( const int& a, const vint4& b ) { return max(vint4(a),b); }
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// Assignment Operators
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -260,11 +272,11 @@ namespace embree
|
||||
__forceinline const vboolf4 operator > ( const vint4& a, const vint4& b ) { return _mm_cmp_epi32_mask(a,b,_MM_CMPINT_GT); }
|
||||
__forceinline const vboolf4 operator <=( const vint4& a, const vint4& b ) { return _mm_cmp_epi32_mask(a,b,_MM_CMPINT_LE); }
|
||||
#else
|
||||
__forceinline const vboolf4 operator ==( const vint4& a, const vint4& b ) { return _mm_castsi128_ps(_mm_cmpeq_epi32(a, b)); }
|
||||
__forceinline const vboolf4 operator ==( const vint4& a, const vint4& b ) { return _mm_castsi128_ps(_mm_cmpeq_epi32 (a.v, b.v)); }
|
||||
__forceinline const vboolf4 operator !=( const vint4& a, const vint4& b ) { return !(a == b); }
|
||||
__forceinline const vboolf4 operator < ( const vint4& a, const vint4& b ) { return _mm_castsi128_ps(_mm_cmplt_epi32(a, b)); }
|
||||
__forceinline const vboolf4 operator < ( const vint4& a, const vint4& b ) { return _mm_castsi128_ps(_mm_cmplt_epi32 (a.v, b.v)); }
|
||||
__forceinline const vboolf4 operator >=( const vint4& a, const vint4& b ) { return !(a < b); }
|
||||
__forceinline const vboolf4 operator > ( const vint4& a, const vint4& b ) { return _mm_castsi128_ps(_mm_cmpgt_epi32(a, b)); }
|
||||
__forceinline const vboolf4 operator > ( const vint4& a, const vint4& b ) { return _mm_castsi128_ps(_mm_cmpgt_epi32 (a.v, b.v)); }
|
||||
__forceinline const vboolf4 operator <=( const vint4& a, const vint4& b ) { return !(a > b); }
|
||||
#endif
|
||||
|
||||
@@ -286,54 +298,18 @@ namespace embree
|
||||
__forceinline const vboolf4 operator <=( const vint4& a, const int& b ) { return a <= vint4(b); }
|
||||
__forceinline const vboolf4 operator <=( const int& a, const vint4& b ) { return vint4(a) <= b; }
|
||||
|
||||
__forceinline vboolf4 eq(const vint4& a, const vint4& b) { return a == b; }
|
||||
__forceinline vboolf4 ne(const vint4& a, const vint4& b) { return a != b; }
|
||||
__forceinline vboolf4 lt(const vint4& a, const vint4& b) { return a < b; }
|
||||
__forceinline vboolf4 ge(const vint4& a, const vint4& b) { return a >= b; }
|
||||
__forceinline vboolf4 gt(const vint4& a, const vint4& b) { return a > b; }
|
||||
__forceinline vboolf4 le(const vint4& a, const vint4& b) { return a <= b; }
|
||||
|
||||
#if defined(__AVX512VL__)
|
||||
__forceinline vboolf4 eq(const vboolf4& mask, const vint4& a, const vint4& b) { return _mm_mask_cmp_epi32_mask(mask, a, b, _MM_CMPINT_EQ); }
|
||||
__forceinline vboolf4 ne(const vboolf4& mask, const vint4& a, const vint4& b) { return _mm_mask_cmp_epi32_mask(mask, a, b, _MM_CMPINT_NE); }
|
||||
__forceinline vboolf4 lt(const vboolf4& mask, const vint4& a, const vint4& b) { return _mm_mask_cmp_epi32_mask(mask, a, b, _MM_CMPINT_LT); }
|
||||
__forceinline vboolf4 ge(const vboolf4& mask, const vint4& a, const vint4& b) { return _mm_mask_cmp_epi32_mask(mask, a, b, _MM_CMPINT_GE); }
|
||||
__forceinline vboolf4 gt(const vboolf4& mask, const vint4& a, const vint4& b) { return _mm_mask_cmp_epi32_mask(mask, a, b, _MM_CMPINT_GT); }
|
||||
__forceinline vboolf4 le(const vboolf4& mask, const vint4& a, const vint4& b) { return _mm_mask_cmp_epi32_mask(mask, a, b, _MM_CMPINT_LE); }
|
||||
#else
|
||||
__forceinline vboolf4 eq(const vboolf4& mask, const vint4& a, const vint4& b) { return mask & (a == b); }
|
||||
__forceinline vboolf4 ne(const vboolf4& mask, const vint4& a, const vint4& b) { return mask & (a != b); }
|
||||
__forceinline vboolf4 lt(const vboolf4& mask, const vint4& a, const vint4& b) { return mask & (a < b); }
|
||||
__forceinline vboolf4 ge(const vboolf4& mask, const vint4& a, const vint4& b) { return mask & (a >= b); }
|
||||
__forceinline vboolf4 gt(const vboolf4& mask, const vint4& a, const vint4& b) { return mask & (a > b); }
|
||||
__forceinline vboolf4 le(const vboolf4& mask, const vint4& a, const vint4& b) { return mask & (a <= b); }
|
||||
#endif
|
||||
|
||||
template<int mask>
|
||||
__forceinline const vint4 select(const vint4& t, const vint4& f) {
|
||||
#if defined(__SSE4_1__)
|
||||
return _mm_castps_si128(_mm_blend_ps(_mm_castsi128_ps(f), _mm_castsi128_ps(t), mask));
|
||||
#else
|
||||
return select(vboolf4(mask), t, f);
|
||||
#endif
|
||||
#if defined(__clang__) && !defined(__INTEL_COMPILER) || defined(_MSC_VER) && !defined(__INTEL_COMPILER) || defined(__GNUC__) && !defined(__INTEL_COMPILER) // still required for clang
|
||||
__forceinline const vint4 select(const int mask, const vint4& t, const vint4& f) {
|
||||
return select(vboolf4(mask), t, f);
|
||||
}
|
||||
|
||||
#if defined(__SSE4_1__)
|
||||
__forceinline const vint4 min( const vint4& a, const vint4& b ) { return _mm_min_epi32(a.v, b.v); }
|
||||
__forceinline const vint4 max( const vint4& a, const vint4& b ) { return _mm_max_epi32(a.v, b.v); }
|
||||
|
||||
__forceinline const vint4 umin( const vint4& a, const vint4& b ) { return _mm_min_epu32(a.v, b.v); }
|
||||
__forceinline const vint4 umax( const vint4& a, const vint4& b ) { return _mm_max_epu32(a.v, b.v); }
|
||||
|
||||
#else
|
||||
__forceinline const vint4 min( const vint4& a, const vint4& b ) { return select(a < b,a,b); }
|
||||
__forceinline const vint4 max( const vint4& a, const vint4& b ) { return select(a < b,b,a); }
|
||||
__forceinline const vint4 select(const int m, const vint4& t, const vint4& f) {
|
||||
return _mm_castps_si128(_mm_blend_ps(_mm_castsi128_ps(f), _mm_castsi128_ps(t), m));
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
__forceinline const vint4 min( const vint4& a, const int& b ) { return min(a,vint4(b)); }
|
||||
__forceinline const vint4 min( const int& a, const vint4& b ) { return min(vint4(a),b); }
|
||||
__forceinline const vint4 max( const vint4& a, const int& b ) { return max(a,vint4(b)); }
|
||||
__forceinline const vint4 max( const int& a, const vint4& b ) { return max(vint4(a),b); }
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Movement/Shifting/Shuffling Functions
|
||||
@@ -405,81 +381,23 @@ namespace embree
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if defined(__SSE4_1__)
|
||||
|
||||
__forceinline vint4 usort_ascending(const vint4& v)
|
||||
__forceinline vint4 sortNetwork(const vint4& v)
|
||||
{
|
||||
const vint4 a0 = v;
|
||||
const vint4 b0 = shuffle<1,0,3,2>(a0);
|
||||
const vint4 c0 = umin(a0,b0);
|
||||
const vint4 d0 = umax(a0,b0);
|
||||
const vint4 a1 = select<0x5 /* 0b0101 */>(c0,d0);
|
||||
const vint4 a1 = select(0x5 /* 0b0101 */,c0,d0);
|
||||
const vint4 b1 = shuffle<2,3,0,1>(a1);
|
||||
const vint4 c1 = umin(a1,b1);
|
||||
const vint4 d1 = umax(a1,b1);
|
||||
const vint4 a2 = select<0x3 /* 0b0011 */>(c1,d1);
|
||||
const vint4 a2 = select(0x3 /* 0b0011 */,c1,d1);
|
||||
const vint4 b2 = shuffle<0,2,1,3>(a2);
|
||||
const vint4 c2 = umin(a2,b2);
|
||||
const vint4 d2 = umax(a2,b2);
|
||||
const vint4 a3 = select<0x2 /* 0b0010 */>(c2,d2);
|
||||
const vint4 a3 = select(0x2 /* 0b0010 */,c2,d2);
|
||||
return a3;
|
||||
}
|
||||
|
||||
__forceinline vint4 usort_descending(const vint4& v)
|
||||
{
|
||||
const vint4 a0 = v;
|
||||
const vint4 b0 = shuffle<1,0,3,2>(a0);
|
||||
const vint4 c0 = umax(a0,b0);
|
||||
const vint4 d0 = umin(a0,b0);
|
||||
const vint4 a1 = select<0x5 /* 0b0101 */>(c0,d0);
|
||||
const vint4 b1 = shuffle<2,3,0,1>(a1);
|
||||
const vint4 c1 = umax(a1,b1);
|
||||
const vint4 d1 = umin(a1,b1);
|
||||
const vint4 a2 = select<0x3 /* 0b0011 */>(c1,d1);
|
||||
const vint4 b2 = shuffle<0,2,1,3>(a2);
|
||||
const vint4 c2 = umax(a2,b2);
|
||||
const vint4 d2 = umin(a2,b2);
|
||||
const vint4 a3 = select<0x2 /* 0b0010 */>(c2,d2);
|
||||
return a3;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
__forceinline vint4 usort_ascending(const vint4& v)
|
||||
{
|
||||
const vint4 a0 = v-vint4(0x80000000);
|
||||
const vint4 b0 = shuffle<1,0,3,2>(a0);
|
||||
const vint4 c0 = min(a0,b0);
|
||||
const vint4 d0 = max(a0,b0);
|
||||
const vint4 a1 = select<0x5 /* 0b0101 */>(c0,d0);
|
||||
const vint4 b1 = shuffle<2,3,0,1>(a1);
|
||||
const vint4 c1 = min(a1,b1);
|
||||
const vint4 d1 = max(a1,b1);
|
||||
const vint4 a2 = select<0x3 /* 0b0011 */>(c1,d1);
|
||||
const vint4 b2 = shuffle<0,2,1,3>(a2);
|
||||
const vint4 c2 = min(a2,b2);
|
||||
const vint4 d2 = max(a2,b2);
|
||||
const vint4 a3 = select<0x2 /* 0b0010 */>(c2,d2);
|
||||
return a3+vint4(0x80000000);
|
||||
}
|
||||
|
||||
__forceinline vint4 usort_descending(const vint4& v)
|
||||
{
|
||||
const vint4 a0 = v-vint4(0x80000000);
|
||||
const vint4 b0 = shuffle<1,0,3,2>(a0);
|
||||
const vint4 c0 = max(a0,b0);
|
||||
const vint4 d0 = min(a0,b0);
|
||||
const vint4 a1 = select<0x5 /* 0b0101 */>(c0,d0);
|
||||
const vint4 b1 = shuffle<2,3,0,1>(a1);
|
||||
const vint4 c1 = max(a1,b1);
|
||||
const vint4 d1 = min(a1,b1);
|
||||
const vint4 a2 = select<0x3 /* 0b0011 */>(c1,d1);
|
||||
const vint4 b2 = shuffle<0,2,1,3>(a2);
|
||||
const vint4 c2 = max(a2,b2);
|
||||
const vint4 d2 = min(a2,b2);
|
||||
const vint4 a3 = select<0x2 /* 0b0010 */>(c2,d2);
|
||||
return a3+vint4(0x80000000);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
+5
-67
@@ -1,5 +1,5 @@
|
||||
// ======================================================================== //
|
||||
// Copyright 2009-2017 Intel Corporation //
|
||||
// Copyright 2009-2016 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
@@ -99,31 +99,13 @@ namespace embree
|
||||
return vint8(il,ih);
|
||||
}
|
||||
|
||||
static __forceinline vint8 load( const unsigned short* const ptr ) {
|
||||
vint4 il = vint4::load(ptr+0);
|
||||
vint4 ih = vint4::load(ptr+4);
|
||||
return vint8(il,ih);
|
||||
}
|
||||
|
||||
static __forceinline vint8 loadu( const unsigned short* const ptr ) {
|
||||
vint4 il = vint4::loadu(ptr+0);
|
||||
vint4 ih = vint4::loadu(ptr+4);
|
||||
return vint8(il,ih);
|
||||
}
|
||||
|
||||
static __forceinline void store( unsigned char* const ptr, const vint8& i ) {
|
||||
static __forceinline void store_uchar( unsigned char* const ptr, const vint8& i ) {
|
||||
vint4 il(i.vl);
|
||||
vint4 ih(i.vh);
|
||||
vint4::store(ptr + 0,il);
|
||||
vint4::store(ptr + 4,ih);
|
||||
vint4::store_uchar(ptr + 0,il);
|
||||
vint4::store_uchar(ptr + 4,ih);
|
||||
}
|
||||
|
||||
static __forceinline void store( unsigned short* const ptr, const vint8& v ) {
|
||||
for (size_t i=0;i<8;i++)
|
||||
ptr[i] = (unsigned short)v[i];
|
||||
}
|
||||
|
||||
|
||||
static __forceinline vint8 broadcast64(const long long &a) { return _mm256_set1_epi64x(a); }
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -246,20 +228,6 @@ namespace embree
|
||||
__forceinline const vboolf8 operator <=( const vint8& a, const int b ) { return a <= vint8(b); }
|
||||
__forceinline const vboolf8 operator <=( const int a, const vint8& b ) { return vint8(a) <= b; }
|
||||
|
||||
__forceinline vboolf8 eq(const vint8& a, const vint8& b) { return a == b; }
|
||||
__forceinline vboolf8 ne(const vint8& a, const vint8& b) { return a != b; }
|
||||
__forceinline vboolf8 lt(const vint8& a, const vint8& b) { return a < b; }
|
||||
__forceinline vboolf8 ge(const vint8& a, const vint8& b) { return a >= b; }
|
||||
__forceinline vboolf8 gt(const vint8& a, const vint8& b) { return a > b; }
|
||||
__forceinline vboolf8 le(const vint8& a, const vint8& b) { return a <= b; }
|
||||
|
||||
__forceinline vboolf8 eq(const vboolf8& mask, const vint8& a, const vint8& b) { return mask & (a == b); }
|
||||
__forceinline vboolf8 ne(const vboolf8& mask, const vint8& a, const vint8& b) { return mask & (a != b); }
|
||||
__forceinline vboolf8 lt(const vboolf8& mask, const vint8& a, const vint8& b) { return mask & (a < b); }
|
||||
__forceinline vboolf8 ge(const vboolf8& mask, const vint8& a, const vint8& b) { return mask & (a >= b); }
|
||||
__forceinline vboolf8 gt(const vboolf8& mask, const vint8& a, const vint8& b) { return mask & (a > b); }
|
||||
__forceinline vboolf8 le(const vboolf8& mask, const vint8& a, const vint8& b) { return mask & (a <= b); }
|
||||
|
||||
__forceinline const vint8 select( const vboolf8& m, const vint8& t, const vint8& f ) {
|
||||
return _mm256_castps_si256(_mm256_blendv_ps(_mm256_castsi256_ps(f), _mm256_castsi256_ps(t), m));
|
||||
}
|
||||
@@ -338,7 +306,7 @@ namespace embree
|
||||
/// Sorting networks
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
__forceinline vint8 usort_ascending(const vint8& v)
|
||||
__forceinline vint8 sortNetwork(const vint8& v)
|
||||
{
|
||||
const vint8 a0 = v;
|
||||
const vint8 b0 = shuffle<1,0,3,2>(a0);
|
||||
@@ -368,36 +336,6 @@ namespace embree
|
||||
return a6;
|
||||
}
|
||||
|
||||
__forceinline vint8 usort_descending(const vint8& v)
|
||||
{
|
||||
const vint8 a0 = v;
|
||||
const vint8 b0 = shuffle<1,0,3,2>(a0);
|
||||
const vint8 c0 = umax(a0,b0);
|
||||
const vint8 d0 = umin(a0,b0);
|
||||
const vint8 a1 = select(0x99 /* 0b10011001 */,c0,d0);
|
||||
const vint8 b1 = shuffle<2,3,0,1>(a1);
|
||||
const vint8 c1 = umax(a1,b1);
|
||||
const vint8 d1 = umin(a1,b1);
|
||||
const vint8 a2 = select(0xc3 /* 0b11000011 */,c1,d1);
|
||||
const vint8 b2 = shuffle<1,0,3,2>(a2);
|
||||
const vint8 c2 = umax(a2,b2);
|
||||
const vint8 d2 = umin(a2,b2);
|
||||
const vint8 a3 = select(0xa5 /* 0b10100101 */,c2,d2);
|
||||
const vint8 b3 = shuffle4<1,0>(a3);
|
||||
const vint8 c3 = umax(a3,b3);
|
||||
const vint8 d3 = umin(a3,b3);
|
||||
const vint8 a4 = select(0xf /* 0b00001111 */,c3,d3);
|
||||
const vint8 b4 = shuffle<2,3,0,1>(a4);
|
||||
const vint8 c4 = umax(a4,b4);
|
||||
const vint8 d4 = umin(a4,b4);
|
||||
const vint8 a5 = select(0x33 /* 0b00110011 */,c4,d4);
|
||||
const vint8 b5 = shuffle<1,0,3,2>(a5);
|
||||
const vint8 c5 = umax(a5,b5);
|
||||
const vint8 d5 = umin(a5,b5);
|
||||
const vint8 a6 = select(0x55 /* 0b01010101 */,c5,d5);
|
||||
return a6;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// Output Operators
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Loaded 100 of 605 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user