Skip to main content
GameDev.net gamedev.net
🔒 Locked

Parallel programming question.

Started by tmarques4 Feb 18, 2013 at 5:34 PM 2 replies 1.1k views
Original Post
tmarques4
tmarques4

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
Tribad
Tribad

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.

frob
frob
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.
tmarques4
tmarques4

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

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.