depends clause with array

Discuss the OpenMP 4.0 Examples document.
Forum rules
The OpenMP Forums are now closed to new posts. Please visit Stack Overflow if you are in need of help:
Posts: 3
Joined: Wed Oct 23, 2013 4:17 am

depends clause with array

Post by pierrick »


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?

Posts: 1
Joined: Sat Dec 05, 2015 12:20 am

Re: depends clause with array

Post 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.