sendrecv_bench.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2019-2020 Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
  4. *
  5. * StarPU is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU Lesser General Public License as published by
  7. * the Free Software Foundation; either version 2.1 of the License, or (at
  8. * your option) any later version.
  9. *
  10. * StarPU is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. *
  14. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  15. */
  16. /*
  17. * Basic send receive benchmark.
  18. * Inspired a lot from NewMadeleine examples/benchmarks/nm_bench_sendrecv.c
  19. */
  20. #include <starpu_mpi.h>
  21. #include "helper.h"
  22. #include "abstract_sendrecv_bench.h"
  23. int main(int argc, char **argv)
  24. {
  25. int ret, rank, worldsize;
  26. int mpi_init;
  27. MPI_INIT_THREAD(&argc, &argv, MPI_THREAD_SERIALIZED, &mpi_init);
  28. ret = starpu_mpi_init_conf(&argc, &argv, mpi_init, MPI_COMM_WORLD, NULL);
  29. STARPU_CHECK_RETURN_VALUE(ret, "starpu_mpi_init_conf");
  30. starpu_mpi_comm_rank(MPI_COMM_WORLD, &rank);
  31. starpu_mpi_comm_size(MPI_COMM_WORLD, &worldsize);
  32. if (worldsize < 2)
  33. {
  34. if (rank == 0)
  35. FPRINTF(stderr, "We need 2 processes.\n");
  36. starpu_mpi_shutdown();
  37. if (!mpi_init)
  38. MPI_Finalize();
  39. return STARPU_TEST_SKIPPED;
  40. }
  41. /* Pause workers for this bench: all workers polling for tasks has a strong impact on performances */
  42. starpu_pause();
  43. sendrecv_bench(rank, NULL);
  44. starpu_resume();
  45. starpu_mpi_shutdown();
  46. if (!mpi_init)
  47. MPI_Finalize();
  48. return 0;
  49. }