What is MPI_Comm_free_keyval?
MPI library
MPI, short for Message Passing Interface, is a library that allows you to write parallel programs in Fortran77 or C. The library uses common operating system services to exchange information among the parallel processes it creates.
MPI_Comm_free_keyval
This method deletes an attribute key for communicator objects.
Syntax
int MPI_Comm_free_keyval(
int *comm_keyval
);
Parameters
comm_keyvalis the key value that will be deleted.
Return value
If unsuccessful, the function returns an error. The error aborts the MPI job by default.
-
In case of success,
MPI_Comm_free_keyvalreturnsMPI_SUCCESS, which is the value returned upon successful termination of any MPI routine. -
MPI_ARR_ARGis returned if an invalid argument is provided or an attempt is made to free one of the permanent keys.
Example
The following illustrates the use of MPI_Comm_free_keyval.
#include "mpi.h"
#include <stdio.h>
int main( int argc, char *argv[] )
{
int key[3];
int i;
MPI_Comm comm;
MPI_Init( &argc, &argv );
comm = MPI_COMM_WORLD;
/* Creating key values */
for (i=0; i<3; i++) {
MPI_Comm_create_keyval( MPI_NULL_COPY_FN, MPI_NULL_DELETE_FN, &key[i], (void *)0 );
}
/* Deleting key values */
for (i=0; i<3; i++) {
MPI_Comm_free_keyval( &key[i] );
}
}
-
We create three key values in the
forloop. -
We use the default copy and delete functions,
MPI_COMM_NULL_COPY_FNandMPI_COMM_NULL_DELETE_FN, in the function’s arguments. -
Finally, we free the key values using the
MPI_Comm_free_keyvalfunction at the end of the above code.
Free Resources