#include <cuda.h>
#include <stdio.h>
#include <math.h>

void readFile(char* fname, int* N, int* iter, float** A, float** b)
{
   FILE *fp;
   char buf[100];

   int i, j;

   fp = fopen(fname, "r");
   if(!fp)
   {
      *N = 0;
      *iter = 0;
      printf("Stale File Handle\n");
      return;
   }

   if(fscanf(fp, "%s", buf) > 0) *N = atoi(buf);
   if(fscanf(fp, "%s", buf) > 0) *iter = atoi(buf);
   printf("N = %d\nIterations = %d\n", *N, *iter);

   *b = (float*) malloc(*N*sizeof(float));
   *A = (float*) malloc((*N)*(*N)*sizeof(float));
   for(i = 0; i < *N; i++)
   {
      for(j = 0; j < *N; j++)
      {
         fscanf(fp, "%s", buf);
         (*A)[ ((*N*j)+i) ] = (float)atoi(buf);
      }
   }
   fscanf(fp, "%s", buf); // Ignore the "solution" in the text
   for(i = 0; i < *N; i++)
   {
      fscanf(fp, "%s", buf);
      (*b)[i] = (float)atoi(buf);
   }

   fclose(fp);
}


__global__
void iloop(float* A, float* b, int N, float* y)
{
	extern __shared__ float X[];

	float t = 0.0;
	int i = (blockIdx.x * blockDim.x) + threadIdx.x;
	int j;

	for(j = threadIdx.x; j < N; j += blockDim.x)
	{
		X[j] = y[j]; // Since we have syncthreads() for every thread block, this avoids memcpy after kernel execution.
	}

	__syncthreads();

	for(j = 0; j < N; j++)
	{
		t += (( A[ ((N*j)+i) ] ) * X[j]);
	}
	y[i] = X[i] + ( (b[i] - t)/(A[ ((N*i)+i) ]) );
}



int main(int argc, char* argv[])
{
   float time = 0.0;
	float maxError = 0.0;
	float* d_A;
	float* d_b;
	//float* d_x;
	float* d_y;
	int k;
	int blocksize;
	int numblocks;

   float* A;
   float* b;
   float* x;
	//float* y;
   float* c;
   char* fname;
   int N, iter, i, j, M;

   cudaEvent_t start, stop;
   cudaEventCreate(&start);
   cudaEventCreate(&stop);

   if(argc >= 2) fname = argv[1];
   else fname = "../inputs/8.txt";
   if(argc >= 3) M = atoi(argv[2]);
   else M = 32;

   readFile(fname, &N, &iter, &A, &b);

	printf("CUDA : Parsed file %s\n", fname);

	x = (float*) malloc(N*sizeof(float));
	//y = (float*) malloc(N*sizeof(float));
	
	for(i = 0; i < N; i++)
	{
		x[i] = 0.0;
		//y[i] = 0.0;
	}

	if( cudaMalloc(&d_A, N*N*sizeof(float)) != cudaSuccess ) printf("CUDA : memory allocation error!\n");
	if( cudaMalloc(&d_b, N*sizeof(float))   != cudaSuccess ) printf("CUDA : memory allocation error!\n");
	//if( cudaMalloc(&d_x, N*sizeof(float))   != cudaSuccess ) printf("CUDA : memory allocation error!\n");
	if( cudaMalloc(&d_y, N*sizeof(float))   != cudaSuccess ) printf("CUDA : memory allocation error!\n");

	if( cudaMemcpy(d_A, A, N*N*sizeof(float), cudaMemcpyHostToDevice) != cudaSuccess ) printf("CUDA : memory copy error!\n");
	if( cudaMemcpy(d_b, b, N*sizeof(float)  , cudaMemcpyHostToDevice) != cudaSuccess ) printf("CUDA : memory copy error!\n");
	//if( cudaMemcpy(d_y, y, N*sizeof(float)  , cudaMemcpyHostToDevice) != cudaSuccess ) printf("CUDA : memory copy error!\n");
	//for(i = 0; i < N*N; i++)
	//{
	//	d_A[i] = A[i];
	//}
	//for(i = 0; i < N; i++)
	//{
	//	d_b[i] = b[i];
	//	d_x[i] = x[i];
	//	d_y[i] = y[i];
	//}

	blocksize = fmin(M, N);
	numblocks = (N+blocksize-1)/blocksize;
	printf("CUDA : Grid Size %d, Block size %d\n", numblocks, blocksize);

	cudaEventRecord(start);
   
	if( cudaMemcpy(d_y, x, N*sizeof(float)  , cudaMemcpyHostToDevice) != cudaSuccess ) printf("CUDA : memory copy error!\n");
	for(k = 0; k < iter; k++)
	{
		iloop<<< numblocks, blocksize, N*sizeof(float) >>>(d_A, d_b, N, d_y); // kernel launch on GPU
	   //if( cudaMemcpy(d_x, d_y, N*sizeof(float)  , cudaMemcpyDeviceToDevice) != cudaSuccess ) printf("CUDA : memory copy error!\n");
	}
   if( cudaMemcpy(x, d_y, N*sizeof(float)  , cudaMemcpyDeviceToHost) != cudaSuccess ) printf("CUDA : memory copy error!\n");
	
	//cudaDeviceSynchronize();
	//for(j = 0; j < N; j++) printf("CUDA : %f\n", d_y[j]);

   cudaEventRecord(stop);
   
   cudaEventSynchronize(stop);
   cudaEventElapsedTime(&time, start, stop);
	
	printf("CUDA : Done Computing Jacobi on GPU\n");
	
	//Verify : sdiff -s <output> inputs/<input>
   //for(i = 0; i < N; i++)
   //{
   //   for(j = 0; j < N; j++)
   //   {
   //      printf("%d", (int)A[(N*i+j)]);
   //      if(j < N-1) printf(" ");
   //   }
   //   printf("\n");
   //}

   //for(i = 0; i < N; i++)
   //{
   //   printf("%d\n", (int)b[i]);
   //}
   //printf("\n\n");

   //for(i = 0; i < N; i++)
   //{
   //   printf("%f\n", x[i]);
   //}
   //printf("\n\n");

	//for(i = 0; i < N; i++) x[i] = d_y[i];

   c = (float*) malloc(N*sizeof(float));

   for(i = 0; i < N; i++)
   {
      c[i] = 0;
      for(j = 0; j < N; j++)
      {
         c[i] += A[ ((N*j)+i) ] * x[j];
      }
      //printf("%0.2f\n", c[i]);
		maxError = fmax(maxError, fabs(c[i] - b[i]));
   }

   printf("\nCUDA : Time %f ms\n", time);
	printf("CUDA : MaxError = %f\n\n\n", maxError);

	cudaFree(d_A);
	cudaFree(d_b);
	//cudaFree(d_x);
	cudaFree(d_y);
	free(A);
	free(b);
	free(x);
	//free(y);
	free(c);

   return 0;
}

	.file	"tmpxft_0033e942_00000000-6_jacobi9.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2031:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2031:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"r"
.LC1:
	.string	"Stale File Handle\n"
.LC2:
	.string	"%s"
.LC3:
	.string	"N = %d\nIterations = %d\n"
	.text
	.globl	_Z8readFilePcPiS0_PPfS2_
	.type	_Z8readFilePcPiS0_PPfS2_, @function
_Z8readFilePcPiS0_PPfS2_:
.LFB2027:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movq	%rcx, %r15
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movq	%r8, %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%rdx, %r13
	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
	movq	%rsi, %rbx
	leaq	.LC0(%rip), %rsi
	subq	$136, %rsp
	.cfi_def_cfa_offset 192
	movq	%fs:40, %rax
	movq	%rax, 120(%rsp)
	xorl	%eax, %eax
	call	fopen@PLT
	testq	%rax, %rax
	jne	.L3
	xorl	%eax, %eax
	movl	%eax, (%rbx)
	movl	%eax, 0(%r13)
	movq	120(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L15
	addq	$136, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	leaq	.LC1(%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
.L3:
	.cfi_restore_state
	movq	%rax, %rbp
	leaq	20(%rsp), %rax
	leaq	.LC2(%rip), %rsi
	movq	%rax, 8(%rsp)
	movq	%rax, %rdx
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc23_fscanf@PLT
	testl	%eax, %eax
	jle	.L5
	movq	8(%rsp), %rdi
	call	atoi@PLT
	movl	%eax, (%rbx)
.L5:
	movq	8(%rsp), %rdx
	xorl	%eax, %eax
	leaq	.LC2(%rip), %rsi
	movq	%rbp, %rdi
	call	__isoc23_fscanf@PLT
	testl	%eax, %eax
	jle	.L6
	movq	8(%rsp), %rdi
	call	atoi@PLT
	movl	%eax, 0(%r13)
.L6:
	movl	0(%r13), %ecx
	movl	(%rbx), %edx
	leaq	.LC3(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	xorl	%r13d, %r13d
	call	__printf_chk@PLT
	movslq	(%rbx), %rdi
	salq	$2, %rdi
	call	malloc@PLT
	movl	(%rbx), %edi
	movq	%rax, (%r14)
	imull	%edi, %edi
	movslq	%edi, %rdi
	salq	$2, %rdi
	call	malloc@PLT
	movq	%rax, (%r15)
.L7:
	cmpl	%r13d, (%rbx)
	jle	.L17
	xorl	%r12d, %r12d
.L9:
	cmpl	%r12d, (%rbx)
	jle	.L18
	movq	8(%rsp), %rdx
	leaq	.LC2(%rip), %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc23_fscanf@PLT
	movq	8(%rsp), %rdi
	call	atoi@PLT
	movq	(%r15), %rdx
	movl	%eax, %esi
	movl	(%rbx), %eax
	cvtsi2ssl	%esi, %xmm0
	imull	%r12d, %eax
	incl	%r12d
	addl	%r13d, %eax
	cltq
	movss	%xmm0, (%rdx,%rax,4)
	jmp	.L9
.L18:
	incl	%r13d
	jmp	.L7
.L17:
	movq	8(%rsp), %rdx
	movq	%rbp, %rdi
	xorl	%eax, %eax
	xorl	%r13d, %r13d
	leaq	.LC2(%rip), %rsi
	call	__isoc23_fscanf@PLT
.L10:
	cmpl	%r13d, (%rbx)
	jle	.L19
	movq	8(%rsp), %rdx
	leaq	.LC2(%rip), %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc23_fscanf@PLT
	movq	8(%rsp), %rdi
	call	atoi@PLT
	movq	(%r14), %rdx
	cvtsi2ssl	%eax, %xmm0
	movss	%xmm0, (%rdx,%r13,4)
	incq	%r13
	jmp	.L10
.L19:
	movq	%rbp, %rdi
	call	fclose@PLT
	movq	120(%rsp), %rax
	subq	%fs:40, %rax
	je	.L12
.L15:
	call	__stack_chk_fail@PLT
.L12:
	addq	$136, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2027:
	.size	_Z8readFilePcPiS0_PPfS2_, .-_Z8readFilePcPiS0_PPfS2_
	.globl	_Z29__device_stub__Z5iloopPfS_iS_PfS_iS_
	.type	_Z29__device_stub__Z5iloopPfS_iS_PfS_iS_, @function
_Z29__device_stub__Z5iloopPfS_iS_PfS_iS_:
.LFB2053:
	.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
	movl	%edx, 12(%rsp)
	leaq	40(%rsp), %rdx
	movq	%rcx, (%rsp)
	leaq	48(%rsp), %rcx
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 64(%rsp)
	movq	%rax, 104(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	12(%rsp), %rax
	movq	%rax, 120(%rsp)
	movq	%rsp, %rax
	movq	%rax, 128(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 56(%rsp)
	movq	%rax, 68(%rsp)
	movl	$1, 76(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L20
	pushq	48(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z5iloopPfS_iS_(%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
.L20:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L22
	call	__stack_chk_fail@PLT
.L22:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2053:
	.size	_Z29__device_stub__Z5iloopPfS_iS_PfS_iS_, .-_Z29__device_stub__Z5iloopPfS_iS_PfS_iS_
	.globl	_Z5iloopPfS_iS_
	.type	_Z5iloopPfS_iS_, @function
_Z5iloopPfS_iS_:
.LFB2054:
	.cfi_startproc
	endbr64
	jmp	_Z29__device_stub__Z5iloopPfS_iS_PfS_iS_
	.cfi_endproc
.LFE2054:
	.size	_Z5iloopPfS_iS_, .-_Z5iloopPfS_iS_
	.section	.rodata.str1.1
.LC4:
	.string	"../inputs/8.txt"
.LC6:
	.string	"CUDA : Parsed file %s\n"
.LC7:
	.string	"CUDA : memory allocation error!\n"
.LC8:
	.string	"CUDA : memory copy error!\n"
.LC9:
	.string	"CUDA : Grid Size %d, Block size %d\n"
.LC10:
	.string	"CUDA : Done Computing Jacobi on GPU\n"
.LC12:
	.string	"\nCUDA : Time %f ms\n"
.LC13:
	.string	"CUDA : MaxError = %f\n\n\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2028:
	.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
	leaq	.LC4(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movl	$32, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movl	%edi, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	%rsi, %rbx
	subq	$152, %rsp
	.cfi_def_cfa_offset 208
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	96(%rsp), %rdi
	movl	$0x00000000, 44(%rsp)
	call	cudaEventCreate@PLT
	leaq	104(%rsp), %rdi
	call	cudaEventCreate@PLT
	cmpl	$1, %ebp
	jle	.L26
	movq	8(%rbx), %r13
	cmpl	$2, %ebp
	je	.L26
	movq	16(%rbx), %rdi
	call	atoi@PLT
	movl	%eax, %r12d
.L26:
	leaq	80(%rsp), %rcx
	leaq	88(%rsp), %r8
	movq	%r13, %rdi
	leaq	52(%rsp), %rdx
	leaq	48(%rsp), %rsi
	call	_Z8readFilePcPiS0_PPfS2_
	movq	%r13, %rdx
	movl	$2, %edi
	xorl	%eax, %eax
	leaq	.LC6(%rip), %rsi
	call	__printf_chk@PLT
	movslq	48(%rsp), %rax
	movq	%rax, %rbx
	salq	$2, %rax
	movq	%rax, %rdi
	movq	%rax, 8(%rsp)
	call	malloc@PLT
	movq	%rax, %rbp
	xorl	%eax, %eax
.L27:
	cmpl	%eax, %ebx
	jle	.L68
	movl	$0x00000000, 0(%rbp,%rax,4)
	incq	%rax
	jmp	.L27
.L68:
	movl	%ebx, %r14d
	leaq	56(%rsp), %rdi
	imull	%ebx, %r14d
	movslq	%r14d, %r14
	salq	$2, %r14
	movq	%r14, %rsi
	call	cudaMalloc@PLT
	testl	%eax, %eax
	je	.L29
	leaq	.LC7(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L29:
	movq	8(%rsp), %rsi
	leaq	64(%rsp), %rdi
	call	cudaMalloc@PLT
	testl	%eax, %eax
	je	.L30
	leaq	.LC7(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L30:
	movq	8(%rsp), %rsi
	leaq	72(%rsp), %rdi
	call	cudaMalloc@PLT
	testl	%eax, %eax
	je	.L31
	leaq	.LC7(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L31:
	movq	80(%rsp), %r13
	movq	56(%rsp), %rdi
	movl	$1, %ecx
	movq	%r14, %rdx
	movq	%r13, %rsi
	call	cudaMemcpy@PLT
	testl	%eax, %eax
	je	.L32
	leaq	.LC8(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L32:
	movq	88(%rsp), %rax
	movq	8(%rsp), %rdx
	movl	$1, %ecx
	movq	64(%rsp), %rdi
	movq	%rax, %rsi
	movq	%rax, 16(%rsp)
	call	cudaMemcpy@PLT
	testl	%eax, %eax
	je	.L33
	leaq	.LC8(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L33:
	cvtsi2sdl	%r12d, %xmm1
	cvtsi2sdl	%ebx, %xmm0
	call	fmin@PLT
	leaq	.LC9(%rip), %rsi
	movl	$2, %edi
	cvttsd2sil	%xmm0, %r12d
	leal	-1(%rbx,%r12), %eax
	movl	%r12d, %ecx
	cltd
	idivl	%r12d
	movl	%eax, %edx
	movl	%eax, 28(%rsp)
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	96(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	8(%rsp), %rdx
	movq	72(%rsp), %rdi
	movq	%rbp, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	testl	%eax, %eax
	je	.L34
	leaq	.LC8(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L34:
	movabsq	$4294967297, %r15
	xorl	%r14d, %r14d
.L35:
	cmpl	%r14d, 52(%rsp)
	jle	.L69
	movl	28(%rsp), %eax
	movq	%r15, 128(%rsp)
	xorl	%r9d, %r9d
	movq	%r15, 116(%rsp)
	movl	132(%rsp), %ecx
	movq	8(%rsp), %r8
	movl	120(%rsp), %esi
	movl	%r12d, 124(%rsp)
	movl	%eax, 112(%rsp)
	movq	124(%rsp), %rdx
	movq	112(%rsp), %rdi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L36
	movq	72(%rsp), %rcx
	movq	64(%rsp), %rsi
	movl	%ebx, %edx
	movq	56(%rsp), %rdi
	call	_Z29__device_stub__Z5iloopPfS_iS_PfS_iS_
.L36:
	incl	%r14d
	jmp	.L35
.L69:
	movq	8(%rsp), %rdx
	movq	72(%rsp), %rsi
	movl	$2, %ecx
	movq	%rbp, %rdi
	call	cudaMemcpy@PLT
	testl	%eax, %eax
	je	.L38
	leaq	.LC8(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L38:
	movq	104(%rsp), %rdi
	xorl	%esi, %esi
	xorl	%r14d, %r14d
	call	cudaEventRecord@PLT
	movq	104(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movq	104(%rsp), %rdx
	movq	96(%rsp), %rsi
	leaq	44(%rsp), %rdi
	call	cudaEventElapsedTime@PLT
	leaq	.LC10(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	8(%rsp), %rdi
	call	malloc@PLT
	xorps	%xmm2, %xmm2
	movq	%rax, %r12
.L39:
	cmpl	%r14d, %ebx
	jle	.L70
	leaq	0(%r13,%r14,4), %rdx
	xorl	%eax, %eax
	xorps	%xmm1, %xmm1
.L40:
	movss	(%rdx), %xmm0
	mulss	0(%rbp,%rax,4), %xmm0
	incq	%rax
	movq	8(%rsp), %rcx
	addq	%rcx, %rdx
	addss	%xmm0, %xmm1
	cmpl	%eax, %ebx
	jg	.L40
	movq	16(%rsp), %rax
	movss	%xmm1, (%r12,%r14,4)
	movaps	%xmm2, %xmm0
	subss	(%rax,%r14,4), %xmm1
	andps	.LC11(%rip), %xmm1
	incq	%r14
	call	fmaxf@PLT
	movaps	%xmm0, %xmm2
	jmp	.L39
.L70:
	leaq	.LC12(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	movss	%xmm2, 8(%rsp)
	cvtss2sd	44(%rsp), %xmm0
	call	__printf_chk@PLT
	movl	$2, %edi
	movb	$1, %al
	movss	8(%rsp), %xmm2
	leaq	.LC13(%rip), %rsi
	cvtss2sd	%xmm2, %xmm0
	call	__printf_chk@PLT
	movq	56(%rsp), %rdi
	call	cudaFree@PLT
	movq	64(%rsp), %rdi
	call	cudaFree@PLT
	movq	72(%rsp), %rdi
	call	cudaFree@PLT
	movq	%r13, %rdi
	call	free@PLT
	movq	16(%rsp), %rdi
	call	free@PLT
	movq	%rbp, %rdi
	call	free@PLT
	movq	%r12, %rdi
	call	free@PLT
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L42
	call	__stack_chk_fail@PLT
.L42:
	addq	$152, %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
.LFE2028:
	.size	main, .-main
	.section	.rodata.str1.1
.LC14:
	.string	"_Z5iloopPfS_iS_"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2056:
	.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	.LC14(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z5iloopPfS_iS_(%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
.LFE2056:
	.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
.LC11:
	.long	2147483647
	.long	0
	.long	0
	.long	0
	.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 <stdio.h>
#include <math.h>

void readFile(char* fname, int* N, int* iter, float** A, float** b)
{
   FILE *fp;
   char buf[100];

   int i, j;

   fp = fopen(fname, "r");
   if(!fp)
   {
      *N = 0;
      *iter = 0;
      printf("Stale File Handle\n");
      return;
   }

   if(fscanf(fp, "%s", buf) > 0) *N = atoi(buf);
   if(fscanf(fp, "%s", buf) > 0) *iter = atoi(buf);
   printf("N = %d\nIterations = %d\n", *N, *iter);

   *b = (float*) malloc(*N*sizeof(float));
   *A = (float*) malloc((*N)*(*N)*sizeof(float));
   for(i = 0; i < *N; i++)
   {
      for(j = 0; j < *N; j++)
      {
         fscanf(fp, "%s", buf);
         (*A)[ ((*N*j)+i) ] = (float)atoi(buf);
      }
   }
   fscanf(fp, "%s", buf); // Ignore the "solution" in the text
   for(i = 0; i < *N; i++)
   {
      fscanf(fp, "%s", buf);
      (*b)[i] = (float)atoi(buf);
   }

   fclose(fp);
}


__global__
void iloop(float* A, float* b, int N, float* y)
{
	extern __shared__ float X[];

	float t = 0.0;
	int i = (blockIdx.x * blockDim.x) + threadIdx.x;
	int j;

	for(j = threadIdx.x; j < N; j += blockDim.x)
	{
		X[j] = y[j]; // Since we have syncthreads() for every thread block, this avoids memcpy after kernel execution.
	}

	__syncthreads();

	for(j = 0; j < N; j++)
	{
		t += (( A[ ((N*j)+i) ] ) * X[j]);
	}
	y[i] = X[i] + ( (b[i] - t)/(A[ ((N*i)+i) ]) );
}



int main(int argc, char* argv[])
{
   float time = 0.0;
	float maxError = 0.0;
	float* d_A;
	float* d_b;
	//float* d_x;
	float* d_y;
	int k;
	int blocksize;
	int numblocks;

   float* A;
   float* b;
   float* x;
	//float* y;
   float* c;
   char* fname;
   int N, iter, i, j, M;

   hipEvent_t start, stop;
   hipEventCreate(&start);
   hipEventCreate(&stop);

   if(argc >= 2) fname = argv[1];
   else fname = "../inputs/8.txt";
   if(argc >= 3) M = atoi(argv[2]);
   else M = 32;

   readFile(fname, &N, &iter, &A, &b);

	printf("CUDA : Parsed file %s\n", fname);

	x = (float*) malloc(N*sizeof(float));
	//y = (float*) malloc(N*sizeof(float));
	
	for(i = 0; i < N; i++)
	{
		x[i] = 0.0;
		//y[i] = 0.0;
	}

	if( hipMalloc(&d_A, N*N*sizeof(float)) != hipSuccess ) printf("CUDA : memory allocation error!\n");
	if( hipMalloc(&d_b, N*sizeof(float))   != hipSuccess ) printf("CUDA : memory allocation error!\n");
	//if( cudaMalloc(&d_x, N*sizeof(float))   != cudaSuccess ) printf("CUDA : memory allocation error!\n");
	if( hipMalloc(&d_y, N*sizeof(float))   != hipSuccess ) printf("CUDA : memory allocation error!\n");

	if( hipMemcpy(d_A, A, N*N*sizeof(float), hipMemcpyHostToDevice) != hipSuccess ) printf("CUDA : memory copy error!\n");
	if( hipMemcpy(d_b, b, N*sizeof(float)  , hipMemcpyHostToDevice) != hipSuccess ) printf("CUDA : memory copy error!\n");
	//if( cudaMemcpy(d_y, y, N*sizeof(float)  , cudaMemcpyHostToDevice) != cudaSuccess ) printf("CUDA : memory copy error!\n");
	//for(i = 0; i < N*N; i++)
	//{
	//	d_A[i] = A[i];
	//}
	//for(i = 0; i < N; i++)
	//{
	//	d_b[i] = b[i];
	//	d_x[i] = x[i];
	//	d_y[i] = y[i];
	//}

	blocksize = fmin(M, N);
	numblocks = (N+blocksize-1)/blocksize;
	printf("CUDA : Grid Size %d, Block size %d\n", numblocks, blocksize);

	hipEventRecord(start);
   
	if( hipMemcpy(d_y, x, N*sizeof(float)  , hipMemcpyHostToDevice) != hipSuccess ) printf("CUDA : memory copy error!\n");
	for(k = 0; k < iter; k++)
	{
		iloop<<< numblocks, blocksize, N*sizeof(float) >>>(d_A, d_b, N, d_y); // kernel launch on GPU
	   //if( cudaMemcpy(d_x, d_y, N*sizeof(float)  , cudaMemcpyDeviceToDevice) != cudaSuccess ) printf("CUDA : memory copy error!\n");
	}
   if( hipMemcpy(x, d_y, N*sizeof(float)  , hipMemcpyDeviceToHost) != hipSuccess ) printf("CUDA : memory copy error!\n");
	
	//cudaDeviceSynchronize();
	//for(j = 0; j < N; j++) printf("CUDA : %f\n", d_y[j]);

   hipEventRecord(stop);
   
   hipEventSynchronize(stop);
   hipEventElapsedTime(&time, start, stop);
	
	printf("CUDA : Done Computing Jacobi on GPU\n");
	
	//Verify : sdiff -s <output> inputs/<input>
   //for(i = 0; i < N; i++)
   //{
   //   for(j = 0; j < N; j++)
   //   {
   //      printf("%d", (int)A[(N*i+j)]);
   //      if(j < N-1) printf(" ");
   //   }
   //   printf("\n");
   //}

   //for(i = 0; i < N; i++)
   //{
   //   printf("%d\n", (int)b[i]);
   //}
   //printf("\n\n");

   //for(i = 0; i < N; i++)
   //{
   //   printf("%f\n", x[i]);
   //}
   //printf("\n\n");

	//for(i = 0; i < N; i++) x[i] = d_y[i];

   c = (float*) malloc(N*sizeof(float));

   for(i = 0; i < N; i++)
   {
      c[i] = 0;
      for(j = 0; j < N; j++)
      {
         c[i] += A[ ((N*j)+i) ] * x[j];
      }
      //printf("%0.2f\n", c[i]);
		maxError = fmax(maxError, fabs(c[i] - b[i]));
   }

   printf("\nCUDA : Time %f ms\n", time);
	printf("CUDA : MaxError = %f\n\n\n", maxError);

	hipFree(d_A);
	hipFree(d_b);
	//cudaFree(d_x);
	hipFree(d_y);
	free(A);
	free(b);
	free(x);
	//free(y);
	free(c);

   return 0;
}

	.text
	.file	"jacobi9.hip"
	.globl	_Z8readFilePcPiS0_PPfS2_        # -- Begin function _Z8readFilePcPiS0_PPfS2_
	.type	_Z8readFilePcPiS0_PPfS2_,@function
_Z8readFilePcPiS0_PPfS2_:               # @_Z8readFilePcPiS0_PPfS2_
	.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
	movq	%r8, %rbx
	movq	%rcx, %r12
	movq	%rdx, %r13
	movq	%rsi, %r14
	movl	$.L.str, %esi
	callq	fopen
	testq	%rax, %rax
	je	.LBB0_16
# %bb.1:
	movq	%rax, %r15
	leaq	32(%rsp), %rdx
	movl	$.L.str.2, %esi
	movq	%rax, %rdi
	xorl	%eax, %eax
	callq	__isoc23_fscanf
	testl	%eax, %eax
	jle	.LBB0_3
# %bb.2:
	leaq	32(%rsp), %rdi
	callq	atoi
	movl	%eax, (%r14)
.LBB0_3:
	leaq	32(%rsp), %rdx
	movl	$.L.str.2, %esi
	movq	%r15, %rdi
	xorl	%eax, %eax
	callq	__isoc23_fscanf
	testl	%eax, %eax
	movq	%r15, (%rsp)                    # 8-byte Spill
	jle	.LBB0_4
# %bb.5:
	leaq	32(%rsp), %rdi
	callq	atoi
	movl	%eax, %edx
	movl	%eax, (%r13)
	jmp	.LBB0_6
.LBB0_16:
	xorl	%eax, %eax
	movl	%eax, (%r14)
	movl	%eax, (%r13)
	movl	$.Lstr, %edi
	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
	jmp	puts@PLT                        # TAILCALL
.LBB0_4:                                # %._crit_edge43
	.cfi_def_cfa_offset 192
	movl	(%r13), %edx
.LBB0_6:
	movl	(%r14), %esi
	movl	$.L.str.3, %edi
	xorl	%eax, %eax
	callq	printf
	movq	%r14, 8(%rsp)                   # 8-byte Spill
	movslq	(%r14), %rbp
	leaq	(,%rbp,4), %rdi
	callq	malloc
	movq	%rbx, 16(%rsp)                  # 8-byte Spill
	movq	%rax, (%rbx)
	movl	%ebp, %edi
	imull	%edi, %edi
	shlq	$2, %rdi
	callq	malloc
	movq	%r12, 24(%rsp)                  # 8-byte Spill
	movq	%rax, (%r12)
	testq	%rbp, %rbp
	jle	.LBB0_12
# %bb.7:                                # %.preheader.preheader
	leaq	32(%rsp), %rdx
	xorl	%ebx, %ebx
	movq	8(%rsp), %r15                   # 8-byte Reload
	movq	(%rsp), %r12                    # 8-byte Reload
	movq	24(%rsp), %r13                  # 8-byte Reload
.LBB0_8:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB0_10 Depth 2
	testl	%ebp, %ebp
	jle	.LBB0_11
# %bb.9:                                # %.lr.ph.preheader
                                        #   in Loop: Header=BB0_8 Depth=1
	xorl	%r14d, %r14d
.LBB0_10:                               # %.lr.ph
                                        #   Parent Loop BB0_8 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	$.L.str.2, %esi
	movq	%r12, %rdi
	movq	%rdx, %rbp
	xorl	%eax, %eax
	callq	__isoc23_fscanf
	movq	%rbp, %rdi
	callq	atoi
	movq	%rbp, %rdx
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	movq	(%r13), %rax
	movl	(%r15), %ebp
	movl	%ebp, %ecx
	imull	%r14d, %ecx
	addl	%ebx, %ecx
	movslq	%ecx, %rcx
	movss	%xmm0, (%rax,%rcx,4)
	incl	%r14d
	cmpl	%ebp, %r14d
	jl	.LBB0_10
.LBB0_11:                               # %._crit_edge
                                        #   in Loop: Header=BB0_8 Depth=1
	incl	%ebx
	cmpl	%ebp, %ebx
	jl	.LBB0_8
.LBB0_12:                               # %._crit_edge37
	leaq	32(%rsp), %rdx
	movl	$.L.str.2, %esi
	movq	(%rsp), %r13                    # 8-byte Reload
	movq	%r13, %rdi
	xorl	%eax, %eax
	callq	__isoc23_fscanf
	movq	8(%rsp), %r15                   # 8-byte Reload
	cmpl	$0, (%r15)
	movq	16(%rsp), %r14                  # 8-byte Reload
	jle	.LBB0_15
# %bb.13:                               # %.lr.ph40.preheader
	leaq	32(%rsp), %r12
	xorl	%ebx, %ebx
.LBB0_14:                               # %.lr.ph40
                                        # =>This Inner Loop Header: Depth=1
	movl	$.L.str.2, %esi
	movq	%r13, %rdi
	movq	%r12, %rdx
	xorl	%eax, %eax
	callq	__isoc23_fscanf
	movq	%r12, %rdi
	callq	atoi
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	movq	(%r14), %rax
	movss	%xmm0, (%rax,%rbx,4)
	incq	%rbx
	movslq	(%r15), %rax
	cmpq	%rax, %rbx
	jl	.LBB0_14
.LBB0_15:                               # %._crit_edge41
	movq	%r13, %rdi
	callq	fclose
	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
.Lfunc_end0:
	.size	_Z8readFilePcPiS0_PPfS2_, .Lfunc_end0-_Z8readFilePcPiS0_PPfS2_
	.cfi_endproc
                                        # -- End function
	.globl	_Z20__device_stub__iloopPfS_iS_ # -- Begin function _Z20__device_stub__iloopPfS_iS_
	.type	_Z20__device_stub__iloopPfS_iS_,@function
_Z20__device_stub__iloopPfS_iS_:        # @_Z20__device_stub__iloopPfS_iS_
	.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	4(%rsp), %rsi
	movl	%edx, (%rsi)
	leaq	24(%rsp), %rdx
	movq	%rcx, (%rdx)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	16(%rsp), %r12
	leaq	8(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z5iloopPfS_iS_, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$128, %rsp
	.cfi_adjust_cfa_offset -128
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end1:
	.size	_Z20__device_stub__iloopPfS_iS_, .Lfunc_end1-_Z20__device_stub__iloopPfS_iS_
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI2_0:
	.quad	0x4040000000000000              # double 32
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0
.LCPI2_1:
	.long	0x7fffffff                      # float NaN
	.long	0x7fffffff                      # float NaN
	.long	0x7fffffff                      # float NaN
	.long	0x7fffffff                      # float NaN
	.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	$104, %rsp
	.cfi_def_cfa_offset 160
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rsi, %r14
	movl	%edi, %ebp
	movl	$0, 20(%rsp)
	leaq	64(%rsp), %rdi
	callq	hipEventCreate
	leaq	32(%rsp), %rdi
	callq	hipEventCreate
	movsd	.LCPI2_0(%rip), %xmm0           # xmm0 = mem[0],zero
	movl	$.L.str.4, %ebx
	cmpl	$2, %ebp
	jl	.LBB2_3
# %bb.1:
	movq	8(%r14), %rbx
	je	.LBB2_3
# %bb.2:
	movq	16(%r14), %rdi
	callq	atoi
	xorps	%xmm0, %xmm0
	cvtsi2sd	%eax, %xmm0
.LBB2_3:                                # %.thread
	movsd	%xmm0, (%rsp)                   # 8-byte Spill
	leaq	100(%rsp), %r14
	leaq	60(%rsp), %rdx
	leaq	88(%rsp), %rcx
	leaq	80(%rsp), %r8
	movq	%rbx, %rdi
	movq	%r14, %rsi
	callq	_Z8readFilePcPiS0_PPfS2_
	movl	$.L.str.5, %edi
	movq	%rbx, %rsi
	xorl	%eax, %eax
	callq	printf
	movslq	(%r14), %r13
	leaq	(,%r13,4), %r14
	movq	%r14, %rdi
	callq	malloc
	movq	%rax, %rbx
	movl	%r13d, %ebp
	testq	%r13, %r13
	jle	.LBB2_5
# %bb.4:                                # %.lr.ph.preheader
	leaq	(,%rbp,4), %rdx
	movq	%rbx, %rdi
	xorl	%esi, %esi
	callq	memset@PLT
.LBB2_5:                                # %._crit_edge
	movl	%r13d, %r12d
	imull	%ebp, %r12d
	shlq	$2, %r12
	leaq	48(%rsp), %rdi
	movq	%r12, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	je	.LBB2_7
# %bb.6:
	movl	$.Lstr.3, %edi
	callq	puts@PLT
.LBB2_7:
	leaq	40(%rsp), %rdi
	movq	%r14, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	je	.LBB2_9
# %bb.8:
	movl	$.Lstr.3, %edi
	callq	puts@PLT
.LBB2_9:
	leaq	24(%rsp), %rdi
	movq	%r14, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	je	.LBB2_11
# %bb.10:
	movl	$.Lstr.3, %edi
	callq	puts@PLT
.LBB2_11:
	movq	48(%rsp), %rdi
	movq	88(%rsp), %r15
	movq	%r15, %rsi
	movq	%r12, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	je	.LBB2_13
# %bb.12:
	movl	$.Lstr.7, %edi
	callq	puts@PLT
.LBB2_13:
	movq	%r15, 72(%rsp)                  # 8-byte Spill
	movq	40(%rsp), %rdi
	movq	80(%rsp), %r12
	movq	%r12, %rsi
	movq	%r14, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	je	.LBB2_15
# %bb.14:
	movl	$.Lstr.7, %edi
	callq	puts@PLT
.LBB2_15:
	movq	%rbp, 8(%rsp)                   # 8-byte Spill
	xorps	%xmm0, %xmm0
	cvtsi2sd	%ebp, %xmm0
	movsd	(%rsp), %xmm1                   # 8-byte Reload
                                        # xmm1 = mem[0],zero
	minsd	%xmm0, %xmm1
	cvttsd2si	%xmm1, %ebp
	movq	%r13, (%rsp)                    # 8-byte Spill
	leal	-1(%r13,%rbp), %eax
	cltd
	idivl	%ebp
	movl	%eax, %r15d
	movl	$.L.str.8, %edi
	movl	%eax, %esi
	movl	%ebp, %edx
	xorl	%eax, %eax
	callq	printf
	movq	64(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	24(%rsp), %rdi
	movq	%rbx, %rsi
	movq	%r14, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	je	.LBB2_17
# %bb.16:
	movl	$.Lstr.7, %edi
	callq	puts@PLT
.LBB2_17:
	movl	60(%rsp), %r13d
	testl	%r13d, %r13d
	jle	.LBB2_22
# %bb.18:                               # %.lr.ph71
	movl	%r15d, %r15d
	btsq	$32, %r15
	movl	%ebp, %ebp
	btsq	$32, %rbp
.LBB2_19:                               # =>This Inner Loop Header: Depth=1
	movq	%r15, %rdi
	movl	$1, %esi
	movq	%rbp, %rdx
	movl	$1, %ecx
	movq	%r14, %r8
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB2_21
# %bb.20:                               #   in Loop: Header=BB2_19 Depth=1
	movq	48(%rsp), %rdi
	movq	40(%rsp), %rsi
	movq	24(%rsp), %rcx
	movq	8(%rsp), %rdx                   # 8-byte Reload
                                        # kill: def $edx killed $edx killed $rdx
	callq	_Z20__device_stub__iloopPfS_iS_
.LBB2_21:                               #   in Loop: Header=BB2_19 Depth=1
	decl	%r13d
	jne	.LBB2_19
.LBB2_22:                               # %._crit_edge72
	movq	24(%rsp), %rsi
	movq	%rbx, %rdi
	movq	%r14, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	je	.LBB2_24
# %bb.23:
	movl	$.Lstr.7, %edi
	callq	puts@PLT
.LBB2_24:
	movq	32(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	32(%rsp), %rdi
	callq	hipEventSynchronize
	movq	64(%rsp), %rsi
	movq	32(%rsp), %rdx
	leaq	20(%rsp), %rdi
	callq	hipEventElapsedTime
	movl	$.Lstr.8, %edi
	callq	puts@PLT
	cmpl	$0, 8(%rsp)                     # 4-byte Folded Reload
	movq	72(%rsp), %r15                  # 8-byte Reload
	movq	(%rsp), %rax                    # 8-byte Reload
	jle	.LBB2_25
# %bb.26:                               # %.lr.ph80
	movl	%eax, %eax
	xorpd	%xmm1, %xmm1
	xorl	%ecx, %ecx
	movaps	.LCPI2_1(%rip), %xmm0           # xmm0 = [NaN,NaN,NaN,NaN]
	movq	%r15, %rdx
.LBB2_27:                               # %.lr.ph75
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB2_28 Depth 2
	movq	%rdx, %rsi
	xorl	%edi, %edi
	xorps	%xmm2, %xmm2
.LBB2_28:                               #   Parent Loop BB2_27 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movss	(%rsi), %xmm3                   # xmm3 = mem[0],zero,zero,zero
	mulss	(%rbx,%rdi,4), %xmm3
	addss	%xmm3, %xmm2
	incq	%rdi
	addq	%r14, %rsi
	cmpq	%rdi, %rax
	jne	.LBB2_28
# %bb.29:                               # %._crit_edge76
                                        #   in Loop: Header=BB2_27 Depth=1
	subss	(%r12,%rcx,4), %xmm2
	andps	%xmm0, %xmm2
	movapd	%xmm1, %xmm3
	cmpunordss	%xmm1, %xmm3
	movaps	%xmm3, %xmm4
	andps	%xmm2, %xmm4
	maxss	%xmm1, %xmm2
	andnps	%xmm2, %xmm3
	orps	%xmm4, %xmm3
	incq	%rcx
	addq	$4, %rdx
	movaps	%xmm3, %xmm1
	cmpq	%rax, %rcx
	jne	.LBB2_27
# %bb.30:                               # %._crit_edge81.loopexit
	xorps	%xmm0, %xmm0
	cvtss2sd	%xmm3, %xmm0
	jmp	.LBB2_31
.LBB2_25:
	xorpd	%xmm0, %xmm0
.LBB2_31:                               # %._crit_edge81
	movsd	%xmm0, 8(%rsp)                  # 8-byte Spill
	xorps	%xmm0, %xmm0
	cvtss2sd	20(%rsp), %xmm0
	movl	$.L.str.10, %edi
	movb	$1, %al
	callq	printf
	movl	$.L.str.11, %edi
	movsd	8(%rsp), %xmm0                  # 8-byte Reload
                                        # xmm0 = mem[0],zero
	movb	$1, %al
	callq	printf
	movq	48(%rsp), %rdi
	callq	hipFree
	movq	40(%rsp), %rdi
	callq	hipFree
	movq	24(%rsp), %rdi
	callq	hipFree
	movq	%r15, %rdi
	callq	free
	movq	%r12, %rdi
	callq	free
	movq	%rbx, %rdi
	callq	free
	xorl	%eax, %eax
	addq	$104, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end2:
	.size	main, .Lfunc_end2-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	.LBB3_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB3_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z5iloopPfS_iS_, %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_end3:
	.size	__hip_module_ctor, .Lfunc_end3-__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	.LBB4_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
.LBB4_2:
	retq
.Lfunc_end4:
	.size	__hip_module_dtor, .Lfunc_end4-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"r"
	.size	.L.str, 2

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"%s"
	.size	.L.str.2, 3

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"N = %d\nIterations = %d\n"
	.size	.L.str.3, 24

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

	.type	.L.str.4,@object                # @.str.4
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.4:
	.asciz	"../inputs/8.txt"
	.size	.L.str.4, 16

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"CUDA : Parsed file %s\n"
	.size	.L.str.5, 23

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"CUDA : Grid Size %d, Block size %d\n"
	.size	.L.str.8, 36

	.type	.L.str.10,@object               # @.str.10
.L.str.10:
	.asciz	"\nCUDA : Time %f ms\n"
	.size	.L.str.10, 20

	.type	.L.str.11,@object               # @.str.11
.L.str.11:
	.asciz	"CUDA : MaxError = %f\n\n\n"
	.size	.L.str.11, 24

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z5iloopPfS_iS_"
	.size	.L__unnamed_1, 16

	.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	"Stale File Handle"
	.size	.Lstr, 18

	.type	.Lstr.3,@object                 # @str.3
.Lstr.3:
	.asciz	"CUDA : memory allocation error!"
	.size	.Lstr.3, 32

	.type	.Lstr.7,@object                 # @str.7
.Lstr.7:
	.asciz	"CUDA : memory copy error!"
	.size	.Lstr.7, 26

	.type	.Lstr.8,@object                 # @str.8
.Lstr.8:
	.asciz	"CUDA : Done Computing Jacobi on GPU"
	.size	.Lstr.8, 36

	.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 _Z20__device_stub__iloopPfS_iS_
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z5iloopPfS_iS_
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z5iloopPfS_iS_         ; -- Begin function _Z5iloopPfS_iS_
	.globl	_Z5iloopPfS_iS_
	.p2align	8
	.type	_Z5iloopPfS_iS_,@function
_Z5iloopPfS_iS_:                        ; @_Z5iloopPfS_iS_
; %bb.0:
	s_clause 0x2
	s_load_b32 s6, s[0:1], 0x10
	s_load_b32 s2, s[0:1], 0x2c
	s_load_b64 s[4:5], s[0:1], 0x18
	s_waitcnt lgkmcnt(0)
	s_and_b32 s7, s2, 0xffff
	s_mov_b32 s2, exec_lo
	v_cmpx_gt_i32_e64 s6, v0
	s_cbranch_execz .LBB0_3
; %bb.1:                                ; %.lr.ph.preheader
	v_lshl_add_u32 v3, v0, 2, 0
	v_mov_b32_e32 v1, v0
	s_mov_b32 s3, 0
	s_lshl_b32 s8, s7, 2
.LBB0_2:                                ; %.lr.ph
                                        ; =>This Inner Loop Header: Depth=1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v2, 31, v1
	v_lshlrev_b64 v[4:5], 2, v[1:2]
	v_add_nc_u32_e32 v1, s7, v1
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_co_u32 v4, vcc_lo, s4, v4
	v_add_co_ci_u32_e32 v5, vcc_lo, s5, v5, vcc_lo
	s_delay_alu instid0(VALU_DEP_3)
	v_cmp_le_i32_e32 vcc_lo, s6, v1
	global_load_b32 v2, v[4:5], off
	s_or_b32 s3, vcc_lo, s3
	s_waitcnt vmcnt(0)
	ds_store_b32 v3, v2
	v_add_nc_u32_e32 v3, s8, v3
	s_and_not1_b32 exec_lo, exec_lo, s3
	s_cbranch_execnz .LBB0_2
.LBB0_3:                                ; %Flow52
	s_or_b32 exec_lo, exec_lo, s2
	s_load_b128 s[0:3], s[0:1], 0x0
	v_mad_u64_u32 v[1:2], null, s15, s7, v[0:1]
	v_mov_b32_e32 v0, 0
	s_cmp_lt_i32 s6, 1
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	s_cbranch_scc1 .LBB0_6
; %bb.4:                                ; %.lr.ph33.preheader
	v_mov_b32_e32 v2, v1
	s_mov_b32 s7, 0
	s_mov_b32 s8, s6
.LBB0_5:                                ; %.lr.ph33
                                        ; =>This Inner Loop Header: Depth=1
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v3, 31, v2
	s_add_i32 s8, s8, -1
	v_lshlrev_b64 v[3:4], 2, v[2:3]
	v_add_nc_u32_e32 v2, s6, v2
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_co_u32 v3, vcc_lo, s0, v3
	v_add_co_ci_u32_e32 v4, vcc_lo, s1, v4, vcc_lo
	global_load_b32 v3, v[3:4], off
	v_mov_b32_e32 v4, s7
	s_add_i32 s7, s7, 4
	s_cmp_lg_u32 s8, 0
	ds_load_b32 v4, v4
	s_waitcnt vmcnt(0) lgkmcnt(0)
	v_fmac_f32_e32 v0, v3, v4
	s_cbranch_scc1 .LBB0_5
.LBB0_6:                                ; %._crit_edge34
	v_ashrrev_i32_e32 v2, 31, v1
	s_delay_alu instid0(VALU_DEP_1)
	v_mad_u64_u32 v[3:4], null, v1, s6, v[1:2]
	v_lshlrev_b64 v[5:6], 2, v[1:2]
	v_lshl_add_u32 v1, v1, 2, 0
	ds_load_b32 v1, v1
	v_ashrrev_i32_e32 v4, 31, v3
	v_add_co_u32 v7, vcc_lo, s2, v5
	v_add_co_ci_u32_e32 v8, vcc_lo, s3, v6, vcc_lo
	s_delay_alu instid0(VALU_DEP_3)
	v_lshlrev_b64 v[2:3], 2, v[3:4]
	global_load_b32 v4, v[7:8], off
	v_add_co_u32 v2, vcc_lo, s0, v2
	v_add_co_ci_u32_e32 v3, vcc_lo, s1, v3, vcc_lo
	global_load_b32 v2, v[2:3], off
	s_waitcnt vmcnt(1)
	v_sub_f32_e32 v0, v4, v0
	s_waitcnt vmcnt(0)
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_div_scale_f32 v3, null, v2, v2, v0
	v_div_scale_f32 v8, vcc_lo, v0, v2, v0
	v_rcp_f32_e32 v4, v3
	s_waitcnt_depctr 0xfff
	v_fma_f32 v7, -v3, v4, 1.0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fmac_f32_e32 v4, v7, v4
	v_mul_f32_e32 v7, v8, v4
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f32 v9, -v3, v7, v8
	v_fmac_f32_e32 v7, v9, v4
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f32 v3, -v3, v7, v8
	v_div_fmas_f32 v3, v3, v4, v7
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_div_fixup_f32 v0, v3, v2, v0
	s_waitcnt lgkmcnt(0)
	v_add_f32_e32 v2, v1, v0
	v_add_co_u32 v0, vcc_lo, s4, v5
	v_add_co_ci_u32_e32 v1, vcc_lo, s5, v6, vcc_lo
	global_store_b32 v[0:1], v2, off
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z5iloopPfS_iS_
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 288
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 10
		.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	_Z5iloopPfS_iS_, .Lfunc_end0-_Z5iloopPfS_iS_
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 540
; NumSgprs: 18
; NumVgprs: 10
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 10
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

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

	.end_amdgpu_metadata
