Skip to content

Commit

Permalink
Merge branch 'v0.8.6' into testing-python-versions
Browse files Browse the repository at this point in the history
  • Loading branch information
jrenaud90 committed Feb 13, 2024
2 parents 5ba794c + c4035dd commit ea267e5
Show file tree
Hide file tree
Showing 17 changed files with 634 additions and 351 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

# Include non-generated c files
!CyRK/array/interp_common.c
!CyRK/cy/rk_step.c

# Ignore coverage files
.coverage
Expand All @@ -17,6 +18,7 @@ __pycache__/
# Objext files
*.so
*.o
*.exe

# Distribution / packaging
.Python
Expand Down
58 changes: 58 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"files.associations": {
"iterator": "c",
"xmemory": "c",
"xutility": "c",
"atomic": "c",
"bit": "c",
"cctype": "c",
"charconv": "c",
"clocale": "c",
"cmath": "c",
"compare": "c",
"complex": "c",
"concepts": "c",
"cstddef": "c",
"cstdint": "c",
"cstdio": "c",
"cstdlib": "c",
"cstring": "c",
"ctime": "c",
"cwchar": "c",
"exception": "c",
"format": "c",
"initializer_list": "c",
"ios": "c",
"iosfwd": "c",
"istream": "c",
"limits": "c",
"locale": "c",
"memory": "c",
"mutex": "c",
"new": "c",
"ostream": "c",
"ratio": "c",
"sstream": "c",
"stdexcept": "c",
"stop_token": "c",
"streambuf": "c",
"string": "c",
"system_error": "c",
"thread": "c",
"tuple": "c",
"type_traits": "c",
"typeinfo": "c",
"utility": "c",
"xfacet": "c",
"xiosbase": "c",
"xlocale": "c",
"xlocbuf": "c",
"xlocinfo": "c",
"xlocmes": "c",
"xlocmon": "c",
"xlocnum": "c",
"xloctime": "c",
"xstring": "c",
"xtr1common": "c"
}
}
28 changes: 28 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: gcc.exe build active file",
"command": "C:\\Software\\mingw64\\bin\\gcc.exe",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
],
"version": "2.0.0"
}
63 changes: 33 additions & 30 deletions Benchmarks/CyRK - SciPy Comparison.ipynb

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@

Major Changes:
- Added support for Python 3.12.
- Converted `CySolver`'s `rk_step` method into a pure-c implementation to allow for further optimizations.
- Changed all files to compile with c rather than c++.
- Had to change cpp_bools to bints to make this change.

Bug Fixes:
- Fixed issue where CyRK was not installing on MacOS due to issue with LLVM and OpenMP.
- Have opted to go to gcc for macOS install due to issues with OpenMP and clang.
- Fixed incorrect type for rk method in CySolver (should eliminate some compile warnings).
- Fixed issue in benchmark where incorrect results were being displayed for CySolver.

#### v0.8.5 (2023-10-27)

Expand Down
2 changes: 1 addition & 1 deletion CyRK/array/interp.pyx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# distutils: language = c++
# distutils: language = c
# cython: boundscheck=False, wraparound=False, nonecheck=False, cdivision=True, initializedcheck=False
from cython.parallel import prange

Expand Down
16 changes: 7 additions & 9 deletions CyRK/cy/common.pxd
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# distutils: language = c++

ctypedef fused double_numeric:
double
double complex

from libcpp cimport bool as bool_cpp_t

cdef double SAFETY
cdef double MIN_FACTOR
cdef double MAX_FACTOR
Expand Down Expand Up @@ -33,16 +31,16 @@ cdef void interpolate(
size_t t_len_full,
size_t t_len_reduced,
size_t target_len,
bool_cpp_t is_complex
bint is_complex
) noexcept

cdef size_t find_expected_size(
size_t y_size,
size_t num_extra,
double t_delta_abs,
double rtol_min,
bool_cpp_t capture_extra,
bool_cpp_t is_complex
bint capture_extra,
bint is_complex
) noexcept nogil


Expand All @@ -51,7 +49,7 @@ cdef void find_max_num_steps(
size_t num_extra,
size_t max_num_steps,
size_t max_ram_MB,
bool_cpp_t capture_extra,
bool_cpp_t is_complex,
bool_cpp_t* user_provided_max_num_steps,
bint capture_extra,
bint is_complex,
bint* user_provided_max_num_steps,
size_t* max_num_steps_touse) noexcept nogil
14 changes: 7 additions & 7 deletions CyRK/cy/common.pyx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# distutils: language = c++
# distutils: language = c
# cython: boundscheck=False, wraparound=False, nonecheck=False, cdivision=True, initializedcheck=False
import cython

Expand Down Expand Up @@ -46,7 +46,7 @@ cdef void interpolate(
size_t t_len_full,
size_t t_len_reduced,
size_t target_len,
bool_cpp_t is_complex
bint is_complex
) noexcept:
""" Interpolate the results of a successful integration over the user provided time domain, `time_domain_full`. """

Expand Down Expand Up @@ -107,8 +107,8 @@ cdef size_t find_expected_size(
size_t num_extra,
double t_delta_abs,
double rtol_min,
bool_cpp_t capture_extra,
bool_cpp_t is_complex) noexcept nogil:
bint capture_extra,
bint is_complex) noexcept nogil:

cdef double temp_expected_size
# Pick starting value that works with most problems
Expand Down Expand Up @@ -145,9 +145,9 @@ cdef void find_max_num_steps(
size_t num_extra,
size_t max_num_steps,
size_t max_ram_MB,
bool_cpp_t capture_extra,
bool_cpp_t is_complex,
bool_cpp_t* user_provided_max_num_steps,
bint capture_extra,
bint is_complex,
bint* user_provided_max_num_steps,
size_t* max_num_steps_touse) noexcept nogil:

# Determine max number of steps
Expand Down
26 changes: 12 additions & 14 deletions CyRK/cy/cyrk.pyx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# distutils: language = c++
# distutils: language = c
# cython: boundscheck=False, wraparound=False, nonecheck=False, cdivision=True, initializedcheck=False

import cython
Expand All @@ -7,9 +7,7 @@ from cpython.mem cimport PyMem_Free

import numpy as np
cimport numpy as np
np.import_array()

from libcpp cimport bool as bool_cpp_t
from libc.math cimport sqrt, fabs, nextafter, NAN, floor

from CyRK.utils.utils cimport allocate_mem, reallocate_mem
Expand Down Expand Up @@ -80,9 +78,9 @@ def cyrk_ode(
double first_step = 0.,
unsigned char rk_method = 1,
double[:] t_eval = None,
bool_cpp_t capture_extra = False,
bint capture_extra = False,
size_t num_extra = 0,
bool_cpp_t interpolate_extra = False,
bint interpolate_extra = False,
size_t expected_size = 0,
size_t max_num_steps = 0,
size_t max_ram_MB = 2000
Expand Down Expand Up @@ -148,7 +146,7 @@ def cyrk_ode(
```
num_extra : int = 0
The number of extra outputs the integrator should expect. With the previous example there is 1 extra output.
interpolate_extra : bool_cpp_t, default=False
interpolate_extra : bint, default=False
Flag if interpolation should be run on extra parameters.
If set to False when `run_interpolation=True`, then interpolation will be run on solution's y, t. These will
then be used to recalculate extra parameters rather than an interpolation on the extra parameters captured
Expand Down Expand Up @@ -181,7 +179,7 @@ def cyrk_ode(
# Determine information about the differential equation based on its initial conditions
cdef size_t y_size
cdef double y_size_dbl, y_size_sqrt
cdef bool_cpp_t y_is_complex
cdef bint y_is_complex
y_size = y0.size
y_is_complex = False
y_size_dbl = <double>y_size
Expand All @@ -201,7 +199,7 @@ def cyrk_ode(

# Build time domain
cdef double t_start, t_end, t_delta, t_delta_check, t_delta_abs, direction_inf, t_old, t_now, time_
cdef bool_cpp_t direction_flag
cdef bint direction_flag
t_start = t_span[0]
t_end = t_span[1]
t_delta = t_end - t_start
Expand All @@ -218,7 +216,7 @@ def cyrk_ode(
direction_inf = -INF

# Pull out information on args
cdef bool_cpp_t use_args
cdef bint use_args
if args is None:
use_args = False
else:
Expand Down Expand Up @@ -271,7 +269,7 @@ def cyrk_ode(

# Determine max number of steps
cdef size_t max_num_steps_touse
cdef bool_cpp_t user_provided_max_num_steps
cdef bint user_provided_max_num_steps
find_max_num_steps(
y_size,
num_extra,
Expand Down Expand Up @@ -363,7 +361,7 @@ def cyrk_ode(
cdef double_numeric[::1] diffeq_out_view = diffeq_out_array

# Determine interpolation information
cdef bool_cpp_t run_interpolation
cdef bint run_interpolation
cdef size_t len_t_eval
if t_eval is None:
run_interpolation = False
Expand Down Expand Up @@ -486,7 +484,7 @@ def cyrk_ode(
cdef double step, step_size, min_step, step_factor

# Integration flags and variables
cdef bool_cpp_t success, step_accepted, step_rejected, step_error
cdef bint success, step_accepted, step_rejected, step_error
cdef size_t len_t

# Integration completion variables
Expand Down Expand Up @@ -666,7 +664,7 @@ def cyrk_ode(
# Initialize
y_view[i] = y_old_ptr[i]

y_view[i] += K_ptr[j * y_size + i] * A_at_sj
y_view[i] = y_view[i] + K_ptr[j * y_size + i] * A_at_sj

if use_args:
diffeq(time_, y_array, diffeq_out_array, *args)
Expand All @@ -686,7 +684,7 @@ def cyrk_ode(
# Initialize
y_view[i] = y_old_ptr[i]

y_view[i] += K_ptr[j * y_size + i] * B_at_j
y_view[i] = y_view[i] + K_ptr[j * y_size + i] * B_at_j

# Find final dydt for this timestep
if use_args:
Expand Down
Loading

0 comments on commit ea267e5

Please sign in to comment.