<<

Course 1: and

Kristaps Dzonsons

01 December, 2011

Course site: http://kristaps.bsd.lv/minicourse 12 2011

Kristaps Dzonsons Fundamentals of High-Performance Computing Environment

Most high-performance computing environments consist of: UNIX an popular in non-desktop environments C a low-level, minimal hardware purpose-built, high-performance hardware In this lecture, we focus on UNIX and C.

Kristaps Dzonsons Fundamentals of High-Performance Computing UNIX: Why?

UNIX in the Top 500 Supercomputers: 99.8%

Source: top500.org, November, 2011

Kristaps Dzonsons Fundamentals of High-Performance Computing UNIX: Why?

UNIX on Swedish Supercomputers (KTH/PDC) Lindgren Cray XE6 (June 2011, 31/500 ranking): Ekman PowerEdge: Linux Povel Prototype Cluster: Linux Zorn NVIDIA GPU Cluster: Linux Hebb IBM Blue Gene/L: Linux Source: www.pdc.kth.

Kristaps Dzonsons Fundamentals of High-Performance Computing UNIX: What is it?

1969 Unics 1969 Open Source 1971 to 1973 UnixTSS 1 to 4 Mixed/Shared Source 1971 to 1973 1974 to 1975 UnixTSS PWB/Unix 5 to 6 Closed Source 1974 to 1975 1978 BSD 1978 1.0 to 2.0 UnixTSS 1979 7 1979 Unix 32v

1980 BSD 1980 3.0 to 4.1 1981 System III 1.0 to 2.3 1981 1982 Xenix 1982 3.0 1983 BSD 4.2 Sun OS System V 1983 1 to 1.1 R1 to R2 1984 SCO Xenix 1984 UnixTSS 1985 8 SCO Xenix 1985 AIX W286 System V 1986 BSD 4.3 1.0 R3 HP/UX Sun OS 1.0 to 1.2 1986 1.2 to 3.0 SCO Xenix 1987 UnixTSS V386 1987 (Time Sharing HP/UX 1988 System) BSD 4.3 System V R4 2.0 to 3.0 1988 9 to 10 Tahoe SCO Xenix 1989 W386 1989 BSD 4.3 1990 Reno 1990 BSD NET/2 1991 Linux 0.0.1 1991 Sun OS 4 1.x NEXTSTEP/ 386BSD OPENSTEP 1992 1992 1.0 to 4.0 HP/UX NetBSD 6 to 11 Linux BSD 0.8 to 1.0 1993 1993 0.95 to 1.2.x SCO Unix 4.4 to 3.2.4 Unixware FreeBSD 4.4 lite2 1.x to 2.x 1994 1994 1.0 to 1995 2.2.x NetBSD OpenBSD 1995 1.1 to 1.2 OpenServer 1.0 to 2.2 5.0 to 5.04 Solaris 1996 AIX 2.1 to 10 1996 3.x to 6.x 1997 1997 NetBSD 1.3 1998 FreeBSD 1998 3.0 to 3.2 Minix OpenServer Unixware 1999 2.x Mac OS X 5.0.5 to 5.0.7 7.x Linux Server 2000 1999 2.0 to 2.6.x OpenBSD 2.3 to 4.x 2000 FreeBSD NetBSD 2001 to 2004 3.3 to 8.0 1.3 to 5.x 2001 to 2004 Mac OS X HP/UX 11i to 11i v3 2005 10.0 to 10.7 2005 Minix (Darwin) OpenServer OpenSolaris 3.x 6.x 2008.05 and 2006 to 2010 later 2006 to 2010

Source: commons.wikimedia.orgKristaps Dzonsons Fundamentals of High-Performance Computing UNIX: What is it?

login: guest Password : $ h e l p

Kristaps Dzonsons Fundamentals of High-Performance Computing UNIX: How do I use it?

Many resources exist to learn UNIX. Web www.ee.surrey.ac.uk/Teaching/Unix/ ... Books and , The UNIX Programming Environment, Prentice Hall, 1984. Arnold Robbins, UNIX in a Nutshell, O’Reilly Media, 2005. ... When you first log in, run the following: $ h e l p

Kristaps Dzonsons Fundamentals of High-Performance Computing UNIX: Logistics

HHS officially does not yet have a UNIX server for computing. HHS unofficially does have a UNIX server for experimenting and testing. Server: gamelab.hhs.se Operating system: OpenBSD (www..org) Contact me ([email protected]) for access or use the temporary guest account.

Kristaps Dzonsons Fundamentals of High-Performance Computing C: Why?

1 supported by default on most (all?) UNIX systems 2 extremely good support for performance (“up”, distributed computing; “down”, mixing assembly) 3 many open and closed-source domain-specific supporting libraries for 4 bindings for most other modern programming languages 5 familiar syntax (most languages are based upon C)

Kristaps Dzonsons Fundamentals of High-Performance Computing C: What is it?

Source: thomasinterestingblog.wordpress.com Kristaps Dzonsons Fundamentals of High-Performance Computing C: What is it?

i n t main ( void ) { printf(”Hello , world !\ n” ) ; return ( 0 ) ; }

Kristaps Dzonsons Fundamentals of High-Performance Computing C: How do I use it?

Many resources exist to learn C. But really only one. Books Brian Kernighan and , The C Programming Language, Prentice Hall, 1988.

Kristaps Dzonsons Fundamentals of High-Performance Computing Case Study

Consider a trivial primality test (trial by division). Run-time: O(nm) where m is the mean input value. f o r ( i = 0 ; i < sz ; i ++) { f o r ( j = 2 ; j < p [ i ] − 1 ; j ++) i f (0 ==p[i] % j) break ; i f ( j == p [ i ] − 1) p r i n t f ( ”%\n” , p [ i ] ) ; }

Kristaps Dzonsons Fundamentals of High-Performance Computing Case Study: Problem and Solutions

Assume the is fixed. How can we improve?

1 Faster processors. 2 More processors (problem: fairness). 3 Micro-optimising (branch prediction in the loop). 4 Vector-parallelism (loop-unrolling).

Kristaps Dzonsons Fundamentals of High-Performance Computing Case Study: Source

#i n c l u d e #i n c l u d e

#i n c l u d e #i n c l u d e #i n c l u d e

s t a t i c v o i d f ( i n t , i n t ∗ , i n t , i n t );

i n t main ( v o i d ) { i n t s z = 0 , ∗p = NULL , v ;

w h i l e (1 == scanf(”%d”, &v)) { p = realloc(p, (sz + 1) ∗ s i z e o f ( i n t )); p [ s z++] = v ; }

i f (0 == ()) f(0, p, 0, sz / 2); i f (0 == fork()) f(1, p, sz / 2, sz);

wait(NULL); wait(NULL); f r e e ( p ) ; e x i t ( EXIT SUCCESS); }

Kristaps Dzonsons Fundamentals of High-Performance Computing Case Study: Source

s t a t i c v o i d f ( i n t id , i n t ∗p , i n t s t a r t , i n t s z ) { ∗ f ; char buf [ 6 4 ] ; i n t i , j ;

snprintf(buf , s i z e o f (buf), ”example0.%d.dat”, id);

f = fopen(buf, ”w”);

f o r ( i = s t a r t ; i < s z ; i ++) { f o r ( j = 2 ; j < p [ i ] − 1 ; j ++) i f (0 ==p[i] % j) break ; i f ( j == p [ i ] − 1) fprintf(f, ”%d\n” , p [ i ] ) ; }

f c l o s e ( f ) ; f r e e ( p ) ; e x i t ( EXIT FAILURE); }

Kristaps Dzonsons Fundamentals of High-Performance Computing Case Study: Environment

Consider computing the value of function f for n numbers. $ scp example0.c gamelab.hhs.se: $ ssh [email protected] [email protected] ’s password: $ cc −Wall −o example0 example0.c $ ./example0 $ s o r t −n example0 . ∗ . dat >example0.dat $ e x i t Connection to gamelab.hhs.se closed. $ scp [email protected]:example0.dat .

Kristaps Dzonsons Fundamentals of High-Performance Computing Case Study: Benchmark

How do we begin to analyse performance? $ j o t −b 93563 10000 | time ./example0 0m8.76s real 0m15.86s user 0m0.27s system We just doubled performance!

Kristaps Dzonsons Fundamentals of High-Performance Computing