Skip to content

Add support for hostpipe sideband signals. #323

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 1 commit into from
Nov 3, 2023
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
20 changes: 20 additions & 0 deletions include/acl.h
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,25 @@ struct acl_hostpipe_mapping {
// avalon_mm = 2, avalon_mm_uses_ready = 3
};

// Mapping of sideband signals to logical pipe

struct acl_sideband_signal_mapping {
std::string logical_name;
unsigned port_identifier;
unsigned port_offset; // bit
unsigned sideband_size; // bit
};

// Must match the definition in the compiler
// Analysis/FPGAAnalysis/Utils/StreamParameters.h
enum signal_type {
SignalUnknown = -1,
AvalonData = 0,
AvalonSop = 1,
AvalonEop = 2,
AvalonEmpty = 3
};

// Part of acl_device_def_t where members are populated from the information
// in the autodiscovery string. This will get updated every time the device
// is programmed with a new device binary as the new binary would contain a
Expand All @@ -570,6 +589,7 @@ typedef struct acl_device_def_autodiscovery_t {
true; // Set the default value to true for backwards compatibility flows.

std::vector<acl_hostpipe_mapping> hostpipe_mappings;
std::vector<acl_sideband_signal_mapping> sideband_signal_mappings;
} acl_device_def_autodiscovery_t;

typedef struct acl_device_def_t {
Expand Down
36 changes: 36 additions & 0 deletions include/acl_hal.h
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,42 @@ typedef struct {
unsigned int physical_device_id, const char *interface_name,
const void *host_addr, size_t dev_addr, size_t size);

/// Simulation only mmd call as of 2024.1
/// Return the sideband signal buffer corresponding to the side band signal
/// port identifier
void *(*hostchannel_get_sideband_buffer)(unsigned int physical_device_id,
unsigned int port_name,
int channel_handle,
size_t *buffer_size, int *status);

/// Pull read_size of sideband data from the device into host_buffer, WITHOUT
/// acknowledge
size_t (*hostchannel_sideband_pull_no_ack)(unsigned int physical_device_id,
unsigned int port_name,
int channel_handle,
void *host_buffer,
size_t read_size, int *status);

/// Push write_size of sideband data to the device from host_buffer, WITHOUT
/// acknowledge
size_t (*hostchannel_sideband_push_no_ack)(unsigned int physical_device_id,
unsigned int port_name,
int channel_handle,
const void *host_buffer,
size_t write_size, int *status);

/// Pull read_size of data from the device into host_buffer, WITHOUT
/// acknowledge
size_t (*hostchannel_pull_no_ack)(unsigned int physical_device_id,
int channel_handle, void *host_buffer,
size_t read_size, int *status);

/// Push write_size of data to the device from host_buffer, WITHOUT
/// acknowledge
size_t (*hostchannel_push_no_ack)(unsigned int physical_device_id,
int channel_handle, const void *host_buffer,
size_t write_size, int *status);

} acl_hal_t;

/// Linked list of MMD library names to load.
Expand Down
10 changes: 10 additions & 0 deletions include/acl_hal_mmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,16 @@ typedef struct {
int (*aocl_mmd_simulation_device_global_interface_write)(
int handle, const char *interface_name, const void *host_addr,
size_t dev_addr, size_t size);

// Return the side band signal buffer corresponding to the side band signal
// port identifier Get a pointer to the mmd buffer for the host channel
// Simulation only mmd call as of 2024.1. HW MMD developer needs to implement
// this function in the future To support hostpipe sideband signals.
void *(*aocl_mmd_hostchannel_get_sideband_buffer)(int handle, int channel,
int port_id,
size_t *buffer_size,
int *status);

} acl_mmd_dispatch_t;

typedef struct {
Expand Down
14 changes: 13 additions & 1 deletion include/acl_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,12 @@ typedef struct host_op_struct {
size_t m_size_sent;
} host_op_t;

struct sideband_signal_t {
unsigned port_identifier; // matches enum signal_type in acl.h
unsigned port_offset; // in bit
unsigned side_band_size; // in bit
};

typedef struct host_pipe_struct {
// The handle to the device needed for mmd call
unsigned int m_physical_device_id;
Expand Down Expand Up @@ -337,6 +343,12 @@ typedef struct host_pipe_struct {
int protocol = -1; // avalon_streaming = 0, avalon_streaming_uses_ready = 1
// avalon_mm = 2, avalon_mm_uses_ready = 3

// Number of sideband signals. Exclude data port.
unsigned num_side_band_signals = 0;

// Sideband signals vector
std::vector<sideband_signal_t> side_band_signals_vector;

} host_pipe_t;

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

struct {
// Used for device global ops
Expand Down
87 changes: 87 additions & 0 deletions src/acl_auto_configure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,82 @@ static bool read_hostpipe_mappings(
return result;
}

/*
New section added in 2024.1
- Number of group of sideband signals -> each group map to each hostpipe
For each sideband signal group
- pipe logical name
- number of sideband signals (including data field)
- number of fields for each sideband signal
- port identifier, like 0 for data, 1,2,3 for different sideband signals
- port offset (in bits)
- sideband size (in bits)

If a hostpipe has no sideband signal (e.g, a pipe only has data field), it won't
have a sideband signal group. If none of the hostpipe has any sideband signals,
the whole section will just be 0, which represents the number of sideband signal
group is 0.

*/

static bool read_sideband_mappings(
const std::string &config_str, std::string::size_type &curr_pos,
std::vector<acl_sideband_signal_mapping> &sideband_signal_mappings,
std::vector<int> &counters, std::string &err_str) noexcept {

// Get how many hostpipes have sideband signals
unsigned int num_of_sideband_groups = 0;
bool result = read_uint_counters(config_str, curr_pos, num_of_sideband_groups,
counters);

// If none of the hostpipes have sideband signals, this section ends here.
if (num_of_sideband_groups == 0) {
return result;
}

// Reaching here means we need to parse sideband signals.

for (unsigned int i = 0; result && (i < num_of_sideband_groups); i++) {

std::string logical_name;
unsigned num_sideband_signals = 0;
result =
read_string_counters(config_str, curr_pos, logical_name, counters) &&
read_uint_counters(config_str, curr_pos, num_sideband_signals,
counters);
assert(num_sideband_signals >=
2); // If it has an entry, it must have 1 data signal + at least 1
// sideband signals

unsigned num_fields_per_sideband = 0;
if (result) {
result = read_uint_counters(config_str, curr_pos, num_fields_per_sideband,
counters);
}

for (unsigned int j = 0; result && (j < num_sideband_signals); j++) {
counters.emplace_back(num_fields_per_sideband);
acl_sideband_signal_mapping mapping{};
mapping.logical_name = logical_name;
result = read_uint_counters(config_str, curr_pos, mapping.port_identifier,
counters) &&
read_uint_counters(config_str, curr_pos, mapping.port_offset,
counters) &&
read_uint_counters(config_str, curr_pos, mapping.sideband_size,
counters);
sideband_signal_mappings.emplace_back(mapping);

while (result && counters.back() > 0) {
std::string tmp;
result = read_string_counters(config_str, curr_pos, tmp, counters);
}
check_section_counters(counters);
counters.pop_back();
}
}
return result;
}

static bool read_kernel_args(const std::string &config_str,
const bool kernel_arg_info_available,
std::string::size_type &curr_pos,
Expand Down Expand Up @@ -1221,6 +1297,17 @@ bool acl_load_device_def_from_str(const std::string &config_str,
config_str, curr_pos, devdef.hostpipe_mappings, counters, err_str);
}

// Starting from 2024.1, there is a new section that adds sideband signal
// information.

// Read program scoped hostpipes sideband signals mapping

if (result && counters.back() > 0) {
result = read_sideband_mappings(config_str, curr_pos,
devdef.sideband_signal_mappings, counters,
err_str);
}

// forward compatibility: bypassing remaining fields at the end of device
// description section
while (result && counters.size() > 0 &&
Expand Down
Loading