Method MPI.Op_create()

Method Op_create

Op Op_create(function(object, object:void) ufun, int commute)


Creates a user-defined MPI operation.

Parameter ufun

The function that implements the MPI.Op to be created.

Parameter commute

Set to 1 if the operation commutes.


void my_add_fun(object invec, object outvec) { for (int i = 0; i < sizeof(outvec); i++) { outvec[i] += invec[i]; }

int main() { MPI.Op myadd; MPI.IntArray ia = MPI.IntArray(10), results;


myadd = MPI.Op_create(my_add_fun, 1);

for (int i = 0; i < sizeof(ia); i++) ia[i] = random(1000);

if (!>rank) results = MPI.IntArray(sizeof(ia));>Reduce(ia, results, 0); if (!>rank) for (int i; i < sizeof(results); i++) write("%02d: %d\n", i, results[i]);

MPI.Finalize(); return 0; }


User-defined MPI operations may not call any MPI operations themselves.

See also

MPI.Comm->Reduce(), MPI_Op_create(3)