Skip to content

Commit c8c6eb5

Browse files
committed
named regions
1 parent 3fbb2ed commit c8c6eb5

5 files changed

Lines changed: 61 additions & 0 deletions

File tree

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ void ariel_output_stats() {
4141
printf("ARIEL: Request to print statistics.\n");
4242
}
4343

44+
void ariel_output_stats_begin_region(const char *name) {
45+
printf("ARIEL: Request to print statistics and begin region:%s\n", name);
46+
}
47+
48+
void ariel_output_stats_end_region(const char *name) {
49+
printf("ARIEL: Request to print statistics and end region:%s\n", name);
50+
}
51+
4452
void ariel_malloc_flag(int64_t id, int count, int level) {
4553
printf("ARIEL: flagging next %d mallocs at id %" PRId64 "\n", count, id);
4654
}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ uint64_t ariel_cycles();
4646
/* Trigger the simulation to output statistics */
4747
void ariel_output_stats();
4848

49+
/* Trigger the simulation to output statistics along with a region name.
50+
* This interface may be changed or removed in the future if named
51+
* regions are added to sst-core.
52+
*/
53+
void ariel_output_stats_begin_region(const char *name);
54+
void ariel_output_stats_end_region(const char *name);
55+
4956
/* Control which memory pool (level) the next 'count' allocations encountered should map to
5057
*
5158
*/

src/sst/elements/ariel/ariel_shmem.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ enum ArielShmemCmd_t {
5555
ARIEL_SWITCH_POOL = 110,
5656
ARIEL_NOOP = 128,
5757
ARIEL_OUTPUT_STATS = 140,
58+
ARIEL_OUTPUT_STATS_BEGIN_REGION = 141,
59+
ARIEL_OUTPUT_STATS_END_REGION = 142,
5860
ARIEL_ISSUE_RTL = 150,
5961
ARIEL_FLUSHLINE_INSTRUCTION = 154,
6062
ARIEL_FENCE_INSTRUCTION = 155,

src/sst/elements/ariel/arielcore.cc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,7 @@ bool ArielCore::refillQueue() {
412412
coreID, (uint32_t) coreQ->size(), (uint32_t) maxQLength));
413413

414414
ArielCommand ac;
415+
char *region_name;
415416
const bool avail = tunnel->readMessageNB(coreID, &ac);
416417

417418
if ( !avail ) {
@@ -427,6 +428,17 @@ bool ArielCore::refillQueue() {
427428
fprintf(stdout, "Performing statistics output at simulation time = %" PRIu64 " cycles\n", getCurrentSimTimeNano());
428429
performGlobalStatisticOutput();
429430
break;
431+
case ARIEL_OUTPUT_STATS_BEGIN_REGION:
432+
region_name = (char*)ac.inst.payload;
433+
fprintf(stdout, "ARIEL_REGION_BEGIN %s %" PRIu64 "\n", region_name, getCurrentSimTime(getCoreTimeBase().toString()));
434+
performGlobalStatisticOutput();
435+
break;
436+
437+
case ARIEL_OUTPUT_STATS_END_REGION:
438+
region_name = (char*)ac.inst.payload;
439+
fprintf(stdout, "ARIEL_REGION_END %s %" PRIu64 "\n", region_name, getCurrentSimTime(getCoreTimeBase().toString()));
440+
performGlobalStatisticOutput();
441+
break;
430442

431443
case ARIEL_START_INSTRUCTION:
432444
if(ARIEL_INST_SP_FP == ac.inst.instClass) {

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

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -889,6 +889,28 @@ void mapped_ariel_output_stats()
889889
tunnel->writeMessage(remap_id[thr], ac);
890890
}
891891

892+
void mapped_ariel_output_stats_begin_region(const char* name)
893+
{
894+
THREADID thr = PIN_ThreadId();
895+
ArielCommand ac;
896+
ac.command = ARIEL_OUTPUT_STATS_BEGIN_REGION;
897+
ac.instPtr = (uint64_t) 0;
898+
strncpy((char*)ac.inst.payload, name, ARIEL_MAX_PAYLOAD_SIZE - 1);
899+
ac.inst.payload[ARIEL_MAX_PAYLOAD_SIZE-1]='\0';
900+
tunnel->writeMessage(remap_id[thr], ac);
901+
}
902+
void mapped_ariel_output_stats_end_region(const char* name)
903+
904+
{
905+
THREADID thr = PIN_ThreadId();
906+
ArielCommand ac;
907+
ac.command = ARIEL_OUTPUT_STATS_END_REGION;
908+
ac.instPtr = (uint64_t) 0;
909+
strncpy((char*)ac.inst.payload, name, ARIEL_MAX_PAYLOAD_SIZE - 1);
910+
ac.inst.payload[ARIEL_MAX_PAYLOAD_SIZE-1]='\0';
911+
tunnel->writeMessage(remap_id[thr], ac);
912+
}
913+
892914
// same effect as mapped_ariel_output_stats(), but it also sends a user-defined reference number back
893915
void mapped_ariel_output_stats_buoy(uint64_t marker)
894916
{
@@ -1401,6 +1423,16 @@ VOID InstrumentRoutine(RTN rtn, VOID* args)
14011423
RTN_Replace(rtn, (AFUNPTR) mapped_ariel_output_stats);
14021424
fprintf(stderr, "Replacement complete\n");
14031425
return;
1426+
} else if (RTN_Name(rtn) == "ariel_output_stats_begin_region" || RTN_Name(rtn) == "_ariel_output_stats_begin_region" || RTN_Name(rtn) == "__arielfort_MOD_ariel_output_stats_begin_region") {
1427+
fprintf(stderr, "Identified routine: ariel_output_stats_begin_region, replacing with Ariel equivalent..\n");
1428+
RTN_Replace(rtn, (AFUNPTR) mapped_ariel_output_stats_begin_region);
1429+
fprintf(stderr, "Replacement complete\n");
1430+
return;
1431+
} else if (RTN_Name(rtn) == "ariel_output_stats_end_region" || RTN_Name(rtn) == "_ariel_output_stats_end_region" || RTN_Name(rtn) == "__arielfort_MOD_ariel_output_stats_end_region") {
1432+
fprintf(stderr, "Identified routine: ariel_output_stats_end_region, replacing with Ariel equivalent..\n");
1433+
RTN_Replace(rtn, (AFUNPTR) mapped_ariel_output_stats_end_region);
1434+
fprintf(stderr, "Replacement complete\n");
1435+
return;
14041436
} else if (RTN_Name(rtn) == "ariel_output_stats_buoy" || RTN_Name(rtn) == "_ariel_output_stats_buoy") {
14051437
fprintf(stderr, "Identified routine: ariel_output_stats_buoy, replacing with Ariel equivalent..\n");
14061438
RTN_Replace(rtn, (AFUNPTR) mapped_ariel_output_stats_buoy);

0 commit comments

Comments
 (0)