Révision 180

BLAS/xTRSV/xTRSV.c (revision 180)
25 25
#include "fortran_common.h"
26 26
#include "fortran_thunking.h"
27 27
#elif FBLAS
28
#include <cblas.h>
28 29
#include <cblas_f77.h>
29 30
#elif GSL
30 31
#include <gsl_cblas.h>
31 32
#elif ACML
32 33
#include <acml.h>
33
#include <acml_mv.h>
34 34
#else
35 35
#include <cblas.h>
36
#include <blaswrap.h>
36 37
#endif
37 38

  
38 39
#ifdef DOUBLE
......
41 42
#define LENGTH float
42 43
#endif
43 44

  
44
#ifdef FBLAS
45

  
46
#ifdef DOUBLE
47

  
48
void dtrsv_( FCHAR, FCHAR, FCHAR, FINT, const double *, FINT, double *, FINT);
49

  
50
void dgemv_(FCHAR, FINT, FINT, const double *, const double *, FINT, 
51
	       const double *, FINT, const double *, double *, FINT);
52

  
53
void dswap_( FINT, double *, FINT, double *, FINT);
54

  
55
void daxpy_( FINT, const double *, const double *, FINT, double *, FINT);
56

  
57
void dnrm2_( FINT, const double *, FINT, double *);
58

  
59
#else
60

  
61
void strsv_( FCHAR, FCHAR, FCHAR, FINT, const float *, FINT, float *, FINT);
62

  
63
void sgemv_(FCHAR, FINT, FINT, const float *, const float *, FINT, 
64
	       const float *, FINT, const float *, float *, FINT);
65

  
66
void sswap_( FINT, float *, FINT, float *, FINT);
67

  
68
void saxpy_( FINT, const float *, const float *, FINT, float *, FINT);
69

  
70
void snrm2_( FINT, const float *, FINT, float *);
71

  
72
#endif
73

  
74
#endif
75

  
76 45
/* Matrix with only defined triangular terms */
77 46
/* Even if there are 0 in matrix, must be defined at all ! */
78 47

  
......
217 186
      if (j>i)
218 187
	{
219 188
	  /* Normalization is necessary to avoid problems */
189
	  /* A[i*dim+j]=(LENGTH)rand()/(RAND_MAX+1.) */
190
	  /*   *(LENGTH)(i+1.)/(LENGTH)(j+1.); */
220 191
	  A[i*dim+j]=(LENGTH)rand()/(RAND_MAX+1.)
221
	    *(LENGTH)(i+1.)/(LENGTH)(j+1.);
192
	    /(LENGTH)(dim-j);
222 193
	}
223 194
      else if (j==i)
224 195
	{
......
314 285
      printVectorGPU(dim,devPtrX,"X","Errors");
315 286

  
316 287
      /* Estimate the second checker */
317
/*       checksA[i]=(double)cublasDnrm2(dim,devPtrX,incx); */
288
      checksA[i]=(double)cublasDnrm2(dim,devPtrX,incx);
318 289

  
319 290
      /* Swap vector X and Y */
320 291
      cublasDswap(dim,devPtrX,incx,devPtrY,incx);
......
340 311
      printVectorGPU(dim,devPtrX,"X","Errors");
341 312

  
342 313
      /* Estimate the second checker */
343
/*       checksA[i]=(double)cublasSnrm2(dim,devPtrX,incx); */
314
      checksA[i]=(double)cublasSnrm2(dim,devPtrX,incx);
344 315

  
345 316
      /* Swap vector X and Y */
346 317
      cublasSswap(dim,devPtrX,incx,devPtrY,incx);
......
395 366
      printVector(dim,X,"X","Errors");
396 367

  
397 368
      /* Store the checker of errors */
398
/*       checksA[i]=(double)CUBLAS_DNRM2(&dim,X,&incx); */
369
      checksA[i]=(double)CUBLAS_DNRM2(&dim,X,&incx);
399 370

  
400 371
      /* Swap vector X and Y */
401 372
      CUBLAS_DSWAP(&dim,X,&incx,Y,&incx);
......
419 390
      printVector(dim,X,"X","Errors");
420 391

  
421 392
      /* Store the checker of errors */
422
/*       checksA[i]=(double)CUBLAS_SNRM2(&dim,X,&incx); */
393
      checksA[i]=(double)CUBLAS_SNRM2(&dim,X,&incx);
423 394

  
424 395
      /* Swap vector X and Y */
425 396
      CUBLAS_SSWAP(&dim,X,&incx,Y,&incx);
......
443 414
    {
444 415
#ifdef DOUBLE
445 416
      
446
      printVector(dim,X,"X","Roots");
417
      printVector(dim,X,"X","Initial roots");
447 418
      
448 419
      /* Multiply A by X as Y <- A.X */
449 420
      dgemv_(&trans,&dim,&dim,&alpha,A,&dim,X,&incx,&beta,Y,&incx);
450 421
      
451
      printVector(dim,Y,"Y","Results");
422
      printVector(dim,Y,"Y<-A.X","Estimated results");
452 423
      
453 424
      /* Solve linear system */
454 425
      dtrsv_(&uplo,&trans,&diag,&dim,A,&dim,Y,&incx);
455 426
      
456
      printVector(dim,Y,"Y","Solutions");
427
      printVector(dim,Y,"X","Solutions from A.X=Y");
457 428
      
458 429
      /* Compare the roots X and Y */
459 430
      daxpy_(&dim,&beta2,Y,&incx,X,&incx);
460 431
      
461
      printVector(dim,X,"X","Errors");
432
      printVector(dim,X,"X","Differences initial and estimated");
462 433
      
463 434
      /* Store the checker of errors */
464
/*       dnrm2_(&dim,X,&incx,&checksA[i]); */
435
      dnrm2_(&dim,X,&incx,&checksA[i]);
465 436
            
466 437
      /* Swap vector X and Y */
467 438
      dswap_(&dim,X,&incx,Y,&incx);
......
486 457
      printVector(dim,X,"X","Errors");
487 458

  
488 459
      /* Store the checker of errors */
489
/*       snrm2_(&dim,X,&incx,&checksA[i]); */
460
      snrm2_(&dim,X,&incx,&checksA[i]);
490 461

  
491 462
      /* Swap vector X and Y */
492 463
      sswap_(&dim,X,&incx,Y,&incx);
......
524 495
      printVector(dim,X,"X","Errors");
525 496
      
526 497
      /* Store the checker of errors */
527
/*       dnrm2_(&dim,X,&incx,&checksA[i]); */
498
      dnrm2_(&dim,X,&incx,&checksA[i]);
528 499
            
529 500
      /* Swap vector X and Y */
530 501
      dswap(dim,X,incx,Y,incx);
......
549 520
      printVector(dim,X,"X","Errors");
550 521

  
551 522
      /* Store the checker of errors */
552
/*       snrm2_(&dim,X,&incx,&checksA[i]); */
523
      snrm2_(&dim,X,&incx,&checksA[i]);
553 524

  
554 525
      /* Swap vector X and Y */
555 526
      sswap(dim,X,incx,Y,incx);
......
592 563
      printVector(dim,X,"X","Errors");
593 564

  
594 565
      /* Store the checker of errors */
595
/*       checksA[i]=(double)cblas_dnrm2(dim,X,incx); */
566
      checksA[i]=(double)cblas_dnrm2(dim,X,incx);
596 567

  
597 568
      cblas_dswap(dim,X,incx,Y,incx);
598 569
      
......
617 588
      printVector(dim,X,"X","Errors");
618 589

  
619 590
      /* Store the checker of errors */
620
/*       checksA[i]=(double)cblas_snrm2(dim,X,incx); */
591
      checksA[i]=(double)cblas_snrm2(dim,X,incx);
621 592

  
622 593
      cblas_sswap(dim,X,incx,Y,incx);
623 594
      
......
659 630
      printVector(dim,X,"X","Errors");
660 631

  
661 632
      /* Store the checker of errors */
662
/*       checksA[i]=(double)cblas_dnrm2(dim,X,incx); */
633
      checksA[i]=(double)cblas_dnrm2(dim,X,incx);
663 634

  
664 635
      cblas_dswap(dim,X,incx,Y,incx);
665 636
      
......
684 655
      printVector(dim,X,"X","Errors");
685 656

  
686 657
      /* Store the checker of errors */
687
/*       checksA[i]=(double)cblas_snrm2(dim,X,incx); */
688

  
658
      checksA[i]=(double)cblas_snrm2(dim,X,incx);
659
      
689 660
      cblas_sswap(dim,X,incx,Y,incx);
690 661
      
691 662
#endif
BLAS/xTRSV/Makefile (revision 180)
1 1
SOURCE=xTRSV.c
2 2

  
3
CC=gcc-4.6
4
FC=gfortran-4.6
3
CC=gcc
4
FC=gfortran
5 5
CFLAGS=-Wall -O3
6 6
LDFLAGS=-lm
7
CUDADIR=/opt/cuda
8
CUDASRC=$(CUDADIR)/src
7
CUDASRC=/usr/share/doc/nvidia-cuda-doc/examples/
9 8
THUNKING=fortran_thunking.c
10 9
CUDASRCINC=fortran_common.h
11
CUDAINC=$(CUDADIR)/include
12
CUDALIB=$(CUDADIR)/lib64
10
CUDAINC=/usr/include
11
CUDALIB=/usr/lib/x86_64-linux-gnu/
13 12

  
14 13
GSLINC=/usr/include/gsl
15 14

  
16 15
GOTO2=/opt/GotoBLAS2
17 16

  
18
OPENBLAS=/usr/lib/openblas-base
17
OPENBLAS=/usr/lib
19 18

  
20 19
ATLAS=/usr/lib/atlas-base
21 20

  
......
31 30

  
32 31
#DIRECTIVES=-D$(FORMAT) -DPRINT -DUNIT
33 32
#DIRECTIVES=-D$(FORMAT) -DUNIT -DRESULTS -DQUIET
34
DIRECTIVES=-DQUIET -DUNIT
33
#DIRECTIVES=-DQUIET -DUNIT
34
DIRECTIVES=-DRESULTS -DQUIET
35 35

  
36 36
all: $(EXECUTABLE)
37 37

  
......
43 43
	$(CC) $(CFLAGS) $(DIRECTIVES) -DDOUBLE -DCBLAS $(LDFLAGS) \
44 44
		$(SOURCE) $(ATLAS)/libcblas.a $(ATLAS)/libatlas.a -o $(SOURCE:.c=)_DP_$@
45 45

  
46
gotoblas: $(SOURCE)
47

  
48
	$(CC) $(CFLAGS) $(DIRECTIVES) -DFLOAT -DCBLAS $(LDFLAGS) \
49
		$(SOURCE) $(GOTO2)/libgoto2.a -lpthread -o $(SOURCE:.c=)_SP_$@
50

  
51
	$(CC) $(CFLAGS) $(DIRECTIVES) -DDOUBLE -DCBLAS $(LDFLAGS) \
52
		$(SOURCE) $(GOTO2)/libgoto2.a -lpthread -o $(SOURCE:.c=)_DP_$@
53

  
54 46
openblas: $(SOURCE)
55 47

  
56 48
	$(CC) $(CFLAGS) $(DIRECTIVES) -DFLOAT -DCBLAS $(LDFLAGS) \

Formats disponibles : Unified diff