#include <cuda.h>
#include <cstdio>
#include <cstdlib>
#define BSIZE2D 32

// EJERCICIOS
// (1) Implemente el matmul de GPU basico
// (2) Implemente el matmul de GPU usando memoria compartida
// (3) Compare el rendimiento de GPU Matmul vs el de CPU que hizo previamente

// GPU matmul basico
__global__ void kernel_matmul(int n, float *a, float *b, float *c){
}

// GPU matmul shared memory 
__global__ void kernel_matmulsm(int n, float *a, float *b, float *c){
}

void matrandom(int n, float *m){
    srand(1);
    for(int i=0; i<n; ++i){
        for(int j=0; j<n; ++j){
            m[i*n + j] = (float)rand()/((float)RAND_MAX);
            //m[i*n + j] = i;
        }
    }
}

void printmat(int n, float *m, const char* msg){
    printf("%s\n", msg);
    for(int i=0; i<n; ++i){
        for(int j=0; j<n; ++j){
            printf("%.2f ", m[i*n + j]);
        }
        printf("\n");
    }
}

int verify(int n, float *a, float *b, float *c, float *cgold){
    float error = 0.01f;
    for(int i=0; i<n; ++i){
        for(int j=0; j<n; ++j){
            float sum = 0.0f;
            for(int k=0; k<n; ++k){
                sum += a[i*n + k]*b[k*n + j];
            }
            cgold[i*n + j] = sum;
            if(fabs(c[i*n + j] - cgold[i*n + j]) >= error){
                fprintf(stderr, "error: c[%i][%i] ---> c %f    cgold %f\n", i, j, c[i*n+j], cgold[i*n+j]);
                return 0;
            }
        }
    }
    return 1;
}

int main(int argc, char **argv){
    printf("GPU MATMUL\n");
    if(argc != 2){
        fprintf(stderr, "run as ./prog n\n");
        exit(EXIT_FAILURE);
    }
    int n = atoi(argv[1]);
    float msecs = 0.0f;

    // (1) creando matrices en host
    float *a = new float[n*n];
    float *b = new float[n*n];
    float *c = new float[n*n];
    float *cgold = new float[n*n];
    printf("initializing A and B......."); fflush(stdout);
    matrandom(n, a);
    matrandom(n, b);
    if(n < 64){
        printmat(n, a, "mat a");
        printmat(n, b, "mat b");
    }
    printf("ok\n"); fflush(stdout);

    // (2) dejando matrices en device
    float *ad, *bd, *cd;
    cudaMalloc(&ad, sizeof(float)*n*n);
    cudaMalloc(&bd, sizeof(float)*n*n);
    cudaMalloc(&cd, sizeof(float)*n*n);
    cudaMemcpy(ad, a, sizeof(float)*n*n, cudaMemcpyHostToDevice);
    cudaMemcpy(bd, b, sizeof(float)*n*n, cudaMemcpyHostToDevice);
    cudaMemcpy(cd, c, sizeof(float)*n*n, cudaMemcpyHostToDevice);

    // (3) ejecutar matmul en GPU
    printf("computing C = A x B........"); fflush(stdout);
        cudaEvent_t start, stop;
        cudaEventCreate(&start);
        cudaEventCreate(&stop);
        dim3 block(BSIZE2D, BSIZE2D, 1);
        dim3 grid((n+BSIZE2D-1)/BSIZE2D, (n+BSIZE2D-1)/BSIZE2D, 1); 
        cudaEventRecord(start);
        kernel_matmul<<<grid, block>>>(n, ad, bd, cd);
        //kernel_matmulsm<<<grid, block>>>(n, ad, bd, cd);
        cudaDeviceSynchronize();
        cudaEventRecord(stop);
        cudaEventSynchronize(stop);
        cudaEventElapsedTime(&msecs, start, stop);
    printf("ok: time: %f secs\n", msecs/1000.0f);

    // (4) copiar resultado a host
    printf("copying result to host....."); fflush(stdout);
    cudaMemcpy(c, cd, sizeof(float)*n*n, cudaMemcpyDeviceToHost);
    printf("ok\n"); fflush(stdout);

    if(n < 50){
        printmat(n, c, "mat c");
    }

    // (5) verificar resultado contra calculo en CPU
    printf("verifying result..........."); fflush(stdout);
    if(!verify(n, a, b, c, cgold)){
        fprintf(stderr, "error verifying result\n");
        exit(EXIT_FAILURE);
    }
    printf("ok\n");
    printf("done!\n");
    exit(EXIT_SUCCESS);
}
    

	.file	"tmpxft_00289909_00000000-6_main.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2033:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2033:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z9matrandomiPf
	.type	_Z9matrandomiPf, @function
_Z9matrandomiPf:
.LFB2027:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	movslq	%edi, %r13
	movl	$1, %edi
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	xorl	%r12d, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	movq	%r13, %rbp
	salq	$2, %r13
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	movq	%rsi, %rbx
	call	srand@PLT
.L3:
	cmpl	%ebp, %r12d
	jge	.L9
	leaq	(%rbx,%r13), %r14
.L4:
	call	rand@PLT
	addq	$4, %rbx
	cvtsi2ssl	%eax, %xmm0
	mulss	.LC0(%rip), %xmm0
	movss	%xmm0, -4(%rbx)
	cmpq	%r14, %rbx
	jne	.L4
	incl	%r12d
	jmp	.L3
.L9:
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2027:
	.size	_Z9matrandomiPf, .-_Z9matrandomiPf
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC1:
	.string	"%s\n"
.LC2:
	.string	"%.2f "
.LC3:
	.string	"\n"
	.text
	.globl	_Z8printmatiPfPKc
	.type	_Z8printmatiPfPKc, @function
_Z8printmatiPfPKc:
.LFB2028:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	xorl	%eax, %eax
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	leaq	.LC2(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movslq	%edi, %r13
	movl	$2, %edi
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	xorl	%r12d, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%r13, %rbp
	salq	$2, %r13
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	%rsi, %rbx
	leaq	.LC1(%rip), %rsi
	pushq	%rcx
	.cfi_def_cfa_offset 64
	call	__printf_chk@PLT
.L11:
	cmpl	%ebp, %r12d
	jge	.L16
	leaq	(%rbx,%r13), %r15
.L12:
	cvtss2sd	(%rbx), %xmm0
	movq	%r14, %rsi
	movl	$2, %edi
	movb	$1, %al
	call	__printf_chk@PLT
	addq	$4, %rbx
	cmpq	%r15, %rbx
	jne	.L12
	leaq	.LC3(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	incl	%r12d
	call	__printf_chk@PLT
	jmp	.L11
.L16:
	popq	%rax
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2028:
	.size	_Z8printmatiPfPKc, .-_Z8printmatiPfPKc
	.section	.rodata.str1.1
.LC7:
	.string	"error: c[%i][%i] ---> c %f    cgold %f\n"
	.text
	.globl	_Z6verifyiPfS_S_S_
	.type	_Z6verifyiPfS_S_S_, @function
_Z6verifyiPfS_S_S_:
.LFB2029:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	movq	%rsi, %r10
	movslq	%edi, %rsi
	movq	%rdx, %r11
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	movl	%edi, %eax
	salq	$2, %rsi
	xorl	%edx, %edx
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	movq	%r8, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	movq	%rcx, %rbx
	xorl	%ecx, %ecx
	pushq	%r9
	.cfi_def_cfa_offset 48
	movss	.LC5(%rip), %xmm3
.L18:
	cmpl	%eax, %ecx
	jge	.L30
	movq	%rdx, %r9
	xorl	%r8d, %r8d
	leaq	(%r10,%rdx), %r13
.L24:
	leaq	(%r11,%r8,4), %r12
	xorl	%edi, %edi
	xorps	%xmm1, %xmm1
.L19:
	movss	0(%r13,%rdi,4), %xmm0
	mulss	(%r12), %xmm0
	incq	%rdi
	addq	%rsi, %r12
	addss	%xmm0, %xmm1
	cmpl	%edi, %eax
	jg	.L19
	movss	%xmm1, 0(%rbp,%r9)
	movss	(%rbx,%r9), %xmm0
	movaps	%xmm0, %xmm2
	subss	%xmm1, %xmm2
	andps	%xmm3, %xmm2
	comiss	.LC6(%rip), %xmm2
	jb	.L28
	movl	$2, %esi
	movq	stderr(%rip), %rdi
	leaq	.LC7(%rip), %rdx
	movb	$2, %al
	cvtss2sd	%xmm0, %xmm0
	cvtss2sd	%xmm1, %xmm1
	call	__fprintf_chk@PLT
	xorl	%eax, %eax
	jmp	.L17
.L28:
	incq	%r8
	addq	$4, %r9
	cmpl	%r8d, %eax
	jg	.L24
	incl	%ecx
	addq	%rsi, %rdx
	jmp	.L18
.L30:
	movl	$1, %eax
.L17:
	popq	%rdx
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2029:
	.size	_Z6verifyiPfS_S_S_, .-_Z6verifyiPfS_S_S_
	.globl	_Z38__device_stub__Z13kernel_matmuliPfS_S_iPfS_S_
	.type	_Z38__device_stub__Z13kernel_matmuliPfS_S_iPfS_S_, @function
_Z38__device_stub__Z13kernel_matmuliPfS_S_iPfS_S_:
.LFB2055:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movl	%edi, 28(%rsp)
	leaq	56(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	68(%rsp), %rsi
	movq	%rdx, 8(%rsp)
	leaq	40(%rsp), %rdx
	movq	%rcx, (%rsp)
	leaq	48(%rsp), %rcx
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	28(%rsp), %rax
	movl	$1, 64(%rsp)
	movq	%rax, 104(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 120(%rsp)
	movq	%rsp, %rax
	movq	%rax, 128(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 56(%rsp)
	movq	%rax, 68(%rsp)
	movl	$1, 76(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L31
	pushq	48(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z13kernel_matmuliPfS_S_(%rip), %rdi
	pushq	48(%rsp)
	.cfi_def_cfa_offset 176
	movq	84(%rsp), %rcx
	movl	92(%rsp), %r8d
	movq	72(%rsp), %rsi
	movl	80(%rsp), %edx
	leaq	120(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 168
	popq	%rdx
	.cfi_def_cfa_offset 160
.L31:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L33
	call	__stack_chk_fail@PLT
.L33:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2055:
	.size	_Z38__device_stub__Z13kernel_matmuliPfS_S_iPfS_S_, .-_Z38__device_stub__Z13kernel_matmuliPfS_S_iPfS_S_
	.globl	_Z13kernel_matmuliPfS_S_
	.type	_Z13kernel_matmuliPfS_S_, @function
_Z13kernel_matmuliPfS_S_:
.LFB2056:
	.cfi_startproc
	endbr64
	jmp	_Z38__device_stub__Z13kernel_matmuliPfS_S_iPfS_S_
	.cfi_endproc
.LFE2056:
	.size	_Z13kernel_matmuliPfS_S_, .-_Z13kernel_matmuliPfS_S_
	.section	.rodata.str1.1
.LC8:
	.string	"GPU MATMUL\n"
.LC9:
	.string	"run as ./prog n\n"
.LC10:
	.string	"initializing A and B......."
.LC11:
	.string	"mat a"
.LC12:
	.string	"mat b"
.LC13:
	.string	"ok\n"
.LC14:
	.string	"computing C = A x B........"
.LC16:
	.string	"ok: time: %f secs\n"
.LC17:
	.string	"copying result to host....."
.LC18:
	.string	"mat c"
.LC19:
	.string	"verifying result..........."
.LC20:
	.string	"error verifying result\n"
.LC21:
	.string	"done!\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2030:
	.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
	movl	%edi, %ebp
	movl	$2, %edi
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	%rsi, %rbx
	leaq	.LC8(%rip), %rsi
	subq	$104, %rsp
	.cfi_def_cfa_offset 160
	movq	%fs:40, %rax
	movq	%rax, 88(%rsp)
	xorl	%eax, %eax
	call	__printf_chk@PLT
	cmpl	$2, %ebp
	je	.L37
	movq	stderr(%rip), %rdi
	leaq	.LC9(%rip), %rdx
	movl	$2, %esi
	xorl	%eax, %eax
	jmp	.L44
.L37:
	movq	8(%rbx), %rdi
	call	atoi@PLT
	movl	$0x00000000, 20(%rsp)
	movl	%eax, %r14d
	movl	%eax, %ebx
	imull	%eax, %r14d
	movslq	%r14d, %r14
	salq	$2, %r14
	movq	%r14, %rdi
	call	_Znam@PLT
	movq	%r14, %rdi
	movq	%rax, %rbp
	call	_Znam@PLT
	movq	%r14, %rdi
	movq	%rax, %r12
	call	_Znam@PLT
	movq	%r14, %rdi
	movq	%rax, %r13
	call	_Znam@PLT
	leaq	.LC10(%rip), %rsi
	movl	$2, %edi
	movq	%rax, %r15
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	stdout(%rip), %rdi
	call	fflush@PLT
	movq	%rbp, %rsi
	movl	%ebx, %edi
	call	_Z9matrandomiPf
	movq	%r12, %rsi
	movl	%ebx, %edi
	call	_Z9matrandomiPf
	cmpl	$63, %ebx
	jg	.L38
	leaq	.LC11(%rip), %rdx
	movq	%rbp, %rsi
	movl	%ebx, %edi
	call	_Z8printmatiPfPKc
	leaq	.LC12(%rip), %rdx
	movq	%r12, %rsi
	movl	%ebx, %edi
	call	_Z8printmatiPfPKc
.L38:
	leaq	.LC13(%rip), %r14
	movl	$2, %edi
	xorl	%eax, %eax
	movq	%r14, %rsi
	call	__printf_chk@PLT
	movq	stdout(%rip), %rdi
	call	fflush@PLT
	movslq	%ebx, %rax
	leaq	24(%rsp), %rdi
	imulq	%rax, %rax
	salq	$2, %rax
	movq	%rax, %rsi
	movq	%rax, 8(%rsp)
	call	cudaMalloc@PLT
	movq	8(%rsp), %rsi
	leaq	32(%rsp), %rdi
	call	cudaMalloc@PLT
	movq	8(%rsp), %rsi
	leaq	40(%rsp), %rdi
	call	cudaMalloc@PLT
	movq	8(%rsp), %rdx
	movq	24(%rsp), %rdi
	movq	%rbp, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movq	8(%rsp), %rdx
	movq	32(%rsp), %rdi
	movq	%r12, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movq	8(%rsp), %rdx
	movq	40(%rsp), %rdi
	movq	%r13, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	leaq	.LC14(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	stdout(%rip), %rdi
	call	fflush@PLT
	leaq	48(%rsp), %rdi
	call	cudaEventCreate@PLT
	leaq	56(%rsp), %rdi
	call	cudaEventCreate@PLT
	movl	$32, %ecx
	xorl	%esi, %esi
	movabsq	$137438953504, %rax
	movq	%rax, 64(%rsp)
	leal	31(%rbx), %eax
	movq	48(%rsp), %rdi
	cltd
	movl	$1, 72(%rsp)
	idivl	%ecx
	movl	$1, 84(%rsp)
	movl	%eax, 76(%rsp)
	movl	%eax, 80(%rsp)
	call	cudaEventRecord@PLT
	movl	72(%rsp), %ecx
	movl	84(%rsp), %esi
	xorl	%r9d, %r9d
	movq	64(%rsp), %rdx
	movq	76(%rsp), %rdi
	xorl	%r8d, %r8d
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L39
	movq	40(%rsp), %rcx
	movq	32(%rsp), %rdx
	movl	%ebx, %edi
	movq	24(%rsp), %rsi
	call	_Z38__device_stub__Z13kernel_matmuliPfS_S_iPfS_S_
.L39:
	call	cudaDeviceSynchronize@PLT
	movq	56(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	56(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movq	56(%rsp), %rdx
	movq	48(%rsp), %rsi
	leaq	20(%rsp), %rdi
	call	cudaEventElapsedTime@PLT
	leaq	.LC16(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	movss	20(%rsp), %xmm0
	divss	.LC15(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	call	__printf_chk@PLT
	leaq	.LC17(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	stdout(%rip), %rdi
	call	fflush@PLT
	movq	8(%rsp), %rdx
	movq	40(%rsp), %rsi
	movq	%r13, %rdi
	movl	$2, %ecx
	call	cudaMemcpy@PLT
	movl	$2, %edi
	xorl	%eax, %eax
	movq	%r14, %rsi
	call	__printf_chk@PLT
	movq	stdout(%rip), %rdi
	call	fflush@PLT
	cmpl	$49, %ebx
	jg	.L40
	leaq	.LC18(%rip), %rdx
	movq	%r13, %rsi
	movl	%ebx, %edi
	call	_Z8printmatiPfPKc
.L40:
	leaq	.LC19(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	stdout(%rip), %rdi
	call	fflush@PLT
	movq	%r15, %r8
	movq	%r13, %rcx
	movq	%r12, %rdx
	movq	%rbp, %rsi
	movl	%ebx, %edi
	call	_Z6verifyiPfS_S_S_
	testl	%eax, %eax
	jne	.L41
	movq	stderr(%rip), %rdi
	leaq	.LC20(%rip), %rdx
	movl	$2, %esi
.L44:
	call	__fprintf_chk@PLT
	movl	$1, %edi
.L45:
	call	exit@PLT
.L41:
	movq	%r14, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	$2, %edi
	leaq	.LC21(%rip), %rsi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	xorl	%edi, %edi
	jmp	.L45
	.cfi_endproc
.LFE2030:
	.size	main, .-main
	.text
	.globl	_Z40__device_stub__Z15kernel_matmulsmiPfS_S_iPfS_S_
	.type	_Z40__device_stub__Z15kernel_matmulsmiPfS_S_iPfS_S_, @function
_Z40__device_stub__Z15kernel_matmulsmiPfS_S_iPfS_S_:
.LFB2057:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movl	%edi, 28(%rsp)
	leaq	56(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	68(%rsp), %rsi
	movq	%rdx, 8(%rsp)
	leaq	40(%rsp), %rdx
	movq	%rcx, (%rsp)
	leaq	48(%rsp), %rcx
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	28(%rsp), %rax
	movl	$1, 64(%rsp)
	movq	%rax, 104(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 120(%rsp)
	movq	%rsp, %rax
	movq	%rax, 128(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 56(%rsp)
	movq	%rax, 68(%rsp)
	movl	$1, 76(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L46
	pushq	48(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z15kernel_matmulsmiPfS_S_(%rip), %rdi
	pushq	48(%rsp)
	.cfi_def_cfa_offset 176
	movq	84(%rsp), %rcx
	movl	92(%rsp), %r8d
	movq	72(%rsp), %rsi
	movl	80(%rsp), %edx
	leaq	120(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 168
	popq	%rdx
	.cfi_def_cfa_offset 160
.L46:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L48
	call	__stack_chk_fail@PLT
.L48:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2057:
	.size	_Z40__device_stub__Z15kernel_matmulsmiPfS_S_iPfS_S_, .-_Z40__device_stub__Z15kernel_matmulsmiPfS_S_iPfS_S_
	.globl	_Z15kernel_matmulsmiPfS_S_
	.type	_Z15kernel_matmulsmiPfS_S_, @function
_Z15kernel_matmulsmiPfS_S_:
.LFB2058:
	.cfi_startproc
	endbr64
	jmp	_Z40__device_stub__Z15kernel_matmulsmiPfS_S_iPfS_S_
	.cfi_endproc
.LFE2058:
	.size	_Z15kernel_matmulsmiPfS_S_, .-_Z15kernel_matmulsmiPfS_S_
	.section	.rodata.str1.1
.LC22:
	.string	"_Z15kernel_matmulsmiPfS_S_"
.LC23:
	.string	"_Z13kernel_matmuliPfS_S_"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2060:
	.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	.LC22(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z15kernel_matmulsmiPfS_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	.LC23(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z13kernel_matmuliPfS_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
.LFE2060:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.section	.rodata.cst4,"aM",@progbits,4
	.align 4
.LC0:
	.long	805306368
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC5:
	.long	2147483647
	.long	0
	.long	0
	.long	0
	.section	.rodata.cst4
	.align 4
.LC6:
	.long	1008981770
	.align 4
.LC15:
	.long	1148846080
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

#include <hip/hip_runtime.h>
#include <cstdio>
#include <cstdlib>
#define BSIZE2D 32

// EJERCICIOS
// (1) Implemente el matmul de GPU basico
// (2) Implemente el matmul de GPU usando memoria compartida
// (3) Compare el rendimiento de GPU Matmul vs el de CPU que hizo previamente

// GPU matmul basico
__global__ void kernel_matmul(int n, float *a, float *b, float *c){
}

// GPU matmul shared memory 
__global__ void kernel_matmulsm(int n, float *a, float *b, float *c){
}

void matrandom(int n, float *m){
    srand(1);
    for(int i=0; i<n; ++i){
        for(int j=0; j<n; ++j){
            m[i*n + j] = (float)rand()/((float)RAND_MAX);
            //m[i*n + j] = i;
        }
    }
}

void printmat(int n, float *m, const char* msg){
    printf("%s\n", msg);
    for(int i=0; i<n; ++i){
        for(int j=0; j<n; ++j){
            printf("%.2f ", m[i*n + j]);
        }
        printf("\n");
    }
}

int verify(int n, float *a, float *b, float *c, float *cgold){
    float error = 0.01f;
    for(int i=0; i<n; ++i){
        for(int j=0; j<n; ++j){
            float sum = 0.0f;
            for(int k=0; k<n; ++k){
                sum += a[i*n + k]*b[k*n + j];
            }
            cgold[i*n + j] = sum;
            if(fabs(c[i*n + j] - cgold[i*n + j]) >= error){
                fprintf(stderr, "error: c[%i][%i] ---> c %f    cgold %f\n", i, j, c[i*n+j], cgold[i*n+j]);
                return 0;
            }
        }
    }
    return 1;
}

int main(int argc, char **argv){
    printf("GPU MATMUL\n");
    if(argc != 2){
        fprintf(stderr, "run as ./prog n\n");
        exit(EXIT_FAILURE);
    }
    int n = atoi(argv[1]);
    float msecs = 0.0f;

    // (1) creando matrices en host
    float *a = new float[n*n];
    float *b = new float[n*n];
    float *c = new float[n*n];
    float *cgold = new float[n*n];
    printf("initializing A and B......."); fflush(stdout);
    matrandom(n, a);
    matrandom(n, b);
    if(n < 64){
        printmat(n, a, "mat a");
        printmat(n, b, "mat b");
    }
    printf("ok\n"); fflush(stdout);

    // (2) dejando matrices en device
    float *ad, *bd, *cd;
    hipMalloc(&ad, sizeof(float)*n*n);
    hipMalloc(&bd, sizeof(float)*n*n);
    hipMalloc(&cd, sizeof(float)*n*n);
    hipMemcpy(ad, a, sizeof(float)*n*n, hipMemcpyHostToDevice);
    hipMemcpy(bd, b, sizeof(float)*n*n, hipMemcpyHostToDevice);
    hipMemcpy(cd, c, sizeof(float)*n*n, hipMemcpyHostToDevice);

    // (3) ejecutar matmul en GPU
    printf("computing C = A x B........"); fflush(stdout);
        hipEvent_t start, stop;
        hipEventCreate(&start);
        hipEventCreate(&stop);
        dim3 block(BSIZE2D, BSIZE2D, 1);
        dim3 grid((n+BSIZE2D-1)/BSIZE2D, (n+BSIZE2D-1)/BSIZE2D, 1); 
        hipEventRecord(start);
        kernel_matmul<<<grid, block>>>(n, ad, bd, cd);
        //kernel_matmulsm<<<grid, block>>>(n, ad, bd, cd);
        hipDeviceSynchronize();
        hipEventRecord(stop);
        hipEventSynchronize(stop);
        hipEventElapsedTime(&msecs, start, stop);
    printf("ok: time: %f secs\n", msecs/1000.0f);

    // (4) copiar resultado a host
    printf("copying result to host....."); fflush(stdout);
    hipMemcpy(c, cd, sizeof(float)*n*n, hipMemcpyDeviceToHost);
    printf("ok\n"); fflush(stdout);

    if(n < 50){
        printmat(n, c, "mat c");
    }

    // (5) verificar resultado contra calculo en CPU
    printf("verifying result..........."); fflush(stdout);
    if(!verify(n, a, b, c, cgold)){
        fprintf(stderr, "error verifying result\n");
        exit(EXIT_FAILURE);
    }
    printf("ok\n");
    printf("done!\n");
    exit(EXIT_SUCCESS);
}
    

	.text
	.file	"main.hip"
	.globl	_Z28__device_stub__kernel_matmuliPfS_S_ # -- Begin function _Z28__device_stub__kernel_matmuliPfS_S_
	.type	_Z28__device_stub__kernel_matmuliPfS_S_,@function
_Z28__device_stub__kernel_matmuliPfS_S_: # @_Z28__device_stub__kernel_matmuliPfS_S_
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$112, %rsp
	.cfi_def_cfa_offset 160
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	4(%rsp), %rax
	movl	%edi, (%rax)
	leaq	40(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	32(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	24(%rsp), %rdx
	movq	%rcx, (%rdx)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	16(%rsp), %r12
	leaq	8(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z13kernel_matmuliPfS_S_, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$128, %rsp
	.cfi_adjust_cfa_offset -128
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	_Z28__device_stub__kernel_matmuliPfS_S_, .Lfunc_end0-_Z28__device_stub__kernel_matmuliPfS_S_
	.cfi_endproc
                                        # -- End function
	.globl	_Z30__device_stub__kernel_matmulsmiPfS_S_ # -- Begin function _Z30__device_stub__kernel_matmulsmiPfS_S_
	.type	_Z30__device_stub__kernel_matmulsmiPfS_S_,@function
_Z30__device_stub__kernel_matmulsmiPfS_S_: # @_Z30__device_stub__kernel_matmulsmiPfS_S_
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$112, %rsp
	.cfi_def_cfa_offset 160
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	4(%rsp), %rax
	movl	%edi, (%rax)
	leaq	40(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	32(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	24(%rsp), %rdx
	movq	%rcx, (%rdx)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	16(%rsp), %r12
	leaq	8(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z15kernel_matmulsmiPfS_S_, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$128, %rsp
	.cfi_adjust_cfa_offset -128
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end1:
	.size	_Z30__device_stub__kernel_matmulsmiPfS_S_, .Lfunc_end1-_Z30__device_stub__kernel_matmulsmiPfS_S_
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function _Z9matrandomiPf
.LCPI2_0:
	.long	0x30000000                      # float 4.65661287E-10
	.text
	.globl	_Z9matrandomiPf
	.type	_Z9matrandomiPf,@function
_Z9matrandomiPf:                        # @_Z9matrandomiPf
	.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
	movq	%rsi, (%rsp)                    # 8-byte Spill
	movl	%edi, %ebp
	movl	$1, %edi
	callq	srand
	testl	%ebp, %ebp
	jle	.LBB2_5
# %bb.1:                                # %.preheader.lr.ph
	movl	%ebp, %r14d
	xorl	%r15d, %r15d
	xorl	%r12d, %r12d
.LBB2_2:                                # %.lr.ph
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB2_3 Depth 2
	movl	%r15d, %eax
	movq	(%rsp), %rcx                    # 8-byte Reload
	leaq	(%rcx,%rax,4), %r13
	xorl	%ebx, %ebx
.LBB2_3:                                #   Parent Loop BB2_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	callq	rand
	movss	.LCPI2_0(%rip), %xmm1           # xmm1 = mem[0],zero,zero,zero
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	mulss	%xmm1, %xmm0
	movss	%xmm0, (%r13,%rbx,4)
	incq	%rbx
	cmpq	%rbx, %r14
	jne	.LBB2_3
# %bb.4:                                # %._crit_edge
                                        #   in Loop: Header=BB2_2 Depth=1
	incq	%r12
	addl	%ebp, %r15d
	cmpq	%r14, %r12
	jne	.LBB2_2
.LBB2_5:                                # %._crit_edge13
	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_end2:
	.size	_Z9matrandomiPf, .Lfunc_end2-_Z9matrandomiPf
	.cfi_endproc
                                        # -- End function
	.globl	_Z8printmatiPfPKc               # -- Begin function _Z8printmatiPfPKc
	.type	_Z8printmatiPfPKc,@function
_Z8printmatiPfPKc:                      # @_Z8printmatiPfPKc
	.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
	movq	%rsi, (%rsp)                    # 8-byte Spill
	movl	%edi, %ebp
	movq	%rdx, %rdi
	callq	puts@PLT
	testl	%ebp, %ebp
	jle	.LBB3_5
# %bb.1:                                # %.preheader.lr.ph
	movl	%ebp, %r14d
	xorl	%r15d, %r15d
	xorl	%r12d, %r12d
.LBB3_2:                                # %.lr.ph
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB3_3 Depth 2
	movl	%r15d, %eax
	movq	(%rsp), %rcx                    # 8-byte Reload
	leaq	(%rcx,%rax,4), %r13
	xorl	%ebx, %ebx
.LBB3_3:                                #   Parent Loop BB3_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	xorps	%xmm0, %xmm0
	cvtss2sd	(%r13,%rbx,4), %xmm0
	movl	$.L.str.1, %edi
	movb	$1, %al
	callq	printf
	incq	%rbx
	cmpq	%rbx, %r14
	jne	.LBB3_3
# %bb.4:                                # %._crit_edge
                                        #   in Loop: Header=BB3_2 Depth=1
	movl	$10, %edi
	callq	putchar@PLT
	incq	%r12
	addl	%ebp, %r15d
	cmpq	%r14, %r12
	jne	.LBB3_2
.LBB3_5:                                # %._crit_edge14
	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	_Z8printmatiPfPKc, .Lfunc_end3-_Z8printmatiPfPKc
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0                          # -- Begin function _Z6verifyiPfS_S_S_
.LCPI4_0:
	.long	0x7fffffff                      # float NaN
	.long	0x7fffffff                      # float NaN
	.long	0x7fffffff                      # float NaN
	.long	0x7fffffff                      # float NaN
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0
.LCPI4_1:
	.long	0x3c23d70a                      # float 0.00999999977
	.text
	.globl	_Z6verifyiPfS_S_S_
	.type	_Z6verifyiPfS_S_S_,@function
_Z6verifyiPfS_S_S_:                     # @_Z6verifyiPfS_S_S_
	.cfi_startproc
# %bb.0:
	testl	%edi, %edi
	jle	.LBB4_1
# %bb.3:                                # %.preheader58.lr.ph
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	pushq	%rax
	.cfi_def_cfa_offset 64
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	%edi, %r10d
	leaq	(,%r10,4), %r11
	xorl	%r14d, %r14d
	movaps	.LCPI4_0(%rip), %xmm0           # xmm0 = [NaN,NaN,NaN,NaN]
	movss	.LCPI4_1(%rip), %xmm1           # xmm1 = mem[0],zero,zero,zero
	xorl	%eax, %eax
	xorl	%r9d, %r9d
.LBB4_4:                                # %.preheader.lr.ph
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB4_5 Depth 2
                                        #       Child Loop BB4_6 Depth 3
	movq	%r9, (%rsp)                     # 8-byte Spill
	movl	%r14d, %r9d
	leaq	(%rsi,%r9,4), %r15
	movq	%rax, %r12
	imulq	%r10, %r12
	movq	%rdx, %r13
	xorl	%r9d, %r9d
.LBB4_5:                                # %.preheader
                                        #   Parent Loop BB4_4 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB4_6 Depth 3
	xorps	%xmm2, %xmm2
	movq	%r13, %rbp
	xorl	%ebx, %ebx
.LBB4_6:                                #   Parent Loop BB4_4 Depth=1
                                        #     Parent Loop BB4_5 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	movss	(%r15,%rbx,4), %xmm3            # xmm3 = mem[0],zero,zero,zero
	mulss	(%rbp), %xmm3
	addss	%xmm3, %xmm2
	incq	%rbx
	addq	%r11, %rbp
	cmpq	%rbx, %r10
	jne	.LBB4_6
# %bb.7:                                # %._crit_edge
                                        #   in Loop: Header=BB4_5 Depth=2
	leaq	(%r9,%r12), %rbx
	movss	%xmm2, (%r8,%rbx,4)
	movss	(%rcx,%rbx,4), %xmm3            # xmm3 = mem[0],zero,zero,zero
	movaps	%xmm3, %xmm4
	subss	%xmm2, %xmm4
	andps	%xmm0, %xmm4
	ucomiss	%xmm1, %xmm4
	jae	.LBB4_8
# %bb.9:                                # %.critedge
                                        #   in Loop: Header=BB4_5 Depth=2
	incq	%r9
	addq	$4, %r13
	cmpq	%r10, %r9
	jne	.LBB4_5
# %bb.10:                               # %.critedge57
                                        #   in Loop: Header=BB4_4 Depth=1
	incq	%rax
	cmpq	%r10, %rax
	setae	%r9b
	addl	%edi, %r14d
	cmpq	%r10, %rax
	jne	.LBB4_4
	jmp	.LBB4_11
.LBB4_8:                                # %._crit_edge70
	movq	stderr(%rip), %rdi
	xorps	%xmm0, %xmm0
	cvtss2sd	%xmm3, %xmm0
	xorps	%xmm1, %xmm1
	cvtss2sd	%xmm2, %xmm1
	movl	$.L.str.3, %esi
	movl	%eax, %edx
	movl	%r9d, %ecx
	movb	$2, %al
	callq	fprintf
	movq	(%rsp), %r9                     # 8-byte Reload
.LBB4_11:
	addq	$8, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	.cfi_restore %rbx
	.cfi_restore %r12
	.cfi_restore %r13
	.cfi_restore %r14
	.cfi_restore %r15
	.cfi_restore %rbp
	jmp	.LBB4_2
.LBB4_1:
	movb	$1, %r9b
.LBB4_2:                                # %._crit_edge68
	movzbl	%r9b, %eax
	andl	$1, %eax
	retq
.Lfunc_end4:
	.size	_Z6verifyiPfS_S_S_, .Lfunc_end4-_Z6verifyiPfS_S_S_
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function main
.LCPI5_0:
	.long	0x447a0000                      # float 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	$72, %rsp
	.cfi_def_cfa_offset 128
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rsi, %rbx
	movl	%edi, %ebp
	movl	$.Lstr, %edi
	callq	puts@PLT
	cmpl	$2, %ebp
	jne	.LBB5_1
# %bb.3:
	movq	8(%rbx), %rdi
	callq	atoi
	movl	%eax, %ebx
	movl	$0, 28(%rsp)
	movl	%eax, %r13d
	imull	%r13d, %r13d
	shlq	$2, %r13
	movq	%r13, %rdi
	callq	_Znam
	movq	%rax, %r14
	movq	%r13, %rdi
	callq	_Znam
	movq	%rax, %r15
	movq	%r13, %rdi
	callq	_Znam
	movq	%rax, 32(%rsp)                  # 8-byte Spill
	movq	%r13, %rdi
	callq	_Znam
	movq	%rax, 40(%rsp)                  # 8-byte Spill
	movl	$.L.str.6, %edi
	xorl	%eax, %eax
	callq	printf
	movq	stdout(%rip), %rdi
	callq	fflush
	movl	%ebx, %edi
	movq	%r14, %rsi
	callq	_Z9matrandomiPf
	movl	%ebx, %edi
	movq	%r15, %rsi
	callq	_Z9matrandomiPf
	cmpl	$63, %ebx
	jg	.LBB5_5
# %bb.4:
	movl	$.L.str.7, %edx
	movl	%ebx, %edi
	movq	%r14, %rsi
	callq	_Z8printmatiPfPKc
	movl	$.L.str.8, %edx
	movl	%ebx, %edi
	movq	%r15, %rsi
	callq	_Z8printmatiPfPKc
.LBB5_5:
	movl	$.Lstr.3, %edi
	callq	puts@PLT
	movq	stdout(%rip), %rdi
	callq	fflush
	movslq	%ebx, %rbp
	imulq	%rbp, %rbp
	shlq	$2, %rbp
	leaq	64(%rsp), %r13
	movq	%r13, %rdi
	movq	%rbp, %rsi
	callq	hipMalloc
	leaq	56(%rsp), %r12
	movq	%r12, %rdi
	movq	%rbp, %rsi
	callq	hipMalloc
	leaq	16(%rsp), %rdi
	movq	%rbp, %rsi
	callq	hipMalloc
	movq	(%r13), %rdi
	movq	%r14, %r13
	movq	%r14, %rsi
	movq	%rbp, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	(%r12), %rdi
	movq	%r15, %r12
	movq	%r15, %rsi
	movq	%rbp, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	leaq	16(%rsp), %rax
	movq	(%rax), %rdi
	movq	32(%rsp), %rsi                  # 8-byte Reload
	movq	%rbp, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movl	$.L.str.10, %edi
	xorl	%eax, %eax
	callq	printf
	movq	stdout(%rip), %rdi
	callq	fflush
	leaq	48(%rsp), %r14
	movq	%r14, %rdi
	callq	hipEventCreate
	leaq	8(%rsp), %rdi
	callq	hipEventCreate
	leal	31(%rbx), %eax
	leal	62(%rbx), %ecx
	testl	%eax, %eax
	cmovnsl	%eax, %ecx
	sarl	$5, %ecx
	movq	%rcx, %r15
	shlq	$32, %r15
	orq	%rcx, %r15
	movq	(%r14), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movabsq	$137438953504, %rdx             # imm = 0x2000000020
	movq	%r15, %rdi
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB5_7
# %bb.6:
	movq	64(%rsp), %rsi
	movq	56(%rsp), %rdx
	movq	16(%rsp), %rcx
	movl	%ebx, %edi
	callq	_Z28__device_stub__kernel_matmuliPfS_S_
.LBB5_7:
	callq	hipDeviceSynchronize
	movq	8(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	8(%rsp), %rdi
	callq	hipEventSynchronize
	movq	48(%rsp), %rsi
	movq	8(%rsp), %rdx
	leaq	28(%rsp), %r14
	movq	%r14, %rdi
	callq	hipEventElapsedTime
	movss	(%r14), %xmm0                   # xmm0 = mem[0],zero,zero,zero
	divss	.LCPI5_0(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	movl	$.L.str.11, %edi
	movb	$1, %al
	callq	printf
	movl	$.L.str.12, %edi
	xorl	%eax, %eax
	callq	printf
	movq	stdout(%rip), %rdi
	callq	fflush
	movq	16(%rsp), %rsi
	movq	32(%rsp), %r14                  # 8-byte Reload
	movq	%r14, %rdi
	movq	%rbp, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	movl	$.Lstr.3, %edi
	callq	puts@PLT
	movq	stdout(%rip), %rdi
	callq	fflush
	cmpl	$49, %ebx
	jg	.LBB5_9
# %bb.8:
	movl	$.L.str.13, %edx
	movl	%ebx, %edi
	movq	%r14, %rsi
	callq	_Z8printmatiPfPKc
.LBB5_9:
	movl	$.L.str.14, %edi
	xorl	%eax, %eax
	callq	printf
	movq	stdout(%rip), %rdi
	callq	fflush
	movl	%ebx, %edi
	movq	%r13, %rsi
	movq	%r12, %rdx
	movq	%r14, %rcx
	movq	40(%rsp), %r8                   # 8-byte Reload
	callq	_Z6verifyiPfS_S_S_
	testl	%eax, %eax
	jne	.LBB5_11
# %bb.10:
	movq	stderr(%rip), %rcx
	movl	$.L.str.15, %edi
	movl	$23, %esi
	jmp	.LBB5_2
.LBB5_1:
	movq	stderr(%rip), %rcx
	movl	$.L.str.5, %edi
	movl	$16, %esi
.LBB5_2:
	movl	$1, %edx
	callq	fwrite@PLT
	movl	$1, %edi
	callq	exit
.LBB5_11:
	movl	$.Lstr.3, %edi
	callq	puts@PLT
	movl	$.Lstr.4, %edi
	callq	puts@PLT
	xorl	%edi, %edi
	callq	exit
.Lfunc_end5:
	.size	main, .Lfunc_end5-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	.LBB6_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB6_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z13kernel_matmuliPfS_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	$_Z15kernel_matmulsmiPfS_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_end6:
	.size	__hip_module_ctor, .Lfunc_end6-__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	.LBB7_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
.LBB7_2:
	retq
.Lfunc_end7:
	.size	__hip_module_dtor, .Lfunc_end7-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	_Z13kernel_matmuliPfS_S_,@object # @_Z13kernel_matmuliPfS_S_
	.section	.rodata,"a",@progbits
	.globl	_Z13kernel_matmuliPfS_S_
	.p2align	3, 0x0
_Z13kernel_matmuliPfS_S_:
	.quad	_Z28__device_stub__kernel_matmuliPfS_S_
	.size	_Z13kernel_matmuliPfS_S_, 8

	.type	_Z15kernel_matmulsmiPfS_S_,@object # @_Z15kernel_matmulsmiPfS_S_
	.globl	_Z15kernel_matmulsmiPfS_S_
	.p2align	3, 0x0
_Z15kernel_matmulsmiPfS_S_:
	.quad	_Z30__device_stub__kernel_matmulsmiPfS_S_
	.size	_Z15kernel_matmulsmiPfS_S_, 8

	.type	.L.str.1,@object                # @.str.1
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.1:
	.asciz	"%.2f "
	.size	.L.str.1, 6

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"error: c[%i][%i] ---> c %f    cgold %f\n"
	.size	.L.str.3, 40

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"run as ./prog n\n"
	.size	.L.str.5, 17

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"initializing A and B......."
	.size	.L.str.6, 28

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"mat a"
	.size	.L.str.7, 6

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"mat b"
	.size	.L.str.8, 6

	.type	.L.str.10,@object               # @.str.10
.L.str.10:
	.asciz	"computing C = A x B........"
	.size	.L.str.10, 28

	.type	.L.str.11,@object               # @.str.11
.L.str.11:
	.asciz	"ok: time: %f secs\n"
	.size	.L.str.11, 19

	.type	.L.str.12,@object               # @.str.12
.L.str.12:
	.asciz	"copying result to host....."
	.size	.L.str.12, 28

	.type	.L.str.13,@object               # @.str.13
.L.str.13:
	.asciz	"mat c"
	.size	.L.str.13, 6

	.type	.L.str.14,@object               # @.str.14
.L.str.14:
	.asciz	"verifying result..........."
	.size	.L.str.14, 28

	.type	.L.str.15,@object               # @.str.15
.L.str.15:
	.asciz	"error verifying result\n"
	.size	.L.str.15, 24

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z13kernel_matmuliPfS_S_"
	.size	.L__unnamed_1, 25

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_Z15kernel_matmulsmiPfS_S_"
	.size	.L__unnamed_2, 27

	.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	"GPU MATMUL"
	.size	.Lstr, 11

	.type	.Lstr.3,@object                 # @str.3
.Lstr.3:
	.asciz	"ok"
	.size	.Lstr.3, 3

	.type	.Lstr.4,@object                 # @str.4
.Lstr.4:
	.asciz	"done!"
	.size	.Lstr.4, 6

	.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 _Z28__device_stub__kernel_matmuliPfS_S_
	.addrsig_sym _Z30__device_stub__kernel_matmulsmiPfS_S_
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z13kernel_matmuliPfS_S_
	.addrsig_sym _Z15kernel_matmulsmiPfS_S_
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z13kernel_matmuliPfS_S_ ; -- Begin function _Z13kernel_matmuliPfS_S_
	.globl	_Z13kernel_matmuliPfS_S_
	.p2align	8
	.type	_Z13kernel_matmuliPfS_S_,@function
_Z13kernel_matmuliPfS_S_:               ; @_Z13kernel_matmuliPfS_S_
; %bb.0:
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z13kernel_matmuliPfS_S_
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 32
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 1
		.amdhsa_next_free_sgpr 1
		.amdhsa_reserve_vcc 0
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end0:
	.size	_Z13kernel_matmuliPfS_S_, .Lfunc_end0-_Z13kernel_matmuliPfS_S_
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 4
; NumSgprs: 0
; NumVgprs: 0
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 0
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 1
; NumVGPRsForWavesPerEU: 1
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.protected	_Z15kernel_matmulsmiPfS_S_ ; -- Begin function _Z15kernel_matmulsmiPfS_S_
	.globl	_Z15kernel_matmulsmiPfS_S_
	.p2align	8
	.type	_Z15kernel_matmulsmiPfS_S_,@function
_Z15kernel_matmulsmiPfS_S_:             ; @_Z15kernel_matmulsmiPfS_S_
; %bb.0:
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z15kernel_matmulsmiPfS_S_
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 32
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 1
		.amdhsa_next_free_sgpr 1
		.amdhsa_reserve_vcc 0
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end1:
	.size	_Z15kernel_matmulsmiPfS_S_, .Lfunc_end1-_Z15kernel_matmulsmiPfS_S_
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 4
; NumSgprs: 0
; NumVgprs: 0
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 0
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 1
; NumVGPRsForWavesPerEU: 1
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.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:           4
        .value_kind:     by_value
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         16
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         24
        .size:           8
        .value_kind:     global_buffer
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 32
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z13kernel_matmuliPfS_S_
    .private_segment_fixed_size: 0
    .sgpr_count:     0
    .sgpr_spill_count: 0
    .symbol:         _Z13kernel_matmuliPfS_S_.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     0
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
  - .args:
      - .offset:         0
        .size:           4
        .value_kind:     by_value
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         16
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         24
        .size:           8
        .value_kind:     global_buffer
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 32
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z15kernel_matmulsmiPfS_S_
    .private_segment_fixed_size: 0
    .sgpr_count:     0
    .sgpr_spill_count: 0
    .symbol:         _Z15kernel_matmulsmiPfS_S_.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     0
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
