From 66eee79be321b6486c2dcd26b3d753e753d447ac Mon Sep 17 00:00:00 2001 From: yoshifuminakamura Date: Wed, 16 Sep 2026 10:12:23 +0900 Subject: [PATCH] Persist SBD NCU plan metadata artifacts Signed-off-by: yoshifuminakamura --- programs/sbd/profile.sh | 26 ++++++++++++++++++++++++++ scripts/tests/test_sbd_ncu_profile.sh | 5 ++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/programs/sbd/profile.sh b/programs/sbd/profile.sh index 4e8b877..b936684 100644 --- a/programs/sbd/profile.sh +++ b/programs/sbd/profile.sh @@ -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 @@ -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" @@ -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" @@ -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() { @@ -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) diff --git a/scripts/tests/test_sbd_ncu_profile.sh b/scripts/tests/test_sbd_ncu_profile.sh index e614b89..158e46b 100644 --- a/scripts/tests/test_sbd_ncu_profile.sh +++ b/scripts/tests/test_sbd_ncu_profile.sh @@ -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