Ensure that a user-defined thread count takes precedence over getNumberOfLogicalThreads() #460
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi,
This pull request ensures that a user-defined thread count (i.e., in the device's config argument) consistently takes precedence over the detected number of logical threads. Previously, Embree would fail if the user-provided thread count was larger than the internally determined one. It internally allocated threading related buffers based on the return value of
getNumberOfLogicalThreads()
, which would then cause a segfault when invokingrtcJoinCommitScene
using a thread pool that has a larger number of threads. Concretely, I encountered this when running Mitsuba 3 on a cluster setup. Currently, Embree effectively requires the user thread pool to be smaller or equal togetNumberOfLogicalThreads()
, but this is not always straightforward to guarantee. Moreover, I would argue that this is neither documented nor immediately obvious for users.This fix seems to work for me, but I am open to suggestions if it is not general enough to be merged in this state.
Best,
Delio