Discussion

From: Andrei Alexandrescu (andrei@cs.washington.edu)
Date: Mon Nov 25 2002 - 17:37:31 PST

  • Next message: Keunwoo Lee: "Re: AOP and parametric polymorphism"

    It would be nice, time permitting, to continue discussing how to allow the
    programmer to express optimizations in source code, notably loop fusion with
    user-defined operators. Here are a couple of references:

    1. The original AOP paper discusses AOP within the context of optimizing
    image transformation algos:

    http://www.parc.xerox.com/csl/groups/sda/publications/papers/Kiczales-ECOOP9
    7/for-web.pdf

    2. A paper on expression templates for implementing operators:

    http://osl.iu.edu/~tveldhui/papers/Expression-Templates/exprtmpl.html

    The page has references to a couple of libraries that boast FORTRAN-like
    performance with regular infix notation for vector and matrix operations. In
    essence, what happens is that each operator returns a type that encodes the
    semantics of that operator. The object's state contains references to the
    operands. For example:

    Matrix A, B, C, D;
    A = B + C + D;

    Here, B + C + D creates an object of type Plus<Matrix, Plus<Matrix, Matrix>
    >. So as you see, the AST is in the type. (The type generated by more
    complex expressions will be appropriatedly hairy.) In addition, each Plus
    object stores two references to its operands. During the assignment, one
    iteration is done calling the indexing operator on Plus. That operator
    evaluates the indexing operator on its two operands. This compile-time
    recursive invocation of indexing yields efficient code.

    So my question is: what language mechanism would allow the programmer to
    express such (and related) transformations in a more natural manner?

    It seems indeed (see http://www.xpdeveloper.com/cgi-bin/wiki.cgi?XPmeetsAOP)
    that AspectJ indeed cannot do even simple loop fusion. This comes as an
    embarrassing limitation of AspectJ, especially considering that
    user-controlled optimizations are the motivation for AOP and one of its main
    applications.

    Andrei

    _______________________________________________
    Cecil mailing list
    Cecil@cs.washington.edu
    http://mailman.cs.washington.edu/mailman/listinfo/cecil



    This archive was generated by hypermail 2.1.5 : Mon Nov 25 2002 - 17:41:25 PST