Skip to content

Commit 8e13e57

Browse files
committed
Fixed fmin, fmax and fabs for integer batches (avx512)
1 parent 5b1d1b4 commit 8e13e57

File tree

6 files changed

+35
-0
lines changed

6 files changed

+35
-0
lines changed

include/xsimd/types/xsimd_avx512_int16.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ namespace xsimd
207207
{
208208
template <class T>
209209
struct avx512_int16_batch_kernel
210+
: avx512_int_kernel_base<batch<T, 32>>
210211
{
211212
using batch_type = batch<T, 32>;
212213
using value_type = T;

include/xsimd/types/xsimd_avx512_int32.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ namespace xsimd
155155
{
156156
template <class T>
157157
struct avx512_int32_batch_kernel
158+
: avx512_int_kernel_base<batch<T, 16>>
158159
{
159160
using batch_type = batch<T, 16>;
160161
using value_type = T;

include/xsimd/types/xsimd_avx512_int64.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ namespace xsimd
213213
{
214214
template <class T>
215215
struct avx512_int64_batch_kernel
216+
: avx512_int_kernel_base<batch<T, 8>>
216217
{
217218
using batch_type = batch<T, 8>;
218219
using value_type = T;

include/xsimd/types/xsimd_avx512_int8.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ namespace xsimd
207207
{
208208
template <class T>
209209
struct avx512_int8_batch_kernel
210+
: avx512_int_kernel_base<batch<T, 64>>
210211
{
211212
using batch_type = batch<T, 64>;
212213
using value_type = T;

include/xsimd/types/xsimd_avx512_int_base.hpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,30 @@ namespace xsimd
316316
_mm512_storeu_si512(dst, this->m_value);
317317
}
318318

319+
namespace detail
320+
{
321+
template <class B>
322+
struct avx512_int_kernel_base
323+
{
324+
using batch_type = B;
325+
326+
static batch_type fmin(const batch_type& lhs, const batch_type& rhs)
327+
{
328+
return min(lhs, rhs);
329+
}
330+
331+
static batch_type fmax(const batch_type& lhs, const batch_type& rhs)
332+
{
333+
return max(lhs, rhs);
334+
}
335+
336+
static batch_type fabs(const batch_type& rhs)
337+
{
338+
return abs(rhs);
339+
}
340+
};
341+
}
342+
319343
namespace avx512_detail
320344
{
321345
template <class F, class T, std::size_t N>

test/xsimd_basic_math_test.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,13 @@ TEST(xsimd, avx_double_basic_math)
7979
#endif
8080

8181
#if XSIMD_X86_INSTR_SET >= XSIMD_X86_AVX512_VERSION
82+
TEST(xsimd, avx512_int32_basic_math)
83+
{
84+
std::ofstream out("log/avx512_int32_basic_math.log", std::ios_base::out);
85+
bool res = xsimd::test_basic_math<int32_t, 16, 64>(out, "avx512 int32_t");
86+
EXPECT_TRUE(res);
87+
}
88+
8289
TEST(xsimd, avx512_float_basic_math)
8390
{
8491
std::ofstream out("log/avx512_float_basic_math.log", std::ios_base::out);

0 commit comments

Comments
 (0)