Neko 0.9.99
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
tensor_xsmm.F90
Go to the documentation of this file.
1! Copyright (c) 2008-2020, UCHICAGO ARGONNE, LLC.
2!
3! The UChicago Argonne, LLC as Operator of Argonne National
4! Laboratory holds copyright in the Software. The copyright holder
5! reserves all rights except those expressly granted to licensees,
6! and U.S. Government license rights.
7!
8! Redistribution and use in source and binary forms, with or without
9! modification, are permitted provided that the following conditions
10! are met:
11!
12! 1. Redistributions of source code must retain the above copyright
13! notice, this list of conditions and the disclaimer below.
14!
15! 2. Redistributions in binary form must reproduce the above copyright
16! notice, this list of conditions and the disclaimer (as noted below)
17! in the documentation and/or other materials provided with the
18! distribution.
19!
20! 3. Neither the name of ANL nor the names of its contributors
21! may be used to endorse or promote products derived from this software
22! without specific prior written permission.
23!
24! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25! "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
27! FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
28! UCHICAGO ARGONNE, LLC, THE U.S. DEPARTMENT OF
29! ENERGY OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30! SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
31! TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33! THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34! (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35! OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36!
37! Additional BSD Notice
38! ---------------------
39! 1. This notice is required to be provided under our contract with
40! the U.S. Department of Energy (DOE). This work was produced at
41! Argonne National Laboratory under Contract
42! No. DE-AC02-06CH11357 with the DOE.
43!
44! 2. Neither the United States Government nor UCHICAGO ARGONNE,
45! LLC nor any of their employees, makes any warranty,
46! express or implied, or assumes any liability or responsibility for the
47! accuracy, completeness, or usefulness of any information, apparatus,
48! product, or process disclosed, or represents that its use would not
49! infringe privately-owned rights.
50!
51! 3. Also, reference herein to any specific commercial products, process,
52! or services by trade name, trademark, manufacturer or otherwise does
53! not necessarily constitute or imply its endorsement, recommendation,
54! or favoring by the United States Government or UCHICAGO ARGONNE LLC.
55! The views and opinions of authors expressed
56! herein do not necessarily state or reflect those of the United States
57! Government or UCHICAGO ARGONNE, LLC, and shall
58! not be used for advertising or product endorsement purposes.
59!
62 use num_types
63 use mxm_wrapper
64 implicit none
65 private
66
68
69contains
70
71 subroutine tnsr2d_el_xsmm(v, nv, u, nu, A, Bt)
72 integer, intent(in) :: nv, nu
73 real(kind=rp), intent(inout) :: v(nv*nv), u(nu*nu)
74 real(kind=rp), intent(inout) :: a(nv,nu), bt(nu,nv)
75 real(kind=rp) :: work(0:nu**2*nv)
76
77 call mxm(a, nv, u, nu, work, nu)
78 call mxm(work, nv, bt, nu, v, nv)
79
80 end subroutine tnsr2d_el_xsmm
81
82 subroutine tnsr3d_el_xsmm(v, nv, u, nu, A, Bt, Ct)
83 integer, intent(in) :: nv, nu
84 real(kind=rp), intent(inout) :: v(nv*nv*nv), u(nu*nu*nu)
85 real(kind=rp), intent(inout) :: a(nv,nu),bt(nu, nv),ct(nu,nv)
86 real(kind=rp) :: work(0:nu**2*nv), work2(0:nu*nv**2)
87 integer :: i, nunu, nvnu, nvnv
88
89 nvnu = nv * nu
90 nunu = nu * nu
91 nvnv = nv * nv
92
93 call mxm(a, nv, u(1), nu ,work, nunu)
94 do i = 0,nu-1
95 call mxm(work(nvnu*i), nv, bt, nu, work2(nv*nv*i), nv)
96 end do
97 call mxm(work2, nvnv, ct, nu, v(1), nv)
98
99 end subroutine tnsr3d_el_xsmm
100
101 subroutine tnsr3d_xsmm(v, nv, u, nu, A, Bt, Ct, nelv)
102 integer, intent(in) :: nv, nu, nelv
103 real(kind=rp), intent(inout) :: v(nv*nv*nv,nelv)
104 real(kind=rp), intent(in) :: u(nu*nu*nu,nelv)
105 real(kind=rp), intent(in) :: a(nv,nu), bt(nu, nv), ct(nu,nv)
106 real(kind=rp) :: work(0:nu**2*nv), work2(0:nu*nv**2)
107 integer :: ie, i, nunu, nvnu, nvnv
108
109 nvnu = nv * nu
110 nunu = nu * nu
111 nvnv = nv * nv
112
113 do ie = 1,nelv
114 call mxm(a, nv, u(1,ie), nu, work, nunu)
115 do i = 0,nu-1
116 call mxm(work(nvnu*i), nv, bt, nu, work2(nv*nv*i), nv)
117 end do
118 call mxm(work2, nvnv, ct, nu, v(1,ie), nv)
119 end do
120
121 end subroutine tnsr3d_xsmm
122
123 subroutine tnsr1_3d_xsmm(v, nv, nu, A, Bt, Ct, nelv)
124 integer, intent(in) :: nv, nu, nelv
125 real(kind=rp), intent(inout) :: v(nv*nv*nv*nelv)
126 real(kind=rp), intent(inout) :: a(nv,nu), bt(nu, nv), ct(nu,nv)
127 real(kind=rp) :: work(0:nu**2*nv), work2(0:nu*nv**2)
128 integer :: e, e0, ee, es, iu, iv, i, nu3, nv3
129
130 e0 = 1
131 es = 1
132 ee = nelv
133
134 if (nv.gt.nu) then
135 e0 = nelv
136 es = -1
137 ee = 1
138 endif
139
140 nu3 = nu**3
141 nv3 = nv**3
142
143 do e = e0,ee,es
144 iu = 1 + (e-1)*nu3
145 iv = 1 + (e-1)*nv3
146 call mxm(a, nv, v(iu), nu, work, nu*nu)
147 do i = 0,nu-1
148 call mxm(work(nv*nu*i), nv, bt, nu, work2(nv*nv*i), nv)
149 end do
150 call mxm(work2, nv*nv, ct, nu, v(iv), nv)
151 end do
152 end subroutine tnsr1_3d_xsmm
153
154end module tensor_xsmm
Wrapper for all matrix-matrix product implementations.
subroutine, public mxm(a, n1, b, n2, c, n3)
Compute matrix-matrix product for contiguously packed matrices A,B, and C.
integer, parameter, public rp
Global precision used in computations.
Definition num_types.f90:12
Tensor operations libxsmm backend.
subroutine, public tnsr3d_el_xsmm(v, nv, u, nu, a, bt, ct)
subroutine, public tnsr3d_xsmm(v, nv, u, nu, a, bt, ct, nelv)
subroutine, public tnsr2d_el_xsmm(v, nv, u, nu, a, bt)
subroutine, public tnsr1_3d_xsmm(v, nv, nu, a, bt, ct, nelv)