Révision 231 TrouNoir/trou_noir_OpenMP.c

trou_noir_OpenMP.c (revision 231)
18 18

  
19 19
	Compilation sous gcc ( Compilateur GNU sous Linux ) :
20 20

  
21
	Version FP32 :	gcc -O3 -ffast-math -FP32 -o trou_noir_FP32 trou_noir.c -lm
22
	Version FP64 :	gcc -O3 -ffast-math -FP64 -o trou_noir_FP64 trou_noir.c -lm
21
	Version FP32 : gcc -fopenmp -O3 -ffast-math -FP32 -o trou_noir_OMP_FP32 trou_noir_OpenMP.c -lm -lgomp
22
	Version FP64 : gcc -fopenmp -O3 -ffast-math -FP64 -o trou_noir_OMP_FP64 trou_noir_OpenMP.c -lm -lgomp
23 23
*/ 
24 24

  
25 25
#include <stdio.h>
......
35 35

  
36 36
#define TRACKPOINTS 2048
37 37

  
38
#if TYPE == FP32
38
#if TYPE == FP64
39 39
#define MYFLOAT float
40 40
#else
41 41
#define MYFLOAT double
......
223 223
  MYFLOAT zmx,fmx;
224 224
  int zimx=0,zjmx=0,fimx=0,fjmx=0;
225 225
  int raie,fcl,zcl;
226
 struct timeval tv1,tv2;
227
  double elapsed;
226
  struct timeval tv1,tv2;
227
  MYFLOAT elapsed,cputime,epoch;
228 228
  int mtv1,mtv2;
229
  unsigned int epoch1,epoch2;
229 230

  
230 231
  /* Variables used inside pragma need to be placed inside loop ! */
231 232

  
......
260 261
	}
261 262
    }
262 263
  
263
  if (argc==9)
264
  if ((argc==9)||(argc==7))
264 265
    {
265 266
      printf("# Utilisation les valeurs definies par l'utilisateur\n");
266 267
      
......
339 340
  bmx=1.25*re;
340 341

  
341 342
  // Set start timer
342
  //  gettimeofday(&tv1, &tz);
343 343
  gettimeofday(&tv1, NULL);
344
  //
345 344
  mtv1=clock()*1000/CLOCKS_PER_SEC;
345
  epoch1=time(NULL);
346 346
  
347 347
#pragma omp parallel for
348 348
  for (int n=1;n<=nmx;n++)
......
422 422
    }
423 423

  
424 424
  // Set stop timer
425
  //  gettimeofday(&tv2, &tz);
426 425
  gettimeofday(&tv2, NULL);
427 426
  mtv2=clock()*1000/CLOCKS_PER_SEC;
427
  epoch2=time(NULL);
428 428
  
429
  //  elapsed=(double)((tv2.tv_sec-tv1.tv_sec) * 1000000L +
430
  //			  (tv2.tv_usec-tv1.tv_usec))/1000000;  
431
  elapsed=(double)((mtv2-mtv1)/1000.);  
432
  
429
  elapsed=(MYFLOAT)((tv2.tv_sec-tv1.tv_sec) * 1000000L +
430
		    (tv2.tv_usec-tv1.tv_usec))/1000000;
431
  cputime=(MYFLOAT)((mtv2-mtv1)/1000.);  
432
  epoch=(MYFLOAT)(epoch2-epoch1);  
433

  
433 434
  fmx=fp[0][0];
434 435
  zmx=zp[0][0];
435 436
  
......
451 452
    }
452 453

  
453 454
  printf("\nElapsed Time : %lf",(double)elapsed);
455
  printf("\nCPU Time : %lf",(double)cputime);
456
  printf("\nEpoch Time : %lf",(double)epoch);
454 457
  printf("\nZ max @(%i,%i) : %f",zimx,zjmx,zmx);
455 458
  printf("\nFlux max @(%i,%i) : %f\n\n",fimx,fjmx,fmx);
456 459

  
457
  for (int i=0;i<dim;i++) for (int j=0;j<dim;j++)
458
    {
459
      zcl=(int)(255/zmx*zp[i][dim-1-j]);
460
      fcl=(int)(255/fmx*fp[i][dim-1-j]);
461

  
462
      if (strcmp(argv[6],"NEGATIVE")==0)
460
  // If input parameters set without output files precised
461
  if (argc!=7) {
462
  
463
    for (int i=0;i<dim;i++)
464
      for (int j=0;j<dim;j++)
463 465
	{
464
	  if (zcl>255)
465
	    {
466
	      izp[i][j]=0;
467
	    }
468
	  else
469
	    {
470
	      izp[i][j]=255-zcl;
471
	    }
466
	  zcl=(int)(255/zmx*zp[i][dim-1-j]);
467
	  fcl=(int)(255/fmx*fp[i][dim-1-j]);
472 468
	  
473
	  if (fcl>255)
469
	  if (strcmp(argv[6],"NEGATIVE")==0)
474 470
	    {
475
	      ifp[i][j]=0;
476
	    }
477
	  else
478
	    {
479
	      ifp[i][j]=255-fcl;
480
	    } 
471
	      if (zcl>255)
472
		{
473
		  izp[i][j]=0;
474
		}
475
	      else
476
		{
477
		  izp[i][j]=255-zcl;
478
		}
479
	      
480
	      if (fcl>255)
481
		{
482
		  ifp[i][j]=0;
483
		}
484
	      else
485
		{
486
		  ifp[i][j]=255-fcl;
487
		} 
481 488
	  
482
	}
483
      else
484
	{
485
	  if (zcl>255)
486
	    {
487
	      izp[i][j]=255;
488 489
	    }
489 490
	  else
490 491
	    {
491
	      izp[i][j]=zcl;
492
	      if (zcl>255)
493
		{
494
		  izp[i][j]=255;
495
		}
496
	      else
497
		{
498
		  izp[i][j]=zcl;
499
		}
500
	      
501
	      if (fcl>255)
502
		{
503
		  ifp[i][j]=255;
504
		}
505
	      else
506
		{
507
		  ifp[i][j]=fcl;
508
		} 
509
	      
492 510
	    }
493
	  
494
	  if (fcl>255)
495
	    {
496
	      ifp[i][j]=255;
497
	    }
498
	  else
499
	    {
500
	      ifp[i][j]=fcl;
501
	    } 
502
	  
511
	
503 512
	}
504
	
505
    }
506

  
507
  if (argc==9)
508
   {
509
     sauvegarde_pgm(argv[7],ifp,dim);
510
     sauvegarde_pgm(argv[8],izp,dim);
511
   }
513
    
514
    if (argc==9)
515
      {
516
	  sauvegarde_pgm(argv[7],ifp,dim);
517
	  sauvegarde_pgm(argv[8],izp,dim);
518
      }
519
    else
520
      {
521
	sauvegarde_pgm("z.pgm",izp,dim);
522
	sauvegarde_pgm("flux.pgm",ifp,dim);
523
      }    
524
  }
512 525
  else
513 526
    {
514
      sauvegarde_pgm("z.pgm",izp,dim);
515
      sauvegarde_pgm("flux.pgm",ifp,dim);
527
      printf("No output file precised, useful for benchmarks...\n\n");
516 528
    }
517 529

  
518 530
  free(zp[0]);
519 531
  free(zp);
520 532
  free(fp[0]);
521 533
  free(fp);
522

  
534
  
523 535
  free(izp[0]);
524 536
  free(izp);
525 537
  free(ifp[0]);

Formats disponibles : Unified diff