辟谷什么意思| 五月二十一号是什么星座| 小金蛙吃什么| 打开什么| 周到是什么意思| 粉红是什么意思| 哪吒为什么叫哪吒| 春梦是什么意思| 结缔组织病是什么病能治愈吗| 脑梗适合吃什么食物| 子宫内膜脱落是什么原因| 伤口撒什么药粉好得快| 孕晚期宫缩是什么感觉| 扌字旁的字和什么有关| 淋巴在什么位置| 血压突然升高是什么原因| 心阴不足吃什么中成药| 喝完酒头疼吃什么药| 杰字五行属什么| 玻尿酸是干什么用的| 夜间睡觉口干是什么原因| 十月30号是什么星座| lcu是什么意思| 手机root后有什么好处和坏处| 念珠菌感染用什么药效果好| 普洱茶属于什么茶| 康桑密达是什么意思| 水仙茶适合什么人喝| 容易紧张是什么原因| 去台湾需要什么证件| 腹膜转移是什么意思| 宋江是属什么生肖| 尿酸高去医院挂什么科| cns是什么意思| 重楼的别名叫什么| 长寿面什么时候吃| 一直鼻塞是什么原因| 牙齿痛吃什么消炎药| 6月份有什么节假日| 人民币代码是什么符号| 热射病是什么| 气虚便秘吃什么中成药| 尿急吃什么药效果最好| fwb什么意思| 大保健是什么意思| 欺人太甚什么意思| 小拇指有痣代表什么| 什么方法可以降血压| 输卵管堵塞是什么原因造成的| 韧带拉伤吃什么药| 一什么睡莲| 三十而立四十不惑什么意思| 陛下的陛是什么意思| 百雀羚适合什么年龄段| 57年的鸡是什么命| 贪是什么意思| 冠脉cta主要检查什么| 脊柱侧弯是什么原因引起的| 蚜虫用什么药| 大地色眼影是什么颜色| 来源朋友验证消息是什么意思| 董明珠什么星座| cc代表什么意思| tp是什么| 生肖鸡和什么生肖最配| 南京立冬吃什么| 什么叫书签| 芭乐是什么| 什么弓什么箭| c反应蛋白是查什么的| 2008属什么| 为什么会痛经| 陪嫁一般陪些什么东西| 生肖排第六是什么生肖| 五粮液什么香型| 胆固醇高不能吃什么| 吃什么能减肥最快还能减全身| 牙齿上白色斑块是什么| 脑溢血是什么原因| 失眠吃什么| 毛字出头念什么| 芒果吃了有什么好处和坏处| 南极被称为什么| 红斑狼疮的症状是什么| 环比增长什么意思| 为什么小鸟站在电线上不会触电| 榴莲什么季节成熟| 藕是莲的什么部位| 孕妇做春梦是什么意思| 眼珠子疼是什么原因| 手经常抖是什么原因| 通草是什么| 电镀对人体有什么危害| 终亡其酒的亡是什么意思| 身体发烧是什么原因| 隐忍是什么意思| cpi指数上涨意味着什么| 财神爷供奉什么供品| 三超是指什么| 中秋节什么时候| 湿气严重吃什么药好得快| 吃什么东西能变白| 梦中的梦中是什么歌| 梦见大蛇是什么预兆| 皲裂是什么意思| 美尼尔氏综合症是什么病| 鸟喙是什么意思| 急诊是什么意思| 二杠四星是什么军衔| 麦穗是什么牌子| 最后一个出场叫什么| 防血栓是什么意思| 嘱托是什么意思| 生长因子是什么| 梦见自己鞋子破了是什么意思| 莲藕是荷花的什么部位| 身份证尾号代表什么| 番茄和西红柿有什么区别| 千锤百炼什么意思| 李晨的爷爷叫什么| 格格不入什么意思| 鸡米头是什么| 小便不利什么意思| 智齿发炎吃什么| 男宠是什么意思| 老是嗝气是什么原因| 动容什么意思| 口腔溃疡吃什么药| 帕金森吃什么药最好| 三月阳春好风光是什么生肖| 皮笑肉不笑是什么生肖| 脓是什么| 重色轻友是什么意思| 为什么有的人晒不黑| 鲜卑族现在是什么族| 梦见巨蟒是什么预兆| dha中文叫什么| 叶子发黄是什么原因| 梦见怀孕是什么预兆| 菊花泡水喝有什么好处| 人为什么要火化| 荷尔蒙分泌是什么意思| 田园生活是什么意思| 369是什么意思| 为什么眼皮会一直跳| 什么牌子的蛋白质粉比较好| 小肚右边疼是什么原因| 乙肝病毒表面抗体阳性是什么意思| 殳是什么意思| 胸口堵是什么原因| 鬼代表什么数字| peg是什么意思| 榜眼是什么意思| 4五行属什么| 濯清涟而不妖的濯是什么意思| 17年是什么年| 什么叫有格局的人| 单数是什么| 为什么一站起来就头晕眼前发黑| bosco是什么意思| 低血压高是什么原因造成的| 梦见换房子是什么预兆| 医生为什么叫大夫| 印第安纹是什么| 组织部是干什么的| 党委副书记是什么级别| 卦是什么意思| 秦朝为什么那么快灭亡| 鸽子夏天喝什么水好| 避讳是什么意思| 抽搐是什么意思| 打2个喷嚏代表什么| 桑葚泡水喝有什么好处| 唐僧是什么佛| 单脐动脉对胎儿有什么影响| 潜阳是什么意思| 醋泡葡萄干有什么功效和作用| 涂是什么意思| 丹毒是什么原因引起的| 阳光灿烂是什么意思| 转氨酶升高有什么症状| 阴道松弛吃什么药| 转氨酶高吃什么食物降得快| 虚岁是什么意思| 无花果不能和什么一起吃| 小腿肚子抽筋是什么原因| 布病挂什么科| 云母是什么东西| 肛门坠胀吃什么消炎药| 非洲是什么人种| 路亚竿什么品牌好| 8023什么意思| 低烧不退是什么原因| 维生素b族适合什么人吃| 吃什么瘦肚子最快| angelababy英文什么意思| 10月25日什么星座| 炎性结节是什么意思| 旦角是什么意思| 吸入物变应原筛查是什么| 手上长红点是什么原因| dwi呈高信号什么意思| 感冒全身酸痛吃什么药| 攫住是什么意思| 鳊鱼吃什么食物| 月亮是什么星| 温水煮青蛙什么意思| 查过敏源挂什么科| 汐五行属性是什么| 甲壳素是什么东西| 脸红是什么原因| 嘴唇薄的男人面相代表什么意味| 表姐的孩子叫我什么| 痔疮手术后可以吃什么水果| 痰湿中阻吃什么中成药| 走水是什么意思| 7月4号什么星座| 什么是焦距| 干红是什么意思| 发烧吃什么消炎药| 右脸长痘是什么原因| 什么鸟没有翅膀| 中国国酒是什么| 白细胞高是什么病| 什么安神助睡眠| 美帝是什么意思| 效价是什么意思| 渗湿是什么意思| 中分化是什么意思| 做些什么| 减肥晚上适合吃什么水果| 尿多尿频是什么原因| 伤心的反义词是什么| 五台山求什么最灵| b型血为什么叫贵族血| 朋友圈ps是什么意思| 宴字五行属什么| 印度为什么那么热| 为什么嗓子总有痰| 什么是肠息肉| 牛河是什么| 土茯苓与茯苓有什么区别| 回笼是什么意思| 猫咖是什么| 品是什么意思| 算力是什么| 处女膜是什么样的| 高压氧治疗有什么作用| 性张力什么意思| 女人银屑病一般都长什么地方| 打胎后要注意什么| 焦虑失眠吃什么药最好| 聊胜于无什么意思| 圣大保罗属于什么档次| 肝内胆管结石吃什么药好| 干什么赚钱| 小孩睡觉打呼噜是什么原因| 癫痫是什么| 大腿根部痛是什么原因| 血虚风燥是什么意思| 谷丙转氨酶偏高是什么原因| 电脑pin是什么意思| 虚情假意是什么意思| 乌鸦叫预示什么| 百度Jump to content

中国代表団、世界水フォーラムに登場 水利事業の成果紹介

From Wikipedia, the free encyclopedia
百度   事实上,中国移动早在2016年便推出了第一代4G智能后视镜,可实现4G联网、智能导航、语音识别等;2017年,中国移动发布面向后装市场的“和路通”品牌,推出第二代智能后视镜X1。

Loop-level parallelism is a form of parallelism in software programming that is concerned with extracting parallel tasks from loops. The opportunity for loop-level parallelism often arises in computing programs where data is stored in random access data structures. Where a sequential program will iterate over the data structure and operate on indices one at a time, a program exploiting loop-level parallelism will use multiple threads or processes which operate on some or all of the indices at the same time. Such parallelism provides a speedup to overall execution time of the program, typically in line with Amdahl's law.

Description

[edit]

For simple loops, where each iteration is independent of the others, loop-level parallelism can be embarrassingly parallel, as parallelizing only requires assigning a process to handle each iteration. However, many algorithms are designed to run sequentially, and fail when parallel processes race due to dependence within the code. Sequential algorithms are sometimes applicable to parallel contexts with slight modification. Usually, though, they require process synchronization. Synchronization can be either implicit, via message passing, or explicit, via synchronization primitives like semaphores.

Example

[edit]

Consider the following code operating on a list L of length n.

for (int i = 0; i < n; ++i) {
    S1: L[i] += 10;
}

Each iteration of the loop takes the value from the current index of L, and increments it by 10. If statement S1 takes T time to execute, then the loop takes time n * T to execute sequentially, ignoring time taken by loop constructs. Now, consider a system with p processors where p > n. If n threads run in parallel, the time to execute all n steps is reduced to T.

Less simple cases produce inconsistent, i.e. non-serializable outcomes. Consider the following loop operating on the same list L.

for (int i = 1; i < n; ++i) {
    S1: L[i] = L[i-1] + 10;
}

Each iteration sets the current index to be the value of the previous plus ten. When run sequentially, each iteration is guaranteed that the previous iteration will already have the correct value. With multiple threads, process scheduling and other considerations prevent the execution order from guaranteeing an iteration will execute only after its dependence is met. It very well may happen before, leading to unexpected results. Serializability can be restored by adding synchronization to preserve the dependence on previous iterations.

Dependencies in code

[edit]

There are several types of dependences that can be found within code.[1][2]

Type Notation Description
True (Flow) Dependence S1 ->T S2 A true dependence between S1 and S2 means that S1 writes to a location later read from by S2
Anti Dependence S1 ->A S2 An anti-dependence between S1 and S2 means that S1 reads from a location later written to by S2.
Output Dependence S1 ->O S2 An output dependence between S1 and S2 means that S1 and S2 write to the same location.
Input Dependence S1 ->I S2 An input dependence between S1 and S2 means that S1 and S2 read from the same location.

In order to preserve the sequential behaviour of a loop when run in parallel, True Dependence must be preserved. Anti-Dependence and Output Dependence can be dealt with by giving each process its own copy of variables (known as privatization).[1]

Example of true dependence

[edit]
S1: int a, b;
S2: a = 2;
S3: b = a + 40;

S2 ->T S3, meaning that S2 has a true dependence on S3 because S2 writes to the variable a, which S3 reads from.

Example of anti-dependence

[edit]
S1: int a, b = 40;
S2: a = b - 38;
S3: b = -1;

S2 ->A S3, meaning that S2 has an anti-dependence on S3 because S2 reads from the variable b before S3 writes to it.

Example of output-dependence

[edit]
S1: int a, b = 40;
S2: a = b - 38;
S3: a = 2;

S2 ->O S3, meaning that S2 has an output dependence on S3 because both write to the variable a.

Example of input-dependence

[edit]
S1: int a, b, c = 2;
S2: a = c - 1;
S3: b = c + 1;

S2 ->I S3, meaning that S2 has an input dependence on S3 because S2 and S3 both read from variable c.

Dependence in loops

[edit]

Loop-carried vs loop-independent dependence

[edit]

Loops can have two types of dependence:

  • Loop-carried dependence
  • Loop-independent dependence

In loop-independent dependence, loops have inter-iteration dependence, but do not have dependence between iterations. Each iteration may be treated as a block and performed in parallel without other synchronization efforts.

In the following example code used for swapping the values of two array of length n, there is a loop-independent dependence of S1 ->T S3.

for (int i = 1; i < n; ++i) {
    S1: tmp = a[i];
    S2: a[i] = b[i];
    S3: b[i] = tmp;
}

In loop-carried dependence, statements in an iteration of a loop depend on statements in another iteration of the loop. Loop-Carried Dependence uses a modified version of the dependence notation seen earlier.

Example of loop-carried dependence where S1[i] ->T S1[i + 1], where i indicates the current iteration, and i + 1 indicates the next iteration.

for (int i = 1; i < n; ++i) {
    S1: a[i] = a[i-1] + 1;
}

Loop carried dependence graph

[edit]

A Loop-carried dependence graph graphically shows the loop-carried dependencies between iterations. Each iteration is listed as a node on the graph, and directed edges show the true, anti, and output dependencies between each iteration.

Types

[edit]

There are a variety of methodologies for parallelizing loops.

  • DISTRIBUTED Loop
  • DOALL Parallelism
  • DOACROSS Parallelism
  • HELIX [3]
  • DOPIPE Parallelism

Each implementation varies slightly in how threads synchronize, if at all. In addition, parallel tasks must somehow be mapped to a process. These tasks can either be allocated statically or dynamically. Research has shown that load-balancing can be better achieved through some dynamic allocation algorithms than when done statically.[4]

The process of parallelizing a sequential program can be broken down into the following discrete steps.[1] Each concrete loop-parallelization below implicitly performs them.

Type Description
Decomposition The program is broken down into tasks, the smallest exploitable unit of concurrence.
Assignment Tasks are assigned to processes.
Orchestration Data access, communication, and synchronization of processes.
Mapping Processes are bound to processors.

DISTRIBUTED loop

[edit]

When a loop has a loop-carried dependence, one way to parallelize it is to distribute the loop into several different loops. Statements that are not dependent on each other are separated so that these distributed loops can be executed in parallel. For example, consider the following code.

for (int i = 1; i < n; ++i) {
    S1: a[i] = a[i-1] + b[i];
    S2: c[i] += d[i];
}

The loop has a loop carried dependence S1[i] ->T S1[i+1] but S2 and S1 do not have a loop-independent dependence so we can rewrite the code as follows.

loop1: for (int i = 1; i < n; ++i) {
    S1: a[i] = a[i-1] + b[i];
}
loop2: for (int i = 1; i < n; ++i) {
    S2: c[i] += d[i];
}

Note that now loop1 and loop2 can be executed in parallel. Instead of single instruction being performed in parallel on different data as in data level parallelism, here different loops perform different tasks on different data. Let's say the time of execution of S1 and S2 be and then the execution time for sequential form of above code is , Now because we split the two statements and put them in two different loops, gives us an execution time of . We call this type of parallelism either function or task parallelism.

DOALL parallelism

[edit]

DOALL parallelism exists when statements within a loop can be executed independently (situations where there is no loop-carried dependence).[1] For example, the following code does not read from the array a, and does not update the arrays b, c. No iterations have a dependence on any other iteration.

for (int i = 0; i < n; ++i) {
    S1: a[i] = b[i] + c[i];
}

Let's say the time of one execution of S1 be then the execution time for sequential form of above code is , Now because DOALL Parallelism exists when all iterations are independent, speed-up may be achieved by executing all iterations in parallel which gives us an execution time of , which is the time taken for one iteration in sequential execution.

The following example, using a simplified pseudo code, shows how a loop might be parallelized to execute each iteration independently.

begin_parallelism();
for (int i = 0; i < n; ++i) {
    S1: a[i] = b[i] + c[i];
    end_parallelism();
}
block();

DOACROSS parallelism

[edit]

DOACROSS Parallelism exists where iterations of a loop are parallelized by extracting calculations that can be performed independently and running them simultaneously.[5]

Synchronization exists to enforce loop-carried dependence.

Consider the following, synchronous loop with dependence S1[i] ->T S1[i+1].

for (int i = 1; i < n; ++i) {
    a[i] = a[i-1] + b[i] + 1;
}

Each loop iteration performs two actions

  • Calculate a[i-1] + b[i] + 1
  • Assign the value to a[i]

Calculating the value a[i-1] + b[i] + 1, and then performing the assignment can be decomposed into two lines(statements S1 and S2):

S1: int tmp = b[i] + 1;
S2: a[i] = a[i-1] + tmp;

The first line, int tmp = b[i] + 1;, has no loop-carried dependence. The loop can then be parallelized by computing the temp value in parallel, and then synchronizing the assignment to a[i].

post(0);
for (int i = 1; i < n; ++i) {

    S1: int tmp = b[i] + 1;
    wait(i-1);

    S2: a[i] = a[i-1] + tmp;
    post(i);
}

Let's say the time of execution of S1 and S2 be and then the execution time for sequential form of above code is , Now because DOACROSS Parallelism exists, speed-up may be achieved by executing iterations in a pipelined fashion which gives us an execution time of .

DOPIPE parallelism

[edit]

DOPIPE Parallelism implements pipelined parallelism for loop-carried dependence where a loop iteration is distributed over multiple, synchronized loops.[1] The goal of DOPIPE is to act like an assembly line, where one stage is started as soon as there is sufficient data available for it from the previous stage.[6]

Consider the following, synchronous code with dependence S1[i] ->T S1[i+1].

for (int i = 1; i < n; ++i) {
    S1: a[i] = a[i-1] + b[i];
    S2: c[i] += a[i];
}

S1 must be executed sequentially, but S2 has no loop-carried dependence. S2 could be executed in parallel using DOALL Parallelism after performing all calculations needed by S1 in series. However, the speedup is limited if this is done. A better approach is to parallelize such that the S2 corresponding to each S1 executes when said S1 is finished.

Implementing pipelined parallelism results in the following set of loops, where the second loop may execute for an index as soon as the first loop has finished its corresponding index.

for (int i = 1; i < n; ++i) {
    S1: a[i] = a[i-1] + b[i];
        post(i);
}

for (int i = 1; i < n; i++) {
        wait(i);
    S2: c[i] += a[i];
}

Let's say the time of execution of S1 and S2 be and then the execution time for sequential form of above code is , Now because DOPIPE Parallelism exists, speed-up may be achieved by executing iterations in a pipelined fashion which gives us an execution time of , where p is the number of processor in parallel.

See also

[edit]

References

[edit]
  1. ^ a b c d e Solihin, Yan (2016). Fundamentals of Parallel Architecture. Boca Raton, FL: CRC Press. ISBN 978-1-4822-1118-4.
  2. ^ Goff, Gina (1991). "Practical dependence testing". Proceedings of the ACM SIGPLAN 1991 conference on Programming language design and implementation - PLDI '91. pp. 15–29. doi:10.1145/113445.113448. ISBN 0897914287. S2CID 2357293.
  3. ^ Murphy, Niall. "Discovering and exploiting parallelism in DOACROSS loops" (PDF). University of Cambridge. Retrieved 10 September 2016.
  4. ^ Kavi, Krishna. "Parallelization of DOALL and DOACROSS Loops-a Survey". {{cite journal}}: Cite journal requires |journal= (help)
  5. ^ Unnikrishnan, Priya (2012), "A Practical Approach to DOACROSS Parallelization", Euro-Par 2012 Parallel Processing, Lecture Notes in Computer Science, vol. 7484, pp. 219–231, doi:10.1007/978-3-642-32820-6_23, ISBN 978-3-642-32819-0, S2CID 18571258
  6. ^ "DoPipe: An Effective Approach to Parallelize Simulation" (PDF). Intel. Retrieved 13 September 2016.
热锅凉油是什么意思 流浓黄鼻涕是什么原因 拜土地公时要念什么好 屮艸芔茻什么意思 n什么意思
巴士是什么意思 病毒性感冒吃什么药效果好 肉麻是什么意思 正餐是什么意思 软组织肿胀是什么意思
冠冕堂皇是什么意思 少将相当于地方什么级别 排除是什么意思 羊肉和什么不能一起吃 528是什么意思
大象的鼻子有什么作用 关帝是什么神 肌酸激酶偏低是什么原因 大便漂浮水面说明什么 二级烫伤是什么程度
喝红茶有什么好处hcv7jop6ns8r.cn 四大是什么hcv8jop7ns9r.cn 不愁吃穿是什么生肖hcv9jop5ns7r.cn 艾滋病早期有什么症状520myf.com 什么血型生出o型血wzqsfys.com
三伏是什么时候hcv7jop7ns3r.cn 腱鞘炎是什么原因引起的ff14chat.com 慎什么意思wuhaiwuya.com 傻白甜什么意思xinmaowt.com 耳朵疼吃什么消炎药hcv7jop5ns0r.cn
心慌挂什么科aiwuzhiyu.com 精液是什么组成的hcv8jop3ns8r.cn 为什么狗不能吃巧克力hcv9jop7ns0r.cn 阴虚火旺什么意思hcv8jop8ns6r.cn 牡丹花什么颜色hcv8jop6ns3r.cn
股骨长径是指胎儿什么hcv8jop6ns9r.cn 高血压药什么时候吃最好hcv8jop0ns6r.cn 助产士一般什么学历hcv9jop5ns4r.cn 苹果和什么一起榨汁好喝hcv7jop9ns4r.cn 为难的难是什么意思clwhiglsz.com
百度