sendrecv_bench.c 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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 pause_workers = 0;
  27. for (int i = 1; i < argc; i++)
  28. {
  29. if (strcmp(argv[i], "-p") == 0)
  30. {
  31. pause_workers = 1;
  32. printf("Workers will be paused during benchmark.\n");
  33. }
  34. else if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0)
  35. {
  36. fprintf(stderr, "Options:\n");
  37. fprintf(stderr, "\t-h --help display this help\n");
  38. fprintf(stderr, "\t-p pause workers during benchmark\n");
  39. exit(EXIT_SUCCESS);
  40. }
  41. else
  42. {
  43. fprintf(stderr,"Unrecognized option %s\n", argv[i]);
  44. exit(EXIT_FAILURE);
  45. }
  46. }
  47. ret = starpu_mpi_init_conf(&argc, &argv, 1, MPI_COMM_WORLD, NULL);
  48. STARPU_CHECK_RETURN_VALUE(ret, "starpu_mpi_init_conf");
  49. starpu_mpi_comm_rank(MPI_COMM_WORLD, &rank);
  50. starpu_mpi_comm_size(MPI_COMM_WORLD, &worldsize);
  51. if (worldsize < 2)
  52. {
  53. if (rank == 0)
  54. FPRINTF(stderr, "We need 2 processes.\n");
  55. starpu_mpi_shutdown();
  56. return STARPU_TEST_SKIPPED;
  57. }
  58. if (pause_workers)
  59. {
  60. /* Pause workers for this bench: all workers polling for tasks has a strong impact on performances */
  61. starpu_pause();
  62. }
  63. sendrecv_bench(rank, NULL);
  64. if (pause_workers)
  65. {
  66. starpu_resume();
  67. }
  68. starpu_mpi_shutdown();
  69. return 0;
  70. }