Brad,

On Mon, 6 Jul 2020, Brad Chamberlain wrote:

Or to inject a helper routine that computes the `v[i] * A[i, ..]` product, storing the result into an array, returning it, and reducing that:

        const rows, cols = 1..10;

         var A: [rows, cols] real;
         var v: [cols] real;

         proc dotprod(v, Ai) {
           var res = v *        Ai;
           return res;
         }

         var z = + reduce [i in rows] dotprod(v, A[i, ..]);

Yes!  Well, almost.

After pondering your suggestions during breaks between meetings, you have given me an idea. I will give up on the 'reduce' and write my code with a helper routine:

    const z : [columns] R = [i in columns] ((dot(v, t[rows, j]) / h) / g);

    [i in rows] t[i, columns] += v * v[i];

It works!

This will not be much slower than what I had originally planned when using the reduce but is slightly more accurate. It is way better than doing everything on a column-at-a-time basis which was my original approach, this being a translation of the original algorithm which was written with Fortran array access in mind. This new way will do writes to memory one row-at-a-time which is the key performance driver. Now initializing the vector 'z' will still read from memory one column-at-a-time, but I can live with that for my current work.

Thanks for the inspiration - Damian

Pacific Engineering Systems International, 277-279 Broadway, Glebe NSW 2037
Ph:+61-2-8571-0847 .. Fx:+61-2-9692-9623 | unsolicited email not wanted here
Views & opinions here are mine and not those of any past or present employer


_______________________________________________
Chapel-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/chapel-developers

Reply via email to