Skip to content

Commit 91f1033

Browse files
committed
Remove legacy error checking Pt 1
1 parent b7e95ab commit 91f1033

File tree

7 files changed

+234
-278
lines changed

7 files changed

+234
-278
lines changed

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

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -258,12 +258,6 @@ class L0DeviceTy final : public GenericDeviceTy {
258258
/// The current size of the global device memory pool (managed by us).
259259
uint64_t HeapSize = 1L << 23L /*8MB=*/;
260260

261-
int32_t synchronize(__tgt_async_info *AsyncInfo, bool ReleaseQueue = true);
262-
int32_t submitData(void *TgtPtr, const void *HstPtr, int64_t Size,
263-
__tgt_async_info *AsyncInfo);
264-
int32_t retrieveData(void *HstPtr, const void *TgtPtr, int64_t Size,
265-
__tgt_async_info *AsyncInfo);
266-
267261
bool shouldSetupDeviceMemoryPool() const override { return false; }
268262
DeviceArchTy computeArch() const;
269263

@@ -336,13 +330,12 @@ class L0DeviceTy final : public GenericDeviceTy {
336330
return nullptr;
337331
}
338332

339-
int32_t buildAllKernels() {
333+
Error buildAllKernels() {
340334
for (auto &PGM : Programs) {
341-
int32_t RC = PGM.loadModuleKernels();
342-
if (RC != OFFLOAD_SUCCESS)
343-
return RC;
335+
if (auto Err = PGM.loadModuleKernels())
336+
return Err;
344337
}
345-
return OFFLOAD_SUCCESS;
338+
return Plugin::success();
346339
}
347340

348341
// add a new program to the device. Return a reference to the new program
@@ -488,17 +481,17 @@ class L0DeviceTy final : public GenericDeviceTy {
488481
ze_command_list_handle_t getImmCopyCmdList();
489482

490483
/// Enqueue copy command
491-
int32_t enqueueMemCopy(void *Dst, const void *Src, size_t Size,
492-
__tgt_async_info *AsyncInfo = nullptr,
493-
bool UseCopyEngine = true);
484+
Error enqueueMemCopy(void *Dst, const void *Src, size_t Size,
485+
__tgt_async_info *AsyncInfo = nullptr,
486+
bool UseCopyEngine = true);
494487

495488
/// Enqueue asynchronous copy command
496-
int32_t enqueueMemCopyAsync(void *Dst, const void *Src, size_t Size,
497-
__tgt_async_info *AsyncInfo, bool CopyTo = true);
489+
Error enqueueMemCopyAsync(void *Dst, const void *Src, size_t Size,
490+
__tgt_async_info *AsyncInfo, bool CopyTo = true);
498491

499492
/// Enqueue fill command
500-
int32_t enqueueMemFill(void *Ptr, const void *Pattern, size_t PatternSize,
501-
size_t Size);
493+
Error enqueueMemFill(void *Ptr, const void *Pattern, size_t PatternSize,
494+
size_t Size);
502495

503496
/// Driver related functions
504497

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -388,10 +388,10 @@ class MemAllocatorTy {
388388
}
389389

390390
/// Perform copy operation
391-
int32_t enqueueMemCopy(void *Dst, const void *Src, size_t Size);
391+
Error enqueueMemCopy(void *Dst, const void *Src, size_t Size);
392392

393393
/// Perform memory fill operation
394-
int32_t enqueueMemSet(void *Dst, int8_t Value, size_t Size);
394+
Error enqueueMemSet(void *Dst, int8_t Value, size_t Size);
395395

396396
}; /// MemAllocatorTy
397397

@@ -517,7 +517,7 @@ class StagingBufferTy {
517517
StagingBufferTy &operator=(const StagingBufferTy &) = delete;
518518
StagingBufferTy &operator=(const StagingBufferTy &&) = delete;
519519

520-
~StagingBufferTy() { }
520+
~StagingBufferTy() {}
521521

522522
void clear() {
523523
ze_result_t Rc;

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

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ class L0ProgramTy : public DeviceImageTy {
5656
bool IsLibModule = false;
5757

5858
/// Build a single module with the given image, build option, and format.
59-
int32_t addModule(const size_t Size, const uint8_t *Image,
60-
const std::string_view BuildOption,
61-
ze_module_format_t Format);
59+
Error addModule(const size_t Size, const uint8_t *Image,
60+
const std::string_view BuildOption,
61+
ze_module_format_t Format);
6262
/// Read file and return the size of the binary if successful.
6363
size_t readFile(const char *FileName, std::vector<uint8_t> &OutFile) const;
6464
void replaceDriverOptsWithBackendOpts(const L0DeviceTy &Device,
@@ -89,22 +89,21 @@ class L0ProgramTy : public DeviceImageTy {
8989
}
9090

9191
/// Build modules from the target image description
92-
int32_t buildModules(const std::string_view BuildOptions);
92+
Error buildModules(const std::string_view BuildOptions);
9393

9494
/// Link modules stored in \p Modules.
95-
int32_t linkModules();
95+
Error linkModules();
9696

9797
/// Loads the kernels names from all modules
98-
int32_t loadModuleKernels();
98+
Error loadModuleKernels();
9999

100100
/// Read data from the location in the device image which corresponds to the
101101
/// specified global variable name.
102-
int32_t readGlobalVariable(const char *Name, size_t Size, void *HostPtr);
102+
Error readGlobalVariable(const char *Name, size_t Size, void *HostPtr);
103103

104104
/// Write data to the location in the device image which corresponds to the
105105
/// specified global variable name.
106-
int32_t writeGlobalVariable(const char *Name, size_t Size,
107-
const void *HostPtr);
106+
Error writeGlobalVariable(const char *Name, size_t Size, const void *HostPtr);
108107

109108
/// Looks up an OpenMP declare target global variable with the given
110109
/// \p Name and \p Size in the device environment for the current device.

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@
7070
CALL_ZE_RET_MTX(NULL, Fn, Mtx, __VA_ARGS__)
7171
#define CALL_ZE_RET_ZERO_MTX(Fn, Mtx, ...) \
7272
CALL_ZE_RET_MTX(0, Fn, Mtx, __VA_ARGS__)
73+
#define CALL_ZE_RET_ERROR_MTX(Fn, Mtx, ...) \
74+
CALL_ZE_RET_MTX( \
75+
Plugin::error(ErrorCode::UNKNOWN, "%s failed with error %d, %s", \
76+
STR(Fn), rc, getZeErrorName(rc)), Fn, Mtx, __VA_ARGS__)
77+
7378

7479
/// For thread-safe functions
7580
#define CALL_ZE_RET(Ret, Fn, ...) \

0 commit comments

Comments
 (0)