Please use GitHub pull requests for new patches. Avoid migrating existing patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
openmp/libomptarget/plugins-nextgen/amdgpu/src/rtl.cpp
Show First 20 Lines • Show All 1,839 Lines • ▼ Show 20 Lines | struct AMDGPUDeviceTy : public GenericDeviceTy, AMDGenericDeviceTy { | ||||||||
} | } | ||||||||
/// Unpin the host buffer. | /// Unpin the host buffer. | ||||||||
Error dataUnlockImpl(void *HstPtr) override { | Error dataUnlockImpl(void *HstPtr) override { | ||||||||
hsa_status_t Status = hsa_amd_memory_unlock(HstPtr); | hsa_status_t Status = hsa_amd_memory_unlock(HstPtr); | ||||||||
return Plugin::check(Status, "Error in hsa_amd_memory_unlock: %s\n"); | return Plugin::check(Status, "Error in hsa_amd_memory_unlock: %s\n"); | ||||||||
} | } | ||||||||
/// Check through the HSA runtime whether the \p HstPtr buffer is pinned. | |||||||||
Expected<bool> isPinnedPtrImpl(void *HstPtr, void *&BaseHstPtr, | |||||||||
void *&BaseDevAccessiblePtr, | |||||||||
size_t &BaseSize) const override { | |||||||||
hsa_amd_pointer_info_t Info; | |||||||||
Info.size = sizeof(hsa_amd_pointer_info_t); | |||||||||
hsa_status_t Status = | |||||||||
jdoerfertUnsubmitted Done ReplyInline Actions
jdoerfert: | |||||||||
It's an output parameter. I'll add the proper comment. kevinsala: It's an output parameter. I'll add the proper comment. | |||||||||
hsa_amd_pointer_info(HstPtr, &Info, /* Allocator */ nullptr, | |||||||||
/* Number of accessible agents (out) */ nullptr, | |||||||||
/* Accessible agents */ nullptr); | |||||||||
if (auto Err = Plugin::check(Status, "Error in hsa_amd_pointer_info: %s")) | |||||||||
return Err; | |||||||||
// The buffer may be locked or allocated through HSA allocators. Assume that | |||||||||
// the buffer is host pinned if the runtime reports a HSA type. | |||||||||
if (Info.type != HSA_EXT_POINTER_TYPE_LOCKED && | |||||||||
Info.type != HSA_EXT_POINTER_TYPE_HSA) | |||||||||
return false; | |||||||||
assert(Info.hostBaseAddress && "Invalid host pinned address"); | |||||||||
assert(Info.agentBaseAddress && "Invalid agent pinned address"); | |||||||||
assert(Info.sizeInBytes > 0 && "Invalid pinned allocation size"); | |||||||||
// Save the allocation info in the output parameters. | |||||||||
BaseHstPtr = Info.hostBaseAddress; | |||||||||
BaseDevAccessiblePtr = Info.agentBaseAddress; | |||||||||
BaseSize = Info.sizeInBytes; | |||||||||
return true; | |||||||||
} | |||||||||
/// Submit data to the device (host to device transfer). | /// Submit data to the device (host to device transfer). | ||||||||
Error dataSubmitImpl(void *TgtPtr, const void *HstPtr, int64_t Size, | Error dataSubmitImpl(void *TgtPtr, const void *HstPtr, int64_t Size, | ||||||||
AsyncInfoWrapperTy &AsyncInfoWrapper) override { | AsyncInfoWrapperTy &AsyncInfoWrapper) override { | ||||||||
// Use one-step asynchronous operation when host memory is already pinned. | // Use one-step asynchronous operation when host memory is already pinned. | ||||||||
if (void *PinnedPtr = | if (void *PinnedPtr = | ||||||||
PinnedAllocs.getDeviceAccessiblePtrFromPinnedBuffer(HstPtr)) { | PinnedAllocs.getDeviceAccessiblePtrFromPinnedBuffer(HstPtr)) { | ||||||||
AMDGPUStreamTy &Stream = getStream(AsyncInfoWrapper); | AMDGPUStreamTy &Stream = getStream(AsyncInfoWrapper); | ||||||||
return Stream.pushPinnedMemoryCopyAsync(TgtPtr, PinnedPtr, Size); | return Stream.pushPinnedMemoryCopyAsync(TgtPtr, PinnedPtr, Size); | ||||||||
▲ Show 20 Lines • Show All 778 Lines • Show Last 20 Lines |