# Intel® Threading Building Blocks.
Binpack sample

This directory contains a simple tbb::flow example that performs binpacking of N integer values into a near-optimal number of bins of capacity V.
It 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 nodes 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.

System Requirements

For the most up to date system requirements, see the release notes.

Files

binpack.cpp
  Driver.
Makefile
  Makefile for building the example.

Directories

msvs
  Contains Microsoft* Visual Studio* workspace for building and running the example with the Intel® C++ Compiler (Windows* systems only).
xcode
  Contains Xcode* IDE workspace for building and running the example (OS X* systems only).

For information about the minimum supported version of IDE, see release notes.

Build instructions

General build directions can be found here.

Usage

`binpack -h`
  Prints the help for command line options
`binpack [#threads=value] [verbose] [silent] [N=value] [V=value] [#packers=value] [optimality=value] [#threads]`
  `#threads` is 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 the TBB default.
  `verbose` print diagnostic output to screen
  `silent` limits output to timing info; overrides verbose
  `N` number of values to pack
  `V` capacity of each bin
  `#packers` number of concurrent bin packers to use (default=#threads)
  `optimality` controls optimality of solution; 1 is highest, use larger numbers for less optimal but faster solution
To run a short version of this example, e.g., for use with Intel® Parallel Inspector:
  Build a debug version of the example (see the build instructions).
  Run it with a small problem size and the desired number of threads, e.g., `binpack 4 N=100`.

Up to parent directory

Legal Information

Intel and the Intel logo are trademarks of Intel Corporation in the U.S. and/or other countries.
* Other names and brands may be claimed as the property of others.
© 2016, Intel Corporation