-
Notifications
You must be signed in to change notification settings - Fork 31
Initial stubs for the error handling overhaul. #630
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
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
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,69 @@ | ||
| //===--------- dpctl_elementary_macros.h - Defines helper macros -*-C++-*- ===// | ||
| // | ||
| // Data Parallel Control (dpctl) | ||
| // | ||
| // Copyright 2020-2021 Intel Corporation | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
| /// | ||
| /// \file | ||
| /// Several helper C preprocessor macros used elsewhere in our code are defined | ||
| /// here. | ||
| /// | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #pragma once | ||
|
|
||
| /*! | ||
| * @brief defines a "__declspec(dllexport)" wrapper for windows. | ||
| * | ||
| */ | ||
| #ifdef _WIN32 | ||
| #ifdef DPCTLSyclInterface_EXPORTS | ||
| #define DPCTL_API __declspec(dllexport) | ||
| #else | ||
| #define DPCTL_API __declspec(dllimport) | ||
| #endif | ||
| #else | ||
| #define DPCTL_API | ||
| #endif | ||
|
|
||
| /*! | ||
| * @brief Convenience macros to add "extern C {" statements to headers. | ||
| * | ||
| */ | ||
| #ifdef __cplusplus | ||
| #define DPCTL_C_EXTERN_C_BEGIN \ | ||
| extern "C" \ | ||
| { | ||
| #define DPCTL_C_EXTERN_C_END } | ||
| #else | ||
| #define DPCTL_C_EXTERN_C_BEGIN | ||
| #define DPCTL_C_EXTERN_C_END | ||
| #endif | ||
|
|
||
| /*! | ||
| * @brief Convenience macro to add deprecation attributes to functions. | ||
| * | ||
| */ | ||
| #define DEPRACATION_NOTICE(notice, FN) notice " " #FN | ||
|
|
||
| #if defined(__GNUC__) && !defined(__clang__) | ||
| #define DPCTL_DEPRECATE(msg, repl_fn_name) \ | ||
| __attribute__((deprecated(DEPRACATION_NOTICE(msg, Use repl_fn_name)))) | ||
| #elif defined(__clang__) | ||
| #define DPCTL_DEPRECATE(msg, repl_fn_name) \ | ||
| __attribute__((deprecated(msg, repl_fn_name))) | ||
| #endif | ||
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,101 @@ | ||
| //===- dpctl_exec_state.h - C API for service functions -*-C++-*- ===// | ||
| // | ||
| // Data Parallel Control (dpctl) | ||
| // | ||
| // Copyright 2020-2021 Intel Corporation | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
| /// | ||
| /// \file | ||
| /// The file declares a struct to store dpctl's error handler and other | ||
| /// execution state configurations. | ||
| /// | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #pragma once | ||
|
|
||
| #include "Support/DllExport.h" | ||
| #include "Support/ExternC.h" | ||
| #include "Support/MemOwnershipAttrs.h" | ||
| #include "dpctl_error_handler_type.h" | ||
|
|
||
| DPCTL_C_EXTERN_C_BEGIN | ||
|
|
||
| /*! | ||
| * @brief An opaque type to represent an "execution state" for the dpctl | ||
| * sycl interface library. | ||
| * | ||
| * The execution state controls the behavior of functions exposed by | ||
| * libDPCTLSyclInterface. For now, only error handling is controlled by an | ||
| * execution state. Using a custom execution state, users can define how | ||
| * exceptions in the C++ code are handled and propagated to callers. A default | ||
| * execution state where all exceptions are caught and the error messages | ||
| * printed to ``std::cerr`` is included for convenience. | ||
| * | ||
| */ | ||
| typedef struct DpctlExecutionState *DpctlExecState; | ||
oleksandr-pavlyk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| /*! | ||
| * @brief Create a new ``DpctlExecState`` object. | ||
| * | ||
| * @param handler An error handler function. | ||
| * @return A ``DpctlExecState`` opaque pointer. | ||
| */ | ||
| __dpctl_give DpctlExecState | ||
| dpctl_exec_state_create(error_handler_callback_fn handler); | ||
|
|
||
| /*! | ||
| * @brief Create a default execution state that prints the error message to | ||
| * ``std::cerr``. | ||
| * | ||
| * @return A ``DpctlExecState`` opaque pointer. | ||
| */ | ||
| __dpctl_give DpctlExecState dpctl_exec_state_create_default(); | ||
|
|
||
| /*! | ||
| * @brief Delete an ``DpctlExecState`` opaque pointer. | ||
| * | ||
| * @param DpctlExecState A ``DpctlExecState`` opaque pointer to be freed. | ||
| */ | ||
| void dpctl_exec_state_delete(__dpctl_take DpctlExecState state); | ||
|
|
||
| /*! | ||
| * @brief Get the error handler defined in the ``DpctlExecState`` object. | ||
| * | ||
| * @param state An ``DpctlExecState`` object. | ||
| * @return A error_handler_callback_fn function pointer that was stored inside | ||
| * the DpctlExecState object. | ||
| */ | ||
| error_handler_callback_fn | ||
| dpctl_exec_state_get_error_handler(__dpctl_keep DpctlExecState state); | ||
|
|
||
| /*! | ||
| * @brief Call the error handler defined in the ``DpctlExecState`` object. | ||
| * | ||
| * @param state An ``DpctlExecState`` object. | ||
| * @param err_code An integer error code. | ||
| * @param err_msg A C string corresponding to an error message. | ||
| * @param file_name The file where the error occurred. | ||
| * @param func_name The function name where the error occurred. | ||
| * @param line_num The line number where the error occurred. | ||
| */ | ||
| void dpctl_exec_state_handle_error(__dpctl_keep DpctlExecState state, | ||
| int err_code, | ||
| __dpctl_keep const char *err_msg, | ||
| __dpctl_keep const char *file_name, | ||
| __dpctl_keep const char *func_name, | ||
| int line_num); | ||
|
|
||
| DPCTL_C_EXTERN_C_END | ||
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.