From 969c43f01645f98380bdf65c43b1cf03df589a0b Mon Sep 17 00:00:00 2001 From: Ahmet Inan Date: Tue, 24 Sep 2019 00:07:14 +0200 Subject: [PATCH] use horizontal rotation helper --- ldpc_decoder.hh | 15 ++------------- ldpc_decoder2.hh | 15 ++------------- 2 files changed, 4 insertions(+), 26 deletions(-) diff --git a/ldpc_decoder.hh b/ldpc_decoder.hh index 8303819..f2baeb8 100644 --- a/ldpc_decoder.hh +++ b/ldpc_decoder.hh @@ -11,6 +11,7 @@ Copyright 2018 Ahmet Inan #include #include "simd.hh" +#include "rotate.hh" namespace CODE { @@ -41,6 +42,7 @@ class LDPCDecoder static const int BNL = (TABLE::LINKS_TOTAL + D-1) / D; typedef SIMD TYPE; + Rotate rotate; TYPE bnl[BNL]; TYPE msg[MSG]; @@ -95,19 +97,6 @@ class LDPCDecoder { return vreinterpret(vand(vmask(b), vorr(vceqz(a), veor(vcgtz(a), vcltz(b))))); } - static TYPE rotate(TYPE a, int s) - { - if (s < 0) - s += D; - int t = D - s; - TYPE ret; - // TODO: I can has barrel shifter? - for (int n = 0; n < s; ++n) - ret.v[n] = a.v[n+t]; - for (int n = 0; n < t; ++n) - ret.v[n+s] = a.v[n]; - return ret; - } bool bad() { diff --git a/ldpc_decoder2.hh b/ldpc_decoder2.hh index 29aea52..a7e4ec8 100644 --- a/ldpc_decoder2.hh +++ b/ldpc_decoder2.hh @@ -11,6 +11,7 @@ Copyright 2018 Ahmet Inan #include #include "simd.hh" +#include "rotate.hh" namespace CODE { @@ -42,6 +43,7 @@ class LDPCDecoder static const int POS = (TABLE::LINKS_TOTAL - (2*R-1) + D-1) / D; typedef SIMD TYPE; + Rotate rotate; TYPE bnl[BNL]; TYPE msg[MSG]; @@ -97,19 +99,6 @@ class LDPCDecoder { return vreinterpret(vand(vmask(b), vorr(vceqz(a), veor(vcgtz(a), vcltz(b))))); } - static TYPE rotate(TYPE a, int s) - { - if (s < 0) - s += D; - int t = D - s; - TYPE ret; - // TODO: I can has barrel shifter? - for (int n = 0; n < s; ++n) - ret.v[n] = a.v[n+t]; - for (int n = 0; n < t; ++n) - ret.v[n+s] = a.v[n]; - return ret; - } bool bad() {