Skip to content

Commit

Permalink
Updated documentation; removed macos test skips
Browse files Browse the repository at this point in the history
  • Loading branch information
jrenaud90 committed Dec 2, 2024
1 parent e0214eb commit 814c3c9
Show file tree
Hide file tree
Showing 24 changed files with 164 additions and 1,437 deletions.
52 changes: 26 additions & 26 deletions Benchmarks/CyRK - SciPy Comparison.ipynb

Large diffs are not rendered by default.

Binary file modified Benchmarks/CyRK_CySolver.pdf
Binary file not shown.
Binary file modified Benchmarks/CyRK_CySolver_DenseOn.pdf
Binary file not shown.
Binary file modified Benchmarks/CyRK_PySolver (njit).pdf
Binary file not shown.
Binary file modified Benchmarks/CyRK_PySolver.pdf
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Benchmarks/CyRK_numba.pdf
Binary file not shown.
Binary file modified Benchmarks/SciPy.pdf
Binary file not shown.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Fixes:
Tests:
* Fixed tests where additional args were not being used.
* Fixed issue with diffeq test 5.
* This fixes GitHub Issue [#67](https://github.com/jrenaud90/CyRK/issues/67)

Documentation:
* Updated the "Advanced CySolver.md" documentation that was out of date.
Expand Down
2 changes: 0 additions & 2 deletions CyRK/cy/cysolve.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "cysolve.hpp"
#include <exception>

#include <cstdio>

void baseline_cysolve_ivp_noreturn(
std::shared_ptr<CySolverResult> solution_sptr,
Expand Down Expand Up @@ -35,7 +34,6 @@ void baseline_cysolve_ivp_noreturn(
const double t_end = t_span_ptr[1];
const bool direction_flag = t_start <= t_end ? true : false;
const bool forward = direction_flag == true;
printf("t_start = %e; t_end = %e; direction_flag = %d; forward = %d\n", t_start, t_end, direction_flag, forward);
const bool t_eval_provided = t_eval ? true : false;

// Get new expected size
Expand Down
20 changes: 0 additions & 20 deletions CyRK/cy/cysolver.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include <cstdio>
#include "cysolver.hpp"
#include "dense.hpp"
#include "cysolution.hpp"
Expand Down Expand Up @@ -67,29 +66,11 @@ CySolverBase::CySolverBase(
{
// Allocate memory for the size of args.
// Store void pointer to it.
printf("Pre resize; size = %d\n", this->size_of_args);
printf("Pre resize; VECTOR size = %d\n", this->args_char_vec.size());
this->args_char_vec.resize(this->size_of_args);

for (size_t i = 0; i < this->size_of_args; i++)
{
printf("\t %x\n", args_ptr[i] & 0xff);
}


// Copy over contents of arg
printf("Pre Copy Over: arg_in_char = %p; sizeof = %d; args_in_char+size = %p\n", args_ptr, this->size_of_args, args_ptr + this->size_of_args);
// this->args_char_vec.insert(this->args_char_vec.begin(), args_ptr, args_ptr + this->size_of_args);
this->args_ptr = this->args_char_vec.data();
std::memcpy(this->args_ptr, args_ptr, this->size_of_args);

printf("Vector array size = %d\n", this->args_char_vec.size());
for (size_t i = 0; i < this->args_char_vec.size(); i++)
{
printf("\t %x\n", this->args_char_vec[i] & 0xff);
}

printf("Post\n");
}
else
{
Expand Down Expand Up @@ -183,7 +164,6 @@ CySolverBase::CySolverBase(
// Destructors
CySolverBase::~CySolverBase()
{
printf("CySolver Deconstructor called.\n");
if (this->deconstruct_python)
{
// Decrease reference count on the cython extension class instance
Expand Down
2 changes: 0 additions & 2 deletions CyRK/cy/cysolver_api.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import numpy as np
cimport numpy as cnp
cnp.import_array()

from libc.stdio cimport printf

# =====================================================================================================================
# Import CySolverResult (container for integration results)
# =====================================================================================================================
Expand Down
43 changes: 6 additions & 37 deletions CyRK/cy/cysolver_test.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@
# cython: boundscheck=False, wraparound=False, nonecheck=False, cdivision=True, initializedcheck=False

from libcpp cimport bool as cpp_bool
from libcpp.memory cimport make_shared, shared_ptr
from libcpp.vector cimport vector
from libcpp.limits cimport numeric_limits
from libc.math cimport sin, cos, fabs, fmin, fmax
from libc.math cimport sin, cos
from libc.stdlib cimport malloc, free, realloc
from libc.stdio cimport printf

cdef double d_NAN = numeric_limits[double].quiet_NaN()

Expand Down Expand Up @@ -156,7 +153,6 @@ cdef void arbitrary_arg_test(double* dy_ptr, double t, double* y_ptr, char* args
cdef double g = arb_args_ptr.g
cdef cpp_bool cause_fail = arb_args_ptr.cause_fail
cdef cpp_bool checker = arb_args_ptr.checker
printf("arbitrary_arg_test:: l = %e, m = %e, g = %e; cause_fail = %d\n", l, m, g, cause_fail)

cdef double coeff_1 = (-3. * g / (2. * l))
cdef double coeff_2 = (3. / (m * l**2))
Expand Down Expand Up @@ -224,31 +220,22 @@ cdef void pendulum_preeval_diffeq(double* dy_ptr, double t, double* y_ptr, char*

def cy_extra_output_tester():

printf("cy_extra_output_tester Pt1\n")

cdef double[2] t_span = [0., 10.]
cdef double* t_span_ptr = &t_span[0]

printf("cy_extra_output_tester Pt2\n")
cdef double[3] y0 = [1., 0., 0]
cdef double* y0_ptr = &y0[0]

printf("cy_extra_output_tester Pt3\n")
cdef size_t num_y = 3
cdef size_t num_extra = 3
cdef int int_method = 1

printf("cy_extra_output_tester Pt4\n")
cdef size_t arg_size = sizeof(double)*3
printf("cy_extra_output_tester Pt5\n")
cdef size_t arg_size = sizeof(double) * 3
cdef double* args_ptr = <double*>malloc(arg_size)
printf("cy_extra_output_tester Pt6\n")
args_ptr[0] = 10.0
args_ptr[1] = 28.0
args_ptr[2] = 8.0 / 3.0
printf("cy_extra_output_tester Pt7\n")

printf("cy_extra_output_tester Pt8\n")

cdef CySolveOutput result = cysolve_ivp(
lorenz_extraoutput_diffeq,
t_span_ptr,
Expand All @@ -261,18 +248,14 @@ def cy_extra_output_tester():
arg_size,
num_extra
)
printf("cy_extra_output_tester Pt9\n")

cdef double dy1, dy2, dy3, e1, e2, e3
cdef double check_t = 4.335

# Call the result to get the baseline values for extra output
printf("cy_extra_output_tester Pt10\n")
cdef double[6] y_interp
cdef double* y_interp_ptr = &y_interp[0]
printf("cy_extra_output_tester Pt11\n")
result.get().call(check_t, y_interp_ptr)
printf("cy_extra_output_tester Pt12\n")
dy1 = y_interp_ptr[0]
dy2 = y_interp_ptr[1]
dy3 = y_interp_ptr[2]
Expand All @@ -284,25 +267,23 @@ def cy_extra_output_tester():
args_ptr[0] = -99.0
args_ptr[1] = -99.0
args_ptr[2] = -99.0
printf("cy_extra_output_tester Pt13\n")
args_ptr = <double*>realloc(args_ptr, sizeof(double)*50)
args_ptr = <double*>realloc(args_ptr, sizeof(double) * 50)
cdef size_t i
for i in range(50):
args_ptr[i] = -99.0


# Recall the solution to see if it still produces the expected values
printf("cy_extra_output_tester Pt14\n")
result.get().call(check_t, y_interp_ptr)
printf("cy_extra_output_tester Pt15\n")

np.testing.assert_allclose(dy1, y_interp_ptr[0])
np.testing.assert_allclose(dy2, y_interp_ptr[1])
np.testing.assert_allclose(dy3, y_interp_ptr[2])
np.testing.assert_allclose(e1, y_interp_ptr[3])
np.testing.assert_allclose(e2, y_interp_ptr[4])
np.testing.assert_allclose(e3, y_interp_ptr[5])
printf("cy_extra_output_tester Pt16\n")

free(args_ptr)

return True

Expand All @@ -324,7 +305,6 @@ def cytester(
double max_step = MAX_STEP,
double first_step = 0.0
):
printf("Cytester pt0\n")
cdef size_t i
cdef double* t_eval_ptr = NULL
cdef size_t len_t_eval = 0
Expand All @@ -342,7 +322,6 @@ def cytester(
cdef size_t num_extra = 0
cdef DiffeqFuncType diffeq = NULL
cdef PreEvalFunc pre_eval_func = NULL
printf("Cytester pt1\n")
if diffeq_number == 0:
diffeq = baseline_diffeq
elif diffeq_number == 1:
Expand All @@ -366,7 +345,6 @@ def cytester(
pre_eval_func = pendulum_preeval_func
else:
raise NotImplementedError
printf("Cytester pt2\n")

# Set up additional argument information
cdef char* args_ptr = NULL
Expand All @@ -380,7 +358,6 @@ def cytester(
cdef ArbitraryArgStruct arb_arg_struct = ArbitraryArgStruct(1.0, False, True, 1.0, 9.81)

# Check if generic testing was requested.
printf("Cytester pt3\n")
if y0 is None:
# Generic Testing Requested

Expand Down Expand Up @@ -482,7 +459,6 @@ def cytester(
else:
raise NotImplementedError
else:
printf("Cytester pt4bn")
# Regular testing requested.
num_y = len(y0)
for i in range(num_y):
Expand All @@ -501,7 +477,6 @@ def cytester(
size_of_args = sizeof(args_arr)

# Parse rtol
printf("Cytester pt5\n")
cdef double* rtols_ptr = NULL
if rtol_array is not None:
rtols_ptr = &rtol_array[0]
Expand All @@ -511,10 +486,6 @@ def cytester(
if atol_array is not None:
atols_ptr = &atol_array[0]


printf("EXTRA ARGS SIZE = %d; Ptr = %p\n", size_of_args, args_ptr)

printf("PRE CySolve\n")
cdef CySolveOutput result = cysolve_ivp(
diffeq,
t_span_ptr,
Expand All @@ -538,8 +509,6 @@ def cytester(
first_step = first_step,
expected_size = expected_size
)
printf("POST CySolve\n")

cdef WrapCySolverResult pysafe_result = WrapCySolverResult()
pysafe_result.set_cyresult_pointer(result)

Expand Down
234 changes: 35 additions & 199 deletions Demos/1 - Getting Started.ipynb

Large diffs are not rendered by default.

Loading

0 comments on commit 814c3c9

Please sign in to comment.