simgrid.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2012-2017 Université de Bordeaux
  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. #ifndef __SIMGRID_H__
  18. #define __SIMGRID_H__
  19. #ifdef STARPU_SIMGRID
  20. #ifdef STARPU_HAVE_SIMGRID_MSG_H
  21. #include <simgrid/msg.h>
  22. #else
  23. #include <msg/msg.h>
  24. #endif
  25. #include <datawizard/data_request.h>
  26. #include <xbt/xbt_os_time.h>
  27. struct _starpu_pthread_args
  28. {
  29. void *(*f)(void*);
  30. void *arg;
  31. };
  32. #define MAX_TSD 16
  33. #define STARPU_MPI_AS_PREFIX "StarPU-MPI"
  34. #define _starpu_simgrid_running_smpi() (getenv("SMPI_GLOBAL_SIZE") != NULL)
  35. void _starpu_simgrid_init_early(int *argc, char ***argv);
  36. void _starpu_simgrid_init(void);
  37. void _starpu_simgrid_deinit(void);
  38. void _starpu_simgrid_wait_tasks(int workerid);
  39. void _starpu_simgrid_submit_job(int workerid, struct _starpu_job *job, struct starpu_perfmodel_arch* perf_arch, double length, unsigned *finished);
  40. int _starpu_simgrid_transfer(size_t size, unsigned src_node, unsigned dst_node, struct _starpu_data_request *req);
  41. int _starpu_simgrid_wait_transfer_event(union _starpu_async_channel_event *event);
  42. int _starpu_simgrid_test_transfer_event(union _starpu_async_channel_event *event);
  43. /* Return the number of hosts prefixed by PREFIX */
  44. int _starpu_simgrid_get_nbhosts(const char *prefix);
  45. unsigned long long _starpu_simgrid_get_memsize(const char *prefix, unsigned devid);
  46. msg_host_t _starpu_simgrid_get_host_by_name(const char *name);
  47. msg_host_t _starpu_simgrid_get_memnode_host(unsigned node);
  48. struct _starpu_worker;
  49. msg_host_t _starpu_simgrid_get_host_by_worker(struct _starpu_worker *worker);
  50. void _starpu_simgrid_get_platform_path(int version, char *path, size_t maxlen);
  51. msg_as_t _starpu_simgrid_get_as_by_name(const char *name);
  52. #pragma weak starpu_mpi_world_rank
  53. extern int starpu_mpi_world_rank(void);
  54. #pragma weak _starpu_mpi_simgrid_init
  55. int _starpu_mpi_simgrid_init(int argc, char *argv[]);
  56. starpu_pthread_queue_t _starpu_simgrid_transfer_queue[STARPU_MAXNODES];
  57. starpu_pthread_queue_t _starpu_simgrid_task_queue[STARPU_NMAXWORKERS];
  58. #define _starpu_simgrid_cuda_malloc_cost() starpu_get_env_number_default("STARPU_SIMGRID_CUDA_MALLOC_COST", 1)
  59. #define _starpu_simgrid_queue_malloc_cost() starpu_get_env_number_default("STARPU_SIMGRID_QUEUE_MALLOC_COST", 1)
  60. #define _starpu_simgrid_task_submit_cost() starpu_get_env_number_default("STARPU_SIMGRID_TASK_SUBMIT_COST", 1)
  61. #define _starpu_simgrid_fetching_input_cost() starpu_get_env_number_default("STARPU_SIMGRID_FETCHING_INPUT_COST", 1)
  62. #define _starpu_simgrid_sched_cost() starpu_get_env_number_default("STARPU_SIMGRID_SCHED_COST", 1)
  63. /* Called at initialization to count how many GPUs are interfering with each
  64. * bus */
  65. void _starpu_simgrid_count_ngpus(void);
  66. void _starpu_simgrid_xbt_thread_create(const char *name, void_f_pvoid_t code,
  67. void *param);
  68. #define _SIMGRID_TIMER_BEGIN \
  69. { \
  70. xbt_os_timer_t __timer = NULL; \
  71. if (_starpu_simgrid_sched_cost()) { \
  72. __timer = xbt_os_timer_new(); \
  73. xbt_os_threadtimer_start(__timer); \
  74. }
  75. #define _SIMGRID_TIMER_END \
  76. if (__timer) { \
  77. xbt_os_threadtimer_stop(__timer); \
  78. MSG_process_sleep(xbt_os_timer_elapsed(__timer));\
  79. xbt_os_timer_free(__timer); \
  80. } \
  81. }
  82. #else // !STARPU_SIMGRID
  83. #define _SIMGRID_TIMER_BEGIN {
  84. #define _SIMGRID_TIMER_END }
  85. #endif
  86. #endif // __SIMGRID_H__