    #include <stdio.h>
    #include <cuda.h>
    #include <math.h>
    
    #define BLOCK_SIZE 16
    
    #define PI 3.141592653589793
    
    // GPU subroutines
    __global__ void GPU_find_potential(int Nr, int Nz, float dr2, float dz2, float *Phi_0, float *Phi_1, float *ChargeSource);
    
    //////////////////////////////////////////////
    int main(void)
    {
    
      // atmosphere properties
      int Nr, Nz;            // grid size [0,...,Nr][0,...,Nz]
      float Rmax, Zmax;      // grid boundaries (in km)
      float dr, dz;          // grid cell size
      float dr2, dz2;        // grid cell size squared
      float *Potential_0, *Potential_1; // electric potentital
      float *charge_source;  // external charge 
      float zcharge,a,Q;   // external charge parameters
    
      // GPU variables
      float *GPU_Potential_0, *GPU_Potential_1; // electric potential
      float *GPU_charge_source;      // external charge 
      dim3 dimBlock, dimGrid;
    
      int i,k,ik;   // counters over the grid
      int n, Nn; // iteration
      float r,z;    // coordinates
    
      // output variables
      FILE *DATAOUT;
      char filename[255];
      
       // Set GPU
       cudaSetDevice(0);
    
       // set atmosphere properties
       Rmax=300.0; // km
       Zmax=100.0; // km
       Nr = 300; Nz = 100; // this gives 1km x 1km grid
       dr = Rmax/Nr; dr2 = dr*dr;
       dz = Zmax/Nz; dz2 = dz*dz;
       zcharge = 10.0;
       a = 3.0;
       Q = 200.0; // total charge
       Q = Q/pow(a*sqrt(PI),3.0)/8.854E-12;
    
       Nn=20001; // iterations
    
       // set varaiables
       Potential_0 = (float *)malloc(sizeof(float)*(Nr+1)*(Nz+1));
       Potential_1 = (float *)malloc(sizeof(float)*(Nr+1)*(Nz+1));
       charge_source = (float *)malloc(sizeof(float)*(Nr+1)*(Nz+1));
    
       // allocate GPU variables
       cudaMalloc((void **) &GPU_Potential_0, sizeof(float)*(Nr+1)*(Nz+1));
       cudaMalloc((void **) &GPU_Potential_1, sizeof(float)*(Nr+1)*(Nz+1));
       cudaMalloc((void **) &GPU_charge_source, sizeof(float)*(Nr+1)*(Nz+1));
    
       // set the external charge 
       for (i=0;i<=Nr;i++) for (k=0;k<=Nz;k++) {
          ik = (Nr+1)*k+i;
          r = i*dr; z = k*dz;
          Potential_0[ik]=0.0;
          Potential_1[ik]=0.0;
          charge_source[ik]=Q*exp(-((z-zcharge)*(z-zcharge)+r*r)/(a*a));
       }
    
       // transfer data to GPU
       cudaMemcpy(GPU_Potential_0, Potential_0, sizeof(float)*(Nr+1)*(Nz+1), cudaMemcpyHostToDevice);
       cudaMemcpy(GPU_Potential_1, Potential_1, sizeof(float)*(Nr+1)*(Nz+1), cudaMemcpyHostToDevice);
       cudaMemcpy(GPU_charge_source, charge_source, sizeof(float)*(Nr+1)*(Nz+1), cudaMemcpyHostToDevice);
    
       // run the electric field calculation 
       dimBlock.x=BLOCK_SIZE;
       dimBlock.y=BLOCK_SIZE;
       dimGrid.x=(int)(Nr/BLOCK_SIZE)+1;
       dimGrid.y=(int)(Nz/BLOCK_SIZE)+1;
       for (n=1;n<=Nn;n++) {
         if (n%2==1)
           GPU_find_potential<<<dimGrid,dimBlock>>>(Nr,Nz,dr2,dz2,GPU_Potential_0,GPU_Potential_1,GPU_charge_source);
         else
           GPU_find_potential<<<dimGrid,dimBlock>>>(Nr,Nz,dr2,dz2,GPU_Potential_1,GPU_Potential_0,GPU_charge_source);
         cudaThreadSynchronize();
       }
    
       // retrieve data from GPU
       cudaMemcpy(Potential_1, GPU_Potential_1, sizeof(float)*(Nr+1)*(Nz+1), cudaMemcpyDeviceToHost);
    
       // data output
       sprintf (filename,"GPU_POTENTIAL.dat");
       DATAOUT = fopen(filename,"w");
       fprintf(DATAOUT,"%d %d\n",Nr,Nz);
       for (i=0;i<=Nr;i++) {
         for (k=0;k<=Nz;k++) {
           ik = (Nr+1)*k+i;
           fprintf(DATAOUT,"%E ",Potential_1[ik]);
         }
         fprintf(DATAOUT,"\n");
       }
       fclose(DATAOUT);
    
    
       // free the memory
       free(Potential_0);
       free(Potential_1);
       free(charge_source);
       cudaFree(GPU_Potential_0); 
       cudaFree(GPU_Potential_1); 
       cudaFree(GPU_charge_source); 
    }
    /////////////////////////////////////////////////////
    /////////////////////////////////////////////////////
    __global__ void GPU_find_potential(int Nr, int Nz, float dr2, float dz2, float *Phi_0, float *Phi_1, float *ChargeSource){
     
     // localy shared data for this block
     __shared__ float PhiBlock[BLOCK_SIZE+2][BLOCK_SIZE+2];
     // updated potential
     float Phi;
    
     // starting index for this block
     int i0 = BLOCK_SIZE * blockIdx.x;
     int k0 = BLOCK_SIZE * blockIdx.y;
    
     // index of this thread in the r-z grid
     int it = threadIdx.x;
     int kt = threadIdx.y;
     int i = i0 + it;
     int k = k0 + kt;
     int ik = (Nr+1)*k + i;
     
     // check if the point is within the r-z grid
     if (i<=Nr && k<=Nz) {
     
       // get the data from global into the shared memory
       PhiBlock[it+1][kt+1]=Phi_0[ik];
       if (i==0) PhiBlock[it][kt+1]=0.0;
       else if (it==0) PhiBlock[it][kt+1]=Phi_0[ik-1];
       if (i==Nr) PhiBlock[it+2][kt+1]=0.0;
       else if (it==BLOCK_SIZE-1) PhiBlock[it+2][kt+1]=Phi_0[ik+1];
       if (k==0) PhiBlock[it+1][kt]=0.0;
       else if (kt==0) PhiBlock[it+1][kt]=Phi_0[ik-(Nr+1)];
       if (k==Nz) PhiBlock[it+1][kt+2]=0.0;
       else if (kt==BLOCK_SIZE-1) PhiBlock[it+1][kt+2]=Phi_0[ik+(Nr+1)];
     }
    
     // synchornize threads to make sure that all data is loaded
     // (We exit "if" because this has to be done for all threads within the block)
     __syncthreads();
    
     if (i<=Nr && k<=Nz) {
    
       // calculate the updated potential
       if (k==0 || k==Nz) Phi = 0.0; // forced by boundary condition
       else if (i>0) {
         Phi=PhiBlock[it][kt+1]*dz2*(1.0-0.5/i);
         Phi += PhiBlock[it+1][kt]*dr2;
         Phi += PhiBlock[it+2][kt+1]*dz2*(1.0+0.5/i);
         Phi += PhiBlock[it+1][kt+2]*dr2;
         Phi += ChargeSource[ik]*dr2*dz2;
         Phi /= (2*(dr2+dz2));
       }
       else {
         Phi = PhiBlock[it+1][kt]*dr2;
         Phi += PhiBlock[it+2][kt+1]*dz2*4;
         Phi += PhiBlock[it+1][kt+2]*dr2;
         Phi += ChargeSource[ik]*dr2*dz2;
         Phi /= (2*(dr2+2*dz2));
       }
    
       // store the result
       Phi_1[ik]=Phi;
    
     } // end of: if (i<=Nr && k<=Nz) 
    
    }
	.file	"tmpxft_00373978_00000000-6_poission.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2030:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2030:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z46__device_stub__Z18GPU_find_potentialiiffPfS_S_iiffPfS_S_
	.type	_Z46__device_stub__Z18GPU_find_potentialiiffPfS_S_iiffPfS_S_, @function
_Z46__device_stub__Z18GPU_find_potentialiiffPfS_S_iiffPfS_S_:
.LFB2052:
	.cfi_startproc
	endbr64
	subq	$184, %rsp
	.cfi_def_cfa_offset 192
	movl	%edi, 44(%rsp)
	leaq	64(%rsp), %rdi
	movl	%esi, 40(%rsp)
	leaq	76(%rsp), %rsi
	movq	%rdx, 24(%rsp)
	leaq	48(%rsp), %rdx
	movq	%rcx, 16(%rsp)
	leaq	56(%rsp), %rcx
	movq	%r8, 8(%rsp)
	movss	%xmm0, 36(%rsp)
	movss	%xmm1, 32(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 168(%rsp)
	xorl	%eax, %eax
	leaq	44(%rsp), %rax
	movl	$1, 72(%rsp)
	movq	%rax, 112(%rsp)
	leaq	40(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	36(%rsp), %rax
	movq	%rax, 128(%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 136(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 144(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 152(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 160(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 64(%rsp)
	movq	%rax, 76(%rsp)
	movl	$1, 84(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L2
	pushq	56(%rsp)
	.cfi_def_cfa_offset 200
	leaq	_Z18GPU_find_potentialiiffPfS_S_(%rip), %rdi
	pushq	56(%rsp)
	.cfi_def_cfa_offset 208
	movq	92(%rsp), %rcx
	movl	100(%rsp), %r8d
	movq	80(%rsp), %rsi
	movl	88(%rsp), %edx
	leaq	128(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 200
	popq	%rdx
	.cfi_def_cfa_offset 192
.L2:
	movq	168(%rsp), %rax
	subq	%fs:40, %rax
	je	.L4
	call	__stack_chk_fail@PLT
.L4:
	addq	$184, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2052:
	.size	_Z46__device_stub__Z18GPU_find_potentialiiffPfS_S_iiffPfS_S_, .-_Z46__device_stub__Z18GPU_find_potentialiiffPfS_S_iiffPfS_S_
	.globl	_Z18GPU_find_potentialiiffPfS_S_
	.type	_Z18GPU_find_potentialiiffPfS_S_, @function
_Z18GPU_find_potentialiiffPfS_S_:
.LFB2053:
	.cfi_startproc
	endbr64
	jmp	_Z46__device_stub__Z18GPU_find_potentialiiffPfS_S_iiffPfS_S_
	.cfi_endproc
.LFE2053:
	.size	_Z18GPU_find_potentialiiffPfS_S_, .-_Z18GPU_find_potentialiiffPfS_S_
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC6:
	.string	"GPU_POTENTIAL.dat"
.LC7:
	.string	"w"
.LC8:
	.string	"%d %d\n"
.LC9:
	.string	"%E "
.LC10:
	.string	"\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2027:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	xorl	%edi, %edi
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	xorl	%r14d, %r14d
	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	$344, %rsp
	.cfi_def_cfa_offset 400
	movq	%fs:40, %rax
	movq	%rax, 328(%rsp)
	xorl	%eax, %eax
	movl	$1, 56(%rsp)
	movl	$1, 68(%rsp)
	call	cudaSetDevice@PLT
	movl	$121604, %edi
	call	malloc@PLT
	movl	$121604, %edi
	movq	%rax, %r12
	call	malloc@PLT
	movl	$121604, %edi
	movq	%rax, %rbx
	call	malloc@PLT
	leaq	24(%rsp), %rdi
	movl	$121604, %esi
	movq	%rax, %rbp
	call	cudaMalloc@PLT
	leaq	32(%rsp), %rdi
	movl	$121604, %esi
	call	cudaMalloc@PLT
	leaq	40(%rsp), %rdi
	movl	$121604, %esi
	call	cudaMalloc@PLT
.L9:
	cvtsi2ssl	%r14d, %xmm0
	leaq	0(,%r14,4), %r13
	xorl	%r15d, %r15d
	mulss	%xmm0, %xmm0
	movss	%xmm0, 8(%rsp)
.L10:
	cvtsi2ssl	%r15d, %xmm0
	subss	.LC1(%rip), %xmm0
	incl	%r15d
	movl	$0x00000000, (%r12,%r13)
	movl	$0x00000000, (%rbx,%r13)
	mulss	%xmm0, %xmm0
	addss	8(%rsp), %xmm0
	xorps	.LC2(%rip), %xmm0
	divss	.LC3(%rip), %xmm0
	call	expf@PLT
	mulss	.LC4(%rip), %xmm0
	movss	%xmm0, 0(%rbp,%r13)
	addq	$1204, %r13
	cmpl	$101, %r15d
	jne	.L10
	incq	%r14
	cmpq	$301, %r14
	jne	.L9
	movq	24(%rsp), %rdi
	movl	$1, %ecx
	movl	$121604, %edx
	movq	%r12, %rsi
	movl	$1, %r13d
	call	cudaMemcpy@PLT
	movq	32(%rsp), %rdi
	movl	$1, %ecx
	movq	%rbx, %rsi
	movl	$121604, %edx
	call	cudaMemcpy@PLT
	movq	40(%rsp), %rdi
	movl	$1, %ecx
	movq	%rbp, %rsi
	movl	$121604, %edx
	call	cudaMemcpy@PLT
	movabsq	$68719476752, %rax
	movq	%rax, 48(%rsp)
	movabsq	$30064771091, %rax
	movq	%rax, 60(%rsp)
.L16:
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movq	48(%rsp), %rdx
	movl	56(%rsp), %ecx
	testl	$1, %r13d
	movq	60(%rsp), %rdi
	movl	68(%rsp), %esi
	je	.L12
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L14
	movq	40(%rsp), %r8
	movq	32(%rsp), %rcx
	movq	24(%rsp), %rdx
	jmp	.L25
.L12:
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L14
	movq	40(%rsp), %r8
	movq	24(%rsp), %rcx
	movq	32(%rsp), %rdx
.L25:
	movss	.LC5(%rip), %xmm1
	movl	$100, %esi
	movl	$300, %edi
	movaps	%xmm1, %xmm0
	call	_Z46__device_stub__Z18GPU_find_potentialiiffPfS_S_iiffPfS_S_
.L14:
	call	cudaThreadSynchronize@PLT
	incl	%r13d
	cmpl	$20002, %r13d
	jne	.L16
	movq	32(%rsp), %rsi
	movl	$2, %ecx
	movq	%rbx, %rdi
	xorl	%r14d, %r14d
	movl	$121604, %edx
	call	cudaMemcpy@PLT
	leaq	73(%rsp), %rdi
	leaq	.LC6(%rip), %rsi
	call	strcpy@PLT
	leaq	.LC7(%rip), %rsi
	movq	%rax, %rdi
	call	fopen@PLT
	movl	$100, %r8d
	movl	$300, %ecx
	leaq	.LC8(%rip), %rdx
	movq	%rax, 8(%rsp)
	movq	%rax, %rdi
	movl	$2, %esi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
.L17:
	leaq	(%rbx,%r14,4), %r15
	xorl	%r13d, %r13d
.L18:
	movq	8(%rsp), %rdi
	movl	$2, %esi
	movb	$1, %al
	incl	%r13d
	leaq	.LC9(%rip), %rdx
	cvtss2sd	(%r15), %xmm0
	addq	$1204, %r15
	call	__fprintf_chk@PLT
	cmpl	$101, %r13d
	jne	.L18
	movq	8(%rsp), %rdi
	movl	$2, %esi
	xorl	%eax, %eax
	incq	%r14
	leaq	.LC10(%rip), %rdx
	call	__fprintf_chk@PLT
	cmpq	$301, %r14
	jne	.L17
	movq	8(%rsp), %rdi
	call	fclose@PLT
	movq	%r12, %rdi
	call	free@PLT
	movq	%rbx, %rdi
	call	free@PLT
	movq	%rbp, %rdi
	call	free@PLT
	movq	24(%rsp), %rdi
	call	cudaFree@PLT
	movq	32(%rsp), %rdi
	call	cudaFree@PLT
	movq	40(%rsp), %rdi
	call	cudaFree@PLT
	movq	328(%rsp), %rax
	subq	%fs:40, %rax
	je	.L20
	call	__stack_chk_fail@PLT
.L20:
	addq	$344, %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
.LFE2027:
	.size	main, .-main
	.section	.rodata.str1.1
.LC11:
	.string	"_Z18GPU_find_potentialiiffPfS_S_"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2055:
	.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	.LC11(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z18GPU_find_potentialiiffPfS_S_(%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
.LFE2055:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.section	.rodata.cst4,"aM",@progbits,4
	.align 4
.LC1:
	.long	1092616192
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC2:
	.long	-2147483648
	.long	0
	.long	0
	.long	0
	.section	.rodata.cst4
	.align 4
.LC3:
	.long	1091567616
	.align 4
.LC4:
	.long	1376513371
	.align 4
.LC5:
	.long	1065353216
	.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 <stdio.h>
    #include <hip/hip_runtime.h>
    #include <math.h>
    
    #define BLOCK_SIZE 16
    
    #define PI 3.141592653589793
    
    // GPU subroutines
    __global__ void GPU_find_potential(int Nr, int Nz, float dr2, float dz2, float *Phi_0, float *Phi_1, float *ChargeSource);
    
    //////////////////////////////////////////////
    int main(void)
    {
    
      // atmosphere properties
      int Nr, Nz;            // grid size [0,...,Nr][0,...,Nz]
      float Rmax, Zmax;      // grid boundaries (in km)
      float dr, dz;          // grid cell size
      float dr2, dz2;        // grid cell size squared
      float *Potential_0, *Potential_1; // electric potentital
      float *charge_source;  // external charge 
      float zcharge,a,Q;   // external charge parameters
    
      // GPU variables
      float *GPU_Potential_0, *GPU_Potential_1; // electric potential
      float *GPU_charge_source;      // external charge 
      dim3 dimBlock, dimGrid;
    
      int i,k,ik;   // counters over the grid
      int n, Nn; // iteration
      float r,z;    // coordinates
    
      // output variables
      FILE *DATAOUT;
      char filename[255];
      
       // Set GPU
       hipSetDevice(0);
    
       // set atmosphere properties
       Rmax=300.0; // km
       Zmax=100.0; // km
       Nr = 300; Nz = 100; // this gives 1km x 1km grid
       dr = Rmax/Nr; dr2 = dr*dr;
       dz = Zmax/Nz; dz2 = dz*dz;
       zcharge = 10.0;
       a = 3.0;
       Q = 200.0; // total charge
       Q = Q/pow(a*sqrt(PI),3.0)/8.854E-12;
    
       Nn=20001; // iterations
    
       // set varaiables
       Potential_0 = (float *)malloc(sizeof(float)*(Nr+1)*(Nz+1));
       Potential_1 = (float *)malloc(sizeof(float)*(Nr+1)*(Nz+1));
       charge_source = (float *)malloc(sizeof(float)*(Nr+1)*(Nz+1));
    
       // allocate GPU variables
       hipMalloc((void **) &GPU_Potential_0, sizeof(float)*(Nr+1)*(Nz+1));
       hipMalloc((void **) &GPU_Potential_1, sizeof(float)*(Nr+1)*(Nz+1));
       hipMalloc((void **) &GPU_charge_source, sizeof(float)*(Nr+1)*(Nz+1));
    
       // set the external charge 
       for (i=0;i<=Nr;i++) for (k=0;k<=Nz;k++) {
          ik = (Nr+1)*k+i;
          r = i*dr; z = k*dz;
          Potential_0[ik]=0.0;
          Potential_1[ik]=0.0;
          charge_source[ik]=Q*exp(-((z-zcharge)*(z-zcharge)+r*r)/(a*a));
       }
    
       // transfer data to GPU
       hipMemcpy(GPU_Potential_0, Potential_0, sizeof(float)*(Nr+1)*(Nz+1), hipMemcpyHostToDevice);
       hipMemcpy(GPU_Potential_1, Potential_1, sizeof(float)*(Nr+1)*(Nz+1), hipMemcpyHostToDevice);
       hipMemcpy(GPU_charge_source, charge_source, sizeof(float)*(Nr+1)*(Nz+1), hipMemcpyHostToDevice);
    
       // run the electric field calculation 
       dimBlock.x=BLOCK_SIZE;
       dimBlock.y=BLOCK_SIZE;
       dimGrid.x=(int)(Nr/BLOCK_SIZE)+1;
       dimGrid.y=(int)(Nz/BLOCK_SIZE)+1;
       for (n=1;n<=Nn;n++) {
         if (n%2==1)
           GPU_find_potential<<<dimGrid,dimBlock>>>(Nr,Nz,dr2,dz2,GPU_Potential_0,GPU_Potential_1,GPU_charge_source);
         else
           GPU_find_potential<<<dimGrid,dimBlock>>>(Nr,Nz,dr2,dz2,GPU_Potential_1,GPU_Potential_0,GPU_charge_source);
         hipDeviceSynchronize();
       }
    
       // retrieve data from GPU
       hipMemcpy(Potential_1, GPU_Potential_1, sizeof(float)*(Nr+1)*(Nz+1), hipMemcpyDeviceToHost);
    
       // data output
       sprintf (filename,"GPU_POTENTIAL.dat");
       DATAOUT = fopen(filename,"w");
       fprintf(DATAOUT,"%d %d\n",Nr,Nz);
       for (i=0;i<=Nr;i++) {
         for (k=0;k<=Nz;k++) {
           ik = (Nr+1)*k+i;
           fprintf(DATAOUT,"%E ",Potential_1[ik]);
         }
         fprintf(DATAOUT,"\n");
       }
       fclose(DATAOUT);
    
    
       // free the memory
       free(Potential_0);
       free(Potential_1);
       free(charge_source);
       hipFree(GPU_Potential_0); 
       hipFree(GPU_Potential_1); 
       hipFree(GPU_charge_source); 
    }
    /////////////////////////////////////////////////////
    /////////////////////////////////////////////////////
    __global__ void GPU_find_potential(int Nr, int Nz, float dr2, float dz2, float *Phi_0, float *Phi_1, float *ChargeSource){
     
     // localy shared data for this block
     __shared__ float PhiBlock[BLOCK_SIZE+2][BLOCK_SIZE+2];
     // updated potential
     float Phi;
    
     // starting index for this block
     int i0 = BLOCK_SIZE * blockIdx.x;
     int k0 = BLOCK_SIZE * blockIdx.y;
    
     // index of this thread in the r-z grid
     int it = threadIdx.x;
     int kt = threadIdx.y;
     int i = i0 + it;
     int k = k0 + kt;
     int ik = (Nr+1)*k + i;
     
     // check if the point is within the r-z grid
     if (i<=Nr && k<=Nz) {
     
       // get the data from global into the shared memory
       PhiBlock[it+1][kt+1]=Phi_0[ik];
       if (i==0) PhiBlock[it][kt+1]=0.0;
       else if (it==0) PhiBlock[it][kt+1]=Phi_0[ik-1];
       if (i==Nr) PhiBlock[it+2][kt+1]=0.0;
       else if (it==BLOCK_SIZE-1) PhiBlock[it+2][kt+1]=Phi_0[ik+1];
       if (k==0) PhiBlock[it+1][kt]=0.0;
       else if (kt==0) PhiBlock[it+1][kt]=Phi_0[ik-(Nr+1)];
       if (k==Nz) PhiBlock[it+1][kt+2]=0.0;
       else if (kt==BLOCK_SIZE-1) PhiBlock[it+1][kt+2]=Phi_0[ik+(Nr+1)];
     }
    
     // synchornize threads to make sure that all data is loaded
     // (We exit "if" because this has to be done for all threads within the block)
     __syncthreads();
    
     if (i<=Nr && k<=Nz) {
    
       // calculate the updated potential
       if (k==0 || k==Nz) Phi = 0.0; // forced by boundary condition
       else if (i>0) {
         Phi=PhiBlock[it][kt+1]*dz2*(1.0-0.5/i);
         Phi += PhiBlock[it+1][kt]*dr2;
         Phi += PhiBlock[it+2][kt+1]*dz2*(1.0+0.5/i);
         Phi += PhiBlock[it+1][kt+2]*dr2;
         Phi += ChargeSource[ik]*dr2*dz2;
         Phi /= (2*(dr2+dz2));
       }
       else {
         Phi = PhiBlock[it+1][kt]*dr2;
         Phi += PhiBlock[it+2][kt+1]*dz2*4;
         Phi += PhiBlock[it+1][kt+2]*dr2;
         Phi += ChargeSource[ik]*dr2*dz2;
         Phi /= (2*(dr2+2*dz2));
       }
    
       // store the result
       Phi_1[ik]=Phi;
    
     } // end of: if (i<=Nr && k<=Nz) 
    
    }
	.text
	.file	"poission.hip"
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function main
.LCPI0_0:
	.long	0xc1200000                      # float -10
.LCPI0_1:
	.long	0xc1100000                      # float -9
.LCPI0_2:
	.long	0x520bed5b                      # float 1.50245655E+11
.LCPI0_3:
	.long	0x3f800000                      # float 1
	.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	$312, %rsp                      # imm = 0x138
	.cfi_def_cfa_offset 368
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	xorl	%r12d, %r12d
	xorl	%edi, %edi
	callq	hipSetDevice
	movl	$121604, %edi                   # imm = 0x1DB04
	callq	malloc
	movq	%rax, %rbx
	movl	$121604, %edi                   # imm = 0x1DB04
	callq	malloc
	movq	%rax, %r14
	movl	$121604, %edi                   # imm = 0x1DB04
	callq	malloc
	movq	%rax, %r15
	leaq	16(%rsp), %rdi
	movl	$121604, %esi                   # imm = 0x1DB04
	callq	hipMalloc
	movq	%rsp, %rdi
	movl	$121604, %esi                   # imm = 0x1DB04
	callq	hipMalloc
	leaq	8(%rsp), %rdi
	movl	$121604, %esi                   # imm = 0x1DB04
	callq	hipMalloc
	movss	.LCPI0_0(%rip), %xmm1           # xmm1 = mem[0],zero,zero,zero
	movss	.LCPI0_1(%rip), %xmm2           # xmm2 = mem[0],zero,zero,zero
	xorl	%r13d, %r13d
	xorl	%eax, %eax
.LBB0_1:                                # %.preheader133
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB0_2 Depth 2
	movq	%rax, 32(%rsp)                  # 8-byte Spill
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	mulss	%xmm0, %xmm0
	movss	%xmm0, 24(%rsp)                 # 4-byte Spill
	movq	%r13, 40(%rsp)                  # 8-byte Spill
	xorl	%ebp, %ebp
.LBB0_2:                                #   Parent Loop BB0_1 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	xorps	%xmm0, %xmm0
	cvtsi2ss	%ebp, %xmm0
	movl	%r12d, (%rbx,%r13)
	movl	%r12d, (%r14,%r13)
	addss	%xmm1, %xmm0
	mulss	%xmm0, %xmm0
	addss	24(%rsp), %xmm0                 # 4-byte Folded Reload
	divss	%xmm2, %xmm0
	callq	expf
	movss	.LCPI0_2(%rip), %xmm3           # xmm3 = mem[0],zero,zero,zero
	movss	.LCPI0_1(%rip), %xmm2           # xmm2 = mem[0],zero,zero,zero
	movss	.LCPI0_0(%rip), %xmm1           # xmm1 = mem[0],zero,zero,zero
	mulss	%xmm3, %xmm0
	movss	%xmm0, (%r15,%r13)
	incq	%rbp
	addq	$1204, %r13                     # imm = 0x4B4
	cmpq	$101, %rbp
	jne	.LBB0_2
# %bb.3:                                #   in Loop: Header=BB0_1 Depth=1
	movq	32(%rsp), %rax                  # 8-byte Reload
	incq	%rax
	movq	40(%rsp), %r13                  # 8-byte Reload
	addq	$4, %r13
	cmpq	$301, %rax                      # imm = 0x12D
	jne	.LBB0_1
# %bb.4:
	movq	16(%rsp), %rdi
	movl	$1, %ebp
	movl	$121604, %edx                   # imm = 0x1DB04
	movq	%rbx, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	movq	(%rsp), %rdi
	movl	$121604, %edx                   # imm = 0x1DB04
	movq	%r14, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	movq	8(%rsp), %rdi
	movl	$121604, %edx                   # imm = 0x1DB04
	movq	%r15, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	movabsq	$30064771091, %r12              # imm = 0x700000013
	movabsq	$68719476752, %r13              # imm = 0x1000000010
.LBB0_5:                                # =>This Inner Loop Header: Depth=1
	movq	%r12, %rdi
	movl	$1, %esi
	movq	%r13, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testb	$1, %bpl
	jne	.LBB0_6
# %bb.8:                                #   in Loop: Header=BB0_5 Depth=1
	testl	%eax, %eax
	jne	.LBB0_11
# %bb.9:                                #   in Loop: Header=BB0_5 Depth=1
	movq	(%rsp), %rdx
	movq	16(%rsp), %rcx
	jmp	.LBB0_10
.LBB0_6:                                #   in Loop: Header=BB0_5 Depth=1
	testl	%eax, %eax
	jne	.LBB0_11
# %bb.7:                                #   in Loop: Header=BB0_5 Depth=1
	movq	16(%rsp), %rdx
	movq	(%rsp), %rcx
.LBB0_10:                               #   in Loop: Header=BB0_5 Depth=1
	movq	8(%rsp), %r8
	movl	$300, %edi                      # imm = 0x12C
	movl	$100, %esi
	movss	.LCPI0_3(%rip), %xmm0           # xmm0 = mem[0],zero,zero,zero
	movaps	%xmm0, %xmm1
	callq	_Z33__device_stub__GPU_find_potentialiiffPfS_S_
.LBB0_11:                               #   in Loop: Header=BB0_5 Depth=1
	callq	hipDeviceSynchronize
	incl	%ebp
	cmpl	$20002, %ebp                    # imm = 0x4E22
	jne	.LBB0_5
# %bb.12:
	movq	(%rsp), %rsi
	movl	$121604, %edx                   # imm = 0x1DB04
	movq	%r14, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	movaps	.L.str(%rip), %xmm0
	leaq	48(%rsp), %rdi
	movaps	%xmm0, (%rdi)
	movw	$116, 16(%rdi)
	movl	$.L.str.1, %esi
	callq	fopen
	movq	%rax, %r12
	xorl	%r13d, %r13d
	movl	$.L.str.2, %esi
	movq	%rax, %rdi
	movl	$300, %edx                      # imm = 0x12C
	movl	$100, %ecx
	xorl	%eax, %eax
	callq	fprintf
	movq	%r14, %rbp
.LBB0_13:                               # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB0_14 Depth 2
	movq	%r13, 24(%rsp)                  # 8-byte Spill
	movq	$-121604, %r13                  # imm = 0xFFFE24FC
.LBB0_14:                               #   Parent Loop BB0_13 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	xorps	%xmm0, %xmm0
	cvtss2sd	121604(%rbp,%r13), %xmm0
	movl	$.L.str.3, %esi
	movq	%r12, %rdi
	movb	$1, %al
	callq	fprintf
	addq	$1204, %r13                     # imm = 0x4B4
	jne	.LBB0_14
# %bb.15:                               #   in Loop: Header=BB0_13 Depth=1
	movl	$10, %edi
	movq	%r12, %rsi
	callq	fputc@PLT
	movq	24(%rsp), %r13                  # 8-byte Reload
	incq	%r13
	addq	$4, %rbp
	cmpq	$301, %r13                      # imm = 0x12D
	jne	.LBB0_13
# %bb.16:
	movq	%r12, %rdi
	callq	fclose
	movq	%rbx, %rdi
	callq	free
	movq	%r14, %rdi
	callq	free
	movq	%r15, %rdi
	callq	free
	movq	16(%rsp), %rdi
	callq	hipFree
	movq	(%rsp), %rdi
	callq	hipFree
	movq	8(%rsp), %rdi
	callq	hipFree
	xorl	%eax, %eax
	addq	$312, %rsp                      # imm = 0x138
	.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	main, .Lfunc_end0-main
	.cfi_endproc
                                        # -- End function
	.globl	_Z33__device_stub__GPU_find_potentialiiffPfS_S_ # -- Begin function _Z33__device_stub__GPU_find_potentialiiffPfS_S_
	.type	_Z33__device_stub__GPU_find_potentialiiffPfS_S_,@function
_Z33__device_stub__GPU_find_potentialiiffPfS_S_: # @_Z33__device_stub__GPU_find_potentialiiffPfS_S_
	.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	$160, %rsp
	.cfi_def_cfa_offset 208
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	20(%rsp), %rax
	movl	%edi, (%rax)
	leaq	16(%rsp), %rdi
	movl	%esi, (%rdi)
	leaq	12(%rsp), %rsi
	movss	%xmm0, (%rsi)
	leaq	8(%rsp), %r9
	movss	%xmm1, (%r9)
	leaq	56(%rsp), %r10
	movq	%rdx, (%r10)
	leaq	48(%rsp), %rdx
	movq	%rcx, (%rdx)
	leaq	40(%rsp), %rcx
	movq	%r8, (%rcx)
	leaq	96(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%r9, 24(%rbx)
	movq	%r10, 32(%rbx)
	movq	%rdx, 40(%rbx)
	movq	%rcx, 48(%rbx)
	leaq	80(%rsp), %r14
	leaq	64(%rsp), %r15
	leaq	32(%rsp), %r12
	leaq	24(%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	$_Z18GPU_find_potentialiiffPfS_S_, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$176, %rsp
	.cfi_adjust_cfa_offset -176
	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	_Z33__device_stub__GPU_find_potentialiiffPfS_S_, .Lfunc_end1-_Z33__device_stub__GPU_find_potentialiiffPfS_S_
	.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	.LBB2_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB2_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z18GPU_find_potentialiiffPfS_S_, %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_end2:
	.size	__hip_module_ctor, .Lfunc_end2-__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	.LBB3_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
.LBB3_2:
	retq
.Lfunc_end3:
	.size	__hip_module_dtor, .Lfunc_end3-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	_Z18GPU_find_potentialiiffPfS_S_,@object # @_Z18GPU_find_potentialiiffPfS_S_
	.section	.rodata,"a",@progbits
	.globl	_Z18GPU_find_potentialiiffPfS_S_
	.p2align	3, 0x0
_Z18GPU_find_potentialiiffPfS_S_:
	.quad	_Z33__device_stub__GPU_find_potentialiiffPfS_S_
	.size	_Z18GPU_find_potentialiiffPfS_S_, 8

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.16,"aMS",@progbits,1
	.p2align	4, 0x0
.L.str:
	.asciz	"GPU_POTENTIAL.dat"
	.size	.L.str, 18

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

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"%d %d\n"
	.size	.L.str.2, 7

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"%E "
	.size	.L.str.3, 4

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

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

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

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

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z18GPU_find_potentialiiffPfS_S_ ; -- Begin function _Z18GPU_find_potentialiiffPfS_S_
	.globl	_Z18GPU_find_potentialiiffPfS_S_
	.p2align	8
	.type	_Z18GPU_find_potentialiiffPfS_S_,@function
_Z18GPU_find_potentialiiffPfS_S_:       ; @_Z18GPU_find_potentialiiffPfS_S_
; %bb.0:
	s_load_b256 s[4:11], s[0:1], 0x0
	v_bfe_u32 v6, v0, 10, 10
	s_load_b64 s[2:3], s[0:1], 0x20
	v_and_b32_e32 v4, 0x3ff, v0
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_lshl_add_u32 v7, s15, 4, v6
	v_lshl_add_u32 v5, s14, 4, v4
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_mul_lo_u32 v0, v7, s4
	v_cmp_ge_i32_e32 vcc_lo, s4, v5
	v_cmp_ge_i32_e64 s0, s5, v7
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_3)
	s_and_b32 s0, vcc_lo, s0
	v_add3_u32 v0, v0, v7, v5
	s_and_saveexec_b32 s1, s0
	s_cbranch_execz .LBB0_25
; %bb.1:
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_2)
	v_ashrrev_i32_e32 v1, 31, v0
	v_lshlrev_b32_e32 v9, 2, v6
	s_mov_b32 s12, exec_lo
	v_lshlrev_b64 v[2:3], 2, v[0:1]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_mad_u32_u24 v8, 0x48, v4, v9
	v_add_co_u32 v2, vcc_lo, s8, v2
	s_delay_alu instid0(VALU_DEP_3)
	v_add_co_ci_u32_e32 v3, vcc_lo, s9, v3, vcc_lo
	global_load_b32 v10, v[2:3], off
	s_waitcnt vmcnt(0)
	ds_store_b32 v8, v10 offset:76
	v_cmpx_ne_u32_e32 0, v5
	s_xor_b32 s12, exec_lo, s12
	s_cbranch_execz .LBB0_5
; %bb.2:
	s_mov_b32 s13, exec_lo
	v_cmpx_eq_u32_e32 0, v4
	s_cbranch_execz .LBB0_4
; %bb.3:
	global_load_b32 v10, v[2:3], off offset:-4
	s_waitcnt vmcnt(0)
	ds_store_b32 v9, v10 offset:4
.LBB0_4:                                ; %Flow152
	s_or_b32 exec_lo, exec_lo, s13
.LBB0_5:                                ; %Flow153
	s_and_not1_saveexec_b32 s12, s12
	s_cbranch_execz .LBB0_7
; %bb.6:
	v_mov_b32_e32 v10, 0
	ds_store_b32 v8, v10 offset:4
.LBB0_7:
	s_or_b32 exec_lo, exec_lo, s12
	s_delay_alu instid0(SALU_CYCLE_1)
	s_mov_b32 s12, exec_lo
	v_cmpx_ne_u32_e64 s4, v5
	s_xor_b32 s12, exec_lo, s12
	s_cbranch_execz .LBB0_11
; %bb.8:
	s_mov_b32 s13, exec_lo
	v_cmpx_eq_u32_e32 15, v4
	s_cbranch_execz .LBB0_10
; %bb.9:
	global_load_b32 v10, v[2:3], off offset:4
	s_waitcnt vmcnt(0)
	ds_store_b32 v9, v10 offset:1228
.LBB0_10:                               ; %Flow150
	s_or_b32 exec_lo, exec_lo, s13
.LBB0_11:                               ; %Flow151
	s_and_not1_saveexec_b32 s12, s12
	s_cbranch_execz .LBB0_13
; %bb.12:
	v_mov_b32_e32 v9, 0
	ds_store_b32 v8, v9 offset:148
.LBB0_13:
	s_or_b32 exec_lo, exec_lo, s12
	v_mul_u32_u24_e32 v9, 0x48, v4
	s_mov_b32 s12, exec_lo
	v_cmpx_ne_u32_e32 0, v7
	s_xor_b32 s12, exec_lo, s12
	s_cbranch_execz .LBB0_17
; %bb.14:
	s_mov_b32 s13, exec_lo
	v_cmpx_eq_u32_e32 0, v6
	s_cbranch_execz .LBB0_16
; %bb.15:
	s_ashr_i32 s14, s4, 31
	v_sub_co_u32 v10, vcc_lo, v0, s4
	v_subrev_co_ci_u32_e32 v11, vcc_lo, s14, v1, vcc_lo
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[10:11], 2, v[10:11]
	v_add_co_u32 v10, vcc_lo, s8, v10
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v11, vcc_lo, s9, v11, vcc_lo
	global_load_b32 v1, v[10:11], off offset:-4
	s_waitcnt vmcnt(0)
	ds_store_b32 v9, v1 offset:72
.LBB0_16:                               ; %Flow148
	s_or_b32 exec_lo, exec_lo, s13
.LBB0_17:                               ; %Flow149
	s_and_not1_saveexec_b32 s8, s12
	s_cbranch_execz .LBB0_19
; %bb.18:
	v_mov_b32_e32 v1, 0
	ds_store_b32 v8, v1 offset:72
.LBB0_19:
	s_or_b32 exec_lo, exec_lo, s8
	s_delay_alu instid0(SALU_CYCLE_1)
	s_mov_b32 s8, exec_lo
	v_cmpx_ne_u32_e64 s5, v7
	s_xor_b32 s8, exec_lo, s8
	s_cbranch_execz .LBB0_23
; %bb.20:
	s_mov_b32 s9, exec_lo
	v_cmpx_eq_u32_e32 15, v6
	s_cbranch_execz .LBB0_22
; %bb.21:
	s_ashr_i32 s13, s4, 31
	s_mov_b32 s12, s4
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_lshl_b64 s[12:13], s[12:13], 2
	v_add_co_u32 v1, vcc_lo, v2, s12
	v_add_co_ci_u32_e32 v2, vcc_lo, s13, v3, vcc_lo
	global_load_b32 v1, v[1:2], off offset:4
	s_waitcnt vmcnt(0)
	ds_store_b32 v9, v1 offset:140
.LBB0_22:                               ; %Flow145
	s_or_b32 exec_lo, exec_lo, s9
                                        ; implicit-def: $vgpr8
.LBB0_23:                               ; %Flow146
	s_and_not1_saveexec_b32 s4, s8
	s_cbranch_execz .LBB0_25
; %bb.24:
	v_mov_b32_e32 v1, 0
	ds_store_b32 v8, v1 offset:80
.LBB0_25:                               ; %Flow154
	s_or_b32 exec_lo, exec_lo, s1
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	s_and_saveexec_b32 s1, s0
	s_cbranch_execz .LBB0_35
; %bb.26:
	v_cmp_ne_u32_e32 vcc_lo, 0, v7
	v_cmp_ne_u32_e64 s0, s5, v7
                                        ; implicit-def: $vgpr3
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_and_b32 s0, vcc_lo, s0
	s_and_saveexec_b32 s1, s0
	s_delay_alu instid0(SALU_CYCLE_1)
	s_xor_b32 s1, exec_lo, s1
	s_cbranch_execz .LBB0_32
; %bb.27:
	v_lshlrev_b32_e32 v2, 2, v6
	s_mov_b32 s0, exec_lo
                                        ; implicit-def: $vgpr3
	v_cmpx_gt_i32_e32 1, v5
	s_xor_b32 s0, exec_lo, s0
	s_cbranch_execz .LBB0_29
; %bb.28:
	v_ashrrev_i32_e32 v1, 31, v0
	v_mad_u32_u24 v2, 0x48, v4, v2
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[5:6], 2, v[0:1]
	v_add_co_u32 v5, vcc_lo, s2, v5
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v6, vcc_lo, s3, v6, vcc_lo
	global_load_b32 v5, v[5:6], off
	ds_load_b32 v4, v2 offset:148
	ds_load_2addr_b32 v[2:3], v2 offset0:18 offset1:20
	s_waitcnt lgkmcnt(1)
	v_mul_f32_e32 v4, s7, v4
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_mul_f32_e32 v4, 4.0, v4
	s_waitcnt lgkmcnt(0)
	v_fmac_f32_e32 v4, s6, v2
	v_fma_f32 v2, s7, 2.0, s6
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_fmac_f32_e32 v4, s6, v3
	s_waitcnt vmcnt(0)
	v_dual_add_f32 v2, v2, v2 :: v_dual_mul_f32 v3, s6, v5
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fmac_f32_e32 v4, s7, v3
	v_div_scale_f32 v3, null, v2, v2, v4
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	v_rcp_f32_e32 v5, v3
	s_waitcnt_depctr 0xfff
	v_fma_f32 v6, -v3, v5, 1.0
	v_fmac_f32_e32 v5, v6, v5
	v_div_scale_f32 v6, vcc_lo, v4, v2, v4
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_f32_e32 v7, v6, v5
	v_fma_f32 v8, -v3, v7, v6
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fmac_f32_e32 v7, v8, v5
	v_fma_f32 v3, -v3, v7, v6
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_div_fmas_f32 v3, v3, v5, v7
                                        ; implicit-def: $vgpr5
	v_div_fixup_f32 v3, v3, v2, v4
                                        ; implicit-def: $vgpr4
                                        ; implicit-def: $vgpr2
.LBB0_29:                               ; %Flow
	s_and_not1_saveexec_b32 s4, s0
	s_cbranch_execz .LBB0_31
; %bb.30:
	v_cvt_f64_i32_e32 v[5:6], v5
	v_ashrrev_i32_e32 v1, 31, v0
	v_mad_u32_u24 v4, 0x48, v4, v2
	ds_load_2addr_b32 v[2:3], v4 offset0:1 offset1:18
	s_waitcnt lgkmcnt(0)
	v_mul_f32_e32 v2, s7, v2
	v_div_scale_f64 v[7:8], null, v[5:6], v[5:6], 0.5
	v_div_scale_f64 v[13:14], vcc_lo, 0.5, v[5:6], 0.5
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	v_rcp_f64_e32 v[9:10], v[7:8]
	s_waitcnt_depctr 0xfff
	v_fma_f64 v[11:12], -v[7:8], v[9:10], 1.0
	v_fma_f64 v[9:10], v[9:10], v[11:12], v[9:10]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[11:12], -v[7:8], v[9:10], 1.0
	v_fma_f64 v[9:10], v[9:10], v[11:12], v[9:10]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_f64 v[11:12], v[13:14], v[9:10]
	v_fma_f64 v[7:8], -v[7:8], v[11:12], v[13:14]
	v_lshlrev_b64 v[13:14], 2, v[0:1]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_co_u32 v13, s0, s2, v13
	v_add_co_ci_u32_e64 v14, s0, s3, v14, s0
	global_load_b32 v13, v[13:14], off
	v_div_fmas_f64 v[7:8], v[7:8], v[9:10], v[11:12]
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_div_fixup_f64 v[5:6], v[7:8], v[5:6], 0.5
	v_cvt_f64_f32_e32 v[7:8], v2
	v_add_f64 v[9:10], -v[5:6], 1.0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_f64 v[7:8], v[9:10], v[7:8]
	v_cvt_f32_f64_e32 v9, v[7:8]
	ds_load_2addr_b32 v[7:8], v4 offset0:20 offset1:37
	v_add_f64 v[4:5], v[5:6], 1.0
	s_waitcnt lgkmcnt(0)
	v_dual_mul_f32 v2, s7, v8 :: v_dual_fmac_f32 v9, s6, v3
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_cvt_f64_f32_e32 v[2:3], v2
	v_cvt_f64_f32_e32 v[8:9], v9
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[2:3], v[4:5], v[2:3], v[8:9]
	v_cvt_f32_f64_e32 v2, v[2:3]
	v_add_f32_e64 v3, s6, s7
	s_waitcnt vmcnt(0)
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_dual_add_f32 v3, v3, v3 :: v_dual_mul_f32 v4, s6, v13
	v_fmac_f32_e32 v2, s6, v7
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fmac_f32_e32 v2, s7, v4
	v_div_scale_f32 v4, null, v3, v3, v2
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	v_rcp_f32_e32 v5, v4
	s_waitcnt_depctr 0xfff
	v_fma_f32 v6, -v4, v5, 1.0
	v_fmac_f32_e32 v5, v6, v5
	v_div_scale_f32 v6, vcc_lo, v2, v3, v2
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_f32_e32 v7, v6, v5
	v_fma_f32 v8, -v4, v7, v6
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fmac_f32_e32 v7, v8, v5
	v_fma_f32 v4, -v4, v7, v6
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_div_fmas_f32 v4, v4, v5, v7
	v_div_fixup_f32 v3, v4, v3, v2
.LBB0_31:                               ; %Flow142
	s_or_b32 exec_lo, exec_lo, s4
.LBB0_32:                               ; %Flow143
	s_and_not1_saveexec_b32 s0, s1
; %bb.33:                               ; %._crit_edge
	v_ashrrev_i32_e32 v1, 31, v0
	v_mov_b32_e32 v3, 0
; %bb.34:
	s_or_b32 exec_lo, exec_lo, s0
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[0:1], 2, v[0:1]
	v_add_co_u32 v0, vcc_lo, s10, v0
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v1, vcc_lo, s11, v1, vcc_lo
	global_store_b32 v[0:1], v3, off
.LBB0_35:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z18GPU_find_potentialiiffPfS_S_
		.amdhsa_group_segment_fixed_size 1296
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 40
		.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	_Z18GPU_find_potentialiiffPfS_S_, .Lfunc_end0-_Z18GPU_find_potentialiiffPfS_S_
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 1340
; NumSgprs: 18
; NumVgprs: 15
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 1296 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
	.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:
      - .offset:         0
        .size:           4
        .value_kind:     by_value
      - .offset:         4
        .size:           4
        .value_kind:     by_value
      - .offset:         8
        .size:           4
        .value_kind:     by_value
      - .offset:         12
        .size:           4
        .value_kind:     by_value
      - .address_space:  global
        .offset:         16
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         24
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         32
        .size:           8
        .value_kind:     global_buffer
    .group_segment_fixed_size: 1296
    .kernarg_segment_align: 8
    .kernarg_segment_size: 40
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z18GPU_find_potentialiiffPfS_S_
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z18GPU_find_potentialiiffPfS_S_.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     15
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
