X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/15badc71ce964f6dae6428c9a4c0198fad5d4936..45c3f1cfee86fb48c96d53f8267f99b6db6e3d7a:/src/smpi/colls/bcast-SMP-binomial.c diff --git a/src/smpi/colls/bcast-SMP-binomial.c b/src/smpi/colls/bcast-SMP-binomial.c index 99193022b1..a45dca5fe4 100644 --- a/src/smpi/colls/bcast-SMP-binomial.c +++ b/src/smpi/colls/bcast-SMP-binomial.c @@ -1,3 +1,9 @@ +/* Copyright (c) 2013-2014. The SimGrid Team. + * All rights reserved. */ + +/* This program is free software; you can redistribute it and/or modify it + * under the terms of the license (GNU LGPL) which comes with this package. */ + #include "colls_private.h" #ifndef NUM_CORE #define NUM_CORE 8 @@ -11,19 +17,27 @@ int smpi_coll_tuned_bcast_SMP_binomial(void *buf, int count, int size; int rank; MPI_Status status; - int tag = 50; + int tag = COLL_TAG_BCAST; size = smpi_comm_size(comm); rank = smpi_comm_rank(comm); + int num_core = simcall_host_get_core(SIMIX_host_self()); + // do we use the default one or the number of cores in the platform ? + // if the number of cores is one, the platform may be simulated with 1 node = 1 core + if (num_core == 1) num_core = NUM_CORE; + + if(size%num_core) + THROWF(arg_error,0, "bcast SMP binomial can't be used with non multiple of NUM_CORE=%d number of processes ! ",num_core); + int to_intra, to_inter; int from_intra, from_inter; - int inter_rank = rank / NUM_CORE; - int inter_size = (size - 1) / NUM_CORE + 1; - int intra_rank = rank % NUM_CORE; - int intra_size = NUM_CORE; - if (((rank / NUM_CORE) * NUM_CORE) == ((size / NUM_CORE) * NUM_CORE)) - intra_size = size - (rank / NUM_CORE) * NUM_CORE; + int inter_rank = rank / num_core; + int inter_size = (size - 1) / num_core + 1; + int intra_rank = rank % num_core; + int intra_size = num_core; + if (((rank / num_core) * num_core) == ((size / num_core) * num_core)) + intra_size = size - (rank / num_core) * num_core; // if root is not zero send to rank zero first if (root != 0) { @@ -40,7 +54,7 @@ int smpi_coll_tuned_bcast_SMP_binomial(void *buf, int count, mask = 1; while (mask < inter_size) { if (inter_rank & mask) { - from_inter = (inter_rank - mask) * NUM_CORE; + from_inter = (inter_rank - mask) * num_core; //printf("Node %d recv from node %d when mask is %d\n", rank, from_inter, mask); smpi_mpi_recv(buf, count, datatype, from_inter, tag, comm, &status); break; @@ -53,7 +67,7 @@ int smpi_coll_tuned_bcast_SMP_binomial(void *buf, int count, while (mask > 0) { if (inter_rank < inter_size) { - to_inter = (inter_rank + mask) * NUM_CORE; + to_inter = (inter_rank + mask) * num_core; if (to_inter < size) { //printf("Node %d send to node %d when mask is %d\n", rank, to_inter, mask); smpi_mpi_send(buf, count, datatype, to_inter, tag, comm); @@ -64,7 +78,7 @@ int smpi_coll_tuned_bcast_SMP_binomial(void *buf, int count, } // SECOND STEP every root-of-each-SMP send to all children with binomial tree // base is a rank of root-of-each-SMP - int base = (rank / NUM_CORE) * NUM_CORE; + int base = (rank / num_core) * num_core; mask = 1; while (mask < intra_size) { if (intra_rank & mask) {