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

error handling in stuff that isnt in the other PRs #392

Merged
merged 16 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
40 changes: 16 additions & 24 deletions doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ note these requirements below. Additionally, we note the behavior of the base SU

SUNAdaptController_Type id = SUNAdaptController_GetType(C);

.. c:function:: int SUNAdaptController_Destroy(SUNAdaptController C)
.. c:function:: SUNErrCode SUNAdaptController_Destroy(SUNAdaptController C)

Deallocates the controller *C*. If this method is not provided by the
implementation, the base class method will free both the *content* and
Expand All @@ -147,16 +147,15 @@ note these requirements below. Additionally, we note the behavior of the base SU
routine).

:param C: the :c:type:`SUNAdaptController` object.
:return: error code indicating success failure
(see :numref:`SUNAdaptController.Description.errorCodes`).
:return: :c:type:`SUNErrCode` indicating success or failure
balos1 marked this conversation as resolved.
Show resolved Hide resolved

Usage:

.. code-block:: c

retval = SUNAdaptController_Destroy(C);

.. c:function:: int SUNAdaptController_EstimateStep(SUNAdaptController C, sunrealtype h, int p, sunrealtype dsm, sunrealtype* hnew)
.. c:function:: SUNErrCode SUNAdaptController_EstimateStep(SUNAdaptController C, sunrealtype h, int p, sunrealtype dsm, sunrealtype* hnew)

Estimates a single-rate step size. This routine is required for controllers
of type ``SUN_ADAPTCONTROLLER_H``. If this is not provided by the
Expand All @@ -167,60 +166,56 @@ note these requirements below. Additionally, we note the behavior of the base SU
:param p: the current order of accuracy for the time integration method.
:param dsm: the local temporal estimate from the previous step attempt.
:param hnew: (output) the estimated step size.
:return: error code indicating success failure
(see :numref:`SUNAdaptController.Description.errorCodes`).
:return: :c:type:`SUNErrCode` indicating success or failure
balos1 marked this conversation as resolved.
Show resolved Hide resolved

Usage:

.. code-block:: c

retval = SUNAdaptController_EstimateStep(C, hcur, p, dsm, &hnew);

.. c:function:: int SUNAdaptController_Reset(SUNAdaptController C)
.. c:function:: SUNErrCode SUNAdaptController_Reset(SUNAdaptController C)

Resets the controller to its initial state, e.g., if it stores a small number
of previous *dsm* or *h* values.

:param C: the :c:type:`SUNAdaptController` object.
:return: error code indicating success failure
(see :numref:`SUNAdaptController.Description.errorCodes`).
:return: :c:type:`SUNErrCode` indicating success or failure
balos1 marked this conversation as resolved.
Show resolved Hide resolved

Usage:

.. code-block:: c

retval = SUNAdaptController_Reset(C);

.. c:function:: int SUNAdaptController_SetDefaults(SUNAdaptController C)
.. c:function:: SUNErrCode SUNAdaptController_SetDefaults(SUNAdaptController C)

Sets the controller parameters to their default values.

:param C: the :c:type:`SUNAdaptController` object.
:return: error code indicating success failure
(see :numref:`SUNAdaptController.Description.errorCodes`).
:return: :c:type:`SUNErrCode` indicating success or failure
balos1 marked this conversation as resolved.
Show resolved Hide resolved

Usage:

.. code-block:: c

retval = SUNAdaptController_SetDefaults(C);

.. c:function:: int SUNAdaptController_Write(SUNAdaptController C, FILE* fptr)
.. c:function:: SUNErrCode SUNAdaptController_Write(SUNAdaptController C, FILE* fptr)

Writes all controller parameters to the indicated file pointer.

:param C: the :c:type:`SUNAdaptController` object.
:param fptr: the output stream to write the parameters to.
:return: error code indicating success failure
(see :numref:`SUNAdaptController.Description.errorCodes`).
:return: :c:type:`SUNErrCode` indicating success or failure
balos1 marked this conversation as resolved.
Show resolved Hide resolved

Usage:

.. code-block:: c

retval = SUNAdaptController_Write(C, stdout);

.. c:function:: int SUNAdaptController_SetErrorBias(SUNAdaptController C, sunrealtype bias)
.. c:function:: SUNErrCode SUNAdaptController_SetErrorBias(SUNAdaptController C, sunrealtype bias)

Sets an error bias factor for scaling the local error factors. This is
typically used to slightly exaggerate the temporal error during the
Expand All @@ -229,16 +224,15 @@ note these requirements below. Additionally, we note the behavior of the base SU
:param C: the :c:type:`SUNAdaptController` object.
:param bias: the error bias factor -- an input :math:`\leq 0` indicates to use
the default value for the controller.
:return: error code indicating success failure
(see :numref:`SUNAdaptController.Description.errorCodes`).
:return: :c:type:`SUNErrCode` indicating success or failure
balos1 marked this conversation as resolved.
Show resolved Hide resolved

Usage:

.. code-block:: c

retval = SUNAdaptController_SetErrorBias(C, 1.2);

.. c:function:: int SUNAdaptController_UpdateH(SUNAdaptController C, sunrealtype h, sunrealtype dsm)
.. c:function:: SUNErrCode SUNAdaptController_UpdateH(SUNAdaptController C, sunrealtype h, sunrealtype dsm)

Notifies a controller of type SUN_ADAPTCONTROLLER_H that a successful time step
was taken with stepsize *h* and local error factor *dsm*, indicating that these
Expand All @@ -249,16 +243,15 @@ note these requirements below. Additionally, we note the behavior of the base SU
:param C: the :c:type:`SUNAdaptController` object.
:param h: the successful step size.
:param dsm: the successful temporal error estimate.
:return: error code indicating success failure
(see :numref:`SUNAdaptController.Description.errorCodes`).
:return: :c:type:`SUNErrCode` indicating success or failure
balos1 marked this conversation as resolved.
Show resolved Hide resolved

Usage:

.. code-block:: c

retval = SUNAdaptController_UpdateH(C, h, dsm);

.. c:function:: int SUNAdaptController_Space(SUNAdaptController C, long int *lenrw, long int *leniw)
.. c:function:: SUNErrCode SUNAdaptController_Space(SUNAdaptController C, long int *lenrw, long int *leniw)

Informative routine that returns the memory requirements of the
:c:type:`SUNAdaptController` object.
Expand All @@ -269,8 +262,7 @@ note these requirements below. Additionally, we note the behavior of the base SU
:param leniw: (output) number of ``sunindextype`` words stored in the
controller. This may also include pointers, `int` and
`long int` words.
:return: error code indicating success failure
(see :numref:`SUNAdaptController.Description.errorCodes`).
:return: :c:type:`SUNErrCode` indicating success or failure
balos1 marked this conversation as resolved.
Show resolved Hide resolved

Usage:

Expand Down
balos1 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ routines:
:param k2e: parameter used within the controller time step estimate.
:param k1i: parameter used within the controller time step estimate.
:param k2i: parameter used within the controller time step estimate.
:return: error code indication success or failure (see :numref:`SUNAdaptController.Description.errorCodes`).
:return: :c:type:`SUNErrCode` indicating success or failure
balos1 marked this conversation as resolved.
Show resolved Hide resolved

Usage:

Expand Down
12 changes: 6 additions & 6 deletions doc/shared/sunadaptcontroller/SUNAdaptController_Soderlind.rst
balos1 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ also provides the following additional user-callable routines:
:param k3: parameter used within the controller time step estimate.
:param k4: parameter used within the controller time step estimate.
:param k5: parameter used within the controller time step estimate.
:return: error code indication success or failure (see :numref:`SUNAdaptController.Description.errorCodes`).
:return: :c:type:`SUNErrCode` indicating success of failure.
balos1 marked this conversation as resolved.
Show resolved Hide resolved

Usage:

Expand Down Expand Up @@ -147,7 +147,7 @@ also provides the following additional user-callable routines:
:param k1: parameter used within the controller time step estimate.
:param k2: parameter used within the controller time step estimate.
:param k3: parameter used within the controller time step estimate.
:return: error code indication success or failure (see :numref:`SUNAdaptController.Description.errorCodes`).
:return: :c:type:`SUNErrCode` indicating success of failure.
balos1 marked this conversation as resolved.
Show resolved Hide resolved

Usage:

Expand Down Expand Up @@ -181,7 +181,7 @@ also provides the following additional user-callable routines:
:param C: the SUNAdaptController_Soderlind object.
:param k1: parameter used within the controller time step estimate.
:param k2: parameter used within the controller time step estimate.
:return: error code indication success or failure (see :numref:`SUNAdaptController.Description.errorCodes`).
:return: :c:type:`SUNErrCode` indicating success of failure.
balos1 marked this conversation as resolved.
Show resolved Hide resolved

Usage:

Expand Down Expand Up @@ -214,7 +214,7 @@ also provides the following additional user-callable routines:

:param C: the SUNAdaptController_Soderlind object.
:param k1: parameter used within the controller time step estimate.
:return: error code indication success or failure (see :numref:`SUNAdaptController.Description.errorCodes`).
:return: :c:type:`SUNErrCode` indicating success of failure.
balos1 marked this conversation as resolved.
Show resolved Hide resolved

Usage:

Expand Down Expand Up @@ -260,7 +260,7 @@ also provides the following additional user-callable routines:
:param C: the SUNAdaptController_Soderlind object.
:param k1_hat: parameter used within the explicit Gustafsson controller time step estimate.
:param k2_hat: parameter used within the explicit Gustafsson controller time step estimate.
:return: error code indication success or failure (see :numref:`SUNAdaptController.Description.errorCodes`).
:return: :c:type:`SUNErrCode` indicating success of failure.
balos1 marked this conversation as resolved.
Show resolved Hide resolved

Usage:

Expand Down Expand Up @@ -306,7 +306,7 @@ also provides the following additional user-callable routines:
:param C: the SUNAdaptController_Soderlind object.
:param k1_hat: parameter used within the implicit Gustafsson controller time step estimate.
:param k2_hat: parameter used within the implicit Gustafsson controller time step estimate.
:return: error code indication success or failure (see :numref:`SUNAdaptController.Description.errorCodes`).
:return: :c:type:`SUNErrCode` indicating success of failure.
balos1 marked this conversation as resolved.
Show resolved Hide resolved

Usage:

Expand Down
10 changes: 5 additions & 5 deletions doc/shared/sunmemory/SUNMemory_CUDA.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ The implementation provides the following operations defined by the

**Returns:**

* An ``int`` flag indicating success (zero) or failure (non-zero).
* A :c:type:`SUNErrCode` indicating success or failure
balos1 marked this conversation as resolved.
Show resolved Hide resolved


.. c:function:: SUNErrCode SUNMemoryHelper_Dealloc_Cuda(SUNMemoryHelper helper, \
Expand All @@ -85,7 +85,7 @@ The implementation provides the following operations defined by the

**Returns:**

* An ``int`` flag indicating success (zero) or failure (non-zero).
* A :c:type:`SUNErrCode` indicating success or failure
balos1 marked this conversation as resolved.
Show resolved Hide resolved


.. c:function:: SUNErrCode SUNMemoryHelper_Copy_Cuda(SUNMemoryHelper helper, \
Expand All @@ -108,7 +108,7 @@ The implementation provides the following operations defined by the

**Returns:**

* An ``int`` flag indicating success (zero) or failure (non-zero).
* A :c:type:`SUNErrCode` indicating success or failure
balos1 marked this conversation as resolved.
Show resolved Hide resolved


.. c:function:: SUNErrCode SUNMemoryHelper_CopyAsync_Cuda(SUNMemoryHelper helper, \
Expand All @@ -133,7 +133,7 @@ The implementation provides the following operations defined by the

**Returns:**

* An ``int`` flag indicating success (zero) or failure (non-zero).
* A :c:type:`SUNErrCode` indicating success or failure
balos1 marked this conversation as resolved.
Show resolved Hide resolved


.. c:function:: SUNErrCode SUNMemoryHelper_GetAllocStats_Cuda(SUNMemoryHelper helper, SUNMemoryType mem_type, unsigned long* num_allocations, \
Expand All @@ -153,4 +153,4 @@ The implementation provides the following operations defined by the

**Returns:**

* An ``int`` flag indicating success (zero) or failure (non-zero).
* A :c:type:`SUNErrCode` indicating success or failure
balos1 marked this conversation as resolved.
Show resolved Hide resolved
31 changes: 15 additions & 16 deletions doc/shared/sunmemory/SUNMemory_Description.rst
balos1 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -97,21 +97,20 @@ This API consists of three new SUNDIALS types: :c:type:`SUNMemoryType`,
struct SUNMemoryHelper_Ops_
{
/* operations that implementations are required to provide */
int (*alloc)(SUNMemoryHelper, SUNMemory* memptr size_t mem_size,
SUNErrCode (*alloc)(SUNMemoryHelper, SUNMemory* memptr size_t mem_size,
SUNMemoryType mem_type, void* queue);
int (*dealloc)(SUNMemoryHelper, SUNMemory mem, void* queue);
int (*copy)(SUNMemoryHelper, SUNMemory dst, SUNMemory src,
SUNErrCode (*dealloc)(SUNMemoryHelper, SUNMemory mem, void* queue);
SUNErrCode (*copy)(SUNMemoryHelper, SUNMemory dst, SUNMemory src,
size_t mem_size, void* queue);

/* operations that provide default implementations */
int (*copyasync)(SUNMemoryHelper, SUNMemory dst,
SUNMemory src, size_t mem_size,
void* queue);
int (*getallocstats)(SUNMemoryHelper, SUNMemoryType mem_type, unsigned long* num_allocations,
unsigned long* num_deallocations, size_t* bytes_allocated,
size_t* bytes_high_watermark);
SUNErrCode (*copyasync)(SUNMemoryHelper, SUNMemory dst,
SUNMemory src, size_t mem_size, void* queue);
SUNErrCode (*getallocstats)(SUNMemoryHelper, SUNMemoryType mem_type, unsigned long* num_allocations,
unsigned long* num_deallocations, size_t* bytes_allocated,
size_t* bytes_high_watermark);
SUNMemoryHelper (*clone)(SUNMemoryHelper);
int (*destroy)(SUNMemoryHelper);
SUNErrCode (*destroy)(SUNMemoryHelper);
};


Expand Down Expand Up @@ -146,7 +145,7 @@ must define:

**Returns:**

* An ``int`` flag indicating success (zero) or failure (non-zero).
* A :c:type:`SUNErrCode` indicating success or failure.
balos1 marked this conversation as resolved.
Show resolved Hide resolved


.. c:function:: SUNErrCode SUNMemoryHelper_Dealloc(SUNMemoryHelper helper, \
Expand All @@ -165,7 +164,7 @@ must define:

**Returns:**

* An ``int`` flag indicating success (zero) or failure (non-zero).
* A :c:type:`SUNErrCode` indicating success or failure.


.. c:function:: SUNErrCode SUNMemoryHelper_Copy(SUNMemoryHelper helper, \
Expand All @@ -190,7 +189,7 @@ must define:

**Returns:**

* An ``int`` flag indicating success (zero) or failure (non-zero).
* A :c:type:`SUNErrCode` indicating success or failure.



Expand Down Expand Up @@ -276,7 +275,7 @@ require a SUNMemoryHelper instance:

**Returns:**

* An ``int`` flag indicating success (zero) or failure (non-zero).
* A :c:type:`SUNErrCode` indicating success or failure.


.. c:function:: SUNErrCode SUNMemoryHelper_GetAllocStats(SUNMemoryHelper helper, SUNMemoryType mem_type, unsigned long* num_allocations, \
Expand All @@ -296,7 +295,7 @@ require a SUNMemoryHelper instance:

**Returns:**

* An ``int`` flag indicating success (zero) or failure (non-zero).
* A :c:type:`SUNErrCode` indicating success or failure.


.. _SUNMemory.Description.Overridable:
Expand Down Expand Up @@ -369,7 +368,7 @@ overridable* operations which an implementation may define:

**Returns:**

* An ``int`` flag indicating success (zero) or failure (non-zero).
* A :c:type:`SUNErrCode` indicating success or failure.

.. note::

Expand Down
10 changes: 5 additions & 5 deletions doc/shared/sunmemory/SUNMemory_SYCL.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ The implementation provides the following operations defined by the

**Returns:**

* An ``int`` flag indicating success (zero) or failure (non-zero).
* A :c:type:`SUNErrCode` indicating success or failure.
balos1 marked this conversation as resolved.
Show resolved Hide resolved


.. c:function:: SUNErrCode SUNMemoryHelper_Dealloc_Sycl(SUNMemoryHelper helper, \
Expand All @@ -84,7 +84,7 @@ The implementation provides the following operations defined by the

**Returns:**

* An ``int`` flag indicating success (zero) or failure (non-zero).
* A :c:type:`SUNErrCode` indicating success or failure.


.. c:function:: SUNErrCode SUNMemoryHelper_Copy_Sycl(SUNMemoryHelper helper, \
Expand All @@ -108,7 +108,7 @@ The implementation provides the following operations defined by the

**Returns:**

* An ``int`` flag indicating success (zero) or failure (non-zero).
* A :c:type:`SUNErrCode` indicating success or failure.


.. c:function:: SUNErrCode SUNMemoryHelper_CopyAsync_Sycl(SUNMemoryHelper helper, \
Expand All @@ -133,7 +133,7 @@ The implementation provides the following operations defined by the

**Returns:**

* An ``int`` flag indicating success (zero) or failure (non-zero).
* A :c:type:`SUNErrCode` indicating success or failure.


.. c:function:: SUNErrCode SUNMemoryHelper_GetAllocStats_Sycl(SUNMemoryHelper helper, SUNMemoryType mem_type, unsigned long* num_allocations, \
Expand All @@ -153,4 +153,4 @@ The implementation provides the following operations defined by the

**Returns:**

* An ``int`` flag indicating success (zero) or failure (non-zero).
* A :c:type:`SUNErrCode` indicating success or failure.
1 change: 1 addition & 0 deletions include/sundials/sundials_errors.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
ENTRY(SUN_ERR_FILE_OPEN, "Unable to open file") \
ENTRY(SUN_ERR_MEM_FAIL, "a memory operation failed") \
ENTRY(SUN_ERR_MALLOC_FAIL, "malloc returned NULL") \
ENTRY(SUN_ERR_EXT_FAIL, "a failure occurred in an external library") \
ENTRY(SUN_ERR_DESTROY_FAIL, "a destroy function returned an error") \
ENTRY(SUN_ERR_NOT_IMPLEMENTED, \
"operation is not implemented: function pointer is NULL") \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ SUNErrCode SUNAdaptController_SetDefaults_Soderlind(SUNAdaptController C)
SUNErrCode SUNAdaptController_Write_Soderlind(SUNAdaptController C, FILE* fptr)
{
SUNFunctionBegin(C->sunctx);
balos1 marked this conversation as resolved.
Show resolved Hide resolved
SUNAssert(fptr, SUN_ERR_ARG_CORRUPT);
fprintf(fptr, "Soderlind SUNAdaptController module:\n");
#if defined(SUNDIALS_EXTENDED_PRECISION)
fprintf(fptr, " k1 = %32Lg\n", SODERLIND_K1(C));
Expand Down
Loading
Loading