Overview

This directory contains a simple tbb::graph 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.

Files

binpack.cpp
Driver.
Makefile
Makefile for building example.

Directories

msvs
Contains Microsoft* Visual Studio* 2008 workspace for building and running the example with the Intel® C++ compiler.
xcode
Contains Mac OS* Xcode* workspace for building and running the example.

To Build

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 directions).
Run it with a small problem size and the desired number of threads, e.g., binpack 4 N=100.

Up to parent directory

Copyright © 2005-2011 Intel Corporation. All Rights Reserved.

Intel, Pentium, Intel Xeon, Itanium, Intel XScale and VTune are registered trademarks or trademarks of Intel Corporation or its subsidiaries in the United States and other countries.

* Other names and brands may be claimed as the property of others.