{"action":"created","issue":{"url":"https://api.github.com/repos/google/highwayhash/issues/7","repository_url":"https://api.github.com/repos/google/highwayhash","labels_url":"https://api.github.com/repos/google/highwayhash/issues/7/labels{/name}","comments_url":"https://api.github.com/repos/google/highwayhash/issues/7/comments","events_url":"https://api.github.com/repos/google/highwayhash/issues/7/events","html_url":"https://github.com/google/highwayhash/pull/7","id":144757530,"number":7,"title":"Runtime lookup for AVX2 instructions","user":{"login":"dryman","id":261232,"avatar_url":"https://avatars.githubusercontent.com/u/261232?v=3","gravatar_id":"","url":"https://api.github.com/users/dryman","html_url":"https://github.com/dryman","followers_url":"https://api.github.com/users/dryman/followers","following_url":"https://api.github.com/users/dryman/following{/other_user}","gists_url":"https://api.github.com/users/dryman/gists{/gist_id}","starred_url":"https://api.github.com/users/dryman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dryman/subscriptions","organizations_url":"https://api.github.com/users/dryman/orgs","repos_url":"https://api.github.com/users/dryman/repos","events_url":"https://api.github.com/users/dryman/events{/privacy}","received_events_url":"https://api.github.com/users/dryman/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/google/highwayhash/labels/cla:%20no","name":"cla: no","color":"fad8c7"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-03-31T00:46:06Z","updated_at":"2016-03-31T00:50:26Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/google/highwayhash/pulls/7","html_url":"https://github.com/google/highwayhash/pull/7","diff_url":"https://github.com/google/highwayhash/pull/7.diff","patch_url":"https://github.com/google/highwayhash/pull/7.patch"},"body":"This patch support the following:\r\n* Use ` __builtin_cpu_supports(\"avx2\")` at runtime to determine if the host/target machine supports avx2\r\n* If avx2 is supported, use the best implementation.\r\n* If not supported, fallback to scalar/sse4.1 implementation.\r\n* The test would be cached in a static function pointer.\r\n\r\nIt has been tested on my old machine that only have sse4.1 but without avx2.\r\n\r\nThe Makefile optimization flag changed from O3 to O2. Using O3 with `-mavx2` would make gcc try to use avx2 instruction on scalar programs as well. As the goal is to have the binary able to run on older machine, I turned it off. Fortunately it didn't affect the performance that much. Most of the time it is optimizing variable init only.\r\n\r\nThe sip_hash implementation uses avx2, and it is also used by scalar_sip_tree_hash. To make it portable to older machine, I created sse41_sip_hash.cc.\r\n\r\nThis implementation requires gcc-4.8 or above. (newer clang seems to have a patch to support this, but I haven't test it). I wrote the macro that if CXX on build machine is gcc-4.8 or above, enable the runtime lookup, else just behave as is."},"comment":{"url":"https://api.github.com/repos/google/highwayhash/issues/comments/203699057","html_url":"https://github.com/google/highwayhash/pull/7#issuecomment-203699057","issue_url":"https://api.github.com/repos/google/highwayhash/issues/7","id":203699057,"user":{"login":"dryman","id":261232,"avatar_url":"https://avatars.githubusercontent.com/u/261232?v=3","gravatar_id":"","url":"https://api.github.com/users/dryman","html_url":"https://github.com/dryman","followers_url":"https://api.github.com/users/dryman/followers","following_url":"https://api.github.com/users/dryman/following{/other_user}","gists_url":"https://api.github.com/users/dryman/gists{/gist_id}","starred_url":"https://api.github.com/users/dryman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dryman/subscriptions","organizations_url":"https://api.github.com/users/dryman/orgs","repos_url":"https://api.github.com/users/dryman/repos","events_url":"https://api.github.com/users/dryman/events{/privacy}","received_events_url":"https://api.github.com/users/dryman/received_events","type":"User","site_admin":false},"created_at":"2016-03-31T00:50:26Z","updated_at":"2016-03-31T00:50:26Z","body":"CLA signed."}}