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 *
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
39#define MAX_PUSH_TIME 1000
40
41 struct _starpu_data_replicate;
42
43 struct _starpu_callback_list
44{
45 void (*callback_func)(void *);
46 void *callback_arg;
47 struct _starpu_callback_list *next;
48};
49
52LIST_TYPE(_starpu_data_request,
53 struct _starpu_spinlock lock;
54 unsigned refcnt;
55 const char *origin;
57 starpu_data_handle_t handle;
58 struct _starpu_data_replicate *src_replicate;
59 struct _starpu_data_replicate *dst_replicate;
60
65 unsigned handling_node;
66
67 /*
68 * What the destination node wants to do with the data: write to it,
69 * read it, or read and write to it. Only in the two latter cases we
70 * need an actual transfer, the first only needs an allocation.
71 *
72 * With mapped buffers, an additional case is mode = 0, which means
73 * unmapping the buffer.
74 */
75 enum starpu_data_access_mode mode;
76
78 struct _starpu_async_channel async_channel;
79
81 unsigned completed;
82
84 enum _starpu_is_prefetch prefetch;
85
87 int prio;
88
90 int retval;
91
94 unsigned ndeps;
95
98 struct _starpu_data_request *next_req[STARPU_MAXNODES+1];
100 unsigned next_req_count;
101
102 struct _starpu_callback_list *callbacks;
103
104 unsigned long com_id;
105)
106PRIO_LIST_TYPE(_starpu_data_request, prio)
107
108
110LIST_TYPE(_starpu_data_requester,
112 enum starpu_data_access_mode mode;
113
115 unsigned is_requested_by_codelet;
116
118 struct _starpu_job *j;
119 unsigned buffer_index;
120
121 int prio;
122
126 void (*ready_data_callback)(void *argcb);
127 void *argcb;
128)
129PRIO_LIST_TYPE(_starpu_data_requester, prio)
130
131 void _starpu_init_data_request_lists(void);
132 void _starpu_deinit_data_request_lists(void);
133 void _starpu_post_data_request(struct _starpu_data_request *r);
135 int _starpu_handle_node_data_requests(unsigned src_node, unsigned may_alloc, unsigned *pushed);
136 int _starpu_handle_node_prefetch_requests(unsigned src_node, unsigned may_alloc, unsigned *pushed);
137 int _starpu_handle_node_idle_requests(unsigned src_node, unsigned may_alloc, unsigned *pushed);
138
139 int _starpu_handle_pending_node_data_requests(unsigned src_node);
140 int _starpu_handle_all_pending_node_data_requests(unsigned src_node);
141
142 int _starpu_check_that_no_data_request_exists(unsigned node);
143 int _starpu_check_that_no_data_request_is_pending(unsigned node);
144
145 struct _starpu_data_request *_starpu_create_data_request(starpu_data_handle_t handle,
146 struct _starpu_data_replicate *src_replicate,
147 struct _starpu_data_replicate *dst_replicate,
148 int handling_node,
149 enum starpu_data_access_mode mode,
150 unsigned ndeps,
151 enum _starpu_is_prefetch is_prefetch,
152 int prio,
153 unsigned is_write_invalidation,
154 const char *origin) STARPU_ATTRIBUTE_MALLOC;
155
156 int _starpu_wait_data_request_completion(struct _starpu_data_request *r, unsigned may_alloc);
157
158 void _starpu_data_request_append_callback(struct _starpu_data_request *r,
159 void (*callback_func)(void *),
160 void *callback_arg);
161
162 void _starpu_update_prefetch_status(struct _starpu_data_request *r, enum _starpu_is_prefetch prefetch);
163#endif // __DATA_REQUEST_H__
coherency.h
_starpu_data_replicate
Definition: coherency.h:45
copy_driver.h
_starpu_is_prefetch
_starpu_is_prefetch
Definition: copy_driver.h:51
_starpu_async_channel
Definition: copy_driver.h:127
list.h
prio_list.h
starpu_spinlock.h
_starpu_spinlock
Definition: starpu_spinlock.h:82
_starpu_callback_list
Definition: data_request.h:44
_starpu_job
Definition: jobs.h:79