examples/omp/benchmarks/bots/omp-tasks/nqueens/nqueens-test.c
void nqueens(int n, int j, char *a, int *solutions)
{
    int i;
    int *csols;
    if (n == j) {
        *solutions = 1;
        return;
    }
    *solutions = 0;
    csols = alloca(n*sizeof(int));
    memset(csols,0,n*sizeof(int));

    /* try each possible position for queen <j> */
    for (i = 0; i < n; i++) {
#pragma omp task untied
        {
            char * b = alloca((j + 1) * sizeof(char));
            memcpy(b, a, j * sizeof(char));
            b[j] = i;
            if (ok(j + 1, b))
                nqueens(n, j + 1, b,&csols[i]);
        }
    }
#pragma omp taskwait
}
//It seems entirely possible to convert the allocas and arrays to a single int, 
// and some atomic increments for the solution.
// It will also require tracking of depth, so that calculation of all states with
// a state that has been determined invalid will not continue.
It seems entirely possible to convert the allocas and arrays to a single int,
and some atomic increments for the solution.
It will also require tracking of depth, so that calculation of all states with
a state that has been determined invalid will not continue.
It seems entirely possible to convert the allocas and arrays to a single int and some atomic increments for the solution . It will also require tracking of depth so that calculation of all states with a state that has been determined invalid will not continue .
void nqueens(int n, int j, char *a, int *solutions)
{
    int i;
    int *csols;
    if (n == j) {
        *solutions = 1;
        return;
    }
    *solutions = 0;
    csols = alloca(n*sizeof(int));
    memset(csols,0,n*sizeof(int));
    for (i = 0; i < n; i++) {
#pragma omp task untied
        {
            char * b = alloca((j + 1) * sizeof(char));
            memcpy(b, a, j * sizeof(char));
            b[j] = i;
            if (ok(j + 1, b))
                nqueens(n, j + 1, b,&csols[i]);
        }
    }
#pragma omp taskwait
}
void nqueens ( int n , int j , char * a , int * solutions ) { int i ; int * csols ; if ( n == j ) { * solutions = 1 ; return ; } * solutions = 0 ; csols = alloca ( n * sizeof ( int ) ) ; memset ( csols , 0 , n * sizeof ( int ) ) ; for ( i = 0 ; i < n ; i ++ ) { #pragma  omp task untied { char * b = alloca ( ( j + 1 ) * sizeof ( char ) ) ; memcpy ( b , a , j * sizeof ( char ) ) ; b [ j ] = i ; if ( ok ( j + 1 , b ) ) nqueens ( n , j + 1 , b , & csols [ i ] ) ; } } #pragma  omp taskwait }
It seems entirely possible to convert the allocas and arrays to a single int,
and some atomic increments for the solution.
It seems entirely possible to convert the allocas and arrays to a single int and some atomic increments for the solution .
/* try each possible position for queen <j> */