aboutsummaryrefslogtreecommitdiff
path: root/cbits/arith.c
diff options
context:
space:
mode:
authorTom Smeding <tom@tomsmeding.com>2024-05-23 13:54:10 +0200
committerTom Smeding <tom@tomsmeding.com>2024-05-23 13:54:10 +0200
commitc231637529ce7fc5b321c24a24320b505df51e91 (patch)
tree769fac7565017de380f61a8aa0b620dd9c9040be /cbits/arith.c
parent4c86a3a4231cecc5b7c31491398f43b4ba667eea (diff)
Better naming in C code
Diffstat (limited to 'cbits/arith.c')
-rw-r--r--cbits/arith.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/cbits/arith.c b/cbits/arith.c
index ca16bf8..3c5d846 100644
--- a/cbits/arith.c
+++ b/cbits/arith.c
@@ -37,7 +37,9 @@ typedef int64_t i64;
// This does not result in multiple loads with GCC 13.
#define GEN_SIGNUM(x) ((x) < 0 ? -1 : (x) > 0 ? 1 : 0)
-#define TARRAY_WALK(again_label_name, rank, shape, strides, body) \
+// Walk a orthotope-style strided array, except for the inner dimension. The
+// body is run for every "inner vector".
+#define TARRAY_WALK_NOINNER(again_label_name, rank, shape, strides, body) \
do { \
i64 idx[(rank) - 1]; \
memset(idx, 0, ((rank) - 1) * sizeof(idx[0])); \
@@ -68,7 +70,7 @@ typedef int64_t i64;
#define REDUCE1_OP(name, op, typ) \
void oxarop_ ## name ## _ ## typ(i64 rank, const i64 *shape, const i64 *strides, typ *out, const typ *arr) { \
if (strides[rank - 1] == 1) { \
- TARRAY_WALK(again1, rank, shape, strides, { \
+ TARRAY_WALK_NOINNER(again1, rank, shape, strides, { \
typ accum = arr[arrlinidx]; \
for (i64 i = 1; i < shape[rank - 1]; i++) { \
accum = accum op arr[arrlinidx + i]; \
@@ -76,7 +78,7 @@ typedef int64_t i64;
out[outlinidx] = accum; \
}); \
} else { \
- TARRAY_WALK(again2, rank, shape, strides, { \
+ TARRAY_WALK_NOINNER(again2, rank, shape, strides, { \
typ accum = arr[arrlinidx]; \
for (i64 i = 1; i < shape[rank - 1]; i++) { \
accum = accum op arr[arrlinidx + strides[rank - 1] * i]; \