/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-composable-kernel/checkouts/docs-6.4.3/include/ck/utility/functional2.hpp Source File

/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-composable-kernel/checkouts/docs-6.4.3/include/ck/utility/functional2.hpp Source File#

Composable Kernel: /home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-composable-kernel/checkouts/docs-6.4.3/include/ck/utility/functional2.hpp Source File
functional2.hpp
Go to the documentation of this file.
1 // SPDX-License-Identifier: MIT
2 // Copyright (c) 2018-2023, Advanced Micro Devices, Inc. All rights reserved.
3 
4 #pragma once
5 
8 
9 namespace ck {
10 
11 namespace detail {
12 
13 template <class>
15 
16 template <index_t... Is>
17 struct static_for_impl<Sequence<Is...>>
18 {
19  template <class F>
20  __host__ __device__ constexpr void operator()(F f) const
21  {
22  swallow{(f(Number<Is>{}), 0)...};
23  }
24 };
25 
26 } // namespace detail
27 
28 // F signature: F(Number<Iter>)
29 template <index_t NBegin, index_t NEnd, index_t Increment>
30 struct static_for
31 {
32  __host__ __device__ constexpr static_for()
33  {
34  static_assert(Increment != 0 && (NEnd - NBegin) % Increment == 0,
35  "Wrong! should satisfy (NEnd - NBegin) % Increment == 0");
36  static_assert((Increment > 0 && NBegin <= NEnd) || (Increment < 0 && NBegin >= NEnd),
37  "wrongs! should (Increment > 0 && NBegin <= NEnd) || (Increment < 0 && "
38  "NBegin >= NEnd)");
39  }
40 
41  template <class F>
42  __host__ __device__ constexpr void operator()(F f) const
43  {
45  f);
46  }
47 };
48 
49 } // namespace ck
Definition: ck.hpp:264
int32_t index_t
Definition: ck.hpp:289
Definition: sequence.hpp:43
__host__ constexpr __device__ void operator()(F f) const
Definition: functional2.hpp:20
Definition: functional2.hpp:14
Definition: integral_constant.hpp:10
Definition: functional2.hpp:31
__host__ constexpr __device__ void operator()(F f) const
Definition: functional2.hpp:42
__host__ constexpr __device__ static_for()
Definition: functional2.hpp:32
Definition: functional.hpp:22