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

IntelPython / dpctl / 14754782295

30 Apr 2025 12:39PM UTC coverage: 86.419%. Remained the same
14754782295

Pull #2068

github

web-flow
Merge c8700ceb2 into b7a6b67c7
Pull Request #2068: Correct a path to `cl.cfg` file

3020 of 3716 branches covered (81.27%)

Branch coverage included in aggregate %.

12195 of 13890 relevant lines covered (87.8%)

6998.91 hits per line

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

79.37
/libsyclinterface/source/dpctl_sycl_device_selector_interface.cpp
1
//=== dpctl_sycl_device_selector_interface.cpp -  device_selector C API    ===//
2
//
3
//                      Data Parallel Control (dpctl)
4
//
5
// Copyright 2020-2025 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
/// Implements constructors for SYCL's device selector classes.
23
///
24
//===----------------------------------------------------------------------===//
25

26
#include "dpctl_sycl_device_selector_interface.h"
27
#include "Config/dpctl_config.h"
28
#include "dpctl_device_selection.hpp"
29
#include "dpctl_error_handlers.h"
30
#include "dpctl_sycl_type_casters.hpp"
31
#include <sycl/sycl.hpp> /* SYCL headers   */
32

33
using namespace sycl;
34

35
namespace
36
{
37
static_assert(__SYCL_COMPILER_VERSION >= __SYCL_COMPILER_VERSION_REQUIRED,
38
              "The compiler does not meet minimum version requirement");
39

40
using namespace dpctl::syclinterface;
41
} // end of anonymous namespace
42

43
__dpctl_give DPCTLSyclDeviceSelectorRef DPCTLAcceleratorSelector_Create()
44
{
165✔
45
    try {
165✔
46
        auto Selector = new dpctl_accelerator_selector();
165✔
47
        return wrap<dpctl_device_selector>(Selector);
165✔
48
    } catch (std::exception const &e) {
165✔
49
        error_handler(e, __FILE__, __func__, __LINE__);
×
50
        return nullptr;
×
51
    }
×
52
}
165✔
53

54
__dpctl_give DPCTLSyclDeviceSelectorRef DPCTLDefaultSelector_Create()
55
{
14,828✔
56
    try {
14,828✔
57
        auto Selector = new dpctl_default_selector();
14,828✔
58
        return wrap<dpctl_device_selector>(Selector);
14,828✔
59
    } catch (std::exception const &e) {
14,828✔
60
        error_handler(e, __FILE__, __func__, __LINE__);
×
61
        return nullptr;
×
62
    }
×
63
}
14,828✔
64

65
__dpctl_give DPCTLSyclDeviceSelectorRef DPCTLCPUSelector_Create()
66
{
166✔
67
    try {
166✔
68
        auto Selector = new dpctl_cpu_selector();
166✔
69
        return wrap<dpctl_device_selector>(Selector);
166✔
70
    } catch (std::exception const &e) {
166✔
71
        error_handler(e, __FILE__, __func__, __LINE__);
×
72
        return nullptr;
×
73
    }
×
74
}
166✔
75

76
__dpctl_give DPCTLSyclDeviceSelectorRef
77
DPCTLFilterSelector_Create(__dpctl_keep const char *filter_str)
78
{
6,035✔
79
    using filter_selector_t = dpctl_filter_selector;
6,035✔
80
    try {
6,035✔
81
        auto Selector = new filter_selector_t(filter_str);
6,035✔
82
        return wrap<dpctl_device_selector>(Selector);
6,035✔
83
    } catch (std::exception const &e) {
6,035✔
84
        error_handler(e, __FILE__, __func__, __LINE__);
59✔
85
        return nullptr;
59✔
86
    }
59✔
87
}
6,035✔
88

89
__dpctl_give DPCTLSyclDeviceSelectorRef DPCTLGPUSelector_Create()
90
{
166✔
91
    try {
166✔
92
        auto Selector = new dpctl_gpu_selector();
166✔
93
        return wrap<dpctl_device_selector>(Selector);
166✔
94
    } catch (std::exception const &e) {
166✔
95
        error_handler(e, __FILE__, __func__, __LINE__);
×
96
        return nullptr;
×
97
    }
×
98
}
166✔
99

100
int DPCTLDeviceSelector_Score(__dpctl_keep DPCTLSyclDeviceSelectorRef DSRef,
101
                              __dpctl_keep DPCTLSyclDeviceRef DRef)
102
{
219✔
103
    constexpr int REJECT_DEVICE_SCORE = -1;
219✔
104
    if (DSRef && DRef) {
219!
105
        auto dev = *(unwrap<device>(DRef));
218✔
106
        return (*unwrap<dpctl_device_selector>(DSRef))(dev);
218✔
107
    }
218✔
108
    else
1✔
109
        return REJECT_DEVICE_SCORE;
1✔
110
}
219✔
111

112
void DPCTLDeviceSelector_Delete(__dpctl_take DPCTLSyclDeviceSelectorRef DSRef)
113
{
21,357✔
114
    auto Selector = unwrap<dpctl_device_selector>(DSRef);
21,357✔
115
    delete Selector;
21,357✔
116
}
21,357✔
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

© 2025 Coveralls, Inc