[Mpi-forum] MPI compile-time/link-time constants

Jeff Squyres jsquyres at cisco.com
Mon Jan 12 12:31:45 CST 2009


Short version: Are MPI constants defined to be compile-time or link- 
time constants?  (I'm only interested in constants here, like  
MPI_ANY_TAG, not handles like MPI_COMM_WORLD)

Longer version: MPI-2.1:2.5.4 states that values like MPI_ANY_TAG need  
to be able to be used for initialization expressions and assignments.   
But what about switch/case statements?  I ask because we have a  
workaround in OMPI for making MPI::SEEK_SET (and friends) work in Open  
MPI, but by making them link-time constants, not compile-time  
constants.  Hence, you can do this:

   int a = MPI::SEEK_SET;

but you can't do this (it'll fail with a compiler error):

   switch (a) {
   case MPI::SEEK_SET:
     ...

Upon closer read on MPI-2.1:2.5.4, I *think* that's actually ok  
because MPI::SEEK_SET is usable for initialization expressions and  
assignments.  There doesn't seem to be a requirement that  
MPI::SEEK_SET (and friends) need to be able to be used in compile-time  
constant expressions (such as switch/case).

Does that sound right to everyone?

-- 
Jeff Squyres
Cisco Systems




More information about the mpi-forum mailing list