fdvmPDe (1158422)

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

Текст из файла

19


Keldysh Institute of Applied Mathematics

Russian Academy of Sciences

Fortran DVM compiler

Preliminary design

March 2000

Contents

1 Functions of compiler 3

2 The content of compiler 3

3 Approach and principle for compiler implementation 3

4 Translating FDVM program 4

4.1 Distributed arrays 4

4.2 Translating specification directives 5

4.2.1 PROCESSORS directive 5

4.2.2 Data mapping directives 6

4.2.3 TASK directive 8

4.2.4 REMOTE_GROUP and REDUCTION_GROUP directives 8

4.3 Translating executable directives and statements 9

4.3.1 PARALLEL directive 9

4.3.2 PREFETCH and RESET directives 12

4.3.3 MAP directive 13

4.3.4 TASK_REGION construct 13

4.3.5 Parallel-task-loop construct 14

4.3.6 The other FDVM directives 14

4.3.7 Debug directives 15

4.3.8 Input/Output Statements 15

5 Translating HPF-DVM program 17

5.1 Assignment and other executable statements outside the range of INDEPENDENT loop 17

5.2 INDEPENDENT directive 17

1Functions of compiler

Fortran DVM (FDVM) is the Fortran 77 language which is extended by special annotations for specifying parallel execution of the program. These annotations are called DVM directives.

The compiler translates the parallel FDVM code into a sequential Fortran 77 code including Lib-DVM library calls. The run-time system Lib-DVM is written in the C language and it uses the features of MPI for providing inter-processor communications.

By user request the FDVM compiler generates an extended code for debugging and performance analyzing. Special mode of compiling is intended to produce “sequential” code ignoring all the DVM directives.

FDVM compiler can also compile a program written in HPF-DVM language that is enhanced subset of HPF.

2The content of compiler

Program compiling is divided into three phases.

Program in source language are first parsed, one file at a time to produce a machine independent binary internal format (called a .dep file). Front-end compiling results in building a parse tree of program, a symbol and type table.

Second phase involves analyzing and restructuring internal representation of FDVM program. Each DVM directive is substituted for a sequence of Lib-DVM function calls. The following actions are taken at this phase:

  • generating function call expressions and assignment statements to store function value;

  • creating declaration statements for temporary variables that are used for argument passing, storing function value, buffering I/O, and addressing distributed arrays;

  • linearizing distributed array element references.

Restructuring control graph may be required to insert new statement in a program (carrying or substituting label, replacement of logical IF statement by IF...THEN...ENDIF construct, and so on).

Last phase of compilation is unparsing, that is generating new source Fortran 77 code from restructured internal form.

3Approach and principle for compiler implementation

Sage ++ system is used as a tool for designing FDVM compiler.

The Fortran parser of Sage++ which is based on the GNU Bison version of YACC is extended to add language extensions (DVM directives) to Fortran system.

Back-end routine is written in C++ language using Sage++ class library. It traverses a program file accessing it in lexical order and substitutes each DVM directive for a sequence of Lib-DVM function calls. Unparsing is implemented by File class member function of Sage++ class library.

4Translating FDVM program

4.1Distributed arrays

The array with attribute DISTRIBUTE or ALIGN is called distributed array. The memory for the distributed array elements is allocated by runtime system (Lib-DVM). Runtime system evaluate the size and allocate the memory on each processor for the local section of distributed array according to it distribution (DISTRIBUTE directive) and for shadow edges are declared in SHADOW directive.

A distributed array is addressed respect to base address declared by means of statements

integer i0000m(0:0)

common /mem000/ i0000m

real r0000m(0:0)

equivalence (i0000m,r0000m)

Coefficients for addressing and offset are evaluated by Run-Time library function (align()) and stored in descriptor of distributed array called header. User’s program has to allocate this header in memory. The FDVM compiler removes from user program the declaration of distributed array and inserts in it the declaration of array header as the same named integer vector of 2*N+2+NR elements, where N is the rank of distributed array, NR is the number of words allocated for remote data buffer headers. For example, if A is distributed array, the declaration statement

real A(L1:U1,L2:U2,...,LN:UN)

is replaced by the statement

integer A(2*N+2+NR)

The FDVM compiler linearizes each distributed array element reference

A(I1,I2, ..., IN)

replacing it by

N

r0000m(A(N+2) + I1 +  A(N-j+2) * Ij )

i=2

The structure of header is given in Fig.1.

1

pointer to system structure

2

C1

coefficients

3

C2

for

. . .

array elements

N+1

CN

addressing

N+2

offset

N+3

L1

lower bounds

N+4

L2

of

. . .

array

2*N+2

LN

dimensions

2*N+3

remote-reference counter

memory for

. . .

remote-data buffer headers

Fig.1. Array header structure in FDVM.

The first N+2 elements of header are initialized by align( ) function of runtime library and renewed by realn( ) and redis( ) functions. Storing lower bounds of dimensions are inserted in user program by FDVM compiler.

4.2Translating specification directives

4.2.1PROCESSORS directive

The PROCESSORS directive declares virtual processor arrangements. The directive

*DVM$ PROCESSORS P(NP1,…,NPr)

is replaced by the statement

INTEGER P

Also, the following sequence of statements is inserted before first executable statement of procedure:

* initializing vector of the sizes of processor array dimensions

size(1) = NP1

. . .

size(r) = NPr

* creating processor system

P = psview(ps,r,size,0)

The NUMBER_OF_PROCESSORS ( ) and ACTIVE_NUM_PROCS( ) function references are replaced by Lib-DVM function references

getsiz(getps(-1), 0) and getsiz(getps(0), 0) ,

correspondingly.

4.2.2Data mapping directives

The specification directives DISTRIBUTE, ALIGN and TEMPLATE determine a mapping tree of distributed arrays. The FDVM compiler builds the mapping trees analyzing specification directives and then generates the statements for creating distributed arrays.

For example, the following statements

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

*DVM$ TEMPLATE T(100,100)

*DVM$ DISTRIBUTE T (BLOCK, BLOCK)

*DVM$ ALIGN A(I) WITH T(I,*)

*DVM$ ALIGN B(I) WITH T(*,I)

*DVM$ DISTRIBUTE C (BLOCK, BLOCK)

*DVM$ DISTRIBUTE D (GEN_BLOCK(NB)) ONTO P

determine the following aligning tree

A B

\ /

T

The following sequence of statements are generated for creating distributed object:

  • for template T

* initializing vector of the sizes of template dimensions

size(1) = size-of-N-th-dimension

. . .

size(N) = size-of-1-st-dimension

* creating abstract machine representation

iamv = crtamv(am,N,size,...)

* mapping abstract machine representation

* (on processor system)

it = distr(iamv,ps,...)

where am - current abstract machine reference,

ps - current processor system reference,

  • for array A with ALIGN attribute

* storing lower bounds of array dimensions in header of

* distributed array

A(N+3) = L1

. . .

A(2*N) = LN

* creating distributed array

it = crtda(A,i0000m,N,...)

. . .

* aligning (mapping) distributed array

it = align(A,iamvt,N,...)

  • for array C with DISTRIBUTE attribute

* initializing vector of the sizes of array dimensions

size(1) = size-of-N-th-dimension

. . .

size(N) = size-of-1-st-dimension

* creating abstract machine representation

iamv = crtamv(am,N,size,...)

* mapping abstract machine representation

* (on processor system)

it = distr(iamv,ps,...)

* storing lower bounds of array dimensions in header of

* distributed array

C(N+3) = L1

. . .

C(2*N) = LN

* creating distributed array

it = crtda(C,i0000m,N,...)

. . .

* aligning (mapping) distributed array

it = align(C,iamv,N,...)

  • for array D with DISTRIBUTE attribute (GEN_BLOCK format):

* initializing vector of the sizes of array dimensions

size(1) = size-of-N-th-dimension

. . .

size(N) = size-of-1-st-dimension

* creating abstract machine representation

iamv = crtamv(am,N,size,...)

* specifying weights of processor element coordinates

it = genbli(ps,iamv,NB,…)

* mapping abstract machine representation

* (on processor system)

it = distr(iamv,ps,...)

* storing lower bounds of array dimensions in header of

* distributed array

C(N+3) = L1

. . .

C(2*N) = LN

* creating distributed array

it = crtda(D,i0000m,N,...)

. . .

* aligning (mapping) distributed array

it = align(D,iamv,N,...)

The statements for creating distributed objects are inserted in a program before first executable statement.

For dynamic array addressed by POINTER variable the same sequence of statements is generated but it is inserted in program instead of the statement

pointer= ALLOCATE(...).

A section of array HEAP:

HEAP( I : I+header-size-1)

is allocated to a dynamic array for header. The corresponding POINTER variable is assigned a value I.

The declaration of dynamic memory pool HEAP is extracted and a new declaration statement is generated

INTEGER HEAP(S)

where S – summary size of all (declared in procedure ) dynamic array headers.

Mapping array that is specified by directive ALIGN and DISTRIBUTE of the form

*DVM$ ALIGN :: D

*DVM$ DISTRIBUTE :: E

is postponed until execution of REALIGN or REDISTRIBUTE directive. Only the statement of creating distributed array is generated in the beginning of program.

4.2.3TASK directive

The object declared in TASK directive is task array. The directive

*DVM$ TASK TA(M)

is replaced by the specification statement

INTEGER TA(2,M)

Besides, the following sequence of statements is generated and inserted before first executable statement of procedure:

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

Тип файла документ

Документы такого типа открываются такими программами, как Microsoft Office Word на компьютерах Windows, Apple Pages на компьютерах Mac, Open Office - бесплатная альтернатива на различных платформах, в том числе Linux. Наиболее простым и современным решением будут Google документы, так как открываются онлайн без скачивания прямо в браузере на любой платформе. Существуют российские качественные аналоги, например от Яндекса.

Будьте внимательны на мобильных устройствах, так как там используются упрощённый функционал даже в официальном приложении от Microsoft, поэтому для просмотра скачивайте PDF-версию. А если нужно редактировать файл, то используйте оригинальный файл.

Файлы такого типа обычно разбиты на страницы, а текст может быть форматированным (жирный, курсив, выбор шрифта, таблицы и т.п.), а также в него можно добавлять изображения. Формат идеально подходит для рефератов, докладов и РПЗ курсовых проектов, которые необходимо распечатать. Кстати перед печатью также сохраняйте файл в PDF, так как принтер может начудить со шрифтами.

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

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