- int gather_id = find_coll_description(mpi_coll_gather_description, sg_cfg_get_string("smpi/gather"),"gather");
- mpi_coll_gather_fun = (int (*)(void *, int, MPI_Datatype, void *, int, MPI_Datatype, int, MPI_Comm))
- mpi_coll_gather_description[gather_id].coll;
-
- int allgather_id = find_coll_description(mpi_coll_allgather_description,
- sg_cfg_get_string("smpi/allgather"),"allgather");
- mpi_coll_allgather_fun = (int (*)(void *, int, MPI_Datatype, void *, int, MPI_Datatype, MPI_Comm))
- mpi_coll_allgather_description[allgather_id].coll;
-
- int allgatherv_id = find_coll_description(mpi_coll_allgatherv_description,
- sg_cfg_get_string("smpi/allgatherv"),"allgatherv");
- mpi_coll_allgatherv_fun = (int (*)(void *, int, MPI_Datatype, void *, int *, int *, MPI_Datatype, MPI_Comm))
- mpi_coll_allgatherv_description[allgatherv_id].coll;
-
- int allreduce_id = find_coll_description(mpi_coll_allreduce_description,
- sg_cfg_get_string("smpi/allreduce"),"allreduce");
- mpi_coll_allreduce_fun = (int (*)(void *sbuf, void *rbuf, int rcount, MPI_Datatype dtype, MPI_Op op, MPI_Comm comm))
- mpi_coll_allreduce_description[allreduce_id].coll;
-
- int alltoall_id = find_coll_description(mpi_coll_alltoall_description,
- sg_cfg_get_string("smpi/alltoall"),"alltoall");
- mpi_coll_alltoall_fun = (int (*)(void *, int, MPI_Datatype, void *, int, MPI_Datatype, MPI_Comm))
- mpi_coll_alltoall_description[alltoall_id].coll;
-
- int alltoallv_id = find_coll_description(mpi_coll_alltoallv_description,
- sg_cfg_get_string("smpi/alltoallv"),"alltoallv");
- mpi_coll_alltoallv_fun = (int (*)(void *, int *, int *, MPI_Datatype, void *, int *, int *, MPI_Datatype, MPI_Comm))
- mpi_coll_alltoallv_description[alltoallv_id].coll;
-
- int bcast_id = find_coll_description(mpi_coll_bcast_description, sg_cfg_get_string("smpi/bcast"),"bcast");
- mpi_coll_bcast_fun = (int (*)(void *buf, int count, MPI_Datatype datatype, int root, MPI_Comm com))
- mpi_coll_bcast_description[bcast_id].coll;
-
- int reduce_id = find_coll_description(mpi_coll_reduce_description, sg_cfg_get_string("smpi/reduce"),"reduce");
- mpi_coll_reduce_fun = (int (*)(void *buf, void *rbuf, int count, MPI_Datatype datatype, MPI_Op op, int root,
- MPI_Comm comm)) mpi_coll_reduce_description[reduce_id].coll;
-
- int reduce_scatter_id =
- find_coll_description(mpi_coll_reduce_scatter_description,
- sg_cfg_get_string("smpi/reduce_scatter"),"reduce_scatter");
- mpi_coll_reduce_scatter_fun = (int (*)(void *sbuf, void *rbuf, int *rcounts,MPI_Datatype dtype, MPI_Op op,
- MPI_Comm comm)) mpi_coll_reduce_scatter_description[reduce_scatter_id].coll;
-
- int scatter_id = find_coll_description(mpi_coll_scatter_description, sg_cfg_get_string("smpi/scatter"),"scatter");
- mpi_coll_scatter_fun = (int (*)(void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf,
- int recvcount, MPI_Datatype recvtype, int root, MPI_Comm comm))
- mpi_coll_scatter_description[scatter_id].coll;
-
- int barrier_id = find_coll_description(mpi_coll_barrier_description, sg_cfg_get_string("smpi/barrier"),"barrier");
- mpi_coll_barrier_fun = (int (*)(MPI_Comm comm)) mpi_coll_barrier_description[barrier_id].coll;
-
- smpi_cpu_threshold = sg_cfg_get_double("smpi/cpu_threshold");
- smpi_running_power = sg_cfg_get_double("smpi/running_power");
- smpi_privatize_global_variables = sg_cfg_get_boolean("smpi/privatize_global_variables");
+ //return if already called
+ if (smpi_cpu_threshold > -1)
+ return;
+ simgrid::smpi::Colls::set_collectives();
+ simgrid::smpi::Colls::smpi_coll_cleanup_callback=nullptr;
+ smpi_cpu_threshold = xbt_cfg_get_double("smpi/cpu-threshold");
+ smpi_host_speed = xbt_cfg_get_double("smpi/host-speed");
+ const char* smpi_privatize_option = xbt_cfg_get_string("smpi/privatization");
+ if (std::strcmp(smpi_privatize_option, "no") == 0)
+ smpi_privatize_global_variables = SMPI_PRIVATIZE_NONE;
+ else if (std::strcmp(smpi_privatize_option, "yes") == 0)
+ smpi_privatize_global_variables = SMPI_PRIVATIZE_DEFAULT;
+ else if (std::strcmp(smpi_privatize_option, "mmap") == 0)
+ smpi_privatize_global_variables = SMPI_PRIVATIZE_MMAP;
+ else if (std::strcmp(smpi_privatize_option, "dlopen") == 0)
+ smpi_privatize_global_variables = SMPI_PRIVATIZE_DLOPEN;
+
+ // Some compatibility stuff:
+ else if (std::strcmp(smpi_privatize_option, "1") == 0)
+ smpi_privatize_global_variables = SMPI_PRIVATIZE_DEFAULT;
+ else if (std::strcmp(smpi_privatize_option, "0") == 0)
+ smpi_privatize_global_variables = SMPI_PRIVATIZE_NONE;
+
+ else
+ xbt_die("Invalid value for smpi/privatization: %s", smpi_privatize_option);
+