Skip to main content

Intel Parallel Studio 2019 meet Cygwin

Introduction

Intel Parallel Studio provides pre-configured bat to run command line interface using Windows CMD.  The command is called 'icl'. To some, this is satisfactory.  To me, I need a better shell.

Cygwin satisfies my need for a UNIX shell.  This post is about setting up a Windows system to successfully compile a simple code using Cygwin and icl, Intel C++.

Largely, I had two issues: one minor, quality-of-life issue, the other critical.

Quality-of-Life issue

The minor issue is that I wanted to simply double-click on the icon to open up a console with appropriate environment.  The provided bat file does that, but for CMD.  I wanted to gear that toward Cygwin bash environment.  The obvious way is to open up the CMD through the bat, and then execute Cygwin.bat from the Cygwin installation folder.

To have one-click icon to open up a prepared Cygwin bash console, we must provide appropriate arguments to the shortcut.

Method

  1. Locate the Intel-provided shortcut file called "Compiler 19.0 for Intel 64 Visual Studio 2017 environment" by going through the start menu and opening the folder location of the shortcut
  2. Make a copy of the shortcut and rename it appropriately (e.g. "Cygwin - Compiler 19.0 for Intel 64 Visual Studio 2017 environment")
  3. Right-click on the new shortcut and adjust the address
    • Add "&" character in the argument to add a new command
    • Add, after &, a command to execute Cygwin.bat
    • The end result will look something like the following: C:\Windows\System32\cmd.exe /E:ON /V:ON /K ""C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2019.0.117\windows\bin\ipsxe-comp-vars.bat" intel64 vs2017 & C:\cygwin64\bin\mintty.exe -i /Cygwin-Terminal.ico - "
  4. Execute and see two windows open: first, CMD windows showing environment being set up, then Cygwin console with the bash promp.

Critical Issue

The second issue, if unaddressed, makes the process unusable.

Symptom

Given a cpp file called test.cpp, compilation is done by icl test.cpp This will generate test.obj and proceeds to link the file to the output file. The link process fails. The link process fails because of the path issue; essentially, wrong and incompatible link is called, causing the compilation process to fail.

Workaround

The issue is the path. The command link exists in /usr/bin of cygwin, as well as in the Intel Parallel Studio installation. When icl is used, like any command in shell, the bash goes through its PATH to find the first match of the command. In the default Cygwin installation, /usr/bin appears before the Windows-imported path. As such, link from GNU Coreutils is selected over the Intel compiler's. Therefore, a simple solution is the reverse the order of path such that Windows-imported path appears before Cygwin native paths. To do so, edit the /etc/profile and change the PATH variable: PATH="/usr/local/bin:/usr/bin${PATH:+:${PATH}}" Now, the correct link will be used to complete the compilation process.

Caveat

This method will now cause Cygwin to call wrong command if there are other commands with the same name in Windows installation. Possible solution is to create a script that will temporarily change the PATH, run icl, and change the PATH back. I will need to understand how Cygwin imports PATH from Windows to implement this.'

UPDATE 20180913

To implement the scenario in Caveat, I created a new shell variable, PATH_INTEL in /etc/profile right before the line with PATH and assigned the appropriate values favorable to icl and kept PATH to its original that placed cygwin bin first and Windows commands later. I also created a script called icl.sh that switched PATH before icl $* and switch it back afterwards. I then finally created an alias for icl that points to script instead. Now, the PATH does not interfere with the rest of the command while correct PATH is used while icl is being run.

Comments

Popular posts from this blog

Creating a patch for GNU GCC using Git

Overview and Target Audience The GNU GCC project followed a blend of a traditional method with contemporary git tools when it comes to contributing code, making the experience unique from some other, git-based projects. This blog post will explore different aspects of the process, helpful commands, and various scripts that would make the experience more pleasent for new contributors. While this blog aims to help new contributors get acustomed to the GNU GCC code culture and make contributing easier, it must be stressed that this is not in any way in-depth exploration of the process. This should help you put your first foot forward; the community will help you take the rest of the steps from that point on. This post also assumes the user is in a POSIX environment (e.g. Linux, FreeBSD). Git and GNU As stated in this phoronix post , GNU GCC made a full transition to git early 2020. As of this writing, the community seems to be adjusting to the new tools. GNU GCC hosts its own git serve

Setting up IRC

About IRC Internet Relay Chat was once the most popular real-time communication method that uses computer for a large spectrum of community groups. While it has largely been supplanted by more contemporarly methods for most people, IRC is still a prefered means of communication among older software projects like GCC. The Client As an old technology that is also very favored among programmers, IRC has many clients with different flavors, from GUI to CLI to headless. As a linux user with strong attraction to tmux, I chose weechat. Depending on your distro or OS, install your client first. Configuring Weechat I will be using GCC channel in OFTC server as the example. How are we configuring this? While Weechat has a configuration file, Weechat officially advises against using the file to configure the program behavior. Instead, it promotes `/set` dialog within the client to set the proper configuration. Connect to server Let's first connect to server. The `#gcc` channel is host

Debugging with GCC: GIMPLE

GCC and GIMPLE One of the very first thing GCC asks the GSoC applicants to do, even before writing the application, is to try various different debugging techniques using GCC. I was personally familiar with the basic, compile-with-g-flag-and-use-gdb method. Turns out, there's more: GIMPLE. A Simple but Non-trivial Program Problem Description The instruction asks to compile a simple but non-trivial program with some flags that generates debugging information: -O3 -S -fdump-tree-all -fdump-ipa-all -fdump-rtl-all . Because I was keep reading on ways to debug GCC just prior to the statement, I immediately thought "GCC" and tried make -j8 CXXFLAGS="-O3 -S -fdump-tree-all -fdump-ipa-all -fdump-rtl-all" . This was a mistake: turns out, GCC can't be compiled with those flags. Thankfully, GCC developers have a very active IRC channel for me to signal SOS. Resolution jakub and segher were quick to respond to my call for help. jakub: it isn't meant that y