C2115 Practical Introduction to Supercomputing 3rd Lesson -1C2115 Practical Introduction to Supercomputing Petr Kulhánek, Jakub Štěpán kulhanek@chemi.muni.cz National Centre for Biomolecular Research, Faculty of Science Masaryk University, Kotlářská 2, CZ-61137 Brno CZ.1.07/2.2.00/15.0233 3rd Lesson C2115 Practical Introduction to Supercomputing 3rd Lesson -2- Contents  Computer Architecture CPU, memory, graphics system, disks, network, pheripherials  Numerical values representation in digital devices whole numbers, real numbers  From problem to result algorithm, source codes, compilation, program running, programming languages C2115 Practical Introduction to Supercomputing 3rd Lesson -3Computer architecture  CPU, memory, graphics system, disks, network, pheripherials C2115 Practical Introduction to Supercomputing 3rd Lesson -4- Overview CPU Memory I/O Controll bus Data bus Adress bus 1945 von Neumann architecture 1944 Hardward architecture CPU Program memory Data memory I/O John von Neumann, hungarian mathematician, worked in US Harvard Mark I - completed computer from relay, 24 bit instructions ro rw rw • program may change itself • program and data can not be loaded simultaneously • program may not change itself • program and data may be loaded simultaneously C2115 Practical Introduction to Supercomputing 3rd Lesson -5Current computers combine both models. Overview CPU Memory I/O Controll bus Data bus Adress bus 1945 von Neumann architecture 1944 Hardward architecture CPU Program memory Data memory I/O John von Neumann, hungarian mathematician, worked in US Harvard Mark I - completed computer from relay, 24 bit instructions ro rw rw • program may change itself • program and data can not be loaded simultaneously • program may not change itself • program and data may be loaded simultaneously C2115 Practical Introduction to Supercomputing 3rd Lesson -6Typical computer scheme CPU North bridge South bridge USB Mouse, keyboard Real time clock SATA controller hard drives BIOS Graphics system Memory Memory controller PCI Express bus fast access peripherals network (ethernet)Sound PCI bus von Neumann architecture North and south bridge constitute chipset C2115 Practical Introduction to Supercomputing 3rd Lesson -7Typical computer scheme, II CPU North bridge South bridge USB Mouse, keyboard Real time clock SATA controllers hard drives BIOS graphics system Memory Memory controller PCI Express bus fast access peripherals Network (ethernet)sound PCI bus Memory controller becomes part of new processors. C2115 Practical Introduction to Supercomputing 3rd Lesson -8- CPU Processor or CPU - Central Processing Unit is main part of computer; it is complicated sequence circuite that processes machine code from operating memory. Machine code consists from machine instructions of computer programs in memory. www.wikipedia.org CPU Controller ALU ALU (arithmetic and logic unit), processes arithmetic and logic operations Loads machine instructions and data and prepares their processing in ALU Sequence processing of machine instructions is controlled by internal clock tick C2115 Practical Introduction to Supercomputing 3rd Lesson -9Numerical values representation  Whole numbers  Real numbers C2115 Practical Introduction to Supercomputing 3rd Lesson -10Whole numbers Smallest data unit in digital technique is one bit. Words are made from bits. Smallest word is byte, that contains 8 bits. One byte may contain numbers from 0 to 255. 128 64 32 16 8 4 2 1 0 1 0 1 0 1 1 1 = 87 Whole numbers with sign may be expressed too. In such a case one bit is dedicated to sign, remaining bits for number. There are multiple possible implementations. Intel architecture uses two’s complement, that leads to range from -128 to 127. 128 64 32 16 8 4 2 1 0 1 1 1 1 1 1 1 = 127 0 1 0 1 0 1 1 1 = 87 0 0 0 0 0 0 0 1 = 1 0 0 0 0 0 0 0 0 = 0 1 1 1 1 1 1 1 1 = -1 1 0 1 0 1 0 0 0 = -87 1 0 0 0 0 0 0 0 = -128 bit dedicated for number sign C2115 Practical Introduction to Supercomputing 3rd Lesson -11Whole numbers, II Whole numbers with larger range may be expressed by larger words typically consisting of four bytes (32 bit word) or eight bytes (64 bit word). Working with numbers is limited by range, it is not possible to express any large number, avoid overflow of the value. 32 bit whole number unsigned: 0 to 4.294.967.295 32 bit whole number signed : −2.147.483.648 to 2.147.483.647 64 bit whole number unsigned : 0 to 18.446.744.073.709.551.615 64 bit whole number signed : −9.223.372.036.854.775.808 to 9.223.372.036.854.775.807 C2115 Practical Introduction to Supercomputing 3rd Lesson -12Real numbers Real numbers are expressed in floating point format: mantissa exponent In digital technology real numbers are usually expressed according to standard IEEE 754. type width mantissa exponent single precision 32 23 8 double precision 64 52 11 ... 2 1 2 1 2 1 2 1 44332211 mmmmQ  m1,m2,m3 are mantissa bits C2115 Practical Introduction to Supercomputing 3rd Lesson -13Real numbers, II type range Precision single precision ±1,18×10−38 to ±3, 4×1038 Approximately 7 decimal places double precision ±2,23×10−308 to ±1,80×10308 Approximately 15 decimal places Special combination of mantissa and exponent special values may be expressed: 0 positive zero -0 negative zero NaN not a number, e. g. division by zero +Inf positive infinity (number too large to express) -Inf negative infinity (negative number too large to express) Working with real numbers is limited by spread of rounding error. Logical compating operators equal to and not equal to are not appropriate to be used with real numbers (except to comparing with zero). C2115 Practical Introduction to Supercomputing 3rd Lesson -14Exercise LII.1 1. Variable of signed char type(byte with sign) contains number 127. What will be walue if we increment value by one? 2. What will be result of sum of two real numbers in double precission with values: 0,1346978.10-12 1,2312657.106 C2115 Practical Introduction to Supercomputing 3rd Lesson -15From problem to result  Algorithm  Source codes, compilation  Running program  Programming languages C2115 Practical Introduction to Supercomputing 3rd Lesson -16From problem to result ... Problem Result C2115 Practical Introduction to Supercomputing 3rd Lesson -17From problem to result ... Problem Result algorithm source code program calculation C2115 Practical Introduction to Supercomputing 3rd Lesson -18From problem to result ... Problem Result algorithm source code program calculation Flowcharts Language selection, human optimising Compilation, machine optimising Alocation and effective resource usage C2115 Practical Introduction to Supercomputing 3rd Lesson -19From problem to result ... Problem Result algorithm source code program calculation hardware Flowcharts Language selection, human optimising Compilation, machine optimising Alocation and effective resource usage C2115 Practical Introduction to Supercomputing 3rd Lesson -20From problem to result ... algorithm source code program calculation hardware Solving problems using computers (supercomputers) it is necessary to evaluate number of aspects including used hardware and architecture. Flowcharts Language selection, human optimising Compilation, machine optimising Alocation and effective resource usage C2115 Practical Introduction to Supercomputing 3rd Lesson -21Lecture focus ... algorithm source code program calculation hardware Basic problem with creation of programs adreesing complex problems - parallelisation Solving problems using computers (supercomputers) it is necessary to evaluate number of aspects including used hardware and architecture. C2115 Practical Introduction to Supercomputing 3rd Lesson -22Lecture focus ... algorithm source code program calculation hardware Effective running of computational chemistry applications (MetaCentrum, small clusters) Solving problems using computers (supercomputers) it is necessary to evaluate number of aspects including used hardware and architecture. C2115 Practical Introduction to Supercomputing 3rd Lesson -23Programs vs. Scripts Source code program input output Compilation script interpreter input output Program is machine instruction file processed directly by processor. It is created by procedure called compilation from source code. Compiled languages: C/C++ Fortran Script is text file containing commands and special constructions, these are processed by interpreter of scripting language. Skripting languages: bash gnuplot awk JavaScript PHP C2115 Practical Introduction to Supercomputing 3rd Lesson -24Programs vs. Scripts, ... No recompilation Program can generate and run self running code Poor optimization Slower processing Easy optimization Fast processing Recompilation needed Self run code not available Source code program input output Compilation script interpreter input output C2115 Practical Introduction to Supercomputing 3rd Lesson -25Programs vs Scripts Programs dedicated to demanding scientific-technical calculations are allways written in compiled programming languages. These include:  Fortran  C/C++ Scripting languages are not used in such calculations at all, or only in supporting parts of calculation, that are not demanding. C2115 Practical Introduction to Supercomputing 3rd Lesson -26Exercise LII.2 1. Determine rate of programs in languages Fortran, C/C++ and others, that are listed on page: http://en.wikipedia.org/wiki/List_of_quantum_chemistry_and_solid_state_physics_software Plot result in sector graph.