-
Notifications
You must be signed in to change notification settings - Fork 849
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
Restructuring of CVariable into a Contiguous Data Structure #753
Conversation
@@ -0,0 +1,370 @@ | |||
#pragma once |
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 is the container class I am planning to use to replace the data members of CVariable.
Where CVariable has a scalar it will have a column vector, and where it has an array it will have a row-major matrix (so it can still return the solution as a pointer to the beginning of a row), where it has a matrix we'll see... this supports nesting but at the moment that is only efficient if the inner type has a static size.
Following some of the comments in #716, it supports aligned memory allocation (c++11 required) and compile-time sizes (no dynamic allocation), which may eventually be used to create an "easily-vectorizable" type (e.g. vector of 4 doubles) to explore vectorization of the numerics.
I am hoping to eventually build some basic dense linear algebra capabilities to collect some of the functionality we have throughout the code. I am not a meta-programming expert though, so the interface for that might not be the most user friendly.
I will add the SU2 header to this file and fix the formatting soonish.
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.
Looks very good. It would also be nice to store Nodes of CEdge class in such a container.
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 @MicK7, CEdge does not have a lot of overhead since it does not have virtual members, but it does have some... I'll get there at some point.
…ix, matrix->mat of ptr
…su2code/SU2 into feature_contiguous_cvariable_PR
Solution_BGS[iVar] = 0.0; | ||
} | ||
|
||
Solution_BGS.resize(nPoint,nVar) = su2double(0.0); |
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 fixed 3 uninitialized warnings, maybe those are the ones you are referring to?
Yes, and this one has been the only critical one ;)
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 also needed Solution_Old
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.
Ok.. it should have had an influence on the residual computation only (it's fixed in the various fixes branch), as it's not used for the solution algorithm. Anyway, might suffice for a crash :p
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.
@economon, I noticed we were allocating Gradient
(of the conservatives) and RMatrix
for variable classes that do not need those fields, namely IncEuler, Euler, FEA, and DiscAdj.
I moved the allocation down to the derived constructors that do require them, and then noticed that the gradients of flow solver conservatives were still being accessed in the two places pointed below, should I delete the calls I commented out along with the associated routines?
@@ -311,8 +311,9 @@ void CIntegration::Adjoint_Setup(CGeometry ****geometry, CSolver *****solver_con | |||
if (iMGLevel != config[iZone]->GetnMGLevels()) { | |||
SetRestricted_Solution(RUNTIME_FLOW_SYS, solver_container[iZone][INST_0][iMGLevel][FLOW_SOL], solver_container[iZone][INST_0][iMGLevel+1][FLOW_SOL], | |||
geometry[iZone][INST_0][iMGLevel], geometry[iZone][INST_0][iMGLevel+1], config[iZone]); | |||
SetRestricted_Gradient(RUNTIME_FLOW_SYS, solver_container[iZone][INST_0][iMGLevel][FLOW_SOL], solver_container[iZone][INST_0][iMGLevel+1][FLOW_SOL], | |||
geometry[iZone][INST_0][iMGLevel], geometry[iZone][INST_0][iMGLevel+1], config[iZone]); | |||
// ToDo: The flow solvers do not use the conservative variable gradients |
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.
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.
Looks like this is outdated. If anything, it should be a restriction of the primitive gradient to make sure everything is well set in multigrid before the adjoint iteration.
I think it is worth trying to remove and see if the continuous adjoint cases fail in the regressions. If so, we can look into it further, since it might need to be adjusted.
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.
On the coarse grids the primitive gradients are never computed, they are only used for viscous residuals but they are zero at that point.
The continuous adjoint cases all pass without calling SetRestricted_Gradient
@@ -335,8 +335,9 @@ void CTransLMSolver::Viscous_Residual(CGeometry *geometry, CSolver **solver_cont | |||
numerics->SetTransVar(nodes->GetSolution(iPoint), nodes->GetSolution(jPoint)); | |||
numerics->SetTransVarGradient(nodes->GetGradient(iPoint), nodes->GetGradient(jPoint)); | |||
|
|||
numerics->SetConsVarGradient(solver_container[FLOW_SOL]->GetNodes()->GetGradient(iPoint), | |||
solver_container[FLOW_SOL]->GetNodes()->GetGradient(jPoint)); | |||
// ToDo: The flow solvers do not use the conservative variable gradients |
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.
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.
This one is probably a good question for @vdweide, since he has been updating the transition model in a separate branch. It looks like the viscous numerics is mostly commented out in the develop branch. I expect we should modify this to use the primitive gradients.
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.
No need to worry about the transition model at the moment. Since the data structures have changed so much lately, it is pretty much impossible to carry out a merge between the transition model branch and the develop branch. The implementation must be redone. @economon, we agreed that we would wait with that until PR 777 is merged in. I assume this is still the case.
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.
@pcarruscag Any other changes you want to add here? Otherwise I'll merge it. |
@pcarruscag : I think we are good to remove those two old gradient sections in #798. I will be working to merge this PR into #790 (and finish up there) next |
Now that I am updating #790 to work with the new structure from this PR (#753), I am seeing that the aligned_alloc() function is not well defined on mac, so xcode/llvm builds are not working on mac at the moment. There are some issue related to C vs C++ with that (depends on the standard you choose for C or C++, 11 or 17, apparently). Might be some ways around it from reading comments by others on the issue: marian-nmt/marian-dev#227. @pcarruscag : can you give this a quick look when you have some time? Thanks! |
Proposed Changes
This is the beginning of the work proposed in #716 .
Comments will follow as work progresses.
I would appreciate if we could keep the restructuring of files that use CVariable heavily for when this is done.
Related Work
#716
PR Checklist
Put an X by all that apply. You can fill this out after submitting the PR. If you have any questions, don't hesitate to ask! We want to help. These are a guide for you to know what the reviewers will be looking for in your contribution.