Neko 1.99.9
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
mxm_wrapper.F90
Go to the documentation of this file.
1
3 use num_types, only : rp, sp, dp, qp
4 use utils, only : neko_error
5#ifdef HAVE_LIBXSMM
6 use libxsmm, only : libxsmm_available, libxsmm_dispatch, &
7 libxsmm_dmmcall_abc, libxsmm_dmmfunction, libxsmm_smmcall_abc, &
8 libxsmm_smmfunction, libxsmm_prefetch
9#endif
10 implicit none
11 private
12
13 public :: mxm
14
15 interface mxm_blas
16 module procedure mxm_blas_sp, mxm_blas_dp
17#ifdef HAVE_REAL128
18 module procedure mxm_blas_qp
19#endif
20 end interface mxm_blas
21
22 interface mxm_libxsmm
23 module procedure mxm_libxsmm_sp, mxm_libxsmm_dp
24#ifdef HAVE_REAL128
25 module procedure mxm_libxsmm_qp
26#endif
27 end interface mxm_libxsmm
28
29 private :: mxm_blas_sp, mxm_blas_dp
31#ifdef HAVE_REAL128
32 private :: mxm_blas_qp, mxm_libxsmm_qp
33#endif
34
35contains
36
39 subroutine mxm(a, n1, b, n2, c, n3)
40 integer, intent(in) :: n1, n2, n3
41 real(kind=rp), intent(in) :: a(n1, n2)
42 real(kind=rp), intent(in) :: b(n2, n3)
43 real(kind=rp), intent(inout) :: c(n1, n3)
44
45#ifdef HAVE_LIBXSMM
46 call mxm_libxsmm(a, n1, b, n2, c, n3)
47#else
48 call mxm_blas(a, n1, b, n2, c, n3)
49#endif
50
51 end subroutine mxm
52
53 subroutine mxm_blas_sp(a, n1, b, n2, c, n3)
54 integer, intent(in) :: n1, n2, n3
55 real(kind=sp), intent(in) :: a(n1, n2)
56 real(kind=sp), intent(in) :: b(n2, n3)
57 real(kind=sp), intent(inout) :: c(n1, n3)
58
59 call sgemm('N', 'N', n1, n3, n2, 1.0, a, n1, b, n2, 0.0, c, n1)
60
61 end subroutine mxm_blas_sp
62
63 subroutine mxm_blas_dp(a, n1, b, n2, c, n3)
64 integer, intent(in) :: n1, n2, n3
65 real(kind=dp), intent(in) :: a(n1, n2)
66 real(kind=dp), intent(in) :: b(n2, n3)
67 real(kind=dp), intent(inout) :: c(n1, n3)
68
69 call dgemm('N', 'N', n1, n3, n2, 1d0, a, n1, b, n2, 0d0, c, n1)
70
71 end subroutine mxm_blas_dp
72
73#ifdef HAVE_REAL128
74 subroutine mxm_blas_qp(a, n1, b, n2, c, n3)
75 integer, intent(in) :: n1, n2, n3
76 real(kind=qp), intent(in) :: a(n1, n2)
77 real(kind=qp), intent(in) :: b(n2, n3)
78 real(kind=qp), intent(inout) :: c(n1, n3)
79
80 call neko_error('Not implemented yet!')
81
82 end subroutine mxm_blas_qp
83#endif
84
85 subroutine mxm_libxsmm_sp(a, n1, b, n2, c, n3)
86 integer, intent(in) :: n1, n2, n3
87 real(kind=sp), intent(in) :: a(n1, n2)
88 real(kind=sp), intent(in) :: b(n2, n3)
89 real(kind=sp), intent(inout) :: c(n1, n3)
90#ifdef HAVE_LIBXSMM
91 type(libxsmm_smmfunction) :: xmm
92
93 call libxsmm_dispatch(xmm, n1, n3, n2, &
94 alpha = 1.0, beta = 0.0, prefetch = libxsmm_prefetch)
95 if (libxsmm_available(xmm)) then
96 call libxsmm_smmcall_abc(xmm, a, b, c)
97 return
98 end if
99#endif
100 end subroutine mxm_libxsmm_sp
101
102 subroutine mxm_libxsmm_dp(a, n1, b, n2, c, n3)
103 integer, intent(in) :: n1, n2, n3
104 real(kind=dp), intent(in) :: a(n1, n2)
105 real(kind=dp), intent(in) :: b(n2, n3)
106 real(kind=dp), intent(inout) :: c(n1, n3)
107#ifdef HAVE_LIBXSMM
108 type(libxsmm_dmmfunction) :: xmm
109
110 call libxsmm_dispatch(xmm, n1, n3, n2, &
111 alpha = 1d0, beta = 0d0, prefetch = libxsmm_prefetch)
112 if (libxsmm_available(xmm)) then
113 call libxsmm_dmmcall_abc(xmm, a, b, c)
114 return
115 end if
116#endif
117 end subroutine mxm_libxsmm_dp
118
119#ifdef HAVE_REAL128
120 subroutine mxm_libxsmm_qp(a, n1, b, n2, c, n3)
121 integer, intent(in) :: n1, n2, n3
122 real(kind=qp), intent(in) :: a(n1, n2)
123 real(kind=qp), intent(in) :: b(n2, n3)
124 real(kind=qp), intent(inout) :: c(n1, n3)
125
126 call neko_error('Not implemented yet!')
127
128 end subroutine mxm_libxsmm_qp
129#endif
130
131end module mxm_wrapper
Wrapper for all matrix-matrix product implementations.
subroutine, private mxm_blas_sp(a, n1, b, n2, c, n3)
subroutine, private mxm_libxsmm_dp(a, n1, b, n2, c, n3)
subroutine, private mxm_blas_dp(a, n1, b, n2, c, n3)
subroutine, private mxm_libxsmm_sp(a, n1, b, n2, c, n3)
subroutine, public mxm(a, n1, b, n2, c, n3)
Compute matrix-matrix product for contiguously packed matrices A,B, and C.
integer, parameter, public qp
Definition num_types.f90:12
integer, parameter, public dp
Definition num_types.f90:10
integer, parameter, public sp
Definition num_types.f90:8
integer, parameter, public rp
Global precision used in computations.
Definition num_types.f90:14
Utilities.
Definition utils.f90:35