我在文件中写入2d块循环分布式数组时遇到问题。
我试过这件事:
rc=MPI_File_open(MPI_COMM_WORLD, rez, MPI_MODE_WRONLY, MPI_INFO_NULL, &cFile);
if(rc){printf("Failed to open file! Error: %d \n", rc);MPI_Finalize();
fflush(stdout);}
else
{
MPI_File_write_all(cFile, MatC, loccC*locrC, compa, &status);
}
...
rc=MPI_File_open(MPI_COMM_WORLD, rez, MPI_MODE_WRONLY, MPI_INFO_NULL, &cFile);
if(rc){printf("Failed to open file! Error: %d \n", rc);MPI_Finalize();
fflush(stdout);}
else
{
MPI_File_write_ordered(cFile, MatC, loccC*locrC, compa, &status);
}
...
rc=MPI_File_open(MPI_COMM_WORLD, rez, MPI_MODE_WRONLY, MPI_INFO_NULL, &cFile);
if(rc){printf("Failed to open file! Error: %d \n", rc);MPI_Finalize();
fflush(stdout);}
else
{
MPI_File_write_shared(cFile, MatC, loccC*locrC, compa, &status);
}
我在这篇文章中找不到任何内容(但是如何读取文件并将其格式化为2d块循环分布式数组(我已成功使用该帖子)): MPI IO Reading and Writing Block Cyclic Matrix
对不起我糟糕的英语:(
答案 0 :(得分:0)
你告诉过你使用过这篇文章:MPI IO Reading and Writing Block Cyclic Matrix。 我们必须假设一些东西 - 比如矩阵MatC的维数:我们假设它是m行和n列。 MatC中块的尺寸,假设它们是m_b和n_b。假设处理器的数量是nproc,并且proc的等级保存在变量节点中。此外,我们必须知道2D-torus(处理器网格)的尺寸,例如p和q。这是你如何做到的:
int dims[]={m, n}, dargs[]={m_b, n_b}, distribs[]={MPI_DISTRIBUTE_CYCLIC, MPI_DISTRIBUTE_CYCLIC}, nproc, dim[]={p, q};
char nat[]="native";
MPI_Datatype dcarray, compa; //don't know what type compa is
...
MPI_Type_create_darray(nproc, node, 2, dims, distribs, dargs, dim, MPI_ORDER_C, compa, &dcarray);
MPI_Type_commit(&dcarray);
rc=MPI_File_open(comm, rez, MPI_MODE_CREATE | MPI_MODE_WRONLY, MPI_INFO_NULL, &cFile);
if(rc){printf("Failed to open file! Error: %d \n", rc);MPI_Finalize(); fflush(stdout);}
else
{
MPI_File_set_view(cFile, 0, compa, dcarray, nat, MPI_INFO_NULL);
MPI_File_write_all(cFile, MatC, locrC*loccC, compa, &status);
}
MPI_File_close(&cFile);