Index: BLAS/xGEMM/patch_thunking.h
===================================================================
--- BLAS/xGEMM/patch_thunking.h	(revision 0)
+++ BLAS/xGEMM/patch_thunking.h	(revision 1)
@@ -0,0 +1,4 @@
+41c41
+< #define CUBLAS_FORTRAN_COMPILER CUBLAS_G95
+---
+> #define CUBLAS_FORTRAN_COMPILER CUBLAS_INTEL_FORTRAN
Index: BLAS/xGEMM/Makefile
===================================================================
--- BLAS/xGEMM/Makefile	(revision 0)
+++ BLAS/xGEMM/Makefile	(revision 1)
@@ -0,0 +1,116 @@
+SOURCE=xGEMM.c
+
+CC=gcc
+CFLAGS=-Wall -O3
+LDFLAGS=-lm
+CUDADIR=/opt/cuda
+CUDASRC=$(CUDADIR)/src
+THUNKING=fortran_thunking.c
+CUDASRCINC=fortran_common.h
+CUDAINC=$(CUDADIR)/include
+CUDALIB=$(CUDADIR)/lib64
+
+PATCHTHUNKING=patch_thunking.h
+
+GSLINC=/usr/include/gsl
+
+GOTO2=/opt/GotoBLAS2
+
+ACML=/opt/acml
+ACMLINC=$(ACML)/gfortran64_mp/include
+ACMLLIB=$(ACML)/gfortran64_mp/lib
+
+
+EXECUTABLE=cblas fblas gsl cublas thunking gotoblas acml
+
+FORMAT=DOUBLE
+#FORMAT=FLOAT
+
+#DIRECTIVES=-D$(FORMAT) -DPRINT -DUNIT
+#DIRECTIVES=-D$(FORMAT) -DUNIT -DRESULTS -DQUIET
+DIRECTIVES=-DUNIT -DQUIET
+
+all: $(EXECUTABLE)
+
+cblas: $(SOURCE)
+
+	$(CC) $(CFLAGS) $(DIRECTIVES) -DFLOAT -DCBLAS $(LDFLAGS) \
+		$(SOURCE) -lcblas -o $(SOURCE:.c=)_SP_$@
+
+	$(CC) $(CFLAGS) $(DIRECTIVES) -DDOUBLE -DCBLAS $(LDFLAGS) \
+		$(SOURCE) -lcblas -o $(SOURCE:.c=)_DP_$@
+
+gotoblas: $(SOURCE)
+
+	$(CC) $(CFLAGS) $(DIRECTIVES) -DFLOAT -DCBLAS $(LDFLAGS) \
+		$(SOURCE) $(GOTO2)/libgoto2.a -lpthread -o $(SOURCE:.c=)_SP_$@
+
+	$(CC) $(CFLAGS) $(DIRECTIVES) -DDOUBLE -DCBLAS $(LDFLAGS) \
+		$(SOURCE) $(GOTO2)/libgoto2.a -lpthread -o $(SOURCE:.c=)_DP_$@
+
+acml: $(SOURCE)
+
+	$(CC) -I$(ACMLINC) $(CFLAGS) $(DIRECTIVES) -DFLOAT -DACML $(LDFLAGS) \
+		$(SOURCE) -L$(ACMLLIB) -lacml_mp -lacml_mv \
+		-lgomp -lgfortran -lpthread -o $(SOURCE:.c=)_SP_$@
+
+	$(CC) -I$(ACMLINC) $(CFLAGS) $(DIRECTIVES) -DDOUBLE -DACML $(LDFLAGS) \
+		$(SOURCE) -L$(ACMLLIB) -lacml_mp -lacml_mv \
+		-lgomp -lgfortran -lpthread -o $(SOURCE:.c=)_DP_$@
+
+fblas: $(SOURCE)
+
+	$(CC) $(CFLAGS) $(DIRECTIVES) -DFLOAT -DFBLAS $(LDFLAGS) \
+		$(SOURCE) -lf77blas -o $(SOURCE:.c=)_SP_$@
+
+	$(CC) $(CFLAGS) $(DIRECTIVES) -DDOUBLE -DFBLAS $(LDFLAGS) \
+		$(SOURCE) -lf77blas -o $(SOURCE:.c=)_DP_$@
+
+
+gsl: $(SOURCE)
+
+	$(CC) -I$(GSLINC) $(CFLAGS) $(DIRECTIVES) -DFLOAT \
+		-DGSL $(LDFLAGS) \
+		$(SOURCE) -lgslcblas -o $(SOURCE:.c=)_SP_$@
+
+	$(CC) -I$(GSLINC) $(CFLAGS) $(DIRECTIVES) -DDOUBLE \
+		-DGSL $(LDFLAGS) \
+		$(SOURCE) -lgslcblas -o $(SOURCE:.c=)_DP_$@
+
+cublas: $(SOURCE)
+
+	$(CC) -I$(CUDAINC) -L$(CUDALIB) $(CFLAGS) -DFLOAT \
+		-DCUBLAS $(LDFLAGS) \
+		$(DIRECTIVES) $(SOURCE) -lcublas -o $(SOURCE:.c=)_SP_$@
+
+	$(CC) -I$(CUDAINC) -L$(CUDALIB) $(CFLAGS) -DDOUBLE \
+		-DCUBLAS $(LDFLAGS) \
+		$(DIRECTIVES) $(SOURCE) -lcublas -o $(SOURCE:.c=)_DP_$@
+
+thunking: $(SOURCE)
+
+	# Copy of source for thunking CUBLAS approach
+	cp $(CUDASRC)/$(THUNKING) $(CUDASRC)/$(THUNKING:.c=.h) \
+		$(CUDASRC)/$(CUDASRCINC) .
+	# Patch Thunking prototypes to compile on Debian Lenny
+	patch $(CUDASRCINC) $(PATCHTHUNKING)
+	$(CC) -I$(CUDAINC) $(CFLAGS) -c $(THUNKING)
+
+	$(CC) -I$(CUDAINC) -L$(CUDALIB) $(CFLAGS) -DFLOAT -DTHUNKING \
+		$(LDFLAGS) $(DIRECTIVES) $(SOURCE) \
+		$(THUNKING:.c=.o) -lcublas -o $(SOURCE:.c=)_SP_$@
+
+	$(CC) -I$(CUDAINC) -L$(CUDALIB) $(CFLAGS) -DDOUBLE -DTHUNKING \
+		$(LDFLAGS) $(DIRECTIVES) $(SOURCE) \
+		$(THUNKING:.c=.o) -lcublas -o $(SOURCE:.c=)_DP_$@
+
+clean: $(SOURCE)
+	find . -name "$(SOURCE:.c=)_*" -exec rm {} \;
+	find . -name "$(THUNKING:.c=)*" -exec rm {} \;
+	find . -name "*~" -exec rm {} \;
+	find . -name "$(CUDASRCINC)" -exec rm {} \;
+
+check: $(EXECUTABLE)
+
+	$(SOURCE:.c=)_SP_$(EXECUTABLE) 2 1
+
Index: BLAS/xGEMM/xGEMM.c
===================================================================
--- BLAS/xGEMM/xGEMM.c	(revision 0)
+++ BLAS/xGEMM/xGEMM.c	(revision 1)
@@ -0,0 +1,559 @@
+/* 
+   Performs matrix multiply
+
+   Thanks for help from aurel32@debian.org
+*/
+
+#include <stdio.h>
+#include <math.h>
+#include <stdlib.h>
+#include <sys/time.h>
+#include <string.h>
+
+#ifdef CUBLAS
+#include <cublas.h>
+#define CUBLAS_WRAPPER_ERROR_NOERR      0
+#define CUBLAS_WRAPPER_ERROR_ALLOC      1
+#define CUBLAS_WRAPPER_ERROR_SET        2
+#define CUBLAS_WRAPPER_ERROR_GET        3
+#define CUBLAS_WRAPPER_ERROR_STUB       4
+#elif THUNKING
+#include <cublas.h>
+#elif FBLAS
+#include <cblas_f77.h>
+#elif GSL
+#include <gsl_cblas.h>
+#elif ACML
+#include <acml.h>
+#include <acml_mv.h>
+#else
+#include <cblas.h>
+#endif
+
+#ifdef DOUBLE
+#define LENGTH double
+#else
+#define LENGTH float
+#endif
+
+#ifdef THUNKING
+#include "fortran_thunking.h"
+
+#elif FBLAS
+
+#ifdef DOUBLE
+
+void dgemm_(FCHAR, FCHAR, FINT, FINT, FINT, const double *, const double *, FINT, 
+	       const double *, FINT, const double *, double *, FINT);
+
+#else
+
+void sgemm_(FCHAR, FCHAR, FINT, FINT, FINT, const float *, const float *, FINT, 
+	       const float *, FINT, const float *, float *, FINT);
+
+#endif
+
+#endif
+
+/* Matrix with only defined triangular terms */
+/* Even if there are 0 in matrix, must be defined at all ! */
+
+/* Get from fortran.c */
+
+#ifdef CUBLAS
+static char *errMsg[5] = 
+{
+    "no error",
+    "allocation error",
+    "setVector/setMatrix error",
+    "getVector/getMatrix error",
+    "not implemented"
+};
+
+static void wrapperError (const char *funcName, int error)
+{
+    printf ("cublas%s wrapper: %s\n", funcName, errMsg[error]);
+    fflush (stdout);
+}
+#endif
+
+int printVector(const int dimVector,const LENGTH *dataVector,
+		char *nameVector,char *mesgVector)
+{
+#ifndef QUIET
+
+  int i;
+  printf("\n%s of %s, size %i:\n",mesgVector,nameVector,dimVector);
+  for (i=0;i<dimVector;i++)
+    {
+      printf("%s[%i]=%2.10e\n",nameVector,i,dataVector[i]);
+    }
+#endif
+
+  return 0;
+}
+  
+int printResults(const int dimVector,const LENGTH *dataVector,
+		 char *nameVector,char *mesgVector)
+{
+#ifdef RESULTS
+  int i;
+
+  printf("\n%s of %s, size %i:\n",mesgVector,nameVector,dimVector);
+  for (i=0;i<dimVector;i++)
+    {
+      printf("%s[%i]=%2.10e\n",nameVector,i,dataVector[i]);
+    }
+#endif
+  return 0;
+}
+  
+#ifdef CUBLAS
+int printVectorGPU(const int dimVector,const LENGTH *dataVector,
+		   char *nameVector,char *mesgVector)
+{
+#ifndef QUIET
+  int i;
+  cublasStatus stat;
+  LENGTH *P=0;
+  int incx=1;
+
+  P=malloc(dimVector*sizeof(LENGTH));
+  
+  stat=cublasGetVector(dimVector,sizeof(P[0]),dataVector,incx,P,incx);
+
+  if (stat != CUBLAS_STATUS_SUCCESS) {
+    wrapperError ("ToGet", CUBLAS_WRAPPER_ERROR_GET);
+  }  
+
+  printf("\n%s of %s, size %i:\n",mesgVector,nameVector,dimVector);
+  for (i=0;i<dimVector;i++)
+    {
+      printf("%s[%i]=%2.10e\n",nameVector,i,P[i]);
+    }
+
+  free(P);  
+#endif
+
+  return 0;
+}
+#endif
+
+int bench(int dim,int RUNS)
+{
+  /*
+  int dim=1000;
+  int RUNS=100;
+  int incx=1;
+  */
+#ifdef PRINT
+  LENGTH factor=1.;
+#endif
+
+  LENGTH alpha=1.,beta=0.;
+  LENGTH *A,*B,*C,*D;
+
+  /* checkBefore checkAfter checks */
+  LENGTH *checksA,*checksB;
+
+  int i=0, j=0;
+
+  double duration;
+
+  struct timeval tv1,tv2;
+  struct timezone tz;
+
+  /* Create 4 Matrix of dimension dim by dim  */
+
+  A=malloc(dim*dim*sizeof(LENGTH));
+  B=malloc(dim*dim*sizeof(LENGTH));
+  C=malloc(dim*dim*sizeof(LENGTH));
+  D=malloc(dim*dim*sizeof(LENGTH));
+
+  /* Create 2 vectors for checker Before and After */
+
+  checksA=malloc(RUNS*sizeof(LENGTH));
+  checksB=malloc(RUNS*sizeof(LENGTH));
+
+  /* Initialize elements with random numbers */
+  /* Initialize the seed for rand() */
+  /* srand(time()); */
+
+  for (i=0; i<dim; i++) {
+    for (j=0; j<dim; j++) {
+	A[i*dim+j]=(LENGTH)rand()/(RAND_MAX+1.)
+	  *(LENGTH)(i+1.)/(LENGTH)(j+1.); 
+	B[i*dim+j]=(LENGTH)rand()/(RAND_MAX+1.)
+	  *(LENGTH)(i+1.)/(LENGTH)(j+1.);
+	C[i*dim+j]=0.;
+	D[i*dim+j]=0.;
+    }
+  }
+  /*
+  A[0]=1;
+  A[1]=2;
+  A[2]=3;
+  A[3]=4;
+  
+  B[0]=5;
+  B[1]=6;
+  B[2]=7;
+  B[3]=8;
+  */
+
+  /* Print the matrix */
+ 
+#ifdef QUIET
+#else
+  for (i=0; i<dim; i++) {
+    for (j=0; j<dim; j++) printf("A[%i,%i]=%1.5f ", i,j,A[i*dim+j]);
+    putchar('\n');
+  }
+  putchar('\n');
+  for (i=0; i<dim; i++) {
+    for (j=0; j<dim; j++) printf("B[%i,%i]=%1.5f ", i,j,B[i*dim+j]);
+    putchar('\n');
+  }
+  putchar('\n');
+#endif
+
+ /* Get first timer before launching */
+  gettimeofday(&tv1, &tz);
+
+  /* Compute with CuBLAS library  */
+#ifdef CUBLAS
+  LENGTH *devPtrA=0, *devPtrB=0, *devPtrC=0, *devPtrD=0;
+  cublasStatus stat1, stat2, stat3, stat4;
+  struct timeval tv3,tv4;
+
+  /* Order is Row */
+  /* Have to swap uplo and trans */
+  char transa='N',transb='T';
+
+  printf("Using CuBLAS: %i iterations for %ix%i matrix\n",
+	 RUNS,dim,dim);
+
+  stat1=cublasAlloc(dim*dim,sizeof(devPtrA[0]),(void**)&devPtrA);
+  stat2=cublasAlloc(dim*dim,sizeof(devPtrB[0]),(void**)&devPtrB);
+  stat3=cublasAlloc(dim*dim,sizeof(devPtrC[0]),(void**)&devPtrC);
+  stat4=cublasAlloc(dim*dim,sizeof(devPtrD[0]),(void**)&devPtrD);
+
+  if ((stat1 != CUBLAS_STATUS_SUCCESS) || 
+      (stat2 != CUBLAS_STATUS_SUCCESS) ||
+      (stat3 != CUBLAS_STATUS_SUCCESS) ||
+      (stat4 != CUBLAS_STATUS_SUCCESS) ) {
+    wrapperError ("Double Dgemm", CUBLAS_WRAPPER_ERROR_ALLOC);
+    cublasFree (devPtrA);
+    cublasFree (devPtrB);
+    cublasFree (devPtrC);
+    cublasFree (devPtrD);
+    return 1;
+  }
+
+  stat1=cublasSetMatrix(dim,dim,sizeof(A[0]),A,dim,devPtrA,dim);
+  stat2=cublasSetMatrix(dim,dim,sizeof(B[0]),B,dim,devPtrB,dim);
+  stat3=cublasSetMatrix(dim,dim,sizeof(C[0]),C,dim,devPtrC,dim);
+  stat4=cublasSetMatrix(dim,dim,sizeof(D[0]),D,dim,devPtrD,dim);
+  
+  if ((stat1 != CUBLAS_STATUS_SUCCESS) ||
+      (stat2 != CUBLAS_STATUS_SUCCESS) ||
+      (stat3 != CUBLAS_STATUS_SUCCESS) ||
+      (stat4 != CUBLAS_STATUS_SUCCESS) ) {
+    wrapperError ("Double Dgemm", CUBLAS_WRAPPER_ERROR_SET);
+    cublasFree (devPtrA);
+    cublasFree (devPtrB);
+    cublasFree (devPtrC);
+    cublasFree (devPtrD);
+    return 1;
+  }
+
+  /* Get third timer after memory operation */
+  gettimeofday(&tv3, &tz);
+
+#ifdef DOUBLE
+
+  for (i=0;i<RUNS;i++)
+    {
+      cublasDgemm(transa,transa,dim,dim,dim,alpha,devPtrB,dim,
+		  devPtrA,dim,beta,devPtrC,dim);
+      cublasDgemm(transb,transb,dim,dim,dim,alpha,devPtrA,dim,
+		  devPtrB,dim,beta,devPtrD,dim);
+    }
+  
+#else
+
+  for (i=0;i<RUNS;i++)
+    {
+      cublasSgemm(transa,transa,dim,dim,dim,alpha,devPtrB,dim,
+		  devPtrA,dim,beta,devPtrC,dim);
+      cublasSgemm(transb,transb,dim,dim,dim,alpha,devPtrA,dim,
+		  devPtrB,dim,beta,devPtrD,dim);
+    }
+  
+#endif
+
+  stat3=cublasGetMatrix(dim,dim,sizeof(C[0]),devPtrC,dim,C,dim);
+  stat4=cublasGetMatrix(dim,dim,sizeof(D[0]),devPtrD,dim,D,dim);
+  
+  cublasFree (devPtrA);
+  cublasFree (devPtrB);
+  cublasFree (devPtrC);
+  cublasFree (devPtrD);
+  
+  if ((stat1 != CUBLAS_STATUS_SUCCESS) ) {
+    wrapperError ("Double Dgemm", CUBLAS_WRAPPER_ERROR_GET);
+  }
+  
+  /* Get fourth timer after memory free */
+  gettimeofday(&tv4, &tz);
+
+#elif THUNKING
+  
+  /* Order is Row : Have to swap uplo='U' and trans='N' */
+  char transa='N',transb='T';
+  printf("Using CuBLAS/Thunking: %i iterations for %ix%i matrix\n",
+	 RUNS,dim,dim);
+
+#ifdef DOUBLE
+
+  for (i=0;i<RUNS;i++)
+    {      
+      /* Multiply A by X as Y <- A.X */
+      CUBLAS_DGEMM(&transa,&transa,
+		   &dim,&dim,&dim,&alpha,B,&dim,A,&dim,&beta,C,&dim);
+      CUBLAS_DGEMM(&transb,&transb,
+		   &dim,&dim,&dim,&alpha,A,&dim,B,&dim,&beta,D,&dim);
+    }
+
+#else
+
+  for (i=0;i<RUNS;i++)
+    {      
+      /* Multiply A by X as Y <- A.X */
+      CUBLAS_SGEMM(&transa,&transa,
+		   &dim,&dim,&dim,&alpha,B,&dim,A,&dim,&beta,C,&dim);
+      CUBLAS_SGEMM(&transb,&transb,
+		   &dim,&dim,&dim,&alpha,A,&dim,B,&dim,&beta,D,&dim);
+    }
+  
+#endif
+
+#elif FBLAS
+  
+  /* Order is Row : Have to swap uplo='U' and trans='N' */
+      char transa='N',transb='T';
+  
+  printf("Using FBLAS: %i iterations for %ix%i matrix\n",
+	 RUNS,dim,dim);
+  
+#ifdef DOUBLE
+
+  for (i=0;i<RUNS;i++)
+    {    
+      /* Multiply A by X as Y <- A.X */
+      dgemm_(&transa,&transa,&dim,&dim,&dim,&alpha,B,&dim,A,&dim,&beta,C,&dim);
+      dgemm_(&transb,&transb,&dim,&dim,&dim,&alpha,A,&dim,B,&dim,&beta,D,&dim);
+    }
+
+#else
+
+  for (i=0;i<RUNS;i++)
+    {    
+      /* Multiply A by X as Y <- A.X */
+      sgemm_(&transa,&transa,&dim,&dim,&dim,&alpha,B,&dim,A,&dim,&beta,C,&dim);
+      sgemm_(&transb,&transb,&dim,&dim,&dim,&alpha,A,&dim,B,&dim,&beta,D,&dim);
+    }
+
+#endif
+
+#elif ACML
+  
+  /* Order is Row : Have to swap uplo='U' and trans='N' */
+      char transa='N',transb='T';
+  
+  printf("Using ACML: %i iterations for %ix%i matrix\n",
+	 RUNS,dim,dim);
+  
+#ifdef DOUBLE
+
+  for (i=0;i<RUNS;i++)
+    {    
+      /* Multiply A by X as Y <- A.X */
+      dgemm(transa,transa,dim,dim,dim,alpha,B,dim,A,dim,beta,C,dim);
+      dgemm(transb,transb,dim,dim,dim,alpha,A,dim,B,dim,beta,D,dim);
+    }
+
+#else
+
+  for (i=0;i<RUNS;i++)
+    {    
+      /* Multiply A by X as Y <- A.X */
+      sgemm(transa,transa,dim,dim,dim,alpha,B,dim,A,dim,beta,C,dim);
+      sgemm(transb,transb,dim,dim,dim,alpha,A,dim,B,dim,beta,D,dim);
+    }
+
+#endif
+
+#elif GSL
+
+  printf("Using GSL: %i iterations for %ix%i matrix\n",RUNS,dim,dim);
+
+  /* 
+     RowMajor : Matrix is read row by row
+     Upper : the no null elements are on top
+     NoTrans : no transposition before estimation
+     NonUnit : Matrix is not unit
+   */
+
+#ifdef DOUBLE
+
+  for (i=0;i<RUNS;i++)
+    {  
+      /* Multiply A by X as Y <- A.X */
+      cblas_dgemm(CblasRowMajor,CblasNoTrans,CblasNoTrans,
+		  dim,dim,dim,alpha,A,dim,B,dim,beta,C,dim);
+      cblas_dgemm(CblasRowMajor,CblasTrans,CblasTrans,
+		  dim,dim,dim,alpha,B,dim,A,dim,beta,D,dim);
+    }
+  
+#else
+
+  for (i=0;i<RUNS;i++)
+    {  
+      /* Multiply A by X as Y <- A.X */
+      cblas_sgemm(CblasRowMajor,CblasNoTrans,CblasNoTrans,
+		  dim,dim,dim,alpha,A,dim,B,dim,beta,C,dim);
+      cblas_sgemm(CblasRowMajor,CblasTrans,CblasTrans,
+		  dim,dim,dim,alpha,B,dim,A,dim,beta,D,dim);
+    }
+  
+#endif
+      
+#else
+
+  printf("Using CBLAS: %i iterations for %ix%i matrix\n",RUNS,dim,dim);
+
+  /* 
+     RowMajor : Matrix is read row bu row
+     Upper : the no null elements are on top
+     NoTrans : no transposition before estimation
+     NonUnit : Matrix is not unit
+   */
+
+#ifdef DOUBLE
+
+  for (i=0;i<RUNS;i++)
+    {  
+      cblas_dgemm(CblasRowMajor,CblasNoTrans,CblasNoTrans,
+		  dim,dim,dim,alpha,A,dim,B,dim,beta,C,dim);
+      cblas_dgemm(CblasRowMajor,CblasTrans,CblasTrans,
+		  dim,dim,dim,alpha,B,dim,A,dim,beta,D,dim);
+    }
+  
+#else
+
+  for (i=0;i<RUNS;i++)
+    {  
+      cblas_sgemm(CblasRowMajor,CblasNoTrans,CblasNoTrans,
+		  dim,dim,dim,alpha,A,dim,B,dim,beta,C,dim);
+      cblas_sgemm(CblasRowMajor,CblasTrans,CblasTrans,
+		  dim,dim,dim,alpha,B,dim,A,dim,beta,D,dim);
+    }
+  
+#endif
+
+#endif
+
+  /* Get second timer after launching */
+  gettimeofday(&tv2, &tz);
+
+  /* Store the checker of errors */
+  checksA[0]=0.;
+  
+  for (i=0; i<dim; i++) {
+    for (j=0; j<dim; j++) {
+      checksA[0]=checksA[0]+fabs(D[i*dim+j]-C[j*dim+i]);
+    }
+  }
+
+  /* Print the matrix */
+ 
+#ifdef QUIET
+#else
+  for (i=0; i<dim; i++) {
+    for (j=0; j<dim; j++) printf("C[%i,%i]=%1.5f ", i,j,C[i*dim+j]);
+    putchar('\n');
+  }
+  putchar('\n');
+  for (i=0; i<dim; i++) {
+    for (j=0; j<dim; j++) printf("D[%i,%i]=%1.5f ", i,j,D[i*dim+j]);
+    putchar('\n');
+  }
+  putchar('\n');
+#endif
+
+  /* Free 1 Matrix and 2 Vectors of dimension dim  */
+
+  free(A);
+  free(B);
+  free(C);
+  free(D);
+
+  putchar('\n');
+
+#ifdef CUBLAS
+  double memoryIn,memoryOut;
+
+  memoryIn=(double)((tv3.tv_sec-tv1.tv_sec) * 1000000L +	\
+		    (tv3.tv_usec-tv1.tv_usec))/1000000.;  
+
+  memoryOut=(double)((tv2.tv_sec-tv4.tv_sec) * 1000000L +	\
+		    (tv2.tv_usec-tv4.tv_usec))/1000000.;  
+
+  duration=(double)((tv4.tv_sec-tv3.tv_sec) * 1000000L +	\
+		    (tv4.tv_usec-tv3.tv_usec))/1000000./RUNS;  
+
+  printf("Duration of memory allocation : %2.10f s\n",memoryIn);
+  printf("Duration of memory free : %2.10f s\n",memoryOut);
+#else
+  duration=(double)((tv2.tv_sec-tv1.tv_sec) * 1000000L +	\
+		    (tv2.tv_usec-tv1.tv_usec))/1000000./RUNS;  
+
+#endif
+
+  printf("Duration of each cycle : %2.10f s\n",duration);
+
+  printf("Number of GFlops : %2.3f \n",
+	 dim*dim*2.*(2.*dim-1)/duration/1000000000.);
+
+  printf("Error %1.10f\n",checksA[0]);
+  printResults(RUNS,checksA,"C","Errors cumulated");
+
+  putchar('\n');
+
+  /* Free 2 vectors for checker Before and After */
+
+  free(checksA);
+  free(checksB);
+
+  return 0;
+}
+
+int main(int argc,char **argv)
+{
+  if ((argc==1)||
+      (strcmp(argv[1],"-h")==0)||
+      (strcmp(argv[1],"--help")==0))
+    {
+      printf("\nPerforms a bench using BLAS library implementation:\n\n"
+	     "\t#1 Size of square matrices \n"
+	     "\t#2 Number of iterations\n\n");
+    }
+  else if ((atoi(argv[1])>=2)&&
+	   (atoi(argv[2])>=1))
+    {
+      bench(atoi(argv[1]),atoi(argv[2]));
+    }
+
+  return 0;
+}
Index: BLAS/xGEMM/bench-cublas.sh
===================================================================
--- BLAS/xGEMM/bench-cublas.sh	(revision 0)
+++ BLAS/xGEMM/bench-cublas.sh	(revision 1)
@@ -0,0 +1,37 @@
+#!/bin/bash
+
+DIR=$(pwd)/OUT
+
+BENCH=lesson23
+
+NUMBER=10
+
+SIZE=30
+
+STEP=1
+
+MAX=3000
+
+FORMAT=SP
+
+OUTSP_THUNKING=$DIR/${BENCH}_${FORMAT}_thunking.out
+OUTSP_CUBLAS=$DIR/${BENCH}_${FORMAT}_cublas.out
+
+echo > $OUTSP_THUNKING
+echo > $OUTSP_CUBLAS
+
+while [ $SIZE -le $MAX ]
+do
+        
+    FORMAT=SP
+
+    THUNKING=$(./${BENCH}_${FORMAT}_thunking $SIZE $NUMBER | grep GFlops | awk -F: '{ print $2 }' | awk '{ print  $1 }')
+    
+    CUBLAS=$(./${BENCH}_${FORMAT}_cublas $SIZE $NUMBER | grep GFlops | awk -F: '{ print $2 }' | tr "\n" " " | awk '{ print  $5"\t"$1"\t"$3 }')
+    
+    echo -e $SIZE"\t"$THUNKING >> $OUTSP_THUNKING
+    echo -e $SIZE"\t"$CUBLAS >> $OUTSP_CUBLAS
+
+    SIZE=$(($SIZE+$STEP))
+
+done

Property changes on: BLAS/xGEMM/bench-cublas.sh
___________________________________________________________________
Added: svn:executable
   + 

Index: BLAS/xGEMM/bench.sh
===================================================================
--- BLAS/xGEMM/bench.sh	(revision 0)
+++ BLAS/xGEMM/bench.sh	(revision 1)
@@ -0,0 +1,84 @@
+#!/bin/sh
+
+DIR=$(pwd)/OUT
+
+BENCH=lesson20
+
+NUMBER=2
+
+SIZE=512
+
+STEP=512
+
+MAX=8192
+
+FORMAT=SP
+
+OUTSP_CBLAS=$DIR/${BENCH}_${FORMAT}_cblas.out
+OUTSP_FBLAS=$DIR/${BENCH}_${FORMAT}_fblas.out
+OUTSP_GSL=$DIR/${BENCH}_${FORMAT}_gsl.out
+OUTSP_THUNKING=$DIR/${BENCH}_${FORMAT}_thunking.out
+OUTSP_CUBLAS=$DIR/${BENCH}_${FORMAT}_cublas.out
+
+FORMAT=DP
+
+OUTDP_CBLAS=$DIR/${BENCH}_${FORMAT}_cblas.out
+OUTDP_FBLAS=$DIR/${BENCH}_${FORMAT}_fblas.out
+OUTDP_GSL=$DIR/${BENCH}_${FORMAT}_gsl.out
+OUTDP_THUNKING=$DIR/${BENCH}_${FORMAT}_thunking.out
+OUTDP_CUBLAS=$DIR/${BENCH}_${FORMAT}_cublas.out
+
+echo > $OUTSP_CBLAS
+echo > $OUTSP_FBLAS
+echo > $OUTSP_GSL
+echo > $OUTSP_THUNKING
+echo > $OUTSP_CUBLAS
+
+echo > $OUTDP_CBLAS
+echo > $OUTDP_FBLAS
+echo > $OUTDP_GSL
+echo > $OUTDP_THUNKING
+echo > $OUTDP_CUBLAS
+
+while [ $SIZE -le $MAX ]
+do
+        
+    FORMAT=SP
+
+    CBLAS=$(./${BENCH}_${FORMAT}_cblas $SIZE $NUMBER | grep GFlops | awk -F: '{ print $2 }' | awk '{ print  $1 }')
+    
+    FBLAS=$(./${BENCH}_${FORMAT}_fblas $SIZE $NUMBER | grep GFlops | awk -F: '{ print $2 }' | awk '{ print  $1 }')
+
+#    GSL=$(./${BENCH}_${FORMAT}_gsl $SIZE $NUMBER | grep GFlops | awk -F: '{ print $2 }' | awk '{ print  $1 }')
+    
+    THUNKING=$(./${BENCH}_${FORMAT}_thunking $SIZE $NUMBER | grep GFlops | awk -F: '{ print $2 }' | awk '{ print  $1 }')
+    
+    CUBLAS=$(./${BENCH}_${FORMAT}_cublas $SIZE $NUMBER | grep GFlops | awk -F: '{ print $2 }' | tr "\n" " " | awk '{ print  $5"\t"$1"\t"$3 }')
+    
+    echo -e $SIZE"\t"$CBLAS >> $OUTSP_CBLAS
+    echo -e $SIZE"\t"$FBLAS >> $OUTSP_FBLAS
+    echo -e $SIZE"\t"$GSL >> $OUTSP_GSL
+    echo -e $SIZE"\t"$THUNKING >> $OUTSP_THUNKING
+    echo -e $SIZE"\t"$CUBLAS >> $OUTSP_CUBLAS
+
+    FORMAT=DP
+
+    CBLAS=$(./${BENCH}_${FORMAT}_cblas $SIZE $NUMBER | grep GFlops | awk -F: '{ print $2 }' | awk '{ print  $1 }')
+    
+    FBLAS=$(./${BENCH}_${FORMAT}_fblas $SIZE $NUMBER | grep GFlops | awk -F: '{ print $2 }' | awk '{ print  $1 }')
+
+#    GSL=$(./${BENCH}_${FORMAT}_gsl $SIZE $NUMBER | grep GFlops | awk -F: '{ print $2 }' | awk '{ print  $1 }')
+    
+    THUNKING=$(./${BENCH}_${FORMAT}_thunking $SIZE $NUMBER | grep GFlops | awk -F: '{ print $2 }' | awk '{ print  $1 }')
+    
+    CUBLAS=$(./${BENCH}_${FORMAT}_cublas $SIZE $NUMBER | grep GFlops | awk -F: '{ print $2 }' | tr "\n" " " | awk '{ print  $5"\t"$1"\t"$3 }')
+    
+    echo -e $SIZE"\t"$CBLAS >> $OUTDP_CBLAS
+    echo -e $SIZE"\t"$FBLAS >> $OUTDP_FBLAS
+#    echo -e $SIZE"\t"$GSL >> $OUTDP_GSL
+    echo -e $SIZE"\t"$THUNKING >> $OUTDP_THUNKING
+    echo -e $SIZE"\t"$CUBLAS >> $OUTDP_CUBLAS
+
+    SIZE=$(($SIZE+$STEP))
+    
+done

Property changes on: BLAS/xGEMM/bench.sh
___________________________________________________________________
Added: svn:executable
   + 

Index: BLAS/xGEMM/fortran_common.h.orig
===================================================================
--- BLAS/xGEMM/fortran_common.h.orig	(revision 0)
+++ BLAS/xGEMM/fortran_common.h.orig	(revision 1)
@@ -0,0 +1,400 @@
+/*
+ * Copyright 1993-2011 NVIDIA Corporation.  All rights reserved.
+ *
+ * NOTICE TO LICENSEE:
+ *
+ * This source code and/or documentation ("Licensed Deliverables") are
+ * subject to NVIDIA intellectual property rights under U.S. and
+ * international Copyright laws.
+ *
+ * These Licensed Deliverables contained herein is PROPRIETARY and
+ * CONFIDENTIAL to NVIDIA and is being provided under the terms and
+ * conditions of a form of NVIDIA software license agreement by and
+ * between NVIDIA and Licensee ("License Agreement") or electronically
+ * accepted by Licensee.  Notwithstanding any terms or conditions to
+ * the contrary in the License Agreement, reproduction or disclosure
+ * of the Licensed Deliverables to any third party without the express
+ * written consent of NVIDIA is prohibited.
+ *
+ * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
+ * LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
+ * SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE.  IT IS
+ * PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
+ * NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
+ * DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
+ * NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
+ * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
+ * LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
+ * SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THESE LICENSED DELIVERABLES.
+ *
+ * U.S. Government End Users.  These Licensed Deliverables are a
+ * "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
+ * 1995), consisting of "commercial computer software" and "commercial
+ * computer software documentation" as such terms are used in 48
+ * C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
+ * only as a commercial end item.  Consistent with 48 C.F.R.12.212 and
+ * 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
+ * U.S. Government End Users acquire the Licensed Deliverables with
+ * only those rights set forth herein.
+ *
+ * Any use of the Licensed Deliverables in individual and commercial
+ * software must include, in the user documentation and internal
+ * comments to the code, the above Disclaimer and U.S. Government End
+ * Users Notice.
+ */
+ 
+#define CUBLAS_G77              1
+#define CUBLAS_INTEL_FORTRAN    2
+#define CUBLAS_G95              3
+
+/* Default to g77 on Linux, and Intel Fortran on Win32 */
+#if defined(_WIN32)
+#define CUBLAS_FORTRAN_COMPILER CUBLAS_INTEL_FORTRAN
+#elif defined(__linux)
+#define CUBLAS_FORTRAN_COMPILER CUBLAS_G95
+#elif defined(__APPLE__)
+#define CUBLAS_FORTRAN_COMPILER CUBLAS_G95
+#define RETURN_COMPLEX   1
+#else
+#error unsupported platform
+#endif
+
+#if (CUBLAS_FORTRAN_COMPILER==CUBLAS_G77) || (CUBLAS_FORTRAN_COMPILER==CUBLAS_G95)
+/* NOTE: Must use -fno-second-underscore when building Fortran source with g77
+ *       g77 invocation may not use -fno-f2c, which forces different return 
+ *       type conventions than the one used below
+ */
+#define CUBLAS_INIT             cublas_init_
+#define CUBLAS_SHUTDOWN         cublas_shutdown_
+#define CUBLAS_ALLOC            cublas_alloc_
+#define CUBLAS_FREE             cublas_free_
+#define CUBLAS_SET_VECTOR       cublas_set_vector_
+#define CUBLAS_GET_VECTOR       cublas_get_vector_
+#define CUBLAS_SET_MATRIX       cublas_set_matrix_
+#define CUBLAS_GET_MATRIX       cublas_get_matrix_
+#define CUBLAS_GET_ERROR        cublas_get_error_
+#define CUBLAS_XERBLA           cublas_xerbla_
+#define CUBLAS_ISAMAX           cublas_isamax_
+#define CUBLAS_ISAMIN           cublas_isamin_
+#define CUBLAS_SASUM            cublas_sasum_
+#define CUBLAS_SAXPY            cublas_saxpy_
+#define CUBLAS_SCOPY            cublas_scopy_
+#define CUBLAS_SDOT             cublas_sdot_
+#define CUBLAS_SNRM2            cublas_snrm2_
+#define CUBLAS_SROT             cublas_srot_
+#define CUBLAS_SROTG            cublas_srotg_
+#define CUBLAS_SROTM            cublas_srotm_
+#define CUBLAS_SROTMG           cublas_srotmg_
+#define CUBLAS_SSCAL            cublas_sscal_
+#define CUBLAS_SSWAP            cublas_sswap_
+#define CUBLAS_CAXPY            cublas_caxpy_
+#define CUBLAS_CCOPY            cublas_ccopy_
+#define CUBLAS_CROT             cublas_crot_
+#define CUBLAS_CROTG            cublas_crotg_
+#define CUBLAS_CSCAL            cublas_cscal_
+#define CUBLAS_CSROT            cublas_csrot_
+#define CUBLAS_CSSCAL           cublas_csscal_
+#define CUBLAS_CSWAP            cublas_cswap_
+#define CUBLAS_CTRMV            cublas_ctrmv_
+#define CUBLAS_CDOTU            cublas_cdotu_
+#define CUBLAS_CDOTC            cublas_cdotc_
+#define CUBLAS_ICAMAX           cublas_icamax_
+#define CUBLAS_SCASUM           cublas_scasum_
+#define CUBLAS_SCNRM2           cublas_scnrm2_
+#define CUBLAS_SGBMV            cublas_sgbmv_
+#define CUBLAS_SGEMV            cublas_sgemv_
+#define CUBLAS_SGER             cublas_sger_
+#define CUBLAS_SSBMV            cublas_ssbmv_
+#define CUBLAS_SSPMV            cublas_sspmv_
+#define CUBLAS_SSPR             cublas_sspr_
+#define CUBLAS_SSPR2            cublas_sspr2_
+#define CUBLAS_SSYMV            cublas_ssymv_
+#define CUBLAS_SSYR             cublas_ssyr_
+#define CUBLAS_SSYR2            cublas_ssyr2_
+#define CUBLAS_STBMV            cublas_stbmv_
+#define CUBLAS_STBSV            cublas_stbsv_
+#define CUBLAS_STPMV            cublas_stpmv_
+#define CUBLAS_STPSV            cublas_stpsv_
+#define CUBLAS_STRMV            cublas_strmv_
+#define CUBLAS_STRSV            cublas_strsv_
+#define CUBLAS_SGEMM            cublas_sgemm_
+#define CUBLAS_SSYMM            cublas_ssymm_
+#define CUBLAS_SSYR2K           cublas_ssyr2k_
+#define CUBLAS_SSYRK            cublas_ssyrk_
+#define CUBLAS_STRMM            cublas_strmm_
+#define CUBLAS_STRSM            cublas_strsm_
+#define CUBLAS_CGEMM            cublas_cgemm_
+#define CUBLAS_CHEMM            cublas_chemm_
+#define CUBLAS_CSYMM            cublas_csymm_
+#define CUBLAS_CTRMM            cublas_ctrmm_
+#define CUBLAS_CTRSM            cublas_ctrsm_
+#define CUBLAS_CHERK            cublas_cherk_
+#define CUBLAS_CSYRK            cublas_csyrk_
+#define CUBLAS_CHER2K           cublas_cher2k_
+#define CUBLAS_CSYR2K           cublas_csyr2k_
+#define CUBLAS_IDAMAX           cublas_idamax_
+#define CUBLAS_IDAMIN           cublas_idamin_
+#define CUBLAS_DASUM            cublas_dasum_
+#define CUBLAS_DAXPY            cublas_daxpy_
+#define CUBLAS_DCOPY            cublas_dcopy_
+#define CUBLAS_DDOT             cublas_ddot_
+#define CUBLAS_DNRM2            cublas_dnrm2_
+#define CUBLAS_DROT             cublas_drot_
+#define CUBLAS_DROTG            cublas_drotg_
+#define CUBLAS_DROTM            cublas_drotm_
+#define CUBLAS_DROTMG           cublas_drotmg_
+#define CUBLAS_DSCAL            cublas_dscal_
+#define CUBLAS_DSWAP            cublas_dswap_
+#define CUBLAS_ZAXPY            cublas_zaxpy_
+#define CUBLAS_ZCOPY            cublas_zcopy_
+#define CUBLAS_ZROT             cublas_zrot_
+#define CUBLAS_ZROTG            cublas_zrotg_
+#define CUBLAS_ZSCAL            cublas_zscal_
+#define CUBLAS_ZDROT            cublas_zdrot_
+#define CUBLAS_ZDSCAL           cublas_zdscal_
+#define CUBLAS_ZSWAP            cublas_zswap_
+#define CUBLAS_ZDOTU            cublas_zdotu_
+#define CUBLAS_ZDOTC            cublas_zdotc_
+#define CUBLAS_IZAMAX           cublas_izamax_
+#define CUBLAS_DZASUM           cublas_dzasum_
+#define CUBLAS_DZNRM2           cublas_dznrm2_
+#define CUBLAS_DGBMV            cublas_dgbmv_
+#define CUBLAS_DGEMV            cublas_dgemv_
+#define CUBLAS_ZGEMV            cublas_zgemv_
+#define CUBLAS_DGER             cublas_dger_
+#define CUBLAS_DSBMV            cublas_dsbmv_
+#define CUBLAS_DSPMV            cublas_dspmv_
+#define CUBLAS_DSPR             cublas_dspr_
+#define CUBLAS_DSPR2            cublas_dspr2_
+#define CUBLAS_DSYMV            cublas_dsymv_
+#define CUBLAS_DSYR             cublas_dsyr_
+#define CUBLAS_DSYR2            cublas_dsyr2_
+#define CUBLAS_DTBMV            cublas_dtbmv_
+#define CUBLAS_DTBSV            cublas_dtbsv_
+#define CUBLAS_DTPMV            cublas_dtpmv_
+#define CUBLAS_DTPSV            cublas_dtpsv_
+#define CUBLAS_DTRMV            cublas_dtrmv_
+#define CUBLAS_DTRSV            cublas_dtrsv_
+#define CUBLAS_DGEMM            cublas_dgemm_
+#define CUBLAS_DSYMM            cublas_dsymm_
+#define CUBLAS_DSYR2K           cublas_dsyr2k_
+#define CUBLAS_DSYRK            cublas_dsyrk_
+#define CUBLAS_ZSYRK            cublas_zsyrk_
+#define CUBLAS_DTRMM            cublas_dtrmm_
+#define CUBLAS_DTRSM            cublas_dtrsm_
+#define CUBLAS_ZGEMM            cublas_zgemm_
+#define CUBLAS_ZHEMM            cublas_zhemm_
+#define CUBLAS_ZSYMM            cublas_zsymm_
+#define CUBLAS_ZTRMM            cublas_ztrmm_
+#define CUBLAS_ZTRSM            cublas_ztrsm_
+#define CUBLAS_ZHERK            cublas_zherk_
+#define CUBLAS_ZSYRK            cublas_zsyrk_
+#define CUBLAS_ZHER2K           cublas_zher2k_
+#define CUBLAS_ZSYR2K           cublas_zsyr2k_
+
+#define  CUBLAS_CGEMV           cublas_cgemv_
+#define  CUBLAS_CGBMV           cublas_cgbmv_
+#define  CUBLAS_CHEMV           cublas_chemv_
+#define  CUBLAS_CHBMV           cublas_chbmv_
+#define  CUBLAS_CHPMV           cublas_chpmv_
+#define  CUBLAS_CTBMV           cublas_ctbmv_
+#define  CUBLAS_CTPMV           cublas_ctpmv_
+#define  CUBLAS_CTRSV           cublas_ctrsv_
+#define  CUBLAS_CTBSV           cublas_ctbsv_
+#define  CUBLAS_CTPSV           cublas_ctpsv_
+#define  CUBLAS_CGERC           cublas_cgerc_
+#define  CUBLAS_CGERU           cublas_cgeru_
+#define  CUBLAS_CHPR            cublas_chpr_
+#define  CUBLAS_CHPR2           cublas_chpr2_
+#define  CUBLAS_CHER            cublas_cher_
+#define  CUBLAS_CHER2           cublas_cher2_
+
+// stubs for zblat2
+#define CUBLAS_ZGBMV           cublas_zgbmv_
+#define CUBLAS_ZHEMV           cublas_zhemv_
+#define CUBLAS_ZHBMV           cublas_zhbmv_
+#define CUBLAS_ZHPMV           cublas_zhpmv_
+#define CUBLAS_ZTRMV           cublas_ztrmv_
+#define CUBLAS_ZTBMV           cublas_ztbmv_
+#define CUBLAS_ZTPMV           cublas_ztpmv_
+#define CUBLAS_ZTRSV           cublas_ztrsv_
+#define CUBLAS_ZTBSV           cublas_ztbsv_
+#define CUBLAS_ZTPSV           cublas_ztpsv_
+#define CUBLAS_ZGERC           cublas_zgerc_
+#define CUBLAS_ZGERU           cublas_zgeru_
+#define CUBLAS_ZHER            cublas_zher_
+#define CUBLAS_ZHPR            cublas_zhpr_
+#define CUBLAS_ZHER2           cublas_zher2_
+#define CUBLAS_ZHPR2           cublas_zhpr2_
+
+#elif CUBLAS_FORTRAN_COMPILER==CUBLAS_INTEL_FORTRAN
+
+#define CUBLAS_INIT             CUBLAS_INIT 
+#define CUBLAS_SHUTDOWN         CUBLAS_SHUTDOWN
+#define CUBLAS_ALLOC            CUBLAS_ALLOC
+#define CUBLAS_FREE             CUBLAS_FREE
+#define CUBLAS_SET_VECTOR       CUBLAS_SET_VECTOR
+#define CUBLAS_GET_VECTOR       CUBLAS_GET_VECTOR
+#define CUBLAS_SET_MATRIX       CUBLAS_SET_MATRIX
+#define CUBLAS_GET_MATRIX       CUBLAS_GET_MATRIX
+#define CUBLAS_GET_ERROR        CUBLAS_GET_ERROR
+#define CUBLAS_XERBLA           CUBLAS_XERBLA
+#define CUBLAS_ISAMAX           CUBLAS_ISAMAX
+#define CUBLAS_ISAMIN           CUBLAS_ISAMIN
+#define CUBLAS_SASUM            CUBLAS_SASUM
+#define CUBLAS_SAXPY            CUBLAS_SAXPY
+#define CUBLAS_SCOPY            CUBLAS_SCOPY
+#define CUBLAS_SDOT             CUBLAS_SDOT
+#define CUBLAS_SNRM2            CUBLAS_SNRM2
+#define CUBLAS_SROT             CUBLAS_SROT
+#define CUBLAS_SROTG            CUBLAS_SROTG
+#define CUBLAS_SROTM            CUBLAS_SROTM
+#define CUBLAS_SROTMG           CUBLAS_SROTMG
+#define CUBLAS_SSCAL            CUBLAS_SSCAL
+#define CUBLAS_SSWAP            CUBLAS_SSWAP
+#define CUBLAS_CAXPY            CUBLAS_CAXPY
+#define CUBLAS_CCOPY            CUBLAS_CCOPY
+#define CUBLAS_ZCOPY            CUBLAS_ZCOPY
+#define CUBLAS_CROT             CUBLAS_CROT
+#define CUBLAS_CROTG            CUBLAS_CROTG
+#define CUBLAS_CSCAL            CUBLAS_CSCAL
+#define CUBLAS_CSROT            CUBLAS_CSROT
+#define CUBLAS_CSSCAL           CUBLAS_CSSCAL
+#define CUBLAS_CSWAP            CUBLAS_CSWAP 
+#define CUBLAS_ZSWAP            CUBLAS_ZSWAP 
+#define CUBLAS_CTRMV            CUBLAS_CTRMV 
+#define CUBLAS_CDOTU            CUBLAS_CDOTU
+#define CUBLAS_CDOTC            CUBLAS_CDOTC
+#define CUBLAS_ICAMAX           CUBLAS_ICAMAX
+#define CUBLAS_SCASUM           CUBLAS_SCASUM
+#define CUBLAS_SCNRM2           CUBLAS_SCNRM2
+#define CUBLAS_SGBMV            CUBLAS_SGBMV
+#define CUBLAS_SGEMV            CUBLAS_SGEMV
+#define CUBLAS_SGER             CUBLAS_SGER
+#define CUBLAS_SSBMV            CUBLAS_SSBMV
+#define CUBLAS_SSPMV            CUBLAS_SSPMV
+#define CUBLAS_SSPR             CUBLAS_SSPR
+#define CUBLAS_SSPR2            CUBLAS_SSPR2
+#define CUBLAS_SSYMV            CUBLAS_SSYMV
+#define CUBLAS_SSYR             CUBLAS_SSYR
+#define CUBLAS_SSYR2            CUBLAS_SSYR2
+#define CUBLAS_STBMV            CUBLAS_STBMV
+#define CUBLAS_STBSV            CUBLAS_STBSV
+#define CUBLAS_STPMV            CUBLAS_STPMV
+#define CUBLAS_STPSV            CUBLAS_STPSV
+#define CUBLAS_STRMV            CUBLAS_STRMV
+#define CUBLAS_STRSV            CUBLAS_STRSV
+#define CUBLAS_SGEMM            CUBLAS_SGEMM
+#define CUBLAS_SSYMM            CUBLAS_SSYMM
+#define CUBLAS_SSYR2K           CUBLAS_SSYR2K
+#define CUBLAS_SSYRK            CUBLAS_SSYRK
+#define CUBLAS_STRMM            CUBLAS_STRMM
+#define CUBLAS_STRSM            CUBLAS_STRSM
+#define CUBLAS_CGEMM            CUBLAS_CGEMM
+#define CUBLAS_CHEMM            CUBLAS_CHEMM
+#define CUBLAS_CSYMM            CUBLAS_CSYMM
+#define CUBLAS_CTRMM            CUBLAS_CTRMM
+#define CUBLAS_CTRSM            CUBLAS_CTRSM
+#define CUBLAS_CHERK            CUBLAS_CHERK
+#define CUBLAS_CSYRK            CUBLAS_CSYRK
+#define CUBLAS_CHER2K           CUBLAS_CHER2K
+#define CUBLAS_CSYR2K           CUBLAS_CSYR2K
+#define CUBLAS_IDAMAX           CUBLAS_IDAMAX
+#define CUBLAS_IDAMIN           CUBLAS_IDAMIN
+#define CUBLAS_DASUM            CUBLAS_DASUM
+#define CUBLAS_DAXPY            CUBLAS_DAXPY
+#define CUBLAS_DCOPY            CUBLAS_DCOPY
+#define CUBLAS_DDOT             CUBLAS_DDOT
+#define CUBLAS_DNRM2            CUBLAS_DNRM2
+#define CUBLAS_DROT             CUBLAS_DROT
+#define CUBLAS_DROTG            CUBLAS_DROTG
+#define CUBLAS_DROTM            CUBLAS_DROTM
+#define CUBLAS_DROTMG           CUBLAS_DROTMG
+#define CUBLAS_DSCAL            CUBLAS_DSCAL
+#define CUBLAS_DSWAP            CUBLAS_DSWAP
+#define CUBLAS_ZAXPY            CUBLAS_ZAXPY
+#define CUBLAS_ZCOPY            CUBLAS_ZCOPY
+#define CUBLAS_ZROT             CUBLAS_ZROT
+#define CUBLAS_ZROTG            CUBLAS_ZROTG
+#define CUBLAS_ZSCAL            CUBLAS_ZSCAL
+#define CUBLAS_ZDROT            CUBLAS_ZDROT
+#define CUBLAS_ZDSCAL           CUBLAS_ZDSCAL
+#define CUBLAS_ZSWAP            CUBLAS_ZSWAP 
+#define CUBLAS_ZDOTU            CUBLAS_ZDOTU
+#define CUBLAS_ZDOTC            CUBLAS_ZDOTC
+#define CUBLAS_IZAMAX           CUBLAS_IZAMAX
+#define CUBLAS_DZASUM           CUBLAS_DZASUM
+#define CUBLAS_DZNRM2           CUBLAS_DZNRM2
+#define CUBLAS_DGBMV            CUBLAS_DGBMV
+#define CUBLAS_DGEMV            CUBLAS_DGEMV
+#define CUBLAS_ZGEMV            CUBLAS_ZGEMV
+#define CUBLAS_DGER             CUBLAS_DGER
+#define CUBLAS_DSBMV            CUBLAS_DSBMV
+#define CUBLAS_DSPMV            CUBLAS_DSPMV
+#define CUBLAS_DSPR             CUBLAS_DSPR
+#define CUBLAS_DSPR2            CUBLAS_DSPR2
+#define CUBLAS_DSYMV            CUBLAS_DSYMV
+#define CUBLAS_DSYR             CUBLAS_DSYR
+#define CUBLAS_DSYR2            CUBLAS_DSYR2
+#define CUBLAS_DTBMV            CUBLAS_DTBMV
+#define CUBLAS_DTBSV            CUBLAS_DTBSV
+#define CUBLAS_DTPMV            CUBLAS_DTPMV
+#define CUBLAS_DTPSV            CUBLAS_DTPSV
+#define CUBLAS_DTRMV            CUBLAS_DTRMV
+#define CUBLAS_DTRSV            CUBLAS_DTRSV
+#define CUBLAS_DGEMM            CUBLAS_DGEMM
+#define CUBLAS_DSYMM            CUBLAS_DSYMM
+#define CUBLAS_DSYR2K           CUBLAS_DSYR2K
+#define CUBLAS_ZSYRK            CUBLAS_ZSYRK
+#define CUBLAS_DTRMM            CUBLAS_DTRMM
+#define CUBLAS_DTRSM            CUBLAS_DTRSM
+#define CUBLAS_ZGEMM            CUBLAS_ZGEMM
+#define CUBLAS_ZHEMM            CUBLAS_ZHEMM
+#define CUBLAS_ZSYMM            CUBLAS_ZSYMM
+#define CUBLAS_ZTRMM            CUBLAS_ZTRMM
+#define CUBLAS_ZTRSM            CUBLAS_ZTRSM
+#define CUBLAS_ZHERK            CUBLAS_ZHERK
+#define CUBLAS_ZSYRK            CUBLAS_ZSYRK
+#define CUBLAS_ZHER2K           CUBLAS_ZHER2K
+#define CUBLAS_ZSYR2K           CUBLAS_ZSYR2K
+
+#define  CUBLAS_CGEMV           CUBLAS_CGEMV
+#define  CUBLAS_CGBMV           CUBLAS_CGBMV
+#define  CUBLAS_CHEMV           CUBLAS_CHEMV
+#define  CUBLAS_CHBMV           CUBLAS_CHBMV
+#define  CUBLAS_CHPMV           CUBLAS_CHPMV
+#define  CUBLAS_CTBMV           CUBLAS_CTBMV
+#define  CUBLAS_CTPMV           CUBLAS_CTPMV
+#define  CUBLAS_CTRSV           CUBLAS_CTRSV
+#define  CUBLAS_CTBSV           CUBLAS_CTBSV
+#define  CUBLAS_CTPSV           CUBLAS_CTPSV
+#define  CUBLAS_CGERC           CUBLAS_CGERC
+#define  CUBLAS_CGERU           CUBLAS_CGERU
+#define  CUBLAS_CHPR            CUBLAS_CHPR
+
+
+// stubs for zblat2
+#define CUBLAS_ZGBMV           CUBLAS_ZGBMV
+#define CUBLAS_ZHEMV           CUBLAS_ZHEMV
+#define CUBLAS_ZHBMV           CUBLAS_ZHBMV
+#define CUBLAS_ZHPMV           CUBLAS_ZHPMV
+#define CUBLAS_ZTRMV           CUBLAS_ZTRMV
+#define CUBLAS_ZTBMV           CUBLAS_ZTBMV
+#define CUBLAS_ZTPMV           CUBLAS_ZTPMV
+#define CUBLAS_ZTRSV           CUBLAS_ZTRSV
+#define CUBLAS_ZTBSV           CUBLAS_ZTBSV
+#define CUBLAS_ZTPSV           CUBLAS_ZTPSV
+#define CUBLAS_ZGERC           CUBLAS_ZGERC
+#define CUBLAS_ZGERU           CUBLAS_ZGERU
+#define CUBLAS_ZHER            CUBLAS_ZHER
+#define CUBLAS_ZHPR            CUBLAS_ZHPR
+#define CUBLAS_ZHER2           CUBLAS_ZHER2
+#define CUBLAS_ZHPR2           CUBLAS_ZHPR2
+
+#else
+#error unsupported Fortran compiler
+#endif
Index: BLAS/xTRSV/patch_thunking.h
===================================================================
--- BLAS/xTRSV/patch_thunking.h	(revision 0)
+++ BLAS/xTRSV/patch_thunking.h	(revision 1)
@@ -0,0 +1,4 @@
+41c41
+< #define CUBLAS_FORTRAN_COMPILER CUBLAS_G95
+---
+> #define CUBLAS_FORTRAN_COMPILER CUBLAS_INTEL_FORTRAN
Index: BLAS/xTRSV/Makefile
===================================================================
--- BLAS/xTRSV/Makefile	(revision 0)
+++ BLAS/xTRSV/Makefile	(revision 1)
@@ -0,0 +1,107 @@
+SOURCE=xTRSV.c
+
+CC=gcc
+CFLAGS=-Wall -O3
+LDFLAGS=-lm
+CUDADIR=/opt/cuda
+CUDASRC=$(CUDADIR)/src
+THUNKING=fortran_thunking.c
+CUDASRCINC=fortran_common.h
+CUDAINC=$(CUDADIR)/include
+CUDALIB=$(CUDADIR)/lib64
+
+PATCHTHUNKING=patch_thunking.h
+
+GSLINC=/usr/include/gsl
+
+GOTO2=/opt/GotoBLAS2
+
+ACML=/opt/acml
+ACMLINC=$(ACML)/gfortran64_mp/include
+ACMLLIB=$(ACML)/gfortran64_mp/lib
+
+EXECUTABLE=cblas fblas gsl cublas thunking gotoblas acml
+
+#FORMAT=DOUBLE
+FORMAT=FLOAT
+
+#DIRECTIVES=-D$(FORMAT) -DPRINT -DUNIT
+#DIRECTIVES=-D$(FORMAT) -DUNIT -DRESULTS -DQUIET
+DIRECTIVES=-DQUIET -DUNIT
+
+all: $(EXECUTABLE)
+
+cblas: $(SOURCE)
+
+	$(CC) $(CFLAGS) $(DIRECTIVES) -DFLOAT -DCBLAS $(LDFLAGS) \
+		$(SOURCE) -lcblas -o $(SOURCE:.c=)_SP_$@
+
+	$(CC) $(CFLAGS) $(DIRECTIVES) -DDOUBLE -DCBLAS $(LDFLAGS) \
+		$(SOURCE) -lcblas -o $(SOURCE:.c=)_DP_$@
+
+gotoblas: $(SOURCE)
+
+	$(CC) $(CFLAGS) $(DIRECTIVES) -DFLOAT -DCBLAS $(LDFLAGS) \
+		$(SOURCE) $(GOTO2)/libgoto2.a -lpthread -o $(SOURCE:.c=)_SP_$@
+
+	$(CC) $(CFLAGS) $(DIRECTIVES) -DDOUBLE -DCBLAS $(LDFLAGS) \
+		$(SOURCE) $(GOTO2)/libgoto2.a -lpthread -o $(SOURCE:.c=)_DP_$@
+
+acml: $(SOURCE)
+
+	$(CC) -I$(ACMLINC) $(CFLAGS) $(DIRECTIVES) -DFLOAT -DACML $(LDFLAGS) \
+		$(SOURCE) -L$(ACMLLIB) -lacml_mp -lacml_mv \
+		-lgomp -lgfortran -lpthread -o $(SOURCE:.c=)_SP_$@
+
+	$(CC) -I$(ACMLINC) $(CFLAGS) $(DIRECTIVES) -DDOUBLE -DACML $(LDFLAGS) \
+		$(SOURCE) -L$(ACMLLIB) -lacml_mp -lacml_mv \
+		-lgomp -lgfortran -lpthread -o $(SOURCE:.c=)_DP_$@
+
+fblas: $(SOURCE)
+
+	$(CC) $(CFLAGS) $(DIRECTIVES) -DFLOAT -DFBLAS $(LDFLAGS) \
+		$(SOURCE) -lf77blas -o $(SOURCE:.c=)_SP_$@
+
+	$(CC) $(CFLAGS) $(DIRECTIVES) -DDOUBLE -DFBLAS $(LDFLAGS) \
+		$(SOURCE) -lf77blas -o $(SOURCE:.c=)_DP_$@
+
+
+gsl: $(SOURCE)
+
+	$(CC) -I$(GSLINC) $(CFLAGS) $(DIRECTIVES) -DFLOAT -DGSL $(LDFLAGS) \
+		$(SOURCE) -lgslcblas -o $(SOURCE:.c=)_SP_$@
+
+	$(CC) -I$(GSLINC) $(CFLAGS) $(DIRECTIVES) -DDOUBLE -DGSL $(LDFLAGS) \
+		$(SOURCE) -lgslcblas -o $(SOURCE:.c=)_DP_$@
+
+
+cublas: $(SOURCE)
+
+	$(CC) -I$(CUDAINC) -L$(CUDALIB) $(CFLAGS) -DCUBLAS -DFLOAT $(LDFLAGS) \
+		$(DIRECTIVES) $(SOURCE) -lcublas -o $(SOURCE:.c=)_SP_$@
+
+	$(CC) -I$(CUDAINC) -L$(CUDALIB) $(CFLAGS) -DCUBLAS -DDOUBLE $(LDFLAGS) \
+		$(DIRECTIVES) $(SOURCE) -lcublas -o $(SOURCE:.c=)_DP_$@
+
+thunking: $(SOURCE)
+
+# Copy of source for thunking CUBLAS approach
+	cp $(CUDASRC)/$(THUNKING) $(CUDASRC)/$(THUNKING:.c=.h) \
+		$(CUDASRC)/$(CUDASRCINC) .
+# Patch Thunking prototypes to compile on Debian Lenny
+	patch $(CUDASRCINC) $(PATCHTHUNKING)
+	$(CC) -I$(CUDAINC) $(CFLAGS) -c $(THUNKING)
+
+	$(CC) -I$(CUDAINC) -L$(CUDALIB) $(CFLAGS) -DTHUNKING \
+		$(LDFLAGS) $(DIRECTIVES) $(SOURCE) -DFLOAT \
+		$(THUNKING:.c=.o) -lcublas -o $(SOURCE:.c=)_SP_$@
+
+	$(CC) -I$(CUDAINC) -L$(CUDALIB) $(CFLAGS) -DTHUNKING \
+		$(LDFLAGS) $(DIRECTIVES) $(SOURCE) -DDOUBLE \
+		$(THUNKING:.c=.o) -lcublas -o $(SOURCE:.c=)_DP_$@
+
+clean: $(SOURCE)
+	find . -name "$(SOURCE:.c=)_*" -exec rm {} \;
+	find . -name "$(THUNKING:.c=)*" -exec rm {} \;
+	find . -name "*~" -exec rm {} \;
+	find . -name "$(CUDASRCINC)" -exec rm {} \;
Index: BLAS/xTRSV/nohup.out
===================================================================
Index: BLAS/xTRSV/xTRSV.c
===================================================================
--- BLAS/xTRSV/xTRSV.c	(revision 0)
+++ BLAS/xTRSV/xTRSV.c	(revision 1)
@@ -0,0 +1,816 @@
+/* 
+   Performs a linear system solving of random generated system
+   Estimates a test
+
+   Matrix is triangular
+   
+   Thanks for help from aurel32@debian.org
+*/
+
+#include <stdio.h>
+#include <math.h>
+#include <stdlib.h>
+#include <sys/time.h>
+#include <string.h>
+
+#ifdef CUBLAS
+#include <cublas.h>
+#define CUBLAS_WRAPPER_ERROR_NOERR      0
+#define CUBLAS_WRAPPER_ERROR_ALLOC      1
+#define CUBLAS_WRAPPER_ERROR_SET        2
+#define CUBLAS_WRAPPER_ERROR_GET        3
+#define CUBLAS_WRAPPER_ERROR_STUB       4
+#elif THUNKING
+#include <cublas.h>
+#elif FBLAS
+#include <cblas_f77.h>
+#elif GSL
+#include <gsl_cblas.h>
+#elif ACML
+#include <acml.h>
+#include <acml_mv.h>
+#else
+#include <cblas.h>
+#endif
+
+#ifdef DOUBLE
+#define LENGTH double
+#else
+#define LENGTH float
+#endif
+
+#ifdef THUNKING
+/* WARNING !
+Prototypes from fortran.c functions used MUST be defined here !
+*/
+#include "fortran_thunking.h"
+
+/*
+#ifdef DOUBLE
+
+void CUBLAS_DCOPY (const int *n, const double *x, const int *incx, double *y,
+                   const int *incy);
+
+double CUBLAS_DNRM2 (const int *dim, const double *X, const int *incx);
+
+void CUBLAS_DTRSV (const char *uplo, const char *trans, const char *diag,
+                   const int *n, const double *A, const int *lda, double *x,
+                   const int *incx);
+
+void CUBLAS_DGEMV (const char *trans, const int *m, const int *n,
+                   const double *alpha, const double *A, const int *lda,
+                   const double *x, const int *incx, const double *beta,
+                   double *y, const int *incy);
+
+void CUBLAS_DSWAP (const int *n, double *x, const int *incx, double *y,
+                   const int *incy);
+
+void CUBLAS_DAXPY (const int *n, const double *alpha, const double *x, 
+                   const int *incx, double *y, const int *incy);
+
+#else
+void CUBLAS_SCOPY (const int *n, const float *x, const int *incx, float *y,
+                   const int *incy);
+
+float CUBLAS_SNRM2 (const int *dim, const float *X, const int *incx);
+
+void CUBLAS_STRSV (const char *uplo, const char *trans, const char *diag,
+                   const int *n, const float *A, const int *lda, float *x,
+                   const int *incx);
+
+void CUBLAS_SGEMV (const char *trans, const int *m, const int *n,
+                   const float *alpha, const float *A, const int *lda,
+                   const float *x, const int *incx, const float *beta,
+                   float *y, const int *incy);
+
+void CUBLAS_SSWAP (const int *n, float *x, const int *incx, float *y,
+                   const int *incy);
+
+void CUBLAS_SAXPY (const int *n, const float *alpha, const float *x, 
+                   const int *incx, float *y, const int *incy);
+
+#endif
+*/
+
+#elif FBLAS
+
+#ifdef DOUBLE
+
+void dtrsv_( FCHAR, FCHAR, FCHAR, FINT, const double *, FINT, double *, FINT);
+
+void dgemv_(FCHAR, FINT, FINT, const double *, const double *, FINT, 
+	       const double *, FINT, const double *, double *, FINT);
+
+void dswap_( FINT, double *, FINT, double *, FINT);
+
+void daxpy_( FINT, const double *, const double *, FINT, double *, FINT);
+
+void dnrm2_( FINT, const double *, FINT, double *);
+
+#else
+
+void strsv_( FCHAR, FCHAR, FCHAR, FINT, const float *, FINT, float *, FINT);
+
+void sgemv_(FCHAR, FINT, FINT, const float *, const float *, FINT, 
+	       const float *, FINT, const float *, float *, FINT);
+
+void sswap_( FINT, float *, FINT, float *, FINT);
+
+void saxpy_( FINT, const float *, const float *, FINT, float *, FINT);
+
+void snrm2_( FINT, const float *, FINT, float *);
+
+#endif
+
+#endif
+
+/* Matrix with only defined triangular terms */
+/* Even if there are 0 in matrix, must be defined at all ! */
+
+/* Get from fortran.c */
+
+#ifdef CUBLAS
+static char *errMsg[5] = 
+{
+    "no error",
+    "allocation error",
+    "setVector/setMatrix error",
+    "getVector/getMatrix error",
+    "not implemented"
+};
+
+static void wrapperError (const char *funcName, int error)
+{
+    printf ("cublas%s wrapper: %s\n", funcName, errMsg[error]);
+    fflush (stdout);
+}
+#endif
+
+int printVector(const int dimVector,const LENGTH *dataVector,
+		char *nameVector,char *mesgVector)
+{
+#ifndef QUIET
+
+  int i;
+  printf("\n%s of %s, size %i:\n",mesgVector,nameVector,dimVector);
+  for (i=0;i<dimVector;i++)
+    {
+      printf("%s[%i]=%2.10e\n",nameVector,i,dataVector[i]);
+    }
+#endif
+
+  return 0;
+}
+  
+int printResults(const int dimVector,const LENGTH *dataVector,
+		 char *nameVector,char *mesgVector)
+{
+#ifdef RESULTS
+  int i;
+
+  printf("\n%s of %s, size %i:\n",mesgVector,nameVector,dimVector);
+  for (i=0;i<dimVector;i++)
+    {
+      printf("%s[%i]=%2.10e\n",nameVector,i,dataVector[i]);
+    }
+#endif
+  return 0;
+}
+  
+#ifdef CUBLAS
+int printVectorGPU(const int dimVector,const LENGTH *dataVector,
+		   char *nameVector,char *mesgVector)
+{
+#ifndef QUIET
+  int i;
+  cublasStatus stat;
+  LENGTH *P=0;
+  int incx=1;
+
+  P=malloc(dimVector*sizeof(LENGTH));
+  
+  stat=cublasGetVector(dimVector,sizeof(P[0]),dataVector,incx,P,incx);
+
+  if (stat != CUBLAS_STATUS_SUCCESS) {
+    wrapperError ("ToGet", CUBLAS_WRAPPER_ERROR_GET);
+  }  
+
+  printf("\n%s of %s, size %i:\n",mesgVector,nameVector,dimVector);
+  for (i=0;i<dimVector;i++)
+    {
+      printf("%s[%i]=%2.10e\n",nameVector,i,P[i]);
+    }
+
+  free(P);  
+#endif
+
+  return 0;
+}
+#endif
+
+int bench(int dim,int RUNS)
+{
+  /*
+  int dim=1000;
+  int RUNS=100;
+  */
+  int incx=1;
+#ifdef PRINT
+  LENGTH factor=1.;
+#endif
+
+  LENGTH alpha=1.,beta=0.,beta2=-1.;
+  LENGTH *A,*X,*Y;
+
+  /* checkBefore checkAfter checks */
+  LENGTH *checksA,*checksB;
+
+  int i=0, j=0;
+
+  double duration;
+
+  struct timeval tv1,tv2;
+  struct timezone tz;
+
+  /* Create 1 Matrix and 2 Vectors of dimension dim  */
+
+  A=malloc(dim*dim*sizeof(LENGTH));
+  X=malloc(dim*sizeof(LENGTH));
+  Y=malloc(dim*sizeof(LENGTH));
+
+  /* Create 2 vectors for checker Before and After */
+
+  checksA=malloc(RUNS*sizeof(double));
+  checksB=malloc(RUNS*sizeof(double));
+
+  /* Initialize elements with random numbers */
+  /* Initialize the seed for rand() */
+  /* srand(time()); */
+
+#ifdef UNIT
+  /* Fill the matrix and vector with random numbers */
+  for (i=0; i<dim; i++) {
+    for (j=0; j<dim; j++) 
+      if (j>=i)
+	{
+	  /* Normalization is necessary to avoid problems */
+	  A[i*dim+j]=1.;
+	}
+      else
+	{
+	   A[i*dim+j]=0.;
+	}
+    X[i]=1;
+  }
+#else
+  for (i=0; i<dim; i++) {
+    for (j=0; j<dim; j++) 
+      if (j>i)
+	{
+	  /* Normalization is necessary to avoid problems */
+	  A[i*dim+j]=(LENGTH)rand()/(RAND_MAX+1.)
+	    *(LENGTH)(i+1.)/(LENGTH)(j+1.);
+	}
+      else if (j==i)
+	{
+	   A[i*dim+j]=1.;
+	}
+      else
+	{
+	   A[i*dim+j]=0.;
+	}
+    X[i]=(LENGTH)rand()/(RAND_MAX+1.);
+  }
+#endif
+
+  /* Print the matrix */
+
+#ifdef QUIET
+#else
+  for (i=0; i<dim; i++) {
+    for (j=0; j<dim; j++) printf("A[%i,%i]=%1.5f ", i,j,A[i*dim+j]);
+    printf("\tX[%i]=%1.5f ", i,X[i]);
+    putchar('\n');
+  }
+  putchar('\n');
+#endif
+
+  /* Get first timer before launching */
+  gettimeofday(&tv1, &tz);
+
+  /* Compute with CuBLAS library  */
+#ifdef CUBLAS
+  LENGTH *devPtrA=0, *devPtrX=0, *devPtrY=0;
+  cublasStatus stat1, stat2, stat3;
+  struct timeval tv3,tv4;
+
+  /* Order is Row */
+  /* Have to swap uplo and trans */
+  char uplo='L',trans='T',diag='N';
+
+  printf("Using CuBLAS: %i iterations for %ix%i matrix\n",
+	 RUNS,dim,dim);
+
+  stat1=cublasAlloc(dim*dim,sizeof(devPtrA[0]),(void**)&devPtrA);
+  stat2=cublasAlloc(dim,sizeof(devPtrX[0]),(void**)&devPtrX);
+  stat3=cublasAlloc(dim,sizeof(devPtrY[0]),(void**)&devPtrY);
+
+  if ((stat1 != CUBLAS_STATUS_SUCCESS) || 
+      (stat2 != CUBLAS_STATUS_SUCCESS) ||
+      (stat3 != CUBLAS_STATUS_SUCCESS)) {
+    wrapperError ("Dtrsv", CUBLAS_WRAPPER_ERROR_ALLOC);
+    cublasFree (devPtrA);
+    cublasFree (devPtrX);
+    cublasFree (devPtrY);
+    return 1;
+  }
+
+  stat1=cublasSetMatrix(dim,dim,sizeof(A[0]),A,dim,devPtrA,dim);
+  stat2=cublasSetVector(dim,sizeof(X[0]),X,incx,devPtrX,incx);
+  stat3=cublasSetVector(dim,sizeof(Y[0]),Y,incx,devPtrY,incx);
+  
+  if ((stat1 != CUBLAS_STATUS_SUCCESS) ||
+      (stat2 != CUBLAS_STATUS_SUCCESS) ||
+      (stat3 != CUBLAS_STATUS_SUCCESS)) {
+    wrapperError ("Dtrsv", CUBLAS_WRAPPER_ERROR_SET);
+    cublasFree (devPtrA);
+    cublasFree (devPtrX);
+    cublasFree (devPtrY);
+    return 1;
+  }
+
+  /* Get third timer after memory operation */
+  gettimeofday(&tv3, &tz);
+
+  for (i=0;i<RUNS;i++)
+    {
+#ifdef DOUBLE
+
+      printVectorGPU(dim,devPtrX,"X","Roots");
+
+      /* Multiply Y <- A.X */
+      cublasDgemv(trans,dim,dim,alpha,devPtrA,dim,
+		  devPtrX,incx,beta,devPtrY,incx);
+
+      printVectorGPU(dim,devPtrY,"Y","Results");
+
+      /* Solve linear system A.X=Y : Y <- A-1.Y */
+      cublasDtrsv(uplo,trans,diag,dim,devPtrA,dim,devPtrY,incx);
+
+      printVectorGPU(dim,devPtrY,"Y","Solutions");
+
+      /* Estimate the difference between X and Y : Y <- -Y+X */
+      cublasDaxpy(dim,beta2,devPtrY,incx,devPtrX,incx);
+
+      printVectorGPU(dim,devPtrX,"X","Errors");
+
+      /* Estimate the second checker */
+/*       checksA[i]=(double)cublasDnrm2(dim,devPtrX,incx); */
+
+      /* Swap vector X and Y */
+      cublasDswap(dim,devPtrX,incx,devPtrY,incx);
+
+#else
+
+      printVectorGPU(dim,devPtrX,"X","Roots");
+
+      /* Multiply Y <- A.X */
+      cublasSgemv(trans,dim,dim,alpha,devPtrA,dim,
+		  devPtrX,incx,beta,devPtrY,incx);
+
+      printVectorGPU(dim,devPtrY,"Y","Results");
+
+      /* Solve linear system Y <- A-1.Y */
+      cublasStrsv(uplo,trans,diag,dim,devPtrA,dim,devPtrY,incx);
+
+      printVectorGPU(dim,devPtrY,"Y","Solutions");
+
+      /* Add vectors X and -Y */
+      cublasSaxpy(dim,beta2,devPtrY,incx,devPtrX,incx);
+
+      printVectorGPU(dim,devPtrX,"X","Errors");
+
+      /* Estimate the second checker */
+/*       checksA[i]=(double)cublasSnrm2(dim,devPtrX,incx); */
+
+      /* Swap vector X and Y */
+      cublasSswap(dim,devPtrX,incx,devPtrY,incx);
+
+#endif
+  
+    }
+
+  stat1=cublasGetMatrix(dim,dim,sizeof(A[0]),devPtrA,dim,A,dim);
+  stat2=cublasGetVector(dim,sizeof(X[0]),devPtrX,incx,X,incx);
+  stat3=cublasGetVector(dim,sizeof(Y[0]),devPtrY,incx,Y,incx);
+  
+  cublasFree (devPtrA);
+  cublasFree (devPtrX);
+  cublasFree (devPtrY);
+  
+  if ((stat1 != CUBLAS_STATUS_SUCCESS) ||
+      (stat2 != CUBLAS_STATUS_SUCCESS) ||
+      (stat3 != CUBLAS_STATUS_SUCCESS)) {
+    wrapperError ("LinearSystem", CUBLAS_WRAPPER_ERROR_GET);
+  }
+  
+  /* Get fourth timer after memory free */
+  gettimeofday(&tv4, &tz);
+
+#elif THUNKING
+  
+  /* Order is Row : Have to swap uplo='U' and trans='N' */
+  char uplo='L',trans='T',diag='N';
+  printf("Using CuBLAS/Thunking: %i iterations for %ix%i matrix\n",
+	 RUNS,dim,dim);
+
+  for (i=0;i<RUNS;i++)
+    {
+#ifdef DOUBLE
+      
+      printVector(dim,X,"X","Roots");
+      
+      /* Multiply A by X as Y <- A.X */
+      CUBLAS_DGEMV(&trans,&dim,&dim,&alpha,A,&dim,X,&incx,&beta,Y,&incx);
+      
+      printVector(dim,Y,"Y","Results");
+
+      /* Solve linear system */
+      CUBLAS_DTRSV(&uplo,&trans,&diag,&dim,A,&dim,Y,&incx);
+      
+      printVector(dim,Y,"Y","Solutions");
+
+      /* Compare the roots X and Y */
+      CUBLAS_DAXPY(&dim,&beta2,Y,&incx,X,&incx);
+
+      printVector(dim,X,"X","Errors");
+
+      /* Store the checker of errors */
+/*       checksA[i]=(double)CUBLAS_DNRM2(&dim,X,&incx); */
+
+      /* Swap vector X and Y */
+      CUBLAS_DSWAP(&dim,X,&incx,Y,&incx);
+#else
+
+      printVector(dim,X,"X","Roots");
+      
+      /* Multiply A by X as Y <- A.X */
+      CUBLAS_SGEMV(&trans,&dim,&dim,&alpha,A,&dim,X,&incx,&beta,Y,&incx);
+      
+      printVector(dim,Y,"Y","Results");
+
+      /* Solve linear system */
+      CUBLAS_STRSV(&uplo,&trans,&diag,&dim,A,&dim,Y,&incx);
+      
+      printVector(dim,Y,"Y","Solutions");
+
+      /* Compare the roots X and Y */
+      CUBLAS_SAXPY(&dim,&beta2,Y,&incx,X,&incx);
+
+      printVector(dim,X,"X","Errors");
+
+      /* Store the checker of errors */
+/*       checksA[i]=(double)CUBLAS_SNRM2(&dim,X,&incx); */
+
+      /* Swap vector X and Y */
+      CUBLAS_SSWAP(&dim,X,&incx,Y,&incx);
+#endif
+
+#ifdef PRINT
+      printf("Iteration %i, checker is %2.5f and error is %2.10f\n",
+	     i,checksA[i],fabs(checksB[i]-checksA[i])/factor);
+#endif
+    }
+
+#elif FBLAS
+  
+  /* Order is Row : Have to swap uplo='U' and trans='N' */
+  char uplo='L',trans='T',diag='N';
+  
+  printf("Using FBLAS: %i iterations for %ix%i matrix\n",
+	 RUNS,dim,dim);
+  
+  for (i=0;i<RUNS;i++)
+    {
+#ifdef DOUBLE
+      
+      printVector(dim,X,"X","Roots");
+      
+      /* Multiply A by X as Y <- A.X */
+      dgemv_(&trans,&dim,&dim,&alpha,A,&dim,X,&incx,&beta,Y,&incx);
+      
+      printVector(dim,Y,"Y","Results");
+      
+      /* Solve linear system */
+      dtrsv_(&uplo,&trans,&diag,&dim,A,&dim,Y,&incx);
+      
+      printVector(dim,Y,"Y","Solutions");
+      
+      /* Compare the roots X and Y */
+      daxpy_(&dim,&beta2,Y,&incx,X,&incx);
+      
+      printVector(dim,X,"X","Errors");
+      
+      /* Store the checker of errors */
+/*       dnrm2_(&dim,X,&incx,&checksA[i]); */
+            
+      /* Swap vector X and Y */
+      dswap_(&dim,X,&incx,Y,&incx);
+
+#else
+
+      printVector(dim,X,"X","Roots");
+      
+      /* Multiply A by X as Y <- A.X */
+      sgemv_(&trans,&dim,&dim,&alpha,A,&dim,X,&incx,&beta,Y,&incx);
+      
+      printVector(dim,Y,"Y","Results");
+
+      /* Solve linear system */
+      strsv_(&uplo,&trans,&diag,&dim,A,&dim,Y,&incx);
+      
+      printVector(dim,Y,"Y","Solutions");
+
+      /* Compare the roots X and Y */
+      saxpy_(&dim,&beta2,Y,&incx,X,&incx);
+
+      printVector(dim,X,"X","Errors");
+
+      /* Store the checker of errors */
+/*       snrm2_(&dim,X,&incx,&checksA[i]); */
+
+      /* Swap vector X and Y */
+      sswap_(&dim,X,&incx,Y,&incx);
+#endif
+
+    }
+
+#elif ACML
+  
+  /* Order is Row : Have to swap uplo='U' and trans='N' */
+  char uplo='L',trans='T',diag='N';
+  
+  printf("Using ACML: %i iterations for %ix%i matrix\n",
+	 RUNS,dim,dim);
+  
+  for (i=0;i<RUNS;i++)
+    {
+#ifdef DOUBLE
+      
+      printVector(dim,X,"X","Roots");
+      
+      /* Multiply A by X as Y <- A.X */
+      dgemv(trans,dim,dim,alpha,A,dim,X,incx,beta,Y,incx);
+      
+      printVector(dim,Y,"Y","Results");
+      
+      /* Solve linear system */
+      dtrsv(uplo,trans,diag,dim,A,dim,Y,incx);
+      
+      printVector(dim,Y,"Y","Solutions");
+      
+      /* Compare the roots X and Y */
+      daxpy(dim,beta2,Y,incx,X,incx);
+      
+      printVector(dim,X,"X","Errors");
+      
+      /* Store the checker of errors */
+/*       dnrm2_(&dim,X,&incx,&checksA[i]); */
+            
+      /* Swap vector X and Y */
+      dswap(dim,X,incx,Y,incx);
+
+#else
+
+      printVector(dim,X,"X","Roots");
+      
+      /* Multiply A by X as Y <- A.X */
+      sgemv(trans,dim,dim,alpha,A,dim,X,incx,beta,Y,incx);
+      
+      printVector(dim,Y,"Y","Results");
+
+      /* Solve linear system */
+      strsv(uplo,trans,diag,dim,A,dim,Y,incx);
+      
+      printVector(dim,Y,"Y","Solutions");
+
+      /* Compare the roots X and Y */
+      saxpy(dim,beta2,Y,incx,X,incx);
+
+      printVector(dim,X,"X","Errors");
+
+      /* Store the checker of errors */
+/*       snrm2_(&dim,X,&incx,&checksA[i]); */
+
+      /* Swap vector X and Y */
+      sswap(dim,X,incx,Y,incx);
+#endif
+
+    }
+
+#elif GSL
+
+  printf("Using GSL: %i iterations for %ix%i matrix\n",RUNS,dim,dim);
+
+  /* 
+     RowMajor : Matrix is read row by row
+     Upper : the no null elements are on top
+     NoTrans : no transposition before estimation
+     NonUnit : Matrix is not unit
+   */
+
+  for (i=0;i<RUNS;i++)
+    {  
+
+#ifdef DOUBLE
+
+      printVector(dim,X,"X","Roots");
+
+      /* Multiply A by X as Y <- A.X */
+      cblas_dgemv(CblasRowMajor,CblasNoTrans,
+		  dim,dim,alpha,A,dim,X,incx,beta,Y,incx);
+
+      printVector(dim,Y,"Y","Results");
+
+      /* Solve linear system : Y <- A-1.Y */
+      cblas_dtrsv(CblasRowMajor,CblasUpper,CblasNoTrans,CblasNonUnit,
+		  dim,A,dim,Y,incx);
+
+      printVector(dim,Y,"Y","Solutions");
+      
+      cblas_daxpy(dim,beta2,Y,incx,X,incx);
+
+      printVector(dim,X,"X","Errors");
+
+      /* Store the checker of errors */
+/*       checksA[i]=(double)cblas_dnrm2(dim,X,incx); */
+
+      cblas_dswap(dim,X,incx,Y,incx);
+      
+#else
+
+      printVector(dim,X,"X","Roots");
+
+      /* Multiply A by X as Y <- A.X */
+      cblas_sgemv(CblasRowMajor,CblasNoTrans,
+		  dim,dim,alpha,A,dim,X,incx,beta,Y,incx);
+
+      printVector(dim,Y,"Y","Results");
+
+      /* Solve linear system : Y <- A-1.Y */
+      cblas_strsv(CblasRowMajor,CblasUpper,CblasNoTrans,CblasNonUnit,
+		  dim,A,dim,Y,incx);
+
+      printVector(dim,Y,"Y","Solutions");
+      
+      cblas_saxpy(dim,beta2,Y,incx,X,incx);
+
+      printVector(dim,X,"X","Errors");
+
+      /* Store the checker of errors */
+/*       checksA[i]=(double)cblas_snrm2(dim,X,incx); */
+
+      cblas_sswap(dim,X,incx,Y,incx);
+      
+#endif
+      
+    }
+#else
+
+  printf("Using CBLAS: %i iterations for %ix%i matrix\n",RUNS,dim,dim);
+
+  /* 
+     RowMajor : Matrix is read row bu row
+     Upper : the no null elements are on top
+     NoTrans : no transposition before estimation
+     NonUnit : Matrix is not unit
+   */
+
+  for (i=0;i<RUNS;i++)
+    {  
+
+#ifdef DOUBLE
+
+      printVector(dim,X,"X","Roots");
+
+      /* Multiply A by X as Y <- A.X */
+      cblas_dgemv(CblasRowMajor,CblasNoTrans,
+		  dim,dim,alpha,A,dim,X,incx,beta,Y,incx);
+
+      printVector(dim,Y,"Y","Results");
+
+      /* Solve linear system : Y <- A-1.Y */
+      cblas_dtrsv(CblasRowMajor,CblasUpper,CblasNoTrans,CblasNonUnit,
+		  dim,A,dim,Y,incx);
+
+      printVector(dim,Y,"Y","Solutions");
+      
+      cblas_daxpy(dim,beta2,Y,incx,X,incx);
+
+      printVector(dim,X,"X","Errors");
+
+      /* Store the checker of errors */
+/*       checksA[i]=(double)cblas_dnrm2(dim,X,incx); */
+
+      cblas_dswap(dim,X,incx,Y,incx);
+      
+#else
+
+      printVector(dim,X,"X","Roots");
+
+      /* Multiply A by X as Y <- A.X */
+      cblas_sgemv(CblasRowMajor,CblasNoTrans,
+		  dim,dim,alpha,A,dim,X,incx,beta,Y,incx);
+
+      printVector(dim,Y,"Y","Results");
+
+      /* Solve linear system : Y <- A-1.Y */
+      cblas_strsv(CblasRowMajor,CblasUpper,CblasNoTrans,CblasNonUnit,
+		  dim,A,dim,Y,incx);
+
+      printVector(dim,Y,"Y","Solutions");
+      
+      cblas_saxpy(dim,beta2,Y,incx,X,incx);
+
+      printVector(dim,X,"X","Errors");
+
+      /* Store the checker of errors */
+/*       checksA[i]=(double)cblas_snrm2(dim,X,incx); */
+
+      cblas_sswap(dim,X,incx,Y,incx);
+      
+#endif
+
+    }
+#endif
+  putchar('\n');
+
+  /* Get second timer after launching */
+  gettimeofday(&tv2, &tz);
+
+#ifdef CUBLAS
+  double memoryIn,memoryOut;
+
+  memoryIn=(double)((tv3.tv_sec-tv1.tv_sec) * 1000000L +	\
+		    (tv3.tv_usec-tv1.tv_usec))/1000000.;  
+
+  memoryOut=(double)((tv2.tv_sec-tv4.tv_sec) * 1000000L +	\
+		    (tv2.tv_usec-tv4.tv_usec))/1000000.;  
+
+  duration=(double)((tv4.tv_sec-tv3.tv_sec) * 1000000L +	\
+		    (tv4.tv_usec-tv3.tv_usec))/1000000./RUNS;  
+
+  printf("Duration of memory allocation : %2.10f s\n",memoryIn);
+  printf("Duration of memory free : %2.10f s\n",memoryOut);
+#else
+  duration=(double)((tv2.tv_sec-tv1.tv_sec) * 1000000L +	\
+		    (tv2.tv_usec-tv1.tv_usec))/1000000./RUNS;  
+
+#endif
+
+  printf("Duration of each cycle : %2.10f s\n",duration);
+
+  printResults(RUNS,checksA,"C","Errors cumulated");
+
+  putchar('\n');
+
+  /*
+#ifdef PRINT
+  for (i=0; i<dim; i++) {
+    for (j=0; j<dim; j++) printf("A[%i,%i]=%1.5f ", i,j,A[i*dim+j]);
+    putchar('\n');
+  }
+
+  for (i=0; i<dim; i++) {
+    printf("X[%i]=%2.5f",i,X[i]);
+    putchar('\n');
+  }
+  putchar('\n');
+  for (i=0; i<dim; i++) {
+    printf("Y[%i]=%2.5f",i,Y[i]);
+    putchar('\n');
+  }
+#endif
+  */
+
+  return 0;
+}
+
+int main(int argc,char **argv)
+{
+  if ((argc==1)||
+      (strcmp(argv[1],"-h")==0)||
+      (strcmp(argv[1],"--help")==0))
+    {
+      printf("\nPerforms a bench using BLAS library implementation:\n\n"
+	     "\t#1 Size on triangular system\n"
+	     "\t#2 Number of iterations\n\n");
+    }
+  else if ((atoi(argv[1])>=2)&&
+	   (atoi(argv[2])>=1))
+    {
+      bench(atoi(argv[1]),atoi(argv[2]));
+    }
+
+  return 0;
+}
Index: BLAS/xTRSV/bench.sh
===================================================================
--- BLAS/xTRSV/bench.sh	(revision 0)
+++ BLAS/xTRSV/bench.sh	(revision 1)
@@ -0,0 +1,46 @@
+#!/bin/sh
+
+BENCH=lesson11
+
+NUMBER=100
+
+SIZE=1000
+
+MAX=32000
+
+FORMAT=DP
+
+OUT_CBLAS=/tmp/${BENCH}_${FORMAT}_cblas.out
+OUT_FBLAS=/tmp/${BENCH}_${FORMAT}_fblas.out
+OUT_GSL=/tmp/${BENCH}_${FORMAT}_gsl.out
+OUT_THUNKING=/tmp/${BENCH}_${FORMAT}_thunking.out
+OUT_CUBLAS=/tmp/${BENCH}_${FORMAT}_cublas.out
+
+echo > $OUT_CBLAS
+echo > $OUT_FBLAS
+echo > $OUT_GSL
+echo > $OUT_THUNKING
+echo > $OUT_CUBLAS
+
+while [ $SIZE -le $MAX ]
+do
+
+    CBLAS=$(./${BENCH}_cblas $SIZE $NUMBER | grep Duration | awk -F: '{ print $2 }' | awk '{ print  $1 }')
+    
+    FBLAS=$(./${BENCH}_fblas $SIZE $NUMBER | grep Duration | awk -F: '{ print $2 }' | awk '{ print  $1 }')
+
+    GSL=$(./${BENCH}_gsl $SIZE $NUMBER | grep Duration | awk -F: '{ print $2 }' | awk '{ print  $1 }')
+    
+    THUNKING=$(./${BENCH}_thunking $SIZE $NUMBER | grep Duration | awk -F: '{ print $2 }' | awk '{ print  $1 }')
+    
+    CUBLAS=$(./${BENCH}_cublas $SIZE $NUMBER | grep Duration | awk -F: '{ print $2 }' | tr "\n" " " | awk '{ print  $5"\t"$1"\t"$3 }')
+    
+    echo -e $SIZE"\t"$CBLAS >> $OUT_CBLAS
+    echo -e $SIZE"\t"$FBLAS >> $OUT_FBLAS
+    echo -e $SIZE"\t"$GSL >> $OUT_GSL
+    echo -e $SIZE"\t"$THUNKING >> $OUT_THUNKING
+    echo -e $SIZE"\t"$CUBLAS >> $OUT_CUBLAS
+
+    SIZE=$(($SIZE+1000))
+    
+done

Property changes on: BLAS/xTRSV/bench.sh
___________________________________________________________________
Added: svn:executable
   + 

Index: BLAS/xTRSV/fortran_common.h.orig
===================================================================
--- BLAS/xTRSV/fortran_common.h.orig	(revision 0)
+++ BLAS/xTRSV/fortran_common.h.orig	(revision 1)
@@ -0,0 +1,400 @@
+/*
+ * Copyright 1993-2011 NVIDIA Corporation.  All rights reserved.
+ *
+ * NOTICE TO LICENSEE:
+ *
+ * This source code and/or documentation ("Licensed Deliverables") are
+ * subject to NVIDIA intellectual property rights under U.S. and
+ * international Copyright laws.
+ *
+ * These Licensed Deliverables contained herein is PROPRIETARY and
+ * CONFIDENTIAL to NVIDIA and is being provided under the terms and
+ * conditions of a form of NVIDIA software license agreement by and
+ * between NVIDIA and Licensee ("License Agreement") or electronically
+ * accepted by Licensee.  Notwithstanding any terms or conditions to
+ * the contrary in the License Agreement, reproduction or disclosure
+ * of the Licensed Deliverables to any third party without the express
+ * written consent of NVIDIA is prohibited.
+ *
+ * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
+ * LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
+ * SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE.  IT IS
+ * PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
+ * NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
+ * DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
+ * NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
+ * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
+ * LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
+ * SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THESE LICENSED DELIVERABLES.
+ *
+ * U.S. Government End Users.  These Licensed Deliverables are a
+ * "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
+ * 1995), consisting of "commercial computer software" and "commercial
+ * computer software documentation" as such terms are used in 48
+ * C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
+ * only as a commercial end item.  Consistent with 48 C.F.R.12.212 and
+ * 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
+ * U.S. Government End Users acquire the Licensed Deliverables with
+ * only those rights set forth herein.
+ *
+ * Any use of the Licensed Deliverables in individual and commercial
+ * software must include, in the user documentation and internal
+ * comments to the code, the above Disclaimer and U.S. Government End
+ * Users Notice.
+ */
+ 
+#define CUBLAS_G77              1
+#define CUBLAS_INTEL_FORTRAN    2
+#define CUBLAS_G95              3
+
+/* Default to g77 on Linux, and Intel Fortran on Win32 */
+#if defined(_WIN32)
+#define CUBLAS_FORTRAN_COMPILER CUBLAS_INTEL_FORTRAN
+#elif defined(__linux)
+#define CUBLAS_FORTRAN_COMPILER CUBLAS_G95
+#elif defined(__APPLE__)
+#define CUBLAS_FORTRAN_COMPILER CUBLAS_G95
+#define RETURN_COMPLEX   1
+#else
+#error unsupported platform
+#endif
+
+#if (CUBLAS_FORTRAN_COMPILER==CUBLAS_G77) || (CUBLAS_FORTRAN_COMPILER==CUBLAS_G95)
+/* NOTE: Must use -fno-second-underscore when building Fortran source with g77
+ *       g77 invocation may not use -fno-f2c, which forces different return 
+ *       type conventions than the one used below
+ */
+#define CUBLAS_INIT             cublas_init_
+#define CUBLAS_SHUTDOWN         cublas_shutdown_
+#define CUBLAS_ALLOC            cublas_alloc_
+#define CUBLAS_FREE             cublas_free_
+#define CUBLAS_SET_VECTOR       cublas_set_vector_
+#define CUBLAS_GET_VECTOR       cublas_get_vector_
+#define CUBLAS_SET_MATRIX       cublas_set_matrix_
+#define CUBLAS_GET_MATRIX       cublas_get_matrix_
+#define CUBLAS_GET_ERROR        cublas_get_error_
+#define CUBLAS_XERBLA           cublas_xerbla_
+#define CUBLAS_ISAMAX           cublas_isamax_
+#define CUBLAS_ISAMIN           cublas_isamin_
+#define CUBLAS_SASUM            cublas_sasum_
+#define CUBLAS_SAXPY            cublas_saxpy_
+#define CUBLAS_SCOPY            cublas_scopy_
+#define CUBLAS_SDOT             cublas_sdot_
+#define CUBLAS_SNRM2            cublas_snrm2_
+#define CUBLAS_SROT             cublas_srot_
+#define CUBLAS_SROTG            cublas_srotg_
+#define CUBLAS_SROTM            cublas_srotm_
+#define CUBLAS_SROTMG           cublas_srotmg_
+#define CUBLAS_SSCAL            cublas_sscal_
+#define CUBLAS_SSWAP            cublas_sswap_
+#define CUBLAS_CAXPY            cublas_caxpy_
+#define CUBLAS_CCOPY            cublas_ccopy_
+#define CUBLAS_CROT             cublas_crot_
+#define CUBLAS_CROTG            cublas_crotg_
+#define CUBLAS_CSCAL            cublas_cscal_
+#define CUBLAS_CSROT            cublas_csrot_
+#define CUBLAS_CSSCAL           cublas_csscal_
+#define CUBLAS_CSWAP            cublas_cswap_
+#define CUBLAS_CTRMV            cublas_ctrmv_
+#define CUBLAS_CDOTU            cublas_cdotu_
+#define CUBLAS_CDOTC            cublas_cdotc_
+#define CUBLAS_ICAMAX           cublas_icamax_
+#define CUBLAS_SCASUM           cublas_scasum_
+#define CUBLAS_SCNRM2           cublas_scnrm2_
+#define CUBLAS_SGBMV            cublas_sgbmv_
+#define CUBLAS_SGEMV            cublas_sgemv_
+#define CUBLAS_SGER             cublas_sger_
+#define CUBLAS_SSBMV            cublas_ssbmv_
+#define CUBLAS_SSPMV            cublas_sspmv_
+#define CUBLAS_SSPR             cublas_sspr_
+#define CUBLAS_SSPR2            cublas_sspr2_
+#define CUBLAS_SSYMV            cublas_ssymv_
+#define CUBLAS_SSYR             cublas_ssyr_
+#define CUBLAS_SSYR2            cublas_ssyr2_
+#define CUBLAS_STBMV            cublas_stbmv_
+#define CUBLAS_STBSV            cublas_stbsv_
+#define CUBLAS_STPMV            cublas_stpmv_
+#define CUBLAS_STPSV            cublas_stpsv_
+#define CUBLAS_STRMV            cublas_strmv_
+#define CUBLAS_STRSV            cublas_strsv_
+#define CUBLAS_SGEMM            cublas_sgemm_
+#define CUBLAS_SSYMM            cublas_ssymm_
+#define CUBLAS_SSYR2K           cublas_ssyr2k_
+#define CUBLAS_SSYRK            cublas_ssyrk_
+#define CUBLAS_STRMM            cublas_strmm_
+#define CUBLAS_STRSM            cublas_strsm_
+#define CUBLAS_CGEMM            cublas_cgemm_
+#define CUBLAS_CHEMM            cublas_chemm_
+#define CUBLAS_CSYMM            cublas_csymm_
+#define CUBLAS_CTRMM            cublas_ctrmm_
+#define CUBLAS_CTRSM            cublas_ctrsm_
+#define CUBLAS_CHERK            cublas_cherk_
+#define CUBLAS_CSYRK            cublas_csyrk_
+#define CUBLAS_CHER2K           cublas_cher2k_
+#define CUBLAS_CSYR2K           cublas_csyr2k_
+#define CUBLAS_IDAMAX           cublas_idamax_
+#define CUBLAS_IDAMIN           cublas_idamin_
+#define CUBLAS_DASUM            cublas_dasum_
+#define CUBLAS_DAXPY            cublas_daxpy_
+#define CUBLAS_DCOPY            cublas_dcopy_
+#define CUBLAS_DDOT             cublas_ddot_
+#define CUBLAS_DNRM2            cublas_dnrm2_
+#define CUBLAS_DROT             cublas_drot_
+#define CUBLAS_DROTG            cublas_drotg_
+#define CUBLAS_DROTM            cublas_drotm_
+#define CUBLAS_DROTMG           cublas_drotmg_
+#define CUBLAS_DSCAL            cublas_dscal_
+#define CUBLAS_DSWAP            cublas_dswap_
+#define CUBLAS_ZAXPY            cublas_zaxpy_
+#define CUBLAS_ZCOPY            cublas_zcopy_
+#define CUBLAS_ZROT             cublas_zrot_
+#define CUBLAS_ZROTG            cublas_zrotg_
+#define CUBLAS_ZSCAL            cublas_zscal_
+#define CUBLAS_ZDROT            cublas_zdrot_
+#define CUBLAS_ZDSCAL           cublas_zdscal_
+#define CUBLAS_ZSWAP            cublas_zswap_
+#define CUBLAS_ZDOTU            cublas_zdotu_
+#define CUBLAS_ZDOTC            cublas_zdotc_
+#define CUBLAS_IZAMAX           cublas_izamax_
+#define CUBLAS_DZASUM           cublas_dzasum_
+#define CUBLAS_DZNRM2           cublas_dznrm2_
+#define CUBLAS_DGBMV            cublas_dgbmv_
+#define CUBLAS_DGEMV            cublas_dgemv_
+#define CUBLAS_ZGEMV            cublas_zgemv_
+#define CUBLAS_DGER             cublas_dger_
+#define CUBLAS_DSBMV            cublas_dsbmv_
+#define CUBLAS_DSPMV            cublas_dspmv_
+#define CUBLAS_DSPR             cublas_dspr_
+#define CUBLAS_DSPR2            cublas_dspr2_
+#define CUBLAS_DSYMV            cublas_dsymv_
+#define CUBLAS_DSYR             cublas_dsyr_
+#define CUBLAS_DSYR2            cublas_dsyr2_
+#define CUBLAS_DTBMV            cublas_dtbmv_
+#define CUBLAS_DTBSV            cublas_dtbsv_
+#define CUBLAS_DTPMV            cublas_dtpmv_
+#define CUBLAS_DTPSV            cublas_dtpsv_
+#define CUBLAS_DTRMV            cublas_dtrmv_
+#define CUBLAS_DTRSV            cublas_dtrsv_
+#define CUBLAS_DGEMM            cublas_dgemm_
+#define CUBLAS_DSYMM            cublas_dsymm_
+#define CUBLAS_DSYR2K           cublas_dsyr2k_
+#define CUBLAS_DSYRK            cublas_dsyrk_
+#define CUBLAS_ZSYRK            cublas_zsyrk_
+#define CUBLAS_DTRMM            cublas_dtrmm_
+#define CUBLAS_DTRSM            cublas_dtrsm_
+#define CUBLAS_ZGEMM            cublas_zgemm_
+#define CUBLAS_ZHEMM            cublas_zhemm_
+#define CUBLAS_ZSYMM            cublas_zsymm_
+#define CUBLAS_ZTRMM            cublas_ztrmm_
+#define CUBLAS_ZTRSM            cublas_ztrsm_
+#define CUBLAS_ZHERK            cublas_zherk_
+#define CUBLAS_ZSYRK            cublas_zsyrk_
+#define CUBLAS_ZHER2K           cublas_zher2k_
+#define CUBLAS_ZSYR2K           cublas_zsyr2k_
+
+#define  CUBLAS_CGEMV           cublas_cgemv_
+#define  CUBLAS_CGBMV           cublas_cgbmv_
+#define  CUBLAS_CHEMV           cublas_chemv_
+#define  CUBLAS_CHBMV           cublas_chbmv_
+#define  CUBLAS_CHPMV           cublas_chpmv_
+#define  CUBLAS_CTBMV           cublas_ctbmv_
+#define  CUBLAS_CTPMV           cublas_ctpmv_
+#define  CUBLAS_CTRSV           cublas_ctrsv_
+#define  CUBLAS_CTBSV           cublas_ctbsv_
+#define  CUBLAS_CTPSV           cublas_ctpsv_
+#define  CUBLAS_CGERC           cublas_cgerc_
+#define  CUBLAS_CGERU           cublas_cgeru_
+#define  CUBLAS_CHPR            cublas_chpr_
+#define  CUBLAS_CHPR2           cublas_chpr2_
+#define  CUBLAS_CHER            cublas_cher_
+#define  CUBLAS_CHER2           cublas_cher2_
+
+// stubs for zblat2
+#define CUBLAS_ZGBMV           cublas_zgbmv_
+#define CUBLAS_ZHEMV           cublas_zhemv_
+#define CUBLAS_ZHBMV           cublas_zhbmv_
+#define CUBLAS_ZHPMV           cublas_zhpmv_
+#define CUBLAS_ZTRMV           cublas_ztrmv_
+#define CUBLAS_ZTBMV           cublas_ztbmv_
+#define CUBLAS_ZTPMV           cublas_ztpmv_
+#define CUBLAS_ZTRSV           cublas_ztrsv_
+#define CUBLAS_ZTBSV           cublas_ztbsv_
+#define CUBLAS_ZTPSV           cublas_ztpsv_
+#define CUBLAS_ZGERC           cublas_zgerc_
+#define CUBLAS_ZGERU           cublas_zgeru_
+#define CUBLAS_ZHER            cublas_zher_
+#define CUBLAS_ZHPR            cublas_zhpr_
+#define CUBLAS_ZHER2           cublas_zher2_
+#define CUBLAS_ZHPR2           cublas_zhpr2_
+
+#elif CUBLAS_FORTRAN_COMPILER==CUBLAS_INTEL_FORTRAN
+
+#define CUBLAS_INIT             CUBLAS_INIT 
+#define CUBLAS_SHUTDOWN         CUBLAS_SHUTDOWN
+#define CUBLAS_ALLOC            CUBLAS_ALLOC
+#define CUBLAS_FREE             CUBLAS_FREE
+#define CUBLAS_SET_VECTOR       CUBLAS_SET_VECTOR
+#define CUBLAS_GET_VECTOR       CUBLAS_GET_VECTOR
+#define CUBLAS_SET_MATRIX       CUBLAS_SET_MATRIX
+#define CUBLAS_GET_MATRIX       CUBLAS_GET_MATRIX
+#define CUBLAS_GET_ERROR        CUBLAS_GET_ERROR
+#define CUBLAS_XERBLA           CUBLAS_XERBLA
+#define CUBLAS_ISAMAX           CUBLAS_ISAMAX
+#define CUBLAS_ISAMIN           CUBLAS_ISAMIN
+#define CUBLAS_SASUM            CUBLAS_SASUM
+#define CUBLAS_SAXPY            CUBLAS_SAXPY
+#define CUBLAS_SCOPY            CUBLAS_SCOPY
+#define CUBLAS_SDOT             CUBLAS_SDOT
+#define CUBLAS_SNRM2            CUBLAS_SNRM2
+#define CUBLAS_SROT             CUBLAS_SROT
+#define CUBLAS_SROTG            CUBLAS_SROTG
+#define CUBLAS_SROTM            CUBLAS_SROTM
+#define CUBLAS_SROTMG           CUBLAS_SROTMG
+#define CUBLAS_SSCAL            CUBLAS_SSCAL
+#define CUBLAS_SSWAP            CUBLAS_SSWAP
+#define CUBLAS_CAXPY            CUBLAS_CAXPY
+#define CUBLAS_CCOPY            CUBLAS_CCOPY
+#define CUBLAS_ZCOPY            CUBLAS_ZCOPY
+#define CUBLAS_CROT             CUBLAS_CROT
+#define CUBLAS_CROTG            CUBLAS_CROTG
+#define CUBLAS_CSCAL            CUBLAS_CSCAL
+#define CUBLAS_CSROT            CUBLAS_CSROT
+#define CUBLAS_CSSCAL           CUBLAS_CSSCAL
+#define CUBLAS_CSWAP            CUBLAS_CSWAP 
+#define CUBLAS_ZSWAP            CUBLAS_ZSWAP 
+#define CUBLAS_CTRMV            CUBLAS_CTRMV 
+#define CUBLAS_CDOTU            CUBLAS_CDOTU
+#define CUBLAS_CDOTC            CUBLAS_CDOTC
+#define CUBLAS_ICAMAX           CUBLAS_ICAMAX
+#define CUBLAS_SCASUM           CUBLAS_SCASUM
+#define CUBLAS_SCNRM2           CUBLAS_SCNRM2
+#define CUBLAS_SGBMV            CUBLAS_SGBMV
+#define CUBLAS_SGEMV            CUBLAS_SGEMV
+#define CUBLAS_SGER             CUBLAS_SGER
+#define CUBLAS_SSBMV            CUBLAS_SSBMV
+#define CUBLAS_SSPMV            CUBLAS_SSPMV
+#define CUBLAS_SSPR             CUBLAS_SSPR
+#define CUBLAS_SSPR2            CUBLAS_SSPR2
+#define CUBLAS_SSYMV            CUBLAS_SSYMV
+#define CUBLAS_SSYR             CUBLAS_SSYR
+#define CUBLAS_SSYR2            CUBLAS_SSYR2
+#define CUBLAS_STBMV            CUBLAS_STBMV
+#define CUBLAS_STBSV            CUBLAS_STBSV
+#define CUBLAS_STPMV            CUBLAS_STPMV
+#define CUBLAS_STPSV            CUBLAS_STPSV
+#define CUBLAS_STRMV            CUBLAS_STRMV
+#define CUBLAS_STRSV            CUBLAS_STRSV
+#define CUBLAS_SGEMM            CUBLAS_SGEMM
+#define CUBLAS_SSYMM            CUBLAS_SSYMM
+#define CUBLAS_SSYR2K           CUBLAS_SSYR2K
+#define CUBLAS_SSYRK            CUBLAS_SSYRK
+#define CUBLAS_STRMM            CUBLAS_STRMM
+#define CUBLAS_STRSM            CUBLAS_STRSM
+#define CUBLAS_CGEMM            CUBLAS_CGEMM
+#define CUBLAS_CHEMM            CUBLAS_CHEMM
+#define CUBLAS_CSYMM            CUBLAS_CSYMM
+#define CUBLAS_CTRMM            CUBLAS_CTRMM
+#define CUBLAS_CTRSM            CUBLAS_CTRSM
+#define CUBLAS_CHERK            CUBLAS_CHERK
+#define CUBLAS_CSYRK            CUBLAS_CSYRK
+#define CUBLAS_CHER2K           CUBLAS_CHER2K
+#define CUBLAS_CSYR2K           CUBLAS_CSYR2K
+#define CUBLAS_IDAMAX           CUBLAS_IDAMAX
+#define CUBLAS_IDAMIN           CUBLAS_IDAMIN
+#define CUBLAS_DASUM            CUBLAS_DASUM
+#define CUBLAS_DAXPY            CUBLAS_DAXPY
+#define CUBLAS_DCOPY            CUBLAS_DCOPY
+#define CUBLAS_DDOT             CUBLAS_DDOT
+#define CUBLAS_DNRM2            CUBLAS_DNRM2
+#define CUBLAS_DROT             CUBLAS_DROT
+#define CUBLAS_DROTG            CUBLAS_DROTG
+#define CUBLAS_DROTM            CUBLAS_DROTM
+#define CUBLAS_DROTMG           CUBLAS_DROTMG
+#define CUBLAS_DSCAL            CUBLAS_DSCAL
+#define CUBLAS_DSWAP            CUBLAS_DSWAP
+#define CUBLAS_ZAXPY            CUBLAS_ZAXPY
+#define CUBLAS_ZCOPY            CUBLAS_ZCOPY
+#define CUBLAS_ZROT             CUBLAS_ZROT
+#define CUBLAS_ZROTG            CUBLAS_ZROTG
+#define CUBLAS_ZSCAL            CUBLAS_ZSCAL
+#define CUBLAS_ZDROT            CUBLAS_ZDROT
+#define CUBLAS_ZDSCAL           CUBLAS_ZDSCAL
+#define CUBLAS_ZSWAP            CUBLAS_ZSWAP 
+#define CUBLAS_ZDOTU            CUBLAS_ZDOTU
+#define CUBLAS_ZDOTC            CUBLAS_ZDOTC
+#define CUBLAS_IZAMAX           CUBLAS_IZAMAX
+#define CUBLAS_DZASUM           CUBLAS_DZASUM
+#define CUBLAS_DZNRM2           CUBLAS_DZNRM2
+#define CUBLAS_DGBMV            CUBLAS_DGBMV
+#define CUBLAS_DGEMV            CUBLAS_DGEMV
+#define CUBLAS_ZGEMV            CUBLAS_ZGEMV
+#define CUBLAS_DGER             CUBLAS_DGER
+#define CUBLAS_DSBMV            CUBLAS_DSBMV
+#define CUBLAS_DSPMV            CUBLAS_DSPMV
+#define CUBLAS_DSPR             CUBLAS_DSPR
+#define CUBLAS_DSPR2            CUBLAS_DSPR2
+#define CUBLAS_DSYMV            CUBLAS_DSYMV
+#define CUBLAS_DSYR             CUBLAS_DSYR
+#define CUBLAS_DSYR2            CUBLAS_DSYR2
+#define CUBLAS_DTBMV            CUBLAS_DTBMV
+#define CUBLAS_DTBSV            CUBLAS_DTBSV
+#define CUBLAS_DTPMV            CUBLAS_DTPMV
+#define CUBLAS_DTPSV            CUBLAS_DTPSV
+#define CUBLAS_DTRMV            CUBLAS_DTRMV
+#define CUBLAS_DTRSV            CUBLAS_DTRSV
+#define CUBLAS_DGEMM            CUBLAS_DGEMM
+#define CUBLAS_DSYMM            CUBLAS_DSYMM
+#define CUBLAS_DSYR2K           CUBLAS_DSYR2K
+#define CUBLAS_ZSYRK            CUBLAS_ZSYRK
+#define CUBLAS_DTRMM            CUBLAS_DTRMM
+#define CUBLAS_DTRSM            CUBLAS_DTRSM
+#define CUBLAS_ZGEMM            CUBLAS_ZGEMM
+#define CUBLAS_ZHEMM            CUBLAS_ZHEMM
+#define CUBLAS_ZSYMM            CUBLAS_ZSYMM
+#define CUBLAS_ZTRMM            CUBLAS_ZTRMM
+#define CUBLAS_ZTRSM            CUBLAS_ZTRSM
+#define CUBLAS_ZHERK            CUBLAS_ZHERK
+#define CUBLAS_ZSYRK            CUBLAS_ZSYRK
+#define CUBLAS_ZHER2K           CUBLAS_ZHER2K
+#define CUBLAS_ZSYR2K           CUBLAS_ZSYR2K
+
+#define  CUBLAS_CGEMV           CUBLAS_CGEMV
+#define  CUBLAS_CGBMV           CUBLAS_CGBMV
+#define  CUBLAS_CHEMV           CUBLAS_CHEMV
+#define  CUBLAS_CHBMV           CUBLAS_CHBMV
+#define  CUBLAS_CHPMV           CUBLAS_CHPMV
+#define  CUBLAS_CTBMV           CUBLAS_CTBMV
+#define  CUBLAS_CTPMV           CUBLAS_CTPMV
+#define  CUBLAS_CTRSV           CUBLAS_CTRSV
+#define  CUBLAS_CTBSV           CUBLAS_CTBSV
+#define  CUBLAS_CTPSV           CUBLAS_CTPSV
+#define  CUBLAS_CGERC           CUBLAS_CGERC
+#define  CUBLAS_CGERU           CUBLAS_CGERU
+#define  CUBLAS_CHPR            CUBLAS_CHPR
+
+
+// stubs for zblat2
+#define CUBLAS_ZGBMV           CUBLAS_ZGBMV
+#define CUBLAS_ZHEMV           CUBLAS_ZHEMV
+#define CUBLAS_ZHBMV           CUBLAS_ZHBMV
+#define CUBLAS_ZHPMV           CUBLAS_ZHPMV
+#define CUBLAS_ZTRMV           CUBLAS_ZTRMV
+#define CUBLAS_ZTBMV           CUBLAS_ZTBMV
+#define CUBLAS_ZTPMV           CUBLAS_ZTPMV
+#define CUBLAS_ZTRSV           CUBLAS_ZTRSV
+#define CUBLAS_ZTBSV           CUBLAS_ZTBSV
+#define CUBLAS_ZTPSV           CUBLAS_ZTPSV
+#define CUBLAS_ZGERC           CUBLAS_ZGERC
+#define CUBLAS_ZGERU           CUBLAS_ZGERU
+#define CUBLAS_ZHER            CUBLAS_ZHER
+#define CUBLAS_ZHPR            CUBLAS_ZHPR
+#define CUBLAS_ZHER2           CUBLAS_ZHER2
+#define CUBLAS_ZHPR2           CUBLAS_ZHPR2
+
+#else
+#error unsupported Fortran compiler
+#endif
