-
Notifications
You must be signed in to change notification settings - Fork 89
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
silence addDependentField warnings #34
Comments
@ibaned I'm surprised you are just seeing this now. That warning is not compiler dependent and has been in the code for some time. It is enabled by a trilinos configure time variable. If you want to turn those warnings off, use the flag: -D Phalanx_SHOW_DEPRECATED_WARNINGS:BOOL=OFF I would like to remove the deprecated code in the next major Trilinos release. Below are instructions for fixing: The warnings are to fix dependent fields for const correctness. Evaluators should NOT be allowed to change the values of "dependent" fields. To remove the warnings, you need to change every dependent field in every evaluator so that the scalar type is const: In your example: var = MDField<ScalarT, Cell, Point>(name, type) should be changed to: var = MDField<const ScalarT, Cell, Point>(name, type) and the declaration in the header should be changed from: MDField<ScalarT, Cell, Point> var to: MDField<const ScalarT, Cell, Point> var |
thanks @rppawlo ! I don't know how it didn't show up until now, but it seems we agree on the fix. Please give me a heads-up when you're going to commit the removal, likewise I'll let you know when Albany stops using the deprecated function. |
@ibaned It probably won't be for a while. As you mentioned - it is quite a lot of tedious work to fix everywhere. I'd like to shoot for the next major Trilinos release when we can break backwards compatibility. It's good to get everyone writing evaluators to use the new methods though :) |
I also ran into this issue only recently. I fixed it by replacing all the calls to addDependentField (field); with addDependenteField(field.fieldTag()); This compiles without warning, although it does not enforce const correctness. This makes me wondering whether FieldTag makes sense. Perhaps it would be better to replace it directly with Tag, which encodes also the underlying data type and can therefore enforce const correctness, on top of allowing distinction between fields with the same name and layout but different type (assuming this is useful somewhere). But this is probably a discussion that does not belong here. |
const correctness is important. in the process of working on this issue, I found that the Albany Helmholtz Residual is modifying one of its dependent fields. |
Oh, I agree. I did that just because I thought it was quicker with sed. But I am going to revert to const DataT instead. Are you planning to put this fix in master soon? Is it going to be in a fix branch? |
there is an |
@rppawlo is it possible to copy a |
@ibaned yes - you should be able assign a non-const field to a const scalar field. Internally all fields are stored non-const and at binding time, dependent fields are assigned to const scalar fields. There are some unit tests that exercise this: MDFields do mirror the view semantics of Kokkos::Views (with the added requirements of field tag consistency). If something is not working, please send code to reproduce the issue. |
I also should mention - if you use the field instead of the field tag to register evaluated and dependent fields, then you no longer need to bind the memory to the field manually with setFieldData() during postRegistrationSetup. If you addDependentField/addEvaluatedField with the field tag, then you have to bind the memory manually as usual. |
So for context, the reason I want to assign to typedef PHX::MDALayout<Cell, QuadPoint, Dim, Dim> Layout;
Teuchos::RCP<Layout> layout = Teuchos::rcp(
new Layout(workset.numCells, coord_qp.dimension(1),
coord_qp.dimension(2), coord_qp.dimension(2)));
PHX::MDField<RealType> f_mdf = PHX::MDField<RealType>("f_mdf", layout);
f_mdf.setFieldData(
PHX::KokkosViewFactory<RealType, PHX::Device>::buildView(f_mdf.fieldTag())); I tried the following: PHX::MDField<const RealType> f_mdf_const = f_mdf; Which gave me this error:
I've since then switched to doing this: auto f_mdf_data = PHX::KokkosViewFactory<RealType, PHX::Device>::buildView(f_mdf.fieldTag());
f_mdf.setFieldData(f_mdf_data);
PHX::MDField<const RealType> f_mdf_const("f_mdf_const", layout);
f_mdf_const.setFieldData(f_mdf_data); |
That should work. I will add a ticket to trilinos, add appropriate testing and fix. Sorry you had to jump through that hoop. |
Now that I think about it, if this did work, then there would only need to be one |
this doesn't compile and is blocking on resolution of trilinos/Trilinos#1063
thanks to @rppawlo for resolving trilinos/Trilinos#1063 which made this progress possible.
merging current progress on issue #34. there is still a bit of work needed to complete issue #34, but the bugs introduced along the way have convinced me that refactoring should take place in small increments on master and not a very long-lived branch. several bugs were fixed and CTest gives the same results on my machine before/after this merge, but likely others will be exposed by the full dashboard.
reverting the issue #34 merge as many compile errors came up on this morning's dashboards
the renaming of local/global response vectors broke these evaluators, this commit should fix them.
this will only compile with trilinos/Trilinos@7846c2e
Well, after much hard work I think I've fixed this issue in the subset of Albany which I enabled, namely ATO, LCM, FELIX, QUAD, and of course PHAL. Those changes have been merged, and if the subsequent dashboard testing looks good, this issue can be closed. |
The dashboard and I have finally reached a truce. I'm closing this until it pops up again. |
This compiles now, but is untested as of yet.
looks like Hydride might still need this. Who uses Hydride ? |
This is a regression w.r.t. #34 Remember to make your dependent fields const!
I think this can be closed. Hydride is not even supported in Albany anymore. |
newer GCC versions (6.2.0 for one) are warning about usage of a deprecated variant of addDependentField. Basically, it seems the right thing to do is to declare your dependent fields with
const
data types, soconst ScalarT
instead of justScalarT
. This is a big job to do throughout Albany, but fairly straightforward.The text was updated successfully, but these errors were encountered: