What is MPI_Comm_copy_attr_function?

MPI library

MPI (Message Passing Interface) is a library that allows you to write parallel programs in C or Fortran77. The library uses commonly available operating system services to create parallel processes and exchange information among these processes.

Parallel processing

MPI_Comm_copy_attr_function

This method is a callback function for caching on communicators. It is invoked when a communicator is duplicated by MPI_COMM_DUP or MPI_COMM_IDUP.

Syntax

int MPI_Comm_copy_attr_function( MPI_Comm oldcomm,int comm_keyval, void *extra_state, void *attribute_val_in, void *attribute_val_out, int *flag
);

Parameters

The copy callback function is called for each key value in oldcomm in an arbitrary order. Each call to the copy callback is made with a key value and its associated attribute.

  • oldcomm is the original communicator object describing a group of processes. In many applications, various processes work together and a communicator describes the processes that a routine initiates.

  • comm_keyval is the key value returned by the MPI_Comm_create_keyval method.

  • extra_state is an optional argument to duplicate the extra state.

  • attribute_val_in is the source attribute value.

  • attribute_val_out is an output parameter representing the destination attribute value.

  • flag is an indicator. If the returned value of flag is 0, the attribute is deleted in the duplicated communicator. If the value returned is 1, the new attribute value is set to the value returned in attribute_val_out.

Return value

The function returns an error if it is unsuccessful. By default, the error aborts the MPI job.

In case of success, it returns MPI_SUCCESS - the value returned upon successful termination of any MPI routine.

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved