#include<stdio.h>
#include<iostream>
#include<fstream>
#include<cuda.h>
#include<time.h>
#include<sys/time.h>

#define IMAGE_LENGTH 2000
#define KERNEL_LENGTH 5
#define MAX_NUMBER 12
#define NumOfBlocks IMAGE_LENGTH/16
#define NumOfThreads 16

using namespace std;
ofstream fs("convolucion.txt");

void print_Matrix(int** matrix, int n, int m){
  for(int i = 0; i < n; i++){
    for(int j = 0; j < m; j++){
      cout<<" "<<matrix[i][j];            
    }
    cout<<endl;
  }
}

int** create_Matrix(int n, int m){
  int **matrix;
  matrix = (int **)malloc(n*sizeof(int *));
  for(int i=0; i < n; i++) {
    matrix[i] = (int *)malloc(m*sizeof(int));
  }
  return matrix;
}

int** gpu_create_Matrix(int n, int m){
  int **matrix;
  cudaMalloc((void***)&matrix,  n*sizeof(int*));
  for(int i=0; i < n; i++) {
    cudaMalloc((void**) &(matrix[i]), m*sizeof(int));
  }
  return matrix;
}

int** gpu_copy_Matrix(int **host, int n, int m){
  int** device = (int **)malloc(n * sizeof(int *));
  int **aux = (int **)malloc(n * sizeof(int *));
  cudaMalloc((void***)&device,  n*sizeof(int*));
  for(int i=0; i<n; i++) {
    cudaMalloc((void**) &(aux[i]), m*sizeof(int));
    cudaMemcpy (aux[i], host[i], m*sizeof(float), cudaMemcpyHostToDevice);
  }
  cudaMemcpy(device, aux, n*sizeof(int *), cudaMemcpyHostToDevice);
  return device;
}

int** cpu_copy_Matrix(int **device, int n, int m){
  int** host = (int **)malloc(n * sizeof(int *));
  int **aux = (int **)malloc(n * sizeof(int *));
  cudaMalloc((void***)&host,  n*sizeof(int*));
  for(int i=0; i<n; i++) {
    cudaMalloc((void**) &(aux[i]), m*sizeof(int));
    cudaMemcpy (aux[i], device[i], m*sizeof(float), cudaMemcpyDeviceToHost);
  }
  cudaMemcpy(host, aux, n*sizeof(int *), cudaMemcpyDeviceToHost);
  return host;
}

int** copy_Matrix(int **orig, int n, int m){
  int** cpy = create_Matrix(n,m);
  for(int i=0; i<n; i++) {
    for(int j=0; i<m; i++){
      cpy[i][j] = orig[i][j];
    }
  }
  return cpy;
}

void generate_Kernel_Matrix(int** a, int n, int m){
  srand( (unsigned)time( NULL ) );
  for(int i=0; i<n;i++){
    for(int j=0;j<m;j++){
      //a[i][j] = (rand()%MAX_NUMBER)+1;;
      a[i][j] = 1;
    }
  }
}

void generate_Image_Matrix(int** a, int n, int m, int index){
  srand( (unsigned)time( NULL ) );
  for(int i=0;i<index;i++){
    for(int j=0;j<m;j++){
      a[i][j] = 0;
    }
  }
  for(int i=0;i<n-index;i++){
    for(int j=0;j<index;j++){
      a[i][j] = 0;
    }
  }
  for(int i=n-index;i<n;i++){
    for(int j=0;j<m;j++){
      a[i][j] = 0;
    }
  }
  for(int i=0;i<n;i++){
    for(int j=m-index;j<m;j++){
      a[i][j] = 0;
    }
  }
  for(int i=index; i<n-index;i++){
    for(int j=index;j<m-index;j++){
      a[i][j] = (rand()%MAX_NUMBER)+1;
      //a[i][j] = j;
    }
  }
}

void init_Matrix(int** a,int n, int m){
  for(int i=0; i<n;i++){
    for(int j=0;j<m;j++){
      a[i][j]=0;
    }
  }
}

bool compare_Matrix(int** A, int** B, int n, int m){
  bool same = true;
  for(int i=0; i<n;i++){
    for(int j=0;j<m;j++){
      if(A[i][j]!=B[i][j]){
        same = false;
        break;
      }
    }
  }
  return same;
}

int sumTermsMatrix(int** a, int n, int m){
  int suma = 0;
  for(int i=0; i<n;i++){
    for(int j=0;j<m;j++){
      suma+=a[i][j];
    }
  }
  return suma;
}

void convolucion(int** kernel, int** image, int** result, int KERNELCOUNT){
  int i, j, n, m;
  int acumulador=0;
  
  for (i=0; i < IMAGE_LENGTH; i++){
    for (j=0; j < IMAGE_LENGTH; j++){
      for (n = 0; n < KERNEL_LENGTH; n++){
        for (m = 0; m < KERNEL_LENGTH; m++){
          acumulador += image[i + n][j + m] * kernel[n][m];
        }
      }
      result[i][j] = acumulador/KERNELCOUNT;
      acumulador = 0;
    }
  }
}

__global__ void convolucionCUDA(int** kernel, int** image, int** result, int KERNELCOUNT){
  int i, j, n, m;
  int acumulador=0;
  
  for (i=0; i < IMAGE_LENGTH; i++){
    for (j=0; j < IMAGE_LENGTH; j++){
      for (n = 0; n < KERNEL_LENGTH; n++){
        for (m = 0; m < KERNEL_LENGTH; m++){
          acumulador += image[i + n][j + m] * kernel[n][m];
        }
      }
      result[i][j] = acumulador/KERNELCOUNT;
      acumulador = 0;
    }
  }
}

__global__ void convKernel(int *inData, int *filter, int dataCol, int dataRow, int filRowRad, int filColRad,
               int *outData)
{
  __shared__ int padRect[2*1024];
  int i, col, row, sum = 0;

  int globalCol = threadIdx.x + blockIdx.x * blockDim.x;
  int globalRow = threadIdx.y + blockIdx.y * blockDim.y;
  int globalIdx = globalCol * dataRow + globalRow;

  int localIdx = threadIdx.x * blockDim.y + threadIdx.y;
  int localCells = blockDim.x * blockDim.y;

  int padRectCol = threadIdx.x + filColRad;
  int padRectRow = threadIdx.y + filRowRad;
  int padRectOffset = 2*filRowRad + blockDim.y;
  int padRectCells = padRectOffset * (blockDim.x + 2*filColRad);

  int *padRectOut = (int*)&padRect[((padRectCells-1)/32 + 1) * 32]; //Padding up with 32
  padRectOut[localIdx] = 0;

  int filOffset = filRowRad*2 + 1;
  int filCells = filOffset * (filColRad*2 + 1);
  int *localFilter = (int *)&padRectOut[((localCells-1)/32 + 1) * 32]; //Padding up with 32

  // Copying the filter elements to shared memory
  for(i = 0; i < (filCells/localCells) + 1; i++) {
    int index = i*localCells + localIdx;
    if(index < filCells) {
      localFilter[index] = filter[index];
    }
  }

  // Copying the Data elements to padded shared memory
  for(i = 0; i < (padRectCells/localCells) + 1; i++) {
    int index = i*localCells + localIdx;
    if(index < padRectCells) {
      int prCol = index / padRectOffset;
      int prRow = index % padRectOffset;
      int glCol = prCol + blockIdx.x*blockDim.x - filColRad;
      int glRow = prRow + blockIdx.y*blockDim.y - filRowRad;
      int glIdx = glCol * dataRow + glRow;
      if(glRow >= 0 && glRow < dataRow && glCol >= 0 && glCol < dataCol)
        padRect[index] = inData[glIdx];
      else
        padRect[index] = 0;
    }
  }

  __syncthreads();

  //Taking Convolution
  for(col = -filColRad; col <= filColRad; col++) {
    for(row = -filRowRad; row <= filRowRad; row++) {
      int filCol = filColRad - col;
      int filRow = filRowRad - row;
      int filIdx = filCol*filOffset + filRow;
      int filVal = localFilter[filIdx];

      int prCol = padRectCol + col;
      int prRow = padRectRow + row;
      int prIdx = prCol*padRectOffset + prRow;
      sum += filVal * padRect[prIdx];
    }
  }
  
  padRectOut[localIdx] = sum;
  __syncthreads();

  outData[globalIdx] = padRectOut[localIdx];


}

int main(){
  float parallelTime, serialTime;
  cudaEvent_t tStart, tStop;
  cudaEventCreate(&tStart, 0);
  cudaEventCreate(&tStop, 0);
  int realKernelLength=0, index = 0;
  if(KERNEL_LENGTH%2!=0){
    realKernelLength = KERNEL_LENGTH - 1;
    index = KERNEL_LENGTH/2;
  } else{
    cout << "Matrix Convolution siempre debe ser 2*N+1"<<endl;
    exit(0);
  }
  int** kernel = create_Matrix(KERNEL_LENGTH, KERNEL_LENGTH);
  int** image = create_Matrix(IMAGE_LENGTH+realKernelLength, IMAGE_LENGTH+realKernelLength);
  int** result = create_Matrix(IMAGE_LENGTH, IMAGE_LENGTH);
  int** resultCUDA = create_Matrix(IMAGE_LENGTH, IMAGE_LENGTH);

  generate_Kernel_Matrix(kernel, KERNEL_LENGTH,KERNEL_LENGTH);
  generate_Image_Matrix(image, IMAGE_LENGTH+realKernelLength, IMAGE_LENGTH+realKernelLength, index);
  init_Matrix(result, IMAGE_LENGTH, IMAGE_LENGTH);
  
  int KERNELCOUNT = sumTermsMatrix(kernel,KERNEL_LENGTH,KERNEL_LENGTH);
  
  cudaEventRecord(tStart, 0);
  convolucion(kernel, image, result, KERNELCOUNT);
  cudaEventRecord(tStop, 0);
  cudaEventSynchronize(tStop);
  cudaEventElapsedTime(&serialTime, tStart, tStop);
  cudaEventDestroy(tStart);
  cudaEventDestroy(tStop);

  if(IMAGE_LENGTH<10){
    cout << "Image: "<<endl;
    print_Matrix(image, IMAGE_LENGTH+realKernelLength, IMAGE_LENGTH+realKernelLength);
    cout << endl << endl;
    
    cout << "Kernel: "<<endl;
    print_Matrix(kernel, KERNEL_LENGTH, KERNEL_LENGTH);
    cout << endl << endl;

    cout << "Result: "<<endl;
    print_Matrix(result, IMAGE_LENGTH, IMAGE_LENGTH);
  }

  cout << "El tiempo en realizar la convolución en tiempo secuencial es: " << serialTime/1000 << endl;
  
//  int ns[] = {1, 2, 4, 8};
  
  fs << "ImgLenght KerLenght numthd serialTime parallelTime eff speedUp"<< endl;
  
  // ----
  int** gpu_kernel = copy_Matrix(kernel, KERNEL_LENGTH, KERNEL_LENGTH);
  int** gpu_image = copy_Matrix(image, IMAGE_LENGTH+realKernelLength, IMAGE_LENGTH+realKernelLength);
  init_Matrix(resultCUDA, IMAGE_LENGTH, IMAGE_LENGTH);
  int** gpu_result = copy_Matrix(resultCUDA, IMAGE_LENGTH, IMAGE_LENGTH);
    
  cudaEventCreate(&tStart, 0);
  cudaEventCreate(&tStop, 0);

  cudaEventRecord(tStart, 0);

  dim3 num_threads(NumOfThreads, 16, 1);
  dim3 numOfBlocks(NumOfBlocks, 1, 1);
  //convolucionCUDA<<<numOfBlocks, num_threads>>>(gpu_image, gpu_kernel, gpu_result, KERNELCOUNT);
  cudaEventRecord(tStop, 0);
  cudaEventSynchronize(tStop);
  cudaEventElapsedTime(&parallelTime, tStart, tStop);
  cudaEventDestroy(tStart);
  cudaEventDestroy(tStop);

  //resultCUDA = cpu_copy_Matrix(gpu_result, IMAGE_LENGTH, IMAGE_LENGTH);
  
  cout << "Son iguales: "<< compare_Matrix(result, resultCUDA, IMAGE_LENGTH, IMAGE_LENGTH) << endl;

  cout << "El tiempo en realizar la convolución en tiempo Paralelo con " << NumOfBlocks << " bloques y " << NumOfThreads <<" hilos es: " << parallelTime << endl;    
  cout << "Speed UP: "<< serialTime/(parallelTime) << endl;
  cout << "Eficiencia: "<< serialTime/(parallelTime*NumOfThreads) << endl;
  
  fs << IMAGE_LENGTH << " " << KERNEL_LENGTH << " " << NumOfThreads <<" " << serialTime <<" " << parallelTime << " " << serialTime/(parallelTime*NumOfThreads)<<" "<< serialTime/(parallelTime) << endl;

  cudaFree(gpu_image);
  cudaFree(gpu_result);
  cudaFree(gpu_kernel);
  
  free(image);
  free(result);
  free(kernel);
  
  return 0;
}

	.file	"tmpxft_0032e0be_00000000-6_gpu_parallel_convolution.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB3781:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE3781:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.align 2
	.type	_ZNSolsEPFRSoS_E.isra.0, @function
_ZNSolsEPFRSoS_E.isra.0:
.LFB4491:
	.cfi_startproc
	jmp	*%rsi
	.cfi_endproc
.LFE4491:
	.size	_ZNSolsEPFRSoS_E.isra.0, .-_ZNSolsEPFRSoS_E.isra.0
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	" "
	.text
	.globl	_Z12print_MatrixPPiii
	.type	_Z12print_MatrixPPiii, @function
_Z12print_MatrixPPiii:
.LFB3766:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	_ZSt4cout(%rip), %r15
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movl	%edx, %r14d
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%rdi, %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movl	%esi, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	xorl	%ebx, %ebx
	pushq	%rcx
	.cfi_def_cfa_offset 64
.L4:
	cmpl	%ebx, %r12d
	jle	.L10
	xorl	%ebp, %ebp
.L6:
	cmpl	%ebp, %r14d
	jle	.L11
	leaq	.LC0(%rip), %rsi
	movq	%r15, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%rax, %rdi
	movq	0(%r13,%rbx,8), %rax
	movl	(%rax,%rbp,4), %esi
	incq	%rbp
	call	_ZNSolsEi@PLT
	jmp	.L6
.L11:
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%r15, %rdi
	incq	%rbx
	call	_ZNSolsEPFRSoS_E.isra.0
	jmp	.L4
.L10:
	popq	%rax
	.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
.LFE3766:
	.size	_Z12print_MatrixPPiii, .-_Z12print_MatrixPPiii
	.globl	_Z13create_Matrixii
	.type	_Z13create_Matrixii, @function
_Z13create_Matrixii:
.LFB3767:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	movslq	%edi, %rdi
	xorl	%r13d, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	movq	%rdi, %r12
	salq	$3, %rdi
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	movslq	%esi, %rbx
	pushq	%rcx
	.cfi_def_cfa_offset 48
	salq	$2, %rbx
	call	malloc@PLT
	movq	%rax, %rbp
.L13:
	cmpl	%r13d, %r12d
	jle	.L16
	movq	%rbx, %rdi
	call	malloc@PLT
	movq	%rax, 0(%rbp,%r13,8)
	incq	%r13
	jmp	.L13
.L16:
	popq	%rdx
	.cfi_def_cfa_offset 40
	movq	%rbp, %rax
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3767:
	.size	_Z13create_Matrixii, .-_Z13create_Matrixii
	.globl	_Z17gpu_create_Matrixii
	.type	_Z17gpu_create_Matrixii, @function
_Z17gpu_create_Matrixii:
.LFB3768:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movl	%edi, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	xorl	%ebp, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	movslq	%esi, %rbx
	movslq	%edi, %rsi
	salq	$3, %rsi
	salq	$2, %rbx
	subq	$16, %rsp
	.cfi_def_cfa_offset 48
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rdi
	call	cudaMalloc@PLT
.L18:
	movq	(%rsp), %rax
	cmpl	%ebp, %r12d
	jle	.L22
	leaq	(%rax,%rbp,8), %rdi
	movq	%rbx, %rsi
	incq	%rbp
	call	cudaMalloc@PLT
	jmp	.L18
.L22:
	movq	8(%rsp), %rdx
	subq	%fs:40, %rdx
	je	.L20
	call	__stack_chk_fail@PLT
.L20:
	addq	$16, %rsp
	.cfi_def_cfa_offset 32
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3768:
	.size	_Z17gpu_create_Matrixii, .-_Z17gpu_create_Matrixii
	.globl	_Z15gpu_copy_MatrixPPiii
	.type	_Z15gpu_copy_MatrixPPiii, @function
_Z15gpu_copy_MatrixPPiii:
.LFB3769:
	.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
	movq	%rdi, %r14
	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
	movslq	%esi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	%rbp, %r13
	salq	$3, %rbp
	movslq	%edx, %rbx
	movq	%rbp, %rdi
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	call	malloc@PLT
	movq	%rbp, %rdi
	movq	%rax, 16(%rsp)
	call	malloc@PLT
	leaq	16(%rsp), %rdi
	movq	%rbp, %rsi
	movq	%rax, %r12
	call	cudaMalloc@PLT
	leaq	0(,%rbx,4), %rax
	movq	%r12, %r15
	xorl	%ebx, %ebx
	movq	%rax, 8(%rsp)
.L24:
	cmpl	%ebx, %r13d
	jle	.L28
	movq	8(%rsp), %rsi
	movq	%r15, %rdi
	addq	$8, %r15
	call	cudaMalloc@PLT
	movq	(%r14,%rbx,8), %rsi
	movq	-8(%r15), %rdi
	incq	%rbx
	movq	8(%rsp), %rdx
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	jmp	.L24
.L28:
	movq	16(%rsp), %rdi
	movl	$1, %ecx
	movq	%rbp, %rdx
	movq	%r12, %rsi
	call	cudaMemcpy@PLT
	movq	16(%rsp), %rax
	movq	24(%rsp), %rdx
	subq	%fs:40, %rdx
	je	.L26
	call	__stack_chk_fail@PLT
.L26:
	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
.LFE3769:
	.size	_Z15gpu_copy_MatrixPPiii, .-_Z15gpu_copy_MatrixPPiii
	.globl	_Z15cpu_copy_MatrixPPiii
	.type	_Z15cpu_copy_MatrixPPiii, @function
_Z15cpu_copy_MatrixPPiii:
.LFB3770:
	.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
	movq	%rdi, %r14
	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
	movslq	%esi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	%rbp, %r13
	salq	$3, %rbp
	movslq	%edx, %rbx
	movq	%rbp, %rdi
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	call	malloc@PLT
	movq	%rbp, %rdi
	movq	%rax, 16(%rsp)
	call	malloc@PLT
	leaq	16(%rsp), %rdi
	movq	%rbp, %rsi
	movq	%rax, %r12
	call	cudaMalloc@PLT
	leaq	0(,%rbx,4), %rax
	movq	%r12, %r15
	xorl	%ebx, %ebx
	movq	%rax, 8(%rsp)
.L30:
	cmpl	%ebx, %r13d
	jle	.L34
	movq	8(%rsp), %rsi
	movq	%r15, %rdi
	addq	$8, %r15
	call	cudaMalloc@PLT
	movq	(%r14,%rbx,8), %rsi
	movq	-8(%r15), %rdi
	incq	%rbx
	movq	8(%rsp), %rdx
	movl	$2, %ecx
	call	cudaMemcpy@PLT
	jmp	.L30
.L34:
	movq	16(%rsp), %rdi
	movl	$2, %ecx
	movq	%rbp, %rdx
	movq	%r12, %rsi
	call	cudaMemcpy@PLT
	movq	16(%rsp), %rax
	movq	24(%rsp), %rdx
	subq	%fs:40, %rdx
	je	.L32
	call	__stack_chk_fail@PLT
.L32:
	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
.LFE3770:
	.size	_Z15cpu_copy_MatrixPPiii, .-_Z15cpu_copy_MatrixPPiii
	.globl	_Z11copy_MatrixPPiii
	.type	_Z11copy_MatrixPPiii, @function
_Z11copy_MatrixPPiii:
.LFB3771:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movq	%rdi, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movl	%esi, %ebp
	movl	%edx, %esi
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	movl	%ebp, %edi
	movl	%edx, %ebx
	call	_Z13create_Matrixii
	xorl	%ecx, %ecx
	xorl	%esi, %esi
.L36:
	cmpl	%ebp, %ecx
	jge	.L35
	movslq	%ecx, %rdx
.L39:
	cmpl	%edx, %ebx
	jle	.L41
	movq	(%r12,%rdx,8), %rdi
	movl	(%rdi), %r8d
	movq	(%rax,%rdx,8), %rdi
	incq	%rdx
	movl	%r8d, (%rdi)
	jmp	.L39
.L41:
	movl	%ebx, %edx
	subl	%ecx, %edx
	cmpl	%ebx, %ecx
	cmovg	%esi, %edx
	leal	1(%rcx,%rdx), %ecx
	jmp	.L36
.L35:
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3771:
	.size	_Z11copy_MatrixPPiii, .-_Z11copy_MatrixPPiii
	.globl	_Z22generate_Kernel_MatrixPPiii
	.type	_Z22generate_Kernel_MatrixPPiii, @function
_Z22generate_Kernel_MatrixPPiii:
.LFB3772:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movl	%edx, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movq	%rdi, %rbp
	xorl	%edi, %edi
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	movl	%esi, %ebx
	call	time@PLT
	movl	%eax, %edi
	call	srand@PLT
	xorl	%eax, %eax
.L43:
	cmpl	%eax, %ebx
	jle	.L48
	xorl	%edx, %edx
.L45:
	cmpl	%edx, %r12d
	jle	.L49
	movq	0(%rbp,%rax,8), %rcx
	movl	$1, (%rcx,%rdx,4)
	incq	%rdx
	jmp	.L45
.L49:
	incq	%rax
	jmp	.L43
.L48:
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3772:
	.size	_Z22generate_Kernel_MatrixPPiii, .-_Z22generate_Kernel_MatrixPPiii
	.globl	_Z21generate_Image_MatrixPPiiii
	.type	_Z21generate_Image_MatrixPPiiii, @function
_Z21generate_Image_MatrixPPiiii:
.LFB3773:
	.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	%esi, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movq	%rdi, %r12
	xorl	%edi, %edi
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movl	%edx, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movl	%ecx, %ebx
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	call	time@PLT
	movl	%eax, %edi
	call	srand@PLT
	xorl	%eax, %eax
.L51:
	cmpl	%eax, %ebx
	jle	.L72
	xorl	%edx, %edx
.L53:
	cmpl	%edx, %ebp
	jle	.L73
	movq	(%r12,%rax,8), %rcx
	xorl	%r14d, %r14d
	movl	%r14d, (%rcx,%rdx,4)
	incq	%rdx
	jmp	.L53
.L73:
	incq	%rax
	jmp	.L51
.L72:
	movl	%r13d, %r14d
	xorl	%eax, %eax
	subl	%ebx, %r14d
.L54:
	cmpl	%eax, %r14d
	jle	.L74
	xorl	%edx, %edx
.L56:
	cmpl	%edx, %ebx
	jle	.L75
	movq	(%r12,%rax,8), %rcx
	xorl	%r11d, %r11d
	movl	%r11d, (%rcx,%rdx,4)
	incq	%rdx
	jmp	.L56
.L75:
	incq	%rax
	jmp	.L54
.L74:
	movslq	%r14d, %rax
.L57:
	cmpl	%eax, %r13d
	jle	.L76
	xorl	%edx, %edx
.L59:
	cmpl	%edx, %ebp
	jle	.L77
	movq	(%r12,%rax,8), %rcx
	xorl	%r10d, %r10d
	movl	%r10d, (%rcx,%rdx,4)
	incq	%rdx
	jmp	.L59
.L77:
	incq	%rax
	jmp	.L57
.L76:
	movl	%ebp, %edi
	xorl	%eax, %eax
	subl	%ebx, %edi
	movslq	%edi, %rdx
	salq	$2, %rdx
.L60:
	cmpl	%eax, %r13d
	jle	.L78
	movq	%rdx, %rsi
	movl	%edi, %ecx
.L62:
	cmpl	%ebp, %ecx
	jge	.L79
	movq	(%r12,%rax,8), %r8
	xorl	%r9d, %r9d
	incl	%ecx
	movl	%r9d, (%r8,%rsi)
	addq	$4, %rsi
	jmp	.L62
.L79:
	incq	%rax
	jmp	.L60
.L78:
	movslq	%ebx, %r13
	subl	%ebx, %ebp
	leaq	0(,%r13,4), %rax
	movq	%rax, (%rsp)
.L63:
	cmpl	%r13d, %r14d
	jle	.L80
	movq	(%rsp), %rsi
	movl	%ebx, %r15d
.L65:
	cmpl	%r15d, %ebp
	jle	.L81
	movq	%rsi, 8(%rsp)
	incl	%r15d
	call	rand@PLT
	movl	$12, %r8d
	movq	8(%rsp), %rsi
	movq	(%r12,%r13,8), %rdi
	cltd
	idivl	%r8d
	incl	%edx
	movl	%edx, (%rdi,%rsi)
	addq	$4, %rsi
	jmp	.L65
.L81:
	incq	%r13
	jmp	.L63
.L80:
	addq	$24, %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
.LFE3773:
	.size	_Z21generate_Image_MatrixPPiiii, .-_Z21generate_Image_MatrixPPiiii
	.globl	_Z11init_MatrixPPiii
	.type	_Z11init_MatrixPPiii, @function
_Z11init_MatrixPPiii:
.LFB3774:
	.cfi_startproc
	endbr64
	xorl	%eax, %eax
.L83:
	cmpl	%eax, %esi
	jle	.L87
	xorl	%ecx, %ecx
.L85:
	cmpl	%ecx, %edx
	jle	.L88
	movq	(%rdi,%rax,8), %r8
	xorl	%r9d, %r9d
	movl	%r9d, (%r8,%rcx,4)
	incq	%rcx
	jmp	.L85
.L88:
	incq	%rax
	jmp	.L83
.L87:
	ret
	.cfi_endproc
.LFE3774:
	.size	_Z11init_MatrixPPiii, .-_Z11init_MatrixPPiii
	.globl	_Z14compare_MatrixPPiS0_ii
	.type	_Z14compare_MatrixPPiS0_ii, @function
_Z14compare_MatrixPPiS0_ii:
.LFB3775:
	.cfi_startproc
	endbr64
	movq	%rdi, %r8
	xorl	%eax, %eax
	movb	$1, %r9b
.L97:
	cmpl	%eax, %edx
	jle	.L103
	xorl	%edi, %edi
	cmpl	%edi, %ecx
	jg	.L102
	incq	%rax
	jmp	.L97
.L103:
	movl	%r9d, %eax
	ret
.L102:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
.L92:
	movq	(%rsi,%rax,8), %r11
	movq	(%r8,%rax,8), %rbx
	leaq	0(,%rdi,4), %r10
	incq	%rdi
	movl	(%r11,%r10), %r11d
	cmpl	%r11d, (%rbx,%r10)
	je	.L93
	xorl	%r9d, %r9d
.L91:
	incq	%rax
	cmpl	%eax, %edx
	jle	.L104
	xorl	%edi, %edi
.L93:
	cmpl	%edi, %ecx
	jg	.L92
	jmp	.L91
.L104:
	movl	%r9d, %eax
	popq	%rbx
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3775:
	.size	_Z14compare_MatrixPPiS0_ii, .-_Z14compare_MatrixPPiS0_ii
	.globl	_Z14sumTermsMatrixPPiii
	.type	_Z14sumTermsMatrixPPiii, @function
_Z14sumTermsMatrixPPiii:
.LFB3776:
	.cfi_startproc
	endbr64
	xorl	%eax, %eax
	xorl	%r8d, %r8d
.L106:
	cmpl	%eax, %esi
	jle	.L110
	xorl	%ecx, %ecx
.L108:
	cmpl	%ecx, %edx
	jle	.L111
	movq	(%rdi,%rax,8), %r9
	addl	(%r9,%rcx,4), %r8d
	incq	%rcx
	jmp	.L108
.L111:
	incq	%rax
	jmp	.L106
.L110:
	movl	%r8d, %eax
	ret
	.cfi_endproc
.LFE3776:
	.size	_Z14sumTermsMatrixPPiii, .-_Z14sumTermsMatrixPPiii
	.globl	_Z11convolucionPPiS0_S0_i
	.type	_Z11convolucionPPiS0_S0_i, @function
_Z11convolucionPPiS0_S0_i:
.LFB3777:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movq	%rsi, %r9
	movq	%rdi, %r11
	movq	%rdx, %r10
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movl	%ecx, %r8d
	xorl	%esi, %esi
	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
.L113:
	movq	(%r10,%rsi,8), %r12
	leaq	(%r9,%rsi,8), %rbp
	xorl	%ecx, %ecx
.L119:
	leaq	0(,%rcx,4), %r13
	xorl	%edx, %edx
	xorl	%eax, %eax
.L117:
	movq	0(%rbp,%rdx), %r14
	movq	(%r11,%rdx), %r15
	xorl	%edi, %edi
	addq	%r13, %r14
.L114:
	movl	(%r14,%rdi), %ebx
	imull	(%r15,%rdi), %ebx
	addq	$4, %rdi
	addl	%ebx, %eax
	cmpq	$20, %rdi
	jne	.L114
	addq	$8, %rdx
	cmpq	$40, %rdx
	jne	.L117
	cltd
	idivl	%r8d
	movl	%eax, (%r12,%rcx,4)
	incq	%rcx
	cmpq	$2000, %rcx
	jne	.L119
	incq	%rsi
	cmpq	$2000, %rsi
	jne	.L113
	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
.LFE3777:
	.size	_Z11convolucionPPiS0_S0_i, .-_Z11convolucionPPiS0_S0_i
	.section	.rodata.str1.1
.LC1:
	.string	"El tiempo en realizar la convoluci\303\263n en tiempo secuencial es: "
.LC3:
	.string	"ImgLenght KerLenght numthd serialTime parallelTime eff speedUp"
.LC4:
	.string	"Son iguales: "
.LC5:
	.string	"El tiempo en realizar la convoluci\303\263n en tiempo Paralelo con "
.LC6:
	.string	" bloques y "
.LC7:
	.string	" hilos es: "
.LC8:
	.string	"Speed UP: "
.LC9:
	.string	"Eficiencia: "
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB3778:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	xorl	%esi, %esi
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	leaq	fs(%rip), %r13
	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	$88, %rsp
	.cfi_def_cfa_offset 144
	movq	%fs:40, %rax
	movq	%rax, 72(%rsp)
	xorl	%eax, %eax
	leaq	56(%rsp), %r15
	leaq	64(%rsp), %r14
	movq	%r15, %rdi
	call	cudaEventCreateWithFlags@PLT
	xorl	%esi, %esi
	movq	%r14, %rdi
	call	cudaEventCreateWithFlags@PLT
	movl	$5, %esi
	movl	$5, %edi
	call	_Z13create_Matrixii
	movl	$2004, %esi
	movl	$2004, %edi
	movq	%rax, 8(%rsp)
	call	_Z13create_Matrixii
	movl	$2000, %esi
	movl	$2000, %edi
	movq	%rax, 16(%rsp)
	call	_Z13create_Matrixii
	movl	$2000, %esi
	movl	$2000, %edi
	movq	%rax, 24(%rsp)
	call	_Z13create_Matrixii
	movq	8(%rsp), %rdi
	movl	$5, %edx
	movl	$5, %esi
	movq	%rax, %rbp
	call	_Z22generate_Kernel_MatrixPPiii
	movq	16(%rsp), %rdi
	movl	$2, %ecx
	movl	$2004, %edx
	movl	$2004, %esi
	call	_Z21generate_Image_MatrixPPiiii
	movq	24(%rsp), %rdi
	movl	$2000, %edx
	movl	$2000, %esi
	call	_Z11init_MatrixPPiii
	movq	8(%rsp), %rdi
	movl	$5, %edx
	movl	$5, %esi
	call	_Z14sumTermsMatrixPPiii
	movq	56(%rsp), %rdi
	xorl	%esi, %esi
	movl	%eax, %ebx
	call	cudaEventRecord@PLT
	movq	24(%rsp), %rdx
	movq	16(%rsp), %rsi
	movl	%ebx, %ecx
	movq	8(%rsp), %rdi
	leaq	_ZSt4cout(%rip), %rbx
	call	_Z11convolucionPPiS0_S0_i
	movq	64(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	64(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movq	64(%rsp), %rdx
	movq	56(%rsp), %rsi
	leaq	52(%rsp), %rdi
	call	cudaEventElapsedTime@PLT
	movq	56(%rsp), %rdi
	call	cudaEventDestroy@PLT
	movq	64(%rsp), %rdi
	call	cudaEventDestroy@PLT
	leaq	.LC1(%rip), %rsi
	movq	%rbx, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movss	52(%rsp), %xmm0
	divss	.LC2(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	movq	%rax, %rdi
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	leaq	.LC3(%rip), %rsi
	movq	%r13, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	movq	8(%rsp), %rdi
	movl	$5, %edx
	movl	$5, %esi
	call	_Z11copy_MatrixPPiii
	movq	16(%rsp), %rdi
	movl	$2004, %edx
	movl	$2004, %esi
	movq	%rax, 32(%rsp)
	call	_Z11copy_MatrixPPiii
	movl	$2000, %edx
	movl	$2000, %esi
	movq	%rbp, %rdi
	movq	%rax, %r12
	call	_Z11init_MatrixPPiii
	call	_Z11copy_MatrixPPiii
	xorl	%esi, %esi
	movq	%r15, %rdi
	movq	%rax, 40(%rsp)
	call	cudaEventCreateWithFlags@PLT
	xorl	%esi, %esi
	movq	%r14, %rdi
	call	cudaEventCreateWithFlags@PLT
	movq	56(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	64(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	64(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movq	64(%rsp), %rdx
	movq	56(%rsp), %rsi
	leaq	48(%rsp), %rdi
	call	cudaEventElapsedTime@PLT
	movq	56(%rsp), %rdi
	call	cudaEventDestroy@PLT
	movq	64(%rsp), %rdi
	call	cudaEventDestroy@PLT
	movq	%rbx, %rdi
	leaq	.LC4(%rip), %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	24(%rsp), %rdi
	movl	$2000, %ecx
	movq	%rbp, %rsi
	movl	$2000, %edx
	movq	%rax, %r14
	call	_Z14compare_MatrixPPiS0_ii
	movq	%r14, %rdi
	movzbl	%al, %esi
	call	_ZNSo9_M_insertIbEERSoT_@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	movq	%rbx, %rdi
	leaq	.LC5(%rip), %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	$125, %esi
	movq	%rax, %rdi
	call	_ZNSolsEi@PLT
	leaq	.LC6(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	$16, %esi
	movq	%rax, %rdi
	call	_ZNSolsEi@PLT
	leaq	.LC7(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	cvtss2sd	48(%rsp), %xmm0
	movq	%rax, %rdi
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	leaq	.LC8(%rip), %rsi
	movq	%rbx, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movss	52(%rsp), %xmm0
	divss	48(%rsp), %xmm0
	cvtss2sd	%xmm0, %xmm0
	movq	%rax, %rdi
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	leaq	.LC9(%rip), %rsi
	movq	%rbx, %rdi
	leaq	.LC0(%rip), %rbx
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movss	.LC10(%rip), %xmm1
	mulss	48(%rsp), %xmm1
	movss	52(%rsp), %xmm0
	movq	%rax, %rdi
	divss	%xmm1, %xmm0
	cvtss2sd	%xmm0, %xmm0
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	movl	$2000, %esi
	movq	%r13, %rdi
	call	_ZNSolsEi@PLT
	movq	%rbx, %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	$5, %esi
	movq	%rax, %rdi
	call	_ZNSolsEi@PLT
	movq	%rbx, %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	$16, %esi
	movq	%rax, %rdi
	call	_ZNSolsEi@PLT
	movq	%rbx, %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	cvtss2sd	52(%rsp), %xmm0
	movq	%rax, %rdi
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	movq	%rbx, %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	cvtss2sd	48(%rsp), %xmm0
	movq	%rax, %rdi
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	movq	%rbx, %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movss	.LC10(%rip), %xmm1
	mulss	48(%rsp), %xmm1
	movss	52(%rsp), %xmm0
	movq	%rax, %rdi
	divss	%xmm1, %xmm0
	cvtss2sd	%xmm0, %xmm0
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	movq	%rbx, %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movss	52(%rsp), %xmm0
	divss	48(%rsp), %xmm0
	cvtss2sd	%xmm0, %xmm0
	movq	%rax, %rdi
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	movq	%r12, %rdi
	call	cudaFree@PLT
	movq	40(%rsp), %rdi
	call	cudaFree@PLT
	movq	32(%rsp), %rdi
	call	cudaFree@PLT
	movq	16(%rsp), %rdi
	call	free@PLT
	movq	24(%rsp), %rdi
	call	free@PLT
	movq	8(%rsp), %rdi
	call	free@PLT
	movq	72(%rsp), %rax
	subq	%fs:40, %rax
	je	.L123
	call	__stack_chk_fail@PLT
.L123:
	addq	$88, %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
.LFE3778:
	.size	main, .-main
	.text
	.globl	_Z43__device_stub__Z15convolucionCUDAPPiS0_S0_iPPiS0_S0_i
	.type	_Z43__device_stub__Z15convolucionCUDAPPiS0_S0_iPPiS0_S0_i, @function
_Z43__device_stub__Z15convolucionCUDAPPiS0_S0_iPPiS0_S0_i:
.LFB3803:
	.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	.L125
	pushq	48(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z15convolucionCUDAPPiS0_S0_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
.L125:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L127
	call	__stack_chk_fail@PLT
.L127:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3803:
	.size	_Z43__device_stub__Z15convolucionCUDAPPiS0_S0_iPPiS0_S0_i, .-_Z43__device_stub__Z15convolucionCUDAPPiS0_S0_iPPiS0_S0_i
	.globl	_Z15convolucionCUDAPPiS0_S0_i
	.type	_Z15convolucionCUDAPPiS0_S0_i, @function
_Z15convolucionCUDAPPiS0_S0_i:
.LFB3804:
	.cfi_startproc
	endbr64
	jmp	_Z43__device_stub__Z15convolucionCUDAPPiS0_S0_iPPiS0_S0_i
	.cfi_endproc
.LFE3804:
	.size	_Z15convolucionCUDAPPiS0_S0_i, .-_Z15convolucionCUDAPPiS0_S0_i
	.globl	_Z38__device_stub__Z10convKernelPiS_iiiiS_PiS_iiiiS_
	.type	_Z38__device_stub__Z10convKernelPiS_iiiiS_PiS_iiiiS_, @function
_Z38__device_stub__Z10convKernelPiS_iiiiS_PiS_iiiiS_:
.LFB3805:
	.cfi_startproc
	endbr64
	subq	$184, %rsp
	.cfi_def_cfa_offset 192
	movq	192(%rsp), %rax
	movq	%rdi, 40(%rsp)
	leaq	64(%rsp), %rdi
	movq	%rsi, 32(%rsp)
	leaq	76(%rsp), %rsi
	movl	%edx, 28(%rsp)
	leaq	48(%rsp), %rdx
	movl	%ecx, 24(%rsp)
	leaq	56(%rsp), %rcx
	movl	%r8d, 20(%rsp)
	movl	%r9d, 16(%rsp)
	movq	%rax, 8(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 168(%rsp)
	xorl	%eax, %eax
	leaq	40(%rsp), %rax
	movl	$1, 72(%rsp)
	movq	%rax, 112(%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	28(%rsp), %rax
	movq	%rax, 128(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 136(%rsp)
	leaq	20(%rsp), %rax
	movq	%rax, 144(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 152(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 160(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 64(%rsp)
	movq	%rax, 76(%rsp)
	movl	$1, 84(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L130
	pushq	56(%rsp)
	.cfi_def_cfa_offset 200
	leaq	_Z10convKernelPiS_iiiiS_(%rip), %rdi
	pushq	56(%rsp)
	.cfi_def_cfa_offset 208
	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 200
	popq	%rdx
	.cfi_def_cfa_offset 192
.L130:
	movq	168(%rsp), %rax
	subq	%fs:40, %rax
	je	.L132
	call	__stack_chk_fail@PLT
.L132:
	addq	$184, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3805:
	.size	_Z38__device_stub__Z10convKernelPiS_iiiiS_PiS_iiiiS_, .-_Z38__device_stub__Z10convKernelPiS_iiiiS_PiS_iiiiS_
	.globl	_Z10convKernelPiS_iiiiS_
	.type	_Z10convKernelPiS_iiiiS_, @function
_Z10convKernelPiS_iiiiS_:
.LFB3806:
	.cfi_startproc
	endbr64
	jmp	_Z38__device_stub__Z10convKernelPiS_iiiiS_PiS_iiiiS_
	.cfi_endproc
.LFE3806:
	.size	_Z10convKernelPiS_iiiiS_, .-_Z10convKernelPiS_iiiiS_
	.section	.rodata.str1.1
.LC11:
	.string	"_Z10convKernelPiS_iiiiS_"
.LC12:
	.string	"_Z15convolucionCUDAPPiS0_S0_i"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB3808:
	.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	.LC11(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z10convKernelPiS_iiiiS_(%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	.LC12(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z15convolucionCUDAPPiS0_S0_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
.LFE3808:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.rodata.str1.1
.LC13:
	.string	"convolucion.txt"
	.section	.text.startup
	.type	_GLOBAL__sub_I_fs, @function
_GLOBAL__sub_I_fs:
.LFB4487:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	leaq	fs(%rip), %rbx
	movl	$16, %edx
	leaq	.LC13(%rip), %rsi
	movq	%rbx, %rdi
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEEC1EPKcSt13_Ios_Openmode@PLT
	movq	_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev@GOTPCREL(%rip), %rdi
	movq	%rbx, %rsi
	popq	%rbx
	.cfi_def_cfa_offset 8
	leaq	__dso_handle(%rip), %rdx
	jmp	__cxa_atexit@PLT
	.cfi_endproc
.LFE4487:
	.size	_GLOBAL__sub_I_fs, .-_GLOBAL__sub_I_fs
	.section	.init_array
	.align 8
	.quad	_GLOBAL__sub_I_fs
	.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
	.globl	fs
	.bss
	.align 32
	.type	fs, @object
	.size	fs, 512
fs:
	.zero	512
	.section	.rodata.cst4,"aM",@progbits,4
	.align 4
.LC2:
	.long	1148846080
	.align 4
.LC10:
	.long	1098907648
	.hidden	__dso_handle
	.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<stdio.h>
#include<iostream>
#include<fstream>
#include<hip/hip_runtime.h>
#include<time.h>
#include<sys/time.h>

#define IMAGE_LENGTH 2000
#define KERNEL_LENGTH 5
#define MAX_NUMBER 12
#define NumOfBlocks IMAGE_LENGTH/16
#define NumOfThreads 16

using namespace std;
ofstream fs("convolucion.txt");

void print_Matrix(int** matrix, int n, int m){
  for(int i = 0; i < n; i++){
    for(int j = 0; j < m; j++){
      cout<<" "<<matrix[i][j];            
    }
    cout<<endl;
  }
}

int** create_Matrix(int n, int m){
  int **matrix;
  matrix = (int **)malloc(n*sizeof(int *));
  for(int i=0; i < n; i++) {
    matrix[i] = (int *)malloc(m*sizeof(int));
  }
  return matrix;
}

int** gpu_create_Matrix(int n, int m){
  int **matrix;
  hipMalloc((void***)&matrix,  n*sizeof(int*));
  for(int i=0; i < n; i++) {
    hipMalloc((void**) &(matrix[i]), m*sizeof(int));
  }
  return matrix;
}

int** gpu_copy_Matrix(int **host, int n, int m){
  int** device = (int **)malloc(n * sizeof(int *));
  int **aux = (int **)malloc(n * sizeof(int *));
  hipMalloc((void***)&device,  n*sizeof(int*));
  for(int i=0; i<n; i++) {
    hipMalloc((void**) &(aux[i]), m*sizeof(int));
    hipMemcpy (aux[i], host[i], m*sizeof(float), hipMemcpyHostToDevice);
  }
  hipMemcpy(device, aux, n*sizeof(int *), hipMemcpyHostToDevice);
  return device;
}

int** cpu_copy_Matrix(int **device, int n, int m){
  int** host = (int **)malloc(n * sizeof(int *));
  int **aux = (int **)malloc(n * sizeof(int *));
  hipMalloc((void***)&host,  n*sizeof(int*));
  for(int i=0; i<n; i++) {
    hipMalloc((void**) &(aux[i]), m*sizeof(int));
    hipMemcpy (aux[i], device[i], m*sizeof(float), hipMemcpyDeviceToHost);
  }
  hipMemcpy(host, aux, n*sizeof(int *), hipMemcpyDeviceToHost);
  return host;
}

int** copy_Matrix(int **orig, int n, int m){
  int** cpy = create_Matrix(n,m);
  for(int i=0; i<n; i++) {
    for(int j=0; i<m; i++){
      cpy[i][j] = orig[i][j];
    }
  }
  return cpy;
}

void generate_Kernel_Matrix(int** a, int n, int m){
  srand( (unsigned)time( NULL ) );
  for(int i=0; i<n;i++){
    for(int j=0;j<m;j++){
      //a[i][j] = (rand()%MAX_NUMBER)+1;;
      a[i][j] = 1;
    }
  }
}

void generate_Image_Matrix(int** a, int n, int m, int index){
  srand( (unsigned)time( NULL ) );
  for(int i=0;i<index;i++){
    for(int j=0;j<m;j++){
      a[i][j] = 0;
    }
  }
  for(int i=0;i<n-index;i++){
    for(int j=0;j<index;j++){
      a[i][j] = 0;
    }
  }
  for(int i=n-index;i<n;i++){
    for(int j=0;j<m;j++){
      a[i][j] = 0;
    }
  }
  for(int i=0;i<n;i++){
    for(int j=m-index;j<m;j++){
      a[i][j] = 0;
    }
  }
  for(int i=index; i<n-index;i++){
    for(int j=index;j<m-index;j++){
      a[i][j] = (rand()%MAX_NUMBER)+1;
      //a[i][j] = j;
    }
  }
}

void init_Matrix(int** a,int n, int m){
  for(int i=0; i<n;i++){
    for(int j=0;j<m;j++){
      a[i][j]=0;
    }
  }
}

bool compare_Matrix(int** A, int** B, int n, int m){
  bool same = true;
  for(int i=0; i<n;i++){
    for(int j=0;j<m;j++){
      if(A[i][j]!=B[i][j]){
        same = false;
        break;
      }
    }
  }
  return same;
}

int sumTermsMatrix(int** a, int n, int m){
  int suma = 0;
  for(int i=0; i<n;i++){
    for(int j=0;j<m;j++){
      suma+=a[i][j];
    }
  }
  return suma;
}

void convolucion(int** kernel, int** image, int** result, int KERNELCOUNT){
  int i, j, n, m;
  int acumulador=0;
  
  for (i=0; i < IMAGE_LENGTH; i++){
    for (j=0; j < IMAGE_LENGTH; j++){
      for (n = 0; n < KERNEL_LENGTH; n++){
        for (m = 0; m < KERNEL_LENGTH; m++){
          acumulador += image[i + n][j + m] * kernel[n][m];
        }
      }
      result[i][j] = acumulador/KERNELCOUNT;
      acumulador = 0;
    }
  }
}

__global__ void convolucionCUDA(int** kernel, int** image, int** result, int KERNELCOUNT){
  int i, j, n, m;
  int acumulador=0;
  
  for (i=0; i < IMAGE_LENGTH; i++){
    for (j=0; j < IMAGE_LENGTH; j++){
      for (n = 0; n < KERNEL_LENGTH; n++){
        for (m = 0; m < KERNEL_LENGTH; m++){
          acumulador += image[i + n][j + m] * kernel[n][m];
        }
      }
      result[i][j] = acumulador/KERNELCOUNT;
      acumulador = 0;
    }
  }
}

__global__ void convKernel(int *inData, int *filter, int dataCol, int dataRow, int filRowRad, int filColRad,
               int *outData)
{
  __shared__ int padRect[2*1024];
  int i, col, row, sum = 0;

  int globalCol = threadIdx.x + blockIdx.x * blockDim.x;
  int globalRow = threadIdx.y + blockIdx.y * blockDim.y;
  int globalIdx = globalCol * dataRow + globalRow;

  int localIdx = threadIdx.x * blockDim.y + threadIdx.y;
  int localCells = blockDim.x * blockDim.y;

  int padRectCol = threadIdx.x + filColRad;
  int padRectRow = threadIdx.y + filRowRad;
  int padRectOffset = 2*filRowRad + blockDim.y;
  int padRectCells = padRectOffset * (blockDim.x + 2*filColRad);

  int *padRectOut = (int*)&padRect[((padRectCells-1)/32 + 1) * 32]; //Padding up with 32
  padRectOut[localIdx] = 0;

  int filOffset = filRowRad*2 + 1;
  int filCells = filOffset * (filColRad*2 + 1);
  int *localFilter = (int *)&padRectOut[((localCells-1)/32 + 1) * 32]; //Padding up with 32

  // Copying the filter elements to shared memory
  for(i = 0; i < (filCells/localCells) + 1; i++) {
    int index = i*localCells + localIdx;
    if(index < filCells) {
      localFilter[index] = filter[index];
    }
  }

  // Copying the Data elements to padded shared memory
  for(i = 0; i < (padRectCells/localCells) + 1; i++) {
    int index = i*localCells + localIdx;
    if(index < padRectCells) {
      int prCol = index / padRectOffset;
      int prRow = index % padRectOffset;
      int glCol = prCol + blockIdx.x*blockDim.x - filColRad;
      int glRow = prRow + blockIdx.y*blockDim.y - filRowRad;
      int glIdx = glCol * dataRow + glRow;
      if(glRow >= 0 && glRow < dataRow && glCol >= 0 && glCol < dataCol)
        padRect[index] = inData[glIdx];
      else
        padRect[index] = 0;
    }
  }

  __syncthreads();

  //Taking Convolution
  for(col = -filColRad; col <= filColRad; col++) {
    for(row = -filRowRad; row <= filRowRad; row++) {
      int filCol = filColRad - col;
      int filRow = filRowRad - row;
      int filIdx = filCol*filOffset + filRow;
      int filVal = localFilter[filIdx];

      int prCol = padRectCol + col;
      int prRow = padRectRow + row;
      int prIdx = prCol*padRectOffset + prRow;
      sum += filVal * padRect[prIdx];
    }
  }
  
  padRectOut[localIdx] = sum;
  __syncthreads();

  outData[globalIdx] = padRectOut[localIdx];


}

int main(){
  float parallelTime, serialTime;
  hipEvent_t tStart, tStop;
  hipEventCreateWithFlags(&tStart, 0);
  hipEventCreateWithFlags(&tStop, 0);
  int realKernelLength=0, index = 0;
  if(KERNEL_LENGTH%2!=0){
    realKernelLength = KERNEL_LENGTH - 1;
    index = KERNEL_LENGTH/2;
  } else{
    cout << "Matrix Convolution siempre debe ser 2*N+1"<<endl;
    exit(0);
  }
  int** kernel = create_Matrix(KERNEL_LENGTH, KERNEL_LENGTH);
  int** image = create_Matrix(IMAGE_LENGTH+realKernelLength, IMAGE_LENGTH+realKernelLength);
  int** result = create_Matrix(IMAGE_LENGTH, IMAGE_LENGTH);
  int** resultCUDA = create_Matrix(IMAGE_LENGTH, IMAGE_LENGTH);

  generate_Kernel_Matrix(kernel, KERNEL_LENGTH,KERNEL_LENGTH);
  generate_Image_Matrix(image, IMAGE_LENGTH+realKernelLength, IMAGE_LENGTH+realKernelLength, index);
  init_Matrix(result, IMAGE_LENGTH, IMAGE_LENGTH);
  
  int KERNELCOUNT = sumTermsMatrix(kernel,KERNEL_LENGTH,KERNEL_LENGTH);
  
  hipEventRecord(tStart, 0);
  convolucion(kernel, image, result, KERNELCOUNT);
  hipEventRecord(tStop, 0);
  hipEventSynchronize(tStop);
  hipEventElapsedTime(&serialTime, tStart, tStop);
  hipEventDestroy(tStart);
  hipEventDestroy(tStop);

  if(IMAGE_LENGTH<10){
    cout << "Image: "<<endl;
    print_Matrix(image, IMAGE_LENGTH+realKernelLength, IMAGE_LENGTH+realKernelLength);
    cout << endl << endl;
    
    cout << "Kernel: "<<endl;
    print_Matrix(kernel, KERNEL_LENGTH, KERNEL_LENGTH);
    cout << endl << endl;

    cout << "Result: "<<endl;
    print_Matrix(result, IMAGE_LENGTH, IMAGE_LENGTH);
  }

  cout << "El tiempo en realizar la convolución en tiempo secuencial es: " << serialTime/1000 << endl;
  
//  int ns[] = {1, 2, 4, 8};
  
  fs << "ImgLenght KerLenght numthd serialTime parallelTime eff speedUp"<< endl;
  
  // ----
  int** gpu_kernel = copy_Matrix(kernel, KERNEL_LENGTH, KERNEL_LENGTH);
  int** gpu_image = copy_Matrix(image, IMAGE_LENGTH+realKernelLength, IMAGE_LENGTH+realKernelLength);
  init_Matrix(resultCUDA, IMAGE_LENGTH, IMAGE_LENGTH);
  int** gpu_result = copy_Matrix(resultCUDA, IMAGE_LENGTH, IMAGE_LENGTH);
    
  hipEventCreateWithFlags(&tStart, 0);
  hipEventCreateWithFlags(&tStop, 0);

  hipEventRecord(tStart, 0);

  dim3 num_threads(NumOfThreads, 16, 1);
  dim3 numOfBlocks(NumOfBlocks, 1, 1);
  //convolucionCUDA<<<numOfBlocks, num_threads>>>(gpu_image, gpu_kernel, gpu_result, KERNELCOUNT);
  hipEventRecord(tStop, 0);
  hipEventSynchronize(tStop);
  hipEventElapsedTime(&parallelTime, tStart, tStop);
  hipEventDestroy(tStart);
  hipEventDestroy(tStop);

  //resultCUDA = cpu_copy_Matrix(gpu_result, IMAGE_LENGTH, IMAGE_LENGTH);
  
  cout << "Son iguales: "<< compare_Matrix(result, resultCUDA, IMAGE_LENGTH, IMAGE_LENGTH) << endl;

  cout << "El tiempo en realizar la convolución en tiempo Paralelo con " << NumOfBlocks << " bloques y " << NumOfThreads <<" hilos es: " << parallelTime << endl;    
  cout << "Speed UP: "<< serialTime/(parallelTime) << endl;
  cout << "Eficiencia: "<< serialTime/(parallelTime*NumOfThreads) << endl;
  
  fs << IMAGE_LENGTH << " " << KERNEL_LENGTH << " " << NumOfThreads <<" " << serialTime <<" " << parallelTime << " " << serialTime/(parallelTime*NumOfThreads)<<" "<< serialTime/(parallelTime) << endl;

  hipFree(gpu_image);
  hipFree(gpu_result);
  hipFree(gpu_kernel);
  
  free(image);
  free(result);
  free(kernel);
  
  return 0;
}

	.text
	.file	"gpu_parallel_convolution.hip"
                                        # Start of file scope inline assembly
	.globl	_ZSt21ios_base_library_initv

                                        # End of file scope inline assembly
	.globl	_Z12print_MatrixPPiii           # -- Begin function _Z12print_MatrixPPiii
	.type	_Z12print_MatrixPPiii,@function
_Z12print_MatrixPPiii:                  # @_Z12print_MatrixPPiii
	.cfi_startproc
# %bb.0:
	testl	%esi, %esi
	jle	.LBB0_7
# %bb.1:                                # %.preheader.lr.ph
	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
.LBB0_2:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB0_4 Depth 2
	testl	%ebx, %ebx
	jle	.LBB0_5
# %bb.3:                                # %.lr.ph
                                        #   in Loop: Header=BB0_2 Depth=1
	xorl	%ebp, %ebp
.LBB0_4:                                #   Parent Loop BB0_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	$_ZSt4cout, %edi
	movl	$.L.str.1, %esi
	movl	$1, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	(%r14,%r13,8), %rax
	movl	(%rax,%rbp,4), %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSolsEi
	incq	%rbp
	cmpq	%rbp, %r12
	jne	.LBB0_4
.LBB0_5:                                # %._crit_edge
                                        #   in Loop: Header=BB0_2 Depth=1
	movq	_ZSt4cout(%rip), %rax
	movq	-24(%rax), %rdi
	movl	$_ZSt4cout, %eax
	addq	%rax, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	incq	%r13
	cmpq	%r15, %r13
	jne	.LBB0_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
.LBB0_7:                                # %._crit_edge11
	retq
.Lfunc_end0:
	.size	_Z12print_MatrixPPiii, .Lfunc_end0-_Z12print_MatrixPPiii
	.cfi_endproc
                                        # -- End function
	.globl	_Z13create_Matrixii             # -- Begin function _Z13create_Matrixii
	.type	_Z13create_Matrixii,@function
_Z13create_Matrixii:                    # @_Z13create_Matrixii
	.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	%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	%esi, %r14d
	movl	%edi, %ebp
	movslq	%edi, %r15
	leaq	(,%r15,8), %rdi
	callq	malloc
	movq	%rax, %rbx
	testl	%r15d, %r15d
	jle	.LBB1_3
# %bb.1:                                # %.lr.ph
	movslq	%r14d, %r14
	shlq	$2, %r14
	movl	%ebp, %r15d
	xorl	%r12d, %r12d
.LBB1_2:                                # =>This Inner Loop Header: Depth=1
	movq	%r14, %rdi
	callq	malloc
	movq	%rax, (%rbx,%r12,8)
	incq	%r12
	cmpq	%r12, %r15
	jne	.LBB1_2
.LBB1_3:                                # %._crit_edge
	movq	%rbx, %rax
	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
	retq
.Lfunc_end1:
	.size	_Z13create_Matrixii, .Lfunc_end1-_Z13create_Matrixii
	.cfi_endproc
                                        # -- End function
	.globl	_Z17gpu_create_Matrixii         # -- Begin function _Z17gpu_create_Matrixii
	.type	_Z17gpu_create_Matrixii,@function
_Z17gpu_create_Matrixii:                # @_Z17gpu_create_Matrixii
	.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	%rbx
	.cfi_def_cfa_offset 40
	pushq	%rax
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	%esi, %ebx
	movl	%edi, %ebp
	movslq	%edi, %r14
	leaq	(,%r14,8), %rsi
	movq	%rsp, %rdi
	callq	hipMalloc
	testl	%r14d, %r14d
	jle	.LBB2_3
# %bb.1:                                # %.lr.ph
	movslq	%ebx, %rbx
	shlq	$2, %rbx
	movl	%ebp, %r14d
	shlq	$3, %r14
	xorl	%r15d, %r15d
.LBB2_2:                                # =>This Inner Loop Header: Depth=1
	movq	(%rsp), %rdi
	addq	%r15, %rdi
	movq	%rbx, %rsi
	callq	hipMalloc
	addq	$8, %r15
	cmpq	%r15, %r14
	jne	.LBB2_2
.LBB2_3:                                # %._crit_edge
	movq	(%rsp), %rax
	addq	$8, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.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_end2:
	.size	_Z17gpu_create_Matrixii, .Lfunc_end2-_Z17gpu_create_Matrixii
	.cfi_endproc
                                        # -- End function
	.globl	_Z15gpu_copy_MatrixPPiii        # -- Begin function _Z15gpu_copy_MatrixPPiii
	.type	_Z15gpu_copy_MatrixPPiii,@function
_Z15gpu_copy_MatrixPPiii:               # @_Z15gpu_copy_MatrixPPiii
	.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	%edx, 12(%rsp)                  # 4-byte Spill
	movl	%esi, %ebp
	movq	%rdi, %r14
	movslq	%esi, %r12
	leaq	(,%r12,8), %rbx
	movq	%rbx, %rdi
	callq	malloc
	leaq	16(%rsp), %r13
	movq	%rax, (%r13)
	movq	%rbx, %rdi
	callq	malloc
	movq	%rax, %r15
	movq	%r13, %rdi
	movq	%rbx, %rsi
	callq	hipMalloc
	testl	%r12d, %r12d
	jle	.LBB3_3
# %bb.1:                                # %.lr.ph
	movslq	12(%rsp), %r12                  # 4-byte Folded Reload
	shlq	$2, %r12
	movl	%ebp, %r13d
	shlq	$3, %r13
	xorl	%ebp, %ebp
.LBB3_2:                                # =>This Inner Loop Header: Depth=1
	leaq	(%r15,%rbp), %rdi
	movq	%r12, %rsi
	callq	hipMalloc
	movq	(%r15,%rbp), %rdi
	movq	(%r14,%rbp), %rsi
	movq	%r12, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	addq	$8, %rbp
	cmpq	%rbp, %r13
	jne	.LBB3_2
.LBB3_3:                                # %._crit_edge
	movq	16(%rsp), %rdi
	movq	%r15, %rsi
	movq	%rbx, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	16(%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_end3:
	.size	_Z15gpu_copy_MatrixPPiii, .Lfunc_end3-_Z15gpu_copy_MatrixPPiii
	.cfi_endproc
                                        # -- End function
	.globl	_Z15cpu_copy_MatrixPPiii        # -- Begin function _Z15cpu_copy_MatrixPPiii
	.type	_Z15cpu_copy_MatrixPPiii,@function
_Z15cpu_copy_MatrixPPiii:               # @_Z15cpu_copy_MatrixPPiii
	.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	%edx, 12(%rsp)                  # 4-byte Spill
	movl	%esi, %ebp
	movq	%rdi, %r14
	movslq	%esi, %r12
	leaq	(,%r12,8), %rbx
	movq	%rbx, %rdi
	callq	malloc
	leaq	16(%rsp), %r13
	movq	%rax, (%r13)
	movq	%rbx, %rdi
	callq	malloc
	movq	%rax, %r15
	movq	%r13, %rdi
	movq	%rbx, %rsi
	callq	hipMalloc
	testl	%r12d, %r12d
	jle	.LBB4_3
# %bb.1:                                # %.lr.ph
	movslq	12(%rsp), %r12                  # 4-byte Folded Reload
	shlq	$2, %r12
	movl	%ebp, %r13d
	shlq	$3, %r13
	xorl	%ebp, %ebp
.LBB4_2:                                # =>This Inner Loop Header: Depth=1
	leaq	(%r15,%rbp), %rdi
	movq	%r12, %rsi
	callq	hipMalloc
	movq	(%r15,%rbp), %rdi
	movq	(%r14,%rbp), %rsi
	movq	%r12, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	addq	$8, %rbp
	cmpq	%rbp, %r13
	jne	.LBB4_2
.LBB4_3:                                # %._crit_edge
	movq	16(%rsp), %rdi
	movq	%r15, %rsi
	movq	%rbx, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	movq	16(%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_end4:
	.size	_Z15cpu_copy_MatrixPPiii, .Lfunc_end4-_Z15cpu_copy_MatrixPPiii
	.cfi_endproc
                                        # -- End function
	.globl	_Z11copy_MatrixPPiii            # -- Begin function _Z11copy_MatrixPPiii
	.type	_Z11copy_MatrixPPiii,@function
_Z11copy_MatrixPPiii:                   # @_Z11copy_MatrixPPiii
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %rbp, -16
	movl	%edx, %ebx
	movl	%esi, %ebp
	movq	%rdi, %r14
	movl	%esi, %edi
	movl	%edx, %esi
	callq	_Z13create_Matrixii
	testl	%ebp, %ebp
	jle	.LBB5_7
# %bb.1:                                # %.preheader.preheader
	movslq	%ebx, %rcx
	xorl	%edx, %edx
.LBB5_2:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB5_4 Depth 2
	cmpl	%ebx, %edx
	jge	.LBB5_6
# %bb.3:                                # %.lr.ph.preheader
                                        #   in Loop: Header=BB5_2 Depth=1
	movslq	%edx, %rdx
.LBB5_4:                                # %.lr.ph
                                        #   Parent Loop BB5_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movq	(%r14,%rdx,8), %rsi
	movl	(%rsi), %esi
	movq	(%rax,%rdx,8), %rdi
	movl	%esi, (%rdi)
	incq	%rdx
	cmpq	%rdx, %rcx
	jne	.LBB5_4
# %bb.5:                                #   in Loop: Header=BB5_2 Depth=1
	movl	%ebx, %edx
.LBB5_6:                                # %._crit_edge
                                        #   in Loop: Header=BB5_2 Depth=1
	incl	%edx
	cmpl	%ebp, %edx
	jl	.LBB5_2
.LBB5_7:                                # %._crit_edge16
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end5:
	.size	_Z11copy_MatrixPPiii, .Lfunc_end5-_Z11copy_MatrixPPiii
	.cfi_endproc
                                        # -- End function
	.globl	_Z22generate_Kernel_MatrixPPiii # -- Begin function _Z22generate_Kernel_MatrixPPiii
	.type	_Z22generate_Kernel_MatrixPPiii,@function
_Z22generate_Kernel_MatrixPPiii:        # @_Z22generate_Kernel_MatrixPPiii
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %rbp, -16
	movl	%edx, %ebx
	movl	%esi, %ebp
	movq	%rdi, %r14
	xorl	%edi, %edi
	callq	time
	movl	%eax, %edi
	callq	srand
	testl	%ebp, %ebp
	jle	.LBB6_6
# %bb.1:                                # %.preheader.lr.ph
	movl	%ebp, %eax
	movl	%ebx, %ecx
	xorl	%edx, %edx
.LBB6_2:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB6_4 Depth 2
	testl	%ebx, %ebx
	jle	.LBB6_5
# %bb.3:                                # %.lr.ph
                                        #   in Loop: Header=BB6_2 Depth=1
	movq	(%r14,%rdx,8), %rsi
	xorl	%edi, %edi
.LBB6_4:                                #   Parent Loop BB6_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	$1, (%rsi,%rdi,4)
	incq	%rdi
	cmpq	%rdi, %rcx
	jne	.LBB6_4
.LBB6_5:                                # %._crit_edge
                                        #   in Loop: Header=BB6_2 Depth=1
	incq	%rdx
	cmpq	%rax, %rdx
	jne	.LBB6_2
.LBB6_6:                                # %._crit_edge11
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end6:
	.size	_Z22generate_Kernel_MatrixPPiii, .Lfunc_end6-_Z22generate_Kernel_MatrixPPiii
	.cfi_endproc
                                        # -- End function
	.globl	_Z21generate_Image_MatrixPPiiii # -- Begin function _Z21generate_Image_MatrixPPiiii
	.type	_Z21generate_Image_MatrixPPiiii,@function
_Z21generate_Image_MatrixPPiiii:        # @_Z21generate_Image_MatrixPPiiii
	.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	%ecx, %ebx
	movl	%edx, %ebp
	movl	%esi, 16(%rsp)                  # 4-byte Spill
	movq	%rdi, %r14
	xorl	%edi, %edi
	callq	time
	movl	%eax, %edi
	callq	srand
	movl	%ebp, 12(%rsp)                  # 4-byte Spill
	movl	%ebp, %r12d
	movl	%ebx, %r13d
	testl	%ebx, %ebx
	jle	.LBB7_5
# %bb.1:                                # %.preheader71.lr.ph
	leaq	(,%r12,4), %r15
	xorl	%ebp, %ebp
.LBB7_2:                                # %.preheader71
                                        # =>This Inner Loop Header: Depth=1
	cmpl	$0, 12(%rsp)                    # 4-byte Folded Reload
	jle	.LBB7_4
# %bb.3:                                # %.lr.ph
                                        #   in Loop: Header=BB7_2 Depth=1
	movq	(%r14,%rbp,8), %rdi
	xorl	%esi, %esi
	movq	%r15, %rdx
	callq	memset@PLT
.LBB7_4:                                # %._crit_edge
                                        #   in Loop: Header=BB7_2 Depth=1
	incq	%rbp
	cmpq	%rbp, %r13
	jne	.LBB7_2
.LBB7_5:                                # %.preheader70
	movl	16(%rsp), %eax                  # 4-byte Reload
	subl	%ebx, %eax
	movl	%eax, 20(%rsp)                  # 4-byte Spill
	jle	.LBB7_10
# %bb.6:                                # %.preheader69.lr.ph
	shlq	$2, %r13
	movl	20(%rsp), %r15d                 # 4-byte Reload
	xorl	%ebp, %ebp
.LBB7_7:                                # %.preheader69
                                        # =>This Inner Loop Header: Depth=1
	testl	%ebx, %ebx
	jle	.LBB7_9
# %bb.8:                                # %.lr.ph75
                                        #   in Loop: Header=BB7_7 Depth=1
	movq	(%r14,%rbp,8), %rdi
	xorl	%esi, %esi
	movq	%r13, %rdx
	callq	memset@PLT
.LBB7_9:                                # %._crit_edge76
                                        #   in Loop: Header=BB7_7 Depth=1
	incq	%rbp
	cmpq	%rbp, %r15
	jne	.LBB7_7
.LBB7_10:                               # %.preheader68
	testl	%ebx, %ebx
	movl	16(%rsp), %ebp                  # 4-byte Reload
	jle	.LBB7_15
# %bb.11:                               # %.preheader67.lr.ph
	shlq	$2, %r12
	movslq	20(%rsp), %r15                  # 4-byte Folded Reload
	movslq	%ebp, %r13
.LBB7_12:                               # %.preheader67
                                        # =>This Inner Loop Header: Depth=1
	cmpl	$0, 12(%rsp)                    # 4-byte Folded Reload
	jle	.LBB7_14
# %bb.13:                               # %.lr.ph79
                                        #   in Loop: Header=BB7_12 Depth=1
	movq	(%r14,%r15,8), %rdi
	xorl	%esi, %esi
	movq	%r12, %rdx
	callq	memset@PLT
.LBB7_14:                               # %._crit_edge80
                                        #   in Loop: Header=BB7_12 Depth=1
	incq	%r15
	cmpq	%r13, %r15
	jl	.LBB7_12
.LBB7_15:                               # %.preheader66
	testl	%ebp, %ebp
	jle	.LBB7_20
# %bb.16:                               # %.lr.ph87
	movl	12(%rsp), %ecx                  # 4-byte Reload
	movl	%ecx, %eax
	subl	%ebx, %eax
	cltq
	leaq	(,%rax,4), %r15
	incl	%eax
	cmpl	%eax, %ecx
	cmovgl	%ecx, %eax
                                        # kill: def $ecx killed $ecx def $rcx
	notl	%ecx
	addl	%ebx, %ecx
	addl	%eax, %ecx
	leaq	4(,%rcx,4), %r12
	movl	%ebp, %r13d
	xorl	%ebp, %ebp
.LBB7_17:                               # =>This Inner Loop Header: Depth=1
	testl	%ebx, %ebx
	jle	.LBB7_19
# %bb.18:                               # %.lr.ph84
                                        #   in Loop: Header=BB7_17 Depth=1
	movq	(%r14,%rbp,8), %rdi
	addq	%r15, %rdi
	xorl	%esi, %esi
	movq	%r12, %rdx
	callq	memset@PLT
.LBB7_19:                               # %._crit_edge85
                                        #   in Loop: Header=BB7_17 Depth=1
	incq	%rbp
	cmpq	%rbp, %r13
	jne	.LBB7_17
.LBB7_20:                               # %.preheader65
	cmpl	%ebx, 20(%rsp)                  # 4-byte Folded Reload
	jle	.LBB7_24
# %bb.21:                               # %.preheader.lr.ph
	movl	12(%rsp), %ecx                  # 4-byte Reload
	movl	%ecx, %eax
	subl	%ebx, %eax
	movl	%eax, 16(%rsp)                  # 4-byte Spill
	movslq	%ebx, %r13
	subl	%ebx, %ecx
	subl	%ebx, %ecx
	movl	%ecx, 12(%rsp)                  # 4-byte Spill
	movq	%r13, %r12
.LBB7_22:                               # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB7_25 Depth 2
	movl	12(%rsp), %ebp                  # 4-byte Reload
	movq	%r12, %r15
	cmpl	%ebx, 16(%rsp)                  # 4-byte Folded Reload
	jle	.LBB7_23
.LBB7_25:                               #   Parent Loop BB7_22 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	callq	rand
	cltq
	imulq	$715827883, %rax, %rcx          # imm = 0x2AAAAAAB
	movq	%rcx, %rdx
	shrq	$63, %rdx
	shrq	$33, %rcx
	addl	%edx, %ecx
	shll	$2, %ecx
	leal	(%rcx,%rcx,2), %ecx
	negl	%ecx
	addl	%ecx, %eax
	incl	%eax
	movq	(%r14,%r13,8), %rcx
	movl	%eax, (%rcx,%r15,4)
	incq	%r15
	decl	%ebp
	jne	.LBB7_25
.LBB7_23:                               # %._crit_edge90
                                        #   in Loop: Header=BB7_22 Depth=1
	incq	%r13
	cmpl	%r13d, 20(%rsp)                 # 4-byte Folded Reload
	jne	.LBB7_22
.LBB7_24:                               # %._crit_edge92
	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_end7:
	.size	_Z21generate_Image_MatrixPPiiii, .Lfunc_end7-_Z21generate_Image_MatrixPPiiii
	.cfi_endproc
                                        # -- End function
	.globl	_Z11init_MatrixPPiii            # -- Begin function _Z11init_MatrixPPiii
	.type	_Z11init_MatrixPPiii,@function
_Z11init_MatrixPPiii:                   # @_Z11init_MatrixPPiii
	.cfi_startproc
# %bb.0:
	testl	%esi, %esi
	jle	.LBB8_6
# %bb.1:                                # %.preheader.lr.ph
	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
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movl	%edx, %ebx
	movq	%rdi, %r14
	movl	%edx, %r15d
	shlq	$2, %r15
	movl	%esi, %r12d
	xorl	%r13d, %r13d
.LBB8_2:                                # %.preheader
                                        # =>This Inner Loop Header: Depth=1
	testl	%ebx, %ebx
	jle	.LBB8_4
# %bb.3:                                # %.lr.ph
                                        #   in Loop: Header=BB8_2 Depth=1
	movq	(%r14,%r13,8), %rdi
	xorl	%esi, %esi
	movq	%r15, %rdx
	callq	memset@PLT
.LBB8_4:                                # %._crit_edge
                                        #   in Loop: Header=BB8_2 Depth=1
	incq	%r13
	cmpq	%r13, %r12
	jne	.LBB8_2
# %bb.5:
	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
	.cfi_restore %rbx
	.cfi_restore %r12
	.cfi_restore %r13
	.cfi_restore %r14
	.cfi_restore %r15
.LBB8_6:                                # %._crit_edge11
	retq
.Lfunc_end8:
	.size	_Z11init_MatrixPPiii, .Lfunc_end8-_Z11init_MatrixPPiii
	.cfi_endproc
                                        # -- End function
	.globl	_Z14compare_MatrixPPiS0_ii      # -- Begin function _Z14compare_MatrixPPiS0_ii
	.type	_Z14compare_MatrixPPiS0_ii,@function
_Z14compare_MatrixPPiS0_ii:             # @_Z14compare_MatrixPPiS0_ii
	.cfi_startproc
# %bb.0:
	testl	%edx, %edx
	jle	.LBB9_9
# %bb.1:                                # %.preheader.lr.ph
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset %rbx, -24
	.cfi_offset %rbp, -16
	movl	%edx, %edx
	movl	%ecx, %r8d
	movb	$1, %al
	xorl	%r9d, %r9d
.LBB9_2:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB9_4 Depth 2
	testl	%ecx, %ecx
	jle	.LBB9_7
# %bb.3:                                # %.lr.ph
                                        #   in Loop: Header=BB9_2 Depth=1
	movq	(%rdi,%r9,8), %r10
	movq	(%rsi,%r9,8), %r11
	xorl	%ebx, %ebx
.LBB9_4:                                #   Parent Loop BB9_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	(%r10,%rbx,4), %ebp
	cmpl	(%r11,%rbx,4), %ebp
	jne	.LBB9_6
# %bb.5:                                #   in Loop: Header=BB9_4 Depth=2
	incq	%rbx
	cmpq	%rbx, %r8
	jne	.LBB9_4
	jmp	.LBB9_7
.LBB9_6:                                #   in Loop: Header=BB9_2 Depth=1
	xorl	%eax, %eax
.LBB9_7:                                # %._crit_edge
                                        #   in Loop: Header=BB9_2 Depth=1
	incq	%r9
	cmpq	%rdx, %r9
	jne	.LBB9_2
# %bb.8:                                # %._crit_edge19.loopexit
	andb	$1, %al
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	.cfi_restore %rbx
	.cfi_restore %rbp
                                        # kill: def $al killed $al killed $eax
	retq
.LBB9_9:
	movb	$1, %al
                                        # kill: def $al killed $al killed $eax
	retq
.Lfunc_end9:
	.size	_Z14compare_MatrixPPiS0_ii, .Lfunc_end9-_Z14compare_MatrixPPiS0_ii
	.cfi_endproc
                                        # -- End function
	.globl	_Z14sumTermsMatrixPPiii         # -- Begin function _Z14sumTermsMatrixPPiii
	.type	_Z14sumTermsMatrixPPiii,@function
_Z14sumTermsMatrixPPiii:                # @_Z14sumTermsMatrixPPiii
	.cfi_startproc
# %bb.0:
	testl	%esi, %esi
	jle	.LBB10_1
# %bb.3:                                # %.preheader.lr.ph
	movl	%esi, %ecx
	movl	%edx, %esi
	xorl	%r8d, %r8d
	xorl	%eax, %eax
.LBB10_4:                               # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB10_6 Depth 2
	testl	%edx, %edx
	jle	.LBB10_7
# %bb.5:                                # %.lr.ph
                                        #   in Loop: Header=BB10_4 Depth=1
	movq	(%rdi,%r8,8), %r9
	xorl	%r10d, %r10d
.LBB10_6:                               #   Parent Loop BB10_4 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	addl	(%r9,%r10,4), %eax
	incq	%r10
	cmpq	%r10, %rsi
	jne	.LBB10_6
.LBB10_7:                               # %._crit_edge
                                        #   in Loop: Header=BB10_4 Depth=1
	incq	%r8
	cmpq	%rcx, %r8
	jne	.LBB10_4
# %bb.2:                                # %._crit_edge16
	retq
.LBB10_1:
	xorl	%eax, %eax
	retq
.Lfunc_end10:
	.size	_Z14sumTermsMatrixPPiii, .Lfunc_end10-_Z14sumTermsMatrixPPiii
	.cfi_endproc
                                        # -- End function
	.globl	_Z11convolucionPPiS0_S0_i       # -- Begin function _Z11convolucionPPiS0_S0_i
	.type	_Z11convolucionPPiS0_S0_i,@function
_Z11convolucionPPiS0_S0_i:              # @_Z11convolucionPPiS0_S0_i
	.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
	.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	%rdx, %r8
	xorl	%r9d, %r9d
.LBB11_1:                               # %.preheader26
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB11_2 Depth 2
                                        #       Child Loop BB11_3 Depth 3
                                        #         Child Loop BB11_4 Depth 4
	movq	(%r8,%r9,8), %r10
	leaq	(%rsi,%r9,8), %r11
	xorl	%ebx, %ebx
	xorl	%r14d, %r14d
.LBB11_2:                               # %.preheader25
                                        #   Parent Loop BB11_1 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB11_3 Depth 3
                                        #         Child Loop BB11_4 Depth 4
	xorl	%edx, %edx
	xorl	%eax, %eax
.LBB11_3:                               # %.preheader
                                        #   Parent Loop BB11_1 Depth=1
                                        #     Parent Loop BB11_2 Depth=2
                                        # =>    This Loop Header: Depth=3
                                        #         Child Loop BB11_4 Depth 4
	movq	(%rdi,%rdx,8), %r15
	movq	(%r11,%rdx,8), %r12
	addq	%rbx, %r12
	xorl	%r13d, %r13d
.LBB11_4:                               #   Parent Loop BB11_1 Depth=1
                                        #     Parent Loop BB11_2 Depth=2
                                        #       Parent Loop BB11_3 Depth=3
                                        # =>      This Inner Loop Header: Depth=4
	movl	(%r15,%r13,4), %ebp
	imull	(%r12,%r13,4), %ebp
	addl	%ebp, %eax
	incq	%r13
	cmpq	$5, %r13
	jne	.LBB11_4
# %bb.5:                                #   in Loop: Header=BB11_3 Depth=3
	incq	%rdx
	cmpq	$5, %rdx
	jne	.LBB11_3
# %bb.6:                                #   in Loop: Header=BB11_2 Depth=2
	cltd
	idivl	%ecx
	movl	%eax, (%r10,%r14,4)
	incq	%r14
	addq	$4, %rbx
	cmpq	$2000, %r14                     # imm = 0x7D0
	jne	.LBB11_2
# %bb.7:                                #   in Loop: Header=BB11_1 Depth=1
	incq	%r9
	cmpq	$2000, %r9                      # imm = 0x7D0
	jne	.LBB11_1
# %bb.8:
	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_end11:
	.size	_Z11convolucionPPiS0_S0_i, .Lfunc_end11-_Z11convolucionPPiS0_S0_i
	.cfi_endproc
                                        # -- End function
	.globl	_Z30__device_stub__convolucionCUDAPPiS0_S0_i # -- Begin function _Z30__device_stub__convolucionCUDAPPiS0_S0_i
	.type	_Z30__device_stub__convolucionCUDAPPiS0_S0_i,@function
_Z30__device_stub__convolucionCUDAPPiS0_S0_i: # @_Z30__device_stub__convolucionCUDAPPiS0_S0_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	$_Z15convolucionCUDAPPiS0_S0_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_end12:
	.size	_Z30__device_stub__convolucionCUDAPPiS0_S0_i, .Lfunc_end12-_Z30__device_stub__convolucionCUDAPPiS0_S0_i
	.cfi_endproc
                                        # -- End function
	.globl	_Z25__device_stub__convKernelPiS_iiiiS_ # -- Begin function _Z25__device_stub__convKernelPiS_iiiiS_
	.type	_Z25__device_stub__convKernelPiS_iiiiS_,@function
_Z25__device_stub__convKernelPiS_iiiiS_: # @_Z25__device_stub__convKernelPiS_iiiiS_
	.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	$144, %rsp
	.cfi_def_cfa_offset 192
	.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	12(%rsp), %rsi
	movl	%edx, (%rsi)
	leaq	8(%rsp), %rdx
	movl	%ecx, (%rdx)
	leaq	4(%rsp), %rcx
	movl	%r8d, (%rcx)
	movq	%rsp, %r8
	movl	%r9d, (%r8)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	movq	%rcx, 32(%rbx)
	movq	%r8, 40(%rbx)
	leaq	192(%rsp), %rax
	movq	%rax, 48(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	24(%rsp), %r12
	leaq	16(%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	$_Z10convKernelPiS_iiiiS_, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$160, %rsp
	.cfi_adjust_cfa_offset -160
	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_end13:
	.size	_Z25__device_stub__convKernelPiS_iiiiS_, .Lfunc_end13-_Z25__device_stub__convKernelPiS_iiiiS_
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function main
.LCPI14_0:
	.long	0x447a0000                      # float 1000
.LCPI14_1:
	.long	0x41800000                      # float 16
	.text
	.globl	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	$56, %rsp
	.cfi_def_cfa_offset 112
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	leaq	16(%rsp), %rdi
	xorl	%r14d, %r14d
	xorl	%esi, %esi
	callq	hipEventCreateWithFlags
	leaq	8(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventCreateWithFlags
	movl	$5, %edi
	movl	$5, %esi
	callq	_Z13create_Matrixii
	movq	%rax, %rbx
	movl	$2004, %edi                     # imm = 0x7D4
	movl	$2004, %esi                     # imm = 0x7D4
	callq	_Z13create_Matrixii
	movq	%rax, %r13
	movl	$2000, %edi                     # imm = 0x7D0
	movl	$2000, %esi                     # imm = 0x7D0
	callq	_Z13create_Matrixii
	movq	%rax, %r15
	movl	$2000, %edi                     # imm = 0x7D0
	movl	$2000, %esi                     # imm = 0x7D0
	callq	_Z13create_Matrixii
	movq	%rax, %r12
	movq	%rbx, %rdi
	movl	$5, %esi
	movl	$5, %edx
	callq	_Z22generate_Kernel_MatrixPPiii
	movq	%r13, 24(%rsp)                  # 8-byte Spill
	movq	%r13, %rdi
	movl	$2004, %esi                     # imm = 0x7D4
	movl	$2004, %edx                     # imm = 0x7D4
	movl	$2, %ecx
	callq	_Z21generate_Image_MatrixPPiiii
.LBB14_1:                               # %.preheader.i
                                        # =>This Inner Loop Header: Depth=1
	movq	(%r15,%r14,8), %rdi
	movl	$8000, %edx                     # imm = 0x1F40
	xorl	%esi, %esi
	callq	memset@PLT
	incq	%r14
	cmpq	$2000, %r14                     # imm = 0x7D0
	jne	.LBB14_1
# %bb.2:                                # %.preheader.i26.preheader
	xorl	%eax, %eax
	xorl	%ebp, %ebp
.LBB14_3:                               # %.preheader.i26
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB14_4 Depth 2
	movq	(%rbx,%rax,8), %rcx
	xorl	%edx, %edx
.LBB14_4:                               #   Parent Loop BB14_3 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	addl	(%rcx,%rdx,4), %ebp
	incq	%rdx
	cmpq	$5, %rdx
	jne	.LBB14_4
# %bb.5:                                # %._crit_edge.i
                                        #   in Loop: Header=BB14_3 Depth=1
	incq	%rax
	cmpq	$5, %rax
	jne	.LBB14_3
# %bb.6:                                # %_Z14sumTermsMatrixPPiii.exit
	movq	16(%rsp), %rdi
	xorl	%r14d, %r14d
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	%rbx, %rdi
	movq	24(%rsp), %rsi                  # 8-byte Reload
	movq	%r15, %rdx
	movl	%ebp, %ecx
	callq	_Z11convolucionPPiS0_S0_i
	movq	8(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	8(%rsp), %rdi
	callq	hipEventSynchronize
	movq	16(%rsp), %rsi
	movq	8(%rsp), %rdx
	leaq	4(%rsp), %r13
	movq	%r13, %rdi
	callq	hipEventElapsedTime
	movq	16(%rsp), %rdi
	callq	hipEventDestroy
	movq	8(%rsp), %rdi
	callq	hipEventDestroy
	movl	$_ZSt4cout, %edi
	movl	$.L.str.2, %esi
	movl	$63, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movss	(%r13), %xmm0                   # xmm0 = mem[0],zero,zero,zero
	divss	.LCPI14_0(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	movl	$_ZSt4cout, %edi
	callq	_ZNSo9_M_insertIdEERSoT_
	movq	%rax, %r13
	movq	(%rax), %rax
	movq	-24(%rax), %rdi
	addq	%r13, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movq	%r13, %rdi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	movl	$fs, %r13d
	movl	$fs, %edi
	movl	$.L.str.3, %esi
	movl	$62, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	fs(%rip), %rax
	movq	-24(%rax), %rdi
	addq	%r13, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$fs, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	movq	%rbx, %rdi
	movl	$5, %esi
	movl	$5, %edx
	callq	_Z11copy_MatrixPPiii
	movq	%rax, 48(%rsp)                  # 8-byte Spill
	movq	24(%rsp), %rdi                  # 8-byte Reload
	movl	$2004, %esi                     # imm = 0x7D4
	movl	$2004, %edx                     # imm = 0x7D4
	callq	_Z11copy_MatrixPPiii
	movq	%rax, 40(%rsp)                  # 8-byte Spill
.LBB14_7:                               # %.preheader.i30
                                        # =>This Inner Loop Header: Depth=1
	movq	(%r12,%r14,8), %rdi
	movl	$8000, %edx                     # imm = 0x1F40
	xorl	%esi, %esi
	callq	memset@PLT
	incq	%r14
	cmpq	$2000, %r14                     # imm = 0x7D0
	jne	.LBB14_7
# %bb.8:                                # %_Z11init_MatrixPPiii.exit35
	movq	%r12, %rdi
	movl	$2000, %esi                     # imm = 0x7D0
	movl	$2000, %edx                     # imm = 0x7D0
	callq	_Z11copy_MatrixPPiii
	movq	%rax, 32(%rsp)                  # 8-byte Spill
	leaq	16(%rsp), %r13
	xorl	%r14d, %r14d
	movq	%r13, %rdi
	xorl	%esi, %esi
	callq	hipEventCreateWithFlags
	leaq	8(%rsp), %rbp
	movq	%rbp, %rdi
	xorl	%esi, %esi
	callq	hipEventCreateWithFlags
	movq	(%r13), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	(%rbp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	(%rbp), %rdi
	callq	hipEventSynchronize
	movq	(%r13), %rsi
	movq	(%rbp), %rdx
	movq	%rsp, %rdi
	callq	hipEventElapsedTime
	movq	(%r13), %rdi
	callq	hipEventDestroy
	movq	(%rbp), %rdi
	callq	hipEventDestroy
	movl	$_ZSt4cout, %edi
	movl	$.L.str.4, %esi
	movl	$13, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movb	$1, %al
.LBB14_9:                               # %.preheader.i36
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB14_11 Depth 2
	movq	(%r15,%r14,8), %rcx
	movq	(%r12,%r14,8), %rdx
	xorl	%esi, %esi
.LBB14_11:                              #   Parent Loop BB14_9 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	(%rcx,%rsi,4), %edi
	cmpl	(%rdx,%rsi,4), %edi
	jne	.LBB14_12
# %bb.10:                               #   in Loop: Header=BB14_11 Depth=2
	incq	%rsi
	cmpq	$2000, %rsi                     # imm = 0x7D0
	jne	.LBB14_11
	jmp	.LBB14_13
.LBB14_12:                              #   in Loop: Header=BB14_9 Depth=1
	xorl	%eax, %eax
.LBB14_13:                              # %._crit_edge.i38
                                        #   in Loop: Header=BB14_9 Depth=1
	incq	%r14
	cmpq	$2000, %r14                     # imm = 0x7D0
	jne	.LBB14_9
# %bb.14:                               # %_Z14compare_MatrixPPiS0_ii.exit
	andb	$1, %al
	movzbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo9_M_insertIbEERSoT_
	movq	%rax, %r12
	movq	(%rax), %rax
	movq	-24(%rax), %rdi
	addq	%r12, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movq	%r12, %rdi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	movl	$_ZSt4cout, %edi
	movl	$.L.str.5, %esi
	movl	$61, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	$_ZSt4cout, %edi
	movl	$125, %esi
	callq	_ZNSolsEi
	movq	%rax, %r12
	movl	$.L.str.6, %esi
	movl	$11, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	%r12, %rdi
	movl	$16, %esi
	callq	_ZNSolsEi
	movq	%rax, %r12
	movl	$.L.str.7, %esi
	movl	$11, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	cvtss2sd	(%rsp), %xmm0
	movq	%r12, %rdi
	callq	_ZNSo9_M_insertIdEERSoT_
	movq	%rax, %r12
	movq	(%rax), %rax
	movq	-24(%rax), %rdi
	addq	%r12, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movq	%r12, %rdi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	movl	$_ZSt4cout, %edi
	movl	$.L.str.8, %esi
	movl	$10, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movss	4(%rsp), %xmm0                  # xmm0 = mem[0],zero,zero,zero
	divss	(%rsp), %xmm0
	cvtss2sd	%xmm0, %xmm0
	movl	$_ZSt4cout, %edi
	callq	_ZNSo9_M_insertIdEERSoT_
	movq	%rax, %r12
	movq	(%rax), %rax
	movq	-24(%rax), %rdi
	addq	%r12, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movq	%r12, %rdi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	movl	$_ZSt4cout, %edi
	movl	$.L.str.9, %esi
	movl	$12, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movss	4(%rsp), %xmm0                  # xmm0 = mem[0],zero,zero,zero
	movss	(%rsp), %xmm1                   # xmm1 = mem[0],zero,zero,zero
	mulss	.LCPI14_1(%rip), %xmm1
	divss	%xmm1, %xmm0
	cvtss2sd	%xmm0, %xmm0
	movl	$_ZSt4cout, %edi
	callq	_ZNSo9_M_insertIdEERSoT_
	movq	%rax, %r12
	movq	(%rax), %rax
	movq	-24(%rax), %rdi
	addq	%r12, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movq	%r12, %rdi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	movl	$fs, %edi
	movl	$2000, %esi                     # imm = 0x7D0
	callq	_ZNSolsEi
	movq	%rax, %r12
	movl	$.L.str.1, %esi
	movl	$1, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	%r12, %rdi
	movl	$5, %esi
	callq	_ZNSolsEi
	movq	%rax, %r12
	movl	$.L.str.1, %esi
	movl	$1, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	%r12, %rdi
	movl	$16, %esi
	callq	_ZNSolsEi
	movq	%rax, %r12
	movl	$.L.str.1, %esi
	movl	$1, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	xorps	%xmm0, %xmm0
	cvtss2sd	4(%rsp), %xmm0
	movq	%r12, %rdi
	callq	_ZNSo9_M_insertIdEERSoT_
	movq	%rax, %r12
	movl	$.L.str.1, %esi
	movl	$1, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	xorps	%xmm0, %xmm0
	cvtss2sd	(%rsp), %xmm0
	movq	%r12, %rdi
	callq	_ZNSo9_M_insertIdEERSoT_
	movq	%rax, %r12
	movl	$.L.str.1, %esi
	movl	$1, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movss	4(%rsp), %xmm0                  # xmm0 = mem[0],zero,zero,zero
	movss	.LCPI14_1(%rip), %xmm1          # xmm1 = mem[0],zero,zero,zero
	mulss	(%rsp), %xmm1
	divss	%xmm1, %xmm0
	cvtss2sd	%xmm0, %xmm0
	movq	%r12, %rdi
	callq	_ZNSo9_M_insertIdEERSoT_
	movq	%rax, %r12
	movl	$.L.str.1, %esi
	movl	$1, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movss	4(%rsp), %xmm0                  # xmm0 = mem[0],zero,zero,zero
	divss	(%rsp), %xmm0
	cvtss2sd	%xmm0, %xmm0
	movq	%r12, %rdi
	callq	_ZNSo9_M_insertIdEERSoT_
	movq	%rax, %r12
	movq	(%rax), %rax
	movq	-24(%rax), %rdi
	addq	%r12, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movq	%r12, %rdi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	movq	40(%rsp), %rdi                  # 8-byte Reload
	callq	hipFree
	movq	32(%rsp), %rdi                  # 8-byte Reload
	callq	hipFree
	movq	48(%rsp), %rdi                  # 8-byte Reload
	callq	hipFree
	movq	24(%rsp), %rdi                  # 8-byte Reload
	callq	free
	movq	%r15, %rdi
	callq	free
	movq	%rbx, %rdi
	callq	free
	xorl	%eax, %eax
	addq	$56, %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_end14:
	.size	main, .Lfunc_end14-main
	.cfi_endproc
                                        # -- End function
	.section	.text.startup,"ax",@progbits
	.type	_GLOBAL__sub_I_gpu_parallel_convolution.hip,@function # -- Begin function _GLOBAL__sub_I_gpu_parallel_convolution.hip
_GLOBAL__sub_I_gpu_parallel_convolution.hip: # @_GLOBAL__sub_I_gpu_parallel_convolution.hip
	.cfi_startproc
# %bb.0:
	pushq	%rax
	.cfi_def_cfa_offset 16
	movl	$fs, %edi
	movl	$.L.str, %esi
	movl	$16, %edx
	callq	_ZNSt14basic_ofstreamIcSt11char_traitsIcEEC1EPKcSt13_Ios_Openmode
	movl	$_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev, %edi
	movl	$fs, %esi
	movl	$__dso_handle, %edx
	popq	%rax
	.cfi_def_cfa_offset 8
	jmp	__cxa_atexit                    # TAILCALL
.Lfunc_end15:
	.size	_GLOBAL__sub_I_gpu_parallel_convolution.hip, .Lfunc_end15-_GLOBAL__sub_I_gpu_parallel_convolution.hip
	.cfi_endproc
                                        # -- End function
	.text
	.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	.LBB16_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB16_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z15convolucionCUDAPPiS0_S0_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	$_Z10convKernelPiS_iiiiS_, %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_end16:
	.size	__hip_module_ctor, .Lfunc_end16-__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	.LBB17_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
.LBB17_2:
	retq
.Lfunc_end17:
	.size	__hip_module_dtor, .Lfunc_end17-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	fs,@object                      # @fs
	.bss
	.globl	fs
	.p2align	3, 0x0
fs:
	.zero	512
	.size	fs, 512

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"convolucion.txt"
	.size	.L.str, 16

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

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

	.type	_Z10convKernelPiS_iiiiS_,@object # @_Z10convKernelPiS_iiiiS_
	.globl	_Z10convKernelPiS_iiiiS_
	.p2align	3, 0x0
_Z10convKernelPiS_iiiiS_:
	.quad	_Z25__device_stub__convKernelPiS_iiiiS_
	.size	_Z10convKernelPiS_iiiiS_, 8

	.type	.L.str.2,@object                # @.str.2
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.2:
	.asciz	"El tiempo en realizar la convoluci\303\263n en tiempo secuencial es: "
	.size	.L.str.2, 64

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"ImgLenght KerLenght numthd serialTime parallelTime eff speedUp"
	.size	.L.str.3, 63

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"Son iguales: "
	.size	.L.str.4, 14

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"El tiempo en realizar la convoluci\303\263n en tiempo Paralelo con "
	.size	.L.str.5, 62

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	" bloques y "
	.size	.L.str.6, 12

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	" hilos es: "
	.size	.L.str.7, 12

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"Speed UP: "
	.size	.L.str.8, 11

	.type	.L.str.9,@object                # @.str.9
.L.str.9:
	.asciz	"Eficiencia: "
	.size	.L.str.9, 13

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z15convolucionCUDAPPiS0_S0_i"
	.size	.L__unnamed_1, 30

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_Z10convKernelPiS_iiiiS_"
	.size	.L__unnamed_2, 25

	.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	_GLOBAL__sub_I_gpu_parallel_convolution.hip
	.quad	__hip_module_ctor
	.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 _Z30__device_stub__convolucionCUDAPPiS0_S0_i
	.addrsig_sym _Z25__device_stub__convKernelPiS_iiiiS_
	.addrsig_sym _GLOBAL__sub_I_gpu_parallel_convolution.hip
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym fs
	.addrsig_sym __dso_handle
	.addrsig_sym _ZSt4cout
	.addrsig_sym _Z15convolucionCUDAPPiS0_S0_i
	.addrsig_sym _Z10convKernelPiS_iiiiS_
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z15convolucionCUDAPPiS0_S0_i ; -- Begin function _Z15convolucionCUDAPPiS0_S0_i
	.globl	_Z15convolucionCUDAPPiS0_S0_i
	.p2align	8
	.type	_Z15convolucionCUDAPPiS0_S0_i,@function
_Z15convolucionCUDAPPiS0_S0_i:          ; @_Z15convolucionCUDAPPiS0_S0_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
	s_waitcnt lgkmcnt(0)
	s_ashr_i32 s22, s2, 31
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_add_i32 s2, s2, s22
	s_xor_b32 s23, s2, s22
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_cvt_f32_u32_e32 v0, s23
	s_sub_i32 s3, 0, s23
	v_rcp_iflag_f32_e32 v0, v0
	s_waitcnt_depctr 0xfff
	v_mul_f32_e32 v0, 0x4f7ffffe, v0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cvt_u32_f32_e32 v0, v0
	v_readfirstlane_b32 s2, v0
	v_mov_b32_e32 v0, 0
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_mul_i32 s3, s3, s2
	s_mul_hi_u32 s8, s2, s3
	s_mov_b32 s3, 0
	s_add_i32 s24, s2, s8
	s_mov_b32 s8, s3
.LBB0_1:                                ; %.preheader33
                                        ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB0_2 Depth 2
                                        ;       Child Loop BB0_3 Depth 3
                                        ;         Child Loop BB0_4 Depth 4
	s_mov_b32 s9, s3
	s_mov_b64 s[12:13], 0
	s_lshl_b64 s[10:11], s[8:9], 3
	s_mov_b32 s14, s3
	s_add_u32 s10, s0, s10
	s_addc_u32 s11, s1, s11
	s_load_b64 s[10:11], s[10:11], 0x0
.LBB0_2:                                ; %.preheader32
                                        ;   Parent Loop BB0_1 Depth=1
                                        ; =>  This Loop Header: Depth=2
                                        ;       Child Loop BB0_3 Depth 3
                                        ;         Child Loop BB0_4 Depth 4
	s_mov_b32 s9, 0
	s_mov_b32 s16, 0
.LBB0_3:                                ; %.preheader
                                        ;   Parent Loop BB0_1 Depth=1
                                        ;     Parent Loop BB0_2 Depth=2
                                        ; =>    This Loop Header: Depth=3
                                        ;         Child Loop BB0_4 Depth 4
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_2) | instid1(SALU_CYCLE_1)
	s_add_i32 s2, s16, s8
	s_mov_b32 s17, s3
	s_lshl_b64 s[18:19], s[2:3], 3
	s_add_u32 s18, s6, s18
	s_addc_u32 s19, s7, s19
	s_lshl_b64 s[20:21], s[16:17], 3
	s_load_b64 s[26:27], s[18:19], 0x0
	s_add_u32 s18, s4, s20
	s_addc_u32 s19, s5, s21
	s_mov_b64 s[20:21], 0
	s_load_b64 s[18:19], s[18:19], 0x0
	s_waitcnt lgkmcnt(0)
	s_add_u32 s2, s26, s12
	s_addc_u32 s15, s27, s13
.LBB0_4:                                ;   Parent Loop BB0_1 Depth=1
                                        ;     Parent Loop BB0_2 Depth=2
                                        ;       Parent Loop BB0_3 Depth=3
                                        ; =>      This Inner Loop Header: Depth=4
	s_add_u32 s26, s2, s20
	s_addc_u32 s27, s15, s21
	s_add_u32 s28, s18, s20
	s_addc_u32 s29, s19, s21
	s_clause 0x1
	global_load_b32 v1, v0, s[26:27]
	global_load_b32 v2, v0, s[28:29]
	s_waitcnt vmcnt(1)
	v_readfirstlane_b32 s17, v1
	s_waitcnt vmcnt(0)
	v_readfirstlane_b32 s25, v2
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_mul_i32 s17, s25, s17
	s_add_i32 s9, s17, s9
	s_add_u32 s20, s20, 4
	s_addc_u32 s21, s21, 0
	s_cmp_lg_u32 s20, 20
	s_cbranch_scc1 .LBB0_4
; %bb.5:                                ;   in Loop: Header=BB0_3 Depth=3
	s_add_i32 s16, s16, 1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_cmp_lg_u32 s16, 5
	s_cbranch_scc1 .LBB0_3
; %bb.6:                                ;   in Loop: Header=BB0_2 Depth=2
	s_ashr_i32 s2, s9, 31
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_add_i32 s9, s9, s2
	s_xor_b32 s9, s9, s2
	s_xor_b32 s2, s2, s22
	s_mul_hi_u32 s15, s9, s24
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_mul_i32 s16, s15, s23
	s_sub_i32 s9, s9, s16
	s_add_i32 s16, s15, 1
	s_sub_i32 s17, s9, s23
	s_cmp_ge_u32 s9, s23
	s_cselect_b32 s15, s16, s15
	s_cselect_b32 s9, s17, s9
	s_add_i32 s16, s15, 1
	s_cmp_ge_u32 s9, s23
	s_cselect_b32 s9, s16, s15
	s_mov_b32 s15, s3
	s_xor_b32 s9, s9, s2
	s_lshl_b64 s[16:17], s[14:15], 2
	s_sub_i32 s2, s9, s2
	s_add_u32 s16, s10, s16
	s_addc_u32 s17, s11, s17
	v_mov_b32_e32 v1, s2
	s_add_i32 s14, s14, 1
	s_add_u32 s12, s12, 4
	s_addc_u32 s13, s13, 0
	s_cmpk_lg_i32 s14, 0x7d0
	global_store_b32 v0, v1, s[16:17]
	s_cbranch_scc1 .LBB0_2
; %bb.7:                                ;   in Loop: Header=BB0_1 Depth=1
	s_add_i32 s8, s8, 1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_cmpk_lg_i32 s8, 0x7d0
	s_cbranch_scc1 .LBB0_1
; %bb.8:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z15convolucionCUDAPPiS0_S0_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 0
		.amdhsa_next_free_vgpr 3
		.amdhsa_next_free_sgpr 30
		.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	_Z15convolucionCUDAPPiS0_S0_i, .Lfunc_end0-_Z15convolucionCUDAPPiS0_S0_i
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 472
; NumSgprs: 30
; NumVgprs: 3
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 3
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 30
; NumVGPRsForWavesPerEU: 3
; 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: 0
	.text
	.protected	_Z10convKernelPiS_iiiiS_ ; -- Begin function _Z10convKernelPiS_iiiiS_
	.globl	_Z10convKernelPiS_iiiiS_
	.p2align	8
	.type	_Z10convKernelPiS_iiiiS_,@function
_Z10convKernelPiS_iiiiS_:               ; @_Z10convKernelPiS_iiiiS_
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x34
	s_load_b256 s[4:11], s[0:1], 0x0
	v_bfe_u32 v4, v0, 10, 10
	s_waitcnt lgkmcnt(0)
	s_lshr_b32 s16, s2, 16
	s_and_b32 s12, s2, 0xffff
	s_lshl_b32 s13, s10, 1
	s_mul_i32 s17, s16, s12
	s_lshl_b32 s21, s11, 1
	s_ashr_i32 s3, s17, 31
	s_add_i32 s18, s13, s16
	s_add_i32 s2, s17, s3
	s_add_i32 s19, s21, s12
	s_xor_b32 s2, s2, s3
	s_mul_i32 s20, s18, s19
	v_cvt_f32_u32_e32 v1, s2
	s_add_i32 s19, s20, -1
	s_or_b32 s13, s13, 1
	s_ashr_i32 s22, s19, 31
	s_sub_i32 s25, 0, s2
	v_rcp_iflag_f32_e32 v2, v1
	v_and_b32_e32 v1, 0x3ff, v0
	s_lshr_b32 s22, s22, 27
	s_add_i32 s24, s17, -1
	s_add_i32 s19, s19, s22
	s_or_b32 s22, s21, 1
	s_ashr_i32 s21, s24, 31
	s_mul_i32 s22, s22, s13
	s_lshr_b32 s21, s21, 27
	s_ashr_i32 s26, s22, 31
	s_waitcnt_depctr 0xfff
	v_mul_f32_e32 v0, 0x4f7ffffe, v2
	s_add_i32 s27, s22, s26
	s_add_i32 s24, s24, s21
	s_xor_b32 s27, s27, s26
	s_ashr_i32 s21, s24, 5
	v_cvt_u32_f32_e32 v0, v0
	s_ashr_i32 s19, s19, 5
	s_xor_b32 s26, s26, s3
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_3)
	v_readfirstlane_b32 s23, v0
	v_mov_b32_e32 v0, 0
	v_mad_u32_u24 v6, v1, s16, v4
	s_mul_i32 s25, s25, s23
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	s_mul_hi_u32 s25, s23, s25
	v_lshlrev_b32_e32 v7, 2, v6
	s_add_i32 s23, s23, s25
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_mul_hi_u32 s25, s27, s23
	s_mul_i32 s24, s25, s2
	s_delay_alu instid0(VALU_DEP_1)
	v_lshl_add_u32 v5, s19, 7, v7
	s_sub_i32 s24, s27, s24
	s_add_i32 s27, s25, 1
	s_sub_i32 s28, s24, s2
	s_cmp_ge_u32 s24, s2
	ds_store_b32 v5, v0 offset:128
	s_cselect_b32 s25, s27, s25
	s_cselect_b32 s24, s28, s24
	s_add_i32 s27, s25, 1
	s_cmp_ge_u32 s24, s2
	s_cselect_b32 s24, s27, s25
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_xor_b32 s24, s24, s26
	s_sub_i32 s24, s24, s26
	s_delay_alu instid0(SALU_CYCLE_1)
	s_cmp_lt_i32 s24, 0
	s_cbranch_scc1 .LBB1_5
; %bb.1:                                ; %.lr.ph.preheader
	s_lshl_b32 s25, s21, 7
	s_lshl_b32 s26, s19, 7
	v_mov_b32_e32 v2, v6
	s_add_i32 s25, s25, s26
	s_add_i32 s24, s24, 1
	v_add3_u32 v0, s25, v7, 0x100
	s_lshl_b32 s25, s17, 2
.LBB1_2:                                ; %.lr.ph
                                        ; =>This Inner Loop Header: Depth=1
	s_mov_b32 s26, exec_lo
	v_cmpx_gt_i32_e64 s22, v2
	s_cbranch_execz .LBB1_4
; %bb.3:                                ;   in Loop: Header=BB1_2 Depth=1
	v_ashrrev_i32_e32 v3, 31, v2
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[8:9], 2, v[2:3]
	v_add_co_u32 v8, vcc_lo, s6, v8
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v9, vcc_lo, s7, v9, vcc_lo
	global_load_b32 v3, v[8:9], off
	s_waitcnt vmcnt(0)
	ds_store_b32 v0, v3
.LBB1_4:                                ;   in Loop: Header=BB1_2 Depth=1
	s_or_b32 exec_lo, exec_lo, s26
	v_add_nc_u32_e32 v0, s25, v0
	v_add_nc_u32_e32 v2, s17, v2
	s_add_i32 s24, s24, -1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_cmp_eq_u32 s24, 0
	s_cbranch_scc0 .LBB1_2
.LBB1_5:                                ; %.preheader
	s_ashr_i32 s6, s20, 31
	s_mul_i32 s15, s15, s16
	s_add_i32 s7, s20, s6
	s_xor_b32 s3, s6, s3
	s_xor_b32 s7, s7, s6
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_mul_hi_u32 s22, s7, s23
	s_mul_i32 s23, s22, s2
	s_delay_alu instid0(SALU_CYCLE_1)
	s_sub_i32 s6, s7, s23
	s_add_i32 s7, s22, 1
	s_sub_i32 s23, s6, s2
	s_cmp_ge_u32 s6, s2
	s_cselect_b32 s7, s7, s22
	s_cselect_b32 s6, s23, s6
	s_add_i32 s22, s7, 1
	s_cmp_ge_u32 s6, s2
	s_cselect_b32 s2, s22, s7
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_xor_b32 s2, s2, s3
	s_sub_i32 s2, s2, s3
	s_delay_alu instid0(SALU_CYCLE_1)
	s_cmp_lt_i32 s2, 0
	s_cbranch_scc1 .LBB1_14
; %bb.6:                                ; %.lr.ph122
	s_ashr_i32 s6, s18, 31
	s_sub_i32 s23, s15, s10
	s_add_i32 s3, s18, s6
	s_add_i32 s24, s2, 1
	s_xor_b32 s7, s3, s6
	s_lshl_b32 s25, s17, 2
	v_cvt_f32_u32_e32 v0, s7
	s_sub_i32 s3, 0, s7
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	v_rcp_iflag_f32_e32 v0, v0
	s_waitcnt_depctr 0xfff
	v_mul_f32_e32 v0, 0x4f7ffffe, v0
	v_cvt_u32_f32_e32 v0, v0
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(SALU_CYCLE_1)
	v_mul_lo_u32 v2, s3, v0
	s_mul_i32 s3, s14, s12
	s_sub_i32 s22, s3, s11
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_hi_u32 v2, v0, v2
	v_add_nc_u32_e32 v2, v0, v2
.LBB1_7:                                ; =>This Inner Loop Header: Depth=1
	s_mov_b32 s26, exec_lo
	v_cmpx_gt_i32_e64 s20, v6
	s_cbranch_execz .LBB1_13
; %bb.8:                                ;   in Loop: Header=BB1_7 Depth=1
	v_ashrrev_i32_e32 v0, 31, v6
	s_mov_b32 s27, exec_lo
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_nc_u32_e32 v3, v6, v0
	v_xor_b32_e32 v3, v3, v0
	v_xor_b32_e32 v0, s6, v0
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_hi_u32 v8, v3, v2
	v_mul_lo_u32 v9, v8, s7
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_sub_nc_u32_e32 v3, v3, v9
	v_add_nc_u32_e32 v9, 1, v8
	v_subrev_nc_u32_e32 v10, s7, v3
	v_cmp_le_u32_e32 vcc_lo, s7, v3
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_dual_cndmask_b32 v8, v8, v9 :: v_dual_cndmask_b32 v3, v3, v10
	v_add_nc_u32_e32 v9, 1, v8
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_cmp_le_u32_e32 vcc_lo, s7, v3
	v_cndmask_b32_e32 v3, v8, v9, vcc_lo
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_xor_b32_e32 v3, v3, v0
	v_sub_nc_u32_e32 v8, v3, v0
	v_mov_b32_e32 v3, 0
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_lo_u32 v0, v8, s18
	v_sub_nc_u32_e32 v0, v6, v0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_nc_u32_e32 v0, s23, v0
	v_cmpx_lt_i32_e32 -1, v0
	s_cbranch_execz .LBB1_12
; %bb.9:                                ;   in Loop: Header=BB1_7 Depth=1
	v_dual_mov_b32 v3, 0 :: v_dual_add_nc_u32 v8, s22, v8
	v_cmp_gt_i32_e32 vcc_lo, s9, v0
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_cmp_gt_i32_e64 s2, s8, v8
	v_cmp_lt_i32_e64 s3, -1, v8
	s_and_b32 s2, vcc_lo, s2
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	s_and_b32 s3, s2, s3
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_saveexec_b32 s2, s3
	s_cbranch_execz .LBB1_11
; %bb.10:                               ;   in Loop: Header=BB1_7 Depth=1
	v_mad_u64_u32 v[9:10], null, v8, s9, v[0:1]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v10, 31, v9
	v_lshlrev_b64 v[8:9], 2, v[9:10]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v8, vcc_lo, s4, v8
	v_add_co_ci_u32_e32 v9, vcc_lo, s5, v9, vcc_lo
	global_load_b32 v3, v[8:9], off
.LBB1_11:                               ; %Flow191
                                        ;   in Loop: Header=BB1_7 Depth=1
	s_or_b32 exec_lo, exec_lo, s2
.LBB1_12:                               ; %.sink.split
                                        ;   in Loop: Header=BB1_7 Depth=1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_or_b32 exec_lo, exec_lo, s27
	s_waitcnt vmcnt(0)
	ds_store_b32 v7, v3
.LBB1_13:                               ; %Flow192
                                        ;   in Loop: Header=BB1_7 Depth=1
	s_or_b32 exec_lo, exec_lo, s26
	v_add_nc_u32_e32 v6, s17, v6
	v_add_nc_u32_e32 v7, s25, v7
	s_add_i32 s24, s24, -1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_cmp_lg_u32 s24, 0
	s_cbranch_scc1 .LBB1_7
.LBB1_14:                               ; %._crit_edge
	v_mov_b32_e32 v0, 0
	s_sub_i32 s2, 0, s11
	s_waitcnt lgkmcnt(0)
	s_cmp_gt_i32 s2, s11
	s_barrier
	buffer_gl0_inv
	s_cbranch_scc1 .LBB1_20
; %bb.15:                               ; %.lr.ph133
	s_sub_i32 s3, 0, s10
	v_mul_lo_u32 v0, v1, s18
	s_cmp_le_i32 s3, s10
	s_mul_i32 s4, s11, s13
	s_cselect_b32 s3, -1, 0
	s_lshl_b32 s4, s4, 3
	s_lshl_b32 s5, s21, 7
	v_lshlrev_b32_e32 v2, 2, v4
	s_add_i32 s4, s4, s5
	s_lshl_b32 s5, s19, 7
	s_lshl_b32 s6, s10, 3
	s_add_i32 s4, s4, s5
	v_lshl_add_u32 v2, v0, 2, v2
	v_mov_b32_e32 v0, 0
	s_add_i32 s4, s4, s6
	s_lshl_b32 s7, s16, 2
	s_addk_i32 s4, 0x100
	s_xor_b32 s5, s6, -4
	s_add_i32 s6, s6, s7
.LBB1_16:                               ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB1_17 Depth 2
	v_mov_b32_e32 v3, v2
	s_and_not1_b32 vcc_lo, exec_lo, s3
	s_mov_b32 s7, s4
	s_mov_b32 s8, s13
	s_cbranch_vccnz .LBB1_18
.LBB1_17:                               ;   Parent Loop BB1_16 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	v_mov_b32_e32 v6, s7
	s_add_i32 s8, s8, -1
	s_add_i32 s7, s7, -4
	s_cmp_lg_u32 s8, 0
	ds_load_b32 v8, v3
	ds_load_b32 v9, v6
	v_add_nc_u32_e32 v3, 4, v3
	s_waitcnt lgkmcnt(0)
	v_mad_u64_u32 v[6:7], null, v8, v9, v[0:1]
	s_delay_alu instid0(VALU_DEP_1)
	v_mov_b32_e32 v0, v6
	s_cbranch_scc1 .LBB1_17
.LBB1_18:                               ; %._crit_edge128
                                        ;   in Loop: Header=BB1_16 Depth=1
	v_add_nc_u32_e32 v2, s6, v2
	s_add_i32 s7, s2, 1
	s_add_i32 s4, s4, s5
	s_cmp_lg_u32 s2, s11
	s_cbranch_scc0 .LBB1_20
; %bb.19:                               ;   in Loop: Header=BB1_16 Depth=1
	s_mov_b32 s2, s7
	s_branch .LBB1_16
.LBB1_20:                               ; %._crit_edge134
	v_mad_u64_u32 v[2:3], null, s14, s12, v[1:2]
	s_load_b64 s[0:1], s[0:1], 0x20
	ds_store_b32 v5, v0 offset:128
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	v_mul_lo_u32 v1, v2, s9
	ds_load_b32 v2, v5 offset:128
	v_add3_u32 v0, s15, v4, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v1, 31, v0
	v_lshlrev_b64 v[0:1], 2, v[0:1]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v0, vcc_lo, s0, v0
	v_add_co_ci_u32_e32 v1, vcc_lo, s1, v1, vcc_lo
	s_waitcnt lgkmcnt(0)
	global_store_b32 v[0:1], v2, off
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z10convKernelPiS_iiiiS_
		.amdhsa_group_segment_fixed_size 8192
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 296
		.amdhsa_user_sgpr_count 14
		.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 1
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 1
		.amdhsa_next_free_vgpr 11
		.amdhsa_next_free_sgpr 29
		.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	_Z10convKernelPiS_iiiiS_, .Lfunc_end1-_Z10convKernelPiS_iiiiS_
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 1292
; NumSgprs: 31
; NumVgprs: 11
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 8192 bytes/workgroup (compile time only)
; SGPRBlocks: 3
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 31
; NumVGPRsForWavesPerEU: 11
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 14
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 1
; 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:           _Z15convolucionCUDAPPiS0_S0_i
    .private_segment_fixed_size: 0
    .sgpr_count:     30
    .sgpr_spill_count: 0
    .symbol:         _Z15convolucionCUDAPPiS0_S0_i.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     3
    .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
      - .offset:         16
        .size:           4
        .value_kind:     by_value
      - .offset:         20
        .size:           4
        .value_kind:     by_value
      - .offset:         24
        .size:           4
        .value_kind:     by_value
      - .offset:         28
        .size:           4
        .value_kind:     by_value
      - .address_space:  global
        .offset:         32
        .size:           8
        .value_kind:     global_buffer
      - .offset:         40
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         44
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         48
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         52
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         54
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         56
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         58
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         60
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         62
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         88
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         96
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         104
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 8192
    .kernarg_segment_align: 8
    .kernarg_segment_size: 296
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z10convKernelPiS_iiiiS_
    .private_segment_fixed_size: 0
    .sgpr_count:     31
    .sgpr_spill_count: 0
    .symbol:         _Z10convKernelPiS_iiiiS_.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     11
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
