1 // Copyright 2021 Google LLC
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //      http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #include "hwy/contrib/sort/disabled_targets.h"
16 #include "hwy/contrib/sort/vqsort.h"
17 
18 #undef HWY_TARGET_INCLUDE
19 #define HWY_TARGET_INCLUDE "hwy/contrib/sort/vqsort_u16a.cc"
20 #include "hwy/foreach_target.h"
21 
22 // After foreach_target
23 #include "hwy/contrib/sort/traits-inl.h"
24 #include "hwy/contrib/sort/vqsort-inl.h"
25 
26 // Workaround for build timeout
27 #if !HWY_COMPILER_MSVC || HWY_IS_DEBUG_BUILD
28 
29 HWY_BEFORE_NAMESPACE();
30 namespace hwy {
31 namespace HWY_NAMESPACE {
32 
SortU16Asc(uint16_t * HWY_RESTRICT keys,size_t num,uint16_t * HWY_RESTRICT buf)33 void SortU16Asc(uint16_t* HWY_RESTRICT keys, size_t num,
34                 uint16_t* HWY_RESTRICT buf) {
35   SortTag<uint16_t> d;
36   detail::SharedTraits<detail::LaneTraits<detail::OrderAscending>> st;
37   Sort(d, st, keys, num, buf);
38 }
39 
40 // NOLINTNEXTLINE(google-readability-namespace-comments)
41 }  // namespace HWY_NAMESPACE
42 }  // namespace hwy
43 HWY_AFTER_NAMESPACE();
44 
45 #if HWY_ONCE
46 namespace hwy {
47 namespace {
48 HWY_EXPORT(SortU16Asc);
49 }  // namespace
50 
operator ()(uint16_t * HWY_RESTRICT keys,size_t n,SortAscending) const51 void Sorter::operator()(uint16_t* HWY_RESTRICT keys, size_t n,
52                         SortAscending) const {
53   HWY_DYNAMIC_DISPATCH(SortU16Asc)(keys, n, Get<uint16_t>());
54 }
55 
56 }  // namespace hwy
57 #endif  // HWY_ONCE
58 
59 #endif  // !HWY_COMPILER_MSVC || HWY_IS_DEBUG_BUILD
60