obl/oblas_lite: add OBLAS_TINY to disable look-up table #2

Merged
benpicco merged 2 commits from oblas_lite-nano into master 2022-02-24 16:37:18 -06:00
benpicco commented 2022-02-23 15:06:57 -06:00 (Migrated from github.com)

I implemented your suggestion from https://github.com/sleepybishop/nanorq/pull/10#issuecomment-1048392099 and it works great!
This brings the size of rs.o down to just 2k on Cortex-M4 with recovery still being plenty fast for firmware updates where speed is measured in kilobytes / s anyway.

Doesn't look too bad on Linux either:

master

===BEGIN===P SEED: 1645650675 K: 20 N: 10 T: 64
data shards = 20, repair shards = 10, encoded 128 MB in 0.732 secs, throughput: 174.8MB/s
data shards = 20, repair shards = 10, decoded 128 MB in 0.493 secs, throughput: 259.8MB/s
total time: 3.772|0.732|0.493

OBLAS_TINY

===BEGIN===P SEED: 1645650714 K: 20 N: 10 T: 64
data shards = 20, repair shards = 10, encoded 128 MB in 1.541 secs, throughput: 83.1MB/s
data shards = 20, repair shards = 10, decoded 128 MB in 1.017 secs, throughput: 125.8MB/s
total time: 5.127|1.541|1.017
I implemented your suggestion from https://github.com/sleepybishop/nanorq/pull/10#issuecomment-1048392099 and it works great! This brings the size of `rs.o` down to just 2k on Cortex-M4 with recovery still being plenty fast for firmware updates where speed is measured in kilobytes / s anyway. Doesn't look too bad on Linux either: #### master ``` ===BEGIN===P SEED: 1645650675 K: 20 N: 10 T: 64 data shards = 20, repair shards = 10, encoded 128 MB in 0.732 secs, throughput: 174.8MB/s data shards = 20, repair shards = 10, decoded 128 MB in 0.493 secs, throughput: 259.8MB/s total time: 3.772|0.732|0.493 ``` #### OBLAS_TINY ``` ===BEGIN===P SEED: 1645650714 K: 20 N: 10 T: 64 data shards = 20, repair shards = 10, encoded 128 MB in 1.541 secs, throughput: 83.1MB/s data shards = 20, repair shards = 10, decoded 128 MB in 1.017 secs, throughput: 125.8MB/s total time: 5.127|1.541|1.017 ```
sleepybishop (Migrated from github.com) reviewed 2022-02-23 19:29:47 -06:00
sleepybishop (Migrated from github.com) left a comment

Thank you for the PR. I've left a suggestion that I think is simpler.

Thank you for the PR. I've left a suggestion that I think is simpler.
@ -1,4 +1,32 @@
#include "oblas_lite.h"
sleepybishop (Migrated from github.com) commented 2022-02-23 19:26:49 -06:00

Would you consider this simpler change? The modulus/accumulator bits are not necessary when using the log and exp tables, and gf2_8_mul() can simply be a macro. Finally the multiplication lookup table is only included if OBLAS_TINY is not defined.

#if defined(OBLAS_TINY)
#define GF2_8_MUL(a, b) (((a) && (b)) ? GF2_8_EXP[GF2_8_LOG[(a)] + GF2_8_LOG[(b)]] : 0)

static void obl_axpy_ref(u8 *a, u8 *b, u8 u, unsigned k)
{
    register u8 *ap = a, *ae = &a[k], *bp = b;
    for (; ap != ae; ap++, bp++)
        *ap ^= GF2_8_MUL(u, *bp);
}

static void obl_scal_ref(u8 *a, u8 *b, u8 u, unsigned k)
{
    register u8 *ap = a, *ae = &a[k];
    for (; ap != ae; ap++)
        *ap = GF2_8_MUL(u, *ap);
}
#else
#include "gf2_8_mul_table.h"

Would you consider this simpler change? The modulus/accumulator bits are not necessary when using the log and exp tables, and `gf2_8_mul()` can simply be a macro. Finally the multiplication lookup table is only included if `OBLAS_TINY` is not defined. ```suggestion #if defined(OBLAS_TINY) #define GF2_8_MUL(a, b) (((a) && (b)) ? GF2_8_EXP[GF2_8_LOG[(a)] + GF2_8_LOG[(b)]] : 0) static void obl_axpy_ref(u8 *a, u8 *b, u8 u, unsigned k) { register u8 *ap = a, *ae = &a[k], *bp = b; for (; ap != ae; ap++, bp++) *ap ^= GF2_8_MUL(u, *bp); } static void obl_scal_ref(u8 *a, u8 *b, u8 u, unsigned k) { register u8 *ap = a, *ae = &a[k]; for (; ap != ae; ap++) *ap = GF2_8_MUL(u, *ap); } #else #include "gf2_8_mul_table.h" ```
sleepybishop (Migrated from github.com) approved these changes 2022-02-24 09:40:50 -06:00
sleepybishop (Migrated from github.com) left a comment

Thank you for the PR!

Thank you for the PR!
Sign in to join this conversation.
No description provided.