LIBDVM2 (1158351), страница 9

Файл №1158351 LIBDVM2 (Раздаточные материалы) 9 страницаLIBDVM2 (1158351) страница 92019-09-18СтудИзба
Просмтор этого файла доступен только зарегистрированным пользователям. Но у нас супер быстрая регистрация: достаточно только электронной почты!

Текст из файла (страница 9)

*LoopRefPtr - pointer to the parallel loop.

The function endpl_ completes the parallel loop execution and forces merging the parallel branches to the parental one. The Run-Time Library automatically deletes all objects created inside the parallel loop. The exception is static objects. (that is, the parallel loop is a program block beginning with the function crtpl_ call, see section 8).

When the control exits from the parallel loop, the pointer to the loop is undefined and so can not be used at any Run-Time Library call.

The function returns zero.

10. Representation of the program as a set of executed in parallel subtasks.

A parallel subtask is a pair (<abstract machine>, <processor subsystem>). A subtask group is an abstract machine representation, each element corresponding to a processor subsystem. A parallel subtask is in execution state (active) at the processor belonging to the subtask processor system, if the subtask abstract machine is current. Each processor always executes the only subtask with the (current) abstract machine mapped on the processor.

A subtask can be created by the functions, mapping an abstract machine representation onto a processor subsystem (distr_, redis_, mdistr_, mredis_), considered in section 5. The created in such a manner subtasks are activated when entering a parallel loop iteration.

Let us consider now creation of the parallel subtasks by explicit specifying of the correspondence <abstract machine>  <processor subsystem> and a way of the subtask initialization.

10.1. Mapping abstract machine (subtask creation).

long mapam_ (

AMRef
PSRef

*AMRefPtr,
*PSRefPtr );

*AMRefPtr

- pointer to abstract machine to be mapped.

*PSRefPtr

- pointer to the processor system, determining a structure of the processors, assigned to the abstract machine (execution area of the created subtask).

The function returns zero.

10.2. Starting subtask (activation).

long runam_ (AMRef *AMRefPtr);

*AMRefPtr - pointer to the abstract machine of started subtask.

After subtask startup its abstract machine becomes the current one.

The function returns the values:

0

- the subtask is not started (the subtask abstract machine is not mapped on the current processor or the current processor doesn't belong to the subtask processor subsystem);

1

- the subtask is started.

10.3. Completing (stopping) current subtask.

long stopam_ (void);

After the function stopam_ execution the abstract machine, parental for the abstract machine, assigned to the stopped subtask, becomes the new current one.

When the subtask is stopped, all objects (except of static ones) created from the moment of its initialization, are automatically deleted, i.e. the points of subtask starting and stopping defines a program block (see section 8).

The function returns zero.

11. Reduction.

The reduction is the computation of the specified function (called «reduction function») with the parameters received from the variable (called «reduction variable») from the different processors executed the different parallel program branches. After reduction execution completes, all copies of the reduction variable in the program branches became equal to the value returned of the reduction function.

For optimization purposes, the Run-Time Library executes the reduction over reduction group, that is aggregate of the reduction variables and reduction functions. Each reduction variable in reduction group associates with own reduction function.

11.1. Creating reduction variable.

Following variables can be used as reduction variables:

  • scalar variable;

  • an element of the «normal» array (that is array, replicated among all the processors);

  • one-dimensional «normal» array.

Generally it is assumed that reduction variable is a one-dimensional array, and reduction function is executed on each array element.

Creating reduction is declaration of reduction variable and corresponding reduction function.

RedRef crtred_ (

long
void
long
long
void
long
long

*RedFuncNumbPtr,
*RedArrayPtr,
*RedArrayTypePtr,
*RedArrayLengthPtr,
*LocArrayPtr,
*LocElmLengthPtr,
*StaticSignPtr);

*RedFuncNumbPtr

- the number of the reduction function.

RedArrayPtr

- pointer to the reduction array-variable.

*RedArrayTypePtr

- the type of the elements of the array-variable.

*RedArrayLengthPtr

- the number of the elements in the array-variable.

LocArrayPtr

- pointer to the array containing additional information about reduction function (the number of the elements in this array has to be equal to the number of the elements in the reduction array-variable).

*LocElmLengthPtr

- the size (in bytes) of an element of the array with additional information.

*StaticSignPtr

- the flag of the static reduction declaration.

The function crtred_ creates a descriptor of the reduction. The function returns pointer to this descriptor (or the pointer to the reduction).

Following reduction function numbers are supported (C language named constants are specified in brackets):

  • sum (rf_SUM);

  • multiplication (rf_MULT);

  • maximum (rf_MAX);

  • minimum (rf_MIN);

  • binary logical «and» (rf_AND);

  • binary logical «or» (rf_OR);

  • binary logical excluding «or» (rf_XOR).

Additional information (also called localization information), associated with the reduction function, depends on the user task algorithm and is formed by the user program. The additional information can be used only in the functions rf_MAX and rf_MIN and turns them into positional reduction functions MAXLOC and MINLOC. Admittedly the additional information in this case is the specified positions of the maximum or minimum. Run-Time Library only sends this information from the processor, where the maximum or minimum was evaluated, to all another processors. If LocArrayPtr==NULL, or if *LocElmLengthPtr==0 than localization information is omitted.

Following types of reduction array-variable are supported (the named constants of the C language are in brackets):

  • int (rt_INT);

  • long (rt_LONG);

  • float (rt_FLOAT);

  • double (rt_DOUBLE).

If the flag *StaticSignPtr of the static reduction declaration is not equal to zero, then the created (or declared) reduction is not deleted automatically when the control exits from the current program block (see section 8). Such reduction has to be deleted explicitly using the function delred_.

Note. To avoid warnings from Fortran-compiler when the function crtred_ is called with different types of the reduction variables, Run-Time Library provides the function

RedRef crtrdf_ (

long
AddrType
long
long
void
long
long

*RedFuncNumbPtr,
*RedArrayAddrPtr,
*RedArrayTypePtr,
*RedArrayLengthPtr,
*LocArrayPtr,
*LocElmLengthPtr,
*StaticSignPtr)

differing from the function crtred_ in the second parameter:

*RedArrayAddrPtr

- pointer to the reduction variable-array, cast to AddrType type by one of the functions, considered in section 17.7.

Other parameters of the function crtrdf_ are similar to corresponding ones of the function crtred_.

11.2. Creating reduction group.

RedGroupRef crtrg_ (

Long
long

*StaticSignPtr,
*DelRedSignPtr);

*StaticSignPtr

- the flag of the static reduction group creation.

*DelRedSignPtr

- the flag of deleting of the all reduction descriptors while deleting the reduction group.

The function crtrg_ creates empty reduction group (that is group that does not contain any reduction). The function returns pointer to the created group.

If the flag *StaticSignPtr of the static reduction group creation is not equal to zero, then the created group does not deleted automatically when the control exits from the current program block (see section 8). Such reduction group has to be deleted explicitly using the function delrg_.

If the flag *DelRedSignPtr is not equal to zero then all reduction variables of the reduction group (at the moment of deleting) will be also deleted while deleting the group. When the group is deleted explicitly, all its variables will be also deleted explicitly, and when the group is deleted implicitly all its variables will be also deleted implicitly.

11.3. Including reduction in reduction group.

long insred_ (

RedGroupRef
RedRef

*RedGroupRefPtr,
*RedRefPtr);

*RedGroupRefPtr

- pointer to the reduction group.

*RedRefPtr

- pointer to the reduction.

Including reduction in reduction group means only registration of this operation as a member of the group reduction operation. Run-Time Library dosn't keep its value for the reduction execution, and the variable is accessible for usage.

The function returns zero.

11.4. Storing values of reduction variables.

long saverv_ (RedGroupRef *RedGroupRefPtr);

*RedGroupRefPtr - pointer to the reduction group.

The function saverv_ stores initial values of all variables of the reduction group to use them for computation of results of the group reduction operation. After execution of this function to include new reductions in this group is not allowed, but it is allowable to store new values of the included variables for next group reduction operation.

The function returns zero.

11.5. Starting reduction group.

long strtrd_ (RedGroupRef *RedGroupRefPtr);

*RedGroupRefPtr - pointer to the reduction group.

The function strtrd_ starts all reduction operations over all reduction variables of the group. It is not allowed to use these reduction variables until the completion of all reduction operations.

The used for reduction operation execution values of the variables, included in the started group, are determined by Run-Time Library in the following way. If a reduction operation is not addition or product, then reduction variable value is its current value (i.e. the value when function strtrd_ is called). If reduction operation is addition or product, then reduction variable value is equal to its current value for the central processor and it is equal to difference between the current value and the value, saved by the function saverv_ (for addition) or quotient of division of the current value to the value, saved by the function saverv_ (for product).

Note, that reduction group starting without previous keeping the values of included reduction operations is allowed. In this case the current value of the corresponding reduction operation will be used on any processor for any reduction operation.

So the keeping of the reduction operation value, that is performed, obviously, before evaluation of its local values, is necessary only in the case, if there is at least one variable with non-zero value and with addition or product operation in the reduction group.

The function returns zero.

11.6. Waiting for completion of reduction group.

long waitrd_ (RedGroupRef *RedGroupRefPtr);

Характеристики

Список файлов учебной работы

Свежие статьи
Популярно сейчас
Зачем заказывать выполнение своего задания, если оно уже было выполнено много много раз? Его можно просто купить или даже скачать бесплатно на СтудИзбе. Найдите нужный учебный материал у нас!
Ответы на популярные вопросы
Да! Наши авторы собирают и выкладывают те работы, которые сдаются в Вашем учебном заведении ежегодно и уже проверены преподавателями.
Да! У нас любой человек может выложить любую учебную работу и зарабатывать на её продажах! Но каждый учебный материал публикуется только после тщательной проверки администрацией.
Вернём деньги! А если быть более точными, то автору даётся немного времени на исправление, а если не исправит или выйдет время, то вернём деньги в полном объёме!
Да! На равне с готовыми студенческими работами у нас продаются услуги. Цены на услуги видны сразу, то есть Вам нужно только указать параметры и сразу можно оплачивать.
Отзывы студентов
Ставлю 10/10
Все нравится, очень удобный сайт, помогает в учебе. Кроме этого, можно заработать самому, выставляя готовые учебные материалы на продажу здесь. Рейтинги и отзывы на преподавателей очень помогают сориентироваться в начале нового семестра. Спасибо за такую функцию. Ставлю максимальную оценку.
Лучшая платформа для успешной сдачи сессии
Познакомился со СтудИзбой благодаря своему другу, очень нравится интерфейс, количество доступных файлов, цена, в общем, все прекрасно. Даже сам продаю какие-то свои работы.
Студизба ван лав ❤
Очень офигенный сайт для студентов. Много полезных учебных материалов. Пользуюсь студизбой с октября 2021 года. Серьёзных нареканий нет. Хотелось бы, что бы ввели подписочную модель и сделали материалы дешевле 300 рублей в рамках подписки бесплатными.
Отличный сайт
Лично меня всё устраивает - и покупка, и продажа; и цены, и возможность предпросмотра куска файла, и обилие бесплатных файлов (в подборках по авторам, читай, ВУЗам и факультетам). Есть определённые баги, но всё решаемо, да и администраторы реагируют в течение суток.
Маленький отзыв о большом помощнике!
Студизба спасает в те моменты, когда сроки горят, а работ накопилось достаточно. Довольно удобный сайт с простой навигацией и огромным количеством материалов.
Студ. Изба как крупнейший сборник работ для студентов
Тут дофига бывает всего полезного. Печально, что бывают предметы по которым даже одного бесплатного решения нет, но это скорее вопрос к студентам. В остальном всё здорово.
Спасательный островок
Если уже не успеваешь разобраться или застрял на каком-то задание поможет тебе быстро и недорого решить твою проблему.
Всё и так отлично
Всё очень удобно. Особенно круто, что есть система бонусов и можно выводить остатки денег. Очень много качественных бесплатных файлов.
Отзыв о системе "Студизба"
Отличная платформа для распространения работ, востребованных студентами. Хорошо налаженная и качественная работа сайта, огромная база заданий и аудитория.
Отличный помощник
Отличный сайт с кучей полезных файлов, позволяющий найти много методичек / учебников / отзывов о вузах и преподователях.
Отлично помогает студентам в любой момент для решения трудных и незамедлительных задач
Хотелось бы больше конкретной информации о преподавателях. А так в принципе хороший сайт, всегда им пользуюсь и ни разу не было желания прекратить. Хороший сайт для помощи студентам, удобный и приятный интерфейс. Из недостатков можно выделить только отсутствия небольшого количества файлов.
Спасибо за шикарный сайт
Великолепный сайт на котором студент за не большие деньги может найти помощь с дз, проектами курсовыми, лабораторными, а также узнать отзывы на преподавателей и бесплатно скачать пособия.
Популярные преподаватели
Добавляйте материалы
и зарабатывайте!
Продажи идут автоматически
7021
Авторов
на СтудИзбе
260
Средний доход
с одного платного файла
Обучение Подробнее