{"action":"created","issue":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/14083","labels_url":"https://api.github.com/repos/JuliaLang/julia/issues/14083/labels{/name}","comments_url":"https://api.github.com/repos/JuliaLang/julia/issues/14083/comments","events_url":"https://api.github.com/repos/JuliaLang/julia/issues/14083/events","html_url":"https://github.com/JuliaLang/julia/pull/14083","id":118205735,"number":14083,"title":"Threading without using patched LLVM","user":{"login":"yuyichao","id":712232,"avatar_url":"https://avatars.githubusercontent.com/u/712232?v=3","gravatar_id":"","url":"https://api.github.com/users/yuyichao","html_url":"https://github.com/yuyichao","followers_url":"https://api.github.com/users/yuyichao/followers","following_url":"https://api.github.com/users/yuyichao/following{/other_user}","gists_url":"https://api.github.com/users/yuyichao/gists{/gist_id}","starred_url":"https://api.github.com/users/yuyichao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yuyichao/subscriptions","organizations_url":"https://api.github.com/users/yuyichao/orgs","repos_url":"https://api.github.com/users/yuyichao/repos","events_url":"https://api.github.com/users/yuyichao/events{/privacy}","received_events_url":"https://api.github.com/users/yuyichao/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/JuliaLang/julia/labels/multi-threading","name":"multi-threading","color":"fbca04"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2015-11-21T16:03:12Z","updated_at":"2015-11-24T16:05:58Z","closed_at":"2015-11-23T20:40:53Z","pull_request":{"url":"https://api.github.com/repos/JuliaLang/julia/pulls/14083","html_url":"https://github.com/JuliaLang/julia/pull/14083","diff_url":"https://github.com/JuliaLang/julia/pull/14083.diff","patch_url":"https://github.com/JuliaLang/julia/pull/14083.patch"},"body":"This tries to implement what @vtjnash suggested for making threading working without LLVM patch. This should also make it possible to support threading on windows since (I was told that) the LLVM tls patch doesn't support emitting TLS on windows.\r\n\r\nA few notes ~~and TODOs~~ (all done):\r\n\r\n1. ~~The first few commits in this PR are not directly related to TLS, they are either slightly related\r\n    clean-up's or fix of the bug discovered when testing this PR.~~\r\n    (merged as https://github.com/JuliaLang/julia/pull/14084)\r\n\r\n2. ~~This is currently GCC/Clang only due to the `__attribute__((const))` but it is only for performance\r\n    and not for correctness so can easily be disabled for other compilers (MSVC) or replaced with\r\n    equivalent attributes.~~ (fixed, [MSVC doesn't/won't support it](http://stackoverflow.com/a/2798511/904262), use `__declspec(noalias)` on MSVC)\r\n\r\n3. This placed all TLS variables in a big struct. Mainly because it's easier to do... There's no `#ifdef`'s\r\n    in the struct in order to keep it clean and to make the threading and non-threading versions ABI\r\n    compatible (to certain degree anyway...). This also effectively export all the TLS variables but we\r\n    could easily fix this using a nested struct (and only exposing the pointer to the inner, exported\r\n    struct) if it is a concern. (FWIW, this is C and there's way more things you can do to break stuff\r\n    other than accessing a non-exported TLS variable....)\r\n\r\n4. Compilation passes, REPL works and all tests passes for both threading and non-threading on\r\n    LLVM37. ~~(The compilation of `inference0.ji` with threading on had one SegFault that I couldn't\r\n    reproduce).~~ (reported as #14091)\r\n\r\n5. ~~Codegen is always accessing the TLS variables through a (const) function call. I get a freeze\r\n    before enterning the REPL if I let it use the global variable directly for non-threading version.\r\n    (probably because I didn't declare the struct correctly for LLVM).~~ (fixed). OTOH, with the\r\n    function attributes set (copied from Clang), llvm is able to emit only on call to `jl_get_ptls_states()`\r\n    per function.\r\n\r\n6. ~~TLS model is still `global-dynamic`.~~ Using a dynamic model by default. Override to a static model in repl. The override has to be done at initialization time and can be done for embedding as well if needed.\r\n\r\nc.c @tkelman @Keno\r\n\r\nedit: closes #13975"},"comment":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/comments/159315221","html_url":"https://github.com/JuliaLang/julia/pull/14083#issuecomment-159315221","issue_url":"https://api.github.com/repos/JuliaLang/julia/issues/14083","id":159315221,"user":{"login":"yuyichao","id":712232,"avatar_url":"https://avatars.githubusercontent.com/u/712232?v=3","gravatar_id":"","url":"https://api.github.com/users/yuyichao","html_url":"https://github.com/yuyichao","followers_url":"https://api.github.com/users/yuyichao/followers","following_url":"https://api.github.com/users/yuyichao/following{/other_user}","gists_url":"https://api.github.com/users/yuyichao/gists{/gist_id}","starred_url":"https://api.github.com/users/yuyichao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yuyichao/subscriptions","organizations_url":"https://api.github.com/users/yuyichao/orgs","repos_url":"https://api.github.com/users/yuyichao/repos","events_url":"https://api.github.com/users/yuyichao/events{/privacy}","received_events_url":"https://api.github.com/users/yuyichao/received_events","type":"User","site_admin":false},"created_at":"2015-11-24T16:05:57Z","updated_at":"2015-11-24T16:05:57Z","body":"The build should work, but I'm pretty sure there's still bugs (not sure if we can hit those bugs without actually running many threads though). Maybe at least have a buildbot for it? @tkelman @staticfloat "}}