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