Skip to content

Commit

Permalink
Add GPTLpr_summary_file function
Browse files Browse the repository at this point in the history
  • Loading branch information
jedwards4b committed Oct 24, 2014
1 parent 541acc0 commit 2f0fe29
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 11 deletions.
35 changes: 35 additions & 0 deletions f_wrappers.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#define gptlpr gptlpr_
#define gptlpr_file gptlpr_file_
#define gptlpr_summary gptlpr_summary_
#define gptlpr_summary_file gptlpr_summary_file_
#define gptlbarrier gptlbarrier_
#define gptlreset gptlreset_
#define gptlstamp gptlstamp_
Expand Down Expand Up @@ -57,6 +58,7 @@
#define gptlpr gptlpr_
#define gptlpr_file gptlpr_file__
#define gptlpr_summary gptlpr_summary__
#define gptlpr_summary_file gptlpr_summary_file__
#define gptlbarrier gptlbarrier_
#define gptlreset gptlreset_
#define gptlstamp gptlstamp_
Expand Down Expand Up @@ -94,9 +96,11 @@ int gptlpr (int *procid);
int gptlpr_file (char *file, int nc1);
#ifdef HAVE_MPI
int gptlpr_summary (int *fcomm);
int gptlpr_summary_file (int *fcomm, char *name, int nc1);
int gptlbarrier (int *fcomm, char *name, int nc1);
#else
int gptlpr_summary (void);
int gptlpr_summary_file (char *name, int nc1);
int gptlbarrier (void);
#endif
int gptlreset (void);
Expand Down Expand Up @@ -176,6 +180,25 @@ int gptlpr_summary (int *fcomm)
return GPTLpr_summary (ccomm);
}

int gptlpr_summary_file (int *fcomm, char *outfile, int nc1)
{
MPI_Comm ccomm;
char cname[MAX_CHARS+1];
int numchars;

numchars = MIN (nc1, MAX_CHARS);
strncpy (cname, outfile, numchars);
cname[numchars] = '\0';

#ifdef HAVE_COMM_F2C
ccomm = MPI_Comm_f2c (*fcomm);
#else
/* Punt and try just casting the Fortran communicator */
ccomm = (MPI_Comm) *fcomm;
#endif
return GPTLpr_summary_file (ccomm, cname);
}

int gptlbarrier (int *fcomm, char *name, int nc1)
{
MPI_Comm ccomm;
Expand All @@ -201,6 +224,18 @@ int gptlpr_summary (void)
return GPTLpr_summary ();
}

int gptlpr_summary_file (char *outfile, int nc1)
{
char cname[MAX_CHARS+1];
int numchars;

numchars = MIN (nc1, MAX_CHARS);
strncpy (cname, outfile, numchars);
cname[numchars] = '\0';

return GPTLpr_summary_file (cname);
}

int gptlbarrier (void)
{
return GPTLerror ("gptlbarrier: Need to build GPTL with #define HAVE_MPI to enable this routine\n");
Expand Down
16 changes: 10 additions & 6 deletions gptl.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,16 @@ extern int GPTLstamp (double *, double *, double *);
extern int GPTLpr (const int);
extern int GPTLpr_file (const char *);

/*
** Use K&R prototype for these 2 because they require MPI
*/
extern int GPTLpr_summary ();
extern int GPTLbarrier ();

#ifdef HAVE_MPI
#include <mpi.h>
extern int GPTLpr_summary (MPI_Comm c);
extern int GPTLpr_summary_file (MPI_Comm c, const char *);
extern int GPTLbarrier (MPI_Comm c, const char *);
#else
extern int GPTLpr_summary ();
extern int GPTLpr_summary_file (const char *);
extern int GPTLbarrier ();
#endif
extern int GPTLreset (void);
extern int GPTLfinalize (void);
extern int GPTLget_memusage (int *, int *, int *, int *, int *);
Expand Down
9 changes: 9 additions & 0 deletions gptlf.F90
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ integer function gptlpr_summary (fcomm)
integer :: fcomm
end function gptlpr_summary

integer function gptlpr_summary_file (fcomm, name)
integer :: fcomm
character(len=*) :: name
end function gptlpr_summary_file

integer function gptlbarrier (fcomm, name)
integer :: fcomm
character(len=*) :: name
Expand All @@ -87,6 +92,10 @@ end function gptlbarrier
integer function gptlpr_summary ()
end function gptlpr_summary

integer function gptlpr_summary_file ( name)
character(len=*) :: name
end function gptlpr_summary_file

integer function gptlbarrier ()
end function gptlbarrier
#endif
Expand Down
23 changes: 18 additions & 5 deletions pr_summary.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,8 @@ static int nthreads; /* Used by both GPTLpr_summary() and get_threadstats() */
*/

#ifdef HAVE_MPI
#include <mpi.h>

int GPTLpr_summary (MPI_Comm comm) /* communicator */
int GPTLpr_summary_file (MPI_Comm comm, const char *outfile) /* communicator */
{
int ret; /* return code */
int iam; /* my rank */
Expand Down Expand Up @@ -76,7 +75,6 @@ int GPTLpr_summary (MPI_Comm comm) /* communicator */
float sigma; /* st. dev. */
unsigned int tsksum; /* part of Chan, et. al. equation */
static const int tag = 98789; /* tag for MPI message */
static const char *outfile = "timing.summary"; /* file to write to */
static const int nbytes = sizeof (Global); /* number of bytes to be sent/recvd */
static const char *thisfunc = "GPTLpr_summary"; /* this function */
FILE *fp = 0; /* file handle to write to */
Expand Down Expand Up @@ -360,12 +358,18 @@ int GPTLpr_summary (MPI_Comm comm) /* communicator */
return 0;
}

int GPTLpr_summary (MPI_Comm comm) /* communicator */
{
static const char *outfile = "timing.summary"; /* file to write to */

return GPTLpr_summary_file(comm, outfile);
}

#else

/* No MPI. Mimic MPI version but for only one rank */
int GPTLpr_summary ()
int GPTLpr_summary (const char outfile[])
{
static const char *outfile = "timing.summary"; /* file to write to */
FILE *fp = 0; /* file handle */
Timer **timers;
int multithread; /* flag indicates multithreaded or not */
Expand Down Expand Up @@ -472,8 +476,17 @@ int GPTLpr_summary ()
return 0;
}

int GPTLpr_summary () /* communicator */
{
static const char *outfile = "timing.summary"; /* file to write to */

return GPTLpr_summary_file(outfile);
}

#endif /* False branch of HAVE_MPI */



/*
** get_threadstats: gather stats for timer "name" over all threads
**
Expand Down

0 comments on commit 2f0fe29

Please sign in to comment.