Skip to content

Commit

Permalink
more warnings fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
balos1 committed Oct 8, 2024
1 parent e8d65b6 commit 11220bb
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 62 deletions.
10 changes: 0 additions & 10 deletions doc/shared/sundials/Profiling.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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``.
2 changes: 1 addition & 1 deletion examples/arkode/C_serial/ark_lotka_volterra_ASA.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
39 changes: 19 additions & 20 deletions include/sunadjoint/sunadjoint_checkpointscheme.h
Original file line number Diff line number Diff line change
Expand Up @@ -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*);

Expand All @@ -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
Expand Down
20 changes: 10 additions & 10 deletions include/sunadjoint/sunadjoint_checkpointscheme_basic.h
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
20 changes: 10 additions & 10 deletions src/sunadjoint/sunadjoint_checkpointscheme.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions src/sunadjoint/sunadjoint_checkpointscheme_basic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);

Expand Down Expand Up @@ -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);
Expand Down
12 changes: 10 additions & 2 deletions src/sundials/sundials_profiler.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* SUNDIALS Copyright End
* -----------------------------------------------------------------*/

#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion test/unit_tests/arkode/C_serial/ark_test_sunadjoint.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
8 changes: 4 additions & 4 deletions test/unit_tests/sundials/test_sundials_hashmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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";
Expand Down Expand Up @@ -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";
Expand All @@ -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";
Expand Down

0 comments on commit 11220bb

Please sign in to comment.