Skip to content
Snippets Groups Projects
Commit 74cdc0c0 authored by Moritz Hanke's avatar Moritz Hanke
Browse files

adds new reduce operation COMM_OP_OR

parent 343ef047
No related branches found
No related tags found
No related merge requests found
......@@ -531,4 +531,41 @@ static void comm_op_sum(void * invec, void * inoutvec, unsigned count,
}
}
static void comm_op_or_uint(void * a, void * b) {
*(unsigned*)b = *(unsigned*)a | *(unsigned*)b;
}
static void comm_op_or_int(void * a, void * b) {
*(int*)b = *(int*)a | *(int*)b;
}
static void comm_op_or_byte(void * a, void * b) {
*(char*)b = *(char*)a | *(char*)b;
}
static void comm_op_or(void * invec, void * inoutvec, unsigned count,
enum yac_comm_data_type type) {
struct {
size_t size;
void (*func)(void * a, void * b);
} comm_op_or[3] = {{.size = sizeof(unsigned), .func = comm_op_or_uint},
{.size = sizeof(int), .func = comm_op_or_int},
{.size = sizeof(char), .func = comm_op_or_byte}},
this_comm_op_or;
switch (type) {
default : yac_internal_abort_message("ERROR(comm_op_or): unsupported or "
"invalid data type", __FILE__, __LINE__);
case (COMM_UINT): this_comm_op_or = comm_op_or[0]; break;
case (COMM_INT): this_comm_op_or = comm_op_or[1]; break;
case (COMM_BYTE): this_comm_op_or = comm_op_or[2]; break;
};
for (unsigned i = 0; i < count; ++i) {
this_comm_op_or.func(invec, inoutvec);
invec = (char*)invec + this_comm_op_or.size;
inoutvec = (char*)inoutvec + this_comm_op_or.size;
}
}
extern func_comm_op COMM_OP_SUM = comm_op_sum;
extern func_comm_op COMM_OP_OR = comm_op_or;
......@@ -82,6 +82,7 @@ typedef void (*func_comm_op)(void * invec, void * inoutvec, unsigned count,
enum yac_comm_data_type type);
extern func_comm_op COMM_OP_SUM;
extern func_comm_op COMM_OP_OR;
/**! priorities used by \ref yac_comm_recv_callback\n
* (highest priority needs to have lowest numerical value)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment