Skip to content

Commit a97edb1

Browse files
committed
Fix kernel id - csr address mapping issue
1 parent 0f8829f commit a97edb1

File tree

4 files changed

+26
-0
lines changed

4 files changed

+26
-0
lines changed

include/acl_hal.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,10 @@ typedef struct {
246246
void (*simulation_streaming_kernel_done)(unsigned int physical_device_id,
247247
const std::string &signal_name,
248248
unsigned int &finish_counter);
249+
250+
void (*simulation_set_kernel_cra_address_map)(
251+
unsigned int physical_device_id,
252+
const std::vector<uintptr_t> kernel_csr_address_map);
249253
} acl_hal_t;
250254

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

include/acl_hal_mmd.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,9 @@ typedef struct {
149149
// accounted and returned in a subsequent invocation of this function.
150150
void (*aocl_mmd_simulation_streaming_kernel_done)(
151151
int handle, const std::string &signal_name, unsigned int &finish_counter);
152+
153+
void (*aocl_mmd_simulation_set_kernel_cra_address_map)(
154+
int handle, const std::vector<uintptr_t> kernel_csr_address_map);
152155
} acl_mmd_dispatch_t;
153156

154157
typedef struct {

src/acl_hal_mmd.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,10 @@ void acl_hal_mmd_simulation_streaming_kernel_done(
161161
unsigned int physical_device_id, const std::string &kernel_name,
162162
unsigned int &finish_counter);
163163

164+
void acl_hal_mmd_simulation_set_kernel_cra_address_map(
165+
unsigned int physical_device_id,
166+
const std::vector<uintptr_t> kernel_csr_address_map);
167+
164168
static size_t acl_kernel_if_read(acl_bsp_io *io, dev_addr_t src, char *dest,
165169
size_t size);
166170
static size_t acl_kernel_if_write(acl_bsp_io *io, dev_addr_t dest,
@@ -354,6 +358,7 @@ static acl_hal_t acl_hal_mmd = {
354358
acl_hal_mmd_shared_alloc, // shared_alloc
355359
acl_hal_mmd_simulation_streaming_kernel_start, // simulation_streaming_kernel_start
356360
acl_hal_mmd_simulation_streaming_kernel_done, // simulation_streaming_kernel_done
361+
acl_hal_mmd_simulation_set_kernel_cra_address_map, // simulation_set_kernel_cra_address_map
357362
};
358363

359364
// This will contain the device physical id to tell us which device across all
@@ -2854,3 +2859,11 @@ void acl_hal_mmd_simulation_streaming_kernel_done(
28542859
.mmd_dispatch->aocl_mmd_simulation_streaming_kernel_done(
28552860
device_info[physical_device_id].handle, kernel_name, finish_counter);
28562861
}
2862+
2863+
void acl_hal_mmd_simulation_set_kernel_cra_address_map(
2864+
unsigned int physical_device_id,
2865+
const std::vector<uintptr_t> kernel_csr_address_map) {
2866+
device_info[physical_device_id]
2867+
.mmd_dispatch->aocl_mmd_simulation_set_kernel_cra_address_map(
2868+
device_info[physical_device_id].handle, kernel_csr_address_map);
2869+
}

src/acl_kernel_if.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -921,16 +921,22 @@ int acl_kernel_if_update(const acl_device_def_autodiscovery_t &devdef,
921921
// The Kernel CSR registers
922922
// The new and improved config ROM give us the address *offsets* from
923923
// the first kernel CSR, and the range of each kernel CSR.
924+
std::vector<uintptr_t> kernel_csr_address_map;
924925
for (unsigned ii = 0; ii < devdef.accel.size(); ++ii) {
925926
kern->accel_csr[ii].address =
926927
OFFSET_KERNEL_CRA + devdef.hal_info[ii].csr.address;
927928
kern->accel_csr[ii].bytes = devdef.hal_info[ii].csr.num_bytes;
929+
kernel_csr_address_map.push_back(kern->accel_csr[ii].address);
928930

929931
ACL_KERNEL_IF_DEBUG_MSG(
930932
kern, "Kernel_%s CSR { 0x%08" PRIxPTR ", 0x%08" PRIxPTR " }\n",
931933
devdef.accel[ii].iface.name.c_str(), kern->accel_csr[ii].address,
932934
kern->accel_csr[ii].bytes);
933935
}
936+
if (acl_platform.offline_mode == ACL_CONTEXT_MPSIM) {
937+
acl_get_hal()->simulation_set_kernel_cra_address_map(
938+
kern->physical_device_id, kernel_csr_address_map);
939+
}
934940

935941
// The Kernel performance monitor registers
936942
for (unsigned ii = 0; ii < devdef.accel.size(); ++ii) {

0 commit comments

Comments
 (0)