GCC Gathering 2011: Notes from the Fortran BOF

At the GCC Gathering 2011 in London, there was also a small gathering of the three gfortran developers in a small circle - and some discussion with other GCC developers. The notes are a bit shorter than hoped for as two gfortaners already had to leave early afternoon on Saturday.

Debugging issues

While there was no time to discuss issues during the GDB session, the following debug issues where at least mentioned at some point:


gfortran's scalarizer is rather complex; every time one tries to modify it, one has to try to understand it again. For performance and maintenance reasons, it makes sense to move it out of trans*.c. The plan was to move to a middle-end scalarizer, which also handles all the whole-array operations.

See also the discussion about a new FE scalarizer

For the matrix multiplication W = matmul (U, V) of matrix U(m,n), V(n,m) and result matrix W(n,n), one has to calculate w(i,j) = sum_{k=1}^m v(i,k)*u(k,j). [I am sure that I somewhere swapped the index order]. The C version of the whole-array implementation looks then as follows (taken from the patch):

matmul(float *w, float *u, float *v, int n, int m)
  float (*U)[n][m] = (float (*)[n][m])u;
  float (*V)[m][n] = (float (*)[m][n])v;
  float (*W)[n][n] = (float (*)[n][n])w;
  int i, j, k, l;
  float Ukj, Vil, VUij;

  Ukj = __builtin_array_idx (__builtin_array_select (U, m, 1, n, m), k, j);
  Vil = __builtin_array_idx (__builtin_array_select (V, n, 1, m, n), i, l);
  VUij = __builtin_array_delta (Vil * Ukj, m, k, l);

  __builtin_array_store (W, __builtin_array_ridx (VUij, i, n, j, n), n, 1, n, n);

* __builtin_array_select: Array selector with the arguments: (1) variable, (2) extend of first dimension, (3) stride of first dimension, (4) extend of second dimension, ...

* __builtin_array_idx: Takes an array selector as first argument, followed by rank arguments of integral type which denote the index variables.

* __builtin_array_delta: The first argument is the actual expression, followed by the bounds of the expression and the variable.

* __builtin_array_ridx (VUij, i, n, j, n): Essentially the same as __builtin_array_select, just for storing the scalarization result for further use, i.e. one generates out of the scalars "w(i,j)" again an array. The first argument "VUij" is the result of the scalar expression generated by __builtin_array_delta; the second argument is an index variable (of integral type), the third argument is the extend; the fourth argument is the index variable of the second dimension and the fifth the extend of the second dimension.

* __builtin_array_store: Wrap up. Store the result in the variable (first argument), using the array-expression (second argument); the array has the extend/strides given as 3rd/4th and 5th/6th etc. argument.

Other topics

To be filled in.

None: GCCGathering2011Fortran (last edited 2012-08-02 14:33:05 by TobiasBurnus)