Skip to content

Commit 7ee55e7

Browse files
committed
Added get-profiler-uprof script
1 parent 90ca691 commit 7ee55e7

File tree

4 files changed

+192
-0
lines changed

4 files changed

+192
-0
lines changed
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
from mlc import utils
2+
import os
3+
from utils import *
4+
5+
6+
def ask_url_acceptance(url):
7+
print(f"Please take a moment to read the EULA at this URL:\n{url}")
8+
print("\nDo you accept the terms of this EULA? [yes/no]")
9+
10+
while True:
11+
response = input().lower()
12+
if response in ["yes", "y"]:
13+
print("You have accepted the EULA.")
14+
return True
15+
elif response in ["no", "n"]:
16+
print("You have not accepted the EULA.")
17+
return False
18+
else:
19+
print("Invalid input. Please enter 'yes' or 'no'.")
20+
21+
22+
def predeps(i):
23+
os_info = i['os_info']
24+
25+
env = i['env']
26+
if env.get('MLC_UPROF_TAR_FILE_PATH', '') != '':
27+
env['MLC_UPROF_NEEDS_TAR'] = 'yes'
28+
29+
elif is_true(env.get('MLC_UPROF_DOWNLOAD')) and not is_true(env.get('MLC_UPROF_ACCEPT_EULA')):
30+
url = "https://www.amd.com/en/developer/uprof/uprof-eula/uprof-5-1-eula.html?filename=AMDuProf_Linux_x64_5.1.701.tar.bz2"
31+
accepted = ask_url_acceptance(url)
32+
if accepted:
33+
env['MLC_UPROF_ACCEPT_EULA'] = 'yes'
34+
35+
return {'return': 0}
36+
37+
38+
def preprocess(i):
39+
40+
os_info = i['os_info']
41+
42+
env = i['env']
43+
44+
exe = 'AMDuProfSys.exe' if os_info['platform'] == 'windows' else 'AMDuProfSys'
45+
46+
if 'MLC_UPROF_BIN_WITH_PATH' not in env:
47+
48+
49+
if env.get('MLC_UPROF_DIR_PATH', '') != '':
50+
uprof_path = env['MLC_UPROF_DIR_PATH']
51+
if os.path.exists(os.path.join(uprof_path, 'bin', exe)):
52+
env['MLC_TMP_PATH'] = os.path.join(uprof_path, 'bin')
53+
54+
r = i['automation'].find_artifact({'file_name': exe,
55+
'env': env,
56+
'os_info': os_info,
57+
'default_path_env_key': 'PATH',
58+
'detect_version': True,
59+
'env_path_key': 'MLC_UPROF_BIN_WITH_PATH',
60+
'run_script_input': i['run_script_input'],
61+
'recursion_spaces': i['recursion_spaces']})
62+
if r['return'] > 0:
63+
return r
64+
65+
return {'return': 0}
66+
67+
68+
def detect_version(i):
69+
logger = i['automation'].logger
70+
71+
r = i['automation'].parse_version({'match_text': r'AMDuProfSys version\s+([\d.]+)',
72+
'group_number': 1,
73+
'env_key': 'MLC_UPROF_VERSION',
74+
'which_env': i['env']})
75+
if r['return'] > 0:
76+
return r
77+
version = r['version']
78+
79+
logger.info(
80+
f"{i['recursion_spaces']} Detected version: {version}")
81+
82+
return {'return': 0, 'version': version}
83+
84+
85+
def postprocess(i):
86+
87+
env = i['env']
88+
r = detect_version(i)
89+
if r['return'] > 0:
90+
return r
91+
92+
version = r['version']
93+
94+
found_file_path = env['MLC_UPROF_BIN_WITH_PATH']
95+
96+
found_path = os.path.dirname(found_file_path)
97+
98+
env['MLC_UPROF_INSTALLED_PATH'] = os.path.dirname(found_path)
99+
100+
env['+PATH'] = [found_path]
101+
102+
return {'return': 0, 'version': version}
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
alias: get-profiler-uprof
2+
automation_alias: script
3+
automation_uid: 5b4e0237da074764
4+
cache: true
5+
category: Compiler automation
6+
clean_files: []
7+
deps:
8+
- tags: detect,os
9+
- enable_if_env:
10+
MLC_UPROF_ACCEPT_EULA:
11+
- true
12+
MLC_UPROF_URL:
13+
- true
14+
env:
15+
MLC_DOWNLOAD_FINAL_ENV_NAME: MLC_UPROF_TAR_FILE_PATH
16+
extra_cache_tags: uprof,download
17+
force_cache: true
18+
tags: download,file,_mlcutil
19+
update_tags_from_env_with_prefix:
20+
_url.:
21+
- MLC_UPROF_URL
22+
- enable_if_env:
23+
MLC_UPROF_NEEDS_TAR:
24+
- true
25+
env:
26+
MLC_EXTRACT_FINAL_ENV_NAME: MLC_UPROF_DIR_PATH
27+
MLC_EXTRACT_USE_SUBDIR_PATH: yes
28+
MLC_EXTRACT_TO_FOLDER: uprof_install
29+
extra_cache_tags: uprof,extract
30+
force_cache: true
31+
tags: extract,file
32+
update_tags_from_env_with_prefix:
33+
_path.:
34+
- MLC_UPROF_TAR_FILE_PATH
35+
input_mapping:
36+
accept_eula: MLC_UPROF_ACCEPT_EULA
37+
uprof_dir: MLC_UPROF_DIR_PATH
38+
tar_file_path: MLC_UPROF_TAR_FILE_PATH
39+
name: Detect or install AMD uprof
40+
new_env_keys:
41+
- +PATH
42+
- MLC_UPROF_INSTALLED_PATH
43+
- MLC_UPROF_BIN_WITH_PATH
44+
post_deps_off:
45+
- tags: get,compiler-flags
46+
sort: 500
47+
tags:
48+
- get-uprof
49+
- get
50+
- uprof
51+
- uprof-profiler
52+
tests:
53+
run_inputs:
54+
- accept_eula: true
55+
uid: 1530bfcddc3f4fa1
56+
57+
variations:
58+
download-and-install:
59+
# currently not supported as EULA needs to be approved manually
60+
default_version: 5.1
61+
env:
62+
MLC_UPROF_DOWNLOAD: true
63+
group: install-type
64+
local-install:
65+
default: true
66+
env:
67+
MLC_UPROF_DOWNLOAD: false
68+
group: install-type
69+
path.#:
70+
default_variations:
71+
install-type: local-install
72+
env:
73+
MLC_UPROF_DIR_PATH: '#'
74+
75+
versions:
76+
5.1:
77+
env:
78+
MLC_UPROF_NEEDS_TAR: true
79+
MLC_UPROF_URL: https://download.amd.com/developer/eula/uprof/uprof-5-1/AMDuProf_Linux_x64_5.1.701.tar.bz2
80+
MLC_DOWNLOAD_CHECKSUM: a297f370e633505e4c432da4f94c680a
81+
MLC_VERSION: 5.1.701

script/get-profiler-uprof/run.bat

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
%MLC_UPROF_BIN_WITH_PATH% --version > tmp-ver.out
2+
IF %ERRORLEVEL% NEQ 0 EXIT %ERRORLEVEL%
3+

script/get-profiler-uprof/run.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
uprof_bin=${MLC_UPROF_BIN_WITH_PATH}
3+
echo "${uprof_bin} --version"
4+
5+
${uprof_bin} --version > tmp-ver.out
6+
test $? -eq 0 || exit $?

0 commit comments

Comments
 (0)