Skip to content

Commit 5f5b7c4

Browse files
authored
Merge pull request #4423 from martin-frbg/issue4422
Check compiler support for AVX512BF16 and base COL/SPR kernel choice on that
2 parents f31bea0 + 995a990 commit 5f5b7c4

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

c_check

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ case "$data" in
244244
esac
245245

246246
no_avx512=0
247+
no_avx512bf=0
247248
if [ "$architecture" = "x86" ] || [ "$architecture" = "x86_64" ]; then
248249
tmpd=$(mktemp -d 2>/dev/null || mktemp -d -t 'OBC')
249250
tmpf="$tmpd/a.c"
@@ -262,6 +263,25 @@ if [ "$architecture" = "x86" ] || [ "$architecture" = "x86_64" ]; then
262263
}
263264

264265
rm -rf "$tmpd"
266+
if [ "$no_avx512" -eq 0 ]; then
267+
tmpd=$(mktemp -d 2>/dev/null || mktemp -d -t 'OBC')
268+
tmpf="$tmpd/a.c"
269+
code='"__m512 a= _mm512_dpbf16_ps(a, (__m512bh) _mm512_loadu_si512(%1]), (__m512bh) _mm512_loadu_si512(%2]));"'
270+
printf "#include <immintrin.h>\n\nint main(void){ %s; }\n" "$code" >> "$tmpf"
271+
if [ "$compiler" = "PGI" ]; then
272+
args=" -tp cooperlake -c -o $tmpf.o $tmpf"
273+
else
274+
args=" -march=cooperlake -c -o $tmpf.o $tmpf"
275+
fi
276+
no_avx512bf=0
277+
{
278+
$compiler_name $flags $args >/dev/null 2>&1
279+
} || {
280+
no_avx512bf=1
281+
}
282+
283+
rm -rf "$tmpd"
284+
fi
265285
fi
266286

267287
no_rv64gv=0
@@ -409,6 +429,7 @@ done
409429
[ "$makefile" = "-" ] && {
410430
[ "$no_rv64gv" -eq 1 ] && printf "NO_RV64GV=1\n"
411431
[ "$no_avx512" -eq 1 ] && printf "NO_AVX512=1\n"
432+
[ "$no_avx512bf" -eq 1 ] && printf "NO_AVX512BF16=1\n"
412433
[ "$no_avx2" -eq 1 ] && printf "NO_AVX2=1\n"
413434
[ "$oldgcc" -eq 1 ] && printf "OLDGCC=1\n"
414435
exit 0
@@ -437,6 +458,7 @@ done
437458
[ "$no_sve" -eq 1 ] && printf "NO_SVE=1\n"
438459
[ "$no_rv64gv" -eq 1 ] && printf "NO_RV64GV=1\n"
439460
[ "$no_avx512" -eq 1 ] && printf "NO_AVX512=1\n"
461+
[ "$no_avx512bf" -eq 1 ] && printf "NO_AVX512BF16=1\n"
440462
[ "$no_avx2" -eq 1 ] && printf "NO_AVX2=1\n"
441463
[ "$oldgcc" -eq 1 ] && printf "OLDGCC=1\n"
442464
[ "$no_lsx" -eq 1 ] && printf "NO_LSX=1\n"

kernel/x86_64/KERNEL.COOPERLAKE

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
include $(KERNELDIR)/KERNEL.SKYLAKEX
2-
2+
ifneq ($(NO_AVX512BF16), 1)
33
SBGEMM_SMALL_M_PERMIT = sbgemm_small_kernel_permit_cooperlake.c
44
SBGEMM_SMALL_K_NN = sbgemm_small_kernel_nn_cooperlake.c
55
SBGEMM_SMALL_K_B0_NN = sbgemm_small_kernel_nn_cooperlake.c
@@ -20,3 +20,4 @@ SBGEMMINCOPYOBJ = sbgemm_incopy$(TSUFFIX).$(SUFFIX)
2020
SBGEMMITCOPYOBJ = sbgemm_itcopy$(TSUFFIX).$(SUFFIX)
2121
SBGEMMONCOPYOBJ = sbgemm_oncopy$(TSUFFIX).$(SUFFIX)
2222
SBGEMMOTCOPYOBJ = sbgemm_otcopy$(TSUFFIX).$(SUFFIX)
23+
endif

kernel/x86_64/KERNEL.SAPPHIRERAPIDS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
include $(KERNELDIR)/KERNEL.COOPERLAKE
22

3+
ifneq ($(NO_AVX512BF16), 1)
34
SBGEMM_SMALL_M_PERMIT =
45
SBGEMM_SMALL_K_NN =
56
SBGEMM_SMALL_K_B0_NN =
@@ -20,3 +21,4 @@ SBGEMMINCOPYOBJ = sbgemm_incopy$(TSUFFIX).$(SUFFIX)
2021
SBGEMMITCOPYOBJ = sbgemm_itcopy$(TSUFFIX).$(SUFFIX)
2122
SBGEMMONCOPYOBJ = sbgemm_oncopy$(TSUFFIX).$(SUFFIX)
2223
SBGEMMOTCOPYOBJ = sbgemm_otcopy$(TSUFFIX).$(SUFFIX)
24+
endif

0 commit comments

Comments
 (0)