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
73e2d3ec
Commit
73e2d3ec
authored
Jan 26, 2024
by
Jammer, Tim
Browse files
Options
Downloads
Patches
Plain Diff
Added Functionality to remove/replace operations to InstructionBlock (
#1
)
parent
bf9a7530
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts/Infrastructure/InstructionBlock.py
+43
-1
43 additions, 1 deletion
scripts/Infrastructure/InstructionBlock.py
with
43 additions
and
1 deletion
scripts/Infrastructure/InstructionBlock.py
+
43
−
1
View file @
73e2d3ec
...
@@ -16,8 +16,16 @@ class InstructionBlock:
...
@@ -16,8 +16,16 @@ class InstructionBlock:
- `__str__(self)`: Converts the InstructionBlock instance to a string, replacing placeholders.
- `__str__(self)`: Converts the InstructionBlock instance to a string, replacing placeholders.
"""
"""
def
__init__
(
self
):
def
__init__
(
self
,
name
=
None
):
"""
Initialize an empty InstructionBlock
Parameters:
- name: The name of the block (for referencing this block with the template Manager)
May be None, does not influence the code generated
"""
self
.
operations
=
{
'
all
'
:
[],
'
not0
'
:
[],
}
self
.
operations
=
{
'
all
'
:
[],
'
not0
'
:
[],
}
self
.
name
=
name
# TODO test if op also can be a list of operations
# TODO test if op also can be a list of operations
def
register_operation
(
self
,
op
,
kind
=
'
all
'
):
def
register_operation
(
self
,
op
,
kind
=
'
all
'
):
...
@@ -79,3 +87,37 @@ class InstructionBlock:
...
@@ -79,3 +87,37 @@ class InstructionBlock:
result_str
+=
"
}
\n
"
result_str
+=
"
}
\n
"
return
result_str
return
result_str
def
get_operation
(
self
,
kind
=
all
,
index
=
0
):
"""
Retrieve the operation registered. will Raise IndexError if not present
Parameters:
- kind (
'
all
'
,
'
not0
'
or integer): which ranks should execute the operation
- index (int): the index of the operation within the given kind
Returns:
str: The operation specified by kind and index
"""
return
self
.
operations
[
kind
][
index
]
def
replace_operation
(
self
,
op
,
kind
=
all
,
index
=
0
):
"""
Replace the operation registered. will Raise IndexError if not present
Parameters:
- op (str or MPICall) the new operation
- kind (
'
all
'
,
'
not0
'
or integer): which ranks should execute the operation
- index (int): the index of the operation within the given kind
"""
if
len
(
self
.
operations
[
kind
])
>=
index
:
raise
IndexError
(
"
Operation Not Found
"
)
self
.
operations
[
kind
][
index
]
=
op
def
remove_operation
(
self
,
kind
=
all
,
index
=
0
):
"""
Removes the operation registered. will Raise IndexError if not present
Parameters:
- kind (
'
all
'
,
'
not0
'
or integer): which ranks should execute the operation
- index (int): the index of the operation within the given kind
"""
if
len
(
self
.
operations
[
kind
])
>=
index
:
raise
IndexError
(
"
Operation Not Found
"
)
del
self
.
operations
[
kind
][
index
]
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