File: test_nvector.h

package info (click to toggle)
sundials 6.4.1%2Bdfsg1-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 79,368 kB
  • sloc: ansic: 218,700; f90: 62,503; cpp: 61,511; fortran: 5,166; python: 4,642; sh: 4,114; makefile: 562; perl: 123
file content (156 lines) | stat: -rw-r--r-- 7,110 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
/* -----------------------------------------------------------------
 * Programmer(s): David J. Gardner @ LLNL
 * -----------------------------------------------------------------
 * SUNDIALS Copyright Start
 * Copyright (c) 2002-2022, Lawrence Livermore National Security
 * and Southern Methodist University.
 * All rights reserved.
 *
 * See the top-level LICENSE and NOTICE files for details.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 * SUNDIALS Copyright End
 * -----------------------------------------------------------------
 * This is the header file contains the prototypes for functions to
 * test an NVECTOR module implementation.
 * -----------------------------------------------------------------*/

#include <math.h>
#include <sundials/sundials_types.h>

/* define constants */
#define NEG_TWO  RCONST(-2.0)
#define NEG_ONE  RCONST(-1.0)
#define NEG_HALF RCONST(-0.5)
#define ZERO     RCONST(0.0)
#define HALF     RCONST(0.5)
#define ONE      RCONST(1.0)
#define TWO      RCONST(2.0)

#ifdef __cplusplus  /* wrapper to enable C++ usage */
extern "C" {
#endif

extern SUNContext sunctx;

/* Forward declarations for implementation specific utility functions */
int check_ans(realtype ans, N_Vector X, sunindextype local_length);
booleantype has_data(N_Vector X);
void set_element(N_Vector X, sunindextype i, realtype val);
void set_element_range(N_Vector X, sunindextype is, sunindextype ie,
                       realtype val);
realtype get_element(N_Vector X, sunindextype i);
double max_time(N_Vector X, double time);
void sync_device(N_Vector X);

/* Shared test initialization/finalization */
int Test_Init(void* comm);
int Test_Finalize();
void Test_Abort(int code);
void Test_AbortMPI(void* comm, int code);

/* Vector ID test */
int Test_N_VGetVectorID(N_Vector X, N_Vector_ID ID, int myid);

/* Vector constructor tests */
int Test_N_VMake(N_Vector X, sunindextype local_length, int myid);

/* Vector clone tests */
int Test_N_VCloneVectorArray(int count, N_Vector W, sunindextype local_length,
                             int myid);
int Test_N_VCloneEmptyVectorArray(int count, N_Vector W, int myid);
int Test_N_VCloneEmpty(N_Vector W, int myid);
int Test_N_VClone(N_Vector W, sunindextype local_length, int myid);

/* Vector get/set function tests */
int Test_N_VGetArrayPointer(N_Vector W, sunindextype local_length, int myid);
int Test_N_VSetArrayPointer(N_Vector W, sunindextype local_length, int myid);
int Test_N_VGetLength(N_Vector W, int myid);
int Test_N_VGetCommunicator(N_Vector W, void *comm, int myid);
int Test_N_VGetCommunicatorMPI(N_Vector W, void *comm, int myid);

/* Standard vector operation tests */
int Test_N_VLinearSum(N_Vector X, N_Vector Y, N_Vector Z,
                      sunindextype local_length, int myid);
int Test_N_VConst(N_Vector X, sunindextype local_length, int myid);
int Test_N_VProd(N_Vector X, N_Vector Y, N_Vector Z, sunindextype local_length,
                 int myid);
int Test_N_VDiv(N_Vector X, N_Vector Y, N_Vector Z, sunindextype local_length,
                int myid);
int Test_N_VScale(N_Vector X, N_Vector Z, sunindextype local_length, int myid);
int Test_N_VAbs(N_Vector X, N_Vector Z, sunindextype local_length, int myid);
int Test_N_VInv(N_Vector X, N_Vector Z, sunindextype local_length, int myid);
int Test_N_VAddConst(N_Vector X, N_Vector Z, sunindextype local_length,
                     int myid);
int Test_N_VDotProd(N_Vector X, N_Vector Y, sunindextype local_length,
                    int myid);
int Test_N_VMaxNorm(N_Vector X, sunindextype local_length, int myid);
int Test_N_VWrmsNorm(N_Vector X, N_Vector W, sunindextype local_length,
                     int myid);
int Test_N_VWrmsNormMask(N_Vector X, N_Vector W, N_Vector ID,
                         sunindextype local_length, int myid);
int Test_N_VMin(N_Vector X, sunindextype local_length, int myid);
int Test_N_VWL2Norm(N_Vector X, N_Vector W, sunindextype local_length,
                    int myid);
int Test_N_VL1Norm(N_Vector X, sunindextype local_length, int myid);
int Test_N_VCompare(N_Vector X, N_Vector Z, sunindextype local_length,
                    int myid);
int Test_N_VInvTest(N_Vector X, N_Vector Z, sunindextype local_length,
                    int myid);
int Test_N_VConstrMask(N_Vector C, N_Vector X, N_Vector M,
                       sunindextype local_length, int myid);
int Test_N_VMinQuotient(N_Vector NUM, N_Vector DENOM, sunindextype local_length,
                        int myid);

/* Fused vector operation tests */
int Test_N_VLinearCombination(N_Vector X, sunindextype local_length, int myid);
int Test_N_VScaleAddMulti(N_Vector X, sunindextype local_length, int myid);
int Test_N_VDotProdMulti(N_Vector X, sunindextype local_length, int myid);

/* Vector array operation tests */
int Test_N_VLinearSumVectorArray(N_Vector X, sunindextype local_length,
                                 int myid);
int Test_N_VScaleVectorArray(N_Vector X, sunindextype local_length, int myid);
int Test_N_VConstVectorArray(N_Vector X, sunindextype local_length, int myid);
int Test_N_VWrmsNormVectorArray(N_Vector X, sunindextype local_length,
                                int myid);
int Test_N_VWrmsNormMaskVectorArray(N_Vector X, sunindextype local_length,
                                    int myid);
int Test_N_VScaleAddMultiVectorArray(N_Vector X, sunindextype local_length,
                                     int myid);
int Test_N_VLinearCombinationVectorArray(N_Vector X, sunindextype local_length,
                                         int myid);

/* Local reduction operation tests */
int Test_N_VDotProdLocal(N_Vector X, N_Vector Y, sunindextype local_length,
                         int myid);
int Test_N_VMaxNormLocal(N_Vector X, sunindextype local_length, int myid);
int Test_N_VMinLocal(N_Vector X, sunindextype local_length, int myid);
int Test_N_VL1NormLocal(N_Vector X, sunindextype local_length, int myid);
int Test_N_VWSqrSumLocal(N_Vector X, N_Vector W, sunindextype local_length,
                         int myid);
int Test_N_VWSqrSumMaskLocal(N_Vector X, N_Vector W, N_Vector ID,
                             sunindextype local_length, int myid);
int Test_N_VInvTestLocal(N_Vector X, N_Vector Z, sunindextype local_length,
                         int myid);
int Test_N_VConstrMaskLocal(N_Vector C, N_Vector X, N_Vector M,
                            sunindextype local_length, int myid);
int Test_N_VMinQuotientLocal(N_Vector NUM, N_Vector DENOM,
                             sunindextype local_length, int myid);

/* Single buffer reduction tests */
int Test_N_VDotProdMultiLocal(N_Vector X, sunindextype local_length, int myid);
int Test_N_VDotProdMultiAllReduce(N_Vector X, sunindextype local_length,
                                  int myid);

/* XBraid interface operations */
int Test_N_VBufSize(N_Vector x, sunindextype local_length, int myid);
int Test_N_VBufPack(N_Vector x, sunindextype local_length, int myid);
int Test_N_VBufUnpack(N_Vector x, sunindextype local_length, int myid);

/* Enabled/disable operation timing */
void SetTiming(int onoff, int myid);

#ifdef __cplusplus
}
#endif