18#ifndef __MP_COMMON_H__
19#define __MP_COMMON_H__
26#include <common/config.h>
33#pragma GCC visibility push(hidden)
37#define BUFFER_SIZE 65536
39#define STARPU_MP_SRC_NODE 0
40#define STARPU_MP_SINK_NODE(a) ((a) + 1)
42#define STARPU_MP_COMMON_REPORT_ERROR(node, status) \
43 (node)->report_error(__starpu_func__, __FILE__, __LINE__, (status))
44enum _starpu_mp_command
48 STARPU_MP_COMMAND_EXIT,
49 STARPU_MP_COMMAND_EXECUTE,
50 STARPU_MP_COMMAND_EXECUTE_DETACHED,
51 STARPU_MP_COMMAND_SINK_NBCORES,
52 STARPU_MP_COMMAND_LOOKUP,
53 STARPU_MP_COMMAND_ALLOCATE,
54 STARPU_MP_COMMAND_FREE,
55 STARPU_MP_COMMAND_MAP,
56 STARPU_MP_COMMAND_UNMAP,
57 STARPU_MP_COMMAND_SYNC_WORKERS,
60 STARPU_MP_COMMAND_RECV_FROM_HOST,
61 STARPU_MP_COMMAND_SEND_TO_HOST,
62 STARPU_MP_COMMAND_RECV_FROM_SINK,
63 STARPU_MP_COMMAND_SEND_TO_SINK,
66 STARPU_MP_COMMAND_RECV_FROM_HOST_ASYNC,
67 STARPU_MP_COMMAND_SEND_TO_HOST_ASYNC,
68 STARPU_MP_COMMAND_RECV_FROM_SINK_ASYNC,
69 STARPU_MP_COMMAND_SEND_TO_SINK_ASYNC,
72 STARPU_MP_COMMAND_ERROR_EXECUTE,
73 STARPU_MP_COMMAND_ERROR_EXECUTE_DETACHED,
74 STARPU_MP_COMMAND_ANSWER_LOOKUP,
75 STARPU_MP_COMMAND_ERROR_LOOKUP,
76 STARPU_MP_COMMAND_ANSWER_ALLOCATE,
77 STARPU_MP_COMMAND_ERROR_ALLOCATE,
78 STARPU_MP_COMMAND_ANSWER_MAP,
79 STARPU_MP_COMMAND_ERROR_MAP,
80 STARPU_MP_COMMAND_ANSWER_TRANSFER_COMPLETE,
81 STARPU_MP_COMMAND_ANSWER_SINK_NBCORES,
82 STARPU_MP_COMMAND_ANSWER_EXECUTION_SUBMITTED,
83 STARPU_MP_COMMAND_ANSWER_EXECUTION_DETACHED_SUBMITTED,
86 STARPU_MP_COMMAND_NOTIF_RECV_FROM_HOST_ASYNC_COMPLETED,
87 STARPU_MP_COMMAND_NOTIF_SEND_TO_HOST_ASYNC_COMPLETED,
88 STARPU_MP_COMMAND_NOTIF_RECV_FROM_SINK_ASYNC_COMPLETED,
89 STARPU_MP_COMMAND_NOTIF_SEND_TO_SINK_ASYNC_COMPLETED,
90 STARPU_MP_COMMAND_NOTIF_EXECUTION_COMPLETED,
91 STARPU_MP_COMMAND_NOTIF_EXECUTION_DETACHED_COMPLETED,
92 STARPU_MP_COMMAND_NOTIF_PRE_EXECUTION,
94 STARPU_MP_COMMAND_NOTIF_FIRST = STARPU_MP_COMMAND_NOTIF_RECV_FROM_HOST_ASYNC_COMPLETED,
95 STARPU_MP_COMMAND_NOTIF_LAST = STARPU_MP_COMMAND_NOTIF_PRE_EXECUTION,
98const char *_starpu_mp_common_command_to_string(
const enum _starpu_mp_command command);
100enum _starpu_mp_node_kind
102 STARPU_NODE_MPI_SINK,
103 STARPU_NODE_MPI_SOURCE,
104 STARPU_NODE_TCPIP_SINK,
105 STARPU_NODE_TCPIP_SOURCE,
106 STARPU_NODE_INVALID_KIND
109const char *_starpu_mp_common_node_kind_to_string(
const int kind);
111union _starpu_mp_connection
113#ifdef STARPU_USE_MPI_MASTER_SLAVE
114 int mpi_remote_nodeid;
116#ifdef STARPU_USE_TCPIP_MASTER_SLAVE
117 struct _starpu_tcpip_socket *tcpip_mp_connection;
121struct _starpu_mp_transfer_command
128struct _starpu_mp_transfer_command_to_device
137struct _starpu_mp_transfer_map_command
144struct _starpu_mp_transfer_unmap_command
152 starpu_pthread_barrier_t before_work_barrier;
153 starpu_pthread_barrier_t after_work_barrier;
157 enum _starpu_mp_command type;
164 void (*kernel)(
void **,
void *);
165 enum starpu_data_interface_id *ids;
167 unsigned nb_interfaces;
169 unsigned cl_arg_size;
171 unsigned cl_ret_size;
173 enum starpu_codelet_type type;
174 int is_parallel_task;
175 int combined_workerid;
177 struct mp_barrier* mp_barrier;
180LIST_TYPE(_starpu_mp_event,
183 enum _starpu_mp_command answer_cmd;
189struct _starpu_mp_node
191 enum _starpu_mp_node_kind kind;
214 union _starpu_mp_connection mp_connection;
219 starpu_pthread_mutex_t connection_mutex;
224 struct _starpu_mp_event_list event_list;
226 struct _starpu_mp_event_list event_queue;
229 starpu_pthread_barrier_t init_completed_barrier;
235 struct mp_message_list message_queue;
236 starpu_pthread_mutex_t message_queue_mutex;
239 struct mp_barrier_list barrier_list;
240 starpu_pthread_mutex_t barrier_mutex;
243 struct mp_task ** run_table;
244 struct mp_task ** run_table_detached;
245 sem_t * sem_run_table;
248 void (*init) (
struct _starpu_mp_node *node);
249 void (*launch_workers) (
struct _starpu_mp_node *node);
250 void (*deinit) (
struct _starpu_mp_node *node);
251 void (*report_error) (
const char *,
const char *,
const int,
const int);
254 int (*mp_recv_is_ready) (
const struct _starpu_mp_node *);
255 void (*mp_send) (
const struct _starpu_mp_node *,
void *, int);
256 void (*mp_recv) (
const struct _starpu_mp_node *,
void *, int);
259 int (*nt_recv_is_ready) (
const struct _starpu_mp_node *);
260 int (*nt_send_is_ready) (
const struct _starpu_mp_node *);
261 void (*nt_send) (
const struct _starpu_mp_node *,
void *, int);
262 void (*nt_recv) (
const struct _starpu_mp_node *,
void *, int);
265 void (*mp_wait) (
struct _starpu_mp_node *);
266 void (*mp_signal) (
const struct _starpu_mp_node *);
269 void (*dt_send) (
const struct _starpu_mp_node *,
void *, int,
void *);
270 void (*dt_recv) (
const struct _starpu_mp_node *,
void *, int,
void *);
271 void (*dt_send_to_device) (
const struct _starpu_mp_node *, int,
void *, int,
void *);
272 void (*dt_recv_from_device) (
const struct _starpu_mp_node *, int,
void *, int,
void *);
277 void (*(*get_kernel_from_job) (
const struct _starpu_mp_node *,
struct _starpu_job *))(void);
278 void (*(*lookup) (
const struct _starpu_mp_node *,
char*))(void);
279 void (*bind_thread) (
const struct _starpu_mp_node *, int,
int *,int);
280 void (*execute) (
struct _starpu_mp_node *,
void *, int);
281 void (*allocate) (
const struct _starpu_mp_node *,
void *, int);
282 void (*free) (
const struct _starpu_mp_node *,
void *, int);
283 void (*map) (
const struct _starpu_mp_node *,
void *, int);
284 void (*unmap) (
const struct _starpu_mp_node *,
void *, int);
287struct _starpu_mp_node * _starpu_mp_common_node_create(
enum _starpu_mp_node_kind node_kind,
int peer_devid) STARPU_ATTRIBUTE_MALLOC;
289void _starpu_mp_common_node_destroy(
struct _starpu_mp_node *node);
291void _starpu_mp_common_send_command(
const struct _starpu_mp_node *node,
292 const enum _starpu_mp_command command,
293 void *arg,
int arg_size);
295void _starpu_nt_common_send_command(
const struct _starpu_mp_node *node,
296 const enum _starpu_mp_command command,
297 void *arg,
int arg_size);
299enum _starpu_mp_command _starpu_mp_common_recv_command(
const struct _starpu_mp_node *node,
void **arg,
int *arg_size);
301enum _starpu_mp_command _starpu_nt_common_recv_command(
const struct _starpu_mp_node *node,
void **arg,
int *arg_size);
303void _starpu_sink_deinit(
struct _starpu_mp_node *node);
304void _starpu_sink_launch_workers(
struct _starpu_mp_node *node);
308#pragma GCC visibility pop
Definition copy_driver.h:71