|
1 | 1 | #!/bin/bash |
2 | | -# estimate.sh — Dummy estimation script for qws application |
3 | | -# |
4 | | -# Usage: bash programs/qws/estimate.sh <result_json_path> |
5 | | -# Output: results/estimate_<code>_0.json |
6 | | -# |
7 | | -# This script uses a simple scale-mock model for integration testing. |
8 | | -# Replace the estimation logic section below with a real estimation tool |
9 | | -# when available. |
| 2 | +# estimate.sh — Reference package-based estimation entrypoint for qws |
10 | 3 |
|
11 | 4 | source scripts/estimate_common.sh |
12 | | - |
13 | | -# --- Read benchmark result --- |
14 | | -read_values "$1" |
15 | | - |
16 | | -# --- Future system benchmark: pass through from the benchmark run --- |
17 | | -est_future_bench_system="$est_system" |
18 | | -est_future_bench_fom="$est_fom" |
19 | | -est_future_bench_nodes="$est_node_count" |
20 | | -est_future_bench_numproc_node="$est_numproc_node" |
21 | | -est_future_bench_timestamp="$est_timestamp" |
22 | | -est_future_bench_uuid="$est_uuid" |
23 | | - |
24 | | -# --- Current system: Fugaku — fetch real FOM from result_server --- |
25 | | -est_current_system="Fugaku" |
26 | | -CURRENT_EXP="CASE0" # Use CASE0 for Fugaku baseline |
27 | | -fetch_current_fom "$est_code" "$CURRENT_EXP" |
28 | | -# fetch_current_fom sets est_current_bench_* variables automatically |
29 | | -est_current_target_nodes="$est_node_count" |
30 | | -est_current_scaling_method="measured" |
31 | | - |
32 | | -# --- Future system: FugakuNEXT — FOM scaled by 2x (dummy) --- |
33 | | -est_future_system="FugakuNEXT" |
34 | | -est_future_fom=$(awk -v fom="$est_fom" 'BEGIN {printf "%.3f", fom * 2}') |
35 | | -est_future_target_nodes="$est_node_count" |
36 | | -est_future_scaling_method="scale-mock" |
37 | | - |
38 | | -# --- Optional metadata blocks --- |
39 | | -est_estimation_id="estimate-${est_code}-${est_uuid:-unknown}" |
40 | | -est_estimation_timestamp=$(date '+%Y-%m-%d %H:%M:%S') |
41 | | -est_method_class="lightweight" |
42 | | -est_detail_level="basic" |
43 | | -est_measurement_json=$(jq -cn \ |
44 | | - --arg tool "benchmark-result-only" \ |
45 | | - --arg method "fom-plus-breakdown" \ |
46 | | - --arg annotation_method "none" \ |
47 | | - --arg counter_set "" \ |
48 | | - --arg interval_timing_method "measured-or-inherited" \ |
49 | | - '{ |
50 | | - tool: $tool, |
51 | | - method: $method, |
52 | | - annotation_method: $annotation_method, |
53 | | - counter_set: ($counter_set | if . == "" then null else . end), |
54 | | - interval_timing_method: $interval_timing_method |
55 | | - }') |
56 | | -est_assumptions_json=$(jq -cn \ |
57 | | - --arg future_system "FugakuNEXT" \ |
58 | | - --arg baseline_system "Fugaku" \ |
59 | | - '{ |
60 | | - future_system_assumption: $future_system, |
61 | | - baseline_system: $baseline_system, |
62 | | - future_fom_rule: "2x benchmark FOM when no detailed model is available" |
63 | | - }') |
64 | | -est_model_json=$(jq -cn \ |
65 | | - --arg type "scaling" \ |
66 | | - --arg name "scale-mock" \ |
67 | | - --arg version "0.1" \ |
68 | | - --arg implementation "programs/qws/estimate.sh" \ |
69 | | - '{ |
70 | | - type: $type, |
71 | | - name: $name, |
72 | | - version: $version, |
73 | | - implementation: $implementation |
74 | | - }') |
75 | | -est_confidence_json='{"level":"experimental","score":0.30}' |
76 | | -est_notes_json=$(jq -cn \ |
77 | | - --arg note "Reference implementation for lightweight estimation in BenchKit." \ |
78 | | - '{summary: $note}') |
79 | | - |
80 | | -# --- fom_breakdown (extend with bench_time, scaling_method, time per section) --- |
81 | | -# Read raw fom_breakdown from benchmark result |
82 | | -raw_breakdown=$(jq -c '.fom_breakdown // empty' "$1") |
83 | | - |
84 | | -if [[ -n "$raw_breakdown" ]]; then |
85 | | - # Future system: scale each section/overlap time by 2x (dummy) |
86 | | - est_future_fom_breakdown=$(echo "$raw_breakdown" | jq -c '{ |
87 | | - sections: [.sections[] | {name, bench_time: .time, scaling_method: "scale-mock", time: (.time * 2)}], |
88 | | - overlaps: [(.overlaps // [])[] | {sections, bench_time: .time, scaling_method: "scale-mock", time: (.time * 2)}] |
89 | | - }') |
90 | | - |
91 | | - # Current system: measured, so time == bench_time (no scaling) |
92 | | - est_current_fom_breakdown=$(echo "$raw_breakdown" | jq -c '{ |
93 | | - sections: [.sections[] | {name, bench_time: .time, scaling_method: "measured", time: .time}], |
94 | | - overlaps: [(.overlaps // [])[] | {sections, bench_time: .time, scaling_method: "measured", time: .time}] |
95 | | - }') |
96 | | - |
97 | | - # Compute FOM from breakdown: Σsections.time - Σoverlaps.time |
98 | | - est_future_fom=$(echo "$est_future_fom_breakdown" | jq '([.sections[].time] | add) - ([(.overlaps // [])[].time] | add // 0)' | awk '{printf "%.3f", $1}') |
99 | | - est_current_fom=$(echo "$est_current_fom_breakdown" | jq '([.sections[].time] | add) - ([(.overlaps // [])[].time] | add // 0)' | awk '{printf "%.3f", $1}') |
100 | | -else |
101 | | - est_future_fom_breakdown="" |
102 | | - est_current_fom_breakdown="" |
| 5 | +source scripts/estimation/packages/lightweight_fom_scaling.sh |
| 6 | + |
| 7 | +BK_ESTIMATION_PACKAGE="lightweight_fom_scaling" |
| 8 | +BK_ESTIMATION_BASELINE_SYSTEM="Fugaku" |
| 9 | +BK_ESTIMATION_BASELINE_EXP="CASE0" |
| 10 | +BK_ESTIMATION_FUTURE_SYSTEM="FugakuNEXT" |
| 11 | +BK_ESTIMATION_SCALE_FACTOR="2" |
| 12 | +BK_ESTIMATION_MODEL_NAME="scale-mock" |
| 13 | +BK_ESTIMATION_MODEL_VERSION="0.1" |
| 14 | +BK_ESTIMATION_INPUT_JSON="$1" |
| 15 | + |
| 16 | +read_values "$BK_ESTIMATION_INPUT_JSON" |
| 17 | + |
| 18 | +if ! bk_estimation_package_check_applicability; then |
| 19 | + echo "ERROR: estimation package ${BK_ESTIMATION_PACKAGE} is not applicable for input ${BK_ESTIMATION_INPUT_JSON}" >&2 |
| 20 | + exit 1 |
103 | 21 | fi |
104 | 22 |
|
105 | | -# --- Output --- |
| 23 | +bk_estimation_package_run |
| 24 | +bk_estimation_package_apply_metadata |
| 25 | + |
106 | 26 | mkdir -p results |
107 | 27 | output_file="results/estimate_${est_code}_0.json" |
108 | 28 | print_json > "$output_file" |
|
0 commit comments