Skip to Content
云端基因组学
book

云端基因组学

by Geraldine A. Van der Auwera, Brian D. O’Connor
April 2022
Beginner to intermediate
486 pages
10h 22m
Chinese
China Electric Power Press Ltd.
Content preview from 云端基因组学
72
3
3.2
并行计算
当你无法再让程序更快一点,可以尝试并行计算方法。在计算语境,并行计算是指
以并行而非串行方式(串行是指等前一项操作结束,才能开始下一项运算)执行一
些操作,让程序更快结束。假如你需要为
64
人做米饭,但电饭煲一次只能做
4
人的量。
以串行方式做所有批次的米饭,你得通宵。你若有
8
个电饭煲,则可以并行使用它们,
这样就能快
8
倍。
这个想法非常简单,但有一个关键要求:工作必须能拆分为更小且可以单独处理的
任务。将米饭分成几份做比较容易,因为米饭是由一个个离散单元组成的。但并非
所有工作都可以这样拆,例如,一位孕妇
9
个月生一个孩子,就无法找
9
名孕妇分
摊生孩工作,无法一个月生下孩子。
幸好,大多数基因组分析工作更像做米饭而非生孩,它们本质上是由一些小型独立
操作组成的,这些操作可并行处理。那么,我们如何将做米饭这套方法搬到程序执
行场景呢?
3.2.1
并行处理一个简单分析任务
考虑到当你运行分析项目时,你不过是告诉计算机去执行一组指令。假如我们想统
计一个文本文件有多少行内容。该任务所需指令非常简单,如下所示:
打开文件;统计文件有多少行;告诉我们行数;关闭文件。
请注意,“告诉我们行数”可以指将其写到终端或保存到其他地方,以便后续使用,
我们现在无需考虑这点。
现在,假如我们想知道每行有多少单词。其指令如下:
打开文件;读取第一行;统计词数;告诉我们词数;读取第二行;统计词数;
告诉我们词数;读取第三行;统计词数;告诉我们词数。
以此类推,直到读取所有行,最后关闭文件。上述指令非常直白,但若文件行数很多, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

What Successful Project Managers Do

What Successful Project Managers Do

W. Scott Cameron, Jeffrey S. Russell, Edward J. Hoffman, Alexander Laufer
How to Overcome a Power Deficit

How to Overcome a Power Deficit

Cyril Bouquet, Jean-Louis Barsoux
The Human Factor in AI-Based Decision-Making

The Human Factor in AI-Based Decision-Making

Philip Meissner, Christoph Keding

Publisher Resources

ISBN: 9787519864422