From 1e09e1421647408f991d54848b90d9404e9154f6 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Wed, 18 Oct 2017 16:50:59 +0200 Subject: [PATCH 1/1] Merge if statements. --- src/xbt/graph.c | 9 ++++----- teshsuite/smpi/coll-allgather/coll-allgather.c | 10 ++++------ teshsuite/smpi/coll-allgatherv/coll-allgatherv.c | 10 ++++------ teshsuite/smpi/coll-allreduce/coll-allreduce.c | 10 ++++------ teshsuite/smpi/coll-alltoall/coll-alltoall.c | 10 ++++------ teshsuite/smpi/coll-bcast/coll-bcast.c | 10 ++++------ 6 files changed, 24 insertions(+), 35 deletions(-) diff --git a/src/xbt/graph.c b/src/xbt/graph.c index b82a58179d..b5f95c6632 100644 --- a/src/xbt/graph.c +++ b/src/xbt/graph.c @@ -226,11 +226,10 @@ void xbt_floyd_algorithm(xbt_graph_t g, double *adj, double *d, xbt_node_t * p) for (k = 0; k < n; k++) { for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { - if ((d[i*n+k] > -1) && (d[k*n+j] > -1)) { - if ((d[i*n+j] < 0) || (d[i*n+j] > d[i*n+k] + d[k*n+j])) { - d[i*n+j] = d[i*n+k] + d[k*n+j]; - p[i*n+j] = p[k*n+j]; - } + if (d[i * n + k] > -1 && d[k * n + j] > -1 && + (d[i * n + j] < 0 || d[i * n + j] > d[i * n + k] + d[k * n + j])) { + d[i * n + j] = d[i * n + k] + d[k * n + j]; + p[i * n + j] = p[k * n + j]; } } } diff --git a/teshsuite/smpi/coll-allgather/coll-allgather.c b/teshsuite/smpi/coll-allgather/coll-allgather.c index 68cfc76500..83ba94a2c3 100644 --- a/teshsuite/smpi/coll-allgather/coll-allgather.c +++ b/teshsuite/smpi/coll-allgather/coll-allgather.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2009-2010, 2013-2014. The SimGrid Team. +/* Copyright (c) 2009-2010, 2013-2017. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it @@ -46,11 +46,9 @@ int main(int argc, char *argv[]) printf("%d ", rb[i]); printf("]\n"); - if (rank == 0) { - if (status != MPI_SUCCESS) { - printf("allgather returned %d\n", status); - fflush(stdout); - } + if (rank == 0 && status != MPI_SUCCESS) { + printf("allgather returned %d\n", status); + fflush(stdout); } xbt_free(sb); xbt_free(rb); diff --git a/teshsuite/smpi/coll-allgatherv/coll-allgatherv.c b/teshsuite/smpi/coll-allgatherv/coll-allgatherv.c index 30734f17d5..7e2f35e81a 100644 --- a/teshsuite/smpi/coll-allgatherv/coll-allgatherv.c +++ b/teshsuite/smpi/coll-allgatherv/coll-allgatherv.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2009-2010, 2013-2014. The SimGrid Team. +/* Copyright (c) 2009-2010, 2013-2017. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it @@ -56,11 +56,9 @@ int main(int argc, char *argv[]) printf("%d ", rb[i]); printf("]\n"); - if (rank == 0) { - if (status != MPI_SUCCESS) { - printf("allgatherv returned %d\n", status); - fflush(stdout); - } + if (rank == 0 && status != MPI_SUCCESS) { + printf("allgatherv returned %d\n", status); + fflush(stdout); } xbt_free(sb); xbt_free(rb); diff --git a/teshsuite/smpi/coll-allreduce/coll-allreduce.c b/teshsuite/smpi/coll-allreduce/coll-allreduce.c index 509aec9883..c35732fce6 100644 --- a/teshsuite/smpi/coll-allreduce/coll-allreduce.c +++ b/teshsuite/smpi/coll-allreduce/coll-allreduce.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2009-2010, 2013-2014. The SimGrid Team. +/* Copyright (c) 2009-2010, 2013-2017. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it @@ -50,11 +50,9 @@ int main(int argc, char *argv[]) printf("%d ", rb[i]); printf("]\n"); - if (rank == 0) { - if (status != MPI_SUCCESS) { - printf("all_to_all returned %d\n", status); - fflush(stdout); - } + if (rank == 0 && status != MPI_SUCCESS) { + printf("all_to_all returned %d\n", status); + fflush(stdout); } xbt_free(sb); xbt_free(rb); diff --git a/teshsuite/smpi/coll-alltoall/coll-alltoall.c b/teshsuite/smpi/coll-alltoall/coll-alltoall.c index 1bbcf69d17..da76146ad3 100644 --- a/teshsuite/smpi/coll-alltoall/coll-alltoall.c +++ b/teshsuite/smpi/coll-alltoall/coll-alltoall.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2009-2010, 2013-2014. The SimGrid Team. +/* Copyright (c) 2009-2010, 2013-2017. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it @@ -46,11 +46,9 @@ int main(int argc, char *argv[]) printf("%d ", rb[i]); printf("]\n"); - if (rank == 0) { - if (status != MPI_SUCCESS) { - printf("all_to_all returned %d\n", status); - fflush(stdout); - } + if (rank == 0 && status != MPI_SUCCESS) { + printf("all_to_all returned %d\n", status); + fflush(stdout); } xbt_free(sb); xbt_free(rb); diff --git a/teshsuite/smpi/coll-bcast/coll-bcast.c b/teshsuite/smpi/coll-bcast/coll-bcast.c index e8aeaecc0a..a53771ad4c 100644 --- a/teshsuite/smpi/coll-bcast/coll-bcast.c +++ b/teshsuite/smpi/coll-bcast/coll-bcast.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2009, 2013-2014. The SimGrid Team. +/* Copyright (c) 2009, 2013-2017. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it @@ -46,11 +46,9 @@ int main(int argc, char **argv) if (values[i]==17) good++; printf("[%d] number of values equals to 17: %d\n", rank, good); - if (rank == 0) { - if (status != MPI_SUCCESS) { - printf("bcast returned %d\n", status); - fflush(stdout); - } + if (rank == 0 && status != MPI_SUCCESS) { + printf("bcast returned %d\n", status); + fflush(stdout); } xbt_free(values); MPI_Finalize(); -- 2.20.1