Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: #pragma omp simd (don't merge) #983

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion lstm/weightmatrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,14 @@ void WeightMatrix::MatrixDotVector(const inT8* u, double* v) const {
for (int i = 0; i < num_out; ++i) {
const inT8* Wi = wi_[i];
int total = 0;
#if _OPENMP < 201307 // before OpenMP 4.0 try something else first
if (SIMDDetect::IsSSEAvailable()) {
total = IntDotProductSSE(u, Wi, num_in);
} else {
}
else
#endif
{
#pragma omp simd reduction(+:total) // ignored before OpenMP 4.0
for (int j = 0; j < num_in; ++j) total += Wi[j] * u[j];
}
// Add in the bias and correct for integer values.
Expand Down Expand Up @@ -335,9 +340,12 @@ double WeightMatrix::DotProduct(const double* u, const double* v, int n) {
// is about 8% faster than sse. This suggests that the time is memory
// bandwidth constrained and could benefit from holding the reused vector
// in AVX registers.
#if _OPENMP < 201307 // before OpenMP 4.0 try something else first
if (SIMDDetect::IsAVXAvailable()) return DotProductAVX(u, v, n);
if (SIMDDetect::IsSSEAvailable()) return DotProductSSE(u, v, n);
#endif
double total = 0.0;
#pragma omp simd reduction(+:total) // ignored before OpenMP 4.0
for (int k = 0; k < n; ++k) total += u[k] * v[k];
return total;
}
Expand Down