Open MPI logo

Open MPI User's Mailing List Archives

  |   Home   |   Support   |   FAQ   |  

This web mail archive is frozen.

This page is part of a frozen web archive of this mailing list.

You can still navigate around this archive, but know that no new mails have been added to it since July of 2016.

Click here to be taken to the new web archives of this list; it includes all the mails that are in this frozen archive plus all new mails that have been sent to the list since it was migrated to the new archives.

From: Rainer Keller (keller_at_[hidden])
Date: 2007-05-12 09:58:11


Hello,
On Saturday 12 May 2007 11:25, Sefa Arslan wrote:
> I need to use rank of the mpi processes in my sub functions ( c
> language). which one has more cost?;
> creating a new variable& and finding the rank in each sub function by:
> int mpi_rank;
> MPI_Comm_rank(MPI_COMM_WORLD,&mpi_rank);
> or finding the rank in main function once, and every time sending
> this information to the functions in function arguments like
> foo(a,b,c,mpi_rank);
Depends how often You call this function, too.
But You ommitted another solution, so let's see:
1.) Calling MPI_Comm_rank involves:
- Overhead of calling the function MPI_Comm_rank
- Overhead of checking the communicator (in case of --enable-debug),
- (otherwise, only the inline function ompi_comm_rank is evaluated as
comm->c_my_rank).

2.) Calling MPI_Comm_rank once and pass the rank as parameter:
- Clutters Your function parameters...

3.) Keep the mpi_rank of MPI_COMM_WORLD as global variable.

The latter would be the fastest; although not possibly the nicest solution; if
You already have a structure keeping init-once variables, this would be the
place to keep...

Hope, this helps.

With best regards,
Rainer

-- 
----------------------------------------------------------------
Dipl.-Inf. Rainer Keller       http://www.hlrs.de/people/keller
 High Performance Computing       Tel: ++49 (0)711-685 6 5858
   Center Stuttgart (HLRS)           Fax: ++49 (0)711-685 6 5832
 POSTAL:Nobelstrasse 19                 email: keller_at_[hidden]     
 ACTUAL:Allmandring 30, R.O.030            AIM:rusraink
 70550 Stuttgart