Parallel Algorithms for String Matching Problem on Single and Two Dimensional Reconfigurable Pipelined Bus Systems

: W e considered string matching on LARPBS and 2D LARPBS. This has applications such as string databases, cellular automata and computational biology. The main use of this method is to reduce the time spent on comparisons in string matching by using LARPBS. We investigated exact string matching and approximate string matching problems. For these two sub problems, we obtained O (n) bus cycles algorithm and constant bus cycles algorithm. These algorithms have some disadvantages: Reconnecting the sub buses and shuffling the contents .These problems can be solved by 2D LARPBS.


INTRODUCTION
String matching mainly deals with the problem of finding all the occurrences of a string in a given text. String matching had been one of the most extensive problems in computer technologies during the past two decades. Pattern matching is widely implemented in information retrieval, web search engine, DNA sequencing [13,14,16] , artificial intelligence and several other fields. Two sub-problems for the string matching problem considered, the first is the exact string matching and the second is approximate string matching with k-mismatches. Experimental results of well known sequential algorithm can be found in [6,9]. Since the VLSI (Very Large Scale Integration) technology has been developed rapidly, hardware approaches have also been proposed [5,12] . But most of the algorithms that can be found in the literature multiphase algorithms; they need preprocessing phase in order to retrieve special structures in either the pattern or the reference string. It is then difficult to build special purpose hardware for just string matching tasks. We propose two kinds of parallel algorithms for both string matching problems without any preprocessing phase. First propose on-line solutions; it means that they process the inputs in turn, without knowledge of whole pattern at the beginning of the computation; its elements will be treated one by one. Then we give solutions that require a constant number of steps. Several computational models that have been considered for parallel string matching algorithms the PRAM model, mesh structure [17] and etc. The parallel string matching algorithm is often said to be optimal if its cost is O (nm). The first optimal O (log m) time string matching algorithm was introduced by Galil [3].
The text string of length n and a pattern of length m, Galil presented a optimal constant time complexity parallel algorithm with n processors for the exact string matching problem [3] on a conceptual CRCW PRAM model but this algorithm requires additional space and needs to preprocess the text string. Recently, on a linear systolic array, Park and George proposed an architecture based on data flow for both sub problems [15] , solving them in O (n/k+ ) where k is the number of streams and 1 m with k*m processors. In this algorithm the approaches were based on the computation of the well-known Hamming distance. The string matching problem solving on the LARPBS model, introduced by Pan and Li in [7] , it has known a growing success since the end of two thousands as well as all optical bus based models. Many authors have been discussed for sorting or matrix multiplication or selection [2,8,11]. The used pipelined optical bus, instead of an electrical one. The pipelined optical bus utilizes optical fibers to transmit information.

Larpbs Model:
The linear array with a reconfigurable pipelined bus system (LARPBS) consists of three waveguides. It is presented by Pan and Li in [7]. It is based on the ideas of using pipelined bus systems and processor array reconfiguration. This is called the one dimensional parallel processing optical model. In such model, a pipelined optical bus system uses optical waveguides instead of electrical signals to transfer the several messages which can circulate at the same time among processors through the bus in a pipelined fashion. The communication time for the LARPBS model is measured based on the number of bus cycles used. A bus cycle is the end-to-end propagation delay on the bus .The time complexity of an algorithm is determined in terms of time steps, where a single time step comprises one bus cycle and one local computation which is the time taken for an optical signal to propagate through the entire bus. The properties of optical bus as follows: Unidirectional propagation and predictable delay per unit length, in addition to the high propagation speed of light. These advantages of using waveguides enable synchronized concurrent access of an optical bus in a pipelined fashion.
The optical bus of a LARPBS processes three distinct waveguides. The message waveguide is used for sending data and the select and reference waveguides has been used for sending address information. The message waveguide is similar to reference waveguide. The shape of the bus is U structure, as per the structure of bus; the upper half of the bus is used for transmission and lower half for reception. Each processor is connected to the bus through the directional couplers, for transmitting and the other for receiving. Hence, the bus is divided into two segments, the transmitting segment and the receiving segment. The receiving segments of the reference and message waveguides have an extra segment of fiber between every pair of consecutive processors. The receiving segment is used to introduce one unit propagation delay in these two waveguides. Hence the propagation delays on the receiving segments of the reference and select waveguides not the same. In addition the select bus has switch controlled conditional delay between every pair of consecutive processors is placed on the transmitting segment segments of the select waveguide. The conditional delays can be implemented using 2x2 optical switches. The switch can function in two different states. If set to cross, a unit time delay is introduced On the other hand, if the switch is open the messages can pass-through without any delay. Hence many divide and conquer algorithms fit naturally into this model. The main features of the model is scalability and several basic data operations such as broadcast, multicast, split, binary prefix sum and minimum finding.

Reconfigurability:
The importance of this model in fact that it can support dynamic reconfiguration facility on the bus. The separate set of optical switches exists on each waveguide of bus. That's why some more optical switches inserted on each segment of the bus. Half of the optical switches on both transmitting and receiving sides (one per waveguide). If all these switches set to straight, the bus system operates only the select and reference waveguide represented [4]. The message waveguide is similar to the reference waveguide. P 1 and P 4 have their switches set to cross. P 2 , P 3 , P 5 have their switches set to straight (Fig:2.1). A regular pipelined bus system connecting all the processors. However, if the switches at processors P i set to cross, the bus is split into two separate buses, one connecting processors P 1 P 2 …P i and the other connecting processors Pi+1…Pn . Thus the whole is split into two separate LARPBS structures (only one waveguide is shown) . These two sets can work independently as two LARPBS.
Addressing: An address technology is called coincident pulse technique. The coincident pulse technique is the most common and flexible way of communication among the many methods. That addressing is done using the coincident pulse technique [11]. The coincident pulse technique helps in addressing b manipulating the relative time delay of select and reference pulses on separate buses so that they will coincide only at the required receiver. The coincident pulse technique uses frames for writing and addressing information. Each processor processes a select and reference frame that has N slots for the N processors on the LARPBS. If processor P i wants to send message to processor Pj, P i transmits a message frame on the message waveguide and a pair of select and reference pulses on the select and reference waveguides. The technique requires the select and reference waveguides of delays between the select and reference waveguides in order to make the pulses coincide at processor P j . With such method, it is possible to route messages or to broadcast messages on the optical bus. However when more than one message arrive at the same processor in the same bus cycle, it accepts only the first message, the others automatically ignored. It is due to the fact that an electrical processor cannot match the transmission speed of an optical bus [7]. Why the LARPBS is powerful model, and basic operations broadcasting , multicasting, binary prefix sum computation and compression [6,9].

RESULTS AND DISCUSSIONS
In results and discussion, designing of algorithms for both problems, such as the exact string matching problem [1] and the approximate string matching with kmismatches. These algorithms designed based on the Hamming distance. Hamming distance is used for error correction. So it is best of known for finding of differences between two strings. The Hamming distance is a measure of distance between two strings equal is the number of positions for which the corresponding symbols may be different, that need to be changed to obtain one from the other, as per the definition for the following two strings: "rama" and "rimu" have a Hamming distance of 2. Let A=a 1 a 2 ..a m and B=b 1 b 2 ..b m be two strings of length m , The Hamming distance of string A and string B, noted Ham (A,B) , is the number of locations where A[i]!=B[i], 1 i m.How to use this definition in order to solve string matching problem as shown below: Let us consider text(T)length of n and pattern(P) length of m. suppose there is an occurrence of P in T, it means the text string t i ,t i+1 ..t i+m-1 equal to P, so that H(t i ,t i+1 ..t i+m-1 ,P)=0. It is used for exact string matching problem. Suppose that there is an occurrence of P in T. It means that a factor t i ,t i+1 ..t i+m-1 of R is equal to P with at most k mismatches , hence Ham(t i ,t i+1 ..t i+m-1 ,P) k. It is used for string matching with k-mismatches. A naïve algorithm for solving the string matching problem can proceed as follows: consider the first n-m+1 positions of the text string. Occurrences of the pattern can start only at these positions. The algorithm checks each of these positions for an occurrence of the pattern. The time complexity for the occurrence of pattern is O(mn)

Fig. 2.3: A 2 D LARBPS
At this point, it can easily deduce a naïve algorithm for both problems on a LARPBS.Comparing all subscripts r i r i+1 …r i+m-1 of the reference string ( 1 i n-m+1) of length m with the pattern , let us denote those factors R i.. This solution requires the sending of m messages (p 1 p 2 …p m ) to perform the comparisons for each ri r i+1 ….r i+m-1 of a R i. As a processor can receive at most one message per cycle, it takes m cycles to compare the pattern with all the Ri . We must add m more cycles between them to make processor i know Ham (R i, P) from the m next processors. As it requires to know the pattern, this solution is not on-line. To reduce the number cycles to O(m) and obtain the algorithm on a LARPBS with O(n) processors. First, describe the approach with the exact string matching problem, and will show later how to easily adapt it for the approximate string matching problem with kmismatches. Given a string R=r 1 r 2 …r n of length n, it requires nprocessors LARPBS that contains an element of R on each processor, i.e. processor I contains the i th element of R. for designing of an algorithm require one source processor that sends the elements of the pattern P one by one. The main aim of computation, for a pattern of length m, processor i (1 i n-m+1) has calculated Ham(Ri ,P) , i.e. Ham(r i r i+1 …r i+m-1 , p 1 p 2 …p m ).

Constant Time String Matching Algorithm on LARPBS:
In this section introduce a new constant time string matching algorithm for the LARPBS model. When compared with naïve algorithm in O(m 2 ) cycles with O(n+m) processors, our algorithm requires more processors and is much simpler in constant cycles. The present algorithm use m*(n-m+1) processors on LARPBS. It uses a different strategy when finding the occurrence of string in a text (reference string). The reference string is decomposed into m sets of length n-m+1( L 1 ,L 2 ,..L m ). In each set L i is occurrences of P j , The j th element of P j then it is denoted by r k,j . if r k,j have m elements such that(k,j)={ (i,l), (i+1,2),…(i+m-1,m)} then r i ,r i+1 ,…r i+m-1 is an occurrences of the pattern. The string matching problem can solve in O (1) bus cycle with a m*(n-m+1) processors on LARPBS.
Algorithm for string matching (text n, pattern m) Begin

Multicast (Li):
Each processor Pi,j , where 1 i m and 1 j n-m+1, multicasts its Li to Pi,j and processor holding the first element of each set also carries an element of the pattern. Form sub-buses: processors Pi, where 1 i n, set their switches to cross in order to partition the array into m sub-buses. Each sub-bus has n-m+1 processor. Broadcast: the first processor of each sub-bus broadcasts the element of the pattern it carries.
Calculate matching array: each active processor Pi,j does the following multicast operation: uses the Ei and Pj to set its select frame , and then multicasts a dummy message within its sub-bus. If processor Pi,j receives a message in this multiple multi cast operation, then Pi,j sets its SUB-BUS(i) = i ; otherwise it sets SUB-BUS(i)=0.

Reconnecting processors:
To reconnect all the m subbuses.
Rearranging the data: the rearranging the order of processors is difficult, so we change their contents without rearranging the bus (i th processor of each subbus to be placed in the i th sub-bus in the same order).
Sub array: the array of bus is divided into n-m+1 sub arrays with the length of m. In the above algorithm identified three disadvantages: First, divide the bus into several subbuses, second, reconnecting the buses, third when we need to move the processors but it is not possible that has been solving by just change their contents. For solving above problem, propose a 2D LARPBS.

Constant Time String Matching Algorithm on 2D LARPBS:
The algorithm can be extended to 2D LARPBS; here is the 2D LARPBS algorithm. the data on processors have been organized such that they represent the m sets of length of n-m+1 of the text string with m* n-m+1 matrix plus, the first processor of each row segment holding the first element of each set also carries an element of pattern. The process is similar as per above for the remaining m-1 rows. First show how to find the occurrences of pattern P in text string T on 2D LARPBS with m*(n-m+1) in constant time O (1).
Algorithm for string matching (pattern P, text T) Begin Initially: m elements of pattern initially distributed to the m processors on the first column, one processor and L i,j distributed to the m*(n-m+1) processors on the row and column. Where 1 i m and m j m*(n-m+1) First processors broadcast elements on row buses: each first processor p i,1 , where 1 i m, broadcasts the element c i,1 to every processor in the i th row using only row buses .After this multiple row broadcast communication operations each processor P i,j saves received element as r i,j.
Compare and Set results: Each processor P i,j compares r i,j with X i,j, if r i,j = X i,j if sets result=1 otherwise, result=0 Sum up 1's: perform a one-dimensional binary prefix sum operation on each column simultaneously for the value of result. Each processor P i,j where 1 (i,j) m stores the binary prefix sums to b i,j.
Based on Hamming Distance: If P m,j =0 then the string matching(i.e. exact string matching) otherwise approximate string matching with k mismatches. End. Each step in the above algorithm runs in constant time. Thus we have the following theorem.
Theorem: There is a constant time string matching algorithm on a 2D LARPBS that finds the occurrences of pattern in text using m*(n-m+1) processors Example: Text string T(n)= abcbcd and Pattern string P(m)= bcb L1 ={ abcb}, L2={bcbc} L3={cbcd} As per the given example, after step 4 in the matrix M m+1,j values useful for deciding the matching is exact string matching or approximate string matching with the k mismatches.
Scalability: Suppose the number of available processors is p, if (n-m-1) p<m*(n-m+1), then modify algorithm in the following way to achieve good scalability. As per the above information, it is still want to split the processors into m sub-buses in step1. Each group is responsible for one set of m sets and pattern string, matching array. Thus there x=p/(n-m+1) processors in each sub-bus .every processor has three arrays :pattern, reference (Li) and matching array each of which has size m*(n-m+1)/p. the algorithm takes (m*(n-m+1))/p bus cycle and there is no local computation for multicast and contains the (m*(n-m+1))/p computation time. The time complexity for the modified string matching algorithm (m*(n-m+1))/p. in other words , the complexity T1(N)=O(1) , T2(P)=(m*(n-m+1))/p where N=m*(n-m+1) and P=p the scalability for our algorithm is g(N,P)=T2(P)/T1(N) * P/N = 1 . So that the string matching is completely scalability and obtain the following theorem.
Theorem: The given two strings size of text n and size of pattern m. find the occurrences of pattern in text. There is completely scalable on LARPBS. The algorithm runs in O(m*(n-m+1))/P time, where P is the number of processors and 1 p m*(n-m+1).

CONCLUSIONS
We studied both optical interconnection models and efficient algorithms for these models. Mainly we concentrated on a simple but powerful optical interconnection network model-LARPBS. This model extended to 2DLARPBS to improve the scalability. We achieved a constant O(1) time algorithm for string matching on 2DLARPBS without any preprocessing the pattern string or text string. This is first known optimal algorithm for pattern matching on 2DLARPBS.Our future research on same problem with three dimensions or another mode, which contains minimum communication, and improve the performance.