1

I am new to the oneAPI with SYCL and I have the following function

q.submit([&](auto &h) {
     h.parallel_for(range<1>(size), [=](id<1> idx) {
               m_Add(C,A,B,idx);
               m_Multiply(D,C,A,idx); 
             });

   }).wait();

I understand that the parallel_for function acts like

for(int idx = 0; idx < size; idx++)

I would like to run these m_Add and m_Multiply functions depending on a while loop condition like D < A so the parallel_for function runs while(D < A)

Is it possible to achieve this with any other function that the accelarator executes these functions within a while loop ?

solarlate
  • 11
  • 1
  • 2
  • If `D` changes throughout the loop, and the loop condition depends on it, then parallelism is not possible without manually coming up with some algorithm for it. If some thread encounters a `! (D – Peter Cordes Oct 05 '22 at 10:49
  • 2
    So TL:DR: no, I don't expect an API to allow a data-dependent exit condition for a parallel_for, only cases where the loop trip-count can be computed before the first iteration. But I haven't used OneAPI or SYCL. – Peter Cordes Oct 05 '22 at 10:51

0 Answers0