Skip to content

Commit

Permalink
EC/CPU: fix overlap reductions
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergei-Lebedev committed Aug 17, 2023
1 parent bd6f89c commit 928e764
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions src/components/ec/cpu/ec_cpu_reduce.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
#include "ec_cpu.h"
#include <complex.h>

#define DO_DT_REDUCE_WITH_OP(s, d, _count, _n_srcs, OP) \
#define DO_DT_REDUCE_WITH_OP(type, s, d, _count, _n_srcs, OP) \
do { \
size_t _i, _j; \
type _tmp; \
switch (_n_srcs) { \
case 2: \
for (_i = 0; _i < _count; _i++) { \
Expand Down Expand Up @@ -53,13 +54,12 @@
break; \
default: \
for (_i = 0; _i < _count; _i++) { \
d[_i] = OP##_8(s[0][_i], s[1][_i], s[2][_i], s[3][_i], \
s[4][_i], s[5][_i], s[6][_i], s[7][_i]); \
} \
for (_j = 8; _j < _n_srcs; _j++) { \
for (_i = 0; _i < _count; _i++) { \
d[_i] = OP##_2(d[_i], s[_j][_i]); \
_tmp = OP##_8(s[0][_i], s[1][_i], s[2][_i], s[3][_i], \
s[4][_i], s[5][_i], s[6][_i], s[7][_i]); \
for (_j = 8; _j < _n_srcs; _j++) { \
_tmp = OP##_2(_tmp, s[_j][_i]); \
} \
d[_i] = _tmp; \
} \
break; \
} \
Expand All @@ -80,37 +80,37 @@
switch (_op) { \
case UCC_OP_AVG: \
case UCC_OP_SUM: \
DO_DT_REDUCE_WITH_OP(s, d, _count, _n_srcs, DO_OP_SUM); \
DO_DT_REDUCE_WITH_OP(type, s, d, _count, _n_srcs, DO_OP_SUM); \
if (flags & UCC_EEE_TASK_FLAG_REDUCE_WITH_ALPHA) { \
VEC_OP(d, _count, task->alpha); \
} \
break; \
case UCC_OP_MIN: \
DO_DT_REDUCE_WITH_OP(s, d, _count, _n_srcs, DO_OP_MIN); \
DO_DT_REDUCE_WITH_OP(type, s, d, _count, _n_srcs, DO_OP_MIN); \
break; \
case UCC_OP_MAX: \
DO_DT_REDUCE_WITH_OP(s, d, _count, _n_srcs, DO_OP_MAX); \
DO_DT_REDUCE_WITH_OP(type, s, d, _count, _n_srcs, DO_OP_MAX); \
break; \
case UCC_OP_PROD: \
DO_DT_REDUCE_WITH_OP(s, d, _count, _n_srcs, DO_OP_PROD); \
DO_DT_REDUCE_WITH_OP(type, s, d, _count, _n_srcs, DO_OP_PROD); \
break; \
case UCC_OP_LAND: \
DO_DT_REDUCE_WITH_OP(s, d, _count, _n_srcs, DO_OP_LAND); \
DO_DT_REDUCE_WITH_OP(type, s, d, _count, _n_srcs, DO_OP_LAND); \
break; \
case UCC_OP_BAND: \
DO_DT_REDUCE_WITH_OP(s, d, _count, _n_srcs, DO_OP_BAND); \
DO_DT_REDUCE_WITH_OP(type, s, d, _count, _n_srcs, DO_OP_BAND); \
break; \
case UCC_OP_LOR: \
DO_DT_REDUCE_WITH_OP(s, d, _count, _n_srcs, DO_OP_LOR); \
DO_DT_REDUCE_WITH_OP(type, s, d, _count, _n_srcs, DO_OP_LOR); \
break; \
case UCC_OP_BOR: \
DO_DT_REDUCE_WITH_OP(s, d, _count, _n_srcs, DO_OP_BOR); \
DO_DT_REDUCE_WITH_OP(type, s, d, _count, _n_srcs, DO_OP_BOR); \
break; \
case UCC_OP_LXOR: \
DO_DT_REDUCE_WITH_OP(s, d, _count, _n_srcs, DO_OP_LXOR); \
DO_DT_REDUCE_WITH_OP(type, s, d, _count, _n_srcs, DO_OP_LXOR); \
break; \
case UCC_OP_BXOR: \
DO_DT_REDUCE_WITH_OP(s, d, _count, _n_srcs, DO_OP_BXOR); \
DO_DT_REDUCE_WITH_OP(type, s, d, _count, _n_srcs, DO_OP_BXOR); \
break; \
default: \
ec_error(&ucc_ec_cpu.super, \
Expand Down Expand Up @@ -176,16 +176,16 @@
switch (_op) { \
case UCC_OP_AVG: \
case UCC_OP_SUM: \
DO_DT_REDUCE_WITH_OP(s, d, _count, _n_srcs, DO_OP_SUM); \
DO_DT_REDUCE_WITH_OP(type, s, d, _count, _n_srcs, DO_OP_SUM); \
break; \
case UCC_OP_PROD: \
DO_DT_REDUCE_WITH_OP(s, d, _count, _n_srcs, DO_OP_PROD); \
DO_DT_REDUCE_WITH_OP(type, s, d, _count, _n_srcs, DO_OP_PROD); \
break; \
case UCC_OP_MIN: \
DO_DT_REDUCE_WITH_OP(s, d, _count, _n_srcs, DO_OP_MIN); \
DO_DT_REDUCE_WITH_OP(type, s, d, _count, _n_srcs, DO_OP_MIN); \
break; \
case UCC_OP_MAX: \
DO_DT_REDUCE_WITH_OP(s, d, _count, _n_srcs, DO_OP_MAX); \
DO_DT_REDUCE_WITH_OP(type, s, d, _count, _n_srcs, DO_OP_MAX); \
break; \
default: \
ec_error(&ucc_ec_cpu.super, \
Expand All @@ -206,10 +206,10 @@
switch (_op) { \
case UCC_OP_AVG: \
case UCC_OP_SUM: \
DO_DT_REDUCE_WITH_OP(s, d, _count, _n_srcs, DO_OP_SUM); \
DO_DT_REDUCE_WITH_OP(type, s, d, _count, _n_srcs, DO_OP_SUM); \
break; \
case UCC_OP_PROD: \
DO_DT_REDUCE_WITH_OP(s, d, _count, _n_srcs, DO_OP_PROD); \
DO_DT_REDUCE_WITH_OP(type, s, d, _count, _n_srcs, DO_OP_PROD); \
break; \
default: \
ec_error(&ucc_ec_cpu.super, \
Expand Down

0 comments on commit 928e764

Please sign in to comment.