Depend clause in openmp does not match declared dependency

I am trying to use openmp tasks to schedule the tiled execution of a basic jacobi2d calculation. In jacobi2d, there is a dependence on A (i, j) on

A (i, j)
A (i-1, j)
A (i + 1, j)
A (i, j-1)
A (i, j + 1).

In my understanding of the dependency clause, I correctly define the dependencies, but they are not respected when executing the code. I copied the simplified part of the code below. Initially, I assumed that out of range limits for some fragments this problem might occur, so I fixed it, but the problem persists. (I did not copy the longer code with the correct ranges of tiles, since this part is just a bunch of ifs + max)

int n=8,tsteps=2,b=4; //n - size of matrix, tsteps - time iterations, b - tile size or block size #pragma omp parallel { #pragma omp master for (t=0; t<tsteps; ++t) { for (i=0; i<n; i+=b) for (j=0; j<n; j+=b) { #pragma omp task firstprivate(t,i,j) depend(in:A[i-1:b+2][j-1:b+2]) depend(out:B[i:b][j:b]) { #pragma omp critical printf("t-%d i-%d j-%d --A",t,i,j); //Prints out time loop, i,j } } for (i=0; i<n; i+=b) for (j=0; j<n; j+=b) { #pragma omp task firstprivate(t,i,j) depend(in:B[i-1:b+2][j-1:b+2]) depend(out:A[i:b][j:b]) { #pragma omp critical printf("t-%d i-%d j-%d --B",t,i,j); //Prints out time loop, i,j } } } } } 

So the idea of ​​declaring a dependency, starting with i-1 and j-1 and range (b + 2), is that neighboring tiles also affect your current tile calculations. And similarly for the second set of loops, where the values ​​in should be overwritten only after the neighboring tiles used the values.

The code compiles using gcc 5.3, which supports openmp 4.0.

ps: the array path declared above indicates the starting position and the number of indices to consider when creating a dependency graph.

edit (based on Zulan comment) - changed the internal code to a simple print statement, as this is enough to check the order of the task. Ideally, for the above values ​​(since there are only 4 tiles), all tiles should complete the first printf and then only the second. But if you execute the code, it will mix the order.

+5
source share
1 answer

So, I finally figured out this problem, although the OpenMP specifications say that the dependency proposal is supposed to be implemented with a starting point and range, it has not yet been implemented in gcc. Therefore, he currently compares only the starting point with the depend clause (dependency (in: A [i-1: b + 2] [j-1: b + 2])) A [i-1] [j-1] in This case.

At first, I compared elements in different positions of a relative tile. For example, comparing (0,0) an element with the last element of a tile, which did not give rise to conflicts with dependency and, therefore, a random order of performing various tasks.

The current gcc implementation is not interested in the range specified in the sentence.

0
source

Source: https://habr.com/ru/post/1246112/


All Articles