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

#define NXPROB      20480                /* x dimension of problem grid */
#define NYPROB      32768                  /* y dimension of problem grid */
#define STEPS       500                /* number of time steps */
#define MAXWORKER   8                  /* maximum number of worker tasks */
#define MINWORKER   3                  /* minimum number of worker tasks */
#define BEGIN       1                  /* message tag */
#define LTAG        2                  /* message tag */
#define RTAG        3                  /* message tag */
#define NONE        0                  /* indicates no neighbor */
#define DONE        4                  /* message tag */
#define MASTER      0                  /* taskid of first process */

#define BLOCK_H   10
#define BLOCK_V   8
#define THREADS   32

struct Parms {
  float cx;
  float cy;
} parms = {0.1, 0.1};

/**************************************************************************
 *  subroutine update
 ****************************************************************************/
void update(int start, int end, int ny, float *u1, float *u2)
{
   int ix, iy;
   for (ix = start; ix <= end; ix++)
      for (iy = 1; iy <= ny-2; iy++)
         *(u2+ix*ny+iy) = *(u1+ix*ny+iy)  +
                          parms.cx * (*(u1+(ix+1)*ny+iy) +
                          *(u1+(ix-1)*ny+iy) -
                          2.0 * *(u1+ix*ny+iy)) +
                          parms.cy * (*(u1+ix*ny+iy+1) +
                         *(u1+ix*ny+iy-1) -
                          2.0 * *(u1+ix*ny+iy));
}

/*****************************************************************************
 *  subroutine inidat
 *****************************************************************************/
void inidat(int nx, int ny, float *u) {
int ix, iy;
for (ix = 0; ix <= nx-1; ix++)
  for (iy = 0; iy <= ny-1; iy++)
     {*(u+ix*ny+iy) = (float)(ix * (nx - ix - 1) * iy * (ny - iy - 1)%1000);
     //if (*(u+ix*ny+iy) > 10000.0)
     //printf("%f\n", *(u+ix*ny+iy));
    }
}

/**************************************************************************
 * subroutine prtdat
 **************************************************************************/
void prtdat(int nx, int ny, float *u1, const char *fnam) {
int ix, iy;
FILE *fp;

fp = fopen(fnam, "w");
for (iy = ny-1; iy >= 0; iy--) {
  for (ix = 0; ix <= nx-1; ix++) {
    fprintf(fp, "%6.1f", *(u1+ix*ny+iy));
    if (ix != nx-1)
      fprintf(fp, " ");
    else
      fprintf(fp, "\n");
    }
  }
fclose(fp);
}

__global__ void cuda_update(float *u0, float *u1, struct Parms parms)
{
  int ix, iy;
  ix = blockIdx.x * blockDim.x + threadIdx.x + 1;
  iy = blockIdx.y * blockDim.y + threadIdx.y + 1;

  if (ix > 0 && iy > 0)
  {
    if (ix + iy < NXPROB + NYPROB - 2)
    {
      *(u1+ix*NYPROB+iy) = *(u0+ix*NYPROB+iy)  +
                          parms.cx * (*(u0+(ix+1)*NYPROB+iy) +
                          *(u0+(ix-1)*NYPROB+iy) -
                          2.0 * *(u0+ix*NYPROB+iy)) +
                          parms.cy * (*(u0+ix*NYPROB+iy+1) +
                         *(u0+ix*NYPROB+iy-1) -
                          2.0 * *(u0+ix*NYPROB+iy));
    }
  }
}

__global__ void MyKernel(int *a, int *b, int *c, int N) 
{ 
  int idx = threadIdx.x + blockIdx.x * blockDim.x; 
  if (idx < N) 
  {
    c[idx] = a[idx] + b[idx];
  } 
} 

int main (int argc, char *argv[])
{
  int i;
  float *u;
  float *cuda_u0, *cuda_u1;
  cudaEvent_t start, stop;
  cudaEventCreate(&start);
  cudaEventCreate(&stop);
  float ms = 0.0f;
  int block_size;
  int min_grid, grid;
  
  //http://devblogs.nvidia.com/parallelforall/cuda-pro-tip-occupancy-api-simplifies-launch-configuration/
  cudaOccupancyMaxPotentialBlockSize(&min_grid, &block_size, MyKernel, 0, NXPROB*NYPROB);
  grid = (NXPROB*NYPROB + block_size - 1) / block_size;
  dim3 dimBlocks(BLOCK_H, BLOCK_V);
  dim3 dimThreads((NXPROB / BLOCK_H) + ((NXPROB % BLOCK_H) != 0), (NYPROB / BLOCK_V) + ((NYPROB % BLOCK_V) != 0));

  //malloc host 
  u = (float*)malloc(NXPROB*NYPROB*sizeof(float));

  //malloc device
  cudaMalloc((void**)&cuda_u0, (NXPROB*NYPROB*sizeof(float)));
  cudaMalloc((void**)&cuda_u1, (NXPROB*NYPROB*sizeof(float)));

  printf("Grid size: X= %d  Y= %d  Time steps= %d\n",NXPROB,NYPROB,STEPS);
  inidat(NXPROB, NYPROB, u); //initialize
  //prtdat(NXPROB, NYPROB, u, "initial.dat"); //print

  //copy from host to device
  cudaMemcpy(cuda_u0, u, (NXPROB*NYPROB*sizeof(float)), cudaMemcpyHostToDevice);
  cudaMemcpy(cuda_u1, u, (NXPROB*NYPROB*sizeof(float)), cudaMemcpyHostToDevice);

  cudaEventRecord(start, 0);
  for (i = 0; i < STEPS; i+=2)
  { 
      cuda_update<<<grid, block_size>>>(cuda_u0, cuda_u1, parms);
      cuda_update<<<grid, block_size>>>(cuda_u1, cuda_u0, parms);
  }
  cudaThreadSynchronize();
  cudaEventRecord(stop, 0);
  cudaEventSynchronize(stop);
  cudaEventElapsedTime(&ms, start, stop);

  //copy from device to host
  cudaMemcpy(u, cuda_u1, (NXPROB*NYPROB*sizeof(float)), cudaMemcpyDeviceToHost);
  //prtdat(NXPROB, NYPROB, u, "final.dat");   //print
  printf("Time: %f ms\n", ms);
  
  cudaFree(cuda_u0);
  cudaFree(cuda_u1);
  free(u);
  cudaEventDestroy(start);
  cudaEventDestroy(stop);

  return 0;
}

	.file	"tmpxft_002dd833_00000000-6_cuda_heat2Dn.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2033:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2033:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z6updateiiiPfS_
	.type	_Z6updateiiiPfS_, @function
_Z6updateiiiPfS_:
.LFB2027:
	.cfi_startproc
	endbr64
	movl	%edx, %r11d
	leal	1(%rdi), %r10d
	leal	-1(%rdi), %r9d
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	imull	%edi, %r11d
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	movl	%edx, %eax
	leal	-1(%rdx), %r13d
	imull	%edx, %r10d
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	imull	%edx, %r9d
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	movl	%esi, %ebx
.L3:
	cmpl	%ebx, %edi
	jg	.L2
	movslq	%r10d, %rsi
	movslq	%r11d, %rdx
	leaq	(%rcx,%rsi,4), %r12
	movslq	%r9d, %rsi
	salq	$2, %rdx
	leaq	(%rcx,%rsi,4), %rbp
	xorl	%esi, %esi
.L6:
	incq	%rsi
	addq	$4, %rdx
	cmpl	%esi, %r13d
	jle	.L9
	cvtss2sd	(%rcx,%rdx), %xmm1
	movaps	%xmm1, %xmm2
	movss	(%r12,%rsi,4), %xmm0
	addss	0(%rbp,%rsi,4), %xmm0
	addsd	%xmm1, %xmm2
	cvtss2sd	parms(%rip), %xmm3
	cvtss2sd	%xmm0, %xmm0
	subsd	%xmm2, %xmm0
	mulsd	%xmm3, %xmm0
	addsd	%xmm1, %xmm0
	movss	4(%rcx,%rdx), %xmm1
	addss	-4(%rcx,%rdx), %xmm1
	cvtss2sd	%xmm1, %xmm1
	subsd	%xmm2, %xmm1
	cvtss2sd	4+parms(%rip), %xmm2
	mulsd	%xmm2, %xmm1
	addsd	%xmm1, %xmm0
	cvtsd2ss	%xmm0, %xmm0
	movss	%xmm0, (%r8,%rdx)
	jmp	.L6
.L9:
	incl	%edi
	addl	%eax, %r11d
	addl	%eax, %r10d
	addl	%eax, %r9d
	jmp	.L3
.L2:
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2027:
	.size	_Z6updateiiiPfS_, .-_Z6updateiiiPfS_
	.globl	_Z6inidatiiPf
	.type	_Z6inidatiiPf, @function
_Z6inidatiiPf:
.LFB2028:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	movl	%edi, %r8d
	movq	%rdx, %r10
	movl	%esi, %edi
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	xorl	%r11d, %r11d
	xorl	%esi, %esi
	leal	-1(%r8), %r13d
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	movl	$1000, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
.L11:
	cmpl	%r8d, %esi
	jge	.L10
	movl	%r13d, %ebx
	movslq	%r11d, %rax
	xorl	%r9d, %r9d
	xorl	%ecx, %ecx
	subl	%esi, %ebx
	leaq	(%r10,%rax,4), %r12
	imull	%esi, %ebx
.L14:
	incq	%rcx
	leal	-1(%rcx), %eax
	cmpl	%eax, %edi
	jle	.L16
	movl	%edi, %eax
	subl	%ecx, %eax
	imull	%r9d, %eax
	addl	%ebx, %r9d
	cltd
	idivl	%ebp
	cvtsi2ssl	%edx, %xmm0
	movss	%xmm0, -4(%r12,%rcx,4)
	jmp	.L14
.L16:
	incl	%esi
	addl	%edi, %r11d
	jmp	.L11
.L10:
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2028:
	.size	_Z6inidatiiPf, .-_Z6inidatiiPf
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"w"
.LC1:
	.string	"%6.1f"
.LC2:
	.string	" "
.LC3:
	.string	"\n"
	.text
	.globl	_Z6prtdatiiPfPKc
	.type	_Z6prtdatiiPfPKc, @function
_Z6prtdatiiPfPKc:
.LFB2029:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movq	%rdx, %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movl	%edi, %r12d
	movq	%rcx, %rdi
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movslq	%esi, %rbx
	leaq	.LC0(%rip), %rsi
	leal	-1(%rbx), %ebp
	movslq	%ebp, %r15
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	call	fopen@PLT
	movq	%rax, (%rsp)
	leaq	0(,%rbx,4), %rax
	movq	%rax, 8(%rsp)
.L18:
	testl	%ebp, %ebp
	js	.L22
	leaq	(%r14,%r15,4), %r13
	xorl	%ebx, %ebx
.L23:
	cmpl	%r12d, %ebx
	jge	.L26
	movq	(%rsp), %rdi
	leaq	.LC1(%rip), %rdx
	movl	$2, %esi
	movb	$1, %al
	cvtss2sd	0(%r13), %xmm0
	call	__fprintf_chk@PLT
	leal	-1(%r12), %eax
	leaq	.LC2(%rip), %rdx
	cmpl	%ebx, %eax
	jne	.L25
	leaq	.LC3(%rip), %rdx
.L25:
	movq	(%rsp), %rdi
	movl	$2, %esi
	xorl	%eax, %eax
	incl	%ebx
	call	__fprintf_chk@PLT
	movq	8(%rsp), %rax
	addq	%rax, %r13
	jmp	.L23
.L26:
	decl	%ebp
	decq	%r15
	jmp	.L18
.L22:
	movq	(%rsp), %rdi
	addq	$24, %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
	jmp	fclose@PLT
	.cfi_endproc
.LFE2029:
	.size	_Z6prtdatiiPfPKc, .-_Z6prtdatiiPfPKc
	.globl	_Z39__device_stub__Z11cuda_updatePfS_5ParmsPfS_R5Parms
	.type	_Z39__device_stub__Z11cuda_updatePfS_5ParmsPfS_R5Parms, @function
_Z39__device_stub__Z11cuda_updatePfS_5ParmsPfS_R5Parms:
.LFB2055:
	.cfi_startproc
	endbr64
	subq	$120, %rsp
	.cfi_def_cfa_offset 128
	movq	%rdi, 8(%rsp)
	leaq	24(%rsp), %rcx
	leaq	32(%rsp), %rdi
	movq	%rsi, (%rsp)
	leaq	44(%rsp), %rsi
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rax
	movq	%rdx, 96(%rsp)
	leaq	16(%rsp), %rdx
	movq	%rax, 80(%rsp)
	movq	%rsp, %rax
	movq	%rax, 88(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 32(%rsp)
	movl	$1, 40(%rsp)
	movq	%rax, 44(%rsp)
	movl	$1, 52(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L27
	pushq	24(%rsp)
	.cfi_def_cfa_offset 136
	leaq	_Z11cuda_updatePfS_5Parms(%rip), %rdi
	pushq	24(%rsp)
	.cfi_def_cfa_offset 144
	movq	60(%rsp), %rcx
	movl	68(%rsp), %r8d
	movq	48(%rsp), %rsi
	movl	56(%rsp), %edx
	leaq	96(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 136
	popq	%rdx
	.cfi_def_cfa_offset 128
.L27:
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	je	.L29
	call	__stack_chk_fail@PLT
.L29:
	addq	$120, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2055:
	.size	_Z39__device_stub__Z11cuda_updatePfS_5ParmsPfS_R5Parms, .-_Z39__device_stub__Z11cuda_updatePfS_5ParmsPfS_R5Parms
	.globl	_Z11cuda_updatePfS_5Parms
	.type	_Z11cuda_updatePfS_5Parms, @function
_Z11cuda_updatePfS_5Parms:
.LFB2056:
	.cfi_startproc
	endbr64
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	leaq	8(%rsp), %rdx
	movq	%xmm0, 8(%rsp)
	call	_Z39__device_stub__Z11cuda_updatePfS_5ParmsPfS_R5Parms
	addq	$24, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2056:
	.size	_Z11cuda_updatePfS_5Parms, .-_Z11cuda_updatePfS_5Parms
	.section	.rodata.str1.1
.LC5:
	.string	"Grid size: X= %d  Y= %d  Time steps= %d\n"
.LC6:
	.string	"Time: %f ms\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2030:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$264, %rsp
	.cfi_def_cfa_offset 320
	movq	%fs:40, %rax
	movq	%rax, 248(%rsp)
	xorl	%eax, %eax
	leaq	56(%rsp), %rdi
	call	cudaEventCreate@PLT
	leaq	64(%rsp), %rdi
	call	cudaEventCreate@PLT
	leaq	36(%rsp), %rdi
	movl	$0x00000000, 32(%rsp)
	call	cudaGetDevice@PLT
	testl	%eax, %eax
	leaq	40(%rsp), %rax
	movq	%rax, (%rsp)
	leaq	48(%rsp), %rax
	movq	%rax, 8(%rsp)
	jne	.L35
	movl	36(%rsp), %edx
	movq	(%rsp), %rdi
	movl	$39, %esi
	call	cudaDeviceGetAttribute@PLT
	testl	%eax, %eax
	jne	.L35
	movl	36(%rsp), %edx
	movq	8(%rsp), %rdi
	movl	$10, %esi
	call	cudaDeviceGetAttribute@PLT
	testl	%eax, %eax
	jne	.L35
	movl	36(%rsp), %edx
	leaq	72(%rsp), %rdi
	movl	$1, %esi
	call	cudaDeviceGetAttribute@PLT
	testl	%eax, %eax
	jne	.L35
	movl	36(%rsp), %edx
	leaq	80(%rsp), %rdi
	movl	$16, %esi
	call	cudaDeviceGetAttribute@PLT
	testl	%eax, %eax
	jne	.L35
	leaq	104(%rsp), %rdi
	leaq	_Z8MyKernelPiS_S_i(%rip), %rsi
	call	cudaFuncGetAttributes@PLT
	testl	%eax, %eax
	jne	.L35
	movl	40(%rsp), %eax
	movl	128(%rsp), %r9d
	movl	48(%rsp), %r12d
	movl	%eax, 20(%rsp)
	movl	72(%rsp), %eax
	cmpl	%eax, %r9d
	cmovle	%r9d, %eax
	movl	%eax, %r13d
	movl	$671088640, %eax
	cmpl	%eax, %r13d
	cmovg	%eax, %r13d
	xorl	%r15d, %r15d
	xorl	%ebp, %ebp
	leal	-1(%r12,%r13), %ebx
	movl	%ebx, %eax
	cltd
	idivl	%r12d
	leaq	92(%rsp), %rax
	movq	%rax, 24(%rsp)
	subl	%edx, %ebx
.L37:
	testl	%ebx, %ebx
	jle	.L35
	cmpl	%ebx, %r13d
	movl	%ebx, %r14d
	movq	24(%rsp), %rdi
	leaq	_Z8MyKernelPiS_S_i(%rip), %rsi
	cmovle	%r13d, %r14d
	xorl	%r8d, %r8d
	xorl	%ecx, %ecx
	movl	%r14d, %edx
	call	cudaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags@PLT
	testl	%eax, %eax
	jne	.L35
	movl	92(%rsp), %eax
	imull	%r14d, %eax
	cmpl	%r15d, %eax
	jle	.L38
	movl	%eax, %r15d
	movl	%r14d, %ebp
.L38:
	cmpl	%r15d, 20(%rsp)
	je	.L35
	subl	%r12d, %ebx
	jmp	.L37
.L35:
	leal	671088639(%rbp), %eax
	movl	$2684354560, %r14d
	movabsq	$4294967297, %r12
	cltd
	movq	%r14, %rdi
	idivl	%ebp
	movl	%eax, %r13d
	call	malloc@PLT
	movq	(%rsp), %rdi
	movq	%r14, %rsi
	movq	%rax, %rbx
	call	cudaMalloc@PLT
	movq	8(%rsp), %rdi
	movq	%r14, %rsi
	call	cudaMalloc@PLT
	movl	$500, %r8d
	xorl	%eax, %eax
	movl	$32768, %ecx
	movl	$20480, %edx
	leaq	.LC5(%rip), %rsi
	movl	$2, %edi
	call	__printf_chk@PLT
	movq	%rbx, %rdx
	movl	$32768, %esi
	movl	$20480, %edi
	call	_Z6inidatiiPf
	movq	40(%rsp), %rdi
	movq	%r14, %rdx
	movq	%rbx, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movq	48(%rsp), %rdi
	movq	%r14, %rdx
	movq	%rbx, %rsi
	movl	$1, %ecx
	movl	$250, %r14d
	call	cudaMemcpy@PLT
	movq	56(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
.L42:
	movq	%r12, 96(%rsp)
	movl	100(%rsp), %ecx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movq	%r12, 84(%rsp)
	movl	88(%rsp), %esi
	movl	%ebp, 92(%rsp)
	movq	92(%rsp), %rdx
	movl	%r13d, 80(%rsp)
	movq	80(%rsp), %rdi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L40
	movq	48(%rsp), %rsi
	movq	40(%rsp), %rdi
	leaq	72(%rsp), %rdx
	movq	parms(%rip), %rax
	movq	%rax, 72(%rsp)
	call	_Z39__device_stub__Z11cuda_updatePfS_5ParmsPfS_R5Parms
.L40:
	movq	%r12, 96(%rsp)
	movl	100(%rsp), %ecx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movq	%r12, 84(%rsp)
	movl	88(%rsp), %esi
	movl	%ebp, 92(%rsp)
	movq	92(%rsp), %rdx
	movl	%r13d, 80(%rsp)
	movq	80(%rsp), %rdi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L41
	movq	40(%rsp), %rsi
	movq	48(%rsp), %rdi
	leaq	72(%rsp), %rdx
	movq	parms(%rip), %rax
	movq	%rax, 72(%rsp)
	call	_Z39__device_stub__Z11cuda_updatePfS_5ParmsPfS_R5Parms
.L41:
	decl	%r14d
	jne	.L42
	call	cudaThreadSynchronize@PLT
	movq	64(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	64(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movq	64(%rsp), %rdx
	movq	56(%rsp), %rsi
	leaq	32(%rsp), %rdi
	call	cudaEventElapsedTime@PLT
	movq	48(%rsp), %rsi
	movl	$2, %ecx
	movq	%rbx, %rdi
	movl	$2684354560, %edx
	call	cudaMemcpy@PLT
	leaq	.LC6(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	cvtss2sd	32(%rsp), %xmm0
	call	__printf_chk@PLT
	movq	40(%rsp), %rdi
	call	cudaFree@PLT
	movq	48(%rsp), %rdi
	call	cudaFree@PLT
	movq	%rbx, %rdi
	call	free@PLT
	movq	56(%rsp), %rdi
	call	cudaEventDestroy@PLT
	movq	64(%rsp), %rdi
	call	cudaEventDestroy@PLT
	movq	248(%rsp), %rax
	subq	%fs:40, %rax
	je	.L43
	call	__stack_chk_fail@PLT
.L43:
	addq	$264, %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
.LFE2030:
	.size	main, .-main
	.text
	.globl	_Z32__device_stub__Z8MyKernelPiS_S_iPiS_S_i
	.type	_Z32__device_stub__Z8MyKernelPiS_S_iPiS_S_i, @function
_Z32__device_stub__Z8MyKernelPiS_S_iPiS_S_i:
.LFB2057:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movq	%rdi, 24(%rsp)
	leaq	56(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	68(%rsp), %rsi
	movq	%rdx, 8(%rsp)
	leaq	40(%rsp), %rdx
	movl	%ecx, 4(%rsp)
	leaq	48(%rsp), %rcx
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 64(%rsp)
	movq	%rax, 104(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	4(%rsp), %rax
	movq	%rax, 128(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 56(%rsp)
	movq	%rax, 68(%rsp)
	movl	$1, 76(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L47
	pushq	48(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z8MyKernelPiS_S_i(%rip), %rdi
	pushq	48(%rsp)
	.cfi_def_cfa_offset 176
	movq	84(%rsp), %rcx
	movl	92(%rsp), %r8d
	movq	72(%rsp), %rsi
	movl	80(%rsp), %edx
	leaq	120(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 168
	popq	%rdx
	.cfi_def_cfa_offset 160
.L47:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L49
	call	__stack_chk_fail@PLT
.L49:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2057:
	.size	_Z32__device_stub__Z8MyKernelPiS_S_iPiS_S_i, .-_Z32__device_stub__Z8MyKernelPiS_S_iPiS_S_i
	.globl	_Z8MyKernelPiS_S_i
	.type	_Z8MyKernelPiS_S_i, @function
_Z8MyKernelPiS_S_i:
.LFB2058:
	.cfi_startproc
	endbr64
	jmp	_Z32__device_stub__Z8MyKernelPiS_S_iPiS_S_i
	.cfi_endproc
.LFE2058:
	.size	_Z8MyKernelPiS_S_i, .-_Z8MyKernelPiS_S_i
	.section	.rodata.str1.1
.LC7:
	.string	"_Z8MyKernelPiS_S_i"
.LC8:
	.string	"_Z11cuda_updatePfS_5Parms"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2060:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	pushq	$0
	.cfi_def_cfa_offset 24
	xorl	%r9d, %r9d
	orl	$-1, %r8d
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC7(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z8MyKernelPiS_S_i(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 48
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r9d, %r9d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC8(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z11cuda_updatePfS_5Parms(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 40
	pushq	$0
	.cfi_def_cfa_offset 48
	call	__cudaRegisterFunction@PLT
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE2060:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.globl	parms
	.data
	.align 8
	.type	parms, @object
	.size	parms, 8
parms:
	.long	1036831949
	.long	1036831949
	.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 <math.h>
#include <stdio.h>
#include <stdlib.h>

#define NXPROB      20480                /* x dimension of problem grid */
#define NYPROB      32768                  /* y dimension of problem grid */
#define STEPS       500                /* number of time steps */
#define MAXWORKER   8                  /* maximum number of worker tasks */
#define MINWORKER   3                  /* minimum number of worker tasks */
#define BEGIN       1                  /* message tag */
#define LTAG        2                  /* message tag */
#define RTAG        3                  /* message tag */
#define NONE        0                  /* indicates no neighbor */
#define DONE        4                  /* message tag */
#define MASTER      0                  /* taskid of first process */

#define BLOCK_H   10
#define BLOCK_V   8
#define THREADS   32

struct Parms {
  float cx;
  float cy;
} parms = {0.1, 0.1};

/**************************************************************************
 *  subroutine update
 ****************************************************************************/
void update(int start, int end, int ny, float *u1, float *u2)
{
   int ix, iy;
   for (ix = start; ix <= end; ix++)
      for (iy = 1; iy <= ny-2; iy++)
         *(u2+ix*ny+iy) = *(u1+ix*ny+iy)  +
                          parms.cx * (*(u1+(ix+1)*ny+iy) +
                          *(u1+(ix-1)*ny+iy) -
                          2.0 * *(u1+ix*ny+iy)) +
                          parms.cy * (*(u1+ix*ny+iy+1) +
                         *(u1+ix*ny+iy-1) -
                          2.0 * *(u1+ix*ny+iy));
}

/*****************************************************************************
 *  subroutine inidat
 *****************************************************************************/
void inidat(int nx, int ny, float *u) {
int ix, iy;
for (ix = 0; ix <= nx-1; ix++)
  for (iy = 0; iy <= ny-1; iy++)
     {*(u+ix*ny+iy) = (float)(ix * (nx - ix - 1) * iy * (ny - iy - 1)%1000);
     //if (*(u+ix*ny+iy) > 10000.0)
     //printf("%f\n", *(u+ix*ny+iy));
    }
}

/**************************************************************************
 * subroutine prtdat
 **************************************************************************/
void prtdat(int nx, int ny, float *u1, const char *fnam) {
int ix, iy;
FILE *fp;

fp = fopen(fnam, "w");
for (iy = ny-1; iy >= 0; iy--) {
  for (ix = 0; ix <= nx-1; ix++) {
    fprintf(fp, "%6.1f", *(u1+ix*ny+iy));
    if (ix != nx-1)
      fprintf(fp, " ");
    else
      fprintf(fp, "\n");
    }
  }
fclose(fp);
}

__global__ void cuda_update(float *u0, float *u1, struct Parms parms)
{
  int ix, iy;
  ix = blockIdx.x * blockDim.x + threadIdx.x + 1;
  iy = blockIdx.y * blockDim.y + threadIdx.y + 1;

  if (ix > 0 && iy > 0)
  {
    if (ix + iy < NXPROB + NYPROB - 2)
    {
      *(u1+ix*NYPROB+iy) = *(u0+ix*NYPROB+iy)  +
                          parms.cx * (*(u0+(ix+1)*NYPROB+iy) +
                          *(u0+(ix-1)*NYPROB+iy) -
                          2.0 * *(u0+ix*NYPROB+iy)) +
                          parms.cy * (*(u0+ix*NYPROB+iy+1) +
                         *(u0+ix*NYPROB+iy-1) -
                          2.0 * *(u0+ix*NYPROB+iy));
    }
  }
}

__global__ void MyKernel(int *a, int *b, int *c, int N) 
{ 
  int idx = threadIdx.x + blockIdx.x * blockDim.x; 
  if (idx < N) 
  {
    c[idx] = a[idx] + b[idx];
  } 
} 

int main (int argc, char *argv[])
{
  int i;
  float *u;
  float *cuda_u0, *cuda_u1;
  hipEvent_t start, stop;
  hipEventCreate(&start);
  hipEventCreate(&stop);
  float ms = 0.0f;
  int block_size;
  int min_grid, grid;
  
  //http://devblogs.nvidia.com/parallelforall/cuda-pro-tip-occupancy-api-simplifies-launch-configuration/
  hipOccupancyMaxPotentialBlockSize(&min_grid, &block_size, MyKernel, 0, NXPROB*NYPROB);
  grid = (NXPROB*NYPROB + block_size - 1) / block_size;
  dim3 dimBlocks(BLOCK_H, BLOCK_V);
  dim3 dimThreads((NXPROB / BLOCK_H) + ((NXPROB % BLOCK_H) != 0), (NYPROB / BLOCK_V) + ((NYPROB % BLOCK_V) != 0));

  //malloc host 
  u = (float*)malloc(NXPROB*NYPROB*sizeof(float));

  //malloc device
  hipMalloc((void**)&cuda_u0, (NXPROB*NYPROB*sizeof(float)));
  hipMalloc((void**)&cuda_u1, (NXPROB*NYPROB*sizeof(float)));

  printf("Grid size: X= %d  Y= %d  Time steps= %d\n",NXPROB,NYPROB,STEPS);
  inidat(NXPROB, NYPROB, u); //initialize
  //prtdat(NXPROB, NYPROB, u, "initial.dat"); //print

  //copy from host to device
  hipMemcpy(cuda_u0, u, (NXPROB*NYPROB*sizeof(float)), hipMemcpyHostToDevice);
  hipMemcpy(cuda_u1, u, (NXPROB*NYPROB*sizeof(float)), hipMemcpyHostToDevice);

  hipEventRecord(start, 0);
  for (i = 0; i < STEPS; i+=2)
  { 
      cuda_update<<<grid, block_size>>>(cuda_u0, cuda_u1, parms);
      cuda_update<<<grid, block_size>>>(cuda_u1, cuda_u0, parms);
  }
  hipDeviceSynchronize();
  hipEventRecord(stop, 0);
  hipEventSynchronize(stop);
  hipEventElapsedTime(&ms, start, stop);

  //copy from device to host
  hipMemcpy(u, cuda_u1, (NXPROB*NYPROB*sizeof(float)), hipMemcpyDeviceToHost);
  //prtdat(NXPROB, NYPROB, u, "final.dat");   //print
  printf("Time: %f ms\n", ms);
  
  hipFree(cuda_u0);
  hipFree(cuda_u1);
  free(u);
  hipEventDestroy(start);
  hipEventDestroy(stop);

  return 0;
}

	.text
	.file	"cuda_heat2Dn.hip"
	.globl	_Z6updateiiiPfS_                # -- Begin function _Z6updateiiiPfS_
	.type	_Z6updateiiiPfS_,@function
_Z6updateiiiPfS_:                       # @_Z6updateiiiPfS_
	.cfi_startproc
# %bb.0:
                                        # kill: def $edx killed $edx def $rdx
	cmpl	%esi, %edi
	jg	.LBB0_9
# %bb.1:                                # %.preheader.lr.ph
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r12
	.cfi_def_cfa_offset 32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset %rbx, -40
	.cfi_offset %r12, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leal	-1(%rdx), %r10d
	movslq	%edi, %rdi
	movslq	%edx, %rax
	incl	%esi
	addq	$4, %r8
	shlq	$2, %rax
	leaq	4(%rcx), %r9
	addq	$8, %rcx
	leaq	-4(,%r10,4), %r10
.LBB0_2:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB0_5 Depth 2
	cmpl	$2, %edx
	jg	.LBB0_4
# %bb.3:                                # %.preheader.._crit_edge_crit_edge
                                        #   in Loop: Header=BB0_2 Depth=1
	incq	%rdi
	movq	%rdi, %r11
	jmp	.LBB0_7
.LBB0_4:                                # %.lr.ph
                                        #   in Loop: Header=BB0_2 Depth=1
	leaq	1(%rdi), %r11
	movq	%rax, %rbx
	imulq	%rdi, %rbx
	decq	%rdi
	leaq	(%r8,%rbx), %r14
	imulq	%rax, %rdi
	addq	%r9, %rdi
	movq	%rax, %r15
	imulq	%r11, %r15
	addq	%r9, %r15
	addq	%rcx, %rbx
	xorl	%r12d, %r12d
.LBB0_5:                                #   Parent Loop BB0_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	xorps	%xmm0, %xmm0
	cvtss2sd	-4(%rbx,%r12), %xmm0
	xorps	%xmm1, %xmm1
	cvtss2sd	parms(%rip), %xmm1
	movss	(%r15,%r12), %xmm2              # xmm2 = mem[0],zero,zero,zero
	addss	(%rdi,%r12), %xmm2
	cvtss2sd	%xmm2, %xmm2
	movaps	%xmm0, %xmm3
	addsd	%xmm0, %xmm3
	subsd	%xmm3, %xmm2
	mulsd	%xmm1, %xmm2
	addsd	%xmm0, %xmm2
	xorps	%xmm0, %xmm0
	cvtss2sd	parms+4(%rip), %xmm0
	movss	(%rbx,%r12), %xmm1              # xmm1 = mem[0],zero,zero,zero
	addss	-8(%rbx,%r12), %xmm1
	cvtss2sd	%xmm1, %xmm1
	subsd	%xmm3, %xmm1
	mulsd	%xmm0, %xmm1
	addsd	%xmm2, %xmm1
	xorps	%xmm0, %xmm0
	cvtsd2ss	%xmm1, %xmm0
	movss	%xmm0, (%r14,%r12)
	addq	$4, %r12
	cmpq	%r12, %r10
	jne	.LBB0_5
# %bb.6:                                #   in Loop: Header=BB0_2 Depth=1
	movq	%r11, %rdi
.LBB0_7:                                # %._crit_edge
                                        #   in Loop: Header=BB0_2 Depth=1
	cmpl	%r11d, %esi
	jne	.LBB0_2
# %bb.8:
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	.cfi_restore %rbx
	.cfi_restore %r12
	.cfi_restore %r14
	.cfi_restore %r15
.LBB0_9:                                # %._crit_edge44
	retq
.Lfunc_end0:
	.size	_Z6updateiiiPfS_, .Lfunc_end0-_Z6updateiiiPfS_
	.cfi_endproc
                                        # -- End function
	.globl	_Z6inidatiiPf                   # -- Begin function _Z6inidatiiPf
	.type	_Z6inidatiiPf,@function
_Z6inidatiiPf:                          # @_Z6inidatiiPf
	.cfi_startproc
# %bb.0:
	testl	%edi, %edi
	jle	.LBB1_7
# %bb.1:                                # %.preheader.lr.ph
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movslq	%esi, %rax
	movl	%edi, %ecx
	movl	%eax, %r8d
	addl	$-2, %edi
	leal	-1(%rax), %r9d
	shlq	$2, %rax
	xorl	%r10d, %r10d
	xorl	%r11d, %r11d
.LBB1_2:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_4 Depth 2
	testl	%esi, %esi
	jle	.LBB1_5
# %bb.3:                                # %.lr.ph
                                        #   in Loop: Header=BB1_2 Depth=1
	xorl	%ebx, %ebx
	movl	%r9d, %ebp
	xorl	%r14d, %r14d
.LBB1_4:                                #   Parent Loop BB1_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	%ebp, %r15d
	imull	%ebx, %r15d
	movslq	%r15d, %r15
	imulq	$274877907, %r15, %r12          # imm = 0x10624DD3
	movq	%r12, %r13
	shrq	$63, %r13
	sarq	$38, %r12
	addl	%r13d, %r12d
	imull	$1000, %r12d, %r12d             # imm = 0x3E8
	subl	%r12d, %r15d
	xorps	%xmm0, %xmm0
	cvtsi2ss	%r15d, %xmm0
	movss	%xmm0, (%rdx,%r14,4)
	incq	%r14
	addl	%r10d, %ebx
	decl	%ebp
	cmpq	%r14, %r8
	jne	.LBB1_4
.LBB1_5:                                # %._crit_edge
                                        #   in Loop: Header=BB1_2 Depth=1
	incq	%r11
	addl	%edi, %r10d
	addl	$-2, %edi
	addq	%rax, %rdx
	cmpq	%rcx, %r11
	jne	.LBB1_2
# %bb.6:
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	.cfi_restore %rbx
	.cfi_restore %r12
	.cfi_restore %r13
	.cfi_restore %r14
	.cfi_restore %r15
	.cfi_restore %rbp
.LBB1_7:                                # %._crit_edge21
	retq
.Lfunc_end1:
	.size	_Z6inidatiiPf, .Lfunc_end1-_Z6inidatiiPf
	.cfi_endproc
                                        # -- End function
	.globl	_Z6prtdatiiPfPKc                # -- Begin function _Z6prtdatiiPfPKc
	.type	_Z6prtdatiiPfPKc,@function
_Z6prtdatiiPfPKc:                       # @_Z6prtdatiiPfPKc
	.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	%rdx, %rbx
	movl	%esi, %ebp
                                        # kill: def $edi killed $edi def $rdi
	movq	%rdi, (%rsp)                    # 8-byte Spill
	movl	$.L.str, %esi
	movq	%rcx, %rdi
	callq	fopen
	movq	%rax, %r14
	testl	%ebp, %ebp
	jle	.LBB2_6
# %bb.1:                                # %.preheader.lr.ph
	movq	(%rsp), %rax                    # 8-byte Reload
	leal	-1(%rax), %r12d
	movl	%ebp, %ecx
	movl	%eax, %ebp
	leaq	(,%rcx,4), %r15
	leaq	(%rbx,%rcx,4), %rax
	addq	$-4, %rax
	movq	%rax, 8(%rsp)                   # 8-byte Spill
.LBB2_3:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB2_5 Depth 2
	movq	%rcx, 16(%rsp)                  # 8-byte Spill
	cmpl	$0, (%rsp)                      # 4-byte Folded Reload
	jle	.LBB2_2
# %bb.4:                                # %.lr.ph
                                        #   in Loop: Header=BB2_3 Depth=1
	movq	8(%rsp), %rbx                   # 8-byte Reload
	xorl	%r13d, %r13d
.LBB2_5:                                #   Parent Loop BB2_3 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	xorps	%xmm0, %xmm0
	cvtss2sd	(%rbx), %xmm0
	movl	$.L.str.1, %esi
	movq	%r14, %rdi
	movb	$1, %al
	callq	fprintf
	cmpq	%r13, %r12
	movl	$32, %edi
	movl	$10, %eax
	cmovel	%eax, %edi
	movq	%r14, %rsi
	callq	fputc@PLT
	incq	%r13
	addq	%r15, %rbx
	cmpq	%r13, %rbp
	jne	.LBB2_5
.LBB2_2:                                # %.loopexit
                                        #   in Loop: Header=BB2_3 Depth=1
	movq	16(%rsp), %rcx                  # 8-byte Reload
	leaq	-1(%rcx), %rax
	addq	$-4, 8(%rsp)                    # 8-byte Folded Spill
	cmpq	$2, %rcx
	movq	%rax, %rcx
	jge	.LBB2_3
.LBB2_6:                                # %._crit_edge
	movq	%r14, %rdi
	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	fclose                          # TAILCALL
.Lfunc_end2:
	.size	_Z6prtdatiiPfPKc, .Lfunc_end2-_Z6prtdatiiPfPKc
	.cfi_endproc
                                        # -- End function
	.globl	_Z26__device_stub__cuda_updatePfS_5Parms # -- Begin function _Z26__device_stub__cuda_updatePfS_5Parms
	.type	_Z26__device_stub__cuda_updatePfS_5Parms,@function
_Z26__device_stub__cuda_updatePfS_5Parms: # @_Z26__device_stub__cuda_updatePfS_5Parms
	.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
	movlps	%xmm0, (%rax)
	leaq	32(%rsp), %rcx
	movq	%rdi, (%rcx)
	leaq	24(%rsp), %rdx
	movq	%rsi, (%rdx)
	leaq	80(%rsp), %rbx
	movq	%rcx, (%rbx)
	movq	%rdx, 8(%rbx)
	movq	%rax, 16(%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	$_Z11cuda_updatePfS_5Parms, %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_end3:
	.size	_Z26__device_stub__cuda_updatePfS_5Parms, .Lfunc_end3-_Z26__device_stub__cuda_updatePfS_5Parms
	.cfi_endproc
                                        # -- End function
	.globl	_Z23__device_stub__MyKernelPiS_S_i # -- Begin function _Z23__device_stub__MyKernelPiS_S_i
	.type	_Z23__device_stub__MyKernelPiS_S_i,@function
_Z23__device_stub__MyKernelPiS_S_i:     # @_Z23__device_stub__MyKernelPiS_S_i
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$112, %rsp
	.cfi_def_cfa_offset 160
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	32(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	24(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	4(%rsp), %rdx
	movl	%ecx, (%rdx)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	16(%rsp), %r12
	leaq	8(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z8MyKernelPiS_S_i, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$128, %rsp
	.cfi_adjust_cfa_offset -128
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end4:
	.size	_Z23__device_stub__MyKernelPiS_S_i, .Lfunc_end4-_Z23__device_stub__MyKernelPiS_S_i
	.cfi_endproc
                                        # -- End function
	.globl	main                            # -- Begin function 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	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$48, %rsp
	.cfi_def_cfa_offset 96
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	$2684354560, %r15d              # imm = 0xA0000000
	leaq	32(%rsp), %rdi
	callq	hipEventCreate
	leaq	16(%rsp), %rdi
	callq	hipEventCreate
	movl	$0, 40(%rsp)
	xorl	%r14d, %r14d
	leaq	44(%rsp), %rdi
	leaq	12(%rsp), %rbx
	movl	$_Z8MyKernelPiS_S_i, %edx
	movq	%rbx, %rsi
	xorl	%ecx, %ecx
	movl	$671088640, %r8d                # imm = 0x28000000
	callq	hipOccupancyMaxPotentialBlockSize
	movl	(%rbx), %r12d
	leal	671088639(%r12), %ebp
	movl	$2684354560, %edi               # imm = 0xA0000000
	callq	malloc
	movq	%rax, %rbx
	leaq	24(%rsp), %rdi
	movl	$2684354560, %esi               # imm = 0xA0000000
	callq	hipMalloc
	movq	%rsp, %rdi
	movl	$2684354560, %esi               # imm = 0xA0000000
	callq	hipMalloc
	movl	$.L.str.4, %edi
	movl	$20480, %esi                    # imm = 0x5000
	movl	$32768, %edx                    # imm = 0x8000
	movl	$500, %ecx                      # imm = 0x1F4
	xorl	%eax, %eax
	callq	printf
	movl	$20478, %eax                    # imm = 0x4FFE
	movq	%rbx, %rcx
	xorl	%edx, %edx
.LBB5_1:                                # %.preheader.i
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB5_2 Depth 2
	movl	$32767, %esi                    # imm = 0x7FFF
	xorl	%edi, %edi
	xorl	%r8d, %r8d
.LBB5_2:                                #   Parent Loop BB5_1 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	%esi, %r9d
	imull	%edi, %r9d
	movslq	%r9d, %r9
	imulq	$274877907, %r9, %r10           # imm = 0x10624DD3
	movq	%r10, %r11
	shrq	$63, %r11
	sarq	$38, %r10
	addl	%r11d, %r10d
	imull	$1000, %r10d, %r10d             # imm = 0x3E8
	subl	%r10d, %r9d
	xorps	%xmm0, %xmm0
	cvtsi2ss	%r9d, %xmm0
	movss	%xmm0, (%rcx,%r8,4)
	incq	%r8
	decl	%esi
	addl	%r14d, %edi
	cmpq	$32768, %r8                     # imm = 0x8000
	jne	.LBB5_2
# %bb.3:                                # %._crit_edge.i
                                        #   in Loop: Header=BB5_1 Depth=1
	incq	%rdx
	addq	$131072, %rcx                   # imm = 0x20000
	addl	%eax, %r14d
	addl	$-2, %eax
	cmpq	$20480, %rdx                    # imm = 0x5000
	jne	.LBB5_1
# %bb.4:                                # %_Z6inidatiiPf.exit
	movl	%ebp, %eax
	cltd
	idivl	%r12d
	movl	%eax, %r14d
	movq	24(%rsp), %rdi
	movl	$2684354560, %edx               # imm = 0xA0000000
	movq	%rbx, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	movq	(%rsp), %rdi
	movl	$2684354560, %edx               # imm = 0xA0000000
	movq	%rbx, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	movq	32(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	addq	%r15, %r14
	addq	$1610612736, %r14               # imm = 0x60000000
	movl	$-2, %ebp
.LBB5_5:                                # =>This Inner Loop Header: Depth=1
	movl	12(%rsp), %eax
	leaq	(%r15,%rax), %rdx
	addq	$1610612736, %rdx               # imm = 0x60000000
	movq	%r14, %rdi
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB5_7
# %bb.6:                                #   in Loop: Header=BB5_5 Depth=1
	movq	24(%rsp), %rdi
	movq	(%rsp), %rsi
	movsd	parms(%rip), %xmm0              # xmm0 = mem[0],zero
	callq	_Z26__device_stub__cuda_updatePfS_5Parms
.LBB5_7:                                #   in Loop: Header=BB5_5 Depth=1
	movl	12(%rsp), %eax
	leaq	(%r15,%rax), %rdx
	addq	$1610612736, %rdx               # imm = 0x60000000
	movq	%r14, %rdi
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB5_9
# %bb.8:                                #   in Loop: Header=BB5_5 Depth=1
	movq	(%rsp), %rdi
	movq	24(%rsp), %rsi
	movsd	parms(%rip), %xmm0              # xmm0 = mem[0],zero
	callq	_Z26__device_stub__cuda_updatePfS_5Parms
.LBB5_9:                                #   in Loop: Header=BB5_5 Depth=1
	addl	$2, %ebp
	cmpl	$498, %ebp                      # imm = 0x1F2
	jb	.LBB5_5
# %bb.10:
	callq	hipDeviceSynchronize
	movq	16(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	16(%rsp), %rdi
	callq	hipEventSynchronize
	movq	32(%rsp), %rsi
	movq	16(%rsp), %rdx
	leaq	40(%rsp), %r14
	movq	%r14, %rdi
	callq	hipEventElapsedTime
	movq	(%rsp), %rsi
	movl	$2684354560, %edx               # imm = 0xA0000000
	movq	%rbx, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	xorps	%xmm0, %xmm0
	cvtss2sd	(%r14), %xmm0
	movl	$.L.str.5, %edi
	movb	$1, %al
	callq	printf
	movq	24(%rsp), %rdi
	callq	hipFree
	movq	(%rsp), %rdi
	callq	hipFree
	movq	%rbx, %rdi
	callq	free
	movq	32(%rsp), %rdi
	callq	hipEventDestroy
	movq	16(%rsp), %rdi
	callq	hipEventDestroy
	xorl	%eax, %eax
	addq	$48, %rsp
	.cfi_def_cfa_offset 48
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.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_end5:
	.size	main, .Lfunc_end5-main
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$32, %rsp
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -16
	movq	__hip_gpubin_handle(%rip), %rbx
	testq	%rbx, %rbx
	jne	.LBB6_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB6_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z11cuda_updatePfS_5Parms, %esi
	movl	$.L__unnamed_1, %edx
	movl	$.L__unnamed_1, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z8MyKernelPiS_S_i, %esi
	movl	$.L__unnamed_2, %edx
	movl	$.L__unnamed_2, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$__hip_module_dtor, %edi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_end6:
	.size	__hip_module_ctor, .Lfunc_end6-__hip_module_ctor
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_dtor
	.type	__hip_module_dtor,@function
__hip_module_dtor:                      # @__hip_module_dtor
	.cfi_startproc
# %bb.0:
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	je	.LBB7_2
# %bb.1:
	pushq	%rax
	.cfi_def_cfa_offset 16
	callq	__hipUnregisterFatBinary
	movq	$0, __hip_gpubin_handle(%rip)
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
.LBB7_2:
	retq
.Lfunc_end7:
	.size	__hip_module_dtor, .Lfunc_end7-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	parms,@object                   # @parms
	.data
	.globl	parms
	.p2align	3, 0x0
parms:
	.long	0x3dcccccd                      # float 0.100000001
	.long	0x3dcccccd                      # float 0.100000001
	.size	parms, 8

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

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"%6.1f"
	.size	.L.str.1, 6

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

	.type	_Z8MyKernelPiS_S_i,@object      # @_Z8MyKernelPiS_S_i
	.globl	_Z8MyKernelPiS_S_i
	.p2align	3, 0x0
_Z8MyKernelPiS_S_i:
	.quad	_Z23__device_stub__MyKernelPiS_S_i
	.size	_Z8MyKernelPiS_S_i, 8

	.type	.L.str.4,@object                # @.str.4
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.4:
	.asciz	"Grid size: X= %d  Y= %d  Time steps= %d\n"
	.size	.L.str.4, 41

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"Time: %f ms\n"
	.size	.L.str.5, 13

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z11cuda_updatePfS_5Parms"
	.size	.L__unnamed_1, 26

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_Z8MyKernelPiS_S_i"
	.size	.L__unnamed_2, 19

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

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

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym _Z26__device_stub__cuda_updatePfS_5Parms
	.addrsig_sym _Z23__device_stub__MyKernelPiS_S_i
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z11cuda_updatePfS_5Parms
	.addrsig_sym _Z8MyKernelPiS_S_i
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z11cuda_updatePfS_5Parms ; -- Begin function _Z11cuda_updatePfS_5Parms
	.globl	_Z11cuda_updatePfS_5Parms
	.p2align	8
	.type	_Z11cuda_updatePfS_5Parms,@function
_Z11cuda_updatePfS_5Parms:              ; @_Z11cuda_updatePfS_5Parms
; %bb.0:
	s_load_b32 s2, s[0:1], 0x24
	v_and_b32_e32 v3, 0x3ff, v0
	v_bfe_u32 v0, v0, 10, 10
	s_waitcnt lgkmcnt(0)
	s_lshr_b32 s3, s2, 16
	s_and_b32 s2, s2, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s14, s2, v[3:4]
	v_mad_u64_u32 v[3:4], null, s15, s3, v[0:1]
	v_add_nc_u32_e32 v2, 1, v1
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_add_nc_u32_e32 v0, 1, v3
	v_max_u32_e32 v3, v1, v3
	v_add_nc_u32_e32 v4, v0, v2
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_cmp_gt_u32_e32 vcc_lo, 0x7fffffff, v3
	v_cmp_gt_i32_e64 s2, 0xcffe, v4
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_and_b32 s2, vcc_lo, s2
	s_and_saveexec_b32 s3, s2
	s_cbranch_execz .LBB0_2
; %bb.1:
	s_load_b128 s[4:7], s[0:1], 0x0
	v_lshlrev_b32_e32 v3, 15, v1
	v_lshlrev_b32_e32 v5, 15, v2
	v_mov_b32_e32 v1, 0
	s_load_b64 s[0:1], s[0:1], 0x10
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_nc_u32_e32 v7, 0x10000, v3
	v_ashrrev_i32_e32 v6, 31, v5
	v_ashrrev_i32_e32 v4, 31, v3
	v_lshlrev_b64 v[9:10], 2, v[0:1]
	s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_4)
	v_ashrrev_i32_e32 v8, 31, v7
	v_lshlrev_b64 v[5:6], 2, v[5:6]
	s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_lshlrev_b64 v[0:1], 2, v[3:4]
	v_lshlrev_b64 v[2:3], 2, v[7:8]
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_4)
	v_add_co_u32 v4, vcc_lo, s4, v5
	v_add_co_ci_u32_e32 v8, vcc_lo, s5, v6, vcc_lo
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_4)
	v_add_co_u32 v2, vcc_lo, s4, v2
	v_add_co_ci_u32_e32 v3, vcc_lo, s5, v3, vcc_lo
	v_add_co_u32 v7, vcc_lo, s4, v0
	v_add_co_ci_u32_e32 v11, vcc_lo, s5, v1, vcc_lo
	s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_4)
	v_add_co_u32 v0, vcc_lo, v2, v9
	v_add_co_ci_u32_e32 v1, vcc_lo, v3, v10, vcc_lo
	s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_4)
	v_add_co_u32 v2, vcc_lo, v7, v9
	v_add_co_ci_u32_e32 v3, vcc_lo, v11, v10, vcc_lo
	v_add_co_u32 v7, vcc_lo, v4, v9
	v_add_co_ci_u32_e32 v8, vcc_lo, v8, v10, vcc_lo
	s_clause 0x2
	global_load_b32 v4, v[0:1], off
	global_load_b32 v3, v[2:3], off
	global_load_b96 v[0:2], v[7:8], off offset:-4
	v_cvt_f64_f32_e32 v[13:14], s1
	s_waitcnt vmcnt(0)
	v_dual_add_f32 v7, v4, v3 :: v_dual_add_f32 v2, v2, v0
	v_cvt_f64_f32_e32 v[3:4], v1
	v_cvt_f64_f32_e32 v[0:1], s0
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_4)
	v_cvt_f64_f32_e32 v[7:8], v7
	v_cvt_f64_f32_e32 v[11:12], v2
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[7:8], v[3:4], -2.0, v[7:8]
	v_fma_f64 v[0:1], v[7:8], v[0:1], v[3:4]
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[2:3], v[3:4], -2.0, v[11:12]
	v_fma_f64 v[0:1], v[2:3], v[13:14], v[0:1]
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_2)
	v_cvt_f32_f64_e32 v2, v[0:1]
	v_add_co_u32 v0, vcc_lo, s6, v5
	v_add_co_ci_u32_e32 v1, vcc_lo, s7, v6, vcc_lo
	v_add_co_u32 v0, vcc_lo, v0, v9
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v1, vcc_lo, v1, v10, vcc_lo
	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 _Z11cuda_updatePfS_5Parms
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 280
		.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 15
		.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	_Z11cuda_updatePfS_5Parms, .Lfunc_end0-_Z11cuda_updatePfS_5Parms
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 464
; NumSgprs: 18
; NumVgprs: 15
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 15
; 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
	.protected	_Z8MyKernelPiS_S_i      ; -- Begin function _Z8MyKernelPiS_S_i
	.globl	_Z8MyKernelPiS_S_i
	.p2align	8
	.type	_Z8MyKernelPiS_S_i,@function
_Z8MyKernelPiS_S_i:                     ; @_Z8MyKernelPiS_S_i
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x2c
	s_load_b32 s3, s[0:1], 0x18
	s_waitcnt lgkmcnt(0)
	s_and_b32 s2, s2, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s15, s2, v[0:1]
	s_mov_b32 s2, exec_lo
	v_cmpx_gt_i32_e64 s3, v1
	s_cbranch_execz .LBB1_2
; %bb.1:
	s_load_b128 s[4:7], s[0:1], 0x0
	v_ashrrev_i32_e32 v2, 31, v1
	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[1:2]
	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_nc_u32_e32 v2, v3, v2
	global_store_b32 v[0:1], v2, off
.LBB1_2:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z8MyKernelPiS_S_i
		.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 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_end1:
	.size	_Z8MyKernelPiS_S_i, .Lfunc_end1-_Z8MyKernelPiS_S_i
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 180
; 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: 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:           8
        .value_kind:     by_value
      - .offset:         24
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         28
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         32
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         36
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         38
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         40
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         42
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         44
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         46
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         64
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         88
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 280
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z11cuda_updatePfS_5Parms
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z11cuda_updatePfS_5Parms.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     15
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         16
        .size:           8
        .value_kind:     global_buffer
      - .offset:         24
        .size:           4
        .value_kind:     by_value
      - .offset:         32
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         36
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         40
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         44
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         46
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         48
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         50
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         52
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         54
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         88
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         96
        .size:           2
        .value_kind:     hidden_grid_dims
    .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:           _Z8MyKernelPiS_S_i
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z8MyKernelPiS_S_i.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
