Sign in to follow this  
tmarques4

Parallel programming question.

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this