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

/*  square root of number of threads in a block (the number of threads in a block is NT^2)  */
#define NT 32
/*  length of the target domain  */
#define L 10.0
/*  number of division for the discretization of the target domain  */
#define N 256
/*  dimensionless time step size (theta = D * dt / dx^2)  */
#define THETA 0.1
/*  number of iterations  */
#define M 2000


/*  constants on a GPU  */
__device__ __constant__ int n;
__device__ __constant__ double theta;

//GPU functions-----------------------------------------------------------------
__global__ void diffusion_global(double *field_device, double *field_device_new) {
	int i_global;
	int j_global;
	int i_left, i_right;
	int j_top, j_bottom;

	i_global = blockDim.x * blockIdx.x + threadIdx.x;

	if(i_global < n) {
		i_right = (i_global + 1) % n;
		i_left = (i_global - 1 + n) % n;
		for(j_global = threadIdx.y; j_global < n; j_global += NT) {
			j_top = (j_global + 1) % n;
			j_bottom = (j_global - 1 + n) % n;
			field_device_new[i_global * n + j_global] =  field_device[i_global * n + j_global]
				+ theta * (field_device[i_right * n + j_global] + field_device[i_left * n + j_global]
					      + field_device[i_global * n + j_top] + field_device[i_global * n + j_bottom]
					      - 4.0 * field_device[i_global * n + j_global]);
		}
	}
}

__global__ void diffusion_shared(double *field_device, double *field_device_new) {
	int i_global;
	int j_global;
	int i_shared;
	int j_shared;
	int i_left, i_right;
	int j_top, j_bottom;
	double field_register;
	__shared__ double field_shared[(NT + 2) * (NT + 2)];

	i_global = blockDim.x * blockIdx.x + threadIdx.x;
	i_shared = threadIdx.x + 1;
	j_shared = threadIdx.y + 1;

	if(i_global < n) {
		for(j_global = threadIdx.y; j_global < n; j_global += NT) {
			//copy field from global to shared----------------------
			field_register = field_device[i_global * n + j_global];
			field_shared[i_shared * (NT + 2) + j_shared] = field_register;
			if(i_shared == 1) {
				i_left = (i_global - 1 + n) % n;
				field_shared[0 * (NT + 2) + j_shared] = field_device[i_left * n + j_global];
			} else if(i_shared == NT) {
				i_right = (i_global + 1) % n;
				field_shared[(NT + 1) * (NT + 2) + j_shared] = field_device[i_right * n + j_global];
			}
			if(j_shared == 1) {
				j_bottom = (j_global - 1 + n) % n;
				field_shared[i_shared * (NT + 2) + 0] = field_device[i_global * n + j_bottom];
			} else if(j_shared == NT) {
				j_top = (j_global + 1) % n;
				field_shared[i_shared * (NT + 2) + (NT + 1)] = field_device[i_global * n + j_top];
			}
			__syncthreads();

			//calculate field evolution-----------------------------
			field_device_new[i_global * n + j_global] = field_register
				+ theta * (field_shared[(i_shared + 1) * (NT + 2) + j_shared] + field_shared[(i_shared - 1) * (NT + 2) + j_shared]
					      + field_shared[i_shared * (NT + 2) + (j_shared + 1)] + field_shared[i_shared * (NT + 2) + (j_shared - 1)]
					      - 4.0 * field_register);

		}
	}
}

//Host functions----------------------------------------------------------------
void init_field(double *field_host, int n_host, int l_host) {
	int i;
	int j;
	double x;
	double y;
	double dx = l_host / (double)n_host;
	double dy = l_host / (double)n_host;
	double midst = l_host * 0.5;
	for(i = 0; i < n_host; i += 1) {
		x = (double)i * dx;
		for(j = 0; j < n_host; j += 1) {
			y = (double)j * dy;
			if((x > midst && y > midst) || (x < midst && y < midst)) {
				field_host[n_host * j + i] = 1.0;
			} else {
				field_host[n_host * j + i] = 0.0;
			}
		}
	}
}

void flip_ij(int *i, int *j) {
	int i_temp;
	i_temp = *i;
	*i = *j;
	*j = i_temp;
}

void print_field(FILE *file_write, double *field, int n, double l) {
	int i;
	int j;
	double x;
	double y;
	double d = l/(double)n;
	for(i = 0; i < N; i += 1) {
		y = (double)j * d;
		for(j = 0; j < N; j += 1) {
			x = (double)i * d;
			fprintf(file_write, "%f %f %f\n", x, y, field[i * n + j]);
		}
	}
}

void diffusion_host(double *field_host, double *field_host_new, int n_host, double theta_host) {
	int i;
	int j;
	int i_right, i_left;
	int j_top, j_bottom;

	for(i = 0; i < n_host; i += 1) {
		i_right = (i + 1) % n_host;
		i_left = (i - 1 + n_host) % n_host;
		for(j = 0; j < n_host; j += 1) {
			j_top = (j + 1) % n_host;
			j_bottom = (j - 1 + n_host) % n_host;
			field_host_new[i * n_host + j] = field_host[i * n_host + j]
				+ theta_host * (field_host[i_right * n_host + j] + field_host[i_left * n_host + j]
					      + field_host[i * n_host + j_top] + field_host[i * n_host + j_bottom]
					      - 4.0 * field_host[i * n_host + j]);

		}
	}
}

double check_residue(double *field_host, double *field_device, int n_host) {
	int i;
	double residue = 0.0;

	for(i = 0; i < n_host * n_host; i += 1) {
		residue += (field_host[i] - field_device[i]) * (field_host[i] - field_device[i]);;
	}
	return residue;
}

int main(void) {
//delcare variavles-------------------------------------------------------------
	int i;
	int j;
	int k;
	int n_host;
	int n_square;
	int iteration;
	int n_blocks;
	double l_host;
	double theta_host;
	dim3 dim_threads;
	double *field_host[2];
	double *field_device[2];
	double *result_host;
	double *result_global_host;
	double *result_shared_host;
	FILE *file_write;
	char filename_write[256];
	clock_t start, end;

//initialize--------------------------------------------------------------------
	//set variables---------------------------------------------------------
	n_host = N;
	n_square = N * N;
	l_host = L;
	theta_host = THETA;
	dim_threads.x = NT;
	dim_threads.y = NT;
	dim_threads.z = 1;
	n_blocks = (int)(ceil((double)n_host / NT));
	iteration = M;

	//allocate memories-----------------------------------------------------
	cudaMemcpyToSymbol(n, &n_host, sizeof(int), 0, cudaMemcpyHostToDevice);
	cudaMemcpyToSymbol(theta, &theta_host, sizeof(double), 0, cudaMemcpyHostToDevice);
	cudaHostAlloc((void **)&field_host[0], n_square * sizeof(double), cudaHostAllocMapped);
	cudaHostAlloc((void **)&field_host[1], n_square * sizeof(double), cudaHostAllocMapped);
	cudaHostAlloc((void **)&result_global_host,  n_square * sizeof(double), cudaHostAllocMapped);
	cudaHostAlloc((void **)&result_shared_host,  n_square * sizeof(double), cudaHostAllocMapped);
	cudaMalloc((void **)&field_device[0], n_square * sizeof(double));
	cudaMalloc((void **)&field_device[1], n_square * sizeof(double));
	result_host = (double *)malloc(n_square * sizeof(double));

//calculate on CPU--------------------------------------------------------------
	//initialize field------------------------------------------------------
	init_field(field_host[0], n_host, l_host);
	start = clock();
	//iteration-------------------------------------------------------------
	i = 0;
	j = 1;
	for(k = 0; k < iteration; k += 1) {
		diffusion_host(field_host[i], field_host[j], n_host, theta_host);
		flip_ij(&i, &j);
	}
	//save and print out----------------------------------------------------
	memcpy(result_host, field_host[i], n_square * sizeof(double));
	end = clock();
	printf("host:%ld\n", end - start);
	/*sprintf(filename_write, "result_host.txt");
	file_write = fopen(filename_write, "w");
	print_field(file_write, result_host, n_host, l_host);
	fclose(file_write);*/

//calculate using only global memory--------------------------------------------
	//initialize field------------------------------------------------------
	init_field(field_host[0], n_host, l_host);
	start = clock();
	cudaMemcpy(field_device[0], field_host[0], n_square * sizeof(double), cudaMemcpyHostToDevice);
	//iteration-------------------------------------------------------------
	i = 0;
	j = 1;
	for(k = 0; k < iteration; k += 1) {
		diffusion_global<<<n_blocks, dim_threads>>>(field_device[i], field_device[j]);
		cudaDeviceSynchronize();
		flip_ij(&i, &j);
	}
	//copy to host and print out--------------------------------------------
	cudaMemcpy(result_global_host, field_device[i], n_square * sizeof(double), cudaMemcpyDeviceToHost);
	end = clock();
	printf("global:%ld\n", end - start);
	/*sprintf(filename_write, "result_global.txt");
	file_write = fopen(filename_write, "w");
	print_field(file_write, result_global_host, n_host, l_host);
	fclose(file_write);*/

//calculate using shared memory-------------------------------------------------
	//initialize field------------------------------------------------------
	init_field(field_host[0], n_host, l_host);
	start = clock();
	cudaMemcpy(field_device[0], field_host[0], n_square * sizeof(double), cudaMemcpyHostToDevice);
	//iteration-------------------------------------------------------------
	i = 0;
	j = 1;
	for(k = 0; k < iteration; k += 1) {
		diffusion_shared<<<n_blocks, dim_threads>>>(field_device[i], field_device[j]);
		cudaDeviceSynchronize();
		flip_ij(&i, &j);
	}
	//copy to host and print out--------------------------------------------
	cudaMemcpy(result_shared_host, field_device[i], n_square * sizeof(double), cudaMemcpyDeviceToHost);
	end = clock();
	printf("shared:%ld\n", end - start);
	/*sprintf(filename_write, "result_shared.txt");
	file_write = fopen(filename_write, "w");
	print_field(file_write, result_shared_host, n_host, l_host);
	fclose(file_write);*/

//check answers-----------------------------------------------------------------
	printf("answers\n");
	printf("global:%f\n", check_residue(result_host, result_global_host, n_host));
	printf("shared:%f\n",  check_residue(result_host, result_shared_host, n_host));

//finalize----------------------------------------------------------------------
	cudaFreeHost(field_host[0]);
	cudaFreeHost(field_host[1]);
	cudaFreeHost(result_global_host);
	cudaFreeHost(result_shared_host);
	cudaFree(field_device[0]);
	cudaFree(field_device[1]);
	free(result_host);

	return 0;
}

	.file	"tmpxft_003866a7_00000000-6_diffusion_me.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2035:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2035:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z10init_fieldPdii
	.type	_Z10init_fieldPdii, @function
_Z10init_fieldPdii:
.LFB2027:
	.cfi_startproc
	endbr64
	cvtsi2sdl	%edx, %xmm0
	movsd	.LC1(%rip), %xmm4
	xorl	%eax, %eax
	cvtsi2sdl	%esi, %xmm1
	movaps	%xmm0, %xmm3
	divsd	%xmm1, %xmm3
	mulsd	.LC0(%rip), %xmm0
.L3:
	cmpl	%esi, %eax
	jge	.L19
	cvtsi2sdl	%eax, %xmm1
	movl	%eax, %ecx
	xorl	%edx, %edx
	mulsd	%xmm3, %xmm1
.L11:
	cvtsi2sdl	%edx, %xmm2
	comisd	%xmm0, %xmm1
	movslq	%ecx, %r8
	mulsd	%xmm3, %xmm2
	jbe	.L16
	comisd	%xmm0, %xmm2
	jmp	.L17
.L16:
	comisd	%xmm1, %xmm0
	jbe	.L7
	comisd	%xmm2, %xmm0
.L17:
	jbe	.L7
	movsd	%xmm4, (%rdi,%r8,8)
	jmp	.L10
.L7:
	movq	$0x000000000, (%rdi,%r8,8)
.L10:
	incl	%edx
	addl	%esi, %ecx
	cmpl	%edx, %esi
	jne	.L11
	incl	%eax
	jmp	.L3
.L19:
	ret
	.cfi_endproc
.LFE2027:
	.size	_Z10init_fieldPdii, .-_Z10init_fieldPdii
	.globl	_Z7flip_ijPiS_
	.type	_Z7flip_ijPiS_, @function
_Z7flip_ijPiS_:
.LFB2028:
	.cfi_startproc
	endbr64
	movl	(%rdi), %eax
	movl	(%rsi), %edx
	movl	%edx, (%rdi)
	movl	%eax, (%rsi)
	ret
	.cfi_endproc
.LFE2028:
	.size	_Z7flip_ijPiS_, .-_Z7flip_ijPiS_
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC4:
	.string	"%f %f %f\n"
	.text
	.globl	_Z11print_fieldP8_IO_FILEPdid
	.type	_Z11print_fieldP8_IO_FILEPdid, @function
_Z11print_fieldP8_IO_FILEPdid:
.LFB2029:
	.cfi_startproc
	endbr64
	movaps	%xmm0, %xmm3
	cvtsi2sdl	%edx, %xmm0
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movslq	%edx, %rdx
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	leaq	.LC4(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	xorl	%r13d, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movq	%rdi, %r12
	divsd	%xmm0, %xmm3
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%rsi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	0(,%rdx,8), %rbx
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	movsd	.LC3(%rip), %xmm1
	mulsd	%xmm3, %xmm1
.L23:
	cvtsi2sdl	%r13d, %xmm0
	xorl	%r15d, %r15d
	mulsd	%xmm3, %xmm0
	movsd	%xmm0, 8(%rsp)
.L22:
	movsd	0(%rbp,%r15,8), %xmm2
	movq	%r14, %rdx
	movq	%r12, %rdi
	movb	$3, %al
	movsd	8(%rsp), %xmm0
	movl	$2, %esi
	incq	%r15
	movsd	%xmm3, 24(%rsp)
	movsd	%xmm1, 16(%rsp)
	call	__fprintf_chk@PLT
	cmpq	$256, %r15
	movsd	16(%rsp), %xmm1
	movsd	24(%rsp), %xmm3
	jne	.L22
	incl	%r13d
	addq	%rbx, %rbp
	cmpl	$256, %r13d
	jne	.L23
	addq	$40, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2029:
	.size	_Z11print_fieldP8_IO_FILEPdid, .-_Z11print_fieldP8_IO_FILEPdid
	.globl	_Z14diffusion_hostPdS_id
	.type	_Z14diffusion_hostPdS_id, @function
_Z14diffusion_hostPdS_id:
.LFB2030:
	.cfi_startproc
	endbr64
	movslq	%edx, %r11
	movsd	.LC5(%rip), %xmm4
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	xorl	%r9d, %r9d
	movq	%r11, %rcx
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	salq	$3, %r11
	xorl	%r8d, %r8d
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	leal	-1(%rcx), %r13d
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	leal	-2(%rcx), %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%rsi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	xorl	%ebx, %ebx
.L28:
	cmpl	%ecx, %r8d
	jge	.L33
	incl	%r8d
	movq	%rbx, %r10
	xorl	%esi, %esi
	movl	%r8d, %eax
	cltd
	idivl	%ecx
	leal	(%r12,%r8), %eax
	imull	%ecx, %edx
	movslq	%edx, %rdx
	leaq	(%rdi,%rdx,8), %r15
	cltd
	idivl	%ecx
	imull	%ecx, %edx
	movslq	%edx, %rdx
	leaq	(%rdi,%rdx,8), %r14
.L29:
	leal	1(%rsi), %eax
	movsd	(%r15,%rsi,8), %xmm2
	addsd	(%r14,%rsi,8), %xmm2
	cltd
	movsd	(%rdi,%r10), %xmm3
	idivl	%ecx
	leal	0(%r13,%rsi), %eax
	incq	%rsi
	addl	%r9d, %edx
	movslq	%edx, %rdx
	addsd	(%rdi,%rdx,8), %xmm2
	cltd
	idivl	%ecx
	addl	%r9d, %edx
	movslq	%edx, %rdx
	movsd	(%rdi,%rdx,8), %xmm1
	addsd	%xmm2, %xmm1
	movaps	%xmm3, %xmm2
	mulsd	%xmm4, %xmm2
	subsd	%xmm2, %xmm1
	mulsd	%xmm0, %xmm1
	addsd	%xmm3, %xmm1
	movsd	%xmm1, 0(%rbp,%r10)
	addq	$8, %r10
	cmpl	%esi, %ecx
	jg	.L29
	addq	%r11, %rbx
	addl	%ecx, %r9d
	jmp	.L28
.L33:
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2030:
	.size	_Z14diffusion_hostPdS_id, .-_Z14diffusion_hostPdS_id
	.globl	_Z13check_residuePdS_i
	.type	_Z13check_residuePdS_i, @function
_Z13check_residuePdS_i:
.LFB2031:
	.cfi_startproc
	endbr64
	imull	%edx, %edx
	xorl	%eax, %eax
	xorps	%xmm1, %xmm1
.L35:
	cmpl	%eax, %edx
	jle	.L37
	movsd	(%rdi,%rax,8), %xmm0
	subsd	(%rsi,%rax,8), %xmm0
	incq	%rax
	mulsd	%xmm0, %xmm0
	addsd	%xmm0, %xmm1
	jmp	.L35
.L37:
	movaps	%xmm1, %xmm0
	ret
	.cfi_endproc
.LFE2031:
	.size	_Z13check_residuePdS_i, .-_Z13check_residuePdS_i
	.globl	_Z38__device_stub__Z16diffusion_globalPdS_PdS_
	.type	_Z38__device_stub__Z16diffusion_globalPdS_PdS_, @function
_Z38__device_stub__Z16diffusion_globalPdS_PdS_:
.LFB2057:
	.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	.L38
	pushq	32(%rsp)
	.cfi_def_cfa_offset 136
	leaq	_Z16diffusion_globalPdS_(%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
.L38:
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	je	.L40
	call	__stack_chk_fail@PLT
.L40:
	addq	$120, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2057:
	.size	_Z38__device_stub__Z16diffusion_globalPdS_PdS_, .-_Z38__device_stub__Z16diffusion_globalPdS_PdS_
	.globl	_Z16diffusion_globalPdS_
	.type	_Z16diffusion_globalPdS_, @function
_Z16diffusion_globalPdS_:
.LFB2058:
	.cfi_startproc
	endbr64
	jmp	_Z38__device_stub__Z16diffusion_globalPdS_PdS_
	.cfi_endproc
.LFE2058:
	.size	_Z16diffusion_globalPdS_, .-_Z16diffusion_globalPdS_
	.globl	_Z38__device_stub__Z16diffusion_sharedPdS_PdS_
	.type	_Z38__device_stub__Z16diffusion_sharedPdS_PdS_, @function
_Z38__device_stub__Z16diffusion_sharedPdS_PdS_:
.LFB2059:
	.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	.L43
	pushq	32(%rsp)
	.cfi_def_cfa_offset 136
	leaq	_Z16diffusion_sharedPdS_(%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
.L43:
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	je	.L45
	call	__stack_chk_fail@PLT
.L45:
	addq	$120, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2059:
	.size	_Z38__device_stub__Z16diffusion_sharedPdS_PdS_, .-_Z38__device_stub__Z16diffusion_sharedPdS_PdS_
	.globl	_Z16diffusion_sharedPdS_
	.type	_Z16diffusion_sharedPdS_, @function
_Z16diffusion_sharedPdS_:
.LFB2060:
	.cfi_startproc
	endbr64
	jmp	_Z38__device_stub__Z16diffusion_sharedPdS_PdS_
	.cfi_endproc
.LFE2060:
	.size	_Z16diffusion_sharedPdS_, .-_Z16diffusion_sharedPdS_
	.section	.rodata.str1.1
.LC7:
	.string	"host:%ld\n"
.LC8:
	.string	"global:%ld\n"
.LC9:
	.string	"shared:%ld\n"
.LC10:
	.string	"answers\n"
.LC11:
	.string	"global:%f\n"
.LC12:
	.string	"shared:%f\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2032:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	$1, %r8d
	xorl	%ecx, %ecx
	movl	$4, %edx
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	leaq	_ZL1n(%rip), %rdi
	movl	$1, %r14d
	xorl	%r15d, %r15d
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movl	$2000, %r13d
	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	$104, %rsp
	.cfi_def_cfa_offset 160
	movq	%fs:40, %rax
	movq	%rax, 88(%rsp)
	xorl	%eax, %eax
	movq	.LC6(%rip), %rax
	leaq	4(%rsp), %rsi
	movl	$256, 4(%rsp)
	movl	$1, 40(%rsp)
	movq	%rax, 8(%rsp)
	movabsq	$137438953504, %rax
	movq	%rax, 32(%rsp)
	call	cudaMemcpyToSymbol@PLT
	movl	$1, %r8d
	xorl	%ecx, %ecx
	leaq	8(%rsp), %rsi
	movl	$8, %edx
	leaq	_ZL5theta(%rip), %rdi
	call	cudaMemcpyToSymbol@PLT
	leaq	56(%rsp), %rdi
	movl	$2, %edx
	movl	$524288, %esi
	call	cudaHostAlloc@PLT
	leaq	64(%rsp), %rdi
	movl	$2, %edx
	movl	$524288, %esi
	call	cudaHostAlloc@PLT
	leaq	16(%rsp), %rdi
	movl	$2, %edx
	movl	$524288, %esi
	call	cudaHostAlloc@PLT
	movl	$2, %edx
	leaq	24(%rsp), %rdi
	movl	$524288, %esi
	call	cudaHostAlloc@PLT
	leaq	72(%rsp), %rdi
	movl	$524288, %esi
	call	cudaMalloc@PLT
	movl	$524288, %esi
	leaq	80(%rsp), %rdi
	call	cudaMalloc@PLT
	movl	$524288, %edi
	call	malloc@PLT
	movl	4(%rsp), %esi
	movq	56(%rsp), %rdi
	movl	$10, %edx
	movq	%rax, %rbx
	call	_Z10init_fieldPdii
	call	clock@PLT
	movq	%rax, %r12
.L49:
	movslq	%r14d, %rax
	movsd	8(%rsp), %xmm0
	movl	4(%rsp), %edx
	movq	56(%rsp,%rax,8), %rbp
	movslq	%r15d, %rax
	movq	56(%rsp,%rax,8), %rdi
	movq	%rbp, %rsi
	call	_Z14diffusion_hostPdS_id
	movl	%r14d, %eax
	movl	%r15d, %r14d
	decl	%r13d
	je	.L59
	movl	%eax, %r15d
	jmp	.L49
.L59:
	movq	%rbp, %rsi
	movl	$131072, %ecx
	movq	%rbx, %rdi
	movl	$1, %ebp
	rep movsl
	movl	$2000, %r13d
	xorl	%r14d, %r14d
	movabsq	$4294967304, %r15
	call	clock@PLT
	leaq	.LC7(%rip), %rsi
	movl	$2, %edi
	subq	%r12, %rax
	movq	%rax, %rdx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	4(%rsp), %esi
	movq	56(%rsp), %rdi
	movl	$10, %edx
	call	_Z10init_fieldPdii
	call	clock@PLT
	movq	56(%rsp), %rsi
	movq	72(%rsp), %rdi
	movl	$1, %ecx
	movl	$524288, %edx
	movq	%rax, %r12
	call	cudaMemcpy@PLT
.L51:
	movl	40(%rsp), %ecx
	movq	32(%rsp), %rdx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movq	%r15, %rdi
	movl	$1, %esi
	movq	%r15, 44(%rsp)
	movl	$1, 52(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L50
	movslq	%ebp, %rax
	movq	72(%rsp,%rax,8), %rsi
	movslq	%r14d, %rax
	movq	72(%rsp,%rax,8), %rdi
	call	_Z38__device_stub__Z16diffusion_globalPdS_PdS_
.L50:
	call	cudaDeviceSynchronize@PLT
	decl	%r13d
	je	.L60
	movl	%r14d, %eax
	movl	%ebp, %r14d
	movslq	%eax, %rbp
	jmp	.L51
.L60:
	movq	72(%rsp,%rbp,8), %rsi
	movq	16(%rsp), %rdi
	movl	$2, %ecx
	movl	$524288, %edx
	movl	$2000, %r13d
	movl	$1, %ebp
	xorl	%r14d, %r14d
	movabsq	$4294967304, %r15
	call	cudaMemcpy@PLT
	call	clock@PLT
	leaq	.LC8(%rip), %rsi
	movl	$2, %edi
	subq	%r12, %rax
	movq	%rax, %rdx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	4(%rsp), %esi
	movq	56(%rsp), %rdi
	movl	$10, %edx
	call	_Z10init_fieldPdii
	call	clock@PLT
	movq	56(%rsp), %rsi
	movq	72(%rsp), %rdi
	movl	$1, %ecx
	movl	$524288, %edx
	movq	%rax, %r12
	call	cudaMemcpy@PLT
.L53:
	movl	40(%rsp), %ecx
	movq	32(%rsp), %rdx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movq	%r15, %rdi
	movl	$1, %esi
	movq	%r15, 44(%rsp)
	movl	$1, 52(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L52
	movslq	%ebp, %rax
	movq	72(%rsp,%rax,8), %rsi
	movslq	%r14d, %rax
	movq	72(%rsp,%rax,8), %rdi
	call	_Z38__device_stub__Z16diffusion_sharedPdS_PdS_
.L52:
	call	cudaDeviceSynchronize@PLT
	decl	%r13d
	je	.L61
	movl	%r14d, %eax
	movl	%ebp, %r14d
	movslq	%eax, %rbp
	jmp	.L53
.L61:
	movq	72(%rsp,%rbp,8), %rsi
	movq	24(%rsp), %rdi
	movl	$2, %ecx
	movl	$524288, %edx
	call	cudaMemcpy@PLT
	call	clock@PLT
	leaq	.LC9(%rip), %rsi
	movl	$2, %edi
	subq	%r12, %rax
	movq	%rax, %rdx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	.LC10(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	4(%rsp), %edx
	movq	16(%rsp), %rsi
	movq	%rbx, %rdi
	call	_Z13check_residuePdS_i
	leaq	.LC11(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	call	__printf_chk@PLT
	movl	4(%rsp), %edx
	movq	24(%rsp), %rsi
	movq	%rbx, %rdi
	call	_Z13check_residuePdS_i
	leaq	.LC12(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	call	__printf_chk@PLT
	movq	56(%rsp), %rdi
	call	cudaFreeHost@PLT
	movq	64(%rsp), %rdi
	call	cudaFreeHost@PLT
	movq	16(%rsp), %rdi
	call	cudaFreeHost@PLT
	movq	24(%rsp), %rdi
	call	cudaFreeHost@PLT
	movq	72(%rsp), %rdi
	call	cudaFree@PLT
	movq	80(%rsp), %rdi
	call	cudaFree@PLT
	movq	%rbx, %rdi
	call	free@PLT
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	je	.L54
	call	__stack_chk_fail@PLT
.L54:
	addq	$104, %rsp
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2032:
	.size	main, .-main
	.section	.rodata.str1.1
.LC13:
	.string	"_Z16diffusion_sharedPdS_"
.LC14:
	.string	"_Z16diffusion_globalPdS_"
.LC15:
	.string	"n"
.LC16:
	.string	"theta"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2062:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	pushq	$0
	.cfi_def_cfa_offset 24
	xorl	%r9d, %r9d
	orl	$-1, %r8d
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC13(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z16diffusion_sharedPdS_(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 48
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r9d, %r9d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC14(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z16diffusion_globalPdS_(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 40
	pushq	$0
	.cfi_def_cfa_offset 48
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC15(%rip), %rdx
	movl	$4, %r9d
	leaq	_ZL1n(%rip), %rsi
	pushq	$1
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	call	__cudaRegisterVar@PLT
	popq	%rax
	.cfi_def_cfa_offset 24
	popq	%rdx
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$1
	.cfi_def_cfa_offset 32
	leaq	.LC16(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movq	%rdx, %rcx
	movl	$8, %r9d
	leaq	_ZL5theta(%rip), %rsi
	call	__cudaRegisterVar@PLT
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	popq	%rcx
	.cfi_def_cfa_offset 24
	popq	%rsi
	.cfi_def_cfa_offset 16
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE2062:
	.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
	.local	_ZL5theta
	.comm	_ZL5theta,8,8
	.local	_ZL1n
	.comm	_ZL1n,4,4
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC0:
	.long	0
	.long	1071644672
	.align 8
.LC1:
	.long	0
	.long	1072693248
	.align 8
.LC3:
	.long	0
	.long	1081081856
	.align 8
.LC5:
	.long	0
	.long	1074790400
	.align 8
.LC6:
	.long	-1717986918
	.long	1069128089
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:


#include <hip/hip_runtime.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

/*  square root of number of threads in a block (the number of threads in a block is NT^2)  */
#define NT 32
/*  length of the target domain  */
#define L 10.0
/*  number of division for the discretization of the target domain  */
#define N 256
/*  dimensionless time step size (theta = D * dt / dx^2)  */
#define THETA 0.1
/*  number of iterations  */
#define M 2000


/*  constants on a GPU  */
__device__ __constant__ int n;
__device__ __constant__ double theta;

//GPU functions-----------------------------------------------------------------
__global__ void diffusion_global(double *field_device, double *field_device_new) {
	int i_global;
	int j_global;
	int i_left, i_right;
	int j_top, j_bottom;

	i_global = blockDim.x * blockIdx.x + threadIdx.x;

	if(i_global < n) {
		i_right = (i_global + 1) % n;
		i_left = (i_global - 1 + n) % n;
		for(j_global = threadIdx.y; j_global < n; j_global += NT) {
			j_top = (j_global + 1) % n;
			j_bottom = (j_global - 1 + n) % n;
			field_device_new[i_global * n + j_global] =  field_device[i_global * n + j_global]
				+ theta * (field_device[i_right * n + j_global] + field_device[i_left * n + j_global]
					      + field_device[i_global * n + j_top] + field_device[i_global * n + j_bottom]
					      - 4.0 * field_device[i_global * n + j_global]);
		}
	}
}

__global__ void diffusion_shared(double *field_device, double *field_device_new) {
	int i_global;
	int j_global;
	int i_shared;
	int j_shared;
	int i_left, i_right;
	int j_top, j_bottom;
	double field_register;
	__shared__ double field_shared[(NT + 2) * (NT + 2)];

	i_global = blockDim.x * blockIdx.x + threadIdx.x;
	i_shared = threadIdx.x + 1;
	j_shared = threadIdx.y + 1;

	if(i_global < n) {
		for(j_global = threadIdx.y; j_global < n; j_global += NT) {
			//copy field from global to shared----------------------
			field_register = field_device[i_global * n + j_global];
			field_shared[i_shared * (NT + 2) + j_shared] = field_register;
			if(i_shared == 1) {
				i_left = (i_global - 1 + n) % n;
				field_shared[0 * (NT + 2) + j_shared] = field_device[i_left * n + j_global];
			} else if(i_shared == NT) {
				i_right = (i_global + 1) % n;
				field_shared[(NT + 1) * (NT + 2) + j_shared] = field_device[i_right * n + j_global];
			}
			if(j_shared == 1) {
				j_bottom = (j_global - 1 + n) % n;
				field_shared[i_shared * (NT + 2) + 0] = field_device[i_global * n + j_bottom];
			} else if(j_shared == NT) {
				j_top = (j_global + 1) % n;
				field_shared[i_shared * (NT + 2) + (NT + 1)] = field_device[i_global * n + j_top];
			}
			__syncthreads();

			//calculate field evolution-----------------------------
			field_device_new[i_global * n + j_global] = field_register
				+ theta * (field_shared[(i_shared + 1) * (NT + 2) + j_shared] + field_shared[(i_shared - 1) * (NT + 2) + j_shared]
					      + field_shared[i_shared * (NT + 2) + (j_shared + 1)] + field_shared[i_shared * (NT + 2) + (j_shared - 1)]
					      - 4.0 * field_register);

		}
	}
}

//Host functions----------------------------------------------------------------
void init_field(double *field_host, int n_host, int l_host) {
	int i;
	int j;
	double x;
	double y;
	double dx = l_host / (double)n_host;
	double dy = l_host / (double)n_host;
	double midst = l_host * 0.5;
	for(i = 0; i < n_host; i += 1) {
		x = (double)i * dx;
		for(j = 0; j < n_host; j += 1) {
			y = (double)j * dy;
			if((x > midst && y > midst) || (x < midst && y < midst)) {
				field_host[n_host * j + i] = 1.0;
			} else {
				field_host[n_host * j + i] = 0.0;
			}
		}
	}
}

void flip_ij(int *i, int *j) {
	int i_temp;
	i_temp = *i;
	*i = *j;
	*j = i_temp;
}

void print_field(FILE *file_write, double *field, int n, double l) {
	int i;
	int j;
	double x;
	double y;
	double d = l/(double)n;
	for(i = 0; i < N; i += 1) {
		y = (double)j * d;
		for(j = 0; j < N; j += 1) {
			x = (double)i * d;
			fprintf(file_write, "%f %f %f\n", x, y, field[i * n + j]);
		}
	}
}

void diffusion_host(double *field_host, double *field_host_new, int n_host, double theta_host) {
	int i;
	int j;
	int i_right, i_left;
	int j_top, j_bottom;

	for(i = 0; i < n_host; i += 1) {
		i_right = (i + 1) % n_host;
		i_left = (i - 1 + n_host) % n_host;
		for(j = 0; j < n_host; j += 1) {
			j_top = (j + 1) % n_host;
			j_bottom = (j - 1 + n_host) % n_host;
			field_host_new[i * n_host + j] = field_host[i * n_host + j]
				+ theta_host * (field_host[i_right * n_host + j] + field_host[i_left * n_host + j]
					      + field_host[i * n_host + j_top] + field_host[i * n_host + j_bottom]
					      - 4.0 * field_host[i * n_host + j]);

		}
	}
}

double check_residue(double *field_host, double *field_device, int n_host) {
	int i;
	double residue = 0.0;

	for(i = 0; i < n_host * n_host; i += 1) {
		residue += (field_host[i] - field_device[i]) * (field_host[i] - field_device[i]);;
	}
	return residue;
}

int main(void) {
//delcare variavles-------------------------------------------------------------
	int i;
	int j;
	int k;
	int n_host;
	int n_square;
	int iteration;
	int n_blocks;
	double l_host;
	double theta_host;
	dim3 dim_threads;
	double *field_host[2];
	double *field_device[2];
	double *result_host;
	double *result_global_host;
	double *result_shared_host;
	FILE *file_write;
	char filename_write[256];
	clock_t start, end;

//initialize--------------------------------------------------------------------
	//set variables---------------------------------------------------------
	n_host = N;
	n_square = N * N;
	l_host = L;
	theta_host = THETA;
	dim_threads.x = NT;
	dim_threads.y = NT;
	dim_threads.z = 1;
	n_blocks = (int)(ceil((double)n_host / NT));
	iteration = M;

	//allocate memories-----------------------------------------------------
	hipMemcpyToSymbol(HIP_SYMBOL(n), &n_host, sizeof(int), 0, hipMemcpyHostToDevice);
	hipMemcpyToSymbol(HIP_SYMBOL(theta), &theta_host, sizeof(double), 0, hipMemcpyHostToDevice);
	hipHostAlloc((void **)&field_host[0], n_square * sizeof(double), hipHostMallocMapped);
	hipHostAlloc((void **)&field_host[1], n_square * sizeof(double), hipHostMallocMapped);
	hipHostAlloc((void **)&result_global_host,  n_square * sizeof(double), hipHostMallocMapped);
	hipHostAlloc((void **)&result_shared_host,  n_square * sizeof(double), hipHostMallocMapped);
	hipMalloc((void **)&field_device[0], n_square * sizeof(double));
	hipMalloc((void **)&field_device[1], n_square * sizeof(double));
	result_host = (double *)malloc(n_square * sizeof(double));

//calculate on CPU--------------------------------------------------------------
	//initialize field------------------------------------------------------
	init_field(field_host[0], n_host, l_host);
	start = clock();
	//iteration-------------------------------------------------------------
	i = 0;
	j = 1;
	for(k = 0; k < iteration; k += 1) {
		diffusion_host(field_host[i], field_host[j], n_host, theta_host);
		flip_ij(&i, &j);
	}
	//save and print out----------------------------------------------------
	memcpy(result_host, field_host[i], n_square * sizeof(double));
	end = clock();
	printf("host:%ld\n", end - start);
	/*sprintf(filename_write, "result_host.txt");
	file_write = fopen(filename_write, "w");
	print_field(file_write, result_host, n_host, l_host);
	fclose(file_write);*/

//calculate using only global memory--------------------------------------------
	//initialize field------------------------------------------------------
	init_field(field_host[0], n_host, l_host);
	start = clock();
	hipMemcpy(field_device[0], field_host[0], n_square * sizeof(double), hipMemcpyHostToDevice);
	//iteration-------------------------------------------------------------
	i = 0;
	j = 1;
	for(k = 0; k < iteration; k += 1) {
		diffusion_global<<<n_blocks, dim_threads>>>(field_device[i], field_device[j]);
		hipDeviceSynchronize();
		flip_ij(&i, &j);
	}
	//copy to host and print out--------------------------------------------
	hipMemcpy(result_global_host, field_device[i], n_square * sizeof(double), hipMemcpyDeviceToHost);
	end = clock();
	printf("global:%ld\n", end - start);
	/*sprintf(filename_write, "result_global.txt");
	file_write = fopen(filename_write, "w");
	print_field(file_write, result_global_host, n_host, l_host);
	fclose(file_write);*/

//calculate using shared memory-------------------------------------------------
	//initialize field------------------------------------------------------
	init_field(field_host[0], n_host, l_host);
	start = clock();
	hipMemcpy(field_device[0], field_host[0], n_square * sizeof(double), hipMemcpyHostToDevice);
	//iteration-------------------------------------------------------------
	i = 0;
	j = 1;
	for(k = 0; k < iteration; k += 1) {
		diffusion_shared<<<n_blocks, dim_threads>>>(field_device[i], field_device[j]);
		hipDeviceSynchronize();
		flip_ij(&i, &j);
	}
	//copy to host and print out--------------------------------------------
	hipMemcpy(result_shared_host, field_device[i], n_square * sizeof(double), hipMemcpyDeviceToHost);
	end = clock();
	printf("shared:%ld\n", end - start);
	/*sprintf(filename_write, "result_shared.txt");
	file_write = fopen(filename_write, "w");
	print_field(file_write, result_shared_host, n_host, l_host);
	fclose(file_write);*/

//check answers-----------------------------------------------------------------
	printf("answers\n");
	printf("global:%f\n", check_residue(result_host, result_global_host, n_host));
	printf("shared:%f\n",  check_residue(result_host, result_shared_host, n_host));

//finalize----------------------------------------------------------------------
	hipHostFree(field_host[0]);
	hipHostFree(field_host[1]);
	hipHostFree(result_global_host);
	hipHostFree(result_shared_host);
	hipFree(field_device[0]);
	hipFree(field_device[1]);
	free(result_host);

	return 0;
}

	.text
	.file	"diffusion_me.hip"
	.globl	_Z31__device_stub__diffusion_globalPdS_ # -- Begin function _Z31__device_stub__diffusion_globalPdS_
	.type	_Z31__device_stub__diffusion_globalPdS_,@function
_Z31__device_stub__diffusion_globalPdS_: # @_Z31__device_stub__diffusion_globalPdS_
	.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	$_Z16diffusion_globalPdS_, %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_end0:
	.size	_Z31__device_stub__diffusion_globalPdS_, .Lfunc_end0-_Z31__device_stub__diffusion_globalPdS_
	.cfi_endproc
                                        # -- End function
	.globl	_Z31__device_stub__diffusion_sharedPdS_ # -- Begin function _Z31__device_stub__diffusion_sharedPdS_
	.type	_Z31__device_stub__diffusion_sharedPdS_,@function
_Z31__device_stub__diffusion_sharedPdS_: # @_Z31__device_stub__diffusion_sharedPdS_
	.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	$_Z16diffusion_sharedPdS_, %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	_Z31__device_stub__diffusion_sharedPdS_, .Lfunc_end1-_Z31__device_stub__diffusion_sharedPdS_
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z10init_fieldPdii
.LCPI2_0:
	.quad	0x3fe0000000000000              # double 0.5
.LCPI2_1:
	.quad	0x3ff0000000000000              # double 1
	.text
	.globl	_Z10init_fieldPdii
	.type	_Z10init_fieldPdii,@function
_Z10init_fieldPdii:                     # @_Z10init_fieldPdii
	.cfi_startproc
# %bb.0:
	testl	%esi, %esi
	jle	.LBB2_5
# %bb.1:                                # %.lr.ph37
	cvtsi2sd	%edx, %xmm0
	cvtsi2sd	%esi, %xmm2
	movapd	%xmm0, %xmm1
	divsd	%xmm2, %xmm1
	mulsd	.LCPI2_0(%rip), %xmm0
	movl	%esi, %eax
	leaq	(,%rax,8), %rcx
	xorl	%edx, %edx
	movsd	.LCPI2_1(%rip), %xmm2           # xmm2 = mem[0],zero
.LBB2_2:                                # %.lr.ph
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB2_3 Depth 2
	xorps	%xmm3, %xmm3
	cvtsi2sd	%edx, %xmm3
	mulsd	%xmm1, %xmm3
	movapd	%xmm0, %xmm4
	cmpltsd	%xmm3, %xmm4
	cmpltsd	%xmm0, %xmm3
	movq	%rdi, %rsi
	xorl	%r8d, %r8d
.LBB2_3:                                #   Parent Loop BB2_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	xorps	%xmm5, %xmm5
	cvtsi2sd	%r8d, %xmm5
	mulsd	%xmm1, %xmm5
	movapd	%xmm0, %xmm6
	cmpltsd	%xmm5, %xmm6
	cmpltsd	%xmm0, %xmm5
	andpd	%xmm2, %xmm5
	andpd	%xmm3, %xmm5
	movapd	%xmm4, %xmm7
	andnpd	%xmm5, %xmm7
	movapd	%xmm6, %xmm8
	andnpd	%xmm5, %xmm8
	andpd	%xmm2, %xmm6
	orpd	%xmm8, %xmm6
	andpd	%xmm4, %xmm6
	orpd	%xmm7, %xmm6
	movlpd	%xmm6, (%rsi)
	incq	%r8
	addq	%rcx, %rsi
	cmpq	%r8, %rax
	jne	.LBB2_3
# %bb.4:                                # %._crit_edge
                                        #   in Loop: Header=BB2_2 Depth=1
	incq	%rdx
	addq	$8, %rdi
	cmpq	%rax, %rdx
	jne	.LBB2_2
.LBB2_5:                                # %._crit_edge38
	retq
.Lfunc_end2:
	.size	_Z10init_fieldPdii, .Lfunc_end2-_Z10init_fieldPdii
	.cfi_endproc
                                        # -- End function
	.globl	_Z7flip_ijPiS_                  # -- Begin function _Z7flip_ijPiS_
	.type	_Z7flip_ijPiS_,@function
_Z7flip_ijPiS_:                         # @_Z7flip_ijPiS_
	.cfi_startproc
# %bb.0:
	movl	(%rdi), %eax
	movl	(%rsi), %ecx
	movl	%ecx, (%rdi)
	movl	%eax, (%rsi)
	retq
.Lfunc_end3:
	.size	_Z7flip_ijPiS_, .Lfunc_end3-_Z7flip_ijPiS_
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z11print_fieldP8_IO_FILEPdid
.LCPI4_0:
	.quad	0x4070000000000000              # double 256
	.text
	.globl	_Z11print_fieldP8_IO_FILEPdid
	.type	_Z11print_fieldP8_IO_FILEPdid,@function
_Z11print_fieldP8_IO_FILEPdid:          # @_Z11print_fieldP8_IO_FILEPdid
	.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	$32, %rsp
	.cfi_def_cfa_offset 80
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rsi, %rbx
	movq	%rdi, %r14
	cvtsi2sd	%edx, %xmm1
	divsd	%xmm1, %xmm0
	movslq	%edx, %r15
	movsd	.LCPI4_0(%rip), %xmm1           # xmm1 = mem[0],zero
	movsd	%xmm0, 8(%rsp)                  # 8-byte Spill
	mulsd	%xmm0, %xmm1
	shlq	$3, %r15
	xorl	%r12d, %r12d
	movsd	%xmm1, 16(%rsp)                 # 8-byte Spill
.LBB4_1:                                # =>This Loop Header: Depth=1
                                        #     Child Loop BB4_2 Depth 2
	xorps	%xmm0, %xmm0
	cvtsi2sd	%r12d, %xmm0
	mulsd	8(%rsp), %xmm0                  # 8-byte Folded Reload
	movsd	%xmm0, 24(%rsp)                 # 8-byte Spill
	xorl	%r13d, %r13d
.LBB4_2:                                #   Parent Loop BB4_1 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movsd	(%rbx,%r13,8), %xmm2            # xmm2 = mem[0],zero
	movl	$.L.str, %esi
	movq	%r14, %rdi
	movsd	24(%rsp), %xmm0                 # 8-byte Reload
                                        # xmm0 = mem[0],zero
	movsd	16(%rsp), %xmm1                 # 8-byte Reload
                                        # xmm1 = mem[0],zero
	movb	$3, %al
	callq	fprintf
	incq	%r13
	cmpq	$256, %r13                      # imm = 0x100
	jne	.LBB4_2
# %bb.3:                                #   in Loop: Header=BB4_1 Depth=1
	incq	%r12
	addq	%r15, %rbx
	cmpq	$256, %r12                      # imm = 0x100
	jne	.LBB4_1
# %bb.4:
	addq	$32, %rsp
	.cfi_def_cfa_offset 48
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end4:
	.size	_Z11print_fieldP8_IO_FILEPdid, .Lfunc_end4-_Z11print_fieldP8_IO_FILEPdid
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z14diffusion_hostPdS_id
.LCPI5_0:
	.quad	0xc010000000000000              # double -4
	.text
	.globl	_Z14diffusion_hostPdS_id
	.type	_Z14diffusion_hostPdS_id,@function
_Z14diffusion_hostPdS_id:               # @_Z14diffusion_hostPdS_id
	.cfi_startproc
# %bb.0:
	testl	%edx, %edx
	jle	.LBB5_6
# %bb.1:                                # %.lr.ph48
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	%edx, %ecx
	movl	%edx, %r8d
	leal	-1(%rcx), %eax
	movq	%rax, -8(%rsp)                  # 8-byte Spill
	leaq	(,%r8,8), %rax
	movq	%rax, -16(%rsp)                 # 8-byte Spill
	movq	%r8, %r11
	negq	%r11
	xorl	%ebx, %ebx
	movsd	.LCPI5_0(%rip), %xmm1           # xmm1 = mem[0],zero
	movq	%rdi, %r14
	xorl	%r15d, %r15d
.LBB5_3:                                # %.lr.ph
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB5_4 Depth 2
	movq	%r15, %r12
	incq	%r15
	movq	-8(%rsp), %rax                  # 8-byte Reload
	addl	%r12d, %eax
	cltd
	idivl	%ecx
	cmpq	%r8, %r15
	movl	%r15d, %eax
	cmovel	%ebx, %eax
	imulq	%r8, %r12
	imull	%ecx, %eax
	imull	%ecx, %edx
	cltq
	movslq	%edx, %rdx
	leaq	(%rdi,%rax,8), %r13
	leaq	(%rdi,%rdx,8), %rbp
	leaq	(%rdi,%r12,8), %r9
	movl	$1, %r10d
.LBB5_4:                                #   Parent Loop BB5_3 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	leal	(%r8,%r10), %eax
	addl	$-2, %eax
	cltd
	idivl	%r8d
	cmpq	%r10, %r8
	movsd	-8(%r13,%r10,8), %xmm2          # xmm2 = mem[0],zero
	addsd	-8(%rbp,%r10,8), %xmm2
	movsd	-8(%r14,%r10,8), %xmm3          # xmm3 = mem[0],zero
	movl	%r10d, %eax
	cmovel	%ebx, %eax
	addl	%r12d, %eax
	addsd	(%rdi,%rax,8), %xmm2
	movslq	%edx, %rax
	addsd	(%r9,%rax,8), %xmm2
	movapd	%xmm3, %xmm4
	mulsd	%xmm1, %xmm4
	addsd	%xmm2, %xmm4
	mulsd	%xmm0, %xmm4
	addsd	%xmm3, %xmm4
	movsd	%xmm4, -8(%rsi,%r10,8)
	leaq	(%r11,%r10), %rax
	incq	%rax
	incq	%r10
	cmpq	$1, %rax
	jne	.LBB5_4
# %bb.2:                                # %.loopexit
                                        #   in Loop: Header=BB5_3 Depth=1
	movq	-16(%rsp), %rax                 # 8-byte Reload
	addq	%rax, %rsi
	addq	%rax, %r14
	cmpq	%r8, %r15
	jne	.LBB5_3
# %bb.5:
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	.cfi_restore %rbx
	.cfi_restore %r12
	.cfi_restore %r13
	.cfi_restore %r14
	.cfi_restore %r15
	.cfi_restore %rbp
.LBB5_6:                                # %._crit_edge
	retq
.Lfunc_end5:
	.size	_Z14diffusion_hostPdS_id, .Lfunc_end5-_Z14diffusion_hostPdS_id
	.cfi_endproc
                                        # -- End function
	.globl	_Z13check_residuePdS_i          # -- Begin function _Z13check_residuePdS_i
	.type	_Z13check_residuePdS_i,@function
_Z13check_residuePdS_i:                 # @_Z13check_residuePdS_i
	.cfi_startproc
# %bb.0:
                                        # kill: def $edx killed $edx def $rdx
	testl	%edx, %edx
	je	.LBB6_1
# %bb.2:                                # %.lr.ph.preheader
	imull	%edx, %edx
	cmpl	$1, %edx
	adcl	$0, %edx
	xorpd	%xmm0, %xmm0
	xorl	%eax, %eax
.LBB6_3:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movsd	(%rdi,%rax,8), %xmm1            # xmm1 = mem[0],zero
	subsd	(%rsi,%rax,8), %xmm1
	mulsd	%xmm1, %xmm1
	addsd	%xmm1, %xmm0
	incq	%rax
	cmpq	%rax, %rdx
	jne	.LBB6_3
# %bb.4:                                # %._crit_edge
	retq
.LBB6_1:
	xorps	%xmm0, %xmm0
	retq
.Lfunc_end6:
	.size	_Z13check_residuePdS_i, .Lfunc_end6-_Z13check_residuePdS_i
	.cfi_endproc
                                        # -- End function
	.globl	main                            # -- Begin function main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$104, %rsp
	.cfi_def_cfa_offset 160
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	leaq	12(%rsp), %r14
	movl	$256, (%r14)                    # imm = 0x100
	movabsq	$4591870180066957722, %rax      # imm = 0x3FB999999999999A
	leaq	96(%rsp), %rbx
	movq	%rax, (%rbx)
	xorl	%r13d, %r13d
	movl	$1, %ebp
	movl	$n, %edi
	movl	$4, %edx
	movq	%r14, %rsi
	xorl	%ecx, %ecx
	movl	$1, %r8d
	callq	hipMemcpyToSymbol
	movl	$theta, %edi
	movl	$8, %edx
	movq	%rbx, %rsi
	xorl	%ecx, %ecx
	movl	$1, %r8d
	callq	hipMemcpyToSymbol
	leaq	48(%rsp), %rdi
	movl	$524288, %esi                   # imm = 0x80000
	movl	$2, %edx
	callq	hipHostAlloc
	leaq	56(%rsp), %r15
	movl	$524288, %esi                   # imm = 0x80000
	movq	%r15, %rdi
	movl	$2, %edx
	callq	hipHostAlloc
	leaq	80(%rsp), %rdi
	movl	$524288, %esi                   # imm = 0x80000
	movl	$2, %edx
	callq	hipHostAlloc
	leaq	72(%rsp), %rdi
	movl	$524288, %esi                   # imm = 0x80000
	movl	$2, %edx
	callq	hipHostAlloc
	leaq	16(%rsp), %rdi
	movl	$524288, %esi                   # imm = 0x80000
	callq	hipMalloc
	leaq	24(%rsp), %rdi
	movl	$524288, %esi                   # imm = 0x80000
	callq	hipMalloc
	movl	$524288, %edi                   # imm = 0x80000
	callq	malloc
	movq	%rax, 88(%rsp)                  # 8-byte Spill
	movq	-8(%r15), %rdi
	movl	(%r14), %esi
	movl	$10, %edx
	callq	_Z10init_fieldPdii
	movl	$2000, %ebx                     # imm = 0x7D0
	callq	clock
	movq	%rax, 40(%rsp)                  # 8-byte Spill
.LBB7_1:                                # =>This Inner Loop Header: Depth=1
	movl	%r13d, %r14d
	movl	%r13d, %eax
	movq	48(%rsp,%rax,8), %rdi
	movl	%ebp, %r12d
	movq	48(%rsp,%r12,8), %rsi
	movl	12(%rsp), %edx
	movsd	96(%rsp), %xmm0                 # xmm0 = mem[0],zero
	callq	_Z14diffusion_hostPdS_id
	movl	%ebp, %r13d
	movl	%r14d, %ebp
	decl	%ebx
	jne	.LBB7_1
# %bb.2:
	movabsq	$137438953504, %r14             # imm = 0x2000000020
	movabsq	$4294967304, %r15               # imm = 0x100000008
	movq	48(%rsp,%r12,8), %rsi
	movl	$524288, %edx                   # imm = 0x80000
	movq	88(%rsp), %rdi                  # 8-byte Reload
	callq	memcpy@PLT
	callq	clock
	subq	40(%rsp), %rax                  # 8-byte Folded Reload
	xorl	%ebx, %ebx
	movl	$.L.str.1, %edi
	movq	%rax, %rsi
	xorl	%eax, %eax
	callq	printf
	movq	48(%rsp), %rdi
	movl	12(%rsp), %esi
	movl	$10, %edx
	callq	_Z10init_fieldPdii
	callq	clock
	movq	%rax, 40(%rsp)                  # 8-byte Spill
	movq	16(%rsp), %rdi
	movq	48(%rsp), %rsi
	movl	$1, %r12d
	movl	$524288, %edx                   # imm = 0x80000
	movl	$1, %ecx
	callq	hipMemcpy
	movl	$2000, %r13d                    # imm = 0x7D0
.LBB7_3:                                # =>This Inner Loop Header: Depth=1
	movl	%r12d, %ebp
	movl	%ebx, %r12d
	movq	%r15, %rdi
	movl	$1, %esi
	movq	%r14, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB7_5
# %bb.4:                                #   in Loop: Header=BB7_3 Depth=1
	movl	%r12d, %eax
	movq	16(%rsp,%rax,8), %rdi
	movl	%ebp, %eax
	movq	16(%rsp,%rax,8), %rsi
	callq	_Z31__device_stub__diffusion_globalPdS_
.LBB7_5:                                #   in Loop: Header=BB7_3 Depth=1
	callq	hipDeviceSynchronize
	movl	%ebp, %ebx
	decl	%r13d
	jne	.LBB7_3
# %bb.6:
	movq	80(%rsp), %rdi
	movl	%ebp, %eax
	movq	16(%rsp,%rax,8), %rsi
	movl	$524288, %edx                   # imm = 0x80000
	movl	$2, %ecx
	callq	hipMemcpy
	callq	clock
	subq	40(%rsp), %rax                  # 8-byte Folded Reload
	xorl	%ebx, %ebx
	movl	$.L.str.2, %edi
	movq	%rax, %rsi
	xorl	%eax, %eax
	callq	printf
	movq	48(%rsp), %rdi
	movl	12(%rsp), %esi
	movl	$10, %edx
	callq	_Z10init_fieldPdii
	callq	clock
	movq	%rax, 40(%rsp)                  # 8-byte Spill
	movq	16(%rsp), %rdi
	movq	48(%rsp), %rsi
	movl	$1, %r12d
	movl	$524288, %edx                   # imm = 0x80000
	movl	$1, %ecx
	callq	hipMemcpy
	movl	$2000, %r13d                    # imm = 0x7D0
.LBB7_7:                                # =>This Inner Loop Header: Depth=1
	movl	%r12d, %ebp
	movl	%ebx, %r12d
	movq	%r15, %rdi
	movl	$1, %esi
	movq	%r14, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB7_9
# %bb.8:                                #   in Loop: Header=BB7_7 Depth=1
	movl	%r12d, %eax
	movq	16(%rsp,%rax,8), %rdi
	movl	%ebp, %eax
	movq	16(%rsp,%rax,8), %rsi
	callq	_Z31__device_stub__diffusion_sharedPdS_
.LBB7_9:                                #   in Loop: Header=BB7_7 Depth=1
	callq	hipDeviceSynchronize
	movl	%ebp, %ebx
	decl	%r13d
	jne	.LBB7_7
# %bb.10:
	movq	72(%rsp), %rdi
	movl	%ebp, %eax
	movq	16(%rsp,%rax,8), %rsi
	movl	$524288, %edx                   # imm = 0x80000
	movl	$2, %ecx
	callq	hipMemcpy
	callq	clock
	subq	40(%rsp), %rax                  # 8-byte Folded Reload
	movl	$.L.str.3, %edi
	movq	%rax, %rsi
	xorl	%eax, %eax
	callq	printf
	movl	$.Lstr, %edi
	callq	puts@PLT
	movl	12(%rsp), %eax
	xorpd	%xmm0, %xmm0
	testl	%eax, %eax
	movq	88(%rsp), %rbx                  # 8-byte Reload
	je	.LBB7_13
# %bb.11:                               # %.lr.ph.preheader.i
	movq	80(%rsp), %rcx
	imull	%eax, %eax
	cmpl	$1, %eax
	adcl	$0, %eax
	xorl	%edx, %edx
.LBB7_12:                               # %.lr.ph.i
                                        # =>This Inner Loop Header: Depth=1
	movsd	(%rbx,%rdx,8), %xmm1            # xmm1 = mem[0],zero
	subsd	(%rcx,%rdx,8), %xmm1
	mulsd	%xmm1, %xmm1
	addsd	%xmm1, %xmm0
	incq	%rdx
	cmpq	%rdx, %rax
	jne	.LBB7_12
.LBB7_13:                               # %_Z13check_residuePdS_i.exit
	movl	$.L.str.5, %edi
	movb	$1, %al
	callq	printf
	movl	12(%rsp), %eax
	testl	%eax, %eax
	xorpd	%xmm0, %xmm0
	je	.LBB7_16
# %bb.14:                               # %.lr.ph.preheader.i47
	movq	72(%rsp), %rcx
	imull	%eax, %eax
	cmpl	$1, %eax
	adcl	$0, %eax
	xorl	%edx, %edx
.LBB7_15:                               # %.lr.ph.i50
                                        # =>This Inner Loop Header: Depth=1
	movsd	(%rbx,%rdx,8), %xmm1            # xmm1 = mem[0],zero
	subsd	(%rcx,%rdx,8), %xmm1
	mulsd	%xmm1, %xmm1
	addsd	%xmm1, %xmm0
	incq	%rdx
	cmpq	%rdx, %rax
	jne	.LBB7_15
.LBB7_16:                               # %_Z13check_residuePdS_i.exit56
	movl	$.L.str.6, %edi
	movb	$1, %al
	callq	printf
	movq	48(%rsp), %rdi
	callq	hipHostFree
	movq	56(%rsp), %rdi
	callq	hipHostFree
	movq	80(%rsp), %rdi
	callq	hipHostFree
	movq	72(%rsp), %rdi
	callq	hipHostFree
	movq	16(%rsp), %rdi
	callq	hipFree
	movq	24(%rsp), %rdi
	callq	hipFree
	movq	%rbx, %rdi
	callq	free
	xorl	%eax, %eax
	addq	$104, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end7:
	.size	main, .Lfunc_end7-main
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$32, %rsp
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -16
	movq	__hip_gpubin_handle(%rip), %rbx
	testq	%rbx, %rbx
	jne	.LBB8_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB8_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z16diffusion_globalPdS_, %esi
	movl	$.L__unnamed_1, %edx
	movl	$.L__unnamed_1, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z16diffusion_sharedPdS_, %esi
	movl	$.L__unnamed_2, %edx
	movl	$.L__unnamed_2, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$0, 8(%rsp)
	movl	$1, (%rsp)
	movl	$n, %esi
	movl	$.L__unnamed_3, %edx
	movl	$.L__unnamed_3, %ecx
	movl	$4, %r9d
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	callq	__hipRegisterVar
	movl	$0, 8(%rsp)
	movl	$1, (%rsp)
	movl	$theta, %esi
	movl	$.L__unnamed_4, %edx
	movl	$.L__unnamed_4, %ecx
	movl	$8, %r9d
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	callq	__hipRegisterVar
	movl	$__hip_module_dtor, %edi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_end8:
	.size	__hip_module_ctor, .Lfunc_end8-__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	.LBB9_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
.LBB9_2:
	retq
.Lfunc_end9:
	.size	__hip_module_dtor, .Lfunc_end9-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	n,@object                       # @n
	.local	n
	.comm	n,4,4
	.type	theta,@object                   # @theta
	.local	theta
	.comm	theta,8,8
	.type	_Z16diffusion_globalPdS_,@object # @_Z16diffusion_globalPdS_
	.section	.rodata,"a",@progbits
	.globl	_Z16diffusion_globalPdS_
	.p2align	3, 0x0
_Z16diffusion_globalPdS_:
	.quad	_Z31__device_stub__diffusion_globalPdS_
	.size	_Z16diffusion_globalPdS_, 8

	.type	_Z16diffusion_sharedPdS_,@object # @_Z16diffusion_sharedPdS_
	.globl	_Z16diffusion_sharedPdS_
	.p2align	3, 0x0
_Z16diffusion_sharedPdS_:
	.quad	_Z31__device_stub__diffusion_sharedPdS_
	.size	_Z16diffusion_sharedPdS_, 8

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"%f %f %f\n"
	.size	.L.str, 10

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"host:%ld\n"
	.size	.L.str.1, 10

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"global:%ld\n"
	.size	.L.str.2, 12

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"shared:%ld\n"
	.size	.L.str.3, 12

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"global:%f\n"
	.size	.L.str.5, 11

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

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z16diffusion_globalPdS_"
	.size	.L__unnamed_1, 25

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_Z16diffusion_sharedPdS_"
	.size	.L__unnamed_2, 25

	.type	.L__unnamed_3,@object           # @2
.L__unnamed_3:
	.asciz	"n"
	.size	.L__unnamed_3, 2

	.type	.L__unnamed_4,@object           # @3
.L__unnamed_4:
	.asciz	"theta"
	.size	.L__unnamed_4, 6

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

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

	.type	.Lstr,@object                   # @str
	.section	.rodata.str1.1,"aMS",@progbits,1
.Lstr:
	.asciz	"answers"
	.size	.Lstr, 8

	.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 _Z31__device_stub__diffusion_globalPdS_
	.addrsig_sym _Z31__device_stub__diffusion_sharedPdS_
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym n
	.addrsig_sym theta
	.addrsig_sym _Z16diffusion_globalPdS_
	.addrsig_sym _Z16diffusion_sharedPdS_
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z16diffusion_globalPdS_ ; -- Begin function _Z16diffusion_globalPdS_
	.globl	_Z16diffusion_globalPdS_
	.p2align	8
	.type	_Z16diffusion_globalPdS_,@function
_Z16diffusion_globalPdS_:               ; @_Z16diffusion_globalPdS_
; %bb.0:
	s_load_b32 s4, s[0:1], 0x1c
	s_getpc_b64 s[2:3]
	s_add_u32 s2, s2, n@rel32@lo+4
	s_addc_u32 s3, s3, n@rel32@hi+12
	v_and_b32_e32 v3, 0x3ff, v0
	s_load_b32 s8, s[2:3], 0x0
	s_waitcnt lgkmcnt(0)
	s_and_b32 s2, s4, 0xffff
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	v_mad_u64_u32 v[1:2], null, s15, s2, v[3:4]
	s_mov_b32 s2, exec_lo
	s_delay_alu instid0(VALU_DEP_1)
	v_cmpx_gt_i32_e64 s8, v1
	s_cbranch_execz .LBB0_4
; %bb.1:
	v_bfe_u32 v0, v0, 10, 10
	s_delay_alu instid0(VALU_DEP_1)
	v_cmp_gt_i32_e32 vcc_lo, s8, v0
	s_and_b32 exec_lo, exec_lo, vcc_lo
	s_cbranch_execz .LBB0_4
; %bb.2:                                ; %.lr.ph
	s_ashr_i32 s2, s8, 31
	s_add_i32 s10, s8, -1
	s_add_i32 s3, s8, s2
	v_add_nc_u32_e32 v5, 1, v1
	s_xor_b32 s9, s3, s2
	v_mul_lo_u32 v10, v1, s8
	v_cvt_f32_u32_e32 v2, s9
	s_sub_i32 s2, 0, s9
	v_ashrrev_i32_e32 v7, 31, v5
	s_load_b128 s[4:7], s[0:1], 0x0
	s_getpc_b64 s[0:1]
	s_add_u32 s0, s0, theta@rel32@lo+4
	s_addc_u32 s1, s1, theta@rel32@hi+12
	v_rcp_iflag_f32_e32 v2, v2
	v_add_nc_u32_e32 v3, s10, v1
	v_add_nc_u32_e32 v5, v5, v7
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v6, 31, v3
	s_waitcnt_depctr 0xfff
	v_mul_f32_e32 v2, 0x4f7ffffe, v2
	v_cvt_u32_f32_e32 v2, v2
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	v_mul_lo_u32 v4, s2, v2
	s_load_b64 s[2:3], s[0:1], 0x0
	s_mov_b32 s1, 0
	v_mul_hi_u32 v4, v2, v4
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_add_nc_u32_e32 v9, v2, v4
	v_xor_b32_e32 v2, v5, v7
	v_mul_hi_u32 v5, v2, v9
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_lo_u32 v5, v5, s9
	v_sub_nc_u32_e32 v2, v2, v5
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_subrev_nc_u32_e32 v5, s9, v2
	v_add_nc_u32_e32 v3, v3, v6
	v_xor_b32_e32 v3, v3, v6
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_hi_u32 v4, v3, v9
	v_mul_lo_u32 v4, v4, s9
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_sub_nc_u32_e32 v3, v3, v4
	v_subrev_nc_u32_e32 v4, s9, v3
	v_cmp_le_u32_e32 vcc_lo, s9, v3
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_cndmask_b32_e32 v3, v3, v4, vcc_lo
	v_cmp_le_u32_e32 vcc_lo, s9, v2
	v_subrev_nc_u32_e32 v4, s9, v3
	v_cndmask_b32_e32 v2, v2, v5, vcc_lo
	v_cmp_le_u32_e32 vcc_lo, s9, v3
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_4)
	v_subrev_nc_u32_e32 v5, s9, v2
	v_cndmask_b32_e32 v3, v3, v4, vcc_lo
	v_cmp_le_u32_e32 vcc_lo, s9, v2
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_4)
	v_xor_b32_e32 v3, v3, v6
	v_cndmask_b32_e32 v2, v2, v5, vcc_lo
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_sub_nc_u32_e32 v3, v3, v6
	v_xor_b32_e32 v1, v2, v7
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_sub_nc_u32_e32 v4, v1, v7
	v_mad_u64_u32 v[1:2], null, v3, s8, v[0:1]
	v_add_nc_u32_e32 v3, v0, v10
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_mul_lo_u32 v5, v4, s8
	v_ashrrev_i32_e32 v4, 31, v3
	s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_ashrrev_i32_e32 v2, 31, v1
	v_ashrrev_i32_e32 v6, 31, v5
	v_add_co_u32 v5, vcc_lo, v5, v0
	s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_4)
	v_lshlrev_b64 v[7:8], 3, v[3:4]
	v_lshlrev_b64 v[3:4], 3, v[1:2]
	s_delay_alu instid0(VALU_DEP_4) | instskip(SKIP_1) | instid1(VALU_DEP_3)
	v_add_co_ci_u32_e32 v6, vcc_lo, 0, v6, vcc_lo
	s_waitcnt lgkmcnt(0)
	v_add_co_u32 v1, vcc_lo, s4, v7
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_3) | instid1(VALU_DEP_4)
	v_lshlrev_b64 v[5:6], 3, v[5:6]
	v_add_co_ci_u32_e32 v2, vcc_lo, s5, v8, vcc_lo
	v_add_co_u32 v3, vcc_lo, s4, v3
	v_add_co_ci_u32_e32 v4, vcc_lo, s5, v4, vcc_lo
	v_add_co_u32 v5, vcc_lo, s4, v5
	v_add_co_ci_u32_e32 v6, vcc_lo, s5, v6, vcc_lo
	v_add_co_u32 v7, vcc_lo, s6, v7
	v_add_co_ci_u32_e32 v8, vcc_lo, s7, v8, vcc_lo
.LBB0_3:                                ; =>This Inner Loop Header: Depth=1
	v_cmp_ne_u32_e32 vcc_lo, s10, v0
	v_add_nc_u32_e32 v16, s10, v0
	global_load_b64 v[11:12], v[5:6], off
	global_load_b64 v[13:14], v[3:4], off
	v_ashrrev_i32_e32 v17, 31, v16
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_nc_u32_e32 v18, v16, v17
	v_xor_b32_e32 v18, v18, v17
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_hi_u32 v19, v18, v9
	v_mul_lo_u32 v19, v19, s9
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_sub_nc_u32_e32 v18, v18, v19
	v_subrev_nc_u32_e32 v19, s9, v18
	v_add_nc_u32_e32 v15, 1, v0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_dual_cndmask_b32 v15, 0, v15 :: v_dual_add_nc_u32 v0, 32, v0
	v_add_nc_u32_e32 v15, v15, v10
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v16, 31, v15
	v_lshlrev_b64 v[15:16], 3, v[15:16]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v15, vcc_lo, s4, v15
	v_add_co_ci_u32_e32 v16, vcc_lo, s5, v16, vcc_lo
	v_cmp_le_u32_e32 vcc_lo, s9, v18
	global_load_b64 v[15:16], v[15:16], off
	v_cndmask_b32_e32 v18, v18, v19, vcc_lo
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_subrev_nc_u32_e32 v19, s9, v18
	v_cmp_le_u32_e32 vcc_lo, s9, v18
	v_cndmask_b32_e32 v18, v18, v19, vcc_lo
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_xor_b32_e32 v18, v18, v17
	v_sub_nc_u32_e32 v17, v18, v17
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_nc_u32_e32 v17, v17, v10
	v_ashrrev_i32_e32 v18, 31, v17
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[17:18], 3, v[17:18]
	v_add_co_u32 v17, vcc_lo, s4, v17
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v18, vcc_lo, s5, v18, vcc_lo
	global_load_b64 v[17:18], v[17:18], off
	global_load_b64 v[19:20], v[1:2], off
	v_add_co_u32 v3, vcc_lo, 0x100, v3
	v_add_co_ci_u32_e32 v4, vcc_lo, 0, v4, vcc_lo
	v_add_co_u32 v5, vcc_lo, 0x100, v5
	v_add_co_ci_u32_e32 v6, vcc_lo, 0, v6, vcc_lo
	v_add_co_u32 v1, vcc_lo, 0x100, v1
	v_add_co_ci_u32_e32 v2, vcc_lo, 0, v2, vcc_lo
	v_cmp_le_i32_e32 vcc_lo, s8, v0
	s_or_b32 s1, vcc_lo, s1
	s_waitcnt vmcnt(3)
	v_add_f64 v[11:12], v[11:12], v[13:14]
	s_waitcnt vmcnt(2)
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_add_f64 v[11:12], v[11:12], v[15:16]
	s_waitcnt vmcnt(1)
	v_add_f64 v[11:12], v[11:12], v[17:18]
	s_waitcnt vmcnt(0)
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[11:12], v[19:20], -4.0, v[11:12]
	v_fma_f64 v[11:12], s[2:3], v[11:12], v[19:20]
	global_store_b64 v[7:8], v[11:12], off
	v_add_co_u32 v7, s0, 0x100, v7
	s_delay_alu instid0(VALU_DEP_1)
	v_add_co_ci_u32_e64 v8, s0, 0, v8, s0
	s_and_not1_b32 exec_lo, exec_lo, s1
	s_cbranch_execnz .LBB0_3
.LBB0_4:                                ; %.loopexit
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z16diffusion_globalPdS_
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 272
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 1
		.amdhsa_next_free_vgpr 21
		.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	_Z16diffusion_globalPdS_, .Lfunc_end0-_Z16diffusion_globalPdS_
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 944
; NumSgprs: 18
; NumVgprs: 21
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 2
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 21
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 1
	.text
	.protected	_Z16diffusion_sharedPdS_ ; -- Begin function _Z16diffusion_sharedPdS_
	.globl	_Z16diffusion_sharedPdS_
	.p2align	8
	.type	_Z16diffusion_sharedPdS_,@function
_Z16diffusion_sharedPdS_:               ; @_Z16diffusion_sharedPdS_
; %bb.0:
	s_load_b32 s4, s[0:1], 0x1c
	s_getpc_b64 s[2:3]
	s_add_u32 s2, s2, n@rel32@lo+4
	s_addc_u32 s3, s3, n@rel32@hi+12
	v_and_b32_e32 v1, 0x3ff, v0
	s_load_b32 s10, s[2:3], 0x0
	v_bfe_u32 v6, v0, 10, 10
	s_waitcnt lgkmcnt(0)
	s_and_b32 s2, s4, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[2:3], null, s15, s2, v[1:2]
	s_mov_b32 s2, exec_lo
	v_max_i32_e32 v0, v2, v6
	s_delay_alu instid0(VALU_DEP_1)
	v_cmpx_gt_i32_e64 s10, v0
	s_cbranch_execz .LBB1_13
; %bb.1:                                ; %.lr.ph
	s_ashr_i32 s2, s10, 31
	v_lshlrev_b32_e32 v4, 3, v6
	s_add_i32 s3, s10, s2
	s_add_i32 s12, s10, -1
	s_xor_b32 s11, s3, s2
	v_cmp_eq_u32_e64 s2, 0, v1
	v_cvt_f32_u32_e32 v0, s11
	v_add_nc_u32_e32 v3, 0x2318, v4
	v_add_nc_u32_e32 v5, 8, v4
	s_sub_i32 s3, 0, s11
	v_mul_lo_u32 v9, v2, s10
	v_rcp_iflag_f32_e32 v0, v0
	s_load_b128 s[4:7], s[0:1], 0x0
	v_cndmask_b32_e64 v7, v3, v5, s2
	v_cndmask_b32_e64 v3, 1, s12, s2
	v_add_nc_u32_e32 v11, 1, v1
	s_getpc_b64 s[8:9]
	s_add_u32 s8, s8, theta@rel32@lo+4
	s_addc_u32 s9, s9, theta@rel32@hi+12
	v_cmp_eq_u32_e64 s0, 31, v6
	s_load_b64 s[8:9], s[8:9], 0x0
	v_add_nc_u32_e32 v3, v3, v2
	v_mul_u32_u24_e32 v10, 34, v11
	v_mul_f32_e32 v0, 0x4f7ffffe, v0
	v_cmp_eq_u32_e64 s1, 32, v11
	v_mad_u32_u24 v11, v11, 34, 33
	v_ashrrev_i32_e32 v15, 31, v3
	v_add_lshl_u32 v12, v10, v6, 3
	v_cvt_u32_f32_e32 v0, v0
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_nc_u32_e32 v3, v3, v15
	v_mul_lo_u32 v8, s3, v0
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_xor_b32_e32 v3, v3, v15
	v_mul_hi_u32 v8, v0, v8
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_nc_u32_e32 v8, v0, v8
	v_mul_hi_u32 v0, v3, v8
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_lo_u32 v0, v0, s11
	v_sub_nc_u32_e32 v0, v3, v0
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_subrev_nc_u32_e32 v3, s11, v0
	v_cmp_le_u32_e32 vcc_lo, s11, v0
	v_cndmask_b32_e32 v2, v0, v3, vcc_lo
	v_mul_u32_u24_e32 v3, 34, v1
	v_add_nc_u32_e32 v0, v6, v9
	v_cmp_ne_u32_e32 vcc_lo, 0, v6
	s_delay_alu instid0(VALU_DEP_4) | instskip(SKIP_2) | instid1(VALU_DEP_2)
	v_subrev_nc_u32_e32 v1, s11, v2
	v_cmp_le_u32_e64 s3, s11, v2
	v_lshlrev_b32_e32 v14, 3, v3
	v_cndmask_b32_e64 v2, v2, v1, s3
	v_ashrrev_i32_e32 v1, 31, v0
	s_delay_alu instid0(VALU_DEP_3) | instskip(SKIP_1) | instid1(VALU_DEP_4)
	v_add_nc_u32_e32 v13, v5, v14
	v_add_nc_u32_e32 v14, v4, v14
	v_xor_b32_e32 v16, v2, v15
	s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_lshlrev_b64 v[2:3], 3, v[0:1]
	v_sub_nc_u32_e32 v4, v16, v15
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_co_u32 v0, s3, s6, v2
	v_add_co_ci_u32_e64 v1, s3, s7, v3, s3
	s_delay_alu instid0(VALU_DEP_3) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_mul_lo_u32 v15, v4, s10
	v_add_co_u32 v2, s3, s4, v2
	v_add_co_ci_u32_e64 v3, s3, s5, v3, s3
	s_mov_b32 s3, 0
	s_or_b32 s6, s2, s1
.LBB1_2:                                ; =>This Inner Loop Header: Depth=1
	global_load_b64 v[4:5], v[2:3], off
	s_waitcnt vmcnt(0)
	ds_store_b64 v12, v[4:5] offset:8
	s_and_saveexec_b32 s2, s6
	s_cbranch_execz .LBB1_4
; %bb.3:                                ; %.sink.split
                                        ;   in Loop: Header=BB1_2 Depth=1
	v_add_nc_u32_e32 v16, v15, v6
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v17, 31, v16
	v_lshlrev_b64 v[16:17], 3, v[16:17]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_co_u32 v16, s1, s4, v16
	v_add_co_ci_u32_e64 v17, s1, s5, v17, s1
	global_load_b64 v[16:17], v[16:17], off
	s_waitcnt vmcnt(0)
	ds_store_b64 v7, v[16:17]
.LBB1_4:                                ;   in Loop: Header=BB1_2 Depth=1
	s_or_b32 exec_lo, exec_lo, s2
	s_mov_b32 s1, 0
                                        ; implicit-def: $vgpr16
                                        ; implicit-def: $vgpr17
	s_and_saveexec_b32 s2, vcc_lo
	s_delay_alu instid0(SALU_CYCLE_1)
	s_xor_b32 s2, exec_lo, s2
	s_cbranch_execz .LBB1_8
; %bb.5:                                ;   in Loop: Header=BB1_2 Depth=1
                                        ; implicit-def: $vgpr17
	s_and_saveexec_b32 s7, s0
	s_delay_alu instid0(SALU_CYCLE_1)
	s_xor_b32 s7, exec_lo, s7
; %bb.6:                                ;   in Loop: Header=BB1_2 Depth=1
	s_mov_b32 s1, exec_lo
	v_add_nc_u32_e32 v17, 1, v6
; %bb.7:                                ; %Flow77
                                        ;   in Loop: Header=BB1_2 Depth=1
	s_or_b32 exec_lo, exec_lo, s7
	v_mov_b32_e32 v16, v11
	s_and_b32 s1, s1, exec_lo
.LBB1_8:                                ; %Flow
                                        ;   in Loop: Header=BB1_2 Depth=1
	s_and_not1_saveexec_b32 s2, s2
; %bb.9:                                ;   in Loop: Header=BB1_2 Depth=1
	v_dual_mov_b32 v16, v10 :: v_dual_add_nc_u32 v17, s12, v6
	s_or_b32 s1, s1, exec_lo
; %bb.10:                               ; %Flow78
                                        ;   in Loop: Header=BB1_2 Depth=1
	s_or_b32 exec_lo, exec_lo, s2
	s_and_saveexec_b32 s2, s1
	s_cbranch_execz .LBB1_12
; %bb.11:                               ; %.sink.split56
                                        ;   in Loop: Header=BB1_2 Depth=1
	v_ashrrev_i32_e32 v18, 31, v17
	v_lshlrev_b32_e32 v16, 3, v16
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_nc_u32_e32 v17, v17, v18
	v_xor_b32_e32 v17, v17, v18
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_hi_u32 v19, v17, v8
	v_mul_lo_u32 v19, v19, s11
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_sub_nc_u32_e32 v17, v17, v19
	v_subrev_nc_u32_e32 v19, s11, v17
	v_cmp_le_u32_e64 s1, s11, v17
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cndmask_b32_e64 v17, v17, v19, s1
	v_subrev_nc_u32_e32 v19, s11, v17
	v_cmp_le_u32_e64 s1, s11, v17
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cndmask_b32_e64 v17, v17, v19, s1
	v_xor_b32_e32 v17, v17, v18
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_sub_nc_u32_e32 v17, v17, v18
	v_add_nc_u32_e32 v17, v17, v9
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v18, 31, v17
	v_lshlrev_b64 v[17:18], 3, v[17:18]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_co_u32 v17, s1, s4, v17
	v_add_co_ci_u32_e64 v18, s1, s5, v18, s1
	global_load_b64 v[17:18], v[17:18], off
	s_waitcnt vmcnt(0)
	ds_store_b64 v16, v[17:18]
.LBB1_12:                               ;   in Loop: Header=BB1_2 Depth=1
	s_or_b32 exec_lo, exec_lo, s2
	s_waitcnt lgkmcnt(0)
	s_waitcnt_vscnt null, 0x0
	s_barrier
	buffer_gl0_inv
	ds_load_b64 v[16:17], v13 offset:544
	ds_load_b64 v[18:19], v14 offset:8
	v_add_nc_u32_e32 v6, 32, v6
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cmp_le_i32_e64 s1, s10, v6
	s_or_b32 s3, s1, s3
	s_waitcnt lgkmcnt(0)
	v_add_f64 v[20:21], v[16:17], v[18:19]
	ds_load_2addr_b64 v[16:19], v12 offset1:2
	s_waitcnt lgkmcnt(0)
	v_add_f64 v[18:19], v[20:21], v[18:19]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[16:17], v[18:19], v[16:17]
	v_fma_f64 v[16:17], v[4:5], -4.0, v[16:17]
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	v_fma_f64 v[4:5], s[8:9], v[16:17], v[4:5]
	global_store_b64 v[0:1], v[4:5], off
	v_add_co_u32 v0, s2, 0x100, v0
	v_add_co_ci_u32_e64 v1, s2, 0, v1, s2
	v_add_co_u32 v2, s2, 0x100, v2
	s_delay_alu instid0(VALU_DEP_1)
	v_add_co_ci_u32_e64 v3, s2, 0, v3, s2
	s_and_not1_b32 exec_lo, exec_lo, s3
	s_cbranch_execnz .LBB1_2
.LBB1_13:                               ; %.loopexit
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z16diffusion_sharedPdS_
		.amdhsa_group_segment_fixed_size 9248
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 272
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 1
		.amdhsa_next_free_vgpr 22
		.amdhsa_next_free_sgpr 16
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end1:
	.size	_Z16diffusion_sharedPdS_, .Lfunc_end1-_Z16diffusion_sharedPdS_
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 1024
; NumSgprs: 18
; NumVgprs: 22
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 9248 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 2
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 22
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 1
	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.protected	n                       ; @n
	.type	n,@object
	.section	.bss,"aw",@nobits
	.globl	n
	.p2align	2, 0x0
n:
	.long	0                               ; 0x0
	.size	n, 4

	.protected	theta                   ; @theta
	.type	theta,@object
	.globl	theta
	.p2align	3, 0x0
theta:
	.quad	0x0000000000000000              ; double 0
	.size	theta, 8

	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.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 n
	.addrsig_sym theta
	.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:           _Z16diffusion_globalPdS_
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z16diffusion_globalPdS_.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     21
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .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: 9248
    .kernarg_segment_align: 8
    .kernarg_segment_size: 272
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z16diffusion_sharedPdS_
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z16diffusion_sharedPdS_.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     22
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
