mirror of
https://github.com/matrix-construct/construct
synced 2025-01-13 16:33:53 +01:00
ircd::simd: Simplify stream template; deduce unaligned type.
This commit is contained in:
parent
112151249b
commit
7f63dc07ef
2 changed files with 11 additions and 15 deletions
|
@ -22,13 +22,11 @@ namespace ircd::simd
|
|||
template<class block_t>
|
||||
using transform_prototype = u64x2 (block_t &, block_t mask);
|
||||
|
||||
template<class block_t_u,
|
||||
class block_t,
|
||||
template<class block_t,
|
||||
class lambda>
|
||||
u64x2 stream(const char *, const u64x2, lambda&&) noexcept;
|
||||
|
||||
template<class block_t_u,
|
||||
class block_t,
|
||||
template<class block_t,
|
||||
class lambda>
|
||||
u64x2 stream(char *, const char *, const u64x2, lambda&&) noexcept;
|
||||
}
|
||||
|
@ -55,8 +53,7 @@ namespace ircd::simd
|
|||
/// gives the buffer size in that format. The return value is the consumed
|
||||
/// bytes (final counter value) in that format.
|
||||
///
|
||||
template<class block_t_u,
|
||||
class block_t,
|
||||
template<class block_t,
|
||||
class lambda>
|
||||
inline ircd::u64x2
|
||||
ircd::simd::stream(char *const __restrict__ out,
|
||||
|
@ -65,6 +62,8 @@ ircd::simd::stream(char *const __restrict__ out,
|
|||
lambda&& closure)
|
||||
noexcept
|
||||
{
|
||||
using block_t_u = unaligned<block_t>;
|
||||
|
||||
u64x2 count
|
||||
{
|
||||
0, // output pos
|
||||
|
@ -156,8 +155,7 @@ noexcept
|
|||
/// iteration; a zero value is available for loop control: the loop will
|
||||
/// break without another iteration.
|
||||
///
|
||||
template<class block_t_u,
|
||||
class block_t,
|
||||
template<class block_t,
|
||||
class lambda>
|
||||
inline ircd::u64x2
|
||||
ircd::simd::stream(const char *const __restrict__ in,
|
||||
|
@ -165,6 +163,8 @@ ircd::simd::stream(const char *const __restrict__ in,
|
|||
lambda&& closure)
|
||||
noexcept
|
||||
{
|
||||
using block_t_u = unaligned<block_t>;
|
||||
|
||||
u64x2 count
|
||||
{
|
||||
max[0], // preserved for caller
|
||||
|
|
10
ircd/json.cc
10
ircd/json.cc
|
@ -498,10 +498,8 @@ const
|
|||
// falls back to scalar instead, so we have to case 128bit systems on GCC.
|
||||
#if defined(__AVX__) || defined(__clang__)
|
||||
using block_t = u8x32;
|
||||
using block_t_u = u256x1_u;
|
||||
#else
|
||||
using block_t = u8x16;
|
||||
using block_t_u = u128x1_u;
|
||||
#endif
|
||||
|
||||
assert(start <= stop);
|
||||
|
@ -531,7 +529,7 @@ const
|
|||
|
||||
const auto count
|
||||
{
|
||||
simd::stream<block_t_u, block_t>(start + 1, max, each_block)
|
||||
simd::stream<block_t>(start + 1, max, each_block)
|
||||
};
|
||||
|
||||
const bool ok
|
||||
|
@ -3450,7 +3448,6 @@ ircd::json::string::stringify(const mutable_buffer &buf,
|
|||
noexcept
|
||||
{
|
||||
using block_t = u8x16;
|
||||
using block_t_u = u128x1_u;
|
||||
|
||||
const u64x2 max
|
||||
{
|
||||
|
@ -3459,7 +3456,7 @@ noexcept
|
|||
|
||||
const auto consumed
|
||||
{
|
||||
simd::stream<block_t_u, block_t>(ircd::data(buf), ircd::data(input), max, string_stringify)
|
||||
simd::stream<block_t>(ircd::data(buf), ircd::data(input), max, string_stringify)
|
||||
};
|
||||
|
||||
return consumed[0]; // output pos (bytes written)
|
||||
|
@ -3696,7 +3693,6 @@ ircd::json::string::serialized(const string_view &input)
|
|||
noexcept
|
||||
{
|
||||
using block_t = u8x16;
|
||||
using block_t_u = u128x1_u;
|
||||
|
||||
const u64x2 max
|
||||
{
|
||||
|
@ -3705,7 +3701,7 @@ noexcept
|
|||
|
||||
const auto count
|
||||
{
|
||||
simd::stream<block_t_u, block_t>(ircd::data(input), max, string_serialized)
|
||||
simd::stream<block_t>(ircd::data(input), max, string_serialized)
|
||||
};
|
||||
|
||||
return count[0];
|
||||
|
|
Loading…
Reference in a new issue