How can i create or use a critical section in OpenCL?


Already exist a critical section sentence in OpenCL?
If there is not, how can i create a critical section in OpenCL?

Very Thanks,

Luiz Drumond.

There is no builtin function to create a critical section. Notice that by definition a critical section runs sequentially and will hurt performance a lot.

You can use the atomic functions (if your platform/device supports the extension) to implement a critical section (look at wikipedias critical section page, you can use atomic instructions to create a mutex).

But, as David mentioned, it will really hurt performance. Some algorithms have no alternative, but make sure it’s your last resort.