{"action":"created","issue":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/9318","repository_url":"https://api.github.com/repos/JuliaLang/julia","labels_url":"https://api.github.com/repos/JuliaLang/julia/issues/9318/labels{/name}","comments_url":"https://api.github.com/repos/JuliaLang/julia/issues/9318/comments","events_url":"https://api.github.com/repos/JuliaLang/julia/issues/9318/events","html_url":"https://github.com/JuliaLang/julia/issues/9318","id":51743817,"node_id":"MDU6SXNzdWU1MTc0MzgxNw==","number":9318,"title":"SIMD vectorization of SubArrays and Complex numbers","user":{"login":"mweastwood","id":4071225,"node_id":"MDQ6VXNlcjQwNzEyMjU=","avatar_url":"https://avatars0.githubusercontent.com/u/4071225?v=4","gravatar_id":"","url":"https://api.github.com/users/mweastwood","html_url":"https://github.com/mweastwood","followers_url":"https://api.github.com/users/mweastwood/followers","following_url":"https://api.github.com/users/mweastwood/following{/other_user}","gists_url":"https://api.github.com/users/mweastwood/gists{/gist_id}","starred_url":"https://api.github.com/users/mweastwood/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mweastwood/subscriptions","organizations_url":"https://api.github.com/users/mweastwood/orgs","repos_url":"https://api.github.com/users/mweastwood/repos","events_url":"https://api.github.com/users/mweastwood/events{/privacy}","received_events_url":"https://api.github.com/users/mweastwood/received_events","type":"User","site_admin":false},"labels":[{"id":115619,"node_id":"MDU6TGFiZWwxMTU2MTk=","url":"https://api.github.com/repos/JuliaLang/julia/labels/doc","name":"doc","color":"02d7e1","default":false},{"id":115858,"node_id":"MDU6TGFiZWwxMTU4NTg=","url":"https://api.github.com/repos/JuliaLang/julia/labels/performance","name":"performance","color":"d7e102","default":false},{"id":912660205,"node_id":"MDU6TGFiZWw5MTI2NjAyMDU=","url":"https://api.github.com/repos/JuliaLang/julia/labels/simd","name":"simd","color":"c2e0c6","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2014-12-11T21:59:11Z","updated_at":"2018-10-23T21:55:31Z","closed_at":"2018-10-23T21:55:31Z","author_association":"CONTRIBUTOR","body":"At the risk of advertising my ignorance of how `@simd` works, it would be nice if both `SubArray`s and complex arithmetic could vectorize automatically. It seems to me that by making some careful, manual adjustments to your code, you can get something equivalent to vectorize (in both cases).\r\n\r\nFor example:\r\n\r\n```\r\nfunction f!(v)\r\n    @simd for i = 1:length(v)\r\n        @inbounds v[i] += v[i]\r\n    end\r\n    nothing\r\nend\r\n\r\nfunction g!(A,start,stride,finish)\r\n    @simd for i = start:stride:finish\r\n        @inbounds A[i] += A[i]\r\n    end\r\n    nothing\r\nend\r\n\r\nA = ones(5,5)\r\n@code_llvm f!(view(A,3,:)) # does not vectorize :(\r\n@code_llvm g!(A,3,5,23)   # vectorizes!\r\n```\r\n\r\nAnd for complex numbers:\r\n\r\n```\r\nfunction f!(v)\r\n    @simd for i = 1:length(v)\r\n        @inbounds v[i] += v[i]\r\n    end\r\n    nothing\r\nend\r\n\r\nfunction g!(v_real,v_imag)\r\n    @simd for i = 1:length(v_real)\r\n        @inbounds v_real[i] += v_real[i]\r\n        @inbounds v_imag[i] += v_imag[i]\r\n    end\r\n    nothing\r\nend\r\n\r\nv = ones(Complex64,5)\r\nv_real = real(v)\r\nv_imag = imag(v)\r\n@code_llvm f!(v)             # does not vectorize :(\r\n@code_llvm g!(v_real,v_imag) # vectorizes!\r\n```\r\n\r\nIt would be convenient if `f!` vectorized in both cases.\r\n"},"comment":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/comments/432435691","html_url":"https://github.com/JuliaLang/julia/issues/9318#issuecomment-432435691","issue_url":"https://api.github.com/repos/JuliaLang/julia/issues/9318","id":432435691,"node_id":"MDEyOklzc3VlQ29tbWVudDQzMjQzNTY5MQ==","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},"created_at":"2018-10-23T21:55:31Z","updated_at":"2018-10-23T21:55:31Z","author_association":"CONTRIBUTOR","body":"All now vectorize."}}
{"actor":{"display_login":"KristofferC"}}