You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
See the attached code for a minimal repro. I am new to this API so if I am making an obvious mistake, please do let me know. This bug appears to occur reliably when TASK_COUNT >= 50 and when TASK_COUNT is 5000 it will always happen.
Context / use case: I am developing a terrain streaming system. On world load I spawn about 5000~ tasks which procedurally generate each terrain cell's heightmap, then another 5000~ with various dependencies to generate the meshes.
From a preliminary search of the library code, the problem appears to occur only when the task buffer is full and it must be executed immediately. The code does not properly handle ranges that are not divisible by the range step, so what should be the final step overruns into an infinite loop.
I have removed this block - it doesn't make sense to me, if we were simply executing the same job immediately because there was no room, why would we have to tweak the range that we've already calculated? This fixed the problem for me. I did verify that every element of the range was being generated with the following test:
structRepro : publicenki::ITaskSet
{
std::vector<int> data;
Repro() : enki::ITaskSet(TASK_RANGE) { data.resize(TASK_RANGE); };
virtualvoidExecuteRange( enki::TaskSetPartition range, uint32_t) override
{
if (range.start > TASK_RANGE || range.end > TASK_RANGE)
{
__debugbreak(); // bug?!
}
for (size_t i = range.start; i < range.end; ++i)
{
data[i] = 1;
}
}
};
... later
for (std::unique_ptr<Repro>& job : jobs)
{
int count = 0;
for (size_t i = 0; i < TASK_RANGE; ++i)
{
count += job->data[i];
}
ASSERT(count == TASK_RANGE);
}
The text was updated successfully, but these errors were encountered:
Many thanks for this report and especially for a simple reproduction - it seems my own tests for this didn't trigger the exact flow required to get the issue.
I've added your reproduction as part of the test suite, fixed the issue and added an extra assert.
See the attached code for a minimal repro. I am new to this API so if I am making an obvious mistake, please do let me know. This bug appears to occur reliably when
TASK_COUNT
>= 50 and whenTASK_COUNT
is 5000 it will always happen.Context / use case: I am developing a terrain streaming system. On world load I spawn about 5000~ tasks which procedurally generate each terrain cell's heightmap, then another 5000~ with various dependencies to generate the meshes.
From a preliminary search of the library code, the problem appears to occur only when the task buffer is full and it must be executed immediately. The code does not properly handle ranges that are not divisible by the range step, so what should be the final step overruns into an infinite loop.
https://github.com/dougbinks/enkiTS/blob/master/src/TaskScheduler.cpp#L656
I have removed this block - it doesn't make sense to me, if we were simply executing the same job immediately because there was no room, why would we have to tweak the range that we've already calculated? This fixed the problem for me. I did verify that every element of the range was being generated with the following test:
The text was updated successfully, but these errors were encountered: