Skip to content

Commit 00d20fe

Browse files
Implement batch_bool::mask() for riscv
As a followup to #1236
1 parent 6f7ee16 commit 00d20fe

File tree

4 files changed

+23
-11
lines changed

4 files changed

+23
-11
lines changed

include/xsimd/arch/xsimd_constants.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#ifndef XSIMD_NUMERICAL_CONSTANT_HPP
1313
#define XSIMD_NUMERICAL_CONSTANT_HPP
1414

15-
#include <limits>
15+
//#include <limits>
1616

1717
#include "../types/xsimd_utils.hpp"
1818

include/xsimd/arch/xsimd_rvv.hpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
#ifndef XSIMD_RVV_HPP
1111
#define XSIMD_RVV_HPP
1212

13-
#include <complex>
14-
#include <type_traits>
15-
#include <utility>
13+
//#include <complex>
14+
//#include <type_traits>
15+
//#include <utility>
1616

1717
#include "../types/xsimd_rvv_register.hpp"
1818
#include "xsimd_constants.hpp"
@@ -76,6 +76,8 @@
7676
#define XSIMD_RVV_M , _M,
7777
#define XSIMD_RVV_TSM XSIMD_RVV_T XSIMD_RVV_S XSIMD_RVV_M
7878

79+
#define XSIMD_RVV_MASKED _m
80+
7981
// XSIMD_RVV_OVERLOAD, below, expands to a head section, a number of body sections
8082
// (depending on which types are supported), and a tail section. Different
8183
// variants of these sections are implemented with different suffixes on the
@@ -1507,6 +1509,16 @@ namespace xsimd
15071509
const auto mask = abs(arg) < constants::maxflint<batch<T, A>>();
15081510
return select(mask, to_float(detail::rvvfcvt_default(arg)), arg, rvv {});
15091511
}
1512+
1513+
// mask
1514+
template <class A, class T>
1515+
XSIMD_INLINE uint64_t mask(batch_bool<T, A> const& self, requires_arch<rvv>) noexcept
1516+
{
1517+
auto ones = detail::broadcast<as_unsigned_integer_t<T>, A::width>(1);
1518+
auto iota = vindex<A, T>();
1519+
auto powers = detail::rvvsll(ones, iota);
1520+
return __riscv_vredor(self.data, powers);
1521+
}
15101522
} // namespace kernel
15111523
} // namespace xsimd
15121524

include/xsimd/types/xsimd_register.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#ifndef XSIMD_REGISTER_HPP
1313
#define XSIMD_REGISTER_HPP
1414

15-
#include <type_traits>
15+
//#include <type_traits>
1616

1717
namespace xsimd
1818
{

include/xsimd/types/xsimd_utils.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
#ifndef XSIMD_UTILS_HPP
1313
#define XSIMD_UTILS_HPP
1414

15-
#include <complex>
16-
#include <cstdint>
17-
#include <cstring>
18-
#include <tuple>
19-
#include <type_traits>
20-
#include <utility>
15+
//#include <complex>
16+
//#include <cstdint>
17+
//#include <cstring>
18+
//#include <tuple>
19+
//#include <type_traits>
20+
//#include <utility>
2121

2222
#ifdef XSIMD_ENABLE_XTL_COMPLEX
2323
#include "xtl/xcomplex.hpp"

0 commit comments

Comments
 (0)