I was trying to support mgpuMemcpy runtime call in SyclRuntimeWrappers.cpp, which is needed for lowering of gpu::MemcpyOp in intel gpu platform. But I’m encountering the *** stack smashing detected ***: terminated .
Here is my code
extern “C” SYCL_RUNTIME_EXPORT void
mgpuMemcpy(void *dst, void *src, size_t sizeBytes, sycl::queue *queue) {
// Verify pointer type (example for Intel SYCL extensions)
auto dst_type = sycl::get_pointer_type(dst, queue->get_context());
auto src_type = sycl::get_pointer_type(src, queue->get_context());
queue->memcpy(dst, src, sizeBytes).wait();
}
PS: dst, src are not null and size is as per expectations
dst_type and src_type are coming as sycl::usm::alloc::unknown
Part of IR(where the error is coming from):
llvm.func @GetModelValues(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: !llvm.ptr, %arg3: !llvm.ptr) → i32 attributes {llvm.emit_c_interface} {
%0 = llvm.mlir.zero : !llvm.ptr
%1 = llvm.mlir.constant(42 : i32) : i32
%2 = llvm.call @mgpuStreamCreate() : () → !llvm.ptr
%3 = llvm.getelementptr %0[7] : (!llvm.ptr) → !llvm.ptr, f32
%4 = llvm.ptrtoint %3 : !llvm.ptr to i64
llvm.call @mgpuMemcpy(%arg2, %arg0, %4, %2) : (!llvm.ptr, !llvm.ptr, i64, !llvm.ptr) → ()
%5 = llvm.getelementptr %0[7] : (!llvm.ptr) → !llvm.ptr, i32
%6 = llvm.ptrtoint %5 : !llvm.ptr to i64
llvm.call @mgpuMemcpy(%arg3, %arg1, %6, %2) : (!llvm.ptr, !llvm.ptr, i64, !llvm.ptr) → ()
llvm.call @mgpuStreamSynchronize(%2) : (!llvm.ptr) → ()
llvm.call @mgpuStreamDestroy(%2) : (!llvm.ptr) → ()
llvm.return %1 : i32
}