0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2025-01-16 01:26:58 +01:00

ircd::simd: Simplify string/debug interface.

This commit is contained in:
Jason Volk 2020-06-25 10:37:06 -07:00
parent 99f203a4b7
commit 1ad2a1546a
2 changed files with 195 additions and 24 deletions
include/ircd
ircd

View file

@ -164,17 +164,9 @@ namespace ircd::simd
template<int bits> u128x1 shl(const u128x1 &a) noexcept; template<int bits> u128x1 shl(const u128x1 &a) noexcept;
template<int bits> u128x1 shr(const u128x1 &a) noexcept; template<int bits> u128x1 shr(const u128x1 &a) noexcept;
// debug print lanes hex // readable output and debug
template<class V> template<class T> string_view str_reg(const mutable_buffer &buf, const T &, const uint &fmt = 0) noexcept;
string_view print_lane(const mutable_buffer &buf, const V &) noexcept; template<class T> string_view str_mem(const mutable_buffer &buf, const T &, const uint &fmt = 0) noexcept;
// debug print register hex
template<class V>
string_view print_reg(const mutable_buffer &buf, const V &) noexcept;
// debug print memory hex
template<class V>
string_view print_mem(const mutable_buffer &buf, const V &) noexcept;
} }
namespace ircd namespace ircd

View file

@ -77,14 +77,16 @@ ircd::simd::u128x1_lane_id
template<> template<>
ircd::string_view ircd::string_view
ircd::simd::print_lane(const mutable_buffer &buf, ircd::simd::str_reg(const mutable_buffer &buf,
const u8x16 &a) const u8x16 &a,
const uint &fmt)
noexcept noexcept
{ {
const auto len(::snprintf const auto len(::snprintf
( (
data(buf), size(buf), data(buf), size(buf),
"[%02x|%02x|%02x|%02x|%02x|%02x|%02x|%02x|%02x|%02x|%02x|%02x|%02x|%02x|%02x|%02x]", "0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x "
"0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x",
a[0x00], a[0x01], a[0x02], a[0x03], a[0x04], a[0x05], a[0x06], a[0x07], a[0x00], a[0x01], a[0x02], a[0x03], a[0x04], a[0x05], a[0x06], a[0x07],
a[0x08], a[0x09], a[0x0a], a[0x0b], a[0x0c], a[0x0d], a[0x0e], a[0x0f] a[0x08], a[0x09], a[0x0a], a[0x0b], a[0x0c], a[0x0d], a[0x0e], a[0x0f]
)); ));
@ -97,19 +99,196 @@ noexcept
template<> template<>
ircd::string_view ircd::string_view
ircd::simd::print_lane(const mutable_buffer &buf, ircd::simd::str_reg(const mutable_buffer &buf,
const u8x32 &a) const u16x8 &a_,
const uint &fmt)
noexcept noexcept
{ {
const u8x16 a(a_);
const auto len(::snprintf const auto len(::snprintf
( (
data(buf), size(buf), data(buf), size(buf),
"[%02x|%02x|%02x|%02x|%02x|%02x|%02x|%02x|%02x|%02x|%02x|%02x|%02x|%02x|%02x|%02x" "0x%02x%02x 0x%02x%02x 0x%02x%02x 0x%02x%02x "
"|%02x|%02x|%02x|%02x|%02x|%02x|%02x|%02x|%02x|%02x|%02x|%02x|%02x|%02x|%02x|%02x]", "0x%02x%02x 0x%02x%02x 0x%02x%02x 0x%02x%02x",
a[0x00], a[0x01], a[0x02], a[0x03], a[0x04], a[0x05], a[0x06], a[0x07], a[0x01], a[0x00], a[0x03], a[0x02], a[0x05], a[0x04], a[0x07], a[0x06],
a[0x08], a[0x09], a[0x0a], a[0x0b], a[0x0c], a[0x0d], a[0x0e], a[0x0f], a[0x09], a[0x08], a[0x0b], a[0x0a], a[0x0d], a[0x0c], a[0x0f], a[0x0e]
a[0x10], a[0x11], a[0x12], a[0x13], a[0x14], a[0x15], a[0x16], a[0x17], ));
a[0x18], a[0x19], a[0x1a], a[0x1b], a[0x1c], a[0x1d], a[0x1e], a[0x1f]
return string_view
{
data(buf), size_t(len)
};
}
template<>
ircd::string_view
ircd::simd::str_reg(const mutable_buffer &buf,
const u32x4 &a_,
const uint &fmt)
noexcept
{
const u8x16 a(a_);
const auto len(::snprintf
(
data(buf), size(buf),
"0x%02x%02x%02x%02x 0x%02x%02x%02x%02x "
"0x%02x%02x%02x%02x 0x%02x%02x%02x%02x",
a[0x03], a[0x02], a[0x01], a[0x00], a[0x07], a[0x06], a[0x05], a[0x04],
a[0x0b], a[0x0a], a[0x09], a[0x08], a[0x0f], a[0x0e], a[0x0d], a[0x0c]
));
return string_view
{
data(buf), size_t(len)
};
}
template<>
ircd::string_view
ircd::simd::str_reg(const mutable_buffer &buf,
const u64x2 &a_,
const uint &fmt)
noexcept
{
const u8x16 a(a_);
const auto len(::snprintf
(
data(buf), size(buf),
"0x%02x%02x%02x%02x%02x%02x%02x%02x 0x%02x%02x%02x%02x%02x%02x%02x%02x",
a[0x07], a[0x06], a[0x05], a[0x04], a[0x03], a[0x02], a[0x01], a[0x00],
a[0x0f], a[0x0e], a[0x0d], a[0x0c], a[0x0b], a[0x0a], a[0x09], a[0x08]
));
return string_view
{
data(buf), size_t(len)
};
}
template<>
ircd::string_view
ircd::simd::str_reg(const mutable_buffer &buf,
const u128x1 &a_,
const uint &fmt)
noexcept
{
const u8x16 a(a_);
const auto len(::snprintf
(
data(buf), size(buf),
"0x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
a[0x0f], a[0x0e], a[0x0d], a[0x0c], a[0x0b], a[0x0a], a[0x09], a[0x08],
a[0x07], a[0x06], a[0x05], a[0x04], a[0x03], a[0x02], a[0x01], a[0x00]
));
return string_view
{
data(buf), size_t(len)
};
}
template<>
ircd::string_view
ircd::simd::str_mem(const mutable_buffer &buf,
const u8x16 &a_,
const uint &fmt)
noexcept
{
const u8x16 a(a_);
const auto len(::snprintf
(
data(buf), size(buf),
"%02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x",
a[0x00], a[0x01], a[0x02], a[0x03], a[0x04], a[0x05], a[0x06], a[0x07],
a[0x08], a[0x09], a[0x0a], a[0x0b], a[0x0c], a[0x0d], a[0x0e], a[0x0f]
));
return string_view
{
data(buf), size_t(len)
};
}
template<>
ircd::string_view
ircd::simd::str_mem(const mutable_buffer &buf,
const u16x8 &a_,
const uint &fmt)
noexcept
{
const u8x16 a(a_);
const auto len(::snprintf
(
data(buf), size(buf),
"%02x%02x %02x%02x %02x%02x %02x%02x %02x%02x %02x%02x %02x%02x %02x%02x",
a[0x00], a[0x01], a[0x02], a[0x03], a[0x04], a[0x05], a[0x06], a[0x07],
a[0x08], a[0x09], a[0x0a], a[0x0b], a[0x0c], a[0x0d], a[0x0e], a[0x0f]
));
return string_view
{
data(buf), size_t(len)
};
}
template<>
ircd::string_view
ircd::simd::str_mem(const mutable_buffer &buf,
const u32x4 &a_,
const uint &fmt)
noexcept
{
const u8x16 a(a_);
const auto len(::snprintf
(
data(buf), size(buf),
"%02x%02x%02x%02x %02x%02x%02x%02x %02x%02x%02x%02x %02x%02x%02x%02x",
a[0x00], a[0x01], a[0x02], a[0x03], a[0x04], a[0x05], a[0x06], a[0x07],
a[0x08], a[0x09], a[0x0a], a[0x0b], a[0x0c], a[0x0d], a[0x0e], a[0x0f]
));
return string_view
{
data(buf), size_t(len)
};
}
template<>
ircd::string_view
ircd::simd::str_mem(const mutable_buffer &buf,
const u64x2 &a_,
const uint &fmt)
noexcept
{
const u8x16 a(a_);
const auto len(::snprintf
(
data(buf), size(buf),
"%02x%02x%02x%02x%02x%02x%02x%02x %02x%02x%02x%02x%02x%02x%02x%02x",
a[0x00], a[0x01], a[0x02], a[0x03], a[0x04], a[0x05], a[0x06], a[0x07],
a[0x08], a[0x09], a[0x0a], a[0x0b], a[0x0c], a[0x0d], a[0x0e], a[0x0f]
));
return string_view
{
data(buf), size_t(len)
};
}
template<>
ircd::string_view
ircd::simd::str_mem(const mutable_buffer &buf,
const u128x1 &a_,
const uint &fmt)
noexcept
{
const u8x16 a(a_);
const auto len(::snprintf
(
data(buf), size(buf),
"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
a[0x00], a[0x01], a[0x02], a[0x03], a[0x04], a[0x05], a[0x06], a[0x07],
a[0x08], a[0x09], a[0x0a], a[0x0b], a[0x0c], a[0x0d], a[0x0e], a[0x0f]
)); ));
return string_view return string_view