PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

CUDA-x86.

Compiling OpenMP & OpenACC for simultaneous execution

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



Joined: 22 Feb 2014
Posts: 5

PostPosted: Mon Feb 24, 2014 10:48 am    Post subject: Compiling OpenMP & OpenACC for simultaneous execution Reply with quote

Suppose that I have two regions of code (See below).
I would like to create one program that executes the OpenMP region on the CPU and the OpenACC region on the GPU simultaneously.
Can I do that? and how?

Thanks in advance.
Ami
======================

#pragma omp parallel for
for (int i = 1; i < m; i++)
{
some work... }

#pragma acc kernels
for (int j = 1; j < n; j++)
{
some work... }
Back to top
View user's profile
mkcolg



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

PostPosted: Mon Feb 24, 2014 1:09 pm    Post subject: Reply with quote

Hi Ami,

There's several ways this could be done. In my opinion, the easiest would be to launch your OpenACC compute region asynchronous, enter the OpenMP region, then use an OpenACC "wait" pragma to sync. Something like:

Code:
#pragma acc data pcopy(myarr[0:size])
{

// Use "async" to have the host code not wait for the
// kernel to finish before continuing
// Make sure no data is copied back, including a reduction,
// otherwise the code will block on the data movement
#pragma acc kernels present(myarr) async
for (int j = 1; j < n; j++)
 {
 some work...
 }

// CPU continues and then enters the OpenMP region
#pragma omp parallel for
 for (int i = 1; i < m; i++)
 {
 some work... }

} // end the data region, copy back myarr
// sync the host and device execution
#pragma acc wait


- Mat
Back to top
View user's profile
amimar



Joined: 22 Feb 2014
Posts: 5

PostPosted: Mon Feb 24, 2014 2:04 pm    Post subject: Reply with quote

Mat,

How such a program have to be compiled?
with the compiler option -acc or -mp?

Ami
Back to top
View user's profile
mkcolg



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

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

Quote:
compiler option -acc or -mp?
Both.
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