Skip to content

Commit

Permalink
Fix the callsite report
Browse files Browse the repository at this point in the history
Use the MPI operation name as an indicator of the starting point of
a callsite.
We know that MPI_<op> is located in the wrappers.c (or maybe in another
profiler's wrapper file).
So we only output callsite starting from frames above the one, containing
MPI_<op>

Signed-off-by: Artem Polyakov <[email protected]>
  • Loading branch information
artpol84 committed Jun 27, 2019
1 parent c82c32a commit 4eda0b2
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 11 deletions.
4 changes: 3 additions & 1 deletion mpiPi.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@

#define MPIP_HELP_LIST "@PACKAGE_BUGREPORT@"

#define MPIP_CALLSITE_STACK_DEPTH (mpiPi.stackDepth)
#define MPIP_CALLSITE_STACK_INT_ADDITION 2
#define MPIP_CALLSITE_STACK_DEPTH \
(mpiPi.stackDepth + MPIP_CALLSITE_STACK_INT_ADDITION)
#define MPIP_CALLSITE_STATS_COOKIE 518641
#define MPIP_CALLSITE_STATS_COOKIE_ASSERT(f) {assert(MPIP_CALLSITE_STATS_COOKIE==((f)->cookie));}

Expand Down
36 changes: 26 additions & 10 deletions report.c
Original file line number Diff line number Diff line change
Expand Up @@ -583,38 +583,54 @@ mpiPi_print_callsites (FILE * fp)

for (i = 0; i < ac; i++)
{
int j;
for (j = 0, stack_continue_flag = 1;
int j, start_point = 0;
char *mpi_funcname = mpiPi.lookup[av[i]->op - mpiPi_BASE].name;

/* Find the starting point:
* search for the MPI operation name in the stacktrace and use it
* as the beginning of the stack.
*/
for (j = 0;
(j < MPIP_CALLSITE_STACK_DEPTH) && (av[i]->filename[j] != NULL);
j++)
{

if (strcmp (av[i]->functname[j], mpi_funcname) == 0)
{
start_point = j + 1;
}
}

for (j = start_point, stack_continue_flag = 1;
(j < MPIP_CALLSITE_STACK_DEPTH) && (av[i]->filename[j] != NULL) &&
stack_continue_flag == 1; j++)
{
int level = j - start_point;
if (av[i]->line[j] == 0 &&
(strcmp (av[i]->filename[j], "[unknown]") == 0 ||
strcmp (av[i]->functname[j], "[unknown]") == 0))
{
fprintf (fp, "%3d %3d %-*s %-*s %s\n",
av[i]->id,
j,
level,
fileLenMax + 6,
mpiP_format_address (av[i]->pc[j], addr_buf),
funcLenMax,
av[i]->functname[j],
(j ==
0) ? &(mpiPi.lookup[av[i]->op -
mpiPi_BASE].name[4]) : "");
(level == 0) ?
&(mpiPi.lookup[av[i]->op - mpiPi_BASE].name[4]) : "");
}
else
{
fprintf (fp, "%3d %3d %-*s %5d %-*s %s\n",
av[i]->id,
j,
level,
fileLenMax,
av[i]->filename[j], av[i]->line[j],
funcLenMax,
av[i]->functname[j],
(j ==
0) ? &(mpiPi.lookup[av[i]->op -
mpiPi_BASE].name[4]) : "");
(level == 0) ?
&(mpiPi.lookup[av[i]->op - mpiPi_BASE].name[4]) : "");
}
/* Do not bother printing stack frames above main */
if (strcmp (av[i]->functname[j], "main") == 0
Expand Down

0 comments on commit 4eda0b2

Please sign in to comment.