summaryrefslogtreecommitdiffstats
path: root/pablo/PabloHDF_RT.c
diff options
context:
space:
mode:
authorDan Wells <dwells@cs.uiuc.edu>2002-04-22 18:14:00 (GMT)
committerDan Wells <dwells@cs.uiuc.edu>2002-04-22 18:14:00 (GMT)
commitb60521774f32a8ce04189e2176f162e7e9608f23 (patch)
tree4d396f2381c011674c4581053f9cf30bee46be4c /pablo/PabloHDF_RT.c
parente5fc40662c6520edc50c7e68c96e24eb766972f2 (diff)
downloadhdf5-b60521774f32a8ce04189e2176f162e7e9608f23.zip
hdf5-b60521774f32a8ce04189e2176f162e7e9608f23.tar.gz
hdf5-b60521774f32a8ce04189e2176f162e7e9608f23.tar.bz2
[svn-r5220]
Purpose: Bug Fix Description: Users could not trace MPI programs when library wasn't compiled for parallel execution Solution: Allow Pablo Trace library to set the processor number and generate the filenames for each processor. Platforms tested: Sun Workstation, HP VClass, Irix 64
Diffstat (limited to 'pablo/PabloHDF_RT.c')
-rw-r--r--pablo/PabloHDF_RT.c367
1 files changed, 175 insertions, 192 deletions
diff --git a/pablo/PabloHDF_RT.c b/pablo/PabloHDF_RT.c
index c1289a4..d15c47b 100644
--- a/pablo/PabloHDF_RT.c
+++ b/pablo/PabloHDF_RT.c
@@ -143,7 +143,7 @@
#include "HDFrecord_RT.h"
-#ifdef H5_HAVE_PARALLEL
+#ifdef H5_HAVE_MPIOTRACE
#include "mpi.h"
#include "MPIO_EventArgs.h"
#endif
@@ -184,7 +184,7 @@ fileRec_t *HDFfileList;
// Internal Function prototypes *
//======================================================================*/
void HDFinitTrace_RT( char *, int );
-void HDFendTrace_RT( int );
+void HDFendTrace_RT();
int initproctracert_( void );
int initHDFProcTrace_RT( void );
void HDFtraceEvent_RT( int , char *, unsigned ) ;
@@ -223,51 +223,32 @@ extern char HDFprocNames[][40];
// NAME *
// HDFinitTrace_RT-- initialize HDF real-time tracing *
// USAGE *
-// VOID HDFinitTrace_RT( fileName, OUTSW ) *
+// VOID HDFinitTrace_RT( fileName ) *
// *
// char *fileName; IN: name of output file *
-// int OUTSW ; IN: Type of tracing *
// RETURNS *
// None. *
//======================================================================*/
void HDFinitTrace_RT( char *fileName, int OUTSW )
{
-#ifdef H5_HAVE_PARALLEL
- int myNode;
-#endif
- int error;
- TRgetClock( &epoch );
- error = initHDFProcTrace_RT() ;
- if ( error != SUCCESS ) {
- fprintf (stderr,"Unable to Initialize properly. Exiting program\n");
- exit(-1);
- }
- FileName = ( char * ) malloc ( strlen( fileName ) + 10 );
-#ifdef H5_HAVE_PARALLEL
- /*==============================================================*
- // Here the library was built to linked with the MPI and MPIO *
- // libraries. However, the use may chose not to run with MPI. *
- // A check is made to see if MPI has been initialized. If so, *
- // a trace file is assigned to the current node with the number *
- // of the node as a suffix; if not, only one file is opened *
- // and it is not given a suffix. *
- //==============================================================*/
- if ( OUTSW == MPI_SUMMARY_TRACE ) {
- MPI_Comm_rank( MPI_COMM_WORLD, &myNode );
- setTraceProcessorNumber( myNode );
- sprintf(FileName,"%s.nd%d",fileName,myNode);
- } else {
- strcpy( FileName, fileName ) ;
- }
-#else
- /*==============================================================*
- case, set the trace file name and *
- // initialize the trace library. *
- //==============================================================*/
- strcpy( FileName, fileName ) ;
-#endif /* H5_HAVE_PARALLEL */
- setTraceFileName(FileName);
- basicLibraryInit( );
+ int error;
+ TRgetClock( &epoch );
+ error = initHDFProcTrace_RT() ;
+ if ( error != SUCCESS )
+ {
+ fprintf (stderr,"Unable to Initialize properly. Exiting program\n");
+ exit(-1);
+ }
+ FileName = ( char * ) malloc ( strlen( fileName ) + 10 );
+ /*===================================================================*
+ // Here the library was built to linked with the MPI and MPIO *
+ // libraries. However, the use may chose not to run with MPI. *
+ // A check is made to see if MPI has been initialized. If so, *
+ // a trace file is assigned to the current node with the number *
+ // of the node as a suffix; if not, only one file is opened *
+ // and it is not given a suffix. *
+ //===================================================================*/
+ IOtraceInit( fileName, OUTSW );
}
/*======================================================================*
// NAME *
@@ -277,37 +258,37 @@ void HDFinitTrace_RT( char *fileName, int OUTSW )
// RETURNS *
// None. *
//======================================================================*/
-void HDFendTrace_RT( int OUTSW )
+void HDFendTrace_RT( )
{
- int j, numSetIDs;
- HDFnode_t *P;
- char **Names;
+ int j, numSetIDs;
+ HDFnode_t *P;
+ char **Names;
- HDFfinalTimeStamp();
- /*==============================================================*
- // Assing pablo ids to named identifiers and tag records *
- //==============================================================*/
- HDFassignPabloIDs( &numSetIDs, &Names );
- /*==============================================================*
- // Create a file name for the File map file. *
- // Disable for now. *
- //==============================================================*/
+ HDFfinalTimeStamp();
+ /*===================================================================*
+ // Assing pablo ids to named identifiers and tag records *
+ //===================================================================*/
+ HDFassignPabloIDs( &numSetIDs, &Names );
+ /*===================================================================*
+ // Create a file name for the File map file. *
+ // Disable for now. *
+ //===================================================================*/
/* mapFile = (char *)malloc( strlen(FileName) + 4 );
- strcpy(mapFile,FileName);
- strcat(mapFile,".map"); */
- /*==============================================================*
- // print the file mappings. *
- //==============================================================*/
+ strcpy(mapFile,FileName);
+ strcat(mapFile,".map"); */
+ /*===================================================================*
+ // print the file mappings. *
+ //===================================================================*/
/* printFileMappingsRT( mapFile, Names, numSetIDs ); */
- /*==============================================================*
- // Print SDDF summary records *
- //==============================================================*/
- writeHDFRecDescrptrsRT();
- writeHDFNamePacketsRT( Names, numSetIDs );
+ /*===================================================================*
+ // Print SDDF summary records *
+ //===================================================================*/
+ writeHDFRecDescrptrsRT();
+ writeHDFNamePacketsRT( Names, numSetIDs );
for ( j = 0; j < NumHDFProcs; ++j ) {
- HDFSummarySDDF( HDFQueues[j], j );
- }
- endTracing();
+ HDFSummarySDDF( HDFQueues[j], j );
+ }
+ endTracing();
}
/*======================================================================*
// initHFDProcTrace_RT *
@@ -318,71 +299,80 @@ void HDFendTrace_RT( int OUTSW )
int initproctracert_( void )
{
- return initHDFProcTrace_RT();
+ return initHDFProcTrace_RT();
}
int initHDFProcTrace_RT( void )
-
{
- int i, j, size;
- int numProcs = NumHDFProcs;
+ int i;
+ int j;
+ int size;
+ int numProcs = NumHDFProcs;
- if ( traceProcessorNumber == -1 ) {
- traceProcessorNumber = TRgetDefaultProcessor();
- }
- /*==============================================================*
- // Initialize InitNode used for node initialization. *
- //==============================================================*/
- InitNode.ptr = NULL;
- InitNode.eventID = 0;
- InitNode.lastIOtime = zeroClock;
- InitNode.record.nCalls = 0;
- InitNode.record.lastCall = zeroClock;
- InitNode.record.incDur = zeroClock;
- InitNode.record.excDur = zeroClock;
- InitNode.record.hdfID = 0;
- InitNode.record.xRef = 0;
- for ( j = 0; j < nTallyFields; ++j ) {
+ if ( traceProcessorNumber == -1 )
+ {
+ traceProcessorNumber = TRgetDefaultProcessor();
+ }
+ /*===================================================================*
+ // Initialize InitNode used for node initialization. *
+ //===================================================================*/
+ InitNode.ptr = NULL;
+ InitNode.eventID = 0;
+ InitNode.lastIOtime = zeroClock;
+ InitNode.record.nCalls = 0;
+ InitNode.record.lastCall = zeroClock;
+ InitNode.record.incDur = zeroClock;
+ InitNode.record.excDur = zeroClock;
+ InitNode.record.hdfID = 0;
+ InitNode.record.xRef = 0;
+ for ( j = 0; j < nTallyFields; ++j )
+ {
InitNode.record.times[j] = zeroClock;
- }
- for ( j = 0; j < nTallyFields; ++j ) {
+ }
+ for ( j = 0; j < nTallyFields; ++j )
+ {
InitNode.record.counts[j] = 0;
- }
- for ( j = 0; j < nByteFields; ++j ) {
+ }
+ for ( j = 0; j < nByteFields; ++j )
+ {
InitNode.record.bytes[j] = 0;
- }
- for ( i = 0; i < nByteFields; ++i ) {
- for ( j = 0; j < nBkts; ++j ) {
- InitNode.record.Hists[i][j] = 0;
- }
- }
- /*==============================================================*
- // initialize linked list used to keep track of named hdf *
- // identifiers. *
- //==============================================================*/
- HDFfileList = NULL;
- /*==============================================================*
- // Allocate a one dimensional array of pointers to queues of *
- // HDFnodes. There is one queue for each thread and one for *
- // each HDF procedure. Each queue will be a list of summary *
- // records distinquished by file type and *
- //==============================================================*/
- size = (int)(numProcs*sizeof( HDFnode_t * ));
- HDFQueues = (HDFnode_t **)malloc( size );
- if ( HDFQueues == NULL ) {
- fprintf(stderr,"Failed to allocate HDFQueues in initHDFProcTrace\n");
- return FAILURE;
- }
- for ( j = 0; j < numProcs; ++j ) {
- HDFQueues[j] = NULL;
- }
- /*==============================================================*
- // Initialize call stack to a dummy node and TagQueue to NULL *
- //==============================================================*/
- CallStack = (HDFnode_t *)malloc( sizeof(HDFnode_t) );
- *CallStack = InitNode;
- TagQueue = NULL ;
- return SUCCESS;
+ }
+ for ( i = 0; i < nByteFields; ++i )
+ {
+ for ( j = 0; j < nBkts; ++j )
+ {
+ InitNode.record.Hists[i][j] = 0;
+ }
+ }
+ /*===================================================================*
+ // initialize linked list used to keep track of named hdf *
+ // identifiers. *
+ //===================================================================*/
+ HDFfileList = NULL;
+ /*===================================================================*
+ // Allocate a one dimensional array of pointers to queues of *
+ // HDFnodes. There is one queue for each thread and one for *
+ // each HDF procedure. Each queue will be a list of summary *
+ // records distinquished by file type and *
+ //===================================================================*/
+ size = (int)(numProcs*sizeof( HDFnode_t * ));
+ HDFQueues = (HDFnode_t **)malloc( size );
+ if ( HDFQueues == NULL )
+ {
+ fprintf(stderr,"Failed to allocate HDFQueues in initHDFProcTrace\n");
+ return FAILURE;
+ }
+ for ( j = 0; j < numProcs; ++j )
+ {
+ HDFQueues[j] = NULL;
+ }
+ /*===================================================================*
+ // Initialize call stack to a dummy node and TagQueue to NULL *
+ //===================================================================*/
+ CallStack = (HDFnode_t *)malloc( sizeof(HDFnode_t) );
+ *CallStack = InitNode;
+ TagQueue = NULL ;
+ return SUCCESS;
}
/*======================================================================*
// This is called from the HDF and I/O routines when real-time summary *
@@ -411,7 +401,7 @@ void HDFtraceEvent_RT( int eventType, char *dataPtr, unsigned dataLen )
else if ( isEndHDFEvent( eventType ) )
{
EndHDFEventRecord ( seconds, dataPtr );
-#ifdef H5_HAVE_PARALLEL
+#ifdef H5_HAVE_MPIOTRACE
}
else if ( isBeginMPIOEvent( eventType ) )
{
@@ -420,7 +410,7 @@ void HDFtraceEvent_RT( int eventType, char *dataPtr, unsigned dataLen )
else if ( isEndMPIOEvent( eventType ) )
{
EndMPIOEventRecord ( eventType, seconds, dataPtr, dataLen );
-#endif /* H5_HAVE_PARALLEL */
+#endif /* H5_HAVE_MPIOTRACE */
}
else
{
@@ -529,7 +519,7 @@ void EndIOEventRecord ( int eventType, CLOCK secs, void *dataPtr )
}
}
-#ifdef H5_HAVE_PARALLEL
+#ifdef H5_HAVE_MPIOTRACE
/*======================================================================*
// BeginMPIOEventRecord: *
// This routine simply records the time in the record on the top of *
@@ -542,18 +532,18 @@ void BeginMPIOEventRecord( int eventType,
{
HDFsetInfo *dataPtr;
dataPtr = (HDFsetInfo *)data;
- /*==============================================================*
- // save the time value temporarily in top of stack *
- // When the end record is received, the duration can be *
- // computed. *
- //==============================================================*/
+ /*===================================================================*
+ // save the time value temporarily in top of stack *
+ // When the end record is received, the duration can be *
+ // computed. *
+ //===================================================================*/
CallStack->lastIOtime = seconds;
- /*==============================================================*
- // get useful info from the structure pointed to by dataPtr. *
- cases, this is the file ID. For mpiOpen, it is the *
+ /*===================================================================*
+ // get useful info from the structure pointed to by dataPtr. *
+ // Form most cases, this is the file ID. For mpiOpen, it is the *
// name of the file. For mpiDelete, no information is of any *
// use. *
- //==============================================================*/
+ //===================================================================*/
if ( dataLen == 0 ) return;
CallStack->record.hdfID = dataPtr->setID;
switch ( eventType )
@@ -766,7 +756,7 @@ void EndMPIOEventRecord ( int eventType,
}
}
}
-#endif /* H5_HAVE_PARALLEL */
+#endif /* H5_HAVE_MPIOTRACE */
/*======================================================================*
// BeginHDFEventRecord: *
// This function puts a trace record on the stack corresponding to *
@@ -1087,17 +1077,18 @@ void HDFSummarySDDF( HDFnode_t *P, int procIndex )
char buff[1024];
char *Packet;
HDFnode_t *Q;
- struct {
- int packetLen,
- packetType,
- packetTag,
- eventID;
- double Seconds,
- IncDur,
- ExcDur;
- long HDFid,
- XREFid;
- } Header;
+ struct
+ {
+ int packetLen;
+ int packetType;
+ int packetTag;
+ int eventID;
+ double Seconds;
+ double IncDur;
+ double ExcDur;
+ long HDFid;
+ long XREFid;
+ } Header;
Header.packetLen = sizeof(Header)
+ sizeof(int) /* n Calls */
@@ -1109,8 +1100,7 @@ void HDFSummarySDDF( HDFnode_t *P, int procIndex )
+ nByteFields*sizeof(int) /* bytes array */
+ nHistFields*sizeof(int) /* array lens */
+ nHistFields*nBkts*sizeof(int) /* byte hist */
- + sizeof(int) /* nodeID */
- + sizeof(int) ; /* Name len */
+ + sizeof(int); /* nodeID */
Header.packetTag = HDF_SUMMARY_FAMILY +
( procIndex + 1 )*8 + RECORD_TRACE ;
Header.packetType = PKT_DATA;
@@ -1186,7 +1176,8 @@ void HDFSummarySDDF( HDFnode_t *P, int procIndex )
// copy length of historgram arrays and arrays to Packet. *
//===========================================================*/
arrayLen = nBkts;
- for ( i = 0; i < nByteFields; ++i ) {
+ for ( i = 0; i < nHistFields; ++i )
+ {
memcpy( Packet, &arrayLen, sizeof(int) );
Packet += sizeof(int);
memcpy( Packet, P->record.Hists[i], nBkts*sizeof(int) );
@@ -1194,9 +1185,9 @@ void HDFSummarySDDF( HDFnode_t *P, int procIndex )
}
memcpy( Packet, &nodeID, sizeof(int) );
Packet += sizeof(int);
- arrayLen = 0; /* name length */
- memcpy( Packet, &arrayLen, sizeof(int) );
- putBytes( buff, Header.packetLen );
+ arrayLen = Packet-buff;
+ memcpy(buff,&arrayLen,sizeof(int));
+ putBytes( buff, Packet-buff );
P = Q;
}
}
@@ -1205,7 +1196,7 @@ void HDFSummarySDDF( HDFnode_t *P, int procIndex )
//======================================================================*/
void HDFnodeInit ( HDFnode_t *S )
{
- *S = InitNode;
+ *S = InitNode;
}
/*======================================================================*
// Compute IO totals, exclusive durations of the input record T *
@@ -1213,27 +1204,34 @@ void HDFnodeInit ( HDFnode_t *S )
//======================================================================*/
void HDFrecordSum ( HDFrec_t *S, HDFrec_t *T )
{
- int i, j;
+ int i;
+ int j;
- S->nCalls += T->nCalls;
- if ( clockCompare ( S->lastCall, T->lastCall ) < 0 ) {
- S->lastCall = T->lastCall ;
- }
- S->incDur = clockAdd ( S->incDur, T->incDur );
- for ( j = 0; j < nTallyFields; ++j ) {
- S->times[j] = clockAdd( S->times[j] , T->times[j] ) ;
- }
- for ( j = 0; j < nTallyFields; ++j ) {
- S->counts[j] += T->counts[j] ;
- }
- for ( j = 0; j < nByteFields; ++j ) {
- S->bytes[j] += T->bytes[j] ;
- }
- for ( j = 0; j < nHistFields; ++j ) {
- for ( i = 0; i < nBkts; ++i ) {
- S->Hists[j][i] += T->Hists[j][i] ;
- }
- }
+ S->nCalls += T->nCalls;
+ if ( clockCompare ( S->lastCall, T->lastCall ) < 0 )
+ {
+ S->lastCall = T->lastCall ;
+ }
+ S->incDur = clockAdd ( S->incDur, T->incDur );
+ for ( j = 0; j < nTallyFields; ++j )
+ {
+ S->times[j] = clockAdd( S->times[j] , T->times[j] ) ;
+ }
+ for ( j = 0; j < nTallyFields; ++j )
+ {
+ S->counts[j] += T->counts[j] ;
+ }
+ for ( j = 0; j < nByteFields; ++j )
+ {
+ S->bytes[j] += T->bytes[j] ;
+ }
+ for ( j = 0; j < nHistFields; ++j )
+ {
+ for ( i = 0; i < nBkts; ++i )
+ {
+ S->Hists[j][i] += T->Hists[j][i] ;
+ }
+ }
}
/*======================================================================*
// Return the field index corresponding to an IO event ID. The fields *
@@ -1498,7 +1496,7 @@ void _hdfDescriptorRT( char *recordName, char *recordDescription,
/*==================================================================*
// The record field count *
//==================================================================*/
- sddfWriteInteger( &hdfRecordPointer, 17 );
+ sddfWriteInteger( &hdfRecordPointer, 16 );
WRITE_HDF_FIELD( "Event Identifier",
"Event ID",
"Corresponding Event",
@@ -1563,10 +1561,6 @@ void _hdfDescriptorRT( char *recordName, char *recordDescription,
"Node",
"Processor number",
INTEGER, 0 );
- WRITE_HDF_FIELD( "HDF Name",
- "HDF Name",
- "Name of File,Data Set or Dim accessed",
- CHARACTER, 1 );
/*===================================================================
// The entire record descriptor packet has been written. *
// Compute and update the record length. *
@@ -1586,17 +1580,6 @@ void _hdfDescriptorRT( char *recordName, char *recordDescription,
//======================================================================*/
void writeHDFRecDescrptrsRT( void )
{
-/*
- char HDFprocNames[][40] = {
- "noName",
- "noName",
- "noName",
- "noName",
- "noName",
-# include "HDFentryNames.h"
- "HDF_Last_Entry"
- };
-*/
int j, FAMILY;
char BUF1[256], BUF2[256] ;
_hdfNameDescriptor(); /* Descriptor for named identifiers */
@@ -1646,10 +1629,10 @@ void _hdfNameDescriptor( void )
static char recordBuffer[ 4096 ];
int recordLength;
-#ifdef DEBUG
+#ifdef PABLODEBUG
fprintf( debugFile, "_hdfExitTraceDescriptor entered\n" );
fflush( debugFile );
-#endif /* DEBUG */
+#endif /* PABLODEBUG */
hdfRecordPointer = recordBuffer;
/********************************************************************/
/* Allow space at the beginning of the record for the packet */