Skip to content

Commit 569e7bd

Browse files
committed
Adding support for Hostpipe sideband signals
1 parent 29bf7b7 commit 569e7bd

File tree

9 files changed

+652
-40
lines changed

9 files changed

+652
-40
lines changed

include/acl.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,25 @@ struct acl_hostpipe_mapping {
544544
// avalon_mm = 2, avalon_mm_uses_ready = 3
545545
};
546546

547+
// Mapping of sideband signals to logical pipe
548+
549+
struct acl_sideband_signal_mapping {
550+
std::string logical_name;
551+
unsigned port_identifier;
552+
unsigned port_offset; // bit
553+
unsigned sideband_size; // bit
554+
};
555+
556+
// Must match the definition in the compiler
557+
// Analysis/FPGAAnalysis/Utils/StreamParameters.h
558+
enum signal_type {
559+
SignalUnknown = -1,
560+
AvalonData = 0,
561+
AvalonSop = 1,
562+
AvalonEop = 2,
563+
AvalonEmpty = 3
564+
};
565+
547566
// Part of acl_device_def_t where members are populated from the information
548567
// in the autodiscovery string. This will get updated every time the device
549568
// is programmed with a new device binary as the new binary would contain a
@@ -570,6 +589,7 @@ typedef struct acl_device_def_autodiscovery_t {
570589
true; // Set the default value to true for backwards compatibility flows.
571590

572591
std::vector<acl_hostpipe_mapping> hostpipe_mappings;
592+
std::vector<acl_sideband_signal_mapping> sideband_signal_mappings;
573593
} acl_device_def_autodiscovery_t;
574594

575595
typedef struct acl_device_def_t {

include/acl_hal.h

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,42 @@ typedef struct {
265265
unsigned int physical_device_id, const char *interface_name,
266266
const void *host_addr, size_t dev_addr, size_t size);
267267

268+
/// Simulation only mmd call as of 2024.1
269+
/// Return the sideband signal buffer corresponding to the side band signal
270+
/// port identifier
271+
void *(*hostchannel_get_sideband_buffer)(unsigned int physical_device_id,
272+
unsigned int port_name,
273+
int channel_handle,
274+
size_t *buffer_size, int *status);
275+
276+
/// Pull read_size of sideband data from the device into host_buffer, WITHOUT
277+
/// acknowledge
278+
size_t (*hostchannel_sideband_pull_no_ack)(unsigned int physical_device_id,
279+
unsigned int port_name,
280+
int channel_handle,
281+
void *host_buffer,
282+
size_t read_size, int *status);
283+
284+
/// Push write_size of sideband data to the device from host_buffer, WITHOUT
285+
/// acknowledge
286+
size_t (*hostchannel_sideband_push_no_ack)(unsigned int physical_device_id,
287+
unsigned int port_name,
288+
int channel_handle,
289+
const void *host_buffer,
290+
size_t write_size, int *status);
291+
292+
/// Pull read_size of data from the device into host_buffer, WITHOUT
293+
/// acknowledge
294+
size_t (*hostchannel_pull_no_ack)(unsigned int physical_device_id,
295+
int channel_handle, void *host_buffer,
296+
size_t read_size, int *status);
297+
298+
/// Push write_size of data to the device from host_buffer, WITHOUT
299+
/// acknowledge
300+
size_t (*hostchannel_push_no_ack)(unsigned int physical_device_id,
301+
int channel_handle, const void *host_buffer,
302+
size_t write_size, int *status);
303+
268304
} acl_hal_t;
269305

270306
/// Linked list of MMD library names to load.

include/acl_hal_mmd.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,16 @@ typedef struct {
269269
int (*aocl_mmd_simulation_device_global_interface_write)(
270270
int handle, const char *interface_name, const void *host_addr,
271271
size_t dev_addr, size_t size);
272+
273+
// Return the side band signal buffer corresponding to the side band signal
274+
// port identifier Get a pointer to the mmd buffer for the host channel
275+
// Simulation only mmd call as of 2024.1. HW MMD developer needs to implement
276+
// this function in the future To support hostpipe sideband signals.
277+
void *(*aocl_mmd_hostchannel_get_sideband_buffer)(int handle, int channel,
278+
int port_id,
279+
size_t *buffer_size,
280+
int *status);
281+
272282
} acl_mmd_dispatch_t;
273283

274284
typedef struct {

include/acl_types.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,12 @@ typedef struct host_op_struct {
295295
size_t m_size_sent;
296296
} host_op_t;
297297

298+
struct sideband_signal_t {
299+
unsigned port_identifier; // matches enum signal_type in acl.h
300+
unsigned port_offset; // in bit
301+
unsigned side_band_size; // in bit
302+
};
303+
298304
typedef struct host_pipe_struct {
299305
// The handle to the device needed for mmd call
300306
unsigned int m_physical_device_id;
@@ -337,6 +343,12 @@ typedef struct host_pipe_struct {
337343
int protocol = -1; // avalon_streaming = 0, avalon_streaming_uses_ready = 1
338344
// avalon_mm = 2, avalon_mm_uses_ready = 3
339345

346+
// Number of sideband signals. Exclude data port.
347+
unsigned num_side_band_signals = 0;
348+
349+
// Sideband signals vector
350+
std::vector<sideband_signal_t> side_band_signals_vector;
351+
340352
} host_pipe_t;
341353

342354
// The device-specific information about a program.
@@ -617,7 +629,7 @@ typedef struct {
617629
const char *logical_name; // Use char* instead string here due to a
618630
// compilation error from acl_command_info_t
619631
// constructor malloc related
620-
} host_pipe_info;
632+
} host_pipe_dynamic_info;
621633

622634
struct {
623635
// Used for device global ops

src/acl_auto_configure.cpp

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,82 @@ static bool read_hostpipe_mappings(
681681
return result;
682682
}
683683

684+
/*
685+
New section added in 2024.1
686+
- Number of group of sideband signals -> each group map to each hostpipe
687+
For each sideband signal group
688+
- pipe logical name
689+
- number of sideband signals (including data field)
690+
- number of fields for each sideband signal
691+
- port identifier, like 0 for data, 1,2,3 for different sideband signals
692+
- port offset (in bits)
693+
- sideband size (in bits)
694+
695+
If a hostpipe has no sideband signal (e.g, a pipe only has data field), it won't
696+
have a sideband signal group. If none of the hostpipe has any sideband signals,
697+
the whole section will just be 0, which represents the number of sideband signal
698+
group is 0.
699+
700+
*/
701+
702+
static bool read_sideband_mappings(
703+
const std::string &config_str, std::string::size_type &curr_pos,
704+
std::vector<acl_sideband_signal_mapping> &sideband_signal_mappings,
705+
std::vector<int> &counters, std::string &err_str) noexcept {
706+
707+
// Get how many hostpipes have sideband signals
708+
unsigned int num_of_sideband_groups = 0;
709+
bool result = read_uint_counters(config_str, curr_pos, num_of_sideband_groups,
710+
counters);
711+
712+
// If none of the hostpipes have sideband signals, this section ends here.
713+
if (num_of_sideband_groups == 0) {
714+
return result;
715+
}
716+
717+
// Reaching here means we need to parse sideband signals.
718+
719+
for (unsigned int i = 0; result && (i < num_of_sideband_groups); i++) {
720+
721+
std::string logical_name;
722+
unsigned num_sideband_signals = 0;
723+
result =
724+
read_string_counters(config_str, curr_pos, logical_name, counters) &&
725+
read_uint_counters(config_str, curr_pos, num_sideband_signals,
726+
counters);
727+
assert(num_sideband_signals >=
728+
2); // If it has an entry, it must have 1 data signal + at least 1
729+
// sideband signals
730+
731+
unsigned num_fields_per_sideband = 0;
732+
if (result) {
733+
result = read_uint_counters(config_str, curr_pos, num_fields_per_sideband,
734+
counters);
735+
}
736+
737+
for (unsigned int j = 0; result && (j < num_sideband_signals); j++) {
738+
counters.emplace_back(num_fields_per_sideband);
739+
acl_sideband_signal_mapping mapping{};
740+
mapping.logical_name = logical_name;
741+
result = read_uint_counters(config_str, curr_pos, mapping.port_identifier,
742+
counters) &&
743+
read_uint_counters(config_str, curr_pos, mapping.port_offset,
744+
counters) &&
745+
read_uint_counters(config_str, curr_pos, mapping.sideband_size,
746+
counters);
747+
sideband_signal_mappings.emplace_back(mapping);
748+
749+
while (result && counters.back() > 0) {
750+
std::string tmp;
751+
result = read_string_counters(config_str, curr_pos, tmp, counters);
752+
}
753+
check_section_counters(counters);
754+
counters.pop_back();
755+
}
756+
}
757+
return result;
758+
}
759+
684760
static bool read_kernel_args(const std::string &config_str,
685761
const bool kernel_arg_info_available,
686762
std::string::size_type &curr_pos,
@@ -1221,6 +1297,17 @@ bool acl_load_device_def_from_str(const std::string &config_str,
12211297
config_str, curr_pos, devdef.hostpipe_mappings, counters, err_str);
12221298
}
12231299

1300+
// Starting from 2024.1, there is a new section that adds sideband signal
1301+
// information.
1302+
1303+
// Read program scoped hostpipes sideband signals mapping
1304+
1305+
if (result && counters.back() > 0) {
1306+
result = read_sideband_mappings(config_str, curr_pos,
1307+
devdef.sideband_signal_mappings, counters,
1308+
err_str);
1309+
}
1310+
12241311
// forward compatibility: bypassing remaining fields at the end of device
12251312
// description section
12261313
while (result && counters.size() > 0 &&

0 commit comments

Comments
 (0)