0

I cannot get extend of the derived MPI data type in the following code when I do mpirun -n 2 ./out. Why?

Error message:

*** An error occurred in MPI_Type_get_extent
*** reported by process [969080833,1]
*** on communicator MPI_COMM_WORLD
*** MPI_ERR_ARG: invalid argument of some other kind
*** MPI_ERRORS_ARE_FATAL (processes in this communicator will now abort,
***    and potentially your MPI job)
1 more process has sent help message help-mpi-errors.txt / mpi_errors_are_fatal
Set MCA parameter "orte_base_help_aggregate" to 0 to see all help / error messages

main.cpp:

#include "mpi.h"

MPI_Datatype MPI_A;

struct A
{ 
    int a;
};  

int main()
{   
    MPI_Init(NULL, NULL);

    A a;

    int nblock = 1;
    int block_count = 1;
    MPI_Aint offset = 0;
    MPI_Datatype block_type = MPI_INT;

    MPI_Type_struct(nblock, &block_count, &offset, &block_type, &MPI_A);
    MPI_Type_commit(&MPI_A);

    MPI_Aint extent;
    MPI_Type_get_extent(MPI_A, NULL, &extent);

    return 0;
}

1 Answer 1

2

The error is here:

MPI_Type_get_extent(MPI_A, NULL, &extent);
                           ^^^^

Neither the lower bound nor the extent arguments in the call to MPI_Type_get_extent can be NULL.

Also, your code is missing the mandatory call to MPI_Finalize().

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

Comments

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.