Skip to content

[SYCL] Coverity bug fix #10446

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
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
d48a512
[SYCL] change the behavior of sycl::maximum and sycl::minimum to be c…
Jun 27, 2023
a1c1205
[SYCL] change the behavior of sycl::maximum and sycl::minimum to be c…
eunakim0103 Jun 28, 2023
6aaf3c9
[SYCL] change the behavior of sycl::maximum and sycl::minimum to be c…
eunakim0103 Jun 28, 2023
000adf4
[SYCL] change the behavior of sycl::maximum and sycl::minimum to be c…
eunakim0103 Jun 28, 2023
84ae02b
[SYCL] change the behavior of sycl::maximum and sycl::minimum to be c…
eunakim0103 Jun 29, 2023
58907b0
[SYCL] change the behavior of sycl::maximum and sycl::minimum to be c…
eunakim0103 Jun 29, 2023
faa7c2a
Merge remote-tracking branch 'intel/sycl' into sycl_min_max
eunakim0103 Jun 29, 2023
65f7461
Merge remote-tracking branch 'intel/sycl' into sycl_min_max
eunakim0103 Jun 29, 2023
740ab1b
change the execution command in lit test file
eunakim0103 Jul 6, 2023
1ec6361
change the RUN parameter in the lit test file
eunakim0103 Jul 6, 2023
de9f2e6
fix the binary generation for the lit test and fixed comment
eunakim0103 Jul 13, 2023
3d161a9
removing -fsyntax-only from command
eunakim0103 Jul 13, 2023
6d857c0
fixed comments and format
eunakim0103 Jul 14, 2023
e8012fb
fixed to follow the SYCL2020 namespace standard
eunakim0103 Jul 14, 2023
5c94421
fixed the order in including headers
eunakim0103 Jul 14, 2023
a8659a2
improved the header includes
eunakim0103 Jul 14, 2023
0849b53
Coverity - Copy without assign issues
eunakim0103 Jul 18, 2023
307af96
Coverity - logically dead code removal
eunakim0103 Jul 18, 2023
ff218d8
Coverity - Missing assignment operator issues fixed
eunakim0103 Jul 18, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions sycl/include/sycl/functional.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,36 +35,39 @@ template <typename T = void> struct logical_or {

template <> struct logical_or<void> : std::logical_or<void> {};

// sycl::minimum definition should be consistent with std::min
template <typename T = void> struct minimum {
T operator()(const T &lhs, const T &rhs) const {
return std::less<T>()(lhs, rhs) ? lhs : rhs;
return (rhs < lhs) ? rhs : lhs;
}
};

template <> struct minimum<void> {
struct is_transparent {};
template <typename T, typename U>
auto operator()(T &&lhs, U &&rhs) const -> std::common_type_t<T &&, U &&> {
return std::less<>()(std::forward<const T>(lhs), std::forward<const U>(rhs))
? std::forward<T>(lhs)
: std::forward<U>(rhs);
auto operator()(T &&lhs, U &&rhs) const ->
typename std::common_type<T &&, U &&>::type {
return (std::forward<const U>(rhs) < std::forward<const T>(lhs))
? std::forward<U>(rhs)
: std::forward<T>(lhs);
}
};

// sycl::maximum definition should be consistent with std::max
template <typename T = void> struct maximum {
T operator()(const T &lhs, const T &rhs) const {
return std::greater<T>()(lhs, rhs) ? lhs : rhs;
return (lhs < rhs) ? rhs : lhs;
}
};

template <> struct maximum<void> {
struct is_transparent {};
template <typename T, typename U>
auto operator()(T &&lhs, U &&rhs) const -> std::common_type_t<T &&, U &&> {
return std::greater<>()(std::forward<const T>(lhs),
std::forward<const U>(rhs))
? std::forward<T>(lhs)
: std::forward<U>(rhs);
auto operator()(T &&lhs, U &&rhs) const ->
typename std::common_type<T &&, U &&>::type {
return (std::forward<const T>(lhs) < std::forward<const U>(rhs))
? std::forward<U>(rhs)
: std::forward<T>(lhs);
}
};

Expand Down
1 change: 1 addition & 0 deletions sycl/source/detail/global_handler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class GlobalHandler {

GlobalHandler(const GlobalHandler &) = delete;
GlobalHandler(GlobalHandler &&) = delete;
GlobalHandler &operator=(const GlobalHandler &) = delete;

void registerSchedulerUsage(bool ModifyCounter = true);
Scheduler &getScheduler();
Expand Down
3 changes: 0 additions & 3 deletions sycl/source/detail/program_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,6 @@ program_impl::program_impl(ContextImplPtr Context,
OptionsVector.data(), nullptr);
std::string Options(OptionsVector.begin(), OptionsVector.end());
switch (BinaryType) {
case PI_PROGRAM_BINARY_TYPE_NONE:
assert(false);
break;
case PI_PROGRAM_BINARY_TYPE_COMPILED_OBJECT:
MState = program_state::compiled;
MCompileOptions = Options;
Expand Down
14 changes: 14 additions & 0 deletions sycl/source/detail/scheduler/commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,20 @@ bool CurrentCodeLocationValid() {
struct DemangleHandle {
char *p;
DemangleHandle(char *ptr) : p(ptr) {}

DemangleHandle &operator=(const DemangleHandle &rhs) {
if (this == &rhs)
return *this;

std::size_t n{std::strlen(rhs.p) + 1};
char *new_p = new char[n];
std::memcpy(new_p, rhs.p, n);
delete[] p;
p = new_p;

return *this;
}

~DemangleHandle() { std::free(p); }
};
static std::string demangleKernelName(std::string Name) {
Expand Down
12 changes: 12 additions & 0 deletions sycl/source/detail/scheduler/leaves_collection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,18 @@ class LeavesCollection {
(!MGenericIsActive && MHACIt != Rhs.MHACIt));
}

IteratorT &operator=(const IteratorT<IsConst> &Rhs) {
if (this == &Rhs)
return *this;

MHost = Rhs.MHost;
MGCIt = Rhs.MGCIt;
MHACIt = Rhs.MHACIt;
MGenericIsActive = Rhs.MGenericIsActive;

return *this;
}

// pre-increment
IteratorT<IsConst> &operator++() {
increment();
Expand Down
25 changes: 25 additions & 0 deletions sycl/test/basic_tests/sycl_maximum_minimum.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// RUN: %clangxx -fsycl %s -o %t.out
// RUN: %t.out
#include <sycl/sycl.hpp>

#include <algorithm>
#include <cassert>
#include <limits>

int main() {
double f1 = 1.0f;
double f2 = std::numeric_limits<double>::quiet_NaN();

assert(((std::max(f1, f2) == sycl::maximum{}(f1, f2)) &&
"sycl::maximum result is wrong"));
assert(((std::isnan((std::max(f2, f1)))) &&
(std::isnan(sycl::maximum{}(f2, f1)))) &&
"sycl::maximum result is wrong");
assert(((std::min(f1, f2) == sycl::minimum{}(f1, f2)) &&
"sycl::minimum result is wrong"));
assert(((std::isnan((std::min(f2, f1)))) &&
(std::isnan(sycl::minimum{}(f2, f1)))) &&
"sycl::minimum result is wrong");

return 0;
}
6 changes: 6 additions & 0 deletions xpti/src/xpti_proxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ class ProxyLoader {
tryToEnable();
}

ProxyLoader(bool loaded, xpti_plugin_handle_t fw_plugin_handle)
: m_loaded(loaded), m_fw_plugin_handle(fw_plugin_handle) {}

ProxyLoader(const ProxyLoader &rhs)
: ProxyLoader(rhs.m_loaded, rhs.m_fw_plugin_handle) {}

~ProxyLoader() {
// If the loading of the framework library was
// successful, we should close the handle in the
Expand Down