For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /max/get-started.md).
Mojo function
shmem_calloc
shmem_calloc[dtype: DType](count: Int, size: Int = Int[Int](size_of[dtype]())) -> UnsafePointer[Scalar[dtype], MutExternalOrigin]
Collectively allocate a zeroed block of symmetric memory.
The shmem_calloc routine is a collective operation on the world team that
allocates a region of remotely accessible memory for an array of count
objects of size bytes each and returns a pointer to the lowest byte
address of the allocated symmetric memory. The space is initialized to all
bits zero. If the allocation succeeds, the pointer returned shall be
suitably aligned so that it may be assigned to a pointer to any type of
object. If the allocation does not succeed, or either count or size is 0,
the return value is a null pointer. The values for count and size shall each
be equal across all PEs calling shmem_calloc; otherwise, the behavior is
undefined. When count or size is 0, the shmem_calloc routine returns
without performing a barrier. Otherwise, this routine calls a procedure that
is semantically equivalent to shmem_barrier_all on exit.
Note: on ROCSHMEM this will raise an error if exceeding the default static symmetric heap size of 1GB across all GPUs, while NVSHMEM uses dynamic symmetric heap allocation and won't error.
Parameters:
- โdtype (
DType): The data type of elements to allocate memory for.
Args:
- โcount (
Int): The number of elements to allocate. - โsize (
Int): The size in bytes of each element (defaults to size_ofdtype).
Returns:
UnsafePointer[Scalar[dtype], MutExternalOrigin]: A pointer to the lowest byte address of the allocated space; otherwise, it
returns a null pointer.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!