Skip to content

Commit 1892082

Browse files
committed
auto_configure: parse streaming kernel information
Signed-off-by: Peter Colberg <[email protected]>
1 parent 565aa18 commit 1892082

File tree

3 files changed

+295
-0
lines changed

3 files changed

+295
-0
lines changed

include/acl.h

Lines changed: 18 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_info_available;
180+
acl_streaming_kernel_arg_info streaming_info;
173181
} acl_kernel_arg_info_t;
174182

175183
// This struct must remain trivially copyable.
@@ -191,6 +199,13 @@ typedef struct {
191199
std::string format_string;
192200
} acl_printf_info_t;
193201

202+
struct acl_streaming_kernel_info {
203+
std::string start;
204+
std::string done;
205+
std::string stall_in;
206+
std::string stall_out;
207+
};
208+
194209
/* The definition of a single accelerator.
195210
* It can run a single kernel type.
196211
* We assume binary compilation only.
@@ -231,6 +246,9 @@ typedef struct {
231246
fast_launch_depth; /* How many kernels can be buffered on the device, 0
232247
means no buffering just one can execute*/
233248
unsigned int is_sycl_compile; /* [1] SYCL compile; [0] OpenCL compile*/
249+
250+
bool streaming_info_available;
251+
acl_streaming_kernel_info streaming_info;
234252
} acl_accel_def_t;
235253

236254
/* An ACL system definition.

src/acl_auto_configure.cpp

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

507+
static bool
508+
read_streaming_kernel_arg_info(const std::string &config_str,
509+
std::string::size_type &curr_pos,
510+
bool &streaming_info_available,
511+
acl_streaming_kernel_arg_info &streaming_info,
512+
std::vector<int> &counters) noexcept {
513+
int num_fields = 0;
514+
bool result = read_int_counters(config_str, curr_pos, num_fields, counters);
515+
counters.emplace_back(num_fields);
516+
517+
streaming_info_available = false;
518+
if (result && counters.back() > 0) {
519+
streaming_info_available = true;
520+
streaming_info = acl_streaming_kernel_arg_info{};
521+
result = read_string_counters(config_str, curr_pos,
522+
streaming_info.interface_name, counters);
523+
}
524+
525+
while (result && counters.back() > 0) {
526+
std::string tmp;
527+
result = read_string_counters(config_str, curr_pos, tmp, counters);
528+
}
529+
check_section_counters(counters);
530+
counters.pop_back();
531+
532+
return result;
533+
}
534+
507535
static bool read_kernel_args(const std::string &config_str,
508536
const bool kernel_arg_info_available,
509537
std::string::size_type &curr_pos,
@@ -597,6 +625,14 @@ static bool read_kernel_args(const std::string &config_str,
597625
type_name = "";
598626
}
599627

628+
bool streaming_info_available = false;
629+
acl_streaming_kernel_arg_info streaming_info;
630+
if (result && counters.back() > 0) {
631+
result = read_streaming_kernel_arg_info(config_str, curr_pos,
632+
streaming_info_available,
633+
streaming_info, counters);
634+
}
635+
600636
/*****************************************************************
601637
Since the introduction of autodiscovery forwards-compatibility,
602638
new entries for each kernel argument section start here.
@@ -619,6 +655,8 @@ static bool read_kernel_args(const std::string &config_str,
619655
args[j].host_accessible = host_accessible;
620656
args[j].pipe_channel_id = pipe_channel_id;
621657
args[j].buffer_location = buffer_location;
658+
args[j].streaming_info_available = streaming_info_available;
659+
args[j].streaming_info = streaming_info;
622660
}
623661
// forward compatibility: bypassing remaining fields at the end of
624662
// arguments section
@@ -635,6 +673,38 @@ static bool read_kernel_args(const std::string &config_str,
635673
return result;
636674
}
637675

676+
static bool read_streaming_kernel_info(
677+
const std::string &config_str, std::string::size_type &curr_pos,
678+
bool &streaming_info_available, acl_streaming_kernel_info &streaming_info,
679+
std::vector<int> &counters) noexcept {
680+
int num_fields = 0;
681+
bool result = read_int_counters(config_str, curr_pos, num_fields, counters);
682+
counters.emplace_back(num_fields);
683+
684+
streaming_info_available = false;
685+
if (result && counters.back() > 0) {
686+
streaming_info_available = true;
687+
streaming_info = acl_streaming_kernel_info{};
688+
result = read_string_counters(config_str, curr_pos, streaming_info.start,
689+
counters) &&
690+
read_string_counters(config_str, curr_pos, streaming_info.done,
691+
counters) &&
692+
read_string_counters(config_str, curr_pos, streaming_info.stall_in,
693+
counters) &&
694+
read_string_counters(config_str, curr_pos,
695+
streaming_info.stall_out, counters);
696+
}
697+
698+
while (result && counters.back() > 0) {
699+
std::string tmp;
700+
result = read_string_counters(config_str, curr_pos, tmp, counters);
701+
}
702+
check_section_counters(counters);
703+
counters.pop_back();
704+
705+
return result;
706+
}
707+
638708
static bool read_accel_defs(const std::string &config_str,
639709
std::string::size_type &curr_pos,
640710
const bool kernel_arg_info_available,
@@ -872,6 +942,12 @@ static bool read_accel_defs(const std::string &config_str,
872942
accel[i].is_sycl_compile, counters);
873943
}
874944

945+
if (result && counters.back() > 0) {
946+
result = read_streaming_kernel_info(config_str, curr_pos,
947+
accel[i].streaming_info_available,
948+
accel[i].streaming_info, counters);
949+
}
950+
875951
// forward compatibility: bypassing remaining fields at the end of kernel
876952
// description section
877953
while (result && counters.size() > 0 &&

test/acl_auto_configure_test.cpp

Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1227,3 +1227,204 @@ 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 107 _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 4 "
1240+
"k0_ZTS3CRCILi0EE_streaming_start k0_ZTS3CRCILi0EE_streaming_done "
1241+
"k0_ZTS3CRCILi0EE_streaming_stall_in "
1242+
"k0_ZTS3CRCILi0EE_streaming_stall_out"};
1243+
1244+
acl_device_def_autodiscovery_t devdef;
1245+
{
1246+
bool result;
1247+
std::string err_str;
1248+
ACL_LOCKED(result =
1249+
acl_load_device_def_from_str(config_str, devdef, err_str));
1250+
std::cerr << err_str;
1251+
CHECK(result);
1252+
}
1253+
1254+
CHECK_EQUAL(1, devdef.accel.size());
1255+
1256+
CHECK(!devdef.accel[0].is_sycl_compile);
1257+
CHECK(devdef.accel[0].streaming_info_available);
1258+
CHECK("k0_ZTS3CRCILi0EE_streaming_start" ==
1259+
devdef.accel[0].streaming_info.start);
1260+
CHECK("k0_ZTS3CRCILi0EE_streaming_done" ==
1261+
devdef.accel[0].streaming_info.done);
1262+
CHECK("k0_ZTS3CRCILi0EE_streaming_stall_in" ==
1263+
devdef.accel[0].streaming_info.stall_in);
1264+
CHECK("k0_ZTS3CRCILi0EE_streaming_stall_out" ==
1265+
devdef.accel[0].streaming_info.stall_out);
1266+
1267+
const auto &args = devdef.accel[0].iface.args;
1268+
CHECK_EQUAL(9, args.size());
1269+
1270+
CHECK(args[0].streaming_info_available);
1271+
CHECK("k0_ZTS3CRCILi0EE_arg0" == args[0].streaming_info.interface_name);
1272+
1273+
CHECK(args[1].streaming_info_available);
1274+
CHECK("k0_ZTS3CRCILi0EE_arg1" == args[1].streaming_info.interface_name);
1275+
1276+
CHECK(args[2].streaming_info_available);
1277+
CHECK("k0_ZTS3CRCILi0EE_arg2" == args[2].streaming_info.interface_name);
1278+
1279+
for (size_t i = 3; i < args.size(); ++i) {
1280+
CHECK(!args[i].streaming_info_available);
1281+
}
1282+
}
1283+
1284+
TEST(auto_configure, one_streaming_arg_and_streaming_kernel) {
1285+
const std::string config_str{
1286+
"23 27 531091a097f0d7096b21f349b4b283f9e206ebc0 pac_s10 0 1 17 DDR 2 4 "
1287+
"24 1 2 0 8589934592 8589934592 17179869184 17179869184 25769803776 "
1288+
"25769803776 34359738368 0 - 0 0 0 0 0 0 1 127 _ZTS15binomial_kernel 0 "
1289+
"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 "
1290+
"k0_ZTS15binomial_kernel_arg1 7 0 0 8 1 0 0 0 7 0 0 8 1 0 0 0 7 2 1 8 "
1291+
"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 "
1292+
"8196 65 8196 66 8196 67 8196 68 8196 69 8196 70 8196 71 8196 72 8196 73 "
1293+
"8196 74 8196 75 8196 76 8196 77 8196 78 8196 79 8196 1 1 1 3 1 1 1 3 1 "
1294+
"1 4 k0_ZTS15binomial_kernel_streaming_start "
1295+
"k0_ZTS15binomial_kernel_streaming_done "
1296+
"k0_ZTS15binomial_kernel_streaming_stall_in "
1297+
"k0_ZTS15binomial_kernel_streaming_stall_out"};
1298+
1299+
acl_device_def_autodiscovery_t devdef;
1300+
{
1301+
bool result;
1302+
std::string err_str;
1303+
ACL_LOCKED(result =
1304+
acl_load_device_def_from_str(config_str, devdef, err_str));
1305+
std::cerr << err_str;
1306+
CHECK(result);
1307+
}
1308+
1309+
CHECK_EQUAL(1, devdef.accel.size());
1310+
1311+
CHECK(devdef.accel[0].streaming_info_available);
1312+
CHECK("k0_ZTS15binomial_kernel_streaming_start" ==
1313+
devdef.accel[0].streaming_info.start);
1314+
CHECK("k0_ZTS15binomial_kernel_streaming_done" ==
1315+
devdef.accel[0].streaming_info.done);
1316+
CHECK("k0_ZTS15binomial_kernel_streaming_stall_in" ==
1317+
devdef.accel[0].streaming_info.stall_in);
1318+
CHECK("k0_ZTS15binomial_kernel_streaming_stall_out" ==
1319+
devdef.accel[0].streaming_info.stall_out);
1320+
1321+
const auto &args = devdef.accel[0].iface.args;
1322+
CHECK_EQUAL(8, args.size());
1323+
1324+
CHECK(!args[0].streaming_info_available);
1325+
1326+
CHECK(args[1].streaming_info_available);
1327+
CHECK("k0_ZTS15binomial_kernel_arg1" ==
1328+
args[1].streaming_info.interface_name);
1329+
1330+
for (size_t i = 2; i < args.size(); ++i) {
1331+
CHECK(!args[i].streaming_info_available);
1332+
}
1333+
}
1334+
1335+
TEST(auto_configure, two_streaming_args_and_streaming_kernel) {
1336+
const std::string config_str{
1337+
"23 27 531091a097f0d7096b21f349b4b283f9e206ebc0 pac_s10 0 1 17 DDR 2 4 "
1338+
"24 1 2 0 8589934592 8589934592 17179869184 17179869184 25769803776 "
1339+
"25769803776 34359738368 0 - 0 0 0 0 0 0 1 128 _ZTS15binomial_kernel 0 "
1340+
"256 0 0 0 0 0 1 0 8 8 2 1 8 1024 0 2 1 k0_ZTS15binomial_kernel_arg0 8 0 "
1341+
"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 "
1342+
"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 "
1343+
"0 16 2 64 8196 65 8196 66 8196 67 8196 68 8196 69 8196 70 8196 71 8196 "
1344+
"72 8196 73 8196 74 8196 75 8196 76 8196 77 8196 78 8196 79 8196 1 1 1 3 "
1345+
"1 1 1 3 1 1 4 k0_ZTS15binomial_kernel_streaming_start "
1346+
"k0_ZTS15binomial_kernel_streaming_done "
1347+
"k0_ZTS15binomial_kernel_streaming_stall_in "
1348+
"k0_ZTS15binomial_kernel_streaming_stall_out"};
1349+
1350+
acl_device_def_autodiscovery_t devdef;
1351+
{
1352+
bool result;
1353+
std::string err_str;
1354+
ACL_LOCKED(result =
1355+
acl_load_device_def_from_str(config_str, devdef, err_str));
1356+
std::cerr << err_str;
1357+
CHECK(result);
1358+
}
1359+
1360+
CHECK_EQUAL(1, devdef.accel.size());
1361+
1362+
CHECK(devdef.accel[0].is_sycl_compile);
1363+
CHECK(devdef.accel[0].streaming_info_available);
1364+
CHECK("k0_ZTS15binomial_kernel_streaming_start" ==
1365+
devdef.accel[0].streaming_info.start);
1366+
CHECK("k0_ZTS15binomial_kernel_streaming_done" ==
1367+
devdef.accel[0].streaming_info.done);
1368+
CHECK("k0_ZTS15binomial_kernel_streaming_stall_in" ==
1369+
devdef.accel[0].streaming_info.stall_in);
1370+
CHECK("k0_ZTS15binomial_kernel_streaming_stall_out" ==
1371+
devdef.accel[0].streaming_info.stall_out);
1372+
1373+
const auto &args = devdef.accel[0].iface.args;
1374+
CHECK_EQUAL(8, args.size());
1375+
1376+
CHECK(args[0].streaming_info_available);
1377+
CHECK("k0_ZTS15binomial_kernel_arg0" ==
1378+
args[0].streaming_info.interface_name);
1379+
1380+
CHECK(args[1].streaming_info_available);
1381+
CHECK("k0_ZTS15binomial_kernel_arg1" ==
1382+
args[1].streaming_info.interface_name);
1383+
1384+
for (size_t i = 2; i < args.size(); ++i) {
1385+
CHECK(!args[i].streaming_info_available);
1386+
}
1387+
}
1388+
1389+
TEST(auto_configure, two_streaming_args_and_non_streaming_kernel) {
1390+
const std::string config_str{
1391+
"23 27 531091a097f0d7096b21f349b4b283f9e206ebc0 pac_s10 0 1 17 DDR 2 4 "
1392+
"24 1 2 0 8589934592 8589934592 17179869184 17179869184 25769803776 "
1393+
"25769803776 34359738368 0 - 0 0 0 0 0 0 1 124 _ZTS15binomial_kernel 0 "
1394+
"256 0 0 0 0 0 1 0 8 8 2 1 8 1024 0 2 1 k0_ZTS15binomial_kernel_arg0 8 0 "
1395+
"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 "
1396+
"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 "
1397+
"0 16 2 64 8196 65 8196 66 8196 67 8196 68 8196 69 8196 70 8196 71 8196 "
1398+
"72 8196 73 8196 74 8196 75 8196 76 8196 77 8196 78 8196 79 8196 1 1 1 3 "
1399+
"1 1 1 3 1 1 0"};
1400+
1401+
acl_device_def_autodiscovery_t devdef;
1402+
{
1403+
bool result;
1404+
std::string err_str;
1405+
ACL_LOCKED(result =
1406+
acl_load_device_def_from_str(config_str, devdef, err_str));
1407+
std::cerr << err_str;
1408+
CHECK(result);
1409+
}
1410+
1411+
CHECK_EQUAL(1, devdef.accel.size());
1412+
1413+
CHECK(devdef.accel[0].is_sycl_compile);
1414+
CHECK(!devdef.accel[0].streaming_info_available);
1415+
1416+
const auto &args = devdef.accel[0].iface.args;
1417+
CHECK_EQUAL(8, args.size());
1418+
1419+
CHECK(args[0].streaming_info_available);
1420+
CHECK("k0_ZTS15binomial_kernel_arg0" ==
1421+
args[0].streaming_info.interface_name);
1422+
1423+
CHECK(args[1].streaming_info_available);
1424+
CHECK("k0_ZTS15binomial_kernel_arg1" ==
1425+
args[1].streaming_info.interface_name);
1426+
1427+
for (size_t i = 2; i < args.size(); ++i) {
1428+
CHECK(!args[i].streaming_info_available);
1429+
}
1430+
}

0 commit comments

Comments
 (0)