topic Inner loops with OpenCL in OpenCL*
https://community.intel.com/t5/OpenCL/Inner-loops-with-OpenCL/m-p/780537#M363
<DIV class="MessageText_Container">
<P>Hello</P>
<P>I am new to OpenCL and want to parallelize some looping code thats
doing lu factorization with the looping structure showed by exact code
as below:</P>
<P> for(int k = 0; k < N-1; k++)<BR /> {<BR /> for(int i = k+1; i < N; i++)<BR /> S[i*N + k] = S[i*N + k] / S[k*N + k];<BR /><BR /> for(int j = k+1; j < N; j++)<BR /> for(int i = k+1; i < N; i++)<BR /> S[i*N + j] -= S[i*N + k] * S[k*N + j];<BR /> }</P>
<P>I have done with the simple opencl kernel with single work items (no groping). Thats following:</P>
<P> int IDx = get_global_id(0);<BR /> int IDy = get_global_id(1);<BR /><BR /> for(int k = 0; k < n-1; k++)<BR /> {<BR /> barrier(CLK_GLOBAL_MEM_FENCE);<BR /><BR /> if(IDy > k && IDx == k)<BR /> matrix[IDy*n + IDx] = matrix[IDy*n + IDx] / matrix[IDx*n + IDx];<BR /><BR /> barrier(CLK_GLOBAL_MEM_FENCE);<BR /><BR /> for(int j = k+1; j < n; j++)<BR /> {<BR /> if(IDy > k && IDx == j)<BR /> matrix[IDy*n + IDx] -= matrix[IDy*n + k] * matrix[k*n + IDx];<BR /> }<BR /> }</P>
<P></P>
<P>But I dont get correct results when compared to the serial code, this
is my personal try for OpenCL kernel and I am still learning how this
data parallel scheme in OpenCL works, Can you point out what I am doing
wrong in the kernel?</P>
</DIV>Sun, 31 Jul 2011 18:18:56 GMTakhal2011-07-31T18:18:56ZInner loops with OpenCL
https://community.intel.com/t5/OpenCL/Inner-loops-with-OpenCL/m-p/780537#M363
<DIV class="MessageText_Container">
<P>Hello</P>
<P>I am new to OpenCL and want to parallelize some looping code thats
doing lu factorization with the looping structure showed by exact code
as below:</P>
<P> for(int k = 0; k < N-1; k++)<BR /> {<BR /> for(int i = k+1; i < N; i++)<BR /> S[i*N + k] = S[i*N + k] / S[k*N + k];<BR /><BR /> for(int j = k+1; j < N; j++)<BR /> for(int i = k+1; i < N; i++)<BR /> S[i*N + j] -= S[i*N + k] * S[k*N + j];<BR /> }</P>
<P>I have done with the simple opencl kernel with single work items (no groping). Thats following:</P>
<P> int IDx = get_global_id(0);<BR /> int IDy = get_global_id(1);<BR /><BR /> for(int k = 0; k < n-1; k++)<BR /> {<BR /> barrier(CLK_GLOBAL_MEM_FENCE);<BR /><BR /> if(IDy > k && IDx == k)<BR /> matrix[IDy*n + IDx] = matrix[IDy*n + IDx] / matrix[IDx*n + IDx];<BR /><BR /> barrier(CLK_GLOBAL_MEM_FENCE);<BR /><BR /> for(int j = k+1; j < n; j++)<BR /> {<BR /> if(IDy > k && IDx == j)<BR /> matrix[IDy*n + IDx] -= matrix[IDy*n + k] * matrix[k*n + IDx];<BR /> }<BR /> }</P>
<P></P>
<P>But I dont get correct results when compared to the serial code, this
is my personal try for OpenCL kernel and I am still learning how this
data parallel scheme in OpenCL works, Can you point out what I am doing
wrong in the kernel?</P>
</DIV>Sun, 31 Jul 2011 18:18:56 GMThttps://community.intel.com/t5/OpenCL/Inner-loops-with-OpenCL/m-p/780537#M363akhal2011-07-31T18:18:56ZInner loops with OpenCL
https://community.intel.com/t5/OpenCL/Inner-loops-with-OpenCL/m-p/780538#M364
Anybody there ....Wed, 03 Aug 2011 13:49:50 GMThttps://community.intel.com/t5/OpenCL/Inner-loops-with-OpenCL/m-p/780538#M364akhal2011-08-03T13:49:50ZInner loops with OpenCL
https://community.intel.com/t5/OpenCL/Inner-loops-with-OpenCL/m-p/780539#M365
Hello everybody,<BR />
<BR />
I encounter exactly the same problem: A barrier within a inner loop
seems not to guarantee a synchronisation within items of the same work
group. Does anybody have an explanation for this issue?<BR />
<BR />
Thank you in advance and kind regards<BR />
Stefan H.,<BR />
Germany<BR />Mon, 06 Feb 2012 13:54:03 GMThttps://community.intel.com/t5/OpenCL/Inner-loops-with-OpenCL/m-p/780539#M365stefanh2012-02-06T13:54:03ZInner loops with OpenCL
https://community.intel.com/t5/OpenCL/Inner-loops-with-OpenCL/m-p/780540#M366
Sorry for the late answer.<BR />I will check this issue and return to you as soon as possible.<BR />Can you give me the version of the OpenCL SDK you are using?<BR /><BR />Thanks.Mon, 06 Feb 2012 21:38:55 GMThttps://community.intel.com/t5/OpenCL/Inner-loops-with-OpenCL/m-p/780540#M366Amjad_A_Intel2012-02-06T21:38:55ZInner loops with OpenCL
https://community.intel.com/t5/OpenCL/Inner-loops-with-OpenCL/m-p/780541#M367
Hi Stefanh,<DIV></DIV><DIV>To be clear a barrier only guarantees that all threads will stop at that point and wait for all memory operations to complete before continueing on. That does not mean they didn't put memory access out of order before that call or after it.</DIV><DIV></DIV><DIV>To be fair I could see how the above problem is an overly excited parser unrolling loops.</DIV>Tue, 07 Feb 2012 22:52:52 GMThttps://community.intel.com/t5/OpenCL/Inner-loops-with-OpenCL/m-p/780541#M367Jim_Vaughn2012-02-07T22:52:52ZInner loops with OpenCL
https://community.intel.com/t5/OpenCL/Inner-loops-with-OpenCL/m-p/780542#M368
<P>Hi,</P><P>I went through the code and i think that the issue is in the implementation of the algorithm which requires that all work groups must complete their work prior to proceeding to the code after the barrier. However, please note that a barrier in OpenCL does not provide this mechanism (synchronization between work groups) as it only synchronizes work items in the same work group.</P><P>To validate this assumption please run the code with a single work group configuration (local size == global size). </P><P>Please let us know what you think about our analysis.</P><P>Regards,</P><P>Amjad</P>Thu, 09 Feb 2012 08:26:51 GMThttps://community.intel.com/t5/OpenCL/Inner-loops-with-OpenCL/m-p/780542#M368Amjad_A_Intel2012-02-09T08:26:51ZInner loops with OpenCL
https://community.intel.com/t5/OpenCL/Inner-loops-with-OpenCL/m-p/780543#M369
"I went through the code and i think that the issue is in the
implementation of the algorithm which requires that all work groups must
complete their work prior to proceeding to the code after the barrier."<BR /><BR />This was my original thought but I didn't have enough time to verify that it was occuring and to be honest wasn't 100% of how the original algorithm was intendend to function. I was going to recommend testing the code on the CPU using an outer loop to simulate random the execution environment to ensure it was correct. After you add the outer loop you could write a get_global_id() function which returned an random id which has not been used. I have used this is the past to debug issues with algorithms for the GPU and I am sure it will work here.<BR /><BR />Also I recently saw a paper on a similar subject about comparing openCL algorithms to their C counterparts semantically to ensure equality. It was very interesting as they ran their code through the Bullet physics engine's OpenCL implementation and found a number of unknown errors as well as compiler bugs. Obviously it wouldn't work when you make architecture trade offs but for simple porting of algorithms it could be of a real benifit.<BR />Thu, 09 Feb 2012 13:26:56 GMThttps://community.intel.com/t5/OpenCL/Inner-loops-with-OpenCL/m-p/780543#M369Jim_Vaughn2012-02-09T13:26:56Z