Standard library / gpu
gpu.alloc
Starts allocating GPU memory in the background and returns right away. Await the result before you use it.
func alloc(_ size: Int) -> MemoryParameters
- size
- Int
- Number of elements to allocate
Returns
Memory you await before use
Example
1 2 3 4 5 6 7 8 9
kernel func allocateAndFill(with constant: Float) { // The allocation will begin in the background let mem = gpu.alloc(1024) // do other stuff // If the allocation is not complete, pause here until it is await gpu.fill(await mem, constant) }