コードは以下である。
Threading Building Blocks
This file contains 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; | |
} | |
0 件のコメント:
コメントを投稿