Files
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

157 lines
9.4 KiB
C++

//===--- Level Zero Target RTL Implementation -----------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// Code for tracing L0.
//
//===----------------------------------------------------------------------===//
// clang-format off
#ifndef OPENMP_LIBOMPTARGET_PLUGINS_NEXTGEN_LEVEL_ZERO_L0TRACE_H
#define OPENMP_LIBOMPTARGET_PLUGINS_NEXTGEN_LEVEL_ZERO_L0TRACE_H
#include "Shared/Debug.h"
#include "omptarget.h"
#include <string>
#include <level_zero/ze_api.h>
using namespace llvm::offload::debug;
#define CALL_ZE(Rc, Fn, ...) \
do { \
Rc = Fn(__VA_ARGS__); \
} while (0)
/// For non-thread-safe functions.
#define CALL_ZE_RET_MTX(Ret, Fn, Mtx, ...) \
do { \
Mtx.lock(); \
ze_result_t rc; \
CALL_ZE(rc, Fn, __VA_ARGS__); \
Mtx.unlock(); \
if (rc != ZE_RESULT_SUCCESS) { \
ODBG(OLDT_Error) << "Error: " << #Fn << " failed with error code " \
<< rc << ", " << getZeErrorName(rc); \
return Ret; \
} \
} while (0)
#define CALL_ZE_RET_ERROR_MTX(Fn, Mtx, ...) \
CALL_ZE_RET_MTX( \
Plugin::error(ErrorCode::UNKNOWN, "%s failed with error %d, %s", \
#Fn, rc, getZeErrorName(rc)), Fn, Mtx, __VA_ARGS__)
/// For thread-safe functions.
#define CALL_ZE_RET(Ret, Fn, ...) \
do { \
ze_result_t rc; \
CALL_ZE(rc, Fn, __VA_ARGS__); \
if (rc != ZE_RESULT_SUCCESS) { \
ODBG(OLDT_Error) << "Error: " << #Fn << " failed with error code " \
<< rc << ", " << getZeErrorName(rc); \
return Ret; \
} \
} while (0)
#define CALL_ZE_RET_ERROR(Fn, ...) \
CALL_ZE_RET( \
Plugin::error(ErrorCode::UNKNOWN, "%s failed with error %d, %s", \
#Fn, rc, getZeErrorName(rc)), Fn, __VA_ARGS__)
#define CALL_ZE_SILENT(Fn, ...) \
do { \
ze_result_t rc; \
CALL_ZE(rc, Fn, __VA_ARGS__); \
(void)rc; /* Silence unused variable warning. */ \
} while (0)
#define CALL_ZE_HANDLE_ERROR(HandleErrFn, Fn, ...) \
do { \
ze_result_t rc; \
CALL_ZE(rc, Fn, __VA_ARGS__); \
if (rc != ZE_RESULT_SUCCESS) { \
HandleErrFn(Plugin::error(ErrorCode::UNKNOWN, "%s failed with error %d," \
" %s", #Fn, rc, getZeErrorName(rc))); \
} \
} while (0)
#define CALL_ZE_ACCUM_ERROR(Err, Fn, ...) \
do { \
ze_result_t rc; \
CALL_ZE(rc, Fn, __VA_ARGS__); \
if (rc != ZE_RESULT_SUCCESS) { \
Err = joinErrors(std::move(Err), \
Plugin::error(ErrorCode::UNKNOWN, "%s failed with error %d," \
" %s", #Fn, rc, getZeErrorName(rc))); \
} \
} while (0)
#define CALL_ZE_EXT_SILENT_RET(Device, Ret, Name, ...) \
do { \
ze_result_t rc; \
CALL_ZE_EXT_SILENT(Device, rc, Name, __VA_ARGS__); \
if (rc != ZE_RESULT_SUCCESS) \
return Ret; \
} while (0)
#define CALL_ZE_EXT_RET_ERROR(Device, Name, ...) \
CALL_ZE_EXT_SILENT_RET(Device, \
Plugin::error(ErrorCode::UNKNOWN, "%s failed with code %d, %s", \
#Name, rc, getZeErrorName(rc)), Name, __VA_ARGS__)
#define FOREACH_ZE_ERROR_CODE(Fn) \
Fn(ZE_RESULT_SUCCESS) \
Fn(ZE_RESULT_NOT_READY) \
Fn(ZE_RESULT_ERROR_DEVICE_LOST) \
Fn(ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY) \
Fn(ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY) \
Fn(ZE_RESULT_ERROR_MODULE_BUILD_FAILURE) \
Fn(ZE_RESULT_ERROR_MODULE_LINK_FAILURE) \
Fn(ZE_RESULT_ERROR_DEVICE_REQUIRES_RESET) \
Fn(ZE_RESULT_ERROR_DEVICE_IN_LOW_POWER_STATE) \
Fn(ZE_RESULT_ERROR_INSUFFICIENT_PERMISSIONS) \
Fn(ZE_RESULT_ERROR_NOT_AVAILABLE) \
Fn(ZE_RESULT_ERROR_DEPENDENCY_UNAVAILABLE) \
Fn(ZE_RESULT_WARNING_DROPPED_DATA) \
Fn(ZE_RESULT_ERROR_UNINITIALIZED) \
Fn(ZE_RESULT_ERROR_UNSUPPORTED_VERSION) \
Fn(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) \
Fn(ZE_RESULT_ERROR_INVALID_ARGUMENT) \
Fn(ZE_RESULT_ERROR_INVALID_NULL_HANDLE) \
Fn(ZE_RESULT_ERROR_HANDLE_OBJECT_IN_USE) \
Fn(ZE_RESULT_ERROR_INVALID_NULL_POINTER) \
Fn(ZE_RESULT_ERROR_INVALID_SIZE) \
Fn(ZE_RESULT_ERROR_UNSUPPORTED_SIZE) \
Fn(ZE_RESULT_ERROR_UNSUPPORTED_ALIGNMENT) \
Fn(ZE_RESULT_ERROR_INVALID_SYNCHRONIZATION_OBJECT) \
Fn(ZE_RESULT_ERROR_INVALID_ENUMERATION) \
Fn(ZE_RESULT_ERROR_UNSUPPORTED_ENUMERATION) \
Fn(ZE_RESULT_ERROR_UNSUPPORTED_IMAGE_FORMAT) \
Fn(ZE_RESULT_ERROR_INVALID_NATIVE_BINARY) \
Fn(ZE_RESULT_ERROR_INVALID_GLOBAL_NAME) \
Fn(ZE_RESULT_ERROR_INVALID_KERNEL_NAME) \
Fn(ZE_RESULT_ERROR_INVALID_FUNCTION_NAME) \
Fn(ZE_RESULT_ERROR_INVALID_GROUP_SIZE_DIMENSION) \
Fn(ZE_RESULT_ERROR_INVALID_GLOBAL_WIDTH_DIMENSION) \
Fn(ZE_RESULT_ERROR_INVALID_KERNEL_ARGUMENT_INDEX) \
Fn(ZE_RESULT_ERROR_INVALID_KERNEL_ARGUMENT_SIZE) \
Fn(ZE_RESULT_ERROR_INVALID_KERNEL_ATTRIBUTE_VALUE) \
Fn(ZE_RESULT_ERROR_INVALID_MODULE_UNLINKED) \
Fn(ZE_RESULT_ERROR_INVALID_COMMAND_LIST_TYPE) \
Fn(ZE_RESULT_ERROR_OVERLAPPING_REGIONS) \
Fn(ZE_RESULT_WARNING_ACTION_REQUIRED) \
Fn(ZE_RESULT_ERROR_UNKNOWN)
#define CASE_TO_STRING(Num) case Num: return #Num;
inline const char *getZeErrorName(int32_t Error) {
switch (Error) {
FOREACH_ZE_ERROR_CODE(CASE_TO_STRING)
default:
return "ZE_RESULT_ERROR_UNKNOWN";
}
}
#endif // OPENMP_LIBOMPTARGET_PLUGINS_NEXTGEN_LEVEL_ZERO_L0TRACE_H