load_balancer.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2017 CNRS
  4. * Copyright (C) 2017,2018 Université de Bordeaux
  5. *
  6. * StarPU is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU Lesser General Public License as published by
  8. * the Free Software Foundation; either version 2.1 of the License, or (at
  9. * your option) any later version.
  10. *
  11. * StarPU is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  14. *
  15. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  16. */
  17. #include <starpu_mpi.h>
  18. #include <starpu_mpi_lb.h>
  19. #include "helper.h"
  20. #if !defined(STARPU_HAVE_UNSETENV) || !defined(STARPU_USE_MPI_MPI)
  21. #warning unsetenv is not defined. Skipping test
  22. int main(int argc, char **argv)
  23. {
  24. return STARPU_TEST_SKIPPED;
  25. }
  26. #else
  27. void get_neighbors(int **neighbor_ids, int *nneighbors)
  28. {
  29. int rank, size;
  30. starpu_mpi_comm_rank(MPI_COMM_WORLD, &rank);
  31. starpu_mpi_comm_size(MPI_COMM_WORLD, &size);
  32. *nneighbors = 1;
  33. *neighbor_ids = malloc(sizeof(int));
  34. *neighbor_ids[0] = rank==size-1?0:rank+1;
  35. }
  36. void get_data_unit_to_migrate(starpu_data_handle_t **handle_unit, int *nhandles, int dst_node)
  37. {
  38. (void)handle_unit;
  39. (void)dst_node;
  40. *nhandles = 0;
  41. }
  42. int main(int argc, char **argv)
  43. {
  44. int ret;
  45. struct starpu_mpi_lb_conf itf;
  46. int mpi_init;
  47. itf.get_neighbors = get_neighbors;
  48. itf.get_data_unit_to_migrate = get_data_unit_to_migrate;
  49. MPI_INIT_THREAD(&argc, &argv, MPI_THREAD_SERIALIZED, &mpi_init);
  50. ret = starpu_mpi_init_conf(&argc, &argv, mpi_init, MPI_COMM_WORLD, NULL);
  51. STARPU_CHECK_RETURN_VALUE(ret, "starpu_mpi_init_conf");
  52. unsetenv("STARPU_MPI_LB");
  53. starpu_mpi_lb_init(NULL, NULL);
  54. starpu_mpi_lb_shutdown();
  55. starpu_mpi_lb_init("heat", &itf);
  56. starpu_mpi_lb_shutdown();
  57. starpu_mpi_shutdown();
  58. if (!mpi_init)
  59. MPI_Finalize();
  60. return 0;
  61. }
  62. #endif