Skip to content

Commit

Permalink
changed atomic int to omp reduction clause
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreFCruz committed Jul 4, 2022
1 parent 1e01045 commit 34f1103
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions include/LightGBM/objective_function.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

#include <string>
#include <functional>
#include <atomic>

namespace LightGBM {
/*!
Expand Down Expand Up @@ -668,9 +667,9 @@ class ConstrainedObjectiveFunction : public ObjectiveFunction
*/
double ComputeGlobalFPR(const double *score, double probabilities_threshold) const
{
std::atomic<int> false_positives(0), label_negatives(0);
int false_positives = 0, label_negatives = 0;

#pragma omp parallel for schedule(static)
#pragma omp parallel for schedule(static) reduction(+ : false_positives, label_negatives)
for (data_size_t i = 0; i < num_data_; ++i)
{
if (label_[i] == 0)
Expand Down Expand Up @@ -882,9 +881,9 @@ class ConstrainedObjectiveFunction : public ObjectiveFunction
*/
double ComputeGlobalFNR(const double *score, double probabilities_threshold) const
{
std::atomic<int> false_negatives(0), label_positives(0);
int false_negatives = 0, label_positives = 0;

#pragma omp parallel for schedule(static)
#pragma omp parallel for schedule(static) reduction(+ : false_negatives, label_positives)
for (data_size_t i = 0; i < num_data_; ++i)
{
if (label_[i] == 1)
Expand Down

0 comments on commit 34f1103

Please sign in to comment.