Line data Source code
1 : #ifndef HEADER_fd_src_disco_topo_fd_topob_h
2 : #define HEADER_fd_src_disco_topo_fd_topob_h
3 :
4 : /* fd_topob is a builder for fd_topo, providing many convenience
5 : functions for creating a useful topology. */
6 :
7 : #include "../../disco/topo/fd_topo.h"
8 : #include "fd_cpu_topo.h"
9 :
10 : /* A link in the topology is either unpolled or polled. Almost all
11 : links are polled, which means a tile which has this link as an in
12 : will read fragments from it and pass them to the tile handling
13 : code. An unpolled link will not read off the link by default and
14 : the user code will need to specifically read it as needed. */
15 :
16 0 : #define FD_TOPOB_UNPOLLED 0
17 0 : #define FD_TOPOB_POLLED 1
18 :
19 : /* A reliable link is a flow controlled one, where the producer will
20 : not send fragments if any downstream consumer does not have enough
21 : capacity (credits) to handle it. */
22 :
23 0 : #define FD_TOPOB_UNRELIABLE 0
24 0 : #define FD_TOPOB_RELIABLE 1
25 :
26 : /* Tile priority types used by fd_topob_auto_layout to classify tiles
27 : into scheduling categories. */
28 0 : #define FD_TOPOB_PRIORITY_FLOATING (1)
29 0 : #define FD_TOPOB_PRIORITY_STARTUP (2)
30 0 : #define FD_TOPOB_PRIORITY_NORMAL (3)
31 0 : #define FD_TOPOB_PRIORITY_CRITICAL (4)
32 :
33 : FD_PROTOTYPES_BEGIN
34 :
35 : /* Initialize a new fd_topo_t with the given app name and at the memory address
36 : provided. Returns the topology at given address. The topology will be empty
37 : with no tiles, objects, links. */
38 :
39 : fd_topo_t *
40 : fd_topob_new( void * mem,
41 : char const * app_name );
42 :
43 : /* Add a workspace with the given name to the topology. Workspace names
44 : must be unique and adding the same workspace twice will produce an
45 : error. */
46 :
47 : fd_topo_wksp_t *
48 : fd_topob_wksp( fd_topo_t * topo,
49 : char const * name );
50 :
51 : /* Add an object with the given type to the toplogy. An object is
52 : something that takes up space in memory, in a workspace.
53 :
54 : The workspace must exist and have been added to the topology.
55 : Adding an object will cause it to occupt space in memory, but not
56 : be mapped into any tiles. If you wish the object to be readable or
57 : writable by a tile, you need to add a fd_topob_tile_uses relationship. */
58 :
59 : fd_topo_obj_t *
60 : fd_topob_obj( fd_topo_t * topo,
61 : char const * obj_type,
62 : char const * wksp_name );
63 :
64 : /* Same as fd_topo_obj, but labels the object. */
65 :
66 : fd_topo_obj_t *
67 : fd_topob_obj_named( fd_topo_t * topo,
68 : char const * obj_type,
69 : char const * wksp_name,
70 : char const * label );
71 :
72 : /* Add a relationship saying that a certain tile uses a given object.
73 : This has the effect that when memory mapping required workspaces
74 : for a tile, it will map the workspace required for this object in
75 : the appropriate mode.
76 :
77 : mode should be one of FD_SHMEM_JOIN_MODE_READ_ONLY or
78 : FD_SHMEM_JOIN_MODE_READ_WRITE. */
79 :
80 : void
81 : fd_topob_tile_uses( fd_topo_t * topo,
82 : fd_topo_tile_t * tile,
83 : fd_topo_obj_t const * obj,
84 : int mode );
85 :
86 : /* Add a link to the toplogy. The link will not have any producer or
87 : consumer(s) by default, and those need to be added after. The link
88 : can have no backing data buffer, a dcache, or a reassembly buffer
89 : behind it. */
90 :
91 : fd_topo_link_t *
92 : fd_topob_link( fd_topo_t * topo,
93 : char const * link_name,
94 : char const * wksp_name,
95 : ulong depth,
96 : ulong mtu,
97 : ulong burst );
98 :
99 : /* Add a tile to the topology. This creates various objects needed for
100 : a standard tile, including tile scratch memory, metrics memory and so
101 : on. These objects will be created and linked to the respective
102 : workspaces provided, and the tile will be specified to map those
103 : workspaces when it is attached. */
104 :
105 : fd_topo_tile_t *
106 : fd_topob_tile( fd_topo_t * topo,
107 : char const * tile_name,
108 : char const * tile_wksp,
109 : char const * metrics_wksp,
110 : ulong cpu_idx,
111 : int is_agave,
112 : int uses_id_keyswitch,
113 : int uses_av_keyswitch );
114 :
115 : /* Add an input link to the tile. If the tile is created with fd_stem,
116 : it will automatically poll the in link and forward fragments to the
117 : user code (unless the link is specified as unpolled).
118 :
119 : An input link has an fseq which is a ulong used for returning the
120 : current reader position in sequence space, used for wiring flow
121 : control to the producer. The producer will not produce fragments
122 : while any downstream consumer link is not ready to receive them,
123 : unless the link is marked as unreliable. */
124 :
125 : void
126 : fd_topob_tile_in( fd_topo_t * topo,
127 : char const * tile_name,
128 : ulong tile_kind_id,
129 : char const * fseq_wksp,
130 : char const * link_name,
131 : ulong link_kind_id,
132 : int reliable,
133 : int polled );
134 :
135 : /* Add an output link to the tile. This doesn't do much by itself,
136 : but will cause the link to get mapped in as writable for the tile,
137 : and the tile can later look up the link by name and write to it
138 : as it wants. */
139 :
140 : void
141 : fd_topob_tile_out( fd_topo_t * topo,
142 : char const * tile_name,
143 : ulong tile_kind_id,
144 : char const * link_name,
145 : ulong link_kind_id );
146 :
147 : /* Automatically layout the tiles onto CPUs in the topology for a
148 : best effort. fd_topob_auto_layout reads CPU topology from the OS.
149 : fd_topob_auto_layout_cpus takes a pre-built CPU topology, useful
150 : for testing. */
151 :
152 : void
153 : fd_topob_auto_layout( fd_topo_t * topo,
154 : int reserve_agave_cores );
155 :
156 : void
157 : fd_topob_auto_layout_cpus( fd_topo_t * topo,
158 : fd_topo_cpus_t * cpus,
159 : int reserve_agave_cores );
160 :
161 : /* Finish creating the topology. Lays out all the objects in the
162 : given workspaces, and sizes everything correctly. Also validates
163 : the topology before returning.
164 :
165 : This must be called to finish creating the topology. */
166 :
167 : void
168 : fd_topob_finish( fd_topo_t * topo,
169 : fd_topo_obj_callbacks_t ** callbacks );
170 :
171 :
172 : /* Classify a tile name into one of the FD_TOPOB_PRIORITY_* categories. */
173 : int
174 : fd_topob_tile_priority_type( char const * name );
175 : FD_PROTOTYPES_END
176 :
177 : #endif /* HEADER_fd_src_disco_topo_fd_topob_h */
|