MPI IO当不知道偏移量时写入文件 [英] MPI IO Writing a file when offset is not known
本文介绍了MPI IO当不知道偏移量时写入文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用MPI IO写入文件. 进程处于while循环中,它调用一个函数,该函数生成随机量的数据.我想将此数据写入单个文件. 我该怎么做?
I want to use MPI IO to write files. The processes is in a while loop and it calls a function which generates random amount of data. I want to write this data to a single file. How can I accomplish this?
推荐答案
在while循环的每次迭代中,每个进程都知道将要写入多少数据.使用MPI_SCAN共享该数据,然后使用MPI_File_write_at_all进行集体写入:
in each iteration of your while loop, each process knows how much data will be written. Use MPI_SCAN to share that data, then MPI_File_write_at_all to write collectively:
incr = generate_random_data();
MPI_Scan(&incr, &new_offset, 1, MPI_LONG_LONG_INT,
MPI_SUM, MPI_COMM_WORLD);
new_offset -= incr;
ret = MPI_File_write_at_all(mpi_fh, new_offset, buf, count,
datatype, status);
这篇关于MPI IO当不知道偏移量时写入文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文