Skip to content
Snippets Groups Projects
Verified Commit 1747635a authored by Simon Schwitanski's avatar Simon Schwitanski :slight_smile:
Browse files

InstructionBlock: Add get_operations and register_operations for lists of operations

parent b3a7aed6
No related branches found
No related tags found
3 merge requests!9Infrastructure: Type Hints, Instruction class and lists of instructions,!8Draft: RMA,!7InstructionBlock: Add get_operations and register_operations for lists of operations
......@@ -50,6 +50,20 @@ class InstructionBlock:
self.operations[as_int] = []
self.operations[as_int].append(op)
def register_operations(self, ops, kind='all'):
"""
Registers a list of operations based on rank.
Parameters:
- ops: The operations to register.
- kind: Rank to execute the operation ('all', 'not0', or integer).
- all: all Ranks execute this operation
- not0: all Ranks but the Root (rank 0) execute
- Or the integer of the rank that should execute
"""
for op in ops:
self.register_operation(op, kind)
def get_version(self):
"""
Retrieves the minimum required MPI version.
......@@ -115,6 +129,16 @@ class InstructionBlock:
"""
return self.operations[kind][index]
def get_operations(self, kind='all'):
"""
Retrieve all operations registered for the given kind.
Parameters:
- kind ('all','not0' or integer): which ranks should execute the operation
Returns:
str: List of all operations with given kind
"""
return self.operations[kind]
def replace_operation(self, op, kind='all', index=0):
"""
Replace the operation registered. will Raise IndexError if not present
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment