Repository navigation
Conversation
This is still incomplete. I haven't addressed the vector interfaces, for example or documentation
| const auto local_scale = factors.scale; | ||
| const auto local_inv_scale = factors.inv_scale; | ||
| return t_.TemperatureFromDensityInternalEnergy(local_scale * rho, | ||
| local_inv_scale * sie, lambda); |
There was a problem hiding this comment.
| const auto local_scale = factors.scale; | |
| const auto local_inv_scale = factors.inv_scale; | |
| return t_.TemperatureFromDensityInternalEnergy(local_scale * rho, | |
| local_inv_scale * sie, lambda); | |
| const auto rho_scale = factors.scale * rho; | |
| const auto sie_scale = factors.inv_scale * sie; | |
| return t_.TemperatureFromDensityInternalEnergy(rho_scale, | |
| sie_scale, lambda); |
What do you think is more useful to have in a local register here? The scaled density & sie, or the scaling factors, or neither? It's a genuine question. I suppose the answer might change for the different use cases in this file....
There was a problem hiding this comment.
You're using the word register, so I'm guessing you are asking about performance, and I honestly wouldn't have any idea. In terms of debugging, I could live with either one, but your suggestion looks good to me.
There was a problem hiding this comment.
I agreed to do this before switching to the structured bindings. Would you still rather I create temporaries like rho_scale and sie_scale?
| struct ScaleFactors { | ||
| Real scale; | ||
| Real inv_scale; | ||
| }; | ||
|
|
||
| template <typename Indexer_t> | ||
| PORTABLE_FORCEINLINE_FUNCTION ScaleFactors | ||
| GetScaleFactors(const Indexer_t &lambda) const { | ||
| Real local_scale = scale_; | ||
|
|
||
| // Checks for the named index and apply it if it exists. | ||
| if (singularity::IndexerUtils::SafeGet<IndexableTypes::DensityScalingRatio>( | ||
| lambda, local_scale)) { | ||
| PORTABLE_ALWAYS_REQUIRE(local_scale > 0.0, | ||
| "Local density scaling ratio must be positive."); | ||
|
|
||
| const Real local_inv_scale = 1.0 / local_scale; | ||
|
|
||
| PORTABLE_ALWAYS_REQUIRE(local_inv_scale > 0.0, | ||
| "Inverse local density scaling ratio must be positive."); | ||
|
|
||
| return {local_scale, local_inv_scale}; | ||
| } | ||
|
|
||
| return {scale_, inv_scale_}; | ||
| } |
There was a problem hiding this comment.
We could do away with the struct and just return a tuple, that would let you then capture the two scale factors into local variables without first making a struct then copying the two members into local variables.
There was a problem hiding this comment.
std::tuple? Is that always device safe? Not exactly a fix for the copy concern, but where it's used, we could do const auto [scale, inv_scale] = GetScaleFactors(lambda);
There was a problem hiding this comment.
I think it depends on the situation, but I've never had a problem. I believe this use case should be fine. And I'd do const auto &[scale, inv_scale]... with the reference binding. We could try it out and see if the testing falls over.
This make local scaling ratios possible.
PR Summary
This adds evaluation of the lambda for local scale factors to ScaledEOS and ScaledFreeEnergy. The vector interfaces also forward those local factors now too.
NOTE: I have not yet addressed eospac.
PR Checklist
make formatcommand after configuring withcmake.plan_historiesfolder, with a filename the same as the MR number.If preparing for a new release, in addition please check the following: