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