diff --git a/include/acl.h b/include/acl.h index 45bcea7b..bc76c40b 100644 --- a/include/acl.h +++ b/include/acl.h @@ -512,25 +512,16 @@ typedef enum { ACL_DEVICE_GLOBAL_HOST_ACCESS_TYPE_COUNT } acl_device_global_host_access_t; -// Enum values here also need to match the SPIRV spec for device -// global in the above link for acl_device_global_host_access_t. -// ACL_DEVICE_GLOBAL_INIT_MODE_TYPE_COUNT is used for validation in -// autodiscovery string parsing and should remain the last constant -// in the enum. -typedef enum { - ACL_DEVICE_GLOBAL_INIT_MODE_REPROGRAM, - ACL_DEVICE_GLOBAL_INIT_MODE_RESET, - - ACL_DEVICE_GLOBAL_INIT_MODE_TYPE_COUNT -} acl_device_global_init_mode_t; - // Definition of device global. struct acl_device_global_mem_def_t { uint64_t address; uint32_t size; acl_device_global_host_access_t host_access; - acl_device_global_init_mode_t init_mode; + // every device global has the same value for can_skip_programming + bool can_skip_programming; bool implement_in_csr; + // every device global has the same value for reset_on_reuse + bool reset_on_reuse; }; // Part of acl_device_def_t where members are populated from the information diff --git a/src/acl_auto_configure.cpp b/src/acl_auto_configure.cpp index c78082dd..c9a177fd 100644 --- a/src/acl_auto_configure.cpp +++ b/src/acl_auto_configure.cpp @@ -528,25 +528,29 @@ static bool read_device_global_mem_defs( static_cast(ACL_DEVICE_GLOBAL_HOST_ACCESS_TYPE_COUNT)) result = false; } - auto init_mode = - static_cast(ACL_DEVICE_GLOBAL_INIT_MODE_REPROGRAM); + bool can_skip_programming = false; if (result && counters.back() > 0) { - result = read_uint_counters(config_str, curr_pos, init_mode, counters); - if (init_mode >= - static_cast(ACL_DEVICE_GLOBAL_INIT_MODE_TYPE_COUNT)) - result = false; + result = read_bool_counters(config_str, curr_pos, can_skip_programming, + counters); } bool implement_in_csr = false; if (result && counters.back() > 0) { result = read_bool_counters(config_str, curr_pos, implement_in_csr, counters); } + bool reset_on_reuse = false; + if (result && counters.back() > 0) { + result = + read_bool_counters(config_str, curr_pos, reset_on_reuse, counters); + } acl_device_global_mem_def_t dev_global_def = { - dev_global_addr, dev_global_size, + dev_global_addr, + dev_global_size, static_cast(host_access), - static_cast(init_mode), - implement_in_csr}; + can_skip_programming, + implement_in_csr, + reset_on_reuse}; bool ok = device_global_mem_defs.insert({device_global_name, dev_global_def}) .second; diff --git a/src/acl_kernel.cpp b/src/acl_kernel.cpp index 1a1c0987..9751b2a1 100644 --- a/src/acl_kernel.cpp +++ b/src/acl_kernel.cpp @@ -3016,8 +3016,7 @@ bool acl_device_has_reprogram_device_globals(cl_device_id device) { std::find_if(device_global_mem_defs.begin(), device_global_mem_defs.end(), [](const auto &name_and_def) { - return name_and_def.second.init_mode == - ACL_DEVICE_GLOBAL_INIT_MODE_REPROGRAM; + return !name_and_def.second.can_skip_programming; }); } diff --git a/test/acl_auto_configure_test.cpp b/test/acl_auto_configure_test.cpp index 8024a4c6..b52d710d 100644 --- a/test/acl_auto_configure_test.cpp +++ b/test/acl_auto_configure_test.cpp @@ -36,7 +36,7 @@ TEST(auto_configure, simple) { #define VERSIONIDSTRINGIFY(x) #x #define VERSIONIDTOSTR(x) VERSIONIDSTRINGIFY(x) #define DEVICE_FIELDS " 23" -#define DEVICE_FIELDS_DEV_GLOBAL " 36" +#define DEVICE_FIELDS_DEV_GLOBAL " 38" #define DEVICE_FIELDS_OLD " 18" #define BOARDNAME "de4_gen2x4_swdimm" #define BOARDNAME2 "pcie385_a7" @@ -99,11 +99,11 @@ TEST(auto_configure, simple) { // Device global autodiscovery entries #define NUM_DEV_GLOBAL " 2" -#define NUM_DEV_GLOBAL_FIELD \ - " 6" // contains dev_globa_name, address, size, host_access, init_mode, - // implement_in_csr with the above format -#define DEV_GLOBAL_1 " kernel15_dev_global 0x1000 2048 3 1 0" -#define DEV_GLOBAL_2 " kernel15_dev_global2 0x800 1024 1 0 1" +#define NUM_DEV_GLOBAL_FIELD " 7" +// The 7 fields are dev_globa_name, address, size, host_access, +// can_skip_programming, implement_in_csr, reset_on_reuse +#define DEV_GLOBAL_1 " kernel15_dev_global 0x1000 2048 3 0 0 0" +#define DEV_GLOBAL_2 " kernel15_dev_global2 0x800 1024 1 0 1 0" int parsed; std::string err_str; @@ -286,16 +286,16 @@ TEST(auto_configure, simple) { CHECK_EQUAL(2048, kernel15_dev_global->second.size); CHECK_EQUAL(ACL_DEVICE_GLOBAL_HOST_ACCESS_NONE, kernel15_dev_global->second.host_access); - CHECK_EQUAL(ACL_DEVICE_GLOBAL_INIT_MODE_RESET, - kernel15_dev_global->second.init_mode); + CHECK_EQUAL(false, kernel15_dev_global->second.can_skip_programming); CHECK_EQUAL(false, kernel15_dev_global->second.implement_in_csr); + CHECK_EQUAL(false, kernel15_dev_global->second.reset_on_reuse); CHECK_EQUAL(2048, kernel15_dev_global2->second.address); CHECK_EQUAL(1024, kernel15_dev_global2->second.size); CHECK_EQUAL(ACL_DEVICE_GLOBAL_HOST_ACCESS_WRITE_ONLY, kernel15_dev_global2->second.host_access); - CHECK_EQUAL(ACL_DEVICE_GLOBAL_INIT_MODE_REPROGRAM, - kernel15_dev_global2->second.init_mode); + CHECK_EQUAL(false, kernel15_dev_global2->second.can_skip_programming); CHECK_EQUAL(true, kernel15_dev_global2->second.implement_in_csr); + CHECK_EQUAL(false, kernel15_dev_global2->second.reset_on_reuse); // Check a second parsing. // It should allocate a new string for the name. @@ -493,12 +493,14 @@ TEST(auto_configure, many_ok_forward_compatibility) { // sections and subsections to check forward compatibility std::string str(VERSIONIDTOSTR( - ACL_AUTO_CONFIGURE_VERSIONID) " 49 " + ACL_AUTO_CONFIGURE_VERSIONID) " 51 " "sample40byterandomhash000000000000000000 " "a10gx 0 1 17 DDR 2 1 6 0 2147483648 100 " "100 100 100 0 - 0 200 200 200 200 0 0 0 " - "2 9 ms_dev_global1 0x800 1024 3 0 0 300 " + "2 10 ms_dev_global1 0x800 1024 3 0 0 0 " + "300 " "300 300 ms_dev_global2 0x1000 1024 1 1 1 " + "0 " "300 300 300 0 0 400 400 47 " "40 external_sort_stage_0 0 128 1 0 0 1 0 " "1 0 1 10 0 0 4 1 0 0 0 500 500 500 0 0 " @@ -1206,14 +1208,15 @@ TEST(auto_configure, kernel_arg_info) { TEST(auto_configure, hostpipe) { std::string str(VERSIONIDTOSTR( - ACL_AUTO_CONFIGURE_VERSIONID) " 49 " + ACL_AUTO_CONFIGURE_VERSIONID) " 50 " "sample40byterandomhash000000000000000000 " "a10gx_hostpipe 0 1 15 DDR 2 1 6 0 " "2147483648 0 100 100 100 100 200 200 200 " "200 " "2 9 host_to_dev 1 0 32 32768 300 300 300 " "300 dev_to_host 0 1 32 32768 300 300 300 " - "300 400 1 6 dev_global_3 0x400 2048 0 0 0 " + "300 400 1 7 dev_global_3 0x400 2048 0 0 0 " + "0 " "1 29 foo 0 128 1 0 0 1 0 1 0 0 0 0 0 0 1 " "1 1 3 1 1 1 3 1 0 0 800 800 800 900 " "900" @@ -1243,9 +1246,10 @@ TEST(auto_configure, hostpipe) { TEST(auto_configure, streaming) { const std::string config_str{ - "23 29 " RANDOM_HASH + "23 30 " RANDOM_HASH " pac_a10 0 1 13 DDR 2 2 24 1 2 0 4294967296 4294967296 8589934592 0 - 0 " - "0 0 0 1 6 device_global_name 0x100 128 0 0 0 1 105 _ZTS3CRCILi0EE 0 256 " + "0 0 0 1 7 device_global_name 0x100 128 0 0 0 0 1 105 _ZTS3CRCILi0EE 0 " + "256 " "1 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 k0_ZTS3CRCILi0EE_arg1 8 0 0 8 1 0 0 1 k0_ZTS3CRCILi0EE_arg2 7 0 0 8 1 " "0 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 " diff --git a/test/acl_kernel_test.cpp b/test/acl_kernel_test.cpp index 68f1952a..0558d60b 100644 --- a/test/acl_kernel_test.cpp +++ b/test/acl_kernel_test.cpp @@ -4350,8 +4350,9 @@ TEST(acl_kernel_reprogram_scheduler, device_global_reprogram) { {/* address */ 1024, /* size */ 1024, /* host_access */ ACL_DEVICE_GLOBAL_HOST_ACCESS_READ_WRITE, - /* init_mode */ ACL_DEVICE_GLOBAL_INIT_MODE_REPROGRAM, - /* implement_in_csr */ false}}); + /* can_skip_programming */ false, + /* implement_in_csr */ false, + /* reset_on_reuse */ false}}); // Initial eager reprogram int offset = m_devlog.num_ops;