How to run MIT 6.172 OCW Code
← HomeContext
I noticed that the code provided with the open-sourced course 6.172 — Performance Engineering on MIT OpenCourseWare — doesn't compile and there aren't very clear instructions on how to get the toolchain with the Cilk multithreading library and X11 graphics working for the projects. Hopefully, this guide helps answer those questions and lets people get started quickly!
Local devenv with Docker (the easy way)
The easiest way to get up and running is to follow the setup instructions at https://github.com/peterg17/6.172. This repo includes a Dockerfile and only requires that you have Docker and an X11 client like XQuartz for MacOS. This has only been tested on MacOS.
If you want to run reliable benchmarks and avoid noisy neighbors (more than on your personal machine), you may want to use an EC2 instance for performance testing jobs.
EC2 instance setup (the slightly harder way)
To provision and setup an EC2 instance for development, you can follow these steps:
- Click
launch instanceon the EC2 landing page. -
Create a
t2.micro(or size of your choice) instance with the "Ubuntu, 16.04 LTS, amd64" AMI.- You can always upgrade the instance type, but we are starting off very small to save $ (and because our goal is to simply get the course code running).
-
Make sure to create a new keypair and save the
.pemfile to your local machine. You will use this to SSH in. - Make sure to click the "Allow SSH traffic" button in network settings.
- In the "configure storage" section, set the root volume to have 30 GB of storage (since that's the max of the free tier).
Dependencies
Now login to your newly created instance using the SSH command:
ssh -i <keypair path> ubuntu@<instance IP>
Where the instance IP is the IP address under "Public IPv4 address" in your EC2 instance config. For
instance:
ssh -i peter-test-keypair.pem ubuntu@55.222.77.111.
Note: you might get the following warning:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: UNPROTECTED PRIVATE KEY FILE! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Permissions 0644 for 'peter-test-keypair.pem' are too open. It is required that your private key files are NOT accessible by others. This private key will be ignored. Load key "peter-test-keypair.pem": bad permissions ubuntu@54.227.77.114: Permission denied (publickey).
In this case, you simply must run chmod 400 keypair.pem with your actual keypair name to
change the permissions so that other users/groups cannot read the keypair.
First, we will get the source code for one of the projects. Here I am using project 2 because it uses all of the dependencies we need to display a fully functioning devenv: cilk, the rest of the clang toolchain, and X11 graphics.
-
Download zip to project 2:
-
curl -L -o project2.zip https://ocw.mit.edu/courses/6-172-performance-engineering-of-software-systems-fall-2018/e73f8fc30a609509b847f708815a72c0_MIT6_172F18-project2.zip sudo apt-get install unzipunzip project2.zip-
You should now have the contents of the zip under a folder called
MIT6_172F18-project2.
-
-
Install clang toolchain w/ CILK
- Credit: the steps to get the clang toolchain w/ CILK is from https://github.com/mattfeng/batch-scrimmage/blob/master/awsbatch/Dockerfile , thanks!
cd MIT6_172F18-project2sudo apt-get install make emacssudo apt-get install software-properties-commonsudo add-apt-repository -y ppa:wsmoses/tapir-toolchainsudo apt-get updatesudo apt-get install -y tapirclang-5.0 libcilkrts5sudo apt-get install -y build-essential clang
If you try running make now, you might notice the following error:
ubuntu@ip-172-31-27-25:~/project2/MIT6_172F18-project2$ make clang -std=gnu99 -Wall -ftapir -O3 -DNDEBUG -o intersection_event_list.o -c intersection_event_list.c clang: error: unknown argument: '-ftapir'
This is because we are using the standard version of clang and not the one with Cilk. You can
see above that we install tapirclang-5.0, so we should modify the Makefile to use
clang-5.0 instead of the clang in our path (which on my machine is
clang version 3.8.0-2ubuntu4).
Modify the following lines of Makefile:
- Instead of
CXX = clang, useCXX = clang-5.0 - Instead of
CXXFLAGS = -std=gnu99 -Wall -ftapir, useCXXFLAGS = -std=gnu11 -Wall -fcilkplus
X11 graphics
If you try running make at this point, you might hit the following error:
././graphic_stuff.h:28:10: fatal error: 'X11/Xlib.h' file not found #include <X11/Xlib.h>
This is because we need X11 sources and other tools which we can get with:
sudo apt-get install x11-appssudo apt-get install libx11-devsudo apt-get install xorg-dev