From 76f9990d6fd7a8d402ab30cc2abb313eb01285c3 Mon Sep 17 00:00:00 2001 From: shesung Date: Mon, 5 Nov 2018 11:47:10 +0800 Subject: [PATCH] change OMP for better performance --- src/operator/contrib/roi_align.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/operator/contrib/roi_align.cc b/src/operator/contrib/roi_align.cc index ecbbcb44f57e..325b1dd40cef 100644 --- a/src/operator/contrib/roi_align.cc +++ b/src/operator/contrib/roi_align.cc @@ -157,7 +157,10 @@ void ROIAlignForward( int n_rois = nthreads / channels / pooled_width / pooled_height; // (n, c, ph, pw) is an element in the pooled output // can be parallelized using omp - for (int n = 0; n < n_rois; n++) { + int n; +#pragma omp parallel for private(n) \ +num_threads(engine::OpenMP::Get()->GetRecommendedOMPThreadCount()) + for (n = 0; n < n_rois; n++) { int index_n = n * channels * pooled_width * pooled_height; // roi could have 4 or 5 columns @@ -209,10 +212,7 @@ void ROIAlignForward( roi_bin_grid_w, &pre_calc); - int c; -#pragma omp parallel for private(c) \ -num_threads(engine::OpenMP::Get()->GetRecommendedOMPThreadCount()) - for (c = 0; c < channels; c++) { + for (int c = 0; c < channels; c++) { int index_n_c = index_n + c * pooled_width * pooled_height; int pre_calc_index = 0;