Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
платформа.docx
Скачиваний:
3
Добавлен:
01.07.2025
Размер:
1.91 Mб
Скачать

2.3.Specify required elements of the program in mpi

We cannot tell which "Hello world" line was printed by which process. To identify a process we need some sort of process ID and a routine that lets a process find its own process ID. MPI assigns an integer to each process beginning with 0 for the parent process and incrementing each time a new process is created. A process ID is also called its "rank".

MPI also provides routines that let the process determine its process ID, as well as the number of processes that are have been created.

It is important to realize that separate processes share no memory variables. They appear to be using the same variables, but they are really using COPIES of any variable defined in the program.

As a result, these programs cannot communicate with each other by exchanging information in memory variables. Instead they may use any of a large number of MPI communication routines. The two basic routines are:

  • MPI_Send, to send a message to another process, and

  • MPI_Recv, to receive a message from another process.

2.4.Prove the importance of working with time in mpi. Describe procedure Measurements time of the program portion.

2.5.Passing arguments specify flow function

  1. function to memoize

  2. equality function for arguments

  3. equality function for return type

Two main changes to enter the type:

  1. Since memoize is a generic function who's return type depends on the type parameters, you need to include a return type. If you don't, Flow will infer a return type, and Flow only infers monomorphic types, not polymorphic types.

  2. Add an upperbound for ArgsType to say it's either a tuple or an array.

Functions have two places where types are applied: Parameters (input) and the return value (output).

Using inference, these types are often optional:

function concat(a, b) {

return a + b;}

concat("foo", "bar"); // Works!

concat(true, false); // Error!

Sometimes Flow’s inference will create types that are more permissive than you want them to be.

function concat(a, b) {

return a + b;}

concat("foo", "bar"); // Works!

concat(1, 2); // Works!

There are three forms of functions that each have their own slightly different syntax.Function Declarations. Here you can see the syntax for function declarations with and without types added.

2.6.Provide examples of basic stream control operation

Streams are an important component of small-program design and unix philosophy but there are many other important abstractions worth considering.

I/O in node is asynchronous, so interacting with the disk and network involves passing callbacks to functions. 

There are 5 kinds of streams: readable, writable, transform, duplex, and "classic".

All the different types of streams use .pipe() to pair inputs with outputs.

.pipe() is just a function that takes a readable source stream src and hooks the output to a destination writable stream dst:

src.pipe(dst)

.pipe(dst) returns dst so that you can chain together multiple .pipe() calls together:

a.pipe(b).pipe(c).pipe(d)

which is the same as:

a.pipe(b);

b.pipe(c);

c.pipe(d);

This is very much like what you might do on the command-line to pipe programs together:

a | b | c | d

Readable streams produce data that can be fed into a writable, transform, or duplex stream by calling .pipe():

readableStream.pipe(dst)