/*    TESTING OF THE SHADOW DIRECTIVE AND THE SHADOW_RENEW CLAUSE'.
     DISTRIBUTED ARRAY A(N,M) IS TO HAVE DIFFERENT SHADOW WIDTH
     ON BOTH SIDES */

#include <math.h>
#include <stdlib.h>
#include <stdio.h>

#define N 60
#define M 60
#define NL 1000

static void sh2101();
static void sh2102();
static void sh2103();
static void sh2104();
static void sh2105();
static void sh2106();
static void sh2107();
static void sh2108();
static void sh2109();
static void sh2110();
static void sh2111();
static void sh2112();
static void sh2113();
static void sh2114();
static void sh2115();
static void sh2116();
static void sh2117();
static void sh2118();
static void sh2119();
static void sh2120();
static void sh2121();
static void sh2122();

static void serial2(int AR[N][M], int NN, int NM, int NNL);
static void ansyes(const char tname[]);
static void ansno(const char tname[]);

int main(int argc, char *argv[])
{
    printf("===START OF SH21========================\n");
    sh2101();
    sh2102();
    sh2103();
    sh2104();
    sh2105();
    sh2106();
    sh2107();
    sh2108();
    sh2109();
    sh2110();
    sh2111();
    sh2112();
    sh2113();
    sh2114();
    sh2115();
    sh2116();
    sh2117();
    sh2118();
    sh2119();
    sh2120();
    sh2121();
    sh2122();

    printf("=== END OF SH21 ========================= \n");
    return 0;
}
/* ---------------------------------------------SH2101  */
void sh2101()
{
    int C[N][M];
    int nloopi, nloopj;
    char tname[] = "SH2101";
    int i, j, NN, NM, NNL;
    #pragma dvm array distribute[block][block]
    int B[N][M];
    #pragma dvm array align([i][j] with B[i][j])
    int A[N][M];
    NN = N;
    NM = M;
    NNL = NL;
    serial2(C, NN, NM, NNL);

    nloopi = NL;
    nloopj = NL;

    #pragma dvm region local(A), out(B)
    {
    #pragma dvm parallel([i][j] on A[i][j])
    for (i = 0; i < N; i++)
        for (j = 0; j < M; j++)
            A[i][j] = NL + i + j;
    #pragma dvm parallel([i][j] on B[i][j]) shadow_renew(A (corner))
    for (i = 1; i < N - 1; i++)
        for (j = 1; j < M - 1; j++)
            B[i][j] = A[i+1][j]+A[i][j+1]+A[i-1][j]+A[i][j-1]+ A[i-1][j-1]+
                       A[i+1][j+1]+A[i-1][j+1]+A[i+1][j-1];
    } /*end region*/

    #pragma dvm get_actual(B)
    #pragma dvm parallel([i][j] on B[i][j]) reduction(min(nloopi), min(nloopj))
    for (i = 1; i < N - 1; i++)
        for (j = 1; j < M - 1; j++)
            if (B[i][j] !=C[i+1][j]+C[i][j+1]+C[i-1][j]+C[i][j-1]+C[i-1][j-1]+
            C[i+1][j+1]+C[i-1][j+1]+C[i+1][j-1])
            {
                if (nloopi > i) nloopi = i;
                if (nloopj > j) nloopj = j;
            }
    if (nloopi == NL && nloopj == NL)
        ansyes(tname);
    else
        ansno(tname);
}

/* ---------------------------------------------SH2102  */
void sh2102()
{
    int C[N][M];
    int nloopi, nloopj;
    char tname[] = "SH2102";
    int i, j, NN, NM, NNL;
    #pragma dvm array distribute[block][block]
    int B[N][M];
    #pragma dvm array align([i][j] with B[i][j])
    int A[N][M];
    NN = N;
    NM = M;
    NNL = NL;
    serial2(C, NN, NM, NNL);

    nloopi = NL;
    nloopj = NL;

    #pragma dvm region local(A), out(B)
    {
    #pragma dvm parallel([i][j] on A[i][j])
    for (i = 0; i < N; i++)
        for (j = 0; j < M; j++)
            A[i][j] = NL + i + j;

    #pragma dvm parallel([i][j] on B[i][j]) shadow_renew(A[0:1][0:1](corner))
    for (i = 1; i < N - 1; i++)
        for (j = 1; j < M - 1; j++)
            B[i][j] = A[i+1][j]+A[i][j+1]+ A[i+1][j+1];
    } /*end region*/

    #pragma dvm get_actual(B)
    #pragma dvm parallel([i][j] on B[i][j]) reduction(min(nloopi), min(nloopj))
    for (i = 1; i < N - 1; i++)
        for (j = 1; j < M - 1; j++)
            if (B[i][j] !=C[i+1][j]+C[i][j+1]+C[i+1][j+1])
            {
                if (nloopi > i) nloopi = i;
                if (nloopj > j) nloopj = j;
            }

    if (nloopi == NL && nloopj == NL)
        ansyes(tname);
    else
        ansno(tname);
}

/* ---------------------------------------------SH2103  */
void sh2103()
{
    int C[N][M];
    int nloopi, nloopj;
    char tname[] = "SH2103";
    int i, j, NN, NM, NNL;
    #pragma dvm array distribute[block][block]
    int B[N][M];
    #pragma dvm array align([i][j] with B[i][j]), shadow[1:0][0:1]
    int A[N][M];
    NN = N;
    NM = M;
    NNL = NL;
    serial2(C, NN, NM, NNL);

    nloopi = NL;
    nloopj = NL;

    #pragma dvm region local(A), out(B)
    {
    #pragma dvm parallel([i][j] on A[i][j])
    for (i = 0; i < N; i++)
        for (j = 0; j < M; j++)
            A[i][j] = NL + i + j;

    #pragma dvm parallel([i][j] on B[i][j]) shadow_renew(A[1:0][0:1](corner))
    for (i = 1; i < N - 1; i++)
        for (j = 1; j < M - 1; j++)
            B[i][j] = A[i-1][j]+A[i][j+1];

    } /*end region*/

    #pragma dvm get_actual(B)

    #pragma dvm parallel([i][j] on B[i][j]) reduction(min(nloopi), min(nloopj))
    for (i = 1; i < N - 1; i++)
        for (j = 1; j < M - 1; j++)
            if (B[i][j] !=C[i-1][j]+C[i][j+1])
            {
                if (nloopi > i) nloopi = i;
                if (nloopj > j) nloopj = j;
            }

    if (nloopi == NL && nloopj == NL)
        ansyes(tname);
    else
        ansno(tname);
}
/* ---------------------------------------------SH2104  */
void sh2104()
{
    int C[N][M];
    int nloopi, nloopj;
    char tname[] = "SH2104";
    int i, j, NN, NM, NNL;
    #pragma dvm array distribute[block][block]
    int B[N][M];
    #pragma dvm array align([i][j] with B[i][j]), shadow[0:1][0:1]
    int A[N][M];
    NN = N;
    NM = M;
    NNL = NL;
    serial2(C, NN, NM, NNL);

    nloopi = NL;
    nloopj = NL;

    #pragma dvm region local(A), out(B)
    {
    #pragma dvm parallel([i][j] on A[i][j])
    for (i = 0; i < N; i++)
        for (j = 0; j < M; j++)
            A[i][j] = NL + i + j;

    #pragma dvm parallel([i][j] on B[i][j]) shadow_renew(A[0:1][0:1](corner))
    for (i = 1; i < N - 1; i++)
        for (j = 1; j < M - 1; j++)
            B[i][j] = A[i+1][j]+A[i][j+1]+ A[i+1][j+1];

    } /*end region*/

    #pragma dvm get_actual(B)

    #pragma dvm parallel([i][j] on B[i][j]) reduction(min(nloopi), min(nloopj))
    for (i = 1; i < N - 1; i++)
        for (j = 1; j < M - 1; j++)
            if (B[i][j] !=C[i+1][j]+C[i][j+1]+C[i+1][j+1])
            {
                if (nloopi > i) nloopi = i;
                if (nloopj > j) nloopj = j;
            }

    if (nloopi == NL && nloopj == NL)
        ansyes(tname);
    else
        ansno(tname);
}

/* ---------------------------------------------SH2105  */
void sh2105()
{
    int C[N][M];
    int nloopi, nloopj;
    char tname[] = "SH2105";
    int i, j, NN, NM, NNL;
    #pragma dvm array distribute[block][block]
    int B[N][M];
    #pragma dvm array align([i][j] with B[i][j]), shadow[0:1][1:0]
    int A[N][M];
    NN = N;
    NM = M;
    NNL = NL;
    serial2(C, NN, NM, NNL);

    nloopi = NL;
    nloopj = NL;

    #pragma dvm region local(A), out(B)
    {
    #pragma dvm parallel([i][j] on A[i][j])
    for (i = 0; i < N; i++)
        for (j = 0; j < M; j++)
            A[i][j] = NL + i + j;

    #pragma dvm parallel([i][j] on B[i][j]) shadow_renew(A[0:1][1:0](corner))
    for (i = 1; i < N - 1; i++)
        for (j = 1; j < M - 1; j++)
            B[i][j] = A[i][j-1]+A[i+1][j]+A[i+1][j-1];
    } /*end region*/

    #pragma dvm get_actual(B)

    #pragma dvm parallel([i][j] on B[i][j]) reduction(min(nloopi), min(nloopj))
    for (i = 1; i < N - 1; i++)
        for (j = 1; j < M - 1; j++)
            if (B[i][j] !=C[i][j-1]+C[i+1][j]+C[i+1][j-1])
            {
                if (nloopi > i) nloopi = i;
                if (nloopj > j) nloopj = j;
            }

    if (nloopi == NL && nloopj == NL)
        ansyes(tname);
    else
        ansno(tname);
}
/* ---------------------------------------------SH2106  */
void sh2106()
{
    int C[N][M];
    int nloopi, nloopj;
    char tname[] = "SH2106";
    int i, j, NN, NM, NNL;
    #pragma dvm array distribute[block][block]
    int B[N][M];
    #pragma dvm array align([i][j] with B[i][j]), shadow[0:1][0:0]
    int A[N][M];
    NN = N;
    NM = M;
    NNL = NL;
    serial2(C, NN, NM, NNL);

    nloopi = NL;
    nloopj = NL;

    #pragma dvm region local(A), out(B)
    {
    #pragma dvm parallel([i][j] on A[i][j])
    for (i = 0; i < N; i++)
        for (j = 0; j < M; j++)
            A[i][j] = NL + i + j;

    #pragma dvm parallel([i][j] on B[i][j]) shadow_renew(A[0:1][0:0](corner))
    for (i = 1; i < N - 1; i++)
        for (j = 1; j < M - 1; j++)
            B[i][j] = A[i+1][j];

    } /*end region*/

    #pragma dvm get_actual(B)

    #pragma dvm parallel([i][j] on B[i][j]) reduction(min(nloopi), min(nloopj))
    for (i = 1; i < N - 1; i++)
        for (j = 1; j < M - 1; j++)
            if (B[i][j] != C[i+1][j])
            {
                if (nloopi > i) nloopi = i;
                if (nloopj > j) nloopj = j;
            }

    if (nloopi == NL && nloopj == NL)
        ansyes(tname);
    else
        ansno(tname);
}
/* ---------------------------------------------SH2107  */
void sh2107()
{
    int C[N][M];
    int nloopi, nloopj;
    char tname[] = "SH2107";
    int i, j, NN, NM, NNL;
    #pragma dvm array distribute[block][block]
    int B[N][M];
    #pragma dvm array align([i][j] with B[i][j]), shadow[0:0][1:0]
    int A[N][M];
    NN = N;
    NM = M;
    NNL = NL;
    serial2(C, NN, NM, NNL);

    nloopi = NL;
    nloopj = NL;

    #pragma dvm region local(A), out(B)
    {
    #pragma dvm parallel([i][j] on A[i][j])
    for (i = 0; i < N; i++)
        for (j = 0; j < M; j++)
            A[i][j] = NL + i + j;

    #pragma dvm parallel([i][j] on B[i][j]) shadow_renew(A[0:0][1:0](corner))
    for (i = 1; i < N - 1; i++)
        for (j = 1; j < M - 1; j++)
            B[i][j] = A[i][j-1];

    } /*end region*/

    #pragma dvm get_actual(B)
    #pragma dvm parallel([i][j] on B[i][j]) reduction(min(nloopi), min(nloopj))
    for (i = 1; i < N - 1; i++)
        for (j = 1; j < M - 1; j++)
            if (B[i][j] !=C[i][j-1])
            {
                if (nloopi > i) nloopi = i;
                if (nloopj > j) nloopj = j;
            }

    if (nloopi == NL && nloopj == NL)
        ansyes(tname);
    else
        ansno(tname);
}

/* ---------------------------------------------SH2108  */
void sh2108()
{
    int C[N][M];
    int nloopi, nloopj;
    char tname[] = "SH2108";
    int i, j, NN, NM, NNL;
    #pragma dvm array distribute[block][block]
    int B[N][M];
    #pragma dvm array align([i][j] with B[i][j]), shadow[2:2][2:2]
    int A[N][M];
    NN = N;
    NM = M;
    NNL = NL;
    serial2(C, NN, NM, NNL);

    nloopi = NL;
    nloopj = NL;

    #pragma dvm region local(A), out(B)
    {
    #pragma dvm parallel([i][j] on A[i][j])
    for (i = 0; i < N; i++)
        for (j = 0; j < M; j++)
            A[i][j] = NL + i + j;

    #pragma dvm parallel([i][j] on B[i][j]) shadow_renew(A[2:2][2:2](corner))
    for (i = 2; i < N - 2; i++)
        for (j = 2; j < M - 2; j++)
            B[i][j] = A[i+2][j]+A[i][j+2]+A[i+2][j+2]+A[i-2][j+2]+
                 A[i-2][j]+A[i][j-2]+A[i-2][j-2]+A[i+2][j];
    } /*end region*/

    #pragma dvm get_actual(B)

    #pragma dvm parallel([i][j] on B[i][j]) reduction(min(nloopi), min(nloopj))
    for (i = 2; i < N - 2; i++)
        for (j = 2; j < M - 2; j++)
            if (B[i][j] != C[i+2][j]+C[i][j+2]+C[i+2][j+2]+C[i-2][j+2]+
                 C[i-2][j]+C[i][j-2]+C[i-2][j-2]+C[i+2][j])
            {
                if (nloopi > i) nloopi = i;
                if (nloopj > j) nloopj = j;
            }

    if (nloopi == NL && nloopj == NL)
        ansyes(tname);
    else
        ansno(tname);
}
/* ---------------------------------------------SH2109  */
 void sh2109()
{
    int C[N][M];
    int nloopi, nloopj;
    char tname[] = "SH2109";
    int i, j, NN, NM, NNL;
    #pragma dvm array distribute[block][block]
    int B[N][M];
    #pragma dvm array align([i][j] with B[i][j]), shadow[0:2][2:2]
    int A[N][M];
    NN = N;
    NM = M;
    NNL = NL;
    serial2(C, NN, NM, NNL);

    nloopi = NL;
    nloopj = NL;

    #pragma dvm region local(A), out(B)
    {
    #pragma dvm parallel([i][j] on A[i][j])
    for (i = 0; i < N; i++)
        for (j = 0; j < M; j++)
            A[i][j] = NL + i + j;

    #pragma dvm parallel([i][j] on B[i][j]) shadow_renew(A[0:2][2:2](corner))
    for (i = 2; i < N - 2; i++)
        for (j = 2; j < M - 2; j++)
            B[i][j] = A[i+2][j+2]+A[i+1][j+1]+A[i][j+2]+A[i][j-2]+A[i+2][j-2];
    } /*end region*/

    #pragma dvm get_actual(B)

    #pragma dvm parallel([i][j] on B[i][j]) reduction(min(nloopi), min(nloopj))
    for (i = 2; i < N - 2; i++)
        for (j = 2; j < M - 2; j++)
            if (B[i][j] != C[i+2][j+2]+C[i+1][j+1]+C[i][j+2]+C[i][j-2]+C[i+2][j-2])
            {
                if (nloopi > i) nloopi = i;
                if (nloopj > j) nloopj = j;
            }

   if (nloopi == NL && nloopj == NL)
       ansyes(tname);
   else
       ansno(tname);
}
/* ---------------------------------------------SH2110  */
void sh2110()
{
    int C[N][M];
    int nloopi, nloopj;
    char tname[] = "SH2110";
    int i, j, NN, NM, NNL;
    #pragma dvm array distribute[block][block]
    int B[N][M];
    #pragma dvm array align([i][j] with B[i][j]), shadow[2:2][2:0]
    int A[N][M];
    NN = N;
    NM = M;
    NNL = NL;
    serial2(C, NN, NM, NNL);

    nloopi = NL;
    nloopj = NL;

    #pragma dvm region local(A), out(B)
    {
    #pragma dvm parallel([i][j] on A[i][j])
    for (i = 0; i < N; i++)
        for (j = 0; j < M; j++)
            A[i][j] = NL + i + j;

    #pragma dvm parallel([i][j] on B[i][j]) shadow_renew(A[2:2][2:0](corner))
    for (i = 2; i < N - 2; i++)
        for (j = 2; j < M - 2; j++)
            B[i][j] = A[i-2][j-2]+A[i-1][j-1]+A[i-2][j]+A[i+2][j]+A[i+2][j-2];
    } /*end region*/

    #pragma dvm get_actual(B)

    #pragma dvm parallel([i][j] on B[i][j]) reduction(min(nloopi), min(nloopj))
    for (i = 2; i < N - 2; i++)
        for (j = 2; j < M - 2; j++)
            if (B[i][j] != C[i-2][j-2]+C[i-1][j-1]+C[i-2][j]+C[i+2][j]+C[i+2][j-2])
            {
                if (nloopi > i) nloopi = i;
                if (nloopj > j) nloopj = j;
            }

    if (nloopi == NL && nloopj == NL)
        ansyes(tname);
    else
        ansno(tname);
}
/* ---------------------------------------------SH2111  */
void sh2111()
{
    int C[N][M];
    int nloopi, nloopj;
    char tname[] = "SH2111";
    int i, j, NN, NM, NNL;
    #pragma dvm array distribute[block][block]
    int B[N][M];
    #pragma dvm array align([i][j] with B[i][j]), shadow[2:2][0:2]
    int A[N][M];
    NN = N;
    NM = M;
    NNL = NL;
    serial2(C, NN, NM, NNL);

    nloopi = NL;
    nloopj = NL;

    #pragma dvm region local(A), out(B)
    {
    #pragma dvm parallel([i][j] on A[i][j])
    for (i = 0; i < N; i++)
        for (j = 0; j < M; j++)
            A[i][j] = NL + i + j;

    #pragma dvm parallel([i][j] on B[i][j]) shadow_renew(A[2:2][0:2](corner))
    for (i = 2; i < N - 2; i++)
        for (j = 2; j < M - 2; j++)
            B[i][j] = A[i+2][j+2]+A[i+1][j+1]+A[i-2][j+2]+A[i+2][j];
    } /*end region*/

    #pragma dvm get_actual(B)

    #pragma dvm parallel([i][j] on B[i][j]) reduction(min(nloopi), min(nloopj))
    for (i = 2; i < N - 2; i++)
        for (j = 2; j < M - 2; j++)
            if (B[i][j] != C[i+2][j+2]+C[i+1][j+1]+C[i-2][j+2]+C[i+2][j])
            {
                if (nloopi > i) nloopi = i;
                if (nloopj > j) nloopj = j;
            }

    if (nloopi == NL && nloopj == NL)
        ansyes(tname);
    else
        ansno(tname);
}

/* ---------------------------------------------SH2112  */
void sh2112()
{
    int C[N][M];
    int nloopi, nloopj;
    char tname[] = "SH2112";
    int i, j, NN, NM, NNL;
    #pragma dvm array distribute[block][block]
    int B[N][M];
    #pragma dvm array align([i][j] with B[i][j]), shadow[2:0][2:2]
    int A[N][M];
    NN = N;
    NM = M;
    NNL = NL;
    serial2(C, NN, NM, NNL);

    nloopi = NL;
    nloopj = NL;

    #pragma dvm region local(A), out(B)
    {
    #pragma dvm parallel([i][j] on A[i][j])
    for (i = 0; i < N; i++)
        for (j = 0; j < M; j++)
            A[i][j] = NL + i + j;

    #pragma dvm parallel([i][j] on B[i][j]) shadow_renew(A[1:0][0:1](corner))
    for (i = 2; i < N - 2; i++)
        for (j = 2; j < M - 2; j++)
            B[i][j] = A[i-1][j+1]+A[i][j+1]+A[i-1][j];
    } /*end region*/

    #pragma dvm get_actual(B)

    #pragma dvm parallel([i][j] on B[i][j]) reduction(min(nloopi), min(nloopj))
    for (i = 2; i < N - 2; i++)
        for (j = 2; j < M - 2; j++)
            if (B[i][j] != C[i-1][j+1]+C[i][j+1]+C[i-1][j])
            {
                if (nloopi > i) nloopi = i;
                if (nloopj > j) nloopj = j;
            }

    if (nloopi == NL && nloopj == NL)
        ansyes(tname);
    else
        ansno(tname);
}
/* ---------------------------------------------SH2113  */
void sh2113()
{
    int C[N][M];
    int nloopi, nloopj;
    char tname[] = "SH2113";
    int i, j, NN, NM, NNL;
    #pragma dvm array distribute[block][block]
    int B[N][M];
    #pragma dvm array align([i][j] with B[i][j]), shadow[2:2][2:0]
    int A[N][M];
    NN = N;
    NM = M;
    NNL = NL;
    serial2(C, NN, NM, NNL);

    nloopi = NL;
    nloopj = NL;

    #pragma dvm region local(A), out(B)
    {
    #pragma dvm parallel([i][j] on A[i][j])
    for (i = 0; i < N; i++)
        for (j = 0; j < M; j++)
            A[i][j] = NL + i + j;

    #pragma dvm parallel([i][j] on B[i][j]) shadow_renew(A[0:1][0:0](corner))
    for (i = 2; i < N - 2; i++)
        for (j = 2; j < M - 2; j++)
            B[i][j] = A[i+1][j];
    } /*end region*/

    #pragma dvm get_actual(B)

    #pragma dvm parallel([i][j] on B[i][j]) reduction(min(nloopi), min(nloopj))
    for (i = 2; i < N - 2; i++)
        for (j = 2; j < M - 2; j++)
            if (B[i][j] !=C[i+1][j])
            {
                if (nloopi > i) nloopi = i;
                if (nloopj > j) nloopj = j;
            }

    if (nloopi == NL && nloopj == NL)
        ansyes(tname);
    else
        ansno(tname);
}
/* ---------------------------------------------SH2114  */
void sh2114()
{
    int C[N][M];
    int nloopi, nloopj;
    char tname[] = "SH2114";
    int i, j, NN, NM, NNL;
    #pragma dvm array distribute[block][block]
    int B[N][M];
    #pragma dvm array align([i][j] with B[i][j]), shadow[2:0][2:2]
    int A[N][M];
    NN = N;
    NM = M;
    NNL = NL;
    serial2(C, NN, NM, NNL);

    nloopi = NL;
    nloopj = NL;

    #pragma dvm region local(A), out(B)
    {
    #pragma dvm parallel([i][j] on A[i][j])
    for (i = 0; i < N; i++)
        for (j = 0; j < M; j++)
            A[i][j] = NL + i + j;

    #pragma dvm parallel([i][j] on B[i][j]) shadow_renew(A[0:0][0:2](corner))
    for (i = 2; i < N - 2; i++)
        for (j = 2; j < M - 2; j++)
            B[i][j] = A[i][j+2]+A[i][j+1];
    } /*end region*/

    #pragma dvm get_actual(B)

    #pragma dvm parallel([i][j] on B[i][j]) reduction(min(nloopi), min(nloopj))
    for (i = 2; i < N - 2; i++)
        for (j = 2; j < M - 2; j++)
            if (B[i][j] !=C[i][j+2]+C[i][j+1])
            {
                if (nloopi > i) nloopi = i;
                if (nloopj > j) nloopj = j;
            }

    if (nloopi == NL && nloopj == NL)
        ansyes(tname);
    else
        ansno(tname);
}
/* ---------------------------------------------SH2115  */
void sh2115()
{
    int C[N][M];
    int nloopi, nloopj;
    char tname[] = "SH2115";
    int i, j, NN, NM, NNL;
    #pragma dvm array distribute[block][block]
    int B[N][M];
    #pragma dvm array align([i][j] with B[i][j]), shadow[3:3][3:3]
    int A[N][M];
    NN = N;
    NM = M;
    NNL = NL;
    serial2(C, NN, NM, NNL);

    nloopi = NL;
    nloopj = NL;

    #pragma dvm region local(A), out(B)
    {
    #pragma dvm parallel([i][j] on A[i][j])
    for (i = 0; i < N; i++)
        for (j = 0; j < M; j++)
            A[i][j] = NL + i + j;

    #pragma dvm parallel([i][j] on B[i][j]) shadow_renew(A(corner))
    for (i = 3; i < N - 3; i++)
        for (j = 3; j < M - 3; j++)
            B[i][j] = A[i+1][j+1]+A[i+2][j+2]+A[i+3][j+3]+A[i-3][j-3]+A[i-2][j-2]+
                 A[i-1][j-1]+A[i-3][j+3]+A[i+3][j-3];
    } /*end region*/

    #pragma dvm get_actual(B)

    #pragma dvm parallel([i][j] on B[i][j]) reduction(min(nloopi), min(nloopj))
    for (i = 3; i < N - 3; i++)
        for (j = 3; j < M - 3; j++)
            if (B[i][j] !=C[i+1][j+1]+C[i+2][j+2]+C[i+3][j+3]+C[i-3][j-3]+C[i-2][j-2]+
                 C[i-1][j-1]+C[i-3][j+3]+C[i+3][j-3])
            {
                if (nloopi > i) nloopi = i;
                if (nloopj > j) nloopj = j;
            }

    if (nloopi == NL && nloopj == NL)
        ansyes(tname);
    else
        ansno(tname);
}
/*  ---------------------------------------------SH2116  */
void sh2116()
{
    int C[N][M];
    int nloopi, nloopj;
    char tname[] = "SH2116";
    int i, j, NN, NM, NNL;
    #pragma dvm array distribute[block][block]
    int B[N][M];
    #pragma dvm array align([i][j] with B[i][j]), shadow[3:3][0:3]
    int A[N][M];
    NN = N;
    NM = M;
    NNL = NL;
    serial2(C, NN, NM, NNL);

    nloopi = NL;
    nloopj = NL;

    #pragma dvm region local(A), out(B)
    {
    #pragma dvm parallel([i][j] on A[i][j])
    for (i = 0; i < N; i++)
        for (j = 0; j < M; j++)
            A[i][j] = NL + i + j;

    #pragma dvm parallel([i][j] on B[i][j]) shadow_renew(A[0:0][0:1](corner))
    for (i = 3; i < N - 3; i++)
        for (j = 3; j < M - 3; j++)
            B[i][j] = A[i][j+1];
    } /*end region*/

    #pragma dvm get_actual(B)

    #pragma dvm parallel([i][j] on B[i][j]) reduction(min(nloopi), min(nloopj))
    for (i = 3; i < N - 3; i++)
        for (j = 3; j < M - 3; j++)
            if (B[i][j] !=C[i][j+1])
            {
                if (nloopi > i) nloopi = i;
                if (nloopj > j) nloopj = j;
            }

    if (nloopi == NL && nloopj == NL)
        ansyes(tname);
    else
        ansno(tname);
}

/* ---------------------------------------------SH2117  */
void sh2117()
{
    int C[N][M];
    int nloopi, nloopj;
    char tname[] = "SH2117";
    int i, j, NN, NM, NNL;
    #pragma dvm array distribute[block][block]
    int B[N][M];
    #pragma dvm array align([i][j] with B[i][j]), shadow[0:3][3:3]
    int A[N][M];
    NN = N;
    NM = M;
    NNL = NL;
    serial2(C, NN, NM, NNL);

    nloopi = NL;
    nloopj = NL;

    #pragma dvm region local(A), out(B)
    {
    #pragma dvm parallel([i][j] on A[i][j])
    for (i = 0; i < N; i++)
        for (j = 0; j < M; j++)
            A[i][j] = NL + i + j;

    #pragma dvm parallel([i][j] on B[i][j]) shadow_renew(A[0:1][0:0](corner))
    for (i = 3; i < N - 3; i++)
        for (j = 3; j < M - 3; j++)
            B[i][j] = A[i+1][j];
    } /*end region*/

    #pragma dvm get_actual(B)

    #pragma dvm parallel([i][j] on B[i][j]) reduction(min(nloopi), min(nloopj))
    for (i = 3; i < N - 3; i++)
        for (j = 3; j < M - 3; j++)
            if (B[i][j] !=C[i+1][j])
            {
                if (nloopi > i) nloopi = i;
                if (nloopj > j) nloopj = j;
            }

    if (nloopi == NL && nloopj == NL)
        ansyes(tname);
    else
        ansno(tname);
}
/* ---------------------------------------------SH2118  */
void sh2118()
{
    int C[N][M];
    int nloopi, nloopj;
    char tname[] = "SH2118";
    int i, j, NN, NM, NNL;
    #pragma dvm array distribute[block][block]
    int B[N][M];
    #pragma dvm array align([i][j] with B[i][j]), shadow[3:3][3:0]
    int A[N][M];
    NN = N;
    NM = M;
    NNL = NL;
    serial2(C, NN, NM, NNL);

    nloopi = NL;
    nloopj = NL;

    #pragma dvm region local(A), out(B)
    {
    #pragma dvm parallel([i][j] on A[i][j])
    for (i = 0; i < N; i++)
        for (j = 0; j < M; j++)
            A[i][j] = NL + i + j;

    #pragma dvm parallel([i][j] on B[i][j]) shadow_renew(A(corner))
    for (i = 3; i < N - 3; i++)
        for (j = 3; j < M - 3; j++)
            B[i][j] = A[i-3][j-3]+A[i+3][j]+A[i-3][j];
    } /*end region*/

    #pragma dvm get_actual(B)

    #pragma dvm parallel([i][j] on B[i][j]) reduction(min(nloopi), min(nloopj))
    for (i = 3; i < N - 3; i++)
        for (j = 3; j < M - 3; j++)
            if (B[i][j] !=C[i-3][j-3]+C[i+3][j]+C[i-3][j])
            {
                if (nloopi > i) nloopi = i;
                if (nloopj > j) nloopj = j;
            }

    if (nloopi == NL && nloopj == NL)
        ansyes(tname);
    else
        ansno(tname);
}
/* ---------------------------------------------SH2119  */
void sh2119()
{
    int C[N][M];
    int nloopi, nloopj;
    char tname[] = "SH2119";
    int i, j, NN, NM, NNL;
    #pragma dvm array distribute[block][block]
    int B[N][M];
    #pragma dvm array align([i][j] with B[i][j]), shadow[3:0][3:3]
    int A[N][M];
    NN = N;
    NM = M;
    NNL = NL;
    serial2(C, NN, NM, NNL);

    nloopi = NL;
    nloopj = NL;

    #pragma dvm region local(A), out(B)
    {
    #pragma dvm parallel([i][j] on A[i][j])
    for (i = 0; i < N; i++)
        for (j = 0; j < M; j++)
            A[i][j] = NL + i + j;

    #pragma dvm parallel([i][j] on B[i][j]) shadow_renew(A[3:0][3:3](corner))
    for (i = 3; i < N - 3; i++)
        for (j = 3; j < M - 3; j++)
            B[i][j] = A[i-3][j-3]+A[i][j+3]+A[i-3][j+3];
    } /*end region*/

    #pragma dvm get_actual(B)

    #pragma dvm parallel([i][j] on B[i][j]) reduction(min(nloopi), min(nloopj))
    for (i = 3; i < N - 3; i++)
        for (j = 3; j < M - 3; j++)
            if (B[i][j] !=C[i-3][j-3]+C[i][j+3]+C[i-3][j+3])
            {
                if (nloopi > i) nloopi = i;
                if (nloopj > j) nloopj = j;
            }

    if (nloopi == NL && nloopj == NL)
        ansyes(tname);
    else
        ansno(tname);
}
/* ---------------------------------------------SH2120  */
void sh2120()
{
    int C[N][M];
    int nloopi, nloopj;
    char tname[] = "SH2120";
    int i, j, NN, NM, NNL;
    #pragma dvm array distribute[block][block]
    int B[N][M];
    #pragma dvm array align([i][j] with B[i][j]), shadow[9:9][9:9]
    int A[N][M];
    NN = N;
    NM = M;
    NNL = NL;
    serial2(C, NN, NM, NNL);

    nloopi = NL;
    nloopj = NL;

    #pragma dvm region local(A), out(B)
    {
    #pragma dvm parallel([i][j] on A[i][j])
    for (i = 0; i < N; i++)
        for (j = 0; j < M; j++)
            A[i][j] = NL + i + j;

    #pragma dvm parallel([i][j] on B[i][j]) shadow_renew(A(corner))
    for (i = 9; i < N - 9;i++)
        for (j = 9; j < M - 9; j++)
            B[i][j] = A[i+7][j+7]+A[i+8][j+8]+A[i+9][j+9]+A[i-9][j-9]+A[i-8][j-8]+
                 A[i-7][j-7]+A[i-9][j+9]+A[i+9][j-9];

    } /*end region*/

    #pragma dvm get_actual(B)

    #pragma dvm parallel([i][j] on B[i][j]) reduction(min(nloopi), min(nloopj))
    for (i = 9; i < N - 9; i++)
        for (j = 9; j < M - 9; j++)
            if (B[i][j] !=C[i+7][j+7]+C[i+8][j+8]+C[i+9][j+9]+C[i-9][j-9]+C[i-8][j-8]+
                 C[i-7][j-7]+C[i-9][j+9]+C[i+9][j-9] )
            {
                if (nloopi > i) nloopi = i;
                if (nloopj > j) nloopj = j;
            }

    if (nloopi == NL && nloopj == NL)
        ansyes(tname);
    else
        ansno(tname);
}
/* ---------------------------------------------SH2121  */
void sh2121()
{
    int C[N][M];
    int nloopi, nloopj;
    char tname[] = "SH2121";
    int i, j, NN, NM, NNL;

    #pragma dvm array distribute[block][block]
    int B[N][M];

    #pragma dvm array shadow[9:9][9:9]
    int A[N][M];

    NN = N;
    NM = M;
    NNL = NL;
    serial2(C, NN, NM, NNL);
    nloopi = NL;
    nloopj = NL;
    #pragma dvm realign(A[i][j] with B[i][j])
    #pragma dvm region local(A), out(B)
    {

    #pragma dvm parallel([i][j] on A[i][j])
    for (i = 0; i < N; i++)
        for (j = 0; j < M; j++)
            A[i][j] = NL + i + j;

    #pragma dvm parallel([i][j] on B[i][j]) shadow_renew(A(corner))
    for (i = 9; i < N - 9;i++)
        for (j = 9; j < M - 9; j++)
            B[i][j] = A[i+7][j+7]+A[i+8][j+8]+A[i+9][j+9]+A[i-9][j-9]+A[i-8][j-8]+
                 A[i-7][j-7]+A[i-9][j+9]+A[i+9][j-9];

    } /*end region*/

    #pragma dvm get_actual(B)

    #pragma dvm parallel([i][j] on B[i][j]) reduction(min(nloopi), min(nloopj))
    for (i = 9; i < N - 9; i++)
        for (j = 9; j < M - 9; j++)
            if (B[i][j] !=C[i+7][j+7]+C[i+8][j+8]+C[i+9][j+9]+C[i-9][j-9]+C[i-8][j-8]+
                 C[i-7][j-7]+C[i-9][j+9]+C[i+9][j-9] )
            {
                if (nloopi > i) nloopi = i;
                if (nloopj > j) nloopj = j;
            }

    if (nloopi == NL && nloopj == NL)
        ansyes(tname);
    else
        ansno(tname);
}
/* ---------------------------------------------SH2122  */
void sh2122()
{
    int C[N][M];
    int nloopi, nloopj;
    char tname[] = "SH2122";
    int i, j, NN, NM, NNL;

    #pragma dvm array
    int B[N][M];

    #pragma dvm array shadow[9:9][9:9]
    int A[N][M];

    NN = N;
    NM = M;
    NNL = NL;
    serial2(C, NN, NM, NNL);
    nloopi = NL;
    nloopj = NL;
    #pragma dvm redistribute(B[block][block])
    #pragma dvm realign(A[i][j] with B[i][j])
    #pragma dvm region local(A), out(B)
    {

    #pragma dvm parallel([i][j] on A[i][j])
    for (i = 0; i < N; i++)
        for (j = 0; j < M; j++)
            A[i][j] = NL + i + j;

    #pragma dvm parallel([i][j] on B[i][j]) shadow_renew(A(corner))
    for (i = 9; i < N - 9;i++)
        for (j = 9; j < M - 9; j++)
            B[i][j] = A[i+7][j+7]+A[i+8][j+8]+A[i+9][j+9]+A[i-9][j-9]+A[i-8][j-8]+
                 A[i-7][j-7]+A[i-9][j+9]+A[i+9][j-9];

    } /*end region*/

    #pragma dvm get_actual(B)

    #pragma dvm parallel([i][j] on B[i][j]) reduction(min(nloopi), min(nloopj))
    for (i = 9; i < N - 9; i++)
        for (j = 9; j < M - 9; j++)
            if (B[i][j] !=C[i+7][j+7]+C[i+8][j+8]+C[i+9][j+9]+C[i-9][j-9]+C[i-8][j-8]+
                 C[i-7][j-7]+C[i-9][j+9]+C[i+9][j-9] )
            {
                if (nloopi > i) nloopi = i;
                if (nloopj > j) nloopj = j;
            }

    if (nloopi == NL && nloopj == NL)
        ansyes(tname);
    else
        ansno(tname);
}

void serial2(int AR[N][M], int NN, int NM, int NNL)
{
    int i,j;
    for (i = 0; i < NN; i++)
        for (j = 0; j < NM; j++)
            AR[i][j] = NNL + i + j;
}

void ansyes(const char name[])
{
    printf("%s  -  complete\n", name);
}

void ansno(const char name[])
{
    printf("%s  -  ***error\n", name);
}
