Line data Source code
1 : #include "../../vinyl/fd_vinyl.h"
2 : #include "../../disco/topo/fd_topo.h"
3 : #include "../../flamenco/accdb/fd_vinyl_req_pool.h"
4 : #include "../../util/pod/fd_pod_format.h"
5 :
6 0 : #define VAL(name) (__extension__({ \
7 0 : ulong __x = fd_pod_queryf_ulong( topo->props, ULONG_MAX, "obj.%lu.%s", obj->id, name ); \
8 0 : if( FD_UNLIKELY( __x==ULONG_MAX ) ) FD_LOG_ERR(( "obj.%lu.%s was not set", obj->id, name )); \
9 0 : __x; }))
10 :
11 :
12 : /* vinyl_meta: a shared memory separately chained hash map */
13 :
14 : static ulong
15 : vinyl_meta_align( fd_topo_t const * topo,
16 0 : fd_topo_obj_t const * obj ) {
17 0 : (void)topo; (void)obj;
18 0 : return fd_vinyl_meta_align();
19 0 : }
20 :
21 : static ulong
22 : vinyl_meta_footprint( fd_topo_t const * topo,
23 0 : fd_topo_obj_t const * obj ) {
24 0 : return fd_vinyl_meta_footprint( VAL("ele_max"), VAL("lock_cnt"), VAL("probe_max") );
25 0 : }
26 :
27 : static void
28 : vinyl_meta_new( fd_topo_t const * topo,
29 0 : fd_topo_obj_t const * obj ) {
30 0 : FD_TEST( fd_vinyl_meta_new( fd_topo_obj_laddr( topo, obj->id ), VAL("ele_max"), VAL("lock_cnt"), VAL("probe_max"), VAL("seed") ) );
31 0 : }
32 :
33 : fd_topo_obj_callbacks_t fd_obj_cb_vinyl_meta = {
34 : .name = "vinyl_meta",
35 : .footprint = vinyl_meta_footprint,
36 : .align = vinyl_meta_align,
37 : .new = vinyl_meta_new,
38 : };
39 :
40 : /* vinyl_meta_ele: hash map elements of vinyl_meta */
41 :
42 : static ulong
43 : vinyl_meta_ele_align( fd_topo_t const * topo,
44 0 : fd_topo_obj_t const * obj ) {
45 0 : (void)topo; (void)obj;
46 0 : return fd_ulong_max( alignof(fd_vinyl_meta_ele_t), 128UL );
47 0 : }
48 :
49 : static ulong
50 : vinyl_meta_ele_footprint( fd_topo_t const * topo,
51 0 : fd_topo_obj_t const * obj ) {
52 0 : return fd_ulong_align_up( sizeof(fd_vinyl_meta_ele_t) * VAL("cnt"), vinyl_meta_ele_align( topo, obj ) );
53 0 : }
54 :
55 : static void
56 : vinyl_meta_ele_new( fd_topo_t const * topo,
57 0 : fd_topo_obj_t const * obj ) {
58 : /* On Zen 4:
59 : - non-temporal wide stores are fastest
60 : - scattering 8 byte writes is slower
61 : - memset is slowest */
62 :
63 0 : # if FD_HAS_AVX512
64 0 : uchar * m0 = fd_topo_obj_laddr( topo, obj->id );
65 0 : uchar * m1 = m0 + vinyl_meta_ele_footprint( topo, obj );
66 0 : __m512i zero = _mm512_setzero_si512();
67 0 : for( uchar * m=m0; m<m1; m+=64 ) {
68 0 : _mm512_stream_si512( (__m512i *)m, zero );
69 0 : }
70 0 : _mm_sfence();
71 : # else
72 0 : fd_vinyl_meta_ele_t * ele = fd_topo_obj_laddr( topo, obj->id );
73 0 : ulong cnt = VAL("cnt");
74 0 : for( ulong i=0UL; i<cnt; i++ ) {
75 0 : ele[ i ].phdr.ctl = 0UL;
76 0 : }
77 0 : # endif
78 0 : }
79 :
80 : fd_topo_obj_callbacks_t fd_obj_cb_vinyl_meta_ele = {
81 : .name = "vinyl_meta_e",
82 : .footprint = vinyl_meta_ele_footprint,
83 : .align = vinyl_meta_ele_align,
84 : .new = vinyl_meta_ele_new,
85 : };
86 :
87 : /* vinyl_data: memory arena for data cache entries */
88 :
89 : static ulong
90 : vinyl_data_align( fd_topo_t const * topo,
91 0 : fd_topo_obj_t const * obj ) {
92 0 : (void)topo; (void)obj;
93 0 : return alignof(fd_vinyl_data_obj_t);
94 0 : }
95 :
96 : static ulong
97 : vinyl_data_footprint( fd_topo_t const * topo,
98 0 : fd_topo_obj_t const * obj ) {
99 0 : return fd_ulong_align_dn( VAL("data_sz"), alignof(fd_vinyl_data_obj_t) );
100 0 : }
101 :
102 : static void
103 : vinyl_data_new( fd_topo_t const * topo,
104 0 : fd_topo_obj_t const * obj ) {
105 0 : (void)topo; (void)obj;
106 : /* initialized by user */
107 0 : }
108 :
109 : fd_topo_obj_callbacks_t fd_obj_cb_vinyl_data = {
110 : .name = "vinyl_data",
111 : .footprint = vinyl_data_footprint,
112 : .align = vinyl_data_align,
113 : .new = vinyl_data_new,
114 : };
115 :
116 : /* vinyl_req_pool: request allocator */
117 :
118 : static ulong
119 : vinyl_req_pool_align( fd_topo_t const * topo,
120 0 : fd_topo_obj_t const * obj ) {
121 0 : (void)topo; (void)obj;
122 0 : return fd_vinyl_req_pool_align();
123 0 : }
124 :
125 : static ulong
126 : vinyl_req_pool_footprint( fd_topo_t const * topo,
127 0 : fd_topo_obj_t const * obj ) {
128 0 : return fd_vinyl_req_pool_footprint( VAL("batch_max"), VAL("batch_key_max") );
129 0 : }
130 :
131 : static void
132 : vinyl_req_pool_new( fd_topo_t const * topo,
133 0 : fd_topo_obj_t const * obj ) {
134 0 : FD_TEST( fd_vinyl_req_pool_new( fd_topo_obj_laddr( topo, obj->id ), VAL("batch_max"), VAL("batch_key_max") ) );
135 0 : }
136 :
137 : fd_topo_obj_callbacks_t fd_obj_cb_vinyl_req_pool = {
138 : .name = "vinyl_rpool",
139 : .footprint = vinyl_req_pool_footprint,
140 : .align = vinyl_req_pool_align,
141 : .new = vinyl_req_pool_new,
142 : };
143 :
144 : /* vinyl_rq: request queue */
145 :
146 : static ulong
147 : vinyl_rq_align( fd_topo_t const * topo,
148 0 : fd_topo_obj_t const * obj ) {
149 0 : (void)topo; (void)obj;
150 0 : return fd_vinyl_rq_align();
151 0 : }
152 :
153 : static ulong
154 : vinyl_rq_footprint( fd_topo_t const * topo,
155 0 : fd_topo_obj_t const * obj ) {
156 0 : return fd_vinyl_rq_footprint( VAL("req_cnt") );
157 0 : }
158 :
159 : static void
160 : vinyl_rq_new( fd_topo_t const * topo,
161 0 : fd_topo_obj_t const * obj ) {
162 0 : FD_TEST( fd_vinyl_rq_new( fd_topo_obj_laddr( topo, obj->id ), VAL("req_cnt") ) );
163 0 : }
164 :
165 : fd_topo_obj_callbacks_t fd_obj_cb_vinyl_rq = {
166 : .name = "vinyl_rq",
167 : .footprint = vinyl_rq_footprint,
168 : .align = vinyl_rq_align,
169 : .new = vinyl_rq_new,
170 : };
171 :
172 : /* vinyl_cq: completion queue */
173 :
174 : static ulong
175 : vinyl_cq_align( fd_topo_t const * topo,
176 0 : fd_topo_obj_t const * obj ) {
177 0 : (void)topo; (void)obj;
178 0 : return fd_vinyl_cq_align();
179 0 : }
180 :
181 : static ulong
182 : vinyl_cq_footprint( fd_topo_t const * topo,
183 0 : fd_topo_obj_t const * obj ) {
184 0 : return fd_vinyl_cq_footprint( VAL("comp_cnt") );
185 0 : }
186 :
187 : static void
188 : vinyl_cq_new( fd_topo_t const * topo,
189 0 : fd_topo_obj_t const * obj ) {
190 0 : FD_TEST( fd_vinyl_cq_new( fd_topo_obj_laddr( topo, obj->id ), VAL("comp_cnt") ) );
191 0 : }
192 :
193 : fd_topo_obj_callbacks_t fd_obj_cb_vinyl_cq = {
194 : .name = "vinyl_cq",
195 : .footprint = vinyl_cq_footprint,
196 : .align = vinyl_cq_align,
197 : .new = vinyl_cq_new,
198 : };
|