Skip to content

Commit 6c5278f

Browse files
committed
Adjust interfaces after merge
1 parent a4cd814 commit 6c5278f

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

offload/plugins-nextgen/level_zero/include/L0Device.h

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -541,13 +541,14 @@ class L0DeviceTy final : public GenericDeviceTy {
541541
// Allocation related routines
542542

543543
/// Data alloc
544-
void *dataAlloc(size_t Size, size_t Align, int32_t Kind, intptr_t Offset,
545-
bool UserAlloc, bool DevMalloc = false,
546-
uint32_t MemAdvice = UINT32_MAX,
547-
AllocOptionTy AllocOpt = AllocOptionTy::ALLOC_OPT_NONE);
544+
Expected<void *>
545+
dataAlloc(size_t Size, size_t Align, int32_t Kind, intptr_t Offset,
546+
bool UserAlloc, bool DevMalloc = false,
547+
uint32_t MemAdvice = UINT32_MAX,
548+
AllocOptionTy AllocOpt = AllocOptionTy::ALLOC_OPT_NONE);
548549

549550
/// Data delete
550-
int32_t dataDelete(void *Ptr);
551+
Error dataDelete(void *Ptr);
551552

552553
/// Return the memory allocation type for the specified memory location.
553554
uint32_t getMemAllocType(const void *Ptr) const;
@@ -575,8 +576,9 @@ class L0DeviceTy final : public GenericDeviceTy {
575576
loadBinaryImpl(std::unique_ptr<MemoryBuffer> &&TgtImage,
576577
int32_t ImageId) override;
577578
Error unloadBinaryImpl(DeviceImageTy *Image) override;
578-
void *allocate(size_t Size, void *HstPtr, TargetAllocTy Kind) override;
579-
int free(void *TgtPtr, TargetAllocTy Kind = TARGET_ALLOC_DEFAULT) override;
579+
Expected<void *> allocate(size_t Size, void *HstPtr,
580+
TargetAllocTy Kind) override;
581+
Error free(void *TgtPtr, TargetAllocTy Kind = TARGET_ALLOC_DEFAULT) override;
580582

581583
Expected<void *> dataLockImpl(void *HstPtr, int64_t Size) override {
582584
return Plugin::error(error::ErrorCode::UNKNOWN,

offload/plugins-nextgen/level_zero/src/L0Device.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -492,13 +492,14 @@ Error L0DeviceTy::queryAsyncImpl(__tgt_async_info &AsyncInfo) {
492492
return Plugin::success();
493493
}
494494

495-
void *L0DeviceTy::allocate(size_t Size, void *HstPtr, TargetAllocTy Kind) {
495+
Expected<void *> L0DeviceTy::allocate(size_t Size, void *HstPtr,
496+
TargetAllocTy Kind) {
496497
return dataAlloc(Size, /*Align=*/0, Kind,
497498
/*Offset=*/0, /*UserAlloc=*/HstPtr == nullptr,
498499
/*DevMalloc=*/false);
499500
}
500501

501-
int L0DeviceTy::free(void *TgtPtr, TargetAllocTy Kind) {
502+
Error L0DeviceTy::free(void *TgtPtr, TargetAllocTy Kind) {
502503
return dataDelete(TgtPtr);
503504
}
504505

@@ -790,9 +791,10 @@ Error L0DeviceTy::dataFillImpl(void *TgtPtr, const void *PatternPtr,
790791
return Plugin::error(error::ErrorCode::UNKNOWN, "%s failed\n", __func__);
791792
}
792793

793-
void *L0DeviceTy::dataAlloc(size_t Size, size_t Align, int32_t Kind,
794-
intptr_t Offset, bool UserAlloc, bool DevMalloc,
795-
uint32_t MemAdvice, AllocOptionTy AllocOpt) {
794+
Expected<void *> L0DeviceTy::dataAlloc(size_t Size, size_t Align, int32_t Kind,
795+
intptr_t Offset, bool UserAlloc,
796+
bool DevMalloc, uint32_t MemAdvice,
797+
AllocOptionTy AllocOpt) {
796798

797799
const bool UseDedicatedPool =
798800
(AllocOpt == AllocOptionTy::ALLOC_OPT_REDUCTION_SCRATCH) ||
@@ -812,9 +814,9 @@ void *L0DeviceTy::dataAlloc(size_t Size, size_t Align, int32_t Kind,
812814
MemAdvice, AllocOpt);
813815
}
814816

815-
int32_t L0DeviceTy::dataDelete(void *Ptr) {
817+
Error L0DeviceTy::dataDelete(void *Ptr) {
816818
auto &Allocator = getMemAllocator(Ptr);
817-
return Allocator.dealloc(Ptr);
819+
return Plugin::check(Allocator.dealloc(Ptr), "Error deleting ptr");
818820
}
819821

820822
int32_t L0DeviceTy::makeMemoryResident(void *Mem, size_t Size) {

0 commit comments

Comments
 (0)