diff --git a/doc/shared/sundials/Profiling.rst b/doc/shared/sundials/Profiling.rst index 2f8f458235..73dbcb08ba 100644 --- a/doc/shared/sundials/Profiling.rst +++ b/doc/shared/sundials/Profiling.rst @@ -237,13 +237,3 @@ It is applicable to any of the SUNDIALS solver packages. } SUNDIALS_MARK_END(profobj, "Integration loop"); PrintFinalStats(cvode_mem); /* Print some final statistics */ - - -.. _SUNDIALS.Profiling.Other: - -Other Considerations --------------------- - -If many regions are being timed, it may be necessary to increase the maximum -number of profiler entries (the default is ``2560``). This can be done -by setting the environment variable ``SUNPROFILER_MAX_ENTRIES``. diff --git a/examples/arkode/C_serial/ark_lotka_volterra_ASA.c b/examples/arkode/C_serial/ark_lotka_volterra_ASA.c index e13574c5e1..1c826baf2c 100644 --- a/examples/arkode/C_serial/ark_lotka_volterra_ASA.c +++ b/examples/arkode/C_serial/ark_lotka_volterra_ASA.c @@ -109,7 +109,7 @@ int main(int argc, char* argv[]) const sunrealtype dt = args.dt; sunrealtype t0 = 0.0; sunrealtype tf = args.tf; - const int nsteps = ((tf - t0) / dt + 1); + const int nsteps = (int)ceil(((tf - t0) / dt + 1)); const int order = args.order; void* arkode_mem = ARKStepCreate(lotka_volterra, NULL, t0, u, sunctx); diff --git a/include/sunadjoint/sunadjoint_checkpointscheme.h b/include/sunadjoint/sunadjoint_checkpointscheme.h index 25a2496e86..7a925162ce 100644 --- a/include/sunadjoint/sunadjoint_checkpointscheme.h +++ b/include/sunadjoint/sunadjoint_checkpointscheme.h @@ -27,23 +27,22 @@ typedef _SUNDIALS_STRUCT_ SUNAdjointCheckpointScheme_* SUNAdjointCheckpointSchem struct SUNAdjointCheckpointScheme_Ops_ { - SUNErrCode (*shouldWeSave)(SUNAdjointCheckpointScheme, sunindextype step_num, - sunindextype stage_num, sunrealtype t, + SUNErrCode (*shouldWeSave)(SUNAdjointCheckpointScheme, int64_t step_num, + int64_t stage_num, sunrealtype t, sunbooleantype* yes_or_no); - SUNErrCode (*shouldWeDelete)(SUNAdjointCheckpointScheme, sunindextype step_num, - sunindextype stage_num, sunbooleantype* yes_or_no); + SUNErrCode (*shouldWeDelete)(SUNAdjointCheckpointScheme, int64_t step_num, + int64_t stage_num, sunbooleantype* yes_or_no); - SUNErrCode (*insertVector)(SUNAdjointCheckpointScheme, sunindextype step_num, - sunindextype stage_num, sunrealtype t, - N_Vector state); + SUNErrCode (*insertVector)(SUNAdjointCheckpointScheme, int64_t step_num, + int64_t stage_num, sunrealtype t, N_Vector state); - SUNErrCode (*loadVector)(SUNAdjointCheckpointScheme, sunindextype step_num, - sunindextype stage_num, sunbooleantype peek, + SUNErrCode (*loadVector)(SUNAdjointCheckpointScheme, int64_t step_num, + int64_t stage_num, sunbooleantype peek, N_Vector* out, sunrealtype* tout); - SUNErrCode (*removeVector)(SUNAdjointCheckpointScheme, sunindextype step_num, - sunindextype stage_num, N_Vector* out); + SUNErrCode (*removeVector)(SUNAdjointCheckpointScheme, int64_t step_num, + int64_t stage_num, N_Vector* out); SUNErrCode (*destroy)(SUNAdjointCheckpointScheme*); @@ -63,31 +62,31 @@ SUNErrCode SUNAdjointCheckpointScheme_NewEmpty(SUNContext sunctx, SUNDIALS_EXPORT SUNErrCode SUNAdjointCheckpointScheme_ShouldWeSave(SUNAdjointCheckpointScheme, - sunindextype step_num, - sunindextype stage_num, + int64_t step_num, + int64_t stage_num, sunrealtype t, sunbooleantype* yes_or_no); SUNDIALS_EXPORT SUNErrCode SUNAdjointCheckpointScheme_ShouldWeDelete(SUNAdjointCheckpointScheme, - sunindextype step_num, - sunindextype stage_num, + int64_t step_num, + int64_t stage_num, sunbooleantype* yes_or_no); SUNDIALS_EXPORT SUNErrCode SUNAdjointCheckpointScheme_InsertVector(SUNAdjointCheckpointScheme, - sunindextype step_num, - sunindextype stage_num, + int64_t step_num, + int64_t stage_num, sunrealtype t, N_Vector state); SUNDIALS_EXPORT SUNErrCode SUNAdjointCheckpointScheme_LoadVector( - SUNAdjointCheckpointScheme, sunindextype step_num, sunindextype stage_num, + SUNAdjointCheckpointScheme, int64_t step_num, int64_t stage_num, sunbooleantype peek, N_Vector* out, sunrealtype* tout); SUNErrCode SUNAdjointCheckpointScheme_RemoveVector(SUNAdjointCheckpointScheme, - sunindextype step_num, - sunindextype stage_num, + int64_t step_num, + int64_t stage_num, N_Vector* out); SUNDIALS_EXPORT diff --git a/include/sunadjoint/sunadjoint_checkpointscheme_basic.h b/include/sunadjoint/sunadjoint_checkpointscheme_basic.h index d53a3f8cad..be40724efb 100644 --- a/include/sunadjoint/sunadjoint_checkpointscheme_basic.h +++ b/include/sunadjoint/sunadjoint_checkpointscheme_basic.h @@ -32,28 +32,28 @@ SUNErrCode SUNAdjointCheckpointScheme_Create_Basic( SUNDIALS_EXPORT SUNErrCode SUNAdjointCheckpointScheme_ShouldWeSave_Basic( - SUNAdjointCheckpointScheme check_scheme, sunindextype step_num, - sunindextype stage_num, sunrealtype t, sunbooleantype* yes_or_no); + SUNAdjointCheckpointScheme check_scheme, int64_t step_num, int64_t stage_num, + sunrealtype t, sunbooleantype* yes_or_no); SUNDIALS_EXPORT SUNErrCode SUNAdjointCheckpointScheme_InsertVector_Basic( - SUNAdjointCheckpointScheme check_scheme, sunindextype step_num, - sunindextype stage_num, sunrealtype t, N_Vector state); + SUNAdjointCheckpointScheme check_scheme, int64_t step_num, int64_t stage_num, + sunrealtype t, N_Vector state); SUNDIALS_EXPORT SUNErrCode SUNAdjointCheckpointScheme_ShouldWeDelete_Basic( - SUNAdjointCheckpointScheme check_scheme, sunindextype step_num, - sunindextype stage_num, sunbooleantype* yes_or_no); + SUNAdjointCheckpointScheme check_scheme, int64_t step_num, int64_t stage_num, + sunbooleantype* yes_or_no); SUNDIALS_EXPORT SUNErrCode SUNAdjointCheckpointScheme_RemoveVector_Basic( - SUNAdjointCheckpointScheme check_scheme, sunindextype step_num, - sunindextype stage_num, N_Vector* out); + SUNAdjointCheckpointScheme check_scheme, int64_t step_num, int64_t stage_num, + N_Vector* out); SUNDIALS_EXPORT SUNErrCode SUNAdjointCheckpointScheme_LoadVector_Basic( - SUNAdjointCheckpointScheme check_scheme, sunindextype step_num, - sunindextype stage_num, sunbooleantype peek, N_Vector* out, sunrealtype* tout); + SUNAdjointCheckpointScheme check_scheme, int64_t step_num, int64_t stage_num, + sunbooleantype peek, N_Vector* out, sunrealtype* tout); SUNDIALS_EXPORT SUNErrCode SUNAdjointCheckpointScheme_Destroy_Basic( diff --git a/src/sunadjoint/sunadjoint_checkpointscheme.c b/src/sunadjoint/sunadjoint_checkpointscheme.c index 1f716a75b1..0a8eea7750 100644 --- a/src/sunadjoint/sunadjoint_checkpointscheme.c +++ b/src/sunadjoint/sunadjoint_checkpointscheme.c @@ -52,8 +52,8 @@ SUNErrCode SUNAdjointCheckpointScheme_NewEmpty( } SUNErrCode SUNAdjointCheckpointScheme_ShouldWeSave( - SUNAdjointCheckpointScheme check_scheme, sunindextype step_num, - sunindextype stage_num, sunrealtype t, sunbooleantype* yes_or_no) + SUNAdjointCheckpointScheme check_scheme, int64_t step_num, int64_t stage_num, + sunrealtype t, sunbooleantype* yes_or_no) { SUNFunctionBegin(check_scheme->sunctx); SUNDIALS_MARK_FUNCTION_BEGIN(SUNCTX_->profiler); @@ -69,8 +69,8 @@ SUNErrCode SUNAdjointCheckpointScheme_ShouldWeSave( } SUNErrCode SUNAdjointCheckpointScheme_ShouldWeDelete( - SUNAdjointCheckpointScheme check_scheme, sunindextype step_num, - sunindextype stage_num, sunbooleantype* yes_or_no) + SUNAdjointCheckpointScheme check_scheme, int64_t step_num, int64_t stage_num, + sunbooleantype* yes_or_no) { SUNFunctionBegin(check_scheme->sunctx); SUNDIALS_MARK_FUNCTION_BEGIN(SUNCTX_->profiler); @@ -86,8 +86,8 @@ SUNErrCode SUNAdjointCheckpointScheme_ShouldWeDelete( } SUNErrCode SUNAdjointCheckpointScheme_InsertVector( - SUNAdjointCheckpointScheme check_scheme, sunindextype step_num, - sunindextype stage_num, sunrealtype t, N_Vector state) + SUNAdjointCheckpointScheme check_scheme, int64_t step_num, int64_t stage_num, + sunrealtype t, N_Vector state) { SUNFunctionBegin(check_scheme->sunctx); SUNDIALS_MARK_FUNCTION_BEGIN(SUNCTX_->profiler); @@ -102,8 +102,8 @@ SUNErrCode SUNAdjointCheckpointScheme_InsertVector( } SUNErrCode SUNAdjointCheckpointScheme_LoadVector( - SUNAdjointCheckpointScheme check_scheme, sunindextype step_num, - sunindextype stage_num, sunbooleantype peek, N_Vector* out, sunrealtype* tout) + SUNAdjointCheckpointScheme check_scheme, int64_t step_num, int64_t stage_num, + sunbooleantype peek, N_Vector* out, sunrealtype* tout) { SUNFunctionBegin(check_scheme->sunctx); SUNDIALS_MARK_FUNCTION_BEGIN(SUNCTX_->profiler); @@ -118,8 +118,8 @@ SUNErrCode SUNAdjointCheckpointScheme_LoadVector( } SUNErrCode SUNAdjointCheckpointScheme_RemoveVector( - SUNAdjointCheckpointScheme check_scheme, sunindextype step_num, - sunindextype stage_num, N_Vector* out) + SUNAdjointCheckpointScheme check_scheme, int64_t step_num, int64_t stage_num, + N_Vector* out) { SUNFunctionBegin(check_scheme->sunctx); SUNDIALS_MARK_FUNCTION_BEGIN(SUNCTX_->profiler); diff --git a/src/sunadjoint/sunadjoint_checkpointscheme_basic.c b/src/sunadjoint/sunadjoint_checkpointscheme_basic.c index 135793749b..a094366fd7 100644 --- a/src/sunadjoint/sunadjoint_checkpointscheme_basic.c +++ b/src/sunadjoint/sunadjoint_checkpointscheme_basic.c @@ -88,7 +88,7 @@ SUNErrCode SUNAdjointCheckpointScheme_Create_Basic( } SUNErrCode SUNAdjointCheckpointScheme_ShouldWeSave_Basic( - SUNAdjointCheckpointScheme self, sunindextype step_num, sunindextype stage_num, + SUNAdjointCheckpointScheme self, int64_t step_num, int64_t stage_num, SUNDIALS_MAYBE_UNUSED sunrealtype t, sunbooleantype* yes_or_no) { SUNFunctionBegin(self->sunctx); @@ -105,8 +105,8 @@ SUNErrCode SUNAdjointCheckpointScheme_ShouldWeSave_Basic( } SUNErrCode SUNAdjointCheckpointScheme_InsertVector_Basic( - SUNAdjointCheckpointScheme self, sunindextype step_num, - sunindextype stage_num, sunrealtype t, N_Vector state) + SUNAdjointCheckpointScheme self, int64_t step_num, int64_t stage_num, + sunrealtype t, N_Vector state) { SUNFunctionBegin(self->sunctx); @@ -153,7 +153,7 @@ SUNErrCode SUNAdjointCheckpointScheme_InsertVector_Basic( } SUNErrCode SUNAdjointCheckpointScheme_LoadVector_Basic( - SUNAdjointCheckpointScheme self, sunindextype step_num, sunindextype stage_num, + SUNAdjointCheckpointScheme self, int64_t step_num, int64_t stage_num, sunbooleantype peek, N_Vector* loaded_state, sunrealtype* t) { SUNFunctionBegin(self->sunctx); diff --git a/src/sundials/sundials_profiler.c b/src/sundials/sundials_profiler.c index 67e1f0510e..598f0b76cf 100644 --- a/src/sundials/sundials_profiler.c +++ b/src/sundials/sundials_profiler.c @@ -12,6 +12,7 @@ * SUNDIALS Copyright End * -----------------------------------------------------------------*/ +#include #include #include #include @@ -470,13 +471,20 @@ SUNErrCode sunCollectTimers(SUNProfiler p) sunTimerStruct** values = NULL; - int64_t map_size = SUNHashMap_Capacity(p->map); + /* MPI restricts us to int, but the hashmap allows int64_t. + We add a check here to make sure that the capacity does + not exceed an int, although it is unlikely we ever will. */ + if (SUNHashMap_Capacity(p->map) > INT_MAX) + { + return SUN_ERR_PROFILER_MAPFULL; + } + int map_size = (int)SUNHashMap_Capacity(p->map); /* Extract the elapsed times from the hash map */ SUNHashMap_Values(p->map, (void***)&values, sizeof(sunTimerStruct)); sunTimerStruct* reduced = (sunTimerStruct*)malloc(map_size * sizeof(sunTimerStruct)); - for (int64_t i = 0; i < map_size; ++i) { reduced[i] = *values[i]; } + for (int i = 0; i < map_size; ++i) { reduced[i] = *values[i]; } /* Register MPI datatype for sunTimerStruct */ MPI_Datatype tmp_type, MPI_sunTimerStruct; diff --git a/test/unit_tests/arkode/C_serial/ark_test_sunadjoint.c b/test/unit_tests/arkode/C_serial/ark_test_sunadjoint.c index 583a047992..47ba673f08 100644 --- a/test/unit_tests/arkode/C_serial/ark_test_sunadjoint.c +++ b/test/unit_tests/arkode/C_serial/ark_test_sunadjoint.c @@ -295,7 +295,7 @@ int main(int argc, char* argv[]) const sunrealtype dt = args.dt; sunrealtype t0 = 0.0; sunrealtype tf = args.tf; - const int nsteps = ((tf - t0) / dt + 1); + const int nsteps = (int)ceil(((tf - t0) / dt + 1)); const int order = args.order; void* arkode_mem = ARKStepCreate(lotka_volterra, NULL, t0, u, sunctx); diff --git a/test/unit_tests/sundials/test_sundials_hashmap.cpp b/test/unit_tests/sundials/test_sundials_hashmap.cpp index 7a9bc88fd5..291cd0e99c 100644 --- a/test/unit_tests/sundials/test_sundials_hashmap.cpp +++ b/test/unit_tests/sundials/test_sundials_hashmap.cpp @@ -53,7 +53,7 @@ TEST_F(SUNHashMapTest, InsertAndGetWorks) { SetUp(1); - SUNErrCode err = SUN_SUCCESS; + int64_t err = 0; const char* key = "test_key"; int value = 42; @@ -71,7 +71,7 @@ TEST_F(SUNHashMapTest, InsertRequiringResizeWorks) { SetUp(2); - SUNErrCode err = SUN_SUCCESS; + int64_t err = 0; const char* key1 = "test_key1"; const char* key2 = "test_key2"; const char* key3 = "test_key3"; @@ -110,7 +110,7 @@ TEST_F(SUNHashMapTest, InsertDuplicateKeyFails) { SetUp(1); - int err; + int64_t err; // Insert same key twice (should overwrite) const char* key = "test_key"; @@ -127,7 +127,7 @@ TEST_F(SUNHashMapTest, RemoveWorks) { SetUp(2); - int err; + int64_t err; // Insert a key-value pair const char* key = "test_key";