Zero Suppression with OpenMP CS 462 Parallel Programming, Project #2 Dr. Beck Zerosuppressionisaformofcompressionthattakesasinputanarrayofintegers andreplaceseverysequenceofzeroswithtwointegers: a. asinglezero,followedby b. thenumberofconsecutivezerosinthesequence. Forexample,thesequence 5,0,0,0,0,3,2,0,4,1,5,0,0,0,6 wouldbecompressedas 5,0,4,3,2,0,1,4,1,5,0,3,6 YouaretowriteaparallelOpenMPprogramtoreadinanNxNtwodimensional arrayfromafile(Nspecifiedasacommandlineparameter)inrowmajororder,and either 1. Compressthematrixinrowmajororder,or A[0,0],A[0,1],A[0,2],…A[0,N-1],A[1,0],A[1,1],A[1,2],…A[1,N-1],… 2. Compressthematrixincolumnmajororder. A[0,0],A[1,0],A[2,0],…A[N-1,0],A[0,1],A[1,1],A[2,1],…A[N-1,1],… Acommand-lineargumentshouldbeusedtodeterminethedirectionofsuppression • -drforzerosuppressioninrowmajororder • -dcforzerosuppressionincolumnmajororder Iftheargumentisnotpresent,thenyourprogramshoulduseuniformrandom samplingtodeterminethemostefficientdirection(choosearandomsetofstarting pointsanddirectionsandfindtheaveragelengthofazerosequenceineach direction). Theoutputshouldstartwithavaluethatspecifieswhichdirectionofcompression wasused(1forrowmajor,2,forcolumnmajor). Youshouldwriteaprogram(notnecessarilyparallel)tocheckyourresults,and obtaintimings(bothwithandwithoutI/O)forfilesandnumbersofthreadsupto thecapacityofthelargestmulticorenodesintheNewtonclusters. Whatchangetothisspecificationwouldmakecheckingmoreeasilyparallelizable? GeneratingInputFiles Theeasiestwaytogenerateaninputfileistocreateanarraywithallthedifferent possibleinputsoccurringwiththerelativefrequencythatyouwantinthefile.Thus ifthefilewastocontainintegersintherange[0..9]withequalfrequencyexceptthat 9occurswithtwicethefrequencyoftheothernumbers,thenyouwouldusean arraywith11entries,witheachofthenumbersintherange[0..8]occurringonce andthenumber9occuringtwice.Thenyouwouldgenerateaninputfileofanysize usingauniformdistributionrandomnumbergenerator(suchasrand()fromtheC library)modifiedtoproduceindicesintherange[0..10]andthenusingthose indicestoindexintothearray. Forthisproject,youwanttoensurethattherearerunsofzerostobecompressed, sotheabovetechniquecanbeusedwithamodification.Negativenumberscanbe usedtorepresentrunsofzeros(-2represents2zeros,-3represents3zeros,etc).If thesespecialvaluesareaddedtothevaluesinthearray,thenwhentheycomeup thentheappropriatenumberofzeroscanbegenerated.Thisrequiresthatallofthe othervaluesinthearraybenon-negative,whichisacceptable.Then,aswith numbers,thefrequencyofrunsofzerosofdifferentlengthscanbeadjustedby adjustingthefrequencyofthevariousnegativenumbersinthearray.