Skip to content

Commit

Permalink
add a function to print epoch to trace
Browse files Browse the repository at this point in the history
  • Loading branch information
tim0s committed Oct 22, 2023
1 parent 94a41b7 commit 42ebecc
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
4 changes: 4 additions & 0 deletions build/mpi_c_wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ static void lap_collect_traces(void) {
free(chunkbuf);
}

void lap_write_epoch(int epoch) {
WRITE_TRACE("# epoch %i\n", epoch);
}

int MPI_Abort (MPI_Comm comm, int errorcode) {
if (lap_tracing_enabled == 0) {
int pmpi_retval; pmpi_retval = PMPI_Abort(comm, errorcode);
Expand Down
4 changes: 4 additions & 0 deletions build/mpi_f_wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,10 @@ void FortranCInterface_GLOBAL(pmpi_wtick,PMPI_WTICK) (int* ierr);
void FortranCInterface_GLOBAL(pmpi_wtime,PMPI_WTIME) (int* ierr);


void FortranCInterface_GLOBAL(lap_write_epoch,LAP_WRITE_EPOCH) (int* epoch) {
WRITE_TRACE("# epoch %i\n", *epoch);
}

void FortranCInterface_GLOBAL(mpi_abort,MPI_ABORT) (int* comm, int* errorcode, int* ierr) {
if (lap_tracing_enabled == 0) {
int pmpi_retval; FortranCInterface_GLOBAL(pmpi_abort,PMPI_ABORT)(comm, errorcode, ierr);
Expand Down
14 changes: 14 additions & 0 deletions src/liballprof2/gencode.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,18 @@ def produce_fortran_pmpi_prototypes(self):
self.outfile.write(f"void FortranCInterface_GLOBAL({pfunc.lower()},{pfunc.upper()}) ({params})"+";\n")
self.outfile.write("\n\n")

def produce_lap_util(self, mode):
ref = ""
if mode == 'fortran':
ref = "*"
pfunc = "lap_write_epoch"
params = f"int{ref} epoch"
if mode == 'fortran':
self.outfile.write(f"void FortranCInterface_GLOBAL({pfunc.lower()},{pfunc.upper()}) ({params})"+" {\n")
else:
self.outfile.write(f"void {pfunc}({params})"+" {\n")
self.outfile.write(f" WRITE_TRACE(\"# epoch %i\\n\", {ref}epoch);\n")
self.outfile.write("}\n\n")

def produce_pmpi_only_if_tracing_disabled(self, func, mode):
self.outfile.write(f" if (lap_tracing_enabled == 0) {{ \n")
Expand Down Expand Up @@ -382,6 +394,7 @@ def produce_tracers(self, mode='c'):
codegen.parse_semantics(args.semantics_file)
codegen.outfile = open(args.c_output_file, "w")
codegen.write_prolog(mode='c')
codegen.produce_lap_util(mode='c')
codegen.produce_tracers(mode='c')
codegen.outfile.close()

Expand All @@ -393,6 +406,7 @@ def produce_tracers(self, mode='c'):
codegen.outfile = open(args.fortran_output_file, "w")
codegen.write_prolog(mode='fortran')
codegen.produce_fortran_pmpi_prototypes()
codegen.produce_lap_util(mode='fortran')
codegen.produce_tracers(mode='fortran')
codegen.outfile.close()

0 comments on commit 42ebecc

Please sign in to comment.