On Sunday 17 January 2010 12:21:04 pm Josh Milthorpe wrote: > Hi Christoph, > > I won't comment on whether there are better ways to implement a > matrix-vector multiply. > > The immediate problem here is that the Region.product(...) operation > doesn't combine the rank constraints of the two operands. In other > words, it is currently defined as: > > abstract public global def product(that: Region): Region; > > whereas it should be: > > abstract public global def product(that: Region): > Region(this.rank+that.rank); > > Unfortunately such arithmetic constraints will not be possible until X10 > 2.1, so for the time being, the rank constraint must be lost. > > For now, you could perform a cast to restore the lost rank constraint: > > val r = ( ([j..j] as Region(1)) * A.region.projection(1)) as Region(2); > > Once X10 2.1 is released, such a cast should no longer be required. > > I would also suggest that you drop the explicit type declarations for > values, as discussed in Bard's earlier posting: > http://sourceforge.net/mailarchive/message.php?msg_name=OF1917566B.E32908BD > -ON852576A6.0007CA46-852576A6.000916B7%40us.ibm.com > > For example just write > val r = ... > instead of > val r:Region = > > This will ensure that type information (including the rank constraint) > is preserved as far as possible. > > Kind regards, > > Josh >
Josh, that you for your suggestions. I was trying them today and the code looks now as follows. /** * Method to multiply matrix A with vector v */ def ClassicMatrixMultiply() { finish ateach (p in v2.dist() ) { val j = (p.coords())(0); val r = ( ([j..j] as Region(1)) * A.region.projection(1)) as Region(2); val d = A.dist().intersection(r); val linev = (v as Array[double](d)); v2(p) = ((A|d)*linev).reduce(double.+,0); } finish v = (v2 as Array[double](v.dist()) ); } But still the X10 compiler complains about val d = A.dist().intersection(r); with the following message. Multiple messages: Method intersection(x10.lang.Region {_self10885689.rank==x10.lang.Dist#this.region.rank}) in x10.lang.Dist {_self10925187==matmul#this.A.dist} cannot be called with arguments (x10.lang.Region {_self10868754==r, r.rank==2}); Call invalid; actual parameter of type | x10.lang.Region {_self10868754==r, r.rank==2}| cannot be assigned to formal parameter type | x10.lang.Region {r.rank==matmul#this.A.dist.region.rank}|. Method intersection(x10.lang.Region {_self10885689.rank==x10.lang.Dist#this.region.rank}) in x10.lang.Dist {_self10883810==matmul#this.A.dist} cannot be called with arguments (x10.lang.Region {_self10868754==r, r.rank==2}); Call invalid; actual parameter of type | x10.lang.Region {_self10868754==r, r.rank==2}| cannot be assigned to formal parameter type | x10.lang.Region {r.rank==matmul#this.A.dist.region.rank}|. I have difficulty understanding this error message. It seems to tell me that the construct A.dist().intersection(r) is illegal, but it doesn't tell me why. Do I miss something here ? -- Mit freundlichen Grüßen / Kind regards Dr. Christoph Pospiech High Performance & Parallel Computing Phone: +49-351 86269826 Mobile: +49-171-765 5871 E-Mail: christoph.pospi...@de.ibm.com ------------------------------------- IBM Deutschland GmbH Vorsitzender des Aufsichtsrats: Erich Clementi Geschäftsführung: Martin Jetter (Vorsitzender), Reinhard Reschke, Christoph Grandpierre, Klaus Lintelmann, Michael Diemer, Martina Koederitz Sitz der Gesellschaft: Ehningen / Registergericht: Amtsgericht Stuttgart, HRB 14562 WEEE-Reg.-Nr. DE 99369940 ------------------------------------------------------------------------------ Throughout its 18-year history, RSA Conference consistently attracts the world's best and brightest in the field, creating opportunities for Conference attendees to learn about information security's most important issues through interactions with peers, luminaries and emerging and established companies. http://p.sf.net/sfu/rsaconf-dev2dev _______________________________________________ X10-users mailing list X10-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/x10-users