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-2020 Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
4  *
5  * StarPU is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU Lesser General Public License as published by
7  * the Free Software Foundation; either version 2.1 of the License, or (at
8  * your option) any later version.
9  *
10  * StarPU is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13  *
14  * See the GNU Lesser General Public License in COPYING.LGPL for more details.
15  */
16 
19 /* This one includes us, so make sure to include it first */
20 #include <datawizard/coherency.h>
21 
22 #ifndef __DATA_REQUEST_H__
23 #define __DATA_REQUEST_H__
24 
25 #include <semaphore.h>
26 #include <datawizard/copy_driver.h>
27 #include <common/list.h>
28 #include <common/prio_list.h>
29 #include <common/starpu_spinlock.h>
30 
31 /* TODO: This should be tuned according to driver capabilities
32  * Data interfaces should also have to declare how many asynchronous requests
33  * they have actually started (think of e.g. csr).
34  */
35 #define MAX_PENDING_REQUESTS_PER_NODE 20
36 #define MAX_PENDING_PREFETCH_REQUESTS_PER_NODE 10
37 #define MAX_PENDING_IDLE_REQUESTS_PER_NODE 1
38 #define MAX_PUSH_TIME 1000 /* Maximum time in us that we can afford pushing requests before going back to the driver loop, e.g. for checking GPU task termination */
39 
41 
43 {
44  void (*callback_func)(void *);
45  void *callback_arg;
46  struct _starpu_callback_list *next;
47 };
48 
51 LIST_TYPE(_starpu_data_request,
52  struct _starpu_spinlock lock;
53  unsigned refcnt;
54  const char *origin;
56  starpu_data_handle_t handle;
57  struct _starpu_data_replicate *src_replicate;
58  struct _starpu_data_replicate *dst_replicate;
59 
64  unsigned handling_node;
65 
66  /*
67  * What the destination node wants to do with the data: write to it,
68  * read it, or read and write to it. Only in the two latter cases we
69  * need an actual transfer, the first only needs an allocation.
70  *
71  * With mapped buffers, an additional case is mode = 0, which means
72  * unmapping the buffer.
73  */
74  enum starpu_data_access_mode mode;
75 
77  struct _starpu_async_channel async_channel;
78 
80  unsigned completed;
81 
87  unsigned prefetch;
88 
90  int prio;
91 
93  int retval;
94 
97  unsigned ndeps;
98 
101  struct _starpu_data_request *next_req[STARPU_MAXNODES+1];
103  unsigned next_req_count;
104 
105  struct _starpu_callback_list *callbacks;
106 
107  unsigned long com_id;
108 )
109 PRIO_LIST_TYPE(_starpu_data_request, prio)
110 
111 
113 LIST_TYPE(_starpu_data_requester,
115  enum starpu_data_access_mode mode;
116 
118  unsigned is_requested_by_codelet;
119 
121  struct _starpu_job *j;
122  unsigned buffer_index;
123 
124  int prio;
125 
129  void (*ready_data_callback)(void *argcb);
130  void *argcb;
131 )
132 PRIO_LIST_TYPE(_starpu_data_requester, prio)
133 
134 void _starpu_init_data_request_lists(void);
135 void _starpu_deinit_data_request_lists(void);
136 void _starpu_post_data_request(struct _starpu_data_request *r);
138 int _starpu_handle_node_data_requests(unsigned src_node, unsigned may_alloc, unsigned *pushed);
139 int _starpu_handle_node_prefetch_requests(unsigned src_node, unsigned may_alloc, unsigned *pushed);
140 int _starpu_handle_node_idle_requests(unsigned src_node, unsigned may_alloc, unsigned *pushed);
141 
142 int _starpu_handle_pending_node_data_requests(unsigned src_node);
143 int _starpu_handle_all_pending_node_data_requests(unsigned src_node);
144 
145 int _starpu_check_that_no_data_request_exists(unsigned node);
146 int _starpu_check_that_no_data_request_is_pending(unsigned node);
147 
148 struct _starpu_data_request *_starpu_create_data_request(starpu_data_handle_t handle,
149  struct _starpu_data_replicate *src_replicate,
150  struct _starpu_data_replicate *dst_replicate,
151  int handling_node,
152  enum starpu_data_access_mode mode,
153  unsigned ndeps,
154  unsigned is_prefetch,
155  int prio,
156  unsigned is_write_invalidation,
157  const char *origin) STARPU_ATTRIBUTE_MALLOC;
158 
159 int _starpu_wait_data_request_completion(struct _starpu_data_request *r, unsigned may_alloc);
160 
161 void _starpu_data_request_append_callback(struct _starpu_data_request *r,
162  void (*callback_func)(void *),
163  void *callback_arg);
164 
165 void _starpu_update_prefetch_status(struct _starpu_data_request *r, unsigned prefetch);
166 #endif // __DATA_REQUEST_H__
starpu_spinlock.h
coherency.h
prio_list.h
_starpu_callback_list
Definition: data_request.h:42
_starpu_data_replicate
Definition: coherency.h:44
_starpu_spinlock
Definition: starpu_spinlock.h:81
_starpu_job
Definition: jobs.h:78
_starpu_async_channel
Definition: copy_driver.h:115
copy_driver.h