simgrid.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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 __cplusplus
  20. extern "C"
  21. {
  22. #endif
  23. #ifdef STARPU_SIMGRID
  24. #ifdef STARPU_HAVE_SIMGRID_MSG_H
  25. #include <simgrid/msg.h>
  26. #else
  27. #include <msg/msg.h>
  28. #endif
  29. #include <xbt/xbt_os_time.h>
  30. struct _starpu_pthread_args
  31. {
  32. void *(*f)(void*);
  33. void *arg;
  34. };
  35. #define MAX_TSD 16
  36. #define STARPU_MPI_AS_PREFIX "StarPU-MPI"
  37. #define _starpu_simgrid_running_smpi() (getenv("SMPI_GLOBAL_SIZE") != NULL)
  38. void _starpu_start_simgrid(int *argc, char **argv);
  39. void _starpu_simgrid_init_early(int *argc, char ***argv);
  40. void _starpu_simgrid_init(void);
  41. void _starpu_simgrid_deinit(void);
  42. void _starpu_simgrid_deinit_late(void);
  43. void _starpu_simgrid_wait_tasks(int workerid);
  44. struct _starpu_job;
  45. void _starpu_simgrid_submit_job(int workerid, struct _starpu_job *job, struct starpu_perfmodel_arch* perf_arch, double length, unsigned *finished);
  46. struct _starpu_data_request;
  47. int _starpu_simgrid_transfer(size_t size, unsigned src_node, unsigned dst_node, struct _starpu_data_request *req);
  48. union _starpu_async_channel_event;
  49. int _starpu_simgrid_wait_transfer_event(union _starpu_async_channel_event *event);
  50. int _starpu_simgrid_test_transfer_event(union _starpu_async_channel_event *event);
  51. void _starpu_simgrid_sync_gpus(void);
  52. /* Return the number of hosts prefixed by PREFIX */
  53. int _starpu_simgrid_get_nbhosts(const char *prefix);
  54. unsigned long long _starpu_simgrid_get_memsize(const char *prefix, unsigned devid);
  55. msg_host_t _starpu_simgrid_get_host_by_name(const char *name);
  56. msg_host_t _starpu_simgrid_get_memnode_host(unsigned node);
  57. struct _starpu_worker;
  58. msg_host_t _starpu_simgrid_get_host_by_worker(struct _starpu_worker *worker);
  59. void _starpu_simgrid_get_platform_path(int version, char *path, size_t maxlen);
  60. msg_as_t _starpu_simgrid_get_as_by_name(const char *name);
  61. #pragma weak starpu_mpi_world_rank
  62. extern int starpu_mpi_world_rank(void);
  63. #pragma weak _starpu_mpi_simgrid_init
  64. int _starpu_mpi_simgrid_init(int argc, char *argv[]);
  65. starpu_pthread_queue_t _starpu_simgrid_transfer_queue[STARPU_MAXNODES];
  66. starpu_pthread_queue_t _starpu_simgrid_task_queue[STARPU_NMAXWORKERS];
  67. #define _starpu_simgrid_cuda_malloc_cost() starpu_get_env_number_default("STARPU_SIMGRID_CUDA_MALLOC_COST", 1)
  68. #define _starpu_simgrid_queue_malloc_cost() starpu_get_env_number_default("STARPU_SIMGRID_QUEUE_MALLOC_COST", 1)
  69. #define _starpu_simgrid_task_submit_cost() starpu_get_env_number_default("STARPU_SIMGRID_TASK_SUBMIT_COST", 1)
  70. #define _starpu_simgrid_fetching_input_cost() starpu_get_env_number_default("STARPU_SIMGRID_FETCHING_INPUT_COST", 1)
  71. #define _starpu_simgrid_sched_cost() starpu_get_env_number_default("STARPU_SIMGRID_SCHED_COST", 0)
  72. /* Called at initialization to count how many GPUs are interfering with each
  73. * bus */
  74. void _starpu_simgrid_count_ngpus(void);
  75. void _starpu_simgrid_xbt_thread_create(const char *name, void_f_pvoid_t code,
  76. void *param);
  77. #define _SIMGRID_TIMER_BEGIN(cond) \
  78. { \
  79. xbt_os_timer_t __timer = NULL; \
  80. if (cond) { \
  81. __timer = xbt_os_timer_new(); \
  82. xbt_os_threadtimer_start(__timer); \
  83. }
  84. #define _SIMGRID_TIMER_END \
  85. if (__timer) { \
  86. xbt_os_threadtimer_stop(__timer); \
  87. MSG_process_sleep(xbt_os_timer_elapsed(__timer));\
  88. xbt_os_timer_free(__timer); \
  89. } \
  90. }
  91. #else // !STARPU_SIMGRID
  92. #define _SIMGRID_TIMER_BEGIN(cond) {
  93. #define _SIMGRID_TIMER_END }
  94. #endif
  95. /* Experimental functions for OOC stochastic analysis */
  96. /* disk <-> MAIN_RAM only */
  97. #if defined(STARPU_SIMGRID) && 0
  98. void _starpu_simgrid_data_new(size_t size);
  99. void _starpu_simgrid_data_increase(size_t size);
  100. void _starpu_simgrid_data_alloc(size_t size);
  101. void _starpu_simgrid_data_free(size_t size);
  102. void _starpu_simgrid_data_transfer(size_t size, unsigned src_node, unsigned dst_node);
  103. #else
  104. #define _starpu_simgrid_data_new(size) (void)0
  105. #define _starpu_simgrid_data_increase(size) (void)0
  106. #define _starpu_simgrid_data_alloc(size) (void)0
  107. #define _starpu_simgrid_data_free(size) (void)0
  108. #define _starpu_simgrid_data_transfer(size, src_node, dst_node) (void)0
  109. #endif
  110. #ifdef __cplusplus
  111. }
  112. #endif
  113. #endif // __SIMGRID_H__