Skip to content
Snippets Groups Projects

P2P

Open
Jammer, Timrequested to merge
p2p into main
1 file
+ 60
0
Compare changes
  • Side-by-side
  • Inline
#! /usr/bin/python3
import itertools
from scripts.Infrastructure.ErrorGenerator import ErrorGenerator
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 RecvBeforeSend(ErrorGenerator):
send_funcs = ["mpi_send",
"mpi_isend", "mpi_ssend", "mpi_issend", "mpi_rsend", "mpi_irsend", "mpi_bsend", "mpi_ibsend",
"mpi_send_init", "mpi_ssend_init", "mpi_bsend_init", "mpi_rsend_init", "mpi_psend_init"
]
recv_funcs = ["mpi_recv", "mpi_irecv", "mpi_recv_init", "mpi_precv_init"]
probe_recv_funcs = ["mpi_mprobe", "mpi_improbe"]
def __init__(self):
pass
def get_feature(self):
return ["P2P"]
def generate_impl(self, send_func, recv_func):
tm = get_send_recv_template(send_func, recv_func)
tm.set_description("CallOrdering-" + send_func, "Call Ordering: both ranks try to receive befroe sending")
tm.get_block("MPICALL").get_instruction(kind=0, index=0).set_has_error()
reverse_msg_block = InstructionBlock("second_msg")
send = CorrectMPICallFactory.mpi_send()
send.set_arg("dest", "1")
reverse_msg_block.register_instruction(send, 0)
recv = CorrectMPICallFactory.mpi_recv()
recv.set_arg("source", "0")
recv.set_has_error()
reverse_msg_block.register_instruction(recv, 1)
# this is a correct case with no deadlock
# introduce deadlock by moving rank 1s send after the recv
rank_1_send_instr = tm.get_block("MPICALL").get_instruction(kind=1, index='all')
tm.get_block("MPICALL").remove_instruction(kind=1, index='all')
reverse_msg_block.register_instruction(rank_1_send_instr, kind=1)
tm.insert_block(reverse_msg_block, after_block_name="MPICALL")
yield tm
def generate(self, generate_full_set):
for send_func, recv_func in itertools.product(self.send_funcs, self.recv_funcs):
yield from self.generate_impl(send_func, "mpi_irecv")
if not generate_full_set:
pass
Loading