Page 1 of 1

depends clause with array

PostPosted: Thu Mar 13, 2014 12:40 am
by pierrick
Hi,

Looking at the example, I only see one example with dependency on array :

Code: Select all
// Assume BS divides N perfectly
void matmul_depend(int N, int BS, float A[N][N], float B[N][N], float C[N][N] ){
   int i, j, k, ii, jj, kk;
   for (i = 0; i < N; i+=BS) {
      for (j = 0; j < N; j+=BS) {
         for (k = 0; k < N; k+=BS) {
#pragma omp task depend ( in: A[i:BS][k:BS], B[k:BS][j:BS] ) \
            depend ( inout: C[i:BS][j:BS] )
            for (ii = i; ii < i+BS; ii++ )
               for (jj = j; jj < j+BS; jj++ )
                  for (kk = k; kk < k+BS; kk++ )
                     C[ii][jj] = C[ii][jj] + A[ii][kk] * B[kk][jj];
         }
      }
   }
}


This code is interesting but looks wrong as it use VLA. I mean it does the multiplication of matrix in C but C being a VLA parameter of the function, it is a deep copy of the C argument so nothing output will come from this function. Also it will lead to really bad performance as a deep copy for 3 "big" array will happen.

Also, VLA are optional with C11, is it required to support them for OpenMP 4.0?

Does someone have another code to test dependencies on array?
Thanks,
Pierrick

Re: depends clause with array

PostPosted: Fri Dec 18, 2015 3:27 am
by Randalltbartel
The declaration statement for a temporary or variable array can contain a HAVING clause. The HAVING clause associates a label, format, and informat attribute with the array. If the array is a variable array, then the HAVING clause is also associated with the variables referenced by the variable array. You can refer this website to know more about writing works.