SlideShare a Scribd company logo
1 of 3
Download to read offline
Using an Array:
#include <stdio.h>
#include <mpi.h>
int main(int argc, char** argv) {
int rank, size;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
// Define topology
int topology[5][2] = {{1, 4}, {0, 2, 3}, {1,-1}, {0, 4}, {0, 3}};
// Initialize index and edge arrays
int index[5] = {0};
int edges[5][3] = {{0}};
// Add edges into index array
int i =0;
int j =0;
for (i = 0; i < 5; i++)
{
index[i] = sizeof(topology[i]) / sizeof(int);
for (j = 0; j < index[i]; j++)
{
edges[i][j] = topology[i][j];
}
}
// Display topology for each process
for (i = 0; i < size; i++)
{
if (rank == i)
{
printf("Process %d has %d neighbors: ", i, index[i]);
for (j = 0; j < index[i]; j++)
{
printf("%d ", edges[i][j]);
}
printf("n");
}
MPI_Barrier(MPI_COMM_WORLD);
}
MPI_Finalize();
return 0;
}
MPI Functions:
#include <mpi.h>
#include <stdio.h>
int main(int argc, char** argv)
{
int rank, size;
MPI_Init(&argc, &argv); // Initialize MPI
MPI_Comm_rank(MPI_COMM_WORLD, &rank); // Get the rank of the current process
MPI_Comm_size(MPI_COMM_WORLD, &size); // Get the total number of processes
int nnodes = 5; // Number of nodes in the topology
int nedges = 8; // Number of edges in the topolofy
// Index of the first edge for each node
int index[5] = {2, 5, 6, 8, 9};
int edges[9] = {4, 1, 0, 2, 3, 1, 4, 0, 3}; // List of all edges
MPI_Comm graph_comm; // Create a new communicator for the graph topology
MPI_Graph_create(MPI_COMM_WORLD, nnodes, index, edges, 0, &graph_comm); // Create the
graph topology
int count; // Number of neighbors
int* neighbors; // Neighbor Ranks
MPI_Graph_neighbors_count(graph_comm, rank, &count); // Get the number of neighbors for the
current process
neighbors = (int*) malloc(count * sizeof(int)); // Allocate memory for the array of neighbor ranks
MPI_Graph_neighbors(graph_comm, rank, count, neighbors); // Get the neighbor ranks for the
current process
// Display process and the node in the topologies neighbors
printf("Process %d has %d neighbors:", rank, count);
int i;
for (i = 0; i < count; i++)
{
printf(" %d", neighbors[i]); // Print the neighbor ranks
}
printf("n");
MPI_Finalize();
return 0;
}
ive provided my own code above in case that helps or makes it easier on you guys.
My output isnt quite right ive been at it for a while if someone could fix the output and explain it to
me id be very happy :)
4. Use Graph topology to create following one. Once you create your topology, use one process
(e.g., process 0 ) to display the number of neighbors and its neighbors at each node (i.e.,
process). Use following two methods to check your topology. (20 points) i) Use two arrays, index
and edges, to display number of neighbors and its neighbors for each node. ii) Use two functions
in MPI, "MPI Graph neighbors count" and "MPI Graph neighbors". llinn@scholar-fe06: /470 $
mpirun -n 5 ./hmwk5q4-b Process 0 has 2 neighbors: 41 Process 1 has 3 neighbors: 023 Process
2 has 1 neighbors: 1 Process 3 has 2 neighbors: 40

More Related Content

Similar to Using an Array include ltstdiohgt include ltmpih.pdf

Computer Networks Lab File
Computer Networks Lab FileComputer Networks Lab File
Computer Networks Lab FileKandarp Tiwari
 
Assignment c programming
Assignment c programmingAssignment c programming
Assignment c programmingIcaii Infotech
 
Hooking signals and dumping the callstack
Hooking signals and dumping the callstackHooking signals and dumping the callstack
Hooking signals and dumping the callstackThierry Gayet
 
Code is not text! How graph technologies can help us to understand our code b...
Code is not text! How graph technologies can help us to understand our code b...Code is not text! How graph technologies can help us to understand our code b...
Code is not text! How graph technologies can help us to understand our code b...Andreas Dewes
 
Mouse programming in c
Mouse programming in cMouse programming in c
Mouse programming in cgkgaur1987
 
#include iostream #include deque #include stdio.h   scan.pdf
#include iostream #include deque #include stdio.h   scan.pdf#include iostream #include deque #include stdio.h   scan.pdf
#include iostream #include deque #include stdio.h   scan.pdfanandmobile
 
Q1 Consider the below omp_trap1.c implantation, modify the code so t.pdf
Q1 Consider the below omp_trap1.c implantation, modify the code so t.pdfQ1 Consider the below omp_trap1.c implantation, modify the code so t.pdf
Q1 Consider the below omp_trap1.c implantation, modify the code so t.pdfabdulrahamanbags
 
Write a C code to perform the following tasks In main Define an arr.pdf
Write a C code to perform the following tasks In main Define an arr.pdfWrite a C code to perform the following tasks In main Define an arr.pdf
Write a C code to perform the following tasks In main Define an arr.pdffabmallkochi
 
golang_getting_started.pptx
golang_getting_started.pptxgolang_getting_started.pptx
golang_getting_started.pptxGuy Komari
 
C and Data structure lab manual ECE (2).pdf
C and Data structure lab manual ECE (2).pdfC and Data structure lab manual ECE (2).pdf
C and Data structure lab manual ECE (2).pdfjanakim15
 
PROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docx
PROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docxPROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docx
PROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docxamrit47
 
C programming language tutorial
C programming language tutorial C programming language tutorial
C programming language tutorial javaTpoint s
 
Using standard libraries like stdio and sdtlib.h and using stats.h a.pdf
Using standard libraries like stdio and sdtlib.h and using stats.h a.pdfUsing standard libraries like stdio and sdtlib.h and using stats.h a.pdf
Using standard libraries like stdio and sdtlib.h and using stats.h a.pdffashiongallery1
 

Similar to Using an Array include ltstdiohgt include ltmpih.pdf (20)

C
CC
C
 
C
CC
C
 
Unit 3
Unit 3 Unit 3
Unit 3
 
Computer Networks Lab File
Computer Networks Lab FileComputer Networks Lab File
Computer Networks Lab File
 
Assignment c programming
Assignment c programmingAssignment c programming
Assignment c programming
 
Hooking signals and dumping the callstack
Hooking signals and dumping the callstackHooking signals and dumping the callstack
Hooking signals and dumping the callstack
 
Code is not text! How graph technologies can help us to understand our code b...
Code is not text! How graph technologies can help us to understand our code b...Code is not text! How graph technologies can help us to understand our code b...
Code is not text! How graph technologies can help us to understand our code b...
 
Mouse programming in c
Mouse programming in cMouse programming in c
Mouse programming in c
 
#include iostream #include deque #include stdio.h   scan.pdf
#include iostream #include deque #include stdio.h   scan.pdf#include iostream #include deque #include stdio.h   scan.pdf
#include iostream #include deque #include stdio.h   scan.pdf
 
Q1 Consider the below omp_trap1.c implantation, modify the code so t.pdf
Q1 Consider the below omp_trap1.c implantation, modify the code so t.pdfQ1 Consider the below omp_trap1.c implantation, modify the code so t.pdf
Q1 Consider the below omp_trap1.c implantation, modify the code so t.pdf
 
DSC program.pdf
DSC program.pdfDSC program.pdf
DSC program.pdf
 
Write a C code to perform the following tasks In main Define an arr.pdf
Write a C code to perform the following tasks In main Define an arr.pdfWrite a C code to perform the following tasks In main Define an arr.pdf
Write a C code to perform the following tasks In main Define an arr.pdf
 
golang_getting_started.pptx
golang_getting_started.pptxgolang_getting_started.pptx
golang_getting_started.pptx
 
C and Data structure lab manual ECE (2).pdf
C and Data structure lab manual ECE (2).pdfC and Data structure lab manual ECE (2).pdf
C and Data structure lab manual ECE (2).pdf
 
C
CC
C
 
PROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docx
PROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docxPROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docx
PROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docx
 
C programming language tutorial
C programming language tutorial C programming language tutorial
C programming language tutorial
 
Using standard libraries like stdio and sdtlib.h and using stats.h a.pdf
Using standard libraries like stdio and sdtlib.h and using stats.h a.pdfUsing standard libraries like stdio and sdtlib.h and using stats.h a.pdf
Using standard libraries like stdio and sdtlib.h and using stats.h a.pdf
 
Code optimization
Code optimization Code optimization
Code optimization
 
Code optimization
Code optimization Code optimization
Code optimization
 

More from giriraj65

Which of these refers to the degree and nature of interdepen.pdf
Which of these refers to the degree and nature of interdepen.pdfWhich of these refers to the degree and nature of interdepen.pdf
Which of these refers to the degree and nature of interdepen.pdfgiriraj65
 
Wheat crops across the Americas Asia Europe and Africa ar.pdf
Wheat crops across the Americas Asia Europe and Africa ar.pdfWheat crops across the Americas Asia Europe and Africa ar.pdf
Wheat crops across the Americas Asia Europe and Africa ar.pdfgiriraj65
 
The resto txt Use for TM254 2021J TMA02 Question 6 .pdf
The resto txt     Use for TM254 2021J TMA02 Question 6 .pdfThe resto txt     Use for TM254 2021J TMA02 Question 6 .pdf
The resto txt Use for TM254 2021J TMA02 Question 6 .pdfgiriraj65
 
Tableau DA 33 MiniCase Analyzing adjusting entries and p.pdf
Tableau DA 33 MiniCase Analyzing adjusting entries and p.pdfTableau DA 33 MiniCase Analyzing adjusting entries and p.pdf
Tableau DA 33 MiniCase Analyzing adjusting entries and p.pdfgiriraj65
 
Rios Co is a regional insurance company that began operatio.pdf
Rios Co is a regional insurance company that began operatio.pdfRios Co is a regional insurance company that began operatio.pdf
Rios Co is a regional insurance company that began operatio.pdfgiriraj65
 
Question 1 2 pts Which of the following can be absolute defe.pdf
Question 1 2 pts Which of the following can be absolute defe.pdfQuestion 1 2 pts Which of the following can be absolute defe.pdf
Question 1 2 pts Which of the following can be absolute defe.pdfgiriraj65
 
Objective The purpose of this exercise is to create a Linke.pdf
Objective The purpose of this exercise is to create a Linke.pdfObjective The purpose of this exercise is to create a Linke.pdf
Objective The purpose of this exercise is to create a Linke.pdfgiriraj65
 
Problem 6 Create the Kmaps and then simplify for the followi.pdf
Problem 6 Create the Kmaps and then simplify for the followi.pdfProblem 6 Create the Kmaps and then simplify for the followi.pdf
Problem 6 Create the Kmaps and then simplify for the followi.pdfgiriraj65
 
PLEASE ANSWER PART A B C D Thank you Kingbird Inc uses.pdf
PLEASE ANSWER PART A B C D  Thank you Kingbird Inc uses.pdfPLEASE ANSWER PART A B C D  Thank you Kingbird Inc uses.pdf
PLEASE ANSWER PART A B C D Thank you Kingbird Inc uses.pdfgiriraj65
 
Please discuss the following i Using examples for each typ.pdf
Please discuss the following i Using examples for each typ.pdfPlease discuss the following i Using examples for each typ.pdf
Please discuss the following i Using examples for each typ.pdfgiriraj65
 
Mill Company began operations on January 1201 and recogni.pdf
Mill Company began operations on January 1201 and recogni.pdfMill Company began operations on January 1201 and recogni.pdf
Mill Company began operations on January 1201 and recogni.pdfgiriraj65
 
For each situation described below indicate which financial.pdf
For each situation described below indicate which financial.pdfFor each situation described below indicate which financial.pdf
For each situation described below indicate which financial.pdfgiriraj65
 
Exercise I Georgettes and Georges Genotypes Gene 1 Geor.pdf
Exercise I Georgettes and Georges Genotypes Gene 1  Geor.pdfExercise I Georgettes and Georges Genotypes Gene 1  Geor.pdf
Exercise I Georgettes and Georges Genotypes Gene 1 Geor.pdfgiriraj65
 
El 23 de enero se adquieren 17000 acciones de Tolle Company.pdf
El 23 de enero se adquieren 17000 acciones de Tolle Company.pdfEl 23 de enero se adquieren 17000 acciones de Tolle Company.pdf
El 23 de enero se adquieren 17000 acciones de Tolle Company.pdfgiriraj65
 
Ests realizando experimentos de mejoramiento en maz Comie.pdf
Ests realizando experimentos de mejoramiento en maz Comie.pdfEsts realizando experimentos de mejoramiento en maz Comie.pdf
Ests realizando experimentos de mejoramiento en maz Comie.pdfgiriraj65
 
Assume that a cross is made between AaBb and aabb plants and.pdf
Assume that a cross is made between AaBb and aabb plants and.pdfAssume that a cross is made between AaBb and aabb plants and.pdf
Assume that a cross is made between AaBb and aabb plants and.pdfgiriraj65
 
a How much money was eriginally invested t Show that th.pdf
a How much money was eriginally invested t Show that th.pdfa How much money was eriginally invested t Show that th.pdf
a How much money was eriginally invested t Show that th.pdfgiriraj65
 
A Bucle remolino y arco B Crestas surcos y colinas .pdf
A  Bucle remolino y arco   B  Crestas surcos y colinas  .pdfA  Bucle remolino y arco   B  Crestas surcos y colinas  .pdf
A Bucle remolino y arco B Crestas surcos y colinas .pdfgiriraj65
 
68 Exercise Ferris Corporation makes a single product a f.pdf
68 Exercise Ferris Corporation makes a single product  a f.pdf68 Exercise Ferris Corporation makes a single product  a f.pdf
68 Exercise Ferris Corporation makes a single product a f.pdfgiriraj65
 
A special interest speaks for a position or program which 1.pdf
A special interest speaks for a position or program which 1.pdfA special interest speaks for a position or program which 1.pdf
A special interest speaks for a position or program which 1.pdfgiriraj65
 

More from giriraj65 (20)

Which of these refers to the degree and nature of interdepen.pdf
Which of these refers to the degree and nature of interdepen.pdfWhich of these refers to the degree and nature of interdepen.pdf
Which of these refers to the degree and nature of interdepen.pdf
 
Wheat crops across the Americas Asia Europe and Africa ar.pdf
Wheat crops across the Americas Asia Europe and Africa ar.pdfWheat crops across the Americas Asia Europe and Africa ar.pdf
Wheat crops across the Americas Asia Europe and Africa ar.pdf
 
The resto txt Use for TM254 2021J TMA02 Question 6 .pdf
The resto txt     Use for TM254 2021J TMA02 Question 6 .pdfThe resto txt     Use for TM254 2021J TMA02 Question 6 .pdf
The resto txt Use for TM254 2021J TMA02 Question 6 .pdf
 
Tableau DA 33 MiniCase Analyzing adjusting entries and p.pdf
Tableau DA 33 MiniCase Analyzing adjusting entries and p.pdfTableau DA 33 MiniCase Analyzing adjusting entries and p.pdf
Tableau DA 33 MiniCase Analyzing adjusting entries and p.pdf
 
Rios Co is a regional insurance company that began operatio.pdf
Rios Co is a regional insurance company that began operatio.pdfRios Co is a regional insurance company that began operatio.pdf
Rios Co is a regional insurance company that began operatio.pdf
 
Question 1 2 pts Which of the following can be absolute defe.pdf
Question 1 2 pts Which of the following can be absolute defe.pdfQuestion 1 2 pts Which of the following can be absolute defe.pdf
Question 1 2 pts Which of the following can be absolute defe.pdf
 
Objective The purpose of this exercise is to create a Linke.pdf
Objective The purpose of this exercise is to create a Linke.pdfObjective The purpose of this exercise is to create a Linke.pdf
Objective The purpose of this exercise is to create a Linke.pdf
 
Problem 6 Create the Kmaps and then simplify for the followi.pdf
Problem 6 Create the Kmaps and then simplify for the followi.pdfProblem 6 Create the Kmaps and then simplify for the followi.pdf
Problem 6 Create the Kmaps and then simplify for the followi.pdf
 
PLEASE ANSWER PART A B C D Thank you Kingbird Inc uses.pdf
PLEASE ANSWER PART A B C D  Thank you Kingbird Inc uses.pdfPLEASE ANSWER PART A B C D  Thank you Kingbird Inc uses.pdf
PLEASE ANSWER PART A B C D Thank you Kingbird Inc uses.pdf
 
Please discuss the following i Using examples for each typ.pdf
Please discuss the following i Using examples for each typ.pdfPlease discuss the following i Using examples for each typ.pdf
Please discuss the following i Using examples for each typ.pdf
 
Mill Company began operations on January 1201 and recogni.pdf
Mill Company began operations on January 1201 and recogni.pdfMill Company began operations on January 1201 and recogni.pdf
Mill Company began operations on January 1201 and recogni.pdf
 
For each situation described below indicate which financial.pdf
For each situation described below indicate which financial.pdfFor each situation described below indicate which financial.pdf
For each situation described below indicate which financial.pdf
 
Exercise I Georgettes and Georges Genotypes Gene 1 Geor.pdf
Exercise I Georgettes and Georges Genotypes Gene 1  Geor.pdfExercise I Georgettes and Georges Genotypes Gene 1  Geor.pdf
Exercise I Georgettes and Georges Genotypes Gene 1 Geor.pdf
 
El 23 de enero se adquieren 17000 acciones de Tolle Company.pdf
El 23 de enero se adquieren 17000 acciones de Tolle Company.pdfEl 23 de enero se adquieren 17000 acciones de Tolle Company.pdf
El 23 de enero se adquieren 17000 acciones de Tolle Company.pdf
 
Ests realizando experimentos de mejoramiento en maz Comie.pdf
Ests realizando experimentos de mejoramiento en maz Comie.pdfEsts realizando experimentos de mejoramiento en maz Comie.pdf
Ests realizando experimentos de mejoramiento en maz Comie.pdf
 
Assume that a cross is made between AaBb and aabb plants and.pdf
Assume that a cross is made between AaBb and aabb plants and.pdfAssume that a cross is made between AaBb and aabb plants and.pdf
Assume that a cross is made between AaBb and aabb plants and.pdf
 
a How much money was eriginally invested t Show that th.pdf
a How much money was eriginally invested t Show that th.pdfa How much money was eriginally invested t Show that th.pdf
a How much money was eriginally invested t Show that th.pdf
 
A Bucle remolino y arco B Crestas surcos y colinas .pdf
A  Bucle remolino y arco   B  Crestas surcos y colinas  .pdfA  Bucle remolino y arco   B  Crestas surcos y colinas  .pdf
A Bucle remolino y arco B Crestas surcos y colinas .pdf
 
68 Exercise Ferris Corporation makes a single product a f.pdf
68 Exercise Ferris Corporation makes a single product  a f.pdf68 Exercise Ferris Corporation makes a single product  a f.pdf
68 Exercise Ferris Corporation makes a single product a f.pdf
 
A special interest speaks for a position or program which 1.pdf
A special interest speaks for a position or program which 1.pdfA special interest speaks for a position or program which 1.pdf
A special interest speaks for a position or program which 1.pdf
 

Recently uploaded

Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfakmcokerachita
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 

Recently uploaded (20)

Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdf
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 

Using an Array include ltstdiohgt include ltmpih.pdf

  • 1. Using an Array: #include <stdio.h> #include <mpi.h> int main(int argc, char** argv) { int rank, size; MPI_Init(&argc, &argv); MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_size(MPI_COMM_WORLD, &size); // Define topology int topology[5][2] = {{1, 4}, {0, 2, 3}, {1,-1}, {0, 4}, {0, 3}}; // Initialize index and edge arrays int index[5] = {0}; int edges[5][3] = {{0}}; // Add edges into index array int i =0; int j =0; for (i = 0; i < 5; i++) { index[i] = sizeof(topology[i]) / sizeof(int); for (j = 0; j < index[i]; j++) { edges[i][j] = topology[i][j]; } } // Display topology for each process for (i = 0; i < size; i++) { if (rank == i) { printf("Process %d has %d neighbors: ", i, index[i]); for (j = 0; j < index[i]; j++) { printf("%d ", edges[i][j]); } printf("n"); } MPI_Barrier(MPI_COMM_WORLD); } MPI_Finalize(); return 0; } MPI Functions:
  • 2. #include <mpi.h> #include <stdio.h> int main(int argc, char** argv) { int rank, size; MPI_Init(&argc, &argv); // Initialize MPI MPI_Comm_rank(MPI_COMM_WORLD, &rank); // Get the rank of the current process MPI_Comm_size(MPI_COMM_WORLD, &size); // Get the total number of processes int nnodes = 5; // Number of nodes in the topology int nedges = 8; // Number of edges in the topolofy // Index of the first edge for each node int index[5] = {2, 5, 6, 8, 9}; int edges[9] = {4, 1, 0, 2, 3, 1, 4, 0, 3}; // List of all edges MPI_Comm graph_comm; // Create a new communicator for the graph topology MPI_Graph_create(MPI_COMM_WORLD, nnodes, index, edges, 0, &graph_comm); // Create the graph topology int count; // Number of neighbors int* neighbors; // Neighbor Ranks MPI_Graph_neighbors_count(graph_comm, rank, &count); // Get the number of neighbors for the current process neighbors = (int*) malloc(count * sizeof(int)); // Allocate memory for the array of neighbor ranks MPI_Graph_neighbors(graph_comm, rank, count, neighbors); // Get the neighbor ranks for the current process // Display process and the node in the topologies neighbors printf("Process %d has %d neighbors:", rank, count); int i; for (i = 0; i < count; i++) { printf(" %d", neighbors[i]); // Print the neighbor ranks } printf("n"); MPI_Finalize(); return 0; } ive provided my own code above in case that helps or makes it easier on you guys. My output isnt quite right ive been at it for a while if someone could fix the output and explain it to me id be very happy :) 4. Use Graph topology to create following one. Once you create your topology, use one process (e.g., process 0 ) to display the number of neighbors and its neighbors at each node (i.e., process). Use following two methods to check your topology. (20 points) i) Use two arrays, index and edges, to display number of neighbors and its neighbors for each node. ii) Use two functions in MPI, "MPI Graph neighbors count" and "MPI Graph neighbors". llinn@scholar-fe06: /470 $
  • 3. mpirun -n 5 ./hmwk5q4-b Process 0 has 2 neighbors: 41 Process 1 has 3 neighbors: 023 Process 2 has 1 neighbors: 1 Process 3 has 2 neighbors: 40