simgrid.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2013,2017 CNRS
  4. * Copyright (C) 2016-2017 Inria
  5. * Copyright (C) 2012-2017 Université de Bordeaux
  6. *
  7. * StarPU is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU Lesser General Public License as published by
  9. * the Free Software Foundation; either version 2.1 of the License, or (at
  10. * your option) any later version.
  11. *
  12. * StarPU is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  15. *
  16. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  17. */
  18. #ifndef __SIMGRID_H__
  19. #define __SIMGRID_H__
  20. #ifdef __cplusplus
  21. extern "C"
  22. {
  23. #endif
  24. #ifdef STARPU_SIMGRID
  25. #ifdef STARPU_HAVE_SIMGRID_MSG_H
  26. #include <simgrid/msg.h>
  27. #else
  28. #include <msg/msg.h>
  29. #endif
  30. #include <xbt/xbt_os_time.h>
  31. struct _starpu_pthread_args
  32. {
  33. void *(*f)(void*);
  34. void *arg;
  35. };
  36. #define MAX_TSD 16
  37. #define STARPU_MPI_AS_PREFIX "StarPU-MPI"
  38. #define _starpu_simgrid_running_smpi() (getenv("SMPI_GLOBAL_SIZE") != NULL)
  39. void _starpu_start_simgrid(int *argc, char **argv);
  40. void _starpu_simgrid_init_early(int *argc, char ***argv);
  41. void _starpu_simgrid_init(void);
  42. void _starpu_simgrid_deinit(void);
  43. void _starpu_simgrid_deinit_late(void);
  44. void _starpu_simgrid_wait_tasks(int workerid);
  45. struct _starpu_job;
  46. void _starpu_simgrid_submit_job(int workerid, struct _starpu_job *job, struct starpu_perfmodel_arch* perf_arch, double length, unsigned *finished);
  47. struct _starpu_data_request;
  48. int _starpu_simgrid_transfer(size_t size, unsigned src_node, unsigned dst_node, struct _starpu_data_request *req);
  49. union _starpu_async_channel_event;
  50. int _starpu_simgrid_wait_transfer_event(union _starpu_async_channel_event *event);
  51. int _starpu_simgrid_test_transfer_event(union _starpu_async_channel_event *event);
  52. void _starpu_simgrid_sync_gpus(void);
  53. /* Return the number of hosts prefixed by PREFIX */
  54. int _starpu_simgrid_get_nbhosts(const char *prefix);
  55. unsigned long long _starpu_simgrid_get_memsize(const char *prefix, unsigned devid);
  56. msg_host_t _starpu_simgrid_get_host_by_name(const char *name);
  57. msg_host_t _starpu_simgrid_get_memnode_host(unsigned node);
  58. struct _starpu_worker;
  59. msg_host_t _starpu_simgrid_get_host_by_worker(struct _starpu_worker *worker);
  60. void _starpu_simgrid_get_platform_path(int version, char *path, size_t maxlen);
  61. msg_as_t _starpu_simgrid_get_as_by_name(const char *name);
  62. #pragma weak starpu_mpi_world_rank
  63. extern int starpu_mpi_world_rank(void);
  64. #pragma weak _starpu_mpi_simgrid_init
  65. int _starpu_mpi_simgrid_init(int argc, char *argv[]);
  66. extern starpu_pthread_queue_t _starpu_simgrid_transfer_queue[STARPU_MAXNODES];
  67. extern starpu_pthread_queue_t _starpu_simgrid_task_queue[STARPU_NMAXWORKERS];
  68. #define _starpu_simgrid_cuda_malloc_cost() starpu_get_env_number_default("STARPU_SIMGRID_CUDA_MALLOC_COST", 1)
  69. #define _starpu_simgrid_queue_malloc_cost() starpu_get_env_number_default("STARPU_SIMGRID_QUEUE_MALLOC_COST", 1)
  70. #define _starpu_simgrid_task_submit_cost() starpu_get_env_number_default("STARPU_SIMGRID_TASK_SUBMIT_COST", 1)
  71. #define _starpu_simgrid_fetching_input_cost() starpu_get_env_number_default("STARPU_SIMGRID_FETCHING_INPUT_COST", 1)
  72. #define _starpu_simgrid_sched_cost() starpu_get_env_number_default("STARPU_SIMGRID_SCHED_COST", 0)
  73. /* Called at initialization to count how many GPUs are interfering with each
  74. * bus */
  75. void _starpu_simgrid_count_ngpus(void);
  76. void _starpu_simgrid_xbt_thread_create(const char *name, void_f_pvoid_t code,
  77. void *param);
  78. #define _SIMGRID_TIMER_BEGIN(cond) \
  79. { \
  80. xbt_os_timer_t __timer = NULL; \
  81. if (cond) { \
  82. __timer = xbt_os_timer_new(); \
  83. xbt_os_threadtimer_start(__timer); \
  84. }
  85. #define _SIMGRID_TIMER_END \
  86. if (__timer) { \
  87. xbt_os_threadtimer_stop(__timer); \
  88. MSG_process_sleep(xbt_os_timer_elapsed(__timer));\
  89. xbt_os_timer_free(__timer); \
  90. } \
  91. }
  92. #else // !STARPU_SIMGRID
  93. #define _SIMGRID_TIMER_BEGIN(cond) {
  94. #define _SIMGRID_TIMER_END }
  95. #endif
  96. /* Experimental functions for OOC stochastic analysis */
  97. /* disk <-> MAIN_RAM only */
  98. #if defined(STARPU_SIMGRID) && 0
  99. void _starpu_simgrid_data_new(size_t size);
  100. void _starpu_simgrid_data_increase(size_t size);
  101. void _starpu_simgrid_data_alloc(size_t size);
  102. void _starpu_simgrid_data_free(size_t size);
  103. void _starpu_simgrid_data_transfer(size_t size, unsigned src_node, unsigned dst_node);
  104. #else
  105. #define _starpu_simgrid_data_new(size) (void)0
  106. #define _starpu_simgrid_data_increase(size) (void)0
  107. #define _starpu_simgrid_data_alloc(size) (void)0
  108. #define _starpu_simgrid_data_free(size) (void)0
  109. #define _starpu_simgrid_data_transfer(size, src_node, dst_node) (void)0
  110. #endif
  111. #ifdef __cplusplus
  112. }
  113. #endif
  114. #endif // __SIMGRID_H__