|
| 1 | +# Getting Started Sample for Intel oneAPI Rendering Toolkit: Intel Implicit SPMD Program Compiler |
| 2 | + |
| 3 | + |
| 4 | +Intel Implicit SPMD Program Compiler (ISPC) optimizes single program multiple data kernels for execution on modern SIMD hardware. ISPC is often used in conjunction with high performing Embree and OpenVKL based programs. ISPC compiles a C programming language variant. The language has helpful constructs for modern parallelism. This sample introduces Intel ISPC within the scope of the Intel oneAPI Rendering Toolkit (Render Kit). |
| 5 | + |
| 6 | +| Minimum Requirements | Description |
| 7 | +|:--- |:--- |
| 8 | +| OS | Linux* Ubuntu* 18.04, CentOS* 8 (or compatible); Windows* 10; MacOS* 10.15+ |
| 9 | +| Hardware | Intel 64 Penryn or newer with SSE4.1 extensions; or an ARM64 with NEON extensions |
| 10 | +| Compiler Toolchain | Windows* OS: MSVS 2019 installed with Windows* SDK and CMake*; Other platforms: C++11 compiler and CMake* |
| 11 | +| Libraries | Install Render Kit including Intel Implicit SPMD Program Compiler |
| 12 | + |
| 13 | +| Optimized Requirements | Description |
| 14 | +| :--- | :--- |
| 15 | +| Hardware | Intel 64 Skylake or newer with AVX512 extensions; or ARM64 with NEON extensions |
| 16 | + |
| 17 | +| Objective | Description |
| 18 | +|:--- |:--- |
| 19 | +| What you will learn | How to build and run a basic Intel ISPC program using the Render Kit distribution. |
| 20 | +| Time to complete | 5 minutes |
| 21 | + |
| 22 | + |
| 23 | +## Purpose |
| 24 | + |
| 25 | +This getting started sample highlights three key basic parts to using Intel ISPC. |
| 26 | +1) the Intel ISPC kernel, `simple`. |
| 27 | +2) kernel linking into a final program |
| 28 | +3) vector hardware extension targeting capability |
| 29 | + |
| 30 | + |
| 31 | +The `simple` kernel, defined in `simple.ispc`, performs an element wise operation on an input float array. The output is written to stdout. |
| 32 | + |
| 33 | + |
| 34 | +## Key Implementation Details |
| 35 | + |
| 36 | +### The Kernel and Linking (1 and 2) |
| 37 | + |
| 38 | +- Our sample programs have the main entry point defined in `simple.cpp`. We compile this source to an object with a C++ compiler. |
| 39 | +- `simple.ispc` contains the implementation of the kernel function. This source is compiled to an object by the Intel ISPC compiler driver `ispc`. |
| 40 | +- The final program is links the C++ object to the Intel ISPC object. |
| 41 | +- Within the C++ source, the function prototype for the kernel is introduced by way of this preprocessor code: |
| 42 | +``` |
| 43 | +#include "simple_ispc.h" |
| 44 | +``` |
| 45 | + |
| 46 | +- Key: The simple_ispc.h header file is generated by the `ispc` compiler driver when it compiles simple.ispc. |
| 47 | + |
| 48 | +### Single and Multitargeting (3) |
| 49 | + |
| 50 | +In this sample, we demonstrate both single and automatic multiple device targeting. Two output programs are built respectively they emit the same output. |
| 51 | + |
| 52 | +- The first build target program, `simple`, builds with the simple.ispc kernel targeted to SSE2 (Streaming SIMD Extensions 2) ISA extensions. These extensions were introduced on CPUs in the early 2000's. |
| 53 | +- The second build target program, `simple_multi`, will create an object per ISA extension target, as well as a primary kernel linking object. All objects are then linked to generate the final binary. The program will runtime detect the appropriate codepath for the target platform. |
| 54 | + |
| 55 | +This initial sample demonstrates Intel ISPC usage with an introductory program running on CPU only. Other Intel Embree and Intel Open VKL sample programs demonstrate usage of ISPC in conjuction with those libraries. |
| 56 | +See more about programming with Intel ISPC with the [documentation](https://ispc.github.io/documentation.html). |
| 57 | + |
| 58 | +### Targeting Documentation |
| 59 | + |
| 60 | +- To target ISA extension capability introduced in newer x86_64 processors, see the [targeting table](https://ispc.github.io/ispc.html#selecting-the-compilation-target) in the release notes. |
| 61 | +- For targeting ARM64 with NEON extensions. See the [target selection](https://ispc.github.io/ispc.html#selecting-the-compilation-target) in the release notes. Edit the CMakeLists.txt file accordingly for the build step. |
| 62 | +- For targeting Intel Graphics Processors, see the article for [ISPC on Gen](https://ispc.github.io/ispc_for_gen.html). |
| 63 | + |
| 64 | +## License |
| 65 | + |
| 66 | +This code sample is licensed under a BSD-3-Clause license. See |
| 67 | +[LICENSE.txt](LICENSE.txt) for details. |
| 68 | + |
| 69 | +Third party program Licenses can be found here: [third-party-programs.txt](https://github.com/oneapi-src/oneAPI-samples/blob/master/third-party-programs.txt) |
| 70 | + |
| 71 | +## Build and Run |
| 72 | + |
| 73 | + |
| 74 | +### Windows OS: |
| 75 | + |
| 76 | + |
| 77 | +Run a new **x64 Native Tools Command Prompt for MSVS 2019** |
| 78 | + |
| 79 | +``` |
| 80 | +call <path-to-oneapi-folder>\setvars.bat |
| 81 | +cd <path-to-oneAPI-samples>\RenderingToolkit\GettingStarted\05_ispc_gsg |
| 82 | +mkdir build |
| 83 | +cd build |
| 84 | +cmake .. |
| 85 | +cmake --build . --config Release |
| 86 | +cd Release |
| 87 | +.\simple.exe |
| 88 | +.\simple_multi.exe |
| 89 | +``` |
| 90 | + |
| 91 | +Review the output emitted to standard out. |
| 92 | + |
| 93 | + |
| 94 | +### Linux OS: |
| 95 | + |
| 96 | +Start a new Terminal session |
| 97 | +``` |
| 98 | +source <path-to-oneapi-folder>/setvars.sh |
| 99 | +cd <path-to-oneAPI-samples>/RenderingToolkit/GettingStarted/05_ispc_gsg |
| 100 | +mkdir build |
| 101 | +cd build |
| 102 | +cmake .. |
| 103 | +cmake --build . |
| 104 | +./simple |
| 105 | +./simple_multi |
| 106 | +``` |
| 107 | + |
| 108 | +Review the output emitted to standard out. |
| 109 | + |
| 110 | +### MacOS: |
| 111 | + |
| 112 | +Start a new Terminal session |
| 113 | + |
| 114 | +``` |
| 115 | +source <path-to-oneapi-folder>/setvars.sh |
| 116 | +cd <path-to-oneAPI-samples>/RenderingToolkit/GettingStarted/05_ispc_gsg |
| 117 | +mkdir build |
| 118 | +cd build |
| 119 | +cmake .. |
| 120 | +cmake --build . |
| 121 | +./simple |
| 122 | +./simple_multi |
| 123 | +``` |
| 124 | + |
| 125 | +Review the output emitted to standard out. |
0 commit comments