Skip to content

Commit 47fce96

Browse files
committed
AIESW-26391:Fix eff_net hip testcase failure.
Support computed addresses (base + offset) for global memory arguments to enable pointer arithmetic use cases like sub-buffer access. Detect offset in global arguments and pass raw pointer to preserve computed addresses (base + offset), otherwise pass buffer object for proper memory tracking. Previously, extracting the buffer object would return only the base address, breaking computed addresses like: wts_base + (offset[i] * 4) Signed-off-by: Srikanth Vuppala <120363307+svup-xilinx@users.noreply.github.com>
1 parent 96d9829 commit 47fce96

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

src/runtime_src/hip/core/event.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -255,14 +255,22 @@ kernel_start::kernel_start(std::shared_ptr<function> f, void** args)
255255
break;
256256

257257
case karg::argtype::global: {
258+
// Handle both base buffer addresses and computed addresses (base + offset).
259+
// If offset is non-zero, pass raw pointer to preserve computed address.
260+
// If offset is zero, pass buffer object for proper memory management.
258261
void **bufptr = static_cast<void **>(args[idx]);
259-
auto hip_mem = memory_database::instance().get_hip_mem_from_addr(*bufptr).first;
262+
auto hip_mem_info = memory_database::instance().get_hip_mem_from_addr(*bufptr);
263+
auto hip_mem = hip_mem_info.first;
260264
if (!hip_mem) {
261-
std::string err_msg = "failed to get memory from arg at index - " + std::to_string(idx);
262-
throw_hip_error(hipErrorInvalidValue, err_msg.c_str());
263-
}
265+
std::string err_msg = "failed to get memory from arg at index - " + std::to_string(idx);
266+
throw_hip_error(hipErrorInvalidValue, err_msg.c_str());
267+
}
268+
269+
if (hip_mem_info.second)
270+
r.set_arg(static_cast<int>(arg->index), *bufptr);
271+
else
272+
r.set_arg(static_cast<int>(arg->index), hip_mem->get_xrt_bo());
264273

265-
r.set_arg(arg->index, hip_mem->get_xrt_bo());
266274
break;
267275
}
268276
case karg::argtype::constant :

0 commit comments

Comments
 (0)