-
Notifications
You must be signed in to change notification settings - Fork 32
Implement error_handler function in libsyclinterface/helper #683
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
Merged
oleksandr-pavlyk
merged 15 commits into
IntelPython:master
from
vlad-perevezentsev:error_handler
Dec 1, 2021
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
f31c30c
Implemented error_handler func
vlad-perevezentsev b1b89cd
Use error_handler in dpctl_sycl_platform_interface
vlad-perevezentsev 504d798
Use eror_handler in dpctl_sycl_context_interface
vlad-perevezentsev 380c54d
Use error_handler in dpctl_sycl_device_interface
vlad-perevezentsev 033dac0
Use error_handler in dpctl_sycl_device_manager
vlad-perevezentsev 0d10f0c
Use error_handler in dpctl_sycl_device_selector_interface
vlad-perevezentsev 0a2c1dc
Use error_handler in dpctl_sycl_event_interface
vlad-perevezentsev 36e0aec
Use error_handler in dpctl_sycl_kernel_interface
vlad-perevezentsev 90aab6e
Use error_handler in dpctl_sycl_platform_manager
vlad-perevezentsev cfa5a05
Use error_handler in dpctl_sycl_usm_interface
vlad-perevezentsev 8562e67
Use error_handler in dpctl_vector_templ
vlad-perevezentsev 8bdec8c
Use eror_handler in dpctl_sycl_program_interface
vlad-perevezentsev 4cd9164
Use eror_handler in dpctl_sycl_queue_interface
vlad-perevezentsev 4b1700e
Use error_handler in dpctl_sycl_queue_manager.cpp
oleksandr-pavlyk 3e0c061
Removed uses of deprecated exception
oleksandr-pavlyk 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
42 changes: 0 additions & 42 deletions
42
libsyclinterface/helper/source/dpctl_async_error_handler.cpp
This file was deleted.
Oops, something went wrong.
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,89 @@ | ||
| //===-- dpctl_async_error_handler.h - An async error handler -*-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 | ||
| /// A functor to use for passing an error handler callback function to sycl | ||
| /// context and queue contructors. | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "dpctl_error_handlers.h" | ||
| #include <cstring> | ||
|
|
||
| void DPCTL_AsyncErrorHandler::operator()( | ||
| const cl::sycl::exception_list &exceptions) | ||
| { | ||
| for (std::exception_ptr const &e : exceptions) { | ||
| try { | ||
| std::rethrow_exception(e); | ||
| } catch (sycl::exception const &e) { | ||
| error_handler(e, __FILE__, __func__, __LINE__); | ||
| auto err_code = e.get_cl_code(); | ||
| handler_(static_cast<int>(err_code)); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| inline int get_requested_level(void) | ||
| { | ||
| int requested_level = 0; | ||
|
|
||
| const char *verbose = std::getenv("DPCTL_VERBOSITY"); | ||
|
|
||
| if (verbose) { | ||
| if (!strncmp(verbose, "none", 4)) | ||
| requested_level = error_level::none; | ||
| else if (!strncmp(verbose, "error", 5)) | ||
| requested_level = error_level::error; | ||
| else if (!strncmp(verbose, "warning", 7)) | ||
| requested_level = error_level::warning; | ||
| } | ||
|
|
||
| return requested_level; | ||
| } | ||
|
|
||
| void error_handler(const std::exception &e, | ||
| const char *file_name, | ||
| const char *func_name, | ||
| int line_num, | ||
| error_level error_type) | ||
| { | ||
| int requested_level = get_requested_level(); | ||
| int error_level = static_cast<int>(error_type); | ||
|
|
||
| if (requested_level <= error_level) { | ||
| std::cerr << e.what() << " in " << func_name << " at " << file_name | ||
| << ":" << line_num << std::endl; | ||
| } | ||
| } | ||
|
|
||
| void error_handler(const std::string &what, | ||
| const char *file_name, | ||
| const char *func_name, | ||
| int line_num, | ||
| error_level error_type) | ||
| { | ||
| int error_level = static_cast<int>(error_type); | ||
| int requested_level = get_requested_level(); | ||
|
|
||
| if (requested_level <= error_level) { | ||
| std::cerr << what << " In " << func_name << " at " << file_name << ":" | ||
| << line_num << std::endl; | ||
| } | ||
| } |
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
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.
Uh oh!
There was an error while loading. Please reload this page.