Skip to content

[SYCL] Switch build of SYCL runtime to C++17 #3447

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
merged 8 commits into from
Apr 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion sycl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.14)

project(sycl-solution)
# Requirements
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
option(SYCL_ENABLE_WERROR "Treat all warnings as errors in SYCL project" OFF)
Expand Down
7 changes: 0 additions & 7 deletions sycl/cmake/modules/AddSYCLUnitTest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,6 @@ macro(add_sycl_unittest test_dirname link_variant)
-Wno-inconsistent-missing-override
)
endif()
# LLVM gtest uses LLVM utilities that require C++-14
# CXX_STANDARD_REQUIRED makes CXX_STANDARD a hard requirement.
set_target_properties(${test_dirname}
PROPERTIES
CXX_STANDARD 14
CXX_STANDARD_REQUIRED ON
)
endmacro()

macro(add_sycl_unittest_with_device test_dirname link_variant)
Expand Down
2 changes: 1 addition & 1 deletion sycl/doc/GetStartedGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ which contains all the symbols required.

## C++ standard

* DPC++ runtime and headers require C++14 at least.
* DPC++ runtime and headers require C++17 at least.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vladimirlaz, could you confirm that there are no runtime library ABI breaking changes requiring us to increment the library version, please?

Copy link
Contributor

@v-klochkov v-klochkov Apr 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idea for a separate PR: It would be good to have a static_assert somewhere in SYCL headers that would check that C++ is 17 or higher.
It would give user-friendly message instead of some unexpected compilation errors due to various reasons (using 'if constexpr', auto in template args, inline vars, etc. with C++14 option)

* DPC++ compiler builds apps as C++17 apps by default. Higher versions of
standard are supported as well.

Expand Down
13 changes: 7 additions & 6 deletions sycl/include/CL/sycl/ONEAPI/accessor_property_list.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,17 +193,18 @@ class accessor_property_list : protected sycl::detail::PropertyListBase {

#if __cplusplus >= 201703L
template <typename T>
static constexpr
typename detail::enable_if_t<is_compile_time_property<T>::value, bool>
has_property() {
constexpr std::enable_if_t<is_compile_time_property<T>::value, bool>
has_property() const {
return ContainsPropertyInstance<PropertyContainer<PropsT...>,
T::template instance>::value;
}

template <typename T,
typename = typename detail::enable_if_t<
is_compile_time_property<T>::value && has_property<T>()>>
static constexpr auto get_property() {
typename = std::enable_if_t<
is_compile_time_property<T>::value &&
ContainsPropertyInstance<PropertyContainer<PropsT...>,
T::template instance>::value>>
constexpr auto get_property() const {
return typename GetCompileTimePropertyHelper<PropertyContainer<PropsT...>,
T::template instance>::type{};
}
Expand Down
2 changes: 1 addition & 1 deletion sycl/include/CL/sycl/properties/accessor_properties.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ struct buffer_location {
} // namespace property
#if __cplusplus > 201402L
template <int A>
inline constexpr property::buffer_location::instance<A> buffer_location;
inline constexpr property::buffer_location::instance<A> buffer_location{};
#endif
} // namespace INTEL
namespace ONEAPI {
Expand Down
2 changes: 1 addition & 1 deletion sycl/unittests/scheduler/NoHostUnifiedMemory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ TEST_F(SchedulerTest, NoHostUnifiedMemory) {
// Memory movement operations should be omitted for discard access modes.
detail::Command *MemoryMove =
MS.insertMemoryMove(Record, &DiscardReq, DefaultHostQueue);
EXPECT_EQ(MemoryMove, nullptr);
EXPECT_TRUE(MemoryMove == nullptr);
// The current context for the record should still be modified.
EXPECT_EQ(Record->MCurContext, DefaultHostQueue->getContextImplPtr());
}
Expand Down
4 changes: 2 additions & 2 deletions sycl/unittests/scheduler/WaitAfterCleanup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ using namespace cl::sycl;
TEST_F(SchedulerTest, WaitAfterCleanup) {
auto Cmd = new MockCommand(detail::getSyclObjImpl(MQueue));
auto Event = Cmd->getEvent();
ASSERT_NE(Event, nullptr) << "Command must have an event\n";
ASSERT_FALSE(Event == nullptr) << "Command must have an event\n";

detail::Scheduler::getInstance().waitForEvent(Event);
ASSERT_EQ(Event->getCommand(), Cmd)
<< "Command should not have been cleaned up yet\n";

detail::Scheduler::getInstance().cleanupFinishedCommands(Event);
ASSERT_EQ(Event->getCommand(), nullptr)
ASSERT_TRUE(Event->getCommand() == nullptr)
<< "Command should have been cleaned up\n";

detail::Scheduler::getInstance().waitForEvent(Event);
Expand Down