Skip to content

Commit 8787d77

Browse files
Merge pull request #67 from discopop-project/refactor/TP/commandLineArguments
Correction of Task Pattern command line arguments
2 parents d8cd6e0 + c09acc8 commit 8787d77

File tree

4 files changed

+25
-17
lines changed

4 files changed

+25
-17
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
uses: actions/checkout@v2
4444
- name: "Install Dependencies"
4545
run: |
46-
sudo apt-get remove clang-10 clang-9
46+
sudo apt-get remove clang-10 clang-9 clang-11
4747
sudo apt-get install libclang-8-dev clang-8 llvm-8
4848
- name: "Build DiscoPoP Profiler"
4949
run: |

discopop_explorer/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919

2020
def run(cu_xml: str, dep_file: str, loop_counter_file: str, reduction_file: str, plugins: List[str],
2121
file_mapping: Optional[str] = None, cu_inst_result_file: Optional[str] = None,
22-
llvm_cxxfilt_path: Optional[str] = None, discopop_build_path: Optional[str] = None) -> DetectionResult:
22+
llvm_cxxfilt_path: Optional[str] = None, discopop_build_path: Optional[str] = None,
23+
enable_task_pattern: bool = False) -> DetectionResult:
2324
pet = PETGraphX.from_parsed_input(*parse_inputs(cu_xml, dep_file,
2425
loop_counter_file, reduction_file))
2526
# TODO add visualization
@@ -39,7 +40,7 @@ def run(cu_xml: str, dep_file: str, loop_counter_file: str, reduction_file: str,
3940

4041
res: DetectionResult = pattern_detector.detect_patterns(cu_xml, dep_file, loop_counter_file, reduction_file,
4142
file_mapping, cu_inst_result_file, llvm_cxxfilt_path,
42-
discopop_build_path)
43+
discopop_build_path, enable_task_pattern)
4344

4445
for plugin_name in plugins:
4546
p = plugin_source.load_plugin(plugin_name)

discopop_explorer/__main__.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
Usage:
1212
discopop_explorer [--path <path>] [--cu-xml <cuxml>] [--dep-file <depfile>] [--plugins <plugs>] \
1313
[--loop-counter <loopcount>] [--reduction <reduction>] [--json <json_out>] [--fmap <fmap>] \
14-
[--cu-inst-res <cuinstres>] [--llvm-cxxfilt-path <cxxfp>] [--discopop-build-path=<dpbuildpath>] \
15-
[--generate-data-cu-inst <outputdir>]
14+
[--task-pattern] [--cu-inst-res <cuinstres>] [--llvm-cxxfilt-path <cxxfp>] \
15+
[--dp-build-path=<dpbuildpath>] [--generate-data-cu-inst <outputdir>]
1616
1717
Options:
1818
--path=<path> Directory with input data [default: ./]
@@ -23,10 +23,12 @@
2323
--fmap=<fmap> File mapping [default: FileMapping.txt]
2424
--json=<json_out> Json output
2525
--plugins=<plugs> Plugins to execute
26-
--cu-inst-res=<cuinstres> CU instantiation result file. Task Pattern Detector is executed if this option is set.
27-
--llvm-cxxfilt-path=<cxxfp> Path to llvm-cxxfilt executable. Required for Task Pattern Detector
26+
--task-pattern Enables the task parallelism pattern identification.
27+
Requires --cu-inst-res and --llvm-cxxfilt-path to be set.
28+
--cu-inst-res=<cuinstres> CU instantiation result file.
29+
--llvm-cxxfilt-path=<cxxfp> Path to llvm-cxxfilt executable. Required for task pattern detector
2830
if non-standard path should be used.
29-
--discopop-build-path=<dpbuildpath> Path to DiscoPoP build folder. Required, if --cu-inst-res is set.
31+
--dp-build-path=<dpbuildpath> Path to DiscoPoP build folder [default: discopop/build]
3032
--generate-data-cu-inst=<outputdir> Generates Data_CUInst.txt file and stores it in the given directory.
3133
Stops the regular execution of the discopop_explorer.
3234
Requires --cu-xml, --dep-file, --loop-counter, --reduction.
@@ -40,6 +42,7 @@
4042

4143
from docopt import docopt # type:ignore
4244
from schema import Schema, Use, SchemaError # type:ignore
45+
from pathlib import Path
4346

4447
from . import run, __version__
4548
from .json_serializer import PatternInfoSerializer
@@ -53,9 +56,10 @@
5356
'--fmap': Use(str),
5457
'--plugins': Use(str),
5558
'--json': Use(str),
59+
'--task-pattern': Use(bool),
5660
'--cu-inst-res': Use(str),
5761
'--llvm-cxxfilt-path': Use(str),
58-
'--discopop-build-path': Use(str),
62+
'--dp-build-path': Use(str),
5963
'--generate-data-cu-inst': Use(str),
6064
})
6165

@@ -86,6 +90,12 @@ def main():
8690
reduction_file = get_path(path, arguments['--reduction'])
8791
file_mapping = get_path(path, 'FileMapping.txt')
8892
cu_inst_result_file = get_path(path, arguments['--cu-inst-res'])
93+
if arguments['--dp-build-path'] != 'None':
94+
discopop_build_path=arguments['--dp-build-path']
95+
else:
96+
# set default discopop build path
97+
discopop_build_path = Path(__file__).resolve().parent.parent
98+
discopop_build_path = os.path.join(discopop_build_path, "build")
8999

90100
for file in [cu_xml, dep_file, loop_counter_file, reduction_file]:
91101
if not os.path.isfile(file):
@@ -105,7 +115,7 @@ def main():
105115

106116
res = run(cu_xml, dep_file, loop_counter_file, reduction_file, plugins, file_mapping=file_mapping,
107117
cu_inst_result_file=cu_inst_result_file, llvm_cxxfilt_path=arguments['--llvm-cxxfilt-path'],
108-
discopop_build_path=arguments['--discopop-build-path'])
118+
discopop_build_path=discopop_build_path, enable_task_pattern=arguments['--task-pattern'])
109119

110120
end = time.time()
111121

discopop_explorer/pattern_detection.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def __merge(self, loop_type: bool, remove_dummies: bool):
6060
self.pet.g.remove_node(n)
6161

6262
def detect_patterns(self, cu_dict, dependencies, loop_data, reduction_vars, file_mapping, cu_inst_result_file,
63-
llvm_cxxfilt_path, discopop_build_path):
63+
llvm_cxxfilt_path, discopop_build_path, enable_task_pattern):
6464
"""Runs pattern discovery on the CU graph
6565
"""
6666
self.__merge(False, True)
@@ -74,10 +74,7 @@ def detect_patterns(self, cu_dict, dependencies, loop_data, reduction_vars, file
7474
res.geometric_decomposition = detect_gd(self.pet)
7575

7676
# check if task pattern should be enabled
77-
if file_mapping is None or cu_inst_result_file is None:
78-
return res
79-
if cu_inst_result_file.endswith("/None"):
80-
return res
81-
res.task = detect_tp(cu_dict, dependencies, loop_data, reduction_vars, file_mapping, cu_inst_result_file,
82-
llvm_cxxfilt_path, discopop_build_path)
77+
if enable_task_pattern:
78+
res.task = detect_tp(cu_dict, dependencies, loop_data, reduction_vars, file_mapping, cu_inst_result_file,
79+
llvm_cxxfilt_path, discopop_build_path)
8380
return res

0 commit comments

Comments
 (0)