|
std::vector<IndexRange> splitInputRange(const IndexRange& range, |
I was working fine with TBB in my app on Windows, defining the grainsize, but I got problems when porting to Linux and using TinyThreads. So I looked at the code.
Here I can see that, if I have a vector of size 767, and I set the grainsize to 64 I get the following:
- Total threads is
8
- So,
767/8 is not exact, and the algorithm chooses to do 767/(8-1) ~= 109
- So each chunk will be of size
109. That is fine for my algorithm that needs a chunk larger than, let's say, 60.
- There will be
767 / 109 = 7.0366 jobs. That means one job will be of size 4 that is below my grainsize of 64. And this will break my algorithm.
So, what about the last chunk to be of size 113 instead of 109 + 4? This will be in conformity with what is expected from grainsize.
I can write a pull request. For now, I'm just discussing the case.
RcppParallel/inst/include/RcppParallel/TinyThread.h
Line 68 in 39303ec
I was working fine with TBB in my app on Windows, defining the grainsize, but I got problems when porting to Linux and using TinyThreads. So I looked at the code.
Here I can see that, if I have a vector of size
767, and I set the grainsize to64I get the following:8767/8is not exact, and the algorithm chooses to do767/(8-1) ~= 109109. That is fine for my algorithm that needs a chunk larger than, let's say,60.767 / 109 = 7.0366jobs. That means one job will be of size4that is below my grainsize of64. And this will break my algorithm.So, what about the last chunk to be of size
113instead of109+4? This will be in conformity with what is expected from grainsize.I can write a pull request. For now, I'm just discussing the case.