diff --git a/scripts/Infrastructure/CorrectParameter.py b/scripts/Infrastructure/CorrectParameter.py index 0a2fc99c27730054ddfb8d70c5c424b6fa7c3886..db8d5517dd03772fb196b6a6fd44aba7c5c91be6 100644 --- a/scripts/Infrastructure/CorrectParameter.py +++ b/scripts/Infrastructure/CorrectParameter.py @@ -105,10 +105,12 @@ class CorrectParameterFactory: return "&mpi_comm_0" if param in ["comm_old"]: return "MPI_COMM_WORLD" - if param in ["ndims"]: + 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"]: 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 a90a6567040b2b3214ed94f3fa545a9ec99106e7..1d36fa97984d93c37e73ffefb5d33a0b38eeccbe 100644 --- a/scripts/Infrastructure/TemplateFactory.py +++ b/scripts/Infrastructure/TemplateFactory.py @@ -201,8 +201,11 @@ def get_collective_template(collective_func): 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") # use MPI_Dims_create(nprocs,2,dims); - + 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"): diff --git a/scripts/errors/coll/Correct.py b/scripts/errors/coll/Correct.py index 0e09ce4a85825443fb7aa19fe61516a0d6c9f853..4201aa6653a659f30e212e138c9671b5df02f42d 100644 --- a/scripts/errors/coll/Correct.py +++ b/scripts/errors/coll/Correct.py @@ -5,11 +5,12 @@ 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 +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", "mpi_cart_create" ] + 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 @@ -20,11 +21,28 @@ class CorrectColl(ErrorGenerator): 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 + if not generate_full_set: + return diff --git a/scripts/errors/coll/InvalidComm.py b/scripts/errors/coll/InvalidComm.py index a4240dbb7c23f0fab537c9c6e41ba36a2b00ad15..e09e63231a9d9113e2214bb667774a3e828e8309 100644 --- a/scripts/errors/coll/InvalidComm.py +++ b/scripts/errors/coll/InvalidComm.py @@ -12,7 +12,7 @@ class InvalidComErrorColl(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", "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 @@ -33,6 +33,19 @@ class InvalidComErrorColl(ErrorGenerator): 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 not generate_full_set: return