{"action":"created","comment":{"url":"https://api.github.com/repos/firedrakeproject/firedrake/pulls/comments/92394888","pull_request_review_id":12908680,"id":92394888,"diff_hunk":"@@ -0,0 +1,324 @@\n+\"\"\"This is SLATE's Linear Algebra Compiler. This module is responsible for generating\n+C++ kernel functions representing symbolic linear algebra expressions written in SLATE.\n+\n+This linear algebra compiler uses both Firedrake's form compiler, the Two-Stage\n+Form Compiler (TSFC) and COFFEE's kernel abstract syntax tree (AST) optimizer. TSFC\n+provides this compiler with appropriate kernel functions (in C) for evaluating integral\n+expressions (finite element variational forms written in UFL). COFFEE's AST optimizing\n+framework produces the resulting kernel AST returned by: `compile_slate_expression`.\n+\n+The Eigen C++ library (http://eigen.tuxfamily.org/) is required, as all low-level numerical\n+linear algebra operations are performed using the `Eigen::Matrix` methods built into Eigen.\n+\"\"\"\n+from __future__ import absolute_import, print_function, division\n+\n+import petsc\n+\n+from coffee import base as ast\n+\n+from firedrake.constant import Constant\n+from firedrake.tsfc_interface import SplitKernel, KernelInfo\n+from firedrake.slate.slate import (TensorBase, Tensor,\n+                                   Transpose, Inverse, Negative,\n+                                   Add, Sub, Mul, Action)\n+from firedrake.slate.slac.kernel_builder import KernelBuilder\n+from firedrake import op2\n+\n+from tsfc.parameters import SCALAR_TYPE\n+\n+from ufl.coefficient import Coefficient\n+\n+\n+__all__ = ['compile_expression']\n+\n+\n+def compile_expression(slate_expr, tsfc_parameters=None):\n+    \"\"\"Takes a SLATE expression `slate_expr` and returns the appropriate\n+    :class:`firedrake.op2.Kernel` object representing the SLATE expression.\n+\n+    :arg slate_expr: a :class:'TensorBase' expression.\n+\n+    :arg tsfc_parameters: an optional `dict` of form compiler parameters to\n+                          be passed onto TSFC during the compilation of ufl forms.\n+    \"\"\"\n+    if not isinstance(slate_expr, TensorBase):\n+        raise ValueError(\"Expecting a `slate.TensorBase` expression, not a %r\" % slate_expr)\n+\n+    # TODO: Get PyOP2 to write into mixed dats\n+    if any(len(a.function_space()) > 1 for a in slate_expr.arguments()):\n+        raise NotImplementedError(\"Compiling mixed slate expressions\")\n+\n+    # Initialize shape and statements list\n+    shape = slate_expr.shape\n+    statements = []\n+\n+    # Create a builder for the SLATE expression\n+    builder = KernelBuilder(expression=slate_expr, tsfc_parameters=tsfc_parameters)\n+\n+    # Initialize coordinate and facet symbols\n+    coordsym = ast.Symbol(\"coords\")\n+    coords = None\n+    cellfacetsym = ast.Symbol(\"cell_facets\")\n+    inc = []\n+\n+    # Now we construct the list of statements to provide to the builder\n+    context_temps = builder.temps.copy()\n+    for exp, t in context_temps.items():\n+        statements.append(ast.Decl(eigen_matrixbase_type(exp.shape), t))\n+        statements.append(ast.FlatBlock(\"%s.setZero();\\n\" % t))\n+\n+        for splitkernel in builder.kernel_exprs[exp]:\n+            clist = []\n+            index = splitkernel.indices\n+            kinfo = splitkernel.kinfo\n+            integral_type = kinfo.integral_type\n+\n+            if integral_type not in [\"cell\", \"interior_facet\", \"exterior_facet\"]:\n+                raise NotImplementedError(\"Integral type %s not currently supported.\" % integral_type)\n+\n+            coordinates = exp.ufl_domain().coordinates\n+            if coords is not None:\n+                assert coordinates == coords\n+            else:\n+                coords = coordinates\n+\n+            for cindex in kinfo.coefficient_map:\n+                c = exp.coefficients()[cindex]\n+                clist.append(builder.coefficient_map()[c])","path":"firedrake/slate/slac/compiler.py","position":87,"original_position":87,"commit_id":"9dfc1202434ed6c5f35ec7b42b2894ea9e654179","original_commit_id":"9dfc1202434ed6c5f35ec7b42b2894ea9e654179","user":{"login":"wence-","id":1126981,"avatar_url":"https://avatars.githubusercontent.com/u/1126981?v=3","gravatar_id":"","url":"https://api.github.com/users/wence-","html_url":"https://github.com/wence-","followers_url":"https://api.github.com/users/wence-/followers","following_url":"https://api.github.com/users/wence-/following{/other_user}","gists_url":"https://api.github.com/users/wence-/gists{/gist_id}","starred_url":"https://api.github.com/users/wence-/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wence-/subscriptions","organizations_url":"https://api.github.com/users/wence-/orgs","repos_url":"https://api.github.com/users/wence-/repos","events_url":"https://api.github.com/users/wence-/events{/privacy}","received_events_url":"https://api.github.com/users/wence-/received_events","type":"User","site_admin":false},"body":"tsfc splits mixed coefficients (I think), is that taken into account here somehow?","created_at":"2016-12-14T13:47:13Z","updated_at":"2016-12-14T13:47:13Z","html_url":"https://github.com/firedrakeproject/firedrake/pull/942#discussion_r92394888","pull_request_url":"https://api.github.com/repos/firedrakeproject/firedrake/pulls/942","_links":{"self":{"href":"https://api.github.com/repos/firedrakeproject/firedrake/pulls/comments/92394888"},"html":{"href":"https://github.com/firedrakeproject/firedrake/pull/942#discussion_r92394888"},"pull_request":{"href":"https://api.github.com/repos/firedrakeproject/firedrake/pulls/942"}}},"pull_request":{"url":"https://api.github.com/repos/firedrakeproject/firedrake/pulls/942","id":93437153,"html_url":"https://github.com/firedrakeproject/firedrake/pull/942","diff_url":"https://github.com/firedrakeproject/firedrake/pull/942.diff","patch_url":"https://github.com/firedrakeproject/firedrake/pull/942.patch","issue_url":"https://api.github.com/repos/firedrakeproject/firedrake/issues/942","number":942,"state":"open","locked":false,"title":"Introducing SLATE","user":{"login":"thomasgibson","id":14180421,"avatar_url":"https://avatars.githubusercontent.com/u/14180421?v=3","gravatar_id":"","url":"https://api.github.com/users/thomasgibson","html_url":"https://github.com/thomasgibson","followers_url":"https://api.github.com/users/thomasgibson/followers","following_url":"https://api.github.com/users/thomasgibson/following{/other_user}","gists_url":"https://api.github.com/users/thomasgibson/gists{/gist_id}","starred_url":"https://api.github.com/users/thomasgibson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thomasgibson/subscriptions","organizations_url":"https://api.github.com/users/thomasgibson/orgs","repos_url":"https://api.github.com/users/thomasgibson/repos","events_url":"https://api.github.com/users/thomasgibson/events{/privacy}","received_events_url":"https://api.github.com/users/thomasgibson/received_events","type":"User","site_admin":false},"body":"SLATE is a symbolic framework for expressing linear algebra operations on the matrices, vectors and scalars associated with finite element forms. A direct example of why such a framework is useful can be seen when hybridizing a mixed method. This framework allows one to locally write down the finite element forms, assemble symbolic `slate.TensorBase` objects and write out the Schur reduction. An example of this can be seen in the regression test `test_slate_hybridization.py`. In addition, the element-wise reconstruction of unknowns can also be done in SLATE (as demonstrated in the same hybridization test).\r\n\r\nThis PR contains the SLATE language in its current form and numerous regression tests that test its basic infrastructure. SLATE requires the Eigen C++ template library, and changes were made accordingly to the `firedrake-install` script to download Eigen via a `petsc` option flag `--download-eigen`.","created_at":"2016-11-12T12:05:24Z","updated_at":"2016-12-14T13:47:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"345b4e8a995d0f68d42b59b60c0261e7168cecc4","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/firedrakeproject/firedrake/pulls/942/commits","review_comments_url":"https://api.github.com/repos/firedrakeproject/firedrake/pulls/942/comments","review_comment_url":"https://api.github.com/repos/firedrakeproject/firedrake/pulls/comments{/number}","comments_url":"https://api.github.com/repos/firedrakeproject/firedrake/issues/942/comments","statuses_url":"https://api.github.com/repos/firedrakeproject/firedrake/statuses/9dfc1202434ed6c5f35ec7b42b2894ea9e654179","head":{"label":"firedrakeproject:static-condensation","ref":"static-condensation","sha":"9dfc1202434ed6c5f35ec7b42b2894ea9e654179","user":{"login":"firedrakeproject","id":5558005,"avatar_url":"https://avatars.githubusercontent.com/u/5558005?v=3","gravatar_id":"","url":"https://api.github.com/users/firedrakeproject","html_url":"https://github.com/firedrakeproject","followers_url":"https://api.github.com/users/firedrakeproject/followers","following_url":"https://api.github.com/users/firedrakeproject/following{/other_user}","gists_url":"https://api.github.com/users/firedrakeproject/gists{/gist_id}","starred_url":"https://api.github.com/users/firedrakeproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/firedrakeproject/subscriptions","organizations_url":"https://api.github.com/users/firedrakeproject/orgs","repos_url":"https://api.github.com/users/firedrakeproject/repos","events_url":"https://api.github.com/users/firedrakeproject/events{/privacy}","received_events_url":"https://api.github.com/users/firedrakeproject/received_events","type":"Organization","site_admin":false},"repo":{"id":13384052,"name":"firedrake","full_name":"firedrakeproject/firedrake","owner":{"login":"firedrakeproject","id":5558005,"avatar_url":"https://avatars.githubusercontent.com/u/5558005?v=3","gravatar_id":"","url":"https://api.github.com/users/firedrakeproject","html_url":"https://github.com/firedrakeproject","followers_url":"https://api.github.com/users/firedrakeproject/followers","following_url":"https://api.github.com/users/firedrakeproject/following{/other_user}","gists_url":"https://api.github.com/users/firedrakeproject/gists{/gist_id}","starred_url":"https://api.github.com/users/firedrakeproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/firedrakeproject/subscriptions","organizations_url":"https://api.github.com/users/firedrakeproject/orgs","repos_url":"https://api.github.com/users/firedrakeproject/repos","events_url":"https://api.github.com/users/firedrakeproject/events{/privacy}","received_events_url":"https://api.github.com/users/firedrakeproject/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/firedrakeproject/firedrake","description":"Firedrake is an automated system for the portable solution of partial differential equations using the finite element method (FEM)","fork":false,"url":"https://api.github.com/repos/firedrakeproject/firedrake","forks_url":"https://api.github.com/repos/firedrakeproject/firedrake/forks","keys_url":"https://api.github.com/repos/firedrakeproject/firedrake/keys{/key_id}","collaborators_url":"https://api.github.com/repos/firedrakeproject/firedrake/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/firedrakeproject/firedrake/teams","hooks_url":"https://api.github.com/repos/firedrakeproject/firedrake/hooks","issue_events_url":"https://api.github.com/repos/firedrakeproject/firedrake/issues/events{/number}","events_url":"https://api.github.com/repos/firedrakeproject/firedrake/events","assignees_url":"https://api.github.com/repos/firedrakeproject/firedrake/assignees{/user}","branches_url":"https://api.github.com/repos/firedrakeproject/firedrake/branches{/branch}","tags_url":"https://api.github.com/repos/firedrakeproject/firedrake/tags","blobs_url":"https://api.github.com/repos/firedrakeproject/firedrake/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/firedrakeproject/firedrake/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/firedrakeproject/firedrake/git/refs{/sha}","trees_url":"https://api.github.com/repos/firedrakeproject/firedrake/git/trees{/sha}","statuses_url":"https://api.github.com/repos/firedrakeproject/firedrake/statuses/{sha}","languages_url":"https://api.github.com/repos/firedrakeproject/firedrake/languages","stargazers_url":"https://api.github.com/repos/firedrakeproject/firedrake/stargazers","contributors_url":"https://api.github.com/repos/firedrakeproject/firedrake/contributors","subscribers_url":"https://api.github.com/repos/firedrakeproject/firedrake/subscribers","subscription_url":"https://api.github.com/repos/firedrakeproject/firedrake/subscription","commits_url":"https://api.github.com/repos/firedrakeproject/firedrake/commits{/sha}","git_commits_url":"https://api.github.com/repos/firedrakeproject/firedrake/git/commits{/sha}","comments_url":"https://api.github.com/repos/firedrakeproject/firedrake/comments{/number}","issue_comment_url":"https://api.github.com/repos/firedrakeproject/firedrake/issues/comments{/number}","contents_url":"https://api.github.com/repos/firedrakeproject/firedrake/contents/{+path}","compare_url":"https://api.github.com/repos/firedrakeproject/firedrake/compare/{base}...{head}","merges_url":"https://api.github.com/repos/firedrakeproject/firedrake/merges","archive_url":"https://api.github.com/repos/firedrakeproject/firedrake/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/firedrakeproject/firedrake/downloads","issues_url":"https://api.github.com/repos/firedrakeproject/firedrake/issues{/number}","pulls_url":"https://api.github.com/repos/firedrakeproject/firedrake/pulls{/number}","milestones_url":"https://api.github.com/repos/firedrakeproject/firedrake/milestones{/number}","notifications_url":"https://api.github.com/repos/firedrakeproject/firedrake/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/firedrakeproject/firedrake/labels{/name}","releases_url":"https://api.github.com/repos/firedrakeproject/firedrake/releases{/id}","deployments_url":"https://api.github.com/repos/firedrakeproject/firedrake/deployments","created_at":"2013-10-07T13:07:44Z","updated_at":"2016-11-14T03:27:08Z","pushed_at":"2016-12-14T13:33:54Z","git_url":"git://github.com/firedrakeproject/firedrake.git","ssh_url":"git@github.com:firedrakeproject/firedrake.git","clone_url":"https://github.com/firedrakeproject/firedrake.git","svn_url":"https://github.com/firedrakeproject/firedrake","homepage":"http://firedrakeproject.org","size":16466,"stargazers_count":45,"watchers_count":45,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":26,"mirror_url":null,"open_issues_count":62,"forks":26,"open_issues":62,"watchers":45,"default_branch":"master"}},"base":{"label":"firedrakeproject:master","ref":"master","sha":"8c810842145d7d44f4e1f9e03b17f0484773af0f","user":{"login":"firedrakeproject","id":5558005,"avatar_url":"https://avatars.githubusercontent.com/u/5558005?v=3","gravatar_id":"","url":"https://api.github.com/users/firedrakeproject","html_url":"https://github.com/firedrakeproject","followers_url":"https://api.github.com/users/firedrakeproject/followers","following_url":"https://api.github.com/users/firedrakeproject/following{/other_user}","gists_url":"https://api.github.com/users/firedrakeproject/gists{/gist_id}","starred_url":"https://api.github.com/users/firedrakeproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/firedrakeproject/subscriptions","organizations_url":"https://api.github.com/users/firedrakeproject/orgs","repos_url":"https://api.github.com/users/firedrakeproject/repos","events_url":"https://api.github.com/users/firedrakeproject/events{/privacy}","received_events_url":"https://api.github.com/users/firedrakeproject/received_events","type":"Organization","site_admin":false},"repo":{"id":13384052,"name":"firedrake","full_name":"firedrakeproject/firedrake","owner":{"login":"firedrakeproject","id":5558005,"avatar_url":"https://avatars.githubusercontent.com/u/5558005?v=3","gravatar_id":"","url":"https://api.github.com/users/firedrakeproject","html_url":"https://github.com/firedrakeproject","followers_url":"https://api.github.com/users/firedrakeproject/followers","following_url":"https://api.github.com/users/firedrakeproject/following{/other_user}","gists_url":"https://api.github.com/users/firedrakeproject/gists{/gist_id}","starred_url":"https://api.github.com/users/firedrakeproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/firedrakeproject/subscriptions","organizations_url":"https://api.github.com/users/firedrakeproject/orgs","repos_url":"https://api.github.com/users/firedrakeproject/repos","events_url":"https://api.github.com/users/firedrakeproject/events{/privacy}","received_events_url":"https://api.github.com/users/firedrakeproject/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/firedrakeproject/firedrake","description":"Firedrake is an automated system for the portable solution of partial differential equations using the finite element method (FEM)","fork":false,"url":"https://api.github.com/repos/firedrakeproject/firedrake","forks_url":"https://api.github.com/repos/firedrakeproject/firedrake/forks","keys_url":"https://api.github.com/repos/firedrakeproject/firedrake/keys{/key_id}","collaborators_url":"https://api.github.com/repos/firedrakeproject/firedrake/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/firedrakeproject/firedrake/teams","hooks_url":"https://api.github.com/repos/firedrakeproject/firedrake/hooks","issue_events_url":"https://api.github.com/repos/firedrakeproject/firedrake/issues/events{/number}","events_url":"https://api.github.com/repos/firedrakeproject/firedrake/events","assignees_url":"https://api.github.com/repos/firedrakeproject/firedrake/assignees{/user}","branches_url":"https://api.github.com/repos/firedrakeproject/firedrake/branches{/branch}","tags_url":"https://api.github.com/repos/firedrakeproject/firedrake/tags","blobs_url":"https://api.github.com/repos/firedrakeproject/firedrake/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/firedrakeproject/firedrake/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/firedrakeproject/firedrake/git/refs{/sha}","trees_url":"https://api.github.com/repos/firedrakeproject/firedrake/git/trees{/sha}","statuses_url":"https://api.github.com/repos/firedrakeproject/firedrake/statuses/{sha}","languages_url":"https://api.github.com/repos/firedrakeproject/firedrake/languages","stargazers_url":"https://api.github.com/repos/firedrakeproject/firedrake/stargazers","contributors_url":"https://api.github.com/repos/firedrakeproject/firedrake/contributors","subscribers_url":"https://api.github.com/repos/firedrakeproject/firedrake/subscribers","subscription_url":"https://api.github.com/repos/firedrakeproject/firedrake/subscription","commits_url":"https://api.github.com/repos/firedrakeproject/firedrake/commits{/sha}","git_commits_url":"https://api.github.com/repos/firedrakeproject/firedrake/git/commits{/sha}","comments_url":"https://api.github.com/repos/firedrakeproject/firedrake/comments{/number}","issue_comment_url":"https://api.github.com/repos/firedrakeproject/firedrake/issues/comments{/number}","contents_url":"https://api.github.com/repos/firedrakeproject/firedrake/contents/{+path}","compare_url":"https://api.github.com/repos/firedrakeproject/firedrake/compare/{base}...{head}","merges_url":"https://api.github.com/repos/firedrakeproject/firedrake/merges","archive_url":"https://api.github.com/repos/firedrakeproject/firedrake/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/firedrakeproject/firedrake/downloads","issues_url":"https://api.github.com/repos/firedrakeproject/firedrake/issues{/number}","pulls_url":"https://api.github.com/repos/firedrakeproject/firedrake/pulls{/number}","milestones_url":"https://api.github.com/repos/firedrakeproject/firedrake/milestones{/number}","notifications_url":"https://api.github.com/repos/firedrakeproject/firedrake/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/firedrakeproject/firedrake/labels{/name}","releases_url":"https://api.github.com/repos/firedrakeproject/firedrake/releases{/id}","deployments_url":"https://api.github.com/repos/firedrakeproject/firedrake/deployments","created_at":"2013-10-07T13:07:44Z","updated_at":"2016-11-14T03:27:08Z","pushed_at":"2016-12-14T13:33:54Z","git_url":"git://github.com/firedrakeproject/firedrake.git","ssh_url":"git@github.com:firedrakeproject/firedrake.git","clone_url":"https://github.com/firedrakeproject/firedrake.git","svn_url":"https://github.com/firedrakeproject/firedrake","homepage":"http://firedrakeproject.org","size":16466,"stargazers_count":45,"watchers_count":45,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":26,"mirror_url":null,"open_issues_count":62,"forks":26,"open_issues":62,"watchers":45,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/firedrakeproject/firedrake/pulls/942"},"html":{"href":"https://github.com/firedrakeproject/firedrake/pull/942"},"issue":{"href":"https://api.github.com/repos/firedrakeproject/firedrake/issues/942"},"comments":{"href":"https://api.github.com/repos/firedrakeproject/firedrake/issues/942/comments"},"review_comments":{"href":"https://api.github.com/repos/firedrakeproject/firedrake/pulls/942/comments"},"review_comment":{"href":"https://api.github.com/repos/firedrakeproject/firedrake/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/firedrakeproject/firedrake/pulls/942/commits"},"statuses":{"href":"https://api.github.com/repos/firedrakeproject/firedrake/statuses/9dfc1202434ed6c5f35ec7b42b2894ea9e654179"}}}}
{"actor":{"display_login":"wence-"}}