Skip to content
Snippets Groups Projects
Commit 91e29056 authored by Jammer, Tim's avatar Jammer, Tim
Browse files

added rank field for Instruction

parent 7b684fd6
No related branches found
No related tags found
1 merge request!14Infrastructure: Remove Instructionblock
#! /usr/bin/python3
from __future__ import annotations
from typing_extensions import override
from scripts.Infrastructure.Instruction import Instruction
......@@ -26,7 +28,7 @@ alloc_template = """
class AllocCall(Instruction):
@override
def __init__(self, type: str, num_elements: str, name: str = "buf", use_malloc: bool = False,
identifier: str = None):
rank: str | int = 'all', identifier: str = None):
"""
Creates a New allocation Call
......@@ -36,7 +38,7 @@ class AllocCall(Instruction):
name: name of buffer variable
use_malloc: True: use Malloc, False: use calloc for allocation
"""
super().__init__("", identifier)
super().__init__("", rank,identifier)
self._use_malloc = use_malloc
self._type = type
self._num_elements = num_elements
......
#! /usr/bin/python3
from __future__ import annotations
from scripts.Infrastructure.Variables import ERROR_MARKER_COMMENT_BEGIN, ERROR_MARKER_COMMENT_END
......@@ -9,10 +10,13 @@ class Instruction(object):
the identifier is used, in order to reference that instruction in the Template Manager (e.g. to change it). can be None
"""
def __init__(self, str_representation: str, identifier: str = None):
def __init__(self, str_representation: str, rank: str | int = 'all', identifier: str = None):
self._str_representation = str_representation
self._has_error = False
self._identifier = identifier
if isinstance(rank, str):
assert rank in ['all', 'not0']
self._rank = rank
def set_has_error(self, has_error: bool = True):
self._has_error = has_error
......@@ -23,6 +27,14 @@ class Instruction(object):
def set_identifier(self, identifier: str):
self._identifier = identifier
def get_ranks_executing(self) -> str | int:
return self._rank
def set_ranks_executing(self, rank: str | int):
if isinstance(rank, str):
assert rank in ['all', 'not0']
self._rank = rank
def __str__(self):
if self._has_error:
return ERROR_MARKER_COMMENT_BEGIN + self._str_representation + ERROR_MARKER_COMMENT_END
......
#! /usr/bin/python3
from __future__ import annotations
import typing
from typing_extensions import override
......@@ -9,8 +11,9 @@ from scripts.Infrastructure.Variables import ERROR_MARKER_COMMENT_BEGIN, ERROR_M
class MPICall(Instruction):
@override
def __init__(self, function: str, args: typing.OrderedDict[str, str], version: str, identifier: str = None):
super().__init__("", identifier)
def __init__(self, function: str, args: typing.OrderedDict[str, str], version: str, rank: str | int = 'all',
identifier: str = None):
super().__init__("", rank, identifier)
self._function = function
self._args = args
self._version = version
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment