Skip to content

Commit 906150c

Browse files
committed
add perf region hooks to Ariel API
1 parent 11b43cf commit 906150c

3 files changed

Lines changed: 59 additions & 1 deletion

File tree

src/sst/elements/ariel/api/arielapi.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,11 @@ int MPI_Init_thread(int *argc, char ***argv, int required, int *provided) {
103103
exit(1);
104104
#endif
105105
}
106+
107+
void ariel_region_begin(char* region_name) {
108+
printf("ARIEL: ariel_region_begin called in Ariel API.\n");
109+
}
110+
111+
void ariel_region_end(char* region_name) {
112+
printf("ARIEL: ariel_region_end called in Ariel API.\n");
113+
}

src/sst/elements/ariel/api/arielapi.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,18 @@ void ariel_output_stats();
5151
*/
5252
void ariel_malloc_flag(int64_t id, int count, int level);
5353

54+
/* Signal to the SST Statistics system that we are entering a profiling region.
55+
* NOOP for now. Hopefully this functionality will be addedin the future.
56+
* `name` will appear in the stats output.
57+
*/
58+
void ariel_region_begin(char* region_name);
59+
60+
/* Signal to the SST statistics system that we are leaving a profiling region.
61+
* NOOP for now. `name` will be used for error checking.
62+
*/
63+
void ariel_region_end(char* region_name);
64+
65+
5466
#if defined(c_plusplus) || defined(__cplusplus)
5567
}
5668
#endif

src/sst/elements/ariel/frontend/pin3/fesimple.cc

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -845,6 +845,34 @@ int check_for_api_mpi_init() {
845845
return 0;
846846
}
847847

848+
// Must only be called by one thread
849+
void mapped_ariel_region_begin(char *region_name)
850+
{
851+
return; // Not yet implemented. Potential implementation below.
852+
/*
853+
THREADID thr = PIN_ThreadId();
854+
ArielCommand ac;
855+
ac.command = ARIEL_REGION_BEGIN; // Does not exist yet
856+
strncpy(ac.region_name, region_name, ARIEL_REGION_MAX); // Need to send name somehow. Would be nice to do this without blowing up the size of ArielCommand
857+
// Maybe it makes sense to break this into three different messages, with the middle one possibly larger?
858+
tunnel->writeMessage(thr, ac);
859+
*/
860+
}
861+
862+
// Must only be called by one thread
863+
void mapped_ariel_region_end(char *region_name)
864+
{
865+
return; // Not yet implemented. Potential implementation below.
866+
/*
867+
THREADID thr = PIN_ThreadId();
868+
ArielCommand ac;
869+
ac.command = ARIEL_REGION_END; // Does not exist yet
870+
strncpy(ac.region_name, region_name, ARIEL_REGION_MAX); // Need to send name somehow. Would be nice to do this without blowing up the size of ArielCommand
871+
// Maybe it makes sense to break this into three different messages, with the middle one possibly larger?
872+
tunnel->writeMessage(thr, ac);
873+
*/
874+
}
875+
848876
int ariel_mlm_memcpy(void* dest, void* source, size_t size) {
849877
#ifdef ARIEL_DEBUG
850878
fprintf(stderr, "Perform a mlm_memcpy from Ariel from %p to %p length %llu\n",
@@ -1252,12 +1280,12 @@ VOID InstrumentRoutine(RTN rtn, VOID* args)
12521280
RTN_InsertCall(rtn, IPOINT_AFTER, (AFUNPTR) check_for_api_mpi_init, IARG_END);
12531281
RTN_Close(rtn);
12541282
fprintf(stderr, "Instrumentation complete\n");
1283+
return;
12551284
} else if (RTN_Name(rtn) == "api_mpi_init" || RTN_Name(rtn) == "_api_mpi_init") {
12561285
fprintf(stderr, "Replacing api_mpi_init with mapped_api_mpi_init.\n");
12571286
RTN_Replace(rtn, (AFUNPTR) mapped_api_mpi_init);
12581287
fprintf(stderr, "Replacement complete\n");
12591288
return;
1260-
return;
12611289
#if ! defined(__APPLE__)
12621290
} else if (RTN_Name(rtn) == "clock_gettime" || RTN_Name(rtn) == "_clock_gettime" ||
12631291
RTN_Name(rtn) == "__clock_gettime") {
@@ -1360,6 +1388,16 @@ VOID InstrumentRoutine(RTN rtn, VOID* args)
13601388
RTN_Replace(rtn, (AFUNPTR) mapped_ariel_malloc_flag_fortran);
13611389
return;
13621390
}
1391+
} else if (RTN_Name(rtn) == "ariel_region_begin" || RTN_Name(rtn) == "_ariel_region_begin") {
1392+
fprintf(stderr, "Identified routine: ariel_region_begin, replacing with Ariel equivalent..\n");
1393+
RTN_Replace(rtn, (AFUNPTR) mapped_ariel_region_begin);
1394+
fprintf(stderr, "Replacement complete\n");
1395+
return;
1396+
} else if (RTN_Name(rtn) == "ariel_region_end" || RTN_Name(rtn) == "_ariel_region_end") {
1397+
fprintf(stderr, "Identified routine: ariel_region_end, replacing with Ariel equivalent..\n");
1398+
RTN_Replace(rtn, (AFUNPTR) mapped_ariel_region_end);
1399+
fprintf(stderr, "Replacement complete\n");
1400+
return;
13631401
}
13641402
}
13651403

0 commit comments

Comments
 (0)