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
24extern "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
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
63void _starpu_start_simgrid(int *argc, char **argv);
64
65void _starpu_simgrid_init_early(int *argc, char ***argv);
66void _starpu_simgrid_init(void);
67void _starpu_simgrid_deinit(void);
68void _starpu_simgrid_deinit_late(void);
69void _starpu_simgrid_actor_setup(void);
70void _starpu_simgrid_wait_tasks(int workerid);
71struct _starpu_job;
72void _starpu_simgrid_submit_job(int workerid, struct _starpu_job *job, struct starpu_perfmodel_arch* perf_arch, double length, unsigned *finished);
73struct _starpu_data_request;
74int _starpu_simgrid_transfer(size_t size, unsigned src_node, unsigned dst_node, struct _starpu_data_request *req);
76int _starpu_simgrid_wait_transfer_event(union _starpu_async_channel_event *event);
77int _starpu_simgrid_test_transfer_event(union _starpu_async_channel_event *event);
78void _starpu_simgrid_sync_gpus(void);
80int _starpu_simgrid_get_nbhosts(const char *prefix);
81unsigned 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);
84struct _starpu_worker;
85starpu_sg_host_t _starpu_simgrid_get_host_by_worker(struct _starpu_worker *worker);
86void _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
93extern int starpu_mpi_world_rank(void);
94#pragma weak _starpu_mpi_simgrid_init
95int _starpu_mpi_simgrid_init(int argc, char *argv[]);
96
97extern starpu_pthread_queue_t _starpu_simgrid_transfer_queue[STARPU_MAXNODES];
98extern 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
109
110void _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
136void _starpu_simgrid_data_new(size_t size);
137void _starpu_simgrid_data_increase(size_t size);
138void _starpu_simgrid_data_alloc(size_t size);
139void _starpu_simgrid_data_free(size_t size);
140void _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__
Definition: copy_driver.h:103
void _starpu_simgrid_count_ngpus(void)
#define _starpu_simgrid_data_new(size)
Definition: simgrid.h:142
int _starpu_simgrid_get_nbhosts(const char *prefix)
Definition: jobs.h:79
Definition: simgrid.h:53
Definition: workers.h:70