Sam Vilain > threads-tbb > threads::tbb::blocked_int

Download:
threads-tbb-0.04.tar.gz

Annotate this POD

CPAN RT

New  2
Open  0
View/Report Bugs
Source  

NAME ^

threads::tbb::blocked_int - a divisible range of integers

SYNOPSIS ^

  use threads::tbb;

  # a range, and a minimum quanta
  my $range = threads::tbb::blocked_int->new(1, 10, 1);

  print $range->size;         # 9
  print $range->begin;        # 1
  print $range->end;          # 10
  print $range->grainsize;    # 1
  print $range->is_divisible; # bool: 1 or ""
  print $range->empty;        # bool: 1 or ""

DESCRIPTION ^

This class lets you construct a tbb::blocked_range<int> range. This is used for passing to functions such as "parallel_for" in threads::tbb to specify the iteration / division space.

Ranges use a convention called b<half-open intervals>, written in the TBB documentation as [x,y), which means the integers x <= N < y. So, if you want to iterate from 1 to 10 you'll need to set begin to 1 and end to 11.

The grainsize is a quanta for each work item. The idea is that this is tuned once the code is finished; it is the size of a minimum chunk for processing in one go. Larger grain sizes give more performance, but allow less scope for the work to be divided among processors. If the grain size is too small, the overhead of the library may slow down the program unacceptably on uniprocessor systems.

SEE ALSO ^

threads::tbb

syntax highlighting: