oneDNN icon indicating copy to clipboard operation
oneDNN copied to clipboard

Best instruction set for s8s8s32 gemm ?

Open TPcoding opened this issue 7 years ago • 5 comments

Environment

Intel MKL-DNN includes hardware-specific optimizations and may behave differently on depending on the compiler and build environment. Include the following information to help reproduce the issue:

  • CPU make and model (try lscpu; if your lscpu does not list CPU flags, A CPU: flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm ida arat pln pts dtherm tpr_shadow vnmi flexpriority ept vpid fsgsbase smep erms xsaveopt B CPU: flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm ida arat pln pts dtherm tpr_shadow vnmi flexpriority ept vpid fsgsbase smep erms xsaveopt

  • OS version (uname -a) A cpu: Linux dev-istio-lasr-001 3.10.0-957.10.1.el7.x86_64 #1 SMP Mon Mar 18 15:06:45 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux B cpu: Linux dev-istio-lasr-001 3.10.0-957.10.1.el7.x86_64 #1 SMP Mon Mar 18 15:06:45 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

  • Compiler version (gcc --version) Linux dev-istio-lasr-001 3.10.0-957.10.1.el7.x86_64 #1 SMP Mon Mar 18 15:06:45 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

  • MKLROOT value (echo MKLROOT=$MKLROOT) /opt/intel/composer_xe_2015/mkl/lib/intel64/

  • CMake version (cmake --version)

  • CMake output log

  • git hash (git log -1 --format=%H) 1.0.0

Actual behavior

I find s8s8s32gemm different speed up with float/int8. I do some graph compute time used below: A cpu float 71ms, 8bit 458ms B cpu float 65ms, 8bit 22ms why A cpu int8 is so slow? avx not speed up? which instruction set is best for int8 gemm speed up?

TPcoding avatar Aug 08 '19 09:08 TPcoding

MKL-DNN supports optimized int8 on machines supporting avx512bw and avx512 vnni instruction sets. (Skylake/Cascade Lake). See this documentation page for more info.

This means that probably MKL-DNN does not have optimizations for CPU A and dispatches to a reference implementation which is very slow.

rsdubtso avatar Aug 08 '19 14:08 rsdubtso

Closing. Please feel free to reopen if you have any further questions.

rsdubtso avatar Aug 13 '19 04:08 rsdubtso

MKL-DNN supports optimized int8 on machines supporting avx512bw and avx512 vnni instruction sets. (Skylake/Cascade Lake). See this documentation page for more info.

This means that probably MKL-DNN does not have optimizations for CPU A and dispatches to a reference implementation which is very slow. @rsdubtso What's the planning of s8s8s32_gemm support for avx&avx2, and if use avx&avx2 in s8s8s32_gemm how much it will speed up? In my customer's serversing, much more are not support avx512. I really need MKL-DNN quantization speed up by avx/avx2.

TPcoding avatar Sep 04 '19 03:09 TPcoding

Sorry for the delay. There are plans for avx2 (not avx), but I cannot comment on when this is going to happen because this has not been defined yet. For what it's worth, OpenVINO already supports integer-based inferencing on machines supporting avx2 ISA.

rsdubtso avatar Sep 08 '19 19:09 rsdubtso

I'm also interested in AVX2 support. When deploying solutions on-premise, AVX512 is rarely available.

Also for reference, Intel MKL 2019.5 now optimizes GEMM_S8U8S32 and GEMM_S16S16S32 on SSE4.2, AVX, AVX2, and AVX512! You can benefit from that by using a v0.x release and linking to MKL.

guillaumekln avatar Sep 24 '19 09:09 guillaumekln