From d9da83da0c3042c61955a566b762b0ce1fe145bd Mon Sep 17 00:00:00 2001 From: James Lamb Date: Sun, 8 Oct 2023 15:46:20 -0500 Subject: [PATCH] remove unnecessary allocations in HistogramSumReducer --- include/LightGBM/bin.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/include/LightGBM/bin.h b/include/LightGBM/bin.h index ffb8f2844843..de1bb6eb94ed 100644 --- a/include/LightGBM/bin.h +++ b/include/LightGBM/bin.h @@ -63,8 +63,7 @@ inline static void Int32HistogramSumReducer(const char* src, char* dst, int type const int64_t* src_ptr = reinterpret_cast(src); int64_t* dst_ptr = reinterpret_cast(dst); const comm_size_t steps = (len + (type_size * 2) - 1) / (type_size * 2); - const int num_threads = OMP_NUM_THREADS(); - #pragma omp parallel for schedule(static) num_threads(num_threads) + #pragma omp parallel for schedule(static) num_threads(OMP_NUM_THREADS()) for (comm_size_t i = 0; i < steps; ++i) { dst_ptr[i] += src_ptr[i]; } @@ -74,8 +73,7 @@ inline static void Int16HistogramSumReducer(const char* src, char* dst, int type const int32_t* src_ptr = reinterpret_cast(src); int32_t* dst_ptr = reinterpret_cast(dst); const comm_size_t steps = (len + (type_size * 2) - 1) / (type_size * 2); - const int num_threads = OMP_NUM_THREADS(); - #pragma omp parallel for schedule(static) num_threads(num_threads) + #pragma omp parallel for schedule(static) num_threads(OMP_NUM_THREADS()) for (comm_size_t i = 0; i < steps; ++i) { dst_ptr[i] += src_ptr[i]; }