Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • coll
  • devel-ES
  • devel-TJ
  • dtypes
  • fix-rma-lockunlock
  • fortran
  • infrasructure-patch-1
  • infrastructure-patch-3
  • infrastructure-patch2
  • instructionblock-lists
  • main
  • mbi
  • merged
  • must-json
  • must-toolcoverage
  • p2p
  • paper_repro
  • parcoach
  • rma
  • toolcoverage
  • tools
  • tools-parallel
  • usertypes
23 results

Target

Select target project
  • hpc-public/mpi-bugbench
1 result
Select Git revision
  • coll
  • devel-ES
  • devel-TJ
  • dtypes
  • fix-rma-lockunlock
  • fortran
  • infrasructure-patch-1
  • infrastructure-patch-3
  • infrastructure-patch2
  • instructionblock-lists
  • main
  • mbi
  • merged
  • must-json
  • must-toolcoverage
  • p2p
  • paper_repro
  • parcoach
  • rma
  • toolcoverage
  • tools
  • tools-parallel
  • usertypes
23 results
Show changes

Commits on Source 3

......@@ -14,7 +14,7 @@ dealloc_template_c = """
free(@NAME@);
"""
alloc_template_fort = """
allocate(@{NAME}@(@{NUM}@))
allocate(@{NAME}@(0:(@{NUM}@)-1))
"""
dealloc_template_fort = """
deallocate(@NAME@)
......
#! /usr/bin/python3
from __future__ import annotations
from typing_extensions import override
import re
from Infrastructure.Instruction import Instruction
from Infrastructure.Variables import ERROR_MARKER_COMMENT_BEGIN, ERROR_MARKER_COMMENT_END, ERROR_MARKER_COMMENT_BEGIN_FORT, ERROR_MARKER_COMMENT_END_FORT, adjust_var_language
import Infrastructure.Variables as infvars
for_template_c = "for (int i = @START@; i < @END@; ++i)"
for_template_fort = "do i=@START@, @END@"
if_template_c = "if (@COND@) {"
if_template_fort = "if (@COND@) then"
"""
Class Overview:
The `Branch` class is a prototype for the specific IfBranch/ForBranch helpers for creating if/for branches/loops.
It should not be used directly
Methods:
- `__init__(self)`: Initializes a new branch
- `header(self)`: Returns a string representing the branch header
- `trailer(self)`: Returns a string representing the branch trailer
"""
class Branch:
@override
def __init__(self):
pass
def header(self):
return ""
@staticmethod
def trailer():
return ""
class IfBranch(Branch):
@override
def __init__(self, cond: str, elseif: bool = False):
self._cond = cond
self._elseif = elseif
@override
def header(self):
if infvars.generator_language == "c":
res = if_template_c.replace("@COND@", self._cond)
else:
res = if_template_fort.replace("@COND@", adjust_var_language(self._cond)).replace("!=", "/=")
return res if not self._elseif else f"else {res}"
@override
@staticmethod
def trailer():
if infvars.generator_language == "c":
return "}"
else:
return "end if"
class ForLoop(Branch):
@override
def __init__(self, start: str, end: str):
self._start = start
self._end = end
@override
def header(self):
if infvars.generator_language == "c":
return for_template_c.replace("@START@", str(self._start)).replace("@END@", str(self._end))
else:
return for_template_fort.replace("@START@", str(self._end)).replace("@END@", str(self._end))
@override
@staticmethod
def trailer():
if infvars.generator_language == "c":
return "}"
else:
return "end do"
#! /usr/bin/python3
from __future__ import annotations
from typing_extensions import override
import re
from Infrastructure.Instruction import Instruction
from Infrastructure.Variables import ERROR_MARKER_COMMENT_BEGIN, ERROR_MARKER_COMMENT_END, ERROR_MARKER_COMMENT_BEGIN_FORT, ERROR_MARKER_COMMENT_END_FORT, adjust_var_language
import Infrastructure.Variables as infvars
print_template_c = "printf(\"@STRING@\"@ARGS@);"
print_template_fort = "print *, \"@STRING@\"@ARGS@"
"""
Class Overview:
The `PrintInst` class is a helper for creating print instructions
Methods:
- `__init__(self)`: Initializes a new print instruction
- `__str__(self)`: Converts the print instance to a string, replacing placeholders.
"""
class PrintInst(Instruction):
@override
def __init__(self, string: str, args: List[str] = []):
"""
Creates a new print instruction
Args:
string: String to print
args: List of variables to print (postfix)
"""
super().__init__("")
self._string = string
self._args = args
@override
def __str__(self):
actual_template = print_template_c if infvars.generator_language == "c" else print_template_fort
actual_string = self._string
arg_str = ""
for arg in self._args:
arg_str = ", " + adjust_var_language(arg)
if infvars.generator_language == "c":
actual_string += " %d"
if infvars.generator_language == "c":
actual_string += "\\n"
result = actual_template.replace("@STRING@", actual_string).replace("@ARGS@", arg_str)
if infvars.generator_language == "c":
error_begin = ERROR_MARKER_COMMENT_BEGIN
error_end = ERROR_MARKER_COMMENT_END
else:
error_begin = ERROR_MARKER_COMMENT_BEGIN_FORT
error_end = ERROR_MARKER_COMMENT_END_FORT
if self.has_error():
result = error_begin + result + error_end
return result
......@@ -8,6 +8,7 @@ from Infrastructure.AllocCall import AllocCall
from Infrastructure.MPICall import MPICall
from Infrastructure.CorrectParameter import CorrectParameterFactory
from Infrastructure.Variables import ERROR_CLASSES
from Infrastructure.Branches import IfBranch
import Infrastructure.Variables as infvars
deadlock_marker = "\n!\n! This testcase can result in a Deadlock\n!"
......@@ -100,6 +101,7 @@ program main
integer :: double_size
integer :: integer_size
integer :: logical_size
integer :: i ! Loop index used by some tests
@{stack_vars}@
@{mpi_init}@
......@@ -126,17 +128,6 @@ if (@{thread_level}@ < provided)
printf("MBI ERROR: The MPI Implementation does not provide the required thread level!\\n");
"""
def get_if_cond(eq: bool, var: str, val: str):
if infvars.generator_language == "fort":
comp = ".eq." if eq else ".ne."
suffix = "then"
else:
comp = "==" if eq else "!="
suffix = "{"
return f"if ({var} {comp} {val}) {suffix}"
def get_if_postfix():
return "}" if infvars.generator_language == "c" else "end if"
def get_call(func: str):
if infvars.generator_language == "fort":
return f"call {func}(ierr)"
......@@ -256,19 +247,19 @@ class TemplateManager:
alloc_vars_fort.append(f" {inst.get_type()}, pointer :: {inst.get_name()}(:)")
if inst.get_rank_executing() != current_rank:
if current_rank != 'all':
code_string = code_string + get_if_postfix() + "\n"
code_string = code_string + IfBranch.trailer() + "\n"
# end previous if
current_rank = inst.get_rank_executing()
if current_rank == 'not0':
code_string = code_string + get_if_cond(False, "rank", "0") + "\n"
code_string = code_string + IfBranch("rank != 0").header() + "\n"
elif current_rank != 'all':
code_string = code_string + get_if_cond(True, "rank", str(current_rank)) + "\n"
code_string = code_string + IfBranch(f"rank == {current_rank}").header() + "\n"
code_string += str(inst) + "\n"
# end for inst
if current_rank != 'all':
code_string = code_string + get_if_postfix() + "\n" # end previous if
code_string = code_string + IfBranch.trailer() + "\n" # end previous if
init_string = ""
if self._has_init:
......
......@@ -45,6 +45,8 @@ def adjust_var_language(var) -> str:
actual_value = re.sub(r"^\*", r"", actual_value)
# Need to replace % with MODULO
actual_value = re.sub(r"([A-z0-9]+)\s*\%\s*([A-z0-9]+)", r"modulo(\1, \2)", actual_value)
# Replace array access [*] with (*)
actual_value = re.sub(r"([A-z0-9]+)\s*\[(.+)\]", r"\1(\2)", actual_value)
return actual_value
BASIC_TEST_LEVEL = 1
......
......@@ -6,6 +6,7 @@ from Infrastructure.ErrorGenerator import ErrorGenerator
from Infrastructure.MPICallFactory import CorrectMPICallFactory
from Infrastructure.Template import TemplateManager
from Infrastructure.ArrAsgn import ArrAsgn
from Infrastructure.Branches import IfBranch, ForLoop
class MessageRaceErrorAnyTag(ErrorGenerator):
......@@ -26,30 +27,30 @@ class MessageRaceErrorAnyTag(ErrorGenerator):
# send part
tm.register_instruction("for(int i =0; i < 10; ++i) {", rank_to_execute=1)
tm.register_instruction(ForLoop(0, 10).header(), rank_to_execute=1)
tm.register_instruction(ArrAsgn("buf", 0, "i"), rank_to_execute=1)
send_call = CorrectMPICallFactory().mpi_send()
send_call.set_arg("tag", "i")
tm.register_instruction(send_call, rank_to_execute=1)
tm.register_instruction("}", rank_to_execute=1)
tm.register_instruction(ForLoop.trailer(), rank_to_execute=1)
# the final msg after the loop
send_call = CorrectMPICallFactory().mpi_send()
tm.register_instruction(send_call, rank_to_execute=1)
# recv part
tm.register_instruction("for(int i =0; i < 10; ++i) {", rank_to_execute=0)
tm.register_instruction(ForLoop(0, 10).header(), rank_to_execute=0)
recv_call = CorrectMPICallFactory().mpi_recv()
recv_call.set_arg("tag", "MPI_ANY_TAG")
recv_call.set_rank_executing(0)
tm.register_instruction(recv_call)
tm.register_instruction("if(buf[0]!=i){", rank_to_execute=0)
tm.register_instruction(IfBranch("buf[0]!=i").header(), rank_to_execute=0)
additional_recv = CorrectMPICallFactory().mpi_recv()
additional_recv.set_has_error() # additional recv may lead to deadlock
tm.register_instruction(additional_recv,rank_to_execute=0)
tm.register_instruction(" }", rank_to_execute=0) # end if
tm.register_instruction("}", rank_to_execute=0) # end for
tm.register_instruction(IfBranch.trailer(), rank_to_execute=0)
tm.register_instruction(ForLoop.trailer(), rank_to_execute=0)
tm.register_instruction(CorrectParameterFactory().get_buffer_free())
......@@ -81,16 +82,16 @@ class MessageRaceErrorAnysource(ErrorGenerator):
tm.register_instruction(send_call, rank_to_execute=1)
# recv part
tm.register_instruction("for(int i =1; i < nprocs; ++i) {", rank_to_execute=0)
tm.register_instruction(ForLoop(1, "nprocs").header(), rank_to_execute=0)
recv_call = CorrectMPICallFactory().mpi_recv()
recv_call.set_arg("source", "MPI_ANY_SOURCE")
tm.register_instruction(recv_call, rank_to_execute=0)
tm.register_instruction("if(buf[0]!=i){", rank_to_execute=0)
tm.register_instruction(IfBranch("buf[0]!=i").header(), rank_to_execute=0)
additional_recv = CorrectMPICallFactory().mpi_recv()
additional_recv.set_has_error() # additional recv leads to deadlock
tm.register_instruction(additional_recv, rank_to_execute=0)
tm.register_instruction(" }", rank_to_execute=0) # end if
tm.register_instruction("}", rank_to_execute=0) # end for
tm.register_instruction(IfBranch.trailer(), rank_to_execute=0) # end if
tm.register_instruction(ForLoop.trailer(), rank_to_execute=0)
tm.register_instruction(CorrectParameterFactory().get_buffer_free())
......
......@@ -5,6 +5,10 @@ from Infrastructure.Variables import *
from Infrastructure.ErrorGenerator import ErrorGenerator
from Infrastructure.Template import TemplateManager
from Infrastructure.TemplateFactory import get_send_recv_template
from Infrastructure.AllocCall import AllocCall
from Infrastructure.MPICallFactory import MPICallFactory
from Infrastructure.Branches import IfBranch, ForLoop
from Infrastructure.PrintInst import PrintInst
class UnmatchedP2Pcall(ErrorGenerator):
......@@ -79,7 +83,6 @@ class ComplexMissmach(ErrorGenerator):
def generate(self, generate_level, real_world_score_table):
tm = TemplateManager()
tm.add_stack_variable("int", "i")
tm.add_stack_variable("MPI_Request", "request")
tm.add_stack_variable("MPI_Status", "status")
tm.add_stack_variable("int", "countEvenNumbers")
......@@ -89,40 +92,37 @@ class ComplexMissmach(ErrorGenerator):
tm.register_instruction(Instruction("#define MSG_TAG_A 124523"))
tm.register_instruction(Instruction("#define N 10"))
tm.register_instruction(Instruction("#define EVEN 0"))
code = """
int buffer[N];
for (i = 0; i < 10; i++) {
if (rank == 0) {
tag_sender = i * N;
MPI_Isend(buffer, 1, MPI_INT, 1, tag_sender, MPI_COMM_WORLD, &request);
MPI_Wait(&request, &status);
}
else if (rank == 1) {
tag_receiver = i * N;
if (i % 2 == EVEN) {
(countEvenNumbers)++;
}
if ((countEvenNumbers) == (N / 2)) {
tag_receiver++; // mismatch
}
printf(\"Count Even Numbers: %d \\n\", countEvenNumbers);
MPI_Irecv(buffer, 1, MPI_INT, 0, tag_receiver, MPI_COMM_WORLD, &request);
MPI_Wait(&request, &status);
}
}
"""
i = Instruction(code)
i.set_has_error()
tm.register_instruction(i)
tm.set_can_deadlock()
tm.register_instruction(AllocCall("int", "N", "buffer"))
tm.register_instruction(ForLoop(0, 10).header())
tm.register_instruction(IfBranch("rank == 0").header())
tm.register_instruction("tag_sender = i*N")
tm.register_instruction(MPICallFactory.mpi_isend("buffer", 1, "MPI_INT", 1, "tag_sender", "MPI_COMM_WORLD", "&request"))
tm.register_instruction(MPICallFactory.mpi_wait("&request", "&status"))
tm.register_instruction(IfBranch("rank == 1", elseif=True).header())
#TODO SET_HAS_ERROR
tm.register_instruction("tag_receiver = i*N")
tm.register_instruction(IfBranch("i % 2 == EVEN").header())
tm.register_instruction("countEvenNumbers = countEvenNumbers + 1")
tm.register_instruction(IfBranch.trailer())
tm.register_instruction(IfBranch("(countEvenNumbers) == (N / 2)").header())
tm.register_instruction("tag_receiver = tag_receiver + 1")
tm.register_instruction(IfBranch.trailer())
tm.register_instruction(PrintInst("Count Even Numbers: ", ["countEvenNumbers"]))
recv_call = MPICallFactory.mpi_irecv("buffer", 1, "MPI_INT", 0, "tag_receiver", "MPI_COMM_WORLD", "&request")
recv_call.set_has_error()
tm.register_instruction(recv_call)
tm.register_instruction(MPICallFactory.mpi_wait("&request", "&status"))
tm.register_instruction(IfBranch.trailer())
tm.register_instruction(ForLoop.trailer())
tm.set_can_deadlock()
tm.set_description("GlobalParameterMissmatch-tag-mpi_send", "Missmatching message tags in iteration 10")
yield tm
......@@ -12,7 +12,7 @@ from Infrastructure.Template import TemplateManager
from Infrastructure.TemplateFactory import get_allocated_window, get_rma_call
from Infrastructure.AllocCall import AllocCall
from Infrastructure.ArrAsgn import ArrAsgn
import Infrastructure.Variables as infvars
from Infrastructure.PrintInst import PrintInst
import itertools
......@@ -40,12 +40,8 @@ class GlobalConcurrencyErrorRMA(ErrorGenerator):
localbufread.set_arg("target_count", "1")
localbufread.set_arg("target_rank", "0")
if infvars.generator_language == "c":
read_str = f'printf("winbuf is %d\\n", {CorrectParameterFactory().winbuf_var_name}[1]);'
else:
read_str = f'print *, "winbuf is ", {CorrectParameterFactory().winbuf_var_name}(1)'
self.buf_instructions = {
"bufread": Instruction(read_str, 1, "bufread"),
"bufread": PrintInst("winbuf is ", [f"{CorrectParameterFactory().winbuf_var_name}[1]"]),
"bufwrite": ArrAsgn(CorrectParameterFactory().winbuf_var_name, 1, 42, rank=1, identifier="bufwrite"),
"localbufread": localbufread,
"localbufwrite": localbufwrite
......
......@@ -12,7 +12,7 @@ from Infrastructure.Template import TemplateManager
from Infrastructure.TemplateFactory import get_allocated_window, get_rma_call
from Infrastructure.AllocCall import AllocCall
from Infrastructure.ArrAsgn import ArrAsgn
import Infrastructure.Variables as infvars
from Infrastructure.PrintInst import PrintInst
import itertools
......@@ -23,12 +23,8 @@ class LocalConcurrencyErrorRMA(ErrorGenerator):
def __init__(self):
self.cfmpi = CorrectMPICallFactory()
# generate standard buffer access instructions
if infvars.generator_language == "c":
read_str = f'printf("buf is %d\\n", {CorrectParameterFactory().buf_var_name}[0]);'
else:
read_str = f'print *, "buf is ", {CorrectParameterFactory().buf_var_name}(0)'
self.buf_instructions = {
"bufread": Instruction(read_str, 0, "bufread"),
"bufread": PrintInst("buf is ", [f"{CorrectParameterFactory().buf_var_name}[0]"]),
"bufwrite": ArrAsgn(CorrectParameterFactory().buf_var_name, 0, 42)
}
......