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
Allow using float shape functions #9104
Conversation
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.
Extending to float
is a good idea. However, lets first discuss on the style (especially from the background that we might want in the future multiple shape_values
; e.g. different polynomial degrees, over-integration).
global_shape_values_d[(max_elem_degree + 1) * (max_elem_degree + 1)]; | ||
__constant__ float | ||
global_shape_values_f[(max_elem_degree + 1) * (max_elem_degree + 1)]; |
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.
This looks ugly. Any chance to create a struct like:
template<typename T>
struct ShapeData
{
T global_shape_values[(max_elem_degree + 1) * (max_elem_degree + 1)];
T global_shape_gradients[(max_elem_degree + 1) * (max_elem_degree + 1)];
T global_co_shape_gradients[(max_elem_degree + 1) * (max_elem_degree + 1)];
}
In the long term, it would be nice to be able to write __constant__ ShapeData<Number, degree, q_points>
or s.th. similar. It would be nice to have as much flexibility as in the case of the CPU version.
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.
Not a bad suggestion even if helps only slightly. We still need separate global __constant__
variables (function scope static
variables are also not allowed) and this is also the reason that we can't templatize on degree
and n_q_points
in a meaningful way. These arrays have to exist independent of the polynomial degree. Of course, we could create separate arrays, but that would only waste space.
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 give up on improving this. Accessing __constant__
memory seems to be really brittle. If you pass a pointer instead of a reference to a C-style array or try to use a struct
for structuring the data better, you always get an invalid device symbol
error.
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 you pass a pointer instead of a reference to a C-style
I also tried that out some time ago; I had the same conclusion :( Thanks for trying out the struct approach! Let's merge!
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.
Nice!
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!
I had to discard the |
82c3588
to
5b28e6d
Compare
Previously, we were not able to compile with
float
as number type sinceglobal_co_shape_gradients
/global_shape_gradients
/global_shape_values
weredouble
arrays.This pull request fixes the issue by duplicating the storage for
float
.