diff --git a/scripts/Infrastructure/CorrectParameter.py b/scripts/Infrastructure/CorrectParameter.py index 5faa4f15ae1ccd08e79bd82777e390a7534ffbfa..504b69824b09e33a92f9dab2f687cf0e87cddf23 100644 --- a/scripts/Infrastructure/CorrectParameter.py +++ b/scripts/Infrastructure/CorrectParameter.py @@ -1,7 +1,7 @@ #! /usr/bin/python3 from scripts.Infrastructure import MPICall from scripts.Infrastructure.Instruction import Instruction - +#from scripts.Infrastructure.MPICallFactory import MPICallFactory from scripts.Infrastructure.AllocCall import AllocCall, get_free @@ -28,13 +28,13 @@ class CorrectParameterFactory: return self.buf_var_name if param in ["COUNT", "count", "sendcount", "recvcount", "origin_count", "target_count", "result_count"]: return str(self.buf_size) + if param in ["sendcounts", "recvcounts"]: + return str(self.buf_size) if param in ["DATATYPE", "datatype", "sendtype", "recvtype", "origin_datatype", "target_datatype", "result_datatype"]: return self.dtype[1] - if param in ["DEST", "dest", "rank"]: + if param in ["DEST", "dest", "target_rank"]: return "0" - if param in ["target_rank"]: - return "1" if param in ["SRC", "source"]: return "1" if param in ["RANK", "root"]: @@ -60,7 +60,7 @@ class CorrectParameterFactory: if param in ["REQUEST", "request"]: return "&mpi_request_0" if param in ["GROUP", "group"]: - return "mpi_group_0" + return "&mpi_group_0" if param in ["color"]: return "1" if param in ["message"]: @@ -105,6 +105,20 @@ class CorrectParameterFactory: return "resultbuf" if param in ["compare_addr"]: return "comparebuf" + if param in ["comm_cart"]: + return "&mpi_comm_0" + if param in ["comm_old"]: + return "MPI_COMM_WORLD" + if param in ["ndims", "maxdims"]: + return "2" + if param in ["dims"]: + return "dims" + if param in ["coords"]: + return "coords" + if param in ["periods"]: + return "periods" + if param in ["reorder"]: + return "0" print("Not Implemented: " + param) assert False, "Param not known" @@ -124,3 +138,19 @@ class CorrectParameterFactory: # TODO implement other types print("Not Implemented: " + variable_type) assert False, "Param not known" + + +# todo also for send and non default args +def get_matching_recv(call: MPICall) -> MPICall: + correct_params = CorrectParameterFactory() + recv = MPICallFactory().mpi_recv( + correct_params.get("BUFFER"), + correct_params.get("COUNT"), + correct_params.get("DATATYPE"), + correct_params.get("SRC"), + correct_params.get("TAG"), + correct_params.get("COMM"), + correct_params.get("STATUS", "MPI_Recv"), + ) + + return recv diff --git a/scripts/Infrastructure/MPICallFactory.py b/scripts/Infrastructure/MPICallFactory.py index a243cb2be718f75283b2d09c75e7e018fb599863..b89d4ec7edd0e24fde44acd8bc885fff3905575d 100644 --- a/scripts/Infrastructure/MPICallFactory.py +++ b/scripts/Infrastructure/MPICallFactory.py @@ -149,7 +149,7 @@ class MPICallFactory: @staticmethod def mpi_cart_get(*args): - return MPICall("MPI_Cart_get", OrderedDict([("comm", args[0]), ("maxdims", args[1]), ("dims", args[2]), ("periods", args[3]), ("coords", args[4]), ]), "1.0") + return MPICall("MPI_Cart_get", OrderedDict([("comm_cart", args[0]), ("maxdims", args[1]), ("dims", args[2]), ("periods", args[3]), ("coords", args[4]), ]), "1.0") @staticmethod def mpi_cart_map(*args): @@ -2255,7 +2255,7 @@ class CorrectMPICallFactory: @staticmethod def mpi_cart_get(): correct_params = CorrectParameterFactory() - return MPICallFactory().mpi_cart_get(correct_params.get("comm"),correct_params.get("maxdims"),correct_params.get("dims"),correct_params.get("periods"),correct_params.get("coords")) + return MPICallFactory().mpi_cart_get(correct_params.get("comm_cart"),correct_params.get("maxdims"),correct_params.get("dims"),correct_params.get("periods"),correct_params.get("coords")) @staticmethod def mpi_cart_map(): diff --git a/scripts/Infrastructure/TemplateFactory.py b/scripts/Infrastructure/TemplateFactory.py index 09f5742a7011b18b73903a50cb9f41a857850b51..d0f470bee0ec6d8706bc10cf4ddcc6113ba05681 100644 --- a/scripts/Infrastructure/TemplateFactory.py +++ b/scripts/Infrastructure/TemplateFactory.py @@ -571,37 +571,40 @@ def replace_wait(wait_call, tm, wait_func_to_use): def get_collective_template(collective_func): """ - Contructs a default template for the given mpi collecive + Contructs a default template for the given mpi collective 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 """ - need_buf_funcs = ["mpi_bcast", "mpi_ibcast", "mpi_reduce", "mpi_ireduce", "mpi_exscan", "mpi_scan", "mpi_iscan", "mpi_gather", "mpi_igather", "mpi_allgather", "mpi_iallgather", "mpi_allreduce", "mpi_iallreduce", "mpi_alltoall", "mpi_ialltoall", "mpi_scatter", "mpi_iscatter"] - need_recv_and_send_buf_funcs = [] tm = TemplateManager() cf = CorrectParameterFactory() - # spilt send and recv buf - # to remove for barrier operation - #if collective_func in need_buf_funcs: - alloc = cf.get_buffer_alloc() - alloc.set_identifier("ALLOC") - alloc.set_name("buf") - tm.register_instruction(alloc) - cmpicf = CorrectMPICallFactory() call_creator_function = getattr(cmpicf, collective_func) c = call_creator_function() + if c.has_arg("buffer") or c.has_arg("sendbuf"): + alloc = cf.get_buffer_alloc() + alloc.set_identifier("ALLOC") + alloc.set_name("buf") + tm.register_instruction(alloc) + + if c.has_arg("comm_cart"): + tm.add_stack_variable("MPI_Comm") + # TODO: create proper instructions + tm.register_instruction(Instruction("int periods[2]={1,1};"), identifier="ALLOC") + tm.register_instruction(Instruction("int dims[2]={0,0};"), identifier="ALLOC") # this is an initialization, we use dim_create function + tm.register_instruction(Instruction("int coords[2]={0,0};"), identifier="ALLOC") + # Get the dims of the cartesian topology MPI_Dims_create(nprocs,2,dims); + dims_create = MPICallFactory.mpi_dims_create("nprocs", "2", "dims") + tm.register_instruction(dims_create) + # add request for nonblocking collectives if collective_func.startswith("mpi_i"): tm.add_stack_variable("MPI_Request") - # Set parameters for some collectives: sendcount, recvcounts - #if collective_func in ["mpi_alltoallv"]: - # TODO coll = CorrectMPICallFactory.get(collective_func) coll.set_identifier("MPICALL") @@ -611,12 +614,55 @@ def get_collective_template(collective_func): if collective_func.startswith("mpi_i"): tm.register_instruction(CorrectMPICallFactory.mpi_wait(), rank_to_execute='all', identifier="WAIT") - tm.register_instruction(cf.get_buffer_free(), identifier="FREE") + if c.has_arg("buffer") or c.has_arg("sendbuf"): + tm.register_instruction(cf.get_buffer_free(), identifier="FREE") return tm +def get_two_collective_template(collective_func1, collective_func2): + """ + Contructs a default template for two given mpi collectives + Returns: + TemplateManager Initialized with a default template + The function is contained in a block named MPICALL + """ + + tm = TemplateManager() + cf = CorrectParameterFactory() + + # todo: spilt send and recv buf + alloc = cf.get_buffer_alloc() + alloc.set_identifier("ALLOC") + alloc.set_name("buf") + tm.register_instruction(alloc) + + cmpicf = CorrectMPICallFactory() + call_creator_function = getattr(cmpicf, collective_func1) + c = call_creator_function() + + # add request for nonblocking collectives + if collective_func1.startswith("mpi_i") or collective_func2.startswith("mpi_i"): + tm.add_stack_variable("MPI_Request") + coll1 = CorrectMPICallFactory.get(collective_func1) + coll1.set_identifier("MPICALL") + tm.register_instruction(coll1) + coll1.set_rank_executing(0) + + coll2 = CorrectMPICallFactory.get(collective_func2) + coll2.set_identifier("MPICALL") + tm.register_instruction(coll2) + coll2.set_rank_executing('not0') + + # add wait function for nonblocking collectives + if collective_func1.startswith("mpi_i") or collective_func2.startswith("mpi_i"): + tm.register_instruction(CorrectMPICallFactory.mpi_wait(), rank_to_execute='all', identifier="WAIT") + + tm.register_instruction(cf.get_buffer_free(), identifier="FREE") + + return tm + def get_allocated_window(win_alloc_func, name, bufname, ctype, num_elements): """ Constructs a window allocation using Win_allocate or Win_create and a corresponding free call. diff --git a/scripts/errors/coll/CallOrdering.py b/scripts/errors/coll/CallOrdering.py index 9860d46cf936be527af2f36e7d4cc812686f5839..0069b7e4ec37fbf5f4c146a1f2a70e8e50398a53 100644 --- a/scripts/errors/coll/CallOrdering.py +++ b/scripts/errors/coll/CallOrdering.py @@ -2,12 +2,17 @@ from scripts.Infrastructure.Variables import * from scripts.Infrastructure.ErrorGenerator import ErrorGenerator - -from scripts.Infrastructure.TemplateFactory import get_collective_template +from scripts.Infrastructure.Instruction import Instruction +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, get_collective_template class InvalidRankErrorColl(ErrorGenerator): - functions_to_use = ["mpi_reduce", "mpi_bcast"] - + functions_to_use = ["mpi_allgather","mpi_allreduce","mpi_alltoall","mpi_barrier","mpi_bcast", "mpi_reduce", "mpi_scatter","mpi_exscan","mpi_gather", "mpi_reduce_scatter_block", "mpi_scan", "mpi_ibarrier", "mpi_iallreduce", "mpi_ialltoall", "mpi_ibcast", "mpi_ireduce", "mpi_iscatter", "mpi_igather", "mpi_iscan" ] + functions_not_supported_yet = ["mpi_allgatherv", "mpi_alltoallv", "mpi_alltoallw", "mpi_gatherv", "mpi_reduce_scatter", "mpi_scatterv"] + #need_buf_funcs = ["mpi_bcast", "mpi_ibcast", "mpi_reduce", "mpi_ireduce", "mpi_exscan", "mpi_scan", "mpi_iscan", "mpi_gather", "mpi_igather", "mpi_allgather", "mpi_iallgather", "mpi_allreduce", "mpi_iallreduce", "mpi_alltoall", "mpi_ialltoall", "mpi_scatter", "mpi_iscatter", "mpi_reduce_scatter_block"] + def __init__(self): pass @@ -24,10 +29,23 @@ class InvalidRankErrorColl(ErrorGenerator): tm.set_description("CallOrdering-unmatched-"+func_to_use, func_to_use+" is not called by all processes") for call in tm.get_instruction("MPICALL", return_list=True): - call.set_rank_executing(0) + call.set_rank_executing(0) # do the same for wait function call.set_has_error() yield tm - if generate_level <= BASIC_TEST_LEVEL: + + for func1 in self.functions_to_use: + for func2 in self.functions_to_use: # this generates func1-func2 and func2-func1 -> we need to remove similar cases + tm = get_two_collective_template(func1, func2) + + tm.set_description("CallOrdering-unmatched-"+func1+"-"+func2, "Collective mismatch: "+func1+" is matched with "+func2) + + for call in tm.get_instruction("MPICALL", return_list=True): + call.set_has_error() + if func1 != func2: # we want different functions + yield tm + + + if not generate_level <= BASIC_TEST_LEVEL: return diff --git a/scripts/errors/coll/Correct.py b/scripts/errors/coll/Correct.py new file mode 100644 index 0000000000000000000000000000000000000000..4201aa6653a659f30e212e138c9671b5df02f42d --- /dev/null +++ b/scripts/errors/coll/Correct.py @@ -0,0 +1,48 @@ +#! /usr/bin/python3 + +from scripts.Infrastructure.ErrorGenerator import ErrorGenerator +from scripts.Infrastructure.Instruction import Instruction +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_collective_template, get_two_collective_template + +class CorrectColl(ErrorGenerator): + functions_to_use = ["mpi_allgather","mpi_allreduce","mpi_alltoall","mpi_barrier","mpi_bcast", "mpi_reduce", "mpi_scatter","mpi_exscan","mpi_gather", "mpi_reduce_scatter_block", "mpi_scan", "mpi_ibarrier", "mpi_iallreduce", "mpi_ialltoall", "mpi_ibcast", "mpi_ireduce", "mpi_iscatter", "mpi_igather", "mpi_iscan"] + functions_not_supported_yet = ["mpi_gatherv", "mpi_scatterv", "mpi_igatherv", "mpi_iscatterv"] + topology_functions = ["mpi_cart_create"] + + def __init__(self): + pass + + + def get_feature(self): + return ["COLL"] + + def generate(self, generate_full_set): + + # Only one function called by all processes + for func_to_use in self.functions_to_use: + tm = get_collective_template(func_to_use) + tm.set_description("Correct-"+func_to_use, "Correct code") + yield tm + + # Separate function called depending of process ID + for func_to_use in self.functions_to_use: + tm = get_two_collective_template(func_to_use, func_to_use) + tm.set_description("Correct-"+func_to_use+"-"+func_to_use, "Correct code") + yield tm + + # Generate scenarios with topology functions + for func_to_use in self.topology_functions: + tm = get_collective_template(func_to_use) + tm.set_description("Correct-"+func_to_use, "Correct code") + yield tm + tm.set_description("Correct-"+func_to_use+"-mpi_cart_get", "Correct code") + cart_get = CorrectMPICallFactory().mpi_cart_get() + cart_get.set_arg("comm_cart", "mpi_comm_0") + tm.register_instruction(cart_get) + yield tm + + if not generate_full_set: + return diff --git a/scripts/errors/coll/InvalidComm.py b/scripts/errors/coll/InvalidComm.py index 05d073c0d3836ad5d30d59ce7d62b668fbb4cce2..cba77b1682fcb2816b2f2c59decc18dceaacc86f 100644 --- a/scripts/errors/coll/InvalidComm.py +++ b/scripts/errors/coll/InvalidComm.py @@ -6,10 +6,10 @@ from scripts.Infrastructure.TemplateFactory import get_collective_template class InvalidComErrorColl(ErrorGenerator): invalid_com = ["MPI_COMM_NULL", "NULL"] - functions_to_use = ["mpi_allgather","mpi_allreduce","mpi_alltoall","mpi_barrier","mpi_bcast", "mpi_reduce", "mpi_scatter","mpi_exscan","mpi_gather", "mpi_reduce_scatter_block", "mpi_scan", "mpi_ibarrier", "mpi_iallreduce", "mpi_ialltoall", "mpi_ibcast", "mpi_ireduce", "mpi_iscatter", "mpi_igather", "mpi_iscan" ] + functions_to_use = ["mpi_allgather","mpi_allreduce","mpi_alltoall","mpi_barrier","mpi_bcast", "mpi_reduce", "mpi_scatter","mpi_exscan","mpi_gather", "mpi_reduce_scatter_block", "mpi_scan", "mpi_ibarrier", "mpi_iallreduce", "mpi_ialltoall", "mpi_ibcast", "mpi_ireduce", "mpi_iscatter", "mpi_igather", "mpi_iscan", "mpi_cart_create" ] functions_not_supported_yet = ["mpi_allgatherv", "mpi_alltoallv", "mpi_alltoallw", "mpi_gatherv", "mpi_reduce_scatter", "mpi_scatterv"] ####functions_to_use = ["mpi_allgather","mpi_allgatherv","mpi_allreduce","mpi_alltoall","mpi_alltoallv","mpi_alltoallw","mpi_barrier","mpi_bcast", "mpi_exscan","mpi_gather", "mpi_gatherv","mpi_reduce", "mpi_reduce_scatter", "mpi_reduce_scatter_block", "mpi_scan", "mpi_scatter", "mpi_scatterv", "mpi_ibarrier", "mpi_iallreduce", "mpi_ialltoall", "mpi_ibcast", "mpi_ireduce", "mpi_iscatter", "mpi_igather", "mpi_iscan"] - + topology_functions = ["mpi_cart_create"] def __init__(self): pass @@ -21,15 +21,28 @@ class InvalidComErrorColl(ErrorGenerator): for com_to_use in self.invalid_com: for func_to_use in self.functions_to_use: tm = get_collective_template(func_to_use) - arg_to_replace = "comm" - + tm.set_description("InvalidParam-Comm-"+func_to_use, "Invalid communicator: %s" % com_to_use) for call in tm.get_instruction("MPICALL", return_list=True): + arg_to_replace = "comm" if call.has_arg("comm") else "comm_old" call.set_arg(arg_to_replace, com_to_use) call.set_has_error() yield tm + + for fun_to_use in self.topology_functions: + tm = get_collective_template(func_to_use) + + for com_to_use in ["MPI_COMM_NULL", "NULL", "MPI_COMM_WORLD"]: + tm.set_description("InvalidParam-Comm-"+func_to_use+"-mpi_cart_get", "A function tries to get cartesian information of "+com_to_use) + + cart_get = CorrectMPICallFactory().mpi_cart_get() + cart_get.set_arg("comm_cart", com_to_use) + tm.register_instruction(cart_get) + cart_get.set_has_error() + yield tm + # only check for one comm if generate_level <= BASIC_TEST_LEVEL: return diff --git a/scripts/errors/coll/InvalidRank.py b/scripts/errors/coll/InvalidRank.py index 8b28ecf5384d3d12eeccb005855e5b6b44a12907..2b8583fe7453cfd2508e9a8374ef0cb3c4664ae3 100644 --- a/scripts/errors/coll/InvalidRank.py +++ b/scripts/errors/coll/InvalidRank.py @@ -6,7 +6,8 @@ from scripts.Infrastructure.TemplateFactory import get_collective_template class InvalidRankErrorColl(ErrorGenerator): invalid_ranks = ["-1", "nprocs", "MPI_PROC_NULL"] - functions_to_use = ["mpi_reduce", "mpi_bcast"] + functions_to_use = ["mpi_reduce", "mpi_bcast", "mpi_gather", "mpi_scatter", "mpi_ireduce", "mpi_ibcast", "mpi_igather", "mpi_iscatter"] + functions_not_supported_yet = ["mpi_gatherv", "mpi_scatterv", "mpi_igatherv", "mpi_iscatterv"] def __init__(self): pass @@ -20,11 +21,10 @@ class InvalidRankErrorColl(ErrorGenerator): for func_to_use in self.functions_to_use: for rank_to_use in self.invalid_ranks: tm = get_collective_template(func_to_use) - arg_to_replace = "root" tm.set_description("InvalidParam-Rank-"+func_to_use, "Invalid Rank: %s" % rank_to_use) for call in tm.get_instruction("MPICALL", return_list=True): - call.set_arg(arg_to_replace, rank_to_use) + call.set_arg("root", rank_to_use) call.set_has_error() yield tm diff --git a/scripts/errors/coll/InvalidType.py b/scripts/errors/coll/InvalidType.py index f780ee062ae604b5f10270612c98169293553148..a1ea8b436e3d8c90463632e54f7876d78df3fda8 100644 --- a/scripts/errors/coll/InvalidType.py +++ b/scripts/errors/coll/InvalidType.py @@ -2,6 +2,10 @@ from scripts.Infrastructure.Variables import * from scripts.Infrastructure.ErrorGenerator import ErrorGenerator +from scripts.Infrastructure.Instruction import Instruction +from scripts.Infrastructure.MPICallFactory import MPICallFactory, CorrectMPICallFactory +from scripts.Infrastructure.CorrectParameter import CorrectParameterFactory +from scripts.Infrastructure.Template import TemplateManager from scripts.Infrastructure.TemplateFactory import get_collective_template class InvalidComErrorColl(ErrorGenerator): diff --git a/scripts/errors/coll/LocalConcurrency.py b/scripts/errors/coll/LocalConcurrency.py new file mode 100644 index 0000000000000000000000000000000000000000..811ce739c13b1f5463933416072d7b46af6df5b5 --- /dev/null +++ b/scripts/errors/coll/LocalConcurrency.py @@ -0,0 +1,37 @@ +#! /usr/bin/python3 + +from scripts.Infrastructure.ErrorGenerator import ErrorGenerator +from scripts.Infrastructure.Instruction import Instruction +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_collective_template + +class InvalidRankErrorColl(ErrorGenerator): + nbfunc_to_use = ["mpi_iallreduce", "mpi_ialltoall", "mpi_ibcast", "mpi_ireduce", "mpi_iscatter", "mpi_igather", "mpi_iscan" ] + + def __init__(self): + pass + + + def get_feature(self): + return ["COLL"] + + + def generate(self, generate_full_set): + + for func_to_use in self.nbfunc_to_use: + tm = get_collective_template(func_to_use) + + tm.set_description("LocalConcurrency-"+func_to_use, "Usage of buffer before operation is completed") + + conflicting_inst = Instruction("buf[2]=1;") + conflicting_inst.set_has_error() + wait = tm.get_instruction("WAIT", return_list=True) + tm.insert_instruction(conflicting_inst,before_instruction=wait) + + + yield tm + + if not generate_full_set: + return \ No newline at end of file diff --git a/scripts/errors/coll/ParamMatching.py b/scripts/errors/coll/ParamMatching.py new file mode 100644 index 0000000000000000000000000000000000000000..6bfb81352a638dea46b09055f2d5ace025388352 --- /dev/null +++ b/scripts/errors/coll/ParamMatching.py @@ -0,0 +1,91 @@ +#! /usr/bin/python3 + +from scripts.Infrastructure.ErrorGenerator import ErrorGenerator +from scripts.Infrastructure.Instruction import Instruction +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_collective_template, get_two_collective_template + +class InvalidComErrorColl(ErrorGenerator): + functions_to_use = ["mpi_bcast", "mpi_ibcast", "mpi_reduce", "mpi_ireduce", "mpi_exscan", "mpi_scan", "mpi_iscan", "mpi_gather", "mpi_igather", "mpi_allgather", "mpi_iallgather", "mpi_allreduce", "mpi_iallreduce", "mpi_alltoall", "mpi_ialltoall", "mpi_scatter", "mpi_iscatter" ] + func_with_one_type_arg = ["mpi_bcast", "mpi_reduce", "mpi_exscan", "mpi_scan", "mpi_ibcast", "mpi_ireduce", "mpi_iscan", "mpi_allreduce", "mpi_iallreduce" ] + functions_not_supported_yet = ["mpi_reduce_scatter_block", "mpi_allgatherv", "mpi_alltoallv", "mpi_alltoallw", "mpi_gatherv", "mpi_reduce_scatter", "mpi_scatterv"] + func_with_op = ["mpi_reduce", "mpi_ireduce", "mpi_allreduce", "mpi_iallreduce"] + func_with_root = ["mpi_reduce", "mpi_bcast", "mpi_gather", "mpi_scatter", "mpi_ireduce", "mpi_ibcast", "mpi_igather", "mpi_iscatter"] + + def __init__(self): + pass + + def get_feature(self): + return ["COLL"] + + def generate(self, generate_full_set): + + # Generate codes with type mismatch + for func_to_use in self.func_with_one_type_arg: + tm = get_collective_template(func_to_use) + type_to_use = "MPI_DOUBLE" # this could be a list of types + tm.set_description("ParamMatching-Type-"+func_to_use, "Wrong datatype matching") + for call in tm.get_instruction("MPICALL", return_list=True): + call.set_rank_executing(0) + call.set_arg("datatype", type_to_use) + call.set_has_error() + c = CorrectMPICallFactory.get(func_to_use) + c.set_rank_executing('not0') + c.set_has_error() + tm.insert_instruction(c, after_instruction=call) + + yield tm + + # Generate codes with op mismatch + for func_to_use in self.func_with_op: + tm = get_collective_template(func_to_use) + op_to_use = "MPI_MAX" # this could be a list of op + tm.set_description("ParamMatching-Op-"+func_to_use, "Wrong operation matching") + + for call in tm.get_instruction("MPICALL", return_list=True): + call.set_rank_executing(0) + call.set_arg("op", op_to_use) + call.set_has_error() + c = CorrectMPICallFactory.get(func_to_use) + c.set_rank_executing('not0') + c.set_has_error() + tm.insert_instruction(c, after_instruction=call) + + yield tm + + # Generate codes with root mismatch + for func_to_use in self.func_with_root: + tm = get_collective_template(func_to_use) + rank_to_use = "rank" # process ID, declared in the template + tm.set_description("ParamMatching-Root-"+func_to_use, "Wrong root matching") + + for call in tm.get_instruction("MPICALL", return_list=True): + call.set_rank_executing(0) + call.set_arg("root", rank_to_use) + call.set_has_error() + c = CorrectMPICallFactory.get(func_to_use) + + yield tm + + # Generate codes with communicator mismatch + for func_to_use in self.functions_to_use: + tm = get_collective_template(func_to_use) + com_to_use = "MPI_COMM_SELF" + tm.set_description("ParamMatching-Com-"+func_to_use, "Wrong communicator matching") + + for call in tm.get_instruction("MPICALL", return_list=True): + call.set_rank_executing(0) + call.set_arg("comm", com_to_use) + call.set_has_error() + c = CorrectMPICallFactory.get(func_to_use) + c.set_rank_executing('not0') + c.set_has_error() + tm.insert_instruction(c, after_instruction=call) + + yield tm + + if not generate_full_set: + return + diff --git a/scripts/errors/coll/RequestLifeCycle.py b/scripts/errors/coll/RequestLifeCycle.py new file mode 100644 index 0000000000000000000000000000000000000000..f90d0ff6fd8f38abf35fe7e41b8c02352881c9cb --- /dev/null +++ b/scripts/errors/coll/RequestLifeCycle.py @@ -0,0 +1,37 @@ +#! /usr/bin/python3 + +from scripts.Infrastructure.ErrorGenerator import ErrorGenerator +from scripts.Infrastructure.Instruction import Instruction +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, get_collective_template + +class CorrectColl(ErrorGenerator): + nbfunc_to_use = ["mpi_ibarrier", "mpi_iallreduce", "mpi_ialltoall", "mpi_ibcast", "mpi_ireduce", "mpi_iscatter", "mpi_igather", "mpi_iscan" ] + functions_not_supported_yet = ["mpi_igatherv", "mpi_iscatterv"] + + def __init__(self): + pass + + + def get_feature(self): + return ["COLL"] + + + def generate(self, generate_full_set): + + for func_to_use in self.nbfunc_to_use: + tm = get_collective_template(func_to_use) + + tm.set_description("RequestLifeCycle-"+func_to_use, func_to_use+" is not associated with a completion operation (missing wait)") + + for call in tm.get_instruction("MPICALL", return_list=True): + wait = tm.get_instruction("WAIT", return_list=True) + tm.remove_instruction(instruction=wait) + call.set_has_error() + + yield tm + + if not generate_full_set: + return \ No newline at end of file