To install oneTBB using GUI, complete the following steps:
Click the corresponding link to start the download and wait for it to complete.
For the offline installer:
a. Run the downloaded .exe file.
b. installation wizardSpecify the path where to extract the package. By default, it is C:\Users
c. Click Extract.
NOTE: For the online installer, the download starts automatically after you run the .exe file.
For offline installer, click Continue. The online installer proceeds automatically.
Read and accept the license agreement.
Choose the installation mode:
NOTE: No other components or versions can be selected due to the solution nature.
At the Integrate IDE step, the program checks if it is possible to deploy oneTBB using Microsoft* Visual Studio* IDE. If IDE is not installed, you can exit the setup and restart it after installing the IDE or proceed without integration.
Select the option you prefer at the Software Improvement Program step. Click Install to start the installation.
When the installation is complete, click Finish.
NOTE: Configure environment variables after installation. See Next Steps to learn about it.
在新建Visual Studio项目属性中设置
代码:
#include
int main() {
int sum = oneapi::tbb::parallel_reduce(
oneapi::tbb::blocked_range<int>(1, 101), 0,
[](oneapi::tbb::blocked_range<int> const& r, int init) -> int {
for (int v = r.begin(); v != r.end(); v++) {
init += v;
}
return init;
},
[](int lhs, int rhs) -> int {
return lhs + rhs;
}
);
printf("Sum: %d\n", sum);
return 0;
}
编译,测试
Sum: 5050
D:\documents\vs2019\func_test\func_teset\x64\Debug\tbb_use.exe (进程 20716)已退出,代码为 0。
要在调试停止时自动关闭控制台,请启用“工具”->“选项”->“调试”->“调试停止时自动关闭控制台”。
按任意键关闭此窗口. . .