OpenBLAS: ddot returns value inconsistent with sum(a*b) on newer Intel CPUs
I’m using OpenBLAS 0.3.18 (apparently), from anaconda3, and for this simple fortran program I get an output that is different from 0 by of order 1e-16 on some Intel CPUs (it’s not threading, or at least setting OPENBLAS_NUM_THREADS=1 doesn’t change it). With MKL the difference is 0 for all CPUs I’ve tried. I have to admit that I’m a bit confused by the anaconda3 versioning, so if there’s a canonical version of OpenBLAS (that’d run on CentOS 7), I’d be happy to compare to that.
program test_dot
implicit none
double precision :: p(3), v(3)
double precision, external :: ddot
double precision :: val_sum, val_dot
p = (/ 16.90513420661038423986610723659396171569824218750000D0, &
0.50000000000000000000000000000000000000000000000000D0, &
-1.71583683999999991875995419832179322838783264160156D0 /)
v = (/ 0.01628648030646704172874628113731887424364686012268D0, &
-0.17188353256547875269610869963798904791474342346191D0, &
-0.98498264035059979182307188239064998924732208251953D0 /)
val_sum = sum(p*v)
write (*, '(A15,F55.50)') "sum", val_sum
val_dot = ddot(3, p, 1, v, 1)
write (*, "(A15,F55.50)") "dot", val_dot
write (*, '(A15,F55.50)') "dot - sum", (val_dot - val_sum)
end program
The newest CPU that does not show a difference is
Intel(R) Xeon(R) CPU E5-2630 v3 @ 2.40GHz
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 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm epb invpcid_single intel_ppin ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid cqm xsaveopt cqm_llc cqm_occup_llc dtherm ida arat pln pts md_clear spec_ctrl intel_stibp flush_l1d
and the oldest that does is
Intel(R) Xeon(R) Gold 6140 CPU @ 2.30GHz
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 art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch epb cat_l3 cdp_l3 invpcid_single intel_ppin intel_pt ssbd mba ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm cqm mpx rdt_a avx512f avx512dq rdseed adx smap clflushopt clwb avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local dtherm ida arat pln pts pku ospke md_clear spec_ctrl intel_stibp flush_l1d
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 31 (15 by maintainers)
I doubt that 0.3.20 will be any different - no change in the AVX512 ddot microkernel there, the “issue” is probably that it accumulates intermediate results at higher precision. (And I suspect you could run into the same kind and magnitude of problem with compiler optimizations alone…)