Skip to content

Instantly share code, notes, and snippets.

@MasazI
Created May 31, 2015 07:18
Show Gist options
  • Save MasazI/c34f326440b1acca6c0a to your computer and use it in GitHub Desktop.
Save MasazI/c34f326440b1acca6c0a to your computer and use it in GitHub Desktop.
tbb parallel for
//
// tbb_intro.cpp
// CplusplusPractice
//
// Created by masai on 2015/05/31.
// Copyright (c) 2015年 masai. All rights reserved.
//
#include <iostream>
#include <cmath>
#include <tbb/tbb.h>
double *output;
double *input;
int main(){
const int size = 20000000;
output = new double[size];
input = new double[size];
for(int i = 0; i < size; ++i){
input[i] = i;
}
tbb::parallel_for(0, size, 1, [=](int i){
output[i] = sqrt(sin(input[i]*sin(input[i]) + cos(input[i])*cos(input[i])));
}
);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment