Unrecognized boolean variable inside the OpenACC parallel construct

Hello,

I am accelerating a function using the OpenACC manual data movement approach, the below function was working properly however when I introduced the (artificial_compressibility_method ) which is a boolean variable inside the function the value of it was not copied to the device even if I add it to the copyin clause.
Its value was ignored. I don’t understand what could be the problem, is it the boolean function or the if statement inside the function that is not passed. my second question can I copy a single int variable to the GPU or it should be in array shape.
Thanks for your help and support.

void FlowSolver::calculateFluxes() {

for(int i = topo->iter_common[INNER][INIX]; i <= topo->iter_common[INNER][ENDX]; i++) {
for(int j = topo->iter_common[INNER][INIY]; j <= topo->iter_common[INNER][ENDY]; j++) {
for(int k = topo->iter_common[INNER][INIZ]; k <= topo->iter_common[INNER][ENDZ]; k++) {
rho_inv_flux[I1D(i,j,k)] = 1.0 ;
}
}
}

int index_L, index_R, var_type;
double delta_x, delta_y, delta_z;
double rho_L, u_L, v_L, w_L, E_L, P_L, P_rhouvw_L, a_L;
double rho_R, u_R, v_R, w_R, E_R, P_R, P_rhouvw_R, a_R;
double rho_F_p, rho_F_m, rhou_F_p, rhou_F_m, rhov_F_p;
double rhov_F_m, rhow_F_p, rhow_F_m, rhoE_F_p, rhoE_F_m;
const int local_size_x = _lNx_;
const int local_size_y = _lNy_;
const int local_size_z = _lNz_;
const int local_size   = local_size_x*local_size_y*local_size_z;
const int inix = topo->iter_common[_INNER_][_INIX_];
const int iniy = topo->iter_common[_INNER_][_INIY_];
const int iniz = topo->iter_common[_INNER_][_INIZ_];
const int endx = topo->iter_common[_INNER_][_ENDX_];
const int endy = topo->iter_common[_INNER_][_ENDY_];
const int endz = topo->iter_common[_INNER_][_ENDZ_];
#pragma acc enter data copyin(this) 
#pragma acc parallel loop collapse (3) copyin (rho_field.vector[0:local_size],u_field.vector[0:local_size],v_field.vector[0:local_size],w_field.vector[0:local_size],E_field.vector[0:local_size],P_field.vector[0:local_size],sos_field.vector[0:local_size],x_field.vector[0:local_size],y_field.vector[0:local_size],z_field.vector[0:local_size]) copyout (rho_inv_flux.vector[0:local_size],rhou_inv_flux.vector[0:local_size],rhov_inv_flux.vector[0:local_size],rhow_inv_flux.vector[0:local_size],rhoE_inv_flux.vector[0:local_size])
for(int i = inix; i <= endx; i++) {
    for(int j = iniy; j <= endy; j++) {
        for(int k = iniz; k <= endz; k++) {

            /// Geometric stuff
            delta_x = 0.5*( x_field[I1D(i+1,j,k)] - x_field[I1D(i-1,j,k)] ); 
            delta_y = 0.5*( y_field[I1D(i,j+1,k)] - y_field[I1D(i,j-1,k)] ); 
            delta_z = 0.5*( z_field[I1D(i,j,k+1)] - z_field[I1D(i,j,k-1)] );
            /// x-direction i+1/2
            index_L = i;                           index_R = i + 1;
            rho_L   = rho_field[I1D(index_L,j,k)]; rho_R   = rho_field[I1D(index_R,j,k)]; 
            u_L     = u_field[I1D(index_L,j,k)];   u_R     = u_field[I1D(index_R,j,k)];
            v_L     = v_field[I1D(index_L,j,k)];   v_R     = v_field[I1D(index_R,j,k)];
            w_L     = w_field[I1D(index_L,j,k)];   w_R     = w_field[I1D(index_R,j,k)];
            E_L     = E_field[I1D(index_L,j,k)];   E_R     = E_field[I1D(index_R,j,k)];
            P_L     = P_field[I1D(index_L,j,k)];   P_R     = P_field[I1D(index_R,j,k)];
            a_L     = sos_field[I1D(index_L,j,k)]; a_R     = sos_field[I1D(index_R,j,k)];
            P_rhouvw_L = P_L;                      P_rhouvw_R = P_R;
            #pragma acc update device(artificial_compressibility_method)
            **if( artificial_compressibility_method ) {        **

** P_rhouvw_L = P_L - P_thermo;**
** P_rhouvw_R = P_R - P_thermo;**
rho_F_p = calculateIntercellFlux( rho_L, rho_R, u_L, u_R, v_L, v_R, w_L, w_R, E_L, E_R, P_L, P_R, a_L, a_R, var_type );
rhou_F_p = calculateIntercellFlux( rho_L, rho_R, u_L, u_R, v_L, v_R, w_L, w_R, E_L, E_R, P_rhouvw_L, P_rhouvw_R, a_L, a_R, var_type );
rhov_F_p = calculateIntercellFlux( rho_L, rho_R, u_L, u_R, v_L, v_R, w_L, w_R, E_L, E_R, P_rhouvw_L, P_rhouvw_R, a_L, a_R, var_type );
rhow_F_p = calculateIntercellFlux( rho_L, rho_R, u_L, u_R, v_L, v_R, w_L, w_R, E_L, E_R, P_rhouvw_L, P_rhouvw_R, a_L, a_R, var_type );
rhoE_F_p = calculateIntercellFlux( rho_L, rho_R, u_L, u_R, v_L, v_R, w_L, w_R, E_L, E_R, P_L, P_R, a_L, a_R, var_type );
}
}
}
}
for(int i = topo->iter_common[INNER][INIX]; i <= topo->iter_common[INNER][ENDX]; i++) {
for(int j = topo->iter_common[INNER][INIY]; j <= topo->iter_common[INNER][ENDY]; j++) {
for(int k = topo->iter_common[INNER][INIZ]; k <= topo->iter_common[INNER][ENDZ]; k++) {
cout << rho_inv_flux[I1D(i,j,k)] << endl;
}
}
}

Hi Ahmed,

Data and update directives can’t be used within a compute region. Can you try moving the update directive before the “acc parallel loop”?

-Mat

Hi Mat,

Thanks for your reply, I will apply your comment and check again.

Ahmed