Skip to content

Commit

Permalink
Adding computation offloading support for different OP and Datatypes
Browse files Browse the repository at this point in the history
  • Loading branch information
sb17v authored and Giuseppe Congiu committed Jun 26, 2019
1 parent eeace26 commit 4eea475
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 24 deletions.
22 changes: 15 additions & 7 deletions src/include/mpir_op_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
#ifndef MPIR_OP_UTIL_H_INCLUDED
#define MPIR_OP_UTIL_H_INCLUDED

#include "ch4_cuda_helper.h"
#include "ch4_cuda_kernel_ops.h"

/* The MPI Standard (MPI-2.1, sec 5.9.2) defines which predfined reduction
operators are valid by groups of types:
C integer
Expand Down Expand Up @@ -45,13 +48,18 @@ MPIR_OP_TYPE_GROUP(C_INTEGER)
* emits a warning and generates invalid arithmetic code. We could drop the
* restrict instead, but we are more likely to get an optimization from it than
* const. [goodell@ 2010-12-15] */
#define MPIR_OP_TYPE_REDUCE_CASE(mpi_type_,c_type_,op_macro_) \
case (mpi_type_): { \
c_type_ * restrict a = (c_type_ *)inoutvec; \
/*const*/ c_type_ * restrict b = (c_type_ *)invec; \
for (i=0; i<len; i++) \
a[i] = op_macro_(a[i],b[i]); \
break; \
#define MPIR_OP_TYPE_REDUCE_CASE(mpi_type_,c_type_,type_name_,op_macro_) \
case (mpi_type_): { \
c_type_ * restrict a = (c_type_ *)inoutvec; \
/*const*/ c_type_ * restrict b = (c_type_ *)invec; \
if(is_mem_type_device(inoutvec) && is_mem_type_device(invec)) \
{ \
call_##type_name_##_##op_macro_(a, b, len); \
} else { \
for (i=0; i<len; i++) \
a[i] = op_macro_(a[i],b[i]); \
} \
break; \
}
/* helps enforce consistent naming */
#define MPIR_OP_TYPE_GROUP(group) MPIR_OP_TYPE_GROUP_##group
Expand Down
4 changes: 2 additions & 2 deletions src/mpi/coll/op/opband.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ void MPIR_BAND(void *invec, void *inoutvec, int *Len, MPI_Datatype * type)

switch (*type) {
#undef MPIR_OP_TYPE_MACRO
#define MPIR_OP_TYPE_MACRO(mpi_type_, c_type_, type_name_) MPIR_OP_TYPE_REDUCE_CASE(mpi_type_, c_type_, MPIR_LBAND)
#define MPIR_OP_TYPE_MACRO(mpi_type_, c_type_, type_name_) MPIR_OP_TYPE_REDUCE_CASE(mpi_type_, c_type_, type_name_, MPIR_LBAND)
/* no semicolons by necessity */
MPIR_OP_TYPE_GROUP(C_INTEGER)
MPIR_OP_TYPE_GROUP(C_INTEGER)
MPIR_OP_TYPE_GROUP(FORTRAN_INTEGER)
MPIR_OP_TYPE_GROUP(BYTE)
/* extra types that are not required to be supported by the MPI Standard */
Expand Down
2 changes: 1 addition & 1 deletion src/mpi/coll/op/opbor.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ void MPIR_BOR(void *invec, void *inoutvec, int *Len, MPI_Datatype * type)

switch (*type) {
#undef MPIR_OP_TYPE_MACRO
#define MPIR_OP_TYPE_MACRO(mpi_type_, c_type_, type_name_) MPIR_OP_TYPE_REDUCE_CASE(mpi_type_, c_type_, MPIR_LBOR)
#define MPIR_OP_TYPE_MACRO(mpi_type_, c_type_, type_name_) MPIR_OP_TYPE_REDUCE_CASE(mpi_type_, c_type_, type_name_, MPIR_LBOR)
/* no semicolons by necessity */
MPIR_OP_TYPE_GROUP(C_INTEGER)
MPIR_OP_TYPE_GROUP(FORTRAN_INTEGER)
Expand Down
2 changes: 1 addition & 1 deletion src/mpi/coll/op/opbxor.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ void MPIR_BXOR(void *invec, void *inoutvec, int *Len, MPI_Datatype * type)

switch (*type) {
#undef MPIR_OP_TYPE_MACRO
#define MPIR_OP_TYPE_MACRO(mpi_type_, c_type_, type_name_) MPIR_OP_TYPE_REDUCE_CASE(mpi_type_, c_type_, MPIR_LBXOR)
#define MPIR_OP_TYPE_MACRO(mpi_type_, c_type_, type_name_) MPIR_OP_TYPE_REDUCE_CASE(mpi_type_, c_type_, type_name_, MPIR_LBXOR)
/* no semicolons by necessity */
MPIR_OP_TYPE_GROUP(C_INTEGER)
MPIR_OP_TYPE_GROUP(FORTRAN_INTEGER)
Expand Down
2 changes: 1 addition & 1 deletion src/mpi/coll/op/opland.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void MPIR_LAND(void *invec, void *inoutvec, int *Len, MPI_Datatype * type)

switch (*type) {
#undef MPIR_OP_TYPE_MACRO
#define MPIR_OP_TYPE_MACRO(mpi_type_, c_type_, type_name_) MPIR_OP_TYPE_REDUCE_CASE(mpi_type_, c_type_, MPIR_LLAND)
#define MPIR_OP_TYPE_MACRO(mpi_type_, c_type_, type_name_) MPIR_OP_TYPE_REDUCE_CASE(mpi_type_, c_type_, type_name_, MPIR_LLAND)
/* no semicolons by necessity */
MPIR_OP_TYPE_GROUP(C_INTEGER)

Expand Down
2 changes: 1 addition & 1 deletion src/mpi/coll/op/oplor.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void MPIR_LOR(void *invec, void *inoutvec, int *Len, MPI_Datatype * type)

switch (*type) {
#undef MPIR_OP_TYPE_MACRO
#define MPIR_OP_TYPE_MACRO(mpi_type_, c_type_, type_name_) MPIR_OP_TYPE_REDUCE_CASE(mpi_type_, c_type_, MPIR_LLOR)
#define MPIR_OP_TYPE_MACRO(mpi_type_, c_type_, type_name_) MPIR_OP_TYPE_REDUCE_CASE(mpi_type_, c_type_, type_name_, MPIR_LLOR)
/* no semicolons by necessity */
MPIR_OP_TYPE_GROUP(C_INTEGER)

Expand Down
2 changes: 1 addition & 1 deletion src/mpi/coll/op/oplxor.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void MPIR_LXOR(void *invec, void *inoutvec, int *Len, MPI_Datatype * type)

switch (*type) {
#undef MPIR_OP_TYPE_MACRO
#define MPIR_OP_TYPE_MACRO(mpi_type_, c_type_, type_name_) MPIR_OP_TYPE_REDUCE_CASE(mpi_type_, c_type_, MPIR_LLXOR)
#define MPIR_OP_TYPE_MACRO(mpi_type_, c_type_, type_name_) MPIR_OP_TYPE_REDUCE_CASE(mpi_type_, c_type_, type_name_, MPIR_LLXOR)
/* no semicolons by necessity */
MPIR_OP_TYPE_GROUP(C_INTEGER)

Expand Down
2 changes: 1 addition & 1 deletion src/mpi/coll/op/opmax.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ void MPIR_MAXF(void *invec, void *inoutvec, int *Len, MPI_Datatype * type)

switch (*type) {
#undef MPIR_OP_TYPE_MACRO
#define MPIR_OP_TYPE_MACRO(mpi_type_, c_type_, type_name_) MPIR_OP_TYPE_REDUCE_CASE(mpi_type_, c_type_, MPL_MAX)
#define MPIR_OP_TYPE_MACRO(mpi_type_, c_type_, type_name_) MPIR_OP_TYPE_REDUCE_CASE(mpi_type_, c_type_, type_name_, MPL_MAX)
/* no semicolons by necessity */
MPIR_OP_TYPE_GROUP(C_INTEGER)
MPIR_OP_TYPE_GROUP(FORTRAN_INTEGER)
Expand Down
2 changes: 1 addition & 1 deletion src/mpi/coll/op/opmin.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ void MPIR_MINF(void *invec, void *inoutvec, int *Len, MPI_Datatype * type)

switch (*type) {
#undef MPIR_OP_TYPE_MACRO
#define MPIR_OP_TYPE_MACRO(mpi_type_, c_type_, type_name_) MPIR_OP_TYPE_REDUCE_CASE(mpi_type_, c_type_, MPL_MIN)
#define MPIR_OP_TYPE_MACRO(mpi_type_, c_type_, type_name_) MPIR_OP_TYPE_REDUCE_CASE(mpi_type_, c_type_, type_name_, MPL_MIN)
/* no semicolons by necessity */
MPIR_OP_TYPE_GROUP(C_INTEGER)
MPIR_OP_TYPE_GROUP(FORTRAN_INTEGER)
Expand Down
8 changes: 4 additions & 4 deletions src/mpi/coll/op/opprod.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void MPIR_PROD(void *invec, void *inoutvec, int *Len, MPI_Datatype * type)

switch (*type) {
#undef MPIR_OP_TYPE_MACRO
#define MPIR_OP_TYPE_MACRO(mpi_type_, c_type_, type_name_) MPIR_OP_TYPE_REDUCE_CASE(mpi_type_, c_type_, MPIR_LPROD)
#define MPIR_OP_TYPE_MACRO(mpi_type_, c_type_, type_name_) MPIR_OP_TYPE_REDUCE_CASE(mpi_type_, c_type_, type_name_, MPIR_LPROD)
/* no semicolons by necessity */
MPIR_OP_TYPE_GROUP(C_INTEGER)
MPIR_OP_TYPE_GROUP(FORTRAN_INTEGER)
Expand All @@ -45,9 +45,9 @@ void MPIR_PROD(void *invec, void *inoutvec, int *Len, MPI_Datatype * type)
break; \
}
#undef MPIR_OP_C_COMPLEX_TYPE_MACRO
#define MPIR_OP_C_COMPLEX_TYPE_MACRO(mpi_type_,c_type_,type_name_) MPIR_OP_TYPE_REDUCE_CASE(mpi_type_,c_type_,MPIR_LPROD)
MPIR_OP_TYPE_GROUP(COMPLEX)
MPIR_OP_TYPE_GROUP(COMPLEX_EXTRA)
#define MPIR_OP_C_COMPLEX_TYPE_MACRO(mpi_type_,c_type_,type_name_) MPIR_OP_TYPE_REDUCE_CASE(mpi_type_,c_type_,type_name_,MPIR_LPROD)
// MPIR_OP_TYPE_GROUP(COMPLEX)
// MPIR_OP_TYPE_GROUP(COMPLEX_EXTRA)
/* put things back where we found them */
#undef MPIR_OP_TYPE_MACRO
#undef MPIR_OP_C_COMPLEX_TYPE_MACRO
Expand Down
8 changes: 4 additions & 4 deletions src/mpi/coll/op/opsum.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void MPIR_SUM(void *invec, void *inoutvec, int *Len, MPI_Datatype * type)

switch (*type) {
#undef MPIR_OP_TYPE_MACRO
#define MPIR_OP_TYPE_MACRO(mpi_type_, c_type_, type_name_) MPIR_OP_TYPE_REDUCE_CASE(mpi_type_, c_type_, MPIR_LSUM)
#define MPIR_OP_TYPE_MACRO(mpi_type_, c_type_, type_name_) MPIR_OP_TYPE_REDUCE_CASE(mpi_type_, c_type_, type_name_, MPIR_LSUM)
/* no semicolons by necessity */
MPIR_OP_TYPE_GROUP(C_INTEGER)
MPIR_OP_TYPE_GROUP(FORTRAN_INTEGER)
Expand All @@ -44,9 +44,9 @@ void MPIR_SUM(void *invec, void *inoutvec, int *Len, MPI_Datatype * type)
}
/* C complex types are just simple sums */
#undef MPIR_OP_C_COMPLEX_TYPE_MACRO
#define MPIR_OP_C_COMPLEX_TYPE_MACRO(mpi_type_,c_type_,type_name_) MPIR_OP_TYPE_REDUCE_CASE(mpi_type_,c_type_,MPIR_LSUM)
MPIR_OP_TYPE_GROUP(COMPLEX)
MPIR_OP_TYPE_GROUP(COMPLEX_EXTRA)
#define MPIR_OP_C_COMPLEX_TYPE_MACRO(mpi_type_,c_type_,type_name_) MPIR_OP_TYPE_REDUCE_CASE(mpi_type_,c_type_,type_name_,MPIR_LSUM)
//MPIR_OP_TYPE_GROUP(COMPLEX)
// MPIR_OP_TYPE_GROUP(COMPLEX_EXTRA)
/* put things back where we found them */
#undef MPIR_OP_TYPE_MACRO
#undef MPIR_OP_C_COMPLEX_TYPE_MACRO
Expand Down

0 comments on commit 4eea475

Please sign in to comment.