-
Notifications
You must be signed in to change notification settings - Fork 25
Ksagiyam/tsfc refactor 1 #261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
5cff887 to
4d2358d
Compare
1280275 to
2395192
Compare
tsfc/driver.py
Outdated
| self.domain_number = domain_number | ||
| self.coefficients = coefficients | ||
| self.coefficient_numbers = coefficient_numbers | ||
| super(TSFCIntegralDataInfo, self).__init__() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is an immutable object does it make sense for it just to be a NamedTuple?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes! Fixed.
tsfc/kernel_interface/common.py
Outdated
| class KernelBuilderMixin(object): | ||
| """Mixin for KernelBuilder classes.""" | ||
|
|
||
| @cached_property |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turn this into a function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
| """Mixin for KernelBuilder classes.""" | ||
|
|
||
| @cached_property | ||
| def fem_config(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docstring please!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added.
tsfc/kernel_interface/firedrake.py
Outdated
| subdomain_id = integral_data_info.subdomain_id | ||
| domain_number = integral_data_info.domain_number | ||
| super(KernelBuilder, self).__init__(scalar_type, integral_type.startswith("interior_facet")) | ||
| self.fem_scalar_type = fem_scalar_type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactor so that parameters["scalar_type"] is the only thing that is passed in and the coffee builder constructs the C-name of the type internally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then we don't need to pass two scalar types that are generally the same here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Fixed using coffee.base.as_cstr().
2395192 to
4793fc4
Compare
tsfc/kernel_interface/common.py
Outdated
| class KernelBuilderMixin(object): | ||
| """Mixin for KernelBuilder classes.""" | ||
|
|
||
| def compile_ufl(self, integrand, params, ctx): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Call this compile_integrand ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
tsfc/kernel_interface/common.py
Outdated
| """Compile UFL integrand. | ||
| :arg integrand: UFL integrand. | ||
| :arg params: a dict of parameters containing quadrature info. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does ctx need a docstring?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Added.
| self.argument_multiindices, | ||
| params) | ||
|
|
||
| def stash_integrals(self, reps, params, ctx): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docstring
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added.
| for var, rep in zip(self.return_variables, reps): | ||
| mode_irs[mode].setdefault(var, []).append(rep) | ||
|
|
||
| def compile_gem(self, ctx): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docstring please.
Can we also document (somewhere, maybe not here) the interface that ctx must offer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added more texts under KernelBuilderMixin.create_context method.
| """ | ||
| def __init__(self, ast=None, integral_type=None, oriented=False, | ||
| subdomain_id=None, domain_number=None, quadrature_rule=None, | ||
| subdomain_id=None, domain_number=None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The quadrature rule is used by themis: https://github.com/celdred/themis, maybe instead of dropping it replace this commit with a comment that that is what it is for.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@celdred what is themis' status?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder what themis is expecting from quad_rule. quad_rule is a local variable in for integral in integral_data.integrals loop (https://github.com/firedrakeproject/tsfc/blob/master/tsfc/driver.py#L193), but the last value it happens to take is passed to builder.construct_kernel(...) (https://github.com/firedrakeproject/tsfc/blob/master/tsfc/driver.py#L266), which themis seems to require.
4793fc4 to
fc66951
Compare
fc66951 to
c260ac8
Compare
c260ac8 to
4a1cd20
Compare
Breaking #234 into smaller pieces (Phase 1)
This PR attempts to refactor TSFC.
Firedrake PR firedrakeproject/firedrake#2200 must follow this.