Skip to content

Commit 06958e9

Browse files
committed
auto_configure: add attributes of device global to autodiscovery string parsing and extend unit test
1 parent f8e3a83 commit 06958e9

File tree

3 files changed

+70
-19
lines changed

3 files changed

+70
-19
lines changed

include/acl.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,10 +498,25 @@ typedef class acl_device_program_info_t *acl_device_program_info;
498498
*/
499499
#define ACL_MEM_CAPABILITY_P2P (1 << 3)
500500

501+
typedef enum {
502+
ACL_DEVICE_GLOBAL_HOST_ACCESS_NONE,
503+
ACL_DEVICE_GLOBAL_HOST_ACCESS_READ_ONLY,
504+
ACL_DEVICE_GLOBAL_HOST_ACCESS_WRITE_ONLY,
505+
ACL_DEVICE_GLOBAL_HOST_ACCESS_READ_WRITE
506+
} acl_device_global_host_access_t;
507+
508+
typedef enum {
509+
ACL_DEVICE_GLOBAL_INIT_MODE_REPROGRAM,
510+
ACL_DEVICE_GLOBAL_INIT_MODE_RESET
511+
} acl_device_global_init_mode_t;
512+
501513
// Definition of device global.
502514
struct acl_device_global_mem_def_t {
503515
uint32_t address;
504516
uint32_t size;
517+
acl_device_global_host_access_t host_access;
518+
acl_device_global_init_mode_t init_mode;
519+
bool implement_in_csr;
505520
};
506521

507522
// Part of acl_device_def_t where members are populated from the information

src/acl_auto_configure.cpp

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,9 @@ static bool read_device_global_mem_defs(
470470
total_fields_device_global, counters);
471471
}
472472

473+
// Clean up any residual information first
474+
device_global_mem_defs.clear();
475+
473476
for (auto i = 0U; result && (i < num_device_global); i++) {
474477
counters.emplace_back(total_fields_device_global);
475478

@@ -493,8 +496,28 @@ static bool read_device_global_mem_defs(
493496
read_uint32_counters(config_str, curr_pos, dev_global_size, counters);
494497
}
495498

496-
acl_device_global_mem_def_t dev_global_def = {dev_global_addr,
497-
dev_global_size};
499+
// read device global properties
500+
auto host_access = static_cast<unsigned>(
501+
ACL_DEVICE_GLOBAL_HOST_ACCESS_READ_WRITE); // default
502+
if (result && counters.back() > 0) {
503+
result = read_uint_counters(config_str, curr_pos, host_access, counters);
504+
}
505+
auto init_mode =
506+
static_cast<unsigned>(ACL_DEVICE_GLOBAL_INIT_MODE_REPROGRAM); // default
507+
if (result && counters.back() > 0) {
508+
result = read_uint_counters(config_str, curr_pos, init_mode, counters);
509+
}
510+
bool implement_in_csr = false; // default to false
511+
if (result && counters.back() > 0) {
512+
result =
513+
read_bool_counters(config_str, curr_pos, implement_in_csr, counters);
514+
}
515+
516+
acl_device_global_mem_def_t dev_global_def = {
517+
dev_global_addr, dev_global_size,
518+
static_cast<acl_device_global_host_access_t>(host_access),
519+
static_cast<acl_device_global_init_mode_t>(init_mode),
520+
implement_in_csr};
498521
bool ok =
499522
device_global_mem_defs.insert({device_global_name, dev_global_def})
500523
.second;

test/acl_auto_configure_test.cpp

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ TEST(auto_configure, simple) {
3636
#define VERSIONIDSTRINGIFY(x) #x
3737
#define VERSIONIDTOSTR(x) VERSIONIDSTRINGIFY(x)
3838
#define DEVICE_FIELDS " 23"
39-
#define DEVICE_FIELDS_DEV_GLOBAL " 30"
39+
#define DEVICE_FIELDS_DEV_GLOBAL " 36"
4040
#define DEVICE_FIELDS_OLD " 18"
4141
#define BOARDNAME "de4_gen2x4_swdimm"
4242
#define BOARDNAME2 "pcie385_a7"
@@ -99,10 +99,11 @@ TEST(auto_configure, simple) {
9999

100100
// Device global autodiscovery entries
101101
#define NUM_DEV_GLOBAL " 2"
102-
#define NUM_DEV_GLOBAL_FIELD " 3" // containing dev_globa_name, address, size
103-
#define DEV_GLOBAL_1 \
104-
" kernel15_dev_global 4096 2048" // in format of dev_globa_name, address, size
105-
#define DEV_GLOBAL_2 " kernel15_dev_global2 2048 1024"
102+
#define NUM_DEV_GLOBAL_FIELD \
103+
" 6" // contains dev_globa_name, address, size, host_access, init_mode,
104+
// implement_in_csr with the above format
105+
#define DEV_GLOBAL_1 " kernel15_dev_global 4096 2048 0 1 0"
106+
#define DEV_GLOBAL_2 " kernel15_dev_global2 2048 1024 2 0 1"
106107

107108
int parsed;
108109
std::string err_str;
@@ -283,8 +284,18 @@ TEST(auto_configure, simple) {
283284
m_device_def.autodiscovery_def.device_global_mem_defs.end());
284285
CHECK_EQUAL(4096, kernel15_dev_global->second.address);
285286
CHECK_EQUAL(2048, kernel15_dev_global->second.size);
287+
CHECK_EQUAL(ACL_DEVICE_GLOBAL_HOST_ACCESS_NONE,
288+
kernel15_dev_global->second.host_access);
289+
CHECK_EQUAL(ACL_DEVICE_GLOBAL_INIT_MODE_RESET,
290+
kernel15_dev_global->second.init_mode);
291+
CHECK_EQUAL(false, kernel15_dev_global->second.implement_in_csr);
286292
CHECK_EQUAL(2048, kernel15_dev_global2->second.address);
287293
CHECK_EQUAL(1024, kernel15_dev_global2->second.size);
294+
CHECK_EQUAL(ACL_DEVICE_GLOBAL_HOST_ACCESS_WRITE_ONLY,
295+
kernel15_dev_global2->second.host_access);
296+
CHECK_EQUAL(ACL_DEVICE_GLOBAL_INIT_MODE_REPROGRAM,
297+
kernel15_dev_global2->second.init_mode);
298+
CHECK_EQUAL(true, kernel15_dev_global2->second.implement_in_csr);
288299

289300
// Check a second parsing.
290301
// It should allocate a new string for the name.
@@ -482,11 +493,13 @@ TEST(auto_configure, many_ok_forward_compatibility) {
482493
// sections and subsections to check forward compatibility
483494

484495
std::string str(VERSIONIDTOSTR(
485-
ACL_AUTO_CONFIGURE_VERSIONID) " 29 "
496+
ACL_AUTO_CONFIGURE_VERSIONID) " 49 "
486497
"sample40byterandomhash000000000000000000 "
487-
"a10gx 0 1 15 DDR 2 1 6 0 2147483648 100 "
488-
"100 100 100 200 200 200 200 0 0 0 0 2 "
489-
"1 name1 name2 0 0 47 "
498+
"a10gx 0 1 17 DDR 2 1 6 0 2147483648 100 "
499+
"100 100 100 0 - 0 200 200 200 200 0 0 0 "
500+
"2 9 ms_dev_global1 2048 1024 3 0 0 300 "
501+
"300 300 ms_dev_global2 4096 1024 1 1 1 "
502+
"300 300 300 0 0 400 400 47 "
490503
"40 external_sort_stage_0 0 128 1 0 0 1 0 "
491504
"1 0 1 10 0 0 4 1 0 0 0 500 500 500 0 0 "
492505
"0 0 1 1 1 3 1 1 1 3 1 0 0 800 800 800 "
@@ -677,10 +690,10 @@ TEST(auto_configure, many_ok_forward_compatibility) {
677690

678691
TEST(auto_configure, many_limit_check) {
679692
std::string str(VERSIONIDTOSTR(
680-
ACL_AUTO_CONFIGURE_VERSIONID) " 15 "
693+
ACL_AUTO_CONFIGURE_VERSIONID) " 19 "
681694
"sample40byterandomhash000000000000000000 "
682-
"a10gx 0 1 7 DDR 2 1 2 0 2147483648 0 0 0 "
683-
"0 75 "
695+
"a10gx 0 1 9 DDR 2 1 2 0 2147483648 0 - 0 "
696+
"0 0 0 0 0 75 " // 75 kernels
684697
"31 external_sort_stage_0 0 128 1 0 0 1 0 "
685698
"1 0 1 6 0 0 4 1 0 0 0 0 0 0 1 1 1 3 1 1 1 "
686699
"3 1 "
@@ -1193,14 +1206,14 @@ TEST(auto_configure, kernel_arg_info) {
11931206

11941207
TEST(auto_configure, hostpipe) {
11951208
std::string str(VERSIONIDTOSTR(
1196-
ACL_AUTO_CONFIGURE_VERSIONID) " 46 "
1209+
ACL_AUTO_CONFIGURE_VERSIONID) " 49 "
11971210
"sample40byterandomhash000000000000000000 "
11981211
"a10gx_hostpipe 0 1 15 DDR 2 1 6 0 "
11991212
"2147483648 0 100 100 100 100 200 200 200 "
12001213
"200 "
12011214
"2 9 host_to_dev 1 0 32 32768 300 300 300 "
12021215
"300 dev_to_host 0 1 32 32768 300 300 300 "
1203-
"300 400 1 3 name3 400 0 "
1216+
"300 400 1 6 dev_global_3 1024 2048 0 0 0 "
12041217
"1 29 foo 0 128 1 0 0 1 0 1 0 0 0 0 0 0 1 "
12051218
"1 1 3 1 1 1 3 1 0 0 800 800 800 900 "
12061219
"900"
@@ -1230,10 +1243,10 @@ TEST(auto_configure, hostpipe) {
12301243

12311244
TEST(auto_configure, streaming) {
12321245
const std::string config_str{
1233-
"23 26 " RANDOM_HASH
1246+
"23 29 " RANDOM_HASH
12341247
" pac_a10 0 1 13 DDR 2 2 24 1 2 0 4294967296 4294967296 8589934592 0 - 0 "
1235-
"0 0 0 1 3 device_global_name 256 128 1 105 _ZTS3CRCILi0EE 0 256 1 0 0 1 "
1236-
"0 1 0 9 8 0 0 8 1 0 0 1 k0_ZTS3CRCILi0EE_arg0 8 2 1 8 1024 0 3 1 "
1248+
"0 0 0 1 6 device_global_name 256 128 0 0 0 1 105 _ZTS3CRCILi0EE 0 256 1 "
1249+
"0 0 1 0 1 0 9 8 0 0 8 1 0 0 1 k0_ZTS3CRCILi0EE_arg0 8 2 1 8 1024 0 3 1 "
12371250
"k0_ZTS3CRCILi0EE_arg1 8 0 0 8 1 0 0 1 k0_ZTS3CRCILi0EE_arg2 7 0 0 8 1 0 "
12381251
"0 0 7 0 0 8 1 0 0 0 7 2 1 8 1024 0 2 0 7 0 0 8 1 0 0 0 7 0 0 8 1 0 0 0 "
12391252
"7 0 0 8 1 0 0 0 0 0 1 2 64 4096 1 1 1 3 1 1 1 3 1 0 1 "

0 commit comments

Comments
 (0)