shithub: dav1d

Download patch

ref: 7cd946937ae499ba3a966f19c7c4d4544154623a
parent: 8e1295201e96a01cde0752418ae460833db3b5af
author: Janne Grunau <[email protected]>
date: Thu Mar 26 17:44:45 EDT 2020

meson/x86: add option to disable AVX-512 asm

Allows building with nasm < 2.14.

--- a/meson.build
+++ b/meson.build
@@ -362,20 +362,11 @@
     cdata_asm.set10('PREFIX', true)
 endif
 
-# Generate config.h
-config_h_target = configure_file(output: 'config.h', configuration: cdata)
-
-
-
 #
 # ASM specific stuff
 #
 if is_asm_enabled and host_machine.cpu_family().startswith('x86')
 
-    # Generate config.asm
-    config_asm_target = configure_file(output: 'config.asm', output_format: 'nasm', configuration: cdata_asm)
-
-
     # NASM compiler support
 
     nasm = find_program('nasm')
@@ -390,14 +381,22 @@
 
         out = nasm_r.stdout().strip().split()
         if out[1].to_lower() == 'version'
-            if out[2].version_compare('<2.14')
-                error('nasm 2.14 or later is required, found nasm @0@'.format(out[2]))
+            if out[2].version_compare('<2.13.02')
+                error('nasm 2.13.02 or later is required, found nasm @0@'.format(out[2]))
+            elif out[2].version_compare('<2.14') and get_option('enable_avx512')
+                error('nasm 2.14 or later is required for AVX-512 asm.\n' +
+                       'AVX-512 asm can be disabled with \'-Denable_avx512=false\'')
             endif
+            cdata.set10('HAVE_AVX512ICL', get_option('enable_avx512'))
+            cdata_asm.set10('HAVE_AVX512ICL', get_option('enable_avx512'))
         else
             error('unexpected nasm version string: @0@'.format(nasm_r.stdout()))
         endif
     endif
 
+    # Generate config.asm
+    config_asm_target = configure_file(output: 'config.asm', output_format: 'nasm', configuration: cdata_asm)
+
     if host_machine.system() == 'windows'
         nasm_format = 'win'
     elif host_machine.system() == 'darwin'
@@ -424,6 +423,10 @@
             '-o', '@OUTPUT@'
         ])
 endif
+
+
+# Generate config.h
+config_h_target = configure_file(output: 'config.h', configuration: cdata)
 
 
 
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -10,6 +10,11 @@
     value: true,
     description: 'Build asm files, if available')
 
+option('enable_avx512',
+    type: 'boolean',
+    value: true,
+    description: 'Build AVX-512 asm files, requires nasm 2.14')
+
 option('enable_tools',
     type: 'boolean',
     value: true,
--- a/src/x86/cdef.asm
+++ b/src/x86/cdef.asm
@@ -1849,6 +1849,8 @@
 ; 4e 4f 40 41 42 43 44 45
 ; 5e 5f 50 51 52 53 54 55
 
+%if HAVE_AVX512ICL
+
 INIT_ZMM avx512icl
 cglobal cdef_filter_4x4, 4, 8, 13, dst, stride, left, top, pri, sec, dir, damping, edge
 %define base r7-edge_mask
@@ -1997,5 +1999,7 @@
     pminub         m5, m12
     vpdpbusd       m0, m5, m9
     ret
+
+%endif ; HAVE_AVX512ICL
 
 %endif ; ARCH_X86_64
--- a/src/x86/cdef_init_tmpl.c
+++ b/src/x86/cdef_init_tmpl.c
@@ -84,7 +84,7 @@
 
     if (!(flags & DAV1D_X86_CPU_FLAG_AVX512ICL)) return;
 
-#if BITDEPTH == 8
+#if HAVE_AVX512ICL && BITDEPTH == 8
     c->fb[2] = dav1d_cdef_filter_4x4_avx512icl;
 #endif
 
--- a/src/x86/mc.asm
+++ b/src/x86/mc.asm
@@ -240,6 +240,7 @@
 BIDIR_JMP_TABLE blend_v_avx2,      2, 4, 8, 16, 32
 BIDIR_JMP_TABLE blend_h_avx2,      2, 4, 8, 16, 32, 32, 32
 
+%if HAVE_AVX512ICL
 BASE_JMP_TABLE prep, avx512icl,            4, 8, 16, 32, 64, 128
 HV_JMP_TABLE prep, bilin, avx512icl, 7,    4, 8, 16, 32, 64, 128
 HV_JMP_TABLE prep, 8tap,  avx512icl, 7,    4, 8, 16, 32, 64, 128
@@ -249,6 +250,7 @@
 BIDIR_JMP_TABLE w_mask_420_avx512icl,      4, 8, 16, 32, 64, 128
 BIDIR_JMP_TABLE w_mask_422_avx512icl,      4, 8, 16, 32, 64, 128
 BIDIR_JMP_TABLE w_mask_444_avx512icl,      4, 8, 16, 32, 64, 128
+%endif ; HAVE_AVX512ICL
 
 SECTION .text
 
@@ -5501,6 +5503,7 @@
     jg .w128_loop
     RET
 
+%if HAVE_AVX512ICL
 INIT_ZMM avx512icl
 PREP_BILIN
 PREP_8TAP
@@ -6022,5 +6025,7 @@
     dec                  hd
     jg .w128_loop
     RET
+
+%endif ; HAVE_AVX512ICL
 
 %endif ; ARCH_X86_64
--- a/src/x86/mc_init_tmpl.c
+++ b/src/x86/mc_init_tmpl.c
@@ -224,7 +224,7 @@
     if (!(flags & DAV1D_X86_CPU_FLAG_AVX512ICL))
         return;
 
-#if BITDEPTH == 8
+#if HAVE_AVX512ICL && BITDEPTH == 8
     init_mct_fn(FILTER_2D_8TAP_REGULAR,        8tap_regular,        avx512icl);
     init_mct_fn(FILTER_2D_8TAP_REGULAR_SMOOTH, 8tap_regular_smooth, avx512icl);
     init_mct_fn(FILTER_2D_8TAP_REGULAR_SHARP,  8tap_regular_sharp,  avx512icl);