Skip to content
This repository has been archived by the owner on Jul 17, 2024. It is now read-only.

Commit

Permalink
Merge pull request #85 from nlmixr2/84-remove-lincmt-solved-+-grad-fo…
Browse files Browse the repository at this point in the history
…r-intel-compiler

84 remove lincmt solved + grad for intel compiler
  • Loading branch information
mattfidler authored Jan 25, 2024
2 parents 2963b78 + 326acc9 commit 94be647
Show file tree
Hide file tree
Showing 8 changed files with 166 additions and 16 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: rxode2parse
Title: Parsing and Code Generation Functions for 'rxode2'
Version: 2.0.17.9000
Version: 2.0.18
Authors@R: c(
person("Matthew L.", "Fidler", , "matthew.fidler@gmail.com", role = c("aut", "cre"),
comment = c(ORCID = "0000-0001-8538-6691")),
Expand Down Expand Up @@ -56,4 +56,4 @@ Encoding: UTF-8
Language: en-US
NeedsCompilation: yes
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
RoxygenNote: 7.3.1
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export(.extraC)
export(.extraCnow)
export(.getLastIdLvl)
export(.getWh)
export(.linCmtSens)
export(.rxC)
export(.rxSEeqUsr)
export(.rxTransInfo)
Expand Down
8 changes: 7 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# rxode2parse (development version)
# rxode2parse 2.0.18

* Removed linear compartment solutions with gradients from rxode2parse
(and rxode2) when compiled with intel c++ compiler (since it crashes
while compiling).

* Fixed `m1mac` string issues as requested by CRAN

# rxode2parse 2.0.17

Expand Down
12 changes: 12 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -296,4 +296,16 @@ rxDerived <- function(..., verbose = FALSE, digits = 0) {
.r <- rex::rex(start, end)
.d <- data.table::data.table(a=1)
}
#' Is the linear systems with gradients built-in
#'
#' @return logical (TRUE) if the solved systems with gradients are
#' built-in. (FALSE) if the solves systems with gradients are absent
#' @export
#' @author Matthew L. Fidler
#' @keywords internal
#' @examples
#' .linCmtSens()
.linCmtSens <- function() {
as.logical(.Call(`_rxode2parse_linCmtB`))
}
## nocov end
22 changes: 22 additions & 0 deletions man/dot-linCmtSens.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions src/Makevars.in
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,3 @@ PKG_LIBS = $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) $(SHLIB_OPENMP_CXXFLAGS) @SL@
# Release options
PKG_CFLAGS = -D_isrxode2parse_
PKG_CXXFLAGS = $(SHLIB_OPENMP_CXXFLAGS) -D_isrxode2parse_ -DBOOST_DISABLE_ASSERTS -DBOOST_NO_CXX11_STATIC_ASSERT -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -D_HAS_AUTO_PTR_ETC=0 -D_REENTRANT -@ISYSTEM@"$(BH)" -@ISYSTEM@"$(EG)" $(SH) -@ISYSTEM@"$(RCPP)"


2 changes: 2 additions & 0 deletions src/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ SEXP _rxode2parse_codeLoaded(void);
SEXP _rxode2parse_codegen(SEXP c_file, SEXP prefix, SEXP libname, SEXP pMd5, SEXP timeId, SEXP lastMv, SEXP goodFuns);
SEXP _rxode2parse_parseModel(SEXP type);
SEXP _rxode2parse_isLinCmt(void);
SEXP _rxode2parse_linCmtB(void);

void transIniNull(void);

Expand Down Expand Up @@ -136,6 +137,7 @@ double _rxode2parse_evalUdf(const char *fun, int n, const double *args);

void R_init_rxode2parse(DllInfo *info){
R_CallMethodDef callMethods[] = {
{"_rxode2parse_linCmtB", (DL_FUNC) &_rxode2parse_linCmtB},
{"_rxode2parse_convertId_", (DL_FUNC) &_rxode2parse_convertId_, 1},
{"_rxode2parse_funPtrs", (DL_FUNC) &_rxode2parse_funPtrs, 0},
{"_rxode2parse_rxEtTransAsDataFrame_", (DL_FUNC) &_rxode2parse_rxEtTransAsDataFrame_, 1},
Expand Down
131 changes: 120 additions & 11 deletions src/lincmtB.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,105 @@
#if defined(__INTEL_LLVM_COMPILER)
#define rxode2parseNoLinCmtB
#endif

//#undef NDEBUG
#ifdef rxode2parseNoLinCmtB
//================================================================================
// NO solved systems with gradient
//================================================================================
#ifndef NDEBUG
#define NDEBUG // just in case
#endif
#include <Rcpp.h>


#define op_global _rxode2parse_op_global
#define rx_global _rxode2parse_rx_global
#define AMT _rxode2parse_AMT
#define LAG _rxode2parse_LAG
#define RATE _rxode2parse_RATE
#define DUR _rxode2parse_DUR
#define calc_mtime _rxode2parse_calc_mtime
#define getTime_ _rxode2parse_getTime_
#define getTime _rxode2parse_getTime
#define _locateTimeIndex _rxode2parse_locateTimeIndex

#include "../inst/include/rxode2parse.h"
extern "C" void _rxode2parse_unprotect();

extern "C" {
rx_solving_options _rxode2parse_op_global;
rx_solve _rxode2parse_rx_global;
t_F AMT = NULL;
t_LAG LAG = NULL;
t_RATE RATE = NULL;
t_DUR DUR = NULL;
t_calc_mtime calc_mtime = NULL;

t_ME ME = NULL;
t_IndF IndF = NULL;

t_getTime _rxode2parse_getTime;
t_locateTimeIndex _rxode2parse_locateTimeIndex;
t_handle_evidL _rxode2parse_handle_evidL;
t_getDur _rxode2parse_getDur;
}
#define _getDur _rxode2parse_getDur

extern "C" void RSprintf(const char *format, ...);

extern "C" void _rxode2parse_assignFuns2(rx_solve rx,
rx_solving_options op,
t_F f,
t_LAG lag,
t_RATE rate,
t_DUR dur,
t_calc_mtime mtime,
t_ME me,
t_IndF indf,
t_getTime gettime,
t_locateTimeIndex timeindex,
t_handle_evidL handleEvid,
t_getDur getdur) {
_rxode2parse_rx_global = rx;
_rxode2parse_op_global = op;
AMT = f;
LAG = lag;
RATE = rate;
DUR = dur;
calc_mtime = mtime;
ME = me;
IndF = indf;
_rxode2parse_getTime = gettime;
_rxode2parse_locateTimeIndex = timeindex;
_rxode2parse_handle_evidL=handleEvid;
_rxode2parse_getDur=getdur;
}

extern "C" double linCmtB(rx_solve *rx, unsigned int id,
double _t, int linCmt,
int ncmt, int trans, int val,
double dd_p1, double dd_v1,
double dd_p2, double dd_p3,
double dd_p4, double dd_p5,
double dd_tlag, double dd_F,
double dd_rate, double dd_dur,
// oral extra parameters
double dd_ka, double dd_tlag2,
double dd_F2, double dd_rate2, double dd_dur2){
Rcpp::stop("no linCmtB builtin, probably using intel's compilers try clang/gcc");
}

extern "C" SEXP _rxode2parse_linCmtB() {
SEXP ret = PROTECT(Rf_allocVector(INTSXP, 1));
INTEGER(ret)[0] = 0;
UNPROTECT(1);
return ret;
}
#else
//================================================================================
// Solved systems with gradient
//================================================================================
#ifndef NDEBUG
#define NDEBUG // just in case
#endif
Expand All @@ -23,6 +124,13 @@
#define _locateTimeIndex _rxode2parse_locateTimeIndex

#include "../inst/include/rxode2parse.h"

extern "C" SEXP _rxode2parse_linCmtB() {
SEXP ret = PROTECT(Rf_allocVector(INTSXP, 1));
INTEGER(ret)[0] = 1;
UNPROTECT(1);
return ret;
}
extern "C" void _rxode2parse_unprotect();

extern "C" {
Expand All @@ -40,7 +148,7 @@ extern "C" {
t_getTime _rxode2parse_getTime;
t_locateTimeIndex _rxode2parse_locateTimeIndex;
t_handle_evidL _rxode2parse_handle_evidL;
t_getDur _rxode2parse_getDur;
t_getDur _rxode2parse_getDur;
}
#define _getDur _rxode2parse_getDur

Expand All @@ -51,7 +159,7 @@ extern "C" void _rxode2parse_assignFuns2(rx_solve rx,
t_F f,
t_LAG lag,
t_RATE rate,
t_DUR dur,
t_DUR dur,
t_calc_mtime mtime,
t_ME me,
t_IndF indf,
Expand Down Expand Up @@ -1018,7 +1126,7 @@ namespace stan {
eB0*(ka*(Al12*beta2 - beta*Al123) + Al23*beta2 - beta3*A2last) +
eKa0*(ka*k32 - ka2);
Al12 = Al12*k23;
A3 = eB0*(A3last*(ka*beta2-ka*E2*beta+ E2*beta2 - beta3) - ka*Al12*beta + k23*beta2*A2last)
A3 = eB0*(A3last*(ka*beta2-ka*E2*beta+ E2*beta2 - beta3) - ka*Al12*beta + k23*beta2*A2last)
-eA0*(ka*alpha2*A3last - ka*E2*alpha*A3last - ka*Al12*alpha + E2*alpha2*A3last + k23*alpha2*A2last-alpha3*A3last)+
eKa0*ka*k23;
#undef E2
Expand Down Expand Up @@ -2848,56 +2956,56 @@ extern "C" double linCmtB(rx_solve *rx, unsigned int id,
if (op->linBflag & 64) { // tlag
A[cur++] = updateDiff(rx, id, _t, 7, linCmt, ncmt, trans,
dd_p1, dd_v1, dd_p2, dd_p3, dd_p4, dd_p5,
dd_tlag, dd_F, dd_rate, dd_dur,
dd_tlag, dd_F, dd_rate, dd_dur,
dd_ka, dd_tlag2, dd_F2, dd_rate2, dd_dur2,
op->cTlag, op->hTlag, v0);
}
if (op->linBflag & 128) { // f 8
A[cur++] = updateDiff(rx, id, _t, 8, linCmt, ncmt, trans,
dd_p1, dd_v1, dd_p2, dd_p3, dd_p4, dd_p5,
dd_tlag, dd_F, dd_rate, dd_dur,
dd_tlag, dd_F, dd_rate, dd_dur,
dd_ka, dd_tlag2, dd_F2, dd_rate2, dd_dur2,
op->cF, op->hF, v0);
}
if (op->linBflag & 256) { // rate 9
A[cur++] = updateDiff(rx, id, _t, 9, linCmt, ncmt, trans,
dd_p1, dd_v1, dd_p2, dd_p3, dd_p4, dd_p5,
dd_tlag, dd_F, dd_rate, dd_dur,
dd_tlag, dd_F, dd_rate, dd_dur,
dd_ka, dd_tlag2, dd_F2, dd_rate2, dd_dur2,
op->cRate, op->hRate, v0);
}
if (op->linBflag & 512) { // dur 10
A[cur++] = updateDiff(rx, id, _t, 10, linCmt, ncmt, trans,
dd_p1, dd_v1, dd_p2, dd_p3, dd_p4, dd_p5,
dd_tlag, dd_F, dd_rate, dd_dur,
dd_tlag, dd_F, dd_rate, dd_dur,
dd_ka, dd_tlag2, dd_F2, dd_rate2, dd_dur2,
op->cDur, op->hDur, v0);
}
if (op->linBflag & 2048) { // tlag2 12
A[cur++] = updateDiff(rx, id, _t, 12, linCmt, ncmt, trans,
dd_p1, dd_v1, dd_p2, dd_p3, dd_p4, dd_p5,
dd_tlag, dd_F, dd_rate, dd_dur,
dd_tlag, dd_F, dd_rate, dd_dur,
dd_ka, dd_tlag2, dd_F2, dd_rate2, dd_dur2,
op->cTlag2, op->hTlag2, v0);
}
if (op->linBflag & 4096) { // f2 13
A[cur++] = updateDiff(rx, id, _t, 13, linCmt, ncmt, trans,
dd_p1, dd_v1, dd_p2, dd_p3, dd_p4, dd_p5,
dd_tlag, dd_F, dd_rate, dd_dur,
dd_tlag, dd_F, dd_rate, dd_dur,
dd_ka, dd_tlag2, dd_F2, dd_rate2, dd_dur2,
op->cF2, op->hF2, v0);
}
if (op->linBflag & 8192) { // rate2 14
A[cur++] = updateDiff(rx, id, _t, 14, linCmt, ncmt, trans,
dd_p1, dd_v1, dd_p2, dd_p3, dd_p4, dd_p5,
dd_tlag, dd_F, dd_rate, dd_dur,
dd_tlag, dd_F, dd_rate, dd_dur,
dd_ka, dd_tlag2, dd_F2, dd_rate2, dd_dur2,
op->cRate2, op->hRate2, v0);
}
if (op->linBflag & 16384) { // dur2 15
A[cur++] = updateDiff(rx, id, _t, 15, linCmt, ncmt, trans,
dd_p1, dd_v1, dd_p2, dd_p3, dd_p4, dd_p5,
dd_tlag, dd_F, dd_rate, dd_dur,
dd_tlag, dd_F, dd_rate, dd_dur,
dd_ka, dd_tlag2, dd_F2, dd_rate2, dd_dur2,
op->cDur2, op->hDur2, v0);
}
Expand Down Expand Up @@ -2931,3 +3039,4 @@ extern "C" double linCmtB(rx_solve *rx, unsigned int id,
Rf_errorcall(R_NilValue, "unsupported sensitivity");
}
}
#endif

0 comments on commit 94be647

Please sign in to comment.