Using Intel Threading Building Blocks in Universal Windows Platform applications

Using Intel Threading Building Blocks in Universal Windows Platform applications

The Intel® Threading Building Blocks (Intel® TBB) library provides a set of algorithms to enable parallelism in C++ applications. It is highly portable and supports multiple platforms, including the full spectrum of Windows* devices based on Intel® architecture.

The Intel TBB 2018 release added support for the Universal Windows Platform (UWP) – an application platform for the Windows 10 ecosystem that allows developers to create and run apps on all kinds of Windows devices – PC, Tablet, Phone, Xbox*, HoloLens*, Surface Hub*, and even IoT.

The wide reach of UWP has its consequences: there are restrictions against API that can violate the security of the platform. Microsoft’s Visual C++* compiler has the /ZW option that can be used to detect such API calls; however, to make sure your app is fully UWP-compliant, you have to check the whole package with the Windows App Certification Kit.

Getting Started with Developing UWP Applications Using Intel® Threading Building Blocks

The tutorials Windows* 8 Tutorial: Writing a Multithreaded Application for the Windows Store* using Intel® Threading Building Blocks and Windows* 8 OS Tutorial: Writing a Multithreaded Application for the Windows Store* using Intel® Threading Building Blocks – now with DLLs are fully applicable to UWP application development with just a couple of small changes:

  • You have to use the Blank App (Universal Windows) Microsoft Visual Studio* 2015/2017 template instead of Blank App (Windows Store).
  • Prebuilt UWP-compliant binaries of the Intel TBB library are available as part of our commercial and open-source distributions. You can find them in the following locations:
  • In the open-source distribution: <distribution_root>\lib\<target_architecture>\vc14_uwp
  • In the commercial distribution: <suite_install_dir>\compilers_and_libraries_<version>\windows\tbb\lib\<target_architecture>\vc14_uwp, where <suite_install_dir> is the installation directory of the software suite Intel TBB came with (by default, C:\Program Files (x86)\IntelSWTools\)

Note that the Universal Windows Driver platform is also supported. You can find the binaries for it in the folder vc14_uwd available in the commercial distribution of Intel TBB. Also, binaries for the Windows Runtime (WinRT) are still available in the folder vc12_ui.

If you prefer to build the binaries from source, see the section Build Intel® Threading Building Blocks from Source.

The steps to package Intel TBB inside a UWP app are largely the same as for Windows 8 applications:

1. In your Microsoft Visual Studio Project Properties > Linker options, set Additional Dependencies to tbb.dll and Additional Library Directories to the Intel TBB folder with the binaries.

2. Right-click your project root and select Add > Existing item…. Select the tbb.dll file to add it to your UWP project dependencies.

3. Right-click tbb.dll in your project tree and select Properties. Set Content to True to mark the file as content. This will include the Intel TBB library inside your UWP app package.

4. Right-click your project root and select Store > Create App Packages… to create a Windows Store Application package.

Finally, the last step is to launch Windows App Certification Kit and check that application successfully passes validation. The main thing to watch out for is the Supported API test, which checks that your application calls no restricted Windows Store* API:

Congratulations, you’re done! Your Universal Windows Platform application can use Intel TBB and benefit from parallelism on the wide range of Windows devices based on Intel architecture.

Build Intel® Threading Building Blocks from Source

Universal Windows Platform Binary

To build UWP-compliant Intel TBB from source, you have to install:

1. GNU* Make

2. Microsoft Visual Studio 2015/2017

3. Windows 10 SDK

To prepare the environment:

1. Launch the Microsoft Visual Studio developer command prompt

2. From within the developer command prompt, locate the script vcvarsall.bat in your Microsoft Visual Studio installation and launch it with the options vcvarsall.bat <arch> store, where <arch>is the target architecture. This step configures the environment for linking to UWP libraries.

From the same developer command prompt, run the following:

gmake tbb tbbmalloc target_app=uwp target_mode=store

Let’s take a look at the options:

  • target_app=uwp configures Intel TBB to link to OneCore.lib and to use only the set of APIs that is allowed for a Universal Windows Platform application.
  • target_mode=store makes sure that tbb.dll is configured to be run in an app container (a requirement for Windows Store UWP packages).

Universal Windows Driver Binary

To build UWD-compatible binaries, you have to install the same set of software as for UWP-compliant Intel TBB plus the Windows Driver Kit.

Launch the Microsoft Visual Studio developer command prompt. You don't have to launch vcvarsall.bat with the store argument for UWD binaries. From the command prompt, run the following:

gmake tbb tbbmalloc target_app=uwd

  • The target_mode option is not required because a Universal Windows Driver does not need to be run in the restricted UWP application environment.
  • target_app=uwd configures Intel TBB to link to OneCore.lib dynamically and to the C Run-Time Libraries (CRT) statically. Linking to the CRT is necessary for Universal Windows Drivers.

For more such intel IoT resources and tools from Intel, please visit the Intel® Developer Zone

Source: https://software.intel.com/en-us/blogs/2017/11/27/using-intel-threading-building-blocks-in-universal-windows-platform-applications

Promotion
Digit.in
Logo
Digit.in
Logo