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

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

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

CDVM$ DISTRIBUTE (BLOCK,BLOCK) :: PA, PB

C arrays of size N* N and M* M are required in the program

READ (6 , *) N, M

C shape of the first array

DESCA(1) = N

DESCA(2) = N

C allocation and distribution of the first array

PA = ALLOCATE(DESCA,1)

C shape of the second array

DESCB(1) = M

DESCB(2) = M

C allocation and distribution of the second array

PB = ALLOCATE(DESCB, N*N+1)

CALL SUB1(HEAP(PA), N, HEAP(PB), M)

END

SUBROUTINE SUB1(A, N, B, M)

DIMENSION A(N,N), B(M,M)

CDVM$ DISTRIBUTE (BLOCK,BLOCK) :: A, B

. . .

END

FUNCTION ALLOCATE(DESC, P)

INTEGER DESC(2), P

ALLOCATE = P

END

Other examples of dynamic array distribution see in section 7.7.

4.3Distributing by aligning

Aligning array A with distributed array B brings in accordance to each element of array A an element or a section of array B. When array B is distributed array A will be distributed simultaneously. If element of B is mapped on the processor, the element of A, corresponding to element B via alignment, will be also mapped on the same processor.

Method of mapping via alignment performs the following two functions.

The same distribution of the arrays of the same shape on one processor arrangement does not always guarantee allocation of corresponding elements on the same processor. It forces to specify remote access (see section 6) where it is possible not exist. Only alignment of corresponding elements of the arrays guarantees their allocation on the same processor.

Several arrays can be aligned with the same array. Redistribution of one array by REDISTRIBUTE directive will cause corresponding redistribution of the array group.

4.3.1ALIGN and REALIGN directives

The following directives describe array aligning:

align-directive

is align-action alignee align-directive-stuff

or align-action [ align-directive-stuff ] :: alignee‑list

align-action

is ALIGN

or REALIGN

align-directive-stuff

is ( align-source-list ) align-with-clause

alignee

is array-name

align-source

is *

or align-dummy

align-dummy

is scalar-int-variable

align-with-clause

is WITH align-spec

align-spec

is align-target ( align-subscript-list )

align-target

is array-name

or template-name

align-subscript

is int-expr

or align-dummy-use

or *

align-dummy-use

is [ primary-expr * ] align‑dummy
[ add-op primary-expr ]

primary-expr

is int-constant

or int-variable

or ( int-expr )

add-op

is +

or -

Constraints:

  • A length of align-source-list must be equal to the rank of aligned array.

  • A length of align-subscript-list must be equal to the rank of align‑target.

  • Each align-dummy may appear at most once in an align-subscript-list.

  • An array-name mentioned as an alignee may not appear as a distributee.

  • REALIGN directive may be applied only to the arrays specified in DYNAMIC directives.

  • align-directive-stuff can be omitted only in ALIGN directive. In such a case the distributed array can be used only after execution of REALIGN directive.

Let the alignment of two arrays is specified by the directive

CDVM$ ALIGN A(d1,…,dn) WITH B(ard1,…,ardm)

where di is specification of i-th dimension of aligned array A,

ardj is specification of j-th dimension of base array B.

If di is specified by integer variable I, then there must be at most one dimension of array B, specified by linear function ardj = a*I + b.

Let i-th dimension of array A has bounds LAi : HAi , and j-th dimension of array B, specified by linear function a*I + b , has the bounds LBj : HBj. Since the parameter I is defined on the value set LAi : HAi, then the following conditions must be satisfied:

a*LAi + b LBj , a* HAi + b HBj

If di is * , the i-th dimension of array A will be local on each processor independently from array B distribution (it is analogue of local dimension in DISTRIBUTE directive).

If ardi is * , then the array A will be replicated along j-th dimension of the array B.

If ardi is int-expr, then array A is aligned with the section of the array B.

Example 4.8. Aligning arrays

REAL A(10),B(10,10),C(22,22),D(20),E(20),F(10),G(20),H(10,10)

CDVM$ DISTRIBUTE B (BLOCK,BLOCK)

CDVM$ DISTRIBUTE D (BLOCK)

C aligning with the array section

C (the vector is aligned with the first line of A)

CDVM$ ALIGN A( I ) WITH B(1,I)

C replication of the vector aligning it with each line

CDVM$ ALIGN F( I ) WITH B(*,I)

C the matrix is collapsed;

C each matrix column corresponds to the vector element

CDVM$ ALIGN C(*,I) WITH D( I )

C alignment of vector with vector using stretching

CDVM$ ALIGN E( I ) WITH D(2*I)

C alignment vector with vector using reverse ordering

CDVM$ ALIGN G( I ) WITH D(-I+21)

C alignment matrix with matrix using rotation and stretching

CDVM$ ALIGN H(I,J) WITH C(2*J,2*I)

Several arrays (A1, A2,…) can be aligned with one B array in the same manner by the directive of the form:

CDVM$ ALIGN (d1,…,dn) WITH B(ard1,…,ardm) :: A1, A2, …

At that A1, A2… arrays must have the same rank (n), but can have different sizes of dimensions.

Let the sequence of alignments A f1 B f2 C, be specified; f2 is alignment of the array B with the array C, and f1 is alignment of the array A with the array B. The arrays A and B are considered as aligned with array C by definition. The array B is aligned by function f2 directly and array A is aligned by composite function f1(f2) indirectly. Therefore applying REALIGN directive to the array B doesn't cause redistribution of array A.

Generally a set of ALIGN specifications is a set of trees. At that every tree root must be distributed by DISTRIBUTE or REDISTRIBUTE directives. When REDISTRIBUTE directive is executed, the whole alignment tree is redistributed.

4.3.2TEMPLATE directive

If values of linear function a*I + b are beyond base array dimension, it is necessary to define a dummy array - referred to as an alignment template – using the following directive.

template-directive

is TEMPLATE template-decl-list

template-decl

is template-name [ ( explicit-shape-spec-list ) ]

Then it is necessary to align both arrays with the template. The template is distributed by DISTRIBUTE and REDISTRIBUTE directives. The template elements are mapped among processors without real memory allocation. They specify a processor on which elements of aligned arrays must be mapped.

Consider the following example.

Example 4.9. Aligning with template.

REAL A(100), B(100), C(100)

CDVM$ TEMPLATE TABC(102)

CDVM$ ALIGN B( I ) WITH TABC( I )

CDVM$ ALIGN A( I ) WITH TABC( I+1 )

CDVM$ ALIGN C( I ) WITH TABC( I+2 )

CDVM$ DISTRIBUTE TABC ( BLOCK )

. . .

DO 10 I = 2, 98

A(I) = C(I-1) + B(I+1)

10 CONTINUE

To avoid exchange between processors, it is necessary to allocate the elements A(I), C(I-1) and B(I+1) on the same processor. It is impossible to align arrays C and B with array A, because alignment functions I-1 and I+1 cause bounds violation of array A. Therefore the template TABS is declared. The elements of arrays A, B and C, which must be allocated on the same processor, are aligned with the same element of the template.

4.3.3Aligning dynamic arrays

To specify dynamic arrays alignment the syntax of ALIGN and REALIGN directives is extended in the following way.

alignee

is . . .

or pointer-name

align-target

is . . .

or pointer-name

If a variable with POINTER attribute is specified as aligned array (alignee) in ALIGN directive, then directive executing is postponed up to execution of ALLOCATE function, defining the variable value. The REALIGN directive may be executed only after execution of the ALLOCATE function.

Example 4.10. Aligning dynamic arrays.

REAL HEAP(100000)

CDVM$ REAL, POINTER (:,:) :: PX, PY

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

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

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