Discussion:
Reading files concurrently
(too old to reply)
l***@yahoo.com
2008-08-20 01:44:35 UTC
Permalink
Hi all,
I'll like to know if it is alright to read from a file concurrently
from multiple processors, i.e. every processor has their own file
pointer and opens the same file, read its contents, close the file etc
concurrently. I've tried it and it seems to give me the correct
results, but I'm not sure if there are any hidden errors that just
haven't shown up yet.

Thank you.

Regards,
Rayne
Michael Hofmann
2008-08-20 06:36:50 UTC
Permalink
Post by l***@yahoo.com
Hi all,
I'll like to know if it is alright to read from a file concurrently
from multiple processors, i.e. every processor has their own file
pointer and opens the same file, read its contents, close the file etc
concurrently. I've tried it and it seems to give me the correct
results, but I'm not sure if there are any hidden errors that just
haven't shown up yet.
MPI has nothing to do with regular file I/O (fopen, fseek, fread, fclose,
...). Whether it is OK or not depends on your OS, the network file system,
...

MPI-2 provides an own set of file I/O routines (MPI_File_...). If you use
it correctly, it is definitely OK and it is portable.

In general, concurrent read should not be a problem (if you open the file
read-only).


Michael
David Cronk
2008-08-28 15:54:48 UTC
Permalink
Post by l***@yahoo.com
Hi all,
I'll like to know if it is alright to read from a file concurrently
from multiple processors, i.e. every processor has their own file
pointer and opens the same file, read its contents, close the file etc
concurrently. I've tried it and it seems to give me the correct
results, but I'm not sure if there are any hidden errors that just
haven't shown up yet.
This is legal but not scalable. Operating systems have limits on how
many processes can have a single file open at the same time.

Since this is an MPI group, look into MPI-I/O to see how to do this with
MPI. You may even find it is easier with MPI-I/O.

Hope this helps.

Dave.
Post by l***@yahoo.com
Thank you.
Regards,
Rayne
--
Dr. David Cronk, Ph.D. phone: (865) 974-3735
Research Director fax: (865) 974-8296
Innovative Computing Lab http://www.cs.utk.edu/~cronk
University of Tennessee, Knoxville
Loading...