Skip to content

Commit a3ac363

Browse files
author
Ryan Lai
authored
Removed DXCore from WInMLRunner (#179)
1 parent 3db448f commit a3ac363

File tree

11 files changed

+41
-221
lines changed

11 files changed

+41
-221
lines changed

Testing/WinMLRunnerTest/WinMLRunnerTest.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<ProjectGuid>{E9D4AC92-8295-4FB4-BF7D-3FAF74B564E8}</ProjectGuid>
2424
<Keyword>Win32Proj</Keyword>
2525
<RootNamespace>WinMLRunnerTest</RootNamespace>
26-
<WindowsTargetPlatformVersion>10.0.18323.0</WindowsTargetPlatformVersion>
26+
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
2727
<ProjectSubType>NativeUnitTestProject</ProjectSubType>
2828
</PropertyGroup>
2929
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />

Tools/WinMLRunner/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ You can either download the x64 executable or build it yourself.
1616
#### Prerequisites
1717
- [Visual Studio 2017 Version 15.7.4 or Newer](https://developer.microsoft.com/en-us/windows/downloads)
1818
- [Windows 10 - Build 17763 or higher](https://www.microsoft.com/en-us/software-download/windowsinsiderpreviewiso)
19-
- [Windows SDK - Build 18323 or higher](https://www.microsoft.com/en-us/software-download/windowsinsiderpreviewSDK)
19+
- [Windows SDK - Build 17763 or higher](https://www.microsoft.com/en-us/software-download/windowsinsiderpreviewSDK)
2020

2121
The easiest way to use these samples without using Git is to download the zip file containing the current version (using the following link or by clicking the "Download ZIP" button on the repo page). You can then unzip the entire archive and use the samples in Visual Studio 2017. Notes: Before you unzip the archive, right-click it, select Properties, and then select Unblock.
2222
Be sure to unzip the entire archive, and not just individual samples. The samples all depend on the SharedContent folder in the archive. In Visual Studio 2017, the platform target defaults to ARM, so be sure to change that to x64 or x86 if you want to test on a non-ARM device. Reminder: If you unzip individual samples, they will not build due to references to other portions of the ZIP file that were not unzipped.
@@ -37,7 +37,6 @@ Required command-Line arguments:
3737
-GPU : Will create a session on the GPU.
3838
-GPUHighPerformance : Will create a session with the most powerful GPU device available.
3939
-GPUMinPower : Will create a session with GPU with the least power.
40-
-GPUAdapterIndex : run model on GPU specified by its index in DXGI enumeration. NOTE: Please only use this flag on DXCore supported machines.
4140
-CreateDeviceOnClient : Will create the device on the client and explicitly pass it to WinML via the API. GPU runs using this flag will usually be faster than -CreateDeviceInWinML since we avoid a cross-device copy by creating the video frame on the same device that DML uses to bind inputs.
4241
-CreateDeviceInWinML : Will create the device inside WinML. GPU runs using this flag will usually be slower than -CreateDeviceOnClient since we have to copy the video frame to a different device.
4342
-CPUBoundInput : Will bind the input to the CPU.

Tools/WinMLRunner/WinMLRunner.vcxproj

Lines changed: 16 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
<ProjectGuid>{31653A2F-02CC-4A95-9880-BF86965FB262}</ProjectGuid>
4949
<Keyword>Win32Proj</Keyword>
5050
<RootNamespace>WinMLRunner</RootNamespace>
51-
<WindowsTargetPlatformVersion>10.0.18323.0</WindowsTargetPlatformVersion>
51+
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
5252
<WindowsSDKDesktopARM64Support>true</WindowsSDKDesktopARM64Support>
5353
</PropertyGroup>
5454
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
@@ -77,7 +77,6 @@
7777
<PlatformToolset>v141</PlatformToolset>
7878
<WholeProgramOptimization>true</WholeProgramOptimization>
7979
<CharacterSet>Unicode</CharacterSet>
80-
<WindowsAppContainer>false</WindowsAppContainer>
8180
</PropertyGroup>
8281
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
8382
<ConfigurationType>Application</ConfigurationType>
@@ -148,7 +147,6 @@
148147
<WarningLevel>Level3</WarningLevel>
149148
<Optimization>Disabled</Optimization>
150149
<SDLCheck>true</SDLCheck>
151-
<ShowIncludes>true</ShowIncludes>
152150
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
153151
<ConformanceMode>true</ConformanceMode>
154152
<PrecompiledHeaderFile>
@@ -159,14 +157,8 @@
159157
</ClCompile>
160158
<Link>
161159
<SubSystem>Console</SubSystem>
162-
<AdditionalDependencies>mincore.lib;windowsapp.lib;d3d12.lib;dxgi.lib;d3d11.lib;onecore.lib</AdditionalDependencies>
163-
<AdditionalOptions>
164-
</AdditionalOptions>
165-
<DelayLoadDLLs>dxgi.dll;d3d11.dll; ext-ms-win-dxcore-l1-1-0.dll</DelayLoadDLLs>
166-
<IgnoreAllDefaultLibraries>
167-
</IgnoreAllDefaultLibraries>
168-
<IgnoreSpecificDefaultLibraries>kernel32.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
169-
<GenerateDebugInformation>DebugFull</GenerateDebugInformation>
160+
<GenerateDebugInformation>true</GenerateDebugInformation>
161+
<AdditionalDependencies>WindowsApp.lib; mincore.lib; DXGI.lib</AdditionalDependencies>
170162
</Link>
171163
<PreBuildEvent>
172164
<Command>$(ProjectDir)src\GenerateVersionStrings.cmd $(ProjectDir) $(IntDir)</Command>
@@ -187,18 +179,11 @@
187179
</PrecompiledHeaderFile>
188180
<PrecompiledHeaderOutputFile />
189181
<LanguageStandard>stdcpp17</LanguageStandard>
190-
<ConformanceMode>true</ConformanceMode>
191182
</ClCompile>
192183
<Link>
193184
<SubSystem>Console</SubSystem>
194-
<AdditionalDependencies>mincore.lib;windowsapp.lib;d3d12.lib;dxgi.lib;d3d11.lib;onecore.lib</AdditionalDependencies>
195-
<AdditionalOptions>
196-
</AdditionalOptions>
197-
<DelayLoadDLLs>dxgi.dll;d3d11.dll; ext-ms-win-dxcore-l1-1-0.dll</DelayLoadDLLs>
198-
<IgnoreAllDefaultLibraries>
199-
</IgnoreAllDefaultLibraries>
200-
<IgnoreSpecificDefaultLibraries>kernel32.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
201-
<GenerateDebugInformation>DebugFull</GenerateDebugInformation>
185+
<GenerateDebugInformation>true</GenerateDebugInformation>
186+
<AdditionalDependencies>WindowsApp.lib; mincore.lib; DXGI.lib</AdditionalDependencies>
202187
</Link>
203188
<ResourceCompile>
204189
<AdditionalIncludeDirectories>$(IntDir)</AdditionalIncludeDirectories>
@@ -223,14 +208,8 @@
223208
</ClCompile>
224209
<Link>
225210
<SubSystem>Console</SubSystem>
226-
<AdditionalDependencies>mincore.lib;windowsapp.lib;d3d12.lib;dxgi.lib;d3d11.lib;onecore.lib</AdditionalDependencies>
227-
<AdditionalOptions>
228-
</AdditionalOptions>
229-
<DelayLoadDLLs>dxgi.dll;d3d11.dll; ext-ms-win-dxcore-l1-1-0.dll</DelayLoadDLLs>
230-
<IgnoreAllDefaultLibraries>
231-
</IgnoreAllDefaultLibraries>
232-
<IgnoreSpecificDefaultLibraries>kernel32.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
233-
<GenerateDebugInformation>DebugFull</GenerateDebugInformation>
211+
<GenerateDebugInformation>true</GenerateDebugInformation>
212+
<AdditionalDependencies>WindowsApp.lib; mincore.lib; DXGI.lib</AdditionalDependencies>
234213
</Link>
235214
<ResourceCompile>
236215
<AdditionalIncludeDirectories>$(IntDir)</AdditionalIncludeDirectories>
@@ -247,7 +226,6 @@
247226
<FunctionLevelLinking>true</FunctionLevelLinking>
248227
<IntrinsicFunctions>true</IntrinsicFunctions>
249228
<SDLCheck>true</SDLCheck>
250-
<ShowIncludes>true</ShowIncludes>
251229
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
252230
<ConformanceMode>true</ConformanceMode>
253231
<PrecompiledHeaderFile>
@@ -257,16 +235,11 @@
257235
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
258236
</ClCompile>
259237
<Link>
238+
<SubSystem>Console</SubSystem>
260239
<EnableCOMDATFolding>true</EnableCOMDATFolding>
261240
<OptimizeReferences>true</OptimizeReferences>
262-
<SubSystem>Console</SubSystem>
263-
<AdditionalDependencies>mincore.lib;windowsapp.lib;d3d12.lib;dxgi.lib;d3d11.lib;onecore.lib</AdditionalDependencies>
264-
<AdditionalOptions>
265-
</AdditionalOptions>
266-
<DelayLoadDLLs>dxgi.dll;d3d11.dll; ext-ms-win-dxcore-l1-1-0.dll</DelayLoadDLLs>
267-
<IgnoreAllDefaultLibraries>
268-
</IgnoreAllDefaultLibraries>
269-
<IgnoreSpecificDefaultLibraries>kernel32.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
241+
<GenerateDebugInformation>true</GenerateDebugInformation>
242+
<AdditionalDependencies>WindowsApp.lib; mincore.lib; DXGI.lib</AdditionalDependencies>
270243
</Link>
271244
<ResourceCompile>
272245
<AdditionalIncludeDirectories>$(IntDir)</AdditionalIncludeDirectories>
@@ -293,16 +266,11 @@
293266
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
294267
</ClCompile>
295268
<Link>
269+
<SubSystem>Console</SubSystem>
296270
<EnableCOMDATFolding>true</EnableCOMDATFolding>
297271
<OptimizeReferences>true</OptimizeReferences>
298-
<SubSystem>Console</SubSystem>
299-
<AdditionalDependencies>mincore.lib;windowsapp.lib;d3d12.lib;dxgi.lib;d3d11.lib;onecore.lib</AdditionalDependencies>
300-
<AdditionalOptions>
301-
</AdditionalOptions>
302-
<DelayLoadDLLs>dxgi.dll;d3d11.dll; ext-ms-win-dxcore-l1-1-0.dll</DelayLoadDLLs>
303-
<IgnoreAllDefaultLibraries>
304-
</IgnoreAllDefaultLibraries>
305-
<IgnoreSpecificDefaultLibraries>kernel32.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
272+
<GenerateDebugInformation>true</GenerateDebugInformation>
273+
<AdditionalDependencies>WindowsApp.lib; mincore.lib; DXGI.lib</AdditionalDependencies>
306274
</Link>
307275
<ResourceCompile>
308276
<AdditionalIncludeDirectories>$(IntDir)</AdditionalIncludeDirectories>
@@ -329,16 +297,11 @@
329297
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
330298
</ClCompile>
331299
<Link>
300+
<SubSystem>Console</SubSystem>
332301
<EnableCOMDATFolding>true</EnableCOMDATFolding>
333302
<OptimizeReferences>true</OptimizeReferences>
334-
<SubSystem>Console</SubSystem>
335-
<AdditionalDependencies>mincore.lib;windowsapp.lib;d3d12.lib;dxgi.lib;d3d11.lib;onecore.lib</AdditionalDependencies>
336-
<AdditionalOptions>
337-
</AdditionalOptions>
338-
<DelayLoadDLLs>dxgi.dll;d3d11.dll; ext-ms-win-dxcore-l1-1-0.dll</DelayLoadDLLs>
339-
<IgnoreAllDefaultLibraries>
340-
</IgnoreAllDefaultLibraries>
341-
<IgnoreSpecificDefaultLibraries>kernel32.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
303+
<GenerateDebugInformation>true</GenerateDebugInformation>
304+
<AdditionalDependencies>WindowsApp.lib; mincore.lib; DXGI.lib</AdditionalDependencies>
342305
</Link>
343306
<PreBuildEvent>
344307
<Command>$(ProjectDir)src\GenerateVersionStrings.cmd $(ProjectDir) $(IntDir)</Command>

Tools/WinMLRunner/WinMLRunnerScenarios.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
<ProjectGuid>{C174D45D-C189-475B-B1A7-494939EE7491}</ProjectGuid>
3232
<Keyword>Win32Proj</Keyword>
3333
<RootNamespace>WinMLRunnerScenarios</RootNamespace>
34-
<WindowsTargetPlatformVersion>10.0.18323.0</WindowsTargetPlatformVersion>
34+
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
3535
</PropertyGroup>
3636
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
3737
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">

Tools/WinMLRunner/WinMLRunnerStaticLib.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
<ProjectGuid>{C3BCBEA1-90E6-426F-88AC-64C274BCEF45}</ProjectGuid>
4949
<Keyword>Win32Proj</Keyword>
5050
<RootNamespace>WinMLRunnerStaticLib</RootNamespace>
51-
<WindowsTargetPlatformVersion>10.0.18323.0</WindowsTargetPlatformVersion>
51+
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
5252
<WindowsSDKDesktopARM64Support>true</WindowsSDKDesktopARM64Support>
5353
</PropertyGroup>
5454
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />

Tools/WinMLRunner/src/CommandLineArgs.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#include <string>
33
#include <iostream>
44
#include "CommandLineArgs.h"
5-
#include <apiquery2.h>
65
#include <ctime>
76
#include <iomanip>
87

@@ -19,7 +18,6 @@ void CommandLineArgs::PrintUsage() {
1918
std::cout << " -GPU : run model on default GPU" << std::endl;
2019
std::cout << " -GPUHighPerformance : run model on GPU with highest performance" << std::endl;
2120
std::cout << " -GPUMinPower : run model on GPU with the least power" << std::endl;
22-
std::cout << " -GPUAdapterIndex : run model on GPU specified by its index in DXGI enumeration. NOTE: Please only use this flag on DXCore supported machines." << std::endl;
2321
std::cout << " -CreateDeviceOnClient : create the device on the client and pass it to WinML" << std::endl;
2422
std::cout << " -CreateDeviceInWinML : create the device inside WinML" << std::endl;
2523
std::cout << " -CPUBoundInput : bind the input to the CPU" << std::endl;
@@ -73,18 +71,6 @@ CommandLineArgs::CommandLineArgs(const std::vector<std::wstring> &args)
7371
{
7472
m_useGPUMinPower = true;
7573
}
76-
else if ((_wcsicmp(args[i].c_str(), L"-GPUAdapterIndex") == 0) && i + 1 < args.size() && args[i + 1][0] != L'-')
77-
{
78-
CheckNextArgument(args, i);
79-
HMODULE library{ nullptr };
80-
library = LoadLibrary(L"ext-ms-win-dxcore-l1-1-0");
81-
if (!library)
82-
{
83-
throw hresult_invalid_argument(L"ERROR: DXCORE isn't supported on this machine. GpuAdapterIndex flag should only be used with DXCore supported machines.");
84-
}
85-
m_useGPU = true;
86-
m_adapterIndex = static_cast<UINT>(_wtoi(args[++i].c_str()));
87-
}
8874
else if ((_wcsicmp(args[i].c_str(), L"-CreateDeviceOnClient") == 0))
8975
{
9076
m_createDeviceOnClient = true;

Tools/WinMLRunner/src/CommandLineArgs.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ class CommandLineArgs
3030
const std::wstring& FolderPath() const { return m_modelFolderPath; }
3131
const std::wstring& ModelPath() const { return m_modelPath; }
3232
const std::wstring& TensorOutputPath() const { return m_tensorOutputPath; }
33-
UINT GetGPUAdapterIndex() const { return m_adapterIndex; }
3433

3534
bool UseRGB() const
3635
{
@@ -135,7 +134,6 @@ class CommandLineArgs
135134
bool m_autoScale = false;
136135
bool m_perfOutput = false;
137136
BitmapInterpolationMode m_autoScaleInterpMode = BitmapInterpolationMode::Cubic;
138-
UINT m_adapterIndex = -1;
139137
bool m_saveTensor = false;
140138
std::string m_saveTensorMode = "First";
141139

Tools/WinMLRunner/src/Common.h

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
#ifndef _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS
33
#define _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS
44
#endif
5-
#include <vcruntime.h>
6-
#include <windows.h>
75
// unknown.h needs to be inlcuded before any winrt headers
86
#include <unknwn.h>
97
#include <winrt/Windows.AI.MachineLearning.h>
@@ -22,9 +20,7 @@
2220
#include <numeric>
2321
#include <cassert>
2422
#include <fstream>
25-
#include <Windows.AI.MachineLearning.Native.h>
2623
#include <dxgi1_6.h>
27-
#include <d3d12.h>
2824
#include "TypeHelper.h"
2925
#include "TimerHelper.h"
3026
#include "DirectXPackedVector.h"
@@ -85,16 +81,4 @@ inline void ThrowIfFailed(HRESULT hr, const std::wstring &errorMsg = L"")
8581
inline void ThrowFailure(const std::wstring &errorMsg)
8682
{
8783
throw errorMsg;
88-
}
89-
90-
//
91-
// Delay load exception information
92-
//
93-
#ifndef FACILITY_VISUALCPP
94-
#define FACILITY_VISUALCPP ((LONG)0x6d)
95-
#endif
96-
97-
#define VcppException(sev,err) ((sev) | (FACILITY_VISUALCPP<<16) | err)
98-
99-
HRESULT CreateDXGIFactory2SEH(void **pIDXGIFactory);
100-
84+
}

Tools/WinMLRunner/src/OutputHelper.h

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -135,36 +135,29 @@ class OutputHelper
135135
void PrintHardwareInfo() const
136136
{
137137
std::cout << "WinML Runner" << std::endl;
138-
139-
com_ptr<IDXGIFactory4> factory;
140-
HRESULT hr;
141-
142-
try
143-
{
144-
hr = CreateDXGIFactory2SEH(factory.put_void());
145-
}
146-
catch (...)
147-
{
148-
hr = E_FAIL;
149-
}
150-
if (hr != S_OK)
151-
{
152-
return;
153-
}
154-
155-
//Print All Adapters
156-
com_ptr<IDXGIAdapter> adapter;
157-
for (UINT i = 0; ; ++i)
158-
{
138+
std::cout << "Printing available GPUs with DXGI.." << std::endl;
139+
com_ptr<IDXGIFactory6> factory;
140+
CreateDXGIFactory1(__uuidof(IDXGIFactory6), factory.put_void());
141+
std::vector <com_ptr<IDXGIAdapter1>> validAdapters;
142+
for (UINT i = 0; ; ++i) {
159143
com_ptr<IDXGIAdapter1> spAdapter;
160-
if (factory->EnumAdapters1(i, spAdapter.put()) != S_OK)
161-
{
144+
if (factory->EnumAdapters1(i, spAdapter.put()) != S_OK) {
162145
break;
163146
}
164147
DXGI_ADAPTER_DESC1 pDesc;
165148
spAdapter->GetDesc1(&pDesc);
166-
printf("Index: %d, Description: %ls\n", i, pDesc.Description);
149+
150+
// is a software adapter
151+
if (pDesc.Flags == DXGI_ADAPTER_FLAG_SOFTWARE || (pDesc.VendorId == 0x1414 && pDesc.DeviceId == 0x8c)) {
152+
continue;
153+
}
154+
// valid GPU adapter
155+
else {
156+
printf("Index: %d, Description: %ls\n", static_cast<int>(validAdapters.size()), pDesc.Description);
157+
validAdapters.push_back(spAdapter);
158+
}
167159
}
160+
std::cout << std::endl;
168161
}
169162

170163
void PrintLearningModelDevice(DeviceType deviceType, const LearningModelDevice& device)

0 commit comments

Comments
 (0)