This blog is for noting down the details about setting up the development environment for RMCProfile on Windows machine. The notes here are still based on the conventional way of compiling using make files. There is some work happening in the background now to transfer the compiling to using cmake. Before the whole pipeline of cmake is ready, we will still rely on the route as in the current blog. In fact, even the current route is depracated, some of the notes will still apply when setting up the development environment.
-
Nowadays, we are pretty much using the intel Fortran compiler which now is free, through the
oneAPItoolkit. To install the compiler, we need to first installMicrosoft Visual Studio(the community version is fine, and it is free). We may need to remove whatever existing old versions ofMicrosoft Visual Studio(e.g., the 2019 version may need to be removed, if the we intend to use the 2022 version). I am not sure whether this is the cause for my issue, but in my case, I have been struggling a lot with theoneAPIsetup in the down stream. Anyhow, having a clean version of 2022 turns out to be working fine for me. -
Then we want to install the
OneAPItoolkit.Here is the official website for download and instructions (as of writing), oneAPI Base Toolkit download and install
See the
Run Sample Code to Verify Installationsection on the website for the command to run for terminal (e.g.,powershell) initialization. -
To use
makeand also for the purpose of back-compatibility for some plotting routines, we need to installCygwinand set up thepgplotlibrary inside theCygwinenvironment (see the section at the very bottom for details about setting uppgplotinCygwin). When installingCygwin, the following selections are necessary:make,x11andxorg. Later on when installing thepgplotlibrary, if some of theX11stuff are missing, we can Google what we need to include forX11installation according to the error message we got. -
We will need to install
nvccfor compiling CUDA codes involved in theRMCProfileproject. As of writing, the offial website for download the installation file is this. In case it is changed, we can just google ‘CUDA nvcc install’ or something relevant to search for information. -
In preparation for the compiling, we may need to delete unnecessary entries in the
PATHenvironment variable. Otherwise, thenvcccommand will fail when it is trying to set up the environment on-the-fly. It is something relevant to the running ofvcvars64.batscript which will be running on-the-fly when runningnvcc, and the fundamental reason for the potential failure is the value of the environment variablePATHis too long. On Windows, we can useStartto search for ‘environment variable’ to bring up the GUI window for changing thePATHvariable. -
On
powershell, we need to runcmd.exe "/K" '"C:\Program Files (x86)\Intel\oneAPI\setvars.bat" && powershell'to initialize the terminal environment.
This command needs to be run each time when launching a new
powershellterminal.When we see error like this,
LINK : fatal error LNK1104: cannot open file 'ifconsol.lib'it infers the
oneAPIenvironment initializer was not run, in which case we just need to run the command above to initialize the environment and try again the compiling. -
As a side note, with the latest intel
oneAPIcompiler (ifort), the argument that goes intoc_loc(the function used in the source codes for fetching the address of a pointer) should be defined as a pointer. The original definition of some of the variables (used as the argument forc_loc) as allocatable arrays would not work. -
When encountering the issue with unresolved CUDA symbols, we may need to change the cuda library files to the version that is compatible with the version of
nvccbeing used for the compiling. Specifically, two CUDA library filescublas.libandcudart.libneed to be linked while making thermcprofile.exeexecutable. For specific command for linking, etc., refer to thoseMakefilefiles in theRMCProfilerepository – for the moment, the source code is not open source yet. To get access, get in touch with me here. We need to copy the proper version of these two files to somewhere (and the path to the two library files will be specified while linking to makermcprofile.exe).In my case, I was using the
12.6version ofnvccand my library files could be found here,C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.6\lib\x64.
=================I AM A SEPARATOR=================
Here follows are the detaild instructions about setting up pgplot in Cygwin.
-
Grab the
pgplot5.2.tar.gzfile which has already been included in the main directory of theRMCProfilerepository. -
Decompress and extract the contents of the distribution file in a source directory. In this sense, I always place
pgplot5.2.tar.gzunder /usr/local/src. Then we can do,cd /usr/local/src mv [SOMEWHERE]/pgplot5.2.tar.gz . tar zxvf pgplot5.2.tar.gzThis will create
/usr/local/src/pgplotand subdirectories. -
Create the directory where
PGPLOTwill be actually installed,mkdir /usr/local/pgplot cd /usr/local/pgplot -
Copy the file
drivers.listfrom the source directory to the installation directory,cp /usr/local/src/pgplot/drivers.list . -
Edit that file and remove the exclamation mark (first column of each row) in front of the following graphic devices,
/PS, /VPS, /CPS, /VCPS, /Xserve and /XWindow -
Create the makefile. From the installation directory
/usr/local/pgplot, execute,/usr/local/src/pgplot/makemake /usr/local/src/pgplot linux g77_gcc_aout -
Edit the file makefile and change the line,
FCOMPL=g77to
FCOMPL=gfortran -
Compile the source files,
make make cpg make clean
=================I AM A SEPARATOR=================
Here are some random notes on compiling with cmake.
-
In the main
CMakeLists.txtfile, there is one lineproject(RMCProfile LANGUAGES CXX C Fortran)specifying what languages are included in the project.cmakewill perform the necessary configuration checking and testing at the configuration stage for all the included languages. WithCUDA, I found that on my Windows machine, includingCUDAin the language list would never pass the initial configuration stage. However, leaving outCUDAfrom the list, thus skipping theCUDAchecking and testing, is still OK – the compiling could still be finished without problems withCUDAcodes compiled successfully. Not sure why, but suspecting whether it is the following line that puts downCUDAspecification explicitly actually did the magic,find_package(CUDA 11.4 REQUIRED) set(CMAKE_CUDA_STANDARD 11) set(CMAKE_CUDA_STANDARD_REQUIRED ON) find_package(CUDAToolkit REQUIRED) if(CUDAToolkit_VERSION_MAJOR GREATER_EQUAL 12) set(CMAKE_CUDA_ARCHITECTURES "61;70;75;80;86;89") else() set(CMAKE_CUDA_ARCHITECTURES "61;70;75;80;86") endif() message(STATUS "Using Nvidia GPU architectures ${CMAKE_CUDA_ARCHITECTURES}") if(CMAKE_BUILD_TYPE STREQUAL "Debug") set(CMAKE_CUDA_FLAGS ${CMAKE_CUDA_FLAGS} "-g -G") # enable cuda-gdb endif()