Introduction to Supercomputing

Similar documents
Introduction to Supercomputing

Exercise 1: Basic Tools

Introduction to Linux. Woo-Yeong Jeong Computer Systems Laboratory Sungkyunkwan University

Laboratory 1 Semester 1 11/12

Introduction to Linux

CMPT 300. Operating Systems. Brief Intro to UNIX and C

Introduction to Linux

CS356: Discussion #1 Development Environment. Marco Paolieri

Beyond this course. Machine code. Readings: CP:AMA 2.1, 15.4

Introduction to the UNIX command line

Introduction of Linux

Shell Programming Systems Skills in C and Unix

Linux environment. Graphical interface X-window + window manager. Text interface terminal + shell

Unix/Linux Operating System. Introduction to Computational Statistics STAT 598G, Fall 2011

Introduction to Linux Basics

Linux at the Command Line Don Johnson of BU IS&T

CS 3410 Intro to Unix, shell commands, etc... (slides from Hussam Abu-Libdeh and David Slater)

The Unix Shell & Shell Scripts

CSE 303 Lecture 2. Introduction to bash shell. read Linux Pocket Guide pp , 58-59, 60, 65-70, 71-72, 77-80

Introduction to Linux

Problem Set 1: Unix Commands 1

GNU/Linux 101. Casey McLaughlin. Research Computing Center Spring Workshop Series 2018

CSE 15L Winter Midterm :) Review

CS240: Programming in C

Unix/Linux Basics. Cpt S 223, Fall 2007 Copyright: Washington State University

Practical Session 0 Introduction to Linux

CS 261 Recitation 1 Compiling C on UNIX

Introduction To. Barry Grant

CSc33200: Operating Systems, CS-CCNY, Fall 2003 Jinzhong Niu September 26, Nachos Overview

Unix Introduction to UNIX

Introduction to Linux

Oregon State University School of Electrical Engineering and Computer Science. CS 261 Recitation 1. Spring 2011

1. What statistic did the wc -l command show? (do man wc to get the answer) A. The number of bytes B. The number of lines C. The number of words

CENG 334 Computer Networks. Laboratory I Linux Tutorial

Unix Tools / Command Line

Table of contents. Our goal. Notes. Notes. Notes. Summer June 29, Our goal is to see how we can use Unix as a tool for developing programs

CS240: Programming in C. Lecture 2: Overview

Chapter-3. Introduction to Unix: Fundamental Commands

The Shell. EOAS Software Carpentry Workshop. September 20th, 2016

Linux Systems Administration Shell Scripting Basics. Mike Jager Network Startup Resource Center

Intermediate Programming, Spring Misha Kazhdan

Linux Operating System Environment Computadors Grau en Ciència i Enginyeria de Dades Q2

Linux Command Line Primer. By: Scott Marshall

Basic Linux (Bash) Commands

Windshield. Language Reference Manual. Columbia University COMS W4115 Programming Languages and Translators Spring Prof. Stephen A.

Carnegie Mellon. Linux Boot Camp. Jack, Matthew, Nishad, Stanley 6 Sep 2016

COMP s1 Lecture 1

Hitchhiker s Guide to VLSI Design with Cadence & Synopsys

CSC111 Computer Science II

EE516: Embedded Software Project 1. Setting Up Environment for Projects

Systems Programming/ C and UNIX

Introduction to Linux Part 1. Anita Orendt and Wim Cardoen Center for High Performance Computing 24 May 2017

GNU/Linux Course Lesson 1. Puria Nafisi

unix intro Documentation

COSC UNIX. Textbook. Grading Scheme

CSCE 212H, Spring 2008, Matthews Lab Assignment 1: Representation of Integers Assigned: January 17 Due: January 22

Basic Unix Commands. CGS 3460, Lecture 6 Jan 23, 2006 Zhen Yang

Linux Refresher (1) 310/ Fourth Workshop on Distributed Laboratory Instrumentation Systems (30 October - 24 November 2006)

Computer Systems and Architecture

Computer Systems and Architecture

commandname flags arguments

Shell scripting and system variables. HORT Lecture 5 Instructor: Kranthi Varala

BIOINFORMATICS POST-DIPLOMA PROGRAM SUBJECT OUTLINE Subject Title: OPERATING SYSTEMS AND PROJECT MANAGEMENT Subject Code: BIF713 Subject Description:

Computer Science 2500 Computer Organization Rensselaer Polytechnic Institute Spring Topic Notes: C and Unix Overview

Saint Louis University. Intro to Linux and C. CSCI 2400/ ECE 3217: Computer Architecture. Instructors: David Ferry

CSE 351. Introduction & Course Tools

EECS Software Tools. Lab 2 Tutorial: Introduction to UNIX/Linux. Tilemachos Pechlivanoglou

System Programming. Introduction to Unix

Unix basics exercise MBV-INFX410

Hand-on Labs for Chapter 1 and Appendix A CSCE 212 Introduction to Computer Architecture, Spring

COMP 2400 UNIX Tools

Files and Directories

Software Development With Emacs: The Edit-Compile-Debug Cycle

Contents. Note: pay attention to where you are. Note: Plaintext version. Note: pay attention to where you are... 1 Note: Plaintext version...

PRINCIPLES OF OPERATING SYSTEMS

CSCI 2132 Software Development. Lecture 5: File Permissions

TNM093 Practical Data Visualization and Virtual Reality Laboratory Platform

Recap From Last Time:

COMS 6100 Class Notes 3

Lecture 03 Bits, Bytes and Data Types

BGGN 213 Working with UNIX Barry Grant

Systems Programming and Computer Architecture ( ) Exercise Session 01 Data Lab

Unix as a Platform Exercises. Course Code: OS-01-UNXPLAT

Intro to Linux & Command Line

Introduction in Unix. Linus Torvalds Ken Thompson & Dennis Ritchie

CSCI 2132 Software Development. Lecture 4: Files and Directories

Introduction to the C-Language and Programming Environment

INF322 Operating Systems

Using the Unix system. UNIX Introduction

Introduction p. 1 Who Should Read This Book? p. 1 What You Need to Know Before Reading This Book p. 2 How This Book Is Organized p.

Introduction. Let s start with the first set of slides

Recap From Last Time: Setup Checklist BGGN 213. Todays Menu. Introduction to UNIX.

This lab exercise is to be submitted at the end of the lab session! passwd [That is the command to change your current password to a new one]


Command-line interpreters

Scripting Languages Course 1. Diana Trandabăț

Section 1: Tools. Kaifei Chen, Luca Zuccarini. January 23, Make Motivation How... 2

Crash Course in Unix. For more info check out the Unix man pages -orhttp:// -or- Unix in a Nutshell (an O Reilly book).

Introduction to Unix: Fundamental Commands

DATA 301 Introduction to Data Analytics Command Line. Dr. Ramon Lawrence University of British Columbia Okanagan

Transcription:

Introduction to Supercomputing TMA4280 Introduction to UNIX environment and tools 0.1 Getting started with the environment and the bash shell interpreter Desktop computers are usually operated from a graphical user interface (GUI), but they have historically been interacted with by using a command interpreter: a sequence of commands is enter in a terminal. Since supercomputers do not run a graphical interface, As of November 2016, 100% of the supercomputers listed on the Top500 run a flavour of UNIX: 498 GNU/Linux systems and 2 UNIX systems. The most common interactive command interpreter, a shell, is bash, the Bourne Again SHell. The shell can be used interactively in a terminal and to run scripts: it is a very powerful tool which allows the user to interact with all the aspects of the system and perform tasks automatically. This section is a basic introduction to the UNIX environment which covers getting information from the system, navigating in directories, manipulating files and processing text. Several aspect of the interaction with the bash shell: typing sequences of commands and arguments on the command line, auto-completion can be used with the TAB key to expand the name of a command or file, navigation in the history of commands entered can be done with UP/DOWN arrow keys, history of commands can be inspected or searched with CTRL-R, built-in functions can be used for scripting. All commands are documented and the manual pages can be displayed using commands listed in Table 0.1. The man utility is certainly the most important command. Exercise 1. Before starting to navigate, let us inspect the work environment using the commands listed in Table 0.2. Open a text editor: you will use this document to describe your steps and copy sample outputs from the terminal.

Table 0.1: Basic commands: documentation info man Display manual pages in the GNU Texinfo format. Display manual pages in the troff format. Table 0.2: Basic commands: information df du env groups hostname top uname uptime which who whoami Display status of disk space on file systems. Summarize disk usage. Print environment variables. Print group membership of user. Set or print name of current host system. Display system usage information. Print name of current system. Show how long the system has been up. Which - locate a command and display its pathname or alias. Who is logged on the system. Print effective user identity. 1. Open a terminal and inspect information about your user and the system: Print your user name, the machine name (hostname). Use the manual page of uname to find how to print the machine name. Find out to which groups your user belongs to. 2. Inspect the environment variables: Display the environment variables and note the value of SHELL, PATH and HOME. For each of these variables, type echo $VARIABLE, this is how to return the value of an environment variable. Print the current working directory and observe that it is your home directory, i.e the value returned. 3. Find out more about resources: Display the time elapsed since the machine was booted and inspect the resources (memory, processes, disk space). Look at the du manual page and determine the current disk usage of your home directory.

Table 0.3: Basic commands: navigation cd cp find ls mkdir mv pwd rm, rmdir touch, settime Change working directory. Copy files. Find files in the directory hierarchy. List contents of directory. Make directories Move files. Print working directory name. Remove directory entries. Change file access and modification times. Exercise 2. Now that you are familiar with your system, let us navigate and create directories/files. Create a directory named TMA4280 and move inside it. Create a directory named shell and move inside it. Move one level up (two options possible) and create a directory named prog. Move one level up again and type the command ls -lha, inspect the different fields. Open the manual pages of chown, chown and chmod: how are these commands useful? Create a README file using the command touch. Table 0.4: Basic commands: text utilities awk cat grep more, less sed Pattern scanning and processing language. Concatenate and display files. Search a file for a pattern. Display text content with pagination. Stream editor for text manipulation. Exercise 3. Just introducing a few concept for text and file manipulation: Enter the shell directory and create a cat subdirectory. Create three files named 1.txt, 2.txt and 3.txt and write the text foo, bar and braz into them.

Table 0.5: Basic commands: pipes and redirections Pipe operator. > Redirection. < Redirection. Concatenate the content of the three files into the file all.txt. Display it in a pager. Together let us use the different utilities to search and replace text in these files. 0.2 Build and development tools During this course, only the make tools and compilers will be used for the sake of simplicity. Compiler commands and options vary across systems and depend on the programming language, Binaries are created in three main stages: the source code is preprocessed (ex: cpp), then compiled into objects (ex: cc) and finally linked into a library or executable (ex: ld). C Programming Table 0.6: Data types Type char short int long float double Signed or unsigned integer stored on 8 bits, a byte. Integer of a least 16-bit long. Integer of a least 16-bit long, usually 32-bit long. Integer of a least same size as int, usually 32-bit long. Single precision floating-point number of size 32 bits Double precision floating-point number of size 64 bits Types can be signed or unsigned. Exercise 4. Let us create our first program, the famous Hello world! : 1. Go to the progs directory and create a hello0 subdirectory. 2. Create a main.c file, implement a program printing Hello world! in C using the printf.

Table 0.7: Control flow statements and loops Name if { condition } (...) Conditional. if { condition } (...) else (...) Conditional. for (pre;condition;post) {...} Loop. while (condition) {...} Loop. do {...} while (condition) Loop. switch (variable) { case value: body; break;...} Switch between cases. 3. Compile and execute it. We only have a single source file. We can then do the compilation and linking in a single command. gcc -o hello hello.c We might want to turn on compiler optimizations. gcc -o hello hello.c -O2 We might want to include debugging info. gcc -o hello hello.c -g 4. Copy the directory to hello1, create a header and source file to separate the implementation from the main file: list the commands required to build the program and write a Makefile. gcc -c -o hello.o hello.c gcc -c -o utils.o utils.c gcc -o hello hello.o utils.o 5. Modify the program to print Goodbye world! depending on an input argument, then add support for a number of times the message should be printed using int ntimes = atoi(argv[1]); to convert the argument. 6. Copy the directory to hello2, modify the Makefile to create a static library and link. We first link the printing functions into a library

gcc -c -o hello_utils.o hello_utils.c gcc -c -o goodbye_utils.o goodbye_utils.c ar r libutils.a hello_utils.o goodbye_utils.o Then we build the program. gcc -c -o main.o main.c gcc -o hello main.o libutils.a # include <stdio.h> Table 0.8: Main function int main(int argc, char ** argv) { return 0; } Small programming exercises Exercise 5. Matrix-Vector product. Implement a C/C++ program that computes y Ax. Two versions possible. A 0.3 0.4 0.3 0.7 0.1 0.2, x 1.0 1.0. 0.5 0.5 0.0 1.0 Exercise 6. Vector sum. Implement a C/C++ program that creates three real vectors x, y, z, one real number α and computes z αx + y for given x and y (double-precision). First use a fixed-size of 10 then implement a version with dynamic size. Exercise 7. Dot product. Implement a C/C++ program that creates two real vectors x, y R N and one real number α and computes α N i 1 x i y i for given x and y (double-precision). 0.3 Revision control system In this section, we will use the GIT revision control system tool to create a local repository and push it to Github.