Skip to content

Commit a50bdbd

Browse files
committed
Auto discovery change
1 parent 03ebe32 commit a50bdbd

File tree

5 files changed

+24
-30
lines changed

5 files changed

+24
-30
lines changed

include/acl.h

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -514,23 +514,16 @@ typedef enum {
514514

515515
// Enum values here also need to match the SPIRV spec for device
516516
// 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,
523517

524-
ACL_DEVICE_GLOBAL_INIT_MODE_TYPE_COUNT
525-
} acl_device_global_init_mode_t;
526518

527519
// Definition of device global.
528520
struct acl_device_global_mem_def_t {
529521
uint64_t address;
530522
uint32_t size;
531523
acl_device_global_host_access_t host_access;
532-
acl_device_global_init_mode_t init_mode;
524+
bool can_skip_programming; // every device global has the same value
533525
bool implement_in_csr;
526+
bool reset_on_reuse; // every device global has the same value
534527
};
535528

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

src/acl_auto_configure.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -528,25 +528,26 @@ 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 =
534+
read_bool_counters(config_str, curr_pos, can_skip_programming, 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 = {
546548
dev_global_addr, dev_global_size,
547549
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};
550+
can_skip_programming, implement_in_csr, reset_on_reuse};
550551
bool ok =
551552
device_global_mem_defs.insert({device_global_name, dev_global_def})
552553
.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: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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,15 +286,15 @@ 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,
290+
kernel15_dev_global->second.can_skip_programming);
291291
CHECK_EQUAL(false, kernel15_dev_global->second.implement_in_csr);
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,
297+
kernel15_dev_global2->second.can_skip_programming);
298298
CHECK_EQUAL(true, kernel15_dev_global2->second.implement_in_csr);
299299

300300
// Check a second parsing.

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)