[MPICH] Can I ask MPI to not copy the data to shared-mem ?

Jean-Marc Saffroy saffroy at gmail.com
Tue Oct 9 18:27:53 CDT 2007


On Tue, 9 Oct 2007, Darius Buntinas wrote:

> Yeah, interesting.  But you have to read the maps file every time you do 
> a send or receive.  You can't just read the maps file once at init and 
> cache it, because the user could change the mapping after init.

Well, then you could overload the functions that modify the maps. Reminds 
me of something... ;)

> I guess for sufficiently large messages the benefit of not having to 
> copy would outweigh the cost of reading the maps file.

Reading /proc/self/maps costs about 32µsec (lseek + read) on my PC; with a 
RAM throughput of 1GB/s (and cache is much faster), you have to save the 
copy of a few tens of KB to amortize the cost of reading maps once.

$ make selfmaps
gcc -Wall -O2 -g    selfmaps.c   -o selfmaps

$ time ./selfmaps 100000 > /dev/null

real    0m3.292s
user    0m0.018s
sys     0m3.226s

$ cat selfmaps.c
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>

int main(int argc, char **argv) {
         char buf[4096];
         int fd, n = 0, i;

         fd = open("/proc/self/maps", O_RDONLY);
         for(i = 0; i < atoi(argv[1]); i++) {
                 lseek(fd, 0, SEEK_SET);
                 n = read(fd, buf, sizeof(buf));
         }
         write(1, buf, n);

         return 0;
}


-- 
saffroy at gmail.com


More information about the mpich-discuss mailing list