Skip to content

Commit

Permalink
Stripped out OpenMP SIMD macros as they're not worth the effort.
Browse files Browse the repository at this point in the history
Some testing on godbolt indicates that the compiler autovectorizes wherever it
can anyway; the OpenMP macros don't change the compiler's decision much, at
least not in the places that it's used in this codebase. So, we remove them
to reduce the risk of incorrectness and the amount of testing we have to do.
  • Loading branch information
LTLA committed Sep 2, 2024
1 parent f540b25 commit 95d4d20
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 24 deletions.
6 changes: 0 additions & 6 deletions include/qdtsne/SPTree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,18 +288,12 @@ class SPTree {
Float_ mult = count * div;
result_sum += mult;
mult *= div;
#ifdef _OPENMP
#pragma omp simd
#endif
for (int d = 0; d < num_dim_; ++d) {
neg_f[d] += mult * (point[d] - center[d]);
}
}

static void remove_self_from_center(const Float_* point, const std::array<Float_, num_dim_>& center, Float_ count, std::array<Float_, num_dim_>& temp) {
#ifdef _OPENMP
#pragma omp simd
#endif
for (int d = 0; d < num_dim_; ++d) {
temp[d] = (center[d] * count - point[d]) / (count - 1);
}
Expand Down
6 changes: 0 additions & 6 deletions include/qdtsne/Status.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,6 @@ class Status {

// Update gains
size_t ngains = my_gains.size();
#ifdef _OPENMP
#pragma omp simd
#endif
for (size_t i = 0; i < ngains; ++i) {
Float_& g = my_gains[i];
constexpr Float_ lower_bound = 0.01;
Expand All @@ -197,9 +194,6 @@ class Status {
}

// Perform gradient update (with momentum and gains)
#ifdef _OPENMP
#pragma omp simd
#endif
for (size_t i = 0; i < ngains; ++i) {
my_uY[i] = momentum * my_uY[i] - my_options.eta * my_gains[i] * my_dY[i];
Y[i] += my_uY[i];
Expand Down
12 changes: 0 additions & 12 deletions include/qdtsne/gaussian.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ void compute_gaussian_perplexity(NeighborList<Index_, Float_>& neighbors, Float_
const Float_ first = current[0].second;
const Float_ first2 = first * first;

#ifdef _OPENMP
#pragma omp simd
#endif
for (int m = 1; m < K; ++m) {
Float_ dist = current[m].second;
Float_ squared_delta_dist_raw = dist * dist - first2;
Expand All @@ -61,9 +58,6 @@ void compute_gaussian_perplexity(NeighborList<Index_, Float_>& neighbors, Float_
for (int iter = 0; iter < 200; ++iter) {
// We skip the first value because we know that squared_delta_dist[0] = 0
// (as we subtracted 'first') and thus output[0] = 1.
#ifdef _OPENMP
#pragma omp simd
#endif
for (int m = 1; m < K; ++m) {
output[m] = std::exp(-beta * squared_delta_dist[m]);
}
Expand Down Expand Up @@ -111,9 +105,6 @@ void compute_gaussian_perplexity(NeighborList<Index_, Float_>& neighbors, Float_

if (std::isinf(beta)) {
// Avoid propagation of NaNs via Inf * 0.
#ifdef _OPENMP
#pragma omp simd
#endif
for (int m = 1; m < K; ++m) {
output[m] = (squared_delta_dist[m] == 0);
}
Expand All @@ -122,9 +113,6 @@ void compute_gaussian_perplexity(NeighborList<Index_, Float_>& neighbors, Float_
}

// Row-normalize current row of P.
#ifdef _OPENMP
#pragma omp simd
#endif
for (int m = 0; m < K; ++m) {
current[m].second = output[m] / sum_P;
}
Expand Down

0 comments on commit 95d4d20

Please sign in to comment.