Created
May 31, 2015 07:18
-
-
Save MasazI/c34f326440b1acca6c0a to your computer and use it in GitHub Desktop.
tbb parallel for
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// 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