PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

Free OpenACC Course

Struct member as loop bound error

 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Accelerator Programming
View previous topic :: View next topic  
Author Message
EnricoC



Joined: 07 Mar 2014
Posts: 16

PostPosted: Wed Sep 16, 2015 6:56 am    Post subject: Struct member as loop bound error Reply with quote

Hi,
I noticed a strange behavior when using a struct member as a loop bound, in particular:
ignoring OpenACC pragmas (and thus running in the CPU), both of the code versions reported below, work, giving the same results;
on the other side, when enabling OpenACC prgmas, the first version gives wrong results, while the second one gives correct results as the ones run on the CPU.

Am I doing something not allowed using OpenACC in the first code version?
Or both the versions should be equivalent and the compiler is doing something wrong when compiling the second one?

Code version one:
Code:

void recombine_shifted_vec3_to_vec3(const __restrict vec3_soa* const in_shifted
                                                        const __restrict vec3_soa* const in,
                                                                __restrict vec3_soa* const out,
                                                        const RationalApprox * const approx ){
  int ih;
  int iter=0;
  #pragma acc kernels present(out) present(in) present(in_shifted) present(approx)
  #pragma acc loop independent
  for(ih=0; ih < sizeh; ih++){

      out->c0[ih] =  in->c0[ih]*approx->RA_a0;
      out->c1[ih] =  in->c1[ih]*approx->RA_a0;
      out->c2[ih] =  in->c2[ih]*approx->RA_a0;

      #pragma acc seq
      for(iter=0; iter<(approx->approx_order); iter++){
        out->c0[ih] +=  approx->RA_a[iter] * in_shifted[iter].c0[ih];
        out->c1[ih] +=  approx->RA_a[iter] * in_shifted[iter].c1[ih];
        out->c2[ih] +=  approx->RA_a[iter] * in_shifted[iter].c2[ih];
      }
   }
}


Code version two:
Code:

void recombine_shifted_vec3_to_vec3(const __restrict vec3_soa* const in_shifted
                                                        const __restrict vec3_soa* const in,
                                                                __restrict vec3_soa* const out,
                                                        const RationalApprox * const approx ){
  int ih;
  int iter=0;
  #pragma acc kernels present(out) present(in) present(in_shifted) present(approx)
  #pragma acc loop independent
  for(ih=0; ih < sizeh; ih++){

      int ordine=approx->approx_order;

      out->c0[ih] =  in->c0[ih]*approx->RA_a0;
      out->c1[ih] =  in->c1[ih]*approx->RA_a0;
      out->c2[ih] =  in->c2[ih]*approx->RA_a0;

      #pragma acc seq
      for(iter=0; iter<ordine; iter++){
        out->c0[ih] +=  approx->RA_a[iter] * in_shifted[iter].c0[ih];
        out->c1[ih] +=  approx->RA_a[iter] * in_shifted[iter].c1[ih];
        out->c2[ih] +=  approx->RA_a[iter] * in_shifted[iter].c2[ih];
      }
   }
}
Back to top
View user's profile
mkcolg



Joined: 30 Jun 2004
Posts: 6484
Location: The Portland Group Inc.

PostPosted: Wed Sep 16, 2015 3:33 pm    Post subject: Reply with quote

Hi EnricoC,

What compiler version are you using?

I found a similar problem myself early this year and our compiler folks were able to fix it in the 15.4 release. If 15.4 doesn't fix your issue, can you please post or send to PGI Customer Service (trs@pgroup.com) a reproducing example so I can investigate?

Thanks,
Mat
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    PGI User Forum Forum Index -> Accelerator Programming All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © phpBB Group