Re: [OMPI devel] pgi and fortran in master

2015-08-30 Thread Jeff Squyres (jsquyres)
Rolf --

Can you ask your compiler guys something?  I don't know enough Fortran to say 
whether this is a bug or we're doing something wrong in OMPI.

Here's the code in question (from 
ompi/mpi/fortran/use-mpi-f08/cart_create_f08.F90):

-
8  subroutine 
MPI_Cart_create_f08(comm_old,ndims,dims,periods,reorder,comm_cart,ierror)
9 use :: mpi_f08_types, only : MPI_Comm
10! See note in mpi-f-interfaces-bind.h for why we "use mpi" here and   
 
11! call a PMPI_* subroutine below. 
 
12use :: mpi, only : PMPI_Cart_create
13implicit none
-

The problem is occurring as a conflict between lines 9 and 12.

The "use :: FOO" statement is somewhat analogous to an #include file in C: it 
imports a series of types and declarations for the compiler to use.

However, Fortran has a special "only" clause that lets you selectively bring in 
only parts of the specified module.

On line 9, we're importing the mpi_f08_types module, but supposedly only the 
declaration of the MPI_Comm type.
Similarly, on line 12, we're importing the mpi module, but supposedly only the 
declaration of the PMPI_Cart_create subroutine.

The problem is that elsewhere in the mpi_f08_types and mpi modules, we have 
conflicting declarations for all the symbols listed in the error message (e.g., 
mpi_fortran_bottom).  Specifically:

- in mpi_f08_types, mpi_fortran_bottom is "integer, bind(C, 
name="mpi_fortran_bottom_") :: MPI_BOTTOM"
- in mpi, mpi_fortran_bottom is "common/mpi_fortran_bottom/MPI_BOTTOM"

(*** it's complicated as to why we do this -- don't ask, unless you really want 
to know! ***)

My understanding was that the "only" clauses on lines 9 and 12 would make this 
ok -- i.e., the Fortran compiler should be ignoring the rest of the modules, 
and therefore ignore the apparently conflict.

Can you ask your Fortran compiler guys what the Fortran language spec says 
about this?


> On Aug 26, 2015, at 10:23 AM, Rolf vandeVaart  wrote:
> 
> I just tested this against the PGI 15.7 compiler and I see the same thing. It 
> appears that we get this error on some of the files called out in 
> ompi/mpi/fortran/use-mpi-f08/mpi-f-interfaces-bind.h as not having an 
> "easy-peasy" solution. All the other files compile just fine.  I checked the 
> list of failing files against the list called out in the 
> mpi-f-interfaces-bind.h file.  The mpi-f-interfaces-bind.h file calls out 32 
> files, but here is the list of files that are failing which is a subset of 
> them (20). Maybe that is a clue to what is going wrong.
> 
>   0 inform,   0 warnings,   9 severes, 0 fatal for mpi_cart_create_f08
>   0 inform,   0 warnings,   9 severes, 0 fatal for mpi_cart_get_f08
>   0 inform,   0 warnings,   9 severes, 0 fatal for mpi_cart_map_f08
>   0 inform,   0 warnings,   9 severes, 0 fatal for mpi_cart_sub_f08
>   0 inform,   0 warnings,   9 severes, 0 fatal for mpi_comm_get_attr_f08
>   0 inform,   0 warnings,   9 severes, 0 fatal for mpi_comm_test_inter_f08
>   0 inform,   0 warnings,   9 severes, 0 fatal for 
> mpi_dist_graph_create_adjacent_f08
>   0 inform,   0 warnings,   9 severes, 0 fatal for mpi_dist_graph_create_f08
>   0 inform,   0 warnings,   9 severes, 0 fatal for 
> mpi_dist_graph_neighbors_count_f08
>   0 inform,   0 warnings,   9 severes, 0 fatal for mpi_graph_create_f08
>   0 inform,   0 warnings,   9 severes, 0 fatal for mpi_info_get_f08
>   0 inform,   0 warnings,   9 severes, 0 fatal for mpi_info_get_valuelen_f08
>   0 inform,   0 warnings,   9 severes, 0 fatal for mpi_intercomm_merge_f08
>   0 inform,   0 warnings,   9 severes, 0 fatal for mpi_op_commutative_f08
>   0 inform,   0 warnings,   9 severes, 0 fatal for mpi_op_create_f08
>   0 inform,   0 warnings,   9 severes, 0 fatal for mpi_type_get_attr_f08
>   0 inform,   0 warnings,   9 severes, 0 fatal for mpi_win_get_attr_f08
>   0 inform,   0 warnings,   9 severes, 0 fatal for mpi_win_test_f08
>   0 inform,   0 warnings,   9 severes, 0 fatal for mpi_file_get_atomicity_f08
>   0 inform,   0 warnings,   9 severes, 0 fatal for mpi_file_set_atomicity_f08
> 
> 
> 
> From: devel  on behalf of Paul Hargrove 
> 
> Sent: Wednesday, August 26, 2015 6:50 AM
> To: Open MPI Developers
> Subject: [OMPI devel] pgi and fortran in master
>  
> It looks like current and past PGI fortran compilers that are happy with 
> 1.8.x and 1.10.x are unhappy with master:
> 
> /bin/sh ../../../../libtool  --tag=FC   --mode=compile pgf90 -DHAVE_CONFIG_H 
> -I. 
> -I/scratch/scratchdirs/hargrove/OMPI/openmpi-master-linux-x86_64-pgi-14.7/openmpi-dev-2371-gea935df/ompi/mpi/fortran/use-mpi-f08
>  -I../../../../opal/include -I../../../../ompi/include 
> -I../../../../oshmem/include 
> -I../../../../opal/mca/hwloc/hwloc1110/hwloc/include/private/autogen 
> -I../../../../opal/mca/hwloc/hwloc1110/hwloc/include/hwloc/autogen 
> -I../../../../ompi/mpiext/cuda/c   
> -I/scratch/scratchdirs/hargrove/OMPI/openmpi-master-linux-x86_64-pgi-14.7/openmpi-dev-2371-g

Re: [OMPI devel] fortran calling MPI_* instead of PMPI_*

2015-08-30 Thread Gilles Gouaillardet
ok, will do

basically, I simply have to
#include "ompi/mpi/c/profile/defines.h"
if configure set the WANT_MPI_PROFILING macro
(since this is an AM_CONDITIONAL, I will have the Makefile.am sets the CPP
flags for the compiler)

makes sense ?

/* the patch will be pretty large since all *_f files are impacted, and for
mpif-h only,
so i'd rather ask before I fill the pr, and even if a sed command will do
most of the job */

Cheers,

Gilles

On Saturday, August 29, 2015, Jeff Squyres (jsquyres) 
wrote:

> On Aug 27, 2015, at 3:25 AM, Gilles Gouaillardet  > wrote:
> >
> > I am lost ...
>
> Fortran does that to ya.  ;-)
>
> > from ompi/mpi/fortran/mpif-h/profile/palltoall_f.c
> >
> > void ompi_alltoall_f(char *sendbuf, MPI_Fint *sendcount, MPI_Fint
> *sendtype,
> >char *recvbuf, MPI_Fint *recvcount, MPI_Fint
> *recvtype,
> >MPI_Fint *comm, MPI_Fint *ierr)
> > {
> >[...]
> >c_ierr = MPI_Alltoall(sendbuf,
> >  OMPI_FINT_2_INT(*sendcount),
> >  c_sendtype,
> >  recvbuf,
> >  OMPI_FINT_2_INT(*recvcount),
> >  c_recvtype, c_comm);
> >[...]
> > }
> >
> > $ nm ompi/mpi/fortran/mpif-h/profile/.libs/palltoall_f.o | grep
> MPI_Alltoall
> > U MPI_Alltoall
> >  W MPI_Alltoall_f
> >  W MPI_Alltoall_f08
> >  W PMPI_Alltoall_f
> >  W PMPI_Alltoall_f08
> >
> > ompi_alltoall_f() calls MPI_Alltoall()
> >
> >
> > the "natural" way of writing a tool is to write mpi_alltoall_ (that
> calls pmpi_alltoall_)
> > *and* MPI_Alltoall (that calls PMPI_Alltoall)
>
> Sidenote: the only correct way to write a tool that intercepts Fortran MPI
> API calls is to write those interceptions *in Fortran*.  I.e., the tool
> should provide MPI_ALLTOALL as a Fortran subroutine.  I realize that this
> is not the point of what you are saying :-), but everyone always gets this
> point wrong, so I feel the need to keep pointing this out.
>
> > since ompi_alltoall_f invokes MPI_Alltoall (and not PMPI_Alltoall), the
> tool is invoked twice, by both the Fortran and C wrapper.
>
> I didn't think that this was true, but I just confirmed it by looking at
> "gcc -E" output in the mpif-h/profile directory.
>
> I don't think that it was the intent.  See below.
>
> > my initial question was
> > "why does ompi_alltoall_f invokes MPI_Alltoall instead of PMPI_Alltoall
> ?"
> >
> > /* since we share the same source code when building with or without mpi
> profiling,
> > that means we would need to
> > #define MPI_Alltoall PMPI_Alltoall
> > when ompi is configure'd with --enable-mpi-profile
> > */
>
> I'm guessing that the complexity in the build system to support
> environments without and with weak symbols (i.e., OS X vs. just about
> everyone else) have made this get lost over time.
>
> Can you supply a patch?
>
> --
> Jeff Squyres
> jsquy...@cisco.com 
> For corporate legal information go to:
> http://www.cisco.com/web/about/doing_business/legal/cri/
>
> ___
> devel mailing list
> de...@open-mpi.org 
> Subscription: http://www.open-mpi.org/mailman/listinfo.cgi/devel
> Link to this post:
> http://www.open-mpi.org/community/lists/devel/2015/08/17897.php
>