• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

IntelPython / dpctl / 27701703901

17 Jun 2026 03:50PM UTC coverage: 75.692% (+0.06%) from 75.632%
27701703901

Pull #2250

github

web-flow
Merge 8bddb1174 into ba47162ef
Pull Request #2250: Remove `python-gil` requirement and enable free-threaded Python

833 of 1156 branches covered (72.06%)

Branch coverage included in aggregate %.

21 of 22 new or added lines in 2 files covered. (95.45%)

5 existing lines in 2 files now uncovered.

3243 of 4229 relevant lines covered (76.68%)

274.6 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

74.07
/libsyclinterface/helper/source/dpctl_error_handlers.cpp
1
//===-- dpctl_async_error_handler.h - An async error handler     -*-C++-*- ===//
2
//
3
//                      Data Parallel Control (dpctl)
4
//
5
// Copyright 2021 Intel Corporation
6
//
7
// Licensed under the Apache License, Version 2.0 (the "License");
8
// you may not use this file except in compliance with the License.
9
// You may obtain a copy of the License at
10
//
11
//    http://www.apache.org/licenses/LICENSE-2.0
12
//
13
// Unless required by applicable law or agreed to in writing, software
14
// distributed under the License is distributed on an "AS IS" BASIS,
15
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
// See the License for the specific language governing permissions and
17
// limitations under the License.
18
//
19
//===----------------------------------------------------------------------===//
20
///
21
/// \file
22
/// A functor to use for passing an error handler callback function to sycl
23
/// context and queue constructors.
24
//===----------------------------------------------------------------------===//
25

26
#include "dpctl_error_handlers.h"
27
#include "dpctl_service.h"
28
#include <cstring>
29
#include <sstream>
30
#ifdef _WIN32
31
#include <cstdlib>
32
#include <stddef.h>
33
#endif
34
#ifdef ENABLE_GLOG
35
#include <glog/logging.h>
36
#endif
37

38
void DPCTL_AsyncErrorHandler::operator()(const sycl::exception_list &exceptions)
UNCOV
39
{
×
40
    for (std::exception_ptr const &e : exceptions) {
×
41
        try {
×
42
            std::rethrow_exception(e);
×
43
        } catch (sycl::exception const &e) {
×
44
            error_handler(e, __FILE__, __func__, __LINE__);
×
45
            auto err_code = e.code().value();
×
46
            handler_(static_cast<int>(err_code));
×
47
        }
×
48
    }
×
49
}
×
50

51
namespace
52
{
53
int requested_verbosity_level(void)
54
{
3,890✔
55
    char *verbose = nullptr;
3,890✔
56

57
#ifdef _WIN32
58
    size_t len = 0;
59
    _dupenv_s(&verbose, &len, "DPCTL_VERBOSITY");
60
#else
61
    verbose = std::getenv("DPCTL_VERBOSITY");
3,890✔
62
#endif
3,890✔
63

64
    int requested_level = 0;
3,890✔
65

66
    if (verbose) {
3,890✔
67
        if (!std::strncmp(verbose, "none", 4))
2,026!
UNCOV
68
            requested_level = error_level::none;
×
69
        else if (!std::strncmp(verbose, "error", 5))
2,026!
UNCOV
70
            requested_level = error_level::error;
×
71
        else if (!std::strncmp(verbose, "warning", 7))
2,026!
72
            requested_level = error_level::warning;
2,026✔
73
    }
2,026✔
74

75
#ifdef _WIN32
76
    if (verbose)
77
        free(verbose);
78
#endif
79

80
    return requested_level;
3,890✔
81
}
3,890✔
82

83
void output_message(std::string ss_str, error_level error_type)
84
{
2,026✔
85
#ifdef ENABLE_GLOG
86
    switch (error_type) {
87
    case error_level::error:
88
        LOG(ERROR) << "[ERR] " << ss_str;
89
        break;
90
    case error_level::warning:
91
        LOG(WARNING) << "[WARN] " << ss_str;
92
        break;
93
    default:
94
        LOG(FATAL) << "[FATAL] " << ss_str;
95
    }
96
#else
97
    switch (error_type) {
2,026✔
98
    case error_level::error:
1,620✔
99
        std::cerr << "[ERR] " << ss_str;
1,620✔
100
        break;
1,620✔
101
    case error_level::warning:
406✔
102
        std::cerr << "[WARN] " << ss_str;
406✔
103
        break;
406✔
UNCOV
104
    default:
×
105
        std::cerr << "[FATAL] " << ss_str;
×
106
    }
2,026✔
107
#endif
2,026✔
108
}
2,026✔
109

110
} // namespace
111

112
void error_handler(const std::exception &e,
113
                   const char *file_name,
114
                   const char *func_name,
115
                   int line_num,
116
                   error_level error_type)
117
{
3,448✔
118
    int requested_level = requested_verbosity_level();
3,448✔
119
    int error_level = static_cast<int>(error_type);
3,448✔
120

121
    bool to_output = requested_level >= error_level;
3,448✔
122

123
    if (to_output) {
3,448✔
124
        std::stringstream ss;
1,619✔
125
        ss << e.what() << " in " << func_name << " at " << file_name << ":"
1,619✔
126
           << line_num << std::endl;
1,619✔
127

128
        output_message(ss.str(), error_type);
1,619✔
129
    }
1,619✔
130
}
3,448✔
131

132
void error_handler(const std::string &what,
133
                   const char *file_name,
134
                   const char *func_name,
135
                   int line_num,
136
                   error_level error_type)
137
{
442✔
138
    int requested_level = requested_verbosity_level();
442✔
139
    int error_level = static_cast<int>(error_type);
442✔
140

141
    bool to_output = requested_level >= error_level;
442✔
142

143
    if (to_output) {
442✔
144
        std::stringstream ss;
407✔
145
        ss << what << " in " << func_name << " at " << file_name << ":"
407✔
146
           << line_num << std::endl;
407✔
147

148
        output_message(ss.str(), error_type);
407✔
149
    }
407✔
150
}
442✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc