driver_mpi_sink.c 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2015 Mathieu Lirzin <mthl@openmailbox.org>
  4. * Copyright (C) 2016 Inria
  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 <mpi.h>
  18. #include "driver_mpi_sink.h"
  19. #include "driver_mpi_common.h"
  20. void _starpu_mpi_sink_init(struct _starpu_mp_node *node)
  21. {
  22. _starpu_mpi_common_mp_initialize_src_sink(node);
  23. node->thread_table = malloc(sizeof(starpu_pthread_t)*node->nb_cores);
  24. //TODO
  25. }
  26. void _starpu_mpi_sink_deinit(struct _starpu_mp_node *node)
  27. {
  28. free(node->thread_table);
  29. //TODO
  30. }
  31. void _starpu_mpi_sink_launch_workers(struct _starpu_mp_node *node)
  32. {
  33. //TODO
  34. int i, ret;
  35. struct arg_sink_thread * arg;
  36. cpu_set_t cpuset;
  37. starpu_pthread_attr_t attr;
  38. starpu_pthread_t thread;
  39. for(i=0; i < node->nb_cores; i++)
  40. {
  41. //init the set
  42. CPU_ZERO(&cpuset);
  43. CPU_SET(i,&cpuset);
  44. ret = starpu_pthread_attr_init(&attr);
  45. STARPU_ASSERT(ret == 0);
  46. ret = pthread_attr_setaffinity_np(&attr, sizeof(cpu_set_t), &cpuset);
  47. STARPU_ASSERT(ret == 0);
  48. /*prepare the argument for the thread*/
  49. arg= malloc(sizeof(struct arg_sink_thread));
  50. arg->coreid = i;
  51. arg->node = node;
  52. ret = starpu_pthread_create(&thread, &attr, _starpu_sink_thread, arg);
  53. STARPU_ASSERT(ret == 0);
  54. ((starpu_pthread_t *)node->thread_table)[i] = thread;
  55. }
  56. }
  57. void _starpu_mpi_sink_bind_thread(const struct _starpu_mp_node *mp_node STARPU_ATTRIBUTE_UNUSED, int coreid, int * core_table, int nb_core)
  58. {
  59. //TODO
  60. }
  61. //void _starpu_mpi_sink_send(const struct _starpu_mp_node *sink, void *msg,
  62. // int len)
  63. //{
  64. // int dst = STARPU_MP_SRC_NODE;
  65. // if (MPI_Send(msg, len, MPI_CHAR, dst, dst, MPI_COMM_WORLD))
  66. // STARPU_MP_COMMON_REPORT_ERROR(sink, errno);
  67. //}
  68. //
  69. //void _starpu_mpi_sink_recv(const struct _starpu_mp_node *sink, void *msg,
  70. // int len)
  71. //{
  72. // int src = STARPU_MP_SRC_NODE;
  73. // if (MPI_Recv(msg, len, MPI_CHAR, src, sink->mp_connection.mpi_nodeid,
  74. // MPI_COMM_WORLD, MPI_STATUS_IGNORE))
  75. // STARPU_MP_COMMON_REPORT_ERROR(sink, errno);
  76. //}