// Written by Vasily Volkov.
// Copyright (c) 2008, The Regents of the University of California. 
// All rights reserved.

#include <time.h>

#include "sgemmN.cuh"
#include "cuda_runtime.h"

#define BLOCK_SIZE 32

__device__ void saxpy( float a, float *b, float *c )
{
    c[0] += a*b[0];
    c[1] += a*b[1];
    c[2] += a*b[2];
    c[3] += a*b[3];
    c[4] += a*b[4];
    c[5] += a*b[5];
    c[6] += a*b[6];
    c[7] += a*b[7];
    c[8] += a*b[8];
    c[9] += a*b[9];
    c[10] += a*b[10];
    c[11] += a*b[11];
    c[12] += a*b[12];
    c[13] += a*b[13];
    c[14] += a*b[14];
    c[15] += a*b[15];
}

__device__ void saxpy2( const float* a, const float *b, const float *a2, float *c )
{
    c[0]  += a[0] *b[0] * a2[0];
    c[1]  += a[1] *b[1] * a2[0];
    c[2]  += a[2] *b[2] * a2[0];
    c[3]  += a[3] *b[3] * a2[0];
    c[4]  += a[4] *b[4] * a2[0];
    c[5]  += a[5] *b[5] * a2[0];
    c[6]  += a[6] *b[6] * a2[0];
    c[7]  += a[7] *b[7] * a2[0];
    c[8]  += a[8] *b[8] * a2[0];
    c[9]  += a[9] *b[9] * a2[0];
    c[10] += a[10]*b[10] * a2[0];
    c[11] += a[11]*b[11] * a2[0];
    c[12] += a[12]*b[12] * a2[0];
    c[13] += a[13]*b[13] * a2[0];
    c[14] += a[14]*b[14] * a2[0];
    c[15] += a[15]*b[15] * a2[0];
}

__device__ void saxpy3( const float* a, const float *b, float *c )
{
    c[0]  += a[0] *b[0] ;
    c[1]  += a[1] *b[1] ;
    c[2]  += a[2] *b[2] ;
    c[3]  += a[3] *b[3] ;
    c[4]  += a[4] *b[4] ;
    c[5]  += a[5] *b[5] ;
    c[6]  += a[6] *b[6] ;
    c[7]  += a[7] *b[7] ;
    c[8]  += a[8] *b[8] ;
    c[9]  += a[9] *b[9] ;
    c[10] += a[10]*b[10] ;
    c[11] += a[11]*b[11] ;
    c[12] += a[12]*b[12] ;
    c[13] += a[13]*b[13] ;
    c[14] += a[14]*b[14] ;
    c[15] += a[15]*b[15] ;
}

__device__ void saxpy64( const float* a, const float *b, float *c )
{
	#pragma unroll
	for( int i = 0; i < 64; i++)
		c[i]  = a[i]*b[i] ;
}

__device__ void saxpy32( const float* a, const float *b, float *c, const float* balance )
{
	#pragma unroll
	for( int i = 0; i < 32; i++)
		c[i]  = a[i]*b[i]* balance[0];
}

__device__ void redux32sum( const float* a, float* res )
{
	float c2[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
	float c[8] = {0,0,0,0,0,0,0,0};

	
	// 32 -> 16
	#pragma unroll
		for( int i = 0; i < 16; i++)
			c2[i]  = a[i] + a[16+i];

	// 16 -> 8
	#pragma unroll
		for( int i = 0; i < 8; i++)
			c[i] = c2[8+i] + c2[i];

	//8 -> 4
	#pragma unroll
		for( int i = 0; i < 4; i++)
			c2[i]  = c[4+i] + c[i];

	//4->2
	#pragma unroll
		for( int i = 0; i < 2; i++)
			c[i]  = c2[2+i] + c2[i];

	// 2->1
			*res = c[0] + c[1];
}

__device__ void redux64sum( const float* a, float* res )
{
	float c[32] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
				   0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};

	float c2[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};

	// 64 -> 32
	#pragma unroll
		for( int i = 0; i < 64; i++)
			c[i]  = a[i] + a[32+i];

	
	// 32 -> 16
	#pragma unroll
		for( int i = 0; i < 16; i++)
			c2[i] = c[16+i] + c[i];

	// 16 -> 8
	#pragma unroll
		for( int i = 0; i < 8; i++)
			c[i] = c2[8+i] + c2[i];

	//8 -> 4
	#pragma unroll
		for( int i = 0; i < 4; i++)
			c2[i]  = c[4+i] + c[i];

	//4->2
	#pragma unroll
		for( int i = 0; i < 2; i++)
			c[i]  = c2[2+i] + c2[i];

	// 2->1
			*res = c[0] + c[1];
}
__device__ void redux16sum( const float* a, float* res )
{
	float c[8] = {0,0,0,0,0,0,0,0};

	// 16 -> 8
	#pragma unroll
		for( int i = 0; i < 8; i++)
			c[i]  += a[i] + a[i*2];

	//8 -> 4
	#pragma unroll
		for( int i = 0; i < 4; i++)
			c[i]  += a[i] + a[i*2];

	//4->2
	#pragma unroll
		for( int i = 0; i < 2; i++)
			c[i]  += a[i] + a[i*2];

	// 2->1
			*res = c[0] + c[1];
}

extern "C" __global__ void sgemmNT( const float *A, int lda, const float *B, int ldb, float* C, int ldc, int k, float alpha, float beta )
{
    const int inx = threadIdx.x;
    const int iny = threadIdx.y;

    const int ibx = blockIdx.x * 64;
    const int iby = blockIdx.y * 16;
    
	const int id = inx + iny*16;

    A += ibx + id;
    B += iby + inx + __mul24( iny, ldb );
    C += ibx + id  + __mul24( iby, ldc );
    const float *Blast = B + k*ldb;

    float c[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};

    __shared__ float bs[16][16];
    do
    {
#pragma unroll
        for( int i = 0; i < 16; i += 4 )
            bs[iny+i][inx]  = B[i*ldb];
        __syncthreads();

#pragma unroll
        for( int i = 0; i < 16; i++, A += lda )
            saxpy( A[0], &bs[i][0], c ); 

        B += 16*ldb;
        __syncthreads();
    } while( B < Blast );

    for( int i = 0; i < 16; i++, C += ldc )
        C[0] = alpha*c[i] + beta*C[0]; 
}	

extern "C" __global__ void sgemmNN( const float *A, int lda, const float *B, int ldb, float* C, int ldc, int k, float alpha, float beta )
{
    const int inx = threadIdx.x;
    const int iny = threadIdx.y;

    const int ibx = blockIdx.x * 64;
    const int iby = blockIdx.y * 16;
    
	const int id = inx + iny*16;

    A += ibx + id;
    B += inx + __mul24( iby + iny, ldb );
    C += ibx + id  + __mul24( iby, ldc );

    const float *Blast = B + k;

    float c[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};

    __shared__ float bs[16][17];
    do
    {
#pragma unroll
        for( int i = 0; i < 16; i += 4 )
            bs[inx][iny+i]  = B[i*ldb];
        __syncthreads();

#pragma unroll
        for( int i = 0; i < 16; i++, A += lda )
            saxpy( A[0], &bs[i][0], c ); 

        B += 16;
        __syncthreads();
    } while( B < Blast );

    for( int i = 0; i < 16; i++, C += ldc )
        C[0] = alpha*c[i] + beta*C[0]; 
}	


extern "C" __global__ void vec_mat_vec_mult(const float *A, int lda, 
											const float *B, int ldb, 
											float *C, int k, 
											float alpha, float beta )
{
	// FOR 16 threads

	
    const int inx = threadIdx.x; 
    //const int iny = threadIdx.y;

    const int ibx = blockIdx.x * 16;
    const int iby = blockIdx.y * 16;
    
	const int id = inx;

	const float* ARow = A;
	A += ibx + id;
	B += ibx;  

    const float *Blast = B + k;

	// vector de multiplicacion local
    float c[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
	
	// vector de sumatorio a lo largo de la columna
	float r[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
	
	// valor temporal
	float res = 0;
    
	// cargamos la parte del vector que toca
	__shared__ float bs[16];
	bs[id]  = A[0];
	C[id] = -1;

	__syncthreads();

	do
    {
        saxpy3( &B[0], &bs[0], c ); 
		redux16sum(c, &res);
		r[id] += res*ARow[0];

        __syncthreads();

		B += 16;
		ARow += 16;

    } while( B < Blast );

    redux16sum(r, &C[ibx]);
}	

extern "C" __global__ void vmSymv(const float *A, int lda, 
								  const float *B, int ldb, 
							      float *C, int k, int length, 
							      float alpha, float beta )
{
	// FOR 16 threads
    const int inx = threadIdx.x; 

    const int ibx = blockIdx.x * 16;
    const int iby = blockIdx.y * 16;
    
	const int id = threadIdx.x;

	const float* ARow = A;
	A += ibx + id;
	B += ibx + __mul24(iby+inx,ldb);  

    const float *Blast = ARow + k;

	// vector de multiplicacion local
    float c[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
	
	// vector de sumatorio a lo largo de la columna
	__shared__ float r[16];
	
	// valor temporal
	float res = 0;
    
	// cargamos la parte del vector que toca
	__shared__ float bs[16];
	bs[id]  = A[0];
	r[id] = 0;
	__syncthreads();

	int steps = ldb/16;
	int counter = 0;

	do
    {
        saxpy3( &B[0], &bs[0], c ); 
		redux16sum(c, &res);
		r[id] += res*ARow[0];

        __syncthreads();

		B += 16 * ldb;
		ARow += 16;
		counter++;

    } while( counter < steps );

	if(id == 0)
		redux16sum(r, &C[ibx]);
}	


extern "C" __global__ void vmv(const float *A, int lda, 
							   const float *B, int ldb, 
							   float *C, int k, 
							   float alpha, float beta )
{
	// FOR 64 threads
    const int id = threadIdx.x;
	const int ibx = blockIdx.x * BLOCK_SIZE;

	B += ibx + id*ldb;

	// vector de multiplicacion local
    float c[BLOCK_SIZE] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
							0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
	
	// cargamos la parte del vector que toca
	__shared__ float bs[BLOCK_SIZE];
	float r[BLOCK_SIZE] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
							0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};

	// valor temporal
	float res;
	bs[id]  = A[ibx + id];
	__syncthreads();

	const int BStep = ldb*BLOCK_SIZE;
	const float* blast = A + lda;

	do
    {
        saxpy32( &B[0], &bs[0], c, &A[id]); 
		redux32sum(c, &res);
		r[id] += res;

		B += BStep;
		A += BLOCK_SIZE;

    } while( A < blast );

	C[ibx+id] = r[id];
}	


extern "C" void ourSgemm( char transa, char transb, int m, int n, int k, float alpha, const float *A, int lda, const float *B, int ldb, float beta, float *C, int ldc )
{	
    dim3 grid( m/64, n/16 ), threads( 16, 4 );
    if( transb == 'N' || transb == 'n' )
        sgemmNN<<<grid, threads>>>( A, lda, B, ldb, C, ldc, k, alpha, beta );
    else
        sgemmNT<<<grid, threads>>>( A, lda, B, ldb, C, ldc, k, alpha, beta );
}	

//
//	auxiliary routines
//	
void fill( float *A, int n, int maxi )
{	
    for( int j = 0; j < n; j++ )
        A[j] = float( (rand()%(maxi*2+1)) - maxi ) / ( maxi + 1.f );
}	

float diff( int m, int n, float *A, int lda, float *B, int ldb )
{
    float err = 0;
    for( int j = 0; j < n; j++ )
        for( int i = 0; i < m; i++ )
            err = max( err, fabs( A[i+j*lda] - B[i+j*ldb] ) );
    return err;
}

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cuda_runtime.h>
#include "cublas_v2.h"
#define MSize 6
#define NSize 512*32
#define IDX2C(i,j,ld) (((j)*(ld))+(i))

static __inline__ void modify (cublasHandle_t handle, float *m, int ldm, int
								n, int p, int q, float alpha, float beta)
{
	cublasSscal (handle, n-p, &alpha, &m[IDX2C(p,q,ldm)], ldm);
	cublasSscal (handle, ldm-p, &beta, &m[IDX2C(p,q,ldm)], 1);
}

int cublas_example()
{

	cudaError_t cudaStat;
	cublasStatus_t stat;
	cublasHandle_t handle;
	int i, j;

    // Matriz simetrica, column-mayor
	float *B = (float*)malloc( (NSize*(NSize+1))/2*sizeof( float ) );
	float *BComplete = (float*)malloc( NSize*NSize*sizeof( float ) );

	// Vector
	float *AVec = (float*)malloc( NSize*sizeof( float ) );

	fill( BComplete, NSize*NSize, 31 );
	fill( AVec, NSize, 31 );

	int count = 0;
	for(int i = 0; i< NSize; i++)
	{
		for(int j = 0; j < NSize; j++)
		{
			if(j <= i)
			{
				BComplete[i*NSize + j] = BComplete[j * NSize + i];
				B[count] = BComplete[i*NSize + j];
				count++;
			}
		}
	}

	// resultados
	float *cuda_result = (float*)malloc( NSize*sizeof( float ) );

	for(int i = 0; i< NSize; i++)
		cuda_result[i]= 0;

	//float *cpu_result= (float*)malloc( NSize*sizeof( float ) );

	float* devPtrB, *devPtrAVec, *devPtrRes, devPtrBSym;
	cudaStat = cudaMalloc ((void**)&devPtrB, NSize*NSize*sizeof(float));
	cudaStat = cudaMalloc ((void**)&devPtrAVec, NSize*sizeof(float));
	cudaStat = cudaMalloc ((void**)&devPtrRes,  NSize*sizeof(float));

	cudaStat = cudaMalloc ((void**)&devPtrBSym, ((NSize+1)*NSize)/2*sizeof(float));


	if (cudaStat != cudaSuccess) {
		printf ("device memory allocation failed");
		return EXIT_FAILURE;
	}

	stat = cublasCreate(&handle);
	if (stat != CUBLAS_STATUS_SUCCESS) {
		printf ("CUBLAS initialization failed\n");
		return EXIT_FAILURE;
	}

	cublasSetAtomicsMode(handle, CUBLAS_ATOMICS_ALLOWED);

	stat = cublasSetMatrix (NSize, NSize, sizeof(float), BComplete, NSize, devPtrB, NSize);
	
	//cudaStat = cudaMemcpy(&devPtrBSym, &B, ((NSize+1)*NSize)/2*sizeof(float), cudaMemcpyHostToDevice);
	
	//cudaStat = cudaMemcpy(&devPtrB, &BComplete, NSize*NSize*sizeof(float), cudaMemcpyHostToDevice);

	stat = cublasSetVector (NSize, sizeof(float), AVec, 1, devPtrAVec, 1);
	stat = cublasSetVector (NSize, sizeof(float), cuda_result, 1, devPtrRes, 1);

	if (stat != CUBLAS_STATUS_SUCCESS) {
		printf ("data download failed");
		cudaFree (devPtrAVec);
		cublasDestroy(handle);
		return EXIT_FAILURE;
	}

	float alpha = 1;
	float beta = 0;

	cudaEvent_t start, end;
    Q( cudaEventCreate( &start ) );
    Q( cudaEventCreate( &end ) );
	cudaEventRecord(start, 0);
	
	float* sum = (float*)malloc(sizeof(float));

	stat = cublasSgemv( handle, CUBLAS_OP_T, NSize, NSize, &alpha, devPtrB, NSize, devPtrAVec, 1, &beta, devPtrRes, 1 );

	//stat = cublasSsymv( handle, CUBLAS_FILL_MODE_LOWER, NSize, &alpha, devPtrB, NSize, devPtrAVec, 1, &beta, devPtrRes, 1 );

	if (stat != CUBLAS_STATUS_SUCCESS) {
		printf ("cublasSgemv failed");
		cudaFree (devPtrAVec);
		cublasDestroy(handle);
		return EXIT_FAILURE;
	}

	cudaEventRecord(end, 0);
	cudaEventSynchronize(end);
	float time;
	cudaEventElapsedTime(&time, start, end);
	cudaEventRecord(start, 0);
	
	stat = cublasSdot( handle, NSize, devPtrAVec, 1, devPtrRes, 1, sum );

	cudaEventRecord(end, 0);
	cudaEventSynchronize(end);
	float time2;
	cudaEventElapsedTime(&time2, start, end);
	
	stat = cublasGetVector (NSize, sizeof(float), devPtrRes, 1, cuda_result, 1);

	if (stat != CUBLAS_STATUS_SUCCESS) {
		printf ("data upload failed");
		cudaFree (devPtrAVec);
		cublasDestroy(handle);
		return EXIT_FAILURE;
	}

	cudaFree (devPtrAVec);
	cublasDestroy(handle);

	/*float sum = 0;
	for (j = 0; j < NSize; j++) {
			sum += cuda_result[j]*AVec[j];
	}*/

	float sumCPU = 0; 
	clock_t ini = clock();
	for(int i = 0; i< NSize; i++)
	{
		float sumCPUTemp = 0;

		for(int j = 0; j< NSize; j++)
		{
			sumCPUTemp += BComplete[i*NSize+j]*AVec[j];
		}

		sumCPU+= sumCPUTemp*AVec[i];
	}
	clock_t fin = clock();

	float sumDot = 0;
	clock_t ini2 = clock();
	for(int ii = 0; ii< 1000; ii++)
	{
		for(int jj = 0; jj< NSize; jj++)
		{
			sumDot += BComplete[jj*NSize+ii]*AVec[jj];
		}
	}
	clock_t fin2 = clock();

	printf("Multiplicacion mxv de %d elems.\n", NSize );
	printf("Sumatorio completo en CUDA: %f en %f + %f ms.\n", *sum, time, time2);
	printf("Sumatorio completo en CPU: %f en %f y %f ms.\n", sumCPU, ((double)(fin-ini))/CLOCKS_PER_SEC*1000, ((double)(fin2-ini2))/CLOCKS_PER_SEC*1000);

	return EXIT_SUCCESS;
}


//
//	main()
//
int ejecutar_sgemmNN(int items)//( int argc, char **argv )
{	
/*
    int N = items;
	if(N < 16)
		N = 16;

	//FILE* cout;
	//cout = fopen("C:\\Users\\chus\\Documents\\dev\\Data\\models\\multmatrix.txt", "a");

    //
    //  startup
    //
    int idevice = 0;


    Q( cudaSetDevice( idevice ) );

    struct cudaDeviceProp prop;
    Q( cudaGetDeviceProperties( &prop, idevice ) );
    printf( "\nDevice: %s, %.0f MHz clock, %.0f MB memory.\n", prop.name, prop.clockRate/1000.f, prop.totalGlobalMem/1024.f/1024.f );

    cudaEvent_t start, end;
    Q( cudaEventCreate( &start ) );
    Q( cudaEventCreate( &end ) );

    //Q( cublasInit( ) );

    //
    //  allocate memory
    //
    //float *A = (float*)malloc( N*N*sizeof( float ) );
    float *B = (float*)malloc( N*N*sizeof( float ) );
	float *AVec = (float*)malloc( N*sizeof( float ) );

    //float *C = (float*)malloc( N*N*sizeof( float ) );
    //float *cublas_result = (float*)malloc( N*N*sizeof( float ) );
    //float *our_result = (float*)malloc( N*N*sizeof( float ) );

	float *our_result_for_sum = (float*)malloc( N*sizeof( float ) );
	float *our_result= (float*)malloc( N*sizeof( float ) );

    //fill( A, N*N, 31 );
    fill( B, N*N, 31 );
    //fill( C, N*N, 31 );
	fill( AVec, N, 31 );

	for(int i = 0; i< N; i++)
		our_result_for_sum[i] = 0;

    float *dA, *dB, *dC, *dAVec, *dCVec;
    //Q( cublasAlloc( N*N, sizeof(float), (void**)&dA ) );
    Q( cublasAlloc( N*N, sizeof(float), (void**)&dB ) );
    //Q( cublasAlloc( N*N, sizeof(float), (void**)&dC ) );
	Q( cublasAlloc( N, sizeof(float), (void**)&dAVec ) );
	Q( cublasAlloc( N, sizeof(float), (void**)&dCVec ) );
    //Q( cudaMemcpy( dA, A, N*N*sizeof(float), cudaMemcpyHostToDevice ) );
    Q( cudaMemcpy( dB, B, N*N*sizeof(float), cudaMemcpyHostToDevice ) );
	Q( cudaMemcpy( dAVec, AVec, N*sizeof(float), cudaMemcpyHostToDevice ) );
    Q( cudaMemcpy( dCVec, our_result_for_sum, N*sizeof(float), cudaMemcpyHostToDevice ) );
		
    //
    //	bench square matrices
    //
	int i = 0;
    //for( int i = 0; i < 2; i++ )
    {
        const char transa = 'N';
        const char transb = i ? 'T' : 'N';

        //printf( "\ntesting sgemm( '%c', '%c', n, n, n, ... )\n\n", transa, transb );

        const int nb = 64;
        //printf( "   n   CUBLAS,Gflop/s   we,Gflop/s   \"error\"\n" );
        int idim = 1;
		//for(idim = 1; idim <= N/nb; idim = int((idim+1)*1.25) )
        //{
			idim = N/nb;
            int dim = idim*nb;

            //
            //	set up the parameters
            //
            const int m = dim;
            const int n = dim;
            const int k = dim;
            const int lda = dim;
            const int ldb = dim;
            const int ldc = dim;
            const float alpha = 1;
            const float beta = -1;

            //
            // compute with CUBLAS
            //
			
			/*			
            Q( cublasSetMatrix( m, n, sizeof( float ), C, ldc, dC, ldc ) );
			clock_t ini1 = clock();
            cublasSgemm( transa, transb, m, n, k, alpha, dA, lda, dB, ldb, beta, dC, ldc );
			cudaError_t cudaStatus = cudaDeviceSynchronize();
			clock_t fin1 = clock();
						
            Q( cublasGetError( ) );
            Q( cublasGetMatrix( m, n, sizeof( float ), dC, ldc, cublas_result, ldc ) );
			
            //
            // compute with our routine
            //
            Q( cublasSetMatrix( m, n, sizeof( float ), C, ldc, dC, ldc ) );
			clock_t ini2 = clock();
            ourSgemm( transa, transb, m, n, k, alpha, dA, lda, dB, ldb, beta, dC, ldc );
			cudaError_t cudaStatus2 = cudaDeviceSynchronize();
			clock_t fin2 = clock();
			Q( cublasGetMatrix( m, n, sizeof( float ), dC, ldc, our_result, ldc ) );
			*/

			/*
		    dim3 grid( m/16 , 0, 0), threads( 16 , 0, 0);

			
			//Q( cublasSetMatrix( m, n, sizeof( float ), C, ldc, dC, ldc ) );
			clock_t ini3 = clock();
			vec_mat_vec_mult<<<grid, threads>>>( AVec, lda, B, ldb, dCVec, k, alpha, beta );
			clock_t fin3 = clock();

			cudaError_t cudaStatus = cudaDeviceSynchronize();
			if (cudaStatus != cudaSuccess) 
			{
				printf("cudaDeviceSynchronize returned error code %d after launching addKernel!\n", cudaStatus);
				printf("Error String: %s\n", cudaGetErrorString(cudaStatus));
			}

			Q( cudaMemcpy( our_result_for_sum, dCVec, (m/16)*sizeof(float), cudaMemcpyDeviceToHost ) );
			
			float resFinal = 0;
			for(int i = 0; i< (m/16); i++)
			{
				resFinal += our_result_for_sum[i];
			}

			printf("Resultado Final en cuda: %f en %f ms\n", resFinal, ((double)(fin3-ini3))/CLOCKS_PER_SEC*1000);
			
            //
            //	check the difference in results
            //
            //float difference = diff( m, n, cublas_result, ldc, our_result, ldc );

            //
            //	bench cublas
            //
            /*
			double cublas_time;
            cublasSgemm( transa, transb, m, n, k, alpha, dA, lda, dB, ldb, beta, dC, ldc );
            BEGIN_TIMING( );
            cublasSgemm( transa, transb, m, n, k, alpha, dA, lda, dB, ldb, beta, dC, ldc );
            END_TIMING( cublas_time );

            double cublas_gflops = 2.*m*n*k/cublas_time/1e9;

            //
            //	bench our routine
            //
            double our_time;
            ourSgemm( transa, transb, m, n, k, alpha, dA, lda, dB, ldb, beta, dC, ldc );
            BEGIN_TIMING( );
            ourSgemm( transa, transb, m, n, k, alpha, dA, lda, dB, ldb, beta, dC, ldc );
            END_TIMING( our_time );
			
            double our_gflops = 2.*m*n*k/our_time/1e9;
			*/
            //
            //	report the results
            //
			
			/*
			clock_t ini = clock();

			float result = 0;

			for(int i = 0; i< n; i++)
			{
				double tempSum = 0.0;
				for(int k = 0; k< n; k++)
				{
					tempSum += AVec[k]*B[i*n+k];
				}
				result += tempSum*AVec[i];  
			}

			clock_t fin = clock();

			printf("Resultado Final en cpu: %f en %f ms\n", result, ((double)(fin-ini))/CLOCKS_PER_SEC*1000);
			

			//printf( "TIME: %5d %11.2f %14.2f\n", n, cublas_time, our_time);
			//double time1 = ((double)(fin1-ini1))/CLOCKS_PER_SEC * 1000.0;
			//double time2 = ((double)(fin2-ini2))/CLOCKS_PER_SEC * 1000.0;
			//printf( "TIME MINE: %d, %f, %f, CPU: %f \n", n, time1, time2, ((double)(fin-ini))/CLOCKS_PER_SEC * 1000.0);
            //printf( "%5d %11.2f %14.2f %8g\n", n, cublas_gflops, our_gflops, difference );

			//fprintf(cout, "%d, %f, %f, %f \n", n, time1, time2 , ((double)(fin-ini))/CLOCKS_PER_SEC * 1000.0);
			//fflush(cout);

			
        //}
    }

	//fclose(cout);
	
    //
    //	shutdown
    //

    //cublasFree( dAVec );
    //cublasFree( dB );
    //cublasFree( dCVec );

    free( AVec );
    free( B );
    free( our_result_for_sum );

    //free( cublas_result );
    free( our_result );

    //Q( cublasShutdown( ) );

    return 0;
	*/
	return 0;
}

	

int ejecutar_matrixVector(int items)//( int argc, char **argv )
{	
    int N = items;
	if(N < 16)
		N = 16;

	//FILE* cout;
	//cout = fopen("C:\\Users\\chus\\Documents\\dev\\Data\\models\\multmatrix.txt", "a");

    int idevice = 0;
    Q( cudaSetDevice( idevice ) );

    struct cudaDeviceProp prop;
    Q( cudaGetDeviceProperties( &prop, idevice ) );
    printf( "\nDevice: %s, %.0f MHz clock, %.0f MB memory.\n", prop.name, prop.clockRate/1000.f, prop.totalGlobalMem/1024.f/1024.f );

    cudaEvent_t start, end;
    Q( cudaEventCreate( &start ) );
    Q( cudaEventCreate( &end ) );

    //
    //  allocate memory
    //

	printf("%d Elementos.\n", N);

    // Matriz simetrica, row-mayor
	float *B = (float*)malloc( (N*(N+1))/2*sizeof( float ) );
	float *BComplete = (float*)malloc( N*N*sizeof( float ) );

	// Vector
	float *AVec = (float*)malloc( N*sizeof( float ) );

	// resultados
	float *cuda_result = (float*)malloc( N*sizeof( float ) );
	float *cpu_result= (float*)malloc( N*sizeof( float ) );

	// Inicializacion
	fill( BComplete, N*N, 31 );
	fill( AVec, N, 31 );

	int count = 0;
	for(int i = 0; i< N; i++)
	{
		for(int j= i; j< N; j++)
		{
			B[count] = BComplete[i*N + j ];
			count++;
		}
	}

	for(int i = 0; i< N; i++) cuda_result[i] = 0;

    float *dA, *dB, *dAVec, *dCVec, *cuda_final_result, *cudaFinalResFloat;

	cudaError_t cudaStat; 
    //cudaStat = cudaMalloc( (void**)&dB, (N*(N+1))/2 * sizeof(float) );
	cudaStat = cudaMalloc( (void**)&dB, N*N * sizeof(float) );
	cudaStat = cudaMalloc( (void**)&dAVec, N* sizeof(float) );
	cudaStat = cudaMalloc( (void**)&dCVec, N* sizeof(float) );
	cudaStat = cudaMalloc( (void**)&cudaFinalResFloat, sizeof(float) );

    //cudaMemcpy( dB, B, (N*(N+1))/2*sizeof(float), cudaMemcpyHostToDevice );
	cudaMemcpy( dB, BComplete, N*N*sizeof(float), cudaMemcpyHostToDevice );	
	cudaMemcpy( dAVec, AVec, N*sizeof(float), cudaMemcpyHostToDevice );
    cudaMemcpy( dCVec, cuda_result, N*sizeof(float), cudaMemcpyHostToDevice );
		
    //	set up the parameters
	const int dim = N;
    const int m = dim;
    const int n = dim;
    const int k = dim;
    const int lda = dim;
    const int ldb = dim;
    const int ldc = dim;
    const float alpha = 1;
    const float beta = 0;


    // compute with CUBLAS
	clock_t ini1 = clock();
	//for(int tempI = 0; tempI< 1000; tempI++)
	{
		/*
		cublasSsymv( h, CUBLAS_FILL_MODE_UPPER, N, &alpha, dB, lda, dAVec, 1, &beta, dCVec, 1 );
		cudaError_t cudaStatus = cudaDeviceSynchronize();
		if (cudaStatus != cudaSuccess) 
		{
			printf("cudaDeviceSynchronize returned error code %d after launching addKernel!\n", cudaStatus);
			printf("Error String: %s\n", cudaGetErrorString(cudaStatus));
		}

		Q( cudaMemcpy( cuda_result, dCVec, N*sizeof(float), cudaMemcpyDeviceToHost ) );

		printf("Que pasa:\n %f %f %f %f %f \n", cuda_result[0], cuda_result[1], cuda_result[2], cuda_result[3], cuda_result[4]);

		cublasSdot( h, N, dAVec, 1, dCVec, 1 , cudaFinalResFloat);

		cudaMemcpy( &hostRes, cudaFinalResFloat, sizeof(float), cudaMemcpyDeviceToHost );
		*/

		dim3 grid(N/32), threads(32);
		vmv<<<grid, threads>>>( dAVec, lda, dB, ldb, dCVec, k, alpha, beta );

	}
	cudaError_t cudaStatus = cudaDeviceSynchronize();

	Q( cudaMemcpy( cuda_result, dCVec, N*sizeof(float), cudaMemcpyDeviceToHost ) );
	float res001 = 0;
	for(int f = 0; f < N; f++)
		res001 += cuda_result[f];

	clock_t fin1 = clock();
	printf("Resultado Final en cuda: %f en %f ms\n", res001, ((double)(fin1-ini1))/CLOCKS_PER_SEC*1000);
	float masHostRes = 0, masHostRes2 = 0;

	/*
	clock_t ini2 = clock();
	for(int tempI = 0; tempI< 1000; tempI++)
		cublasSdot( h, N, dAVec, 1, dAVec, 1, cudaFinalResFloat);
	clock_t fin2 = clock();
	printf("masHostRes:%f en %fms\n", masHostRes, ((double)(fin2-ini2))/CLOCKS_PER_SEC);

	clock_t ini3 = clock();
	for(int tempI = 0; tempI< 1000; tempI++)
	{
		masHostRes2 = 0;
		for(int i = 0; i<N; i++)
			masHostRes2 += AVec[i]*AVec[i];
	}
	clock_t fin3 = clock();

	printf("masHostResCPU:%f  en %fms\n", masHostRes2, ((double)(fin3-ini3))/CLOCKS_PER_SEC);
	*/	
			/*			
            Q( cublasSetMatrix( m, n, sizeof( float ), C, ldc, dC, ldc ) );

						
            Q( cublasGetError( ) );
            Q( cublasGetMatrix( m, n, sizeof( float ), dC, ldc, cublas_result, ldc ) );
			
            //
            // compute with our routine
            //
            Q( cublasSetMatrix( m, n, sizeof( float ), C, ldc, dC, ldc ) );
			clock_t ini2 = clock();
            ourSgemm( transa, transb, m, n, k, alpha, dA, lda, dB, ldb, beta, dC, ldc );
			cudaError_t cudaStatus2 = cudaDeviceSynchronize();
			clock_t fin2 = clock();
			Q( cublasGetMatrix( m, n, sizeof( float ), dC, ldc, our_result, ldc ) );
			*/

			/*
		    dim3 grid( m/16 , 0, 0), threads( 16 , 0, 0);

			
			//Q( cublasSetMatrix( m, n, sizeof( float ), C, ldc, dC, ldc ) );
			clock_t ini3 = clock();
			vec_mat_vec_mult<<<grid, threads>>>( AVec, lda, B, ldb, dCVec, k, alpha, beta );
			clock_t fin3 = clock();

			cudaError_t cudaStatus = cudaDeviceSynchronize();
			if (cudaStatus != cudaSuccess) 
			{
				printf("cudaDeviceSynchronize returned error code %d after launching addKernel!\n", cudaStatus);
				printf("Error String: %s\n", cudaGetErrorString(cudaStatus));
			}

			Q( cudaMemcpy( our_result_for_sum, dCVec, (m/16)*sizeof(float), cudaMemcpyDeviceToHost ) );
			*/

		//printf("Resultado Final en cuda: %f en %f ms\n", hostRes, ((double)(fin1-ini1))/CLOCKS_PER_SEC);
			
            //
            //	check the difference in results
            //
            //float difference = diff( m, n, cublas_result, ldc, our_result, ldc );

            //
            //	bench cublas
            //
            /*
			double cublas_time;
            cublasSgemm( transa, transb, m, n, k, alpha, dA, lda, dB, ldb, beta, dC, ldc );
            BEGIN_TIMING( );
            cublasSgemm( transa, transb, m, n, k, alpha, dA, lda, dB, ldb, beta, dC, ldc );
            END_TIMING( cublas_time );

            double cublas_gflops = 2.*m*n*k/cublas_time/1e9;

            //
            //	bench our routine
            //
            double our_time;
            ourSgemm( transa, transb, m, n, k, alpha, dA, lda, dB, ldb, beta, dC, ldc );
            BEGIN_TIMING( );
            ourSgemm( transa, transb, m, n, k, alpha, dA, lda, dB, ldb, beta, dC, ldc );
            END_TIMING( our_time );
			
            double our_gflops = 2.*m*n*k/our_time/1e9;
			*/
            //
            //	report the results
            //
			
	clock_t ini = clock();

	float result = 0;

	for(int i = 0; i< N; i++)
	{
		float tempSum = 0.0;
		for(int k = 0; k< N; k++)
		{
			float AvecValue = AVec[k];
			float BValue = BComplete[i*N+k];
			float tempValue = AVec[k]*BComplete[i*N+k];
			tempSum += tempValue;
		}
		result += tempSum*AVec[i];  
	}

	clock_t fin = clock();

	printf("Resultado Final en cpu: %f en %f ms\n", result, ((double)(fin-ini))/CLOCKS_PER_SEC*1000);
			

			//printf( "TIME: %5d %11.2f %14.2f\n", n, cublas_time, our_time);
			//double time1 = ((double)(fin1-ini1))/CLOCKS_PER_SEC * 1000.0;
			//double time2 = ((double)(fin2-ini2))/CLOCKS_PER_SEC * 1000.0;
			//printf( "TIME MINE: %d, %f, %f, CPU: %f \n", n, time1, time2, ((double)(fin-ini))/CLOCKS_PER_SEC * 1000.0);
            //printf( "%5d %11.2f %14.2f %8g\n", n, cublas_gflops, our_gflops, difference );

			//fprintf(cout, "%d, %f, %f, %f \n", n, time1, time2 , ((double)(fin-ini))/CLOCKS_PER_SEC * 1000.0);
			//fflush(cout);

			
        //}
    //}

	//fclose(cout);
	
    //
    //	shutdown
    //

	//cublasDestroy(h);
    cudaFree( dAVec );
    cudaFree( dB );
    cudaFree( dCVec );

    free( AVec );
    free( B );
    free( cuda_result );

    //free( cublas_result );
    free( cpu_result );


    return 0;
}	


//////////////////////

	.file	"tmpxft_00320eb3_00000000-6_sgemmN.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2849:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2849:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z5saxpyfPfS_
	.type	_Z5saxpyfPfS_, @function
_Z5saxpyfPfS_:
.LFB2027:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE2027:
	.size	_Z5saxpyfPfS_, .-_Z5saxpyfPfS_
	.globl	_Z6saxpy2PKfS0_S0_Pf
	.type	_Z6saxpy2PKfS0_S0_Pf, @function
_Z6saxpy2PKfS0_S0_Pf:
.LFB2028:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE2028:
	.size	_Z6saxpy2PKfS0_S0_Pf, .-_Z6saxpy2PKfS0_S0_Pf
	.globl	_Z6saxpy3PKfS0_Pf
	.type	_Z6saxpy3PKfS0_Pf, @function
_Z6saxpy3PKfS0_Pf:
.LFB2029:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE2029:
	.size	_Z6saxpy3PKfS0_Pf, .-_Z6saxpy3PKfS0_Pf
	.globl	_Z7saxpy64PKfS0_Pf
	.type	_Z7saxpy64PKfS0_Pf, @function
_Z7saxpy64PKfS0_Pf:
.LFB2999:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE2999:
	.size	_Z7saxpy64PKfS0_Pf, .-_Z7saxpy64PKfS0_Pf
	.globl	_Z7saxpy32PKfS0_PfS0_
	.type	_Z7saxpy32PKfS0_PfS0_, @function
_Z7saxpy32PKfS0_PfS0_:
.LFB3001:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE3001:
	.size	_Z7saxpy32PKfS0_PfS0_, .-_Z7saxpy32PKfS0_PfS0_
	.globl	_Z10redux32sumPKfPf
	.type	_Z10redux32sumPKfPf, @function
_Z10redux32sumPKfPf:
.LFB2032:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE2032:
	.size	_Z10redux32sumPKfPf, .-_Z10redux32sumPKfPf
	.globl	_Z10redux64sumPKfPf
	.type	_Z10redux64sumPKfPf, @function
_Z10redux64sumPKfPf:
.LFB3003:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	pushq	%rax
	.cfi_def_cfa_offset 16
	call	_Z10redux32sumPKfPf
	.cfi_endproc
.LFE3003:
	.size	_Z10redux64sumPKfPf, .-_Z10redux64sumPKfPf
	.globl	_Z10redux16sumPKfPf
	.type	_Z10redux16sumPKfPf, @function
_Z10redux16sumPKfPf:
.LFB3005:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	pushq	%rax
	.cfi_def_cfa_offset 16
	call	_Z10redux32sumPKfPf
	.cfi_endproc
.LFE3005:
	.size	_Z10redux16sumPKfPf, .-_Z10redux16sumPKfPf
	.globl	_Z4fillPfii
	.type	_Z4fillPfii, @function
_Z4fillPfii:
.LFB2036:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	leal	1(%rdx,%rdx), %r14d
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	movq	%rdi, %r13
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	movl	%esi, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	xorl	%ebp, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	movl	%edx, %ebx
.L19:
	cmpl	%ebp, %r12d
	jle	.L23
	call	rand@PLT
	cvtsi2ssl	%ebx, %xmm1
	addss	.LC0(%rip), %xmm1
	cltd
	idivl	%r14d
	subl	%ebx, %edx
	cvtsi2ssl	%edx, %xmm0
	divss	%xmm1, %xmm0
	movss	%xmm0, 0(%r13,%rbp,4)
	incq	%rbp
	jmp	.L19
.L23:
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2036:
	.size	_Z4fillPfii, .-_Z4fillPfii
	.globl	_Z4diffiiPfiS_i
	.type	_Z4diffiiPfiS_i, @function
_Z4diffiiPfiS_i:
.LFB2037:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	xorl	%eax, %eax
	xorl	%r15d, %r15d
	xorps	%xmm0, %xmm0
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movq	%rdx, %r14
	movl	%ecx, %edx
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	xorl	%r12d, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%r8, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	movl	%edi, 4(%rsp)
.L25:
	cmpl	%esi, %eax
	jge	.L24
	movslq	%r15d, %rcx
	xorl	%ebx, %ebx
	leaq	(%r14,%rcx,4), %rdi
	movslq	%r12d, %rcx
	leaq	0(%rbp,%rcx,4), %r13
.L28:
	cmpl	%ebx, 4(%rsp)
	jle	.L30
	movss	(%rdi,%rbx,4), %xmm1
	subss	0(%r13,%rbx,4), %xmm1
	movl	%r9d, 28(%rsp)
	incq	%rbx
	andps	.LC2(%rip), %xmm1
	movl	%edx, 24(%rsp)
	movl	%esi, 20(%rsp)
	movl	%eax, 16(%rsp)
	movq	%rdi, 8(%rsp)
	call	fmaxf@PLT
	movl	28(%rsp), %r9d
	movl	24(%rsp), %edx
	movl	20(%rsp), %esi
	movl	16(%rsp), %eax
	movq	8(%rsp), %rdi
	jmp	.L28
.L30:
	incl	%eax
	addl	%edx, %r15d
	addl	%r9d, %r12d
	jmp	.L25
.L24:
	addq	$40, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2037:
	.size	_Z4diffiiPfiS_i, .-_Z4diffiiPfiS_i
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC3:
	.string	"device memory allocation failed"
.LC4:
	.string	"CUBLAS initialization failed\n"
.LC5:
	.string	"data download failed"
.LC6:
	.string	"/home/ubuntu/Datasets/stackv2/train-structured/immagery/air/master/AirLib/cuda/sgemmN.cu"
.LC7:
	.string	"\n FAILURE in %s, line %d\n"
.LC8:
	.string	"cublasSgemv failed"
.LC9:
	.string	"data upload failed"
.LC10:
	.string	"Multiplicacion mxv de %d elems.\n"
.LC11:
	.string	"Sumatorio completo en CUDA: %f en %f + %f ms.\n"
.LC14:
	.string	"Sumatorio completo en CPU: %f en %f y %f ms.\n"
	.text
	.globl	_Z14cublas_examplev
	.type	_Z14cublas_examplev, @function
_Z14cublas_examplev:
.LFB2844:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	movl	$536903680, %edi
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	subq	$96, %rsp
	.cfi_def_cfa_offset 144
	movq	%fs:40, %rax
	movq	%rax, 88(%rsp)
	xorl	%eax, %eax
	call	malloc@PLT
	movl	$1073741824, %edi
	movq	%rax, %r12
	call	malloc@PLT
	movl	$65536, %edi
	movq	%rax, %rbx
	call	malloc@PLT
	movl	$31, %edx
	movl	$268435456, %esi
	movq	%rbx, %rdi
	movq	%rax, %rbp
	call	_Z4fillPfii
	movl	$31, %edx
	movl	$16384, %esi
	movq	%rbp, %rdi
	call	_Z4fillPfii
	xorl	%edx, %edx
	xorl	%ecx, %ecx
.L32:
	movl	%edx, %esi
	xorl	%eax, %eax
	sall	$14, %esi
.L34:
	cmpl	%eax, %edx
	jl	.L33
	movl	%eax, %edi
	sall	$14, %edi
	addl	%edx, %edi
	movl	%edi, %edi
	movss	(%rbx,%rdi,4), %xmm0
	leal	(%rsi,%rax), %edi
	movss	%xmm0, (%rbx,%rdi,4)
	movslq	%ecx, %rdi
	incl	%ecx
	movss	%xmm0, (%r12,%rdi,4)
.L33:
	incl	%eax
	cmpl	$16384, %eax
	jne	.L34
	incl	%edx
	cmpl	$16384, %edx
	jne	.L32
	movl	$65536, %edi
	call	malloc@PLT
	movl	$16384, %ecx
	movl	$1073741824, %esi
	movq	%rax, %r12
	xorl	%eax, %eax
	movq	%r12, %rdi
	rep stosl
	leaq	48(%rsp), %rdi
	call	cudaMalloc@PLT
	leaq	56(%rsp), %rdi
	movl	$65536, %esi
	call	cudaMalloc@PLT
	leaq	64(%rsp), %rdi
	movl	$65536, %esi
	call	cudaMalloc@PLT
	movl	$536903680, %esi
	leaq	20(%rsp), %rdi
	call	cudaMalloc@PLT
	leaq	.LC3(%rip), %rsi
	testl	%eax, %eax
	jne	.L52
	leaq	40(%rsp), %rdi
	call	cublasCreate_v2@PLT
	testl	%eax, %eax
	je	.L38
	leaq	.LC4(%rip), %rsi
.L52:
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L37:
	movl	$1, %eax
	jmp	.L31
.L38:
	movq	40(%rsp), %rdi
	movl	$1, %esi
	call	cublasSetAtomicsMode@PLT
	movl	$16384, %r8d
	movq	%rbx, %rcx
	movl	$4, %edx
	pushq	%rsi
	.cfi_def_cfa_offset 152
	movl	$16384, %edi
	movl	$16384, %esi
	pushq	$16384
	.cfi_def_cfa_offset 160
	movq	64(%rsp), %r9
	call	cublasSetMatrix@PLT
	popq	%rdi
	.cfi_def_cfa_offset 152
	popq	%r8
	.cfi_def_cfa_offset 144
	movl	$1, %r9d
	movq	56(%rsp), %r8
	movl	$1, %ecx
	movq	%rbp, %rdx
	movl	$4, %esi
	movl	$16384, %edi
	call	cublasSetVector@PLT
	movq	64(%rsp), %r8
	movl	$4, %esi
	movq	%r12, %rdx
	movl	$1, %r9d
	movl	$1, %ecx
	movl	$16384, %edi
	call	cublasSetVector@PLT
	leaq	.LC5(%rip), %rsi
	testl	%eax, %eax
	jne	.L53
	leaq	72(%rsp), %rdi
	movl	$0x3f800000, 24(%rsp)
	movl	$0x00000000, 28(%rsp)
	call	cudaEventCreate@PLT
	movl	$528, %ecx
	testl	%eax, %eax
	jne	.L54
	leaq	80(%rsp), %rdi
	call	cudaEventCreate@PLT
	testl	%eax, %eax
	je	.L42
	movl	$529, %ecx
.L54:
	movl	$2, %edi
	leaq	.LC6(%rip), %rdx
	leaq	.LC7(%rip), %rsi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	$1, %edi
	call	exit@PLT
.L42:
	movq	72(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movl	$4, %edi
	call	malloc@PLT
	pushq	$1
	.cfi_def_cfa_offset 152
	movl	$1, %esi
	movl	$16384, %ecx
	pushq	72(%rsp)
	.cfi_def_cfa_offset 160
	movq	%rax, %r13
	movl	$16384, %edx
	leaq	44(%rsp), %rax
	pushq	%rax
	.cfi_def_cfa_offset 168
	pushq	$1
	.cfi_def_cfa_offset 176
	pushq	88(%rsp)
	.cfi_def_cfa_offset 184
	pushq	$16384
	.cfi_def_cfa_offset 192
	movq	96(%rsp), %r9
	movq	88(%rsp), %rdi
	leaq	72(%rsp), %r8
	call	cublasSgemv_v2@PLT
	addq	$48, %rsp
	.cfi_def_cfa_offset 144
	leaq	.LC8(%rip), %rsi
	testl	%eax, %eax
	jne	.L53
	movq	80(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	80(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movq	80(%rsp), %rdx
	movq	72(%rsp), %rsi
	leaq	32(%rsp), %rdi
	call	cudaEventElapsedTime@PLT
	movq	72(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movl	$1, %r9d
	movl	$1, %ecx
	movl	$16384, %esi
	pushq	%rax
	.cfi_def_cfa_offset 152
	pushq	%r13
	.cfi_def_cfa_offset 160
	movq	80(%rsp), %r8
	movq	56(%rsp), %rdi
	movq	72(%rsp), %rdx
	call	cublasSdot_v2@PLT
	popq	%rdx
	.cfi_def_cfa_offset 152
	popq	%rcx
	.cfi_def_cfa_offset 144
	xorl	%esi, %esi
	movq	80(%rsp), %rdi
	call	cudaEventRecord@PLT
	movq	80(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movq	80(%rsp), %rdx
	movq	72(%rsp), %rsi
	leaq	36(%rsp), %rdi
	call	cudaEventElapsedTime@PLT
	movq	64(%rsp), %rdx
	movl	$1, %r9d
	movq	%r12, %r8
	movl	$1, %ecx
	movl	$4, %esi
	movl	$16384, %edi
	call	cublasGetVector@PLT
	testl	%eax, %eax
	je	.L44
	leaq	.LC9(%rip), %rsi
.L53:
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	56(%rsp), %rdi
	call	cudaFree@PLT
	movq	40(%rsp), %rdi
	call	cublasDestroy_v2@PLT
	jmp	.L37
.L44:
	movq	56(%rsp), %rdi
	call	cudaFree@PLT
	movq	40(%rsp), %rdi
	call	cublasDestroy_v2@PLT
	call	clock@PLT
	xorl	%edx, %edx
	xorps	%xmm3, %xmm3
	movq	%rax, %r12
.L45:
	movq	%rdx, %rcx
	xorl	%eax, %eax
	xorps	%xmm0, %xmm0
	salq	$16, %rcx
	addq	%rbx, %rcx
.L46:
	movss	(%rcx,%rax), %xmm1
	mulss	0(%rbp,%rax), %xmm1
	addq	$4, %rax
	addss	%xmm1, %xmm0
	cmpq	$65536, %rax
	jne	.L46
	mulss	0(%rbp,%rdx,4), %xmm0
	incq	%rdx
	addss	%xmm0, %xmm3
	cmpq	$16384, %rdx
	jne	.L45
	movss	%xmm3, 12(%rsp)
	call	clock@PLT
	movq	%rax, %rbx
	call	clock@PLT
	subq	%r12, %rbx
	movq	%rax, %r14
	call	clock@PLT
	movl	$16384, %edx
	movl	$2, %edi
	leaq	.LC10(%rip), %rsi
	movq	%rax, %rbp
	xorl	%eax, %eax
	call	__printf_chk@PLT
	subq	%r14, %rbp
	movl	$2, %edi
	movb	$3, %al
	leaq	.LC11(%rip), %rsi
	cvtss2sd	0(%r13), %xmm0
	cvtss2sd	36(%rsp), %xmm2
	cvtss2sd	32(%rsp), %xmm1
	call	__printf_chk@PLT
	cvtsi2sdq	%rbp, %xmm2
	movb	$3, %al
	movsd	.LC12(%rip), %xmm0
	cvtsi2sdq	%rbx, %xmm1
	movsd	.LC13(%rip), %xmm4
	movss	12(%rsp), %xmm3
	leaq	.LC14(%rip), %rsi
	movl	$2, %edi
	divsd	%xmm0, %xmm2
	divsd	%xmm0, %xmm1
	cvtss2sd	%xmm3, %xmm0
	mulsd	%xmm4, %xmm2
	mulsd	%xmm4, %xmm1
	call	__printf_chk@PLT
	xorl	%eax, %eax
.L31:
	movq	88(%rsp), %rdx
	subq	%fs:40, %rdx
	je	.L48
	call	__stack_chk_fail@PLT
.L48:
	addq	$96, %rsp
	.cfi_def_cfa_offset 48
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2844:
	.size	_Z14cublas_examplev, .-_Z14cublas_examplev
	.globl	_Z16ejecutar_sgemmNNi
	.type	_Z16ejecutar_sgemmNNi, @function
_Z16ejecutar_sgemmNNi:
.LFB2845:
	.cfi_startproc
	endbr64
	xorl	%eax, %eax
	ret
	.cfi_endproc
.LFE2845:
	.size	_Z16ejecutar_sgemmNNi, .-_Z16ejecutar_sgemmNNi
	.globl	_Z38__device_stub__Z7sgemmNTPKfiS0_iPfiiffPKfiS0_iPfiiff
	.type	_Z38__device_stub__Z7sgemmNTPKfiS0_iPfiiffPKfiS0_iPfiiff, @function
_Z38__device_stub__Z7sgemmNTPKfiS0_iPfiiffPKfiS0_iPfiiff:
.LFB2871:
	.cfi_startproc
	endbr64
	subq	$200, %rsp
	.cfi_def_cfa_offset 208
	movq	%rdi, 40(%rsp)
	leaq	64(%rsp), %rdi
	movl	%esi, 36(%rsp)
	leaq	76(%rsp), %rsi
	movq	%rdx, 24(%rsp)
	leaq	48(%rsp), %rdx
	movl	%ecx, 32(%rsp)
	leaq	56(%rsp), %rcx
	movq	%r8, 16(%rsp)
	movl	%r9d, 12(%rsp)
	movss	%xmm0, 8(%rsp)
	movss	%xmm1, 4(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 184(%rsp)
	xorl	%eax, %eax
	leaq	40(%rsp), %rax
	movl	$1, 72(%rsp)
	movq	%rax, 112(%rsp)
	leaq	36(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 128(%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 136(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 144(%rsp)
	leaq	12(%rsp), %rax
	movq	%rax, 152(%rsp)
	leaq	208(%rsp), %rax
	movq	%rax, 160(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 168(%rsp)
	leaq	4(%rsp), %rax
	movq	%rax, 176(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 64(%rsp)
	movq	%rax, 76(%rsp)
	movl	$1, 84(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L56
	pushq	56(%rsp)
	.cfi_def_cfa_offset 216
	leaq	sgemmNT(%rip), %rdi
	pushq	56(%rsp)
	.cfi_def_cfa_offset 224
	movq	92(%rsp), %rcx
	movl	100(%rsp), %r8d
	movq	80(%rsp), %rsi
	movl	88(%rsp), %edx
	leaq	128(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 216
	popq	%rdx
	.cfi_def_cfa_offset 208
.L56:
	movq	184(%rsp), %rax
	subq	%fs:40, %rax
	je	.L58
	call	__stack_chk_fail@PLT
.L58:
	addq	$200, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2871:
	.size	_Z38__device_stub__Z7sgemmNTPKfiS0_iPfiiffPKfiS0_iPfiiff, .-_Z38__device_stub__Z7sgemmNTPKfiS0_iPfiiffPKfiS0_iPfiiff
	.globl	sgemmNT
	.type	sgemmNT, @function
sgemmNT:
.LFB2872:
	.cfi_startproc
	endbr64
	jmp	_Z38__device_stub__Z7sgemmNTPKfiS0_iPfiiffPKfiS0_iPfiiff
	.cfi_endproc
.LFE2872:
	.size	sgemmNT, .-sgemmNT
	.globl	_Z38__device_stub__Z7sgemmNNPKfiS0_iPfiiffPKfiS0_iPfiiff
	.type	_Z38__device_stub__Z7sgemmNNPKfiS0_iPfiiffPKfiS0_iPfiiff, @function
_Z38__device_stub__Z7sgemmNNPKfiS0_iPfiiffPKfiS0_iPfiiff:
.LFB2873:
	.cfi_startproc
	endbr64
	subq	$200, %rsp
	.cfi_def_cfa_offset 208
	movq	%rdi, 40(%rsp)
	leaq	64(%rsp), %rdi
	movl	%esi, 36(%rsp)
	leaq	76(%rsp), %rsi
	movq	%rdx, 24(%rsp)
	leaq	48(%rsp), %rdx
	movl	%ecx, 32(%rsp)
	leaq	56(%rsp), %rcx
	movq	%r8, 16(%rsp)
	movl	%r9d, 12(%rsp)
	movss	%xmm0, 8(%rsp)
	movss	%xmm1, 4(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 184(%rsp)
	xorl	%eax, %eax
	leaq	40(%rsp), %rax
	movl	$1, 72(%rsp)
	movq	%rax, 112(%rsp)
	leaq	36(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 128(%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 136(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 144(%rsp)
	leaq	12(%rsp), %rax
	movq	%rax, 152(%rsp)
	leaq	208(%rsp), %rax
	movq	%rax, 160(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 168(%rsp)
	leaq	4(%rsp), %rax
	movq	%rax, 176(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 64(%rsp)
	movq	%rax, 76(%rsp)
	movl	$1, 84(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L61
	pushq	56(%rsp)
	.cfi_def_cfa_offset 216
	leaq	sgemmNN(%rip), %rdi
	pushq	56(%rsp)
	.cfi_def_cfa_offset 224
	movq	92(%rsp), %rcx
	movl	100(%rsp), %r8d
	movq	80(%rsp), %rsi
	movl	88(%rsp), %edx
	leaq	128(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 216
	popq	%rdx
	.cfi_def_cfa_offset 208
.L61:
	movq	184(%rsp), %rax
	subq	%fs:40, %rax
	je	.L63
	call	__stack_chk_fail@PLT
.L63:
	addq	$200, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2873:
	.size	_Z38__device_stub__Z7sgemmNNPKfiS0_iPfiiffPKfiS0_iPfiiff, .-_Z38__device_stub__Z7sgemmNNPKfiS0_iPfiiffPKfiS0_iPfiiff
	.globl	sgemmNN
	.type	sgemmNN, @function
sgemmNN:
.LFB2874:
	.cfi_startproc
	endbr64
	jmp	_Z38__device_stub__Z7sgemmNNPKfiS0_iPfiiffPKfiS0_iPfiiff
	.cfi_endproc
.LFE2874:
	.size	sgemmNN, .-sgemmNN
	.globl	ourSgemm
	.type	ourSgemm, @function
ourSgemm:
.LFB2035:
	.cfi_startproc
	endbr64
	movl	%edx, %eax
	movl	$64, %edi
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	andl	$-33, %esi
	cltd
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	idivl	%edi
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	movl	$16, %edi
	movl	%r8d, %ebx
	movl	$0, %r8d
	movl	112(%rsp), %ebp
	movq	%r9, (%rsp)
	movl	$0, %r9d
	movq	120(%rsp), %r12
	movl	128(%rsp), %r13d
	movss	%xmm0, 8(%rsp)
	movq	136(%rsp), %r14
	movl	144(%rsp), %r15d
	movss	%xmm1, 12(%rsp)
	movl	%eax, 24(%rsp)
	movl	%ecx, %eax
	movl	$1, %ecx
	cltd
	idivl	%edi
	movl	$1073741825, %edx
	salq	$4, %rdx
	cmpb	$78, %sil
	movl	$1, %esi
	movl	%eax, 28(%rsp)
	movq	24(%rsp), %rdi
	jne	.L67
	call	__cudaPushCallConfiguration@PLT
	movss	12(%rsp), %xmm1
	testl	%eax, %eax
	jne	.L66
	movl	%ebx, 112(%rsp)
	movss	8(%rsp), %xmm0
	movl	%r15d, %r9d
	movq	%r14, %r8
	movq	(%rsp), %rdi
	addq	$56, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	movl	%r13d, %ecx
	movq	%r12, %rdx
	popq	%rbx
	.cfi_def_cfa_offset 48
	movl	%ebp, %esi
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	jmp	_Z38__device_stub__Z7sgemmNNPKfiS0_iPfiiffPKfiS0_iPfiiff
.L67:
	.cfi_restore_state
	call	__cudaPushCallConfiguration@PLT
	movss	12(%rsp), %xmm1
	testl	%eax, %eax
	jne	.L66
	movl	%ebx, 112(%rsp)
	movss	8(%rsp), %xmm0
	movl	%r15d, %r9d
	movq	%r14, %r8
	movq	(%rsp), %rdi
	addq	$56, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	movl	%r13d, %ecx
	movq	%r12, %rdx
	popq	%rbx
	.cfi_def_cfa_offset 48
	movl	%ebp, %esi
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	jmp	_Z38__device_stub__Z7sgemmNTPKfiS0_iPfiiffPKfiS0_iPfiiff
.L66:
	.cfi_restore_state
	addq	$56, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2035:
	.size	ourSgemm, .-ourSgemm
	.globl	_Z47__device_stub__Z16vec_mat_vec_multPKfiS0_iPfiffPKfiS0_iPfiff
	.type	_Z47__device_stub__Z16vec_mat_vec_multPKfiS0_iPfiffPKfiS0_iPfiff, @function
_Z47__device_stub__Z16vec_mat_vec_multPKfiS0_iPfiffPKfiS0_iPfiff:
.LFB2875:
	.cfi_startproc
	endbr64
	subq	$200, %rsp
	.cfi_def_cfa_offset 208
	movq	%rdi, 40(%rsp)
	leaq	72(%rsp), %rdi
	movl	%esi, 36(%rsp)
	leaq	84(%rsp), %rsi
	movq	%rdx, 24(%rsp)
	leaq	56(%rsp), %rdx
	movl	%ecx, 32(%rsp)
	leaq	64(%rsp), %rcx
	movq	%r8, 16(%rsp)
	movl	%r9d, 12(%rsp)
	movss	%xmm0, 8(%rsp)
	movss	%xmm1, 4(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 184(%rsp)
	xorl	%eax, %eax
	leaq	40(%rsp), %rax
	movl	$1, 80(%rsp)
	movq	%rax, 120(%rsp)
	leaq	36(%rsp), %rax
	movq	%rax, 128(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 136(%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 144(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 152(%rsp)
	leaq	12(%rsp), %rax
	movq	%rax, 160(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 168(%rsp)
	leaq	4(%rsp), %rax
	movq	%rax, 176(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 72(%rsp)
	movq	%rax, 84(%rsp)
	movl	$1, 92(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L72
	pushq	64(%rsp)
	.cfi_def_cfa_offset 216
	leaq	vec_mat_vec_mult(%rip), %rdi
	pushq	64(%rsp)
	.cfi_def_cfa_offset 224
	movq	100(%rsp), %rcx
	movl	108(%rsp), %r8d
	movq	88(%rsp), %rsi
	movl	96(%rsp), %edx
	leaq	136(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 216
	popq	%rdx
	.cfi_def_cfa_offset 208
.L72:
	movq	184(%rsp), %rax
	subq	%fs:40, %rax
	je	.L74
	call	__stack_chk_fail@PLT
.L74:
	addq	$200, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2875:
	.size	_Z47__device_stub__Z16vec_mat_vec_multPKfiS0_iPfiffPKfiS0_iPfiff, .-_Z47__device_stub__Z16vec_mat_vec_multPKfiS0_iPfiffPKfiS0_iPfiff
	.globl	vec_mat_vec_mult
	.type	vec_mat_vec_mult, @function
vec_mat_vec_mult:
.LFB2876:
	.cfi_startproc
	endbr64
	jmp	_Z47__device_stub__Z16vec_mat_vec_multPKfiS0_iPfiffPKfiS0_iPfiff
	.cfi_endproc
.LFE2876:
	.size	vec_mat_vec_mult, .-vec_mat_vec_mult
	.globl	_Z37__device_stub__Z6vmSymvPKfiS0_iPfiiffPKfiS0_iPfiiff
	.type	_Z37__device_stub__Z6vmSymvPKfiS0_iPfiiffPKfiS0_iPfiiff, @function
_Z37__device_stub__Z6vmSymvPKfiS0_iPfiiffPKfiS0_iPfiiff:
.LFB2877:
	.cfi_startproc
	endbr64
	subq	$200, %rsp
	.cfi_def_cfa_offset 208
	movq	%rdi, 40(%rsp)
	leaq	64(%rsp), %rdi
	movl	%esi, 36(%rsp)
	leaq	76(%rsp), %rsi
	movq	%rdx, 24(%rsp)
	leaq	48(%rsp), %rdx
	movl	%ecx, 32(%rsp)
	leaq	56(%rsp), %rcx
	movq	%r8, 16(%rsp)
	movl	%r9d, 12(%rsp)
	movss	%xmm0, 8(%rsp)
	movss	%xmm1, 4(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 184(%rsp)
	xorl	%eax, %eax
	leaq	40(%rsp), %rax
	movl	$1, 72(%rsp)
	movq	%rax, 112(%rsp)
	leaq	36(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 128(%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 136(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 144(%rsp)
	leaq	12(%rsp), %rax
	movq	%rax, 152(%rsp)
	leaq	208(%rsp), %rax
	movq	%rax, 160(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 168(%rsp)
	leaq	4(%rsp), %rax
	movq	%rax, 176(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 64(%rsp)
	movq	%rax, 76(%rsp)
	movl	$1, 84(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L77
	pushq	56(%rsp)
	.cfi_def_cfa_offset 216
	leaq	vmSymv(%rip), %rdi
	pushq	56(%rsp)
	.cfi_def_cfa_offset 224
	movq	92(%rsp), %rcx
	movl	100(%rsp), %r8d
	movq	80(%rsp), %rsi
	movl	88(%rsp), %edx
	leaq	128(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 216
	popq	%rdx
	.cfi_def_cfa_offset 208
.L77:
	movq	184(%rsp), %rax
	subq	%fs:40, %rax
	je	.L79
	call	__stack_chk_fail@PLT
.L79:
	addq	$200, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2877:
	.size	_Z37__device_stub__Z6vmSymvPKfiS0_iPfiiffPKfiS0_iPfiiff, .-_Z37__device_stub__Z6vmSymvPKfiS0_iPfiiffPKfiS0_iPfiiff
	.globl	vmSymv
	.type	vmSymv, @function
vmSymv:
.LFB2878:
	.cfi_startproc
	endbr64
	jmp	_Z37__device_stub__Z6vmSymvPKfiS0_iPfiiffPKfiS0_iPfiiff
	.cfi_endproc
.LFE2878:
	.size	vmSymv, .-vmSymv
	.globl	_Z33__device_stub__Z3vmvPKfiS0_iPfiffPKfiS0_iPfiff
	.type	_Z33__device_stub__Z3vmvPKfiS0_iPfiffPKfiS0_iPfiff, @function
_Z33__device_stub__Z3vmvPKfiS0_iPfiffPKfiS0_iPfiff:
.LFB2879:
	.cfi_startproc
	endbr64
	subq	$200, %rsp
	.cfi_def_cfa_offset 208
	movq	%rdi, 40(%rsp)
	leaq	72(%rsp), %rdi
	movl	%esi, 36(%rsp)
	leaq	84(%rsp), %rsi
	movq	%rdx, 24(%rsp)
	leaq	56(%rsp), %rdx
	movl	%ecx, 32(%rsp)
	leaq	64(%rsp), %rcx
	movq	%r8, 16(%rsp)
	movl	%r9d, 12(%rsp)
	movss	%xmm0, 8(%rsp)
	movss	%xmm1, 4(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 184(%rsp)
	xorl	%eax, %eax
	leaq	40(%rsp), %rax
	movl	$1, 80(%rsp)
	movq	%rax, 120(%rsp)
	leaq	36(%rsp), %rax
	movq	%rax, 128(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 136(%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 144(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 152(%rsp)
	leaq	12(%rsp), %rax
	movq	%rax, 160(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 168(%rsp)
	leaq	4(%rsp), %rax
	movq	%rax, 176(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 72(%rsp)
	movq	%rax, 84(%rsp)
	movl	$1, 92(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L82
	pushq	64(%rsp)
	.cfi_def_cfa_offset 216
	leaq	vmv(%rip), %rdi
	pushq	64(%rsp)
	.cfi_def_cfa_offset 224
	movq	100(%rsp), %rcx
	movl	108(%rsp), %r8d
	movq	88(%rsp), %rsi
	movl	96(%rsp), %edx
	leaq	136(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 216
	popq	%rdx
	.cfi_def_cfa_offset 208
.L82:
	movq	184(%rsp), %rax
	subq	%fs:40, %rax
	je	.L84
	call	__stack_chk_fail@PLT
.L84:
	addq	$200, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2879:
	.size	_Z33__device_stub__Z3vmvPKfiS0_iPfiffPKfiS0_iPfiff, .-_Z33__device_stub__Z3vmvPKfiS0_iPfiffPKfiS0_iPfiff
	.globl	vmv
	.type	vmv, @function
vmv:
.LFB2880:
	.cfi_startproc
	endbr64
	jmp	_Z33__device_stub__Z3vmvPKfiS0_iPfiffPKfiS0_iPfiff
	.cfi_endproc
.LFE2880:
	.size	vmv, .-vmv
	.section	.rodata.str1.1
.LC17:
	.string	"\nDevice: %s, %.0f MHz clock, %.0f MB memory.\n"
.LC18:
	.string	"%d Elementos.\n"
.LC19:
	.string	"Resultado Final en cuda: %f en %f ms\n"
.LC20:
	.string	"Resultado Final en cpu: %f en %f ms\n"
	.text
	.globl	_Z21ejecutar_matrixVectori
	.type	_Z21ejecutar_matrixVectori, @function
_Z21ejecutar_matrixVectori:
.LFB2846:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$1160, %rsp
	.cfi_def_cfa_offset 1216
	movq	%fs:40, %rax
	movq	%rax, 1144(%rsp)
	movl	$16, %eax
	cmpl	%eax, %edi
	cmovge	%edi, %eax
	xorl	%edi, %edi
	movl	%eax, %ebx
	call	cudaSetDevice@PLT
	movl	$856, %ecx
	testl	%eax, %eax
	jne	.L110
	leaq	112(%rsp), %rbp
	xorl	%esi, %esi
	movq	%rbp, %rdi
	call	cudaGetDeviceProperties_v2@PLT
	testl	%eax, %eax
	je	.L89
	movl	$859, %ecx
.L110:
	leaq	.LC6(%rip), %rdx
	leaq	.LC7(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
.L111:
	call	__printf_chk@PLT
	movl	$1, %edi
	call	exit@PLT
.L89:
	movq	400(%rsp), %rax
	testq	%rax, %rax
	js	.L90
	cvtsi2ssq	%rax, %xmm1
	jmp	.L91
.L90:
	movq	%rax, %rdx
	andl	$1, %eax
	shrq	%rdx
	orq	%rax, %rdx
	cvtsi2ssq	%rdx, %xmm1
	addss	%xmm1, %xmm1
.L91:
	movss	.LC15(%rip), %xmm0
	movq	%rbp, %rdx
	movl	$2, %edi
	movb	$2, %al
	leaq	.LC17(%rip), %rsi
	mulss	%xmm0, %xmm1
	mulss	%xmm0, %xmm1
	cvtsi2ssl	460(%rsp), %xmm0
	divss	.LC16(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	cvtss2sd	%xmm1, %xmm1
	call	__printf_chk@PLT
	leaq	40(%rsp), %rdi
	call	cudaEventCreate@PLT
	movl	$863, %ecx
	testl	%eax, %eax
	jne	.L110
	leaq	48(%rsp), %rdi
	call	cudaEventCreate@PLT
	movl	$864, %ecx
	movl	%eax, %r15d
	testl	%eax, %eax
	jne	.L110
	movl	%ebx, %edx
	leaq	.LC18(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leal	1(%rbx), %edi
	imull	%ebx, %edi
	sarl	%edi
	movslq	%edi, %rdi
	salq	$2, %rdi
	call	malloc@PLT
	movl	%ebx, %esi
	imull	%ebx, %esi
	movq	%rax, %r14
	movslq	%esi, %rax
	movl	%esi, 28(%rsp)
	salq	$2, %rax
	movq	%rax, %rdi
	movq	%rax, 16(%rsp)
	call	malloc@PLT
	movq	%rax, %rbp
	movslq	%ebx, %rax
	salq	$2, %rax
	movq	%rax, %rdi
	movq	%rax, 8(%rsp)
	call	malloc@PLT
	movq	8(%rsp), %rdi
	movq	%rax, %r13
	call	malloc@PLT
	movl	28(%rsp), %esi
	movl	$31, %edx
	movq	%rbp, %rdi
	movq	%rax, %r12
	call	_Z4fillPfii
	movq	%r13, %rdi
	movl	$31, %edx
	movl	%ebx, %esi
	call	_Z4fillPfii
	xorl	%eax, %eax
	xorl	%edi, %edi
	xorl	%r10d, %r10d
.L94:
	movslq	%r15d, %rdx
	movl	%eax, %r9d
	movslq	%edi, %rsi
	leaq	0(%rbp,%rdx,4), %r8
	movq	%rax, %rdx
.L97:
	cmpl	%edx, %ebx
	jle	.L112
	movss	(%r8,%rdx,4), %xmm0
	incq	%rdx
	movss	%xmm0, (%r14,%rsi,4)
	incq	%rsi
	jmp	.L97
.L112:
	movl	%ebx, %edx
	subl	%r9d, %edx
	cmpl	%eax, %ebx
	cmovl	%r10d, %edx
	incq	%rax
	addl	%ebx, %r15d
	addl	%edx, %edi
	cmpl	%eax, %ebx
	jg	.L94
	movl	%ebx, %ecx
	xorl	%eax, %eax
	movq	%r12, %rdi
	movq	16(%rsp), %rsi
	salq	$2, %rcx
	rep stosb
	leaq	56(%rsp), %rdi
	call	cudaMalloc@PLT
	movq	8(%rsp), %rsi
	leaq	64(%rsp), %rdi
	call	cudaMalloc@PLT
	movq	8(%rsp), %rsi
	leaq	72(%rsp), %rdi
	call	cudaMalloc@PLT
	leaq	80(%rsp), %rdi
	movl	$4, %esi
	call	cudaMalloc@PLT
	movq	16(%rsp), %rdx
	movq	56(%rsp), %rdi
	movq	%rbp, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movq	8(%rsp), %rdx
	movq	64(%rsp), %rdi
	movq	%r13, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movq	8(%rsp), %rdx
	movq	72(%rsp), %rdi
	movq	%r12, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	call	clock@PLT
	movl	$134217729, %edx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movq	%rax, %r15
	movl	%ebx, %eax
	salq	$5, %rdx
	movl	$1, %ecx
	sarl	$5, %eax
	movl	%eax, 88(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 92(%rsp)
	movq	88(%rsp), %rdi
	movl	96(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L98
	movss	.LC0(%rip), %xmm0
	xorps	%xmm1, %xmm1
	movl	%ebx, %r9d
	movl	%ebx, %ecx
	movq	72(%rsp), %r8
	movq	56(%rsp), %rdx
	movl	%ebx, %esi
	movq	64(%rsp), %rdi
	call	_Z33__device_stub__Z3vmvPKfiS0_iPfiffPKfiS0_iPfiff
.L98:
	call	cudaDeviceSynchronize@PLT
	movq	8(%rsp), %rdx
	movq	72(%rsp), %rsi
	movq	%r12, %rdi
	movl	$2, %ecx
	call	cudaMemcpy@PLT
	xorps	%xmm0, %xmm0
	movl	%eax, %edx
	xorl	%eax, %eax
	testl	%edx, %edx
	je	.L99
	movl	$953, %ecx
	leaq	.LC6(%rip), %rdx
	movl	$2, %edi
	leaq	.LC7(%rip), %rsi
	jmp	.L111
.L99:
	addss	(%r12,%rax,4), %xmm0
	incq	%rax
	cmpl	%eax, %ebx
	jg	.L99
	movss	%xmm0, 16(%rsp)
	call	clock@PLT
	movss	16(%rsp), %xmm0
	movl	$2, %edi
	leaq	.LC19(%rip), %rsi
	subq	%r15, %rax
	cvtsi2sdq	%rax, %xmm1
	divsd	.LC12(%rip), %xmm1
	movb	$2, %al
	cvtss2sd	%xmm0, %xmm0
	mulsd	.LC13(%rip), %xmm1
	call	__printf_chk@PLT
	call	clock@PLT
	xorl	%ecx, %ecx
	xorps	%xmm0, %xmm0
	movq	%rax, %r15
.L100:
	xorl	%edx, %edx
	xorps	%xmm1, %xmm1
.L101:
	movss	0(%r13,%rdx,4), %xmm2
	mulss	0(%rbp,%rdx,4), %xmm2
	incq	%rdx
	addss	%xmm2, %xmm1
	cmpl	%edx, %ebx
	jg	.L101
	mulss	0(%r13,%rcx,4), %xmm1
	movq	8(%rsp), %rax
	incq	%rcx
	addq	%rax, %rbp
	addss	%xmm1, %xmm0
	cmpl	%ecx, %ebx
	jg	.L100
	movss	%xmm0, 8(%rsp)
	call	clock@PLT
	movss	8(%rsp), %xmm0
	movl	$2, %edi
	leaq	.LC20(%rip), %rsi
	subq	%r15, %rax
	cvtsi2sdq	%rax, %xmm1
	divsd	.LC12(%rip), %xmm1
	movb	$2, %al
	cvtss2sd	%xmm0, %xmm0
	mulsd	.LC13(%rip), %xmm1
	call	__printf_chk@PLT
	movq	64(%rsp), %rdi
	call	cudaFree@PLT
	movq	56(%rsp), %rdi
	call	cudaFree@PLT
	movq	72(%rsp), %rdi
	call	cudaFree@PLT
	movq	%r13, %rdi
	call	free@PLT
	movq	%r14, %rdi
	call	free@PLT
	movq	%r12, %rdi
	call	free@PLT
	movq	1144(%rsp), %rax
	subq	%fs:40, %rax
	je	.L103
	call	__stack_chk_fail@PLT
.L103:
	addq	$1160, %rsp
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2846:
	.size	_Z21ejecutar_matrixVectori, .-_Z21ejecutar_matrixVectori
	.section	.rodata.str1.1
.LC21:
	.string	"vmv"
.LC22:
	.string	"vmSymv"
.LC23:
	.string	"vec_mat_vec_mult"
.LC24:
	.string	"sgemmNN"
.LC25:
	.string	"sgemmNT"
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2882:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	pushq	$0
	.cfi_def_cfa_offset 24
	xorl	%r9d, %r9d
	orl	$-1, %r8d
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC21(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	vmv(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 48
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r9d, %r9d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC22(%rip), %rdx
	orl	$-1, %r8d
	leaq	vmSymv(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 40
	pushq	$0
	.cfi_def_cfa_offset 48
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r9d, %r9d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC23(%rip), %rdx
	orl	$-1, %r8d
	leaq	vec_mat_vec_mult(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 40
	pushq	$0
	.cfi_def_cfa_offset 48
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r9d, %r9d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC24(%rip), %rdx
	orl	$-1, %r8d
	leaq	sgemmNN(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 40
	pushq	$0
	.cfi_def_cfa_offset 48
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r9d, %r9d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC25(%rip), %rdx
	orl	$-1, %r8d
	leaq	sgemmNT(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 40
	pushq	$0
	.cfi_def_cfa_offset 48
	call	__cudaRegisterFunction@PLT
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE2882:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.section	.rodata.cst4,"aM",@progbits,4
	.align 4
.LC0:
	.long	1065353216
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC2:
	.long	2147483647
	.long	0
	.long	0
	.long	0
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC12:
	.long	0
	.long	1093567616
	.align 8
.LC13:
	.long	0
	.long	1083129856
	.section	.rodata.cst4
	.align 4
.LC15:
	.long	981467136
	.align 4
.LC16:
	.long	1148846080
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

#ifndef CUDA_SGEMMN_H
#define CUDA_SGEMMN_H

// Written by Vasily Volkov.
// Copyright (c) 2008, The Regents of the University of California. 
// All rights reserved.

#include <stdio.h>
#include "hip/hip_runtime.h"

#define TIMER_TOLERANCE 0.1f

#define BEGIN_TIMING( )	\
{\
    unsigned int n_iterations;	\
    for( n_iterations = 1; n_iterations < 0x80000000; n_iterations *= 2 )\
    {\
        Q( hipDeviceSynchronize( ) );\
        Q( hipEventRecord( start, 0 ) );\
        for( unsigned int iteration = 0; iteration < n_iterations; iteration++ ){

#define END_TIMING( seconds ) }\
        Q( hipEventRecord( end, 0 ) );\
        Q( hipEventSynchronize( end ) );\
        float milliseconds;\
        Q( hipEventElapsedTime( &milliseconds, start, end ) );\
        seconds = milliseconds/1e3f;\
        if( seconds >= TIMER_TOLERANCE )\
            break;\
    }\
    seconds /= n_iterations;\
}

#define Q( condition ) {if( (condition) != 0 ) { printf( "\n FAILURE in %s, line %d\n", __FILE__, __LINE__ );exit( 1 );}}

int ejecutar_sgemmNN( int items/*int argc, char **argv */);	
int ejecutar_matrixVector( int items/*int argc, char **argv */);	

int cublas_example();

#endif
	.text
	.file	"sgemmN.hip"
	.type	__hip_cuid_,@object             # @__hip_cuid_
	.bss
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               # 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __hip_cuid_

	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __hip_cuid_
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.amdgpu_metadata
---
amdhsa.kernels:  []
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
