LECTURES (Version January 23 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 lectures.

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.

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 23 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 simplest (Visual Studio, PDF): this is the simplest version of Hello world in our lectures. It runs only in Visual Studio. If you wanted to make it running under various operating systems and IDEs, it would be sufficient to use preprocessor directives as in the next sample.

Hello world basics (C++Builder, Visual Studio, Linux, PDF):
You can compile this code in Linux by

and launch it by

In C++Builder you can push a speed button Open Project, locate Proj_hello_world_basics.cbproj, double click on hello_world_basics.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 hello_world_basics.sln, unfold Source Files in Solution Explorer on the left, double click on hello_world_basics.cpp in Solution Explorer, and push the button with a green arrow. Alternatively, for compilation, you can select Project > Build Proj_hello_world_basics (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.

Basic types and operators: Fundamental_types, Data_type_ranges, Data_type_constants, Standard_types, and Operators in C and C++.

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

All samples (C++Builder, Visual Studio, Linux).

Hello world classes: Because the sample 7A consists of 3 files - hello_world_classes.cpp, hello_class.cpp, and hello_class.h - you have to compile it in Linux by

and launch it by

Useful tables: Keywords.


Object-oriented programing in C++ (Version January 23 2018)

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 and Overloading.


MPI for C/C++ (Version January 23 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):

All samples (Visual Studio, Linux).