{"action":"created","comment":{"url":"https://api.github.com/repos/eth-cscs/arbor/pulls/comments/174840124","pull_request_review_id":103836005,"id":174840124,"diff_hunk":"@@ -0,0 +1,948 @@\n+SIMD classes for Arbor\n+======================\n+\n+The purpose of the SIMD classes is to abstract and consolidate the use of\n+compiler intrinsics for the manipulation of architecture-specific vector\n+(SIMD) values.\n+\n+The implementation is rather loosely based on the data-parallel vector types\n+proposal P0214R6 for the C++ Parallelism TS 2.\n+\n+Examples\n+--------\n+\n+The following code performs an element-wise vector product, storing\n+only non-zero values in the resultant array.\n+\n+.. container:: example-code\n+\n+    .. code-block:: cpp\n+\n+        #include <util/simd.hpp>\n+        using namespace arb;\n+\n+        void product_nonzero(int n, const double* a, const double* b, double* result) {\n+            constexpr int N = simd_abi::native_width<double>::value;\n+            using simd = simd<double, N>;\n+            using mask = simd::simd_mask;\n+\n+            int i = 0;\n+            for (; i+N<=n; i+=N) {\n+                auto vp = simd(a+i)*simd(b+i);\n+                where(vp!=0, vp).copy_to(result+i);\n+            }\n+\n+            int tail = n-i;\n+            auto m = mask::unpack((1<<tail)-1);\n+\n+            auto vp = simd(a+i, m)*simd(b+i, m);\n+            where(m && vp!=0, vp).copy_to(c+i);\n+        }\n+\n+\n+Classes\n+-------\n+\n+Three user-facing template classes are provided:\n+\n+1. ``simd<V, N, I = simd_abi::default_abi>``\n+\n+   *N*-wide vector type of values of type *V*, using architecture-specific\n+   implementation *I*. The implementation parameter is itself a template,\n+   acting as a type-map, with ``I<V, N>::type`` being the concrete implementation\n+   class (see below) for *N*-wide vectors of type *V* for this architecture.\n+\n+   The implementation ``simd_abi::generic`` provides a ``std::array``-backed\n+   implementation for arbitrary *V* and *N*, while ``simd_abi::native``\n+   maps to the native architecture implementation for *V* and *N*, if\n+   supported.\n+\n+   ``simd_abi::default_abi`` will use ``simd_abi::native`` if available, or\n+   else fall back to the generic implementation.\n+\n+2. ``simd_mask<V, N, I = simd_api::default_abi>``\n+\n+   The result of performing a lane-wise comparison/test operation on\n+   a ``simd<V, N, I>`` vector value. ``simd_mask`` objects support logical\n+   operations and are used as arguments to ``where`` expressions.\n+\n+   ``simd_mask<V, N, I>`` is a type alias for ``simd<V, N, I>::simd_mask``.\n+\n+3. ``where_expression<simd<V, N, I>>``\n+\n+   The result of a ``where`` expression, used for masked assignment.\n+\n+Implementation typemaps live in the ``simd_abi`` namespace, while concrete\n+implementation classes live in ``simd_detail``. A particular specialization\n+for an architecture, for example 4-wide double on AVX, then requires:\n+\n+*  A concrete implementation class, e.g. ``simd_detail::avx_double4``.\n+\n+*  A specialization of its ABI map, so that ``simd_abi::avx<double, 4>::type``\n+   is an alias for ``simd_detail::avx_double4``.\n+\n+*  A specialization of the native ABI map, so that\n+   ``simd_abi::native<double, 4>::type`` is an alias for ``simd_abi::avx<double, 4>::type``.\n+\n+The maximum natively supported width for a scalar type *V* is recorded in\n+``simd_abi::native_width<V>::value``.\n+\n+Class ``simd``\n+^^^^^^^^^^^^^^\n+\n+The class ``simd<V, N, I>`` is an alias for ``simd_detail::simd_impl<I<V, N>::type>``;\n+the class ``simd_detail::simd_impl<C>`` provides the public interface and\n+arithmetic operators for a concrete implementation class `C`.\n+\n+In the following:\n+\n+* *S* stands for the class ``simd<V, N, I>``.\n+* *s* is an SIMD value of type *S*.\n+* *m* is a mask value of type ``S::simd_mask``.\n+* *t*, *u* and *v* are const objects of type *S*.\n+* *i* is an index of type ``int``.\n+* *j* is a const object of type ``simd<U, N, J>`` where *U* is an integral type.\n+* *x* is a value of type *V*.\n+* *p* is a pointer to *V*.\n+* *c* is a const pointer to *V* or a length *N* array of *V*.\n+\n+Here and below, the value in lane *i* of a SIMD vector or mask *v* is denoted by\n+*v*\\ `i`:sub:\n+\n+\n+.. rubric:: Type aliases and constexpr members\n+\n+.. list-table::\n+    :widths: 20 20 60\n+    :header-rows: 1\n+\n+    * - Name\n+      - Type\n+      - Description\n+\n+    * - ``S::scalar_type``\n+      - *V*\n+      - The type of one lane of the SIMD type.\n+\n+    * - ``S::simd_mask``\n+      - ``simd_mask<V, N, I>``\n+      - The ``simd_mask`` specialization resulting from comparisons of *S* SIMD values.\n+\n+    * - ``S::width``\n+      - ``unsigned``\n+      - The SIMD width *N*.\n+\n+.. rubric:: Constructors\n+\n+.. list-table::\n+    :widths: 20 80\n+    :header-rows: 1\n+\n+    * - Expression\n+      - Description\n+\n+    * - ``S(x)``\n+      - A SIMD value *v* with *v*\\ `i`:sub: equal to *x* for *i* = 0…*N*-1.\n+\n+    * - ``S(t)``\n+      - A copy of the SIMD value *t*.\n+\n+    * - ``S(c)``","path":"doc/simd_api.rst","position":150,"original_position":150,"commit_id":"d1cf9c8f13d8b81c9254aeae87f54db888228901","original_commit_id":"d1cf9c8f13d8b81c9254aeae87f54db888228901","user":{"login":"bcumming","id":384605,"avatar_url":"https://avatars0.githubusercontent.com/u/384605?v=4","gravatar_id":"","url":"https://api.github.com/users/bcumming","html_url":"https://github.com/bcumming","followers_url":"https://api.github.com/users/bcumming/followers","following_url":"https://api.github.com/users/bcumming/following{/other_user}","gists_url":"https://api.github.com/users/bcumming/gists{/gist_id}","starred_url":"https://api.github.com/users/bcumming/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bcumming/subscriptions","organizations_url":"https://api.github.com/users/bcumming/orgs","repos_url":"https://api.github.com/users/bcumming/repos","events_url":"https://api.github.com/users/bcumming/events{/privacy}","received_events_url":"https://api.github.com/users/bcumming/received_events","type":"User","site_admin":false},"body":"I think that explicitly saying `S(const V*)`, or even `simd<V,N,I>(const V*)` is clearer, because that is the signature of the constructor.","created_at":"2018-03-15T16:09:51Z","updated_at":"2018-03-15T16:22:37Z","html_url":"https://github.com/eth-cscs/arbor/pull/450#discussion_r174840124","pull_request_url":"https://api.github.com/repos/eth-cscs/arbor/pulls/450","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/eth-cscs/arbor/pulls/comments/174840124"},"html":{"href":"https://github.com/eth-cscs/arbor/pull/450#discussion_r174840124"},"pull_request":{"href":"https://api.github.com/repos/eth-cscs/arbor/pulls/450"}}},"pull_request":{"url":"https://api.github.com/repos/eth-cscs/arbor/pulls/450","id":174903428,"html_url":"https://github.com/eth-cscs/arbor/pull/450","diff_url":"https://github.com/eth-cscs/arbor/pull/450.diff","patch_url":"https://github.com/eth-cscs/arbor/pull/450.patch","issue_url":"https://api.github.com/repos/eth-cscs/arbor/issues/450","number":450,"state":"open","locked":false,"title":"SIMD wrappers for Arbor generated mechanisms.","user":{"login":"halfflat","id":556816,"avatar_url":"https://avatars1.githubusercontent.com/u/556816?v=4","gravatar_id":"","url":"https://api.github.com/users/halfflat","html_url":"https://github.com/halfflat","followers_url":"https://api.github.com/users/halfflat/followers","following_url":"https://api.github.com/users/halfflat/following{/other_user}","gists_url":"https://api.github.com/users/halfflat/gists{/gist_id}","starred_url":"https://api.github.com/users/halfflat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/halfflat/subscriptions","organizations_url":"https://api.github.com/users/halfflat/orgs","repos_url":"https://api.github.com/users/halfflat/repos","events_url":"https://api.github.com/users/halfflat/events{/privacy}","received_events_url":"https://api.github.com/users/halfflat/received_events","type":"User","site_admin":false},"body":"This provides a bunch of SIMD intrinsic wrappers as a precursor to the SIMD printers in the `mech-refactor` branch. The aim is that the SIMD printer can be agnostic regarding the particular vector architecture.\r\n\r\n~~Note: the documentation in this PR is *incomplete*. The PR will be updated soon™ with more thorough documentation; in the meantime, the information in `doc/simd_api.rst` should be accurate up to and including the section _Examples_.~~ \r\n\r\nThe design is based rather loosely on the proposal P0214R6 for C++ Parallelism TS 2. It deviates primarily in that the vector length is provided explicitly, rather than implicitly, and that we have interfaces included for gather and scatter operations. The transcendental function implementations are adapted from the existing SIMD architecture-specific code, which in turn are based on the Cephes library algorithms.\r\n\r\nThe HTML CSS has been also tweaked in this patch, with a hack to override the scrolling dynamic tables behaviour, and to put appropriate spacing after paragraphs in list items.","created_at":"2018-03-14T09:58:18Z","updated_at":"2018-03-15T16:22:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"10295612d5fe0c232840c594ead63adc3baa83f8","assignee":null,"assignees":[],"requested_reviewers":[{"login":"vkarak","id":611019,"avatar_url":"https://avatars1.githubusercontent.com/u/611019?v=4","gravatar_id":"","url":"https://api.github.com/users/vkarak","html_url":"https://github.com/vkarak","followers_url":"https://api.github.com/users/vkarak/followers","following_url":"https://api.github.com/users/vkarak/following{/other_user}","gists_url":"https://api.github.com/users/vkarak/gists{/gist_id}","starred_url":"https://api.github.com/users/vkarak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vkarak/subscriptions","organizations_url":"https://api.github.com/users/vkarak/orgs","repos_url":"https://api.github.com/users/vkarak/repos","events_url":"https://api.github.com/users/vkarak/events{/privacy}","received_events_url":"https://api.github.com/users/vkarak/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/eth-cscs/arbor/pulls/450/commits","review_comments_url":"https://api.github.com/repos/eth-cscs/arbor/pulls/450/comments","review_comment_url":"https://api.github.com/repos/eth-cscs/arbor/pulls/comments{/number}","comments_url":"https://api.github.com/repos/eth-cscs/arbor/issues/450/comments","statuses_url":"https://api.github.com/repos/eth-cscs/arbor/statuses/d1cf9c8f13d8b81c9254aeae87f54db888228901","head":{"label":"halfflat:feature/consolidate-simd","ref":"feature/consolidate-simd","sha":"d1cf9c8f13d8b81c9254aeae87f54db888228901","user":{"login":"halfflat","id":556816,"avatar_url":"https://avatars1.githubusercontent.com/u/556816?v=4","gravatar_id":"","url":"https://api.github.com/users/halfflat","html_url":"https://github.com/halfflat","followers_url":"https://api.github.com/users/halfflat/followers","following_url":"https://api.github.com/users/halfflat/following{/other_user}","gists_url":"https://api.github.com/users/halfflat/gists{/gist_id}","starred_url":"https://api.github.com/users/halfflat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/halfflat/subscriptions","organizations_url":"https://api.github.com/users/halfflat/orgs","repos_url":"https://api.github.com/users/halfflat/repos","events_url":"https://api.github.com/users/halfflat/events{/privacy}","received_events_url":"https://api.github.com/users/halfflat/received_events","type":"User","site_admin":false},"repo":{"id":70549033,"name":"arbor","full_name":"halfflat/arbor","owner":{"login":"halfflat","id":556816,"avatar_url":"https://avatars1.githubusercontent.com/u/556816?v=4","gravatar_id":"","url":"https://api.github.com/users/halfflat","html_url":"https://github.com/halfflat","followers_url":"https://api.github.com/users/halfflat/followers","following_url":"https://api.github.com/users/halfflat/following{/other_user}","gists_url":"https://api.github.com/users/halfflat/gists{/gist_id}","starred_url":"https://api.github.com/users/halfflat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/halfflat/subscriptions","organizations_url":"https://api.github.com/users/halfflat/orgs","repos_url":"https://api.github.com/users/halfflat/repos","events_url":"https://api.github.com/users/halfflat/events{/privacy}","received_events_url":"https://api.github.com/users/halfflat/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/halfflat/arbor","description":"Prototype for the NestMC multi-compartment neural network simulator","fork":true,"url":"https://api.github.com/repos/halfflat/arbor","forks_url":"https://api.github.com/repos/halfflat/arbor/forks","keys_url":"https://api.github.com/repos/halfflat/arbor/keys{/key_id}","collaborators_url":"https://api.github.com/repos/halfflat/arbor/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/halfflat/arbor/teams","hooks_url":"https://api.github.com/repos/halfflat/arbor/hooks","issue_events_url":"https://api.github.com/repos/halfflat/arbor/issues/events{/number}","events_url":"https://api.github.com/repos/halfflat/arbor/events","assignees_url":"https://api.github.com/repos/halfflat/arbor/assignees{/user}","branches_url":"https://api.github.com/repos/halfflat/arbor/branches{/branch}","tags_url":"https://api.github.com/repos/halfflat/arbor/tags","blobs_url":"https://api.github.com/repos/halfflat/arbor/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/halfflat/arbor/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/halfflat/arbor/git/refs{/sha}","trees_url":"https://api.github.com/repos/halfflat/arbor/git/trees{/sha}","statuses_url":"https://api.github.com/repos/halfflat/arbor/statuses/{sha}","languages_url":"https://api.github.com/repos/halfflat/arbor/languages","stargazers_url":"https://api.github.com/repos/halfflat/arbor/stargazers","contributors_url":"https://api.github.com/repos/halfflat/arbor/contributors","subscribers_url":"https://api.github.com/repos/halfflat/arbor/subscribers","subscription_url":"https://api.github.com/repos/halfflat/arbor/subscription","commits_url":"https://api.github.com/repos/halfflat/arbor/commits{/sha}","git_commits_url":"https://api.github.com/repos/halfflat/arbor/git/commits{/sha}","comments_url":"https://api.github.com/repos/halfflat/arbor/comments{/number}","issue_comment_url":"https://api.github.com/repos/halfflat/arbor/issues/comments{/number}","contents_url":"https://api.github.com/repos/halfflat/arbor/contents/{+path}","compare_url":"https://api.github.com/repos/halfflat/arbor/compare/{base}...{head}","merges_url":"https://api.github.com/repos/halfflat/arbor/merges","archive_url":"https://api.github.com/repos/halfflat/arbor/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/halfflat/arbor/downloads","issues_url":"https://api.github.com/repos/halfflat/arbor/issues{/number}","pulls_url":"https://api.github.com/repos/halfflat/arbor/pulls{/number}","milestones_url":"https://api.github.com/repos/halfflat/arbor/milestones{/number}","notifications_url":"https://api.github.com/repos/halfflat/arbor/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/halfflat/arbor/labels{/name}","releases_url":"https://api.github.com/repos/halfflat/arbor/releases{/id}","deployments_url":"https://api.github.com/repos/halfflat/arbor/deployments","created_at":"2016-10-11T02:43:08Z","updated_at":"2017-09-27T13:33:08Z","pushed_at":"2018-03-14T19:16:47Z","git_url":"git://github.com/halfflat/arbor.git","ssh_url":"git@github.com:halfflat/arbor.git","clone_url":"https://github.com/halfflat/arbor.git","svn_url":"https://github.com/halfflat/arbor","homepage":"https://eth-cscs.github.io/nestmc/","size":3560,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"eth-cscs:master","ref":"master","sha":"aca8473011b5eac780305f2524d26cf2b32a7d62","user":{"login":"eth-cscs","id":5744410,"avatar_url":"https://avatars0.githubusercontent.com/u/5744410?v=4","gravatar_id":"","url":"https://api.github.com/users/eth-cscs","html_url":"https://github.com/eth-cscs","followers_url":"https://api.github.com/users/eth-cscs/followers","following_url":"https://api.github.com/users/eth-cscs/following{/other_user}","gists_url":"https://api.github.com/users/eth-cscs/gists{/gist_id}","starred_url":"https://api.github.com/users/eth-cscs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eth-cscs/subscriptions","organizations_url":"https://api.github.com/users/eth-cscs/orgs","repos_url":"https://api.github.com/users/eth-cscs/repos","events_url":"https://api.github.com/users/eth-cscs/events{/privacy}","received_events_url":"https://api.github.com/users/eth-cscs/received_events","type":"Organization","site_admin":false},"repo":{"id":69863074,"name":"arbor","full_name":"eth-cscs/arbor","owner":{"login":"eth-cscs","id":5744410,"avatar_url":"https://avatars0.githubusercontent.com/u/5744410?v=4","gravatar_id":"","url":"https://api.github.com/users/eth-cscs","html_url":"https://github.com/eth-cscs","followers_url":"https://api.github.com/users/eth-cscs/followers","following_url":"https://api.github.com/users/eth-cscs/following{/other_user}","gists_url":"https://api.github.com/users/eth-cscs/gists{/gist_id}","starred_url":"https://api.github.com/users/eth-cscs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eth-cscs/subscriptions","organizations_url":"https://api.github.com/users/eth-cscs/orgs","repos_url":"https://api.github.com/users/eth-cscs/repos","events_url":"https://api.github.com/users/eth-cscs/events{/privacy}","received_events_url":"https://api.github.com/users/eth-cscs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/eth-cscs/arbor","description":"The Arbor multi-compartment neural network simulation library.","fork":false,"url":"https://api.github.com/repos/eth-cscs/arbor","forks_url":"https://api.github.com/repos/eth-cscs/arbor/forks","keys_url":"https://api.github.com/repos/eth-cscs/arbor/keys{/key_id}","collaborators_url":"https://api.github.com/repos/eth-cscs/arbor/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/eth-cscs/arbor/teams","hooks_url":"https://api.github.com/repos/eth-cscs/arbor/hooks","issue_events_url":"https://api.github.com/repos/eth-cscs/arbor/issues/events{/number}","events_url":"https://api.github.com/repos/eth-cscs/arbor/events","assignees_url":"https://api.github.com/repos/eth-cscs/arbor/assignees{/user}","branches_url":"https://api.github.com/repos/eth-cscs/arbor/branches{/branch}","tags_url":"https://api.github.com/repos/eth-cscs/arbor/tags","blobs_url":"https://api.github.com/repos/eth-cscs/arbor/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/eth-cscs/arbor/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/eth-cscs/arbor/git/refs{/sha}","trees_url":"https://api.github.com/repos/eth-cscs/arbor/git/trees{/sha}","statuses_url":"https://api.github.com/repos/eth-cscs/arbor/statuses/{sha}","languages_url":"https://api.github.com/repos/eth-cscs/arbor/languages","stargazers_url":"https://api.github.com/repos/eth-cscs/arbor/stargazers","contributors_url":"https://api.github.com/repos/eth-cscs/arbor/contributors","subscribers_url":"https://api.github.com/repos/eth-cscs/arbor/subscribers","subscription_url":"https://api.github.com/repos/eth-cscs/arbor/subscription","commits_url":"https://api.github.com/repos/eth-cscs/arbor/commits{/sha}","git_commits_url":"https://api.github.com/repos/eth-cscs/arbor/git/commits{/sha}","comments_url":"https://api.github.com/repos/eth-cscs/arbor/comments{/number}","issue_comment_url":"https://api.github.com/repos/eth-cscs/arbor/issues/comments{/number}","contents_url":"https://api.github.com/repos/eth-cscs/arbor/contents/{+path}","compare_url":"https://api.github.com/repos/eth-cscs/arbor/compare/{base}...{head}","merges_url":"https://api.github.com/repos/eth-cscs/arbor/merges","archive_url":"https://api.github.com/repos/eth-cscs/arbor/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/eth-cscs/arbor/downloads","issues_url":"https://api.github.com/repos/eth-cscs/arbor/issues{/number}","pulls_url":"https://api.github.com/repos/eth-cscs/arbor/pulls{/number}","milestones_url":"https://api.github.com/repos/eth-cscs/arbor/milestones{/number}","notifications_url":"https://api.github.com/repos/eth-cscs/arbor/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/eth-cscs/arbor/labels{/name}","releases_url":"https://api.github.com/repos/eth-cscs/arbor/releases{/id}","deployments_url":"https://api.github.com/repos/eth-cscs/arbor/deployments","created_at":"2016-10-03T11:03:22Z","updated_at":"2018-03-15T13:07:12Z","pushed_at":"2018-03-15T13:52:42Z","git_url":"git://github.com/eth-cscs/arbor.git","ssh_url":"git@github.com:eth-cscs/arbor.git","clone_url":"https://github.com/eth-cscs/arbor.git","svn_url":"https://github.com/eth-cscs/arbor","homepage":"https://eth-cscs.github.io/nestmc/","size":3045,"stargazers_count":12,"watchers_count":12,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":13,"mirror_url":null,"archived":false,"open_issues_count":84,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":13,"open_issues":84,"watchers":12,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/eth-cscs/arbor/pulls/450"},"html":{"href":"https://github.com/eth-cscs/arbor/pull/450"},"issue":{"href":"https://api.github.com/repos/eth-cscs/arbor/issues/450"},"comments":{"href":"https://api.github.com/repos/eth-cscs/arbor/issues/450/comments"},"review_comments":{"href":"https://api.github.com/repos/eth-cscs/arbor/pulls/450/comments"},"review_comment":{"href":"https://api.github.com/repos/eth-cscs/arbor/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/eth-cscs/arbor/pulls/450/commits"},"statuses":{"href":"https://api.github.com/repos/eth-cscs/arbor/statuses/d1cf9c8f13d8b81c9254aeae87f54db888228901"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"bcumming"}}