load_balancer.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2017-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. #include <starpu_mpi.h>
  17. #include <starpu_mpi_lb.h>
  18. #include "helper.h"
  19. #if !defined(STARPU_HAVE_UNSETENV) || !defined(STARPU_USE_MPI_MPI)
  20. #warning unsetenv is not defined. Skipping test
  21. int main(int argc, char **argv)
  22. {
  23. return STARPU_TEST_SKIPPED;
  24. }
  25. #else
  26. void get_neighbors(int **neighbor_ids, int *nneighbors)
  27. {
  28. int rank, size;
  29. starpu_mpi_comm_rank(MPI_COMM_WORLD, &rank);
  30. starpu_mpi_comm_size(MPI_COMM_WORLD, &size);
  31. *nneighbors = 1;
  32. *neighbor_ids = malloc(sizeof(int));
  33. *neighbor_ids[0] = rank==size-1?0:rank+1;
  34. }
  35. void get_data_unit_to_migrate(starpu_data_handle_t **handle_unit, int *nhandles, int dst_node)
  36. {
  37. (void)handle_unit;
  38. (void)dst_node;
  39. *nhandles = 0;
  40. }
  41. int main(int argc, char **argv)
  42. {
  43. int ret;
  44. struct starpu_mpi_lb_conf itf;
  45. int mpi_init;
  46. itf.get_neighbors = get_neighbors;
  47. itf.get_data_unit_to_migrate = get_data_unit_to_migrate;
  48. MPI_INIT_THREAD(&argc, &argv, MPI_THREAD_SERIALIZED, &mpi_init);
  49. ret = starpu_mpi_init_conf(&argc, &argv, mpi_init, MPI_COMM_WORLD, NULL);
  50. STARPU_CHECK_RETURN_VALUE(ret, "starpu_mpi_init_conf");
  51. unsetenv("STARPU_MPI_LB");
  52. starpu_mpi_lb_init(NULL, NULL);
  53. starpu_mpi_lb_shutdown();
  54. starpu_mpi_lb_init("heat", &itf);
  55. starpu_mpi_lb_shutdown();
  56. starpu_mpi_shutdown();
  57. if (!mpi_init)
  58. MPI_Finalize();
  59. return 0;
  60. }
  61. #endif