@@ -174,12 +174,46 @@ TYPED_TEST_P(avx512argsort, test_reverse)
174
174
}
175
175
}
176
176
177
+ TYPED_TEST_P (avx512argsort, test_array_with_nan)
178
+ {
179
+ if (!cpu_has_avx512bw ()) {
180
+ GTEST_SKIP () << " Skipping this test, it requires avx512bw ISA" ;
181
+ }
182
+ if (!std::is_floating_point<TypeParam>::value) {
183
+ GTEST_SKIP () << " Skipping this test, it is meant for float/double" ;
184
+ }
185
+ std::vector<int64_t > arrsizes;
186
+ for (int64_t ii = 2 ; ii <= 1024 ; ++ii) {
187
+ arrsizes.push_back (ii);
188
+ }
189
+ std::vector<TypeParam> arr;
190
+ for (auto &size : arrsizes) {
191
+ arr = get_uniform_rand_array<TypeParam>(size);
192
+ arr[0 ] = std::numeric_limits<TypeParam>::quiet_NaN ();
193
+ arr[1 ] = std::numeric_limits<TypeParam>::quiet_NaN ();
194
+ std::vector<int64_t > inx
195
+ = avx512_argsort<TypeParam>(arr.data (), arr.size ());
196
+ std::vector<TypeParam> sort1;
197
+ for (size_t jj = 0 ; jj < size; ++jj) {
198
+ sort1.push_back (arr[inx[jj]]);
199
+ }
200
+ if ((!std::isnan (sort1[size-1 ])) || (!std::isnan (sort1[size-2 ]))) {
201
+ FAIL () << " NAN's aren't sorted to the end" ;
202
+ }
203
+ if (!std::is_sorted (sort1.begin (), sort1.end () - 2 )) {
204
+ FAIL () << " Array isn't sorted" ;
205
+ }
206
+ arr.clear ();
207
+ }
208
+ }
209
+
177
210
REGISTER_TYPED_TEST_SUITE_P (avx512argsort,
178
211
test_random,
179
212
test_reverse,
180
213
test_constant,
181
214
test_sorted,
182
- test_small_range);
215
+ test_small_range,
216
+ test_array_with_nan);
183
217
184
218
using ArgSortTestTypes = testing::Types<int32_t ,
185
219
uint32_t ,
0 commit comments