#include <sys/time.h>
#include <stdio.h>
#include <math.h>
//TODO for writing to file, will be deleted
#include <stdlib.h>
//TODO: could include later
//#include <device_launch_parameters.h>
#include <cuda_runtime.h>
//#include "../inc/helper_cuda.h"

#define GRID_YDIM 65535
// time stamp function in seconds
double getTimeStamp() {
 struct timeval tv ;
 gettimeofday( &tv, NULL ) ;
 return (double) tv.tv_usec/1000000 + tv.tv_sec ;
}
void initDataA(float* data, int nx, int ny){ 
 int i,j;
 for(i = 0; i < nx; i++){
  for(j = 0; j < ny; j++){
   data[i*ny + j] = (float) (i+j)/3.0;
  }
 }
}
void initDataB(float* data, int nx, int ny){ 
 int i,j;
 for(i = 0; i < nx; i++){
  for(j = 0; j < ny; j++){
   data[i*ny + j] = (float)3.14*(i+j);
  }
 }
}
void debugPrint(float* data, int nx, int ny){
 int i,j;
 for(i = 0; i < nx; i++){
  for(j = 0; j < ny; j++){
   printf("%f ",data[i*ny + j]);
  }
  printf("\n");
 }
 printf("\n");
}
// host side matrix addition
void h_addmat(float *A, float *B, float *C, int nx, int ny){
 int i;
 for(i = 0; i < nx*ny; i++){
  C[i] = A[i] + B[i];
 }
}
// device-side matrix addition
//__global__ void f_addmat( float *A, float *B, float *C, int nx, int ny ){
// // kernel code might look something like this
// // but you may want to pad the matrices and index into them accordingly
// int ix = threadIdx.x + blockIdx.x*blockDim.x ;
// int iy = threadIdx.y + blockIdx.y*blockDim.y ;
// int idx = iy*nx + ix ;
// if( (ix<nx) && (iy<ny) )
// C[idx] = A[idx] + B[idx] ;
//}
__global__ void f_addmat( float *A, float *B, float *C, int nx, int ny ){
 // kernel code might look something like this
 // but you may want to pad the matrices and index into them accordingly
 int ix = threadIdx.x + blockIdx.x*blockDim.x ;
 int iy = threadIdx.y + blockIdx.y*blockDim.y ;
 int idx = iy*blockDim.x*gridDim.x + ix ;
 if(idx<nx*ny)
 C[idx] = A[idx] + B[idx] ;
}
int main( int argc, char *argv[] ) {
 // get program arguments
 if( argc != 3) {
 printf("Error: wrong number of args\n") ;
 exit(1) ;
 }
 int nx = atoi( argv[1] ) ; // should check validity
 int ny = atoi( argv[2] ) ; // should check validity
 int noElems = nx*ny ;
 int bytes = noElems * sizeof(float) ;
 // but you may want to pad the matrices…

 // alloc memory host-side
 float *h_A = (float *) malloc( bytes ) ;
 float *h_B = (float *) malloc( bytes ) ;
 float *h_hC = (float *) malloc( bytes ) ; // host result
 float *h_dC = (float *) malloc( bytes ) ; // gpu result

 // init matrices with random data
 //initData( h_A, noElems ) ; initData( h_B, noElems ) ;
 initDataA(h_A, nx, ny);
 initDataB(h_B, nx, ny);
 // alloc memory dev-side
 float *d_A, *d_B, *d_C ;
 cudaMalloc( (void **) &d_A, bytes ) ;
 cudaMalloc( (void **) &d_B, bytes ) ;
 cudaMalloc( (void **) &d_C, bytes ) ;
 
 // invoke Kernel
 dim3 block( 32, 32 ) ; // you will want to configure this
 //int block = 64;
 //int grid = (noElems + block-1)/block;
 int gy = (int)sqrt(noElems);
 int gx = (noElems+gy-1)/gy;
 //printf("prev gx %d and gy %d\n",gx,gy);
 if(gy > GRID_YDIM){
  gx = (gx*gy+GRID_YDIM-1)/GRID_YDIM;
  gy = GRID_YDIM;
 }
 //printf("gx %d and gy %d\n",gx,gy);
 gx = (gx+block.x-1)/block.x;
 gy = (gy+block.y-1)/block.y;
 dim3 grid( gx, gy ) ;
 //cudaDeviceProp GPUprop;
 //cudaGetDeviceProperties(&GPUprop,0);
 //printf("maxgridsize x is %d\n",GPUprop.maxGridSize[0]);
 printf("noelems is %d\n",noElems);
 //printf("gridx is %d\n",grid);
 //printf("gridx is %d and grid y is %d\n",grid.x,grid.y);

 double timeStampA = getTimeStamp() ;
 //transfer data to dev
 cudaMemcpy( d_A, h_A, bytes, cudaMemcpyHostToDevice ) ;
 cudaMemcpy( d_B, h_B, bytes, cudaMemcpyHostToDevice ) ;
 // note that the transfers would be twice as fast if h_A and h_B
 // matrices are pinned
 double timeStampB = getTimeStamp() ;

 f_addmat<<<grid, block>>>( d_A, d_B, d_C, nx, ny ) ;
 cudaDeviceSynchronize() ;

 double timeStampC = getTimeStamp() ;
 //copy data back
 cudaMemcpy( h_dC, d_C, bytes, cudaMemcpyDeviceToHost ) ;
 double timeStampD = getTimeStamp() ;

 // free GPU resources
 cudaFree( d_A ) ; cudaFree( d_B ) ; cudaFree( d_C ) ;
 cudaDeviceReset() ;

 // check result
 h_addmat( h_A, h_B, h_hC, nx, ny ) ;
 
 // print out results
 if(!memcmp(h_hC,h_dC,nx*ny*sizeof(float))){
  //debugPrint(h_hC, nx, ny);
  //debugPrint(h_dC, nx, ny);
  FILE* fptr;
  fptr = fopen("time.log","a");
  fprintf(fptr,"%dX%d %.6f %.6f %.6f %.6f\n", nx, ny, timeStampD-timeStampA, timeStampB-timeStampA, timeStampC-timeStampB, timeStampD-timeStampC);
  fclose(fptr);
  printf("%.6f %.6f %.6f %.6f\n", timeStampD-timeStampA, timeStampB-timeStampA, timeStampC-timeStampB, timeStampD-timeStampC);
 }else{
  printf("Error: function failed.\n");
 }
}

	.file	"tmpxft_002e3872_00000000-6_main_v1_sqr_grid.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2035:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2035:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z12getTimeStampv
	.type	_Z12getTimeStampv, @function
_Z12getTimeStampv:
.LFB2027:
	.cfi_startproc
	endbr64
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	xorl	%esi, %esi
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rdi
	call	gettimeofday@PLT
	cvtsi2sdq	8(%rsp), %xmm1
	cvtsi2sdq	16(%rsp), %xmm0
	divsd	.LC0(%rip), %xmm0
	addsd	%xmm1, %xmm0
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	je	.L3
	call	__stack_chk_fail@PLT
.L3:
	addq	$40, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2027:
	.size	_Z12getTimeStampv, .-_Z12getTimeStampv
	.globl	_Z9initDataAPfii
	.type	_Z9initDataAPfii, @function
_Z9initDataAPfii:
.LFB2028:
	.cfi_startproc
	endbr64
	movss	.LC1(%rip), %xmm1
	xorl	%r8d, %r8d
	xorl	%ecx, %ecx
.L7:
	cmpl	%esi, %ecx
	jge	.L6
	movslq	%r8d, %rax
	leaq	(%rdi,%rax,4), %r9
	xorl	%eax, %eax
.L10:
	cmpl	%eax, %edx
	jle	.L11
	leal	(%rcx,%rax), %r10d
	cvtsi2ssl	%r10d, %xmm0
	divss	%xmm1, %xmm0
	movss	%xmm0, (%r9,%rax,4)
	incq	%rax
	jmp	.L10
.L11:
	incl	%ecx
	addl	%edx, %r8d
	jmp	.L7
.L6:
	ret
	.cfi_endproc
.LFE2028:
	.size	_Z9initDataAPfii, .-_Z9initDataAPfii
	.globl	_Z9initDataBPfii
	.type	_Z9initDataBPfii, @function
_Z9initDataBPfii:
.LFB2029:
	.cfi_startproc
	endbr64
	movss	.LC2(%rip), %xmm1
	xorl	%r8d, %r8d
	xorl	%ecx, %ecx
.L13:
	cmpl	%esi, %ecx
	jge	.L12
	movslq	%r8d, %rax
	leaq	(%rdi,%rax,4), %r9
	xorl	%eax, %eax
.L16:
	cmpl	%eax, %edx
	jle	.L17
	leal	(%rcx,%rax), %r10d
	cvtsi2ssl	%r10d, %xmm0
	mulss	%xmm1, %xmm0
	movss	%xmm0, (%r9,%rax,4)
	incq	%rax
	jmp	.L16
.L17:
	incl	%ecx
	addl	%edx, %r8d
	jmp	.L13
.L12:
	ret
	.cfi_endproc
.LFE2029:
	.size	_Z9initDataBPfii, .-_Z9initDataBPfii
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC3:
	.string	"%f "
.LC4:
	.string	"\n"
	.text
	.globl	_Z10debugPrintPfii
	.type	_Z10debugPrintPfii, @function
_Z10debugPrintPfii:
.LFB2030:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movl	%esi, %r14d
	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
	movq	%rdi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movl	%edx, %ebx
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
.L19:
	cmpl	%r14d, %r13d
	jge	.L21
	movslq	%r12d, %rax
	xorl	%r15d, %r15d
	leaq	0(%rbp,%rax,4), %rcx
.L22:
	cmpl	%r15d, %ebx
	jle	.L24
	leaq	.LC3(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	cvtss2sd	(%rcx,%r15,4), %xmm0
	movq	%rcx, 8(%rsp)
	incq	%r15
	call	__printf_chk@PLT
	movq	8(%rsp), %rcx
	jmp	.L22
.L24:
	leaq	.LC4(%rip), %rsi
	xorl	%eax, %eax
	incl	%r13d
	addl	%ebx, %r12d
	movl	$2, %edi
	call	__printf_chk@PLT
	jmp	.L19
.L21:
	addq	$24, %rsp
	.cfi_def_cfa_offset 56
	leaq	.LC4(%rip), %rsi
	movl	$2, %edi
	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
	jmp	__printf_chk@PLT
	.cfi_endproc
.LFE2030:
	.size	_Z10debugPrintPfii, .-_Z10debugPrintPfii
	.globl	_Z8h_addmatPfS_S_ii
	.type	_Z8h_addmatPfS_S_ii, @function
_Z8h_addmatPfS_S_ii:
.LFB2031:
	.cfi_startproc
	endbr64
	imull	%r8d, %ecx
	xorl	%eax, %eax
.L26:
	cmpl	%eax, %ecx
	jle	.L28
	movss	(%rdi,%rax,4), %xmm0
	addss	(%rsi,%rax,4), %xmm0
	movss	%xmm0, (%rdx,%rax,4)
	incq	%rax
	jmp	.L26
.L28:
	ret
	.cfi_endproc
.LFE2031:
	.size	_Z8h_addmatPfS_S_ii, .-_Z8h_addmatPfS_S_ii
	.globl	_Z33__device_stub__Z8f_addmatPfS_S_iiPfS_S_ii
	.type	_Z33__device_stub__Z8f_addmatPfS_S_iiPfS_S_ii, @function
_Z33__device_stub__Z8f_addmatPfS_S_iiPfS_S_ii:
.LFB2057:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movq	%rdi, 24(%rsp)
	leaq	48(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	60(%rsp), %rsi
	movq	%rdx, 8(%rsp)
	leaq	32(%rsp), %rdx
	movl	%ecx, 4(%rsp)
	leaq	40(%rsp), %rcx
	movl	%r8d, (%rsp)
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 56(%rsp)
	movq	%rax, 96(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 104(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	4(%rsp), %rax
	movq	%rax, 120(%rsp)
	movq	%rsp, %rax
	movq	%rax, 128(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 48(%rsp)
	movq	%rax, 60(%rsp)
	movl	$1, 68(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L29
	pushq	40(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z8f_addmatPfS_S_ii(%rip), %rdi
	pushq	40(%rsp)
	.cfi_def_cfa_offset 176
	movq	76(%rsp), %rcx
	movl	84(%rsp), %r8d
	movq	64(%rsp), %rsi
	movl	72(%rsp), %edx
	leaq	112(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 168
	popq	%rdx
	.cfi_def_cfa_offset 160
.L29:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L31
	call	__stack_chk_fail@PLT
.L31:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2057:
	.size	_Z33__device_stub__Z8f_addmatPfS_S_iiPfS_S_ii, .-_Z33__device_stub__Z8f_addmatPfS_S_iiPfS_S_ii
	.globl	_Z8f_addmatPfS_S_ii
	.type	_Z8f_addmatPfS_S_ii, @function
_Z8f_addmatPfS_S_ii:
.LFB2058:
	.cfi_startproc
	endbr64
	jmp	_Z33__device_stub__Z8f_addmatPfS_S_iiPfS_S_ii
	.cfi_endproc
.LFE2058:
	.size	_Z8f_addmatPfS_S_ii, .-_Z8f_addmatPfS_S_ii
	.section	.rodata.str1.1
.LC5:
	.string	"Error: wrong number of args\n"
.LC6:
	.string	"noelems is %d\n"
.LC7:
	.string	"a"
.LC8:
	.string	"time.log"
.LC9:
	.string	"%dX%d %.6f %.6f %.6f %.6f\n"
.LC10:
	.string	"%.6f %.6f %.6f %.6f\n"
.LC11:
	.string	"Error: function failed.\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2032:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$120, %rsp
	.cfi_def_cfa_offset 176
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	cmpl	$3, %edi
	je	.L35
	movl	$2, %edi
	leaq	.LC5(%rip), %rsi
	call	__printf_chk@PLT
	movl	$1, %edi
	call	exit@PLT
.L35:
	movq	8(%rsi), %rdi
	movq	%rsi, %rbx
	call	atoi@PLT
	movq	16(%rbx), %rdi
	movl	%eax, %ebp
	call	atoi@PLT
	movl	%ebp, %r13d
	imull	%eax, %r13d
	movl	%eax, %r12d
	leal	0(,%r13,4), %ebx
	movslq	%r13d, %r15
	movslq	%ebx, %rbx
	movq	%rbx, %rdi
	call	malloc@PLT
	movq	%rbx, %rdi
	movq	%rax, (%rsp)
	call	malloc@PLT
	movq	%rbx, %rdi
	movq	%rax, %r14
	call	malloc@PLT
	movq	%rbx, %rdi
	movq	%rax, 8(%rsp)
	call	malloc@PLT
	movq	(%rsp), %rdi
	movl	%r12d, %edx
	movl	%ebp, %esi
	movq	%rax, 16(%rsp)
	call	_Z9initDataAPfii
	movq	%r14, %rdi
	call	_Z9initDataBPfii
	leaq	56(%rsp), %rdi
	movq	%rbx, %rsi
	call	cudaMalloc@PLT
	leaq	64(%rsp), %rdi
	movq	%rbx, %rsi
	call	cudaMalloc@PLT
	leaq	72(%rsp), %rdi
	movq	%rbx, %rsi
	call	cudaMalloc@PLT
	cvtsi2sdl	%r13d, %xmm0
	movl	$1, 88(%rsp)
	call	sqrt@PLT
	cvttsd2sil	%xmm0, %ecx
	leal	-1(%rcx,%r13), %eax
	cltd
	idivl	%ecx
	cmpl	$65535, %ecx
	jle	.L36
	imull	%eax, %ecx
	leal	65534(%rcx), %eax
	movl	$65535, %ecx
	cltd
	idivl	%ecx
.L36:
	movl	$1, 100(%rsp)
	addl	$31, %eax
	addl	$31, %ecx
	movl	%r13d, %edx
	movl	$2, %edi
	shrl	$5, %eax
	shrl	$5, %ecx
	leaq	.LC6(%rip), %rsi
	movl	%eax, 92(%rsp)
	xorl	%eax, %eax
	movl	%ecx, 96(%rsp)
	call	__printf_chk@PLT
	call	_Z12getTimeStampv
	movq	(%rsp), %rsi
	movq	56(%rsp), %rdi
	movq	%rbx, %rdx
	movl	$1, %ecx
	movsd	%xmm0, 24(%rsp)
	call	cudaMemcpy@PLT
	movq	64(%rsp), %rdi
	movq	%rbx, %rdx
	movq	%r14, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	call	_Z12getTimeStampv
	movl	88(%rsp), %ecx
	movl	100(%rsp), %esi
	xorl	%r9d, %r9d
	movq	92(%rsp), %rdi
	xorl	%r8d, %r8d
	movsd	%xmm0, 32(%rsp)
	movabsq	$137438953504, %rdx
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L37
	movq	72(%rsp), %rdx
	movq	64(%rsp), %rsi
	movl	%r12d, %r8d
	movl	%ebp, %ecx
	movq	56(%rsp), %rdi
	call	_Z33__device_stub__Z8f_addmatPfS_S_iiPfS_S_ii
.L37:
	call	cudaDeviceSynchronize@PLT
	call	_Z12getTimeStampv
	movq	72(%rsp), %rsi
	movq	16(%rsp), %rdi
	movq	%rbx, %rdx
	movl	$2, %ecx
	movsd	%xmm0, 40(%rsp)
	call	cudaMemcpy@PLT
	call	_Z12getTimeStampv
	movq	56(%rsp), %rdi
	movq	%xmm0, %rbx
	call	cudaFree@PLT
	movq	64(%rsp), %rdi
	call	cudaFree@PLT
	movq	72(%rsp), %rdi
	call	cudaFree@PLT
	call	cudaDeviceReset@PLT
	movq	8(%rsp), %rdx
	movq	(%rsp), %rdi
	movl	%ebp, %ecx
	movq	%r14, %rsi
	movl	%r12d, %r8d
	call	_Z8h_addmatPfS_S_ii
	movq	16(%rsp), %rsi
	movq	8(%rsp), %rdi
	leaq	0(,%r15,4), %rdx
	call	memcmp@PLT
	testl	%eax, %eax
	jne	.L38
	leaq	.LC7(%rip), %rsi
	leaq	.LC8(%rip), %rdi
	call	fopen@PLT
	movq	%rbx, %xmm4
	subsd	24(%rsp), %xmm4
	movsd	40(%rsp), %xmm2
	movsd	32(%rsp), %xmm1
	movq	%rbx, %xmm3
	movq	%rax, %r13
	movl	%ebp, %ecx
	subsd	40(%rsp), %xmm3
	subsd	32(%rsp), %xmm2
	movl	%r12d, %r8d
	movq	%rax, %rdi
	subsd	24(%rsp), %xmm1
	movaps	%xmm4, %xmm0
	movl	$2, %esi
	movb	$4, %al
	leaq	.LC9(%rip), %rdx
	movq	%xmm4, %rbx
	movsd	%xmm3, 16(%rsp)
	movsd	%xmm2, 8(%rsp)
	movsd	%xmm1, (%rsp)
	call	__fprintf_chk@PLT
	movq	%r13, %rdi
	call	fclose@PLT
	movsd	16(%rsp), %xmm3
	movsd	8(%rsp), %xmm2
	movq	%rbx, %xmm0
	movsd	(%rsp), %xmm1
	leaq	.LC10(%rip), %rsi
	movl	$2, %edi
	movb	$4, %al
	call	__printf_chk@PLT
	jmp	.L39
.L38:
	leaq	.LC11(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L39:
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	je	.L40
	call	__stack_chk_fail@PLT
.L40:
	addq	$120, %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
.LFE2032:
	.size	main, .-main
	.section	.rodata.str1.1
.LC12:
	.string	"_Z8f_addmatPfS_S_ii"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2060:
	.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	.LC12(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z8f_addmatPfS_S_ii(%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
.LFE2060:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC0:
	.long	0
	.long	1093567616
	.section	.rodata.cst4,"aM",@progbits,4
	.align 4
.LC1:
	.long	1077936128
	.align 4
.LC2:
	.long	1078523331
	.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 <sys/time.h>
#include <stdio.h>
#include <math.h>
//TODO for writing to file, will be deleted
#include <stdlib.h>
//TODO: could include later
//#include <device_launch_parameters.h>
#include <hip/hip_runtime.h>
//#include "../inc/helper_cuda.h"

#define GRID_YDIM 65535
// time stamp function in seconds
double getTimeStamp() {
 struct timeval tv ;
 gettimeofday( &tv, NULL ) ;
 return (double) tv.tv_usec/1000000 + tv.tv_sec ;
}
void initDataA(float* data, int nx, int ny){ 
 int i,j;
 for(i = 0; i < nx; i++){
  for(j = 0; j < ny; j++){
   data[i*ny + j] = (float) (i+j)/3.0;
  }
 }
}
void initDataB(float* data, int nx, int ny){ 
 int i,j;
 for(i = 0; i < nx; i++){
  for(j = 0; j < ny; j++){
   data[i*ny + j] = (float)3.14*(i+j);
  }
 }
}
void debugPrint(float* data, int nx, int ny){
 int i,j;
 for(i = 0; i < nx; i++){
  for(j = 0; j < ny; j++){
   printf("%f ",data[i*ny + j]);
  }
  printf("\n");
 }
 printf("\n");
}
// host side matrix addition
void h_addmat(float *A, float *B, float *C, int nx, int ny){
 int i;
 for(i = 0; i < nx*ny; i++){
  C[i] = A[i] + B[i];
 }
}
// device-side matrix addition
//__global__ void f_addmat( float *A, float *B, float *C, int nx, int ny ){
// // kernel code might look something like this
// // but you may want to pad the matrices and index into them accordingly
// int ix = threadIdx.x + blockIdx.x*blockDim.x ;
// int iy = threadIdx.y + blockIdx.y*blockDim.y ;
// int idx = iy*nx + ix ;
// if( (ix<nx) && (iy<ny) )
// C[idx] = A[idx] + B[idx] ;
//}
__global__ void f_addmat( float *A, float *B, float *C, int nx, int ny ){
 // kernel code might look something like this
 // but you may want to pad the matrices and index into them accordingly
 int ix = threadIdx.x + blockIdx.x*blockDim.x ;
 int iy = threadIdx.y + blockIdx.y*blockDim.y ;
 int idx = iy*blockDim.x*gridDim.x + ix ;
 if(idx<nx*ny)
 C[idx] = A[idx] + B[idx] ;
}
int main( int argc, char *argv[] ) {
 // get program arguments
 if( argc != 3) {
 printf("Error: wrong number of args\n") ;
 exit(1) ;
 }
 int nx = atoi( argv[1] ) ; // should check validity
 int ny = atoi( argv[2] ) ; // should check validity
 int noElems = nx*ny ;
 int bytes = noElems * sizeof(float) ;
 // but you may want to pad the matrices…

 // alloc memory host-side
 float *h_A = (float *) malloc( bytes ) ;
 float *h_B = (float *) malloc( bytes ) ;
 float *h_hC = (float *) malloc( bytes ) ; // host result
 float *h_dC = (float *) malloc( bytes ) ; // gpu result

 // init matrices with random data
 //initData( h_A, noElems ) ; initData( h_B, noElems ) ;
 initDataA(h_A, nx, ny);
 initDataB(h_B, nx, ny);
 // alloc memory dev-side
 float *d_A, *d_B, *d_C ;
 hipMalloc( (void **) &d_A, bytes ) ;
 hipMalloc( (void **) &d_B, bytes ) ;
 hipMalloc( (void **) &d_C, bytes ) ;
 
 // invoke Kernel
 dim3 block( 32, 32 ) ; // you will want to configure this
 //int block = 64;
 //int grid = (noElems + block-1)/block;
 int gy = (int)sqrt(noElems);
 int gx = (noElems+gy-1)/gy;
 //printf("prev gx %d and gy %d\n",gx,gy);
 if(gy > GRID_YDIM){
  gx = (gx*gy+GRID_YDIM-1)/GRID_YDIM;
  gy = GRID_YDIM;
 }
 //printf("gx %d and gy %d\n",gx,gy);
 gx = (gx+block.x-1)/block.x;
 gy = (gy+block.y-1)/block.y;
 dim3 grid( gx, gy ) ;
 //cudaDeviceProp GPUprop;
 //cudaGetDeviceProperties(&GPUprop,0);
 //printf("maxgridsize x is %d\n",GPUprop.maxGridSize[0]);
 printf("noelems is %d\n",noElems);
 //printf("gridx is %d\n",grid);
 //printf("gridx is %d and grid y is %d\n",grid.x,grid.y);

 double timeStampA = getTimeStamp() ;
 //transfer data to dev
 hipMemcpy( d_A, h_A, bytes, hipMemcpyHostToDevice ) ;
 hipMemcpy( d_B, h_B, bytes, hipMemcpyHostToDevice ) ;
 // note that the transfers would be twice as fast if h_A and h_B
 // matrices are pinned
 double timeStampB = getTimeStamp() ;

 f_addmat<<<grid, block>>>( d_A, d_B, d_C, nx, ny ) ;
 hipDeviceSynchronize() ;

 double timeStampC = getTimeStamp() ;
 //copy data back
 hipMemcpy( h_dC, d_C, bytes, hipMemcpyDeviceToHost ) ;
 double timeStampD = getTimeStamp() ;

 // free GPU resources
 hipFree( d_A ) ; hipFree( d_B ) ; hipFree( d_C ) ;
 hipDeviceReset() ;

 // check result
 h_addmat( h_A, h_B, h_hC, nx, ny ) ;
 
 // print out results
 if(!memcmp(h_hC,h_dC,nx*ny*sizeof(float))){
  //debugPrint(h_hC, nx, ny);
  //debugPrint(h_dC, nx, ny);
  FILE* fptr;
  fptr = fopen("time.log","a");
  fprintf(fptr,"%dX%d %.6f %.6f %.6f %.6f\n", nx, ny, timeStampD-timeStampA, timeStampB-timeStampA, timeStampC-timeStampB, timeStampD-timeStampC);
  fclose(fptr);
  printf("%.6f %.6f %.6f %.6f\n", timeStampD-timeStampA, timeStampB-timeStampA, timeStampC-timeStampB, timeStampD-timeStampC);
 }else{
  printf("Error: function failed.\n");
 }
}

	.text
	.file	"main_v1_sqr_grid.hip"
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z12getTimeStampv
.LCPI0_0:
	.quad	0x412e848000000000              # double 1.0E+6
	.text
	.globl	_Z12getTimeStampv
	.type	_Z12getTimeStampv,@function
_Z12getTimeStampv:                      # @_Z12getTimeStampv
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$16, %rsp
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -16
	movq	%rsp, %rbx
	movq	%rbx, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	cvtsi2sdq	8(%rbx), %xmm1
	divsd	.LCPI0_0(%rip), %xmm1
	cvtsi2sdq	(%rbx), %xmm0
	addsd	%xmm1, %xmm0
	addq	$16, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	_Z12getTimeStampv, .Lfunc_end0-_Z12getTimeStampv
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function _Z9initDataAPfii
.LCPI1_0:
	.long	0x40400000                      # float 3
	.text
	.globl	_Z9initDataAPfii
	.type	_Z9initDataAPfii,@function
_Z9initDataAPfii:                       # @_Z9initDataAPfii
	.cfi_startproc
# %bb.0:
	testl	%esi, %esi
	jle	.LBB1_6
# %bb.1:                                # %.preheader.lr.ph
	movl	%esi, %eax
	movl	%edx, %ecx
	xorl	%esi, %esi
	movss	.LCPI1_0(%rip), %xmm0           # xmm0 = mem[0],zero,zero,zero
	xorl	%r8d, %r8d
.LBB1_2:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_4 Depth 2
	testl	%edx, %edx
	jle	.LBB1_5
# %bb.3:                                # %.lr.ph
                                        #   in Loop: Header=BB1_2 Depth=1
	movl	%esi, %r9d
	leaq	(%rdi,%r9,4), %r9
	xorl	%r10d, %r10d
.LBB1_4:                                #   Parent Loop BB1_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	leal	(%r8,%r10), %r11d
	xorps	%xmm1, %xmm1
	cvtsi2ss	%r11d, %xmm1
	divss	%xmm0, %xmm1
	movss	%xmm1, (%r9,%r10,4)
	incq	%r10
	cmpq	%r10, %rcx
	jne	.LBB1_4
.LBB1_5:                                # %._crit_edge
                                        #   in Loop: Header=BB1_2 Depth=1
	incq	%r8
	addl	%edx, %esi
	cmpq	%rax, %r8
	jne	.LBB1_2
.LBB1_6:                                # %._crit_edge15
	retq
.Lfunc_end1:
	.size	_Z9initDataAPfii, .Lfunc_end1-_Z9initDataAPfii
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function _Z9initDataBPfii
.LCPI2_0:
	.long	0x4048f5c3                      # float 3.1400001
	.text
	.globl	_Z9initDataBPfii
	.type	_Z9initDataBPfii,@function
_Z9initDataBPfii:                       # @_Z9initDataBPfii
	.cfi_startproc
# %bb.0:
	testl	%esi, %esi
	jle	.LBB2_6
# %bb.1:                                # %.preheader.lr.ph
	movl	%esi, %eax
	movl	%edx, %ecx
	xorl	%esi, %esi
	movss	.LCPI2_0(%rip), %xmm0           # xmm0 = mem[0],zero,zero,zero
	xorl	%r8d, %r8d
.LBB2_2:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB2_4 Depth 2
	testl	%edx, %edx
	jle	.LBB2_5
# %bb.3:                                # %.lr.ph
                                        #   in Loop: Header=BB2_2 Depth=1
	movl	%esi, %r9d
	leaq	(%rdi,%r9,4), %r9
	xorl	%r10d, %r10d
.LBB2_4:                                #   Parent Loop BB2_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	leal	(%r8,%r10), %r11d
	xorps	%xmm1, %xmm1
	cvtsi2ss	%r11d, %xmm1
	mulss	%xmm0, %xmm1
	movss	%xmm1, (%r9,%r10,4)
	incq	%r10
	cmpq	%r10, %rcx
	jne	.LBB2_4
.LBB2_5:                                # %._crit_edge
                                        #   in Loop: Header=BB2_2 Depth=1
	incq	%r8
	addl	%edx, %esi
	cmpq	%rax, %r8
	jne	.LBB2_2
.LBB2_6:                                # %._crit_edge15
	retq
.Lfunc_end2:
	.size	_Z9initDataBPfii, .Lfunc_end2-_Z9initDataBPfii
	.cfi_endproc
                                        # -- End function
	.globl	_Z10debugPrintPfii              # -- Begin function _Z10debugPrintPfii
	.type	_Z10debugPrintPfii,@function
_Z10debugPrintPfii:                     # @_Z10debugPrintPfii
	.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	%rdi, 8(%rsp)                   # 8-byte Spill
	testl	%esi, %esi
	jle	.LBB3_6
# %bb.1:                                # %.preheader.lr.ph
	movl	%edx, %ebx
	movl	%esi, %eax
	movq	%rax, 16(%rsp)                  # 8-byte Spill
	movl	%edx, %r12d
	xorl	%r13d, %r13d
	xorl	%ebp, %ebp
.LBB3_2:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB3_4 Depth 2
	testl	%ebx, %ebx
	jle	.LBB3_5
# %bb.3:                                # %.lr.ph
                                        #   in Loop: Header=BB3_2 Depth=1
	movl	%r13d, %eax
	movq	8(%rsp), %rcx                   # 8-byte Reload
	leaq	(%rcx,%rax,4), %r14
	xorl	%r15d, %r15d
.LBB3_4:                                #   Parent Loop BB3_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	xorps	%xmm0, %xmm0
	cvtss2sd	(%r14,%r15,4), %xmm0
	movl	$.L.str, %edi
	movb	$1, %al
	callq	printf
	incq	%r15
	cmpq	%r15, %r12
	jne	.LBB3_4
.LBB3_5:                                # %._crit_edge
                                        #   in Loop: Header=BB3_2 Depth=1
	movl	$10, %edi
	callq	putchar@PLT
	incq	%rbp
	addl	%ebx, %r13d
	cmpq	16(%rsp), %rbp                  # 8-byte Folded Reload
	jne	.LBB3_2
.LBB3_6:                                # %._crit_edge14
	movl	$10, %edi
	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
	jmp	putchar@PLT                     # TAILCALL
.Lfunc_end3:
	.size	_Z10debugPrintPfii, .Lfunc_end3-_Z10debugPrintPfii
	.cfi_endproc
                                        # -- End function
	.globl	_Z8h_addmatPfS_S_ii             # -- Begin function _Z8h_addmatPfS_S_ii
	.type	_Z8h_addmatPfS_S_ii,@function
_Z8h_addmatPfS_S_ii:                    # @_Z8h_addmatPfS_S_ii
	.cfi_startproc
# %bb.0:
	imull	%r8d, %ecx
	testl	%ecx, %ecx
	jle	.LBB4_3
# %bb.1:                                # %.lr.ph.preheader
	movl	%ecx, %eax
	xorl	%ecx, %ecx
.LBB4_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movss	(%rdi,%rcx,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	addss	(%rsi,%rcx,4), %xmm0
	movss	%xmm0, (%rdx,%rcx,4)
	incq	%rcx
	cmpq	%rcx, %rax
	jne	.LBB4_2
.LBB4_3:                                # %._crit_edge
	retq
.Lfunc_end4:
	.size	_Z8h_addmatPfS_S_ii, .Lfunc_end4-_Z8h_addmatPfS_S_ii
	.cfi_endproc
                                        # -- End function
	.globl	_Z23__device_stub__f_addmatPfS_S_ii # -- Begin function _Z23__device_stub__f_addmatPfS_S_ii
	.type	_Z23__device_stub__f_addmatPfS_S_ii,@function
_Z23__device_stub__f_addmatPfS_S_ii:    # @_Z23__device_stub__f_addmatPfS_S_ii
	.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	$128, %rsp
	.cfi_def_cfa_offset 176
	.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)
	movq	%rsp, %rcx
	movl	%r8d, (%rcx)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	movq	%rcx, 32(%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	$_Z8f_addmatPfS_S_ii, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$144, %rsp
	.cfi_adjust_cfa_offset -144
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end5:
	.size	_Z23__device_stub__f_addmatPfS_S_ii, .Lfunc_end5-_Z23__device_stub__f_addmatPfS_S_ii
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function main
.LCPI6_0:
	.long	0x40400000                      # float 3
.LCPI6_1:
	.long	0x4048f5c3                      # float 3.1400001
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0
.LCPI6_2:
	.quad	0x412e848000000000              # double 1.0E+6
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$136, %rsp
	.cfi_def_cfa_offset 192
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	cmpl	$3, %edi
	jne	.LBB6_26
# %bb.1:
	movq	%rsi, %rbx
	movq	8(%rsi), %rdi
	callq	atoi
	movl	%eax, %r14d
	movq	16(%rbx), %rdi
	callq	atoi
	movl	%eax, %ebp
	imull	%r14d, %eax
	movq	%rax, 24(%rsp)                  # 8-byte Spill
	movslq	%eax, %r13
	movq	%r13, 80(%rsp)                  # 8-byte Spill
	shlq	$34, %r13
	sarq	$32, %r13
	movq	%r13, %rdi
	callq	malloc
	movq	%rax, %r15
	movq	%r13, %rdi
	callq	malloc
	movq	%rax, %r12
	movq	%r13, %rdi
	callq	malloc
	movq	%rax, %rbx
	movq	%r13, (%rsp)                    # 8-byte Spill
	movq	%r13, %rdi
	callq	malloc
	movq	%rax, 72(%rsp)                  # 8-byte Spill
	testl	%r14d, %r14d
	jle	.LBB6_12
# %bb.2:                                # %.preheader.lr.ph.i
	movl	%r14d, %eax
	movl	%ebp, %ecx
	xorl	%edx, %edx
	movss	.LCPI6_0(%rip), %xmm0           # xmm0 = mem[0],zero,zero,zero
	xorl	%esi, %esi
.LBB6_3:                                # %.preheader.i
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB6_5 Depth 2
	testl	%ebp, %ebp
	jle	.LBB6_6
# %bb.4:                                # %.lr.ph.i
                                        #   in Loop: Header=BB6_3 Depth=1
	movl	%edx, %edi
	leaq	(%r15,%rdi,4), %rdi
	xorl	%r8d, %r8d
.LBB6_5:                                #   Parent Loop BB6_3 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	leal	(%rsi,%r8), %r9d
	xorps	%xmm1, %xmm1
	cvtsi2ss	%r9d, %xmm1
	divss	%xmm0, %xmm1
	movss	%xmm1, (%rdi,%r8,4)
	incq	%r8
	cmpq	%r8, %rcx
	jne	.LBB6_5
.LBB6_6:                                # %._crit_edge.i
                                        #   in Loop: Header=BB6_3 Depth=1
	incq	%rsi
	addl	%ebp, %edx
	cmpq	%rax, %rsi
	jne	.LBB6_3
# %bb.7:                                # %.preheader.i82.preheader
	xorl	%edx, %edx
	movss	.LCPI6_1(%rip), %xmm0           # xmm0 = mem[0],zero,zero,zero
	xorl	%esi, %esi
.LBB6_8:                                # %.preheader.i82
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB6_10 Depth 2
	testl	%ebp, %ebp
	jle	.LBB6_11
# %bb.9:                                # %.lr.ph.i87
                                        #   in Loop: Header=BB6_8 Depth=1
	movl	%edx, %edi
	leaq	(%r12,%rdi,4), %rdi
	xorl	%r8d, %r8d
.LBB6_10:                               #   Parent Loop BB6_8 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	leal	(%rsi,%r8), %r9d
	xorps	%xmm1, %xmm1
	cvtsi2ss	%r9d, %xmm1
	mulss	%xmm0, %xmm1
	movss	%xmm1, (%rdi,%r8,4)
	incq	%r8
	cmpq	%r8, %rcx
	jne	.LBB6_10
.LBB6_11:                               # %._crit_edge.i84
                                        #   in Loop: Header=BB6_8 Depth=1
	incq	%rsi
	addl	%ebp, %edx
	cmpq	%rax, %rsi
	jne	.LBB6_8
.LBB6_12:                               # %_Z9initDataBPfii.exit
	leaq	56(%rsp), %rdi
	movq	(%rsp), %r13                    # 8-byte Reload
	movq	%r13, %rsi
	callq	hipMalloc
	leaq	48(%rsp), %rdi
	movq	%r13, %rsi
	callq	hipMalloc
	leaq	40(%rsp), %rdi
	movq	%r13, %rsi
	callq	hipMalloc
	movq	24(%rsp), %rsi                  # 8-byte Reload
	xorps	%xmm0, %xmm0
	cvtsi2sd	%esi, %xmm0
	xorps	%xmm1, %xmm1
	ucomisd	%xmm1, %xmm0
	movl	%r14d, 68(%rsp)                 # 4-byte Spill
	jb	.LBB6_14
# %bb.13:
	sqrtsd	%xmm0, %xmm0
	jmp	.LBB6_15
.LBB6_14:                               # %call.sqrt
	callq	sqrt
	movq	24(%rsp), %rsi                  # 8-byte Reload
.LBB6_15:                               # %_Z9initDataBPfii.exit.split
	cvttsd2si	%xmm0, %r13d
	leal	(%rsi,%r13), %eax
	decl	%eax
	cltd
	idivl	%r13d
                                        # kill: def $eax killed $eax def $rax
	cmpl	$65536, %r13d                   # imm = 0x10000
	jl	.LBB6_17
# %bb.16:
	imull	%r13d, %eax
	movl	%eax, %ecx
	addl	$65534, %ecx                    # imm = 0xFFFE
	movslq	%ecx, %rcx
	imulq	$-2147450879, %rcx, %rcx        # imm = 0x80008001
	shrq	$32, %rcx
	addl	%ecx, %eax
	addl	$65534, %eax                    # imm = 0xFFFE
	movl	%eax, %ecx
	shrl	$31, %ecx
	sarl	$15, %eax
	addl	%ecx, %eax
	movl	$65535, %r13d                   # imm = 0xFFFF
.LBB6_17:
	addl	$31, %eax
	shrl	$5, %eax
	addl	$31, %r13d
	shrl	$5, %r13d
	shlq	$32, %r13
	orq	%rax, %r13
	movl	$.L.str.3, %edi
                                        # kill: def $esi killed $esi killed $rsi
	xorl	%eax, %eax
	callq	printf
	leaq	120(%rsp), %r14
	movq	%r14, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	xorps	%xmm0, %xmm0
	cvtsi2sdq	8(%r14), %xmm0
	movsd	%xmm0, 32(%rsp)                 # 8-byte Spill
	xorps	%xmm0, %xmm0
	cvtsi2sdq	(%r14), %xmm0
	movsd	%xmm0, 112(%rsp)                # 8-byte Spill
	movq	56(%rsp), %rdi
	movq	%r15, %rsi
	movq	(%rsp), %r14                    # 8-byte Reload
	movq	%r14, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	48(%rsp), %rdi
	movq	%r12, %rsi
	movq	%r14, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	leaq	120(%rsp), %r14
	movq	%r14, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	xorps	%xmm0, %xmm0
	cvtsi2sdq	8(%r14), %xmm0
	movsd	%xmm0, 16(%rsp)                 # 8-byte Spill
	xorps	%xmm0, %xmm0
	cvtsi2sdq	(%r14), %xmm0
	movsd	%xmm0, 104(%rsp)                # 8-byte Spill
	movabsq	$137438953504, %rdx             # imm = 0x2000000020
	movq	%r13, %rdi
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	movl	68(%rsp), %r13d                 # 4-byte Reload
	jne	.LBB6_19
# %bb.18:
	movq	56(%rsp), %rdi
	movq	48(%rsp), %rsi
	movq	40(%rsp), %rdx
	movl	%r13d, %ecx
	movl	%ebp, %r8d
	callq	_Z23__device_stub__f_addmatPfS_S_ii
.LBB6_19:
	shlq	$2, 80(%rsp)                    # 8-byte Folded Spill
	callq	hipDeviceSynchronize
	leaq	120(%rsp), %r14
	movq	%r14, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	xorps	%xmm0, %xmm0
	cvtsi2sdq	8(%r14), %xmm0
	movsd	%xmm0, 8(%rsp)                  # 8-byte Spill
	xorps	%xmm0, %xmm0
	cvtsi2sdq	(%r14), %xmm0
	movsd	%xmm0, 96(%rsp)                 # 8-byte Spill
	movq	40(%rsp), %rsi
	movq	72(%rsp), %rdi                  # 8-byte Reload
	movq	(%rsp), %rdx                    # 8-byte Reload
	movl	$2, %ecx
	callq	hipMemcpy
	leaq	120(%rsp), %r14
	movq	%r14, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	xorps	%xmm0, %xmm0
	cvtsi2sdq	8(%r14), %xmm0
	movsd	%xmm0, (%rsp)                   # 8-byte Spill
	xorps	%xmm0, %xmm0
	cvtsi2sdq	(%r14), %xmm0
	movsd	%xmm0, 88(%rsp)                 # 8-byte Spill
	movq	56(%rsp), %rdi
	callq	hipFree
	movq	48(%rsp), %rdi
	callq	hipFree
	movq	40(%rsp), %rdi
	callq	hipFree
	callq	hipDeviceReset
	movq	24(%rsp), %rax                  # 8-byte Reload
	testl	%eax, %eax
	jle	.LBB6_22
# %bb.20:                               # %.lr.ph.preheader.i
	movl	%eax, %eax
	xorl	%ecx, %ecx
.LBB6_21:                               # %.lr.ph.i95
                                        # =>This Inner Loop Header: Depth=1
	movss	(%r15,%rcx,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	addss	(%r12,%rcx,4), %xmm0
	movss	%xmm0, (%rbx,%rcx,4)
	incq	%rcx
	cmpq	%rcx, %rax
	jne	.LBB6_21
.LBB6_22:                               # %_Z8h_addmatPfS_S_ii.exit
	movq	%rbx, %rdi
	movq	72(%rsp), %rsi                  # 8-byte Reload
	movq	80(%rsp), %rdx                  # 8-byte Reload
	callq	bcmp@PLT
	testl	%eax, %eax
	je	.LBB6_23
# %bb.24:
	movl	$.Lstr, %edi
	callq	puts@PLT
	jmp	.LBB6_25
.LBB6_23:
	movsd	.LCPI6_2(%rip), %xmm0           # xmm0 = mem[0],zero
	movsd	32(%rsp), %xmm1                 # 8-byte Reload
                                        # xmm1 = mem[0],zero
	divsd	%xmm0, %xmm1
	addsd	112(%rsp), %xmm1                # 8-byte Folded Reload
	movsd	%xmm1, 32(%rsp)                 # 8-byte Spill
	movsd	16(%rsp), %xmm1                 # 8-byte Reload
                                        # xmm1 = mem[0],zero
	divsd	%xmm0, %xmm1
	addsd	104(%rsp), %xmm1                # 8-byte Folded Reload
	movsd	%xmm1, 16(%rsp)                 # 8-byte Spill
	movsd	8(%rsp), %xmm1                  # 8-byte Reload
                                        # xmm1 = mem[0],zero
	divsd	%xmm0, %xmm1
	addsd	96(%rsp), %xmm1                 # 8-byte Folded Reload
	movsd	%xmm1, 8(%rsp)                  # 8-byte Spill
	movsd	(%rsp), %xmm1                   # 8-byte Reload
                                        # xmm1 = mem[0],zero
	divsd	%xmm0, %xmm1
	addsd	88(%rsp), %xmm1                 # 8-byte Folded Reload
	movsd	%xmm1, (%rsp)                   # 8-byte Spill
	movl	$.L.str.4, %edi
	movl	$.L.str.5, %esi
	callq	fopen
	movq	%rax, %rbx
	movsd	(%rsp), %xmm2                   # 8-byte Reload
                                        # xmm2 = mem[0],zero
	movapd	%xmm2, %xmm1
	movsd	32(%rsp), %xmm4                 # 8-byte Reload
                                        # xmm4 = mem[0],zero
	subsd	%xmm4, %xmm1
	movapd	%xmm1, %xmm0
	movsd	%xmm1, 24(%rsp)                 # 8-byte Spill
	movsd	8(%rsp), %xmm1                  # 8-byte Reload
                                        # xmm1 = mem[0],zero
	subsd	%xmm1, %xmm2
	movapd	%xmm2, %xmm3
	movsd	%xmm2, (%rsp)                   # 8-byte Spill
	movsd	16(%rsp), %xmm5                 # 8-byte Reload
                                        # xmm5 = mem[0],zero
	subsd	%xmm5, %xmm1
	movapd	%xmm1, %xmm2
	movsd	%xmm1, 8(%rsp)                  # 8-byte Spill
	subsd	%xmm4, %xmm5
	movapd	%xmm5, %xmm1
	movsd	%xmm5, 16(%rsp)                 # 8-byte Spill
	movl	$.L.str.6, %esi
	movq	%rax, %rdi
	movl	%r13d, %edx
	movl	%ebp, %ecx
	movb	$4, %al
	callq	fprintf
	movq	%rbx, %rdi
	callq	fclose
	movl	$.L.str.7, %edi
	movsd	24(%rsp), %xmm0                 # 8-byte Reload
                                        # xmm0 = mem[0],zero
	movsd	16(%rsp), %xmm1                 # 8-byte Reload
                                        # xmm1 = mem[0],zero
	movsd	8(%rsp), %xmm2                  # 8-byte Reload
                                        # xmm2 = mem[0],zero
	movsd	(%rsp), %xmm3                   # 8-byte Reload
                                        # xmm3 = mem[0],zero
	movb	$4, %al
	callq	printf
.LBB6_25:
	xorl	%eax, %eax
	addq	$136, %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
.LBB6_26:
	.cfi_def_cfa_offset 192
	movl	$.Lstr.1, %edi
	callq	puts@PLT
	movl	$1, %edi
	callq	exit
.Lfunc_end6:
	.size	main, .Lfunc_end6-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	.LBB7_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB7_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z8f_addmatPfS_S_ii, %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_end7:
	.size	__hip_module_ctor, .Lfunc_end7-__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	.LBB8_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
.LBB8_2:
	retq
.Lfunc_end8:
	.size	__hip_module_dtor, .Lfunc_end8-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"%f "
	.size	.L.str, 4

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

	.type	.L.str.3,@object                # @.str.3
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.3:
	.asciz	"noelems is %d\n"
	.size	.L.str.3, 15

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"time.log"
	.size	.L.str.4, 9

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"a"
	.size	.L.str.5, 2

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"%dX%d %.6f %.6f %.6f %.6f\n"
	.size	.L.str.6, 27

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"%.6f %.6f %.6f %.6f\n"
	.size	.L.str.7, 21

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z8f_addmatPfS_S_ii"
	.size	.L__unnamed_1, 20

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

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

	.type	.Lstr,@object                   # @str
	.section	.rodata.str1.1,"aMS",@progbits,1
.Lstr:
	.asciz	"Error: function failed."
	.size	.Lstr, 24

	.type	.Lstr.1,@object                 # @str.1
.Lstr.1:
	.asciz	"Error: wrong number of args"
	.size	.Lstr.1, 28

	.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 _Z23__device_stub__f_addmatPfS_S_ii
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z8f_addmatPfS_S_ii
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z8f_addmatPfS_S_ii     ; -- Begin function _Z8f_addmatPfS_S_ii
	.globl	_Z8f_addmatPfS_S_ii
	.p2align	8
	.type	_Z8f_addmatPfS_S_ii,@function
_Z8f_addmatPfS_S_ii:                    ; @_Z8f_addmatPfS_S_ii
; %bb.0:
	s_clause 0x1
	s_load_b32 s4, s[0:1], 0x2c
	s_load_b32 s5, s[0:1], 0x20
	v_bfe_u32 v1, v0, 10, 10
	s_waitcnt lgkmcnt(0)
	s_lshr_b32 s2, s4, 16
	s_and_b32 s4, s4, 0xffff
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[2:3], null, s15, s2, v[1:2]
	s_load_b64 s[2:3], s[0:1], 0x18
	v_mad_u64_u32 v[3:4], null, v2, s5, s[14:15]
	v_and_b32_e32 v2, 0x3ff, v0
	s_delay_alu instid0(VALU_DEP_1)
	v_mad_u64_u32 v[0:1], null, v3, s4, v[2:3]
	s_waitcnt lgkmcnt(0)
	s_mul_i32 s2, s3, s2
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	v_cmp_gt_i32_e32 vcc_lo, s2, v0
	s_and_saveexec_b32 s2, vcc_lo
	s_cbranch_execz .LBB0_2
; %bb.1:
	s_load_b128 s[4:7], s[0:1], 0x0
	v_ashrrev_i32_e32 v1, 31, v0
	s_load_b64 s[0:1], s[0:1], 0x10
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[0:1], 2, v[0:1]
	s_waitcnt lgkmcnt(0)
	v_add_co_u32 v2, vcc_lo, s4, v0
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v3, vcc_lo, s5, v1, vcc_lo
	v_add_co_u32 v4, vcc_lo, s6, v0
	v_add_co_ci_u32_e32 v5, vcc_lo, s7, v1, vcc_lo
	v_add_co_u32 v0, vcc_lo, s0, v0
	global_load_b32 v2, v[2:3], off
	global_load_b32 v3, v[4:5], off
	v_add_co_ci_u32_e32 v1, vcc_lo, s1, v1, vcc_lo
	s_waitcnt vmcnt(0)
	v_add_f32_e32 v2, v2, v3
	global_store_b32 v[0:1], v2, off
.LBB0_2:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z8f_addmatPfS_S_ii
		.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 1
		.amdhsa_next_free_vgpr 6
		.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	_Z8f_addmatPfS_S_ii, .Lfunc_end0-_Z8f_addmatPfS_S_ii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 236
; NumSgprs: 18
; NumVgprs: 6
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 6
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 14
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 1
	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

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

	.end_amdgpu_metadata
