Hi Jeff ---
(Copying the x10-users list on my response to your recent question.)
X10 has a very general framework for arrays. But clearly we want
performance for the common cases. Hence we have introduced a set of
properties that can inform the compiler to generate better code. Chief
among them are rank, rect and zeroBased.
In practice there are a few usability issues.
(a) The built-in classes (e.g. point, region, dist, arrays etc) are
currently defined in Java (for the Java-based runtime), and hence it is
not easy for them to express the signatures of their methods using X10's
dependent types. So currently we have patched the compiler to recognize
methods for some of these classes and propagate properties correctly.
However, the support is a bit incomplete.
I have recently committed some changes which will support the following
examples:
final int N=10000;
region(:rect&&zeroBased&&rank==1) r = [0:N];
dist(:rect&&zeroBased&&rank==1) d = dist.block(r);
double[:rect&&zeroBased&&rank==1] a = new double[d];
i.e. these properties are correctly propagated out of the region
constructor ([0:N]), from the region to the distribution, and from the
distribution to the array.
The general solution (and hopefully one we will implement in the next
major release) is to move several of the basic classes (e.g. point,
region, dist, array) to X10. This will permit us to use X10's dependent
type systems to directly specify how properties should be propagated,
and we can remove all the special purpose code within the compiler to
perform this propagation.
Second, we are also going to support some localized type inference. For
sure we will permit type inference for explicitly initialized variable
declarations. For instance, you will be able to write the above example as
final int N=10000;
_ r = [0:N];
_ d = dist.block(r);
_ a = new double[d];
One reads the second statement as saying "r is a local variable,
initialized with [0:N], whose static type defaults to the static type of
the initializer". Similarly for the remaining. This clearly wins on
writability, and arguably does not lose on readability if there is
support in X10DT for revealing the latent static type on a mouse hover
(and optionally writing out the type into the source file).
(Satish Chandra has been working on a more general framework for type
inference (a paper is due out in the next PPoPP), and perhaps we will
have some of that implemented in the next major release.)
Now let me come to the final point, typedef. Nate Nystrom is currently
working on the next major revision of the X10 language design, with
support for generics ... and for typedefs. This will of course be a big
boon for X10 developers since complicated dependent types can be written
once and used many times. I will let him describe the proposal he is
working on if he is comfortable doing so.
Note that specifically for :rank==1&&rect&&zeroBased", we have
introduced the property "rail" as a shorthand. However, this has not
been completely implemented in the current release. Perhaps we can get
this out in the next minor release.
Hope this helps,
Best,
Vijay
Jeff Kuehn wrote:
> BTW: as I'm new to X10 (and very rusty on Java), I've run across a few
> questions on the syntax for declaring distributed arrays. In particular,
> the performance of McCalpin's STREAM example compares reasonably well
> with that of native C code (kudos!) if ":rank==1&&rect&&zeroBased" are
> specified in both the type and cast (ie. twice) for each array
> declaration, but the performance drops to only 10% of the native code
> performance if these are omitted or changed (with some cases not passing
> the compiler). Is there a more compact way to specify these constraints
> in one place within the source and reference that in each declaration?
> (ie, can the be attached to the dist or region? I'm looking for
> something a little closer to the C "typedef" construct to avoid errors
> or mismatches).
>
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
X10-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/x10-users