#include <cstdio>
#include <cstdlib>
#include <cuda.h>
#include <chrono>

using namespace std;

__global__ void matrix_product_kernel(float *P, float *M, float *N,
                                      size_t width) {
  int i = blockIdx.x * 32 + threadIdx.x,
      j = blockIdx.y * 32 + threadIdx.y;
  float acc = 0;
  for (int k = 0; k < width; ++k)
    acc += M[i*width+k] * N[k*width+j];
  P[i*width+j] = acc;
}

void matrix_product_serial(float *P, float *M, float *N, size_t width) {
#pragma omp parallel for
  for (size_t i = 0; i < width; ++i)
    for (size_t j = 0; j < width; ++j) {
      float acc = 0;
      for (size_t k = 0; k < width; ++k)
        acc += M[i*width+k] * N[k*width+j];
      P[i*width+j] = acc;
    }
}

void matrix_product(float *P, float *M, float *N, size_t width) {
  float *Pd, *Md, *Nd;
  size_t dsize = width * width * sizeof(float);
  cudaMalloc((void **)&Md, dsize);
  cudaMemcpy(Md, M, dsize, cudaMemcpyHostToDevice);
  cudaMalloc((void **)&Nd, dsize);
  cudaMemcpy(Nd, N, dsize, cudaMemcpyHostToDevice);
  cudaMalloc((void **)&Pd, dsize);

  dim3 dim_block(32, 32), dim_grid(width / 32, width / 32);
  matrix_product_kernel<<<dim_grid, dim_block>>>(Pd, Md, Nd, width);

  cudaMemcpy(P, Pd, dsize, cudaMemcpyDeviceToHost);

  cudaFree(Pd);
  cudaFree(Md);
  cudaFree(Nd);
}

void print(float *M, size_t width) {
  for (size_t i = 0; i < width; ++i) {
    for (size_t j = 0; j < width; ++j)
      printf("%.2f ", M[i*width+j]);
    puts("");
  }
}

int main(int argc, char *argv[]) {
  size_t width;

#ifdef NOIO
  width = 1024;
#else
  scanf("%ld", &width);
#endif

  float *M = new float[width*width],
        *N = new float[width*width],
        *P = new float[width*width];
  for (int i = 0; i < width * width; ++i) {
    M[i] = ((float)rand() / RAND_MAX - 0.5) * 2;
    N[i] = ((float)rand() / RAND_MAX - 0.5) * 2;
  }

  chrono::time_point<chrono::system_clock> start, end;
  int ms;

  start = chrono::system_clock::now();
  matrix_product(P, M, N, width);
  end = chrono::system_clock::now();
  ms = chrono::duration_cast<chrono::milliseconds>(end-start).count();
  printf("GPU: %d\n", ms);

#ifndef NOIO
  print(M, width);
  puts("-------");
  print(N, width);
  puts("-------");
  print(P, width);
#endif

  start = chrono::system_clock::now();
  matrix_product_serial(P, M, N, width);
  end = chrono::system_clock::now();
  ms = chrono::duration_cast<chrono::milliseconds>(end-start).count();
  printf("CPU: %d\n", ms);

#ifndef NOIO
  print(M, width);
  puts("-------");
  print(N, width);
  puts("-------");
  print(P, width);
#endif

  delete[] M;
  delete[] N;
  delete[] P;
  return 0;
}


	.file	"tmpxft_0035026f_00000000-6_matrix.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2138:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2138:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z21matrix_product_serialPfS_S_m
	.type	_Z21matrix_product_serialPfS_S_m, @function
_Z21matrix_product_serialPfS_S_m:
.LFB2126:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	movq	%rsi, %r8
	movq	%rdx, %r11
	xorl	%r9d, %r9d
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	xorl	%r10d, %r10d
	leaq	0(,%rcx,4), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
.L3:
	cmpq	%rcx, %r10
	je	.L2
	leaq	0(,%r9,4), %rax
	leaq	(%r8,%rax), %rbp
	leaq	(%rdi,%rax), %rsi
	xorl	%eax, %eax
.L7:
	leaq	(%r11,%rax,4), %rbx
	xorl	%edx, %edx
	xorps	%xmm0, %xmm0
.L4:
	movss	0(%rbp,%rdx,4), %xmm1
	mulss	(%rbx), %xmm1
	movq	%rdx, %r13
	incq	%rdx
	addq	%r12, %rbx
	addss	%xmm1, %xmm0
	cmpq	%rdx, %rcx
	jne	.L4
	movss	%xmm0, (%rsi,%rax,4)
	leaq	1(%rax), %rdx
	cmpq	%r13, %rax
	je	.L5
	movq	%rdx, %rax
	jmp	.L7
.L5:
	incq	%r10
	addq	%rcx, %r9
	jmp	.L3
.L2:
	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
.LFE2126:
	.size	_Z21matrix_product_serialPfS_S_m, .-_Z21matrix_product_serialPfS_S_m
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC1:
	.string	"%.2f "
.LC2:
	.string	""
	.text
	.globl	_Z5printPfm
	.type	_Z5printPfm, @function
_Z5printPfm:
.LFB2128:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movq	%rdi, %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	xorl	%r13d, %r13d
	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
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	%rsi, %rbx
	pushq	%rdx
	.cfi_def_cfa_offset 64
.L12:
	cmpq	%rbx, %r12
	je	.L17
	leaq	(%r14,%r13,4), %r15
	xorl	%ebp, %ebp
.L13:
	cvtss2sd	(%r15,%rbp,4), %xmm0
	leaq	.LC1(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	call	__printf_chk@PLT
	incq	%rbp
	cmpq	%rbp, %rbx
	jne	.L13
	leaq	.LC2(%rip), %rdi
	incq	%r12
	addq	%rbx, %r13
	call	puts@PLT
	jmp	.L12
.L17:
	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
.LFE2128:
	.size	_Z5printPfm, .-_Z5printPfm
	.globl	_Z46__device_stub__Z21matrix_product_kernelPfS_S_mPfS_S_m
	.type	_Z46__device_stub__Z21matrix_product_kernelPfS_S_mPfS_S_m, @function
_Z46__device_stub__Z21matrix_product_kernelPfS_S_mPfS_S_m:
.LFB2160:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movq	%rdi, 24(%rsp)
	leaq	56(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	68(%rsp), %rsi
	movq	%rdx, 8(%rsp)
	leaq	40(%rsp), %rdx
	movq	%rcx, (%rsp)
	leaq	48(%rsp), %rcx
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 64(%rsp)
	movq	%rax, 104(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 120(%rsp)
	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	.L18
	pushq	48(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z21matrix_product_kernelPfS_S_m(%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
.L18:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L20
	call	__stack_chk_fail@PLT
.L20:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2160:
	.size	_Z46__device_stub__Z21matrix_product_kernelPfS_S_mPfS_S_m, .-_Z46__device_stub__Z21matrix_product_kernelPfS_S_mPfS_S_m
	.globl	_Z21matrix_product_kernelPfS_S_m
	.type	_Z21matrix_product_kernelPfS_S_m, @function
_Z21matrix_product_kernelPfS_S_m:
.LFB2161:
	.cfi_startproc
	endbr64
	jmp	_Z46__device_stub__Z21matrix_product_kernelPfS_S_mPfS_S_m
	.cfi_endproc
.LFE2161:
	.size	_Z21matrix_product_kernelPfS_S_m, .-_Z21matrix_product_kernelPfS_S_m
	.globl	_Z14matrix_productPfS_S_m
	.type	_Z14matrix_productPfS_S_m, @function
_Z14matrix_productPfS_S_m:
.LFB2127:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	movq	%rsi, %r14
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	movq	%rdx, %r13
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	movq	%rdi, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	movq	%rcx, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	movq	%rcx, %rbx
	imulq	%rcx, %rbx
	subq	$64, %rsp
	.cfi_def_cfa_offset 112
	movq	%fs:40, %rax
	movq	%rax, 56(%rsp)
	xorl	%eax, %eax
	salq	$2, %rbx
	leaq	16(%rsp), %rdi
	movq	%rbx, %rsi
	call	cudaMalloc@PLT
	movq	16(%rsp), %rdi
	movq	%rbx, %rdx
	movq	%r14, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	leaq	24(%rsp), %rdi
	movq	%rbx, %rsi
	call	cudaMalloc@PLT
	movq	24(%rsp), %rdi
	movq	%rbx, %rdx
	movq	%r13, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	leaq	8(%rsp), %rdi
	movq	%rbx, %rsi
	call	cudaMalloc@PLT
	movq	%rbp, %rax
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	shrq	$5, %rax
	movl	$1, %ecx
	movl	$1, %esi
	movabsq	$137438953504, %rdx
	movl	%eax, 44(%rsp)
	movl	%eax, 48(%rsp)
	movq	44(%rsp), %rdi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L24
	movq	24(%rsp), %rdx
	movq	16(%rsp), %rsi
	movq	%rbp, %rcx
	movq	8(%rsp), %rdi
	call	_Z46__device_stub__Z21matrix_product_kernelPfS_S_mPfS_S_m
.L24:
	movq	8(%rsp), %rsi
	movl	$2, %ecx
	movq	%rbx, %rdx
	movq	%r12, %rdi
	call	cudaMemcpy@PLT
	movq	8(%rsp), %rdi
	call	cudaFree@PLT
	movq	16(%rsp), %rdi
	call	cudaFree@PLT
	movq	24(%rsp), %rdi
	call	cudaFree@PLT
	movq	56(%rsp), %rax
	subq	%fs:40, %rax
	je	.L25
	call	__stack_chk_fail@PLT
.L25:
	addq	$64, %rsp
	.cfi_def_cfa_offset 48
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2127:
	.size	_Z14matrix_productPfS_S_m, .-_Z14matrix_productPfS_S_m
	.section	.rodata.str1.1
.LC3:
	.string	"%ld"
.LC6:
	.string	"GPU: %d\n"
.LC7:
	.string	"-------"
.LC8:
	.string	"CPU: %d\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2129:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	.LC3(%rip), %rdi
	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
	movabsq	$2305843009213693950, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rsi
	call	__isoc23_scanf@PLT
	movq	(%rsp), %rdi
	imulq	%rdi, %rdi
	cmpq	%rdi, %r12
	jb	.L28
	salq	$2, %rdi
	call	_Znam@PLT
	movq	(%rsp), %rdi
	movq	%rax, %rbp
	imulq	%rdi, %rdi
	cmpq	%rdi, %r12
	jnb	.L29
.L28:
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L35
	call	__cxa_throw_bad_array_new_length@PLT
.L29:
	salq	$2, %rdi
	call	_Znam@PLT
	movq	(%rsp), %rdi
	movq	%rax, %rbx
	imulq	%rdi, %rdi
	cmpq	%rdi, %r12
	jb	.L28
	salq	$2, %rdi
	xorl	%r13d, %r13d
	call	_Znam@PLT
	movq	%rax, %r12
.L31:
	movq	(%rsp), %rax
	imulq	%rax, %rax
	cmpq	%rax, %r13
	jnb	.L36
	call	rand@PLT
	cvtsi2ssl	%eax, %xmm0
	mulss	.LC4(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	subsd	.LC5(%rip), %xmm0
	addsd	%xmm0, %xmm0
	cvtsd2ss	%xmm0, %xmm0
	movss	%xmm0, 0(%rbp,%r13,4)
	call	rand@PLT
	cvtsi2ssl	%eax, %xmm0
	mulss	.LC4(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	subsd	.LC5(%rip), %xmm0
	addsd	%xmm0, %xmm0
	cvtsd2ss	%xmm0, %xmm0
	movss	%xmm0, (%rbx,%r13,4)
	incq	%r13
	jmp	.L31
.L36:
	call	_ZNSt6chrono3_V212system_clock3nowEv@PLT
	movq	%rbx, %rdx
	movq	%rbp, %rsi
	movq	%r12, %rdi
	movq	(%rsp), %rcx
	movq	%rax, %r13
	movl	$1000000, %r15d
	leaq	.LC7(%rip), %r14
	call	_Z14matrix_productPfS_S_m
	call	_ZNSt6chrono3_V212system_clock3nowEv@PLT
	leaq	.LC6(%rip), %rsi
	movl	$2, %edi
	subq	%r13, %rax
	cqto
	idivq	%r15
	movl	%eax, %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	(%rsp), %rsi
	movq	%rbp, %rdi
	call	_Z5printPfm
	movq	%r14, %rdi
	call	puts@PLT
	movq	(%rsp), %rsi
	movq	%rbx, %rdi
	call	_Z5printPfm
	movq	%r14, %rdi
	call	puts@PLT
	movq	(%rsp), %rsi
	movq	%r12, %rdi
	call	_Z5printPfm
	call	_ZNSt6chrono3_V212system_clock3nowEv@PLT
	movq	(%rsp), %rcx
	movq	%rbx, %rdx
	movq	%rbp, %rsi
	movq	%r12, %rdi
	movq	%rax, %r13
	call	_Z21matrix_product_serialPfS_S_m
	call	_ZNSt6chrono3_V212system_clock3nowEv@PLT
	leaq	.LC8(%rip), %rsi
	movl	$2, %edi
	subq	%r13, %rax
	cqto
	idivq	%r15
	movl	%eax, %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	(%rsp), %rsi
	movq	%rbp, %rdi
	call	_Z5printPfm
	movq	%r14, %rdi
	call	puts@PLT
	movq	(%rsp), %rsi
	movq	%rbx, %rdi
	call	_Z5printPfm
	movq	%r14, %rdi
	call	puts@PLT
	movq	(%rsp), %rsi
	movq	%r12, %rdi
	call	_Z5printPfm
	movq	%rbp, %rdi
	call	_ZdaPv@PLT
	movq	%rbx, %rdi
	call	_ZdaPv@PLT
	movq	%r12, %rdi
	call	_ZdaPv@PLT
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	je	.L33
.L35:
	call	__stack_chk_fail@PLT
.L33:
	addq	$24, %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
.LFE2129:
	.size	main, .-main
	.section	.rodata.str1.1
.LC9:
	.string	"_Z21matrix_product_kernelPfS_S_m"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2163:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 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	.LC9(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z21matrix_product_kernelPfS_S_m(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 48
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	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	%rdx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE2163:
	.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
.LC4:
	.long	805306368
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC5:
	.long	0
	.long	1071644672
	.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 <cstdio>
#include <cstdlib>
#include <hip/hip_runtime.h>
#include <chrono>

using namespace std;

__global__ void matrix_product_kernel(float *P, float *M, float *N,
                                      size_t width) {
  int i = blockIdx.x * 32 + threadIdx.x,
      j = blockIdx.y * 32 + threadIdx.y;
  float acc = 0;
  for (int k = 0; k < width; ++k)
    acc += M[i*width+k] * N[k*width+j];
  P[i*width+j] = acc;
}

void matrix_product_serial(float *P, float *M, float *N, size_t width) {
#pragma omp parallel for
  for (size_t i = 0; i < width; ++i)
    for (size_t j = 0; j < width; ++j) {
      float acc = 0;
      for (size_t k = 0; k < width; ++k)
        acc += M[i*width+k] * N[k*width+j];
      P[i*width+j] = acc;
    }
}

void matrix_product(float *P, float *M, float *N, size_t width) {
  float *Pd, *Md, *Nd;
  size_t dsize = width * width * sizeof(float);
  hipMalloc((void **)&Md, dsize);
  hipMemcpy(Md, M, dsize, hipMemcpyHostToDevice);
  hipMalloc((void **)&Nd, dsize);
  hipMemcpy(Nd, N, dsize, hipMemcpyHostToDevice);
  hipMalloc((void **)&Pd, dsize);

  dim3 dim_block(32, 32), dim_grid(width / 32, width / 32);
  matrix_product_kernel<<<dim_grid, dim_block>>>(Pd, Md, Nd, width);

  hipMemcpy(P, Pd, dsize, hipMemcpyDeviceToHost);

  hipFree(Pd);
  hipFree(Md);
  hipFree(Nd);
}

void print(float *M, size_t width) {
  for (size_t i = 0; i < width; ++i) {
    for (size_t j = 0; j < width; ++j)
      printf("%.2f ", M[i*width+j]);
    puts("");
  }
}

int main(int argc, char *argv[]) {
  size_t width;

#ifdef NOIO
  width = 1024;
#else
  scanf("%ld", &width);
#endif

  float *M = new float[width*width],
        *N = new float[width*width],
        *P = new float[width*width];
  for (int i = 0; i < width * width; ++i) {
    M[i] = ((float)rand() / RAND_MAX - 0.5) * 2;
    N[i] = ((float)rand() / RAND_MAX - 0.5) * 2;
  }

  chrono::time_point<chrono::system_clock> start, end;
  int ms;

  start = chrono::system_clock::now();
  matrix_product(P, M, N, width);
  end = chrono::system_clock::now();
  ms = chrono::duration_cast<chrono::milliseconds>(end-start).count();
  printf("GPU: %d\n", ms);

#ifndef NOIO
  print(M, width);
  puts("-------");
  print(N, width);
  puts("-------");
  print(P, width);
#endif

  start = chrono::system_clock::now();
  matrix_product_serial(P, M, N, width);
  end = chrono::system_clock::now();
  ms = chrono::duration_cast<chrono::milliseconds>(end-start).count();
  printf("CPU: %d\n", ms);

#ifndef NOIO
  print(M, width);
  puts("-------");
  print(N, width);
  puts("-------");
  print(P, width);
#endif

  delete[] M;
  delete[] N;
  delete[] P;
  return 0;
}


	.text
	.file	"matrix.hip"
	.globl	_Z36__device_stub__matrix_product_kernelPfS_S_m # -- Begin function _Z36__device_stub__matrix_product_kernelPfS_S_m
	.type	_Z36__device_stub__matrix_product_kernelPfS_S_m,@function
_Z36__device_stub__matrix_product_kernelPfS_S_m: # @_Z36__device_stub__matrix_product_kernelPfS_S_m
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$112, %rsp
	.cfi_def_cfa_offset 160
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	32(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	24(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	16(%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	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	$_Z21matrix_product_kernelPfS_S_m, %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	_Z36__device_stub__matrix_product_kernelPfS_S_m, .Lfunc_end0-_Z36__device_stub__matrix_product_kernelPfS_S_m
	.cfi_endproc
                                        # -- End function
	.globl	_Z21matrix_product_serialPfS_S_m # -- Begin function _Z21matrix_product_serialPfS_S_m
	.type	_Z21matrix_product_serialPfS_S_m,@function
_Z21matrix_product_serialPfS_S_m:       # @_Z21matrix_product_serialPfS_S_m
	.cfi_startproc
# %bb.0:
	testq	%rcx, %rcx
	je	.LBB1_8
# %bb.1:                                # %.preheader26.preheader
	pushq	%r14
	.cfi_def_cfa_offset 16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset %rbx, -24
	.cfi_offset %r14, -16
	leaq	(,%rcx,4), %rax
	xorl	%r8d, %r8d
.LBB1_2:                                # %.preheader26
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_3 Depth 2
                                        #       Child Loop BB1_4 Depth 3
	movq	%r8, %r9
	imulq	%rcx, %r9
	leaq	(%rdi,%r9,4), %r9
	movq	%rdx, %r10
	xorl	%r11d, %r11d
.LBB1_3:                                # %.preheader
                                        #   Parent Loop BB1_2 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB1_4 Depth 3
	xorps	%xmm0, %xmm0
	movq	%r10, %rbx
	xorl	%r14d, %r14d
.LBB1_4:                                #   Parent Loop BB1_2 Depth=1
                                        #     Parent Loop BB1_3 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	movss	(%rsi,%r14,4), %xmm1            # xmm1 = mem[0],zero,zero,zero
	mulss	(%rbx), %xmm1
	addss	%xmm1, %xmm0
	incq	%r14
	addq	%rax, %rbx
	cmpq	%r14, %rcx
	jne	.LBB1_4
# %bb.5:                                #   in Loop: Header=BB1_3 Depth=2
	movss	%xmm0, (%r9,%r11,4)
	incq	%r11
	addq	$4, %r10
	cmpq	%rcx, %r11
	jne	.LBB1_3
# %bb.6:                                #   in Loop: Header=BB1_2 Depth=1
	incq	%r8
	addq	%rax, %rsi
	cmpq	%rcx, %r8
	jne	.LBB1_2
# %bb.7:
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	.cfi_restore %rbx
	.cfi_restore %r14
.LBB1_8:                                # %._crit_edge
	retq
.Lfunc_end1:
	.size	_Z21matrix_product_serialPfS_S_m, .Lfunc_end1-_Z21matrix_product_serialPfS_S_m
	.cfi_endproc
                                        # -- End function
	.globl	_Z14matrix_productPfS_S_m       # -- Begin function _Z14matrix_productPfS_S_m
	.type	_Z14matrix_productPfS_S_m,@function
_Z14matrix_productPfS_S_m:              # @_Z14matrix_productPfS_S_m
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rcx, %r15
	movq	%rdx, %r12
	movq	%rsi, %r13
	movq	%rdi, %r14
	movq	%rcx, %rbx
	imulq	%rcx, %rbx
	shlq	$2, %rbx
	leaq	16(%rsp), %rbp
	movq	%rbp, %rdi
	movq	%rbx, %rsi
	callq	hipMalloc
	movq	(%rbp), %rdi
	movq	%r13, %rsi
	movq	%rbx, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	leaq	8(%rsp), %r13
	movq	%r13, %rdi
	movq	%rbx, %rsi
	callq	hipMalloc
	movq	(%r13), %rdi
	movq	%r12, %rsi
	movq	%rbx, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	%rsp, %rdi
	movq	%rbx, %rsi
	callq	hipMalloc
	movq	%r15, %rdi
	shrq	$5, %rdi
	movl	%edi, %eax
	shlq	$32, %rdi
	orq	%rax, %rdi
	movabsq	$137438953504, %rdx             # imm = 0x2000000020
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB2_2
# %bb.1:
	movq	(%rsp), %rdi
	movq	16(%rsp), %rsi
	movq	8(%rsp), %rdx
	movq	%r15, %rcx
	callq	_Z36__device_stub__matrix_product_kernelPfS_S_m
.LBB2_2:
	movq	(%rsp), %rsi
	movq	%r14, %rdi
	movq	%rbx, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	movq	(%rsp), %rdi
	callq	hipFree
	movq	16(%rsp), %rdi
	callq	hipFree
	movq	8(%rsp), %rdi
	callq	hipFree
	addq	$24, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end2:
	.size	_Z14matrix_productPfS_S_m, .Lfunc_end2-_Z14matrix_productPfS_S_m
	.cfi_endproc
                                        # -- End function
	.globl	_Z5printPfm                     # -- Begin function _Z5printPfm
	.type	_Z5printPfm,@function
_Z5printPfm:                            # @_Z5printPfm
	.cfi_startproc
# %bb.0:
	testq	%rsi, %rsi
	je	.LBB3_6
# %bb.1:                                # %.preheader.preheader
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rsi, %rbx
	movq	%rdi, %r14
	leaq	(,%rsi,4), %r15
	xorl	%r12d, %r12d
.LBB3_2:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB3_3 Depth 2
	xorl	%r13d, %r13d
.LBB3_3:                                #   Parent Loop BB3_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	xorps	%xmm0, %xmm0
	cvtss2sd	(%r14,%r13,4), %xmm0
	movl	$.L.str, %edi
	movb	$1, %al
	callq	printf
	incq	%r13
	cmpq	%r13, %rbx
	jne	.LBB3_3
# %bb.4:                                #   in Loop: Header=BB3_2 Depth=1
	movl	$10, %edi
	callq	putchar@PLT
	incq	%r12
	addq	%r15, %r14
	cmpq	%rbx, %r12
	jne	.LBB3_2
# %bb.5:
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	.cfi_restore %rbx
	.cfi_restore %r12
	.cfi_restore %r13
	.cfi_restore %r14
	.cfi_restore %r15
.LBB3_6:                                # %._crit_edge
	retq
.Lfunc_end3:
	.size	_Z5printPfm, .Lfunc_end3-_Z5printPfm
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function main
.LCPI4_0:
	.long	0x30000000                      # float 4.65661287E-10
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0
.LCPI4_1:
	.quad	0xbfe0000000000000              # double -0.5
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
	.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	$16, %rsp
	.cfi_def_cfa_offset 64
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	xorl	%r15d, %r15d
	leaq	8(%rsp), %rbx
	movl	$.L.str.2, %edi
	movq	%rbx, %rsi
	xorl	%eax, %eax
	callq	__isoc23_scanf
	movq	(%rbx), %r12
	imulq	%r12, %r12
	movq	%r12, %rax
	shrq	$62, %rax
	leaq	(,%r12,4), %rcx
	negq	%rax
	sbbq	%r15, %r15
	orq	%rcx, %r15
	movq	%r15, %rdi
	callq	_Znam
	movq	%rax, %rbx
	movq	%r15, %rdi
	callq	_Znam
	movq	%rax, %r14
	movq	%r15, %rdi
	callq	_Znam
	movq	%rax, %r15
	testq	%r12, %r12
	je	.LBB4_3
# %bb.1:                                # %.lr.ph.preheader
	xorl	%r12d, %r12d
.LBB4_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	callq	rand
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	movss	.LCPI4_0(%rip), %xmm1           # xmm1 = mem[0],zero,zero,zero
	mulss	%xmm1, %xmm0
	cvtss2sd	%xmm0, %xmm0
	movsd	.LCPI4_1(%rip), %xmm1           # xmm1 = mem[0],zero
	addsd	%xmm1, %xmm0
	addsd	%xmm0, %xmm0
	cvtsd2ss	%xmm0, %xmm0
	movss	%xmm0, (%rbx,%r12,4)
	callq	rand
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	mulss	.LCPI4_0(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	addsd	.LCPI4_1(%rip), %xmm0
	addsd	%xmm0, %xmm0
	cvtsd2ss	%xmm0, %xmm0
	movss	%xmm0, (%r14,%r12,4)
	incq	%r12
	movq	8(%rsp), %rax
	imulq	%rax, %rax
	cmpq	%r12, %rax
	ja	.LBB4_2
.LBB4_3:                                # %._crit_edge
	callq	_ZNSt6chrono3_V212system_clock3nowEv
	movq	%rax, %r12
	movq	8(%rsp), %rcx
	movq	%r15, %rdi
	movq	%rbx, %rsi
	movq	%r14, %rdx
	callq	_Z14matrix_productPfS_S_m
	callq	_ZNSt6chrono3_V212system_clock3nowEv
	subq	%r12, %rax
	movabsq	$4835703278458516699, %r13      # imm = 0x431BDE82D7B634DB
	imulq	%r13
	movq	%rdx, %rsi
	shrq	$63, %rsi
	shrq	$18, %rdx
	addl	%edx, %esi
	movl	$.L.str.3, %edi
                                        # kill: def $esi killed $esi killed $rsi
	xorl	%eax, %eax
	callq	printf
	movq	8(%rsp), %rsi
	movq	%rbx, %rdi
	callq	_Z5printPfm
	movl	$.L.str.4, %edi
	callq	puts
	movq	8(%rsp), %rsi
	movq	%r14, %rdi
	callq	_Z5printPfm
	movl	$.L.str.4, %edi
	callq	puts
	movq	8(%rsp), %rsi
	movq	%r15, %rdi
	callq	_Z5printPfm
	callq	_ZNSt6chrono3_V212system_clock3nowEv
	movq	%rax, %r12
	movq	8(%rsp), %rax
	testq	%rax, %rax
	je	.LBB4_10
# %bb.4:                                # %.preheader26.i.preheader
	leaq	(,%rax,4), %rcx
	xorl	%edx, %edx
	movq	%rbx, %rsi
.LBB4_5:                                # %.preheader26.i
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB4_6 Depth 2
                                        #       Child Loop BB4_7 Depth 3
	movq	%rdx, %rdi
	imulq	%rax, %rdi
	leaq	(%r15,%rdi,4), %rdi
	movq	%r14, %r8
	xorl	%r9d, %r9d
.LBB4_6:                                # %.preheader.i
                                        #   Parent Loop BB4_5 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB4_7 Depth 3
	xorps	%xmm0, %xmm0
	movq	%r8, %r10
	xorl	%r11d, %r11d
.LBB4_7:                                #   Parent Loop BB4_5 Depth=1
                                        #     Parent Loop BB4_6 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	movss	(%rsi,%r11,4), %xmm1            # xmm1 = mem[0],zero,zero,zero
	mulss	(%r10), %xmm1
	addss	%xmm1, %xmm0
	incq	%r11
	addq	%rcx, %r10
	cmpq	%r11, %rax
	jne	.LBB4_7
# %bb.8:                                #   in Loop: Header=BB4_6 Depth=2
	movss	%xmm0, (%rdi,%r9,4)
	incq	%r9
	addq	$4, %r8
	cmpq	%rax, %r9
	jne	.LBB4_6
# %bb.9:                                #   in Loop: Header=BB4_5 Depth=1
	incq	%rdx
	addq	%rcx, %rsi
	cmpq	%rax, %rdx
	jne	.LBB4_5
.LBB4_10:                               # %_Z21matrix_product_serialPfS_S_m.exit
	callq	_ZNSt6chrono3_V212system_clock3nowEv
	subq	%r12, %rax
	imulq	%r13
	movq	%rdx, %rsi
	shrq	$63, %rsi
	shrq	$18, %rdx
	addl	%edx, %esi
	movl	$.L.str.5, %edi
                                        # kill: def $esi killed $esi killed $rsi
	xorl	%eax, %eax
	callq	printf
	movq	8(%rsp), %rsi
	movq	%rbx, %rdi
	callq	_Z5printPfm
	movl	$.L.str.4, %edi
	callq	puts
	movq	8(%rsp), %rsi
	movq	%r14, %rdi
	callq	_Z5printPfm
	movl	$.L.str.4, %edi
	callq	puts
	movq	8(%rsp), %rsi
	movq	%r15, %rdi
	callq	_Z5printPfm
	movq	%rbx, %rdi
	callq	_ZdaPv
	movq	%r14, %rdi
	callq	_ZdaPv
	movq	%r15, %rdi
	callq	_ZdaPv
	xorl	%eax, %eax
	addq	$16, %rsp
	.cfi_def_cfa_offset 48
	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_end4:
	.size	main, .Lfunc_end4-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:
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	jne	.LBB5_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB5_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z21matrix_product_kernelPfS_S_m, %esi
	movl	$.L__unnamed_1, %edx
	movl	$.L__unnamed_1, %ecx
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$__hip_module_dtor, %edi
	addq	$40, %rsp
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_end5:
	.size	__hip_module_ctor, .Lfunc_end5-__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	.LBB6_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
.LBB6_2:
	retq
.Lfunc_end6:
	.size	__hip_module_dtor, .Lfunc_end6-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	_Z21matrix_product_kernelPfS_S_m,@object # @_Z21matrix_product_kernelPfS_S_m
	.section	.rodata,"a",@progbits
	.globl	_Z21matrix_product_kernelPfS_S_m
	.p2align	3, 0x0
_Z21matrix_product_kernelPfS_S_m:
	.quad	_Z36__device_stub__matrix_product_kernelPfS_S_m
	.size	_Z21matrix_product_kernelPfS_S_m, 8

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

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"%ld"
	.size	.L.str.2, 4

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"GPU: %d\n"
	.size	.L.str.3, 9

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"-------"
	.size	.L.str.4, 8

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"CPU: %d\n"
	.size	.L.str.5, 9

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z21matrix_product_kernelPfS_S_m"
	.size	.L__unnamed_1, 33

	.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

	.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 _Z36__device_stub__matrix_product_kernelPfS_S_m
	.addrsig_sym __gxx_personality_v0
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z21matrix_product_kernelPfS_S_m
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z21matrix_product_kernelPfS_S_m ; -- Begin function _Z21matrix_product_kernelPfS_S_m
	.globl	_Z21matrix_product_kernelPfS_S_m
	.p2align	8
	.type	_Z21matrix_product_kernelPfS_S_m,@function
_Z21matrix_product_kernelPfS_S_m:       ; @_Z21matrix_product_kernelPfS_S_m
; %bb.0:
	s_load_b256 s[0:7], s[0:1], 0x0
	v_bfe_u32 v1, v0, 10, 10
	s_mov_b64 s[8:9], 0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshl_add_u32 v1, s15, 5, v1
	v_ashrrev_i32_e32 v2, 31, v1
	s_waitcnt lgkmcnt(0)
	s_cmp_lg_u64 s[6:7], 0
	s_cbranch_scc0 .LBB0_4
; %bb.1:                                ; %.lr.ph
	v_and_b32_e32 v0, 0x3ff, v0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshl_add_u32 v0, s14, 5, v0
	v_ashrrev_i32_e32 v5, 31, v0
	v_mul_lo_u32 v6, v0, s7
	v_mad_u64_u32 v[3:4], null, v0, s6, 0
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_lo_u32 v0, v5, s6
	v_add3_u32 v4, v4, v6, v0
	v_lshlrev_b64 v[5:6], 2, v[1:2]
	v_mov_b32_e32 v0, 0
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_lshlrev_b64 v[7:8], 2, v[3:4]
	v_add_co_u32 v5, vcc_lo, s4, v5
	s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_co_ci_u32_e32 v6, vcc_lo, s5, v6, vcc_lo
	v_add_co_u32 v7, vcc_lo, s2, v7
	s_delay_alu instid0(VALU_DEP_4)
	v_add_co_ci_u32_e32 v8, vcc_lo, s3, v8, vcc_lo
	s_lshl_b64 s[2:3], s[6:7], 2
.LBB0_2:                                ; =>This Inner Loop Header: Depth=1
	global_load_b32 v9, v[7:8], off
	global_load_b32 v10, v[5:6], off
	s_add_u32 s8, s8, 1
	v_add_co_u32 v5, vcc_lo, v5, s2
	s_addc_u32 s9, s9, 0
	v_add_co_ci_u32_e32 v6, vcc_lo, s3, v6, vcc_lo
	v_cmp_ge_u64_e64 s4, s[8:9], s[6:7]
	v_add_co_u32 v7, vcc_lo, v7, 4
	v_add_co_ci_u32_e32 v8, vcc_lo, 0, v8, vcc_lo
	s_delay_alu instid0(VALU_DEP_3)
	s_and_b32 vcc_lo, exec_lo, s4
	s_waitcnt vmcnt(0)
	v_fmac_f32_e32 v0, v9, v10
	s_cbranch_vccz .LBB0_2
; %bb.3:                                ; %Flow
	s_mov_b32 s2, 0
	s_branch .LBB0_5
.LBB0_4:
	s_mov_b32 s2, -1
                                        ; implicit-def: $vgpr0
                                        ; implicit-def: $vgpr3_vgpr4
.LBB0_5:                                ; %Flow41
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_b32 vcc_lo, exec_lo, s2
	s_cbranch_vccz .LBB0_7
; %bb.6:                                ; %.._crit_edge_crit_edge
	v_dual_mov_b32 v3, 0 :: v_dual_mov_b32 v0, 0
	v_mov_b32_e32 v4, 0
.LBB0_7:                                ; %._crit_edge
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_lshlrev_b64 v[3:4], 2, v[3:4]
	v_lshlrev_b64 v[1:2], 2, v[1:2]
	v_add_co_u32 v3, vcc_lo, s0, v3
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_ci_u32_e32 v4, vcc_lo, s1, v4, vcc_lo
	v_add_co_u32 v1, vcc_lo, v3, v1
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v2, vcc_lo, v4, v2, vcc_lo
	global_store_b32 v[1:2], v0, off
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z21matrix_product_kernelPfS_S_m
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 32
		.amdhsa_user_sgpr_count 14
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 1
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 1
		.amdhsa_next_free_vgpr 11
		.amdhsa_next_free_sgpr 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	_Z21matrix_product_kernelPfS_S_m, .Lfunc_end0-_Z21matrix_product_kernelPfS_S_m
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 352
; NumSgprs: 18
; NumVgprs: 11
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 11
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 14
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 1
	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __hip_cuid_
	.amdgpu_metadata
---
amdhsa.kernels:
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         16
        .size:           8
        .value_kind:     global_buffer
      - .offset:         24
        .size:           8
        .value_kind:     by_value
    .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:           _Z21matrix_product_kernelPfS_S_m
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z21matrix_product_kernelPfS_S_m.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     11
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
