Simplest Example...

Simplest Example...

Are there any really simple examples?

3 posts / novo 0
Último post
Para obter mais informações sobre otimizações de compiladores, consulte Aviso sobre otimizações.
imagem de Zhang Z (Intel)

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:

Then download the source code used in the tutorial:

Here is a simple example that adds two dense containers:


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;

Faça login para deixar um comentário.