/*==============================================================*/ /* ioExampleMPI.c */ /* The following is an example of an MPI code written in C. */ /* The application opens an output file for each processor */ /* named OutFile.n where n is the processor number, writes */ /* an array of ints to the file, then closes the file. */ /*==============================================================*/ #include <stdio.h> #include <mpi.h> main(int argc, char **argv)
{
char fileName[20];
char outFile[20];
int myNode;
FILE *ptr;
int data[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
MPI_Init(&argc, &argv); MPI_Comm_rank(MPI_COMM_WORLD, &myNode); /*===========================================================*/ /* set output file name for this processor */ /*===========================================================*/ sprintf(outFile, "%s.%d\0", "OutFile", myNode); /*===========================================================*/ /* Open the file, write the data and close the file. */ /*===========================================================*/ ptr = fopen(outFile,"w"); fwrite( data, sizeof(int), 10, ptr ); fclose(ptr); MPI_Finalize(); } |
/*==============================================================*/ /* ioExampleMPI.c */ /* The following is an example of an MPI code written in C */ /* after Pablo instrumentaion. */ /* The application opens an output file for each processor */ /* named OutFile.n where n is the processor number, writes */ /* an array of ints to the file, then closes the file. */ /* A Pablo trace file named myTrace.n is created for each */ /* processor and trace data is written to it. */ /* Instrumentation is done by using the preprocessor feature. */ /*==============================================================*/ #include <stdio.h> #include <mpi.h> #define IOTRACE /* PABLO */ #include "IOTrace.h" /* PABLO */ main(int argc, char **argv)
{
char fileName[20];
char outFile[20];
int myNode;
FILE *ptr;
int data[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
MPI_Init(&argc, &argv); MPI_Comm_rank(MPI_COMM_WORLD, &myNode); /*===========================================================*/ /* set the name of the trace file to myTrace.n where n is */ /* the MPI process number. */ /*===========================================================*/ setTraceProcessorNumber( myNode ); sprintf(fileName, "myTrace.%d\0", myNode); setTraceFileName( fileName ); /*===========================================================*/ /* set the Pablo trace processor number to the current node */ /* number and initialize Pablo I/O Tracing. Initialization */ /* of Pablo tracing must be done after MPI_Init is called. */ /*===========================================================*/ initIOTrace(); /*===========================================================*/ /* set output file name for this processor */ /*===========================================================*/ sprintf(outFile, "%s.%d\0", "OutFile", myNode); /*===========================================================*/ /* Open the file, write the data and close the file. */ /*===========================================================*/ ptr = fopen(outFile,"w"); fwrite( data, sizeof(int), 10, ptr ); fclose(ptr); /*===========================================================*/ /* Terminiate Pablo Tracing. This must be done before */ /* calling MPI_Finalize. */ /*===========================================================*/ endIOTrace(); endTracing(); MPI_Finalize(); } |
Suppose the Pablo software is installed in the directory <PabloDir>.
To compile the code, use the following command:
mpicc -c ioExampleMPI.c -I<PabloDir>/include -I<mpidir>/include
To link the code, use the following command:
mpicc -o myEXE ioExampleMPI.o -L<PabloDir>/lib -lPabloTrace -lPabloTraceExt -lmpi [other libraries as necessary]
To execute the code, use the following command:
mpirun -np <nprocs> myEXE
This will produce a trace output files named myTrace.n where n is the processor number.
Click on the name below to download the binary files produced for the case <nprocs> = 2. See the Trace Output Files section below for the steps necessary to convert these files to ascii.
Before doing any further processing, the trace files should be merged and the file ids synchronized. This can be done by issuing the following commands:
MergePabloTraces -o myTraces.mrg myTraces.* SyncIOfileIDs myTraces.mrg
This will produce a tracefile myTraces.mrg.syncFiles and a map file myTraces.mrg.syncFiles.map. This last file is a mapping of file IDs to file names in the application.
Click to download the trace output file myTraces.mrg.syncFiles produced by following the steps above with nprocs equal to two (2). The file is in binary. To convert it to ASCII follow the steps in the Trace Output Files section below.
Click to dowload the map file myTraces.mrg.syncFiles.map. It is already in ASCII format.
The trace output files are in binary format and are generally best processed in that format. Sometimes it is convenient, however, to convert the file to ASCII in order to read its contents. To convert a binary trace file to ASCII, use the command SDDFconverter. The following is the session used to convert myTraces.mrg.syncFiles from a binary format to the ASCII file myTraces.mrg.syncFiles.ascii. User responses are in bold. User responses are in bold.
% SDDFconverter
Please enter name of the input SDDF file: myTraces.mrg.syncFiles
File is in SDDF Non-Native Binary format
Output in Ascii, Binary or Converted (reverse byte order) format [A, B, C]: A
Please entery name of the output SDDF file: myTraces.mrg.syncFiles.ascii
Do you want diagnostic messages printed [Y or N}: N
Issue the command IOStats myTraces.mrg.syncFiles to produce the report on the screen.
- IOStatsTable
Issue the command IOStatsTable myTraces.mrg.syncFiles to produce the report for all processors on the screen. Issue the command IOStatsTable -processor <n> myTraces.mrg.syncFiles to produce the report for processor <n> on the screen. Click to view the report for processor 0 for the case <nprocs> = 2.
- Lifetime Summary Report
Because lifetime summary data collection was not enabled within the sample insturmented code above, the SDDF files required to generate this report were not generated. Had they been enabled, a report could have been generated that would look like this example generated by an instrumented C code.
- File Region Summary
Because file region summary data collection was not enabled within the sample insturmented code above, the SDDF files required to generate this report were not generated. Had they been enabled, a report could have been generated that would look like this example generated by an instrumented C code.
- Time Window Summary
Because time window summary data collection was not enabled within the sample insturmented code above, the SDDF files required to generate this report were not generated. Had they been enabled, a report could have been generated that would look like this example generated by an instrumented C code.
- Graph