driver_mpi_sink.c 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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 <dlfcn.h>
  19. #include "driver_mpi_sink.h"
  20. #include "driver_mpi_source.h"
  21. #include "driver_mpi_common.h"
  22. void _starpu_mpi_sink_init(struct _starpu_mp_node *node)
  23. {
  24. _starpu_mpi_common_mp_initialize_src_sink(node);
  25. _STARPU_MALLOC(node->thread_table, sizeof(starpu_pthread_t)*node->nb_cores);
  26. //TODO
  27. }
  28. void _starpu_mpi_sink_deinit(struct _starpu_mp_node *node)
  29. {
  30. int i;
  31. node->is_running = 0;
  32. for(i=0; i<node->nb_cores; i++)
  33. {
  34. sem_post(&node->sem_run_table[i]);
  35. starpu_pthread_join(((starpu_pthread_t *)node->thread_table)[i],NULL);
  36. }
  37. free(node->thread_table);
  38. }
  39. void (*_starpu_mpi_sink_lookup (const struct _starpu_mp_node * node STARPU_ATTRIBUTE_UNUSED, char* func_name))(void)
  40. {
  41. void *dl_handle = dlopen(NULL, RTLD_NOW);
  42. return dlsym(dl_handle, func_name);
  43. }
  44. void _starpu_mpi_sink_launch_workers(struct _starpu_mp_node *node)
  45. {
  46. //TODO
  47. int i, ret;
  48. struct arg_sink_thread * arg;
  49. cpu_set_t cpuset;
  50. starpu_pthread_attr_t attr;
  51. starpu_pthread_t thread;
  52. for(i=0; i < node->nb_cores; i++)
  53. {
  54. //init the set
  55. CPU_ZERO(&cpuset);
  56. CPU_SET(i,&cpuset);
  57. ret = starpu_pthread_attr_init(&attr);
  58. STARPU_ASSERT(ret == 0);
  59. ret = pthread_attr_setaffinity_np(&attr, sizeof(cpu_set_t), &cpuset);
  60. STARPU_ASSERT(ret == 0);
  61. /*prepare the argument for the thread*/
  62. _STARPU_MALLOC(arg, sizeof(struct arg_sink_thread));
  63. arg->coreid = i;
  64. arg->node = node;
  65. ret = starpu_pthread_create(&thread, &attr, _starpu_sink_thread, arg);
  66. STARPU_ASSERT(ret == 0);
  67. ((starpu_pthread_t *)node->thread_table)[i] = thread;
  68. }
  69. }
  70. void _starpu_mpi_sink_bind_thread(const struct _starpu_mp_node *mp_node STARPU_ATTRIBUTE_UNUSED, int coreid, int * core_table, int nb_core)
  71. {
  72. //TODO
  73. }