xref: /libCEED/tests/t102-vector.c (revision ba59ac12ef3579eea938de09e332a3a266c3cc08)
1 /// @file
2 /// Test CeedVectorGetArrayRead state counter
3 /// \test Test CeedVectorGetArrayRead state counter
4 #include <ceed.h>
5 
6 int main(int argc, char **argv) {
7   Ceed       ceed;
8   CeedVector x;
9   CeedInt    len = 10;
10 
11   CeedInit(argv[1], &ceed);
12 
13   CeedVectorCreate(ceed, len, &x);
14   CeedVectorSetValue(x, 0.0);
15 
16   // Two read accesses should not generate an error
17   {
18     const CeedScalar *a, *b;
19 
20     CeedVectorGetArrayRead(x, CEED_MEM_HOST, &a);
21     CeedVectorGetArrayRead(x, CEED_MEM_HOST, &b);
22 
23     CeedVectorRestoreArrayRead(x, &a);
24     CeedVectorRestoreArrayRead(x, &b);
25   }
26 
27   CeedVectorDestroy(&x);
28   CeedDestroy(&ceed);
29   return 0;
30 }
31