
#include <iostream>
#include <fstream>
#include <cmath>

// lattice size
int const NX = 256;
int const NY = 256;

int const MaxIter = 200000; // number of Jacobi iterations

void checkError(cudaError_t e)
{
   if (e != cudaSuccess)
   {
      std::cerr << "CUDA error: " << int(e) << " : " << cudaGetErrorString(e) << '\n';
      abort();
   }
}

// CUDA kernel to update the Tnew array based on the Told
// using Jacobi iterate of the Laplace operator

__global__
void Laplace(float* Told, float* Tnew)
{
   // compute the x,y location of the lattice point
   // handled by this thread
   int x = blockIdx.x*blockDim.x + threadIdx.x ;
   int y = blockIdx.y*blockDim.y + threadIdx.y ;

   // get the natural index values of node (x,y) and its neighboring nodes
   int P = y*NX + x;           // node (x,y)         N
   int E = y*NX + (x+1);       // node (x+1,y)       |
   int W = y*NX + (x-1);       // node (x-1,y)    W--P--E
   int N = (y+1)*NX + x;       // node (x,y+1)       |
   int S = (y-1)*NX + x;       // node (x,y-1)       S

   // only update the interior points - fixed boundary conditions
   if(x > 0 && x < (NX-1) && y > 0 && y < (NY-1))
   {
      Tnew[P] = 0.25*(Told[E] + Told[W] + Told[N] + Told[S]);
   }
}

// Initial condition

void Initialize(float* T)
{
   // set everything to zero
   for(int x=0; x < NX; ++x)
   {
      for(int y=0; y < NY; ++y)
      {
         int index = y*NX + x;
         T[index] = 0.0;
      }
   }

   // set left wall to 1
   for(int y=0; y < NY; ++y)
   {
      int index = y*NX;
      T[index] = 1.0;
   }
   // set back wall to a ramp
   for(int x=0; x < NX; ++x)
   {
      int index = (NY-1)*NX + x;
      T[index] = 1.0 - float(x)/NX;
   }
   // set front wall to a sinusoid
   for(int x=0; x < NX; ++x)
   {
      int index = x;
      T[index] = std::cos(3.0 * M_PI_2 * float(x)/NX);
   }
}

int main()
{
   // The temperature matrix on the CPU
   float* T = new float[NX*NY];


   // Storage on the device (GPU)
   float* T1_device;
   float* T2_device;

    // initialize array on the host
    Initialize(T);

    // allocate storage space on the GPU
    checkError(cudaMalloc(&T1_device, NX*NY*sizeof(float)));
    checkError(cudaMalloc(&T2_device, NX*NY*sizeof(float)));

    // copy (initialized) host arrays to the GPU memory from CPU memory
    checkError(cudaMemcpy(T1_device, T, NX*NY*sizeof(float), cudaMemcpyHostToDevice));
    checkError(cudaMemcpy(T2_device, T, NX*NY*sizeof(float), cudaMemcpyHostToDevice));

    // assign a 2D distribution of CUDA "threads" within each CUDA "block".
    dim3 dimBlock(16, 16);  // total of 256 threads per block

    // calculate number of blocks along X and Y in a 2D CUDA "grid"
    dim3 dimGrid((NX+dimBlock.x-1) / dimBlock.x, (NY+dimBlock.y-1) / dimBlock.y);

    // begin Jacobi iteration
    for (int k = 0; k < MaxIter; k += 2)
    {
        Laplace<<<dimGrid, dimBlock>>>(T1_device, T2_device);   // update T1 using data stored in T2
        Laplace<<<dimGrid, dimBlock>>>(T2_device, T1_device);   // update T2 using data stored in T1
    }

    // copy final array to the CPU from the GPU
    checkError(cudaMemcpy(T, T2_device, NX*NY*sizeof(float),cudaMemcpyDeviceToHost));
    cudaDeviceSynchronize();

    // print the results to a file
    std::ofstream Out("temperature.dat");
    for (int y = 0; y < NY; ++y)
    {
       for (int x = 0; x < NX; ++x)
       {
          int index = y*NX + x;
          Out << x << ' ' << y << ' ' << T[index] << '\n';
       }
       Out << '\n';
    }
    Out.close();

    // release memory
    delete[] T;
    cudaFree(T1_device);
    cudaFree(T2_device);
}

	.file	"tmpxft_0037eee7_00000000-6_laplace.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB3771:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE3771:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"CUDA error: "
.LC1:
	.string	" : "
	.text
	.globl	_Z10checkError9cudaError
	.type	_Z10checkError9cudaError, @function
_Z10checkError9cudaError:
.LFB3766:
	.cfi_startproc
	endbr64
	testl	%edi, %edi
	je	.L2
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	leaq	.LC0(%rip), %rsi
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	movl	%edi, %ebx
	leaq	_ZSt4cerr(%rip), %rdi
	pushq	%rax
	.cfi_def_cfa_offset 32
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	%ebx, %esi
	movq	%rax, %rdi
	call	_ZNSolsEi@PLT
	leaq	.LC1(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	%ebx, %edi
	movq	%rax, %rbp
	call	cudaGetErrorString@PLT
	movq	%rbp, %rdi
	movq	%rax, %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	$10, %esi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c@PLT
	call	abort@PLT
.L2:
	.cfi_def_cfa_offset 8
	.cfi_restore 3
	.cfi_restore 6
	ret
	.cfi_endproc
.LFE3766:
	.size	_Z10checkError9cudaError, .-_Z10checkError9cudaError
	.globl	_Z10InitializePf
	.type	_Z10InitializePf, @function
_Z10InitializePf:
.LFB3767:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rdi, %rax
	movq	%rdi, %rsi
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	movq	%rdi, %rbx
	xorl	%edi, %edi
	pushq	%rdx
	.cfi_def_cfa_offset 32
.L9:
	movq	%rsi, %rcx
	movl	$256, %edx
.L10:
	movl	$0x00000000, (%rcx)
	addq	$1024, %rcx
	decl	%edx
	jne	.L10
	incl	%edi
	addq	$4, %rsi
	cmpl	$256, %edi
	jne	.L9
	movss	.LC3(%rip), %xmm1
	leaq	262144(%rbx), %rdx
.L12:
	movss	%xmm1, (%rax)
	addq	$1024, %rax
	cmpq	%rdx, %rax
	jne	.L12
	movss	.LC4(%rip), %xmm3
	xorl	%eax, %eax
.L13:
	cvtsi2ssl	%eax, %xmm0
	movaps	%xmm1, %xmm2
	mulss	%xmm3, %xmm0
	subss	%xmm0, %xmm2
	movss	%xmm2, 261120(%rbx,%rax,4)
	incq	%rax
	cmpq	$256, %rax
	jne	.L13
	xorl	%ebp, %ebp
.L14:
	cvtsi2ssl	%ebp, %xmm0
	cvtss2sd	%xmm0, %xmm0
	mulsd	.LC5(%rip), %xmm0
	mulsd	.LC6(%rip), %xmm0
	call	cos@PLT
	cvtsd2ss	%xmm0, %xmm0
	movss	%xmm0, (%rbx,%rbp,4)
	incq	%rbp
	cmpq	$256, %rbp
	jne	.L14
	popq	%rax
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3767:
	.size	_Z10InitializePf, .-_Z10InitializePf
	.globl	_Z28__device_stub__Z7LaplacePfS_PfS_
	.type	_Z28__device_stub__Z7LaplacePfS_PfS_, @function
_Z28__device_stub__Z7LaplacePfS_PfS_:
.LFB3793:
	.cfi_startproc
	endbr64
	subq	$120, %rsp
	.cfi_def_cfa_offset 128
	movq	%rdi, 8(%rsp)
	leaq	32(%rsp), %rcx
	leaq	24(%rsp), %rdx
	movq	%rsi, (%rsp)
	leaq	40(%rsp), %rdi
	leaq	52(%rsp), %rsi
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rax
	movl	$1, 48(%rsp)
	movq	%rax, 88(%rsp)
	movq	%rsp, %rax
	movq	%rax, 96(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 40(%rsp)
	movq	%rax, 52(%rsp)
	movl	$1, 60(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L20
	pushq	32(%rsp)
	.cfi_def_cfa_offset 136
	leaq	_Z7LaplacePfS_(%rip), %rdi
	pushq	32(%rsp)
	.cfi_def_cfa_offset 144
	movq	68(%rsp), %rcx
	movl	76(%rsp), %r8d
	movq	56(%rsp), %rsi
	movl	64(%rsp), %edx
	leaq	104(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 136
	popq	%rdx
	.cfi_def_cfa_offset 128
.L20:
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	je	.L22
	call	__stack_chk_fail@PLT
.L22:
	addq	$120, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3793:
	.size	_Z28__device_stub__Z7LaplacePfS_PfS_, .-_Z28__device_stub__Z7LaplacePfS_PfS_
	.globl	_Z7LaplacePfS_
	.type	_Z7LaplacePfS_, @function
_Z7LaplacePfS_:
.LFB3794:
	.cfi_startproc
	endbr64
	jmp	_Z28__device_stub__Z7LaplacePfS_PfS_
	.cfi_endproc
.LFE3794:
	.size	_Z7LaplacePfS_, .-_Z7LaplacePfS_
	.section	.rodata.str1.1
.LC7:
	.string	"_Z7LaplacePfS_"
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB3796:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	pushq	$0
	.cfi_def_cfa_offset 24
	xorl	%r9d, %r9d
	orl	$-1, %r8d
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC7(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z7LaplacePfS_(%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
.LFE3796:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.rodata.str1.1
.LC8:
	.string	"temperature.dat"
	.section	.text.startup
	.globl	main
	.type	main, @function
main:
.LFB3768:
	.cfi_startproc
	.cfi_personality 0x9b,DW.ref.__gxx_personality_v0
	.cfi_lsda 0x1b,.LLSDA3768
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	$262144, %edi
	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
	movabsq	$68719476752, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movl	$100000, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$568, %rsp
	.cfi_def_cfa_offset 624
	movq	%fs:40, %rax
	movq	%rax, 552(%rsp)
	xorl	%eax, %eax
.LEHB0:
	call	_Znam@PLT
	movq	%rax, %rdi
	movq	%rax, %rbx
	call	_Z10InitializePf
	movl	$262144, %esi
	movq	%rsp, %rdi
	call	cudaMalloc@PLT
	movl	%eax, %edi
	call	_Z10checkError9cudaError
	movl	$262144, %esi
	leaq	8(%rsp), %rdi
	call	cudaMalloc@PLT
	movl	%eax, %edi
	call	_Z10checkError9cudaError
	movq	(%rsp), %rdi
	movl	$1, %ecx
	movq	%rbx, %rsi
	movl	$262144, %edx
	call	cudaMemcpy@PLT
	movl	%eax, %edi
	call	_Z10checkError9cudaError
	movq	8(%rsp), %rdi
	movl	$1, %ecx
	movq	%rbx, %rsi
	movl	$262144, %edx
	call	cudaMemcpy@PLT
	movl	%eax, %edi
	call	_Z10checkError9cudaError
	movl	$1, 24(%rsp)
	movq	%r12, 28(%rsp)
	movl	$1, 36(%rsp)
.L30:
	movl	24(%rsp), %ecx
	movq	28(%rsp), %rdi
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	36(%rsp), %esi
	movq	%r12, %rdx
	movq	%r12, 16(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L28
	movq	8(%rsp), %rsi
	movq	(%rsp), %rdi
	call	_Z28__device_stub__Z7LaplacePfS_PfS_
.L28:
	movl	24(%rsp), %ecx
	movq	16(%rsp), %rdx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movq	28(%rsp), %rdi
	movl	36(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L29
	movq	(%rsp), %rsi
	movq	8(%rsp), %rdi
	call	_Z28__device_stub__Z7LaplacePfS_PfS_
.L29:
	decl	%ebp
	jne	.L30
	movq	8(%rsp), %rsi
	movl	$2, %ecx
	movq	%rbx, %rdi
	xorl	%r13d, %r13d
	movl	$262144, %edx
	leaq	40(%rsp), %rbp
	call	cudaMemcpy@PLT
	movl	%eax, %edi
	call	_Z10checkError9cudaError
	call	cudaDeviceSynchronize@PLT
	movl	$16, %edx
	leaq	.LC8(%rip), %rsi
	movq	%rbp, %rdi
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEEC1EPKcSt13_Ios_Openmode@PLT
.LEHE0:
.L31:
	movq	%r13, %r14
	movl	%r13d, %r15d
	xorl	%r12d, %r12d
	salq	$10, %r14
	addq	%rbx, %r14
.L32:
	movl	%r12d, %esi
	movq	%rbp, %rdi
.LEHB1:
	call	_ZNSolsEi@PLT
	movq	%rax, %rdi
	movl	$32, %esi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c@PLT
	movq	%rax, %rdi
	movl	%r15d, %esi
	call	_ZNSolsEi@PLT
	movq	%rax, %rdi
	movl	$32, %esi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c@PLT
	movq	%rax, %rdi
	cvtss2sd	(%r14,%r12,4), %xmm0
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	movq	%rax, %rdi
	movl	$10, %esi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c@PLT
	incq	%r12
	cmpq	$256, %r12
	jne	.L32
	movl	$10, %esi
	movq	%rbp, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c@PLT
	incq	%r13
	cmpq	$256, %r13
	jne	.L31
	movq	%rbp, %rdi
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEE5closeEv@PLT
	movq	%rbx, %rdi
	call	_ZdaPv@PLT
	movq	(%rsp), %rdi
	call	cudaFree@PLT
	movq	8(%rsp), %rdi
	call	cudaFree@PLT
.LEHE1:
	movq	%rbp, %rdi
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev@PLT
	movq	552(%rsp), %rax
	subq	%fs:40, %rax
	je	.L36
	jmp	.L40
.L37:
	endbr64
	movq	%rax, %rbx
.L34:
	movq	%rbp, %rdi
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev@PLT
	movq	552(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L40
	movq	%rbx, %rdi
.LEHB2:
	call	_Unwind_Resume@PLT
.LEHE2:
.L40:
	call	__stack_chk_fail@PLT
.L36:
	addq	$568, %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
.LFE3768:
	.globl	__gxx_personality_v0
	.section	.gcc_except_table,"a",@progbits
.LLSDA3768:
	.byte	0xff
	.byte	0xff
	.byte	0x1
	.uleb128 .LLSDACSE3768-.LLSDACSB3768
.LLSDACSB3768:
	.uleb128 .LEHB0-.LFB3768
	.uleb128 .LEHE0-.LEHB0
	.uleb128 0
	.uleb128 0
	.uleb128 .LEHB1-.LFB3768
	.uleb128 .LEHE1-.LEHB1
	.uleb128 .L37-.LFB3768
	.uleb128 0
	.uleb128 .LEHB2-.LFB3768
	.uleb128 .LEHE2-.LEHB2
	.uleb128 0
	.uleb128 0
.LLSDACSE3768:
	.section	.text.startup
	.size	main, .-main
	.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
.LC3:
	.long	1065353216
	.align 4
.LC4:
	.long	998244352
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC5:
	.long	2134057426
	.long	1074977148
	.align 8
.LC6:
	.long	0
	.long	1064304640
	.hidden	DW.ref.__gxx_personality_v0
	.weak	DW.ref.__gxx_personality_v0
	.section	.data.rel.local.DW.ref.__gxx_personality_v0,"awG",@progbits,DW.ref.__gxx_personality_v0,comdat
	.align 8
	.type	DW.ref.__gxx_personality_v0, @object
	.size	DW.ref.__gxx_personality_v0, 8
DW.ref.__gxx_personality_v0:
	.quad	__gxx_personality_v0
	.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 <iostream>
#include <fstream>
#include <cmath>

// lattice size
int const NX = 256;
int const NY = 256;

int const MaxIter = 200000; // number of Jacobi iterations

void checkError(hipError_t e)
{
   if (e != hipSuccess)
   {
      std::cerr << "CUDA error: " << int(e) << " : " << hipGetErrorString(e) << '\n';
      abort();
   }
}

// CUDA kernel to update the Tnew array based on the Told
// using Jacobi iterate of the Laplace operator

__global__
void Laplace(float* Told, float* Tnew)
{
   // compute the x,y location of the lattice point
   // handled by this thread
   int x = blockIdx.x*blockDim.x + threadIdx.x ;
   int y = blockIdx.y*blockDim.y + threadIdx.y ;

   // get the natural index values of node (x,y) and its neighboring nodes
   int P = y*NX + x;           // node (x,y)         N
   int E = y*NX + (x+1);       // node (x+1,y)       |
   int W = y*NX + (x-1);       // node (x-1,y)    W--P--E
   int N = (y+1)*NX + x;       // node (x,y+1)       |
   int S = (y-1)*NX + x;       // node (x,y-1)       S

   // only update the interior points - fixed boundary conditions
   if(x > 0 && x < (NX-1) && y > 0 && y < (NY-1))
   {
      Tnew[P] = 0.25*(Told[E] + Told[W] + Told[N] + Told[S]);
   }
}

// Initial condition

void Initialize(float* T)
{
   // set everything to zero
   for(int x=0; x < NX; ++x)
   {
      for(int y=0; y < NY; ++y)
      {
         int index = y*NX + x;
         T[index] = 0.0;
      }
   }

   // set left wall to 1
   for(int y=0; y < NY; ++y)
   {
      int index = y*NX;
      T[index] = 1.0;
   }
   // set back wall to a ramp
   for(int x=0; x < NX; ++x)
   {
      int index = (NY-1)*NX + x;
      T[index] = 1.0 - float(x)/NX;
   }
   // set front wall to a sinusoid
   for(int x=0; x < NX; ++x)
   {
      int index = x;
      T[index] = std::cos(3.0 * M_PI_2 * float(x)/NX);
   }
}

int main()
{
   // The temperature matrix on the CPU
   float* T = new float[NX*NY];


   // Storage on the device (GPU)
   float* T1_device;
   float* T2_device;

    // initialize array on the host
    Initialize(T);

    // allocate storage space on the GPU
    checkError(hipMalloc(&T1_device, NX*NY*sizeof(float)));
    checkError(hipMalloc(&T2_device, NX*NY*sizeof(float)));

    // copy (initialized) host arrays to the GPU memory from CPU memory
    checkError(hipMemcpy(T1_device, T, NX*NY*sizeof(float), hipMemcpyHostToDevice));
    checkError(hipMemcpy(T2_device, T, NX*NY*sizeof(float), hipMemcpyHostToDevice));

    // assign a 2D distribution of CUDA "threads" within each CUDA "block".
    dim3 dimBlock(16, 16);  // total of 256 threads per block

    // calculate number of blocks along X and Y in a 2D CUDA "grid"
    dim3 dimGrid((NX+dimBlock.x-1) / dimBlock.x, (NY+dimBlock.y-1) / dimBlock.y);

    // begin Jacobi iteration
    for (int k = 0; k < MaxIter; k += 2)
    {
        Laplace<<<dimGrid, dimBlock>>>(T1_device, T2_device);   // update T1 using data stored in T2
        Laplace<<<dimGrid, dimBlock>>>(T2_device, T1_device);   // update T2 using data stored in T1
    }

    // copy final array to the CPU from the GPU
    checkError(hipMemcpy(T, T2_device, NX*NY*sizeof(float),hipMemcpyDeviceToHost));
    hipDeviceSynchronize();

    // print the results to a file
    std::ofstream Out("temperature.dat");
    for (int y = 0; y < NY; ++y)
    {
       for (int x = 0; x < NX; ++x)
       {
          int index = y*NX + x;
          Out << x << ' ' << y << ' ' << T[index] << '\n';
       }
       Out << '\n';
    }
    Out.close();

    // release memory
    delete[] T;
    hipFree(T1_device);
    hipFree(T2_device);
}

	.text
	.file	"laplace.hip"
                                        # Start of file scope inline assembly
	.globl	_ZSt21ios_base_library_initv

                                        # End of file scope inline assembly
	.globl	_Z10checkError10hipError_t      # -- Begin function _Z10checkError10hipError_t
	.type	_Z10checkError10hipError_t,@function
_Z10checkError10hipError_t:             # @_Z10checkError10hipError_t
	.cfi_startproc
# %bb.0:
	testl	%edi, %edi
	jne	.LBB0_2
# %bb.1:
	retq
.LBB0_2:
	pushq	%r14
	.cfi_def_cfa_offset 16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	pushq	%rax
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -24
	.cfi_offset %r14, -16
	movl	%edi, %ebx
	movl	$_ZSt4cerr, %edi
	movl	$.L.str, %esi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rdi
	movl	%ebx, %esi
	callq	_ZNSolsEi
	movl	$.L.str.1, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %r14
	movl	%ebx, %edi
	callq	hipGetErrorString
	movq	%r14, %rdi
	movq	%rax, %rsi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rdi
	movl	$10, %esi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c
	callq	abort
.Lfunc_end0:
	.size	_Z10checkError10hipError_t, .Lfunc_end0-_Z10checkError10hipError_t
	.cfi_endproc
                                        # -- End function
	.globl	_Z22__device_stub__LaplacePfS_  # -- Begin function _Z22__device_stub__LaplacePfS_
	.type	_Z22__device_stub__LaplacePfS_,@function
_Z22__device_stub__LaplacePfS_:         # @_Z22__device_stub__LaplacePfS_
	.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	$80, %rsp
	.cfi_def_cfa_offset 128
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	24(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	16(%rsp), %rcx
	movq	%rsi, (%rcx)
	leaq	64(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	leaq	48(%rsp), %r14
	leaq	32(%rsp), %r15
	leaq	8(%rsp), %r12
	movq	%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	$_Z7LaplacePfS_, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$96, %rsp
	.cfi_adjust_cfa_offset -96
	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	_Z22__device_stub__LaplacePfS_, .Lfunc_end1-_Z22__device_stub__LaplacePfS_
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function _Z10InitializePf
.LCPI2_0:
	.long	0xbb800000                      # float -0.00390625
.LCPI2_1:
	.long	0x3f800000                      # float 1
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0
.LCPI2_2:
	.quad	0x4012d97c7f3321d2              # double 4.7123889803846897
.LCPI2_3:
	.quad	0x3f70000000000000              # double 0.00390625
	.text
	.globl	_Z10InitializePf
	.type	_Z10InitializePf,@function
_Z10InitializePf:                       # @_Z10InitializePf
	.cfi_startproc
# %bb.0:
	pushq	%r14
	.cfi_def_cfa_offset 16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	pushq	%rax
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -24
	.cfi_offset %r14, -16
	movq	%rdi, %rbx
	xorl	%eax, %eax
	movq	%rdi, %rcx
.LBB2_1:                                # %.preheader30
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB2_2 Depth 2
	xorl	%edx, %edx
.LBB2_2:                                #   Parent Loop BB2_1 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	$0, (%rcx,%rdx)
	addq	$1024, %rdx                     # imm = 0x400
	cmpq	$262144, %rdx                   # imm = 0x40000
	jne	.LBB2_2
# %bb.3:                                #   in Loop: Header=BB2_1 Depth=1
	incq	%rax
	addq	$4, %rcx
	cmpq	$256, %rax                      # imm = 0x100
	jne	.LBB2_1
# %bb.4:                                # %.preheader29.preheader
	xorl	%eax, %eax
.LBB2_5:                                # %.preheader29
                                        # =>This Inner Loop Header: Depth=1
	movl	$1065353216, (%rbx,%rax)        # imm = 0x3F800000
	addq	$1024, %rax                     # imm = 0x400
	cmpq	$262144, %rax                   # imm = 0x40000
	jne	.LBB2_5
# %bb.6:                                # %.preheader28.preheader
	xorl	%eax, %eax
	movss	.LCPI2_0(%rip), %xmm0           # xmm0 = mem[0],zero,zero,zero
	movss	.LCPI2_1(%rip), %xmm1           # xmm1 = mem[0],zero,zero,zero
.LBB2_7:                                # %.preheader28
                                        # =>This Inner Loop Header: Depth=1
	xorps	%xmm2, %xmm2
	cvtsi2ss	%eax, %xmm2
	mulss	%xmm0, %xmm2
	addss	%xmm1, %xmm2
	movss	%xmm2, 261120(%rbx,%rax,4)
	incq	%rax
	cmpq	$256, %rax                      # imm = 0x100
	jne	.LBB2_7
# %bb.8:                                # %.preheader.preheader
	xorl	%r14d, %r14d
.LBB2_9:                                # %.preheader
                                        # =>This Inner Loop Header: Depth=1
	xorps	%xmm0, %xmm0
	cvtsi2sd	%r14d, %xmm0
	mulsd	.LCPI2_2(%rip), %xmm0
	mulsd	.LCPI2_3(%rip), %xmm0
	callq	cos
	cvtsd2ss	%xmm0, %xmm0
	movss	%xmm0, (%rbx,%r14,4)
	incq	%r14
	cmpq	$256, %r14                      # imm = 0x100
	jne	.LBB2_9
# %bb.10:
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end2:
	.size	_Z10InitializePf, .Lfunc_end2-_Z10InitializePf
	.cfi_endproc
                                        # -- End function
	.globl	main                            # -- Begin function main
	.type	main,@function
main:                                   # @main
.Lfunc_begin0:
	.cfi_startproc
	.cfi_personality 3, __gxx_personality_v0
	.cfi_lsda 3, .Lexception0
# %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	$552, %rsp                      # imm = 0x228
	.cfi_def_cfa_offset 608
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movabsq	$68719476752, %r14              # imm = 0x1000000010
	movl	$262144, %edi                   # imm = 0x40000
	callq	_Znam
	movq	%rax, %rbx
	movq	%rax, %rdi
	callq	_Z10InitializePf
	leaq	24(%rsp), %r15
	movl	$262144, %esi                   # imm = 0x40000
	movq	%r15, %rdi
	callq	hipMalloc
	movl	%eax, %edi
	callq	_Z10checkError10hipError_t
	leaq	16(%rsp), %r12
	movl	$262144, %esi                   # imm = 0x40000
	movq	%r12, %rdi
	callq	hipMalloc
	movl	%eax, %edi
	callq	_Z10checkError10hipError_t
	movq	(%r15), %rdi
	movl	$262144, %edx                   # imm = 0x40000
	movq	%rbx, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	movl	%eax, %edi
	callq	_Z10checkError10hipError_t
	movq	(%r12), %rdi
	movl	$262144, %edx                   # imm = 0x40000
	movq	%rbx, 32(%rsp)                  # 8-byte Spill
	movq	%rbx, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	movl	%eax, %edi
	callq	_Z10checkError10hipError_t
	movl	$-2, %ebx
.LBB3_1:                                # =>This Inner Loop Header: Depth=1
	movq	%r14, %rdi
	movl	$1, %esi
	movq	%r14, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB3_3
# %bb.2:                                #   in Loop: Header=BB3_1 Depth=1
	movq	24(%rsp), %rdi
	movq	16(%rsp), %rsi
	callq	_Z22__device_stub__LaplacePfS_
.LBB3_3:                                #   in Loop: Header=BB3_1 Depth=1
	movq	%r14, %rdi
	movl	$1, %esi
	movq	%r14, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB3_5
# %bb.4:                                #   in Loop: Header=BB3_1 Depth=1
	movq	16(%rsp), %rdi
	movq	24(%rsp), %rsi
	callq	_Z22__device_stub__LaplacePfS_
.LBB3_5:                                #   in Loop: Header=BB3_1 Depth=1
	addl	$2, %ebx
	cmpl	$199998, %ebx                   # imm = 0x30D3E
	jb	.LBB3_1
# %bb.6:
	movq	16(%rsp), %rsi
	movl	$262144, %edx                   # imm = 0x40000
	movq	32(%rsp), %rbx                  # 8-byte Reload
	movq	%rbx, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	movl	%eax, %edi
	callq	_Z10checkError10hipError_t
	callq	hipDeviceSynchronize
	leaq	40(%rsp), %r14
	movl	$.L.str.2, %esi
	movq	%r14, %rdi
	movl	$16, %edx
	callq	_ZNSt14basic_ofstreamIcSt11char_traitsIcEEC1EPKcSt13_Ios_Openmode
	xorl	%r15d, %r15d
	leaq	15(%rsp), %r12
.LBB3_7:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB3_8 Depth 2
	xorl	%r13d, %r13d
.LBB3_8:                                #   Parent Loop BB3_7 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
.Ltmp0:
	movq	%r14, %rdi
	movl	%r13d, %esi
	callq	_ZNSolsEi
.Ltmp1:
# %bb.9:                                #   in Loop: Header=BB3_8 Depth=2
	movq	%rax, %rbp
	movb	$32, 15(%rsp)
	movq	(%rax), %rax
	movq	-24(%rax), %rax
	cmpq	$0, 16(%rbp,%rax)
	je	.LBB3_14
# %bb.10:                               #   in Loop: Header=BB3_8 Depth=2
.Ltmp2:
	movl	$1, %edx
	movq	%rbp, %rdi
	movq	%r12, %rsi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp3:
# %bb.11:                               #   in Loop: Header=BB3_8 Depth=2
	movq	%rax, %rbp
	jmp	.LBB3_15
.LBB3_14:                               #   in Loop: Header=BB3_8 Depth=2
.Ltmp4:
	movq	%rbp, %rdi
	movl	$32, %esi
	callq	_ZNSo3putEc
.Ltmp5:
.LBB3_15:                               #   in Loop: Header=BB3_8 Depth=2
.Ltmp6:
	movq	%rbp, %rdi
	movl	%r15d, %esi
	callq	_ZNSolsEi
.Ltmp7:
# %bb.16:                               #   in Loop: Header=BB3_8 Depth=2
	movq	%rax, %rbp
	movb	$32, 15(%rsp)
	movq	(%rax), %rax
	movq	-24(%rax), %rax
	cmpq	$0, 16(%rbp,%rax)
	je	.LBB3_19
# %bb.17:                               #   in Loop: Header=BB3_8 Depth=2
.Ltmp8:
	movl	$1, %edx
	movq	%rbp, %rdi
	movq	%r12, %rsi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp9:
# %bb.18:                               #   in Loop: Header=BB3_8 Depth=2
	movq	%rax, %rbp
	jmp	.LBB3_20
.LBB3_19:                               #   in Loop: Header=BB3_8 Depth=2
.Ltmp10:
	movq	%rbp, %rdi
	movl	$32, %esi
	callq	_ZNSo3putEc
.Ltmp11:
.LBB3_20:                               #   in Loop: Header=BB3_8 Depth=2
	xorps	%xmm0, %xmm0
	cvtss2sd	(%rbx,%r13,4), %xmm0
.Ltmp12:
	movq	%rbp, %rdi
	callq	_ZNSo9_M_insertIdEERSoT_
.Ltmp13:
# %bb.21:                               # %_ZNSolsEf.exit
                                        #   in Loop: Header=BB3_8 Depth=2
	movb	$10, 15(%rsp)
	movq	(%rax), %rcx
	movq	-24(%rcx), %rcx
	cmpq	$0, 16(%rax,%rcx)
	je	.LBB3_23
# %bb.22:                               #   in Loop: Header=BB3_8 Depth=2
.Ltmp14:
	movl	$1, %edx
	movq	%rax, %rdi
	movq	%r12, %rsi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp15:
	jmp	.LBB3_24
.LBB3_23:                               #   in Loop: Header=BB3_8 Depth=2
.Ltmp16:
	movq	%rax, %rdi
	movl	$10, %esi
	callq	_ZNSo3putEc
.Ltmp17:
.LBB3_24:                               #   in Loop: Header=BB3_8 Depth=2
	incq	%r13
	cmpq	$256, %r13                      # imm = 0x100
	jne	.LBB3_8
# %bb.12:                               #   in Loop: Header=BB3_7 Depth=1
	movb	$10, 15(%rsp)
	movq	40(%rsp), %rax
	movq	-24(%rax), %rax
	cmpq	$0, 56(%rsp,%rax)
	je	.LBB3_26
# %bb.13:                               #   in Loop: Header=BB3_7 Depth=1
.Ltmp19:
	movl	$1, %edx
	movq	%r14, %rdi
	movq	%r12, %rsi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp20:
	jmp	.LBB3_27
.LBB3_26:                               #   in Loop: Header=BB3_7 Depth=1
.Ltmp21:
	movq	%r14, %rdi
	movl	$10, %esi
	callq	_ZNSo3putEc
.Ltmp22:
.LBB3_27:                               #   in Loop: Header=BB3_7 Depth=1
	incq	%r15
	addq	$1024, %rbx                     # imm = 0x400
	cmpq	$256, %r15                      # imm = 0x100
	jne	.LBB3_7
# %bb.28:
.Ltmp24:
	leaq	40(%rsp), %rdi
	callq	_ZNSt14basic_ofstreamIcSt11char_traitsIcEE5closeEv
.Ltmp25:
# %bb.29:
	movq	32(%rsp), %rdi                  # 8-byte Reload
	callq	_ZdaPv
	movq	24(%rsp), %rdi
.Ltmp26:
	callq	hipFree
.Ltmp27:
# %bb.30:
	movq	16(%rsp), %rdi
.Ltmp28:
	callq	hipFree
.Ltmp29:
# %bb.31:
	movq	_ZTTSt14basic_ofstreamIcSt11char_traitsIcEE(%rip), %rax
	leaq	48(%rsp), %rdi
	movq	%rax, -8(%rdi)
	movq	_ZTTSt14basic_ofstreamIcSt11char_traitsIcEE+24(%rip), %rcx
	movq	-24(%rax), %rax
	movq	%rcx, 40(%rsp,%rax)
	callq	_ZNSt13basic_filebufIcSt11char_traitsIcEED2Ev
	leaq	288(%rsp), %rdi
	callq	_ZNSt8ios_baseD2Ev
	xorl	%eax, %eax
	addq	$552, %rsp                      # imm = 0x228
	.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
.LBB3_32:
	.cfi_def_cfa_offset 608
.Ltmp30:
	jmp	.LBB3_33
.LBB3_34:
.Ltmp23:
	jmp	.LBB3_33
.LBB3_25:
.Ltmp18:
.LBB3_33:
	movq	%rax, %rbx
	leaq	40(%rsp), %rdi
	callq	_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev
	movq	%rbx, %rdi
	callq	_Unwind_Resume@PLT
.Lfunc_end3:
	.size	main, .Lfunc_end3-main
	.cfi_endproc
	.section	.gcc_except_table,"a",@progbits
	.p2align	2, 0x0
GCC_except_table3:
.Lexception0:
	.byte	255                             # @LPStart Encoding = omit
	.byte	255                             # @TType Encoding = omit
	.byte	1                               # Call site Encoding = uleb128
	.uleb128 .Lcst_end0-.Lcst_begin0
.Lcst_begin0:
	.uleb128 .Lfunc_begin0-.Lfunc_begin0    # >> Call Site 1 <<
	.uleb128 .Ltmp0-.Lfunc_begin0           #   Call between .Lfunc_begin0 and .Ltmp0
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp0-.Lfunc_begin0           # >> Call Site 2 <<
	.uleb128 .Ltmp17-.Ltmp0                 #   Call between .Ltmp0 and .Ltmp17
	.uleb128 .Ltmp18-.Lfunc_begin0          #     jumps to .Ltmp18
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp19-.Lfunc_begin0          # >> Call Site 3 <<
	.uleb128 .Ltmp22-.Ltmp19                #   Call between .Ltmp19 and .Ltmp22
	.uleb128 .Ltmp23-.Lfunc_begin0          #     jumps to .Ltmp23
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp24-.Lfunc_begin0          # >> Call Site 4 <<
	.uleb128 .Ltmp29-.Ltmp24                #   Call between .Ltmp24 and .Ltmp29
	.uleb128 .Ltmp30-.Lfunc_begin0          #     jumps to .Ltmp30
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp29-.Lfunc_begin0          # >> Call Site 5 <<
	.uleb128 .Lfunc_end3-.Ltmp29            #   Call between .Ltmp29 and .Lfunc_end3
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
.Lcst_end0:
	.p2align	2, 0x0
                                        # -- End function
	.text
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	jne	.LBB4_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB4_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z7LaplacePfS_, %esi
	movl	$.L__unnamed_1, %edx
	movl	$.L__unnamed_1, %ecx
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$__hip_module_dtor, %edi
	addq	$40, %rsp
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_end4:
	.size	__hip_module_ctor, .Lfunc_end4-__hip_module_ctor
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_dtor
	.type	__hip_module_dtor,@function
__hip_module_dtor:                      # @__hip_module_dtor
	.cfi_startproc
# %bb.0:
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	je	.LBB5_2
# %bb.1:
	pushq	%rax
	.cfi_def_cfa_offset 16
	callq	__hipUnregisterFatBinary
	movq	$0, __hip_gpubin_handle(%rip)
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
.LBB5_2:
	retq
.Lfunc_end5:
	.size	__hip_module_dtor, .Lfunc_end5-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"CUDA error: "
	.size	.L.str, 13

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	" : "
	.size	.L.str.1, 4

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

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

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z7LaplacePfS_"
	.size	.L__unnamed_1, 15

	.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 _Z22__device_stub__LaplacePfS_
	.addrsig_sym __gxx_personality_v0
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Unwind_Resume
	.addrsig_sym _ZSt4cerr
	.addrsig_sym _Z7LaplacePfS_
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z7LaplacePfS_          ; -- Begin function _Z7LaplacePfS_
	.globl	_Z7LaplacePfS_
	.p2align	8
	.type	_Z7LaplacePfS_,@function
_Z7LaplacePfS_:                         ; @_Z7LaplacePfS_
; %bb.0:
	s_load_b32 s2, s[0:1], 0x1c
	v_and_b32_e32 v2, 0x3ff, v0
	v_bfe_u32 v3, v0, 10, 10
	s_waitcnt lgkmcnt(0)
	s_lshr_b32 s3, s2, 16
	s_and_b32 s2, s2, 0xffff
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	v_mad_u64_u32 v[0:1], null, s14, s2, v[2:3]
	v_mad_u64_u32 v[1:2], null, s15, s3, v[3:4]
	s_mov_b32 s2, exec_lo
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_nc_u32_e32 v2, -1, v0
	v_add_nc_u32_e32 v3, -1, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_max_u32_e32 v3, v2, v3
	v_cmpx_gt_u32_e32 0xfe, v3
	s_cbranch_execz .LBB0_2
; %bb.1:
	s_load_b128 s[0:3], s[0:1], 0x0
	v_dual_mov_b32 v1, 0 :: v_dual_lshlrev_b32 v6, 8, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_co_u32 v4, s4, v0, v6
	v_add_co_ci_u32_e64 v5, null, 0, 0, s4
	v_add_nc_u32_e32 v3, v6, v0
	s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_dual_mov_b32 v7, v1 :: v_dual_add_nc_u32 v0, v6, v2
	v_lshlrev_b64 v[4:5], 2, v[4:5]
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_nc_u32_e32 v6, 0xffffff00, v3
	v_lshlrev_b64 v[8:9], 2, v[0:1]
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_4)
	v_lshlrev_b64 v[6:7], 2, v[6:7]
	s_waitcnt lgkmcnt(0)
	v_add_co_u32 v4, vcc_lo, s0, v4
	v_add_co_ci_u32_e32 v5, vcc_lo, s1, v5, vcc_lo
	s_delay_alu instid0(VALU_DEP_4)
	v_add_co_u32 v8, vcc_lo, s0, v8
	v_add_co_ci_u32_e32 v9, vcc_lo, s1, v9, vcc_lo
	v_add_co_u32 v6, vcc_lo, s0, v6
	v_add_co_ci_u32_e32 v7, vcc_lo, s1, v7, vcc_lo
	s_clause 0x3
	global_load_b32 v0, v[4:5], off offset:4
	global_load_b32 v2, v[8:9], off
	global_load_b32 v6, v[6:7], off
	global_load_b32 v4, v[4:5], off offset:1024
	s_waitcnt vmcnt(2)
	v_add_f32_e32 v0, v0, v2
	s_waitcnt vmcnt(0)
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_add_f32_e32 v0, v0, v4
	v_mov_b32_e32 v4, v1
	v_add_f32_e32 v2, v0, v6
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_lshlrev_b64 v[0:1], 2, v[3:4]
	v_mul_f32_e32 v2, 0x3e800000, v2
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_co_u32 v0, vcc_lo, s2, v0
	v_add_co_ci_u32_e32 v1, vcc_lo, s3, v1, 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 _Z7LaplacePfS_
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 272
		.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 10
		.amdhsa_next_free_sgpr 16
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end0:
	.size	_Z7LaplacePfS_, .Lfunc_end0-_Z7LaplacePfS_
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 352
; NumSgprs: 18
; NumVgprs: 10
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 10
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 14
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 1
	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __hip_cuid_
	.amdgpu_metadata
---
amdhsa.kernels:
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .offset:         16
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         20
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         24
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         28
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         30
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         32
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         34
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         36
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         38
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         56
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         64
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         80
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 272
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z7LaplacePfS_
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z7LaplacePfS_.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     10
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
