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

A few changes to properly pass storeResidual to BLAST #16

Closed
wants to merge 4 commits into from
Closed

A few changes to properly pass storeResidual to BLAST #16

wants to merge 4 commits into from

Conversation

genevb
Copy link

@genevb genevb commented Aug 14, 2022

While this fixes several little issues, it has not resolved problems I see with reading a precision cascade where the residual is stored. Still looking into that, but figured I'd go ahead and get these patches in.

@genevb genevb requested a review from pcanal as a code owner August 14, 2022 05:32
// do not accept negative levels, and only accept level 0 if it is the final level,
// as this is a proxy for storing the residual of a cascade
bool storeResidual = content->fStoreResidual || (tgt_number > 0 && cxlevels[tgt_number-1] == 0);
int tgt_checks = tgt_number - (storeResidual ? 1 : 0);
Copy link
Owner

Choose a reason for hiding this comment

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

Humm that seems wrong. If 'content->fStoreResidual', the last element is probably not zero, unless we explicitly already added it (in which case the if can be simplified to tgt_number > 0 && cxlevels[tgt_number-1] == 0), isn't it?

Copy link
Author

@genevb genevb Aug 15, 2022

Choose a reason for hiding this comment

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

Thanks for double-checking me on this, Philippe.

I have observed that if content->fStoreResidua', then tgt_number, which is passed via precisionCascades.size() from TBasket, is 1 larger than content->fLen, so there is no point in examining cxlevels[tgt_number-1] in that case because the user never set that many levels. In other words, if I as a user provide 5 levels, and turn on fStoreResidual, then precisionCascades will have a size of 6 (it already has an extra buffer for the residual) and we only want to check the value of the 5 user-provided levels [0]...[4], not [5]. So I think this is the correct thing to do.

Copy link
Owner

Choose a reason for hiding this comment

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

but what if the user put both a zero at the end and has fStoreResidual == true ?

Copy link
Author

Choose a reason for hiding this comment

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

Yeah, right now it is set to fail on that with the check on the level being less than 1. The code you've written will create two buffers and output files for the residual in that case, so if it is to be allowed, it should be caught further upstream of this to avoid creating two buffers/files for the residual.

Copy link
Owner

Choose a reason for hiding this comment

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

Maybe the simplest is to not support '0' as a compression level (and possible explicitly reject it in PrecisionCascadeCompressionConfig::PrecisionCascadeCompressionConfig in Compression.cxx. then the code above can be simplified, right?

Copy link
Author

Choose a reason for hiding this comment

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

Perhaps this was the only controversial point in this PR?

Copy link
Owner

Choose a reason for hiding this comment

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

yes but since we migrate the i/o to store the 'storeResidual' at the end of the levels array (adding it based on the user input), it seems most of the PR is moot. Let me finish the change and see what I need to import.

tgt[3] = (char)((out_sizes[tgt_idx] + 2) & 0xff);
tgt[4] = (char)((out_sizes[tgt_idx] >> 8) & 0xff);
tgt[5] = (char)((out_sizes[tgt_idx] >> 16) & 0xff);
size_t out_size = out_sizes[tgt_idx] + 2;
Copy link
Owner

Choose a reason for hiding this comment

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

Is this change cosmetic?

Copy link
Author

Choose a reason for hiding this comment

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

No. As you had written it, if out_sizes[tgt_idx] = 255, then tgt[3] = 1, tgt[4] = 0, and tgt[5] = 0, which would be interpreted as having a size of 1. The way I wrote it, tgt[4] would also become 1, so that the true size of 255 + 2 = 257 is preserved.

Copy link
Owner

Choose a reason for hiding this comment

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

Right. Thanks!

@pcanal
Copy link
Owner

pcanal commented Aug 15, 2022

Most of the PR became unnecessary following the change of the I/O storage for the config. Change in out_size calculation was pushed manually.

@pcanal pcanal closed this Aug 15, 2022
auto content = reinterpret_cast<ROOT::Internal::PrecisionCascadeConfigArrayContent*>(configarray);
(void) configsize;
Copy link
Owner

Choose a reason for hiding this comment

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

Since the assert is the only use of configsize and it is removed in Release build, this line prevent the compiler from complaining about unused variable/parameter.

@genevb genevb mentioned this pull request Aug 16, 2022
@genevb genevb deleted the ZIGTests2 branch August 16, 2022 03:10
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.

2 participants