Technical Article

  • 05/05/2020
  • Public Content

Remote Visual Studio Code Development with oneAPI on Windows Subsystem for Linux*

The following procedure will use a Remote Host connection enabling you to edit and debug your code using the Windows Subsystem for Linux* (WSL).

Prerequisites

It is not necessary to install VSCode on your Linux target that is running on WSL. VSCode is only needed on your Windows development system. The Linux installed on WSL does not require a GUI in order to be used for Linux development.

Set oneAPI Environment Variables on the WSL Target Linux

In order to perform development on your remote WSL target, you must install (at minimum) the Intel® oneAPI Base Toolkit (Base Kit) and configure the oneAPI development environment variables on the WSL target Linux.
  1. Open a WSL terminal and install the Base Kit on to that target Linux system using the appropriate Linux package manager.
    To get started, you need to install only the Base Kit on your WSL target; you can install additional oneAPI toolkits either now or at a later time.
  2. Configure your WSL Linux target so that the oneAPI development environment script (
    setvars.sh
    ) runs when VS Code initiates a connection.
    Visual Studio Code does not currently provide a mechanism to automatically run scripts on your remote Linux target when it interacts with the WSL system (for example, running
    setvars.sh
    automatically). There are a variety of ways to get around this issue, only one of which is presented here. See the Bash Startup Files man page for more options.
    Add the following shell script lines to your remote Linux system's
    /etc/profile
    script. This location (or in an
    /etc/profile.d/
    script) will ensure that all users of your WSL target development system will run the
    setvars.sh
    environment script when they connect using Visual Studio Code:
    . /opt/intel/oneapi/setvars.sh &>/dev/null
    The above assumes that you have installed your oneAPI toolkits on the WSL system in the default "root/sudo" installation location (
    /opt/intel/oneapi/
    ). If you have installed the oneAPI tools in a different location on your remote Linux system, you will have to adjust the path to
    setvars.sh
    .
    See Configure Your CPU or GPU System for more details regarding configuration of the oneAPI environment on a Linux system.

Configure Visual Studio Code on Your Local Host

You must install the VS Code "Remote - WSL" extension into your local copy of VS Code. This extension facilitates development on the WSL* system.
  1. Install the
    Remote - WSL
    extension by Microsoft. Click the
    Extensions
    icon and search for "remote wsl" in the search bar.
  2. Click
    install
    . After installation, you see
    Remote – WSL
    in the
    Installed Extensions
    list.

Connect to Your WSL Linux System

See the Visual Studio Code Remote Development in WSL documentation for detailed instructions, requirements, and additional information.
  1. Open a WSL terminal for your desired Linux distribution. From within the terminal, invoke VS Code from the command line to start a local instance connected to WSL.
    user@host:~$ code
  2. A new VS Code window opens and is connected to the WSL system.
  3. Once connected, add the
    C/C++ extension
    to the VS Code instance. This extension is required to debug a remote session using the VS Code debug interface.

Create a New oneAPI Project

Follow the instructions in Basic Usage of Visual Studio Code with oneAPI on Linux, and refer to the section titled "Working in VS Code with the oneAPI CLI Sample Browser".
Once you have created a oneAPI sample on your WSL system, you can build, run, and debug it on the remote host, from within your local VS Code window.

Disconnect from a Remote Host

You can close the VS Code remote connection by selecting
File
Close Remote Connection
from the VS Code menu. Alternatively, click the colored
remote wsl
notification in the lower-left corner of the VSCode window and select
Close Remote Connection
from the list of
Remote-WSL
commands.

Product and Performance Information

1

Intel's compilers may or may not optimize to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors. These optimizations include SSE2, SSE3, and SSSE3 instruction sets and other optimizations. Intel does not guarantee the availability, functionality, or effectiveness of any optimization on microprocessors not manufactured by Intel. Microprocessor-dependent optimizations in this product are intended for use with Intel microprocessors. Certain optimizations not specific to Intel microarchitecture are reserved for Intel microprocessors. Please refer to the applicable product User and Reference Guides for more information regarding the specific instruction sets covered by this notice.

Notice revision #20110804