Game of life with neighborhood without zeros - OpenMP version

We have a board B of size NxN, with integer values between 0 and a given maximum. Successive iterations are performed on the board. In each iteration, each non-zero element is substituted by the mean of its value and its neighbor values. If one neighbor value is 0, its neighbor in the same direction is consider. If that new neighbor is 0, no more neighbors in this direction are searched. For example, with an initial board

2 3 0 3

1 0 0 2

0 1 0 0

3 0 3 1

the resulting board in one iteration is

2 2 0 1

1 0 0 1

0 0 0 0

2 0 1 2

where the first 3 is substituted by 2=(3+2+3+1)/4,

and the value in the position of the first 1 is obtained 1=(1+2+0+3)/4.

The program obtains the number of 1s in the board after each iteration.

A number of problems is solved. For each problem the function to parallelize has:

Input parameters:

-int N: size of the board, NxN

-int *B: the board

-int NI: number of iterations

Output parameter:

-int *NUM1: number of ones in the board after each iteration, of size NI

Files

For more instructions: general instructions.