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

Allow users to specify lib & include paths for all dependencies #2834

Closed
wants to merge 37 commits into from
Closed
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
e0e1dfd
Testing 1
andrjohns Oct 24, 2022
dd09c41
Merge branch 'develop' into lib-paths-2
andrjohns Oct 24, 2022
792bf0b
sundials interface changes
andrjohns Oct 24, 2022
a4d8d87
Path and lib fixes
andrjohns Oct 24, 2022
10074f0
Fix test linking
andrjohns Oct 24, 2022
41f809e
Add libs testing workflow
andrjohns Oct 24, 2022
5167814
Update testing workflow
andrjohns Oct 24, 2022
b573397
yaml typo
andrjohns Oct 24, 2022
f4573e3
Test install 3.3.9 eigen
andrjohns Oct 24, 2022
7c89eb4
Permissions
andrjohns Oct 24, 2022
d155b07
Permissions
andrjohns Oct 24, 2022
faf23c5
older
andrjohns Oct 24, 2022
01a560b
Expand tests
andrjohns Oct 24, 2022
7477808
Update naming
andrjohns Oct 24, 2022
e609398
Fix linebreak
andrjohns Oct 24, 2022
7b0d205
Add opencl to workflow
andrjohns Oct 24, 2022
a33c785
Reduce parallelism opencl tests
andrjohns Oct 24, 2022
64c620e
Reduce parallelism opencl tests
andrjohns Oct 24, 2022
22eeb6c
Simplify tests
andrjohns Oct 24, 2022
64ac7bb
Update workflows and add version checks
andrjohns Oct 25, 2022
c5def60
Consolidate version checking
andrjohns Oct 25, 2022
b6aae98
Workflow naming
andrjohns Oct 25, 2022
2b69c06
Tidy ordering
andrjohns Oct 25, 2022
079119b
Merge branch 'develop' into lib-paths-2
andrjohns Oct 25, 2022
a257548
[Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1
stan-buildbot Oct 25, 2022
4407ba4
Restructure ifdefs to avoid clangformat breakages
andrjohns Oct 25, 2022
2930adb
Merge branch 'stan-dev:develop' into feature/specify-lib-paths
andrjohns Oct 25, 2022
2e827b9
Make SUNDIALS_INC consistent
andrjohns Oct 26, 2022
1cbd670
Make SUNDIALS_INC consistent
andrjohns Oct 26, 2022
f9500bb
Merge branch 'develop' into feature/specify-lib-paths
andrjohns Nov 14, 2022
873d86f
Merge branch 'develop' into feature/specify-lib-paths
andrjohns Dec 2, 2022
87630b0
Split LIBSUNDIALS to TARGETS
andrjohns Dec 2, 2022
a3892ed
Update test dependency linking
andrjohns Dec 5, 2022
9c827fe
Only include version-checking header with external libs
andrjohns Dec 6, 2022
95839e4
Fix TBB
andrjohns Dec 6, 2022
c3b7b2a
Revert SUNDIALS backwards-compatibility
andrjohns Dec 9, 2022
6e0d75a
Missed workflow update
andrjohns Dec 9, 2022
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
103 changes: 103 additions & 0 deletions .github/workflows/system_libraries.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
name: System Libraries

on:
pull_request:
branches: [ develop, master ]
push:
branches: [ develop ]
paths-ignore:
- 'doygen/**'
- 'hooks/**'
- 'licenses/**'
- 'LICENSE.md'
- 'README.md'
- 'RELEASE-NOTES.txt'
permissions:
contents: read

jobs:
system-libraries-fwd-mix:
permissions:
actions: write # for n1hility/cancel-previous-runs to create & stop workflow runs
contents: read # for actions/checkout to fetch code
name: System Library Linking - fwd and non-fun mix tests
runs-on: ubuntu-22.04

steps:
- uses: n1hility/cancel-previous-runs@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/master' && github.ref != 'refs/heads/develop'"

- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- name: Install system libraries
run: |
# Eigen version in 22.04 repos (3.4) not yet compatible with Stan,
# manually install 3.3.9 from Debian repositories
wget http://ftp.de.debian.org/debian/pool/main/e/eigen3/libeigen3-dev_3.3.9-2_all.deb
sudo dpkg -i ./libeigen3-dev_3.3.9-2_all.deb
sudo apt-get install -y libboost-all-dev libtbb-dev libsundials-dev ocl-icd-libopencl1 ocl-icd-opencl-dev opencl-c-headers opencl-clhpp-headers
echo "EIGEN_INC=/usr/include/eigen3/" >> make/local
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[EIGEN_INC]: We don't need a new variable. This is literally the existing EIGEN make variable. Unless we want this to be renaming all the includes.

echo "BOOST_INC=/usr/include/" >> make/local
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[BOOST_INC]: this should just be BOOST

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is missing the proper include directory.

echo "TBB_INC=/usr/include/" >> make/local
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[TBB_INC]: this is the same as the TBB variable. We should just use that. Also, this isn't pointing to the proper include directory.

echo "TBB_LIB=/usr/lib/86_64-linux-gnu" >> make/local
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks wrong for the TBB include library (By inspection). An example from doxygen:

TBB_LIB="$TBB/lib/intel64/gcc4.8"

I'd expect there to be a TBB somewhere.

echo "SUNDIALS_INC=/usr/include" >> make/local
echo "SUNDIALS_LIB=/usr/lib/x86_64-linux-gnu" >> make/local
echo "OPENCL_INC=/usr/include/" >> make/local
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[OPENCL_INC]: this should just be OPENCL and the include is not correct.

echo "OPENCL_LIB=/usr/lib/x86_64-linux-gnu" >> make/local
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[OPENCL_LIB]: should we just use the existing LDLIBS_OPENCL variable? You can just specify the link libraries directly.

echo "STAN_OPENCL=true" >> make/local
- name: Run fwd and non-fun mix tests
run: |
python runTests.py -j2 test/unit/math/fwd
python runTests.py -j2 test/unit/math/mix/core
python runTests.py -j2 test/unit/math/mix/functor
python runTests.py -j2 test/unit/math/mix/meta
python runTests.py -j2 test/unit/math/mix/prob
python runTests.py -j2 test/unit/math/mix/*_test.cpp
- name: Upload gtest_output xml
uses: actions/upload-artifact@v3
if: failure()
with:
name: gtest_outputs_xml
path: '**/*_test.xml'
system-libraries-rev:
permissions:
actions: write # for n1hility/cancel-previous-runs to create & stop workflow runs
contents: read # for actions/checkout to fetch code
name: System Library Linking - rev tests
runs-on: ubuntu-22.04

steps:
- uses: n1hility/cancel-previous-runs@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/master' && github.ref != 'refs/heads/develop'"

- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- name: Install system libraries
run: |
# Eigen version in 22.04 repos (3.4) not yet compatible with Stan,
# manually install 3.3.9 from Debian repositories
wget http://ftp.de.debian.org/debian/pool/main/e/eigen3/libeigen3-dev_3.3.9-2_all.deb
sudo dpkg -i ./libeigen3-dev_3.3.9-2_all.deb
sudo apt-get install -y libboost-all-dev libtbb-dev libsundials-dev ocl-icd-libopencl1 ocl-icd-opencl-dev opencl-c-headers opencl-clhpp-headers
echo "EIGEN_INC=/usr/include/eigen3/" >> make/local
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are these repeated from above?

echo "BOOST_INC=/usr/include/" >> make/local
echo "TBB_INC=/usr/include/" >> make/local
echo "TBB_LIB=/usr/lib/86_64-linux-gnu" >> make/local
echo "SUNDIALS_INC=/usr/include" >> make/local
echo "SUNDIALS_LIB=/usr/lib/x86_64-linux-gnu" >> make/local
echo "OPENCL_INC=/usr/include/" >> make/local
echo "OPENCL_LIB=/usr/lib/x86_64-linux-gnu" >> make/local
echo "STAN_OPENCL=true" >> make/local
- name: Run rev tests
run: |
python runTests.py -j2 test/unit/math/rev
- name: Upload gtest_output xml
uses: actions/upload-artifact@v3
if: failure()
with:
name: gtest_outputs_xml
path: '**/*_test.xml'
39 changes: 35 additions & 4 deletions make/compiler_flags
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ endif
O ?= 3

## setup includes
INC ?= $(INC_FIRST) -I $(if $(MATH),$(MATH),.) -I $(EIGEN) -I $(BOOST) $(INC_SUNDIALS)
INC ?= $(INC_FIRST) -I $(if $(MATH),$(MATH),.) -include stan/math/version.hpp
INC_SUNDIALS ?= -I $(SUNDIALS)/include -I $(SUNDIALS)/src/sundials
INC_GTEST ?= -I $(GTEST)/include -I $(GTEST)

Expand All @@ -117,10 +117,33 @@ CPPFLAGS_SUNDIALS ?= -DNO_FPRINTF_OUTPUT $(CPPFLAGS_OPTIM_SUNDIALS) $(CXXFLAGS_F

## setup compiler flags
CXXFLAGS_LANG ?= -std=c++1y
#CXXFLAGS_BOOST ?=
CXXFLAGS_SUNDIALS ?= -pipe $(CXXFLAGS_OPTIM_SUNDIALS) $(CPPFLAGS_FLTO_SUNDIALS)
#CXXFLAGS_GTEST

ifdef BOOST_INC
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should remove this variable in favor of just using the BOOST variable. There's no need to do this if statement.

Let's chat if you need help understanding how make works. (The doc is really tough to understand, so happy to walk you through it.) There are two things that really stand out that we shouldn't do here:

  1. ifdef BOOST_INC ... the ?= is the operator you want to use.
  2. CXXFLAGS... we're not including the C++ includes in our CXX flags. We've managed to get things consistenly split out by having INC_* and separating that from CXXFLAGS_*. There really aren't codified rules for make anywhere, but let's follow how make itself uses these variables and their naming convention so we look more standard than just inventing a bunch of stuff that makes it harder to manage than it already is.

CXXFLAGS_BOOST ?= -I $(BOOST_INC)
else
CXXFLAGS_BOOST ?= -I $(BOOST)
endif

ifdef SUNDIALS_LIB
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment as above

LDFLAGS_SUNDIALS ?= -L $(SUNDIALS_LIB) -lsundials_cvodes -lsundials_idas -lsundials_kinsol -lsundials_nvecserial
ifdef SUNDIALS_INC
CXXFLAGS_SUNDIALS += -I $(SUNDIALS_INC)
endif
else
CXXFLAGS_SUNDIALS += $(INC_SUNDIALS)
endif

ifdef SUNDIALS_INTERFACE_OLD
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

??? what's SUNDIALS_INTERFACE_OLD?

this looks like some testing that got included.

CXXFLAGS_SUNDIALS += -DSUNDIALS_INTERFACE_OLD
endif

ifdef EIGEN_INC
CXXFLAGS_EIGEN ?= -I $(EIGEN_INC)
else
CXXFLAGS_EIGEN ?= -I $(EIGEN)
endif

## These are the other compiler flags that can be set.
##
Expand Down Expand Up @@ -218,7 +241,15 @@ ifdef STAN_OPENCL
CPPFLAGS_OPENCL ?= -DSTAN_OPENCL -DOPENCL_DEVICE_ID=$(OPENCL_DEVICE_ID) -DOPENCL_PLATFORM_ID=$(OPENCL_PLATFORM_ID)
CPPFLAGS_OPENCL += -DCL_HPP_TARGET_OPENCL_VERSION=120 -DCL_HPP_MINIMUM_OPENCL_VERSION=120
CPPFLAGS_OPENCL += -DCL_HPP_ENABLE_EXCEPTIONS -Wno-ignored-attributes

ifdef OPENCL_LIB
LDFLAGS_OPENCL ?= -L $(OPENCL_LIB)
endif
ifdef OPENCL_INC
CXXFLAGS_OPENCL ?= -I $(OPENCL_INC)
else
CXXFLAGS_OPENCL ?= -I $(OPENCL)
endif

ifdef INTEGRATED_OPENCL
CPPFLAGS_OPENCL += -DINTEGRATED_OPENCL=1
Expand Down Expand Up @@ -312,9 +343,9 @@ ifdef STAN_MPI
CXXFLAGS_MPI ?= -Wno-delete-non-virtual-dtor
endif

CXXFLAGS += $(CXXFLAGS_LANG) $(CXXFLAGS_OS) $(CXXFLAGS_WARNINGS) $(CXXFLAGS_BOOST) $(CXXFLAGS_EIGEN) $(CXXFLAGS_OPENCL) $(CXXFLAGS_MPI) $(CXXFLAGS_THREADS) $(CXXFLAGS_TBB) $(CXXFLAGS_FLTO) $(CXXFLAGS_OPTIM) $(CXXFLAGS_NO_RANGE_CHECKS) -O$(O) $(INC)
CXXFLAGS += $(CXXFLAGS_LANG) $(CXXFLAGS_OS) $(CXXFLAGS_WARNINGS) $(CXXFLAGS_BOOST) $(CXXFLAGS_EIGEN) $(CXXFLAGS_OPENCL) $(CXXFLAGS_MPI) $(CXXFLAGS_THREADS) $(CXXFLAGS_TBB) $(CXXFLAGS_SUNDIALS) $(CXXFLAGS_FLTO) $(CXXFLAGS_OPTIM) $(CXXFLAGS_NO_RANGE_CHECKS) -O$(O) $(INC)
CPPFLAGS += $(CPPFLAGS_LANG) $(CPPFLAGS_OS) $(CPPFLAGS_WARNINGS) $(CPPFLAGS_BOOST) $(CPPFLAGS_EIGEN) $(CPPFLAGS_OPENCL) $(CPPFLAGS_TBB) $(CPPFLAGS_MPI) $(CPPFLAGS_TBB) $(CPPFLAGS_FLTO) $(CPPFLAGS_OPTIM) $(CXXFLAGS_NO_RANGE_CHECKS)
LDFLAGS += $(LDFLAGS_LANG) $(LDFLAGS_OS) $(LDFLAGS_WARNINGS) $(LDFLAGS_BOOST) $(LDFLAGS_EIGEN) $(LDFLAGS_OPENCL) $(LDFLAGS_MPI) $(LDFLAGS_TBB) $(LDFLAGS_FLTO) $(LDFLAGS_OPTIM)
LDFLAGS += $(LDFLAGS_LANG) $(LDFLAGS_OS) $(LDFLAGS_WARNINGS) $(LDFLAGS_BOOST) $(LDFLAGS_EIGEN) $(LDFLAGS_OPENCL) $(LDFLAGS_MPI) $(LDFLAGS_TBB) $(LDFLAGS_SUNDIALS) $(LDFLAGS_FLTO) $(LDFLAGS_OPTIM)
LDLIBS += $(LDLIBS_LANG) $(LDLIBS_OS) $(LDLIBS_WARNINGS) $(LDLIBS_BOOST) $(LDLIBS_EIGEN) $(LDLIBS_OPENCL) $(LDLIBS_MPI) $(LDLIBS_TBB)

.PHONY: print-compiler-flags
Expand Down
6 changes: 4 additions & 2 deletions make/libraries
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ CPPLINT ?= $(MATH)lib/cpplint_1.4.5
# Fortran bindings which we do not need for stan-math. Thus these targets
# are ignored here. This convention was introduced with 4.0.
##

ifndef SUNDIALS_LIB
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this shouldn't be necessary.

SUNDIALS_CVODES := $(patsubst %.c,%.o,\
$(wildcard $(SUNDIALS)/src/cvodes/*.c) \
$(filter-out $(SUNDIALS)/src/sundials/sundials_profiler.c, $(wildcard $(SUNDIALS)/src/sundials/*.c)) \
Expand Down Expand Up @@ -87,7 +87,9 @@ $(STAN_SUNDIALS_HEADERS) : $(LIBSUNDIALS)
clean-sundials:
@echo ' cleaning sundials targets'
$(RM) $(wildcard $(sort $(SUNDIALS_CVODES) $(SUNDIALS_IDAS) $(SUNDIALS_KINSOL) $(SUNDIALS_NVECSERIAL) $(LIBSUNDIALS)))

else
LIBSUNDIALS := $(SUNDIALS_LIB)/libsundials_nvecserial.a $(SUNDIALS_LIB)/libsundials_cvodes.a $(SUNDIALS_LIB)/libsundials_idas.a $(SUNDIALS_LIB)/libsundials_kinsol.a
endif

############################################################
# TBB build rules
Expand Down
8 changes: 0 additions & 8 deletions stan/math/prim/core/init_threadpool_tbb.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,6 @@

#include <boost/lexical_cast.hpp>

#ifndef TBB_INTERFACE_NEW
#include <tbb/tbb_stddef.h>

#if TBB_VERSION_MAJOR >= 2020
#define TBB_INTERFACE_NEW
#endif
#endif

#ifdef TBB_INTERFACE_NEW
#include <tbb/global_control.h>
#include <tbb/task_arena.h>
Expand Down
59 changes: 59 additions & 0 deletions stan/math/rev/functor/algebra_solver_fp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
#include <stan/math/prim/fun/to_array_1d.hpp>
#include <stan/math/prim/fun/to_vector.hpp>
#include <stan/math/prim/fun/value_of.hpp>
#ifndef SUNDIALS_INTERFACE_OLD
#include <sundials/sundials_context.h>
#endif
#include <kinsol/kinsol.h>
#include <sunmatrix/sunmatrix_dense.h>
#include <sunlinsol/sunlinsol_dense.h>
Expand All @@ -33,8 +35,10 @@ namespace math {
*/
template <typename F>
struct KinsolFixedPointEnv {
#ifndef SUNDIALS_INTERFACE_OLD
/** Sundials context **/
sundials::Context sundials_context_;
#endif
/** RHS functor. */
const F& f_;
/** val of params for @c y_ to refer to when
Expand All @@ -61,6 +65,7 @@ struct KinsolFixedPointEnv {
/** NVECTOR for scaling f */
N_Vector nv_f_scal_;

#ifndef SUNDIALS_INTERFACE_OLD
/** Constructor when y is data */
template <typename T, typename T_u, typename T_f>
KinsolFixedPointEnv(const F& f, const Eigen::Matrix<T, -1, 1>& x,
Expand Down Expand Up @@ -115,6 +120,60 @@ struct KinsolFixedPointEnv {
NV_Ith_S(nv_f_scal_, i) = stan::math::value_of(f_scale[i]);
}
}
#else
/** Constructor when y is data */
template <typename T, typename T_u, typename T_f>
KinsolFixedPointEnv(const F& f, const Eigen::Matrix<T, -1, 1>& x,
const Eigen::VectorXd& y, const std::vector<double>& x_r,
const std::vector<int>& x_i, std::ostream* msgs,
const std::vector<T_u>& u_scale,
const std::vector<T_f>& f_scale)
: f_(f),
y_dummy(),
y_(y),
N_(x.size()),
M_(y.size()),
x_r_(x_r),
x_i_(x_i),
msgs_(msgs),
mem_(KINCreate()),
nv_x_(N_VNew_Serial(N_)),
nv_u_scal_(N_VNew_Serial(N_)),
nv_f_scal_(N_VNew_Serial(N_)) {
for (int i = 0; i < N_; ++i) {
NV_Ith_S(nv_x_, i) = stan::math::value_of(x(i));
NV_Ith_S(nv_u_scal_, i) = stan::math::value_of(u_scale[i]);
NV_Ith_S(nv_f_scal_, i) = stan::math::value_of(f_scale[i]);
}
}

/** Constructor when y is param */
template <typename T, typename T_u, typename T_f>
KinsolFixedPointEnv(const F& f, const Eigen::Matrix<T, -1, 1>& x,
const Eigen::Matrix<stan::math::var, -1, 1>& y,
const std::vector<double>& x_r,
const std::vector<int>& x_i, std::ostream* msgs,
const std::vector<T_u>& u_scale,
const std::vector<T_f>& f_scale)
: f_(f),
y_dummy(stan::math::value_of(y)),
y_(y_dummy),
N_(x.size()),
M_(y.size()),
x_r_(x_r),
x_i_(x_i),
msgs_(msgs),
mem_(KINCreate()),
nv_x_(N_VNew_Serial(N_)),
nv_u_scal_(N_VNew_Serial(N_)),
nv_f_scal_(N_VNew_Serial(N_)) {
for (int i = 0; i < N_; ++i) {
NV_Ith_S(nv_x_, i) = stan::math::value_of(x(i));
NV_Ith_S(nv_u_scal_, i) = stan::math::value_of(u_scale[i]);
NV_Ith_S(nv_f_scal_, i) = stan::math::value_of(f_scale[i]);
}
}
#endif

~KinsolFixedPointEnv() {
N_VDestroy_Serial(nv_x_);
Expand Down
19 changes: 19 additions & 0 deletions stan/math/rev/functor/cvodes_integrator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
#include <stan/math/prim/err.hpp>
#include <stan/math/prim/functor/apply.hpp>
#include <stan/math/prim/fun/value_of.hpp>
#ifndef SUNDIALS_INTERFACE_OLD
#include <sundials/sundials_context.h>
#endif
#include <cvodes/cvodes.h>
#include <nvector/nvector_serial.h>
#include <sunlinsol/sunlinsol_dense.h>
Expand Down Expand Up @@ -37,7 +39,9 @@ class cvodes_integrator {
using T_y0_t0 = return_type_t<T_y0, T_t0>;

const char* function_name_;
#ifndef SUNDIALS_INTERFACE_OLD
sundials::Context sundials_context_;
#endif
const F& f_;
const Eigen::Matrix<T_y0_t0, Eigen::Dynamic, 1> y0_;
const T_t0 t0_;
Expand Down Expand Up @@ -194,7 +198,9 @@ class cvodes_integrator {
long int max_num_steps, // NOLINT(runtime/int)
std::ostream* msgs, const T_Args&... args)
: function_name_(function_name),
#ifndef SUNDIALS_INTERFACE_OLD
sundials_context_(),
#endif
f_(f),
y0_(y0.template cast<T_y0_t0>()),
t0_(t0),
Expand Down Expand Up @@ -234,10 +240,19 @@ class cvodes_integrator {
absolute_tolerance_);
check_positive(function_name, "max_num_steps", max_num_steps_);

#ifndef SUNDIALS_INTERFACE_OLD
nv_state_ = N_VMake_Serial(N_, &coupled_state_[0], sundials_context_);
nv_state_sens_ = nullptr;

A_ = SUNDenseMatrix(N_, N_, sundials_context_);
LS_ = SUNLinSol_Dense(nv_state_, A_, sundials_context_);
#else
nv_state_ = N_VMake_Serial(N_, &coupled_state_[0]);
nv_state_sens_ = nullptr;

A_ = SUNDenseMatrix(N_, N_);
LS_ = SUNLinSol_Dense(nv_state_, A_);
#endif

if (num_y0_vars_ + num_args_vars_ > 0) {
nv_state_sens_
Expand Down Expand Up @@ -268,7 +283,11 @@ class cvodes_integrator {
std::vector<Eigen::Matrix<T_Return, Eigen::Dynamic, 1>> operator()() {
std::vector<Eigen::Matrix<T_Return, Eigen::Dynamic, 1>> y;

#ifndef SUNDIALS_INTERFACE_OLD
void* cvodes_mem = CVodeCreate(Lmm, sundials_context_);
#else
void* cvodes_mem = CVodeCreate(Lmm);
#endif
if (cvodes_mem == nullptr) {
throw std::runtime_error("CVodeCreate failed to allocate memory");
}
Expand Down
Loading