Skip to content

Pass streaming control signal names to simulator #145

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions include/acl.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,12 @@ typedef struct {
std::string format_string;
} acl_printf_info_t;

// Signal names for streaming control kernel.
struct acl_streaming_kernel_control_info {
std::string start;
std::string done;
};

/* The definition of a single accelerator.
* It can run a single kernel type.
* We assume binary compilation only.
Expand Down Expand Up @@ -241,6 +247,7 @@ typedef struct {
unsigned int is_sycl_compile; /* [1] SYCL compile; [0] OpenCL compile*/

bool streaming_control_info_available;
acl_streaming_kernel_control_info streaming_control_info;
} acl_accel_def_t;

/* An ACL system definition.
Expand Down
4 changes: 2 additions & 2 deletions include/acl_hal.h
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,9 @@ typedef struct {
mem_properties_t *properties, int *error);

void (*simulation_streaming_kernel_start)(unsigned int physical_device_id,
const std::string &kernel_name);
const std::string &signal_name);
void (*simulation_streaming_kernel_done)(unsigned int physical_device_id,
const std::string &kernel_name,
const std::string &signal_name,
unsigned int &finish_counter);
} acl_hal_t;

Expand Down
4 changes: 2 additions & 2 deletions include/acl_hal_mmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ typedef struct {

// Submits streaming kernel control start signal to simulator.
void (*aocl_mmd_simulation_streaming_kernel_start)(
int handle, const std::string &kernel_name);
int handle, const std::string &signal_name);

// Queries streaming kernel control done signal from simulator.
// Returns non-negative number of finished kernels invocations.
Expand All @@ -148,7 +148,7 @@ typedef struct {
// invocations that finish *while* this function is invoked are properly
// accounted and returned in a subsequent invocation of this function.
void (*aocl_mmd_simulation_streaming_kernel_done)(
int handle, const std::string &kernel_name, unsigned int &finish_counter);
int handle, const std::string &signal_name, unsigned int &finish_counter);
} acl_mmd_dispatch_t;

typedef struct {
Expand Down
3 changes: 2 additions & 1 deletion include/acl_kernel_if.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ typedef struct {
acl_kernel_if_addr_range *accel_perf_mon;
unsigned int *accel_num_printfs;

std::vector<std::optional<std::string>> streaming_control_kernel_names;
std::vector<std::optional<acl_streaming_kernel_control_info>>
streaming_control_signal_names;

// Track potential hangs
time_ns last_kern_update;
Expand Down
20 changes: 14 additions & 6 deletions src/acl_auto_configure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -663,15 +663,23 @@ static bool read_kernel_args(const std::string &config_str,
return result;
}

static bool
read_streaming_kernel_control_info(const std::string &config_str,
std::string::size_type &curr_pos,
bool &streaming_control_info_available,
std::vector<int> &counters) noexcept {
static bool read_streaming_kernel_control_info(
const std::string &config_str, std::string::size_type &curr_pos,
bool &streaming_control_info_available,
acl_streaming_kernel_control_info &streaming_control_info,
std::vector<int> &counters) noexcept {
unsigned int value = 0;
bool result = read_uint_counters(config_str, curr_pos, value, counters);
streaming_control_info_available = value;

if (result && streaming_control_info_available) {
streaming_control_info = acl_streaming_kernel_control_info{};
result = read_string_counters(config_str, curr_pos,
streaming_control_info.start, counters);
result = read_string_counters(config_str, curr_pos,
streaming_control_info.done, counters);
}

return result;
}

Expand Down Expand Up @@ -915,7 +923,7 @@ static bool read_accel_defs(const std::string &config_str,
if (result && counters.back() > 0) {
result = read_streaming_kernel_control_info(
config_str, curr_pos, accel[i].streaming_control_info_available,
counters);
accel[i].streaming_control_info, counters);
}

// forward compatibility: bypassing remaining fields at the end of kernel
Expand Down
20 changes: 10 additions & 10 deletions src/acl_kernel_if.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -949,14 +949,14 @@ int acl_kernel_if_update(const acl_device_def_autodiscovery_t &devdef,
}
}

kern->streaming_control_kernel_names.clear();
kern->streaming_control_kernel_names.reserve(devdef.accel.size());
kern->streaming_control_signal_names.clear();
kern->streaming_control_signal_names.reserve(devdef.accel.size());
for (const auto &accel : devdef.accel) {
std::optional<std::string> kernel_name;
std::optional<acl_streaming_kernel_control_info> signal_names;
if (accel.streaming_control_info_available) {
kernel_name = accel.iface.name;
signal_names = accel.streaming_control_info;
}
kern->streaming_control_kernel_names.emplace_back(kernel_name);
kern->streaming_control_signal_names.emplace_back(signal_names);
}
}

Expand Down Expand Up @@ -1266,10 +1266,10 @@ void acl_kernel_if_launch_kernel_on_custom_sof(
}
kern->accel_queue_front[accel_id] = next_launch_index;

if (kern->streaming_control_kernel_names[accel_id]) {
if (kern->streaming_control_signal_names[accel_id]) {
acl_get_hal()->simulation_streaming_kernel_start(
kern->physical_device_id,
*kern->streaming_control_kernel_names[accel_id]);
kern->streaming_control_signal_names[accel_id]->start);
return;
}

Expand Down Expand Up @@ -1510,10 +1510,10 @@ void acl_kernel_if_update_status(acl_kernel_if *kern) {
unsigned int finish_counter = 0;
unsigned int printf_size = 0;

if (kern->streaming_control_kernel_names[accel_id]) {
if (kern->streaming_control_signal_names[accel_id]) {
acl_get_hal()->simulation_streaming_kernel_done(
kern->physical_device_id,
*kern->streaming_control_kernel_names[accel_id], finish_counter);
kern->streaming_control_signal_names[accel_id]->done, finish_counter);
} else {
acl_kernel_if_update_status_query(kern, accel_id, activation_id,
finish_counter, printf_size);
Expand All @@ -1531,7 +1531,7 @@ void acl_kernel_if_update_status(acl_kernel_if *kern) {
// Tell the host library this job is done
kern->accel_job_ids[accel_id][next_queue_back] = -1;

if (!kern->streaming_control_kernel_names[accel_id]) {
if (!kern->streaming_control_signal_names[accel_id]) {
acl_kernel_if_update_status_finish(kern, accel_id, activation_id,
printf_size);
}
Expand Down
27 changes: 21 additions & 6 deletions test/acl_auto_configure_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1232,11 +1232,12 @@ TEST(auto_configure, streaming) {
const std::string config_str{
"23 26 " RANDOM_HASH
" pac_a10 0 1 13 DDR 2 2 24 1 2 0 4294967296 4294967296 8589934592 0 - 0 "
"0 0 0 1 3 device_global_name 256 128 1 103 _ZTS3CRCILi0EE 0 256 1 0 0 1 "
"0 0 0 1 3 device_global_name 256 128 1 105 _ZTS3CRCILi0EE 0 256 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 1 "
"k0_ZTS3CRCILi0EE_arg1 8 0 0 8 1 0 0 1 k0_ZTS3CRCILi0EE_arg2 7 0 0 8 1 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 0 "
"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"};
"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 "
"k0_ZTS3CRCILi0EE_streaming_start k0_ZTS3CRCILi0EE_streaming_done "};

acl_device_def_autodiscovery_t devdef;
{
Expand All @@ -1252,6 +1253,10 @@ TEST(auto_configure, streaming) {

CHECK(!devdef.accel[0].is_sycl_compile);
CHECK(devdef.accel[0].streaming_control_info_available);
CHECK("k0_ZTS3CRCILi0EE_streaming_start" ==
devdef.accel[0].streaming_control_info.start);
CHECK("k0_ZTS3CRCILi0EE_streaming_done" ==
devdef.accel[0].streaming_control_info.done);

const auto &args = devdef.accel[0].iface.args;
CHECK_EQUAL(9, args.size());
Expand All @@ -1274,13 +1279,14 @@ TEST(auto_configure, one_streaming_arg_and_streaming_kernel) {
const std::string config_str{
"23 27 531091a097f0d7096b21f349b4b283f9e206ebc0 pac_s10 0 1 17 DDR 2 4 "
"24 1 2 0 8589934592 8589934592 17179869184 17179869184 25769803776 "
"25769803776 34359738368 0 - 0 0 0 0 0 0 1 123 _ZTS15binomial_kernel 0 "
"25769803776 34359738368 0 - 0 0 0 0 0 0 1 125 _ZTS15binomial_kernel 0 "
"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 "
"k0_ZTS15binomial_kernel_arg1 7 0 0 8 1 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 0 7 0 0 8 1 0 0 0 0 0 16 2 64 "
"8196 65 8196 66 8196 67 8196 68 8196 69 8196 70 8196 71 8196 72 8196 73 "
"8196 74 8196 75 8196 76 8196 77 8196 78 8196 79 8196 1 1 1 3 1 1 1 3 1 "
"1 1"};
"1 1 k0_ZTS15binomial_kernel_streaming_start "
"k0_ZTS15binomial_kernel_streaming_done "};

acl_device_def_autodiscovery_t devdef;
{
Expand All @@ -1295,6 +1301,10 @@ TEST(auto_configure, one_streaming_arg_and_streaming_kernel) {
CHECK_EQUAL(1, devdef.accel.size());

CHECK(devdef.accel[0].streaming_control_info_available);
CHECK("k0_ZTS15binomial_kernel_streaming_start" ==
devdef.accel[0].streaming_control_info.start);
CHECK("k0_ZTS15binomial_kernel_streaming_done" ==
devdef.accel[0].streaming_control_info.done);

const auto &args = devdef.accel[0].iface.args;
CHECK_EQUAL(8, args.size());
Expand All @@ -1314,13 +1324,14 @@ TEST(auto_configure, two_streaming_args_and_streaming_kernel) {
const std::string config_str{
"23 27 531091a097f0d7096b21f349b4b283f9e206ebc0 pac_s10 0 1 17 DDR 2 4 "
"24 1 2 0 8589934592 8589934592 17179869184 17179869184 25769803776 "
"25769803776 34359738368 0 - 0 0 0 0 0 0 1 124 _ZTS15binomial_kernel 0 "
"25769803776 34359738368 0 - 0 0 0 0 0 0 1 126 _ZTS15binomial_kernel 0 "
"256 0 0 0 0 0 1 0 8 8 2 1 8 1024 0 2 1 k0_ZTS15binomial_kernel_arg0 8 0 "
"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 "
"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 "
"0 16 2 64 8196 65 8196 66 8196 67 8196 68 8196 69 8196 70 8196 71 8196 "
"72 8196 73 8196 74 8196 75 8196 76 8196 77 8196 78 8196 79 8196 1 1 1 3 "
"1 1 1 3 1 1 1"};
"1 1 1 3 1 1 1 k0_ZTS15binomial_kernel_streaming_start "
"k0_ZTS15binomial_kernel_streaming_done "};

acl_device_def_autodiscovery_t devdef;
{
Expand All @@ -1336,6 +1347,10 @@ TEST(auto_configure, two_streaming_args_and_streaming_kernel) {

CHECK(devdef.accel[0].is_sycl_compile);
CHECK(devdef.accel[0].streaming_control_info_available);
CHECK("k0_ZTS15binomial_kernel_streaming_start" ==
devdef.accel[0].streaming_control_info.start);
CHECK("k0_ZTS15binomial_kernel_streaming_done" ==
devdef.accel[0].streaming_control_info.done);

const auto &args = devdef.accel[0].iface.args;
CHECK_EQUAL(8, args.size());
Expand Down