Skip to content

Commit be49360

Browse files
authored
Merge pull request #2283 from stan-dev/feature/issue-update-sundials-561
Feature/issue update sundials 561
2 parents 62f5aa8 + e883b1a commit be49360

File tree

308 files changed

+4179
-448
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

308 files changed

+4179
-448
lines changed

README.md

+2-2
File renamed without changes.
File renamed without changes.

lib/sundials_5.5.0/README.md lib/sundials_5.6.1/README.md

+1-1
File renamed without changes.

lib/sundials_5.5.0/include/nvector/nvector_cuda.h lib/sundials_5.6.1/include/nvector/nvector_cuda.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ SUNDIALS_STATIC_INLINE
105105
realtype *N_VGetDeviceArrayPointer_Cuda(N_Vector x)
106106
{
107107
N_VectorContent_Cuda content = (N_VectorContent_Cuda)x->content;
108-
return(content->host_data == NULL ? NULL : (realtype*)content->device_data->ptr);
108+
return(content->device_data == NULL ? NULL : (realtype*)content->device_data->ptr);
109109
}
110110

111111
/*
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,217 @@
1+
/* -----------------------------------------------------------------
2+
* Programmer(s): Daniel McGreer and Cody J. Balos @ LLNL
3+
* -----------------------------------------------------------------
4+
* SUNDIALS Copyright Start
5+
* Copyright (c) 2002-2020, Lawrence Livermore National Security
6+
* and Southern Methodist University.
7+
* All rights reserved.
8+
*
9+
* See the top-level LICENSE and NOTICE files for details.
10+
*
11+
* SPDX-License-Identifier: BSD-3-Clause
12+
* SUNDIALS Copyright End
13+
* -----------------------------------------------------------------
14+
* This is the header file for the hip implementation of the
15+
* NVECTOR module.
16+
*
17+
* Notes:
18+
*
19+
* - The definition of the generic N_Vector structure can be found
20+
* in the header file sundials_nvector.h.
21+
*
22+
* - The definitions of the types 'realtype' and 'sunindextype' can
23+
* be found in the header file sundials_types.h, and it may be
24+
* changed (at the configuration stage) according to the user's needs.
25+
* The sundials_types.h file also contains the definition
26+
* for the type 'booleantype'.
27+
*
28+
* - N_Vector arguments to arithmetic vector operations need not
29+
* be distinct. For example, the following call:
30+
*
31+
* N_VLinearSum_Hip(a,x,b,y,y);
32+
*
33+
* (which stores the result of the operation a*x+b*y in y)
34+
* is legal.
35+
* -----------------------------------------------------------------*/
36+
37+
#ifndef _NVECTOR_HIP_H
38+
#define _NVECTOR_HIP_H
39+
40+
#include <stdio.h>
41+
42+
#include <sundials/sundials_hip_policies.hpp>
43+
#include <sundials/sundials_memory.h>
44+
#include <sundials/sundials_nvector.h>
45+
46+
#ifdef __cplusplus /* wrapper to enable C++ usage */
47+
extern "C" {
48+
#endif
49+
50+
/*
51+
* -----------------------------------------------------------------
52+
* hip implementation of N_Vector
53+
* -----------------------------------------------------------------
54+
*/
55+
56+
struct _N_VectorContent_Hip
57+
{
58+
sunindextype length;
59+
booleantype own_exec;
60+
booleantype own_helper;
61+
SUNMemory host_data;
62+
SUNMemory device_data;
63+
SUNHipExecPolicy* stream_exec_policy;
64+
SUNHipExecPolicy* reduce_exec_policy;
65+
SUNMemoryHelper mem_helper;
66+
void* priv; /* 'private' data */
67+
};
68+
69+
typedef struct _N_VectorContent_Hip *N_VectorContent_Hip;
70+
71+
/*
72+
* -----------------------------------------------------------------
73+
* NVECTOR_HIP implementation specific functions
74+
* -----------------------------------------------------------------
75+
*/
76+
77+
SUNDIALS_EXPORT N_Vector N_VNew_Hip(sunindextype length);
78+
SUNDIALS_EXPORT N_Vector N_VNewManaged_Hip(sunindextype length);
79+
SUNDIALS_EXPORT N_Vector N_VNewWithMemHelp_Hip(sunindextype length,
80+
booleantype use_managed_mem,
81+
SUNMemoryHelper helper);
82+
SUNDIALS_EXPORT N_Vector N_VNewEmpty_Hip();
83+
SUNDIALS_EXPORT N_Vector N_VMake_Hip(sunindextype length,
84+
realtype *h_vdata,
85+
realtype *d_vdata);
86+
SUNDIALS_EXPORT N_Vector N_VMakeManaged_Hip(sunindextype length,
87+
realtype *vdata);
88+
SUNDIALS_EXPORT void N_VSetHostArrayPointer_Hip(realtype* h_vdata, N_Vector v);
89+
SUNDIALS_EXPORT booleantype N_VIsManagedMemory_Hip(N_Vector x);
90+
SUNDIALS_EXPORT int N_VSetKernelExecPolicy_Hip(N_Vector x,
91+
SUNHipExecPolicy* stream_exec_policy,
92+
SUNHipExecPolicy* reduce_exec_policy);
93+
SUNDIALS_EXPORT void N_VCopyToDevice_Hip(N_Vector v);
94+
SUNDIALS_EXPORT void N_VCopyFromDevice_Hip(N_Vector v);
95+
SUNDIALS_EXPORT void N_VPrint_Hip(N_Vector v);
96+
SUNDIALS_EXPORT void N_VPrintFile_Hip(N_Vector v, FILE *outfile);
97+
98+
SUNDIALS_STATIC_INLINE
99+
sunindextype N_VGetLength_Hip(N_Vector x)
100+
{
101+
N_VectorContent_Hip content = (N_VectorContent_Hip)x->content;
102+
return content->length;
103+
}
104+
105+
SUNDIALS_STATIC_INLINE
106+
realtype *N_VGetHostArrayPointer_Hip(N_Vector x)
107+
{
108+
N_VectorContent_Hip content = (N_VectorContent_Hip)x->content;
109+
return(content->host_data == NULL ? NULL : (realtype*)content->host_data->ptr);
110+
}
111+
112+
SUNDIALS_STATIC_INLINE
113+
realtype *N_VGetDeviceArrayPointer_Hip(N_Vector x)
114+
{
115+
N_VectorContent_Hip content = (N_VectorContent_Hip)x->content;
116+
return(content->device_data == NULL ? NULL : (realtype*)content->device_data->ptr);
117+
}
118+
119+
/*
120+
* -----------------------------------------------------------------
121+
* NVECTOR API functions
122+
* -----------------------------------------------------------------
123+
*/
124+
125+
SUNDIALS_EXPORT N_Vector N_VCloneEmpty_Hip(N_Vector w);
126+
SUNDIALS_EXPORT N_Vector N_VClone_Hip(N_Vector w);
127+
SUNDIALS_EXPORT void N_VDestroy_Hip(N_Vector v);
128+
SUNDIALS_EXPORT void N_VSpace_Hip(N_Vector v, sunindextype *lrw, sunindextype *liw);
129+
130+
/* standard vector operations */
131+
SUNDIALS_EXPORT void N_VLinearSum_Hip(realtype a, N_Vector x, realtype b, N_Vector y, N_Vector z);
132+
SUNDIALS_EXPORT void N_VConst_Hip(realtype c, N_Vector z);
133+
SUNDIALS_EXPORT void N_VProd_Hip(N_Vector x, N_Vector y, N_Vector z);
134+
SUNDIALS_EXPORT void N_VDiv_Hip(N_Vector x, N_Vector y, N_Vector z);
135+
SUNDIALS_EXPORT void N_VScale_Hip(realtype c, N_Vector x, N_Vector z);
136+
SUNDIALS_EXPORT void N_VAbs_Hip(N_Vector x, N_Vector z);
137+
SUNDIALS_EXPORT void N_VInv_Hip(N_Vector x, N_Vector z);
138+
SUNDIALS_EXPORT void N_VAddConst_Hip(N_Vector x, realtype b, N_Vector z);
139+
SUNDIALS_EXPORT realtype N_VDotProd_Hip(N_Vector x, N_Vector y);
140+
SUNDIALS_EXPORT realtype N_VMaxNorm_Hip(N_Vector x);
141+
SUNDIALS_EXPORT realtype N_VWrmsNorm_Hip(N_Vector x, N_Vector w);
142+
SUNDIALS_EXPORT realtype N_VWrmsNormMask_Hip(N_Vector x, N_Vector w, N_Vector id);
143+
SUNDIALS_EXPORT realtype N_VMin_Hip(N_Vector x);
144+
SUNDIALS_EXPORT realtype N_VWL2Norm_Hip(N_Vector x, N_Vector w);
145+
SUNDIALS_EXPORT realtype N_VL1Norm_Hip(N_Vector x);
146+
SUNDIALS_EXPORT void N_VCompare_Hip(realtype c, N_Vector x, N_Vector z);
147+
SUNDIALS_EXPORT booleantype N_VInvTest_Hip(N_Vector x, N_Vector z);
148+
SUNDIALS_EXPORT booleantype N_VConstrMask_Hip(N_Vector c, N_Vector x, N_Vector m);
149+
SUNDIALS_EXPORT realtype N_VMinQuotient_Hip(N_Vector num, N_Vector denom);
150+
151+
/* fused vector operations */
152+
SUNDIALS_EXPORT int N_VLinearCombination_Hip(int nvec, realtype* c, N_Vector* X,
153+
N_Vector Z);
154+
SUNDIALS_EXPORT int N_VScaleAddMulti_Hip(int nvec, realtype* c, N_Vector X,
155+
N_Vector* Y, N_Vector* Z);
156+
SUNDIALS_EXPORT int N_VDotProdMulti_Hip(int nvec, N_Vector x, N_Vector* Y,
157+
realtype* dotprods);
158+
159+
/* vector array operations */
160+
SUNDIALS_EXPORT int N_VLinearSumVectorArray_Hip(int nvec,
161+
realtype a, N_Vector* X,
162+
realtype b, N_Vector* Y,
163+
N_Vector* Z);
164+
SUNDIALS_EXPORT int N_VScaleVectorArray_Hip(int nvec, realtype* c, N_Vector* X,
165+
N_Vector* Z);
166+
SUNDIALS_EXPORT int N_VConstVectorArray_Hip(int nvec, realtype c, N_Vector* Z);
167+
SUNDIALS_EXPORT int N_VScaleAddMultiVectorArray_Hip(int nvec, int nsum,
168+
realtype* a, N_Vector* X,
169+
N_Vector** Y, N_Vector** Z);
170+
SUNDIALS_EXPORT int N_VLinearCombinationVectorArray_Hip(int nvec, int nsum,
171+
realtype* c,
172+
N_Vector** X,
173+
N_Vector* Z);
174+
SUNDIALS_EXPORT int N_VWrmsNormVectorArray_Hip(int nvec, N_Vector* X,
175+
N_Vector* W, realtype* nrm);
176+
SUNDIALS_EXPORT int N_VWrmsNormMaskVectorArray_Hip(int nvec, N_Vector* X,
177+
N_Vector* W, N_Vector id,
178+
realtype* nrm);
179+
180+
/* OPTIONAL local reduction kernels (no parallel communication) */
181+
SUNDIALS_EXPORT realtype N_VWSqrSumLocal_Hip(N_Vector x, N_Vector w);
182+
SUNDIALS_EXPORT realtype N_VWSqrSumMaskLocal_Hip(N_Vector x, N_Vector w, N_Vector id);
183+
184+
/* OPTIONAL XBraid interface operations */
185+
SUNDIALS_EXPORT int N_VBufSize_Hip(N_Vector x, sunindextype *size);
186+
SUNDIALS_EXPORT int N_VBufPack_Hip(N_Vector x, void *buf);
187+
SUNDIALS_EXPORT int N_VBufUnpack_Hip(N_Vector x, void *buf);
188+
189+
/* OPTIONAL operations for debugging */
190+
SUNDIALS_EXPORT void N_VPrint_Hip(N_Vector v);
191+
SUNDIALS_EXPORT void N_VPrintFile_Hip(N_Vector v, FILE *outfile);
192+
193+
/*
194+
* -----------------------------------------------------------------
195+
* Enable / disable fused vector operations
196+
* -----------------------------------------------------------------
197+
*/
198+
199+
SUNDIALS_EXPORT int N_VEnableFusedOps_Hip(N_Vector v, booleantype tf);
200+
201+
SUNDIALS_EXPORT int N_VEnableLinearCombination_Hip(N_Vector v, booleantype tf);
202+
SUNDIALS_EXPORT int N_VEnableScaleAddMulti_Hip(N_Vector v, booleantype tf);
203+
SUNDIALS_EXPORT int N_VEnableDotProdMulti_Hip(N_Vector v, booleantype tf);
204+
205+
SUNDIALS_EXPORT int N_VEnableLinearSumVectorArray_Hip(N_Vector v, booleantype tf);
206+
SUNDIALS_EXPORT int N_VEnableScaleVectorArray_Hip(N_Vector v, booleantype tf);
207+
SUNDIALS_EXPORT int N_VEnableConstVectorArray_Hip(N_Vector v, booleantype tf);
208+
SUNDIALS_EXPORT int N_VEnableWrmsNormVectorArray_Hip(N_Vector v, booleantype tf);
209+
SUNDIALS_EXPORT int N_VEnableWrmsNormMaskVectorArray_Hip(N_Vector v, booleantype tf);
210+
SUNDIALS_EXPORT int N_VEnableScaleAddMultiVectorArray_Hip(N_Vector v, booleantype tf);
211+
SUNDIALS_EXPORT int N_VEnableLinearCombinationVectorArray_Hip(N_Vector v, booleantype tf);
212+
213+
#ifdef __cplusplus
214+
}
215+
#endif
216+
217+
#endif

lib/sundials_5.5.0/include/nvector/nvector_mpiplusx.h lib/sundials_5.6.1/include/nvector/nvector_mpiplusx.h

+4
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ SUNDIALS_EXPORT N_Vector N_VGetLocalVector_MPIPlusX(N_Vector v);
4242

4343
SUNDIALS_EXPORT sunindextype N_VGetLocalLength_MPIPlusX(N_Vector v);
4444

45+
SUNDIALS_STATIC_INLINE
46+
int N_VEnableFusedOps_MPIPlusX(N_Vector v, booleantype tf)
47+
{ return N_VEnableFusedOps_MPIManyVector(v, tf); }
48+
4549
#ifdef __cplusplus
4650
}
4751
#endif

lib/sundials_5.5.0/include/nvector/nvector_raja.h lib/sundials_5.6.1/include/nvector/nvector_raja.h

+5-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
*
1111
* SPDX-License-Identifier: BSD-3-Clause
1212
* SUNDIALS Copyright End
13+
* -----------------------------------------------------------------
14+
* This is the header file for the RAJA implementation of the
15+
* NVECTOR module.
1316
* -----------------------------------------------------------------*/
1417

1518
#ifndef _NVECTOR_RAJA_H
@@ -18,8 +21,8 @@
1821
#include <stdio.h>
1922

2023
#include <sundials/sundials_nvector.h>
24+
#include <sundials/sundials_memory.h>
2125
#include <sundials/sundials_config.h>
22-
#include <sunmemory/sunmemory_cuda.h>
2326

2427
#ifdef __cplusplus /* wrapper to enable C++ usage */
2528
extern "C" {
@@ -85,7 +88,7 @@ SUNDIALS_STATIC_INLINE
8588
realtype *N_VGetDeviceArrayPointer_Raja(N_Vector x)
8689
{
8790
N_VectorContent_Raja content = (N_VectorContent_Raja)x->content;
88-
return(content->host_data == NULL ? NULL : (realtype*)content->device_data->ptr);
91+
return(content->device_data == NULL ? NULL : (realtype*)content->device_data->ptr);
8992
}
9093

9194

lib/sundials_5.5.0/include/sundials/sundials_config.h lib/sundials_5.6.1/include/sundials/sundials_config.h

+16-14
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@
2525
* -----------------------------------------------------------------*/
2626

2727

28-
#define SUNDIALS_VERSION "5.5.0"
28+
#define SUNDIALS_VERSION "5.6.1"
2929
#define SUNDIALS_VERSION_MAJOR 5
30-
#define SUNDIALS_VERSION_MINOR 5
31-
#define SUNDIALS_VERSION_PATCH 0
30+
#define SUNDIALS_VERSION_MINOR 6
31+
#define SUNDIALS_VERSION_PATCH 1
3232
#define SUNDIALS_VERSION_LABEL ""
3333

3434

@@ -70,6 +70,16 @@
7070
*/
7171
/* #undef SUNDIALS_HAVE_POSIX_TIMERS */
7272

73+
/* CVODE should use fused kernels if utilizing
74+
* the CUDA NVector.
75+
*/
76+
/* #undef SUNDIALS_BUILD_PACKAGE_FUSED_KERNELS */
77+
78+
79+
/* BUILD SUNDIALS with monitoring functionalities
80+
* the CUDA NVector.
81+
*/
82+
/* #undef SUNDIALS_BUILD_WITH_MONITORING */
7383

7484
/* ------------------------------------------------------------------
7585
* SUNDIALS TPL macros
@@ -93,17 +103,9 @@
93103
*/
94104
/* #undef SUNDIALS_TRILINOS_HAVE_MPI */
95105

96-
/* CVODE should use fused kernels if utilizing
97-
* the CUDA NVector.
98-
*/
99-
/* #undef SUNDIALS_BUILD_PACKAGE_FUSED_KERNELS */
100-
101-
102-
/* BUILD SUNDIALS with monitoring functionalities
103-
* the CUDA NVector.
104-
*/
105-
/* #undef SUNDIALS_BUILD_WITH_MONITORING */
106-
106+
/* RAJA backends */
107+
/* #undef SUNDIALS_RAJA_BACKENDS_HIP */
108+
#define SUNDIALS_RAJA_BACKENDS_CUDA
107109

108110
/* ------------------------------------------------------------------
109111
* SUNDIALS modules enabled

lib/sundials_5.5.0/include/sundials/sundials_config.in lib/sundials_5.6.1/include/sundials/sundials_config.in

+13-11
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,16 @@
7070
*/
7171
#cmakedefine SUNDIALS_HAVE_POSIX_TIMERS
7272

73+
/* CVODE should use fused kernels if utilizing
74+
* the CUDA NVector.
75+
*/
76+
#cmakedefine SUNDIALS_BUILD_PACKAGE_FUSED_KERNELS
77+
78+
79+
/* BUILD SUNDIALS with monitoring functionalities
80+
* the CUDA NVector.
81+
*/
82+
#cmakedefine SUNDIALS_BUILD_WITH_MONITORING
7383

7484
/* ------------------------------------------------------------------
7585
* SUNDIALS TPL macros
@@ -93,17 +103,9 @@
93103
*/
94104
#cmakedefine SUNDIALS_TRILINOS_HAVE_MPI
95105

96-
/* CVODE should use fused kernels if utilizing
97-
* the CUDA NVector.
98-
*/
99-
#cmakedefine SUNDIALS_BUILD_PACKAGE_FUSED_KERNELS
100-
101-
102-
/* BUILD SUNDIALS with monitoring functionalities
103-
* the CUDA NVector.
104-
*/
105-
#cmakedefine SUNDIALS_BUILD_WITH_MONITORING
106-
106+
/* RAJA backends */
107+
#cmakedefine SUNDIALS_RAJA_BACKENDS_HIP
108+
#cmakedefine SUNDIALS_RAJA_BACKENDS_CUDA
107109

108110
/* ------------------------------------------------------------------
109111
* SUNDIALS modules enabled

0 commit comments

Comments
 (0)