computablee / DotMP

A collection of powerful abstractions for parallel programming in .NET with an OpenMP-like API.
https://computablee.github.io/DotMP/
GNU Lesser General Public License v2.1
29 stars 7 forks source link

[BUG] No exception thrown for overflow in loop indices and schedulers #115

Closed computablee closed 11 months ago

computablee commented 12 months ago

Describe the bug.

When a parallel-for loop (namely collapsed loops) exceed int.MaxValue iterations, there is some sort of internal overflow that is uncaught and loop results become invalid.

To Reproduce.

Example:

DotMP.Parallel.ParallelForCollapse((0, 256), (0, 256), (0, 256), (0, 256),
    (i, j, k, l) =>
{
    // improper loop executed
});

Expected behavior.

Either some sort of overflow exception, or optimally, an internal refactor to migrate to long instead of int for loop scheduling. Might be good for a v2.0.0 release.

Desktop (please complete the following information):

computablee commented 11 months ago

This is also an issue with the schedulers, where if a loop goes near int.MaxValue the internal counters will overflow and the mechanism by which parallel-for loops terminate is rendered impossible. Checks need to be implemented for this to avoid halting issues.