正在加载图片...
第十四章分布存储系统并行编程 习题例题: 1、试考虑下述代码段中通信体的使用; MPI Send(msg l, countI, MPI INT, tagl, commD); parallel fft(.) MPI Recv(msgl, countI, MPI INT, tagl, commD); )试分析上述代码段的计算功能 (2)如果在 parallel fft(..)中又包含了另一个发送程序 If(my rank ==0)MPI Send( msg2, countI, MPI INT, 1, tag2, comm2) 如果没有通信体则会发生什么情况? 2、填上空白处,使下面两代码段完全等效: l) float data[1024]」 MPI Datatype floattype MPI Type vector(10, 1, 32, MPI FLOAT, &floattype) MPI Type commit( &floattype) MPI Send(data, 1, floattype, dest, tag, MPI COMM WORLD) (2)float data[ 1024, buff 101 i++buff(]=data MPI Send( buff, MPI FLOAT 3、下面是PVM环境下的 hello程序,它是一个 host/node程序,试分析其工作过程 ∥PⅤM主机/节点编程的 hello代码段∥ /*host程序 hello.c* #include <stdio. h> # include“pvm3.h” char buf[1001 printf("I'm t%n, pvm myido) cc= pvm span( hello other”,(char**)0,0,“”,1,&tid) if(c==1) c→ pvm recv(-1,-1) pvm bufinfo(cc, (int*)o,(int*)0, &tid); pvm upkstr(buf) printf( from t%x: %s\n,tid, buf) i else第十四章 分布存储系统并行编程 习题例题: 1、试考虑下述代码段中通信体的使用; process 0: MPI_Send(msg1,count1,MPI_INT,tag1,comm1); parallel_fft(...); process 1: MPI_Recv(msg1,count1,MPI_INT,tag1,comm1); parallel_fft(...); ⑴试分析上述代码段的计算功能。 ⑵如果在 parallel_fft(...)中又包含了另一个发送程序: If(my_rank = = 0) MPI_Send(msg2,count1,MPI_INT,1,tag2,comm2); 如果没有通信体则会发生什么情况? 2、填上空白处,使下面两代码段完全等效: ⑴float data[1024]; MPI_Datatype floattype; MPI_Type_vector(10,1,32,MPI_FLOAT,&floattype); MPI_Type_commit(&floattype); MPI_Send(data,1,floattype,dest,tag,MPI_COMM_WORLD); MPI_Type_free(&floattype); ⑵float data[1024],buff[10]; for( ______ ; ______ ; i++) buff[i] = data [_____] MPI_Send(buff,______ , MPI_FLOAT,______ ,______ ,______ ); 3、下面是 PVM 环境下的 hello 程序,它是一个 host/node 程序,试分析其工作过程。 //*PVM 主机/节点编程的 hello 代码段*// /*host 程序 hello.c*/ #include <stdio.h> #include “pvm3.h” main() { int cc, tid; char buf[100]; printf(“i’m t%x \n”, pvm_myid()); cc=pvm_spwan(“hello_other”, (char **)0, 0, “”, 1, &tid); if (cc = = 1) { cc=pvm_recv(-1, -1); pvm_bufinfo(cc, (int *)0, (int *)0, &tid); pvm_upkstr(buf); printf(”from t%x: %s \n”, tid, buf); } else
向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有