-
Notifications
You must be signed in to change notification settings - Fork 2
/
get_timing_data_from_log.sh
executable file
·92 lines (76 loc) · 3.76 KB
/
get_timing_data_from_log.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/bin/bash
NONOPT_ARGS=()
YAML_FILE_NAME=""
OUTPUT_PATH=""
SUMMARY_FILE_NAME=""
while [[ $# -gt 0 ]]; do
case $1 in
-y|--yaml)
YAML_FILE_NAME="$2"
shift
shift
;;
-s|--summary)
SUMMARY_FILE_NAME="$2"
shift
shift
;;
-o|--output)
OUTPUT_PATH="$2"
shift
shift
;;
-*|--*)
echo "Unknown option $1"
exit 1
;;
*)
NONOPT_ARGS+=("$1")
shift
;;
esac
done
set -- "${NONOPT_ARGS[@]}"
date
INPUT_RUN_LOG_FILE="${1}"
RUN_LOG_PATH="$(dirname "${INPUT_RUN_LOG_FILE}")"
RUN_LOG_FILE="$(basename "${INPUT_RUN_LOG_FILE}")"
OUTPUT_PATH=${OUTPUT_PATH:-"."}
printf "get_timing_data_from_log: Processing ${INPUT_RUN_LOG_FILE}\n"
printf "get_timing_data_from_log: Input file: ${RUN_LOG_FILE}\n"
printf "get_timing_data_from_log: Input path: ${RUN_LOG_PATH}\n"
printf "get_timing_data_from_log: Output Path ${OUTPUT_PATH}\n"
RUN_CASENAME=$(printf "${RUN_LOG_FILE}" | sed 's/-rank0\.sqlite//')
YAML_FILE_NAME=${YAML_FILE_NAME:-"${RUN_CASENAME}-timing-data.yaml"}
SUMMARY_FILE_ROOT=${SUMMARY_FILE_NAME:-"${RUN_CASENAME}-timing-data"}
YAML_OUTPUT_NAME="${OUTPUT_PATH}/${YAML_FILE_NAME}"
SUMMARY_FILE_NAME="${OUTPUT_PATH}/${SUMMARY_FILE_ROOT}.sqlite"
printf "get_timing_data_from_log: Casename ${RUN_CASENAME}\n"
printf "get_timing_data_from_log: Summary File ${SUMMARY_FILE_NAME}\n"
printf "get_timing_data_from_log: YAML output ${YAML_OUTPUT_NAME}\n"
rm -f ${YAML_OUTPUT_NAME}
rm -f ${SUMMARY_FILE_NAME}
# -- Process the results of the timing run
if [[ -f "${RUN_LOG_PATH}/${RUN_LOG_FILE}" ]]; then
# --- Pull the timings out of the sqlite files generated by logging
runalyzer-gather ${SUMMARY_FILE_NAME} ${RUN_LOG_PATH}/${RUN_LOG_FILE}
CL_DEVICE=$(sqlite3 ${SUMMARY_FILE_NAME} 'SELECT cl_device_name FROM runs')
STARTUP_TIME=$(runalyzer -m ${SUMMARY_FILE_NAME} -c 'print(q("select $t_init.max").fetchall()[0][0])' | grep -v INFO)
FIRST_STEP=$(runalyzer -m ${SUMMARY_FILE_NAME} -c 'print(sum(p[0] for p in q("select $t_step.max").fetchall()[0:1]))' | grep -v INFO)
FIRST_10_STEPS=$(runalyzer -m ${SUMMARY_FILE_NAME} -c 'print(sum(p[0] for p in q("select $t_step.max").fetchall()[0:10]))' | grep -v INFO)
SECOND_10_STEPS=$(runalyzer -m ${SUMMARY_FILE_NAME} -c 'print(sum(p[0] for p in q("select $t_step.max").fetchall()[10:19]))' | grep -v INFO)
MAX_PYTHON_MEM_USAGE=$(runalyzer -m ${SUMMARY_FILE_NAME} -c 'print(max(p[0] for p in q("select $memory_usage_python.max").fetchall()))' | grep -v INFO)
MAX_GPU_MEM_USAGE=$(runalyzer -m ${SUMMARY_FILE_NAME} -c 'print(max(p[0] for p in q("select $memory_usage_gpu.max").fetchall()))' | grep -v INFO)
# --- Create a YAML-compatible text snippet with the timing info
printf "Creating YAML output: ${YAML_OUTPUT_NAME}\n"
# printf "run_date: ${TIMING_DATE}\nrun_host: ${TIMING_HOST}\n" > ${YAML_OUTPUT_NAME}
printf "cl_device: ${CL_DEVICE}\n" > ${YAML_OUTPUT_NAME}
# printf "run_epoch: ${TIME_SINCE_EPOCH}\nrun_platform: ${TIMING_PLATFORM}\n" >> ${YAML_OUTPUT_NAME}
# printf "run_arch: ${TIMING_ARCH}\ngpu_arch: ${GPU_ARCH}\n" >> ${YAML_OUTPUT_NAME}
# printf "mirge_version: ${MIRGE_HASH}\n" >> ${YAML_OUTPUT_NAME}
# printf "driver_version: ${DRIVER_HASH}\ndriver_md5sum: ${DRIVER_MD5SUM}\n" >> ${YAML_OUTPUT_NAME}
printf "time_startup: ${STARTUP_TIME}\ntime_first_step: ${FIRST_STEP}\n" >> ${YAML_OUTPUT_NAME}
printf "time_first_10: ${FIRST_10_STEPS}\ntime_second_10: ${SECOND_10_STEPS}\n" >> ${YAML_OUTPUT_NAME}
printf "max_python_mem_usage: ${MAX_PYTHON_MEM_USAGE}\n" >> ${YAML_OUTPUT_NAME}
printf "max_gpu_mem_usage: ${MAX_GPU_MEM_USAGE}\n---\n" >> ${YAML_OUTPUT_NAME}
fi