Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does vulkan pipeline memory barrier eases the sync constraint in relation to pipeline barrier with no memory barrier?

From the spec related to vkCmdPipelineBarrier:

If no memory barriers are specified, then the first access scope includes no accesses.

This is noted for both, the first and second access scopes, so if I understand correctly:

(1) A pipeline barrier without a memory barrier causes all subsequent commands to wait in destination stage until all commands before finish the source stage. This is a hard constraint which applies to all commands.

(2) A pipeline barrier with memory barrier eases the sync constraint so only subsequent commands that deal with that memory are wait in destination stage (at the relevant access action) until only preceding commands that deal with that memory finish the source stage (at the relevant access action).

Is it correct?

like image 647
audi02 Avatar asked Sep 11 '25 04:09

audi02


1 Answers

(1)
Yes, except for a liberal application of the as-if principle. If you cannot find the difference purely by output, then the driver would be allowed to violate it (e.g. if the only difference was performance).

It applies to all commands, if they are action commands, are the same queue, do actually process something in such stage, and blah blah....

The specification calls this execution dependency.

(2)
This is called memory dependency. It is a superset of the execution dependency. It does not weaken it. It makes it more strict. It means that in addition to (1), all side effects (caches) defined by the memory dependency parameters have to be flushed\invalidated (or whatever the particual device architecture needs to do, and whatever is the specific nomenclature for it).

PS: I am not 110 % sure about VK_KHR_synchronization2 though. There was some attempt to "dumb-down" synchronization, but doing that some of the intuition was lost. I think though it is same as if you walked all the memory barrier structures and collected all the stages thogether, and it still works as (1).

like image 83
krOoze Avatar answered Sep 16 '25 00:09

krOoze