Physics 2660: Fundamentals of Scientific Computing Lecture 1 Announcements • Weekly readings will be assigned and available through the class wiki home page • HW01 will be assigned there as well – Will be assigned on Thursday this week after labs – Due Thursday 4 February • Electronic submission: by 12:00 noon EST • Last week: Lab00 – Work through these exercises if you registered late to the class and have not yet completed them • This week: Lab01 – Will be posted on Thursday 2 Connecting to galileo • The galileo computer cluster is where we will do all of our work this semester – Everyone has an account there now – Do not lose this information or forget how to connect • The best methods for connecting to galileo: – Use ‘ssh’ from the terminal application from one of the desktop PCs in the computer lab – Use ‘ssh’ and ‘NXClient’ from a computer in an ITC hosted computer lab – Use ‘ssh’ and an Xserver app from a personal computer 3 GeBing Help • My office hours: – 3:30-­‐‑5pm Tuesdays in Room 022-­‐‑C (our computer lab) • TA office hours – In Room 022-­‐‑C • Mondays 5:00-­‐‑8:00 pm • Tuesdays 5:00-­‐‑8:00 pm 4 Last Time and This Time • Last time: – Intro to course objectives and expectations • Today: – – – – – – – – – Computer hardware What is an operating system? Example: Linux Command line interface Shells Basic linux commands Intro to the galileo cluster – where we will do all our work! Computer programs and compilers The basics of C: • • • • example program variables and definitions, arithmetic comments inside code functions 5 Computers 6 Computer Hardware CPU and cache Memory fast (aka RAM) fast PCIe Bus (for graphics card) Northbridge fast (aka front side bus, MCH) “MCH” = memory controller hub slow slow Peripherals (keyboard, mouse) Hard drive / disk Southbridge slow (aka back side bus, ICH) “ICH” = I/O controller hub 7 Computer Hardware • Since the advent of the personal computer (PC) in the early 80s, the architecture has not changed much: – Central Processing Unit (CPU): does the computer’s actual work – Northbridge / Southbridge: middlemen, handling fast and slow input/output and inter-­‐‑component communications – Memory: temporary storage of data needed rapidly when running programs – Hard drive / disk: permanent, long-­‐‑term storage of data – Input devices: enables interaction with users – Graphics card: middleman to allow for visual output to be displayed 8 Disk, Memory and Cache • These are confusing to many computing newcomers • Disk: large capacity, slow access • Memory: reasonable capacity, fast access • Cache: meager capacity, really fast access (internal to CPU) – Computers are designed to predict what data from the disk one needs when running a program. This is stored in memory. – Similar prediction game is played when puding select important data into the cache. 9 How a Program Runs • Users write programs in some human-­‐‑readable language – Ex: C, C++, java, FORTAN, etc. • Problem: CPUs don’t speak any human readable language! • Compiler translates into low-­‐‑level instructions for the CPU • CPU gets ordered instructions from memory • Location in memory stored in a register on CPU • CPU executes instructions in number order and moves on CPUs are all different, depending on manufacturer and specifications èinstructions need to be matched to CPU. Different compilers are necessary for different computers. Not an issue on galileo. 10 CPUs • The story behind the CPU is rich and interesting in its own right • We will not get deep into it here and now • There have been many different CPU architectures over the years • Two most prominent modern examples: – x86-­‐‑32 (aka i386 or x86): 32-­‐‑bit CPUs made by Intel and AMD (declining utility) – x86-­‐‑64: 64-­‐‑bit CPUs made by AMD and Intel • Multicore processors – Multiple CPUs (cores) in one motherboard 11 Operating Systems and Linux 12 What is an Operating System? • Beyond the hardware, we need some management structure to tie all the pieces together – This is the role of the operating system • Functions: many handled by the kernel – – – – – middleman for handling I/O middleman for handling memory allocation order of execution of processes parallelization of processes handling of network information • Every standard computer has some sort of operating system • Examples: Windows, Mac OS X, Android, iOS, Linux… hdp://upload.wikimedia.org/wikipedia/commons/e/e1/Operating_system_placement.svg 13 What is Linux? • Linux is an operating system borne out of the desire to have a freely available computer programming environment – In the early days of computing, many saw the need to ensure freely open software – proprietary nature of some software was very off-­‐‑ puding to many developers – Many tools existed (see the GNU project) that were “open-­‐‑source” – Linus Torvalds in 1991 wrote an operating system+kernel and brought together these disparate pieces…and Linux was born • Features: – can run programs for any purpose (no usage restrictions) – can edit programs (open source) – can redistribute without oversight • Rich interesting history starting from Unix, on to GNU and late 60s 70s-­‐‑80s eventually Linux 90s 14 What is Linux? • Linux is an operating system borne out of the desire to have a freely available computer programming environment – In the early days of computing, many saw the need to ensure freely open software – proprietary nature of some software was very off-­‐‑ puding to many developers – Many tools existed (see the GNU project) that were “open-­‐‑source” – Linus Torvalds in 1991 wrote an operating system+kernel and brought together these disparate pieces…and Linux was born • Features: – can run programs for any purpose (no usage restrictions) – can edit programs (open source) – can redistribute without oversight • Rich interesting history starting from Unix, on to GNU and late 60s 70s-­‐‑80s eventually Linux 90s 15 What is Linux? • Linux is an operating system borne out of the desire to have a freely available computer programming environment – In the early days of computing, many saw the need to ensure freely open software – proprietary nature of some software was very off-­‐‑ puding to many developers – Many tools existed (see the GNU project) that were “open-­‐‑source” – Linus Torvalds in 1991 wrote an operating system+kernel and brought together these disparate pieces…and Linux was born • Features: – can run programs for any purpose (no usage restrictions) – can edit programs (open source) – can redistribute without oversight Why a penguin? • Rich interesting history starting from Unix, on to GNU and late 60s 70s-­‐‑80s eventually Linux 90s hdp://www.sjbaker.org/wiki/index.php?title=The_History_of_Tux_the_Linux_Penguin 16 The Command Line • More emphasis in Linux than in other OS’s in user-­‐‑interactions executed through the command line rather than through graphical user interface (GUI) than eg Windows prompt [phys2660@node5 ~]$ [phys2660@node5 ~]$ ls total 9748 drwxr-xr-x 4 phys2660 drwxr-xr-x 4 phys2660 drwxr-x--- 2 phys2660 drwxr-xr-x 11 phys2660 write commands here a command: running a program -lrt phys2660 phys2660 phys2660 phys2660 4096 4096 4096 4096 Feb 22 Apr 4 Aug 10 Mar 20 2007 2007 2007 2008 lib local Desktop usr output 17 Command Line Shells • Virtues of the command line: – Can narrow results with wildcard expressions using “*” – Text interactions are easily reproduced user-­‐‑to-­‐‑user or session-­‐‑to-­‐‑ session (command history) whereas it is more awkward to describe graphical interactions – Allow for aliasing commands to more familiar, user-­‐‑defined choices – Establishment of environment variables for convenient consistent functions – Graphical interactions are nice but typically of limited use – Linux has graphical interfaces but they are inconsistent among different Linux variants – Not every computer has graphical tools installed, especially if it was built for performance – but there will ~always be command-­‐‑line interactions – Many simple things do not need a fancy graphical output (think ‘ls’ instead of Windows Explorer..) 18 The Shell 19 Commands and Arguments ccn4g@galileo /home/ccn4g] ls btag/ Desktop/ mail/ phys2660_spring2012/ public_html/ ROOT_intro/ ccn4g@galileo /home/ccn4g] ls -1 btag/ Desktop/ mail/ phys2660_spring2012/ phys5630_fall2010/ public/ public_html/ ROOT_intro/ ccn4g@galileo /home/ccn4g] ls -lrt total 32 drwxr-x--- 2 ccn4g ccn4g 4096 Aug 10 2007 drwx------ 2 ccn4g ccn4g 4096 Feb 15 2010 drwxr-xr-x 2 ccn4g ccn4g 4096 Feb 16 2010 drwxr-xr-x 2 ccn4g ccn4g 4096 Feb 16 2010 drwxr-xr-x 2 ccn4g ccn4g 4096 Aug 24 2010 drwxrwxrwx 2 ccn4g ccn4g 4096 Sep 19 2010 drwxr-xr-x 5 ccn4g ccn4g 4096 Sep 19 2010 drwxr-xr-x 3 ccn4g ccn4g 4096 Jan 23 14:46 phys5630_fall2010/ public/ Look at the different output of the program ‘ls’ when passing different arguments Desktop/ mail/ ROOT_intro/ btag/ public_html/ public/ phys5630_fall2010/ phys2660_spring2012/ 20 Illustration of the Linux Filesystem 21 Navigating Filesystem and Special Directories • Think of the filesystem as a nested collection of folders, a user has a home location and a current location • How to tell your current location: pwd [phys2660@node1 phys2660_spring2012]$ pwd /home/ccn4g/phys2660_spring2012 • Change to a different directory: cd [phys2660@node1 phys2660_spring2012]$ ls prelab_01 [phys2660@node1 phys2660_spring2012]$ cd prelab_01/ [phys2660@node1 prelab_01]$ • A user’s “home” directory: ccn4g@galileo /home/ccn4g/phys2660_spring2012] echo $HOME /home/ccn4g 22 The PATH Environment Variable ccn4g@galileo /home/ccn4g/phys2660_spring2012] echo $PATH /home/phys2660/usr/bin:.:/usr/lib/qt-3.3/bin:/usr/kerberos/bin: .:/local/bin:/cluster/bin:/common/bin:/bin:/usr/bin:/usr/games: /usr/X11R6/bin:/usr/openwin/bin:/common/CERN/pro/bin: /common/lib/scilab/bin:/common/lib/LASSP/bin:/usr/NX/bin: /opt/real/RealPlayer • Typing commands = running a program • Compiled version of program can be anywhere on the disk • PATH variable tells your shell what locations within the context of the filesystem to look for these executables • For instance, most common Linux commands reside under /bin or /usr/bin 23 Convenience: Command History ccn4g@galileo /home/ccn4g/phys2660_spring2012] history 10 559 9:12 su phys2660 560 9:16 echo $HOME 561 9:16 ls 562 9:16 cd phys2660_spring2012/ 563 9:16 echo $HOME 564 9:19 echo $PATH 565 9:24 history 566 9:24 man history 567 9:24 history --help 568 9:24 history 10 • On galileo, one can use up arrow to access commands in your history 24 Convenience: Manual Pages Within Linux ccn4g@galileo /home/ccn4g/phys2660_spring2012] man ls LS(1) User Commands NAME ls - list directory contents SYNOPSIS ls [OPTION]... [FILE]... DESCRIPTION List information about the FILEs (the current directory by default). Sort entries alphabetically if none of -cftuvSUX nor --sort. Mandatory arguments to long options are mandatory for short options too. -a, --all do not ignore entries starting with . -A, --almost-all do not list implied . and .. • good programs have easy-­‐‑to-­‐‑read manual pages, called man pages. Use: man <commandname> 25 Some Common Linux Commands 26 Editing Files • One of the main tasks you will do is edit human-­‐‑readable files • Many tools available to you to do this: – – – – – nano (lab00) pico (similar to nano) nedit emacs (lab01) See this wiki page for some more discussion 27 Caution on Caps 28 Galileo: Where We Will Do Our Work hBp://galileo.phys.virginia.edu/ 29 Remote Shells • So far we have tacitly overlooked one key component: – What if I am not siding in front of the specific computer / Linux machine I want to work on? – How do I establish a connection to that machine? – Use the network! • Remote shell access: – We will use a program called ssh • Secure Shell • Replaced an old lovable program called telnet, which, in terms of security, had more holes than swiss cheese! Totally Unencrypted • Tip: Never ever type the command telnet or even consider typing it – FYI There is no ssh version for Windows by default but you can install a Windows version for free. See Software for home on the class home page. 30 Galileo: Where We Will Do Our Work • The computer / Linux “machine” where we will do all our work is in the physics department and goes by the name galileo • galileo is actually the head node of a cluster of computers running Linux d-172-25-103-246 /Users/neu] ssh -Y -l ccn4g galileo.phys.virginia.edu ccn4g@galileo.phys.virginia.edu's password: Warning: No xauth data; using fake authentication data for X11 forwarding. Last login: Mon Jan 23 14:08:26 2012 from d-128-100-66.bootp.virginia.edu .cshrc sourced ccn4g@galileo /home/ccn4g] 31 A Note on Our Computer Lab Room 022 Room ?? 32 The Computers in the Lab • The desktop machines in our computer lab run Lubuntu v12.04, kernel v3.2.0-­‐‑24-­‐‑ generic – a “lightweight” Linux operating system based on Ubuntu. – Ubuntu is a popular (most popular?) type of Linux OS distributions with its own desktop environment. – There are several such distributions popular in the community today, Ubuntu is just one The actual nodes on galileo run a Linux distribution called CentOS, release 5-­‐‑11. The kernel is v 2.6.18-­‐‑407.el5 Use ‘lsb_release –a’ 33 Remote Graphics • X Server: running on your local computer • X Client: program to display graphics from any other program • Can be on different computers! 34 Connecting to galileo from other locations/laptops • It would be nice to connect to galileo to do your work from say, your laptop while siding in the library for instance • Many hints on how to do this are located here: hdp://faculty.virginia.edu/comp-­‐‑phys/phys2660/wiki/ doku.php?id=software:sw_main • If you run Windows – I recommend installing and using pudy with Xming – Another option for Windows: NXClient for speedier graphics connections. See me if interested – might be beder than pudy +XMing • If you run Mac OS X – ssh is installed but you still need an X Server to see graphics. See ssh and X11 for Mac 35 We’ll pick up from here next time. Don’t forget lab on Thursday! See you then. 36