starpu_mpi_req.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2009-2021 Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
  4. * Copyright (C) 2017 Guillaume Beauchamp
  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.h>
  18. #include <starpu_mpi_private.h>
  19. void _starpu_mpi_request_init(struct _starpu_mpi_req **req)
  20. {
  21. _STARPU_MPI_CALLOC(*req, 1, sizeof(struct _starpu_mpi_req));
  22. /* Initialize the request structure */
  23. //(*req)->data_handle = NULL;
  24. //(*req)->prio = 0;
  25. (*req)->node = (unsigned) -1;
  26. //(*req)->datatype = 0;
  27. //(*req)->datatype_name = NULL;
  28. //(*req)->ptr = NULL;
  29. (*req)->count = -1;
  30. (*req)->registered_datatype = -1;
  31. (*req)->node_tag.node.rank = -1;
  32. (*req)->node_tag.data_tag = -1;
  33. //(*req)->node_tag.node.comm = 0;
  34. //(*req)->func = NULL;
  35. //(*req)->status = NULL;
  36. //(*req)->flag = NULL;
  37. _starpu_mpi_req_multilist_init_coop_sends(*req);
  38. (*req)->ret = -1;
  39. (*req)->request_type = UNKNOWN_REQ;
  40. //(*req)->submitted = 0;
  41. //(*req)->completed = 0;
  42. //(*req)->posted = 0;
  43. //(*req)->sync = 0;
  44. (*req)->detached = -1;
  45. //(*req)->callback = NULL;
  46. //(*req)->callback_arg = NULL;
  47. (*req)->sequential_consistency = 1;
  48. (*req)->pre_sync_jobid = -1;
  49. (*req)->post_sync_jobid = -1;
  50. #ifdef STARPU_SIMGRID
  51. starpu_pthread_queue_init(&((*req)->queue));
  52. starpu_pthread_queue_register(&_starpu_mpi_thread_wait, &((*req)->queue));
  53. //(*req)->done = 0;
  54. #endif
  55. _mpi_backend._starpu_mpi_backend_request_init(*req);
  56. }
  57. struct _starpu_mpi_req *_starpu_mpi_request_fill(starpu_data_handle_t data_handle,
  58. int srcdst, starpu_mpi_tag_t data_tag, MPI_Comm comm,
  59. unsigned detached, unsigned sync, int prio, void (*callback)(void *), void *arg,
  60. enum _starpu_mpi_request_type request_type, void (*func)(struct _starpu_mpi_req *),
  61. int sequential_consistency,
  62. int is_internal_req,
  63. starpu_ssize_t count)
  64. {
  65. struct _starpu_mpi_req *req;
  66. /* Initialize the request structure */
  67. _starpu_mpi_request_init(&req);
  68. req->request_type = request_type;
  69. /* prio_list is sorted by increasing values */
  70. if (_starpu_mpi_use_prio)
  71. req->prio = prio;
  72. req->data_handle = data_handle;
  73. req->node_tag.node.rank = srcdst;
  74. req->node_tag.data_tag = data_tag;
  75. req->node_tag.node.comm = comm;
  76. req->detached = detached;
  77. req->sync = sync;
  78. req->callback = callback;
  79. req->callback_arg = arg;
  80. req->func = func;
  81. req->sequential_consistency = sequential_consistency;
  82. req->count = count;
  83. _mpi_backend._starpu_mpi_backend_request_fill(req, comm, is_internal_req);
  84. return req;
  85. }
  86. void _starpu_mpi_request_destroy(struct _starpu_mpi_req *req)
  87. {
  88. _mpi_backend._starpu_mpi_backend_request_destroy(req);
  89. free(req->datatype_name);
  90. req->datatype_name = NULL;
  91. #ifdef STARPU_SIMGRID
  92. starpu_pthread_queue_unregister(&_starpu_mpi_thread_wait, &req->queue);
  93. starpu_pthread_queue_destroy(&req->queue);
  94. #endif
  95. free(req);
  96. }