Skip to content

Commit 92a8371

Browse files
pcolbergsophimao
authored andcommitted
auto_configure: parse streaming kernel information
This parses new fields from the kernel section for streaming kernel control and from the kernel argument section for streaming kernels arguments, both for simulation of IP authoring components. The kernel section is augmented with a boolean field that specifies whether the kernel uses streaming control, i.e., whether the kernel is started using the streaming control start signal and queried for completion using the streaming control done signal via the simulator. The kernel argument section is augmented with a boolean field that specifies whether the kernel argument is a streaming argument, i.e., whether the argument is excluded from the kernel invocation image and directly streamed to the component via the simulator. If the kernel argument is streaming, a string field is added containing the full kernel argument name for the simulator. Signed-off-by: Peter Colberg <[email protected]>
1 parent 7f4bd98 commit 92a8371

File tree

3 files changed

+224
-0
lines changed

3 files changed

+224
-0
lines changed

include/acl.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,11 @@ typedef enum {
136136
} acl_kernel_arg_access_qualifier_t; // this is defaulted to none, for non-pipe
137137
// and non-image args.
138138

139+
struct acl_streaming_kernel_arg_info {
140+
// name of the streaming interface at device image boundary
141+
std::string interface_name;
142+
};
143+
139144
// This defines everything "interface" of a kernel argument.
140145
// Be sure to keep this consistent with l_kernel_interface_match() in
141146
// acl_kernel.cpp. This struct must remain trivially copyable.
@@ -170,6 +175,9 @@ typedef struct {
170175
// allowed, e.g., "struct mystruct"
171176
std::string type_name;
172177
std::string name;
178+
179+
bool streaming_arg_info_available;
180+
acl_streaming_kernel_arg_info streaming_arg_info;
173181
} acl_kernel_arg_info_t;
174182

175183
// This struct must remain trivially copyable.
@@ -231,6 +239,8 @@ typedef struct {
231239
fast_launch_depth; /* How many kernels can be buffered on the device, 0
232240
means no buffering just one can execute*/
233241
unsigned int is_sycl_compile; /* [1] SYCL compile; [0] OpenCL compile*/
242+
243+
bool streaming_control_info_available;
234244
} acl_accel_def_t;
235245

236246
/* An ACL system definition.

src/acl_auto_configure.cpp

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,24 @@ static bool read_device_global_mem_defs(
504504
return result;
505505
}
506506

507+
static bool read_streaming_kernel_arg_info(
508+
const std::string &config_str, std::string::size_type &curr_pos,
509+
bool &streaming_arg_info_available,
510+
acl_streaming_kernel_arg_info &streaming_arg_info,
511+
std::vector<int> &counters) noexcept {
512+
unsigned int value = 0;
513+
bool result = read_uint_counters(config_str, curr_pos, value, counters);
514+
streaming_arg_info_available = value;
515+
516+
if (result && streaming_arg_info_available) {
517+
streaming_arg_info = acl_streaming_kernel_arg_info{};
518+
result = read_string_counters(config_str, curr_pos,
519+
streaming_arg_info.interface_name, counters);
520+
}
521+
522+
return result;
523+
}
524+
507525
static bool read_kernel_args(const std::string &config_str,
508526
const bool kernel_arg_info_available,
509527
std::string::size_type &curr_pos,
@@ -597,6 +615,14 @@ static bool read_kernel_args(const std::string &config_str,
597615
type_name = "";
598616
}
599617

618+
bool streaming_arg_info_available = false;
619+
acl_streaming_kernel_arg_info streaming_arg_info;
620+
if (result && counters.back() > 0) {
621+
result = read_streaming_kernel_arg_info(config_str, curr_pos,
622+
streaming_arg_info_available,
623+
streaming_arg_info, counters);
624+
}
625+
600626
/*****************************************************************
601627
Since the introduction of autodiscovery forwards-compatibility,
602628
new entries for each kernel argument section start here.
@@ -619,6 +645,8 @@ static bool read_kernel_args(const std::string &config_str,
619645
args[j].host_accessible = host_accessible;
620646
args[j].pipe_channel_id = pipe_channel_id;
621647
args[j].buffer_location = buffer_location;
648+
args[j].streaming_arg_info_available = streaming_arg_info_available;
649+
args[j].streaming_arg_info = streaming_arg_info;
622650
}
623651
// forward compatibility: bypassing remaining fields at the end of
624652
// arguments section
@@ -635,6 +663,18 @@ static bool read_kernel_args(const std::string &config_str,
635663
return result;
636664
}
637665

666+
static bool
667+
read_streaming_kernel_control_info(const std::string &config_str,
668+
std::string::size_type &curr_pos,
669+
bool &streaming_control_info_available,
670+
std::vector<int> &counters) noexcept {
671+
unsigned int value = 0;
672+
bool result = read_uint_counters(config_str, curr_pos, value, counters);
673+
streaming_control_info_available = value;
674+
675+
return result;
676+
}
677+
638678
static bool read_accel_defs(const std::string &config_str,
639679
std::string::size_type &curr_pos,
640680
const bool kernel_arg_info_available,
@@ -872,6 +912,12 @@ static bool read_accel_defs(const std::string &config_str,
872912
accel[i].is_sycl_compile, counters);
873913
}
874914

915+
if (result && counters.back() > 0) {
916+
result = read_streaming_kernel_control_info(
917+
config_str, curr_pos, accel[i].streaming_control_info_available,
918+
counters);
919+
}
920+
875921
// forward compatibility: bypassing remaining fields at the end of kernel
876922
// description section
877923
while (result && counters.size() > 0 &&

test/acl_auto_configure_test.cpp

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1227,3 +1227,171 @@ TEST(auto_configure, hostpipe) {
12271227
CHECK_EQUAL(1, (int)device_def.autodiscovery_def.hal_info.size());
12281228
}
12291229
}
1230+
1231+
TEST(auto_configure, streaming) {
1232+
const std::string config_str{
1233+
"23 26 " RANDOM_HASH
1234+
" 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 103 _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 "
1237+
"k0_ZTS3CRCILi0EE_arg1 8 0 0 8 1 0 0 1 k0_ZTS3CRCILi0EE_arg2 7 0 0 8 1 0 "
1238+
"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 "
1239+
"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"};
1240+
1241+
acl_device_def_autodiscovery_t devdef;
1242+
{
1243+
bool result;
1244+
std::string err_str;
1245+
ACL_LOCKED(result =
1246+
acl_load_device_def_from_str(config_str, devdef, err_str));
1247+
std::cerr << err_str;
1248+
CHECK(result);
1249+
}
1250+
1251+
CHECK_EQUAL(1, devdef.accel.size());
1252+
1253+
CHECK(!devdef.accel[0].is_sycl_compile);
1254+
CHECK(devdef.accel[0].streaming_control_info_available);
1255+
1256+
const auto &args = devdef.accel[0].iface.args;
1257+
CHECK_EQUAL(9, args.size());
1258+
1259+
CHECK(args[0].streaming_arg_info_available);
1260+
CHECK("k0_ZTS3CRCILi0EE_arg0" == args[0].streaming_arg_info.interface_name);
1261+
1262+
CHECK(args[1].streaming_arg_info_available);
1263+
CHECK("k0_ZTS3CRCILi0EE_arg1" == args[1].streaming_arg_info.interface_name);
1264+
1265+
CHECK(args[2].streaming_arg_info_available);
1266+
CHECK("k0_ZTS3CRCILi0EE_arg2" == args[2].streaming_arg_info.interface_name);
1267+
1268+
for (size_t i = 3; i < args.size(); ++i) {
1269+
CHECK(!args[i].streaming_arg_info_available);
1270+
}
1271+
}
1272+
1273+
TEST(auto_configure, one_streaming_arg_and_streaming_kernel) {
1274+
const std::string config_str{
1275+
"23 27 531091a097f0d7096b21f349b4b283f9e206ebc0 pac_s10 0 1 17 DDR 2 4 "
1276+
"24 1 2 0 8589934592 8589934592 17179869184 17179869184 25769803776 "
1277+
"25769803776 34359738368 0 - 0 0 0 0 0 0 1 123 _ZTS15binomial_kernel 0 "
1278+
"256 0 0 0 0 0 1 0 8 7 2 1 8 1024 0 2 0 8 0 0 8 1 0 0 1 "
1279+
"k0_ZTS15binomial_kernel_arg1 7 0 0 8 1 0 0 0 7 0 0 8 1 0 0 0 7 2 1 8 "
1280+
"1024 0 2 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 0 0 16 2 64 "
1281+
"8196 65 8196 66 8196 67 8196 68 8196 69 8196 70 8196 71 8196 72 8196 73 "
1282+
"8196 74 8196 75 8196 76 8196 77 8196 78 8196 79 8196 1 1 1 3 1 1 1 3 1 "
1283+
"1 1"};
1284+
1285+
acl_device_def_autodiscovery_t devdef;
1286+
{
1287+
bool result;
1288+
std::string err_str;
1289+
ACL_LOCKED(result =
1290+
acl_load_device_def_from_str(config_str, devdef, err_str));
1291+
std::cerr << err_str;
1292+
CHECK(result);
1293+
}
1294+
1295+
CHECK_EQUAL(1, devdef.accel.size());
1296+
1297+
CHECK(devdef.accel[0].streaming_control_info_available);
1298+
1299+
const auto &args = devdef.accel[0].iface.args;
1300+
CHECK_EQUAL(8, args.size());
1301+
1302+
CHECK(!args[0].streaming_arg_info_available);
1303+
1304+
CHECK(args[1].streaming_arg_info_available);
1305+
CHECK("k0_ZTS15binomial_kernel_arg1" ==
1306+
args[1].streaming_arg_info.interface_name);
1307+
1308+
for (size_t i = 2; i < args.size(); ++i) {
1309+
CHECK(!args[i].streaming_arg_info_available);
1310+
}
1311+
}
1312+
1313+
TEST(auto_configure, two_streaming_args_and_streaming_kernel) {
1314+
const std::string config_str{
1315+
"23 27 531091a097f0d7096b21f349b4b283f9e206ebc0 pac_s10 0 1 17 DDR 2 4 "
1316+
"24 1 2 0 8589934592 8589934592 17179869184 17179869184 25769803776 "
1317+
"25769803776 34359738368 0 - 0 0 0 0 0 0 1 124 _ZTS15binomial_kernel 0 "
1318+
"256 0 0 0 0 0 1 0 8 8 2 1 8 1024 0 2 1 k0_ZTS15binomial_kernel_arg0 8 0 "
1319+
"0 8 1 0 0 1 k0_ZTS15binomial_kernel_arg1 7 0 0 8 1 0 0 0 7 0 0 8 1 0 0 "
1320+
"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 7 0 0 8 1 0 0 0 0 "
1321+
"0 16 2 64 8196 65 8196 66 8196 67 8196 68 8196 69 8196 70 8196 71 8196 "
1322+
"72 8196 73 8196 74 8196 75 8196 76 8196 77 8196 78 8196 79 8196 1 1 1 3 "
1323+
"1 1 1 3 1 1 1"};
1324+
1325+
acl_device_def_autodiscovery_t devdef;
1326+
{
1327+
bool result;
1328+
std::string err_str;
1329+
ACL_LOCKED(result =
1330+
acl_load_device_def_from_str(config_str, devdef, err_str));
1331+
std::cerr << err_str;
1332+
CHECK(result);
1333+
}
1334+
1335+
CHECK_EQUAL(1, devdef.accel.size());
1336+
1337+
CHECK(devdef.accel[0].is_sycl_compile);
1338+
CHECK(devdef.accel[0].streaming_control_info_available);
1339+
1340+
const auto &args = devdef.accel[0].iface.args;
1341+
CHECK_EQUAL(8, args.size());
1342+
1343+
CHECK(args[0].streaming_arg_info_available);
1344+
CHECK("k0_ZTS15binomial_kernel_arg0" ==
1345+
args[0].streaming_arg_info.interface_name);
1346+
1347+
CHECK(args[1].streaming_arg_info_available);
1348+
CHECK("k0_ZTS15binomial_kernel_arg1" ==
1349+
args[1].streaming_arg_info.interface_name);
1350+
1351+
for (size_t i = 2; i < args.size(); ++i) {
1352+
CHECK(!args[i].streaming_arg_info_available);
1353+
}
1354+
}
1355+
1356+
TEST(auto_configure, two_streaming_args_and_non_streaming_kernel) {
1357+
const std::string config_str{
1358+
"23 27 531091a097f0d7096b21f349b4b283f9e206ebc0 pac_s10 0 1 17 DDR 2 4 "
1359+
"24 1 2 0 8589934592 8589934592 17179869184 17179869184 25769803776 "
1360+
"25769803776 34359738368 0 - 0 0 0 0 0 0 1 124 _ZTS15binomial_kernel 0 "
1361+
"256 0 0 0 0 0 1 0 8 8 2 1 8 1024 0 2 1 k0_ZTS15binomial_kernel_arg0 8 0 "
1362+
"0 8 1 0 0 1 k0_ZTS15binomial_kernel_arg1 7 0 0 8 1 0 0 0 7 0 0 8 1 0 0 "
1363+
"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 7 0 0 8 1 0 0 0 0 "
1364+
"0 16 2 64 8196 65 8196 66 8196 67 8196 68 8196 69 8196 70 8196 71 8196 "
1365+
"72 8196 73 8196 74 8196 75 8196 76 8196 77 8196 78 8196 79 8196 1 1 1 3 "
1366+
"1 1 1 3 1 1 0"};
1367+
1368+
acl_device_def_autodiscovery_t devdef;
1369+
{
1370+
bool result;
1371+
std::string err_str;
1372+
ACL_LOCKED(result =
1373+
acl_load_device_def_from_str(config_str, devdef, err_str));
1374+
std::cerr << err_str;
1375+
CHECK(result);
1376+
}
1377+
1378+
CHECK_EQUAL(1, devdef.accel.size());
1379+
1380+
CHECK(devdef.accel[0].is_sycl_compile);
1381+
CHECK(!devdef.accel[0].streaming_control_info_available);
1382+
1383+
const auto &args = devdef.accel[0].iface.args;
1384+
CHECK_EQUAL(8, args.size());
1385+
1386+
CHECK(args[0].streaming_arg_info_available);
1387+
CHECK("k0_ZTS15binomial_kernel_arg0" ==
1388+
args[0].streaming_arg_info.interface_name);
1389+
1390+
CHECK(args[1].streaming_arg_info_available);
1391+
CHECK("k0_ZTS15binomial_kernel_arg1" ==
1392+
args[1].streaming_arg_info.interface_name);
1393+
1394+
for (size_t i = 2; i < args.size(); ++i) {
1395+
CHECK(!args[i].streaming_arg_info_available);
1396+
}
1397+
}

0 commit comments

Comments
 (0)