From: Martin Quinson Date: Sun, 24 Jul 2016 19:27:19 +0000 (+0200) Subject: kill two obscure SMPI examples X-Git-Tag: v3_14~724 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/0849140b2492bfcb59a4703ee08e8b95c58e1f9e?ds=sidebyside kill two obscure SMPI examples They were added in the very beginning of SMPI development, are not specially useful, and present absolutely not explanation or documentation. Plus, they represent a bunch of days of quality debt on Sonar. Death. --- diff --git a/.gitignore b/.gitignore index 7fe508f7ab..98812d8a7a 100644 --- a/.gitignore +++ b/.gitignore @@ -199,7 +199,6 @@ examples/simdag/throttling/sd_throttling examples/simdag/fail/sd_fail examples/simdag/test/sd_test examples/simdag/typed_tasks/sd_typed_tasks -examples/smpi/bcbench/smpi_bcbench examples/smpi/energy/f77/sef examples/smpi/energy/f90/sef90 examples/smpi/energy/smpi_energy @@ -214,7 +213,6 @@ examples/smpi/mc/send_deterministic examples/smpi/NAS/dt examples/smpi/NAS/ep examples/smpi/NAS/is -examples/smpi/mvmul/smpi_mvmul examples/smpi/replay_multiple/replay_multiple examples/smpi/replay/one_trace examples/smpi/ring_c @@ -284,6 +282,7 @@ teshsuite/smpi/coll-bcast/coll-bcast teshsuite/smpi/coll-barrier/coll-barrier teshsuite/smpi/coll-gather/coll-gather teshsuite/smpi/macro-sample/macro-sample +teshsuite/smpi/timers/timers teshsuite/smpi/type-hvector/type-hvector teshsuite/smpi/type-indexed/type-indexed teshsuite/smpi/isp/umpire/abort diff --git a/examples/smpi/CMakeLists.txt b/examples/smpi/CMakeLists.txt index e1847b2107..376a992668 100644 --- a/examples/smpi/CMakeLists.txt +++ b/examples/smpi/CMakeLists.txt @@ -4,7 +4,7 @@ if(enable_smpi) file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/mc/") - foreach(x bcbench mvmul replay trace trace_simple trace_call_location energy) + foreach(x replay trace trace_simple trace_call_location energy) add_executable (smpi_${x} ${CMAKE_CURRENT_SOURCE_DIR}/${x}/${x}.c) target_link_libraries(smpi_${x} simgrid) set_target_properties(smpi_${x} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${x}) diff --git a/examples/smpi/bcbench/bcbench.c b/examples/smpi/bcbench/bcbench.c deleted file mode 100644 index 082250ded9..0000000000 --- a/examples/smpi/bcbench/bcbench.c +++ /dev/null @@ -1,96 +0,0 @@ -/* Copyright (c) 2009-2010, 2012-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 -#include -#include - -#ifdef _WIN32 - #define srandom srand - #define random rand -#endif - -#define GETTIMEOFDAY_ERROR 1 - -#define N_START 1 -#define N_STOP 1024*1024 -#define N_NEXT (N*2) -#define ITER 100 -#define ONE_MILLION 1000000.0 -#define RAND_SEED 842270 - -int main(int argc, char *argv[]) -{ - int size, rank; - struct timeval *start_time = NULL, *stop_time = NULL; - double seconds = 0; - char *buffer; - int check; - - srandom(RAND_SEED); - - MPI_Init(&argc, &argv); - - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &size); - - if (0 == rank) { - start_time = (struct timeval *) malloc(sizeof(struct timeval)); - stop_time = (struct timeval *) malloc(sizeof(struct timeval)); - } - - for (int N = N_START; N <= N_STOP; N = N_NEXT) { - buffer = malloc(sizeof(char) * N); - - if (0 == rank) { - for (int j = 0; j < N; j++) { - buffer[j] = (char) (random() % 256); - } - if (-1 == gettimeofday(start_time, NULL)) { - printf("couldn't set start_time on node 0!\n"); - MPI_Abort(MPI_COMM_WORLD, GETTIMEOFDAY_ERROR); - exit(EXIT_FAILURE); - } - } - - for (int i = 0; i < ITER; i++) { - MPI_Bcast(buffer, N, MPI_BYTE, 0, MPI_COMM_WORLD); - if (0 == rank) { - for (int j = 1; j < size; j++) { - MPI_Recv(&check, 1, MPI_INT, MPI_ANY_SOURCE, 1, MPI_COMM_WORLD, MPI_STATUS_IGNORE); - } - } else { - MPI_Send(&rank, 1, MPI_INT, 0, 1, MPI_COMM_WORLD); - } - } - - if (0 == rank) { - if (-1 == gettimeofday(stop_time, NULL)) { - printf("couldn't set start_time on node 0!\n"); - MPI_Abort(MPI_COMM_WORLD, GETTIMEOFDAY_ERROR); - exit(EXIT_FAILURE); - } - seconds = (double) (stop_time->tv_sec - start_time->tv_sec) + - (double) (stop_time->tv_usec - start_time->tv_usec) / ONE_MILLION; - } - - free(buffer); - - if (0 == rank) { - printf("N: %10d, iter: %d, time: %10f s, avg rate: %12f Mbps\n", N, ITER, seconds, - ((double) N * ITER * 8) / (1024.0 * 1024.0 * seconds)); - } - } - - if (0 == rank) { - free(start_time); - free(stop_time); - } - - MPI_Finalize(); - - return 0; -} diff --git a/examples/smpi/mvmul/mvmul.c b/examples/smpi/mvmul/mvmul.c deleted file mode 100644 index fd2581397d..0000000000 --- a/examples/smpi/mvmul/mvmul.c +++ /dev/null @@ -1,207 +0,0 @@ -/* Copyright (c) 2009-2010, 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 -#include -#include -#include -#include - -#define ITERATIONS 10 -#define USAGE_ERROR 1 -#define SANITY_ERROR 2 -#define GETTIMEOFDAY_ERROR 3 - -int main(int argc, char *argv[]) -{ - int size, rank; - int N, n, i, j, k, current_iteration, successful_iterations = 0; - double *matrix = NULL, *vector = NULL, *vcalc, *vcheck; - MPI_Status status; - struct timeval *start_time = NULL, *stop_time = NULL; - long parallel_usecs, parallel_usecs_total = 0, sequential_usecs, sequential_usecs_total = 0; - - MPI_Init(&argc, &argv); - - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &size); - - if (0 == rank) { - // root node parses cmdline args - if (2 > argc || !isdigit(*argv[1])) { - printf("usage:\n%s \n", argv[0]); - MPI_Abort(MPI_COMM_WORLD, USAGE_ERROR); - exit(USAGE_ERROR); - } - - N = xbt_str_parse_int(argv[1], "Invalid size: %s"); - - start_time = (struct timeval *) malloc(sizeof(struct timeval)); - stop_time = (struct timeval *) malloc(sizeof(struct timeval)); - } - - for (current_iteration = 0; current_iteration < ITERATIONS; current_iteration++) { - if (0 == rank) { - matrix = (double *) malloc(N * N * sizeof(double)); - vector = (double *) malloc(N * sizeof(double)); - - for (i = 0; i < N * N; i++) { - matrix[i] = (double) rand() / ((double) RAND_MAX + 1); - } - - for (i = 0; i < N; i++) { - vector[i] = (double) rand() / ((double) RAND_MAX + 1); - } - - // for the sake of argument, the parallel algorithm begins when the root node begins to transmit the matrix to the - // workers. - if (-1 == gettimeofday(start_time, NULL)) { - printf("couldn't set start_time on node 0!\n"); - MPI_Abort(MPI_COMM_WORLD, GETTIMEOFDAY_ERROR); - exit(GETTIMEOFDAY_ERROR); - } - - for (i = 1; i < size; i++) { - MPI_Send(&N, 1, MPI_INT, i, 0, MPI_COMM_WORLD); - } - } else { - MPI_Recv(&N, 1, MPI_INT, 0, 0, MPI_COMM_WORLD, &status); - } - - // this algorithm uses at most N processors... - if (rank < N) { - if (size > N) - size = N; - n = N / size + ((rank < (N % size)) ? 1 : 0); - - if (0 == rank) { - for (i = 1, j = n; i < size && j < N; i++, j += k) { - k = N / size + ((i < (N % size)) ? 1 : 0); - MPI_Send(matrix + N * j, N * k, MPI_DOUBLE, i, 0, MPI_COMM_WORLD); - MPI_Send(vector, N, MPI_DOUBLE, i, 0, MPI_COMM_WORLD); - } - - // sanity check -#ifdef DEBUG - if (i != size || j != N) { - printf("index calc error: i = %d, size = %d, j = %d, N = %d\n", i, size, j, N); - MPI_Abort(MPI_COMM_WORLD, SANITY_ERROR); - exit(SANITY_ERROR); - } -#endif - - vcalc = (double *) malloc(N * sizeof(double)); - } else { - matrix = (double *) malloc(N * n * sizeof(double)); - vector = (double *) malloc(N * sizeof(double)); - vcalc = (double *) malloc(n * sizeof(double)); - - MPI_Recv(matrix, N * n, MPI_DOUBLE, 0, 0, MPI_COMM_WORLD, &status); - MPI_Recv(vector, N, MPI_DOUBLE, 0, 0, MPI_COMM_WORLD, &status); - } - - for (i = 0; i < n; i++) { - vcalc[i] = 0.0; - for (j = 0; j < N; j++) { - vcalc[i] += matrix[N * i + j] * vector[j]; - } - } - - if (0 != rank) { - MPI_Send(vcalc, n, MPI_DOUBLE, 0, 0, MPI_COMM_WORLD); - } else { - for (i = 1, j = n; i < size && j < N; i++, j += k) { - k = N / size + ((i < (N % size)) ? 1 : 0); - MPI_Recv(vcalc + j, k, MPI_DOUBLE, i, 0, MPI_COMM_WORLD, &status); - } - - // sanity check -#ifdef DEBUG - if (i != size || j != N) { - printf("index calc error 2: i = %d, size = %d, j = %d, N = %d\n", i, size, j, N); - MPI_Abort(MPI_COMM_WORLD, SANITY_ERROR); - exit(SANITY_ERROR); - } -#endif - - if (-1 == gettimeofday(stop_time, NULL)) { - printf("couldn't set stop_time on node 0!\n"); - MPI_Abort(MPI_COMM_WORLD, GETTIMEOFDAY_ERROR); - exit(GETTIMEOFDAY_ERROR); - } - - parallel_usecs = (stop_time->tv_sec * 1000000 + stop_time->tv_usec) - - (start_time->tv_sec * 1000000 + start_time->tv_usec); - - if (-1 == gettimeofday(start_time, NULL)) { - printf("couldn't set start_time on node 0!\n"); - MPI_Abort(MPI_COMM_WORLD, GETTIMEOFDAY_ERROR); - exit(GETTIMEOFDAY_ERROR); - } - // calculate serially - vcheck = (double *) malloc(N * sizeof(double)); - for (i = 0; i < N; i++) { - vcheck[i] = 0.0; - for (j = 0; j < N; j++) { - vcheck[i] += matrix[N * i + j] * vector[j]; - } - } - - if (-1 == gettimeofday(stop_time, NULL)) { - printf("couldn't set stop_time on node 0!\n"); - MPI_Abort(MPI_COMM_WORLD, GETTIMEOFDAY_ERROR); - exit(GETTIMEOFDAY_ERROR); - } - - sequential_usecs = (stop_time->tv_sec * 1000000 + stop_time->tv_usec) - - (start_time->tv_sec * 1000000 + start_time->tv_usec); - - // verify correctness - for (i = 0; i < N && vcalc[i] == vcheck[i]; i++); - - printf("prog: blocking, i: %d ", current_iteration); - - if (i == N) { - printf("ptime: %ld us, stime: %ld us, speedup: %.3f, nodes: %d, efficiency: %.3f\n", - parallel_usecs, sequential_usecs, (double) sequential_usecs / (double) parallel_usecs, size, - (double) sequential_usecs / ((double) parallel_usecs * (double) size)); - - parallel_usecs_total += parallel_usecs; - sequential_usecs_total += sequential_usecs; - successful_iterations++; - } else { - printf("parallel calc != serial calc, "); - } - - free(vcheck); - } - - free(matrix); - free(vector); - free(vcalc); - } - } - - if (0 == rank) { - printf("prog: blocking, "); - if (0 < successful_iterations) { - printf("iterations: %d, avg. ptime: %.3f us, avg. stime: %.3f us, avg. speedup: %.3f, nodes: %d, avg. efficiency: %.3f\n", - successful_iterations, (double) parallel_usecs_total / (double) successful_iterations, - (double) sequential_usecs_total / (double) successful_iterations, - (double) sequential_usecs_total / (double) parallel_usecs_total, size, - (double) sequential_usecs_total / ((double) parallel_usecs_total * (double) size)); - } else { - printf("no successful iterations!\n"); - } - - free(start_time); - free(stop_time); - } - - MPI_Finalize(); - - return 0; -}