Skip to content

Commit bd518a4

Browse files
committed
Minor fixes for AVX512F/AVX512+
Signed-off-by: Nick Avramoussis <4256455+Idclip@users.noreply.github.com>
1 parent c096713 commit bd518a4

2 files changed

Lines changed: 28 additions & 8 deletions

File tree

cmake/OpenVDBUtils.cmake

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,22 @@ function(OPENVDB_COMPUTE_X86_INSTRSET_FROM_VCL VCL_INSTRSET)
189189
# Figure out that the INSTRSET macor would expand to.
190190
# @todo would be much faster with try_run
191191
include(CheckCXXSourceCompiles)
192+
check_cxx_source_compiles([[
193+
#include "${CMAKE_SOURCE_DIR}/ext/vcl/openvdb/ext/vcl/instrset.h"
194+
int main() { static_assert(INSTRSET == 10); return 0; } ]] COMPUTE_VCL_INSTRSET__AVX512VL_DQ_BW__)
195+
if(COMPUTE_VCL_INSTRSET__AVX512VL_DQ_BW__)
196+
set(${VCL_INSTRSET} 10 PARENT_SCOPE)
197+
set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
198+
return()
199+
endif()
200+
check_cxx_source_compiles([[
201+
#include "${CMAKE_SOURCE_DIR}/ext/vcl/openvdb/ext/vcl/instrset.h"
202+
int main() { static_assert(INSTRSET == 9); return 0; } ]] COMPUTE_VCL_INSTRSET__AVX512F__)
203+
if(COMPUTE_VCL_INSTRSET__AVX512F__)
204+
set(${VCL_INSTRSET} 9 PARENT_SCOPE)
205+
set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
206+
return()
207+
endif()
192208
check_cxx_source_compiles([[
193209
#include "${CMAKE_SOURCE_DIR}/ext/vcl/openvdb/ext/vcl/instrset.h"
194210
int main() { static_assert(INSTRSET == 8); return 0; } ]] COMPUTE_VCL_INSTRSET__AVX2__)

openvdb/openvdb/simd/Simd.h

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ namespace simd {
6161
#define OPENVDB_SELECT_SIMD_T(A, ...) A
6262
static inline constexpr size_t OPENVDB_MAX_REGISTER_SIZE =
6363
(OPENVDB_X86_INSTRSET < 7 ? 128 : // no AVX, SSE __m128 registers
64-
(OPENVDB_X86_INSTRSET < 9 ? 256 : // AVX __m256 registers
65-
(OPENVDB_X86_INSTRSET > 9 ? 512 : 0))); // AVX __m512 registers, else 128
64+
(OPENVDB_X86_INSTRSET < 9 ? 256 : // AVX/AVX2 __m256 registers
65+
(OPENVDB_X86_INSTRSET >= 9 ? 512 : 0))); // AVX512 __m512 registers
6666
#else
6767
#define OPENVDB_SELECT_SIMD_T(A, ...) __VA_ARGS__
6868
// @note In this case VCL will not have been used to determine any requested ISA.
@@ -249,24 +249,28 @@ template <> struct IsSimdMaskT<simd::Vec512b> : std::true_type {};
249249

250250
// broad bool masks
251251
#ifdef OPENVDB_USE_VCL // Duplicate specializations when VCL is NOT in use
252-
template <> struct IsSimdMaskT<simd::Vec16cb> : std::true_type {};
252+
#if OPENVDB_X86_INSTRSET < 9 // These alias to corresponding VecNb containers with AVX512f
253253
template <> struct IsSimdMaskT<simd::Vec16fb> : std::true_type {};
254+
template <> struct IsSimdMaskT<simd::Vec8db> : std::true_type {};
255+
template <> struct IsSimdMaskT<simd::Vec8qb> : std::true_type {};
254256
template <> struct IsSimdMaskT<simd::Vec16ib> : std::true_type {};
257+
#endif
258+
#if OPENVDB_X86_INSTRSET < 10 // These alias to corresponding VecNb containers with AVX512+
259+
template <> struct IsSimdMaskT<simd::Vec16cb> : std::true_type {};
255260
template <> struct IsSimdMaskT<simd::Vec16sb> : std::true_type {};
256261
template <> struct IsSimdMaskT<simd::Vec2db> : std::true_type {};
257262
template <> struct IsSimdMaskT<simd::Vec2qb> : std::true_type {};
258263
template <> struct IsSimdMaskT<simd::Vec32cb> : std::true_type {};
259-
template <> struct IsSimdMaskT<simd::Vec32sb> : std::true_type {};
260-
template <> struct IsSimdMaskT<simd::Vec4db> : std::true_type {};
261264
template <> struct IsSimdMaskT<simd::Vec4fb> : std::true_type {};
265+
template <> struct IsSimdMaskT<simd::Vec4db> : std::true_type {};
262266
template <> struct IsSimdMaskT<simd::Vec4ib> : std::true_type {};
263-
template <> struct IsSimdMaskT<simd::Vec4qb> : std::true_type {};
264267
template <> struct IsSimdMaskT<simd::Vec64cb> : std::true_type {};
265-
template <> struct IsSimdMaskT<simd::Vec8db> : std::true_type {};
268+
template <> struct IsSimdMaskT<simd::Vec4qb> : std::true_type {};
266269
template <> struct IsSimdMaskT<simd::Vec8fb> : std::true_type {};
267270
template <> struct IsSimdMaskT<simd::Vec8ib> : std::true_type {};
268-
template <> struct IsSimdMaskT<simd::Vec8qb> : std::true_type {};
269271
template <> struct IsSimdMaskT<simd::Vec8sb> : std::true_type {};
272+
template <> struct IsSimdMaskT<simd::Vec32sb> : std::true_type {};
273+
#endif
270274
#endif
271275

272276
// 8-bit signed integer vectors

0 commit comments

Comments
 (0)