jax.experimental.pallas.mosaic_gpu.alloc_semaphore#
- jax.experimental.pallas.mosaic_gpu.alloc_semaphore(shape=())[source]#
Returns a zero-initialized GMEM semaphore Ref.
This function can only be used outside of a kernel; for semaphores scoped to a single kernel, use
scratch_typesinstead. It is the only way to create semaphores that outlive a single kernel invocation. It performs no cross-device synchronization: the caller is responsible for the initial sync, e.g. by running a kernel that is data dependent on the returned refs withskip_device_barrier=False.Example:
sem = plgpu.alloc_semaphore((num_devices,)) # The first kernel consuming ``sem`` must not skip the device barrier, so # that all devices observe the zero-initialized semaphores before use. out = plgpu.kernel(body, out_type=out_type, grid=grid, grid_names=names)( sem, x )