Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -98,22 +98,8 @@ ur_result_t AsanInterceptor::allocateMemory(ur_context_handle_t Context,
Pool = ContextInfo->getUSMPool();
}

if (Type == AllocType::DEVICE_USM) {
UR_CALL(getContext()->urDdiTable.USM.pfnDeviceAlloc(
Context, Device, Properties, Pool, NeededSize, &Allocated));
} else if (Type == AllocType::HOST_USM) {
UR_CALL(getContext()->urDdiTable.USM.pfnHostAlloc(Context, Properties, Pool,
NeededSize, &Allocated));
} else if (Type == AllocType::SHARED_USM) {
UR_CALL(getContext()->urDdiTable.USM.pfnSharedAlloc(
Context, Device, Properties, Pool, NeededSize, &Allocated));
} else if (Type == AllocType::MEM_BUFFER) {
UR_CALL(getContext()->urDdiTable.USM.pfnDeviceAlloc(
Context, Device, Properties, Pool, NeededSize, &Allocated));
} else {
UR_LOG_L(getContext()->logger, ERR, "Unsupport memory type");
return UR_RESULT_ERROR_INVALID_ARGUMENT;
}
UR_CALL(SafeAllocate(Context, Device, NeededSize, Properties, Pool, Type,
&Allocated));

// Udpate statistics
ContextInfo->Stats.UpdateUSMMalloced(NeededSize, NeededSize - Size);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,9 @@ struct AsanRuntimeDataWrapper {

Host.NumLocalArgs = LocalArgs.size();
const size_t LocalArgsInfoSize = sizeof(LocalArgsInfo) * Host.NumLocalArgs;
UR_CALL(getContext()->urDdiTable.USM.pfnDeviceAlloc(
Context, Device, nullptr, nullptr, LocalArgsInfoSize,
ur_cast<void **>(&Host.LocalArgs)));
UR_CALL(SafeAllocate(Context, Device, LocalArgsInfoSize, nullptr, nullptr,
AllocType::DEVICE_USM,
ur_cast<void **>(&Host.LocalArgs)));

UR_CALL(getContext()->urDdiTable.Enqueue.pfnUSMMemcpy(
Queue, true, Host.LocalArgs, &LocalArgs[0], LocalArgsInfoSize, 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,8 @@ ur_result_t ShadowMemoryGPU::AllocLocalShadow(ur_queue_handle_t Queue,
LastAllocedSize = 0;
}

UR_CALL(getContext()->urDdiTable.USM.pfnDeviceAlloc(
Context, Device, nullptr, nullptr, RequiredShadowSize,
(void **)&LocalShadowOffset));
UR_CALL(SafeAllocate(Context, Device, RequiredShadowSize, nullptr, nullptr,
AllocType::DEVICE_USM, (void **)&LocalShadowOffset));

// Initialize shadow memory
ur_result_t URes = EnqueueUSMSet(Queue, (void *)LocalShadowOffset, (char)0,
Expand Down Expand Up @@ -312,9 +311,9 @@ ur_result_t ShadowMemoryGPU::AllocPrivateShadow(ur_queue_handle_t Queue,

ur_usm_desc_t PrivateBaseProps{UR_STRUCTURE_TYPE_USM_DESC, nullptr,
UR_USM_ADVICE_FLAG_DEFAULT, sizeof(uptr)};
UR_CALL_THROWS(getContext()->urDdiTable.USM.pfnDeviceAlloc(
Context, Device, &PrivateBaseProps, nullptr, NewPrivateBaseSize,
(void **)&PrivateBasePtr));
UR_CALL_THROWS(SafeAllocate(
Context, Device, NewPrivateBaseSize, &PrivateBaseProps, nullptr,
AllocType::DEVICE_USM, (void **)&PrivateBasePtr));

// No need to clean the shadow base, their should be set by work item on
// launch
Expand All @@ -337,9 +336,9 @@ ur_result_t ShadowMemoryGPU::AllocPrivateShadow(ur_queue_handle_t Queue,
LastPrivateShadowAllocedSize = 0;
}

UR_CALL_THROWS(getContext()->urDdiTable.USM.pfnDeviceAlloc(
Context, Device, nullptr, nullptr, NewPrivateShadowSize,
(void **)&PrivateShadowOffset));
UR_CALL_THROWS(SafeAllocate(Context, Device, NewPrivateShadowSize,
nullptr, nullptr, AllocType::DEVICE_USM,
(void **)&PrivateShadowOffset));
LastPrivateShadowAllocedSize = NewPrivateShadowSize;
UR_CALL_THROWS(EnqueueUSMSet(Queue, (void *)PrivateShadowOffset, (char)0,
NewPrivateShadowSize));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -498,10 +498,10 @@ ur_result_t MsanInterceptor::prepareLaunch(

// Clean shadow
// Its content is always zero, and is used for unsupport memory types
UR_CALL(getContext()->urDdiTable.USM.pfnDeviceAlloc(
ContextInfo->Handle, DeviceInfo->Handle, nullptr, nullptr,
ContextInfo->CleanShadowSize,
(void **)&LaunchInfo.Data.Host.CleanShadow));
UR_CALL(SafeAllocate(ContextInfo->Handle, DeviceInfo->Handle,
ContextInfo->CleanShadowSize, nullptr, nullptr,
AllocType::DEVICE_USM,
(void **)&LaunchInfo.Data.Host.CleanShadow));
UR_CALL(EnqueueUSMSet(Queue, (void *)LaunchInfo.Data.Host.CleanShadow,
(char)0, ContextInfo->CleanShadowSize, 0, nullptr,
nullptr));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,9 @@ struct MsanRuntimeDataWrapper {
Host.NumLocalArgs = LocalArgs.size();
const size_t LocalArgsInfoSize =
sizeof(MsanLocalArgsInfo) * Host.NumLocalArgs;
UR_CALL(getContext()->urDdiTable.USM.pfnDeviceAlloc(
Context, Device, nullptr, nullptr, LocalArgsInfoSize,
ur_cast<void **>(&Host.LocalArgs)));
UR_CALL(SafeAllocate(Context, Device, LocalArgsInfoSize, nullptr, nullptr,
AllocType::DEVICE_USM,
ur_cast<void **>(&Host.LocalArgs)));

UR_CALL(getContext()->urDdiTable.Enqueue.pfnUSMMemcpy(
Queue, true, Host.LocalArgs, &LocalArgs[0], LocalArgsInfoSize, 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,9 +387,8 @@ ur_result_t MsanShadowMemoryGPU::AllocLocalShadow(ur_queue_handle_t Queue,
LastAllocedSize = 0;
}

UR_CALL(getContext()->urDdiTable.USM.pfnDeviceAlloc(
Context, Device, nullptr, nullptr, RequiredShadowSize,
(void **)&LocalShadowOffset));
UR_CALL(SafeAllocate(Context, Device, RequiredShadowSize, nullptr, nullptr,
AllocType::DEVICE_USM, (void **)&LocalShadowOffset));

// Initialize shadow memory
ur_result_t URes = EnqueueUSMSet(Queue, (void *)LocalShadowOffset, (char)0,
Expand Down Expand Up @@ -433,9 +432,9 @@ ur_result_t MsanShadowMemoryGPU::AllocPrivateShadow(ur_queue_handle_t Queue,

ur_usm_desc_t PrivateBaseProps{UR_STRUCTURE_TYPE_USM_DESC, nullptr,
UR_USM_ADVICE_FLAG_DEFAULT, sizeof(uptr)};
UR_CALL_THROWS(getContext()->urDdiTable.USM.pfnDeviceAlloc(
Context, Device, &PrivateBaseProps, nullptr, NewPrivateBaseSize,
(void **)&PrivateBasePtr));
UR_CALL_THROWS(SafeAllocate(
Context, Device, NewPrivateBaseSize, &PrivateBaseProps, nullptr,
AllocType::DEVICE_USM, (void **)&PrivateBasePtr));

// No need to clean the shadow base, their should be set by work item on
// launch
Expand All @@ -454,9 +453,9 @@ ur_result_t MsanShadowMemoryGPU::AllocPrivateShadow(ur_queue_handle_t Queue,
LastPrivateShadowAllocedSize = 0;
}

UR_CALL_THROWS(getContext()->urDdiTable.USM.pfnDeviceAlloc(
Context, Device, nullptr, nullptr, NewPrivateShadowSize,
(void **)&PrivateShadowOffset));
UR_CALL_THROWS(SafeAllocate(Context, Device, NewPrivateShadowSize,
nullptr, nullptr, AllocType::DEVICE_USM,
(void **)&PrivateShadowOffset));
LastPrivateShadowAllocedSize = NewPrivateShadowSize;
UR_CALL_THROWS(EnqueueUSMSet(Queue, (void *)PrivateShadowOffset, (char)0,
NewPrivateShadowSize));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,20 @@ ur_result_t SafeAllocate(ur_context_handle_t Context, ur_device_handle_t Device,
Device ? GetDeviceType(Context, Device) : DeviceType::UNKNOWN;
switch (Type) {
case AllocType::DEVICE_USM:
case AllocType::MEM_BUFFER:
UR_CALL(getContext()->urDdiTable.USM.pfnDeviceAlloc(
Context, Device, Properties, Pool, Size, Allocated));
case AllocType::MEM_BUFFER: {
auto UrRes = getContext()->urDdiTable.USM.pfnDeviceAlloc(
Context, Device, Properties, Pool, Size, Allocated);
if (UrRes != UR_RESULT_SUCCESS) {
if (UrRes == UR_RESULT_ERROR_OUT_OF_DEVICE_MEMORY)
UR_LOG_L(getContext()->logger, WARN,
"Out of device memory. Please consider reducing the "
"application or running the application with MPI on multi "
"devices.");
return UrRes;
}
validateDeviceUSM((uptr)*Allocated, DevieType);
break;
}
case AllocType::HOST_USM:
UR_CALL(getContext()->urDdiTable.USM.pfnHostAlloc(Context, Properties, Pool,
Size, Allocated));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ ur_result_t TsanRuntimeDataWrapper::importLocalArgsInfo(
Host.NumLocalArgs = LocalArgs.size();
const size_t LocalArgsInfoSize =
sizeof(TsanLocalArgsInfo) * Host.NumLocalArgs;
UR_CALL(getContext()->urDdiTable.USM.pfnDeviceAlloc(
Context, Device, nullptr, nullptr, LocalArgsInfoSize,
ur_cast<void **>(&Host.LocalArgs)));
UR_CALL(SafeAllocate(Context, Device, LocalArgsInfoSize, nullptr, nullptr,
AllocType::DEVICE_USM,
ur_cast<void **>(&Host.LocalArgs)));

UR_CALL(getContext()->urDdiTable.Enqueue.pfnUSMMemcpy(
Queue, true, Host.LocalArgs, &LocalArgs[0], LocalArgsInfoSize, 0, nullptr,
Expand Down Expand Up @@ -140,16 +140,8 @@ ur_result_t TsanInterceptor::allocateMemory(ur_context_handle_t Context,

void *Allocated = nullptr;

if (Type == AllocType::DEVICE_USM) {
UR_CALL(getContext()->urDdiTable.USM.pfnDeviceAlloc(
Context, Device, Properties, Pool, Size, &Allocated));
} else if (Type == AllocType::HOST_USM) {
UR_CALL(getContext()->urDdiTable.USM.pfnHostAlloc(Context, Properties, Pool,
Size, &Allocated));
} else if (Type == AllocType::SHARED_USM) {
UR_CALL(getContext()->urDdiTable.USM.pfnSharedAlloc(
Context, Device, Properties, Pool, Size, &Allocated));
}
UR_CALL(
SafeAllocate(Context, Device, Size, Properties, Pool, Type, &Allocated));

auto AI = TsanAllocInfo{reinterpret_cast<uptr>(Allocated), Size};
// For updating shadow memory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,8 @@ ur_result_t ShadowMemoryGPU::AllocLocalShadow(ur_queue_handle_t Queue,
LastAllocatedSize = 0;
}

UR_CALL(getContext()->urDdiTable.USM.pfnDeviceAlloc(
Context, Device, nullptr, nullptr, RequiredShadowSize,
(void **)&LocalShadowOffset));
UR_CALL(SafeAllocate(Context, Device, RequiredShadowSize, nullptr, nullptr,
AllocType::DEVICE_USM, (void **)&LocalShadowOffset));

// Initialize shadow memory
ur_result_t URes =
Expand Down
Loading