DPC++ Runtime
Runtime libraries for oneAPI DPC++
vector_traits.hpp
Go to the documentation of this file.
1 //==----------- vector_traits.hpp - SYCL vector size queries --------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #pragma once
10 
11 #include <algorithm> // for std::min and vs2017 win
12 #include <type_traits> // for integral_constant, conditional_t, remove_cv_t
13 
14 namespace sycl {
15 inline namespace _V1 {
16 namespace detail {
17 
18 // 4.10.2.6 Memory layout and alignment
19 // due to MSVC the maximum alignment for sycl::vec is 64 and this proposed
20 // change is being brought to the spec committee.
21 constexpr size_t MaxVecAlignment = 64;
22 template <typename T, size_t N>
24  : std::conditional_t<
25  N == 3,
26  std::integral_constant<size_t,
27  (std::min)(sizeof(T) * 4, MaxVecAlignment)>,
28  std::integral_constant<size_t,
29  (std::min)(sizeof(T) * N, MaxVecAlignment)>> {
30 };
31 
32 template <typename T, size_t N>
34  : vector_alignment_impl<std::remove_cv_t<std::remove_reference_t<T>>, N> {};
35 } // namespace detail
36 } // namespace _V1
37 } // namespace sycl
constexpr size_t MaxVecAlignment
Definition: access.hpp:18