【问题标题】:MPI output write 2d block cyclic distribution in C using some of MPI_File_writeMPI 输出使用一些 MPI_File_write 在 C 中写入 2d 块循环分布
【发布时间】:2013-01-25 07:10:45
【问题描述】:

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

我试过这些东西:

    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);    
    }

我在这篇文章中什么也找不到(但只是如何读取文件并将其格式化为二维块循环分布式数组(我已成功使用该文章)): MPI IO Reading and Writing Block Cyclic Matrix

对不起我糟糕的英语:(

【问题讨论】:

    标签: c 2d mpi block cyclic


    【解决方案1】:

    您告诉过您使用过此帖子:MPI IO Reading and Writing Block Cyclic Matrix。 我们必须假设一些事情——比如矩阵 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);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-09-29
      • 2012-05-07
      • 1970-01-01
      • 1970-01-01
      • 2019-04-16
      • 2016-03-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多