#include <stdio.h>
#include <stdlib.h>
 

__host__ double** getWeightMatrix(int rows, int cols)
{
    FILE *myFile;
    myFile = fopen("WMatrix.txt", "r");

    double** mat;
    cudaMallocManaged(&mat, rows * sizeof(double*));

    for (int i = 0; i < rows; i++)
    {
        cudaMallocManaged(&(mat[i]), cols * sizeof(double));

        fscanf(myFile, "%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,", 
            &(mat[i][0]), &(mat[i][1]), &(mat[i][2]), &(mat[i][3]), &(mat[i][4]),
            &(mat[i][5]), &(mat[i][6]), &(mat[i][7]), &(mat[i][8]), &(mat[i][9])
        );
    }
    fclose(myFile);

    return mat;
}

__host__ double* getBVector(int cols)
{
    FILE *myFile;
    myFile = fopen("bVector.txt", "r");

    double* vector;
    cudaMallocManaged(&vector, cols * sizeof(double));

    fscanf(myFile, "%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,", 
        &(vector[0]), &(vector[1]), &(vector[2]), &(vector[3]), &(vector[4]),
        &(vector[5]), &(vector[6]), &(vector[7]), &(vector[8]), &(vector[9])
    );
    
    fclose(myFile);

    return vector;
}

__host__ void printMatrix(double **mat, int rows, int cols)
{
    for (int i = 0; i < rows; i++)
    {
        printf("[");
        for (int j = 0; j < cols; j++)
        {
            printf("%0.10lf\t", mat[i][j]);
        }
        printf("]\n");
    }
    printf("\n");
}

__host__ void getMNISTTest(int indice, int* label, int* vector, int rows, int cols)
{
    if (indice > 10000)
    {
        printf("Solo hay 10,000 datos de test !");
        return;
    }

    FILE *myFile;
    myFile = fopen("mnist_test.csv", "r");

    for (int i = 0; i < indice; i++)
    {
        fscanf(myFile, "%*[^\n]\n");
    }

    fscanf(myFile, "%d", label);

    fscanf(myFile, ",");

    for (int j = 0; j < rows; j++)
    {
        fscanf(myFile, "%d,", &(vector[j]));
    }

    fclose(myFile);
}

__host__ void printImage(int label, int* vector, int rows)
{
    for (int j = 0, x; j < rows; j++)
    {
        x = vector[j];

        if (x == 0)
        {
            printf("--");
        }
        else
        {
            printf("%d%d", label, label);
        }

        if ((j + 1) % 28 == 0)
        {
            printf("\n");
        }
    }
    printf("\n");
}

__host__ double getMaxIndex(double* y, int cols)
{
    double max = y[0];
    int maxIndex = -1;

    for (int i = 0; i < cols; i++)
    {
        if (y[i] >= max)
        {
            max = y[i];
            maxIndex = i;
        }
    }
    return maxIndex;   
}

__global__ void productMatrixVectorKernel(int* X, double** W, double* WX, int cols)
{
    int j = threadIdx.y;

    double sum = 0;
    for (int k = 0; k < cols; k++)
    {
        sum += X[k] * W[k][j];
    }
    WX[j] = sum;

    __syncthreads();
}

__global__ void SumVectorVectorKernel(double* WX, double* b, double* y)
{
    int j = threadIdx.y;
    
    y[j] = WX[j] + b[j];

    __syncthreads();
}

int main()
{
    int rows = 784;
    int cols = 10;
    int indexTest = 44;

    double** W = getWeightMatrix(rows, cols);
    double* b = getBVector(cols);

    int label;
    int* X; 
    cudaMallocManaged(&X, rows * sizeof(int));
    double* WX;
    cudaMallocManaged(&WX, cols * sizeof(double));
    double* y;
    cudaMallocManaged(&y, cols * sizeof(double));

    int prediction;

    while(1)
    {
        printf("Indice del Data Set: ");
        scanf("%d", &indexTest);
        if (indexTest > 10000)
        {
            printf("Solo hay 10,000 datos\n\n");
            continue;
        }

        getMNISTTest(indexTest, &label, X, rows, cols);

        dim3 blocksPerGrid(1);
        dim3 threadsPerBlock(1, cols);

        productMatrixVectorKernel<<< blocksPerGrid, threadsPerBlock >>>(X, W, WX, rows);
        cudaDeviceSynchronize();

        SumVectorVectorKernel<<< blocksPerGrid, threadsPerBlock >>>(WX, b, y);
        cudaDeviceSynchronize();

        prediction = getMaxIndex(y, cols);
        printf("Original %d, Prediccion %d\n", label, prediction);

        printImage(label, X, rows);
    }
}

	.file	"tmpxft_002a9ca8_00000000-6_pFinal.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2036:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2036:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"r"
.LC1:
	.string	"WMatrix.txt"
.LC2:
	.string	"%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,"
	.text
	.globl	_Z15getWeightMatrixii
	.type	_Z15getWeightMatrixii, @function
_Z15getWeightMatrixii:
.LFB2027:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	leaq	.LC2(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	movl	%edi, %r13d
	leaq	.LC1(%rip), %rdi
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	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
	movslq	%esi, %rbx
	leaq	.LC0(%rip), %rsi
	salq	$3, %rbx
	subq	$16, %rsp
	.cfi_def_cfa_offset 64
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	call	fopen@PLT
	movslq	%r13d, %rsi
	movq	%rsp, %rdi
	movl	$1, %edx
	salq	$3, %rsi
	movq	%rax, %r12
	call	cudaMallocManaged@PLT
.L3:
	cmpl	%ebp, %r13d
	jle	.L8
	movq	(%rsp), %rax
	movl	$1, %edx
	movq	%rbx, %rsi
	leaq	(%rax,%rbp,8), %rdi
	call	cudaMallocManaged@PLT
	movq	(%rsp), %rax
	movq	%r14, %rsi
	movq	%r12, %rdi
	movq	(%rax,%rbp,8), %rdx
	incq	%rbp
	leaq	72(%rdx), %rax
	leaq	8(%rdx), %rcx
	pushq	%rax
	.cfi_def_cfa_offset 72
	leaq	64(%rdx), %rax
	leaq	24(%rdx), %r9
	pushq	%rax
	.cfi_def_cfa_offset 80
	leaq	56(%rdx), %rax
	leaq	16(%rdx), %r8
	pushq	%rax
	.cfi_def_cfa_offset 88
	leaq	48(%rdx), %rax
	pushq	%rax
	.cfi_def_cfa_offset 96
	leaq	40(%rdx), %rax
	pushq	%rax
	.cfi_def_cfa_offset 104
	leaq	32(%rdx), %rax
	pushq	%rax
	.cfi_def_cfa_offset 112
	xorl	%eax, %eax
	call	__isoc23_fscanf@PLT
	addq	$48, %rsp
	.cfi_def_cfa_offset 64
	jmp	.L3
.L8:
	movq	%r12, %rdi
	call	fclose@PLT
	movq	(%rsp), %rax
	movq	8(%rsp), %rdx
	subq	%fs:40, %rdx
	je	.L5
	call	__stack_chk_fail@PLT
.L5:
	addq	$16, %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
.LFE2027:
	.size	_Z15getWeightMatrixii, .-_Z15getWeightMatrixii
	.section	.rodata.str1.1
.LC3:
	.string	"bVector.txt"
	.text
	.globl	_Z10getBVectori
	.type	_Z10getBVectori, @function
_Z10getBVectori:
.LFB2028:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	leaq	.LC0(%rip), %rsi
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	movl	%edi, %ebx
	leaq	.LC3(%rip), %rdi
	subq	$24, %rsp
	.cfi_def_cfa_offset 48
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	call	fopen@PLT
	movslq	%ebx, %rsi
	movq	%rsp, %rdi
	movl	$1, %edx
	salq	$3, %rsi
	movq	%rax, %rbp
	call	cudaMallocManaged@PLT
	movq	(%rsp), %rdx
	leaq	.LC2(%rip), %rsi
	movq	%rbp, %rdi
	leaq	72(%rdx), %rax
	leaq	8(%rdx), %rcx
	pushq	%rax
	.cfi_def_cfa_offset 56
	leaq	64(%rdx), %rax
	leaq	24(%rdx), %r9
	pushq	%rax
	.cfi_def_cfa_offset 64
	leaq	56(%rdx), %rax
	leaq	16(%rdx), %r8
	pushq	%rax
	.cfi_def_cfa_offset 72
	leaq	48(%rdx), %rax
	pushq	%rax
	.cfi_def_cfa_offset 80
	leaq	40(%rdx), %rax
	pushq	%rax
	.cfi_def_cfa_offset 88
	leaq	32(%rdx), %rax
	pushq	%rax
	.cfi_def_cfa_offset 96
	xorl	%eax, %eax
	call	__isoc23_fscanf@PLT
	addq	$48, %rsp
	.cfi_def_cfa_offset 48
	movq	%rbp, %rdi
	call	fclose@PLT
	movq	(%rsp), %rax
	movq	8(%rsp), %rdx
	subq	%fs:40, %rdx
	je	.L10
	call	__stack_chk_fail@PLT
.L10:
	addq	$24, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2028:
	.size	_Z10getBVectori, .-_Z10getBVectori
	.section	.rodata.str1.1
.LC4:
	.string	"["
.LC5:
	.string	"%0.10lf\t"
.LC6:
	.string	"]\n"
.LC7:
	.string	"\n"
	.text
	.globl	_Z11printMatrixPPdii
	.type	_Z11printMatrixPPdii, @function
_Z11printMatrixPPdii:
.LFB2029:
	.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
	movl	%edx, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movq	%rdi, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movl	%esi, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	xorl	%ebx, %ebx
	pushq	%rcx
	.cfi_def_cfa_offset 64
.L13:
	cmpl	%ebx, %ebp
	jle	.L18
	leaq	.LC4(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	xorl	%r14d, %r14d
	call	__printf_chk@PLT
	leaq	.LC5(%rip), %r15
.L14:
	cmpl	%r14d, %r13d
	jle	.L19
	movq	(%r12,%rbx,8), %rax
	movq	%r15, %rsi
	movl	$2, %edi
	movsd	(%rax,%r14,8), %xmm0
	movb	$1, %al
	incq	%r14
	call	__printf_chk@PLT
	jmp	.L14
.L19:
	leaq	.LC6(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	incq	%rbx
	call	__printf_chk@PLT
	jmp	.L13
.L18:
	popq	%rdx
	.cfi_def_cfa_offset 56
	leaq	.LC7(%rip), %rsi
	popq	%rbx
	.cfi_def_cfa_offset 48
	movl	$2, %edi
	popq	%rbp
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	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	__printf_chk@PLT
	.cfi_endproc
.LFE2029:
	.size	_Z11printMatrixPPdii, .-_Z11printMatrixPPdii
	.section	.rodata.str1.1
.LC8:
	.string	"Solo hay 10,000 datos de test !"
.LC9:
	.string	"mnist_test.csv"
.LC10:
	.string	"%*[^\n]\n"
.LC11:
	.string	"%d"
.LC12:
	.string	","
.LC13:
	.string	"%d,"
	.text
	.globl	_Z12getMNISTTestiPiS_ii
	.type	_Z12getMNISTTestiPiS_ii, @function
_Z12getMNISTTestiPiS_ii:
.LFB2030:
	.cfi_startproc
	endbr64
	cmpl	$10000, %edi
	jle	.L21
	leaq	.LC8(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	jmp	__printf_chk@PLT
.L21:
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	.LC10(%rip), %r15
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movq	%rsi, %r14
	leaq	.LC0(%rip), %rsi
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movl	%ecx, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movl	%edi, %r12d
	leaq	.LC9(%rip), %rdi
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%rdx, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	xorl	%ebx, %ebx
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	call	fopen@PLT
	movq	%rax, 8(%rsp)
.L22:
	cmpl	%ebx, %r12d
	jle	.L28
	movq	8(%rsp), %rdi
	movq	%r15, %rsi
	xorl	%eax, %eax
	incl	%ebx
	call	__isoc23_fscanf@PLT
	jmp	.L22
.L28:
	movq	8(%rsp), %rdi
	movq	%r14, %rdx
	xorl	%eax, %eax
	xorl	%r12d, %r12d
	leaq	.LC11(%rip), %rsi
	leaq	.LC13(%rip), %r14
	call	__isoc23_fscanf@PLT
	movq	8(%rsp), %rdi
	leaq	.LC12(%rip), %rsi
	xorl	%eax, %eax
	call	__isoc23_fscanf@PLT
.L24:
	cmpl	%r12d, %r13d
	jle	.L29
	movq	8(%rsp), %rdi
	movq	%rbp, %rdx
	movq	%r14, %rsi
	xorl	%eax, %eax
	incl	%r12d
	addq	$4, %rbp
	call	__isoc23_fscanf@PLT
	jmp	.L24
.L29:
	movq	8(%rsp), %rdi
	addq	$24, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_restore 3
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_restore 6
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_restore 12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_restore 13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_restore 14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_restore 15
	.cfi_def_cfa_offset 8
	jmp	fclose@PLT
	.cfi_endproc
.LFE2030:
	.size	_Z12getMNISTTestiPiS_ii, .-_Z12getMNISTTestiPiS_ii
	.section	.rodata.str1.1
.LC14:
	.string	"--"
.LC15:
	.string	"%d%d"
	.text
	.globl	_Z10printImageiPii
	.type	_Z10printImageiPii, @function
_Z10printImageiPii:
.LFB2031:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	leaq	.LC15(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	movq	%rsi, %r13
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	movl	%edx, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	movl	%edi, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	xorl	%ebx, %ebx
.L31:
	cmpl	%ebx, %r12d
	jle	.L37
	cmpl	$0, 0(%r13,%rbx,4)
	jne	.L32
	leaq	.LC14(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L33
.L32:
	movl	%ebp, %ecx
	movl	%ebp, %edx
	movq	%r14, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L33:
	leal	1(%rbx), %eax
	movl	$28, %ecx
	cltd
	idivl	%ecx
	testl	%edx, %edx
	jne	.L34
	leaq	.LC7(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L34:
	incq	%rbx
	jmp	.L31
.L37:
	popq	%rbx
	.cfi_def_cfa_offset 40
	leaq	.LC7(%rip), %rsi
	popq	%rbp
	.cfi_def_cfa_offset 32
	movl	$2, %edi
	popq	%r12
	.cfi_def_cfa_offset 24
	xorl	%eax, %eax
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	jmp	__printf_chk@PLT
	.cfi_endproc
.LFE2031:
	.size	_Z10printImageiPii, .-_Z10printImageiPii
	.globl	_Z11getMaxIndexPdi
	.type	_Z11getMaxIndexPdi, @function
_Z11getMaxIndexPdi:
.LFB2032:
	.cfi_startproc
	endbr64
	movsd	(%rdi), %xmm0
	xorl	%eax, %eax
	orl	$-1, %edx
.L39:
	cmpl	%eax, %esi
	jle	.L44
	movsd	(%rdi,%rax,8), %xmm1
	comisd	%xmm0, %xmm1
	jb	.L40
	movl	%eax, %edx
	movaps	%xmm1, %xmm0
.L40:
	incq	%rax
	jmp	.L39
.L44:
	cvtsi2sdl	%edx, %xmm0
	ret
	.cfi_endproc
.LFE2032:
	.size	_Z11getMaxIndexPdi, .-_Z11getMaxIndexPdi
	.globl	_Z52__device_stub__Z25productMatrixVectorKernelPiPPdS0_iPiPPdS0_i
	.type	_Z52__device_stub__Z25productMatrixVectorKernelPiPPdS0_iPiPPdS0_i, @function
_Z52__device_stub__Z25productMatrixVectorKernelPiPPdS0_iPiPPdS0_i:
.LFB2058:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movq	%rdi, 24(%rsp)
	leaq	56(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	68(%rsp), %rsi
	movq	%rdx, 8(%rsp)
	leaq	40(%rsp), %rdx
	movl	%ecx, 4(%rsp)
	leaq	48(%rsp), %rcx
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 64(%rsp)
	movq	%rax, 104(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	4(%rsp), %rax
	movq	%rax, 128(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 56(%rsp)
	movq	%rax, 68(%rsp)
	movl	$1, 76(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L45
	pushq	48(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z25productMatrixVectorKernelPiPPdS0_i(%rip), %rdi
	pushq	48(%rsp)
	.cfi_def_cfa_offset 176
	movq	84(%rsp), %rcx
	movl	92(%rsp), %r8d
	movq	72(%rsp), %rsi
	movl	80(%rsp), %edx
	leaq	120(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 168
	popq	%rdx
	.cfi_def_cfa_offset 160
.L45:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L47
	call	__stack_chk_fail@PLT
.L47:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2058:
	.size	_Z52__device_stub__Z25productMatrixVectorKernelPiPPdS0_iPiPPdS0_i, .-_Z52__device_stub__Z25productMatrixVectorKernelPiPPdS0_iPiPPdS0_i
	.globl	_Z25productMatrixVectorKernelPiPPdS0_i
	.type	_Z25productMatrixVectorKernelPiPPdS0_i, @function
_Z25productMatrixVectorKernelPiPPdS0_i:
.LFB2059:
	.cfi_startproc
	endbr64
	jmp	_Z52__device_stub__Z25productMatrixVectorKernelPiPPdS0_iPiPPdS0_i
	.cfi_endproc
.LFE2059:
	.size	_Z25productMatrixVectorKernelPiPPdS0_i, .-_Z25productMatrixVectorKernelPiPPdS0_i
	.globl	_Z45__device_stub__Z21SumVectorVectorKernelPdS_S_PdS_S_
	.type	_Z45__device_stub__Z21SumVectorVectorKernelPdS_S_PdS_S_, @function
_Z45__device_stub__Z21SumVectorVectorKernelPdS_S_PdS_S_:
.LFB2060:
	.cfi_startproc
	endbr64
	subq	$136, %rsp
	.cfi_def_cfa_offset 144
	movq	%rdi, 24(%rsp)
	leaq	40(%rsp), %rcx
	leaq	48(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	60(%rsp), %rsi
	movq	%rdx, 8(%rsp)
	leaq	32(%rsp), %rdx
	movq	%fs:40, %rax
	movq	%rax, 120(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 56(%rsp)
	movq	%rax, 96(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 104(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 112(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 48(%rsp)
	movq	%rax, 60(%rsp)
	movl	$1, 68(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L50
	pushq	40(%rsp)
	.cfi_def_cfa_offset 152
	leaq	_Z21SumVectorVectorKernelPdS_S_(%rip), %rdi
	pushq	40(%rsp)
	.cfi_def_cfa_offset 160
	movq	76(%rsp), %rcx
	movl	84(%rsp), %r8d
	movq	64(%rsp), %rsi
	movl	72(%rsp), %edx
	leaq	112(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 152
	popq	%rdx
	.cfi_def_cfa_offset 144
.L50:
	movq	120(%rsp), %rax
	subq	%fs:40, %rax
	je	.L52
	call	__stack_chk_fail@PLT
.L52:
	addq	$136, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2060:
	.size	_Z45__device_stub__Z21SumVectorVectorKernelPdS_S_PdS_S_, .-_Z45__device_stub__Z21SumVectorVectorKernelPdS_S_PdS_S_
	.globl	_Z21SumVectorVectorKernelPdS_S_
	.type	_Z21SumVectorVectorKernelPdS_S_, @function
_Z21SumVectorVectorKernelPdS_S_:
.LFB2061:
	.cfi_startproc
	endbr64
	jmp	_Z45__device_stub__Z21SumVectorVectorKernelPdS_S_PdS_S_
	.cfi_endproc
.LFE2061:
	.size	_Z21SumVectorVectorKernelPdS_S_, .-_Z21SumVectorVectorKernelPdS_S_
	.section	.rodata.str1.1
.LC16:
	.string	"Indice del Data Set: "
.LC17:
	.string	"Solo hay 10,000 datos\n\n"
.LC18:
	.string	"Original %d, Prediccion %d\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2033:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movl	$10, %esi
	movl	$784, %edi
	leaq	.LC16(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	subq	$64, %rsp
	.cfi_def_cfa_offset 96
	movq	%fs:40, %rax
	movq	%rax, 56(%rsp)
	xorl	%eax, %eax
	movl	$44, (%rsp)
	call	_Z15getWeightMatrixii
	movl	$10, %edi
	movq	%rax, %rbx
	call	_Z10getBVectori
	leaq	8(%rsp), %rdi
	movl	$1, %edx
	movl	$3136, %esi
	movq	%rax, %rbp
	call	cudaMallocManaged@PLT
	leaq	16(%rsp), %rdi
	movl	$1, %edx
	movl	$80, %esi
	call	cudaMallocManaged@PLT
	leaq	24(%rsp), %rdi
	movl	$1, %edx
	movl	$80, %esi
	call	cudaMallocManaged@PLT
.L56:
	movq	%r12, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	.LC11(%rip), %rdi
	movq	%rsp, %rsi
	xorl	%eax, %eax
	call	__isoc23_scanf@PLT
	movl	(%rsp), %edi
	cmpl	$10000, %edi
	jle	.L57
	leaq	.LC17(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L56
.L57:
	movq	8(%rsp), %rdx
	leaq	4(%rsp), %rsi
	movl	$10, %r8d
	movl	$784, %ecx
	call	_Z12getMNISTTestiPiS_ii
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	$1, %ecx
	movabsq	$4294967297, %rdi
	movl	$1, %esi
	movabsq	$42949672961, %rdx
	movl	$1, 40(%rsp)
	movq	%rdi, 32(%rsp)
	movq	%rdx, 44(%rsp)
	movl	$1, 52(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L59
	movq	16(%rsp), %rdx
	movq	8(%rsp), %rdi
	movl	$784, %ecx
	movq	%rbx, %rsi
	call	_Z52__device_stub__Z25productMatrixVectorKernelPiPPdS0_iPiPPdS0_i
.L59:
	call	cudaDeviceSynchronize@PLT
	movl	52(%rsp), %ecx
	movl	40(%rsp), %esi
	xorl	%r9d, %r9d
	movq	44(%rsp), %rdx
	movq	32(%rsp), %rdi
	xorl	%r8d, %r8d
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L60
	movq	24(%rsp), %rdx
	movq	16(%rsp), %rdi
	movq	%rbp, %rsi
	call	_Z45__device_stub__Z21SumVectorVectorKernelPdS_S_PdS_S_
.L60:
	call	cudaDeviceSynchronize@PLT
	movq	24(%rsp), %rdi
	movl	$10, %esi
	call	_Z11getMaxIndexPdi
	movl	4(%rsp), %edx
	movl	$2, %edi
	xorl	%eax, %eax
	cvttsd2sil	%xmm0, %ecx
	leaq	.LC18(%rip), %rsi
	call	__printf_chk@PLT
	movq	8(%rsp), %rsi
	movl	4(%rsp), %edi
	movl	$784, %edx
	call	_Z10printImageiPii
	jmp	.L56
	.cfi_endproc
.LFE2033:
	.size	main, .-main
	.section	.rodata.str1.1
.LC19:
	.string	"_Z21SumVectorVectorKernelPdS_S_"
.LC20:
	.string	"_Z25productMatrixVectorKernelPiPPdS0_i"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2063:
	.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	.LC19(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z21SumVectorVectorKernelPdS_S_(%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	.LC20(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z25productMatrixVectorKernelPiPPdS0_i(%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
.LFE2063:
	.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
	.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:


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

__host__ double** getWeightMatrix(int rows, int cols)
{
    FILE *myFile;
    myFile = fopen("WMatrix.txt", "r");

    double** mat;
    hipMallocManaged(&mat, rows * sizeof(double*));

    for (int i = 0; i < rows; i++)
    {
        hipMallocManaged(&(mat[i]), cols * sizeof(double));

        fscanf(myFile, "%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,", 
            &(mat[i][0]), &(mat[i][1]), &(mat[i][2]), &(mat[i][3]), &(mat[i][4]),
            &(mat[i][5]), &(mat[i][6]), &(mat[i][7]), &(mat[i][8]), &(mat[i][9])
        );
    }
    fclose(myFile);

    return mat;
}

__host__ double* getBVector(int cols)
{
    FILE *myFile;
    myFile = fopen("bVector.txt", "r");

    double* vector;
    hipMallocManaged(&vector, cols * sizeof(double));

    fscanf(myFile, "%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,", 
        &(vector[0]), &(vector[1]), &(vector[2]), &(vector[3]), &(vector[4]),
        &(vector[5]), &(vector[6]), &(vector[7]), &(vector[8]), &(vector[9])
    );
    
    fclose(myFile);

    return vector;
}

__host__ void printMatrix(double **mat, int rows, int cols)
{
    for (int i = 0; i < rows; i++)
    {
        printf("[");
        for (int j = 0; j < cols; j++)
        {
            printf("%0.10lf\t", mat[i][j]);
        }
        printf("]\n");
    }
    printf("\n");
}

__host__ void getMNISTTest(int indice, int* label, int* vector, int rows, int cols)
{
    if (indice > 10000)
    {
        printf("Solo hay 10,000 datos de test !");
        return;
    }

    FILE *myFile;
    myFile = fopen("mnist_test.csv", "r");

    for (int i = 0; i < indice; i++)
    {
        fscanf(myFile, "%*[^\n]\n");
    }

    fscanf(myFile, "%d", label);

    fscanf(myFile, ",");

    for (int j = 0; j < rows; j++)
    {
        fscanf(myFile, "%d,", &(vector[j]));
    }

    fclose(myFile);
}

__host__ void printImage(int label, int* vector, int rows)
{
    for (int j = 0, x; j < rows; j++)
    {
        x = vector[j];

        if (x == 0)
        {
            printf("--");
        }
        else
        {
            printf("%d%d", label, label);
        }

        if ((j + 1) % 28 == 0)
        {
            printf("\n");
        }
    }
    printf("\n");
}

__host__ double getMaxIndex(double* y, int cols)
{
    double max = y[0];
    int maxIndex = -1;

    for (int i = 0; i < cols; i++)
    {
        if (y[i] >= max)
        {
            max = y[i];
            maxIndex = i;
        }
    }
    return maxIndex;   
}

__global__ void productMatrixVectorKernel(int* X, double** W, double* WX, int cols)
{
    int j = threadIdx.y;

    double sum = 0;
    for (int k = 0; k < cols; k++)
    {
        sum += X[k] * W[k][j];
    }
    WX[j] = sum;

    __syncthreads();
}

__global__ void SumVectorVectorKernel(double* WX, double* b, double* y)
{
    int j = threadIdx.y;
    
    y[j] = WX[j] + b[j];

    __syncthreads();
}

int main()
{
    int rows = 784;
    int cols = 10;
    int indexTest = 44;

    double** W = getWeightMatrix(rows, cols);
    double* b = getBVector(cols);

    int label;
    int* X; 
    hipMallocManaged(&X, rows * sizeof(int));
    double* WX;
    hipMallocManaged(&WX, cols * sizeof(double));
    double* y;
    hipMallocManaged(&y, cols * sizeof(double));

    int prediction;

    while(1)
    {
        printf("Indice del Data Set: ");
        scanf("%d", &indexTest);
        if (indexTest > 10000)
        {
            printf("Solo hay 10,000 datos\n\n");
            continue;
        }

        getMNISTTest(indexTest, &label, X, rows, cols);

        dim3 blocksPerGrid(1);
        dim3 threadsPerBlock(1, cols);

        productMatrixVectorKernel<<< blocksPerGrid, threadsPerBlock >>>(X, W, WX, rows);
        hipDeviceSynchronize();

        SumVectorVectorKernel<<< blocksPerGrid, threadsPerBlock >>>(WX, b, y);
        hipDeviceSynchronize();

        prediction = getMaxIndex(y, cols);
        printf("Original %d, Prediccion %d\n", label, prediction);

        printImage(label, X, rows);
    }
}

	.text
	.file	"pFinal.hip"
	.globl	_Z15getWeightMatrixii           # -- Begin function _Z15getWeightMatrixii
	.type	_Z15getWeightMatrixii,@function
_Z15getWeightMatrixii:                  # @_Z15getWeightMatrixii
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	%esi, %r14d
	movl	%edi, %ebp
	movl	$.L.str, %edi
	movl	$.L.str.1, %esi
	callq	fopen
	movq	%rax, 8(%rsp)                   # 8-byte Spill
	movslq	%ebp, %r15
	leaq	(,%r15,8), %rsi
	movq	%rsp, %rdi
	movl	$1, %edx
	callq	hipMallocManaged
	testl	%r15d, %r15d
	jle	.LBB0_3
# %bb.1:                                # %.lr.ph
	movslq	%r14d, %rax
	shlq	$3, %rax
	movq	%rax, 16(%rsp)                  # 8-byte Spill
	movl	%ebp, %r15d
	shlq	$3, %r15
	xorl	%r12d, %r12d
.LBB0_2:                                # =>This Inner Loop Header: Depth=1
	movq	(%rsp), %rdi
	addq	%r12, %rdi
	movq	16(%rsp), %rsi                  # 8-byte Reload
	movl	$1, %edx
	callq	hipMallocManaged
	movq	(%rsp), %rax
	movq	(%rax,%r12), %rdx
	leaq	8(%rdx), %rcx
	leaq	16(%rdx), %r8
	leaq	24(%rdx), %r9
	leaq	32(%rdx), %r10
	leaq	40(%rdx), %r11
	leaq	48(%rdx), %r13
	leaq	56(%rdx), %rbp
	leaq	64(%rdx), %rbx
	leaq	72(%rdx), %r14
	movl	$.L.str.2, %esi
	movq	8(%rsp), %rdi                   # 8-byte Reload
	xorl	%eax, %eax
	pushq	%r14
	.cfi_adjust_cfa_offset 8
	pushq	%rbx
	.cfi_adjust_cfa_offset 8
	pushq	%rbp
	.cfi_adjust_cfa_offset 8
	pushq	%r13
	.cfi_adjust_cfa_offset 8
	pushq	%r11
	.cfi_adjust_cfa_offset 8
	pushq	%r10
	.cfi_adjust_cfa_offset 8
	callq	__isoc23_fscanf
	addq	$48, %rsp
	.cfi_adjust_cfa_offset -48
	addq	$8, %r12
	cmpq	%r12, %r15
	jne	.LBB0_2
.LBB0_3:                                # %._crit_edge
	movq	8(%rsp), %rdi                   # 8-byte Reload
	callq	fclose
	movq	(%rsp), %rax
	addq	$24, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	_Z15getWeightMatrixii, .Lfunc_end0-_Z15getWeightMatrixii
	.cfi_endproc
                                        # -- End function
	.globl	_Z10getBVectori                 # -- Begin function _Z10getBVectori
	.type	_Z10getBVectori,@function
_Z10getBVectori:                        # @_Z10getBVectori
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	pushq	%rax
	.cfi_def_cfa_offset 64
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	%edi, %ebp
	movl	$.L.str.3, %edi
	movl	$.L.str.1, %esi
	callq	fopen
	movq	%rax, %rbx
	movslq	%ebp, %rsi
	shlq	$3, %rsi
	movq	%rsp, %r14
	movq	%r14, %rdi
	movl	$1, %edx
	callq	hipMallocManaged
	movq	(%r14), %rdx
	leaq	8(%rdx), %rcx
	leaq	16(%rdx), %r8
	leaq	24(%rdx), %r9
	leaq	32(%rdx), %r10
	leaq	40(%rdx), %r11
	leaq	48(%rdx), %r15
	leaq	56(%rdx), %r12
	leaq	64(%rdx), %r13
	leaq	72(%rdx), %rbp
	movl	$.L.str.2, %esi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	pushq	%rbp
	.cfi_adjust_cfa_offset 8
	pushq	%r13
	.cfi_adjust_cfa_offset 8
	pushq	%r12
	.cfi_adjust_cfa_offset 8
	pushq	%r15
	.cfi_adjust_cfa_offset 8
	pushq	%r11
	.cfi_adjust_cfa_offset 8
	pushq	%r10
	.cfi_adjust_cfa_offset 8
	callq	__isoc23_fscanf
	addq	$48, %rsp
	.cfi_adjust_cfa_offset -48
	movq	%rbx, %rdi
	callq	fclose
	movq	(%r14), %rax
	addq	$8, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end1:
	.size	_Z10getBVectori, .Lfunc_end1-_Z10getBVectori
	.cfi_endproc
                                        # -- End function
	.globl	_Z11printMatrixPPdii            # -- Begin function _Z11printMatrixPPdii
	.type	_Z11printMatrixPPdii,@function
_Z11printMatrixPPdii:                   # @_Z11printMatrixPPdii
	.cfi_startproc
# %bb.0:
	testl	%esi, %esi
	jle	.LBB2_7
# %bb.1:                                # %.lr.ph13
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	pushq	%rax
	.cfi_def_cfa_offset 64
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	%edx, %ebx
	movq	%rdi, %r14
	movl	%esi, %r15d
	movl	%edx, %r12d
	xorl	%r13d, %r13d
.LBB2_2:                                # =>This Loop Header: Depth=1
                                        #     Child Loop BB2_4 Depth 2
	movl	$91, %edi
	callq	putchar@PLT
	testl	%ebx, %ebx
	jle	.LBB2_5
# %bb.3:                                # %.lr.ph
                                        #   in Loop: Header=BB2_2 Depth=1
	xorl	%ebp, %ebp
.LBB2_4:                                #   Parent Loop BB2_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movq	(%r14,%r13,8), %rax
	movsd	(%rax,%rbp,8), %xmm0            # xmm0 = mem[0],zero
	movl	$.L.str.5, %edi
	movb	$1, %al
	callq	printf
	incq	%rbp
	cmpq	%rbp, %r12
	jne	.LBB2_4
.LBB2_5:                                # %._crit_edge
                                        #   in Loop: Header=BB2_2 Depth=1
	movl	$.Lstr, %edi
	callq	puts@PLT
	incq	%r13
	cmpq	%r15, %r13
	jne	.LBB2_2
# %bb.6:
	addq	$8, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	.cfi_restore %rbx
	.cfi_restore %r12
	.cfi_restore %r13
	.cfi_restore %r14
	.cfi_restore %r15
	.cfi_restore %rbp
.LBB2_7:                                # %._crit_edge14
	movl	$10, %edi
	jmp	putchar@PLT                     # TAILCALL
.Lfunc_end2:
	.size	_Z11printMatrixPPdii, .Lfunc_end2-_Z11printMatrixPPdii
	.cfi_endproc
                                        # -- End function
	.globl	_Z12getMNISTTestiPiS_ii         # -- Begin function _Z12getMNISTTestiPiS_ii
	.type	_Z12getMNISTTestiPiS_ii,@function
_Z12getMNISTTestiPiS_ii:                # @_Z12getMNISTTestiPiS_ii
	.cfi_startproc
# %bb.0:
	cmpl	$10001, %edi                    # imm = 0x2711
	jl	.LBB3_1
# %bb.7:
	movl	$.L.str.8, %edi
	xorl	%eax, %eax
	jmp	printf                          # TAILCALL
.LBB3_1:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	%ecx, %ebp
	movq	%rdx, %rbx
	movq	%rsi, %r15
	movl	%edi, %r12d
	movl	$.L.str.9, %edi
	movl	$.L.str.1, %esi
	callq	fopen
	movq	%rax, %r14
	testl	%r12d, %r12d
	jle	.LBB3_2
.LBB3_6:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movl	$.L.str.10, %esi
	movq	%r14, %rdi
	xorl	%eax, %eax
	callq	__isoc23_fscanf
	decl	%r12d
	jne	.LBB3_6
.LBB3_2:                                # %._crit_edge
	movl	$.L.str.11, %esi
	movq	%r14, %rdi
	movq	%r15, %rdx
	xorl	%eax, %eax
	callq	__isoc23_fscanf
	movl	$.L.str.12, %esi
	movq	%r14, %rdi
	xorl	%eax, %eax
	callq	__isoc23_fscanf
	testl	%ebp, %ebp
	jle	.LBB3_5
# %bb.3:                                # %.lr.ph19.preheader
	movl	%ebp, %r15d
.LBB3_4:                                # %.lr.ph19
                                        # =>This Inner Loop Header: Depth=1
	movl	$.L.str.13, %esi
	movq	%r14, %rdi
	movq	%rbx, %rdx
	xorl	%eax, %eax
	callq	__isoc23_fscanf
	addq	$4, %rbx
	decq	%r15
	jne	.LBB3_4
.LBB3_5:                                # %._crit_edge20
	movq	%r14, %rdi
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	jmp	fclose                          # TAILCALL
.Lfunc_end3:
	.size	_Z12getMNISTTestiPiS_ii, .Lfunc_end3-_Z12getMNISTTestiPiS_ii
	.cfi_endproc
                                        # -- End function
	.globl	_Z10printImageiPii              # -- Begin function _Z10printImageiPii
	.type	_Z10printImageiPii,@function
_Z10printImageiPii:                     # @_Z10printImageiPii
	.cfi_startproc
# %bb.0:
	testl	%edx, %edx
	jle	.LBB4_9
# %bb.1:                                # %.lr.ph.preheader
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	pushq	%rax
	.cfi_def_cfa_offset 64
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rsi, %rbx
	movl	%edi, %ebp
	movl	%edx, %r14d
	shlq	$2, %r14
	movl	$-1, %r15d
	movl	$1, %r12d
	xorl	%r13d, %r13d
.LBB4_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	cmpl	$0, (%rbx,%r13)
	je	.LBB4_3
# %bb.4:                                #   in Loop: Header=BB4_2 Depth=1
	movl	$.L.str.15, %edi
	movl	%ebp, %esi
	movl	%ebp, %edx
	xorl	%eax, %eax
	callq	printf
	jmp	.LBB4_5
.LBB4_3:                                #   in Loop: Header=BB4_2 Depth=1
	movl	$.L.str.14, %edi
	xorl	%eax, %eax
	callq	printf
.LBB4_5:                                #   in Loop: Header=BB4_2 Depth=1
	movl	%r12d, %eax
	shrl	$2, %eax
	imulq	$613566757, %rax, %rax          # imm = 0x24924925
	shrq	$32, %rax
	leal	(%rax,%rax,8), %ecx
	leal	(%rcx,%rcx,2), %ecx
	addl	%r15d, %eax
	addl	%ecx, %eax
	jne	.LBB4_7
# %bb.6:                                #   in Loop: Header=BB4_2 Depth=1
	movl	$10, %edi
	callq	putchar@PLT
.LBB4_7:                                #   in Loop: Header=BB4_2 Depth=1
	addq	$4, %r13
	decl	%r15d
	incl	%r12d
	cmpq	%r13, %r14
	jne	.LBB4_2
# %bb.8:
	addq	$8, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	.cfi_restore %rbx
	.cfi_restore %r12
	.cfi_restore %r13
	.cfi_restore %r14
	.cfi_restore %r15
	.cfi_restore %rbp
.LBB4_9:                                # %._crit_edge
	movl	$10, %edi
	jmp	putchar@PLT                     # TAILCALL
.Lfunc_end4:
	.size	_Z10printImageiPii, .Lfunc_end4-_Z10printImageiPii
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z11getMaxIndexPdi
.LCPI5_0:
	.quad	0xbff0000000000000              # double -1
	.text
	.globl	_Z11getMaxIndexPdi
	.type	_Z11getMaxIndexPdi,@function
_Z11getMaxIndexPdi:                     # @_Z11getMaxIndexPdi
	.cfi_startproc
# %bb.0:
	testl	%esi, %esi
	jle	.LBB5_1
# %bb.4:                                # %.lr.ph.preheader
	movsd	(%rdi), %xmm1                   # xmm1 = mem[0],zero
	movl	%esi, %eax
	movl	$-1, %ecx
	xorl	%edx, %edx
	movapd	%xmm1, %xmm0
.LBB5_5:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movsd	(%rdi,%rdx,8), %xmm2            # xmm2 = mem[0],zero
	ucomisd	%xmm1, %xmm2
	cmpnlesd	%xmm2, %xmm0
	movapd	%xmm0, %xmm3
	andnpd	%xmm2, %xmm3
	andpd	%xmm1, %xmm0
	cmovael	%edx, %ecx
	orpd	%xmm3, %xmm0
	incq	%rdx
	movapd	%xmm0, %xmm1
	cmpq	%rdx, %rax
	jne	.LBB5_5
# %bb.2:                                # %._crit_edge.loopexit
	xorps	%xmm0, %xmm0
	cvtsi2sd	%ecx, %xmm0
	retq
.LBB5_1:
	movsd	.LCPI5_0(%rip), %xmm0           # xmm0 = mem[0],zero
	retq
.Lfunc_end5:
	.size	_Z11getMaxIndexPdi, .Lfunc_end5-_Z11getMaxIndexPdi
	.cfi_endproc
                                        # -- End function
	.globl	_Z40__device_stub__productMatrixVectorKernelPiPPdS0_i # -- Begin function _Z40__device_stub__productMatrixVectorKernelPiPPdS0_i
	.type	_Z40__device_stub__productMatrixVectorKernelPiPPdS0_i,@function
_Z40__device_stub__productMatrixVectorKernelPiPPdS0_i: # @_Z40__device_stub__productMatrixVectorKernelPiPPdS0_i
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$112, %rsp
	.cfi_def_cfa_offset 160
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	32(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	24(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	4(%rsp), %rdx
	movl	%ecx, (%rdx)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	16(%rsp), %r12
	leaq	8(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z25productMatrixVectorKernelPiPPdS0_i, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$128, %rsp
	.cfi_adjust_cfa_offset -128
	popq	%rbx
	.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
	retq
.Lfunc_end6:
	.size	_Z40__device_stub__productMatrixVectorKernelPiPPdS0_i, .Lfunc_end6-_Z40__device_stub__productMatrixVectorKernelPiPPdS0_i
	.cfi_endproc
                                        # -- End function
	.globl	_Z36__device_stub__SumVectorVectorKernelPdS_S_ # -- Begin function _Z36__device_stub__SumVectorVectorKernelPdS_S_
	.type	_Z36__device_stub__SumVectorVectorKernelPdS_S_,@function
_Z36__device_stub__SumVectorVectorKernelPdS_S_: # @_Z36__device_stub__SumVectorVectorKernelPdS_S_
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$112, %rsp
	.cfi_def_cfa_offset 160
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	32(%rsp), %rcx
	movq	%rsi, (%rcx)
	leaq	24(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	movq	%rsi, 16(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	16(%rsp), %r12
	leaq	8(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z21SumVectorVectorKernelPdS_S_, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$128, %rsp
	.cfi_adjust_cfa_offset -128
	popq	%rbx
	.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
	retq
.Lfunc_end7:
	.size	_Z36__device_stub__SumVectorVectorKernelPdS_S_, .Lfunc_end7-_Z36__device_stub__SumVectorVectorKernelPdS_S_
	.cfi_endproc
                                        # -- End function
	.globl	main                            # -- Begin function main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movabsq	$42949672961, %rbx              # imm = 0xA00000001
	movabsq	$4294967297, %r14               # imm = 0x100000001
	leaq	20(%rsp), %r15
	movl	$44, (%r15)
	movl	$784, %edi                      # imm = 0x310
	movl	$10, %esi
	callq	_Z15getWeightMatrixii
	movq	%rax, %r12
	movl	$10, %edi
	callq	_Z10getBVectori
	movq	%rax, %r13
	leaq	8(%rsp), %rdi
	movl	$3136, %esi                     # imm = 0xC40
	movl	$1, %edx
	callq	hipMallocManaged
	leaq	32(%rsp), %rdi
	movl	$80, %esi
	movl	$1, %edx
	callq	hipMallocManaged
	leaq	24(%rsp), %rdi
	movl	$80, %esi
	movl	$1, %edx
	callq	hipMallocManaged
	leaq	4(%rsp), %rbp
.LBB8_1:                                # %.backedge
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB8_8 Depth 2
	movl	$.L.str.16, %edi
	xorl	%eax, %eax
	callq	printf
	movl	$.L.str.11, %edi
	movq	%r15, %rsi
	xorl	%eax, %eax
	callq	__isoc23_scanf
	movl	20(%rsp), %edi
	cmpl	$10001, %edi                    # imm = 0x2711
	jl	.LBB8_3
# %bb.2:                                #   in Loop: Header=BB8_1 Depth=1
	movl	$.Lstr.1, %edi
	callq	puts@PLT
	jmp	.LBB8_1
.LBB8_3:                                #   in Loop: Header=BB8_1 Depth=1
	movq	8(%rsp), %rdx
	movq	%rbp, %rsi
	movl	$784, %ecx                      # imm = 0x310
	callq	_Z12getMNISTTestiPiS_ii
	movq	%r14, %rdi
	movl	$1, %esi
	movq	%rbx, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB8_5
# %bb.4:                                #   in Loop: Header=BB8_1 Depth=1
	movq	8(%rsp), %rdi
	movq	32(%rsp), %rdx
	movq	%r12, %rsi
	movl	$784, %ecx                      # imm = 0x310
	callq	_Z40__device_stub__productMatrixVectorKernelPiPPdS0_i
.LBB8_5:                                #   in Loop: Header=BB8_1 Depth=1
	callq	hipDeviceSynchronize
	movq	%r14, %rdi
	movl	$1, %esi
	movq	%rbx, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB8_7
# %bb.6:                                #   in Loop: Header=BB8_1 Depth=1
	movq	32(%rsp), %rdi
	movq	24(%rsp), %rdx
	movq	%r13, %rsi
	callq	_Z36__device_stub__SumVectorVectorKernelPdS_S_
.LBB8_7:                                #   in Loop: Header=BB8_1 Depth=1
	callq	hipDeviceSynchronize
	movq	24(%rsp), %rax
	movsd	(%rax), %xmm1                   # xmm1 = mem[0],zero
	movl	$-1, %edx
	xorl	%ecx, %ecx
	movapd	%xmm1, %xmm0
.LBB8_8:                                # %.lr.ph.i
                                        #   Parent Loop BB8_1 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movsd	(%rax,%rcx,8), %xmm2            # xmm2 = mem[0],zero
	ucomisd	%xmm1, %xmm2
	cmpnlesd	%xmm2, %xmm0
	movapd	%xmm0, %xmm3
	andnpd	%xmm2, %xmm3
	andpd	%xmm1, %xmm0
	cmovael	%ecx, %edx
	orpd	%xmm3, %xmm0
	incq	%rcx
	movapd	%xmm0, %xmm1
	cmpq	$10, %rcx
	jne	.LBB8_8
# %bb.9:                                # %_Z11getMaxIndexPdi.exit
                                        #   in Loop: Header=BB8_1 Depth=1
	movl	4(%rsp), %esi
	movl	$.L.str.18, %edi
	xorl	%eax, %eax
	callq	printf
	movl	4(%rsp), %edi
	movq	8(%rsp), %rsi
	movl	$784, %edx                      # imm = 0x310
	callq	_Z10printImageiPii
	jmp	.LBB8_1
.Lfunc_end8:
	.size	main, .Lfunc_end8-main
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$32, %rsp
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -16
	movq	__hip_gpubin_handle(%rip), %rbx
	testq	%rbx, %rbx
	jne	.LBB9_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB9_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z25productMatrixVectorKernelPiPPdS0_i, %esi
	movl	$.L__unnamed_1, %edx
	movl	$.L__unnamed_1, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z21SumVectorVectorKernelPdS_S_, %esi
	movl	$.L__unnamed_2, %edx
	movl	$.L__unnamed_2, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$__hip_module_dtor, %edi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_end9:
	.size	__hip_module_ctor, .Lfunc_end9-__hip_module_ctor
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_dtor
	.type	__hip_module_dtor,@function
__hip_module_dtor:                      # @__hip_module_dtor
	.cfi_startproc
# %bb.0:
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	je	.LBB10_2
# %bb.1:
	pushq	%rax
	.cfi_def_cfa_offset 16
	callq	__hipUnregisterFatBinary
	movq	$0, __hip_gpubin_handle(%rip)
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
.LBB10_2:
	retq
.Lfunc_end10:
	.size	__hip_module_dtor, .Lfunc_end10-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"WMatrix.txt"
	.size	.L.str, 12

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"r"
	.size	.L.str.1, 2

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,"
	.size	.L.str.2, 41

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"bVector.txt"
	.size	.L.str.3, 12

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"%0.10lf\t"
	.size	.L.str.5, 9

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"Solo hay 10,000 datos de test !"
	.size	.L.str.8, 32

	.type	.L.str.9,@object                # @.str.9
.L.str.9:
	.asciz	"mnist_test.csv"
	.size	.L.str.9, 15

	.type	.L.str.10,@object               # @.str.10
.L.str.10:
	.asciz	"%*[^\n]\n"
	.size	.L.str.10, 8

	.type	.L.str.11,@object               # @.str.11
.L.str.11:
	.asciz	"%d"
	.size	.L.str.11, 3

	.type	.L.str.12,@object               # @.str.12
.L.str.12:
	.asciz	","
	.size	.L.str.12, 2

	.type	.L.str.13,@object               # @.str.13
.L.str.13:
	.asciz	"%d,"
	.size	.L.str.13, 4

	.type	.L.str.14,@object               # @.str.14
.L.str.14:
	.asciz	"--"
	.size	.L.str.14, 3

	.type	.L.str.15,@object               # @.str.15
.L.str.15:
	.asciz	"%d%d"
	.size	.L.str.15, 5

	.type	_Z25productMatrixVectorKernelPiPPdS0_i,@object # @_Z25productMatrixVectorKernelPiPPdS0_i
	.section	.rodata,"a",@progbits
	.globl	_Z25productMatrixVectorKernelPiPPdS0_i
	.p2align	3, 0x0
_Z25productMatrixVectorKernelPiPPdS0_i:
	.quad	_Z40__device_stub__productMatrixVectorKernelPiPPdS0_i
	.size	_Z25productMatrixVectorKernelPiPPdS0_i, 8

	.type	_Z21SumVectorVectorKernelPdS_S_,@object # @_Z21SumVectorVectorKernelPdS_S_
	.globl	_Z21SumVectorVectorKernelPdS_S_
	.p2align	3, 0x0
_Z21SumVectorVectorKernelPdS_S_:
	.quad	_Z36__device_stub__SumVectorVectorKernelPdS_S_
	.size	_Z21SumVectorVectorKernelPdS_S_, 8

	.type	.L.str.16,@object               # @.str.16
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.16:
	.asciz	"Indice del Data Set: "
	.size	.L.str.16, 22

	.type	.L.str.18,@object               # @.str.18
.L.str.18:
	.asciz	"Original %d, Prediccion %d\n"
	.size	.L.str.18, 28

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z25productMatrixVectorKernelPiPPdS0_i"
	.size	.L__unnamed_1, 39

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_Z21SumVectorVectorKernelPdS_S_"
	.size	.L__unnamed_2, 32

	.type	__hip_fatbin_wrapper,@object    # @__hip_fatbin_wrapper
	.section	.hipFatBinSegment,"a",@progbits
	.p2align	3, 0x0
__hip_fatbin_wrapper:
	.long	1212764230                      # 0x48495046
	.long	1                               # 0x1
	.quad	__hip_fatbin
	.quad	0
	.size	__hip_fatbin_wrapper, 24

	.type	__hip_gpubin_handle,@object     # @__hip_gpubin_handle
	.local	__hip_gpubin_handle
	.comm	__hip_gpubin_handle,8,8
	.section	.init_array,"aw",@init_array
	.p2align	3, 0x0
	.quad	__hip_module_ctor
	.type	__hip_cuid_,@object             # @__hip_cuid_
	.bss
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               # 0x0
	.size	__hip_cuid_, 1

	.type	.Lstr,@object                   # @str
	.section	.rodata.str1.1,"aMS",@progbits,1
.Lstr:
	.asciz	"]"
	.size	.Lstr, 2

	.type	.Lstr.1,@object                 # @str.1
.Lstr.1:
	.asciz	"Solo hay 10,000 datos\n"
	.size	.Lstr.1, 23

	.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 _Z40__device_stub__productMatrixVectorKernelPiPPdS0_i
	.addrsig_sym _Z36__device_stub__SumVectorVectorKernelPdS_S_
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z25productMatrixVectorKernelPiPPdS0_i
	.addrsig_sym _Z21SumVectorVectorKernelPdS_S_
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z25productMatrixVectorKernelPiPPdS0_i ; -- Begin function _Z25productMatrixVectorKernelPiPPdS0_i
	.globl	_Z25productMatrixVectorKernelPiPPdS0_i
	.p2align	8
	.type	_Z25productMatrixVectorKernelPiPPdS0_i,@function
_Z25productMatrixVectorKernelPiPPdS0_i: ; @_Z25productMatrixVectorKernelPiPPdS0_i
; %bb.0:
	s_clause 0x2
	s_load_b32 s2, s[0:1], 0x18
	s_load_b128 s[4:7], s[0:1], 0x0
	s_load_b64 s[0:1], s[0:1], 0x10
	v_bfe_u32 v0, v0, 10, 10
	s_delay_alu instid0(VALU_DEP_1)
	v_lshlrev_b32_e32 v2, 3, v0
	v_mov_b32_e32 v0, 0
	v_mov_b32_e32 v1, 0
	s_waitcnt lgkmcnt(0)
	s_cmp_lt_i32 s2, 1
	s_cbranch_scc1 .LBB0_2
.LBB0_1:                                ; %.lr.ph
                                        ; =>This Inner Loop Header: Depth=1
	s_load_b64 s[8:9], s[6:7], 0x0
	s_load_b32 s3, s[4:5], 0x0
	s_add_i32 s2, s2, -1
	s_add_u32 s4, s4, 4
	s_addc_u32 s5, s5, 0
	s_add_u32 s6, s6, 8
	s_addc_u32 s7, s7, 0
	s_cmp_eq_u32 s2, 0
	s_waitcnt lgkmcnt(0)
	global_load_b64 v[3:4], v2, s[8:9]
	v_cvt_f64_i32_e32 v[5:6], s3
	s_waitcnt vmcnt(0)
	s_delay_alu instid0(VALU_DEP_1)
	v_fma_f64 v[0:1], v[3:4], v[5:6], v[0:1]
	s_cbranch_scc0 .LBB0_1
.LBB0_2:                                ; %Flow30
	global_store_b64 v2, v[0:1], s[0:1]
	s_waitcnt_vscnt null, 0x0
	s_barrier
	buffer_gl0_inv
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z25productMatrixVectorKernelPiPPdS0_i
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 28
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 1
		.amdhsa_next_free_vgpr 7
		.amdhsa_next_free_sgpr 10
		.amdhsa_reserve_vcc 0
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end0:
	.size	_Z25productMatrixVectorKernelPiPPdS0_i, .Lfunc_end0-_Z25productMatrixVectorKernelPiPPdS0_i
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 168
; NumSgprs: 10
; NumVgprs: 7
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 1
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 10
; NumVGPRsForWavesPerEU: 7
; Occupancy: 16
; WaveLimiterHint : 1
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 1
	.text
	.protected	_Z21SumVectorVectorKernelPdS_S_ ; -- Begin function _Z21SumVectorVectorKernelPdS_S_
	.globl	_Z21SumVectorVectorKernelPdS_S_
	.p2align	8
	.type	_Z21SumVectorVectorKernelPdS_S_,@function
_Z21SumVectorVectorKernelPdS_S_:        ; @_Z21SumVectorVectorKernelPdS_S_
; %bb.0:
	s_load_b128 s[4:7], s[0:1], 0x0
	v_bfe_u32 v0, v0, 10, 10
	s_load_b64 s[0:1], s[0:1], 0x10
	s_delay_alu instid0(VALU_DEP_1)
	v_lshlrev_b32_e32 v4, 3, v0
	s_waitcnt lgkmcnt(0)
	s_clause 0x1
	global_load_b64 v[0:1], v4, s[4:5]
	global_load_b64 v[2:3], v4, s[6:7]
	s_waitcnt vmcnt(0)
	v_add_f64 v[0:1], v[0:1], v[2:3]
	global_store_b64 v4, v[0:1], s[0:1]
	s_waitcnt_vscnt null, 0x0
	s_barrier
	buffer_gl0_inv
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z21SumVectorVectorKernelPdS_S_
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 24
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 1
		.amdhsa_next_free_vgpr 5
		.amdhsa_next_free_sgpr 8
		.amdhsa_reserve_vcc 0
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end1:
	.size	_Z21SumVectorVectorKernelPdS_S_, .Lfunc_end1-_Z21SumVectorVectorKernelPdS_S_
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 96
; NumSgprs: 8
; NumVgprs: 5
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 0
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 8
; NumVGPRsForWavesPerEU: 5
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 1
	.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_
	.amdgpu_metadata
---
amdhsa.kernels:
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         16
        .size:           8
        .value_kind:     global_buffer
      - .offset:         24
        .size:           4
        .value_kind:     by_value
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 28
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z25productMatrixVectorKernelPiPPdS0_i
    .private_segment_fixed_size: 0
    .sgpr_count:     10
    .sgpr_spill_count: 0
    .symbol:         _Z25productMatrixVectorKernelPiPPdS0_i.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     7
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         16
        .size:           8
        .value_kind:     global_buffer
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 24
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z21SumVectorVectorKernelPdS_S_
    .private_segment_fixed_size: 0
    .sgpr_count:     8
    .sgpr_spill_count: 0
    .symbol:         _Z21SumVectorVectorKernelPdS_S_.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     5
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
