Microsoft is bringing OpenCL and OpenGL support to DirectX, for both Windows and Windows Subsystem for Linux, enabling machine learning and data parallel computing in everyday business applications.
There's a lot more to the modern GPU than high-speed, high-resolution graphics. They're powerful compute engines, using their many cores as a way of implementing massively parallel processing algorithms, handling big data analysis and complex numerical computing problems, or supporting machine learning with neural network implementations.
Tasks like these used to need supercomputers -- custom hardware designed to process large amounts of data as quickly as possible. But with GPUs in desktop computers and laptops (and even in modern servers), we can fit what used to need millions of dollars of hardware into much smaller and more affordable devices. While much GPU-based compute has been focused on scientific computing in high-end workstations, a new generation of desktop applications are starting to take advantage of GPU technology to add new features.
SEE: Computer Equipment Disposal policy (TechRepublic Premium)
There are many good reasons for keeping high-performance computing local: dealing with high-latency connections to cloud resources; user privacy; working within local regulatory constraints, for example. With machine learning essential to assistive technologies like voice recognition, or helping power document search and management, there's a growing demand for local GPU-based applications, using a mix of technologies. Simple APIs like Windows' ONNX-based WinML make it easy to handle inferencing in models created using cloud-based training services like those on Azure.
Compute in DirectX
Microsoft's DirectX has already added compute support with its DirectML and DirectCompute features, alongside its C++ AMP extensions. You can use these in your code to connect applications directly to your GPU's compute capabilities. They're low-level technologies that require specific hardware support to work well, although they are significantly faster than using other Windows programming techniques.
DirectX isn't the only set of GPU APIs with compute capabilities, so Windows support for additional GPU technologies is important. The open-source Mesa 3D libraries are a commonly used implementation of the core OpenGL and OpenCL specifications. Mesa 3D is widely used, but until recently graphics hardware vendors needed to ship both DirectX and Mesa 3D drivers, more than doubling the work needed to deliver drivers for Windows. As many cross-platform GPU compute workloads depend on OpenCL, lack of support from many lower-cost GPUs made it hard to port code to Windows.
Bringing Mesa3D to DirectX
Microsoft recently announced that it was working with Collabora to deliver a new Mesa 3D layer on top of DirectX 12. Building on existing translation layers, it's a way of allowing hardware vendors to focus resources on their DirectX drivers, knowing that developers can still use Mesa 3D for OpenCL calls. The new layer gives you access to an OpenCL compiler and runtime that connect directly to DirectX. The result should be near-native speed, with familiar tools that reduce the work needed to port code to Windows.
With OpenCL support soon available for all Windows GPUs, what applications will take advantage of these new features? Adobe has been putting in GPU-accelerated machine learning in applications like Photoshop and Lightroom, while Corel has added AI-powered brushes to its natural material Painter. By opening DirectX's GPU compute to cross-platform APIs like Mesa3D, it's going to be easier for tools like this to deliver the same features across PC, Mac and Linux.
Adding GPU support to WSL 2
It's not only Windows apps that will be able to take advantage of GPU compute on Windows 10. At Build 2020 Microsoft announced that it would be supporting GPU virtualisation in upcoming releases of its Windows Subsystem for Linux (WSL). This ensures that code running in WSL 2 will be able to take advantage of your PC's graphics hardware, allowing you to use the GPUs in modern devices like the Surface Book 3 with technologies like TensorFlow.
Microsoft will be shipping a new Linux kernel driver that maps the Windows display driver to a Linux device, with a direct connection to your PC's GPU. Your Linux code will be able to connect directly to GPU resources, so if Windows isn't using the GPU, a WSL Linux application can use it all. It's an approach that should work well on devices like the Surface Book 3, with both integrated and discrete graphics capabilities.
By making the new Linux driver compatible with the Windows driver, Microsoft can bring DirectX 12 to WSL. You get access to most of its features, apart from displaying pixels on a screen. That shouldn't be too much of an issue, as you'll still be able to use your PC's GPU for compute and for offline rendering. The modules to implement the APIs remain closed source, so you won't be able to modify them.
OpenCL in WSL
This approach allows Microsoft to bring its DirectML APIs to Linux, with support for both inferencing and training. Developers will be able to use familiar open-source machine-learning platforms in WSL to build, test, and train models that can then be exported using technologies like ONNX for use in WinML applications running under Windows. Microsoft will be releasing a build of TensorFlow with DirectML support for hardware-based model training.
Most Linux applications don't use Microsoft APIs, instead working with the Khronos Group's open standard APIs, with OpenCL providing GPU compute capabilities. WSL 2's GPU support will include a version of the popular Mesa library that can access the new GPU virtualisation drivers, allowing familiar Mesa calls to OpenCL to run on Windows PCs. OpenCL is designed to work across different brands of GPUs, so if you want to access Nvidia-specific features, you need to use Nvidia's own CUDA. Microsoft will be including CUDA support in WSL, with a version of libcuda that works with the new GPU drivers.
AMD has recently unveiled drivers that support WSL GPU-acceleration, rolling out an updated preview of its Adrenalin Radeon DirectX 12 drivers. As the updated DirectML adds support for model training as well as inferencing, you can take advantage of the latest high-end GPUs to work with familiar machine learning frameworks in either Windows or a WSL 2-hosted Linux distribution. You can start experimenting with it in the latest Dev channel (what used to be the Fast Ring) Windows 10 builds.
Unifying GPU support in Windows makes a lot of sense. Vendors can reduce support costs, while Microsoft can finally offer a cross-platform GPU solution that simplifies porting code from many different platforms (both for productivity and for gaming) to Windows. With tools like TensorFlow available to Windows, and with the ability to train ML models on workstation PCs, it's going to be interesting to see how machine learning and data parallel computing arrive in our everyday business applications.
- Windows 10: A cheat sheet (TechRepublic)
- What to do if you're still running Windows 7 (free PDF) (TechRepublic)
- Power checklist: Securing Windows Server 2016 (TechRepublic Premium)
- Microsoft delivers first Windows 10 Fast Ring build from its new development branch (ZDNet)
- 6 simple security changes all Windows 10 users need to make (CNET)
- Get more must-read Microsoft tips and news (TechRepublic on Flipboard)