MCPcopy Create free account
hub / github.com/apache/tvm / recycleReadStagingBuffer

Method recycleReadStagingBuffer

web/src/webgpu.ts:987–1000  ·  view source on GitHub ↗

* Return a MAP_READ staging buffer to the pool for reuse. * Evicts the smallest buffer if the pool is full.

(buf: GPUBuffer)

Source from the content-addressed store, hash-verified

985 * Evicts the smallest buffer if the pool is full.
986 */
987 private recycleReadStagingBuffer(buf: GPUBuffer): void {
988 buf.unmap();
989 if (this.readStagingBufferPool.length >= this.maxReadStagingBuffers) {
990 // Evict smallest buffer to make room
991 let minIdx = 0;
992 for (let i = 1; i < this.readStagingBufferPool.length; i++) {
993 if (this.readStagingBufferPool[i].size < this.readStagingBufferPool[minIdx].size) {
994 minIdx = i;
995 }
996 }
997 this.readStagingBufferPool.splice(minIdx, 1)[0].buffer.destroy();
998 }
999 this.readStagingBufferPool.push({ buffer: buf, size: buf.size });
1000 }
1001
1002 private deviceCopyFromGPU(
1003 from: GPUPointer,

Callers 1

deviceCopyFromGPUMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected