2013-02-09 56 views
1

我在寫入2d塊循環分佈式數組時遇到了問題。MPI輸出使用部分MPI_File_write寫C中的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

你告訴你已經使用這個帖子:MPI IO Reading and Writing Block Cyclic Matrix。 我們必須假設一些東西 - 比如矩陣MatC的維數:讓我們假設它是m行和n列。 MatC中塊的尺寸,我們假設它們是m_b和n_b。假設處理器的數量是nproc,並且proc的等級被保存在變量節點中。此外,我們必須知道二維圓環(處理器網格)的尺寸,例如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);