From: <ipe...@us...> - 2009-11-12 04:42:09
|
Revision: 12007 http://x10.svn.sourceforge.net/x10/?rev=12007&view=rev Author: ipeshansky Date: 2009-11-12 04:41:51 +0000 (Thu, 12 Nov 2009) Log Message: ----------- Fix ateach expansion to avoid creating points if possible. Add missing newline in constructor codegen. Make Dist.makeUnique() return a singleton. Mark Dist.makeUnique() return value as rect. Whitespace. Modified Paths: -------------- trunk/x10.compiler/src/x10/visit/Desugarer.java trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java trunk/x10.runtime/src-x10/Dummy.x10 trunk/x10.runtime/src-x10/x10/array/BaseDist.x10 trunk/x10.runtime/src-x10/x10/lang/Dist.x10 Modified: trunk/x10.compiler/src/x10/visit/Desugarer.java =================================================================== --- trunk/x10.compiler/src/x10/visit/Desugarer.java 2009-11-12 01:37:40 UTC (rev 12006) +++ trunk/x10.compiler/src/x10/visit/Desugarer.java 2009-11-12 04:41:51 UTC (rev 12007) @@ -510,27 +510,38 @@ assert (((X10TypeSystem_c) xts).isDistribution(dType)); MethodInstance mi = xts.findMethod(dType, xts.MethodMatcher(dType, APPLY, Collections.singletonList(fType), context)); - Expr index = xnf.Local(bpos, - xnf.Id(bpos, formal.name().id())) - .localInstance(formal.localDef().asInstance()) - .type(fType); + List<Expr> index = new ArrayList<Expr>(); if (formal.isUnnamed()) { ArrayList<Expr> vars = new ArrayList<Expr>(); + ArrayList<Type> varTypes = new ArrayList<Type>(); for (LocalDef ld : formal.localInstances()) { + Type t = ld.type().get(); vars.add(xnf.Local(bpos, nf.Id(bpos, ld.name())) .localInstance(ld.asInstance()) - .type(ld.type().get())); + .type(t)); + varTypes.add(t); } - Type intRail = xts.ValRail(xts.Int()); - MethodInstance cnv = xts.findMethod(fType, - xts.MethodMatcher(fType, CONVERT_IMPLICITLY, - Collections.singletonList(intRail), context)); - assert (cnv.flags().isStatic()); - index = - xnf.Call(bpos, xnf.CanonicalTypeNode(bpos, fType), - xnf.Id(bpos, CONVERT_IMPLICITLY), - xnf.Tuple(bpos, vars).type(intRail)).methodInstance(cnv).type(fType); + MethodInstance mi1 = xts.findMethod(dType, + xts.MethodMatcher(dType, APPLY, varTypes, context)); + if (mi1 != null) { + mi = mi1; + index = vars; + } else { + Type intRail = xts.ValRail(xts.Int()); + MethodInstance cnv = xts.findMethod(fType, + xts.MethodMatcher(fType, CONVERT_IMPLICITLY, + Collections.singletonList(intRail), context)); + assert (cnv.flags().isStatic()); + index.add(xnf.Call(bpos, xnf.CanonicalTypeNode(bpos, fType), + xnf.Id(bpos, CONVERT_IMPLICITLY), + xnf.Tuple(bpos, vars).type(intRail)).methodInstance(cnv).type(fType)); + } + } else { + index.add(xnf.Local(bpos, + xnf.Id(bpos, formal.name().id())) + .localInstance(formal.localDef().asInstance()) + .type(fType)); } Expr place = xnf.Call(bpos, xnf.Local(pos, xnf.Id(pos, tmp)).localInstance(lDef.asInstance()).type(dType), Modified: trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2009-11-12 01:37:40 UTC (rev 12006) +++ trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2009-11-12 04:41:51 UTC (rev 12007) @@ -1973,6 +1973,7 @@ } sw.end(); sw.newline(); sw.write("}"); + sw.newline(); if (!container.flags().isAbstract()) { // emit _make method Modified: trunk/x10.runtime/src-x10/Dummy.x10 =================================================================== --- trunk/x10.runtime/src-x10/Dummy.x10 2009-11-12 01:37:40 UTC (rev 12006) +++ trunk/x10.runtime/src-x10/Dummy.x10 2009-11-12 04:41:51 UTC (rev 12007) @@ -97,7 +97,7 @@ var f105 : x10.lang.Unsigned; var f106 : x10.lang.UnsupportedOperationException; var f107 : x10.lang.ValRail[Dummy]; - // var f108 : x10.lang.Value; + //var f108 : x10.lang.Value; var f109 : x10.lang._; var f113 : x10.runtime.Clock_c; var f115 : x10.runtime.Future_c[Dummy]; Modified: trunk/x10.runtime/src-x10/x10/array/BaseDist.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/BaseDist.x10 2009-11-12 01:37:40 UTC (rev 12006) +++ trunk/x10.runtime/src-x10/x10/array/BaseDist.x10 2009-11-12 04:41:51 UTC (rev 12007) @@ -30,8 +30,10 @@ // factories - place is all applicable places // - public static def makeUnique1(): Dist(1) { - return makeUnique1(Place.places); + // There's only one unique distribution + private static val UNIQUE = makeUnique1(Place.places) as Dist(1){rect}; + public static def makeUnique1(): Dist(1){rect} { + return UNIQUE; } public static def makeUnique1(ps: Rail[Place]): Dist(1) { // XTENLANG-4 Modified: trunk/x10.runtime/src-x10/x10/lang/Dist.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Dist.x10 2009-11-12 01:37:40 UTC (rev 12006) +++ trunk/x10.runtime/src-x10/x10/lang/Dist.x10 2009-11-12 04:41:51 UTC (rev 12007) @@ -46,7 +46,7 @@ * point in the region to every place. */ - public static def makeUnique(): Dist(1) = BaseDist.makeUnique1(); + public static def makeUnique(): Dist(1){rect} = BaseDist.makeUnique1(); /** * Returns a distribution over the specified region that maps This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |