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

Enable OMP multithreading in lookup_table_v2 #45249

Merged
merged 9 commits into from
Aug 25, 2022
5 changes: 5 additions & 0 deletions paddle/phi/kernels/cpu/embedding_kernel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ struct EmbeddingCPUFunctor {
dev_ctx_.template Alloc<T>(out_);
auto* output = out_->data<T>();

#if defined _OPENMP
#ifndef PADDLE_WITH_CUDA
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you could reformulate this conditions like: #if defined(_OPENMP) && !defined(PADDLE_WITH_CUDA)..... perhaps it would look more readable?

#pragma omp parallel for
#endif
#endif
for (int64_t i = 0; i < ids_numel; ++i) {
if (padding_idx_ != kNoPadding && ids[i] == padding_idx_) {
memset(output + i * row_width, 0, row_width * sizeof(T));
Expand Down