IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /get-started.md).

Mojo module

semaphore

This module provides a device-wide semaphore implementation for NVIDIA GPUs.

The Semaphore struct enables inter-CTA (Cooperative Thread Array) synchronization by providing atomic operations and memory barriers. It uses NVIDIA-specific intrinsics to implement efficient thread synchronization.

Examples:

```mojo
from max.gpu.sync import Semaphore

def semaphore(lock: Pointer[mut=True, Int32, ...]):
    var thread_id = 0
    var sem = Semaphore(lock, thread_id)

    # Wait for a specific state
    sem.wait(0)

    # Release the semaphore
    sem.release(1)
```

Structsโ€‹