• Advertisement
Sign in to follow this  

Parallel programming question.

This topic is 1796 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello,

 

My question is related to OpenCL but I guess it could be applied to any parallel API (Cuda, MPI, pThread...)

 

I have a kernel that's executed thousands of times and each parallel kernel holds a reference to a single memory space called "__global char *comp". Prior to executing the kernels, the Host initializes this "comp" memory space to "true" and, during execution, kernels only acess "comp" if it needs to assign it's value to "false".

 

Do I have to worry about memory access synchronization in this particular case? I'm thinking it wouldn't matter if two kernels acessed the memory space concurrently as the only possible outcome would be for it to have a "false" value assigned.

Share this post


Link to post
Share on other sites
Advertisement

I think someone will check the value whether it is true or false. If it is done in a loop and it has no harm to  check it a cycle later it is seems to me ok to not do any synchronization.

Share this post


Link to post
Share on other sites
If you don't need it to be immediately synced between processes the multiple readers is fine with a single writer.

Just mark the readers as const global and it should all work well in OpenCL.

Share this post


Link to post
Share on other sites

If you don't need it to be immediately synced between processes the multiple readers is fine with a single writer.

Just mark the readers as const global and it should all work well in OpenCL.

 

Ok, I understand now.

 

Actually I wanted processes to have write access to memory space but I realised data can end up being corrupted even in this case if there's no synchronization.

 

Thanks for the help, Frob, Tribad!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement