1

我在文件中写入二维块循环分布式数组时遇到问题。

我试过这些东西:

    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

对不起我糟糕的英语:(

4

1 回答 1

0

您告诉过您使用过这篇文章:MPI IO 读写块循环矩阵。我们必须假设一些事情——比如矩阵 MatC 的维度:让我们假设有 m 行和 n 列。MatC中块的尺寸,假设它们是m_b和n_b。假设处理器的数量是 nproc,并且 proc 的等级保存在变量 node 中。此外,对于我们的示例 p 和 q,我们必须知道 2D 环面(处理器网格)的维度。这是你如何做到的:

    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);
于 2013-02-10T13:56:43.187 回答