# JetCracker

Life-time learner's blog

## [MPI] Calculating integral in parallel

Problem: write a programme to calculate the integral with MPI:



Actually, the programme must be able to calculate any integral. But before writing a parallel programme, we should write a serial one to make sure it works and the algorithm is correct.

There are plenty of algorithms for calculating integrals. One of the most advanced (efficient), among non-parallel, is the method of local stack. Read more of this post

## [MPI] Solving the advection equation in parallel

In chemistry, engineering and earth sciences, advection is a transport mechanism of a substance or conserved property by a fluid due to the fluid’s bulk motion.

$\frac{\partial\psi}{\partial t}+\nabla\cdot\left(\psi{\bold u}\right)=0$

In my course on Parallel programming, I had to implement a solution to a particular advection equation, with  the initial and boundary conditions defined. Read more of this post

## [Presentation] Artificial heart.

Hello! Sorry, I don’t have time to write anything here at the moment.

Have a look at my presentation on Engineering – Artificial Heart. This presentation is based on the article “Artificial Heart” which was taken from the book “Encyclopedia of Heart Diseases” by Dr. Gabriel Khan. I also used some materials from Wikipedia. The pictures and photos are from the Internet.

Again, we have another presentation here. The topic for today is Education. Let’s see what presentation I created.

[Greeting] Good morning, everyone. My name is Anton Danshin. I’m a student of Moscow Institute of Physics and Technology.

[Why?] The topic is very interesting and the information I’ll give you might be useful for those students who want to continue their education abroad.

[What?] There is an infinite variety of academic grading systems in different counties and there is no way to cover all these systems. And I will cover only common ones.

First of all, I’ll tell you what an academic grading is. Secondly, I’d like to tell a few words about the system that is used in Europe. Thirdly, I’ll familiarize you with the american grading system. Then I’ll tell a little bit about Russian system and systems used in the countries of CIS. And finally, I’ll highlight the main points of my presentation and make a conclusion.

[How?] The presentation won’t take long – just about 10 minutes. You may ask your questions at the end.

Lets get started!

What is an academic grading? The answer is quite obvious. The academic grading is the way of measurement of student’s knowledge and skills in a certain subject which he or she acquired during study at educational institution.

A perfect academic grading system should provide an objective assessment of the quality of student’s knowledge, rather than the quantity. Let’s see what functions a perfect grading system should fulfil.

• Firstly, it should help to compare stated aims with results achieved by a student.
• Secondly, it should reveal the main difficulties which students have.
• Thirdly, it should determine the quality of teachers work.
• And finally, a perfect grading system should motivate student to study.

Now that we know what academic grading is all about and what it stands for, we can move on to the next point of my presentation.

In Europe the most common grading is so called ECTS – European Credit Transfer and Accumulation System. It is a standard for comparing the study attainment and performance of students of higher education across the European Union and other collaborating European countries.

For successfully completed studies, ECTS credits are awarded. One academic year corresponds to 60 ECTS-credits that are equivalent to 1500–1800 hours of study in all countries irrespective of standard or qualification type. To get bachelors degree it is necessary to have at least 180 – 240 ECTS-credits, and 300 credits for masters.  ECTS also includes a standard ECTS grading scale, intended to be shown in addition to local (i.e. national) standard grades. The ECTS grading scale is shown on the slide.

In the Unated States of America they also have letter grades scale but it is very different from European one. They use 4-points scale. In addition, there is not any rating system, the Grade Point Average (GPA) is calculated instead.

Most graduate schools require a 3.0 (B) average to take a degree, with C or C- being the lowest grade for course credit. Most undergraduate schools require a 2.0, or C average to obtain a degree with a minimum of D or D− to pass a course. But this all depends on laws of a certain state.

Russia

That’s all about the USA. Let’s move on to the next point and see what we have in Russia and some neighbouring countries. As we can see from the table, some countries from Eastern Europe tend to have 10-point scale. Our country still has 5 point scale, but is it enough to represent the knowledge of students? Or there is no difference? These (actually difficult) questions bring me to the end of my presentation.

Conclusion

Let’s go over the main points I covered.

• Academic grading is a way to assess the quality of students’ knowledge and skills.
• A perfect grading system has to fulfil a lot of functions and there is obviously no the perfect one.
• There are a lot of different grading systems.
• Europe: ECTS
• the USA: 4-point scale + GPA
• Russia: 5-point scale

It’s quite difficult to decide which one is the best. But I think that the main problem is not in the grading scale at all! The main problem is in student’s ability and desire to study.

As the proverb says: ‘You can bring a horse to the water. But you can’t make it drink’. In other words, you can design any kind of grading scale but the final choice to study or not is up to students.

Let me know if you find a mistake. Good luck with your English!

Anton Danshin

## MPI: Calculating sum 1/n! in parallel

Hello.
I’ve spend several hours to understand how to programme in MPI and how to calculate the sum of 1/n! in parallel (it’s my task from university). (By the way, why do I have study this shit? I don’t think I will be working in the field of parallel/distributed computing.)

But finally I wrote a decent programme, which showed not bad results. And I am very excited to share with you! Read more of this post

## How to install MPI in Ubuntu

I am starting a series of articles devoted to distributed computing that we are now studying at MIPT. For programming we will use MPI.

Message Passing Interface (MPI) is a standardized and portable message-passing system designed by a group of researchers from academia and industry to function on a wide variety of parallel computers. The standard defines the syntax and semantics of a core of library routines useful to a wide range of users writing portable message-passing programs. We can use it for creating programmes for distributed computing systems (parallel computing).

## Presentation: Software design patterns

Hello.

For my previous English class a had a task to create a presentation on design. This topic was pretty hard for me because I am not very good at describing design and I am not an expert in it!

I’ve spent nearly 2 hours just to choose what I wanted to speak about in my presentation. And finally I came up with an idea to create a presentation about software design patterns. I know, it is rather boring topic to speak about because is quite technical, but I’m just know about it way more than I know about design of furniture or design of cars.

### Presentation: Software Design Patterns

Good morning everyone. My name is Anton. I’m a student of MIPT. Today in my presentation, I’m going to speak about Software Design patterns. My presentation will take about 15 minutes. Feel free to interrupt me and ask a question.

The plan of my presentation is shown on the slide. Let’s start!

### Design Patterns

Simplicity is the soul of efficiency.
— Austin Freeman, “The Eye of Osiris”

The first thing I want to tell you about is what a software design pattern is. Does anyone know the answer to this question?

In software engineering, a design pattern is a general repeatable solution to a commonly occurring problem in software design. A design pattern isn’t a finished design that can be transformed directly into code. It is a description or template for how to solve a problem that can be used in many different situations.

Now that we know what it is we can move on to the question “Why do we use design patterns?”

### Why do we use design patterns?

Design patterns can speed up the development process by providing tested, proven development paradigms. Effective software design requires considering issues that may not become visible until later in the implementation. Reusing design patterns helps to prevent subtle issues that can cause major problems in the future.

In addition, patterns allow developers to communicate using well-known, well understood names for software interactions. More than that, common design patterns can be improved easily.

Also, design patterns improve code readability for coders and solution architects. The code becomes understandable and maintainable.

So, the design patterns is actually a good thing! And there are over 30 patterns to solve almost any problem. This brings me to the next point.

### Classification of design patterns

There are a lot of design patterns and they all are divided into four classes: creational, structural, behavioural, and concurrent.

Creational design patterns

These design patterns are all about class instantiation. This pattern can be further divided into class-creation patterns and object-creational patterns. While class-creation patterns use inheritance effectively in the instantiation process, object-creation patterns use delegation effectively to get the job done.

Structural design patterns

These design patterns are all about Class and Object composition. Structural class-creation patterns use inheritance to compose interfaces. Structural object-patterns define ways to compose objects to obtain new functionality.

Behavioural design patterns

These design patterns are all about Class’s objects communication. Behavioural patterns are those patterns that are most specifically concerned with communication between objects.

Concurrent patterns

These patterns help to control the execution flow of the applications and provide solutions to problem of concurrent access.

Now, lets have a look at an example of a simple but very useful creational design pattern – Singleton

SINGLETON

Intent

• Ensure a class has only one instance, and provide a global point of access to it.
• Encapsulated “just-in-time initialization” or “initialization on first use”.

Problem

Application needs one, and only one, instance of an object. Additionally, lazy initialization and global access are necessary.

Discussion

Singleton should be considered only if all three of the following criteria are satisfied:

1. Ownership of the single instance cannot be reasonably assigned
2. Lazy initialization is desirable
3. Global access is not otherwise provided for

The example of the implementation of Singleton in Java you can see on the slide.

The main disadvantages of this implementation are that deleting a Singleton class/instance is a non-trivial design problem and this implementation is not thread-safe.

OK. Design patters are good. But what about the other side of the coin? Let’s  have look at its bad points.

### Criticism

The concept of design patterns has been criticized by some in the field of computer science.

Targets the wrong problem

The need for patterns results from using computer languages or techniques with insufficient abstraction ability. Under ideal factoring, a concept should not be copied, but merely referenced. But if something is referenced instead of copied, then there is no “pattern” to label and catalogue. Paul Graham writes in the essay Revenge of the Nerds.

Peter Norvig provides a similar argument. He demonstrates that 16 out of the 23 patterns in the Design Patterns book (which is primarily focused on C++) are simplified or eliminated (via direct language support) in Lisp or Dylan.

Lacks formal foundations

The study of design patterns has been excessively ad-hoc, and some have argued that the concept sorely needs to be put on a more formal footing. At Oopsla 1999, the Gang of Four were (with their full cooperation) subjected to a show trial, in which they were “charged” with numerous crimes against computer science. They were “convicted” by ⅔ of the “jurors” who attended the trial.

The idea of a design pattern is an attempt to standardize what are already accepted best practices. In principle this might appear to be beneficial, but in practice it often results in the unnecessary duplication of code. It is almost always a more efficient solution to use a well-factored implementation rather than a “just barely good enough” design pattern.

And final bad point is that design patterns are very bad when they are used improperly or overused. So, DO NOT OVERUSE IT!

Let’s move on to my next point which I want to cover in my presentation.

### Anti-patterns

Anti-patterns are complete opposite to patterns. Patterns, as you now know, are the examples of good programming practice. In contrast, anti-patterns are the examples of mistakes, which are made in solving different problems.

Here are the most common anti-patterns:

1. Copy and Paste Programming
2. Spaghetti Code
3. Golden Hammer
4. Magic Numbers
5. Hard Code
6. Soft Code
7. Reinventing the Wheel
8. Reinventing the Square Wheel
9. Blind Faith
10. Brute Force Coding
11. Boat Anchor
12. God Object
Choose the one you like, and I’ll explain what this anti-pattern means.

### Conclusion

Now, I’d like to make a conclusion to my whole presentation. Let’s go over the main points.

1. Design pattern is a general solution to a commonly occurring problem in software design
2. Using design patterns makes your code better
3. Design patterns are divided into:
• Creational
• Behavioral
• Structural
• Concurrent
4. Do NOT OVERUSE design patterns
5. Creating your software avoid anti-patterns.

### Sources:

Here you may find all about software design patterns and anti-patterns.

Thank you very much for your attention! 🙂