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 6 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
Original file line number Diff line number Diff line change
Expand Up @@ -287,14 +287,10 @@ SUNAdaptController Error Codes

SUNAdaptController functions return one of the following set of error codes:

* ``SUNADAPTCONTROLLER_SUCCESS`` (0) -- successful call.

* ``SUNADAPTCONTROLLER_ILL_INPUT`` (-1001) -- an illegal input has been provided to the function.
* ``SUN_SUCCESS`` (0) -- successful call.

* ``SUNADAPTCONTROLLER_MEM_FAIL`` (-1002) -- a memory access or allocation failed.

* ``SUNADAPTCONTROLLER_USER_FCN_FAIL`` (-1003) -- a user-supplied function returned a nonzero [error] value.

* ``SUNADAPTCONTROLLER_OPERATION_FAIL`` (-1004) -- catch-all for errors not in the above list.
balos1 marked this conversation as resolved.
Show resolved Hide resolved

.. note::
Expand Down
8 changes: 4 additions & 4 deletions doc/shared/sunmemory/SUNMemory_CUDA.rst
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ The implementation provides the following operations defined by the
* An ``int`` flag indicating success (zero) or failure (non-zero).
balos1 marked this conversation as resolved.
Show resolved Hide resolved


.. c:function:: int SUNMemoryHelper_Dealloc_Cuda(SUNMemoryHelper helper, \
.. c:function:: SUNErrCode SUNMemoryHelper_Dealloc_Cuda(SUNMemoryHelper helper, \
SUNMemory mem, void* queue)

Deallocates the ``mem->ptr`` field if it is owned by ``mem``, and then
Expand All @@ -88,7 +88,7 @@ The implementation provides the following operations defined by the
* An ``int`` flag indicating success (zero) or failure (non-zero).


.. c:function:: int SUNMemoryHelper_Copy_Cuda(SUNMemoryHelper helper, \
.. c:function:: SUNErrCode SUNMemoryHelper_Copy_Cuda(SUNMemoryHelper helper, \
SUNMemory dst, SUNMemory src, \
size_t mem_size, void* queue)

Expand All @@ -111,7 +111,7 @@ The implementation provides the following operations defined by the
* An ``int`` flag indicating success (zero) or failure (non-zero).


.. c:function:: int SUNMemoryHelper_CopyAsync_Cuda(SUNMemoryHelper helper, \
.. c:function:: SUNErrCode SUNMemoryHelper_CopyAsync_Cuda(SUNMemoryHelper helper, \
SUNMemory dst, \
SUNMemory src, \
size_t mem_size, void* queue)
Expand All @@ -136,7 +136,7 @@ The implementation provides the following operations defined by the
* An ``int`` flag indicating success (zero) or failure (non-zero).


.. c:function:: int SUNMemoryHelper_GetAllocStats_Cuda(SUNMemoryHelper helper, SUNMemoryType mem_type, unsigned long* num_allocations, \
.. c:function:: SUNErrCode SUNMemoryHelper_GetAllocStats_Cuda(SUNMemoryHelper helper, SUNMemoryType mem_type, unsigned long* num_allocations, \
unsigned long* num_deallocations, size_t* bytes_allocated, \
size_t* bytes_high_watermark)

Expand Down
12 changes: 6 additions & 6 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 @@ -149,7 +149,7 @@ must define:
* An ``int`` flag indicating success (zero) or failure (non-zero).
balos1 marked this conversation as resolved.
Show resolved Hide resolved


.. c:function:: int SUNMemoryHelper_Dealloc(SUNMemoryHelper helper, \
.. c:function:: SUNErrCode SUNMemoryHelper_Dealloc(SUNMemoryHelper helper, \
SUNMemory mem, void* queue)

Deallocates the ``mem->ptr`` field if it is owned by ``mem``, and then
Expand All @@ -168,7 +168,7 @@ must define:
* An ``int`` flag indicating success (zero) or failure (non-zero).


.. c:function:: int SUNMemoryHelper_Copy(SUNMemoryHelper helper, \
.. c:function:: SUNErrCode SUNMemoryHelper_Copy(SUNMemoryHelper helper, \
SUNMemory dst, SUNMemory src, \
size_t mem_size, void* queue)

Expand Down Expand Up @@ -263,7 +263,7 @@ require a SUNMemoryHelper instance:
The ``SUNMemoryHelper`` argument was added to the function signature.


.. c:function:: int SUNMemoryHelper_CopyOps(SUNMemoryHelper src, \
.. c:function:: SUNErrCode SUNMemoryHelper_CopyOps(SUNMemoryHelper src, \
SUNMemoryHelper dst)

Copies the ``ops`` field of ``src`` to the ``ops`` field of ``dst``.
Expand All @@ -279,7 +279,7 @@ require a SUNMemoryHelper instance:
* An ``int`` flag indicating success (zero) or failure (non-zero).


.. c:function:: int SUNMemoryHelper_GetAllocStats(SUNMemoryHelper helper, SUNMemoryType mem_type, unsigned long* num_allocations, \
.. c:function:: SUNErrCode SUNMemoryHelper_GetAllocStats(SUNMemoryHelper helper, SUNMemoryType mem_type, unsigned long* num_allocations, \
unsigned long* num_deallocations, size_t* bytes_allocated, \
size_t* bytes_high_watermark)

Expand Down Expand Up @@ -308,7 +308,7 @@ In addition, the SUNMemoryHelper API defines the following *optionally
overridable* operations which an implementation may define:


.. c:function:: int SUNMemoryHelper_CopyAsync(SUNMemoryHelper helper, \
.. c:function:: SUNErrCode SUNMemoryHelper_CopyAsync(SUNMemoryHelper helper, \
SUNMemory dst, SUNMemory src, \
size_t mem_size, void* queue)

Expand Down Expand Up @@ -359,7 +359,7 @@ overridable* operations which an implementation may define:
``helper->ops``, and not the ``helper->content`` field.


.. c:function:: int SUNMemoryHelper_Destroy(SUNMemoryHelper helper)
.. c:function:: SUNErrCode SUNMemoryHelper_Destroy(SUNMemoryHelper helper)

Destroys (frees) the ``SUNMemoryHelper`` object itself.

Expand Down
8 changes: 4 additions & 4 deletions doc/shared/sunmemory/SUNMemory_HIP.rst
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ The implementation provides the following operations defined by the
* An ``int`` flag indicating success (zero) or failure (non-zero).
gardner48 marked this conversation as resolved.
Show resolved Hide resolved


.. c:function:: int SUNMemoryHelper_Dealloc_Hip(SUNMemoryHelper helper, \
.. c:function:: SUNErrCode SUNMemoryHelper_Dealloc_Hip(SUNMemoryHelper helper, \
SUNMemory mem, \
void* queue)

Expand All @@ -88,7 +88,7 @@ The implementation provides the following operations defined by the
* An ``int`` flag indicating success (zero) or failure (non-zero).


.. c:function:: int SUNMemoryHelper_Copy_Hip(SUNMemoryHelper helper, \
.. c:function:: SUNErrCode SUNMemoryHelper_Copy_Hip(SUNMemoryHelper helper, \
SUNMemory dst, SUNMemory src, \
size_t mem_size, void* queue)

Expand All @@ -110,7 +110,7 @@ The implementation provides the following operations defined by the
* An ``int`` flag indicating success (zero) or failure (non-zero).


.. c:function:: int SUNMemoryHelper_CopyAsync_Hip(SUNMemoryHelper helper, \
.. c:function:: SUNErrCode SUNMemoryHelper_CopyAsync_Hip(SUNMemoryHelper helper, \
SUNMemory dst, \
SUNMemory src, \
size_t mem_size, void* queue)
Expand All @@ -135,7 +135,7 @@ The implementation provides the following operations defined by the
* An ``int`` flag indicating success (zero) or failure (non-zero).


.. c:function:: int SUNMemoryHelper_GetAllocStats_Hip(SUNMemoryHelper helper, SUNMemoryType mem_type, unsigned long* num_allocations, \
.. c:function:: SUNErrCode SUNMemoryHelper_GetAllocStats_Hip(SUNMemoryHelper helper, SUNMemoryType mem_type, unsigned long* num_allocations, \
unsigned long* num_deallocations, size_t* bytes_allocated, \
size_t* bytes_high_watermark)

Expand Down
8 changes: 4 additions & 4 deletions doc/shared/sunmemory/SUNMemory_SYCL.rst
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ The implementation provides the following operations defined by the
* An ``int`` flag indicating success (zero) or failure (non-zero).
balos1 marked this conversation as resolved.
Show resolved Hide resolved


.. c:function:: int SUNMemoryHelper_Dealloc_Sycl(SUNMemoryHelper helper, \
.. c:function:: SUNErrCode SUNMemoryHelper_Dealloc_Sycl(SUNMemoryHelper helper, \
SUNMemory mem, void* queue)

Deallocates the ``mem->ptr`` field if it is owned by ``mem``, and then
Expand All @@ -87,7 +87,7 @@ The implementation provides the following operations defined by the
* An ``int`` flag indicating success (zero) or failure (non-zero).


.. c:function:: int SUNMemoryHelper_Copy_Sycl(SUNMemoryHelper helper, \
.. c:function:: SUNErrCode SUNMemoryHelper_Copy_Sycl(SUNMemoryHelper helper, \
SUNMemory dst, SUNMemory src, \
size_t mem_size, void* queue)

Expand All @@ -111,7 +111,7 @@ The implementation provides the following operations defined by the
* An ``int`` flag indicating success (zero) or failure (non-zero).


.. c:function:: int SUNMemoryHelper_CopyAsync_Sycl(SUNMemoryHelper helper, \
.. c:function:: SUNErrCode SUNMemoryHelper_CopyAsync_Sycl(SUNMemoryHelper helper, \
SUNMemory dst, \
SUNMemory src, \
size_t mem_size, void* queue)
Expand All @@ -136,7 +136,7 @@ The implementation provides the following operations defined by the
* An ``int`` flag indicating success (zero) or failure (non-zero).


.. c:function:: int SUNMemoryHelper_GetAllocStats_Sycl(SUNMemoryHelper helper, SUNMemoryType mem_type, unsigned long* num_allocations, \
.. c:function:: SUNErrCode SUNMemoryHelper_GetAllocStats_Sycl(SUNMemoryHelper helper, SUNMemoryType mem_type, unsigned long* num_allocations, \
unsigned long* num_deallocations, size_t* bytes_allocated, \
size_t* bytes_high_watermark)

Expand Down
37 changes: 22 additions & 15 deletions include/sunadaptcontroller/sunadaptcontroller_imexgus.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,31 +48,38 @@ typedef struct _SUNAdaptControllerContent_ImExGus* SUNAdaptControllerContent_ImE

SUNDIALS_EXPORT
SUNAdaptController SUNAdaptController_ImExGus(SUNContext sunctx);

SUNDIALS_EXPORT
int SUNAdaptController_SetParams_ImExGus(SUNAdaptController C, sunrealtype k1e,
sunrealtype k2e, sunrealtype k1i,
sunrealtype k2i);
SUNErrCode SUNAdaptController_SetParams_ImExGus(SUNAdaptController C,
sunrealtype k1e, sunrealtype k2e,
sunrealtype k1i, sunrealtype k2i);
SUNDIALS_EXPORT
SUNAdaptController_Type SUNAdaptController_GetType_ImExGus(SUNAdaptController C);

SUNDIALS_EXPORT
int SUNAdaptController_EstimateStep_ImExGus(SUNAdaptController C, sunrealtype h,
int p, sunrealtype dsm,
sunrealtype* hnew);
SUNErrCode SUNAdaptController_EstimateStep_ImExGus(SUNAdaptController C,
sunrealtype h, int p,
sunrealtype dsm,
sunrealtype* hnew);
SUNDIALS_EXPORT
int SUNAdaptController_Reset_ImExGus(SUNAdaptController C);
SUNErrCode SUNAdaptController_Reset_ImExGus(SUNAdaptController C);

SUNDIALS_EXPORT
int SUNAdaptController_SetDefaults_ImExGus(SUNAdaptController C);
SUNErrCode SUNAdaptController_SetDefaults_ImExGus(SUNAdaptController C);

SUNDIALS_EXPORT
int SUNAdaptController_Write_ImExGus(SUNAdaptController C, FILE* fptr);
SUNErrCode SUNAdaptController_Write_ImExGus(SUNAdaptController C, FILE* fptr);

SUNDIALS_EXPORT
int SUNAdaptController_SetErrorBias_ImExGus(SUNAdaptController C,
sunrealtype bias);
SUNErrCode SUNAdaptController_SetErrorBias_ImExGus(SUNAdaptController C,
sunrealtype bias);
SUNDIALS_EXPORT
int SUNAdaptController_UpdateH_ImExGus(SUNAdaptController C, sunrealtype h,
sunrealtype dsm);
SUNErrCode SUNAdaptController_UpdateH_ImExGus(SUNAdaptController C,
sunrealtype h, sunrealtype dsm);

SUNDIALS_EXPORT
int SUNAdaptController_Space_ImExGus(SUNAdaptController C, long int* lenrw,
long int* leniw);
SUNErrCode SUNAdaptController_Space_ImExGus(SUNAdaptController C,
long int* lenrw, long int* leniw);

#ifdef __cplusplus
}
Expand Down
67 changes: 43 additions & 24 deletions include/sunadaptcontroller/sunadaptcontroller_soderlind.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,59 +52,78 @@ typedef struct _SUNAdaptControllerContent_Soderlind* SUNAdaptControllerContent_S

SUNDIALS_EXPORT
SUNAdaptController SUNAdaptController_Soderlind(SUNContext sunctx);

SUNDIALS_EXPORT
int SUNAdaptController_SetParams_Soderlind(SUNAdaptController C, sunrealtype k1,
sunrealtype k2, sunrealtype k3,
sunrealtype k4, sunrealtype k5);
SUNErrCode SUNAdaptController_SetParams_Soderlind(SUNAdaptController C,
sunrealtype k1, sunrealtype k2,
sunrealtype k3, sunrealtype k4,
sunrealtype k5);

SUNDIALS_EXPORT
SUNAdaptController_Type SUNAdaptController_GetType_Soderlind(SUNAdaptController C);

SUNDIALS_EXPORT
int SUNAdaptController_EstimateStep_Soderlind(SUNAdaptController C,
sunrealtype h, int p,
sunrealtype dsm, sunrealtype* hnew);
SUNErrCode SUNAdaptController_EstimateStep_Soderlind(SUNAdaptController C,
sunrealtype h, int p,
sunrealtype dsm,
sunrealtype* hnew);

SUNDIALS_EXPORT
int SUNAdaptController_Reset_Soderlind(SUNAdaptController C);
SUNErrCode SUNAdaptController_Reset_Soderlind(SUNAdaptController C);

SUNDIALS_EXPORT
int SUNAdaptController_SetDefaults_Soderlind(SUNAdaptController C);
SUNErrCode SUNAdaptController_SetDefaults_Soderlind(SUNAdaptController C);

SUNDIALS_EXPORT
int SUNAdaptController_Write_Soderlind(SUNAdaptController C, FILE* fptr);
SUNErrCode SUNAdaptController_Write_Soderlind(SUNAdaptController C, FILE* fptr);

SUNDIALS_EXPORT
int SUNAdaptController_SetErrorBias_Soderlind(SUNAdaptController C,
sunrealtype bias);
SUNErrCode SUNAdaptController_SetErrorBias_Soderlind(SUNAdaptController C,
sunrealtype bias);

SUNDIALS_EXPORT
int SUNAdaptController_UpdateH_Soderlind(SUNAdaptController C, sunrealtype h,
sunrealtype dsm);
SUNErrCode SUNAdaptController_UpdateH_Soderlind(SUNAdaptController C,
sunrealtype h, sunrealtype dsm);

SUNDIALS_EXPORT
int SUNAdaptController_Space_Soderlind(SUNAdaptController C, long int* lenrw,
long int* leniw);
SUNErrCode SUNAdaptController_Space_Soderlind(SUNAdaptController C,
long int* lenrw, long int* leniw);

/* Convenience routines to construct subsidiary controllers */

SUNDIALS_EXPORT
SUNAdaptController SUNAdaptController_PID(SUNContext sunctx);

SUNDIALS_EXPORT
int SUNAdaptController_SetParams_PID(SUNAdaptController C, sunrealtype k1,
sunrealtype k2, sunrealtype k3);
SUNErrCode SUNAdaptController_SetParams_PID(SUNAdaptController C, sunrealtype k1,
sunrealtype k2, sunrealtype k3);

SUNDIALS_EXPORT
SUNAdaptController SUNAdaptController_PI(SUNContext sunctx);

SUNDIALS_EXPORT
int SUNAdaptController_SetParams_PI(SUNAdaptController C, sunrealtype k1,
sunrealtype k2);
SUNErrCode SUNAdaptController_SetParams_PI(SUNAdaptController C, sunrealtype k1,
sunrealtype k2);

SUNDIALS_EXPORT
SUNAdaptController SUNAdaptController_I(SUNContext sunctx);

SUNDIALS_EXPORT
int SUNAdaptController_SetParams_I(SUNAdaptController C, sunrealtype k1);
SUNErrCode SUNAdaptController_SetParams_I(SUNAdaptController C, sunrealtype k1);

SUNDIALS_EXPORT
SUNAdaptController SUNAdaptController_ExpGus(SUNContext sunctx);

SUNDIALS_EXPORT
int SUNAdaptController_SetParams_ExpGus(SUNAdaptController C, sunrealtype k1,
sunrealtype k2);
SUNErrCode SUNAdaptController_SetParams_ExpGus(SUNAdaptController C,
sunrealtype k1, sunrealtype k2);

SUNDIALS_EXPORT
SUNAdaptController SUNAdaptController_ImpGus(SUNContext sunctx);

SUNDIALS_EXPORT
int SUNAdaptController_SetParams_ImpGus(SUNAdaptController C, sunrealtype k1,
sunrealtype k2);
SUNErrCode SUNAdaptController_SetParams_ImpGus(SUNAdaptController C,
sunrealtype k1, sunrealtype k2);

#ifdef __cplusplus
}
Expand Down
13 changes: 2 additions & 11 deletions include/sundials/sundials_adaptcontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ SUNAdaptController_Type SUNAdaptController_GetType(SUNAdaptController C);

/* Function to deallocate a SUNAdaptController object.

Any return value other than SUNADAPTCONTROLLER_SUCCESS will be treated as
Any return value other than SUN_SUCCESS will be treated as
an unrecoverable failure. */
SUNDIALS_EXPORT
SUNErrCode SUNAdaptController_Destroy(SUNAdaptController C);
Expand All @@ -107,7 +107,7 @@ SUNErrCode SUNAdaptController_Destroy(SUNAdaptController C);
controller should estimate 'hnew' so that the ensuing step
will have 'dsm' value JUST BELOW 1.

Any return value other than SUNADAPTCONTROLLER_SUCCESS will be treated as
Any return value other than SUN_SUCCESS will be treated as
an unrecoverable failure. */
SUNDIALS_EXPORT
SUNErrCode SUNAdaptController_EstimateStep(SUNAdaptController C, sunrealtype h,
Expand Down Expand Up @@ -146,15 +146,6 @@ SUNDIALS_EXPORT
SUNErrCode SUNAdaptController_Space(SUNAdaptController C, long int* lenrw,
long int* leniw);

/* -----------------------------------------------------------------
* SUNAdaptController error codes
* ----------------------------------------------------------------- */

/* TODO(CJB): eliminate these after updating soderlind and imexgus in follow-on PR */
#define SUNADAPTCONTROLLER_SUCCESS 0 /* function successfull */
#define SUNADAPTCONTROLLER_ILL_INPUT -1001 /* illegal function input */
#define SUNADAPTCONTROLLER_USER_FCN_FAIL -1003 /* user-supplied fcn failure */

#ifdef __cplusplus
}
#endif
Expand Down
1 change: 1 addition & 0 deletions include/sundials/sundials_errors.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
ENTRY(SUN_ERR_DESTROY_FAIL, "a destroy function returned an error") \
ENTRY(SUN_ERR_NOT_IMPLEMENTED, \
"operation is not implemented: function pointer is NULL") \
ENTRY(SUN_ERR_USER_FCN_FAIL, "the user provided callback function failed") \
\
ENTRY(SUN_ERR_PROFILER_MAPFULL, \
"the number of profiler entries exceeded SUNPROFILER_MAX_ENTRIES") \
Expand Down
Loading
Loading