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

Merge branch 'infrasructure-patch-1' into 'main'

Infrasructure patch 1

See merge request !13
parents aa92cbe4 d918d38f
No related branches found
No related tags found
1 merge request!13Infrasructure patch 1
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
from typing_extensions import override from typing_extensions import override
from scripts.Infrastructure.Instruction import Instruction from scripts.Infrastructure.Instruction import Instruction
from scripts.Infrastructure.Variables import ERROR_MARKER_COMMENT from scripts.Infrastructure.Variables import ERROR_MARKER_COMMENT_BEGIN, ERROR_MARKER_COMMENT_END
alloc_template = """ alloc_template = """
@{TYPE}@* @{NAME}@ = (@{TYPE}@*) @{FUNCTION}@(@{NUM}@ @{SEP}@ sizeof(@{TYPE}@)); @{TYPE}@* @{NAME}@ = (@{TYPE}@*) @{FUNCTION}@(@{NUM}@ @{SEP}@ sizeof(@{TYPE}@));
...@@ -58,7 +58,7 @@ class AllocCall(Instruction): ...@@ -58,7 +58,7 @@ class AllocCall(Instruction):
.replace("@{SEP}@", delim)) .replace("@{SEP}@", delim))
if self._has_error: if self._has_error:
s += ERROR_MARKER_COMMENT s = ERROR_MARKER_COMMENT_BEGIN + s + ERROR_MARKER_COMMENT_END
return s return s
......
...@@ -69,7 +69,8 @@ class GeneratorManager: ...@@ -69,7 +69,8 @@ class GeneratorManager:
return case_name + "-" + str(num).zfill(digits_to_use) + suffix return case_name + "-" + str(num).zfill(digits_to_use) + suffix
def generate(self, outpath: str | Path | os.PathLike[str], filterlist_:typing.Sequence[str]=None, print_progress_bar:bool=True, overwrite:bool=True, generate_full_set:bool=False, def generate(self, outpath: str | Path | os.PathLike[str], filterlist_: typing.Sequence[str] = None,
print_progress_bar: bool = True, overwrite: bool = True, generate_full_set: bool = False,
try_compile: bool = False, max_mpi_version: str = "4.0", use_clang_format: bool = True): try_compile: bool = False, max_mpi_version: str = "4.0", use_clang_format: bool = True):
""" """
Generates test cases based on the specified parameters. Generates test cases based on the specified parameters.
...@@ -115,6 +116,9 @@ class GeneratorManager: ...@@ -115,6 +116,9 @@ class GeneratorManager:
cases_generated = 0 cases_generated = 0
for generator in generators_to_use: for generator in generators_to_use:
# use first feature as category if generatro has multiple
categroy_path = os.path.join(outpath, generator.get_feature()[0])
os.makedirs(categroy_path, exist_ok=True)
for result_error in generator.generate(generate_full_set): for result_error in generator.generate(generate_full_set):
assert isinstance(result_error, TemplateManager) assert isinstance(result_error, TemplateManager)
...@@ -122,7 +126,7 @@ class GeneratorManager: ...@@ -122,7 +126,7 @@ class GeneratorManager:
if not float(result_error.get_version()) > float(max_mpi_version): if not float(result_error.get_version()) > float(max_mpi_version):
case_name = result_error.get_short_descr() case_name = result_error.get_short_descr()
fname = self.get_filename(case_name) fname = self.get_filename(case_name)
full_name = os.path.join(outpath, fname) full_name = os.path.join(categroy_path, fname)
if not overwrite and os.path.isfile(full_name): if not overwrite and os.path.isfile(full_name):
assert False and "File Already exists" assert False and "File Already exists"
......
#! /usr/bin/python3 #! /usr/bin/python3
from scripts.Infrastructure.Variables import ERROR_MARKER_COMMENT from scripts.Infrastructure.Variables import ERROR_MARKER_COMMENT_BEGIN, ERROR_MARKER_COMMENT_END
class Instruction(object): class Instruction(object):
...@@ -16,6 +16,6 @@ class Instruction(object): ...@@ -16,6 +16,6 @@ class Instruction(object):
def __str__(self): def __str__(self):
if self._has_error: if self._has_error:
return self._str_representation + ERROR_MARKER_COMMENT return ERROR_MARKER_COMMENT_BEGIN + self._str_representation + ERROR_MARKER_COMMENT_END
else: else:
return self._str_representation return self._str_representation
...@@ -3,7 +3,7 @@ from __future__ import annotations ...@@ -3,7 +3,7 @@ from __future__ import annotations
import typing import typing
from scripts.Infrastructure.Instruction import Instruction from scripts.Infrastructure.Instruction import Instruction
from scripts.Infrastructure.MPICall import MPI_Call from scripts.Infrastructure.MPICall import MPICall
class InstructionBlock: class InstructionBlock:
...@@ -76,7 +76,7 @@ class InstructionBlock: ...@@ -76,7 +76,7 @@ class InstructionBlock:
max_v = "0.0" max_v = "0.0"
for k, v in self.operations.items(): for k, v in self.operations.items():
for op in v: for op in v:
if isinstance(op, MPI_Call): if isinstance(op, MPICall):
max_v = max(op.get_version(), max_v) max_v = max(op.get_version(), max_v)
return max_v return max_v
...@@ -98,7 +98,7 @@ class InstructionBlock: ...@@ -98,7 +98,7 @@ class InstructionBlock:
result_str += str(op) + "\n" result_str += str(op) + "\n"
result_str += "}\n" result_str += "}\n"
else: else:
assert len(val) > 0 if len(val) > 0:
result_str += "if (rank == %d) {\n" % int(key) result_str += "if (rank == %d) {\n" % int(key)
for op in val: for op in val:
result_str += str(op) + "\n" result_str += str(op) + "\n"
...@@ -131,6 +131,8 @@ class InstructionBlock: ...@@ -131,6 +131,8 @@ class InstructionBlock:
str: The operation specified by kind and index str: The operation specified by kind and index
""" """
if index == 'all': if index == 'all':
if kind not in self.operations:
return []
return self.operations[kind] return self.operations[kind]
else: else:
as_int = int(index) # will Raise ValueError if not integer as_int = int(index) # will Raise ValueError if not integer
...@@ -157,7 +159,6 @@ class InstructionBlock: ...@@ -157,7 +159,6 @@ class InstructionBlock:
self.operations[kind] = op self.operations[kind] = op
else: else:
as_int = int(index) # will Raise ValueError if not integer as_int = int(index) # will Raise ValueError if not integer
print(op)
if not isinstance(op, Instruction): if not isinstance(op, Instruction):
raise ValueError('Provide Instruction') raise ValueError('Provide Instruction')
if len(self.operations[kind]) < as_int: if len(self.operations[kind]) < as_int:
......
...@@ -9,13 +9,13 @@ from scripts.Infrastructure.MPIAPIInfo.MPIAPIParameters import get_mpi_version_d ...@@ -9,13 +9,13 @@ from scripts.Infrastructure.MPIAPIInfo.MPIAPIParameters import get_mpi_version_d
template = """ template = """
@staticmethod @staticmethod
def @{FUNC_KEY}@(*args): def @{FUNC_KEY}@(*args):
return MPI_Call("@{FUNC_NAME}@", OrderedDict(@{PARAM_DICT}@), "@{VERSION}@") return MPICall("@{FUNC_NAME}@", OrderedDict(@{PARAM_DICT}@), "@{VERSION}@")
""" """
file_header="""#! /usr/bin/python3 file_header="""#! /usr/bin/python3
from collections import OrderedDict from collections import OrderedDict
from scripts.Infrastructure.MPICall import MPI_Call from scripts.Infrastructure.MPICall import MPICall
class MPICallFactory: class MPICallFactory:
......
...@@ -3,10 +3,10 @@ import typing ...@@ -3,10 +3,10 @@ import typing
from typing_extensions import override from typing_extensions import override
from scripts.Infrastructure.Instruction import Instruction from scripts.Infrastructure.Instruction import Instruction
from scripts.Infrastructure.Variables import ERROR_MARKER_COMMENT from scripts.Infrastructure.Variables import ERROR_MARKER_COMMENT_BEGIN, ERROR_MARKER_COMMENT_END
class MPI_Call(Instruction): class MPICall(Instruction):
@override @override
def __init__(self, function: str, args: typing.OrderedDict[str, str], version: str): def __init__(self, function: str, args: typing.OrderedDict[str, str], version: str):
...@@ -25,7 +25,7 @@ class MPI_Call(Instruction): ...@@ -25,7 +25,7 @@ class MPI_Call(Instruction):
s = s[:-2] # remove last , and space s = s[:-2] # remove last , and space
s += ");" s += ");"
if self._has_error: if self._has_error:
s += ERROR_MARKER_COMMENT s = ERROR_MARKER_COMMENT_BEGIN + s + ERROR_MARKER_COMMENT_END
return s return s
......
This diff is collapsed.
#! /usr/bin/python3 #! /usr/bin/python3
from scripts.Infrastructure.InstructionBlock import InstructionBlock from scripts.Infrastructure.InstructionBlock import InstructionBlock
from scripts.Infrastructure.MPICall import MPI_Call from scripts.Infrastructure.MPICall import MPICall
template = """// @{generatedby}@ template = """// @{generatedby}@
/* ///////////////////////// The MPI Bug Bench //////////////////////// /* ///////////////////////// The MPI Bug Bench ////////////////////////
...@@ -187,20 +187,25 @@ class TemplateManager: ...@@ -187,20 +187,25 @@ class TemplateManager:
raise ValueError("Neither Both block name nor index is given") raise ValueError("Neither Both block name nor index is given")
def insert_block(self, new_block: InstructionBlock, after_block_name: str = None, after_idx: int = None): def insert_block(self, new_block: InstructionBlock, after_block_name: str = None, after_idx: int = None,
before_block_name: str = None, before_idx: int = None):
""" """
inserts the given Instruction Block AFTER the one specified Either by name or by index inserts the given Instruction Block after/before the one specified Either by name or by index
Raises IndexError if the specified block is not found Raises IndexError if the specified block is not found
Raises IndexError if multiple Blocks with the given name are found Raises IndexError if multiple Blocks with the given name are found
Raises ValueError if Both a block name and index are given (or none is given) Raises ValueError if Both a block name and index are given (or none is given)
Raises ValueError if Both a before and an after block is given (or none is given)
Args: Args:
new_block (InstructionBlock): the block to insert new_block (InstructionBlock): the block to insert
after_block_name (str): The name of the InstructionBlock to receive after_block_name (str): The name of the InstructionBlock to receive
after_idx (int): index of the InstructionBlock to retrieve after_idx (int): index of the InstructionBlock to retrieve
""" """
# assert only one param is not None
parameters = [after_block_name, after_idx, before_block_name, before_idx]
if parameters.count(None) != 3:
raise ValueError("Only one parameter is allowed to be specified")
if after_block_name is not None: if after_block_name is not None:
if after_idx is not None:
raise ValueError("Both block name and index are given")
to_return = [b for b in self._blocks if b.name == after_block_name] to_return = [b for b in self._blocks if b.name == after_block_name]
if len(to_return) == 0: if len(to_return) == 0:
raise IndexError("Block Not Found") raise IndexError("Block Not Found")
...@@ -208,12 +213,21 @@ class TemplateManager: ...@@ -208,12 +213,21 @@ class TemplateManager:
raise IndexError("Multiple Blocks Found") raise IndexError("Multiple Blocks Found")
self._blocks.insert(self._blocks.index(to_return[0]) + 1, new_block) self._blocks.insert(self._blocks.index(to_return[0]) + 1, new_block)
return return
if before_block_name is not None:
to_return = [b for b in self._blocks if b.name == before_block_name]
if len(to_return) == 0:
raise IndexError("Block Not Found")
if len(to_return) > 1:
raise IndexError("Multiple Blocks Found")
self._blocks.insert(self._blocks.index(to_return[0]), new_block)
return
if after_idx is not None: if after_idx is not None:
if after_block_name is not None:
raise ValueError("Both block name and index are given")
self._blocks.insert(after_idx + 1, new_block) self._blocks.insert(after_idx + 1, new_block)
return return
if before_idx is not None:
self._blocks.insert(before_idx, new_block)
return
raise ValueError("Neither Both block name nor index is given") raise ValueError("Neither Both block name nor index is given")
......
...@@ -6,7 +6,7 @@ import typing ...@@ -6,7 +6,7 @@ import typing
from scripts.Infrastructure.AllocCall import AllocCall from scripts.Infrastructure.AllocCall import AllocCall
from scripts.Infrastructure.CorrectParameter import CorrectParameterFactory from scripts.Infrastructure.CorrectParameter import CorrectParameterFactory
from scripts.Infrastructure.InstructionBlock import InstructionBlock from scripts.Infrastructure.InstructionBlock import InstructionBlock
from scripts.Infrastructure.MPICall import MPI_Call from scripts.Infrastructure.MPICall import MPICall
from scripts.Infrastructure.MPICallFactory import CorrectMPICallFactory, MPICallFactory from scripts.Infrastructure.MPICallFactory import CorrectMPICallFactory, MPICallFactory
from scripts.Infrastructure.Template import TemplateManager from scripts.Infrastructure.Template import TemplateManager
......
#! /usr/bin/python3 #! /usr/bin/python3
# The 'Magic' Comment denoting where the Error is in a testcase # The 'Magic' Comments denoting where the Error is in a testcase
ERROR_MARKER_COMMENT = "/*MBBERROR*/" ERROR_MARKER_COMMENT_BEGIN = "/*MBBERROR_BEGIN*/"
ERROR_MARKER_COMMENT_END = "/*MBBERROR_END*/"
# The List of Features considered # The List of Features considered
featurelist = ["P2P", "COLL", "RMA", "TOOL"] featurelist = ["P2P", "COLL", "RMA", "TOOL"]
......
...@@ -6,14 +6,17 @@ from scripts.Infrastructure.GeneratorManager import GeneratorManager ...@@ -6,14 +6,17 @@ from scripts.Infrastructure.GeneratorManager import GeneratorManager
if __name__ == "__main__": if __name__ == "__main__":
gencodes_dir = "../gencodes/" gencodes_dir = "../gencodes/"
#gm = GeneratorManager("./errors") gm = GeneratorManager("./errors")
gm = GeneratorManager("./errors/devel") # gm = GeneratorManager("./errors/devel")
# remove all testcases from previous execution (ease of debugging) # remove all testcases from previous execution (ease of debugging)
filelist = [f for f in os.listdir(gencodes_dir) if f.endswith(".c")] for root, dirs, files in os.walk(gencodes_dir):
for f in filelist: for file in files:
os.remove(os.path.join(gencodes_dir, f)) if file.endswith(".c"):
os.remove(os.path.join(root, file))
# gm.generate(gencodes_dir, try_compile=True, generate_full_set=False) # default # gm.generate(gencodes_dir, try_compile=True, generate_full_set=False) # default
gm.generate(gencodes_dir, try_compile=True, generate_full_set=True, max_mpi_version="3.1") #all cases that can compile for my local mpi installation gm.generate(gencodes_dir, try_compile=True, generate_full_set=True,
max_mpi_version="3.1") # all cases that can compile for my local mpi installation
pass pass
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment