Skip to content

Commit

Permalink
vector check removed
Browse files Browse the repository at this point in the history
  • Loading branch information
DiamonDinoia committed Sep 13, 2024
1 parent 8a9fec9 commit 2f33b1f
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions src/spreadinterp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1897,11 +1897,11 @@ void bin_sort_singlethread_vector(
};

static constexpr auto has_duplicates = [](const auto &vec) constexpr noexcept {
using T = decltype(std::decay_t<decltype(vec)>());
for (auto i = 0; i < simd_size; i++) {
const auto rotated = xsimd::rotr(vec, sizeof(typename T::value_type) * 8 * i);
if ((rotated == vec) != xsimd::batch_bool<bool>(false)) {
return true;
for (int i = 0; i < simd_size; i++) {
for (int j = i + 1; j < simd_size; j++) {
if (vec[i] == vec[j]) {
return true;
}
}
}
return false;
Expand Down Expand Up @@ -1940,9 +1940,9 @@ void bin_sort_singlethread_vector(
iskz ? xsimd::to_int(fold_rescale(simd_type::load_unaligned(kz + i), N3) *
inv_bin_size_z_vec)
: zero;
const auto bin = i1 + nbins1 * (i2 + nbins2 * i3);
if (has_duplicates(bin)) {
const auto bin_array = to_array(bin);
const auto bin = i1 + nbins1 * (i2 + nbins2 * i3);
const auto bin_array = to_array(bin);
if (has_duplicates(bin_array)) {
for (int j = 0; j < simd_size; j++) {
++counts[bin_array[j]];
}
Expand Down Expand Up @@ -1981,10 +1981,11 @@ void bin_sort_singlethread_vector(
iskz ? xsimd::to_int(fold_rescale(simd_type::load_unaligned(kz + i), N3) *
inv_bin_size_z_vec)
: zero;
const auto bin = i1 + nbins1 * (i2 + nbins2 * i3);
const auto bins = decltype(bin)::gather(counts.data(), bin);
if (has_duplicates(bin) || has_duplicates(bins)) {
const auto bin_array = to_array(to_int(bin));
const auto bin = i1 + nbins1 * (i2 + nbins2 * i3);
const auto bins = decltype(bin)::gather(counts.data(), bin);
const auto bin_array = to_array(to_int(bin));
const auto bins_array = to_array(to_int(bins));
if (has_duplicates(bin_array) || has_duplicates(bins_array)) {
for (int j = 0; j < simd_size; j++) {
ret[counts[bin_array[j]]] = j + i;
counts[bin_array[j]]++;
Expand Down

0 comments on commit 2f33b1f

Please sign in to comment.