StarPU Internal Handbook
data_request.h
Go to the documentation of this file.
1/* StarPU --- Runtime system for heterogeneous multicore architectures.
2 *
3 * Copyright (C) 2008-2021 Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
4 * Copyright (C) 2021 Federal University of Rio Grande do Sul (UFRGS)
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
20/* This one includes us, so make sure to include it first */
22
23#ifndef __DATA_REQUEST_H__
24#define __DATA_REQUEST_H__
25
26#include <semaphore.h>
28#include <common/list.h>
29#include <common/prio_list.h>
31
32#pragma GCC visibility push(hidden)
33
34/* TODO: This should be tuned according to driver capabilities
35 * Data interfaces should also have to declare how many asynchronous requests
36 * they have actually started (think of e.g. csr).
37 */
38#define MAX_PENDING_REQUESTS_PER_NODE 5
39#define MAX_PENDING_PREFETCH_REQUESTS_PER_NODE 2
40#define MAX_PENDING_IDLE_REQUESTS_PER_NODE 1
42#define MAX_PUSH_TIME 1000
43
45
47{
48 void (*callback_func)(void *);
49 void *callback_arg;
50 struct _starpu_callback_list *next;
51};
52
53enum _starpu_data_request_inout
54{
55 _STARPU_DATA_REQUEST_IN, _STARPU_DATA_REQUEST_OUT
56};
57
60LIST_TYPE(_starpu_data_request,
61 struct _starpu_spinlock lock;
62 unsigned refcnt;
63 const char *origin;
65 starpu_data_handle_t handle;
66 struct _starpu_data_replicate *src_replicate;
67 struct _starpu_data_replicate *dst_replicate;
68
73 unsigned handling_node;
74 unsigned peer_node;
75 enum _starpu_data_request_inout inout;
76
77 /*
78 * What the destination node wants to do with the data: write to it,
79 * read it, or read and write to it. Only in the two latter cases we
80 * need an actual transfer, the first only needs an allocation.
81 *
82 * With mapped buffers, an additional case is mode = 0, which means
83 * unmapping the buffer.
84 */
85 enum starpu_data_access_mode mode;
86
88 struct _starpu_async_channel async_channel;
89
91 unsigned completed:1;
92
94 unsigned added_ref:1;
95
97 unsigned canceled:2;
98
100 enum starpu_is_prefetch prefetch:3;
101
103 struct starpu_task *task;
104
106 unsigned nb_tasks_prefetch;
107
109 int prio;
110
112 int retval;
113
116 unsigned ndeps;
117
120 struct _starpu_data_request *next_same_req;
121
124 struct _starpu_data_request *next_req[STARPU_MAXNODES+1];
126 unsigned next_req_count;
127
128 struct _starpu_callback_list *callbacks;
129
130 unsigned long com_id;
131)
132PRIO_LIST_TYPE(_starpu_data_request, prio)
133
134
136LIST_TYPE(_starpu_data_requester,
138 enum starpu_data_access_mode mode;
139
141 unsigned is_requested_by_codelet;
142
144 struct _starpu_job *j;
145 unsigned buffer_index;
146
147 int prio;
148
152 void (*ready_data_callback)(void *argcb);
153 void *argcb;
154)
155PRIO_LIST_TYPE(_starpu_data_requester, prio)
156
157void _starpu_init_data_request_lists(void);
158void _starpu_deinit_data_request_lists(void);
159void _starpu_post_data_request(struct _starpu_data_request *r);
161int _starpu_handle_node_data_requests(unsigned handling_node, unsigned peer_node, enum _starpu_data_request_inout inout, enum _starpu_may_alloc may_alloc, unsigned *pushed);
162int _starpu_handle_node_prefetch_requests(unsigned handling_node, unsigned peer_node, enum _starpu_data_request_inout inout, enum _starpu_may_alloc may_alloc, unsigned *pushed);
163int _starpu_handle_node_idle_requests(unsigned handling_node, unsigned peer_node, enum _starpu_data_request_inout inout, enum _starpu_may_alloc may_alloc, unsigned *pushed);
164
165int _starpu_handle_pending_node_data_requests(unsigned handling_node, unsigned peer_node, enum _starpu_data_request_inout inout);
166int _starpu_handle_all_pending_node_data_requests(unsigned handling_node, unsigned peer_node, enum _starpu_data_request_inout inout);
167
168int _starpu_check_that_no_data_request_exists(unsigned handling_node);
169int _starpu_check_that_no_data_request_is_pending(unsigned handling_node, unsigned peer_node, enum _starpu_data_request_inout inout);
170
171struct _starpu_data_request *_starpu_create_data_request(starpu_data_handle_t handle,
172 struct _starpu_data_replicate *src_replicate,
173 struct _starpu_data_replicate *dst_replicate,
174 int handling_node,
175 enum starpu_data_access_mode mode,
176 unsigned ndeps,
177 struct starpu_task *task,
178 enum starpu_is_prefetch is_prefetch,
179 int prio,
180 unsigned is_write_invalidation,
181 const char *origin) STARPU_ATTRIBUTE_MALLOC;
182
183int _starpu_wait_data_request_completion(struct _starpu_data_request *r, enum _starpu_may_alloc may_alloc);
184
185void _starpu_data_request_append_callback(struct _starpu_data_request *r,
186 void (*callback_func)(void *),
187 void *callback_arg);
188
189void _starpu_update_prefetch_status(struct _starpu_data_request *r, enum starpu_is_prefetch prefetch);
190
191#pragma GCC visibility pop
192
193#endif // __DATA_REQUEST_H__
Definition: coherency.h:47
Definition: copy_driver.h:71
#define STARPU_MAXNODES
Definition: starpu_config.h:229
Definition: starpu_spinlock.h:82
Definition: data_request.h:47
Definition: jobs.h:74