diff --git a/scripts/Infrastructure/InstructionBlock.py b/scripts/Infrastructure/InstructionBlock.py index ec5310b924b9854cac885450e52aec40184d465f..dfb40d40a008dc12656a84df08b3afe0966d2e94 100644 --- a/scripts/Infrastructure/InstructionBlock.py +++ b/scripts/Infrastructure/InstructionBlock.py @@ -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. @@ -114,6 +128,16 @@ class InstructionBlock: str: The operation specified by kind and index """ 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): """