RSS
Логотип
Баннер в шапке 1
Баннер в шапке 2
2012/09/21 13:22:29

Functional stream computer. Micro programming of functions. Program

Article continues the project (Sections 5 and 6) not of fon_neymanovsky structure of a stream computer with parallel processing of data streams and expressions by collective of microprocessors – the Structure Aktivatsy (SA) which is dynamically rebuilt on structure of the next expression – superpositions of futsnktion. Here the fixed assets of micro programming of entrance and output flows of functions, as well as main actions of functions considered in the previous Section 4 are considered in more detail. At last, the concept of the program as a flow of expressions and based on this concept main built in (without explicit definition by the user) macro definitions is entered

Content

Links to all sections of the project:

1. Functional Stream Mashina with parallel computings. Introduction (http://tadviser.ru/a/121275)
2. Uniform data structure and programs (http://tadviser.ru/a/149691)
3. Functioning of FPM. Expressions of language of programming (http://tadviser.ru/a/149691)
4. Flows and their processing in structure of expression (http://tadviser.ru/a/150588)
5. Micro programming of functions (http://tadviser.ru/a/153069)
6. The program as the managed flow of expressions (http://tadviser.ru/a/153069)
7. Macro definitions of the user functions (http://tadviser.ru/a/157631)

5. Micro programming of functions

These transactions were considered when processing function parameters (item 3.4.1.2), entrance flows (item 4.2.1) of function, direct it implementation (item 4.1.2, item 4.1.4, Subparagraphs 4.3.2-4) and the output flows (item 4.2.3) created by it. In the same place the main primitives were considered _If, calculator _if managing the choice of the sequence of transactions as well as the transactions _Skip, _Break, _Go and the general structure of formulas and even as examples some transactions _Calc (microtransactions) used in formulas. Here we will specify these determinations which are standard when using transactions of the calculator.

5.1. General principles of the organization of formulas of the calculator

1) Let's remind (river 2, river 4) that the formula is defined as:

    `[<цикл>]<операция_Calc>{ ;<операция_Calc>}`

The cycle is defined only the formula restarted for each element of a train (item 4.3.2, $Sync) or a stack (item 4.1.4, * by Tree) /

The empty formula' '-without the transactions _Calc in which nothing is performed is possible.

    <операция _Calc>::=
        <операнд>[%<Свойства>%]|%<Свойства>%|
        [<операнд[1]>][%<Свойства>%]<код операции>[<операнд[2]>][%<Свойства>%]

  a) The transaction _Calc of a type <операнд><Свойства>[%%] with on the right Properties leads an operand to a type, the answering these properties and the result of reduction (or without reduction for lack of Properties) places in the register'.', the saving result of the last executed transactions _Calc.

  b) The transaction _Calc <Свойства>%% is equivalent to transaction. <Свойства>%%

  c) In the presence of an activity code operands similarly are given to the properties specified on the right just before transaction, however without preserving in any registers results of this reduction are used in transaction if of course near an operand required properties are specified. For lack of such properties on the right or at impossibility of reduction of an operand to the specified type an operand it is used in transaction in an initial type. In some transactions (activity code) of NE the requirement of preliminary reduction of one is allowed from operands to a certain type and then this requirement (Properties) are simply ignored by transaction.

  d) For lack of an operand, as well as in case of (b) the register is by default used '.'

2) Finally operands of the transactions _Calc are the registers of the calculator containing direct value of atom (% \%) or links: R-(UKA, UKS) or V-value (river 2). As like those are defined:

  a) Parameters (item 3.4.1) of functions, perhaps after their reduction to an okonchatetelny type (item 3.4.1.2) considered here and earlier transactions. The names of parameters defined at function call or defined by default are anyway used. In absence the parameter specified by a name an operand Lish of properties and transaction with it are simply passed, behind an exception (1a) without Properties on the right, the placing parameter without properties in the register '.'.

  b) The names a-z of elements of a train (function of $Sync, item 4.3.2), stack elements at a bypass of a hierarchical structure on a circuit (generator * Tree, item 4.1.3), etc. Directly atoms and links (value R-and V-) are allowed to be changed NE in these registers. However through links in them it is admissible to change values (atoms and layers) specified by these links except for special cases (for example, * to Tree), stipulated separately. For lack of a-z specified by member name action identiyano to a case (a) of the absence specified name of the parameter (operand)

  c) Register '.' it is usually autocompleted by result of accomplishment of transaction except for some separately the stipulated transactions. It is used also by default any of required operands. At successful accomplishment of transaction in it are removed the dynamic (item 4.5) properties 1 and/or 2 which are defining an operand (1st and/or 2nd), caused an error, otherwise, opposite, these properties automatically appear

  d) Register '!', most often on completion of all transactions (and formulas) it is used as result of processing of an element entrance or output flow and also result of function evaluation. In an initial status before transactions usually in this register it is offered (expected) result of processing or calculations which transactions can change.

P.S. Operands '!' and '.' are most important in terms of change of an execution order of transactions of processing, including formulas, because primitives of _If and _if determine this order by the analysis of properties of registers, respectively '!' and '.'.

  e) The calculator allows any use in formulas of operands of registers of $a, $b..., $z, initially without properties (%%), except for part of them created automatically by functions:

    $i and $n - respectively, number of the transactions _Calc of elements which arrived and accepted by the time of the beginning in input or an output flow, number of the N ($n) for an exit of results created by function ($i) and transferred.; $i = $n=0 (original value) by the beginning of processing input and formations of an output flow, by the beginning of work of function (transaction of its calculations)

    $e - by the time of the beginning of the transactions _Calc value of the element of the flow processed (an input flow), calculated or arrived on a specific exit (an output flow) by the beginning of transactions for processing of the next element following it. Original value by $e it is deprived of properties (%%)

    $l - quantity of elements of a train ($Sync), quantity of entrance flows ($Async, item 4.3.3), the current size of a stack at a bypass hierarchical structure on a circuit (*Tree, item 4.1.4)

    $k - quantity arrived (without property '^') from even open inputs of function of elements of a train ($Sync), quantity still the arriving entrance flows - open inputs ($Async), the integer index in V-value of top of a stack (*Tree).

  f) The operand '^' is NE the register, but the link to one of elements of a train ($Sync) or a stack (*Tree). Use of this the link as an operand it is equivalent to the direct use specified by it an element of a train or a stack. For lack of a train or a stack the element specified by it always without properties. At the organization of a cycle (1) at the beginning of each repetition (cycle) of a formula the link' ^' automatically is established on the next processed element of a train or a stack regardless of change of its forced (the transaction _Calc, item 5.2) installations (on any element of a train or a stack) in the previous cycle of execution of a formula

  g) The register of $S - "adder" which is made out by transactions of the user and saving the contents upon transition from processing (transactions) one element of a flow (input or output) to another, as well as from one result calculated by function (transactions) to calculation another. Let's remind that original value - structure of sozherzhimy this register for (1) calculations of results function and (2) processings output flows is defined by the standard Sum parameter (item 3.4.1.1) which can be also processed by the transactions _Calc (item 3.4.1.2) to function start. Let's remind that upon termination of work of the function using as an argument a primitive of _Sum (item 4.4), %S value for (1) automatically remains in a subspace - an argument of this primitive. For lack of use transactions (1) use $S processings (2) on the main thing - syntactically the defined function exit

5.2. Transactions of the calculator in formulas

    <код операции>::= <спецсимвол>[<спецсимвол>]

Transactions in formulas are focused on properties of operands after their possible reduction to the type specified to the right of them:



1) '+'  - Addition:

  a) Arithmetic addition of integer numbers (% of.9%) and material (%./%)

  b) Katenation lines (operand1) with syntax representation (line) according to river the 2nd other atom of any kind (operand2). At the same time used in determination of atoms of an operand 2 characters limiting it ('for a formula, % for properties,' for date) Are not transferred to result of a katenation

  c) Atom (the first operand) determined directly (% \%) or R-value (%. ~, %) without layer (the link UKA at UKS=0) instead of with R-value layer (% ~., %) the second operand without atom (UKS at UKA=0) form new R-value of <>UKA0 of the first operand and <>UKS0 of the second

  d) <>UKS0 R-values of the first operand without atom (% ~., %) and positive whole (% of \.9+ %) or a name index (% \.|%) - value of the second operand, set directly (% \%) form V-value. At the same time NE is controlled existence of the R-value specified by this V-value. Such, perhaps, the absent R-value (similar to $In, item 4.3.3.1) it is necessary to apply the transaction '.%&@%' to creation

  e) To the integer V-values index of the first operand increases whole (% of.9%) - atom of the second

  f) To atom - date (%.' ~, %, river 2) increases whole (taking into account the sign, % of.9%), forming (result) new date

The result of transaction, as usual is located in the register'.'. At others, excellent from listed above properties of operands transaction It is not executed, the register'.' saves the original value. In all considered options of transaction with atoms the last opredelyaetsya directly (% \%) or <>UKA0 of R-values

2) '+='  - differs from (1) those that:

  a) register'.' at any result of transaction remains invariable: result, including reset or installation defining an error properties 1 or 2, substitutes value of the operand first (at the left) in (1a) and (1b) only if this operand - the atom (% \%) set directly, in other cases (1d, e, f) certainly (1

  b) In case of transactions (1a, b) with atom, the specified UKA R-values of the first operand only its value according to the link UKA in BP changes without changes of this link

  c) The layer on UKS R-values of the first operand without atom (% ~., %) is replenished with R-value of the second operand (addition to the transaction '+').

  d) The layer on UKS R-values of the first operand without atom (% ~., %) is replenished with indefinite values in specified directly (% of.\9+ %) the second operand quantity. At this UKS of the first operand remains to the same

3)<операнд>' ++'  - it is equivalent'<операнд> + =1'


4)' -'  - Subtraction:


  a) Arithmetic subtraction of integer numbers (% of.9%) and material (%./%)

  b) From a line - the first operand, set directly in the register (% \." the %), is removed the first occurrence - the substring which is syntax representation (line) according to river the 2nd other atom of any kind (an operand 2) without the limiting characters similarly (1)

  c) From the integer V-values index of the first operand it is subtracted whole (% of.9%) - atom of the second. The received negative the value of the index is replaced with 0

  d) From atom - date (%.' ~, the %, river 2) takes away date (the second operand) and the result is made out as whole (% of.9%) - a difference in days

5) '-='  - differs from (4):

  a) listed (2a) and (2b) similar to the transaction '+='

  b) From a layer on UKS R-values of the first operand without atom (% ~., %) its last elements in specified directly are removed (% of \.9+ %) the second operand quantity. At this UKS of the first operand remains to the same


6)'<операнд> -'  - it is equivalent'<операнд>-=1'

7)' *'  - Multiplication:

  a) Arithmetic multiplication of integer numbers (% of.9%) and material (%./%)

  b) A line - the first operand, set directly in the register (% \." the %), repeats (katenation) number of times - the whole value atom (% of.9+ %) of the second operand

  c) The R-value of the first operand forms a layer of repetitions of this R-value (the copy of UKA, UKS) number of times - the whole value atom (% of.9+ %) of the second operand

8) '/'  - Division:

  a) Arithmetic division of integer numbers (% of.9%) and material (%./%)

  b) From a line - the first operand, set directly in the register (% \." %), are removed all occurrences - the substrings which are syntax representation (line) according to river the 2nd other atom of any kind (an operand 2) without the limiting characters similarly (4b)

  c) From a line - the first operand, set directly in the register (% \." the %), is cut its initial segment (the register'.') length - the whole value of atom (% of.9+ %) of the second operand. The remaining balance of a line (a final part) is located in the register of $a. If required initial segment is exceeded by the size of an initial line, this line to the specified size is replenished with spaces, and the line in $a is empty (length 0)

  d) Similar to a line (b) the layer is divided by UKS R-values of the first operand without atom (% ~., %): instead of characters of a line are used layer elements. At the same time initial and final "segments" of a layer are located in the same registers as R-values of layers (also without atoms), each of which is located in the separate free BP (unique UKS) selected from DRP. These "segments" contain copies of R-values (links UKA, UKS) from a native layer

9)' "' -Reading a line in the register'.': The characters of the only operand following the code'" until the end of transaction (code';' or end of a formula) are located directly in the register'.'. At the same time the codes placed in the resulting line ';' and '\' surely are preceded by the code '\' which is not placed in a line.

P.S. Here in (9) some derogation from determination of an operand in item 5.1

10)' &'  - Broadcast of a line (% \." %) - the only operand (register) in the structure described by it syntactically, it is possible and hierarchical multi-level according to item 2.1. If this line submits the description of atom, then this atom is located directly (% \%) in register'.'. Otherwise in this register the R-value generated (result of broadcasting) in DRP of a hierarchical structure is located according to determinations of item 2.1 (see coding of structure)

Examples of formulas with transactions:

'"'3/13/1943'; @' - in the register'.' places date 3/13/1943 (% \.' %)

'"'3/13/1943'; @; % @ %' - the same, but in addition from date in the register '.'
		     creates in the same the register R-value from UKA on
		     the copy of this date in the selected free BP

'"(Ab, $Num (7)); @' - in the register '.' places R-value of structure
		     (Ab, $Num (7)) with properties of % @ ~., % (UKA=0, UKS)
		     layer without atom from two elements)

In these examples the first transaction' "'places a line in the register'.' and following' @', using the same register as the operand by default, broadcasts this line according to determination of syntax of structure in the codes of structure (item 2.1) placed in DRP

11) '&"'  - Relaying of the structure defined (specified) by R-value - the only operand (register) on the right at line (register '.')


12) '->'  - Copying of value - directly atom (% \%), R-or - V-value (links) of the first operand into place (register) the second

13) '=>'  - Copying of value - directly atom (% \%), R-or - V-value (links) of the first operand according to links the second:

  a) The R-value - the first operand is located to the place of the R-value specified by V-value - the second operand

  c) Atom directly (% \%) from the register - the first operand or on UKA of its R-value with UKS=0 (% @. ~, %) registers in BP on UKA R-values of the second (instead of the atom existing there). Respectively, the atom BP size (an operand 2) under new atom (an operand 1) increases or it is reduced. In absence at the second operand of UKA (UKA=0) or use of the BP incompatible type in view of mismatch of types of atoms (replaced and substituting) transaction NOT is executed

  b) R-values of elements of a layer (the copy of links) on UKS R-values of the first operand are copied in the same order in BP on UKS R-values of the second (instead of the layer of couples of links existing there<УКА,УКС>). Respectively, the layer BP size (an operand 2) under a new layer (an operand 1) it increases or reduced.

  c) In case of R-values of both operands with <><>UKA0 and UKS0 (the %., %) perform operations (a) and (b) in parallel

Attention! Reduction to the necessary type (the necessary properties to the right of an operand) before transaction can only be specified in transactions (12) and (13) for the first operand

14) '<='  - Reduction of properties of the first operand to a type (properties) of the second

Attention! Reduction to the necessary type (the necessary properties to the right of an operand) before transaction can only be specified in transaction (14) for the second operand

15) '<-'  - Copying of the second operand on all hierarchy levels, as structures and record in the register of the first


16) '<>'  - Determination of the sizes (length) of the only operand on the right:

  a) The atom determined directly (% \%) or by UKA R-values for lack of a layer (% @. ~, %). The size is defined according to to syntax of representation of atom, and the size of NE atom joins the characters limiting its determination ("" for a line, etc.)

  a) A layer (quantity of elements) on UKS R-values for lack of atom (% @ ~., %).


  c) A layer (quantity of elements) on UKS V-values (% @ ~., %).


17) '='  - Comparison of atoms of the operands (set directly or on UKA): numbers are compared by numerical value, dates taking into account their determination according to the calendar, other and not coinciding types of atoms are compared as a line of the leksikokraficheski on their syntax representations without the brackets limiting them ("for lines, 'for dates, etc.). In particular, in this case "atom" with UKA=0 is most less. In case of equality of atoms of operands both are replenished with dynamic (item 4.5) property' ='. Otherwise smaller is replenished with dynamic property' <'and bigger with property'>'


18) Transactions of management of the link' ^ on an element of a train or a stack' (without operands):

  '<<'-installation of the link' ^' on the element 'a' - an initial element of a train or top of a stack

  '>>' - installation of the link' ^' on the last element of a train or an element on stack bottom

  '>' - movement of the link '^' on the element of a train following on the right or to stack bottom

  '<' - movement of the link '^' on following at the left (by the beginning) an element of a train or to stack top

  '> a '-'> z' - installation of the link to an element' a '-' z'. For lack of the specified element the link (name a-z) the element is established on the next lexicographic

19) Transactions of management of transactions in a formula:

  '/*' [<Свойства>] - to interrupt accomplishment of a formula including all its cycles at compliance of Properties of the register'.' specified transaction

  '/+' [<Свойства>] - to pass (not to execute) the transaction of a formula following this at compliance of Properties of the register'.' specified by transaction

  '//' [<Свойства>] - to pass (not to execute) all following for this transaction of a formula at compliance of Properties of the register '.' specified by transaction

Note: In the absence of Properties in the specified transactions these transactions are executed certainly regardless of properties of the register '.'

6. The program as the managed flow of expressions

Syntax:

  <поток[выражений]><поток[данных]>$Eval([,]
      <подпространство><подпространство>[,_Area({,})])		(6-1)

  <подпространство>::= <Имя подпространства>[:<Структура>]
 				%.|1%

The flows of expressions and data calculated by function arguments $Eval arrive synchronously: the next expression of a flow and given a flow is formed similar to $Sync a train from two elements' an 'and' b' which can be processed by the same (item 4.2.1) means on an input functions and even the transactions _If (_if), including the version (4-1) and also by means of _Break and _Skip to refuse processing of trains and even use the sinkhropotoki and _Scale. At the same time implementation of the next expression (an element of' a') of a train is executed certainly its development in similar structure of SA from a micro computer with connection of this expression to an element of' b' of a train Data primitive (), entering expression (item 3.2). Replacement of this action of function with formulas _Calc here of NE is allowed. Next Exit of "processing" of it train is:

  • an element 'b' of a train, perhaps, processed with access through Data () the expression specified by R-value of an element 'a';
  • for lack of a data stream (an element of' b') the unary value calculated by expression of' a';
  • a layer (% ~., %) from elements of a flow of the expression of' a' created by root function.

Let's remind (item 4.5) that by means of an argument of _Sum of any function from the expression performed by $Eval the value of Adder of this is possible functions place in a subspace of this or higher $Eval (see further)

At function of $Eval, as well as at any other function, additional exits can be entered and, as well as the main exit of Out of function of $Eval can be are filtered and processed similar to any function (item 4.2.2, item 4.2.3). It is clear, that these exits and channels connected with them should be within expression which rassmatrivavemy $Eval enters.

Let's remind that $Eval creates own space the empty or using subspace _Area determined by a primitive, perhaps, and indefinite. This $Eval contacts communication lines higher on the level (b) of $Eval, performing expression since considered. Let's remind what at the appeal of expression to a podpostranstvo by the name of in the beginning this subspace is looked for by name in $Eval subspace(s), performing this expression, for lack of it in a subspace of $Eval (b), etc. up hierarchy. And only for lack of like that on to all levels of an iyererkhiya of $Eval the subspace is created in $Eval (a) with a required name. Actually such search is performed in parallel on all hierarchy levels of $Eval.

At the most top level of the hierarchy of $Eval mentioned above there is the FPM executing entered manually by the user of expression (flow) and these expressions processed synchronously data (flow). Moreover out of (6-1) user can define subspaces by means of _Area primitive. Here, having entered manually the expression containing one or more function calls of $Eval the user defines these $Eval c them spaces of the following it is lower than the level, etc. Not only root $Eval, but also created in expression of $Eval can demand input of a flow expressions and data manually, as well as subspaces of its space, i.e. not obligatory $Eval function argument

As well as $Sync (item 4.3.2) function of $Eval comes to the end after exhaustion of both of its entrance flows. At the premature termination of one of flows similarly in a train its last element is reused.
  Attention! At premature end of a flow of expressions (the data stream from the second argument is not complete) and repetition the last NE of the containing $Eval expression of a flow for the purpose of an exception of dead times of calculations of NE its development in SA and even repeats with $Eval, processing (the 1st her argument) NE the flow of the expressions which are not containing appeals to user calculated (literals) to functions (river 7). In this case for its repetition its first development in SA perhaps is simply used (not necessarily!) from repeated setup. Otherwise in expression only development of a subtree (branch) of SA with a root - $Eval, not answering to the listed above conditions repeats

  In conclusion we will note the following:

The declarative structure of the cycle for of traditional algorithmic languages for expression repetition can be provided so here:

 <количество раз><выражение[структура]>$Eval(*Row(Expr,) ,_Area(Expr:)) -
    - Expr subspace directly in space of $Eval expression
or
  in the beginning it is autonomous to create Expr subspace with required expression
  in space
 	<выражение [структура его]>_Area(Expr:)
  the function of $Eval performing the following expression:
 	<количество раз>$Eval(*Row(Expr,))
 

Once again we will pay attention to that fact that function * Row (item 4.1.2) of NE repeats expression, but only links to it, as well as in the following case:

   <выражение [структура его]><количество раз>$Eval(*Row(Lit(),))
 

The expression repeated here (cycle) can include (to contain) functions of $Eval (yes not one!), processing own flow of expressions

  • the 'program' of FPM repeated in the scraper, etc. with any investment of cycles

6.1 Built-in macro definitions


1) It is possible to define Expr subspace as a layer from expressions 1-N and then to start the program – consecutive calculation of these expressions:

   <выражение 1><выражение 2><выражение N>_Area(Expr:(,,…,))

Further calculation of expressions 1, 2, …, N:

  $Eval(*Sel(Expr))					(6-2)

or the same is shorter as the built-in macro definition:

  $Eval(Expr)						(6-3)

As well as the other built-in macro definitions (6-3) it will be transformed in (6-2) only at development to SA. This conversion is executed only for Expr with properties of % ~., % (layer). If Expr defines expression:

	Expr:<выражение>

that this expression is executed as usual.

2) Option of implementation of the same program directly in expression without use of subspaces use of the generator * Lit (item 4.1)

  • links (UKA, UKS, item 2.3) on the expressions described as literals:

  <выражение 1><выражение 2><выражение N>$Eval(*Lit(,,…,))

or the same is shorter as the built-in macro definition:

  <выражение 1><выражение 2><выражение N>$Eval{,,…,}	(6-4)


The used reductions:

FPM	-functional stream machine
p. 5	-Section 5 of the FPM project
item 2.3	-point 3 of Section 2
SA	-Structure Aktivatsy – implementing expression of language (superposition
 	  functions) collective of appropriately connected micro computers, 
 	  each of which implements separate function or a primitive 
 	 (calculator) of _Calc
DRP	-dynamically distributed memory over which funkutsionirut 
 	  micro EVM SA
BP	-the DRP block selected under atom or a layer of structure
UKA	-pointer (link to BP) of atom (item 2.3)
UKS	-pointer (link to BP) of a layer (river 2)