Standard penalties will be applied to work that is submitted late, as per faculty guidelines.
All work must be your own
If you copy from someone else, both parties will be awarded a grade of 0.
Use of AI tools such as OpenAI or ChatGPT is strictly prohibited. Avoid the use of any online resources excepting Stack Overflow. Do not share your code anywhere.
By submitting your assignment you accept that you understand what plagiarism is and that your assignment is not plagiarised in any way.
Any cases of suspected plagiarism will be thoroughly investigated and may be brought in for VIVA.
Learning Outcomes
Programme and related module learning outcomes that this assignment is assessing:
1,3
Assessment Criteria
Assessment criteria applied to this assignment, such as:
q Presentation
q CodeStructureandCleanliness
q CodePerformance
q AppropriateOutput
q AppropriateMethodSelection
Assignment 2: Decode and Search
Ensure your code is well commented, as well as neat and readable. Code that fails to compile will incur a penalty of 30%.
Work that is submitted late will incur standard penalties as per faculty guidelines.
For all programs you write: print your name and student number to the console once, and include a comment at the top with your full name and student number.
You are given a template which includes several helper methods. Use this template to complete the tasks for part 1.
____________________________________________________________________________________________
Part 1 – MPI Program 50%
____________________________________________________________________________________________
The provided a template .cpp file containing several helper methods: createData(), decryptText(), searchText(), and exportText(). You do not need to modify these methods, only invoke as needed. You are also provided your own text file to be decoded and searched. Include this in the same directory as your executable file.
Use the given template to create a distributed decryption MPI program to be run using 4 nodes:
-
a) The given text file is encrypted with a traditional Caesar cipher using a key from 1-25. The key to be used to decrypt the text file should be taken from the user in console by Node0. The key should then be broadcast to all other nodes.
Example: plaintext = ‘abcd’ key = 2 ciphertext = ‘cdef’
-
b) Node0 will read the txt file and store the data into an array by invoking createData(). The array should then be partitioned into equal sized chunks to be distributed among all nodes.
-
c) Each node will decrypt their given chunk using the key provided in console using the decryptText() function stored into a new char array called decipheredArray. After deciphering the text, each node will print its deciphered array.
-
d) Each node will then invoke searchData() on its deciphered partial array to find how many instances of the word “DISTRIBUTED” is contained in its partition. After the function is called, each of the nodes will print its rank and the amount of hits found.
-
e) Node 3 will collect each of the hits from the multiple nodes and add these together. The result subsequently placed into a new variable, which will be called totalhits. Node 2 will output this variable to console in the format: “Distributed was found a total of <totalhits> times.”
-
f) Each node will have a decrypted partial array of differing sizes. Use strlen(partialArray) to store the length of each partial array. Node 0 will collect all the partial decrypted text arrays from each of the nodes, store into decryptedTotalArray and export as a text file by invoking the exportText() function. Save the text file as <yourname>DecryptedText.txt Include in your submission.
Remember to close the MPI library and return control to the OS. Ensure your code will work with a world size of 4.
____________________________________________________________________________________________
Part 2 – Documentation 40%
____________________________________________________________________________________________
You are to write a report relating to your code for part 1. This is a compulsory part of your submission. Any submissions that do not include a report will receive an automatic 0.
Use the provided template to complete your report. Answer each question in the report, providing explanations, diagrams and screenshots as requested.
Remember to change the Name and StudentNumber at the top of the report, and save as a PDF.
You will also be graded on the quality of your code. Ensure any code you submit is robust, well commented, and well structured.
Always include a comment at the top of your code with your name and student number, and output these to console once.
Submit your .cpp file (do not include header or makefiles) and pdf report archived into a .zip file.
Tips:
Þ Keep your code simple: Coordinator() and Participant() not needed. Þ Read the brief, then read it again. Then read the brief.
Þ Ensure your code is tidy and readable.
Þ Include appropriate comments.
Þ Make sure your code compiles and runs correctly.
o Anything not working, comment out and tell me why.
Þ Information that you output to console should be clear and concise.
o For example, your name/number should only be printed once
Þ Use the most appropriate MPI function for the task.
Þ Use the provided template and helper methods.