Skip to content

Commit

Permalink
Adding ncores
Browse files Browse the repository at this point in the history
  • Loading branch information
gvegayon committed Sep 27, 2023
1 parent c57353c commit d57476a
Show file tree
Hide file tree
Showing 9 changed files with 155 additions and 92 deletions.
220 changes: 141 additions & 79 deletions barry.hpp

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion include/barry/barry-macros.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#if defined(_OPENMP) || defined(__OPENMP)
#define BARRY_NCORES_ARG(default) size_t ncores default
#else
#define BARRY_NCORES_ARG(default) size_t
#define BARRY_NCORES_ARG(default) size_t ncores default
#endif


Expand Down
2 changes: 1 addition & 1 deletion include/barry/counters/network.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ inline void counter_ctriads(NetCounters<NetworkDense> * counters)

// i->j->k->i
double ans = 0.0;
#ifdef __OPENM
#if defined(__OPENMP) || defined(_OPENMP)
#pragma omp simd reduction(+:ans)
#endif
for (size_t k = 0u; k < Array.nrow(); ++k)
Expand Down
4 changes: 2 additions & 2 deletions include/barry/model-meat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,7 @@ inline double Model<Array_Type,Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_
params.size()
) BARRY_SAFE_EXP;

#ifdef __OPENM
#if defined(__OPENMP) || defined(_OPENMP)
#pragma omp simd reduction(-:res)
#endif
for (size_t i = 0u; i < params_last_size; ++i)
Expand All @@ -924,7 +924,7 @@ inline double Model<Array_Type,Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_

res = 1.0;
size_t stats_target_size = stats_target.size();
#ifdef __OPENM
#if defined(__OPENMP) || defined(_OPENMP)
#pragma omp simd reduction(*:res)
#endif
for (size_t i = 0; i < stats_target_size; ++i)
Expand Down
2 changes: 1 addition & 1 deletion include/barry/models/geese/flock-bones.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class Flock {
const std::vector< double > & par,
bool as_log = false,
bool use_reduced_sequence = true,
BARRY_NCORES_ARG(=1)
size_t ncores = 1u
);

/**
Expand Down
6 changes: 3 additions & 3 deletions include/barry/models/geese/flock-meat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ inline double Flock::likelihood_joint(
const std::vector< double > & par,
bool as_log,
bool use_reduced_sequence,
BARRY_NCORES_ARG()
size_t ncores
)
{

Expand All @@ -150,14 +150,14 @@ inline double Flock::likelihood_joint(
if (as_log) {

for (auto& d : this->dat)
ans += d.likelihood(par, as_log, use_reduced_sequence);
ans += d.likelihood(par, as_log, use_reduced_sequence, ncores);

}
else
{

for (auto& d : this->dat)
ans *= d.likelihood(par, as_log, use_reduced_sequence);
ans *= d.likelihood(par, as_log, use_reduced_sequence, ncores);

}

Expand Down
2 changes: 1 addition & 1 deletion include/barry/models/geese/geese-bones.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ class Geese {
const std::vector< double > & par,
bool as_log = false,
bool use_reduced_sequence = true,
BARRY_NCORES_ARG(= 1)
size_t ncores = 1u
);

double likelihood_exhaust(const std::vector< double > & par);
Expand Down
3 changes: 2 additions & 1 deletion include/barry/models/geese/geese-meat-likelihood.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ inline double Geese::likelihood(
const std::vector< double > & par,
bool as_log,
bool use_reduced_sequence,
BARRY_NCORES_ARG()
size_t ncores
) {

INITIALIZED()
Expand Down Expand Up @@ -150,6 +150,7 @@ inline double Geese::likelihood(
par0,
temp_stats,
node.narray[s],
as_log,
ncores
);
} catch (std::exception & e) {
Expand Down
6 changes: 3 additions & 3 deletions include/barry/typedefs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ inline bool vec_equal_approx(
}
///@}

#ifdef __OPENM
#if defined(__OPENMP) || defined(_OPENMP)
#pragma omp declare simd
#endif
template <typename T>
Expand All @@ -267,7 +267,7 @@ inline T vec_inner_prod(
) {

double res = 0.0;
#ifdef __OPENM
#if defined(__OPENMP) || defined(_OPENMP)
#pragma omp simd reduction(+:res)
#else
#ifdef __GNUC__
Expand All @@ -283,7 +283,7 @@ inline T vec_inner_prod(

}

#ifdef __OPENM
#if defined(__OPENMP) || defined(_OPENMP)
#pragma omp declare simd
#endif
template <>
Expand Down

0 comments on commit d57476a

Please sign in to comment.