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

KonstantinOptional startup flags to override performance-related defaults for the compute shaders11c399b

master
1.7 KiB68 linesraw
1#pragma once
2#include <atlcomcli.h>
3#include <string>
4
5namespace DirectCompute
6{
7	ID3D11Device* device();
8	ID3D11DeviceContext* context();
9	D3D_FEATURE_LEVEL featureLevel();
10
11	HRESULT initialize( uint32_t flags );
12	void terminate();
13
14	// DXGI_ADAPTER_DESC.VendorId magic numbers; they come from that database: https://pcisig.com/membership/member-companies
15	enum struct eGpuVendor : uint16_t
16	{
17		AMD = 0x1002,
18		NVidia = 0x10de,
19		Intel = 0x8086,
20		VMWare = 0x15ad,
21	};
22
23	enum struct eGpuEffectiveFlags : uint8_t
24	{
25		Wave64 = 1,
26		ReshapedMatMul = 2,
27	};
28
29	struct sGpuInfo
30	{
31		eGpuEffectiveFlags flags;
32		eGpuVendor vendor;
33		uint16_t device, revision;
34		uint32_t subsystem;
35		size_t vramDedicated, ramDedicated, ramShared;
36		std::wstring description;
37
38		inline bool wave64() const
39		{
40			return 0 != ( (uint8_t)flags & (uint8_t)eGpuEffectiveFlags::Wave64 );
41		}
42
43		// On nVidia 1080Ti that approach is much slower, by a factor of 2.4
44		// On AMD Cezanne that approach is faster by a factor of 0.69, i.e. 30% faster.
45		// Dunno why that is, maybe 'coz on that AMD complete panels fit in L3 cache.
46		// Anyway, we do want extra 30% perf on AMD Cezanne, so only using that code on AMD GPUs.
47		// Dunno how it gonna behave on other GPUs, need to test.
48		inline bool useReshapedMatMul() const
49		{
50			return 0 != ( (uint8_t)flags & (uint8_t)eGpuEffectiveFlags::ReshapedMatMul );
51		}
52	};
53	extern const sGpuInfo& gpuInfo;
54
55	inline bool available()
56	{
57		return nullptr != device();
58	}
59
60	inline void csSetCB( ID3D11Buffer* cb )
61	{
62		context()->CSSetConstantBuffers( 0, 1, &cb );
63	}
64
65	__m128i bufferMemoryUsage( ID3D11Buffer* buffer );
66
67	__m128i resourceMemoryUsage( ID3D11ShaderResourceView* srv );
68}