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

Added An InvalidRank generator for collectives

parent e4e8bacf
No related branches found
No related tags found
1 merge request!3more work on infrastructure II
......@@ -20,7 +20,7 @@ class CorrectParameterFactory:
return b
def get(self, param, func=None):
if param == "BUFFER" or param == "buf":
if param == "BUFFER" or param == "buf" or param == "buffer" or param == "sendbuf" or param == "recvbuf":
return self.buf_var_name
if param == "COUNT" or param == "count":
return str(self.buf_size)
......@@ -30,12 +30,18 @@ class CorrectParameterFactory:
return "0"
if param == "SRC" or param == "source":
return "1"
if param == "RANK" or param == "root":
return "0"
if param == "TAG" or param == "tag":
return str(self.tag)
if param == "COMM" or param == "comm":
return "MPI_COMM_WORLD"
if param == "STATUS" or param == "status":
return "MPI_STATUS_IGNORE"
if param == "OPERATION" or param == "op":
return "MPI_SUM"
print("Not Implemented: " + param)
assert False, "Param not known"
......
......@@ -18,6 +18,15 @@ def get_default_template(mpi_func):
def get_send_recv_template(send_func, recv_func):
"""
Contructs a default template for the given mpi send recv function pair
Returns:
TemplateManager Initialized with a default template
The function is contained in a block named MPICALL with seperate calls for rank 1 and 2)
"""
assert send_func == "mpi_send" or send_func == "mpi_ssend"
assert recv_func == "mpi_recv"
tm = TemplateManager()
cf = CorrectParameterFactory()
......@@ -37,3 +46,31 @@ def get_send_recv_template(send_func, recv_func):
tm.register_instruction_block(b)
return tm
def get_collective_template(collective_func,seperate=True):
"""
Contructs a default template for the given mpi collecive
Returns:
TemplateManager Initialized with a default template
The function is contained in a block named MPICALL
with seperate calls for rank 1 and 2 if seperate ==True
"""
tm = TemplateManager()
cf = CorrectParameterFactory()
tm.register_instruction_block(cf.get_buffer_alloc())
cmpicf = CorrectMPICallFactory()
call_creator_function = getattr(cmpicf, collective_func)
c = call_creator_function()
b = InstructionBlock("MPICALL")
if seperate:
b.register_operation(c, 1)
b.register_operation(c, 0)
else:
b.register_operation(c,'all')
tm.register_instruction_block(b)
return tm
......@@ -5,10 +5,10 @@ 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 scripts.Infrastructure.TemplateFactory import get_send_recv_template, get_collective_template
class InvalidRankError(ErrorGenerator):
class InvalidRankErrorP2P(ErrorGenerator):
invalid_ranks = ["-1", "size", "MPI_PROC_NULL"]
def __init__(self):
......@@ -28,9 +28,40 @@ class InvalidRankError(ErrorGenerator):
rank_to_use = self.invalid_ranks[i]
tm = get_send_recv_template("mpi_send", "mpi_recv")
tm.set_description("InvalidParam-Rank-MPI_Send", "Invalid Rank: %s" % self.invalid_ranks[i])
tm.set_description("InvalidParam-Rank-MPI_Send", "Invalid Rank: %s" % rank_to_use)
tm.get_block("MPICALL").get_operation(kind=0, index=0).set_arg("source", rank_to_use)
tm.get_block("MPICALL").get_operation(kind=0, index=0).set_has_error()
return tm
class InvalidRankErrorColl(ErrorGenerator):
invalid_ranks = ["-1", "size", "MPI_PROC_NULL"]
functions_to_use = ["mpi_reduce", "mpi_bcast"]
def __init__(self):
pass
def get_num_errors(self):
return len(self.invalid_ranks) * len(self.functions_to_use)
# the number of errors to produce in the extended mode (all possible combinations)
def get_num_errors_extended(self):
return len(self.invalid_ranks) * len(self.functions_to_use)
def get_feature(self):
return ["COLL"]
def generate(self, i):
rank_to_use = self.invalid_ranks[i // len(self.functions_to_use)]
func_to_use = self.functions_to_use[i % len(self.functions_to_use)]
tm = get_collective_template(func_to_use, seperate=False)
arg_to_replace = "root"
tm.set_description("InvalidParam-Rank-"+func_to_use, "Invalid Rank: %s" % rank_to_use)
tm.get_block("MPICALL").get_operation(kind='all', index=0).set_arg(arg_to_replace, rank_to_use)
tm.get_block("MPICALL").get_operation(kind='all', index=0).set_has_error()
return tm
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment