Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions programs/sbd/profile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,18 @@ sbd_profile_results_dir() {

sbd_register_mult_section_artifact() {
local artifact_path="$1"
local current
local existing_artifacts=()

if [ -z "$artifact_path" ]; then
return 0
fi
IFS=',' read -r -a existing_artifacts <<< "${SBD_MULT_SECTION_ARTIFACTS:-}"
for current in "${existing_artifacts[@]}"; do
if [ "$current" = "$artifact_path" ]; then
return 0
fi
done
if [ -z "${SBD_MULT_SECTION_ARTIFACTS:-}" ]; then
SBD_MULT_SECTION_ARTIFACTS="$artifact_path"
else
Expand All @@ -65,6 +76,18 @@ sbd_register_mult_section_artifact() {
export SBD_MULT_SECTION_ARTIFACTS
}

sbd_register_ncu_plan_artifacts() {
local discovery_json="$1"
local plan_json="$2"

if [ -s "$discovery_json" ]; then
sbd_register_mult_section_artifact "results/$(basename "$discovery_json")"
fi
if [ -s "$plan_json" ]; then
sbd_register_mult_section_artifact "results/$(basename "$plan_json")"
fi
}

sbd_run_rank0_nsys_discovery() {
local n_ranks="$1"
local report_base="$2"
Expand Down Expand Up @@ -210,6 +233,7 @@ sbd_generate_ncu_plan() {
return 1
fi

sbd_register_ncu_plan_artifacts "$discovery_json" "$plan_json"
echo "SBD kernel discovery JSON: ${discovery_json}" >&2
echo "SBD NCU plan JSON: ${plan_json}" >&2
printf '%s\n' "$plan_json"
Expand Down Expand Up @@ -367,6 +391,7 @@ sbd_run_rank0_ncu_profile() {

echo "SBD NCU profile metadata: ${metadata_rel_path}" >&2
sbd_register_mult_section_artifact "$archive_rel_path"
sbd_register_mult_section_artifact "$metadata_rel_path"
}

sbd_run_ncu_plan_profiles() {
Expand Down Expand Up @@ -451,6 +476,7 @@ sbd_run_configured_ncu_profiles() {
case "$(sbd_ncu_profile_mode)" in
discovery|auto)
plan_json=$(sbd_generate_ncu_plan "$n_ranks" "$@") || return 1
sbd_register_ncu_plan_artifacts "$(sbd_profile_results_dir)/sbd_kernel_discovery.json" "$plan_json"
sbd_run_ncu_plan_profiles "$plan_json" "$n_ranks" "$@" || return $?
;;
discovery-only|auto-discovery-only)
Expand Down
5 changes: 4 additions & 1 deletion scripts/tests/test_sbd_ncu_profile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,10 @@ test "${#profile_archives[@]}" -eq 5
test "${#profile_metadata[@]}" -eq 5

artifact_count=$(printf '%s\n' "${SBD_MULT_SECTION_ARTIFACTS}" | tr ',' '\n' | awk 'NF { count += 1 } END { print count + 0 }')
test "$artifact_count" -eq 5
test "$artifact_count" -eq 12
printf '%s\n' "${SBD_MULT_SECTION_ARTIFACTS}" | tr ',' '\n' | grep -Fxq 'results/sbd_kernel_discovery.json'
printf '%s\n' "${SBD_MULT_SECTION_ARTIFACTS}" | tr ',' '\n' | grep -Fxq 'results/sbd_ncu_plan.json'
printf '%s\n' "${SBD_MULT_SECTION_ARTIFACTS}" | tr ',' '\n' | grep -Eq '^results/padata_.*\.metadata\.json$'

jq -e '
.kind == "gpu_kernel_profile_metadata" and
Expand Down
Loading