VS Code, WSL2, and OneAPI — Leveraging Tools for Cross-Platform Software Development | by TonyM | Jun, 2022

How to build oneAPI for Linux and Windows using WSL2 and VSCode

0*MXO It3wlI6R3qUi
Photo by Vidar Nordli-Mathisen on Unsplash

Hello, world! As a 19-year Software Engineer and Software Architect at Intel in performance/parallelization tools and AI system platforms, I am very lucky and excited to share some of my experiences with you and get your thoughts about software, technology, and Intel. My first focus is trying to tackle the dilemmas of the modern software developer.

For as long as I can remember, I have always loved programming and solving problems. I started programming using BASIC when I was in first grade in 1985, when it was still slightly less common.

I’ve been fortunate enough (or unfortunate enough?) to have learned a few dozen programming languages, programmed in several IDEs and developed software in both Windows and Linux environments. I’ve also had to develop in rapidly evolving areas like Web/UI frameworks, Cloud development, Deep Learning, etc.

One constant over this time is that engineers are always fighting their tools to be more productive. As a developer, I want to be efficient as possible to get more work done or to free up my time to do something else in my life…so this means a lot to me personally. =)

Unfortunately for us, there is no one modern software developer. When I write Go code for microservices or Kubernetes, I use a quite different toolchain than I do when I’m writing React/Angular/Vue/Javascript code. There are also a lot of times I need cross-platform support between Windows/Linux/Mac.

Fortunately, there have been lots of advancements in cross platform IDEs and support. I am a long-time Vi user (no offense emacs users, I know emacs is more powerful), but I like modern IDEs and as an engineer, I love normalizing my workflow across platforms because it makes me more efficient.

Luckily for me, the languages I typically work with (C/C++/Python/Javascript/Go) all work reasonably well within Microsoft’s Visual Studio Code (VSCode) and recent updates to Microsoft’s Window Subsystem for Linux (WSL) also work well for cross-platform development.

Given that back drop, I thought I’d try to see how well I can get some cross platform oneAPI samples running on my Intel Alder Lake Core i9 Alienware R13 system (no not purchased by Intel).

Setting up WSL was painless, I simply opened a Windows command prompt and ran

> wsl --install

which installed the Ubuntu 20.04 distro for WSL with a quick, required reboot.

For me the process was painless, but some of my colleagues mentioned that if you do run into issues, Microsoft has provided a handy troubleshooting guide that will guide you through the prerequisite steps to make your system WSL ready.

The next step was setting up my VSCode. I initially tried to setup my VSCode in WSL using a Linux installation workflow, but it turns out that wasn’t the proper way to do it. Following the instructions from Microsoft I simply had to enable the Remote WSL extension in VSCode following the instructions here:

After enabling the extension, it was as easy as asking for a new WSL Window which popped up as a VSCode WSL connected Window.

1*Vmk6 wSgpuvLTV6SMK pkw

Since I wanted to see if I could run both Linux and Windows oneAPI based code on my system, I went to the oneAPI release page here:

1*EU 7nkUy vSWP98 pG7BDw

And selected the Toolkits I wanted and followed the instructions to install them on my system. I used an apt installation in a WSL terminal and the online installer for Windows.

1*dGqfW1WFC2qsD UrHcrE9g

Now that I theoretically had a working development environment, I went to the oneAPI samples Github:

and pulled the code to my local machine. This code is designed to be both Windows and Linux compatible, so I loaded up the Libraries->oneMKL->matrix_mul_mkl directory in my WSL VSCode window and pulled up a bash terminal. I had to source the oneAPI variables to enable the proper environment and then run make to build and run the sample code:

> source /opt/intel/oneapi/
> make

This successfully built and ran the DPC++/Intel® Math Kernel Library (MKL) Matrix Multiply example.


Creating and running the sample using a Windows binary ended up being a little more work as this was a new system so I had to install the Microsoft Visual Studio 2022 Community Edition and GNUMake. After that, it again was as simple as loading up VSCode and running:

> C:\Program Files (x86)\Intel\oneAPI\setvars.bat
> make

I’m sure many of you know this, but this next thing was an amazing discovery for me. I was playing with VSCode (Windows, not WSL based) and saw I could select a WSL prompt for my split terminal!

Doing that allowed me to build and run the sample for both Windows and Linux in the same VSCode instance.

Cross-platform development on a single system in a single IDE! I cannot express the endorphin high from the magic of this having spent years dealing with pain of cross-platform development.

The nice thing about all of this is I was able to set all of this up on a new system in just a couple of hours in the background.

In the future, I’ll be writing more on how well this flow works for Intel Arc-based GPUs, discussing other developer workflows like Jupyter notebooks, diving into software topics like Cloud and AI System Platform development, and sharing my experiences as a software engineer in the technology industry. Thanks for reading!

Want to Connect?If you want to see what random tech news I’m reading, you can follow me on Twitter.

Intel, the Intel logo, and other Intel marks are trademarks of Intel Corporation or its subsidiaries.

News Credit

%d bloggers like this: