From: David C. <dc...@us...> - 2012-10-09 23:46:14
|
I've just committed to trunk a change that allows code like the following, for both managed and native backends: import x10.io.Console; import x10.compiler.*; public class AtProfile { public static def printProf (str:String, x:Runtime.Profile) { Console.OUT.println(str+": Serialization nanos: "+x.serializationNanos+" Communication nanos: "+x.communicationNanos+" Bytes: "+x.bytes); } public static def main (args : Array[String]) { val x = new Runtime.Profile(); val arr = new Array[Float](25000); val there = here.next(); x.reset(); @Profile(x) at (here) { arr(10) = 10.0f; } printProf("Local at", x); x.reset(); @Profile(x) at (here) async { arr(10) = 10.0f; } printProf("Local at async", x); //x.reset(); //val tmp = @Profile(x) at (here) arr(10); //printProf("Local at expr", x); x.reset(); @Profile(x) at (there) { arr(10) = 10.0f; } printProf("Remote at", x); x.reset(); @Profile(x) at (there) async { arr(10) = 10.0f; } printProf("Remote at async", x); //x.reset(); //val tmp = @Profile(x) at (there) arr(10); //printProf("Remote at expr", x); x.reset(); Runtime.deepCopy(arr, x); printProf("Explicit deep copy", x); } } Currently, one cannot put an annotation on an at expression, which is why that is commented out. Exception serialization is not counted, if you throw an exception. At expression return values are also not counted. The intention is to only include stuff that the program can control in the 'bytes' quantity, i.e. exclude internal overheads (like finish state, x10rt overheads, IP/layer 2 packet headers, etc) as much as possible. The reasoning is that any answer we can provide is not going to be accurate is it will not be sampled at a low enough level. So it is best to go for the other extreme and only provide information the programmer can relate to. This is quite tricky though in the case of e.g. clocks so right now there will still be some extra bytes in some cases. Here is the output for both backends: MANAGED: Local at: Serialization nanos: 17373456 Communication nanos: 0 Bytes: 100093 Local at async: Serialization nanos: 35523967 Communication nanos: 0 Bytes: 100093 Remote at: Serialization nanos: 2324627 Communication nanos: 393421 Bytes: 100121 Remote at async: Serialization nanos: 1060134 Communication nanos: 125017 Bytes: 100091 Explicit deep copy: Serialization nanos: 1234391 Communication nanos: 0 Bytes: 100091 NATIVE: Local at: Serialization nanos: 564253 Communication nanos: 0 Bytes: 100054 Local at async: Serialization nanos: 258626 Communication nanos: 0 Bytes: 100054 Remote at: Serialization nanos: 74382 Communication nanos: 85976 Bytes: 100068 Remote at async: Serialization nanos: 22279 Communication nanos: 70192 Bytes: 100052 Explicit deep copy: Serialization nanos: 94776 Communication nanos: 0 Bytes: 100052 Take the times with a pinch of salt as there is no warmup phase for the managed backend, and the native numbers are for an unoptimised build of X10. |