Hi Chris, this is a nice test of X10 primitive and communications.
When I profile your code on multiple places on a single computer, I see almost all the runtime is spent in "busy waiting" - presumably, threads at the receiving node waiting for the sending node to complete. There is more information on the busy waiting problem in http://jira.codehaus.org/browse/XTENLANG-1012 I'm guessing that the "sleep" is not an essential part of your benchmark. If that's right, I would say that this is a perfect test for conditional atomic blocks (section 14.7.2 of the language specification). You can replace the body of recv(...) with when (A(here.id) == value); This simply waits for the value to be set, and then returns. Sadly, this won't work by itself. With the current version of X10, the blocked thread is never woken up again to check the condition. Thus we have a deadlock - see http://jira.codehaus.org/browse/XTENLANG-1660 for more information. There is an easy way to avoid this deadlock using an (unconditional) atomic block in send(...) as follows: at (target) { atomic A(here.id) = value; } On exit of this atomic block at the receiving place, the runtime checks whether there are other threads waiting, and if so wakes them up. So the blocked thread will see that the condition is now true, and continue. These changes improved the performance of your code by over three orders of magnitude on my platform. Please let me know whether they work for you. As an aside, you can use the Place.next() method to simplify the code dramatically. A full version is below. Cheers Josh --- public static def send(target:Place, value:Int) { at (target) { atomic A(here.id) = value; } } public static def recv(value:Int) { when (A(here.id) == value); } public static def main(args:Array[String](1)) { val startTime = Timer.milliTime(); for (var index : Int = 0; index < NUM_MESSAGES; index++) { val i = index; finish for (p in Place.places()) async at (p) { Ring.send(here.next(), i); Ring.recv(i); } } val endTime = Timer.milliTime(); val totalTime = (endTime - startTime) / 1000.0; Console.OUT.printf("It took %f seconds\n", totalTime); } --- Chris Bunch wrote: > Hi all, > I've been working on a small thread ring benchmark in X10 and have > codes written in MPI, UPC, and X10 thus far. Unfortunately, my X10 code > is quite slower than the others (two orders of magnitude slower) and I'm > not entirely sure why. Essentially each process just sends a message to > the next process, and the final process sends the message to the first > process (forming a ring). > > I'd like to make the code comparable to MPI and UPC and would love a > separate pair of eyes to look it over - it's less than 100 lines of code > so it's not that long. I've posted the code here for those who are > interested: > > http://pastebin.com/dYPCwh4G > > I know everyone is busy but any help is much appreciated! I know X10 can > pass around 100 messages between 64 processors on two nodes with the MPI > backed faster than 9700 seconds (the MPI is doing it in 4 seconds), but > I'm just not sure what I'm doing wrong. > > Thanks! > > > ------------------------------------------------------------------------------ > The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE: > Pinpoint memory and threading errors before they happen. > Find and fix more than 250 security defects in the development cycle. > Locate bottlenecks in serial and parallel code that limit performance. > http://p.sf.net/sfu/intel-dev2devfeb > _______________________________________________ > X10-users mailing list > X10-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/x10-users > ------------------------------------------------------------------------------ The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE: Pinpoint memory and threading errors before they happen. Find and fix more than 250 security defects in the development cycle. Locate bottlenecks in serial and parallel code that limit performance. http://p.sf.net/sfu/intel-dev2devfeb _______________________________________________ X10-users mailing list X10-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/x10-users