Sorry, you need to enable JavaScript to visit this website.

C for Metal Development Package

The Intel® C for Metal development package is a software development package for Intel® Graphics Technology. It includes the Intel® C for Metal Compiler, the Intel® C for Metal Runtime, Intel® Media Driver for VAAPI, and reference examples, which can be used to develop applications accelerated by Intel® Graphics Media Accelerator. A typical application contains two kinds of source code, kernel and host. The kernel is written in Intel® C for Media language, compiled to GPU ISA binary by the Intel® C for Metal Compiler, and executed on the GPU. Host manages workloads through the Intel® C for Metal Runtime and user mode media driver.

 

 

 

Intel® C for Metal Development Package

Windows Package

Introduction

The Intel® C for Metal Development Package is a software development package for Intel® Graphics Technology.

License

The Intel C for Metal Development Package is distributed under the MIT license. You may obtain a copy of the License at: https://opensource.org/licenses/MIT

Prerequisites

Windows 7/Windows 8/Windows 10

Microsoft® Visual Studio 2015

Dependencies (Intel Components)

Intel® Graphics Driver for Windows [15.60] (downloaded from www.intel.com)

Intel® C for Metal Runtime (included in Graphics Driver)

Intel® C for Metal Compiler (included in this package)

Install

Install the Intel C for Metal Development Package

Folder structure after installation

<package_root>
            ├── compiler
            │   ├── bin
            │   └── include_llvm
            ├── documents
            │   ├── cmrtlib
            │   └── compiler
            ├── examples
            ├── runtime
            │   ├── include
            │   └── lib
            ├── LICENSE.md
            ├── README.md
            └── setupenv.bat

Details of folder structure

compiler: the compiler binaries and libraries used to build CM language source codes to GPU kernels running on Render engine

compiler/bin: The compiler binaries to build GPU kernels

compiler/include_llvm: The header files needed during compiling GPU kernels

runtime: the libraries and headers defines a set of CM APIs used by CPU applications, through which GPU kernels can be loaded onto render engine and be executed

runtime/include: The header files defining the CM APIs

runtime/lib: The libraries implementing the CM APIs

documents/compiler: The documents about the CM compiler usage and the CM language to write GPU kernels

documents/runtime: The documents about the CM APIs to load and execute GPU kernels

examples: Each folder under examples is an example, including host source code xxx.cpp and kernel source code xxx_genx.cpp.

setupenv.bat: The script to setup environment before building the application.

Install Intel® Graphics Driver for Windows

Intel® Graphics Driver for Windows can be downloaded from https://downloadcenter.intel.com/product/80939/Graphics-Drivers

The recommended version for each package can be found in each package's readme.md.

Build and Execute

Layout of an Intel C for Metal application

Usually an Intel C for Metal application contains two parts: host code running on CPU and kernel code running on GPU. Take /examples/linear_walker as an example:

linear_walker.cpp is the host application source code. It is standard C++ source code calling the Intel C for Metal APIs to load the GPU kernels. It is compiled by g++ and executed on CPU.

linear_walker_genx.cpp is the GPU kernel source code. It is written using the Intel C for Metal language. It is compiled by the Intel C for Metal compiler, cmc in compiler/bin, and is loaded by the host application and executed on GPU.

Build an example using provided bat script

At first of first, open a cmd window and run setupenv.bat in to setup environment.

    setupenv.bat gen_arch [platform] [dx_version]
                        

Please refer to the help message by running setupenv.bat without args

After running the setupenv.bat, all the below command should be executed in the same cmd window as setupenv.bat.

Take examples/linear_walker as an example. Change directory into examples, then run the build.bat script:

    cd examples
    build.bat linear_walker
                        

All source code files and other resource files in examples/linear_walker will be copied to examples/linear_walker/TMP_DIR. Besides, two new binaries will be generate in TMP_DIR:

  1. linear_walker.exe: the executable on CPU, generated from linear_walker.cpp

  2. linear_walker_genx.isa: the GPU kernel loaded by the CPU executable and executed on render engine on GPU, generated from linear_walker_genx.cpp

The build_all.bat will build all the examples by one command:

    cd examples
    build_all.bat
                        

Binaries of each example can be found in the TMP_DIR in each example folder.

Build an example using Visual Studio 2015

The Visual Studio solution is created by cmake, so please make sure cmake (version >= 3.2) has been installed.

At first of first, open a cmd window and run setupenv.bat in to setup environment.

    setupenv.bat gen_arch [platform] [dx_version]
                        

Please refer to the help message by running setupenv.bat without args

After running the setupenv.bat, all the below command should be executed in the same cmd window as setupenv.bat.

Still take examples/linear_walker as an example. Change directory into examples, then run the build.bat script:

    cd examples
    create_vs.bat linear_walker
                        

There will be a new folder linear_walker_x86 or linear_walker_x64 in examples/linear_walker, and the sln file can be found there. (x86 or x64 depends on the environment set when running the setupenv.bat)

Just build the solution and it will build both linear_walker.exe and linear_walker_genx.isa for both DX9 and DX11.

Run the host application code

Make sure both the host application binary and the GPU kernel binary are generated, and they are in the same directory.

Run the host application binary directly.

Build an example using command lines (advanced)

Contribu To This Package

The source code of Intel C for Metal compiler and examples in the package are maintained on github:

https://github.com/intel/cm-compiler

We welcome your contributions including bug fixes, optimizations, and new features. You may create a new pull request on github for your changes. We will review it, test it, and give you our feedback. When the change is finalized, we will push it to the project repository.

For any new example using CM, as long as you have the entire application that can be built and run on either Linux or Windows, you can email it to the maintainer of Intel C for Metal compiler. We can help you customize it, and publish it in our example folder.

Supported Platforms

Intel® microarchitecture code name Broadwell, Intel® microarchitecture code name Skylake, Apollo Lake, Kaby Lake, Coffee Lake, and Cannon Lake.

Known Issues and Limitations

(*) Other names and brands may be claimed as property of others.