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#include "stdafx.h" 2#include "LargeBuffer.h" 3using namespace CpuCompute ; 4 5void LargeBuffer ::deallocate () 6{ 7if (nullptr == pv ) 8return ; 9VirtualFree (pv ,0 ,MEM_RELEASE ); 10pv = nullptr ; 11} 12 13HRESULT LargeBuffer ::allocate (size_t cb ) 14{ 15deallocate (); 16 17pv = VirtualAlloc (nullptr ,cb ,MEM_COMMIT |MEM_RESERVE ,PAGE_READWRITE ); 18if (nullptr != pv ) 19return S_OK ; 20return HRESULT_FROM_WIN32 (GetLastError () ); 21} 22 23HRESULT LargeBuffer ::setReadOnly (size_t cb ) 24{ 25if (nullptr != pv ) 26 { 27DWORD op = 0 ; 28if (VirtualProtect (pv ,cb ,PAGE_READONLY ,& op ) ) 29return S_OK ; 30return HRESULT_FROM_WIN32 (GetLastError () ); 31 } 32else 33return OLE_E_BLANK ; 34}