Skip to content

Commit e4e5b10

Browse files
committed
Support arbitary BL for accessor
1 parent 0f1ec3a commit e4e5b10

File tree

5 files changed

+106
-0
lines changed

5 files changed

+106
-0
lines changed

include/acl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,8 @@ typedef struct {
381381

382382
return result;
383383
}
384+
385+
std::string id = "-";
384386
} acl_system_global_mem_def_t;
385387

386388
// Our allocator is optimized for simplicity, and for the case where there

src/acl_auto_configure.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,8 @@ read_global_mem_defs(const std::string &config_str,
278278

279279
for (auto i = 0U; result && (i < num_global_mem_systems); i++) {
280280
std::string gmem_name;
281+
std::string gmem_id = "-"; // This should be the default value even if the
282+
// auto-discovery string doesn't have this field.
281283
// read total number of fields in global_memories
282284
int total_fields_global_memories = 0;
283285
result = read_int_counters(config_str, curr_pos,
@@ -403,6 +405,12 @@ read_global_mem_defs(const std::string &config_str,
403405
can_access.push_back(temp);
404406
}
405407
}
408+
409+
// read global memory id field. If it doesn't exist, then the value is "-"
410+
// It's a new field introduced from 2024.2
411+
if (result && counters.back() > 0) {
412+
result = read_string_counters(config_str, curr_pos, gmem_id, counters);
413+
}
406414
}
407415

408416
if (result) {
@@ -428,6 +436,7 @@ read_global_mem_defs(const std::string &config_str,
428436
global_mem_defs[i].allocation_type = allocation_type;
429437
global_mem_defs[i].primary_interface = primary_interface;
430438
global_mem_defs[i].can_access_list = can_access;
439+
global_mem_defs[i].id = gmem_id;
431440
}
432441

433442
// forward compatibility: bypassing remaining fields at the end of global

src/acl_mem.cpp

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,64 @@ CL_API_ENTRY cl_mem clCreateBufferWithPropertiesINTEL(
437437
} break;
438438
case CL_MEM_ALLOC_BUFFER_LOCATION_INTEL: {
439439
tmp_mem_id = (cl_uint) * (properties + 1);
440+
441+
// In FullSystem flow, buffer location is always the index of the global
442+
// memories. Therefore, there is no additional handling needed for FS.
443+
444+
// However, in SYCL_HLS(IPA) flow, the user passed buffer_location<id>
445+
// maps to the global memory with the same id. Runtime needs to find the
446+
// correct index of the global memory with that id. The id filed is
447+
// introduced in 2024.2 in auto-discovery string. This change is for
448+
// accessor only and the USM buffer location change is done in the
449+
// simulator.
450+
451+
// Runtime needs to determine whether it's FS or SYCL_HLS first by
452+
// checking if the global memory id exist or not. If exists, then it's
453+
// SYCL_HLS flow.
454+
bool is_SYCL_HLS = false;
455+
456+
// We document the limitation here:
457+
// https://www.intel.com/content/www/us/en/docs/oneapi-fpga-add-on/
458+
// developer-guide/2024-0/targeting-multiple-homogeneous-fpga-devices.html
459+
// All FPGA devices used must be of the same FPGA card (same -Xstarget
460+
// target). There might be some workaround supporting multi-device with
461+
// different boards but they are for FS, not for SYCL_HLS.
462+
463+
// Therefore, we can safely assume all devices have the same
464+
// global_mem_defs in SYCL_HLS flow as of 2024.2. So we can just check
465+
// acl_platform.device[0].
466+
467+
auto global_mem_defs =
468+
acl_platform.device[0].def.autodiscovery_def.global_mem_defs;
469+
470+
for (const auto &global_mem_def : global_mem_defs) {
471+
if (global_mem_def.id != "-") {
472+
is_SYCL_HLS = true;
473+
break;
474+
}
475+
}
476+
477+
if (is_SYCL_HLS) {
478+
// find the correct index in the global memory
479+
long index = -1;
480+
for (auto it = begin(global_mem_defs); it != end(global_mem_defs);
481+
++it) {
482+
if (stoul(it->id) == tmp_mem_id) {
483+
index = it - global_mem_defs.begin();
484+
break;
485+
}
486+
}
487+
488+
if (index == -1) {
489+
BAIL_INFO(CL_INVALID_VALUE, context,
490+
"Invalid Buffer Location id provided");
491+
}
492+
493+
// Update the tmp_mem_id to the corect index in the global memories
494+
// vector.
495+
tmp_mem_id = static_cast<cl_uint>(index);
496+
}
497+
440498
} break;
441499
default: {
442500
BAIL_INFO(CL_INVALID_DEVICE, context, "Invalid properties");

src/acl_program.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2125,6 +2125,7 @@ l_device_memory_definition_copy(acl_device_def_autodiscovery_t *dest_dev,
21252125
src_dev->global_mem_defs[idef].primary_interface;
21262126
dest_dev->global_mem_defs[idef].can_access_list =
21272127
src_dev->global_mem_defs[idef].can_access_list;
2128+
dest_dev->global_mem_defs[idef].id = src_dev->global_mem_defs[idef].id;
21282129
}
21292130
}
21302131

test/acl_auto_configure_test.cpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1672,3 +1672,39 @@ TEST(auto_configure, sideband_mappings) {
16721672
CHECK(devdef.sideband_signal_mappings[7].port_offset == 352);
16731673
CHECK(devdef.sideband_signal_mappings[7].sideband_size == 32);
16741674
}
1675+
1676+
TEST(auto_configure, global_mem_id) {
1677+
const std::string config_str{
1678+
"23 46 " RANDOM_HASH " custom_ipa 0 3 "
1679+
" 10 1 2 1 2 2199023255552 2233382993920 4 - 0 1" // Global memory 1
1680+
" 10 3 2 1 2 6597069766656 6631429505024 4 - 0 3" // Global memory 2
1681+
" 10 5 2 1 2 10995116277760 11029476016128 4 - 0 5" // Global memory 3
1682+
" 0 0 0 0 0 1 0 0"
1683+
" 0 2 133 _ZTS10SimpleVAddIiE 0 256 1 0 0 1 0 1 0 13 8 2 1 8"
1684+
" 1 1 5 0 0 7 0 0 8 1 0 0 0 7 0 0 8 1 0 0 0 7 0 0 8 1 0 0 0 8"
1685+
" 2 1 8 1 1 3 0 0 7 0 0 8 1 0 0 0 7 0 0 8 1 0 0 0 7 0 0 8 1 0"
1686+
" 0 0 8 2 1 8 1 1 1 0 0 7 0 0 8 1 0 0 0 7 0 0 8 1 0 0 0 7 0 0"
1687+
" 8 1 0 0 0 7 0 0 4 1 0 0 0 0 0 0 0 1 1 1 3 1 1 1 0 1 1 0 133 "
1688+
" _ZTS10SimpleVAddIfE 256 256 1 0 0 1 0 1 0 13 8 2 1 8 1 1 5 0"
1689+
" 0 7 0 0 8 1 0 0 0 7 0 0 8 1 0 0 0 7 0 0 8 1 0 0 0 8 2 1 8 1 1"
1690+
" 3 0 0 7 0 0 8 1 0 0 0 7 0 0 8 1 0 0 0 7 0 0 8 1 0 0 0 8 2 1 8"
1691+
" 1 1 1 0 0 7 0 0 8 1 0 0 0 7 0 0 8 1 0 0 0 7 0 0 8 1 0 0 0 7 0"
1692+
" 0 4 1 0 0 0 0 0 0 0 1 1 1 3 1 1 1 0 1 1 0"};
1693+
1694+
acl_device_def_autodiscovery_t devdef;
1695+
{
1696+
bool result;
1697+
std::string err_str;
1698+
ACL_LOCKED(result =
1699+
acl_load_device_def_from_str(config_str, devdef, err_str));
1700+
std::cerr << err_str;
1701+
CHECK(result);
1702+
}
1703+
1704+
CHECK("1" == devdef.global_mem_defs[0].name);
1705+
CHECK("1" == devdef.global_mem_defs[0].id);
1706+
CHECK("3" == devdef.global_mem_defs[1].name);
1707+
CHECK("3" == devdef.global_mem_defs[1].id);
1708+
CHECK("5" == devdef.global_mem_defs[2].name);
1709+
CHECK("5" == devdef.global_mem_defs[2].id);
1710+
}

0 commit comments

Comments
 (0)