starpu_mpi_req.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2010-2019 CNRS
  4. * Copyright (C) 2009-2019 Université de Bordeaux
  5. * Copyright (C) 2012,2013,2016,2017 Inria
  6. * Copyright (C) 2017 Guillaume Beauchamp
  7. *
  8. * StarPU is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU Lesser General Public License as published by
  10. * the Free Software Foundation; either version 2.1 of the License, or (at
  11. * your option) any later version.
  12. *
  13. * StarPU is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  16. *
  17. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  18. */
  19. #include <starpu.h>
  20. #include <starpu_mpi_private.h>
  21. void _starpu_mpi_request_init(struct _starpu_mpi_req **req)
  22. {
  23. _STARPU_MPI_CALLOC(*req, 1, sizeof(struct _starpu_mpi_req));
  24. /* Initialize the request structure */
  25. (*req)->data_handle = NULL;
  26. (*req)->prio = 0;
  27. (*req)->datatype = 0;
  28. (*req)->datatype_name = NULL;
  29. (*req)->ptr = NULL;
  30. (*req)->count = -1;
  31. (*req)->registered_datatype = -1;
  32. (*req)->node_tag.node.rank = -1;
  33. (*req)->node_tag.data_tag = -1;
  34. (*req)->node_tag.node.comm = 0;
  35. (*req)->func = NULL;
  36. (*req)->status = NULL;
  37. (*req)->flag = NULL;
  38. _starpu_mpi_req_multilist_init_coop_sends(*req);
  39. (*req)->ret = -1;
  40. (*req)->request_type = UNKNOWN_REQ;
  41. (*req)->submitted = 0;
  42. (*req)->completed = 0;
  43. (*req)->posted = 0;
  44. (*req)->sync = 0;
  45. (*req)->detached = -1;
  46. (*req)->callback = NULL;
  47. (*req)->callback_arg = NULL;
  48. (*req)->sequential_consistency = 1;
  49. (*req)->pre_sync_jobid = -1;
  50. (*req)->post_sync_jobid = -1;
  51. #ifdef STARPU_SIMGRID
  52. starpu_pthread_queue_init(&((*req)->queue));
  53. starpu_pthread_queue_register(&_starpu_mpi_thread_wait, &((*req)->queue));
  54. (*req)->done = 0;
  55. #endif
  56. _mpi_backend._starpu_mpi_backend_request_init(*req);
  57. }
  58. struct _starpu_mpi_req *_starpu_mpi_request_fill(starpu_data_handle_t data_handle,
  59. int srcdst, starpu_mpi_tag_t data_tag, MPI_Comm comm,
  60. unsigned detached, unsigned sync, int prio, void (*callback)(void *), void *arg,
  61. enum _starpu_mpi_request_type request_type, void (*func)(struct _starpu_mpi_req *),
  62. int sequential_consistency,
  63. int is_internal_req,
  64. starpu_ssize_t count)
  65. {
  66. struct _starpu_mpi_req *req;
  67. /* Initialize the request structure */
  68. _starpu_mpi_request_init(&req);
  69. req->request_type = request_type;
  70. /* prio_list is sorted by increasing values */
  71. if (_starpu_mpi_use_prio)
  72. req->prio = prio;
  73. req->data_handle = data_handle;
  74. req->node_tag.node.rank = srcdst;
  75. req->node_tag.data_tag = data_tag;
  76. req->node_tag.node.comm = comm;
  77. req->detached = detached;
  78. req->sync = sync;
  79. req->callback = callback;
  80. req->callback_arg = arg;
  81. req->func = func;
  82. req->sequential_consistency = sequential_consistency;
  83. req->count = count;
  84. _mpi_backend._starpu_mpi_backend_request_fill(req, comm, is_internal_req);
  85. return req;
  86. }
  87. void _starpu_mpi_request_destroy(struct _starpu_mpi_req *req)
  88. {
  89. _mpi_backend._starpu_mpi_backend_request_destroy(req);
  90. free(req->datatype_name);
  91. req->datatype_name = NULL;
  92. #ifdef STARPU_SIMGRID
  93. starpu_pthread_queue_unregister(&_starpu_mpi_thread_wait, &req->queue);
  94. starpu_pthread_queue_destroy(&req->queue);
  95. #endif
  96. free(req);
  97. }