StarPU Internal Handbook
simgrid.h
Go to the documentation of this file.
1 /* StarPU --- Runtime system for heterogeneous multicore architectures.
2  *
3  * Copyright (C) 2012-2022 Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
4  * Copyright (C) 2013 Thibaut Lambert
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 
18 #ifndef __SIMGRID_H__
19 #define __SIMGRID_H__
20 
23 /* Note: when changing something here, update the include list in configure.ac
24  * in the part that tries to enable stdc++11 */
25 #ifdef STARPU_SIMGRID
26 #ifdef STARPU_HAVE_SIMGRID_MSG_H
27 #include <simgrid/msg.h>
28 #elif defined(STARPU_HAVE_MSG_MSG_H)
29 #include <msg/msg.h>
30 #endif
31 
32 #ifdef STARPU_HAVE_XBT_BASE_H
33 #include <xbt/base.h>
34 #endif
35 #ifdef STARPU_HAVE_SIMGRID_VERSION_H
36 #include <simgrid/version.h>
37 #endif
38 #ifdef STARPU_HAVE_SIMGRID_ZONE_H
39 #include <simgrid/zone.h>
40 #endif
41 #ifdef STARPU_HAVE_SIMGRID_HOST_H
42 #include <simgrid/host.h>
43 #endif
44 
45 #include <xbt/xbt_os_time.h>
46 #endif
47 
48 #ifdef __cplusplus
49 extern "C"
50 {
51 #endif
52 
53 #ifdef STARPU_SIMGRID
55 {
56  void *(*f)(void*);
57  void *arg;
58 };
59 
60 #if (SIMGRID_VERSION >= 31500) && (SIMGRID_VERSION != 31559)
61 typedef sg_link_t starpu_sg_link_t;
62 #else
63 typedef SD_link_t starpu_sg_link_t;
64 #endif
65 
66 #define MAX_TSD 16
67 
68 #define STARPU_MPI_AS_PREFIX "StarPU-MPI"
69 #define _starpu_simgrid_running_smpi() (getenv("SMPI_GLOBAL_SIZE") != NULL)
70 
71 void _starpu_start_simgrid(int *argc, char **argv);
72 
73 void _starpu_simgrid_init_early(int *argc, char ***argv);
74 void _starpu_simgrid_init(void);
75 void _starpu_simgrid_deinit(void);
76 void _starpu_simgrid_deinit_late(void);
77 void _starpu_simgrid_actor_setup(void);
78 void _starpu_simgrid_wait_tasks(int workerid);
79 struct _starpu_job;
80 void _starpu_simgrid_submit_job(int workerid, struct _starpu_job *job, struct starpu_perfmodel_arch* perf_arch, double length, unsigned *finished);
81 struct _starpu_data_request;
82 int _starpu_simgrid_transfer(size_t size, unsigned src_node, unsigned dst_node, struct _starpu_data_request *req);
84 int _starpu_simgrid_wait_transfer_event(union _starpu_async_channel_event *event);
85 int _starpu_simgrid_test_transfer_event(union _starpu_async_channel_event *event);
86 void _starpu_simgrid_sync_gpus(void);
88 int _starpu_simgrid_get_nbhosts(const char *prefix);
89 unsigned long long _starpu_simgrid_get_memsize(const char *prefix, unsigned devid);
90 starpu_sg_host_t _starpu_simgrid_get_host_by_name(const char *name);
91 starpu_sg_host_t _starpu_simgrid_get_memnode_host(unsigned node);
92 struct _starpu_worker;
93 starpu_sg_host_t _starpu_simgrid_get_host_by_worker(struct _starpu_worker *worker);
94 void _starpu_simgrid_get_platform_path(int version, char *path, size_t maxlen);
95 #if defined(HAVE_SG_ZONE_GET_BY_NAME) || defined(sg_zone_get_by_name)
96 sg_netzone_t _starpu_simgrid_get_as_by_name(const char *name);
97 #else
98 msg_as_t _starpu_simgrid_get_as_by_name(const char *name);
99 #endif
100 #pragma weak starpu_mpi_world_rank
101 extern int starpu_mpi_world_rank(void);
102 #pragma weak _starpu_mpi_simgrid_init
103 int _starpu_mpi_simgrid_init(int argc, char *argv[]);
104 
105 extern starpu_pthread_queue_t _starpu_simgrid_transfer_queue[STARPU_MAXNODES];
106 extern starpu_pthread_queue_t _starpu_simgrid_task_queue[STARPU_NMAXWORKERS];
107 
108 #define _starpu_simgrid_cuda_malloc_cost() starpu_get_env_number_default("STARPU_SIMGRID_CUDA_MALLOC_COST", 1)
109 #define _starpu_simgrid_cuda_queue_cost() starpu_get_env_number_default("STARPU_SIMGRID_CUDA_QUEUE_COST", 1)
110 #define _starpu_simgrid_task_submit_cost() starpu_get_env_number_default("STARPU_SIMGRID_TASK_SUBMIT_COST", 1)
111 #define _starpu_simgrid_fetching_input_cost() starpu_get_env_number_default("STARPU_SIMGRID_FETCHING_INPUT_COST", 1)
112 #define _starpu_simgrid_sched_cost() starpu_get_env_number_default("STARPU_SIMGRID_SCHED_COST", 0)
113 
117 
118 void _starpu_simgrid_xbt_thread_create(const char *name, void_f_pvoid_t code,
119  void *param);
120 
121 #define _SIMGRID_TIMER_BEGIN(cond) \
122  { \
123  xbt_os_timer_t __timer = NULL; \
124  if (cond) { \
125  __timer = xbt_os_timer_new(); \
126  xbt_os_threadtimer_start(__timer); \
127  }
128 #define _SIMGRID_TIMER_END \
129  if (__timer) { \
130  xbt_os_threadtimer_stop(__timer); \
131  starpu_sleep(xbt_os_timer_elapsed(__timer));\
132  xbt_os_timer_free(__timer); \
133  } \
134  }
135 
136 #else // !STARPU_SIMGRID
137 #define _SIMGRID_TIMER_BEGIN(cond) {
138 #define _SIMGRID_TIMER_END }
139 #endif
140 
142 /* disk <-> MAIN_RAM only */
143 #if defined(STARPU_SIMGRID) && 0
144 void _starpu_simgrid_data_new(size_t size);
145 void _starpu_simgrid_data_increase(size_t size);
146 void _starpu_simgrid_data_alloc(size_t size);
147 void _starpu_simgrid_data_free(size_t size);
148 void _starpu_simgrid_data_transfer(size_t size, unsigned src_node, unsigned dst_node);
149 #else
150 #define _starpu_simgrid_data_new(size) (void)0
151 #define _starpu_simgrid_data_increase(size) (void)0
152 #define _starpu_simgrid_data_alloc(size) (void)0
153 #define _starpu_simgrid_data_free(size) (void)0
154 #define _starpu_simgrid_data_transfer(size, src_node, dst_node) (void)0
155 #endif
156 
157 #ifdef __cplusplus
158 }
159 #endif
160 
161 #endif // __SIMGRID_H__
Definition: copy_driver.h:103
void _starpu_simgrid_count_ngpus(void)
#define _starpu_simgrid_data_new(size)
Definition: simgrid.h:150
int _starpu_simgrid_get_nbhosts(const char *prefix)
Definition: jobs.h:79
Definition: simgrid.h:55
Definition: workers.h:70