Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

write with MPI include #include int main(int argc, char *argv[]){ int start, end, partial_sum, N=100 ; MPI_Init( &argc , &argv ); MPI_Comm_size( MPI_COMM_WORLD , &nbproc

image text in transcribed

write with MPI

include #include int main(int argc, char *argv[]){ int start, end, partial_sum, N=100 ; MPI_Init( &argc , &argv ); MPI_Comm_size( MPI_COMM_WORLD , &nbproc ); MPI_Comm_rank( MPI_COMM_WORLD , &myrank ); startval = 0 endval = N * myrank+100; partial_sum = 0 ; tmp_sum = 0 for( i=start ; i

}

something like this

(1) Write a program named partialSum.c such that each processor will compute and print out a partial sum of N numbers. Set N=1000 in your program and define 10 processors in job 100 script file, then processor O will print out the partial sum of 1+2+...+100 (that is, i) processor 1 will print out the partial sum of 101+102+...+200(that is, Li), i-101 1000 processor 9 will print out the partial sum of 901+902+...+1000(that is, i), 1-901 (Note: In this program, you can declare a constant N=1000 or use preprocessing statement #define N 1000.) (2) When you finish the program, check whether you have file named like slurm- Xxxxput in the current directory. Open the file slurm-xXxxx.out and check the content. You should have the following content: Please remove files that are not needed anymore. Partial sum from process 0 of total 10 is. 5050. Partial sum from process 6 of total 10 is: 65050. Partial sum from process 3 of total 10 is. 35050. Partial sum from process 7 of total 10 is a 75050. Partial sum from process 2 of total 10 is: 25050. Partial sum from process 9 of total 10 is: 95050. Partial sum from process 5 of total 10 is : 55050. Partial sum from process 4 of total 10 is: 45050. Partial sum from process 8 of total 10 is : 85050. Partial sum from process 1 of total 10 is. 15050. (3) Revise your script file to apply for 16 nodes, and then run your program again. (1) Write a program named partialSum.c such that each processor will compute and print out a partial sum of N numbers. Set N=1000 in your program and define 10 processors in job 100 script file, then processor O will print out the partial sum of 1+2+...+100 (that is, i) processor 1 will print out the partial sum of 101+102+...+200(that is, Li), i-101 1000 processor 9 will print out the partial sum of 901+902+...+1000(that is, i), 1-901 (Note: In this program, you can declare a constant N=1000 or use preprocessing statement #define N 1000.) (2) When you finish the program, check whether you have file named like slurm- Xxxxput in the current directory. Open the file slurm-xXxxx.out and check the content. You should have the following content: Please remove files that are not needed anymore. Partial sum from process 0 of total 10 is. 5050. Partial sum from process 6 of total 10 is: 65050. Partial sum from process 3 of total 10 is. 35050. Partial sum from process 7 of total 10 is a 75050. Partial sum from process 2 of total 10 is: 25050. Partial sum from process 9 of total 10 is: 95050. Partial sum from process 5 of total 10 is : 55050. Partial sum from process 4 of total 10 is: 45050. Partial sum from process 8 of total 10 is : 85050. Partial sum from process 1 of total 10 is. 15050. (3) Revise your script file to apply for 16 nodes, and then run your program again

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

What is the specific purpose of an acceptable use policy?

Answered: 1 week ago