Compare commits

...
813 Commits
Author SHA1 Message Date
cbenthin d3d9f6225b Merge remote-tracking branch 'origin/devel' into cbenthin 2017-09-28 16:14:37 +02:00
Johannes Günther f34b975536 More robust FindTBB 2017-09-28 14:11:02 +02:00
Johannes Günther b8c30540ba Let WIX set CMake registry ==> Embree will be found without embree_DIR 2017-09-26 11:43:36 +02:00
Sven Woop 42979151c2 added missing precompiled freeglut 3.0.0 library 2017-09-26 10:25:21 +02:00
Sven Woop 6bafe12b19 replacing old freeglut with freeglut 3.0.0 2017-09-26 08:48:19 +02:00
Sven Woop 4b078bb1bc package scripts properly return errors now 2017-09-25 08:39:56 +02:00
Sven Woop 66f21608e0 improved MacOSX uninstall script, calling rm and pkgutil using global path /bin/rm and /usr/sbin/pkgutil 2017-09-25 08:25:58 +02:00
Sven Woop c41d484595 Merge branch 'release' into devel 2017-09-25 07:37:54 +02:00
cbenthin 4794b0e55f updates 2017-09-22 06:57:45 -07:00
Sven Woop c48d21814c updates 2017-09-22 15:09:48 +02:00
Sven Woop a7d313ad41 Merge branch 'release' into devel 2017-09-22 13:12:05 +02:00
Sven Woop fe52f5d6b7 setting version to v2.17.1-alpha.0 2017-09-22 13:11:57 +02:00
Sven Woop 729ece7292 update 2017-09-22 13:10:44 +02:00
Sven Woop 9722b4c30d Merge branch 'release' into devel 2017-09-22 12:21:36 +02:00
Sven Woop ed8ee37967 setting product and upgrade GUI for WiX 2017-09-22 12:02:50 +02:00
Sven Woop 7a50a2d692 WiX also installs Embree to Intel folder under Program Files 2017-09-22 11:52:19 +02:00
Sven Woop 357c6f24c5 no longer installing tbb.dll into lib folder (but only to bin folder) 2017-09-22 11:49:52 +02:00
Sven Woop 83fcf53b95 replaced NSIS by WiX to generate MSI installer for Windows 2017-09-22 11:47:13 +02:00
cbenthin 8968597c20 updates to sub-pixel pattern 2017-09-22 11:36:53 +02:00
cbenthin 95a4cbcb94 updates 2017-09-22 10:40:44 +02:00
Sven Woop 2c724c529f fixed stripping of releases under MacOSX 2017-09-22 10:11:18 +02:00
cbenthin 5da02d0800 some MSAA experiments 2017-09-22 10:04:36 +02:00
Sven Woop 11b243931c added security comment to stipping of binaries 2017-09-22 09:08:15 +02:00
Sven Woop 28e11c9857 updates to release_win.bat, removed 32 bit build 2017-09-22 08:28:13 +02:00
Sven Woop 4c9c026a1b updates to release_win.bat, enabling stack protector for all builds 2017-09-22 08:27:30 +02:00
cbenthin 1a47e44b72 sync with devel 2017-09-21 18:23:40 +02:00
cbenthin 1fb988cd6b sync with master/release 2017-09-21 13:49:25 +02:00
Sven Woop c6498a29d0 compile fix for internal task scheduler 2017-09-21 07:19:34 +02:00
cbenthin fcd747217b set -inline-factor to 150 for the intel compiler to reduce compile times, moved mb builders from bvh_builder_hair.cpp into bvh_builder_hair_mb.cpp 2017-09-20 17:02:06 +02:00
Sven Woop 6bf725ba7c fixed compile issues with ICC and internal task scheduler 2017-09-20 14:14:46 +02:00
CDash e9a402ecd1 reduced inline-factor to 150 for intel compiler on mac os to prevent internal compiler error 2017-09-20 06:26:17 -05:00
Sven Woop a7dd991418 bugfix in test.py 2017-09-20 07:34:42 +02:00
Sven Woop 2f6af2832d updated documentation 2017-09-19 16:28:30 +02:00
Sven Woop 640c6daa85 setting version to 2.17.0 2017-09-19 16:27:07 +02:00
Sven Woop 512811023f bugfix in rtcOccluded1 and rtcOccluded1Ex API functions for ISPC 2017-09-19 12:11:35 +02:00
Sven Woop c0a1dbb5d8 cleanups 2017-09-19 10:18:31 +02:00
Sven Woop 045c418031 fixed some Clang 5 compile warnings 2017-09-19 10:01:58 +02:00
Sven Woop 8956aee21c enabling stack protector for releases 2017-09-19 09:48:27 +02:00
Sven Woop 0d9bc8df72 enabled stack protector for releases 2017-09-19 09:45:43 +02:00
Sven Woop ca96c96cb3 disabled stack protector by default 2017-09-19 09:43:38 +02:00
Sven Woop 4c50caa6b1 Merge branch 'devel' of https://github.com/embree/embree into devel 2017-09-19 09:19:21 +02:00
Sven Woop 9edba0f4ea reduced stack requirement for verify IntersectWithMode function 2017-09-19 09:19:06 +02:00
Sven Woop f4626bb22e reduced stack requirement for subdiv code 2017-09-19 09:18:44 +02:00
cbenthin 7d66ef477b fixed few msvc compile warnings 2017-09-18 05:49:12 -07:00
cbenthin 1b3b7ecb38 fixed few msvc compile warnings 2017-09-18 05:39:24 -07:00
Sven Woop e082712373 enabling stack protector by default 2017-09-18 07:05:17 +02:00
Sven Woop 185ffc39d3 added more tests to gitlab-ci 2017-09-15 14:47:28 +02:00
Sven Woop 3f4c6ac6e3 verbose=0 for tests 2017-09-15 14:20:21 +02:00
Sven Woop 5e3b4cf0e2 updates to CI 2017-09-15 14:11:40 +02:00
Sven Woop dec21a5f65 updates to CI 2017-09-15 14:08:14 +02:00
Sven Woop 2b0c400355 updates to CI 2017-09-15 14:06:52 +02:00
Sven Woop 058e820efb updates 2017-09-15 14:04:55 +02:00
Sven Woop d633a5541d updates to test.cmake 2017-09-15 13:59:16 +02:00
Sven Woop 563fa8b32c updates to test.cmake 2017-09-15 13:51:44 +02:00
Sven Woop 0894d751f1 updates to test.cmake 2017-09-15 13:50:45 +02:00
Sven Woop 23e8a0389d updates to test.cmake 2017-09-15 13:44:51 +02:00
Sven Woop 54f29c991b updates to test.cmake 2017-09-15 13:42:12 +02:00
Sven Woop fd3af84024 updates 2017-09-15 13:34:06 +02:00
Sven Woop a9a868f252 updates to test.cmake 2017-09-15 13:24:09 +02:00
Sven Woop 870e7adc71 updates to test.cmake 2017-09-15 13:19:25 +02:00
Sven Woop bec88b6568 Merge branch 'devel' of gitlab.com:embree/embree into devel 2017-09-15 13:13:16 +02:00
Sven Woop 85a6d9c54c updates to test.py 2017-09-15 13:11:35 +02:00
Sven Woop 63919c188c updates 2017-09-15 12:40:05 +02:00
Sven Woop 76892f8577 updates to test.py script 2017-09-15 12:38:12 +02:00
Sven Woop 44e783d59d updates to test.py 2017-09-15 12:31:08 +02:00
Sven Woop 0a642420af updates to test script 2017-09-15 12:25:20 +02:00
Sven Woop d208cbb4d9 added embree test scripts 2017-09-15 11:15:39 +02:00
Sven Woop 0419f1d8cc bugfix in FindTBB.cmake 2017-09-15 09:56:31 +02:00
Sven Woop c2309bbf79 updates to CI 2017-09-15 09:48:31 +02:00
Sven Woop e9149e8e9a added .gitlab-ci.yml with experimental settings 2017-09-15 09:30:26 +02:00
Sven Woop c15bb92593 Added support for BVH8 when AVX target was not enabled but targets higher than AVX.
Previously we did not use BVH8 in this case. This makes it e.g. possible to build
Embree properly for AVX2 only.
2017-09-15 08:51:35 +02:00
Sven Woop a1b56e8adc never enabling stack protector for traversal kernels 2017-09-14 13:38:38 +02:00
Sven Woop d85aea4c1a cleanups in frustum.h 2017-09-14 11:50:19 +02:00
Sven Woop 4498acd035 setting max internal stream size to 32 for 32 bit platforms 2017-09-14 11:43:56 +02:00
Sven Woop 152073d7ac cleanups 2017-09-14 11:42:43 +02:00
Sven Woop a90002157c cleanups in bvh_intersector_stream.h 2017-09-14 11:37:15 +02:00
Sven Woop f8c8d55c44 specializing frustum for robust and fast mode 2017-09-14 11:34:56 +02:00
Sven Woop 97600fb260 cleanups 2017-09-14 11:28:54 +02:00
Sven Woop b6d6cba2a2 specializing Packet for robust and non-robust mode 2017-09-14 11:23:27 +02:00
Sven Woop ead4835d35 cleanups in Packet class 2017-09-14 11:17:30 +02:00
Sven Woop eb4906c79c adding Packet constructor 2017-09-14 11:13:55 +02:00
Sven Woop 85b65574bb NearFarPreCompute no longer templated 2017-09-14 10:55:21 +02:00
Sven Woop 363c005f8e moved more code into packet struct 2017-09-14 10:42:48 +02:00
Sven Woop 4422ca608c re-using packet box test 2017-09-14 10:05:56 +02:00
Sven Woop d38ac50b2b moving packet intersection code to packet struct 2017-09-14 09:51:53 +02:00
Sven Woop 4d05b49867 moving Packet struct 2017-09-14 09:41:20 +02:00
Sven Woop a22e54cc49 cleanups 2017-09-14 09:36:44 +02:00
Sven Woop 46d131e056 re-using frustum intersection in stream frustum kernel 2017-09-14 09:36:06 +02:00
Sven Woop f1d23c57ed updates to frustum intersection interface 2017-09-14 09:30:53 +02:00
Sven Woop 265044e73f using new frustum struct in frustum stream traverser 2017-09-14 09:25:44 +02:00
Sven Woop ca84d3425e modifying frustum interface 2017-09-14 09:08:35 +02:00
Sven Woop 418ec0bdfb unifying frustm intersection interface 2017-09-14 08:52:45 +02:00
Sven Woop 2d1f8a6a97 updates to bvh_intersector_stream.h 2017-09-14 08:45:24 +02:00
Sven Woop 9813d6a6ee re-using NearFarPreCompute struct 2017-09-14 08:40:44 +02:00
Sven Woop 255ab75c5f first step to separate frustum structure 2017-09-14 08:26:45 +02:00
Sven Woop ece6b8345c removed unused file 2017-09-14 08:09:15 +02:00
Sven Woop 59ec5d0fcd Merge branch 'devel' of https://github.com/embree/embree into devel 2017-09-14 08:08:34 +02:00
Sven Woop 2cd05a8b2b Removing KNL optimization of frustum code for ray packet mode.
This caused a 5% slowdown, but frustum path is still significantly
faster (38%) than hybrid kernel. This change will make it easier
having a single frustum infrastructure for all frustum kernels.
2017-09-14 08:06:15 +02:00
cbenthin 08e54eb4c1 cleanups 2017-09-13 13:57:01 +02:00
cbenthin fb13a85505 cleanups 2017-09-13 13:45:46 +02:00
Sven Woop fb81cb34de removed no longer required packet fallback from bvh_intersector_stream.cpp 2017-09-13 12:27:02 +02:00
Sven Woop 3ceca55050 enabling stream kernels also for SSE, this codepath was already implemented but not selected 2017-09-13 12:20:48 +02:00
Sven Woop 87d45e6096 Merge branch 'devel' of https://github.com/embree/embree into devel 2017-09-13 12:07:29 +02:00
Sven Woop 872ced9934 printing camera before rendering 2017-09-13 12:07:16 +02:00
cbenthin f987d717ef removed validIsec checks in stream filters 2017-09-13 12:01:59 +02:00
cbenthin 9b40fcb862 Merge branch 'devel' of https://github.com/embree/embree into devel 2017-09-13 11:56:58 +02:00
cbenthin 19605e0738 added fallback to packet intersectorNs to isa namespaces, removed fallback in accel.h 2017-09-13 11:56:52 +02:00
Sven Woop fe56a4dc3c renames in bvh_intersector_hybrid.h 2017-09-13 11:55:53 +02:00
Sven Woop 4994f64729 implemented robust stream traversal 2017-09-13 11:29:08 +02:00
Sven Woop 7b4af861f4 adding first robust code to bvh_intersector_stream.h 2017-09-13 11:10:20 +02:00
Sven Woop 82ef698bcf Passing Accel::Intersectors* instead of BVH* to all intersector routines.
This way all intersectors can properly fallback to other interectors.

Moved intersect helper functions from Accel to Accel::Intersectors struct.

Fixed issue in stream kernels, that did fallback to packet traversal
using scene->intersect. This is wrong as causes iteration over all BVH
types again.
2017-09-13 08:59:00 +02:00
cbenthin ca70fc388b re-added accels.validIsecN test in stream filters otherwise verify crashes 2017-09-12 21:04:08 +02:00
Sven Woop ae06ac06a9 Merge branch 'devel' of https://github.com/embree/embree into devel 2017-09-12 16:12:17 +02:00
Sven Woop e2656563b1 cleanups in stream filters, not isRobust and validISecN tests are not required 2017-09-12 16:12:04 +02:00
cbenthin 752e905ecc increased benchmark iterations for more consistent results 2017-09-12 15:17:45 +02:00
Sven Woop d9e046d0c3 cleanups 2017-09-12 12:58:17 +02:00
Sven Woop 5945b87db9 cleanups in bvh_intersector_stream.cpp 2017-09-12 12:26:40 +02:00
Sven Woop 0c92fff315 Removed MAX_RAYS_PER_OCTANT (we have no octant sorting anymore). Only using MAX_INTERNAL_STREAM_SIZE. 2017-09-12 12:24:50 +02:00
Sven Woop 360ad9d0c3 fixed interface of intersectN/occludedN functions to RayK<VSIZEX> 2017-09-12 12:03:52 +02:00
Sven Woop 6c34e0d090 variable renames in frustum traverser 2017-09-12 11:39:34 +02:00
Sven Woop 794d90069c variable renames in frustum traverser 2017-09-12 11:27:09 +02:00
Sven Woop fb8e4405c7 cleanups in frustum packet traverser, added docu to frustum packet traverser 2017-09-12 11:23:20 +02:00
Sven Woop 36d53847c7 cleanups 2017-09-12 09:45:06 +02:00
Sven Woop e45aabfb8a added docu to maxDepth BVH member 2017-09-12 09:12:14 +02:00
Sven Woop d66fbeb235 making occlusion rays always incoherent in pathtracer 2017-09-12 08:50:21 +02:00
Sven Woop af13b7704f adding coherent/incoherent tests for viewer and pathtracer 2017-09-12 08:38:29 +02:00
Sven Woop 649d39f3a8 coherent/incoherent mode can be set from command line for viewer 2017-09-12 08:30:27 +02:00
Sven Woop 9b3362a394 fixed warning 2017-09-12 08:15:40 +02:00
Sven Woop fdb80242af returning in feature_adaptive_eval for out of bounds subpatch ID 2017-09-12 08:14:24 +02:00
Sven Woop fa7d1b4f89 bugfix of potential out of range access in stringstream.h 2017-09-12 08:00:18 +02:00
cbenthin f6cdaeb732 added AVX512VL sorting code to both 4 and 8-wide code paths 2017-09-11 18:27:06 +02:00
cbenthin a9d59ed6c8 Merge remote-tracking branch 'origin/devel' into cbenthin 2017-09-11 17:21:34 +02:00
cbenthin 5633e5233d deactivating all prefetches for large nodes on Xeon but still keep L2 prefetches for KNL 2017-09-11 16:33:21 +02:00
cbenthin 2b681c5f27 removed implicit int->uint conversion in sorting code 2017-09-09 08:01:30 -05:00
cbenthin 8a8f7c78aa sync 2017-09-08 16:54:27 +02:00
Sven Woop 159e440014 updates klocwork server 2017-09-08 07:24:07 +02:00
atafra 04d8b88026 added transpose optimization for SKX 2017-09-07 18:03:21 +03:00
atafra 1f8e43141c removed unused node intersection code 2017-09-07 14:05:24 +03:00
Sven Woop 07c35e2ed2 change 2017-09-07 07:46:12 +02:00
Sven Woop a44f900b20 replaced unsigned -> unsigned int for ISPC 2017-09-07 07:12:28 +02:00
atafra 141aa737c6 minor cleanup 2017-09-07 01:41:55 +03:00
atafra f154b5f160 improved very slow fallback path in filterSOA so it's not slow anymore 2017-09-07 01:39:43 +03:00
atafra 7f82ff96ce fixes and cleanups in RayPacketSOA, RayStreamAOS, and RayStreamAOP 2017-09-07 01:26:26 +03:00
atafra 1112474494 filter cleanups 2017-09-06 13:23:57 +03:00
atafra b486e32e7c implemented coherent code path for filterAOS and filterAOP 2017-09-06 12:42:32 +03:00
cbenthin 8375fa6ddc invalidates occlusion rays inside packet/stream if geomID has already been set to 0 2017-09-05 19:13:14 +02:00
cbenthin 1c618498f1 more fixes in acceln 2017-09-05 18:51:38 +02:00
cbenthin 412f96bd78 fixes 2017-09-05 18:31:15 +02:00
cbenthin d29f6463fc rewrote early out for occlusion calls in acceln 2017-09-05 18:12:12 +02:00
cbenthin 83cf25ff11 Merge branch 'devel' of https://github.com/embree/embree into devel 2017-09-05 18:06:32 +02:00
cbenthin 7502c34550 rewrote early out for occlusion calls in acceln 2017-09-05 18:06:28 +02:00
atafra e70e719de9 fixed the coherent path of filterSOP for streams having a size that is not a multiple of VSIZEX 2017-09-05 18:50:30 +03:00
atafra da88c40c5a Merge remote-tracking branch 'origin/devel' into devel 2017-09-05 18:39:07 +03:00
atafra 97d9c48aea filterSOA cleanups 2017-09-05 18:38:45 +03:00
cbenthin ff0adca3d2 Merge branch 'devel' of https://github.com/embree/embree into devel 2017-09-05 16:38:19 +02:00
cbenthin 386aca9c02 cleanups 2017-09-05 16:38:13 +02:00
atafra 9f19cc077b removed AOS support from the stream kernels because filters always convert to SOA 2017-09-05 17:37:20 +03:00
atafra 9631f41e77 Merge remote-tracking branch 'origin/devel' into devel 2017-09-05 17:16:04 +03:00
atafra 9f034802bb filterSOP cleanup 2017-09-05 17:14:58 +03:00
cbenthin 437e87a931 bugfix in occluded coherent stream kernel when we have inactive rays, verify failed in this case 2017-09-05 15:07:29 +02:00
cbenthin 081a301f20 removed Ray** stuff no longer necessary 2017-09-05 13:18:15 +02:00
cbenthin 71495578a4 Merge branch 'devel' of https://github.com/embree/embree into devel 2017-09-05 13:06:32 +02:00
cbenthin d2960b7b5c removed check for common octant and all rays active in filterSOACoherent as the stream kernel does this too and eventually falls back to packets 2017-09-05 13:06:13 +02:00
atafra 78a9ad27c3 added global "undefined" constant (UndefinedTy), replaced the static undefined() functions of the vector classes with constructors 2017-09-05 12:49:29 +03:00
atafra ecda1d8a44 Merge remote-tracking branch 'origin/devel' into devel 2017-09-05 12:39:19 +03:00
atafra 9da3d17093 removed unnecessary static constant functions (e.g. vfloat16::zero()) from some vector classes 2017-09-05 12:37:37 +03:00
cbenthin 8d0a5962a9 Merge branch 'devel' of https://github.com/embree/embree into devel 2017-09-05 11:04:59 +02:00
cbenthin e9a41e05e1 replaced RTCRay** in intersectN/occludedN by void**, removed unused childID tracking in stream kernels, few minor fixes 2017-09-05 11:04:56 +02:00
Sven Woop 24e7f7e369 Merge branch 'devel' of https://github.com/embree/embree into devel 2017-09-05 11:03:35 +02:00
Sven Woop 28737d9ee9 added more assertions to verify 2017-09-05 11:01:23 +02:00
atafra 6dafd1d4d3 cleanups 2017-09-05 11:51:28 +03:00
Sven Woop 6353759cce exception handling in case of task and closure stack overflow in internal task scheduler 2017-09-05 10:10:22 +02:00
Sven Woop fb0def1684 added assertions to StackArray in array.h 2017-09-05 10:02:36 +02:00
Sven Woop caea79c997 Bugfix in getExecutableFileName. We did not null terminate the returned string when the filename was too large. 2017-09-05 09:55:35 +02:00
Sven Woop c775d0de2e fixed potential out of bounds read/write in extract/insert functions in vuint4_sse2.h 2017-09-05 09:33:54 +02:00
Sven Woop 843d6dd4c8 better array size in foreach2 2017-09-05 09:32:30 +02:00
Sven Woop c935e0da39 fixed potential out of bounds read in vint4_sse2.h 2017-09-05 09:21:28 +02:00
Sven Woop d87d7df513 fixed potential out of bounds access in insert function in vfloat4_sse2.h 2017-09-05 09:17:03 +02:00
Sven Woop 77dc26ef4f fixed wrong assertion 2017-09-05 09:13:26 +02:00
cbenthin 8963303344 fixed avx512 icc compile bug 2017-09-05 09:12:19 +02:00
Sven Woop 746cadf4e4 fixed potential out of bounds read in stringstream.h 2017-09-05 09:11:13 +02:00
Sven Woop 417eb0d7b8 updates 2017-09-05 09:07:30 +02:00
Sven Woop 5d19c5bb68 fixed potential out of bounds read in tokenstream.h 2017-09-05 09:02:30 +02:00
Sven Woop b479fb5d9f bugfix in parallel_filter.h 2017-09-05 08:44:15 +02:00
Sven Woop 6901238ba7 updates 2017-09-05 07:26:55 +02:00
Sven Woop 0e296bba08 updates 2017-09-05 07:00:14 +02:00
atafra 01adb67d9f Merge remote-tracking branch 'origin/devel' into devel 2017-09-04 22:49:52 +03:00
atafra 305a169b01 gathers return zero where the mask is zero, to be consistent with the masked loads (but the compiler zeroed the result before gathering anyway) 2017-09-04 22:49:04 +03:00
cbenthin 6c598c3c35 Merge branch 'devel' of https://github.com/embree/embree into devel 2017-09-04 18:42:22 +02:00
cbenthin 24b98e170e cleanups in defining/declaring stream intersectors 2017-09-04 18:42:14 +02:00
atafra b2bd8f62b2 Merge remote-tracking branch 'origin/devel' into devel 2017-09-04 18:23:03 +03:00
atafra 1d143a08dd added RayK::octant() helper function 2017-09-04 18:22:31 +03:00
cbenthin 23908e9c71 cleanups 2017-09-04 17:11:59 +02:00
cbenthin 9fc5e527e9 Merge branch 'devel' of https://github.com/embree/embree into devel 2017-09-04 15:22:31 +02:00
cbenthin 5f13249d40 minor updates to make valgrind happy 2017-09-04 15:22:18 +02:00
Sven Woop 1a745a5d1d updates 2017-09-04 13:40:31 +02:00
Sven Woop 6cbc00fb19 updates 2017-09-04 13:37:32 +02:00
cbenthin ee3387e59d removed unused stream AOS traversal code 2017-09-02 20:37:21 +02:00
cbenthin fb7f022fc3 Merge remote-tracking branch 'origin/master' into devel 2017-09-02 20:29:57 +02:00
cbenthin fbeaa1002f bugfix in coherent stream traversal code: full stream-box culling before entering BVH leaves avoids ray order-dependent behaviour 2017-09-02 20:28:51 +02:00
atafra 9328d403ee cleanup 2017-09-02 15:05:46 +03:00
atafra 3e927e6874 stream filter cleanups 2017-09-02 15:04:47 +03:00
atafra 15a5d109c7 cleanup 2017-09-02 14:32:40 +03:00
atafra 96f8c8f414 added transpose optimization to RayStreamAOP 2017-09-02 13:37:08 +03:00
atafra 6e888ebdbf added RayStreamAOP, fixed name of RayPacketSOA 2017-09-02 12:31:56 +03:00
atafra ba945af43a RayStream class renamed to RayStreamFilter 2017-09-01 19:59:15 +03:00
atafra c62e54d720 ray helper cleanups 2017-09-01 19:50:31 +03:00
atafra d9763d57bf ray helper updates 2017-09-01 18:57:17 +03:00
atafra 299b53370d Merge remote-tracking branch 'origin/devel' into devel 2017-09-01 16:38:50 +03:00
atafra 61a0b1f35f fixed RayStream::filterAOP 2017-09-01 16:37:52 +03:00
cbenthin a8604e6a68 Merge branch 'devel' of https://github.com/embree/embree into devel 2017-09-01 15:26:18 +02:00
cbenthin 5f1bc27167 removed most intersector1M functionality 2017-09-01 15:26:14 +02:00
atafra 620d45feb4 Merge remote-tracking branch 'origin/devel' into devel 2017-09-01 14:42:09 +03:00
atafra cb81b83199 minor optimization in RayStreamAOS 2017-09-01 14:40:11 +03:00
cbenthin 14813caba9 back conversion from packet to single etc now only updates geomID and others when geomID is not invalid, made this consistent in ray.h helpers 2017-09-01 13:34:40 +02:00
cbenthin 7bbd847b33 need to check for data alignment in filterSOA otherwise we can't directly use the input data as ray packets 2017-09-01 11:32:11 +02:00
cbenthin 32aa21e991 need to check for data alignment in filterSOA otherwise we can't directly use the input data as ray packets 2017-09-01 11:31:46 +02:00
cbenthin dea80f4954 replaced aligned loads by unaligned load in transpose code 2017-09-01 11:14:23 +02:00
cbenthin e1415c4474 added fallback for filterSOA when input packet size does not match VSIZEX 2017-09-01 11:13:29 +02:00
atafra fbbb077fb7 update 2017-09-01 03:09:32 +03:00
atafra 7d604fc519 moved ray AOS to SOA conversion into RayStreamAOS helper class 2017-09-01 03:02:59 +03:00
atafra e23b856425 Merge remote-tracking branch 'origin/devel' into devel 2017-09-01 01:18:35 +03:00
atafra 16872d6323 added packet fallback to RayStream::filterSOA, cleanups 2017-09-01 01:12:44 +03:00
cbenthin 1b82440464 minor fix 2017-08-31 21:13:16 +02:00
cbenthin 5ac4f24a6c removed now unused stream code 2017-08-31 20:49:10 +02:00
cbenthin 2d87a836dd replaced incoherent stream kernels with fallback to packets 2017-08-31 20:35:54 +02:00
atafra eea2e26f27 started cleaning up the stream helper classes 2017-08-31 19:04:02 +03:00
atafra 34a5076448 cleanup 2017-08-31 16:46:44 +03:00
atafra 8dcb052322 cleanup 2017-08-31 16:45:44 +03:00
atafra d3b5b12a5a cleanups 2017-08-31 13:14:55 +03:00
cbenthin c44b69807d Merge remote-tracking branch 'origin/master' into devel 2017-08-31 11:25:01 +02:00
cbenthin 5248d162d7 bugfix in coherent stream traversal code, making the traversal order independent with respect to the ordering of rays within the stream 2017-08-31 11:23:01 +02:00
atafra d3db45d710 cleanups 2017-08-31 02:57:57 +03:00
atafra 70a24218cf cleanups 2017-08-31 02:50:13 +03:00
atafra b2bc8807b5 SIMD wrapper cleanups 2017-08-31 02:46:41 +03:00
atafra db90caa563 SIMD wrapper cleanups 2017-08-31 01:58:58 +03:00
cbenthin 4837531a00 Merge branch 'devel' of https://github.com/embree/embree into devel 2017-08-30 19:07:27 +02:00
cbenthin 4586f0bbb4 minor fixes 2017-08-30 19:07:15 +02:00
atafra 6db9a37056 cleanup 2017-08-30 16:18:39 +03:00
atafra 360ece9e98 Merge remote-tracking branch 'origin/devel' into devel 2017-08-30 16:06:48 +03:00
atafra a6dea3e220 added packet fallback to RayStream::filterAOP 2017-08-30 16:05:07 +03:00
atafra 10e494b220 fixed filtering of invalid rays in RayStream::filterAOS 2017-08-30 13:46:18 +03:00
CDash b57c862896 Merge branch 'devel' of https://github.com/embree/embree into devel 2017-08-30 05:44:06 -05:00
CDash 2fb5038a4e more fixes for clang 2017-08-30 05:43:59 -05:00
CDash 7cc0ed4dcb more fixes for old clang/macos combo 2017-08-30 05:33:04 -05:00
atafra 12e0435035 cleanup 2017-08-30 13:27:13 +03:00
atafra e5ccab49c2 cleanup 2017-08-30 13:24:43 +03:00
atafra c954c616a8 Merge remote-tracking branch 'origin/devel' into devel
Conflicts:
	common/simd/vfloat4_sse2.h
	common/simd/vint4_sse2.h
	common/simd/vuint4_sse2.h
2017-08-30 13:22:54 +03:00
atafra fd9674c6c0 fixed some SIMD gather functions 2017-08-30 13:18:20 +03:00
Carsten Benthin 71a828ebfd replaced undefined implementation for vint4/vuint4 to make older clang compilers happy 2017-08-30 10:44:51 +02:00
cbenthin 8ac982ad08 fixed compile errors with clang 4.0.0 2017-08-30 09:33:12 +02:00
atafra bf5af56f19 SIMD wrapper fixes 2017-08-30 01:50:52 +03:00
atafra 9a4aedeecb SIMD wrapper fixes, cleanups 2017-08-30 01:34:20 +03:00
atafra 26df12ba62 cleanups 2017-08-29 23:42:43 +03:00
atafra 20221e0fcd cleanups 2017-08-29 23:40:03 +03:00
atafra 17f16c7f13 fixed Vec3ba assignment operators 2017-08-29 23:39:36 +03:00
atafra c5c2493a80 cleanups 2017-08-29 23:33:31 +03:00
atafra 3e2a13182b fixed vbool assignment operators 2017-08-29 23:28:50 +03:00
atafra 34568ddfec SIMD wrapper cleanups 2017-08-29 23:24:00 +03:00
atafra 60838a7555 added comment 2017-08-29 21:45:00 +03:00
atafra d07c1c4e57 Merge remote-tracking branch 'origin/atafra3' into devel 2017-08-29 21:41:41 +03:00
atafra 601da2a282 cleanups 2017-08-29 21:41:16 +03:00
atafra 188388ce2f fix 2017-08-29 21:30:35 +03:00
atafra 6615050cf2 switched to gather/scatter in RayStream::filterAOS 2017-08-29 21:25:37 +03:00
atafra ef5aeb5065 added KNL code path for RayStream::filterAOS 2017-08-29 17:39:13 +03:00
atafra 9fcfb997e5 added 4x4 and 8x8 transpose funcs for vfloat16 2017-08-29 17:38:45 +03:00
atafra 06f7784f31 SIMD improvements and cleanups 2017-08-29 17:12:32 +03:00
atafra 7b4979c100 fixed incorrect and inconsistent shuffles in vdouble and vllong 2017-08-29 17:05:20 +03:00
atafra 90b83aea4b stream filter update 2017-08-29 12:38:26 +03:00
cbenthin 2e0a5011e7 removed some warnings when compiled with -Wpedantic 2017-08-28 13:58:50 +02:00
cbenthin 897c893d50 fixed when stat counters are on 2017-08-24 10:23:49 +02:00
atafra 821c0d4d7c cleanup 2017-08-24 01:42:04 +03:00
atafra 2929c4d4a9 cleanup 2017-08-24 01:32:55 +03:00
atafra 199cbdba2f started implementing faster AOS<->SOA conversion in RayStream::filterAOS 2017-08-24 01:29:25 +03:00
atafra da71a4116a added transpose function 2017-08-24 01:26:13 +03:00
atafra 2a0ae0225a removed some experimental stream kernel code 2017-08-23 17:14:17 +03:00
cbenthin 7a68a3dab5 added fast coherent paths for occluded packet queries 2017-08-23 16:09:49 +02:00
atafra dc191dabcf added maskless gathers/scatters 2017-08-23 16:53:42 +03:00
atafra ccc00a7cc0 stream experiments 2017-08-23 13:58:20 +03:00
atafra 2908742a66 gatter/scatter cleanups 2017-08-22 18:20:16 +03:00
cbenthin 1693f87a5d AVX512 opts 2017-08-22 17:16:58 +02:00
cbenthin 4ec31fc480 added preliminrary avx512 code path 2017-08-22 15:21:42 +02:00
cbenthin 1801d8e60c new packet/frustum code works in robust mode 2017-08-22 11:03:47 +02:00
cbenthin 552ea1f55c cleanups 2017-08-21 19:58:44 +02:00
atafra d228ba1027 added stream to packet fallback (with and without octant sorting) 2017-08-21 17:38:20 +03:00
cbenthin 42490d8395 updates 2017-08-21 15:55:31 +02:00
cbenthin 27aaf7ce61 updates 2017-08-18 17:54:34 +02:00
cbenthin e2027ab2a1 added fast path for coherent packets 2017-08-17 19:53:54 +02:00
atafra 8ec7a998c9 Merge remote-tracking branch 'origin/devel' into atafra3 2017-08-16 13:32:23 +03:00
cbenthin 5cfaf6b9a9 sync 2017-08-16 10:33:10 +02:00
cbenthin 27319c93db Merge remote-tracking branch 'origin/release' into devel 2017-08-16 10:27:51 +02:00
cbenthin 6821947508 changelog updates 2017-08-14 16:04:10 +02:00
atafra 51c709a7da Merge remote-tracking branch 'origin/devel' into atafra3 2017-08-11 15:38:40 +03:00
Sven Woop efc316bee9 Merge branch 'devel' of https://github.com/embree/embree into devel 2017-08-11 13:22:15 +02:00
Sven Woop 5caee9ba5e not building single .a file for embree anymore, this is not working properly 2017-08-11 13:22:04 +02:00
cbenthin 5c10d17b89 sync with release 2017-08-11 11:34:05 +02:00
cbenthin 995e7883a9 fixed potential memory leak in ISPC scene setup 2017-08-11 11:28:36 +02:00
cbenthin 467f13fd50 fixed potential memory leak in ISPC scene setup 2017-08-11 11:21:34 +02:00
Sven Woop 0e9eb89dd8 experimental object order change 2017-08-11 09:44:25 +02:00
Sven Woop cb3923da42 simplified kernels/CMakeLists.txt and fixed some compile issues for specific ISA configurations 2017-08-11 09:26:39 +02:00
Sven Woop 470b9c2f5f updates 2017-08-11 07:43:28 +02:00
Sven Woop 0981bc1c34 added support to build tbb from sources as static and dynamic library 2017-08-10 13:06:10 +02:00
Sven Woop ca9e9989d0 fixing build for a single ISA, got broken when introducing OBJECT libraries to support compiling Embree into single static library 2017-08-10 12:12:38 +02:00
Sven Woop e3a283905d updates 2017-08-10 08:49:59 +02:00
Sven Woop cc29db2665 moving some projects to proper folder in solution file 2017-08-10 08:47:46 +02:00
Sven Woop 3a15addfb0 bugfix in CheckGlobals function under Windows and MacOSX 2017-08-10 08:43:34 +02:00
Sven Woop b6b2dc3bd5 fixed windows link error 2017-08-10 08:30:53 +02:00
Sven Woop 6cf6fc14d2 windows compile fix when using TBB in Debug mode 2017-08-10 08:25:27 +02:00
Sven Woop f5f43863e2 Merge branch 'devel' of https://github.com/embree/embree into devel 2017-08-09 13:10:33 +02:00
Sven Woop 14b39eb106 creating single .a file when linking Embree statically 2017-08-09 13:10:20 +02:00
Sven Woop ae957a4a3d updates 2017-08-09 10:30:49 +02:00
Sven Woop 4e66c586f0 updates 2017-08-09 10:07:56 +02:00
Sven Woop a257e6df95 updates 2017-08-09 09:42:13 +02:00
Sven Woop 5adea052a3 updates 2017-08-09 09:30:36 +02:00
Sven Woop 2647217c70 update 2017-08-09 09:16:02 +02:00
Sven Woop f01d534202 update 2017-08-09 08:58:22 +02:00
Sven Woop 389c9267d3 compile fix 2017-08-09 08:52:10 +02:00
Sven Woop 733a1f8db6 bugfix in smooth shading normal calculation, it may happen that the interpolated normal gets zero 2017-08-09 08:44:13 +02:00
Sven Woop 661336d18b bugfix in animated shading normal interpolation 2017-08-09 08:43:55 +02:00
Sven Woop 5758aa3986 added animated shading normal support to pathtracer 2017-08-09 08:43:35 +02:00
Sven Woop 6b900ed9a7 added support for shading normals for quads 2017-08-09 08:35:38 +02:00
Sven Woop 4cf545b763 added support for vertex normals to path tracer 2017-08-09 08:35:31 +02:00
Sven Woop 339eb9fb98 disabling stack protector by default 2017-08-09 08:09:46 +02:00
Sven Woop 156ac538cb Merge branch 'release' into devel 2017-08-08 13:55:25 +02:00
Sven Woop 66c5b693ae Merge branch 'release' of https://github.com/embree/embree into release 2017-08-08 13:53:30 +02:00
Sven Woop cf3826df6c verifyHit for ray packets makes problems in rtcore.cpp 2017-08-08 13:53:14 +02:00
Sven Woop 46c9952cd5 fixed crash in error handling code when null scene was passed to API 2017-08-08 13:49:08 +02:00
Sven Woop dc21219be0 updated docu 2017-08-08 11:18:12 +02:00
Sven Woop 4ae61b1e95 compile fix for win32 2017-08-08 11:12:31 +02:00
Sven Woop facb73b64c fixed bug in curve geometry intersector caused by bezier curves with p0==p1 and/or p2==p3 2017-08-08 11:11:41 +02:00
Sven Woop abdedb8680 curve intersector filters out NaNs caused in special cases such as ray oriented along a cylinder 2017-08-08 11:10:11 +02:00
Sven Woop 6c49e40df6 bugfix in cylinder intersection, masking error caused cracks in curve geometry 2017-08-08 11:08:19 +02:00
Sven Woop 3a266e9ea5 enabling SSE2 in release_linux.sh script 2017-08-08 11:07:03 +02:00
Sven Woop f545575d1b setting version to v2.16.5 2017-08-08 11:06:29 +02:00
Sven Woop dcb846ee00 fixed bug that caused instances to fail when a small than native packet size was used 2017-08-08 11:02:13 +02:00
Sven Woop fc2f36fe52 fixing NaNs in robust triangle intersector 2017-08-08 10:36:57 +02:00
Sven Woop b5cff0b840 fixing NaNs in robust triangle intersector 2017-08-08 10:36:31 +02:00
Sven Woop edd38d1e05 added verify of hit in debug mode 2017-08-08 10:20:47 +02:00
Sven Woop 5538ff3720 bugfix 2017-08-08 09:47:41 +02:00
Sven Woop 68e27509c1 bugfix 2017-08-08 09:47:18 +02:00
Sven Woop 799aebcb34 fixing signature of error reporting functions in isa.h 2017-08-08 09:25:42 +02:00
Sven Woop 38f3286b92 fixing signature of error reporting functions in isa.h 2017-08-08 09:24:52 +02:00
Sven Woop e692393935 Merge branch 'chuckatkins-fix-relative-paths-in-cmake-config' into devel 2017-08-07 09:15:25 +02:00
Sven Woop 169c80df85 Merge branch 'fix-relative-paths-in-cmake-config' of https://github.com/chuckatkins/embree into chuckatkins-fix-relative-paths-in-cmake-config 2017-08-07 09:14:39 +02:00
Sven Woop e3c7ba0f9f Merge branch 'chuckatkins-add-missing-cray-isa-flags' into devel 2017-08-07 09:10:58 +02:00
Sven Woop 1f295a492b merge 2017-08-07 09:10:19 +02:00
Chuck Atkins eebad657b8 Remove relative paths in cmake package-config
Using relative paths in the cmake config can result in broken
dependencies in downstream packaging when embree is a private
dependency.  This converts the relative paths generated in
embree-config.cmake from /foo/bar/baz/../../libFoo.so to /foo/libFoo.so
2017-08-01 17:10:40 -04:00
Chuck Atkins 9cc5f09fd6 Add ISA targeting flags for SSE42 and AVX512SKX to use with the CrayPE 2017-08-01 17:08:15 -04:00
Johannes Günther 365174a376 Fix lib names for embree-config
On Linux and Mac OS X the lib names to be linked against should contain
the API version (SOVERSION).
2017-07-26 15:25:40 +02:00
Jefferson Amstutz c27655b52e fix for craype config skipping SSE4.2 code generation 2017-07-26 15:25:40 +02:00
atafra 04ed0b9a7f fixed crash in hybrid intersector when a leaf is intersected with only invalid rays 2017-07-24 20:25:15 +03:00
Johannes Günther def9ffdf5d Don't build RPMs for Appliance (we have external scripts for that) 2017-07-19 12:30:32 +02:00
atafra 4f5814142e fixed crash in hybrid intersector when a leaf is intersected with only invalid rays 2017-07-17 02:21:11 +03:00
Johannes Günther e9f29bb2fe RPM tweaks 2017-07-11 17:27:48 +02:00
Sven Woop b15603013c added support to enable cycles shader from command line 2017-07-07 11:10:43 +02:00
Sven Woop abf06ab28f experimentally disabling stack protector for ICC under Windows 2017-07-07 09:41:46 +02:00
Sven Woop d75751c610 Merge branch 'devel' of https://github.com/embree/embree into devel 2017-07-07 09:11:39 +02:00
Sven Woop 168bef78d7 bugfix in cylinder intersection, masking error caused cracks in curve geometry 2017-07-07 09:11:18 +02:00
Sven Woop d748b4ab21 compile fix for MacOSX 2017-07-06 12:49:39 +02:00
Sven Woop 9bdc237098 disabling -fPIE for Mac 2017-07-06 12:35:04 +02:00
Sven Woop 36ae76cd43 documented all compile options, adding secure compile options 2017-07-06 09:48:33 +02:00
Sven Woop 6835cc16bf added --spp and --accumulate command line options to pathtracer tutorial 2017-07-05 07:19:54 +02:00
Sven Woop a0df9f4677 compile fix for win32 2017-07-04 07:03:18 +02:00
Sven Woop af19eecb09 fixed bug in curve geometry intersector caused by bezier curves with p0==p1 and/or p2==p3 2017-07-03 13:20:20 +02:00
Sven Woop 1aadf8edc4 curve intersector filters out NaNs caused in special cases such as ray oriented along a cylinder 2017-07-03 11:10:05 +02:00
Sven Woop 1bf79fb49a fixed typo 2017-07-03 09:40:49 +02:00
Sven Woop f1de9dd828 bugfix in smooth shading normal calculation, it may happen that the interpolated normal gets zero 2017-06-30 16:55:00 +02:00
Sven Woop d2cae64d59 bugfix in animated shading normal interpolation 2017-06-30 16:16:33 +02:00
Sven Woop 9c1b26ad9d Merge branch 'devel' of https://github.com/embree/embree into devel 2017-06-30 15:55:54 +02:00
Sven Woop cad0f8e70f updated models hash 2017-06-30 15:55:36 +02:00
Sven Woop 4163b5e2bb added animated shading normal support to pathtracer 2017-06-30 15:37:02 +02:00
Sven Woop d69fbc1d55 added support for shading normals for quads 2017-06-30 14:45:18 +02:00
Sven Woop 98c5a3f3d0 added support for vertex normals to path tracer 2017-06-30 13:48:22 +02:00
Sven Woop 5fca4e4808 alignedMalloc returns now nullptr for empty allocations 2017-06-30 08:50:45 +02:00
Johannes Günther 08fa094069 Fix lib names for embree-config
On Linux and Mac OS X the lib names to be linked against should contain
the API version (SOVERSION).
2017-06-29 10:45:39 +02:00
cbenthin 63df1246a7 Merge branch 'devel' of https://github.com/embree/embree into devel 2017-06-28 15:21:43 +02:00
Sven Woop 41f82f6c4c Merge branch 'release' into devel 2017-06-28 15:12:17 +02:00
Sven Woop c30dcbd51d compile fix 2017-06-28 15:11:17 +02:00
Sven Woop e51b891169 Merge branch 'devel' of https://github.com/embree/embree into devel 2017-06-28 15:10:17 +02:00
Sven Woop 0c90158577 compile fix 2017-06-28 15:09:47 +02:00
cbenthin 4ced89f6c5 Merge branch 'devel' of https://github.com/embree/embree into devel 2017-06-28 15:05:37 +02:00
cbenthin 7cfbff5ab2 for avx512 sorting code path replaced '<=' based sorting by '<' which works better for scenes like powerplant 2017-06-28 15:05:32 +02:00
Sven Woop 7c9afe7666 merged in v2.16.4 release 2017-06-28 12:10:51 +02:00
Sven Woop 8c7bae6e96 bugfixes in parsers, filename in parse location was corrupted, had to introduce reference counts again 2017-06-28 12:09:38 +02:00
Sven Woop 8bfcca7793 updated documentation 2017-06-28 12:07:34 +02:00
Sven Woop f79699fbee setting version to v2.16.4 2017-06-28 12:06:46 +02:00
Sven Woop 1cf5cb51c9 setting version to v2.16.4-alpha.0 2017-06-28 10:17:14 +02:00
Sven Woop 51a2a57a55 bugfix of ribbon_intersector for non-normalized rays 2017-06-28 10:16:27 +02:00
Sven Woop fe19c8d140 added support to load corona hair format from OBJ files 2017-06-28 08:39:32 +02:00
Sven Woop c97766cf6e bugfixes in parsers, filename in parse location was corrupted, had to introduce reference counts again 2017-06-28 08:31:53 +02:00
Sven Woop ad48abf863 fixed to enable -fPIE on ICC 2017-06-27 12:00:57 +02:00
Sven Woop 6b5845b8db compile fix, some system do not have std::string::back() function 2017-06-26 07:14:10 +02:00
Sven Woop 9b1ecd8fcb merge 2017-06-23 09:47:48 +02:00
Sven Woop 31a2dd189a updated documentation 2017-06-23 09:46:26 +02:00
Sven Woop 5f8976f9e9 increased accuracy of handling subdivision surfaces, this solves issues with cracks when using displacement mapping 2017-06-23 09:36:03 +02:00
Sven Woop d83294ae24 fast update mode for subdivs was incorrectly activated when vertex buffers got changed 2017-06-23 09:02:14 +02:00
cbenthin 2d62cb4f65 Merge branch 'devel' of https://github.com/embree/embree into devel 2017-06-22 15:15:54 +02:00
cbenthin 37e3d7cd10 relaxed memory allocation overhead from 5 to 7.5% on KNL, allows for building smaller scenes faster, also added doubling of growSize of the allocation overhead is smaller than 2.5% 2017-06-22 15:15:40 +02:00
Sven Woop e84331a505 removed use of sprintf from sysinfo.cpp 2017-06-19 13:10:43 +02:00
Sven Woop 3fa4799b87 removed use of strlen from stream.h 2017-06-19 13:06:45 +02:00
Sven Woop dfae7e082c not using sscanf in alloc.cpp anymore 2017-06-19 12:57:41 +02:00
Sven Woop 30ffd1c9ca cleanups to input checking 2017-06-14 11:44:15 +02:00
Sven Woop a7976875c7 using std::string in OBJ loader, avoids using strlen 2017-06-14 09:02:26 +02:00
Sven Woop f764a98382 removed memcpy from texture.cpp 2017-06-14 08:45:06 +02:00
Sven Woop 96b77bc423 bugfix 2017-06-14 08:32:16 +02:00
Sven Woop d668f4c479 removed memcpy from jpeg.cpp 2017-06-14 08:15:04 +02:00
Sven Woop f574ef434d removing not required network code 2017-06-14 07:57:35 +02:00
Sven Woop 740315f828 removed memcpy from grid_soa.cpp 2017-06-14 07:52:59 +02:00
Sven Woop 92d1f529c2 Merge branch 'release' into devel 2017-06-13 11:45:06 +02:00
Sven Woop 30a095afe1 improvements of UV encoding for subdivs, 0xFFFF factor was not optimal, 0x10000 factor is a better choice 2017-06-13 11:44:51 +02:00
Sven Woop ab89e99311 improvements of UV encoding for subdivs, 0xFFFF factor was not optimal, 0x10000 factor is a better choice 2017-06-13 10:17:32 +02:00
Sven Woop 187af3c675 Merge branch 'devel' of https://github.com/embree/embree into devel 2017-06-09 15:03:43 +02:00
Sven Woop c60a3cac1c removed usages of strlen 2017-06-09 15:03:32 +02:00
Sven Woop c9cb2c5dc5 replaced all usages of sscanf with std::stof 2017-06-09 14:42:35 +02:00
Sven Woop 73c02815de update 2017-06-09 13:23:38 +02:00
Sven Woop d80067bc64 merge 2017-06-09 11:50:07 +02:00
Sven Woop ca69cd410e adding docu, setting version to v2.16.2 2017-06-09 11:49:16 +02:00
Sven Woop a1cc4946c4 merge 2017-06-09 08:45:51 +02:00
Sven Woop 1ad3e67440 updated models hash 2017-06-09 08:43:16 +02:00
Sven Woop 2c52981b5f setting version to v2.16.2-alpha.1 2017-06-09 08:41:37 +02:00
Sven Woop 45b97468f4 cleanups 2017-06-09 08:40:40 +02:00
Sven Woop f7a276e00b improved subdiv uv encoding 2017-06-09 08:35:30 +02:00
Sven Woop e4ef689276 changed subdiv uv encoding to support uv's in the range [-0.5,1.5[ 2017-06-08 14:04:47 +02:00
Sven Woop 7379e75ded Merge branch 'release' into devel 2017-06-08 08:16:13 +02:00
Sven Woop c95596d398 The pluecker intersector calculates uv's by U*rcp(U+V+W) now. This keeps the uv's inside the triangle for small triangles. 2017-06-08 08:12:19 +02:00
Sven Woop 1b6ea047a0 merge 2017-06-07 14:10:21 +02:00
Sven Woop 30b08617f7 fixed issue where NULL intersection context was passed to intersection filter when instancing was used 2017-06-07 14:07:38 +02:00
atafra 12f3fe074e Merge remote-tracking branch 'origin/atafra3' into atafra3 2017-06-03 17:15:26 +03:00
atafra d0ae78e8c2 added stream sorting into octants for the packet fallback 2017-06-03 16:05:38 +03:00
Sven Woop a855710386 printing scene statistics 2017-06-02 09:09:10 +02:00
Sven Woop 6ea9510929 Merge branch 'devel' of https://github.com/embree/embree into devel 2017-06-02 07:26:57 +02:00
Jefferson Amstutz 7c0f6fcf37 fix for craype config skipping SSE4.2 code generation 2017-06-02 01:15:51 +00:00
cbenthin 59a74f5c53 deactivated parallel test execution in verify for win32 platforms due to out of memory exceptions 2017-06-01 02:40:58 -07:00
Sven Woop cb1c23397b added support for occlusion shader, F3 enables tracing occlusion rays only 2017-06-01 10:25:05 +02:00
Sven Woop e23e368bbb Merge branch 'devel' of https://github.com/embree/embree into devel 2017-05-31 14:49:31 +02:00
Sven Woop ee11bbb967 settings is a member in all builders now, makes changing settings based on type easier 2017-05-31 14:49:16 +02:00
cbenthin 627318c847 Merge branch 'devel' of https://github.com/embree/embree into devel 2017-05-31 05:32:02 -07:00
cbenthin b348b4a923 fixed compile warnings 2017-05-31 05:31:44 -07:00
Sven Woop 3392f195e3 builders pass primref array to createLeaf function 2017-05-31 10:04:08 +02:00
Sven Woop c95a469e53 passing and storing primref in builders 2017-05-31 09:44:26 +02:00
Sven Woop 323f065342 renames 2017-05-31 08:35:25 +02:00
Sven Woop d31b5e28c0 primTy member of BVH is a pointer now 2017-05-30 09:59:09 +02:00
Sven Woop 7e9701dbfe Merge branch 'devel' of https://github.com/embree/embree into devel 2017-05-30 07:28:04 +02:00
cbenthin 001dc353b0 bug fix 2017-05-24 10:40:22 +02:00
Sven Woop 999a1e0940 cleanups to heuristic_binning.h 2017-05-24 09:54:44 +02:00
cbenthin 468f0b006e Merge remote-tracking branch 'origin/devel' into cbenthin 2017-05-24 09:48:48 +02:00
Sven Woop 797cb841cb cleanups to bvh_builder_hair 2017-05-24 09:16:26 +02:00
Sven Woop 4c18806032 msmblur hair builder uses same node creation interface as normal msmblur builder 2017-05-24 09:03:00 +02:00
Sven Woop e158b4aeb4 using NodeRecordMB4D in msmblur hair builder, this makes this builder consistent with other msmblur builders 2017-05-24 08:37:34 +02:00
Sven Woop a421584457 added missing files 2017-05-24 08:16:40 +02:00
Sven Woop 7e2ef21e8a moved constant definitions to constant.cpp file, this fixes warnings of problematic global symbols when compiling in debug mode 2017-05-24 08:12:44 +02:00
Sven Woop 555bf49f82 updates to release_linux.sh 2017-05-24 07:35:04 +02:00
cbenthin 530e12fd08 Merge remote-tracking branch 'origin/devel' into cbenthin 2017-05-23 16:58:38 +02:00
cbenthin 3a985370e1 updates 2017-05-23 16:55:31 +02:00
Sven Woop 04413db408 renamed variable in bvh_builder_instancing 2017-05-23 10:20:28 +02:00
Sven Woop b7a754bf1e Merge branch 'master' into devel 2017-05-23 09:33:08 +02:00
Sven Woop bd6450fae9 Merge branch 'devel' of https://github.com/embree/embree into devel 2017-05-23 09:28:15 +02:00
Sven Woop 9bf5063504 using add_center2(PrimRef) function at most places in builders, makes tracking prim types easier 2017-05-23 09:28:03 +02:00
Johannes Günther ab16bfb9ff Always build static lib when shared libs not supported; use option 2017-05-23 09:19:21 +02:00
Sven Woop ee1b3e0974 cleanups to priminfo.h 2017-05-23 08:46:55 +02:00
Sven Woop 782c3a00b9 cleanups to priminfo.h 2017-05-23 08:22:43 +02:00
Sven Woop fd6d8eebfc cleanups to priminfo.h 2017-05-23 08:18:18 +02:00
Sven Woop 74a0465bd9 cleanups to PrimInfoExtRange and PrimInfoRange constructors 2017-05-23 08:11:50 +02:00
Sven Woop 788d9129bd updates 2017-05-22 17:49:05 +02:00
cbenthin 270be28fa1 Merge remote-tracking branch 'origin/devel' into cbenthin 2017-05-22 15:14:25 +02:00
cbenthin 4cf85a5d3a more vs 2017 warning fixes 2017-05-22 04:50:46 -07:00
cbenthin bcf566e242 more vs 2017 warning fixes 2017-05-22 04:11:58 -07:00
cbenthin 261135446b some vs 2017 warning fixes 2017-05-22 02:56:15 -07:00
cbenthin 8d7737a40d Merge branch 'devel' of https://github.com/embree/embree into devel 2017-05-22 02:47:57 -07:00
cbenthin a503458f46 merge with devel and some vs 2017 warning fixes 2017-05-22 02:47:47 -07:00
Sven Woop f58120e3d9 simplifications in priminfo.h 2017-05-22 11:29:43 +02:00
Sven Woop a91a622031 disabling twolevel morton builder for user geometries (also for BVH8) 2017-05-22 11:19:53 +02:00
Sven Woop a497a0d420 merge 2017-05-22 10:57:13 +02:00
Sven Woop bfdde3a838 updated docu 2017-05-22 10:32:23 +02:00
Sven Woop 18ff8964e9 disabling twolevel morton builder for user geometries, causes memory consumption issues with instances 2017-05-22 10:17:23 +02:00
Sven Woop 9d666f3c60 bugfix in bvh.cpp, print statistics could crash 2017-05-22 10:10:15 +02:00
Sven Woop 70283e66cd fixed quadratic runtime of resize(n+1) loop 2017-05-22 08:25:54 +02:00
Sven Woop 91641f03f0 setting version to v2.16.1 2017-05-22 08:04:10 +02:00
Sven Woop 4dfbb4f634 setting version to v2.16.1 2017-05-22 08:03:41 +02:00
Sven Woop 8a0b5ace23 workaround for VS2017 internal compiler bug 2017-05-22 08:02:25 +02:00
Sven Woop 84b31bec95 bugfix to getNumEagerLeaves function 2017-05-22 08:00:58 +02:00
Sven Woop 555d73a939 recurse function of msmblur builder no longer stored split in BuildRecord 2017-05-22 07:39:46 +02:00
Sven Woop ecd9fec37d compile fix for AVX512SKX 2017-05-22 07:18:34 +02:00
Sven Woop cef647b6f0 Merge branch 'devel' of https://github.com/embree/embree into devel 2017-05-22 07:16:02 +02:00
atafra c624afc9af Merge remote-tracking branch 'origin/devel' into atafra3 2017-05-21 16:46:17 +03:00
cbenthin dff2d930c1 Merge remote-tracking branch 'origin/release' into devel 2017-05-19 14:51:59 +02:00
Sven Woop 8e34329cb8 cleanups in scene_triangle_mesh.h 2017-05-19 14:24:08 +02:00
cbenthin 5e7c954431 added __forceinline to splitFallback to prevent strange VS 2017 compiler bug 2017-05-19 14:22:46 +02:00
Sven Woop 344b55c0e3 fixed rcp(float) and rsqrt(float) functions, used _ps instead of _ss intrinsics 2017-05-19 13:46:51 +02:00
Sven Woop 39d239c532 fixed source of floating point exceptions in binner 2017-05-19 13:34:06 +02:00
Sven Woop d11fab4176 adding tbb.lib and tbbmalloc.lib to release package under Windows 2017-05-19 12:23:11 +02:00
Sven Woop abe0530dd8 RTC_CONFIG_TASKING_SYSTEM returns 2 if PPL is used 2017-05-19 10:39:20 +02:00
atafra a62a51eb8a Merge remote-tracking branch 'origin/devel' into atafra3 2017-05-18 17:32:22 +03:00
atafra 72e0ebb1ca stream intersector experiments 2017-05-18 17:31:42 +03:00
atafra 2c77282a31 updated documentation 2017-05-17 20:29:02 +03:00
cbenthin 67d3896680 updates before test 2017-05-17 15:13:51 +02:00
cbenthin 96d11769a8 updates 2017-05-17 10:13:11 +02:00
Sven Woop e5f9f21586 updates to check_globals.cmake, static variable inside function is ok 2017-05-17 09:26:05 +02:00
Sven Woop ec23630dfb Merge branch 'devel' of https://github.com/embree/embree into devel 2017-05-17 09:23:26 +02:00
Sven Woop e6d389b4d9 added support to create mixed tri/quad scene 2017-05-17 09:23:15 +02:00
Sven Woop 3d8f66e496 updates 2017-05-17 08:44:58 +02:00
Sven Woop 2764be05aa increased threshold for dynamic scene memory consumption test to 1.3x 2017-05-17 08:38:01 +02:00
Sven Woop e49f0f68b0 set version to v2.17.0-alpha.0 2017-05-17 08:30:18 +02:00
Sven Woop 89dedd512f workaround for ICC2016 compiler bug 2017-05-16 21:35:49 +02:00
Sven Woop 7421bf3faf increased minimal GLIBCXX version from 3.4.5 to 3.4.11 2017-05-16 16:55:45 +02:00
Sven Woop 9497a83c3c workaround for ICC2016 compiler bug 2017-05-16 16:34:03 +02:00
cbenthin ac7ef24c4b just changed stat3 macros for packets in rtcore.cpp to count active rays only, makes stats comparisons between single and hybrid easier 2017-05-16 12:00:52 +02:00
Sven Woop d02419b1ec updated documentation 2017-05-16 10:29:17 +02:00
Sven Woop ef4791be82 setting version to v2.16.0 2017-05-16 10:20:15 +02:00
Sven Woop 48ec6b4982 cleanups to bvh_builder_twolevel 2017-05-16 10:19:19 +02:00
Sven Woop 0d2a8ec3cb cleanup to heuristic_openmerge_array 2017-05-16 10:11:03 +02:00
Sven Woop 2fe5c3dfe5 cleanup to heuristic_openmerge_array, added OpenHeuristic struct that encapsulates the 10% maxdim heuristic 2017-05-16 10:06:06 +02:00
Sven Woop 15a90015b3 cleanup to heuristic_openmerge_array 2017-05-16 09:46:27 +02:00
Sven Woop 79f79a3043 cleanup to heuristic_openmerge_array 2017-05-16 09:45:31 +02:00
Sven Woop c10b251bd0 cleanup to heuristic_openmerge_array, removed unused openNodesUntilSetIsFull function 2017-05-16 09:38:43 +02:00
Sven Woop afc105f211 cleanup to heuristic_openmerge_array 2017-05-16 09:33:32 +02:00
Sven Woop 774731d456 cleanup to heuristic_openmerge_array 2017-05-16 09:21:21 +02:00
Sven Woop 2a80cb21ad cleanup to heuristic_openmerge_array, removed unused calculation of split info 2017-05-16 09:13:39 +02:00
Sven Woop 222536b63f cleanup to heuristic_openmerge_array 2017-05-16 09:11:10 +02:00
Sven Woop e6af6c3c1d optimization to heuristic_openmerge_array, improved disabling opening when unsufficient extended space available 2017-05-16 09:07:28 +02:00
Sven Woop 1f361ae496 cleanups to heuristic_openmerge_array, openNodesBasedOnExtend 2017-05-16 08:52:41 +02:00
Sven Woop 2e0e512d6d cleanups to heuristic_openmerge_array 2017-05-16 08:47:51 +02:00
Sven Woop 5c76db9d32 bugfix in heuristic_openmerge_array, fixed size_t -> float -> size_t cast 2017-05-16 08:44:23 +02:00
Sven Woop 2502dcb73b cleanups to heuristic_openmerge_array, removed unused countOpenNodes function 2017-05-16 08:42:45 +02:00
Sven Woop 9525b0ded8 cleanups to heuristic_openmerge_array 2017-05-16 08:33:48 +02:00
Sven Woop 5915152b28 cleanups to heuristic_openmerge_array, simplified getProperties 2017-05-16 08:31:20 +02:00
Sven Woop d832a6bf13 potential bugfix in heuristic_openmerge_array.h, disjoint test would have failed for empty input array 2017-05-16 08:14:20 +02:00
Sven Woop 955e1701be cleanups to heuristic_openmerge_array.h, disjoint test 2017-05-16 08:13:36 +02:00
Sven Woop 703d1cf38b cleanups to heuristic_openmerge_array.h 2017-05-16 08:04:06 +02:00
Sven Woop bdad88f276 cleanups to heuristic_openmerge_array.h 2017-05-16 08:01:21 +02:00
Sven Woop c177d88e73 Merge branch 'devel' of https://github.com/embree/embree into devel 2017-05-15 16:53:37 +02:00
Sven Woop c721ab734e removed SplitOpenMerge struct, not required as identical as BinSplit 2017-05-15 16:53:28 +02:00
cbenthin c80cc59a31 increasing epsilon to 2*ulp seems to remove all artifacts with icc 2017-05-15 13:22:01 +02:00
Sven Woop ad4d18367d removed binSubTreeRefs function and used normal binning API, added size() function to TwoLevelBuilder::BuildRef to properly handle subtree sizes during binning 2017-05-15 12:56:39 +02:00
Sven Woop add47a2007 cleanups 2017-05-15 12:45:19 +02:00
Sven Woop dd7772fb7c matching opensize of new and old toplevel rebuild approach 2017-05-15 11:34:43 +02:00
Sven Woop 5e5a1732d8 matching opensize of new and old toplevel rebuild approach 2017-05-15 11:34:05 +02:00
Sven Woop c6e0e35356 passing full BVH size estimate as toplevel size estimate 2017-05-15 10:48:04 +02:00
Sven Woop 40cd5ca468 Merge branch 'devel' of https://github.com/embree/embree into devel 2017-05-15 10:40:31 +02:00
Sven Woop 58b1db62d7 improved uninstall script for MacOSX 2017-05-15 10:40:24 +02:00
Sven Woop 7a2448158b added some epsilons to curve geometry intersector, might fix some issues seen with ICC on KNL 2017-05-15 10:25:50 +02:00
Sven Woop 8584438138 Curves use again AVX for interpolation, code was correct as we use masked load/store 2017-05-15 07:20:07 +02:00
Sven Woop dc750313a3 updates to primref geomID and primID assignment 2017-05-12 14:55:43 +02:00
Sven Woop a79423d727 replaced DEFINE/DECLARE_BUILDER2 by more general DEFINE/DECLARE_ISA_FUNCTION makros 2017-05-12 14:29:59 +02:00
Sven Woop 46fab1953c removed stream intersection loops from individual intersectors and solely using loops in ArrayIntersector wrapper 2017-05-12 13:41:52 +02:00
Sven Woop b108520812 compile fix, interpolate_helper symbol was not always created 2017-05-12 13:14:24 +02:00
Sven Woop 8e76d782c3 Merge branch 'devel' of https://github.com/embree/embree into devel 2017-05-12 11:53:33 +02:00
Sven Woop 808436be23 builders pass range<size_t> to createLeaf functions 2017-05-12 11:53:15 +02:00
Sven Woop 997ea3cffd derived extended_range from range 2017-05-12 11:53:02 +02:00
Sven Woop 09c41bd813 removed dependency of primref and primref_mb from scene 2017-05-12 10:20:35 +02:00
CDash 1fbc9852eb Merge branch 'devel' of https://github.com/embree/embree into devel 2017-05-12 03:15:08 -05:00
CDash f593f4662e fixed compile error for ICC15 on macos 2017-05-12 03:14:59 -05:00
Sven Woop 3628b44c68 Revert "passing accel to single ray leaf intersectors"
This reverts commit 413360fb5b.
2017-05-12 07:53:25 +02:00
cbenthin 0947794ef1 added comments 2017-05-11 22:33:10 +02:00
cbenthin 48dbdafe3e added some comments 2017-05-11 22:14:10 +02:00
cbenthin 9f700284b5 Merge remote-tracking branch 'origin/devel' into cbenthin 2017-05-11 21:55:02 +02:00
cbenthin 984845812a cleanups 2017-05-11 21:54:40 +02:00
cbenthin 7ae934c340 open merge heursitic gets wideness of BVH through getN() call 2017-05-11 15:44:17 +02:00
cbenthin cde999ab5d updates 2017-05-11 15:26:58 +02:00
Sven Woop 413360fb5b passing accel to single ray leaf intersectors 2017-05-11 14:21:54 +02:00
Sven Woop bb75f2f3c6 updates models hash 2017-05-11 13:36:29 +02:00
Sven Woop c43f04ff2f removed experimental leafType parameter that was passed around, is no longer required 2017-05-11 13:36:08 +02:00
Sven Woop 198cd858db addes isa specialization for curves 2017-05-11 12:41:50 +02:00
Sven Woop fad1918545 bugfix in scene_bezier_curves.cpp, interpolation code did use AVX when code was compiled with AVX as lowest ISA, that is wrong as it required vertex buffers to be 32 bytes aligned 2017-05-11 12:24:06 +02:00
Sven Woop 463155a1bc cleanups in scene_bezier_curves 2017-05-11 12:18:05 +02:00
Sven Woop 98ce178ce3 added isa specialization for QuadMesh and LineSegments 2017-05-11 12:00:07 +02:00
cbenthin d23edf3b8f updates 2017-05-11 11:59:15 +02:00
Sven Woop 4abe5db03d added isa specialization of SubdivMesh 2017-05-11 11:39:53 +02:00
Sven Woop fd3d496232 added ISA specialization for TriangleMesh 2017-05-11 11:11:08 +02:00
cbenthin f559545523 more cleanups 2017-05-11 10:46:26 +02:00
Sven Woop c5450e92fe fixed ray/curve intersection issues when intersecting with perfect cylinder 2017-05-11 10:12:50 +02:00
cbenthin 6456c4f3c7 cleanups 2017-05-11 09:29:03 +02:00
cbenthin d43ef73908 Merge remote-tracking branch 'origin/devel' into cbenthin 2017-05-11 09:22:00 +02:00
cbenthin 9d624e49ea fast AVX512 sorting also for bvh4 on KNL 2017-05-10 17:51:46 +02:00
cbenthin 2edda871df Merge branch 'hpg2017' into cbenthin 2017-05-10 14:28:09 +02:00
cbenthin edd543069f Merge remote-tracking branch 'origin/cbenthin' into devel 2017-05-10 13:58:00 +02:00
cbenthin cd1b4e33bd sync with cbenthin 2017-05-10 13:47:05 +02:00
cbenthin 8a835efcc2 Merge remote-tracking branch 'origin/cbenthin' into hpg2017 2017-05-10 13:44:08 +02:00
cbenthin c39552f417 updates: 2017-05-10 13:37:56 +02:00
cbenthin 168749d762 Merge remote-tracking branch 'origin/devel' into cbenthin 2017-05-10 13:36:05 +02:00
Sven Woop 1d7cb42e60 fixed embree.rc 2017-05-10 11:53:02 +02:00
cbenthin bfe17bb80c updates 2017-05-10 11:52:43 +02:00
cbenthin bf3acb9d59 updates 2017-05-10 11:34:44 +02:00
cbenthin 47ba786010 updates 2017-05-10 10:43:02 +02:00
cbenthin f6bb338869 Merge remote-tracking branch 'origin/devel' into hpg2017 2017-05-10 10:00:01 +02:00
Sven Woop 4859c7931f added missing file 2017-05-10 09:59:33 +02:00
cbenthin 5513cfc963 Merge remote-tracking branch 'origin/devel' into hpg2017 2017-05-10 09:57:49 +02:00
cbenthin d4d2c4b57e updates 2017-05-10 09:56:58 +02:00
Sven Woop d66e0a8b9f renamed __TARGET_XXX__ to EMBREE_TARGET_XXX, __ macros are reserved 2017-05-10 09:03:45 +02:00
Sven Woop d3e6290bcb removed hash from rtcore_version.h, git repo cannot contain file with the hash of the repo, including rtcore_version.h also in rtcore.isph 2017-05-10 08:55:08 +02:00
Sven Woop 5af8c6376e Embree version makros RTCORE_VERSION_XXX also available when not installing Embree 2017-05-10 08:41:47 +02:00
Sven Woop 4dee38860b renamed __EMBREE_VERSION_XXX__ to RTCORE_VERSION_XXX 2017-05-10 08:29:30 +02:00
Sven Woop c5f0c18759 added geomID()/primID() access functiont to GridSOA 2017-05-10 07:55:01 +02:00
Sven Woop 1422e18f2a increased memory consumption estimate for hair_mb, bounds are very loose but this way the test runs through 2017-05-10 07:12:13 +02:00
Sven Woop 5819d40c71 adding geomID()/primID() access functions to SubdivPatch1Base 2017-05-10 07:09:12 +02:00
cbenthin 856fcfb119 cleanups for avx512 sorting code 2017-05-09 22:32:50 +02:00
cbenthin 49726b589f merge with devel 2017-05-09 19:30:03 +02:00
cbenthin fc5cbabc39 merge with devel 2017-05-09 16:21:24 +02:00
cbenthin 9ebe020db5 commit before merging with devel 2017-05-09 16:06:41 +02:00
cbenthin fb8766e7e2 simplified quantized nodes, underlying type is now easily exchangeble 2017-05-09 15:59:26 +02:00
cbenthin ab5acfb6fb Merge remote-tracking branch 'origin/devel' into cbenthin 2017-05-09 13:52:29 +02:00
Sven Woop 34ff5912e4 geomID/primID accessed through access functions only 2017-05-09 13:49:34 +02:00
Sven Woop 3790892968 cleanups in bezier1v.h 2017-05-09 12:36:12 +02:00
Sven Woop b29260d342 removed unused BezierPrim struct 2017-05-09 12:30:56 +02:00
Sven Woop db170e7fa2 geomID/primID accessed through access functions only 2017-05-09 12:09:45 +02:00
Sven Woop 23c418b6e5 consistently using BVH4 for compact mode 2017-05-09 11:32:25 +02:00
cbenthin fcab0dbd72 sync 2017-05-09 11:17:58 +02:00
Sven Woop b7809f9614 removed compact mode from init_estimate 2017-05-09 08:06:21 +02:00
Sven Woop 812b477637 removed single_mode argument from init_estimate 2017-05-09 07:58:37 +02:00
Sven Woop 0a80def516 removed HIGH_SINGLE_THREAD_THRESHOLD from bvh_builder_sah 2017-05-09 07:54:15 +02:00
Sven Woop 736d28592e updates to buildbench 2017-05-09 07:43:56 +02:00
Sven Woop 242531273f removed switching between old and new fast allocator settings 2017-05-09 07:41:06 +02:00
Sven Woop 3bfc06e637 updates 2017-05-09 07:35:51 +02:00
Sven Woop 1bfe141883 Merge branch 'devel' into swoop 2017-05-09 07:17:50 +02:00
Sven Woop 882dc41460 using first vertex from first primitive to fill invalid prims for trianglei and quadi 2017-05-09 07:16:39 +02:00
cbenthin b3dc0c76f3 fixed upconverting issue for AVX512 in TravRay 2017-05-08 17:46:44 +02:00
cbenthin 39d9fde114 minor updates 2017-05-08 16:30:54 +02:00
cbenthin 7fbc12bfa8 improved distance-based ordering for chunk traversal 2017-05-08 15:07:48 +02:00
cbenthin 52d7468d8f chunk traverser processes now only rays with the same direction signs 2017-05-08 13:01:19 +02:00
Sven Woop 7eefc31f87 Merge branch 'devel' of https://github.com/embree/embree into devel 2017-05-08 12:11:52 +02:00
Sven Woop 7755090d76 compile fix when enabled filtering out of invalid rays 2017-05-08 12:11:42 +02:00
cbenthin 5b349e324c set defaultBlockSize to a maximum of 4160 2017-05-08 10:07:31 +02:00
cbenthin 0f36893bdb Merge remote-tracking branch 'origin/devel' into swoop 2017-05-08 09:59:18 +02:00
cbenthin 9db42a42e1 merge with devel 2017-05-08 09:59:05 +02:00
Sven Woop 5d8bd7fa12 reduced diff to devel 2017-05-04 09:55:30 +02:00
Sven Woop d776a5a3ba Merge branch 'devel' into swoop 2017-05-04 08:35:29 +02:00
Sven Woop f05a6c7977 bugfix 2017-05-02 11:45:07 +02:00
Sven Woop 98ff0713c2 updates to verify 2017-05-02 11:39:01 +02:00
Sven Woop c017b5e5a6 bugfixes 2017-05-02 11:26:46 +02:00
Sven Woop 70c39601c4 updates to FastAllocator 2017-05-02 10:17:51 +02:00
Sven Woop d057db526f never enabling single alloc mode 2017-05-02 09:50:09 +02:00
Sven Woop 9e7e8bc38f updates 2017-05-02 09:35:18 +02:00
Sven Woop 1db3616236 updates 2017-05-02 09:05:58 +02:00
Sven Woop c81578dd06 updates to initGrowSizeAndNumSlots 2017-05-02 08:57:53 +02:00
Sven Woop cca6e644db updates 2017-05-02 08:41:42 +02:00
Sven Woop 2627a3e6aa updates 2017-05-02 08:28:47 +02:00
Sven Woop cd7c280825 updates to fixSingleThreadThreshold 2017-05-02 08:23:08 +02:00
Sven Woop 892b57dbb5 FastAllocator setting configurable from command line 2017-05-02 07:53:36 +02:00
Sven Woop fccf939e42 Merge branch 'devel' into swoop 2017-05-02 07:33:43 +02:00
cbenthin 7bcaf8a539 merge with devel 2017-04-29 13:31:59 +02:00
cbenthin 8d99340118 set defaultBlockSize also to 4160 when FILTER ON, gets back most of the perf on KNL 2017-04-29 10:54:01 +02:00
cbenthin aa2b2c442f temporarily disabled some tests in buildbench 2017-04-28 17:38:26 +02:00
cbenthin c24c08ffa6 Merge branch 'swoop' of https://github.com/embree/embree into swoop 2017-04-28 10:37:13 +02:00
Sven Woop 7fe6f8de32 compile fix for windows and ICC 2017-04-28 07:34:46 +02:00
Sven Woop 885395bd36 Merge branch 'devel' into swoop 2017-04-27 19:52:55 +02:00
cbenthin f71d3db828 Merge remote-tracking branch 'origin/devel' into swoop 2017-04-27 16:08:23 +02:00
Sven Woop 546daeab5e Merge branch 'devel' into swoop 2017-04-27 13:19:21 +02:00
Sven Woop 2cffe6f6e5 adjusted thresholds 2017-04-27 12:55:22 +02:00
Sven Woop d6362a44dc merged in devel branch 2017-04-27 12:47:20 +02:00
Sven Woop 98bc2f7bea improved calculation of singleThreadThreshold, large scenes have fast threshold now, disabled better singleThreadThreshold usage in bvh_builder_sah 2017-04-27 12:19:46 +02:00
Sven Woop 5036ea9b10 more accurate singleThreadThreshold fulfillment in SAH builder 2017-04-18 12:44:09 +02:00
Sven Woop b855e06437 updates to memory bounds for AVX2 2017-04-18 11:17:10 +02:00
Sven Woop 978f4b7e79 updates 2017-04-18 08:07:15 +02:00
Sven Woop d70a7412e7 bugfix 2017-04-18 08:04:33 +02:00
Sven Woop 3cf7f3b65f updates 2017-04-13 14:50:47 +02:00
Sven Woop 98f88dabdc updates 2017-04-13 14:45:24 +02:00
Sven Woop 32f812e576 bugfix 2017-04-13 14:34:26 +02:00
Sven Woop 5b25f26a20 getting performance back for morton builder 2017-04-13 14:20:15 +02:00
Sven Woop e36ac7e8f6 updates 2017-04-13 13:55:58 +02:00
Sven Woop edd1c233c8 updates 2017-04-13 12:56:25 +02:00
Sven Woop 530cfc23f0 configured memory_consumption_test to run faster 2017-04-13 12:25:17 +02:00
Sven Woop 9ac1af39bd updates 2017-04-13 12:20:12 +02:00
Sven Woop 28cc65b124 updates to verify, memory test runs also with AVX 2017-04-13 12:19:58 +02:00
Sven Woop 8f7ad8752e increased SINGLE_THREADED_BYTES threshold 2017-04-13 11:45:39 +02:00
Sven Woop 47d0d2ea02 updates to verify 2017-04-13 11:42:00 +02:00
Sven Woop e3c3cd41cd updates 2017-04-13 11:35:09 +02:00
Sven Woop 482cccc172 FastAllocator reports again MB 2017-04-13 11:33:37 +02:00
Sven Woop 20e564fb27 updates to memory consumption test in verify 2017-04-13 11:32:34 +02:00
Sven Woop 3a3a7b232f updates to verify 2017-04-13 11:16:48 +02:00
Sven Woop 3d727fa459 updates to verify 2017-04-13 11:00:23 +02:00
Sven Woop 5af3cf7907 updates to verify 2017-04-13 10:19:59 +02:00
Sven Woop 373176d58c allocating smaller initial block in morton builder 2017-04-13 09:52:17 +02:00
Sven Woop 970cd0b454 fixes to verify mem consumption test 2017-04-13 09:33:29 +02:00
Sven Woop 9f706fa429 fixes to verify mem consumption test 2017-04-13 09:22:10 +02:00
Sven Woop 6cef830a2a updates 2017-04-13 08:59:05 +02:00
Sven Woop d513f0bd32 calculating single threaded threshold based on subtree size 2017-04-13 08:29:40 +02:00
Sven Woop ee9bb538b3 updates 2017-04-13 08:18:46 +02:00
Sven Woop 9405a1912f switching between both fastallocator heuristics 2017-04-13 08:07:18 +02:00
Sven Woop d364491d99 cleanups 2017-04-13 07:46:53 +02:00
Sven Woop db231a40f8 added both, new and old parameters to FastAllocator 2017-04-13 07:44:31 +02:00
Sven Woop ced929b265 updates to verify 2017-04-12 15:10:17 +02:00
Sven Woop 2d58fc0461 updates 2017-04-12 14:50:24 +02:00
Sven Woop 3fc60a3c85 updates to verify 2017-04-12 14:41:41 +02:00
Sven Woop 9784267543 updates 2017-04-12 14:40:01 +02:00
Sven Woop 9c3036e7da bugfix in FastAllocator 2017-04-12 14:19:18 +02:00
Sven Woop f045058ded cleanups in verify 2017-04-12 14:07:54 +02:00
Sven Woop 1e9b9173a2 improvements to FastAllocator 2017-04-12 13:49:40 +02:00
Sven Woop 532c43bf75 updates 2017-04-12 13:44:46 +02:00
Sven Woop 7cac067244 improved reporting of free memory in FastAllocator 2017-04-12 13:27:11 +02:00
Sven Woop 6a25443f07 1024k blocks in fastallocator, output in kB 2017-04-12 13:15:26 +02:00
Sven Woop b4c3aee893 cleanups in FastAllocator initGrowSizeAndNumSlots function 2017-04-12 12:43:33 +02:00
Sven Woop 84c1243797 improved statistics output of FastAllocator 2017-04-12 12:16:59 +02:00
Sven Woop 51d22ee3e4 FastAllocator prints now, allocated bytes, free bytes, and total block size 2017-04-12 11:21:15 +02:00
Sven Woop c161a1f311 changed free bytes calculation 2017-04-12 11:17:06 +02:00
Sven Woop e038be50ce changed use_single_mode calculation 2017-04-12 11:08:49 +02:00
Sven Woop 5b8aa24e76 fixed maxGrowSize and defaultBlockSize calculation 2017-04-12 10:50:25 +02:00
Sven Woop bd7fb9e436 more accurate size estimate for SAH builder 2017-04-12 10:39:29 +02:00
Sven Woop 99c977a0d2 updates to FastAllocator 2017-04-12 10:25:47 +02:00
Sven Woop 1a077bd957 added maxGrowSize to FastAllocator 2017-04-12 10:21:22 +02:00
Sven Woop be3497baeb tracking estimated size in FastAllocator 2017-04-12 10:21:02 +02:00
Sven Woop 5dd4428771 bugfix in MemoryConsumptionTest 2017-04-12 09:36:12 +02:00
cbenthin 9e0a15f701 updates 2017-04-06 17:20:09 +02:00
cbenthin 8e608c22ff updates 2017-04-06 13:20:13 +02:00
cbenthin 979f97bb08 merge devel into branch 2017-04-06 11:33:18 +02:00
cbenthin 7226a5fbc6 sync with devel, knl compile fixes 2017-03-28 11:07:53 +02:00
cbenthin 6965907cfd updates 2017-03-24 17:41:24 +01:00
cbenthin 3f27ef3e47 Merge branch 'devel' into hpg2017 2017-03-24 14:54:22 +01:00
cbenthin a8dab9bc02 updates 2017-03-24 14:53:32 +01:00
cbenthin a00de166e3 updates 2017-03-23 22:44:55 +01:00
cbenthin f5bc499537 removed dbuffer code 2017-03-23 09:23:55 +01:00
cbenthin 1876e3d0c5 Merge branch 'devel' into hpg2017 2017-03-22 11:24:52 +01:00
Sven Woop c0bef11c5c merging in devel 2017-03-21 14:15:20 +01:00
cbenthin bcbb0f7dc5 updates 2017-03-20 21:41:13 +01:00
cbenthin aa99cd3068 updates 2017-03-18 18:18:05 +01:00
cbenthin 4a0ff52fed updates 2017-03-18 18:06:39 +01:00
cbenthin 60a4d86c51 sync with devel 2017-03-17 17:33:36 +01:00
cbenthin 4fb7ebb10b Merge branch 'devel' into hpg2017 2017-03-17 14:29:42 +01:00
cbenthin 74fb6a1cc6 Merge branch 'hpg2017' of sdvis.org:embree into hpg2017 2017-03-17 14:28:56 +01:00
cbenthin 89bf200f4a sync before merge 2017-03-17 14:28:49 +01:00
Sven Woop 3d8d025fc9 manual merge 2017-03-17 10:10:05 +01:00
cbenthin 99429bc2e7 Merge branch 'hpg2017' of sdvis.org:embree into hpg2017 2017-03-12 22:21:17 +01:00
cbenthin ed31151b7b updates 2017-03-12 22:21:00 +01:00
Sven Woop 3321403096 merge 2017-03-10 12:26:54 +01:00
cbenthin 65acc52e9b Merge branch 'devel' into hpg2017 2017-03-07 16:16:34 +01:00
cbenthin 5b1b55ca3d updates 2017-03-07 16:16:11 +01:00
cbenthin 32086d24b0 updates 2017-03-06 11:37:22 +01:00
cbenthin be4f7b0971 updates 2017-03-05 21:17:06 +01:00
Sven Woop 650e7f4413 updates 2017-03-03 14:34:29 +01:00
Sven Woop 42ad7c3c15 compile fix for disabled subtree size binning, printing number of leaves 2017-03-03 14:02:43 +01:00
Sven Woop 3e9a23b0c2 merging in devel branch 2017-03-03 13:43:57 +01:00
cbenthin d5ba1ad118 Merge branch 'devel' into hpg2017 2017-02-24 17:19:28 +01:00
cbenthin 25eabd1cf5 updates 2017-02-24 17:18:47 +01:00
cbenthin b84a6446e0 working 2017-02-24 17:09:37 +01:00
cbenthin 6e86742a1e splitting 2017-02-24 16:57:59 +01:00
cbenthin e888e4f5b5 working 2017-02-24 16:01:56 +01:00
cbenthin 3764b6af59 not yet working 2017-02-24 15:34:44 +01:00
cbenthin fb4580b1d8 updates 2017-02-24 14:44:09 +01:00
cbenthin 979525d85b cleanups 2017-02-24 08:55:27 +01:00
cbenthin 8335910113 Merge branch 'devel' into hpg2017 2017-02-24 08:46:25 +01:00
cbenthin 47a18fef09 updates 2017-02-23 22:32:00 +01:00
cbenthin e79ee5506d updates 2017-02-23 14:26:28 +01:00
cbenthin 6aed72c3cb updates 2017-02-22 21:00:17 +01:00
cbenthin 16bee21512 merge 2017-02-22 18:12:59 +01:00
cbenthin 34e070e2e6 updates 2017-02-22 18:03:08 +01:00
cbenthin 7b58f587c6 Merge branch 'devel' into hpg2017 2017-02-22 10:23:21 +01:00
cbenthin 54e0227e3c updates 2017-02-22 10:22:39 +01:00
cbenthin 12de968465 updates 2017-02-21 22:41:19 +01:00
cbenthin f7b5a14555 updates 2017-02-21 14:24:16 +01:00
Sven Woop 97e6f4c2a0 manual merge 2017-02-21 09:02:22 +01:00
cbenthin 1804f9cda9 removed old code 2017-02-20 21:57:24 +01:00
cbenthin b03e4f2c25 updates 2017-02-20 21:36:56 +01:00
cbenthin 5e6edf1916 parallel version 2017-02-20 21:10:35 +01:00
cbenthin ea06788681 updates 2017-02-20 15:54:20 +01:00
cbenthin 6ccbf45b53 new 10% criteria 2017-02-20 15:18:50 +01:00
cbenthin 818907e679 updates 2017-02-19 22:59:25 +01:00
cbenthin 2cc71ff726 cleanups 2017-02-19 22:04:25 +01:00
cbenthin f67b7cb7d4 working 2017-02-19 21:47:21 +01:00
cbenthin ee63896f22 updates 2017-02-19 20:58:00 +01:00
cbenthin 272bba72a6 updates 2017-02-18 22:09:55 +01:00
cbenthin a335fab7bc updates 2017-02-18 21:36:03 +01:00
cbenthin 303def8b2f updates 2017-02-18 18:05:50 +01:00
cbenthin 11af0d5487 updates 2017-02-17 19:40:06 +01:00
cbenthin a5398177fe updates 2017-02-16 22:28:38 +01:00
cbenthin b53199a00e updates 2017-02-16 22:28:09 +01:00
cbenthin b1924f7411 updates 2017-02-16 21:29:46 +01:00
cbenthin 4cd399f356 updates 2017-02-16 17:30:09 +01:00
cbenthin c71348e149 updates 2017-02-16 16:07:25 +01:00
cbenthin b6c9cbc725 updates 2017-02-16 13:47:40 +01:00
cbenthin 0a758fc284 updates 2017-02-16 11:28:41 +01:00
cbenthin 17e86ea0d3 todo updates 2017-02-16 10:25:32 +01:00
cbenthin a05e8bc79c binning works 2017-02-16 10:24:31 +01:00
cbenthin 9742130614 updates 2017-02-16 10:09:13 +01:00
cbenthin 83d14dc5be updates 2017-02-16 09:40:02 +01:00
cbenthin a43bb541fd updates 2017-02-15 21:33:02 +01:00
cbenthin 0cdb81ae31 updates 2017-02-15 21:28:26 +01:00
cbenthin c865c6b1a0 enabled term criteria 2017-02-15 21:11:25 +01:00
cbenthin 4d394f08a8 fixes 2017-02-15 20:24:54 +01:00
cbenthin b7dd77cb9c working 2017-02-15 18:38:14 +01:00
cbenthin 9580084b2e updates 2017-02-15 17:13:01 +01:00
cbenthin ddb2ac9dba updates 2017-02-15 16:54:38 +01:00
cbenthin a341cab53e updates 2017-02-15 16:17:39 +01:00
cbenthin 12cebdf624 updates 2017-02-15 16:09:54 +01:00
cbenthin 728b1187ea updates 2017-02-15 15:59:29 +01:00
cbenthin a92e807f0f updates 2017-02-15 08:49:47 +01:00
cbenthin 9abac6ec14 updates 2017-02-14 21:50:48 +01:00
cbenthin e3eead7859 working 2017-02-14 21:38:44 +01:00
cbenthin 816c220091 updates 2017-02-14 17:59:56 +01:00
cbenthin e95c8c252c updates 2017-02-14 12:05:14 +01:00
cbenthin 8d8eebe99a updates 2017-02-14 10:53:17 +01:00
cbenthin 0470b16268 updates 2017-02-14 09:27:58 +01:00
cbenthin 1c6ec17756 updates 2017-02-13 22:41:10 +01:00
cbenthin 27f6d4ede8 updates 2017-02-13 22:29:41 +01:00
cbenthin 166f274706 updates 2017-02-13 16:11:14 +01:00
cbenthin 0c23aa10ad updates 2017-02-11 16:25:27 +01:00
cbenthin f373a08f6a updates 2017-02-11 16:20:42 +01:00
cbenthin 58d967a485 updates 2017-02-11 16:11:52 +01:00
cbenthin f2cce4787b updates 2017-02-11 15:34:09 +01:00
cbenthin 9f1356d39b updates 2017-02-10 17:37:05 +01:00
cbenthin 4b139e7518 Merge branch 'devel' into hpg2017 2017-02-10 11:04:56 +01:00
cbenthin a158cc6907 updates 2017-02-09 22:16:32 +01:00
cbenthin 5efc849353 Merge branch 'devel' into hpg2017 2017-02-09 12:00:27 +01:00
cbenthin 538fd546c3 updates: 2017-02-08 22:35:35 +01:00
cbenthin 13022b6f90 updates 2017-02-08 18:59:31 +01:00
cbenthin 3e8fa0a7c8 Merge branch 'devel' into hpg2017 2017-02-08 15:51:42 +01:00
cbenthin 602ba53314 Merge branch 'devel' into hpg2017 2017-02-08 14:39:02 +01:00
cbenthin 11c3b08a0f compile fix 2017-02-06 16:46:09 +01:00
cbenthin 0249967ebb Merge branch 'devel' into hpg2017 2017-02-06 16:31:00 +01:00
cbenthin 3ceb6cdb8d sync 2017-02-03 10:38:30 +01:00
cbenthin 1fec174297 Merge branch 'devel' into hpg2017 2017-02-01 11:20:23 +01:00
cbenthin e755170fd9 sync 2017-02-01 11:19:59 +01:00
cbenthin 48def083c9 updates 2017-01-26 16:13:53 +01:00
cbenthin 94c665accf first version of edge detection 2017-01-25 19:22:31 +01:00
cbenthin 125a2223ee test 2017-01-25 14:23:01 +01:00
304 changed files with 12329 additions and 24145 deletions

No files matched your search

+81
View File
@@ -0,0 +1,81 @@
# have to disable proxy servers as otherwise CDash commits fail
before_script:
- export http_proxy=
- export https_proxy=
build-centos6-gcc:
script:
- "./scripts/test.py platform:x64 build:RelWithDebInfo compiler:ICC isa:SSE2 tasking:TBB"
#####################################################################
# WINDOWS
####################################################################
.windows-x64-RelWithDebInfo-V140-AVX2-TBB:
script: "./sripts/test.py platform:x64 build:RelWithDebInfo compiler:V140 isa:AVX2 tasking:TBB intensive:OFF"
tags: [win, v140]
.windows-x64-RelWithDebInfo-V120-AVX2-TBB:
script: "./scripts/test.py platform:x64 build:RelWithDebInfo compiler:V120 isa:AVX2 tasking:TBB intensive:OFF"
tags: [win, v120]
.windows-x64-RelWithDebInfo-ICC17-AVX2-TBB:
script: "./scripts/test.py platform:x64 build:RelWithDebInfo compiler:ICC17 isa:AVX2 tasking:TBB intensive:OFF"
tags: [win, icc17]
.windows-x64-RelWithDebInfo-CLANG-AVX2-TBB:
script: "./scripts/test.py platform:x64 build:RelWithDebInfo compiler:CLANG isa:AVX2 tasking:TBB intensive:OFF"
tags: [win, clang]
#####################################################################
# MACOSX
####################################################################
.macosx-x64-RelWithDebInfo-CLANG-AVX2:
script: "./scripts/test.py platform:x64 build:RelWithDebInfo compiler:CLANG isa:AVX2 tasking:TBB intensive:OFF"
tags: [macosx, clang]
.macosx-x64-RelWithDebInfo-ICC16-AVX2:
script: "./scripts/test.py platform:x64 build:RelWithDebInfo compiler:ICC16 isa:AVX2 tasking:TBB intensive:OFF"
tags: [macosx, icc16]
#####################################################################
# LINUX
####################################################################
.linux-x64-RelWithDebInfo-CLANG-AVX2-TBB:
script: "./scripts/test.py platform:x64 build:RelWithDebInfo compiler:CLANG isa:AVX2 tasking:TBB intensive:OFF"
tags: [linux, clang]
.linux-x64-RelWithDebInfo-GCC-AVX2-TBB:
script: "./scripts/test.py platform:x64 build:RelWithDebInfo compiler:GCC isa:AVX2 tasking:TBB intensive:OFF"
tags: [linux, gcc]
.linux-x64-RelWithDebInfo-ICC17-AVX512KNL-TBB:
script: "./scripts/test.py platform:x64 build:RelWithDebInfo compiler:ICC17 isa:AVX512KNL tasking:TBB intensive:OFF"
tags: [linux, icc17]
.linux-x64-RelWithDebInfo-ICC17-AVX2-TBB-KLOCKWORK:
script: "./scripts/test.py platform:x64 build:RelWithDebInfo compiler:ICC17 isa:AVX2 tasking:TBB klocwork:ON"
tags: [linux, icc17, klocwork]
.linux-knl-x64-RelWithDebInfo-ICC17-AVX512KNL-TBB:
script: "./scripts/test.py platform:x64 build:RelWithDebInfo compiler:ICC17 isa:AVX512KNL tasking:TBB intensive:OFF"
tags: [linux, knl, icc17]
.linux-knl-x64-RelWithDebInfo-CLANG4-AVX512KNL-TBB:
script: "./scripts/test.py platform:x64 build:RelWithDebInfo compiler:CLANG4 isa:AVX512KNL tasking:TBB intensive:OFF"
tags: [linux, knl, clang4]
.linux-skx-x64-RelWithDebInfo-ICC17-AVX512SKX-TBB:
script: "./scripts/test.py platform:x64 build:RelWithDebInfo compiler:ICC17 isa:AVX512SKX tasking:TBB intensive:OFF"
tags: [linux, skx, icc17]
.linux-skx-x64-RelWithDebInfo-CLANG4-AVX512SKX-TBB:
script: "./scripts/test.py platform:x64 build:RelWithDebInfo compiler:CLANG4 isa:AVX512SKX tasking:TBB intensive:OFF"
tags: [linux, skx, clang4]
+153 -55
View File
@@ -1,13 +1,130 @@
Version History
---------------
### New Features in Embree 2.17.0
- Improved packet ray tracing performance for coherent rays by 10-60%
(requires RTC_INTERSECT_COHERENT flag).
- Improved ray tracing performance for incoherent rays on
AVX-512 architectures by 5%.
- Improved ray tracing performance for streams of incoherent rays
by 5-15%.
- Fixed tbb_debug.lib linking error under Windows.
- Fast coherent ray stream and packet code paths now also work in robust mode.
- Using less agressive prefetching for large BVH nodes which
results in 1-2% higher ray tracing performance.
- Precompiled binaries have stack-protector enabled, except for
traversal kernels. BVH builders can be slightly slower due to this
change. If you want stack-protectors disabled please turn off
EMBREE_STACK_PROTECTOR in cmake and build the binaries yourself.
- When enabling ISAs individually, the 8-wide BVH was previously only
available when the AVX ISA was also selected. This issue is now
fixed, and one can enable only AVX2 and still get best
performance by using an 8-wide BVH.
- Fixed rtcOccluded1 and rtcOccluded1Ex API functions which were
broken in ISPC.
### 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`
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
@@ -16,20 +133,21 @@ Version History
memory monitor callback function which additionally get passed a
user provided pointer. (`rtcDeviceSetMemoryMonitorFunction` is now
deprecated).
- Build performance for hair geometry improved up to 2x.
- Added API extension to use internal Morton builder, standard SAH
builder, and spatial split SAH builder.
- 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 Bezier or BSpline basis internally, and converts other
curves, which requiring 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 an application side
tbb::taskscheduler_init object is now working properly.
- Windows and Linux releases are build using AVX512 support.
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.
- AVX512 code compiles with Clang 4.0.0
- 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
@@ -49,14 +167,14 @@ Version History
- 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.
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.
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.
@@ -70,8 +188,8 @@ Version History
- 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.
- 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.
@@ -106,8 +224,8 @@ Version History
- 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.
@@ -124,12 +242,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.
@@ -140,8 +258,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.
@@ -162,26 +280,29 @@ Version History
- 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 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.
@@ -295,7 +416,7 @@ Version History
- Improved mixed AABB/OBB-BVH for hair geometry (Xeon Phi)
- Reduced amount of pre-allocated memory for BVH builders (Xeon Phi)
- New 64 bit Morton code-based BVH builder (Xeon Phi)
- New 64-bit Morton code-based BVH builder (Xeon Phi)
- (Enhanced) Morton code-based BVH builders use now tree rotations to
improve BVH quality (Xeon Phi)
- Bug fixes (Xeon and Xeon Phi)
@@ -351,29 +472,6 @@ 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
+46 -25
View File
@@ -15,9 +15,9 @@
## ======================================================================== ##
SET(EMBREE_VERSION_MAJOR 2)
SET(EMBREE_VERSION_MINOR 16)
SET(EMBREE_VERSION_PATCH 0)
SET(EMBREE_VERSION_NOTE "-alpha.3")
SET(EMBREE_VERSION_MINOR 17)
SET(EMBREE_VERSION_PATCH 1)
SET(EMBREE_VERSION_NOTE "-alpha.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)
@@ -43,8 +43,12 @@ IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git)
ENDIF()
CONFIGURE_FILE(
"${PROJECT_SOURCE_DIR}/kernels/version.h.in"
"${PROJECT_BINARY_DIR}/version.h"
"${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"
)
FILE(WRITE "${PROJECT_BINARY_DIR}/hash" "${EMBREE_HASH}")
@@ -74,11 +78,14 @@ 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." OFF)
OPTION(EMBREE_STATIC_LIB "Build Embree as a static library.")
MARK_AS_ADVANCED(CLEAR EMBREE_STATIC_LIB)
ELSE()
OPTION(EMBREE_STATIC_LIB "Build Embree as a static library." ON)
SET(EMBREE_STATIC_LIB ON CACHE BOOL "Build Embree as a static library." FORCE)
MARK_AS_ADVANCED(EMBREE_STATIC_LIB)
ENDIF()
IF (EMBREE_STATIC_LIB)
SET(EMBREE_LIB_TYPE STATIC)
@@ -94,6 +101,7 @@ 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.")
@@ -161,12 +169,12 @@ ENDIF()
SET_PROPERTY(CACHE EMBREE_MAX_ISA PROPERTY STRINGS NONE SSE2 SSE4.2 AVX AVX2 AVX512KNL AVX512SKX)
IF (EMBREE_MAX_ISA STREQUAL "NONE")
SET(EMBREE_ISA_SSE2 "OFF" CACHE BOOL "Enables SSE2 ISA.")
SET(EMBREE_ISA_SSE42 "OFF" CACHE BOOL "Enables SSE4.2 ISA.")
SET(EMBREE_ISA_AVX "OFF" CACHE BOOL "Enables AVX ISA.")
SET(EMBREE_ISA_AVX2 "OFF" CACHE BOOL "Enables AVX2 ISA.")
SET(EMBREE_ISA_AVX512KNL "OFF" CACHE BOOL "Enables AVX512 ISA for Knights Landing.")
SET(EMBREE_ISA_AVX512SKX "OFF" CACHE BOOL "Enables AVX512 ISA for Skylake.")
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:")
@@ -279,53 +287,66 @@ ENDIF (WIN32)
# ISA configuration continued
##############################################################
SET(SSE2 0)
SET(SSE42 1)
SET(AVX 2)
SET(AVX2 3)
SET(AVX512KNL 4)
SET(AVX512SKX 5)
UNSET(FLAGS_LOWEST)
IF (EMBREE_ISA_SSE2)
ADD_DEFINITIONS(-D__TARGET_SSE2__)
ADD_DEFINITIONS(-DEMBREE_TARGET_SSE2)
LIST(APPEND ISPC_TARGETS "sse2")
IF(NOT FLAGS_LOWEST)
SET(FLAGS_LOWEST ${FLAGS_SSE2})
SET(ISA_LOWEST ${SSE2})
SET(FLAGS_LOWEST ${FLAGS_SSE2})
ENDIF()
ENDIF()
IF (EMBREE_ISA_SSE42)
ADD_DEFINITIONS(-D__TARGET_SSE42__)
ADD_DEFINITIONS(-DEMBREE_TARGET_SSE42)
LIST(APPEND ISPC_TARGETS "sse4")
IF(NOT FLAGS_LOWEST)
SET(FLAGS_LOWEST ${FLAGS_SSE42})
SET(ISA_LOWEST ${SSE42})
SET(FLAGS_LOWEST ${FLAGS_SSE42})
ENDIF()
ENDIF ()
IF (EMBREE_ISA_AVX)
ADD_DEFINITIONS(-D__TARGET_AVX__)
ADD_DEFINITIONS(-DEMBREE_TARGET_AVX)
LIST(APPEND ISPC_TARGETS "avx")
IF(NOT FLAGS_LOWEST)
SET(FLAGS_LOWEST ${FLAGS_AVX})
SET(ISA_LOWEST ${AVX})
SET(FLAGS_LOWEST ${FLAGS_AVX})
ENDIF()
ENDIF ()
IF (EMBREE_ISA_AVX2)
ADD_DEFINITIONS(-D__TARGET_AVX2__)
ADD_DEFINITIONS(-DEMBREE_TARGET_AVX2)
LIST(APPEND ISPC_TARGETS "avx2")
IF(NOT FLAGS_LOWEST)
SET(FLAGS_LOWEST ${FLAGS_AVX2})
SET(ISA_LOWEST ${AVX2})
SET(FLAGS_LOWEST ${FLAGS_AVX2})
ENDIF()
ENDIF ()
IF (EMBREE_ISA_AVX512KNL)
ADD_DEFINITIONS(-D__TARGET_AVX512KNL__)
ADD_DEFINITIONS(-DEMBREE_TARGET_AVX512KNL)
LIST(APPEND ISPC_TARGETS "avx512knl-i32x16")
IF(NOT FLAGS_LOWEST)
SET(FLAGS_LOWEST ${FLAGS_AVX512KNL})
SET(ISA_LOWEST ${AVX512KNL})
SET(FLAGS_LOWEST ${FLAGS_AVX512KNL})
ENDIF()
ENDIF ()
IF (EMBREE_ISA_AVX512SKX)
ADD_DEFINITIONS(-D__TARGET_AVX512SKX__)
ADD_DEFINITIONS(-DEMBREE_TARGET_AVX512SKX)
LIST(APPEND ISPC_TARGETS "avx512skx-i32x16")
IF(NOT FLAGS_LOWEST)
SET(FLAGS_LOWEST ${FLAGS_AVX512SKX})
SET(ISA_LOWEST ${AVX512SKX})
SET(FLAGS_LOWEST ${FLAGS_AVX512SKX})
ENDIF()
ENDIF ()
+1 -1
View File
@@ -16,7 +16,7 @@
set(CTEST_PROJECT_NAME "Embree")
set(CTEST_NIGHTLY_START_TIME "22:00:00 UTC")
set(TEST_MODELS_HASH 208ffea4545822ac58015d215b19927ee9449918)
set(TEST_MODELS_HASH 01ada7ec1ace15ddba73aaab3f53ac6aac6a0309)
IF (NOT CTEST_DROP_SITE)
set(CTEST_DROP_METHOD "http")
+333 -235
View File
File diff suppressed because it is too large. Load diff
+1
View File
@@ -15,6 +15,7 @@
## ======================================================================== ##
ADD_SUBDIRECTORY(sys)
ADD_SUBDIRECTORY(math)
ADD_SUBDIRECTORY(simd)
ADD_SUBDIRECTORY(lexers)
ADD_SUBDIRECTORY(tasking)
+8 -6
View File
@@ -33,29 +33,31 @@ namespace embree
for (size_t N=10; N<1000000; N=size_t(2.1*N))
{
size_t N0 = rand() % 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++)
for (size_t i=N0; i<N; i++)
if (pred(src[i]))
m[src[i]] = 0;
for (size_t i=0; i<N; i++)
for (size_t i=N0; 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);
//size_t M = sequential_filter(src.data(),N0,N,pred);
size_t M = parallel_filter(src.data(),N0,N,size_t(1024),pred);
/* check if filtered data is correct */
for (size_t i=0; i<M; i++) {
for (size_t i=N0; i<M; i++) {
passed &= pred(src[i]);
m[src[i]]--;
}
for (size_t i=0; i<M; i++)
for (size_t i=N0; i<M; i++)
passed &= (m[src[i]] == 0);
}
+6 -3
View File
@@ -76,8 +76,8 @@ namespace embree
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);
Index dst = begin+(taskIndex+0)*(end-begin)/taskCount+nused[taskIndex];
Index dst_end = min(dst+nfree[taskIndex],begin+sused);
if (dst_end <= dst) return;
/* range of misplaced elements to copy to destination */
@@ -92,7 +92,10 @@ namespace embree
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];
Index isrc = src-i+k0-1;
assert(dst >= begin && dst < end);
assert(isrc >= begin && isrc < end);
data[dst++] = data[isrc];
}
k0 = k1;
}
+59 -8
View File
@@ -14,13 +14,36 @@
## limitations under the License. ##
## ======================================================================== ##
IF (NOT TBB_ROOT)
SET(TBB_ROOT $ENV{TBB_ROOT})
ENDIF()
IF (NOT TBB_ROOT)
SET(TBB_ROOT $ENV{TBBROOT})
ENDIF()
IF (WIN32)
# workaround for parentheses in variable name / CMP0053
SET(PROGRAMFILESx86 "PROGRAMFILES(x86)")
SET(PROGRAMFILES32 "$ENV{${PROGRAMFILESx86}}")
IF (NOT PROGRAMFILES32)
SET(PROGRAMFILES32 "$ENV{PROGRAMFILES}")
ENDIF()
IF (NOT PROGRAMFILES32)
SET(PROGRAMFILES32 "C:/Program Files (x86)")
ENDIF()
FIND_PATH(EMBREE_TBB_ROOT include/tbb/tbb.h
DOC "Root of TBB installation"
PATHS ${PROJECT_SOURCE_DIR}/tbb "C:/Program Files (x86)/Intel/Composer XE/tbb"
PATHS ${PROJECT_SOURCE_DIR}/tbb
NO_DEFAULT_PATH
)
FIND_PATH(EMBREE_TBB_ROOT include/tbb/tbb.h)
FIND_PATH(EMBREE_TBB_ROOT include/tbb/tbb.h
HINTS ${TBB_ROOT}
PATHS
${PROJECT_SOURCE_DIR}/../tbb
"${PROGRAMFILES32}/IntelSWTools/compilers_and_libraries/windows/tbb"
"${PROGRAMFILES32}/Intel/Composer XE/tbb"
"${PROGRAMFILES32}/Intel/compilers_and_libraries/windows/tbb"
)
IF (CMAKE_SIZEOF_VOID_P EQUAL 8)
SET(TBB_ARCH intel64)
@@ -32,8 +55,10 @@ IF (WIN32)
SET(TBB_VCVER vc10)
ELSEIF (MSVC11)
SET(TBB_VCVER vc11)
ELSE()
ELSEIF (MSVC12)
SET(TBB_VCVER vc12)
ELSE()
SET(TBB_VCVER vc14)
ENDIF()
SET(TBB_LIBDIR ${EMBREE_TBB_ROOT}/lib/${TBB_ARCH}/${TBB_VCVER})
@@ -56,15 +81,40 @@ 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
NO_DEFAULT_PATH
)
FIND_PATH(EMBREE_TBB_ROOT include/tbb/tbb.h)
FIND_PATH(EMBREE_TBB_ROOT include/tbb/tbb.h
DOC "Root of TBB installation"
HINTS ${TBB_ROOT}
PATHS
${PROJECT_SOURCE_DIR}/tbb
/opt/intel/composerxe/tbb
/opt/intel/compilers_and_libraries/tbb
/opt/intel/tbb
)
IF (EMBREE_TBB_ROOT STREQUAL "")
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}/cmake/TBBBuild.cmake)
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)
@@ -75,8 +125,9 @@ ELSE ()
FIND_LIBRARY(TBB_LIBRARY_MALLOC tbbmalloc PATHS ${EMBREE_TBB_ROOT}/lib NO_DEFAULT_PATH)
ELSE()
FIND_PATH(TBB_INCLUDE_DIR tbb/task_scheduler_init.h PATHS ${EMBREE_TBB_ROOT}/include NO_DEFAULT_PATH)
FIND_LIBRARY(TBB_LIBRARY tbb PATHS ${EMBREE_TBB_ROOT}/lib/intel64/gcc4.4 ${EMBREE_TBB_ROOT}/lib ${EMBREE_TBB_ROOT}/lib64 /usr/libx86_64-linux-gnu/ NO_DEFAULT_PATH)
FIND_LIBRARY(TBB_LIBRARY_MALLOC tbbmalloc PATHS ${EMBREE_TBB_ROOT}/lib/intel64/gcc4.4 ${EMBREE_TBB_ROOT}/lib ${EMBREE_TBB_ROOT}/lib64 /usr/libx86_64-linux-gnu/ NO_DEFAULT_PATH)
SET(TBB_HINTS HINTS ${EMBREE_TBB_ROOT}/lib/intel64/gcc4.4 ${EMBREE_TBB_ROOT}/lib ${EMBREE_TBB_ROOT}/lib64 PATHS /usr/libx86_64-linux-gnu/)
FIND_LIBRARY(TBB_LIBRARY tbb ${TBB_HINTS})
FIND_LIBRARY(TBB_LIBRARY_MALLOC tbbmalloc ${TBB_HINTS})
ENDIF()
ENDIF()
@@ -100,7 +151,7 @@ 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)
+2 -1
View File
@@ -23,7 +23,8 @@ string(REPLACE "\n" ";" output ${output})
foreach (line ${output})
if ("${line}" MATCHES "O .bss")
if (NOT "${line}" MATCHES "std::__ioinit")
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()
+85 -13
View File
@@ -26,13 +26,48 @@ SET(FLAGS_AVX512SKX "-march=skx")
IF (WIN32)
SET(COMMON_CXX_FLAGS "/EHsc /GR -Xclang -fcxx-exceptions")
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 /Oi /Gy -fno-vectorize")
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${COMMON_CXX_FLAGS} /Ox /Oi /Gy -fno-vectorize")
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()
MACRO(DISABLE_STACK_PROTECTOR_FOR_FILE file)
IF (EMBREE_STACK_PROTECTOR)
SET_SOURCE_FILES_PROPERTIES(${file} PROPERTIES COMPILE_FLAGS "/GS-")
ENDIF()
ENDMACRO()
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_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /DEBUG")
SET(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} /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)
@@ -43,16 +78,53 @@ ELSE()
SET(CMAKE_CXX_FLAGS "")
ENDIF()
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 -fno-vectorize")
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-DDEBUG -DTBB_USE_DEBUG -g -O3 -fno-vectorize")
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()
MACRO(DISABLE_STACK_PROTECTOR_FOR_FILE file)
IF (EMBREE_STACK_PROTECTOR)
SET_SOURCE_FILES_PROPERTIES(${file} PROPERTIES COMPILE_FLAGS "-fno-stack-protector")
ENDIF()
ENDMACRO()
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 ") # we only use MacOSX 10.7 features
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++" ) # link against C++11 stdlib
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")
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()
+2 -2
View File
@@ -15,8 +15,8 @@
## ======================================================================== ##
SET(FLAGS_SSE2 "-target-cpu=xeon")
SET(FLAGS_SSE42 "ERROR_ISA_NOT_SUPPORTED")
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 "ERROR_ISA_NOT_SUPPORTED")
SET(FLAGS_AVX512SKX "-target-cpu=x86-skylake")
+1
View File
@@ -15,6 +15,7 @@
## ======================================================================== ##
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@)
+44 -8
View File
@@ -26,16 +26,52 @@ IF (EMBREE_IGNORE_CMAKE_CXX_FLAGS)
SET(CMAKE_CXX_FLAGS "")
ENDIF()
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 -fno-tree-vectorize")
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-DDEBUG -DTBB_USE_DEBUG -g -O3 -fno-tree-vectorize")
SET(CMAKE_EXE_LINKER_FLAGS "")
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()
MACRO(DISABLE_STACK_PROTECTOR_FOR_FILE file)
IF (EMBREE_STACK_PROTECTOR)
SET_SOURCE_FILES_PROPERTIES(${file} PROPERTIES COMPILE_FLAGS "-fno-stack-protector")
ENDIF()
ENDMACRO()
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_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS_INIT} -dynamiclib)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.7 -stdlib=libc++")
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")
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)
+105 -22
View File
@@ -23,27 +23,65 @@ IF (WIN32)
SET(FLAGS_AVX512KNL "/QxMIC-AVX512")
SET(FLAGS_AVX512SKX "/QxCORE-AVX512")
SET(COMMON_CXX_FLAGS "/EHsc /MP /GR /GS-")
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()
MACRO(DISABLE_STACK_PROTECTOR_FOR_FILE file)
IF (EMBREE_STACK_PROTECTOR)
SET_SOURCE_FILES_PROPERTIES(${file} PROPERTIES COMPILE_FLAGS "/GS-")
ENDIF()
ENDMACRO()
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
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 /Oi /Gy /Qinline-max-total-size- /Qinline-factor=200 /Qvec- ")
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${COMMON_CXX_FLAGS} /Ox /Oi /Gy /Qinline-max-total-size- /Qinline-factor=200 /Qvec- ")
SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /DEBUG")
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_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=150") # increase default inline factors by 2x
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=150") # 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
SET(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} /DEBUG")
INCLUDE(msvc_post)
ELSE()
IF (APPLE)
SET(FLAGS_SSE2 "-xssse3") # in MacOSX ICC does not support SSE2
SET(FLAGS_SSE2 "-xssse3") # on MacOSX ICC does not support SSE2
ELSE()
SET(FLAGS_SSE2 "-xsse2")
SET(FLAGS_SSE2 "-xsse2")
ENDIF()
SET(FLAGS_SSE42 "-xsse4.2")
SET(FLAGS_AVX "-xAVX")
@@ -55,26 +93,71 @@ ELSE()
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()
MACRO(DISABLE_STACK_PROTECTOR_FOR_FILE file)
IF (EMBREE_STACK_PROTECTOR)
SET_SOURCE_FILES_PROPERTIES(${file} PROPERTIES COMPILE_FLAGS "-fno-stack-protector")
ENDIF()
ENDMACRO()
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fPIC -std=c++11 -fvisibility-inlines-hidden -fvisibility=hidden -no-ansi-alias -fasm-blocks")
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 -no-inline-max-per-compile -no-vec")
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-DDEBUG -DTBB_USE_DEBUG -g -O3 -restrict -no-inline-max-total-size -inline-factor=200 -no-inline-max-per-compile -no-vec")
# Don't change linker flags used by Cray wrappers
IF(NOT CMAKE_CXX_COMPILER_WRAPPER STREQUAL "CrayPrgEnv")
# enable -static-intel and -no-intel-extensions to void to export ICC specific symbols from Embree
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-intel -no-intel-extensions")
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=150") # 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=150") # 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 ") # we only use MacOSX 10.7 features
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++" ) # link against C++11 stdlib
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")
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()
+39 -6
View File
@@ -19,16 +19,49 @@ 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")
SET(COMMON_CXX_FLAGS "/EHsc /MP /GR /GS- ${FLAGS_SSE2}")
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
ELSE()
SET(COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} /GS-") # do not protect against return address overrides
ENDIF()
MACRO(DISABLE_STACK_PROTECTOR_FOR_FILE file)
IF (EMBREE_STACK_PROTECTOR)
SET_SOURCE_FILES_PROPERTIES(${file} PROPERTIES COMPILE_FLAGS "/GS-")
ENDIF()
ENDMACRO()
SET(COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} ${FLAGS_SSE2}")
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 /Oi /Gy")
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${COMMON_CXX_FLAGS} /Ox /Oi /Gy")
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)
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_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /DEBUG")
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)
+20 -32
View File
@@ -39,12 +39,7 @@ 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
@@ -99,11 +94,15 @@ 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 embree.lib)
SET(EMBREE_LIBRARY_NAME ${CMAKE_IMPORT_LIBRARY_PREFIX}embree${CMAKE_IMPORT_LIBRARY_SUFFIX})
ELSEIF (APPLE)
SET(EMBREE_LIBRARY_NAME ${CMAKE_SHARED_LIBRARY_PREFIX}embree.${EMBREE_CONFIG_VERSION}${CMAKE_SHARED_LIBRARY_SUFFIX})
ELSE()
SET(EMBREE_LIBRARY_NAME ${CMAKE_SHARED_LIBRARY_PREFIX}embree${CMAKE_SHARED_LIBRARY_SUFFIX})
SET(EMBREE_LIBRARY_NAME ${CMAKE_SHARED_LIBRARY_PREFIX}embree${CMAKE_SHARED_LIBRARY_SUFFIX}.${EMBREE_CONFIG_VERSION})
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
@@ -126,11 +125,12 @@ INSTALL(FILES "${PROJECT_BINARY_DIR}/embree-config-version.cmake" DESTINATION ${
# CPack specific stuff
##############################################################
SET(CPACK_PACKAGE_NAME "Embree")
SET(CPACK_PACKAGE_NAME "Embree Ray Tracing Kernels")
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) # do not disable, stripping symbols is important for security reasons
SET(CMAKE_STRIP "${PROJECT_SOURCE_DIR}/scripts/strip.sh") # needs this to properly strip under MacOSX
SET(CPACK_PACKAGE_VERSION_MAJOR ${EMBREE_VERSION_MAJOR})
SET(CPACK_PACKAGE_VERSION_MINOR ${EMBREE_VERSION_MINOR})
@@ -162,33 +162,19 @@ IF(WIN32)
IF (CMAKE_SIZEOF_VOID_P EQUAL 8)
SET(ARCH x64)
SET(PROGRAMFILES "\$PROGRAMFILES64")
SET(CPACK_PACKAGE_NAME "${CPACK_PACKAGE_NAME} x64")
ELSE()
SET(ARCH win32)
SET(PROGRAMFILES "\$PROGRAMFILES")
SET(CPACK_PACKAGE_NAME "${CPACK_PACKAGE_NAME} Win32")
ENDIF()
# NSIS specific settings
IF (NOT EMBREE_ZIP_MODE)
SET(CPACK_GENERATOR NSIS)
SET(CPACK_GENERATOR WIX)
SET(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}.${ARCH}")
SET(CPACK_COMPONENTS_ALL lib devel examples)
SET(CPACK_NSIS_INSTALL_ROOT "${PROGRAMFILES}\\\\Intel")
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "Embree v${EMBREE_VERSION} ${ARCH}")
SET(CPACK_NSIS_DISPLAY_NAME "Embree v${EMBREE_VERSION} ${ARCH}")
SET(CPACK_NSIS_PACKAGE_NAME "Embree v${EMBREE_VERSION} ${ARCH}")
SET(CPACK_NSIS_URL_INFO_ABOUT http://embree.github.io/)
#SET(CPACK_NSIS_HELP_LINK http://embree.github.io/downloads.html#windows)
SET(CPACK_NSIS_MUI_ICON ${PROJECT_SOURCE_DIR}/scripts/install_windows/icon32.ico)
SET(CPACK_NSIS_CONTACT ${CPACK_PACKAGE_CONTACT})
#SET(CPACK_NSIS_EXTRA_PREINSTALL_COMMANDS ${CPACK_NSIS_EXTRA_PREINSTALL_COMMANDS} "\n CreateDirectory \\\"$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\"")
#SET(CPACK_NSIS_EXTRA_PREINSTALL_COMMANDS ${CPACK_NSIS_EXTRA_PREINSTALL_COMMANDS} "\n CreateDirectory \\\"$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\documentation\\\"")
#SET(CPACK_NSIS_EXTRA_PREINSTALL_COMMANDS ${CPACK_NSIS_EXTRA_PREINSTALL_COMMANDS} "\n CreateDirectory \\\"$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\tutorials\\\" \n")
#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")
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "Intel\\\\Embree v${EMBREE_VERSION} ${ARCH}")
SET(CPACK_WIX_PRODUCT_GUID "331BD5A9-DAD6-486B-A435-18AAB80${EMBREE_VERSION_NUMBER}")
SET(CPACK_WIX_UPGRADE_GUID "331BD5A9-DAD6-486B-A435-18AAB80${EMBREE_VERSION_MAJOR}0000") # upgrade as long as major version is the same
SET(CPACK_WIX_CMAKE_PACKAGE_REGISTRY TRUE)
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()
@@ -231,17 +217,19 @@ ELSEIF(APPLE)
# Linux specific settings
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 "") # ChangeLog of the RPM; also CHANGELOG.md is not in the required format
SET(CPACK_RPM_PACKAGE_ARCHITECTURE x86_64)
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_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
+1 -2
View File
@@ -18,6 +18,5 @@ ADD_LIBRARY(lexers STATIC
stringstream.cpp
tokenstream.cpp
)
TARGET_LINK_LIBRARIES(lexers sys)
TARGET_LINK_LIBRARIES(lexers sys math)
SET_PROPERTY(TARGET lexers PROPERTY FOLDER common)
+20 -17
View File
@@ -32,21 +32,21 @@ namespace embree
class ParseLocation
{
public:
ParseLocation () : fileName(nullptr), lineNumber(-1), colNumber(-1), charNumber(-1) {}
ParseLocation (const char* fileName, ssize_t lineNumber, ssize_t colNumber, ssize_t charNumber)
ParseLocation () : lineNumber(-1), colNumber(-1), charNumber(-1) {}
ParseLocation (std::shared_ptr<std::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;
if (lineNumber >= 0) str += " line " + toString(lineNumber);
if (lineNumber >= 0 && colNumber >= 0) str += " character " + toString(colNumber);
return str;
}
private:
const char* fileName; /// name of the file (or stream) the token is from
std::shared_ptr<std::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
@@ -67,7 +67,7 @@ namespace embree
}
__forceinline void push_back(const std::pair<T,ParseLocation>& v) {
if (past+future == BUF_SIZE) pop_front();
int end = (start+past+future++)%BUF_SIZE;
size_t end = (start+past+future++)%BUF_SIZE;
buffer[end] = v;
}
__forceinline void pop_front() {
@@ -113,10 +113,10 @@ namespace embree
{
public:
StdStream (std::istream& cin, const std::string& name = "std::stream")
: cin(cin), lineNumber(1), colNumber(0), charNumber(0), name(name) {}
: cin(cin), lineNumber(1), colNumber(0), charNumber(0), name(std::shared_ptr<std::string>(new std::string(name))) {}
~StdStream() {}
ParseLocation location() {
return ParseLocation(name.c_str(),lineNumber,colNumber,charNumber);
return ParseLocation(name,lineNumber,colNumber,charNumber);
}
int next() {
int c = cin.get();
@@ -129,7 +129,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::string name; /// name of buffer
std::shared_ptr<std::string> name; /// name of buffer
};
/*! creates a stream from a file */
@@ -138,10 +138,10 @@ namespace embree
public:
FileStream (FILE* file, const std::string& name = "file")
: file(file), lineNumber(1), colNumber(0), charNumber(0), name(name) {}
: file(file), lineNumber(1), colNumber(0), charNumber(0), name(std::shared_ptr<std::string>(new std::string(name))) {}
FileStream (const FileName& fileName)
: lineNumber(1), colNumber(0), charNumber(0), name(fileName.str())
: lineNumber(1), colNumber(0), charNumber(0), name(std::shared_ptr<std::string>(new std::string(fileName.str())))
{
file = fopen(fileName.c_str(),"r");
if (file == nullptr) THROW_RUNTIME_ERROR("cannot open file " + fileName.str());
@@ -150,7 +150,7 @@ namespace embree
public:
ParseLocation location() {
return ParseLocation(name.c_str(),lineNumber,colNumber,charNumber);
return ParseLocation(name,lineNumber,colNumber,charNumber);
}
int next() {
@@ -165,7 +165,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::string name; /// name of buffer
std::shared_ptr<std::string> name; /// name of buffer
};
/*! creates a stream from a string */
@@ -178,7 +178,7 @@ namespace embree
public:
ParseLocation location() {
return ParseLocation(nullptr,lineNumber,colNumber,charNumber);
return ParseLocation(std::shared_ptr<std::string>(),lineNumber,colNumber,charNumber);
}
int next() {
@@ -201,15 +201,18 @@ namespace embree
{
public:
CommandLineStream (int argc, char** argv, const std::string& name = "command line")
: i(0), j(0), charNumber(0), name(name)
: i(0), j(0), charNumber(0), name(std::shared_ptr<std::string>(new std::string(name)))
{
if (argc > 0) charNumber = strlen(argv[0])+1;
if (argc > 0) {
for (size_t i=0; argv[0][i] && i<1024; i++) charNumber++;
charNumber++;
}
for (ssize_t k=1; k<argc; k++) args.push_back(argv[k]);
}
~CommandLineStream() {}
public:
ParseLocation location() {
return ParseLocation(name.c_str(),0,charNumber,charNumber);
return ParseLocation(name,0,charNumber,charNumber);
}
int next() {
if (i == args.size()) return EOF;
@@ -221,6 +224,6 @@ namespace embree
size_t i,j;
std::vector<std::string> args;
ssize_t charNumber; /// the character in the file
std::string name; /// name of buffer
std::shared_ptr<std::string> name; /// name of buffer
};
}
+1 -1
View File
@@ -30,7 +30,7 @@ namespace embree
ParseLocation location() { return cin->loc(); }
std::string next();
private:
__forceinline bool isSeparator(int c) const { return isSepMap[c]; }
__forceinline bool isSeparator(int c) const { return c<256 && isSepMap[c]; }
private:
Ref<Stream<int> > cin; /*! source character stream */
bool isSepMap[256]; /*! map for fast classification of separators */
+2 -2
View File
@@ -160,13 +160,13 @@ namespace embree
std::vector<std::string> symbols;
/*! checks if a character is a separator */
__forceinline bool isSeparator(int c) const { return isSepMap[c]; }
__forceinline bool isSeparator(int c) const { return c<256 && isSepMap[c]; }
/*! checks if a character is a number */
__forceinline bool isDigit(int c) const { return c >= '0' && c <= '9';}
/*! checks if a character is legal for an identifier */
__forceinline bool isAlpha(int c) const { return isAlphaMap[c]; }
__forceinline bool isAlpha(int c) const { return c<256 && isAlphaMap[c]; }
__forceinline bool isAlphaNum(int c) const { return isAlpha(c) || isDigit(c); }
};
}
+18
View File
@@ -0,0 +1,18 @@
## ======================================================================== ##
## 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. ##
## ======================================================================== ##
ADD_LIBRARY(math STATIC constants.cpp)
SET_PROPERTY(TARGET math PROPERTY FOLDER common)
+3 -3
View File
@@ -107,9 +107,9 @@ namespace embree
template<typename L> __forceinline AffineSpaceT<L>& operator /=( AffineSpaceT<L>& a, const AffineSpaceT<L>& b ) { return a = a / b; }
template<typename L> __forceinline AffineSpaceT<L>& operator /=( AffineSpaceT<L>& a, const ScalarT & b ) { return a = a / b; }
template<typename L> __forceinline const VectorT xfmPoint (const AffineSpaceT<L>& m, const VectorT& p) { return madd(VectorT(p.x),m.l.vx,madd(VectorT(p.y),m.l.vy,madd(VectorT(p.z),m.l.vz,m.p))); }
template<typename L> __forceinline const VectorT xfmVector(const AffineSpaceT<L>& m, const VectorT& v) { return xfmVector(m.l,v); }
template<typename L> __forceinline const VectorT xfmNormal(const AffineSpaceT<L>& m, const VectorT& n) { return xfmNormal(m.l,n); }
template<typename L> __forceinline VectorT xfmPoint (const AffineSpaceT<L>& m, const VectorT& p) { return madd(VectorT(p.x),m.l.vx,madd(VectorT(p.y),m.l.vy,madd(VectorT(p.z),m.l.vz,m.p))); }
template<typename L> __forceinline VectorT xfmVector(const AffineSpaceT<L>& m, const VectorT& v) { return xfmVector(m.l,v); }
template<typename L> __forceinline VectorT xfmNormal(const AffineSpaceT<L>& m, const VectorT& n) { return xfmNormal(m.l,n); }
__forceinline const BBox<Vec3fa> xfmBounds(const AffineSpaceT<LinearSpace3<Vec3fa> >& m, const BBox<Vec3fa>& b)
{
+4 -4
View File
@@ -53,8 +53,8 @@ namespace embree
__forceinline Color4 ( const Color4& other ) : m128(other.m128) {}
__forceinline Color4& operator=( const Color4& other ) { m128 = other.m128; return *this; }
__forceinline operator const __m128&( void ) const { return m128; }
__forceinline operator __m128&( void ) { return m128; }
__forceinline operator const __m128&() const { return m128; }
__forceinline operator __m128&() { return m128; }
////////////////////////////////////////////////////////////////////////////////
/// Set
@@ -115,8 +115,8 @@ namespace embree
__forceinline Color ( const Color4& other ) : m128(other.m128) {}
__forceinline Color& operator=( const Color4& other ) { m128 = other.m128; return *this; }
__forceinline operator const __m128&( void ) const { return m128; }
__forceinline operator __m128&( void ) { return m128; }
__forceinline operator const __m128&() const { return m128; }
__forceinline operator __m128&() { return m128; }
////////////////////////////////////////////////////////////////////////////////
/// Set
@@ -14,24 +14,27 @@
// limitations under the License. //
// ======================================================================== //
#pragma once
#include "../common/scene_instance.h"
#include "../common/ray.h"
#include "constants.h"
namespace embree
{
namespace isa
{
template<int K>
struct FastInstanceIntersectorK
{
static void intersect(vint<K>* valid, const Instance* instance, RayK<K>& ray, size_t item);
static void occluded (vint<K>* valid, const Instance* instance, RayK<K>& ray, size_t item);
};
typedef FastInstanceIntersectorK<4> FastInstanceIntersector4;
typedef FastInstanceIntersectorK<8> FastInstanceIntersector8;
typedef FastInstanceIntersectorK<16> FastInstanceIntersector16;
}
TrueTy True;
FalseTy False;
ZeroTy zero;
OneTy one;
NegInfTy neg_inf;
PosInfTy inf;
PosInfTy pos_inf;
NaNTy nan;
UlpTy ulp;
PiTy pi;
OneOverPiTy one_over_pi;
TwoPiTy two_pi;
OneOverTwoPiTy one_over_two_pi;
FourPiTy four_pi;
OneOverFourPiTy one_over_four_pi;
StepTy step;
ReverseStepTy reverse_step;
EmptyTy empty;
UndefinedTy undefined;
}
+78 -36
View File
@@ -32,15 +32,19 @@ namespace embree
/* we consider floating point numbers in that range as valid input numbers */
static float FLT_LARGE = 1.844E18f;
static struct TrueTy {
struct TrueTy {
__forceinline operator bool( ) const { return true; }
} True MAYBE_UNUSED;
};
static struct FalseTy {
extern MAYBE_UNUSED TrueTy True;
struct FalseTy {
__forceinline operator bool( ) const { return false; }
} False MAYBE_UNUSED;
};
extern MAYBE_UNUSED FalseTy False;
static struct ZeroTy
struct ZeroTy
{
__forceinline operator double ( ) const { return 0; }
__forceinline operator float ( ) const { return 0; }
@@ -54,9 +58,11 @@ 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;
};
static struct OneTy
extern MAYBE_UNUSED ZeroTy zero;
struct OneTy
{
__forceinline operator double ( ) const { return 1; }
__forceinline operator float ( ) const { return 1; }
@@ -70,9 +76,11 @@ 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;
};
static struct NegInfTy
extern MAYBE_UNUSED OneTy one;
struct NegInfTy
{
__forceinline operator double ( ) const { return -std::numeric_limits<double>::infinity(); }
__forceinline operator float ( ) const { return -std::numeric_limits<float>::infinity(); }
@@ -87,9 +95,11 @@ 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;
};
static struct PosInfTy
extern MAYBE_UNUSED NegInfTy neg_inf;
struct PosInfTy
{
__forceinline operator double ( ) const { return std::numeric_limits<double>::infinity(); }
__forceinline operator float ( ) const { return std::numeric_limits<float>::infinity(); }
@@ -103,65 +113,97 @@ 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;
};
static struct NaNTy
extern MAYBE_UNUSED PosInfTy inf;
extern MAYBE_UNUSED PosInfTy pos_inf;
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;
};
static struct UlpTy
extern MAYBE_UNUSED NaNTy nan;
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;
};
static struct PiTy
extern MAYBE_UNUSED UlpTy ulp;
struct PiTy
{
__forceinline operator double( ) const { return double(M_PI); }
__forceinline operator float ( ) const { return float(M_PI); }
} pi MAYBE_UNUSED;
};
static struct OneOverPiTy
extern MAYBE_UNUSED PiTy pi;
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;
};
static struct TwoPiTy
extern MAYBE_UNUSED OneOverPiTy one_over_pi;
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;
};
static struct OneOverTwoPiTy
extern MAYBE_UNUSED TwoPiTy two_pi;
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;
};
static struct FourPiTy
extern MAYBE_UNUSED OneOverTwoPiTy one_over_two_pi;
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;
};
static struct OneOverFourPiTy
extern MAYBE_UNUSED FourPiTy four_pi;
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;
};
static struct StepTy {
} step MAYBE_UNUSED;
extern MAYBE_UNUSED OneOverFourPiTy one_over_four_pi;
static struct ReverseStepTy {
} reverse_step MAYBE_UNUSED;
struct StepTy {
};
static struct EmptyTy {
} empty MAYBE_UNUSED;
extern MAYBE_UNUSED StepTy step;
static struct FullTy {
} full MAYBE_UNUSED;
struct ReverseStepTy {
};
extern MAYBE_UNUSED ReverseStepTy reverse_step;
struct EmptyTy {
};
extern MAYBE_UNUSED EmptyTy empty;
struct FullTy {
};
extern MAYBE_UNUSED FullTy full;
struct UndefinedTy {
};
extern MAYBE_UNUSED UndefinedTy undefined;
}
+2 -2
View File
@@ -94,7 +94,7 @@ namespace embree
BBox<T> b0 = lerp(blower0, blower1, lower-ilowerf);
BBox<T> b1 = lerp(bupper1, bupper0, iupperf-upper);
for (size_t i = ilower+1; i < iupper; i++)
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);
@@ -125,7 +125,7 @@ namespace embree
return;
}
for (size_t i = ilower+1; i<iupper; i++)
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);
+2 -2
View File
@@ -58,10 +58,10 @@ namespace embree
__forceinline const LinearSpace2 transposed() const { return LinearSpace2(vx.x,vx.y,vy.x,vy.y); }
/*! returns first row of matrix */
__forceinline const Vector row0() const { return Vector(vx.x,vy.x); }
__forceinline Vector row0() const { return Vector(vx.x,vy.x); }
/*! returns second row of matrix */
__forceinline const Vector row1() const { return Vector(vx.y,vy.y); }
__forceinline Vector row1() const { return Vector(vx.y,vy.y); }
////////////////////////////////////////////////////////////////////////////////
/// Constants
+3 -3
View File
@@ -66,13 +66,13 @@ namespace embree
__forceinline const LinearSpace3 transposed() const { return LinearSpace3(vx.x,vx.y,vx.z,vy.x,vy.y,vy.z,vz.x,vz.y,vz.z); }
/*! returns first row of matrix */
__forceinline const Vector row0() const { return Vector(vx.x,vy.x,vz.x); }
__forceinline Vector row0() const { return Vector(vx.x,vy.x,vz.x); }
/*! returns second row of matrix */
__forceinline const Vector row1() const { return Vector(vx.y,vy.y,vz.y); }
__forceinline Vector row1() const { return Vector(vx.y,vy.y,vz.y); }
/*! returns third row of matrix */
__forceinline const Vector row2() const { return Vector(vx.z,vy.z,vz.z); }
__forceinline Vector row2() const { return Vector(vx.z,vy.z,vz.z); }
////////////////////////////////////////////////////////////////////////////////
/// Constants
+8 -8
View File
@@ -62,15 +62,15 @@ namespace embree
const __m128 a = _mm_set_ss(x);
#if defined(__AVX512VL__)
const __m128 r = _mm_rcp14_ps(a);
const __m128 r = _mm_rcp14_ss(_mm_set_ss(0.0f),a);
#else
const __m128 r = _mm_rcp_ps(a);
const __m128 r = _mm_rcp_ss(a);
#endif
#if defined(__AVX2__)
return _mm_cvtss_f32(_mm_mul_ps(r,_mm_fnmadd_ps(r, a, _mm_set_ss(2.0f))));
return _mm_cvtss_f32(_mm_mul_ss(r,_mm_fnmadd_ss(r, a, _mm_set_ss(2.0f))));
#else
return _mm_cvtss_f32(_mm_mul_ps(r,_mm_sub_ps(_mm_set_ss(2.0f), _mm_mul_ps(r, a))));
return _mm_cvtss_f32(_mm_mul_ss(r,_mm_sub_ss(_mm_set_ss(2.0f), _mm_mul_ss(r, a))));
#endif
}
@@ -87,12 +87,12 @@ namespace embree
{
const __m128 a = _mm_set_ss(x);
#if defined(__AVX512VL__)
const __m128 r = _mm_rsqrt14_ps(a);
const __m128 r = _mm_rsqrt14_ss(_mm_set_ss(0.0f),a);
#else
const __m128 r = _mm_rsqrt_ps(a);
const __m128 r = _mm_rsqrt_ss(a);
#endif
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)));
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)));
return _mm_cvtss_f32(c);
}
+2 -2
View File
@@ -33,7 +33,7 @@ namespace embree
/// Construction
////////////////////////////////////////////////////////////////////////////////
__forceinline QuaternionT ( void ) { }
__forceinline QuaternionT () { }
__forceinline QuaternionT ( const QuaternionT& other ) { r = other.r; i = other.i; j = other.j; k = other.k; }
__forceinline QuaternionT& operator=( const QuaternionT& other ) { r = other.r; i = other.i; j = other.j; k = other.k; return *this; }
@@ -58,7 +58,7 @@ namespace embree
}
/*! returns the rotation axis of the quaternion as a vector */
__forceinline const Vec3<T> v( ) const { return Vec3<T>(i, j, k); }
__forceinline Vec3<T> v( ) const { return Vec3<T>(i, j, k); }
public:
T r, i, j, k;
+12 -24
View File
@@ -100,56 +100,44 @@ namespace embree
}
template<typename Ty>
struct extended_range
struct extended_range : public range<Ty>
{
__forceinline extended_range () {}
__forceinline extended_range (const Ty& begin)
: _begin(begin), _end(begin+1), _ext_end(begin+1) {}
: range<Ty>(begin), _ext_end(begin+1) {}
__forceinline extended_range (const Ty& begin, const Ty& end)
: _begin(begin), _end(end), _ext_end(end) {}
: range<Ty>(begin,end), _ext_end(end) {}
__forceinline extended_range (const Ty& begin, const Ty& end, const Ty& ext_end)
: _begin(begin), _end(end), _ext_end(ext_end) {}
: range<Ty>(begin,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 - _begin;
return _ext_end - range<Ty>::_begin;
}
__forceinline Ty ext_range_size() const {
return _ext_end - _end;
return _ext_end - range<Ty>::_end;
}
__forceinline bool has_ext_range() const {
assert(_ext_end >= _end);
return (_ext_end - _end) > 0;
assert(_ext_end >= range<Ty>::_end);
return (_ext_end - range<Ty>::_end) > 0;
}
__forceinline void set_ext_range(const size_t ext_end){
assert(ext_end >= _end);
assert(ext_end >= range<Ty>::_end);
_ext_end = ext_end;
}
__forceinline void move_right(const size_t plus){
_begin += plus;
_end += plus;
range<Ty>::_begin += plus;
range<Ty>::_end += plus;
_ext_end += plus;
}
@@ -157,6 +145,6 @@ namespace embree
return cout << "extended_range [" << r.begin() << ", " << r.end() << " (" << r.ext_end() << ")]";
}
Ty _begin, _end, _ext_end;
Ty _ext_end;
};
}
+8 -8
View File
@@ -92,15 +92,15 @@ namespace embree
/// Ternary Operators
////////////////////////////////////////////////////////////////////////////////
template<typename T> __forceinline const Vec2<T> madd ( const Vec2<T>& a, const Vec2<T>& b, const Vec2<T>& c) { return Vec2<T>( madd(a.x,b.x,c.x), madd(a.y,b.y,c.y) ); }
template<typename T> __forceinline const Vec2<T> msub ( const Vec2<T>& a, const Vec2<T>& b, const Vec2<T>& c) { return Vec2<T>( msub(a.x,b.x,c.x), msub(a.y,b.y,c.y) ); }
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 Vec2<T> madd ( const Vec2<T>& a, const Vec2<T>& b, const Vec2<T>& c) { return Vec2<T>( madd(a.x,b.x,c.x), madd(a.y,b.y,c.y) ); }
template<typename T> __forceinline Vec2<T> msub ( const Vec2<T>& a, const Vec2<T>& b, const Vec2<T>& c) { return Vec2<T>( msub(a.x,b.x,c.x), msub(a.y,b.y,c.y) ); }
template<typename T> __forceinline 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 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) ); }
template<typename T> __forceinline 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 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 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 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
+36 -32
View File
@@ -77,7 +77,7 @@ namespace embree
select(abs(a.y)<min_rcp_input,T(min_rcp_input),a.y),
select(abs(a.z)<min_rcp_input,T(min_rcp_input),a.z));
}
template<typename T> __forceinline const Vec3<T> rcp_safe(const Vec3<T>& a) { return rcp(zero_fix(a)); }
template<typename T> __forceinline Vec3<T> rcp_safe(const Vec3<T>& a) { return rcp(zero_fix(a)); }
////////////////////////////////////////////////////////////////////////////////
/// Binary Operators
@@ -102,25 +102,25 @@ namespace embree
/// Ternary Operators
////////////////////////////////////////////////////////////////////////////////
template<typename T> __forceinline const Vec3<T> madd ( const Vec3<T>& a, const Vec3<T>& b, const Vec3<T>& c) { return Vec3<T>( madd(a.x,b.x,c.x), madd(a.y,b.y,c.y), madd(a.z,b.z,c.z)); }
template<typename T> __forceinline const Vec3<T> msub ( const Vec3<T>& a, const Vec3<T>& b, const Vec3<T>& c) { return Vec3<T>( msub(a.x,b.x,c.x), msub(a.y,b.y,c.y), msub(a.z,b.z,c.z)); }
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 Vec3<T> madd ( const Vec3<T>& a, const Vec3<T>& b, const Vec3<T>& c) { return Vec3<T>( madd(a.x,b.x,c.x), madd(a.y,b.y,c.y), madd(a.z,b.z,c.z)); }
template<typename T> __forceinline Vec3<T> msub ( const Vec3<T>& a, const Vec3<T>& b, const Vec3<T>& c) { return Vec3<T>( msub(a.x,b.x,c.x), msub(a.y,b.y,c.y), msub(a.z,b.z,c.z)); }
template<typename T> __forceinline 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 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)); }
template<typename T> __forceinline 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 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 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 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
////////////////////////////////////////////////////////////////////////////////
template<typename T> __forceinline const Vec3<T>& operator +=( Vec3<T>& a, const T b ) { a.x += b; a.y += b; a.z += b; return a; }
template<typename T> __forceinline const Vec3<T>& operator +=( Vec3<T>& a, const Vec3<T>& b ) { a.x += b.x; a.y += b.y; a.z += b.z; return a; }
template<typename T> __forceinline const Vec3<T>& operator -=( Vec3<T>& a, const Vec3<T>& b ) { a.x -= b.x; a.y -= b.y; a.z -= b.z; return a; }
template<typename T> __forceinline const Vec3<T>& operator *=( Vec3<T>& a, const T& b ) { a.x *= b ; a.y *= b ; a.z *= b ; return a; }
template<typename T> __forceinline const Vec3<T>& operator /=( Vec3<T>& a, const T& b ) { a.x /= b ; a.y /= b ; a.z /= b ; return a; }
template<typename T> __forceinline Vec3<T>& operator +=( Vec3<T>& a, const T b ) { a.x += b; a.y += b; a.z += b; return a; }
template<typename T> __forceinline Vec3<T>& operator +=( Vec3<T>& a, const Vec3<T>& b ) { a.x += b.x; a.y += b.y; a.z += b.z; return a; }
template<typename T> __forceinline Vec3<T>& operator -=( Vec3<T>& a, const Vec3<T>& b ) { a.x -= b.x; a.y -= b.y; a.z -= b.z; return a; }
template<typename T> __forceinline Vec3<T>& operator *=( Vec3<T>& a, const T& b ) { a.x *= b ; a.y *= b ; a.z *= b ; return a; }
template<typename T> __forceinline Vec3<T>& operator /=( Vec3<T>& a, const T& b ) { a.x /= b ; a.y /= b ; a.z /= b ; return a; }
////////////////////////////////////////////////////////////////////////////////
/// Reduction Operators
@@ -270,66 +270,70 @@ namespace embree
namespace embree
{
template<typename Out, typename In>
__forceinline Vec3<Out> broadcast(const Vec3<In>& a, const size_t k) {
return Vec3<Out>(Out(a.x[k]),Out(a.y[k]),Out(a.z[k]));
__forceinline Vec3<Out> broadcast(const Vec3<In>& a, const size_t k) {
return Vec3<Out>(Out(a.x[k]), Out(a.y[k]), Out(a.z[k]));
}
template<> __forceinline Vec3<float>::Vec3( const Vec3fa& a ) { x = a.x; y = a.y; z = a.z; }
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 ) {
template<> __forceinline Vec3<vfloat4>::Vec3(const Vec3fa& a) {
x = a.x; y = a.y; z = a.z;
}
#elif defined(__SSE__)
template<> __forceinline Vec3<vfloat4>::Vec3( const Vec3fa& a ) {
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 ) {
__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]));
}
template<>
__forceinline Vec3<vfloat4> broadcast<vfloat4,vfloat4>( const Vec3<vfloat4>& a, const size_t k ) {
__forceinline Vec3<vfloat4> broadcast<vfloat4,vfloat4>(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]));
}
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));
template<int i0, int i1, int i2, int i3>
__forceinline 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__)
template<> __forceinline Vec3<vfloat8>::Vec3( const Vec3fa& a ) {
template<>
__forceinline Vec3<vfloat8>::Vec3(const Vec3fa& a) {
x = a.x; y = a.y; z = a.z;
}
__forceinline Vec3<vfloat4> broadcast4f( const Vec3<vfloat8>& a, const size_t k ) {
__forceinline Vec3<vfloat4> broadcast4f(const Vec3<vfloat8>& a, const size_t k) {
return Vec3<vfloat4>(vfloat4::broadcast(&a.x[k]), vfloat4::broadcast(&a.y[k]), vfloat4::broadcast(&a.z[k]));
}
__forceinline Vec3<vfloat8> broadcast8f( const Vec3<vfloat4>& a, const size_t k ) {
__forceinline Vec3<vfloat8> broadcast8f(const Vec3<vfloat4>& a, const size_t k) {
return Vec3<vfloat8>(vfloat8::broadcast(&a.x[k]), vfloat8::broadcast(&a.y[k]), vfloat8::broadcast(&a.z[k]));
}
__forceinline Vec3<vfloat8> broadcast8f( const Vec3<vfloat8>& a, const size_t k ) {
__forceinline Vec3<vfloat8> broadcast8f(const Vec3<vfloat8>& a, const size_t k) {
return Vec3<vfloat8>(vfloat8::broadcast(&a.x[k]), vfloat8::broadcast(&a.y[k]), vfloat8::broadcast(&a.z[k]));
}
template<>
__forceinline Vec3<vfloat8> broadcast<vfloat8,vfloat4>( const Vec3<vfloat4>& a, const size_t k ) {
__forceinline Vec3<vfloat8> broadcast<vfloat8,vfloat4>(const Vec3<vfloat4>& a, const size_t k) {
return Vec3<vfloat8>(vfloat8::broadcast(&a.x[k]), vfloat8::broadcast(&a.y[k]), vfloat8::broadcast(&a.z[k]));
}
template<>
__forceinline Vec3<vfloat8> broadcast<vfloat8,vfloat8>( const Vec3<vfloat8>& a, const size_t k ) {
__forceinline Vec3<vfloat8> broadcast<vfloat8,vfloat8>(const Vec3<vfloat8>& a, const size_t k) {
return Vec3<vfloat8>(vfloat8::broadcast(&a.x[k]), vfloat8::broadcast(&a.y[k]), vfloat8::broadcast(&a.z[k]));
}
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));
template<int i0, int i1, int i2, int i3>
__forceinline 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__)
template<> __forceinline Vec3<vfloat16>::Vec3( const Vec3fa& a ) : x(a.x), y(a.y), z(a.z) {}
template<> __forceinline Vec3<vfloat16>::Vec3(const Vec3fa& a) : x(a.x), y(a.y), z(a.z) {}
#endif
}
+9 -9
View File
@@ -52,8 +52,8 @@ namespace embree
__forceinline Vec3ba( bool a, bool b, bool c)
: m128(_mm_lookupmask_ps[(size_t(c) << 2) | (size_t(b) << 1) | size_t(a)]) {}
__forceinline operator const __m128&( void ) const { return m128; }
__forceinline operator __m128&( void ) { return m128; }
__forceinline operator const __m128&() const { return m128; }
__forceinline operator __m128&() { return m128; }
////////////////////////////////////////////////////////////////////////////////
/// Constants
@@ -75,23 +75,23 @@ namespace embree
/// Unary Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline const Vec3ba operator !( const Vec3ba& a ) { return _mm_xor_ps(a.m128, Vec3ba(embree::True)); }
__forceinline Vec3ba operator !( const Vec3ba& a ) { return _mm_xor_ps(a.m128, Vec3ba(embree::True)); }
////////////////////////////////////////////////////////////////////////////////
/// Binary Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline const Vec3ba operator &( const Vec3ba& a, const Vec3ba& b ) { return _mm_and_ps(a.m128, b.m128); }
__forceinline const Vec3ba operator |( const Vec3ba& a, const Vec3ba& b ) { return _mm_or_ps (a.m128, b.m128); }
__forceinline const Vec3ba operator ^( const Vec3ba& a, const Vec3ba& b ) { return _mm_xor_ps(a.m128, b.m128); }
__forceinline Vec3ba operator &( const Vec3ba& a, const Vec3ba& b ) { return _mm_and_ps(a.m128, b.m128); }
__forceinline Vec3ba operator |( const Vec3ba& a, const Vec3ba& b ) { return _mm_or_ps (a.m128, b.m128); }
__forceinline Vec3ba operator ^( const Vec3ba& a, const Vec3ba& b ) { return _mm_xor_ps(a.m128, b.m128); }
////////////////////////////////////////////////////////////////////////////////
/// Assignment Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline const Vec3ba operator &=( Vec3ba& a, const Vec3ba& b ) { return a = a & b; }
__forceinline const Vec3ba operator |=( Vec3ba& a, const Vec3ba& b ) { return a = a | b; }
__forceinline const Vec3ba operator ^=( Vec3ba& a, const Vec3ba& b ) { return a = a ^ b; }
__forceinline Vec3ba& operator &=( Vec3ba& a, const Vec3ba& b ) { return a = a & b; }
__forceinline Vec3ba& operator |=( Vec3ba& a, const Vec3ba& b ) { return a = a | b; }
__forceinline Vec3ba& operator ^=( Vec3ba& a, const Vec3ba& b ) { return a = a ^ b; }
////////////////////////////////////////////////////////////////////////////////
/// Comparison Operators + Select
+32 -32
View File
@@ -63,13 +63,13 @@ namespace embree
__forceinline explicit Vec3fa( const __m128i a ) : m128(_mm_cvtepi32_ps(a)) {}
__forceinline operator const __m128&( void ) const { return m128; }
__forceinline operator __m128&( void ) { return m128; }
__forceinline operator const __m128&() const { return m128; }
__forceinline operator __m128&() { return m128; }
#if defined (__SSE4_1__)
friend __forceinline const Vec3fa copy_a( const Vec3fa& a, const Vec3fa& b ) { return _mm_insert_ps(a, b, (3 << 4) | (3 << 6)); }
friend __forceinline Vec3fa copy_a( const Vec3fa& a, const Vec3fa& b ) { return _mm_insert_ps(a, b, (3 << 4) | (3 << 6)); }
#else
friend __forceinline const Vec3fa copy_a( const Vec3fa& a, const Vec3fa& b ) { Vec3fa c = a; c.a = b.a; return c; }
friend __forceinline Vec3fa copy_a( const Vec3fa& a, const Vec3fa& b ) { Vec3fa c = a; c.a = b.a; return c; }
#endif
////////////////////////////////////////////////////////////////////////////////
@@ -109,20 +109,20 @@ namespace embree
/// Unary Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline const Vec3fa operator +( const Vec3fa& a ) { return a; }
__forceinline const Vec3fa operator -( const Vec3fa& a ) {
__forceinline Vec3fa operator +( const Vec3fa& a ) { return a; }
__forceinline Vec3fa operator -( const Vec3fa& a ) {
const __m128 mask = _mm_castsi128_ps(_mm_set1_epi32(0x80000000));
return _mm_xor_ps(a.m128, mask);
}
__forceinline const Vec3fa abs ( const Vec3fa& a ) {
__forceinline Vec3fa abs ( const Vec3fa& a ) {
const __m128 mask = _mm_castsi128_ps(_mm_set1_epi32(0x7fffffff));
return _mm_and_ps(a.m128, mask);
}
__forceinline const Vec3fa sign ( const Vec3fa& a ) {
__forceinline 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 )
__forceinline Vec3fa rcp ( const Vec3fa& a )
{
#if defined(__AVX512VL__)
const Vec3fa r = _mm_rcp14_ps(a.m128);
@@ -140,10 +140,10 @@ namespace embree
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 Vec3fa sqrt ( const Vec3fa& a ) { return _mm_sqrt_ps(a.m128); }
__forceinline Vec3fa sqr ( const Vec3fa& a ) { return _mm_mul_ps(a,a); }
__forceinline const Vec3fa rsqrt( const Vec3fa& a )
__forceinline Vec3fa rsqrt( const Vec3fa& a )
{
#if defined(__AVX512VL__)
__m128 r = _mm_rsqrt14_ps(a.m128);
@@ -153,10 +153,10 @@ namespace embree
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) {
__forceinline 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)));
}
__forceinline const Vec3fa rcp_safe(const Vec3fa& a) {
__forceinline Vec3fa rcp_safe(const Vec3fa& a) {
return rcp(zero_fix(a));
}
__forceinline Vec3fa log ( const Vec3fa& a ) {
@@ -171,17 +171,17 @@ namespace embree
/// Binary Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline const Vec3fa operator +( const Vec3fa& a, const Vec3fa& b ) { return _mm_add_ps(a.m128, b.m128); }
__forceinline const Vec3fa operator -( const Vec3fa& a, const Vec3fa& b ) { return _mm_sub_ps(a.m128, b.m128); }
__forceinline const Vec3fa operator *( const Vec3fa& a, const Vec3fa& b ) { return _mm_mul_ps(a.m128, b.m128); }
__forceinline const Vec3fa operator *( const Vec3fa& a, const float b ) { return a * Vec3fa(b); }
__forceinline const Vec3fa operator *( const float a, const Vec3fa& b ) { return Vec3fa(a) * b; }
__forceinline const Vec3fa operator /( const Vec3fa& a, const Vec3fa& b ) { return _mm_div_ps(a.m128,b.m128); }
__forceinline const Vec3fa operator /( const Vec3fa& a, const float b ) { return _mm_div_ps(a.m128,_mm_set1_ps(b)); }
__forceinline const Vec3fa operator /( const float a, const Vec3fa& b ) { return _mm_div_ps(_mm_set1_ps(a),b.m128); }
__forceinline Vec3fa operator +( const Vec3fa& a, const Vec3fa& b ) { return _mm_add_ps(a.m128, b.m128); }
__forceinline Vec3fa operator -( const Vec3fa& a, const Vec3fa& b ) { return _mm_sub_ps(a.m128, b.m128); }
__forceinline Vec3fa operator *( const Vec3fa& a, const Vec3fa& b ) { return _mm_mul_ps(a.m128, b.m128); }
__forceinline Vec3fa operator *( const Vec3fa& a, const float b ) { return a * Vec3fa(b); }
__forceinline Vec3fa operator *( const float a, const Vec3fa& b ) { return Vec3fa(a) * b; }
__forceinline Vec3fa operator /( const Vec3fa& a, const Vec3fa& b ) { return _mm_div_ps(a.m128,b.m128); }
__forceinline Vec3fa operator /( const Vec3fa& a, const float b ) { return _mm_div_ps(a.m128,_mm_set1_ps(b)); }
__forceinline Vec3fa operator /( const float a, const Vec3fa& b ) { return _mm_div_ps(_mm_set1_ps(a),b.m128); }
__forceinline const Vec3fa min( const Vec3fa& a, const Vec3fa& b ) { return _mm_min_ps(a.m128,b.m128); }
__forceinline const Vec3fa max( const Vec3fa& a, const Vec3fa& b ) { return _mm_max_ps(a.m128,b.m128); }
__forceinline Vec3fa min( const Vec3fa& a, const Vec3fa& b ) { return _mm_min_ps(a.m128,b.m128); }
__forceinline Vec3fa max( const Vec3fa& a, const Vec3fa& b ) { return _mm_max_ps(a.m128,b.m128); }
#if defined(__SSE4_1__)
__forceinline Vec3fa mini(const Vec3fa& a, const Vec3fa& b) {
@@ -316,12 +316,12 @@ namespace embree
/// Select
////////////////////////////////////////////////////////////////////////////////
__forceinline const Vec3fa select( bool s, const Vec3fa& t, const Vec3fa& f ) {
__forceinline Vec3fa select( bool s, const Vec3fa& t, const Vec3fa& f ) {
__m128 mask = s ? _mm_castsi128_ps(_mm_cmpeq_epi32(_mm_setzero_si128(), _mm_setzero_si128())) : _mm_setzero_ps();
return blendv_ps(f, t, mask);
}
__forceinline const Vec3fa select( const Vec3ba& s, const Vec3fa& t, const Vec3fa& f ) {
__forceinline Vec3fa select( const Vec3ba& s, const Vec3fa& t, const Vec3fa& f ) {
return blendv_ps(f, t, s);
}
@@ -340,13 +340,13 @@ namespace embree
////////////////////////////////////////////////////////////////////////////////
#if defined (__SSE4_1__)
//__forceinline const Vec3fa trunc( const Vec3fa& a ) { return _mm_round_ps(a, _MM_FROUND_TO_NEAREST_INT); }
__forceinline const Vec3fa floor( const Vec3fa& a ) { return _mm_round_ps(a, _MM_FROUND_TO_NEG_INF ); }
__forceinline const Vec3fa ceil ( const Vec3fa& a ) { return _mm_round_ps(a, _MM_FROUND_TO_POS_INF ); }
//__forceinline Vec3fa trunc( const Vec3fa& a ) { return _mm_round_ps(a, _MM_FROUND_TO_NEAREST_INT); }
__forceinline Vec3fa floor( const Vec3fa& a ) { return _mm_round_ps(a, _MM_FROUND_TO_NEG_INF ); }
__forceinline Vec3fa ceil ( const Vec3fa& a ) { return _mm_round_ps(a, _MM_FROUND_TO_POS_INF ); }
#else
//__forceinline const Vec3fa trunc( const Vec3fa& a ) { return Vec3fa(truncf(a.x),truncf(a.y),truncf(a.z)); }
__forceinline const Vec3fa floor( const Vec3fa& a ) { return Vec3fa(floorf(a.x),floorf(a.y),floorf(a.z)); }
__forceinline const Vec3fa ceil ( const Vec3fa& a ) { return Vec3fa(ceilf (a.x),ceilf (a.y),ceilf (a.z)); }
//__forceinline Vec3fa trunc( const Vec3fa& a ) { return Vec3fa(truncf(a.x),truncf(a.y),truncf(a.z)); }
__forceinline Vec3fa floor( const Vec3fa& a ) { return Vec3fa(floorf(a.x),floorf(a.y),floorf(a.z)); }
__forceinline Vec3fa ceil ( const Vec3fa& a ) { return Vec3fa(ceilf (a.x),ceilf (a.y),ceilf (a.z)); }
#endif
////////////////////////////////////////////////////////////////////////////////
+33 -33
View File
@@ -51,8 +51,8 @@ namespace embree
__forceinline Vec3ia( const int x, const int y, const int z) : m128(_mm_set_epi32(z, z, y, x)) {}
__forceinline explicit Vec3ia( const __m128 a ) : m128(_mm_cvtps_epi32(a)) {}
__forceinline operator const __m128i&( void ) const { return m128; }
__forceinline operator __m128i&( void ) { return m128; }
__forceinline operator const __m128i&() const { return m128; }
__forceinline operator __m128i&() { return m128; }
////////////////////////////////////////////////////////////////////////////////
/// Constants
@@ -76,48 +76,48 @@ namespace embree
/// Unary Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline const Vec3ia operator +( const Vec3ia& a ) { return a; }
__forceinline const Vec3ia operator -( const Vec3ia& a ) { return _mm_sub_epi32(_mm_setzero_si128(), a.m128); }
__forceinline Vec3ia operator +( const Vec3ia& a ) { return a; }
__forceinline Vec3ia operator -( const Vec3ia& a ) { return _mm_sub_epi32(_mm_setzero_si128(), a.m128); }
#if defined(__SSSE3__)
__forceinline const Vec3ia abs ( const Vec3ia& a ) { return _mm_abs_epi32(a.m128); }
__forceinline Vec3ia abs ( const Vec3ia& a ) { return _mm_abs_epi32(a.m128); }
#endif
////////////////////////////////////////////////////////////////////////////////
/// Binary Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline const Vec3ia operator +( const Vec3ia& a, const Vec3ia& b ) { return _mm_add_epi32(a.m128, b.m128); }
__forceinline const Vec3ia operator +( const Vec3ia& a, const int b ) { return a+Vec3ia(b); }
__forceinline const Vec3ia operator +( const int a, const Vec3ia& b ) { return Vec3ia(a)+b; }
__forceinline Vec3ia operator +( const Vec3ia& a, const Vec3ia& b ) { return _mm_add_epi32(a.m128, b.m128); }
__forceinline Vec3ia operator +( const Vec3ia& a, const int b ) { return a+Vec3ia(b); }
__forceinline Vec3ia operator +( const int a, const Vec3ia& b ) { return Vec3ia(a)+b; }
__forceinline const Vec3ia operator -( const Vec3ia& a, const Vec3ia& b ) { return _mm_sub_epi32(a.m128, b.m128); }
__forceinline const Vec3ia operator -( const Vec3ia& a, const int b ) { return a-Vec3ia(b); }
__forceinline const Vec3ia operator -( const int a, const Vec3ia& b ) { return Vec3ia(a)-b; }
__forceinline Vec3ia operator -( const Vec3ia& a, const Vec3ia& b ) { return _mm_sub_epi32(a.m128, b.m128); }
__forceinline Vec3ia operator -( const Vec3ia& a, const int b ) { return a-Vec3ia(b); }
__forceinline Vec3ia operator -( const int a, const Vec3ia& b ) { return Vec3ia(a)-b; }
#if defined(__SSE4_1__)
__forceinline const Vec3ia operator *( const Vec3ia& a, const Vec3ia& b ) { return _mm_mullo_epi32(a.m128, b.m128); }
__forceinline const Vec3ia operator *( const Vec3ia& a, const int b ) { return a * Vec3ia(b); }
__forceinline const Vec3ia operator *( const int a, const Vec3ia& b ) { return Vec3ia(a) * b; }
__forceinline Vec3ia operator *( const Vec3ia& a, const Vec3ia& b ) { return _mm_mullo_epi32(a.m128, b.m128); }
__forceinline Vec3ia operator *( const Vec3ia& a, const int b ) { return a * Vec3ia(b); }
__forceinline Vec3ia operator *( const int a, const Vec3ia& b ) { return Vec3ia(a) * b; }
#endif
__forceinline const Vec3ia operator &( const Vec3ia& a, const Vec3ia& b ) { return _mm_and_si128(a.m128, b.m128); }
__forceinline const Vec3ia operator &( const Vec3ia& a, const int b ) { return a & Vec3ia(b); }
__forceinline const Vec3ia operator &( const int a, const Vec3ia& b ) { return Vec3ia(a) & b; }
__forceinline Vec3ia operator &( const Vec3ia& a, const Vec3ia& b ) { return _mm_and_si128(a.m128, b.m128); }
__forceinline Vec3ia operator &( const Vec3ia& a, const int b ) { return a & Vec3ia(b); }
__forceinline Vec3ia operator &( const int a, const Vec3ia& b ) { return Vec3ia(a) & b; }
__forceinline const Vec3ia operator |( const Vec3ia& a, const Vec3ia& b ) { return _mm_or_si128(a.m128, b.m128); }
__forceinline const Vec3ia operator |( const Vec3ia& a, const int b ) { return a | Vec3ia(b); }
__forceinline const Vec3ia operator |( const int a, const Vec3ia& b ) { return Vec3ia(a) | b; }
__forceinline Vec3ia operator |( const Vec3ia& a, const Vec3ia& b ) { return _mm_or_si128(a.m128, b.m128); }
__forceinline Vec3ia operator |( const Vec3ia& a, const int b ) { return a | Vec3ia(b); }
__forceinline Vec3ia operator |( const int a, const Vec3ia& b ) { return Vec3ia(a) | b; }
__forceinline const Vec3ia operator ^( const Vec3ia& a, const Vec3ia& b ) { return _mm_xor_si128(a.m128, b.m128); }
__forceinline const Vec3ia operator ^( const Vec3ia& a, const int b ) { return a ^ Vec3ia(b); }
__forceinline const Vec3ia operator ^( const int a, const Vec3ia& b ) { return Vec3ia(a) ^ b; }
__forceinline Vec3ia operator ^( const Vec3ia& a, const Vec3ia& b ) { return _mm_xor_si128(a.m128, b.m128); }
__forceinline Vec3ia operator ^( const Vec3ia& a, const int b ) { return a ^ Vec3ia(b); }
__forceinline Vec3ia operator ^( const int a, const Vec3ia& b ) { return Vec3ia(a) ^ b; }
__forceinline const Vec3ia operator <<( const Vec3ia& a, const int n ) { return _mm_slli_epi32(a.m128, n); }
__forceinline const Vec3ia operator >>( const Vec3ia& a, const int n ) { return _mm_srai_epi32(a.m128, n); }
__forceinline Vec3ia operator <<( const Vec3ia& a, const int n ) { return _mm_slli_epi32(a.m128, n); }
__forceinline Vec3ia operator >>( const Vec3ia& a, const int n ) { return _mm_srai_epi32(a.m128, n); }
__forceinline const Vec3ia sll ( const Vec3ia& a, const int b ) { return _mm_slli_epi32(a.m128, b); }
__forceinline const Vec3ia sra ( const Vec3ia& a, const int b ) { return _mm_srai_epi32(a.m128, b); }
__forceinline const Vec3ia srl ( const Vec3ia& a, const int b ) { return _mm_srli_epi32(a.m128, b); }
__forceinline Vec3ia sll ( const Vec3ia& a, const int b ) { return _mm_slli_epi32(a.m128, b); }
__forceinline Vec3ia sra ( const Vec3ia& a, const int b ) { return _mm_srai_epi32(a.m128, b); }
__forceinline Vec3ia srl ( const Vec3ia& a, const int b ) { return _mm_srli_epi32(a.m128, b); }
////////////////////////////////////////////////////////////////////////////////
/// Assignment Operators
@@ -173,7 +173,7 @@ namespace embree
/// Select
////////////////////////////////////////////////////////////////////////////////
__forceinline const Vec3ia select( const Vec3ba& m, const Vec3ia& t, const Vec3ia& f ) {
__forceinline Vec3ia select( const Vec3ba& m, const Vec3ia& t, const Vec3ia& f ) {
#if defined(__SSE4_1__)
return _mm_castps_si128(_mm_blendv_ps(_mm_castsi128_ps(f), _mm_castsi128_ps(t), m));
#else
@@ -182,11 +182,11 @@ namespace embree
}
#if defined(__SSE4_1__)
__forceinline const Vec3ia min( const Vec3ia& a, const Vec3ia& b ) { return _mm_min_epi32(a.m128,b.m128); }
__forceinline const Vec3ia max( const Vec3ia& a, const Vec3ia& b ) { return _mm_max_epi32(a.m128,b.m128); }
__forceinline Vec3ia min( const Vec3ia& a, const Vec3ia& b ) { return _mm_min_epi32(a.m128,b.m128); }
__forceinline Vec3ia max( const Vec3ia& a, const Vec3ia& b ) { return _mm_max_epi32(a.m128,b.m128); }
#else
__forceinline const Vec3ia min( const Vec3ia& a, const Vec3ia& b ) { return select(lt_mask(a,b),a,b); }
__forceinline const Vec3ia max( const Vec3ia& a, const Vec3ia& b ) { return select(gt_mask(a,b),a,b); }
__forceinline Vec3ia min( const Vec3ia& a, const Vec3ia& b ) { return select(lt_mask(a,b),a,b); }
__forceinline Vec3ia max( const Vec3ia& a, const Vec3ia& b ) { return select(gt_mask(a,b),a,b); }
#endif
////////////////////////////////////////////////////////////////////////////////
+8 -8
View File
@@ -99,15 +99,15 @@ namespace embree
/// 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 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 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 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 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)); }
template<typename T> __forceinline 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 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 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 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
+2 -2
View File
@@ -74,8 +74,8 @@ namespace embree
template<typename Closure>
__forceinline void foreach2(int x0, int x1, int y0, int y1, const Closure& closure)
{
__aligned(64) int U[128];
__aligned(64) int V[128];
__aligned(64) int U[2*VSIZEX];
__aligned(64) int V[2*VSIZEX];
int index = 0;
for (int y=y0; y<y1; y++) {
const bool lasty = y+1>=y1;
+2 -2
View File
@@ -24,11 +24,11 @@
namespace embree
{
#if defined(__SSE4_1__)
__forceinline __m128 blendv_ps( __m128 f, __m128 t, __m128 mask ) {
__forceinline __m128 blendv_ps(__m128 f, __m128 t, __m128 mask) {
return _mm_blendv_ps(f,t,mask);
}
#else
__forceinline __m128 blendv_ps( __m128 f, __m128 t, __m128 mask ) {
__forceinline __m128 blendv_ps(__m128 f, __m128 t, __m128 mask) {
return _mm_or_ps(_mm_and_ps(mask, t), _mm_andnot_ps(mask, f));
}
#endif
+44 -42
View File
@@ -35,18 +35,18 @@ namespace embree
/// Constructors, Assignment & Cast Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline vboold () {}
__forceinline vboold ( const vboold4& a ) { v = a.v; }
__forceinline vboold4& operator=( const vboold4& a ) { v = a.v; return *this; }
__forceinline vboold() {}
__forceinline vboold(const vboold4& a) { v = a.v; }
__forceinline vboold4& operator =(const vboold4& a) { v = a.v; return *this; }
__forceinline vboold( const __m256d a ) : v(a) {}
__forceinline vboold( const __m256i a ) : v(_mm256_castsi256_pd(a)) {}
__forceinline vboold(__m256d a) : v(a) {}
__forceinline vboold(__m256i a) : v(_mm256_castsi256_pd(a)) {}
__forceinline operator const __m256( void ) const { return _mm256_castpd_ps(v); }
__forceinline operator const __m256i( void ) const { return _mm256_castpd_si256(v); }
__forceinline operator const __m256d( void ) const { return v; }
__forceinline operator const __m256() const { return _mm256_castpd_ps(v); }
__forceinline operator const __m256i() const { return _mm256_castpd_si256(v); }
__forceinline operator const __m256d() const { return v; }
__forceinline vboold ( const int a )
__forceinline vboold(int a)
{
assert(a >= 0 && a <= 255);
#if defined (__AVX2__)
@@ -60,49 +60,49 @@ namespace embree
#endif
}
__forceinline vboold ( const __m128d a, const __m128d b) : vl(a), vh(b) {}
__forceinline vboold(__m128d a, __m128d b) : vl(a), vh(b) {}
////////////////////////////////////////////////////////////////////////////////
/// Constants
////////////////////////////////////////////////////////////////////////////////
__forceinline vboold( FalseTy ) : v(_mm256_setzero_pd()) {}
__forceinline vboold( TrueTy ) : v(_mm256_cmp_pd(_mm256_setzero_pd(), _mm256_setzero_pd(), _CMP_EQ_OQ)) {}
__forceinline vboold(FalseTy) : v(_mm256_setzero_pd()) {}
__forceinline vboold(TrueTy) : v(_mm256_cmp_pd(_mm256_setzero_pd(), _mm256_setzero_pd(), _CMP_EQ_OQ)) {}
////////////////////////////////////////////////////////////////////////////////
/// 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 [](size_t index) const { assert(index < 4); return (_mm256_movemask_pd(v) >> index) & 1; }
__forceinline long long& operator [](size_t index) { assert(index < 4); return i[index]; }
};
////////////////////////////////////////////////////////////////////////////////
/// Unary Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline const vboold4 operator !( const vboold4& a ) { return _mm256_xor_pd(a, vboold4(embree::True)); }
__forceinline vboold4 operator !(const vboold4& a) { return _mm256_xor_pd(a, vboold4(embree::True)); }
////////////////////////////////////////////////////////////////////////////////
/// Binary Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline const vboold4 operator &( const vboold4& a, const vboold4& b ) { return _mm256_and_pd(a, b); }
__forceinline const vboold4 operator |( const vboold4& a, const vboold4& b ) { return _mm256_or_pd (a, b); }
__forceinline const vboold4 operator ^( const vboold4& a, const vboold4& b ) { return _mm256_xor_pd(a, b); }
__forceinline vboold4 operator &(const vboold4& a, const vboold4& b) { return _mm256_and_pd(a, b); }
__forceinline vboold4 operator |(const vboold4& a, const vboold4& b) { return _mm256_or_pd (a, b); }
__forceinline vboold4 operator ^(const vboold4& a, const vboold4& b) { return _mm256_xor_pd(a, b); }
__forceinline vboold4 operator &=( vboold4& a, const vboold4& b ) { return a = a & b; }
__forceinline vboold4 operator |=( vboold4& a, const vboold4& b ) { return a = a | b; }
__forceinline vboold4 operator ^=( vboold4& a, const vboold4& b ) { return a = a ^ b; }
__forceinline vboold4& operator &=(vboold4& a, const vboold4& b) { return a = a & b; }
__forceinline vboold4& operator |=(vboold4& a, const vboold4& b) { return a = a | b; }
__forceinline vboold4& operator ^=(vboold4& a, const vboold4& b) { return a = a ^ b; }
////////////////////////////////////////////////////////////////////////////////
/// Comparison Operators + Select
////////////////////////////////////////////////////////////////////////////////
__forceinline const vboold4 operator !=( const vboold4& a, const vboold4& b ) { return _mm256_xor_pd(a, b); }
__forceinline const vboold4 operator ==( const vboold4& a, const vboold4& b ) { return _mm256_xor_pd(_mm256_xor_pd(a,b),vboold4(embree::True)); }
__forceinline vboold4 operator !=(const vboold4& a, const vboold4& b) { return _mm256_xor_pd(a, b); }
__forceinline vboold4 operator ==(const vboold4& a, const vboold4& b) { return _mm256_xor_pd(_mm256_xor_pd(a,b),vboold4(embree::True)); }
__forceinline const vboold4 select( const vboold4& mask, const vboold4& t, const vboold4& f ) {
__forceinline vboold4 select(const vboold4& mask, const vboold4& t, const vboold4& f) {
return _mm256_blendv_pd(f, t, mask);
}
@@ -110,17 +110,19 @@ namespace embree
/// Movement/Shifting/Shuffling Functions
////////////////////////////////////////////////////////////////////////////////
__forceinline vboold4 unpacklo( const vboold4& a, const vboold4& b ) { return _mm256_unpacklo_pd(a.v, b.v); }
__forceinline vboold4 unpackhi( const vboold4& a, const vboold4& b ) { return _mm256_unpackhi_pd(a.v, b.v); }
__forceinline vboold4 unpacklo(const vboold4& a, const vboold4& b) { return _mm256_unpacklo_pd(a, b); }
__forceinline vboold4 unpackhi(const vboold4& a, const vboold4& b) { return _mm256_unpackhi_pd(a, b); }
#if defined(__AVX2__)
template<size_t i0, size_t i1, size_t i2, size_t i3> __forceinline const vboold4 shuffle( const vboold4& a ) {
return _mm256_permute4x64_pd(a, _MM_SHUFFLE(i3, i2, i1, i0));
template<int i0, int i1, int i2, int i3>
__forceinline vboold4 shuffle(const vboold4& v) {
return _mm256_permute4x64_pd(v, _MM_SHUFFLE(i3, i2, i1, i0));
}
template<size_t i> __forceinline const vboold4 shuffle( const vboold4& a ) {
return _mm256_permute4x64_pd(a, _MM_SHUFFLE(i, i, i, i));
template<int i>
__forceinline vboold4 shuffle(const vboold4& v) {
return _mm256_permute4x64_pd(v, _MM_SHUFFLE(i, i, i, i));
}
#endif
@@ -129,33 +131,33 @@ namespace embree
/// Reduction Operations
////////////////////////////////////////////////////////////////////////////////
__forceinline bool reduce_and( const vboold4& a ) { return _mm256_movemask_pd(a) == (unsigned int)0xf; }
__forceinline bool reduce_or ( const vboold4& a ) { return !_mm256_testz_pd(a,a); }
__forceinline bool reduce_and(const vboold4& a) { return _mm256_movemask_pd(a) == (unsigned int)0xf; }
__forceinline bool reduce_or (const vboold4& a) { return !_mm256_testz_pd(a,a); }
__forceinline bool all ( const vboold4& a ) { return _mm256_movemask_pd(a) == (unsigned int)0xf; }
__forceinline bool any ( const vboold4& a ) { return !_mm256_testz_pd(a,a); }
__forceinline bool none ( const vboold4& a ) { return _mm256_testz_pd(a,a) != 0; }
__forceinline bool all (const vboold4& a) { return _mm256_movemask_pd(a) == (unsigned int)0xf; }
__forceinline bool any (const vboold4& a) { return !_mm256_testz_pd(a,a); }
__forceinline bool none(const vboold4& a) { return _mm256_testz_pd(a,a) != 0; }
__forceinline bool all ( const vboold4& valid, const vboold4& b ) { return all((!valid) | b); }
__forceinline bool any ( const vboold4& valid, const vboold4& b ) { return any( valid & b); }
__forceinline bool none ( const vboold4& valid, const vboold4& b ) { return none(valid & b); }
__forceinline bool all (const vboold4& valid, const vboold4& b) { return all((!valid) | b); }
__forceinline bool any (const vboold4& valid, const vboold4& b) { return any(valid & b); }
__forceinline bool none(const vboold4& valid, const vboold4& b) { return none(valid & b); }
__forceinline unsigned int movemask( const vboold4& a ) { return _mm256_movemask_pd(a); }
__forceinline size_t popcnt ( const vboold4& a ) { return __popcnt((size_t)_mm256_movemask_pd(a)); }
__forceinline unsigned int movemask(const vboold4& a) { return _mm256_movemask_pd(a); }
__forceinline size_t popcnt (const vboold4& a) { return __popcnt((size_t)_mm256_movemask_pd(a)); }
////////////////////////////////////////////////////////////////////////////////
/// Get/Set Functions
////////////////////////////////////////////////////////////////////////////////
__forceinline bool get(const vboold4& a, size_t index) { return a[index]; }
__forceinline void set (vboold4& a, size_t index) { a[index] = -1; }
__forceinline void set (vboold4& a, size_t index) { a[index] = -1; }
__forceinline void clear(vboold4& a, size_t index) { a[index] = 0; }
////////////////////////////////////////////////////////////////////////////////
/// Output Operators
////////////////////////////////////////////////////////////////////////////////
inline std::ostream& operator<<(std::ostream& cout, const vboold4& a) {
inline std::ostream& operator <<(std::ostream& cout, const vboold4& a) {
return cout << "<" << a[0] << ", " << a[1] << ", " << a[2] << ", " << a[3] << ", "
<< a[4] << ", " << a[5] << ", " << a[6] << ", " << a[7] << ">";
}
+25 -25
View File
@@ -33,8 +33,8 @@ namespace embree
////////////////////////////////////////////////////////////////////////////////
__forceinline vboold() {}
__forceinline vboold(const vboold4 &t) { v = t.v; }
__forceinline vboold4& operator=(const vboold4 &f) { v = f.v; return *this; }
__forceinline vboold(const vboold4& t) { v = t.v; }
__forceinline vboold4& operator =(const vboold4& f) { v = f.v; return *this; }
__forceinline vboold(const __mmask8 &t) { v = t; }
__forceinline operator __mmask8() const { return v; }
@@ -62,42 +62,42 @@ namespace embree
/// Constants
////////////////////////////////////////////////////////////////////////////////
__forceinline vboold( FalseTy ) : v(0x0) {}
__forceinline vboold( TrueTy ) : v(0xf) {}
__forceinline vboold(FalseTy) : v(0x0) {}
__forceinline vboold(TrueTy) : v(0xf) {}
};
////////////////////////////////////////////////////////////////////////////////
/// Unary Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline vboold4 operator!(const vboold4 &a) { return _mm512_kandn(a, 0xf); }
__forceinline vboold4 operator !(const vboold4& a) { return _mm512_kandn(a, 0xf); }
////////////////////////////////////////////////////////////////////////////////
/// Binary Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline vboold4 operator&(const vboold4 &a, const vboold4 &b) { return _mm512_kand(a, b); }
__forceinline vboold4 operator|(const vboold4 &a, const vboold4 &b) { return _mm512_kor(a, b); }
__forceinline vboold4 operator^(const vboold4 &a, const vboold4 &b) { return _mm512_kxor(a, b); }
__forceinline vboold4 operator &(const vboold4& a, const vboold4& b) { return _mm512_kand(a, b); }
__forceinline vboold4 operator |(const vboold4& a, const vboold4& b) { return _mm512_kor(a, b); }
__forceinline vboold4 operator ^(const vboold4& a, const vboold4& b) { return _mm512_kxor(a, b); }
__forceinline vboold4 andn(const vboold4 &a, const vboold4 &b) { return _mm512_kandn(b, a); }
__forceinline vboold4 andn(const vboold4& a, const vboold4& b) { return _mm512_kandn(b, a); }
////////////////////////////////////////////////////////////////////////////////
/// Assignment Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline const vboold4 operator &=( vboold4& a, const vboold4& b ) { return a = a & b; }
__forceinline const vboold4 operator |=( vboold4& a, const vboold4& b ) { return a = a | b; }
__forceinline const vboold4 operator ^=( vboold4& a, const vboold4& b ) { return a = a ^ b; }
__forceinline vboold4& operator &=(vboold4& a, const vboold4& b) { return a = a & b; }
__forceinline vboold4& operator |=(vboold4& a, const vboold4& b) { return a = a | b; }
__forceinline vboold4& operator ^=(vboold4& a, const vboold4& b) { return a = a ^ b; }
////////////////////////////////////////////////////////////////////////////////
/// Comparison Operators + Select
////////////////////////////////////////////////////////////////////////////////
__forceinline const vboold4 operator !=( const vboold4& a, const vboold4& b ) { return _mm512_kxor(a, b); }
__forceinline const vboold4 operator ==( const vboold4& a, const vboold4& b ) { return _mm512_kand(_mm512_kxnor(a, b), 0xf); }
__forceinline vboold4 operator !=(const vboold4& a, const vboold4& b) { return _mm512_kxor(a, b); }
__forceinline vboold4 operator ==(const vboold4& a, const vboold4& b) { return _mm512_kand(_mm512_kxnor(a, b), 0xf); }
__forceinline vboold4 select (const vboold4 &s, const vboold4 &a, const vboold4 &b) {
__forceinline vboold4 select(const vboold4& s, const vboold4& a, const vboold4& b) {
return _mm512_kor(_mm512_kand(s, a), _mm512_kandn(s, b));
}
@@ -105,22 +105,22 @@ namespace embree
/// Reduction Operations
////////////////////////////////////////////////////////////////////////////////
__forceinline int all (const vboold4 &a) { return a.v == 0xf; }
__forceinline int any (const vboold4 &a) { return _mm512_kortestz(a, a) == 0; }
__forceinline int none(const vboold4 &a) { return _mm512_kortestz(a, a) != 0; }
__forceinline int all (const vboold4& a) { return a.v == 0xf; }
__forceinline int any (const vboold4& a) { return _mm512_kortestz(a, a) == 0; }
__forceinline int none(const vboold4& a) { return _mm512_kortestz(a, a) != 0; }
__forceinline int all ( const vboold4& valid, const vboold4& b ) { return all((!valid) | b); }
__forceinline int any ( const vboold4& valid, const vboold4& b ) { return any( valid & b); }
__forceinline int none( const vboold4& valid, const vboold4& b ) { return none(valid & b); }
__forceinline int all (const vboold4& valid, const vboold4& b) { return all((!valid) | b); }
__forceinline int any (const vboold4& valid, const vboold4& b) { return any(valid & b); }
__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 movemask(const vboold4& a) { return _mm512_kmov(a); }
__forceinline size_t popcnt (const vboold4& a) { return __popcnt(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
@@ -134,7 +134,7 @@ namespace embree
/// Output Operators
////////////////////////////////////////////////////////////////////////////////
inline std::ostream& operator<<(std::ostream& cout, const vboold4& a)
inline std::ostream& operator <<(std::ostream& cout, const vboold4& a)
{
cout << "<";
for (size_t i=0; i<4; i++) {
+26 -26
View File
@@ -33,10 +33,10 @@ namespace embree
////////////////////////////////////////////////////////////////////////////////
__forceinline vboold() {}
__forceinline vboold(const vboold8 &t) { v = t.v; }
__forceinline vboold8& operator=(const vboold8 &f) { v = f.v; return *this; }
__forceinline vboold(const vboold8& t) { v = t.v; }
__forceinline vboold8& operator =(const vboold8& f) { v = f.v; return *this; }
__forceinline vboold(const __mmask8 &t) { v = t; }
__forceinline vboold(const __mmask8& t) { v = t; }
__forceinline operator __mmask8() const { return v; }
__forceinline vboold(bool b) { v = b ? 0xff : 0x00; }
@@ -70,42 +70,42 @@ namespace embree
/// Constants
////////////////////////////////////////////////////////////////////////////////
__forceinline vboold( FalseTy ) : v(0x00) {}
__forceinline vboold( TrueTy ) : v(0xff) {}
__forceinline vboold(FalseTy) : v(0x00) {}
__forceinline vboold(TrueTy) : v(0xff) {}
};
////////////////////////////////////////////////////////////////////////////////
/// Unary Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline vboold8 operator!(const vboold8 &a) { return _mm512_knot(a); }
__forceinline vboold8 operator !(const vboold8& a) { return _mm512_knot(a); }
////////////////////////////////////////////////////////////////////////////////
/// Binary Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline vboold8 operator&(const vboold8 &a, const vboold8 &b) { return _mm512_kand(a, b); }
__forceinline vboold8 operator|(const vboold8 &a, const vboold8 &b) { return _mm512_kor(a, b); }
__forceinline vboold8 operator^(const vboold8 &a, const vboold8 &b) { return _mm512_kxor(a, b); }
__forceinline vboold8 operator &(const vboold8& a, const vboold8& b) { return _mm512_kand(a, b); }
__forceinline vboold8 operator |(const vboold8& a, const vboold8& b) { return _mm512_kor(a, b); }
__forceinline vboold8 operator ^(const vboold8& a, const vboold8& b) { return _mm512_kxor(a, b); }
__forceinline vboold8 andn(const vboold8 &a, const vboold8 &b) { return _mm512_kandn(b, a); }
__forceinline vboold8 andn(const vboold8& a, const vboold8& b) { return _mm512_kandn(b, a); }
////////////////////////////////////////////////////////////////////////////////
/// Assignment Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline const vboold8 operator &=( vboold8& a, const vboold8& b ) { return a = a & b; }
__forceinline const vboold8 operator |=( vboold8& a, const vboold8& b ) { return a = a | b; }
__forceinline const vboold8 operator ^=( vboold8& a, const vboold8& b ) { return a = a ^ b; }
__forceinline vboold8& operator &=(vboold8& a, const vboold8& b) { return a = a & b; }
__forceinline vboold8& operator |=(vboold8& a, const vboold8& b) { return a = a | b; }
__forceinline vboold8& operator ^=(vboold8& a, const vboold8& b) { return a = a ^ b; }
////////////////////////////////////////////////////////////////////////////////
/// Comparison Operators + Select
////////////////////////////////////////////////////////////////////////////////
__forceinline const vboold8 operator !=( const vboold8& a, const vboold8& b ) { return _mm512_kxor(a, b); }
__forceinline const vboold8 operator ==( const vboold8& a, const vboold8& b ) { return _mm512_kxnor(a, b); }
__forceinline vboold8 operator !=(const vboold8& a, const vboold8& b) { return _mm512_kxor(a, b); }
__forceinline vboold8 operator ==(const vboold8& a, const vboold8& b) { return _mm512_kxnor(a, b); }
__forceinline vboold8 select(const vboold8 &s, const vboold8 &a, const vboold8 &b) {
__forceinline vboold8 select(const vboold8& s, const vboold8& a, const vboold8& b) {
return _mm512_kor(_mm512_kand(s, a), _mm512_kandn(s, b));
}
@@ -113,22 +113,22 @@ namespace embree
/// Reduction Operations
////////////////////////////////////////////////////////////////////////////////
__forceinline int all (const vboold8 &a) { return a.v == 0xff; }
__forceinline int any (const vboold8 &a) { return _mm512_kortestz(a, a) == 0; }
__forceinline int none(const vboold8 &a) { return _mm512_kortestz(a, a) != 0; }
__forceinline int all (const vboold8& a) { return a.v == 0xff; }
__forceinline int any (const vboold8& a) { return _mm512_kortestz(a, a) == 0; }
__forceinline int none(const vboold8& a) { return _mm512_kortestz(a, a) != 0; }
__forceinline int all ( const vboold8& valid, const vboold8& b ) { return all((!valid) | b); }
__forceinline int any ( const vboold8& valid, const vboold8& b ) { return any( valid & b); }
__forceinline int none( const vboold8& valid, const vboold8& b ) { return none(valid & b); }
__forceinline int all (const vboold8& valid, const vboold8& b) { return all((!valid) | b); }
__forceinline int any (const vboold8& valid, const vboold8& b) { return any(valid & b); }
__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 movemask(const vboold8& a) { return _mm512_kmov(a); }
__forceinline size_t popcnt (const vboold8& a) { return __popcnt(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
@@ -142,7 +142,7 @@ namespace embree
/// Output Operators
////////////////////////////////////////////////////////////////////////////////
inline std::ostream& operator<<(std::ostream& cout, const vboold8& a)
inline std::ostream& operator <<(std::ostream& cout, const vboold8& a)
{
cout << "<";
for (size_t i=0; i<8; i++) {
+31 -31
View File
@@ -34,15 +34,15 @@ namespace embree
////////////////////////////////////////////////////////////////////////////////
__forceinline vboolf() {}
__forceinline vboolf(const vboolf16 &t) { v = t.v; }
__forceinline vboolf16& operator=(const vboolf16 &f) { v = f.v; return *this; }
__forceinline vboolf(const vboolf16& t) { v = t.v; }
__forceinline vboolf16& operator =(const vboolf16& f) { v = f.v; return *this; }
__forceinline vboolf(const __mmask16 &t) { v = t; }
__forceinline operator __mmask16 () const { return v; }
__forceinline vboolf(const __mmask16& t) { v = t; }
__forceinline operator __mmask16() const { return v; }
__forceinline vboolf(bool b) { v = b ? 0xFFFF : 0x0000; }
__forceinline vboolf(int t ) { v = (__mmask16)t; }
__forceinline vboolf(unsigned int t ) { v = (__mmask16)t; }
__forceinline vboolf(int t) { v = (__mmask16)t; }
__forceinline vboolf(unsigned int t) { v = (__mmask16)t; }
/* return int8 mask */
__forceinline __m128i mask8() const {
@@ -71,14 +71,14 @@ namespace embree
/// Constants
////////////////////////////////////////////////////////////////////////////////
__forceinline vboolf( FalseTy ) : v(0x0000) {}
__forceinline vboolf( TrueTy ) : v(0xffff) {}
__forceinline vboolf(FalseTy) : v(0x0000) {}
__forceinline vboolf(TrueTy) : v(0xffff) {}
////////////////////////////////////////////////////////////////////////////////
/// Array Access
////////////////////////////////////////////////////////////////////////////////
__forceinline bool operator []( const size_t index ) const {
__forceinline bool operator [](size_t index) const {
assert(index < 16); return (mm512_mask2int(v) >> index) & 1;
}
};
@@ -87,34 +87,34 @@ namespace embree
/// Unary Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline vboolf16 operator!(const vboolf16 &a) { return _mm512_knot(a); }
__forceinline vboolf16 operator !(const vboolf16& a) { return _mm512_knot(a); }
////////////////////////////////////////////////////////////////////////////////
/// Binary Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline vboolf16 operator&(const vboolf16 &a, const vboolf16 &b) { return _mm512_kand(a,b); }
__forceinline vboolf16 operator|(const vboolf16 &a, const vboolf16 &b) { return _mm512_kor(a,b); }
__forceinline vboolf16 operator^(const vboolf16 &a, const vboolf16 &b) { return _mm512_kxor(a,b); }
__forceinline vboolf16 operator &(const vboolf16& a, const vboolf16& b) { return _mm512_kand(a,b); }
__forceinline vboolf16 operator |(const vboolf16& a, const vboolf16& b) { return _mm512_kor(a,b); }
__forceinline vboolf16 operator ^(const vboolf16& a, const vboolf16& b) { return _mm512_kxor(a,b); }
__forceinline vboolf16 andn(const vboolf16 &a, const vboolf16 &b) { return _mm512_kandn(b,a); }
__forceinline vboolf16 andn(const vboolf16& a, const vboolf16& b) { return _mm512_kandn(b,a); }
////////////////////////////////////////////////////////////////////////////////
/// Assignment Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline const vboolf16 operator &=( vboolf16& a, const vboolf16& b ) { return a = a & b; }
__forceinline const vboolf16 operator |=( vboolf16& a, const vboolf16& b ) { return a = a | b; }
__forceinline const vboolf16 operator ^=( vboolf16& a, const vboolf16& b ) { return a = a ^ b; }
__forceinline vboolf16& operator &=(vboolf16& a, const vboolf16& b) { return a = a & b; }
__forceinline vboolf16& operator |=(vboolf16& a, const vboolf16& b) { return a = a | b; }
__forceinline vboolf16& operator ^=(vboolf16& a, const vboolf16& b) { return a = a ^ b; }
////////////////////////////////////////////////////////////////////////////////
/// Comparison Operators + Select
////////////////////////////////////////////////////////////////////////////////
__forceinline const vboolf16 operator !=( const vboolf16& a, const vboolf16& b ) { return _mm512_kxor(a, b); }
__forceinline const vboolf16 operator ==( const vboolf16& a, const vboolf16& b ) { return _mm512_kxnor(a, b); }
__forceinline vboolf16 operator !=(const vboolf16& a, const vboolf16& b) { return _mm512_kxor(a, b); }
__forceinline vboolf16 operator ==(const vboolf16& a, const vboolf16& b) { return _mm512_kxnor(a, b); }
__forceinline vboolf16 select (const vboolf16 &s, const vboolf16 &a, const vboolf16 &b) {
__forceinline vboolf16 select(const vboolf16& s, const vboolf16& a, const vboolf16& b) {
return _mm512_kor(_mm512_kand(s,a),_mm512_kandn(s,b));
}
@@ -122,23 +122,23 @@ namespace embree
/// Reduction Operations
////////////////////////////////////////////////////////////////////////////////
__forceinline int all (const vboolf16 &a) { return _mm512_kortestc(a,a) != 0; }
__forceinline int any (const vboolf16 &a) { return _mm512_kortestz(a,a) == 0; }
__forceinline int none(const vboolf16 &a) { return _mm512_kortestz(a,a) != 0; }
__forceinline int all (const vboolf16& a) { return _mm512_kortestc(a,a) != 0; }
__forceinline int any (const vboolf16& a) { return _mm512_kortestz(a,a) == 0; }
__forceinline int none(const vboolf16& a) { return _mm512_kortestz(a,a) != 0; }
__forceinline int all ( const vboolf16& valid, const vboolf16& b ) { return all((!valid) | b); }
__forceinline int any ( const vboolf16& valid, const vboolf16& b ) { return any( valid & b); }
__forceinline int none( const vboolf16& valid, const vboolf16& b ) { return none(valid & b); }
__forceinline int all (const vboolf16& valid, const vboolf16& b) { return all((!valid) | b); }
__forceinline int any (const vboolf16& valid, const vboolf16& b) { return any(valid & b); }
__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 movemask(const vboolf16& a) { return _mm512_kmov(a); }
__forceinline size_t popcnt (const vboolf16& a) { return __popcnt(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
@@ -152,7 +152,7 @@ namespace embree
/// Output Operators
////////////////////////////////////////////////////////////////////////////////
inline std::ostream& operator<<(std::ostream& cout, const vboolf16& a)
inline std::ostream& operator <<(std::ostream& cout, const vboolf16& a)
{
cout << "<";
for (size_t i=0; i<16; i++) {
+25 -25
View File
@@ -33,8 +33,8 @@ namespace embree
////////////////////////////////////////////////////////////////////////////////
__forceinline vboolf() {}
__forceinline vboolf(const vboolf4 &t) { v = t.v; }
__forceinline vboolf4& operator=(const vboolf4 &f) { v = f.v; return *this; }
__forceinline vboolf(const vboolf4& t) { v = t.v; }
__forceinline vboolf4& operator =(const vboolf4& f) { v = f.v; return *this; }
__forceinline vboolf(const __mmask8 &t) { v = t; }
__forceinline operator __mmask8() const { return v; }
@@ -62,42 +62,42 @@ namespace embree
/// Constants
////////////////////////////////////////////////////////////////////////////////
__forceinline vboolf( FalseTy ) : v(0x0) {}
__forceinline vboolf( TrueTy ) : v(0xf) {}
__forceinline vboolf(FalseTy) : v(0x0) {}
__forceinline vboolf(TrueTy) : v(0xf) {}
};
////////////////////////////////////////////////////////////////////////////////
/// Unary Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline vboolf4 operator!(const vboolf4 &a) { return _mm512_kandn(a, 0xf); }
__forceinline vboolf4 operator !(const vboolf4& a) { return _mm512_kandn(a, 0xf); }
////////////////////////////////////////////////////////////////////////////////
/// Binary Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline vboolf4 operator&(const vboolf4 &a, const vboolf4 &b) { return _mm512_kand(a, b); }
__forceinline vboolf4 operator|(const vboolf4 &a, const vboolf4 &b) { return _mm512_kor(a, b); }
__forceinline vboolf4 operator^(const vboolf4 &a, const vboolf4 &b) { return _mm512_kxor(a, b); }
__forceinline vboolf4 operator &(const vboolf4& a, const vboolf4& b) { return _mm512_kand(a, b); }
__forceinline vboolf4 operator |(const vboolf4& a, const vboolf4& b) { return _mm512_kor(a, b); }
__forceinline vboolf4 operator ^(const vboolf4& a, const vboolf4& b) { return _mm512_kxor(a, b); }
__forceinline vboolf4 andn(const vboolf4 &a, const vboolf4 &b) { return _mm512_kandn(b, a); }
__forceinline vboolf4 andn(const vboolf4& a, const vboolf4& b) { return _mm512_kandn(b, a); }
////////////////////////////////////////////////////////////////////////////////
/// Assignment Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline const vboolf4 operator &=( vboolf4& a, const vboolf4& b ) { return a = a & b; }
__forceinline const vboolf4 operator |=( vboolf4& a, const vboolf4& b ) { return a = a | b; }
__forceinline const vboolf4 operator ^=( vboolf4& a, const vboolf4& b ) { return a = a ^ b; }
__forceinline vboolf4& operator &=(vboolf4& a, const vboolf4& b) { return a = a & b; }
__forceinline vboolf4& operator |=(vboolf4& a, const vboolf4& b) { return a = a | b; }
__forceinline vboolf4& operator ^=(vboolf4& a, const vboolf4& b) { return a = a ^ b; }
////////////////////////////////////////////////////////////////////////////////
/// Comparison Operators + Select
////////////////////////////////////////////////////////////////////////////////
__forceinline const vboolf4 operator !=( const vboolf4& a, const vboolf4& b ) { return _mm512_kxor(a, b); }
__forceinline const vboolf4 operator ==( const vboolf4& a, const vboolf4& b ) { return _mm512_kand(_mm512_kxnor(a, b), 0xf); }
__forceinline vboolf4 operator !=(const vboolf4& a, const vboolf4& b) { return _mm512_kxor(a, b); }
__forceinline vboolf4 operator ==(const vboolf4& a, const vboolf4& b) { return _mm512_kand(_mm512_kxnor(a, b), 0xf); }
__forceinline vboolf4 select (const vboolf4 &s, const vboolf4 &a, const vboolf4 &b) {
__forceinline vboolf4 select(const vboolf4& s, const vboolf4& a, const vboolf4& b) {
return _mm512_kor(_mm512_kand(s, a), _mm512_kandn(s, b));
}
@@ -105,22 +105,22 @@ namespace embree
/// Reduction Operations
////////////////////////////////////////////////////////////////////////////////
__forceinline int all (const vboolf4 &a) { return a.v == 0xf; }
__forceinline int any (const vboolf4 &a) { return _mm512_kortestz(a, a) == 0; }
__forceinline int none(const vboolf4 &a) { return _mm512_kortestz(a, a) != 0; }
__forceinline int all (const vboolf4& a) { return a.v == 0xf; }
__forceinline int any (const vboolf4& a) { return _mm512_kortestz(a, a) == 0; }
__forceinline int none(const vboolf4& a) { return _mm512_kortestz(a, a) != 0; }
__forceinline int all ( const vboolf4& valid, const vboolf4& b ) { return all((!valid) | b); }
__forceinline int any ( const vboolf4& valid, const vboolf4& b ) { return any( valid & b); }
__forceinline int none( const vboolf4& valid, const vboolf4& b ) { return none(valid & b); }
__forceinline int all (const vboolf4& valid, const vboolf4& b) { return all((!valid) | b); }
__forceinline int any (const vboolf4& valid, const vboolf4& b) { return any(valid & b); }
__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 movemask(const vboolf4& a) { return _mm512_kmov(a); }
__forceinline size_t popcnt (const vboolf4& a) { return __popcnt(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
@@ -134,7 +134,7 @@ namespace embree
/// Output Operators
////////////////////////////////////////////////////////////////////////////////
inline std::ostream& operator<<(std::ostream& cout, const vboolf4& a)
inline std::ostream& operator <<(std::ostream& cout, const vboolf4& a)
{
cout << "<";
for (size_t i=0; i<4; i++) {
+54 -51
View File
@@ -33,23 +33,23 @@ namespace embree
/// Constructors, Assignment & Cast Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline vboolf ( ) {}
__forceinline vboolf ( const vboolf4& other ) { v = other.v; }
__forceinline vboolf4& operator=( const vboolf4& other ) { v = other.v; return *this; }
__forceinline vboolf() {}
__forceinline vboolf(const vboolf4& other) { v = other.v; }
__forceinline vboolf4& operator =(const vboolf4& other) { v = other.v; return *this; }
__forceinline vboolf( const __m128 input ) : v(input) {}
__forceinline operator const __m128&( void ) const { return v; }
__forceinline operator const __m128i( void ) const { return _mm_castps_si128(v); }
__forceinline operator const __m128d( void ) const { return _mm_castps_pd(v); }
__forceinline vboolf(__m128 input) : v(input) {}
__forceinline operator const __m128&() const { return v; }
__forceinline operator const __m128i() const { return _mm_castps_si128(v); }
__forceinline operator const __m128d() const { return _mm_castps_pd(v); }
__forceinline vboolf( bool a )
__forceinline vboolf(bool a)
: v(_mm_lookupmask_ps[(size_t(a) << 3) | (size_t(a) << 2) | (size_t(a) << 1) | size_t(a)]) {}
__forceinline vboolf( bool a, bool b )
__forceinline vboolf(bool a, bool b)
: 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 )
__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]; }
__forceinline vboolf(unsigned int mask) { assert(mask < 16); v = _mm_lookupmask_ps[mask]; }
/* return int32 mask */
__forceinline __m128i mask32() const {
@@ -60,47 +60,47 @@ namespace embree
/// Constants
////////////////////////////////////////////////////////////////////////////////
__forceinline vboolf( FalseTy ) : v(_mm_setzero_ps()) {}
__forceinline vboolf( TrueTy ) : v(_mm_castsi128_ps(_mm_cmpeq_epi32(_mm_setzero_si128(), _mm_setzero_si128()))) {}
__forceinline vboolf(FalseTy) : v(_mm_setzero_ps()) {}
__forceinline vboolf(TrueTy) : v(_mm_castsi128_ps(_mm_cmpeq_epi32(_mm_setzero_si128(), _mm_setzero_si128()))) {}
////////////////////////////////////////////////////////////////////////////////
/// Array Access
////////////////////////////////////////////////////////////////////////////////
__forceinline bool operator []( const size_t index ) const { assert(index < 4); return (_mm_movemask_ps(v) >> index) & 1; }
__forceinline int& operator []( const size_t index ) { assert(index < 4); return i[index]; }
__forceinline bool operator [](size_t index) const { assert(index < 4); return (_mm_movemask_ps(v) >> index) & 1; }
__forceinline int& operator [](size_t index) { assert(index < 4); return i[index]; }
};
////////////////////////////////////////////////////////////////////////////////
/// Unary Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline const vboolf4 operator !( const vboolf4& a ) { return _mm_xor_ps(a, vboolf4(embree::True)); }
__forceinline vboolf4 operator !(const vboolf4& a) { return _mm_xor_ps(a, vboolf4(embree::True)); }
////////////////////////////////////////////////////////////////////////////////
/// Binary Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline const vboolf4 operator &( const vboolf4& a, const vboolf4& b ) { return _mm_and_ps(a, b); }
__forceinline const vboolf4 operator |( const vboolf4& a, const vboolf4& b ) { return _mm_or_ps (a, b); }
__forceinline const vboolf4 operator ^( const vboolf4& a, const vboolf4& b ) { return _mm_xor_ps(a, b); }
__forceinline vboolf4 operator &(const vboolf4& a, const vboolf4& b) { return _mm_and_ps(a, b); }
__forceinline vboolf4 operator |(const vboolf4& a, const vboolf4& b) { return _mm_or_ps (a, b); }
__forceinline vboolf4 operator ^(const vboolf4& a, const vboolf4& b) { return _mm_xor_ps(a, b); }
////////////////////////////////////////////////////////////////////////////////
/// Assignment Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline const vboolf4 operator &=( vboolf4& a, const vboolf4& b ) { return a = a & b; }
__forceinline const vboolf4 operator |=( vboolf4& a, const vboolf4& b ) { return a = a | b; }
__forceinline const vboolf4 operator ^=( vboolf4& a, const vboolf4& b ) { return a = a ^ b; }
__forceinline vboolf4& operator &=(vboolf4& a, const vboolf4& b) { return a = a & b; }
__forceinline vboolf4& operator |=(vboolf4& a, const vboolf4& b) { return a = a | b; }
__forceinline vboolf4& operator ^=(vboolf4& a, const vboolf4& b) { return a = a ^ b; }
////////////////////////////////////////////////////////////////////////////////
/// Comparison Operators + Select
////////////////////////////////////////////////////////////////////////////////
__forceinline const vboolf4 operator !=( const vboolf4& a, const vboolf4& b ) { return _mm_xor_ps(a, b); }
__forceinline const vboolf4 operator ==( const vboolf4& a, const vboolf4& b ) { return _mm_castsi128_ps(_mm_cmpeq_epi32(a, b)); }
__forceinline vboolf4 operator !=(const vboolf4& a, const vboolf4& b) { return _mm_xor_ps(a, b); }
__forceinline vboolf4 operator ==(const vboolf4& a, const vboolf4& b) { return _mm_castsi128_ps(_mm_cmpeq_epi32(a, b)); }
__forceinline const vboolf4 select( const vboolf4& m, const vboolf4& t, const vboolf4& f ) {
__forceinline vboolf4 select(const vboolf4& m, const vboolf4& t, const vboolf4& f) {
#if defined(__SSE4_1__)
return _mm_blendv_ps(f, t, m);
#else
@@ -112,53 +112,56 @@ namespace embree
/// Movement/Shifting/Shuffling Functions
////////////////////////////////////////////////////////////////////////////////
__forceinline const vboolf4 unpacklo( const vboolf4& a, const vboolf4& b ) { return _mm_unpacklo_ps(a, b); }
__forceinline const vboolf4 unpackhi( const vboolf4& a, const vboolf4& b ) { return _mm_unpackhi_ps(a, b); }
__forceinline vboolf4 unpacklo(const vboolf4& a, const vboolf4& b) { return _mm_unpacklo_ps(a, b); }
__forceinline vboolf4 unpackhi(const vboolf4& a, const vboolf4& b) { return _mm_unpackhi_ps(a, b); }
template<size_t i0, size_t i1, size_t i2, size_t i3> __forceinline const vboolf4 shuffle( const vboolf4& a ) {
return _mm_shuffle_epi32(a, _MM_SHUFFLE(i3, i2, i1, i0));
template<int i0, int i1, int i2, int i3>
__forceinline vboolf4 shuffle(const vboolf4& v) {
return _mm_shuffle_epi32(v, _MM_SHUFFLE(i3, i2, i1, i0));
}
template<size_t i0, size_t i1, size_t i2, size_t i3> __forceinline const vboolf4 shuffle( const vboolf4& a, const vboolf4& b ) {
template<int i0, int i1, int i2, int i3>
__forceinline vboolf4 shuffle(const vboolf4& a, const vboolf4& b) {
return _mm_shuffle_ps(a, b, _MM_SHUFFLE(i3, i2, i1, i0));
}
template<size_t i0> __forceinline const vboolf4 shuffle( const vboolf4& b ) {
return shuffle<i0,i0,i0,i0>(b);
template<int i0>
__forceinline vboolf4 shuffle(const vboolf4& v) {
return shuffle<i0,i0,i0,i0>(v);
}
#if defined(__SSE3__)
template<> __forceinline const vboolf4 shuffle<0, 0, 2, 2>( const vboolf4& a ) { return _mm_moveldup_ps(a); }
template<> __forceinline const vboolf4 shuffle<1, 1, 3, 3>( const vboolf4& a ) { return _mm_movehdup_ps(a); }
template<> __forceinline const vboolf4 shuffle<0, 1, 0, 1>( const vboolf4& a ) { return _mm_castpd_ps(_mm_movedup_pd (a)); }
template<> __forceinline vboolf4 shuffle<0, 0, 2, 2>(const vboolf4& v) { return _mm_moveldup_ps(v); }
template<> __forceinline vboolf4 shuffle<1, 1, 3, 3>(const vboolf4& v) { return _mm_movehdup_ps(v); }
template<> __forceinline vboolf4 shuffle<0, 1, 0, 1>(const vboolf4& v) { return _mm_castpd_ps(_mm_movedup_pd(v)); }
#endif
#if defined(__SSE4_1__)
template<size_t dst, size_t src, size_t clr> __forceinline const vboolf4 insert( const vboolf4& a, const vboolf4& b ) { return _mm_insert_ps(a, b, (dst << 4) | (src << 6) | clr); }
template<size_t dst, size_t src> __forceinline const vboolf4 insert( const vboolf4& a, const vboolf4& b ) { return insert<dst, src, 0>(a, b); }
template<size_t dst> __forceinline const vboolf4 insert( const vboolf4& a, const bool b ) { return insert<dst,0>(a, vboolf4(b)); }
template<int dst, int src, int clr> __forceinline vboolf4 insert(const vboolf4& a, const vboolf4& b) { return _mm_insert_ps(a, b, (dst << 4) | (src << 6) | clr); }
template<int dst, int src> __forceinline vboolf4 insert(const vboolf4& a, const vboolf4& b) { return insert<dst, src, 0>(a, b); }
template<int dst> __forceinline vboolf4 insert(const vboolf4& a, const bool b) { return insert<dst, 0>(a, vboolf4(b)); }
#endif
////////////////////////////////////////////////////////////////////////////////
/// Reduction Operations
////////////////////////////////////////////////////////////////////////////////
__forceinline bool reduce_and( const vboolf4& a ) { return _mm_movemask_ps(a) == 0xf; }
__forceinline bool reduce_or ( const vboolf4& a ) { return _mm_movemask_ps(a) != 0x0; }
__forceinline bool reduce_and(const vboolf4& a) { return _mm_movemask_ps(a) == 0xf; }
__forceinline bool reduce_or (const vboolf4& a) { return _mm_movemask_ps(a) != 0x0; }
__forceinline bool all ( const vboolf4& b ) { return _mm_movemask_ps(b) == 0xf; }
__forceinline bool any ( const vboolf4& b ) { return _mm_movemask_ps(b) != 0x0; }
__forceinline bool none ( const vboolf4& b ) { return _mm_movemask_ps(b) == 0x0; }
__forceinline bool all (const vboolf4& b) { return _mm_movemask_ps(b) == 0xf; }
__forceinline bool any (const vboolf4& b) { return _mm_movemask_ps(b) != 0x0; }
__forceinline bool none(const vboolf4& b) { return _mm_movemask_ps(b) == 0x0; }
__forceinline bool all ( const vboolf4& valid, const vboolf4& b ) { return all((!valid) | b); }
__forceinline bool any ( const vboolf4& valid, const vboolf4& b ) { return any( valid & b); }
__forceinline bool none ( const vboolf4& valid, const vboolf4& b ) { return none(valid & b); }
__forceinline bool all (const vboolf4& valid, const vboolf4& b) { return all((!valid) | b); }
__forceinline bool any (const vboolf4& valid, const vboolf4& b) { return any(valid & b); }
__forceinline bool none(const vboolf4& valid, const vboolf4& b) { return none(valid & b); }
__forceinline size_t movemask( const vboolf4& a ) { return _mm_movemask_ps(a); }
__forceinline size_t movemask(const vboolf4& a) { return _mm_movemask_ps(a); }
#if defined(__SSE4_2__)
__forceinline size_t popcnt( const vboolf4& a ) { return __popcnt((size_t)_mm_movemask_ps(a)); }
__forceinline size_t popcnt(const vboolf4& a) { return __popcnt((size_t)_mm_movemask_ps(a)); }
#else
__forceinline size_t popcnt( const vboolf4& a ) { return bool(a[0])+bool(a[1])+bool(a[2])+bool(a[3]); }
__forceinline size_t popcnt(const vboolf4& a) { return bool(a[0])+bool(a[1])+bool(a[2])+bool(a[3]); }
#endif
////////////////////////////////////////////////////////////////////////////////
@@ -173,7 +176,7 @@ namespace embree
/// Output Operators
////////////////////////////////////////////////////////////////////////////////
inline std::ostream& operator<<(std::ostream& cout, const vboolf4& a) {
inline std::ostream& operator <<(std::ostream& cout, const vboolf4& a) {
return cout << "<" << a[0] << ", " << a[1] << ", " << a[2] << ", " << a[3] << ">";
}
}
+61 -56
View File
@@ -37,16 +37,16 @@ namespace embree
/// Constructors, Assignment & Cast Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline vboolf () {}
__forceinline vboolf ( const vboolf8& a ) { v = a.v; }
__forceinline vboolf8& operator=( const vboolf8& a ) { v = a.v; return *this; }
__forceinline vboolf() {}
__forceinline vboolf(const vboolf8& a) { v = a.v; }
__forceinline vboolf8& operator =(const vboolf8& a) { v = a.v; return *this; }
__forceinline vboolf( const __m256 a ) : v(a) {}
__forceinline operator const __m256&( void ) const { return v; }
__forceinline operator const __m256i( void ) const { return _mm256_castps_si256(v); }
__forceinline operator const __m256d( void ) const { return _mm256_castps_pd(v); }
__forceinline vboolf(__m256 a) : v(a) {}
__forceinline operator const __m256&() const { return v; }
__forceinline operator const __m256i() const { return _mm256_castps_si256(v); }
__forceinline operator const __m256d() const { return _mm256_castps_pd(v); }
__forceinline vboolf ( const int a )
__forceinline vboolf(int a)
{
assert(a >= 0 && a <= 255);
#if defined (__AVX2__)
@@ -60,14 +60,14 @@ namespace embree
#endif
}
__forceinline vboolf ( const vboolf4& a ) : v(_mm256_insertf128_ps(_mm256_castps128_ps256(a),a,1)) {}
__forceinline vboolf ( const vboolf4& a, const vboolf4& b) : v(_mm256_insertf128_ps(_mm256_castps128_ps256(a),b,1)) {}
__forceinline vboolf ( const __m128 a, const __m128 b) : vl(a), vh(b) {}
__forceinline vboolf(const vboolf4& a) : v(_mm256_insertf128_ps(_mm256_castps128_ps256(a),a,1)) {}
__forceinline vboolf(const vboolf4& a, const vboolf4& b) : v(_mm256_insertf128_ps(_mm256_castps128_ps256(a),b,1)) {}
__forceinline vboolf(__m128 a, __m128 b) : vl(a), vh(b) {}
__forceinline vboolf ( bool a ) : v(vboolf8(vboolf4(a), vboolf4(a))) {}
__forceinline vboolf ( bool a, bool b) : v(vboolf8(vboolf4(a), vboolf4(b))) {}
__forceinline vboolf ( bool a, bool b, bool c, bool d) : v(vboolf8(vboolf4(a,b), vboolf4(c,d))) {}
__forceinline vboolf ( bool a, bool b, bool c, bool d, bool e, bool f, bool g, bool vh ) : v(vboolf8(vboolf4(a,b,c,d), vboolf4(e,f,g,vh))) {}
__forceinline vboolf(bool a) : v(vboolf8(vboolf4(a), vboolf4(a))) {}
__forceinline vboolf(bool a, bool b) : v(vboolf8(vboolf4(a), vboolf4(b))) {}
__forceinline vboolf(bool a, bool b, bool c, bool d) : v(vboolf8(vboolf4(a,b), vboolf4(c,d))) {}
__forceinline vboolf(bool a, bool b, bool c, bool d, bool e, bool f, bool g, bool h) : v(vboolf8(vboolf4(a,b,c,d), vboolf4(e,f,g,h))) {}
/* return int32 mask */
__forceinline __m256i mask32() const {
@@ -78,43 +78,43 @@ namespace embree
/// Constants
////////////////////////////////////////////////////////////////////////////////
__forceinline vboolf( FalseTy ) : v(_mm256_setzero_ps()) {}
__forceinline vboolf( TrueTy ) : v(_mm256_cmp_ps(_mm256_setzero_ps(), _mm256_setzero_ps(), _CMP_EQ_OQ)) {}
__forceinline vboolf(FalseTy) : v(_mm256_setzero_ps()) {}
__forceinline vboolf(TrueTy) : v(_mm256_cmp_ps(_mm256_setzero_ps(), _mm256_setzero_ps(), _CMP_EQ_OQ)) {}
////////////////////////////////////////////////////////////////////////////////
/// Array Access
////////////////////////////////////////////////////////////////////////////////
__forceinline bool operator []( const size_t index ) const { assert(index < 8); return (_mm256_movemask_ps(v) >> index) & 1; }
__forceinline int& operator []( const size_t index ) { assert(index < 8); return i[index]; }
__forceinline bool operator [](size_t index) const { assert(index < 8); return (_mm256_movemask_ps(v) >> index) & 1; }
__forceinline int& operator [](size_t index) { assert(index < 8); return i[index]; }
};
////////////////////////////////////////////////////////////////////////////////
/// Unary Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline const vboolf8 operator !( const vboolf8& a ) { return _mm256_xor_ps(a, vboolf8(embree::True)); }
__forceinline vboolf8 operator !(const vboolf8& a) { return _mm256_xor_ps(a, vboolf8(embree::True)); }
////////////////////////////////////////////////////////////////////////////////
/// Binary Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline const vboolf8 operator &( const vboolf8& a, const vboolf8& b ) { return _mm256_and_ps(a, b); }
__forceinline const vboolf8 operator |( const vboolf8& a, const vboolf8& b ) { return _mm256_or_ps (a, b); }
__forceinline const vboolf8 operator ^( const vboolf8& a, const vboolf8& b ) { return _mm256_xor_ps(a, b); }
__forceinline vboolf8 operator &(const vboolf8& a, const vboolf8& b) { return _mm256_and_ps(a, b); }
__forceinline vboolf8 operator |(const vboolf8& a, const vboolf8& b) { return _mm256_or_ps (a, b); }
__forceinline vboolf8 operator ^(const vboolf8& a, const vboolf8& b) { return _mm256_xor_ps(a, b); }
__forceinline vboolf8 operator &=( vboolf8& a, const vboolf8& b ) { return a = a & b; }
__forceinline vboolf8 operator |=( vboolf8& a, const vboolf8& b ) { return a = a | b; }
__forceinline vboolf8 operator ^=( vboolf8& a, const vboolf8& b ) { return a = a ^ b; }
__forceinline vboolf8& operator &=(vboolf8& a, const vboolf8& b) { return a = a & b; }
__forceinline vboolf8& operator |=(vboolf8& a, const vboolf8& b) { return a = a | b; }
__forceinline vboolf8& operator ^=(vboolf8& a, const vboolf8& b) { return a = a ^ b; }
////////////////////////////////////////////////////////////////////////////////
/// Comparison Operators + Select
////////////////////////////////////////////////////////////////////////////////
__forceinline const vboolf8 operator !=( const vboolf8& a, const vboolf8& b ) { return _mm256_xor_ps(a, b); }
__forceinline const vboolf8 operator ==( const vboolf8& a, const vboolf8& b ) { return _mm256_xor_ps(_mm256_xor_ps(a,b),vboolf8(embree::True)); }
__forceinline vboolf8 operator !=(const vboolf8& a, const vboolf8& b) { return _mm256_xor_ps(a, b); }
__forceinline vboolf8 operator ==(const vboolf8& a, const vboolf8& b) { return _mm256_xor_ps(_mm256_xor_ps(a,b),vboolf8(embree::True)); }
__forceinline const vboolf8 select( const vboolf8& mask, const vboolf8& t, const vboolf8& f ) {
__forceinline vboolf8 select(const vboolf8& mask, const vboolf8& t, const vboolf8& f) {
return _mm256_blendv_ps(f, t, mask);
}
@@ -122,54 +122,59 @@ namespace embree
/// Movement/Shifting/Shuffling Functions
////////////////////////////////////////////////////////////////////////////////
__forceinline vboolf8 unpacklo( const vboolf8& a, const vboolf8& b ) { return _mm256_unpacklo_ps(a.v, b.v); }
__forceinline vboolf8 unpackhi( const vboolf8& a, const vboolf8& b ) { return _mm256_unpackhi_ps(a.v, b.v); }
__forceinline vboolf8 unpacklo(const vboolf8& a, const vboolf8& b) { return _mm256_unpacklo_ps(a, b); }
__forceinline vboolf8 unpackhi(const vboolf8& a, const vboolf8& b) { return _mm256_unpackhi_ps(a, b); }
template<size_t i> __forceinline const vboolf8 shuffle( const vboolf8& a ) {
return _mm256_permute_ps(a, _MM_SHUFFLE(i, i, i, i));
template<int i>
__forceinline vboolf8 shuffle(const vboolf8& v) {
return _mm256_permute_ps(v, _MM_SHUFFLE(i, i, i, i));
}
template<size_t i0, size_t i1> __forceinline const vboolf8 shuffle4( const vboolf8& a ) {
return _mm256_permute2f128_ps(a, a, (i1 << 4) | (i0 << 0));
template<int i0, int i1>
__forceinline vboolf8 shuffle4(const vboolf8& v) {
return _mm256_permute2f128_ps(v, v, (i1 << 4) | (i0 << 0));
}
template<size_t i0, size_t i1> __forceinline const vboolf8 shuffle4( const vboolf8& a, const vboolf8& b) {
template<int i0, int i1>
__forceinline vboolf8 shuffle4(const vboolf8& a, const vboolf8& b) {
return _mm256_permute2f128_ps(a, b, (i1 << 4) | (i0 << 0));
}
template<size_t i0, size_t i1, size_t i2, size_t i3> __forceinline const vboolf8 shuffle( const vboolf8& a ) {
return _mm256_permute_ps(a, _MM_SHUFFLE(i3, i2, i1, i0));
template<int i0, int i1, int i2, int i3>
__forceinline vboolf8 shuffle(const vboolf8& v) {
return _mm256_permute_ps(v, _MM_SHUFFLE(i3, i2, i1, i0));
}
template<size_t i0, size_t i1, size_t i2, size_t i3> __forceinline const vboolf8 shuffle( const vboolf8& a, const vboolf8& b ) {
template<int i0, int i1, int i2, int i3>
__forceinline vboolf8 shuffle(const vboolf8& a, const vboolf8& b) {
return _mm256_shuffle_ps(a, b, _MM_SHUFFLE(i3, i2, i1, i0));
}
template<> __forceinline const vboolf8 shuffle<0, 0, 2, 2>( const vboolf8& b ) { return _mm256_moveldup_ps(b); }
template<> __forceinline const vboolf8 shuffle<1, 1, 3, 3>( const vboolf8& b ) { return _mm256_movehdup_ps(b); }
template<> __forceinline const vboolf8 shuffle<0, 1, 0, 1>( const vboolf8& b ) { return _mm256_castpd_ps(_mm256_movedup_pd(_mm256_castps_pd(b))); }
template<> __forceinline vboolf8 shuffle<0, 0, 2, 2>(const vboolf8& v) { return _mm256_moveldup_ps(v); }
template<> __forceinline vboolf8 shuffle<1, 1, 3, 3>(const vboolf8& v) { return _mm256_movehdup_ps(v); }
template<> __forceinline vboolf8 shuffle<0, 1, 0, 1>(const vboolf8& v) { return _mm256_castpd_ps(_mm256_movedup_pd(_mm256_castps_pd(v))); }
template<size_t i> __forceinline const vboolf8 insert4(const vboolf8& a, const vboolf4& b) { return _mm256_insertf128_ps(a, b, i); }
template<size_t i> __forceinline const vboolf4 extract4 (const vboolf8& a) { return _mm256_extractf128_ps(a, i); }
template<> __forceinline const vboolf4 extract4<0>(const vboolf8& a) { return _mm256_castps256_ps128(a); }
template<int i> __forceinline vboolf8 insert4(const vboolf8& a, const vboolf4& b) { return _mm256_insertf128_ps(a, b, i); }
template<int i> __forceinline vboolf4 extract4 (const vboolf8& a) { return _mm256_extractf128_ps(a, i); }
template<> __forceinline vboolf4 extract4<0>(const vboolf8& a) { return _mm256_castps256_ps128(a); }
////////////////////////////////////////////////////////////////////////////////
/// Reduction Operations
////////////////////////////////////////////////////////////////////////////////
__forceinline bool reduce_and( const vboolf8& a ) { return _mm256_movemask_ps(a) == (unsigned int)0xff; }
__forceinline bool reduce_or ( const vboolf8& a ) { return !_mm256_testz_ps(a,a); }
__forceinline bool reduce_and(const vboolf8& a) { return _mm256_movemask_ps(a) == (unsigned int)0xff; }
__forceinline bool reduce_or (const vboolf8& a) { return !_mm256_testz_ps(a,a); }
__forceinline bool all ( const vboolf8& a ) { return _mm256_movemask_ps(a) == (unsigned int)0xff; }
__forceinline bool any ( const vboolf8& a ) { return !_mm256_testz_ps(a,a); }
__forceinline bool none ( const vboolf8& a ) { return _mm256_testz_ps(a,a) != 0; }
__forceinline bool all (const vboolf8& a) { return _mm256_movemask_ps(a) == (unsigned int)0xff; }
__forceinline bool any (const vboolf8& a) { return !_mm256_testz_ps(a,a); }
__forceinline bool none(const vboolf8& a) { return _mm256_testz_ps(a,a) != 0; }
__forceinline bool all ( const vboolf8& valid, const vboolf8& b ) { return all((!valid) | b); }
__forceinline bool any ( const vboolf8& valid, const vboolf8& b ) { return any( valid & b); }
__forceinline bool none ( const vboolf8& valid, const vboolf8& b ) { return none(valid & b); }
__forceinline bool all (const vboolf8& valid, const vboolf8& b) { return all((!valid) | b); }
__forceinline bool any (const vboolf8& valid, const vboolf8& b) { return any(valid & b); }
__forceinline bool none(const vboolf8& valid, const vboolf8& b) { return none(valid & b); }
__forceinline unsigned int movemask( const vboolf8& a ) { return _mm256_movemask_ps(a); }
__forceinline size_t popcnt ( const vboolf8& a ) { return __popcnt((size_t)_mm256_movemask_ps(a)); }
__forceinline unsigned int movemask(const vboolf8& a) { return _mm256_movemask_ps(a); }
__forceinline size_t popcnt (const vboolf8& a) { return __popcnt((size_t)_mm256_movemask_ps(a)); }
////////////////////////////////////////////////////////////////////////////////
/// Get/Set Functions
@@ -183,7 +188,7 @@ namespace embree
/// Output Operators
////////////////////////////////////////////////////////////////////////////////
inline std::ostream& operator<<(std::ostream& cout, const vboolf8& a) {
inline std::ostream& operator <<(std::ostream& cout, const vboolf8& a) {
return cout << "<" << a[0] << ", " << a[1] << ", " << a[2] << ", " << a[3] << ", "
<< a[4] << ", " << a[5] << ", " << a[6] << ", " << a[7] << ">";
}
+25 -25
View File
@@ -33,8 +33,8 @@ namespace embree
////////////////////////////////////////////////////////////////////////////////
__forceinline vboolf() {}
__forceinline vboolf(const vboolf8 &t) { v = t.v; }
__forceinline vboolf8& operator=(const vboolf8 &f) { v = f.v; return *this; }
__forceinline vboolf(const vboolf8& t) { v = t.v; }
__forceinline vboolf8& operator =(const vboolf8& f) { v = f.v; return *this; }
__forceinline vboolf(const __mmask8 &t) { v = t; }
__forceinline operator __mmask8() const { return v; }
@@ -62,42 +62,42 @@ namespace embree
/// Constants
////////////////////////////////////////////////////////////////////////////////
__forceinline vboolf( FalseTy ) : v(0x00) {}
__forceinline vboolf( TrueTy ) : v(0xff) {}
__forceinline vboolf(FalseTy) : v(0x00) {}
__forceinline vboolf(TrueTy) : v(0xff) {}
};
////////////////////////////////////////////////////////////////////////////////
/// Unary Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline vboolf8 operator!(const vboolf8 &a) { return _mm512_knot(a); }
__forceinline vboolf8 operator !(const vboolf8& a) { return _mm512_knot(a); }
////////////////////////////////////////////////////////////////////////////////
/// Binary Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline vboolf8 operator&(const vboolf8 &a, const vboolf8 &b) { return _mm512_kand(a, b); }
__forceinline vboolf8 operator|(const vboolf8 &a, const vboolf8 &b) { return _mm512_kor(a, b); }
__forceinline vboolf8 operator^(const vboolf8 &a, const vboolf8 &b) { return _mm512_kxor(a, b); }
__forceinline vboolf8 operator &(const vboolf8& a, const vboolf8& b) { return _mm512_kand(a, b); }
__forceinline vboolf8 operator |(const vboolf8& a, const vboolf8& b) { return _mm512_kor(a, b); }
__forceinline vboolf8 operator ^(const vboolf8& a, const vboolf8& b) { return _mm512_kxor(a, b); }
__forceinline vboolf8 andn(const vboolf8 &a, const vboolf8 &b) { return _mm512_kandn(b, a); }
__forceinline vboolf8 andn(const vboolf8& a, const vboolf8& b) { return _mm512_kandn(b, a); }
////////////////////////////////////////////////////////////////////////////////
/// Assignment Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline const vboolf8 operator &=( vboolf8& a, const vboolf8& b ) { return a = a & b; }
__forceinline const vboolf8 operator |=( vboolf8& a, const vboolf8& b ) { return a = a | b; }
__forceinline const vboolf8 operator ^=( vboolf8& a, const vboolf8& b ) { return a = a ^ b; }
__forceinline vboolf8& operator &=(vboolf8& a, const vboolf8& b) { return a = a & b; }
__forceinline vboolf8& operator |=(vboolf8& a, const vboolf8& b) { return a = a | b; }
__forceinline vboolf8& operator ^=(vboolf8& a, const vboolf8& b) { return a = a ^ b; }
////////////////////////////////////////////////////////////////////////////////
/// Comparison Operators + Select
////////////////////////////////////////////////////////////////////////////////
__forceinline const vboolf8 operator !=( const vboolf8& a, const vboolf8& b ) { return _mm512_kxor(a, b); }
__forceinline const vboolf8 operator ==( const vboolf8& a, const vboolf8& b ) { return _mm512_kxnor(a, b); }
__forceinline vboolf8 operator !=(const vboolf8& a, const vboolf8& b) { return _mm512_kxor(a, b); }
__forceinline vboolf8 operator ==(const vboolf8& a, const vboolf8& b) { return _mm512_kxnor(a, b); }
__forceinline vboolf8 select(const vboolf8 &s, const vboolf8 &a, const vboolf8 &b) {
__forceinline vboolf8 select(const vboolf8& s, const vboolf8& a, const vboolf8& b) {
return _mm512_kor(_mm512_kand(s, a), _mm512_kandn(s, b));
}
@@ -105,22 +105,22 @@ namespace embree
/// Reduction Operations
////////////////////////////////////////////////////////////////////////////////
__forceinline int all (const vboolf8 &a) { return a.v == 0xff; }
__forceinline int any (const vboolf8 &a) { return _mm512_kortestz(a, a) == 0; }
__forceinline int none(const vboolf8 &a) { return _mm512_kortestz(a, a) != 0; }
__forceinline int all (const vboolf8& a) { return a.v == 0xff; }
__forceinline int any (const vboolf8& a) { return _mm512_kortestz(a, a) == 0; }
__forceinline int none(const vboolf8& a) { return _mm512_kortestz(a, a) != 0; }
__forceinline int all ( const vboolf8& valid, const vboolf8& b ) { return all((!valid) | b); }
__forceinline int any ( const vboolf8& valid, const vboolf8& b ) { return any( valid & b); }
__forceinline int none( const vboolf8& valid, const vboolf8& b ) { return none(valid & b); }
__forceinline int all (const vboolf8& valid, const vboolf8& b) { return all((!valid) | b); }
__forceinline int any (const vboolf8& valid, const vboolf8& b) { return any(valid & b); }
__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 movemask(const vboolf8& a) { return _mm512_kmov(a); }
__forceinline size_t popcnt (const vboolf8& a) { return __popcnt(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
@@ -134,7 +134,7 @@ namespace embree
/// Output Operators
////////////////////////////////////////////////////////////////////////////////
inline std::ostream& operator<<(std::ostream& cout, const vboolf8& a)
inline std::ostream& operator <<(std::ostream& cout, const vboolf8& a)
{
cout << "<";
for (size_t i=0; i<8; i++) {
+103 -111
View File
@@ -18,17 +18,7 @@
namespace embree
{
#ifndef _MM_SHUF_PERM2
#define _MM_SHUF_PERM2(e3, e2, e1, e0) \
((int)(((e3)<<3) | ((e2)<<2) | ((e1)<<1) | (e0)))
#endif
#ifndef _MM_SHUF_PERM3
#define _MM_SHUF_PERM3(e1, e0) \
((int)(((e1)<<4) | (e0)))
#endif
/* 4-wide AVX 64bit double type */
/* 4-wide AVX 64-bit double type */
template<>
struct vdouble<4>
{
@@ -46,16 +36,16 @@ namespace embree
__forceinline vdouble() {}
__forceinline vdouble(const vdouble4& t) { v = t.v; }
__forceinline vdouble4& operator=(const vdouble4& f) { v = f.v; return *this; }
__forceinline vdouble4& operator =(const vdouble4& f) { v = f.v; return *this; }
__forceinline vdouble(const __m256d& t) { v = t; }
__forceinline operator __m256d () const { return v; }
__forceinline operator __m256d() const { return v; }
__forceinline vdouble(const double i) {
__forceinline vdouble(double i) {
v = _mm256_set1_pd(i);
}
__forceinline vdouble(const double a, const double b, const double c, const double d) {
__forceinline vdouble(double a, double b, double c, double d) {
v = _mm256_set_pd(d,c,b,a);
}
@@ -64,25 +54,20 @@ namespace embree
/// Constants
////////////////////////////////////////////////////////////////////////////////
__forceinline vdouble( ZeroTy ) : v(_mm256_setzero_pd()) {}
__forceinline vdouble( OneTy ) : v(_mm256_set1_pd(1)) {}
__forceinline vdouble( StepTy ) : v(_mm256_set_pd(3.0,2.0,1.0,0.0)) {}
__forceinline vdouble( ReverseStepTy ) : v(_mm256_setr_pd(3.0,2.0,1.0,0.0)) {}
__forceinline static vdouble4 zero() { return _mm256_setzero_pd(); }
__forceinline static vdouble4 one () { return _mm256_set1_pd(1.0); }
__forceinline static vdouble4 neg_one () { return _mm256_set1_pd(-1.0); }
__forceinline vdouble(ZeroTy) : v(_mm256_setzero_pd()) {}
__forceinline vdouble(OneTy) : v(_mm256_set1_pd(1)) {}
__forceinline vdouble(StepTy) : v(_mm256_set_pd(3.0,2.0,1.0,0.0)) {}
__forceinline vdouble(ReverseStepTy) : v(_mm256_setr_pd(3.0,2.0,1.0,0.0)) {}
////////////////////////////////////////////////////////////////////////////////
/// Loads and Stores
////////////////////////////////////////////////////////////////////////////////
static __forceinline void store_nt(double *__restrict__ ptr, const vdouble4& a) {
_mm256_stream_pd(ptr,a);
_mm256_stream_pd(ptr, a);
}
static __forceinline vdouble4 loadu(const double* addr)
{
static __forceinline vdouble4 loadu(const double* addr) {
return _mm256_loadu_pd(addr);
}
@@ -95,11 +80,11 @@ namespace embree
}
static __forceinline void store(double* ptr, const vdouble4& v) {
_mm256_store_pd(ptr,v);
_mm256_store_pd(ptr, v);
}
static __forceinline void storeu(double* ptr, const vdouble4& v ) {
_mm256_storeu_pd(ptr,v);
static __forceinline void storeu(double* ptr, const vdouble4& v) {
_mm256_storeu_pd(ptr, v);
}
@@ -107,72 +92,71 @@ 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]; }
__forceinline double& operator [](size_t index) { assert(index < 4); return i[index]; }
__forceinline const double& operator [](size_t index) const { assert(index < 4); return i[index]; }
};
////////////////////////////////////////////////////////////////////////////////
/// Unary Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline const vdouble4 operator +( const vdouble4& a ) { return a; }
__forceinline const vdouble4 operator -( const vdouble4& a ) { return _mm256_sub_pd(_mm256_setzero_pd(), a); }
__forceinline vdouble4 operator +(const vdouble4& a) { return a; }
__forceinline vdouble4 operator -(const vdouble4& a) { return _mm256_sub_pd(_mm256_setzero_pd(), a); }
////////////////////////////////////////////////////////////////////////////////
/// Binary Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline const vdouble4 operator +( const vdouble4& a, const vdouble4& b ) { return _mm256_add_pd(a, b); }
__forceinline const vdouble4 operator +( const vdouble4& a, const double b ) { return a + vdouble4(b); }
__forceinline const vdouble4 operator +( const double a, const vdouble4& b ) { return vdouble4(a) + b; }
__forceinline vdouble4 operator +(const vdouble4& a, const vdouble4& b) { return _mm256_add_pd(a, b); }
__forceinline vdouble4 operator +(const vdouble4& a, double b) { return a + vdouble4(b); }
__forceinline vdouble4 operator +(double a, const vdouble4& b) { return vdouble4(a) + b; }
__forceinline const vdouble4 operator -( const vdouble4& a, const vdouble4& b ) { return _mm256_sub_pd(a, b); }
__forceinline const vdouble4 operator -( const vdouble4& a, const double b ) { return a - vdouble4(b); }
__forceinline const vdouble4 operator -( const double a, const vdouble4& b ) { return vdouble4(a) - b; }
__forceinline vdouble4 operator -(const vdouble4& a, const vdouble4& b) { return _mm256_sub_pd(a, b); }
__forceinline vdouble4 operator -(const vdouble4& a, double b) { return a - vdouble4(b); }
__forceinline vdouble4 operator -(double a, const vdouble4& b) { return vdouble4(a) - b; }
__forceinline const vdouble4 operator *( const vdouble4& a, const vdouble4& b ) { return _mm256_mul_pd(a, b); }
__forceinline const vdouble4 operator *( const vdouble4& a, const double b ) { return a * vdouble4(b); }
__forceinline const vdouble4 operator *( const double a, const vdouble4& b ) { return vdouble4(a) * b; }
__forceinline vdouble4 operator *(const vdouble4& a, const vdouble4& b) { return _mm256_mul_pd(a, b); }
__forceinline vdouble4 operator *(const vdouble4& a, double b) { return a * vdouble4(b); }
__forceinline vdouble4 operator *(double a, const vdouble4& b) { return vdouble4(a) * b; }
__forceinline const vdouble4 operator &( const vdouble4& a, const vdouble4& b ) { return _mm256_and_pd(a, b); }
__forceinline const vdouble4 operator &( const vdouble4& a, const double b ) { return a & vdouble4(b); }
__forceinline const vdouble4 operator &( const double a, const vdouble4& b ) { return vdouble4(a) & b; }
__forceinline vdouble4 operator &(const vdouble4& a, const vdouble4& b) { return _mm256_and_pd(a, b); }
__forceinline vdouble4 operator &(const vdouble4& a, double b) { return a & vdouble4(b); }
__forceinline vdouble4 operator &(double a, const vdouble4& b) { return vdouble4(a) & b; }
__forceinline const vdouble4 operator |( const vdouble4& a, const vdouble4& b ) { return _mm256_or_pd(a, b); }
__forceinline const vdouble4 operator |( const vdouble4& a, const double b ) { return a | vdouble4(b); }
__forceinline const vdouble4 operator |( const double a, const vdouble4& b ) { return vdouble4(a) | b; }
__forceinline vdouble4 operator |(const vdouble4& a, const vdouble4& b) { return _mm256_or_pd(a, b); }
__forceinline vdouble4 operator |(const vdouble4& a, double b) { return a | vdouble4(b); }
__forceinline vdouble4 operator |(double a, const vdouble4& b) { return vdouble4(a) | b; }
__forceinline const vdouble4 operator ^( const vdouble4& a, const vdouble4& b ) { return _mm256_xor_pd(a, b); }
__forceinline const vdouble4 operator ^( const vdouble4& a, const double b ) { return a ^ vdouble4(b); }
__forceinline const vdouble4 operator ^( const double a, const vdouble4& b ) { return vdouble4(a) ^ b; }
__forceinline vdouble4 operator ^(const vdouble4& a, const vdouble4& b) { return _mm256_xor_pd(a, b); }
__forceinline vdouble4 operator ^(const vdouble4& a, double b) { return a ^ vdouble4(b); }
__forceinline vdouble4 operator ^(double a, const vdouble4& b) { return vdouble4(a) ^ b; }
__forceinline const vdouble4 min( const vdouble4& a, const vdouble4& b ) { return _mm256_min_pd(a, b); }
__forceinline const vdouble4 min( const vdouble4& a, const double b ) { return min(a,vdouble4(b)); }
__forceinline const vdouble4 min( const double a, const vdouble4& b ) { return min(vdouble4(a),b); }
__forceinline vdouble4 min(const vdouble4& a, const vdouble4& b) { return _mm256_min_pd(a, b); }
__forceinline vdouble4 min(const vdouble4& a, double b) { return min(a,vdouble4(b)); }
__forceinline vdouble4 min(double a, const vdouble4& b) { return min(vdouble4(a),b); }
__forceinline const vdouble4 max( const vdouble4& a, const vdouble4& b ) { return _mm256_max_pd(a, b); }
__forceinline const vdouble4 max( const vdouble4& a, const double b ) { return max(a,vdouble4(b)); }
__forceinline const vdouble4 max( const double a, const vdouble4& b ) { return max(vdouble4(a),b); }
__forceinline vdouble4 max(const vdouble4& a, const vdouble4& b) { return _mm256_max_pd(a, b); }
__forceinline vdouble4 max(const vdouble4& a, double b) { return max(a,vdouble4(b)); }
__forceinline vdouble4 max(double a, const vdouble4& b) { return max(vdouble4(a),b); }
////////////////////////////////////////////////////////////////////////////////
/// Assignment Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline vdouble4& operator +=( vdouble4& a, const vdouble4& b ) { return a = a + b; }
__forceinline vdouble4& operator +=( vdouble4& a, const double b ) { return a = a + b; }
__forceinline vdouble4& operator +=(vdouble4& a, const vdouble4& b) { return a = a + b; }
__forceinline vdouble4& operator +=(vdouble4& a, double b) { return a = a + b; }
__forceinline vdouble4& operator -=( vdouble4& a, const vdouble4& b ) { return a = a - b; }
__forceinline vdouble4& operator -=( vdouble4& a, const double b ) { return a = a - b; }
__forceinline vdouble4& operator -=(vdouble4& a, const vdouble4& b) { return a = a - b; }
__forceinline vdouble4& operator -=(vdouble4& a, double b) { return a = a - b; }
__forceinline vdouble4& operator *=( vdouble4& a, const vdouble4& b ) { return a = a * b; }
__forceinline vdouble4& operator *=( vdouble4& a, const double b ) { return a = a * b; }
__forceinline vdouble4& operator *=(vdouble4& a, const vdouble4& b) { return a = a * b; }
__forceinline vdouble4& operator *=(vdouble4& a, double b) { return a = a * b; }
__forceinline vdouble4& operator &=( vdouble4& a, const vdouble4& b ) { return a = a & b; }
__forceinline vdouble4& operator &=( vdouble4& a, const double b ) { return a = a & b; }
__forceinline vdouble4& operator &=(vdouble4& a, const vdouble4& b) { return a = a & b; }
__forceinline vdouble4& operator &=(vdouble4& a, double b) { return a = a & b; }
__forceinline vdouble4& operator |=( vdouble4& a, const vdouble4& b ) { return a = a | b; }
__forceinline vdouble4& operator |=( vdouble4& a, const double b ) { return a = a | b; }
__forceinline vdouble4& operator |=(vdouble4& a, const vdouble4& b) { return a = a | b; }
__forceinline vdouble4& operator |=(vdouble4& a, double b) { return a = a | b; }
////////////////////////////////////////////////////////////////////////////////
@@ -180,38 +164,38 @@ 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 vboold4 operator ==(const vdouble4& a, const vdouble4& b) { return _mm256_cmp_pd_mask(a,b,_MM_CMPINT_EQ); }
__forceinline vboold4 operator !=(const vdouble4& a, const vdouble4& b) { return _mm256_cmp_pd_mask(a,b,_MM_CMPINT_NE); }
__forceinline vboold4 operator < (const vdouble4& a, const vdouble4& b) { return _mm256_cmp_pd_mask(a,b,_MM_CMPINT_LT); }
__forceinline vboold4 operator >=(const vdouble4& a, const vdouble4& b) { return _mm256_cmp_pd_mask(a,b,_MM_CMPINT_GE); }
__forceinline vboold4 operator > (const vdouble4& a, const vdouble4& b) { return _mm256_cmp_pd_mask(a,b,_MM_CMPINT_GT); }
__forceinline vboold4 operator <=(const vdouble4& a, const vdouble4& b) { return _mm256_cmp_pd_mask(a,b,_MM_CMPINT_LE); }
#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); }
__forceinline const vboold4 operator < ( const vdouble4& a, const vdouble4& b ) { return _mm256_cmp_pd(a,b,_CMP_LT_OQ); }
__forceinline const vboold4 operator >=( const vdouble4& a, const vdouble4& b ) { return _mm256_cmp_pd(a,b,_CMP_GE_OQ); }
__forceinline const vboold4 operator > ( const vdouble4& a, const vdouble4& b ) { return _mm256_cmp_pd(a,b,_CMP_GT_OQ); }
__forceinline const vboold4 operator <=( const vdouble4& a, const vdouble4& b ) { return _mm256_cmp_pd(a,b,_CMP_LE_OQ); }
__forceinline vboold4 operator ==(const vdouble4& a, const vdouble4& b) { return _mm256_cmp_pd(a,b,_CMP_EQ_UQ); }
__forceinline vboold4 operator !=(const vdouble4& a, const vdouble4& b) { return _mm256_cmp_pd(a,b,_CMP_NEQ_UQ); }
__forceinline vboold4 operator < (const vdouble4& a, const vdouble4& b) { return _mm256_cmp_pd(a,b,_CMP_LT_OQ); }
__forceinline vboold4 operator >=(const vdouble4& a, const vdouble4& b) { return _mm256_cmp_pd(a,b,_CMP_GE_OQ); }
__forceinline vboold4 operator > (const vdouble4& a, const vdouble4& b) { return _mm256_cmp_pd(a,b,_CMP_GT_OQ); }
__forceinline vboold4 operator <=(const vdouble4& a, const vdouble4& b) { return _mm256_cmp_pd(a,b,_CMP_LE_OQ); }
#endif
__forceinline const vboold4 operator ==( const vdouble4& a, const double b ) { return a == vdouble4(b); }
__forceinline const vboold4 operator ==( const double a, const vdouble4& b ) { return vdouble4(a) == b; }
__forceinline vboold4 operator ==(const vdouble4& a, double b) { return a == vdouble4(b); }
__forceinline vboold4 operator ==(double a, const vdouble4& b) { return vdouble4(a) == b; }
__forceinline const vboold4 operator !=( const vdouble4& a, const double b ) { return a != vdouble4(b); }
__forceinline const vboold4 operator !=( const double a, const vdouble4& b ) { return vdouble4(a) != b; }
__forceinline vboold4 operator !=(const vdouble4& a, double b) { return a != vdouble4(b); }
__forceinline vboold4 operator !=(double a, const vdouble4& b) { return vdouble4(a) != b; }
__forceinline const vboold4 operator < ( const vdouble4& a, const double b ) { return a < vdouble4(b); }
__forceinline const vboold4 operator < ( const double a, const vdouble4& b ) { return vdouble4(a) < b; }
__forceinline vboold4 operator < (const vdouble4& a, double b) { return a < vdouble4(b); }
__forceinline vboold4 operator < (double a, const vdouble4& b) { return vdouble4(a) < b; }
__forceinline const vboold4 operator >=( const vdouble4& a, const double b ) { return a >= vdouble4(b); }
__forceinline const vboold4 operator >=( const double a, const vdouble4& b ) { return vdouble4(a) >= b; }
__forceinline vboold4 operator >=(const vdouble4& a, double b) { return a >= vdouble4(b); }
__forceinline vboold4 operator >=(double a, const vdouble4& b) { return vdouble4(a) >= b; }
__forceinline const vboold4 operator > ( const vdouble4& a, const double b ) { return a > vdouble4(b); }
__forceinline const vboold4 operator > ( const double a, const vdouble4& b ) { return vdouble4(a) > b; }
__forceinline vboold4 operator > (const vdouble4& a, double b) { return a > vdouble4(b); }
__forceinline vboold4 operator > (double a, const vdouble4& b) { return vdouble4(a) > b; }
__forceinline const vboold4 operator <=( const vdouble4& a, const double b ) { return a <= vdouble4(b); }
__forceinline const vboold4 operator <=( const double a, const vdouble4& b ) { return vdouble4(a) <= b; }
__forceinline vboold4 operator <=(const vdouble4& a, double b) { return a <= vdouble4(b); }
__forceinline vboold4 operator <=(double a, const vdouble4& b) { return vdouble4(a) <= b; }
__forceinline vboold4 eq(const vdouble4& a, const vdouble4& b) { return a == b; }
__forceinline vboold4 ne(const vdouble4& a, const vdouble4& b) { return a != b; }
@@ -236,7 +220,7 @@ namespace embree
__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 ) {
__forceinline vdouble4 select(const vboold4& m, const vdouble4& t, const vdouble4& f) {
#if defined(__AVX512VL__)
return _mm256_mask_blend_pd(m, f, t);
#else
@@ -260,35 +244,43 @@ namespace embree
// Movement/Shifting/Shuffling Functions
////////////////////////////////////////////////////////////////////////////////
template<int B, int A> __forceinline vdouble4 shuffle (const vdouble4& v) { return _mm256_permute_pd(v,(int)_MM_SHUF_PERM2(B,A,B,A)); }
template<int A> __forceinline vdouble4 shuffle (const vdouble4& x) { return shuffle<A,A>(x); }
template<int i0, int i1>
__forceinline vdouble4 shuffle(const vdouble4& v) {
return _mm256_permute_pd(v, (i1 << 3) | (i0 << 2) | (i1 << 1) | i0);
}
template<int B, int A> __forceinline vdouble4 shuffle2 (const vdouble4& v) { return _mm256_permute2f128_pd(v,v,(int)_MM_SHUF_PERM3(B,A)); }
template<int i>
__forceinline vdouble4 shuffle(const vdouble4& v) {
return shuffle<i, i>(v);
}
__forceinline double toScalar(const vdouble4& a)
{
return _mm_cvtsd_f64(_mm256_castpd256_pd128(a));
template<int i0, int i1>
__forceinline vdouble4 shuffle2(const vdouble4& v) {
return _mm256_permute2f128_pd(v, v, (i1 << 4) | i0);
}
__forceinline double toScalar(const vdouble4& v) {
return _mm_cvtsd_f64(_mm256_castpd256_pd128(v));
}
////////////////////////////////////////////////////////////////////////////////
/// Reductions
////////////////////////////////////////////////////////////////////////////////
__forceinline vdouble4 vreduce_min2(const vdouble4& x) { return min(x,shuffle<0,1>(x)); }
__forceinline vdouble4 vreduce_min (const vdouble4& y) { const vdouble4 x = vreduce_min2(y); return min(x,shuffle2<0,1>(x)); }
__forceinline vdouble4 vreduce_min2(const vdouble4& x) { return min(x, shuffle<1,0>(x)); }
__forceinline vdouble4 vreduce_min (const vdouble4& y) { const vdouble4 x = vreduce_min2(y); return min(x, shuffle2<1,0>(x)); }
__forceinline vdouble4 vreduce_max2(const vdouble4& x) { return max(x,shuffle<0,1>(x)); }
__forceinline vdouble4 vreduce_max (const vdouble4& y) { const vdouble4 x = vreduce_max2(y); return max(x,shuffle2<0,1>(x)); }
__forceinline vdouble4 vreduce_max2(const vdouble4& x) { return max(x,shuffle<1,0>(x)); }
__forceinline vdouble4 vreduce_max (const vdouble4& y) { const vdouble4 x = vreduce_max2(y); return max(x, shuffle2<1,0>(x)); }
__forceinline vdouble4 vreduce_and2(const vdouble4& x) { return x & shuffle<0,1>(x); }
__forceinline vdouble4 vreduce_and (const vdouble4& y) { const vdouble4 x = vreduce_and2(y); return x & shuffle2<0,1>(x); }
__forceinline vdouble4 vreduce_and2(const vdouble4& x) { return x & shuffle<1,0>(x); }
__forceinline vdouble4 vreduce_and (const vdouble4& y) { const vdouble4 x = vreduce_and2(y); return x & shuffle2<1,0>(x); }
__forceinline vdouble4 vreduce_or2(const vdouble4& x) { return x | shuffle<0,1>(x); }
__forceinline vdouble4 vreduce_or (const vdouble4& y) { const vdouble4 x = vreduce_or2(y); return x | shuffle2<0,1>(x); }
__forceinline vdouble4 vreduce_or2(const vdouble4& x) { return x | shuffle<1,0>(x); }
__forceinline vdouble4 vreduce_or (const vdouble4& y) { const vdouble4 x = vreduce_or2(y); return x | shuffle2<1,0>(x); }
__forceinline vdouble4 vreduce_add2(const vdouble4& x) { return x + shuffle<0,1>(x); }
__forceinline vdouble4 vreduce_add (const vdouble4& y) { const vdouble4 x = vreduce_add2(y); return x + shuffle2<0,1>(x); }
__forceinline vdouble4 vreduce_add2(const vdouble4& x) { return x + shuffle<1,0>(x); }
__forceinline vdouble4 vreduce_add (const vdouble4& y) { const vdouble4 x = vreduce_add2(y); return x + shuffle2<1,0>(x); }
__forceinline double reduce_add(const vdouble4& a) { return toScalar(vreduce_add(a)); }
__forceinline double reduce_min(const vdouble4& a) { return toScalar(vreduce_min(a)); }
@@ -304,7 +296,7 @@ namespace embree
/// Output Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline std::ostream& operator<<(std::ostream& cout, const vdouble4& v)
__forceinline std::ostream& operator <<(std::ostream& cout, const vdouble4& v)
{
cout << "<" << v[0];
for (size_t i=1; i<4; i++) cout << ", " << v[i];
+125 -125
View File
@@ -18,7 +18,7 @@
namespace embree
{
/* 8-wide AVX-512 64bit double type */
/* 8-wide AVX-512 64-bit double type */
template<>
struct vdouble<8>
{
@@ -36,22 +36,22 @@ namespace embree
__forceinline vdouble() {}
__forceinline vdouble(const vdouble8& t) { v = t.v; }
__forceinline vdouble8& operator=(const vdouble8& f) { v = f.v; return *this; }
__forceinline vdouble8& operator =(const vdouble8& f) { v = f.v; return *this; }
__forceinline vdouble(const __m512d& t) { v = t; }
__forceinline operator __m512d () const { return v; }
__forceinline operator __m256d () const { return _mm512_castpd512_pd256(v); }
__forceinline operator __m512d() const { return v; }
__forceinline operator __m256d() const { return _mm512_castpd512_pd256(v); }
__forceinline vdouble(const double i) {
__forceinline vdouble(double i) {
v = _mm512_set1_pd(i);
}
__forceinline vdouble(const double a, const double b, const double c, const double d) {
__forceinline vdouble(double a, double b, double c, double d) {
v = _mm512_set4_pd(d,c,b,a);
}
__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)
__forceinline vdouble(double a0, double a1, double a2, double a3,
double a4, double a5, double a6, double a7)
{
v = _mm512_set_pd(a7,a6,a5,a4,a3,a2,a1,a0);
}
@@ -61,21 +61,17 @@ namespace embree
/// 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( 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 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(ReverseStepTy) : v(_mm512_setr_pd(7.0,6.0,5.0,4.0,3.0,2.0,1.0,0.0)) {}
////////////////////////////////////////////////////////////////////////////////
/// Loads and Stores
////////////////////////////////////////////////////////////////////////////////
static __forceinline void store_nt(void *__restrict__ ptr, const vdouble8& a) {
_mm512_stream_pd((double*)ptr,a);
_mm512_stream_pd((double*)ptr, a);
}
static __forceinline vdouble8 loadu(const void* addr) {
@@ -91,36 +87,36 @@ namespace embree
}
static __forceinline void store(void* ptr, const vdouble8& v) {
_mm512_store_pd(ptr,v);
_mm512_store_pd(ptr, v);
}
static __forceinline void storeu(void* ptr, const vdouble8& v ) {
_mm512_storeu_pd(ptr,v);
static __forceinline void storeu(void* ptr, const vdouble8& v) {
_mm512_storeu_pd(ptr, v);
}
static __forceinline void storeu(const vboold8& mask, double* ptr, const vdouble8& f ) {
_mm512_mask_storeu_pd(ptr,mask,f);
static __forceinline void storeu(const vboold8& mask, double* ptr, const vdouble8& f) {
_mm512_mask_storeu_pd(ptr, mask, f);
}
static __forceinline void store(const vboold8& mask, void* addr, const vdouble8& v2) {
_mm512_mask_store_pd(addr,mask,v2);
_mm512_mask_store_pd(addr, mask, v2);
}
/* 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);
_mm512_mask_compressstoreu_pd(addr, mask, reg);
}
static __forceinline vdouble8 compact64bit(const vboold8& mask, vdouble8& v) {
return _mm512_mask_compress_pd(v,mask,v);
return _mm512_mask_compress_pd(v, mask, v);
}
static __forceinline vdouble8 compact(const vboold8& mask, vdouble8& v) {
return _mm512_mask_compress_pd(v,mask,v);
return _mm512_mask_compress_pd(v, mask, v);
}
static __forceinline vdouble8 compact(const vboold8& mask, const vdouble8& a, vdouble8& b) {
return _mm512_mask_compress_pd(a,mask,b);
return _mm512_mask_compress_pd(a, mask, b);
}
@@ -128,8 +124,8 @@ 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]; }
__forceinline double& operator [](size_t index) { assert(index < 8); return i[index]; }
__forceinline const double& operator [](size_t index) const { assert(index < 8); return i[index]; }
};
@@ -137,112 +133,112 @@ namespace embree
/// Unary Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline const vdouble8 asDouble ( const __m512& a ) { return _mm512_castps_pd(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); }
__forceinline vdouble8 asDouble (const __m512& a) { return _mm512_castps_pd(a); }
__forceinline vdouble8 operator +(const vdouble8& a) { return a; }
__forceinline vdouble8 operator -(const vdouble8& a) { return _mm512_sub_pd(_mm512_setzero_pd(), a); }
////////////////////////////////////////////////////////////////////////////////
/// Binary Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline const vdouble8 operator +( const vdouble8& a, const vdouble8& b ) { return _mm512_add_pd(a, b); }
__forceinline const vdouble8 operator +( const vdouble8& a, const double b ) { return a + vdouble8(b); }
__forceinline const vdouble8 operator +( const double a, const vdouble8& b ) { return vdouble8(a) + b; }
__forceinline vdouble8 operator +(const vdouble8& a, const vdouble8& b) { return _mm512_add_pd(a, b); }
__forceinline vdouble8 operator +(const vdouble8& a, double b) { return a + vdouble8(b); }
__forceinline vdouble8 operator +(double a, const vdouble8& b) { return vdouble8(a) + b; }
__forceinline const vdouble8 operator -( const vdouble8& a, const vdouble8& b ) { return _mm512_sub_pd(a, b); }
__forceinline const vdouble8 operator -( const vdouble8& a, const double b ) { return a - vdouble8(b); }
__forceinline const vdouble8 operator -( const double a, const vdouble8& b ) { return vdouble8(a) - b; }
__forceinline vdouble8 operator -(const vdouble8& a, const vdouble8& b) { return _mm512_sub_pd(a, b); }
__forceinline vdouble8 operator -(const vdouble8& a, double b) { return a - vdouble8(b); }
__forceinline vdouble8 operator -(double a, const vdouble8& b) { return vdouble8(a) - b; }
__forceinline const vdouble8 operator *( const vdouble8& a, const vdouble8& b ) { return _mm512_mul_pd(a, b); }
__forceinline const vdouble8 operator *( const vdouble8& a, const double b ) { return a * vdouble8(b); }
__forceinline const vdouble8 operator *( const double a, const vdouble8& b ) { return vdouble8(a) * b; }
__forceinline vdouble8 operator *(const vdouble8& a, const vdouble8& b) { return _mm512_mul_pd(a, b); }
__forceinline vdouble8 operator *(const vdouble8& a, double b) { return a * vdouble8(b); }
__forceinline vdouble8 operator *(double a, const vdouble8& b) { return vdouble8(a) * b; }
__forceinline const vdouble8 operator &( const vdouble8& a, const vdouble8& b ) { return _mm512_and_pd(a, b); }
__forceinline const vdouble8 operator &( const vdouble8& a, const double b ) { return a & vdouble8(b); }
__forceinline const vdouble8 operator &( const double a, const vdouble8& b ) { return vdouble8(a) & b; }
__forceinline vdouble8 operator &(const vdouble8& a, const vdouble8& b) { return _mm512_and_pd(a, b); }
__forceinline vdouble8 operator &(const vdouble8& a, double b) { return a & vdouble8(b); }
__forceinline vdouble8 operator &(double a, const vdouble8& b) { return vdouble8(a) & b; }
__forceinline const vdouble8 operator |( const vdouble8& a, const vdouble8& b ) { return _mm512_or_pd(a, b); }
__forceinline const vdouble8 operator |( const vdouble8& a, const double b ) { return a | vdouble8(b); }
__forceinline const vdouble8 operator |( const double a, const vdouble8& b ) { return vdouble8(a) | b; }
__forceinline vdouble8 operator |(const vdouble8& a, const vdouble8& b) { return _mm512_or_pd(a, b); }
__forceinline vdouble8 operator |(const vdouble8& a, double b) { return a | vdouble8(b); }
__forceinline vdouble8 operator |(double a, const vdouble8& b) { return vdouble8(a) | b; }
__forceinline const vdouble8 operator ^( const vdouble8& a, const vdouble8& b ) { return _mm512_xor_pd(a, b); }
__forceinline const vdouble8 operator ^( const vdouble8& a, const double b ) { return a ^ vdouble8(b); }
__forceinline const vdouble8 operator ^( const double a, const vdouble8& b ) { return vdouble8(a) ^ b; }
__forceinline vdouble8 operator ^(const vdouble8& a, const vdouble8& b) { return _mm512_xor_pd(a, b); }
__forceinline vdouble8 operator ^(const vdouble8& a, double b) { return a ^ vdouble8(b); }
__forceinline vdouble8 operator ^(double a, const vdouble8& b) { return vdouble8(a) ^ b; }
__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 vdouble8 operator <<(const vdouble8& a, const unsigned int n) { return _mm512_castsi512_pd(_mm512_slli_epi64(_mm512_castpd_si512(a), n)); }
__forceinline 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 vdouble8 operator <<(const vdouble8& a, const vllong8& n) { return _mm512_castsi512_pd(_mm512_sllv_epi64(_mm512_castpd_si512(a), n)); }
__forceinline vdouble8 operator >>(const vdouble8& a, const vllong8& 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 vdouble8 sll (const vdouble8& a, const unsigned int b) { return _mm512_castsi512_pd(_mm512_slli_epi64(_mm512_castpd_si512(a), b)); }
__forceinline vdouble8 sra (const vdouble8& a, const unsigned int b) { return _mm512_castsi512_pd(_mm512_srai_epi64(_mm512_castpd_si512(a), b)); }
__forceinline 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); }
__forceinline vdouble8 min(const vdouble8& a, const vdouble8& b) { return _mm512_min_pd(a, b); }
__forceinline vdouble8 min(const vdouble8& a, double b) { return min(a,vdouble8(b)); }
__forceinline vdouble8 min(double a, const vdouble8& b) { return min(vdouble8(a),b); }
__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 vdouble8 max(const vdouble8& a, const vdouble8& b) { return _mm512_max_pd(a, b); }
__forceinline vdouble8 max(const vdouble8& a, double b) { return max(a,vdouble8(b)); }
__forceinline vdouble8 max(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); }
__forceinline vdouble8 mask_add(const vboold8& mask, vdouble8& c, const vdouble8& a, const vdouble8& b) { return _mm512_mask_add_pd(c,mask,a,b); }
__forceinline vdouble8 mask_sub(const vboold8& mask, vdouble8& c, const vdouble8& a, const vdouble8& b) { return _mm512_mask_sub_pd(c,mask,a,b); }
__forceinline const vdouble8 mask_and(const vboold8& m,vdouble8& c, const vdouble8& a, const vdouble8& b) { return _mm512_mask_and_pd(c,m,a,b); }
__forceinline const vdouble8 mask_or (const vboold8& m,vdouble8& c, const vdouble8& a, const vdouble8& b) { return _mm512_mask_or_pd(c,m,a,b); }
__forceinline vdouble8 mask_and(const vboold8& m,vdouble8& c, const vdouble8& a, const vdouble8& b) { return _mm512_mask_and_pd(c,m,a,b); }
__forceinline vdouble8 mask_or (const vboold8& m,vdouble8& c, const vdouble8& a, const vdouble8& b) { return _mm512_mask_or_pd(c,m,a,b); }
////////////////////////////////////////////////////////////////////////////////
/// Assignment Operators
////////////////////////////////////////////////////////////////////////////////
__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, 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, 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, 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, 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, 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; }
__forceinline vdouble8& operator <<=(vdouble8& a, const double b) { return a = a << b; }
__forceinline vdouble8& operator >>=(vdouble8& a, const double b) { return a = a >> b; }
////////////////////////////////////////////////////////////////////////////////
/// Comparison Operators + Select
////////////////////////////////////////////////////////////////////////////////
__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 vboold8 operator ==(const vdouble8& a, const vdouble8& b) { return _mm512_cmp_pd_mask(a,b,_MM_CMPINT_EQ); }
__forceinline vboold8 operator ==(const vdouble8& a, double b) { return a == vdouble8(b); }
__forceinline vboold8 operator ==(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 vboold8 operator !=(const vdouble8& a, const vdouble8& b) { return _mm512_cmp_pd_mask(a,b,_MM_CMPINT_NE); }
__forceinline vboold8 operator !=(const vdouble8& a, double b) { return a != vdouble8(b); }
__forceinline vboold8 operator !=(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 vboold8 operator < (const vdouble8& a, const vdouble8& b) { return _mm512_cmp_pd_mask(a,b,_MM_CMPINT_LT); }
__forceinline vboold8 operator < (const vdouble8& a, double b) { return a < vdouble8(b); }
__forceinline vboold8 operator < (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; }
__forceinline vboold8 operator >=(const vdouble8& a, const vdouble8& b) { return _mm512_cmp_pd_mask(a,b,_MM_CMPINT_GE); }
__forceinline vboold8 operator >=(const vdouble8& a, double b) { return a >= vdouble8(b); }
__forceinline vboold8 operator >=(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_GT); }
__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 operator > (const vdouble8& a, const vdouble8& b) { return _mm512_cmp_pd_mask(a,b,_MM_CMPINT_GT); }
__forceinline vboold8 operator > (const vdouble8& a, double b) { return a > vdouble8(b); }
__forceinline vboold8 operator > (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_LE); }
__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 operator <=(const vdouble8& a, const vdouble8& b) { return _mm512_cmp_pd_mask(a,b,_MM_CMPINT_LE); }
__forceinline vboold8 operator <=(const vdouble8& a, double b) { return a <= vdouble8(b); }
__forceinline vboold8 operator <=(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); }
@@ -258,7 +254,7 @@ namespace embree
__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 const vdouble8 select( const vboold8& m, const vdouble8& t, const vdouble8& f ) {
__forceinline vdouble8 select(const vboold8& m, const vdouble8& t, const vdouble8& f) {
return _mm512_mask_or_pd(f,m,t,t);
}
@@ -278,34 +274,38 @@ 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 i0, int i1>
__forceinline vdouble8 shuffle(const vdouble8& v) {
return _mm512_permute_pd(v, (i1 << 7) | (i0 << 6) | (i1 << 5) | (i0 << 4) | (i1 << 3) | (i0 << 2) | (i1 << 1) | i0);
}
template<int i>
__forceinline vdouble8 shuffle4(const vdouble8& x) {
return _mm512_shuffle_f64x2(x,x,_MM_SHUFFLE(i,i,i,i));
__forceinline vdouble8 shuffle(const vdouble8& v) {
return shuffle<i, i>(v);
}
template<int A, int B>
__forceinline vdouble8 shuffle4(const vdouble8& x) {
return _mm512_shuffle_f64x2(x,x,_MM_SHUFFLE(0,0,B,A));
template<int i0, int i1, int i2, int i3>
__forceinline vdouble8 shuffle(const vdouble8& v) {
return _mm512_permutex_pd(v, _MM_SHUFFLE(i3, i2, i1, i0));
}
template<int i0, int i1>
__forceinline vdouble8 shuffle4(const vdouble8& v) {
return _mm512_shuffle_f64x2(v, v, _MM_SHUFFLE(i1*2+1, i1*2, i0*2+1, i0*2));
}
template<int i>
__forceinline vdouble8 shuffle4(const vdouble8& v) {
return shuffle4<i, i>(v);
}
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));
__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));
}
__forceinline double toScalar(const vdouble8& a) {
return _mm_cvtsd_f64(_mm512_castpd512_pd128(a));
__forceinline double toScalar(const vdouble8& v) {
return _mm_cvtsd_f64(_mm512_castpd512_pd128(v));
}
////////////////////////////////////////////////////////////////////////////////
@@ -316,13 +316,13 @@ namespace embree
__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 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_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(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_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 double reduce_add(const vdouble8& v) { return toScalar(vreduce_add(v)); }
__forceinline double reduce_min(const vdouble8& v) { return toScalar(vreduce_min(v)); }
@@ -333,18 +333,18 @@ namespace embree
////////////////////////////////////////////////////////////////////////////////
__forceinline vdouble8 permute(const vdouble8& v, const vllong8& index) {
return _mm512_permutexvar_pd(index,v);
return _mm512_permutexvar_pd(index, v);
}
__forceinline vdouble8 reverse(const vdouble8& a) {
return permute(a,vllong8(reverse_step));
return permute(a, vllong8(reverse_step));
}
////////////////////////////////////////////////////////////////////////////////
/// Output Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline std::ostream& operator<<(std::ostream& cout, const vdouble8& v)
__forceinline std::ostream& operator <<(std::ostream& cout, const vdouble8& v)
{
cout << "<" << v[0];
for (size_t i=1; i<8; i++) cout << ", " << v[i];
+295 -193
View File
@@ -39,47 +39,51 @@ namespace embree
__forceinline vfloat() {}
__forceinline vfloat(const vfloat16& t) { v = t; }
__forceinline vfloat16& operator=(const vfloat16& f) { v = f.v; return *this; }
__forceinline vfloat16& operator =(const vfloat16& f) { v = f.v; return *this; }
__forceinline vfloat(const __m512& t) { v = t; }
__forceinline operator __m512 () const { return v; }
__forceinline operator __m256 () const { return _mm512_castps512_ps256(v); }
__forceinline operator __m512() const { return v; }
__forceinline operator __m256() const { return _mm512_castps512_ps256(v); }
__forceinline vfloat(const float& f) {
__forceinline vfloat(float f) {
v = _mm512_set1_ps(f);
}
__forceinline vfloat(const float& a, const float& b, const float& c, const float& d) {
v = _mm512_set4_ps(a,b,c,d);
__forceinline vfloat(float a, float b, float c, float d) {
v = _mm512_set4_ps(a, b, c, d);
}
__forceinline vfloat(const vfloat4 &i) {
__forceinline vfloat(const vfloat4& i) {
v = _mm512_broadcast_f32x4(i);
}
__forceinline vfloat(const vfloat4 &a, const vfloat4 &b, const vfloat4 &c, const vfloat4 &d) {
v = _mm512_broadcast_f32x4(a);
__forceinline vfloat(const vfloat4& a, const vfloat4& b, const vfloat4& c, const vfloat4& d) {
v = _mm512_castps128_ps512(a);
v = _mm512_insertf32x4(v, b, 1);
v = _mm512_insertf32x4(v, c, 2);
v = _mm512_insertf32x4(v, d, 3);
}
__forceinline vfloat(const vboolf16& mask, const vfloat4 &a, const vfloat4 &b) {
__forceinline vfloat(const vboolf16& mask, const vfloat4& a, const vfloat4& b) {
v = _mm512_broadcast_f32x4(a);
v = _mm512_mask_broadcast_f32x4(v,mask,b);
}
__forceinline vfloat(const vfloat8 &i) {
__forceinline vfloat(const vfloat8& i) {
v = _mm512_castpd_ps(_mm512_broadcast_f64x4(_mm256_castps_pd(i)));
}
__forceinline vfloat(const vfloat8 &a, const vfloat8 &b) { // FIXME: optimize
const vfloat aa = _mm512_castpd_ps(_mm512_broadcast_f64x4(_mm256_castps_pd(a)));
const vfloat bb = _mm512_castpd_ps(_mm512_broadcast_f64x4(_mm256_castps_pd(b)));
v = _mm512_mask_blend_ps(0xff, bb, aa);
__forceinline vfloat(const vfloat8& a, const vfloat8& b) {
v = _mm512_castps256_ps512(a);
#if defined(__AVX512DQ__)
v = _mm512_insertf32x8(v, b, 1);
#else
v = _mm512_castpd_ps(_mm512_insertf64x4(_mm512_castps_pd(v), _mm256_castps_pd(b), 1));
#endif
}
/* WARNING: due to f64x4 the mask is considered as an 8bit mask */
__forceinline vfloat(const vboolf16& mask, const vfloat8 &a, const vfloat8 &b) {
__forceinline vfloat(const vboolf16& mask, const vfloat8& a, const vfloat8& b) {
__m512d aa = _mm512_broadcast_f64x4(_mm256_castps_pd(a));
aa = _mm512_mask_broadcast_f64x4(aa,mask,_mm256_castps_pd(b));
v = _mm512_castpd_ps(aa);
@@ -89,111 +93,127 @@ namespace embree
v = _mm512_cvtepi32_ps(a);
}
////////////////////////////////////////////////////////////////////////////////
/// Constants
////////////////////////////////////////////////////////////////////////////////
__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(UndefinedTy) : v(_mm512_undefined_ps()) {}
////////////////////////////////////////////////////////////////////////////////
/// Loads and Stores
////////////////////////////////////////////////////////////////////////////////
static __forceinline vfloat16 load (const void* const ptr) { return _mm512_load_ps((float*)ptr); }
static __forceinline vfloat16 loadu(const void* const ptr) { return _mm512_loadu_ps((float*)ptr); }
static __forceinline vfloat16 load (const void* ptr) { return _mm512_load_ps((float*)ptr); }
static __forceinline vfloat16 loadu(const void* ptr) { return _mm512_loadu_ps((float*)ptr); }
static __forceinline vfloat16 load (const vboolf16& mask, const void* const ptr) { return _mm512_mask_load_ps (_mm512_setzero_ps(),mask,(float*)ptr); }
static __forceinline vfloat16 loadu(const vboolf16& mask, const void* const ptr) { return _mm512_mask_loadu_ps(_mm512_setzero_ps(),mask,(float*)ptr); }
static __forceinline vfloat16 load (const vboolf16& mask, const void* ptr) { return _mm512_mask_load_ps (_mm512_setzero_ps(),mask,(float*)ptr); }
static __forceinline vfloat16 loadu(const vboolf16& mask, const void* ptr) { return _mm512_mask_loadu_ps(_mm512_setzero_ps(),mask,(float*)ptr); }
static __forceinline void store (void* const ptr, const vfloat16& v) { _mm512_store_ps ((float*)ptr,v); }
static __forceinline void storeu(void* const ptr, const vfloat16& v) { _mm512_storeu_ps((float*)ptr,v); }
static __forceinline void store (void* ptr, const vfloat16& v) { _mm512_store_ps ((float*)ptr,v); }
static __forceinline void storeu(void* ptr, const vfloat16& v) { _mm512_storeu_ps((float*)ptr,v); }
static __forceinline void store (const vboolf16& mask, void* ptr, const vfloat16& v) { _mm512_mask_store_ps ((float*)ptr,mask,v); }
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) {
static __forceinline void store_nt(void* __restrict__ ptr, const vfloat16& a) {
_mm512_stream_ps((float*)ptr,a);
}
static __forceinline vfloat16 broadcast(const float *const f) {
static __forceinline vfloat16 broadcast(const float* f) {
return _mm512_set1_ps(*f);
}
static __forceinline vfloat16 compact(const vboolf16& mask, vfloat16 &v) {
return _mm512_mask_compress_ps(v,mask,v);
return _mm512_mask_compress_ps(v, mask, v);
}
static __forceinline vfloat16 compact(const vboolf16& mask, const vfloat16 &a, vfloat16 &b) {
return _mm512_mask_compress_ps(a,mask,b);
static __forceinline vfloat16 compact(const vboolf16& mask, vfloat16 &a, const 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);
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);
static __forceinline vfloat16 loadu_compact(const vboolf16& mask, const void* ptr) {
return _mm512_mask_expandloadu_ps(_mm512_setzero_ps(), mask, (float*)ptr);
}
static __forceinline void storeu_compact(const vboolf16& mask, float *addr, const vfloat16 reg) {
_mm512_mask_compressstoreu_ps(addr,mask,reg);
_mm512_mask_compressstoreu_ps(addr, mask, reg);
}
static __forceinline void storeu_compact_single(const vboolf16& mask, float * addr, const vfloat16 &reg) {
static __forceinline void storeu_compact_single(const vboolf16& mask, float * addr, const vfloat16& reg) {
//_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));
}
template<int scale = 4>
static __forceinline vfloat16 gather(const float* ptr, const vint16& index) {
return _mm512_i32gather_ps(index, ptr, scale);
}
////////////////////////////////////////////////////////////////////////////////
/// Constants
////////////////////////////////////////////////////////////////////////////////
__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)) {}
template<int scale = 4>
static __forceinline vfloat16 gather(const vboolf16& mask, const float* ptr, const vint16& index) {
vfloat16 r = zero;
return _mm512_mask_i32gather_ps(r, mask, index, ptr, scale);
}
__forceinline static vfloat16 undefined() { return _mm512_undefined_ps(); }
__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); }
template<int scale = 4>
static __forceinline void scatter(float* ptr, const vint16& index, const vfloat16& v) {
_mm512_i32scatter_ps(ptr, index, v, scale);
}
template<int scale = 4>
static __forceinline void scatter(const vboolf16& mask, float* ptr, const vint16& index, const vfloat16& v) {
_mm512_mask_i32scatter_ps(ptr, mask, index, v, scale);
}
////////////////////////////////////////////////////////////////////////////////
/// Array Access
////////////////////////////////////////////////////////////////////////////////
__forceinline float& operator [](const size_t index) { assert(index < 16); return f[index]; }
__forceinline const float& operator [](const size_t index) const { assert(index < 16); return f[index]; }
__forceinline float& operator [](size_t index) { assert(index < 16); return f[index]; }
__forceinline const float& operator [](size_t index) const { assert(index < 16); return f[index]; }
};
////////////////////////////////////////////////////////////////////////////////
/// Unary Operators
////////////////////////////////////////////////////////////////////////////////
__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 signmsk ( const vfloat16& a ) { return _mm512_castsi512_ps(_mm512_and_epi32(_mm512_castps_si512(a),_mm512_set1_epi32(0x80000000))); }
__forceinline vfloat16 asFloat(const __m512i& a) { return _mm512_castsi512_ps(a); }
__forceinline const vfloat16 rcp(const vfloat16& a) {
__forceinline vfloat16 operator +(const vfloat16& a) { return a; }
__forceinline vfloat16 operator -(const vfloat16& a) { return _mm512_mul_ps(a,vfloat16(-1)); }
__forceinline vfloat16 abs (const vfloat16& a) { return _mm512_castsi512_ps(_mm512_and_epi32(_mm512_castps_si512(a),_mm512_set1_epi32(0x7FFFFFFF))); }
__forceinline vfloat16 signmsk(const vfloat16& a) { return _mm512_castsi512_ps(_mm512_and_epi32(_mm512_castps_si512(a),_mm512_set1_epi32(0x80000000))); }
__forceinline vfloat16 rcp(const vfloat16& a) {
#if defined(__AVX512ER__)
return _mm512_rcp28_ps(a);
#else
const vfloat16 r = _mm512_rcp14_ps(a.v);
const vfloat16 r = _mm512_rcp14_ps(a);
return _mm512_mul_ps(r, _mm512_fnmadd_ps(r, a, vfloat16(2.0f)));
#endif
}
__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 vfloat16 sqr (const vfloat16& a) { return _mm512_mul_ps(a,a); }
__forceinline vfloat16 sqrt(const vfloat16& a) { return _mm512_sqrt_ps(a); }
__forceinline const vfloat16 rsqrt( const vfloat16& a )
__forceinline vfloat16 rsqrt(const vfloat16& a)
{
#if defined(__AVX512VL__)
const vfloat16 r = _mm512_rsqrt14_ps(a.v);
const vfloat16 r = _mm512_rsqrt14_ps(a);
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);
return _mm512_rsqrt28_ps(a);
#endif
}
@@ -201,43 +221,43 @@ namespace embree
/// Binary Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline const vfloat16 operator +( const vfloat16& a, const vfloat16& b ) { return _mm512_add_ps(a, b); }
__forceinline const vfloat16 operator +( const vfloat16& a, const float& b ) { return a + vfloat16(b); }
__forceinline const vfloat16 operator +( const float& a, const vfloat16& b ) { return vfloat16(a) + b; }
__forceinline vfloat16 operator +(const vfloat16& a, const vfloat16& b) { return _mm512_add_ps(a, b); }
__forceinline vfloat16 operator +(const vfloat16& a, float b) { return a + vfloat16(b); }
__forceinline vfloat16 operator +(float a, const vfloat16& b) { return vfloat16(a) + b; }
__forceinline const vfloat16 operator -( const vfloat16& a, const vfloat16& b ) { return _mm512_sub_ps(a, b); }
__forceinline const vfloat16 operator -( const vfloat16& a, const float& b ) { return a - vfloat16(b); }
__forceinline const vfloat16 operator -( const float& a, const vfloat16& b ) { return vfloat16(a) - b; }
__forceinline vfloat16 operator -(const vfloat16& a, const vfloat16& b) { return _mm512_sub_ps(a, b); }
__forceinline vfloat16 operator -(const vfloat16& a, float b) { return a - vfloat16(b); }
__forceinline vfloat16 operator -(float a, const vfloat16& b) { return vfloat16(a) - b; }
__forceinline const vfloat16 operator *( const vfloat16& a, const vfloat16& b ) { return _mm512_mul_ps(a, b); }
__forceinline const vfloat16 operator *( const vfloat16& a, const float& b ) { return a * vfloat16(b); }
__forceinline const vfloat16 operator *( const float& a, const vfloat16& b ) { return vfloat16(a) * b; }
__forceinline vfloat16 operator *(const vfloat16& a, const vfloat16& b) { return _mm512_mul_ps(a, b); }
__forceinline vfloat16 operator *(const vfloat16& a, float b) { return a * vfloat16(b); }
__forceinline vfloat16 operator *(float a, const vfloat16& b) { return vfloat16(a) * b; }
__forceinline const vfloat16 operator /( const vfloat16& a, const vfloat16& b ) { return _mm512_div_ps(a,b); }
__forceinline const vfloat16 operator /( const vfloat16& a, const float& b ) { return a/vfloat16(b); }
__forceinline const vfloat16 operator /( const float& a, const vfloat16& b ) { return vfloat16(a)/b; }
__forceinline vfloat16 operator /(const vfloat16& a, const vfloat16& b) { return _mm512_div_ps(a,b); }
__forceinline vfloat16 operator /(const vfloat16& a, float b) { return a/vfloat16(b); }
__forceinline vfloat16 operator /(float a, const vfloat16& b) { return vfloat16(a)/b; }
__forceinline const vfloat16 operator^(const vfloat16& a, const vfloat16& b) {
__forceinline vfloat16 operator ^(const vfloat16& a, const vfloat16& b) {
return _mm512_castsi512_ps(_mm512_xor_epi32(_mm512_castps_si512(a),_mm512_castps_si512(b)));
}
__forceinline const vfloat16 min( const vfloat16& a, const vfloat16& b ) {
__forceinline vfloat16 min(const vfloat16& a, const vfloat16& b) {
return _mm512_min_ps(a,b);
}
__forceinline const vfloat16 min( const vfloat16& a, const float& b ) {
__forceinline vfloat16 min(const vfloat16& a, float b) {
return _mm512_min_ps(a,vfloat16(b));
}
__forceinline const vfloat16 min( const float& a, const vfloat16& b ) {
__forceinline vfloat16 min(const float& a, const vfloat16& b) {
return _mm512_min_ps(vfloat16(a),b);
}
__forceinline const vfloat16 max( const vfloat16& a, const vfloat16& b ) {
__forceinline vfloat16 max(const vfloat16& a, const vfloat16& b) {
return _mm512_max_ps(a,b);
}
__forceinline const vfloat16 max( const vfloat16& a, const float& b ) {
__forceinline vfloat16 max(const vfloat16& a, float b) {
return _mm512_max_ps(a,vfloat16(b));
}
__forceinline const vfloat16 max( const float& a, const vfloat16& b ) {
__forceinline vfloat16 max(const float& a, const vfloat16& b) {
return _mm512_max_ps(vfloat16(a),b);
}
@@ -276,12 +296,11 @@ namespace embree
////////////////////////////////////////////////////////////////////////////////
__forceinline vfloat16 madd (const vfloat16& a, const vfloat16& b, const vfloat16& c) { return _mm512_fmadd_ps(a,b,c); }
__forceinline vfloat16 msub (const vfloat16& a, const vfloat16& b, const vfloat16& c) { return _mm512_fmsub_ps(a,b,c); }
__forceinline vfloat16 nmadd (const vfloat16& a, const vfloat16& b, const vfloat16& c) { return _mm512_fnmadd_ps(a,b,c); }
__forceinline vfloat16 nmsub (const vfloat16& a, const vfloat16& b, const vfloat16& c) { return _mm512_fnmsub_ps(a,b,c); }
__forceinline vfloat16 nmadd(const vfloat16& a, const vfloat16& b, const vfloat16& c) { return _mm512_fnmadd_ps(a,b,c); }
__forceinline vfloat16 nmsub(const vfloat16& a, const vfloat16& b, const vfloat16& c) { return _mm512_fnmsub_ps(a,b,c); }
__forceinline vfloat16 mask_msub (const vboolf16& mask,const vfloat16& a, const vfloat16& b, const vfloat16& c) { return _mm512_mask_fmsub_ps(a,mask,b,c); }
__forceinline vfloat16 mask_msub(const vboolf16& mask,const vfloat16& a, const vfloat16& b, const vfloat16& c) { return _mm512_mask_fmsub_ps(a,mask,b,c); }
__forceinline vfloat16 madd231 (const vfloat16& a, const vfloat16& b, const vfloat16& c) { return _mm512_fmadd_ps(c,b,a); }
__forceinline vfloat16 msub213 (const vfloat16& a, const vfloat16& b, const vfloat16& c) { return _mm512_fmsub_ps(a,b,c); }
@@ -293,74 +312,74 @@ 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 | _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 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 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 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 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 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 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 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_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_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); }
__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
////////////////////////////////////////////////////////////////////////////////
__forceinline vfloat16& operator +=( vfloat16& a, const vfloat16& b ) { return a = a + b; }
__forceinline vfloat16& operator +=( vfloat16& a, const float& b ) { return a = a + b; }
__forceinline vfloat16& operator +=(vfloat16& a, const vfloat16& b) { return a = a + b; }
__forceinline vfloat16& operator +=(vfloat16& a, float b) { return a = a + b; }
__forceinline vfloat16& operator -=( vfloat16& a, const vfloat16& b ) { return a = a - b; }
__forceinline vfloat16& operator -=( vfloat16& a, const float& b ) { return a = a - b; }
__forceinline vfloat16& operator -=(vfloat16& a, const vfloat16& b) { return a = a - b; }
__forceinline vfloat16& operator -=(vfloat16& a, float b) { return a = a - b; }
__forceinline vfloat16& operator *=( vfloat16& a, const vfloat16& b ) { return a = a * b; }
__forceinline vfloat16& operator *=( vfloat16& a, const float& b ) { return a = a * b; }
__forceinline vfloat16& operator *=(vfloat16& a, const vfloat16& b) { return a = a * b; }
__forceinline vfloat16& operator *=(vfloat16& a, float b) { return a = a * b; }
__forceinline vfloat16& operator /=( vfloat16& a, const vfloat16& b ) { return a = a / b; }
__forceinline vfloat16& operator /=( vfloat16& a, const float& b ) { return a = a / b; }
__forceinline vfloat16& operator /=(vfloat16& a, const vfloat16& b) { return a = a / b; }
__forceinline vfloat16& operator /=(vfloat16& a, float b) { return a = a / b; }
////////////////////////////////////////////////////////////////////////////////
/// Comparison Operators + Select
////////////////////////////////////////////////////////////////////////////////
__forceinline const vboolf16 operator ==( const vfloat16& a, const vfloat16& b ) { return _mm512_cmp_ps_mask(a,b,_MM_CMPINT_EQ); }
__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 operator ==(const vfloat16& a, const vfloat16& b) { return _mm512_cmp_ps_mask(a,b,_MM_CMPINT_EQ); }
__forceinline vboolf16 operator ==(const vfloat16& a, float b) { return a == vfloat16(b); }
__forceinline vboolf16 operator ==(float a, const vfloat16& b) { return vfloat16(a) == b; }
__forceinline const vboolf16 operator !=( const vfloat16& a, const vfloat16& b ) { return _mm512_cmp_ps_mask(a,b,_MM_CMPINT_NE); }
__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 operator !=(const vfloat16& a, const vfloat16& b) { return _mm512_cmp_ps_mask(a,b,_MM_CMPINT_NE); }
__forceinline vboolf16 operator !=(const vfloat16& a, float b) { return a != vfloat16(b); }
__forceinline vboolf16 operator !=(float a, const vfloat16& b) { return vfloat16(a) != b; }
__forceinline const vboolf16 operator < ( const vfloat16& a, const vfloat16& b ) { return _mm512_cmp_ps_mask(a,b,_MM_CMPINT_LT); }
__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 operator < (const vfloat16& a, const vfloat16& b) { return _mm512_cmp_ps_mask(a,b,_MM_CMPINT_LT); }
__forceinline vboolf16 operator < (const vfloat16& a, float b) { return a < vfloat16(b); }
__forceinline vboolf16 operator < (float a, const vfloat16& b) { return vfloat16(a) < b; }
__forceinline const vboolf16 operator >=( const vfloat16& a, const vfloat16& b ) { return _mm512_cmp_ps_mask(a,b,_MM_CMPINT_GE); }
__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 operator >=(const vfloat16& a, const vfloat16& b) { return _mm512_cmp_ps_mask(a,b,_MM_CMPINT_GE); }
__forceinline vboolf16 operator >=(const vfloat16& a, float b) { return a >= vfloat16(b); }
__forceinline vboolf16 operator >=(float a, const vfloat16& b) { return vfloat16(a) >= b; }
__forceinline const vboolf16 operator > ( const vfloat16& a, const vfloat16& b ) { return _mm512_cmp_ps_mask(a,b,_MM_CMPINT_GT); }
__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 operator > (const vfloat16& a, const vfloat16& b) { return _mm512_cmp_ps_mask(a,b,_MM_CMPINT_GT); }
__forceinline vboolf16 operator > (const vfloat16& a, float b) { return a > vfloat16(b); }
__forceinline vboolf16 operator > (float a, const vfloat16& b) { return vfloat16(a) > b; }
__forceinline const vboolf16 operator <=( const vfloat16& a, const vfloat16& b ) { return _mm512_cmp_ps_mask(a,b,_MM_CMPINT_LE); }
__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 operator <=(const vfloat16& a, const vfloat16& b) { return _mm512_cmp_ps_mask(a,b,_MM_CMPINT_LE); }
__forceinline vboolf16 operator <=(const vfloat16& a, float b) { return a <= vfloat16(b); }
__forceinline vboolf16 operator <=(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); }
@@ -376,7 +395,7 @@ namespace embree
__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 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 ) {
__forceinline vfloat16 select(const vboolf16& s, const vfloat16& t, const vfloat16& f) {
return _mm512_mask_blend_ps(s, f, t);
}
@@ -409,61 +428,86 @@ namespace embree
/// 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 unpacklo(const vfloat16& a, const vfloat16& b) { return _mm512_unpacklo_ps(a, b); }
__forceinline vfloat16 unpackhi(const vfloat16& a, const vfloat16& b) { return _mm512_unpackhi_ps(a, b); }
template<int i>
__forceinline vfloat16 shuffle(const vfloat16& v) {
return _mm512_permute_ps(v, _MM_SHUFFLE(i, i, i, i));
}
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));
template<int i0, int i1, int i2, int i3>
__forceinline vfloat16 shuffle(const vfloat16& v) {
return _mm512_permute_ps(v, _MM_SHUFFLE(i3, i2, i1, i0));
}
template<int i>
__forceinline vfloat16 shuffle4(const vfloat16& x) {
return _mm512_shuffle_f32x4(x,x,_MM_SHUFFLE(i,i,i,i));
__forceinline vfloat16 shuffle4(const vfloat16& v) {
return _mm512_shuffle_f32x4(v, v ,_MM_SHUFFLE(i, i, i, i));
}
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));
template<int i0, int i1, int i2, int i3>
__forceinline vfloat16 shuffle4(const vfloat16& v) {
return _mm512_shuffle_f32x4(v, v, _MM_SHUFFLE(i3, i2, i1, i0));
}
__forceinline vfloat16 permute(vfloat16 v,__m512i index)
{
return _mm512_castsi512_ps(_mm512_permutexvar_epi32(index,_mm512_castps_si512(v)));
__forceinline vfloat16 interleave_even(const vfloat16& a, const vfloat16& b) {
return _mm512_castsi512_ps(_mm512_mask_shuffle_epi32(_mm512_castps_si512(a), mm512_int2mask(0xaaaa), _mm512_castps_si512(b), 0xb1));
}
__forceinline vfloat16 reverse(const vfloat16 &a)
{
return permute(a,_mm512_setr_epi32(15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0));
__forceinline vfloat16 interleave_odd(const vfloat16& a, const vfloat16& b) {
return _mm512_castsi512_ps(_mm512_mask_shuffle_epi32(_mm512_castps_si512(b), mm512_int2mask(0x5555), _mm512_castps_si512(a), 0xb1));
}
__forceinline vfloat16 interleave2_even(const vfloat16& a, const vfloat16& b) {
/* mask should be 8-bit but is 16-bit to reuse for interleave_even */
return _mm512_castsi512_ps(_mm512_mask_permutex_epi64(_mm512_castps_si512(a), mm512_int2mask(0xaaaa), _mm512_castps_si512(b), 0xb1));
}
__forceinline vfloat16 interleave2_odd(const vfloat16& a, const vfloat16& b) {
/* mask should be 8-bit but is 16-bit to reuse for interleave_odd */
return _mm512_castsi512_ps(_mm512_mask_permutex_epi64(_mm512_castps_si512(b), mm512_int2mask(0x5555), _mm512_castps_si512(a), 0xb1));
}
__forceinline vfloat16 interleave4_even(const vfloat16& a, const vfloat16& b) {
return _mm512_castsi512_ps(_mm512_mask_permutex_epi64(_mm512_castps_si512(a), mm512_int2mask(0xcc), _mm512_castps_si512(b), 0x4e));
}
__forceinline vfloat16 interleave4_odd(const vfloat16& a, const vfloat16& b) {
return _mm512_castsi512_ps(_mm512_mask_permutex_epi64(_mm512_castps_si512(b), mm512_int2mask(0x33), _mm512_castps_si512(a), 0x4e));
}
__forceinline vfloat16 permute(vfloat16 v, __m512i index) {
return _mm512_castsi512_ps(_mm512_permutexvar_epi32(index, _mm512_castps_si512(v)));
}
__forceinline vfloat16 reverse(const vfloat16& v) {
return permute(v,_mm512_setr_epi32(15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0));
}
template<int i>
__forceinline vfloat16 align_shift_right(const vfloat16 &a, const vfloat16 &b)
{
__forceinline vfloat16 align_shift_right(const vfloat16& a, const vfloat16& b) {
return _mm512_castsi512_ps(_mm512_alignr_epi32(_mm512_castps_si512(a),_mm512_castps_si512(b),i));
};
template<int i>
__forceinline vfloat16 mask_align_shift_right(const vboolf16 &mask,vfloat16 &c,const vfloat16 &a, const vfloat16 &b)
{
__forceinline vfloat16 mask_align_shift_right(const vboolf16& mask, vfloat16& c, const vfloat16& a, const vfloat16& b) {
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) {
vfloat16 z = vfloat16::zero();
__forceinline vfloat16 shift_left_1(const vfloat16& a) {
vfloat16 z = zero;
return mask_align_shift_right<15>(0xfffe,z,a,a);
}
__forceinline vfloat16 shift_right_1( const vfloat16& x) {
__forceinline vfloat16 shift_right_1(const vfloat16& x) {
return align_shift_right<1>(zero,x);
}
__forceinline float toScalar(const vfloat16& a) { return mm512_cvtss_f32(a); }
__forceinline float toScalar(const vfloat16& v) { return mm512_cvtss_f32(v); }
template<int i> __forceinline const vfloat16 insert4(const vfloat16& a, const vfloat4& b) { return _mm512_insertf32x4(a, b, i); }
template<int i> __forceinline 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);
@@ -482,6 +526,79 @@ namespace embree
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); }
////////////////////////////////////////////////////////////////////////////////
/// Transpose
////////////////////////////////////////////////////////////////////////////////
__forceinline void transpose(const vfloat16& r0, const vfloat16& r1, const vfloat16& r2, const vfloat16& r3,
vfloat16& c0, vfloat16& c1, vfloat16& c2, vfloat16& c3)
{
#if defined(__AVX512F__) && !defined(__AVX512VL__) // KNL
vfloat16 a0a1_c0c1 = interleave_even(r0, r1);
vfloat16 a2a3_c2c3 = interleave_even(r2, r3);
vfloat16 b0b1_d0d1 = interleave_odd (r0, r1);
vfloat16 b2b3_d2d3 = interleave_odd (r2, r3);
c0 = interleave2_even(a0a1_c0c1, a2a3_c2c3);
c1 = interleave2_even(b0b1_d0d1, b2b3_d2d3);
c2 = interleave2_odd (a0a1_c0c1, a2a3_c2c3);
c3 = interleave2_odd (b0b1_d0d1, b2b3_d2d3);
#else
vfloat16 a0a2_b0b2 = unpacklo(r0, r2);
vfloat16 c0c2_d0d2 = unpackhi(r0, r2);
vfloat16 a1a3_b1b3 = unpacklo(r1, r3);
vfloat16 c1c3_d1d3 = unpackhi(r1, r3);
c0 = unpacklo(a0a2_b0b2, a1a3_b1b3);
c1 = unpackhi(a0a2_b0b2, a1a3_b1b3);
c2 = unpacklo(c0c2_d0d2, c1c3_d1d3);
c3 = unpackhi(c0c2_d0d2, c1c3_d1d3);
#endif
}
__forceinline void transpose(const vfloat4& r0, const vfloat4& r1, const vfloat4& r2, const vfloat4& r3,
const vfloat4& r4, const vfloat4& r5, const vfloat4& r6, const vfloat4& r7,
const vfloat4& r8, const vfloat4& r9, const vfloat4& r10, const vfloat4& r11,
const vfloat4& r12, const vfloat4& r13, const vfloat4& r14, const vfloat4& r15,
vfloat16& c0, vfloat16& c1, vfloat16& c2, vfloat16& c3)
{
return transpose(vfloat16(r0, r4, r8, r12), vfloat16(r1, r5, r9, r13), vfloat16(r2, r6, r10, r14), vfloat16(r3, r7, r11, r15),
c0, c1, c2, c3);
}
__forceinline void transpose(const vfloat16& r0, const vfloat16& r1, const vfloat16& r2, const vfloat16& r3,
const vfloat16& r4, const vfloat16& r5, const vfloat16& r6, const vfloat16& r7,
vfloat16& c0, vfloat16& c1, vfloat16& c2, vfloat16& c3,
vfloat16& c4, vfloat16& c5, vfloat16& c6, vfloat16& c7)
{
vfloat16 a0a1a2a3_e0e1e2e3, b0b1b2b3_f0f1f2f3, c0c1c2c3_g0g1g2g3, d0d1d2d3_h0h1h2h3;
transpose(r0, r1, r2, r3, a0a1a2a3_e0e1e2e3, b0b1b2b3_f0f1f2f3, c0c1c2c3_g0g1g2g3, d0d1d2d3_h0h1h2h3);
vfloat16 a4a5a6a7_e4e5e6e7, b4b5b6b7_f4f5f6f7, c4c5c6c7_g4g5g6g7, d4d5d6d7_h4h5h6h7;
transpose(r4, r5, r6, r7, a4a5a6a7_e4e5e6e7, b4b5b6b7_f4f5f6f7, c4c5c6c7_g4g5g6g7, d4d5d6d7_h4h5h6h7);
c0 = interleave4_even(a0a1a2a3_e0e1e2e3, a4a5a6a7_e4e5e6e7);
c1 = interleave4_even(b0b1b2b3_f0f1f2f3, b4b5b6b7_f4f5f6f7);
c2 = interleave4_even(c0c1c2c3_g0g1g2g3, c4c5c6c7_g4g5g6g7);
c3 = interleave4_even(d0d1d2d3_h0h1h2h3, d4d5d6d7_h4h5h6h7);
c4 = interleave4_odd (a0a1a2a3_e0e1e2e3, a4a5a6a7_e4e5e6e7);
c5 = interleave4_odd (b0b1b2b3_f0f1f2f3, b4b5b6b7_f4f5f6f7);
c6 = interleave4_odd (c0c1c2c3_g0g1g2g3, c4c5c6c7_g4g5g6g7);
c7 = interleave4_odd (d0d1d2d3_h0h1h2h3, d4d5d6d7_h4h5h6h7);
}
__forceinline void transpose(const vfloat8& r0, const vfloat8& r1, const vfloat8& r2, const vfloat8& r3,
const vfloat8& r4, const vfloat8& r5, const vfloat8& r6, const vfloat8& r7,
const vfloat8& r8, const vfloat8& r9, const vfloat8& r10, const vfloat8& r11,
const vfloat8& r12, const vfloat8& r13, const vfloat8& r14, const vfloat8& r15,
vfloat16& c0, vfloat16& c1, vfloat16& c2, vfloat16& c3,
vfloat16& c4, vfloat16& c5, vfloat16& c6, vfloat16& c7)
{
return transpose(vfloat16(r0, r8), vfloat16(r1, r9), vfloat16(r2, r10), vfloat16(r3, r11),
vfloat16(r4, r12), vfloat16(r5, r13), vfloat16(r6, r14), vfloat16(r7, r15),
c0, c1, c2, c3, c4, c5, c6, c7);
}
////////////////////////////////////////////////////////////////////////////////
/// Reductions
////////////////////////////////////////////////////////////////////////////////
@@ -491,15 +608,15 @@ namespace embree
__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 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<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_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<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 float reduce_add(const vfloat16& v) { return toScalar(vreduce_add(v)); }
__forceinline float reduce_min(const vfloat16& v) { return toScalar(vreduce_min(v)); }
@@ -598,47 +715,32 @@ namespace embree
/// Memory load and store operations
////////////////////////////////////////////////////////////////////////////////
__forceinline void compactustore16f_low(const vboolf16& mask, float * addr, const vfloat16 &reg) {
_mm512_mask_compressstoreu_ps(addr,mask,reg);
}
template<int scale = 4>
__forceinline vfloat16 gather16f(const vboolf16& mask, const float *const ptr, __m512i index) {
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 vfloat16 loadAOS4to16f(const float& x,const float& y, const float& z)
__forceinline vfloat16 loadAOS4to16f(const float& x, const float& y, const float& z)
{
vfloat16 f = vfloat16::zero();
vfloat16 f = zero;
f = select(0x1111,vfloat16::broadcast(&x),f);
f = select(0x2222,vfloat16::broadcast(&y),f);
f = select(0x4444,vfloat16::broadcast(&z),f);
return f;
}
__forceinline vfloat16 loadAOS4to16f(const unsigned int index,
const vfloat16 &x,
const vfloat16 &y,
const vfloat16 &z)
__forceinline vfloat16 loadAOS4to16f(unsigned int index,
const vfloat16& x,
const vfloat16& y,
const vfloat16& z)
{
vfloat16 f = vfloat16::zero();
vfloat16 f = zero;
f = select(0x1111,vfloat16::broadcast((float*)&x + index),f);
f = select(0x2222,vfloat16::broadcast((float*)&y + index),f);
f = select(0x4444,vfloat16::broadcast((float*)&z + index),f);
return f;
}
__forceinline vfloat16 loadAOS4to16f(const unsigned int index,
const vfloat16 &x,
const vfloat16 &y,
const vfloat16 &z,
const vfloat16 &fill)
__forceinline vfloat16 loadAOS4to16f(unsigned int index,
const vfloat16& x,
const vfloat16& y,
const vfloat16& z,
const vfloat16& fill)
{
vfloat16 f = fill;
f = select(0x1111,vfloat16::broadcast((float*)&x + index),f);
@@ -647,15 +749,15 @@ namespace embree
return f;
}
__forceinline vfloat16 rcp_safe( const vfloat16& a ) {
return rcp(select(a != vfloat16::zero(),a,vfloat16(min_rcp_input)));
__forceinline vfloat16 rcp_safe(const vfloat16& a) {
return rcp(select(a != vfloat16(zero), a, vfloat16(min_rcp_input)));
}
////////////////////////////////////////////////////////////////////////////////
/// Output Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline std::ostream &operator<<(std::ostream& cout, const vfloat16& v)
__forceinline std::ostream& operator <<(std::ostream& cout, const vfloat16& v)
{
cout << "<" << v[0];
for (int i=1; i<16; i++) cout << ", " << v[i];
+233 -167
View File
@@ -33,67 +33,76 @@ namespace embree
/// Constructors, Assignment & Cast Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline vfloat ( ) {}
__forceinline vfloat ( const vfloat4& other ) { v = other.v; }
__forceinline vfloat4& operator=( const vfloat4& other ) { v = other.v; return *this; }
__forceinline vfloat() {}
__forceinline vfloat(const vfloat4& other) { v = other.v; }
__forceinline vfloat4& operator =(const vfloat4& other) { v = other.v; return *this; }
__forceinline vfloat( const __m128 a ) : v(a) {}
__forceinline operator const __m128&( void ) const { return v; }
__forceinline operator __m128&( void ) { return v; }
__forceinline vfloat(__m128 a) : v(a) {}
__forceinline operator const __m128&() const { return v; }
__forceinline operator __m128&() { return v; }
__forceinline vfloat( float a ) : v(_mm_set1_ps(a)) {}
__forceinline vfloat( float a, float b, float c, float d) : v(_mm_set_ps(d, c, b, a)) {}
__forceinline vfloat(float a) : v(_mm_set1_ps(a)) {}
__forceinline vfloat(float a, float b, float c, float d) : v(_mm_set_ps(d, c, b, a)) {}
__forceinline explicit vfloat( const __m128i a ) : v(_mm_cvtepi32_ps(a)) {}
__forceinline explicit vfloat(__m128i a) : v(_mm_cvtepi32_ps(a)) {}
////////////////////////////////////////////////////////////////////////////////
/// Constants
////////////////////////////////////////////////////////////////////////////////
__forceinline vfloat( ZeroTy ) : v(_mm_setzero_ps()) {}
__forceinline vfloat( OneTy ) : v(_mm_set1_ps(1.0f)) {}
__forceinline vfloat( PosInfTy ) : v(_mm_set1_ps(pos_inf)) {}
__forceinline vfloat( NegInfTy ) : v(_mm_set1_ps(neg_inf)) {}
__forceinline vfloat( StepTy ) : v(_mm_set_ps(3.0f, 2.0f, 1.0f, 0.0f)) {}
__forceinline vfloat( NaNTy ) : v(_mm_set1_ps(nan)) {}
__forceinline vfloat(ZeroTy) : v(_mm_setzero_ps()) {}
__forceinline vfloat(OneTy) : v(_mm_set1_ps(1.0f)) {}
__forceinline vfloat(PosInfTy) : v(_mm_set1_ps(pos_inf)) {}
__forceinline vfloat(NegInfTy) : v(_mm_set1_ps(neg_inf)) {}
__forceinline vfloat(StepTy) : v(_mm_set_ps(3.0f, 2.0f, 1.0f, 0.0f)) {}
__forceinline vfloat(NaNTy) : v(_mm_set1_ps(nan)) {}
__forceinline vfloat(UndefinedTy) : v(_mm_undefined_ps()) {}
////////////////////////////////////////////////////////////////////////////////
/// Loads and Stores
////////////////////////////////////////////////////////////////////////////////
static __forceinline vfloat4 load ( const void* const a ) { return _mm_load_ps((float*)a); }
static __forceinline vfloat4 loadu( const void* const a ) { return _mm_loadu_ps((float*)a); }
static __forceinline vfloat4 load (const void* a) { return _mm_load_ps((float*)a); }
static __forceinline vfloat4 loadu(const void* a) { return _mm_loadu_ps((float*)a); }
static __forceinline void store ( void* ptr, const vfloat4& v ) { _mm_store_ps((float*)ptr,v); }
static __forceinline void storeu( void* ptr, const vfloat4& v ) { _mm_storeu_ps((float*)ptr,v); }
static __forceinline void store (void* ptr, const vfloat4& v) { _mm_store_ps((float*)ptr,v); }
static __forceinline void storeu(void* ptr, const vfloat4& v) { _mm_storeu_ps((float*)ptr,v); }
#if defined(__AVX512VL__)
static __forceinline vfloat4 load ( const vboolf4& mask, const void* const ptr) { return _mm_mask_load_ps (_mm_setzero_ps(),mask,(float*)ptr); }
static __forceinline vfloat4 loadu( const vboolf4& mask, const void* const ptr) { return _mm_mask_loadu_ps(_mm_setzero_ps(),mask,(float*)ptr); }
static __forceinline void store ( const vboolf4& mask, void* ptr, const vfloat4& v) { _mm_mask_store_ps ((float*)ptr,mask,v); }
static __forceinline void storeu( const vboolf4& mask, void* ptr, const vfloat4& v) { _mm_mask_storeu_ps((float*)ptr,mask,v); }
static __forceinline vfloat4 compact(const vboolf4& mask, vfloat4 &v) {
return _mm_mask_compress_ps(v, mask, v);
}
static __forceinline vfloat4 compact(const vboolf4& mask, vfloat4 &a, const vfloat4& b) {
return _mm_mask_compress_ps(a, mask, b);
}
static __forceinline vfloat4 load (const vboolf4& mask, const void* ptr) { return _mm_mask_load_ps (_mm_setzero_ps(),mask,(float*)ptr); }
static __forceinline vfloat4 loadu(const vboolf4& mask, const void* ptr) { return _mm_mask_loadu_ps(_mm_setzero_ps(),mask,(float*)ptr); }
static __forceinline void store (const vboolf4& mask, void* ptr, const vfloat4& v) { _mm_mask_store_ps ((float*)ptr,mask,v); }
static __forceinline void storeu(const vboolf4& mask, void* ptr, const vfloat4& v) { _mm_mask_storeu_ps((float*)ptr,mask,v); }
#elif defined(__AVX__)
static __forceinline vfloat4 load ( const vboolf4& mask, const void* const ptr ) { return _mm_maskload_ps((float*)ptr,mask); }
static __forceinline vfloat4 loadu( const vboolf4& mask, const void* const ptr ) { return _mm_maskload_ps((float*)ptr,mask); }
static __forceinline vfloat4 load (const vboolf4& mask, const void* ptr) { return _mm_maskload_ps((float*)ptr,mask); }
static __forceinline vfloat4 loadu(const vboolf4& mask, const void* ptr) { return _mm_maskload_ps((float*)ptr,mask); }
static __forceinline void store ( const vboolf4& mask, void* ptr, const vfloat4& v ) { _mm_maskstore_ps((float*)ptr,(__m128i)mask,v); }
static __forceinline void storeu( const vboolf4& mask, void* ptr, const vfloat4& v ) { _mm_maskstore_ps((float*)ptr,(__m128i)mask,v); }
static __forceinline void store (const vboolf4& mask, void* ptr, const vfloat4& v) { _mm_maskstore_ps((float*)ptr,(__m128i)mask,v); }
static __forceinline void storeu(const vboolf4& mask, void* ptr, const vfloat4& v) { _mm_maskstore_ps((float*)ptr,(__m128i)mask,v); }
#else
static __forceinline vfloat4 load ( const vboolf4& mask, const void* const ptr ) { return _mm_and_ps(_mm_load_ps ((float*)ptr),mask); }
static __forceinline vfloat4 loadu( const vboolf4& mask, const void* const ptr ) { return _mm_and_ps(_mm_loadu_ps((float*)ptr),mask); }
static __forceinline vfloat4 load (const vboolf4& mask, const void* ptr) { return _mm_and_ps(_mm_load_ps ((float*)ptr),mask); }
static __forceinline vfloat4 loadu(const vboolf4& mask, const void* ptr) { return _mm_and_ps(_mm_loadu_ps((float*)ptr),mask); }
static __forceinline void store ( const vboolf4& mask, void* ptr, const vfloat4& v ) { store (ptr,select(mask,v,load (ptr))); }
static __forceinline void storeu( const vboolf4& mask, void* ptr, const vfloat4& v ) { storeu(ptr,select(mask,v,loadu(ptr))); }
static __forceinline void store (const vboolf4& mask, void* ptr, const vfloat4& v) { store (ptr,select(mask,v,load (ptr))); }
static __forceinline void storeu(const vboolf4& mask, void* ptr, const vfloat4& v) { storeu(ptr,select(mask,v,loadu(ptr))); }
#endif
#if defined(__AVX__)
static __forceinline vfloat4 broadcast( const void* const a ) { return _mm_broadcast_ss((float*)a); }
static __forceinline vfloat4 broadcast(const void* a) { return _mm_broadcast_ss((float*)a); }
#else
static __forceinline vfloat4 broadcast( const void* const a ) { return _mm_set1_ps(*(float*)a); }
static __forceinline vfloat4 broadcast(const void* a) { return _mm_set1_ps(*(float*)a); }
#endif
static __forceinline vfloat4 load_nt ( const float* ptr ) {
static __forceinline vfloat4 load_nt (const float* ptr) {
#if defined (__SSE4_1__)
return _mm_castsi128_ps(_mm_stream_load_si128((__m128i*)ptr));
#else
@@ -102,21 +111,21 @@ namespace embree
}
#if defined(__SSE4_1__)
static __forceinline vfloat4 load( const unsigned char* const ptr ) {
static __forceinline vfloat4 load(const unsigned char* ptr) {
return _mm_cvtepi32_ps(_mm_cvtepu8_epi32(_mm_loadu_si128((__m128i*)ptr)));
}
#else
static __forceinline vfloat4 load( const unsigned char* const ptr ) {
static __forceinline vfloat4 load(const unsigned char* ptr) {
//return _mm_cvtpu8_ps(*(__m64*)ptr); // don't enable, will use MMX instructions
return vfloat4(ptr[0],ptr[1],ptr[2],ptr[3]);
}
#endif
static __forceinline vfloat4 load(const unsigned short* const ptr) {
static __forceinline vfloat4 load(const unsigned short* ptr) {
return _mm_mul_ps(vfloat4(vint4::load(ptr)),vfloat4(1.0f/65535.0f));
}
static __forceinline void store_nt ( void* ptr, const vfloat4& v)
static __forceinline void store_nt(void* ptr, const vfloat4& v)
{
#if defined (__SSE4_1__)
_mm_stream_ps((float*)ptr,v);
@@ -125,16 +134,58 @@ namespace embree
#endif
}
template<int scale>
static __forceinline void scatter(const vboolf4& mask, void* ptr, const vint4& ofs, const vfloat4& v)
template<int scale = 4>
static __forceinline vfloat4 gather(const float* ptr, const vint4& index) {
#if defined(__AVX2__)
return _mm_i32gather_ps(ptr, index, scale);
#else
return vfloat4(
*(float*)(((char*)ptr)+scale*index[0]),
*(float*)(((char*)ptr)+scale*index[1]),
*(float*)(((char*)ptr)+scale*index[2]),
*(float*)(((char*)ptr)+scale*index[3]));
#endif
}
template<int scale = 4>
static __forceinline vfloat4 gather(const vboolf4& mask, const float* ptr, const vint4& index) {
vfloat4 r = zero;
#if defined(__AVX512VL__)
return _mm_mmask_i32gather_ps(r, mask, index, ptr, scale);
#elif defined(__AVX2__)
return _mm_mask_i32gather_ps(r, ptr, index, mask, scale);
#else
if (likely(mask[0])) r[0] = *(float*)(((char*)ptr)+scale*index[0]);
if (likely(mask[1])) r[1] = *(float*)(((char*)ptr)+scale*index[1]);
if (likely(mask[2])) r[2] = *(float*)(((char*)ptr)+scale*index[2]);
if (likely(mask[3])) r[3] = *(float*)(((char*)ptr)+scale*index[3]);
return r;
#endif
}
template<int scale = 4>
static __forceinline void scatter(void* ptr, const vint4& index, const vfloat4& v)
{
#if defined(__AVX512VL__)
_mm_mask_i32scatter_ps((float*)ptr,mask,ofs,v,scale);
_mm_i32scatter_ps((float*)ptr,index,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];
if (likely(mask[2])) *(float*)(((char*)ptr)+scale*ofs[2]) = v[2];
if (likely(mask[3])) *(float*)(((char*)ptr)+scale*ofs[3]) = v[3];
*(float*)(((char*)ptr)+scale*index[0]) = v[0];
*(float*)(((char*)ptr)+scale*index[1]) = v[1];
*(float*)(((char*)ptr)+scale*index[2]) = v[2];
*(float*)(((char*)ptr)+scale*index[3]) = v[3];
#endif
}
template<int scale = 4>
static __forceinline void scatter(const vboolf4& mask, void* ptr, const vint4& index, const vfloat4& v)
{
#if defined(__AVX512VL__)
_mm_mask_i32scatter_ps((float*)ptr,mask,index,v,scale);
#else
if (likely(mask[0])) *(float*)(((char*)ptr)+scale*index[0]) = v[0];
if (likely(mask[1])) *(float*)(((char*)ptr)+scale*index[1]) = v[1];
if (likely(mask[2])) *(float*)(((char*)ptr)+scale*index[2]) = v[2];
if (likely(mask[3])) *(float*)(((char*)ptr)+scale*index[3]) = v[3];
#endif
}
@@ -149,10 +200,10 @@ namespace embree
/// Array Access
////////////////////////////////////////////////////////////////////////////////
__forceinline const float& operator []( const size_t index ) const { assert(index < 4); return f[index]; }
__forceinline float& operator []( const size_t index ) { assert(index < 4); return f[index]; }
__forceinline const float& operator [](size_t index) const { assert(index < 4); return f[index]; }
__forceinline float& operator [](size_t index) { assert(index < 4); return f[index]; }
friend __forceinline const vfloat4 select( const vboolf4& m, const vfloat4& t, const vfloat4& f ) {
friend __forceinline vfloat4 select(const vboolf4& m, const vfloat4& t, const vfloat4& f) {
#if defined(__AVX512VL__)
return _mm_mask_blend_ps(m, f, t);
#elif defined(__SSE4_1__)
@@ -168,23 +219,25 @@ namespace embree
/// Unary Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline const vfloat4 asFloat ( const __m128i& a ) { return _mm_castsi128_ps(a); }
__forceinline const vfloat4 operator +( const vfloat4& a ) { return a; }
__forceinline const vfloat4 operator -( const vfloat4& a ) { return _mm_xor_ps(a.v, _mm_castsi128_ps(_mm_set1_epi32(0x80000000))); }
__forceinline const vfloat4 abs ( const vfloat4& a ) { return _mm_and_ps(a.v, _mm_castsi128_ps(_mm_set1_epi32(0x7fffffff))); }
__forceinline vfloat4 asFloat(const __m128i& a) { return _mm_castsi128_ps(a); }
__forceinline vfloat4 operator +(const vfloat4& a) { return a; }
__forceinline vfloat4 operator -(const vfloat4& a) { return _mm_xor_ps(a, _mm_castsi128_ps(_mm_set1_epi32(0x80000000))); }
__forceinline vfloat4 abs(const vfloat4& a) { return _mm_and_ps(a, _mm_castsi128_ps(_mm_set1_epi32(0x7fffffff))); }
#if defined(__AVX512VL__)
__forceinline const vfloat4 sign ( const vfloat4& a ) { return _mm_mask_blend_ps(_mm_cmp_ps_mask(a, vfloat4(zero), _CMP_LT_OQ), vfloat4(one), -vfloat4(one)); }
__forceinline vfloat4 sign(const vfloat4& a) { return _mm_mask_blend_ps(_mm_cmp_ps_mask(a, vfloat4(zero), _CMP_LT_OQ), vfloat4(one), -vfloat4(one)); }
#else
__forceinline const vfloat4 sign ( const vfloat4& a ) { return blendv_ps(vfloat4(one), -vfloat4(one), _mm_cmplt_ps(a, vfloat4(zero))); }
__forceinline vfloat4 sign(const vfloat4& a) { return blendv_ps(vfloat4(one), -vfloat4(one), _mm_cmplt_ps(a, vfloat4(zero))); }
#endif
__forceinline const vfloat4 signmsk ( const vfloat4& a ) { return _mm_and_ps(a.v,_mm_castsi128_ps(_mm_set1_epi32(0x80000000))); }
__forceinline vfloat4 signmsk(const vfloat4& a) { return _mm_and_ps(a,_mm_castsi128_ps(_mm_set1_epi32(0x80000000))); }
__forceinline const vfloat4 rcp ( const vfloat4& a )
__forceinline vfloat4 rcp(const vfloat4& a)
{
#if defined(__AVX512VL__)
const vfloat4 r = _mm_rcp14_ps(a.v);
const vfloat4 r = _mm_rcp14_ps(a);
#else
const vfloat4 r = _mm_rcp_ps(a.v);
const vfloat4 r = _mm_rcp_ps(a);
#endif
#if defined(__AVX2__)
@@ -193,15 +246,15 @@ namespace embree
return _mm_mul_ps(r,_mm_sub_ps(vfloat4(2.0f), _mm_mul_ps(r, a)));
#endif
}
__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 vfloat4 sqr (const vfloat4& a) { return _mm_mul_ps(a,a); }
__forceinline vfloat4 sqrt(const vfloat4& a) { return _mm_sqrt_ps(a); }
__forceinline const vfloat4 rsqrt( const vfloat4& a )
__forceinline vfloat4 rsqrt(const vfloat4& a)
{
#if defined(__AVX512VL__)
const vfloat4 r = _mm_rsqrt14_ps(a.v);
const vfloat4 r = _mm_rsqrt14_ps(a);
#else
const vfloat4 r = _mm_rsqrt_ps(a.v);
const vfloat4 r = _mm_rsqrt_ps(a);
#endif
#if defined(__AVX2__)
@@ -213,8 +266,8 @@ namespace embree
#endif
}
__forceinline const vboolf4 isnan( const vfloat4& a ) {
const vfloat4 b = _mm_and_ps(a.v, _mm_castsi128_ps(_mm_set1_epi32(0x7fffffff)));
__forceinline vboolf4 isnan(const vfloat4& a) {
const vfloat4 b = _mm_and_ps(a, _mm_castsi128_ps(_mm_set1_epi32(0x7fffffff)));
#if defined(__AVX512VL__)
return _mm_cmp_epi32_mask(_mm_castps_si128(b), _mm_set1_epi32(0x7f800000), _MM_CMPINT_GT);
#else
@@ -226,32 +279,32 @@ namespace embree
/// Binary Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline const vfloat4 operator +( const vfloat4& a, const vfloat4& b ) { return _mm_add_ps(a.v, b.v); }
__forceinline const vfloat4 operator +( const vfloat4& a, const float& b ) { return a + vfloat4(b); }
__forceinline const vfloat4 operator +( const float& a, const vfloat4& b ) { return vfloat4(a) + b; }
__forceinline vfloat4 operator +(const vfloat4& a, const vfloat4& b) { return _mm_add_ps(a, b); }
__forceinline vfloat4 operator +(const vfloat4& a, float b) { return a + vfloat4(b); }
__forceinline vfloat4 operator +(float a, const vfloat4& b) { return vfloat4(a) + b; }
__forceinline const vfloat4 operator -( const vfloat4& a, const vfloat4& b ) { return _mm_sub_ps(a.v, b.v); }
__forceinline const vfloat4 operator -( const vfloat4& a, const float& b ) { return a - vfloat4(b); }
__forceinline const vfloat4 operator -( const float& a, const vfloat4& b ) { return vfloat4(a) - b; }
__forceinline vfloat4 operator -(const vfloat4& a, const vfloat4& b) { return _mm_sub_ps(a, b); }
__forceinline vfloat4 operator -(const vfloat4& a, float b) { return a - vfloat4(b); }
__forceinline vfloat4 operator -(float a, const vfloat4& b) { return vfloat4(a) - b; }
__forceinline const vfloat4 operator *( const vfloat4& a, const vfloat4& b ) { return _mm_mul_ps(a.v, b.v); }
__forceinline const vfloat4 operator *( const vfloat4& a, const float& b ) { return a * vfloat4(b); }
__forceinline const vfloat4 operator *( const float& a, const vfloat4& b ) { return vfloat4(a) * b; }
__forceinline vfloat4 operator *(const vfloat4& a, const vfloat4& b) { return _mm_mul_ps(a, b); }
__forceinline vfloat4 operator *(const vfloat4& a, float b) { return a * vfloat4(b); }
__forceinline vfloat4 operator *(float a, const vfloat4& b) { return vfloat4(a) * b; }
__forceinline const vfloat4 operator /( const vfloat4& a, const vfloat4& b ) { return _mm_div_ps(a.v,b.v); }
__forceinline const vfloat4 operator /( const vfloat4& a, const float& b ) { return a/vfloat4(b); }
__forceinline const vfloat4 operator /( const float& a, const vfloat4& b ) { return vfloat4(a)/b; }
__forceinline vfloat4 operator /(const vfloat4& a, const vfloat4& b) { return _mm_div_ps(a,b); }
__forceinline vfloat4 operator /(const vfloat4& a, float b) { return a/vfloat4(b); }
__forceinline vfloat4 operator /(float a, const vfloat4& b) { return vfloat4(a)/b; }
__forceinline const vfloat4 operator^( const vfloat4& a, const vfloat4& b ) { return _mm_xor_ps(a.v,b.v); }
__forceinline const vfloat4 operator^( const vfloat4& a, const vint4& b ) { return _mm_xor_ps(a.v,_mm_castsi128_ps(b.v)); }
__forceinline vfloat4 operator ^(const vfloat4& a, const vfloat4& b) { return _mm_xor_ps(a,b); }
__forceinline vfloat4 operator ^(const vfloat4& a, const vint4& b) { return _mm_xor_ps(a,_mm_castsi128_ps(b)); }
__forceinline const vfloat4 min( const vfloat4& a, const vfloat4& b ) { return _mm_min_ps(a.v,b.v); }
__forceinline const vfloat4 min( const vfloat4& a, const float& b ) { return _mm_min_ps(a.v,vfloat4(b)); }
__forceinline const vfloat4 min( const float& a, const vfloat4& b ) { return _mm_min_ps(vfloat4(a),b.v); }
__forceinline vfloat4 min(const vfloat4& a, const vfloat4& b) { return _mm_min_ps(a,b); }
__forceinline vfloat4 min(const vfloat4& a, float b) { return _mm_min_ps(a,vfloat4(b)); }
__forceinline vfloat4 min(float a, const vfloat4& b) { return _mm_min_ps(vfloat4(a),b); }
__forceinline const vfloat4 max( const vfloat4& a, const vfloat4& b ) { return _mm_max_ps(a.v,b.v); }
__forceinline const vfloat4 max( const vfloat4& a, const float& b ) { return _mm_max_ps(a.v,vfloat4(b)); }
__forceinline const vfloat4 max( const float& a, const vfloat4& b ) { return _mm_max_ps(vfloat4(a),b.v); }
__forceinline vfloat4 max(const vfloat4& a, const vfloat4& b) { return _mm_max_ps(a,b); }
__forceinline vfloat4 max(const vfloat4& a, float b) { return _mm_max_ps(a,vfloat4(b)); }
__forceinline vfloat4 max(float a, const vfloat4& b) { return _mm_max_ps(vfloat4(a),b); }
#if defined(__SSE4_1__)
__forceinline vfloat4 mini(const vfloat4& a, const vfloat4& b) {
@@ -260,6 +313,7 @@ namespace embree
const vint4 ci = _mm_min_epi32(ai,bi);
return _mm_castsi128_ps(ci);
}
__forceinline vfloat4 maxi(const vfloat4& a, const vfloat4& b) {
const vint4 ai = _mm_castps_si128(a);
const vint4 bi = _mm_castps_si128(b);
@@ -273,17 +327,18 @@ namespace embree
const vint4 ci = _mm_min_epu32(ai,bi);
return _mm_castsi128_ps(ci);
}
__forceinline vfloat4 maxui(const vfloat4& a, const vfloat4& b) {
const vint4 ai = _mm_castps_si128(a);
const vint4 bi = _mm_castps_si128(b);
const vint4 ci = _mm_max_epu32(ai,bi);
return _mm_castsi128_ps(ci);
}
#else
__forceinline vfloat4 mini(const vfloat4& a, const vfloat4& b) {
return min(a,b);
}
__forceinline vfloat4 maxi(const vfloat4& a, const vfloat4& b) {
return max(a,b);
}
@@ -294,70 +349,70 @@ namespace embree
////////////////////////////////////////////////////////////////////////////////
#if defined(__AVX2__)
__forceinline const vfloat4 madd ( const vfloat4& a, const vfloat4& b, const vfloat4& c) { return _mm_fmadd_ps(a,b,c); }
__forceinline const vfloat4 msub ( const vfloat4& a, const vfloat4& b, const vfloat4& c) { return _mm_fmsub_ps(a,b,c); }
__forceinline const vfloat4 nmadd ( const vfloat4& a, const vfloat4& b, const vfloat4& c) { return _mm_fnmadd_ps(a,b,c); }
__forceinline const vfloat4 nmsub ( const vfloat4& a, const vfloat4& b, const vfloat4& c) { return _mm_fnmsub_ps(a,b,c); }
__forceinline vfloat4 madd (const vfloat4& a, const vfloat4& b, const vfloat4& c) { return _mm_fmadd_ps(a,b,c); }
__forceinline vfloat4 msub (const vfloat4& a, const vfloat4& b, const vfloat4& c) { return _mm_fmsub_ps(a,b,c); }
__forceinline vfloat4 nmadd(const vfloat4& a, const vfloat4& b, const vfloat4& c) { return _mm_fnmadd_ps(a,b,c); }
__forceinline vfloat4 nmsub(const vfloat4& a, const vfloat4& b, const vfloat4& c) { return _mm_fnmsub_ps(a,b,c); }
#else
__forceinline const vfloat4 madd ( const vfloat4& a, const vfloat4& b, const vfloat4& c) { return a*b+c; }
__forceinline const vfloat4 msub ( const vfloat4& a, const vfloat4& b, const vfloat4& c) { return a*b-c; }
__forceinline const vfloat4 nmadd ( const vfloat4& a, const vfloat4& b, const vfloat4& c) { return -a*b+c;}
__forceinline const vfloat4 nmsub ( const vfloat4& a, const vfloat4& b, const vfloat4& c) { return -a*b-c; }
__forceinline vfloat4 madd (const vfloat4& a, const vfloat4& b, const vfloat4& c) { return a*b+c; }
__forceinline vfloat4 msub (const vfloat4& a, const vfloat4& b, const vfloat4& c) { return a*b-c; }
__forceinline vfloat4 nmadd(const vfloat4& a, const vfloat4& b, const vfloat4& c) { return -a*b+c;}
__forceinline vfloat4 nmsub(const vfloat4& a, const vfloat4& b, const vfloat4& c) { return -a*b-c; }
#endif
////////////////////////////////////////////////////////////////////////////////
/// Assignment Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline vfloat4& operator +=( vfloat4& a, const vfloat4& b ) { return a = a + b; }
__forceinline vfloat4& operator +=( vfloat4& a, const float& b ) { return a = a + b; }
__forceinline vfloat4& operator +=(vfloat4& a, const vfloat4& b) { return a = a + b; }
__forceinline vfloat4& operator +=(vfloat4& a, float b) { return a = a + b; }
__forceinline vfloat4& operator -=( vfloat4& a, const vfloat4& b ) { return a = a - b; }
__forceinline vfloat4& operator -=( vfloat4& a, const float& b ) { return a = a - b; }
__forceinline vfloat4& operator -=(vfloat4& a, const vfloat4& b) { return a = a - b; }
__forceinline vfloat4& operator -=(vfloat4& a, float b) { return a = a - b; }
__forceinline vfloat4& operator *=( vfloat4& a, const vfloat4& b ) { return a = a * b; }
__forceinline vfloat4& operator *=( vfloat4& a, const float& b ) { return a = a * b; }
__forceinline vfloat4& operator *=(vfloat4& a, const vfloat4& b) { return a = a * b; }
__forceinline vfloat4& operator *=(vfloat4& a, float b) { return a = a * b; }
__forceinline vfloat4& operator /=( vfloat4& a, const vfloat4& b ) { return a = a / b; }
__forceinline vfloat4& operator /=( vfloat4& a, const float& b ) { return a = a / b; }
__forceinline vfloat4& operator /=(vfloat4& a, const vfloat4& b) { return a = a / b; }
__forceinline vfloat4& operator /=(vfloat4& a, float b) { return a = a / b; }
////////////////////////////////////////////////////////////////////////////////
/// Comparison Operators + Select
////////////////////////////////////////////////////////////////////////////////
#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 vboolf4 operator ==(const vfloat4& a, const vfloat4& b) { return _mm_cmp_ps_mask(a, b, _MM_CMPINT_EQ); }
__forceinline vboolf4 operator !=(const vfloat4& a, const vfloat4& b) { return _mm_cmp_ps_mask(a, b, _MM_CMPINT_NE); }
__forceinline vboolf4 operator < (const vfloat4& a, const vfloat4& b) { return _mm_cmp_ps_mask(a, b, _MM_CMPINT_LT); }
__forceinline vboolf4 operator >=(const vfloat4& a, const vfloat4& b) { return _mm_cmp_ps_mask(a, b, _MM_CMPINT_GE); }
__forceinline vboolf4 operator > (const vfloat4& a, const vfloat4& b) { return _mm_cmp_ps_mask(a, b, _MM_CMPINT_GT); }
__forceinline vboolf4 operator <=(const vfloat4& a, const vfloat4& b) { return _mm_cmp_ps_mask(a, b, _MM_CMPINT_LE); }
#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 vboolf4 operator ==(const vfloat4& a, const vfloat4& b) { return _mm_cmpeq_ps (a, b); }
__forceinline vboolf4 operator !=(const vfloat4& a, const vfloat4& b) { return _mm_cmpneq_ps(a, b); }
__forceinline vboolf4 operator < (const vfloat4& a, const vfloat4& b) { return _mm_cmplt_ps (a, b); }
__forceinline vboolf4 operator >=(const vfloat4& a, const vfloat4& b) { return _mm_cmpnlt_ps(a, b); }
__forceinline vboolf4 operator > (const vfloat4& a, const vfloat4& b) { return _mm_cmpnle_ps(a, b); }
__forceinline vboolf4 operator <=(const vfloat4& a, const vfloat4& b) { return _mm_cmple_ps (a, b); }
#endif
__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 operator ==(const vfloat4& a, float b) { return a == vfloat4(b); }
__forceinline vboolf4 operator ==(float a, const vfloat4& b) { return vfloat4(a) == b; }
__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 operator !=(const vfloat4& a, float b) { return a != vfloat4(b); }
__forceinline vboolf4 operator !=(float a, const vfloat4& b) { return vfloat4(a) != b; }
__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 operator < (const vfloat4& a, float b) { return a < vfloat4(b); }
__forceinline vboolf4 operator < (float a, const vfloat4& b) { return vfloat4(a) < b; }
__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 operator >=(const vfloat4& a, float b) { return a >= vfloat4(b); }
__forceinline vboolf4 operator >=(float a, const vfloat4& b) { return vfloat4(a) >= b; }
__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 operator > (const vfloat4& a, float b) { return a > vfloat4(b); }
__forceinline vboolf4 operator > (float a, const vfloat4& b) { return vfloat4(a) > b; }
__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 operator <=(const vfloat4& a, float b) { return a <= vfloat4(b); }
__forceinline vboolf4 operator <=(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; }
@@ -383,7 +438,7 @@ namespace embree
#endif
template<int mask>
__forceinline const vfloat4 select(const vfloat4& t, const vfloat4& f)
__forceinline vfloat4 select(const vfloat4& t, const vfloat4& f)
{
#if defined(__SSE4_1__)
return _mm_blend_ps(f, t, mask);
@@ -396,15 +451,15 @@ namespace embree
return madd(t,b-a,a);
}
__forceinline bool isvalid ( const vfloat4& v ) {
__forceinline bool isvalid(const vfloat4& v) {
return all((v > vfloat4(-FLT_LARGE)) & (v < vfloat4(+FLT_LARGE)));
}
__forceinline bool is_finite ( const vfloat4& a ) {
__forceinline bool is_finite(const vfloat4& a) {
return all((a >= vfloat4(-FLT_MAX)) & (a <= vfloat4(+FLT_MAX)));
}
__forceinline bool is_finite ( const vboolf4& valid, const vfloat4& a ) {
__forceinline bool is_finite(const vboolf4& valid, const vfloat4& a) {
return all(valid, (a >= vfloat4(-FLT_MAX)) & (a <= vfloat4(+FLT_MAX)));
}
@@ -413,17 +468,17 @@ namespace embree
////////////////////////////////////////////////////////////////////////////////
#if defined (__SSE4_1__)
__forceinline const vfloat4 floor ( const vfloat4& a ) { return _mm_round_ps(a, _MM_FROUND_TO_NEG_INF ); }
__forceinline const vfloat4 ceil ( const vfloat4& a ) { return _mm_round_ps(a, _MM_FROUND_TO_POS_INF ); }
__forceinline const vfloat4 trunc ( const vfloat4& a ) { return _mm_round_ps(a, _MM_FROUND_TO_ZERO ); }
__forceinline vfloat4 floor(const vfloat4& a) { return _mm_round_ps(a, _MM_FROUND_TO_NEG_INF ); }
__forceinline vfloat4 ceil (const vfloat4& a) { return _mm_round_ps(a, _MM_FROUND_TO_POS_INF ); }
__forceinline vfloat4 trunc(const vfloat4& a) { return _mm_round_ps(a, _MM_FROUND_TO_ZERO ); }
#else
__forceinline const vfloat4 floor ( const vfloat4& a ) { return vfloat4(floorf(a[0]),floorf(a[1]),floorf(a[2]),floorf(a[3])); }
__forceinline const vfloat4 ceil ( const vfloat4& a ) { return vfloat4(ceilf (a[0]),ceilf (a[1]),ceilf (a[2]),ceilf (a[3])); }
//__forceinline const vfloat4 trunc ( const vfloat4& a ) { return vfloat4(truncf(a[0]),truncf(a[1]),truncf(a[2]),truncf(a[3])); }
__forceinline vfloat4 floor(const vfloat4& a) { return vfloat4(floorf(a[0]),floorf(a[1]),floorf(a[2]),floorf(a[3])); }
__forceinline vfloat4 ceil (const vfloat4& a) { return vfloat4(ceilf (a[0]),ceilf (a[1]),ceilf (a[2]),ceilf (a[3])); }
//__forceinline vfloat4 trunc(const vfloat4& a) { return vfloat4(truncf(a[0]),truncf(a[1]),truncf(a[2]),truncf(a[3])); }
#endif
__forceinline const vfloat4 frac ( const vfloat4& a ) { return a-floor(a); }
__forceinline vfloat4 frac(const vfloat4& a) { return a-floor(a); }
__forceinline vint4 floori (const vfloat4& a) {
__forceinline vint4 floori(const vfloat4& a) {
#if defined(__SSE4_1__)
return vint4(floor(a));
#else
@@ -435,56 +490,59 @@ namespace embree
/// Movement/Shifting/Shuffling Functions
////////////////////////////////////////////////////////////////////////////////
__forceinline vfloat4 unpacklo( const vfloat4& a, const vfloat4& b ) { return _mm_unpacklo_ps(a.v, b.v); }
__forceinline vfloat4 unpackhi( const vfloat4& a, const vfloat4& b ) { return _mm_unpackhi_ps(a.v, b.v); }
__forceinline vfloat4 unpacklo(const vfloat4& a, const vfloat4& b) { return _mm_unpacklo_ps(a, b); }
__forceinline vfloat4 unpackhi(const vfloat4& a, const vfloat4& b) { return _mm_unpackhi_ps(a, b); }
template<size_t i0, size_t i1, size_t i2, size_t i3> __forceinline const vfloat4 shuffle( const vfloat4& b ) {
return _mm_castsi128_ps(_mm_shuffle_epi32(_mm_castps_si128(b), _MM_SHUFFLE(i3, i2, i1, i0)));
template<int i0, int i1, int i2, int i3>
__forceinline vfloat4 shuffle(const vfloat4& v) {
return _mm_castsi128_ps(_mm_shuffle_epi32(_mm_castps_si128(v), _MM_SHUFFLE(i3, i2, i1, i0)));
}
template<size_t i0, size_t i1, size_t i2, size_t i3> __forceinline const vfloat4 shuffle( const vfloat4& a, const vfloat4& b ) {
template<int i0, int i1, int i2, int i3>
__forceinline vfloat4 shuffle(const vfloat4& a, const vfloat4& b) {
return _mm_shuffle_ps(a, b, _MM_SHUFFLE(i3, i2, i1, i0));
}
#if defined (__SSSE3__)
__forceinline const vfloat4 shuffle8(const vfloat4& a, const vint4& shuf) {
__forceinline vfloat4 shuffle8(const vfloat4& a, const vint4& shuf) {
return _mm_castsi128_ps(_mm_shuffle_epi8(_mm_castps_si128(a), shuf));
}
#endif
#if defined(__SSE3__)
template<> __forceinline const vfloat4 shuffle<0, 0, 2, 2>( const vfloat4& b ) { return _mm_moveldup_ps(b); }
template<> __forceinline const vfloat4 shuffle<1, 1, 3, 3>( const vfloat4& b ) { return _mm_movehdup_ps(b); }
template<> __forceinline const vfloat4 shuffle<0, 1, 0, 1>( const vfloat4& b ) { return _mm_castpd_ps(_mm_movedup_pd(_mm_castps_pd(b))); }
template<> __forceinline vfloat4 shuffle<0, 0, 2, 2>(const vfloat4& v) { return _mm_moveldup_ps(v); }
template<> __forceinline vfloat4 shuffle<1, 1, 3, 3>(const vfloat4& v) { return _mm_movehdup_ps(v); }
template<> __forceinline vfloat4 shuffle<0, 1, 0, 1>(const vfloat4& v) { return _mm_castpd_ps(_mm_movedup_pd(_mm_castps_pd(v))); }
#endif
template<size_t i0> __forceinline const vfloat4 shuffle( const vfloat4& b ) {
return shuffle<i0,i0,i0,i0>(b);
template<int i>
__forceinline vfloat4 shuffle(const vfloat4& v) {
return shuffle<i,i,i,i>(v);
}
#if defined (__SSE4_1__) && !defined(__GNUC__)
template<size_t i> __forceinline float extract ( const vfloat4& a ) { return _mm_cvtss_f32(_mm_extract_ps(a,i)); }
template<int i> __forceinline float extract(const vfloat4& a) { return _mm_cvtss_f32(_mm_extract_ps(a,i)); }
#else
template<size_t i> __forceinline float extract ( const vfloat4& a ) { return _mm_cvtss_f32(shuffle<i,i,i,i>(a)); }
template<int i> __forceinline float extract(const vfloat4& a) { return _mm_cvtss_f32(shuffle<i,i,i,i>(a)); }
#endif
template<> __forceinline float extract<0>( const vfloat4& a ) { return _mm_cvtss_f32(a); }
template<> __forceinline float extract<0>(const vfloat4& a) { return _mm_cvtss_f32(a); }
#if defined (__SSE4_1__)
template<size_t dst, size_t src, size_t clr> __forceinline const vfloat4 insert( const vfloat4& a, const vfloat4& b ) { return _mm_insert_ps(a, b, (dst << 4) | (src << 6) | clr); }
template<size_t dst, size_t src> __forceinline const vfloat4 insert( const vfloat4& a, const vfloat4& b ) { return insert<dst, src, 0>(a, b); }
template<size_t dst> __forceinline const vfloat4 insert( const vfloat4& a, const float b ) { return insert<dst, 0>(a, _mm_set_ss(b)); }
template<int dst, int src, int clr> __forceinline vfloat4 insert(const vfloat4& a, const vfloat4& b) { return _mm_insert_ps(a, b, (dst << 4) | (src << 6) | clr); }
template<int dst, int src> __forceinline vfloat4 insert(const vfloat4& a, const vfloat4& b) { return insert<dst, src, 0>(a, b); }
template<int dst> __forceinline vfloat4 insert(const vfloat4& a, const float b) { return insert<dst, 0>(a, _mm_set_ss(b)); }
#else
template<size_t dst, size_t src> __forceinline const vfloat4 insert( const vfloat4& a, const vfloat4& b ) { vfloat4 c = a; c[dst] = b[src]; return c; }
template<size_t dst> __forceinline const vfloat4 insert( const vfloat4& a, const float b ) { vfloat4 c = a; c[dst] = b; return c; }
template<int dst, int src> __forceinline vfloat4 insert(const vfloat4& a, const vfloat4& b) { vfloat4 c = a; c[dst&3] = b[src&3]; return c; }
template<int dst> __forceinline vfloat4 insert(const vfloat4& a, float b) { vfloat4 c = a; c[dst&3] = b; return c; }
#endif
__forceinline float toScalar(const vfloat4& a) { return _mm_cvtss_f32(a); }
__forceinline float toScalar(const vfloat4& v) { return _mm_cvtss_f32(v); }
__forceinline vfloat4 broadcast4f( const vfloat4& a, const size_t k ) {
__forceinline vfloat4 broadcast4f(const vfloat4& a, size_t k) {
return vfloat4::broadcast(&a[k]);
}
__forceinline vfloat4 shift_right_1( const vfloat4& x) {
__forceinline vfloat4 shift_right_1(const vfloat4& x) {
return _mm_castsi128_ps(_mm_srli_si128(_mm_castps_si128(x), 4));
}
@@ -493,10 +551,18 @@ namespace embree
return _mm_permutevar_ps(a,index);
}
__forceinline vfloat4 broadcast1f( const void* const a ) { return _mm_broadcast_ss((float*)a); }
__forceinline vfloat4 broadcast1f(const void* a) { return _mm_broadcast_ss((float*)a); }
#endif
#if defined(__AVX512VL__)
template<int i>
__forceinline vfloat4 align_shift_right(const vfloat4& a, const vfloat4& b) {
return _mm_castsi128_ps(_mm_alignr_epi32(_mm_castps_si128(a), _mm_castps_si128(b), i));
}
#endif
////////////////////////////////////////////////////////////////////////////////
/// Sorting Network
////////////////////////////////////////////////////////////////////////////////
@@ -568,9 +634,9 @@ namespace embree
/// Reductions
////////////////////////////////////////////////////////////////////////////////
__forceinline const vfloat4 vreduce_min(const vfloat4& v) { vfloat4 h = min(shuffle<1,0,3,2>(v),v); return min(shuffle<2,3,0,1>(h),h); }
__forceinline const vfloat4 vreduce_max(const vfloat4& v) { vfloat4 h = max(shuffle<1,0,3,2>(v),v); return max(shuffle<2,3,0,1>(h),h); }
__forceinline const vfloat4 vreduce_add(const vfloat4& v) { vfloat4 h = shuffle<1,0,3,2>(v) + v ; return shuffle<2,3,0,1>(h) + h ; }
__forceinline vfloat4 vreduce_min(const vfloat4& v) { vfloat4 h = min(shuffle<1,0,3,2>(v),v); return min(shuffle<2,3,0,1>(h),h); }
__forceinline vfloat4 vreduce_max(const vfloat4& v) { vfloat4 h = max(shuffle<1,0,3,2>(v),v); return max(shuffle<2,3,0,1>(h),h); }
__forceinline vfloat4 vreduce_add(const vfloat4& v) { vfloat4 h = shuffle<1,0,3,2>(v) + v ; return shuffle<2,3,0,1>(h) + h ; }
__forceinline float reduce_min(const vfloat4& v) { return _mm_cvtss_f32(vreduce_min(v)); }
__forceinline float reduce_max(const vfloat4& v) { return _mm_cvtss_f32(vreduce_max(v)); }
@@ -593,11 +659,11 @@ namespace embree
/// Euclidian Space Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline float dot ( const vfloat4& a, const vfloat4& b ) {
__forceinline float dot(const vfloat4& a, const vfloat4& b) {
return reduce_add(a*b);
}
__forceinline vfloat4 cross ( const vfloat4& a, const vfloat4& b )
__forceinline vfloat4 cross(const vfloat4& a, const vfloat4& b)
{
const vfloat4 a0 = a;
const vfloat4 b0 = shuffle<1,2,0,3>(b);
@@ -610,7 +676,7 @@ namespace embree
/// Output Operators
////////////////////////////////////////////////////////////////////////////////
inline std::ostream& operator<<(std::ostream& cout, const vfloat4& a) {
inline std::ostream& operator <<(std::ostream& cout, const vfloat4& a) {
return cout << "<" << a[0] << ", " << a[1] << ", " << a[2] << ", " << a[3] << ">";
}
+295 -214
View File
@@ -33,45 +33,46 @@ namespace embree
/// Constructors, Assignment & Cast Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline vfloat ( ) {}
__forceinline vfloat ( const vfloat8& other ) { v = other.v; }
__forceinline vfloat8& operator=( const vfloat8& other ) { v = other.v; return *this; }
__forceinline vfloat() {}
__forceinline vfloat(const vfloat8& other) { v = other.v; }
__forceinline vfloat8& operator =(const vfloat8& other) { v = other.v; return *this; }
__forceinline vfloat( const __m256 a ) : v(a) {}
__forceinline operator const __m256&( void ) const { return v; }
__forceinline operator __m256&( void ) { return v; }
__forceinline vfloat(__m256 a) : v(a) {}
__forceinline operator const __m256&() const { return v; }
__forceinline operator __m256&() { return v; }
__forceinline explicit vfloat( const vfloat4& a ) : v(_mm256_insertf128_ps(_mm256_castps128_ps256(a),a,1)) {}
__forceinline vfloat( const vfloat4& a, const vfloat4& b ) : v(_mm256_insertf128_ps(_mm256_castps128_ps256(a),b,1)) {}
__forceinline explicit vfloat(const vfloat4& a) : v(_mm256_insertf128_ps(_mm256_castps128_ps256(a),a,1)) {}
__forceinline vfloat(const vfloat4& a, const vfloat4& b) : v(_mm256_insertf128_ps(_mm256_castps128_ps256(a),b,1)) {}
__forceinline explicit vfloat( const char* const a ) : v(_mm256_loadu_ps((const float*)a)) {}
__forceinline vfloat( const float& a ) : v(_mm256_broadcast_ss(&a)) {}
__forceinline vfloat( float a, float b) : v(_mm256_set_ps(b, a, b, a, b, a, b, a)) {}
__forceinline vfloat( float a, float b, float c, float d ) : v(_mm256_set_ps(d, c, b, a, d, c, b, a)) {}
__forceinline vfloat( float a, float b, float c, float d, float e, float f, float g, float h ) : v(_mm256_set_ps(h, g, f, e, d, c, b, a)) {}
__forceinline explicit vfloat(const char* a) : v(_mm256_loadu_ps((const float*)a)) {}
__forceinline vfloat(float a) : v(_mm256_set1_ps(a)) {}
__forceinline vfloat(float a, float b) : v(_mm256_set_ps(b, a, b, a, b, a, b, a)) {}
__forceinline vfloat(float a, float b, float c, float d) : v(_mm256_set_ps(d, c, b, a, d, c, b, a)) {}
__forceinline vfloat(float a, float b, float c, float d, float e, float f, float g, float h) : v(_mm256_set_ps(h, g, f, e, d, c, b, a)) {}
__forceinline explicit vfloat( const __m256i a ) : v(_mm256_cvtepi32_ps(a)) {}
__forceinline explicit vfloat(__m256i a) : v(_mm256_cvtepi32_ps(a)) {}
////////////////////////////////////////////////////////////////////////////////
/// Constants
////////////////////////////////////////////////////////////////////////////////
__forceinline vfloat( ZeroTy ) : v(_mm256_setzero_ps()) {}
__forceinline vfloat( OneTy ) : v(_mm256_set1_ps(1.0f)) {}
__forceinline vfloat( PosInfTy ) : v(_mm256_set1_ps(pos_inf)) {}
__forceinline vfloat( NegInfTy ) : v(_mm256_set1_ps(neg_inf)) {}
__forceinline vfloat( StepTy ) : v(_mm256_set_ps(7.0f, 6.0f, 5.0f, 4.0f, 3.0f, 2.0f, 1.0f, 0.0f)) {}
__forceinline vfloat( NaNTy ) : v(_mm256_set1_ps(nan)) {}
__forceinline vfloat(ZeroTy) : v(_mm256_setzero_ps()) {}
__forceinline vfloat(OneTy) : v(_mm256_set1_ps(1.0f)) {}
__forceinline vfloat(PosInfTy) : v(_mm256_set1_ps(pos_inf)) {}
__forceinline vfloat(NegInfTy) : v(_mm256_set1_ps(neg_inf)) {}
__forceinline vfloat(StepTy) : v(_mm256_set_ps(7.0f, 6.0f, 5.0f, 4.0f, 3.0f, 2.0f, 1.0f, 0.0f)) {}
__forceinline vfloat(NaNTy) : v(_mm256_set1_ps(nan)) {}
__forceinline vfloat(UndefinedTy) : v(_mm256_undefined_ps()) {}
////////////////////////////////////////////////////////////////////////////////
/// Loads and Stores
////////////////////////////////////////////////////////////////////////////////
static __forceinline vfloat8 broadcast( const void* const a ) {
static __forceinline vfloat8 broadcast(const void* a) {
return _mm256_broadcast_ss((float*)a);
}
static __forceinline vfloat8 broadcast2( const float* const a, const float* const b ) {
static __forceinline vfloat8 broadcast2(const float* a, const float* b) {
#if defined(__INTEL_COMPILER)
const vfloat8 v0 = _mm256_broadcast_ss(a);
const vfloat8 v1 = _mm256_broadcast_ss(b);
@@ -81,11 +82,11 @@ namespace embree
#endif
}
static __forceinline const vfloat8 broadcast4f(const vfloat4* ptr) {
static __forceinline vfloat8 broadcast4f(const vfloat4* ptr) {
return _mm256_broadcast_ps((__m128*)ptr);
}
static __forceinline vfloat8 load( const unsigned char* const ptr ) {
static __forceinline vfloat8 load(const unsigned char* ptr) {
#if defined(__AVX2__)
return _mm256_cvtepi32_ps(_mm256_cvtepu8_epi32(_mm_loadu_si128((__m128i*)ptr)));
#else
@@ -93,24 +94,32 @@ namespace embree
#endif
}
static __forceinline vfloat8 load ( const void* const ptr) { return _mm256_load_ps((float*)ptr); }
static __forceinline vfloat8 loadu( const void* const ptr) { return _mm256_loadu_ps((float*)ptr); }
static __forceinline vfloat8 load (const void* ptr) { return _mm256_load_ps((float*)ptr); }
static __forceinline vfloat8 loadu(const void* ptr) { return _mm256_loadu_ps((float*)ptr); }
static __forceinline void store ( void* ptr, const vfloat8& v) { return _mm256_store_ps((float*)ptr,v); }
static __forceinline void storeu( void* ptr, const vfloat8& v) { return _mm256_storeu_ps((float*)ptr,v); }
static __forceinline void store (void* ptr, const vfloat8& v) { return _mm256_store_ps((float*)ptr,v); }
static __forceinline void storeu(void* ptr, const vfloat8& v) { return _mm256_storeu_ps((float*)ptr,v); }
#if defined(__AVX512VL__)
static __forceinline vfloat8 load ( const vboolf8& mask, const void* const ptr) { return _mm256_mask_load_ps (_mm256_setzero_ps(),mask,(float*)ptr); }
static __forceinline vfloat8 loadu( const vboolf8& mask, const void* const ptr) { return _mm256_mask_loadu_ps(_mm256_setzero_ps(),mask,(float*)ptr); }
static __forceinline void store ( const vboolf8& mask, void* ptr, const vfloat8& v) { _mm256_mask_store_ps ((float*)ptr,mask,v); }
static __forceinline void storeu( const vboolf8& mask, void* ptr, const vfloat8& v) { _mm256_mask_storeu_ps((float*)ptr,mask,v); }
static __forceinline vfloat8 compact(const vboolf8& mask, vfloat8 &v) {
return _mm256_mask_compress_ps(v, mask, v);
}
static __forceinline vfloat8 compact(const vboolf8& mask, vfloat8 &a, const vfloat8& b) {
return _mm256_mask_compress_ps(a, mask, b);
}
static __forceinline vfloat8 load (const vboolf8& mask, const void* ptr) { return _mm256_mask_load_ps (_mm256_setzero_ps(),mask,(float*)ptr); }
static __forceinline vfloat8 loadu(const vboolf8& mask, const void* ptr) { return _mm256_mask_loadu_ps(_mm256_setzero_ps(),mask,(float*)ptr); }
static __forceinline void store (const vboolf8& mask, void* ptr, const vfloat8& v) { _mm256_mask_store_ps ((float*)ptr,mask,v); }
static __forceinline void storeu(const vboolf8& mask, void* ptr, const vfloat8& v) { _mm256_mask_storeu_ps((float*)ptr,mask,v); }
#else
static __forceinline vfloat8 load ( const vboolf8& mask, const void* const ptr) { return _mm256_maskload_ps((float*)ptr,(__m256i)mask); }
static __forceinline vfloat8 loadu( const vboolf8& mask, const void* const ptr) { return _mm256_maskload_ps((float*)ptr,(__m256i)mask); }
static __forceinline vfloat8 load (const vboolf8& mask, const void* ptr) { return _mm256_maskload_ps((float*)ptr,(__m256i)mask); }
static __forceinline vfloat8 loadu(const vboolf8& mask, const void* ptr) { return _mm256_maskload_ps((float*)ptr,(__m256i)mask); }
static __forceinline void store ( const vboolf8& mask, void* ptr, const vfloat8& v) { _mm256_maskstore_ps((float*)ptr,(__m256i)mask,v); }
static __forceinline void storeu( const vboolf8& mask, void* ptr, const vfloat8& v) { _mm256_maskstore_ps((float*)ptr,(__m256i)mask,v); }
static __forceinline void store (const vboolf8& mask, void* ptr, const vfloat8& v) { _mm256_maskstore_ps((float*)ptr,(__m256i)mask,v); }
static __forceinline void storeu(const vboolf8& mask, void* ptr, const vfloat8& v) { _mm256_maskstore_ps((float*)ptr,(__m256i)mask,v); }
#endif
#if defined(__AVX2__)
@@ -123,8 +132,62 @@ 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)
template<int scale = 4>
static __forceinline vfloat8 gather(const float* ptr, const vint8& index) {
#if defined(__AVX2__)
return _mm256_i32gather_ps(ptr, index ,scale);
#else
return vfloat8(
*(float*)(((char*)ptr)+scale*index[0]),
*(float*)(((char*)ptr)+scale*index[1]),
*(float*)(((char*)ptr)+scale*index[2]),
*(float*)(((char*)ptr)+scale*index[3]),
*(float*)(((char*)ptr)+scale*index[4]),
*(float*)(((char*)ptr)+scale*index[5]),
*(float*)(((char*)ptr)+scale*index[6]),
*(float*)(((char*)ptr)+scale*index[7]));
#endif
}
template<int scale = 4>
static __forceinline vfloat8 gather(const vboolf8& mask, const float* ptr, const vint8& index) {
vfloat8 r = zero;
#if defined(__AVX512VL__)
return _mm256_mmask_i32gather_ps(r, mask, index, ptr, scale);
#elif defined(__AVX2__)
return _mm256_mask_i32gather_ps(r, ptr, index, mask, scale);
#else
if (likely(mask[0])) r[0] = *(float*)(((char*)ptr)+scale*index[0]);
if (likely(mask[1])) r[1] = *(float*)(((char*)ptr)+scale*index[1]);
if (likely(mask[2])) r[2] = *(float*)(((char*)ptr)+scale*index[2]);
if (likely(mask[3])) r[3] = *(float*)(((char*)ptr)+scale*index[3]);
if (likely(mask[4])) r[4] = *(float*)(((char*)ptr)+scale*index[4]);
if (likely(mask[5])) r[5] = *(float*)(((char*)ptr)+scale*index[5]);
if (likely(mask[6])) r[6] = *(float*)(((char*)ptr)+scale*index[6]);
if (likely(mask[7])) r[7] = *(float*)(((char*)ptr)+scale*index[7]);
return r;
#endif
}
template<int scale = 4>
static __forceinline void scatter(void* ptr, const vint8& ofs, const vfloat8& v)
{
#if defined(__AVX512VL__)
_mm256_i32scatter_ps((float*)ptr,ofs,v,scale);
#else
*(float*)(((char*)ptr)+scale*ofs[0]) = v[0];
*(float*)(((char*)ptr)+scale*ofs[1]) = v[1];
*(float*)(((char*)ptr)+scale*ofs[2]) = v[2];
*(float*)(((char*)ptr)+scale*ofs[3]) = v[3];
*(float*)(((char*)ptr)+scale*ofs[4]) = v[4];
*(float*)(((char*)ptr)+scale*ofs[5]) = v[5];
*(float*)(((char*)ptr)+scale*ofs[6]) = v[6];
*(float*)(((char*)ptr)+scale*ofs[7]) = v[7];
#endif
}
template<int scale = 4>
static __forceinline void scatter(const vboolf8& mask, void* ptr, const vint8& ofs, const vfloat8& v)
{
#if defined(__AVX512VL__)
_mm256_mask_i32scatter_ps((float*)ptr,mask,ofs,v,scale);
@@ -151,8 +214,8 @@ namespace embree
/// Array Access
////////////////////////////////////////////////////////////////////////////////
__forceinline const float& operator []( const size_t index ) const { assert(index < 8); return f[index]; }
__forceinline float& operator []( const size_t index ) { assert(index < 8); return f[index]; }
__forceinline const float& operator [](size_t index) const { assert(index < 8); return f[index]; }
__forceinline float& operator [](size_t index) { assert(index < 8); return f[index]; }
};
@@ -160,44 +223,45 @@ namespace embree
/// Unary Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline const vfloat8 asFloat ( const vint8& a ) { return _mm256_castsi256_ps(a); }
__forceinline const vint8 asInt ( const vfloat8& a ) { return _mm256_castps_si256(a); }
__forceinline const vfloat8 operator +( const vfloat8& a ) { return a; }
__forceinline const vfloat8 operator -( const vfloat8& a ) {
__forceinline vfloat8 asFloat(const vint8& a) { return _mm256_castsi256_ps(a); }
__forceinline vint8 asInt (const vfloat8& a) { return _mm256_castps_si256(a); }
__forceinline vfloat8 operator +(const vfloat8& a) { return a; }
__forceinline vfloat8 operator -(const vfloat8& a) {
const __m256 mask = _mm256_castsi256_ps(_mm256_set1_epi32(0x80000000));
return _mm256_xor_ps(a.v, mask);
return _mm256_xor_ps(a, mask);
}
__forceinline const vfloat8 abs ( const vfloat8& a ) {
__forceinline vfloat8 abs(const vfloat8& a) {
const __m256 mask = _mm256_castsi256_ps(_mm256_set1_epi32(0x7fffffff));
return _mm256_and_ps(a.v, mask);
return _mm256_and_ps(a, mask);
}
__forceinline const vfloat8 sign ( const vfloat8& a ) { return _mm256_blendv_ps(vfloat8(one), -vfloat8(one), _mm256_cmp_ps(a, vfloat8(zero), _CMP_NGE_UQ )); }
__forceinline const vfloat8 signmsk ( const vfloat8& a ) { return _mm256_and_ps(a.v,_mm256_castsi256_ps(_mm256_set1_epi32(0x80000000))); }
__forceinline vfloat8 sign (const vfloat8& a) { return _mm256_blendv_ps(vfloat8(one), -vfloat8(one), _mm256_cmp_ps(a, vfloat8(zero), _CMP_NGE_UQ)); }
__forceinline vfloat8 signmsk(const vfloat8& a) { return _mm256_and_ps(a,_mm256_castsi256_ps(_mm256_set1_epi32(0x80000000))); }
__forceinline const vfloat8 rcp(const vfloat8& a)
__forceinline vfloat8 rcp(const vfloat8& a)
{
#if defined(__AVX512VL__)
const vfloat8 r = _mm256_rcp14_ps(a.v);
const vfloat8 r = _mm256_rcp14_ps(a);
#else
const vfloat8 r = _mm256_rcp_ps(a.v);
const vfloat8 r = _mm256_rcp_ps(a);
#endif
#if defined(__AVX2__)
return _mm256_mul_ps(r,_mm256_fnmadd_ps(r, a, vfloat8(2.0f)));
return _mm256_mul_ps(r, _mm256_fnmadd_ps(r, a, vfloat8(2.0f)));
#else
return _mm256_mul_ps(r,_mm256_sub_ps(vfloat8(2.0f), _mm256_mul_ps(r, a)));
return _mm256_mul_ps(r, _mm256_sub_ps(vfloat8(2.0f), _mm256_mul_ps(r, a)));
#endif
}
__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 vfloat8 sqr (const vfloat8& a) { return _mm256_mul_ps(a,a); }
__forceinline vfloat8 sqrt(const vfloat8& a) { return _mm256_sqrt_ps(a); }
__forceinline const vfloat8 rsqrt( const vfloat8& a )
__forceinline vfloat8 rsqrt(const vfloat8& a)
{
#if defined(__AVX512VL__)
const vfloat8 r = _mm256_rsqrt14_ps(a.v);
const vfloat8 r = _mm256_rsqrt14_ps(a);
#else
const vfloat8 r = _mm256_rsqrt_ps(a.v);
const vfloat8 r = _mm256_rsqrt_ps(a);
#endif
#if defined(__AVX2__)
@@ -213,70 +277,75 @@ namespace embree
/// Binary Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline const vfloat8 operator +( const vfloat8& a, const vfloat8& b ) { return _mm256_add_ps(a.v, b.v); }
__forceinline const vfloat8 operator +( const vfloat8& a, const float b ) { return a + vfloat8(b); }
__forceinline const vfloat8 operator +( const float a, const vfloat8& b ) { return vfloat8(a) + b; }
__forceinline vfloat8 operator +(const vfloat8& a, const vfloat8& b) { return _mm256_add_ps(a, b); }
__forceinline vfloat8 operator +(const vfloat8& a, float b) { return a + vfloat8(b); }
__forceinline vfloat8 operator +(float a, const vfloat8& b) { return vfloat8(a) + b; }
__forceinline const vfloat8 operator -( const vfloat8& a, const vfloat8& b ) { return _mm256_sub_ps(a.v, b.v); }
__forceinline const vfloat8 operator -( const vfloat8& a, const float b ) { return a - vfloat8(b); }
__forceinline const vfloat8 operator -( const float a, const vfloat8& b ) { return vfloat8(a) - b; }
__forceinline vfloat8 operator -(const vfloat8& a, const vfloat8& b) { return _mm256_sub_ps(a, b); }
__forceinline vfloat8 operator -(const vfloat8& a, float b) { return a - vfloat8(b); }
__forceinline vfloat8 operator -(float a, const vfloat8& b) { return vfloat8(a) - b; }
__forceinline const vfloat8 operator *( const vfloat8& a, const vfloat8& b ) { return _mm256_mul_ps(a.v, b.v); }
__forceinline const vfloat8 operator *( const vfloat8& a, const float b ) { return a * vfloat8(b); }
__forceinline const vfloat8 operator *( const float a, const vfloat8& b ) { return vfloat8(a) * b; }
__forceinline vfloat8 operator *(const vfloat8& a, const vfloat8& b) { return _mm256_mul_ps(a, b); }
__forceinline vfloat8 operator *(const vfloat8& a, float b) { return a * vfloat8(b); }
__forceinline vfloat8 operator *(float a, const vfloat8& b) { return vfloat8(a) * b; }
__forceinline const vfloat8 operator /( const vfloat8& a, const vfloat8& b ) { return _mm256_div_ps(a.v, b.v); }
__forceinline const vfloat8 operator /( const vfloat8& a, const float b ) { return a / vfloat8(b); }
__forceinline const vfloat8 operator /( const float a, const vfloat8& b ) { return vfloat8(a) / b; }
__forceinline vfloat8 operator /(const vfloat8& a, const vfloat8& b) { return _mm256_div_ps(a, b); }
__forceinline vfloat8 operator /(const vfloat8& a, float b) { return a / vfloat8(b); }
__forceinline vfloat8 operator /(float a, const vfloat8& b) { return vfloat8(a) / b; }
__forceinline const vfloat8 operator^( const vfloat8& a, const vfloat8& b ) { return _mm256_xor_ps(a.v,b.v); }
__forceinline const vfloat8 operator^( const vfloat8& a, const vint8& b ) { return _mm256_xor_ps(a.v,_mm256_castsi256_ps(b.v)); }
__forceinline vfloat8 operator ^(const vfloat8& a, const vfloat8& b) { return _mm256_xor_ps(a,b); }
__forceinline vfloat8 operator ^(const vfloat8& a, const vint8& b) { return _mm256_xor_ps(a,_mm256_castsi256_ps(b)); }
__forceinline const vfloat8 operator&( const vfloat8& a, const vfloat8& b ) { return _mm256_and_ps(a.v,b.v); }
__forceinline vfloat8 operator &(const vfloat8& a, const vfloat8& b) { return _mm256_and_ps(a,b); }
__forceinline const vfloat8 min( const vfloat8& a, const vfloat8& b ) { return _mm256_min_ps(a.v, b.v); }
__forceinline const vfloat8 min( const vfloat8& a, const float b ) { return _mm256_min_ps(a.v, vfloat8(b)); }
__forceinline const vfloat8 min( const float a, const vfloat8& b ) { return _mm256_min_ps(vfloat8(a), b.v); }
__forceinline vfloat8 min(const vfloat8& a, const vfloat8& b) { return _mm256_min_ps(a, b); }
__forceinline vfloat8 min(const vfloat8& a, float b) { return _mm256_min_ps(a, vfloat8(b)); }
__forceinline vfloat8 min(float a, const vfloat8& b) { return _mm256_min_ps(vfloat8(a), b); }
__forceinline const vfloat8 max( const vfloat8& a, const vfloat8& b ) { return _mm256_max_ps(a.v, b.v); }
__forceinline const vfloat8 max( const vfloat8& a, const float b ) { return _mm256_max_ps(a.v, vfloat8(b)); }
__forceinline const vfloat8 max( const float a, const vfloat8& b ) { return _mm256_max_ps(vfloat8(a), b.v); }
__forceinline vfloat8 max(const vfloat8& a, const vfloat8& b) { return _mm256_max_ps(a, b); }
__forceinline vfloat8 max(const vfloat8& a, float b) { return _mm256_max_ps(a, vfloat8(b)); }
__forceinline vfloat8 max(float a, const vfloat8& b) { return _mm256_max_ps(vfloat8(a), b); }
#if defined (__AVX2__)
#if defined(__AVX2__)
__forceinline vfloat8 mini(const vfloat8& a, const vfloat8& b) {
const vint8 ai = _mm256_castps_si256(a);
const vint8 bi = _mm256_castps_si256(b);
const vint8 ci = _mm256_min_epi32(ai,bi);
return _mm256_castsi256_ps(ci);
}
__forceinline vfloat8 maxi(const vfloat8& a, const vfloat8& b) {
const vint8 ai = _mm256_castps_si256(a);
const vint8 bi = _mm256_castps_si256(b);
const vint8 ci = _mm256_max_epi32(ai,bi);
return _mm256_castsi256_ps(ci);
}
__forceinline vfloat8 mini(const vfloat8& a, const vfloat8& b) {
const vint8 ai = _mm256_castps_si256(a);
const vint8 bi = _mm256_castps_si256(b);
const vint8 ci = _mm256_min_epi32(ai,bi);
return _mm256_castsi256_ps(ci);
}
__forceinline vfloat8 minui(const vfloat8& a, const vfloat8& b) {
const vint8 ai = _mm256_castps_si256(a);
const vint8 bi = _mm256_castps_si256(b);
const vint8 ci = _mm256_min_epu32(ai,bi);
return _mm256_castsi256_ps(ci);
}
__forceinline vfloat8 maxui(const vfloat8& a, const vfloat8& b) {
const vint8 ai = _mm256_castps_si256(a);
const vint8 bi = _mm256_castps_si256(b);
const vint8 ci = _mm256_max_epu32(ai,bi);
return _mm256_castsi256_ps(ci);
}
__forceinline vfloat8 maxi(const vfloat8& a, const vfloat8& b) {
const vint8 ai = _mm256_castps_si256(a);
const vint8 bi = _mm256_castps_si256(b);
const vint8 ci = _mm256_max_epi32(ai,bi);
return _mm256_castsi256_ps(ci);
}
__forceinline vfloat8 minui(const vfloat8& a, const vfloat8& b) {
const vint8 ai = _mm256_castps_si256(a);
const vint8 bi = _mm256_castps_si256(b);
const vint8 ci = _mm256_min_epu32(ai,bi);
return _mm256_castsi256_ps(ci);
}
__forceinline vfloat8 maxui(const vfloat8& a, const vfloat8& b) {
const vint8 ai = _mm256_castps_si256(a);
const vint8 bi = _mm256_castps_si256(b);
const vint8 ci = _mm256_max_epu32(ai,bi);
return _mm256_castsi256_ps(ci);
}
#else
__forceinline vfloat8 mini(const vfloat8& a, const vfloat8& b) {
return min(a,b);
}
__forceinline vfloat8 maxi(const vfloat8& a, const vfloat8& b) {
return max(a,b);
}
__forceinline vfloat8 mini(const vfloat8& a, const vfloat8& b) {
return min(a,b);
}
__forceinline vfloat8 maxi(const vfloat8& a, const vfloat8& b) {
return max(a,b);
}
#endif
////////////////////////////////////////////////////////////////////////////////
@@ -284,83 +353,83 @@ namespace embree
////////////////////////////////////////////////////////////////////////////////
#if defined(__AVX2__)
__forceinline const vfloat8 madd ( const vfloat8& a, const vfloat8& b, const vfloat8& c) { return _mm256_fmadd_ps(a,b,c); }
__forceinline const vfloat8 msub ( const vfloat8& a, const vfloat8& b, const vfloat8& c) { return _mm256_fmsub_ps(a,b,c); }
__forceinline const vfloat8 nmadd ( const vfloat8& a, const vfloat8& b, const vfloat8& c) { return _mm256_fnmadd_ps(a,b,c); }
__forceinline const vfloat8 nmsub ( const vfloat8& a, const vfloat8& b, const vfloat8& c) { return _mm256_fnmsub_ps(a,b,c); }
__forceinline vfloat8 madd (const vfloat8& a, const vfloat8& b, const vfloat8& c) { return _mm256_fmadd_ps(a,b,c); }
__forceinline vfloat8 msub (const vfloat8& a, const vfloat8& b, const vfloat8& c) { return _mm256_fmsub_ps(a,b,c); }
__forceinline vfloat8 nmadd (const vfloat8& a, const vfloat8& b, const vfloat8& c) { return _mm256_fnmadd_ps(a,b,c); }
__forceinline vfloat8 nmsub (const vfloat8& a, const vfloat8& b, const vfloat8& c) { return _mm256_fnmsub_ps(a,b,c); }
#else
__forceinline const vfloat8 madd ( const vfloat8& a, const vfloat8& b, const vfloat8& c) { return a*b+c; }
__forceinline const vfloat8 msub ( const vfloat8& a, const vfloat8& b, const vfloat8& c) { return a*b-c; }
__forceinline const vfloat8 nmadd ( const vfloat8& a, const vfloat8& b, const vfloat8& c) { return -a*b+c;}
__forceinline const vfloat8 nmsub ( const vfloat8& a, const vfloat8& b, const vfloat8& c) { return -a*b-c; }
__forceinline vfloat8 madd (const vfloat8& a, const vfloat8& b, const vfloat8& c) { return a*b+c; }
__forceinline vfloat8 msub (const vfloat8& a, const vfloat8& b, const vfloat8& c) { return a*b-c; }
__forceinline vfloat8 nmadd (const vfloat8& a, const vfloat8& b, const vfloat8& c) { return -a*b+c;}
__forceinline vfloat8 nmsub (const vfloat8& a, const vfloat8& b, const vfloat8& c) { return -a*b-c; }
#endif
////////////////////////////////////////////////////////////////////////////////
/// Assignment Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline vfloat8& operator +=( vfloat8& a, const vfloat8& b ) { return a = a + b; }
__forceinline vfloat8& operator +=( vfloat8& a, const float b ) { return a = a + b; }
__forceinline vfloat8& operator +=(vfloat8& a, const vfloat8& b) { return a = a + b; }
__forceinline vfloat8& operator +=(vfloat8& a, float b) { return a = a + b; }
__forceinline vfloat8& operator -=( vfloat8& a, const vfloat8& b ) { return a = a - b; }
__forceinline vfloat8& operator -=( vfloat8& a, const float b ) { return a = a - b; }
__forceinline vfloat8& operator -=(vfloat8& a, const vfloat8& b) { return a = a - b; }
__forceinline vfloat8& operator -=(vfloat8& a, float b) { return a = a - b; }
__forceinline vfloat8& operator *=( vfloat8& a, const vfloat8& b ) { return a = a * b; }
__forceinline vfloat8& operator *=( vfloat8& a, const float b ) { return a = a * b; }
__forceinline vfloat8& operator *=(vfloat8& a, const vfloat8& b) { return a = a * b; }
__forceinline vfloat8& operator *=(vfloat8& a, float b) { return a = a * b; }
__forceinline vfloat8& operator /=( vfloat8& a, const vfloat8& b ) { return a = a / b; }
__forceinline vfloat8& operator /=( vfloat8& a, const float b ) { return a = a / b; }
__forceinline vfloat8& operator /=(vfloat8& a, const vfloat8& b) { return a = a / b; }
__forceinline vfloat8& operator /=(vfloat8& a, float b) { return a = a / b; }
////////////////////////////////////////////////////////////////////////////////
/// Comparison Operators + Select
////////////////////////////////////////////////////////////////////////////////
#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 vboolf8 operator ==(const vfloat8& a, const vfloat8& b) { return _mm256_cmp_ps_mask(a, b, _MM_CMPINT_EQ); }
__forceinline vboolf8 operator !=(const vfloat8& a, const vfloat8& b) { return _mm256_cmp_ps_mask(a, b, _MM_CMPINT_NE); }
__forceinline vboolf8 operator < (const vfloat8& a, const vfloat8& b) { return _mm256_cmp_ps_mask(a, b, _MM_CMPINT_LT); }
__forceinline vboolf8 operator >=(const vfloat8& a, const vfloat8& b) { return _mm256_cmp_ps_mask(a, b, _MM_CMPINT_GE); }
__forceinline vboolf8 operator > (const vfloat8& a, const vfloat8& b) { return _mm256_cmp_ps_mask(a, b, _MM_CMPINT_GT); }
__forceinline vboolf8 operator <=(const vfloat8& a, const vfloat8& b) { return _mm256_cmp_ps_mask(a, b, _MM_CMPINT_LE); }
__forceinline const vfloat8 select( const vboolf8& m, const vfloat8& t, const vfloat8& f ) {
__forceinline 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 vboolf8 operator ==(const vfloat8& a, const vfloat8& b) { return _mm256_cmp_ps(a, b, _CMP_EQ_OQ); }
__forceinline vboolf8 operator !=(const vfloat8& a, const vfloat8& b) { return _mm256_cmp_ps(a, b, _CMP_NEQ_OQ); }
__forceinline vboolf8 operator < (const vfloat8& a, const vfloat8& b) { return _mm256_cmp_ps(a, b, _CMP_LT_OQ); }
__forceinline vboolf8 operator >=(const vfloat8& a, const vfloat8& b) { return _mm256_cmp_ps(a, b, _CMP_GE_OQ); }
__forceinline vboolf8 operator > (const vfloat8& a, const vfloat8& b) { return _mm256_cmp_ps(a, b, _CMP_GT_OQ); }
__forceinline vboolf8 operator <=(const vfloat8& a, const vfloat8& b) { return _mm256_cmp_ps(a, b, _CMP_LE_OQ); }
__forceinline const vfloat8 select( const vboolf8& m, const vfloat8& t, const vfloat8& f ) {
__forceinline 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 ) {
__forceinline vfloat8 select(const vfloat8& t, const vfloat8& f) {
return _mm256_blend_ps(f, t, mask);
}
__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 operator ==(const vfloat8& a, const float& b) { return a == vfloat8(b); }
__forceinline vboolf8 operator ==(const float& a, const vfloat8& b) { return vfloat8(a) == b; }
__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 operator !=(const vfloat8& a, const float& b) { return a != vfloat8(b); }
__forceinline vboolf8 operator !=(const float& a, const vfloat8& b) { return vfloat8(a) != b; }
__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 operator < (const vfloat8& a, const float& b) { return a < vfloat8(b); }
__forceinline vboolf8 operator < (const float& a, const vfloat8& b) { return vfloat8(a) < b; }
__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 operator >=(const vfloat8& a, const float& b) { return a >= vfloat8(b); }
__forceinline vboolf8 operator >=(const float& a, const vfloat8& b) { return vfloat8(a) >= b; }
__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 operator > (const vfloat8& a, const float& b) { return a > vfloat8(b); }
__forceinline vboolf8 operator > (const float& a, const vfloat8& b) { return vfloat8(a) > b; }
__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 operator <=(const vfloat8& a, const float& b) { return a <= vfloat8(b); }
__forceinline 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; }
@@ -389,15 +458,15 @@ namespace embree
return madd(t,b-a,a);
}
__forceinline bool isvalid ( const vfloat8& v ) {
__forceinline bool isvalid (const vfloat8& v) {
return all((v > vfloat8(-FLT_LARGE)) & (v < vfloat8(+FLT_LARGE)));
}
__forceinline bool is_finite ( const vfloat8& a ) {
__forceinline bool is_finite (const vfloat8& a) {
return all((a >= vfloat8(-FLT_MAX)) & (a <= vfloat8(+FLT_MAX)));
}
__forceinline bool is_finite ( const vboolf8& valid, const vfloat8& a ) {
__forceinline bool is_finite (const vboolf8& valid, const vfloat8& a) {
return all(valid, (a >= vfloat8(-FLT_MAX)) & (a <= vfloat8(+FLT_MAX)));
}
@@ -405,98 +474,104 @@ namespace embree
/// Rounding Functions
////////////////////////////////////////////////////////////////////////////////
__forceinline const vfloat8 floor( const vfloat8& a ) { return _mm256_round_ps(a, _MM_FROUND_TO_NEG_INF ); }
__forceinline const vfloat8 ceil ( const vfloat8& a ) { return _mm256_round_ps(a, _MM_FROUND_TO_POS_INF ); }
__forceinline const vfloat8 trunc( const vfloat8& a ) { return _mm256_round_ps(a, _MM_FROUND_TO_ZERO ); }
__forceinline const vfloat8 frac ( const vfloat8& a ) { return a-floor(a); }
__forceinline vfloat8 floor(const vfloat8& a) { return _mm256_round_ps(a, _MM_FROUND_TO_NEG_INF ); }
__forceinline vfloat8 ceil (const vfloat8& a) { return _mm256_round_ps(a, _MM_FROUND_TO_POS_INF ); }
__forceinline vfloat8 trunc(const vfloat8& a) { return _mm256_round_ps(a, _MM_FROUND_TO_ZERO ); }
__forceinline vfloat8 frac (const vfloat8& a) { return a-floor(a); }
////////////////////////////////////////////////////////////////////////////////
/// Movement/Shifting/Shuffling Functions
////////////////////////////////////////////////////////////////////////////////
__forceinline vfloat8 unpacklo( const vfloat8& a, const vfloat8& b ) { return _mm256_unpacklo_ps(a.v, b.v); }
__forceinline vfloat8 unpackhi( const vfloat8& a, const vfloat8& b ) { return _mm256_unpackhi_ps(a.v, b.v); }
__forceinline vfloat8 unpacklo(const vfloat8& a, const vfloat8& b) { return _mm256_unpacklo_ps(a, b); }
__forceinline vfloat8 unpackhi(const vfloat8& a, const vfloat8& b) { return _mm256_unpackhi_ps(a, b); }
template<size_t i> __forceinline const vfloat8 shuffle( const vfloat8& a ) {
return _mm256_permute_ps(a, _MM_SHUFFLE(i, i, i, i));
template<int i>
__forceinline vfloat8 shuffle(const vfloat8& v) {
return _mm256_permute_ps(v, _MM_SHUFFLE(i, i, i, i));
}
template<size_t i0, size_t i1> __forceinline const vfloat8 shuffle4( const vfloat8& a ) {
return _mm256_permute2f128_ps(a, a, (i1 << 4) | (i0 << 0));
template<int i0, int i1>
__forceinline vfloat8 shuffle4(const vfloat8& v) {
return _mm256_permute2f128_ps(v, v, (i1 << 4) | (i0 << 0));
}
template<size_t i0, size_t i1> __forceinline const vfloat8 shuffle4( const vfloat8& a, const vfloat8& b) {
template<int i0, int i1>
__forceinline vfloat8 shuffle4(const vfloat8& a, const vfloat8& b) {
return _mm256_permute2f128_ps(a, b, (i1 << 4) | (i0 << 0));
}
template<size_t i0, size_t i1, size_t i2, size_t i3> __forceinline const vfloat8 shuffle( const vfloat8& a ) {
return _mm256_permute_ps(a, _MM_SHUFFLE(i3, i2, i1, i0));
template<int i0, int i1, int i2, int i3>
__forceinline vfloat8 shuffle(const vfloat8& v) {
return _mm256_permute_ps(v, _MM_SHUFFLE(i3, i2, i1, i0));
}
template<size_t i0, size_t i1, size_t i2, size_t i3> __forceinline const vfloat8 shuffle( const vfloat8& a, const vfloat8& b ) {
template<int i0, int i1, int i2, int i3>
__forceinline vfloat8 shuffle(const vfloat8& a, const vfloat8& b) {
return _mm256_shuffle_ps(a, b, _MM_SHUFFLE(i3, i2, i1, i0));
}
template<> __forceinline const vfloat8 shuffle<0, 0, 2, 2>( const vfloat8& b ) { return _mm256_moveldup_ps(b); }
template<> __forceinline const vfloat8 shuffle<1, 1, 3, 3>( const vfloat8& b ) { return _mm256_movehdup_ps(b); }
template<> __forceinline const vfloat8 shuffle<0, 1, 0, 1>( const vfloat8& b ) { return _mm256_castpd_ps(_mm256_movedup_pd(_mm256_castps_pd(b))); }
template<> __forceinline vfloat8 shuffle<0, 0, 2, 2>(const vfloat8& v) { return _mm256_moveldup_ps(v); }
template<> __forceinline vfloat8 shuffle<1, 1, 3, 3>(const vfloat8& v) { return _mm256_movehdup_ps(v); }
template<> __forceinline vfloat8 shuffle<0, 1, 0, 1>(const vfloat8& v) { return _mm256_castpd_ps(_mm256_movedup_pd(_mm256_castps_pd(v))); }
__forceinline const vfloat8 broadcast(const float* ptr) { return _mm256_broadcast_ss(ptr); }
template<size_t i> __forceinline const vfloat8 insert4(const vfloat8& a, const vfloat4& b) { return _mm256_insertf128_ps(a, b, i); }
template<size_t i> __forceinline const vfloat4 extract4 (const vfloat8& a) { return _mm256_extractf128_ps(a, i); }
template<> __forceinline const vfloat4 extract4<0>(const vfloat8& a) { return _mm256_castps256_ps128(a); }
__forceinline vfloat8 broadcast(const float* ptr) { return _mm256_broadcast_ss(ptr); }
template<size_t i> __forceinline vfloat8 insert4(const vfloat8& a, const vfloat4& b) { return _mm256_insertf128_ps(a, b, i); }
template<size_t i> __forceinline vfloat4 extract4 (const vfloat8& a) { return _mm256_extractf128_ps(a, i); }
template<> __forceinline vfloat4 extract4<0>(const vfloat8& a) { return _mm256_castps256_ps128(a); }
__forceinline float toScalar(const vfloat8& a) { return _mm_cvtss_f32(_mm256_castps256_ps128(a)); }
__forceinline float toScalar(const vfloat8& v) { return _mm_cvtss_f32(_mm256_castps256_ps128(v)); }
__forceinline vfloat8 assign( const vfloat4& a ) { return _mm256_castps128_ps256(a); }
__forceinline vfloat8 assign(const vfloat4& a) { return _mm256_castps128_ps256(a); }
#if defined (__AVX2__)
__forceinline vfloat8 permute(const vfloat8 &a, const __m256i &index) {
return _mm256_permutevar8x32_ps(a,index);
__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) {
__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));
}
#endif
#if defined (__AVX_I__)
template<const int mode>
__forceinline vint4 convert_to_hf16(const vfloat8 &a) {
return _mm256_cvtps_ph(a,mode);
__forceinline vint4 convert_to_hf16(const vfloat8& a) {
return _mm256_cvtps_ph(a, mode);
}
__forceinline vfloat8 convert_from_hf16(const vint4 &a) {
__forceinline vfloat8 convert_from_hf16(const vint4& a) {
return _mm256_cvtph_ps(a);
}
#endif
__forceinline vfloat4 broadcast4f( const vfloat8& a, const size_t k ) {
__forceinline vfloat4 broadcast4f(const vfloat8& a, const size_t k) {
return vfloat4::broadcast(&a[k]);
}
__forceinline vfloat8 broadcast8f( const vfloat8& a, const size_t k ) {
__forceinline vfloat8 broadcast8f(const vfloat8& a, const size_t k) {
return vfloat8::broadcast(&a[k]);
}
#if defined(__AVX512VL__)
__forceinline vfloat8 shift_right_1( const vfloat8& x) {
__forceinline vfloat8 shift_right_1(const vfloat8& x) {
return align_shift_right<1>(zero,x);
}
#else
__forceinline vfloat8 shift_right_1( const vfloat8& x) {
__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) {
__forceinline vint8 floori(const vfloat8& a) {
return vint8(floor(a));
}
////////////////////////////////////////////////////////////////////////////////
/// Transpose
////////////////////////////////////////////////////////////////////////////////
@@ -539,6 +614,12 @@ namespace embree
c7 = shuffle4<1,3>(h3,h7);
}
__forceinline void transpose(const vfloat4& r0, const vfloat4& r1, const vfloat4& r2, const vfloat4& r3, const vfloat4& r4, const vfloat4& r5, const vfloat4& r6, const vfloat4& r7,
vfloat8& c0, vfloat8& c1, vfloat8& c2, vfloat8& c3)
{
transpose(vfloat8(r0,r4), vfloat8(r1,r5), vfloat8(r2,r6), vfloat8(r3,r7), c0, c1, c2, c3);
}
__forceinline void transpose(const vfloat4& r0, const vfloat4& r1, const vfloat4& r2, const vfloat4& r3, const vfloat4& r4, const vfloat4& r5, const vfloat4& r6, const vfloat4& r7,
vfloat8& c0, vfloat8& c1, vfloat8& c2)
{
@@ -549,17 +630,17 @@ namespace embree
/// Reductions
////////////////////////////////////////////////////////////////////////////////
__forceinline const vfloat8 vreduce_min2(const vfloat8& v) { return min(v,shuffle<1,0,3,2>(v)); }
__forceinline const vfloat8 vreduce_min4(const vfloat8& v) { vfloat8 v1 = vreduce_min2(v); return min(v1,shuffle<2,3,0,1>(v1)); }
__forceinline const vfloat8 vreduce_min (const vfloat8& v) { vfloat8 v1 = vreduce_min4(v); return min(v1,shuffle4<1,0>(v1)); }
__forceinline vfloat8 vreduce_min2(const vfloat8& v) { return min(v,shuffle<1,0,3,2>(v)); }
__forceinline vfloat8 vreduce_min4(const vfloat8& v) { vfloat8 v1 = vreduce_min2(v); return min(v1,shuffle<2,3,0,1>(v1)); }
__forceinline vfloat8 vreduce_min (const vfloat8& v) { vfloat8 v1 = vreduce_min4(v); return min(v1,shuffle4<1,0>(v1)); }
__forceinline const vfloat8 vreduce_max2(const vfloat8& v) { return max(v,shuffle<1,0,3,2>(v)); }
__forceinline const vfloat8 vreduce_max4(const vfloat8& v) { vfloat8 v1 = vreduce_max2(v); return max(v1,shuffle<2,3,0,1>(v1)); }
__forceinline const vfloat8 vreduce_max (const vfloat8& v) { vfloat8 v1 = vreduce_max4(v); return max(v1,shuffle4<1,0>(v1)); }
__forceinline vfloat8 vreduce_max2(const vfloat8& v) { return max(v,shuffle<1,0,3,2>(v)); }
__forceinline vfloat8 vreduce_max4(const vfloat8& v) { vfloat8 v1 = vreduce_max2(v); return max(v1,shuffle<2,3,0,1>(v1)); }
__forceinline vfloat8 vreduce_max (const vfloat8& v) { vfloat8 v1 = vreduce_max4(v); return max(v1,shuffle4<1,0>(v1)); }
__forceinline const vfloat8 vreduce_add2(const vfloat8& v) { return v + shuffle<1,0,3,2>(v); }
__forceinline const vfloat8 vreduce_add4(const vfloat8& v) { vfloat8 v1 = vreduce_add2(v); return v1 + shuffle<2,3,0,1>(v1); }
__forceinline const vfloat8 vreduce_add (const vfloat8& v) { vfloat8 v1 = vreduce_add4(v); return v1 + shuffle4<1,0>(v1); }
__forceinline vfloat8 vreduce_add2(const vfloat8& v) { return v + shuffle<1,0,3,2>(v); }
__forceinline vfloat8 vreduce_add4(const vfloat8& v) { vfloat8 v1 = vreduce_add2(v); return v1 + shuffle<2,3,0,1>(v1); }
__forceinline vfloat8 vreduce_add (const vfloat8& v) { vfloat8 v1 = vreduce_add4(v); return v1 + shuffle4<1,0>(v1); }
__forceinline float reduce_min(const vfloat8& v) { return toScalar(vreduce_min(v)); }
__forceinline float reduce_max(const vfloat8& v) { return toScalar(vreduce_max(v)); }
@@ -584,15 +665,15 @@ namespace embree
/// Euclidian Space Operators (pairs of Vec3fa's)
////////////////////////////////////////////////////////////////////////////////
//__forceinline vfloat8 dot ( const vfloat8& a, const vfloat8& b ) {
//__forceinline vfloat8 dot(const vfloat8& a, const vfloat8& b) {
// return vreduce_add4(a*b);
//}
__forceinline vfloat8 dot ( const vfloat8& a, const vfloat8& b ) {
__forceinline vfloat8 dot(const vfloat8& a, const vfloat8& b) {
return _mm256_dp_ps(a,b,0x7F);
}
__forceinline vfloat8 cross ( const vfloat8& a, const vfloat8& b )
__forceinline vfloat8 cross(const vfloat8& a, const vfloat8& b)
{
const vfloat8 a0 = a;
const vfloat8 b0 = shuffle<1,2,0,3>(b);
@@ -601,17 +682,17 @@ namespace embree
return shuffle<1,2,0,3>(msub(a0,b0,a1*b1));
}
//__forceinline float sqr_length ( const vfloat<8>& a ) { return dot(a,a); }
//__forceinline float rcp_length ( const vfloat<8>& a ) { return rsqrt(dot(a,a)); }
//__forceinline float rcp_length2( const vfloat<8>& a ) { return rcp(dot(a,a)); }
//__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 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; }
//__forceinline float sqr_length (const vfloat<8>& a) { return dot(a,a); }
//__forceinline float rcp_length (const vfloat<8>& a) { return rsqrt(dot(a,a)); }
//__forceinline float rcp_length2(const vfloat<8>& a) { return rcp(dot(a,a)); }
//__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 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; }
//__forceinline vfloat<8> normalize_safe( const vfloat<8>& a ) {
//__forceinline vfloat<8> normalize_safe(const vfloat<8>& a) {
// const float d = dot(a,a); if (unlikely(d == 0.0f)) return a; else return a*rsqrt(d);
//}
@@ -683,7 +764,7 @@ namespace embree
/// Output Operators
////////////////////////////////////////////////////////////////////////////////
inline std::ostream& operator<<(std::ostream& cout, const vfloat8& a) {
inline std::ostream& operator <<(std::ostream& cout, const vfloat8& a) {
return cout << "<" << a[0] << ", " << a[1] << ", " << a[2] << ", " << a[3] << ", " << a[4] << ", " << a[5] << ", " << a[6] << ", " << a[7] << ">";
}
}
+164 -155
View File
@@ -38,24 +38,24 @@ namespace embree
__forceinline vint() {}
__forceinline vint(const vint16& t) { v = t.v; }
__forceinline vint16& operator=(const vint16& f) { v = f.v; return *this; }
__forceinline vint16& operator =(const vint16& f) { v = f.v; return *this; }
__forceinline vint(const __m512i& t) { v = t; }
__forceinline operator __m512i () const { return v; }
__forceinline operator __m256i () const { return _mm512_castsi512_si256(v); }
__forceinline operator __m512i() const { return v; }
__forceinline operator __m256i() const { return _mm512_castsi512_si256(v); }
__forceinline vint(const int i) {
__forceinline vint(int i) {
v = _mm512_set1_epi32(i);
}
__forceinline vint(const int a, const int b, const int c, const int d) {
__forceinline vint(int a, int b, int c, int d) {
v = _mm512_set4_epi32(d,c,b,a);
}
__forceinline vint(const int a0 , const int a1 , const int a2 , const int a3,
const int a4 , const int a5 , const int a6 , const int a7,
const int a8 , const int a9 , const int a10, const int a11,
const int a12, const int a13, const int a14, const int a15)
__forceinline vint(int a0 , int a1 , int a2 , int a3,
int a4 , int a5 , int a6 , int a7,
int a8 , int a9 , int a10, int a11,
int a12, int a13, int a14, int a15)
{
v = _mm512_set_epi32(a15,a14,a13,a12,a11,a10,a9,a8,a7,a6,a5,a4,a3,a2,a1,a0);
}
@@ -64,9 +64,21 @@ namespace embree
v = _mm512_broadcast_i32x4(i);
}
__forceinline vint(const vint4& a, const vint4& b, const vint4& c, const vint4& d) {
v = _mm512_castsi128_si512(a);
v = _mm512_inserti32x4(v, b, 1);
v = _mm512_inserti32x4(v, c, 2);
v = _mm512_inserti32x4(v, d, 3);
}
__forceinline vint(const vint8& i) {
v = _mm512_castps_si512(_mm512_castpd_ps(_mm512_broadcast_f64x4(_mm256_castsi256_pd(i))));
}
__forceinline vint(const vint8& a, const vint8& b) {
v = _mm512_castsi256_si512(a);
v = _mm512_inserti64x4(v, b, 1);
}
__forceinline explicit vint(const __m512& f) {
v = _mm512_cvtps_epi32(f);
@@ -76,17 +88,12 @@ namespace embree
/// Constants
////////////////////////////////////////////////////////////////////////////////
__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( 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 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(ReverseStepTy) : v(_mm512_setr_epi32(15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0)) {}
////////////////////////////////////////////////////////////////////////////////
/// Loads and Stores
@@ -94,8 +101,8 @@ 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 vint16 load(const unsigned char* ptr) { return _mm512_cvtepu8_epi32(_mm_load_si128((__m128i*)ptr)); }
static __forceinline vint16 load(const unsigned short* ptr) { return _mm512_cvtepu16_epi32(*(__m256i*)ptr); }
static __forceinline vint16 loadu(const void* addr) { return _mm512_loadu_si512(addr); }
@@ -106,16 +113,16 @@ namespace embree
static __forceinline void storeu(void* ptr, const vint16& v) { _mm512_storeu_si512(ptr,v); }
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 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((__m512i*)ptr,a); }
/* pass by value to avoid compiler generating inefficient code */
static __forceinline void storeu_compact(const vboolf16 mask,void * addr, const vint16 reg) {
static __forceinline void storeu_compact(const vboolf16 mask, void* addr, vint16 reg) {
_mm512_mask_compressstoreu_epi32(addr,mask,reg);
}
static __forceinline void storeu_compact_single(const vboolf16 mask,void * addr, const vint16 reg) {
static __forceinline void storeu_compact_single(const vboolf16 mask, void* addr, 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)));
}
@@ -136,135 +143,159 @@ namespace embree
return _mm512_mask_expand_epi32(b,mask,a);
}
template<int scale = 4>
static __forceinline vint16 gather(const int* ptr, const vint16& index) {
return _mm512_i32gather_epi32(index,ptr,scale);
}
template<int scale = 4>
static __forceinline vint16 gather(const vboolf16& mask, const int* ptr, const vint16& index) {
return _mm512_mask_i32gather_epi32(_mm512_undefined_epi32(),mask,index,ptr,scale);
}
template<int scale = 4>
static __forceinline vint16 gather(const vboolf16& mask, vint16& dest, const int* ptr, const vint16& index) {
return _mm512_mask_i32gather_epi32(dest,mask,index,ptr,scale);
}
template<int scale = 4>
static __forceinline void scatter(int* ptr, const vint16& index, const vint16& v) {
_mm512_i32scatter_epi32((int*)ptr,index,v,scale);
}
template<int scale = 4>
static __forceinline void scatter(const vboolf16& mask, int* ptr, const vint16& index, const vint16& v) {
_mm512_mask_i32scatter_epi32((int*)ptr,mask,index,v,scale);
}
static __forceinline vint16 broadcast64bit(size_t v) {
return _mm512_set1_epi64(v);
}
////////////////////////////////////////////////////////////////////////////////
/// Array Access
////////////////////////////////////////////////////////////////////////////////
__forceinline int& operator[](const size_t index) { assert(index < 16); return i[index]; }
__forceinline const int& operator[](const size_t index) const { assert(index < 16); return i[index]; }
__forceinline int& operator [](size_t index) { assert(index < 16); return i[index]; }
__forceinline const int& operator [](size_t index) const { assert(index < 16); return i[index]; }
__forceinline unsigned int uint (const size_t index) const { assert(index < 16); return ((unsigned int*)i)[index]; }
__forceinline size_t& uint64_t(const size_t index) const { assert(index < 8); return ((size_t*)i)[index]; }
__forceinline unsigned int uint (size_t index) const { assert(index < 16); return ((unsigned int*)i)[index]; }
__forceinline size_t& uint64_t(size_t index) const { assert(index < 8); return ((size_t*)i)[index]; }
};
////////////////////////////////////////////////////////////////////////////////
/// Unary Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline const vint16 asInt ( const __m512& a ) { return _mm512_castps_si512(a); }
__forceinline const vint16 operator +( const vint16& a ) { return a; }
__forceinline const vint16 operator -( const vint16& a ) { return _mm512_sub_epi32(_mm512_setzero_epi32(), a); }
__forceinline vint16 asInt (const __m512& a) { return _mm512_castps_si512(a); }
__forceinline vint16 operator +(const vint16& a) { return a; }
__forceinline vint16 operator -(const vint16& a) { return _mm512_sub_epi32(_mm512_setzero_epi32(), a); }
////////////////////////////////////////////////////////////////////////////////
/// Binary Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline const vint16 operator +( const vint16& a, const vint16& b ) { return _mm512_add_epi32(a, b); }
__forceinline const vint16 operator +( const vint16& a, const int b ) { return a + vint16(b); }
__forceinline const vint16 operator +( const int a, const vint16& b ) { return vint16(a) + b; }
__forceinline vint16 operator +(const vint16& a, const vint16& b) { return _mm512_add_epi32(a, b); }
__forceinline vint16 operator +(const vint16& a, int b) { return a + vint16(b); }
__forceinline vint16 operator +(int a, const vint16& b) { return vint16(a) + b; }
__forceinline const vint16 operator -( const vint16& a, const vint16& b ) { return _mm512_sub_epi32(a, b); }
__forceinline const vint16 operator -( const vint16& a, const int b ) { return a - vint16(b); }
__forceinline const vint16 operator -( const int a, const vint16& b ) { return vint16(a) - b; }
__forceinline vint16 operator -(const vint16& a, const vint16& b) { return _mm512_sub_epi32(a, b); }
__forceinline vint16 operator -(const vint16& a, int b) { return a - vint16(b); }
__forceinline vint16 operator -(int a, const vint16& b) { return vint16(a) - b; }
__forceinline const vint16 operator *( const vint16& a, const vint16& b ) { return _mm512_mullo_epi32(a, b); }
__forceinline const vint16 operator *( const vint16& a, const int b ) { return a * vint16(b); }
__forceinline const vint16 operator *( const int a, const vint16& b ) { return vint16(a) * b; }
__forceinline vint16 operator *(const vint16& a, const vint16& b) { return _mm512_mullo_epi32(a, b); }
__forceinline vint16 operator *(const vint16& a, int b) { return a * vint16(b); }
__forceinline vint16 operator *(int a, const vint16& b) { return vint16(a) * b; }
__forceinline const vint16 operator &( const vint16& a, const vint16& b ) { return _mm512_and_epi32(a, b); }
__forceinline const vint16 operator &( const vint16& a, const int b ) { return a & vint16(b); }
__forceinline const vint16 operator &( const int a, const vint16& b ) { return vint16(a) & b; }
__forceinline vint16 operator &(const vint16& a, const vint16& b) { return _mm512_and_epi32(a, b); }
__forceinline vint16 operator &(const vint16& a, int b) { return a & vint16(b); }
__forceinline vint16 operator &(int a, const vint16& b) { return vint16(a) & b; }
__forceinline const vint16 operator |( const vint16& a, const vint16& b ) { return _mm512_or_epi32(a, b); }
__forceinline const vint16 operator |( const vint16& a, const int b ) { return a | vint16(b); }
__forceinline const vint16 operator |( const int a, const vint16& b ) { return vint16(a) | b; }
__forceinline vint16 operator |(const vint16& a, const vint16& b) { return _mm512_or_epi32(a, b); }
__forceinline vint16 operator |(const vint16& a, int b) { return a | vint16(b); }
__forceinline vint16 operator |(int a, const vint16& b) { return vint16(a) | b; }
__forceinline const vint16 operator ^( const vint16& a, const vint16& b ) { return _mm512_xor_epi32(a, b); }
__forceinline const vint16 operator ^( const vint16& a, const int b ) { return a ^ vint16(b); }
__forceinline const vint16 operator ^( const int a, const vint16& b ) { return vint16(a) ^ b; }
__forceinline vint16 operator ^(const vint16& a, const vint16& b) { return _mm512_xor_epi32(a, b); }
__forceinline vint16 operator ^(const vint16& a, int b) { return a ^ vint16(b); }
__forceinline vint16 operator ^(int a, const vint16& b) { return vint16(a) ^ b; }
__forceinline const vint16 operator <<( const vint16& a, const int n ) { return _mm512_slli_epi32(a, n); }
__forceinline const vint16 operator >>( const vint16& a, const int n ) { return _mm512_srai_epi32(a, n); }
__forceinline vint16 operator <<(const vint16& a, int n) { return _mm512_slli_epi32(a, n); }
__forceinline vint16 operator >>(const vint16& a, int n) { return _mm512_srai_epi32(a, n); }
__forceinline const vint16 operator <<( const vint16& a, const vint16& n ) { return _mm512_sllv_epi32(a, n); }
__forceinline const vint16 operator >>( const vint16& a, const vint16& n ) { return _mm512_srav_epi32(a, n); }
__forceinline vint16 operator <<(const vint16& a, const vint16& n) { return _mm512_sllv_epi32(a, n); }
__forceinline vint16 operator >>(const vint16& a, const vint16& n) { return _mm512_srav_epi32(a, n); }
__forceinline const vint16 sll ( const vint16& a, const int b ) { return _mm512_slli_epi32(a, b); }
__forceinline const vint16 sra ( const vint16& a, const int b ) { return _mm512_srai_epi32(a, b); }
__forceinline const vint16 srl ( const vint16& a, const int b ) { return _mm512_srli_epi32(a, b); }
__forceinline vint16 sll (const vint16& a, int b) { return _mm512_slli_epi32(a, b); }
__forceinline vint16 sra (const vint16& a, int b) { return _mm512_srai_epi32(a, b); }
__forceinline vint16 srl (const vint16& a, int b) { return _mm512_srli_epi32(a, b); }
__forceinline const vint16 min( const vint16& a, const vint16& b ) { return _mm512_min_epi32(a, b); }
__forceinline const vint16 min( const vint16& a, const int b ) { return min(a,vint16(b)); }
__forceinline const vint16 min( const int a, const vint16& b ) { return min(vint16(a),b); }
__forceinline vint16 min(const vint16& a, const vint16& b) { return _mm512_min_epi32(a, b); }
__forceinline vint16 min(const vint16& a, int b) { return min(a,vint16(b)); }
__forceinline vint16 min(int a, const vint16& b) { return min(vint16(a),b); }
__forceinline const vint16 max( const vint16& a, const vint16& b ) { return _mm512_max_epi32(a, b); }
__forceinline const vint16 max( const vint16& a, const int b ) { return max(a,vint16(b)); }
__forceinline const vint16 max( const int a, const vint16& b ) { return max(vint16(a),b); }
__forceinline vint16 max(const vint16& a, const vint16& b) { return _mm512_max_epi32(a, b); }
__forceinline vint16 max(const vint16& a, int b) { return max(a,vint16(b)); }
__forceinline vint16 max(int a, const vint16& b) { return max(vint16(a),b); }
__forceinline const vint16 umin( const vint16& a, const vint16& b ) { return _mm512_min_epu32(a.v, b.v); }
__forceinline const vint16 umax( const vint16& a, const vint16& b ) { return _mm512_max_epu32(a.v, b.v); }
__forceinline vint16 umin(const vint16& a, const vint16& b) { return _mm512_min_epu32(a, b); }
__forceinline vint16 umax(const vint16& a, const vint16& b) { return _mm512_max_epu32(a, b); }
__forceinline const vint16 mask_add(const vboolf16& mask, vint16& c, const vint16& a, const vint16& b) { return _mm512_mask_add_epi32(c,mask,a,b); }
__forceinline const vint16 mask_sub(const vboolf16& mask, vint16& c, const vint16& a, const vint16& b) { return _mm512_mask_sub_epi32(c,mask,a,b); }
__forceinline vint16 mask_add(const vboolf16& mask, vint16& c, const vint16& a, const vint16& b) { return _mm512_mask_add_epi32(c,mask,a,b); }
__forceinline vint16 mask_sub(const vboolf16& mask, vint16& c, const vint16& a, const vint16& b) { return _mm512_mask_sub_epi32(c,mask,a,b); }
__forceinline const vint16 mask_and(const vboolf16& m,vint16& c, const vint16& a, const vint16& b) { return _mm512_mask_and_epi32(c,m,a,b); }
__forceinline const vint16 mask_or (const vboolf16& m,vint16& c, const vint16& a, const vint16& b) { return _mm512_mask_or_epi32(c,m,a,b); }
__forceinline vint16 mask_and(const vboolf16& m, vint16& c, const vint16& a, const vint16& b) { return _mm512_mask_and_epi32(c,m,a,b); }
__forceinline vint16 mask_or (const vboolf16& m, vint16& c, const vint16& a, const vint16& b) { return _mm512_mask_or_epi32(c,m,a,b); }
////////////////////////////////////////////////////////////////////////////////
/// Assignment Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline vint16& operator +=( vint16& a, const vint16& b ) { return a = a + b; }
__forceinline vint16& operator +=( vint16& a, const int b ) { return a = a + b; }
__forceinline vint16& operator +=(vint16& a, const vint16& b) { return a = a + b; }
__forceinline vint16& operator +=(vint16& a, int b) { return a = a + b; }
__forceinline vint16& operator -=( vint16& a, const vint16& b ) { return a = a - b; }
__forceinline vint16& operator -=( vint16& a, const int b ) { return a = a - b; }
__forceinline vint16& operator -=(vint16& a, const vint16& b) { return a = a - b; }
__forceinline vint16& operator -=(vint16& a, int b) { return a = a - b; }
__forceinline vint16& operator *=( vint16& a, const vint16& b ) { return a = a * b; }
__forceinline vint16& operator *=( vint16& a, const int b ) { return a = a * b; }
__forceinline vint16& operator *=(vint16& a, const vint16& b) { return a = a * b; }
__forceinline vint16& operator *=(vint16& a, int b) { return a = a * b; }
__forceinline vint16& operator &=( vint16& a, const vint16& b ) { return a = a & b; }
__forceinline vint16& operator &=( vint16& a, const int b ) { return a = a & b; }
__forceinline vint16& operator &=(vint16& a, const vint16& b) { return a = a & b; }
__forceinline vint16& operator &=(vint16& a, int b) { return a = a & b; }
__forceinline vint16& operator |=( vint16& a, const vint16& b ) { return a = a | b; }
__forceinline vint16& operator |=( vint16& a, const int b ) { return a = a | b; }
__forceinline vint16& operator |=(vint16& a, const vint16& b) { return a = a | b; }
__forceinline vint16& operator |=(vint16& a, int b) { return a = a | b; }
__forceinline vint16& operator <<=( vint16& a, const int b ) { return a = a << b; }
__forceinline vint16& operator >>=( vint16& a, const int b ) { return a = a >> b; }
__forceinline vint16& operator <<=(vint16& a, int b) { return a = a << b; }
__forceinline vint16& operator >>=(vint16& a, int b) { return a = a >> b; }
////////////////////////////////////////////////////////////////////////////////
/// Comparison Operators + Select
////////////////////////////////////////////////////////////////////////////////
__forceinline const vboolf16 operator ==( const vint16& a, const vint16& b ) { return _mm512_cmp_epi32_mask(a,b,_MM_CMPINT_EQ); }
__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 operator ==(const vint16& a, const vint16& b) { return _mm512_cmp_epi32_mask(a,b,_MM_CMPINT_EQ); }
__forceinline vboolf16 operator ==(const vint16& a, int b) { return a == vint16(b); }
__forceinline vboolf16 operator ==(int a, const vint16& b) { return vint16(a) == b; }
__forceinline const vboolf16 operator !=( const vint16& a, const vint16& b ) { return _mm512_cmp_epi32_mask(a,b,_MM_CMPINT_NE); }
__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 operator !=(const vint16& a, const vint16& b) { return _mm512_cmp_epi32_mask(a,b,_MM_CMPINT_NE); }
__forceinline vboolf16 operator !=(const vint16& a, int b) { return a != vint16(b); }
__forceinline vboolf16 operator !=(int a, const vint16& b) { return vint16(a) != b; }
__forceinline const vboolf16 operator < ( const vint16& a, const vint16& b ) { return _mm512_cmp_epi32_mask(a,b,_MM_CMPINT_LT); }
__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 operator < (const vint16& a, const vint16& b) { return _mm512_cmp_epi32_mask(a,b,_MM_CMPINT_LT); }
__forceinline vboolf16 operator < (const vint16& a, int b) { return a < vint16(b); }
__forceinline vboolf16 operator < (int a, const vint16& b) { return vint16(a) < b; }
__forceinline const vboolf16 operator >=( const vint16& a, const vint16& b ) { return _mm512_cmp_epi32_mask(a,b,_MM_CMPINT_GE); }
__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 operator >=(const vint16& a, const vint16& b) { return _mm512_cmp_epi32_mask(a,b,_MM_CMPINT_GE); }
__forceinline vboolf16 operator >=(const vint16& a, int b) { return a >= vint16(b); }
__forceinline vboolf16 operator >=(int a, const vint16& b) { return vint16(a) >= b; }
__forceinline const vboolf16 operator > ( const vint16& a, const vint16& b ) { return _mm512_cmp_epi32_mask(a,b,_MM_CMPINT_GT); }
__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 operator > (const vint16& a, const vint16& b) { return _mm512_cmp_epi32_mask(a,b,_MM_CMPINT_GT); }
__forceinline vboolf16 operator > (const vint16& a, int b) { return a > vint16(b); }
__forceinline vboolf16 operator > (int a, const vint16& b) { return vint16(a) > b; }
__forceinline const vboolf16 operator <=( const vint16& a, const vint16& b ) { return _mm512_cmp_epi32_mask(a,b,_MM_CMPINT_LE); }
__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 operator <=(const vint16& a, const vint16& b) { return _mm512_cmp_epi32_mask(a,b,_MM_CMPINT_LE); }
__forceinline vboolf16 operator <=(const vint16& a, int b) { return a <= vint16(b); }
__forceinline vboolf16 operator <=(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); }
@@ -285,7 +316,7 @@ namespace embree
__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); }
__forceinline const vint16 select( const vboolf16& m, const vint16& t, const vint16& f ) {
__forceinline vint16 select(const vboolf16& m, const vint16& t, const vint16& f) {
return _mm512_mask_or_epi32(f,m,t,t);
}
@@ -305,41 +336,39 @@ namespace embree
// Movement/Shifting/Shuffling Functions
////////////////////////////////////////////////////////////////////////////////
__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); }
__forceinline vint16 unpacklo(const vint16& a, const vint16& b) { return _mm512_unpacklo_epi32(a, b); }
__forceinline vint16 unpackhi(const vint16& a, const vint16& b) { return _mm512_unpackhi_epi32(a, b); }
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)));
template<int i>
__forceinline vint16 shuffle(const vint16& v) {
return _mm512_castps_si512(_mm512_permute_ps(_mm512_castsi512_ps(v), _MM_SHUFFLE(i, i, i, i)));
}
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)));
template<int i0, int i1, int i2, int i3>
__forceinline vint16 shuffle(const vint16& v) {
return _mm512_castps_si512(_mm512_permute_ps(_mm512_castsi512_ps(v), _MM_SHUFFLE(i3, i2, i1, i0)));
}
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 shuffle4(const vint16& v) {
return _mm512_castps_si512(_mm512_shuffle_f32x4(_mm512_castsi512_ps(v), _mm512_castsi512_ps(v), _MM_SHUFFLE(i, i, i, i)));
}
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)));
template<int i0, int i1, int i2, int i3>
__forceinline vint16 shuffle4(const vint16& v) {
return _mm512_castps_si512(_mm512_shuffle_f32x4(_mm512_castsi512_ps(v), _mm512_castsi512_ps(v), _MM_SHUFFLE(i3, i2, i1, i0)));
}
template<int i>
__forceinline vint16 align_shift_right(const vint16& a, const vint16& b)
{
return _mm512_alignr_epi32(a,b,i);
__forceinline vint16 align_shift_right(const vint16& a, const vint16& b) {
return _mm512_alignr_epi32(a, b, i);
};
__forceinline int toScalar(const vint16& a)
{
return _mm_cvtsi128_si32(_mm512_castsi512_si128(a));
__forceinline int toScalar(const vint16& v) {
return _mm_cvtsi128_si32(_mm512_castsi512_si128(v));
}
template<int i> __forceinline const vint16 insert4(const vint16& a, const vint4& b) { return _mm512_inserti32x4(a, b, i); }
template<int i> __forceinline 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));
@@ -366,15 +395,15 @@ namespace embree
/// 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_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_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); }
@@ -401,36 +430,16 @@ namespace embree
/// Memory load and store operations
////////////////////////////////////////////////////////////////////////////////
template<int scale = 4>
__forceinline vint16 gather16i(const vboolf16& mask, const int *const ptr, const vint16& index) {
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) {
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) {
_mm512_mask_i32scatter_epi32((int*)ptr,mask,index,v,scale);
}
__forceinline vint16 conflict16i(const vint16& index)
__forceinline vint16 conflict(const vint16& index)
{
return _mm512_conflict_epi32(index);
}
__forceinline vint16 conflict16i(const vboolf16& mask, vint16& dest, const vint16& index)
__forceinline vint16 conflict(const vboolf16& mask, vint16& dest, const vint16& index)
{
return _mm512_mask_conflict_epi32(dest,mask,index);
}
__forceinline void compactustore16i_low(const vboolf16 mask, void *addr, const vint16& reg) {
_mm512_mask_compressstoreu_epi32(addr,mask,reg);
}
__forceinline vint16 convert_uint32_t(const __m512& f) {
return _mm512_cvtps_epu32(f);
}
@@ -467,10 +476,10 @@ 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(const void* base_addr, const vbool16& mask, const vint16& offset)
{
#if defined(__AVX512PF__)
_mm512_mask_prefetch_i64gather_pd(offset,mask,base_addr,scale,hint);
_mm512_mask_prefetch_i64gather_pd(offset, mask, base_addr, scale, hint);
#endif
}
@@ -478,7 +487,7 @@ namespace embree
/// Output Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline std::ostream& operator<<(std::ostream& cout, const vint16& v)
__forceinline std::ostream& operator <<(std::ostream& cout, const vint16& v)
{
cout << "<" << v[0];
for (int i=1; i<16; i++) cout << ", " << v[i];
+190 -143
View File
@@ -35,83 +35,86 @@ namespace embree
/// Constructors, Assignment & Cast Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline vint ( ) {}
__forceinline vint ( const vint4& a ) { v = a.v; }
__forceinline vint4& operator=( const vint4& a ) { v = a.v; return *this; }
__forceinline vint() {}
__forceinline vint(const vint4& a) { v = a.v; }
__forceinline vint4& operator =(const vint4& a) { v = a.v; return *this; }
__forceinline vint( const __m128i a ) : v(a) {}
__forceinline operator const __m128i&( void ) const { return v; }
__forceinline operator __m128i&( void ) { return v; }
__forceinline vint(__m128i a) : v(a) {}
__forceinline operator const __m128i&() const { return v; }
__forceinline operator __m128i&() { return v; }
__forceinline vint(int a) : v(_mm_set1_epi32(a)) {}
__forceinline vint(int a, int b, int c, int d) : v(_mm_set_epi32(d, c, b, a)) {}
__forceinline vint( const int& a ) : v(_mm_shuffle_epi32(_mm_castps_si128(_mm_load_ss((float*)&a)), _MM_SHUFFLE(0, 0, 0, 0))) {}
__forceinline vint( const uint32_t& a ) : v(_mm_shuffle_epi32(_mm_castps_si128(_mm_load_ss((float*)&a)), _MM_SHUFFLE(0, 0, 0, 0))) {}
#if defined(__X86_64__)
__forceinline vint( const size_t a ) : v(_mm_set1_epi32((int)a)) {}
#endif
__forceinline vint( int a, int b, int c, int d) : v(_mm_set_epi32(d, c, b, a)) {}
__forceinline explicit vint( const __m128 a ) : v(_mm_cvtps_epi32(a)) {}
__forceinline explicit vint(__m128 a) : v(_mm_cvtps_epi32(a)) {}
#if defined(__AVX512VL__)
__forceinline explicit vint( const vboolf4 &a ) : v(_mm_movm_epi32(a)) {}
__forceinline explicit vint(const vboolf4& a) : v(_mm_movm_epi32(a)) {}
#else
__forceinline explicit vint( const vboolf4 &a ) : v(_mm_castps_si128((__m128)a)) {}
__forceinline explicit vint(const vboolf4& a) : v(_mm_castps_si128((__m128)a)) {}
#endif
////////////////////////////////////////////////////////////////////////////////
/// Constants
////////////////////////////////////////////////////////////////////////////////
__forceinline vint( ZeroTy ) : v(_mm_setzero_si128()) {}
__forceinline vint( OneTy ) : v(_mm_set_epi32(1, 1, 1, 1)) {}
__forceinline vint( PosInfTy ) : v(_mm_set_epi32(pos_inf, pos_inf, pos_inf, pos_inf)) {}
__forceinline vint( NegInfTy ) : v(_mm_set_epi32(neg_inf, neg_inf, neg_inf, neg_inf)) {}
__forceinline vint( StepTy ) : v(_mm_set_epi32(3, 2, 1, 0)) {}
__forceinline vint( TrueTy ) { v = _mm_cmpeq_epi32(v,v); }
__forceinline vint(ZeroTy) : v(_mm_setzero_si128()) {}
__forceinline vint(OneTy) : v(_mm_set_epi32(1, 1, 1, 1)) {}
__forceinline vint(PosInfTy) : v(_mm_set_epi32(pos_inf, pos_inf, pos_inf, pos_inf)) {}
__forceinline vint(NegInfTy) : v(_mm_set_epi32(neg_inf, neg_inf, neg_inf, neg_inf)) {}
__forceinline vint(StepTy) : v(_mm_set_epi32(3, 2, 1, 0)) {}
__forceinline vint(TrueTy) { v = _mm_cmpeq_epi32(v,v); }
__forceinline vint(UndefinedTy) : v(_mm_castps_si128(_mm_undefined_ps())) {}
////////////////////////////////////////////////////////////////////////////////
/// Loads and Stores
////////////////////////////////////////////////////////////////////////////////
static __forceinline vint4 load ( const void* const a ) { return _mm_load_si128((__m128i*)a); }
static __forceinline vint4 loadu( const void* const a ) { return _mm_loadu_si128((__m128i*)a); }
static __forceinline vint4 load (const void* a) { return _mm_load_si128((__m128i*)a); }
static __forceinline vint4 loadu(const void* a) { return _mm_loadu_si128((__m128i*)a); }
static __forceinline void store (void* ptr, const vint4& v) { _mm_store_si128((__m128i*)ptr,v); }
static __forceinline void storeu(void* ptr, const vint4& v) { _mm_storeu_si128((__m128i*)ptr,v); }
#if defined(__AVX512VL__)
static __forceinline vint4 load ( const vboolf4& mask, const void* const ptr ) { return _mm_mask_load_epi32 (_mm_setzero_si128(),mask,ptr); }
static __forceinline vint4 loadu( const vboolf4& mask, const void* const ptr ) { return _mm_mask_loadu_epi32(_mm_setzero_si128(),mask,ptr); }
static __forceinline void store ( const vboolf4& mask, void* ptr, const vint4& v ) { _mm_mask_store_epi32 (ptr,mask,v); }
static __forceinline void storeu( const vboolf4& mask, void* ptr, const vint4& v ) { _mm_mask_storeu_epi32(ptr,mask,v); }
static __forceinline vint4 compact(const vboolf4& mask, vint4 &v) {
return _mm_mask_compress_epi32(v, mask, v);
}
static __forceinline vint4 compact(const vboolf4& mask, vint4 &a, const vint4& b) {
return _mm_mask_compress_epi32(a, mask, b);
}
static __forceinline vint4 load (const vboolf4& mask, const void* ptr) { return _mm_mask_load_epi32 (_mm_setzero_si128(),mask,ptr); }
static __forceinline vint4 loadu(const vboolf4& mask, const void* ptr) { return _mm_mask_loadu_epi32(_mm_setzero_si128(),mask,ptr); }
static __forceinline void store (const vboolf4& mask, void* ptr, const vint4& v) { _mm_mask_store_epi32 (ptr,mask,v); }
static __forceinline void storeu(const vboolf4& mask, void* ptr, const vint4& v) { _mm_mask_storeu_epi32(ptr,mask,v); }
#elif defined(__AVX__)
static __forceinline vint4 load ( const vbool4& mask, const void* const a ) { return _mm_castps_si128(_mm_maskload_ps((float*)a,mask)); }
static __forceinline vint4 loadu( const vbool4& mask, const void* const a ) { return _mm_castps_si128(_mm_maskload_ps((float*)a,mask)); }
static __forceinline vint4 load (const vbool4& mask, const void* a) { return _mm_castps_si128(_mm_maskload_ps((float*)a,mask)); }
static __forceinline vint4 loadu(const vbool4& mask, const void* a) { return _mm_castps_si128(_mm_maskload_ps((float*)a,mask)); }
static __forceinline void store ( const vboolf4& mask, void* ptr, const vint4& i ) { _mm_maskstore_ps((float*)ptr,(__m128i)mask,_mm_castsi128_ps(i)); }
static __forceinline void storeu( const vboolf4& mask, void* ptr, const vint4& i ) { _mm_maskstore_ps((float*)ptr,(__m128i)mask,_mm_castsi128_ps(i)); }
static __forceinline void store (const vboolf4& mask, void* ptr, const vint4& i) { _mm_maskstore_ps((float*)ptr,(__m128i)mask,_mm_castsi128_ps(i)); }
static __forceinline void storeu(const vboolf4& mask, void* ptr, const vint4& i) { _mm_maskstore_ps((float*)ptr,(__m128i)mask,_mm_castsi128_ps(i)); }
#else
static __forceinline vint4 load ( const vbool4& mask, const void* const a ) { return _mm_and_si128(_mm_load_si128 ((__m128i*)a),mask); }
static __forceinline vint4 loadu( const vbool4& mask, const void* const a ) { return _mm_and_si128(_mm_loadu_si128((__m128i*)a),mask); }
static __forceinline vint4 load (const vbool4& mask, const void* a) { return _mm_and_si128(_mm_load_si128 ((__m128i*)a),mask); }
static __forceinline vint4 loadu(const vbool4& mask, const void* a) { return _mm_and_si128(_mm_loadu_si128((__m128i*)a),mask); }
static __forceinline void store ( const vboolf4& mask, void* ptr, const vint4& i ) { store (ptr,select(mask,i,load (ptr))); }
static __forceinline void storeu( const vboolf4& mask, void* ptr, const vint4& i ) { storeu(ptr,select(mask,i,loadu(ptr))); }
static __forceinline void store (const vboolf4& mask, void* ptr, const vint4& i) { store (ptr,select(mask,i,load (ptr))); }
static __forceinline void storeu(const vboolf4& mask, void* ptr, const vint4& i) { storeu(ptr,select(mask,i,loadu(ptr))); }
#endif
#if defined(__SSE4_1__)
static __forceinline vint4 load( const unsigned char* const ptr ) {
static __forceinline vint4 load(const unsigned char* ptr) {
return _mm_cvtepu8_epi32(_mm_load_si128((__m128i*)ptr));
}
static __forceinline vint4 loadu( const unsigned char* const ptr ) {
static __forceinline vint4 loadu(const unsigned char* ptr) {
return _mm_cvtepu8_epi32(_mm_loadu_si128((__m128i*)ptr));
}
#endif
static __forceinline vint4 load(const unsigned short* const ptr) {
static __forceinline vint4 load(const unsigned short* ptr) {
#if defined (__SSE4_1__)
return _mm_cvtepu16_epi32(_mm_loadu_si128((__m128i*)ptr));
#else
@@ -119,7 +122,7 @@ namespace embree
#endif
}
static __forceinline void store_uchar( unsigned char* const ptr, const vint4& v ) {
static __forceinline void store(unsigned char* ptr, const vint4& v) {
#if defined(__SSE4_1__)
__m128i x = v;
x = _mm_packus_epi32(x, x);
@@ -131,12 +134,12 @@ namespace embree
#endif
}
static __forceinline void store_ushort( unsigned short* const ptr, const vint4& v ) {
static __forceinline void store(unsigned short* 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) {
static __forceinline vint4 load_nt(void* ptr) {
#if defined(__SSE4_1__)
return _mm_stream_load_si128((__m128i*)ptr);
#else
@@ -146,24 +149,53 @@ namespace embree
static __forceinline void store_nt(void* ptr, const vint4& v) {
#if defined(__SSE4_1__)
_mm_stream_ps((float*)ptr,_mm_castsi128_ps(v));
_mm_stream_ps((float*)ptr, _mm_castsi128_ps(v));
#else
_mm_store_si128((__m128i*)ptr,v);
#endif
}
template<int scale = 4>
static __forceinline vint4 gather(const int* ptr, const vint4& index) {
#if defined(__AVX2__)
return _mm_i32gather_epi32(ptr, index, scale);
#else
return vint4(
*(int*)(((char*)ptr)+scale*index[0]),
*(int*)(((char*)ptr)+scale*index[1]),
*(int*)(((char*)ptr)+scale*index[2]),
*(int*)(((char*)ptr)+scale*index[3]));
#endif
}
template<int scale = 4>
static __forceinline vint4 gather(const vboolf4& mask, const int* ptr, const vint4& index) {
vint4 r = zero;
#if defined(__AVX512VL__)
return _mm_mmask_i32gather_epi32(r, mask, index, ptr, scale);
#elif defined(__AVX2__)
return _mm_mask_i32gather_epi32(r, ptr, index, mask, scale);
#else
if (likely(mask[0])) r[0] = *(int*)(((char*)ptr)+scale*index[0]);
if (likely(mask[1])) r[1] = *(int*)(((char*)ptr)+scale*index[1]);
if (likely(mask[2])) r[2] = *(int*)(((char*)ptr)+scale*index[2]);
if (likely(mask[3])) r[3] = *(int*)(((char*)ptr)+scale*index[3]);
return r;
#endif
}
#if defined(__x86_64__)
static __forceinline vint4 broadcast64(const long long &a) { return _mm_set1_epi64x(a); }
static __forceinline vint4 broadcast64(long long a) { return _mm_set1_epi64x(a); }
#endif
////////////////////////////////////////////////////////////////////////////////
/// Array Access
////////////////////////////////////////////////////////////////////////////////
__forceinline const int& operator []( const size_t index ) const { assert(index < 4); return i[index]; }
__forceinline int& operator []( const size_t index ) { assert(index < 4); return i[index]; }
__forceinline const int& operator [](size_t index) const { assert(index < 4); return i[index]; }
__forceinline int& operator [](size_t index) { assert(index < 4); return i[index]; }
friend __forceinline const vint4 select( const vboolf4& m, const vint4& t, const vint4& f ) {
friend __forceinline vint4 select(const vboolf4& m, const vint4& t, const vint4& f) {
#if defined(__AVX512VL__)
return _mm_mask_blend_epi32(m, f, t);
#elif defined(__SSE4_1__)
@@ -178,113 +210,113 @@ namespace embree
/// Unary Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline const vint4 asInt ( const __m128& a ) { return _mm_castps_si128(a); }
__forceinline const vint4 operator +( const vint4& a ) { return a; }
__forceinline const vint4 operator -( const vint4& a ) { return _mm_sub_epi32(_mm_setzero_si128(), a.v); }
__forceinline vint4 asInt(const __m128& a) { return _mm_castps_si128(a); }
__forceinline vint4 operator +(const vint4& a) { return a; }
__forceinline vint4 operator -(const vint4& a) { return _mm_sub_epi32(_mm_setzero_si128(), a); }
#if defined(__SSSE3__)
__forceinline const vint4 abs ( const vint4& a ) { return _mm_abs_epi32(a.v); }
__forceinline vint4 abs(const vint4& a) { return _mm_abs_epi32(a); }
#endif
////////////////////////////////////////////////////////////////////////////////
/// Binary Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline const vint4 operator +( const vint4& a, const vint4& b ) { return _mm_add_epi32(a.v, b.v); }
__forceinline const vint4 operator +( const vint4& a, const int& b ) { return a + vint4(b); }
__forceinline const vint4 operator +( const int& a, const vint4& b ) { return vint4(a) + b; }
__forceinline vint4 operator +(const vint4& a, const vint4& b) { return _mm_add_epi32(a, b); }
__forceinline vint4 operator +(const vint4& a, int b) { return a + vint4(b); }
__forceinline vint4 operator +(int a, const vint4& b) { return vint4(a) + b; }
__forceinline const vint4 operator -( const vint4& a, const vint4& b ) { return _mm_sub_epi32(a.v, b.v); }
__forceinline const vint4 operator -( const vint4& a, const int& b ) { return a - vint4(b); }
__forceinline const vint4 operator -( const int& a, const vint4& b ) { return vint4(a) - b; }
__forceinline vint4 operator -(const vint4& a, const vint4& b) { return _mm_sub_epi32(a, b); }
__forceinline vint4 operator -(const vint4& a, int b) { return a - vint4(b); }
__forceinline vint4 operator -(int a, const vint4& b) { return vint4(a) - b; }
#if defined(__SSE4_1__)
__forceinline const vint4 operator *( const vint4& a, const vint4& b ) { return _mm_mullo_epi32(a.v, b.v); }
__forceinline vint4 operator *(const vint4& a, const vint4& b) { return _mm_mullo_epi32(a, b); }
#else
__forceinline const vint4 operator *( const vint4& a, const vint4& b ) { return vint4(a[0]*b[0],a[1]*b[1],a[2]*b[2],a[3]*b[3]); }
__forceinline vint4 operator *(const vint4& a, const vint4& b) { return vint4(a[0]*b[0],a[1]*b[1],a[2]*b[2],a[3]*b[3]); }
#endif
__forceinline const vint4 operator *( const vint4& a, const int& b ) { return a * vint4(b); }
__forceinline const vint4 operator *( const int& a, const vint4& b ) { return vint4(a) * b; }
__forceinline vint4 operator *(const vint4& a, int b) { return a * vint4(b); }
__forceinline vint4 operator *(int a, const vint4& b) { return vint4(a) * b; }
__forceinline const vint4 operator &( const vint4& a, const vint4& b ) { return _mm_and_si128(a.v, b.v); }
__forceinline const vint4 operator &( const vint4& a, const int& b ) { return a & vint4(b); }
__forceinline const vint4 operator &( const int& a, const vint4& b ) { return vint4(a) & b; }
__forceinline vint4 operator &(const vint4& a, const vint4& b) { return _mm_and_si128(a, b); }
__forceinline vint4 operator &(const vint4& a, int b) { return a & vint4(b); }
__forceinline vint4 operator &(int a, const vint4& b) { return vint4(a) & b; }
__forceinline const vint4 operator |( const vint4& a, const vint4& b ) { return _mm_or_si128(a.v, b.v); }
__forceinline const vint4 operator |( const vint4& a, const int& b ) { return a | vint4(b); }
__forceinline const vint4 operator |( const int& a, const vint4& b ) { return vint4(a) | b; }
__forceinline vint4 operator |(const vint4& a, const vint4& b) { return _mm_or_si128(a, b); }
__forceinline vint4 operator |(const vint4& a, int b) { return a | vint4(b); }
__forceinline vint4 operator |(int a, const vint4& b) { return vint4(a) | b; }
__forceinline const vint4 operator ^( const vint4& a, const vint4& b ) { return _mm_xor_si128(a.v, b.v); }
__forceinline const vint4 operator ^( const vint4& a, const int& b ) { return a ^ vint4(b); }
__forceinline const vint4 operator ^( const int& a, const vint4& b ) { return vint4(a) ^ b; }
__forceinline vint4 operator ^(const vint4& a, const vint4& b) { return _mm_xor_si128(a, b); }
__forceinline vint4 operator ^(const vint4& a, int b) { return a ^ vint4(b); }
__forceinline vint4 operator ^(int a, const vint4& b) { return vint4(a) ^ b; }
__forceinline const vint4 operator <<( const vint4& a, const int& n ) { return _mm_slli_epi32(a.v, n); }
__forceinline const vint4 operator >>( const vint4& a, const int& n ) { return _mm_srai_epi32(a.v, n); }
__forceinline vint4 operator <<(const vint4& a, int n) { return _mm_slli_epi32(a, n); }
__forceinline vint4 operator >>(const vint4& a, int n) { return _mm_srai_epi32(a, n); }
__forceinline const vint4 sll ( const vint4& a, const int& b ) { return _mm_slli_epi32(a.v, b); }
__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); }
__forceinline vint4 sll (const vint4& a, int b) { return _mm_slli_epi32(a, b); }
__forceinline vint4 sra (const vint4& a, int b) { return _mm_srai_epi32(a, b); }
__forceinline vint4 srl (const vint4& a, int b) { return _mm_srli_epi32(a, b); }
////////////////////////////////////////////////////////////////////////////////
/// Assignment Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline vint4& operator +=( vint4& a, const vint4& b ) { return a = a + b; }
__forceinline vint4& operator +=( vint4& a, const int& b ) { return a = a + b; }
__forceinline vint4& operator +=(vint4& a, const vint4& b) { return a = a + b; }
__forceinline vint4& operator +=(vint4& a, int b) { return a = a + b; }
__forceinline vint4& operator -=( vint4& a, const vint4& b ) { return a = a - b; }
__forceinline vint4& operator -=( vint4& a, const int& b ) { return a = a - b; }
__forceinline vint4& operator -=(vint4& a, const vint4& b) { return a = a - b; }
__forceinline vint4& operator -=(vint4& a, int b) { return a = a - b; }
#if defined(__SSE4_1__)
__forceinline vint4& operator *=( vint4& a, const vint4& b ) { return a = a * b; }
__forceinline vint4& operator *=( vint4& a, const int& b ) { return a = a * b; }
__forceinline vint4& operator *=(vint4& a, const vint4& b) { return a = a * b; }
__forceinline vint4& operator *=(vint4& a, int b) { return a = a * b; }
#endif
__forceinline vint4& operator &=( vint4& a, const vint4& b ) { return a = a & b; }
__forceinline vint4& operator &=( vint4& a, const int& b ) { return a = a & b; }
__forceinline vint4& operator &=(vint4& a, const vint4& b) { return a = a & b; }
__forceinline vint4& operator &=(vint4& a, int b) { return a = a & b; }
__forceinline vint4& operator |=( vint4& a, const vint4& b ) { return a = a | b; }
__forceinline vint4& operator |=( vint4& a, const int& b ) { return a = a | b; }
__forceinline vint4& operator |=(vint4& a, const vint4& b) { return a = a | b; }
__forceinline vint4& operator |=(vint4& a, int b) { return a = a | b; }
__forceinline vint4& operator <<=( vint4& a, const int& b ) { return a = a << b; }
__forceinline vint4& operator >>=( vint4& a, const int& b ) { return a = a >> b; }
__forceinline vint4& operator <<=(vint4& a, int b) { return a = a << b; }
__forceinline vint4& operator >>=(vint4& a, int b) { return a = a >> b; }
////////////////////////////////////////////////////////////////////////////////
/// Comparison Operators + Select
////////////////////////////////////////////////////////////////////////////////
#if defined(__AVX512VL__)
__forceinline const vboolf4 operator ==( const vint4& a, const vint4& b ) { return _mm_cmp_epi32_mask(a,b,_MM_CMPINT_EQ); }
__forceinline const vboolf4 operator !=( const vint4& a, const vint4& b ) { return _mm_cmp_epi32_mask(a,b,_MM_CMPINT_NE); }
__forceinline const vboolf4 operator < ( const vint4& a, const vint4& b ) { return _mm_cmp_epi32_mask(a,b,_MM_CMPINT_LT); }
__forceinline const vboolf4 operator >=( const vint4& a, const vint4& b ) { return _mm_cmp_epi32_mask(a,b,_MM_CMPINT_GE); }
__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); }
__forceinline vboolf4 operator ==(const vint4& a, const vint4& b) { return _mm_cmp_epi32_mask(a,b,_MM_CMPINT_EQ); }
__forceinline vboolf4 operator !=(const vint4& a, const vint4& b) { return _mm_cmp_epi32_mask(a,b,_MM_CMPINT_NE); }
__forceinline vboolf4 operator < (const vint4& a, const vint4& b) { return _mm_cmp_epi32_mask(a,b,_MM_CMPINT_LT); }
__forceinline vboolf4 operator >=(const vint4& a, const vint4& b) { return _mm_cmp_epi32_mask(a,b,_MM_CMPINT_GE); }
__forceinline vboolf4 operator > (const vint4& a, const vint4& b) { return _mm_cmp_epi32_mask(a,b,_MM_CMPINT_GT); }
__forceinline 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 !(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 !(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 !(a > b); }
__forceinline vboolf4 operator ==(const vint4& a, const vint4& b) { return _mm_castsi128_ps(_mm_cmpeq_epi32(a, b)); }
__forceinline vboolf4 operator !=(const vint4& a, const vint4& b) { return !(a == b); }
__forceinline vboolf4 operator < (const vint4& a, const vint4& b) { return _mm_castsi128_ps(_mm_cmplt_epi32(a, b)); }
__forceinline vboolf4 operator >=(const vint4& a, const vint4& b) { return !(a < b); }
__forceinline vboolf4 operator > (const vint4& a, const vint4& b) { return _mm_castsi128_ps(_mm_cmpgt_epi32(a, b)); }
__forceinline vboolf4 operator <=(const vint4& a, const vint4& b) { return !(a > b); }
#endif
__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 operator ==(const vint4& a, int b) { return a == vint4(b); }
__forceinline vboolf4 operator ==(int a, const vint4& b) { return vint4(a) == b; }
__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 operator !=(const vint4& a, int b) { return a != vint4(b); }
__forceinline vboolf4 operator !=(int a, const vint4& b) { return vint4(a) != b; }
__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 operator < (const vint4& a, int b) { return a < vint4(b); }
__forceinline vboolf4 operator < (int a, const vint4& b) { return vint4(a) < b; }
__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 operator >=(const vint4& a, int b) { return a >= vint4(b); }
__forceinline vboolf4 operator >=(int a, const vint4& b) { return vint4(a) >= b; }
__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 operator > (const vint4& a, int b) { return a > vint4(b); }
__forceinline vboolf4 operator > (int a, const vint4& b) { return vint4(a) > b; }
__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 operator <=(const vint4& a, int b) { return a <= vint4(b); }
__forceinline vboolf4 operator <=(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; }
@@ -310,7 +342,7 @@ namespace embree
#endif
template<int mask>
__forceinline const vint4 select(const vint4& t, const vint4& f) {
__forceinline 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
@@ -319,68 +351,83 @@ namespace embree
}
#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 vint4 min(const vint4& a, const vint4& b) { return _mm_min_epi32(a, b); }
__forceinline vint4 max(const vint4& a, const vint4& b) { return _mm_max_epi32(a, b); }
__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); }
__forceinline vint4 umin(const vint4& a, const vint4& b) { return _mm_min_epu32(a, b); }
__forceinline vint4 umax(const vint4& a, const vint4& b) { return _mm_max_epu32(a, b); }
#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 vint4 min(const vint4& a, const vint4& b) { return select(a < b,a,b); }
__forceinline vint4 max(const vint4& a, const vint4& b) { return select(a < b,b,a); }
#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); }
__forceinline vint4 min(const vint4& a, int b) { return min(a,vint4(b)); }
__forceinline vint4 min(int a, const vint4& b) { return min(vint4(a),b); }
__forceinline vint4 max(const vint4& a, int b) { return max(a,vint4(b)); }
__forceinline vint4 max(int a, const vint4& b) { return max(vint4(a),b); }
////////////////////////////////////////////////////////////////////////////////
// Movement/Shifting/Shuffling Functions
////////////////////////////////////////////////////////////////////////////////
__forceinline vint4 unpacklo( const vint4& a, const vint4& b ) { return _mm_castps_si128(_mm_unpacklo_ps(_mm_castsi128_ps(a.v), _mm_castsi128_ps(b.v))); }
__forceinline vint4 unpackhi( const vint4& a, const vint4& b ) { return _mm_castps_si128(_mm_unpackhi_ps(_mm_castsi128_ps(a.v), _mm_castsi128_ps(b.v))); }
__forceinline vint4 unpacklo(const vint4& a, const vint4& b) { return _mm_castps_si128(_mm_unpacklo_ps(_mm_castsi128_ps(a), _mm_castsi128_ps(b))); }
__forceinline vint4 unpackhi(const vint4& a, const vint4& b) { return _mm_castps_si128(_mm_unpackhi_ps(_mm_castsi128_ps(a), _mm_castsi128_ps(b))); }
template<size_t i0, size_t i1, size_t i2, size_t i3> __forceinline const vint4 shuffle( const vint4& a ) {
return _mm_shuffle_epi32(a, _MM_SHUFFLE(i3, i2, i1, i0));
template<int i0, int i1, int i2, int i3>
__forceinline vint4 shuffle(const vint4& v) {
return _mm_shuffle_epi32(v, _MM_SHUFFLE(i3, i2, i1, i0));
}
template<size_t i0, size_t i1, size_t i2, size_t i3> __forceinline const vint4 shuffle( const vint4& a, const vint4& b ) {
template<int i0, int i1, int i2, int i3>
__forceinline vint4 shuffle(const vint4& a, const vint4& b) {
return _mm_castps_si128(_mm_shuffle_ps(_mm_castsi128_ps(a), _mm_castsi128_ps(b), _MM_SHUFFLE(i3, i2, i1, i0)));
}
#if defined(__SSE3__)
template<> __forceinline const vint4 shuffle<0, 0, 2, 2>( const vint4& a ) { return _mm_castps_si128(_mm_moveldup_ps(_mm_castsi128_ps(a))); }
template<> __forceinline const vint4 shuffle<1, 1, 3, 3>( const vint4& a ) { return _mm_castps_si128(_mm_movehdup_ps(_mm_castsi128_ps(a))); }
template<> __forceinline const vint4 shuffle<0, 1, 0, 1>( const vint4& a ) { return _mm_castpd_si128(_mm_movedup_pd (_mm_castsi128_pd(a))); }
template<> __forceinline vint4 shuffle<0, 0, 2, 2>(const vint4& v) { return _mm_castps_si128(_mm_moveldup_ps(_mm_castsi128_ps(v))); }
template<> __forceinline vint4 shuffle<1, 1, 3, 3>(const vint4& v) { return _mm_castps_si128(_mm_movehdup_ps(_mm_castsi128_ps(v))); }
template<> __forceinline vint4 shuffle<0, 1, 0, 1>(const vint4& v) { return _mm_castpd_si128(_mm_movedup_pd (_mm_castsi128_pd(v))); }
#endif
template<size_t i0> __forceinline const vint4 shuffle( const vint4& b ) {
return shuffle<i0,i0,i0,i0>(b);
template<int i>
__forceinline vint4 shuffle(const vint4& v) {
return shuffle<i,i,i,i>(v);
}
#if defined(__SSE4_1__)
template<size_t src> __forceinline int extract( const vint4& b ) { return _mm_extract_epi32(b, src); }
template<size_t dst> __forceinline const vint4 insert( const vint4& a, const int b ) { return _mm_insert_epi32(a, b, dst); }
template<int src> __forceinline int extract(const vint4& b) { return _mm_extract_epi32(b, src); }
template<int dst> __forceinline vint4 insert(const vint4& a, const int b) { return _mm_insert_epi32(a, b, dst); }
#else
template<size_t src> __forceinline int extract( const vint4& b ) { return b[src]; }
template<size_t dst> __forceinline const vint4 insert( const vint4& a, const int b ) { vint4 c = a; c[dst] = b; return c; }
template<int src> __forceinline int extract(const vint4& b) { return b[src&3]; }
template<int dst> __forceinline vint4 insert(const vint4& a, int b) { vint4 c = a; c[dst&3] = b; return c; }
#endif
template<> __forceinline int extract<0>( const vint4& b ) { return _mm_cvtsi128_si32(b); }
template<> __forceinline int extract<0>(const vint4& b) { return _mm_cvtsi128_si32(b); }
__forceinline int toScalar(const vint4& a) { return _mm_cvtsi128_si32(a); }
__forceinline int toScalar(const vint4& v) { return _mm_cvtsi128_si32(v); }
#if defined(__AVX512VL__)
__forceinline vint4 permute(const vint4 &a, const vint4 &index) {
return _mm_castps_si128(_mm_permutevar_ps(_mm_castsi128_ps(a),index));
}
template<int i>
__forceinline vint4 align_shift_right(const vint4& a, const vint4& b) {
return _mm_alignr_epi32(a, b, i);
}
#endif
////////////////////////////////////////////////////////////////////////////////
/// Reductions
////////////////////////////////////////////////////////////////////////////////
#if defined(__SSE4_1__)
__forceinline const vint4 vreduce_min(const vint4& v) { vint4 h = min(shuffle<1,0,3,2>(v),v); return min(shuffle<2,3,0,1>(h),h); }
__forceinline const vint4 vreduce_max(const vint4& v) { vint4 h = max(shuffle<1,0,3,2>(v),v); return max(shuffle<2,3,0,1>(h),h); }
__forceinline const vint4 vreduce_add(const vint4& v) { vint4 h = shuffle<1,0,3,2>(v) + v ; return shuffle<2,3,0,1>(h) + h ; }
__forceinline vint4 vreduce_min(const vint4& v) { vint4 h = min(shuffle<1,0,3,2>(v),v); return min(shuffle<2,3,0,1>(h),h); }
__forceinline vint4 vreduce_max(const vint4& v) { vint4 h = max(shuffle<1,0,3,2>(v),v); return max(shuffle<2,3,0,1>(h),h); }
__forceinline vint4 vreduce_add(const vint4& v) { vint4 h = shuffle<1,0,3,2>(v) + v ; return shuffle<2,3,0,1>(h) + h ; }
__forceinline int reduce_min(const vint4& v) { return toScalar(vreduce_min(v)); }
__forceinline int reduce_max(const vint4& v) { return toScalar(vreduce_max(v)); }
@@ -486,7 +533,7 @@ namespace embree
/// Output Operators
////////////////////////////////////////////////////////////////////////////////
inline std::ostream& operator<<(std::ostream& cout, const vint4& a) {
inline std::ostream& operator <<(std::ostream& cout, const vint4& a) {
return cout << "<" << a[0] << ", " << a[1] << ", " << a[2] << ", " << a[3] << ">";
}
}
+170 -137
View File
@@ -37,214 +37,242 @@ namespace embree
/// Constructors, Assignment & Cast Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline vint ( ) {}
__forceinline vint ( const vint8& a ) { v = a.v; }
__forceinline vint8& operator=( const vint8& a ) { v = a.v; return *this; }
__forceinline vint() {}
__forceinline vint(const vint8& a) { v = a.v; }
__forceinline vint8& operator =(const vint8& a) { v = a.v; return *this; }
__forceinline vint( const __m256i a ) : v(a) {}
__forceinline operator const __m256i&( void ) const { return v; }
__forceinline operator __m256i&( void ) { return v; }
__forceinline vint(__m256i a) : v(a) {}
__forceinline operator const __m256i&() const { return v; }
__forceinline operator __m256i&() { return v; }
__forceinline explicit vint( const vint4& a ) : v(_mm256_insertf128_si256(_mm256_castsi128_si256(a),a,1)) {}
__forceinline vint( const vint4& a, const vint4& b ) : v(_mm256_insertf128_si256(_mm256_castsi128_si256(a),b,1)) {}
__forceinline vint( const __m128i& a, const __m128i& b ) : vl(a), vh(b) {}
__forceinline explicit vint(const vint4& a) : v(_mm256_insertf128_si256(_mm256_castsi128_si256(a),a,1)) {}
__forceinline vint(const vint4& a, const vint4& b) : v(_mm256_insertf128_si256(_mm256_castsi128_si256(a),b,1)) {}
__forceinline vint(const __m128i& a, const __m128i& b) : vl(a), vh(b) {}
__forceinline explicit vint ( const int* const a ) : v(_mm256_castps_si256(_mm256_loadu_ps((const float*)a))) {}
__forceinline vint ( int a ) : v(_mm256_set1_epi32(a)) {}
__forceinline vint ( int a, int b) : v(_mm256_set_epi32(b, a, b, a, b, a, b, a)) {}
__forceinline vint ( int a, int b, int c, int d) : v(_mm256_set_epi32(d, c, b, a, d, c, b, a)) {}
__forceinline vint ( int a, int b, int c, int d, int e, int f, int g, int vh) : v(_mm256_set_epi32(vh, g, f, e, d, c, b, a)) {}
__forceinline explicit vint(const int* a) : v(_mm256_castps_si256(_mm256_loadu_ps((const float*)a))) {}
__forceinline vint(int a) : v(_mm256_set1_epi32(a)) {}
__forceinline vint(int a, int b) : v(_mm256_set_epi32(b, a, b, a, b, a, b, a)) {}
__forceinline vint(int a, int b, int c, int d) : v(_mm256_set_epi32(d, c, b, a, d, c, b, a)) {}
__forceinline vint(int a, int b, int c, int d, int e, int f, int g, int vh) : v(_mm256_set_epi32(vh, g, f, e, d, c, b, a)) {}
__forceinline explicit vint( const __m256 a ) : v(_mm256_cvtps_epi32(a)) {}
__forceinline explicit vint(__m256 a) : v(_mm256_cvtps_epi32(a)) {}
////////////////////////////////////////////////////////////////////////////////
/// Constants
////////////////////////////////////////////////////////////////////////////////
__forceinline vint( ZeroTy ) : v(_mm256_setzero_si256()) {}
__forceinline vint( OneTy ) : v(_mm256_set_epi32(1,1,1,1,1,1,1,1)) {}
__forceinline vint( PosInfTy ) : v(_mm256_set_epi32(pos_inf,pos_inf,pos_inf,pos_inf,pos_inf,pos_inf,pos_inf,pos_inf)) {}
__forceinline vint( NegInfTy ) : v(_mm256_set_epi32(neg_inf,neg_inf,neg_inf,neg_inf,neg_inf,neg_inf,neg_inf,neg_inf)) {}
__forceinline vint( StepTy ) : v(_mm256_set_epi32(7, 6, 5, 4, 3, 2, 1, 0)) {}
__forceinline vint(ZeroTy) : v(_mm256_setzero_si256()) {}
__forceinline vint(OneTy) : v(_mm256_set_epi32(1,1,1,1,1,1,1,1)) {}
__forceinline vint(PosInfTy) : v(_mm256_set_epi32(pos_inf,pos_inf,pos_inf,pos_inf,pos_inf,pos_inf,pos_inf,pos_inf)) {}
__forceinline vint(NegInfTy) : v(_mm256_set_epi32(neg_inf,neg_inf,neg_inf,neg_inf,neg_inf,neg_inf,neg_inf,neg_inf)) {}
__forceinline vint(StepTy) : v(_mm256_set_epi32(7, 6, 5, 4, 3, 2, 1, 0)) {}
__forceinline vint(UndefinedTy) : v(_mm256_undefined_si256()) {}
////////////////////////////////////////////////////////////////////////////////
/// Loads and Stores
////////////////////////////////////////////////////////////////////////////////
static __forceinline vint8 load ( const void* const a) { return _mm256_castps_si256(_mm256_load_ps((float*)a)); }
static __forceinline vint8 loadu( const void* const a) { return _mm256_castps_si256(_mm256_loadu_ps((float*)a)); }
static __forceinline vint8 load (const void* a) { return _mm256_castps_si256(_mm256_load_ps((float*)a)); }
static __forceinline vint8 loadu(const void* a) { return _mm256_castps_si256(_mm256_loadu_ps((float*)a)); }
static __forceinline vint8 load ( const vboolf8& mask, const void* const a ) { return _mm256_castps_si256(_mm256_maskload_ps((float*)a,mask)); }
static __forceinline vint8 loadu( const vboolf8& mask, const void* const a ) { return _mm256_castps_si256(_mm256_maskload_ps((float*)a,mask)); }
static __forceinline vint8 load (const vboolf8& mask, const void* a) { return _mm256_castps_si256(_mm256_maskload_ps((float*)a,mask)); }
static __forceinline vint8 loadu(const vboolf8& mask, const void* a) { return _mm256_castps_si256(_mm256_maskload_ps((float*)a,mask)); }
static __forceinline void store ( void* ptr, const vint8& f ) { _mm256_store_ps((float*)ptr,_mm256_castsi256_ps(f)); }
static __forceinline void storeu( void* ptr, const vint8& f ) { _mm256_storeu_ps((float*)ptr,_mm256_castsi256_ps(f)); }
static __forceinline void store (void* ptr, const vint8& f) { _mm256_store_ps((float*)ptr,_mm256_castsi256_ps(f)); }
static __forceinline void storeu(void* ptr, const vint8& f) { _mm256_storeu_ps((float*)ptr,_mm256_castsi256_ps(f)); }
static __forceinline void store ( const vboolf8& mask, void* ptr, const vint8& f ) { _mm256_maskstore_ps((float*)ptr,(__m256i)mask,_mm256_castsi256_ps(f)); }
static __forceinline void storeu( const vboolf8& mask, void* ptr, const vint8& f ) { _mm256_maskstore_ps((float*)ptr,(__m256i)mask,_mm256_castsi256_ps(f)); }
static __forceinline void store (const vboolf8& mask, void* ptr, const vint8& f) { _mm256_maskstore_ps((float*)ptr,(__m256i)mask,_mm256_castsi256_ps(f)); }
static __forceinline void storeu(const vboolf8& mask, void* ptr, const vint8& f) { _mm256_maskstore_ps((float*)ptr,(__m256i)mask,_mm256_castsi256_ps(f)); }
static __forceinline void store_nt(void* ptr, const vint8& v) {
_mm256_stream_ps((float*)ptr,_mm256_castsi256_ps(v));
}
static __forceinline vint8 load( const unsigned char* const ptr ) {
static __forceinline vint8 load(const unsigned char* ptr) {
vint4 il = vint4::load(ptr+0);
vint4 ih = vint4::load(ptr+4);
return vint8(il,ih);
}
static __forceinline vint8 loadu( const unsigned char* const ptr ) {
static __forceinline vint8 loadu(const unsigned char* ptr) {
vint4 il = vint4::loadu(ptr+0);
vint4 ih = vint4::loadu(ptr+4);
return vint8(il,ih);
}
static __forceinline vint8 load( const unsigned short* const ptr ) {
static __forceinline vint8 load(const unsigned short* 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 ) {
static __forceinline vint8 loadu(const unsigned short* ptr) {
vint4 il = vint4::loadu(ptr+0);
vint4 ih = vint4::loadu(ptr+4);
return vint8(il,ih);
}
static __forceinline void store_uchar( unsigned char* const ptr, const vint8& i ) {
static __forceinline void store(unsigned char* ptr, const vint8& i) {
vint4 il(i.vl);
vint4 ih(i.vh);
vint4::store_uchar(ptr + 0,il);
vint4::store_uchar(ptr + 4,ih);
vint4::store(ptr + 0,il);
vint4::store(ptr + 4,ih);
}
static __forceinline void store_ushort( unsigned short* const ptr, const vint8& v ) {
static __forceinline void store(unsigned short* ptr, const vint8& v) {
for (size_t i=0;i<8;i++)
ptr[i] = (unsigned short)v[i];
}
template<int scale = 4>
static __forceinline vint8 gather(const int* ptr, const vint8& index) {
return vint8(
*(int*)(((char*)ptr)+scale*index[0]),
*(int*)(((char*)ptr)+scale*index[1]),
*(int*)(((char*)ptr)+scale*index[2]),
*(int*)(((char*)ptr)+scale*index[3]),
*(int*)(((char*)ptr)+scale*index[4]),
*(int*)(((char*)ptr)+scale*index[5]),
*(int*)(((char*)ptr)+scale*index[6]),
*(int*)(((char*)ptr)+scale*index[7]));
}
static __forceinline vint8 broadcast64(const long long &a) { return _mm256_set1_epi64x(a); }
template<int scale = 4>
static __forceinline vint8 gather(const vboolf8& mask, const int* ptr, const vint8& index) {
vint8 r = zero;
if (likely(mask[0])) r[0] = *(int*)(((char*)ptr)+scale*index[0]);
if (likely(mask[1])) r[1] = *(int*)(((char*)ptr)+scale*index[1]);
if (likely(mask[2])) r[2] = *(int*)(((char*)ptr)+scale*index[2]);
if (likely(mask[3])) r[3] = *(int*)(((char*)ptr)+scale*index[3]);
if (likely(mask[4])) r[4] = *(int*)(((char*)ptr)+scale*index[4]);
if (likely(mask[5])) r[5] = *(int*)(((char*)ptr)+scale*index[5]);
if (likely(mask[6])) r[6] = *(int*)(((char*)ptr)+scale*index[6]);
if (likely(mask[7])) r[7] = *(int*)(((char*)ptr)+scale*index[7]);
return r;
}
static __forceinline vint8 broadcast64(const long long& a) { return _mm256_set1_epi64x(a); }
////////////////////////////////////////////////////////////////////////////////
/// Array Access
////////////////////////////////////////////////////////////////////////////////
__forceinline const int& operator []( const size_t index ) const { assert(index < 8); return i[index]; }
__forceinline int& operator []( const size_t index ) { assert(index < 8); return i[index]; }
__forceinline const int& operator [](size_t index) const { assert(index < 8); return i[index]; }
__forceinline int& operator [](size_t index) { assert(index < 8); return i[index]; }
};
////////////////////////////////////////////////////////////////////////////////
/// Unary Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline const vint8 operator +( const vint8& a ) { return a; }
__forceinline const vint8 operator -( const vint8& a ) { return vint8(_mm_sub_epi32(_mm_setzero_si128(), a.vl), _mm_sub_epi32(_mm_setzero_si128(), a.vh)); }
__forceinline const vint8 abs ( const vint8& a ) { return vint8(_mm_abs_epi32(a.vl), _mm_abs_epi32(a.vh)); }
__forceinline vint8 operator +(const vint8& a) { return a; }
__forceinline vint8 operator -(const vint8& a) { return vint8(_mm_sub_epi32(_mm_setzero_si128(), a.vl), _mm_sub_epi32(_mm_setzero_si128(), a.vh)); }
__forceinline vint8 abs (const vint8& a) { return vint8(_mm_abs_epi32(a.vl), _mm_abs_epi32(a.vh)); }
////////////////////////////////////////////////////////////////////////////////
/// Binary Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline const vint8 operator +( const vint8& a, const vint8& b ) { return vint8(_mm_add_epi32(a.vl, b.vl), _mm_add_epi32(a.vh, b.vh)); }
__forceinline const vint8 operator +( const vint8& a, const int b ) { return a + vint8(b); }
__forceinline const vint8 operator +( const int a, const vint8& b ) { return vint8(a) + b; }
__forceinline vint8 operator +(const vint8& a, const vint8& b) { return vint8(_mm_add_epi32(a.vl, b.vl), _mm_add_epi32(a.vh, b.vh)); }
__forceinline vint8 operator +(const vint8& a, int b) { return a + vint8(b); }
__forceinline vint8 operator +(int a, const vint8& b) { return vint8(a) + b; }
__forceinline const vint8 operator -( const vint8& a, const vint8& b ) { return vint8(_mm_sub_epi32(a.vl, b.vl), _mm_sub_epi32(a.vh, b.vh)); }
__forceinline const vint8 operator -( const vint8& a, const int b ) { return a - vint8(b); }
__forceinline const vint8 operator -( const int a, const vint8& b ) { return vint8(a) - b; }
__forceinline vint8 operator -(const vint8& a, const vint8& b) { return vint8(_mm_sub_epi32(a.vl, b.vl), _mm_sub_epi32(a.vh, b.vh)); }
__forceinline vint8 operator -(const vint8& a, int b) { return a - vint8(b); }
__forceinline vint8 operator -(int a, const vint8& b) { return vint8(a) - b; }
__forceinline const vint8 operator *( const vint8& a, const vint8& b ) { return vint8(_mm_mullo_epi32(a.vl, b.vl), _mm_mullo_epi32(a.vh, b.vh)); }
__forceinline const vint8 operator *( const vint8& a, const int b ) { return a * vint8(b); }
__forceinline const vint8 operator *( const int a, const vint8& b ) { return vint8(a) * b; }
__forceinline vint8 operator *(const vint8& a, const vint8& b) { return vint8(_mm_mullo_epi32(a.vl, b.vl), _mm_mullo_epi32(a.vh, b.vh)); }
__forceinline vint8 operator *(const vint8& a, int b) { return a * vint8(b); }
__forceinline vint8 operator *(int a, const vint8& b) { return vint8(a) * b; }
__forceinline const vint8 operator &( const vint8& a, const vint8& b ) { return _mm256_castps_si256(_mm256_and_ps(_mm256_castsi256_ps(a), _mm256_castsi256_ps(b))); }
__forceinline const vint8 operator &( const vint8& a, const int b ) { return a & vint8(b); }
__forceinline const vint8 operator &( const int a, const vint8& b ) { return vint8(a) & b; }
__forceinline vint8 operator &(const vint8& a, const vint8& b) { return _mm256_castps_si256(_mm256_and_ps(_mm256_castsi256_ps(a), _mm256_castsi256_ps(b))); }
__forceinline vint8 operator &(const vint8& a, int b) { return a & vint8(b); }
__forceinline vint8 operator &(int a, const vint8& b) { return vint8(a) & b; }
__forceinline const vint8 operator |( const vint8& a, const vint8& b ) { return _mm256_castps_si256(_mm256_or_ps (_mm256_castsi256_ps(a), _mm256_castsi256_ps(b))); }
__forceinline const vint8 operator |( const vint8& a, const int b ) { return a | vint8(b); }
__forceinline const vint8 operator |( const int a, const vint8& b ) { return vint8(a) | b; }
__forceinline vint8 operator |(const vint8& a, const vint8& b) { return _mm256_castps_si256(_mm256_or_ps (_mm256_castsi256_ps(a), _mm256_castsi256_ps(b))); }
__forceinline vint8 operator |(const vint8& a, int b) { return a | vint8(b); }
__forceinline vint8 operator |(int a, const vint8& b) { return vint8(a) | b; }
__forceinline const vint8 operator ^( const vint8& a, const vint8& b ) { return _mm256_castps_si256(_mm256_xor_ps(_mm256_castsi256_ps(a), _mm256_castsi256_ps(b))); }
__forceinline const vint8 operator ^( const vint8& a, const int b ) { return a ^ vint8(b); }
__forceinline const vint8 operator ^( const int a, const vint8& b ) { return vint8(a) ^ b; }
__forceinline vint8 operator ^(const vint8& a, const vint8& b) { return _mm256_castps_si256(_mm256_xor_ps(_mm256_castsi256_ps(a), _mm256_castsi256_ps(b))); }
__forceinline vint8 operator ^(const vint8& a, int b) { return a ^ vint8(b); }
__forceinline vint8 operator ^(int a, const vint8& b) { return vint8(a) ^ b; }
__forceinline const vint8 operator <<( const vint8& a, const int n ) { return vint8(_mm_slli_epi32(a.vl, n), _mm_slli_epi32(a.vh, n)); }
__forceinline const vint8 operator >>( const vint8& a, const int n ) { return vint8(_mm_srai_epi32(a.vl, n), _mm_srai_epi32(a.vh, n)); }
__forceinline vint8 operator <<(const vint8& a, int n) { return vint8(_mm_slli_epi32(a.vl, n), _mm_slli_epi32(a.vh, n)); }
__forceinline vint8 operator >>(const vint8& a, int n) { return vint8(_mm_srai_epi32(a.vl, n), _mm_srai_epi32(a.vh, n)); }
__forceinline const vint8 sll ( const vint8& a, const int b ) { return vint8(_mm_slli_epi32(a.vl, b), _mm_slli_epi32(a.vh, b)); }
__forceinline const vint8 sra ( const vint8& a, const int b ) { return vint8(_mm_srai_epi32(a.vl, b), _mm_srai_epi32(a.vh, b)); }
__forceinline const vint8 srl ( const vint8& a, const int b ) { return vint8(_mm_srli_epi32(a.vl, b), _mm_srli_epi32(a.vh, b)); }
__forceinline vint8 sll (const vint8& a, int b) { return vint8(_mm_slli_epi32(a.vl, b), _mm_slli_epi32(a.vh, b)); }
__forceinline vint8 sra (const vint8& a, int b) { return vint8(_mm_srai_epi32(a.vl, b), _mm_srai_epi32(a.vh, b)); }
__forceinline vint8 srl (const vint8& a, int b) { return vint8(_mm_srli_epi32(a.vl, b), _mm_srli_epi32(a.vh, b)); }
__forceinline const vint8 min( const vint8& a, const vint8& b ) { return vint8(_mm_min_epi32(a.vl, b.vl), _mm_min_epi32(a.vh, b.vh)); }
__forceinline const vint8 min( const vint8& a, const int b ) { return min(a,vint8(b)); }
__forceinline const vint8 min( const int a, const vint8& b ) { return min(vint8(a),b); }
__forceinline vint8 min(const vint8& a, const vint8& b) { return vint8(_mm_min_epi32(a.vl, b.vl), _mm_min_epi32(a.vh, b.vh)); }
__forceinline vint8 min(const vint8& a, int b) { return min(a,vint8(b)); }
__forceinline vint8 min(int a, const vint8& b) { return min(vint8(a),b); }
__forceinline const vint8 max( const vint8& a, const vint8& b ) { return vint8(_mm_max_epi32(a.vl, b.vl), _mm_max_epi32(a.vh, b.vh)); }
__forceinline const vint8 max( const vint8& a, const int b ) { return max(a,vint8(b)); }
__forceinline const vint8 max( const int a, const vint8& b ) { return max(vint8(a),b); }
__forceinline vint8 max(const vint8& a, const vint8& b) { return vint8(_mm_max_epi32(a.vl, b.vl), _mm_max_epi32(a.vh, b.vh)); }
__forceinline vint8 max(const vint8& a, int b) { return max(a,vint8(b)); }
__forceinline vint8 max(int a, const vint8& b) { return max(vint8(a),b); }
__forceinline const vint8 umin( const vint8& a, const vint8& b ) { return vint8(_mm_min_epu32(a.vl, b.vl), _mm_min_epu32(a.vh, b.vh)); }
__forceinline const vint8 umin( const vint8& a, const int b ) { return umin(a,vint8(b)); }
__forceinline const vint8 umin( const int a, const vint8& b ) { return umin(vint8(a),b); }
__forceinline vint8 umin(const vint8& a, const vint8& b) { return vint8(_mm_min_epu32(a.vl, b.vl), _mm_min_epu32(a.vh, b.vh)); }
__forceinline vint8 umin(const vint8& a, int b) { return umin(a,vint8(b)); }
__forceinline vint8 umin(int a, const vint8& b) { return umin(vint8(a),b); }
__forceinline const vint8 umax( const vint8& a, const vint8& b ) { return vint8(_mm_max_epu32(a.vl, b.vl), _mm_max_epu32(a.vh, b.vh)); }
__forceinline const vint8 umax( const vint8& a, const int b ) { return umax(a,vint8(b)); }
__forceinline const vint8 umax( const int a, const vint8& b ) { return umax(vint8(a),b); }
__forceinline vint8 umax(const vint8& a, const vint8& b) { return vint8(_mm_max_epu32(a.vl, b.vl), _mm_max_epu32(a.vh, b.vh)); }
__forceinline vint8 umax(const vint8& a, int b) { return umax(a,vint8(b)); }
__forceinline vint8 umax(int a, const vint8& b) { return umax(vint8(a),b); }
////////////////////////////////////////////////////////////////////////////////
/// Assignment Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline vint8& operator +=( vint8& a, const vint8& b ) { return a = a + b; }
__forceinline vint8& operator +=( vint8& a, const int b ) { return a = a + b; }
__forceinline vint8& operator +=(vint8& a, const vint8& b) { return a = a + b; }
__forceinline vint8& operator +=(vint8& a, int b) { return a = a + b; }
__forceinline vint8& operator -=( vint8& a, const vint8& b ) { return a = a - b; }
__forceinline vint8& operator -=( vint8& a, const int b ) { return a = a - b; }
__forceinline vint8& operator -=(vint8& a, const vint8& b) { return a = a - b; }
__forceinline vint8& operator -=(vint8& a, int b) { return a = a - b; }
__forceinline vint8& operator *=( vint8& a, const vint8& b ) { return a = a * b; }
__forceinline vint8& operator *=( vint8& a, const int b ) { return a = a * b; }
__forceinline vint8& operator *=(vint8& a, const vint8& b) { return a = a * b; }
__forceinline vint8& operator *=(vint8& a, int b) { return a = a * b; }
__forceinline vint8& operator &=( vint8& a, const vint8& b ) { return a = a & b; }
__forceinline vint8& operator &=( vint8& a, const int b ) { return a = a & b; }
__forceinline vint8& operator &=(vint8& a, const vint8& b) { return a = a & b; }
__forceinline vint8& operator &=(vint8& a, int b) { return a = a & b; }
__forceinline vint8& operator |=( vint8& a, const vint8& b ) { return a = a | b; }
__forceinline vint8& operator |=( vint8& a, const int b ) { return a = a | b; }
__forceinline vint8& operator |=(vint8& a, const vint8& b) { return a = a | b; }
__forceinline vint8& operator |=(vint8& a, int b) { return a = a | b; }
__forceinline vint8& operator <<=( vint8& a, const int b ) { return a = a << b; }
__forceinline vint8& operator >>=( vint8& a, const int b ) { return a = a >> b; }
__forceinline vint8& operator <<=(vint8& a, int b) { return a = a << b; }
__forceinline vint8& operator >>=(vint8& a, int b) { return a = a >> b; }
////////////////////////////////////////////////////////////////////////////////
/// Comparison Operators + Select
////////////////////////////////////////////////////////////////////////////////
__forceinline const vboolf8 operator ==( const vint8& a, const vint8& b ) { return vboolf8(_mm_castsi128_ps(_mm_cmpeq_epi32 (a.vl, b.vl)),
__forceinline vboolf8 operator ==(const vint8& a, const vint8& b) { return vboolf8(_mm_castsi128_ps(_mm_cmpeq_epi32 (a.vl, b.vl)),
_mm_castsi128_ps(_mm_cmpeq_epi32 (a.vh, b.vh))); }
__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 operator ==(const vint8& a, int b) { return a == vint8(b); }
__forceinline vboolf8 operator ==(int a, const vint8& b) { return vint8(a) == b; }
__forceinline const vboolf8 operator !=( const vint8& a, const vint8& b ) { return !(a == b); }
__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 operator !=(const vint8& a, const vint8& b) { return !(a == b); }
__forceinline vboolf8 operator !=(const vint8& a, int b) { return a != vint8(b); }
__forceinline vboolf8 operator !=(int a, const vint8& b) { return vint8(a) != b; }
__forceinline const vboolf8 operator < ( const vint8& a, const vint8& b ) { return vboolf8(_mm_castsi128_ps(_mm_cmplt_epi32 (a.vl, b.vl)),
__forceinline vboolf8 operator < (const vint8& a, const vint8& b) { return vboolf8(_mm_castsi128_ps(_mm_cmplt_epi32 (a.vl, b.vl)),
_mm_castsi128_ps(_mm_cmplt_epi32 (a.vh, b.vh))); }
__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 operator < (const vint8& a, int b) { return a < vint8(b); }
__forceinline vboolf8 operator < (int a, const vint8& b) { return vint8(a) < b; }
__forceinline const vboolf8 operator >=( const vint8& a, const vint8& b ) { return !(a < b); }
__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 operator >=(const vint8& a, const vint8& b) { return !(a < b); }
__forceinline vboolf8 operator >=(const vint8& a, int b) { return a >= vint8(b); }
__forceinline vboolf8 operator >=(int a, const vint8& b) { return vint8(a) >= b; }
__forceinline const vboolf8 operator > ( const vint8& a, const vint8& b ) { return vboolf8(_mm_castsi128_ps(_mm_cmpgt_epi32 (a.vl, b.vl)),
__forceinline vboolf8 operator > (const vint8& a, const vint8& b) { return vboolf8(_mm_castsi128_ps(_mm_cmpgt_epi32 (a.vl, b.vl)),
_mm_castsi128_ps(_mm_cmpgt_epi32 (a.vh, b.vh))); }
__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 operator > (const vint8& a, int b) { return a > vint8(b); }
__forceinline vboolf8 operator > (int a, const vint8& b) { return vint8(a) > b; }
__forceinline const vboolf8 operator <=( const vint8& a, const vint8& b ) { return !(a > b); }
__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 operator <=(const vint8& a, const vint8& b) { return !(a > b); }
__forceinline vboolf8 operator <=(const vint8& a, int b) { return a <= vint8(b); }
__forceinline vboolf8 operator <=(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; }
@@ -260,11 +288,11 @@ namespace embree
__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 ) {
__forceinline 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));
}
__forceinline const vint8 notand( const vboolf8& m, const vint8& f) {
__forceinline vint8 notand(const vboolf8& m, const vint8& f) {
return _mm256_castps_si256(_mm256_andnot_ps(m, _mm256_castsi256_ps(f)));
}
@@ -273,56 +301,61 @@ namespace embree
/// Movement/Shifting/Shuffling Functions
////////////////////////////////////////////////////////////////////////////////
__forceinline vint8 unpacklo( const vint8& a, const vint8& b ) { return _mm256_castps_si256(_mm256_unpacklo_ps(_mm256_castsi256_ps(a), _mm256_castsi256_ps(b))); }
__forceinline vint8 unpackhi( const vint8& a, const vint8& b ) { return _mm256_castps_si256(_mm256_unpackhi_ps(_mm256_castsi256_ps(a), _mm256_castsi256_ps(b))); }
__forceinline vint8 unpacklo(const vint8& a, const vint8& b) { return _mm256_castps_si256(_mm256_unpacklo_ps(_mm256_castsi256_ps(a), _mm256_castsi256_ps(b))); }
__forceinline vint8 unpackhi(const vint8& a, const vint8& b) { return _mm256_castps_si256(_mm256_unpackhi_ps(_mm256_castsi256_ps(a), _mm256_castsi256_ps(b))); }
template<size_t i> __forceinline const vint8 shuffle( const vint8& a ) {
return _mm256_castps_si256(_mm256_permute_ps(_mm256_castsi256_ps(a), _MM_SHUFFLE(i, i, i, i)));
template<int i>
__forceinline vint8 shuffle(const vint8& v) {
return _mm256_castps_si256(_mm256_permute_ps(_mm256_castsi256_ps(v), _MM_SHUFFLE(i, i, i, i)));
}
template<size_t i0, size_t i1> __forceinline const vint8 shuffle4( const vint8& a ) {
return _mm256_permute2f128_si256(a, a, (i1 << 4) | (i0 << 0));
template<int i0, int i1>
__forceinline vint8 shuffle4(const vint8& v) {
return _mm256_permute2f128_si256(v, v, (i1 << 4) | (i0 << 0));
}
template<size_t i0, size_t i1> __forceinline const vint8 shuffle4( const vint8& a, const vint8& b) {
template<int i0, int i1>
__forceinline vint8 shuffle4(const vint8& a, const vint8& b) {
return _mm256_permute2f128_si256(a, b, (i1 << 4) | (i0 << 0));
}
template<size_t i0, size_t i1, size_t i2, size_t i3> __forceinline const vint8 shuffle( const vint8& a ) {
return _mm256_castps_si256(_mm256_permute_ps(_mm256_castsi256_ps(a), _MM_SHUFFLE(i3, i2, i1, i0)));
template<int i0, int i1, int i2, int i3>
__forceinline vint8 shuffle(const vint8& v) {
return _mm256_castps_si256(_mm256_permute_ps(_mm256_castsi256_ps(v), _MM_SHUFFLE(i3, i2, i1, i0)));
}
template<size_t i0, size_t i1, size_t i2, size_t i3> __forceinline const vint8 shuffle( const vint8& a, const vint8& b ) {
template<int i0, int i1, int i2, int i3>
__forceinline vint8 shuffle(const vint8& a, const vint8& b) {
return _mm256_castps_si256(_mm256_shuffle_ps(_mm256_castsi256_ps(a), _mm256_castsi256_ps(b), _MM_SHUFFLE(i3, i2, i1, i0)));
}
template<> __forceinline const vint8 shuffle<0, 0, 2, 2>( const vint8& b ) { return _mm256_castps_si256(_mm256_moveldup_ps(_mm256_castsi256_ps(b))); }
template<> __forceinline const vint8 shuffle<1, 1, 3, 3>( const vint8& b ) { return _mm256_castps_si256(_mm256_movehdup_ps(_mm256_castsi256_ps(b))); }
template<> __forceinline const vint8 shuffle<0, 1, 0, 1>( const vint8& b ) { return _mm256_castps_si256(_mm256_castpd_ps(_mm256_movedup_pd(_mm256_castps_pd(_mm256_castsi256_ps(b))))); }
template<> __forceinline vint8 shuffle<0, 0, 2, 2>(const vint8& v) { return _mm256_castps_si256(_mm256_moveldup_ps(_mm256_castsi256_ps(v))); }
template<> __forceinline vint8 shuffle<1, 1, 3, 3>(const vint8& v) { return _mm256_castps_si256(_mm256_movehdup_ps(_mm256_castsi256_ps(v))); }
template<> __forceinline vint8 shuffle<0, 1, 0, 1>(const vint8& v) { return _mm256_castps_si256(_mm256_castpd_ps(_mm256_movedup_pd(_mm256_castps_pd(_mm256_castsi256_ps(v))))); }
__forceinline const vint8 broadcast(const int* ptr) { return _mm256_castps_si256(_mm256_broadcast_ss((const float*)ptr)); }
template<size_t i> __forceinline const vint8 insert4(const vint8& a, const vint4& b) { return _mm256_insertf128_si256(a, b, i); }
template<size_t i> __forceinline const vint4 extract4 (const vint8& a) { return _mm256_extractf128_si256(a, i); }
template<> __forceinline const vint4 extract4<0>(const vint8& a) { return _mm256_castsi256_si128(a); }
__forceinline vint8 broadcast(const int* ptr) { return _mm256_castps_si256(_mm256_broadcast_ss((const float*)ptr)); }
template<int i> __forceinline vint8 insert4(const vint8& a, const vint4& b) { return _mm256_insertf128_si256(a, b, i); }
template<int i> __forceinline vint4 extract4(const vint8& a) { return _mm256_extractf128_si256(a, i); }
template<> __forceinline vint4 extract4<0>(const vint8& a) { return _mm256_castsi256_si128(a); }
__forceinline int toScalar(const vint8& a) { return _mm_cvtsi128_si32(_mm256_castsi256_si128(a)); }
__forceinline int toScalar(const vint8& v) { return _mm_cvtsi128_si32(_mm256_castsi256_si128(v)); }
////////////////////////////////////////////////////////////////////////////////
/// Reductions
////////////////////////////////////////////////////////////////////////////////
__forceinline const vint8 vreduce_min2(const vint8& v) { return min(v,shuffle<1,0,3,2>(v)); }
__forceinline const vint8 vreduce_min4(const vint8& v) { vint8 v1 = vreduce_min2(v); return min(v1,shuffle<2,3,0,1>(v1)); }
__forceinline const vint8 vreduce_min (const vint8& v) { vint8 v1 = vreduce_min4(v); return min(v1,shuffle4<1,0>(v1)); }
__forceinline vint8 vreduce_min2(const vint8& v) { return min(v,shuffle<1,0,3,2>(v)); }
__forceinline vint8 vreduce_min4(const vint8& v) { vint8 v1 = vreduce_min2(v); return min(v1,shuffle<2,3,0,1>(v1)); }
__forceinline vint8 vreduce_min (const vint8& v) { vint8 v1 = vreduce_min4(v); return min(v1,shuffle4<1,0>(v1)); }
__forceinline const vint8 vreduce_max2(const vint8& v) { return max(v,shuffle<1,0,3,2>(v)); }
__forceinline const vint8 vreduce_max4(const vint8& v) { vint8 v1 = vreduce_max2(v); return max(v1,shuffle<2,3,0,1>(v1)); }
__forceinline const vint8 vreduce_max (const vint8& v) { vint8 v1 = vreduce_max4(v); return max(v1,shuffle4<1,0>(v1)); }
__forceinline vint8 vreduce_max2(const vint8& v) { return max(v,shuffle<1,0,3,2>(v)); }
__forceinline vint8 vreduce_max4(const vint8& v) { vint8 v1 = vreduce_max2(v); return max(v1,shuffle<2,3,0,1>(v1)); }
__forceinline vint8 vreduce_max (const vint8& v) { vint8 v1 = vreduce_max4(v); return max(v1,shuffle4<1,0>(v1)); }
__forceinline const vint8 vreduce_add2(const vint8& v) { return v + shuffle<1,0,3,2>(v); }
__forceinline const vint8 vreduce_add4(const vint8& v) { vint8 v1 = vreduce_add2(v); return v1 + shuffle<2,3,0,1>(v1); }
__forceinline const vint8 vreduce_add (const vint8& v) { vint8 v1 = vreduce_add4(v); return v1 + shuffle4<1,0>(v1); }
__forceinline vint8 vreduce_add2(const vint8& v) { return v + shuffle<1,0,3,2>(v); }
__forceinline vint8 vreduce_add4(const vint8& v) { vint8 v1 = vreduce_add2(v); return v1 + shuffle<2,3,0,1>(v1); }
__forceinline vint8 vreduce_add (const vint8& v) { vint8 v1 = vreduce_add4(v); return v1 + shuffle4<1,0>(v1); }
__forceinline int reduce_min(const vint8& v) { return toScalar(vreduce_min(v)); }
__forceinline int reduce_max(const vint8& v) { return toScalar(vreduce_max(v)); }
@@ -402,7 +435,7 @@ namespace embree
/// Output Operators
////////////////////////////////////////////////////////////////////////////////
inline std::ostream& operator<<(std::ostream& cout, const vint8& a) {
inline std::ostream& operator <<(std::ostream& cout, const vint8& a) {
return cout << "<" << a[0] << ", " << a[1] << ", " << a[2] << ", " << a[3] << ", " << a[4] << ", " << a[5] << ", " << a[6] << ", " << a[7] << ">";
}
}
+188 -158
View File
@@ -36,82 +36,89 @@ namespace embree
/// Constructors, Assignment & Cast Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline vint ( ) {}
__forceinline vint ( const vint8& a ) { v = a.v; }
__forceinline vint8& operator=( const vint8& a ) { v = a.v; return *this; }
__forceinline vint() {}
__forceinline vint(const vint8& a) { v = a.v; }
__forceinline vint8& operator =(const vint8& a) { v = a.v; return *this; }
__forceinline vint( const __m256i a ) : v(a) {}
__forceinline operator const __m256i&( void ) const { return v; }
__forceinline operator __m256i&( void ) { return v; }
__forceinline vint(__m256i a) : v(a) {}
__forceinline operator const __m256i&() const { return v; }
__forceinline operator __m256i&() { return v; }
__forceinline explicit vint( const vint4& a ) : v(_mm256_insertf128_si256(_mm256_castsi128_si256(a),a,1)) {}
__forceinline vint( const vint4& a, const vint4& b ) : v(_mm256_insertf128_si256(_mm256_castsi128_si256(a),b,1)) {}
__forceinline vint( const __m128i& a, const __m128i& b ) : v(_mm256_insertf128_si256(_mm256_castsi128_si256(a),b,1)) {}
__forceinline explicit vint(const vint4& a) : v(_mm256_insertf128_si256(_mm256_castsi128_si256(a),a,1)) {}
__forceinline vint(const vint4& a, const vint4& b) : v(_mm256_insertf128_si256(_mm256_castsi128_si256(a),b,1)) {}
__forceinline vint(const __m128i& a, const __m128i& b) : v(_mm256_insertf128_si256(_mm256_castsi128_si256(a),b,1)) {}
__forceinline explicit vint ( const int* const a ) : v(_mm256_castps_si256(_mm256_loadu_ps((const float*)a))) {}
__forceinline vint ( int a ) : v(_mm256_set1_epi32(a)) {}
__forceinline vint ( int a, int b) : v(_mm256_set_epi32(b, a, b, a, b, a, b, a)) {}
__forceinline vint ( int a, int b, int c, int d) : v(_mm256_set_epi32(d, c, b, a, d, c, b, a)) {}
__forceinline vint ( int a, int b, int c, int d, int e, int f, int g, int h) : v(_mm256_set_epi32(h, g, f, e, d, c, b, a)) {}
__forceinline explicit vint(const int* a) : v(_mm256_castps_si256(_mm256_loadu_ps((const float*)a))) {}
__forceinline vint(int a) : v(_mm256_set1_epi32(a)) {}
__forceinline vint(int a, int b) : v(_mm256_set_epi32(b, a, b, a, b, a, b, a)) {}
__forceinline vint(int a, int b, int c, int d) : v(_mm256_set_epi32(d, c, b, a, d, c, b, a)) {}
__forceinline vint(int a, int b, int c, int d, int e, int f, int g, int h) : v(_mm256_set_epi32(h, g, f, e, d, c, b, a)) {}
__forceinline explicit vint( const __m256 a ) : v(_mm256_cvtps_epi32(a)) {}
__forceinline explicit vint(__m256 a) : v(_mm256_cvtps_epi32(a)) {}
#if defined(__AVX512VL__)
__forceinline explicit vint( const vboolf8 &a ) : v(_mm256_movm_epi32(a)) {}
__forceinline explicit vint(const vboolf8& a) : v(_mm256_movm_epi32(a)) {}
#else
__forceinline explicit vint( const vboolf8 &a ) : v(_mm256_castps_si256((__m256)a)) {}
__forceinline explicit vint(const vboolf8& a) : v(_mm256_castps_si256((__m256)a)) {}
#endif
////////////////////////////////////////////////////////////////////////////////
/// Constants
////////////////////////////////////////////////////////////////////////////////
__forceinline vint( ZeroTy ) : v(_mm256_setzero_si256()) {}
__forceinline vint( OneTy ) : v(_mm256_set1_epi32(1)) {}
__forceinline vint( PosInfTy ) : v(_mm256_set1_epi32(pos_inf)) {}
__forceinline vint( NegInfTy ) : v(_mm256_set1_epi32(neg_inf)) {}
__forceinline vint( StepTy ) : v(_mm256_set_epi32(7, 6, 5, 4, 3, 2, 1, 0)) {}
__forceinline vint(ZeroTy) : v(_mm256_setzero_si256()) {}
__forceinline vint(OneTy) : v(_mm256_set1_epi32(1)) {}
__forceinline vint(PosInfTy) : v(_mm256_set1_epi32(pos_inf)) {}
__forceinline vint(NegInfTy) : v(_mm256_set1_epi32(neg_inf)) {}
__forceinline vint(StepTy) : v(_mm256_set_epi32(7, 6, 5, 4, 3, 2, 1, 0)) {}
__forceinline vint(UndefinedTy) : v(_mm256_undefined_si256()) {}
////////////////////////////////////////////////////////////////////////////////
/// Loads and Stores
////////////////////////////////////////////////////////////////////////////////
static __forceinline const vint8 load( const unsigned char* const ptr ) { return _mm256_cvtepu8_epi32(_mm_load_si128((__m128i*)ptr)); }
static __forceinline const vint8 loadu( const unsigned char* const ptr ) { return _mm256_cvtepu8_epi32(_mm_loadu_si128((__m128i*)ptr)); }
static __forceinline const vint8 load( const unsigned short* const ptr ) { return _mm256_cvtepu16_epi32(_mm_load_si128((__m128i*)ptr)); }
static __forceinline const vint8 loadu( const unsigned short* const ptr ) { return _mm256_cvtepu16_epi32(_mm_loadu_si128((__m128i*)ptr)); }
static __forceinline vint8 load(const unsigned char* ptr) { return _mm256_cvtepu8_epi32(_mm_load_si128((__m128i*)ptr)); }
static __forceinline vint8 loadu(const unsigned char* ptr) { return _mm256_cvtepu8_epi32(_mm_loadu_si128((__m128i*)ptr)); }
static __forceinline vint8 load(const unsigned short* ptr) { return _mm256_cvtepu16_epi32(_mm_load_si128((__m128i*)ptr)); }
static __forceinline vint8 loadu(const unsigned short* ptr) { return _mm256_cvtepu16_epi32(_mm_loadu_si128((__m128i*)ptr)); }
static __forceinline const vint8 load( const void* const ptr ) { return _mm256_load_si256((__m256i*)ptr); }
static __forceinline const vint8 loadu(const void* const ptr ) { return _mm256_loadu_si256((__m256i*)ptr); }
static __forceinline vint8 load(const void* ptr) { return _mm256_load_si256((__m256i*)ptr); }
static __forceinline vint8 loadu(const void* ptr) { return _mm256_loadu_si256((__m256i*)ptr); }
static __forceinline void store ( void* ptr, const vint8& v ) { _mm256_store_si256((__m256i*)ptr,v); }
static __forceinline void storeu( void* ptr, const vint8& v ) { _mm256_storeu_ps((float*)ptr,_mm256_castsi256_ps(v)); }
static __forceinline void store (void* ptr, const vint8& v) { _mm256_store_si256((__m256i*)ptr,v); }
static __forceinline void storeu(void* ptr, const vint8& v) { _mm256_storeu_ps((float*)ptr,_mm256_castsi256_ps(v)); }
#if defined(__AVX512VL__)
static __forceinline vint8 load ( const vboolf8& mask, const void* const ptr ) { return _mm256_mask_load_epi32 (_mm256_setzero_si256(),mask,ptr); }
static __forceinline vint8 loadu( const vboolf8& mask, const void* const ptr ) { return _mm256_mask_loadu_epi32(_mm256_setzero_si256(),mask,ptr); }
static __forceinline void store ( const vboolf8& mask, void* ptr, const vint8& v ) { _mm256_mask_store_epi32 (ptr,mask,v); }
static __forceinline void storeu( const vboolf8& mask, void* ptr, const vint8& v ) { _mm256_mask_storeu_epi32(ptr,mask,v); }
static __forceinline vint8 compact(const vboolf8& mask, vint8 &v) {
return _mm256_mask_compress_epi32(v, mask, v);
}
static __forceinline vint8 compact(const vboolf8& mask, vint8 &a, const vint8& b) {
return _mm256_mask_compress_epi32(a, mask, b);
}
static __forceinline vint8 load (const vboolf8& mask, const void* ptr) { return _mm256_mask_load_epi32 (_mm256_setzero_si256(),mask,ptr); }
static __forceinline vint8 loadu(const vboolf8& mask, const void* ptr) { return _mm256_mask_loadu_epi32(_mm256_setzero_si256(),mask,ptr); }
static __forceinline void store (const vboolf8& mask, void* ptr, const vint8& v) { _mm256_mask_store_epi32 (ptr,mask,v); }
static __forceinline void storeu(const vboolf8& mask, void* ptr, const vint8& v) { _mm256_mask_storeu_epi32(ptr,mask,v); }
#else
static __forceinline vint8 load ( const vboolf8& mask, const void* const ptr ) { return _mm256_castps_si256(_mm256_maskload_ps((float*)ptr,mask)); }
static __forceinline vint8 loadu( const vboolf8& mask, const void* const ptr ) { return _mm256_castps_si256(_mm256_maskload_ps((float*)ptr,mask)); }
static __forceinline vint8 load (const vboolf8& mask, const void* ptr) { return _mm256_castps_si256(_mm256_maskload_ps((float*)ptr,mask)); }
static __forceinline vint8 loadu(const vboolf8& mask, const void* ptr) { return _mm256_castps_si256(_mm256_maskload_ps((float*)ptr,mask)); }
static __forceinline void store ( const vboolf8& mask, void* ptr, const vint8& v ) { _mm256_maskstore_epi32((int*)ptr,mask,v); }
static __forceinline void storeu( const vboolf8& mask, void* ptr, const vint8& v ) { _mm256_maskstore_epi32((int*)ptr,mask,v); }
static __forceinline void store (const vboolf8& mask, void* ptr, const vint8& v) { _mm256_maskstore_epi32((int*)ptr,mask,v); }
static __forceinline void storeu(const vboolf8& mask, void* ptr, const vint8& v) { _mm256_maskstore_epi32((int*)ptr,mask,v); }
#endif
#if defined (__AVX2__)
static __forceinline vint8 load_nt(void* ptr) {
return _mm256_stream_load_si256((__m256i*)ptr);
}
#endif
static __forceinline void store_nt(void* ptr, const vint8& v) {
_mm256_stream_ps((float*)ptr,_mm256_castsi256_ps(v));
}
static __forceinline void store_uchar( unsigned char* const ptr, const vint8& i ) {
static __forceinline void store(unsigned char* ptr, const vint8& i) {
__m256i x = i;
x = _mm256_packus_epi32(x, x);
x = _mm256_packus_epi16(x, x);
@@ -123,154 +130,169 @@ namespace embree
#endif
}
static __forceinline void store_ushort( unsigned short* const ptr, const vint8& v ) {
static __forceinline void store(unsigned short* ptr, const vint8& v) {
for (size_t i=0;i<8;i++)
ptr[i] = (unsigned short)v[i];
}
template<int scale = 4>
static __forceinline vint8 gather(const int *const ptr, const vint8& index) {
return _mm256_i32gather_epi32(ptr, index, scale);
}
template<int scale = 4>
static __forceinline vint8 gather(const vboolf8& mask, const int *const ptr, const vint8& index) {
vint8 r = zero;
#if defined(__AVX512VL__)
return _mm256_mmask_i32gather_epi32(r, mask, index, ptr, scale);
#else
return _mm256_mask_i32gather_epi32(r, ptr, index, mask, scale);
#endif
}
static __forceinline vint8 broadcast64(const long long &a) { return _mm256_set1_epi64x(a); }
////////////////////////////////////////////////////////////////////////////////
/// Array Access
////////////////////////////////////////////////////////////////////////////////
__forceinline const int& operator []( const size_t index ) const { assert(index < 8); return i[index]; }
__forceinline int& operator []( const size_t index ) { assert(index < 8); return i[index]; }
__forceinline const int& operator [](size_t index) const { assert(index < 8); return i[index]; }
__forceinline int& operator [](size_t index) { assert(index < 8); return i[index]; }
};
////////////////////////////////////////////////////////////////////////////////
/// Unary Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline const vint8 operator +( const vint8& a ) { return a; }
__forceinline const vint8 operator -( const vint8& a ) { return _mm256_sub_epi32(_mm256_setzero_si256(), a.v); }
__forceinline const vint8 abs ( const vint8& a ) { return _mm256_abs_epi32(a.v); }
__forceinline vint8 operator +(const vint8& a) { return a; }
__forceinline vint8 operator -(const vint8& a) { return _mm256_sub_epi32(_mm256_setzero_si256(), a); }
__forceinline vint8 abs (const vint8& a) { return _mm256_abs_epi32(a); }
////////////////////////////////////////////////////////////////////////////////
/// Binary Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline const vint8 operator +( const vint8& a, const vint8& b ) { return _mm256_add_epi32(a.v, b.v); }
__forceinline const vint8 operator +( const vint8& a, const int b ) { return a + vint8(b); }
__forceinline const vint8 operator +( const int a, const vint8& b ) { return vint8(a) + b; }
__forceinline vint8 operator +(const vint8& a, const vint8& b) { return _mm256_add_epi32(a, b); }
__forceinline vint8 operator +(const vint8& a, int b) { return a + vint8(b); }
__forceinline vint8 operator +(int a, const vint8& b) { return vint8(a) + b; }
__forceinline const vint8 operator -( const vint8& a, const vint8& b ) { return _mm256_sub_epi32(a.v, b.v); }
__forceinline const vint8 operator -( const vint8& a, const int b ) { return a - vint8(b); }
__forceinline const vint8 operator -( const int a, const vint8& b ) { return vint8(a) - b; }
__forceinline vint8 operator -(const vint8& a, const vint8& b) { return _mm256_sub_epi32(a, b); }
__forceinline vint8 operator -(const vint8& a, int b) { return a - vint8(b); }
__forceinline vint8 operator -(int a, const vint8& b) { return vint8(a) - b; }
__forceinline const vint8 operator *( const vint8& a, const vint8& b ) { return _mm256_mullo_epi32(a.v, b.v); }
__forceinline const vint8 operator *( const vint8& a, const int b ) { return a * vint8(b); }
__forceinline const vint8 operator *( const int a, const vint8& b ) { return vint8(a) * b; }
__forceinline vint8 operator *(const vint8& a, const vint8& b) { return _mm256_mullo_epi32(a, b); }
__forceinline vint8 operator *(const vint8& a, int b) { return a * vint8(b); }
__forceinline vint8 operator *(int a, const vint8& b) { return vint8(a) * b; }
__forceinline const vint8 operator &( const vint8& a, const vint8& b ) { return _mm256_and_si256(a.v, b.v); }
__forceinline const vint8 operator &( const vint8& a, const int b ) { return a & vint8(b); }
__forceinline const vint8 operator &( const int a, const vint8& b ) { return vint8(a) & b; }
__forceinline vint8 operator &(const vint8& a, const vint8& b) { return _mm256_and_si256(a, b); }
__forceinline vint8 operator &(const vint8& a, int b) { return a & vint8(b); }
__forceinline vint8 operator &(int a, const vint8& b) { return vint8(a) & b; }
__forceinline const vint8 operator |( const vint8& a, const vint8& b ) { return _mm256_or_si256(a.v, b.v); }
__forceinline const vint8 operator |( const vint8& a, const int b ) { return a | vint8(b); }
__forceinline const vint8 operator |( const int a, const vint8& b ) { return vint8(a) | b; }
__forceinline vint8 operator |(const vint8& a, const vint8& b) { return _mm256_or_si256(a, b); }
__forceinline vint8 operator |(const vint8& a, int b) { return a | vint8(b); }
__forceinline vint8 operator |(int a, const vint8& b) { return vint8(a) | b; }
__forceinline const vint8 operator ^( const vint8& a, const vint8& b ) { return _mm256_xor_si256(a.v, b.v); }
__forceinline const vint8 operator ^( const vint8& a, const int b ) { return a ^ vint8(b); }
__forceinline const vint8 operator ^( const int a, const vint8& b ) { return vint8(a) ^ b; }
__forceinline vint8 operator ^(const vint8& a, const vint8& b) { return _mm256_xor_si256(a, b); }
__forceinline vint8 operator ^(const vint8& a, int b) { return a ^ vint8(b); }
__forceinline vint8 operator ^(int a, const vint8& b) { return vint8(a) ^ b; }
__forceinline const vint8 operator <<( const vint8& a, const int n ) { return _mm256_slli_epi32(a.v, n); }
__forceinline const vint8 operator >>( const vint8& a, const int n ) { return _mm256_srai_epi32(a.v, n); }
__forceinline vint8 operator <<(const vint8& a, int n) { return _mm256_slli_epi32(a, n); }
__forceinline vint8 operator >>(const vint8& a, int n) { return _mm256_srai_epi32(a, n); }
__forceinline const vint8 operator <<( const vint8& a, const vint8& n ) { return _mm256_sllv_epi32(a.v, n); }
__forceinline const vint8 operator >>( const vint8& a, const vint8& n ) { return _mm256_srav_epi32(a.v, n); }
__forceinline vint8 operator <<(const vint8& a, const vint8& n) { return _mm256_sllv_epi32(a, n); }
__forceinline vint8 operator >>(const vint8& a, const vint8& n) { return _mm256_srav_epi32(a, n); }
__forceinline const vint8 sll ( const vint8& a, const int b ) { return _mm256_slli_epi32(a.v, b); }
__forceinline const vint8 sra ( const vint8& a, const int b ) { return _mm256_srai_epi32(a.v, b); }
__forceinline const vint8 srl ( const vint8& a, const int b ) { return _mm256_srli_epi32(a.v, b); }
__forceinline vint8 sll(const vint8& a, int b) { return _mm256_slli_epi32(a, b); }
__forceinline vint8 sra(const vint8& a, int b) { return _mm256_srai_epi32(a, b); }
__forceinline vint8 srl(const vint8& a, int b) { return _mm256_srli_epi32(a, b); }
__forceinline const vint8 sll ( const vint8& a, const vint8 &b ) { return _mm256_sllv_epi32(a.v, b.v); }
__forceinline const vint8 sra ( const vint8& a, const vint8 &b ) { return _mm256_srav_epi32(a.v, b.v); }
__forceinline const vint8 srl ( const vint8& a, const vint8 &b ) { return _mm256_srlv_epi32(a.v, b.v); }
__forceinline vint8 sll(const vint8& a, const vint8& b) { return _mm256_sllv_epi32(a, b); }
__forceinline vint8 sra(const vint8& a, const vint8& b) { return _mm256_srav_epi32(a, b); }
__forceinline vint8 srl(const vint8& a, const vint8& b) { return _mm256_srlv_epi32(a, b); }
__forceinline const vint8 min( const vint8& a, const vint8& b ) { return _mm256_min_epi32(a.v, b.v); }
__forceinline const vint8 min( const vint8& a, const int b ) { return min(a,vint8(b)); }
__forceinline const vint8 min( const int a, const vint8& b ) { return min(vint8(a),b); }
__forceinline vint8 min(const vint8& a, const vint8& b) { return _mm256_min_epi32(a, b); }
__forceinline vint8 min(const vint8& a, int b) { return min(a,vint8(b)); }
__forceinline vint8 min(int a, const vint8& b) { return min(vint8(a),b); }
__forceinline const vint8 max( const vint8& a, const vint8& b ) { return _mm256_max_epi32(a.v, b.v); }
__forceinline const vint8 max( const vint8& a, const int b ) { return max(a,vint8(b)); }
__forceinline const vint8 max( const int a, const vint8& b ) { return max(vint8(a),b); }
__forceinline vint8 max(const vint8& a, const vint8& b) { return _mm256_max_epi32(a, b); }
__forceinline vint8 max(const vint8& a, int b) { return max(a,vint8(b)); }
__forceinline vint8 max(int a, const vint8& b) { return max(vint8(a),b); }
__forceinline const vint8 umin( const vint8& a, const vint8& b ) { return _mm256_min_epu32(a.v, b.v); }
__forceinline const vint8 umax( const vint8& a, const vint8& b ) { return _mm256_max_epu32(a.v, b.v); }
__forceinline vint8 umin(const vint8& a, const vint8& b) { return _mm256_min_epu32(a, b); }
__forceinline vint8 umax(const vint8& a, const vint8& b) { return _mm256_max_epu32(a, b); }
////////////////////////////////////////////////////////////////////////////////
/// Assignment Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline vint8& operator +=( vint8& a, const vint8& b ) { return a = a + b; }
__forceinline vint8& operator +=( vint8& a, const int b ) { return a = a + b; }
__forceinline vint8& operator +=(vint8& a, const vint8& b) { return a = a + b; }
__forceinline vint8& operator +=(vint8& a, int b) { return a = a + b; }
__forceinline vint8& operator -=( vint8& a, const vint8& b ) { return a = a - b; }
__forceinline vint8& operator -=( vint8& a, const int b ) { return a = a - b; }
__forceinline vint8& operator -=(vint8& a, const vint8& b) { return a = a - b; }
__forceinline vint8& operator -=(vint8& a, int b) { return a = a - b; }
__forceinline vint8& operator *=( vint8& a, const vint8& b ) { return a = a * b; }
__forceinline vint8& operator *=( vint8& a, const int b ) { return a = a * b; }
__forceinline vint8& operator *=(vint8& a, const vint8& b) { return a = a * b; }
__forceinline vint8& operator *=(vint8& a, int b) { return a = a * b; }
__forceinline vint8& operator &=( vint8& a, const vint8& b ) { return a = a & b; }
__forceinline vint8& operator &=( vint8& a, const int b ) { return a = a & b; }
__forceinline vint8& operator &=(vint8& a, const vint8& b) { return a = a & b; }
__forceinline vint8& operator &=(vint8& a, int b) { return a = a & b; }
__forceinline vint8& operator |=( vint8& a, const vint8& b ) { return a = a | b; }
__forceinline vint8& operator |=( vint8& a, const int b ) { return a = a | b; }
__forceinline vint8& operator |=(vint8& a, const vint8& b) { return a = a | b; }
__forceinline vint8& operator |=(vint8& a, int b) { return a = a | b; }
__forceinline vint8& operator <<=( vint8& a, const int b ) { return a = a << b; }
__forceinline vint8& operator >>=( vint8& a, const int b ) { return a = a >> b; }
__forceinline vint8& operator <<=(vint8& a, const int b) { return a = a << b; }
__forceinline vint8& operator >>=(vint8& a, const int b) { return a = a >> b; }
////////////////////////////////////////////////////////////////////////////////
/// Comparison Operators + Select
////////////////////////////////////////////////////////////////////////////////
#if defined(__AVX512VL__)
__forceinline const vboolf8 operator ==( const vint8& a, const vint8& b ) { return _mm256_cmp_epi32_mask(a,b,_MM_CMPINT_EQ); }
__forceinline const vboolf8 operator !=( const vint8& a, const vint8& b ) { return _mm256_cmp_epi32_mask(a,b,_MM_CMPINT_NE); }
__forceinline const vboolf8 operator < ( const vint8& a, const vint8& b ) { return _mm256_cmp_epi32_mask(a,b,_MM_CMPINT_LT); }
__forceinline const vboolf8 operator >=( const vint8& a, const vint8& b ) { return _mm256_cmp_epi32_mask(a,b,_MM_CMPINT_GE); }
__forceinline const vboolf8 operator > ( const vint8& a, const vint8& b ) { return _mm256_cmp_epi32_mask(a,b,_MM_CMPINT_GT); }
__forceinline const vboolf8 operator <=( const vint8& a, const vint8& b ) { return _mm256_cmp_epi32_mask(a,b,_MM_CMPINT_LE); }
__forceinline vboolf8 operator ==(const vint8& a, const vint8& b) { return _mm256_cmp_epi32_mask(a,b,_MM_CMPINT_EQ); }
__forceinline vboolf8 operator !=(const vint8& a, const vint8& b) { return _mm256_cmp_epi32_mask(a,b,_MM_CMPINT_NE); }
__forceinline vboolf8 operator < (const vint8& a, const vint8& b) { return _mm256_cmp_epi32_mask(a,b,_MM_CMPINT_LT); }
__forceinline vboolf8 operator >=(const vint8& a, const vint8& b) { return _mm256_cmp_epi32_mask(a,b,_MM_CMPINT_GE); }
__forceinline vboolf8 operator > (const vint8& a, const vint8& b) { return _mm256_cmp_epi32_mask(a,b,_MM_CMPINT_GT); }
__forceinline vboolf8 operator <=(const vint8& a, const vint8& b) { return _mm256_cmp_epi32_mask(a,b,_MM_CMPINT_LE); }
__forceinline const vint8 select( const vboolf8& m, const vint8& t, const vint8& f ) {
__forceinline vint8 select(const vboolf8& m, const vint8& t, const vint8& f) {
return _mm256_mask_blend_epi32(m, f, t);
}
#else
__forceinline const vboolf8 operator ==( const vint8& a, const vint8& b ) { return _mm256_castsi256_ps(_mm256_cmpeq_epi32(a, b)); }
__forceinline const vboolf8 operator !=( const vint8& a, const vint8& b ) { return !(a == b); }
__forceinline const vboolf8 operator < ( const vint8& a, const vint8& b ) { return _mm256_castsi256_ps(_mm256_cmpgt_epi32(b, a)); }
__forceinline const vboolf8 operator >=( const vint8& a, const vint8& b ) { return !(a < b); }
__forceinline const vboolf8 operator > ( const vint8& a, const vint8& b ) { return _mm256_castsi256_ps(_mm256_cmpgt_epi32(a, b)); }
__forceinline const vboolf8 operator <=( const vint8& a, const vint8& b ) { return !(a > b); }
__forceinline vboolf8 operator ==(const vint8& a, const vint8& b) { return _mm256_castsi256_ps(_mm256_cmpeq_epi32(a, b)); }
__forceinline vboolf8 operator !=(const vint8& a, const vint8& b) { return !(a == b); }
__forceinline vboolf8 operator < (const vint8& a, const vint8& b) { return _mm256_castsi256_ps(_mm256_cmpgt_epi32(b, a)); }
__forceinline vboolf8 operator >=(const vint8& a, const vint8& b) { return !(a < b); }
__forceinline vboolf8 operator > (const vint8& a, const vint8& b) { return _mm256_castsi256_ps(_mm256_cmpgt_epi32(a, b)); }
__forceinline vboolf8 operator <=(const vint8& a, const vint8& b) { return !(a > b); }
__forceinline const vint8 select( const vboolf8& m, const vint8& t, const vint8& f ) {
__forceinline 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));
}
#endif
template<int mask>
__forceinline const vint8 select(const vint8& t, const vint8& f) {
__forceinline vint8 select(const vint8& t, const vint8& f) {
return _mm256_blend_epi32(f, t, mask);
}
__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 operator ==(const vint8& a, int b) { return a == vint8(b); }
__forceinline vboolf8 operator ==(int a, const vint8& b) { return vint8(a) == b; }
__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 operator !=(const vint8& a, int b) { return a != vint8(b); }
__forceinline vboolf8 operator !=(int a, const vint8& b) { return vint8(a) != b; }
__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 operator < (const vint8& a, int b) { return a < vint8(b); }
__forceinline vboolf8 operator < (int a, const vint8& b) { return vint8(a) < b; }
__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 operator >=(const vint8& a, int b) { return a >= vint8(b); }
__forceinline vboolf8 operator >=(int a, const vint8& b) { return vint8(a) >= b; }
__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 operator > (const vint8& a, int b) { return a > vint8(b); }
__forceinline vboolf8 operator > (int a, const vint8& b) { return vint8(a) > b; }
__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 operator <=(const vint8& a, int b) { return a <= vint8(b); }
__forceinline vboolf8 operator <=(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; }
@@ -299,70 +321,78 @@ namespace embree
/// Movement/Shifting/Shuffling Functions
////////////////////////////////////////////////////////////////////////////////
__forceinline vint8 unpacklo( const vint8& a, const vint8& b ) { return _mm256_unpacklo_epi32(a.v, b.v); }
__forceinline vint8 unpackhi( const vint8& a, const vint8& b ) { return _mm256_unpackhi_epi32(a.v, b.v); }
__forceinline vint8 unpacklo(const vint8& a, const vint8& b) { return _mm256_unpacklo_epi32(a, b); }
__forceinline vint8 unpackhi(const vint8& a, const vint8& b) { return _mm256_unpackhi_epi32(a, b); }
template<size_t i> __forceinline const vint8 shuffle( const vint8& a ) {
return _mm256_castps_si256(_mm256_permute_ps(_mm256_castsi256_ps(a), _MM_SHUFFLE(i, i, i, i)));
template<int i>
__forceinline vint8 shuffle(const vint8& v) {
return _mm256_castps_si256(_mm256_permute_ps(_mm256_castsi256_ps(v), _MM_SHUFFLE(i, i, i, i)));
}
template<size_t i0, size_t i1> __forceinline const vint8 shuffle4( const vint8& a ) {
return _mm256_permute2f128_si256(a, a, (i1 << 4) | (i0 << 0));
template<int i0, int i1>
__forceinline vint8 shuffle4(const vint8& v) {
return _mm256_permute2f128_si256(v, v, (i1 << 4) | (i0 << 0));
}
template<size_t i0, size_t i1> __forceinline const vint8 shuffle4( const vint8& a, const vint8& b) {
template<int i0, int i1>
__forceinline vint8 shuffle4(const vint8& a, const vint8& b) {
return _mm256_permute2f128_si256(a, b, (i1 << 4) | (i0 << 0));
}
template<size_t i0, size_t i1, size_t i2, size_t i3> __forceinline const vint8 shuffle( const vint8& a ) {
return _mm256_castps_si256(_mm256_permute_ps(_mm256_castsi256_ps(a), _MM_SHUFFLE(i3, i2, i1, i0)));
template<int i0, int i1, int i2, int i3>
__forceinline vint8 shuffle(const vint8& v) {
return _mm256_castps_si256(_mm256_permute_ps(_mm256_castsi256_ps(v), _MM_SHUFFLE(i3, i2, i1, i0)));
}
template<size_t i0, size_t i1, size_t i2, size_t i3> __forceinline const vint8 shuffle( const vint8& a, const vint8& b ) {
template<int i0, int i1, int i2, int i3>
__forceinline vint8 shuffle(const vint8& a, const vint8& b) {
return _mm256_castps_si256(_mm256_shuffle_ps(_mm256_castsi256_ps(a), _mm256_castsi256_ps(b), _MM_SHUFFLE(i3, i2, i1, i0)));
}
template<> __forceinline const vint8 shuffle<0, 0, 2, 2>( const vint8& b ) { return _mm256_castps_si256(_mm256_moveldup_ps(_mm256_castsi256_ps(b))); }
template<> __forceinline const vint8 shuffle<1, 1, 3, 3>( const vint8& b ) { return _mm256_castps_si256(_mm256_movehdup_ps(_mm256_castsi256_ps(b))); }
template<> __forceinline const vint8 shuffle<0, 1, 0, 1>( const vint8& b ) { return _mm256_castps_si256(_mm256_castpd_ps(_mm256_movedup_pd(_mm256_castps_pd(_mm256_castsi256_ps(b))))); }
template<> __forceinline vint8 shuffle<0, 0, 2, 2>(const vint8& v) { return _mm256_castps_si256(_mm256_moveldup_ps(_mm256_castsi256_ps(v))); }
template<> __forceinline vint8 shuffle<1, 1, 3, 3>(const vint8& v) { return _mm256_castps_si256(_mm256_movehdup_ps(_mm256_castsi256_ps(v))); }
template<> __forceinline vint8 shuffle<0, 1, 0, 1>(const vint8& v) { return _mm256_castps_si256(_mm256_castpd_ps(_mm256_movedup_pd(_mm256_castps_pd(_mm256_castsi256_ps(v))))); }
__forceinline const vint8 broadcast(const int* ptr) { return _mm256_castps_si256(_mm256_broadcast_ss((const float*)ptr)); }
__forceinline vint8 broadcast(const int* ptr) { return _mm256_castps_si256(_mm256_broadcast_ss((const float*)ptr)); }
template<size_t i> __forceinline const vint8 insert4(const vint8& a, const vint4& b) { return _mm256_insertf128_si256(a, b, i); }
template<size_t i> __forceinline const vint4 extract4 (const vint8& a) { return _mm256_extractf128_si256(a, i); }
template<> __forceinline const vint4 extract4<0>(const vint8& a) { return _mm256_castsi256_si128(a); }
template<int i> __forceinline vint8 insert4(const vint8& a, const vint4& b) { return _mm256_insertf128_si256(a, b, i); }
template<int i> __forceinline vint4 extract4(const vint8& a) { return _mm256_extractf128_si256(a, i); }
template<> __forceinline vint4 extract4<0>(const vint8& a) { return _mm256_castsi256_si128(a); }
__forceinline int toScalar(const vint8& a) { return _mm_cvtsi128_si32(_mm256_castsi256_si128(a)); }
__forceinline int toScalar(const vint8& v) { return _mm_cvtsi128_si32(_mm256_castsi256_si128(v)); }
__forceinline vint8 permute(const vint8& a, const __m256i& index) {
return _mm256_permutevar8x32_epi32(a,index);
__forceinline vint8 permute(const vint8& v, const __m256i& index) {
return _mm256_permutevar8x32_epi32(v, index);
}
__forceinline vint8 shuffle(const vint8& a, const __m256i& index) {
return _mm256_castps_si256(_mm256_permutevar_ps(_mm256_castsi256_ps(a),index));
__forceinline vint8 shuffle(const vint8& v, const __m256i& index) {
return _mm256_castps_si256(_mm256_permutevar_ps(_mm256_castsi256_ps(v), index));
}
template<int i>
__forceinline vint8 align_shift_right(const vint8 &a, const vint8 &b) {
return _mm256_alignr_epi8(a, b, i);
__forceinline vint8 align_shift_right(const vint8& a, const vint8& b) {
#if defined(__AVX512VL__)
return _mm256_alignr_epi32(a, b, i);
#else
return _mm256_alignr_epi8(a, b, 4*i);
#endif
}
////////////////////////////////////////////////////////////////////////////////
/// Reductions
////////////////////////////////////////////////////////////////////////////////
__forceinline const vint8 vreduce_min2(const vint8& v) { return min(v,shuffle<1,0,3,2>(v)); }
__forceinline const vint8 vreduce_min4(const vint8& v) { vint8 v1 = vreduce_min2(v); return min(v1,shuffle<2,3,0,1>(v1)); }
__forceinline const vint8 vreduce_min (const vint8& v) { vint8 v1 = vreduce_min4(v); return min(v1,shuffle4<1,0>(v1)); }
__forceinline vint8 vreduce_min2(const vint8& v) { return min(v,shuffle<1,0,3,2>(v)); }
__forceinline vint8 vreduce_min4(const vint8& v) { vint8 v1 = vreduce_min2(v); return min(v1,shuffle<2,3,0,1>(v1)); }
__forceinline vint8 vreduce_min (const vint8& v) { vint8 v1 = vreduce_min4(v); return min(v1,shuffle4<1,0>(v1)); }
__forceinline const vint8 vreduce_max2(const vint8& v) { return max(v,shuffle<1,0,3,2>(v)); }
__forceinline const vint8 vreduce_max4(const vint8& v) { vint8 v1 = vreduce_max2(v); return max(v1,shuffle<2,3,0,1>(v1)); }
__forceinline const vint8 vreduce_max (const vint8& v) { vint8 v1 = vreduce_max4(v); return max(v1,shuffle4<1,0>(v1)); }
__forceinline vint8 vreduce_max2(const vint8& v) { return max(v,shuffle<1,0,3,2>(v)); }
__forceinline vint8 vreduce_max4(const vint8& v) { vint8 v1 = vreduce_max2(v); return max(v1,shuffle<2,3,0,1>(v1)); }
__forceinline vint8 vreduce_max (const vint8& v) { vint8 v1 = vreduce_max4(v); return max(v1,shuffle4<1,0>(v1)); }
__forceinline const vint8 vreduce_add2(const vint8& v) { return v + shuffle<1,0,3,2>(v); }
__forceinline const vint8 vreduce_add4(const vint8& v) { vint8 v1 = vreduce_add2(v); return v1 + shuffle<2,3,0,1>(v1); }
__forceinline const vint8 vreduce_add (const vint8& v) { vint8 v1 = vreduce_add4(v); return v1 + shuffle4<1,0>(v1); }
__forceinline vint8 vreduce_add2(const vint8& v) { return v + shuffle<1,0,3,2>(v); }
__forceinline vint8 vreduce_add4(const vint8& v) { vint8 v1 = vreduce_add2(v); return v1 + shuffle<2,3,0,1>(v1); }
__forceinline vint8 vreduce_add (const vint8& v) { vint8 v1 = vreduce_add4(v); return v1 + shuffle4<1,0>(v1); }
__forceinline int reduce_min(const vint8& v) { return toScalar(vreduce_min(v)); }
__forceinline int reduce_max(const vint8& v) { return toScalar(vreduce_max(v)); }
@@ -375,7 +405,7 @@ namespace embree
__forceinline size_t select_max(const vboolf8& valid, const vint8& v) { const vint8 a = select(valid,v,vint8(neg_inf)); return __bsf(movemask(valid & (a == vreduce_max(a)))); }
__forceinline vint8 assign( const vint4& a ) { return _mm256_castsi128_si256(a); }
__forceinline vint8 assign(const vint4& a) { return _mm256_castsi128_si256(a); }
////////////////////////////////////////////////////////////////////////////////
/// Sorting networks
@@ -445,7 +475,7 @@ namespace embree
/// Output Operators
////////////////////////////////////////////////////////////////////////////////
inline std::ostream& operator<<(std::ostream& cout, const vint8& a) {
inline std::ostream& operator <<(std::ostream& cout, const vint8& a) {
return cout << "<" << a[0] << ", " << a[1] << ", " << a[2] << ", " << a[3] << ", " << a[4] << ", " << a[5] << ", " << a[6] << ", " << a[7] << ">";
}
}
+108 -114
View File
@@ -18,17 +18,7 @@
namespace embree
{
#ifndef _MM_SHUF_PERM2
#define _MM_SHUF_PERM2(e3, e2, e1, e0) \
((int)(((e3)<<3) | ((e2)<<2) | ((e1)<<1) | (e0)))
#endif
#ifndef _MM_SHUF_PERM3
#define _MM_SHUF_PERM3(e1, e0) \
((int)(((e1)<<4) | (e0)))
#endif
/* 4-wide AVX2 64bit long long type */
/* 4-wide AVX2 64-bit long long type */
template<>
struct vllong<4>
{
@@ -46,18 +36,18 @@ namespace embree
__forceinline vllong() {}
__forceinline vllong(const vllong4& t) { v = t.v; }
__forceinline vllong4& operator=(const vllong4& f) { v = f.v; return *this; }
__forceinline vllong4& operator =(const vllong4& f) { v = f.v; return *this; }
__forceinline vllong(const __m256i& t) { v = t; }
__forceinline operator __m256i () const { return v; }
__forceinline operator __m256d () const { return _mm256_castsi256_pd(v); }
__forceinline operator __m256i() const { return v; }
__forceinline operator __m256d() const { return _mm256_castsi256_pd(v); }
__forceinline vllong(const long long i) {
__forceinline vllong(long long i) {
v = _mm256_set1_epi64x(i);
}
__forceinline vllong(const long long a, const long long b, const long long c, const long long d) {
__forceinline vllong(long long a, long long b, long long c, long long d) {
v = _mm256_set_epi64x(d,c,b,a);
}
@@ -66,20 +56,16 @@ namespace embree
/// Constants
////////////////////////////////////////////////////////////////////////////////
__forceinline vllong( ZeroTy ) : v(_mm256_setzero_si256()) {}
__forceinline vllong( OneTy ) : v(_mm256_set1_epi64x(1)) {}
__forceinline vllong( StepTy ) : v(_mm256_set_epi64x(3,2,1,0)) {}
__forceinline vllong( ReverseStepTy ) : v(_mm256_set_epi64x(0,1,2,3)) {}
__forceinline static vllong4 zero() { return _mm256_setzero_si256(); }
__forceinline static vllong4 one () { return _mm256_set1_epi64x(1); }
__forceinline static vllong4 neg_one () { return _mm256_set1_epi64x(-1); }
__forceinline vllong(ZeroTy) : v(_mm256_setzero_si256()) {}
__forceinline vllong(OneTy) : v(_mm256_set1_epi64x(1)) {}
__forceinline vllong(StepTy) : v(_mm256_set_epi64x(3,2,1,0)) {}
__forceinline vllong(ReverseStepTy) : v(_mm256_set_epi64x(0,1,2,3)) {}
////////////////////////////////////////////////////////////////////////////////
/// Loads and Stores
////////////////////////////////////////////////////////////////////////////////
static __forceinline void store_nt(void *__restrict__ ptr, const vllong4& a) {
static __forceinline void store_nt(void* __restrict__ ptr, const vllong4& a) {
_mm256_stream_ps((float*)ptr,_mm256_castsi256_ps(a));
}
@@ -134,8 +120,8 @@ namespace embree
/// Array Access
////////////////////////////////////////////////////////////////////////////////
__forceinline long long& operator[](const size_t index) { assert(index < 4); return i[index]; }
__forceinline const long long& operator[](const size_t index) const { assert(index < 4); return i[index]; }
__forceinline long long& operator [](size_t index) { assert(index < 4); return i[index]; }
__forceinline const long long& operator [](size_t index) const { assert(index < 4); return i[index]; }
};
@@ -143,7 +129,7 @@ namespace embree
/// Select
////////////////////////////////////////////////////////////////////////////////
__forceinline const vllong4 select( const vboold4& m, const vllong4& t, const vllong4& f ) {
__forceinline vllong4 select(const vboold4& m, const vllong4& t, const vllong4& f) {
#if defined(__AVX512VL__)
return _mm256_mask_blend_epi64(m, f, t);
#else
@@ -155,123 +141,123 @@ namespace embree
/// Unary Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline const vllong4 asLong ( const __m256& a ) { return _mm256_castps_si256(a); }
__forceinline const vllong4 operator +( const vllong4& a ) { return a; }
__forceinline const vllong4 operator -( const vllong4& a ) { return _mm256_sub_epi64(_mm256_setzero_si256(), a); }
__forceinline vllong4 asLong (const __m256& a) { return _mm256_castps_si256(a); }
__forceinline vllong4 operator +(const vllong4& a) { return a; }
__forceinline vllong4 operator -(const vllong4& a) { return _mm256_sub_epi64(_mm256_setzero_si256(), a); }
////////////////////////////////////////////////////////////////////////////////
/// Binary Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline const vllong4 operator +( const vllong4& a, const vllong4& b ) { return _mm256_add_epi64(a, b); }
__forceinline const vllong4 operator +( const vllong4& a, const long long b ) { return a + vllong4(b); }
__forceinline const vllong4 operator +( const long long a, const vllong4& b ) { return vllong4(a) + b; }
__forceinline vllong4 operator +(const vllong4& a, const vllong4& b) { return _mm256_add_epi64(a, b); }
__forceinline vllong4 operator +(const vllong4& a, long long b) { return a + vllong4(b); }
__forceinline vllong4 operator +(long long a, const vllong4& b) { return vllong4(a) + b; }
__forceinline const vllong4 operator -( const vllong4& a, const vllong4& b ) { return _mm256_sub_epi64(a, b); }
__forceinline const vllong4 operator -( const vllong4& a, const long long b ) { return a - vllong4(b); }
__forceinline const vllong4 operator -( const long long a, const vllong4& b ) { return vllong4(a) - b; }
__forceinline vllong4 operator -(const vllong4& a, const vllong4& b) { return _mm256_sub_epi64(a, b); }
__forceinline vllong4 operator -(const vllong4& a, long long b) { return a - vllong4(b); }
__forceinline vllong4 operator -(long long a, const vllong4& b) { return vllong4(a) - b; }
/* only low 32bit part */
__forceinline const vllong4 operator *( const vllong4& a, const vllong4& b ) { return _mm256_mul_epi32(a, b); }
__forceinline const vllong4 operator *( const vllong4& a, const long long b ) { return a * vllong4(b); }
__forceinline const vllong4 operator *( const long long a, const vllong4& b ) { return vllong4(a) * b; }
__forceinline vllong4 operator *(const vllong4& a, const vllong4& b) { return _mm256_mul_epi32(a, b); }
__forceinline vllong4 operator *(const vllong4& a, long long b) { return a * vllong4(b); }
__forceinline vllong4 operator *(long long a, const vllong4& b) { return vllong4(a) * b; }
__forceinline const vllong4 operator &( const vllong4& a, const vllong4& b ) { return _mm256_and_si256(a, b); }
__forceinline const vllong4 operator &( const vllong4& a, const long long b ) { return a & vllong4(b); }
__forceinline const vllong4 operator &( const long long a, const vllong4& b ) { return vllong4(a) & b; }
__forceinline vllong4 operator &(const vllong4& a, const vllong4& b) { return _mm256_and_si256(a, b); }
__forceinline vllong4 operator &(const vllong4& a, long long b) { return a & vllong4(b); }
__forceinline vllong4 operator &(long long a, const vllong4& b) { return vllong4(a) & b; }
__forceinline const vllong4 operator |( const vllong4& a, const vllong4& b ) { return _mm256_or_si256(a, b); }
__forceinline const vllong4 operator |( const vllong4& a, const long long b ) { return a | vllong4(b); }
__forceinline const vllong4 operator |( const long long a, const vllong4& b ) { return vllong4(a) | b; }
__forceinline vllong4 operator |(const vllong4& a, const vllong4& b) { return _mm256_or_si256(a, b); }
__forceinline vllong4 operator |(const vllong4& a, long long b) { return a | vllong4(b); }
__forceinline vllong4 operator |(long long a, const vllong4& b) { return vllong4(a) | b; }
__forceinline const vllong4 operator ^( const vllong4& a, const vllong4& b ) { return _mm256_xor_si256(a, b); }
__forceinline const vllong4 operator ^( const vllong4& a, const long long b ) { return a ^ vllong4(b); }
__forceinline const vllong4 operator ^( const long long a, const vllong4& b ) { return vllong4(a) ^ b; }
__forceinline vllong4 operator ^(const vllong4& a, const vllong4& b) { return _mm256_xor_si256(a, b); }
__forceinline vllong4 operator ^(const vllong4& a, long long b) { return a ^ vllong4(b); }
__forceinline vllong4 operator ^(long long a, const vllong4& b) { return vllong4(a) ^ b; }
__forceinline const vllong4 operator <<( const vllong4& a, const long long n ) { return _mm256_slli_epi64(a, n); }
//__forceinline const vllong4 operator >>( const vllong4& a, const long long n ) { return _mm256_srai_epi64(a, n); }
__forceinline vllong4 operator <<(const vllong4& a, long long n) { return _mm256_slli_epi64(a, (int)n); }
//__forceinline vllong4 operator >>(const vllong4& a, long long n) { return _mm256_srai_epi64(a, n); }
__forceinline const vllong4 operator <<( const vllong4& a, const vllong4& n ) { return _mm256_sllv_epi64(a, n); }
//__forceinline const vllong4 operator >>( const vllong4& a, const vllong4& n ) { return _mm256_srav_epi64(a, n); }
//__forceinline const vllong4 sra ( const vllong4& a, const long long b ) { return _mm256_srai_epi64(a, b); }
__forceinline vllong4 operator <<(const vllong4& a, const vllong4& n) { return _mm256_sllv_epi64(a, n); }
//__forceinline vllong4 operator >>(const vllong4& a, const vllong4& n) { return _mm256_srav_epi64(a, n); }
//__forceinline vllong4 sra(const vllong4& a, long long b) { return _mm256_srai_epi64(a, b); }
__forceinline const vllong4 srl ( const vllong4& a, const long long b ) { return _mm256_srli_epi64(a, b); }
__forceinline vllong4 srl(const vllong4& a, long long b) { return _mm256_srli_epi64(a, (int)b); }
//__forceinline const vllong4 min( const vllong4& a, const vllong4& b ) { return _mm256_min_epi64(a, b); }
//__forceinline const vllong4 min( const vllong4& a, const long long b ) { return min(a,vllong4(b)); }
//__forceinline const vllong4 min( const long long a, const vllong4& b ) { return min(vllong4(a),b); }
//__forceinline vllong4 min(const vllong4& a, const vllong4& b) { return _mm256_min_epi64(a, b); }
//__forceinline vllong4 min(const vllong4& a, long long b) { return min(a,vllong4(b)); }
//__forceinline vllong4 min(long long a, const vllong4& b) { return min(vllong4(a),b); }
//__forceinline const vllong4 max( const vllong4& a, const vllong4& b ) { return _mm256_max_epi64(a, b); }
//__forceinline const vllong4 max( const vllong4& a, const long long b ) { return max(a,vllong4(b)); }
//__forceinline const vllong4 max( const long long a, const vllong4& b ) { return max(vllong4(a),b); }
//__forceinline vllong4 max(const vllong4& a, const vllong4& b) { return _mm256_max_epi64(a, b); }
//__forceinline vllong4 max(const vllong4& a, long long b) { return max(a,vllong4(b)); }
//__forceinline vllong4 max(long long a, const vllong4& b) { return max(vllong4(a),b); }
#if defined(__AVX512VL__)
__forceinline const vllong4 mask_and(const vboold4& m, const vllong4& c, const vllong4& a, const vllong4& b) { return _mm256_mask_and_epi64(c,m,a,b); }
__forceinline const vllong4 mask_or (const vboold4& m, const vllong4& c, const vllong4& a, const vllong4& b) { return _mm256_mask_or_epi64(c,m,a,b); }
__forceinline vllong4 mask_and(const vboold4& m, const vllong4& c, const vllong4& a, const vllong4& b) { return _mm256_mask_and_epi64(c,m,a,b); }
__forceinline vllong4 mask_or (const vboold4& m, const vllong4& c, const vllong4& a, const vllong4& b) { return _mm256_mask_or_epi64(c,m,a,b); }
#else
__forceinline const vllong4 mask_and(const vboold4& m, const vllong4& c, const vllong4& a, const vllong4& b) { return select(m, a & b, c); }
__forceinline const vllong4 mask_or (const vboold4& m, const vllong4& c, const vllong4& a, const vllong4& b) { return select(m, a | b, c); }
__forceinline vllong4 mask_and(const vboold4& m, const vllong4& c, const vllong4& a, const vllong4& b) { return select(m, a & b, c); }
__forceinline vllong4 mask_or (const vboold4& m, const vllong4& c, const vllong4& a, const vllong4& b) { return select(m, a | b, c); }
#endif
////////////////////////////////////////////////////////////////////////////////
/// Assignment Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline vllong4& operator +=( vllong4& a, const vllong4& b ) { return a = a + b; }
__forceinline vllong4& operator +=( vllong4& a, const long long b ) { return a = a + b; }
__forceinline vllong4& operator +=(vllong4& a, const vllong4& b) { return a = a + b; }
__forceinline vllong4& operator +=(vllong4& a, long long b) { return a = a + b; }
__forceinline vllong4& operator -=( vllong4& a, const vllong4& b ) { return a = a - b; }
__forceinline vllong4& operator -=( vllong4& a, const long long b ) { return a = a - b; }
__forceinline vllong4& operator -=(vllong4& a, const vllong4& b) { return a = a - b; }
__forceinline vllong4& operator -=(vllong4& a, long long b) { return a = a - b; }
__forceinline vllong4& operator *=( vllong4& a, const vllong4& b ) { return a = a * b; }
__forceinline vllong4& operator *=( vllong4& a, const long long b ) { return a = a * b; }
__forceinline vllong4& operator *=(vllong4& a, const vllong4& b) { return a = a * b; }
__forceinline vllong4& operator *=(vllong4& a, long long b) { return a = a * b; }
__forceinline vllong4& operator &=( vllong4& a, const vllong4& b ) { return a = a & b; }
__forceinline vllong4& operator &=( vllong4& a, const long long b ) { return a = a & b; }
__forceinline vllong4& operator &=(vllong4& a, const vllong4& b) { return a = a & b; }
__forceinline vllong4& operator &=(vllong4& a, long long b) { return a = a & b; }
__forceinline vllong4& operator |=( vllong4& a, const vllong4& b ) { return a = a | b; }
__forceinline vllong4& operator |=( vllong4& a, const long long b ) { return a = a | b; }
__forceinline vllong4& operator |=(vllong4& a, const vllong4& b) { return a = a | b; }
__forceinline vllong4& operator |=(vllong4& a, long long b) { return a = a | b; }
__forceinline vllong4& operator <<=( vllong4& a, const long long b ) { return a = a << b; }
//__forceinline vllong4& operator >>=( vllong4& a, const long long b ) { return a = a >> b; }
__forceinline vllong4& operator <<=(vllong4& a, long long b) { return a = a << b; }
//__forceinline vllong4& operator >>=(vllong4& a, long long b) { return a = a >> b; }
////////////////////////////////////////////////////////////////////////////////
/// Comparison Operators
////////////////////////////////////////////////////////////////////////////////
#if defined(__AVX512VL__)
__forceinline const vboold4 operator ==( const vllong4& a, const vllong4& b ) { return _mm256_cmp_epi64_mask(a,b,_MM_CMPINT_EQ); }
__forceinline const vboold4 operator !=( const vllong4& a, const vllong4& b ) { return _mm256_cmp_epi64_mask(a,b,_MM_CMPINT_NE); }
__forceinline const vboold4 operator < ( const vllong4& a, const vllong4& b ) { return _mm256_cmp_epi64_mask(a,b,_MM_CMPINT_LT); }
__forceinline const vboold4 operator >=( const vllong4& a, const vllong4& b ) { return _mm256_cmp_epi64_mask(a,b,_MM_CMPINT_GE); }
__forceinline const vboold4 operator > ( const vllong4& a, const vllong4& b ) { return _mm256_cmp_epi64_mask(a,b,_MM_CMPINT_GT); }
__forceinline const vboold4 operator <=( const vllong4& a, const vllong4& b ) { return _mm256_cmp_epi64_mask(a,b,_MM_CMPINT_LE); }
__forceinline vboold4 operator ==(const vllong4& a, const vllong4& b) { return _mm256_cmp_epi64_mask(a,b,_MM_CMPINT_EQ); }
__forceinline vboold4 operator !=(const vllong4& a, const vllong4& b) { return _mm256_cmp_epi64_mask(a,b,_MM_CMPINT_NE); }
__forceinline vboold4 operator < (const vllong4& a, const vllong4& b) { return _mm256_cmp_epi64_mask(a,b,_MM_CMPINT_LT); }
__forceinline vboold4 operator >=(const vllong4& a, const vllong4& b) { return _mm256_cmp_epi64_mask(a,b,_MM_CMPINT_GE); }
__forceinline vboold4 operator > (const vllong4& a, const vllong4& b) { return _mm256_cmp_epi64_mask(a,b,_MM_CMPINT_GT); }
__forceinline vboold4 operator <=(const vllong4& a, const vllong4& b) { return _mm256_cmp_epi64_mask(a,b,_MM_CMPINT_LE); }
#else
__forceinline const vboold4 operator ==( const vllong4& a, const vllong4& b ) { return _mm256_cmpeq_epi64(a,b); }
__forceinline const vboold4 operator !=( const vllong4& a, const vllong4& b ) { return !(a == b); }
__forceinline const vboold4 operator > ( const vllong4& a, const vllong4& b ) { return _mm256_cmpgt_epi64(a,b); }
__forceinline const vboold4 operator < ( const vllong4& a, const vllong4& b ) { return _mm256_cmpgt_epi64(b,a); }
__forceinline const vboold4 operator >=( const vllong4& a, const vllong4& b ) { return !(a < b); }
__forceinline const vboold4 operator <=( const vllong4& a, const vllong4& b ) { return !(a > b); }
__forceinline vboold4 operator ==(const vllong4& a, const vllong4& b) { return _mm256_cmpeq_epi64(a,b); }
__forceinline vboold4 operator !=(const vllong4& a, const vllong4& b) { return !(a == b); }
__forceinline vboold4 operator > (const vllong4& a, const vllong4& b) { return _mm256_cmpgt_epi64(a,b); }
__forceinline vboold4 operator < (const vllong4& a, const vllong4& b) { return _mm256_cmpgt_epi64(b,a); }
__forceinline vboold4 operator >=(const vllong4& a, const vllong4& b) { return !(a < b); }
__forceinline vboold4 operator <=(const vllong4& a, const vllong4& b) { return !(a > b); }
#endif
__forceinline const vboold4 operator ==( const vllong4& a, const long long b ) { return a == vllong4(b); }
__forceinline const vboold4 operator ==( const long long a, const vllong4& b ) { return vllong4(a) == b; }
__forceinline vboold4 operator ==(const vllong4& a, long long b) { return a == vllong4(b); }
__forceinline vboold4 operator ==(long long a, const vllong4& b) { return vllong4(a) == b; }
__forceinline const vboold4 operator !=( const vllong4& a, const long long b ) { return a != vllong4(b); }
__forceinline const vboold4 operator !=( const long long a, const vllong4& b ) { return vllong4(a) != b; }
__forceinline vboold4 operator !=(const vllong4& a, long long b) { return a != vllong4(b); }
__forceinline vboold4 operator !=(long long a, const vllong4& b) { return vllong4(a) != b; }
__forceinline const vboold4 operator > ( const vllong4& a, const long long b ) { return a > vllong4(b); }
__forceinline const vboold4 operator > ( const long long a, const vllong4& b ) { return vllong4(a) > b; }
__forceinline vboold4 operator > (const vllong4& a, long long b) { return a > vllong4(b); }
__forceinline vboold4 operator > (long long a, const vllong4& b) { return vllong4(a) > b; }
__forceinline const vboold4 operator < ( const vllong4& a, const long long b ) { return a < vllong4(b); }
__forceinline const vboold4 operator < ( const long long a, const vllong4& b ) { return vllong4(a) < b; }
__forceinline vboold4 operator < (const vllong4& a, long long b) { return a < vllong4(b); }
__forceinline vboold4 operator < (long long a, const vllong4& b) { return vllong4(a) < b; }
__forceinline const vboold4 operator >=( const vllong4& a, const long long b ) { return a >= vllong4(b); }
__forceinline const vboold4 operator >=( const long long a, const vllong4& b ) { return vllong4(a) >= b; }
__forceinline vboold4 operator >=(const vllong4& a, long long b) { return a >= vllong4(b); }
__forceinline vboold4 operator >=(long long a, const vllong4& b) { return vllong4(a) >= b; }
__forceinline const vboold4 operator <=( const vllong4& a, const long long b ) { return a <= vllong4(b); }
__forceinline const vboold4 operator <=( const long long a, const vllong4& b ) { return vllong4(a) <= b; }
__forceinline vboold4 operator <=(const vllong4& a, long long b) { return a <= vllong4(b); }
__forceinline vboold4 operator <=(long long a, const vllong4& b) { return vllong4(a) <= b; }
__forceinline vboold4 eq(const vllong4& a, const vllong4& b) { return a == b; }
__forceinline vboold4 ne(const vllong4& a, const vllong4& b) { return a != b; }
@@ -312,15 +298,23 @@ namespace embree
// Movement/Shifting/Shuffling Functions
////////////////////////////////////////////////////////////////////////////////
template<int B, int A> __forceinline vllong4 shuffle (const vllong4& v) { return _mm256_castpd_si256(_mm256_permute_pd(_mm256_castsi256_pd(v),(int)_MM_SHUF_PERM2(B,A,B,A))); }
template<int A> __forceinline vllong4 shuffle (const vllong4& x) { return shuffle<A,A>(x); }
template<int i0, int i1>
__forceinline vllong4 shuffle(const vllong4& v) {
return _mm256_castpd_si256(_mm256_permute_pd(_mm256_castsi256_pd(v), (i1 << 3) | (i0 << 2) | (i1 << 1) | i0));
}
template<int B, int A> __forceinline vllong4 shuffle2 (const vllong4& v) { return _mm256_castpd_si256(_mm256_permute2f128_pd(_mm256_castsi256_pd(v),v,(int)_MM_SHUF_PERM3(B,A))); }
template<int i>
__forceinline vllong4 shuffle(const vllong4& v) {
return shuffle<i, i>(v);
}
template<int i0, int i1>
__forceinline vllong4 shuffle2(const vllong4& v) {
return _mm256_castpd_si256(_mm256_permute2f128_pd(_mm256_castsi256_pd(v), _mm256_castsi256_pd(v), (i1 << 4) | i0));
}
__forceinline long long toScalar(const vllong4& a)
{
return _mm_cvtsi128_si64(_mm256_castsi256_si128(a));
__forceinline long long toScalar(const vllong4& v) {
return _mm_cvtsi128_si64(_mm256_castsi256_si128(v));
}
////////////////////////////////////////////////////////////////////////////////
@@ -328,14 +322,14 @@ namespace embree
////////////////////////////////////////////////////////////////////////////////
__forceinline vllong4 vreduce_and2(const vllong4& x) { return x & shuffle<0,1>(x); }
__forceinline vllong4 vreduce_and (const vllong4& y) { const vllong4 x = vreduce_and2(y); return x & shuffle2<0,1>(x); }
__forceinline vllong4 vreduce_and2(const vllong4& x) { return x & shuffle<1,0>(x); }
__forceinline vllong4 vreduce_and (const vllong4& y) { const vllong4 x = vreduce_and2(y); return x & shuffle2<1,0>(x); }
__forceinline vllong4 vreduce_or2(const vllong4& x) { return x | shuffle<0,1>(x); }
__forceinline vllong4 vreduce_or (const vllong4& y) { const vllong4 x = vreduce_or2(y); return x | shuffle2<0,1>(x); }
__forceinline vllong4 vreduce_or2(const vllong4& x) { return x | shuffle<1,0>(x); }
__forceinline vllong4 vreduce_or (const vllong4& y) { const vllong4 x = vreduce_or2(y); return x | shuffle2<1,0>(x); }
__forceinline vllong4 vreduce_add2(const vllong4& x) { return x + shuffle<0,1>(x); }
__forceinline vllong4 vreduce_add (const vllong4& y) { const vllong4 x = vreduce_add2(y); return x + shuffle2<0,1>(x); }
__forceinline vllong4 vreduce_add2(const vllong4& x) { return x + shuffle<1,0>(x); }
__forceinline vllong4 vreduce_add (const vllong4& y) { const vllong4 x = vreduce_add2(y); return x + shuffle2<1,0>(x); }
__forceinline long long reduce_add(const vllong4& a) { return toScalar(vreduce_add(a)); }
__forceinline long long reduce_or (const vllong4& a) { return toScalar(vreduce_or(a)); }
@@ -345,7 +339,7 @@ namespace embree
/// Output Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline std::ostream& operator<<(std::ostream& cout, const vllong4& v)
__forceinline std::ostream& operator <<(std::ostream& cout, const vllong4& v)
{
cout << "<" << v[0];
for (size_t i=1; i<4; i++) cout << ", " << v[i];
+121 -119
View File
@@ -18,7 +18,7 @@
namespace embree
{
/* 8-wide AVX-512 64bit long long type */
/* 8-wide AVX-512 64-bit long long type */
template<>
struct vllong<8>
{
@@ -36,45 +36,44 @@ namespace embree
__forceinline vllong() {}
__forceinline vllong(const vllong8& t) { v = t.v; }
__forceinline vllong8& operator=(const vllong8& f) { v = f.v; return *this; }
__forceinline vllong8& operator =(const vllong8& f) { v = f.v; return *this; }
__forceinline vllong(const __m512i& t) { v = t; }
__forceinline operator __m512i () const { return v; }
__forceinline operator __m256i () const { return _mm512_castsi512_si256(v); }
__forceinline operator __m512i() const { return v; }
__forceinline operator __m256i() const { return _mm512_castsi512_si256(v); }
__forceinline vllong(const long long i) {
__forceinline vllong(long long i) {
v = _mm512_set1_epi64(i);
}
__forceinline vllong(const long long a, const long long b, const long long c, const long long d) {
__forceinline vllong(long long a, long long b, long long c, long long d) {
v = _mm512_set4_epi64(d,c,b,a);
}
__forceinline vllong(const long long a0, const long long a1, const long long a2, const long long a3,
const long long a4, const long long a5, const long long a6, const long long a7)
__forceinline vllong(long long a0, long long a1, long long a2, long long a3,
long long a4, long long a5, long long a6, long long a7)
{
v = _mm512_set_epi64(a7,a6,a5,a4,a3,a2,a1,a0);
}
__forceinline vllong(const vllong<4>& i) {
v = _mm512_broadcast_i64x4(i);
}
////////////////////////////////////////////////////////////////////////////////
/// Constants
////////////////////////////////////////////////////////////////////////////////
__forceinline vllong( ZeroTy ) : v(_mm512_setzero_epi32()) {}
__forceinline vllong( OneTy ) : v(_mm512_set1_epi64(1)) {}
__forceinline vllong( StepTy ) : v(_mm512_set_epi64(7,6,5,4,3,2,1,0)) {}
__forceinline vllong( ReverseStepTy ) : v(_mm512_setr_epi64(7,6,5,4,3,2,1,0)) {}
__forceinline static vllong8 zero() { return _mm512_setzero_epi32(); }
__forceinline static vllong8 one () { return _mm512_set1_epi64(1); }
__forceinline static vllong8 neg_one () { return _mm512_set1_epi64(-1); }
__forceinline vllong(ZeroTy) : v(_mm512_setzero_epi32()) {}
__forceinline vllong(OneTy) : v(_mm512_set1_epi64(1)) {}
__forceinline vllong(StepTy) : v(_mm512_set_epi64(7,6,5,4,3,2,1,0)) {}
__forceinline vllong(ReverseStepTy) : v(_mm512_setr_epi64(7,6,5,4,3,2,1,0)) {}
////////////////////////////////////////////////////////////////////////////////
/// Loads and Stores
////////////////////////////////////////////////////////////////////////////////
static __forceinline void store_nt(void *__restrict__ ptr, const vllong8& a) {
static __forceinline void store_nt(void* __restrict__ ptr, const vllong8& a) {
_mm512_stream_si512((__m512i*)ptr,a);
}
@@ -90,7 +89,7 @@ namespace embree
return _mm512_load_si512(addr);
}
static __forceinline const vllong8 load( const unsigned char* const ptr ) {
static __forceinline vllong8 load(const unsigned char* ptr) {
return _mm512_cvtepu8_epi64(*(__m128i*)ptr);
}
@@ -98,11 +97,11 @@ namespace embree
_mm512_store_si512(ptr,v);
}
static __forceinline void storeu(void* ptr, const vllong8& v ) {
static __forceinline void storeu(void* ptr, const vllong8& v) {
_mm512_storeu_si512(ptr,v);
}
static __forceinline void storeu(const vboold8& mask, long long* ptr, const vllong8& f ) {
static __forceinline void storeu(const vboold8& mask, long long* ptr, const vllong8& f) {
_mm512_mask_storeu_epi64(ptr,mask,f);
}
@@ -111,7 +110,7 @@ namespace embree
}
/* pass by value to avoid compiler generating inefficient code */
static __forceinline void storeu_compact(const vboold8 mask,void * addr, const vllong8& reg) {
static __forceinline void storeu_compact(const vboold8 mask, void* addr, const vllong8& reg) {
_mm512_mask_compressstoreu_epi64(addr,mask,reg);
}
@@ -149,8 +148,8 @@ namespace embree
/// Array Access
////////////////////////////////////////////////////////////////////////////////
__forceinline long long& operator[](const size_t index) { assert(index < 8); return i[index]; }
__forceinline const long long& operator[](const size_t index) const { assert(index < 8); return i[index]; }
__forceinline long long& operator [](size_t index) { assert(index < 8); return i[index]; }
__forceinline const long long& operator [](size_t index) const { assert(index < 8); return i[index]; }
};
@@ -158,111 +157,111 @@ namespace embree
/// Unary Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline const vllong8 asLong ( const __m512& a ) { return _mm512_castps_si512(a); }
__forceinline const vllong8 operator +( const vllong8& a ) { return a; }
__forceinline const vllong8 operator -( const vllong8& a ) { return _mm512_sub_epi64(_mm512_setzero_epi32(), a); }
__forceinline vllong8 asLong (const __m512& a) { return _mm512_castps_si512(a); }
__forceinline vllong8 operator +(const vllong8& a) { return a; }
__forceinline vllong8 operator -(const vllong8& a) { return _mm512_sub_epi64(_mm512_setzero_epi32(), a); }
////////////////////////////////////////////////////////////////////////////////
/// Binary Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline const vllong8 operator +( const vllong8& a, const vllong8& b ) { return _mm512_add_epi64(a, b); }
__forceinline const vllong8 operator +( const vllong8& a, const long long b ) { return a + vllong8(b); }
__forceinline const vllong8 operator +( const long long a, const vllong8& b ) { return vllong8(a) + b; }
__forceinline vllong8 operator +(const vllong8& a, const vllong8& b) { return _mm512_add_epi64(a, b); }
__forceinline vllong8 operator +(const vllong8& a, long long b) { return a + vllong8(b); }
__forceinline vllong8 operator +(long long a, const vllong8& b) { return vllong8(a) + b; }
__forceinline const vllong8 operator -( const vllong8& a, const vllong8& b ) { return _mm512_sub_epi64(a, b); }
__forceinline const vllong8 operator -( const vllong8& a, const long long b ) { return a - vllong8(b); }
__forceinline const vllong8 operator -( const long long a, const vllong8& b ) { return vllong8(a) - b; }
__forceinline vllong8 operator -(const vllong8& a, const vllong8& b) { return _mm512_sub_epi64(a, b); }
__forceinline vllong8 operator -(const vllong8& a, long long b) { return a - vllong8(b); }
__forceinline vllong8 operator -(long long a, const vllong8& b) { return vllong8(a) - b; }
__forceinline const vllong8 operator *( const vllong8& a, const vllong8& b ) { return _mm512_mullo_epi64(a, b); }
__forceinline const vllong8 operator *( const vllong8& a, const long long b ) { return a * vllong8(b); }
__forceinline const vllong8 operator *( const long long a, const vllong8& b ) { return vllong8(a) * b; }
__forceinline vllong8 operator *(const vllong8& a, const vllong8& b) { return _mm512_mullo_epi64(a, b); }
__forceinline vllong8 operator *(const vllong8& a, long long b) { return a * vllong8(b); }
__forceinline vllong8 operator *(long long a, const vllong8& b) { return vllong8(a) * b; }
__forceinline const vllong8 operator &( const vllong8& a, const vllong8& b ) { return _mm512_and_epi64(a, b); }
__forceinline const vllong8 operator &( const vllong8& a, const long long b ) { return a & vllong8(b); }
__forceinline const vllong8 operator &( const long long a, const vllong8& b ) { return vllong8(a) & b; }
__forceinline vllong8 operator &(const vllong8& a, const vllong8& b) { return _mm512_and_epi64(a, b); }
__forceinline vllong8 operator &(const vllong8& a, long long b) { return a & vllong8(b); }
__forceinline vllong8 operator &(long long a, const vllong8& b) { return vllong8(a) & b; }
__forceinline const vllong8 operator |( const vllong8& a, const vllong8& b ) { return _mm512_or_epi64(a, b); }
__forceinline const vllong8 operator |( const vllong8& a, const long long b ) { return a | vllong8(b); }
__forceinline const vllong8 operator |( const long long a, const vllong8& b ) { return vllong8(a) | b; }
__forceinline vllong8 operator |(const vllong8& a, const vllong8& b) { return _mm512_or_epi64(a, b); }
__forceinline vllong8 operator |(const vllong8& a, long long b) { return a | vllong8(b); }
__forceinline vllong8 operator |(long long a, const vllong8& b) { return vllong8(a) | b; }
__forceinline const vllong8 operator ^( const vllong8& a, const vllong8& b ) { return _mm512_xor_epi64(a, b); }
__forceinline const vllong8 operator ^( const vllong8& a, const long long b ) { return a ^ vllong8(b); }
__forceinline const vllong8 operator ^( const long long a, const vllong8& b ) { return vllong8(a) ^ b; }
__forceinline vllong8 operator ^(const vllong8& a, const vllong8& b) { return _mm512_xor_epi64(a, b); }
__forceinline vllong8 operator ^(const vllong8& a, long long b) { return a ^ vllong8(b); }
__forceinline vllong8 operator ^(long long a, const vllong8& b) { return vllong8(a) ^ b; }
__forceinline const vllong8 operator <<( const vllong8& a, const long long n ) { return _mm512_slli_epi64(a, n); }
__forceinline const vllong8 operator >>( const vllong8& a, const long long n ) { return _mm512_srai_epi64(a, n); }
__forceinline vllong8 operator <<(const vllong8& a, long long n) { return _mm512_slli_epi64(a, n); }
__forceinline vllong8 operator >>(const vllong8& a, long long n) { return _mm512_srai_epi64(a, n); }
__forceinline const vllong8 operator <<( const vllong8& a, const vllong8& n ) { return _mm512_sllv_epi64(a, n); }
__forceinline const vllong8 operator >>( const vllong8& a, const vllong8& n ) { return _mm512_srav_epi64(a, n); }
__forceinline vllong8 operator <<(const vllong8& a, const vllong8& n) { return _mm512_sllv_epi64(a, n); }
__forceinline vllong8 operator >>(const vllong8& a, const vllong8& n) { return _mm512_srav_epi64(a, n); }
__forceinline const vllong8 sll ( const vllong8& a, const long long b ) { return _mm512_slli_epi64(a, b); }
__forceinline const vllong8 sra ( const vllong8& a, const long long b ) { return _mm512_srai_epi64(a, b); }
__forceinline const vllong8 srl ( const vllong8& a, const long long b ) { return _mm512_srli_epi64(a, b); }
__forceinline vllong8 sll (const vllong8& a, long long b) { return _mm512_slli_epi64(a, b); }
__forceinline vllong8 sra (const vllong8& a, long long b) { return _mm512_srai_epi64(a, b); }
__forceinline vllong8 srl (const vllong8& a, long long b) { return _mm512_srli_epi64(a, b); }
__forceinline const vllong8 min( const vllong8& a, const vllong8& b ) { return _mm512_min_epi64(a, b); }
__forceinline const vllong8 min( const vllong8& a, const long long b ) { return min(a,vllong8(b)); }
__forceinline const vllong8 min( const long long a, const vllong8& b ) { return min(vllong8(a),b); }
__forceinline vllong8 min(const vllong8& a, const vllong8& b) { return _mm512_min_epi64(a, b); }
__forceinline vllong8 min(const vllong8& a, long long b) { return min(a,vllong8(b)); }
__forceinline vllong8 min(long long a, const vllong8& b) { return min(vllong8(a),b); }
__forceinline const vllong8 max( const vllong8& a, const vllong8& b ) { return _mm512_max_epi64(a, b); }
__forceinline const vllong8 max( const vllong8& a, const long long b ) { return max(a,vllong8(b)); }
__forceinline const vllong8 max( const long long a, const vllong8& b ) { return max(vllong8(a),b); }
__forceinline vllong8 max(const vllong8& a, const vllong8& b) { return _mm512_max_epi64(a, b); }
__forceinline vllong8 max(const vllong8& a, long long b) { return max(a,vllong8(b)); }
__forceinline vllong8 max(long long a, const vllong8& b) { return max(vllong8(a),b); }
__forceinline const vllong8 mask_add(const vboold8& m, const vllong8& c, const vllong8& a, const vllong8& b) { return _mm512_mask_add_epi64(c,m,a,b); }
__forceinline const vllong8 mask_sub(const vboold8& m, const vllong8& c, const vllong8& a, const vllong8& b) { return _mm512_mask_sub_epi64(c,m,a,b); }
__forceinline vllong8 mask_add(const vboold8& m, const vllong8& c, const vllong8& a, const vllong8& b) { return _mm512_mask_add_epi64(c,m,a,b); }
__forceinline vllong8 mask_sub(const vboold8& m, const vllong8& c, const vllong8& a, const vllong8& b) { return _mm512_mask_sub_epi64(c,m,a,b); }
__forceinline const vllong8 mask_and(const vboold8& m, const vllong8& c, const vllong8& a, const vllong8& b) { return _mm512_mask_and_epi64(c,m,a,b); }
__forceinline const vllong8 mask_or (const vboold8& m, const vllong8& c, const vllong8& a, const vllong8& b) { return _mm512_mask_or_epi64(c,m,a,b); }
__forceinline vllong8 mask_and(const vboold8& m, const vllong8& c, const vllong8& a, const vllong8& b) { return _mm512_mask_and_epi64(c,m,a,b); }
__forceinline vllong8 mask_or (const vboold8& m, const vllong8& c, const vllong8& a, const vllong8& b) { return _mm512_mask_or_epi64(c,m,a,b); }
////////////////////////////////////////////////////////////////////////////////
/// Assignment Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline vllong8& operator +=( vllong8& a, const vllong8& b ) { return a = a + b; }
__forceinline vllong8& operator +=( vllong8& a, const long long b ) { return a = a + b; }
__forceinline vllong8& operator +=(vllong8& a, const vllong8& b) { return a = a + b; }
__forceinline vllong8& operator +=(vllong8& a, long long b) { return a = a + b; }
__forceinline vllong8& operator -=( vllong8& a, const vllong8& b ) { return a = a - b; }
__forceinline vllong8& operator -=( vllong8& a, const long long b ) { return a = a - b; }
__forceinline vllong8& operator -=(vllong8& a, const vllong8& b) { return a = a - b; }
__forceinline vllong8& operator -=(vllong8& a, long long b) { return a = a - b; }
__forceinline vllong8& operator *=( vllong8& a, const vllong8& b ) { return a = a * b; }
__forceinline vllong8& operator *=( vllong8& a, const long long b ) { return a = a * b; }
__forceinline vllong8& operator *=(vllong8& a, const vllong8& b) { return a = a * b; }
__forceinline vllong8& operator *=(vllong8& a, long long b) { return a = a * b; }
__forceinline vllong8& operator &=( vllong8& a, const vllong8& b ) { return a = a & b; }
__forceinline vllong8& operator &=( vllong8& a, const long long b ) { return a = a & b; }
__forceinline vllong8& operator &=(vllong8& a, const vllong8& b) { return a = a & b; }
__forceinline vllong8& operator &=(vllong8& a, long long b) { return a = a & b; }
__forceinline vllong8& operator |=( vllong8& a, const vllong8& b ) { return a = a | b; }
__forceinline vllong8& operator |=( vllong8& a, const long long b ) { return a = a | b; }
__forceinline vllong8& operator |=(vllong8& a, const vllong8& b) { return a = a | b; }
__forceinline vllong8& operator |=(vllong8& a, long long b) { return a = a | b; }
__forceinline vllong8& operator <<=( vllong8& a, const long long b ) { return a = a << b; }
__forceinline vllong8& operator >>=( vllong8& a, const long long b ) { return a = a >> b; }
__forceinline vllong8& operator <<=(vllong8& a, long long b) { return a = a << b; }
__forceinline vllong8& operator >>=(vllong8& a, long long b) { return a = a >> b; }
////////////////////////////////////////////////////////////////////////////////
/// Comparison Operators + Select
////////////////////////////////////////////////////////////////////////////////
__forceinline const vboold8 operator ==( const vllong8& a, const vllong8& b ) { return _mm512_cmp_epi64_mask(a,b,_MM_CMPINT_EQ); }
__forceinline const vboold8 operator ==( const vllong8& a, const long long b ) { return a == vllong8(b); }
__forceinline const vboold8 operator ==( const long long a, const vllong8& b ) { return vllong8(a) == b; }
__forceinline vboold8 operator ==(const vllong8& a, const vllong8& b) { return _mm512_cmp_epi64_mask(a,b,_MM_CMPINT_EQ); }
__forceinline vboold8 operator ==(const vllong8& a, long long b) { return a == vllong8(b); }
__forceinline vboold8 operator ==(long long a, const vllong8& b) { return vllong8(a) == b; }
__forceinline const vboold8 operator !=( const vllong8& a, const vllong8& b ) { return _mm512_cmp_epi64_mask(a,b,_MM_CMPINT_NE); }
__forceinline const vboold8 operator !=( const vllong8& a, const long long b ) { return a != vllong8(b); }
__forceinline const vboold8 operator !=( const long long a, const vllong8& b ) { return vllong8(a) != b; }
__forceinline vboold8 operator !=(const vllong8& a, const vllong8& b) { return _mm512_cmp_epi64_mask(a,b,_MM_CMPINT_NE); }
__forceinline vboold8 operator !=(const vllong8& a, long long b) { return a != vllong8(b); }
__forceinline vboold8 operator !=(long long a, const vllong8& b) { return vllong8(a) != b; }
__forceinline const vboold8 operator < ( const vllong8& a, const vllong8& b ) { return _mm512_cmp_epi64_mask(a,b,_MM_CMPINT_LT); }
__forceinline const vboold8 operator < ( const vllong8& a, const long long b ) { return a < vllong8(b); }
__forceinline const vboold8 operator < ( const long long a, const vllong8& b ) { return vllong8(a) < b; }
__forceinline vboold8 operator < (const vllong8& a, const vllong8& b) { return _mm512_cmp_epi64_mask(a,b,_MM_CMPINT_LT); }
__forceinline vboold8 operator < (const vllong8& a, long long b) { return a < vllong8(b); }
__forceinline vboold8 operator < (long long a, const vllong8& b) { return vllong8(a) < b; }
__forceinline const vboold8 operator >=( const vllong8& a, const vllong8& b ) { return _mm512_cmp_epi64_mask(a,b,_MM_CMPINT_GE); }
__forceinline const vboold8 operator >=( const vllong8& a, const long long b ) { return a >= vllong8(b); }
__forceinline const vboold8 operator >=( const long long a, const vllong8& b ) { return vllong8(a) >= b; }
__forceinline vboold8 operator >=(const vllong8& a, const vllong8& b) { return _mm512_cmp_epi64_mask(a,b,_MM_CMPINT_GE); }
__forceinline vboold8 operator >=(const vllong8& a, long long b) { return a >= vllong8(b); }
__forceinline vboold8 operator >=(long long a, const vllong8& b) { return vllong8(a) >= b; }
__forceinline const vboold8 operator > ( const vllong8& a, const vllong8& b ) { return _mm512_cmp_epi64_mask(a,b,_MM_CMPINT_GT); }
__forceinline const vboold8 operator > ( const vllong8& a, const long long b ) { return a > vllong8(b); }
__forceinline const vboold8 operator > ( const long long a, const vllong8& b ) { return vllong8(a) > b; }
__forceinline vboold8 operator > (const vllong8& a, const vllong8& b) { return _mm512_cmp_epi64_mask(a,b,_MM_CMPINT_GT); }
__forceinline vboold8 operator > (const vllong8& a, long long b) { return a > vllong8(b); }
__forceinline vboold8 operator > (long long a, const vllong8& b) { return vllong8(a) > b; }
__forceinline const vboold8 operator <=( const vllong8& a, const vllong8& b ) { return _mm512_cmp_epi64_mask(a,b,_MM_CMPINT_LE); }
__forceinline const vboold8 operator <=( const vllong8& a, const long long b ) { return a <= vllong8(b); }
__forceinline const vboold8 operator <=( const long long a, const vllong8& b ) { return vllong8(a) <= b; }
__forceinline vboold8 operator <=(const vllong8& a, const vllong8& b) { return _mm512_cmp_epi64_mask(a,b,_MM_CMPINT_LE); }
__forceinline vboold8 operator <=(const vllong8& a, long long b) { return a <= vllong8(b); }
__forceinline vboold8 operator <=(long long a, const vllong8& b) { return vllong8(a) <= b; }
__forceinline vboold8 eq(const vllong8& a, const vllong8& b) { return _mm512_cmp_epi64_mask(a,b,_MM_CMPINT_EQ); }
__forceinline vboold8 ne(const vllong8& a, const vllong8& b) { return _mm512_cmp_epi64_mask(a,b,_MM_CMPINT_NE); }
@@ -278,7 +277,7 @@ namespace embree
__forceinline vboold8 gt(const vboold8 mask, const vllong8& a, const vllong8& b) { return _mm512_mask_cmp_epi64_mask(mask,a,b,_MM_CMPINT_GT); }
__forceinline vboold8 le(const vboold8 mask, const vllong8& a, const vllong8& b) { return _mm512_mask_cmp_epi64_mask(mask,a,b,_MM_CMPINT_LE); }
__forceinline const vllong8 select( const vboold8& m, const vllong8& t, const vllong8& f ) {
__forceinline vllong8 select(const vboold8& m, const vllong8& t, const vllong8& f) {
return _mm512_mask_or_epi64(f,m,t,t);
}
@@ -298,38 +297,41 @@ namespace embree
// Movement/Shifting/Shuffling Functions
////////////////////////////////////////////////////////////////////////////////
template<size_t i>
__forceinline const vllong8 shuffle( const vllong8& a ) {
return _mm512_castpd_si512(_mm512_permute_pd(_mm512_castsi512_pd(a), _MM_SHUFFLE(i, i, i, i)));
}
template<int A, int B, int C, int D>
__forceinline vllong8 shuffle (const vllong8& v) {
return _mm512_castpd_si512(_mm512_permute_pd(_mm512_castsi512_pd(v),_MM_SHUFFLE(D,C,B,A)));
template<int i0, int i1>
__forceinline vllong8 shuffle(const vllong8& v) {
return _mm512_castpd_si512(_mm512_permute_pd(_mm512_castsi512_pd(v), (i1 << 7) | (i0 << 6) | (i1 << 5) | (i0 << 4) | (i1 << 3) | (i0 << 2) | (i1 << 1) | i0));
}
template<int i>
__forceinline vllong8 shuffle4(const vllong8& x) {
return _mm512_castpd_si512(_mm512_shuffle_f64x2(_mm512_castsi512_pd(x),_mm512_castsi512_pd(x),_MM_SHUFFLE(i,i,i,i)));
__forceinline vllong8 shuffle(const vllong8& v) {
return shuffle<i, i>(v);
}
template<int A, int B>
__forceinline vllong8 shuffle4(const vllong8& x) {
return _mm512_castpd_si512(_mm512_shuffle_f64x2(_mm512_castsi512_pd(x),_mm512_castsi512_pd(x),_MM_SHUFFLE(0,0,B,A)));
template<int i0, int i1, int i2, int i3>
__forceinline vllong8 shuffle(const vllong8& v) {
return _mm512_permutex_epi64(v, _MM_SHUFFLE(i3, i2, i1, i0));
}
template<int i0, int i1>
__forceinline vllong8 shuffle4(const vllong8& v) {
return _mm512_shuffle_i64x2(v, v, _MM_SHUFFLE(i1*2+1, i1*2, i0*2+1, i0*2));
}
template<int i>
__forceinline vllong8 align_shift_right(const vllong8& a, const vllong8& b)
{
return _mm512_alignr_epi64(a,b,i);
__forceinline vllong8 shuffle4(const vllong8& v) {
return shuffle4<i, i>(v);
}
template<int i>
__forceinline vllong8 align_shift_right(const vllong8& a, const vllong8& b) {
return _mm512_alignr_epi64(a, b, i);
};
__forceinline long long toScalar(const vllong8& a)
{
return _mm_cvtsi128_si64(_mm512_castsi512_si128(a));
__forceinline long long toScalar(const vllong8& v) {
return _mm_cvtsi128_si64(_mm512_castsi512_si128(v));
}
__forceinline vllong8 zeroExtend32Bit(const __m512i &a) {
__forceinline vllong8 zeroExtend32Bit(const __m512i& a) {
return _mm512_cvtepu32_epi64(_mm512_castsi512_si256(a));
}
@@ -337,13 +339,13 @@ namespace embree
/// Reductions
////////////////////////////////////////////////////////////////////////////////
__forceinline vllong8 vreduce_min2(vllong8 x) { return min(x,shuffle<1,0,3,2>(x)); }
__forceinline vllong8 vreduce_min4(vllong8 x) { x = vreduce_min2(x); return min(x,shuffle<2,3,0,1>(x)); }
__forceinline vllong8 vreduce_min (vllong8 x) { x = vreduce_min4(x); return min(x,shuffle4<1,0>(x)); }
__forceinline vllong8 vreduce_min2(vllong8 x) { return min(x, shuffle<1,0,3,2>(x)); }
__forceinline vllong8 vreduce_min4(vllong8 x) { x = vreduce_min2(x); return min(x, shuffle<2,3,0,1>(x)); }
__forceinline vllong8 vreduce_min (vllong8 x) { x = vreduce_min4(x); return min(x, shuffle4<1,0>(x)); }
__forceinline vllong8 vreduce_max2(vllong8 x) { return max(x,shuffle<1,0,3,2>(x)); }
__forceinline vllong8 vreduce_max4(vllong8 x) { x = vreduce_max2(x); return max(x,shuffle<2,3,0,1>(x)); }
__forceinline vllong8 vreduce_max (vllong8 x) { x = vreduce_max4(x); return max(x,shuffle4<1,0>(x)); }
__forceinline vllong8 vreduce_max2(vllong8 x) { return max(x, shuffle<1,0,3,2>(x)); }
__forceinline vllong8 vreduce_max4(vllong8 x) { x = vreduce_max2(x); return max(x, shuffle<2,3,0,1>(x)); }
__forceinline vllong8 vreduce_max (vllong8 x) { x = vreduce_max4(x); return max(x, shuffle4<1,0>(x)); }
__forceinline vllong8 vreduce_and2(vllong8 x) { return x & shuffle<1,0,3,2>(x); }
__forceinline vllong8 vreduce_and4(vllong8 x) { x = vreduce_and2(x); return x & shuffle<2,3,0,1>(x); }
@@ -379,7 +381,7 @@ namespace embree
/// Output Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline std::ostream& operator<<(std::ostream& cout, const vllong8& v)
__forceinline std::ostream& operator <<(std::ostream& cout, const vllong8& v)
{
cout << "<" << v[0];
for (size_t i=1; i<8; i++) cout << ", " << v[i];
+145 -147
View File
@@ -38,24 +38,24 @@ namespace embree
__forceinline vuint() {}
__forceinline vuint(const vuint16& t) { v = t.v; }
__forceinline vuint16& operator=(const vuint16& f) { v = f.v; return *this; }
__forceinline vuint16& operator =(const vuint16& f) { v = f.v; return *this; }
__forceinline vuint(const __m512i& t) { v = t; }
__forceinline operator __m512i () const { return v; }
__forceinline operator __m256i () const { return _mm512_castsi512_si256(v); }
__forceinline operator __m512i() const { return v; }
__forceinline operator __m256i() const { return _mm512_castsi512_si256(v); }
__forceinline vuint(const unsigned int i) {
__forceinline vuint(unsigned int i) {
v = _mm512_set1_epi32(i);
}
__forceinline vuint(const unsigned int a, const unsigned int b, const unsigned int c, const unsigned int d) {
__forceinline vuint(unsigned int a, unsigned int b, unsigned int c, unsigned int d) {
v = _mm512_set4_epi32(d,c,b,a);
}
__forceinline vuint(const unsigned int a0 , const unsigned int a1 , const unsigned int a2 , const unsigned int a3,
const unsigned int a4 , const unsigned int a5 , const unsigned int a6 , const unsigned int a7,
const unsigned int a8 , const unsigned int a9 , const unsigned int a10, const unsigned int a11,
const unsigned int a12, const unsigned int a13, const unsigned int a14, const unsigned int a15)
__forceinline vuint(unsigned int a0 , unsigned int a1 , unsigned int a2 , unsigned int a3,
unsigned int a4 , unsigned int a5 , unsigned int a6 , unsigned int a7,
unsigned int a8 , unsigned int a9 , unsigned int a10, unsigned int a11,
unsigned int a12, unsigned int a13, unsigned int a14, unsigned int a15)
{
v = _mm512_set_epi32(a15,a14,a13,a12,a11,a10,a9,a8,a7,a6,a5,a4,a3,a2,a1,a0);
}
@@ -68,20 +68,16 @@ namespace embree
/// Constants
////////////////////////////////////////////////////////////////////////////////
__forceinline vuint( ZeroTy ) : v(_mm512_setzero_epi32()) {}
__forceinline vuint( OneTy ) : v(_mm512_set1_epi32(1)) {}
__forceinline vuint( StepTy ) : v(_mm512_set_epi32(15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0)) {}
__forceinline vuint( ReverseStepTy ) : v(_mm512_setr_epi32(15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0)) {}
__forceinline static vuint16 zero() { return _mm512_setzero_epi32(); }
__forceinline static vuint16 one () { return _mm512_set1_epi32(1); }
__forceinline static vuint16 neg_one () { return _mm512_set1_epi32(-1); }
__forceinline vuint(ZeroTy) : v(_mm512_setzero_epi32()) {}
__forceinline vuint(OneTy) : v(_mm512_set1_epi32(1)) {}
__forceinline vuint(StepTy) : v(_mm512_set_epi32(15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0)) {}
__forceinline vuint(ReverseStepTy) : v(_mm512_setr_epi32(15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0)) {}
////////////////////////////////////////////////////////////////////////////////
/// Loads and Stores
////////////////////////////////////////////////////////////////////////////////
static __forceinline void store_nt(void *__restrict__ ptr, const vuint16& a) {
static __forceinline void store_nt(void* __restrict__ ptr, const vuint16& a) {
_mm512_stream_si512((__m512i*)ptr,a);
}
@@ -98,18 +94,18 @@ namespace embree
return _mm512_load_si512(addr);
}
static __forceinline vuint16 load( const unsigned short* const ptr ) { return _mm512_cvtepu16_epi32(*(__m256i*)ptr); }
static __forceinline vuint16 load(unsigned short* ptr) { return _mm512_cvtepu16_epi32(*(__m256i*)ptr); }
static __forceinline void store(void* ptr, const vuint16& v) {
_mm512_store_si512(ptr,v);
}
static __forceinline void storeu(void* ptr, const vuint16& v ) {
static __forceinline void storeu(void* ptr, const vuint16& v) {
_mm512_storeu_si512(ptr,v);
}
static __forceinline void storeu(const vboolf16& mask, int* ptr, const vuint16& f ) {
static __forceinline void storeu(const vboolf16& mask, int* ptr, const vuint16& f) {
_mm512_mask_storeu_epi32(ptr,mask,f);
}
@@ -117,20 +113,20 @@ namespace embree
_mm512_mask_store_epi32(addr,mask,v2);
}
/* pass by value to avoid compiler generating inefficient code */
static __forceinline void storeu_compact(const vboolf16 mask,void * addr, const vuint16 reg) {
/* pass by value to avoid compiler generating inefficient code */
static __forceinline void storeu_compact(const vboolf16 mask, void* addr, const vuint16 reg) {
_mm512_mask_compressstoreu_epi32(addr,mask,reg);
}
static __forceinline vuint16 compact64bit(const vboolf16& mask, vuint16 &v) {
static __forceinline vuint16 compact64bit(const vboolf16& mask, vuint16& v) {
return _mm512_mask_compress_epi64(v,mask,v);
}
static __forceinline vuint16 compact(const vboolf16& mask, vuint16 &v) {
static __forceinline vuint16 compact(const vboolf16& mask, vuint16& v) {
return _mm512_mask_compress_epi32(v,mask,v);
}
static __forceinline vuint16 compact(const vboolf16& mask, const vuint16 &a, vuint16 &b) {
static __forceinline vuint16 compact(const vboolf16& mask, const vuint16& a, vuint16& b) {
return _mm512_mask_compress_epi32(a,mask,b);
}
@@ -138,6 +134,30 @@ namespace embree
return _mm512_mask_expand_epi32(b,mask,a);
}
template<int scale = 4>
static __forceinline vuint16 gather(const unsigned int* ptr, const vint16& index) {
return _mm512_i32gather_epi32(index,ptr,scale);
}
template<int scale = 4>
static __forceinline vuint16 gather(const vboolf16& mask, const unsigned int* ptr, const vint16& index) {
return _mm512_mask_i32gather_epi32(_mm512_undefined_epi32(),mask,index,ptr,scale);
}
template<int scale = 4>
static __forceinline vuint16 gather(const vboolf16& mask, vuint16& dest, const unsigned int* ptr, const vint16& index) {
return _mm512_mask_i32gather_epi32(dest,mask,index,ptr,scale);
}
template<int scale = 4>
static __forceinline void scatter(unsigned int* ptr, const vint16& index, const vuint16& v) {
_mm512_i32scatter_epi32((int*)ptr,index,v,scale);
}
template<int scale = 4>
static __forceinline void scatter(const vboolf16& mask, unsigned int* ptr, const vint16& index, const vuint16& v) {
_mm512_mask_i32scatter_epi32((int*)ptr,mask,index,v,scale);
}
static __forceinline vuint16 broadcast64bit(size_t v) {
return _mm512_set1_epi64(v);
@@ -148,128 +168,127 @@ namespace embree
return _mm_cvtsi128_si64(_mm512_castsi512_si128(v));
}
////////////////////////////////////////////////////////////////////////////////
/// Array Access
////////////////////////////////////////////////////////////////////////////////
__forceinline unsigned int& operator[](const size_t index) { assert(index < 16); return i[index]; }
__forceinline const unsigned int& operator[](const size_t index) const { assert(index < 16); return i[index]; }
__forceinline unsigned int& operator [](size_t index) { assert(index < 16); return i[index]; }
__forceinline const unsigned int& operator [](size_t index) const { assert(index < 16); return i[index]; }
__forceinline unsigned int uint (const size_t index) const { assert(index < 16); return ((unsigned int*)i)[index]; }
__forceinline size_t& uint64_t(const size_t index) const { assert(index < 8); return ((size_t*)i)[index]; }
__forceinline unsigned int uint (size_t index) const { assert(index < 16); return ((unsigned int*)i)[index]; }
__forceinline size_t& uint64_t(size_t index) const { assert(index < 8); return ((size_t*)i)[index]; }
};
////////////////////////////////////////////////////////////////////////////////
/// Unary Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline const vuint16 asUInt ( const __m512& a ) { return _mm512_castps_si512(a); }
__forceinline const vuint16 operator +( const vuint16& a ) { return a; }
__forceinline const vuint16 operator -( const vuint16& a ) { return _mm512_sub_epi32(_mm512_setzero_epi32(), a); }
__forceinline vuint16 asUInt(const __m512& a) { return _mm512_castps_si512(a); }
__forceinline vuint16 operator +(const vuint16& a) { return a; }
__forceinline vuint16 operator -(const vuint16& a) { return _mm512_sub_epi32(_mm512_setzero_epi32(), a); }
////////////////////////////////////////////////////////////////////////////////
/// Binary Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline const vuint16 operator +( const vuint16& a, const vuint16& b ) { return _mm512_add_epi32(a, b); }
__forceinline const vuint16 operator +( const vuint16& a, const unsigned int b ) { return a + vuint16(b); }
__forceinline const vuint16 operator +( const unsigned int a, const vuint16& b ) { return vuint16(a) + b; }
__forceinline vuint16 operator +(const vuint16& a, const vuint16& b) { return _mm512_add_epi32(a, b); }
__forceinline vuint16 operator +(const vuint16& a, unsigned int b) { return a + vuint16(b); }
__forceinline vuint16 operator +(unsigned int a, const vuint16& b) { return vuint16(a) + b; }
__forceinline const vuint16 operator -( const vuint16& a, const vuint16& b ) { return _mm512_sub_epi32(a, b); }
__forceinline const vuint16 operator -( const vuint16& a, const unsigned int b ) { return a - vuint16(b); }
__forceinline const vuint16 operator -( const unsigned int a, const vuint16& b ) { return vuint16(a) - b; }
__forceinline vuint16 operator -(const vuint16& a, const vuint16& b) { return _mm512_sub_epi32(a, b); }
__forceinline vuint16 operator -(const vuint16& a, unsigned int b) { return a - vuint16(b); }
__forceinline vuint16 operator -(unsigned int a, const vuint16& b) { return vuint16(a) - b; }
__forceinline const vuint16 operator *( const vuint16& a, const vuint16& b ) { return _mm512_mul_epu32(a, b); }
__forceinline const vuint16 operator *( const vuint16& a, const unsigned int b ) { return a * vuint16(b); }
__forceinline const vuint16 operator *( const unsigned int a, const vuint16& b ) { return vuint16(a) * b; }
__forceinline vuint16 operator *(const vuint16& a, const vuint16& b) { return _mm512_mul_epu32(a, b); }
__forceinline vuint16 operator *(const vuint16& a, unsigned int b) { return a * vuint16(b); }
__forceinline vuint16 operator *(unsigned int a, const vuint16& b) { return vuint16(a) * b; }
__forceinline const vuint16 operator &( const vuint16& a, const vuint16& b ) { return _mm512_and_epi32(a, b); }
__forceinline const vuint16 operator &( const vuint16& a, const unsigned int b ) { return a & vuint16(b); }
__forceinline const vuint16 operator &( const unsigned int a, const vuint16& b ) { return vuint16(a) & b; }
__forceinline vuint16 operator &(const vuint16& a, const vuint16& b) { return _mm512_and_epi32(a, b); }
__forceinline vuint16 operator &(const vuint16& a, unsigned int b) { return a & vuint16(b); }
__forceinline vuint16 operator &(unsigned int a, const vuint16& b) { return vuint16(a) & b; }
__forceinline const vuint16 operator |( const vuint16& a, const vuint16& b ) { return _mm512_or_epi32(a, b); }
__forceinline const vuint16 operator |( const vuint16& a, const unsigned int b ) { return a | vuint16(b); }
__forceinline const vuint16 operator |( const unsigned int a, const vuint16& b ) { return vuint16(a) | b; }
__forceinline vuint16 operator |(const vuint16& a, const vuint16& b) { return _mm512_or_epi32(a, b); }
__forceinline vuint16 operator |(const vuint16& a, unsigned int b) { return a | vuint16(b); }
__forceinline vuint16 operator |(unsigned int a, const vuint16& b) { return vuint16(a) | b; }
__forceinline const vuint16 operator ^( const vuint16& a, const vuint16& b ) { return _mm512_xor_epi32(a, b); }
__forceinline const vuint16 operator ^( const vuint16& a, const unsigned int b ) { return a ^ vuint16(b); }
__forceinline const vuint16 operator ^( const unsigned int a, const vuint16& b ) { return vuint16(a) ^ b; }
__forceinline vuint16 operator ^(const vuint16& a, const vuint16& b) { return _mm512_xor_epi32(a, b); }
__forceinline vuint16 operator ^(const vuint16& a, unsigned int b) { return a ^ vuint16(b); }
__forceinline vuint16 operator ^(unsigned int a, const vuint16& b) { return vuint16(a) ^ b; }
__forceinline const vuint16 operator <<( const vuint16& a, const unsigned int n ) { return _mm512_slli_epi32(a, n); }
__forceinline const vuint16 operator >>( const vuint16& a, const unsigned int n ) { return _mm512_srli_epi32(a, n); }
__forceinline vuint16 operator <<(const vuint16& a, unsigned int n) { return _mm512_slli_epi32(a, n); }
__forceinline vuint16 operator >>(const vuint16& a, unsigned int n) { return _mm512_srli_epi32(a, n); }
__forceinline const vuint16 operator <<( const vuint16& a, const vuint16& n ) { return _mm512_sllv_epi32(a, n); }
__forceinline const vuint16 operator >>( const vuint16& a, const vuint16& n ) { return _mm512_srlv_epi32(a, n); }
__forceinline vuint16 operator <<(const vuint16& a, const vuint16& n) { return _mm512_sllv_epi32(a, n); }
__forceinline vuint16 operator >>(const vuint16& a, const vuint16& n) { return _mm512_srlv_epi32(a, n); }
__forceinline const vuint16 sll ( const vuint16& a, const unsigned int b ) { return _mm512_slli_epi32(a, b); }
__forceinline const vuint16 sra ( const vuint16& a, const unsigned int b ) { return _mm512_srai_epi32(a, b); }
__forceinline const vuint16 srl ( const vuint16& a, const unsigned int b ) { return _mm512_srli_epi32(a, b); }
__forceinline vuint16 sll (const vuint16& a, unsigned int b) { return _mm512_slli_epi32(a, b); }
__forceinline vuint16 sra (const vuint16& a, unsigned int b) { return _mm512_srai_epi32(a, b); }
__forceinline vuint16 srl (const vuint16& a, unsigned int b) { return _mm512_srli_epi32(a, b); }
__forceinline const vuint16 min( const vuint16& a, const vuint16& b ) { return _mm512_min_epu32(a, b); }
__forceinline const vuint16 min( const vuint16& a, const unsigned int b ) { return min(a,vuint16(b)); }
__forceinline const vuint16 min( const unsigned int a, const vuint16& b ) { return min(vuint16(a),b); }
__forceinline vuint16 min(const vuint16& a, const vuint16& b) { return _mm512_min_epu32(a, b); }
__forceinline vuint16 min(const vuint16& a, unsigned int b) { return min(a,vuint16(b)); }
__forceinline vuint16 min(unsigned int a, const vuint16& b) { return min(vuint16(a),b); }
__forceinline const vuint16 max( const vuint16& a, const vuint16& b ) { return _mm512_max_epu32(a, b); }
__forceinline const vuint16 max( const vuint16& a, const unsigned int b ) { return max(a,vuint16(b)); }
__forceinline const vuint16 max( const unsigned int a, const vuint16& b ) { return max(vuint16(a),b); }
__forceinline vuint16 max(const vuint16& a, const vuint16& b) { return _mm512_max_epu32(a, b); }
__forceinline vuint16 max(const vuint16& a, unsigned int b) { return max(a,vuint16(b)); }
__forceinline vuint16 max(unsigned int a, const vuint16& b) { return max(vuint16(a),b); }
__forceinline const vuint16 mask_add(const vboolf16& mask, vuint16& c, const vuint16& a, const vuint16& b) { return _mm512_mask_add_epi32(c,mask,a,b); }
__forceinline const vuint16 mask_sub(const vboolf16& mask, vuint16& c, const vuint16& a, const vuint16& b) { return _mm512_mask_sub_epi32(c,mask,a,b); }
__forceinline vuint16 mask_add(const vboolf16& mask, vuint16& c, const vuint16& a, const vuint16& b) { return _mm512_mask_add_epi32(c,mask,a,b); }
__forceinline vuint16 mask_sub(const vboolf16& mask, vuint16& c, const vuint16& a, const vuint16& b) { return _mm512_mask_sub_epi32(c,mask,a,b); }
__forceinline const vuint16 mask_and(const vboolf16& m,vuint16& c, const vuint16& a, const vuint16& b) { return _mm512_mask_and_epi32(c,m,a,b); }
__forceinline const vuint16 mask_or (const vboolf16& m,vuint16& c, const vuint16& a, const vuint16& b) { return _mm512_mask_or_epi32(c,m,a,b); }
__forceinline vuint16 mask_and(const vboolf16& m, vuint16& c, const vuint16& a, const vuint16& b) { return _mm512_mask_and_epi32(c,m,a,b); }
__forceinline vuint16 mask_or (const vboolf16& m, vuint16& c, const vuint16& a, const vuint16& b) { return _mm512_mask_or_epi32(c,m,a,b); }
////////////////////////////////////////////////////////////////////////////////
/// Assignment Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline vuint16& operator +=( vuint16& a, const vuint16& b ) { return a = a + b; }
__forceinline vuint16& operator +=( vuint16& a, const unsigned int b ) { return a = a + b; }
__forceinline vuint16& operator +=(vuint16& a, const vuint16& b) { return a = a + b; }
__forceinline vuint16& operator +=(vuint16& a, unsigned int b) { return a = a + b; }
__forceinline vuint16& operator -=( vuint16& a, const vuint16& b ) { return a = a - b; }
__forceinline vuint16& operator -=( vuint16& a, const unsigned int b ) { return a = a - b; }
__forceinline vuint16& operator -=(vuint16& a, const vuint16& b) { return a = a - b; }
__forceinline vuint16& operator -=(vuint16& a, unsigned int b) { return a = a - b; }
__forceinline vuint16& operator *=( vuint16& a, const vuint16& b ) { return a = a * b; }
__forceinline vuint16& operator *=( vuint16& a, const unsigned int b ) { return a = a * b; }
__forceinline vuint16& operator *=(vuint16& a, const vuint16& b) { return a = a * b; }
__forceinline vuint16& operator *=(vuint16& a, unsigned int b) { return a = a * b; }
__forceinline vuint16& operator &=( vuint16& a, const vuint16& b ) { return a = a & b; }
__forceinline vuint16& operator &=( vuint16& a, const unsigned int b ) { return a = a & b; }
__forceinline vuint16& operator &=(vuint16& a, const vuint16& b) { return a = a & b; }
__forceinline vuint16& operator &=(vuint16& a, unsigned int b) { return a = a & b; }
__forceinline vuint16& operator |=( vuint16& a, const vuint16& b ) { return a = a | b; }
__forceinline vuint16& operator |=( vuint16& a, const unsigned int b ) { return a = a | b; }
__forceinline vuint16& operator |=(vuint16& a, const vuint16& b) { return a = a | b; }
__forceinline vuint16& operator |=(vuint16& a, unsigned int b) { return a = a | b; }
__forceinline vuint16& operator <<=( vuint16& a, const unsigned int b ) { return a = a << b; }
__forceinline vuint16& operator >>=( vuint16& a, const unsigned int b ) { return a = a >> b; }
__forceinline vuint16& operator <<=(vuint16& a, unsigned int b) { return a = a << b; }
__forceinline vuint16& operator >>=(vuint16& a, unsigned int b) { return a = a >> b; }
////////////////////////////////////////////////////////////////////////////////
/// Comparison Operators + Select
////////////////////////////////////////////////////////////////////////////////
__forceinline const vboolf16 operator ==( const vuint16& a, const vuint16& b ) { return _mm512_cmp_epu32_mask(a,b,_MM_CMPINT_EQ); }
__forceinline const vboolf16 operator ==( const vuint16& a, const unsigned int b ) { return a == vuint16(b); }
__forceinline const vboolf16 operator ==( const unsigned int a, const vuint16& b ) { return vuint16(a) == b; }
__forceinline vboolf16 operator ==(const vuint16& a, const vuint16& b) { return _mm512_cmp_epu32_mask(a,b,_MM_CMPINT_EQ); }
__forceinline vboolf16 operator ==(const vuint16& a, unsigned int b) { return a == vuint16(b); }
__forceinline vboolf16 operator ==(unsigned int a, const vuint16& b) { return vuint16(a) == b; }
__forceinline const vboolf16 operator !=( const vuint16& a, const vuint16& b ) { return _mm512_cmp_epu32_mask(a,b,_MM_CMPINT_NE); }
__forceinline const vboolf16 operator !=( const vuint16& a, const unsigned int b ) { return a != vuint16(b); }
__forceinline const vboolf16 operator !=( const unsigned int a, const vuint16& b ) { return vuint16(a) != b; }
__forceinline vboolf16 operator !=(const vuint16& a, const vuint16& b) { return _mm512_cmp_epu32_mask(a,b,_MM_CMPINT_NE); }
__forceinline vboolf16 operator !=(const vuint16& a, unsigned int b) { return a != vuint16(b); }
__forceinline vboolf16 operator !=(unsigned int a, const vuint16& b) { return vuint16(a) != b; }
__forceinline const vboolf16 operator < ( const vuint16& a, const vuint16& b ) { return _mm512_cmp_epu32_mask(a,b,_MM_CMPINT_LT); }
__forceinline const vboolf16 operator < ( const vuint16& a, const unsigned int b ) { return a < vuint16(b); }
__forceinline const vboolf16 operator < ( const unsigned int a, const vuint16& b ) { return vuint16(a) < b; }
__forceinline vboolf16 operator < (const vuint16& a, const vuint16& b) { return _mm512_cmp_epu32_mask(a,b,_MM_CMPINT_LT); }
__forceinline vboolf16 operator < (const vuint16& a, unsigned int b) { return a < vuint16(b); }
__forceinline vboolf16 operator < (unsigned int a, const vuint16& b) { return vuint16(a) < b; }
__forceinline const vboolf16 operator >=( const vuint16& a, const vuint16& b ) { return _mm512_cmp_epu32_mask(a,b,_MM_CMPINT_GE); }
__forceinline const vboolf16 operator >=( const vuint16& a, const unsigned int b ) { return a >= vuint16(b); }
__forceinline const vboolf16 operator >=( const unsigned int a, const vuint16& b ) { return vuint16(a) >= b; }
__forceinline vboolf16 operator >=(const vuint16& a, const vuint16& b) { return _mm512_cmp_epu32_mask(a,b,_MM_CMPINT_GE); }
__forceinline vboolf16 operator >=(const vuint16& a, unsigned int b) { return a >= vuint16(b); }
__forceinline vboolf16 operator >=(unsigned int a, const vuint16& b) { return vuint16(a) >= b; }
__forceinline const vboolf16 operator > ( const vuint16& a, const vuint16& b ) { return _mm512_cmp_epu32_mask(a,b,_MM_CMPINT_GT); }
__forceinline const vboolf16 operator > ( const vuint16& a, const unsigned int b ) { return a > vuint16(b); }
__forceinline const vboolf16 operator > ( const unsigned int a, const vuint16& b ) { return vuint16(a) > b; }
__forceinline vboolf16 operator > (const vuint16& a, const vuint16& b) { return _mm512_cmp_epu32_mask(a,b,_MM_CMPINT_GT); }
__forceinline vboolf16 operator > (const vuint16& a, unsigned int b) { return a > vuint16(b); }
__forceinline vboolf16 operator > (unsigned int a, const vuint16& b) { return vuint16(a) > b; }
__forceinline const vboolf16 operator <=( const vuint16& a, const vuint16& b ) { return _mm512_cmp_epu32_mask(a,b,_MM_CMPINT_LE); }
__forceinline const vboolf16 operator <=( const vuint16& a, const unsigned int b ) { return a <= vuint16(b); }
__forceinline const vboolf16 operator <=( const unsigned int a, const vuint16& b ) { return vuint16(a) <= b; }
__forceinline vboolf16 operator <=(const vuint16& a, const vuint16& b) { return _mm512_cmp_epu32_mask(a,b,_MM_CMPINT_LE); }
__forceinline vboolf16 operator <=(const vuint16& a, unsigned int b) { return a <= vuint16(b); }
__forceinline vboolf16 operator <=(unsigned int a, const vuint16& b) { return vuint16(a) <= b; }
__forceinline vboolf16 eq(const vuint16& a, const vuint16& b) { return _mm512_cmp_epu32_mask(a,b,_MM_CMPINT_EQ); }
__forceinline vboolf16 ne(const vuint16& a, const vuint16& b) { return _mm512_cmp_epu32_mask(a,b,_MM_CMPINT_NE); }
@@ -286,7 +305,7 @@ namespace embree
__forceinline vboolf16 le(const vboolf16 mask, const vuint16& a, const vuint16& b) { return _mm512_mask_cmp_epu32_mask(mask,a,b,_MM_CMPINT_LE); }
__forceinline const vuint16 select( const vboolf16& m, const vuint16& t, const vuint16& f ) {
__forceinline vuint16 select(const vboolf16& m, const vuint16& t, const vuint16& f) {
return _mm512_mask_or_epi32(f,m,t,t);
}
@@ -306,50 +325,48 @@ namespace embree
// Movement/Shifting/Shuffling Functions
////////////////////////////////////////////////////////////////////////////////
template<size_t i>
__forceinline const vuint16 shuffle( const vuint16& a ) {
return _mm512_castps_si512(_mm512_permute_ps(_mm512_castsi512_ps(a), _MM_SHUFFLE(i, i, i, i)));
template<int i>
__forceinline vuint16 shuffle(const vuint16& v) {
return _mm512_castps_si512(_mm512_permute_ps(_mm512_castsi512_ps(v), _MM_SHUFFLE(i, i, i, i)));
}
template<int A, int B, int C, int D>
__forceinline vuint16 shuffle (const vuint16& v) {
return _mm512_castps_si512(_mm512_permute_ps(_mm512_castsi512_ps(v),_MM_SHUFFLE(D,C,B,A)));
template<int i0, int i1, int i2, int i3>
__forceinline vuint16 shuffle(const vuint16& v) {
return _mm512_castps_si512(_mm512_permute_ps(_mm512_castsi512_ps(v), _MM_SHUFFLE(i3, i2, i1, i0)));
}
template<int i>
__forceinline vuint16 shuffle4(const vuint16& x) {
return _mm512_castps_si512(_mm512_shuffle_f32x4(_mm512_castsi512_ps(x),_mm512_castsi512_ps(x),_MM_SHUFFLE(i,i,i,i)));
__forceinline vuint16 shuffle4(const vuint16& v) {
return _mm512_castps_si512(_mm512_shuffle_f32x4(_mm512_castsi512_ps(v), _mm512_castsi512_ps(v) ,_MM_SHUFFLE(i, i, i, i)));
}
template<int A, int B, int C, int D>
__forceinline vuint16 shuffle4(const vuint16& x) {
return _mm512_castps_si512(_mm512_shuffle_f32x4(_mm512_castsi512_ps(x),_mm512_castsi512_ps(x),_MM_SHUFFLE(D,C,B,A)));
template<int i0, int i1, int i2, int i3>
__forceinline vuint16 shuffle4(const vuint16& v) {
return _mm512_castps_si512(_mm512_shuffle_f32x4(_mm512_castsi512_ps(v), _mm512_castsi512_ps(v), _MM_SHUFFLE(i3, i2, i1, i0)));
}
template<int i>
__forceinline vuint16 align_shift_right(const vuint16& a, const vuint16& b)
{
return _mm512_alignr_epi32(a,b,i);
__forceinline vuint16 align_shift_right(const vuint16& a, const vuint16& b) {
return _mm512_alignr_epi32(a, b, i);
};
__forceinline unsigned int toScalar(const vuint16& a)
{
return _mm_cvtsi128_si32(_mm512_castsi512_si128(a));
__forceinline unsigned int toScalar(const vuint16& v) {
return _mm_cvtsi128_si32(_mm512_castsi512_si128(v));
}
////////////////////////////////////////////////////////////////////////////////
/// Reductions
////////////////////////////////////////////////////////////////////////////////
__forceinline vuint16 vreduce_min2(vuint16 x) { return min(x,shuffle<1,0,3,2>(x)); }
__forceinline vuint16 vreduce_min4(vuint16 x) { x = vreduce_min2(x); return min(x,shuffle<2,3,0,1>(x)); }
__forceinline vuint16 vreduce_min8(vuint16 x) { x = vreduce_min4(x); return min(x,shuffle4<1,0,3,2>(x)); }
__forceinline vuint16 vreduce_min (vuint16 x) { x = vreduce_min8(x); return min(x,shuffle4<2,3,0,1>(x)); }
__forceinline vuint16 vreduce_min2(vuint16 x) { return min(x, shuffle<1,0,3,2>(x)); }
__forceinline vuint16 vreduce_min4(vuint16 x) { x = vreduce_min2(x); return min(x, shuffle<2,3,0,1>(x)); }
__forceinline vuint16 vreduce_min8(vuint16 x) { x = vreduce_min4(x); return min(x, shuffle4<1,0,3,2>(x)); }
__forceinline vuint16 vreduce_min (vuint16 x) { x = vreduce_min8(x); return min(x, shuffle4<2,3,0,1>(x)); }
__forceinline vuint16 vreduce_max2(vuint16 x) { return max(x,shuffle<1,0,3,2>(x)); }
__forceinline vuint16 vreduce_max4(vuint16 x) { x = vreduce_max2(x); return max(x,shuffle<2,3,0,1>(x)); }
__forceinline vuint16 vreduce_max8(vuint16 x) { x = vreduce_max4(x); return max(x,shuffle4<1,0,3,2>(x)); }
__forceinline vuint16 vreduce_max (vuint16 x) { x = vreduce_max8(x); return max(x,shuffle4<2,3,0,1>(x)); }
__forceinline vuint16 vreduce_max2(vuint16 x) { return max(x, shuffle<1,0,3,2>(x)); }
__forceinline vuint16 vreduce_max4(vuint16 x) { x = vreduce_max2(x); return max(x, shuffle<2,3,0,1>(x)); }
__forceinline vuint16 vreduce_max8(vuint16 x) { x = vreduce_max4(x); return max(x, shuffle4<1,0,3,2>(x)); }
__forceinline vuint16 vreduce_max (vuint16 x) { x = vreduce_max8(x); return max(x, shuffle4<2,3,0,1>(x)); }
__forceinline vuint16 vreduce_and2(vuint16 x) { return x & shuffle<1,0,3,2>(x); }
__forceinline vuint16 vreduce_and4(vuint16 x) { x = vreduce_and2(x); return x & shuffle<2,3,0,1>(x); }
@@ -375,31 +392,12 @@ namespace embree
////////////////////////////////////////////////////////////////////////////////
/// Memory load and store operations
////////////////////////////////////////////////////////////////////////////////
template<int scale = 4>
__forceinline vuint16 gather16i(const vboolf16& mask, const unsigned int *const ptr, const vuint16& index) {
return _mm512_mask_i32gather_epi32(_mm512_undefined_epi32(),mask,index,ptr,scale);
}
template<int scale = 4>
__forceinline vuint16 gather16i(const vboolf16& mask, vuint16& dest, const unsigned int *const ptr, const vuint16& index) {
return _mm512_mask_i32gather_epi32(dest,mask,index,ptr,scale);
}
template<int scale = 4>
__forceinline void scatter16i(const vboolf16& mask,unsigned int *const ptr, const vuint16& index,const vuint16& v) {
_mm512_mask_i32scatter_epi32((int*)ptr,mask,index,v,scale);
}
__forceinline void compactustore16i_low(const vboolf16 mask, void *addr, const vuint16& reg) {
_mm512_mask_compressstoreu_epi32(addr,mask,reg);
}
__forceinline vuint16 permute(vuint16 v,vuint16 index) {
__forceinline vuint16 permute(vuint16 v, vuint16 index) {
return _mm512_permutexvar_epi32(index,v);
}
__forceinline vuint16 reverse(const vuint16 &a) {
__forceinline vuint16 reverse(const vuint16& a) {
return permute(a,vuint16(reverse_step));
}
@@ -429,7 +427,7 @@ namespace embree
/// Output Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline std::ostream& operator<<(std::ostream& cout, const vuint16& v)
__forceinline std::ostream& operator <<(std::ostream& cout, const vuint16& v)
{
cout << "<" << v[0];
for (int i=1; i<16; i++) cout << ", " << v[i];
+172 -143
View File
@@ -28,88 +28,85 @@ namespace embree
typedef vuint4 Int;
typedef vfloat4 Float;
enum { size = 4 }; // number of SIMD elements
union { __m128i v; unsigned i[4]; }; // data
enum { size = 4 }; // number of SIMD elements
union { __m128i v; unsigned int i[4]; }; // data
////////////////////////////////////////////////////////////////////////////////
/// Constructors, Assignment & Cast Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline vuint ( ) {}
__forceinline vuint ( const vuint4& a ) { v = a.v; }
__forceinline vuint4& operator=( const vuint4& a ) { v = a.v; return *this; }
__forceinline vuint() {}
__forceinline vuint(const vuint4& a) { v = a.v; }
__forceinline vuint4& operator =(const vuint4& a) { v = a.v; return *this; }
__forceinline vuint( const __m128i a ) : v(a) {}
__forceinline operator const __m128i&( void ) const { return v; }
__forceinline operator __m128i&( void ) { return v; }
__forceinline vuint(const __m128i a) : v(a) {}
__forceinline operator const __m128i&() const { return v; }
__forceinline operator __m128i&() { return v; }
__forceinline vuint( const unsigned& a ) : v(_mm_shuffle_epi32(_mm_castps_si128(_mm_load_ss((float*)&a)), _MM_SHUFFLE(0, 0, 0, 0))) {}
#if defined(__X86_64__)
__forceinline vuint( const size_t a ) : v(_mm_set1_epi32((int)a)) {}
#endif
__forceinline vuint( unsigned a, unsigned b, unsigned c, unsigned d) : v(_mm_set_epi32(d, c, b, a)) {}
__forceinline vuint(unsigned int a) : v(_mm_set1_epi32(a)) {}
__forceinline vuint(unsigned int a, unsigned int b, unsigned int c, unsigned int d) : v(_mm_set_epi32(d, c, b, a)) {}
//__forceinline explicit vuint( const __m128 a ) : v(_mm_cvtps_epu32(a)) {}
//__forceinline explicit vuint(__m128 a) : v(_mm_cvtps_epu32(a)) {}
#if defined(__AVX512VL__)
__forceinline explicit vuint( const vboolf4 &a ) : v(_mm_movm_epi32(a)) {}
__forceinline explicit vuint(const vboolf4& a) : v(_mm_movm_epi32(a)) {}
#else
__forceinline explicit vuint( const vboolf4 &a ) : v(_mm_castps_si128((__m128)a)) {}
__forceinline explicit vuint(const vboolf4& a) : v(_mm_castps_si128((__m128)a)) {}
#endif
////////////////////////////////////////////////////////////////////////////////
/// Constants
////////////////////////////////////////////////////////////////////////////////
__forceinline vuint( ZeroTy ) : v(_mm_setzero_si128()) {}
__forceinline vuint( OneTy ) : v(_mm_set1_epi32(1)) {}
__forceinline vuint( PosInfTy ) : v(_mm_set1_epi32(unsigned(pos_inf))) {}
__forceinline vuint( StepTy ) : v(_mm_set_epi32(3, 2, 1, 0)) {}
__forceinline vuint( TrueTy ) { v = _mm_cmpeq_epi32(v,v); }
__forceinline vuint(ZeroTy) : v(_mm_setzero_si128()) {}
__forceinline vuint(OneTy) : v(_mm_set1_epi32(1)) {}
__forceinline vuint(PosInfTy) : v(_mm_set1_epi32(unsigned(pos_inf))) {}
__forceinline vuint(StepTy) : v(_mm_set_epi32(3, 2, 1, 0)) {}
__forceinline vuint(TrueTy) { v = _mm_cmpeq_epi32(v,v); }
__forceinline vuint(UndefinedTy) : v(_mm_castps_si128(_mm_undefined_ps())) {}
////////////////////////////////////////////////////////////////////////////////
/// Loads and Stores
////////////////////////////////////////////////////////////////////////////////
static __forceinline vuint4 load ( const void* const a ) { return _mm_load_si128((__m128i*)a); }
static __forceinline vuint4 loadu( const void* const a ) { return _mm_loadu_si128((__m128i*)a); }
static __forceinline vuint4 load (const void* a) { return _mm_load_si128((__m128i*)a); }
static __forceinline vuint4 loadu(const void* a) { return _mm_loadu_si128((__m128i*)a); }
static __forceinline void store (void* ptr, const vuint4& v) { _mm_store_si128((__m128i*)ptr,v); }
static __forceinline void storeu(void* ptr, const vuint4& v) { _mm_storeu_si128((__m128i*)ptr,v); }
#if defined(__AVX512VL__)
static __forceinline vuint4 load ( const vboolf4& mask, const void* const ptr ) { return _mm_mask_load_epi32 (_mm_setzero_si128(),mask,ptr); }
static __forceinline vuint4 loadu( const vboolf4& mask, const void* const ptr ) { return _mm_mask_loadu_epi32(_mm_setzero_si128(),mask,ptr); }
static __forceinline vuint4 load (const vboolf4& mask, const void* ptr) { return _mm_mask_load_epi32 (_mm_setzero_si128(),mask,ptr); }
static __forceinline vuint4 loadu(const vboolf4& mask, const void* ptr) { return _mm_mask_loadu_epi32(_mm_setzero_si128(),mask,ptr); }
static __forceinline void store ( const vboolf4& mask, void* ptr, const vuint4& v ) { _mm_mask_store_epi32 (ptr,mask,v); }
static __forceinline void storeu( const vboolf4& mask, void* ptr, const vuint4& v ) { _mm_mask_storeu_epi32(ptr,mask,v); }
static __forceinline void store (const vboolf4& mask, void* ptr, const vuint4& v) { _mm_mask_store_epi32 (ptr,mask,v); }
static __forceinline void storeu(const vboolf4& mask, void* ptr, const vuint4& v) { _mm_mask_storeu_epi32(ptr,mask,v); }
#elif defined(__AVX__)
static __forceinline vuint4 load ( const vbool4& mask, const void* const a ) { return _mm_castps_si128(_mm_maskload_ps((float*)a,mask)); }
static __forceinline vuint4 loadu( const vbool4& mask, const void* const a ) { return _mm_castps_si128(_mm_maskload_ps((float*)a,mask)); }
static __forceinline vuint4 load (const vbool4& mask, const void* a) { return _mm_castps_si128(_mm_maskload_ps((float*)a,mask)); }
static __forceinline vuint4 loadu(const vbool4& mask, const void* a) { return _mm_castps_si128(_mm_maskload_ps((float*)a,mask)); }
static __forceinline void store ( const vboolf4& mask, void* ptr, const vuint4& i ) { _mm_maskstore_ps((float*)ptr,(__m128i)mask,_mm_castsi128_ps(i)); }
static __forceinline void storeu( const vboolf4& mask, void* ptr, const vuint4& i ) { _mm_maskstore_ps((float*)ptr,(__m128i)mask,_mm_castsi128_ps(i)); }
static __forceinline void store (const vboolf4& mask, void* ptr, const vuint4& i) { _mm_maskstore_ps((float*)ptr,(__m128i)mask,_mm_castsi128_ps(i)); }
static __forceinline void storeu(const vboolf4& mask, void* ptr, const vuint4& i) { _mm_maskstore_ps((float*)ptr,(__m128i)mask,_mm_castsi128_ps(i)); }
#else
static __forceinline vuint4 load ( const vbool4& mask, const void* const a ) { return _mm_and_si128(_mm_load_si128 ((__m128i*)a),mask); }
static __forceinline vuint4 loadu( const vbool4& mask, const void* const a ) { return _mm_and_si128(_mm_loadu_si128((__m128i*)a),mask); }
static __forceinline vuint4 load (const vbool4& mask, const void* a) { return _mm_and_si128(_mm_load_si128 ((__m128i*)a),mask); }
static __forceinline vuint4 loadu(const vbool4& mask, const void* a) { return _mm_and_si128(_mm_loadu_si128((__m128i*)a),mask); }
static __forceinline void store ( const vboolf4& mask, void* ptr, const vuint4& i ) { store (ptr,select(mask,i,load (ptr))); }
static __forceinline void storeu( const vboolf4& mask, void* ptr, const vuint4& i ) { storeu(ptr,select(mask,i,loadu(ptr))); }
static __forceinline void store (const vboolf4& mask, void* ptr, const vuint4& i) { store (ptr,select(mask,i,load (ptr))); }
static __forceinline void storeu(const vboolf4& mask, void* ptr, const vuint4& i) { storeu(ptr,select(mask,i,loadu(ptr))); }
#endif
#if defined(__SSE4_1__)
static __forceinline vuint4 load( const unsigned char* const ptr ) {
static __forceinline vuint4 load(const unsigned char* ptr) {
return _mm_cvtepu8_epi32(_mm_load_si128((__m128i*)ptr));
}
static __forceinline vuint4 loadu( const unsigned char* const ptr ) {
static __forceinline vuint4 loadu(const unsigned char* ptr) {
return _mm_cvtepu8_epi32(_mm_loadu_si128((__m128i*)ptr));
}
#endif
static __forceinline vuint4 load(const unsigned short* const ptr) {
static __forceinline vuint4 load(const unsigned short* ptr) {
#if defined (__SSE4_1__)
return _mm_cvtepu16_epi32(_mm_loadu_si128((__m128i*)ptr));
#else
@@ -117,7 +114,7 @@ namespace embree
#endif
}
static __forceinline void store_uchar( unsigned char* const ptr, const vuint4& v ) {
static __forceinline void store_uchar(unsigned char* ptr, const vuint4& v) {
#if defined(__SSE4_1__)
__m128i x = v;
x = _mm_packus_epi32(x, x);
@@ -129,12 +126,12 @@ namespace embree
#endif
}
static __forceinline void store_uchar( unsigned short* const ptr, const vuint4& v ) {
static __forceinline void store_uchar(unsigned short* ptr, const vuint4& v) {
for (size_t i=0;i<4;i++)
ptr[i] = (unsigned short)v[i];
}
static __forceinline vuint4 load_nt (void* ptr) {
static __forceinline vuint4 load_nt(void* ptr) {
#if defined(__SSE4_1__)
return _mm_stream_load_si128((__m128i*)ptr);
#else
@@ -150,14 +147,43 @@ namespace embree
#endif
}
template<int scale = 4>
static __forceinline vuint4 gather(const unsigned int* ptr, const vint4& index) {
#if defined(__AVX2__)
return _mm_i32gather_epi32((const int*)ptr, index, scale);
#else
return vuint4(
*(unsigned int*)(((char*)ptr)+scale*index[0]),
*(unsigned int*)(((char*)ptr)+scale*index[1]),
*(unsigned int*)(((char*)ptr)+scale*index[2]),
*(unsigned int*)(((char*)ptr)+scale*index[3]));
#endif
}
template<int scale = 4>
static __forceinline vuint4 gather(const vboolf4& mask, const unsigned int* ptr, const vint4& index) {
vuint4 r = zero;
#if defined(__AVX512VL__)
return _mm_mmask_i32gather_epi32(r, mask, index, ptr, scale);
#elif defined(__AVX2__)
return _mm_mask_i32gather_epi32(r, (const int*)ptr, index, mask, scale);
#else
if (likely(mask[0])) r[0] = *(unsigned int*)(((char*)ptr)+scale*index[0]);
if (likely(mask[1])) r[1] = *(unsigned int*)(((char*)ptr)+scale*index[1]);
if (likely(mask[2])) r[2] = *(unsigned int*)(((char*)ptr)+scale*index[2]);
if (likely(mask[3])) r[3] = *(unsigned int*)(((char*)ptr)+scale*index[3]);
return r;
#endif
}
////////////////////////////////////////////////////////////////////////////////
/// Array Access
////////////////////////////////////////////////////////////////////////////////
__forceinline const unsigned& operator []( const size_t index ) const { assert(index < 4); return i[index]; }
__forceinline unsigned& operator []( const size_t index ) { assert(index < 4); return i[index]; }
__forceinline const unsigned int& operator [](size_t index) const { assert(index < 4); return i[index]; }
__forceinline unsigned int& operator [](size_t index) { assert(index < 4); return i[index]; }
friend __forceinline const vuint4 select( const vboolf4& m, const vuint4& t, const vuint4& f ) {
friend __forceinline vuint4 select(const vboolf4& m, const vuint4& t, const vuint4& f) {
#if defined(__AVX512VL__)
return _mm_mask_blend_epi32(m, f, t);
#elif defined(__SSE4_1__)
@@ -172,110 +198,110 @@ namespace embree
/// Unary Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline const vuint4 asUint ( const __m128& a ) { return _mm_castps_si128(a); }
__forceinline const vuint4 operator +( const vuint4& a ) { return a; }
__forceinline const vuint4 operator -( const vuint4& a ) { return _mm_sub_epi32(_mm_setzero_si128(), a.v); }
__forceinline vuint4 asUint(const __m128& a) { return _mm_castps_si128(a); }
__forceinline vuint4 operator +(const vuint4& a) { return a; }
__forceinline vuint4 operator -(const vuint4& a) { return _mm_sub_epi32(_mm_setzero_si128(), a); }
////////////////////////////////////////////////////////////////////////////////
/// Binary Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline const vuint4 operator +( const vuint4& a, const vuint4& b ) { return _mm_add_epi32(a.v, b.v); }
__forceinline const vuint4 operator +( const vuint4& a, const unsigned& b ) { return a + vuint4(b); }
__forceinline const vuint4 operator +( const unsigned& a, const vuint4& b ) { return vuint4(a) + b; }
__forceinline vuint4 operator +(const vuint4& a, const vuint4& b) { return _mm_add_epi32(a, b); }
__forceinline vuint4 operator +(const vuint4& a, unsigned int b) { return a + vuint4(b); }
__forceinline vuint4 operator +(unsigned int a, const vuint4& b) { return vuint4(a) + b; }
__forceinline const vuint4 operator -( const vuint4& a, const vuint4& b ) { return _mm_sub_epi32(a.v, b.v); }
__forceinline const vuint4 operator -( const vuint4& a, const unsigned& b ) { return a - vuint4(b); }
__forceinline const vuint4 operator -( const unsigned& a, const vuint4& b ) { return vuint4(a) - b; }
__forceinline vuint4 operator -(const vuint4& a, const vuint4& b) { return _mm_sub_epi32(a, b); }
__forceinline vuint4 operator -(const vuint4& a, unsigned int b) { return a - vuint4(b); }
__forceinline vuint4 operator -(unsigned int a, const vuint4& b) { return vuint4(a) - b; }
//#if defined(__SSE4_1__)
// __forceinline const vuint4 operator *( const vuint4& a, const vuint4& b ) { return _mm_mullo_epu32(a.v, b.v); }
// __forceinline vuint4 operator *(const vuint4& a, const vuint4& b) { return _mm_mullo_epu32(a, b); }
//#else
// __forceinline const vuint4 operator *( const vuint4& a, const vuint4& b ) { return vuint4(a[0]*b[0],a[1]*b[1],a[2]*b[2],a[3]*b[3]); }
// __forceinline vuint4 operator *(const vuint4& a, const vuint4& b) { return vuint4(a[0]*b[0],a[1]*b[1],a[2]*b[2],a[3]*b[3]); }
//#endif
// __forceinline const vuint4 operator *( const vuint4& a, const unsigned& b ) { return a * vuint4(b); }
// __forceinline const vuint4 operator *( const unsigned& a, const vuint4& b ) { return vuint4(a) * b; }
// __forceinline vuint4 operator *(const vuint4& a, unsigned int b) { return a * vuint4(b); }
// __forceinline vuint4 operator *(unsigned int a, const vuint4& b) { return vuint4(a) * b; }
__forceinline const vuint4 operator &( const vuint4& a, const vuint4& b ) { return _mm_and_si128(a.v, b.v); }
__forceinline const vuint4 operator &( const vuint4& a, const unsigned& b ) { return a & vuint4(b); }
__forceinline const vuint4 operator &( const unsigned& a, const vuint4& b ) { return vuint4(a) & b; }
__forceinline vuint4 operator &(const vuint4& a, const vuint4& b) { return _mm_and_si128(a, b); }
__forceinline vuint4 operator &(const vuint4& a, unsigned int b) { return a & vuint4(b); }
__forceinline vuint4 operator &(unsigned int a, const vuint4& b) { return vuint4(a) & b; }
__forceinline const vuint4 operator |( const vuint4& a, const vuint4& b ) { return _mm_or_si128(a.v, b.v); }
__forceinline const vuint4 operator |( const vuint4& a, const unsigned& b ) { return a | vuint4(b); }
__forceinline const vuint4 operator |( const unsigned& a, const vuint4& b ) { return vuint4(a) | b; }
__forceinline vuint4 operator |(const vuint4& a, const vuint4& b) { return _mm_or_si128(a, b); }
__forceinline vuint4 operator |(const vuint4& a, unsigned int b) { return a | vuint4(b); }
__forceinline vuint4 operator |(unsigned int a, const vuint4& b) { return vuint4(a) | b; }
__forceinline const vuint4 operator ^( const vuint4& a, const vuint4& b ) { return _mm_xor_si128(a.v, b.v); }
__forceinline const vuint4 operator ^( const vuint4& a, const unsigned& b ) { return a ^ vuint4(b); }
__forceinline const vuint4 operator ^( const unsigned& a, const vuint4& b ) { return vuint4(a) ^ b; }
__forceinline vuint4 operator ^(const vuint4& a, const vuint4& b) { return _mm_xor_si128(a, b); }
__forceinline vuint4 operator ^(const vuint4& a, unsigned int b) { return a ^ vuint4(b); }
__forceinline vuint4 operator ^(unsigned int a, const vuint4& b) { return vuint4(a) ^ b; }
__forceinline const vuint4 operator <<( const vuint4& a, const unsigned& n ) { return _mm_slli_epi32(a.v, n); }
__forceinline const vuint4 operator >>( const vuint4& a, const unsigned& n ) { return _mm_srli_epi32(a.v, n); }
__forceinline vuint4 operator <<(const vuint4& a, unsigned int n) { return _mm_slli_epi32(a, n); }
__forceinline vuint4 operator >>(const vuint4& a, unsigned int n) { return _mm_srli_epi32(a, n); }
__forceinline const vuint4 sll ( const vuint4& a, const unsigned& b ) { return _mm_slli_epi32(a.v, b); }
__forceinline const vuint4 sra ( const vuint4& a, const unsigned& b ) { return _mm_srai_epi32(a.v, b); }
__forceinline const vuint4 srl ( const vuint4& a, const unsigned& b ) { return _mm_srli_epi32(a.v, b); }
__forceinline vuint4 sll (const vuint4& a, unsigned int b) { return _mm_slli_epi32(a, b); }
__forceinline vuint4 sra (const vuint4& a, unsigned int b) { return _mm_srai_epi32(a, b); }
__forceinline vuint4 srl (const vuint4& a, unsigned int b) { return _mm_srli_epi32(a, b); }
////////////////////////////////////////////////////////////////////////////////
/// Assignment Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline vuint4& operator +=( vuint4& a, const vuint4& b ) { return a = a + b; }
__forceinline vuint4& operator +=( vuint4& a, const unsigned& b ) { return a = a + b; }
__forceinline vuint4& operator +=(vuint4& a, const vuint4& b) { return a = a + b; }
__forceinline vuint4& operator +=(vuint4& a, unsigned int b) { return a = a + b; }
__forceinline vuint4& operator -=( vuint4& a, const vuint4& b ) { return a = a - b; }
__forceinline vuint4& operator -=( vuint4& a, const unsigned& b ) { return a = a - b; }
__forceinline vuint4& operator -=(vuint4& a, const vuint4& b) { return a = a - b; }
__forceinline vuint4& operator -=(vuint4& a, unsigned int b) { return a = a - b; }
//#if defined(__SSE4_1__)
// __forceinline vuint4& operator *=( vuint4& a, const vuint4& b ) { return a = a * b; }
// __forceinline vuint4& operator *=( vuint4& a, const unsigned& b ) { return a = a * b; }
// __forceinline vuint4& operator *=(vuint4& a, const vuint4& b) { return a = a * b; }
// __forceinline vuint4& operator *=(vuint4& a, unsigned int b) { return a = a * b; }
//#endif
__forceinline vuint4& operator &=( vuint4& a, const vuint4& b ) { return a = a & b; }
__forceinline vuint4& operator &=( vuint4& a, const unsigned& b ) { return a = a & b; }
__forceinline vuint4& operator &=(vuint4& a, const vuint4& b) { return a = a & b; }
__forceinline vuint4& operator &=(vuint4& a, unsigned int b) { return a = a & b; }
__forceinline vuint4& operator |=( vuint4& a, const vuint4& b ) { return a = a | b; }
__forceinline vuint4& operator |=( vuint4& a, const unsigned& b ) { return a = a | b; }
__forceinline vuint4& operator |=(vuint4& a, const vuint4& b) { return a = a | b; }
__forceinline vuint4& operator |=(vuint4& a, unsigned int b) { return a = a | b; }
__forceinline vuint4& operator <<=( vuint4& a, const unsigned& b ) { return a = a << b; }
__forceinline vuint4& operator >>=( vuint4& a, const unsigned& b ) { return a = a >> b; }
__forceinline vuint4& operator <<=(vuint4& a, unsigned int b) { return a = a << b; }
__forceinline vuint4& operator >>=(vuint4& a, unsigned int b) { return a = a >> b; }
////////////////////////////////////////////////////////////////////////////////
/// Comparison Operators + Select
////////////////////////////////////////////////////////////////////////////////
#if defined(__AVX512VL__)
__forceinline const vboolf4 operator ==( const vuint4& a, const vuint4& b ) { return _mm_cmp_epu32_mask(a,b,_MM_CMPINT_EQ); }
__forceinline const vboolf4 operator !=( const vuint4& a, const vuint4& b ) { return _mm_cmp_epu32_mask(a,b,_MM_CMPINT_NE); }
//__forceinline const vboolf4 operator < ( const vuint4& a, const vuint4& b ) { return _mm_cmp_epu32_mask(a,b,_MM_CMPINT_LT); }
//__forceinline const vboolf4 operator >=( const vuint4& a, const vuint4& b ) { return _mm_cmp_epu32_mask(a,b,_MM_CMPINT_GE); }
//__forceinline const vboolf4 operator > ( const vuint4& a, const vuint4& b ) { return _mm_cmp_epu32_mask(a,b,_MM_CMPINT_GT); }
//__forceinline const vboolf4 operator <=( const vuint4& a, const vuint4& b ) { return _mm_cmp_epu32_mask(a,b,_MM_CMPINT_LE); }
__forceinline vboolf4 operator ==(const vuint4& a, const vuint4& b) { return _mm_cmp_epu32_mask(a,b,_MM_CMPINT_EQ); }
__forceinline vboolf4 operator !=(const vuint4& a, const vuint4& b) { return _mm_cmp_epu32_mask(a,b,_MM_CMPINT_NE); }
//__forceinline vboolf4 operator < (const vuint4& a, const vuint4& b) { return _mm_cmp_epu32_mask(a,b,_MM_CMPINT_LT); }
//__forceinline vboolf4 operator >=(const vuint4& a, const vuint4& b) { return _mm_cmp_epu32_mask(a,b,_MM_CMPINT_GE); }
//__forceinline vboolf4 operator > (const vuint4& a, const vuint4& b) { return _mm_cmp_epu32_mask(a,b,_MM_CMPINT_GT); }
//__forceinline vboolf4 operator <=(const vuint4& a, const vuint4& b) { return _mm_cmp_epu32_mask(a,b,_MM_CMPINT_LE); }
#else
__forceinline const vboolf4 operator ==( const vuint4& a, const vuint4& b ) { return _mm_castsi128_ps(_mm_cmpeq_epi32(a, b)); }
__forceinline const vboolf4 operator !=( const vuint4& a, const vuint4& b ) { return !(a == b); }
//__forceinline const vboolf4 operator < ( const vuint4& a, const vuint4& b ) { return _mm_castsi128_ps(_mm_cmplt_epu32(a, b)); }
//__forceinline const vboolf4 operator >=( const vuint4& a, const vuint4& b ) { return !(a < b); }
//__forceinline const vboolf4 operator > ( const vuint4& a, const vuint4& b ) { return _mm_castsi128_ps(_mm_cmpgt_epu32(a, b)); }
//__forceinline const vboolf4 operator <=( const vuint4& a, const vuint4& b ) { return !(a > b); }
__forceinline vboolf4 operator ==(const vuint4& a, const vuint4& b) { return _mm_castsi128_ps(_mm_cmpeq_epi32(a, b)); }
__forceinline vboolf4 operator !=(const vuint4& a, const vuint4& b) { return !(a == b); }
//__forceinline vboolf4 operator < (const vuint4& a, const vuint4& b) { return _mm_castsi128_ps(_mm_cmplt_epu32(a, b)); }
//__forceinline vboolf4 operator >=(const vuint4& a, const vuint4& b) { return !(a < b); }
//__forceinline vboolf4 operator > (const vuint4& a, const vuint4& b) { return _mm_castsi128_ps(_mm_cmpgt_epu32(a, b)); }
//__forceinline vboolf4 operator <=(const vuint4& a, const vuint4& b) { return !(a > b); }
#endif
__forceinline const vboolf4 operator ==( const vuint4& a, const unsigned& b ) { return a == vuint4(b); }
__forceinline const vboolf4 operator ==( const unsigned& a, const vuint4& b ) { return vuint4(a) == b; }
__forceinline vboolf4 operator ==(const vuint4& a, unsigned int b) { return a == vuint4(b); }
__forceinline vboolf4 operator ==(unsigned int a, const vuint4& b) { return vuint4(a) == b; }
__forceinline const vboolf4 operator !=( const vuint4& a, const unsigned& b ) { return a != vuint4(b); }
__forceinline const vboolf4 operator !=( const unsigned& a, const vuint4& b ) { return vuint4(a) != b; }
__forceinline vboolf4 operator !=(const vuint4& a, unsigned int b) { return a != vuint4(b); }
__forceinline vboolf4 operator !=(unsigned int a, const vuint4& b) { return vuint4(a) != b; }
//__forceinline const vboolf4 operator < ( const vuint4& a, const unsigned& b ) { return a < vuint4(b); }
//__forceinline const vboolf4 operator < ( const unsigned& a, const vuint4& b ) { return vuint4(a) < b; }
//__forceinline vboolf4 operator < (const vuint4& a, unsigned int b) { return a < vuint4(b); }
//__forceinline vboolf4 operator < (unsigned int a, const vuint4& b) { return vuint4(a) < b; }
//__forceinline const vboolf4 operator >=( const vuint4& a, const unsigned& b ) { return a >= vuint4(b); }
//__forceinline const vboolf4 operator >=( const unsigned& a, const vuint4& b ) { return vuint4(a) >= b; }
//__forceinline vboolf4 operator >=(const vuint4& a, unsigned int b) { return a >= vuint4(b); }
//__forceinline vboolf4 operator >=(unsigned int a, const vuint4& b) { return vuint4(a) >= b; }
//__forceinline const vboolf4 operator > ( const vuint4& a, const unsigned& b ) { return a > vuint4(b); }
//__forceinline const vboolf4 operator > ( const unsigned& a, const vuint4& b ) { return vuint4(a) > b; }
//__forceinline vboolf4 operator > (const vuint4& a, unsigned int b) { return a > vuint4(b); }
//__forceinline vboolf4 operator > (unsigned int a, const vuint4& b) { return vuint4(a) > b; }
//__forceinline const vboolf4 operator <=( const vuint4& a, const unsigned& b ) { return a <= vuint4(b); }
//__forceinline const vboolf4 operator <=( const unsigned& a, const vuint4& b ) { return vuint4(a) <= b; }
//__forceinline vboolf4 operator <=(const vuint4& a, unsigned int b) { return a <= vuint4(b); }
//__forceinline vboolf4 operator <=(unsigned int a, const vuint4& b) { return vuint4(a) <= b; }
__forceinline vboolf4 eq(const vuint4& a, const vuint4& b) { return a == b; }
__forceinline vboolf4 ne(const vuint4& a, const vuint4& b) { return a != b; }
@@ -301,7 +327,7 @@ namespace embree
#endif
template<int mask>
__forceinline const vuint4 select(const vuint4& t, const vuint4& f) {
__forceinline vuint4 select(const vuint4& t, const vuint4& f) {
#if defined(__SSE4_1__)
return _mm_castps_si128(_mm_blend_ps(_mm_castsi128_ps(f), _mm_castsi128_ps(t), mask));
#else
@@ -310,56 +336,59 @@ namespace embree
}
/*#if defined(__SSE4_1__)
__forceinline const vuint4 min( const vuint4& a, const vuint4& b ) { return _mm_min_epu32(a.v, b.v); }
__forceinline const vuint4 max( const vuint4& a, const vuint4& b ) { return _mm_max_epu32(a.v, b.v); }
__forceinline vuint4 min(const vuint4& a, const vuint4& b) { return _mm_min_epu32(a, b); }
__forceinline vuint4 max(const vuint4& a, const vuint4& b) { return _mm_max_epu32(a, b); }
#else
__forceinline const vuint4 min( const vuint4& a, const vuint4& b ) { return select(a < b,a,b); }
__forceinline const vuint4 max( const vuint4& a, const vuint4& b ) { return select(a < b,b,a); }
__forceinline vuint4 min(const vuint4& a, const vuint4& b) { return select(a < b,a,b); }
__forceinline vuint4 max(const vuint4& a, const vuint4& b) { return select(a < b,b,a); }
#endif
__forceinline const vuint4 min( const vuint4& a, const unsigned& b ) { return min(a,vuint4(b)); }
__forceinline const vuint4 min( const unsigned& a, const vuint4& b ) { return min(vuint4(a),b); }
__forceinline const vuint4 max( const vuint4& a, const unsigned& b ) { return max(a,vuint4(b)); }
__forceinline const vuint4 max( const unsigned& a, const vuint4& b ) { return max(vuint4(a),b); }*/
__forceinline vuint4 min(const vuint4& a, unsigned int b) { return min(a,vuint4(b)); }
__forceinline vuint4 min(unsigned int a, const vuint4& b) { return min(vuint4(a),b); }
__forceinline vuint4 max(const vuint4& a, unsigned int b) { return max(a,vuint4(b)); }
__forceinline vuint4 max(unsigned int a, const vuint4& b) { return max(vuint4(a),b); }*/
////////////////////////////////////////////////////////////////////////////////
// Movement/Shifting/Shuffling Functions
////////////////////////////////////////////////////////////////////////////////
__forceinline vuint4 unpacklo( const vuint4& a, const vuint4& b ) { return _mm_castps_si128(_mm_unpacklo_ps(_mm_castsi128_ps(a.v), _mm_castsi128_ps(b.v))); }
__forceinline vuint4 unpackhi( const vuint4& a, const vuint4& b ) { return _mm_castps_si128(_mm_unpackhi_ps(_mm_castsi128_ps(a.v), _mm_castsi128_ps(b.v))); }
__forceinline vuint4 unpacklo(const vuint4& a, const vuint4& b) { return _mm_castps_si128(_mm_unpacklo_ps(_mm_castsi128_ps(a), _mm_castsi128_ps(b))); }
__forceinline vuint4 unpackhi(const vuint4& a, const vuint4& b) { return _mm_castps_si128(_mm_unpackhi_ps(_mm_castsi128_ps(a), _mm_castsi128_ps(b))); }
template<size_t i0, size_t i1, size_t i2, size_t i3> __forceinline const vuint4 shuffle( const vuint4& a ) {
return _mm_shuffle_epi32(a, _MM_SHUFFLE(i3, i2, i1, i0));
template<int i0, int i1, int i2, int i3>
__forceinline vuint4 shuffle(const vuint4& v) {
return _mm_shuffle_epi32(v, _MM_SHUFFLE(i3, i2, i1, i0));
}
template<size_t i0, size_t i1, size_t i2, size_t i3> __forceinline const vuint4 shuffle( const vuint4& a, const vuint4& b ) {
template<int i0, int i1, int i2, int i3>
__forceinline vuint4 shuffle(const vuint4& a, const vuint4& b) {
return _mm_castps_si128(_mm_shuffle_ps(_mm_castsi128_ps(a), _mm_castsi128_ps(b), _MM_SHUFFLE(i3, i2, i1, i0)));
}
#if defined(__SSE3__)
template<> __forceinline const vuint4 shuffle<0, 0, 2, 2>( const vuint4& a ) { return _mm_castps_si128(_mm_moveldup_ps(_mm_castsi128_ps(a))); }
template<> __forceinline const vuint4 shuffle<1, 1, 3, 3>( const vuint4& a ) { return _mm_castps_si128(_mm_movehdup_ps(_mm_castsi128_ps(a))); }
template<> __forceinline const vuint4 shuffle<0, 1, 0, 1>( const vuint4& a ) { return _mm_castpd_si128(_mm_movedup_pd (_mm_castsi128_pd(a))); }
template<> __forceinline vuint4 shuffle<0, 0, 2, 2>(const vuint4& v) { return _mm_castps_si128(_mm_moveldup_ps(_mm_castsi128_ps(v))); }
template<> __forceinline vuint4 shuffle<1, 1, 3, 3>(const vuint4& v) { return _mm_castps_si128(_mm_movehdup_ps(_mm_castsi128_ps(v))); }
template<> __forceinline vuint4 shuffle<0, 1, 0, 1>(const vuint4& v) { return _mm_castpd_si128(_mm_movedup_pd (_mm_castsi128_pd(v))); }
#endif
template<size_t i0> __forceinline const vuint4 shuffle( const vuint4& b ) {
return shuffle<i0,i0,i0,i0>(b);
template<int i>
__forceinline vuint4 shuffle(const vuint4& v) {
return shuffle<i,i,i,i>(v);
}
#if defined(__SSE4_1__)
template<size_t src> __forceinline unsigned extract( const vuint4& b ) { return _mm_extract_epi32(b, src); }
template<size_t dst> __forceinline const vuint4 insert( const vuint4& a, const unsigned b ) { return _mm_insert_epi32(a, b, dst); }
template<int src> __forceinline unsigned int extract(const vuint4& b) { return _mm_extract_epi32(b, src); }
template<int dst> __forceinline vuint4 insert(const vuint4& a, const unsigned b) { return _mm_insert_epi32(a, b, dst); }
#else
template<size_t src> __forceinline unsigned extract( const vuint4& b ) { return b[src]; }
template<size_t dst> __forceinline const vuint4 insert( const vuint4& a, const unsigned b ) { vuint4 c = a; c[dst] = b; return c; }
template<int src> __forceinline unsigned int extract(const vuint4& b) { return b[src&3]; }
template<int dst> __forceinline vuint4 insert(const vuint4& a, const unsigned b) { vuint4 c = a; c[dst&3] = b; return c; }
#endif
template<> __forceinline unsigned extract<0>( const vuint4& b ) { return _mm_cvtsi128_si32(b); }
template<> __forceinline unsigned int extract<0>(const vuint4& b) { return _mm_cvtsi128_si32(b); }
__forceinline unsigned toScalar(const vuint4& a) { return _mm_cvtsi128_si32(a); }
__forceinline unsigned int toScalar(const vuint4& v) { return _mm_cvtsi128_si32(v); }
////////////////////////////////////////////////////////////////////////////////
/// Reductions
@@ -368,13 +397,13 @@ namespace embree
#if 0
#if defined(__SSE4_1__)
__forceinline const vuint4 vreduce_min(const vuint4& v) { vuint4 h = min(shuffle<1,0,3,2>(v),v); return min(shuffle<2,3,0,1>(h),h); }
__forceinline const vuint4 vreduce_max(const vuint4& v) { vuint4 h = max(shuffle<1,0,3,2>(v),v); return max(shuffle<2,3,0,1>(h),h); }
__forceinline const vuint4 vreduce_add(const vuint4& v) { vuint4 h = shuffle<1,0,3,2>(v) + v ; return shuffle<2,3,0,1>(h) + h ; }
__forceinline vuint4 vreduce_min(const vuint4& v) { vuint4 h = min(shuffle<1,0,3,2>(v),v); return min(shuffle<2,3,0,1>(h),h); }
__forceinline vuint4 vreduce_max(const vuint4& v) { vuint4 h = max(shuffle<1,0,3,2>(v),v); return max(shuffle<2,3,0,1>(h),h); }
__forceinline vuint4 vreduce_add(const vuint4& v) { vuint4 h = shuffle<1,0,3,2>(v) + v ; return shuffle<2,3,0,1>(h) + h ; }
__forceinline unsigned reduce_min(const vuint4& v) { return toScalar(vreduce_min(v)); }
__forceinline unsigned reduce_max(const vuint4& v) { return toScalar(vreduce_max(v)); }
__forceinline unsigned reduce_add(const vuint4& v) { return toScalar(vreduce_add(v)); }
__forceinline unsigned int reduce_min(const vuint4& v) { return toScalar(vreduce_min(v)); }
__forceinline unsigned int reduce_max(const vuint4& v) { return toScalar(vreduce_max(v)); }
__forceinline unsigned int reduce_add(const vuint4& v) { return toScalar(vreduce_add(v)); }
__forceinline size_t select_min(const vuint4& v) { return __bsf(movemask(v == vreduce_min(v))); }
__forceinline size_t select_max(const vuint4& v) { return __bsf(movemask(v == vreduce_max(v))); }
@@ -384,9 +413,9 @@ namespace embree
#else
__forceinline unsigned reduce_min(const vuint4& v) { return min(v[0],v[1],v[2],v[3]); }
__forceinline unsigned reduce_max(const vuint4& v) { return max(v[0],v[1],v[2],v[3]); }
__forceinline unsigned reduce_add(const vuint4& v) { return v[0]+v[1]+v[2]+v[3]; }
__forceinline unsigned int reduce_min(const vuint4& v) { return min(v[0],v[1],v[2],v[3]); }
__forceinline unsigned int reduce_max(const vuint4& v) { return max(v[0],v[1],v[2],v[3]); }
__forceinline unsigned int reduce_add(const vuint4& v) { return v[0]+v[1]+v[2]+v[3]; }
#endif
#endif
@@ -395,7 +424,7 @@ namespace embree
/// Output Operators
////////////////////////////////////////////////////////////////////////////////
inline std::ostream& operator<<(std::ostream& cout, const vuint4& a) {
inline std::ostream& operator <<(std::ostream& cout, const vuint4& a) {
return cout << "<" << a[0] << ", " << a[1] << ", " << a[2] << ", " << a[3] << ">";
}
}
-1
View File
@@ -23,7 +23,6 @@ ADD_LIBRARY(sys STATIC
filename.cpp
library.cpp
thread.cpp
network.cpp
string.cpp
regression.cpp
mutex.cpp
+20 -9
View File
@@ -28,6 +28,9 @@ namespace embree
{
void* alignedMalloc(size_t size, size_t align)
{
if (size == 0)
return nullptr;
assert((align & (align-1)) == 0);
void* ptr = _mm_malloc(size,align);
@@ -37,8 +40,10 @@ namespace embree
return ptr;
}
void alignedFree(void* ptr) {
_mm_free(ptr);
void alignedFree(void* ptr)
{
if (ptr)
_mm_free(ptr);
}
static bool huge_pages_enabled = false;
@@ -185,6 +190,7 @@ namespace embree
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <sstream>
#if defined(__MACOSX__)
#include <mach/vm_statistics.h>
@@ -214,13 +220,18 @@ namespace embree
}
std::string line;
int val; char tag[41], unit[6];
while (getline(file,line)) {
if (sscanf(line.c_str(),"%40s %i %5s",tag,&val,unit) == 3) {
if (std::string(tag) == "Hugepagesize:" && std::string(unit) == "kB") {
hugepagesize = val*1024;
break;
}
while (getline(file,line))
{
std::stringstream sline(line);
while (!sline.eof() && sline.peek() == ' ') sline.ignore();
std::string tag; getline(sline,tag,' ');
while (!sline.eof() && sline.peek() == ' ') sline.ignore();
std::string val; getline(sline,val,' ');
while (!sline.eof() && sline.peek() == ' ') sline.ignore();
std::string unit; getline(sline,unit,' ');
if (tag == "Hugepagesize:" && unit == "kB") {
hugepagesize = std::stoi(val)*1024;
break;
}
}
+10 -8
View File
@@ -58,7 +58,7 @@ namespace embree
T items[N];
};
/*! static array with dyamic size */
/*! static array with dynamic size */
template<typename T, size_t N>
class darray_t
{
@@ -130,7 +130,8 @@ namespace embree
template<typename Ty, size_t max_stack_bytes>
struct __aligned(64) StackArray
{
__forceinline StackArray (const size_t N)
__forceinline StackArray (const size_t N)
: N(N)
{
if (N*sizeof(Ty) <= max_stack_bytes)
data = &arr[0];
@@ -145,19 +146,20 @@ namespace embree
__forceinline operator Ty* () { return data; }
__forceinline operator const Ty* () const { return data; }
__forceinline Ty& operator[](const int i) { return data[i]; }
__forceinline const Ty& operator[](const int i) const { return data[i]; }
__forceinline Ty& operator[](const int i) { assert(i>=0 && i<N); return data[i]; }
__forceinline const Ty& operator[](const int i) const { assert(i>=0 && i<N); return data[i]; }
__forceinline Ty& operator[](const unsigned i) { return data[i]; }
__forceinline const Ty& operator[](const unsigned i) const { return data[i]; }
__forceinline Ty& operator[](const unsigned i) { assert(i<N); return data[i]; }
__forceinline const Ty& operator[](const unsigned i) const { assert(i<N); return data[i]; }
#if defined(__X86_64__)
__forceinline Ty& operator[](const size_t i) { return data[i]; }
__forceinline const Ty& operator[](const size_t i) const { return data[i]; }
__forceinline Ty& operator[](const size_t i) { assert(i<N); return data[i]; }
__forceinline const Ty& operator[](const size_t i) const { assert(i<N); return data[i]; }
#endif
private:
Ty arr[max_stack_bytes/sizeof(Ty)];
Ty* data;
size_t N;
};
}
+37 -10
View File
@@ -366,7 +366,7 @@ namespace embree
size_t r = 0; asm ("btr %1,%0" : "=r"(r) : "r"(i), "0"(v) : "flags"); return r;
}
__forceinline int32_t atomic_cmpxchg( int32_t volatile* value, int32_t comparand, const int32_t input ) {
__forceinline int32_t atomic_cmpxchg(int32_t volatile* value, int32_t comparand, const int32_t input) {
return __sync_val_compare_and_swap(value, comparand, input);
}
@@ -376,6 +376,21 @@ namespace embree
/// All Platforms
////////////////////////////////////////////////////////////////////////////////
#if defined(__clang__) || defined(__GNUC__)
#if !defined(_mm_undefined_ps)
__forceinline __m128 _mm_undefined_ps() { return _mm_setzero_ps(); }
#endif
#if !defined(_mm_undefined_si128)
__forceinline __m128i _mm_undefined_si128() { return _mm_setzero_si128(); }
#endif
#if !defined(_mm256_undefined_ps) && (__AVX__)
__forceinline __m256 _mm256_undefined_ps() { return _mm256_setzero_ps(); }
#endif
#if !defined(_mm_undefined_si128) && (__AVX__)
__forceinline __m256i _mm256_undefined_si256() { return _mm256_setzero_si256(); }
#endif
#endif
#if defined(__SSE4_2__)
__forceinline int __popcnt(int in) {
@@ -403,7 +418,7 @@ namespace embree
return clock;
}
__forceinline void __pause_cpu (const size_t N = 8)
__forceinline void __pause_cpu(const size_t N = 8)
{
for (size_t i=0; i<N; i++)
_mm_pause();
@@ -430,23 +445,35 @@ namespace embree
prefetchEX(ptr);
}
#if defined(__AVX2__)
__forceinline unsigned int pext(const unsigned int a, const unsigned int b) { return _pext_u32(a,b); }
__forceinline unsigned int pdep(const unsigned int a, const unsigned int b) { return _pdep_u32(a,b); }
__forceinline unsigned int pext(unsigned int a, unsigned int b) { return _pext_u32(a, b); }
__forceinline unsigned int pdep(unsigned int a, unsigned int b) { return _pdep_u32(a, b); }
#if defined(__X86_64__)
__forceinline size_t pext(const size_t a, const size_t b) { return _pext_u64(a,b); }
__forceinline size_t pdep(const size_t a, const size_t b) { return _pdep_u64(a,b); }
__forceinline size_t pext(size_t a, size_t b) { return _pext_u64(a, b); }
__forceinline size_t pdep(size_t a, size_t b) { return _pdep_u64(a, b); }
#endif
#endif
#if defined (__AVX512F__)
__forceinline float mm512_cvtss_f32 (__m512 v) { // FIXME: _mm512_cvtss_f32 neither supported by clang v4.0.0 nor GCC 6.3
#if defined(__AVX512F__)
#if defined(__INTEL_COMPILER)
__forceinline float mm512_cvtss_f32(__m512 v) {
return _mm512_cvtss_f32(v);
}
__forceinline int mm512_mask2int(__mmask16 k1) {
return _mm512_mask2int(k1);
}
__forceinline __mmask16 mm512_int2mask(int mask) {
return _mm512_int2mask(mask);
}
#else
__forceinline float mm512_cvtss_f32(__m512 v) { // FIXME: _mm512_cvtss_f32 neither supported by clang v4.0.0 nor GCC 6.3
return _mm_cvtss_f32(_mm512_castps512_ps128(v));
}
__forceinline int mm512_mask2int (__mmask16 k1) { // FIXME: _mm512_mask2int not yet supported by GCC 6.3
__forceinline int mm512_mask2int(__mmask16 k1) { // FIXME: _mm512_mask2int not yet supported by GCC 6.3
return (int)k1;
}
__forceinline __mmask16 mm512_int2mask (int mask) { // FIXME: _mm512_int2mask not yet supported by GCC 6.3
__forceinline __mmask16 mm512_int2mask(int mask) { // FIXME: _mm512_int2mask not yet supported by GCC 6.3
return (__mmask16)mask;
}
#endif
#endif
}
+10 -10
View File
@@ -25,11 +25,11 @@
namespace embree
{
MutexSys::MutexSys( void ) { mutex = new CRITICAL_SECTION; InitializeCriticalSection((CRITICAL_SECTION*)mutex); }
MutexSys::~MutexSys( void ) { DeleteCriticalSection((CRITICAL_SECTION*)mutex); delete (CRITICAL_SECTION*)mutex; }
void MutexSys::lock( void ) { EnterCriticalSection((CRITICAL_SECTION*)mutex); }
bool MutexSys::try_lock( void ) { return TryEnterCriticalSection((CRITICAL_SECTION*)mutex) != 0; }
void MutexSys::unlock( void ) { LeaveCriticalSection((CRITICAL_SECTION*)mutex); }
MutexSys::MutexSys() { mutex = new CRITICAL_SECTION; InitializeCriticalSection((CRITICAL_SECTION*)mutex); }
MutexSys::~MutexSys() { DeleteCriticalSection((CRITICAL_SECTION*)mutex); delete (CRITICAL_SECTION*)mutex; }
void MutexSys::lock() { EnterCriticalSection((CRITICAL_SECTION*)mutex); }
bool MutexSys::try_lock() { return TryEnterCriticalSection((CRITICAL_SECTION*)mutex) != 0; }
void MutexSys::unlock() { LeaveCriticalSection((CRITICAL_SECTION*)mutex); }
}
#endif
@@ -38,31 +38,31 @@ namespace embree
namespace embree
{
/*! system mutex using pthreads */
MutexSys::MutexSys( void )
MutexSys::MutexSys()
{
mutex = new pthread_mutex_t;
if (pthread_mutex_init((pthread_mutex_t*)mutex, nullptr) != 0)
THROW_RUNTIME_ERROR("pthread_mutex_init failed");
}
MutexSys::~MutexSys( void )
MutexSys::~MutexSys()
{
MAYBE_UNUSED bool ok = pthread_mutex_destroy((pthread_mutex_t*)mutex) == 0;
assert(ok);
delete (pthread_mutex_t*)mutex;
}
void MutexSys::lock( void )
void MutexSys::lock()
{
if (pthread_mutex_lock((pthread_mutex_t*)mutex) != 0)
THROW_RUNTIME_ERROR("pthread_mutex_lock failed");
}
bool MutexSys::try_lock( void ) {
bool MutexSys::try_lock() {
return pthread_mutex_trylock((pthread_mutex_t*)mutex) == 0;
}
void MutexSys::unlock( void )
void MutexSys::unlock()
{
if (pthread_mutex_unlock((pthread_mutex_t*)mutex) != 0)
THROW_RUNTIME_ERROR("pthread_mutex_unlock failed");
+5 -5
View File
@@ -26,17 +26,17 @@ namespace embree
class MutexSys {
friend struct ConditionImplementation;
public:
MutexSys( void );
~MutexSys( void );
MutexSys();
~MutexSys();
private:
MutexSys (const MutexSys& other) DELETED; // do not implement
MutexSys& operator= (const MutexSys& other) DELETED; // do not implement
public:
void lock( void );
bool try_lock( void );
void unlock( void );
void lock();
bool try_lock();
void unlock();
protected:
void* mutex;
-355
View File
@@ -1,355 +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 "network.h"
#include "string.h"
#include "mutex.h"
////////////////////////////////////////////////////////////////////////////////
/// Platforms supporting Socket interface
////////////////////////////////////////////////////////////////////////////////
#if defined(__WIN32__)
#define _WINSOCK_DEPRECATED_NO_WARNINGS
//#include <winsock2.h>
//#include <io.h>
typedef int socklen_t;
#define SHUT_RDWR 0x2
#else
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <netdb.h>
#define SOCKET int
#define INVALID_SOCKET -1
#define closesocket ::close
#endif
/*! ignore if not supported */
#ifndef MSG_NOSIGNAL
#define MSG_NOSIGNAL 0
#endif
#define BUFFERING 1
namespace embree
{
namespace network
{
__forceinline void initialize() {
#ifdef __WIN32__
static bool initialized = false;
static MutexSys initMutex;
Lock<MutexSys> lock(initMutex);
WSADATA wsaData;
short version = MAKEWORD(1,1);
if (WSAStartup(version,&wsaData) != 0)
THROW_RUNTIME_ERROR("Winsock initialization failed");
initialized = true;
#endif
}
struct buffered_socket_t
{
buffered_socket_t (SOCKET fd, size_t isize = 64*1024, size_t osize = 64*1024)
: fd(fd),
ibuf(new char[isize]), isize(isize), istart(0), iend(0),
obuf(new char[osize]), osize(osize), oend(0) {
}
~buffered_socket_t () {
delete[] ibuf; ibuf = nullptr;
delete[] obuf; obuf = nullptr;
}
private:
buffered_socket_t (const buffered_socket_t& other) DELETED; // do not implement
buffered_socket_t& operator= (const buffered_socket_t& other) DELETED; // do not implement
public:
SOCKET fd; //!< file descriptor of the socket
char* ibuf;
size_t isize;
size_t istart,iend;
char* obuf;
size_t osize;
size_t oend;
};
struct AutoCloseSocket
{
SOCKET sock;
AutoCloseSocket (SOCKET sock) : sock(sock) {}
~AutoCloseSocket () {
if (sock != INVALID_SOCKET) {
closesocket(sock);
}
}
};
socket_t connect(const char* host, unsigned short port)
{
initialize();
/*! create a new socket */
SOCKET sockfd = ::socket(AF_INET, SOCK_STREAM, 0);
if (sockfd == INVALID_SOCKET) THROW_RUNTIME_ERROR("cannot create socket");
AutoCloseSocket auto_close(sockfd);
/*! perform DNS lookup */
struct hostent* server = ::gethostbyname(host);
if (!server)
THROW_RUNTIME_ERROR("server "+std::string(host)+" not found");
if (server->h_length != sizeof(in_addr))
THROW_RUNTIME_ERROR("gethostbyname error");
/*! perform connection */
struct sockaddr_in serv_addr;
memset((char*)&serv_addr, 0, sizeof(serv_addr));
serv_addr.sin_family = AF_INET;
serv_addr.sin_port = (unsigned short) htons(port);
serv_addr.sin_addr = *(in_addr*) server->h_addr;
if (::connect(sockfd,(struct sockaddr*) &serv_addr,sizeof(serv_addr)) < 0)
THROW_RUNTIME_ERROR("connection to "+std::string(host)+":"+toString(port)+" failed");
/*! enable TCP_NODELAY */
#ifdef TCP_NODELAY
{ int flag = 1; ::setsockopt(sockfd, IPPROTO_TCP, TCP_NODELAY, (const char*)&flag, sizeof(int)); }
#endif
/*! we do not want SIGPIPE to be thrown */
#ifdef SO_NOSIGPIPE
{ int flag = 1; setsockopt(sockfd, SOL_SOCKET, SO_NOSIGPIPE, (const char*) &flag, sizeof(int)); }
#endif
auto_close.sock = INVALID_SOCKET;
return (socket_t) new buffered_socket_t(sockfd);
}
socket_t bind(unsigned short port)
{
initialize();
/*! create a new socket */
SOCKET sockfd = ::socket(AF_INET, SOCK_STREAM, 0);
if (sockfd == INVALID_SOCKET) THROW_RUNTIME_ERROR("cannot create socket");
AutoCloseSocket auto_close(sockfd);
/* When the server completes, the server socket enters a time-wait state during which the local
address and port used by the socket are believed to be in use by the OS. The wait state may
last several minutes. This socket option allows bind() to reuse the port immediately. */
#ifdef SO_REUSEADDR
{ int flag = true; ::setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, (const char*)&flag, sizeof(int)); }
#endif
/*! bind socket to port */
struct sockaddr_in serv_addr;
memset((char *) &serv_addr, 0, sizeof(serv_addr));
serv_addr.sin_family = AF_INET;
serv_addr.sin_port = (unsigned short) htons(port);
serv_addr.sin_addr.s_addr = INADDR_ANY;
if (::bind(sockfd, (struct sockaddr*) &serv_addr, sizeof(serv_addr)) < 0)
THROW_RUNTIME_ERROR("binding to port "+toString(port)+" failed");
/*! listen to port, up to 5 pending connections */
if (::listen(sockfd,5) < 0)
THROW_RUNTIME_ERROR("listening on socket failed");
auto_close.sock = INVALID_SOCKET;
return (socket_t) new buffered_socket_t(sockfd);
}
socket_t listen(socket_t hsock)
{
SOCKET sockfd = ((buffered_socket_t*) hsock)->fd;
/*! accept incoming connection */
struct sockaddr_in addr;
socklen_t len = sizeof(addr);
SOCKET fd = ::accept(sockfd, (struct sockaddr *) &addr, &len);
if (fd == INVALID_SOCKET) THROW_RUNTIME_ERROR("cannot accept connection");
/*! enable TCP_NODELAY */
#ifdef TCP_NODELAY
{ int flag = 1; ::setsockopt(fd,IPPROTO_TCP,TCP_NODELAY,(char*)&flag,sizeof(int)); }
#endif
/*! we do not want SIGPIPE to be thrown */
#ifdef SO_NOSIGPIPE
{ int flag = 1; setsockopt(fd, SOL_SOCKET, SO_NOSIGPIPE, (void*)&flag, sizeof(int)); }
#endif
return (socket_t) new buffered_socket_t(fd);
}
void read(socket_t hsock_i, void* data_i, size_t bytes)
{
#if BUFFERING
char* data = (char*)data_i;
buffered_socket_t* hsock = (buffered_socket_t*) hsock_i;
while (bytes) {
if (hsock->istart == hsock->iend) {
ssize_t n = ::recv(hsock->fd,hsock->ibuf,int(hsock->isize),MSG_NOSIGNAL);
if (n == 0) throw Disconnect();
else if (n < 0) THROW_RUNTIME_ERROR("error reading from socket");
hsock->istart = 0;
hsock->iend = n;
}
size_t bsize = hsock->iend-hsock->istart;
if (bytes < bsize) bsize = bytes;
memcpy(data,hsock->ibuf+hsock->istart,bsize);
data += bsize;
hsock->istart += bsize;
bytes -= bsize;
}
#else
char* data = (char*) data_i;
buffered_socket_t* hsock = (buffered_socket_t*) hsock_i;
while (bytes) {
ssize_t n = ::read(hsock->fd,data,bytes);
if (n == 0) throw Disconnect();
else if (n < 0) THROW_RUNTIME_ERROR("error reading from socket");
data+=n;
bytes-=n;
}
#endif
}
void write(socket_t hsock_i, const void* data_i, size_t bytes)
{
#if BUFFERING
const char* data = (const char*) data_i;
buffered_socket_t* hsock = (buffered_socket_t*) hsock_i;
while (bytes) {
if (hsock->oend == hsock->osize) flush(hsock_i);
size_t bsize = hsock->osize-hsock->oend;
if (bytes < bsize) bsize = bytes;
memcpy(hsock->obuf+hsock->oend,data,bsize);
data += bsize;
hsock->oend += bsize;
bytes -= bsize;
}
#else
const char* data = (const char*) data_i;
buffered_socket_t* hsock = (buffered_socket_t*) hsock_i;
while (bytes) {
ssize_t n = ::write(hsock->fd,data,bytes);
if (n < 0) THROW_RUNTIME_ERROR("error writing to socket");
data+=n;
bytes-=n;
}
#endif
}
void flush(socket_t hsock_i)
{
#if BUFFERING
buffered_socket_t* hsock = (buffered_socket_t*) hsock_i;
char* data = hsock->obuf;
size_t bytes = hsock->oend;
while (bytes > 0) {
ssize_t n = ::send(hsock->fd,data,(int)bytes,MSG_NOSIGNAL);
if (n < 0) THROW_RUNTIME_ERROR("error writing to socket");
bytes -= n;
data += n;
}
hsock->oend = 0;
#endif
}
void close(socket_t hsock_i) {
buffered_socket_t* hsock = (buffered_socket_t*) hsock_i;
::shutdown(hsock->fd,SHUT_RDWR);
closesocket(hsock->fd);
delete hsock;
}
}
}
////////////////////////////////////////////////////////////////////////////////
/// All Platforms
////////////////////////////////////////////////////////////////////////////////
namespace embree
{
namespace network
{
bool read_bool(socket_t socket)
{
bool value = 0;
read(socket,&value,sizeof(bool));
return value;
}
char read_char(socket_t socket)
{
char value = 0;
read(socket,&value,sizeof(char));
return value;
}
int read_int(socket_t socket)
{
int value = 0;
read(socket,&value,sizeof(int));
return value;
}
float read_float(socket_t socket)
{
float value = 0.0f;
read(socket,&value,sizeof(float));
return value;
}
std::string read_string(socket_t socket)
{
int bytes = read_int(socket);
char* str = new char[bytes+1];
read(socket,str,bytes);
str[bytes] = 0x00;
std::string s(str);
delete[] str;
return s;
}
void write(socket_t socket, bool value) {
write(socket,&value,sizeof(bool));
}
void write(socket_t socket, char value) {
write(socket,&value,sizeof(char));
}
void write(socket_t socket, int value) {
write(socket,&value,sizeof(int));
}
void write(socket_t socket, float value) {
write(socket,&value,sizeof(float));
}
void write(socket_t socket, const std::string& str) {
write(socket,(int)str.size());
write(socket,str.c_str(),str.size());
}
}
}
-86
View File
@@ -1,86 +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 "platform.h"
namespace embree
{
namespace network
{
/*! type for a socket */
typedef struct opaque_socket_t* socket_t;
/*! exception thrown when other side disconnects */
struct Disconnect : public std::exception {
virtual const char* what() const throw() {
return "network disconnect";
}
};
/*! creates a socket bound to a port */
socket_t bind(unsigned short port);
/*! listens for an incoming connection and accepts that connection */
socket_t listen(socket_t sockfd);
/*! initiates a connection */
socket_t connect(const char* host, unsigned short port);
/*! read data from the socket */
void read(socket_t socket, void* data, size_t bytes);
/*! write data to the socket */
void write(socket_t socket, const void* data, size_t bytes);
/*! flushes the write buffer */
void flush(socket_t socket);
/*! close a socket */
void close(socket_t socket);
/*! reads a bool from the socket */
bool read_bool(socket_t socket);
/*! reads a character from the socket */
char read_char(socket_t socket);
/*! reads an integer from the socket */
int read_int(socket_t socket);
/*! reads a float from the socket */
float read_float(socket_t socket);
/*! reads a string from the socket */
std::string read_string(socket_t socket);
/*! writes a bool to the socket */
void write(socket_t socket, bool value);
/*! writes a character to the socket */
void write(socket_t socket, char value);
/*! writes an integer to the socket */
void write(socket_t socket, int value);
/*! writes a float to the socket */
void write(socket_t socket, float value);
/*! writes a string to the socket */
void write(socket_t socket, const std::string& str);
}
}
+3 -3
View File
@@ -18,8 +18,6 @@
#define _CRT_SECURE_NO_WARNINGS
//__asm__(".symver memcpy,memcpy@GLIBC_2.2.5");
#include <cstddef>
#include <cassert>
#include <cstdlib>
@@ -251,6 +249,7 @@ __forceinline std::string toString(long long value) {
#pragma warning(disable:4503) // decorated name length exceeded, name was truncated
#pragma warning(disable:4180) // qualifier applied to function type has no meaning; ignored
#pragma warning(disable:4258) // definition from the for loop is ignored; the definition from the enclosing scope is used
#pragma warning(disable:4789) // buffer '' of size 8 bytes will be overrun; 32 bytes will be written starting at offset 0
#endif
#if defined(__clang__) && !defined(__INTEL_COMPILER)
@@ -353,7 +352,7 @@ namespace embree
template <typename Closure>
OnScopeExitHelper<Closure> OnScopeExit(const Closure f) {
return OnScopeExitHelper<Closure>(f);
};
}
#define STRING_JOIN2(arg1, arg2) DO_STRING_JOIN2(arg1, arg2)
#define DO_STRING_JOIN2(arg1, arg2) arg1 ## arg2
@@ -364,4 +363,5 @@ namespace embree
std::unique_ptr<Ty> make_unique(Ty* ptr) {
return std::unique_ptr<Ty>(ptr);
}
}
+7 -7
View File
@@ -48,7 +48,7 @@ namespace embree
/// Constructors, Assignment & Cast Operators
////////////////////////////////////////////////////////////////////////////////
__forceinline Ref( void ) : ptr(nullptr) {}
__forceinline Ref() : ptr(nullptr) {}
__forceinline Ref(NullTy) : ptr(nullptr) {}
__forceinline Ref( const Ref& input ) : ptr(input.ptr) { if ( ptr ) ptr->refInc(); }
@@ -57,7 +57,7 @@ namespace embree
ptr->refInc();
}
__forceinline ~Ref( void ) {
__forceinline ~Ref() {
if (ptr) ptr->refDec();
}
@@ -83,12 +83,12 @@ namespace embree
return *this;
}
__forceinline operator bool( void ) const { return ptr != nullptr; }
__forceinline operator bool() const { return ptr != nullptr; }
__forceinline const Type& operator *( void ) const { return *ptr; }
__forceinline Type& operator *( void ) { return *ptr; }
__forceinline const Type* operator ->( void ) const { return ptr; }
__forceinline Type* operator ->( void ) { return ptr; }
__forceinline const Type& operator *() const { return *ptr; }
__forceinline Type& operator *() { return *ptr; }
__forceinline const Type* operator ->() const { return ptr; }
__forceinline Type* operator ->() { return ptr; }
template<typename TypeOut>
__forceinline Ref<TypeOut> cast() { return Ref<TypeOut>(static_cast<TypeOut*>(ptr)); }
+9
View File
@@ -25,4 +25,13 @@ namespace embree
char to_upper(char c) { return char(toupper(int(c))); }
std::string toLowerCase(const std::string& s) { std::string dst(s); std::transform(dst.begin(), dst.end(), dst.begin(), to_lower); return dst; }
std::string toUpperCase(const std::string& s) { std::string dst(s); std::transform(dst.begin(), dst.end(), dst.begin(), to_upper); return dst; }
Vec3f string_to_Vec3f ( std::string str )
{
size_t next = 0;
const float x = std::stof(str,&next); str = str.substr(next+1);
const float y = std::stof(str,&next); str = str.substr(next+1);
const float z = std::stof(str,&next);
return Vec3f(x,y,z);
}
}
+3
View File
@@ -17,6 +17,7 @@
#pragma once
#include "platform.h"
#include "../math/vec3.h"
namespace embree
{
@@ -40,4 +41,6 @@ namespace embree
std::string toLowerCase(const std::string& s);
std::string toUpperCase(const std::string& s);
Vec3f string_to_Vec3f ( std::string str );
}
+15 -10
View File
@@ -341,7 +341,8 @@ namespace embree
{
std::string getExecutableFileName() {
char filename[1024];
if (!GetModuleFileName(nullptr, filename, sizeof(filename))) return std::string();
if (!GetModuleFileName(nullptr, filename, sizeof(filename)))
return std::string();
return std::string(filename);
}
@@ -411,10 +412,11 @@ namespace embree
{
std::string getExecutableFileName()
{
char pid[32]; sprintf(pid, "/proc/%d/exe", getpid());
char buf[1024];
int bytes = readlink(pid, buf, sizeof(buf)-1);
if (bytes != -1) buf[bytes] = '\0';
std::string pid = "/proc/" + toString(getpid()) + "/exe";
char buf[4096];
memset(buf,0,sizeof(buf));
if (readlink(pid.c_str(), buf, sizeof(buf)-1) == -1)
return std::string();
return std::string(buf);
}
}
@@ -434,9 +436,11 @@ namespace embree
std::string getExecutableFileName()
{
const int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 };
char buf[1024];
size_t len = sizeof(buf);
if (sysctl(mib, 4, buf, &len, 0x0, 0) == -1) *buf = '\0';
char buf[4096];
memset(buf,0,sizeof(buf));
size_t len = sizeof(buf)-1;
if (sysctl(mib, 4, buf, &len, 0x0, 0) == -1)
return std::string();
return std::string(buf);
}
}
@@ -455,9 +459,10 @@ namespace embree
{
std::string getExecutableFileName()
{
char buf[1024];
char buf[4096];
uint32_t size = sizeof(buf);
if (_NSGetExecutablePath(buf, &size) != 0) return std::string();
if (_NSGetExecutablePath(buf, &size) != 0)
return std::string();
return std::string(buf);
}
}
+5 -6
View File
@@ -93,7 +93,7 @@ namespace embree
__forceinline void resize(size_t new_size) {
internal_resize(new_size,size_alloced < new_size ? new_size : size_alloced);
internal_resize(new_size,internal_grow_size(new_size));
}
__forceinline void reserve(size_t new_alloced)
@@ -130,7 +130,7 @@ namespace embree
__forceinline void push_back(const T& nt)
{
const T v = nt; // need local copy as input reference could point to this vector
internal_grow(size_active+1);
internal_resize(size_active,internal_grow_size(size_active+1));
::new (&items[size_active++]) T(v);
}
@@ -216,11 +216,11 @@ namespace embree
size_alloced = new_alloced;
}
__forceinline void internal_grow(size_t new_alloced)
__forceinline size_t internal_grow_size(size_t new_alloced)
{
/* do nothing if container already large enough */
if (new_alloced <= size_alloced)
return;
return size_alloced;
/* resize to next power of 2 otherwise */
size_t new_size_alloced = size_alloced;
@@ -228,8 +228,7 @@ namespace embree
new_size_alloced = 2*new_size_alloced;
if (new_size_alloced == 0) new_size_alloced = 1;
}
internal_resize(size_active,new_size_alloced);
return new_size_alloced;
}
private:
+2 -2
View File
@@ -20,12 +20,12 @@ ENDIF()
IF (TASKING_TBB)
ADD_LIBRARY(tasking STATIC taskschedulertbb.cpp)
TARGET_LINK_LIBRARIES(tasking sys ${TBB_LIBRARIES})
TARGET_LINK_LIBRARIES(tasking sys math ${TBB_LIBRARIES})
ENDIF()
IF (TASKING_PPL)
ADD_LIBRARY(tasking STATIC taskschedulerppl.cpp)
TARGET_LINK_LIBRARIES(tasking sys ${PPL_LIBRARIES})
TARGET_LINK_LIBRARIES(tasking sys math ${PPL_LIBRARIES})
ENDIF()
SET_PROPERTY(TARGET tasking PROPERTY FOLDER common)
+15 -6
View File
@@ -50,7 +50,7 @@ namespace embree
}
/*! run this task */
__dllexport void TaskScheduler::Task::run (Thread& thread) // FIXME: avoid as many __dllexports as possible
void TaskScheduler::Task::run_internal (Thread& thread) // FIXME: avoid as many __dllexports as possible
{
/* try to run if not already stolen */
if (try_switch_state(INITIALIZED,DONE))
@@ -71,14 +71,19 @@ namespace embree
/* steal until all dependencies have completed */
steal_loop(thread,
[&] () { return dependencies>0; },
[&] () { while (thread.tasks.execute_local(thread,this)); });
[&] () { while (thread.tasks.execute_local_internal(thread,this)); });
/* now signal our parent task that we are finished */
if (parent)
parent->add_dependencies(-1);
}
__dllexport bool TaskScheduler::TaskQueue::execute_local(Thread& thread, Task* parent)
/*! run this task */
__dllexport void TaskScheduler::Task::run (Thread& thread) {
run_internal(thread);
}
bool TaskScheduler::TaskQueue::execute_local_internal(Thread& thread, Task* parent)
{
/* stop if we run out of local tasks or reach the waiting task */
if (right == 0 || &tasks[right-1] == parent)
@@ -86,7 +91,7 @@ namespace embree
/* execute task */
size_t oldRight = right;
tasks[right-1].run(thread);
tasks[right-1].run_internal(thread);
if (right != oldRight) {
THROW_RUNTIME_ERROR("you have to wait for spawned subtasks");
}
@@ -102,6 +107,10 @@ namespace embree
return right != 0;
}
__dllexport bool TaskScheduler::TaskQueue::execute_local(Thread& thread, Task* parent) {
return execute_local_internal(thread,parent);
}
bool TaskScheduler::TaskQueue::steal(Thread& thread)
{
size_t l = left;
@@ -316,7 +325,7 @@ namespace embree
{
Thread* thread = TaskScheduler::thread();
if (thread == nullptr) return true;
while (thread->tasks.execute_local(*thread,thread->task)) {};
while (thread->tasks.execute_local_internal(*thread,thread->task)) {};
return thread->scheduler->cancellingException == nullptr;
}
@@ -335,7 +344,7 @@ namespace embree
[&] () { return anyTasksRunning > 0; },
[&] () {
anyTasksRunning++;
while (thread.tasks.execute_local(thread,nullptr));
while (thread.tasks.execute_local_internal(thread,nullptr));
anyTasksRunning--;
});
}
+11 -4
View File
@@ -109,6 +109,8 @@ namespace embree
/*! run this task */
__dllexport void run(Thread& thread);
void run_internal(Thread& thread);
public:
std::atomic<int> state; //!< state this task is in
std::atomic<int> dependencies; //!< dependencies to wait for
@@ -124,16 +126,20 @@ namespace embree
TaskQueue ()
: left(0), right(0), stackPtr(0) {}
__forceinline void* alloc(size_t bytes, size_t align = 64) {
stackPtr += bytes + ((align - stackPtr) & (align-1));
assert(stackPtr <= CLOSURE_STACK_SIZE);
__forceinline void* alloc(size_t bytes, size_t align = 64)
{
size_t ofs = bytes + ((align - stackPtr) & (align-1));
if (stackPtr + ofs > CLOSURE_STACK_SIZE)
throw std::runtime_error("closure stack overflow");
stackPtr += ofs;
return &stack[stackPtr-bytes];
}
template<typename Closure>
__forceinline void push_right(Thread& thread, const size_t size, const Closure& closure)
{
assert(right < TASK_STACK_SIZE);
if (right >= TASK_STACK_SIZE)
throw std::runtime_error("task stack overflow");
/* allocate new task on right side of stack */
size_t oldStackPtr = stackPtr;
@@ -145,6 +151,7 @@ namespace embree
}
__dllexport bool execute_local(Thread& thread, Task* parent);
bool execute_local_internal(Thread& thread, Task* parent);
bool steal(Thread& thread);
size_t getTaskSizeAtLeft();
+8
View File
@@ -28,6 +28,12 @@
# define NOMINMAX
#endif
// We need to define these to avoid implicit linkage against
// tbb_debug.lib under Windows. When removing these lines debug build
// under Windows fails.
#define __TBB_NO_IMPLICIT_LINKAGE 1
#define __TBBMALLOC_NO_IMPLICIT_LINKAGE 1
#include "tbb/tbb.h"
#include "tbb/parallel_sort.h"
@@ -67,5 +73,7 @@ namespace embree
return tbb::task_scheduler_init::default_num_threads();
#endif
}
};
};
+3 -7
View File
@@ -20,6 +20,8 @@
#include <stddef.h>
#include <sys/types.h>
#include "rtcore_version.h"
#if defined(_WIN32)
#if defined(_M_X64)
typedef long long ssize_t;
@@ -58,12 +60,6 @@ typedef int ssize_t;
# define RTCORE_FORCEINLINE inline __attribute__((always_inline))
#endif
/*! Embree API version */
#define RTCORE_VERSION_MAJOR @EMBREE_VERSION_MAJOR@
#define RTCORE_VERSION_MINOR @EMBREE_VERSION_MINOR@
#define RTCORE_VERSION_PATCH @EMBREE_VERSION_PATCH@
#define RTCORE_VERSION @EMBREE_VERSION_NUMBER@
/*! \file rtcore.h Defines the Embree Ray Tracing Kernel API for C and C++
This file defines the Embree ray tracing kernel API for C and
@@ -156,7 +152,7 @@ enum RTCParameter {
RTC_CONFIG_INTERSECTION_FILTER = 8, //!< checks if intersection filters are enabled (read only)
RTC_CONFIG_INTERSECTION_FILTER_RESTORE = 9, //!< checks if intersection filters restores previous hit (read only)
RTC_CONFIG_IGNORE_INVALID_RAYS = 11, //!< checks if invalid rays are ignored (read only)
RTC_CONFIG_TASKING_SYSTEM = 12, //!< return used tasking system (0 = INTERNAL, 1 = TBB) (read only)
RTC_CONFIG_TASKING_SYSTEM = 12, //!< return used tasking system (0 = INTERNAL, 1 = TBB, 2 = PPL) (read only)
RTC_CONFIG_VERSION_MAJOR = 13, //!< returns Embree major version (read only)
RTC_CONFIG_VERSION_MINOR = 14, //!< returns Embree minor version (read only)
+2 -6
View File
@@ -17,6 +17,8 @@
#ifndef __RTCORE_ISPH__
#define __RTCORE_ISPH__
#include "rtcore_version.h"
#if !defined(RTCORE_API)
#define RTCORE_API extern "C" unmasked
#endif
@@ -31,12 +33,6 @@
#define RTCORE_DEPRECATED // FIXME: deprecation not supported by ISPC
#endif
/*! Embree API version */
#define RTCORE_VERSION_MAJOR @EMBREE_VERSION_MAJOR@
#define RTCORE_VERSION_MINOR @EMBREE_VERSION_MINOR@
#define RTCORE_VERSION_PATCH @EMBREE_VERSION_PATCH@
#define RTCORE_VERSION @EMBREE_VERSION_NUMBER@
/*! \file rtcore.isph Defines the Embree Ray Tracing Kernel API for ISPC.
This file defines the Embree ray tracing kernel API for C and
+2 -2
View File
@@ -226,7 +226,7 @@ RTCORE_API void rtcSetTransform2 (RTCScene scene, //!< s
(numTriangles), number of vertices (numVertices), and number of time
steps (1 for normal meshes, and up to RTC_MAX_TIME_STEPS for multi
segment motion blur), have to get specified. The triangle indices
can be set be mapping and writing to the index buffer
can be set by mapping and writing to the index buffer
(RTC_INDEX_BUFFER) and the triangle vertices can be set by mapping
and writing into the vertex buffer (RTC_VERTEX_BUFFER). In case of
multi-segment motion blur, multiple vertex buffers have to get filled
@@ -255,7 +255,7 @@ RTCORE_API unsigned rtcNewTriangleMesh2 (RTCScene scene, //!<
/*! \brief Creates a new quad mesh. The number of quads (numQuads),
number of vertices (numVertices), and number of time steps (1 for
normal meshes, and up to RTC_MAX_TIME_STEPS for multi-segment motion
blur), have to get specified. The quad indices can be set be mapping
blur), have to get specified. The quad indices can be set by mapping
and writing to the index buffer (RTC_INDEX_BUFFER) and the quad
vertices can be set by mapping and writing into the vertex buffer
(RTC_VERTEX_BUFFER). In case of multi-segment motion blur, multiple
+11 -11
View File
@@ -165,15 +165,15 @@ RTCORE_DEPRECATED uniform unsigned int rtcNewInstance (RTCScene target,
the provided scene. If any geometry is hit, the instance ID (instID)
member of the ray will get set to the geometry ID of the
instance. */
uniform unsigned rtcNewInstance2 (RTCScene target, //!< the scene the instance belongs to
RTCScene source, //!< the scene to instantiate
uniform size_t numTimeSteps = 1 //!< number of timesteps, one matrix per timestep
uniform unsigned int rtcNewInstance2 (RTCScene target, //!< the scene the instance belongs to
RTCScene source, //!< the scene to instantiate
uniform size_t numTimeSteps = 1 //!< number of timesteps, one matrix per timestep
);
uniform unsigned rtcNewInstance3 (RTCScene target, //!< the scene the instance belongs to
RTCScene source, //!< the scene to instantiate
uniform size_t numTimeSteps = 1, //!< number of timesteps, one matrix per timestep
uniform unsigned int geomID = -1 //!< optional geometry ID to assign
uniform unsigned int rtcNewInstance3 (RTCScene target, //!< the scene the instance belongs to
RTCScene source, //!< the scene to instantiate
uniform size_t numTimeSteps = 1, //!< number of timesteps, one matrix per timestep
uniform unsigned int geomID = -1 //!< optional geometry ID to assign
);
/*! \brief Creates a new geometry instance.
@@ -208,7 +208,7 @@ void rtcSetTransform2 (RTCScene scene, //!< scen
(numTriangles), number of vertices (numVertices), and number of time
steps (1 for normal meshes, and up to RTC_MAX_TIME_STEPS for multi
segment motion blur), have to get specified. The triangle indices
can be set be mapping and writing to the index buffer
can be set by mapping and writing to the index buffer
(RTC_INDEX_BUFFER) and the triangle vertices can be set by mapping
and writing into the vertex buffer (RTC_VERTEX_BUFFER). In case of
multi-segment motion blur, multiple vertex buffers have to get filled
@@ -236,7 +236,7 @@ uniform unsigned int rtcNewTriangleMesh2(RTCScene scene, //!<
/*! \brief Creates a new quad mesh. The number of quads (numQuads),
number of vertices (numVertices), and number of time steps (1 for
normal meshes, and up to RTC_MAX_TIME_STEPS for multi-segment motion
blur), have to get specified. The quad indices can be set be mapping
blur), have to get specified. The quad indices can be set by mapping
and writing to the index buffer (RTC_INDEX_BUFFER) and the quad
vertices can be set by mapping and writing into the vertex buffer
(RTC_VERTEX_BUFFER). In case of multi-segment motion blur, multiple
@@ -564,7 +564,7 @@ uniform unsigned int rtcNewLineSegments2(RTCScene scene, //!<
/*! Sets a uniform tessellation rate for subdiv meshes and hair
* geometry. For subdivision meshes the RTC_LEVEL_BUFFER can also be used
* optionally to set a different tessellation rate per edge.*/
void rtcSetTessellationRate (RTCScene scene, uniform unsigned geomID, uniform float tessellationRate);
void rtcSetTessellationRate (RTCScene scene, uniform unsigned int geomID, uniform float tessellationRate);
/*! \brief Sets 32 bit ray mask. */
void rtcSetMask (RTCScene scene, uniform unsigned int geomID, uniform int mask);
@@ -578,7 +578,7 @@ RTCORE_DEPRECATED void rtcSetBoundaryMode(RTCScene scene, uniform unsigned int g
void rtcSetSubdivisionMode(RTCScene scene, uniform unsigned int geomID, uniform unsigned int topologyID, uniform RTCSubdivisionMode mode);
/*! \brief Binds a user vertex buffer to some index buffer topology. */
void rtcSetIndexBuffer(RTCScene scene, uniform unsigned geomID, uniform RTCBufferType vertexBuffer, uniform RTCBufferType indexBuffer);
void rtcSetIndexBuffer(RTCScene scene, uniform unsigned int geomID, uniform RTCBufferType vertexBuffer, uniform RTCBufferType indexBuffer);
/*! \brief Maps specified buffer. This function can be used to set index and
* vertex buffers of geometries. */
+4 -4
View File
@@ -153,12 +153,12 @@ void rtcSetIntersectFunction (RTCScene scene, uniform unsigned int geomID, unifo
/*! Set intersect function for stream of rays. The rtcIntersectN function
* will call the passed function for intersecting the user
* geometry. */
void rtcSetIntersectFunction1Mp (RTCScene scene, uniform unsigned geomID, uniform RTCIntersectFunc1Mp intersect);
void rtcSetIntersectFunction1Mp (RTCScene scene, uniform unsigned int geomID, uniform RTCIntersectFunc1Mp intersect);
/*! Set intersect function for ray packets of size N. The rtcIntersectN function
* will call the passed function for intersecting the user
* geometry. */
void rtcSetIntersectFunctionN (RTCScene scene, uniform unsigned geomID, uniform RTCIntersectFuncN intersect);
void rtcSetIntersectFunctionN (RTCScene scene, uniform unsigned int geomID, uniform RTCIntersectFuncN intersect);
/*! Set occlusion function for uniform rays. The rtcOccluded1 function
* will call the passed function for intersecting the user
@@ -173,12 +173,12 @@ void rtcSetOccludedFunction (RTCScene scene, uniform unsigned int geomID, unifor
/*! Set occlusion function for a stream of single rays. The rtcOccludedN function
* will call the passed function for intersecting the user
* geometry. */
void rtcSetOccludedFunction1Mp (RTCScene scene, uniform unsigned geomID, uniform RTCOccludedFunc1Mp occluded);
void rtcSetOccludedFunction1Mp (RTCScene scene, uniform unsigned int geomID, uniform RTCOccludedFunc1Mp occluded);
/*! Set occlusion function for a ray packets of size N. The rtcOccludedN function
* will call the passed function for intersecting the user
* geometry. */
void rtcSetOccludedFunctionN (RTCScene scene, uniform unsigned geomID, uniform RTCOccludedFuncN occluded);
void rtcSetOccludedFunctionN (RTCScene scene, uniform unsigned int geomID, uniform RTCOccludedFuncN occluded);
/*! @} */
+25 -25
View File
@@ -169,28 +169,28 @@ public:
struct RTCRayN {};
RTCORE_FORCEINLINE float& RTCRayN_org_x(RTCRayN* ptr, size_t N, size_t i) { const size_t N1 = (size_t)(N == 1); return ((float*)ptr)[0*N+0*N1+i]; } //!< x coordinate of ray origin
RTCORE_FORCEINLINE float& RTCRayN_org_y(RTCRayN* ptr, size_t N, size_t i) { const size_t N1 = (size_t)(N == 1); return ((float*)ptr)[1*N+0*N1+i]; } //!< y coordinate of ray origin
RTCORE_FORCEINLINE float& RTCRayN_org_z(RTCRayN* ptr, size_t N, size_t i) { const size_t N1 = (size_t)(N == 1); return ((float*)ptr)[2*N+0*N1+i]; }; //!< z coordinate of ray origin
RTCORE_FORCEINLINE float& RTCRayN_org_z(RTCRayN* ptr, size_t N, size_t i) { const size_t N1 = (size_t)(N == 1); return ((float*)ptr)[2*N+0*N1+i]; } //!< z coordinate of ray origin
RTCORE_FORCEINLINE float& RTCRayN_dir_x(RTCRayN* ptr, size_t N, size_t i) { const size_t N1 = (size_t)(N == 1); return ((float*)ptr)[3*N+1*N1+i]; }; //!< x coordinate of ray direction
RTCORE_FORCEINLINE float& RTCRayN_dir_y(RTCRayN* ptr, size_t N, size_t i) { const size_t N1 = (size_t)(N == 1); return ((float*)ptr)[4*N+1*N1+i]; }; //!< y coordinate of ray direction
RTCORE_FORCEINLINE float& RTCRayN_dir_z(RTCRayN* ptr, size_t N, size_t i) { const size_t N1 = (size_t)(N == 1); return ((float*)ptr)[5*N+1*N1+i]; }; //!< z coordinate of ray direction
RTCORE_FORCEINLINE float& RTCRayN_dir_x(RTCRayN* ptr, size_t N, size_t i) { const size_t N1 = (size_t)(N == 1); return ((float*)ptr)[3*N+1*N1+i]; } //!< x coordinate of ray direction
RTCORE_FORCEINLINE float& RTCRayN_dir_y(RTCRayN* ptr, size_t N, size_t i) { const size_t N1 = (size_t)(N == 1); return ((float*)ptr)[4*N+1*N1+i]; } //!< y coordinate of ray direction
RTCORE_FORCEINLINE float& RTCRayN_dir_z(RTCRayN* ptr, size_t N, size_t i) { const size_t N1 = (size_t)(N == 1); return ((float*)ptr)[5*N+1*N1+i]; } //!< z coordinate of ray direction
RTCORE_FORCEINLINE float& RTCRayN_tnear(RTCRayN* ptr, size_t N, size_t i) { const size_t N1 = (size_t)(N == 1); return ((float*)ptr)[6*N+2*N1+i]; }; //!< Start of ray segment
RTCORE_FORCEINLINE float& RTCRayN_tfar (RTCRayN* ptr, size_t N, size_t i) { const size_t N1 = (size_t)(N == 1); return ((float*)ptr)[7*N+2*N1+i]; }; //!< End of ray segment (set to hit distance)
RTCORE_FORCEINLINE float& RTCRayN_tnear(RTCRayN* ptr, size_t N, size_t i) { const size_t N1 = (size_t)(N == 1); return ((float*)ptr)[6*N+2*N1+i]; } //!< Start of ray segment
RTCORE_FORCEINLINE float& RTCRayN_tfar (RTCRayN* ptr, size_t N, size_t i) { const size_t N1 = (size_t)(N == 1); return ((float*)ptr)[7*N+2*N1+i]; } //!< End of ray segment (set to hit distance)
RTCORE_FORCEINLINE float& RTCRayN_time(RTCRayN* ptr, size_t N, size_t i) { const size_t N1 = (size_t)(N == 1); return ((float*) ptr)[8*N+2*N1+i]; }; //!< Time of this ray for motion blur
RTCORE_FORCEINLINE unsigned& RTCRayN_mask(RTCRayN* ptr, size_t N, size_t i) { const size_t N1 = (size_t)(N == 1); return ((unsigned*)ptr)[9*N+2*N1+i]; }; //!< Used to mask out objects during traversal
RTCORE_FORCEINLINE float& RTCRayN_time(RTCRayN* ptr, size_t N, size_t i) { const size_t N1 = (size_t)(N == 1); return ((float*) ptr)[8*N+2*N1+i]; } //!< Time of this ray for motion blur
RTCORE_FORCEINLINE unsigned& RTCRayN_mask(RTCRayN* ptr, size_t N, size_t i) { const size_t N1 = (size_t)(N == 1); return ((unsigned*)ptr)[9*N+2*N1+i]; } //!< Used to mask out objects during traversal
RTCORE_FORCEINLINE float& RTCRayN_Ng_x(RTCRayN* ptr, size_t N, size_t i) { const size_t N1 = (size_t)(N == 1); return ((float*)ptr)[10*N+2*N1+i]; }; //!< x coordinate of geometry normal
RTCORE_FORCEINLINE float& RTCRayN_Ng_y(RTCRayN* ptr, size_t N, size_t i) { const size_t N1 = (size_t)(N == 1); return ((float*)ptr)[11*N+2*N1+i]; }; //!< y coordinate of geometry normal
RTCORE_FORCEINLINE float& RTCRayN_Ng_z(RTCRayN* ptr, size_t N, size_t i) { const size_t N1 = (size_t)(N == 1); return ((float*)ptr)[12*N+2*N1+i]; }; //!< z coordinate of geometry normal
RTCORE_FORCEINLINE float& RTCRayN_Ng_x(RTCRayN* ptr, size_t N, size_t i) { const size_t N1 = (size_t)(N == 1); return ((float*)ptr)[10*N+2*N1+i]; } //!< x coordinate of geometry normal
RTCORE_FORCEINLINE float& RTCRayN_Ng_y(RTCRayN* ptr, size_t N, size_t i) { const size_t N1 = (size_t)(N == 1); return ((float*)ptr)[11*N+2*N1+i]; } //!< y coordinate of geometry normal
RTCORE_FORCEINLINE float& RTCRayN_Ng_z(RTCRayN* ptr, size_t N, size_t i) { const size_t N1 = (size_t)(N == 1); return ((float*)ptr)[12*N+2*N1+i]; } //!< z coordinate of geometry normal
RTCORE_FORCEINLINE float& RTCRayN_u (RTCRayN* ptr, size_t N, size_t i) { const size_t N1 = (size_t)(N == 1); return ((float*)ptr)[13*N+3*N1+i]; }; //!< Barycentric u coordinate of hit
RTCORE_FORCEINLINE float& RTCRayN_v (RTCRayN* ptr, size_t N, size_t i) { const size_t N1 = (size_t)(N == 1); return ((float*)ptr)[14*N+3*N1+i]; }; //!< Barycentric v coordinate of hit
RTCORE_FORCEINLINE float& RTCRayN_u (RTCRayN* ptr, size_t N, size_t i) { const size_t N1 = (size_t)(N == 1); return ((float*)ptr)[13*N+3*N1+i]; } //!< Barycentric u coordinate of hit
RTCORE_FORCEINLINE float& RTCRayN_v (RTCRayN* ptr, size_t N, size_t i) { const size_t N1 = (size_t)(N == 1); return ((float*)ptr)[14*N+3*N1+i]; } //!< Barycentric v coordinate of hit
RTCORE_FORCEINLINE unsigned& RTCRayN_geomID(RTCRayN* ptr, size_t N, size_t i) { const size_t N1 = (size_t)(N == 1); return ((unsigned*)ptr)[15*N+3*N1+i]; }; //!< geometry ID
RTCORE_FORCEINLINE unsigned& RTCRayN_primID(RTCRayN* ptr, size_t N, size_t i) { const size_t N1 = (size_t)(N == 1); return ((unsigned*)ptr)[16*N+3*N1+i]; }; //!< primitive ID
RTCORE_FORCEINLINE unsigned& RTCRayN_instID(RTCRayN* ptr, size_t N, size_t i) { const size_t N1 = (size_t)(N == 1); return ((unsigned*)ptr)[17*N+3*N1+i]; }; //!< instance ID
RTCORE_FORCEINLINE unsigned& RTCRayN_geomID(RTCRayN* ptr, size_t N, size_t i) { const size_t N1 = (size_t)(N == 1); return ((unsigned*)ptr)[15*N+3*N1+i]; } //!< geometry ID
RTCORE_FORCEINLINE unsigned& RTCRayN_primID(RTCRayN* ptr, size_t N, size_t i) { const size_t N1 = (size_t)(N == 1); return ((unsigned*)ptr)[16*N+3*N1+i]; } //!< primitive ID
RTCORE_FORCEINLINE unsigned& RTCRayN_instID(RTCRayN* ptr, size_t N, size_t i) { const size_t N1 = (size_t)(N == 1); return ((unsigned*)ptr)[17*N+3*N1+i]; } //!< instance ID
#endif
/* Helper structure to create a ray packet of compile time size N */
@@ -272,17 +272,17 @@ public:
#ifndef __RTCHitN__
#define __RTCHitN__
struct RTCHitN {};
RTCORE_FORCEINLINE float& RTCHitN_Ng_x(const RTCHitN* ptr, size_t N, size_t i) { return ((float*)ptr)[0*N+i]; }; //!< x coordinate of geometry normal
RTCORE_FORCEINLINE float& RTCHitN_Ng_y(const RTCHitN* ptr, size_t N, size_t i) { return ((float*)ptr)[1*N+i]; }; //!< y coordinate of geometry normal
RTCORE_FORCEINLINE float& RTCHitN_Ng_z(const RTCHitN* ptr, size_t N, size_t i) { return ((float*)ptr)[2*N+i]; }; //!< z coordinate of geometry normal
RTCORE_FORCEINLINE float& RTCHitN_Ng_x(const RTCHitN* ptr, size_t N, size_t i) { return ((float*)ptr)[0*N+i]; } //!< x coordinate of geometry normal
RTCORE_FORCEINLINE float& RTCHitN_Ng_y(const RTCHitN* ptr, size_t N, size_t i) { return ((float*)ptr)[1*N+i]; } //!< y coordinate of geometry normal
RTCORE_FORCEINLINE float& RTCHitN_Ng_z(const RTCHitN* ptr, size_t N, size_t i) { return ((float*)ptr)[2*N+i]; } //!< z coordinate of geometry normal
RTCORE_FORCEINLINE unsigned& RTCHitN_instID(const RTCHitN* ptr, size_t N, size_t i) { return ((unsigned*)ptr)[3*N+i]; }; //!< instance ID
RTCORE_FORCEINLINE unsigned& RTCHitN_geomID(const RTCHitN* ptr, size_t N, size_t i) { return ((unsigned*)ptr)[4*N+i]; }; //!< geometry ID
RTCORE_FORCEINLINE unsigned& RTCHitN_primID(const RTCHitN* ptr, size_t N, size_t i) { return ((unsigned*)ptr)[5*N+i]; }; //!< primitive ID
RTCORE_FORCEINLINE unsigned& RTCHitN_instID(const RTCHitN* ptr, size_t N, size_t i) { return ((unsigned*)ptr)[3*N+i]; } //!< instance ID
RTCORE_FORCEINLINE unsigned& RTCHitN_geomID(const RTCHitN* ptr, size_t N, size_t i) { return ((unsigned*)ptr)[4*N+i]; } //!< geometry ID
RTCORE_FORCEINLINE unsigned& RTCHitN_primID(const RTCHitN* ptr, size_t N, size_t i) { return ((unsigned*)ptr)[5*N+i]; } //!< primitive ID
RTCORE_FORCEINLINE float& RTCHitN_u (const RTCHitN* ptr, size_t N, size_t i) { return ((float*)ptr)[6*N+i]; }; //!< Barycentric u coordinate of hit
RTCORE_FORCEINLINE float& RTCHitN_v (const RTCHitN* ptr, size_t N, size_t i) { return ((float*)ptr)[7*N+i]; }; //!< Barycentric v coordinate of hit
RTCORE_FORCEINLINE float& RTCHitN_t (const RTCHitN* ptr, size_t N, size_t i) { return ((float*)ptr)[8*N+i]; }; //!< hit distance
RTCORE_FORCEINLINE float& RTCHitN_u (const RTCHitN* ptr, size_t N, size_t i) { return ((float*)ptr)[6*N+i]; } //!< Barycentric u coordinate of hit
RTCORE_FORCEINLINE float& RTCHitN_v (const RTCHitN* ptr, size_t N, size_t i) { return ((float*)ptr)[7*N+i]; } //!< Barycentric v coordinate of hit
RTCORE_FORCEINLINE float& RTCHitN_t (const RTCHitN* ptr, size_t N, size_t i) { return ((float*)ptr)[8*N+i]; } //!< hit distance
#endif
/* Helper structure to create a hit packet of compile time size N */
+21
View File
@@ -0,0 +1,21 @@
// ======================================================================== //
// 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. //
// ======================================================================== //
#define RTCORE_VERSION_MAJOR 2
#define RTCORE_VERSION_MINOR 17
#define RTCORE_VERSION_PATCH 1
#define RTCORE_VERSION 21701
#define RTCORE_VERSION_STRING "2.17.1-alpha.0"
+116 -149
View File
@@ -14,6 +14,14 @@
## limitations under the License. ##
## ======================================================================== ##
MACRO(DISABLE_STACK_PROTECTOR_FOR_INTERSECTORS)
FOREACH(src ${ARGN})
IF (src MATCHES ".*intersector.*")
DISABLE_STACK_PROTECTOR_FOR_FILE(${src})
ENDIF()
ENDFOREACH()
ENDMACRO()
SOURCE_GROUP("Source Files\\bvh4" "/bvh4/" )
SOURCE_GROUP("Source Files\\bvh8" "/bvh8/" )
SOURCE_GROUP("Source Files\\geometry" "/geometry/" )
@@ -51,7 +59,6 @@ SET(EMBREE_LIBRARY_FILES
geometry/primitive.cpp
geometry/instance_intersector1.cpp
geometry/instance_intersector.cpp
builders/primrefgen.cpp
bvh/bvh.cpp
@@ -63,6 +70,7 @@ SET(EMBREE_LIBRARY_FILES
bvh/bvh_refit.cpp
bvh/bvh_builder.cpp
bvh/bvh_builder_hair.cpp
bvh/bvh_builder_hair_mb.cpp
bvh/bvh_builder_morton.cpp
bvh/bvh_builder_sah.cpp
bvh/bvh_builder_twolevel.cpp
@@ -93,158 +101,93 @@ IF (EMBREE_RAY_PACKETS)
bvh/bvh_intersector_stream_filters.cpp)
ENDIF()
SET(EMBREE_LIBRARY_FILES_SSE42
MACRO(embree_files TARGET ISA)
SET(${TARGET}
geometry/instance_intersector1.cpp
bvh/bvh_intersector1_bvh4.cpp)
IF (EMBREE_GEOMETRY_SUBDIV)
SET(EMBREE_LIBRARY_FILES_SSE42 ${EMBREE_LIBRARY_FILES_SSE42}
geometry/grid_soa.cpp
subdiv/subdivpatch1base_eval.cpp)
ENDIF()
IF (EMBREE_RAY_PACKETS)
SET(EMBREE_LIBRARY_FILES_SSE42 ${EMBREE_LIBRARY_FILES_SSE42}
bvh/bvh_intersector_hybrid4_bvh4.cpp
bvh/bvh_intersector_stream_bvh4.cpp
bvh/bvh_intersector_stream_filters.cpp)
ENDIF()
SET(EMBREE_LIBRARY_FILES_AVX
geometry/instance_intersector1.cpp
builders/primrefgen.cpp
bvh/bvh_rotate.cpp
bvh/bvh_refit.cpp
bvh/bvh_builder.cpp
bvh/bvh_builder_hair.cpp
bvh/bvh_builder_morton.cpp
bvh/bvh_builder_sah.cpp
bvh/bvh_builder_twolevel.cpp
bvh/bvh_builder_instancing.cpp
bvh/bvh_intersector1_bvh4.cpp
bvh/bvh_intersector1_bvh8.cpp
IF (${ISA} EQUAL ${SSE2} OR ${ISA} EQUAL ${AVX} OR ${ISA} EQUAL ${AVX512KNL} OR ${ISA_LOWEST} EQUAL ${ISA})
bvh/bvh.cpp
bvh/bvh_statistics.cpp)
LIST(APPEND ${TARGET}
common/scene_triangle_mesh.cpp
common/scene_quad_mesh.cpp
common/scene_bezier_curves.cpp
common/scene_line_segments.cpp
bvh/bvh_refit.cpp
bvh/bvh_builder.cpp
bvh/bvh_builder_hair.cpp
bvh/bvh_builder_hair_mb.cpp
bvh/bvh_builder_sah.cpp
bvh/bvh_builder_twolevel.cpp
bvh/bvh_builder_instancing.cpp)
IF (EMBREE_GEOMETRY_SUBDIV)
SET(EMBREE_LIBRARY_FILES_AVX ${EMBREE_LIBRARY_FILES_AVX}
geometry/grid_soa.cpp
subdiv/subdivpatch1base_eval.cpp
common/scene_subdiv_mesh_avx.cpp
bvh/bvh_builder_subdiv.cpp)
ENDIF()
IF (EMBREE_GEOMETRY_SUBDIV)
LIST(APPEND ${TARGET} bvh/bvh_builder_subdiv.cpp)
ENDIF()
ENDIF()
IF (EMBREE_RAY_PACKETS)
SET(EMBREE_LIBRARY_FILES_AVX ${EMBREE_LIBRARY_FILES_AVX}
IF (${ISA} EQUAL ${SSE2} OR ${ISA} EQUAL ${AVX} OR ${ISA} EQUAL ${AVX2} OR ${ISA} EQUAL ${AVX512KNL} OR ${ISA_LOWEST} EQUAL ${ISA})
LIST(APPEND ${TARGET}
bvh/bvh_builder_morton.cpp
bvh/bvh_rotate.cpp
builders/primrefgen.cpp)
ENDIF()
IF (${ISA} GREATER ${SSE42})
LIST(APPEND ${TARGET} bvh/bvh_intersector1_bvh8.cpp)
ENDIF()
geometry/instance_intersector.cpp
IF (${ISA} EQUAL ${AVX})
LIST(APPEND ${TARGET}
bvh/bvh.cpp
bvh/bvh_statistics.cpp)
ENDIF()
bvh/bvh_intersector_hybrid4_bvh4.cpp
bvh/bvh_intersector_hybrid8_bvh4.cpp
bvh/bvh_intersector_hybrid4_bvh8.cpp
bvh/bvh_intersector_hybrid8_bvh8.cpp
bvh/bvh_intersector_stream_bvh4.cpp
bvh/bvh_intersector_stream_bvh8.cpp
bvh/bvh_intersector_stream_filters.cpp)
ENDIF()
IF (EMBREE_GEOMETRY_SUBDIV)
LIST(APPEND ${TARGET}
common/scene_subdiv_mesh.cpp
geometry/grid_soa.cpp
subdiv/subdivpatch1base_eval.cpp)
ENDIF()
IF (EMBREE_RAY_PACKETS)
LIST(APPEND ${TARGET}
bvh/bvh_intersector_hybrid4_bvh4.cpp
bvh/bvh_intersector_stream_bvh4.cpp
bvh/bvh_intersector_stream_filters.cpp)
SET(EMBREE_LIBRARY_FILES_AVX2
IF (${ISA} GREATER ${SSE42})
LIST(APPEND ${TARGET}
bvh/bvh_intersector_hybrid8_bvh4.cpp
bvh/bvh_intersector_hybrid4_bvh8.cpp
bvh/bvh_intersector_hybrid8_bvh8.cpp
bvh/bvh_intersector_stream_bvh8.cpp)
ENDIF()
geometry/instance_intersector1.cpp
builders/primrefgen.cpp
bvh/bvh_builder_morton.cpp
bvh/bvh_rotate.cpp
bvh/bvh_intersector1_bvh4.cpp
bvh/bvh_intersector1_bvh8.cpp)
IF (${ISA} GREATER ${AVX2})
LIST(APPEND ${TARGET}
bvh/bvh_intersector_hybrid16_bvh8.cpp
bvh/bvh_intersector_hybrid16_bvh4.cpp)
ENDIF()
ENDIF()
ENDMACRO()
IF (EMBREE_GEOMETRY_SUBDIV)
SET(EMBREE_LIBRARY_FILES_AVX2 ${EMBREE_LIBRARY_FILES_AVX2}
geometry/grid_soa.cpp
subdiv/subdivpatch1base_eval.cpp)
ENDIF()
#embree_files(EMBREE_LIBRARY_FILES_SSE2 ${SSE2})
embree_files(EMBREE_LIBRARY_FILES_SSE42 ${SSE42})
embree_files(EMBREE_LIBRARY_FILES_AVX ${AVX})
embree_files(EMBREE_LIBRARY_FILES_AVX2 ${AVX2})
embree_files(EMBREE_LIBRARY_FILES_AVX512KNL ${AVX512KNL})
embree_files(EMBREE_LIBRARY_FILES_AVX512SKX ${AVX512SKX})
IF (EMBREE_RAY_PACKETS)
SET(EMBREE_LIBRARY_FILES_AVX2 ${EMBREE_LIBRARY_FILES_AVX2}
geometry/instance_intersector.cpp
bvh/bvh_intersector_hybrid4_bvh4.cpp
bvh/bvh_intersector_hybrid8_bvh4.cpp
bvh/bvh_intersector_hybrid4_bvh8.cpp
bvh/bvh_intersector_hybrid8_bvh8.cpp
bvh/bvh_intersector_stream_bvh4.cpp
bvh/bvh_intersector_stream_bvh8.cpp
bvh/bvh_intersector_stream_filters.cpp)
ENDIF()
SET(EMBREE_LIBRARY_FILES_AVX512KNL
geometry/instance_intersector1.cpp
bvh/bvh_refit.cpp
bvh/bvh_rotate.cpp
bvh/bvh_intersector1_bvh4.cpp
bvh/bvh_intersector1_bvh8.cpp
builders/primrefgen.cpp
bvh/bvh_builder.cpp
bvh/bvh_builder_sah.cpp
bvh/bvh_builder_twolevel.cpp
bvh/bvh_builder_instancing.cpp
bvh/bvh_builder_morton.cpp)
IF (EMBREE_GEOMETRY_SUBDIV)
SET(EMBREE_LIBRARY_FILES_AVX512KNL ${EMBREE_LIBRARY_FILES_AVX512KNL}
geometry/grid_soa.cpp
subdiv/subdivpatch1base_eval.cpp
bvh/bvh_builder_subdiv.cpp)
ENDIF()
IF (EMBREE_RAY_PACKETS)
SET(EMBREE_LIBRARY_FILES_AVX512KNL ${EMBREE_LIBRARY_FILES_AVX512KNL}
geometry/instance_intersector.cpp
bvh/bvh_intersector_hybrid4_bvh4.cpp
bvh/bvh_intersector_hybrid8_bvh4.cpp
bvh/bvh_intersector_hybrid16_bvh4.cpp
bvh/bvh_intersector_hybrid4_bvh8.cpp
bvh/bvh_intersector_hybrid8_bvh8.cpp
bvh/bvh_intersector_hybrid16_bvh8.cpp
bvh/bvh_intersector_stream_bvh4.cpp
bvh/bvh_intersector_stream_bvh8.cpp
bvh/bvh_intersector_stream_filters.cpp)
ENDIF()
SET(EMBREE_LIBRARY_FILES_AVX512SKX
geometry/instance_intersector1.cpp
bvh/bvh_intersector1_bvh4.cpp
bvh/bvh_intersector1_bvh8.cpp)
IF (EMBREE_GEOMETRY_SUBDIV)
SET(EMBREE_LIBRARY_FILES_AVX512SKX ${EMBREE_LIBRARY_FILES_AVX512SKX}
geometry/grid_soa.cpp
subdiv/subdivpatch1base_eval.cpp)
ENDIF()
IF (EMBREE_RAY_PACKETS)
SET(EMBREE_LIBRARY_FILES_AVX512SKX ${EMBREE_LIBRARY_FILES_AVX512SKX}
geometry/instance_intersector.cpp
bvh/bvh_intersector_hybrid4_bvh4.cpp
bvh/bvh_intersector_hybrid8_bvh4.cpp
bvh/bvh_intersector_hybrid16_bvh4.cpp
bvh/bvh_intersector_hybrid4_bvh8.cpp
bvh/bvh_intersector_hybrid8_bvh8.cpp
bvh/bvh_intersector_hybrid16_bvh8.cpp
bvh/bvh_intersector_stream_bvh4.cpp
bvh/bvh_intersector_stream_bvh8.cpp
bvh/bvh_intersector_stream_filters.cpp)
ENDIF()
#message("SSE2: ${EMBREE_LIBRARY_FILES_SSE2}")
#message("SSE42: ${EMBREE_LIBRARY_FILES_SSE42}")
#message("AVX: ${EMBREE_LIBRARY_FILES_AVX}")
#message("AVX2: ${EMBREE_LIBRARY_FILES_AVX2}")
#message("AVX512KNL: ${EMBREE_LIBRARY_FILES_AVX512KNL}")
#message("AVX512SKX: ${EMBREE_LIBRARY_FILES_AVX512SKX}")
# replaces all .cpp files with a dummy file that includes that .cpp file
# this is to work around an ICC name mangling issue related to lambda functions under windows
@@ -262,58 +205,82 @@ MACRO (CreateISADummyFiles list isa)
DEPENDS ${src_file})
ENDFOREACH()
ENDMACRO()
#CreateISADummyFiles(EMBREE_LIBRARY_FILES_SSE2 sse2 ${EMBREE_LIBRARY_FILES_SSE2})
CreateISADummyFiles(EMBREE_LIBRARY_FILES_SSE42 sse42 ${EMBREE_LIBRARY_FILES_SSE42})
CreateISADummyFiles(EMBREE_LIBRARY_FILES_AVX avx ${EMBREE_LIBRARY_FILES_AVX})
CreateISADummyFiles(EMBREE_LIBRARY_FILES_AVX2 avx2 ${EMBREE_LIBRARY_FILES_AVX2})
CreateISADummyFiles(EMBREE_LIBRARY_FILES_AVX512KNL avx512knl ${EMBREE_LIBRARY_FILES_AVX512KNL})
CreateISADummyFiles(EMBREE_LIBRARY_FILES_AVX512SKX avx512skx ${EMBREE_LIBRARY_FILES_AVX512SKX})
MACRO (CheckGlobals library)
IF (NOT WIN32 AND NOT APPLE)
ADD_CUSTOM_TARGET(${library}_check_globals ALL COMMAND ${CMAKE_COMMAND} -D file=$<TARGET_FILE:${library}> -P ${PROJECT_SOURCE_DIR}/common/cmake/check_globals.cmake DEPENDS ${library})
ENDIF()
ENDMACRO()
DISABLE_STACK_PROTECTOR_FOR_INTERSECTORS(${EMBREE_LIBRARY_FILES})
ADD_ISPC_LIBRARY(embree ${EMBREE_LIB_TYPE} ${EMBREE_LIBRARY_FILES} $<TARGET_OBJECTS:algorithms>)
SET_TARGET_PROPERTIES(embree PROPERTIES COMPILE_FLAGS "${FLAGS_LOWEST}")
SET_TARGET_PROPERTIES(embree PROPERTIES COMPILE_DEFINITIONS "EMBREE_LOWEST_ISA")
SET_PROPERTY(TARGET embree PROPERTY FOLDER kernels)
ADD_CUSTOM_TARGET(embree_check_stack_frame_size COMMAND ${CMAKE_COMMAND} -D file=$<TARGET_FILE:embree> -P ${PROJECT_SOURCE_DIR}/common/cmake/check_stack_frame_size.cmake DEPENDS embree)
IF (NOT WIN32 AND NOT APPLE)
ADD_CUSTOM_TARGET(embree_check_stack_frame_size COMMAND ${CMAKE_COMMAND} -D file=$<TARGET_FILE:embree> -P ${PROJECT_SOURCE_DIR}/common/cmake/check_stack_frame_size.cmake DEPENDS embree)
ENDIF()
#IF (EMBREE_ISA_SSE2 AND EMBREE_LIBRARY_FILES_SSE2)
# ADD_LIBRARY(embree_sse2 STATIC ${EMBREE_LIBRARY_FILES_SSE2})
# SET_TARGET_PROPERTIES(embree_sse2 PROPERTIES COMPILE_FLAGS "${FLAGS_SSE2}")
# SET_PROPERTY(TARGET embree_sse2 PROPERTY FOLDER kernels)
# SET(EMBREE_LIBRARIES ${EMBREE_LIBRARIES} embree_sse2)
# CheckGlobals(embree_sse2)
#ENDIF ()
IF (EMBREE_ISA_SSE42 AND EMBREE_LIBRARY_FILES_SSE42)
DISABLE_STACK_PROTECTOR_FOR_INTERSECTORS(${EMBREE_LIBRARY_FILES_SSE42})
ADD_LIBRARY(embree_sse42 STATIC ${EMBREE_LIBRARY_FILES_SSE42})
SET_TARGET_PROPERTIES(embree_sse42 PROPERTIES COMPILE_FLAGS "${FLAGS_SSE42}")
SET_PROPERTY(TARGET embree_sse42 PROPERTY FOLDER kernels)
SET(EMBREE_LIBRARIES ${EMBREE_LIBRARIES} embree_sse42)
ADD_CUSTOM_TARGET(embree_sse42_check_globals ALL COMMAND ${CMAKE_COMMAND} -D file=$<TARGET_FILE:embree_sse42> -P ${PROJECT_SOURCE_DIR}/common/cmake/check_globals.cmake DEPENDS embree_sse42)
CheckGlobals(embree_sse42)
ENDIF ()
IF (EMBREE_ISA_AVX AND EMBREE_LIBRARY_FILES_AVX)
DISABLE_STACK_PROTECTOR_FOR_INTERSECTORS(${EMBREE_LIBRARY_FILES_AVX})
ADD_LIBRARY(embree_avx STATIC ${EMBREE_LIBRARY_FILES_AVX})
SET_TARGET_PROPERTIES(embree_avx PROPERTIES COMPILE_FLAGS "${FLAGS_AVX}")
SET_PROPERTY(TARGET embree_avx PROPERTY FOLDER kernels)
SET(EMBREE_LIBRARIES ${EMBREE_LIBRARIES} embree_avx)
ADD_CUSTOM_TARGET(embree_avx_check_globals ALL COMMAND ${CMAKE_COMMAND} -D file=$<TARGET_FILE:embree_avx> -P ${PROJECT_SOURCE_DIR}/common/cmake/check_globals.cmake DEPENDS embree_avx)
CheckGlobals(embree_avx)
ENDIF()
IF (EMBREE_ISA_AVX2 AND EMBREE_LIBRARY_FILES_AVX2)
DISABLE_STACK_PROTECTOR_FOR_INTERSECTORS(${EMBREE_LIBRARY_FILES_AVX2})
ADD_LIBRARY(embree_avx2 STATIC ${EMBREE_LIBRARY_FILES_AVX2})
SET_TARGET_PROPERTIES(embree_avx2 PROPERTIES COMPILE_FLAGS "${FLAGS_AVX2}")
SET_PROPERTY(TARGET embree_avx2 PROPERTY FOLDER kernels)
SET(EMBREE_LIBRARIES ${EMBREE_LIBRARIES} embree_avx2)
ADD_CUSTOM_TARGET(embree_avx2_check_globals ALL COMMAND ${CMAKE_COMMAND} -D file=$<TARGET_FILE:embree_avx2> -P ${PROJECT_SOURCE_DIR}/common/cmake/check_globals.cmake DEPENDS embree_avx2)
CheckGlobals(embree_avx2)
ENDIF()
IF (EMBREE_ISA_AVX512KNL AND EMBREE_LIBRARY_FILES_AVX512KNL)
DISABLE_STACK_PROTECTOR_FOR_INTERSECTORS(${EMBREE_LIBRARY_FILES_AVX512KNL})
ADD_LIBRARY(embree_avx512knl STATIC ${EMBREE_LIBRARY_FILES_AVX512KNL})
SET_TARGET_PROPERTIES(embree_avx512knl PROPERTIES COMPILE_FLAGS "${FLAGS_AVX512KNL}")
SET_PROPERTY(TARGET embree_avx512knl PROPERTY FOLDER kernels)
SET(EMBREE_LIBRARIES ${EMBREE_LIBRARIES} embree_avx512knl)
ADD_CUSTOM_TARGET(embree_avx512knl_check_globals ALL COMMAND ${CMAKE_COMMAND} -D file=$<TARGET_FILE:embree_avx512knl> -P ${PROJECT_SOURCE_DIR}/common/cmake/check_globals.cmake DEPENDS embree_avx512knl)
CheckGlobals(embree_avx512knl)
ENDIF()
IF (EMBREE_ISA_AVX512SKX AND EMBREE_LIBRARY_FILES_AVX512SKX)
DISABLE_STACK_PROTECTOR_FOR_INTERSECTORS(${EMBREE_LIBRARY_FILES_AVX512SKX})
ADD_LIBRARY(embree_avx512skx STATIC ${EMBREE_LIBRARY_FILES_AVX512SKX})
SET_TARGET_PROPERTIES(embree_avx512skx PROPERTIES COMPILE_FLAGS "${FLAGS_AVX512SKX}")
SET_PROPERTY(TARGET embree_avx512skx PROPERTY FOLDER kernels)
SET(EMBREE_LIBRARIES ${EMBREE_LIBRARIES} embree_avx512skx)
ADD_CUSTOM_TARGET(embree_avx512skx_check_globals ALL COMMAND ${CMAKE_COMMAND} -D file=$<TARGET_FILE:embree_avx512skx> -P ${PROJECT_SOURCE_DIR}/common/cmake/check_globals.cmake DEPENDS embree_avx512skx)
CheckGlobals(embree_avx512skx)
ENDIF()
TARGET_LINK_LIBRARIES(embree ${EMBREE_LIBRARIES} sys simd lexers tasking)
TARGET_LINK_LIBRARIES(embree ${EMBREE_LIBRARIES} sys math simd lexers tasking)
SET_TARGET_PROPERTIES(embree PROPERTIES INSTALL_RPATH "") # no RPATH for installed libembree
IF (WIN32)
+13 -10
View File
@@ -55,7 +55,7 @@ namespace embree
typename CreateLeafFunc,
typename ProgressMonitor>
class BuilderT : private Settings
class BuilderT
{
ALIGNED_CLASS;
friend struct BVHBuilderHair;
@@ -84,7 +84,8 @@ namespace embree
const ProgressMonitor& progressMonitor,
const Settings settings)
: Settings(settings),
: cfg(settings),
prims(prims),
createAlloc(createAlloc),
createAlignedNode(createAlignedNode),
setAlignedNode(setAlignedNode),
@@ -98,12 +99,12 @@ namespace embree
NodeRef createLargeLeaf(size_t depth, const PrimInfoRange& pinfo, Allocator alloc)
{
/* this should never occur but is a fatal error */
if (depth > maxDepth)
if (depth > cfg.maxDepth)
throw_RTCError(RTC_UNKNOWN_ERROR,"depth limit reached");
/* create leaf for few primitives */
if (pinfo.size() <= maxLeafSize)
return createLeaf(depth,pinfo,alloc);
if (pinfo.size() <= cfg.maxLeafSize)
return createLeaf(prims,pinfo,alloc);
/* fill all children by always splitting the largest one */
PrimInfoRange children[MAX_BRANCHING_FACTOR];
@@ -118,7 +119,7 @@ namespace embree
for (unsigned i=0; i<numChildren; i++)
{
/* ignore leaves as they cannot get split */
if (children[i].size() <= maxLeafSize)
if (children[i].size() <= cfg.maxLeafSize)
continue;
/* remember child with largest size */
@@ -139,7 +140,7 @@ namespace embree
children[numChildren+0] = right;
numChildren++;
} while (numChildren < branchingFactor);
} while (numChildren < cfg.branchingFactor);
/* create node */
auto node = createAlignedNode(alloc);
@@ -232,7 +233,7 @@ namespace embree
PrimInfoRange children[MAX_BRANCHING_FACTOR];
/* create leaf node */
if (depth+MIN_LARGE_LEAF_LEVELS >= maxDepth || pinfo.size() <= minLeafSize) {
if (depth+MIN_LARGE_LEAF_LEVELS >= cfg.maxDepth || pinfo.size() <= cfg.minLeafSize) {
alignedHeuristic.deterministic_order(pinfo);
return createLargeLeaf(depth,pinfo,alloc);
}
@@ -250,7 +251,7 @@ namespace embree
for (size_t i=0; i<numChildren; i++)
{
/* ignore leaves as they cannot get split */
if (children[i].size() <= minLeafSize)
if (children[i].size() <= cfg.minLeafSize)
continue;
/* remember child with largest area */
@@ -271,7 +272,7 @@ namespace embree
children[numChildren+0] = right;
numChildren++;
} while (numChildren < branchingFactor);
} while (numChildren < cfg.branchingFactor);
/* create aligned node */
if (aligned)
@@ -329,6 +330,8 @@ namespace embree
}
private:
Settings cfg;
PrimRef* prims;
const CreateAllocFunc& createAlloc;
const CreateAlignedNodeFunc& createAlignedNode;
const SetAlignedNodeFunc& setAlignedNode;
+75 -53
View File
@@ -127,18 +127,19 @@ namespace embree
const Mesh* mesh = scene->get<Mesh>(geomID);
const LBBox3fa lbounds = mesh->linearBounds(primID, time_range);
const unsigned num_time_segments = mesh->numTimeSegments();
const range<int> tbounds = getTimeSegmentRange(time_range, num_time_segments);
const range<int> tbounds = getTimeSegmentRange(time_range, (float)num_time_segments);
return PrimRefMB (lbounds, tbounds.size(), num_time_segments, geomID, primID);
}
__forceinline PrimRefMB operator() (const PrimRefMB& prim, const BBox1f time_range, const LinearSpace3fa& space) const
// __noinline is workaround for ICC16 bug under MacOSX
__noinline PrimRefMB operator() (const PrimRefMB& prim, const BBox1f time_range, const LinearSpace3fa& space) const
{
const unsigned geomID = prim.geomID();
const unsigned primID = prim.primID();
const Mesh* mesh = scene->get<Mesh>(geomID);
const LBBox3fa lbounds = mesh->linearBounds(space, primID, time_range);
const unsigned num_time_segments = mesh->numTimeSegments();
const range<int> tbounds = getTimeSegmentRange(time_range, num_time_segments);
const range<int> tbounds = getTimeSegmentRange(time_range, (float)num_time_segments);
return PrimRefMB (lbounds, tbounds.size(), num_time_segments, geomID, primID);
}
@@ -146,7 +147,8 @@ namespace embree
return scene->get<Mesh>(prim.geomID())->linearBounds(prim.primID(), time_range);
}
__forceinline LBBox3fa linearBounds(const PrimRefMB& prim, const BBox1f time_range, const LinearSpace3fa& space) const {
// __noinline is workaround for ICC16 bug under MacOSX
__noinline LBBox3fa linearBounds(const PrimRefMB& prim, const BBox1f time_range, const LinearSpace3fa& space) const {
return scene->get<Mesh>(prim.geomID())->linearBounds(space, prim.primID(), time_range);
}
};
@@ -182,8 +184,8 @@ namespace embree
__forceinline BuildRecord (size_t depth)
: depth(depth) {}
__forceinline BuildRecord (const SetMB& prims, const BinSplit<MBLUR_NUM_OBJECT_BINS>& split, size_t depth)
: depth(depth), prims(prims), split(split) {}
__forceinline BuildRecord (const SetMB& prims, size_t depth)
: depth(depth), prims(prims) {}
__forceinline friend bool operator< (const BuildRecord& a, const BuildRecord& b) {
return a.prims.size() < b.prims.size();
@@ -196,7 +198,19 @@ namespace embree
public:
size_t depth; //!< Depth of the root of this subtree.
SetMB prims; //!< The list of primitives.
BinSplit<MBLUR_NUM_OBJECT_BINS> split; //!< The best split for the primitives.
};
struct BuildRecordSplit : public BuildRecord
{
__forceinline BuildRecordSplit () {}
__forceinline BuildRecordSplit (size_t depth)
: BuildRecord(depth) {}
__forceinline BuildRecordSplit (const BuildRecord& record, const BinSplit<MBLUR_NUM_OBJECT_BINS>& split)
: BuildRecord(record), split(split) {}
BinSplit<MBLUR_NUM_OBJECT_BINS> split;
};
template<
@@ -209,18 +223,18 @@ namespace embree
typename CreateLeafFunc,
typename ProgressMonitor>
class BuilderT : private Settings
class BuilderT
{
ALIGNED_CLASS;
static const size_t MAX_BRANCHING_FACTOR = 8; //!< maximal supported BVH branching factor
static const size_t MIN_LARGE_LEAF_LEVELS = 8; //!< create balanced tree if we are that many levels before the maximal tree depth
typedef BVHNodeRecordMB4D<NodeRef> NodeRecordMB4D;
typedef BinSplit<MBLUR_NUM_OBJECT_BINS> Split;
typedef mvector<PrimRefMB>* PrimRefVector;
typedef SharedVector<mvector<PrimRefMB>> SharedPrimRefVector;
typedef LocalChildListT<BuildRecord,MAX_BRANCHING_FACTOR> LocalChildList;
typedef LocalChildListT<BuildRecordSplit,MAX_BRANCHING_FACTOR> LocalChildListSplit;
public:
@@ -232,13 +246,13 @@ namespace embree
const CreateLeafFunc createLeaf,
const ProgressMonitor progressMonitor,
const Settings& settings)
: Settings(settings),
: cfg(settings),
heuristicObjectSplit(),
heuristicTemporalSplit(device, recalculatePrimRef),
recalculatePrimRef(recalculatePrimRef), createAlloc(createAlloc), createNode(createNode), setNode(setNode), createLeaf(createLeaf),
progressMonitor(progressMonitor)
{
if (branchingFactor > MAX_BRANCHING_FACTOR)
if (cfg.branchingFactor > MAX_BRANCHING_FACTOR)
throw_RTCError(RTC_UNKNOWN_ERROR,"bvh_builder: branching factor too large");
}
@@ -246,18 +260,18 @@ namespace embree
const Split find(const SetMB& set)
{
/* first try standard object split */
const Split object_split = heuristicObjectSplit.find(set,logBlockSize);
const Split object_split = heuristicObjectSplit.find(set,cfg.logBlockSize);
const float object_split_sah = object_split.splitSAH();
/* test temporal splits only when object split was bad */
const float leaf_sah = set.leafSAH(logBlockSize);
const float leaf_sah = set.leafSAH(cfg.logBlockSize);
if (object_split_sah < 0.50f*leaf_sah)
return object_split;
/* do temporal splits only if the the time range is big enough */
if (set.time_range.size() > 1.01f/float(set.max_num_time_segments))
{
const Split temporal_split = heuristicTemporalSplit.find(set,logBlockSize);
const Split temporal_split = heuristicTemporalSplit.find(set,cfg.logBlockSize);
const float temporal_split_sah = temporal_split.splitSAH();
/* take temporal split if it improved SAH */
@@ -269,20 +283,20 @@ namespace embree
}
/*! array partitioning */
__forceinline std::unique_ptr<mvector<PrimRefMB>> split(const BuildRecord& brecord, BuildRecord& lrecord, BuildRecord& rrecord)
__forceinline std::unique_ptr<mvector<PrimRefMB>> split(const Split& split, const SetMB& set, SetMB& lset, SetMB& rset)
{
/* perform object split */
if (likely(brecord.split.data == Split::SPLIT_OBJECT)) {
heuristicObjectSplit.split(brecord.split,brecord.prims,lrecord.prims,rrecord.prims);
if (likely(split.data == Split::SPLIT_OBJECT)) {
heuristicObjectSplit.split(split,set,lset,rset);
}
/* perform temporal split */
else if (likely(brecord.split.data == Split::SPLIT_TEMPORAL)) {
return heuristicTemporalSplit.split(brecord.split,brecord.prims,lrecord.prims,rrecord.prims);
else if (likely(split.data == Split::SPLIT_TEMPORAL)) {
return heuristicTemporalSplit.split(split,set,lset,rset);
}
/* perform fallback split */
else if (unlikely(brecord.split.data == Split::SPLIT_FALLBACK)) {
brecord.prims.deterministic_order();
splitFallback(brecord.prims,lrecord.prims,rrecord.prims);
else if (unlikely(split.data == Split::SPLIT_FALLBACK)) {
set.deterministic_order();
splitFallback(set,lset,rset);
}
else
assert(false);
@@ -291,16 +305,16 @@ namespace embree
}
/*! finds the best fallback split */
__forceinline Split findFallback(const SetMB& set)
__noinline Split findFallback(const SetMB& set)
{
/* if a leaf can only hold a single time-segment, we might have to do additional temporal splits */
if (singleLeafTimeSegment)
if (cfg.singleLeafTimeSegment)
{
/* test if one primitive has more than one time segment in time range, if so split time */
for (size_t i=set.object_range.begin(); i<set.object_range.end(); i++)
{
const PrimRefMB& prim = (*set.prims)[i];
const range<int> itime_range = getTimeSegmentRange(set.time_range,prim.totalTimeSegments());
const range<int> itime_range = getTimeSegmentRange(set.time_range,(float)prim.totalTimeSegments());
const int localTimeSegments = itime_range.size();
assert(localTimeSegments > 0);
if (localTimeSegments > 1) {
@@ -339,20 +353,20 @@ namespace embree
const NodeRecordMB4D createLargeLeaf(const BuildRecord& in, Allocator alloc)
{
/* this should never occur but is a fatal error */
if (in.depth > maxDepth)
if (in.depth > cfg.maxDepth)
throw_RTCError(RTC_UNKNOWN_ERROR,"depth limit reached");
/* replace already found split by fallback split */
const BuildRecord current(in.prims,findFallback(in.prims),in.depth);
const BuildRecordSplit current(BuildRecord(in.prims,in.depth),findFallback(in.prims));
/* create leaf for few primitives */
if (current.size() <= maxLeafSize && current.split.data != Split::SPLIT_TEMPORAL)
if (current.size() <= cfg.maxLeafSize && current.split.data != Split::SPLIT_TEMPORAL)
return createLeaf(current,alloc);
/* fill all children by always splitting the largest one */
bool hasTimeSplits = false;
NodeRecordMB4D values[MAX_BRANCHING_FACTOR];
LocalChildList children(current);
LocalChildListSplit children(current);
do {
/* find best child with largest bounding box area */
@@ -361,7 +375,7 @@ namespace embree
for (size_t i=0; i<children.size(); i++)
{
/* ignore leaves as they cannot get split */
if (children[i].size() <= maxLeafSize && children[i].split.data != Split::SPLIT_TEMPORAL)
if (children[i].size() <= cfg.maxLeafSize && children[i].split.data != Split::SPLIT_TEMPORAL)
continue;
/* remember child with largest size */
@@ -373,10 +387,10 @@ namespace embree
if (bestChild == -1) break;
/* perform best found split */
BuildRecord& brecord = children[bestChild];
BuildRecord lrecord(current.depth+1);
BuildRecord rrecord(current.depth+1);
std::unique_ptr<mvector<PrimRefMB>> new_vector = split(brecord,lrecord,rrecord);
BuildRecordSplit& brecord = children[bestChild];
BuildRecordSplit lrecord(current.depth+1);
BuildRecordSplit rrecord(current.depth+1);
std::unique_ptr<mvector<PrimRefMB>> new_vector = split(brecord.split,brecord.prims,lrecord.prims,rrecord.prims);
hasTimeSplits |= new_vector != nullptr;
/* find new splits */
@@ -384,7 +398,7 @@ namespace embree
rrecord.split = findFallback(rrecord.prims);
children.split(bestChild,lrecord,rrecord,std::move(new_vector));
} while (children.size() < branchingFactor);
} while (children.size() < cfg.branchingFactor);
/* create node */
auto node = createNode(alloc, hasTimeSplits);
@@ -411,52 +425,59 @@ namespace embree
alloc = createAlloc();
/* call memory monitor function to signal progress */
if (toplevel && current.size() <= singleThreadThreshold)
if (toplevel && current.size() <= cfg.singleThreadThreshold)
progressMonitor(current.size());
/*! find best split */
const Split csplit = find(current.prims);
/*! compute leaf and split cost */
const float leafSAH = intCost*current.prims.leafSAH(logBlockSize);
const float splitSAH = travCost*current.prims.halfArea()+intCost*current.split.splitSAH();
const float leafSAH = cfg.intCost*current.prims.leafSAH(cfg.logBlockSize);
const float splitSAH = cfg.travCost*current.prims.halfArea()+cfg.intCost*csplit.splitSAH();
assert((current.size() == 0) || ((leafSAH >= 0) && (splitSAH >= 0)));
/*! create a leaf node when threshold reached or SAH tells us to stop */
if (current.size() <= minLeafSize || current.depth+MIN_LARGE_LEAF_LEVELS >= maxDepth || (current.size() <= maxLeafSize && leafSAH <= splitSAH)) {
if (current.size() <= cfg.minLeafSize || current.depth+MIN_LARGE_LEAF_LEVELS >= cfg.maxDepth || (current.size() <= cfg.maxLeafSize && leafSAH <= splitSAH)) {
current.prims.deterministic_order();
return createLargeLeaf(current,alloc);
}
/*! initialize child list */
bool hasTimeSplits = false;
/*! perform initial split */
SetMB lprims,rprims;
std::unique_ptr<mvector<PrimRefMB>> new_vector = split(csplit,current.prims,lprims,rprims);
bool hasTimeSplits = new_vector != nullptr;
NodeRecordMB4D values[MAX_BRANCHING_FACTOR];
LocalChildList children(current);
{
BuildRecord lrecord(lprims,current.depth+1);
BuildRecord rrecord(rprims,current.depth+1);
children.split(0,lrecord,rrecord,std::move(new_vector));
}
/*! split until node is full or SAH tells us to stop */
do {
while (children.size() < cfg.branchingFactor)
{
/*! find best child to split */
float bestArea = neg_inf;
ssize_t bestChild = -1;
for (size_t i=0; i<children.size(); i++)
{
if (children[i].size() <= minLeafSize) continue;
if (children[i].size() <= cfg.minLeafSize) continue;
if (expectedApproxHalfArea(children[i].prims.geomBounds) > bestArea) {
bestChild = i; bestArea = expectedApproxHalfArea(children[i].prims.geomBounds);
}
}
if (bestChild == -1) break;
/* perform best found split */
/* perform split */
BuildRecord& brecord = children[bestChild];
BuildRecord lrecord(current.depth+1);
BuildRecord rrecord(current.depth+1);
std::unique_ptr<mvector<PrimRefMB>> new_vector = split(brecord,lrecord,rrecord);
Split csplit = find(brecord.prims);
std::unique_ptr<mvector<PrimRefMB>> new_vector = split(csplit,brecord.prims,lrecord.prims,rrecord.prims);
hasTimeSplits |= new_vector != nullptr;
/* find new splits */
lrecord.split = find(lrecord.prims);
rrecord.split = find(rrecord.prims);
children.split(bestChild,lrecord,rrecord,std::move(new_vector));
} while (children.size() < branchingFactor);
}
/* sort buildrecords for simpler shadow ray traversal */
//std::sort(&children[0],&children[children.size()],std::greater<BuildRecord>()); // FIXME: reduces traversal performance of bvh8.triangle4 (need to verified) !!
@@ -466,7 +487,7 @@ namespace embree
LBBox3fa gbounds = empty;
/* spawn tasks */
if (unlikely(current.size() > singleThreadThreshold))
if (unlikely(current.size() > cfg.singleThreadThreshold))
{
/*! parallel_for is faster than spawing sub-tasks */
parallel_for(size_t(0), children.size(), [&] (const range<size_t>& r) {
@@ -503,12 +524,13 @@ namespace embree
__forceinline const NodeRecordMB4D operator() (mvector<PrimRefMB>& prims, const PrimInfoMB& pinfo)
{
const SetMB set(pinfo,&prims);
auto ret = recurse(BuildRecord(set,find(set),1),nullptr,true);
auto ret = recurse(BuildRecord(set,1),nullptr,true);
_mm_mfence(); // to allow non-temporal stores during build
return ret;
}
private:
Settings cfg;
HeuristicArrayBinningMB<PrimRefMB,MBLUR_NUM_OBJECT_BINS> heuristicObjectSplit;
HeuristicMBlurTemporalSplit<PrimRefMB,RecalculatePrimRef,MBLUR_NUM_TEMPORAL_BINS> heuristicTemporalSplit;
const RecalculatePrimRef recalculatePrimRef;
+57 -69
View File
@@ -67,16 +67,14 @@ namespace embree
template<typename NodeRef,
typename RecalculatePrimRef,
typename CreateAllocFunc,
typename CreateAlignedNodeFunc,
typename SetAlignedNodeFunc,
typename CreateUnalignedNodeFunc,
typename SetUnalignedNodeFunc,
typename CreateAlignedNode4DFunc,
typename SetAlignedNode4DFunc,
typename CreateAlignedNodeMBFunc,
typename SetAlignedNodeMBFunc,
typename CreateUnalignedNodeMBFunc,
typename SetUnalignedNodeMBFunc,
typename CreateLeafFunc,
typename ProgressMonitor>
class BuilderT : private Settings
class BuilderT
{
ALIGNED_CLASS;
@@ -99,23 +97,20 @@ namespace embree
BuilderT (Scene* scene,
const RecalculatePrimRef& recalculatePrimRef,
const CreateAllocFunc& createAlloc,
const CreateAlignedNodeFunc& createAlignedNode,
const SetAlignedNodeFunc& setAlignedNode,
const CreateUnalignedNodeFunc& createUnalignedNode,
const SetUnalignedNodeFunc& setUnalignedNode,
const CreateAlignedNode4DFunc& createAlignedNode4D,
const SetAlignedNode4DFunc& setAlignedNode4D,
const CreateAlignedNodeMBFunc& createAlignedNodeMB,
const SetAlignedNodeMBFunc& setAlignedNodeMB,
const CreateUnalignedNodeMBFunc& createUnalignedNodeMB,
const SetUnalignedNodeMBFunc& setUnalignedNodeMB,
const CreateLeafFunc& createLeaf,
const ProgressMonitor& progressMonitor,
const Settings settings)
: Settings(settings),
: cfg(settings),
scene(scene),
recalculatePrimRef(recalculatePrimRef),
createAlloc(createAlloc),
createAlignedNode(createAlignedNode), setAlignedNode(setAlignedNode),
createUnalignedNode(createUnalignedNode), setUnalignedNode(setUnalignedNode),
createAlignedNode4D(createAlignedNode4D), setAlignedNode4D(setAlignedNode4D),
createAlignedNodeMB(createAlignedNodeMB), setAlignedNodeMB(setAlignedNodeMB),
createUnalignedNodeMB(createUnalignedNodeMB), setUnalignedNodeMB(setUnalignedNodeMB),
createLeaf(createLeaf),
progressMonitor(progressMonitor),
unalignedHeuristic(scene),
@@ -145,14 +140,14 @@ namespace embree
}
/*! creates a large leaf that could be larger than supported by the BVH */
NodeRecordMB createLargeLeaf(BuildRecord& current, Allocator alloc)
NodeRecordMB4D createLargeLeaf(BuildRecord& current, Allocator alloc)
{
/* this should never occur but is a fatal error */
if (current.depth > maxDepth)
if (current.depth > cfg.maxDepth)
throw_RTCError(RTC_UNKNOWN_ERROR,"depth limit reached");
/* create leaf for few primitives */
if (current.size() <= maxLeafSize)
if (current.size() <= cfg.maxLeafSize)
return createLeaf(current.prims,alloc);
/* fill all children by always splitting the largest one */
@@ -166,7 +161,7 @@ namespace embree
for (unsigned i=0; i<children.size(); i++)
{
/* ignore leaves as they cannot get split */
if (children[i].size() <= maxLeafSize)
if (children[i].size() <= cfg.maxLeafSize)
continue;
/* remember child with largest size */
@@ -183,19 +178,19 @@ namespace embree
splitFallback(children[bestChild].prims,left.prims,right.prims);
children.split(bestChild,left,right,std::unique_ptr<mvector<PrimRefMB>>());
} while (children.size() < branchingFactor);
} while (children.size() < cfg.branchingFactor);
/* create node */
NodeRef node = createAlignedNode(alloc);
NodeRef node = createAlignedNodeMB(alloc,false);
LBBox3fa bounds = empty;
for (size_t i=0; i<children.size(); i++) {
const auto child = createLargeLeaf(children[i],alloc);
setAlignedNode(node,i,NodeRecordMB4D(child.ref,child.lbounds,children[i].prims.time_range));
setAlignedNodeMB(node,i,child);
bounds.extend(child.lbounds);
}
return NodeRecordMB(node,bounds);
return NodeRecordMB4D(node,bounds,current.prims.time_range);
}
/*! performs split */
@@ -227,7 +222,7 @@ namespace embree
typename HeuristicTemporal::Split temporal_split;
if (bestSAH > 0.5f*leafSAH) {
if (current.prims.time_range.size() > 1.01f/float(current.prims.max_num_time_segments)) {
temporal_split = temporalSplitHeuristic.find(current.prims, 0);
temporal_split = temporalSplitHeuristic.find(current.prims, size_t(0));
temporal_split_sah = temporal_split.splitSAH();
bestSAH = min(temporal_split_sah,bestSAH);
}
@@ -259,7 +254,7 @@ namespace embree
}
/*! recursive build */
NodeRecordMB recurse(BuildRecord& current, Allocator alloc, bool toplevel)
NodeRecordMB4D recurse(BuildRecord& current, Allocator alloc, bool toplevel)
{
/* get thread local allocator */
if (!alloc)
@@ -270,7 +265,7 @@ namespace embree
progressMonitor(current.size());
/* create leaf node */
if (current.depth+MIN_LARGE_LEAF_LEVELS >= maxDepth || current.size() <= minLeafSize) {
if (current.depth+MIN_LARGE_LEAF_LEVELS >= cfg.maxDepth || current.size() <= cfg.minLeafSize) {
current.prims.deterministic_order();
return createLargeLeaf(current,alloc);
}
@@ -288,7 +283,7 @@ namespace embree
for (size_t i=0; i<children.size(); i++)
{
/* ignore leaves as they cannot get split */
if (children[i].size() <= minLeafSize)
if (children[i].size() <= cfg.minLeafSize)
continue;
/* remember child with largest area */
@@ -306,12 +301,12 @@ namespace embree
std::unique_ptr<mvector<PrimRefMB>> new_vector = split(children[bestChild],left,right,aligned,timesplit);
children.split(bestChild,left,right,std::move(new_vector));
} while (children.size() < branchingFactor);
} while (children.size() < cfg.branchingFactor);
/* create time split node */
if (timesplit)
{
const NodeRef node = createAlignedNode4D(alloc);
const NodeRef node = createAlignedNodeMB(alloc,true);
/* spawn tasks or ... */
if (current.size() > SINGLE_THREADED_THRESHOLD)
@@ -319,7 +314,7 @@ namespace embree
parallel_for(size_t(0), children.size(), [&] (const range<size_t>& r) {
for (size_t i=r.begin(); i<r.end(); i++) {
const auto child = recurse(children[i],nullptr,true);
setAlignedNode4D(node,i,NodeRecordMB4D(child.ref,child.lbounds,children[i].prims.time_range));
setAlignedNodeMB(node,i,child);
_mm_mfence(); // to allow non-temporal stores during build
}
});
@@ -328,18 +323,18 @@ namespace embree
else {
for (size_t i=0; i<children.size(); i++) {
const auto child = recurse(children[i],alloc,false);
setAlignedNode4D(node,i,NodeRecordMB4D(child.ref,child.lbounds,children[i].prims.time_range));
setAlignedNodeMB(node,i,child);
}
}
const LBBox3fa bounds = current.prims.linearBounds(recalculatePrimRef);
return NodeRecordMB(node,bounds);
return NodeRecordMB4D(node,bounds,current.prims.time_range);
}
/* create aligned node */
else if (aligned)
{
const NodeRef node = createAlignedNode(alloc);
const NodeRef node = createAlignedNodeMB(alloc,false);
/* spawn tasks or ... */
if (current.size() > SINGLE_THREADED_THRESHOLD)
@@ -348,7 +343,7 @@ namespace embree
parallel_for(size_t(0), children.size(), [&] (const range<size_t>& r) {
for (size_t i=r.begin(); i<r.end(); i++) {
const auto child = recurse(children[i],nullptr,true);
setAlignedNode(node,i,NodeRecordMB4D(child.ref,child.lbounds,children[i].prims.time_range));
setAlignedNodeMB(node,i,child);
cbounds[i] = child.lbounds;
_mm_mfence(); // to allow non-temporal stores during build
}
@@ -358,7 +353,7 @@ namespace embree
for (size_t i=0; i<children.size(); i++)
bounds.extend(cbounds[i]);
return NodeRecordMB(node,bounds);
return NodeRecordMB4D(node,bounds,current.prims.time_range);
}
/* ... continue sequentially */
else
@@ -366,17 +361,17 @@ namespace embree
LBBox3fa bounds = empty;
for (size_t i=0; i<children.size(); i++) {
const auto child = recurse(children[i],alloc,false);
setAlignedNode(node,i,NodeRecordMB4D(child.ref,child.lbounds,children[i].prims.time_range));
setAlignedNodeMB(node,i,child);
bounds.extend(child.lbounds);
}
return NodeRecordMB(node,bounds);
return NodeRecordMB4D(node,bounds,current.prims.time_range);
}
}
/* create unaligned node */
else
{
const NodeRef node = createUnalignedNode(alloc);
const NodeRef node = createUnalignedNodeMB(alloc);
/* spawn tasks or ... */
if (current.size() > SINGLE_THREADED_THRESHOLD)
@@ -386,7 +381,7 @@ namespace embree
const LinearSpace3fa space = unalignedHeuristic.computeAlignedSpaceMB(scene,children[i].prims);
const LBBox3fa lbounds = children[i].prims.linearBounds(recalculatePrimRef,space);
const auto child = recurse(children[i],nullptr,true);
setUnalignedNode(node,i,child.ref,space,lbounds,children[i].prims.time_range);
setUnalignedNodeMB(node,i,child.ref,space,lbounds,children[i].prims.time_range);
_mm_mfence(); // to allow non-temporal stores during build
}
});
@@ -398,19 +393,19 @@ namespace embree
const LinearSpace3fa space = unalignedHeuristic.computeAlignedSpaceMB(scene,children[i].prims);
const LBBox3fa lbounds = children[i].prims.linearBounds(recalculatePrimRef,space);
const auto child = recurse(children[i],alloc,false);
setUnalignedNode(node,i,child.ref,space,lbounds,children[i].prims.time_range);
setUnalignedNodeMB(node,i,child.ref,space,lbounds,children[i].prims.time_range);
}
}
const LBBox3fa bounds = current.prims.linearBounds(recalculatePrimRef);
return NodeRecordMB(node,bounds);
return NodeRecordMB4D(node,bounds,current.prims.time_range);
}
}
public:
/*! entry point into builder */
NodeRecordMB operator() (mvector<PrimRefMB>& prims, const PrimInfoMB& pinfo)
NodeRecordMB4D operator() (mvector<PrimRefMB>& prims, const PrimInfoMB& pinfo)
{
BuildRecord record(SetMB(pinfo,&prims),1);
auto root = recurse(record,nullptr,true);
@@ -419,15 +414,14 @@ namespace embree
}
private:
Settings cfg;
Scene* scene;
const RecalculatePrimRef& recalculatePrimRef;
const CreateAllocFunc& createAlloc;
const CreateAlignedNodeFunc& createAlignedNode;
const SetAlignedNodeFunc& setAlignedNode;
const CreateUnalignedNodeFunc& createUnalignedNode;
const SetUnalignedNodeFunc& setUnalignedNode;
const CreateAlignedNode4DFunc& createAlignedNode4D;
const SetAlignedNode4DFunc& setAlignedNode4D;
const CreateAlignedNodeMBFunc& createAlignedNodeMB;
const SetAlignedNodeMBFunc& setAlignedNodeMB;
const CreateUnalignedNodeMBFunc& createUnalignedNodeMB;
const SetUnalignedNodeMBFunc& setUnalignedNodeMB;
const CreateLeafFunc& createLeaf;
const ProgressMonitor& progressMonitor;
@@ -440,38 +434,32 @@ namespace embree
template<typename NodeRef,
typename RecalculatePrimRef,
typename CreateAllocFunc,
typename CreateAlignedNodeFunc,
typename SetAlignedNodeFunc,
typename CreateUnalignedNodeFunc,
typename SetUnalignedNodeFunc,
typename CreateAlignedNode4DFunc,
typename SetAlignedNode4DFunc,
typename CreateAlignedNodeMBFunc,
typename SetAlignedNodeMBFunc,
typename CreateUnalignedNodeMBFunc,
typename SetUnalignedNodeMBFunc,
typename CreateLeafFunc,
typename ProgressMonitor>
static BVHNodeRecordMB<NodeRef> build (Scene* scene, mvector<PrimRefMB>& prims, const PrimInfoMB& pinfo,
static BVHNodeRecordMB4D<NodeRef> build (Scene* scene, mvector<PrimRefMB>& prims, const PrimInfoMB& pinfo,
const RecalculatePrimRef& recalculatePrimRef,
const CreateAllocFunc& createAlloc,
const CreateAlignedNodeFunc& createAlignedNode,
const SetAlignedNodeFunc& setAlignedNode,
const CreateUnalignedNodeFunc& createUnalignedNode,
const SetUnalignedNodeFunc& setUnalignedNode,
const CreateAlignedNode4DFunc& createAlignedNode4D,
const SetAlignedNode4DFunc& setAlignedNode4D,
const CreateAlignedNodeMBFunc& createAlignedNodeMB,
const SetAlignedNodeMBFunc& setAlignedNodeMB,
const CreateUnalignedNodeMBFunc& createUnalignedNodeMB,
const SetUnalignedNodeMBFunc& setUnalignedNodeMB,
const CreateLeafFunc& createLeaf,
const ProgressMonitor& progressMonitor,
const Settings settings)
{
typedef BuilderT<NodeRef,RecalculatePrimRef,CreateAllocFunc,
CreateAlignedNodeFunc,SetAlignedNodeFunc,
CreateUnalignedNodeFunc,SetUnalignedNodeFunc,
CreateAlignedNode4DFunc,SetAlignedNode4DFunc,
CreateAlignedNodeMBFunc,SetAlignedNodeMBFunc,
CreateUnalignedNodeMBFunc,SetUnalignedNodeMBFunc,
CreateLeafFunc,ProgressMonitor> Builder;
Builder builder(scene,recalculatePrimRef,createAlloc,
createAlignedNode,setAlignedNode,
createUnalignedNode,setUnalignedNode,
createAlignedNode4D,setAlignedNode4D,
createAlignedNodeMB,setAlignedNodeMB,
createUnalignedNodeMB,setUnalignedNodeMB,
createLeaf,progressMonitor,settings);
return builder(prims,pinfo);
+92 -34
View File
@@ -18,6 +18,7 @@
#include "heuristic_binning_array_aligned.h"
#include "heuristic_spatial_array.h"
#include "heuristic_openmerge_array.h"
#if defined(__AVX512F__)
# define NUM_OBJECT_BINS 16
@@ -103,6 +104,7 @@ namespace embree
template<typename BuildRecord,
typename Heuristic,
typename Set,
typename PrimRef,
typename ReductionTy,
typename Allocator,
typename CreateAllocFunc,
@@ -111,11 +113,12 @@ namespace embree
typename CreateLeafFunc,
typename ProgressMonitor>
class BuilderT : private Settings
class BuilderT
{
friend struct GeneralBVHBuilder;
BuilderT (Heuristic& heuristic,
BuilderT (PrimRef* prims,
Heuristic& heuristic,
const CreateAllocFunc& createAlloc,
const CreateNodeFunc& createNode,
const UpdateNodeFunc& updateNode,
@@ -123,24 +126,25 @@ namespace embree
const ProgressMonitor& progressMonitor,
const Settings& settings)
: Settings(settings),
: cfg(settings),
prims(prims),
heuristic(heuristic),
createAlloc(createAlloc), createNode(createNode), updateNode(updateNode), createLeaf(createLeaf),
progressMonitor(progressMonitor)
{
if (branchingFactor > MAX_BRANCHING_FACTOR)
if (cfg.branchingFactor > MAX_BRANCHING_FACTOR)
throw_RTCError(RTC_UNKNOWN_ERROR,"bvh_builder: branching factor too large");
}
const ReductionTy createLargeLeaf(const BuildRecord& current, Allocator alloc)
{
/* this should never occur but is a fatal error */
if (current.depth > maxDepth)
if (current.depth > cfg.maxDepth)
throw_RTCError(RTC_UNKNOWN_ERROR,"depth limit reached");
/* create leaf for few primitives */
if (current.prims.size() <= maxLeafSize)
return createLeaf(current,alloc);
if (current.prims.size() <= cfg.maxLeafSize)
return createLeaf(prims,current.prims,alloc);
/* fill all children by always splitting the largest one */
ReductionTy values[MAX_BRANCHING_FACTOR];
@@ -155,7 +159,7 @@ namespace embree
for (size_t i=0; i<numChildren; i++)
{
/* ignore leaves as they cannot get split */
if (children[i].prims.size() <= maxLeafSize)
if (children[i].prims.size() <= cfg.maxLeafSize)
continue;
/* remember child with largest size */
@@ -177,12 +181,12 @@ namespace embree
children[numChildren+0] = right;
numChildren++;
} while (numChildren < branchingFactor);
} while (numChildren < cfg.branchingFactor);
/* set barrier for primrefarrayalloc */
if (unlikely(current.size() > primrefarrayalloc))
if (unlikely(current.size() > cfg.primrefarrayalloc))
for (size_t i=0; i<numChildren; i++)
children[i].alloc_barrier = children[i].size() <= primrefarrayalloc;
children[i].alloc_barrier = children[i].size() <= cfg.primrefarrayalloc;
/* create node */
auto node = createNode(children,numChildren,alloc);
@@ -202,19 +206,19 @@ namespace embree
alloc = createAlloc();
/* call memory monitor function to signal progress */
if (toplevel && current.size() <= singleThreadThreshold)
if (toplevel && current.size() <= cfg.singleThreadThreshold)
progressMonitor(current.size());
/*! find best split */
auto split = heuristic.find(current.prims,logBlockSize);
auto split = heuristic.find(current.prims,cfg.logBlockSize);
/*! compute leaf and split cost */
const float leafSAH = intCost*current.prims.leafSAH(logBlockSize);
const float splitSAH = travCost*halfArea(current.prims.geomBounds)+intCost*split.splitSAH();
const float leafSAH = cfg.intCost*current.prims.leafSAH(cfg.logBlockSize);
const float splitSAH = cfg.travCost*halfArea(current.prims.geomBounds)+cfg.intCost*split.splitSAH();
assert((current.prims.size() == 0) || ((leafSAH >= 0) && (splitSAH >= 0)));
/*! create a leaf node when threshold reached or SAH tells us to stop */
if (current.prims.size() <= minLeafSize || current.depth+MIN_LARGE_LEAF_LEVELS >= maxDepth || (current.prims.size() <= maxLeafSize && leafSAH <= splitSAH)) {
if (current.prims.size() <= cfg.minLeafSize || current.depth+MIN_LARGE_LEAF_LEVELS >= cfg.maxDepth || (current.prims.size() <= cfg.maxLeafSize && leafSAH <= splitSAH)) {
heuristic.deterministic_order(current.prims);
return createLargeLeaf(current,alloc);
}
@@ -231,7 +235,7 @@ namespace embree
size_t numChildren = 2;
/*! split until node is full or SAH tells us to stop */
while (numChildren < branchingFactor)
while (numChildren < cfg.branchingFactor)
{
/*! find best child to split */
float bestArea = neg_inf;
@@ -239,7 +243,7 @@ namespace embree
for (size_t i=0; i<numChildren; i++)
{
/* ignore leaves as they cannot get split */
if (children[i].prims.size() <= minLeafSize) continue;
if (children[i].prims.size() <= cfg.minLeafSize) continue;
/* find child with largest surface area */
if (halfArea(children[i].prims.geomBounds) > bestArea) {
@@ -253,7 +257,7 @@ namespace embree
BuildRecord& brecord = children[bestChild];
BuildRecord lrecord(current.depth+1);
BuildRecord rrecord(current.depth+1);
auto split = heuristic.find(brecord.prims,logBlockSize);
auto split = heuristic.find(brecord.prims,cfg.logBlockSize);
heuristic.split(split,brecord.prims,lrecord.prims,rrecord.prims);
children[bestChild ] = lrecord;
children[numChildren] = rrecord;
@@ -261,9 +265,9 @@ namespace embree
}
/* set barrier for primrefarrayalloc */
if (unlikely(current.size() > primrefarrayalloc))
if (unlikely(current.size() > cfg.primrefarrayalloc))
for (size_t i=0; i<numChildren; i++)
children[i].alloc_barrier = children[i].size() <= primrefarrayalloc;
children[i].alloc_barrier = children[i].size() <= cfg.primrefarrayalloc;
/* sort buildrecords for faster shadow ray traversal */
std::sort(&children[0],&children[numChildren],std::greater<BuildRecord>());
@@ -272,7 +276,7 @@ namespace embree
auto node = createNode(children,numChildren,alloc);
/* spawn tasks */
if (current.size() > singleThreadThreshold)
if (current.size() > cfg.singleThreadThreshold)
{
/*! parallel_for is faster than spawing sub-tasks */
parallel_for(size_t(0), numChildren, [&] (const range<size_t>& r) { // FIXME: no range here
@@ -295,6 +299,8 @@ namespace embree
}
private:
Settings cfg;
PrimRef* prims;
Heuristic& heuristic;
const CreateAllocFunc& createAlloc;
const CreateNodeFunc& createNode;
@@ -307,6 +313,7 @@ namespace embree
typename ReductionTy,
typename Heuristic,
typename Set,
typename PrimRef,
typename CreateAllocFunc,
typename CreateNodeFunc,
typename UpdateNodeFunc,
@@ -314,6 +321,7 @@ namespace embree
typename ProgressMonitor>
__noinline static ReductionTy build(Heuristic& heuristic,
PrimRef* prims,
const Set& set,
CreateAllocFunc createAlloc,
CreateNodeFunc createNode, UpdateNodeFunc updateNode,
@@ -327,6 +335,7 @@ namespace embree
BuildRecord,
Heuristic,
Set,
PrimRef,
ReductionTy,
decltype(createAlloc()),
CreateAllocFunc,
@@ -336,7 +345,8 @@ namespace embree
ProgressMonitor> Builder;
/* instantiate builder */
Builder builder(heuristic,
Builder builder(prims,
heuristic,
createAlloc,
createNode,
updateNode,
@@ -377,9 +387,10 @@ namespace embree
const Settings& settings)
{
Heuristic heuristic(prims);
return GeneralBVHBuilder::build<ReductionTy,Heuristic,Set>(
return GeneralBVHBuilder::build<ReductionTy,Heuristic,Set,PrimRef>(
heuristic,
PrimInfoRange(0,pinfo.size(),pinfo.geomBounds,pinfo.centBounds),
prims,
PrimInfoRange(0,pinfo.size(),pinfo),
createAlloc,
createNode,
updateNode,
@@ -403,21 +414,20 @@ namespace embree
template<typename ReductionTy, typename UserCreateLeaf>
struct CreateLeafExt
{
__forceinline CreateLeafExt (const UserCreateLeaf userCreateLeaf, PrimRef* prims)
: userCreateLeaf(userCreateLeaf), prims(prims) {}
__forceinline CreateLeafExt (const UserCreateLeaf userCreateLeaf)
: userCreateLeaf(userCreateLeaf) {}
// __noinline is workaround for ICC2016 compiler bug
template<typename Allocator>
__noinline ReductionTy operator() (const BuildRecord& current, Allocator alloc) const
__noinline ReductionTy operator() (PrimRef* prims, const range<size_t>& range, Allocator alloc) const
{
for (size_t i=current.prims.begin(); i<current.prims.end(); i++)
for (size_t i=range.begin(); i<range.end(); i++)
prims[i].lower.a &= GEOMID_MASK;
return userCreateLeaf(current,alloc);
return userCreateLeaf(prims,range,alloc);
}
const UserCreateLeaf userCreateLeaf;
PrimRef* prims;
};
/*! special builder that propagates reduction over the tree */
@@ -472,16 +482,64 @@ namespace embree
}
});
return GeneralBVHBuilder::build<ReductionTy,Heuristic,Set>(
return GeneralBVHBuilder::build<ReductionTy,Heuristic,Set,PrimRef>(
heuristic,
PrimInfoExtRange(0,pinfo.size(),extSize,pinfo.geomBounds,pinfo.centBounds),
prims,
PrimInfoExtRange(0,pinfo.size(),extSize,pinfo),
createAlloc,
createNode,
updateNode,
CreateLeafExt<ReductionTy,CreateLeafFunc>(createLeaf,prims),
CreateLeafExt<ReductionTy,CreateLeafFunc>(createLeaf),
progressMonitor,
settings);
}
};
/* Open/Merge SAH builder that operates on an array of BuildRecords */
struct BVHBuilderBinnedOpenMergeSAH
{
static const size_t NUM_OBJECT_BINS_HQ = 32;
typedef PrimInfoExtRange Set;
typedef BinSplit<NUM_OBJECT_BINS_HQ> Split;
typedef GeneralBVHBuilder::BuildRecordT<Set,Split> BuildRecord;
typedef GeneralBVHBuilder::Settings Settings;
/*! special builder that propagates reduction over the tree */
template<
typename ReductionTy,
typename BuildRef,
typename CreateAllocFunc,
typename CreateNodeFunc,
typename UpdateNodeFunc,
typename CreateLeafFunc,
typename NodeOpenerFunc,
typename ProgressMonitor>
static ReductionTy build(CreateAllocFunc createAlloc,
CreateNodeFunc createNode,
UpdateNodeFunc updateNode,
const CreateLeafFunc& createLeaf,
NodeOpenerFunc nodeOpenerFunc,
ProgressMonitor progressMonitor,
BuildRef* prims,
const size_t extSize,
const PrimInfo& pinfo,
const Settings& settings)
{
typedef HeuristicArrayOpenMergeSAH<NodeOpenerFunc,BuildRef,NUM_OBJECT_BINS_HQ> Heuristic;
Heuristic heuristic(nodeOpenerFunc,prims,settings.branchingFactor);
return GeneralBVHBuilder::build<ReductionTy,Heuristic,Set,BuildRef>(
heuristic,
prims,
PrimInfoExtRange(0,pinfo.size(),extSize,pinfo),
createAlloc,
createNode,
updateNode,
createLeaf,
progressMonitor,
settings);
}
};
}
}
+54 -33
View File
@@ -37,8 +37,20 @@ namespace embree
__forceinline BinMapping(size_t N, const BBox3fa& centBounds)
{
num = min(BINS,size_t(4.0f + 0.05f*N));
const vfloat4 diag = (vfloat4) centBounds.size();
scale = select(diag > vfloat4(1E-34f),vfloat4(0.99f*num)/diag,vfloat4(0.0f));
assert(num >= 1);
const vfloat4 eps = 1E-34f;
const vfloat4 diag = max(eps, (vfloat4) centBounds.size());
scale = select(diag > eps,vfloat4(0.99f*num)/diag,vfloat4(0.0f));
ofs = (vfloat4) centBounds.lower;
}
/*! calculates the mapping */
__forceinline BinMapping(const BBox3fa& centBounds)
{
num = BINS;
const vfloat4 eps = 1E-34f;
const vfloat4 diag = max(eps, (vfloat4) centBounds.size());
scale = select(diag > eps,vfloat4(0.99f*num)/diag,vfloat4(0.0f));
ofs = (vfloat4) centBounds.lower;
}
@@ -46,9 +58,10 @@ namespace embree
template<typename PrimInfo>
__forceinline BinMapping(const PrimInfo& pinfo)
{
const vfloat4 eps = 1E-34f;
num = min(BINS,size_t(4.0f + 0.05f*pinfo.size()));
const vfloat4 diag = (vfloat4) pinfo.centBounds.size();
scale = select(diag > vfloat4(1E-34f),vfloat4(0.99f*num)/diag,vfloat4(0.0f));
const vfloat4 diag = max(eps,(vfloat4) pinfo.centBounds.size());
scale = select(diag > eps,vfloat4(0.99f*num)/diag,vfloat4(0.0f));
ofs = (vfloat4) pinfo.centBounds.lower;
}
@@ -81,9 +94,9 @@ namespace embree
}
/*! faster but unsafe binning */
template<typename PrimRef>
__forceinline Vec3ia bin_unsafe(const PrimRef& p, const LinearSpace3fa& space, void* user = nullptr) const {
return bin_unsafe(p.binCenter(space,user));
template<typename PrimRef, typename BinBoundsAndCenter>
__forceinline Vec3ia bin_unsafe(const PrimRef& p, const BinBoundsAndCenter& binBoundsAndCenter) const {
return bin_unsafe(binBoundsAndCenter.binCenter(p));
}
template<typename PrimRef>
@@ -94,6 +107,11 @@ namespace embree
return any(((vint4)bin_unsafe(center2(ref.bounds())) < vSplitPos) & splitDimMask);
}
/*! calculates left spatial position of bin */
__forceinline float pos(const size_t bin, const size_t dim) const {
return madd(float(bin),1.0f / scale[dim],ofs[dim]);
}
/*! returns true if the mapping is invalid in some dimension */
__forceinline bool invalid(const size_t dim) const {
return scale[dim] == 0.0f;
@@ -115,9 +133,9 @@ namespace embree
{
enum
{
SPLIT_OBJECT = 0,
SPLIT_TEMPORAL = -1,
SPLIT_FALLBACK = -2,
SPLIT_OBJECT = 0,
SPLIT_TEMPORAL = 1,
SPLIT_FALLBACK = 2,
};
/*! construct an invalid split by default */
@@ -223,7 +241,7 @@ namespace embree
const unsigned int b00 = extract<0>(bin0); bounds(b00,0).extend(prim0);
const unsigned int b01 = extract<1>(bin0); bounds(b01,1).extend(prim0);
const unsigned int b02 = extract<2>(bin0); bounds(b02,2).extend(prim0);
const unsigned int s0 = prims[i+0].size();
const unsigned int s0 = (unsigned int)prims[i+0].size();
counts(b00,0)+=s0;
counts(b01,1)+=s0;
counts(b02,2)+=s0;
@@ -232,7 +250,7 @@ namespace embree
const unsigned int b10 = extract<0>(bin1); bounds(b10,0).extend(prim1);
const unsigned int b11 = extract<1>(bin1); bounds(b11,1).extend(prim1);
const unsigned int b12 = extract<2>(bin1); bounds(b12,2).extend(prim1);
const unsigned int s1 = prims[i+1].size();
const unsigned int s1 = (unsigned int)prims[i+1].size();
counts(b10,0)+=s1;
counts(b11,1)+=s1;
counts(b12,2)+=s1;
@@ -246,7 +264,7 @@ namespace embree
const vint4 bin0 = (vint4)mapping.bin(center0);
/*! increase bounds of bins */
const unsigned int s0 = prims[i].size();
const unsigned int s0 = (unsigned int)prims[i].size();
const int b00 = extract<0>(bin0); counts(b00,0)+=s0; bounds(b00,0).extend(prim0);
const int b01 = extract<1>(bin0); counts(b01,1)+=s0; bounds(b01,1).extend(prim0);
const int b02 = extract<2>(bin0); counts(b02,2)+=s0; bounds(b02,2).extend(prim0);
@@ -254,7 +272,8 @@ namespace embree
}
/*! bins an array of primitives */
__forceinline void bin (const PrimRef* prims, size_t N, const BinMapping<BINS>& mapping, const AffineSpace3fa& space, void* user = nullptr)
template<typename BinBoundsAndCenter>
__forceinline void bin (const PrimRef* prims, size_t N, const BinMapping<BINS>& mapping, const BinBoundsAndCenter& binBoundsAndCenter)
{
if (N == 0) return;
@@ -262,9 +281,9 @@ namespace embree
for (i=0; i<N-1; i+=2)
{
/*! map even and odd primitive to bin */
BBox prim0; Vec3fa center0; prims[i+0].binBoundsAndCenter(prim0,center0,space,user);
BBox prim0; Vec3fa center0; binBoundsAndCenter.binBoundsAndCenter(prims[i+0],prim0,center0);
const vint4 bin0 = (vint4)mapping.bin(center0);
BBox prim1; Vec3fa center1; prims[i+1].binBoundsAndCenter(prim1,center1,space,user);
BBox prim1; Vec3fa center1; binBoundsAndCenter.binBoundsAndCenter(prims[i+1],prim1,center1);
const vint4 bin1 = (vint4)mapping.bin(center1);
/*! increase bounds for bins for even primitive */
@@ -284,7 +303,7 @@ namespace embree
if (i < N)
{
/*! map primitive to bin */
BBox prim0; Vec3fa center0; prims[i+0].binBoundsAndCenter(prim0,center0,space,user);
BBox prim0; Vec3fa center0; binBoundsAndCenter.binBoundsAndCenter(prims[i+0],prim0,center0);
const vint4 bin0 = (vint4)mapping.bin(center0);
/*! increase bounds of bins */
@@ -299,9 +318,10 @@ namespace embree
bin(prims+begin,end-begin,mapping);
}
__forceinline void bin(const PrimRef* prims, size_t begin, size_t end, const BinMapping<BINS>& mapping, const AffineSpace3fa& space, void* user = nullptr) {
bin(prims+begin,end-begin,mapping,space,user);
}
template<typename BinBoundsAndCenter>
__forceinline void bin(const PrimRef* prims, size_t begin, size_t end, const BinMapping<BINS>& mapping, const BinBoundsAndCenter& binBoundsAndCenter) {
bin<BinBoundsAndCenter>(prims+begin,end-begin,mapping,binBoundsAndCenter);
}
/*! merges in other binning information */
__forceinline void merge (const BinInfoT& other, size_t numBins)
@@ -451,8 +471,9 @@ namespace embree
__forceinline BinMapping(const PrimInfo& pinfo)
{
num = 16;
const vfloat4 diag = (vfloat4) pinfo.centBounds.size();
scale = select(diag > vfloat4(1E-34f),vfloat4(0.99f*num)/diag,vfloat4(0.0f));
const vfloat4 eps = 1E-34f;
const vfloat4 diag = max(eps,(vfloat4) pinfo.centBounds.size());
scale = select(diag > eps,vfloat4(0.99f*num)/diag,vfloat4(0.0f));
ofs = (vfloat4) pinfo.centBounds.lower;
scale16 = scale;
ofs16 = ofs;
@@ -593,9 +614,9 @@ namespace embree
max_z1 = init_max;
max_z2 = init_max;
count0 = vint16::zero();
count1 = vint16::zero();
count2 = vint16::zero();
count0 = zero;
count1 = zero;
count2 = zero;
const vint16 step16(step);
size_t i;
@@ -925,14 +946,14 @@ namespace embree
}
}
template<typename BinInfoT, typename BinMapping, typename PrimRef>
__forceinline void bin_parallel(BinInfoT& binner, const PrimRef* prims, size_t begin, size_t end, size_t blockSize, size_t parallelThreshold, const BinMapping& mapping, const AffineSpace3fa& space, void* user = nullptr)
template<typename BinBoundsAndCenter, typename BinInfoT, typename BinMapping, typename PrimRef>
__forceinline void bin_parallel(BinInfoT& binner, const PrimRef* prims, size_t begin, size_t end, size_t blockSize, size_t parallelThreshold, const BinMapping& mapping, const BinBoundsAndCenter& binBoundsAndCenter)
{
if (likely(end-begin < parallelThreshold)) {
binner.bin(prims,begin,end,mapping,space,user);
binner.bin(prims,begin,end,mapping,binBoundsAndCenter);
} else {
binner = parallel_reduce(begin,end,blockSize,binner,
[&](const range<size_t>& r) -> BinInfoT { BinInfoT binner(empty); binner.bin(prims + r.begin(), r.size(), mapping, space, user); return binner; },
[&](const range<size_t>& r) -> BinInfoT { BinInfoT binner(empty); binner.bin(prims + r.begin(), r.size(), mapping, binBoundsAndCenter); return binner; },
[&](const BinInfoT& b0, const BinInfoT& b1) -> BinInfoT { BinInfoT r = b0; r.merge(b1, mapping.size()); return r; });
}
}
@@ -949,14 +970,14 @@ namespace embree
}
}
template<bool parallel, typename BinInfoT, typename BinMapping, typename PrimRef>
__forceinline void bin_serial_or_parallel(BinInfoT& binner, const PrimRef* prims, size_t begin, size_t end, size_t blockSize, const BinMapping& mapping, const AffineSpace3fa& space, void* user = nullptr)
template<bool parallel, typename BinBoundsAndCenter, typename BinInfoT, typename BinMapping, typename PrimRef>
__forceinline void bin_serial_or_parallel(BinInfoT& binner, const PrimRef* prims, size_t begin, size_t end, size_t blockSize, const BinMapping& mapping, const BinBoundsAndCenter& binBoundsAndCenter)
{
if (!parallel) {
binner.bin(prims,begin,end,mapping,space,user);
binner.bin(prims,begin,end,mapping,binBoundsAndCenter);
} else {
binner = parallel_reduce(begin,end,blockSize,binner,
[&](const range<size_t>& r) -> BinInfoT { BinInfoT binner(empty); binner.bin(prims + r.begin(), r.size(), mapping, space, user); return binner; },
[&](const range<size_t>& r) -> BinInfoT { BinInfoT binner(empty); binner.bin(prims + r.begin(), r.size(), mapping, binBoundsAndCenter); return binner; },
[&](const BinInfoT& b0, const BinInfoT& b1) -> BinInfoT { BinInfoT r = b0; r.merge(b1, mapping.size()); return r; });
}
}
@@ -33,8 +33,8 @@ namespace embree
__forceinline PrimInfoRange(EmptyTy)
: CentGeomBBox3fa(EmptyTy()), range<size_t>(0,0) {}
__forceinline PrimInfoRange (size_t begin, size_t end, const BBox3fa& geomBounds, const BBox3fa& centBounds)
: CentGeomBBox3fa(geomBounds,centBounds), range<size_t>(begin,end) {}
__forceinline PrimInfoRange (size_t begin, size_t end, const CentGeomBBox3fa& centGeomBounds)
: CentGeomBBox3fa(centGeomBounds), range<size_t>(begin,end) {}
__forceinline float leafSAH() const {
return expectedApproxHalfArea(geomBounds)*float(size());
@@ -119,16 +119,16 @@ namespace embree
size_t center = 0;
if (!parallel)
center = serial_partitioning(prims,begin,end,local_left,local_right,isLeft,
[] (CentGeomBBox3fa& pinfo,const PrimRef& ref) { pinfo.extend(ref.bounds()); });
[] (CentGeomBBox3fa& pinfo,const PrimRef& ref) { pinfo.extend_center2(ref); });
else
center = parallel_partitioning(
prims,begin,end,EmptyTy(),local_left,local_right,isLeft,
[] (CentGeomBBox3fa& pinfo,const PrimRef &ref) { pinfo.extend(ref.bounds()); },
[] (CentGeomBBox3fa& pinfo0,const CentGeomBBox3fa &pinfo1) { pinfo0.merge(pinfo1); },
[] (CentGeomBBox3fa& pinfo,const PrimRef& ref) { pinfo.extend_center2(ref); },
[] (CentGeomBBox3fa& pinfo0,const CentGeomBBox3fa& pinfo1) { pinfo0.merge(pinfo1); },
PARALLEL_PARTITION_BLOCK_SIZE);
new (&lset) PrimInfoRange(begin,center,local_left.geomBounds,local_left.centBounds);
new (&rset) PrimInfoRange(center,end,local_right.geomBounds,local_right.centBounds);
new (&lset) PrimInfoRange(begin,center,local_left);
new (&rset) PrimInfoRange(center,end,local_right);
assert(area(lset.geomBounds) >= 0.0f);
assert(area(rset.geomBounds) >= 0.0f);
}
@@ -145,15 +145,15 @@ namespace embree
const size_t end = pinfo.end();
const size_t center = (begin + end)/2;
CentGeomBBox3fa left; left.reset();
CentGeomBBox3fa left(empty);
for (size_t i=begin; i<center; i++)
left.extend(prims[i].bounds());
new (&linfo) PrimInfoRange(begin,center,left.geomBounds,left.centBounds);
left.extend_center2(prims[i]);
new (&linfo) PrimInfoRange(begin,center,left);
CentGeomBBox3fa right; right.reset();
CentGeomBBox3fa right(empty);
for (size_t i=center; i<end; i++)
right.extend(prims[i].bounds());
new (&rinfo) PrimInfoRange(center,end,right.geomBounds,right.centBounds);
right.extend_center2(prims[i]);
new (&rinfo) PrimInfoRange(center,end,right);
}
private:
@@ -76,8 +76,35 @@ namespace embree
const CentGeomBBox3fa bounds = parallel_reduce(set.begin(), set.end(), size_t(1024), size_t(4096),
CentGeomBBox3fa(empty), computeBounds, CentGeomBBox3fa::merge2);
return PrimInfo(set.begin(),set.end(),bounds.geomBounds,bounds.centBounds);
return PrimInfo(set.begin(),set.end(),bounds);
}
struct BinBoundsAndCenter
{
__forceinline BinBoundsAndCenter(Scene* scene, const LinearSpace3fa& space)
: scene(scene), space(space) {}
/*! returns center for binning */
__forceinline Vec3fa binCenter(const PrimRef& ref) const
{
NativeCurves* mesh = (NativeCurves*) scene->get(ref.geomID());
BBox3fa bounds = mesh->bounds(space,ref.primID());
return embree::center2(bounds);
}
/*! returns bounds and centroid used for binning */
__forceinline void binBoundsAndCenter(const PrimRef& ref, BBox3fa& bounds_o, Vec3fa& center_o) const
{
NativeCurves* mesh = (NativeCurves*) scene->get(ref.geomID());
BBox3fa bounds = mesh->bounds(space,ref.primID());
bounds_o = bounds;
center_o = embree::center2(bounds);
}
private:
Scene* scene;
const LinearSpace3fa space;
};
/*! finds the best split */
__forceinline const Split find(const PrimInfoRange& pinfo, const size_t logBlockSize, const LinearSpace3fa& space)
@@ -94,7 +121,8 @@ namespace embree
{
Binner binner(empty);
const BinMapping<BINS> mapping(set);
bin_serial_or_parallel<parallel>(binner,prims,set.begin(),set.end(),size_t(4096),mapping,space,scene);
BinBoundsAndCenter binBoundsAndCenter(scene,space);
bin_serial_or_parallel<parallel>(binner,prims,set.begin(),set.end(),size_t(4096),mapping,binBoundsAndCenter);
return binner.best(mapping,logBlockSize);
}
@@ -122,21 +150,22 @@ namespace embree
CentGeomBBox3fa local_right(empty);
const int splitPos = split.pos;
const int splitDim = split.dim;
BinBoundsAndCenter binBoundsAndCenter(scene,space);
size_t center = 0;
if (likely(set.size() < 10000))
center = serial_partitioning(prims,begin,end,local_left,local_right,
[&] (const PrimRef& ref) { return split.mapping.bin_unsafe(ref,space,scene)[splitDim] < splitPos; },
[] (CentGeomBBox3fa& pinfo,const PrimRef& ref) { pinfo.extend(ref.bounds()); });
[&] (const PrimRef& ref) { return split.mapping.bin_unsafe(ref,binBoundsAndCenter)[splitDim] < splitPos; },
[] (CentGeomBBox3fa& pinfo,const PrimRef& ref) { pinfo.extend_center2(ref); });
else
center = parallel_partitioning(prims,begin,end,EmptyTy(),local_left,local_right,
[&] (const PrimRef& ref) { return split.mapping.bin_unsafe(ref,space,scene)[splitDim] < splitPos; },
[] (CentGeomBBox3fa& pinfo,const PrimRef& ref) { pinfo.extend(ref.bounds()); },
[&] (const PrimRef& ref) { return split.mapping.bin_unsafe(ref,binBoundsAndCenter)[splitDim] < splitPos; },
[] (CentGeomBBox3fa& pinfo,const PrimRef& ref) { pinfo.extend_center2(ref); },
[] (CentGeomBBox3fa& pinfo0,const CentGeomBBox3fa& pinfo1) { pinfo0.merge(pinfo1); },
128);
new (&lset) PrimInfoRange(begin,center,local_left.geomBounds,local_left.centBounds);
new (&rset) PrimInfoRange(center,end,local_right.geomBounds,local_right.centBounds);
new (&lset) PrimInfoRange(begin,center,local_left);
new (&rset) PrimInfoRange(center,end,local_right);
assert(area(lset.geomBounds) >= 0.0f);
assert(area(rset.geomBounds) >= 0.0f);
}
@@ -153,15 +182,15 @@ namespace embree
const size_t end = set.end();
const size_t center = (begin + end)/2;
CentGeomBBox3fa left; left.reset();
CentGeomBBox3fa left(empty);
for (size_t i=begin; i<center; i++)
left.extend(prims[i].bounds());
new (&lset) PrimInfoRange(begin,center,left.geomBounds,left.centBounds);
left.extend_center2(prims[i]);
new (&lset) PrimInfoRange(begin,center,left);
CentGeomBBox3fa right; right.reset();
CentGeomBBox3fa right(empty);
for (size_t i=center; i<end; i++)
right.extend(prims[i].bounds());
new (&rset) PrimInfoRange(center,end,right.geomBounds,right.centBounds);
right.extend_center2(prims[i]);
new (&rset) PrimInfoRange(center,end,right);
}
private:
@@ -197,7 +226,7 @@ namespace embree
const NativeCurves* mesh = scene->get<NativeCurves>(geomID);
const unsigned num_time_segments = mesh->numTimeSegments();
const range<int> tbounds = getTimeSegmentRange(set.time_range, num_time_segments);
const range<int> tbounds = getTimeSegmentRange(set.time_range, (float)num_time_segments);
if (tbounds.size() == 0) continue;
const size_t t = (tbounds.begin()+tbounds.end())/2;
@@ -214,13 +243,51 @@ namespace embree
return frame(axis0).transposed();
}
struct BinBoundsAndCenter
{
__forceinline BinBoundsAndCenter(Scene* scene, BBox1f time_range, const LinearSpace3fa& space)
: scene(scene), time_range(time_range), space(space) {}
/*! returns center for binning */
template<typename PrimRef>
__forceinline Vec3fa binCenter(const PrimRef& ref) const
{
NativeCurves* mesh = scene->get<NativeCurves>(ref.geomID());
LBBox3fa lbounds = mesh->linearBounds(space,ref.primID(),time_range);
return center2(lbounds.interpolate(0.5f));
}
/*! returns bounds and centroid used for binning */
__noinline void binBoundsAndCenter (const PrimRefMB& ref, BBox3fa& bounds_o, Vec3fa& center_o) const // __noinline is workaround for ICC16 bug under MacOSX
{
NativeCurves* mesh = scene->get<NativeCurves>(ref.geomID());
LBBox3fa lbounds = mesh->linearBounds(space,ref.primID(),time_range);
bounds_o = lbounds.interpolate(0.5f);
center_o = center2(bounds_o);
}
/*! returns bounds and centroid used for binning */
__noinline void binBoundsAndCenter (const PrimRefMB& ref, LBBox3fa& bounds_o, Vec3fa& center_o) const // __noinline is workaround for ICC16 bug under MacOSX
{
NativeCurves* mesh = scene->get<NativeCurves>(ref.geomID());
LBBox3fa lbounds = mesh->linearBounds(space,ref.primID(),time_range);
bounds_o = lbounds;
center_o = center2(lbounds.interpolate(0.5f));
}
private:
Scene* scene;
BBox1f time_range;
const LinearSpace3fa space;
};
/*! finds the best split */
const Split find(const SetMB& set, const size_t logBlockSize, const LinearSpace3fa& space)
{
UserPrimRefData user(scene,set.time_range);
BinBoundsAndCenter binBoundsAndCenter(scene,set.time_range,space);
ObjectBinner binner(empty);
const BinMapping<BINS> mapping(set.size(),set.centBounds);
bin_parallel(binner,set.prims->data(),set.object_range.begin(),set.object_range.end(),PARALLEL_FIND_BLOCK_SIZE,PARALLEL_THRESHOLD,mapping,space,&user);
bin_parallel(binner,set.prims->data(),set.object_range.begin(),set.object_range.end(),PARALLEL_FIND_BLOCK_SIZE,PARALLEL_THRESHOLD,mapping,binBoundsAndCenter);
Split osplit = binner.best(mapping,logBlockSize);
osplit.sah *= set.time_range.size();
if (!osplit.valid()) osplit.data = Split::SPLIT_FALLBACK; // use fallback split
@@ -230,14 +297,14 @@ namespace embree
/*! array partitioning */
__forceinline void split(const Split& split, const LinearSpace3fa& space, const SetMB& set, SetMB& lset, SetMB& rset)
{
UserPrimRefData user(scene,set.time_range);
BinBoundsAndCenter binBoundsAndCenter(scene,set.time_range,space);
const size_t begin = set.object_range.begin();
const size_t end = set.object_range.end();
PrimInfoMB left = empty;
PrimInfoMB right = empty;
const vint4 vSplitPos(split.pos);
const vbool4 vSplitMask(1 << split.dim);
auto isLeft = [&] (const PrimRefMB &ref) { return any(((vint4)split.mapping.bin_unsafe(ref,space,&user) < vSplitPos) & vSplitMask); };
auto isLeft = [&] (const PrimRefMB &ref) { return any(((vint4)split.mapping.bin_unsafe(ref,binBoundsAndCenter) < vSplitPos) & vSplitMask); };
auto reduction = [] (PrimInfoMB& pinfo, const PrimRefMB& ref) { pinfo.add_primref(ref); };
auto reduction2 = [] (PrimInfoMB& pinfo0,const PrimInfoMB& pinfo1) { pinfo0.merge(pinfo1); };
size_t center = parallel_partitioning(set.prims->data(),begin,end,EmptyTy(),left,right,isLeft,reduction,reduction2,PARALLEL_PARTITION_BLOCK_SIZE,PARALLEL_THRESHOLD);
@@ -0,0 +1,456 @@
// ======================================================================== //
// 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. //
// ======================================================================== //
// TODO:
// - adjust parallel build thresholds
// - openNodesBasedOnExtend should consider max extended size
#pragma once
#include "heuristic_binning.h"
#include "heuristic_spatial.h"
/* stop opening of all bref.geomIDs are the same */
#define EQUAL_GEOMID_STOP_CRITERIA 1
/* 10% spatial extend threshold */
#define MAX_EXTEND_THRESHOLD 0.1f
/* maximum is 8 children */
#define MAX_OPENED_CHILD_NODES 8
/* open until all build refs are below threshold size in one step */
#define USE_LOOP_OPENING 0
namespace embree
{
namespace isa
{
/*! Performs standard object binning */
template<typename NodeOpenerFunc, typename PrimRef, size_t OBJECT_BINS>
struct HeuristicArrayOpenMergeSAH
{
typedef BinSplit<OBJECT_BINS> Split;
typedef BinInfoT<OBJECT_BINS,PrimRef,BBox3fa> Binner;
static const size_t PARALLEL_THRESHOLD = 1024;
static const size_t PARALLEL_FIND_BLOCK_SIZE = 512;
static const size_t PARALLEL_PARTITION_BLOCK_SIZE = 128;
static const size_t MOVE_STEP_SIZE = 64;
static const size_t CREATE_SPLITS_STEP_SIZE = 128;
__forceinline HeuristicArrayOpenMergeSAH ()
: prims0(nullptr) {}
/*! remember prim array */
__forceinline HeuristicArrayOpenMergeSAH (const NodeOpenerFunc& nodeOpenerFunc, PrimRef* prims0, size_t max_open_size)
: prims0(prims0), nodeOpenerFunc(nodeOpenerFunc), max_open_size(max_open_size)
{
assert(max_open_size <= MAX_OPENED_CHILD_NODES);
}
struct OpenHeuristic
{
__forceinline OpenHeuristic( const PrimInfoExtRange& pinfo )
{
const Vec3fa diag = pinfo.geomBounds.size();
dim = maxDim(diag);
assert(diag[dim] > 0.0f);
inv_max_extend = 1.0f / diag[dim];
}
__forceinline bool operator () ( PrimRef& prim ) const {
return !prim.node.isLeaf() && prim.bounds().size()[dim] * inv_max_extend > MAX_EXTEND_THRESHOLD;
}
private:
size_t dim;
float inv_max_extend;
};
/*! compute extended ranges */
__forceinline void setExtentedRanges(const PrimInfoExtRange& set, PrimInfoExtRange& lset, PrimInfoExtRange& rset, const size_t lweight, const size_t rweight)
{
assert(set.ext_range_size() > 0);
const float left_factor = (float)lweight / (lweight + rweight);
const size_t ext_range_size = set.ext_range_size();
const size_t left_ext_range_size = min((size_t)(floorf(left_factor * ext_range_size)),ext_range_size);
const size_t right_ext_range_size = ext_range_size - left_ext_range_size;
lset.set_ext_range(lset.end() + left_ext_range_size);
rset.set_ext_range(rset.end() + right_ext_range_size);
}
/*! move ranges */
__forceinline void moveExtentedRange(const PrimInfoExtRange& set, const PrimInfoExtRange& lset, PrimInfoExtRange& rset)
{
const size_t left_ext_range_size = lset.ext_range_size();
const size_t right_size = rset.size();
/* has the left child an extended range? */
if (left_ext_range_size > 0)
{
/* left extended range smaller than right range ? */
if (left_ext_range_size < right_size)
{
/* only move a small part of the beginning of the right range to the end */
parallel_for( rset.begin(), rset.begin()+left_ext_range_size, MOVE_STEP_SIZE, [&](const range<size_t>& r) {
for (size_t i=r.begin(); i<r.end(); i++)
prims0[i+right_size] = prims0[i];
});
}
else
{
/* no overlap, move entire right range to new location, can be made fully parallel */
parallel_for( rset.begin(), rset.end(), MOVE_STEP_SIZE, [&](const range<size_t>& r) {
for (size_t i=r.begin(); i<r.end(); i++)
prims0[i+left_ext_range_size] = prims0[i];
});
}
/* update right range */
assert(rset.ext_end() + left_ext_range_size == set.ext_end());
rset.move_right(left_ext_range_size);
}
}
/* estimates the extra space required when opening, and checks if all primitives are from same geometry */
__noinline std::pair<size_t,bool> getProperties(const PrimInfoExtRange& set)
{
const OpenHeuristic heuristic(set);
const unsigned int geomID = prims0[set.begin()].geomID();
auto body = [&] (const range<size_t>& r) -> std::pair<size_t,bool> {
bool commonGeomID = true;
size_t opens = 0;
for (size_t i=r.begin(); i<r.end(); i++) {
commonGeomID &= prims0[i].geomID() == geomID;
if (heuristic(prims0[i]))
opens += prims0[i].node.getN()-1; // coarse approximation
}
return std::pair<size_t,bool>(opens,commonGeomID);
};
auto reduction = [&] (const std::pair<size_t,bool>& b0, const std::pair<size_t,bool>& b1) -> std::pair<size_t,bool> {
return std::pair<size_t,bool>(b0.first+b1.first,b0.second && b1.second);
};
return parallel_reduce(set.begin(),set.end(),PARALLEL_FIND_BLOCK_SIZE,PARALLEL_THRESHOLD,std::pair<size_t,bool>(0,true),body,reduction);
}
// FIXME: should consider maximum available extended size
__noinline void openNodesBasedOnExtend(PrimInfoExtRange& set)
{
const OpenHeuristic heuristic(set);
const size_t ext_range_start = set.end();
if (false && set.size() < PARALLEL_THRESHOLD)
{
size_t extra_elements = 0;
for (size_t i=set.begin(); i<set.end(); i++)
{
if (heuristic(prims0[i]))
{
PrimRef tmp[MAX_OPENED_CHILD_NODES];
const size_t n = nodeOpenerFunc(prims0[i],tmp);
assert(extra_elements + n-1 <= set.ext_range_size());
for (size_t j=0; j<n; j++)
set.extend_center2(tmp[j]);
prims0[i] = tmp[0];
for (size_t j=1; j<n; j++)
prims0[ext_range_start+extra_elements+j-1] = tmp[j];
extra_elements += n-1;
}
}
set._end += extra_elements;
}
else
{
std::atomic<size_t> ext_elements;
ext_elements.store(0);
PrimInfo info = parallel_reduce( set.begin(), set.end(), CREATE_SPLITS_STEP_SIZE, PrimInfo(empty), [&](const range<size_t>& r) -> PrimInfo {
PrimInfo info(empty);
for (size_t i=r.begin(); i<r.end(); i++)
if (heuristic(prims0[i]))
{
PrimRef tmp[MAX_OPENED_CHILD_NODES];
const size_t n = nodeOpenerFunc(prims0[i],tmp);
const size_t ID = ext_elements.fetch_add(n-1);
assert(ID + n-1 <= set.ext_range_size());
for (size_t j=0; j<n; j++)
info.extend_center2(tmp[j]);
prims0[i] = tmp[0];
for (size_t j=1; j<n; j++)
prims0[ext_range_start+ID+j-1] = tmp[j];
}
return info;
}, [] (const PrimInfo& a, const PrimInfo& b) { return PrimInfo::merge(a,b); });
set.centBounds.extend(info.centBounds);
assert(ext_elements.load() <= set.ext_range_size());
set._end += ext_elements.load();
}
}
__noinline void openNodesBasedOnExtendLoop(PrimInfoExtRange& set, const size_t est_new_elements)
{
const OpenHeuristic heuristic(set);
size_t next_iteration_extra_elements = est_new_elements;
while (next_iteration_extra_elements <= set.ext_range_size())
{
next_iteration_extra_elements = 0;
size_t extra_elements = 0;
const size_t ext_range_start = set.end();
for (size_t i=set.begin(); i<set.end(); i++)
{
if (heuristic(prims0[i]))
{
PrimRef tmp[MAX_OPENED_CHILD_NODES];
const size_t n = nodeOpenerFunc(prims0[i],tmp);
assert(extra_elements + n-1 <= set.ext_range_size());
for (size_t j=0;j<n;j++)
set.extend_center2(tmp[j]);
prims0[i] = tmp[0];
for (size_t j=1;j<n;j++)
prims0[ext_range_start+extra_elements+j-1] = tmp[j];
extra_elements += n-1;
for (size_t j=0; j<n; j++)
if (heuristic(tmp[j]))
next_iteration_extra_elements += tmp[j].node.getN()-1; // coarse approximation
}
}
assert( extra_elements <= set.ext_range_size());
set._end += extra_elements;
for (size_t i=set.begin();i<set.end();i++)
assert(prims0[i].numPrimitives() > 0);
if (unlikely(next_iteration_extra_elements == 0)) break;
}
}
__noinline const Split find(PrimInfoExtRange& set, const size_t logBlockSize)
{
/* single element */
if (set.size() <= 1)
return Split();
/* disable opening if there is no overlap */
const size_t D = 4;
if (unlikely(set.has_ext_range() && set.size() <= D))
{
bool disjoint = true;
for (size_t j=set.begin(); j<set.end()-1; j++) {
for (size_t i=set.begin()+1; i<set.end(); i++) {
if (conjoint(prims0[j].bounds(),prims0[i].bounds())) {
disjoint = false; break;
}
}
}
if (disjoint) set.set_ext_range(set.end()); /* disables opening */
}
std::pair<size_t,bool> p(0,false);
/* disable opening when all primitives are from same geometry */
if (unlikely(set.has_ext_range()))
{
p = getProperties(set);
#if EQUAL_GEOMID_STOP_CRITERIA == 1
if (p.second) set.set_ext_range(set.end()); /* disable opening */
#endif
}
/* open nodes when we have sufficient space available */
if (unlikely(set.has_ext_range()))
{
#if USE_LOOP_OPENING == 1
openNodesBasedOnExtendLoop(set,p.first);
#else
if (p.first <= set.ext_range_size())
openNodesBasedOnExtend(set);
#endif
/* disable opening when unsufficient space for opening a node available */
if (set.ext_range_size() < max_open_size-1)
set.set_ext_range(set.end()); /* disable opening */
}
/* find best split */
return object_find(set,logBlockSize);
}
/*! finds the best object split */
__forceinline const Split object_find(const PrimInfoExtRange& set,const size_t logBlockSize)
{
if (set.size() < PARALLEL_THRESHOLD) return sequential_object_find(set,logBlockSize);
else return parallel_object_find (set,logBlockSize);
}
/*! finds the best object split */
__noinline const Split sequential_object_find(const PrimInfoExtRange& set, const size_t logBlockSize)
{
Binner binner(empty);
const BinMapping<OBJECT_BINS> mapping(set.centBounds);
binner.bin(prims0,set.begin(),set.end(),mapping);
return binner.best(mapping,logBlockSize);
}
/*! finds the best split */
__noinline const Split parallel_object_find(const PrimInfoExtRange& set, const size_t logBlockSize)
{
Binner binner(empty);
const BinMapping<OBJECT_BINS> mapping(set.centBounds);
const BinMapping<OBJECT_BINS>& _mapping = mapping; // CLANG 3.4 parser bug workaround
auto body = [&] (const range<size_t>& r) -> Binner {
Binner binner(empty); binner.bin(prims0+r.begin(),r.size(),_mapping); return binner;
};
auto reduction = [&] (const Binner& b0, const Binner& b1) -> Binner {
Binner r = b0; r.merge(b1,_mapping.size()); return r;
};
binner = parallel_reduce(set.begin(),set.end(),PARALLEL_FIND_BLOCK_SIZE,binner,body,reduction);
return binner.best(mapping,logBlockSize);
}
/*! array partitioning */
__noinline void split(const Split& split, const PrimInfoExtRange& set_i, PrimInfoExtRange& lset, PrimInfoExtRange& rset)
{
PrimInfoExtRange set = set_i;
/* valid split */
if (unlikely(!split.valid())) {
deterministic_order(set);
splitFallback(set,lset,rset);
return;
}
std::pair<size_t,size_t> ext_weights(0,0);
/* object split */
if (likely(set.size() < PARALLEL_THRESHOLD))
ext_weights = sequential_object_split(split,set,lset,rset);
else
ext_weights = parallel_object_split(split,set,lset,rset);
/* if we have an extended range, set extended child ranges and move right split range */
if (unlikely(set.has_ext_range()))
{
setExtentedRanges(set,lset,rset,ext_weights.first,ext_weights.second);
moveExtentedRange(set,lset,rset);
}
}
/*! array partitioning */
std::pair<size_t,size_t> sequential_object_split(const Split& split, const PrimInfoExtRange& set, PrimInfoExtRange& lset, PrimInfoExtRange& rset)
{
const size_t begin = set.begin();
const size_t end = set.end();
PrimInfo local_left(empty);
PrimInfo local_right(empty);
const unsigned int splitPos = split.pos;
const unsigned int splitDim = split.dim;
const unsigned int splitDimMask = (unsigned int)1 << splitDim;
const vint4 vSplitPos(splitPos);
const vbool4 vSplitMask( (int)splitDimMask );
size_t center = serial_partitioning(prims0,
begin,end,local_left,local_right,
[&] (const PrimRef& ref) { return split.mapping.bin_unsafe(ref,vSplitPos,vSplitMask); },
[] (PrimInfo& pinfo,const PrimRef& ref) { pinfo.add_center2(ref); });
new (&lset) PrimInfoExtRange(begin,center,center,local_left);
new (&rset) PrimInfoExtRange(center,end,end,local_right);
assert(area(lset.geomBounds) >= 0.0f);
assert(area(rset.geomBounds) >= 0.0f);
return std::pair<size_t,size_t>(local_left.size(),local_right.size());
}
/*! array partitioning */
__noinline std::pair<size_t,size_t> parallel_object_split(const Split& split, const PrimInfoExtRange& set, PrimInfoExtRange& lset, PrimInfoExtRange& rset)
{
const size_t begin = set.begin();
const size_t end = set.end();
PrimInfo left(empty);
PrimInfo right(empty);
const unsigned int splitPos = split.pos;
const unsigned int splitDim = split.dim;
const unsigned int splitDimMask = (unsigned int)1 << splitDim;
const vint4 vSplitPos(splitPos);
const vbool4 vSplitMask( (int)splitDimMask );
auto isLeft = [&] (const PrimRef& ref) { return split.mapping.bin_unsafe(ref,vSplitPos,vSplitMask); };
const size_t center = parallel_partitioning(
prims0,begin,end,EmptyTy(),left,right,isLeft,
[] (PrimInfo& pinfo,const PrimRef& ref) { pinfo.add_center2(ref); },
[] (PrimInfo& pinfo0,const PrimInfo& pinfo1) { pinfo0.merge(pinfo1); },
PARALLEL_PARTITION_BLOCK_SIZE);
new (&lset) PrimInfoExtRange(begin,center,center,left);
new (&rset) PrimInfoExtRange(center,end,end,right);
assert(area(lset.geomBounds) >= 0.0f);
assert(area(rset.geomBounds) >= 0.0f);
return std::pair<size_t,size_t>(left.size(),right.size());
}
void deterministic_order(const extended_range<size_t>& set)
{
/* required as parallel partition destroys original primitive order */
std::sort(&prims0[set.begin()],&prims0[set.end()]);
}
__forceinline void splitFallback(const PrimInfoExtRange& set, PrimInfoExtRange& lset, PrimInfoExtRange& rset)
{
const size_t begin = set.begin();
const size_t end = set.end();
const size_t center = (begin + end)/2;
PrimInfo left(empty);
for (size_t i=begin; i<center; i++)
left.add_center2(prims0[i]);
const size_t lweight = left.end;
PrimInfo right(empty);
for (size_t i=center; i<end; i++)
right.add_center2(prims0[i]);
const size_t rweight = right.end;
new (&lset) PrimInfoExtRange(begin,center,center,left);
new (&rset) PrimInfoExtRange(center,end,end,right);
/* if we have an extended range */
if (set.has_ext_range())
{
setExtentedRanges(set,lset,rset,lweight,rweight);
moveExtentedRange(set,lset,rset);
}
}
private:
PrimRef* const prims0;
const NodeOpenerFunc& nodeOpenerFunc;
size_t max_open_size;
};
}
}
+44 -8
View File
@@ -35,9 +35,9 @@ namespace embree
{
const vfloat4 lower = (vfloat4) pinfo.geomBounds.lower;
const vfloat4 upper = (vfloat4) pinfo.geomBounds.upper;
const vbool4 ulpsized = upper - lower <= max(vfloat4(1E-19f),128.0f*vfloat4(ulp)*max(abs(lower),abs(upper)));
const vfloat4 diag = (vfloat4) pinfo.geomBounds.size();
scale = select(ulpsized,vfloat4(0.0f),vfloat4(BINS)/diag);
const vfloat4 eps = 128.0f*vfloat4(ulp)*max(abs(lower),abs(upper));
const vfloat4 diag = max(eps,(vfloat4) pinfo.geomBounds.size());
scale = select(upper-lower <= eps,vfloat4(0.0f),vfloat4(BINS)/diag);
ofs = (vfloat4) pinfo.geomBounds.lower;
inv_scale = 1.0f / scale;
}
@@ -149,14 +149,15 @@ namespace embree
const size_t beginID,
const size_t endID,
const size_t binID,
const BBox3fa &b)
const BBox3fa &b,
const size_t n = 1)
{
assert(beginID < BINS);
assert(endID < BINS);
assert(binID < BINS);
numBegin[beginID][dim]++;
numEnd [endID][dim]++;
numBegin[beginID][dim]+=(unsigned int)n;
numEnd [endID][dim]+=(unsigned int)n;
bounds [binID][dim].extend(b);
}
@@ -278,6 +279,41 @@ namespace embree
}
}
}
/*! bins an array of primitives */
__forceinline void binSubTreeRefs(const PrimRef* source, size_t begin, size_t end, const SpatialBinMapping<BINS>& mapping)
{
for (size_t i=begin; i<end; i++)
{
const PrimRef &prim = source[i];
const vint4 bin0 = mapping.bin(prim.bounds().lower);
const vint4 bin1 = mapping.bin(prim.bounds().upper);
for (size_t dim=0; dim<3; dim++)
{
if (unlikely(mapping.invalid(dim)))
continue;
const size_t l = bin0[dim];
const size_t r = bin1[dim];
const unsigned int n = prim.primID();
// same bin optimization
if (likely(l == r))
{
add(dim,l,l,l,prim.bounds(),n);
continue;
}
const size_t bin_start = bin0[dim];
const size_t bin_end = bin1[dim];
for (size_t bin=bin_start; bin<bin_end; bin++)
add(dim,l,r,bin,prim.bounds(),n);
}
}
}
/*! merges in other binning information */
void merge (const SpatialBinInfo& other)
@@ -308,7 +344,7 @@ namespace embree
}
/*! finds the best split by scanning binning information */
SpatialBinSplit<BINS> best(const SpatialBinMapping<BINS>& mapping, const size_t blocks_shift, const size_t maxCount = (size_t)-1) const
SpatialBinSplit<BINS> best(const SpatialBinMapping<BINS>& mapping, const size_t blocks_shift) const
{
/* sweep from right to left and compute parallel prefix of merged bounds */
vfloat4 rAreas[BINS];
@@ -359,7 +395,7 @@ namespace embree
continue;
/* test if this is a better dimension */
if (vbestSAH[dim] < bestSAH && vbestPos[dim] != 0 /* && (vbestlCount[dim]+vbestrCount[dim]<=(int)maxCount) */) {
if (vbestSAH[dim] < bestSAH && vbestPos[dim] != 0) {
bestDim = dim;
bestPos = vbestPos[dim];
bestSAH = vbestSAH[dim];
+23 -24
View File
@@ -41,8 +41,8 @@ namespace embree
__forceinline PrimInfoExtRange(EmptyTy)
: CentGeomBBox3fa(EmptyTy()), extended_range<size_t>(0,0,0) {}
__forceinline PrimInfoExtRange(size_t begin, size_t end, size_t ext_end, const BBox3fa& geomBounds, const BBox3fa& centBounds)
: CentGeomBBox3fa(geomBounds,centBounds), extended_range<size_t>(begin,end,ext_end) {}
__forceinline PrimInfoExtRange(size_t begin, size_t end, size_t ext_end, const CentGeomBBox3fa& centGeomBounds)
: CentGeomBBox3fa(centGeomBounds), extended_range<size_t>(begin,end,ext_end) {}
__forceinline float leafSAH() const {
return expectedApproxHalfArea(geomBounds)*float(size());
@@ -404,13 +404,12 @@ namespace embree
[&] (const PrimRef& ref) {
return split.mapping.bin_unsafe(ref,vSplitPos,vSplitMask);
},
[] (PrimInfo& pinfo,const PrimRef& ref) { pinfo.add(ref.bounds(),ref.lower.a >> 24); });
[] (PrimInfo& pinfo,const PrimRef& ref) { pinfo.add_center2(ref,ref.lower.a >> 24); });
const size_t left_weight = local_left.end;
const size_t right_weight = local_right.end;
new (&lset) PrimInfoExtRange(begin,center,center,local_left.geomBounds,local_left.centBounds);
new (&rset) PrimInfoExtRange(center,end,end,local_right.geomBounds,local_right.centBounds);
new (&lset) PrimInfoExtRange(begin,center,center,local_left);
new (&rset) PrimInfoExtRange(center,end,end,local_right);
assert(area(lset.geomBounds) >= 0.0f);
assert(area(rset.geomBounds) >= 0.0f);
@@ -430,7 +429,7 @@ namespace embree
const unsigned int splitDimMask = (unsigned int)1 << splitDim;
/* init spatial mapping */
const SpatialBinMapping<SPATIAL_BINS> mapping = split.mapping;
const SpatialBinMapping<SPATIAL_BINS> &mapping = split.mapping;
const vint4 vSplitPos(splitPos);
const vbool4 vSplitMask( (int)splitDimMask );
@@ -440,13 +439,13 @@ namespace embree
const Vec3fa c = ref.bounds().center();
return any(((vint4)mapping.bin(c) < vSplitPos) & vSplitMask);
},
[] (PrimInfo& pinfo,const PrimRef& ref) { pinfo.add(ref.bounds(),ref.lower.a >> 24); });
[] (PrimInfo& pinfo,const PrimRef& ref) { pinfo.add_center2(ref,ref.lower.a >> 24); });
const size_t left_weight = local_left.end;
const size_t right_weight = local_right.end;
new (&lset) PrimInfoExtRange(begin,center,center,local_left.geomBounds,local_left.centBounds);
new (&rset) PrimInfoExtRange(center,end,end,local_right.geomBounds,local_right.centBounds);
new (&lset) PrimInfoExtRange(begin,center,center,local_left);
new (&rset) PrimInfoExtRange(center,end,end,local_right);
assert(area(lset.geomBounds) >= 0.0f);
assert(area(rset.geomBounds) >= 0.0f);
return std::pair<size_t,size_t>(left_weight,right_weight);
@@ -459,8 +458,8 @@ namespace embree
{
const size_t begin = set.begin();
const size_t end = set.end();
PrimInfo left; left.reset();
PrimInfo right; right.reset();
PrimInfo left(empty);
PrimInfo right(empty);
const unsigned int splitPos = split.pos;
const unsigned int splitDim = split.dim;
const unsigned int splitDimMask = (unsigned int)1 << splitDim;
@@ -476,7 +475,7 @@ namespace embree
const size_t center = parallel_partitioning(
prims0,begin,end,EmptyTy(),left,right,isLeft,
[] (PrimInfo &pinfo,const PrimRef &ref) { pinfo.add(ref.bounds(),ref.lower.a >> 24); },
[] (PrimInfo &pinfo,const PrimRef &ref) { pinfo.add_center2(ref,ref.lower.a >> 24); },
[] (PrimInfo &pinfo0,const PrimInfo &pinfo1) { pinfo0.merge(pinfo1); },
PARALLEL_PARTITION_BLOCK_SIZE);
@@ -486,8 +485,8 @@ namespace embree
left.begin = begin; left.end = center;
right.begin = center; right.end = end;
new (&lset) PrimInfoExtRange(begin,center,center,left.geomBounds,left.centBounds);
new (&rset) PrimInfoExtRange(center,end,end,right.geomBounds,right.centBounds);
new (&lset) PrimInfoExtRange(begin,center,center,left);
new (&rset) PrimInfoExtRange(center,end,end,right);
assert(area(left.geomBounds) >= 0.0f);
assert(area(right.geomBounds) >= 0.0f);
@@ -499,8 +498,8 @@ namespace embree
{
const size_t begin = set.begin();
const size_t end = set.end();
PrimInfo left; left.reset();
PrimInfo right; right.reset();
PrimInfo left(empty);
PrimInfo right(empty);
const unsigned int splitPos = split.pos;
const unsigned int splitDim = split.dim;
const unsigned int splitDimMask = (unsigned int)1 << splitDim;
@@ -516,7 +515,7 @@ namespace embree
const size_t center = parallel_partitioning(
prims0,begin,end,EmptyTy(),left,right,isLeft,
[] (PrimInfo &pinfo,const PrimRef &ref) { pinfo.add(ref.bounds(),ref.lower.a >> 24); },
[] (PrimInfo &pinfo,const PrimRef &ref) { pinfo.add_center2(ref,ref.lower.a >> 24); },
[] (PrimInfo &pinfo0,const PrimInfo &pinfo1) { pinfo0.merge(pinfo1); },
PARALLEL_PARTITION_BLOCK_SIZE);
@@ -526,8 +525,8 @@ namespace embree
left.begin = begin; left.end = center;
right.begin = center; right.end = end;
new (&lset) PrimInfoExtRange(begin,center,center,left.geomBounds,left.centBounds);
new (&rset) PrimInfoExtRange(center,end,end,right.geomBounds,right.centBounds);
new (&lset) PrimInfoExtRange(begin,center,center,left);
new (&rset) PrimInfoExtRange(center,end,end,right);
assert(area(left.geomBounds) >= 0.0f);
assert(area(right.geomBounds) >= 0.0f);
@@ -550,18 +549,18 @@ namespace embree
PrimInfo left(empty);
for (size_t i=begin; i<center; i++) {
left.add(prims0[i].bounds(),prims0[i].lower.a >> 24);
left.add_center2(prims0[i],prims0[i].lower.a >> 24);
}
const size_t lweight = left.end;
PrimInfo right(empty);
for (size_t i=center; i<end; i++) {
right.add(prims0[i].bounds(),prims0[i].lower.a >> 24);
right.add_center2(prims0[i],prims0[i].lower.a >> 24);
}
const size_t rweight = right.end;
new (&lset) PrimInfoExtRange(begin,center,center,left.geomBounds,left.centBounds);
new (&rset) PrimInfoExtRange(center,end,end,right.geomBounds,right.centBounds);
new (&lset) PrimInfoExtRange(begin,center,center,left);
new (&rset) PrimInfoExtRange(center,end,end,right);
/* if we have an extended range */
if (set.has_ext_range()) {
+12 -12
View File
@@ -260,8 +260,8 @@ namespace embree
size_t center = serial_partitioning(prims,begin,end,local_left,local_right,primOnLeftSide,mergePrimBounds);
new (&lset) PrimInfoRange(begin,center,local_left.geomBounds,local_left.centBounds);
new (&rset) PrimInfoRange(center,end,local_right.geomBounds,local_right.centBounds);
new (&lset) PrimInfoRange(begin,center,local_left);
new (&rset) PrimInfoRange(center,end,local_right);
assert(area(lset.geomBounds) >= 0.0f);
assert(area(rset.geomBounds) >= 0.0f);
}
@@ -284,16 +284,16 @@ namespace embree
return cos0 > cos1;
};
PrimInfo linfo; linfo.reset(); // FIXME: use CentGeomBBox3fa
PrimInfo rinfo; rinfo.reset();
CentGeomBBox3fa linfo(empty); // FIXME: use CentGeomBBox3fa
CentGeomBBox3fa rinfo(empty);
const size_t center = parallel_partitioning(
prims,begin,end,EmptyTy(),linfo,rinfo,primOnLeftSide,
[this] (PrimInfo &pinfo, const PrimRef& ref) { pinfo.add(bounds(ref)); },
[] (PrimInfo &pinfo0,const PrimInfo& pinfo1) { pinfo0.merge(pinfo1); },
[this] (CentGeomBBox3fa& pinfo, const PrimRef& ref) { pinfo.extend(bounds(ref)); },
[] (CentGeomBBox3fa& pinfo0, const CentGeomBBox3fa& pinfo1) { pinfo0.merge(pinfo1); },
PARALLEL_PARTITION_BLOCK_SIZE);
new (&lset) PrimInfoRange(begin,center,linfo.geomBounds,linfo.centBounds);
new (&rset) PrimInfoRange(center,end,rinfo.geomBounds,rinfo.centBounds);
new (&lset) PrimInfoRange(begin,center,linfo);
new (&rset) PrimInfoRange(center,end,rinfo);
}
void deterministic_order(const Set& set)
@@ -308,15 +308,15 @@ namespace embree
const size_t end = set.end();
const size_t center = (begin + end)/2;
CentGeomBBox3fa left; left.reset();
CentGeomBBox3fa left(empty);
for (size_t i=begin; i<center; i++)
left.extend(bounds(prims[i]));
new (&lset) PrimInfoRange(begin,center,left.geomBounds,left.centBounds);
new (&lset) PrimInfoRange(begin,center,left);
CentGeomBBox3fa right; right.reset();
CentGeomBBox3fa right(empty);
for (size_t i=center; i<end; i++)
right.extend(bounds(prims[i]));
new (&rset) PrimInfoRange(center,end,right.geomBounds,right.centBounds);
new (&rset) PrimInfoRange(center,end,right);
}
private:
+6 -6
View File
@@ -77,8 +77,8 @@ namespace embree
bounds0[b].extend(bn0.interpolate(0.5f));
bounds1[b].extend(bn1.interpolate(0.5f));
#endif
count0[b] += getTimeSegmentRange(dt0,prims[i].totalTimeSegments()).size();
count1[b] += getTimeSegmentRange(dt1,prims[i].totalTimeSegments()).size();
count0[b] += getTimeSegmentRange(dt0,(float)prims[i].totalTimeSegments()).size();
count1[b] += getTimeSegmentRange(dt1,(float)prims[i].totalTimeSegments()).size();
}
}
}
@@ -128,8 +128,8 @@ namespace embree
const BBox1f dt1(center_time,time_range.upper);
/* calculate sah */
const size_t lCount = (count0[b]+(1 << logBlockSize)-1) >> int(logBlockSize);
const size_t rCount = (count1[b]+(1 << logBlockSize)-1) >> int(logBlockSize);
const size_t lCount = (count0[b]+(size_t(1) << logBlockSize)-1) >> int(logBlockSize);
const size_t rCount = (count1[b]+(size_t(1) << logBlockSize)-1) >> int(logBlockSize);
const float sah0 = expectedApproxHalfArea(bounds0[b])*float(lCount)*dt0.size();
const float sah1 = expectedApproxHalfArea(bounds1[b])*float(rCount)*dt1.size();
const float sah = sah0+sah1;
@@ -153,10 +153,10 @@ namespace embree
const Split find(const SetMB& set, const size_t logBlockSize)
{
assert(set.object_range.size() > 0);
unsigned numTimeSegments = set.max_num_time_segments;
unsigned numTimeSegments = unsigned(set.max_num_time_segments);
TemporalBinInfo binner(empty);
binner.bin_parallel(set.prims->data(),set.object_range.begin(),set.object_range.end(),PARALLEL_FIND_BLOCK_SIZE,PARALLEL_THRESHOLD,set.time_range,numTimeSegments,recalculatePrimRef);
Split tsplit = binner.best(logBlockSize,set.time_range,numTimeSegments);
Split tsplit = binner.best((int)logBlockSize,set.time_range,numTimeSegments);
if (!tsplit.valid()) tsplit.data = Split::SPLIT_FALLBACK; // use fallback split
return tsplit;
}
+25 -33
View File
@@ -36,16 +36,6 @@ namespace embree
__forceinline CentGeom (const BBox& geomBounds, const BBox3fa& centBounds)
: geomBounds(geomBounds), centBounds(centBounds) {}
__forceinline void extend(const BBox& geomBounds_, const BBox3fa& centBounds_) {
geomBounds.extend(geomBounds_);
centBounds.extend(centBounds_);
}
__forceinline void reset() {
geomBounds = empty;
centBounds = empty;
}
template<typename PrimRef>
__forceinline void extend_primref(const PrimRef& prim)
{
@@ -55,6 +45,14 @@ namespace embree
centBounds.extend(center);
}
template<typename PrimRef>
__forceinline void extend_center2(const PrimRef& prim)
{
BBox3fa bounds = prim.bounds();
geomBounds.extend(bounds);
centBounds.extend(bounds.center2());
}
__forceinline void extend(const BBox& geomBounds_) {
geomBounds.extend(geomBounds_);
centBounds.extend(center2(geomBounds_));
@@ -90,16 +88,8 @@ namespace embree
__forceinline PrimInfoT (EmptyTy)
: CentGeom<BBox>(empty), begin(0), end(0) {}
__forceinline void reset() {
CentGeom<BBox>::reset();
begin = end = 0;
}
__forceinline PrimInfoT (size_t num, const BBox& geomBounds, const BBox3fa& centBounds)
: CentGeom<BBox>(geomBounds,centBounds), begin(0), end(num) {}
__forceinline PrimInfoT (size_t begin, size_t end, const BBox& geomBounds, const BBox3fa& centBounds)
: CentGeom<BBox>(geomBounds,centBounds), begin(begin), end(end) {}
__forceinline PrimInfoT (size_t begin, size_t end, const CentGeomBBox3fa& centGeomBounds)
: CentGeom<BBox>(centGeomBounds), begin(begin), end(end) {}
template<typename PrimRef>
__forceinline void add_primref(const PrimRef& prim)
@@ -108,29 +98,31 @@ namespace embree
end++;
}
__forceinline void add(const BBox& geomBounds_) {
template<typename PrimRef>
__forceinline void add_center2(const PrimRef& prim) {
CentGeom<BBox>::extend_center2(prim);
end++;
}
template<typename PrimRef>
__forceinline void add_center2(const PrimRef& prim, const size_t i) {
CentGeom<BBox>::extend_center2(prim);
end+=i;
}
/*__forceinline void add(const BBox& geomBounds_) {
CentGeom<BBox>::extend(geomBounds_);
end++;
}
__forceinline void add(const BBox& geomBounds_, const size_t i) {
CentGeom<BBox>::extend(geomBounds_,center2(geomBounds_));
CentGeom<BBox>::extend(geomBounds_);
end+=i;
}
__forceinline void add(const size_t i=1) {
end+=i;
}
__forceinline void add(const BBox& geomBounds_, const BBox3fa& centBounds_, size_t num_ = 1) {
CentGeom<BBox>::extend(geomBounds_,centBounds_);
end += num_;
}
}*/
__forceinline void merge(const PrimInfoT& other)
{
CentGeom<BBox>::merge(other);
//assert(begin == 0);
begin += other.begin;
end += other.end;
}
Loaded 100 of 304 files, more files were not shown because too many files have changed in this diff. Show more