Skip to content

Commit

Permalink
[SYCL][UR][L0] Remove reduntant umf2urResult function
Browse files Browse the repository at this point in the history
  • Loading branch information
kswiecicki committed Oct 24, 2023
1 parent 1c59b67 commit 3af465b
Showing 1 changed file with 4 additions and 32 deletions.
36 changes: 4 additions & 32 deletions source/adapters/level_zero/usm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,34 +20,6 @@

#include <umf_helpers.hpp>

ur_result_t umf2urResult(umf_result_t umfResult) {
if (umfResult == UMF_RESULT_SUCCESS)
return UR_RESULT_SUCCESS;

switch (umfResult) {
case UMF_RESULT_ERROR_OUT_OF_HOST_MEMORY:
return UR_RESULT_ERROR_OUT_OF_HOST_MEMORY;
case UMF_RESULT_ERROR_MEMORY_PROVIDER_SPECIFIC: {
auto hProvider = umfGetLastFailedMemoryProvider();
if (hProvider == nullptr)
return UR_RESULT_ERROR_UNKNOWN;

ur_result_t Err = UR_RESULT_ERROR_UNKNOWN;
umfMemoryProviderGetLastNativeError(hProvider, nullptr,
reinterpret_cast<int32_t *>(&Err));
return Err;
}
case UMF_RESULT_ERROR_INVALID_ARGUMENT:
return UR_RESULT_ERROR_INVALID_ARGUMENT;
case UMF_RESULT_ERROR_INVALID_ALIGNMENT:
return UR_RESULT_ERROR_UNSUPPORTED_ALIGNMENT;
case UMF_RESULT_ERROR_NOT_SUPPORTED:
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
default:
return UR_RESULT_ERROR_UNKNOWN;
};
}

usm::DisjointPoolAllConfigs InitializeDisjointPoolConfig() {
const char *PoolUrConfigVal = std::getenv("SYCL_PI_LEVEL_ZERO_USM_ALLOCATOR");
const char *PoolPiConfigVal = std::getenv("UR_L0_USM_ALLOCATOR");
Expand Down Expand Up @@ -315,7 +287,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urUSMHostAlloc(
*RetMem = umfPoolAlignedMalloc(hPoolInternal, Size, Align);
if (*RetMem == nullptr) {
auto umfRet = umfPoolGetLastAllocationError(hPoolInternal);
return umf2urResult(umfRet);
return umf::umf2urResult(umfRet);
}

if (IndirectAccessTrackingEnabled) {
Expand Down Expand Up @@ -391,7 +363,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urUSMDeviceAlloc(
*RetMem = umfPoolAlignedMalloc(hPoolInternal, Size, Alignment);
if (*RetMem == nullptr) {
auto umfRet = umfPoolGetLastAllocationError(hPoolInternal);
return umf2urResult(umfRet);
return umf::umf2urResult(umfRet);
}

if (IndirectAccessTrackingEnabled) {
Expand Down Expand Up @@ -488,7 +460,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urUSMSharedAlloc(
*RetMem = umfPoolAlignedMalloc(hPoolInternal, Size, Alignment);
if (*RetMem == nullptr) {
auto umfRet = umfPoolGetLastAllocationError(hPoolInternal);
return umf2urResult(umfRet);
return umf::umf2urResult(umfRet);
}

if (IndirectAccessTrackingEnabled) {
Expand Down Expand Up @@ -925,7 +897,7 @@ ur_result_t USMFreeHelper(ur_context_handle_t Context, void *Ptr,
auto umfRet = umfPoolFree(hPool, Ptr);
if (IndirectAccessTrackingEnabled)
UR_CALL(ContextReleaseHelper(Context));
return umf2urResult(umfRet);
return umf::umf2urResult(umfRet);
}

UR_APIEXPORT ur_result_t UR_APICALL urUSMImportExp(ur_context_handle_t Context,
Expand Down

0 comments on commit 3af465b

Please sign in to comment.