nothing.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 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. * This program does nothing. It waits until it is interrupted by the user.
  18. * Useful to check binding while StarPU is running.
  19. */
  20. #include <starpu_mpi.h>
  21. #include <unistd.h>
  22. #include "helper.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_pause(); // our program will only wait, no need to stress cores by polling workers
  31. starpu_mpi_comm_rank(MPI_COMM_WORLD, &rank);
  32. starpu_mpi_comm_size(MPI_COMM_WORLD, &worldsize);
  33. starpu_mpi_barrier(MPI_COMM_WORLD);
  34. char hostname[65];
  35. gethostname(hostname, sizeof(hostname));
  36. printf("[rank %d on %s] ready to wait !\n", rank, hostname);
  37. if (rank == 0)
  38. {
  39. printf("You can now check if thread binding is correct, for instance.\n");
  40. }
  41. fflush(stdout);
  42. while(1)
  43. {
  44. sleep(1);
  45. }
  46. // TODO: maybe better handle the user interruption ?
  47. starpu_resume();
  48. starpu_mpi_shutdown();
  49. if (!mpi_init)
  50. MPI_Finalize();
  51. return 0;
  52. }