{"action":"created","issue":{"url":"https://api.github.com/repos/stan-dev/math/issues/222","labels_url":"https://api.github.com/repos/stan-dev/math/issues/222/labels{/name}","comments_url":"https://api.github.com/repos/stan-dev/math/issues/222/comments","events_url":"https://api.github.com/repos/stan-dev/math/issues/222/events","html_url":"https://github.com/stan-dev/math/issues/222","id":126994106,"number":222,"title":"Parallel automatic differentiation","user":{"login":"ibab","id":890531,"avatar_url":"https://avatars.githubusercontent.com/u/890531?v=3","gravatar_id":"","url":"https://api.github.com/users/ibab","html_url":"https://github.com/ibab","followers_url":"https://api.github.com/users/ibab/followers","following_url":"https://api.github.com/users/ibab/following{/other_user}","gists_url":"https://api.github.com/users/ibab/gists{/gist_id}","starred_url":"https://api.github.com/users/ibab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ibab/subscriptions","organizations_url":"https://api.github.com/users/ibab/orgs","repos_url":"https://api.github.com/users/ibab/repos","events_url":"https://api.github.com/users/ibab/events{/privacy}","received_events_url":"https://api.github.com/users/ibab/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-01-16T02:13:34Z","updated_at":"2016-01-17T01:48:23Z","closed_at":"2016-01-16T18:40:31Z","body":"Is there currently a way of performing automatic differentiatio in parallel?\r\nSomething like the following would be amazing:\r\n\r\n```cpp\r\n#include <stan/math.hpp>\r\n\r\nint main() {\r\n\r\n    stan::math::var result = 0;\r\n    stan::math::var x = 3;\r\n\r\n    #pragma omp declare reduction (+ : stan::math::var : omp_out += omp_in )\r\n    #pragma omp parallel reduction(+ : result) shared(x)\r\n    for (int i = 0; i < 10; i++) {\r\n        result += x * x;\r\n    }\r\n\r\n    std::cout << result.val() << std::endl;\r\n    result.grad();\r\n    std::cout << x.adj() << std::endl;\r\n\r\n    return 0;\r\n}\r\n```\r\n\r\nBut unfortunately, this fails with\r\n```\r\n*** Error in `./simple': free(): invalid next size (fast): 0x00007faa380008c0 ***\r\nzsh: segmentation fault (core dumped)  ./simple\r\n```\r\nwhile the single-threaded version works."},"comment":{"url":"https://api.github.com/repos/stan-dev/math/issues/comments/172283501","html_url":"https://github.com/stan-dev/math/issues/222#issuecomment-172283501","issue_url":"https://api.github.com/repos/stan-dev/math/issues/222","id":172283501,"user":{"login":"ibab","id":890531,"avatar_url":"https://avatars.githubusercontent.com/u/890531?v=3","gravatar_id":"","url":"https://api.github.com/users/ibab","html_url":"https://github.com/ibab","followers_url":"https://api.github.com/users/ibab/followers","following_url":"https://api.github.com/users/ibab/following{/other_user}","gists_url":"https://api.github.com/users/ibab/gists{/gist_id}","starred_url":"https://api.github.com/users/ibab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ibab/subscriptions","organizations_url":"https://api.github.com/users/ibab/orgs","repos_url":"https://api.github.com/users/ibab/repos","events_url":"https://api.github.com/users/ibab/events{/privacy}","received_events_url":"https://api.github.com/users/ibab/received_events","type":"User","site_admin":false},"created_at":"2016-01-17T01:48:23Z","updated_at":"2016-01-17T01:48:23Z","body":"Thanks for the detailed response.\r\nParallelizing reverse mode differentiation seems to be significantly more difficult than I thought."}}