Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - rangovi su uvijek slijedni brojevi i poËinju od 0, a zbog tog öto proces moûe imati razliËiti rang unutar komunikatora ne znamo koji od njih Êe dobiti neki od ta dva ranga
- Zadatak 2:
- /*
- ============================================================================
- Name : petrovic_lv1.c
- Author : student
- Version :
- Copyright : Your copyright notice
- Description : Compute Pi in MPI C++
- ============================================================================
- */
- #include <math.h>
- #include "mpi.h"
- #include <iostream>
- using namespace std;
- int main(int argc, char *argv[])
- {
- int rank,size;
- MPI::Init(argc, argv);
- size = MPI::COMM_WORLD.Get_size();
- rank = MPI::COMM_WORLD.Get_rank();
- int struktura;
- int rang=0;
- if(rank == 0)
- {
- cout << "Odaberite strukturu: " << endl;
- cout << "Struktura 1 - svi procesi su jednaki " << endl;
- cout << "Struktura2 - Master-worker " << endl;
- cin >> struktura;
- }
- if(rank==0 && struktura==2)
- {
- cout << "Odaberite rang procesa za master: " << endl;
- for(int i=0;i<size;i++)
- {
- cout << i << endl;
- }
- cin >> rang;
- }
- if(rank==rang)
- {
- cout<<"Odabrana struktura je: "<<endl;
- if(struktura==1)
- {
- cout << "1 - svi procesi su jednaki " << endl;
- }
- else if (struktura==2)
- {
- cout << "2 - Master-worker " << endl;
- }
- }
- cout << "P[" << rank <<"]([" <<"]): "<< "Pozdrav svijete!" << endl;
- MPI::Finalize();
- return 0; }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement