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

added message race cases

parent 7baaa0dd
Branches
No related tags found
1 merge request!6More Work on infrastructure IV
#! /usr/bin/python3
from scripts.Infrastructure.ErrorGenerator import ErrorGenerator, CorrectTestcase
from scripts.Infrastructure.InstructionBlock import InstructionBlock
from scripts.Infrastructure.MPICallFactory import MPICallFactory, CorrectMPICallFactory
from scripts.Infrastructure.CorrectParameter import CorrectParameterFactory, get_matching_recv
from scripts.Infrastructure.Template import TemplateManager
from scripts.Infrastructure.TemplateFactory import get_send_recv_template
from itertools import chain
class MessageRaceErrorAnyTag(ErrorGenerator):
# TODO do we need to generate it for all combinations of send and recv?
def __init__(self):
pass
def get_num_errors(self):
# send + receive = only check the first two functions
return 1
# the number of errors to produce in the extended mode (all possible combinations)
def get_num_errors_extended(self):
return 1
def get_feature(self):
return ["P2P"]
def generate(self, i):
tm = TemplateManager()
tm.set_description("MsgRace-ANY_TAG", "order of messages is indeterministic, may lead to a deadlock")
b = InstructionBlock("alloc")
b.register_operation(CorrectParameterFactory().get_buffer_alloc())
tm.register_instruction_block(b)
b = InstructionBlock("MPICALL")
# send part
b.register_operation("for(int i =0; i < 10; ++i) {", kind=1)
b.register_operation("buf[0]=i;", kind=1)
send_call = CorrectMPICallFactory().mpi_send()
send_call.set_arg("tag", "i")
b.register_operation(send_call, kind=1)
b.register_operation("}", kind=1)
# recv part
b.register_operation("for(int i =0; i < 10; ++i) {", kind=0)
recv_call = CorrectMPICallFactory().mpi_recv()
recv_call.set_arg("tag", "MPI_ANY_TAG")
b.register_operation(recv_call, kind=0)
b.register_operation("if(buf[0]!=i){", kind=0)
additional_recv = CorrectMPICallFactory().mpi_recv()
additional_recv.set_has_error()# additional recv leads to deadlock
b.register_operation(additional_recv,kind=0)
b.register_operation(" }", kind=0) # end if
b.register_operation("}", kind=0) # end for
tm.register_instruction_block(b)
b = InstructionBlock("free")
b.register_operation(CorrectParameterFactory().get_buffer_free())
tm.register_instruction_block(b)
return tm
class MessageRaceErrorAnysource(ErrorGenerator):
# TODO do we need to generate it for all combinations of send and recv?
def __init__(self):
pass
def get_num_errors(self):
# send + receive = only check the first two functions
return 1
# the number of errors to produce in the extended mode (all possible combinations)
def get_num_errors_extended(self):
return 1
def get_feature(self):
return ["P2P"]
def generate(self, i):
tm = TemplateManager(min_ranks=3)
tm.set_description("MsgRace-ANY_SOURCE", "order of messages is indeterministic, may lead to a deadlock")
b = InstructionBlock("alloc")
b.register_operation(CorrectParameterFactory().get_buffer_alloc())
tm.register_instruction_block(b)
b = InstructionBlock("MPICALL")
# send part
b.register_operation("buf[0]=rank;", kind='not0')
send_call = CorrectMPICallFactory().mpi_send()
b.register_operation(send_call, kind='not0')
# recv part
b.register_operation("for(int i =1; i < nprocs; ++i) {", kind=0)
recv_call = CorrectMPICallFactory().mpi_recv()
recv_call.set_arg("source", "MPI_ANY_SOURCE")
b.register_operation(recv_call, kind=0)
b.register_operation("if(buf[0]!=i){", kind=0)
additional_recv = CorrectMPICallFactory().mpi_recv()
additional_recv.set_has_error()# additional recv leads to deadlock
b.register_operation(additional_recv,kind=0)
b.register_operation(" }", kind=0) # end if
b.register_operation("}", kind=0) # end for
tm.register_instruction_block(b)
b = InstructionBlock("free")
b.register_operation(CorrectParameterFactory().get_buffer_free())
tm.register_instruction_block(b)
return tm
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment