Are there any really simple examples?
The Intel ArBB tutorials contain some very simple examples, such as computing the sum of two vectors and the dot-product of two vectors.
Take a look at Intel ArBB tutorials at: http://software.intel.com/sites/products/documentation/arbb/tutorial/index.htm.
Then download the source code used in the tutorial: http://registrationcenter.intel.com/irc_nas/1942/arbb-tutorials-source.zip
Here is a simple example that adds two dense containers:
#include #include #include
using namespace arbb;
void add(dense& out, dense a, dense b){ out = a + b;}
int main(int argc, char* argv[]){ std::size_t size = 100; // operating on 100 elements
// vectors of floats to store data for a, b, c std::vector a_data(size), b_data(size), c_data(size);
try { dense a, b, c;
// bind data to arbb containers bind(a, &a_data[0], a_data.size()); bind(b, &b_data[0], b_data.size()); bind(c, &c_data[0], c_data.size());
for (std::size_t i = 0; i < b_data.size(); ++i) { b_data[i] = 2.0f; // or rand() or something more useful c_daat[i] = 3.0f; }
// call add with a as input/output and b and c as inputs call(add)(a, b, c);
} catch (exception& e) { std::cout << "exception thrown: " << e.what() << std::endl; return 1; }
// result is in a_data for (std::size_t i = 0; i < a_data.size(); ++i) { std::cout << i << " " << a_data[i] << std::endl; }
return 0;}