1. Homepage
  2. Exam
  3. COMP2017/9017 System Programming - Sample Exam - Q8 Parallelisation

COMP2017/9017 System Programming - Sample Exam - Q8 Parallelisation

This question has been solved
Engage in a Conversation

Question 8 (Programming) (30 marks)

  CourseNana.COM

Question 8A Sequential part - 16 marks CourseNana.COM

  CourseNana.COM

This question considers a 2D grid of floating point numbers with dimensions width and height. Find CourseNana.COM

the position of this grid that has the highest magnitude average. This function computes the sum of the neighbouring values in the 2D grid (NorthWest, North, NorthEast, East, SouthEast, South, SouthWest, West) plus the centre and divides this by 9. Neighbours outside the dimensions of the array are treated as value zero. The grid is given as a 1D array which stores the 2D grid positions row-major order. NULL is returned in found x or found y if there is an error. The error can arise if the input array is NULL, dimensions are <= 0, or found x or found y are NULL values themselves. CourseNana.COM

  CourseNana.COM

The 1D array sequence: 1, 2, 3, 4, 5, 6, 7, 8, 9 represents the grid: CourseNana.COM

1 2 3 CourseNana.COM

4 5 6 CourseNana.COM

7 8 9 CourseNana.COM

  CourseNana.COM

Write the code needed for the following function prototype to work. You may write additional helper CourseNana.COM

functions if needed. CourseNana.COM

// pre: w > 0 h > 0 CourseNana.COM

// returns the position of the highest magnitude average of the array CourseNana.COM

// in variables found_x and found_y CourseNana.COM

void get_hma(float *array , int w, int h, int *found_x , int *found_y) CourseNana.COM

  CourseNana.COM

Question 8B Parallel part - 7 marks CourseNana.COM

  CourseNana.COM

Consider a parallelisation of this problem. Describe in words how you would use 2 or more threads to CourseNana.COM

gain a speedup > 1. CourseNana.COM

  CourseNana.COM

In your answer, you should explain if the approach is task parallel, data parallel, or both and also provide a drawing of a task-dependency graph that supports your description. CourseNana.COM

  CourseNana.COM

Question 8C Parallel part - 7 marks CourseNana.COM

CourseNana.COM

Write a parallel solution using exactly 4 threads to gain a speedup > 1. Write your solution with notation that is similar to pthreads. thread create(), thread join(), lock(mutex), unlock(mutex). sem wait(s), sem post(s), sem init(s, value). CourseNana.COM

Get the Solution to This Question

WeChat (微信) WeChat (微信)
Whatsapp WhatsApp
System Programming代写,C Language代写,Memory代写,Pointer代写,Parallelisation代写,System Programming代编,C Language代编,Memory代编,Pointer代编,Parallelisation代编,System Programming代考,C Language代考,Memory代考,Pointer代考,Parallelisation代考,System Programminghelp,C Languagehelp,Memoryhelp,Pointerhelp,Parallelisationhelp,System Programming作业代写,C Language作业代写,Memory作业代写,Pointer作业代写,Parallelisation作业代写,System Programming编程代写,C Language编程代写,Memory编程代写,Pointer编程代写,Parallelisation编程代写,System Programmingprogramming help,C Languageprogramming help,Memoryprogramming help,Pointerprogramming help,Parallelisationprogramming help,System Programmingassignment help,C Languageassignment help,Memoryassignment help,Pointerassignment help,Parallelisationassignment help,System Programmingsolution,C Languagesolution,Memorysolution,Pointersolution,Parallelisationsolution,