[mvapich-discuss] mvapich2 profiling interface for Fortran

Sayantan Sur surs at cse.ohio-state.edu
Thu Feb 18 17:50:03 EST 2010


Hi Paul,

Thanks for your detailed explanation.

I'm not sure if you are aware of mpiP (http://mpip.sourceforge.net/).
We use this tool frequently to profile MPI applications. This works
with C and Fortran MPI programs. It seems to me that the authors of
mpiP would have solved the kind of issues you are mentioning. Maybe
mpiP developers can help you out as well.

Thanks,

On Thu, Feb 18, 2010 at 5:36 PM, Paul Howard <paulhoward at microway.com> wrote:
> Sayantan Sur wrote:
>
> On Thu, Feb 18, 2010 at 9:48 AM, Paul Howard <paulhoward at microway.com>
> wrote:
>
>
> Hi ... can someone please point me to documentation for the Fortran PMPI
> interface? I'm using mvapich2-1.4, and trying to write a simple
> profiling library. I can do it for C, but not Fortran.
>
>
> I'm wondering if you could elaborate on the exact problem you're
> facing? e.g. some compilation error you may be facing?
>
>
> Thanks for your reply, and sorry for being unclear. What I would like
> to be able to do is write a profiling library (preferably in C), that
> could be called from an MPI Fortran program. It would contain
> functions like this:
>
> int
> MPI_Send (void *       buf,
>       int          count,
>       MPI_Datatype datatype,
>       int          dest,
>       int          tag,
>       MPI_Comm     comm)
> {
>     int  rv;
>
>     trace_printf_c ("MPI_Send", 0, count, datatype, dest);
>     rv = PMPI_Send (buf, count, datatype, dest, tag, comm);
>     trace_printf_c ("MPI_Send", 1, count, datatype, dest);
>     return rv;
> }
>
> where trace_printf_c is a C function that takes a function name as its
> first argument, and uses the other arguments to compute the size of
> the message and print a trace message with a timestamp. (The second
> argument is 0 for begin, 1 for end.)
>
> The above works if the user MPI program is in C. But I would like it
> to be callable from a user MPI program written in Fortran, with calls
> like:
>
>       call MPI_SEND (buf, count, datatype, dest, tag, comm, ierr)
>
> I got it to work by writing the profiling function in Fortran like this:
>
>       subroutine MPI_SEND (buf, count, datatype, dest, tag, comm, ierr)
>       integer buf, count, datatype, dest, tag, comm, ierr
>
>       integer FN_MPI_SEND
>       parameter (FN_MPI_SEND=32)
>
>       call trace_printf_fortran (FN_MPI_SEND, 0, count, datatype, dest)
>       call PMPI_SEND (buf, count, datatype, dest, tag, comm, ierr)
>       call trace_printf_fortran (FN_MPI_SEND, 1, count, datatype, dest)
>       return
>       end
>
> where trace_printf_fortran is a C (not Fortran) function that takes a
> function number (not a name) as its first argument, but otherwise
> works like trace_printf_c above. (It treats its arguments as pointers
> to the values, not the values themselves.) (I'm also not sure what
> happens if "buf" is not an integer.)
>
> But:
>
> 1) I'd rather write the profiling function in C and
> 2) I don't understand how to convert arguments from Fortran data
>    types to C data types (especially string constants) and
> 3) I don't understand how to deal with the return value and
> 4) I don't understand how the function names change (upper and lower
>    case and underscores) within the wrapper functions.
>
> Ideally I would like not to have to write too much duplicate code to
> get the library to work with both C and Fortran.
>
> I can't seem to find documentation of this anywhere, including in the
> mvapich source code (but I don't really know where to look in the
> source code). I realize some of these issues aren't mvapich issues,
> but I need to start somewhere.
>
> Thanks, Paul
>
> --
> Paul Howard
> Chief Scientist, Microway, Inc.
>
>
>



-- 
Sayantan Sur

Research Scientist
Department of Computer Science
The Ohio State University.



More information about the mvapich-discuss mailing list