没有合适的资源?快使用搜索试试~ 我知道了~
首页Pro TBB C++ Thread Blocks Parallel.pdf
Pro TBB C++ Thread Blocks Parallel.pdf
5星 · 超过95%的资源 需积分: 42 26 下载量 145 浏览量
更新于2023-05-17
收藏 129.38MB PDF 举报
TBB是Intel公司的用于C++多线程和并行计算程序的库文件,该书是2019年新版,内容是英文版的,请注意下载。
资源详情
资源推荐
Pro TBB: C++ Parallel Programming with reading Building Blocks
ISBN-13 (pbk): 978-1-4842-4397-8 ISBN-13 (electronic): 978-1-4842-4398-5
https://doi.org/10.1007/978-1-4842-4398-5
Copyright © 2019 by Intel Corporation
is work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the material is
concerned, specically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on
microlms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation,
computer software, or by similar or dissimilar methodology now known or hereafter developed.
Open Access is book is licensed under the terms of the Creative Commons Attribution-
NonCommercial-NoDerivatives 4.0 International License (http://creativecommons.org/licenses/
by-nc-nd/4.0/), which permits any noncommercial use, sharing, distribution and reproduction in any
medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the
Creative Commons license and indicate if you modied the licensed material. You do not have permission under this
license to share adapted material derived from this book or parts of it.
e images or other third party material in this book are included in the book’s Creative Commons license, unless
indicated otherwise in a credit line to the material. If material is not included in the book’s Creative Commons license and
your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain
permission directly from the copyright holder.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every
occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to
the benet of the trademark owner, with no intention of infringement of the trademark.
e use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identied as
such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of publication, neither the
authors nor the editors nor the publisher can accept any legal responsibility for any errors or omissions that may be made.
e publisher makes no warranty, express or implied, with respect to the material contained herein.
Managing Director, Apress Media LLC: Welmoed Spahr
Acquisitions Editor: Natalie Pao
Development Editor: James Markham
Coordinating Editor: Jessica Vakili
Cover designed by eStudioCalamar
Cover image designed by Freepik (www.freepik.com)
Distributed to the book trade worldwide by Springer Science+Business Media NewYork, 233 Spring Street, 6th Floor,
NewYork, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@springer-sbm.com, or visit
www.springeronline.com. Apress Media, LLC is a California LLC and the sole member (owner) is Springer Science +
Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation.
For information on translations, please e-mail rights@apress.com, or visit http://www.apress.com/rights-permissions.
Apress titles may be purchased in bulk for academic, corporate, or promotional use. eBook versions and licenses are also
available for most titles. For more information, reference our Print and eBook Bulk Sales web page at http://www.apress.
com/bulk-sales.
Any source code or other supplementary material referenced by the author in this book is available to readers on GitHub
via the book’s product page, located at www.apress.com/978-1-4842-4397-8. For more detailed information, please visit
http://www.apress.com/source-code.
Printed on acid-free paper.
MichaelVoss
Austin, Texas, USA
JamesReinders
Portland, Oregon, USA
RafaelAsenjo
Málaga, Spain
www.allitebooks.com
iii
About the Authors ����������������������������������������������������������������������������������������������������xv
Acknowledgments �������������������������������������������������������������������������������������������������xvii
Preface �������������������������������������������������������������������������������������������������������������������xix
Table of Contents
Part 1 �������������������������������������������������������������������������������������������������������������� 1
Chapter 1: Jumping Right In: “Hello, TBB!” �������������������������������������������������������������� 3
Why Threading Building Blocks? ��������������������������������������������������������������������������������������������������� 3
Performance: Small Overhead, Big Benets for C++ �������������������������������������������������������������� 4
Evolving Support for Parallelism in TBB and C++ ������������������������������������������������������������������� 5
Recent C++ Additions for Parallelism ������������������������������������������������������������������������������������� 6
The Threading Building Blocks (TBB) Library �������������������������������������������������������������������������������� 7
Parallel Execution Interfaces ��������������������������������������������������������������������������������������������������� 8
Interfaces That Are Independent of the Execution Model ������������������������������������������������������ 10
Using the Building Blocks in TBB ������������������������������������������������������������������������������������������� 10
Let’s Get Started Already! ����������������������������������������������������������������������������������������������������������� 11
Getting the Threading Building Blocks (TBB) Library ������������������������������������������������������������� 11
Getting a Copy of the Examples ��������������������������������������������������������������������������������������������� 12
Writing a First “Hello, TBB!” Example ������������������������������������������������������������������������������������ 12
Building the Simple Examples ����������������������������������������������������������������������������������������������� 15
Building on Windows Using Microsoft Visual Studio ������������������������������������������������������������� 16
Building on a Linux Platform from a Terminal ����������������������������������������������������������������������� 17
A More Complete Example ���������������������������������������������������������������������������������������������������������� 21
Starting with a Serial Implementation ����������������������������������������������������������������������������������� 21
Adding a Message-Driven Layer Using a Flow Graph ������������������������������������������������������������ 25
Adding a Fork-Join Layer Using a parallel_for ���������������������������������������������������������������������� 27
Adding a SIMD Layer Using a Parallel STL Transform ����������������������������������������������������������� 29
www.allitebooks.com
iv
Chapter 2: Generic Parallel Algorithms ������������������������������������������������������������������ 33
Functional / Task Parallelism ������������������������������������������������������������������������������������������������������ 37
A Slightly More Complicated Example: A Parallel Implementation of Quicksort �������������������� 40
Loops: parallel_for, parallel_reduce, and parallel_scan �������������������������������������������������������������� 42
parallel_for: Applying a Body to Each Element in a Range ���������������������������������������������������� 42
parallel_reduce: Calculating a Single Result Across a Range ����������������������������������������������� 46
parallel_scan: A Reduction with Intermediate Values ����������������������������������������������������������� 52
How Does This Work? ������������������������������������������������������������������������������������������������������������ 54
A Slightly More Complicated Example: Line of Sight ������������������������������������������������������������� 56
Cook Until Done: parallel_do and parallel_pipeline �������������������������������������������������������������������� 57
parallel_do: Apply a Body Until There Are No More Items Left ���������������������������������������������� 58
parallel_pipeline: Streaming Items Through a Series of Filters ��������������������������������������������� 67
Chapter 3: Flow Graphs ������������������������������������������������������������������������������������������ 79
Why Use Graphs to Express Parallelism? ������������������������������������������������������������������������������������ 80
The Basics of the TBB Flow Graph Interface ������������������������������������������������������������������������������� 82
Step 1: Create the Graph Object �������������������������������������������������������������������������������������������� 84
Step 2: Make the Nodes �������������������������������������������������������������������������������������������������������� 84
Step 3: Add Edges ������������������������������������������������������������������������������������������������������������������ 87
Step 4: Start the Graph ���������������������������������������������������������������������������������������������������������� 89
Step 5: Wait for the Graph to Complete Executing ����������������������������������������������������������������� 91
A More Complicated Example of a Data Flow Graph ������������������������������������������������������������������� 91
Implementing the Example as a TBB Flow Graph ������������������������������������������������������������������ 93
Understanding the Performance of a Data Flow Graph ��������������������������������������������������������� 96
The Special Case of Dependency Graphs ������������������������������������������������������������������������������������ 97
Implementing a Dependency Graph �������������������������������������������������������������������������������������� 99
Estimating the Scalability of a Dependency Graph �������������������������������������������������������������� 105
Advanced Topics in TBB Flow Graphs ��������������������������������������������������������������������������������������� 106
Chapter 4: TBB and the Parallel Algorithms of the C++ Standard
Template Library ��������������������������������������������������������������������������������������������������� 109
Does the C++ STL Library Belong in This Book? ���������������������������������������������������������������������� 110
A Parallel STL Execution Policy Analogy ����������������������������������������������������������������������������������� 112
Table of ConTenTs
www.allitebooks.com
剩余806页未读,继续阅读
pursuingdream_2014
- 粉丝: 2
- 资源: 29
上传资源 快速赚钱
- 我的内容管理 收起
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
会员权益专享
最新资源
- zigbee-cluster-library-specification
- JSBSim Reference Manual
- c++校园超市商品信息管理系统课程设计说明书(含源代码) (2).pdf
- 建筑供配电系统相关课件.pptx
- 企业管理规章制度及管理模式.doc
- vb打开摄像头.doc
- 云计算-可信计算中认证协议改进方案.pdf
- [详细完整版]单片机编程4.ppt
- c语言常用算法.pdf
- c++经典程序代码大全.pdf
- 单片机数字时钟资料.doc
- 11项目管理前沿1.0.pptx
- 基于ssm的“魅力”繁峙宣传网站的设计与实现论文.doc
- 智慧交通综合解决方案.pptx
- 建筑防潮设计-PowerPointPresentati.pptx
- SPC统计过程控制程序.pptx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功