ergo
g_intrin.h
Go to the documentation of this file.
1/* Ergo, version 3.8, a program for linear scaling electronic structure
2 * calculations.
3 * Copyright (C) 2019 Elias Rudberg, Emanuel H. Rubensson, Pawel Salek,
4 * and Anastasia Kruchinina.
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 *
19 * Primary academic reference:
20 * Ergo: An open-source program for linear-scaling electronic structure
21 * calculations,
22 * Elias Rudberg, Emanuel H. Rubensson, Pawel Salek, and Anastasia
23 * Kruchinina,
24 * SoftwareX 7, 107 (2018),
25 * <http://dx.doi.org/10.1016/j.softx.2018.03.005>
26 *
27 * For further information about Ergo, see <http://www.ergoscf.org>.
28 */
29
39#ifndef G_INTRIN
40#define G_INTRIN
41#include <emmintrin.h>
42#ifdef __SSE3__
43#include <pmmintrin.h>
44#endif
45
46/* Interface to load functions. */
47
48/* load_p */
49template<typename Treal, typename Treg>
50 inline static Treg _mm_load_p (Treal const * ptr);
51
52inline static __m128 _mm_load_p (float const * ptr) {
53 return _mm_load_ps (ptr);
54}
55
56inline static __m128d _mm_load_p (double const * ptr) {
57 return _mm_load_pd (ptr);
58}
59
60/* load1_p */
61template<typename Treal, typename Treg>
62 inline static Treg _mm_load1_p (Treal const * ptr);
63
64inline static __m128 _mm_load1_p (float const * ptr) {
65 return _mm_load1_ps (ptr);
66}
67
68
69inline static __m128d _mm_load1_p (double const * ptr) {
70 return _mm_load1_pd (ptr);
71}
72
73/* set1_p */
74template<typename Treal, typename Treg>
75 inline static Treg _mm_set1_p (Treal const val);
76
77inline static __m128 _mm_set1_p (float const val) {
78 return _mm_set1_ps (val);
79}
80
81
82inline static __m128d _mm_set1_p (double const val) {
83 return _mm_set1_pd (val);
84}
85
86
87/* Interface to store functions. */
88template<typename Treal, typename Treg>
89 inline static void _mm_store_p (Treal * ptr, Treg A);
90
91inline static void _mm_store_p (float * ptr, __m128 A) {
92 _mm_store_ps (ptr, A);
93}
94
95inline static void _mm_store_p (double * ptr, __m128d A) {
96 _mm_store_pd (ptr, A);
97}
98
99
100/* Interface to add functions. */
101
102template<typename Treg>
103inline static Treg _mm_add_p (Treg A, Treg B);
104
105inline static __m128 _mm_add_p (__m128 A, __m128 B) {
106 return _mm_add_ps(A, B);
107}
108
109inline static __m128d _mm_add_p (__m128d A, __m128d B) {
110 return _mm_add_pd(A, B);
111}
112
113
114/* Interface to mul functions. */
115
116template<typename Treg>
117inline static Treg _mm_mul_p (Treg A, Treg B);
118
119inline static __m128 _mm_mul_p (__m128 A, __m128 B) {
120 return _mm_mul_ps(A, B);
121}
122
123inline static __m128d _mm_mul_p (__m128d A, __m128d B) {
124 return _mm_mul_pd(A, B);
125}
126
127/* pxor */
128
129template<typename Treg>
130inline static Treg _mm_xor_p (Treg A, Treg B);
131
132inline static __m128 _mm_xor_p (__m128 A, __m128 B) {
133 return _mm_xor_ps(A, B);
134}
135
136inline static __m128d _mm_xor_p (__m128d A, __m128d B) {
137 return _mm_xor_pd(A, B);
138}
139
140#endif
static Treg _mm_load1_p(Treal const *ptr)
static void _mm_store_p(Treal *ptr, Treg A)
static Treg _mm_load_p(Treal const *ptr)
static Treg _mm_xor_p(Treg A, Treg B)
static Treg _mm_add_p(Treg A, Treg B)
static Treg _mm_set1_p(Treal const val)
static Treg _mm_mul_p(Treg A, Treg B)
#define B
#define A