Intel® oneAPI Data Parallel C++
Support for Intel® oneAPI DPC++ Compiler, Intel® oneAPI DPC++ Library, Intel ICX Compiler , Intel® DPC++ Compatibility Tool, and GDB*
561 Discussions

How do I translate this OpenACC code to SYCL?

gamersensual14
New Contributor I
803 Views

Hi Intel team it's me again.

 

I would like to know how to parallelize this:

//#pragma acc parallel loop
for(i=0; i<targets; i++)
{
//#pragma acc loop
for(j=0; j<lines_samples; j++)
{
if(i == (targets-1)) x_p[i*lines_samples+j] = 0;
u[i] += pow(x_p[i*lines_samples+j], 2);
}

if(sum1 < u[i]) sum1 = u[i]; // Does this make it unparallelizable?
}

The problem is that last line. I tried to parallelize it like this:

my_queue.submit([&](auto &h) {
h.parallel_for(sycl::range<2>(targets,lines_samples), [=](auto index) {
int i = index[0];
int j = index[1];
if(i == (targets-1)) x_p[i*lines_samples+j] = 0;
u[i] += pow(x_p[i*lines_samples+j], 2);
});
}).wait();

But as you can see, I don't know where to put that last line so the behaviour is the same. That line is supposed to be executed only once per i iteration.

 

Looking forward to your answer.

 

Thank you!

0 Kudos
5 Replies
ManjulaC_Intel
Moderator
761 Views

Hi,


Thanks for reaching out to us, we are working on your issue.


Please refer the below DPCPP/SYCL documentation for migration.

https://www.intel.com/content/www/us/en/developer/tools/oneapi/data-parallel-c-plus-plus.html


Thanks & Regards,

Manjula


0 Kudos
Subarnarek_G_Intel
709 Views

Since, you were already using OpenACC an easier approach if you want to offload to Intel GPU's will be through the use of OpenMP Offload. Is there any particular reasons why you aren't using OpenMP Offload? As far as your SYCL code is concerned we need to rewrite the code a bit. You can put a for loop inside parallel_for region as well. Please refer https://github.com/oneapi-src/oneAPI-samples/blob/a8b6d2bd93ac5a251400ec1fed0cd94f565bf743/DirectProgramming/DPC%2B%2B/DenseLinearAlgebra/matrix_mul/src/matrix_mul_dpcpp.cpp

Please let me know if you have further queries.


0 Kudos
Subarnarek_G_Intel
694 Views

Let us know if the provided solution solved the problem.


0 Kudos
Subarnarek_G_Intel
678 Views

Closing this thread as there was no response from the customer.


0 Kudos
Subarnarek_G_Intel
677 Views

This issue has been resolved and we will no longer respond to this thread. If you require additional assistance from Intel, please start a new thread. Any further interaction in this thread will be considered community only.


0 Kudos
Reply