Skip to content

Commit b2f5a56

Browse files
committed
Auto discovery change
For each device global, the init_mode field is changed to can_skip_programming field, a new field reset_on_reuse is added at the end.
1 parent 03ebe32 commit b2f5a56

File tree

5 files changed

+41
-42
lines changed

5 files changed

+41
-42
lines changed

include/acl.h

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -512,25 +512,16 @@ typedef enum {
512512
ACL_DEVICE_GLOBAL_HOST_ACCESS_TYPE_COUNT
513513
} acl_device_global_host_access_t;
514514

515-
// Enum values here also need to match the SPIRV spec for device
516-
// global in the above link for acl_device_global_host_access_t.
517-
// ACL_DEVICE_GLOBAL_INIT_MODE_TYPE_COUNT is used for validation in
518-
// autodiscovery string parsing and should remain the last constant
519-
// in the enum.
520-
typedef enum {
521-
ACL_DEVICE_GLOBAL_INIT_MODE_REPROGRAM,
522-
ACL_DEVICE_GLOBAL_INIT_MODE_RESET,
523-
524-
ACL_DEVICE_GLOBAL_INIT_MODE_TYPE_COUNT
525-
} acl_device_global_init_mode_t;
526-
527515
// Definition of device global.
528516
struct acl_device_global_mem_def_t {
529517
uint64_t address;
530518
uint32_t size;
531519
acl_device_global_host_access_t host_access;
532-
acl_device_global_init_mode_t init_mode;
520+
// every device global has the same value for can_skip_programming
521+
bool can_skip_programming;
533522
bool implement_in_csr;
523+
// every device global has the same value for reset_on_reuse
524+
bool reset_on_reuse;
534525
};
535526

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

src/acl_auto_configure.cpp

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -528,25 +528,29 @@ static bool read_device_global_mem_defs(
528528
static_cast<unsigned>(ACL_DEVICE_GLOBAL_HOST_ACCESS_TYPE_COUNT))
529529
result = false;
530530
}
531-
auto init_mode =
532-
static_cast<unsigned>(ACL_DEVICE_GLOBAL_INIT_MODE_REPROGRAM);
531+
bool can_skip_programming = false;
533532
if (result && counters.back() > 0) {
534-
result = read_uint_counters(config_str, curr_pos, init_mode, counters);
535-
if (init_mode >=
536-
static_cast<unsigned>(ACL_DEVICE_GLOBAL_INIT_MODE_TYPE_COUNT))
537-
result = false;
533+
result = read_bool_counters(config_str, curr_pos, can_skip_programming,
534+
counters);
538535
}
539536
bool implement_in_csr = false;
540537
if (result && counters.back() > 0) {
541538
result =
542539
read_bool_counters(config_str, curr_pos, implement_in_csr, counters);
543540
}
541+
bool reset_on_reuse = false;
542+
if (result && counters.back() > 0) {
543+
result =
544+
read_bool_counters(config_str, curr_pos, reset_on_reuse, counters);
545+
}
544546

545547
acl_device_global_mem_def_t dev_global_def = {
546-
dev_global_addr, dev_global_size,
548+
dev_global_addr,
549+
dev_global_size,
547550
static_cast<acl_device_global_host_access_t>(host_access),
548-
static_cast<acl_device_global_init_mode_t>(init_mode),
549-
implement_in_csr};
551+
can_skip_programming,
552+
implement_in_csr,
553+
reset_on_reuse};
550554
bool ok =
551555
device_global_mem_defs.insert({device_global_name, dev_global_def})
552556
.second;

src/acl_kernel.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3016,8 +3016,7 @@ bool acl_device_has_reprogram_device_globals(cl_device_id device) {
30163016
std::find_if(device_global_mem_defs.begin(),
30173017
device_global_mem_defs.end(),
30183018
[](const auto &name_and_def) {
3019-
return name_and_def.second.init_mode ==
3020-
ACL_DEVICE_GLOBAL_INIT_MODE_REPROGRAM;
3019+
return !name_and_def.second.can_skip_programming;
30213020
});
30223021
}
30233022

test/acl_auto_configure_test.cpp

Lines changed: 20 additions & 16 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 " 36"
39+
#define DEVICE_FIELDS_DEV_GLOBAL " 38"
4040
#define DEVICE_FIELDS_OLD " 18"
4141
#define BOARDNAME "de4_gen2x4_swdimm"
4242
#define BOARDNAME2 "pcie385_a7"
@@ -99,11 +99,11 @@ TEST(auto_configure, simple) {
9999

100100
// Device global autodiscovery entries
101101
#define NUM_DEV_GLOBAL " 2"
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 0x1000 2048 3 1 0"
106-
#define DEV_GLOBAL_2 " kernel15_dev_global2 0x800 1024 1 0 1"
102+
#define NUM_DEV_GLOBAL_FIELD " 7"
103+
// The 7 fields are dev_globa_name, address, size, host_access,
104+
// can_skip_programming, implement_in_csr, reset_on_reuse
105+
#define DEV_GLOBAL_1 " kernel15_dev_global 0x1000 2048 3 0 0 0"
106+
#define DEV_GLOBAL_2 " kernel15_dev_global2 0x800 1024 1 0 1 0"
107107

108108
int parsed;
109109
std::string err_str;
@@ -286,16 +286,16 @@ TEST(auto_configure, simple) {
286286
CHECK_EQUAL(2048, kernel15_dev_global->second.size);
287287
CHECK_EQUAL(ACL_DEVICE_GLOBAL_HOST_ACCESS_NONE,
288288
kernel15_dev_global->second.host_access);
289-
CHECK_EQUAL(ACL_DEVICE_GLOBAL_INIT_MODE_RESET,
290-
kernel15_dev_global->second.init_mode);
289+
CHECK_EQUAL(false, kernel15_dev_global->second.can_skip_programming);
291290
CHECK_EQUAL(false, kernel15_dev_global->second.implement_in_csr);
291+
CHECK_EQUAL(false, kernel15_dev_global->second.reset_on_reuse);
292292
CHECK_EQUAL(2048, kernel15_dev_global2->second.address);
293293
CHECK_EQUAL(1024, kernel15_dev_global2->second.size);
294294
CHECK_EQUAL(ACL_DEVICE_GLOBAL_HOST_ACCESS_WRITE_ONLY,
295295
kernel15_dev_global2->second.host_access);
296-
CHECK_EQUAL(ACL_DEVICE_GLOBAL_INIT_MODE_REPROGRAM,
297-
kernel15_dev_global2->second.init_mode);
296+
CHECK_EQUAL(false, kernel15_dev_global2->second.can_skip_programming);
298297
CHECK_EQUAL(true, kernel15_dev_global2->second.implement_in_csr);
298+
CHECK_EQUAL(false, kernel15_dev_global2->second.reset_on_reuse);
299299

300300
// Check a second parsing.
301301
// It should allocate a new string for the name.
@@ -493,12 +493,14 @@ TEST(auto_configure, many_ok_forward_compatibility) {
493493
// sections and subsections to check forward compatibility
494494

495495
std::string str(VERSIONIDTOSTR(
496-
ACL_AUTO_CONFIGURE_VERSIONID) " 49 "
496+
ACL_AUTO_CONFIGURE_VERSIONID) " 51 "
497497
"sample40byterandomhash000000000000000000 "
498498
"a10gx 0 1 17 DDR 2 1 6 0 2147483648 100 "
499499
"100 100 100 0 - 0 200 200 200 200 0 0 0 "
500-
"2 9 ms_dev_global1 0x800 1024 3 0 0 300 "
500+
"2 10 ms_dev_global1 0x800 1024 3 0 0 0 "
501+
"300 "
501502
"300 300 ms_dev_global2 0x1000 1024 1 1 1 "
503+
"0 "
502504
"300 300 300 0 0 400 400 47 "
503505
"40 external_sort_stage_0 0 128 1 0 0 1 0 "
504506
"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) {
12061208

12071209
TEST(auto_configure, hostpipe) {
12081210
std::string str(VERSIONIDTOSTR(
1209-
ACL_AUTO_CONFIGURE_VERSIONID) " 49 "
1211+
ACL_AUTO_CONFIGURE_VERSIONID) " 50 "
12101212
"sample40byterandomhash000000000000000000 "
12111213
"a10gx_hostpipe 0 1 15 DDR 2 1 6 0 "
12121214
"2147483648 0 100 100 100 100 200 200 200 "
12131215
"200 "
12141216
"2 9 host_to_dev 1 0 32 32768 300 300 300 "
12151217
"300 dev_to_host 0 1 32 32768 300 300 300 "
1216-
"300 400 1 6 dev_global_3 0x400 2048 0 0 0 "
1218+
"300 400 1 7 dev_global_3 0x400 2048 0 0 0 "
1219+
"0 "
12171220
"1 29 foo 0 128 1 0 0 1 0 1 0 0 0 0 0 0 1 "
12181221
"1 1 3 1 1 1 3 1 0 0 800 800 800 900 "
12191222
"900"
@@ -1243,9 +1246,10 @@ TEST(auto_configure, hostpipe) {
12431246

12441247
TEST(auto_configure, streaming) {
12451248
const std::string config_str{
1246-
"23 29 " RANDOM_HASH
1249+
"23 30 " RANDOM_HASH
12471250
" pac_a10 0 1 13 DDR 2 2 24 1 2 0 4294967296 4294967296 8589934592 0 - 0 "
1248-
"0 0 0 1 6 device_global_name 0x100 128 0 0 0 1 105 _ZTS3CRCILi0EE 0 256 "
1251+
"0 0 0 1 7 device_global_name 0x100 128 0 0 0 0 1 105 _ZTS3CRCILi0EE 0 "
1252+
"256 "
12491253
"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 "
12501254
"1 k0_ZTS3CRCILi0EE_arg1 8 0 0 8 1 0 0 1 k0_ZTS3CRCILi0EE_arg2 7 0 0 8 1 "
12511255
"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 "

test/acl_kernel_test.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4350,8 +4350,9 @@ TEST(acl_kernel_reprogram_scheduler, device_global_reprogram) {
43504350
{/* address */ 1024,
43514351
/* size */ 1024,
43524352
/* host_access */ ACL_DEVICE_GLOBAL_HOST_ACCESS_READ_WRITE,
4353-
/* init_mode */ ACL_DEVICE_GLOBAL_INIT_MODE_REPROGRAM,
4354-
/* implement_in_csr */ false}});
4353+
/* can_skip_programming */ false,
4354+
/* implement_in_csr */ false,
4355+
/* reset_on_reuse */ false}});
43554356

43564357
// Initial eager reprogram
43574358
int offset = m_devlog.num_ops;

0 commit comments

Comments
 (0)