2

I'm just wondering if this is possible and if it is would any one have an example of using the MPI_Op_create to create a Op with a function that has many gsl and or boost functions inside of it to pass it on to an mpi_reduce command. In my situation order doesn't matter but serial and Openmp are too slow for what i want to do, so i want to try to convert it to mpi.

instead of a standard C example

void addem ( int *, int *, int *, MPI_Datatype * );

void addem(int *invec, int *inoutvec, int *len, MPI_Datatype *dtype)
{
    int i;
    for ( i=0; i<*len; i++ )
        inoutvec[i] += invec[i];
}

which is then passed on to

MPI_Op_create( (MPI_User_function *)addem, 1, &op );

i would change that to something similar but much more complicated then this

void addgsl(gsl_vector* vec,gsl matrix* mat, int num,.....,MPI_Datatype *dtype)

 for (int i=0; i <num; i++) {
     //some complicated boost or gsl mathematical formula here
                             }

1 Answer 1

3

There are no limitations on what user-defined operations can do: they are simply given some elements from the input and are expected to compute a result. The only requirement for user ops is that they are associative. There is also no way to predict how many elements the function will get: this is up to the MPI implementation, and is specified by the len parameter.

Sign up to request clarification or add additional context in comments.

1 Comment

it says I can specific associate + commutative or not(from the openMPI doc , might be different for different implementations) in my situation order doesn't matter so this is good news thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.