We understand that the material and Assignment 1 may feel challenging, especially if you are not fully comfortable with the prerequisites. If you find yourself struggling or feeling overwhelmed, we kindly encourage you to consider taking this course in a different term once you have built up the required prerequisites. Your success and learning experience are important to us, and we want to ensure that you have a positive and fulfilling journey in this course.
Either MACM 101, and CMPT 125 or CMPT 130/135. or MATH 151 and CMPT 102 for students in an Applied Physics program, all with a minimum grade of C-. Please see here for prerequisites we expect you to know from prior courses:
As outlined above, we expect prior courses to provide the requisite C or C++ knowledge with experience in working with the Linux terminal/shell. If you do not have this experience, please head to the tutorials page and follow the tutorials, and self-learn using the videos we post and recommend. All assignments and labs in this course are administered through the Linux environment and assume you have the prerequisites.
If you are not comfortable working with C/C++ and the Linux terminal at SFU, it is possible that you may not have the prerequisites for this course, regardless of your grade in the prior course. We kindly recommend speaking to an academic advisor for further guidance.
Solid programming skills (C). Working at shell/terminal in Unix/Linux.
Environment. For this C homework, the executables need to run on a course machine. In particular, you will need to compile your source by either using the VM provided or CSIL machine. CSIL machines can be accessed either using RDP or SSH. On MacOS and Linux, python and terminal come installed by default. On windows we suggest you use the VM or set up VSCODE with VPN below. If you have any questions about connecting to CSIL, we kindly suggest reaching out to the Department Tech Staff at helpdesk@cs.sfu.ca.
Note: Prerequisites and CMPT 125/135 courses should have covered working with CSIL and Linux. If you feel unsure or need a refresher, we recommend reading the tutorials, watching the provided videos, and self-learning. We understand that connecting to CSIL or working with Linux can sometimes be challenging, but we won’t be able to provide direct support for SSH or CSIL access questions.
You will be connecting into linux machine
WE DO NOT SUPPORT WINDOWS
RDP without VPN IS NOT SUPPORTED
Your mileage may vary for copy paste
After you have remote desktop. Open Applications>Utilities>Terminal You can SSH or complete assignment tasks from terminal
Prior courses in CMPT should have shown you how to work with a terminal. If you are not comfortable with the terminal, we recommend reading the tutorials, watching the provided videos, and self-learning. We understand that working with the terminal can sometimes be challenging, but we won’t be able to provide direct support for terminal questions.
For windows users we see VM below. Alternatively we suggest you set up windows terminal with WSL and install vscode to help you connect to the university provided linux machines. Helpful links for windows users:
All assignments and labs in this course are administered through the Linux environment that is provided by the university. To access the linux environment, you will need to connect to the SFU VPN. The instructions are maintained by SFU for setting up VPN. Once you are connected to VPN you can ssh or remote desktop into CSIL machines. If you have any questions about connecting to CSIL, we kindly suggest reaching out to the Department Tech Staff at helpdesk@sfu.ca
# Replace SFUID below with the id in coursys e.g., mine is ashriram. Yours will be different. You can try cpu1-10 below if 6 does not work
$ ssh [SFUID]@csil-cpu6.csil.sfu.ca -p 24
To work remotely with CSIL you need to find free machines.
Option 1 Typically these are listed [here]- SSH to CSIL , RDP to CSIL If that page is down or is not working for you. Then you can use the option below or mail helpdesk@cs.sfu.ca
Option 2 First follow steps to connect to VPN above. Then in a terminal use the following python script below to get the list of machines.
# Replace SFUID below with the id in coursys e.g., mine is ashriram. Yours will be different.
$ ssh [SFUID]@csil-cpu6.csil.sfu.ca -p 24
# If cpu6 is down you can try others listed here: https://www.sfu.ca/computing/about/support/csil/unix/how-to-use-csil-linux-cpu-server.html
# On a shell on the CSIL server
$ wget "https://www.cs.sfu.ca/~ashriram/Courses/CS295/assets/distrib/csil-linux.py"
$ python3 csil-linux.py
# e.g., You will get a dump of machine names. These are machines currently running the linux environment.
# The names below will vary each time you run it.
asb10928-d06.csil.sfu.ca
asb10928-e02.csil.sfu.ca
asb10928-e03.csil.sfu.ca
asb10928-e04.csil.sfu.ca
asb10928-e05.csil.sfu.ca
asb10928-e06.csil.sfu.ca
asb10928-e07.csil.sfu.ca
cs-srye4013ua02.cs.surrey.sfu.ca
cs-srye4013ua04.cs.surrey.sfu.ca
cs-srye4013ua08.cs.surrey.sfu.ca
cs-srye4013ua10.cs.surrey.sfu.ca
cs-srye4013ub01.cs.surrey.sfu.ca
cs-srye4013ub02.cs.surrey.sfu.ca
cs-srye4013ub03.cs.surrey.sfu.ca
WARNING 1: If you are accessing remotely someone sitting physically at the linux machine could reboot it i.e., save early and often WARNING 2: The machines can be sshed into does not mean that they support RDP. This depends on sfu. If you encounter trouble for RDPing mail helpdesk@cs.sfu.ca
Instructions in this section are for self-learning purposes only. We apologize in advance, but we won’t be able to respond to any questions on Piazza related to prereq setup. Warning: We highly recommend working with a VM or SSHing into CSIL for a smoother experience.
Overview: In this section, we will learn how to tunnel our edits to files and commands over SSH, specifically using the Remote SSH extension in VSCode. The figure below provides an overview of this process. By using this method, we can run the VSCode editor locally on our laptop while editing files on remote CSIL machines and running commands on Linux remotely.
The video below will assume you have installed vpn and show you how to obtain a terminal on a remote machine and compile and run a program on remote machine.
Please note: We kindly provide the VM for your convenience. However, setting it up on your laptop/desktop is your responsibility. Our staff will not be able to provide individual technical support for this. We recommend referring to the links and video below for guidance. If you encounter any difficulties with the VM, we suggest following the CSIL instructions as an alternative.
We have created a CMPT 295 VM that comes preinstalled with Ubuntu 18.04 Bionic Beaver and many of the tools preinstalled. Download and install latest virtual Box. Last checked on version 6.1.22 Download and install latest extension pack
VMs are not supported by M1 MACs, Chromebooks or ARM-based macs, Macbook air; Please use CSIL
Mac OS Errors
Resolve Mac OS issues
Settings>Privacy>General>Allow
AMD Laptop errors
Enable virtualization
WARNING: NOT U20
)You can ssh into the VM from your machine. Port 2222 on the host machine maps to port 22 on VM.
ssh -p 2222 vagrant@localhost (username: vagrant password: vagrant)
CMPT 295 relies on a set of customized compilers and software. We uses modules to manage the user environment for different third-party software versions. The advantage of the modules approach is that the user is no longer required to explicitly specify paths for different executable versions.
$ module avail
# Step 1: If it says module command not found. If found, goto Step 2.
$ export LD_LIBRARY_PATH=/usr/shared/CMPT/courses/cmpt295/tcl/lib:$LD_LIBRARY_PATH
$ source /usr/shared/CMPT/courses/cmpt295/modules/Modules/3.2.10/init/bash
$ module avail
# If you see some Tclerror etc. Then you have not set the LD_LIBRARY_PATH
# Step 2
$ module load cmpt295/cgdb
$ module load valgrind # if it complains, we have already preinstalled valgrind
$ module load cmpt295/riscv
# If shell does not say (base).. you also need to load conda
$ . "/usr/shared/CMPT/courses/cmpt295/miniconda3/etc/profile.d/conda.sh"
$ conda activate
Alternative if your are not able to get above steps working
# Add this to the file ~/.bashrc if you want to automatically have cgdb loaded each time.
export PATH=/usr/shared/CMPT/courses/cmpt295/cgdb/bin:$PATH
export PATH=/usr/shared/CMPT/courses/cmpt295/valgrind/bin:$PATH
On CSIL. If in SSH Terminal
If you see errors such as cgdb not found
If logged into CSIL. You need to do this everytime you log in to CSIL.
If you do not want to. Add the following commands below to your .bashrc or .zshrc found in your home directory ~/ .
# Step 1: If it says module command not found. If found, goto Step 2.
$ export LD_LIBRARY_PATH=/usr/shared/CMPT/courses/cmpt295/tcl/lib:$LD_LIBRARY_PATH
$ source /usr/shared/CMPT/courses/cmpt295/modules/Modules/3.2.10/init/bash
$ module avail
# If you see some Tclerror etc. Then you have not set the LD_LIBRARY_PATH
# Step 2
# Load compilers
$ module load cmpt295/cgdb
$ module load cmpt295/valgrind
$ module load cmpt295/riscv
# Load the appropriate python3 version. This important for Assignment 4 and 6.
# The . below is important. It IS NOT A TYPO
$ . "/usr/shared/CMPT/courses/cmpt295/miniconda3/etc/profile.d/conda.sh"
# Load the grading scripts
$ conda activate
# Following this your shell should change to (base)....
# If not, then you do not have access to the grading scripts
# Do not add above line to your .bashrc. Simply type conda activate
# If it says conda not found then re-run the last step
# . "/usr/shared/CMPT/courses/cmpt295/miniconda3/etc/profile.d/conda.sh"
If on VM. We preload the software.
$ module avail
# If on VM you do not need to do anything.
## VM
# Your shell should say (base).....
# If module avail says command not found
# then you are most likely in the wrong shell/terminal
Your home directory is shared between the CPU servers, so you can copy files to or from there by connecting to one of the CPU servers. The files will be available on the workstations. Copying files to CSIL will be something like:
scp -P24 filename USERNAME@csil-cpu1.csil.sfu.ca:
And back from CSIL:
scp -P24 USERNAME@csil-cpu1.csil.sfu.ca:filename .
These assignments may need you to navigate through multiple source files. If you do not have a favorite editor then I would highly recommend the following.
You can pull up vscode by typing code in your terminal
(VM or RDP-only)$ valgrind -q --leak-check=full ./main
When validating memory leaks, make sure you’re using valgrind to verify that there are no leaks. However, if you’re struggling to figure out the output from valgrind or other errors in your code. We may include another tool on the VM called scan-build (Clang static analyzer). To run this, call (scan-build -k -V ./main
). It will generate an HTML page that will show existing issues in the code if it can detect some. This tool will not detect all the same issues though that valgrind will, so you cannot rely on it as proof of no leaks in your code.