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

remove unnecessary allocations in HistogramSumReducer #6132

Merged
merged 1 commit into from
Oct 9, 2023
Merged
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
6 changes: 2 additions & 4 deletions include/LightGBM/bin.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ inline static void Int32HistogramSumReducer(const char* src, char* dst, int type
const int64_t* src_ptr = reinterpret_cast<const int64_t*>(src);
int64_t* dst_ptr = reinterpret_cast<int64_t*>(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];
}
Expand All @@ -74,8 +73,7 @@ inline static void Int16HistogramSumReducer(const char* src, char* dst, int type
const int32_t* src_ptr = reinterpret_cast<const int32_t*>(src);
int32_t* dst_ptr = reinterpret_cast<int32_t*>(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];
}
Expand Down