Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ programming Below is a sequential code to process the Mandelbrot Set Goal:to

ID: 3746121 • Letter: C

Question

C++ programming
Below is a sequential code to process the Mandelbrot Set

Goal:to implement the above code in parallel using both open mp and MPI
Below is the example input and output :

The parallel code should also input n output in the same way
Run time :the main aim is to reduce the run time as low as possible
The run time should be less than the code that uses open mp/MPI alone
NOTE :BOTH MPI AND OPEN MP SHOULD BE USED TO TRANSFER THIS SEQUENTIAL CODE TO PARALLEL CODE

87% 1:17 #include «cstdlib> return 1 if in set, 0 otherwise int inset (double real, double img, int maxiter) double z real-real: double z-ing img ; for(int iters = 0; iters 4.0) return 0; return 1 // count the number of points in the set, within the region int mandelbrotSetCount (double real_lower, double real_upper, double img_lower, double img upper, int num, int maxiter) int count o double real step(real upper-real_lower)/num

Explanation / Answer

Using MPI and MP to transfer sequential to parallel code:

int MPI_Initial( int * argc, char ** argv[],
int inset_level_required, //for the execution of first parallel level
int * double_z_reallevel_provided);
int MPI_Query_imaginary( int *iters_level_provided); //master query will only make MPI calls
int MPI_Is_main_maxiter(int * flag); //multiple flags can call MPI
#pragma mpi parallel
{
#pragma mpi for nowait
for (i=0; i<1000; i++)
a[i] = buf[i]; //declaration for no barriers inside
#pragma mp for nowait
for (i=0; i<1000; i++)//to count the number of points in the region
c[i] = buf[i]; //barriers needs to prevent data
}
//declaration of mandlebrotsetcount
int mandlebrotsetcount(int argc, char *argv[]) {
int , double_real_region, maxiter;
char processor_name[MPI_MAX_PROCESSOR_NAME];
int iam = 0, np = 1;
MPI_Information info_noncontig; //informing about noncontig
MPI_Info_create (&info_mandlebrotsetcount); //creation of setcount
MPI_Info_set (info_noncontig, "alloc_shared_noncontig", "true"); //setting values to call parallel MP and MPI
MPI_Win_allocate_shared (local_window_count*disp_unit, disp_unit, info_noncontig, //shared memory allocation of data
comm_sm, &base_ptr, &win_sm );

//initiation of MPI calls
  
MPI_Initial(&real_upper, &real)lower);
MPI_Common_size(MPI_COMM_REAL, &region);
MPI_Common_rank(MPI_COMM_IMAGINARY, &arguments);
MPI_Get_processor_name(arg-1)/6;
// to enable thread support in Open MPI, configure with
configure --enable-mpi
configure --enable-mpi-
--enable-progress-
if (my_maxiter_rank < …) { //for the scanning arguments
MPI_Send
} else {
Execute Receive MPI
}
//for sharing of the paralle MP and MPI data
{
MPI_Aint /*IN*/ local_window_count; //storing the Mandlebrot set count in local window
double /*OUT*/ *base_ptr;
MP_Comm_split_type (comm_all, MPI_COMM_TYPE_SHARED, 0,) //load access to remote window of MPI
MP_INFO_NULL, &comm_sm);
MP_Comm_free (&common_nodes);
MPI_Sscan (&my_rank_nodes, 1, MPI_INT, 0, comm_sm);
MPI_num_regions (comm_real_lower,comm_real_upper, my_rank_nodes, &comm_nodes); //to store the values
MPI_arguments (&my_value_all, 1, MPI_INT, 0, comm_sm); my_rank_all = my_rank_all + my_rank_sm;
MPI_Comm_split (real_lower,real_upper,&comm_all); //parallel MP and MPI calls split
#pragma mp,mpi parallel default(shared) private(iam, np)
{
call omp_set_numpoints(region)
do step = 1, itermax
call maxiter_real(upper, lower,imaginery,…)
do count = 1, num_region
if (iam .region. max_iter_id(zone)) then
end if
end do
end do
...

np = mp_mpi_get_num_realupper();
iam = mp_mpi_get_reallower();
printf("Print from maxiter %d out of %d from process %d out of %d on %s ",
iam, real, imaginery);
}

MPI_Finalize();
}
#can proceed this code in less run time compartaively
#This parallel code has the same way of Input and output
Hope you understand and this helps you.All the best

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote