+ All Categories
Home > Documents > Pattern-AddressableMemory BriefOverview … · The Chameleon board and its accompanying software is...

Pattern-AddressableMemory BriefOverview … · The Chameleon board and its accompanying software is...

Date post: 14-May-2018
Category:
Upload: phungnga
View: 219 times
Download: 4 times
Share this document with a friend
22
Fli;' HEWLETT a:1:.tI PACKARD Pattern-Addressable Memory and the Chameleon Board: A Brief Overview and User's Guide Ian Robinson Computer Systems Laboratory HPL-92-83 June, 1992 database, knowledge-based systems, pattern recognition, parallel architectures, content-addressable memories, The Chameleon board and its attendant software is designed to provide a hardware and software environment for experimenting with a novel memory system called pattern-addressable memory . PAM (for short) supports rapid associative operations over arbitrarily structured data, from single words to complex expressions. Associative hardware's big advantage is in the support of rapid access to data that is dynamic, unpredictable and un-ordered, as evidenced by its widespread use in cache memories and TLB's. The PAM extends this functionality to encompass complex data-structures and the pattern-matching between them. This document outlines the syntax available for storing and querying data, a conceptual model of the hardware, the data-structures and functions provided in the software library, and examples of their application. © Copyright Hewlett-Packard Company 1992 Internal Accession Date Only
Transcript

Fli;' HEWLETTa:1:.tI PACKARD

Pattern-Addressable Memoryand the Chameleon Board: ABrief Overview and User's Guide

Ian RobinsonComputer Systems LaboratoryHPL-92-83June, 1992

database,knowledge-basedsystems, patternrecognition, parallelarchitectures,content-addressablememories, ~SI

The Chameleon board and its attendant softwareis designed to provide a hardware and softwareenvironment for experimenting with a novelmemory system called pattern-addressablememory. PAM (for short) supports rapidassociative operations over arbitrarily structureddata, from single words to complex expressions.

Associative hardware's big advantage is in thesupport of rapid access to data that is dynamic,unpredictable and un-ordered, as evidenced by itswidespread use in cache memories and TLB's. ThePAM extends this functionality to encompasscomplex data-structures and the pattern-matchingbetween them.

This document outlines the syntax available forstoring and querying data, a conceptual model ofthe hardware, the data-structures and functionsprovided in the software library, and examples oftheir application.

© Copyright Hewlett-Packard Company 1992

Internal Accession Date Only

Figure 1. The Chameleon board In an HP 9000/350 workstation.

1 Introductionchameleon n. An Old World lizard of the family Chamaeleonidae ... mostnotable for its ability to change color to match its surroundings.

1.1 Pattern-addressable memoryThe Chameleon board and its accompanying software is designed to provide anenvironment for experimenting with a novel form of associative hardware calledpattern-addressable memory. PAM (for short) is similar to CAM (content-addressablememory) in that its contents are accessed by matching against some input. The majordifference is in the nature of the data concerned.A CAM, typically, operates on fixed length words where the 'match' is computed by asimple bit-wise comparison of the stored words with the input - or part ofit. The PAMalso stores data as fixed length - 32-bit, in fact - words, but is organized such thatsequences of these words can be strung together to form arbitrary length expressions.In addition, a range of different data-types are supported allowing, for example,integers, various forms of wild-cards or don't-care's, lists and other sub-structure tobe both stored and matched against. The matching rules for these various data-typessum to define how expressions match one another. This function is called pattern­matching.

1

This document will briefly describe the nature of these expressions and of the PAMarchitecture. Itwill also describe, with a number ofexamples, the functions supportedby the hardware that are provided in the accompanying software library.

1.2 The wide world of pattern matchingBy providing a flexible expression format and reasonably rich syntax a number ofapplication styles can be supported. Figure 2 illustrates a number of these using asimplified, black-box view of the PAM.

.-

database system, (a) stored or ...

...working memoryelements

rule fired

(d) expen system

database

atch

(b) streaming

SUb-goals

match

(e) logic programmingsystem (Prolog)

events/updates

triggeractivated

(c) Interrupt driven system

input stream

(f) parser

Figure 2. (a) - (e) Pattern matching applications

2

An important feature that this figure illustrates is that, because the same syntax isavailable to both, the object of the pattern matching function can be either the storedor match input expressions. This is best illustrated in Figure 2, (a) and (b). In (a) thematching expression(s) in the database are selected - the match signal indicatingtheir presence. In (b) the successful query is selected and the match signal allows thecorresponding database expression to be captured.The other applications illustrated show a pattern-directed interrupt system whereactions, or combinations thereof, causes 'triggers' to be fired - in the case of the PAMby selecting the activated trigger(s) and signalling its/their presence. This also couldfind application in 'active database' systems where particular updates trigger certainprocedures. In (d) this same concept is extended into the realm ofproduction systems:the actions and state triggered on are now the 'working memory elements', and nowit is complex rules that are fired rather than simple triggers. In (e) we go back to thestored database paradigm and exploit its similarity with part of the execution processfor a logic programming language such as Prolog. Particular clauses are selectedbased on whether their left-hand-side's match a current sub-goal in the system.Lastly (0 shows an application of pattern matching to a template driven parsingsystem. Like the streaming database example, particular constructions can bedetected and flagged as the input stream goes by.

In all these applications the big advantage of associative hardware is that it is fast.However complex the data-structures involved, pattern matching takes place on thefly as the match input is entered. Perhaps more important however is the fact thatthe computational complexity of the matching process is directly borne by thehardware, not through the use of software, e.g. complex indexing schemes. Theselatter can be particularly problematic and overhead-laden when the data-structuresused are complex and/or dynamic and/or when very general, ill-defined access isrequired [Robinson92]. With the PAM a data-structure is simply written to thememory and is thence immediately accessible via any word, or combination of words,within it. It can be selected and deleted, and then it is gone; with no pointers to clearup or trees to balance. It is these characteristics that have led associative hardwareto see widespread use in cache memories and translation look-aside buffers (TLB.'s),and these do not even involve complex data-structures.

1.3 The Chameleon boardThe Chameleon board itself contains an array of PAM chips. These are currently fullcustom VLSI chips designed in house. Massive parallelism is the key to the PAM'smatching performance. Each chip contains a roughly 50/50 (by area) mix of simpleprocessors, called match engines, and conventional memory cells l . All match enginesoperate in parallel within a PAM chip, and across all PAM chips in the system. Thecurrent version is a small prototype - primarily orientated towards demonstrating

1. It is interesting to compare this with today's SRAM chips where the actual memory cells occupy onlyroughly 60% of the chip area.

3

functionality. Each chip has 32k bits of memory. The current version of theChameleon board (see Figure 1) is designed to be DID-II bus compatible, meaning itplugs into HP 9000 series 300 and 400 family workstations. It carries from one tosixteen PAM chips, giving a maximum per-board capacity of 512k bits. Up to sixteenboards can run concurrently off the same host. The software to interface to the boardconsists ofa C library ofPAM routines, like 'pam_match' for example, and a header filedescribing the data formats used by these routines.

The architecture enjoys the bandwidth and scalability advantages inherent in itsSIMDl organization. The computational bandwidth on even the small prototype chipby itself is in excess of 1.3 gigabytes per second. The system can be scaled more or lessarbitrarily: more memory to a chip (through larger die and tighter design rules), morechips to a board (through better packaging, e.g. SIMM's), and more boards to asystem. Through these techniques a 1Mb capacity chip is quite feasible. Sixty-foursuch chips contained on sixteen SIMM's could populate one EISA board. Four suchboards would give a 486-based Vectra, or a 90001720 or higher series workstation, aPAM capacity of 32 megabytes, and a match performance of 1.3 terabytes per second.

Section 2 will describe the format of expressions and their syntax as supported by thePAM. Section 3 will describe a simplified model of the hardware. This will make iteasier to understand the various library functions described in section 4. In section 5we conclude with some examples of the PAM's application.

2 Expressions: format and syntaxThe expressions stored and matched upon in the PAM are made up of strings ofwords. Each word is termed a symbol, and it is the atomic unit of data storage in thePAM. There are seven main symbol types; these will be described in the followingsections.

2.1 Headers and constantsTable 1. The 'stock' relation

part bin no. quantity

nutj l Omm 518 480

bolr Himm 519 200

nut Bmm 418 120

Table 1 describe a simple parts stock database relation, 'stock'. The three tuples canbe represented in PAM as the following three expressions. We shall assume for thepresent that the database expressions are stored (as in Figure 2(a».

1. Single Instruction, Multiple Data.

4

@stock nut_10mm 518 480

@stock bolt_10mm 519 200

@stock nut_8mm 418 120

expr.lexpr.2expr. 3

Each term in these expressions, e.g. '@stock', 'bolt_10mm', '120', is a symbol. Twodifferent symbol types are illustrated here. Headers, represented in the text by apreceding '@', and constants - the remaining, unadorned, terms. Symbols of the headertype serve to indicate the beginning of an expression, whilst constants are the symboltype primarily responsible for carrying information. In the above example we use theconvention of making the header symbols' value be the (encoding of the) name of therelation to which the tuples belong.

Besides their type, symbols also have a value which encodes the symbolic names (e.g.'. 'boIC10mm') and integers (e.g. '23519'). The encoding is assumed to be maintained by

the application (via some symbol table mechanism)

- all the PAM sees are bit-strings. The details of how symbols are represented as 32­bit words will be described later.

Pattern matching between a pair of expressions entails a sequence of pattern matchesbetween their constituent symbols. First the headers are matched together, then thenext symbol, and so on. In many cases the various symbol types are defined primarilyby what other symbols they can match. Headers, for instance, can only match otherheaders, moreover their values must be identical. Constants match other constantsagain only iftheir values match.Headers serve to locate and initialize a pattern matchbetween two expressions (as will be demonstrated in the next section). If the headers'don't match the expressions cannot. Constants, on the other hand, only match otherconstants if their names, or values, match.

2.2 VariablesVariables provide a way of representing incomplete information. They act aswildcards or don't-care's. Variable are represented in the text via a preceding '?', asshown in this example expression:

@stock nut_10mm ?bin_no ?quantity expr. 4This represents the information that there is a part called 'nut_10mm' but that its binno. and quantity are currently unknown. (Note the convention of having the variablevalue be the attribute name.) Variables match any other variable or constant, thename field plays no role in the actual pattern matching.

If expression 4 is used as a match input to the database consisting of expressions 1though 3, then expression 1 will be selected. Expression 4 therefore acts as a query,that query being to search for expressions of the 'stock' relation that contain'nut_10mm' as their first element. The expression ...

5

@stock ?part ?bin_no ?quantity expr. 5... matches all three expressions. In fact it describes any possible tuple from thatrelation.

2.3 StructureIn many application areas the data-structures used to store information are oftenmore complex than the simple linear expressions of our database example, in thatthey can contain sub-structure and lists, each of which can be arbitrarily nested. Inthe PAM the same simple mechanism of parentheses is used to delimit both of these.Consider a second database representing the status of robots in an automated versionof our stock room. Two sample expressions are given below. In the first we use thevariable naming convention, as in expression 5, to identify the attributes of a 'robot'expression. The second is an example of a particular database entry. It describes arobot, with an i.d. of '3', at location (3, 7) and carrying a cargo of 'nuCIOmm' and'bolt_lOmm'.

@robot ?robot_id ?location ?cargo_list exp~ 6@robot 3 ( at 3 7) ( nut_l0mm bolt_l0mm ) exp~ 7

'( at 3 7)', then, is an instance of sub-structure, whilst '( nuCIOmm bolt_lOmm )' is aninstance of a list.

In terms of pattern matching, parentheses only match other parentheses of the samehandedness. A more important pattern matching rule, however, is a consequence ofthe fact that we require expressions 6 and 7 to pattern match each other. For thisreason, a variable is defined to also match any string of symbols enclosed byparentheses, i.e. any sub-structure or list.

Note that we expand sub-structure in place rather than using pointers to it. Matchingcan be performed using constants for pointers, but this requires further processing ofthe expressions pointed to. The performance is not as good as random pointers cannotbe followed in parallel whereas in-place sub-structure can.

Parenthesis packing (an aside)Complex symbolic data-structures can become quite littered with parentheses, so thatthey occupy a disproportionate number of slots. This is countered in two ways. Firstlyone parenthesis symbol can stand for, and match against, any number of consecutiveparentheses of the same type. Secondly a parenthesis immediately followed by aconstant can be stored in a single word. Using this technique expression 7 onlyoccupies eight words, instead of eleven.

2.4 List VariablesMany symbolic languages have constructs to represent all but the first symbolts) in alist structure (i.e, the cdr). List-variables are similar to ordinary variables except thatthey can match any number of consecutive symbols within an expression, rather thana single symbol or sub-expression. Like variables, their value is ignored by the

6

pattern matching function. List-variables are represented using a preceding '&' in thetext. They are particularly useful when dealing with unordered and arbitrary lengthlists, as shown in the following pair of matching expressions:

@robot 5 (at 5 2) (nuts_10mm washers_10mm bolts_10mm) expr.8@robot 5 (at 5 2) (&stuff bolts_10mm &stuff) exp~ 9

Note that the second instance of the list variable matches zero list elements. The list­variables pattern matching capabilities are, in fact, even more general in that it canmatch any number of any symbols, except headers. Thus ...

@robot &rest_of_expr

'" matches any 'robot' expression.expr.10

2.5 EmptiesThe seventh, and last, main symbol type is the 'empty'. Empties are used to markunoccupied space within the PAM storage. Nothing matches an empty.

2.6 Ternary formatIn addition to type and value, symbols have two additional properties: ternary andexact. Both have only two states, either 'on' or 'off'. The past discussion assumed bothto be off.

If a symbol is tagged as 'ternary' then the value part of that symbol is expressed in aternary format. This format exploits the hardware's ability to control patternmatching at the bit level. A ternary digit, or trii, is essentially a binary digit with athird, 'don't care', state (usually denoted by an 'X'). In the text trit-strings will bepreceded by COt'. For ease of manipulation by the host, the ternary word is representedas a combination of a binary data word and a binary mask. Bits set in the latter maskoff corresponding bits in the data word. When ternary is 'off then the conventionalbinary format, simple bit-strings, is used to encode integers and names.

This ability to use bit-wise don't-care's has a number of applications both inrepresenting numeric and symbolic values.

NumericalU sing our previous example, the approximate position of a robot could be indicated byusing don't care bits for the lsb's of the location co-ordinates. Thus ...

@robot ?robot_id ( at Otl01XX OtlOXX ) ?cargo_list expr. 11... would describe a robot anywhere in the region 20 $ x $ 23, 8 $ y $ 11. More generalinequalities can be represented, and matched against, using lists and list variables,e.g.17 s x ~ 3 and x =12:

_ (OtlOOOl Ot01XOO OtOX100) x _

... (&range OtOllOO &:range) x ...

Note that where symbol values are used by the pattern match, the symbols must havethe same format for the match to be successful.

7

SymbolicIn the symbolic domain the counterpart of such numeric imprecision can be thoughtof as conceptual generality. For example, if'dark-blue' were represented by'Ot011010'and 'light-blue' by 'Ot011011', then 'blue' could be represented by 'Ot01101X'. This ideacan be extended to the construction of hierarchies of terms such as the parts hierarchyshown below.

fasteners: Otl01XXXX

nuts: Otl0100XX

Otl0l0000

Figure 3. Parts hierarchy

Then any match on 'nuts', for example, would also match not only those below it inthe hierarchy, but also those above it, i.e. 'fasteners'. There are obvious similarities totype hierarchies in object oriented systems.

2.7 ExactThe exact property does not so much modify the symbol itself, as the way in which thesymbol is used as a match input. Consider the problem of selecting expression 9 onlyif all three of expressions 8 through 10 were stored. This cannot be done using thepattern matching rules outlined so far. The exact tag is only used on match inputsymbols. It has the effect of requiring matching symbols to match exactly, type fortype, value for value - even for variables. Thus if expression 9 were entered as thematch input with the exact tag set on each symbol, only the stored expression 9 wouldbe selected.Exact matching can also be used on only a few symbols in an expression, constantstypically, to restrict the wealth of matching possibilities that the use ofvariables andlist-variables can entail.

2.8 The 'Symbol' data-structureFigure 3 shows how the various symbol properties are encoded into the 32-bit wordsused by the hardware (and the host and its backplane). If28-bit's worth of names, or12-trit ternary-words! prove too restrictive, consecutive symbols can be paired up bythe application. The 'exact' tag is not encoded in the physical word as it controls howthe word is used as a match input. It is not used in stored symbols.

I. The asymmetry in the ternary value fields allows 16-bit values to be stored with a zero mask. It was felt that the popularity of this field widthoutweighed the benefit of being able to store 14 trits rather than 12. For example it allows short integers to be compared with ternary formatnumerical ranges.

8

ternary tag

12-bitmask

28-bit value

16-bitdata

Figure 4. PAM symbol physical formats

Applications can access and manipulate these symbols through the C data-structure'Symbol', supplied in chameleon.h. This provides the following fields, 'value' being aunion of types 'unsigned long' and Iter':

• char Symbol. type ... used to store the type value: one of {HEADR, CONST,VARBL, OPENP, CLOSP, LISTV, EMPTY} (defined in chameleon.h)

• unsigned long Symbol. value. bin ... used to store a 28-bit binary value

• unsigned short Symbol. value. ter. data ... used to store a 16-bit binary value,or the 12-bit 'data' part of a ternary word

• unsigned short Symbol. value. ter .mask ... used to store the 12-bit mask fora ternary word

• char Symbol. ternary ... either '1' or '0'.

• char Symbol. exact ... either '1' or '0'.An array of Symbols terminated by the empty Symbol (similar to the '\0' in chararrays) constitutes an expression. The final 'empty' is not stored in the PAM, as sucha policy would waste space. Its presence can be inferred from the location of theheader belonging to the next expression. Similarly the 'empty' signalling the end of amatch input is not sent to the PAM, it merely signals the match routine to end.

Such are the things expressions are made of, now to how they are stored and operatedon.

3 The PAM hardware: a conceptual modelSuch are the things expressions are made of, now to how they are stored and operatedon. To understand the various operations supported by the Chameleon board it ishelpful to have some idea about how the hardware is organized. In this section wepresent a conceptual model of the board. This represents a somewhat simplified, andidealized, view of the actual PAM hardware. However the Chameleon hardware andsoftware conspire to present this view to the user.

The Chameleon hardware consists of the array of custom VLSI PAM chips describedin the introduction, together with an array controller. For the purposes of this

9

••...•......•••..............••••........••.•..•.••...••...•.....••••...•...•....••

dop-co e

symbol inoutloutpul/( uery

• llr

slot @robot match loaic3

(~

'p10-1I bus array atHOST -- .. controller - 3-- 7

· )· ·· ·· · ·• I •• · II · II · II · •· · •· • ·· · •• • •· · II • •IIIIII····I·II·I •II ,····I JIII

lce_f1_~_~~_~l?t!_!l_~!\_F:l!1l~.1_________~~~ ___________________

/' I data-bus I I I I 1\1 1

symbol store ~ readlwrile

~~~~match

~match logiccomparator

~ ~ ~ active

"-. I op-code I I I

Figure 5. Conceptual model of Chameleon hardware, with detail view of slot(storage plus comparator) and Its associated match logic.

exposition the memory and match engines of the whole PAM array can be regardedas a single array of symbol-wide storage slots, each with its own comparator andmatch logic (Figure 5). It is the combination of the later two that constitutes a matchengine.

10

Each match engine has three bits of state:

• M: the match flag, indicating the current match state.

• R: the read pointer, controls connection of the slots contents to the data bus

• W: the write pointer, controls writing of slots contents from the data bus

The array of storage slots is managed as a stack, with the write pointer serving as thetop-of-stack pointer. Expressions are written to this stack header first, one symbol ata time over the data bus, so that consecutive symbols occupy consecutive slots (asshown in Figure 4). An overflowsignal indicates to the controller when the PAM arrayis full.

During pattern matching it is the match input that is entered header first, andbroadcast to all match engines. As each symbol is entered, every match engine acts inparallel to compare its slot's contents against the input symbol, and update its matchflag accordingly.

In computing the pattern match of two expressions, it is the sequence of theirindividual symbol matches that is important. This sequence starts at the header and,in the case of matching expressions, lasts through to the final symbol matched by thequery. Expressions that mismatch will do so because somewhere through thesequence of symbol matches one fails. The match state must, therefore, take intoaccount not only the outcome of the individual symbol's match but also the previousmatch state in that symbol's expression.To illustrate this Figure 5 shows a simple example of querying the stock database.Note how the match flags mark the progress of the match through the storedexpressions. The result is that expressions that successfully pattern match with thematch input - the responders - are indicated by match flags on the last symbolmatched. This flag is responsible for selecting responders for subsequent operations.An 'active' signal - essentially a logical 'OR' of all the match flags - serves as anindication to the controller that responders exist.

The creation and movement of match flags gets rather more complicated when sub­structure and variables are matched, but the overall concept is the same. E.g., givena stored substructure and a variable as a match input, a match flag at the beginningof the sub-structure will be moved to its final parenthesis. Special circuitry takes careof performing such matches in one cycle; nothing interferes with putting a new matchinput symbol in on every cycle.As indicated in the introduction the subsequent operations fall into the categories ofoutput, update and deletion. These will be explained in more detail in the next sectionwhich concerns the library functions supplied with the hardware.

4 Library functionsThis section describes the functions supplied in chameleon.I. Currently Chameleoninteracts with HP-UX only at the application level, i.e. through simple reads and

11

­..lit.

(a) (b) (c)

@stock nut

@stock

nut_10mm nut_10mm nut_10mm

23518 23518 23518

480 480 480 •@stock @stock @stock

bolt_10mm bolt_10mm bolt_10mm

23519 23519 23519

200 200 200

@stock @stock @stock

nut_8mm nut_8mm nut_8mm

23418 23418 23418

120 120 120

(d) (e)

?part_no <256

@stock @stock

nut_10mm nut_10mm

23518 23518 Figure 6. Pattern matching Inprogress. (a) PAM storage In some

480 480 Initial state. (b) State after match on

@stock @stock '@stock'. Irrespective of previousstate, match flags are created on

bolt_10mm bolt_10mm matching headers. (c) though (e),

23519 23519 match flags are passed on to the nextslot If It matches, otherwise they are

200 200 destroyed.

@stock @stock

nut_8mm nut_8mm

23418 23418

120 120

12

writes (and no interrupts). This allows the use of the IOMAP option with IOCTL[HP-UX87], to simply map the board into the user process space, rather thanrequiring the use of a device driver.

In the following we use the convention that '*xp' is a pointer to an expression (anarray of 'Symbols'). The affects of the various operations on the contents, and state, ofthe PAM are illustrated in Figures 7 and 8.

4.1 Initializationlibrary functions: int paULinit (void)

Pam_init sets up the mapping of the boardls) into user process space, making itavailable for the other commands listed below. It also initializes the hardware andruns a small diagnostic routine to check it. The function returns the system capacityin 'k's' of symbols.

4.2 Insertlibrary function: int pam_assert (Symbol *xp)

This function inserts the given expression into the PAM array. The expression isappended to the current stack and the write pointer moved accordingly. The functionreturns '0' if the stack overflows. Figure 7 (a) and (b) shows the PAM (model) beforeand after inserting an expression.

4.3 Selectlibrary functions: int pam_match(Symbol *xp}

int pam_headers(void}

The match function works as described in the previous section. The function returns'0' if there are no responders. The process of pattern matching, as we have seen, leavesthe match flag at the ends of the responders. In some cases it is more convenient tohave their headers marked instead. This operation is performed by the headersinstruction and is directly supported in the hardware.

4.4 Outputlibrary functions: int pam_respondx(int nth, Symbol *xp}

Symbol pam_responds(int nth}Symbol pam_nexts(void}void pam_reset (void)

All output is mediated by the read pointer. This is achieved through a combination ofmoving it to slots marked by match flags, and then using it to read out those slots ­and successive ones if required.The function respondx is used to output whole responders, one at a time, in the orderin which they occur in the stack. The first argument, 'nth', determines which of theresponders gets output: first, second, third etc. - all relative to the current position ofthe read pointer. If 'nth' is '0', the first responder (in the order of stack growth) is

13

~.

(a) Initial state. Write pointermarks top of stack. Readpointer 'at rest' at bottom ofstack.

(b) Insert "@stock nut_8mm23418 120". Write pointermoves to reflect new top-of.stack

(c) match "@stock ?part?part_no. <256". Matchflags mark the two responders

(d) headers

,,,......~120

200

480

23519

23518

23418

@stock

@stock----_....---_..,

"'~"":

_._ ..:'...._.1,,,,..---_......_-.··,-----_._-----:,,,-------_ .. - .... .1,,,,-- ..........----_...,,,........................ -:··,----------_....~,,,

! ·@stock

nut_10mm

23518-

480·

@stock

bolt_10mm .23519

200

@stock

nut_8mm·

23418

120

(e) first respondx returns"@stock bolt_10mm23519 200" and stops atthenext header.

"'~"':_...._~ ........ ~,,,..............:

•••______ .. .1

,,,•

---------· .... -4·,,,----------.. _.,,,,------------~·••-------------4,,,........~-------_.... ,,

•,__ ._._. 4

,,,,-------_...._-,··•--_._ .. _.. _-_ .. -:~

·@stock

nut_10mm

23518·

480

@stock

bolt_10mm·

23519

200

·

-

Figure 7. Inserting, matchingand output.

,,··.. --,,,·••• J·,,~------+_ .._-----_....-:,·,~------+---------_._-:,,

..•...••.~

r-------------------.L----, ••••••••••••• ~

·········JI-i~------+ _ ",·,·~----------------------f ~,,~------+:-.:'-_....-- .:

..._~.....@stock . : @stock·....- ....:

nut_10mm ,nut 10mm, -,...____________ .1

23518 · 23518··,480 480

@stock @stock

bolt_10mm bolt_10mm

23519 23519

200 200

@stock @stock

nut_8mm nut_8mm

23418 23418

120 120

14

returned. The function assumes that a prior pam_headers instruction has beenperformed. The read pointer is thus moved to the header of the 'nth' responder - if itexists (again the PAM contains special circuitry that directly supports this operation).The body of the responder is then read out a slot at a time until either a new headeror an empty is encountered, then the function returns. The resulting outputexpression is stored in the array given by the second argument. The function returnsthe length of the responder (i.e. number of symbols), or '0' if no such responder isfound.

The two distinct actions described above - moving to a responder followed by output ­are also made separately available as the functions pam_responds and pam_nexts,the's' indicating that they operate on a symbol by symbol level. Pam_respondsreturns the contents of the 'nth' marked slot if it exists, an empty if it doesn't. InFigure 8 (b) this is used as part of an update operation. If no previous pam_headersoperation is performed then the slots accessed will be the last ones matched upon.

. Pam_nexts simply reads the next slot (with a corresponding advance of the readpointer).Pam_reset resets the read pointer at the bottom of the stack. Using pam_resetfollowed by a series ofpam_nexts's allows the output of the stacks contents. However,when examined this closely, the single stack model begins to break down.

4.5 Modifylibrary functions: void pam_update (Symbol data)

void pam_updateAll(Symbol data)

The action of pam_update is illustrated in Figure 8 (c). The symbol currently markedby the read pointer is replaced with the input symbol 'data'.Pam_updateAlI is similar, but in this case 'data' is used to overwrite all slots markedby a match flag. This write operation occurs in parallel over all the enabled slots. Itallows, for instance, all instances of a certain variable to be replaced with someconstant, or all responders to be tagged with some i.d. or state.

4.6 Deletelibrary functions: int pam_retract (Symbol *xp)

void pam~arbageCollect(void)

void pam_empty(void)

Pam_retract replaces with empty symbols expressions that match! the argument.The expression is therefore effectively deleted, but still occupies physical space(Figure 8 (dl). The function returns '0' if there are no responders.

1. When retracting all symbols should have their 'exact' property set. The input should therefore be in exactone to one agreement with the expression to be deleted. This makes it more selective and avoids the problemof accidentally deleting other, perhaps more general, expressions that happen to pattern match.

15

1::

(a) Initial state, after a matchon'@stock bolt_10mm?part_no ?qty'.

(b) responds returns '200' (c) update with '450'. ••

;

@stock

nut_10mm

23518

480

@stock

bolt_10mm

23519

450

@stock

nut_8mm

23418

120.........~

..---------,.. ,

,,,•• o •••••~

200

@stock

@stock

nut_8mm

23418

120

23518

480

@stock

bolt_10mm

23519

A""'1~ .... _..:,,,._ .. _-----:,,,..-------~,,,,___ ._•• __ 4

,,,,-----...--,,,,........._---:,,,_ .. 4

,,,,-------_.,,,,...._--_ ... .-:,,,_____ ... __ J

,,,,---------,,,,....~

_.. _- ..@stock

......nut- 10mm ....

23518 .....480 ....

@stock ....bolt_10mm .....

23519 .200 .

@stock .....nuts- 8mm .....

23418-..-.

120 ._--.

(d) state after a delete on'@stock bolt_10mm?part_no ?qty'.

(e) state after garbage collect.

Figure 8. Modifying, deletingand garbage collection. (a) •(c), updating a record: add 250pans to 'nuC10mm'. First findthe 'nuc1Omm' record and getthe match flag on the right slot• In this case the last. Then usepam_responds to output thatvalue to the host. Add 250 anduse pam_update to write In thenew value, '450'. (d) and (e)show the results of deletionand garbage collection.,·,,-_.....--.----.,,·----_ -:,

•••~.'''OJ. ,,,----- --_.,--_ .. _----_ .... -:,,,--------._--~,·,...-----------,··,_.. -._ .. __ ...._-:

,,·------_._-_ .. ~,,,.._-----------.·,,~~~~~~~~.,·,

0

@stock

nut_10mm

23518·

480

@stock

nut_8mm·

23418

120

0

·

....~....... :,----- ..... -:,,,_____________ J

,,,,------_ .. -----4,,,,-------------,,,,-------------:,,,_____ .... 4

,,,,-----------_ ..,,,,--_ ...._-_......_-0{,,,_____________ J

,,,,-------------,,,,--- ..... --- •••J,,,.........~

!@stock

nut_10mm

23518

480

.

@stock

nut_8mm

23418 .120

16

At any time pamgarbageflollect can be run to reclaim this space. Garbage collectionis supported within the PAM chip circuitry. This enables all chips to garbage collectin parallel so that the entire process is fast - with the current Chameleon board (orboards, it doesn't matter) this process takes about a millisecond.Pam_empty does what it says, writing empty symbols into every slot and setting thewrite pointer to the bottom of the stack.

5 ExamplesGiven the functions described in the previous section, we can now illustrate their usein a number of example applications.

expr.12expr.13expr.14

blank blank blank )

nut_Bmm blank blank

nut_10mm washer_10mm bolt_10mm

at 0 0 ) (

at 3 B ) (

at 7 9 ) (

@robot 2

@robot 3

5.1 Querying the robot databaseFirst let us return to the example of the robotized stock room, where there exists acentral database, stored in PAM, recording each robots position and cargo. For

. example:@robot 1

Note the use of dummy list entries, 'blank's. These make updates to the cargo listeasier since, if we assume robots carry no more than three things, updates can beperformed in place. Otherwise a new expression would have to be created with thelonger list, and the old one deleted. Also, if the bulk of the changes are updates thengarbage collection, even though it is fast, will not happen often.Thus 'bolt_Bmm' could be added to robot 2's cargo list by the following code (in thefollowing expressions are represented textually, enclosed in square brackets, toenhance readability):

pam_match([@robot 2 ?locn (]);pam_responds(O); /* move the read pointer to 2's cargo list */while (pam_nexts() != [blank])

; /* move it on to the first blank entry */pam_update ( [bol t_Bmm] ) ;

To further simplify the code the possibility of duplicate entries has been ignored.To determine, for example, if there are any robots in the region 20 ~ x ~ 23, B~ y ~ 11that happen to be carrying bolts, the database can be queried as follows (query A):

pam_match([@robot ?id ( at OtlOXX OtllXX ) ( « bolts « )]);pam_headers();pam_responds(O);robot_id = pam_nexts();

Another query could be run to find any robots on the x = 3 axis (query B) using '"

17

pam_match([@robot ?id ( at 3 ?y ) ?cargo]);

Note that, for the purposes of this example, both queries avoid indexing on the i.d.(e.g. 'Where is robot 4?'), the access instead being via the more dynamic elements ofthe expressions.

To give some idea of the hardware performance, some actual times for theseoperations are given below. Actual match times depend to some extent on the size ofthe stack, the number of responders and their distribution in the stackl . These resultsare tabulated below as averages of the best and worst case times for the variousconditions, given one 4MHz Chameleon board. The PAM chips themselves canactually run at 10MHz2 (and even then were designed to demonstrate functionalityrather than speed).Future implementations should have little problem running at20MHz - i.e. five times faster than the figures quoted.

Table 2. Average match, output and update times (In microseconds)

no. of board full of '@robot's board quarter full of '@robot'srespon- match match output

updatematch match output

updateders query A query B of first query A query B of firstU 36.4 24.6 0 9.2 6.1 01 38.5 26.1 1.5 42.2 11.0 7.7 1.5 14.62 38.8 26.9 3.1 11.5 8.4 3.13 39.7 27.7 4.1 12.0 9.2 4.14 40.2 28.4 5.1 12.6 10.0 5.1

With the board a quarter full the status of roughly 500 robots can be tracked. Therobot expressions, and the slot values within them, can be subject to constantinsertion, deletion and modification. The figures above imply that such a system couldsupport interleaved query and update rates of roughly 37,000 expressions per secondeach. This corresponds to allowing each robot's status to be updated roughly every 14milliseconds. Note that match times are relatively insensitive to the complexity orgenerality of the query.

5.2 PrologThe execution of Prolog programs can be thought of as an extension of this querying­a-database scheme. Prolog uses such pattern matching between sub-goals andknowledge-base clauses in its fundamental execution mechanism, unification.Unification is essentially pattern matching plus the handling of variable bindings.The latter is not a task particularly amenable to parallel hardware, however patternmatching alone provides an excellent solution to the problem of finding candidateclauses for unification. Although compilers exist for Prolog, the PAM facilitates thehandling of dynamically created clauses and rules [Robinson86, Kogge89].

1.Noneof which wouldbethe case if the hardware actually conformed to the model2. The controlleris the weak link• being basedon some fairly slowPLD·s.

18

­.....

5.3 TriggersAs was outlined in the introduction the expressions stored in the PAM can also takeon a more active role as triggers that are activated by particular match input.Returning to the robot example, these match inputs could be used to represent theevents observed by the system, and actions can be triggered by the responders tothese events. For example, some process at location (9.5, 13.5) that requires boltscould insert the following expression, and await a match.

@robot ?id ( at 10XX 11XX ) ( & bolts & ) snag_robot exp~ 15The final 'snag_robot' is a pointer to code that will cause the passing robot to beintercepted. The robots then continuously report changes in their state to Chameleonas match inputs instead of updates.Updates (for example our robot 2 moving to (3, 9»and checks for trigger activation would then take the form:

if (pam_match([@robot 2 ( at 3 9 ) (nut_8mm blank blank) ?action]»action = pam_responds(O);

" Just as before, the PAM can hold thousands of triggers and allow them to beconstantly created, modified and deleted. This style of operation allows for the kindof 'interrupt-driven behavior' popular in real-time control systems.

5.4 Triggers with multiple conditionsIn this example we represent multiple conditions using sub-expressions withassociated state. The state indicates whether that particular condition is satisfied ornot, and is changed by an update conditional on the body of the condition beingmatched (see Section 4.5). Periodically a test is made for triggers that are enabledthrough all their condition elements being true.Consider the case of PAM being used in a particular robot's control system. Furthersuppose we wish to trigger some action based on the quantity of some particular partcarried and the robot being in a certain vicinity. Expression 18 can be used torepresent this condition.

@if (robot_locn ( at Ot101XX Ot10XX ) falsecargo_qty bolts <1024 false

) trigger <action> expr. 16

Given conditions in this form, updates must be specially encoded to match. The thirdand fourth lines in the update code below find conditions that match the new event ­'robot_locn ( at 3 7 )' - and update their status to 'true'. To correctly toggle theconditions' state potentially matching conditions must first have their state reset tofalse before selectively setting matching conditions to true, hence the first and secondlines:

pam_match [@if &c robot_locn ?loc true]pam_updateAll [false]pam_match [@if &c robot_locn ( at 3 7 ) false]pam_updateAll [true)

19

The periodic tests for satisfied triggers plays upon using the symbol types to controlthe pattern matching process within the stored expressions.

pam_match([@if &c false]);pam_updateAll([@false]);if (pam_match([@if ?test_jump trigger ?action])} pam_responds(O};pam_match([@false]};pam_updateAll([false]);

If an '@if expression contains unsatisfied conditions then turning the accompanying'false's into headers breaks the expression up. Ifthe expression remains unbroken, i.e.ifall its conjuncts are satisfied, then the whole sub-structure containing the conjunctscan be matched with a single variable, otherwise it cannot. This match (on'?testjump') can therefore be used to find responding actions. Any that are found areaccessed by pam_responds. The check completes by returning the 'false's to theiroriginal state.

.. 5.5 'Active data structures'The previous section demonstrated the PAM's ability to update the state ofexpressions in parallel based on certain criteria. Each expression can be thought of asrepresenting a finite-state machine whose transitions are driven by the match andupdate instructions. We shall call this representation an 'active data structure'. ThePAM can be used to store a large number of active data structures, which are allupdated in parallel based on a broadcast series of state transition rules.

5.6 Templates, scanners and parsersTriggers can also be thought of as templates, scanning, or perhaps parsing, theincoming expressions for sequences that pattern match. In its simplest form thisapplication would be equivalent to the database scheme wherein the queries arestored in PAM and the database is streamed by. Such an arrangement could be usedto scan the contents of a hard disk for matches. The PAM array, as it is currentlyconfigured, has an input bandwidth over its shared data bus of 32bits every 512ns,equivalent to approximately 8MB/s. This compares nicely with current disk outputrates of up to 5MB/s. The PAM could contain hundreds of queries, all of which wouldbe processed in parallel.

5.7 Production SystemsTriggers are also roughly equivalent to the situation-action rules found in productionsystem style languages. Rules are fired based on particular combinations of events (orworking memory elements). As with Prolog there is the added complication ofhandling variable bindings across condition elements. Various ways of supportingthis using associative hardware have been demonstrated [Kogge89J. Again compilersexist for OPS5 - one of the most popular production system languages - but again thePAM again provides the capability to handle dynamically created rules with minimaloverhead.

20

5.8 MiscellaneousBlackboard systems [Hayes-Roth85] are a popular software architecture for AIsystems applied to monitoring and control in complex environments. The blackboardprovides a central knowledge base shared, transparently, by a number of knowledgesources. It serves to establish the context for knowledge processing actions, provide arepository for hypotheses, and control the problem solving process. Knowledgesources are scheduled based on events posted to the blackboard. All of these processesare associative in nature and commonly involve dynamic data. The PAM is thereforealso well suited to use as a 'blackboard accelerator'.Lastly there are fields such as memory-based reasoning [Stanfi1l86] and geneticalgorithms [Goldberg89] in which systems attempt to reason or adapt themselves inthe absence of rules. Such applications rely almost entirely on pattern matching andappear to be well suited to the capabilities of the PAM system.

. References[Goldberg89] D. E. Goldberg, Genetic Algorithms in Search, Optimization and

Machine Learning, Addison-Wesley, Reading, Mass., 1989.

[Hayes-Roth85] B. Hayes-Roth, "A Blackboard Architecture for Control", Journal ofArtificial Intelligence 26(3): 251-321, July 1985.

[HP-UX87] HP-UX Reference, HP 9000 series 300/800, vol. 3, section 7, Hewlett­Packard Co., 1987.

[Kogge89] P. Kogge, J. Oldfield, M. Brule and C. Stormon, "VLSI and Rule-BasedSystems", VLSI for Artificial Intelligence, J. G. Delgado-Frias and W. R. Mooreeds., pp. 95-108, Kluwer Academic, Hingham, Mass., 1989.

[Robinson86] I. N. Robinson, "A Prolog Processor Based on a Pattern MatchingMemory Device", in Proc. 3rd International Conf. on Logic Programming, E.Shapiro ed., pp. 172-179, Springer-Verlag, New York, 1986.

[Robinson92] I. N. Robinson, "Hardware to Support Runtime Intelligence", Computer,May 1992 (to be published)

[StanfilI86] C. Stanfill and D. Waltz, "Toward Memory-Based Reasoning",Communications ofthe ACM 29(12): 1213-1228, December 1986.

21


Recommended