{"action":"created","issue":{"url":"https://api.github.com/repos/JuliaDiff/ForwardDiff.jl/issues/376","repository_url":"https://api.github.com/repos/JuliaDiff/ForwardDiff.jl","labels_url":"https://api.github.com/repos/JuliaDiff/ForwardDiff.jl/issues/376/labels{/name}","comments_url":"https://api.github.com/repos/JuliaDiff/ForwardDiff.jl/issues/376/comments","events_url":"https://api.github.com/repos/JuliaDiff/ForwardDiff.jl/issues/376/events","html_url":"https://github.com/JuliaDiff/ForwardDiff.jl/pull/376","id":377236972,"node_id":"MDExOlB1bGxSZXF1ZXN0MjI4MjMwOTk5","number":376,"title":"bump DEFAULT_CHUNK_THRESHOLD to 12","user":{"login":"KristofferC","id":1282691,"node_id":"MDQ6VXNlcjEyODI2OTE=","avatar_url":"https://avatars1.githubusercontent.com/u/1282691?v=4","gravatar_id":"","url":"https://api.github.com/users/KristofferC","html_url":"https://github.com/KristofferC","followers_url":"https://api.github.com/users/KristofferC/followers","following_url":"https://api.github.com/users/KristofferC/following{/other_user}","gists_url":"https://api.github.com/users/KristofferC/gists{/gist_id}","starred_url":"https://api.github.com/users/KristofferC/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KristofferC/subscriptions","organizations_url":"https://api.github.com/users/KristofferC/orgs","repos_url":"https://api.github.com/users/KristofferC/repos","events_url":"https://api.github.com/users/KristofferC/events{/privacy}","received_events_url":"https://api.github.com/users/KristofferC/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-11-05T03:22:43Z","updated_at":"2018-11-05T21:19:59Z","closed_at":null,"author_association":"COLLABORATOR","pull_request":{"url":"https://api.github.com/repos/JuliaDiff/ForwardDiff.jl/pulls/376","html_url":"https://github.com/JuliaDiff/ForwardDiff.jl/pull/376","diff_url":"https://github.com/JuliaDiff/ForwardDiff.jl/pull/376.diff","patch_url":"https://github.com/JuliaDiff/ForwardDiff.jl/pull/376.patch"},"body":"We now have that lovely SIMD by default so should probably think about that a bit more w.r.t the `Chunk` we choose.\r\n\r\nDoing a benchmark such as\r\n\r\n```jl\r\nusing ForwardDiff\r\nusing BenchmarkTools\r\n\r\nimport ForwardDiff.Dual\r\nf(x) = (exp(x) * sin(x) + x^2 / tan(x))^3 / x^2\r\nd_10 = Dual(rand(11)...)\r\nd_12 = Dual(rand(13)...)\r\n\r\n@btime f($d_10)\r\n@btime f($d_12)\r\n```\r\n\r\nWe find\r\n\r\n```jl\r\njulia> @btime f($d_10);\r\n  77.918 ns (0 allocations: 0 bytes)\r\n\r\njulia> @btime f($d_12);\r\n  69.597 ns (0 allocations: 0 bytes)\r\n```\r\n\r\nso it is, in fact, faster to compute with chunk sizes of 12 instead of 10 (likely because they then all nicely fit into AVX registers and no need to clean up the scalars)\r\n\r\nTo see the effect on our favorite toy problem:\r\n\r\n```jl\r\nfunction rosenbrock(x)\r\n   a = one(eltype(x))\r\n   b = 100 * a\r\n   result = zero(eltype(x))\r\n   for i in 1:length(x)-1\r\n       result += (a - x[i])^2 + b*(x[i+1] - x[i]^2)^2\r\n   end\r\n   return result\r\nend\r\n\r\nusing BenchmarkTools\r\nimport ForwardDiff\r\nconst x = rand(60)\r\nconst y = similar(x)\r\nconst gradient_cache = ForwardDiff.GradientConfig(rosenbrock, x)\r\n```\r\n\r\nBefore:\r\n\r\n```jl\r\njulia> @btime ForwardDiff.gradient!(y, rosenbrock, x, gradient_cache)\r\n  5.589 μs (0 allocations: 0 bytes)\r\n```\r\n\r\nAfter:\r\n```jl\r\njulia> @btime ForwardDiff.gradient!(y, rosenbrock, x, gradient_cache)\r\n  4.761 μs (0 allocations: 0 bytes)\r\n```\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/JuliaDiff/ForwardDiff.jl/issues/comments/436039024","html_url":"https://github.com/JuliaDiff/ForwardDiff.jl/pull/376#issuecomment-436039024","issue_url":"https://api.github.com/repos/JuliaDiff/ForwardDiff.jl/issues/376","id":436039024,"node_id":"MDEyOklzc3VlQ29tbWVudDQzNjAzOTAyNA==","user":{"login":"jrevels","id":3277443,"node_id":"MDQ6VXNlcjMyNzc0NDM=","avatar_url":"https://avatars2.githubusercontent.com/u/3277443?v=4","gravatar_id":"","url":"https://api.github.com/users/jrevels","html_url":"https://github.com/jrevels","followers_url":"https://api.github.com/users/jrevels/followers","following_url":"https://api.github.com/users/jrevels/following{/other_user}","gists_url":"https://api.github.com/users/jrevels/gists{/gist_id}","starred_url":"https://api.github.com/users/jrevels/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jrevels/subscriptions","organizations_url":"https://api.github.com/users/jrevels/orgs","repos_url":"https://api.github.com/users/jrevels/repos","events_url":"https://api.github.com/users/jrevels/events{/privacy}","received_events_url":"https://api.github.com/users/jrevels/received_events","type":"User","site_admin":false},"created_at":"2018-11-05T21:19:59Z","updated_at":"2018-11-05T21:19:59Z","author_association":"MEMBER","body":"LGTM, thanks!"}}
{"actor":{"display_login":"jrevels"}}