You are on page 1of 4

CS6868:ConcurrentProgramming Spring2014 Assignment1:Due22February2014,11:59pm 1.

SquareofSquareMatrix(10points)
Consider a square matrix A. The goal of the problem is to find the square of A asefficiently as possible. Fill in A with random entries ranging from 0 to 1. Vary the size of the matrices from 64x64 to 4096x4096 in the order 128x128, 256x256 etc. in powers of 2. Assume that the matrices are given in row major order. If you perform any transformation, this has to be accounted in the runtime as well. Use gettimeofday() for calculating runtimes. Try the different implementationstaughtinclassandmoreoptimizations. Compare the runtimes of different implementations. Your cilk programs must be checked with cilkscreen and ensure that there are no races. Summarize the report that you get from cilkscreen. For each implementation, run cilkview and obtain parallelism values reported. Comparetheparallelismthatisreportedwithparallelismthatyouobtained. Plots:Runtimevs.MatrixSizesfordifferentnumberofthreads Runtimevs.Threadsfordifferentmatrixsizes

2.GameOfLife(25points)
Conways game of life is a cellular automaton where the game depends on the initial configuration and nothing else. The initial configuration is a two dimensional gridofcells each of which is either deador alive(representedas0sand1srepectively).Thegameproceedsin steps where every cell interacts with the vertical, horizontal or diagonal neighbors and decides onitsstatusinthenextstep.Ateachstep,thefollowingrulesareused: 1.Anylivecellwithfewerthantwoliveneighboursdies,asifcausedbyunderpopulation. 2.Anylivecellwithtwoorthreeliveneighborslivesontothenextgeneration. 3.Anylivecellwithmorethanthreeliveneighborsdies,asifbyovercrowding. 4.Anydeadcellwithexactlythreeliveneighborsbecomesalivecell,asifbyreproduction. The initial configuration is called the seed and starting from this all the cells take steps in tandem.Thegridsizeisfixedwithnumberofrows=10000andnumberofcolumns=10000. Input Thefirst10000linesofinputwitheachlinecontaining10000spaceseparatedbinaryvalues(0 fordeadand1foralive)representingtheseed,startingwiththefirstrow.Thecellswithinarow

arepresentedfromlefttoright. Thenextlineofinputcontains#steps,thenumberofstepsthegamehastoproceed. Output Outputshouldcontainexactly10000lineswitheachlinecontaining10000binaryvalues representingtheconfigurationoftheboardafter#stepsstartingfromtheseed. Constraints 0<=#steps<=10000

3.LongestCommonSubsequence(30Points)

Background Evolutionary biologists scourge for patterns in protein sequences of animals to find out evolutionary patterns. One measure for evolutionary similarity is the length of the longest common subsequences between proteins from different organisms. There are many proteins and many organisms, clearly this isa herculean task. You are goingto help these scientistsby applyingDynamicprogrammingfortheLCSproblemontheproteindatasetthatisgiven. Input Your program must taketheinputfilelcs_input.txtthatcontainsmultipletestcases(separatedby $). Each testcase contains 2 proteins. The actual protein sequence contains a string ofamino acid symbols. The valid amino acid symbols are all lettersofEnglishalphabetexceptB,J,O,U,X and Z and are alwaysgivenincapitalletters.The proteinsequencescanbeofvaryinglengths.A sequenceissplitintomultiplelineswitheachlinecontainingatmost60aminoacids. Forexample,considertheproteinfromabull:
MEKTELIQKAKLAEQAERYDDMATCMKAVTEQGAELSNEERNLLSVAYKNVVGGRRSAWR VISSIEQKTDTSDKKLQLIKDYREKVESELRSICTTVLELLDKYLIANATNPESKVFYLK MKGDYFRYLAEVACGDDRKQTIDNSQGAYQEAFDISKKEMQPTHPIRLGLALNFSVFYYE ILNNPELACTLAKTAFDEAIAELDTLNEDSYKDSTLIMQLLRDNLTLWTSDSAGEECDAA EGAEN

The protein has 245 amino acids split into 5 lines. The first four lines contain 60 amino acids each andthe last onecontains5aminoacids.The245characterstringistheprotein.Comment linesintheinputstartwiththesymbol>.Endoffilerepresentedby$$$. Output Your program must print asimilarity scorefor every pair of proteins given to you. The similarity score must be measured as the length of the longest common subsequence. For each such pair, you must also printthe position at which the longest subsequence starts and the longest subsequence string itself. If multipleLongestCommonSubsequencesarepresent,printtheone

whichistheleftmostmatch.Printtheresultstolcs_output.txt OutputFormat For each pair, in a new line, print the length of the sequence followed by the actual longest subsequence.Forexample, 12MKMRCTVGPADE

4.Graphcolouring(35Points)
ProblemDefinition Given an undirected graph G(V,E) where V is set of vertices and E is set of edges, then colour the graph with minimum possiblenumberofcolourssuchthatnotwoadjacentverticeshavethe samecolour. Input An input file contains all the information about a graph needed to define a coloring problem. i.e. Thefirstlinegivesthenumberofverticesandedgesofthegraph. |V||E| where|V|isthenumberofverticesand|E|isthenumberofedges. The following M lines contain edge information of the graph like (w,v) where w,v are the endpoints of the edge (w,v). The vertices are 1indexed(numbered from 1 to N) and so are the colors(1to#colorsyoufindout). Exampleofinputfile 56 12 23 34 45 51 53 Output Anoutputfileshouldcontainthefollowinginthatorder: 1.Onelinecontainingrunningtimeinmicrosecondsprintedasafloat 2.Secondlineshouldcontainthenumberofcolorsyouusedtocolorthegraph 3.|V|lines,eachlinecontainingthecolorofvertexVi.minimumnumberofcoloursusedto colourthegraph.

Exampleofoutputfile 130 3 11 22 31 43 52

You might also like