Computing piby using Monte Carlo MethodsSolution.pdf
Please carry out all sections and document the code with appropriate comments. Some tables are
required, these can be included as comments in the source code or submitted as a separate file.
2 Computing piby using Monte Carlo Methods
The Monte Carlo method uses a set of random points (x,y). If d is the distance from the origin then ndis the number of points where d <= 1. So pican be estimated by nd/nt , where nt is the total number ofpoints. Use the code ran2.c to generatethe random numbers. Carry out the following parallelisation steps:
1. Construct a code that generates two random numbers x,y between 0????1.
2. Calculate the distance of the point (x,y) from the origin.
3. Use the result to estimate pi, using the formula above.
4. Parallelize it by using OpenMP constructs but when updating nd use a syncronous directive.
5. Make the function ran2 thread safe by adding OMP directives only. You should not need to alter
the code. So ignore the Stackoverflow response.
6. You may find that by changing the number of threads changes the result, why?
3 Steady State
You have a 2D array w of 100×100. The first row is 0.0 the last row, first and last columns are 100 and
these values remain fixed. Initially all other elements are set to 75.
w(1,2 : 99) = 0.0 (1)
w(100,1 : 100) = 100.0
w(1 : 100,1) = 100.0
w(1 : 100,100) = 100.0
w(2 : 99,2 : 99) = 75.0
Repeatedly update the interior values of w(2 : 99,2 : 99) with the equation below;
wnew(i, j) = (w(i+1, j)+w(i−1, j)+w(i, j+1)+w(i, j−1))/4 (2)
Stop when the maximum difference between w and wnew is less than 10 to the power -4
Create the serial code first.
Parallelize the initialisation and update of w, using OpenMP constructs.
3. Note that each iteration wnew is independent of the previous w.4. Use 1,2,4 threads and compute absolute and relative speedup and efficiency.
Tired of the boring assignments to be submitted to colleges and universities? MyAssignmentMart.com gives you multiple reasons to trust it with your orders. We employ PhD experts handpicked from prestigious universities over the globe. We cater to quality assignment help, dissertation writing services and online essay help, covering more than 100 academic subjects. We pledge to complete your assignments on time and never compromise when it comes to deadline. Our prices for assignments are the most competitive in the market and make sure the cost suits your budget.
Get Assignment Help Now...!
Subjects We Offer
- Engineering Assignment Help
- MATLAB Assignment Help
- Mechanical Engineering Assignment Help
- Civil Engineering Assignment Help
- Computer Science Assignment Help
- Electrical Engineering Assignment Help
- Electronics Assignment Help
- Economics Assignment Help
- Management Assignment Help
- Do My Assignment
- Cheap Assignment Help
- Programming Assignment Help
- Law Assignment Help
- Assignment Provider
- Finance Assignment Help
- Python Assignment help
- Healthcare Management Assignment Help
- Computer Network Assignment Help
- History Assignment Help
- Industrial Engineering Homework Help
- IT Management Assignment Help
- Nursing Assignment Help
- Operating System Assignment Help
- Statistics Assignment Help
- Material Science Assignment Help
- Mechanical Engineering Homework Help
- University Assignment Help
- Agriculture Engineering Homework Help
- ATHE Courses Assignment Help
- Capital Budgeting Assignment Help
- BTEC Assignment Help
- HND Assignment Help
- Material Science Assignment Help
- Psychology Assignment Help
- Resit Assignment Help
- Computer Architecture Assignment Help
- Data Structure Assignment Help
- Database Assignment Help
- PHP Assignment Help