[mvapich-discuss] mvapich2 profiling interface for Fortran
Paul Howard
paulhoward at microway.com
Thu Feb 18 17:36:02 EST 2010
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.cse.ohio-state.edu/pipermail/mvapich-discuss/attachments/20100218/f691bfc2/attachment.html
More information about the mvapich-discuss
mailing list