1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 ; Copyright(c) 2011-2015 Intel Corporation All rights reserved.
4 ; Redistribution and use in source and binary forms, with or without
5 ; modification, are permitted provided that the following conditions
7 ; * Redistributions of source code must retain the above copyright
8 ; notice, this list of conditions and the following disclaimer.
9 ; * 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
13 ; * Neither the name of Intel Corporation nor the names of its
14 ; contributors may be used to endorse or promote products derived
15 ; from this software without specific prior written permission.
17 ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 ; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 ; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 ; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 ; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 ; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 ; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 ; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 ; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 ; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 ; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
31 ;;; gf_vect_dot_prod_avx512(len, vec, *g_tbls, **buffs, *dest);
34 %include "reg_sizes.asm"
36 %ifdef HAVE_AS_KNOWS_AVX512
38 %ifidn __OUTPUT_FORMAT__, elf64
52 %define func(x) x: endbranch
57 %ifidn __OUTPUT_FORMAT__, win64
63 %define arg4 r12 ; must be saved, loaded and restored
64 %define arg5 r15 ; must be saved and restored
70 %define stack_size 0*16 + 3*8 ; must be an odd multiple of 8
71 %define arg(x) [rsp + stack_size + PS + PS*x]
73 %define func(x) proc_frame x
75 alloc_stack stack_size
92 %define mul_array arg2
100 %ifndef EC_ALIGNED_ADDR
101 ;;; Use Un-aligned load/store
102 %define XLDR vmovdqu8
103 %define XSTR vmovdqu8
105 ;;; Use Non-temporal load/stor
110 %define XLDR vmovntdqa
111 %define XSTR vmovntdq
116 %define xgft1_lo zmm4
117 %define xgft1_loy ymm4
118 %define xgft1_hi zmm3
120 %define xgft1_loy ymm4
131 mk_global gf_vect_dot_prod_avx512, function
132 func(gf_vect_dot_prod_avx512)
136 vpbroadcastb xmask0f, tmp ;Construct mask 0x0f0f0f...
137 sal vec, LOG_PS ;vec *= PS. Make vec_i count by PS
148 XLDR x0, [ptr+pos] ;Get next source vector
151 vpandq xtmpa, x0, xmask0f ;Mask low src nibble in bits 4-0
152 vpsraw x0, x0, 4 ;Shift to put high nibble into bits 4-0
153 vpandq x0, x0, xmask0f ;Mask high src nibble in bits 4-0
155 vmovdqu8 xgft1_loy, [tmp] ;Load array Ax{00}..{0f}, Ax{00}..{f0}
158 vshufi64x2 xgft1_hi, xgft1_lo, xgft1_lo, 0x55
159 vshufi64x2 xgft1_lo, xgft1_lo, xgft1_lo, 0x00
161 vpshufb xgft1_hi, xgft1_hi, x0 ;Lookup mul table of high nibble
162 vpshufb xgft1_lo, xgft1_lo, xtmpa ;Lookup mul table of low nibble
163 vpxorq xgft1_hi, xgft1_hi, xgft1_lo ;GF add high and low partials
164 vpxorq xp1, xp1, xgft1_hi ;xp1 += partial
169 XSTR [dest1+pos], xp1
171 add pos, 64 ;Loop on 64 bytes at a time
180 mov pos, len ;Overlapped offset length-64
181 jmp .loop64 ;Do one more overlap pass
184 .len_lt_64: ; 32-byte version
195 XLDR x0y, [ptr+pos] ;Get next source vector 32B
197 vpsraw xtmpa, x0, 4 ;Shift to put high nibble into bits 4-0
198 vshufi64x2 x0, x0, xtmpa, 0x44 ;put x0 = xl:xh
199 vpandq x0, x0, xmask0f ;Mask bits 4-0
200 vmovdqu8 xgft1_loy, [tmp] ;Load array Ax{00}..{0f}, Ax{00}..{f0}
202 vshufi64x2 xgft1_lo, xgft1_lo, xgft1_lo, 0x50 ;=AlAh:AlAh
203 vpshufb xgft1_lo, xgft1_lo, x0 ;Lookup mul table
204 vshufi64x2 xgft1_hi, xgft1_lo, xgft1_lo, 0x0e ;=xh:
205 vpxorq xgft1_hi, xgft1_hi, xgft1_lo ;GF add high and low partials
206 vpxorq xp1, xp1, xgft1_hi ;xp1 += partial
210 XSTR [dest1+pos], xp1y
211 add pos, 32 ;Loop on 32 bytes at a time
220 mov pos, len ;Overlapped offset length-32
221 jmp .loop32 ;Do one more overlap pass
236 %ifidn __OUTPUT_FORMAT__, win64
237 global no_gf_vect_dot_prod_avx512
238 no_gf_vect_dot_prod_avx512:
240 %endif ; ifdef HAVE_AS_KNOWS_AVX512