Mojo function
threadfence
threadfence[scope: Scope = Scope(5)]()
Enforces ordering of memory operations across threads.
This function acts as a memory fence/barrier that ensures all memory operations (both loads and stores) issued before the fence are visible to other threads within the specified scope before any memory operations after the fence.
Note:
- Maps directly to CUDA __threadfence()
family of functions.
- Critical for synchronizing memory access in parallel algorithms.
- Performance impact increases with broader scopes.
Parameters:
- scope (
Scope
): The memory scope level for the fence operation. Defaults to GPU-wide scope. Valid values are: - Scope.BLOCK: Orders memory within a thread block/CTA. - Scope.GPU: Orders memory across all threads on the GPU (default). - Scope.SYSTEM: Orders memory across the entire system.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!