Skip to content

Commit

Permalink
Jtimes setup (#116)
Browse files Browse the repository at this point in the history
* Updates for new upstream AnyODE

* update header

* Drop custom pytest markers slow and veryslow (too much maintainence burden)

* drop unused pytest

* bump dev version

* update dockerimage used in CI

* drop pytest-pep8 for now
  • Loading branch information
bjodah authored Nov 23, 2020
1 parent a845348 commit 083964e
Show file tree
Hide file tree
Showing 21 changed files with 117 additions and 207 deletions.
1 change: 0 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ jobs:
- run: conda update python
- run: conda install conda-build
- run: conda config --add channels conda-forge
- run: conda config --add channels bjodah
- run: conda config --set show_channel_urls true
- run: conda config --set always_yes yes
- run: conda build conda-recipe
24 changes: 12 additions & 12 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,55 +17,55 @@ pipeline:
ttl: 90 # liftetime in days

# get-pre-reqs:
# image: bjodah/bjodahimg20dev:v1.2.0
# image: bjodah/bjodahimg20dev:2.1.0
# commands:
# - mkdir ./tmp
# - git clone --recurse-submodules https://github.com/bjodah/pycvodes.git ./tmp/pycvodes

# test-py2:
# image: bjodah/bjodahimg20dev:v1.2.0
# image: bjodah/bjodahimg20dev:2.1.0
# environment:
# - CC=gcc-10
# - CXX=g++-10
# - OMP_NUM_THREADS=1
# - ANYODE_NUM_THREADS=2
# - CPLUS_INCLUDE_PATH=/usr/include/suitesparse:/opt/boost_1_73_p/include
# - CPLUS_INCLUDE_PATH=/usr/include/suitesparse:/opt/boost_1_74_p/include
# - LIBRARY_PATH=/usr/lib/x86_64-linux-gnu
# - LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu
# - SUNDBASE=/opt/sundials-5.3.0-klu-lapack
# - SUNDBASE=/opt/sundials-5.4.0-klu-lapack
# commands:
# - apt-get update && apt-get --assume-yes install python2-dev
# - bash -c "ulimit -v 2048000; .ci/test_py2.sh pyodesys $SUNDBASE"

test-sund-5.3.0-klu:
test-sund-5.4.0-klu:
group: testing
image: bjodah/bjodahimg20dev:v1.2.0
image: bjodah/bjodahimg20dev:2.1.0
environment:
- CC=gcc-10
- CXX=g++-10
- OMP_NUM_THREADS=1
- ANYODE_NUM_THREADS=2
- CPLUS_INCLUDE_PATH=/usr/include/suitesparse:/opt/boost_1_73_p/include
- CPLUS_INCLUDE_PATH=/usr/include/suitesparse:/opt/boost_1_74_p/include
- LIBRARY_PATH=/usr/lib/x86_64-linux-gnu
- LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu
- SUNDBASE=/opt/sundials-5.3.0-klu-lapack
- SUNDBASE=/opt/sundials-5.4.0-klu-lapack
commands:
- bash -c "ulimit -v 2048000; .ci/run_ci.sh pyodesys $SUNDBASE"
- ./scripts/prepare_deploy.sh
- bash -c '[[ $(python3 setup.py --version) =~ ^[0-9]+.* ]]'

test-sund-5.3.0-nolapack-noklu-extended:
test-sund-5.4.0-nolapack-noklu-extended:
group: testing
image: bjodah/bjodahimg20dev:v1.2.0
image: bjodah/bjodahimg20dev:2.1.0
environment:
- CC=gcc-10
- CXX=g++-10
- OMP_NUM_THREADS=1
- ANYODE_NUM_THREADS=2
- CPLUS_INCLUDE_PATH=/usr/include/suitesparse:/opt/boost_1_73_p/include
- CPLUS_INCLUDE_PATH=/usr/include/suitesparse:/opt/boost_1_74_p/include
- LIBRARY_PATH=/usr/lib/x86_64-linux-gnu
- LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu
- SUNDBASE=/opt/sundials-5.3.0-noklu-nolapack-extended-int64
- SUNDBASE=/opt/sundials-5.4.0-noklu-nolapack-extended-int64
- PYCVODES_NO_LAPACK=1
- PYCVODES_NO_KLU=1
commands:
Expand Down
28 changes: 0 additions & 28 deletions conftest.py

This file was deleted.

1 change: 0 additions & 1 deletion examples/tests/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
tests = glob.glob(os.path.join(os.path.dirname(__file__), '../*.py'))


@pytest.mark.veryslow
@pytest.mark.skipif(sym is None, reason='package sym missing')
@pytest.mark.parametrize('pypath', tests)
def test_examples(pypath):
Expand Down
2 changes: 1 addition & 1 deletion external/anyode
Submodule anyode updated 3 files
+2 −2 .drone.yml
+13 −12 include/anyode/anyode.hpp
+2 −2 scripts/ci.sh
2 changes: 1 addition & 1 deletion pyodesys/_release.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.13.1.dev0+git'
__version__ = '0.14.0.dev0+git'
4 changes: 2 additions & 2 deletions pyodesys/native/sources/_cvode_wrapper.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def integrate_adaptive(floating [:, ::1] y0,
long int mxsteps=0,
str iter_type='undecided', str linear_solver="default", str method='BDF',
bool with_jacobian=True, bool return_on_root=False,
int autorestart=0, bool return_on_error=False, bool with_jtimes=False,
int autorestart=0, bool return_on_error=False, bint with_jtimes=False,
bool record_rhs_xvals=False, bool record_jac_xvals=False,
bool record_order=False, bool record_fpe=False,
realtype get_dx_max_factor=0.0, bool error_outside_bounds=False,
Expand Down Expand Up @@ -246,7 +246,7 @@ def integrate_predefined(floating [:, ::1] y0,
long int mxsteps=0,
str iter_type='undecided', str linear_solver="default", str method='BDF',
bool with_jacobian=True, int autorestart=0, bool return_on_error=False,
bool with_jtimes=False,
bint with_jtimes=False,
bool record_rhs_xvals=False, bool record_jac_xvals=False,
bool record_order=False, bool record_fpe=False,
realtype get_dx_max_factor=0.0, bool error_outside_bounds=False,
Expand Down
31 changes: 17 additions & 14 deletions pyodesys/native/sources/odesys_anyode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,28 @@ template<typename Real_t=double, typename Index_t=int>
Real_t get_dx0(Real_t, const Real_t * const) override;
Real_t get_dx_max(Real_t, const Real_t * const) override;
AnyODE::Status rhs(Real_t x,
const Real_t * const __restrict__ y,
Real_t * const __restrict__ f) override;
AnyODE::Status jtimes(const Real_t * const __restrict__ v,
Real_t * const __restrict__ Jv,
const Real_t * const y,
Real_t * const f) override;
AnyODE::Status jtimes(const Real_t * const v,
Real_t * const Jv,
Real_t x,
const Real_t * const __restrict__ y,
const Real_t * const __restrict__ fy) override;
const Real_t * const y,
const Real_t * const fy) override;
AnyODE::Status jtimes_setup(Real_t t,
const Real_t * const y,
const Real_t * const fy) override;
AnyODE::Status dense_jac_cmaj(Real_t x,
const Real_t * const __restrict__ y,
const Real_t * const __restrict__ fy,
Real_t * const __restrict__ jac,
const Real_t * const y,
const Real_t * const fy,
Real_t * const jac,
long int ldim,
Real_t * const __restrict__ dfdt=nullptr) override;
Real_t * const dfdt=nullptr) override;
AnyODE::Status dense_jac_rmaj(Real_t x,
const Real_t * const __restrict__ y,
const Real_t * const __restrict__ fy,
Real_t * const __restrict__ jac,
const Real_t * const y,
const Real_t * const fy,
Real_t * const jac,
long int ldim,
Real_t * const __restrict__ dfdt=nullptr) override;
Real_t * const dfdt=nullptr) override;
AnyODE::Status roots(Real_t x, const Real_t * const y, Real_t * const out) override;
};
}
41 changes: 22 additions & 19 deletions pyodesys/native/sources/odesys_anyode_iterative.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,31 +26,34 @@ namespace odesys_anyode {
Real_t get_dx_max(Real_t, const Real_t * const) override;
Real_t max_euler_step(Real_t, const Real_t * const);
AnyODE::Status rhs(Real_t t,
const Real_t * const __restrict__ y,
Real_t * const __restrict__ f) override;
const Real_t * const y,
Real_t * const f) override;
AnyODE::Status dense_jac_cmaj(Real_t t,
const Real_t * const __restrict__ y,
const Real_t * const __restrict__ fy,
Real_t * const __restrict__ jac,
const Real_t * const y,
const Real_t * const fy,
Real_t * const jac,
long int ldim,
Real_t * const __restrict__ dfdt=nullptr) override;
Real_t * const dfdt=nullptr) override;
AnyODE::Status dense_jac_rmaj(Real_t t,
const Real_t * const __restrict__ y,
const Real_t * const __restrict__ fy,
Real_t * const __restrict__ jac,
const Real_t * const y,
const Real_t * const fy,
Real_t * const jac,
long int ldim,
Real_t * const __restrict__ dfdt=nullptr) override;
Real_t * const dfdt=nullptr) override;
AnyODE::Status sparse_jac_csc(Real_t t,
const Real_t * const __restrict__ y,
const Real_t * const __restrict__ fy,
Real_t * const __restrict__ data,
Index_t * const __restrict__ colptrs,
Index_t * const __restrict__ rowvals) override;
AnyODE::Status jtimes(const Real_t * const __restrict__ vec,
Real_t * const __restrict__ out,
const Real_t * const y,
const Real_t * const fy,
Real_t * const data,
Index_t * const colptrs,
Index_t * const rowvals) override;
AnyODE::Status jtimes(const Real_t * const vec,
Real_t * const out,
Real_t t,
const Real_t * const __restrict__ y,
const Real_t * const __restrict__ fy) override;
const Real_t * const y,
const Real_t * const fy) override;
AnyODE::Status jtimes_setup(Real_t t,
const Real_t * const y,
const Real_t * const fy) override;
AnyODE::Status roots(Real_t t, const Real_t * const y, Real_t * const out) override;
};
}
82 changes: 47 additions & 35 deletions pyodesys/native/sources/odesys_anyode_template.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,31 +57,35 @@ namespace odesys_anyode {
realtype get_dx_max(realtype, const realtype * const) override;
realtype max_euler_step(realtype, const realtype * const);
AnyODE::Status rhs(realtype t,
const realtype * const __restrict__ y,
realtype * const __restrict__ f) override;
const realtype * const ANYODE_RESTRICT y,
realtype * const ANYODE_RESTRICT f) override;
AnyODE::Status dense_jac_cmaj(realtype t,
const realtype * const __restrict__ y,
const realtype * const __restrict__ fy,
realtype * const __restrict__ jac,
const realtype * const ANYODE_RESTRICT y,
const realtype * const ANYODE_RESTRICT fy,
realtype * const ANYODE_RESTRICT jac,
long int ldim,
realtype * const __restrict__ dfdt=nullptr) override;
realtype * const ANYODE_RESTRICT dfdt=nullptr) override;
AnyODE::Status dense_jac_rmaj(realtype t,
const realtype * const __restrict__ y,
const realtype * const __restrict__ fy,
realtype * const __restrict__ jac,
const realtype * const ANYODE_RESTRICT y,
const realtype * const ANYODE_RESTRICT fy,
realtype * const ANYODE_RESTRICT jac,
long int ldim,
realtype * const __restrict__ dfdt=nullptr) override;
realtype * const ANYODE_RESTRICT dfdt=nullptr) override;
AnyODE::Status sparse_jac_csc(realtype t,
const realtype * const __restrict__ y,
const realtype * const __restrict__ fy,
realtype * const __restrict__ data,
indextype * const __restrict__ colptrs,
indextype * const __restrict__ rowvals) override;
AnyODE::Status jtimes(const realtype * const __restrict__ vec,
realtype * const __restrict__ out,
const realtype * const ANYODE_RESTRICT y,
const realtype * const ANYODE_RESTRICT fy,
realtype * const ANYODE_RESTRICT data,
indextype * const ANYODE_RESTRICT colptrs,
indextype * const ANYODE_RESTRICT rowvals) override;
AnyODE::Status jtimes(const realtype * const ANYODE_RESTRICT vec,
realtype * const ANYODE_RESTRICT out,
realtype t,
const realtype * const __restrict__ y,
const realtype * const __restrict__ fy) override;
const realtype * const ANYODE_RESTRICT y,
const realtype * const ANYODE_RESTRICT fy) override;

AnyODE::Status jtimes_setup(realtype /*t*/,
const realtype * const ANYODE_RESTRICT /*y*/,
const realtype * const ANYODE_RESTRICT /*fy*/) override;
AnyODE::Status roots(realtype t, const realtype * const y, realtype * const out) override;
};

Expand Down Expand Up @@ -141,8 +145,8 @@ namespace odesys_anyode {
}

AnyODE::Status OdeSys<realtype, indextype>::rhs(realtype x,
const realtype * const __restrict__ y,
realtype * const __restrict__ f) {
const realtype * const ANYODE_RESTRICT y,
realtype * const ANYODE_RESTRICT f) {
%if isinstance(p_rhs, str):
${p_rhs}
%else:
Expand Down Expand Up @@ -199,12 +203,20 @@ namespace odesys_anyode {
%endif
}


AnyODE::Status OdeSys<realtype, indextype>::jtimes_setup(
realtype /*t*/,
const realtype * const ANYODE_RESTRICT /*y*/,
const realtype * const ANYODE_RESTRICT /*fy*/) {
throw std::runtime_error("jtimes_setup not implemented");
}

AnyODE::Status OdeSys<realtype, indextype>::jtimes(
const realtype * const __restrict__ v,
realtype * const __restrict__ Jv,
const realtype * const ANYODE_RESTRICT v,
realtype * const ANYODE_RESTRICT Jv,
realtype x,
const realtype * const __restrict__ y,
const realtype * const __restrict__ fy) {
const realtype * const ANYODE_RESTRICT y,
const realtype * const ANYODE_RESTRICT fy) {
%if p_jtimes is not None:
%if isinstance(p_jtimes, str):
${p_jtimes}
Expand Down Expand Up @@ -233,11 +245,11 @@ namespace odesys_anyode {

%for order in ('cmaj', 'rmaj'):
AnyODE::Status OdeSys<realtype, indextype>::dense_jac_${order}(realtype x,
const realtype * const __restrict__ y,
const realtype * const __restrict__ fy,
realtype * const __restrict__ jac,
const realtype * const ANYODE_RESTRICT y,
const realtype * const ANYODE_RESTRICT fy,
realtype * const ANYODE_RESTRICT jac,
long int ldim,
realtype * const __restrict__ dfdt) {
realtype * const ANYODE_RESTRICT dfdt) {
%if p_jac_dense is not None:
%if order in p_jac_dense:
${p_jac_dense[order]}
Expand Down Expand Up @@ -297,11 +309,11 @@ namespace odesys_anyode {
}

AnyODE::Status OdeSys<realtype, indextype>::sparse_jac_csc(realtype x,
const realtype * const __restrict__ y,
const realtype * const __restrict__ fy,
realtype * const __restrict__ data,
indextype * const __restrict__ colptrs,
indextype * const __restrict__ rowvals) {
const realtype * const ANYODE_RESTRICT y,
const realtype * const ANYODE_RESTRICT fy,
realtype * const ANYODE_RESTRICT data,
indextype * const ANYODE_RESTRICT colptrs,
indextype * const ANYODE_RESTRICT rowvals) {
%if p_jac_sparse is not None:
AnyODE::ignore(fy); // Currently we are not using fy (could be done through extensive pattern matching)
${'AnyODE::ignore(x);' if p_odesys.autonomous_exprs else ''}
Expand Down Expand Up @@ -382,4 +394,4 @@ namespace odesys_anyode {
return AnyODE::Status::success;
%endif
}
}
}
Loading

0 comments on commit 083964e

Please sign in to comment.