Skip to content

Grainsize calculation on TinyThreads #142

@franzbischoff

Description

@franzbischoff

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:

  1. Total threads is 8
  2. So, 767/8 is not exact, and the algorithm chooses to do 767/(8-1) ~= 109
  3. So each chunk will be of size 109. That is fine for my algorithm that needs a chunk larger than, let's say, 60.
  4. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions