Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MPI-BugBench
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
High Performance Computing - Public
MPI-BugBench
Commits
2236f39c
Commit
2236f39c
authored
1 year ago
by
Jammer, Tim
Browse files
Options
Downloads
Patches
Plain Diff
Ported Unmatched error generator to new TemplateManager
parent
36d5f394
No related branches found
No related tags found
1 merge request
!14
Infrastructure: Remove Instructionblock
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
scripts/Infrastructure/Template.py
+45
-27
45 additions, 27 deletions
scripts/Infrastructure/Template.py
scripts/Infrastructure/TemplateFactory.py
+1
-1
1 addition, 1 deletion
scripts/Infrastructure/TemplateFactory.py
with
46 additions
and
28 deletions
scripts/Infrastructure/Template.py
+
45
−
27
View file @
2236f39c
...
...
@@ -115,9 +115,10 @@ class TemplateManager:
code_string
=
""
current_rank
=
'
all
'
for
inst
in
self
.
_instructions
:
if
inst
.
get_rank_executing
!=
current_rank
:
if
inst
.
get_rank_executing
()
!=
current_rank
:
if
current_rank
!=
'
all
'
:
code_string
=
code_string
+
"
}
\n
"
# end previous if
code_string
=
code_string
+
"
}
\n
"
# end previous if
current_rank
=
inst
.
get_rank_executing
()
if
current_rank
==
'
not0
'
:
code_string
=
code_string
+
"
if (rank!=0){
\n
"
...
...
@@ -164,7 +165,7 @@ class TemplateManager:
i
.
set_identifier
(
identifier
)
if
rank_to_execute
is
not
None
:
for
i
in
inst
:
i
.
set_rank
s
_executing
(
rank_to_execute
)
i
.
set_rank_executing
(
rank_to_execute
)
self
.
_instructions
.
extend
(
inst
)
elif
isinstance
(
inst
,
str
):
if
rank_to_execute
is
not
None
:
...
...
@@ -173,11 +174,11 @@ class TemplateManager:
# use default ('all')
self
.
_instructions
.
append
(
Instruction
(
inst
,
identifier
=
identifier
))
else
:
assert
isinstance
(
inst
,
Instruction
)
if
identifier
is
not
None
:
inst
.
set_identifier
(
identifier
)
if
rank_to_execute
is
not
None
:
for
i
in
inst
:
i
.
set_ranks_executing
(
rank_to_execute
)
inst
.
set_rank_executing
(
rank_to_execute
)
self
.
_instructions
.
append
(
inst
)
def
get_version
(
self
)
->
str
:
...
...
@@ -251,21 +252,25 @@ class TemplateManager:
raise
ValueError
(
"
Neither Both block name nor index is given
"
)
def
__get_instruction_index
(
self
,
ident
ifier
:
str
)
->
typing
.
List
[
int
]:
def
__get_instruction_index
(
self
,
ident
:
str
|
Instruction
)
->
typing
.
List
[
int
]:
"""
internal helper function to receive the indices of instructions with ghe given identifier
internal helper function to receive the indices of instructions with ghe given identifier
oris the given isntruction
"""
return
[
idx
for
inst
,
idx
in
enumerate
(
self
.
_instructions
)
if
inst
.
get_identifier
()
==
identifier
]
def
insert_instruction
(
self
,
new_instruction
:
Instruction
,
after_instruction
:
str
|
int
=
None
,
before_instruction
:
str
|
int
=
None
):
if
isinstance
(
ident
,
str
):
return
[
idx
for
idx
,
inst
in
enumerate
(
self
.
_instructions
)
if
inst
.
get_identifier
()
==
ident
]
if
isinstance
(
ident
,
Instruction
):
return
[
idx
for
idx
,
inst
in
enumerate
(
self
.
_instructions
)
if
inst
==
ident
]
raise
ValueError
(
"
Provide string or instruction
"
)
def
insert_instruction
(
self
,
new_instruction
:
Instruction
,
after_instruction
:
Instruction
|
str
|
int
=
None
,
before_instruction
:
Instruction
|
str
|
int
=
None
):
"""
Inserts a new instruction into the template.
Parameters:
new_instruction (Instruction): The new instruction to insert.
after_instruction (str | int): The instruction after which to insert the new one (identifier or index).
before_instruction (str | int): The instruction before which to insert the new one (identifier or index).
after_instruction (
Instruction|
str | int): The instruction after which to insert the new one (identifier or index).
before_instruction (
Instruction|
str | int): The instruction before which to insert the new one (identifier or index).
Raises:
ValueError: if both before and after are provided
IndexError: if it finds multiple places to insert by identifier
...
...
@@ -280,7 +285,6 @@ class TemplateManager:
if
isinstance
(
after_instruction
,
int
):
idx_to_use
=
1
+
after_instruction
else
:
assert
isinstance
(
after_instruction
,
str
)
inst_idx_list
=
self
.
__get_instruction_index
(
after_instruction
)
if
len
(
inst_idx_list
)
!=
1
:
raise
IndexError
(
"
Did not find place to insert
"
)
...
...
@@ -289,7 +293,6 @@ class TemplateManager:
if
isinstance
(
before_instruction
,
int
):
idx_to_use
=
before_instruction
else
:
assert
isinstance
(
before_instruction
,
str
)
inst_idx_list
=
self
.
__get_instruction_index
(
before_instruction
)
if
len
(
inst_idx_list
)
!=
1
:
raise
IndexError
(
"
Did not find place to insert
"
)
...
...
@@ -297,20 +300,29 @@ class TemplateManager:
self
.
_instructions
.
insert
(
idx_to_use
,
new_instruction
)
def
remove_instruction
(
self
,
identifier
:
str
=
None
,
idx
:
int
|
typing
.
List
[
int
]
=
None
):
def
remove_instruction
(
self
,
identifier
:
str
=
None
,
idx
:
int
|
typing
.
List
[
int
]
=
None
,
instruction
:
Instruction
|
typing
.
List
[
Instruction
]
=
None
):
"""
Removes an instruction from the template.
Parameters:
identifier (str): The identifier of the instruction to remove.
idx (int | List[int]): The index or list of indices of the instruction(s) to remove.
instruction (Instruction | List[Instruction]) the list of instructions to remove
"""
# assert only one param is not None
parameters
=
[
identifier
,
idx
]
if
parameters
.
count
(
None
)
!=
1
:
parameters
=
[
identifier
,
idx
,
instruction
]
if
parameters
.
count
(
None
)
!=
2
:
raise
ValueError
(
"
Only one parameter is allowed to be specified
"
)
if
instruction
is
not
None
:
if
isinstance
(
instruction
,
Instruction
):
instruction
=
[
instruction
]
for
instruction
in
instruction
:
self
.
_instructions
.
remove
(
instruction
)
return
idxs_to_remove
=
[]
if
idx
is
not
None
:
if
isinstance
(
idx
,
int
):
...
...
@@ -327,13 +339,15 @@ class TemplateManager:
self
.
_instructions
=
[
elem
for
idx
,
elem
in
enumerate
(
self
.
_instructions
)
if
idx
not
in
idxs_to_remove
]
def
replace_instruction
(
self
,
new_instruction
=
Instruction
,
identifier
:
str
=
None
,
def
replace_instruction
(
self
,
new_instruction
=
Instruction
,
old_instruction
:
Instruction
|
List
[
Instruction
]
=
None
,
identifier
:
str
=
None
,
idx
:
int
|
typing
.
List
[
int
]
=
None
):
"""
Replaces an instruction in the template with a new one.
Parameters:
new_instruction (Instruction | List[Instruction]): The new instruction(s) to replace with.
old_instruction (Instruction | List[Instruction]): The old instruction(s) to replace.
identifier (str): The identifier of the instruction to replace.
idx (int | List[int]): The index or list of indices of the instruction(s) to replace.
Raises
...
...
@@ -341,8 +355,8 @@ class TemplateManager:
or if both idx and identifier are provided
Notes: The instructions to be replaced must not be in contiguous order
"""
parameters
=
[
identifier
,
idx
]
if
parameters
.
count
(
None
)
!=
1
:
parameters
=
[
old_instruction
,
identifier
,
idx
]
if
parameters
.
count
(
None
)
!=
2
:
raise
ValueError
(
"
Only one parameter is allowed to be specified
"
)
new_instruction_list
=
[]
...
...
@@ -351,6 +365,10 @@ class TemplateManager:
else
:
new_instruction_list
=
new_instruction
if
old_instruction
is
not
None
:
raise
EnvironmentError
(
"
NOT IMPLEMENTED
"
)
# TODO implement
idxs_to_replace
=
[]
if
idx
is
not
None
:
if
isinstance
(
idx
,
int
):
...
...
This diff is collapsed.
Click to expand it.
scripts/Infrastructure/TemplateFactory.py
+
1
−
1
View file @
2236f39c
...
...
@@ -112,7 +112,7 @@ def get_send_recv_template(send_func: str = "mpi_isend", recv_func: str | typing
if
recv_func
in
probe_pairs
:
if
recv_func
in
[[
"
mpi_improbe
"
,
"
mpi_mrecv
"
],
[
"
mpi_improbe
"
,
"
mpi_imrecv
"
]]:
tm
.
insert_instruction
(
Instruction
(
"
while (!flag){
"
,
rank
=
0
),
before_instruction
=
"
MPICALL
"
)
tm
.
insert_instruction
(
Instruction
(
"
while (!flag){
"
,
rank
=
0
),
before_instruction
=
r
)
# insertion before the improbe call
tm
.
register_instruction
(
"
}
"
,
rank_to_execute
=
0
)
# end while
tm
.
register_instruction
(
CorrectMPICallFactory
.
get
(
recv_func
[
1
]),
rank_to_execute
=
0
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment