starpu_mpi.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. #include <starpu_mpi.h>
  17. pthread_cond_t cond;
  18. pthread_mutex_t mutex;
  19. pthread_t progress_thread;
  20. static int handle_to_datatype(starpu_data_handle data_handle, MPI_Datatype *datatype)
  21. {
  22. /* TODO we assume that we have a vector yet ! */
  23. unsigned nx = starpu_get_vector_nx(data_handle);
  24. size_t elemsize = starpu_get_vector_elemsize(data_handle);
  25. MPI_Type_contiguous(nx*elemsize, MPI_BYTE, datatype);
  26. MPI_Type_commit(datatype);
  27. return 0;
  28. }
  29. int starpu_mpi_isend(starpu_data_handle data_handle, starpu_mpi_req_t *req,
  30. int dest, int mpi_tag, MPI_Comm comm,
  31. void (*callback)(void *))
  32. {
  33. return 0;
  34. }
  35. int starpu_mpi_irecv(starpu_data_handle data_handle, starpu_mpi_req_t *req,
  36. int source, int mpi_tag, MPI_Comm comm,
  37. void (*callback)(void *))
  38. {
  39. return 0;
  40. }
  41. int starpu_mpi_recv(starpu_data_handle data_handle,
  42. int source, int mpi_tag, MPI_Comm comm)
  43. {
  44. /* TODO test if we are blocking in a callback .. */
  45. starpu_sync_data_with_mem(data_handle, STARPU_W);
  46. void *ptr = (void *)starpu_get_vector_local_ptr(data_handle);
  47. MPI_Status status;
  48. MPI_Datatype datatype;
  49. handle_to_datatype(data_handle, &datatype);
  50. MPI_Recv(ptr, 1, datatype, source, mpi_tag, comm, &status);
  51. starpu_release_data_from_mem(data_handle);
  52. return 0;
  53. }
  54. int starpu_mpi_send(starpu_data_handle data_handle,
  55. int dest, int mpi_tag, MPI_Comm comm)
  56. {
  57. /* TODO test if we are blocking in a callback .. */
  58. starpu_sync_data_with_mem(data_handle, STARPU_R);
  59. void *ptr = (void *)starpu_get_vector_local_ptr(data_handle);
  60. MPI_Status status;
  61. MPI_Datatype datatype;
  62. handle_to_datatype(data_handle, &datatype);
  63. MPI_Send(ptr, 1, datatype, dest, mpi_tag, comm);
  64. starpu_release_data_from_mem(data_handle);
  65. return 0;
  66. }
  67. int starpu_mpi_wait(starpu_mpi_req_t *req)
  68. {
  69. return 0;
  70. }
  71. int starpu_mpi_test(starpu_mpi_req_t *req, int *flag)
  72. {
  73. return 0;
  74. }
  75. int starpu_mpi_initialize(void)
  76. {
  77. return 0;
  78. }
  79. int starpu_mpi_shutdown(void)
  80. {
  81. return 0;
  82. }