logo Use CA10RAM to get 10%* Discount.
Order Nowlogo
(5/5)

Use OpenMP to parallel the two questions, in C programming. Attached is ex5.2_omp_trap1_crit as an e

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

Use OpenMP to parallel the two questions, in C programming.

Attached is ex5.2_omp_trap1_crit as an example.

1. Use OpenMP to implement the parallel histogram program. Attached is ser_hist for the program to use.

2. see attachment:

Question2. Attached is monte_carlo for the program to use.

 

/* C program for estimation of Pi using Monte

Carlo Simulation */

#include <stdio.h>

#include <stdlib.h>

 

 

void get_input(long long int* number_of_tosses);

long long int monte_carlo(long long number_of_tosses);

 

int main()

{

    long long int number_of_tosses;

    long long int number_in_circle;

    double pi_estimate;

 

    srand(time(NULL)); //seed the random number generator

 

 

    get_input( &number_of_tosses );

// Initializing rand() with current time

 

number_in_circle = monte_carlo( number_of_tosses );

 

    pi_estimate = 4*number_in_circle/((double)number_of_tosses);

    printf("pi estimate = %f\n", pi_estimate);

 

return 0;

}

 

void get_input( long long int* number_of_tosses  /* out */) {

 

      printf("Enter the total number of tosses\n");

      scanf("%lld", number_of_tosses);

 

}  /* Get_input */

 

 

/*-------------------------------------------------------------------*/

long long int monte_carlo(long long number_of_tosses) {

   long long int i;

   double x,y;

   double distance_squared;

   long long int number_in_circle = 0;

 

 

   for ( i=0; i< number_of_tosses ; i++) {

      x = (double)rand()/RAND_MAX*2.0-1.0;

      y = (double)rand()/RAND_MAX*2.0-1.0;

 

      distance_squared = x*x + y*y;

 

      if (distance_squared <= 1) {

         number_in_circle++;

      }

   }

 

   return number_in_circle;

}  /* Monte_carlo */

 

(5/5)
Attachments:

Related Questions

. Introgramming & Unix Fall 2018, CRN 44882, Oakland University Homework Assignment 6 - Using Arrays and Functions in C

DescriptionIn this final assignment, the students will demonstrate their ability to apply two ma

. The standard path finding involves finding the (shortest) path from an origin to a destination, typically on a map. This is an

Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t

. Develop a program to emulate a purchase transaction at a retail store. This program will have two classes, a LineItem class and a Transaction class. The LineItem class will represent an individual

Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th

. SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

. Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

Ask This Question To Be Solved By Our ExpertsGet A+ Grade Solution Guaranteed

expert
Um e HaniScience

874 Answers

Hire Me
expert
Muhammad Ali HaiderFinance

578 Answers

Hire Me
expert
Husnain SaeedComputer science

929 Answers

Hire Me
expert
Atharva PatilComputer science

683 Answers

Hire Me

Get Free Quote!

343 Experts Online