#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <chrono>
using namespace std;

#define num_devs 4

__global__ void cudamatmul(float *A, float *B, float *C, int N) {
  int i = blockIdx.y;
  int j = threadIdx.x + blockDim.x * blockIdx.x;
  float sum = 0.0f;
  extern __shared__ float A_s[];
  for (int ks=0; ks<N; ks+=blockDim.x) {
    __syncthreads();
    A_s[threadIdx.x] = A[N*i+ks+threadIdx.x];
    __syncthreads();
    for (int k=ks; k<ks+blockDim.x; k++) {
      sum += A_s[k-ks] * B[N/2*k+j];
    }
  }
  C[N/2*i+j] = sum;
}

void errorcalc(float *A, float *B, float *C, int N){
  #pragma omp parallel for
  for (int i=0; i<N; i++)
    for (int k=0; k<N; k++)
      for (int j=0; j<N; j++)
        C[N*i+j] -= A[N*i+k] * B[N*k+j];
  double err = 0;
  for (int i=0; i<N; i++)
    for (int j=0; j<N; j++)
      err += fabs(C[N*i+j]);
  printf("error: %lf\n",err/N/N);
}

void errorcalc2(float *A, float *B, float *C, int N){
  #pragma omp parallel for
  for (int i=0; i<N/2; i++)
    for (int k=0; k<N; k++)
      for (int j=0; j<N/2; j++)
        C[N/2*i+j] -= A[N*i+k] * B[N/2*k+j];
  double err = 0;
  for (int i=0; i<N/2; i++)
    for (int j=0; j<N/2; j++)
      err += fabs(C[N/2*i+j]);
  printf("error: %lf\n",err/(N/2)/(N/2));
}

int main(int argc, char **argv) {
  int N = 2048;
  int M = 128;
  int size = N*N*sizeof(float);

  float A[N*N], B[N*N], C[N*N];
  for (int i=0; i<N; i++) {
    for (int j=0; j<N; j++) {
      A[N*i+j] = drand48();
      B[N*i+j] = drand48();
      C[N*i+j] = 0;
    }
  }

  float subA[4][N/2*N], subB[4][N*N/2], subC[4][N/2*N/2];
  float *subA_d[4], *subB_d[4], *subC_d[4];
  for (int i=0; i<N/2; i++) {
    for (int j=0; j<N; j++) {
      subA[0][N*i+j] = A[N*i+j];
      subA[1][N*i+j] = A[N*i+j];
      subA[2][N*i+j] = A[N*(i+N/2)+j];
      subA[3][N*i+j] = A[N*(i+N/2)+j];
      subB[0][N/2*j+i] = B[N*j+i];
      subB[1][N/2*j+i] = B[N*j+i];
      subB[2][N/2*j+i] = B[N*j+(i+N/2)];
      subB[3][N/2*j+i] = B[N*j+(i+N/2)];
    }
  }
  for (int i=0; i<N/2; i++) {
    for (int j=0; j<N/2; j++) {
      subC[0][N/2*i+j] = 0;
      subC[1][N/2*i+j] = 0;
      subC[2][N/2*i+j] = 0;
      subC[3][N/2*i+j] = 0;
    }
  }

  cudaStream_t stream[4];
  for (int dev_id=0; dev_id<num_devs; dev_id++) {
    cudaSetDevice(dev_id);
    cudaStreamCreate(&stream[dev_id]);
    cudaMalloc(&(subA_d[dev_id]),size/2);
    cudaMalloc(&(subB_d[dev_id]),size/2);
    cudaMalloc(&(subC_d[dev_id]),size/4);
		cudaMemcpy(subA_d[dev_id],subA[dev_id],size/2,cudaMemcpyHostToDevice);
		cudaMemcpy(subB_d[dev_id],subB[dev_id],size/2,cudaMemcpyHostToDevice);
		cudaMemcpy(subC_d[dev_id],subC[dev_id],size/4,cudaMemcpyHostToDevice);
  }

  auto tic = chrono::steady_clock::now();
  for (int dev_id = 0; dev_id < num_devs; dev_id++) {
    cudaSetDevice(dev_id);
    dim3 grid(N/2/M, N/2);
    cudamatmul<<<grid,M,M*sizeof(float)>>>(subA_d[dev_id], subB_d[dev_id], subC_d[dev_id], N);
  }
  for (int dev_id = 0; dev_id < num_devs; dev_id++) {
    cudaStreamSynchronize(stream[dev_id]);
  }
  
  for (int dev_id = 0; dev_id < num_devs; dev_id++) {
    cudaSetDevice(dev_id);
    cudaMemcpy(subC[dev_id],subC_d[dev_id],size/4,cudaMemcpyDeviceToHost);
  }

  for (int i=0; i<N/2; i++) {
    for (int j=0; j<N/2; j++) {
      C[N*i+j] = subC[0][N/2*i+j];
      C[N*i+(j+N/2)] = subC[1][N/2*i+j];
      C[N*(i+N/2)+j] = subC[2][N/2*i+j];
      C[N*(i+N/2)+(j+N/2)] = subC[3][N/2*i+j];
    }
  }
  auto toc = chrono::steady_clock::now();
  double time = chrono::duration<double>(toc - tic).count();
  printf("N=%d: %lf s (%lf GFlops)\n",N,time,2.*N*N*N/time/1e9);

  /*
  for (int dev_id=0; dev_id<num_devs; dev_id++) {
    errorcalc2(subA[dev_id],subB[dev_id],subC[dev_id],N);
  }
  */

  errorcalc(A,B,C,N);
  
  for (int dev_id=0; dev_id<num_devs; dev_id++) {
    cudaFree(subA_d[dev_id]);
    cudaFree(subB_d[dev_id]);
    cudaFree(subC_d[dev_id]);
  }
}

	.file	"tmpxft_0028d165_00000000-6_multi_gpu.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2134:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2134:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC2:
	.string	"error: %lf\n"
	.text
	.globl	_Z9errorcalcPfS_S_i
	.type	_Z9errorcalcPfS_S_i, @function
_Z9errorcalcPfS_S_i:
.LFB2126:
	.cfi_startproc
	endbr64
	movslq	%ecx, %rcx
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movq	%rdi, %r10
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movq	%rcx, %rax
	xorl	%ebp, %ebp
	salq	$2, %rcx
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	movq	%rsi, %rbx
	xorl	%esi, %esi
.L3:
	cmpl	%eax, %ebp
	jge	.L6
	movq	%rbx, %r11
	xorl	%edi, %edi
	leaq	(%r10,%rsi), %r12
.L7:
	leaq	(%rdx,%rsi), %r9
	xorl	%r8d, %r8d
.L4:
	movss	(%r12,%rdi,4), %xmm1
	mulss	(%r11,%r8,4), %xmm1
	incq	%r8
	addq	$4, %r9
	movss	-4(%r9), %xmm0
	subss	%xmm1, %xmm0
	movss	%xmm0, -4(%r9)
	cmpl	%r8d, %eax
	jg	.L4
	incq	%rdi
	addq	%rcx, %r11
	cmpl	%edi, %eax
	jg	.L7
	incl	%ebp
	addq	%rcx, %rsi
	jmp	.L3
.L6:
	xorl	%edi, %edi
	xorps	%xmm0, %xmm0
	movss	.LC1(%rip), %xmm2
.L8:
	cmpl	%eax, %edi
	jge	.L15
	xorl	%esi, %esi
.L9:
	movss	(%rdx,%rsi,4), %xmm1
	incq	%rsi
	andps	%xmm2, %xmm1
	cvtss2sd	%xmm1, %xmm1
	addsd	%xmm1, %xmm0
	cmpl	%esi, %eax
	jg	.L9
	incl	%edi
	addq	%rcx, %rdx
	jmp	.L8
.L15:
	cvtsi2sdl	%eax, %xmm1
	popq	%rbx
	.cfi_def_cfa_offset 24
	leaq	.LC2(%rip), %rsi
	popq	%rbp
	.cfi_def_cfa_offset 16
	movl	$2, %edi
	movb	$1, %al
	popq	%r12
	.cfi_def_cfa_offset 8
	divsd	%xmm1, %xmm0
	divsd	%xmm1, %xmm0
	jmp	__printf_chk@PLT
	.cfi_endproc
.LFE2126:
	.size	_Z9errorcalcPfS_S_i, .-_Z9errorcalcPfS_S_i
	.globl	_Z10errorcalc2PfS_S_i
	.type	_Z10errorcalc2PfS_S_i, @function
_Z10errorcalc2PfS_S_i:
.LFB2127:
	.cfi_startproc
	endbr64
	movl	%ecx, %eax
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	xorl	%r10d, %r10d
	xorl	%r11d, %r11d
	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
	movq	%rsi, %r12
	movq	%rdx, %rsi
	cltd
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%rdi, %rbp
	movl	$2, %edi
	idivl	%edi
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	xorl	%ebx, %ebx
.L17:
	cmpl	%r11d, %eax
	jle	.L28
	movslq	%r10d, %rdx
	xorl	%r9d, %r9d
	leaq	(%rsi,%rdx,4), %r13
	xorl	%edx, %edx
.L23:
	cmpl	%ecx, %edx
	jge	.L19
	cmpl	$1, %ecx
	je	.L21
	leal	(%rdx,%rbx), %edi
	movq	%r13, %r8
	movslq	%edi, %rdi
	leaq	0(%rbp,%rdi,4), %r15
	movslq	%r9d, %rdi
	leaq	(%r12,%rdi,4), %r14
	xorl	%edi, %edi
.L18:
	movss	(%r15), %xmm1
	mulss	(%r14,%rdi,4), %xmm1
	incq	%rdi
	addq	$4, %r8
	movss	-4(%r8), %xmm0
	subss	%xmm1, %xmm0
	movss	%xmm0, -4(%r8)
	cmpl	%edi, %eax
	jg	.L18
.L21:
	incl	%edx
	addl	%eax, %r9d
	jmp	.L23
.L19:
	incl	%r11d
	addl	%eax, %r10d
	addl	%ecx, %ebx
	jmp	.L17
.L28:
	xorl	%r8d, %r8d
	xorps	%xmm0, %xmm0
	movss	.LC1(%rip), %xmm2
	xorl	%edi, %edi
.L22:
	cmpl	%edi, %eax
	jle	.L25
	cmpl	$1, %ecx
	jle	.L27
	movslq	%r8d, %rdx
	leaq	(%rsi,%rdx,4), %r9
	xorl	%edx, %edx
.L24:
	movss	(%r9,%rdx,4), %xmm1
	incq	%rdx
	andps	%xmm2, %xmm1
	cvtss2sd	%xmm1, %xmm1
	addsd	%xmm1, %xmm0
	cmpl	%edx, %eax
	jg	.L24
.L27:
	incl	%edi
	addl	%eax, %r8d
	jmp	.L22
.L25:
	cvtsi2sdl	%eax, %xmm1
	popq	%rbx
	.cfi_def_cfa_offset 48
	leaq	.LC2(%rip), %rsi
	popq	%rbp
	.cfi_def_cfa_offset 40
	movl	$2, %edi
	popq	%r12
	.cfi_def_cfa_offset 32
	movb	$1, %al
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	divsd	%xmm1, %xmm0
	divsd	%xmm1, %xmm0
	jmp	__printf_chk@PLT
	.cfi_endproc
.LFE2127:
	.size	_Z10errorcalc2PfS_S_i, .-_Z10errorcalc2PfS_S_i
	.globl	_Z35__device_stub__Z10cudamatmulPfS_S_iPfS_S_i
	.type	_Z35__device_stub__Z10cudamatmulPfS_S_iPfS_S_i, @function
_Z35__device_stub__Z10cudamatmulPfS_S_iPfS_S_i:
.LFB2156:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movq	%rdi, 24(%rsp)
	leaq	56(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	68(%rsp), %rsi
	movq	%rdx, 8(%rsp)
	leaq	40(%rsp), %rdx
	movl	%ecx, 4(%rsp)
	leaq	48(%rsp), %rcx
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 64(%rsp)
	movq	%rax, 104(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	4(%rsp), %rax
	movq	%rax, 128(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 56(%rsp)
	movq	%rax, 68(%rsp)
	movl	$1, 76(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L32
	pushq	48(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z10cudamatmulPfS_S_i(%rip), %rdi
	pushq	48(%rsp)
	.cfi_def_cfa_offset 176
	movq	84(%rsp), %rcx
	movl	92(%rsp), %r8d
	movq	72(%rsp), %rsi
	movl	80(%rsp), %edx
	leaq	120(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 168
	popq	%rdx
	.cfi_def_cfa_offset 160
.L32:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L34
	call	__stack_chk_fail@PLT
.L34:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2156:
	.size	_Z35__device_stub__Z10cudamatmulPfS_S_iPfS_S_i, .-_Z35__device_stub__Z10cudamatmulPfS_S_iPfS_S_i
	.globl	_Z10cudamatmulPfS_S_i
	.type	_Z10cudamatmulPfS_S_i, @function
_Z10cudamatmulPfS_S_i:
.LFB2157:
	.cfi_startproc
	endbr64
	jmp	_Z35__device_stub__Z10cudamatmulPfS_S_iPfS_S_i
	.cfi_endproc
.LFE2157:
	.size	_Z10cudamatmulPfS_S_i, .-_Z10cudamatmulPfS_S_i
	.section	.rodata.str1.1
.LC6:
	.string	"N=%d: %lf s (%lf GFlops)\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2128:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$216, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	leaq	-16777216(%rsp), %rax
.L38:
	cmpq	%rax, %rsp
	je	.L39
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L38
.L39:
	movq	%rsp, %r13
	leaq	-16777216(%rsp), %rax
.L41:
	cmpq	%rax, %rsp
	je	.L42
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L41
.L42:
	movq	%rsp, -224(%rbp)
	leaq	-16777216(%rsp), %rax
.L44:
	cmpq	%rax, %rsp
	je	.L45
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L44
.L45:
	xorl	%r12d, %r12d
	movq	%rsp, -232(%rbp)
.L47:
	movq	%r12, %rbx
	movl	$2048, %r14d
	salq	$13, %rbx
.L48:
	call	drand48@PLT
	cvtsd2ss	%xmm0, %xmm0
	movss	%xmm0, 0(%r13,%rbx)
	call	drand48@PLT
	movq	-224(%rbp), %rax
	cvtsd2ss	%xmm0, %xmm0
	movss	%xmm0, (%rax,%rbx)
	movq	-232(%rbp), %rax
	movl	$0x00000000, (%rax,%rbx)
	addq	$4, %rbx
	decl	%r14d
	jne	.L48
	incq	%r12
	cmpq	$2048, %r12
	jne	.L47
	leaq	-33554432(%rsp), %rax
.L50:
	cmpq	%rax, %rsp
	je	.L51
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L50
.L51:
	movq	%rsp, %r15
	leaq	-33554432(%rsp), %rax
.L53:
	cmpq	%rax, %rsp
	je	.L54
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L53
.L54:
	movq	%rsp, -248(%rbp)
	leaq	-16777216(%rsp), %rax
.L56:
	cmpq	%rax, %rsp
	je	.L57
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L56
.L57:
	xorl	%ecx, %ecx
	xorl	%edi, %edi
	movq	%rsp, -216(%rbp)
.L59:
	movq	-224(%rbp), %rax
	movl	$2048, %r12d
	leaq	(%rax,%rcx), %rsi
	movq	-248(%rbp), %rax
	leaq	(%rax,%rcx), %rdx
	movq	%rcx, %rax
	salq	$11, %rax
.L60:
	movss	0(%r13,%rax), %xmm0
	addq	$8192, %rsi
	addq	$4096, %rdx
	movss	%xmm0, (%r15,%rax)
	movss	%xmm0, 8388608(%r15,%rax)
	movss	8388608(%r13,%rax), %xmm0
	movss	%xmm0, 16777216(%r15,%rax)
	movss	%xmm0, 25165824(%r15,%rax)
	addq	$4, %rax
	movss	-8192(%rsi), %xmm0
	movss	%xmm0, -4096(%rdx)
	movss	%xmm0, 8384512(%rdx)
	movss	-4096(%rsi), %xmm0
	movss	%xmm0, 16773120(%rdx)
	movss	%xmm0, 25161728(%rdx)
	decl	%r12d
	jne	.L60
	incl	%edi
	addq	$4, %rcx
	cmpl	$1024, %edi
	jne	.L59
	movq	-216(%rbp), %rdi
	movl	%r12d, %eax
	xorl	%ebx, %ebx
	xorl	%r9d, %r9d
	movl	$4194304, %ecx
	leaq	-88(%rbp), %r14
	rep stosl
.L61:
	movl	%r9d, %edi
	movl	%r9d, -252(%rbp)
	call	cudaSetDevice@PLT
	leaq	(%r14,%rbx), %rdi
	call	cudaStreamCreate@PLT
	leaq	-184(%rbp,%rbx), %rdi
	movl	$8388608, %esi
	call	cudaMalloc@PLT
	leaq	-152(%rbp,%rbx), %rdi
	movl	$8388608, %esi
	call	cudaMalloc@PLT
	leaq	-120(%rbp,%rbx), %rdi
	movl	$4194304, %esi
	call	cudaMalloc@PLT
	movq	%rbx, %r10
	movl	$1, %ecx
	movq	-184(%rbp,%rbx), %rdi
	salq	$20, %r10
	movl	$8388608, %edx
	leaq	(%r15,%r10), %rsi
	movq	%r10, -240(%rbp)
	call	cudaMemcpy@PLT
	movl	$1, %ecx
	movl	$8388608, %edx
	movq	-240(%rbp), %r10
	movq	-248(%rbp), %rax
	movq	-152(%rbp,%rbx), %rdi
	leaq	(%rax,%r10), %rsi
	call	cudaMemcpy@PLT
	movq	-216(%rbp), %rax
	movq	%rbx, %rsi
	movq	-120(%rbp,%rbx), %rdi
	salq	$19, %rsi
	movl	$1, %ecx
	movl	$4194304, %edx
	addq	$8, %rbx
	addq	%rax, %rsi
	movq	%rax, -240(%rbp)
	call	cudaMemcpy@PLT
	movl	-252(%rbp), %r9d
	incl	%r9d
	cmpl	$4, %r9d
	jne	.L61
	call	_ZNSt6chrono3_V212steady_clock3nowEv@PLT
	xorl	%ebx, %ebx
	movq	%rax, %r15
.L63:
	movl	%ebx, %edi
	call	cudaSetDevice@PLT
	movl	$33554433, %edx
	xorl	%r9d, %r9d
	movabsq	$4398046511112, %rax
	salq	$7, %rdx
	movl	$1, %ecx
	movq	%rax, %rdi
	movl	$1, %esi
	movl	$512, %r8d
	movq	%rax, -208(%rbp)
	movl	$1, -200(%rbp)
	movq	%rdx, -196(%rbp)
	movl	$1, -188(%rbp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L62
	movq	-120(%rbp,%rbx,8), %rdx
	movq	-152(%rbp,%rbx,8), %rsi
	movl	$2048, %ecx
	movq	-184(%rbp,%rbx,8), %rdi
	call	_Z35__device_stub__Z10cudamatmulPfS_S_iPfS_S_i
.L62:
	incq	%rbx
	cmpq	$4, %rbx
	jne	.L63
	xorl	%ebx, %ebx
.L64:
	movq	(%r14,%rbx,8), %rdi
	incq	%rbx
	call	cudaStreamSynchronize@PLT
	cmpq	$4, %rbx
	jne	.L64
	xorl	%r14d, %r14d
	leaq	-120(%rbp), %rbx
.L65:
	movl	%r14d, %edi
	call	cudaSetDevice@PLT
	movq	-216(%rbp), %rax
	movq	%r14, %rdi
	movq	(%rbx,%r14,8), %rsi
	salq	$22, %rdi
	movl	$2, %ecx
	movl	$4194304, %edx
	incq	%r14
	addq	%rax, %rdi
	call	cudaMemcpy@PLT
	cmpq	$4, %r14
	jne	.L65
	movq	-232(%rbp), %rsi
.L66:
	movq	-240(%rbp), %rax
	movq	%rsi, %rdx
	movl	$1024, %ecx
.L67:
	movss	(%rax), %xmm0
	addq	$4, %rdx
	addq	$4, %rax
	movss	%xmm0, -4(%rdx)
	movss	4194300(%rax), %xmm0
	movss	%xmm0, 4092(%rdx)
	movss	8388604(%rax), %xmm0
	movss	%xmm0, 8388604(%rdx)
	movss	12582908(%rax), %xmm0
	movss	%xmm0, 8392700(%rdx)
	decl	%ecx
	jne	.L67
	addl	$1024, %r12d
	addq	$8192, %rsi
	addq	$4096, -240(%rbp)
	cmpl	$1048576, %r12d
	jne	.L66
	call	_ZNSt6chrono3_V212steady_clock3nowEv@PLT
	movsd	.LC4(%rip), %xmm2
	xorl	%r12d, %r12d
	movsd	.LC5(%rip), %xmm1
	subq	%r15, %rax
	movl	$2048, %edx
	movl	$2, %edi
	cvtsi2sdq	%rax, %xmm0
	leaq	.LC6(%rip), %rsi
	movb	$2, %al
	divsd	%xmm2, %xmm0
	divsd	%xmm0, %xmm1
	divsd	%xmm2, %xmm1
	call	__printf_chk@PLT
	movq	-232(%rbp), %rdx
	movl	$2048, %ecx
	movq	%r13, %rdi
	movq	-224(%rbp), %rsi
	call	_Z9errorcalcPfS_S_i
.L69:
	movq	-184(%rbp,%r12), %rdi
	call	cudaFree@PLT
	movq	-152(%rbp,%r12), %rdi
	call	cudaFree@PLT
	movq	(%rbx,%r12), %rdi
	addq	$8, %r12
	call	cudaFree@PLT
	cmpq	$32, %r12
	jne	.L69
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	je	.L70
	call	__stack_chk_fail@PLT
.L70:
	leaq	-40(%rbp), %rsp
	xorl	%eax, %eax
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2128:
	.size	main, .-main
	.section	.rodata.str1.1
.LC7:
	.string	"_Z10cudamatmulPfS_S_i"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2159:
	.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	.LC7(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z10cudamatmulPfS_S_i(%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
.LFE2159:
	.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.cst16,"aM",@progbits,16
	.align 16
.LC1:
	.long	2147483647
	.long	0
	.long	0
	.long	0
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC4:
	.long	0
	.long	1104006501
	.align 8
.LC5:
	.long	0
	.long	1108344832
	.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 <cmath>
#include <cstdlib>
#include <cstdio>
#include <chrono>
using namespace std;

#define num_devs 4

__global__ void cudamatmul(float *A, float *B, float *C, int N) {
  int i = blockIdx.y;
  int j = threadIdx.x + blockDim.x * blockIdx.x;
  float sum = 0.0f;
  extern __shared__ float A_s[];
  for (int ks=0; ks<N; ks+=blockDim.x) {
    __syncthreads();
    A_s[threadIdx.x] = A[N*i+ks+threadIdx.x];
    __syncthreads();
    for (int k=ks; k<ks+blockDim.x; k++) {
      sum += A_s[k-ks] * B[N/2*k+j];
    }
  }
  C[N/2*i+j] = sum;
}

void errorcalc(float *A, float *B, float *C, int N){
  #pragma omp parallel for
  for (int i=0; i<N; i++)
    for (int k=0; k<N; k++)
      for (int j=0; j<N; j++)
        C[N*i+j] -= A[N*i+k] * B[N*k+j];
  double err = 0;
  for (int i=0; i<N; i++)
    for (int j=0; j<N; j++)
      err += fabs(C[N*i+j]);
  printf("error: %lf\n",err/N/N);
}

void errorcalc2(float *A, float *B, float *C, int N){
  #pragma omp parallel for
  for (int i=0; i<N/2; i++)
    for (int k=0; k<N; k++)
      for (int j=0; j<N/2; j++)
        C[N/2*i+j] -= A[N*i+k] * B[N/2*k+j];
  double err = 0;
  for (int i=0; i<N/2; i++)
    for (int j=0; j<N/2; j++)
      err += fabs(C[N/2*i+j]);
  printf("error: %lf\n",err/(N/2)/(N/2));
}

int main(int argc, char **argv) {
  int N = 2048;
  int M = 128;
  int size = N*N*sizeof(float);

  float A[N*N], B[N*N], C[N*N];
  for (int i=0; i<N; i++) {
    for (int j=0; j<N; j++) {
      A[N*i+j] = drand48();
      B[N*i+j] = drand48();
      C[N*i+j] = 0;
    }
  }

  float subA[4][N/2*N], subB[4][N*N/2], subC[4][N/2*N/2];
  float *subA_d[4], *subB_d[4], *subC_d[4];
  for (int i=0; i<N/2; i++) {
    for (int j=0; j<N; j++) {
      subA[0][N*i+j] = A[N*i+j];
      subA[1][N*i+j] = A[N*i+j];
      subA[2][N*i+j] = A[N*(i+N/2)+j];
      subA[3][N*i+j] = A[N*(i+N/2)+j];
      subB[0][N/2*j+i] = B[N*j+i];
      subB[1][N/2*j+i] = B[N*j+i];
      subB[2][N/2*j+i] = B[N*j+(i+N/2)];
      subB[3][N/2*j+i] = B[N*j+(i+N/2)];
    }
  }
  for (int i=0; i<N/2; i++) {
    for (int j=0; j<N/2; j++) {
      subC[0][N/2*i+j] = 0;
      subC[1][N/2*i+j] = 0;
      subC[2][N/2*i+j] = 0;
      subC[3][N/2*i+j] = 0;
    }
  }

  hipStream_t stream[4];
  for (int dev_id=0; dev_id<num_devs; dev_id++) {
    hipSetDevice(dev_id);
    hipStreamCreate(&stream[dev_id]);
    hipMalloc(&(subA_d[dev_id]),size/2);
    hipMalloc(&(subB_d[dev_id]),size/2);
    hipMalloc(&(subC_d[dev_id]),size/4);
		hipMemcpy(subA_d[dev_id],subA[dev_id],size/2,hipMemcpyHostToDevice);
		hipMemcpy(subB_d[dev_id],subB[dev_id],size/2,hipMemcpyHostToDevice);
		hipMemcpy(subC_d[dev_id],subC[dev_id],size/4,hipMemcpyHostToDevice);
  }

  auto tic = chrono::steady_clock::now();
  for (int dev_id = 0; dev_id < num_devs; dev_id++) {
    hipSetDevice(dev_id);
    dim3 grid(N/2/M, N/2);
    cudamatmul<<<grid,M,M*sizeof(float)>>>(subA_d[dev_id], subB_d[dev_id], subC_d[dev_id], N);
  }
  for (int dev_id = 0; dev_id < num_devs; dev_id++) {
    hipStreamSynchronize(stream[dev_id]);
  }
  
  for (int dev_id = 0; dev_id < num_devs; dev_id++) {
    hipSetDevice(dev_id);
    hipMemcpy(subC[dev_id],subC_d[dev_id],size/4,hipMemcpyDeviceToHost);
  }

  for (int i=0; i<N/2; i++) {
    for (int j=0; j<N/2; j++) {
      C[N*i+j] = subC[0][N/2*i+j];
      C[N*i+(j+N/2)] = subC[1][N/2*i+j];
      C[N*(i+N/2)+j] = subC[2][N/2*i+j];
      C[N*(i+N/2)+(j+N/2)] = subC[3][N/2*i+j];
    }
  }
  auto toc = chrono::steady_clock::now();
  double time = chrono::duration<double>(toc - tic).count();
  printf("N=%d: %lf s (%lf GFlops)\n",N,time,2.*N*N*N/time/1e9);

  /*
  for (int dev_id=0; dev_id<num_devs; dev_id++) {
    errorcalc2(subA[dev_id],subB[dev_id],subC[dev_id],N);
  }
  */

  errorcalc(A,B,C,N);
  
  for (int dev_id=0; dev_id<num_devs; dev_id++) {
    hipFree(subA_d[dev_id]);
    hipFree(subB_d[dev_id]);
    hipFree(subC_d[dev_id]);
  }
}

	.text
	.file	"multi_gpu.hip"
	.globl	_Z25__device_stub__cudamatmulPfS_S_i # -- Begin function _Z25__device_stub__cudamatmulPfS_S_i
	.type	_Z25__device_stub__cudamatmulPfS_S_i,@function
_Z25__device_stub__cudamatmulPfS_S_i:   # @_Z25__device_stub__cudamatmulPfS_S_i
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$112, %rsp
	.cfi_def_cfa_offset 160
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	32(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	24(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	4(%rsp), %rdx
	movl	%ecx, (%rdx)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	16(%rsp), %r12
	leaq	8(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z10cudamatmulPfS_S_i, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$128, %rsp
	.cfi_adjust_cfa_offset -128
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	_Z25__device_stub__cudamatmulPfS_S_i, .Lfunc_end0-_Z25__device_stub__cudamatmulPfS_S_i
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0                          # -- Begin function _Z9errorcalcPfS_S_i
.LCPI1_0:
	.long	0x7fffffff                      # float NaN
	.long	0x7fffffff                      # float NaN
	.long	0x7fffffff                      # float NaN
	.long	0x7fffffff                      # float NaN
	.text
	.globl	_Z9errorcalcPfS_S_i
	.type	_Z9errorcalcPfS_S_i,@function
_Z9errorcalcPfS_S_i:                    # @_Z9errorcalcPfS_S_i
	.cfi_startproc
# %bb.0:
	xorpd	%xmm0, %xmm0
	testl	%ecx, %ecx
	jle	.LBB1_13
# %bb.1:                                # %.preheader42.lr.ph
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r12
	.cfi_def_cfa_offset 32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset %rbx, -40
	.cfi_offset %r12, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movl	%ecx, %eax
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
.LBB1_2:                                # %.preheader41.lr.ph
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_3 Depth 2
                                        #       Child Loop BB1_4 Depth 3
	movl	%r8d, %r10d
	leaq	(%rdx,%r10,4), %r10
	movl	%r9d, %r11d
	imull	%ecx, %r11d
	leaq	(%rdi,%r11,4), %r11
	xorl	%ebx, %ebx
	xorl	%r14d, %r14d
.LBB1_3:                                # %.preheader41
                                        #   Parent Loop BB1_2 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB1_4 Depth 3
	movl	%ebx, %r15d
	leaq	(%rsi,%r15,4), %r15
	xorl	%r12d, %r12d
.LBB1_4:                                #   Parent Loop BB1_2 Depth=1
                                        #     Parent Loop BB1_3 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	movss	(%r11,%r14,4), %xmm1            # xmm1 = mem[0],zero,zero,zero
	mulss	(%r15,%r12,4), %xmm1
	movss	(%r10,%r12,4), %xmm2            # xmm2 = mem[0],zero,zero,zero
	subss	%xmm1, %xmm2
	movss	%xmm2, (%r10,%r12,4)
	incq	%r12
	cmpq	%r12, %rax
	jne	.LBB1_4
# %bb.5:                                # %._crit_edge
                                        #   in Loop: Header=BB1_3 Depth=2
	incq	%r14
	addl	%ecx, %ebx
	cmpq	%rax, %r14
	jne	.LBB1_3
# %bb.6:                                # %._crit_edge45
                                        #   in Loop: Header=BB1_2 Depth=1
	incq	%r9
	addl	%ecx, %r8d
	cmpq	%rax, %r9
	jne	.LBB1_2
# %bb.7:                                # %.preheader40
	testl	%ecx, %ecx
	jle	.LBB1_12
# %bb.8:                                # %.preheader.lr.ph
	xorpd	%xmm0, %xmm0
	xorl	%esi, %esi
	movaps	.LCPI1_0(%rip), %xmm1           # xmm1 = [NaN,NaN,NaN,NaN]
	xorl	%edi, %edi
.LBB1_9:                                # %.lr.ph49
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_10 Depth 2
	movl	%esi, %r8d
	leaq	(%rdx,%r8,4), %r8
	xorl	%r9d, %r9d
.LBB1_10:                               #   Parent Loop BB1_9 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movss	(%r8,%r9,4), %xmm2              # xmm2 = mem[0],zero,zero,zero
	andps	%xmm1, %xmm2
	cvtss2sd	%xmm2, %xmm2
	addsd	%xmm2, %xmm0
	incq	%r9
	cmpq	%r9, %rax
	jne	.LBB1_10
# %bb.11:                               # %._crit_edge50
                                        #   in Loop: Header=BB1_9 Depth=1
	incq	%rdi
	addl	%ecx, %esi
	cmpq	%rax, %rdi
	jne	.LBB1_9
.LBB1_12:
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%r12
	.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 %r14
	.cfi_restore %r15
.LBB1_13:                               # %._crit_edge53
	xorps	%xmm1, %xmm1
	cvtsi2sd	%ecx, %xmm1
	divsd	%xmm1, %xmm0
	divsd	%xmm1, %xmm0
	movl	$.L.str, %edi
	movb	$1, %al
	jmp	printf                          # TAILCALL
.Lfunc_end1:
	.size	_Z9errorcalcPfS_S_i, .Lfunc_end1-_Z9errorcalcPfS_S_i
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0                          # -- Begin function _Z10errorcalc2PfS_S_i
.LCPI2_0:
	.long	0x7fffffff                      # float NaN
	.long	0x7fffffff                      # float NaN
	.long	0x7fffffff                      # float NaN
	.long	0x7fffffff                      # float NaN
	.text
	.globl	_Z10errorcalc2PfS_S_i
	.type	_Z10errorcalc2PfS_S_i,@function
_Z10errorcalc2PfS_S_i:                  # @_Z10errorcalc2PfS_S_i
	.cfi_startproc
# %bb.0:
	movl	%ecx, %eax
	shrl	$31, %eax
	addl	%ecx, %eax
	sarl	%eax
	xorpd	%xmm0, %xmm0
	cmpl	$2, %ecx
	jl	.LBB2_13
# %bb.1:                                # %.preheader43.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
	.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	%eax, %r8d
	movl	%ecx, %r9d
	xorl	%r10d, %r10d
	xorl	%r11d, %r11d
.LBB2_2:                                # %.preheader42.lr.ph
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB2_3 Depth 2
                                        #       Child Loop BB2_4 Depth 3
	movl	%r10d, %ebx
	leaq	(%rdx,%rbx,4), %rbx
	movl	%r11d, %r14d
	imull	%ecx, %r14d
	leaq	(%rdi,%r14,4), %r14
	xorl	%ebp, %ebp
	xorl	%r15d, %r15d
.LBB2_3:                                # %.lr.ph
                                        #   Parent Loop BB2_2 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB2_4 Depth 3
	movl	%ebp, %r12d
	leaq	(%rsi,%r12,4), %r12
	xorl	%r13d, %r13d
.LBB2_4:                                #   Parent Loop BB2_2 Depth=1
                                        #     Parent Loop BB2_3 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	movss	(%r14,%r15,4), %xmm1            # xmm1 = mem[0],zero,zero,zero
	mulss	(%r12,%r13,4), %xmm1
	movss	(%rbx,%r13,4), %xmm2            # xmm2 = mem[0],zero,zero,zero
	subss	%xmm1, %xmm2
	movss	%xmm2, (%rbx,%r13,4)
	incq	%r13
	cmpq	%r13, %r8
	jne	.LBB2_4
# %bb.5:                                # %._crit_edge
                                        #   in Loop: Header=BB2_3 Depth=2
	incq	%r15
	addl	%eax, %ebp
	cmpq	%r9, %r15
	jne	.LBB2_3
# %bb.6:                                # %._crit_edge46
                                        #   in Loop: Header=BB2_2 Depth=1
	incq	%r11
	addl	%eax, %r10d
	cmpq	%r8, %r11
	jne	.LBB2_2
# %bb.7:                                # %.preheader41
	cmpl	$2, %ecx
	jl	.LBB2_12
# %bb.8:                                # %.preheader.lr.ph
	xorpd	%xmm0, %xmm0
	xorl	%ecx, %ecx
	movaps	.LCPI2_0(%rip), %xmm1           # xmm1 = [NaN,NaN,NaN,NaN]
	xorl	%esi, %esi
.LBB2_9:                                # %.lr.ph50
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB2_10 Depth 2
	movl	%ecx, %edi
	leaq	(%rdx,%rdi,4), %rdi
	xorl	%r9d, %r9d
.LBB2_10:                               #   Parent Loop BB2_9 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movss	(%rdi,%r9,4), %xmm2             # xmm2 = mem[0],zero,zero,zero
	andps	%xmm1, %xmm2
	cvtss2sd	%xmm2, %xmm2
	addsd	%xmm2, %xmm0
	incq	%r9
	cmpq	%r9, %r8
	jne	.LBB2_10
# %bb.11:                               # %._crit_edge51
                                        #   in Loop: Header=BB2_9 Depth=1
	incq	%rsi
	addl	%eax, %ecx
	cmpq	%r8, %rsi
	jne	.LBB2_9
.LBB2_12:
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	.cfi_restore %rbx
	.cfi_restore %r12
	.cfi_restore %r13
	.cfi_restore %r14
	.cfi_restore %r15
	.cfi_restore %rbp
.LBB2_13:                               # %._crit_edge55
	xorps	%xmm1, %xmm1
	cvtsi2sd	%eax, %xmm1
	divsd	%xmm1, %xmm0
	divsd	%xmm1, %xmm0
	movl	$.L.str, %edi
	movb	$1, %al
	jmp	printf                          # TAILCALL
.Lfunc_end2:
	.size	_Z10errorcalc2PfS_S_i, .Lfunc_end2-_Z10errorcalc2PfS_S_i
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI3_0:
	.quad	0x41cdcd6500000000              # double 1.0E+9
.LCPI3_1:
	.quad	0x4210000000000000              # double 17179869184
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset %rbp, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register %rbp
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$50331832, %rsp                 # imm = 0x30000B8
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	leaq	-16777440(%rbp), %rbx
	leaq	-33554656(%rbp), %r14
	leaq	-50331872(%rbp), %r15
	xorl	%r12d, %r12d
.LBB3_1:                                # %.preheader219
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB3_2 Depth 2
	xorl	%r13d, %r13d
.LBB3_2:                                #   Parent Loop BB3_1 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	callq	drand48
	cvtsd2ss	%xmm0, %xmm0
	movss	%xmm0, (%r15,%r13,4)
	callq	drand48
	cvtsd2ss	%xmm0, %xmm0
	movss	%xmm0, (%r14,%r13,4)
	movl	$0, (%rbx,%r13,4)
	incq	%r13
	cmpq	$2048, %r13                     # imm = 0x800
	jne	.LBB3_2
# %bb.3:                                #   in Loop: Header=BB3_1 Depth=1
	incq	%r12
	movl	$8192, %eax                     # imm = 0x2000
	addq	%rax, %rbx
	addq	%rax, %r14
	addq	%rax, %r15
	cmpq	$2048, %r12                     # imm = 0x800
	jne	.LBB3_1
# %bb.4:
	movq	%rsp, %rax
	leaq	-33554432(%rax), %rcx
	movq	%rcx, %r14
	movq	%rcx, %rsp
	movq	%rsp, %rcx
	leaq	-33554432(%rcx), %rdx
	movq	%rdx, %r13
	movq	%rdx, %rsp
	movq	%rsp, %r11
	addq	$-16777216, %r11                # imm = 0xFF000000
	movq	%r11, %rsp
	addq	$-8388608, %rax                 # imm = 0xFF800000
	addq	$-8388608, %rcx                 # imm = 0xFF800000
	leaq	-41943264(%rbp), %rdx
	leaq	-33550560(%rbp), %rsi
	xorl	%edi, %edi
	movl	$8192, %r8d                     # imm = 0x2000
.LBB3_5:                                # %.preheader218
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB3_6 Depth 2
	xorl	%r9d, %r9d
	xorl	%r10d, %r10d
.LBB3_6:                                #   Parent Loop BB3_5 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movss	-8388608(%rdx,%r10), %xmm0      # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, -25165824(%rax,%r10)
	movss	%xmm0, -16777216(%rax,%r10)
	movss	(%rdx,%r10), %xmm0              # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, -8388608(%rax,%r10)
	movss	%xmm0, (%rax,%r10)
	movss	-4096(%rsi,%r9,2), %xmm0        # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, -25165824(%rcx,%r9)
	movss	%xmm0, -16777216(%rcx,%r9)
	movss	(%rsi,%r9,2), %xmm0             # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, -8388608(%rcx,%r9)
	movss	%xmm0, (%rcx,%r9)
	addq	$4, %r10
	addq	$4096, %r9                      # imm = 0x1000
	cmpq	$8192, %r10                     # imm = 0x2000
	jne	.LBB3_6
# %bb.7:                                #   in Loop: Header=BB3_5 Depth=1
	incq	%rdi
	addq	%r8, %rdx
	addq	$4, %rsi
	addq	$4, %rcx
	addq	%r8, %rax
	cmpq	$1024, %rdi                     # imm = 0x400
	jne	.LBB3_5
# %bb.8:                                # %.preheader217
	leaq	12582912(%r11), %r12
	xorl	%eax, %eax
	movq	%r12, %rcx
	xorl	%edx, %edx
.LBB3_9:                                # %.preheader216
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB3_10 Depth 2
	xorl	%esi, %esi
.LBB3_10:                               #   Parent Loop BB3_9 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	%eax, -12582912(%rcx,%rsi,4)
	movl	%eax, -8388608(%rcx,%rsi,4)
	movl	%eax, -4194304(%rcx,%rsi,4)
	movl	%eax, (%rcx,%rsi,4)
	incq	%rsi
	cmpq	$1024, %rsi                     # imm = 0x400
	jne	.LBB3_10
# %bb.11:                               #   in Loop: Header=BB3_9 Depth=1
	incq	%rdx
	addq	$4096, %rcx                     # imm = 0x1000
	cmpq	$1024, %rdx                     # imm = 0x400
	jne	.LBB3_9
# %bb.12:
	xorl	%r15d, %r15d
	movq	%r11, -64(%rbp)                 # 8-byte Spill
	movq	%r11, -56(%rbp)                 # 8-byte Spill
	xorl	%ecx, %ecx
.LBB3_13:                               # =>This Inner Loop Header: Depth=1
	movl	%ecx, -44(%rbp)                 # 4-byte Spill
	movq	%r13, -80(%rbp)                 # 8-byte Spill
	movq	%r14, -88(%rbp)                 # 8-byte Spill
	movl	-44(%rbp), %edi                 # 4-byte Reload
	callq	hipSetDevice
	leaq	(%r15,%rbp), %rdi
	addq	$-224, %rdi
	callq	hipStreamCreate
	leaq	(%r15,%rbp), %rbx
	addq	$-192, %rbx
	movl	$8388608, %esi                  # imm = 0x800000
	movq	%rbx, %rdi
	callq	hipMalloc
	leaq	(%r15,%rbp), %r13
	addq	$-160, %r13
	movl	$8388608, %esi                  # imm = 0x800000
	movq	%r13, %rdi
	callq	hipMalloc
	leaq	(%r15,%rbp), %rdi
	addq	$-128, %rdi
	movq	%rdi, -72(%rbp)                 # 8-byte Spill
	movl	$4194304, %esi                  # imm = 0x400000
	callq	hipMalloc
	movq	(%rbx), %rdi
	movq	-88(%rbp), %r14                 # 8-byte Reload
	movl	$8388608, %edx                  # imm = 0x800000
	movq	%r14, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	movq	(%r13), %rdi
	movq	-80(%rbp), %r13                 # 8-byte Reload
	movl	$8388608, %edx                  # imm = 0x800000
	movq	%r13, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	movq	-72(%rbp), %rax                 # 8-byte Reload
	movq	(%rax), %rdi
	movl	$4194304, %edx                  # imm = 0x400000
	movq	-56(%rbp), %rbx                 # 8-byte Reload
	movq	%rbx, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	movl	-44(%rbp), %ecx                 # 4-byte Reload
	incl	%ecx
	addq	$8, %r15
	movl	$8388608, %eax                  # imm = 0x800000
	addq	%rax, %r14
	addq	%rax, %r13
	addq	$4194304, %rbx                  # imm = 0x400000
	movq	%rbx, -56(%rbp)                 # 8-byte Spill
	cmpq	$32, %r15
	jne	.LBB3_13
# %bb.14:
	xorl	%r15d, %r15d
	callq	_ZNSt6chrono3_V212steady_clock3nowEv
	movq	%rax, %r14
	movabsq	$4398046511112, %rbx            # imm = 0x40000000008
	movabsq	$4294967424, %r13               # imm = 0x100000080
.LBB3_15:                               # =>This Inner Loop Header: Depth=1
	movl	%r15d, %edi
	callq	hipSetDevice
	movl	$512, %r8d                      # imm = 0x200
	movq	%rbx, %rdi
	movl	$1, %esi
	movq	%r13, %rdx
	movl	$1, %ecx
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB3_17
# %bb.16:                               #   in Loop: Header=BB3_15 Depth=1
	movq	-192(%rbp,%r15,8), %rdi
	movq	-160(%rbp,%r15,8), %rsi
	movq	-128(%rbp,%r15,8), %rdx
	movl	$2048, %ecx                     # imm = 0x800
	callq	_Z25__device_stub__cudamatmulPfS_S_i
.LBB3_17:                               #   in Loop: Header=BB3_15 Depth=1
	incq	%r15
	cmpq	$4, %r15
	jne	.LBB3_15
# %bb.18:                               # %.preheader215.preheader
	xorl	%ebx, %ebx
.LBB3_19:                               # %.preheader215
                                        # =>This Inner Loop Header: Depth=1
	movq	-224(%rbp,%rbx,8), %rdi
	callq	hipStreamSynchronize
	incq	%rbx
	cmpq	$4, %rbx
	jne	.LBB3_19
# %bb.20:                               # %.preheader214.preheader
	xorl	%r15d, %r15d
	movq	-64(%rbp), %rbx                 # 8-byte Reload
.LBB3_21:                               # %.preheader214
                                        # =>This Inner Loop Header: Depth=1
	movl	%r15d, %edi
	callq	hipSetDevice
	movq	-128(%rbp,%r15,8), %rsi
	movl	$4194304, %edx                  # imm = 0x400000
	movq	%rbx, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	incq	%r15
	addq	$4194304, %rbx                  # imm = 0x400000
	cmpq	$4, %r15
	jne	.LBB3_21
# %bb.22:                               # %.preheader.preheader
	leaq	-8384736(%rbp), %rax
	xorl	%ecx, %ecx
.LBB3_23:                               # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB3_24 Depth 2
	xorl	%edx, %edx
.LBB3_24:                               #   Parent Loop BB3_23 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movss	-12582912(%r12,%rdx,4), %xmm0   # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, -8392704(%rax,%rdx,4)
	movss	-8388608(%r12,%rdx,4), %xmm0    # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, -8388608(%rax,%rdx,4)
	movss	-4194304(%r12,%rdx,4), %xmm0    # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, -4096(%rax,%rdx,4)
	movss	(%r12,%rdx,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, (%rax,%rdx,4)
	incq	%rdx
	cmpq	$1024, %rdx                     # imm = 0x400
	jne	.LBB3_24
# %bb.25:                               #   in Loop: Header=BB3_23 Depth=1
	incq	%rcx
	addq	$8192, %rax                     # imm = 0x2000
	addq	$4096, %r12                     # imm = 0x1000
	cmpq	$1024, %rcx                     # imm = 0x400
	jne	.LBB3_23
# %bb.26:
	callq	_ZNSt6chrono3_V212steady_clock3nowEv
	subq	%r14, %rax
	xorps	%xmm0, %xmm0
	cvtsi2sd	%rax, %xmm0
	movsd	.LCPI3_0(%rip), %xmm2           # xmm2 = mem[0],zero
	divsd	%xmm2, %xmm0
	movsd	.LCPI3_1(%rip), %xmm1           # xmm1 = mem[0],zero
	divsd	%xmm0, %xmm1
	divsd	%xmm2, %xmm1
	movl	$.L.str.1, %edi
	movl	$2048, %esi                     # imm = 0x800
	movb	$2, %al
	callq	printf
	leaq	-50331872(%rbp), %rdi
	leaq	-33554656(%rbp), %rsi
	leaq	-16777440(%rbp), %rdx
	movl	$2048, %ecx                     # imm = 0x800
	callq	_Z9errorcalcPfS_S_i
	xorl	%ebx, %ebx
.LBB3_27:                               # =>This Inner Loop Header: Depth=1
	movq	-192(%rbp,%rbx,8), %rdi
	callq	hipFree
	movq	-160(%rbp,%rbx,8), %rdi
	callq	hipFree
	movq	-128(%rbp,%rbx,8), %rdi
	callq	hipFree
	incq	%rbx
	cmpq	$4, %rbx
	jne	.LBB3_27
# %bb.28:
	xorl	%eax, %eax
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa %rsp, 8
	retq
.Lfunc_end3:
	.size	main, .Lfunc_end3-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	.LBB4_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB4_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z10cudamatmulPfS_S_i, %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_end4:
	.size	__hip_module_ctor, .Lfunc_end4-__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	.LBB5_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
.LBB5_2:
	retq
.Lfunc_end5:
	.size	__hip_module_dtor, .Lfunc_end5-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	_Z10cudamatmulPfS_S_i,@object   # @_Z10cudamatmulPfS_S_i
	.section	.rodata,"a",@progbits
	.globl	_Z10cudamatmulPfS_S_i
	.p2align	3, 0x0
_Z10cudamatmulPfS_S_i:
	.quad	_Z25__device_stub__cudamatmulPfS_S_i
	.size	_Z10cudamatmulPfS_S_i, 8

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"error: %lf\n"
	.size	.L.str, 12

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"N=%d: %lf s (%lf GFlops)\n"
	.size	.L.str.1, 26

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z10cudamatmulPfS_S_i"
	.size	.L__unnamed_1, 22

	.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 _Z25__device_stub__cudamatmulPfS_S_i
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z10cudamatmulPfS_S_i
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z10cudamatmulPfS_S_i   ; -- Begin function _Z10cudamatmulPfS_S_i
	.globl	_Z10cudamatmulPfS_S_i
	.p2align	8
	.type	_Z10cudamatmulPfS_S_i,@function
_Z10cudamatmulPfS_S_i:                  ; @_Z10cudamatmulPfS_S_i
; %bb.0:
	s_clause 0x3
	s_load_b32 s3, s[0:1], 0x2c
	s_load_b32 s2, s[0:1], 0x18
	s_load_b128 s[4:7], s[0:1], 0x0
	s_load_b64 s[0:1], s[0:1], 0x10
	s_waitcnt lgkmcnt(0)
	s_and_b32 s3, s3, 0xffff
	s_cmp_lt_i32 s2, 1
	v_mad_u64_u32 v[1:2], null, s14, s3, v[0:1]
	s_cbranch_scc1 .LBB0_6
; %bb.1:                                ; %.lr.ph34
	s_delay_alu instid0(VALU_DEP_1)
	v_mad_u64_u32 v[2:3], null, s15, s2, v[0:1]
	v_lshl_add_u32 v7, v0, 2, 0
	v_mov_b32_e32 v4, 0
	v_mov_b32_e32 v8, v1
	v_mov_b32_e32 v0, 0
	s_lshr_b32 s8, s2, 1
	s_mov_b32 s10, 0
	s_mul_i32 s9, s8, s3
.LBB0_2:                                ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB0_4 Depth 2
	s_mov_b32 s11, s10
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_3) | instid1(SALU_CYCLE_1)
	v_add_nc_u32_e32 v3, s11, v2
	s_barrier
	buffer_gl0_inv
	s_add_i32 s10, s10, s3
	s_cmp_ge_u32 s11, s10
	v_lshlrev_b64 v[5:6], 2, v[3:4]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v5, vcc_lo, s4, v5
	v_add_co_ci_u32_e32 v6, vcc_lo, s5, v6, vcc_lo
	global_load_b32 v3, v[5:6], off
	s_waitcnt vmcnt(0)
	ds_store_b32 v7, v3
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	s_cbranch_scc1 .LBB0_5
; %bb.3:                                ; %.lr.ph.preheader
                                        ;   in Loop: Header=BB0_2 Depth=1
	v_mov_b32_e32 v5, v8
	s_mov_b32 s11, 0
	s_mov_b32 s12, s3
.LBB0_4:                                ; %.lr.ph
                                        ;   Parent Loop BB0_2 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v6, 31, v5
	s_add_i32 s12, s12, -1
	v_lshlrev_b64 v[9:10], 2, v[5:6]
	v_dual_mov_b32 v6, s11 :: v_dual_add_nc_u32 v5, s8, v5
	s_add_i32 s11, s11, 4
	s_cmp_eq_u32 s12, 0
	ds_load_b32 v6, v6
	v_add_co_u32 v9, vcc_lo, s6, v9
	v_add_co_ci_u32_e32 v10, vcc_lo, s7, v10, vcc_lo
	global_load_b32 v3, v[9:10], off
	s_waitcnt vmcnt(0) lgkmcnt(0)
	v_fmac_f32_e32 v0, v6, v3
	s_cbranch_scc0 .LBB0_4
.LBB0_5:                                ; %.loopexit
                                        ;   in Loop: Header=BB0_2 Depth=1
	v_add_nc_u32_e32 v8, s9, v8
	s_cmp_lt_i32 s10, s2
	s_cbranch_scc1 .LBB0_2
	s_branch .LBB0_7
.LBB0_6:
	v_mov_b32_e32 v0, 0
.LBB0_7:                                ; %Flow53
	s_lshr_b32 s3, s2, 31
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_add_i32 s2, s2, s3
	s_ashr_i32 s2, s2, 1
	s_delay_alu instid0(VALU_DEP_2) | instid1(SALU_CYCLE_1)
	v_mad_u64_u32 v[2:3], null, s2, s15, v[1:2]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v3, 31, v2
	v_lshlrev_b64 v[1:2], 2, v[2:3]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v1, vcc_lo, s0, v1
	v_add_co_ci_u32_e32 v2, vcc_lo, s1, 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 _Z10cudamatmulPfS_S_i
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 288
		.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 0
		.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	_Z10cudamatmulPfS_S_i, .Lfunc_end0-_Z10cudamatmulPfS_S_i
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 392
; 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: 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:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         16
        .size:           8
        .value_kind:     global_buffer
      - .offset:         24
        .size:           4
        .value_kind:     by_value
      - .offset:         32
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         36
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         40
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         44
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         46
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         48
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         50
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         52
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         54
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         88
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         96
        .size:           2
        .value_kind:     hidden_grid_dims
      - .offset:         152
        .size:           4
        .value_kind:     hidden_dynamic_lds_size
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 288
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z10cudamatmulPfS_S_i
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z10cudamatmulPfS_S_i.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
