From: Augustin Degomme Date: Mon, 13 May 2019 08:26:16 +0000 (+0200) Subject: On some systems, sqrt(int) is not defined properly. On others its just implemented... X-Git-Tag: v3.22.4~127^2~37 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/34f9387eaac8b66b6f35293ee1aab7f2b7143ee2 On some systems, sqrt(int) is not defined properly. On others its just implemented with a conversion to double. --- diff --git a/src/smpi/colls/allgather/allgather-2dmesh.cpp b/src/smpi/colls/allgather/allgather-2dmesh.cpp index 0cfecd05d7..cb7ed513fc 100644 --- a/src/smpi/colls/allgather/allgather-2dmesh.cpp +++ b/src/smpi/colls/allgather/allgather-2dmesh.cpp @@ -69,7 +69,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. static int is_2dmesh(int num, int *i, int *j) { int x, max = num / 2; - x = sqrt(num); + x = sqrt(double(num)); while (x <= max) { if ((num % x) == 0) { diff --git a/src/smpi/colls/alltoall/alltoall-2dmesh.cpp b/src/smpi/colls/alltoall/alltoall-2dmesh.cpp index f9c7f09b36..7d9a906c5d 100644 --- a/src/smpi/colls/alltoall/alltoall-2dmesh.cpp +++ b/src/smpi/colls/alltoall/alltoall-2dmesh.cpp @@ -33,7 +33,7 @@ static int alltoall_check_is_2dmesh(int num, int *i, int *j) { int x, max = num / 2; - x = sqrt(num); + x = sqrt(double(num)); while (x <= max) { if ((num % x) == 0) { diff --git a/src/smpi/mpi/smpi_topo.cpp b/src/smpi/mpi/smpi_topo.cpp index 83b5147c1d..3376a52b97 100644 --- a/src/smpi/mpi/smpi_topo.cpp +++ b/src/smpi/mpi/smpi_topo.cpp @@ -387,8 +387,8 @@ static int getfactors(int num, int *nfactors, int **factors) { return MPI_SUCCESS; } /* Allocate the array of prime factors which cannot exceed log_2(num) entries */ - int sqrtnum = ceil(sqrt(num)); - int size = ceil(log(num) / log(2)); + int sqrtnum = ceil(sqrt(double(num))); + int size = ceil(log(double(num)) / log(2.0)); *factors = new int[size]; int i = 0;