Newsgroups: comp.parallel.mpi From: Erik Demaine Subject: Re: count-process uses complete CPU Organization: University of Waterloo Date: Sun, 14 Dec 1997 14:38:17 GMT Message-ID: Fokke Dijkstra wrote: : Is there an easy way to create a process in MPI supplying values of : a counter to the other processes without taking a complete CPU or a lot : of CPU-time? : The problem seems to be that the process is in MPI_RECV in a tight loop : checking for incoming sends. The problem is with your MPI implementation. Unfortunately, nearly all MPI implementations do not block processes when they get bored; instead, they poll for something interesting. This causes a long-waiting MPI_RECV to use a lot of CPU time (likely nearly all). In fact, I don't know of any (general) MPI implementations that actually put processes to sleep. What sort of system are you running on? Perhaps there are alternatives. As a workaround, you could manually increase the polling time. That is, you could do an MPI_IPROBE, sleep for a longish while, and repeat until IPROBE says that there is a message, in which case you can MPI_RECV it and send back a counter value. The problem is that the more you increase the sleep time, the less CPU you use, but the less responsive your counting process is. There are probably other solutions to global counting. If processes are reasonably responsive, one process could hold a "token" saying that it will count. When other processes need to count, they could request the token from that process. I'm not sure, though, how to maintain information about where the token is (except with some nasty broadcasts). Alas, this is really a virtual shared memory problem, which is not easy to solve. Good luck, Erik -- Erik Demaine \( e-mail: eddemain@daisy.uwaterloo.ca (PGP avail.) Dept. of Computer Science \) URL: http://daisy.uwaterloo.ca/~eddemain/ University of Waterloo (\ "I don't know why; it seems to be harder to lie Waterloo, ON Canada N2L 3G1 )\ to other people than yourself." -Neil Robertson