Parallel Techniques之 易并行计算

Slides:



Advertisements
Similar presentations
Prepared 7/28/2011 by T. O’Neil for 3460:677, Fall 2011, The University of Akron.
Advertisements

Chapter 11 Inferences About Population Variances
退 出退 出退 出退 出 上一页 下一页 仪器使用 §1-2 尺规绘图工具和仪器的使用方法 图板丁字尺三角板 比例尺圆规分规铅笔曲线板。 要提高绘图的准确度和绘图效率,必须正确地使用各种绘图工 具和仪器。常用的手工绘图工具和仪器有图板、丁字尺、三角板、 比例尺、圆规、分规、铅笔、曲线板等。 提示:将光标放在仪器上,
概率统计( ZYH ) 节目录 2.1 随机变量与分布函数 2.2 离散型随机变量的概率分布 2.3 连续型随机变量的概率分布 第二章 随机变量及其分布.
在近年的高考地理试题中,考查地球上 两点间最短航线的方向问题经常出现,由于 很多学生对这类问题没有从本质上搞清楚, 又缺乏空间想象能力,只是机械地背一些结 论,造成解这类题目时经常出错。 地球上两点间的最短航线方向问题.
Partitioning and Divide-and-Conquer Strategies ITCS 4/5145 Cluster Computing, UNC-Charlotte, B. Wilkinson, 2007.
COMPE472 Parallel Computing Embarrassingly Parallel Computations Partitioning and Divide-and-Conquer Strategies Pipelined Computations Synchronous Computations.
Partitioning and Divide-and-Conquer Strategies ITCS 4/5145 Cluster Computing, UNC-Charlotte, B. Wilkinson, 2007.
吉林大学远程教育课件 主讲人 : 杨凤杰学 时: 64 ( 第四十二讲 ) 离散数学. 例 设 S = {a , b} , ρ ( S ) ={ ,{a},{b},{a , b}} 是 S 的幂集合, 则( ρ ( S ),∩, ∪)是一个格。 规定映射 g 为: g (  ) =
Computational Physics Lecture 4 Dr. Guy Tel-Zur.
第二章 质点组力学 质点组:许多(有限或无限)相 互联系的质点组成的系统 研究方法: 1. 分离体法 2. 从整体考虑 把质点的三个定理推广到质点组.
第 5 章 几何变换 二维几何变换 三维几何变换. 二维几何变换 基本变换 矩阵表示和齐次坐标 复合变换 其它变换 坐标系间的变换 仿射变换 变换的光栅方法.
第 4 章 抽象解释 内容概述 以一种独立于编程语言的方式,介绍抽象解释的 一些本质概念 – 将 “ 程序分析对语言语义是正确的 ” 这个概念公式 化 – 用 “ 加宽和收缩技术 ” 来获得最小不动点的较好的 近似,并使所需计算步数得到限制 – 用 “ 伽罗瓦连接和伽罗瓦插入 ” 来把代价较大的属 性空间用代价较小的属性空间来代替.
Embarrassingly Parallel Computations Partitioning and Divide-and-Conquer Strategies Pipelined Computations Synchronous Computations Asynchronous Computations.
分析化学与无机化学中溶液 pH 值计算的异同比较 谢永生  分析化学是大学化学系的一门基础课,课 时较少,其内容主要是无机物的化学分析。 分析化学是以无机化学作为基础的,我们 都是在已掌握一定的无机化学知识后才学 习分析化学 。所以在分析 化学的学习中会 重复许多无机化学内容,造成学习没有兴.
2.1 结构上的作用 作用及作用效应 作用的分类 荷载分类及荷载代表值.
11-8. 电解质溶液的 活度和活度系数 电解质是有能力形成可以 自由移动的离子的物质. 理想溶液体系 分子间相互作用 实际溶液体系 ( 非电解质 ) 部分电离学说 (1878 年 ) 弱电解质溶液体系 离子间相互作用 (1923 年 ) 强电解质溶液体系.
吉林大学远程教育课件 主讲人 : 杨凤杰学 时: 64 ( 第三十八讲 ) 离散数学. 第八章 格与布尔代数 §8.1 引 言 在第一章中我们介绍了关于集 合的理论。如果将 ρ ( S )看做 是集合 S 的所有子集组成的集合, 于是, ρ ( S )中两个集合的并 集 A ∪ B ,两个集合的交集.
吉林大学远程教育课件 主讲人 : 杨凤杰学 时: 64 ( 第四十八讲 ) 离散数学. 例 设 S 是一个非空集合, ρ ( s )是 S 的幂集合。 不难证明 :(ρ(S),∩, ∪,ˉ, ,S) 是一个布尔代数。 其中: A∩B 表示 A , B 的交集; A ∪ B 表示 A ,
第十一章 曲线回归 第一节 曲线的类型与特点 第二节 曲线方程的配置 第三节 多项式回归.
线性代数习题课 吉林大学 术洪亮 第一讲 行 列 式 前面我们已经学习了关 于行列式的概念和一些基本 理论,其主要内容可概括为:
吉林大学远程教育课件 主讲人 : 杨凤杰学 时: 64 ( 第二十五讲 ) 离散数学. 定理 群定义中的条件 ( 1 )和( 2 )可以减弱如下: ( 1 ) ’ G 中有一个元素左壹适合 1 · a=a; ( 2 ) ’ 对于任意 a ,有一个元素左逆 a -1 适 合 a -1 ·
and Divide-and-Conquer Strategies
吉林大学远程教育课件 主讲人 : 杨凤杰学 时: 64 ( 第三十九讲 ) 离散数学. 例 设 S 是一个集合, ρ ( S )是 S 的幂集合,集合 的交( ∩ ),并(∪)是 ρ ( S )上的两个代数运算, 于是,( ρ ( S ), ∩ ,∪) 是一个格。而由例 知.
1 应用计量分析在公共财政领域的应用黄智聪 厦门大学财政系研究生课程 课程名称:应用计量分析在公共财政领域的 应用 授课老师:黄智聪 授课内容: 时间序列与横断面资料的共用 參考書目: Hill, C. R., W. E. Griffiths, and G. G. Judge, (2001), Undergraduate.
吉林大学远程教育课件 主讲人 : 杨凤杰学 时: 64 ( 第四十五讲 ) 离散数学 模 格 定义 设( L , ≤ ) 是一个格,对任意 a , b , c ∈ L , 如果 a≤b ,都有 a  ( b×c ) = b× ( a  c ) 则称( L , ≤ )为模格。
OS 进程调度模拟演示 制作人: 钱晶 高上上. OS 进程调度模拟-实验原理 静态优先级原理 在这种方式下,系统一旦把处理机分配给就绪队 列中的优先权最高的进程后,该进程便一直执行下去, 直至完成。或因为发生某事件使该进程放弃处理机,系 统方可再将处理机分配给另一优先级最高的进程。这些 事件包括有优先级更高的进程进入,或是因为某些原因.
非均相物系的分离 沉降速度 球形颗粒的 :一、自由沉降 二、沉降速度的计算 三、直径计算 1. 试差法 2. 摩擦数群法 四、非球形颗粒的自由沉降 1. 当量直径 de :与颗粒体积相等的圆球直径 V P — 颗粒的实际体积 2. 球形度  s : S—— 与颗粒实际体积相等的球形表面积.
数 学 系 University of Science and Technology of China DEPARTMENT OF MATHEMATICS 第 4 章 非线性方程求根 非线性科学是当今科学发展的一个重要研究方向,而非线性 方程的求根也成了一个不可缺的内容。但是,非线性方程的求根 非常复杂。
主讲教师:陈殿友 总课时: 124 第十一讲 极限的运算法则. 第一章 二、 极限的四则运算法则 三、 复合函数的极限运算法则 一 、无穷小运算法则 机动 目录 上页 下页 返回 结束 §5 极限运算法则.
在发明中学习 线性代数 概念的引入 李尚志 中国科学技术大学. 随风潜入夜 : 知识的引入 之一、线性方程组的解法 加减消去法  方程的线性组合  原方程组的解是新方程的解 是否有 “ 增根 ” ?  互为线性组合 : 等价变形  初等变换  高斯消去法.
Embarrassingly Parallel Computations Partitioning and Divide-and-Conquer Strategies Pipelined Computations Synchronous Computations Asynchronous Computations.
Photoshop CS4 标准培训教程 第三章第三章 在 Photoshop CS4 中所谓的不规则选区指的是随意性强,不被局限在几何形状内, 他们可以是鼠标任意创建的也可以是通过计算而得到的单个选区或多个选区。在 Photoshop 中可以用来创建不规则选区的工具被分组放置到套索工具组、魔棒工具组.
第一节 相图基本知识 1 三元相图的主要特点 (1)是立体图形,主要由曲面构成; (2)可发生四相平衡转变; (3)一、二、三相区为一空间。
1/108 随机信号分析. 2/116 第 2 章 随机信号 3/ 定义与基本特性 2.2 典型信号举例 2.3 一般特性与基本运算 2.4 多维高斯分布与高斯信号 2.5 独立信号 目 录.
第 3 章 控制流分析 内容概述 – 定义一个函数式编程语言,变量可以指称函数 – 以 dynamic dispatch problem 为例(作为参数的 函数被调用时,究竟执行的是哪个函数) – 规范该控制流分析问题,定义什么是可接受的控 制流分析 – 定义可接受分析在语义模型上的可靠性 – 讨论分析算法.
吉林大学远程教育课件 主讲人 : 杨凤杰学 时: 64 ( 第五十三讲 ) 离散数学. 定义 设 G= ( V , T , S , P ) 是一个语法结构,由 G 产生的语言 (或者说 G 的语言)是由初始状态 S 演绎出来的所有终止符的集合, 记为 L ( G ) ={w  T *
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M
Department of Mathematics 第二章 解析函数 第一节 解析函数的概念 与 C-R 条件 第二节 初等解析函数 第三节 初等多值函数.
《 UML 分析与设计》 交互概述图 授课人:唐一韬. 知 识 图 谱知 识 图 谱知 识 图 谱知 识 图 谱.
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M
Scientific Computing Lecture 5 Dr. Guy Tel-Zur Autumn Colors, by Bobby Mikul, Mikul Autumn Colors, by Bobby Mikul,
Embarrassingly Parallel Computations processes …….. Input data results Each process requires different data and produces results from its input without.
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M
新一代移动物联系统 MC MOBILE CONTROL 开启办公物联网时代 Product Promotion.
§10.2 对偶空间 一、对偶空间与对偶基 二、对偶空间的有关结果 三、例题讲析.
请同学们仔细观察下列两幅图有什么共同特点? 如果两个图形不仅形状相同,而且每组对应点所在的直线 都经过同一点, 那么这样的两个图形叫做位似图形, 这个点叫做位 似中心.
超星数字图书馆 一、页面的使用 进入数字图书馆网页 下载超星阅读器 查找图书.
Embarrassingly Parallel Computations Partitioning and Divide-and-Conquer Strategies Pipelined Computations Synchronous Computations Asynchronous Computations.
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M
CSCI-455/552 Introduction to High Performance Computing Lecture 11.5.
力的合成 力的合成 一、力的合成 二、力的平行四边形 上一页下一页 目 录 退 出. 一、力的合成 O. O. 1. 合力与分力 我们常常用 一个力来代替几个力。如果这个 力单独作用在物体上的效果与原 来几个力共同作用在物体上的效 果完全一样,那么,这一个力就 叫做那几个力的合力,而那几个 力就是这个力的分力。
CSCI-455/552 Introduction to High Performance Computing Lecture 9.
1 第 4 章 速度瞬心及其应用 ● 利用速度瞬心进行机构的速度分析 ● 将低副机构转变为高副机构 ( 瞬心线机 构,共轭曲线机构) ● 用低副机构的分析方法对高副机构进 行结构和运动分析 ( 高副低代 )
第五章 特征值与特征向量 —— 幂法 /* Power Method */ 计算矩阵的主特征根及对应的特征向量 Wait a second, what does that dominant eigenvalue mean? That is the eigenvalue with the largest.
八. 真核生物的转录 ㈠ 特点 ① 转录单元为单顺反子( single cistron ),每 个蛋白质基因都有自身的启动子,从而造成在功能 上相关而又独立的基因之间具有更复杂的调控系统。 ② RNA 聚合酶的高度分工,由 3 种不同的酶催化转 录不同的 RNA 。 ③ 需要基本转录因子与转录调控因子的参与,这.
一、 版 面 构 成 的 概 念 版 面 构 成 的 概 念 二、 版 面 构 成 的 发 展 趋 势 版 面 构 成 的 发 展 趋 势 三、 广 告 文 字 的 版 面 构 成 广 告 文 字 的 版 面 构 成 四、 广 告 版 面 的 视 觉 流 程 广 告 版 面 的 视 觉 流 程.
U niversity of S cience and T echnology of C hina VxWorks 及其应用开发 陈香兰 年 7 月.
3D 仿真机房建模 哈尔滨工业大学 指导教师:吴勃英、张达治 蒋灿、杜科材、魏世银 机房尺寸介绍.
欢 迎 使 用 《工程流体力学》 多媒体授课系统 燕 山 大 学 《工程流体力学》课程组. 第九章 缝隙流动 概述 9.1 两固定平板间的层流流动 9.2 具有相对运动的两平行平板 间的缝隙流动 9.3 环形缝隙中的层流流动.
1 第三章 数列 数列的概念 考点 搜索 ●数列的概念 ●数列通项公式的求解方法 ●用函数的观点理解数列 高考 猜想 以递推数列、新情境下的 数列为载体, 重点考查数列的通 项及性质, 是近年来高考的热点, 也是考题难点之所在.
1 Chapter4 Partitioning and Divide-and-Conquer Strategies 划分和分治的并行技术 Lecture 5.
Embarrassingly Parallel Computations
and Divide-and-Conquer Strategies
Monte Carlo Methods A so-called “embarrassingly parallel” computation as it decomposes into obviously independent tasks that can be done in parallel without.
Introduction to High Performance Computing Lecture 7
Parallel Techniques • Embarrassingly Parallel Computations
Embarrassingly Parallel Computations
Introduction to High Performance Computing Lecture 8
Presentation transcript:

Parallel Techniques之 易并行计算 Lecture 4 Parallel Techniques之 易并行计算 张少强 http://bioinfo.uncc.edu/szhang sqzhang@163.com

Embarrassingly Parallel Computations Parallel Techniques Embarrassingly Parallel Computations

Embarrassingly Parallel Computations A computation that can obviously be divided into a number of completely independent parts, each of which can be executed by a separate process(or).计算可以很显然地被分成一组完全独立的部分,每部分可分别由一个进程执行。 进程之间没有或有很少的通信 每个进程可以不与其他进程有交互来运行任务

Practical embarrassingly parallel computation with static process creation and master-slave approach

Embarrassingly Parallel Computation Examples • Low level image processing • Mandelbrot set • Monte Carlo Calculations

Low level image processing Many low level image processing operations only involve local data with very limited if any communication between areas of interest.

Image coordinate system Origin (0,0) x . (x, y) y

Some geometrical operations Shifting平移 Object shifted by Dx in x-dimension and Dy in y-dimension: x¢ = x + Dx y¢ = y + Dy where x and y are original coordinates and x¢ and y¢ are the new coordinates. x y Dx Dy

Some geometrical operations Scaling缩放 Object scaled by factor Sx in x-direction and Sy in y-direction: x¢ = xSx y¢ = ySy x y 3.8

Rotation翻转 Object rotated through an angle q about the origin of the coordinate system: x¢ = x cosq + y sinq y¢ = -x sinq + y cosq x y 3.8

Parallelizing Image Operations Partitioning into regions for individual processes Example Square region for each process (can also use strips) 3.9

主进程master process for(i=0,row=0;i<48;i++,row=row+10) 480行,10行一组分割;分出48个从进程;每个进程处理640*10区域。 for(i=0,row=0;i<48;i++,row=row+10) Send(row,P(i)); /*send row to process i*/ for(i=0;i<480;i++) for(i=0;i<640;j++) temp_map[i][j]=0; for(i=0;i<(640*480);i++) Recv(oldrow,oldcol,newrow,newcol,P_any); if!((newrow<0)||(newrow>=480)||(newcol<0)||(newcol>=640)) temp_map[newrow][newcol]=map[oldrow][oldcol]; } for(j=0;j<640;j++) map[i][j]=temp_map[i][j];

从进程slave process 平移的从进程 从进程之间没有通信 Recv(row, P(0)); /*revecive from master process*/ for(oldrow=row;oldrow<(row+10);oldrow++) for(oldcol=0;oldcol<640;oldcol++){ newrow=oldrow+delta_x; newcol=oldcol+delta_y; Send(oldrow,oldcol,newrow,newcol,P(0)); } 从进程之间没有通信

Mandelbrot Set曼德博集合 是一种在复平面上组成分形的点的集合 Set of points in a complex plane that are quasi-stable (will increase and decrease, but not exceed some limit) when computed by iterating the function: where zk +1 is the (k + 1)th iteration of complex number: z = a + bi and c is a complex number giving position of point in the complex plane. The initial value for z is zero.

Mandelbrot Set continued Zk 或者延伸到无限大,或者只停留在有限半径的圆盘内。 曼德博集合就是使以上序列不延伸至无限大的所有c点的集合。 Iterations continued until magnitude of z is: Greater than 2 or Number of iterations reaches arbitrary limit. Magnitude of z is the length of the vector given by:

对一点(像素)的值进行计算并返回迭代次数(色) structure complex { float real; float imag; }; int cal_pixel(complex c) { int count, max; complex z; float temp, lengthsq; max = 256; /*若令256为黑色*/ z.real = 0; z.imag = 0; count = 0; /* number of iterations */ do { temp = z.real * z.real - z.imag * z.imag + c.real; z.imag = 2 * z.real * z.imag + c.imag; z.real = temp; lengthsq = z.real * z.real + z.imag * z.imag; count++; } while ((lengthsq < 4.0) && (count < max)); return count; }

Mandelbrot set

Static Task Assignment Parallelizing Mandelbrot Set Computation Static Task Assignment Simply divide the region in to fixed number of parts, each computed by a separate processor. Not very successful because different regions require different numbers of iterations and time.

Dynamic Task Assignment Have processor request regions after computing previous regions

动态主进程 Count=0; Row=0; For(k=0;k<num_proc;k++) /*进程数<row/ send(&row,Pk,data_tag); count++; row++; } do{ recv(&slave,&r,color,P_any,result_tag); count--; if(row <disp_height){ send(&row,P_slave,data_tag); }else send(&row, P_slave,terminator_tag); display(); }while(count>0)

Monte Carlo Methods Another embarrassingly parallel computation. Monte Carlo methods use of random selections.

2 x 2的正方形内接一个圆. 圆与正方形的面具比值为: 在正方形内随机选择很多“点”. 记下有多少个“点”落在圆中。 Fraction of points within circle will be , given sufficient number of randomly selected samples.

Computing an Integral One quadrant can be described by integral Random pairs of numbers, (xr,yr) generated, each between 0 and 1. Counted as in circle if

Alternative (better) Method Use random values of x to compute f(x) and sum values of f(x): where xr are randomly generated values of x between x1 and x2. Monte Carlo method very useful if the function cannot be integrated numerically (maybe having a large number of variables)

Example Computing the integral Sequential Code sum = 0; for (i = 0; i < N; i++) { /* N random samples */ xr = rand_v(x1, x2); /* generate next random value */ sum = sum + xr * xr - 3 * xr; /* compute f(xr) */ } area = (sum / N) * (x2 - x1); Routine randv(x1, x2) returns a pseudorandom number between x1 and x2.

For parallelizing Monte Carlo code, must address best way to generate random numbers in parallel

/********************************************************************************* pi_calc.cpp calculates value of pi and compares with actual value (to 25digits) of pi to give error. Integrates function f(x)=4/(1+x^2). **********************************************************************************/ #include <math.h> //include files #include <iostream.h> #include "mpi.h " void printit(); //function prototypes int main(int argc, char *argv[]) { double actual_pi = 3.141592653589793238462643; //for comparison later int n, rank, num_proc, i; double temp_pi, calc_pi, int_size, part_sum, x; char response = 'y', resp1 = 'y'; MPI::Init(argc, argv); //initiate MPI

num_proc = MPI::COMM_WORLD.Get_size(); rank = MPI::COMM_WORLD.Get_rank(); if (rank == 0) printit(); /* I am root node, print out welcome */ while (response == 'y') { if (resp1 == 'y') { if (rank == 0) { /*I am root node*/ cout <<"__________________________________" <<endl; cout <<"\nEnter the number of intervals: (0 will exit)" << endl; cin >> n;} } else n = 0; MPI::COMM_WORLD.Bcast(&n, 1, MPI::INT, 0); //broadcast n if (n==0) break; //check for quit condition

else { int_size = 1.0 / (double) n; //calcs interval size part_sum = 0.0; for (i = rank + 1; i <= n; i += num_proc) { //calcs partial sums x = int_size * ((double)i - 0.5); part_sum += (4.0 / (1.0 + x*x)); } temp_pi = int_size * part_sum; //collects all partial sums computes pi MPI::COMM_WORLD.Reduce(&temp_pi,&calc_pi, 1, MPI::DOUBLE, MPI::SUM, 0);

if (rank == 0) { /*I am server*/ cout << "pi is approximately " << calc_pi << ". Error is " << fabs(calc_pi - actual_pi) << endl <<"_______________________________________" << endl; } } //end else if (rank == 0) { /*I am root node*/ cout << "\nCompute with new intervals? (y/n)" << endl; cin >> resp1; }//end while MPI::Finalize(); //terminate MPI return 0; } //end main

//functions void printit() { cout << "\n*********************************" << endl << "Welcome to the pi calculator!" << endl << "You set the number of divisions \nfor estimating the integral: \n\tf(x)=4/(1+x^2)" << endl << "*********************************" << endl; } //end printit