Skip to content

Commit da51ec6

Browse files
committed
[SYCL][LIT] Add test cases for new buffer constructors
Signed-off-by: Vyacheslav N Klochkov <[email protected]>
1 parent 996bfe2 commit da51ec6

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed
Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
// RUN: %clangxx -std=c++17 -fsyntax-only -Xclang -verify %s -I %sycl_include -Xclang -verify-ignore-unexpected=note,warning
22
// expected-no-diagnostics
3-
//==------------------- buffer_ctad.cpp - SYCL buffer CTAD test ----------------==//
4-
//
5-
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
6-
// See https://llvm.org/LICENSE.txt for license information.
7-
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8-
//
9-
//===----------------------------------------------------------------------===//
103

114
#include <CL/sycl.hpp>
125
#include <cassert>
@@ -19,22 +12,45 @@ int main() {
1912
const std::vector<int> cv(5, 1);
2013
buffer b1(v.data(), range<1>(5));
2114
static_assert(std::is_same<decltype(b1), buffer<int, 1>>::value);
15+
2216
buffer b1a(v.data(), range<1>(5), std::allocator<int>());
2317
static_assert(
2418
std::is_same<decltype(b1a), buffer<int, 1, std::allocator<int>>>::value);
19+
2520
buffer b1b(cv.data(), range<1>(5));
2621
static_assert(std::is_same<decltype(b1b), buffer<int, 1>>::value);
22+
2723
buffer b1c(v.data(), range<2>(2, 2));
2824
static_assert(std::is_same<decltype(b1c), buffer<int, 2>>::value);
25+
2926
buffer b2(v.begin(), v.end());
3027
static_assert(std::is_same<decltype(b2), buffer<int, 1>>::value);
28+
3129
buffer b2a(v.cbegin(), v.cend());
3230
static_assert(std::is_same<decltype(b2a), buffer<int, 1>>::value);
31+
3332
buffer b3(v);
3433
static_assert(std::is_same<decltype(b3), buffer<int, 1>>::value);
34+
3535
buffer b3a(cv);
3636
static_assert(std::is_same<decltype(b3a), buffer<int, 1>>::value);
37+
3738
shared_ptr_class<int> ptr{new int[5], [](int *p) { delete[] p; }};
3839
buffer b4(ptr, range<1>(5));
3940
static_assert(std::is_same<decltype(b4), buffer<int, 1>>::value);
41+
42+
std::allocator<int> buf_alloc;
43+
shared_ptr_class<int> ptr_alloc{new int[5], [](int *p) { delete[] p; }};
44+
buffer b5(ptr, range<1>(5), buf_alloc);
45+
static_assert(std::is_same<decltype(b5),
46+
buffer<int, 1, std::allocator<int>>>::value);
47+
48+
shared_ptr_class<int[]> arr_ptr{new int[5]};
49+
buffer b6(arr_ptr, range<1>(5));
50+
static_assert(std::is_same<decltype(b6), buffer<int, 1>>::value);
51+
52+
shared_ptr_class<int[]> arr_ptr_alloc{new int[5]};
53+
buffer b7(arr_ptr_alloc, range<1>(5), buf_alloc);
54+
static_assert(std::is_same<decltype(b7),
55+
buffer<int, 1, std::allocator<int>>>::value);
4056
}

0 commit comments

Comments
 (0)