updated version query to also include git version info. Delineate
between development mode (git clone) and release version where the git sha is stored in top-level VERSION.sha file. Closes #20. Signed-off-by: Karl W. Schulz <karl.schulz@amd.com>
이 커밋은 다음에 포함됨:
@@ -13,8 +13,18 @@ jobs:
|
||||
env:
|
||||
INSTALL_DIR: /tmp/foo1
|
||||
steps:
|
||||
- name: Set git sha mode
|
||||
id: sha-mode
|
||||
run: |
|
||||
if [ "$EVENT" == 'pull_request' ]; then
|
||||
echo "sha=${{github.event.pull_request.head.sha}}" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "sha=$GITHUB_SHA" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
ref: ${{ steps.sha-mode.sha }}
|
||||
- name: Cancel Previous Runs
|
||||
uses: styfle/cancel-workflow-action@0.11.0
|
||||
- name: Install Python
|
||||
@@ -73,6 +83,8 @@ jobs:
|
||||
- name: Verify expected paths
|
||||
run: |
|
||||
test -d $INSTALL_DIR/omniperf
|
||||
test -s $INSTALL_DIR/omniperf/VERSION
|
||||
test -s $INSTALL_DIR/omniperf/VERSION.sha
|
||||
test -d $INSTALL_DIR/omniperf/bin
|
||||
test -x $INSTALL_DIR/omniperf/bin/omniperf
|
||||
test -d $INSTALL_DIR/modulefiles/omniperf
|
||||
|
||||
+3
-3
@@ -40,9 +40,9 @@ if(Git_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
|
||||
execute_process(
|
||||
COMMAND git log --pretty=format:%h -n 1
|
||||
OUTPUT_VARIABLE OMNIPERF_GIT_REV
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET)
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
message(STATUS "Git revision: ${OMNIPERF_GIT_REV}")
|
||||
endif()
|
||||
message(STATUS "Git revision: ${GIT_REV}")
|
||||
|
||||
set(CMAKE_BUILD_TYPE "Release")
|
||||
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
|
||||
@@ -211,7 +211,7 @@ add_test(
|
||||
install(PROGRAMS src/omniperf TYPE BIN)
|
||||
install(FILES src/parser.py TYPE BIN)
|
||||
install(FILES src/common.py TYPE BIN)
|
||||
install(FILES VERSION DESTINATION ${CMAKE_INSTALL_PREFIX})
|
||||
install(FILES VERSION VERSION.sha DESTINATION ${CMAKE_INSTALL_PREFIX})
|
||||
# src/omniperf_cli
|
||||
install(
|
||||
DIRECTORY src/omniperf_cli
|
||||
|
||||
+50
-7
@@ -22,8 +22,10 @@
|
||||
|
||||
import os
|
||||
import sys
|
||||
import io
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import shutil
|
||||
|
||||
OMNIPERF_HOME = Path(__file__).resolve().parent
|
||||
|
||||
@@ -31,10 +33,51 @@ OMNIPERF_HOME = Path(__file__).resolve().parent
|
||||
PROG = "omniperf"
|
||||
SOC_LIST = ["mi50", "mi100", "mi200"]
|
||||
DISTRO_MAP = {"platform:el8": "rhel8", "15.3": "sle15sp3", "20.04": "ubuntu20_04"}
|
||||
version = os.path.join(OMNIPERF_HOME.parent, "VERSION")
|
||||
try:
|
||||
with open(version, "r") as file:
|
||||
VER = file.read().replace("\n", "")
|
||||
except EnvironmentError:
|
||||
print("ERROR: Cannot find VERSION file at {}".format(version))
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def getVersion():
|
||||
# symantic version info
|
||||
version = os.path.join(OMNIPERF_HOME.parent, "VERSION")
|
||||
try:
|
||||
with open(version, "r") as file:
|
||||
VER = file.read().replace("\n", "")
|
||||
except EnvironmentError:
|
||||
print("ERROR: Cannot find VERSION file at {}".format(version))
|
||||
sys.exit(1)
|
||||
|
||||
# git version info
|
||||
gitDir = os.path.join(OMNIPERF_HOME.parent, ".git")
|
||||
if (shutil.which("git") is not None) and os.path.exists(gitDir):
|
||||
gitQuery = subprocess.run(
|
||||
["git", "log", "--pretty=format:%h", "-n", "1"],
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.DEVNULL,
|
||||
)
|
||||
if gitQuery.returncode != 0:
|
||||
SHA = "unknown"
|
||||
MODE = "unknown"
|
||||
else:
|
||||
SHA = gitQuery.stdout.decode("utf-8")
|
||||
MODE = "dev"
|
||||
else:
|
||||
shaFile = os.path.join(OMNIPERF_HOME.parent, "VERSION.sha")
|
||||
try:
|
||||
with open(shaFile, "r") as file:
|
||||
SHA = file.read().replace("\n", "")
|
||||
except EnvironmentError:
|
||||
print("ERROR: Cannot find VERSION.sha file at {}".format(shaFile))
|
||||
sys.exit(1)
|
||||
|
||||
MODE = "release"
|
||||
|
||||
versionData = {"version": VER, "sha": SHA, "mode": MODE}
|
||||
return versionData
|
||||
|
||||
|
||||
def getVersionDisplay(version, sha, mode):
|
||||
buf = io.StringIO()
|
||||
print("-" * 40, file=buf)
|
||||
print("Omniperf version: %s (%s)" % (version, mode), file=buf)
|
||||
print("Git revision: %s" % sha, file=buf)
|
||||
print("-" * 40, file=buf)
|
||||
return buf.getvalue()
|
||||
|
||||
+8
-4
@@ -43,10 +43,11 @@ from common import (
|
||||
OMNIPERF_HOME,
|
||||
PROG,
|
||||
SOC_LIST,
|
||||
VER,
|
||||
DISTRO_MAP,
|
||||
) # Import global variables
|
||||
|
||||
from common import getVersion
|
||||
|
||||
################################################
|
||||
# Helper Functions
|
||||
################################################
|
||||
@@ -305,7 +306,7 @@ def run_prof(fname, workload_dir, perfmon_dir, cmd, verbose):
|
||||
)
|
||||
|
||||
|
||||
def omniperf_profile(args):
|
||||
def omniperf_profile(args,VER):
|
||||
# Verify valid target
|
||||
if args.target not in SOC_LIST:
|
||||
parse.print_help(sys.stderr)
|
||||
@@ -420,6 +421,9 @@ def main():
|
||||
parse(my_parser)
|
||||
args = my_parser.parse_args()
|
||||
|
||||
vData = getVersion()
|
||||
VER = vData['version']
|
||||
|
||||
if args.mode == None:
|
||||
throw_parse_error(
|
||||
my_parser,
|
||||
@@ -517,8 +521,8 @@ def main():
|
||||
|
||||
# Profile only
|
||||
else:
|
||||
print("\n--------\nProfile only\n--------\n")
|
||||
omniperf_profile(args)
|
||||
print("\n-------------\nProfile only\n-------------\n")
|
||||
omniperf_profile(args,VER)
|
||||
|
||||
##############
|
||||
# DATABASE MODE
|
||||
|
||||
+10
-14
@@ -26,11 +26,16 @@ from common import (
|
||||
OMNIPERF_HOME,
|
||||
PROG,
|
||||
SOC_LIST,
|
||||
VER,
|
||||
) # Import global variables
|
||||
from common import getVersion, getVersionDisplay
|
||||
|
||||
|
||||
def parse(my_parser):
|
||||
|
||||
# versioning info
|
||||
vData = getVersion()
|
||||
versionString = getVersionDisplay(vData["version"], vData["sha"], vData["mode"])
|
||||
|
||||
# -----------------------------------------
|
||||
# Parse arguments (dependent on mode)
|
||||
# -----------------------------------------
|
||||
@@ -40,9 +45,7 @@ def parse(my_parser):
|
||||
general_group = my_parser.add_argument_group("General Options")
|
||||
my_parser._positionals.title = "Modes"
|
||||
my_parser._optionals.title = "Help"
|
||||
general_group.add_argument(
|
||||
"-v", "--version", action="version", version=PROG + " (" + VER + ")"
|
||||
)
|
||||
general_group.add_argument("-v", "--version", action="version", version=versionString)
|
||||
|
||||
subparsers = my_parser.add_subparsers(
|
||||
dest="mode", help="Select mode of interaction with the target application:"
|
||||
@@ -76,13 +79,10 @@ def parse(my_parser):
|
||||
profile_group = profile_parser.add_argument_group("Profile Options")
|
||||
roofline_group = profile_parser.add_argument_group("Standalone Roofline Options")
|
||||
|
||||
general_group.add_argument(
|
||||
"-v", "--version", action="version", version=PROG + " (" + VER + ")"
|
||||
)
|
||||
general_group.add_argument("-v", "--version", action="version", version=versionString)
|
||||
general_group.add_argument(
|
||||
"-V", "--verbose", help="Increase output verbosity", action="count", default=0
|
||||
)
|
||||
|
||||
profile_group.add_argument(
|
||||
"-n",
|
||||
"--name",
|
||||
@@ -227,9 +227,7 @@ def parse(my_parser):
|
||||
interaction_group = db_parser.add_argument_group("Interaction Type")
|
||||
connection_group = db_parser.add_argument_group("Connection Options")
|
||||
|
||||
general_group.add_argument(
|
||||
"-v", "--version", action="version", version=PROG + " (" + VER + ")"
|
||||
)
|
||||
general_group.add_argument("-v", "--version", action="version", version=versionString)
|
||||
general_group.add_argument(
|
||||
"-V", "--verbose", help="Increase output verbosity", action="count", default=0
|
||||
)
|
||||
@@ -327,9 +325,7 @@ def parse(my_parser):
|
||||
general_group = analyze_parser.add_argument_group("General Options")
|
||||
analyze_group = analyze_parser.add_argument_group("Analyze Options")
|
||||
|
||||
general_group.add_argument(
|
||||
"-v", "--version", action="version", version=PROG + " (" + VER + ")"
|
||||
)
|
||||
general_group.add_argument("-v", "--version", action="version", version=versionString)
|
||||
general_group.add_argument(
|
||||
"-V", "--verbose", help="Increase output verbosity", action="count", default=0
|
||||
)
|
||||
|
||||
새 이슈에서 참조
사용자 차단