Skip to content

Commit

Permalink
Simplify syntax for "select" in query specs (LLNL#514)
Browse files Browse the repository at this point in the history
* Simplify select syntax for query specs

* Fix dict parsing

* Use new simplified select option spec syntax

* Update json config examples to new select syntax

* ConfigManager: remove use_alias from build_query()

* Simplify ConfigManager::build_query()

* Remove obsolete ConfigManager 'profile' argument
  • Loading branch information
daboehme authored Oct 19, 2023
1 parent 3b01661 commit 95e6a12
Show file tree
Hide file tree
Showing 11 changed files with 331 additions and 411 deletions.
28 changes: 14 additions & 14 deletions examples/configs/flops.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@
],
"select" :
[
{ "expr": "scale(flops.scalar,1e-6)", "as": "Mflops (scalar)" },
{ "expr": "scale(flops.packed,1e-6)", "as": "Mops (vector)" },
{ "expr": "ratio(flops.scalar,sum#time.duration,1e-6)", "as": "Mflops/s (scalar)" }
"scale(flops.scalar,1e-6) as \"Mflops (scalar)\"",
"scale(flops.packed,1e-6) as \"Mops (vector)\"",
"ratio(flops.scalar,sum#time.duration,1e-6) as \"Mflops/s (scalar)\""
]
},
{ "level" : "cross",
"select" :
[
{ "expr": "sum(scale#flops.scalar)", "as": "Mflops (scalar)" },
{ "expr": "sum(scale#flops.packed)", "as": "Mops (vector)" },
{ "expr": "avg(ratio#flops.scalar/sum#time.duration)", "as": "Mflops/s (avg)" },
{ "expr": "max(ratio#flops.scalar/sum#time.duration)", "as": "Mflops/s (max)" },
{ "expr": "sum(ratio#flops.scalar/sum#time.duration)", "as": "Mflops/s (sum)" }
"sum(scale#flops.scalar) as \"Mflops (scalar)\"",
"sum(scale#flops.packed) as \"Mops (vector)\"",
"avg(ratio#flops.scalar/sum#time.duration) as \"Mflops/s (avg)\"",
"max(ratio#flops.scalar/sum#time.duration) as \"Mflops/s (max)\"",
"sum(ratio#flops.scalar/sum#time.duration) as \"Mflops/s (sum)\""
]
}
]
Expand All @@ -58,17 +58,17 @@
],
"select" :
[
{ "expr": "scale(flops,1e-6)", "as": "Mflops" },
{ "expr": "ratio(flops,sum#time.duration,1e-6)", "as": "Mflops/s" }
"scale(flops,1e-6) as Mflops",
"ratio(flops,sum#time.duration,1e-6) as Mflops/s"
]
},
{ "level" : "cross",
"select" :
[
{ "expr": "sum(scale#flops)", "as": "Mflops" },
{ "expr": "avg(ratio#flops/sum#time.duration)", "as": "Mflops/s (avg)" },
{ "expr": "max(ratio#flops/sum#time.duration)", "as": "Mflops/s (max)" },
{ "expr": "sum(ratio#flops/sum#time.duration)", "as": "Mflops/s (sum)" }
"sum(scale#flops) as Mflops",
"avg(ratio#flops/sum#time.duration) as \"Mflops/s (avg)\"",
"max(ratio#flops/sum#time.duration) as \"Mflops/s (max)\"",
"sum(ratio#flops/sum#time.duration) as \"Mflops/s (sum)\""
]
}
]
Expand Down
18 changes: 9 additions & 9 deletions examples/configs/papi_tot_ins.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
"services" : [ "papi" ],
"config" : { "CALI_PAPI_COUNTERS": "PAPI_TOT_INS" },
"query" : [
{ "level": "local", "select": [ { "expr": "sum(sum#papi.PAPI_TOT_INS)", "as": "Instr." } ] },
{ "level": "local", "select": [ "sum(sum#papi.PAPI_TOT_INS) as Instr." ] },
{ "level": "cross", "select": [
{ "expr": "avg(sum#sum#papi.PAPI_TOT_INS)", "as": "Instr. (avg)" },
{ "expr": "sum(sum#sum#papi.PAPI_TOT_INS)", "as": "Instr. (total)" }
]
"avg(sum#sum#papi.PAPI_TOT_INS) as \"Instr. (avg)\"",
"sum(sum#sum#papi.PAPI_TOT_INS) as \"Instr. (total)\""
]
}
]
},
Expand All @@ -20,13 +20,13 @@
"services" : [ "papi" ],
"config" : { "CALI_PAPI_COUNTERS": "PAPI_REF_CYC" },
"query" : [
{ "level": "local", "select": [ { "expr": "sum(sum#papi.PAPI_REF_CYC)", "as": "Cycles" } ] },
{ "level": "local", "select": [ "sum(sum#papi.PAPI_REF_CYC) as Cycles" ] },
{ "level": "cross", "select": [
{ "expr": "avg(sum#sum#papi.PAPI_REF_CYC)", "as": "Cycles (avg)" },
{ "expr": "sum(sum#sum#papi.PAPI_REF_CYC)", "as": "Cycles (total)" }
]
"avg(sum#sum#papi.PAPI_REF_CYC) as \"Cycles (avg)\"",
"sum(sum#sum#papi.PAPI_REF_CYC) as \"Cycles (total)\""
]
}
]
}
}
]
}
13 changes: 6 additions & 7 deletions include/caliper/ConfigManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class ConfigManager
/// \param in Base CalQL clauses as needed by the controller
/// \return Complete CalQL query statement
std::string
build_query(const char* level, const std::map<std::string, std::string>& in, bool use_alias = true) const;
build_query(const char* level, const std::map<std::string, std::string>& in) const;

friend class ConfigManager;
};
Expand Down Expand Up @@ -282,11 +282,11 @@ class ConfigManager
/// " \"query\" : "
/// " ["
/// " { \"level\": \"local\", \"select\":"
/// " [ { \"expr\": \"sum(sum#papi.PAPI_TOT_INS)\" } ]"
/// " [ \"sum(sum#papi.PAPI_TOT_INS)\" ]"
/// " },"
/// " { \"level\": \"cross\", \"select\":"
/// " [ { \"expr\": \"avg(sum#sum#papi.PAPI_TOT_INS)\", \"as\": \"Avg instr./rank\" },"
/// " { \"expr\": \"max(sum#sum#papi.PAPI_TOT_INS)\", \"as\": \"Max instr./rank\" }"
/// " [ \"avg(sum#sum#papi.PAPI_TOT_INS) as \\\"Avg instr./rank\\\",\"
/// " \"max(sum#sum#papi.PAPI_TOT_INS) as \\\"Max instr./rank\\\"\"
/// " ]"
/// " }"
/// " ]"
Expand Down Expand Up @@ -322,9 +322,8 @@ class ConfigManager
/// two aggregation levels: \e local computes process-local
/// metrics, and \e cross computes cross-process
/// metrics in MPI programs. For each level, specify metrics
/// using a list of "select" definitions, where \e expr defines an
/// aggregation using a CalQL expression, and \e as provides a
/// human-readable name for the metric. Metrics on the \e serial
/// as a list of "select" definitions and aggregations
/// using CalQL expressions. Metrics on the \e serial
/// and \e local levels use runtime aggregation results from
/// the "aggregate" service as input, metrics on the \e cross level
/// use "local" metrics as input.
Expand Down
Loading

0 comments on commit 95e6a12

Please sign in to comment.