load_balancer.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2017 CNRS
  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)
  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 ret, 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. *nhandles = 0;
  38. }
  39. int main(int argc, char **argv)
  40. {
  41. int ret;
  42. struct starpu_mpi_lb_conf itf;
  43. itf.get_neighbors = get_neighbors;
  44. itf.get_data_unit_to_migrate = get_data_unit_to_migrate;
  45. MPI_INIT_THREAD(&argc, &argv, MPI_THREAD_SERIALIZED);
  46. ret = starpu_init(NULL);
  47. STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
  48. ret = starpu_mpi_init(NULL, NULL, 0);
  49. STARPU_CHECK_RETURN_VALUE(ret, "starpu_mpi_init");
  50. unsetenv("STARPU_MPI_LB");
  51. starpu_mpi_lb_init(NULL, NULL);
  52. starpu_mpi_lb_shutdown();
  53. starpu_mpi_lb_init("heat", &itf);
  54. starpu_mpi_lb_shutdown();
  55. starpu_mpi_shutdown();
  56. starpu_shutdown();
  57. MPI_Finalize();
  58. return 0;
  59. }
  60. #endif