Parallel programming question.

Started by
2 comments, last by tmarques4 11 years, 2 months ago

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.

Tiago.MWeb Developer - Aspiring CG Programmer
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.

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.

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!

Tiago.MWeb Developer - Aspiring CG Programmer

This topic is closed to new replies.

Advertisement