LECTURES (Version January 18 2018)

Writing parallel programs in C/C++, in which hundreds and hundreds of data items are sent between processes, it is useful to gather them initially in a container and only then send these containers as the wholes. One of the original intentions of our lectures was to teach attendees how such a container can be programmed, how genetic algorithms can be parallelized, and to prepare the attendees for studying such environments as, e.g., this, etc.

One can write parallel programs either in Fortran or C/C++ and launch them on clusters or supercomputers under Linux or AIX. On the other hand, scientific computations usually have very complicated logical structure and so their debugging is typically very demanding. Because of this, all sample programs of our lectures are universal in that sense that the same code will run under C++Builder, Visual Studio, Linux, and AIX. Thanks to it, they can be debugged in the Integrated Development Environment (IDE) of C++Builder or Visual Studio and then they can be copied to a cluster or a supercomputer without any changes and launched. It is achieved with the help of preprocessor directives, which are colored in brown in PDF listings of all programs. Therefore, beginners can ignore the blocks of the code in brown during the first reading, the more so that there are only three variants of such blocks used in the samples. They are written in such a way to can be copied en bloc to other programs. Due to this, attendees can work in C++Builder, Visual Studio, or Linux during the lecture.

Instalation files: The free installation files of Visual Studio Community 2017 can be downloaded here. It is recommended to install all new releases under your non-administrator account in case you use any. If your Visual Studio could not be launched under your non-administrator account after updating to a newer release, you should delete a file privateregistry.bin from C:\Users\myuser\AppData\Local\Microsoft\VisualStudio\15.0_some_number (where myuser is your non-administrator account) and launch Visual Studio anew. You can also let your Visual Studio repair.

The installation files of MS MPI can be downloaded here. It is necessary to restart your computer after the installation of MS MPI in order you can test its functionality according to this.

The most important samples are emphasized by !!! and the most demanding ones by *, ** or ***. The samples indicated by + only comprise a database of programs that can appear to be useful sometime in the future: almost all of them will be skipped during the lecture.

The basics of C/C++ (Version January 18 2018)

Recommended textbooks: Herout, P.: Učebnice jazyka C, 1. díl (www.martinus.sk/?uItem=22732). Beginners are recommended to read almost all chapters of this textbook.

Hello world (C++Builder, Visual Studio, Linux, PDF (hello_class.h, hello_class.cpp, hello_world.cpp)):
Because this program consists of 3 files - hello_world.cpp, hello.cpp, and hello.h - you have to compile it in Linux by

and launch it by

while it will only be g++ if_kvadr_rovnica.cpp -o if_kvadr_rovnica and ./if_kvadr_rovnica in case of the sample program 1A below.

In C++Builder you can push a speed button Open Project, locate Proj_hello_world.cbproj, double click on hello_world.cpp and hello.cpp in File subwindow on the right, and push the button with a green arrow. In Visual Studio you can push Open Project / Solution, locate helloworld.sln, unfold Header Files and Source Files in Solution Explorer on the left, double click on hello_world.cpp, hello.cpp, and hello.h in Solution Explorer, and push the button with a green arrow. Alternatively, for compilation, you can select Project > Build Proj_hello_world (Shift+F9) in C++Builder or Build > Build Solution (F7) in Visual Studio. If there were errors in your program, it would be described in Messages resp. Output at the bottom of your IDE. You can double click on the error message to locate its position in your program or you can select some error message and push F1 to see a help. When you correct the bug, you can push the button with a green arrow to launch the program.

You can create a new project performing the following steps. C++Builder: Select File > New > Other... > Console Application and retain the default setting on a subwindow New Console Application. Then push a speed button Save All and select appropriate names and location for files of the new project. Visual Studio: Select File > New > Project... and on a subwindow New Project, select Windows Console Application and appropriate name and location for the new project.

Synopsis: PDF.

Sample programs of the lecture (source files, flowchart, and commentaries):

Useful tables: Keywords.

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Object-oriented programing in C++ (Version November 29 2017)

Recommended textbooks: Eckel, B.: Thinking in C++, Volume 1 (www.mindviewinc.com/Books/downloads.html, www.msedv.at/books/eckel/, or mindview.net/Books/DownloadSites). If some sample program taken from this textbook to the lecture needed further commentaries, they could be found in the textbook.

Sample programs of the lecture (source files, diagrams, and commentaries):

Useful tables: Inheritance, Overloading, and Operators in C and C++.

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

MPI for C/C++ (Version January 16 2018)

MPI_Routines (taken from www.mpich.org/static/docs/v3.2/www3).

Settings for Visual Studio (Do not forget to properly set the solution platform x86 or x64 in a memo at the left-upper corner in IDE of your project!).

Sample programs of the lecture (source files, diagrams, and commentaries) (Version December 1 2017):

sunflovers