From 06651ed1c6c8c3bfd544257a3eddaeccc1374cb0 Mon Sep 17 00:00:00 2001 From: Vlad Romanov Date: Thu, 23 Jul 2020 20:36:48 +0300 Subject: [PATCH 1/2] [SYCL][NFC] Move circular_buffer.hpp to the source directory --- .../detail/circular_buffer.hpp | 0 sycl/source/detail/scheduler/scheduler.hpp | 2 +- .../pass-fp-through-buffer.cpp | 1 + sycl/unittests/misc/CMakeLists.txt | 1 + .../misc/CircularBuffer.cpp} | 31 ++++++++++++------- 5 files changed, 22 insertions(+), 13 deletions(-) rename sycl/{include/CL/sycl => source}/detail/circular_buffer.hpp (100%) rename sycl/{test/basic_tests/circular_buffer.cpp => unittests/misc/CircularBuffer.cpp} (51%) diff --git a/sycl/include/CL/sycl/detail/circular_buffer.hpp b/sycl/source/detail/circular_buffer.hpp similarity index 100% rename from sycl/include/CL/sycl/detail/circular_buffer.hpp rename to sycl/source/detail/circular_buffer.hpp diff --git a/sycl/source/detail/scheduler/scheduler.hpp b/sycl/source/detail/scheduler/scheduler.hpp index b7d580e5d1823..1550cfd628d47 100644 --- a/sycl/source/detail/scheduler/scheduler.hpp +++ b/sycl/source/detail/scheduler/scheduler.hpp @@ -9,8 +9,8 @@ #pragma once #include -#include #include +#include #include #include diff --git a/sycl/test/function-pointers/pass-fp-through-buffer.cpp b/sycl/test/function-pointers/pass-fp-through-buffer.cpp index aa2bc85ec9874..67ecea5509a5f 100644 --- a/sycl/test/function-pointers/pass-fp-through-buffer.cpp +++ b/sycl/test/function-pointers/pass-fp-through-buffer.cpp @@ -11,6 +11,7 @@ #include +#include #include #include diff --git a/sycl/unittests/misc/CMakeLists.txt b/sycl/unittests/misc/CMakeLists.txt index 6587f9edea163..169a1572b2d09 100644 --- a/sycl/unittests/misc/CMakeLists.txt +++ b/sycl/unittests/misc/CMakeLists.txt @@ -2,4 +2,5 @@ set(sycl_lib_dir $) add_definitions(-DSYCL_LIB_DIR="${sycl_lib_dir}") add_sycl_unittest(MiscTests SHARED OsUtils.cpp + CircularBuffer.cpp ) diff --git a/sycl/test/basic_tests/circular_buffer.cpp b/sycl/unittests/misc/CircularBuffer.cpp similarity index 51% rename from sycl/test/basic_tests/circular_buffer.cpp rename to sycl/unittests/misc/CircularBuffer.cpp index d3ab0c3a77530..63cad57475707 100644 --- a/sycl/test/basic_tests/circular_buffer.cpp +++ b/sycl/unittests/misc/CircularBuffer.cpp @@ -1,7 +1,14 @@ -// RUN: %clangxx -fsycl %s -o %t.out -// RUN: %t.out +//==---- OsUtils.cpp --- os_utils unit test --------------------------------==// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// -#include +#include + +#include #include #include @@ -11,21 +18,21 @@ // This test contains basic checks for cl::sycl::detail::CircularBuffer void checkEquality(const cl::sycl::detail::CircularBuffer &CB, const std::vector &V) { - assert(std::equal(CB.begin(), CB.end(), V.begin())); + ASSERT_TRUE(std::equal(CB.begin(), CB.end(), V.begin())); } -int main() { +TEST(CircularBufferTest, CircularBufferTest) { const std::size_t Capacity = 6; cl::sycl::detail::CircularBuffer CB{Capacity}; - assert(CB.capacity() == Capacity); - assert(CB.empty()); + ASSERT_TRUE(CB.capacity() == Capacity); + ASSERT_TRUE(CB.empty()); - int nextValue = 0; + size_t nextValue = 0; for (; nextValue < Capacity; ++nextValue) { - assert(CB.size() == nextValue); + ASSERT_TRUE(CB.size() == nextValue); CB.push_back(nextValue); } - assert(CB.full() && CB.size() == CB.capacity()); + ASSERT_TRUE(CB.full() && CB.size() == CB.capacity()); checkEquality(CB, {0, 1, 2, 3, 4, 5}); CB.push_back(nextValue++); @@ -33,8 +40,8 @@ int main() { CB.push_front(nextValue++); checkEquality(CB, {7, 1, 2, 3, 4, 5}); - assert(CB.front() == 7); - assert(CB.back() == 5); + ASSERT_TRUE(CB.front() == 7); + ASSERT_TRUE(CB.back() == 5); CB.erase(CB.begin() + 2); checkEquality(CB, {7, 1, 3, 4, 5}); From 849ae5bbab71406bf81bb91851e4d050983a59b7 Mon Sep 17 00:00:00 2001 From: Vlad Romanov Date: Sun, 26 Jul 2020 17:45:03 +0300 Subject: [PATCH 2/2] fix test title --- sycl/unittests/misc/CircularBuffer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sycl/unittests/misc/CircularBuffer.cpp b/sycl/unittests/misc/CircularBuffer.cpp index 63cad57475707..3ffc666fa0c8f 100644 --- a/sycl/unittests/misc/CircularBuffer.cpp +++ b/sycl/unittests/misc/CircularBuffer.cpp @@ -1,4 +1,4 @@ -//==---- OsUtils.cpp --- os_utils unit test --------------------------------==// +//==---- CircularBuffer.cpp ------------------------------------------------==// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information.