fdvmLDe (1158336), страница 10

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

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

C end of global reduction

PRINT *, S, X

While the reduction group is executed the values of array A elements will be computed.

7Task parallelism

DVM parallel model joins data parallelism and task parallelism.

Data parallelism is implemented by distribution of arrays and loop iterations over virtual processor subsystem. Virtual processor subsystem can include as whole processor arrangement as its section.

Task parallelism is implemented by independent computations on sections of processor arrangement.

Let us define a set of virtual processors, where a procedure is executed, as current virtual processor system. For main program the current system consists of whole set of virtual processors.

The separate task group is defined by the following directives.

  1. Declaration of task array (TASK directive).

  2. Mapping task array on the sections of the processor arrangement (MAP directive).

  3. Distribution of arrays over tasks (REDISTRIBUTE directive)

  4. Distribution of computations (blocks of statements or iterations of parallel loop) over tasks (TASK_REGION construct).

Several tasks can be described in a procedure. Nested tasks are not allowed.

7.1Declaration of task array

A task array is described by the following directive:

task-directive

is TASK task-list

task

is task-name ( max-task )

TASK directive declares one-dimensional task array, which then will be mapped on the processor arrangement sections.

7.2Mapping tasks on processors. MAP directive

The task mapping on processor arrangement section is performed by MAP directive

map-directive

is MAP task-name (index-task)

ONTO processors-name(processors-section-subscript-list)

Several tasks can be mapped on the same section.

7.3Array distribution on tasks

Array distribution on tasks is performed by REDISTRIBUTE directive with the following extension:

dist-target

is . . .

or task-name ( task-index)

The array is distributed on processor arrangement section, provided to the specified task.

7.4Distribution of computations. TASK_REGION directive

Distribution of statement blocks on the tasks is described by TASK_REGION construct:

block-task-region

is task-region-directive

on-block

[ on-block ]...

end-task-region-directive

task-region-directive

is TASK_REGION task-name [ , reduction-clause ]

end-task-region-directive

is END TASK_REGION

on-block

is on-directive

block

end-on-directive

on-directive

is ON task-name ( task-index ) [ , new-clause ]

end-on-directive

is END ON

Task region and each on-block are sequences of statements with single entry (a first statement) and single exit (after last statement). TASK_REGION construct is semantically equivalent to parallel section construction for common memory model. The difference is that statement block in task region can be executed on several processors in data parallelism model.

Distribution of the parallel loop iterations on tasks is performed by the following construct:

loop-task-region

is task-region-directive

parallel-task-loop

end-task-region-directive

parallel-task-loop

is parallel-task-loop-directive

do-loop

parallel-task-loop-directive

is PARALLEL ( do-variable )
ON task-name ( do-variable ) [ , new-clause ]

Distributed computation unit is an iteration of one-dimensional parallel loop. The difference from usual parallel loop is the distribution of the iteration on processor arrangement section, the section being defined by reference to the element of the task array.

Specifications reduction-clause and new-clause have the same semantics as for parallel loop. Reduction variable value must be calculated in each task. After task completion (END TASK_REGION) in the case of synchronous specification the reduction over all values of reduction variable on all the tasks are automatically performed. In the case of asynchronous specification the reduction is started by REDUCTION_START directive.

Constraint:

  • If the reduction operation is performed between tasks, these tasks must be distributed on disjoined sections of the processor arrangement.

7.5Data localization in tasks

A task is on-block or loop iteration. The tasks of the same group have the following constraints on data

  • there are no data dependencies;

  • all used and computed data are allocated (localized) on processor arrangement section of the given task;

  • task can update only the values of arrays, distributed on the section, reduction variable values and the NEW-variable values.

After the task completion each array must have same distribution as before the task startup. If the array distribution is changed in the task, it must be restored after the task completion.

7.6Fragment of static multi-block problem

The program fragment, describing realization of three-block problem (fig.6.6) is presented below.

CDVM$ PROCESSORS P(NUMBER_OF_PROCESSORS( ))

C arrays A1,A2,A3 - the function values on the previous iteration

C arrays B1,B2,B3 - the function values on the current iteration

REAL A1(M,N1+1), B1(M,N1+1)

REAL A2(M1+1,N2+1), B2(M1+1,N2+1)

REAL A3(M2+1,N2+1), B3(M2+1,N2+1)

C declaration of task array

CDVM$ TASK MB( 3 )

C aligning arrays of each block

CDVM$ ALIGN B1(I,J) WITH A1(I,J)

CDVM$ ALIGN B2(I,J) WITH A2(I,J)

CDVM$ ALIGN B3(I,J) WITH A3(I,J)

C

CDVM$ DISTRIBUTE :: A1, A2, A3

CDVM$ REMOTE_GROUP RS

C distribution of tasks on processor arrangement sections and

C distribution of arrays on tasks

C ( each section contains third of all the processors)

NP = NUMBER_OF_PROCESSORS( ) / 3

CDVM$ MAP MB( 1 ) ONTO P(1:NP)

CDVM$ REDISTRIBUTE (*,BLOCK) ONTO MB( 1 ) :: A1

CDVM$ MAP MB( 2 ) ONTO P(NP+1:2*NP)

CDVM$ REDISTRIBUTE (*,BLOCK) ONTO MB( 2 ) :: A2

CDVM$ MAP MB( 3 ) ONTO P(2*NP+1:3*NP)

CDVM$ REDISTRIBUTE (*,BLOCK) ONTO MB( 3 ) :: A3

. . .

DO 10 IT = 1, MAXIT

. . .

CDVM$ PREFETCH RS

C exchanging edges of adjacent blocks

. . .

C distribution of computations (statement blocks) on tasks

CDVM$ TASK_REGION MB

CDVM$ ON MB( 1 )

CALL JACOBY( A1, B1, M, N1+1 )

CDVM$ END ON

CDVM$ ON MB( 2 )

CALL JACOBY( A2, B2, M1+1, N2+1 )

CDVM$ END ON

CDVM$ ON MB( 3 )

CALL JACOBY( A3, B3, M2+1, N2+1 )

CDVM$ END ON

CDVM$ END TASK_REGION

10 CONTINUE

7.7Fragment of dynamic multi-block problem

Let us consider the fragment of the program, which is dynamically tuned on the number of blocks and the size of each block.

C NA - maximal number of blocks

PARAMETER ( NA=20 )

CDVM$ PROCESSORS R(NUMBER_OF_PROCESSORS( ))

C memory for dynamic arrays

REAL HEAP(100000)

C sizes of dynamic arrays

INTEGER SIZE(2,NA)

C arrays of pointers for A and B

CDVM$ REAL, POINTER (:,:) :: PA, PB, P1, P2

INTEGER P1, P2, PA(NA), PB(NA)

CDVM$ TASK PT( NA )

CDVM$ ALIGN :: PB, P2

CDVM$ DISTRIBUTE :: PA, P1

. . .

NP = NUMBER_OF_PROCESSORS( )

C distribution of arrays on tasks

C dynamic allocation of the arrays and execution of postponed

C DISTRIBUTE and ALIGN directives

IP = 1

DO 20 I = 1, NA

CDVM$ MAP PT( I ) ONTO R(IP:IP+1)

PA(I) = ALLOCATE ( SIZE(1,I), HEAP )

P1 = PA(I)

CDVM$ REDISTRIBUTE (*,BLOCK) ONTO PT( I ) :: P1

PB(I) = ALLOCATE ( SIZE(1,I), HEAP )

P2 = PB(I)

CDVM$ REALIGN P2(I,J) WITH P1(I,J)

IP = IP + 2

IF( IP .GT. NP ) THEN IP = 1

20 CONTINUE

. . .

C distribution of computations on tasks

CDVM$ TASK_REGION PT

CDVM$ PARALLEL ( I ) ON PT( I )

DO 50 I = 1,NA

CALL JACOBY(HEAP(PA(I)), HEAP(PB(I)), SIZE(1, I), SIZE(2, I))

50 CONTINUE

CDVM$ END TASK_REGION

The arrays (blocks) are cyclically distributed on two processor sections. If NA > NP/2, then several arrays will be distributed on some sections. The loop iterations, distributed on the same section, will be executed sequentially in data parallelism model.

8COMMON and EQUIVALENCE

The arrays, distributed by default, can be used in COMMON blocks and EQUIVALENCE statements without restrictions.

The arrays, distributed by DISTRIBUTE or ALIGN directive, can't be used in EQUIVALENCE statements. Moreover, these arrays can't be associated with other data objects. Explicitly distributed arrays can be the components of COMMON block under the following conditions:

  • COMMON block must be described in main program unit.

  • Every occurrence of the COMMON block must have the same number of components and each corresponding component must have a storage sequences of the same size;

  • If explicitly mapped array is the component of the COMMON block, then the array declarations in different program units must specify the same data type and shape. The DISRIBUTE and ALIGN directives, applied to the array, must have the identical parameters.

Example 8.1. Explicitly distributed array in COMMON block.

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

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

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