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