Docsity

Matrix Vector Multiplication, Fox's Algorithm-Programming Skills and Concepts-Assignment, Exercises of Computer Programming

Toggle sidebar
bg1
CISโ€421:๎˜ƒIPA๎˜ƒ๎˜ƒ๎˜ƒ๎˜ƒ๎˜ƒ๎˜ƒ๎˜ƒ๎˜ƒ๎˜ƒDue๎˜ƒon๎˜ƒ28โ€10โ€2010๎˜ƒ
Programming๎˜ƒAssignmentโ€1๎˜ƒ
๎˜ƒ
Assignment๎˜ƒObjectives:๎˜ƒ
๏‚ท To๎˜ƒreinforce๎˜ƒyour๎˜ƒunderstanding๎˜ƒof๎˜ƒsome๎˜ƒkey๎˜ƒconcepts/techniques๎˜ƒintroduced๎˜ƒin๎˜ƒclass.๎˜ƒ
๏‚ท To๎˜ƒintroduce๎˜ƒyou๎˜ƒto๎˜ƒdoing๎˜ƒindependent๎˜ƒstudy๎˜ƒin๎˜ƒparallel๎˜ƒcomputing.๎˜ƒ
๎˜ƒ
Q.1๎˜ƒ๎˜ƒ๎˜ƒ๎˜ƒ๎˜ƒ๎˜ƒ๎˜ƒ๎˜ƒ๎˜ƒ๎˜ƒ๎˜ƒMarks๎˜ƒ10๎˜ƒ(=5+5)๎˜ƒ
You๎˜ƒare๎˜ƒgiven๎˜ƒa๎˜ƒsample๎˜ƒcode๎˜ƒfor๎˜ƒmatrixโ€vector๎˜ƒmultiplication๎˜ƒโ€œmatvec1.cppโ€๎˜ƒusing๎˜ƒMPI.๎˜ƒThe๎˜ƒcomments๎˜ƒin๎˜ƒ
the๎˜ƒprogram๎˜ƒexplain๎˜ƒits๎˜ƒworking.๎˜ƒModify๎˜ƒthe๎˜ƒprogram๎˜ƒas:๎˜ƒ
I. The๎˜ƒprogram๎˜ƒshould๎˜ƒtake๎˜ƒinput๎˜ƒask๎˜ƒyou๎˜ƒenter๎˜ƒvector๎˜ƒand๎˜ƒmatrix๎˜ƒand๎˜ƒdimensions๎˜ƒonline.๎˜ƒ
II. Should๎˜ƒread๎˜ƒthe๎˜ƒvector๎˜ƒand๎˜ƒmatrix๎˜ƒfrom๎˜ƒinput๎˜ƒfile๎˜ƒand๎˜ƒgenerate๎˜ƒan๎˜ƒoutput๎˜ƒfile๎˜ƒfor๎˜ƒresults.๎˜ƒ
Do๎˜ƒit๎˜ƒfor๎˜ƒp=n๎˜ƒand๎˜ƒp<n๎˜ƒfor๎˜ƒeach๎˜ƒcase.๎˜ƒ
Q.2๎˜ƒ๎˜ƒ๎˜ƒ๎˜ƒ๎˜ƒ๎˜ƒ๎˜ƒ๎˜ƒ๎˜ƒ๎˜ƒMarks๎˜ƒ30๎˜ƒ(=2x(5+5+5))๎˜ƒ
I. You๎˜ƒare๎˜ƒgiven๎˜ƒa๎˜ƒsample๎˜ƒcode๎˜ƒfor๎˜ƒmatrixโ€matrix๎˜ƒmultiplication๎˜ƒโ€œmatrix.cโ€๎˜ƒusing๎˜ƒMPI.๎˜ƒAnother๎˜ƒ
program๎˜ƒusing๎˜ƒcannonโ€™s๎˜ƒalgorithm๎˜ƒโ€œmmult_cannon.cโ€๎˜ƒand๎˜ƒa๎˜ƒthird๎˜ƒprogram๎˜ƒusing๎˜ƒfoxโ€™s๎˜ƒalgorithm๎˜ƒ
take๎˜ƒfrom๎˜ƒPacheco๎˜ƒbook๎˜ƒ(provided๎˜ƒin๎˜ƒmy๎˜ƒfolder๎˜ƒon๎˜ƒdata๎˜ƒsever).๎˜ƒ๎˜ƒThe๎˜ƒcomments๎˜ƒin๎˜ƒthese๎˜ƒ
programs๎˜ƒexplain๎˜ƒtheir๎˜ƒworking.๎˜ƒThe๎˜ƒtheory๎˜ƒfor๎˜ƒfox๎˜ƒalgorithm๎˜ƒis๎˜ƒgiven๎˜ƒin๎˜ƒ๎˜ƒPacheco๎˜ƒbook๎˜ƒand๎˜ƒsome๎˜ƒ
addition๎˜ƒmaterial๎˜ƒis๎˜ƒgiven๎˜ƒin๎˜ƒmy๎˜ƒfolder๎˜ƒof๎˜ƒ๎˜ƒ๎˜ƒโ€œProgramming๎˜ƒAssignmentsโ€๎˜ƒ.๎˜ƒConvert๎˜ƒthese๎˜ƒcodes๎˜ƒto๎˜ƒ
C++.๎˜ƒModify๎˜ƒthe๎˜ƒprogram๎˜ƒas:๎˜ƒ
a. The๎˜ƒprogram๎˜ƒshould๎˜ƒtake๎˜ƒinput๎˜ƒask๎˜ƒyou๎˜ƒinput๎˜ƒboth๎˜ƒmatrices๎˜ƒand๎˜ƒtheir๎˜ƒdimensions๎˜ƒonline.๎˜ƒ
b. Should๎˜ƒread๎˜ƒthe๎˜ƒmatrix๎˜ƒfrom๎˜ƒinput๎˜ƒfile๎˜ƒand๎˜ƒgenerate๎˜ƒan๎˜ƒoutput๎˜ƒfile๎˜ƒfor๎˜ƒresults.๎˜ƒ
Do๎˜ƒit๎˜ƒfor๎˜ƒp=n๎˜ƒand๎˜ƒp<n๎˜ƒfor๎˜ƒeach๎˜ƒcase.๎˜ƒImplement๎˜ƒthe๎˜ƒcannonโ€™s๎˜ƒand๎˜ƒfox๎˜ƒalgorithms๎˜ƒindependently๎˜ƒ
II. Extend๎˜ƒpart๎˜ƒ(I)๎˜ƒto๎˜ƒuse๎˜ƒDNS๎˜ƒalgorithm๎˜ƒfor๎˜ƒp=n๎˜ƒand๎˜ƒp<n๎˜ƒcases๎˜ƒ
Measure๎˜ƒthe๎˜ƒexecution๎˜ƒtrimmings๎˜ƒby๎˜ƒusing๎˜ƒMPI๎˜ƒfunction๎˜ƒMPI_Wtime().๎˜ƒ
๎˜ƒ
(Dr.Muhammad๎˜ƒHanif๎˜ƒDurad)๎˜ƒ
docsity.com

Partial preview of the text

Download Matrix Vector Multiplication, Fox's Algorithm-Programming Skills and Concepts-Assignment and more Exercises Computer Programming in PDF only on Docsity!

CISโ€421: IPA Due on 28 โ€ 10 โ€ 2010

Programming Assignmentโ€ 1

Assignment Objectives: ๏‚ท To reinforce your understanding of some key concepts/techniques introduced in class. ๏‚ท To introduce you to doing independent study in parallel computing. Q.1 Marks 10 (=5+5) You are given a sample code for matrixโ€vector multiplication โ€œmatvec1.cppโ€ using MPI. The comments in the program explain its working. Modify the program as: I. The program should take input ask you enter vector and matrix and dimensions online. II. Should read the vector and matrix from input file and generate an output file for results. Do it for p=n and p<n for each case. Q.2 Marks 30 (=2x(5+5+5)) I. You are given a sample code for matrixโ€matrix multiplication โ€œmatrix.cโ€ using MPI. Another program using cannonโ€™s algorithm โ€œmmult_cannon.cโ€ and a third program using foxโ€™s algorithm take from Pacheco book (provided in my folder on data sever). The comments in these programs explain their working. The theory for fox algorithm is given in Pacheco book and some addition material is given in my folder of โ€œProgramming Assignmentsโ€. Convert these codes to C++. Modify the program as: a. The program should take input ask you input both matrices and their dimensions online. b. Should read the matrix from input file and generate an output file for results. Do it for p=n and p<n for each case. Implement the cannonโ€™s and fox algorithms independently II. Extend part (I) to use DNS algorithm for p=n and p<n cases Measure the execution trimmings by using MPI function MPI_Wtime(). (Dr.Muhammad Hanif Durad)

docsity.com