Skip to content

Commit 4eb79be

Browse files
oehmkebena-nasa
authored andcommitted
Add different levels of profiling for different regrid weight calculation parts.
1 parent 9438edd commit 4eb79be

File tree

6 files changed

+193
-93
lines changed

6 files changed

+193
-93
lines changed

src/Infrastructure/Mesh/src/ESMCI_Mesh_Regrid_Glue.C

Lines changed: 40 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "ESMCI_Array.h"
2727

2828
#include "ESMCI_TraceMacros.h" // for profiling
29+
#include "ESMCI_TraceRegion.h" // for profiling
2930

3031
#include "Mesh/include/ESMCI_Mesh.h"
3132
#include "Mesh/include/Legacy/ESMCI_MeshRead.h"
@@ -111,13 +112,19 @@ void ESMCI_regrid_create(
111112
#define ESMC_METHOD "ESMCI_regrid_create()"
112113
Trace __trace(" FTN_X(regrid_test)(ESMCI::Grid **gridsrcpp, ESMCI::Grid **griddstcpp, int*rc");
113114

114-
// Create string describing regrid case
115-
std::string ristr;
116-
create_regrid_info_str(arraysrcpp, arraydstpp, regridMethod, ristr);
115+
// Declare local return code
116+
int localrc;
117117

118-
// Trace around whole regrid create
119-
ESMCI::TraceEventRegionEnter(ristr, NULL);
120-
118+
// Enter profile around whole regrid create
119+
std::string ristr;
120+
if (TraceGetProfileTypeInfo(ESMC_PROFILETYPE_REGRID) > 0) {
121+
// Create string describing regrid case
122+
create_regrid_info_str(arraysrcpp, arraydstpp, regridMethod, ristr);
123+
124+
// Trace around whole regrid create
125+
ESMCI::TraceEventRegionEnter(ristr, &localrc);
126+
if (ESMC_LogDefault.MsgFoundError(localrc, ESMCI_ERR_PASSTHRU, ESMC_CONTEXT, rc)) return;
127+
}
121128

122129
// Dereference input variables
123130
ESMCI::Array &srcarray = **arraysrcpp;
@@ -148,9 +155,6 @@ void ESMCI_regrid_create(
148155

149156
try {
150157

151-
// Declare local return code
152-
int localrc;
153-
154158
// Initialize the parallel environment for mesh
155159
ESMCI::Par::Init("MESHLOG", false, VM::getCurrent(&localrc)->getMpi_c());
156160
if (ESMC_LogDefault.MsgFoundError(localrc,ESMCI_ERR_PASSTHRU,ESMC_CONTEXT,NULL)) throw localrc; // bail out with exception
@@ -329,11 +333,11 @@ void ESMCI_regrid_create(
329333
}
330334

331335

332-
333-
// Trace around weight generation
334-
ESMCI::TraceEventRegionEnter("Weight generation", &localrc);
335-
if (ESMC_LogDefault.MsgFoundError(localrc,ESMCI_ERR_PASSTHRU,ESMC_CONTEXT,NULL)) throw localrc;
336-
336+
// Enter profile around weight generation
337+
if (TraceGetProfileTypeInfo(ESMC_PROFILETYPE_REGRID) > 1) {
338+
ESMCI::TraceEventRegionEnter("Weight generation", &localrc);
339+
if (ESMC_LogDefault.MsgFoundError(localrc,ESMCI_ERR_PASSTHRU,ESMC_CONTEXT,NULL)) throw localrc;
340+
}
337341

338342
#ifdef PROGRESSLOG_on
339343
ESMC_LogDefault.Write("c_esmc_regrid_create(): Entering weight generation.", ESMC_LOGMSG_INFO);
@@ -397,10 +401,11 @@ void ESMCI_regrid_create(
397401
}
398402
}
399403

400-
// Trace around weight generation
401-
ESMCI::TraceEventRegionExit("Weight generation", &localrc);
402-
if (ESMC_LogDefault.MsgFoundError(localrc,ESMCI_ERR_PASSTHRU,ESMC_CONTEXT,NULL)) throw localrc;
403-
404+
// Exit profile around weight generation
405+
if (TraceGetProfileTypeInfo(ESMC_PROFILETYPE_REGRID) > 1) {
406+
ESMCI::TraceEventRegionExit("Weight generation", &localrc);
407+
if (ESMC_LogDefault.MsgFoundError(localrc,ESMCI_ERR_PASSTHRU,ESMC_CONTEXT,NULL)) throw localrc;
408+
}
404409

405410
ESMCI_REGRID_TRACE_EXIT("NativeMesh Weight Generation");
406411

@@ -643,11 +648,12 @@ void ESMCI_regrid_create(
643648

644649
// Build the RouteHandle using ArraySMMStore()
645650
if (*has_rh) {
646-
647-
// Trace around routehandle creation
648-
ESMCI::TraceEventRegionEnter("RouteHandle creation", &localrc);
649-
if (ESMC_LogDefault.MsgFoundError(localrc,ESMCI_ERR_PASSTHRU,ESMC_CONTEXT,NULL)) throw localrc;
650-
651+
652+
// Enter profile around routehandle creation
653+
if (TraceGetProfileTypeInfo(ESMC_PROFILETYPE_REGRID) > 1) {
654+
ESMCI::TraceEventRegionEnter("RouteHandle creation", &localrc);
655+
if (ESMC_LogDefault.MsgFoundError(localrc,ESMCI_ERR_PASSTHRU,ESMC_CONTEXT,NULL)) throw localrc;
656+
}
651657

652658
// Set some flags
653659
enum ESMC_TypeKind_Flag tk = ESMC_TYPEKIND_R8;
@@ -666,10 +672,11 @@ void ESMCI_regrid_create(
666672
ESMC_CONTEXT, NULL)) throw localrc; // bail out with exception
667673

668674

669-
// Trace around routehandle creation
670-
ESMCI::TraceEventRegionExit("RouteHandle creation", &localrc);
671-
if (ESMC_LogDefault.MsgFoundError(localrc,ESMCI_ERR_PASSTHRU,ESMC_CONTEXT,NULL)) throw localrc;
672-
675+
// Exit profile around routehandle creation
676+
if (TraceGetProfileTypeInfo(ESMC_PROFILETYPE_REGRID) > 1) {
677+
ESMCI::TraceEventRegionExit("RouteHandle creation", &localrc);
678+
if (ESMC_LogDefault.MsgFoundError(localrc,ESMCI_ERR_PASSTHRU,ESMC_CONTEXT,NULL)) throw localrc;
679+
}
673680
}
674681

675682
ESMCI_REGRID_TRACE_EXIT("NativeMesh ArraySMMStore");
@@ -844,8 +851,12 @@ void ESMCI_regrid_create(
844851
ESMC_LogDefault.Write("c_esmc_regrid_create(): Final return.", ESMC_LOGMSG_INFO);
845852
#endif
846853

847-
// Trace around whole regrid create
848-
ESMCI::TraceEventRegionExit(ristr, NULL);
854+
855+
// Exit profile around whole regrid create
856+
if (TraceGetProfileTypeInfo(ESMC_PROFILETYPE_REGRID) > 0) {
857+
ESMCI::TraceEventRegionExit(ristr, &localrc);
858+
if (ESMC_LogDefault.MsgFoundError(localrc, ESMCI_ERR_PASSTHRU, ESMC_CONTEXT, rc)) return;
859+
}
849860

850861
// Set return code
851862
if (rc!=NULL) *rc = ESMF_SUCCESS;

src/Infrastructure/Mesh/src/Regridding/ESMCI_Extrap.C

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
#include <Mesh/include/Legacy/ESMCI_MeshRead.h>
1515
#include <Mesh/include/Regridding/ESMCI_Interp.h>
1616
#include <Mesh/include/Regridding/ESMCI_CreepFill.h>
17+
#include "ESMCI_TraceRegion.h"
18+
1719

1820
//-----------------------------------------------------------------------------
1921
// leave the following line as-is; it will insert the cvs ident string
@@ -1021,9 +1023,20 @@ template void _merge_dst_to_dst_wts_into_src_to_dst_wts(PointList &dst, WMat &dt
10211023
int extrapNumLevels,
10221024
int extrapNumInputLevels,
10231025
bool set_dst_status, WMat &dst_status) {
1024-
1026+
#undef ESMC_METHOD
1027+
#define ESMC_METHOD "extrap()"
1028+
10251029
// printf("BOB: in extrap() extrapMethod=%d\n",extrapMethod);
10261030

1031+
// Declare local return code
1032+
int localrc;
1033+
1034+
// Enter profile for extrap
1035+
if (TraceGetProfileTypeInfo(ESMC_PROFILETYPE_REGRID) > 2) {
1036+
ESMCI::TraceEventRegionEnter("Extrapolation", &localrc);
1037+
if (ESMC_LogDefault.MsgFoundError(localrc,ESMCI_ERR_PASSTHRU,ESMC_CONTEXT,NULL)) throw localrc;
1038+
}
1039+
10271040
// Branch to each type of extrapolation
10281041
if (extrapMethod == ESMC_EXTRAPMETHOD_NONE) {
10291042

@@ -1082,6 +1095,12 @@ template void _merge_dst_to_dst_wts_into_src_to_dst_wts(PointList &dst, WMat &dt
10821095
Throw() << " Unrecognized extrapolation method.";
10831096
}
10841097

1098+
// Exit profile for extrap
1099+
if (TraceGetProfileTypeInfo(ESMC_PROFILETYPE_REGRID) > 2) {
1100+
ESMCI::TraceEventRegionExit("Extrapolation", &localrc);
1101+
if (ESMC_LogDefault.MsgFoundError(localrc,ESMCI_ERR_PASSTHRU,ESMC_CONTEXT,NULL)) throw localrc;
1102+
}
1103+
10851104
}
10861105

10871106

0 commit comments

Comments
 (0)