Get Started with the Intel® oneAPI Base Toolkit for Linux*

ID 766893
Date 3/31/2023
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

Build and Run a Sample Project Using Visual Studio Code

Intel® oneAPI Base Toolkit

Intel® oneAPI toolkits integrate with third-party IDEs to provide a seamless GUI experience for software development.

NOTE:
If you are using Visual Studio Code (VS Code) with FPGA, see theFPGA Workflows on Third-Party IDEs for Intel® oneAPI Toolkits.

To see a list of components that support CMake, see Use CMake to with oneAPI Applications .

To watch a video presentation of how to install extensions and use them to set up your environment, explore sample code, and connect to the Intel® Developer Cloud using Visual Studio Code, see oneAPI Visual Studio Code Extensions.

This procedure requires the Sample Browser extension to be installed. The next section will describe how to install it. If you have already installed it, skip to Create a Project Using Visual Studio Code.

Extensions for Visual Studio Code Users

To watch a video presentation of how to install extensions and use them to set up your environment, explore sample code, and connect to the Intel® Developer Cloud using Visual Studio Code, see oneAPI Visual Studio Code Extensions.

You can use VS Code extensions to set your environment, create launch configurations, and browse and download samples:

  1. From Visual Studio Code, click on the Extensions logo in the left navigation.

  2. Locate the extension titled Sample Browser for Intel oneAPI Toolkits, or visit https://marketplace.visualstudio.com/publishers/intel-corporation to browse available extensions.
  3. Click Install.
  4. Next, locate the extension titled Environment Configurator for Intel oneAPI Toolkits.
  5. Click Install.

For more information about VS Code extensions for Intel oneAPI Toolkits, see Using Visual Studio Code* to Develop Intel® oneAPI Applications.

Create a Project Using Visual Studio Code

  1. Click on the icon to open the oneAPI Samples Browser:

  2. A list of available samples will open in the left navigation.
  3. To view the readme for the sample, click the next to the sample. If you choose to build and run the sample, the readme will also be downloaded with the sample.
  4. Find the sample you want to build and run. Click the to the right of the sample name.

  5. Create a new folder for your sample and click OK.

  6. The sample will load in a new window:

Set the oneAPI Environment

  1. Press Ctrl+Shift+P ( or View -> Command Palette… ) to open the Command Palette.
  2. Type Intel oneAPI: Initialize environment variables. Click on Intel oneAPI: Initialize environment variables.

Prepare Build Tasks from Make / CMake Files

  1. Press Ctrl+Shift+P or View -> Command Palette… to open the Command Pallette.
  2. Type Intel oneAPI and select Intel oneAPI: Generate tasks.

  3. Select the build tasks (target) from your Make/CMake oneAPI project that you want to use.

  4. Run the task/target by selecting Terminal -> Run task... .

  5. Select the task to run.

NOTE:
Not all oneAPI sample projects use CMake. The README.md file for each sample specifies how to build the sample. We recommend that you check out the CMake extension for VS Code that is maintained by Microsoft.

Build the Project

The oneAPI extensions enable the ability to prepare launch configurations for running and debugging projects created using Intel oneAPI toolkits:

NOTE:
Debugging a local Windows host using VS Code is not supported. Debugging a local Linux host on CPU is supported using VS Code, but debugging on GPU requires a remote host. Debugging a remote Linux target from Windows or Linux host is supported using VS Code.

  1. Press Ctrl+Shift+B or Terminal -> Run Build Task... to set the default build task.
  2. Select the task from the command prompt list to build your project.
  3. Press Ctrl+Shift+B or Terminal -> Run Build Task... again to build your project.

Prepare Launch Configuration for Debugging

The oneAPI extensions enable the ability to prepare launch configurations for running and debugging projects created using Intel oneAPI toolkits:

  1. Press Ctrl+Shift+P or View -> Command Palette... to open the Command Palette.
  2. Type Intel oneAPI and select Intel oneAPI: Generate launch configurations .

  3. Select the executable (target) you want to debug.

    Optional: select any task you want to run before and/or after launching the debugger (for example, build the project before debug, clean the project after debug).

  4. The configuration is now available to debug and run using the gdb-oneapi debugger. You can find it in .vscode/launch.json. To debug and run, click on the Run icon or press Ctrl+Shift+D.

NOTE:
Debugging a local Windows host using VS Code is not supported. Debugging a local Linux host on CPU is supported using VS Code, but debugging on GPU requires a remote host. Debugging a remote Linux target from Windows or Linux host is supported using VS Code.

Debug, Analyze, Develop with More Extensions

There are more oneAPI extensions for Visual Studio Code which enable:

  • debugging
  • remote development
  • connection to Intel Developer Cloud
  • analysis configuration

To learn more about the extensions, see Intel® oneAPI Extensions for Visual Studio Code*.

To learn more about more capabilities and options, see Using Visual Studio Code with Intel® oneAPI Toolkits.

NOTE:

An internet connection is required to download the samples for oneAPI toolkits. If you are using an offline system, download the samples from a system that is internet connected and transfer the sample files to your offline system. If you are using an IDE for development, you will not be able to use the oneAPI CLI Samples Browser while you are offline. Instead, download the samples and extract them to a directory. Then open the sample with your IDE. The samples can be downloaded from here:

Intel® oneAPI Toolkit Code Samples

See Explore SYCL* Through Samples to learn more.