README.md
1# Binpack sample
2This directory contains an `oneapi::tbb::flow` example that performs binpacking of `N` integer values into a near-optimal number of bins of capacity `V`.
3
4It features a `source_node` which passes randomly generated integer values of `size <= V` to a `queue_node`. Multiple function nodes set about taking values from this `queue_node` and packing them into bins according to a best-fit policy. Items that cannot be made to fit are rejected and returned to the queue. When a bin is packed as well as it can be, it is passed to a `buffer_node` where it waits to be picked up by another `function_node`. This final function node gathers stats about the bin and optionally prints its contents. When all bins are accounted for, it optionally prints a summary of the quality of the bin-packing.
5
6## Building the example
7```
8cmake <path_to_example>
9cmake --build .
10```
11
12## Running the sample
13### Predefined make targets
14* `make run_binpack` - executes the example with predefined parameters.
15* `make perf_run_binpack` - executes the example with suggested parameters to measure the oneTBB performance.
16
17### Application parameters
18Usage:
19```
20binpack [#threads=value] [verbose] [silent] [elements_num=value] [bin_capacity=value] [#packers=value] [optimality=value] [-h] [#threads]
21```
22* `-h` - prints the help for command line options.
23* `#threads` - the number of threads to use; a range of the form low\[:high\] where low and optional high are non-negative integers, or `auto` for a platform-specific default number.
24* `verbose` - prints diagnostic output to screen.
25* `silent` - limits output to timing info; overrides verbose.
26* `N` - number of values to pack.
27* `V` - capacity of each bin.
28* `#packers` - number of concurrent bin packers to use (`default=#threads`).
29* `optimality` - controls optimality of solution; 1 is highest, use larger numbers for less optimal but faster solution.
30