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

KonstantinSource codes8c4603c

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