metrics: Add openvino benchmark.

This PR adds openvino test in order to exercise additional ML
benchmarks.

OpenVino bench used to optimize and deploy deep learning models.

Fixes: #9389

Signed-off-by: David Esparza <david.esparza.borquez@intel.com>
This commit is contained in:
David Esparza 2024-04-01 18:23:31 -06:00
parent b37c5f8ba1
commit 3bde511d0d
No known key found for this signature in database
GPG Key ID: EABE0B1A98CC3B7A
2 changed files with 163 additions and 0 deletions

View File

@ -0,0 +1,46 @@
# Copyright (c) 2024 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0
# Set up an Ubuntu image with 'phoronix-test-suite' installed
FROM ubuntu:22.04
LABEL DOCKERFILE_VERSION="1.0"
ENV PHORONIX_VER="10.8.4"
ENV PHORONIX_URL="https://phoronix-test-suite.com/releases/"
ENV PHORONIX_TAR_FILE="phoronix-test-suite-${PHORONIX_VER}.tar.gz"
ENV PHORONIX_SRC="${PHORONIX_URL}/${PHORONIX_TAR_FILE}"
ENV PHORONIX_CFG_ALT="/etc/phoronix-test-suite.xml"
ENV PHORONIX_CFG="/usr/share/phoronix-test-suite/pts-core/static/user-config-defaults.xml"
ENV DEBIAN_FRONTEND noninteractive
ENV DEBCONF_NONINTERACTIVE_SEEN true
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN apt-get update && \
apt-get install -y --no-install-recommends git curl build-essential autoconf && \
apt-get install -y --no-install-recommends php libapache2-mod-php php-bz2 php-gd php-sqlite3 php-xml && \
apt-get install -y --no-install-recommends cmake cmake-data mesa-utils vulkan-tools unzip apt-file && \
curl -OkL ${PHORONIX_SRC} && \
tar zxf ${PHORONIX_TAR_FILE} && cd phoronix-test-suite && ./install-sh && \
apt-get clean && rm -rf /var/lib/apt/lists && \
rm -f ${PHORONIX_TAR_FILE} && \
if [ -n "$http_proxy" ] ; then \
sed -i "s|<ProxyAddress></ProxyAddress>|<ProxyAddress>$(getent hosts "$(echo $http_proxy | sed 's~http[s]*://~~g' | sed -e 's/:[0-9]*//g')" | awk '{ print $1 }')</ProxyAddress>|g" ${PHORONIX_CFG} ; \
sed -i "s|<ProxyPort></ProxyPort>|<ProxyPort>$(echo $http_proxy | sed 's/^.*://g')</ProxyPort>|g" ${PHORONIX_CFG} ; \
fi && \
sed -i "s|<UploadResults>TRUE</UploadResults>|<UploadResults>FALSE</UploadResults>|g" ${PHORONIX_CFG} && \
sed -i "s|<PromptForTestIdentifier>TRUE</PromptForTestIdentifier>|<PromptForTestIdentifier>FALSE</PromptForTestIdentifier>|g" ${PHORONIX_CFG} && \
sed -i "s|<PromptSaveName>TRUE</PromptSaveName>|<PromptSaveName>FALSE</PromptSaveName>|g" ${PHORONIX_CFG} && \
sed -i "s|<PromptForTestDescription>TRUE</PromptForTestDescription>|<PromptForTestDescription>FALSE</PromptForTestDescription>|g" ${PHORONIX_CFG} && \
sed -i "s|<Configured>FALSE</Configured>|<Configured>TRUE</Configured>|g" ${PHORONIX_CFG} && \
sed -i "s|<Timeout>20</Timeout>|<Timeout>2</Timeout>|g" ${PHORONIX_CFG} && \
sed -i "s|<SaveResults>FALSE</SaveResults>|<SaveResults>TRUE</SaveResults>|g" ${PHORONIX_CFG} && \
phoronix-test-suite download-test-files openvino && \
phoronix-test-suite install openvino && \
sed -i 's/<NoNetworkCommunication>FALSE/<NoNetworkCommunication>TRUE/g' ${PHORONIX_CFG} && \
sed -i 's/<Timeout>20/<Timeout>3/g' ${PHORONIX_CFG}
CMD ["/bin/bash"]

View File

@ -0,0 +1,117 @@
#!/bin/bash
#
# Copyright (c) 2024 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0
# Description of the test:
# This test runs the 'openvino benchmark'
# https://github.com/v8/web-tooling-benchmark
set -o pipefail
# General env
SCRIPT_PATH=$(dirname "$(readlink -f "$0")")
source "${SCRIPT_PATH}/../lib/common.bash"
# TEST_NAME is required to collect results and name the workload container.
TEST_NAME="openvino-bench"
WORKLOAD="phoronix-test-suite batch-run openvino"
PAYLOAD_ARGS="${PAYLOAD_ARGS:-tail -f /dev/null}"
IMAGE="docker.io/library/pts-openvino:latest"
DOCKERFILE="${SCRIPT_PATH}/openvino-dockerfile/Dockerfile"
TMP_DIR=$(mktemp --tmpdir -d openvino.XXXXXXXXXX)
KATA_PERF_CONFIG="${TMP_DIR}/openvino_config.toml"
TEST_RESULTS_FNAME="${TMP_DIR}/openvino-results.json"
# Variable used to store the initial configuration file name.
# This file is again pointed to by kata once the script finishes.
KATA_INITIAL_CONFIG_FNAME=""
function restore_kata_config() {
rm -rf "${TMP_DIR}"
set_kata_config_file "${KATA_INITIAL_CONFIG_FNAME}"
}
trap restore_kata_config EXIT
# Show help about this script
function help(){
cat << EOF
Usage: $0
Description:
Runs onednn benchmark.
EOF
}
function save_config() {
metrics_json_start_array
pushd "${DEFAULT_KATA_CONFIG_DIR}"
local MEM_AVAIL_MB="$(cat ${DEFAULT_KATA_CONFIG_FNAME} | grep -i "default_memory =" | cut -d "=" -f2 | tr -d ' ' | tr -d '"')"
local NUM_CPUS="$(cat ${DEFAULT_KATA_CONFIG_FNAME} | grep -i "default_vcpus =" | cut -d "=" -f2 | tr -d ' ' | tr -d '"')"
local SHARED_FS="$(cat ${DEFAULT_KATA_CONFIG_FNAME} | grep shared_fs | cut -d "=" -f2 | tr -d ' ' | tr -d '"')"
popd
local json="$(cat << EOF
{
"image": "${IMAGE}",
"units": "ms",
"mode": "Lower Is Better",
"shared-fs": "${SHARED_FS}",
"num-vcpus": "${NUM_CPUS}",
"memory-available-mb": "${MEM_AVAIL_MB}"
}
EOF
)"
metrics_json_add_array_element "${json}"
metrics_json_end_array "Config"
}
function main() {
local i=0
local cmds=("docker")
local RES_DIR="/var/lib/phoronix-test-suite/test-results"
# Check tools/commands dependencies
init_env
check_cmds "${cmds[@]}"
check_ctr_images "$IMAGE" "$DOCKERFILE"
clean_cache
# Configure Kata to use the maximum number of available CPUs
# and to use the available free memory.
get_current_kata_config_file KATA_INITIAL_CONFIG_FNAME
set_kata_configuration_performance "${KATA_PERF_CONFIG}"
# Launch container.
sudo -E "${CTR_EXE}" run -d --runtime "${CTR_RUNTIME}" "${IMAGE}" "${TEST_NAME}" sh -c "${PAYLOAD_ARGS}"
# Run the test.
sudo -E "${CTR_EXE}" t exec -t --exec-id "$(random_name)" "${TEST_NAME}" sh -c "${WORKLOAD}"
results_fname=$(sudo -E "${CTR_EXE}" t exec --exec-id $(random_name) ${TEST_NAME} sh -c "ls ${RES_DIR}")
SAVE_RESULTS_CMD="phoronix-test-suite result-file-to-json ${results_fname}"
# Save results.
sudo -E "${CTR_EXE}" t exec --exec-id "$(random_name)" "${TEST_NAME}" sh -c "${SAVE_RESULTS_CMD}"
# Extract results.
sudo -E "${CTR_EXE}" t exec --exec-id "${RANDOM}" "${TEST_NAME}" sh -c "cat /root/${results_fname}.json" > "${TEST_RESULTS_FNAME}"
cat <<< $(jq 'del(.systems[].data)' "${TEST_RESULTS_FNAME}") > "${TEST_RESULTS_FNAME}"
local results="$(cat "${TEST_RESULTS_FNAME}")"
metrics_json_init
save_config
metrics_json_start_array
metrics_json_add_array_element "${results}"
metrics_json_end_array "Results"
metrics_json_save
clean_env_ctr
}
main "$@"