相关文章推荐
任性的蚂蚁  ·  浅谈.Net ...·  8 月前    · 
火星上的鸡蛋  ·  c# - MailKit IMAP ...·  1 年前    · 
MPI_Comm_size(MPI_COMM_WORLD,&nPorcs); printf("This is rank %d of %d \n", myrank, nPorcs); if(0 == myrank){ for (int i=0; i<1024; ++i){ data[i]=i; MPI_Barrier(MPI_COMM_WORLD); #if change MPI_Datatype floattype; MPI_Type_vector(10,1,32,MPI_FLOAT,&floattype); MPI_Type_commit(&floattype); if(0 == myrank){ MPI_Send(data,1,floattype,1,tag1,MPI_COMM_WORLD); else{ MPI_Recv(data,1,floattype,0,tag1,MPI_COMM_WORLD,&status); if(1 == myrank){ printf("use MPI_Type_vector\n"); for(int i=0; i<10; ++i){ printf("data[%d] = %f \n", 32*i,data[32*i]); MPI_Type_free(&floattype); #else if(0 == myrank){ for(int i=0; i<10; ++i){ buff[i]=data[32*i]; MPI_Barrier(MPI_COMM_WORLD); if(0 == myrank){ MPI_Send(buff, 10, MPI_FLOAT, 1, tag1, MPI_COMM_WORLD); else{ MPI_Recv(buff, 10, MPI_FLOAT, 0, tag1, MPI_COMM_WORLD, &status); if(1 == myrank){ printf("do not use MPI_Type_vector\n"); for(int i=0; i<10; ++i){ printf("data[%d] = %f \n", 32*i,buff[i]); #endif MPI_Finalize(); return 0;