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 */
DescriptionIn this final assignment, the students will demonstrate their ability to apply two ma
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. Thisprogram will have two classes, a LineItem class and a Transaction class. Th
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
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