File: petscvec_kokkos.hpp.html

package info (click to toggle)
petsc 3.23.1%2Bdfsg1-1exp1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 515,576 kB
  • sloc: ansic: 751,607; cpp: 51,542; python: 38,598; f90: 17,352; javascript: 3,493; makefile: 3,157; sh: 1,502; xml: 619; objc: 445; java: 13; csh: 1
file content (167 lines) | stat: -rw-r--r-- 19,300 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
157
158
159
160
161
162
163
164
165
166
167
<center><a href="https://gitlab.com/petsc/petsc/-/blob/966382dc56242773704ef5f5cee7aa2db3ebc577/include/petscvec_kokkos.hpp">Actual source code: petscvec_kokkos.hpp</a></center><br>

<html>
<head>
<title></title>
<meta name="generator" content="c2html 0.9.6">
<meta name="date" content="2025-04-30T18:14:50+00:00">
</head>

<body bgcolor="#FFFFFF">
<pre width=80>
<a name="line1">  1: </a><font color="#A020F0">#pragma once</font>

<a name="line3">  3: </a><font color="#A020F0">#include &lt;petscconf.h&gt;</font>

<a name="line5">  5: </a><font color="#B22222">/* SUBMANSEC = <a href="../manualpages/Vec/Vec.html">Vec</a> */</font>

<a name="line7">  7: </a><font color="#A020F0">#if defined(PETSC_HAVE_KOKKOS)</font>
<a name="line8">  8: </a><font color="#A020F0">  #if defined(petsccomplexlib)</font>
<a name="line9">  9: </a><font color="#A020F0">    #error </font><font color="#666666">"Error: You must include petscvec_kokkos.hpp before other PETSc headers in this C++ file to use <a href="../manualpages/Sys/PetscComplex.html">PetscComplex</a> with Kokkos"</font><font color="#A020F0"></font>
<a name="line10"> 10: </a><font color="#A020F0">  #endif</font>

<a name="line12"> 12: </a><strong><font color="#228B22">  #define PETSC_DESIRE_KOKKOS_COMPLEX 1 </font><font color="#B22222">/* To control the definition of petsccomplexlib in petscsystypes.h */</font><font color="#228B22"></font></strong>
<a name="line13"> 13: </a><font color="#A020F0">#endif</font>

<a name="line15"> 15: </a>#include <A href="../include/petscvec.h.html">&lt;petscvec.h&gt;</A>

<a name="line17"> 17: </a><font color="#A020F0">#if defined(PETSC_HAVE_KOKKOS)</font>
<a name="line18"> 18: </a><font color="#A020F0">  #include &lt;Kokkos_Core.hpp&gt;</font>

<a name="line20"> 20: </a><font color="#B22222">/*@C</font>
<a name="line21"> 21: </a><font color="#B22222">     <a href="../manualpages/Vec/VecGetKokkosView.html">VecGetKokkosView</a> - Returns a constant Kokkos View that contains up-to-date data of a vector in the specified memory space.</font>

<a name="line23"> 23: </a><font color="#B22222">   Synopsis:</font>
<a name="line24"> 24: </a>#include <A href="../include/petscvec_kokkos.hpp.html">&lt;petscvec_kokkos.hpp&gt;</A>
<a name="line25"> 25: </a><font color="#B22222">   <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> <a href="../manualpages/Vec/VecGetKokkosView.html">VecGetKokkosView</a>  (<a href="../manualpages/Vec/Vec.html">Vec</a> v,Kokkos::View&lt;const <a href="../manualpages/Sys/PetscScalar.html">PetscScalar</a>*,MemorySpace&gt;* kv);</font>
<a name="line26"> 26: </a><font color="#B22222">   <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> <a href="../manualpages/Vec/VecGetKokkosView.html">VecGetKokkosView</a>  (<a href="../manualpages/Vec/Vec.html">Vec</a> v,Kokkos::View&lt;<a href="../manualpages/Sys/PetscScalar.html">PetscScalar</a>*,MemorySpace&gt;* kv);</font>

<a name="line28"> 28: </a><font color="#B22222">   Logically Collective, No Fortran Support</font>

<a name="line30"> 30: </a><font color="#B22222">   Input Parameter:</font>
<a name="line31"> 31: </a><font color="#B22222">.  v - the vector in type of `<a href="../manualpages/Vec/VECKOKKOS.html">VECKOKKOS</a>`</font>

<a name="line33"> 33: </a><font color="#B22222">   Output Parameter:</font>
<a name="line34"> 34: </a><font color="#B22222">.  kv - the Kokkos View with a user-specified template parameter MemorySpace</font>

<a name="line36"> 36: </a><font color="#B22222">   Level: beginner</font>

<a name="line38"> 38: </a><font color="#B22222">   Notes:</font>
<a name="line39"> 39: </a><font color="#B22222">   If the vector is not of type `<a href="../manualpages/Vec/VECKOKKOS.html">VECKOKKOS</a>`, an error will be raised.</font>

<a name="line41"> 41: </a><font color="#B22222">   The functions are similar to `<a href="../manualpages/Vec/VecGetArrayRead.html">VecGetArrayRead</a>()` and `<a href="../manualpages/Vec/VecGetArray.html">VecGetArray</a>()` respectively. One can read-only or read/write the returned Kokkos View.</font>

<a name="line43"> 43: </a><font color="#B22222">   Passing in a const View enables read-only access.</font>

<a name="line45"> 45: </a><font color="#B22222">   One must return the View by a matching `<a href="../manualpages/Vec/VecRestoreKokkosView.html">VecRestoreKokkosView</a>()` after finishing using the View. Currently, only two memory</font>
<a name="line46"> 46: </a><font color="#B22222">   spaces are supported: HostMirrorMemorySpace and Kokkos::DefaultExecutionSpace::memory_space.</font>
<a name="line47"> 47: </a><font color="#B22222">   If needed, a memory copy will be internally called to copy the latest vector data to the specified memory space.</font>

<a name="line49"> 49: </a><font color="#B22222">.seealso: `<a href="../manualpages/Vec/VecRestoreKokkosView.html">VecRestoreKokkosView</a>()`, `<a href="../manualpages/Vec/VecRestoreArray.html">VecRestoreArray</a>()`, `<a href="../manualpages/Vec/VecGetKokkosViewWrite.html">VecGetKokkosViewWrite</a>()`, `<a href="../manualpages/Vec/VecGetArrayRead.html">VecGetArrayRead</a>()`, `<a href="../manualpages/Vec/VecGetArrays.html">VecGetArrays</a>()`, `<a href="../manualpages/Vec/VecPlaceArray.html">VecPlaceArray</a>()`, `<a href="../manualpages/Vec/VecGetArray2d.html">VecGetArray2d</a>()`,</font>
<a name="line50"> 50: </a><font color="#B22222">          `<a href="../manualpages/Vec/VecGetArrayPair.html">VecGetArrayPair</a>()`, `<a href="../manualpages/Vec/VecRestoreArrayPair.html">VecRestoreArrayPair</a>()`, `<a href="../manualpages/Vec/VecGetArrayWrite.html">VecGetArrayWrite</a>()`, `<a href="../manualpages/Vec/VecRestoreArrayWrite.html">VecRestoreArrayWrite</a>()`</font>
<a name="line51"> 51: </a><font color="#B22222">@*/</font>
<a name="line52"> 52: </a>template &lt;class MemorySpace&gt;
<a name="line53"> 53: </a><a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> <a href="../manualpages/Vec/VecGetKokkosView.html">VecGetKokkosView</a>(<a href="../manualpages/Vec/Vec.html">Vec</a>, Kokkos::View&lt;const <a href="../manualpages/Sys/PetscScalar.html">PetscScalar</a> *, MemorySpace&gt; *);
<a name="line54"> 54: </a>template &lt;class MemorySpace&gt;
<a name="line55"> 55: </a><a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> <a href="../manualpages/Vec/VecGetKokkosView.html">VecGetKokkosView</a>(<a href="../manualpages/Vec/Vec.html">Vec</a>, Kokkos::View&lt;<a href="../manualpages/Sys/PetscScalar.html">PetscScalar</a> *, MemorySpace&gt; *);

<a name="line57"> 57: </a><font color="#B22222">/*@C</font>
<a name="line58"> 58: </a><font color="#B22222">   <a href="../manualpages/Vec/VecRestoreKokkosView.html">VecRestoreKokkosView</a> - Returns a Kokkos View gotten by `<a href="../manualpages/Vec/VecGetKokkosView.html">VecGetKokkosView</a>()`.</font>

<a name="line60"> 60: </a><font color="#B22222">   Synopsis:</font>
<a name="line61"> 61: </a>#include <A href="../include/petscvec_kokkos.hpp.html">&lt;petscvec_kokkos.hpp&gt;</A>
<a name="line62"> 62: </a><font color="#B22222">   <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> <a href="../manualpages/Vec/VecRestoreKokkosView.html">VecRestoreKokkosView</a>  (<a href="../manualpages/Vec/Vec.html">Vec</a> v,Kokkos::View&lt;const <a href="../manualpages/Sys/PetscScalar.html">PetscScalar</a>*,MemorySpace&gt;* kv);</font>
<a name="line63"> 63: </a><font color="#B22222">   <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> <a href="../manualpages/Vec/VecRestoreKokkosView.html">VecRestoreKokkosView</a>  (<a href="../manualpages/Vec/Vec.html">Vec</a> v,Kokkos::View&lt;<a href="../manualpages/Sys/PetscScalar.html">PetscScalar</a>*,MemorySpace&gt;* kv);</font>

<a name="line65"> 65: </a><font color="#B22222">   Logically Collective, No Fortran Support</font>

<a name="line67"> 67: </a><font color="#B22222">   Input Parameters:</font>
<a name="line68"> 68: </a><font color="#B22222">+  v  - the vector in type of `<a href="../manualpages/Vec/VECKOKKOS.html">VECKOKKOS</a>`</font>
<a name="line69"> 69: </a><font color="#B22222">-  kv - the Kokkos View with a user-specified template parameter MemorySpace</font>

<a name="line71"> 71: </a><font color="#B22222">   Level: beginner</font>

<a name="line73"> 73: </a><font color="#B22222">   Note:</font>
<a name="line74"> 74: </a><font color="#B22222">   If the vector is not of type `<a href="../manualpages/Vec/VECKOKKOS.html">VECKOKKOS</a>`, an error will be raised.</font>
<a name="line75"> 75: </a><font color="#B22222">   The functions are similar to `<a href="../manualpages/Vec/VecRestoreArrayRead.html">VecRestoreArrayRead</a>()` and `<a href="../manualpages/Vec/VecRestoreArray.html">VecRestoreArray</a>()` respectively. They are the counterpart of `<a href="../manualpages/Vec/VecGetKokkosView.html">VecGetKokkosView</a>()`.</font>

<a name="line77"> 77: </a><font color="#B22222">.seealso: `<a href="../manualpages/Vec/VecGetKokkosView.html">VecGetKokkosView</a>()`, `<a href="../manualpages/Vec/VecRestoreKokkosViewWrite.html">VecRestoreKokkosViewWrite</a>()`, `<a href="../manualpages/Vec/VecRestoreArray.html">VecRestoreArray</a>()`, `<a href="../manualpages/Vec/VecGetArrayRead.html">VecGetArrayRead</a>()`, `<a href="../manualpages/Vec/VecGetArrays.html">VecGetArrays</a>()`, `<a href="../manualpages/Vec/VecPlaceArray.html">VecPlaceArray</a>()`, `<a href="../manualpages/Vec/VecGetArray2d.html">VecGetArray2d</a>()`,</font>
<a name="line78"> 78: </a><font color="#B22222">          `<a href="../manualpages/Vec/VecGetArrayPair.html">VecGetArrayPair</a>()`, `<a href="../manualpages/Vec/VecRestoreArrayPair.html">VecRestoreArrayPair</a>()`, `<a href="../manualpages/Vec/VecGetArrayWrite.html">VecGetArrayWrite</a>()`, `<a href="../manualpages/Vec/VecRestoreArrayWrite.html">VecRestoreArrayWrite</a>()`</font>
<a name="line79"> 79: </a><font color="#B22222">@*/</font>
<a name="line80"> 80: </a>template &lt;class MemorySpace&gt;
<a name="line81"> 81: </a><a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> <a href="../manualpages/Vec/VecRestoreKokkosView.html">VecRestoreKokkosView</a>(<a href="../manualpages/Vec/Vec.html">Vec</a>, Kokkos::View&lt;const <a href="../manualpages/Sys/PetscScalar.html">PetscScalar</a> *, MemorySpace&gt; *)
<a name="line82"> 82: </a>{
<a name="line83"> 83: </a>  <font color="#4169E1">return</font> <a href="../manualpages/Sys/PetscErrorCode.html">PETSC_SUCCESS</a>;
<a name="line84"> 84: </a>}
<a name="line85"> 85: </a>template &lt;class MemorySpace&gt;
<a name="line86"> 86: </a><a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> <a href="../manualpages/Vec/VecRestoreKokkosView.html">VecRestoreKokkosView</a>(<a href="../manualpages/Vec/Vec.html">Vec</a>, Kokkos::View&lt;<a href="../manualpages/Sys/PetscScalar.html">PetscScalar</a> *, MemorySpace&gt; *);

<a name="line88"> 88: </a><font color="#B22222">/*@C</font>
<a name="line89"> 89: </a><font color="#B22222">   <a href="../manualpages/Vec/VecGetKokkosViewWrite.html">VecGetKokkosViewWrite</a> - Returns a Kokkos View that contains the array of a vector in the specified memory space.</font>

<a name="line91"> 91: </a><font color="#B22222">   Synopsis:</font>
<a name="line92"> 92: </a>#include <A href="../include/petscvec_kokkos.hpp.html">&lt;petscvec_kokkos.hpp&gt;</A>
<a name="line93"> 93: </a><font color="#B22222">   <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> <a href="../manualpages/Vec/VecGetKokkosViewWrite.html">VecGetKokkosViewWrite</a>  (<a href="../manualpages/Vec/Vec.html">Vec</a> v,Kokkos::View&lt;<a href="../manualpages/Sys/PetscScalar.html">PetscScalar</a>*,MemorySpace&gt;* kv);</font>

<a name="line95"> 95: </a><font color="#B22222">   Logically Collective, No Fortran Support</font>

<a name="line97"> 97: </a><font color="#B22222">   Input Parameter:</font>
<a name="line98"> 98: </a><font color="#B22222">.  v - the vector in type of `<a href="../manualpages/Vec/VECKOKKOS.html">VECKOKKOS</a>`</font>

<a name="line100">100: </a><font color="#B22222">   Output Parameter:</font>
<a name="line101">101: </a><font color="#B22222">.  kv - the Kokkos View with a user-specified template parameter MemorySpace</font>

<a name="line103">103: </a><font color="#B22222">   Level: beginner</font>

<a name="line105">105: </a><font color="#B22222">   Notes:</font>
<a name="line106">106: </a><font color="#B22222">   If the vector is not of type `<a href="../manualpages/Vec/VECKOKKOS.html">VECKOKKOS</a>`, an error will be raised.</font>

<a name="line108">108: </a><font color="#B22222">   The functions is similar to `<a href="../manualpages/Vec/VecGetArrayWrite.html">VecGetArrayWrite</a>()`. The returned view might contain garbage data or stale data and one is not</font>
<a name="line109">109: </a><font color="#B22222">   expected to read data from the View. Instead, one is expected to overwrite all data in the View.</font>
<a name="line110">110: </a><font color="#B22222">   One must return the View by a matching `<a href="../manualpages/Vec/VecRestoreKokkosViewWrite.html">VecRestoreKokkosViewWrite</a>()` after finishing using the View.</font>

<a name="line112">112: </a><font color="#B22222">   Currently, only two memory spaces are supported: HostMirrorMemorySpace and Kokkos::DefaultExecutionSpace::memory_space.</font>

<a name="line114">114: </a><font color="#B22222">.seealso: `<a href="../manualpages/Vec/VecRestoreKokkosViewWrite.html">VecRestoreKokkosViewWrite</a>()`, `<a href="../manualpages/Vec/VecRestoreKokkosView.html">VecRestoreKokkosView</a>()`, `<a href="../manualpages/Vec/VecGetKokkosView.html">VecGetKokkosView</a>()`, `<a href="../manualpages/Vec/VecRestoreArray.html">VecRestoreArray</a>()`, `<a href="../manualpages/Vec/VecGetArrayRead.html">VecGetArrayRead</a>()`, `<a href="../manualpages/Vec/VecGetArrays.html">VecGetArrays</a>()`, `<a href="../manualpages/Vec/VecPlaceArray.html">VecPlaceArray</a>()`, `<a href="../manualpages/Vec/VecGetArray2d.html">VecGetArray2d</a>()`,</font>
<a name="line115">115: </a><font color="#B22222">          `<a href="../manualpages/Vec/VecGetArrayPair.html">VecGetArrayPair</a>()`, `<a href="../manualpages/Vec/VecRestoreArrayPair.html">VecRestoreArrayPair</a>()`, `<a href="../manualpages/Vec/VecGetArrayWrite.html">VecGetArrayWrite</a>()`, `<a href="../manualpages/Vec/VecRestoreArrayWrite.html">VecRestoreArrayWrite</a>()`</font>
<a name="line116">116: </a><font color="#B22222">@*/</font>
<a name="line117">117: </a>template &lt;class MemorySpace&gt;
<a name="line118">118: </a><a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> <a href="../manualpages/Vec/VecGetKokkosViewWrite.html">VecGetKokkosViewWrite</a>(<a href="../manualpages/Vec/Vec.html">Vec</a>, Kokkos::View&lt;<a href="../manualpages/Sys/PetscScalar.html">PetscScalar</a> *, MemorySpace&gt; *);

<a name="line120">120: </a><font color="#B22222">/*@C</font>
<a name="line121">121: </a><font color="#B22222">   <a href="../manualpages/Vec/VecRestoreKokkosViewWrite.html">VecRestoreKokkosViewWrite</a> - Returns a Kokkos View gotten with `<a href="../manualpages/Vec/VecGetKokkosViewWrite.html">VecGetKokkosViewWrite</a>()`.</font>

<a name="line123">123: </a><font color="#B22222">   Synopsis:</font>
<a name="line124">124: </a>#include <A href="../include/petscvec_kokkos.hpp.html">&lt;petscvec_kokkos.hpp&gt;</A>
<a name="line125">125: </a><font color="#B22222">   <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> <a href="../manualpages/Vec/VecRestoreKokkosViewWrite.html">VecRestoreKokkosViewWrite</a>  (<a href="../manualpages/Vec/Vec.html">Vec</a> v,Kokkos::View&lt;<a href="../manualpages/Sys/PetscScalar.html">PetscScalar</a>*,MemorySpace&gt;* kv);</font>

<a name="line127">127: </a><font color="#B22222">   Logically Collective, No Fortran Support</font>

<a name="line129">129: </a><font color="#B22222">   Input Parameters:</font>
<a name="line130">130: </a><font color="#B22222">+  v  - the vector in type of `<a href="../manualpages/Vec/VECKOKKOS.html">VECKOKKOS</a>`</font>
<a name="line131">131: </a><font color="#B22222">-  kv - the Kokkos View with a user-specified template parameter MemorySpace</font>

<a name="line133">133: </a><font color="#B22222">   Level: beginner</font>

<a name="line135">135: </a><font color="#B22222">   Notes:</font>
<a name="line136">136: </a><font color="#B22222">   If the vector is not of type `<a href="../manualpages/Vec/VECKOKKOS.html">VECKOKKOS</a>`, an error will be raised.</font>

<a name="line138">138: </a><font color="#B22222">   The function is similar to `<a href="../manualpages/Vec/VecRestoreArrayWrite.html">VecRestoreArrayWrite</a>()`. It is the counterpart of `<a href="../manualpages/Vec/VecGetKokkosViewWrite.html">VecGetKokkosViewWrite</a>()`.</font>

<a name="line140">140: </a><font color="#B22222">.seealso: `<a href="../manualpages/Vec/VecGetKokkosViewWrite.html">VecGetKokkosViewWrite</a>()`, `<a href="../manualpages/Vec/VecGetKokkosView.html">VecGetKokkosView</a>()`, `<a href="../manualpages/Vec/VecGetKokkosView.html">VecGetKokkosView</a>()`, `<a href="../manualpages/Vec/VecRestoreArray.html">VecRestoreArray</a>()`, `<a href="../manualpages/Vec/VecGetArrayRead.html">VecGetArrayRead</a>()`, `<a href="../manualpages/Vec/VecGetArrays.html">VecGetArrays</a>()`, `<a href="../manualpages/Vec/VecPlaceArray.html">VecPlaceArray</a>()`, `<a href="../manualpages/Vec/VecGetArray2d.html">VecGetArray2d</a>()`,</font>
<a name="line141">141: </a><font color="#B22222">          `<a href="../manualpages/Vec/VecGetArrayPair.html">VecGetArrayPair</a>()`, `<a href="../manualpages/Vec/VecRestoreArrayPair.html">VecRestoreArrayPair</a>()`, `<a href="../manualpages/Vec/VecGetArrayWrite.html">VecGetArrayWrite</a>()`, `<a href="../manualpages/Vec/VecRestoreArrayWrite.html">VecRestoreArrayWrite</a>()`</font>
<a name="line142">142: </a><font color="#B22222">@*/</font>
<a name="line143">143: </a>template &lt;class MemorySpace&gt;
<a name="line144">144: </a><a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> <a href="../manualpages/Vec/VecRestoreKokkosViewWrite.html">VecRestoreKokkosViewWrite</a>(<a href="../manualpages/Vec/Vec.html">Vec</a>, Kokkos::View&lt;<a href="../manualpages/Sys/PetscScalar.html">PetscScalar</a> *, MemorySpace&gt; *);

<a name="line146">146: </a><font color="#A020F0">  #if defined(PETSC_HAVE_COMPLEX) &amp;&amp; defined(PETSC_USE_COMPLEX)</font>
<a name="line147">147: </a>static_assert(std::alignment_of&lt;Kokkos::complex&lt;<a href="../manualpages/Sys/PetscReal.html">PetscReal</a>&gt;&gt;::value == std::alignment_of&lt;std::complex&lt;<a href="../manualpages/Sys/PetscReal.html">PetscReal</a>&gt;&gt;::value,
<a name="line148">148: </a>              <font color="#666666">"Alignment of Kokkos::complex&lt;<a href="../manualpages/Sys/PetscReal.html">PetscReal</a>&gt; and std::complex&lt;<a href="../manualpages/Sys/PetscReal.html">PetscReal</a>&gt; mismatch. Reconfigure your Kokkos with -DKOKKOS_ENABLE_COMPLEX_ALIGN=OFF, or let PETSc install Kokkos for you with --download-kokkos --download-kokkos-kernels"</font>);
<a name="line149">149: </a><font color="#A020F0">  #endif</font>

<a name="line151">151: </a><font color="#A020F0">#endif</font>
</pre>
</body>

</html>