⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 io35cc.cc

📁 The example for Boor USING MPI2
💻 CC
字号:
// example of parallel MPI read from single file, in C++#include <iostream.h>#include "mpi.h"int main(int argc, char *argv[]){    int bufsize, *buf, count;    char filename[128];    MPI::Status status;    MPI::Init();    int myrank = MPI::COMM_WORLD.Get_rank();    int numprocs = MPI::COMM_WORLD.Get_size();    MPI::File thefile = MPI::File::Open(MPI::COMM_WORLD, "testfile",                                        MPI::MODE_RDONLY,                                        MPI::INFO_NULL);    MPI::Offset filesize = thefile.Get_size();  // in bytes    filesize    = filesize / sizeof(int);    // in number of ints    bufsize     = filesize / numprocs + 1;   // local number to read    buf = (int *) malloc (bufsize * sizeof(int));    thefile.Set_view(myrank * bufsize * sizeof(int),		     MPI_INT, MPI_INT, "native", MPI::INFO_NULL);    thefile.Read(buf, bufsize, MPI_INT, &status);    count = status.Get_count(MPI_INT);    cout << "process " << myrank << " read " << count << " ints"	 << endl;    thefile.Close();    MPI::Finalize();    return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -