thomasmoelhave / tpie

Templated Portable I/O Environment
Other
112 stars 24 forks source link

Fix 'minimum_memory_phase1' returns an illegal value #254

Open SSoelvsten opened 2 years ago

SSoelvsten commented 2 years ago

Closes #250 as a simpler (and working) alternative to #253 . All tests pass, and the computed value seems to be slightly above the min_m1 computed in calculate_parameters for a block size of 2, 4, 8, ..., 64. Except for the tests and my own project, Adiar, I do not know what to test it on.

freekvw commented 2 years ago

See #255. Not sure if this also solves your issue?

SSoelvsten commented 2 years ago

I tried to rerun the minimal example in #250 on main after the merge of #255 and I get

Not enough phase 1 memory for 128 KB items and an open stream! (25167632 < 25298776)

So, this function still seems to return a too small value. The computation in minimum_memory_phase1 is a separate code-duplication of the line you changed. Here, the only difference is the 128*1024 / m_item_size (now std::max(128*1024UL, 16*m_item_size)) is replaced with a 1 which is very unlikely to be the same.