Skip to content

Commit

Permalink
Update cuda and rocm controllers (#524)
Browse files Browse the repository at this point in the history
  • Loading branch information
daboehme authored Jan 22, 2024
1 parent b4553b9 commit ff53426
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 61 deletions.
66 changes: 34 additions & 32 deletions src/caliper/controllers/CudaActivityProfileController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class CudaActivityProfileController : public cali::ChannelController
"*,scale(cupti.activity.duration,1e-9) as \"time (gpu)\" unit sec"
" ,scale(sum#cupti.host.duration,1e-9) as \"time\" unit sec"
},
{ "group by", "prop:nested,cupti.kernel.name,cupti.activity.kind,mpi.rank" },
{ "group by", "path,cupti.kernel.name,cupti.activity.kind,mpi.rank" },
{ "format", format }
});
} else {
Expand All @@ -76,7 +76,7 @@ class CudaActivityProfileController : public cali::ChannelController
{ "select",
"*,scale(cupti.activity.duration,1e-9) as \"time (gpu)\" unit sec"
" ,scale(sum#cupti.host.duration,1e-9) as \"time\" unit sec" },
{ "group by", "prop:nested,cupti.kernel.name,cupti.activity.kind" },
{ "group by", "path,cupti.kernel.name,cupti.activity.kind" },
{ "format", format }
});
}
Expand All @@ -90,7 +90,7 @@ std::string
check_args(const cali::ConfigManager::Options& opts) {
// Check if output.format is valid

std::string format = opts.get("output.format", "json-split").to_string();
std::string format = opts.get("output.format", "cali").to_string();
std::set<std::string> allowed_formats = { "cali", "json", "json-split", "hatchet" };

if (allowed_formats.find(format) == allowed_formats.end())
Expand All @@ -102,46 +102,48 @@ check_args(const cali::ConfigManager::Options& opts) {
cali::ChannelController*
make_controller(const char* name, const config_map_t& initial_cfg, const cali::ConfigManager::Options& opts)
{
std::string format = opts.get("output.format", "json-split").to_string();
std::string format = opts.get("output.format", "cali").to_string();

if (format == "hatchet")
format = "json-split";

if (!(format == "json-split" || format == "json" || format == "cali")) {
format = "json-split";
Log(0).stream() << "hatchet-region-profile: Unknown output format \"" << format
<< "\". Using json-split."
format = "cali";
Log(0).stream() << "cuda-activity-profile: Unknown output format \"" << format
<< "\". Using cali."
<< std::endl;
}

return new CudaActivityProfileController(name, initial_cfg, opts, format);
}

const char* controller_spec =
"{"
" \"name\" : \"cuda-activity-profile\","
" \"description\" : \"Record CUDA activities and a write profile\","
" \"categories\" : [ \"adiak\", \"metric\", \"cuptitrace.metric\", \"output\", \"region\", \"event\" ],"
" \"services\" : [ \"aggregate\", \"cupti\", \"cuptitrace\", \"event\" ],"
" \"config\" : "
" { \"CALI_CHANNEL_FLUSH_ON_EXIT\" : \"false\","
" \"CALI_EVENT_ENABLE_SNAPSHOT_INFO\" : \"false\","
" \"CALI_CUPTITRACE_SNAPSHOT_DURATION\" : \"true\""
" },"
" \"options\": "
" ["
" { "
" \"name\": \"output.format\","
" \"type\": \"string\","
" \"description\": \"Output format ('hatchet', 'cali', 'json')\""
" },"
" { "
" \"name\": \"use.mpi\","
" \"type\": \"bool\","
" \"description\": \"Merge results into a single output stream in MPI programs\""
" }"
" ]"
"}";
const char* controller_spec = R"json(
{
"name" : "cuda-activity-profile",
"description" : "Record CUDA activities and a write profile",
"categories" : [ "adiak", "metric", "cuptitrace.metric", "output", "region", "event" ],
"services" : [ "aggregate", "cupti", "cuptitrace", "event" ],
"config" :
{ "CALI_CHANNEL_FLUSH_ON_EXIT" : "false",
"CALI_EVENT_ENABLE_SNAPSHOT_INFO" : "false",
"CALI_CUPTITRACE_SNAPSHOT_DURATION" : "true"
},
"defaults" : { "node.order": "true" },
"options":
[
{
"name": "output.format",
"type": "string",
"description": "Output format ('hatchet', 'cali', 'json')"
},
{
"name": "use.mpi",
"type": "bool",
"description": "Merge results into a single output stream in MPI programs"
}
]
};
)json";

} // namespace [anonymous]

Expand Down
54 changes: 28 additions & 26 deletions src/caliper/controllers/CudaActivityReportController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class CudaActivityReportController : public cali::ChannelController
",max(iscale#cupti.activity.duration) as \"Max GPU Time\""
",ratio(iscale#cupti.activity.duration,iscale#sum#cupti.host.duration,100.0) as \"GPU %\"";

std::string groupby = "prop:nested";
std::string groupby = "path";

if (opts.is_enabled("show_kernels")) {
groupby += ",cupti.kernel.name";
Expand Down Expand Up @@ -116,31 +116,33 @@ make_controller(const char* name, const config_map_t& initial_cfg, const cali::C
return new CudaActivityReportController(use_mpi(opts), name, initial_cfg, opts);
}

const char* controller_spec =
"{"
" \"name\" : \"cuda-activity-report\","
" \"description\" : \"Record and print CUDA activities (kernel executions, memcopies, etc.)\","
" \"categories\" : [ \"output\", \"region\", \"cuptitrace.metric\", \"treeformatter\", \"event\" ],"
" \"services\" : [ \"aggregate\", \"cupti\", \"cuptitrace\", \"event\" ],"
" \"config\" : "
" { \"CALI_CHANNEL_FLUSH_ON_EXIT\" : \"false\","
" \"CALI_EVENT_ENABLE_SNAPSHOT_INFO\" : \"false\","
" \"CALI_CUPTITRACE_SNAPSHOT_DURATION\" : \"true\""
" },"
" \"options\": "
" ["
" {"
" \"name\": \"aggregate_across_ranks\","
" \"type\": \"bool\","
" \"description\": \"Aggregate results across MPI ranks\""
" },"
" {"
" \"name\": \"show_kernels\","
" \"type\": \"bool\","
" \"description\": \"Show kernel names\""
" }"
" ]"
"}";
const char* controller_spec = R"json(
{
"name" : "cuda-activity-report",
"description" : "Record and print CUDA activities (kernel executions, memcopies, etc.)",
"categories" : [ "output", "region", "cuptitrace.metric", "treeformatter", "event" ],
"services" : [ "aggregate", "cupti", "cuptitrace", "event" ],
"config" :
{ "CALI_CHANNEL_FLUSH_ON_EXIT" : "false",
"CALI_EVENT_ENABLE_SNAPSHOT_INFO" : "false",
"CALI_CUPTITRACE_SNAPSHOT_DURATION" : "true"
},
"defaults" : { "order_as_visited": "true" },
"options":
[
{
"name": "aggregate_across_ranks",
"type": "bool",
"description": "Aggregate results across MPI ranks"
},
{
"name": "show_kernels",
"type": "bool",
"description": "Show kernel names"
}
]
}
)json";

} // namespace [anonymous]

Expand Down
7 changes: 4 additions & 3 deletions src/caliper/controllers/ROCmActivityProfileController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ std::string
check_args(const cali::ConfigManager::Options& opts) {
// Check if output.format is valid

std::string format = opts.get("output.format", "json-split").to_string();
std::string format = opts.get("output.format", "cali").to_string();
std::set<std::string> allowed_formats = { "cali", "json", "json-split", "hatchet" };

if (allowed_formats.find(format) == allowed_formats.end())
Expand All @@ -102,13 +102,13 @@ check_args(const cali::ConfigManager::Options& opts) {
cali::ChannelController*
make_controller(const char* name, const config_map_t& initial_cfg, const cali::ConfigManager::Options& opts)
{
std::string format = opts.get("output.format", "json-split").to_string();
std::string format = opts.get("output.format", "cali").to_string();

if (format == "hatchet")
format = "json-split";

if (!(format == "json-split" || format == "json" || format == "cali")) {
format = "json-split";
format = "cali";
Log(0).stream() << "hatchet-region-profile: Unknown output format \"" << format
<< "\". Using json-split."
<< std::endl;
Expand All @@ -130,6 +130,7 @@ const char* controller_spec = R"json(
"CALI_ROCTRACER_RECORD_KERNEL_NAMES": "true",
"CALI_ROCTRACER_SNAPSHOT_DURATION" : "false"
},
"defaults" : { "node.order": "true" },
"options":
[
{
Expand Down
1 change: 1 addition & 0 deletions src/caliper/controllers/ROCmActivityReportController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ const char* controller_spec = R"json(
"CALI_EVENT_ENABLE_SNAPSHOT_INFO" : "false",
"CALI_ROCTRACER_TRACE_ACTIVITIES" : "true"
},
"defaults" : { "order_as_visited": "true" },
"options":
[
{
Expand Down

0 comments on commit ff53426

Please sign in to comment.