starpu_mpi_req.c 3.3 KB

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