Find Jobs
Hire Freelancers

Convert the following MPI program to a sequent program

$10-30 USD

Closed
Posted about 1 year ago

$10-30 USD

Paid on delivery
Write the program to behave like: How many processes? 5 Then make a shared memory location of type int of the size of: 5 The function (like f) that would be the one parameter of m_fork() should do the following: Generates a random integer. Check to see: if it is a prime number, saves the number in the array that its index is the rank of the process. If it is not a prime number, saves its negate in in the array that its index is the rank of the process. Now the process of rank zero prints the array such that: if the content of a location of the array is positive (like n), outputs n is a prime number. if the content of a location of the array is negative (like -n) outputs n is not a prime number. Note when process with rank zero is going to print the array, all the processes (including rank zero) have saved their number to array. Use the file sequent.h given and then convert the given mpi code to sequent //File name: prime.c #include <mpi.h> #include <stdio.h> #include <stdlib.h> #include <time.h> int isPrime(int n){ int i; for(i = 2; i < n; i++) if(n % i == 0) return 0; return 1; } int main(){ int comm_sz, my_rank, q, n; MPI_Init(NULL, NULL); MPI_Comm_size(MPI_COMM_WORLD, &comm_sz); MPI_Comm_rank(MPI_COMM_WORLD, &my_rank); srandom((unsigned)time(NULL) + my_rank); n = 1 + random()%10000; //The program should work for any positive number. if(isPrime(n)) MPI_Send(&n, 1, MPI_INT, 0, 0, MPI_COMM_WORLD); else{ n = -n; MPI_Send(&n, 1, MPI_INT, 0, 0, MPI_COMM_WORLD); } //To make sure all the processes obtained a number, and sent either n or -n to process 0 MPI_Barrier(MPI_COMM_WORLD); if(my_rank == 0) for (q = 0; q < comm_sz; q++) { MPI_Recv(&n, 1, MPI_INT, q, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE); if(n < 0) printf("Receiving from process: %d, %d is NOT a prime number\n", q, -n); else printf("Receiving from process: %d, %d is a prime number\n", q, n); } MPI_Finalize(); return 0; }
Project ID: 36318330

About the project

5 proposals
Remote project
Active 1 yr ago

Looking to make some money?

Benefits of bidding on Freelancer

Set your budget and timeframe
Get paid for your work
Outline your proposal
It's free to sign up and bid on jobs
5 freelancers are bidding on average $38 USD for this job
User Avatar
I a good with system programming in Linux with C. Know MPI too. Can convert the code for an hour...............
$30 USD in 1 day
4.9 (560 reviews)
7.6
7.6
User Avatar
Hey I am expert in openmp and MPI and I can help you with your project message me to discuss so that we can start working on it
$20 USD in 1 day
4.9 (86 reviews)
5.5
5.5
User Avatar
Hello, my intention is to be able to help each other and dedicate a large part of my time to the project in order to satisfy the proposed needs, in addition to striving to deliver it as quickly as possible.
$20 USD in 7 days
0.0 (0 reviews)
0.0
0.0
User Avatar
This program first creates a memory space with 5 elements. Then it generates an integer for each operation and checks if that integer is prime. If the integer is prime, it is assigned to the index of that process in the stored memory area. If the integer is prime, it is assigned a negative value. Next, the sequential program checks the units in the memory segments, outputting "x is NOT a prime number" if the element is negative. If the element is positive it will output "x is a prime number" I can turn this code into a sequential program if you are interested and contact
$20 USD in 1 day
0.0 (0 reviews)
0.0
0.0

About the client

Flag of UNITED STATES
New York, United States
0.0
0
Payment method verified
Member since Mar 18, 2023

Client Verification

Thanks! We’ve emailed you a link to claim your free credit.
Something went wrong while sending your email. Please try again.
Registered Users Total Jobs Posted
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Loading preview
Permission granted for Geolocation.
Your login session has expired and you have been logged out. Please log in again.