Skip to content

Commit 8adfafb

Browse files
rbertranGitHub Enterprise
authored andcommitted
General improvements after a too long hiatus
* [RISCV] Initial BOOM target definition * [FEATURE] Randomness control improvements via environment variables support * [PASSES] Set register to zero in memory initialization when needed * [PASSES] Add relalign support to operand * [MISC] Platform compatibility improvements (windows) * [CI] Update CI deployment * [FIX] Fix shellcheck in bootstrap_environment.sh * [FIX] Speed improvements to mp_epi/mp_seq/mp_seqtune CLI tools * [FIX] Fix regexp import on wrappers Signed-off-by: Ramon Bertran Monfort <rbertra@us.ibm.com>
1 parent b683456 commit 8adfafb

60 files changed

Lines changed: 5688 additions & 3145 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,5 @@ TAGS
5050
doc/error.log
5151
doc/errors.txt
5252
get_pip
53+
targets/z/
54+
.env

.travis.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@ addons:
3636
- zlib1g-dev
3737
- graphviz
3838
- shellcheck
39-
- gcc-8-riscv64-linux-gnu
4039
- gcc-riscv64-linux-gnu
41-
- g++-8-riscv64-linux-gnu
4240
- g++-riscv64-linux-gnu
4341

4442
stages:

bootstrap_environment.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ pip3 install -U $(pip3 list | grep "\." | cut -d " " -f 1)
4444

4545
echo "export PATH=\$PATH:$(find "$(pwd)/targets" -type d -name tools -exec echo -n {}: \;)"
4646
echo "export PYTHONPATH=$scriptpath/src:\$PYTHONPATH"
47-
echo "export MICROPROBEDATA=$scriptpath/targets/"
48-
echo "export MICROPROBETEMPLATES=$(find "$(pwd)/targets" -type d -name templates -exec echo -n {}: \;)"
49-
echo "export MICROPROBEWRAPPERS=$(find "$(pwd)/targets" -type d -name wrappers -exec echo -n {}: \;)"
47+
echo "export MICROPROBEDATA=\"$scriptpath/targets/\""
48+
echo "export MICROPROBETEMPLATES=\"$(find "$(pwd)/targets" -type d -name templates -exec echo -n {}\; \;)\""
49+
echo "export MICROPROBEWRAPPERS=\"$(find "$(pwd)/targets" -type d -name wrappers -exec echo -n {}\; \;)\""
5050
echo "echo Microprobe environment activated"
5151

5252
} >> "$scriptpath/venv-$name/bin/activate"

dev_tools/ci/check_ci.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@
1818

1919
set -e # Finish right after a non-zero return command
2020

21+
set +e
2122
shellcheck -x -s sh ./*.sh dev_tools/*/*.sh ./targets/*/dev_tools/*/*.sh
23+
set -e
24+
2225
# Code Conventions (always run)
2326
./dev_tools/ci/code_conventions_001_pycodestyle.sh
2427
./dev_tools/ci/code_conventions_002_pylint.sh
@@ -32,4 +35,4 @@ shellcheck -x -s sh ./*.sh dev_tools/*/*.sh ./targets/*/dev_tools/*/*.sh
3235
# Build Release (always run)
3336
./dev_tools/ci/build_001_distribution.sh
3437
# Test Release Deploy (always run)
35-
./dev_tools/ci/test_deploy_001_install.sh 2.7
38+
./dev_tools/ci/test_deploy_001_install.sh 3.9

dev_tools/ci/environment.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ if [ "$TRAVIS" = "true" ] && [ "$CI" = "true" ]; then
5353
MAXJOBS=1
5454
export NOSEOPTS=" -d -v -e load_tests --exe --processes=$MAXJOBS --detailed-errors --process-timeout=$TIMEOUT "
5555

56-
MP_TESTING_COMPILER_RISCV_V22=$(command -v riscv64-linux-gnu-gcc-8)
56+
MP_TESTING_COMPILER_RISCV_V22=$(command -v riscv64-linux-gnu-gcc)
5757
export MP_TESTING_COMPILER_RISCV_V22
5858
else
5959
export NICE="nice -n 1"
@@ -66,7 +66,7 @@ else
6666
# export NOSEOPTS="-d -v -e load_tests --exe --processes=$MAXJOBS -x --detailed-errors --process-timeout=$TIMEOUT"
6767

6868
set +e
69-
MP_TESTING_COMPILER_RISCV_V22=$(command -v riscv64-linux-gnu-gcc-8)
69+
MP_TESTING_COMPILER_RISCV_V22=$(command -v riscv64-linux-gnu-gcc)
7070
export MP_TESTING_COMPILER_RISCV_V22
7171
set -e
7272

@@ -280,9 +280,9 @@ fi
280280
# Add PATHs
281281
export PYTHONPATH="$WORKSPACE/src/:$PYTHONPATH"
282282
export MICROPROBEDATA="$WORKSPACE/targets/"
283-
MICROPROBETEMPLATES="$(find "$(pwd)"/targets -type d -name templates -exec echo -n {}: \;)"
283+
MICROPROBETEMPLATES="$(find "$(pwd)"/targets -type d -name templates -exec echo -n {}\; \;)"
284284
export MICROPROBETEMPLATES
285-
MICROPROBEWRAPPERS="$(find "$(pwd)"/targets -type d -name wrappers -exec echo -n {}: \;)"
285+
MICROPROBEWRAPPERS="$(find "$(pwd)"/targets -type d -name wrappers -exec echo -n {}\; \;)"
286286
export MICROPROBEWRAPPERS
287287
PATH=$PATH:$(find "$(pwd)/targets" -type d -name tools -exec echo -n {}: \;)
288288
export PATH

doc/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ test5: ./source/examples_outputs/example_mp_c2mpt.mpt
104104
./source/examples_outputs/example_mp_c2mpt.mpt: ../targets/riscv/tests/tools/c2mpt_test003.c ../targets/generic/tools/mp_c2mpt.py
105105
rm -f ./source/examples_outputs/example_mp_c2mpt.mpt
106106
mkdir -p ./source/examples_outputs/
107-
mp_c2mpt.py -T riscv_v22-riscv_generic-riscv64_linux_gcc -P ../targets -i ../targets/riscv/tests/tools/c2mpt_test003.c -O ./source/examples_outputs/example_mp_c2mpt.mpt --target-c-compiler riscv64-linux-gnu-gcc-8 --target-objdump riscv64-linux-gnu-objdump --target-c-compiler-flags="-O3 -march=rv64gc"
107+
mp_c2mpt.py -T riscv_v22-riscv_generic-riscv64_linux_gcc -P ../targets -i ../targets/riscv/tests/tools/c2mpt_test003.c -O ./source/examples_outputs/example_mp_c2mpt.mpt --target-c-compiler riscv64-linux-gnu-gcc --target-objdump riscv64-linux-gnu-objdump --target-c-compiler-flags="-O3 -march=rv64gc"
108108

109109
test6: ./source/examples_outputs/example_mpt2trace.output
110110

src/microprobe/__init__.py

Lines changed: 109 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@
4444
- **verbosity** (:class:`~.int`): Verbosity level. It controls the verbosity
4545
level of the logger (Default: 0). Valid values are:
4646
47-
- 0 : quiet
48-
- 1 : critical messages
49-
- 2 : error messages
50-
- 3 : warning messages
51-
- 4 : info messages
47+
- 0: quiet
48+
- 1: critical messages
49+
- 2: error messages
50+
- 3: warning messages
51+
- 4: info messages
5252
5353
- **debug** (:class:`bool`): Enable debug mode (Default: False). If enabled,
5454
lots of output is generated, useful for developers.
@@ -117,18 +117,13 @@
117117

118118
# Built-in modules
119119
import ast
120+
import configparser
120121
import os
121122
import warnings
122-
import configparser
123-
124-
# Third party modules
125123

126124
# Own modules
127125
from microprobe.utils.config import MicroprobeDefaultConfiguration
128126

129-
# Local modules
130-
131-
132127
# Constants
133128

134129
#: Microprobe global configuration dictionary that map configuration options
@@ -143,11 +138,9 @@
143138
#: installation directory, at the user home directory or in the current
144139
#: execution directory.
145140
_DEFAULT_CONFIG_FILE_LOCATIONS = [
146-
os.path.join(
147-
os.path.dirname(__file__), _DEFAULT_CONFIG_FILE_NAME
148-
),
149-
os.path.expanduser('~/.%s' % _DEFAULT_CONFIG_FILE_NAME),
150-
os.path.join(os.getcwd(), _DEFAULT_CONFIG_FILE_NAME)
141+
os.path.join(os.path.dirname(__file__), _DEFAULT_CONFIG_FILE_NAME),
142+
os.path.expanduser(f"~/.{_DEFAULT_CONFIG_FILE_NAME}"),
143+
os.path.join(os.getcwd(), _DEFAULT_CONFIG_FILE_NAME),
151144
]
152145

153146
#: Generic configparser to support the reading of configuration files
@@ -162,50 +155,57 @@
162155

163156
# Initialization
164157
if "MICROPROBERC" in os.environ:
165-
_DEFAULT_CONFIG_FILE_LOCATIONS = os.environ["MICROPROBERC"].split(":") \
166-
+ _DEFAULT_CONFIG_FILE_LOCATIONS
158+
_DEFAULT_CONFIG_FILE_LOCATIONS = (
159+
os.environ["MICROPROBERC"].split(":") + _DEFAULT_CONFIG_FILE_LOCATIONS
160+
)
167161

168162
_CONFIG.read(_DEFAULT_CONFIG_FILE_LOCATIONS)
169163

170164
for section in ["DEFAULT"] + _CONFIG.sections():
171165
for option, value in _CONFIG.items(section):
172166
value = value.strip()
173167
if option in MICROPROBE_RC:
174-
value = value.replace("MICROPROBE_INSTALL_DIR",
175-
os.path.dirname(__file__))
176-
if ((value.endswith(']') and value.startswith('[')) or
177-
value.replace("0x", "").replace(".", "").isdigit() or
178-
value in ['True', 'False']):
168+
value = value.replace(
169+
"MICROPROBE_INSTALL_DIR", os.path.dirname(__file__)
170+
)
171+
if (
172+
(value.endswith("]") and value.startswith("["))
173+
or value.replace("0x", "").replace(".", "").isdigit()
174+
or value in ["True", "False"]
175+
):
176+
# value = r'{}'.format(value)
177+
value = value.encode("unicode_escape").decode()
179178
MICROPROBE_RC[option] = ast.literal_eval(value)
180179
else:
181180
MICROPROBE_RC[option] = value
182181
else:
183-
warnings.warn("Ignoring option: %s" % option)
182+
warnings.warn(f"Ignoring option: {option}")
184183

185184
# Environment configuration
186185
if "MICROPROBEDATA" in os.environ:
187186
MICROPROBE_RC["default_paths"] += [
188187
os.path.abspath(path)
189-
for path in os.environ["MICROPROBEDATA"].split(":")
190-
if path != ''
188+
for path in os.environ["MICROPROBEDATA"].split(";")
189+
if path != ""
191190
]
192191
MICROPROBE_RC["architecture_paths"] += MICROPROBE_RC["default_paths"][:]
193-
MICROPROBE_RC["microarchitecture_paths"] += \
194-
MICROPROBE_RC["default_paths"][:]
192+
MICROPROBE_RC["microarchitecture_paths"] += MICROPROBE_RC["default_paths"][
193+
:
194+
]
195195
MICROPROBE_RC["environment_paths"] += MICROPROBE_RC["default_paths"][:]
196196

197197
if "MICROPROBETEMPLATES" in os.environ:
198-
MICROPROBE_RC['template_paths'] += [
198+
MICROPROBE_RC["template_paths"] += [
199199
os.path.abspath(elem)
200-
for elem in os.environ["MICROPROBETEMPLATES"].split(":")
201-
if elem != ''
200+
for elem in os.environ["MICROPROBETEMPLATES"].split(";")
201+
if elem != ""
202202
]
203203

204204
if "MICROPROBEWRAPPERS" in os.environ:
205205
MICROPROBE_RC["wrapper_paths"] += [
206206
os.path.abspath(elem)
207-
for elem in os.environ["MICROPROBEWRAPPERS"].split(":")
208-
if elem != ''
207+
for elem in os.environ["MICROPROBEWRAPPERS"].split(";")
208+
if elem != ""
209209
]
210210

211211
if "MICROPROBEDEBUG" in os.environ:
@@ -225,26 +225,91 @@
225225
elif os.environ["MICROPROBEASMHEXFMT"].strip() == "none":
226226
MICROPROBE_RC["hex_none"] = True
227227
else:
228-
warnings.warn("Ignoring option: %s in env var MICROPROBEASMHEXFMT" %
229-
os.environ["MICROPROBEASMHEXFMT"])
228+
warnings.warn(
229+
"Ignoring option: %s in env var MICROPROBEASMHEXFMT"
230+
% os.environ["MICROPROBEASMHEXFMT"]
231+
)
230232

231233
if "MICROPROBEPARALLELTHRESHOLD" in os.environ:
232234
try:
233-
MICROPROBE_RC["parallel_threshold"] = \
234-
int(os.environ["MICROPROBEPARALLELTHRESHOLD"].strip())
235+
MICROPROBE_RC["parallel_threshold"] = int(
236+
os.environ["MICROPROBEPARALLELTHRESHOLD"].strip()
237+
)
235238
except ValueError:
236239
warnings.warn(
237-
"Ignoring option: %s in env var MICROPROBEPARALLELTHRESHOLD" %
238-
os.environ["MICROPROBEPARALLELTHRESHOLD"])
240+
"Ignoring option: %s in env var MICROPROBEPARALLELTHRESHOLD"
241+
% os.environ["MICROPROBEPARALLELTHRESHOLD"]
242+
)
239243

240244
if "MICROPROBECPUS" in os.environ:
241245
try:
242-
MICROPROBE_RC["cpus"] = \
243-
int(os.environ["MICROPROBECPUS"].strip())
246+
MICROPROBE_RC["cpus"] = int(os.environ["MICROPROBECPUS"].strip())
244247
except ValueError:
245248
warnings.warn(
246-
"Ignoring option: %s in env var MICROPROBECPUS" %
247-
os.environ["MICROPROBECPUS"])
249+
"Ignoring option: %s in env var MICROPROBECPUS"
250+
% os.environ["MICROPROBECPUS"]
251+
)
248252

249253
if "MICROPROBENOCACHE" in os.environ:
250-
MICROPROBE_RC['no_cache'] = True
254+
MICROPROBE_RC["no_cache"] = True
255+
256+
257+
if "MICROPROBESEED" not in os.environ:
258+
MICROPROBE_RC["seed"] = 13
259+
else:
260+
try:
261+
MICROPROBE_RC["seed"] = int(os.environ["MICROPROBESEED"].strip())
262+
except ValueError:
263+
warnings.warn(
264+
"Ignoring option: %s in env var MICROPROBESEED"
265+
% os.environ["MICROPROBESEED"]
266+
)
267+
MICROPROBE_RC["seed"] = 13
268+
269+
if "MICROPROBEPATTERN" not in os.environ:
270+
MICROPROBE_RC["pattern"] = "random"
271+
MICROPROBE_RC["pattern_update"] = False
272+
else:
273+
try:
274+
if "_" in os.environ["MICROPROBEPATTERN"].strip():
275+
val = os.environ["MICROPROBEPATTERN"].strip().split("_")[0]
276+
update = os.environ["MICROPROBEPATTERN"].strip().split("_")[1]
277+
else:
278+
val = os.environ["MICROPROBEPATTERN"].strip()
279+
update = False
280+
281+
MICROPROBE_RC["pattern"] = int(val, 0)
282+
MICROPROBE_RC["pattern_update"] = update
283+
284+
if MICROPROBE_RC["pattern"] < 0 or update not in [
285+
"rotate",
286+
"negate",
287+
False,
288+
]:
289+
warnings.warn(
290+
"Ignoring option: %s in env var MICROPROBEPATTERN"
291+
% os.environ["MICROPROBEPATTERN"]
292+
)
293+
MICROPROBE_RC["pattern"] = "random"
294+
MICROPROBE_RC["pattern_update"] = False
295+
elif MICROPROBE_RC["pattern"].bit_length() == 0:
296+
MICROPROBE_RC["pattern"] = 0
297+
else:
298+
width = MICROPROBE_RC["pattern"].bit_length()
299+
pattern = MICROPROBE_RC["pattern"] & ((1 << width) - 1)
300+
if width >= 64:
301+
MICROPROBE_RC["pattern"] = pattern & ((1 << 64) - 1)
302+
result = 0
303+
shift = 0
304+
while shift < 64:
305+
result |= pattern << shift
306+
shift += width
307+
MICROPROBE_RC["pattern"] = result & ((1 << 64) - 1)
308+
309+
except ValueError:
310+
warnings.warn(
311+
"Ignoring option: %s in env var MICROPROBEPATTERN"
312+
% os.environ["MICROPROBEPATTERN"]
313+
)
314+
MICROPROBE_RC["pattern"] = "random"
315+
MICROPROBE_RC["pattern_update"] = False

0 commit comments

Comments
 (0)