@@ -193,6 +193,126 @@ static int read_string_counters(const std::string &str,
193
193
return result != " " ;
194
194
}
195
195
196
+ static bool read_kernel_arg_info (const std::string &config_str,
197
+ bool kernel_arg_info_available,
198
+ std::string::size_type &curr_pos,
199
+ acl_kernel_arg_info_t &arg_info,
200
+ std::vector<int > &counters) noexcept {
201
+ bool result = true ;
202
+ auto addr_space_type = 0U ;
203
+ auto category = 0U ;
204
+ auto size = 0U ;
205
+ int total_fields_arguments = 0 ;
206
+ if (result) {
207
+ result = result && read_int_counters (config_str, curr_pos,
208
+ total_fields_arguments, counters);
209
+ }
210
+ counters.emplace_back (total_fields_arguments);
211
+ unsigned alignment = ACL_MEM_ALIGN; // Set default to 1024 bytes
212
+ result =
213
+ result &&
214
+ read_uint_counters (config_str, curr_pos, addr_space_type, counters) &&
215
+ read_uint_counters (config_str, curr_pos, category, counters) &&
216
+ read_uint_counters (config_str, curr_pos, size, counters);
217
+ if (result) {
218
+ result =
219
+ result && read_uint_counters (config_str, curr_pos, alignment, counters);
220
+ }
221
+
222
+ std::string buffer_location = " " ;
223
+ if (result) {
224
+ unsigned int num_buffer_locations = 0 ;
225
+ result = result && read_uint_counters (config_str, curr_pos,
226
+ num_buffer_locations, counters);
227
+ for (unsigned int k = 0 ; result && (k < num_buffer_locations); k++) {
228
+ result = result && read_string_counters (config_str, curr_pos,
229
+ buffer_location, counters);
230
+ }
231
+ if (result && num_buffer_locations > 1 ) {
232
+ std::cerr << " WARNING: kernel argument has multiple buffer_location "
233
+ " attributes which is not supported.\n Selecting "
234
+ << buffer_location << " as buffer location.\n " ;
235
+ }
236
+ }
237
+
238
+ // Only local mem contains the following params
239
+ auto aspace_id = 0U ;
240
+ auto lmem_size_bytes = 0U ;
241
+ if (result && (addr_space_type == ACL_ARG_ADDR_LOCAL)) {
242
+ result =
243
+ result &&
244
+ read_uint_counters (config_str, curr_pos, aspace_id, counters) &&
245
+ read_uint_counters (config_str, curr_pos, lmem_size_bytes, counters);
246
+ }
247
+
248
+ auto type_qualifier = 0U ;
249
+ auto host_accessible = 0U ;
250
+ std::string pipe_channel_id;
251
+ if (result) {
252
+ result = result &&
253
+ read_uint_counters (config_str, curr_pos, type_qualifier, counters);
254
+ if (result && (type_qualifier == ACL_ARG_TYPE_PIPE)) {
255
+ result = result && read_uint_counters (config_str, curr_pos,
256
+ host_accessible, counters);
257
+ if (result && host_accessible) {
258
+ result = result && read_string_counters (config_str, curr_pos,
259
+ pipe_channel_id, counters);
260
+ }
261
+ }
262
+ }
263
+
264
+ std::string name = " " ;
265
+ std::string type_name = " " ;
266
+ auto access_qualifier = 0U ;
267
+ if (kernel_arg_info_available) {
268
+ if (result) {
269
+ result =
270
+ result &&
271
+ read_string_counters (config_str, curr_pos, name, counters) &&
272
+ read_string_counters (config_str, curr_pos, type_name, counters) &&
273
+ read_uint_counters (config_str, curr_pos, access_qualifier, counters);
274
+ }
275
+ if (type_name == " 0" )
276
+ type_name = " " ;
277
+ }
278
+
279
+ /* ****************************************************************
280
+ Since the introduction of autodiscovery forwards-compatibility,
281
+ new entries for each kernel argument section start here.
282
+ ****************************************************************/
283
+
284
+ if (result) {
285
+ arg_info.name = name;
286
+ arg_info.addr_space =
287
+ static_cast <acl_kernel_arg_addr_space_t >(addr_space_type);
288
+ arg_info.access_qualifier =
289
+ static_cast <acl_kernel_arg_access_qualifier_t >(access_qualifier);
290
+ arg_info.category = static_cast <acl_kernel_arg_category_t >(category);
291
+ arg_info.size = size;
292
+ arg_info.alignment = alignment;
293
+ arg_info.aspace_number = aspace_id;
294
+ arg_info.lmem_size_bytes = lmem_size_bytes;
295
+ arg_info.type_name = type_name;
296
+ arg_info.type_qualifier =
297
+ static_cast <acl_kernel_arg_type_qualifier_t >(type_qualifier);
298
+ arg_info.host_accessible = host_accessible;
299
+ arg_info.pipe_channel_id = pipe_channel_id;
300
+ arg_info.buffer_location = buffer_location;
301
+ }
302
+ // forward compatibility: bypassing remaining fields at the end of
303
+ // arguments section
304
+ while (result && counters.size () > 0 &&
305
+ counters.back () > 0 ) { // total_fields_arguments>0
306
+ std::string tmp;
307
+ result =
308
+ result && read_string_counters (config_str, curr_pos, tmp, counters);
309
+ check_section_counters (counters);
310
+ }
311
+ counters.pop_back ();
312
+
313
+ return result;
314
+ }
315
+
196
316
bool acl_load_device_def_from_str (const std::string &config_str,
197
317
acl_device_def_autodiscovery_t &devdef,
198
318
std::string &err_str) noexcept {
@@ -682,123 +802,9 @@ bool acl_load_device_def_from_str(const std::string &config_str,
682
802
}
683
803
684
804
for (auto j = 0U ; result && (j < num_args); j++) { // arguments
685
- auto addr_space_type = 0U ;
686
- auto category = 0U ;
687
- auto size = 0U ;
688
- int total_fields_arguments = 0 ;
689
- if (result) {
690
- result =
691
- result && read_int_counters (config_str, curr_pos,
692
- total_fields_arguments, counters);
693
- }
694
- counters.emplace_back (total_fields_arguments);
695
- unsigned alignment = ACL_MEM_ALIGN; // Set default to 1024 bytes
696
- result = result &&
697
- read_uint_counters (config_str, curr_pos, addr_space_type,
698
- counters) &&
699
- read_uint_counters (config_str, curr_pos, category, counters) &&
700
- read_uint_counters (config_str, curr_pos, size, counters);
701
- if (result) {
702
- result = result && read_uint_counters (config_str, curr_pos, alignment,
703
- counters);
704
- }
705
-
706
- std::string buffer_location = " " ;
707
- if (result) {
708
- unsigned int num_buffer_locations = 0 ;
709
- result = result && read_uint_counters (config_str, curr_pos,
710
- num_buffer_locations, counters);
711
- for (unsigned int k = 0 ; result && (k < num_buffer_locations); k++) {
712
- result = result && read_string_counters (config_str, curr_pos,
713
- buffer_location, counters);
714
- }
715
- if (result && num_buffer_locations > 1 ) {
716
- std::cerr
717
- << " WARNING: kernel argument has multiple buffer_location "
718
- " attributes which is not supported.\n Selecting "
719
- << buffer_location << " as buffer location.\n " ;
720
- }
721
- }
722
-
723
- // Only local mem contains the following params
724
- auto aspace_id = 0U ;
725
- auto lmem_size_bytes = 0U ;
726
- if (result && (addr_space_type == ACL_ARG_ADDR_LOCAL)) {
727
- result =
728
- result &&
729
- read_uint_counters (config_str, curr_pos, aspace_id, counters) &&
730
- read_uint_counters (config_str, curr_pos, lmem_size_bytes,
731
- counters);
732
- }
733
-
734
- auto type_qualifier = 0U ;
735
- auto host_accessible = 0U ;
736
- std::string pipe_channel_id;
737
- if (result) {
738
- result = result && read_uint_counters (config_str, curr_pos,
739
- type_qualifier, counters);
740
- if (result && (type_qualifier == ACL_ARG_TYPE_PIPE)) {
741
- result = result && read_uint_counters (config_str, curr_pos,
742
- host_accessible, counters);
743
- if (result && host_accessible) {
744
- result =
745
- result && read_string_counters (config_str, curr_pos,
746
- pipe_channel_id, counters);
747
- }
748
- }
749
- }
750
-
751
- std::string name = " " ;
752
- std::string type_name = " " ;
753
- auto access_qualifier = 0U ;
754
- if (kernel_arg_info_available) {
755
- if (result) {
756
- result =
757
- result &&
758
- read_string_counters (config_str, curr_pos, name, counters) &&
759
- read_string_counters (config_str, curr_pos, type_name,
760
- counters) &&
761
- read_uint_counters (config_str, curr_pos, access_qualifier,
762
- counters);
763
- }
764
- if (type_name == " 0" )
765
- type_name = " " ;
766
- }
767
-
768
- /* ****************************************************************
769
- Since the introduction of autodiscovery forwards-compatibility,
770
- new entries for each kernel argument section start here.
771
- ****************************************************************/
772
-
773
- if (result) {
774
- devdef.accel [i].iface .args [j].name = name;
775
- devdef.accel [i].iface .args [j].addr_space =
776
- static_cast <acl_kernel_arg_addr_space_t >(addr_space_type);
777
- devdef.accel [i].iface .args [j].access_qualifier =
778
- static_cast <acl_kernel_arg_access_qualifier_t >(access_qualifier);
779
- devdef.accel [i].iface .args [j].category =
780
- static_cast <acl_kernel_arg_category_t >(category);
781
- devdef.accel [i].iface .args [j].size = size;
782
- devdef.accel [i].iface .args [j].alignment = alignment;
783
- devdef.accel [i].iface .args [j].aspace_number = aspace_id;
784
- devdef.accel [i].iface .args [j].lmem_size_bytes = lmem_size_bytes;
785
- devdef.accel [i].iface .args [j].type_name = type_name;
786
- devdef.accel [i].iface .args [j].type_qualifier =
787
- static_cast <acl_kernel_arg_type_qualifier_t >(type_qualifier);
788
- devdef.accel [i].iface .args [j].host_accessible = host_accessible;
789
- devdef.accel [i].iface .args [j].pipe_channel_id = pipe_channel_id;
790
- devdef.accel [i].iface .args [j].buffer_location = buffer_location;
791
- }
792
- // forward compatibility: bypassing remaining fields at the end of
793
- // arguments section
794
- while (result && counters.size () > 0 &&
795
- counters.back () > 0 ) { // total_fields_arguments>0
796
- std::string tmp;
797
- result = result &&
798
- read_string_counters (config_str, curr_pos, tmp, counters);
799
- check_section_counters (counters);
800
- }
801
- counters.pop_back ();
805
+ result = result && read_kernel_arg_info (
806
+ config_str, kernel_arg_info_available, curr_pos,
807
+ devdef.accel [i].iface .args [j], counters);
802
808
} // arguments
803
809
804
810
// Get the number of printf format strings
0 commit comments