starpu_mpi_private.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2010, 2012-2013 Université de Bordeaux
  4. * Copyright (C) 2010, 2011, 2012, 2013 Centre National de la Recherche Scientifique
  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. #ifndef __STARPU_MPI_PRIVATE_H__
  18. #define __STARPU_MPI_PRIVATE_H__
  19. #include <starpu.h>
  20. #include <common/config.h>
  21. #include <common/uthash.h>
  22. #include "starpu_mpi.h"
  23. #include "starpu_mpi_fxt.h"
  24. #include <common/list.h>
  25. #ifdef __cplusplus
  26. extern "C" {
  27. #endif
  28. #ifdef STARPU_VERBOSE
  29. extern int _debug_rank;
  30. extern int _debug_level_min;
  31. extern int _debug_level_max;
  32. void _starpu_mpi_set_debug_level_min(int level);
  33. void _starpu_mpi_set_debug_level_max(int level);
  34. #endif
  35. #ifdef STARPU_VERBOSE
  36. # define _STARPU_MPI_DEBUG(level, fmt, ...) \
  37. do \
  38. { \
  39. if (!getenv("STARPU_SILENT") && _debug_level_min <= level && level <= _debug_level_max) \
  40. { \
  41. if (_debug_rank == -1) MPI_Comm_rank(MPI_COMM_WORLD, &_debug_rank); \
  42. fprintf(stderr, "%*s[%d][starpu_mpi][%s:%d] " fmt , (_debug_rank+1)*4, "", _debug_rank, __starpu_func__ , __LINE__,## __VA_ARGS__); \
  43. fflush(stderr); \
  44. } \
  45. } while(0);
  46. #else
  47. # define _STARPU_MPI_DEBUG(level, fmt, ...)
  48. #endif
  49. #define _STARPU_MPI_DISP(fmt, ...) do { if (!getenv("STARPU_SILENT")) { \
  50. if (_debug_rank == -1) MPI_Comm_rank(MPI_COMM_WORLD, &_debug_rank); \
  51. fprintf(stderr, "%*s[%d][starpu_mpi][%s:%d] " fmt , (_debug_rank+1)*4, "", _debug_rank, __starpu_func__ , __LINE__ ,## __VA_ARGS__); \
  52. fflush(stderr); }} while(0);
  53. #ifdef STARPU_VERBOSE0
  54. # define _STARPU_MPI_LOG_IN() do { if (!getenv("STARPU_SILENT")) { \
  55. if (_debug_rank == -1) MPI_Comm_rank(MPI_COMM_WORLD, &_debug_rank); \
  56. fprintf(stderr, "%*s[%d][starpu_mpi][%s:%d] -->\n", (_debug_rank+1)*4, "", _debug_rank, __starpu_func__ , __LINE__); \
  57. fflush(stderr); }} while(0)
  58. # define _STARPU_MPI_LOG_OUT() do { if (!getenv("STARPU_SILENT")) { \
  59. if (_debug_rank == -1) MPI_Comm_rank(MPI_COMM_WORLD, &_debug_rank); \
  60. fprintf(stderr, "%*s[%d][starpu_mpi][%s:%d] <--\n", (_debug_rank+1)*4, "", _debug_rank, __starpu_func__, __LINE__ ); \
  61. fflush(stderr); }} while(0)
  62. #else
  63. # define _STARPU_MPI_LOG_IN()
  64. # define _STARPU_MPI_LOG_OUT()
  65. #endif
  66. extern int _starpu_mpi_tag;
  67. enum _starpu_mpi_request_type
  68. {
  69. SEND_REQ=0,
  70. RECV_REQ=1,
  71. WAIT_REQ=2,
  72. TEST_REQ=3,
  73. BARRIER_REQ=4,
  74. PROBE_REQ=5,
  75. UNKNOWN_REQ=6,
  76. };
  77. struct _starpu_mpi_envelope
  78. {
  79. ssize_t size;
  80. int mpi_tag;
  81. };
  82. struct _starpu_mpi_req;
  83. LIST_TYPE(_starpu_mpi_req,
  84. /* description of the data at StarPU level */
  85. starpu_data_handle_t data_handle;
  86. /* description of the data to be sent/received */
  87. MPI_Datatype datatype;
  88. void *ptr;
  89. ssize_t count;
  90. int user_datatype;
  91. /* who are we talking to ? */
  92. int srcdst;
  93. int mpi_tag;
  94. MPI_Comm comm;
  95. void (*func)(struct _starpu_mpi_req *);
  96. MPI_Status *status;
  97. MPI_Request request;
  98. int *flag;
  99. int ret;
  100. starpu_pthread_mutex_t req_mutex;
  101. starpu_pthread_cond_t req_cond;
  102. starpu_pthread_mutex_t posted_mutex;
  103. starpu_pthread_cond_t posted_cond;
  104. enum _starpu_mpi_request_type request_type; /* 0 send, 1 recv */
  105. unsigned submitted;
  106. unsigned completed;
  107. unsigned posted;
  108. UT_hash_handle hh;
  109. /* In the case of a Wait/Test request, we are going to post a request
  110. * to test the completion of another request */
  111. struct _starpu_mpi_req *other_request;
  112. /* in the case of detached requests */
  113. unsigned detached;
  114. void *callback_arg;
  115. void (*callback)(void *);
  116. /* in the case of user-defined datatypes, we need to send the size of the data */
  117. MPI_Request size_req;
  118. struct _starpu_mpi_envelope* envelope;
  119. int is_internal_req;
  120. struct _starpu_mpi_req *internal_req;
  121. int sequential_consistency;
  122. );
  123. #ifdef __cplusplus
  124. }
  125. #endif
  126. #endif // __STARPU_MPI_PRIVATE_H__