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
15c33d89
Commit
15c33d89
authored
1 year ago
by
Jammer, Tim
Browse files
Options
Downloads
Patches
Plain Diff
Allowed the Instruction block to create instructions in place from srings for convenience
parent
f8da1715
No related branches found
No related tags found
1 merge request
!9
Infrastructure: Type Hints, Instruction class and lists of instructions
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts/Infrastructure/InstructionBlock.py
+15
-3
15 additions, 3 deletions
scripts/Infrastructure/InstructionBlock.py
with
15 additions
and
3 deletions
scripts/Infrastructure/InstructionBlock.py
+
15
−
3
View file @
15c33d89
...
...
@@ -33,7 +33,7 @@ class InstructionBlock:
assert
not
isinstance
(
name
,
int
)
self
.
name
=
name
def
register_operation
(
self
,
op
:
Instruction
|
typing
.
List
[
Instruction
],
kind
:
str
|
int
=
'
all
'
):
def
register_operation
(
self
,
op
:
str
|
Instruction
|
typing
.
List
[
Instruction
],
kind
:
str
|
int
=
'
all
'
):
"""
Registers an operation based on rank.
...
...
@@ -43,7 +43,11 @@ class InstructionBlock:
- all: all Ranks execute this operation
- not0: all Ranks but the Root (rank 0) execute
- Or the integer of the rank that should execute
Note: if a str is passed as the operation, it will create a new Instruction from the given string
"""
if
isinstance
(
op
,
str
):
op
=
Instruction
(
op
)
if
kind
==
'
all
'
:
if
isinstance
(
op
,
list
):
self
.
operations
[
'
all
'
].
extend
(
op
)
...
...
@@ -132,7 +136,7 @@ class InstructionBlock:
as_int
=
int
(
index
)
# will Raise ValueError if not integer
return
self
.
operations
[
kind
][
as_int
]
def
replace_operation
(
self
,
op
:
Instruction
|
typing
.
List
[
Instruction
],
kind
:
str
|
int
=
'
all
'
,
def
replace_operation
(
self
,
op
:
str
|
Instruction
|
typing
.
List
[
Instruction
],
kind
:
str
|
int
=
'
all
'
,
index
:
str
|
int
=
0
):
"""
Replace the operation registered. will Raise IndexError if not present
...
...
@@ -142,20 +146,25 @@ class InstructionBlock:
- index (
'
all
'
or int): the index of the operation within the given kind;
'
all
'
means all operations will be replaced with the given list
Notes : if one wants to replace all operations one needs to provide a list
if one only wants to replace one operation: no list of operations is allowed
if a string is passed as the operation, it will create a new Instruction
"""
if
isinstance
(
op
,
str
):
op
=
Instruction
(
op
)
if
index
==
'
all
'
:
if
not
isinstance
(
op
,
list
):
raise
ValueError
(
'
Provide List for replacement
'
)
self
.
operations
[
kind
]
=
op
else
:
as_int
=
int
(
index
)
# will Raise ValueError if not integer
print
(
op
)
if
not
isinstance
(
op
,
Instruction
):
raise
ValueError
(
'
Provide Instruction
'
)
if
len
(
self
.
operations
[
kind
])
<
as_int
:
raise
IndexError
(
"
Operation Not Found
"
)
self
.
operations
[
kind
][
as_int
]
=
op
def
insert_operation
(
self
,
op
:
Instruction
|
typing
.
List
[
Instruction
],
kind
:
str
|
int
=
'
all
'
,
def
insert_operation
(
self
,
op
:
str
|
Instruction
|
typing
.
List
[
Instruction
],
kind
:
str
|
int
=
'
all
'
,
before_index
:
int
=
0
):
"""
Inserts an operation before the specified one. will Raise IndexError if not present
...
...
@@ -163,7 +172,10 @@ class InstructionBlock:
- op the new operation or list of operations
- kind (
'
all
'
,
'
not0
'
or integer): which ranks should execute the operation
- index (int): the index of the operation within the given kind
note: if str is passed as the operation, it will Create a New Instruction
"""
if
isinstance
(
op
,
str
):
op
=
Instruction
(
op
)
as_int
=
int
(
before_index
)
# will Raise ValueError if not integer
if
len
(
self
.
operations
[
kind
])
<
before_index
:
raise
IndexError
(
"
Operation Not Found
"
)
...
...
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