Log In | Get Help   
Home My Page Projects Code Snippets Project Openings Mareframe
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files
[mareframe] Diff of /trunk/paramin-beta/netcommunication.cc
[mareframe] / trunk / paramin-beta / netcommunication.cc Repository:
ViewVC logotype

Diff of /trunk/paramin-beta/netcommunication.cc

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 6, Sun May 10 20:56:01 2015 UTC revision 7, Mon May 11 07:50:15 2015 UTC
# Line 69  Line 69 
69  int NetCommunication::startPVM()  int NetCommunication::startPVM()
70  {  {
71          /*          /*
72                  Þetta fall er afgreitt í bili!                  Ãžetta fall er afgreitt í bili!
73                  ATH: Þarf e.t.v. að skoða parametrana í MPI_Init.                  ATH: Þarf e.t.v. að skoða parametrana í MPI_Init.
74          */          */
75          int info;          int info;
76          // Held að það sé í lagi að hafa bara NULL hér...          // Held að það sé í lagi að hafa bara NULL hér...
77          MPI_Init(NULL, NULL);          MPI_Init(NULL, NULL);
78          if (mytid < 0)          if (mytid < 0)
79          {          {
# Line 92  Line 92 
92                  {                  {
93                          printErrorMsg("Error in netcommunication - MPI_Init has not been called!");                          printErrorMsg("Error in netcommunication - MPI_Init has not been called!");
94                  }                  }
95                  // nhost á að vera 1 hérna                  // nhost á að vera 1 hérna
96                  MPI_Comm_size(MPI_COMM_WORLD, &nhost);                  MPI_Comm_size(MPI_COMM_WORLD, &nhost);
97    
98          tids = new int[maxNumHosts];          tids = new int[maxNumHosts];
# Line 109  Line 109 
109  int NetCommunication::startNetCommunication()  int NetCommunication::startNetCommunication()
110  {  {
111          /*          /*
112                  Þetta fall er afgreitt í bili!                  Ãžetta fall er afgreitt í bili!
113          */          */
114          int i, OK, info;          int i, OK, info;
115          if (NETSTARTED == 1 && mytid >= 0)          if (NETSTARTED == 1 && mytid >= 0)
# Line 130  Line 130 
130                  if (OK == 1)                  if (OK == 1)
131                  {                  {
132                          /*                          /*
133                                  Í PVM var notað pvm_catchout(stdin) til að fá output úr                                  Ã� PVM var notað pvm_catchout(stdin) til að fá output úr
134                                  child processunum, í MPI setur maður flag á eftir mpirun                                  child processunum, í MPI setur maður flag á eftir mpirun
135                                  til að fá sambærilega hegðun, þá búast til skrár fyrir hvert                                  til að fá sambærilega hegðun, þá búast til skrár fyrir hvert
136                                  process sem skrifa út allt sem kemur úr stdout og stderr í þeim.                                  process sem skrifa út allt sem kemur úr stdout og stderr í þeim.
137                          */                          */
138                          MPI_Comm_spawn(slaveProgram, slaveArguments, nhost, MPI_INFO_NULL,                          MPI_Comm_spawn(slaveProgram, slaveArguments, nhost, MPI_INFO_NULL,
139                          0, MPI_COMM_WORLD, &intercomm, errcodes);                          0, MPI_COMM_WORLD, &intercomm, errcodes);
# Line 158  Line 158 
158                  }                  }
159    
160                  /*                  /*
161                  Þýðandinn var eitthvað að kvarta hérna...                  ÃžÃ½Ã°andinn var eitthvað að kvarta hérna...
162          for (i = 0; i < nhost; i++)          for (i = 0; i < nhost; i++)
163                  {                  {
164    
# Line 206  Line 206 
206  void NetCommunication::stopNetCommunication()  void NetCommunication::stopNetCommunication()
207  {  {
208          /*          /*
209                  Fínt í bili.                  Fínt í bili.
210          */          */
211          int i, tid, info, numTasks;          int i, tid, info, numTasks;
212          int stopparam = -1;          int stopparam = -1;
# Line 227  Line 227 
227  int NetCommunication::startProcesses()  int NetCommunication::startProcesses()
228  {  {
229          /*          /*
230                  Þetta fall er afgreitt í bili!                  Ãžetta fall er afgreitt í bili!
231          */          */
232    //Send number of variables, group name and number of processes to spawned processes    //Send number of variables, group name and number of processes to spawned processes
233          int cansend = 1;          int cansend = 1;
# Line 274  Line 274 
274          }          }
275    
276          // check if process with identity = id is up and running          // check if process with identity = id is up and running
277          // spurning að sleppa þessu í bili, leyfum þessu að vera á meðan hitt er klárað.          // spurning að sleppa þessu í bili, leyfum þessu að vera á meðan hitt er klárað.
278          OK = checkProcess(id);          OK = checkProcess(id);
279          if (OK == 1)          if (OK == 1)
280          {          {
# Line 314  Line 314 
314    
315  int NetCommunication::checkProcess(int id) {  int NetCommunication::checkProcess(int id) {
316          /*          /*
317                  Þetta fall er ekki að gera neitt, því það sendir adrei nein                  Ãžetta fall er ekki að gera neitt, því það sendir adrei nein
318                  út með tagginu getTaskDiedTag()                  Ãºt með tagginu getTaskDiedTag()
319          */          */
320          int info, bufID, recvTid, flag;          int info, bufID, recvTid, flag;
321          MPI_Status stats, recvstats;          MPI_Status stats, recvstats;
# Line 327  Line 327 
327          // Non-blocking probe which checks for a message with this tag, if there is no message then          // Non-blocking probe which checks for a message with this tag, if there is no message then
328          // flag is false, otherwise it is true, then something is maybe wrong with the process!          // flag is false, otherwise it is true, then something is maybe wrong with the process!
329    
330          // ATH: Þetta flag mun líklega alltaf vera false... það tékkar bara strax og heldur svo          // ATH: Þetta flag mun líklega alltaf vera false... það tékkar bara strax og heldur svo
331          // áfram, þetta virkar eins og pvm_probe, svo þetta ætti að vera í lagi hér.          // áfram, þetta virkar eins og pvm_probe, svo þetta ætti að vera í lagi hér.
332          // Held samt að það sé irrelevant að vera með þetta checkprocess núna, það á allt að          // Held samt að það sé irrelevant að vera með þetta checkprocess núna, það á allt að
333          // vera í lagi...          // vera í lagi...
334          bufID = MPI_Iprobe(id, pvmConst->getTaskDiedTag(), intercomm, &flag, &stats);          bufID = MPI_Iprobe(id, pvmConst->getTaskDiedTag(), intercomm, &flag, &stats);
335          if (flag == true) {          if (flag == true) {
336      // message has arrived from tids[id] that has halted      // message has arrived from tids[id] that has halted
# Line 366  Line 366 
366    
367  void NetCommunication::checkProcesses() {  void NetCommunication::checkProcesses() {
368          /*          /*
369                  Þetta fall er komið í bili.                  Ãžetta fall er komið í bili.
370                  Þetta fall erl íka í raun óþarfi...                  Ãžetta fall erl íka í raun óþarfi...
371          */          */
372    int i, info, tidDown, flag;    int i, info, tidDown, flag;
373    MPI_Request req;    MPI_Request req;
# Line 390  Line 390 
390    
391  void NetCommunication::getHealthOfProcesses(int* procTids) {  void NetCommunication::getHealthOfProcesses(int* procTids) {
392          /*          /*
393                  Þetta fall er afgreitt.                  Ãžetta fall er afgreitt.
394    
395          */          */
396    checkProcesses();    checkProcesses();
# Line 404  Line 404 
404  // ********************************************************  // ********************************************************
405  int NetCommunication::sendData(const ParameterVector& sendP) {  int NetCommunication::sendData(const ParameterVector& sendP) {
406          /*          /*
407                  Komið í bili, þarf samt að skoða MPI_PACK eða eitthvað álíka til að                  Komið í bili, þarf samt að skoða MPI_PACK eða eitthvað álíka til að
408                  raða inn í buffer og senda strengina, gæti verið að maður þurfi þá að                  raða inn í buffer og senda strengina, gæti verið að maður þurfi þá að
409                  pakka int með sem er lengd char fylkisins. Það er samt bara kallað á þetta                  pakka int með sem er lengd char fylkisins. Það er samt bara kallað á þetta
410                  fall einu sinni í byrjun til að senda switches, svo að það ætti að vera í lagi.                  fall einu sinni í byrjun til að senda switches, svo að það ætti að vera í lagi.
411                  !!! ATH !!!                  !!! ATH !!!
412                  Passa að allir sem kalla á þetta sendi communicator !!!                  Passa að allir sem kalla á þetta sendi communicator !!!
413                  !!!                  !!!
414          */          */
415      // must absolutely check if this is possible or can not delete      // must absolutely check if this is possible or can not delete
# Line 425  Line 425 
425                  // broadcasting the data via a tree structure, this should not create too much overhead.                  // broadcasting the data via a tree structure, this should not create too much overhead.
426                  for(int j = 0; j<nhost; j++)                  for(int j = 0; j<nhost; j++)
427                  {                  {
428                          MPI_Send(stringValue[i],strlen(stringValue[i]), MPI_BYTE, j, pvmConst->getMasterSendStringTag(), intercomm);                          MPI_Send(stringValue[i],strlen(stringValue[i])+1, MPI_CHAR, j, pvmConst->getMasterSendStringTag(), intercomm);
429                  }                  }
430        };        };
431      assert(sendP.Size() >= numVar);      assert(sendP.Size() >= numVar);
# Line 448  Line 448 
448    
449  int NetCommunication::sendData(const ParameterVector& sendP, int processID) {  int NetCommunication::sendData(const ParameterVector& sendP, int processID) {
450          /*          /*
451                  Búið í bili...                  Búið í bili...
452          */          */
453          int i, info;          int i, info;
454          char** stringValue;          char** stringValue;
# Line 462  Line 462 
462                          // This could be causing some overhead, could consider packing it in a buffer                          // This could be causing some overhead, could consider packing it in a buffer
463                          // before I send it, like the old pvm version, let's see if this works ok.                          // before I send it, like the old pvm version, let's see if this works ok.
464                          // I think this function is only called once.                          // I think this function is only called once.
465                          MPI_Send(stringValue[i],strlen(stringValue[i]), MPI_BYTE,tids[processID],pvmConst->getMasterSendStringTag(),intercomm);                          MPI_Send(stringValue[i],strlen(stringValue[i])+1, MPI_CHAR,tids[processID],pvmConst->getMasterSendStringTag(),intercomm);
466          };          };
467          assert(sendP.Size() >= numVar);          assert(sendP.Size() >= numVar);
468    
# Line 481  Line 481 
481  int NetCommunication::sendBoundData(const DoubleVector& sendP)  int NetCommunication::sendBoundData(const DoubleVector& sendP)
482  {  {
483          /*          /*
484                  Komið í bili...                  Komið í bili...
485          */          */
486          int i, info;          int i, info;
487          double* temp;          double* temp;
# Line 509  Line 509 
509  int NetCommunication::sendBoundData(const DoubleVector& sendP, int processID)  int NetCommunication::sendBoundData(const DoubleVector& sendP, int processID)
510  {  {
511          /*          /*
512                  Komið í bili!                  Komið í bili!
513          */          */
514          int i, info;          int i, info;
515          double* temp;          double* temp;
# Line 534  Line 534 
534  int NetCommunication::sendData(NetDataVariables* sendP, int processID)  int NetCommunication::sendData(NetDataVariables* sendP, int processID)
535  {  {
536          /*          /*
537                  Komið í bili!                  Komið í bili!
538          */          */
539          int info;          int info;
540          int cansend = 1;          int cansend = 1;
# Line 583  Line 583 
583  int NetCommunication::receiveData(NetDataResult* rp)  int NetCommunication::receiveData(NetDataResult* rp)
584  {  {
585          /*          /*
586                  Komið í bili...                  Komið í bili...
587                  Þarf að passa að kasta villu ef einhver af þessum nær ekki að receive-a, nota kannski                  Ãžarf að passa að kasta villu ef einhver af þessum nær ekki að receive-a, nota kannski
588                  MPI_Probe...                  MPI_Probe...
589          */          */
590          int info;          int info;
# Line 596  Line 596 
596                  MPI_Recv(&rp->result, 1, MPI_DOUBLE, status.MPI_SOURCE, pvmConst->getMasterReceiveDataTag(), intercomm, &status2);                  MPI_Recv(&rp->result, 1, MPI_DOUBLE, status.MPI_SOURCE, pvmConst->getMasterReceiveDataTag(), intercomm, &status2);
597                  MPI_Recv(&rp->who, 1, MPI_INT, status.MPI_SOURCE, pvmConst->getMasterReceiveDataTag(), intercomm, &status2);                  MPI_Recv(&rp->who, 1, MPI_INT, status.MPI_SOURCE, pvmConst->getMasterReceiveDataTag(), intercomm, &status2);
598                  MPI_Recv(&rp->x_id, 1, MPI_INT, status.MPI_SOURCE, pvmConst->getMasterReceiveDataTag(), intercomm, &status2);                  MPI_Recv(&rp->x_id, 1, MPI_INT, status.MPI_SOURCE, pvmConst->getMasterReceiveDataTag(), intercomm, &status2);
599                  cout << "Skrifa result úr netcomm: " << rp->result << "\n";                  cout << "Skrifa result úr netcomm: " << rp->result << "\n";
600          return SUCCESS;          return SUCCESS;
601          }          }
602          else          else
# Line 647  Line 647 
647  void NetCommunication::printErrorMsg(const char* errorMsg)  void NetCommunication::printErrorMsg(const char* errorMsg)
648  {  {
649          /*          /*
650                  Eina fallið sem ég virðist þurfa að eiga eitthvað við hér...                  Eina fallið sem ég virðist þurfa að eiga eitthvað við hér...
651          */          */
652          char* msg;          char* msg;
653          msg = new char[strlen(errorMsg) + 1];          msg = new char[strlen(errorMsg) + 1];
654          strcpy(msg, errorMsg);          strcpy(msg, errorMsg);
655          // Ákvað að gera þetta svona, vona að þetta flood-i ekki command line...          // Ã�kvað að gera þetta svona, vona að þetta flood-i ekki command line...
656          cout << msg << "\n";          cout << msg << "\n";
657          delete[] msg;          delete[] msg;
658          cerr << errorMsg << endl;          cerr << errorMsg << endl;
# Line 693  Line 693 
693  int MasterCommunication::receiveData(NetDataResult* rp)  int MasterCommunication::receiveData(NetDataResult* rp)
694  {  {
695          /*          /*
696                  Komið í bili...                  Komið í bili...
697                  Þarf að passa að kasta villu ef einhver af þessum nær ekki að receive-a, nota kannski                  Ãžarf að passa að kasta villu ef einhver af þessum nær ekki að receive-a, nota kannski
698                  MPI_Probe, þetta var gert með Timeout receive í gömlu útgáfunni...                  MPI_Probe, þetta var gert með Timeout receive í gömlu útgáfunni...
699          */          */
700          int info;          int info;
701          MPI_Status status, status2;          MPI_Status status, status2;

Legend:
Removed from v.6  
changed lines
  Added in v.7

root@forge.cesga.es
ViewVC Help
Powered by ViewVC 1.0.0  

Powered By FusionForge