Computer Science 400
Parallel Processing and High Performance Computing

Fall 2017, Siena College

Lab 0: Setting Up
Due: 11:59 PM, Friday, September 8, 2017

This first lab exercise is intended to get you set up to use our accounts on a few systems, to familiarize you with git and GitHub, and to make sure you can edit, compile, and run a simple C program.

GitHub for Source Code Control

If all goes well, we will be using the git distributed version control system for nearly all of our work this semester.

If you are not familiar with the basic idea of version control, this brief video is a good place to start.

In particular, we will be using git repositories hosted on GitHub which are managed by GitHub Classroom.

If you do not already have an account at GitHub, please visit https://github.com/ and create one. Please use your college-issued email address when you create your account (or, be sure your college-issued email address is associated with your account if you already have one), since GitHub offers free unlimited private repositories for academic use. Also, a username that incorporates your real name is probably a good idea. Building up a portfolio of GitHub repositories that contain your work is a good way to impress future potential employers, so make it a username you won't be embarrassed to put on a resume.

Computer Accounts

We will be using a number of computing resources this semester. All of our programming will use C in Unix-like environments. One of our primary development platforms, a 20-core system, only just arrived and is not yet configured. We'll move to that soon.

FreeBSD server

Until that system is configured, we'll be using a FreeBSD server (the same one that serves our course web pages) named blizzard.teresco.org. Some of you have accounts on blizzard from previous course work. Either way, you will need an account and will need to remember your password. Those who need an account created or their password reset should see the instructor.

XSEDE Supercomputing Resources

We are also fortunate to have been granted access to supercomputing resources through the National Science Foundation-funded XSEDE program (the Extreme Science and Engineering Discovery Environment).

To access those supercomputing resources, you will first need to create an account on the XSEDE User Portal. Please visit that site, click on the "Create Account" button, and fill out the form. Once your account has been created successfully, please email it to jteresco AT siena.edu so you can be added to the project allocation and can gain access to the available resources.

Once everyone's accounts are set up, we will have a lab exercise to try out the "Stampede2" system at the Texas Advanced Computing Center (TACC), University of Texas at Austin. This is a system with 1,143,530 CPU cores!

Trying out GitHub and blizzard

Before you can do this task, you need to have an account on blizzard and know your username and password. You also need to have the GitHub classroom link (sent by email) to be able to create your repository for this lab's work.

Log into your account on blizzard.teresco.org with Secure Shell. From Windows, one way to do this is to use PuTTY. From a Mac or a Unix/Linux system, you will use the ssh command in a terminal window. Once successfully connected, you should see a prompt that looks something like this:

[jcool@blizzard ~]$ 

Next, create a directory (that's our grown up computer scientist Unix word for what Microsoft and Apple want you to call a "folder") for your work for this course. If you want to name it "parallel", use the command:

mkdir parallel

Then change your working directory to that new directory:

cd parallel

Now, create your GitHub repository for this lab. To do so, open a browser window at https://github.com and sign in. In the same browser, visit the link you received in your email. This should bring you do a page where you can "Accept the setup-lab assignment". Do so. If that worked, the next page will have a link to a GitHub URL which is your copy of this lab's repository. Follow it.

You are now on the main page for your repository. You should see a screen that looks like this:

Let's add your name to the README.md file in the repository on GitHub. Click on its name, then in the window that comes up, click on the little pencil icon near the "Raw", "Blame", and "History" buttons to bring up GitHub's simple editor.

You'll be editing in a simple markup language called Markdown (please click here and read about it). Add your name to the file, then scroll down to the bottom and "Commit changes". You can leave the radio buttons above that set to "Commit directly to the master branch." Once you've commited your changes, you should now see the file displayed with your additions.

To get back to the main view of your repository, click on the "<> Code" tab.

Next, click on the green "Clone or Download" and copy the URL that pops up. Go back to your terminal window on blizzard and type

git clone ...

replacing ... with the URL you copied from the web page.

When prompted, log in with your GitHub credentials. You should then see some messages, and a new directory will be created. Change into that directory with the cd command, then list the contents with ls. You should see two files: README.md and hello400.c, which are the same two files that were in the repository on the GitHub site.

Before going further, we have a bit of configuration to do for your git setup on blizzard. Issue these commands (replacing with your own GitHub username and your email, of course) at the terminal prompt:

git config --global user.name "jcool"
git config --global user.email "jcool@teresco.org"

One of those files is a C program, so let's compile and run it on blizzard. You should be in the directory with the README.md and hello400.c files. First, let's take a look at the C program. You can see its contents with the command

cat hello400.c

We'll modify the file in a minute, but first let's compile and run this version. At your command prompt, type

gcc hello400.c

If this is successful, you should just get your prompt back in a second or so. This is typical of Unix: if a command is completed successfully, you will not get any output. "No News is Good News."

Run the ls command, and notice a new file listed: a.out. This is an executable file. To execute it, you can issue the command

./a.out

If all goes well, you should see the "Hello, CSIS 400 world!" printout.

Now, make a couple changes to the C program. Launch the Emacs editor to make those changes.

emacs hello400.c

For now, just use the arrow keys to navigate around (the mouse won't work, and the text-based menus at the top are more trouble than they're worth) and put your name in the comment at the top, and add at least one more printf statement to print additional messages. When you're done, type Ctrl-x then Ctrl-s to save your file, then Ctrl-x then Ctrl-c to exit Emacs.

Recompile and re-run your program to make sure it works. If it does, run it one more time, but this time capturing its output in a file:

./a.out > hello400.txt

If you list the files in your directory, you'll now see hello400.txt as well. You can see its contents with the cat command.

So you now have two copies of the repository, one on the GitHub server (the "origin" repository) and one in your account on blizzard (a "clone"). Later in the semester, you will have multiple clones in various places (our 20-core system here, the Stampede system in Texas, maybe your own computer) and will want to be able to keep them in sync. Your clone has changes (2 new files, and one modified file) that are not in the origin on GitHub.

git knows what's changed, so let's ask it:

git status

You should see something like this:

On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

	modified:   hello400.c

Untracked files:
  (use "git add <file>..." to include in what will be committed)

	a.out
	hello400.txt

no changes added to commit (use "git add" and/or "git commit -a")

This means there is one file that git "knows about" that has changed: hello400.c, and there are two files that git doesn't know about: a.out and hello400.txt.

Since a.out is an executable file that gets generated from the C file, we don't want to store that in our repository. We'll ignore it for now. But the hello400.txt file is one we want to put in the repository (only because it's part of the grading). We can tell git to start tracking it with

git add hello400.txt

If you rerun the git status command, it should now be listed as a new file.

Once we're happy with a change or set of changes to files in our repository, we need to commit those changes to the repository. In this case, we will issue a command for each file, with an appropriate message in each:

git commit -m "Added name and extra printout." hello400.c
git commit -m "Required output capture." hello400.txt

Now a git status command should show something like this:

On branch master
Your branch is ahead of 'origin/master' by 2 commits.
  (use "git push" to publish your local commits)
Untracked files:
  (use "git add <file>..." to include in what will be committed)

	a.out

nothing added to commit but untracked files present (use "git add" to track)

Your changes have been committed to the clone, but they are not yet back up on the origin repository on GitHub. To do that, you will use

git push

This is short for "git push origin master", which says push the changes from this repository to the origin on the master branch. So far, we have not created any branches, so everything is on the master.

If your push command is successful, you should now see your changes reflected on GitHub (in the web page).

One last step: let's make a change right in the GitHub repository and then pull it down to our clone on blizzard. Edit the README.md file again to include a bulleted list of the git commands you used in this lab. Use Markdown to make it look pretty. When you are done, include a meaningful commit message and use the green button to commit your changes.

Now the repository on GitHub has changes that aren't in your clone. Back on blizzard, we want to "pull down" the changes:

git pull

Now, your README.md on blizzard should include the changes you made on GitHub.

Submitting

Your submission requires that all required delierables are committed and pushed to the master for your repository's origin on GitHub. That's it! If you see everything you intend to submit when you visit your repository's page on GitHub, you're set.

Grading

This assignment is worth 15 points, which are distributed as follows:

> FeatureValueScore
XSEDE Portal account created 3
GitHub account/accept assignment 2
README.md has name 2
hello400.c changes 3
hello400.txt file 2
README.md has command list 3
Total 15