How to Retrieve the Value of MPI_TAG_UB in openmpi/2.1.1 Using Fortran?

  • Fortran
  • Thread starter pachomba
  • Start date
  • Tags
    Fortran
In summary: So I suggest that you declare VALUE as INTEGER instead of INTEGER (KIND=MPI_ADDRESS_KIND) and print/write it after the MPI_COMM_GET_ATTR call.In summary, the conversation discusses getting the parameter MPI_TAG_UB for openmpi and using the routine MPI_COMM_GET_ATTR to do so. It is suggested to use "use mpi" in the code and compile it using mpifort. The code should include a print/write statement to show the value of MPI_TAG_UB and the argument MAXTAG should be removed. It is also recommended to declare VALUE as INTEGER instead of INTEGER (KIND=MPI_ADDRESS_KIND) as the upper bound for tags is never smaller than 32767. The error "shmem: posix: file
  • #1
pachomba
3
0
Hello,
I am trying to get the parameter MPI_TAG_UB for openmpi (I am using version 2.1.1). I know I need to use the routine MPI_COMM_GET_ATTR, but I have no idea how to do that, I never used fortran in my life. Following this link (https://www.mpi-forum.org/docs/mpi-2.2/mpi22-report/node369.htm) I tried this:

LOGICAL FLAG
INTEGER IERR
INTEGER (KIND=MPI_ADDRESS_KIND) VALUE

! Upon successful return, VALUE == 7 (sign extended)
CALL MPI_COMM_GET_ATTR(MPI_COMM_WORLD, KEYVAL, VALUE, FLAG, IERR)

I put that in a file test.f90, then did gfortran test.f90 -o test.out, but I got this error message:

Error: Parameter 'mpi_address_kind' at (1) has not been declared or is a variable, which does not reduce to a constant expression
Error: Unexpected end of file in 'test.f90'

So I have no idea what I'm doing. Did someone ever retrieved the value of MPI_TAG_UB for some MPI implementation?
Thanks!
 
Technology news on Phys.org
  • #2
MPI constants are of course not part of Fortran, so the compiler doesn't know what to do with MPI_ADDRESS_KIND.

Try
Fortran:
use mpi
at the beginning of your code.
 
  • #3
DrClaude said:
MPI constants are of course not part of Fortran, so the compiler doesn't know what to do with MPI_ADDRESS_KIND.

Try
Fortran:
use mpi
at the beginning of your code.

Thank you very much DrClaude, I tired that and I got this error:
Error: Unexpected end of file in 'test.f90'

Then I tried including "PROGRAM test" and "END PROGRAM test" at the beginning and end of the script, and I got this error:
~/tmp/cc3b6Lod.o: In function `MAIN__':
test.f90:(.text+0x34): undefined reference to `mpi_comm_get_attr_'
collect2: ld returned 1 exit status

I know it must be a very basic thing I'm not doing, I plan to learn some fortran in the future but for now I just need to get that MPI_TAG_UB value.
Truly appreciate any help.
 
  • #4
pachomba said:
~/tmp/cc3b6Lod.o: In function `MAIN__':
test.f90:(.text+0x34): undefined reference to `mpi_comm_get_attr_'
collect2: ld returned 1 exit status
That's because your not linking to the MPI library. The easiest way to do this is to compile using mpifort instead of gfortran (it will still use gfortran, but will correctly link). See https://www.open-mpi.org/faq/?category=mpi-apps
 
  • #5
DrClaude said:
That's because your not linking to the MPI library. The easiest way to do this is to compile using mpifort instead of gfortran (it will still use gfortran, but will correctly link). See https://www.open-mpi.org/faq/?category=mpi-apps

Thank you Dr, I was able to compile the program with mpifort, now the program looks like this:

PROGRAM test
include 'mpif.h'

LOGICAL FLAG
INTEGER IERR
INTEGER (KIND=MPI_ADDRESS_KIND) VALUE
! Upon successful return, VALUE == 7 (sign extended)
CALL MPI_INIT(IERR)
CALL MPI_COMM_GET_ATTR(MPI_COMM_WORLD, MPI_TAG_UB, MAXTAG, VALUE, FLAG, IERR)

END PROGRAM test

but when I run it I get this error now:

shmem: posix: file name search - max attempts exceeded.cannot continue with posix.

I guess I need to add an include 'something' line at the beginning? Also, is this going to actually tell me what the value of MPI_TAG_UB is?
 
  • #6
pachomba said:
PROGRAM test
include 'mpif.h'

LOGICAL FLAG
INTEGER IERR
INTEGER (KIND=MPI_ADDRESS_KIND) VALUE
! Upon successful return, VALUE == 7 (sign extended)
CALL MPI_INIT(IERR)
CALL MPI_COMM_GET_ATTR(MPI_COMM_WORLD, MPI_TAG_UB, MAXTAG, VALUE, FLAG, IERR)

END PROGRAM test
That program has no output. you have to add a print (or write) statement to show the value of VALUE. Also, when posting code, please use CODE tags (you can get them automatically by clicking on the + in the bar above the text area and choosing </> Code.)
pachomba said:
shmem: posix: file name search - max attempts exceeded.cannot continue with posix.
This appears to be an implementation-dependent error. How are you launching the program? (Often, you need a launcher to execute correctly in parallel, such as mpirun.)

pachomba said:
Also, is this going to actually tell me what the value of MPI_TAG_UB is?
As I wrote above, the program as is will have no output. Looking at the specification soft MPI_COMM_GET_ATTR, you have one argument too many. You should remove MAXTAG. Also, I don't understand why you think that VALUE should be 7, because the MPI standard specifies that the upper bound on tags is never smaller than 32767.
 

What is MPI_TAG_UB and how does it relate to openmpi/2.1.1?

MPI_TAG_UB stands for the upper bound on the values of tags that can be used for message passing in the Message Passing Interface (MPI) protocol. This value is implementation-dependent and may vary across different versions of MPI, such as openmpi/2.1.1.

How is MPI_TAG_UB determined in openmpi/2.1.1?

The value of MPI_TAG_UB in openmpi/2.1.1 is typically determined by the underlying communication library, such as OpenFabrics, TCP/IP, or shared memory. It is usually set to a large value to allow for a wide range of tag values.

What is the significance of MPI_TAG_UB in message passing?

The value of MPI_TAG_UB is important because it sets the upper limit on the values of tags that can be used for message passing. It ensures that messages are not inadvertently overwritten and that communication is efficient and reliable.

Can MPI_TAG_UB be changed in openmpi/2.1.1?

In most cases, MPI_TAG_UB cannot be changed in openmpi/2.1.1 as it is determined by the communication library. However, some implementations may allow for the value to be adjusted using environment variables or configuration options.

What happens if a tag value exceeds MPI_TAG_UB in openmpi/2.1.1?

If a tag value exceeds MPI_TAG_UB in openmpi/2.1.1, the behavior is implementation-dependent. Some implementations may return an error, while others may wrap the tag value around to the lower bound. It is important to check the documentation for the specific implementation being used.

Similar threads

  • Programming and Computer Science
Replies
4
Views
620
  • Programming and Computer Science
Replies
12
Views
3K
  • Programming and Computer Science
Replies
8
Views
1K
  • Programming and Computer Science
Replies
12
Views
6K
  • Programming and Computer Science
Replies
8
Views
881
  • Engineering and Comp Sci Homework Help
Replies
7
Views
1K
  • Programming and Computer Science
Replies
16
Views
2K
  • Programming and Computer Science
Replies
1
Views
2K
  • Programming and Computer Science
Replies
13
Views
2K
  • Programming and Computer Science
Replies
12
Views
1K
Back
Top