starpu_mpi_private.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2010, 2012 Université de Bordeaux 1
  4. * Copyright (C) 2010, 2011, 2012 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 "starpu_mpi.h"
  22. #include "starpu_mpi_fxt.h"
  23. #include <common/list.h>
  24. #include <common/utils.h>
  25. #include <pthread.h>
  26. #ifdef __cplusplus
  27. extern "C" {
  28. #endif
  29. //#define STARPU_MPI_VERBOSE 1
  30. #ifdef STARPU_MPI_VERBOSE
  31. # define _STARPU_MPI_DEBUG(fmt, args ...) do { if (!getenv("STARPU_SILENT")) { \
  32. int _debug_rank; MPI_Comm_rank(MPI_COMM_WORLD, &_debug_rank); \
  33. fprintf(stderr, "%*s[%d][starpu_mpi][%s] " fmt , (_debug_rank+1)*4, "", _debug_rank, __func__ ,##args); \
  34. fflush(stderr); }} while(0);
  35. #else
  36. # define _STARPU_MPI_DEBUG(fmt, args ...)
  37. #endif
  38. #define _STARPU_MPI_DISP(fmt, args ...) do { if (!getenv("STARPU_SILENT")) { \
  39. int _debug_rank; MPI_Comm_rank(MPI_COMM_WORLD, &_debug_rank); \
  40. fprintf(stderr, "%*s[%d][starpu_mpi][%s] " fmt , (_debug_rank+1)*4, "", _debug_rank, __func__ ,##args); \
  41. fflush(stderr); }} while(0);
  42. #ifdef STARPU_MPI_VERBOSE0
  43. # define _STARPU_MPI_LOG_IN() do { if (!getenv("STARPU_SILENT")) { \
  44. int _debug_rank; MPI_Comm_rank(MPI_COMM_WORLD, &_debug_rank); \
  45. fprintf(stderr, "%*s[%d][starpu_mpi][%s] -->\n", (_debug_rank+1)*4, "", _debug_rank, __func__ ); \
  46. fflush(stderr); }} while(0)
  47. # define _STARPU_MPI_LOG_OUT() do { if (!getenv("STARPU_SILENT")) { \
  48. int _debug_rank; MPI_Comm_rank(MPI_COMM_WORLD, &_debug_rank); \
  49. fprintf(stderr, "%*s[%d][starpu_mpi][%s] <--\n", (_debug_rank+1)*4, "", _debug_rank, __func__ ); \
  50. fflush(stderr); }} while(0)
  51. #else
  52. # define _STARPU_MPI_LOG_IN()
  53. # define _STARPU_MPI_LOG_OUT()
  54. #endif
  55. enum _starpu_mpi_request_type
  56. {
  57. SEND_REQ=0,
  58. RECV_REQ=1,
  59. WAIT_REQ=2,
  60. TEST_REQ=3,
  61. BARRIER_REQ=4,
  62. PROBE_REQ=5
  63. };
  64. LIST_TYPE(_starpu_mpi_req,
  65. /* description of the data at StarPU level */
  66. starpu_data_handle_t data_handle;
  67. /* description of the data to be sent/received */
  68. MPI_Datatype datatype;
  69. void *ptr;
  70. size_t count;
  71. int user_datatype;
  72. /* who are we talking to ? */
  73. int srcdst;
  74. int mpi_tag;
  75. MPI_Comm comm;
  76. void (*func)(struct _starpu_mpi_req *);
  77. MPI_Status *status;
  78. MPI_Request request;
  79. int *flag;
  80. int ret;
  81. _starpu_pthread_mutex_t req_mutex;
  82. _starpu_pthread_cond_t req_cond;
  83. enum _starpu_mpi_request_type request_type; /* 0 send, 1 recv */
  84. unsigned submitted;
  85. unsigned completed;
  86. /* In the case of a Wait/Test request, we are going to post a request
  87. * to test the completion of another request */
  88. struct _starpu_mpi_req *other_request;
  89. /* in the case of detached requests */
  90. unsigned detached;
  91. void *callback_arg;
  92. void (*callback)(void *);
  93. );
  94. #ifdef __cplusplus
  95. }
  96. #endif
  97. #endif // __STARPU_MPI_PRIVATE_H__