Skip to content

Commit 9438edd

Browse files
oehmkebena-nasa
authored andcommitted
Add ability to get information about specific types of profiling.
1 parent 1b012db commit 9438edd

File tree

3 files changed

+60
-3
lines changed

3 files changed

+60
-3
lines changed

src/Infrastructure/Trace/include/ESMCI_Trace.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,11 @@ namespace ESMCI {
8989
void TraceTest_GetMPIWaitStats(int *count, long long *time);
9090
void TraceTest_CheckMPIRegion(std::string name, int *exists);
9191
//////////////////////////////
92-
92+
93+
// Trace by specific type info
94+
enum ESMC_ProfileType {ESMC_PROFILETYPE_REGRID=0, ESMC_PROFILETYPE_NUM};
95+
96+
9397

9498
////////////////////////////////
9599

@@ -109,6 +113,8 @@ namespace ESMCI {
109113
void TraceEventClock(int *ep_year, int *ep_month, int *ep_day,
110114
int *ep_hour, int *ep_minute, int *ep_second);
111115

116+
int TraceGetProfileTypeInfo(enum ESMC_ProfileType type);
117+
112118
}
113119

114120
#endif

src/Infrastructure/Trace/src/ESMCI_Trace.C

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ namespace ESMCI {
9999
static bool profileOutputToBinary = false; // output to binary trace?
100100
static bool profileOutputSummary = false; // output aggregate profile on root PET?
101101

102+
// Profile information by type
103+
static int ProfileTypeInfo[ESMC_PROFILETYPE_NUM];
104+
102105
static bool profileLocalPetThread(){
103106
return (profileLocalPet && VM::isThreadKnown());
104107
}
@@ -451,6 +454,35 @@ namespace ESMCI {
451454
#endif
452455
}
453456

457+
static void SetProfileTypeInfoFromEnv() {
458+
459+
// Init to 0
460+
for (int i=0; i<ESMC_PROFILETYPE_NUM; i++) {
461+
ProfileTypeInfo[i]=0;
462+
}
463+
464+
// Check for environment variable and set based on that
465+
// These will probably be fairly specific to the type, so for now
466+
// not trying to do anything automatic across different types
467+
468+
// NOTE: You need to set up the env variable in ESMCI_VM.C before it'll work here
469+
470+
// Set ESMF_ProfileType_Regrid
471+
char const *envRegridChar = VM::getenv("ESMF_RUNTIME_PROFILE_REGRID");
472+
if (envRegridChar != NULL && strlen(envRegridChar) > 0) {
473+
474+
// Get regrid info from string
475+
int info;
476+
if (envRegridChar[0] == '1') info=1;
477+
else if (envRegridChar[0] == '2') info=2;
478+
else if (envRegridChar[0] == '3') info=3;
479+
480+
// Set in profile info array
481+
ProfileTypeInfo[ESMC_PROFILETYPE_REGRID] = info;
482+
}
483+
}
484+
485+
454486
#undef ESMC_METHOD
455487
#define ESMC_METHOD "ESMCI::TraceOpen()"
456488
void TraceOpen(std::string trace_dir, int *profileToLog, int *rc) {
@@ -464,7 +496,7 @@ namespace ESMCI {
464496
if (ESMC_LogDefault.MsgFoundError(localrc,
465497
ESMCI_ERR_PASSTHRU, ESMC_CONTEXT, rc))
466498
return;
467-
499+
468500
//determine if tracing is turned on for this PET
469501
traceLocalPet = TraceIsEnabledForPET(globalvm->getLocalPet(), &localrc);
470502
if (ESMC_LogDefault.MsgFoundError(localrc,
@@ -473,6 +505,7 @@ namespace ESMCI {
473505
return;
474506
}
475507

508+
476509
//determine if profiling is turned on for this PET
477510
//if tracing is enabled, automatically turn on profiling
478511
profileLocalPet = traceLocalPet || ProfileIsEnabledForPET(globalvm->getLocalPet(), &localrc);
@@ -481,7 +514,7 @@ namespace ESMCI {
481514
profileLocalPet = false;
482515
return;
483516
}
484-
517+
485518
//determine output method for profiling, if enabled
486519
if (profileLocalPetThread()) {
487520
//always output binary if tracing is enabled
@@ -530,6 +563,9 @@ namespace ESMCI {
530563
ESMC_LogDefault.Write("ESMF Profiling Enabled", ESMC_LOGMSG_INFO);
531564
}
532565

566+
// Set other profile information
567+
SetProfileTypeInfoFromEnv();
568+
533569
// initialize the clock
534570
struct esmftrc_platform_filesys_ctx *ctx;
535571
if (traceLocalPet || profileLocalPetThread()) {
@@ -1240,6 +1276,7 @@ namespace ESMCI {
12401276
}
12411277

12421278

1279+
12431280

12441281
#undef ESMC_METHOD
12451282
#define ESMC_METHOD "ESMCI::TraceClose()"
@@ -1329,6 +1366,13 @@ namespace ESMCI {
13291366
}
13301367

13311368

1369+
1370+
#undef ESMC_METHOD
1371+
#define ESMC_METHOD "ESMCI::TraceGetProfileTypeInfo()"
1372+
int TraceGetProfileTypeInfo(enum ESMC_ProfileType type) {
1373+
return ProfileTypeInfo[type];
1374+
}
1375+
13321376

13331377
///////////////////// I/O Tracing //////////////////
13341378

src/Infrastructure/VM/src/ESMCI_VM.C

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3370,7 +3370,14 @@ VM *VM::initialize(
33703370
esmfRuntimeEnv.push_back(esmfRuntimeVarName);
33713371
esmfRuntimeEnvValue.push_back(esmfRuntimeVarValue);
33723372
}
3373+
esmfRuntimeVarName = "ESMF_RUNTIME_PROFILE_REGRID";
3374+
esmfRuntimeVarValue = std::getenv(esmfRuntimeVarName);
3375+
if (esmfRuntimeVarValue){
3376+
esmfRuntimeEnv.push_back(esmfRuntimeVarName);
3377+
esmfRuntimeEnvValue.push_back(esmfRuntimeVarValue);
3378+
}
33733379

3380+
33743381
int count = esmfRuntimeEnv.size();
33753382
GlobalVM->broadcast(&count, sizeof(int), 0);
33763383
int *length = new int[2];

0 commit comments

Comments
 (0)