Intel® oneAPI DPC++/C++ Compiler
Talk to fellow users of Intel® oneAPI DPC++/C++ Compiler and companion tools like Intel® oneAPI DPC++ Library, Intel® DPC++ Compatibility Tool, and Intel® Distribution for GDB*
685 Discussions

How do I translate this OpenACC code to SYCL?

gamersensual14
New Contributor I
1,311 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
1,269 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
1,217 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
1,202 Views

Let us know if the provided solution solved the problem.


0 Kudos
Subarnarek_G_Intel
1,186 Views

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


0 Kudos
Subarnarek_G_Intel
1,185 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