Line data Source code
1 : #include "../../util/pod/fd_pod_format.h"
2 :
3 : #include "../../disco/topo/fd_topo.h"
4 : #include "../../disco/store/fd_store.h"
5 : #include "../../flamenco/runtime/fd_bank.h"
6 : #include "../../flamenco/runtime/fd_txncache_shmem.h"
7 : #include "../../funk/fd_funk.h"
8 :
9 0 : #define VAL(name) (__extension__({ \
10 0 : ulong __x = fd_pod_queryf_ulong( topo->props, ULONG_MAX, "obj.%lu.%s", obj->id, name ); \
11 0 : if( FD_UNLIKELY( __x==ULONG_MAX ) ) FD_LOG_ERR(( "obj.%lu.%s was not set", obj->id, name )); \
12 0 : __x; }))
13 :
14 : static ulong
15 : banks_footprint( fd_topo_t const * topo,
16 0 : fd_topo_obj_t const * obj ) {
17 0 : return fd_banks_footprint( VAL("max_live_slots"), VAL("max_fork_width") );
18 0 : }
19 :
20 : static ulong
21 : banks_align( fd_topo_t const * topo FD_FN_UNUSED,
22 0 : fd_topo_obj_t const * obj FD_FN_UNUSED ) {
23 0 : return fd_banks_align();
24 0 : }
25 :
26 : static void
27 : banks_new( fd_topo_t const * topo,
28 0 : fd_topo_obj_t const * obj ) {
29 0 : int larger_max_cost_per_block = fd_pod_queryf_int( topo->props, 0, "obj.%lu.larger_max_cost_per_block", obj->id );
30 0 : ulong seed = fd_pod_queryf_ulong( topo->props, 0UL, "obj.%lu.seed", obj->id );
31 0 : FD_TEST( fd_banks_new( fd_topo_obj_laddr( topo, obj->id ), VAL("max_live_slots"), VAL("max_fork_width"), larger_max_cost_per_block, seed ) );
32 0 : }
33 :
34 : fd_topo_obj_callbacks_t fd_obj_cb_banks = {
35 : .name = "banks",
36 : .footprint = banks_footprint,
37 : .align = banks_align,
38 : .new = banks_new,
39 : };
40 :
41 : static ulong
42 : funk_align( fd_topo_t const * topo,
43 0 : fd_topo_obj_t const * obj ) {
44 0 : (void)topo; (void)obj;
45 0 : return fd_funk_align();
46 0 : }
47 :
48 : static ulong
49 : funk_footprint( fd_topo_t const * topo,
50 0 : fd_topo_obj_t const * obj ) {
51 0 : (void)topo;
52 0 : return fd_funk_footprint( VAL("txn_max"), VAL("rec_max") );
53 0 : }
54 :
55 : static ulong
56 : funk_loose( fd_topo_t const * topo,
57 0 : fd_topo_obj_t const * obj ) {
58 0 : return VAL("heap_max");
59 0 : }
60 :
61 : static void
62 : funk_new( fd_topo_t const * topo,
63 0 : fd_topo_obj_t const * obj ) {
64 0 : ulong funk_seed = fd_pod_queryf_ulong( topo->props, 0UL, "obj.%lu.seed", obj->id );
65 0 : if( !funk_seed ) FD_TEST( fd_rng_secure( &funk_seed, sizeof(ulong) ) );
66 0 : FD_TEST( fd_funk_new( fd_topo_obj_laddr( topo, obj->id ), 2UL, funk_seed, VAL("txn_max"), VAL("rec_max") ) );
67 0 : }
68 :
69 : fd_topo_obj_callbacks_t fd_obj_cb_funk = {
70 : .name = "funk",
71 : .footprint = funk_footprint,
72 : .loose = funk_loose,
73 : .align = funk_align,
74 : .new = funk_new,
75 : };
76 :
77 : /* cnc: a tile admin message queue */
78 :
79 : static ulong
80 : cnc_align( fd_topo_t const * topo,
81 0 : fd_topo_obj_t const * obj ) {
82 0 : (void)topo; (void)obj;
83 0 : return fd_cnc_align();
84 0 : }
85 :
86 : static ulong
87 : cnc_footprint( fd_topo_t const * topo,
88 0 : fd_topo_obj_t const * obj ) {
89 0 : return fd_cnc_footprint( VAL("app_sz") );
90 0 : }
91 :
92 : static void
93 : cnc_new( fd_topo_t const * topo,
94 0 : fd_topo_obj_t const * obj ) {
95 0 : FD_TEST( fd_cnc_new( fd_topo_obj_laddr( topo, obj->id ), VAL("app_sz"), VAL("type"), fd_log_wallclock() ) );
96 0 : }
97 :
98 : fd_topo_obj_callbacks_t fd_obj_cb_cnc = {
99 : .name = "cnc",
100 : .footprint = cnc_footprint,
101 : .align = cnc_align,
102 : .new = cnc_new,
103 : };
104 :
105 : static ulong
106 : fec_sets_footprint( fd_topo_t const * topo,
107 0 : fd_topo_obj_t const * obj ) {
108 0 : return VAL("sz");
109 0 : }
110 :
111 : static ulong
112 : fec_sets_align( fd_topo_t const * topo FD_FN_UNUSED,
113 0 : fd_topo_obj_t const * obj FD_FN_UNUSED ) {
114 0 : return fd_dcache_align();
115 0 : }
116 :
117 : static void
118 : fec_sets_new( FD_PARAM_UNUSED fd_topo_t const * topo,
119 0 : FD_PARAM_UNUSED fd_topo_obj_t const * obj ) {
120 0 : FD_TEST( fd_topo_obj_laddr( topo, obj->id ) );
121 0 : }
122 :
123 : fd_topo_obj_callbacks_t fd_obj_cb_fec_sets = {
124 : .name = "fec_sets",
125 : .footprint = fec_sets_footprint,
126 : .align = fec_sets_align,
127 : .new = fec_sets_new,
128 : };
129 :
130 : static ulong
131 : store_footprint( fd_topo_t const * topo,
132 0 : fd_topo_obj_t const * obj ) {
133 0 : return fd_store_footprint( VAL("fec_max") );
134 0 : }
135 :
136 : static ulong
137 : store_align( fd_topo_t const * topo FD_FN_UNUSED,
138 0 : fd_topo_obj_t const * obj FD_FN_UNUSED ) {
139 0 : return fd_store_align();
140 0 : }
141 :
142 : static void
143 : store_new( fd_topo_t const * topo,
144 0 : fd_topo_obj_t const * obj ) {
145 0 : FD_TEST( fd_store_new( fd_topo_obj_laddr( topo, obj->id ), VAL("fec_max"), VAL("part_cnt") ) );
146 0 : }
147 :
148 : fd_topo_obj_callbacks_t fd_obj_cb_store = {
149 : .name = "store",
150 : .footprint = store_footprint,
151 : .align = store_align,
152 : .new = store_new,
153 : };
154 :
155 : static ulong
156 : txncache_footprint( fd_topo_t const * topo,
157 0 : fd_topo_obj_t const * obj ) {
158 0 : return fd_txncache_shmem_footprint( VAL("max_live_slots"), VAL("max_txn_per_slot") );
159 0 : }
160 :
161 : static ulong
162 : txncache_align( fd_topo_t const * topo FD_FN_UNUSED,
163 0 : fd_topo_obj_t const * obj FD_FN_UNUSED ) {
164 0 : return fd_txncache_shmem_align();
165 0 : }
166 :
167 : static void
168 : txncache_new( fd_topo_t const * topo,
169 0 : fd_topo_obj_t const * obj ) {
170 0 : FD_TEST( fd_txncache_shmem_new( fd_topo_obj_laddr( topo, obj->id ), VAL("max_live_slots"), VAL("max_txn_per_slot") ) );
171 0 : }
172 :
173 : fd_topo_obj_callbacks_t fd_obj_cb_txncache = {
174 : .name = "txncache",
175 : .footprint = txncache_footprint,
176 : .align = txncache_align,
177 : .new = txncache_new,
178 : };
179 :
180 : #undef VAL
|