{"action":"created","issue":{"url":"https://api.github.com/repos/xianyi/OpenBLAS/issues/522","labels_url":"https://api.github.com/repos/xianyi/OpenBLAS/issues/522/labels{/name}","comments_url":"https://api.github.com/repos/xianyi/OpenBLAS/issues/522/comments","events_url":"https://api.github.com/repos/xianyi/OpenBLAS/issues/522/events","html_url":"https://github.com/xianyi/OpenBLAS/issues/522","id":63497582,"number":522,"title":"sdot inaccuracy","user":{"login":"cmr","id":704250,"avatar_url":"https://avatars.githubusercontent.com/u/704250?v=3","gravatar_id":"","url":"https://api.github.com/users/cmr","html_url":"https://github.com/cmr","followers_url":"https://api.github.com/users/cmr/followers","following_url":"https://api.github.com/users/cmr/following{/other_user}","gists_url":"https://api.github.com/users/cmr/gists{/gist_id}","starred_url":"https://api.github.com/users/cmr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cmr/subscriptions","organizations_url":"https://api.github.com/users/cmr/orgs","repos_url":"https://api.github.com/users/cmr/repos","events_url":"https://api.github.com/users/cmr/events{/privacy}","received_events_url":"https://api.github.com/users/cmr/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-03-22T06:40:45Z","updated_at":"2015-03-22T18:33:19Z","closed_at":null,"body":"Via fuzzing, I've found a potential problem, and this behavior differs from the reference BLAS. Here is a testcase:\r\n\r\n```c\r\n#include <cblas.h>\r\n#include <stdio.h>\r\n#include <math.h>\r\n\r\nstatic float x[16] = {0, 0, 0, 0, 0, 0, 0, 0, -28, 0, 41, -15, 0, 20, -55.744289, -76.930283};\r\nstatic float y[16] = {0, 0, 0, 0, 0, 0, 0, 0, -54.654705, 0, 23.670898, -4.533447, 0, 79.964569, -65.6026, -4};\r\n\r\nint main() {\r\n    float expected = 0;\r\n    for (int i = 0; i < 16; i++) {\r\n        expected += x[i] * y[i];\r\n    }\r\n\r\n    float actual = cblas_sdot(16, x, 1, y, 1);\r\n    printf(\"Expected %f, got %f, ==? %s, diff = %f\\n\", expected, actual, expected == actual ? \"true\" : \"false\", fabs(expected - actual));\r\n}\r\n```\r\n\r\nIt seems that the number of leading zeros is important. If you have any more or less than 8 leading zeros in the array, it will give the expected answer. The output here: `Expected 8132.823242, got 8132.822754, ==? false, diff = 0.000488`\r\n\r\n<bountysource-plugin>\r\n---\r\nWant to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/9860976-sdot-inaccuracy?utm_campaign=plugin&utm_content=tracker%2F69691&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F69691&utm_medium=issues&utm_source=github).\r\n</bountysource-plugin>"},"comment":{"url":"https://api.github.com/repos/xianyi/OpenBLAS/issues/comments/84671750","html_url":"https://github.com/xianyi/OpenBLAS/issues/522#issuecomment-84671750","issue_url":"https://api.github.com/repos/xianyi/OpenBLAS/issues/522","id":84671750,"user":{"login":"cmr","id":704250,"avatar_url":"https://avatars.githubusercontent.com/u/704250?v=3","gravatar_id":"","url":"https://api.github.com/users/cmr","html_url":"https://github.com/cmr","followers_url":"https://api.github.com/users/cmr/followers","following_url":"https://api.github.com/users/cmr/following{/other_user}","gists_url":"https://api.github.com/users/cmr/gists{/gist_id}","starred_url":"https://api.github.com/users/cmr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cmr/subscriptions","organizations_url":"https://api.github.com/users/cmr/orgs","repos_url":"https://api.github.com/users/cmr/repos","events_url":"https://api.github.com/users/cmr/events{/privacy}","received_events_url":"https://api.github.com/users/cmr/received_events","type":"User","site_admin":false},"created_at":"2015-03-22T18:33:19Z","updated_at":"2015-03-22T18:33:19Z","body":"I built with just `make` on `cdefdb2` as well. I discovered the bug in a VM, which exposes the Intel model \"Westmere E56xx/L56xx/X56xx (Nehalem-C)\" with the following features:\r\n\r\n```\r\nfpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon rep_good nopl pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes avx f16c rdrand hypervisor lahf_lm abm fsgsbase bmi1 avx2 smep bmi2 erms invpcid\r\n```\r\n\r\nI *cannot* replicate it on the host, which is Haswell with the following features:\r\n\r\n```\r\nfpu 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 est tm2 ssse3 fma cx16 xtpr pdcm pcid sse4_1 sse4_2 movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm ida arat epb pln pts dtherm tpr_shadow vnmi flexpriority ept vpid stronguderef fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid xsaveopt\r\n```"}}