Skip to content
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

Add SmartField usage to some legacy algorithms #1236

Merged
merged 6 commits into from
Apr 5, 2024
Merged

Conversation

psakievich
Copy link
Contributor

@djglaze would it be possible to include the updates from #1233 for just the SmartField/FieldManager accessors? I would like to use fieldManager_.get_legacy_smart_field<double>("temperature") for the conversion process. My thought is if we update this interface then we can just make the update to simple fields as we convert to smart fields. I started playing with it but I got some type mismatch issues.

I'm also considering if I can make the FeildRegistry a constexpr type using the compile time const map from Jason Turner's training. Maybe we can just move the field type analysis to compile time and remove some templates if we revisit that design. @overfelt and @alanw0 you guys might be interested in that as well.

@psakievich psakievich self-assigned this Feb 4, 2024
}
}
thermalCond_->modify_on_host();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's nice to be able to remove these modify and sync calls.

const std::string& name,
const stk::mesh::PartVector& parts,
const int numStates = 0,
const int numComponents = 0,
const void* init_val = nullptr);
const void* init_val = nullptr) const;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious how field registry can be a compile-time definition, if it depends on a part-vector which would have run-time contents.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking the type look up could be moved to compile time so that when fields are accessed we wouldn't have to include the type. Registry would still have to be runtime. However, looking at the dependencies I'm not sure I want to do that anymore. We'd have to expose more of the field information across the code base instead of isolating it to a single *.C file. This could wreak havoc on the compile times. After we convert to the simple fields the type information becomes way less cumbersome for accessing fields. So I think we should keep it as is.

@djglaze
Copy link
Contributor

djglaze commented Feb 5, 2024

@psakievich I think that's a great idea! Both old-style and new-style Fields can coexist just fine, so an incremental conversion like this should work. We won't be able to "pull the trigger" and switch over completely (with a call to MetaData::use_simple_fields()) until everything is converted, which means that things like the coordinates Field that is auto-registered on our behalf during mesh read will remain as an old-style Field. That's fine, though.

We will still have to convert a few parts of nalu-wind beyond just the SmartField and FieldManager, like some compile-time algorithm selection code that is based on the template parameters that are being removed. We need to base them on run-time queries of the Field size and shape, instead. This shouldn't be a big deal since I've already got that figured out.

I'll get to work right away on this. I'll base my changes on current master nalu-wind, with this SmartField commit applied.

@psakievich
Copy link
Contributor Author

@djglaze Sounds great. I like that we have a compile time check for checking when we are close to converting all the fields. I think it will go relatively quickly and should be a net code reduction. Algorithms are straightforward to convert. I need to look at the machinery behind the kernels next. Once I get that squared away we should be able to do a group conversion swarm on the entire code base.

@djglaze
Copy link
Contributor

djglaze commented Feb 5, 2024

@psakievich Upon closer inspection, I'm going to temper my enthusiasm for this approach. It would be a much bigger change than I was thinking, and it would make your FieldManager conversions a lot harder.

The issue is all of the Field typedefs like VectorFieldType, TensorFieldType, etc. Those have to change with this conversion. I think the cleanest approach would be to have two different sets of all of these typedefs, one old-style and one new-style. We would have to change all uses in the code to one or the other, depending on if it has been converted to use the FieldManager or not. Then, when you're doing your normal FieldManager conversions, you would need to change all of the nearby typedefs to the new style. This sounds tedious and messy.

So, I'm now thinking that it would be best to save the simple_fields stuff until after a complete FieldManager and SmartField conversion. I think it would be easier for everybody involved.

@psakievich
Copy link
Contributor Author

@djglaze okay this sounds like what I ran up against when I tried to merge minimal changes from your PR into this one. I would say either way we have to extensively touch the code base twice. If you know what the issue was with the intel build it might be better to revive #1233 and do it first? We can revive it and test it on multiple machines before merging.

@djglaze
Copy link
Contributor

djglaze commented Feb 5, 2024

@psakievich I do know what the problem was with the original #1233 commit. I'd be perfectly happy with resurrecting that, if you like. From my testing on both gcc and Intel, I don't believe there are any other problems in there (other than the one that @jrood-nrel pointed out).

It's a big commit, but the work is already done and it shouldn't interfere with any of your upcoming FieldManager or SmartField conversions.

@psakievich
Copy link
Contributor Author

@djglaze that is what I am thinking too. I think if we do the SmartField stuff first you will have to do another very big commit again. So it is probably better to utilize the work you've already done prior to messing with the fields more.

@djglaze
Copy link
Contributor

djglaze commented Feb 5, 2024

@psakievich Cool. I'll get that going, then.

@psakievich psakievich marked this pull request as ready for review April 1, 2024 22:09
@psakievich psakievich merged commit 9e33aeb into master Apr 5, 2024
3 checks passed
@psakievich psakievich deleted the f/sf-algo branch April 5, 2024 21:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants