int main(int argc, char *argv[]) { char name[MAX_NAME], host[MAX_HOST_NAME], my_host[MAX_HOST_NAME], msgout[MAX_LINE], *server; int bytes; my_ppid = getppid(); server = argv[1]; pthread_mutex_init(&mutex, NULL); printf("\nTrying to connect to server %s at port %d...", server, PORT); sock = sockconnect(server, PORT); if (sock == -1) { printf("\nCouldn't connect to the server!"); exit(1); } /* set up clean up function */ signal(SIGINT, Clean_Up); /* send LOGIN */ gethostname(my_host,MAX_HOST_NAME); my_id = (int) (getpid()); sprintf(msgout,"LOGIN,%s,%s,%d;",getlogin(),my_host,my_id); pthread_mutex_lock(&mutex); bytes = send(sock, msgout, strlen(msgout)+1, 0); pthread_mutex_unlock(&mutex); if (bytes == -1) { printf("\nCouldn't send command!"); Clean_Up(); } else { printf("\nSent Login Info."); } pthread_create(&tid_send_hey, NULL, (void*) &Send_Hey, (void*) sock); pthread_create(&tid_get_hey, NULL, (void*) &Get_Hey, (void*) sock); while (1) { sleep (2); if (my_ppid != getppid()) Clean_Up(); } }
Squad::~Squad() { Clean_Up(); LOG(("Freed Squad \n")); }
int main(int argc, char **argv) { start_timer(); Setup_Grid(); Solve(); Write_Grid(); print_timer(); Clean_Up(); return 0; }
int main(int argc, char **argv) { int size_mpi_double; long data_communicated_bytes; long global_communicated_bytes = 0; MPI_Init(&argc, &argv); Setup_Proc_Grid(argc, argv); // start_timer(); Setup_Grid(); Setup_MPI_Datatypes(); Solve(); Write_Grid(); print_timer(); MPI_Type_size(MPI_DOUBLE, &size_mpi_double); data_communicated_bytes = data_communicated * size_mpi_double; MPI_Reduce(&data_communicated_bytes, &global_communicated_bytes, 1, MPI_LONG, MPI_SUM, 0, grid_comm); if (proc_rank == 0) { printf("ds: Data sent = %ld\n", global_communicated_bytes); } Clean_Up(); MPI_Finalize(); return 0; }