文档介绍:第十四章分布存储系统并行编程<br****题例题:
1、试考虑下述代码段中通信体的使用;
process 0:
MPI_Send(msg1,count1,MPI_INT,m1);
parallel_fft(...);
process 1:
MPI_Recv(msg1,count1,MPI_INT,m1);
parallel_fft(...);
⑴试分析上述代码段的计算功能。
⑵如果在parallel_fft(...)中又包含了另一个发送程序:
If(my_rank = = 0) MPI_Send(msg2,count1,MPI_INT,1,m2);
如果没有通信体则会发生什么情况?
2、填上空白处,使下面两代码段完全等效:
⑴float data[1024];
MPI_Datatype floattype;
MPI_Type_vector(10,1,32,MPI_FLOAT,&floattype);
mit(&floattype);
MPI_Send(data,1,floattype,dest,tag,M_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代码段*//
/**/
#include <>
#include “”
main()
{
, 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);
, (int *)0, (int *)0, &tid);
pvm_upkstr(buf);
printf(”from t%x: %s \n”, tid, buf);
} else
printf(“can’t start hello_other \n”);
pvm_exit();
}
/**/
#include “”
#include “”
main()
{
int ptid;
char buf[100];
ptid=pvm_parent();
strcpy(buf, “hello, world from”);
gethostname(buf+strlen(buf), 64);
pvm_initsend(PvmDataDefault);
pvm_pkstr(buf);
pvm_send(ptid, 1);
pvm_exit();
exit