Grok 12.0.1
print-inl.h
Go to the documentation of this file.
1// Copyright 2022 Google LLC
2// SPDX-License-Identifier: Apache-2.0
3//
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
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
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.
15
16// Print() function
17
18#include "hwy/highway.h"
19#include "hwy/print.h"
20
21// Per-target include guard
22#if defined(HIGHWAY_HWY_PRINT_INL_H_) == defined(HWY_TARGET_TOGGLE)
23#ifdef HIGHWAY_HWY_PRINT_INL_H_
24#undef HIGHWAY_HWY_PRINT_INL_H_
25#else
26#define HIGHWAY_HWY_PRINT_INL_H_
27#endif
28
29#if HWY_TARGET == HWY_RVV
31#endif
32
34namespace hwy {
35namespace HWY_NAMESPACE {
36
37// Prints lanes around `lane`, in memory order.
38template <class D, class V = VFromD<D>>
39HWY_API void Print(const D d, const char* caption, V v, size_t lane_u = 0,
40 size_t max_lanes = 7) {
41 const size_t N = Lanes(d);
42 using T = TFromD<D>;
43#if HWY_TARGET == HWY_RVV
44 auto storage = AllocateAligned<T>(N);
45 T* HWY_RESTRICT lanes = storage.get();
46#else
47 // This works around an SVE compile error on GCC 11 and 12. Calling
48 // AllocateAligned here would seem to require it be marked with HWY_ATTR.
49 HWY_ALIGN T lanes[MaxLanes(d)];
50#endif
51 Store(v, d, lanes);
52
53 const auto info = hwy::detail::MakeTypeInfo<T>();
54 hwy::detail::PrintArray(info, caption, lanes, N, lane_u, max_lanes);
55}
56
57// NOLINTNEXTLINE(google-readability-namespace-comments)
58} // namespace HWY_NAMESPACE
59} // namespace hwy
61
62#endif // per-target include guard
#define HWY_RESTRICT
Definition base.h:95
#define HWY_API
Definition base.h:171
D d
Definition arm_sve-inl.h:1915
HWY_INLINE HWY_MAYBE_UNUSED constexpr size_t MaxLanes(D)
Definition ops/shared-inl.h:442
HWY_API void Store(VFromD< D > v, D d, TFromD< D > *HWY_RESTRICT aligned)
Definition arm_neon-inl.h:3911
typename D::T TFromD
Definition ops/shared-inl.h:426
HWY_API size_t Lanes(D)
Definition rvv-inl.h:598
HWY_API void Print(const D d, const char *caption, V v, size_t lane_u=0, size_t max_lanes=7)
Definition print-inl.h:39
HWY_DLLEXPORT void PrintArray(const TypeInfo &info, const char *caption, const void *array_void, size_t N, size_t lane_u=0, size_t max_lanes=7)
Definition abort.h:8
HWY_AFTER_NAMESPACE()
HWY_BEFORE_NAMESPACE()
#define HWY_ALIGN
Definition set_macros-inl.h:167
#define HWY_NAMESPACE
Definition set_macros-inl.h:166