starpu_mpi_nmad_backend.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2009-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 <stdlib.h>
  17. #include "starpu_mpi_nmad_backend.h"
  18. #include <starpu_mpi_private.h>
  19. #include "starpu_mpi_nmad.h"
  20. #ifdef STARPU_USE_MPI_NMAD
  21. static void starpu_mpi_nmad_backend_constructor(void) __attribute__((constructor));
  22. static void starpu_mpi_nmad_backend_constructor(void)
  23. {
  24. /* strat_prio is preferred for StarPU instead of default strat_aggreg */
  25. setenv("NMAD_STRATEGY", "prio", 0 /* do not overwrite user-supplied value, if set */);
  26. /* prefer rcache on ibverbs */
  27. setenv("NMAD_IBVERBS_RCACHE", "1", 0);
  28. /* use pioman dedicated thread */
  29. setenv("PIOM_DEDICATED", "1", 0);
  30. /* pioman waits for starpu to place its dedicated thread */
  31. setenv("PIOM_DEDICATED_WAIT", "1", 0);
  32. }
  33. void _starpu_mpi_nmad_backend_init(struct starpu_conf *conf)
  34. {
  35. (void)conf;
  36. }
  37. void _starpu_mpi_nmad_backend_shutdown(void)
  38. {
  39. }
  40. int _starpu_mpi_nmad_backend_reserve_core(void)
  41. {
  42. return 1;
  43. }
  44. void _starpu_mpi_nmad_backend_request_init(struct _starpu_mpi_req *req)
  45. {
  46. _STARPU_MPI_CALLOC(req->backend, 1, sizeof(struct _starpu_mpi_req_backend));
  47. piom_cond_init(&req->backend->req_cond, 0);
  48. }
  49. void _starpu_mpi_nmad_backend_request_fill(struct _starpu_mpi_req *req, MPI_Comm comm, int is_internal_req)
  50. {
  51. /* this function gives session and gate: */
  52. nm_mpi_nmad_dest(&req->backend->session, &req->backend->gate, comm, req->node_tag.node.rank);
  53. }
  54. void _starpu_mpi_nmad_backend_request_destroy(struct _starpu_mpi_req *req)
  55. {
  56. piom_cond_destroy(&(req->backend->req_cond));
  57. free(req->backend);
  58. }
  59. void _starpu_mpi_nmad_backend_data_clear(starpu_data_handle_t data_handle)
  60. {
  61. (void)data_handle;
  62. }
  63. void _starpu_mpi_nmad_backend_data_register(starpu_data_handle_t data_handle, starpu_mpi_tag_t data_tag)
  64. {
  65. (void)data_handle;
  66. (void)data_tag;
  67. }
  68. void _starpu_mpi_nmad_backend_comm_register(MPI_Comm comm)
  69. {
  70. (void)comm;
  71. }
  72. struct _starpu_mpi_backend _mpi_backend =
  73. {
  74. ._starpu_mpi_backend_init = _starpu_mpi_nmad_backend_init,
  75. ._starpu_mpi_backend_shutdown = _starpu_mpi_nmad_backend_shutdown,
  76. ._starpu_mpi_backend_reserve_core = _starpu_mpi_nmad_backend_reserve_core,
  77. ._starpu_mpi_backend_request_init = _starpu_mpi_nmad_backend_request_init,
  78. ._starpu_mpi_backend_request_fill = _starpu_mpi_nmad_backend_request_fill,
  79. ._starpu_mpi_backend_request_destroy = _starpu_mpi_nmad_backend_request_destroy,
  80. ._starpu_mpi_backend_data_clear = _starpu_mpi_nmad_backend_data_clear,
  81. ._starpu_mpi_backend_data_register = _starpu_mpi_nmad_backend_data_register,
  82. ._starpu_mpi_backend_comm_register = _starpu_mpi_nmad_backend_comm_register,
  83. ._starpu_mpi_backend_progress_init = _starpu_mpi_progress_init,
  84. ._starpu_mpi_backend_progress_shutdown = _starpu_mpi_progress_shutdown,
  85. //#ifdef STARPU_SIMGRID
  86. // ._starpu_mpi_backend_wait_for_initialization = _starpu_mpi_wait_for_initialization,
  87. //#endif
  88. ._starpu_mpi_backend_barrier = _starpu_mpi_barrier,
  89. ._starpu_mpi_backend_wait_for_all = _starpu_mpi_wait_for_all,
  90. ._starpu_mpi_backend_wait = _starpu_mpi_wait,
  91. ._starpu_mpi_backend_test = _starpu_mpi_test,
  92. ._starpu_mpi_backend_isend_size_func = _starpu_mpi_isend_size_func,
  93. ._starpu_mpi_backend_irecv_size_func = _starpu_mpi_irecv_size_func,
  94. };
  95. #endif /* STARPU_USE_MPI_NMAD*/