aboutsummaryrefslogtreecommitdiff
path: root/cbits/arith.c
diff options
context:
space:
mode:
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]; \