Good day! I am writing a program in C ++ using the message transfer interface (MPI) and have encountered one problem. It is necessary to read data from a text file and transfer it to other threads. Actually, the whole hitch is precisely how to implement the transfer of data from a text file in parts, so that the streams that receive this data perform the subsequent necessary operations not with all the data from the file, but only with their part.

    2 answers 2

    Found an excellent function for such a send - MPI_Scatter. So the question can be considered closed.

    • @rfry, so close. There is a line under the question ... "close" ... - avp
    • @avp it seems you only have :) - sercxjo
    • Apparently this is a question for HashCode. Why the author of the question can not (regardless of points) close your question? Now (from Help on the forum) closing your question: 250 - If the author wishes to close, then I can. - avp

    I understood correctly - the question is how to read the file in pieces ?? fread to help, if so)

    • Unfortunately not familiar with MPI. But if we are talking about threads similar to posix threads, then either in each thread you need to open your FILE, or the threads should synchronize their access to the file and correctly do fseek () in it before reading. Because they all share the same resource. - avp
    • one
      In MPI, concurrency is implemented through processes, not threads. - skegg
    • @mikillskegg, Thanks, I will know. And is there a mechanism for transmitting an open file descriptor (well, on Linux this is possible via sendmsg ()) in MPI? - avp
    • @avp No, processes can run on different machines, data is usually read by one process and distributes them to the others. But it is possible in different processes to read data from different files or from one using a network file system mounted on all machines in the same way. - sercxjo