-
Notifications
You must be signed in to change notification settings - Fork 13.4k
[Offload] Add Error Codes to PluginInterface #138258
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
RossBrunton
wants to merge
4
commits into
llvm:main
Choose a base branch
from
RossBrunton:errcodes
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+291
−92
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
6ebda46
[Offload] Add Error Codes to PluginInterface
RossBrunton 5850cb9
[Offload] Don't partition error code enum into categories
RossBrunton e8e6651
[Offload] Follow other LLVM error code handling
RossBrunton 06d962a
[Offload] Respond to feedback and fix extra definition
RossBrunton File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
//===- Auto-generated file, part of the LLVM/Offload project --------------===// | ||
// | ||
// 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 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef OFFLOAD_ERRC | ||
#error Please define the macro OFFLOAD_ERRCODE(Name, Desc, Value) | ||
#endif | ||
|
||
// Error codes are shared between PluginInterface and liboffload. | ||
// To add new error codes, add them to offload/liboffload/API/Common.td and run | ||
// the GenerateOffload target. | ||
|
||
OFFLOAD_ERRC(SUCCESS, "Success", 0) | ||
OFFLOAD_ERRC(UNKNOWN, "Unknown or internal error", 1) | ||
OFFLOAD_ERRC(INVALID_NULL_POINTER, | ||
"A pointer argument is null when it should not be", 2) | ||
OFFLOAD_ERRC(INVALID_ARGUMENT, "An argument is invalid", 3) | ||
OFFLOAD_ERRC(OUT_OF_RESOURCES, "Out of resources", 4) | ||
OFFLOAD_ERRC(UNSUPPORTED, | ||
"generic error code for unsupported features and enums", 5) | ||
OFFLOAD_ERRC( | ||
INVALID_SIZE, | ||
"invalid size or dimensions (e.g., must not be zero, or is out of bounds)", | ||
6) | ||
OFFLOAD_ERRC(INVALID_ENUMERATION, "enumerator argument is not valid", 7) | ||
OFFLOAD_ERRC(INVALID_KERNEL_NAME, | ||
"Named kernel not found in the program binary", 8) | ||
OFFLOAD_ERRC(INVALID_VALUE, "Invalid Value", 9) | ||
OFFLOAD_ERRC(INVALID_PLATFORM, "Invalid platform", 10) | ||
OFFLOAD_ERRC(INVALID_DEVICE, "Invalid device", 11) | ||
OFFLOAD_ERRC(INVALID_QUEUE, "Invalid queue", 12) | ||
OFFLOAD_ERRC(INVALID_EVENT, "Invalid event", 13) | ||
OFFLOAD_ERRC(INVALID_NULL_HANDLE, "handle argument is not valid", 14) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
set(LIBOFFLOAD_ROOT "${CMAKE_CURRENT_SOURCE_DIR}") | ||
|
||
add_subdirectory(API) | ||
|
||
add_llvm_library( | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
//===- OffloadError.h - Definition of error class -------------------------===// | ||
// | ||
// 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 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef OPENMP_LIBOMPTARGET_PLUGINS_NEXTGEN_COMMON_OFFLOAD_ERROR_H | ||
#define OPENMP_LIBOMPTARGET_PLUGINS_NEXTGEN_COMMON_OFFLOAD_ERROR_H | ||
|
||
#include "llvm/Support/Error.h" | ||
#include "llvm/Support/ErrorHandling.h" | ||
|
||
namespace llvm { | ||
namespace omp { | ||
namespace target { | ||
namespace plugin { | ||
|
||
enum class ErrorCode { | ||
#define OFFLOAD_ERRC(Name, _, Value) Name = Value, | ||
#include "Shared/OffloadErrcodes.inc" | ||
#undef OFFLOAD_ERRC | ||
}; | ||
|
||
} // namespace plugin | ||
} // namespace target | ||
} // namespace omp | ||
} // namespace llvm | ||
|
||
namespace std { | ||
template <> | ||
struct is_error_code_enum<llvm::omp::target::plugin::ErrorCode> | ||
: std::true_type {}; | ||
} // namespace std | ||
|
||
namespace llvm { | ||
namespace omp { | ||
namespace target { | ||
namespace plugin { | ||
|
||
const std::error_category &OffloadErrCategory(); | ||
|
||
inline std::error_code make_error_code(ErrorCode E) { | ||
return std::error_code(static_cast<int>(E), OffloadErrCategory()); | ||
} | ||
|
||
/// Base class for errors originating in DIA SDK, e.g. COM calls | ||
class OffloadError : public ErrorInfo<OffloadError, StringError> { | ||
public: | ||
using ErrorInfo<OffloadError, StringError>::ErrorInfo; | ||
|
||
OffloadError(const Twine &S) : ErrorInfo(S, ErrorCode::UNKNOWN) {} | ||
|
||
static char ID; | ||
}; | ||
} // namespace plugin | ||
} // namespace target | ||
} // namespace omp | ||
} // namespace llvm | ||
|
||
#endif |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change isn't part of this MR, but I assume a previous update to the comments didn't get regen-ed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that's my bad. If we continue to check in the generated files it would be useful to have CI catch this by checking there's no diff after regenerating.