PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

CUDA-x86.

Preprocessing and directives(omp/acc)

 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling
View previous topic :: View next topic  
Author Message
AndrewWilson41729



Joined: 19 Dec 2013
Posts: 14

PostPosted: Mon Feb 24, 2014 2:39 pm    Post subject: Preprocessing and directives(omp/acc) Reply with quote

I'm trying to design code which uses controls OPM or ACC based on a configuration-wide preprocessor symbol.

Code:
#ifdef GPU_SOLVE
#  define CPU_Omp NO_omp
#else
#  define CPU_Omp omp
#endif

... <snip> ...

        !$acc wait(31)
        !$CPU_Omp do  PRIVATE_VARS
        !$acc kernels async(41)
        !$acc loop collapse(3) &
        !$acc      private(i_pml,i_x,i_y)
        do i_pml=2,theGrid % n_pml_bounds-1
            do i_y=1+1,theGrid % n_y-1
                do i_x=1+1,theGrid % n_x-1
                    g_z(i_x,i_y,i_pml,1) = g_z(i_x,i_y,i_pml,2)
                enddo
            enddo
        enddo
        !$acc end kernels
        !$CPU_Omp end do
...<snip>...


This does not behave as I expect: no matter whether GPU_SOLVE is defined or not, (and although I have preprocessing enabled), the !$CPU_omp is not replaced before hitting the directives processing.

(a) Do omp/acc directives get processed before the preprocessor?
(b) If not, why does the preprocessor not replace these instances of the defined symbol?
(c) Is there available documentation on the order of events during pgfort compilation?
Back to top
View user's profile
mkcolg



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

PostPosted: Tue Feb 25, 2014 11:41 am    Post subject: Reply with quote

Quote:
(b) If not, why does the preprocessor not replace these instances of the defined symbol?
The Fortran preprocesser wont replace symbols in comments. You can use cpp instead (i.e. add -Mcpp) but this will only preprocess files (.f90 -> .f) so you'd need to adapt your build process to separate out the preprocess step from the compile step.

Though, the easiest thing to do would be to simply put the "!$" in your define. Something like:

Code:
#ifdef GPU_SOLVE
#  define CPU_Omp !NO_omp
#else
#  define CPU_Omp !$omp
#endif

... <snip> ...

        !$acc wait(31)
        CPU_Omp do  PRIVATE_VARS
        !$acc kernels async(41)
        !$acc loop collapse(3) &
        !$acc      private(i_pml,i_x,i_y)
        do i_pml=2,theGrid % n_pml_bounds-1
            do i_y=1+1,theGrid % n_y-1
                do i_x=1+1,theGrid % n_x-1
                    g_z(i_x,i_y,i_pml,1) = g_z(i_x,i_y,i_pml,2)
                enddo
            enddo
        enddo
        !$acc end kernels
        CPU_Omp end do
...<snip>...


Hope this helps,
Mat
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling 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