AnsweredAssumed Answered

barrier or write_mem_fence

Question asked by spectral on Oct 9, 2012
Latest reply on Oct 10, 2012 by spectral

Hi,

 

I have some doubts about the use of 'write_mem_fence' and 'barrier'.

 

Here is my code :

 

__local WorkItemData workItemData;
const size_t lid     = get_local_id(0);
     if (lid < 1)
     {     
          workItemData.sky                         = sky;
          workItemData.lightsCount               = lightsCount;
          workItemData.emitters                    = emitters;
     }

     //---- Sync : wait that 'workItemData' is fully initialized
     barrier(CLK_LOCAL_MEM_FENCE);
     //write_mem_fence(CLK_LOCAL_MEM_FENCE);

 

The goal is to insure that the variable 'workItemData is well initialized'. Can I use a write_mem_fence ? Will it be faster and more efficient ?

 

Is there some other way to improve performance in this case, by example if I put more operation between the initialization and use, sometimes I don't need to synchronize (But it is dangerous) ! Maybe there are some other ways.

 

Thanks

Outcomes