From 0c363de882e8cb40a45948b65f2e1cb28c4d6bf8 Mon Sep 17 00:00:00 2001 From: piotrekobi <48731682+piotrekobi@users.noreply.github.com> Date: Thu, 25 Aug 2022 16:07:48 +0200 Subject: [PATCH] Enable OMP multithreading in lookup_table_v2 (#45249) * Add omp parallel for directives * Revert "Add omp parallel for directives" This reverts commit f4e4f8ddb12454018d9c1e49c074af2543659de6. * Add #pragma omp parallel for to correct file * Add check for _OPENMP definition * Disable omp on gpu * Trigger CI * Readd check for _OPENMP definition * Change macro disabling changes on GPU * Improve macro readability --- paddle/phi/kernels/cpu/embedding_kernel.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/paddle/phi/kernels/cpu/embedding_kernel.cc b/paddle/phi/kernels/cpu/embedding_kernel.cc index 0430f7a005..7accdffe13 100644 --- a/paddle/phi/kernels/cpu/embedding_kernel.cc +++ b/paddle/phi/kernels/cpu/embedding_kernel.cc @@ -48,6 +48,10 @@ struct EmbeddingCPUFunctor { dev_ctx_.template Alloc(out_); auto* output = out_->data(); +#if defined(_OPENMP) && !defined(PADDLE_WITH_CUDA) +#pragma omp parallel for +#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)); -- GitLab