Skip to content

Commit

Permalink
review fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Ralph J. Steinhagen <[email protected]>
  • Loading branch information
RalphSteinhagen committed Aug 6, 2024
1 parent 68118e3 commit d2458b5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
11 changes: 7 additions & 4 deletions blocks/basic/include/gnuradio-4.0/basic/ConverterBlocks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ struct Convert : public gr::Block<Convert<T, R>> {
template<gr::meta::t_or_simd<T> V>
[[nodiscard]] constexpr auto processOne(const V& input) const noexcept {
if constexpr (gr::meta::any_simd<V>) { // simd case
using RetType = std::experimental::rebind_simd_t<R, V>;
using RetType = vir::stdx::rebind_simd_t<R, V>;
return vir::stdx::static_simd_cast<RetType>(input);
} else { // non-simd case
return static_cast<R>(input);
Expand All @@ -42,7 +42,7 @@ Performs scaling, i.e. 'R output = R(input * scale)'
template<gr::meta::t_or_simd<T> V>
[[nodiscard]] constexpr auto processOne(const V& input) const noexcept {
if constexpr (gr::meta::any_simd<V>) { // simd case
using RetType = std::experimental::rebind_simd_t<R, V>;
using RetType = vir::stdx::rebind_simd_t<R, V>;
return vir::stdx::static_simd_cast<RetType>(input * scale);
} else { // non-simd case
return static_cast<R>(input * scale);
Expand All @@ -61,9 +61,9 @@ struct Abs : public gr::Block<Abs<T>> {
[[nodiscard]] constexpr R processOne(T input) const noexcept {
if constexpr (std::is_unsigned_v<T>) {
using TSigned = std::make_signed_t<T>;
return std::abs(static_cast<TSigned>(input));
return static_cast<R>(std::abs(static_cast<TSigned>(input)));
} else {
return std::abs(input);
return static_cast<R>(std::abs(input));
}
}
};
Expand Down Expand Up @@ -240,6 +240,8 @@ ENABLE_REFLECTION_FOR_TEMPLATE(gr::blocks::type::converter::MagPhaseToComplex, m
ENABLE_REFLECTION_FOR_TEMPLATE(gr::blocks::type::converter::ComplexToInterleaved, in, interleaved)
ENABLE_REFLECTION_FOR_TEMPLATE(gr::blocks::type::converter::InterleavedToComplex, interleaved, out)

/*
TODO: temporarily disabled due to excessive compile-times on CI
namespace gr::blocks::type::converter {
using TSupportedTypes = std::tuple<uint8_t, uint16_t, uint32_t, uint64_t, int8_t, int16_t, int32_t, int64_t, float, double>; // N.B. 10 base types
using TComplexTypes = std::tuple<std::complex<float>, std::complex<double>>; // N.B. 2 (valid) complex types
Expand All @@ -263,5 +265,6 @@ const inline auto registerConverterBlocks =
| gr::registerBlockTT<InterleavedToComplex, TCommonRawSDRTypes, TComplexTypes>(gr::globalBlockRegistry());
// clang-format on
} // namespace gr::blocks::type::converter
*/

#endif // CONVERTERBLOCKS_HPP
18 changes: 9 additions & 9 deletions blocks/basic/test/qa_Converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,17 +253,17 @@ const boost::ut::suite<"complex To/From conversion tests"> complexConversion = [
InterleavedToComplex<R, std::complex<T>> interleavedToComplex;

expect(complexToInterleaved.processBulk(complexData, interleavedData) == gr::work::Status::OK);
expect(eq(interleavedData[0], 1.0f));
expect(eq(interleavedData[1], 2.0f));
expect(eq(interleavedData[2], 3.0f));
expect(eq(interleavedData[3], 4.0f));
expect(eq(interleavedData[4], 5.0f));
expect(eq(interleavedData[5], 6.0f));
expect(eq(interleavedData[0], R(1.0f)));
expect(eq(interleavedData[1], R(2.0f)));
expect(eq(interleavedData[2], R(3.0f)));
expect(eq(interleavedData[3], R(4.0f)));
expect(eq(interleavedData[4], R(5.0f)));
expect(eq(interleavedData[5], R(6.0f)));

expect(interleavedToComplex.processBulk(interleavedData, outputComplexData) == gr::work::Status::OK);
expect(eq(outputComplexData[0], std::complex<T>{1.0f, 2.0f}));
expect(eq(outputComplexData[1], std::complex<T>{3.0f, 4.0f}));
expect(eq(outputComplexData[2], std::complex<T>{5.0f, 6.0f}));
expect(eq(outputComplexData[0], std::complex<T>{T(1.0f), T(2.0f)}));
expect(eq(outputComplexData[1], std::complex<T>{T(3.0f), T(4.0f)}));
expect(eq(outputComplexData[2], std::complex<T>{T(5.0f), T(6.0f)}));
} | std::tuple<float, double, std::int8_t, std::int16_t>();
} | kArithmeticTypes;
};
Expand Down

0 comments on commit d2458b5

Please sign in to comment.