int main(int argc, char **argv)
{
	MPI_Init(&argc, &argv);
	double start_time, end_time;

    int i;
 
	// Init default values.
    Init_Default();

	// Read arguments.
    Read_Options(argc, argv);

	// Init the matrix.
    Init_Matrix();

	// Start timer.
	start_time = MPI_Wtime();

	// Do guassian elimination.
    Work();

	// Stop timer.
	end_time = MPI_Wtime();

    if(PRINT == 1)
	{
		printf("===== AFTER GUASSIAN ELIMINATION ======\n");
		Print_Matrix();
		printf("=======================================\n\n");
	}

	double time_taken = (end_time - start_time);
	printf("Execution time: %f\n", time_taken);
}
Esempio n. 2
0
/*starting the main function*/
int 
main(int argc, char **argv)
{
    pthread_t threads[NUM_CPUS];
    long k;
 
    Init_Default();		/* Init default values	*/
    Read_Options(argc,argv);	/* Read arguments	*/
    Init_Matrix();		/* Init the matrix	*/

   
    if(pthread_barrier_init(&barrier, NULL, NUM_CPUS)) /*barrier synchronization function*/
	{
		
		printf("Could not initialize the barrier \n");
		return -1;
	}


    for(k = 0; k < NUM_CPUS; k++)
	{
      if(pthread_create (&threads[k], NULL, (void *) &work, (void *) k)) /*allocating the work to threads*/
	  {
		  
		  printf("Could not create thread \n");
		  return -1;
	  }
	}

    for(k = 0; k < NUM_CPUS; k++)
	{
      if(pthread_join(threads[k],NULL))  /* Join function to ensure that all the threads have done their work */
		{
			
			printf("Could not join thread \n");
			return -1;
		}
	}

	
    if(pthread_barrier_destroy(&barrier)) /*Destruction of the barrier*/
	{
				printf("Barrier could not be destroyed");
		return -1;
	}

    if (PRINT == 1) /*printing the result*/
	Print_Matrix();
}