From 6bebc7f0d2aef89073a691941643a44cba947b14 Mon Sep 17 00:00:00 2001 From: Jouni Helske Date: Fri, 6 Sep 2024 11:38:28 +0300 Subject: [PATCH] fix lack of openmp with macos --- src/EM.cpp | 2 +- src/EMx.cpp | 2 +- src/forwardbackward.cpp | 2 +- src/forwardbackwardx.cpp | 2 +- src/internalBackward.cpp | 2 +- src/internalForward.cpp | 2 +- src/logLikHMM.cpp | 2 +- src/logLikMixHMM.cpp | 2 +- src/log_EM.cpp | 2 +- src/log_EMx.cpp | 2 +- src/log_forwardbackward.cpp | 2 +- src/log_forwardbackwardx.cpp | 2 +- src/log_internalBackward.cpp | 2 +- src/log_internalForward.cpp | 2 +- src/log_logLikHMM.cpp | 2 +- src/log_logLikMixHMM.cpp | 2 +- src/log_objective.cpp | 2 +- src/log_objectivex.cpp | 2 +- src/objective.cpp | 2 +- src/objectivex.cpp | 2 +- src/useomp.h | 3 +++ 21 files changed, 23 insertions(+), 20 deletions(-) create mode 100644 src/useomp.h diff --git a/src/EM.cpp b/src/EM.cpp index 763bed6c..eb27e832 100644 --- a/src/EM.cpp +++ b/src/EM.cpp @@ -1,7 +1,7 @@ // EM algorithm for non-mixture hidden Markov models #include "forward_backward.h" -#include +#include "useomp.h" // [[Rcpp::export]] Rcpp::List EM(const arma::mat& transition_, const arma::cube& emission_, const arma::vec& init_, diff --git a/src/EMx.cpp b/src/EMx.cpp index deece6b7..2d362395 100644 --- a/src/EMx.cpp +++ b/src/EMx.cpp @@ -2,7 +2,7 @@ #include "forward_backward.h" #include "optcoef.h" #include "reparma.h" -#include +#include "useomp.h" // [[Rcpp::export]] Rcpp::List EMx(const arma::mat& transition_, const arma::cube& emission_, const arma::vec& init_, diff --git a/src/forwardbackward.cpp b/src/forwardbackward.cpp index 2c68080e..fbcae267 100644 --- a/src/forwardbackward.cpp +++ b/src/forwardbackward.cpp @@ -1,6 +1,6 @@ // Forward-backward algorithm for non-mixture hidden Markov models #include "forward_backward.h" -#include +#include "useomp.h" // [[Rcpp::export]] Rcpp::List forwardbackward(const arma::mat& transition, const arma::cube& emission, const arma::vec& init, const arma::ucube& obs, bool forwardonly, unsigned int threads) { diff --git a/src/forwardbackwardx.cpp b/src/forwardbackwardx.cpp index 98d30c49..e5e7c960 100644 --- a/src/forwardbackwardx.cpp +++ b/src/forwardbackwardx.cpp @@ -1,7 +1,7 @@ // Forward-backward algorithm for mixture hidden Markov models #include "forward_backward.h" #include "reparma.h" -#include +#include "useomp.h" // [[Rcpp::export]] Rcpp::List forwardbackwardx(const arma::mat& transition, const arma::cube& emission, diff --git a/src/internalBackward.cpp b/src/internalBackward.cpp index 82626057..2a9e69a5 100644 --- a/src/internalBackward.cpp +++ b/src/internalBackward.cpp @@ -1,6 +1,6 @@ // Internal backward algorithms for HMMs and MHMMs #include "forward_backward.h" -#include +#include "useomp.h" void internalBackward(const arma::mat& transition, const arma::cube& emission, const arma::ucube& obs, arma::cube& beta, const arma::mat& scales, diff --git a/src/internalForward.cpp b/src/internalForward.cpp index 95436aa8..108a9be5 100644 --- a/src/internalForward.cpp +++ b/src/internalForward.cpp @@ -1,7 +1,7 @@ // Internal forward algorithms for HMMs and MHMMs #include "forward_backward.h" -#include +#include "useomp.h" void internalForward(const arma::mat& transition_t, const arma::cube& emission, const arma::vec& init, const arma::ucube& obs, arma::cube& alpha, arma::mat& scales, unsigned int threads) { diff --git a/src/logLikHMM.cpp b/src/logLikHMM.cpp index 916cf0b8..2def64ac 100644 --- a/src/logLikHMM.cpp +++ b/src/logLikHMM.cpp @@ -1,6 +1,6 @@ // log-likelihood of HMM #include -#include +#include "useomp.h" // [[Rcpp::export]] Rcpp::NumericVector logLikHMM(const arma::mat& transition, const arma::cube& emission, diff --git a/src/logLikMixHMM.cpp b/src/logLikMixHMM.cpp index 9784f280..1ea12b7a 100644 --- a/src/logLikMixHMM.cpp +++ b/src/logLikMixHMM.cpp @@ -1,7 +1,7 @@ // log-likelihood of MHMM using log-space #include #include "reparma.h" -#include +#include "useomp.h" // [[Rcpp::export]] Rcpp::NumericVector logLikMixHMM(const arma::mat& transition, const arma::cube& emission, diff --git a/src/log_EM.cpp b/src/log_EM.cpp index db1c7873..f96848c4 100644 --- a/src/log_EM.cpp +++ b/src/log_EM.cpp @@ -2,7 +2,7 @@ #include "log_forward_backward.h" #include "logsumexp.h" -#include +#include "useomp.h" // [[Rcpp::export]] Rcpp::List log_EM(const arma::mat& transition_, const arma::cube& emission_, const arma::vec& init_, const arma::ucube& obs, const arma::uvec& nSymbols, diff --git a/src/log_EMx.cpp b/src/log_EMx.cpp index 6bee6d47..a5032b58 100644 --- a/src/log_EMx.cpp +++ b/src/log_EMx.cpp @@ -4,7 +4,7 @@ #include "optcoef.h" #include "logsumexp.h" #include "reparma.h" -#include +#include "useomp.h" // [[Rcpp::export]] Rcpp::List log_EMx(const arma::mat& transition_, const arma::cube& emission_, diff --git a/src/log_forwardbackward.cpp b/src/log_forwardbackward.cpp index 67619f88..3720f2ca 100644 --- a/src/log_forwardbackward.cpp +++ b/src/log_forwardbackward.cpp @@ -1,7 +1,7 @@ // Forward-backward algorithm for non-mixture hidden Markov models using log-space #include "log_forward_backward.h" -#include +#include "useomp.h" // [[Rcpp::export]] Rcpp::List log_forwardbackward(const arma::mat& transition_, const arma::cube& emission_, diff --git a/src/log_forwardbackwardx.cpp b/src/log_forwardbackwardx.cpp index 9bc97778..d3266346 100644 --- a/src/log_forwardbackwardx.cpp +++ b/src/log_forwardbackwardx.cpp @@ -2,7 +2,7 @@ #include "log_forward_backward.h" #include "reparma.h" -#include +#include "useomp.h" // [[Rcpp::export]] Rcpp::List log_forwardbackwardx(const arma::mat& transition_, diff --git a/src/log_internalBackward.cpp b/src/log_internalBackward.cpp index 6afc0768..0cf921e1 100644 --- a/src/log_internalBackward.cpp +++ b/src/log_internalBackward.cpp @@ -2,7 +2,7 @@ #include "forward_backward.h" #include "logsumexp.h" -#include +#include "useomp.h" void log_internalBackward(const arma::mat& transition, const arma::cube& emission, const arma::ucube& obs, arma::cube& beta, unsigned int threads) { diff --git a/src/log_internalForward.cpp b/src/log_internalForward.cpp index e319d206..85c03424 100644 --- a/src/log_internalForward.cpp +++ b/src/log_internalForward.cpp @@ -2,7 +2,7 @@ #include "forward_backward.h" #include "logsumexp.h" -#include +#include "useomp.h" void log_internalForward(const arma::mat& transition, const arma::cube& emission, const arma::vec& init, const arma::ucube& obs, arma::cube& alpha, unsigned int threads) { diff --git a/src/log_logLikHMM.cpp b/src/log_logLikHMM.cpp index f143d56c..dc26158b 100644 --- a/src/log_logLikHMM.cpp +++ b/src/log_logLikHMM.cpp @@ -1,7 +1,7 @@ // log-likelihood of HMM using log-space #include "logsumexp.h" -#include +#include "useomp.h" // [[Rcpp::export]] Rcpp::NumericVector log_logLikHMM(const arma::mat& transition_, const arma::cube& emission_, diff --git a/src/log_logLikMixHMM.cpp b/src/log_logLikMixHMM.cpp index a53f401b..b0e32980 100644 --- a/src/log_logLikMixHMM.cpp +++ b/src/log_logLikMixHMM.cpp @@ -2,7 +2,7 @@ #include "logsumexp.h" #include "reparma.h" -#include +#include "useomp.h" // [[Rcpp::export]] Rcpp::NumericVector log_logLikMixHMM(arma::mat transition, arma::cube emission, arma::vec init, diff --git a/src/log_objective.cpp b/src/log_objective.cpp index b755e5eb..1aa01a6b 100644 --- a/src/log_objective.cpp +++ b/src/log_objective.cpp @@ -2,7 +2,7 @@ #include "log_forward_backward.h" #include "logsumexp.h" -#include +#include "useomp.h" // [[Rcpp::export]] Rcpp::List log_objective(const arma::mat& transition, const arma::cube& emission, diff --git a/src/log_objectivex.cpp b/src/log_objectivex.cpp index 731fa947..7988d742 100644 --- a/src/log_objectivex.cpp +++ b/src/log_objectivex.cpp @@ -3,7 +3,7 @@ #include "logsumexp.h" #include "reparma.h" -#include +#include "useomp.h" // [[Rcpp::export]] Rcpp::List log_objectivex(const arma::mat& transition, const arma::cube& emission, const arma::vec& init, const arma::ucube& obs, const arma::umat& ANZ, diff --git a/src/objective.cpp b/src/objective.cpp index 225f8f90..1ab6920f 100644 --- a/src/objective.cpp +++ b/src/objective.cpp @@ -1,7 +1,7 @@ // log-likelihood and gradients of HMM #include "optcoef.h" #include "forward_backward.h" -#include +#include "useomp.h" // [[Rcpp::export]] Rcpp::List objective(const arma::mat& transition, const arma::cube& emission, diff --git a/src/objectivex.cpp b/src/objectivex.cpp index 70eb2ea9..65b91118 100644 --- a/src/objectivex.cpp +++ b/src/objectivex.cpp @@ -2,7 +2,7 @@ #include "optcoef.h" #include "forward_backward.h" #include "reparma.h" -#include +#include "useomp.h" // [[Rcpp::export]] Rcpp::List objectivex(const arma::mat& transition, const arma::cube& emission, diff --git a/src/useomp.h b/src/useomp.h new file mode 100644 index 00000000..0c7ec2fe --- /dev/null +++ b/src/useomp.h @@ -0,0 +1,3 @@ +#ifdef _OPENMP + #include +#endif