starpu_mpi.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * StarPU
  3. * Copyright (C) INRIA 2008-2009 (see AUTHORS file)
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU Lesser General Public License as published by
  7. * the Free Software Foundation; either version 2.1 of the License, or (at
  8. * your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. *
  14. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  15. */
  16. #ifndef __STARPU_MPI_H__
  17. #define __STARPU_MPI_H__
  18. #include <starpu.h>
  19. #include <mpi.h>
  20. #include <common/list.h>
  21. #include <pthread.h>
  22. LIST_TYPE(starpu_mpi_req,
  23. /* description of the data at StarPU level */
  24. starpu_data_handle data_handle;
  25. /* description of the data to be sent/received */
  26. void *ptr;
  27. MPI_Datatype datatype;
  28. /* who are we talking to ? */
  29. int srcdst;
  30. int mpi_tag;
  31. MPI_Comm comm;
  32. void (*func)(struct starpu_mpi_req_s *);
  33. MPI_Status *status;
  34. MPI_Request request;
  35. int *flag;
  36. int ret;
  37. pthread_mutex_t req_mutex;
  38. pthread_cond_t req_cond;
  39. unsigned submitted;
  40. unsigned completed;
  41. /* In the case of a Wait/Test request, we are going to post a request
  42. * to test the completion of another request */
  43. struct starpu_mpi_req_s *other_request;
  44. /* in the case of detached requests */
  45. unsigned detached;
  46. void *callback_arg;
  47. void (*callback)(void *);
  48. );
  49. int starpu_mpi_isend(starpu_data_handle data_handle, struct starpu_mpi_req_s *req,
  50. int dest, int mpi_tag, MPI_Comm comm);
  51. int starpu_mpi_irecv(starpu_data_handle data_handle, struct starpu_mpi_req_s *req,
  52. int source, int mpi_tag, MPI_Comm comm);
  53. int starpu_mpi_send(starpu_data_handle data_handle,
  54. int dest, int mpi_tag, MPI_Comm comm);
  55. int starpu_mpi_recv(starpu_data_handle data_handle,
  56. int source, int mpi_tag, MPI_Comm comm, MPI_Status *status);
  57. int starpu_mpi_isend_detached(starpu_data_handle data_handle, int dest, int mpi_tag, MPI_Comm comm, void (*callback)(void *), void *arg);
  58. int starpu_mpi_irecv_detached(starpu_data_handle data_handle, int source, int mpi_tag, MPI_Comm comm, void (*callback)(void *), void *arg);
  59. int starpu_mpi_wait(struct starpu_mpi_req_s *req, MPI_Status *status);
  60. int starpu_mpi_test(struct starpu_mpi_req_s *req, int *flag, MPI_Status *status);
  61. int starpu_mpi_initialize(void);
  62. int starpu_mpi_shutdown(void);
  63. /* Some helper functions */
  64. /* When the transfer is completed, the tag is unlocked */
  65. int starpu_mpi_isend_detached_unlock_tag(starpu_data_handle data_handle, int dest, int mpi_tag, MPI_Comm comm, starpu_tag_t tag);
  66. int starpu_mpi_irecv_detached_unlock_tag(starpu_data_handle data_handle, int source, int mpi_tag, MPI_Comm comm, starpu_tag_t tag);
  67. #endif // __STARPU_MPI_H__