#include <float.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

#define BLOCK_SIZE 50

//Um teste comparando a eficiência de uma
//multiplicação de matrizes por CPU ou GPU
//utilizando memória compartilhada ou global

typedef struct {
  int width;
  int height;
  int stride;
  float *elements;
} Matrix;

void startSeed()
{
    srand(time(NULL));
    int seed = rand();
    srand(seed);
}

void draw_random(Matrix mat) {
     for (int i = 0; i < mat.height*mat.width; i++)
     {
      mat.elements[i] = (float) (rand() % 10);
     }
}

void disp_img(Matrix mat) {
    for (int i = 0; i < mat.height; i++)
     {
        for (int j = 0; j < mat.width; j++)
        {
          printf("%5.0f", mat.elements[i*mat.width + j]);
        }
        printf("\n");
     }
     printf("\n");
}

Matrix createMatrix(int height, int width)
{
    Matrix mat;

    mat.width = width;
    mat.height = height;
    mat.elements = (float*) malloc(mat.width*mat.height*sizeof(float));

    for(int i = 0; i < mat.height; i++)
      for(int j = 0; j < mat.width; j++)
        mat.elements[i*mat.width + j] = 0;
    
    return mat;
}

void multiMatrixCPU(Matrix A, Matrix B, Matrix C)
{
    for (int i = 0; i < A.height; i++) {
        for (int j = 0; j < B.width; j++) {
            C.elements[j + i * B.width] = 0;
            for (int k = 0; k < A.width; k++) {
                C.elements[j + i * C.width] += A.elements[k + i * A.width] * B.elements[j + k * B.width];
            }
        }
    }
}

__device__ float GetElement(const Matrix A, int row, int col)
{
    return A.elements[row * A.stride + col];
}

__device__ void SetElement(Matrix A, int row, int col,
                           float value)
{
    A.elements[row * A.stride + col] = value;
}

 __device__ Matrix GetSubMatrix(Matrix A, int row, int col) 
{
    Matrix Asub;
    Asub.width    = BLOCK_SIZE;
    Asub.height   = BLOCK_SIZE;
    Asub.stride   = A.stride;
    Asub.elements = &A.elements[A.stride * BLOCK_SIZE * row + BLOCK_SIZE * col];
    return Asub;
}

 __global__ void MatMulKernelShared(Matrix A, Matrix B, Matrix C)
{

    int blockRow = blockIdx.y;
    int blockCol = blockIdx.x;

    Matrix Csub = GetSubMatrix(C, blockRow, blockCol);

    float Cvalue = 0;

    int row = threadIdx.y;
    int col = threadIdx.x;

    for (int m = 0; m < (A.width / BLOCK_SIZE); ++m) {

        Matrix Asub = GetSubMatrix(A, blockRow, m);

        Matrix Bsub = GetSubMatrix(B, m, blockCol);

        __shared__ float As[BLOCK_SIZE][BLOCK_SIZE];
        __shared__ float Bs[BLOCK_SIZE][BLOCK_SIZE];

        As[row][col] = GetElement(Asub, row, col);
        Bs[row][col] = GetElement(Bsub, row, col);

        __syncthreads();

        for (int e = 0; e < BLOCK_SIZE; ++e)
            Cvalue += As[row][e] * Bs[e][col];

        __syncthreads();
    }

    SetElement(Csub, row, col, Cvalue);
}

void MatMulShared(const Matrix A, const Matrix B, Matrix C)
{
    Matrix d_A;
    d_A.width = d_A.stride = A.width;
    d_A.height = A.height;
    size_t size = A.width * A.height * sizeof(float);
    cudaMalloc(&d_A.elements, size);
    cudaMemcpy(d_A.elements, A.elements, size, cudaMemcpyHostToDevice);

    Matrix d_B;
    d_B.width = d_B.stride = B.width;
    d_B.height = B.height;
    size = B.width * B.height * sizeof(float);
    cudaMalloc(&d_B.elements, size);
    cudaMemcpy(d_B.elements, B.elements, size, cudaMemcpyHostToDevice);

    Matrix d_C;
    d_C.width = d_C.stride = C.width;
    d_C.height = C.height;
    size = C.width * C.height * sizeof(float);
    cudaMalloc(&d_C.elements, size);

    dim3 dimBlock(BLOCK_SIZE, BLOCK_SIZE);
    dim3 dimGrid(B.width / dimBlock.x, A.height / dimBlock.y);
    
    MatMulKernelShared<<<dimGrid, dimBlock>>>(d_A, d_B, d_C);

    cudaMemcpy(C.elements, d_C.elements, size, cudaMemcpyDeviceToHost);

    cudaFree(d_A.elements);
    cudaFree(d_B.elements);
    cudaFree(d_C.elements);
}

__global__ void MatMulKernel(Matrix A, Matrix B, Matrix C) 
{
  // Each thread computes one element of C
  // by accumulating results into Cvalue
  float Cvalue = 0;
  int row = blockIdx.y * blockDim.y + threadIdx.y;
  int col = blockIdx.x * blockDim.x + threadIdx.x;
  if (row < A.height && col < B.width)
  {
    for (int e = 0; e < A.width; e++)
      Cvalue += (A.elements[row * A.width + e]) * (B.elements[e * B.width + col]);
    C.elements[row * C.width + col] = Cvalue;
  }
  
}

void MatMul(const Matrix A, const Matrix B, Matrix C) 
{
  // Load A and B to device memory 
  Matrix d_A;
  d_A.width = A.width;
  d_A.height = A.height;
  size_t size = A.width * A.height * sizeof(float);
  cudaMalloc(&d_A.elements, size);
  cudaMemcpy(d_A.elements, A.elements, size, cudaMemcpyHostToDevice);
  
  Matrix d_B;
  d_B.width = B.width;
  d_B.height = B.height;
  size = B.width * B.height * sizeof(float);
  cudaMalloc(&d_B.elements, size);
  cudaMemcpy(d_B.elements, B.elements, size, cudaMemcpyHostToDevice);
  
  // Allocate C in device memory
  Matrix d_C;
  d_C.width = C.width;
  d_C.height = C.height;
  size = C.width * C.height * sizeof(float);
  cudaMalloc(&d_C.elements, size);
  
  // Invoke kernel
  dim3 dimBlock(BLOCK_SIZE, BLOCK_SIZE);
  dim3 dimGrid((B.width + dimBlock.x - 1) / dimBlock.x, (A.height + dimBlock.y - 1) / dimBlock.y);
  MatMulKernel<<<dimGrid, dimBlock>>>(d_A, d_B, d_C);
  cudaThreadSynchronize();
  
  // Read C from device memory
  cudaMemcpy(C.elements, d_C.elements, size, cudaMemcpyDeviceToHost);
  
  // Free device memory
  cudaFree(d_A.elements);
  cudaFree(d_B.elements);
  cudaFree(d_C.elements);
}

int main(int argc, char* argv[])
{
  clock_t tic;
  clock_t toc;

  Matrix A;
  Matrix B;
  Matrix C;

  int a;
  int b;
  int c;

  startSeed();

  int num_devices, device;
  printf("Multiplicação de Matrizes\n");
  printf("Neste programa foi utilizado um BLOCK_SIZE = 50\n\n");
  cudaGetDeviceCount(&num_devices);
  for (device = 0; device < num_devices; device++) {
    cudaDeviceProp properties;
    cudaGetDeviceProperties(&properties, device);
    cudaSetDevice(device);
    printf("Utilizando uma %s:\n\n", properties.name);
    for (int i = 100; i <= 1000; i += 100)
    {
      a = i;
      b = i;
      c = i;

      A = createMatrix(a, b);
      B = createMatrix(b, c);
      C = createMatrix(A.height, B.width);

      printf("A[%d][%d] * B[%d][%d]\n", a, b, b, c);
      
      draw_random(A);
      draw_random(B);

      tic = clock();
      MatMul(A, B, C);
      toc = clock();
      printf("GPU (global): %.3fms\n", (double)(toc - tic) / CLOCKS_PER_SEC*1000);
      C = createMatrix(A.height, B.width);

      draw_random(A);
      draw_random(B);

      tic = clock();
      MatMulShared(A, B, C);
      toc = clock();
      printf("GPU (shared): %.3fms\n", (double)(toc - tic) / CLOCKS_PER_SEC*1000);
      C = createMatrix(A.height, B.width);

      draw_random(A);
      draw_random(B);

      tic = clock();
      multiMatrixCPU(A, B, C);
      toc = clock();
      printf("CPU: %.3fms\n", (double)(toc - tic) / CLOCKS_PER_SEC*1000);
      printf("\n");
    }
  }
}
	.file	"tmpxft_00268676_00000000-6_multiplicaMatrizScript.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2040:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2040:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z9startSeedv
	.type	_Z9startSeedv, @function
_Z9startSeedv:
.LFB2027:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	xorl	%edi, %edi
	call	time@PLT
	movl	%eax, %edi
	call	srand@PLT
	call	rand@PLT
	popq	%rdx
	.cfi_def_cfa_offset 8
	movl	%eax, %edi
	jmp	srand@PLT
	.cfi_endproc
.LFE2027:
	.size	_Z9startSeedv, .-_Z9startSeedv
	.globl	_Z11draw_random6Matrix
	.type	_Z11draw_random6Matrix, @function
_Z11draw_random6Matrix:
.LFB2028:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movl	$10, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	xorl	%ebx, %ebx
	pushq	%rdx
	.cfi_def_cfa_offset 32
.L5:
	movl	36(%rsp), %eax
	imull	32(%rsp), %eax
	cmpl	%ebx, %eax
	jle	.L9
	call	rand@PLT
	cltd
	idivl	%ebp
	movq	48(%rsp), %rax
	cvtsi2ssl	%edx, %xmm0
	movss	%xmm0, (%rax,%rbx,4)
	incq	%rbx
	jmp	.L5
.L9:
	popq	%rax
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2028:
	.size	_Z11draw_random6Matrix, .-_Z11draw_random6Matrix
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%5.0f"
.LC1:
	.string	"\n"
	.text
	.globl	_Z8disp_img6Matrix
	.type	_Z8disp_img6Matrix, @function
_Z8disp_img6Matrix:
.LFB2029:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	leaq	.LC0(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	xorl	%r12d, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	xorl	%ebp, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	pushq	%rcx
	.cfi_def_cfa_offset 64
	movl	64(%rsp), %r13d
.L11:
	cmpl	%r12d, 68(%rsp)
	jle	.L13
	movslq	%ebp, %rbx
	xorl	%r15d, %r15d
	salq	$2, %rbx
.L14:
	cmpl	%r13d, %r15d
	jge	.L16
	movq	80(%rsp), %rax
	movq	%r14, %rsi
	movl	$2, %edi
	incl	%r15d
	cvtss2sd	(%rax,%rbx), %xmm0
	movb	$1, %al
	addq	$4, %rbx
	call	__printf_chk@PLT
	jmp	.L14
.L16:
	leaq	.LC1(%rip), %rsi
	xorl	%eax, %eax
	incl	%r12d
	addl	%r13d, %ebp
	movl	$2, %edi
	call	__printf_chk@PLT
	jmp	.L11
.L13:
	popq	%rdx
	.cfi_def_cfa_offset 56
	leaq	.LC1(%rip), %rsi
	popq	%rbx
	.cfi_def_cfa_offset 48
	movl	$2, %edi
	popq	%rbp
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	jmp	__printf_chk@PLT
	.cfi_endproc
.LFE2029:
	.size	_Z8disp_img6Matrix, .-_Z8disp_img6Matrix
	.globl	_Z12createMatrixii
	.type	_Z12createMatrixii, @function
_Z12createMatrixii:
.LFB2030:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movl	%esi, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movl	%edx, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	movq	%rdi, %rbx
	movl	%esi, 4(%rdi)
	movl	%edx, (%rdi)
	movl	%edx, %edi
	imull	%esi, %edi
	movslq	%edi, %rdi
	salq	$2, %rdi
	call	malloc@PLT
	xorl	%ecx, %ecx
	xorl	%esi, %esi
	movq	%rax, 16(%rbx)
.L18:
	cmpl	%r12d, %esi
	jge	.L17
	movslq	%ecx, %rdx
	leaq	(%rax,%rdx,4), %rdi
	xorl	%edx, %edx
.L21:
	cmpl	%edx, %ebp
	jle	.L23
	movl	$0x00000000, (%rdi,%rdx,4)
	incq	%rdx
	jmp	.L21
.L23:
	incl	%esi
	addl	%ebp, %ecx
	jmp	.L18
.L17:
	movq	%rbx, %rax
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2030:
	.size	_Z12createMatrixii, .-_Z12createMatrixii
	.globl	_Z14multiMatrixCPU6MatrixS_S_
	.type	_Z14multiMatrixCPU6MatrixS_S_, @function
_Z14multiMatrixCPU6MatrixS_S_:
.LFB2031:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	xorl	%ecx, %ecx
	xorl	%r9d, %r9d
	xorl	%esi, %esi
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	xorl	%edi, %edi
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movl	60(%rsp), %eax
	movl	80(%rsp), %r8d
	movl	56(%rsp), %ebx
	movq	120(%rsp), %r11
	movq	96(%rsp), %r14
	movl	%eax, -20(%rsp)
	movq	72(%rsp), %rax
	movl	104(%rsp), %r15d
	movq	%rax, -32(%rsp)
	movslq	%r8d, %rax
	salq	$2, %rax
	movq	%rax, -16(%rsp)
.L25:
	cmpl	%edi, -20(%rsp)
	jle	.L24
	movslq	%esi, %rax
	movq	-32(%rsp), %rdx
	leaq	(%r11,%rax,4), %r13
	movslq	%ecx, %rax
	leaq	(%rdx,%rax,4), %rax
	movq	%rax, -8(%rsp)
	xorl	%eax, %eax
.L30:
	cmpl	%eax, %r8d
	jle	.L32
	leal	(%r9,%rax), %edx
	leaq	(%r14,%rax,4), %r10
	movl	$0x00000000, 0(%r13,%rax,4)
	movslq	%edx, %rdx
	leaq	(%r11,%rdx,4), %rbp
	xorl	%edx, %edx
.L26:
	cmpl	%edx, %ebx
	jle	.L33
	movq	-8(%rsp), %r12
	movss	(%r12,%rdx,4), %xmm0
	mulss	(%r10), %xmm0
	incq	%rdx
	addss	0(%rbp), %xmm0
	movq	-16(%rsp), %r12
	addq	%r12, %r10
	movss	%xmm0, 0(%rbp)
	jmp	.L26
.L33:
	incq	%rax
	jmp	.L30
.L32:
	incl	%edi
	addl	%r8d, %esi
	addl	%r15d, %r9d
	addl	%ebx, %ecx
	jmp	.L25
.L24:
	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
.LFE2031:
	.size	_Z14multiMatrixCPU6MatrixS_S_, .-_Z14multiMatrixCPU6MatrixS_S_
	.globl	_Z10GetElement6Matrixii
	.type	_Z10GetElement6Matrixii, @function
_Z10GetElement6Matrixii:
.LFB2032:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE2032:
	.size	_Z10GetElement6Matrixii, .-_Z10GetElement6Matrixii
	.globl	_Z10SetElement6Matrixiif
	.type	_Z10SetElement6Matrixiif, @function
_Z10SetElement6Matrixiif:
.LFB2033:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE2033:
	.size	_Z10SetElement6Matrixiif, .-_Z10SetElement6Matrixiif
	.globl	_Z12GetSubMatrix6Matrixii
	.type	_Z12GetSubMatrix6Matrixii, @function
_Z12GetSubMatrix6Matrixii:
.LFB2034:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE2034:
	.size	_Z12GetSubMatrix6Matrixii, .-_Z12GetSubMatrix6Matrixii
	.globl	_Z47__device_stub__Z18MatMulKernelShared6MatrixS_S_R6MatrixS0_S0_
	.type	_Z47__device_stub__Z18MatMulKernelShared6MatrixS_S_R6MatrixS0_S0_, @function
_Z47__device_stub__Z18MatMulKernelShared6MatrixS_S_R6MatrixS0_S0_:
.LFB2062:
	.cfi_startproc
	endbr64
	subq	$104, %rsp
	.cfi_def_cfa_offset 112
	movq	%fs:40, %rax
	movq	%rax, 88(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rcx
	movq	%rdi, 64(%rsp)
	movabsq	$4294967297, %rax
	movq	%rsi, 72(%rsp)
	leaq	16(%rsp), %rdi
	leaq	28(%rsp), %rsi
	movq	%rdx, 80(%rsp)
	movq	%rsp, %rdx
	movq	%rax, 16(%rsp)
	movl	$1, 24(%rsp)
	movq	%rax, 28(%rsp)
	movl	$1, 36(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L40
	pushq	8(%rsp)
	.cfi_def_cfa_offset 120
	leaq	_Z18MatMulKernelShared6MatrixS_S_(%rip), %rdi
	pushq	8(%rsp)
	.cfi_def_cfa_offset 128
	movq	44(%rsp), %rcx
	movl	52(%rsp), %r8d
	movq	32(%rsp), %rsi
	movl	40(%rsp), %edx
	leaq	80(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 120
	popq	%rdx
	.cfi_def_cfa_offset 112
.L40:
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	je	.L42
	call	__stack_chk_fail@PLT
.L42:
	addq	$104, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2062:
	.size	_Z47__device_stub__Z18MatMulKernelShared6MatrixS_S_R6MatrixS0_S0_, .-_Z47__device_stub__Z18MatMulKernelShared6MatrixS_S_R6MatrixS0_S0_
	.globl	_Z18MatMulKernelShared6MatrixS_S_
	.type	_Z18MatMulKernelShared6MatrixS_S_, @function
_Z18MatMulKernelShared6MatrixS_S_:
.LFB2063:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	leaq	64(%rsp), %rdx
	leaq	40(%rsp), %rsi
	leaq	16(%rsp), %rdi
	call	_Z47__device_stub__Z18MatMulKernelShared6MatrixS_S_R6MatrixS0_S0_
	popq	%rdx
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2063:
	.size	_Z18MatMulKernelShared6MatrixS_S_, .-_Z18MatMulKernelShared6MatrixS_S_
	.globl	_Z12MatMulShared6MatrixS_S_
	.type	_Z12MatMulShared6MatrixS_S_, @function
_Z12MatMulShared6MatrixS_S_:
.LFB2035:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$184, %rsp
	.cfi_def_cfa_offset 240
	movq	%fs:40, %rax
	movq	%rax, 168(%rsp)
	xorl	%eax, %eax
	movl	240(%rsp), %edx
	movl	244(%rsp), %r14d
	leaq	40(%rsp), %rdi
	movl	264(%rsp), %r13d
	movl	288(%rsp), %ebx
	movl	%edx, 32(%rsp)
	movl	268(%rsp), %r12d
	movl	%edx, 24(%rsp)
	imull	%r14d, %edx
	movl	292(%rsp), %r15d
	movl	%r14d, 28(%rsp)
	movslq	%edx, %rbp
	salq	$2, %rbp
	movq	%rbp, %rsi
	call	cudaMalloc@PLT
	movq	256(%rsp), %rsi
	movq	40(%rsp), %rdi
	movq	%rbp, %rdx
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movl	%r12d, 52(%rsp)
	imull	%r13d, %r12d
	leaq	64(%rsp), %rdi
	movl	%r13d, 56(%rsp)
	movl	%r13d, 48(%rsp)
	movslq	%r12d, %rbp
	salq	$2, %rbp
	movq	%rbp, %rsi
	call	cudaMalloc@PLT
	movq	280(%rsp), %rsi
	movq	64(%rsp), %rdi
	movq	%rbp, %rdx
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movl	%ebx, 80(%rsp)
	leaq	88(%rsp), %rdi
	movl	%ebx, 72(%rsp)
	imull	%r15d, %ebx
	movl	%r15d, 76(%rsp)
	movslq	%ebx, %rbx
	salq	$2, %rbx
	movq	%rbx, %rsi
	call	cudaMalloc@PLT
	movl	$50, %ecx
	xorl	%edx, %edx
	movl	%r13d, %eax
	divl	%ecx
	xorl	%edx, %edx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	$1, %esi
	movl	%eax, 12(%rsp)
	movl	%r14d, %eax
	divl	%ecx
	movabsq	$214748364850, %rdx
	movl	$1, %ecx
	movl	%eax, 16(%rsp)
	movq	12(%rsp), %rdi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L47
	movq	40(%rsp), %rax
	movups	24(%rsp), %xmm0
	leaq	144(%rsp), %rdx
	leaq	120(%rsp), %rsi
	movups	48(%rsp), %xmm1
	movups	72(%rsp), %xmm2
	leaq	96(%rsp), %rdi
	movq	%rax, 112(%rsp)
	movq	64(%rsp), %rax
	movups	%xmm0, 96(%rsp)
	movq	%rax, 136(%rsp)
	movq	88(%rsp), %rax
	movups	%xmm1, 120(%rsp)
	movq	%rax, 160(%rsp)
	movups	%xmm2, 144(%rsp)
	call	_Z47__device_stub__Z18MatMulKernelShared6MatrixS_S_R6MatrixS0_S0_
.L47:
	movq	88(%rsp), %rsi
	movq	304(%rsp), %rdi
	movl	$2, %ecx
	movq	%rbx, %rdx
	call	cudaMemcpy@PLT
	movq	40(%rsp), %rdi
	call	cudaFree@PLT
	movq	64(%rsp), %rdi
	call	cudaFree@PLT
	movq	88(%rsp), %rdi
	call	cudaFree@PLT
	movq	168(%rsp), %rax
	subq	%fs:40, %rax
	je	.L48
	call	__stack_chk_fail@PLT
.L48:
	addq	$184, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2035:
	.size	_Z12MatMulShared6MatrixS_S_, .-_Z12MatMulShared6MatrixS_S_
	.globl	_Z41__device_stub__Z12MatMulKernel6MatrixS_S_R6MatrixS0_S0_
	.type	_Z41__device_stub__Z12MatMulKernel6MatrixS_S_R6MatrixS0_S0_, @function
_Z41__device_stub__Z12MatMulKernel6MatrixS_S_R6MatrixS0_S0_:
.LFB2064:
	.cfi_startproc
	endbr64
	subq	$104, %rsp
	.cfi_def_cfa_offset 112
	movq	%fs:40, %rax
	movq	%rax, 88(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rcx
	movq	%rdi, 64(%rsp)
	movabsq	$4294967297, %rax
	movq	%rsi, 72(%rsp)
	leaq	16(%rsp), %rdi
	leaq	28(%rsp), %rsi
	movq	%rdx, 80(%rsp)
	movq	%rsp, %rdx
	movq	%rax, 16(%rsp)
	movl	$1, 24(%rsp)
	movq	%rax, 28(%rsp)
	movl	$1, 36(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L50
	pushq	8(%rsp)
	.cfi_def_cfa_offset 120
	leaq	_Z12MatMulKernel6MatrixS_S_(%rip), %rdi
	pushq	8(%rsp)
	.cfi_def_cfa_offset 128
	movq	44(%rsp), %rcx
	movl	52(%rsp), %r8d
	movq	32(%rsp), %rsi
	movl	40(%rsp), %edx
	leaq	80(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 120
	popq	%rdx
	.cfi_def_cfa_offset 112
.L50:
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	je	.L52
	call	__stack_chk_fail@PLT
.L52:
	addq	$104, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2064:
	.size	_Z41__device_stub__Z12MatMulKernel6MatrixS_S_R6MatrixS0_S0_, .-_Z41__device_stub__Z12MatMulKernel6MatrixS_S_R6MatrixS0_S0_
	.globl	_Z12MatMulKernel6MatrixS_S_
	.type	_Z12MatMulKernel6MatrixS_S_, @function
_Z12MatMulKernel6MatrixS_S_:
.LFB2065:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	leaq	64(%rsp), %rdx
	leaq	40(%rsp), %rsi
	leaq	16(%rsp), %rdi
	call	_Z41__device_stub__Z12MatMulKernel6MatrixS_S_R6MatrixS0_S0_
	popq	%rdx
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2065:
	.size	_Z12MatMulKernel6MatrixS_S_, .-_Z12MatMulKernel6MatrixS_S_
	.globl	_Z6MatMul6MatrixS_S_
	.type	_Z6MatMul6MatrixS_S_, @function
_Z6MatMul6MatrixS_S_:
.LFB2036:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$184, %rsp
	.cfi_def_cfa_offset 240
	movq	%fs:40, %rax
	movq	%rax, 168(%rsp)
	xorl	%eax, %eax
	movl	244(%rsp), %r14d
	movl	240(%rsp), %r13d
	leaq	40(%rsp), %rdi
	movl	264(%rsp), %r12d
	movl	268(%rsp), %ebp
	movl	%r13d, 24(%rsp)
	imull	%r14d, %r13d
	movl	288(%rsp), %ebx
	movl	292(%rsp), %r15d
	movl	%r14d, 28(%rsp)
	movslq	%r13d, %r13
	salq	$2, %r13
	movq	%r13, %rsi
	call	cudaMalloc@PLT
	movq	256(%rsp), %rsi
	movq	40(%rsp), %rdi
	movq	%r13, %rdx
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movl	%ebp, 52(%rsp)
	imull	%r12d, %ebp
	leaq	64(%rsp), %rdi
	movl	%r12d, 48(%rsp)
	movslq	%ebp, %rbp
	salq	$2, %rbp
	movq	%rbp, %rsi
	call	cudaMalloc@PLT
	movq	280(%rsp), %rsi
	movq	64(%rsp), %rdi
	movq	%rbp, %rdx
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movl	%ebx, 72(%rsp)
	imull	%r15d, %ebx
	leaq	88(%rsp), %rdi
	movl	%r15d, 76(%rsp)
	movslq	%ebx, %rbx
	salq	$2, %rbx
	movq	%rbx, %rsi
	call	cudaMalloc@PLT
	movl	$50, %ecx
	xorl	%edx, %edx
	xorl	%r9d, %r9d
	leal	49(%r12), %eax
	xorl	%r8d, %r8d
	movl	$1, %esi
	divl	%ecx
	xorl	%edx, %edx
	movl	%eax, 12(%rsp)
	leal	49(%r14), %eax
	divl	%ecx
	movabsq	$214748364850, %rdx
	movl	$1, %ecx
	movl	%eax, 16(%rsp)
	movq	12(%rsp), %rdi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L57
	movq	40(%rsp), %rax
	movups	24(%rsp), %xmm0
	leaq	144(%rsp), %rdx
	leaq	120(%rsp), %rsi
	movups	48(%rsp), %xmm1
	movups	72(%rsp), %xmm2
	leaq	96(%rsp), %rdi
	movq	%rax, 112(%rsp)
	movq	64(%rsp), %rax
	movups	%xmm0, 96(%rsp)
	movq	%rax, 136(%rsp)
	movq	88(%rsp), %rax
	movups	%xmm1, 120(%rsp)
	movq	%rax, 160(%rsp)
	movups	%xmm2, 144(%rsp)
	call	_Z41__device_stub__Z12MatMulKernel6MatrixS_S_R6MatrixS0_S0_
.L57:
	call	cudaThreadSynchronize@PLT
	movq	88(%rsp), %rsi
	movl	$2, %ecx
	movq	%rbx, %rdx
	movq	304(%rsp), %rdi
	call	cudaMemcpy@PLT
	movq	40(%rsp), %rdi
	call	cudaFree@PLT
	movq	64(%rsp), %rdi
	call	cudaFree@PLT
	movq	88(%rsp), %rdi
	call	cudaFree@PLT
	movq	168(%rsp), %rax
	subq	%fs:40, %rax
	je	.L58
	call	__stack_chk_fail@PLT
.L58:
	addq	$184, %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
.LFE2036:
	.size	_Z6MatMul6MatrixS_S_, .-_Z6MatMul6MatrixS_S_
	.section	.rodata.str1.1
.LC3:
	.string	"Multiplica\303\247\303\243o de Matrizes\n"
.LC4:
	.string	"Neste programa foi utilizado um BLOCK_SIZE = 50\n\n"
.LC5:
	.string	"Utilizando uma %s:\n\n"
.LC6:
	.string	"A[%d][%d] * B[%d][%d]\n"
.LC9:
	.string	"GPU (global): %.3fms\n"
.LC10:
	.string	"GPU (shared): %.3fms\n"
.LC11:
	.string	"CPU: %.3fms\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2037:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	xorl	%ebp, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$1144, %rsp
	.cfi_def_cfa_offset 1200
	movq	%fs:40, %rax
	movq	%rax, 1128(%rsp)
	xorl	%eax, %eax
	call	_Z9startSeedv
	leaq	.LC3(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	.LC4(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	20(%rsp), %rdi
	call	cudaGetDeviceCount@PLT
.L61:
	cmpl	%ebp, 20(%rsp)
	jle	.L67
	leaq	96(%rsp), %rbx
	movl	%ebp, %esi
	leaq	.LC6(%rip), %r15
	movq	%rbx, %rdi
	call	cudaGetDeviceProperties_v2@PLT
	movl	%ebp, %edi
	call	cudaSetDevice@PLT
	movq	%rbx, %rdx
	movl	$2, %edi
	xorl	%eax, %eax
	leaq	.LC5(%rip), %rsi
	movl	$100, %ebx
	call	__printf_chk@PLT
.L62:
	leaq	24(%rsp), %rdi
	movl	%ebx, %edx
	movl	%ebx, %esi
	call	_Z12createMatrixii
	leaq	48(%rsp), %rdi
	movl	%ebx, %edx
	movl	%ebx, %esi
	movl	28(%rsp), %r13d
	call	_Z12createMatrixii
	movl	48(%rsp), %r14d
	leaq	72(%rsp), %rax
	movq	%rax, %rdi
	movl	%r13d, %esi
	movq	%rax, 8(%rsp)
	movl	%r14d, %edx
	call	_Z12createMatrixii
	movl	%ebx, %r9d
	movl	%ebx, %r8d
	movl	%ebx, %ecx
	movl	%ebx, %edx
	movq	%r15, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	subq	$32, %rsp
	.cfi_def_cfa_offset 1232
	movups	56(%rsp), %xmm1
	movq	72(%rsp), %rax
	movups	%xmm1, (%rsp)
	movq	%rax, 16(%rsp)
	call	_Z11draw_random6Matrix
	movups	80(%rsp), %xmm2
	movq	96(%rsp), %rax
	movups	%xmm2, (%rsp)
	movq	%rax, 16(%rsp)
	call	_Z11draw_random6Matrix
	addq	$32, %rsp
	.cfi_def_cfa_offset 1200
	call	clock@PLT
	subq	$80, %rsp
	.cfi_def_cfa_offset 1280
	movq	%rax, %r12
	movq	168(%rsp), %rax
	movups	104(%rsp), %xmm5
	movups	128(%rsp), %xmm4
	movups	152(%rsp), %xmm3
	movq	%rax, 64(%rsp)
	movq	144(%rsp), %rax
	movups	%xmm5, (%rsp)
	movq	%rax, 40(%rsp)
	movq	120(%rsp), %rax
	movups	%xmm4, 24(%rsp)
	movups	%xmm3, 48(%rsp)
	movq	%rax, 16(%rsp)
	call	_Z6MatMul6MatrixS_S_
	addq	$80, %rsp
	.cfi_def_cfa_offset 1200
	call	clock@PLT
	leaq	.LC9(%rip), %rsi
	movl	$2, %edi
	subq	%r12, %rax
	cvtsi2sdq	%rax, %xmm0
	divsd	.LC7(%rip), %xmm0
	movb	$1, %al
	mulsd	.LC8(%rip), %xmm0
	call	__printf_chk@PLT
	movq	8(%rsp), %rdi
	movl	%r14d, %edx
	movl	%r13d, %esi
	call	_Z12createMatrixii
	subq	$32, %rsp
	.cfi_def_cfa_offset 1232
	movups	56(%rsp), %xmm6
	movq	72(%rsp), %rax
	movups	%xmm6, (%rsp)
	movq	%rax, 16(%rsp)
	call	_Z11draw_random6Matrix
	movups	80(%rsp), %xmm7
	movq	96(%rsp), %rax
	movups	%xmm7, (%rsp)
	movq	%rax, 16(%rsp)
	call	_Z11draw_random6Matrix
	addq	$32, %rsp
	.cfi_def_cfa_offset 1200
	call	clock@PLT
	subq	$80, %rsp
	.cfi_def_cfa_offset 1280
	movq	%rax, %r12
	movq	168(%rsp), %rax
	movups	128(%rsp), %xmm2
	movups	104(%rsp), %xmm3
	movups	152(%rsp), %xmm1
	movq	%rax, 64(%rsp)
	movq	144(%rsp), %rax
	movups	%xmm2, 24(%rsp)
	movq	%rax, 40(%rsp)
	movq	120(%rsp), %rax
	movups	%xmm3, (%rsp)
	movups	%xmm1, 48(%rsp)
	movq	%rax, 16(%rsp)
	call	_Z12MatMulShared6MatrixS_S_
	addq	$80, %rsp
	.cfi_def_cfa_offset 1200
	call	clock@PLT
	leaq	.LC10(%rip), %rsi
	movl	$2, %edi
	subq	%r12, %rax
	cvtsi2sdq	%rax, %xmm0
	divsd	.LC7(%rip), %xmm0
	movb	$1, %al
	mulsd	.LC8(%rip), %xmm0
	call	__printf_chk@PLT
	movq	8(%rsp), %rdi
	movl	%r14d, %edx
	movl	%r13d, %esi
	call	_Z12createMatrixii
	subq	$32, %rsp
	.cfi_def_cfa_offset 1232
	movups	56(%rsp), %xmm4
	movq	72(%rsp), %rax
	movups	%xmm4, (%rsp)
	movq	%rax, 16(%rsp)
	call	_Z11draw_random6Matrix
	movups	80(%rsp), %xmm5
	movq	96(%rsp), %rax
	movups	%xmm5, (%rsp)
	movq	%rax, 16(%rsp)
	call	_Z11draw_random6Matrix
	addq	$32, %rsp
	.cfi_def_cfa_offset 1200
	addl	$100, %ebx
	call	clock@PLT
	subq	$80, %rsp
	.cfi_def_cfa_offset 1280
	movq	%rax, %r12
	movq	168(%rsp), %rax
	movups	104(%rsp), %xmm1
	movups	152(%rsp), %xmm6
	movups	128(%rsp), %xmm7
	movq	%rax, 64(%rsp)
	movq	144(%rsp), %rax
	movups	%xmm6, 48(%rsp)
	movq	%rax, 40(%rsp)
	movq	120(%rsp), %rax
	movups	%xmm7, 24(%rsp)
	movups	%xmm1, (%rsp)
	movq	%rax, 16(%rsp)
	call	_Z14multiMatrixCPU6MatrixS_S_
	addq	$80, %rsp
	.cfi_def_cfa_offset 1200
	call	clock@PLT
	leaq	.LC11(%rip), %rsi
	movl	$2, %edi
	subq	%r12, %rax
	cvtsi2sdq	%rax, %xmm0
	divsd	.LC7(%rip), %xmm0
	movb	$1, %al
	mulsd	.LC8(%rip), %xmm0
	call	__printf_chk@PLT
	leaq	.LC1(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	cmpl	$1100, %ebx
	jne	.L62
	incl	%ebp
	jmp	.L61
.L67:
	movq	1128(%rsp), %rax
	subq	%fs:40, %rax
	je	.L64
	call	__stack_chk_fail@PLT
.L64:
	addq	$1144, %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
.LFE2037:
	.size	main, .-main
	.section	.rodata.str1.1
.LC12:
	.string	"_Z12MatMulKernel6MatrixS_S_"
.LC13:
	.string	"_Z18MatMulKernelShared6MatrixS_S_"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2067:
	.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	.LC12(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z12MatMulKernel6MatrixS_S_(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 48
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r9d, %r9d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC13(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z18MatMulKernelShared6MatrixS_S_(%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
.LFE2067:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC7:
	.long	0
	.long	1093567616
	.align 8
.LC8:
	.long	0
	.long	1083129856
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:


#include <hip/hip_runtime.h>
#include <float.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

#define BLOCK_SIZE 50

//Um teste comparando a eficiência de uma
//multiplicação de matrizes por CPU ou GPU
//utilizando memória compartilhada ou global

typedef struct {
  int width;
  int height;
  int stride;
  float *elements;
} Matrix;

void startSeed()
{
    srand(time(NULL));
    int seed = rand();
    srand(seed);
}

void draw_random(Matrix mat) {
     for (int i = 0; i < mat.height*mat.width; i++)
     {
      mat.elements[i] = (float) (rand() % 10);
     }
}

void disp_img(Matrix mat) {
    for (int i = 0; i < mat.height; i++)
     {
        for (int j = 0; j < mat.width; j++)
        {
          printf("%5.0f", mat.elements[i*mat.width + j]);
        }
        printf("\n");
     }
     printf("\n");
}

Matrix createMatrix(int height, int width)
{
    Matrix mat;

    mat.width = width;
    mat.height = height;
    mat.elements = (float*) malloc(mat.width*mat.height*sizeof(float));

    for(int i = 0; i < mat.height; i++)
      for(int j = 0; j < mat.width; j++)
        mat.elements[i*mat.width + j] = 0;
    
    return mat;
}

void multiMatrixCPU(Matrix A, Matrix B, Matrix C)
{
    for (int i = 0; i < A.height; i++) {
        for (int j = 0; j < B.width; j++) {
            C.elements[j + i * B.width] = 0;
            for (int k = 0; k < A.width; k++) {
                C.elements[j + i * C.width] += A.elements[k + i * A.width] * B.elements[j + k * B.width];
            }
        }
    }
}

__device__ float GetElement(const Matrix A, int row, int col)
{
    return A.elements[row * A.stride + col];
}

__device__ void SetElement(Matrix A, int row, int col,
                           float value)
{
    A.elements[row * A.stride + col] = value;
}

 __device__ Matrix GetSubMatrix(Matrix A, int row, int col) 
{
    Matrix Asub;
    Asub.width    = BLOCK_SIZE;
    Asub.height   = BLOCK_SIZE;
    Asub.stride   = A.stride;
    Asub.elements = &A.elements[A.stride * BLOCK_SIZE * row + BLOCK_SIZE * col];
    return Asub;
}

 __global__ void MatMulKernelShared(Matrix A, Matrix B, Matrix C)
{

    int blockRow = blockIdx.y;
    int blockCol = blockIdx.x;

    Matrix Csub = GetSubMatrix(C, blockRow, blockCol);

    float Cvalue = 0;

    int row = threadIdx.y;
    int col = threadIdx.x;

    for (int m = 0; m < (A.width / BLOCK_SIZE); ++m) {

        Matrix Asub = GetSubMatrix(A, blockRow, m);

        Matrix Bsub = GetSubMatrix(B, m, blockCol);

        __shared__ float As[BLOCK_SIZE][BLOCK_SIZE];
        __shared__ float Bs[BLOCK_SIZE][BLOCK_SIZE];

        As[row][col] = GetElement(Asub, row, col);
        Bs[row][col] = GetElement(Bsub, row, col);

        __syncthreads();

        for (int e = 0; e < BLOCK_SIZE; ++e)
            Cvalue += As[row][e] * Bs[e][col];

        __syncthreads();
    }

    SetElement(Csub, row, col, Cvalue);
}

void MatMulShared(const Matrix A, const Matrix B, Matrix C)
{
    Matrix d_A;
    d_A.width = d_A.stride = A.width;
    d_A.height = A.height;
    size_t size = A.width * A.height * sizeof(float);
    hipMalloc(&d_A.elements, size);
    hipMemcpy(d_A.elements, A.elements, size, hipMemcpyHostToDevice);

    Matrix d_B;
    d_B.width = d_B.stride = B.width;
    d_B.height = B.height;
    size = B.width * B.height * sizeof(float);
    hipMalloc(&d_B.elements, size);
    hipMemcpy(d_B.elements, B.elements, size, hipMemcpyHostToDevice);

    Matrix d_C;
    d_C.width = d_C.stride = C.width;
    d_C.height = C.height;
    size = C.width * C.height * sizeof(float);
    hipMalloc(&d_C.elements, size);

    dim3 dimBlock(BLOCK_SIZE, BLOCK_SIZE);
    dim3 dimGrid(B.width / dimBlock.x, A.height / dimBlock.y);
    
    MatMulKernelShared<<<dimGrid, dimBlock>>>(d_A, d_B, d_C);

    hipMemcpy(C.elements, d_C.elements, size, hipMemcpyDeviceToHost);

    hipFree(d_A.elements);
    hipFree(d_B.elements);
    hipFree(d_C.elements);
}

__global__ void MatMulKernel(Matrix A, Matrix B, Matrix C) 
{
  // Each thread computes one element of C
  // by accumulating results into Cvalue
  float Cvalue = 0;
  int row = blockIdx.y * blockDim.y + threadIdx.y;
  int col = blockIdx.x * blockDim.x + threadIdx.x;
  if (row < A.height && col < B.width)
  {
    for (int e = 0; e < A.width; e++)
      Cvalue += (A.elements[row * A.width + e]) * (B.elements[e * B.width + col]);
    C.elements[row * C.width + col] = Cvalue;
  }
  
}

void MatMul(const Matrix A, const Matrix B, Matrix C) 
{
  // Load A and B to device memory 
  Matrix d_A;
  d_A.width = A.width;
  d_A.height = A.height;
  size_t size = A.width * A.height * sizeof(float);
  hipMalloc(&d_A.elements, size);
  hipMemcpy(d_A.elements, A.elements, size, hipMemcpyHostToDevice);
  
  Matrix d_B;
  d_B.width = B.width;
  d_B.height = B.height;
  size = B.width * B.height * sizeof(float);
  hipMalloc(&d_B.elements, size);
  hipMemcpy(d_B.elements, B.elements, size, hipMemcpyHostToDevice);
  
  // Allocate C in device memory
  Matrix d_C;
  d_C.width = C.width;
  d_C.height = C.height;
  size = C.width * C.height * sizeof(float);
  hipMalloc(&d_C.elements, size);
  
  // Invoke kernel
  dim3 dimBlock(BLOCK_SIZE, BLOCK_SIZE);
  dim3 dimGrid((B.width + dimBlock.x - 1) / dimBlock.x, (A.height + dimBlock.y - 1) / dimBlock.y);
  MatMulKernel<<<dimGrid, dimBlock>>>(d_A, d_B, d_C);
  hipDeviceSynchronize();
  
  // Read C from device memory
  hipMemcpy(C.elements, d_C.elements, size, hipMemcpyDeviceToHost);
  
  // Free device memory
  hipFree(d_A.elements);
  hipFree(d_B.elements);
  hipFree(d_C.elements);
}

int main(int argc, char* argv[])
{
  clock_t tic;
  clock_t toc;

  Matrix A;
  Matrix B;
  Matrix C;

  int a;
  int b;
  int c;

  startSeed();

  int num_devices, device;
  printf("Multiplicação de Matrizes\n");
  printf("Neste programa foi utilizado um BLOCK_SIZE = 50\n\n");
  hipGetDeviceCount(&num_devices);
  for (device = 0; device < num_devices; device++) {
    hipDeviceProp_t properties;
    hipGetDeviceProperties(&properties, device);
    hipSetDevice(device);
    printf("Utilizando uma %s:\n\n", properties.name);
    for (int i = 100; i <= 1000; i += 100)
    {
      a = i;
      b = i;
      c = i;

      A = createMatrix(a, b);
      B = createMatrix(b, c);
      C = createMatrix(A.height, B.width);

      printf("A[%d][%d] * B[%d][%d]\n", a, b, b, c);
      
      draw_random(A);
      draw_random(B);

      tic = clock();
      MatMul(A, B, C);
      toc = clock();
      printf("GPU (global): %.3fms\n", (double)(toc - tic) / CLOCKS_PER_SEC*1000);
      C = createMatrix(A.height, B.width);

      draw_random(A);
      draw_random(B);

      tic = clock();
      MatMulShared(A, B, C);
      toc = clock();
      printf("GPU (shared): %.3fms\n", (double)(toc - tic) / CLOCKS_PER_SEC*1000);
      C = createMatrix(A.height, B.width);

      draw_random(A);
      draw_random(B);

      tic = clock();
      multiMatrixCPU(A, B, C);
      toc = clock();
      printf("CPU: %.3fms\n", (double)(toc - tic) / CLOCKS_PER_SEC*1000);
      printf("\n");
    }
  }
}
	.text
	.file	"multiplicaMatrizScript.hip"
	.globl	_Z9startSeedv                   # -- Begin function _Z9startSeedv
	.type	_Z9startSeedv,@function
_Z9startSeedv:                          # @_Z9startSeedv
	.cfi_startproc
# %bb.0:
	pushq	%rax
	.cfi_def_cfa_offset 16
	xorl	%edi, %edi
	callq	time
	movl	%eax, %edi
	callq	srand
	callq	rand
	movl	%eax, %edi
	popq	%rax
	.cfi_def_cfa_offset 8
	jmp	srand                           # TAILCALL
.Lfunc_end0:
	.size	_Z9startSeedv, .Lfunc_end0-_Z9startSeedv
	.cfi_endproc
                                        # -- End function
	.globl	_Z11draw_random6Matrix          # -- Begin function _Z11draw_random6Matrix
	.type	_Z11draw_random6Matrix,@function
_Z11draw_random6Matrix:                 # @_Z11draw_random6Matrix
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.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 %r15, -16
	movl	32(%rsp), %eax
	imull	36(%rsp), %eax
	testl	%eax, %eax
	jle	.LBB1_3
# %bb.1:                                # %.lr.ph
	leaq	32(%rsp), %rcx
	movq	16(%rcx), %rbx
	movl	%eax, %r14d
	xorl	%r15d, %r15d
.LBB1_2:                                # =>This Inner Loop Header: Depth=1
	callq	rand
	cltq
	imulq	$1717986919, %rax, %rcx         # imm = 0x66666667
	movq	%rcx, %rdx
	shrq	$63, %rdx
	sarq	$34, %rcx
	addl	%edx, %ecx
	addl	%ecx, %ecx
	leal	(%rcx,%rcx,4), %ecx
	subl	%ecx, %eax
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	movss	%xmm0, (%rbx,%r15,4)
	incq	%r15
	cmpq	%r15, %r14
	jne	.LBB1_2
.LBB1_3:                                # %._crit_edge
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end1:
	.size	_Z11draw_random6Matrix, .Lfunc_end1-_Z11draw_random6Matrix
	.cfi_endproc
                                        # -- End function
	.globl	_Z8disp_img6Matrix              # -- Begin function _Z8disp_img6Matrix
	.type	_Z8disp_img6Matrix,@function
_Z8disp_img6Matrix:                     # @_Z8disp_img6Matrix
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	pushq	%rax
	.cfi_def_cfa_offset 64
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	68(%rsp), %ebx
	testl	%ebx, %ebx
	jle	.LBB2_6
# %bb.1:                                # %.preheader.lr.ph
	leaq	64(%rsp), %rax
	movl	(%rax), %r14d
	movq	16(%rax), %rax
	movq	%rax, (%rsp)                    # 8-byte Spill
	xorl	%r12d, %r12d
	xorl	%r13d, %r13d
.LBB2_2:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB2_4 Depth 2
	testl	%r14d, %r14d
	jle	.LBB2_5
# %bb.3:                                # %.lr.ph
                                        #   in Loop: Header=BB2_2 Depth=1
	movl	%r12d, %eax
	movq	(%rsp), %rcx                    # 8-byte Reload
	leaq	(%rcx,%rax,4), %rbp
	xorl	%r15d, %r15d
.LBB2_4:                                #   Parent Loop BB2_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	xorps	%xmm0, %xmm0
	cvtss2sd	(%rbp,%r15,4), %xmm0
	movl	$.L.str, %edi
	movb	$1, %al
	callq	printf
	incq	%r15
	cmpq	%r15, %r14
	jne	.LBB2_4
.LBB2_5:                                # %._crit_edge
                                        #   in Loop: Header=BB2_2 Depth=1
	movl	$10, %edi
	callq	putchar@PLT
	incq	%r13
	addl	%r14d, %r12d
	cmpq	%rbx, %r13
	jne	.LBB2_2
.LBB2_6:                                # %._crit_edge11
	movl	$10, %edi
	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
	jmp	putchar@PLT                     # TAILCALL
.Lfunc_end2:
	.size	_Z8disp_img6Matrix, .Lfunc_end2-_Z8disp_img6Matrix
	.cfi_endproc
                                        # -- End function
	.globl	_Z12createMatrixii              # -- Begin function _Z12createMatrixii
	.type	_Z12createMatrixii,@function
_Z12createMatrixii:                     # @_Z12createMatrixii
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	pushq	%rax
	.cfi_def_cfa_offset 64
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	%edx, %ebx
	movl	%esi, %ebp
	movq	%rdi, %r14
	movl	%edx, (%rdi)
	movl	%esi, 4(%rdi)
	movl	%edx, %eax
	imull	%esi, %eax
	movslq	%eax, %rdi
	shlq	$2, %rdi
	callq	malloc
	movq	%rax, 16(%r14)
	testl	%ebp, %ebp
	jle	.LBB3_5
# %bb.1:                                # %.preheader.lr.ph
	movq	%rax, %r15
	movl	%ebx, %r12d
	shlq	$2, %r12
	movl	%ebp, %r13d
	xorl	%ebp, %ebp
.LBB3_2:                                # %.preheader
                                        # =>This Inner Loop Header: Depth=1
	testl	%ebx, %ebx
	jle	.LBB3_4
# %bb.3:                                # %.lr.ph
                                        #   in Loop: Header=BB3_2 Depth=1
	movl	%ebp, %eax
	leaq	(%r15,%rax,4), %rdi
	xorl	%esi, %esi
	movq	%r12, %rdx
	callq	memset@PLT
.LBB3_4:                                # %._crit_edge
                                        #   in Loop: Header=BB3_2 Depth=1
	addl	%ebx, %ebp
	decq	%r13
	jne	.LBB3_2
.LBB3_5:                                # %._crit_edge12
	movq	%r14, %rax
	addq	$8, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end3:
	.size	_Z12createMatrixii, .Lfunc_end3-_Z12createMatrixii
	.cfi_endproc
                                        # -- End function
	.globl	_Z14multiMatrixCPU6MatrixS_S_   # -- Begin function _Z14multiMatrixCPU6MatrixS_S_
	.type	_Z14multiMatrixCPU6MatrixS_S_,@function
_Z14multiMatrixCPU6MatrixS_S_:          # @_Z14multiMatrixCPU6MatrixS_S_
	.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
	movl	60(%rsp), %eax
	testl	%eax, %eax
	jle	.LBB4_9
# %bb.1:                                # %.preheader.lr.ph
	leaq	104(%rsp), %rdi
	leaq	80(%rsp), %r8
	leaq	56(%rsp), %r9
	movl	(%r8), %ecx
	movq	16(%rdi), %rdx
	movl	(%r9), %esi
	movq	16(%r9), %r9
	movq	%r9, -8(%rsp)                   # 8-byte Spill
	movq	16(%r8), %r8
	movq	%r8, -16(%rsp)                  # 8-byte Spill
	movslq	(%rdi), %rdi
	movq	%rdi, -24(%rsp)                 # 8-byte Spill
	movslq	%ecx, %r10
	leaq	(,%r10,4), %r11
	xorl	%ebx, %ebx
	xorl	%r14d, %r14d
.LBB4_2:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB4_4 Depth 2
                                        #       Child Loop BB4_6 Depth 3
	testl	%ecx, %ecx
	jle	.LBB4_8
# %bb.3:                                # %.lr.ph20
                                        #   in Loop: Header=BB4_2 Depth=1
	movl	%ebx, %edi
	movq	-8(%rsp), %r8                   # 8-byte Reload
	leaq	(%r8,%rdi,4), %r15
	movq	%r14, %rdi
	imulq	%r10, %rdi
	movq	%r14, %r8
	imulq	-24(%rsp), %r8                  # 8-byte Folded Reload
	leaq	(%rdx,%rdi,4), %r12
	leaq	(%rdx,%r8,4), %r13
	movq	-16(%rsp), %r8                  # 8-byte Reload
	xorl	%edi, %edi
.LBB4_4:                                #   Parent Loop BB4_2 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB4_6 Depth 3
	movl	$0, (%r12,%rdi,4)
	testl	%esi, %esi
	jle	.LBB4_7
# %bb.5:                                # %.lr.ph
                                        #   in Loop: Header=BB4_4 Depth=2
	movss	(%r13,%rdi,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	movq	%r8, %rbp
	xorl	%r9d, %r9d
.LBB4_6:                                #   Parent Loop BB4_2 Depth=1
                                        #     Parent Loop BB4_4 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	movss	(%r15,%r9,4), %xmm1             # xmm1 = mem[0],zero,zero,zero
	mulss	(%rbp), %xmm1
	addss	%xmm1, %xmm0
	movss	%xmm0, (%r13,%rdi,4)
	incq	%r9
	addq	%r11, %rbp
	cmpq	%r9, %rsi
	jne	.LBB4_6
.LBB4_7:                                # %._crit_edge
                                        #   in Loop: Header=BB4_4 Depth=2
	incq	%rdi
	addq	$4, %r8
	cmpq	%rcx, %rdi
	jne	.LBB4_4
.LBB4_8:                                # %._crit_edge21
                                        #   in Loop: Header=BB4_2 Depth=1
	incq	%r14
	addl	%esi, %ebx
	cmpq	%rax, %r14
	jne	.LBB4_2
.LBB4_9:                                # %._crit_edge23
	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	_Z14multiMatrixCPU6MatrixS_S_, .Lfunc_end4-_Z14multiMatrixCPU6MatrixS_S_
	.cfi_endproc
                                        # -- End function
	.globl	_Z33__device_stub__MatMulKernelShared6MatrixS_S_ # -- Begin function _Z33__device_stub__MatMulKernelShared6MatrixS_S_
	.type	_Z33__device_stub__MatMulKernelShared6MatrixS_S_,@function
_Z33__device_stub__MatMulKernelShared6MatrixS_S_: # @_Z33__device_stub__MatMulKernelShared6MatrixS_S_
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$80, %rsp
	.cfi_def_cfa_offset 128
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	128(%rsp), %rax
	leaq	48(%rsp), %rbx
	movq	%rax, (%rbx)
	leaq	152(%rsp), %rax
	movq	%rax, 8(%rbx)
	leaq	176(%rsp), %rax
	movq	%rax, 16(%rbx)
	leaq	32(%rsp), %r14
	leaq	16(%rsp), %r15
	leaq	8(%rsp), %r12
	movq	%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	$_Z18MatMulKernelShared6MatrixS_S_, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$96, %rsp
	.cfi_adjust_cfa_offset -96
	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_end5:
	.size	_Z33__device_stub__MatMulKernelShared6MatrixS_S_, .Lfunc_end5-_Z33__device_stub__MatMulKernelShared6MatrixS_S_
	.cfi_endproc
                                        # -- End function
	.globl	_Z12MatMulShared6MatrixS_S_     # -- Begin function _Z12MatMulShared6MatrixS_S_
	.type	_Z12MatMulShared6MatrixS_S_,@function
_Z12MatMulShared6MatrixS_S_:            # @_Z12MatMulShared6MatrixS_S_
	.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	$248, %rsp
	.cfi_def_cfa_offset 304
	.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	352(%rsp), %r13
	movl	304(%rsp), %eax
	movl	308(%rsp), %r15d
	leaq	72(%rsp), %rbx
	movl	%eax, -8(%rbx)
	movl	%eax, -16(%rbx)
	movl	%r15d, -12(%rbx)
	imull	%r15d, %eax
	movslq	%eax, %r14
	shlq	$2, %r14
	movq	%rbx, %rdi
	movq	%r14, %rsi
	callq	hipMalloc
	movq	(%rbx), %rdi
	movq	320(%rsp), %rsi
	movq	%r14, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movl	328(%rsp), %r12d
	movl	332(%rsp), %eax
	leaq	48(%rsp), %rbx
	movl	%r12d, -8(%rbx)
	movl	%r12d, -16(%rbx)
	movl	%eax, -12(%rbx)
	imull	%r12d, %eax
	movslq	%eax, %r14
	shlq	$2, %r14
	movq	%rbx, %rdi
	movq	%r14, %rsi
	callq	hipMalloc
	movq	(%rbx), %rdi
	movq	344(%rsp), %rsi
	movq	%r14, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movl	(%r13), %eax
	movl	4(%r13), %ecx
	leaq	24(%rsp), %rdi
	movl	%eax, -8(%rdi)
	movl	%eax, -16(%rdi)
	movl	%ecx, -12(%rdi)
	imull	%eax, %ecx
	movslq	%ecx, %rbx
	shlq	$2, %rbx
	movq	%rbx, %rsi
	callq	hipMalloc
	imulq	$1374389535, %r12, %rax         # imm = 0x51EB851F
	shrq	$36, %rax
	imulq	$1374389535, %r15, %rcx         # imm = 0x51EB851F
	shrq	$4, %rcx
	movabsq	$576460748008456192, %rdi       # imm = 0x7FFFFFF00000000
	andq	%rcx, %rdi
	orq	%rax, %rdi
	movabsq	$214748364850, %rdx             # imm = 0x3200000032
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB6_2
# %bb.1:
	movq	72(%rsp), %rax
	leaq	128(%rsp), %rcx
	movq	%rax, 16(%rcx)
	movups	56(%rsp), %xmm0
	movaps	%xmm0, (%rcx)
	movq	48(%rsp), %rax
	leaq	160(%rsp), %rdx
	movq	%rax, 16(%rdx)
	movups	32(%rsp), %xmm0
	movaps	%xmm0, (%rdx)
	movq	24(%rsp), %rax
	leaq	192(%rsp), %rsi
	movq	%rax, 16(%rsi)
	movups	8(%rsp), %xmm0
	movaps	%xmm0, (%rsi)
	leaq	224(%rsp), %r14
	movq	%rcx, (%r14)
	movq	%rdx, 8(%r14)
	movq	%rsi, 16(%r14)
	leaq	112(%rsp), %r15
	leaq	96(%rsp), %r12
	leaq	88(%rsp), %r13
	leaq	80(%rsp), %rbp
	movq	%r15, %rdi
	movq	%r12, %rsi
	movq	%r13, %rdx
	movq	%rbp, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r15), %rsi
	movl	8(%r15), %edx
	movq	(%r12), %rcx
	movl	8(%r12), %r8d
	movl	$_Z18MatMulKernelShared6MatrixS_S_, %edi
	movq	%r14, %r9
	pushq	(%rbp)
	.cfi_adjust_cfa_offset 8
	pushq	(%r13)
	leaq	368(%rsp), %r13
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$16, %rsp
	.cfi_adjust_cfa_offset -16
.LBB6_2:
	movq	16(%r13), %rdi
	movq	24(%rsp), %rsi
	movq	%rbx, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	movq	72(%rsp), %rdi
	callq	hipFree
	movq	48(%rsp), %rdi
	callq	hipFree
	movq	24(%rsp), %rdi
	callq	hipFree
	addq	$248, %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_end6:
	.size	_Z12MatMulShared6MatrixS_S_, .Lfunc_end6-_Z12MatMulShared6MatrixS_S_
	.cfi_endproc
                                        # -- End function
	.globl	_Z27__device_stub__MatMulKernel6MatrixS_S_ # -- Begin function _Z27__device_stub__MatMulKernel6MatrixS_S_
	.type	_Z27__device_stub__MatMulKernel6MatrixS_S_,@function
_Z27__device_stub__MatMulKernel6MatrixS_S_: # @_Z27__device_stub__MatMulKernel6MatrixS_S_
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$80, %rsp
	.cfi_def_cfa_offset 128
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	128(%rsp), %rax
	leaq	48(%rsp), %rbx
	movq	%rax, (%rbx)
	leaq	152(%rsp), %rax
	movq	%rax, 8(%rbx)
	leaq	176(%rsp), %rax
	movq	%rax, 16(%rbx)
	leaq	32(%rsp), %r14
	leaq	16(%rsp), %r15
	leaq	8(%rsp), %r12
	movq	%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	$_Z12MatMulKernel6MatrixS_S_, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$96, %rsp
	.cfi_adjust_cfa_offset -96
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end7:
	.size	_Z27__device_stub__MatMulKernel6MatrixS_S_, .Lfunc_end7-_Z27__device_stub__MatMulKernel6MatrixS_S_
	.cfi_endproc
                                        # -- End function
	.globl	_Z6MatMul6MatrixS_S_            # -- Begin function _Z6MatMul6MatrixS_S_
	.type	_Z6MatMul6MatrixS_S_,@function
_Z6MatMul6MatrixS_S_:                   # @_Z6MatMul6MatrixS_S_
	.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	$248, %rsp
	.cfi_def_cfa_offset 304
	.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	352(%rsp), %r13
	movl	304(%rsp), %eax
	movl	308(%rsp), %r15d
	leaq	72(%rsp), %rbx
	movl	%eax, -16(%rbx)
	movl	%r15d, -12(%rbx)
	imull	%r15d, %eax
	movslq	%eax, %r14
	shlq	$2, %r14
	movq	%rbx, %rdi
	movq	%r14, %rsi
	callq	hipMalloc
	movq	(%rbx), %rdi
	movq	320(%rsp), %rsi
	movq	%r14, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movl	328(%rsp), %r12d
	movl	332(%rsp), %eax
	leaq	48(%rsp), %rbx
	movl	%r12d, -16(%rbx)
	movl	%eax, -12(%rbx)
	imull	%r12d, %eax
	movslq	%eax, %r14
	shlq	$2, %r14
	movq	%rbx, %rdi
	movq	%r14, %rsi
	callq	hipMalloc
	movq	(%rbx), %rdi
	movq	344(%rsp), %rsi
	movq	%r14, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movl	(%r13), %eax
	movl	4(%r13), %ecx
	leaq	24(%rsp), %rdi
	movl	%eax, -16(%rdi)
	movl	%ecx, -12(%rdi)
	imull	%eax, %ecx
	movslq	%ecx, %rbx
	shlq	$2, %rbx
	movq	%rbx, %rsi
	callq	hipMalloc
	addl	$49, %r12d
	imulq	$1374389535, %r12, %rax         # imm = 0x51EB851F
	shrq	$36, %rax
	addl	$49, %r15d
	imulq	$1374389535, %r15, %rcx         # imm = 0x51EB851F
	shrq	$4, %rcx
	movabsq	$576460748008456192, %rdi       # imm = 0x7FFFFFF00000000
	andq	%rcx, %rdi
	orq	%rax, %rdi
	movabsq	$214748364850, %rdx             # imm = 0x3200000032
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB8_2
# %bb.1:
	movq	72(%rsp), %rax
	leaq	128(%rsp), %rcx
	movq	%rax, 16(%rcx)
	movups	56(%rsp), %xmm0
	movaps	%xmm0, (%rcx)
	movq	48(%rsp), %rax
	leaq	160(%rsp), %rdx
	movq	%rax, 16(%rdx)
	movups	32(%rsp), %xmm0
	movaps	%xmm0, (%rdx)
	movq	24(%rsp), %rax
	leaq	192(%rsp), %rsi
	movq	%rax, 16(%rsi)
	movups	8(%rsp), %xmm0
	movaps	%xmm0, (%rsi)
	leaq	224(%rsp), %r14
	movq	%rcx, (%r14)
	movq	%rdx, 8(%r14)
	movq	%rsi, 16(%r14)
	leaq	112(%rsp), %r15
	leaq	96(%rsp), %r12
	leaq	88(%rsp), %r13
	leaq	80(%rsp), %rbp
	movq	%r15, %rdi
	movq	%r12, %rsi
	movq	%r13, %rdx
	movq	%rbp, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r15), %rsi
	movl	8(%r15), %edx
	movq	(%r12), %rcx
	movl	8(%r12), %r8d
	movl	$_Z12MatMulKernel6MatrixS_S_, %edi
	movq	%r14, %r9
	pushq	(%rbp)
	.cfi_adjust_cfa_offset 8
	pushq	(%r13)
	leaq	368(%rsp), %r13
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$16, %rsp
	.cfi_adjust_cfa_offset -16
.LBB8_2:
	callq	hipDeviceSynchronize
	movq	16(%r13), %rdi
	movq	24(%rsp), %rsi
	movq	%rbx, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	movq	72(%rsp), %rdi
	callq	hipFree
	movq	48(%rsp), %rdi
	callq	hipFree
	movq	24(%rsp), %rdi
	callq	hipFree
	addq	$248, %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_end8:
	.size	_Z6MatMul6MatrixS_S_, .Lfunc_end8-_Z6MatMul6MatrixS_S_
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI9_0:
	.quad	0x412e848000000000              # double 1.0E+6
.LCPI9_1:
	.quad	0x408f400000000000              # double 1000
	.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	$1832, %rsp                     # imm = 0x728
	.cfi_def_cfa_offset 1888
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	callq	_Z9startSeedv
	movl	$.Lstr, %edi
	callq	puts@PLT
	movl	$.Lstr.1, %edi
	callq	puts@PLT
	leaq	196(%rsp), %rbx
	movq	%rbx, %rdi
	callq	hipGetDeviceCount
	cmpl	$0, (%rbx)
	jle	.LBB9_32
# %bb.1:                                # %.lr.ph
	xorl	%ebp, %ebp
.LBB9_2:                                # =>This Loop Header: Depth=1
                                        #     Child Loop BB9_3 Depth 2
                                        #       Child Loop BB9_5 Depth 3
                                        #       Child Loop BB9_8 Depth 3
                                        #       Child Loop BB9_11 Depth 3
                                        #       Child Loop BB9_14 Depth 3
                                        #       Child Loop BB9_17 Depth 3
                                        #       Child Loop BB9_20 Depth 3
                                        #       Child Loop BB9_23 Depth 3
                                        #         Child Loop BB9_25 Depth 4
                                        #           Child Loop BB9_27 Depth 5
	leaq	360(%rsp), %rbx
	movq	%rbx, %rdi
	movl	%ebp, %esi
	callq	hipGetDevicePropertiesR0600
	movl	%ebp, 192(%rsp)                 # 4-byte Spill
	movl	%ebp, %edi
	callq	hipSetDevice
	movl	$.L.str.4, %edi
	movq	%rbx, %rsi
	xorl	%eax, %eax
	callq	printf
	movl	$100, %r12d
.LBB9_3:                                #   Parent Loop BB9_2 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB9_5 Depth 3
                                        #       Child Loop BB9_8 Depth 3
                                        #       Child Loop BB9_11 Depth 3
                                        #       Child Loop BB9_14 Depth 3
                                        #       Child Loop BB9_17 Depth 3
                                        #       Child Loop BB9_20 Depth 3
                                        #       Child Loop BB9_23 Depth 3
                                        #         Child Loop BB9_25 Depth 4
                                        #           Child Loop BB9_27 Depth 5
	leaq	88(%rsp), %rbx
	movq	%rbx, %rdi
	movl	%r12d, %esi
	movl	%r12d, %edx
	callq	_Z12createMatrixii
	movl	88(%rsp), %r14d
	movl	92(%rsp), %ebp
	movq	96(%rsp), %rax
	movq	%rax, 144(%rsp)                 # 8-byte Spill
	movq	104(%rsp), %r15
	movq	%rbx, %rdi
	movl	%r12d, %esi
	movl	%r12d, %edx
	callq	_Z12createMatrixii
	movl	88(%rsp), %r13d
	movl	92(%rsp), %eax
	movl	%eax, 128(%rsp)                 # 4-byte Spill
	movq	96(%rsp), %rax
	movq	%rax, 200(%rsp)                 # 8-byte Spill
	movq	104(%rsp), %rax
	movq	%rax, 176(%rsp)                 # 8-byte Spill
	movq	%rbx, %rdi
	movl	%ebp, %esi
	movl	%r13d, %edx
	callq	_Z12createMatrixii
	movl	88(%rsp), %eax
	movl	%eax, 84(%rsp)                  # 4-byte Spill
	leaq	92(%rsp), %rcx
	movq	(%rcx), %rax
	movq	%rax, 112(%rsp)
	movl	8(%rcx), %eax
	movl	%eax, 120(%rsp)
	movq	104(%rsp), %rax
	movq	%rax, 168(%rsp)                 # 8-byte Spill
	movl	$.L.str.5, %edi
	movl	%r12d, %esi
	movl	%r12d, %edx
	movl	%r12d, %ecx
	movq	%r12, 208(%rsp)                 # 8-byte Spill
	movl	%r12d, %r8d
	xorl	%eax, %eax
	callq	printf
	movq	%rbp, 152(%rsp)                 # 8-byte Spill
	movl	%ebp, %eax
	imull	%r14d, %eax
	movl	%eax, %ebx
	movl	%eax, 140(%rsp)                 # 4-byte Spill
	testl	%eax, %eax
	jle	.LBB9_6
# %bb.4:                                # %.lr.ph.i
                                        #   in Loop: Header=BB9_3 Depth=2
	xorl	%r12d, %r12d
.LBB9_5:                                #   Parent Loop BB9_2 Depth=1
                                        #     Parent Loop BB9_3 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	callq	rand
	cltq
	imulq	$1717986919, %rax, %rcx         # imm = 0x66666667
	movq	%rcx, %rdx
	shrq	$63, %rdx
	sarq	$34, %rcx
	addl	%edx, %ecx
	addl	%ecx, %ecx
	leal	(%rcx,%rcx,4), %ecx
	subl	%ecx, %eax
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	movss	%xmm0, (%r15,%r12,4)
	incq	%r12
	cmpq	%r12, %rbx
	jne	.LBB9_5
.LBB9_6:                                # %_Z11draw_random6Matrix.exit
                                        #   in Loop: Header=BB9_3 Depth=2
	movq	%r15, 184(%rsp)                 # 8-byte Spill
	movl	128(%rsp), %eax                 # 4-byte Reload
	imull	%r13d, %eax
	movl	%eax, %r12d
	movl	%eax, 136(%rsp)                 # 4-byte Spill
	testl	%eax, %eax
	movq	176(%rsp), %r15                 # 8-byte Reload
	jle	.LBB9_9
# %bb.7:                                # %.lr.ph.i68
                                        #   in Loop: Header=BB9_3 Depth=2
	xorl	%ebp, %ebp
.LBB9_8:                                #   Parent Loop BB9_2 Depth=1
                                        #     Parent Loop BB9_3 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	callq	rand
	cltq
	imulq	$1717986919, %rax, %rcx         # imm = 0x66666667
	movq	%rcx, %rdx
	shrq	$63, %rdx
	sarq	$34, %rcx
	addl	%edx, %ecx
	addl	%ecx, %ecx
	leal	(%rcx,%rcx,4), %ecx
	subl	%ecx, %eax
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	movss	%xmm0, (%r15,%rbp,4)
	incq	%rbp
	cmpq	%rbp, %r12
	jne	.LBB9_8
.LBB9_9:                                # %_Z11draw_random6Matrix.exit73
                                        #   in Loop: Header=BB9_3 Depth=2
	callq	clock
	movq	%rax, 160(%rsp)                 # 8-byte Spill
	movl	%r14d, 288(%rsp)
	movq	152(%rsp), %rbp                 # 8-byte Reload
	movl	%ebp, 292(%rsp)
	movq	144(%rsp), %rax                 # 8-byte Reload
	movq	%rax, 296(%rsp)
	movq	%r15, %rax
	movq	184(%rsp), %r15                 # 8-byte Reload
	movq	%r15, 304(%rsp)
	movl	%r13d, 264(%rsp)
	movl	128(%rsp), %ecx                 # 4-byte Reload
	movl	%ecx, 268(%rsp)
	movq	200(%rsp), %rcx                 # 8-byte Reload
	movq	%rcx, 272(%rsp)
	movq	%rax, 280(%rsp)
	movl	84(%rsp), %eax                  # 4-byte Reload
	movl	%eax, 336(%rsp)
	movq	112(%rsp), %rax
	leaq	340(%rsp), %rcx
	movq	%rax, (%rcx)
	movl	120(%rsp), %eax
	movl	%eax, 8(%rcx)
	movq	168(%rsp), %rax                 # 8-byte Reload
	movq	%rax, 352(%rsp)
	movq	%rax, 64(%rsp)
	movups	336(%rsp), %xmm0
	movups	%xmm0, 48(%rsp)
	movq	280(%rsp), %rax
	movq	%rax, 40(%rsp)
	movups	264(%rsp), %xmm0
	movups	%xmm0, 24(%rsp)
	movq	304(%rsp), %rax
	movq	%rax, 16(%rsp)
	movups	288(%rsp), %xmm0
	movups	%xmm0, (%rsp)
	callq	_Z6MatMul6MatrixS_S_
	callq	clock
	subq	160(%rsp), %rax                 # 8-byte Folded Reload
	xorps	%xmm0, %xmm0
	cvtsi2sd	%rax, %xmm0
	divsd	.LCPI9_0(%rip), %xmm0
	mulsd	.LCPI9_1(%rip), %xmm0
	movl	$.L.str.6, %edi
	movb	$1, %al
	callq	printf
	leaq	88(%rsp), %rdi
	movl	%ebp, %esi
	movl	%r13d, %edx
	callq	_Z12createMatrixii
	movl	88(%rsp), %eax
	movl	%eax, 84(%rsp)                  # 4-byte Spill
	leaq	92(%rsp), %rcx
	movq	(%rcx), %rax
	movq	%rax, 112(%rsp)
	movl	8(%rcx), %eax
	movl	%eax, 120(%rsp)
	movq	104(%rsp), %rax
	movq	%rax, 168(%rsp)                 # 8-byte Spill
	cmpl	$0, 140(%rsp)                   # 4-byte Folded Reload
	jle	.LBB9_12
# %bb.10:                               # %.lr.ph.i74
                                        #   in Loop: Header=BB9_3 Depth=2
	xorl	%ebp, %ebp
.LBB9_11:                               #   Parent Loop BB9_2 Depth=1
                                        #     Parent Loop BB9_3 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	callq	rand
	cltq
	imulq	$1717986919, %rax, %rcx         # imm = 0x66666667
	movq	%rcx, %rdx
	shrq	$63, %rdx
	sarq	$34, %rcx
	addl	%edx, %ecx
	addl	%ecx, %ecx
	leal	(%rcx,%rcx,4), %ecx
	subl	%ecx, %eax
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	movss	%xmm0, (%r15,%rbp,4)
	incq	%rbp
	cmpq	%rbp, %rbx
	jne	.LBB9_11
.LBB9_12:                               # %_Z11draw_random6Matrix.exit79
                                        #   in Loop: Header=BB9_3 Depth=2
	cmpl	$0, 136(%rsp)                   # 4-byte Folded Reload
	movq	176(%rsp), %r15                 # 8-byte Reload
	jle	.LBB9_15
# %bb.13:                               # %.lr.ph.i80
                                        #   in Loop: Header=BB9_3 Depth=2
	xorl	%ebp, %ebp
.LBB9_14:                               #   Parent Loop BB9_2 Depth=1
                                        #     Parent Loop BB9_3 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	callq	rand
	cltq
	imulq	$1717986919, %rax, %rcx         # imm = 0x66666667
	movq	%rcx, %rdx
	shrq	$63, %rdx
	sarq	$34, %rcx
	addl	%edx, %ecx
	addl	%ecx, %ecx
	leal	(%rcx,%rcx,4), %ecx
	subl	%ecx, %eax
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	movss	%xmm0, (%r15,%rbp,4)
	incq	%rbp
	cmpq	%rbp, %r12
	jne	.LBB9_14
.LBB9_15:                               # %_Z11draw_random6Matrix.exit85
                                        #   in Loop: Header=BB9_3 Depth=2
	callq	clock
	movq	%rax, 160(%rsp)                 # 8-byte Spill
	movl	%r14d, 240(%rsp)
	movq	152(%rsp), %rbp                 # 8-byte Reload
	movl	%ebp, 244(%rsp)
	movq	144(%rsp), %rax                 # 8-byte Reload
	movq	%rax, 248(%rsp)
	movq	%r15, %rax
	movq	184(%rsp), %r15                 # 8-byte Reload
	movq	%r15, 256(%rsp)
	movl	%r13d, 216(%rsp)
	movl	128(%rsp), %ecx                 # 4-byte Reload
	movl	%ecx, 220(%rsp)
	movq	200(%rsp), %rcx                 # 8-byte Reload
	movq	%rcx, 224(%rsp)
	movq	%rax, 232(%rsp)
	movl	84(%rsp), %eax                  # 4-byte Reload
	movl	%eax, 312(%rsp)
	movq	112(%rsp), %rax
	leaq	316(%rsp), %rcx
	movq	%rax, (%rcx)
	movl	120(%rsp), %eax
	movl	%eax, 8(%rcx)
	movq	168(%rsp), %rax                 # 8-byte Reload
	movq	%rax, 328(%rsp)
	movq	%rax, 64(%rsp)
	movups	312(%rsp), %xmm0
	movups	%xmm0, 48(%rsp)
	movq	232(%rsp), %rax
	movq	%rax, 40(%rsp)
	movups	216(%rsp), %xmm0
	movups	%xmm0, 24(%rsp)
	movq	256(%rsp), %rax
	movq	%rax, 16(%rsp)
	movups	240(%rsp), %xmm0
	movups	%xmm0, (%rsp)
	callq	_Z12MatMulShared6MatrixS_S_
	callq	clock
	subq	160(%rsp), %rax                 # 8-byte Folded Reload
	xorps	%xmm0, %xmm0
	cvtsi2sd	%rax, %xmm0
	divsd	.LCPI9_0(%rip), %xmm0
	mulsd	.LCPI9_1(%rip), %xmm0
	movl	$.L.str.7, %edi
	movb	$1, %al
	callq	printf
	leaq	88(%rsp), %rdi
	movl	%ebp, %esi
	movl	%r13d, %edx
	callq	_Z12createMatrixii
	movslq	88(%rsp), %rax
	movq	%rax, 128(%rsp)                 # 8-byte Spill
	leaq	92(%rsp), %rcx
	movq	(%rcx), %rax
	movq	%rax, 112(%rsp)
	movl	8(%rcx), %eax
	movl	%eax, 120(%rsp)
	movq	104(%rsp), %rax
	movq	%rax, 144(%rsp)                 # 8-byte Spill
	cmpl	$0, 140(%rsp)                   # 4-byte Folded Reload
	jle	.LBB9_18
# %bb.16:                               # %.lr.ph.i86
                                        #   in Loop: Header=BB9_3 Depth=2
	xorl	%ebp, %ebp
.LBB9_17:                               #   Parent Loop BB9_2 Depth=1
                                        #     Parent Loop BB9_3 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	callq	rand
	cltq
	imulq	$1717986919, %rax, %rcx         # imm = 0x66666667
	movq	%rcx, %rdx
	shrq	$63, %rdx
	sarq	$34, %rcx
	addl	%edx, %ecx
	addl	%ecx, %ecx
	leal	(%rcx,%rcx,4), %ecx
	subl	%ecx, %eax
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	movss	%xmm0, (%r15,%rbp,4)
	incq	%rbp
	cmpq	%rbp, %rbx
	jne	.LBB9_17
.LBB9_18:                               # %_Z11draw_random6Matrix.exit91
                                        #   in Loop: Header=BB9_3 Depth=2
	cmpl	$0, 136(%rsp)                   # 4-byte Folded Reload
	movq	176(%rsp), %r15                 # 8-byte Reload
	jle	.LBB9_21
# %bb.19:                               # %.lr.ph.i92
                                        #   in Loop: Header=BB9_3 Depth=2
	xorl	%ebx, %ebx
.LBB9_20:                               #   Parent Loop BB9_2 Depth=1
                                        #     Parent Loop BB9_3 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	callq	rand
	cltq
	imulq	$1717986919, %rax, %rcx         # imm = 0x66666667
	movq	%rcx, %rdx
	shrq	$63, %rdx
	sarq	$34, %rcx
	addl	%edx, %ecx
	addl	%ecx, %ecx
	leal	(%rcx,%rcx,4), %ecx
	subl	%ecx, %eax
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	movss	%xmm0, (%r15,%rbx,4)
	incq	%rbx
	cmpq	%rbx, %r12
	jne	.LBB9_20
.LBB9_21:                               # %_Z11draw_random6Matrix.exit97
                                        #   in Loop: Header=BB9_3 Depth=2
	callq	clock
	movq	%rax, %rbx
	cmpl	$0, 152(%rsp)                   # 4-byte Folded Reload
	jle	.LBB9_30
# %bb.22:                               # %.preheader.lr.ph.i
                                        #   in Loop: Header=BB9_3 Depth=2
	movslq	%r13d, %rax
	leaq	(,%rax,4), %rcx
	xorl	%edx, %edx
	xorl	%esi, %esi
.LBB9_23:                               # %.preheader.i
                                        #   Parent Loop BB9_2 Depth=1
                                        #     Parent Loop BB9_3 Depth=2
                                        # =>    This Loop Header: Depth=3
                                        #         Child Loop BB9_25 Depth 4
                                        #           Child Loop BB9_27 Depth 5
	testl	%r13d, %r13d
	jle	.LBB9_29
# %bb.24:                               # %.lr.ph20.i
                                        #   in Loop: Header=BB9_23 Depth=3
	movl	%edx, %edi
	movq	184(%rsp), %r8                  # 8-byte Reload
	leaq	(%r8,%rdi,4), %rdi
	movq	%rsi, %r8
	imulq	%rax, %r8
	movq	%rsi, %r9
	imulq	128(%rsp), %r9                  # 8-byte Folded Reload
	movq	144(%rsp), %r10                 # 8-byte Reload
	leaq	(%r10,%r8,4), %r8
	leaq	(%r10,%r9,4), %r9
	movq	%r15, %r10
	xorl	%r11d, %r11d
.LBB9_25:                               #   Parent Loop BB9_2 Depth=1
                                        #     Parent Loop BB9_3 Depth=2
                                        #       Parent Loop BB9_23 Depth=3
                                        # =>      This Loop Header: Depth=4
                                        #           Child Loop BB9_27 Depth 5
	movl	$0, (%r8,%r11,4)
	testl	%r14d, %r14d
	jle	.LBB9_28
# %bb.26:                               # %.lr.ph.i99
                                        #   in Loop: Header=BB9_25 Depth=4
	movss	(%r9,%r11,4), %xmm0             # xmm0 = mem[0],zero,zero,zero
	movq	%r10, %r12
	xorl	%ebp, %ebp
.LBB9_27:                               #   Parent Loop BB9_2 Depth=1
                                        #     Parent Loop BB9_3 Depth=2
                                        #       Parent Loop BB9_23 Depth=3
                                        #         Parent Loop BB9_25 Depth=4
                                        # =>        This Inner Loop Header: Depth=5
	movss	(%rdi,%rbp,4), %xmm1            # xmm1 = mem[0],zero,zero,zero
	mulss	(%r12), %xmm1
	addss	%xmm1, %xmm0
	movss	%xmm0, (%r9,%r11,4)
	incq	%rbp
	addq	%rcx, %r12
	cmpq	%rbp, %r14
	jne	.LBB9_27
.LBB9_28:                               # %._crit_edge.i
                                        #   in Loop: Header=BB9_25 Depth=4
	incq	%r11
	addq	$4, %r10
	cmpq	%r13, %r11
	jne	.LBB9_25
.LBB9_29:                               # %._crit_edge21.i
                                        #   in Loop: Header=BB9_23 Depth=3
	incq	%rsi
	addl	%r14d, %edx
	cmpq	152(%rsp), %rsi                 # 8-byte Folded Reload
	jne	.LBB9_23
.LBB9_30:                               # %_Z14multiMatrixCPU6MatrixS_S_.exit
                                        #   in Loop: Header=BB9_3 Depth=2
	callq	clock
	subq	%rbx, %rax
	xorps	%xmm0, %xmm0
	cvtsi2sd	%rax, %xmm0
	divsd	.LCPI9_0(%rip), %xmm0
	mulsd	.LCPI9_1(%rip), %xmm0
	movl	$.L.str.8, %edi
	movb	$1, %al
	callq	printf
	movl	$10, %edi
	callq	putchar@PLT
	movq	208(%rsp), %rcx                 # 8-byte Reload
	leal	100(%rcx), %eax
	cmpl	$901, %ecx                      # imm = 0x385
	movl	%eax, %r12d
	jb	.LBB9_3
# %bb.31:                               #   in Loop: Header=BB9_2 Depth=1
	movl	192(%rsp), %ebp                 # 4-byte Reload
	incl	%ebp
	cmpl	196(%rsp), %ebp
	jl	.LBB9_2
.LBB9_32:                               # %._crit_edge
	xorl	%eax, %eax
	addq	$1832, %rsp                     # imm = 0x728
	.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_end9:
	.size	main, .Lfunc_end9-main
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$32, %rsp
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -16
	movq	__hip_gpubin_handle(%rip), %rbx
	testq	%rbx, %rbx
	jne	.LBB10_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB10_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z18MatMulKernelShared6MatrixS_S_, %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	$_Z12MatMulKernel6MatrixS_S_, %esi
	movl	$.L__unnamed_2, %edx
	movl	$.L__unnamed_2, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$__hip_module_dtor, %edi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_end10:
	.size	__hip_module_ctor, .Lfunc_end10-__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	.LBB11_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
.LBB11_2:
	retq
.Lfunc_end11:
	.size	__hip_module_dtor, .Lfunc_end11-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"%5.0f"
	.size	.L.str, 6

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

	.type	_Z12MatMulKernel6MatrixS_S_,@object # @_Z12MatMulKernel6MatrixS_S_
	.globl	_Z12MatMulKernel6MatrixS_S_
	.p2align	3, 0x0
_Z12MatMulKernel6MatrixS_S_:
	.quad	_Z27__device_stub__MatMulKernel6MatrixS_S_
	.size	_Z12MatMulKernel6MatrixS_S_, 8

	.type	.L.str.4,@object                # @.str.4
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.4:
	.asciz	"Utilizando uma %s:\n\n"
	.size	.L.str.4, 21

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"A[%d][%d] * B[%d][%d]\n"
	.size	.L.str.5, 23

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"GPU (global): %.3fms\n"
	.size	.L.str.6, 22

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"GPU (shared): %.3fms\n"
	.size	.L.str.7, 22

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"CPU: %.3fms\n"
	.size	.L.str.8, 13

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z18MatMulKernelShared6MatrixS_S_"
	.size	.L__unnamed_1, 34

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_Z12MatMulKernel6MatrixS_S_"
	.size	.L__unnamed_2, 28

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

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

	.type	.Lstr,@object                   # @str
	.section	.rodata.str1.1,"aMS",@progbits,1
.Lstr:
	.asciz	"Multiplica\303\247\303\243o de Matrizes"
	.size	.Lstr, 28

	.type	.Lstr.1,@object                 # @str.1
.Lstr.1:
	.asciz	"Neste programa foi utilizado um BLOCK_SIZE = 50\n"
	.size	.Lstr.1, 49

	.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 _Z33__device_stub__MatMulKernelShared6MatrixS_S_
	.addrsig_sym _Z27__device_stub__MatMulKernel6MatrixS_S_
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z18MatMulKernelShared6MatrixS_S_
	.addrsig_sym _Z12MatMulKernel6MatrixS_S_
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z18MatMulKernelShared6MatrixS_S_ ; -- Begin function _Z18MatMulKernelShared6MatrixS_S_
	.globl	_Z18MatMulKernelShared6MatrixS_S_
	.p2align	8
	.type	_Z18MatMulKernelShared6MatrixS_S_,@function
_Z18MatMulKernelShared6MatrixS_S_:      ; @_Z18MatMulKernelShared6MatrixS_S_
; %bb.0:
	s_clause 0x1
	s_load_b32 s5, s[0:1], 0x0
	s_load_b64 s[2:3], s[0:1], 0x40
	v_bfe_u32 v1, v0, 10, 10
	v_and_b32_e32 v0, 0x3ff, v0
	v_mov_b32_e32 v2, 0
	s_waitcnt lgkmcnt(0)
	s_cmp_lt_i32 s5, 50
	s_cbranch_scc1 .LBB0_5
; %bb.1:                                ; %.lr.ph
	s_clause 0x3
	s_load_b32 s10, s[0:1], 0x8
	s_load_b32 s4, s[0:1], 0x20
	s_load_b64 s[6:7], s[0:1], 0x10
	s_load_b64 s[8:9], s[0:1], 0x28
	v_lshlrev_b32_e32 v2, 2, v0
	s_mul_hi_i32 s5, s5, 0x51eb851f
	v_mul_u32_u24_e32 v3, 0xc8, v1
	s_lshr_b32 s11, s5, 31
	s_ashr_i32 s5, s5, 4
	v_add_nc_u32_e32 v4, 0x2710, v2
	s_add_i32 s5, s5, s11
	s_waitcnt lgkmcnt(0)
	v_mad_u64_u32 v[5:6], null, s10, v1, v[0:1]
	v_mad_u64_u32 v[7:8], null, s4, v1, v[0:1]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_ashrrev_i32_e32 v6, 31, v5
	v_ashrrev_i32_e32 v8, 31, v7
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_3)
	v_lshlrev_b64 v[9:10], 2, v[5:6]
	v_mad_u32_u24 v5, 0xc8, v1, v2
	v_lshlrev_b64 v[11:12], 2, v[7:8]
	v_mad_u32_u24 v6, 0xc8, v1, v4
	v_mov_b32_e32 v2, 0
	v_add_co_u32 v7, vcc_lo, s6, v9
	v_add_co_ci_u32_e32 v8, vcc_lo, s7, v10, vcc_lo
	v_add_co_u32 v9, vcc_lo, s8, v11
	v_add_co_ci_u32_e32 v10, vcc_lo, s9, v12, vcc_lo
	s_mul_i32 s6, s10, s15
	s_mov_b32 s7, 0
.LBB0_2:                                ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB0_3 Depth 2
	s_delay_alu instid0(SALU_CYCLE_1)
	s_mul_i32 s8, s7, s4
	s_add_i32 s9, s7, s6
	s_add_i32 s10, s8, s14
	s_mul_i32 s8, s9, 50
	s_mul_i32 s10, s10, 50
	s_ashr_i32 s9, s8, 31
	s_ashr_i32 s11, s10, 31
	s_lshl_b64 s[8:9], s[8:9], 2
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_2) | instid1(SALU_CYCLE_1)
	v_add_co_u32 v11, vcc_lo, v7, s8
	v_add_co_ci_u32_e32 v12, vcc_lo, s9, v8, vcc_lo
	s_lshl_b64 s[8:9], s[10:11], 2
	v_add_co_u32 v13, vcc_lo, v9, s8
	v_add_co_ci_u32_e32 v14, vcc_lo, s9, v10, vcc_lo
	global_load_b32 v12, v[11:12], off
	global_load_b32 v13, v[13:14], off
	v_mov_b32_e32 v11, v4
	s_mov_b32 s8, 0
	s_waitcnt vmcnt(1)
	ds_store_b32 v5, v12
	s_waitcnt vmcnt(0)
	ds_store_b32 v6, v13
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
.LBB0_3:                                ;   Parent Loop BB0_2 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	v_add_nc_u32_e32 v12, s8, v3
	s_add_i32 s8, s8, 4
	ds_load_b32 v13, v11
	ds_load_b32 v12, v12
	v_add_nc_u32_e32 v11, 0xc8, v11
	s_cmpk_eq_i32 s8, 0xc8
	s_waitcnt lgkmcnt(0)
	v_fmac_f32_e32 v2, v12, v13
	s_cbranch_scc0 .LBB0_3
; %bb.4:                                ;   in Loop: Header=BB0_2 Depth=1
	s_add_i32 s7, s7, 1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_cmp_eq_u32 s7, s5
	s_barrier
	buffer_gl0_inv
	s_cbranch_scc0 .LBB0_2
.LBB0_5:                                ; %Flow101
	s_load_b32 s0, s[0:1], 0x38
	s_waitcnt lgkmcnt(0)
	v_mad_u64_u32 v[3:4], null, s0, v1, v[0:1]
	s_mul_i32 s0, s0, s15
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_add_i32 s0, s0, s14
	s_mul_i32 s0, s0, 50
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	s_ashr_i32 s1, s0, 31
	v_ashrrev_i32_e32 v4, 31, v3
	s_lshl_b64 s[0:1], s[0:1], 2
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	s_add_u32 s0, s2, s0
	s_addc_u32 s1, s3, s1
	v_lshlrev_b64 v[0:1], 2, v[3:4]
	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
	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 _Z18MatMulKernelShared6MatrixS_S_
		.amdhsa_group_segment_fixed_size 20000
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 72
		.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 15
		.amdhsa_next_free_sgpr 16
		.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	_Z18MatMulKernelShared6MatrixS_S_, .Lfunc_end0-_Z18MatMulKernelShared6MatrixS_S_
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 556
; NumSgprs: 18
; NumVgprs: 15
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 20000 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 15
; 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
	.protected	_Z12MatMulKernel6MatrixS_S_ ; -- Begin function _Z12MatMulKernel6MatrixS_S_
	.globl	_Z12MatMulKernel6MatrixS_S_
	.p2align	8
	.type	_Z12MatMulKernel6MatrixS_S_,@function
_Z12MatMulKernel6MatrixS_S_:            ; @_Z12MatMulKernel6MatrixS_S_
; %bb.0:
	s_clause 0x2
	s_load_b32 s2, s[0:1], 0x54
	s_load_b64 s[4:5], s[0:1], 0x0
	s_load_b32 s8, s[0:1], 0x18
	v_bfe_u32 v2, v0, 10, 10
	v_and_b32_e32 v3, 0x3ff, v0
	s_add_u32 s6, s0, 24
	s_addc_u32 s7, s1, 0
	s_waitcnt lgkmcnt(0)
	s_lshr_b32 s3, s2, 16
	s_and_b32 s2, s2, 0xffff
	v_mad_u64_u32 v[0:1], null, s15, s3, v[2:3]
	v_mad_u64_u32 v[1:2], null, s14, s2, v[3:4]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_cmp_gt_i32_e32 vcc_lo, s5, v0
	v_cmp_gt_i32_e64 s2, s8, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_and_b32 s2, vcc_lo, s2
	s_and_saveexec_b32 s3, s2
	s_cbranch_execz .LBB1_6
; %bb.1:                                ; %.preheader
	s_load_b64 s[2:3], s[0:1], 0x40
	s_cmp_lt_i32 s4, 1
	s_cbranch_scc1 .LBB1_4
; %bb.2:                                ; %.lr.ph
	s_clause 0x1
	s_load_b64 s[10:11], s[0:1], 0x10
	s_load_b64 s[6:7], s[6:7], 0x10
	v_mul_lo_u32 v2, v0, s4
	v_mov_b32_e32 v6, 0
	v_mov_b32_e32 v4, v1
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v3, 31, v2
	v_lshlrev_b64 v[2:3], 2, v[2:3]
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v2, vcc_lo, s10, v2
	v_add_co_ci_u32_e32 v3, vcc_lo, s11, v3, vcc_lo
.LBB1_3:                                ; =>This Inner Loop Header: Depth=1
	v_ashrrev_i32_e32 v5, 31, v4
	s_add_i32 s4, s4, -1
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	s_cmp_eq_u32 s4, 0
	v_lshlrev_b64 v[7:8], 2, v[4:5]
	v_add_nc_u32_e32 v4, s8, v4
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_co_u32 v7, vcc_lo, s6, v7
	v_add_co_ci_u32_e32 v8, vcc_lo, s7, v8, vcc_lo
	global_load_b32 v5, v[2:3], off
	global_load_b32 v7, v[7:8], off
	v_add_co_u32 v2, vcc_lo, v2, 4
	v_add_co_ci_u32_e32 v3, vcc_lo, 0, v3, vcc_lo
	s_waitcnt vmcnt(0)
	v_fmac_f32_e32 v6, v5, v7
	s_cbranch_scc0 .LBB1_3
	s_branch .LBB1_5
.LBB1_4:
	v_mov_b32_e32 v6, 0
.LBB1_5:                                ; %Flow36
	s_load_b32 s0, s[0:1], 0x30
	s_waitcnt lgkmcnt(0)
	v_mad_u64_u32 v[2:3], null, v0, s0, v[1:2]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v3, 31, v2
	v_lshlrev_b64 v[0:1], 2, v[2:3]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v0, vcc_lo, s2, v0
	v_add_co_ci_u32_e32 v1, vcc_lo, s3, v1, vcc_lo
	global_store_b32 v[0:1], v6, off
.LBB1_6:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z12MatMulKernel6MatrixS_S_
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 328
		.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 9
		.amdhsa_next_free_sgpr 16
		.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	_Z12MatMulKernel6MatrixS_S_, .Lfunc_end1-_Z12MatMulKernel6MatrixS_S_
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 368
; NumSgprs: 18
; NumVgprs: 9
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 9
; 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:
      - .offset:         0
        .size:           24
        .value_kind:     by_value
      - .offset:         24
        .size:           24
        .value_kind:     by_value
      - .offset:         48
        .size:           24
        .value_kind:     by_value
    .group_segment_fixed_size: 20000
    .kernarg_segment_align: 8
    .kernarg_segment_size: 72
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z18MatMulKernelShared6MatrixS_S_
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z18MatMulKernelShared6MatrixS_S_.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     15
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
  - .args:
      - .offset:         0
        .size:           24
        .value_kind:     by_value
      - .offset:         24
        .size:           24
        .value_kind:     by_value
      - .offset:         48
        .size:           24
        .value_kind:     by_value
      - .offset:         72
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         76
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         80
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         84
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         86
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         88
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         90
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         92
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         94
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         112
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         120
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         128
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         136
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 328
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z12MatMulKernel6MatrixS_S_
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z12MatMulKernel6MatrixS_S_.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     9
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
