Skip to content

Commit 1ee6d08

Browse files
authored
Merge pull request #1729 from fenrus75/dscal
Add an AVX512 enabled DSCAL function
2 parents a95a784 + cacacc8 commit 1ee6d08

File tree

2 files changed

+80
-1
lines changed

2 files changed

+80
-1
lines changed

kernel/x86_64/dscal.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3131
#include "dscal_microk_bulldozer-2.c"
3232
#elif defined(SANDYBRIDGE)
3333
#include "dscal_microk_sandy-2.c"
34-
#elif defined(HASWELL) || defined(ZEN) || defined (SKYLAKEX)
34+
#elif defined(HASWELL) || defined(ZEN)
3535
#include "dscal_microk_haswell-2.c"
36+
#elif defined (SKYLAKEX)
37+
#include "dscal_microk_skylakex-2.c"
3638
#endif
3739

3840

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/***************************************************************************
2+
Copyright (c) 2014-2015, The OpenBLAS Project
3+
All rights reserved.
4+
Redistribution and use in source and binary forms, with or without
5+
modification, are permitted provided that the following conditions are
6+
met:
7+
1. Redistributions of source code must retain the above copyright
8+
notice, this list of conditions and the following disclaimer.
9+
2. Redistributions in binary form must reproduce the above copyright
10+
notice, this list of conditions and the following disclaimer in
11+
the documentation and/or other materials provided with the
12+
distribution.
13+
3. Neither the name of the OpenBLAS project nor the names of
14+
its contributors may be used to endorse or promote products
15+
derived from this software without specific prior written permission.
16+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19+
ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBLAS PROJECT OR CONTRIBUTORS BE
20+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
25+
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26+
*****************************************************************************/
27+
28+
/* need a new enough GCC for avx512 support */
29+
#if (( defined(__GNUC__) && __GNUC__ > 6 && defined(__AVX2__)) || (defined(__clang__) && __clang_major__ >= 6))
30+
31+
#include <immintrin.h>
32+
33+
#define HAVE_KERNEL_8 1
34+
35+
static void dscal_kernel_8( BLASLONG n, FLOAT *alpha, FLOAT *x)
36+
{
37+
int i = 0;
38+
39+
#ifdef __AVX512CD__
40+
__m512d __alpha5 = _mm512_broadcastsd_pd(_mm_load_sd(alpha));
41+
for (; i < n; i += 8) {
42+
_mm512_storeu_pd(&x[i + 0], __alpha5 * _mm512_loadu_pd(&x[i + 0]));
43+
}
44+
#else
45+
__m256d __alpha = _mm256_broadcastsd_pd(_mm_load_sd(alpha));
46+
for (; i < n; i += 8) {
47+
_mm256_storeu_pd(&x[i + 0], __alpha * _mm256_loadu_pd(&x[i + 0]));
48+
_mm256_storeu_pd(&x[i + 4], __alpha * _mm256_loadu_pd(&x[i + 4]));
49+
}
50+
#endif
51+
}
52+
53+
54+
static void dscal_kernel_8_zero( BLASLONG n, FLOAT *alpha, FLOAT *x)
55+
{
56+
int i = 0;
57+
58+
/* question to self: Why is this not just memset() */
59+
60+
#ifdef __AVX512CD__
61+
__m512d zero = _mm512_setzero_pd();
62+
for (; i < n; i += 8) {
63+
_mm512_storeu_pd(&x[i], zero);
64+
}
65+
#else
66+
__m256d zero = _mm256_setzero_pd();
67+
for (; i < n; i += 8) {
68+
_mm256_storeu_pd(&x[i + 0], zero);
69+
_mm256_storeu_pd(&x[i + 4], zero);
70+
}
71+
#endif
72+
73+
}
74+
75+
#else
76+
#include "dscal_microk_haswell-2.c"
77+
#endif

0 commit comments

Comments
 (0)