-
Notifications
You must be signed in to change notification settings - Fork 30
Implementation of GLog #718
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 8 commits into
IntelPython:master
from
vlad-perevezentsev:use_glog
Feb 1, 2022
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
9bc62ab
Implement InitLogger and ShutdownLogger funcs for glog and change err…
vlad-perevezentsev 593af45
Provide DPCTL_ENABLE_GLOG cmake option to turn on logging
vlad-perevezentsev 73951d8
Add glog function argument for build_backend class
vlad-perevezentsev 3fd122b
scripts/build_locally.py supports --glog
oleksandr-pavlyk 971d20a
Fixes for DPCTLService_InitLogger
oleksandr-pavlyk 2f6aaec
Add tests to dpctl._dev.verbose
oleksandr-pavlyk 47c3e9c
Renaming to improve self-descriptiveness.
oleksandr-pavlyk 84e7dc5
Update CONTRIBUTING.md
vlad-perevezentsev 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,80 @@ | ||
# 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. | ||
|
||
# distutils: language = c++ | ||
# cython: language_level=3 | ||
# cython: linetrace=True | ||
|
||
""" Implements developer utilities. | ||
""" | ||
import contextlib | ||
import os | ||
|
||
|
||
cdef extern from "syclinterface/dpctl_service.h": | ||
cdef void DPCTLService_InitLogger(const char *, const char *) | ||
cdef void DPCTLService_ShutdownLogger() | ||
|
||
|
||
def _init_logger(log_dir=None): | ||
"""Initialize logger to use given directory to save logs. | ||
|
||
The call has no effect if `dpctl` was not built to use logger. | ||
""" | ||
cdef bytes p = b"" | ||
cdef const char *app_name = "dpctl" | ||
cdef char *ld_cstr = NULL | ||
if log_dir: | ||
if not os.path.exists(log_dir): | ||
raise ValueError(f"Path {log_dir} does not exist") | ||
if isinstance(log_dir, str): | ||
p = bytes(log_dir, "utf-8") | ||
else: | ||
p = bytes(log_dir) | ||
ld_cstr = <char *>p | ||
DPCTLService_InitLogger(app_name, ld_cstr) | ||
|
||
|
||
def _shutdown_logger(): | ||
"""Finalize logger. | ||
|
||
The call has no effect if `dpctl` was not built to use logger. | ||
""" | ||
DPCTLService_ShutdownLogger() | ||
|
||
|
||
@contextlib.contextmanager | ||
def syclinterface_diagnostics(verbosity="warning", log_dir=None): | ||
"""Context manager that activate verbosity of DPCTLSyclInterface | ||
function calls. | ||
""" | ||
_allowed_verbosity = ["warning", "error"] | ||
if not verbosity in _allowed_verbosity: | ||
raise ValueError( | ||
f"Verbosity argument not understood. " | ||
f"Permitted values are {_allowed_verbosity}" | ||
) | ||
_init_logger(log_dir=log_dir) | ||
_saved_verbosity = os.environ.get("DPCTL_VERBOSITY", None) | ||
os.environ["DPCTL_VERBOSITY"] = verbosity | ||
try: | ||
yield | ||
finally: | ||
_shutdown_logger() | ||
if _saved_verbosity: | ||
os.environ["DPCTL_VERBOSITY"] = _saved_verbosity | ||
else: | ||
del os.environ["DPCTL_VERBOSITY"] |
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
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.