Commits

Jay Barra committed 53d1621

keep forgetting files

Comments (0)

Files changed (2)

Firefly/mpiNode.cpp

 		printf("Initializing Nodes\n");
 		printf("*********************************************************\n");
 		printf("Root Node: %s\n", m_pcName);
-		printf("Awaiting worker node responses...\n");
-		for (iSource = 1; iSource <= m_iNodes; iSource++) {
+		//printf("Awaiting worker node responses...\n");
+		/*for (iSource = 1; iSource <= m_iNodes; iSource++) {
 			MPI_Recv(pcMessage, 1024, MPI_CHAR, iSource, MESSAGE_TAG, MPI_COMM_WORLD, &status);
 			getStatus(status, pcStatus);
 			printf("AgentNode: %s\t| Status: %s\n", pcMessage, pcStatus);
-		}
+		}*/
 		printf("Node initialization complete...\n");
 		printf("%i Nodes Registered for work...\n", m_iNodes);
 		printf("*********************************************************\n");
 //-------------------------------------------------
 mpiNode::~mpiNode()
 {
- 	free(m_pcName); 
+  printf("Node %i destroyed\n", m_pcName);
+  //free(m_pcName); 
 }
 //-------------------------------------------------
 int mpiNode::id()
 {
-	return m_ID;
+  return m_ID;
 }
 //-------------------------------------------------
 char* mpiNode::name()
 {
-	return m_pcName;
+  return m_pcName;
 }
 //-------------------------------------------------
 int mpiNode::send(char* pcMessage, int iDest)
 {
-	int rc;
-	rc = MPI_Send(pcMessage, strlen(pcMessage)+1, MPI_CHAR, iDest, MESSAGE_TAG, MPI_COMM_WORLD);
-	return rc;
+  int rc;
+  rc = MPI_Send(pcMessage, strlen(pcMessage)+1, MPI_CHAR, iDest, MESSAGE_TAG, MPI_COMM_WORLD);
+  return rc;
 }
 //------------------------------------------------
 void mpiNode::getStatus(MPI_Status status, char* pcStatus)
 //------------------------------------------------
 void mpiNode::run()
 {
-	int iSize = 3;
-	double** pdSend = (double**)malloc(iSize * iSize * sizeof(double)); 
-	double** pdRecv = (double**)malloc(iSize * iSize * sizeof(double));
-	
-	for (int i = 0; i < iSize; i++) {
-		pdSend[i] = (double*)malloc(iSize * sizeof(double));
-		pdRecv[i] = (double*)malloc(iSize * sizeof(double));
-	}
-
-	MPI_Scatter(*pdSend, iSize, MPI_DOUBLE, *pdRecv, iSize, MPI_DOUBLE, ROOT, MPI_COMM_WORLD);
-	
-	if (m_ID != ROOT) {
-	for (int i = 0; i < iSize; i++) {
-		for (int m = 0; m < iSize; m++) {
-			pdRecv[i][m] = (double)(100 * i) / iSize + m_ID;
-		}
-	} 
-	printf("\n\n");
-	for (int i = 0; i < iSize; i++) {
-		printf("( ");
-		for (int m = 0; m < iSize; m++) {	
-			printf("%f ", pdRecv[i][m]);
-		}
-		printf(") -> %i\n", m_ID);
-	}
-	}
-	
-	MPI_Gather(pdRecv, iSize, MPI_DOUBLE, pdSend, iSize * iSize, MPI_DOUBLE, ROOT, MPI_COMM_WORLD);
-
-
-	if (m_ID == ROOT) {
-		for (int k = 0; k < iSize; k++) {
-			printf("[ ");	
-			for (int l = 0; l < iSize; l++) {
-				printf("%f ", pdSend[k][l]);
-			}
-			printf("]\n");
-		}	
-	}
-	
-	free(*pdSend);
-	free(pdRecv);
 }
 //------------------------------------------------
 

Firefly/run_mpi.sh

 #!/usr/local/bin/tcsh
 clear
-mpirun -np 4 -machinefile mymachines mpi
+mpirun -np 8 ~/cs523/Firefly/mpi -machinefile cluster.hosts