Exemplo n.º 1
0
int main(int argc, char *argv[])
{
    printf("The first four letters of the alphabet:\n");
    print_A();
    print_B();
    print_C();
    print_D();
    return(RETVALUE);
}
int main(int argc, char **argv) {
  /* Timing variables */
  struct timeval etstart, etstop;  /* Elapsed times using gettimeofday() */
  struct timezone tzdummy;
  clock_t etstart2, etstop2;  /* Elapsed times using times() */
  unsigned long long usecstart, usecstop;
  struct tms cputstart, cputstop;  /* CPU times for my processes */

  /* Process program parameters */
  parameters(argc, argv);

  /* Initialize A and B */
  initialize_inputs();

  /* Print input matrices */
  print_inputs();

  /* Start Clock */
  printf("\nStarting clock.\n");
  gettimeofday(&etstart, &tzdummy);
  etstart2 = times(&cputstart);

  /* Gaussian Elimination */
  matrixNorm();

  /* Stop Clock */
  gettimeofday(&etstop, &tzdummy);
  etstop2 = times(&cputstop);
  printf("Stopped clock.\n");
  usecstart = (unsigned long long)etstart.tv_sec * 1000000 + etstart.tv_usec;
  usecstop = (unsigned long long)etstop.tv_sec * 1000000 + etstop.tv_usec;

  /* Display output */
  print_B();

  /* Display timing results */
  printf("\nElapsed time = %g ms.\n",
	 (float)(usecstop - usecstart)/(float)1000);

  printf("(CPU times are accurate to the nearest %g ms)\n",
	 1.0/(float)CLOCKS_PER_SEC * 1000.0);
  printf("My total CPU time for parent = %g ms.\n",
	 (float)( (cputstop.tms_utime + cputstop.tms_stime) -
		  (cputstart.tms_utime + cputstart.tms_stime) ) /
	 (float)CLOCKS_PER_SEC * 1000);
  printf("My system CPU time for parent = %g ms.\n",
	 (float)(cputstop.tms_stime - cputstart.tms_stime) /
	 (float)CLOCKS_PER_SEC * 1000);
  printf("My total CPU time for child processes = %g ms.\n",
	 (float)( (cputstop.tms_cutime + cputstop.tms_cstime) -
		  (cputstart.tms_cutime + cputstart.tms_cstime) ) /
	 (float)CLOCKS_PER_SEC * 1000);
      /* Contrary to the man pages, this appears not to include the parent */
  printf("--------------------------------------------\n");
  
  exit(0);
}
Exemplo n.º 3
0
int main(int argc, char **argv) {

    /* Prototype functions*/
    void gauss();

    MPI_Init(&argc, &argv);

    /* Get my process rank */
    MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);
    /* Find out how many processes are being used */
    MPI_Comm_size(MPI_COMM_WORLD, &p);

    printf("\nProcess number %d of %d says hi\n",
            my_rank+1, p);

    /* Every process reads the parameters to prepare dimension */
    parameters(argc, argv);

    /* Every process must allocate memory for the arrays */
    allocate_memory();

    if ( my_rank == SOURCE ) {
        /* Initialize A and B */
        initialize_inputs();

        /* Print input matrices */
        print_inputs();
    }

    /*printf("\nProcess number %d of %d says hi\n",
            my_rank+1, p);*/

    gauss();

    if ( my_rank == SOURCE ) {

        /* Print input matrices */
        print_A();
        print_B();
        print_X();
    }

    /* The barrier prevents any process to reach the finalize before the others have finished their communications */
    MPI_Barrier(MPI_COMM_WORLD);

    /* Free memory used for the arrays that we allocated previously */
    free_memory();

    MPI_Finalize();
}
Exemplo n.º 4
0
void
run_sspath(t_csr *gs, p_list *predecesor, 
		lint source, double delta){
	int i;	
	char f_buf[100];	
	sprintf(f_buf, "./data/log/ori");
	FILE *log = fopen(f_buf, "w");	
	p_list *B = (p_list*)malloc(sizeof(p_list)*1000);		
	for(i=0;i<1000;i++){
		B[i] = (p_list) malloc(sizeof(t_list));
		creat_list(B[i]);
	}
	p_list R = (p_list)malloc(sizeof(t_list));
	p_list S = (p_list)malloc(sizeof(t_list));

	creat_list(R);
	creat_list(S);
	for(i=0;i<gs->v_size;i++)
		gs->vet_info[i].weight = INFINITY;
	//relax source vertex
	add_list_two(B[0], source, 0.0);
	gs->vet_info[source].weight = 0.0;
	lint b_total = 1;
	lint iter = 0;

	//major computing
	while(b_total>0){
		empty(R);	
		while (B[iter]->next!=NULL){
			request(gs, delta, B[iter], R, TYPE_LIGHT);
			remember(B[iter], S, &b_total);
			relax(gs, predecesor, B, R, delta, &b_total);
			//DPRINTF(1, "finished relax\n");
		}
		request(gs, delta, S, R, TYPE_HEAVY);
		relax(gs, predecesor, B, R, delta, &b_total);
		print_B(B, log, iter);
		//printf("=================iter %ld\n", iter);
		iter++;
		//DPRINTF(1, "finished iteration %lld \n", iter);
	}
	//DPRINTF(1, "iterations taken %lld\n", iter);	
	//for(i=0;i<gs->v_size;i++)
	//	DPRINTF(1, "vertex %lld %f\n", (i+1), gs->vet_info[i].weight);
	//DPRINTF(1, "\n");
}
Exemplo n.º 5
0
int main()
{
	msg_count_login = 0;
	user_count = 0;
	bad_login_count = 0;

A_menu:
	while (1)
	{
		print_A();
		if (handle_A_input() == 2)
			goto B_menu;
	}

B_menu:
	while (1)
	{
		print_B();
		if (handle_B_input() == 2)
			goto A_menu;
	}
	
	return 0;
}