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_u32a.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 HWY_BEFORE_NAMESPACE();
27 namespace hwy {
28 namespace HWY_NAMESPACE {
29 
SortU32Asc(uint32_t * HWY_RESTRICT keys,size_t num,uint32_t * HWY_RESTRICT buf)30 void SortU32Asc(uint32_t* HWY_RESTRICT keys, size_t num,
31                 uint32_t* HWY_RESTRICT buf) {
32   SortTag<uint32_t> d;
33   detail::SharedTraits<detail::LaneTraits<detail::OrderAscending>> st;
34   Sort(d, st, keys, num, buf);
35 }
36 
37 // NOLINTNEXTLINE(google-readability-namespace-comments)
38 }  // namespace HWY_NAMESPACE
39 }  // namespace hwy
40 HWY_AFTER_NAMESPACE();
41 
42 #if HWY_ONCE
43 namespace hwy {
44 namespace {
45 HWY_EXPORT(SortU32Asc);
46 }  // namespace
47 
operator ()(uint32_t * HWY_RESTRICT keys,size_t n,SortAscending) const48 void Sorter::operator()(uint32_t* HWY_RESTRICT keys, size_t n,
49                         SortAscending) const {
50   HWY_DYNAMIC_DISPATCH(SortU32Asc)(keys, n, Get<uint32_t>());
51 }
52 
53 }  // namespace hwy
54 #endif  // HWY_ONCE
55