• windows TBB的使用


    windows TBB的使用

    1. Install with GUI

    To install oneTBB using GUI, complete the following steps:

    1. Go to the Download page.
    2. Select the preferred installer
    • Online installer has a smaller file size but requires a permanent Internet connection while running.
    • Offline installer has a bigger file size but requires an Internet connection only to download the installer file.
    1. Click the corresponding link to start the download and wait for it to complete.

    2. 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\Downloads\w_tbb_oneapi_p__offline.
    c. Click Extract.

    NOTE: For the online installer, the download starts automatically after you run the .exe file.

    1. For offline installer, click Continue. The online installer proceeds automatically.

    2. Read and accept the license agreement.

    3. Choose the installation mode:

    • To use default installation settings, select Recommended Installation. oneTBB is installed in the default location: \Intel\oneAPI>.
    • To modify the default installation location, select Custom Installation and click Customize.

    NOTE: No other components or versions can be selected due to the solution nature.

    在这里插入图片描述

    1. 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.

    2. Select the option you prefer at the Software Improvement Program step. Click Install to start the installation.

    3. 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;
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20

    编译,测试

    Sum: 5050
    
    D:\documents\vs2019\func_test\func_teset\x64\Debug\tbb_use.exe (进程 20716)已退出,代码为 0。
    要在调试停止时自动关闭控制台,请启用“工具”->“选项”->“调试”->“调试停止时自动关闭控制台”。
    按任意键关闭此窗口. . .
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    参考:Install with GUI
    参考:Install on Windows* OS
    参考:Next Steps

  • 相关阅读:
    前端问题整理
    VMware Workstation Pro 16、CentOS7镜像 (Windows10)下载安装
    MybatisPlus多数据源
    下册开学期末+CSP-J游记
    【每日一题】2258. 逃离火灾-2023.11.9
    使用 AIGC ,ChatGPT 快速合并Excel工作薄
    flutter获取字符串和json或者map的md5值
    QGIS编译(跨平台编译)之四十五:Exiv2编译(Windows、Linux、MacOS环境下编译)
    学习和认知的四个阶段,以及学习方法分享
    PROJECT #1 - BUFFER POOL [CMU 15-445645]笔记
  • 原文地址:https://blog.csdn.net/juluwangriyue/article/details/133831156