yum-archive/TaSTT-Whisper
High-performance GPGPU inference of OpenAI's Whisper automatic speech recognition (ASR) model
git clone https://git.yummers.dev/yum-archive/TaSTT-Whisper
8c4603c
master
1#pragma once 2 3namespace CpuCompute 4{ 5// A large memory buffer allocated with VirtualAlloc kernel API, bypassing the heap. 6class LargeBuffer 7 { 8void * pv = nullptr ; 9public : 10LargeBuffer ()= default ; 11LargeBuffer (const LargeBuffer & )= delete ; 12LargeBuffer (LargeBuffer && that )noexcept 13 { 14pv = that .pv ; 15that .pv = nullptr ; 16 } 17 ~LargeBuffer () 18 { 19deallocate (); 20 } 21void operator = (LargeBuffer && that )noexcept 22 { 23std ::swap (pv ,that .pv ); 24 } 25void operator = (const LargeBuffer & that )= delete ; 26 27// Allocate buffer with specified count of bytes, and read+write memory protection 28// The OS kernel guarantees zero-initialization of that memory. 29HRESULT allocate (size_t cb ); 30 31// Change memory protection of the buffer to read only 32HRESULT setReadOnly (size_t cb ); 33 34// Unless the pointer is nullptr, deallocate the buffer 35void deallocate (); 36 37// Pointer to the start of the buffer, aligned by memory page = 4 kilobytes 38uint8_t * pointer ()const 39 { 40assert (nullptr != pv ); 41return (uint8_t * )pv ; 42 } 43 }; 44}