Skip to content
Draft
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
24 changes: 24 additions & 0 deletions offload/liboffload/API/Memory.td
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,27 @@ def olMemFill : Function {
Return<"OL_ERRC_INVALID_SIZE", ["`FillSize % PatternSize != 0`"]>
];
}

def olMemDataLock : Function {
let desc = "Locks / pins host memory using the plugin runtime.";
let params = [
Param<"ol_device_handle_t", "Device", "handle of the device to allocate on", PARAM_IN>,
Param<"void *", "Ptr", "Host Pointer", PARAM_IN>,
Param<"size_t", "Size", "size of the allocation in bytes", PARAM_IN>,
Param<"void**", "LockedPtr", "output for the allocated pointer", PARAM_OUT>
];
let returns = [
Return<"OL_ERRC_INVALID_SIZE", [
"`Size == 0`"
]>
];
}

def olMemDataUnLock : Function {
let desc = "Unlocks / unpins host memory using the plugin runtime.";
let params = [
Param<"ol_device_handle_t", "Device", "handle of the device to allocate on", PARAM_IN>,
Param<"void *", "Ptr", "Host Pointer", PARAM_IN>
];
let returns = [];
}
15 changes: 15 additions & 0 deletions offload/liboffload/src/OffloadImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1214,5 +1214,20 @@ Error olLaunchHostFunction_impl(ol_queue_handle_t Queue,
Queue->AsyncInfo);
}

Error olMemDataLock_impl(ol_device_handle_t Device, void *Ptr, size_t Size,
void** LockedPtr) {
Expected<void*> LockedPtrOrErr = Device->Device->dataLock(Ptr, Size);
if (!LockedPtrOrErr)
return LockedPtrOrErr.takeError();

*LockedPtr = *LockedPtrOrErr;

return Error::success();
}

Error olMemDataUnLock_impl(ol_device_handle_t Device, void *Ptr) {
return Device->Device->dataUnlock(Ptr);
}

} // namespace offload
} // namespace llvm