1 // Copyright 2022 Google LLC
2 // SPDX-License-Identifier: Apache-2.0
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 #include "hwy/aligned_allocator.h"
19 #include "hwy/highway.h"
20 #include "hwy/print.h"
22 // Per-target include guard
23 #if defined(HIGHWAY_HWY_PRINT_INL_H_) == \
24 defined(HWY_TARGET_TOGGLE)
25 #ifdef HIGHWAY_HWY_PRINT_INL_H_
26 #undef HIGHWAY_HWY_PRINT_INL_H_
28 #define HIGHWAY_HWY_PRINT_INL_H_
31 HWY_BEFORE_NAMESPACE();
33 namespace HWY_NAMESPACE
{
35 // Prints lanes around `lane`, in memory order.
36 template <class D
, class V
= VFromD
<D
>>
37 HWY_API
void Print(const D d
, const char* caption
, V v
, size_t lane_u
= 0,
38 size_t max_lanes
= 7) {
39 const size_t N
= Lanes(d
);
41 auto lanes
= AllocateAligned
<T
>(N
);
42 Store(v
, d
, lanes
.get());
44 const auto info
= hwy::detail::MakeTypeInfo
<T
>();
45 hwy::detail::PrintArray(info
, caption
, lanes
.get(), N
, lane_u
, max_lanes
);
48 // NOLINTNEXTLINE(google-readability-namespace-comments)
49 } // namespace HWY_NAMESPACE
51 HWY_AFTER_NAMESPACE();
53 #endif // per-target include guard