#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <sys/time.h>
#include<unistd.h>

#define DEVICE_ID 0

/*  constants for the number of threads and the integration domain  */
/*  number of threads in a block, 2^n  */
#define NT 1024
/*  number of blocks in a grid, 2^n  */
#define NB 16
/*  length of the target domain  */
#define L 10.0
/*  number of division for the discretization of the target domain, 2^n  */
#define N 1024

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

//host functions-----------------------------------------------
double calculate_reference(int n, double l) {
	int i;
	int j;
	double d = l / (double)n;
	double x;
	double y;
	double sum = 0.0;
	for(i = 0; i < n; i += 1) {
		x = d * ((double)i - (double)n / 2.0);
		for(j = 0; j < n; j += 1) {
			y = d * ((double)j - (double)n / 2.0);
			sum += exp(- x * x - y * y);
		}
	}
	return sum * d * d;
}
//device functions---------------------------------------------
__global__ void calculate_each_point(double *device_double) {
	int global_id = threadIdx.x + blockIdx.x * blockDim.x;
	int i;
	double x;
	double y;	
	for(i = global_id; i < n * n; i += NT * NB) {
		x = (l / (double)n) * ((double)(i % n) - (double)n / 2.0);
		y = (l / (double)n) * ((double)(i / n) - (double)n / 2.0);
		device_double[i] = exp(- x * x - y * y);
	}
}
//-------------------------------------------------------------
__global__ void reduce_array_global_memory(double *device_double, double *device_double_reduced, int dim_array) {
	int i;
	int global_id = threadIdx.x + blockIdx.x * blockDim.x;

	for(i = global_id; i < dim_array; i += NT * NB) {
		if(i < dim_array / 2) {
			device_double_reduced[i] = device_double[i] + device_double[i + dim_array / 2];
		}	
	}
}
//-------------------------------------------------------------
__global__ void reduce_array_shared_memory(double *device_double, double *device_double_reduced, int dim_array) {
	__shared__ double device_shared_double[NT];
	int global_id = threadIdx.x + blockIdx.x * blockDim.x;
	int block_id = blockIdx.x;
	int local_id = threadIdx.x;
	int i;
	int j;
	for(i = global_id; i < dim_array; i += NB * NT) {
		device_shared_double[local_id] = device_double[i];
		__syncthreads();

		for(j = NT / 2; j > 0; j = j / 2) {
			if((local_id < j) && (local_id + j < dim_array)) {
				device_shared_double[local_id] += device_shared_double[local_id + j]; 
			}
		__syncthreads();
		}

		if(local_id == 0) {
			device_double_reduced[block_id] = device_shared_double[0];
		}
		__syncthreads();
		block_id += NB;
	}
}
//main---------------------------------------------------------
int main(void) {
	int host_n = N;
	double *device_double[2];
	double host_l = L;
	double host_sum;
	double *host_double;//DBG
	int i;
	int i_temp;
	int j;
	int k;

//initialize---------------------------------------------------
	cudaSetDevice(DEVICE_ID);
	cudaMemcpyToSymbol(n, &host_n, sizeof(double), 0, cudaMemcpyHostToDevice);
	cudaMemcpyToSymbol(l, &host_l, sizeof(double), 0, cudaMemcpyHostToDevice);
	cudaMalloc((void **)&device_double[0], N * N * sizeof(double));
	cudaMalloc((void **)&device_double[1], N * N * sizeof(double));
	host_double = (double *)calloc(N * N, sizeof(double));
//tasks--------------------------------------------------------
	//calculate on gpu w/o shared memory-------------------
	calculate_each_point<<<NB, NT>>>(device_double[0]);
	cudaDeviceSynchronize();
	i = 0;
	j = 1;
	for(k = N * N; k > 1; k = k / 2 + k % 2) { 	
		reduce_array_global_memory<<<NB, NT>>>(device_double[i], device_double[j], k);
		cudaDeviceSynchronize();
		i_temp = i;
		i = j;
		j = i_temp;
	}
	cudaMemcpy(&host_sum, device_double[i], sizeof(double), cudaMemcpyDeviceToHost);
	host_sum = host_sum * host_l * host_l / (double)host_n / (double)host_n;
	printf("calc on gpu w/o shared mem:%f\n", host_sum);
	//calculate on gpu with shared memory------------------
	calculate_each_point<<<NB, NT>>>(device_double[0]);
	cudaDeviceSynchronize();
	i = 0;
	j = 1;
	for(k = N * N; k > 1; k = k / NT) {
		reduce_array_shared_memory<<<NB, NT>>>(device_double[i], device_double[j], k);
		cudaDeviceSynchronize();
		i_temp = i;
		i = j;
		j = i_temp;
	}
	cudaMemcpy(&host_sum, device_double[i], sizeof(double), cudaMemcpyDeviceToHost);
	host_sum = host_sum * host_l * host_l / (double)host_n / (double)host_n;
	printf("calc on gpu with shared mem:%f\n", host_sum);

	//calculate on cpu-------------------------------------
	host_sum = calculate_reference(host_n, host_l);
	printf("all done on cpu:%f\n", host_sum);
//finalize-----------------------------------------------------
	cudaFree(device_double[0]);
	cudaFree(device_double[1]);
	cudaDeviceReset();
	free(host_double);

//work in host-------------------------------------------------

	return 0;
}



	.file	"tmpxft_003a92d0_00000000-6_reduction_me.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2044:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2044:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z19calculate_referenceid
	.type	_Z19calculate_referenceid, @function
_Z19calculate_referenceid:
.LFB2040:
	.cfi_startproc
	endbr64
	cvtsi2sdl	%edi, %xmm5
	movaps	%xmm0, %xmm3
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	xorps	%xmm2, %xmm2
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	xorl	%ebp, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	movl	%edi, %ebx
	divsd	%xmm5, %xmm3
	subq	$56, %rsp
	.cfi_def_cfa_offset 96
.L3:
	cmpl	%ebx, %ebp
	jge	.L9
	movsd	.LC1(%rip), %xmm6
	cvtsi2sdl	%ebp, %xmm0
	movslq	%ebx, %r13
	xorl	%r12d, %r12d
	mulsd	%xmm5, %xmm6
	subsd	%xmm6, %xmm0
	mulsd	%xmm3, %xmm0
	movaps	%xmm0, %xmm1
	xorps	.LC2(%rip), %xmm1
	movaps	%xmm1, %xmm4
	mulsd	%xmm0, %xmm4
.L4:
	cvtsi2sdl	%r12d, %xmm1
	movaps	%xmm4, %xmm0
	incq	%r12
	movsd	%xmm2, 40(%rsp)
	movsd	%xmm5, 32(%rsp)
	movsd	%xmm6, 24(%rsp)
	movsd	%xmm3, 16(%rsp)
	subsd	%xmm6, %xmm1
	movsd	%xmm4, 8(%rsp)
	mulsd	%xmm3, %xmm1
	mulsd	%xmm1, %xmm1
	subsd	%xmm1, %xmm0
	call	exp@PLT
	movsd	40(%rsp), %xmm2
	cmpq	%r12, %r13
	movsd	8(%rsp), %xmm4
	movsd	16(%rsp), %xmm3
	movsd	24(%rsp), %xmm6
	addsd	%xmm0, %xmm2
	movsd	32(%rsp), %xmm5
	jne	.L4
	incl	%ebp
	jmp	.L3
.L9:
	mulsd	%xmm3, %xmm2
	addq	$56, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	mulsd	%xmm3, %xmm2
	movaps	%xmm2, %xmm0
	ret
	.cfi_endproc
.LFE2040:
	.size	_Z19calculate_referenceid, .-_Z19calculate_referenceid
	.globl	_Z40__device_stub__Z20calculate_each_pointPdPd
	.type	_Z40__device_stub__Z20calculate_each_pointPdPd, @function
_Z40__device_stub__Z20calculate_each_pointPdPd:
.LFB2066:
	.cfi_startproc
	endbr64
	subq	$104, %rsp
	.cfi_def_cfa_offset 112
	movq	%rdi, 8(%rsp)
	leaq	24(%rsp), %rcx
	leaq	16(%rsp), %rdx
	leaq	44(%rsp), %rsi
	leaq	32(%rsp), %rdi
	movq	%fs:40, %rax
	movq	%rax, 88(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rax
	movl	$1, 40(%rsp)
	movq	%rax, 80(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 32(%rsp)
	movq	%rax, 44(%rsp)
	movl	$1, 52(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L10
	pushq	24(%rsp)
	.cfi_def_cfa_offset 120
	leaq	_Z20calculate_each_pointPd(%rip), %rdi
	pushq	24(%rsp)
	.cfi_def_cfa_offset 128
	movq	60(%rsp), %rcx
	movl	68(%rsp), %r8d
	movq	48(%rsp), %rsi
	movl	56(%rsp), %edx
	leaq	96(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 120
	popq	%rdx
	.cfi_def_cfa_offset 112
.L10:
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	je	.L12
	call	__stack_chk_fail@PLT
.L12:
	addq	$104, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2066:
	.size	_Z40__device_stub__Z20calculate_each_pointPdPd, .-_Z40__device_stub__Z20calculate_each_pointPdPd
	.globl	_Z20calculate_each_pointPd
	.type	_Z20calculate_each_pointPd, @function
_Z20calculate_each_pointPd:
.LFB2067:
	.cfi_startproc
	endbr64
	jmp	_Z40__device_stub__Z20calculate_each_pointPdPd
	.cfi_endproc
.LFE2067:
	.size	_Z20calculate_each_pointPd, .-_Z20calculate_each_pointPd
	.globl	_Z49__device_stub__Z26reduce_array_global_memoryPdS_iPdS_i
	.type	_Z49__device_stub__Z26reduce_array_global_memoryPdS_iPdS_i, @function
_Z49__device_stub__Z26reduce_array_global_memoryPdS_iPdS_i:
.LFB2068:
	.cfi_startproc
	endbr64
	subq	$136, %rsp
	.cfi_def_cfa_offset 144
	movq	%rdi, 24(%rsp)
	leaq	40(%rsp), %rcx
	leaq	48(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	60(%rsp), %rsi
	movl	%edx, 12(%rsp)
	leaq	32(%rsp), %rdx
	movq	%fs:40, %rax
	movq	%rax, 120(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 56(%rsp)
	movq	%rax, 96(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 104(%rsp)
	leaq	12(%rsp), %rax
	movq	%rax, 112(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 48(%rsp)
	movq	%rax, 60(%rsp)
	movl	$1, 68(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L15
	pushq	40(%rsp)
	.cfi_def_cfa_offset 152
	leaq	_Z26reduce_array_global_memoryPdS_i(%rip), %rdi
	pushq	40(%rsp)
	.cfi_def_cfa_offset 160
	movq	76(%rsp), %rcx
	movl	84(%rsp), %r8d
	movq	64(%rsp), %rsi
	movl	72(%rsp), %edx
	leaq	112(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 152
	popq	%rdx
	.cfi_def_cfa_offset 144
.L15:
	movq	120(%rsp), %rax
	subq	%fs:40, %rax
	je	.L17
	call	__stack_chk_fail@PLT
.L17:
	addq	$136, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2068:
	.size	_Z49__device_stub__Z26reduce_array_global_memoryPdS_iPdS_i, .-_Z49__device_stub__Z26reduce_array_global_memoryPdS_iPdS_i
	.globl	_Z26reduce_array_global_memoryPdS_i
	.type	_Z26reduce_array_global_memoryPdS_i, @function
_Z26reduce_array_global_memoryPdS_i:
.LFB2069:
	.cfi_startproc
	endbr64
	jmp	_Z49__device_stub__Z26reduce_array_global_memoryPdS_iPdS_i
	.cfi_endproc
.LFE2069:
	.size	_Z26reduce_array_global_memoryPdS_i, .-_Z26reduce_array_global_memoryPdS_i
	.globl	_Z49__device_stub__Z26reduce_array_shared_memoryPdS_iPdS_i
	.type	_Z49__device_stub__Z26reduce_array_shared_memoryPdS_iPdS_i, @function
_Z49__device_stub__Z26reduce_array_shared_memoryPdS_iPdS_i:
.LFB2070:
	.cfi_startproc
	endbr64
	subq	$136, %rsp
	.cfi_def_cfa_offset 144
	movq	%rdi, 24(%rsp)
	leaq	40(%rsp), %rcx
	leaq	48(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	60(%rsp), %rsi
	movl	%edx, 12(%rsp)
	leaq	32(%rsp), %rdx
	movq	%fs:40, %rax
	movq	%rax, 120(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 56(%rsp)
	movq	%rax, 96(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 104(%rsp)
	leaq	12(%rsp), %rax
	movq	%rax, 112(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 48(%rsp)
	movq	%rax, 60(%rsp)
	movl	$1, 68(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L20
	pushq	40(%rsp)
	.cfi_def_cfa_offset 152
	leaq	_Z26reduce_array_shared_memoryPdS_i(%rip), %rdi
	pushq	40(%rsp)
	.cfi_def_cfa_offset 160
	movq	76(%rsp), %rcx
	movl	84(%rsp), %r8d
	movq	64(%rsp), %rsi
	movl	72(%rsp), %edx
	leaq	112(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 152
	popq	%rdx
	.cfi_def_cfa_offset 144
.L20:
	movq	120(%rsp), %rax
	subq	%fs:40, %rax
	je	.L22
	call	__stack_chk_fail@PLT
.L22:
	addq	$136, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2070:
	.size	_Z49__device_stub__Z26reduce_array_shared_memoryPdS_iPdS_i, .-_Z49__device_stub__Z26reduce_array_shared_memoryPdS_iPdS_i
	.globl	_Z26reduce_array_shared_memoryPdS_i
	.type	_Z26reduce_array_shared_memoryPdS_i, @function
_Z26reduce_array_shared_memoryPdS_i:
.LFB2071:
	.cfi_startproc
	endbr64
	jmp	_Z49__device_stub__Z26reduce_array_shared_memoryPdS_iPdS_i
	.cfi_endproc
.LFE2071:
	.size	_Z26reduce_array_shared_memoryPdS_i, .-_Z26reduce_array_shared_memoryPdS_i
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC4:
	.string	"calc on gpu w/o shared mem:%f\n"
.LC5:
	.string	"calc on gpu with shared mem:%f\n"
.LC6:
	.string	"all done on cpu:%f\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2041:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	xorl	%edi, %edi
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$88, %rsp
	.cfi_def_cfa_offset 144
	movq	%fs:40, %rax
	movq	%rax, 72(%rsp)
	xorl	%eax, %eax
	movq	.LC3(%rip), %rax
	movl	$1024, 12(%rsp)
	movq	%rax, 16(%rsp)
	call	cudaSetDevice@PLT
	xorl	%ecx, %ecx
	leaq	12(%rsp), %rsi
	movl	$1, %r8d
	movl	$8, %edx
	leaq	_ZL1n(%rip), %rdi
	call	cudaMemcpyToSymbol@PLT
	xorl	%ecx, %ecx
	movl	$1, %r8d
	movl	$8, %edx
	leaq	16(%rsp), %rsi
	leaq	_ZL1l(%rip), %rdi
	call	cudaMemcpyToSymbol@PLT
	leaq	56(%rsp), %rdi
	movl	$8388608, %esi
	call	cudaMalloc@PLT
	leaq	64(%rsp), %rdi
	movl	$8388608, %esi
	call	cudaMalloc@PLT
	movl	$4194305, %edx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	$268435457, %edi
	salq	$10, %rdx
	movl	$1, %ecx
	movl	$1, %esi
	salq	$4, %rdi
	movq	%rdx, 44(%rsp)
	movl	$1, 52(%rsp)
	movq	%rdi, 32(%rsp)
	movl	$1, 40(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L26
	movq	56(%rsp), %rdi
	call	_Z40__device_stub__Z20calculate_each_pointPdPd
.L26:
	call	cudaDeviceSynchronize@PLT
	movl	$1048576, %ebx
	movl	$1, %ebp
	xorl	%r12d, %r12d
	movabsq	$4294968320, %r13
.L28:
	movl	$268435457, %edi
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movq	%r13, %rdx
	salq	$4, %rdi
	movl	$1, %ecx
	movl	$1, %esi
	movq	%r13, 44(%rsp)
	movl	$1, 52(%rsp)
	movq	%rdi, 32(%rsp)
	movl	$1, 40(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L27
	movslq	%ebp, %rax
	movl	%ebx, %edx
	movq	56(%rsp,%rax,8), %rsi
	movslq	%r12d, %rax
	movq	56(%rsp,%rax,8), %rdi
	call	_Z49__device_stub__Z26reduce_array_global_memoryPdS_iPdS_i
.L27:
	call	cudaDeviceSynchronize@PLT
	movl	%ebx, %eax
	andl	$1, %ebx
	sarl	%eax
	addl	%eax, %ebx
	cmpl	$1, %ebx
	je	.L36
	movl	%r12d, %eax
	movl	%ebp, %r12d
	movslq	%eax, %rbp
	jmp	.L28
.L36:
	movq	56(%rsp,%rbp,8), %rsi
	leaq	24(%rsp), %rbp
	movl	$2, %ecx
	movl	$8, %edx
	movq	%rbp, %rdi
	call	cudaMemcpy@PLT
	movsd	16(%rsp), %xmm2
	movb	$1, %al
	movsd	24(%rsp), %xmm0
	cvtsi2sdl	12(%rsp), %xmm1
	leaq	.LC4(%rip), %rsi
	movl	$2, %edi
	mulsd	%xmm2, %xmm0
	mulsd	%xmm2, %xmm0
	divsd	%xmm1, %xmm0
	divsd	%xmm1, %xmm0
	movsd	%xmm0, 24(%rsp)
	call	__printf_chk@PLT
	movl	$4194305, %edx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	$268435457, %edi
	salq	$10, %rdx
	movl	$1, %ecx
	movl	$1, %esi
	salq	$4, %rdi
	movq	%rdx, 44(%rsp)
	movl	$1, 52(%rsp)
	movq	%rdi, 32(%rsp)
	movl	$1, 40(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L29
	movq	56(%rsp), %rdi
	call	_Z40__device_stub__Z20calculate_each_pointPdPd
.L29:
	call	cudaDeviceSynchronize@PLT
	movl	$2, %r14d
	movl	$1048576, %r12d
	xorl	%r13d, %r13d
	movabsq	$4294968320, %r15
.L31:
	movl	$268435457, %edi
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movq	%r15, %rdx
	salq	$4, %rdi
	movl	$1, %ecx
	movl	$1, %esi
	movq	%r15, 44(%rsp)
	movl	$1, 52(%rsp)
	movq	%rdi, 32(%rsp)
	movl	$1, 40(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L30
	movslq	%ebx, %rax
	movl	%r12d, %edx
	movq	56(%rsp,%rax,8), %rsi
	movslq	%r13d, %rax
	movq	56(%rsp,%rax,8), %rdi
	call	_Z49__device_stub__Z26reduce_array_shared_memoryPdS_iPdS_i
.L30:
	call	cudaDeviceSynchronize@PLT
	sarl	$10, %r12d
	decl	%r14d
	je	.L37
	movl	$1, %r14d
	xchgl	%ebx, %r13d
	jmp	.L31
.L37:
	movslq	%ebx, %rbx
	movl	$2, %ecx
	movl	$8, %edx
	movq	%rbp, %rdi
	movq	56(%rsp,%rbx,8), %rsi
	call	cudaMemcpy@PLT
	movsd	16(%rsp), %xmm2
	movb	$1, %al
	movsd	24(%rsp), %xmm0
	cvtsi2sdl	12(%rsp), %xmm1
	leaq	.LC5(%rip), %rsi
	movl	$2, %edi
	mulsd	%xmm2, %xmm0
	mulsd	%xmm2, %xmm0
	divsd	%xmm1, %xmm0
	divsd	%xmm1, %xmm0
	movsd	%xmm0, 24(%rsp)
	call	__printf_chk@PLT
	movl	12(%rsp), %edi
	movsd	16(%rsp), %xmm0
	call	_Z19calculate_referenceid
	leaq	.LC6(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	movsd	%xmm0, 24(%rsp)
	call	__printf_chk@PLT
	movq	56(%rsp), %rdi
	call	cudaFree@PLT
	movq	64(%rsp), %rdi
	call	cudaFree@PLT
	call	cudaDeviceReset@PLT
	movq	72(%rsp), %rax
	subq	%fs:40, %rax
	je	.L32
	call	__stack_chk_fail@PLT
.L32:
	addq	$88, %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
.LFE2041:
	.size	main, .-main
	.section	.rodata.str1.1
.LC7:
	.string	"_Z26reduce_array_shared_memoryPdS_i"
.LC8:
	.string	"_Z26reduce_array_global_memoryPdS_i"
.LC9:
	.string	"_Z20calculate_each_pointPd"
.LC10:
	.string	"n"
.LC11:
	.string	"l"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2073:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	pushq	$0
	.cfi_def_cfa_offset 24
	xorl	%r9d, %r9d
	orl	$-1, %r8d
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC7(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z26reduce_array_shared_memoryPdS_i(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 48
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r9d, %r9d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC8(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z26reduce_array_global_memoryPdS_i(%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	%r9d, %r9d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC9(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z20calculate_each_pointPd(%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	.LC10(%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	.LC11(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movq	%rdx, %rcx
	movl	$8, %r9d
	leaq	_ZL1l(%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
.LFE2073:
	.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	_ZL1l
	.comm	_ZL1l,8,8
	.local	_ZL1n
	.comm	_ZL1n,4,4
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC1:
	.long	0
	.long	1071644672
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC2:
	.long	0
	.long	-2147483648
	.long	0
	.long	0
	.section	.rodata.cst8
	.align 8
.LC3:
	.long	0
	.long	1076101120
	.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 <math.h>
#include <sys/time.h>
#include<unistd.h>

#define DEVICE_ID 0

/*  constants for the number of threads and the integration domain  */
/*  number of threads in a block, 2^n  */
#define NT 1024
/*  number of blocks in a grid, 2^n  */
#define NB 16
/*  length of the target domain  */
#define L 10.0
/*  number of division for the discretization of the target domain, 2^n  */
#define N 1024

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

//host functions-----------------------------------------------
double calculate_reference(int n, double l) {
	int i;
	int j;
	double d = l / (double)n;
	double x;
	double y;
	double sum = 0.0;
	for(i = 0; i < n; i += 1) {
		x = d * ((double)i - (double)n / 2.0);
		for(j = 0; j < n; j += 1) {
			y = d * ((double)j - (double)n / 2.0);
			sum += exp(- x * x - y * y);
		}
	}
	return sum * d * d;
}
//device functions---------------------------------------------
__global__ void calculate_each_point(double *device_double) {
	int global_id = threadIdx.x + blockIdx.x * blockDim.x;
	int i;
	double x;
	double y;	
	for(i = global_id; i < n * n; i += NT * NB) {
		x = (l / (double)n) * ((double)(i % n) - (double)n / 2.0);
		y = (l / (double)n) * ((double)(i / n) - (double)n / 2.0);
		device_double[i] = exp(- x * x - y * y);
	}
}
//-------------------------------------------------------------
__global__ void reduce_array_global_memory(double *device_double, double *device_double_reduced, int dim_array) {
	int i;
	int global_id = threadIdx.x + blockIdx.x * blockDim.x;

	for(i = global_id; i < dim_array; i += NT * NB) {
		if(i < dim_array / 2) {
			device_double_reduced[i] = device_double[i] + device_double[i + dim_array / 2];
		}	
	}
}
//-------------------------------------------------------------
__global__ void reduce_array_shared_memory(double *device_double, double *device_double_reduced, int dim_array) {
	__shared__ double device_shared_double[NT];
	int global_id = threadIdx.x + blockIdx.x * blockDim.x;
	int block_id = blockIdx.x;
	int local_id = threadIdx.x;
	int i;
	int j;
	for(i = global_id; i < dim_array; i += NB * NT) {
		device_shared_double[local_id] = device_double[i];
		__syncthreads();

		for(j = NT / 2; j > 0; j = j / 2) {
			if((local_id < j) && (local_id + j < dim_array)) {
				device_shared_double[local_id] += device_shared_double[local_id + j]; 
			}
		__syncthreads();
		}

		if(local_id == 0) {
			device_double_reduced[block_id] = device_shared_double[0];
		}
		__syncthreads();
		block_id += NB;
	}
}
//main---------------------------------------------------------
int main(void) {
	int host_n = N;
	double *device_double[2];
	double host_l = L;
	double host_sum;
	double *host_double;//DBG
	int i;
	int i_temp;
	int j;
	int k;

//initialize---------------------------------------------------
	hipSetDevice(DEVICE_ID);
	hipMemcpyToSymbol(HIP_SYMBOL(n), &host_n, sizeof(double), 0, hipMemcpyHostToDevice);
	hipMemcpyToSymbol(HIP_SYMBOL(l), &host_l, sizeof(double), 0, hipMemcpyHostToDevice);
	hipMalloc((void **)&device_double[0], N * N * sizeof(double));
	hipMalloc((void **)&device_double[1], N * N * sizeof(double));
	host_double = (double *)calloc(N * N, sizeof(double));
//tasks--------------------------------------------------------
	//calculate on gpu w/o shared memory-------------------
	calculate_each_point<<<NB, NT>>>(device_double[0]);
	hipDeviceSynchronize();
	i = 0;
	j = 1;
	for(k = N * N; k > 1; k = k / 2 + k % 2) { 	
		reduce_array_global_memory<<<NB, NT>>>(device_double[i], device_double[j], k);
		hipDeviceSynchronize();
		i_temp = i;
		i = j;
		j = i_temp;
	}
	hipMemcpy(&host_sum, device_double[i], sizeof(double), hipMemcpyDeviceToHost);
	host_sum = host_sum * host_l * host_l / (double)host_n / (double)host_n;
	printf("calc on gpu w/o shared mem:%f\n", host_sum);
	//calculate on gpu with shared memory------------------
	calculate_each_point<<<NB, NT>>>(device_double[0]);
	hipDeviceSynchronize();
	i = 0;
	j = 1;
	for(k = N * N; k > 1; k = k / NT) {
		reduce_array_shared_memory<<<NB, NT>>>(device_double[i], device_double[j], k);
		hipDeviceSynchronize();
		i_temp = i;
		i = j;
		j = i_temp;
	}
	hipMemcpy(&host_sum, device_double[i], sizeof(double), hipMemcpyDeviceToHost);
	host_sum = host_sum * host_l * host_l / (double)host_n / (double)host_n;
	printf("calc on gpu with shared mem:%f\n", host_sum);

	//calculate on cpu-------------------------------------
	host_sum = calculate_reference(host_n, host_l);
	printf("all done on cpu:%f\n", host_sum);
//finalize-----------------------------------------------------
	hipFree(device_double[0]);
	hipFree(device_double[1]);
	hipDeviceReset();
	free(host_double);

//work in host-------------------------------------------------

	return 0;
}



	.text
	.file	"reduction_me.hip"
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z19calculate_referenceid
.LCPI0_0:
	.quad	0x3fe0000000000000              # double 0.5
.LCPI0_2:
	.quad	0x3ff0000000000000              # double 1
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0
.LCPI0_1:
	.quad	0x8000000000000000              # double -0
	.quad	0x8000000000000000              # double -0
	.text
	.globl	_Z19calculate_referenceid
	.type	_Z19calculate_referenceid,@function
_Z19calculate_referenceid:              # @_Z19calculate_referenceid
	.cfi_startproc
# %bb.0:
	movapd	%xmm0, %xmm2
	cvtsi2sd	%edi, %xmm3
	divsd	%xmm3, %xmm2
	testl	%edi, %edi
	jle	.LBB0_1
# %bb.3:                                # %.lr.ph29
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	subq	$64, %rsp
	.cfi_def_cfa_offset 96
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %rbp, -16
	movl	%edi, %ebx
	mulsd	.LCPI0_0(%rip), %xmm3
	xorl	%ebp, %ebp
	xorpd	%xmm1, %xmm1
	xorpd	%xmm0, %xmm0
	movsd	%xmm2, 24(%rsp)                 # 8-byte Spill
	movsd	%xmm3, 16(%rsp)                 # 8-byte Spill
.LBB0_4:                                # %.lr.ph
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB0_5 Depth 2
	movsd	%xmm0, 8(%rsp)                  # 8-byte Spill
	subsd	%xmm3, %xmm0
	mulsd	%xmm2, %xmm0
	movapd	%xmm0, %xmm4
	xorpd	.LCPI0_1(%rip), %xmm4
	mulsd	%xmm0, %xmm4
	movapd	%xmm4, 48(%rsp)                 # 16-byte Spill
	movl	%ebx, %r14d
	xorpd	%xmm0, %xmm0
.LBB0_5:                                #   Parent Loop BB0_4 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movsd	%xmm0, 32(%rsp)                 # 8-byte Spill
	movsd	%xmm1, 40(%rsp)                 # 8-byte Spill
	movapd	%xmm0, %xmm1
	subsd	%xmm3, %xmm1
	mulsd	%xmm2, %xmm1
	mulsd	%xmm1, %xmm1
	movapd	48(%rsp), %xmm0                 # 16-byte Reload
	subsd	%xmm1, %xmm0
	callq	exp
	movsd	.LCPI0_2(%rip), %xmm4           # xmm4 = mem[0],zero
	movsd	40(%rsp), %xmm1                 # 8-byte Reload
                                        # xmm1 = mem[0],zero
	movsd	16(%rsp), %xmm3                 # 8-byte Reload
                                        # xmm3 = mem[0],zero
	movsd	24(%rsp), %xmm2                 # 8-byte Reload
                                        # xmm2 = mem[0],zero
	addsd	%xmm0, %xmm1
	movsd	32(%rsp), %xmm0                 # 8-byte Reload
                                        # xmm0 = mem[0],zero
	addsd	%xmm4, %xmm0
	decl	%r14d
	jne	.LBB0_5
# %bb.6:                                # %._crit_edge
                                        #   in Loop: Header=BB0_4 Depth=1
	movsd	8(%rsp), %xmm0                  # 8-byte Reload
                                        # xmm0 = mem[0],zero
	addsd	%xmm4, %xmm0
	incl	%ebp
	cmpl	%ebx, %ebp
	jne	.LBB0_4
# %bb.7:
	addq	$64, %rsp
	.cfi_def_cfa_offset 32
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	.cfi_restore %rbx
	.cfi_restore %r14
	.cfi_restore %rbp
	jmp	.LBB0_2
.LBB0_1:
	xorpd	%xmm1, %xmm1
.LBB0_2:                                # %._crit_edge30
	mulsd	%xmm2, %xmm1
	mulsd	%xmm2, %xmm1
	movapd	%xmm1, %xmm0
	retq
.Lfunc_end0:
	.size	_Z19calculate_referenceid, .Lfunc_end0-_Z19calculate_referenceid
	.cfi_endproc
                                        # -- End function
	.globl	_Z35__device_stub__calculate_each_pointPd # -- Begin function _Z35__device_stub__calculate_each_pointPd
	.type	_Z35__device_stub__calculate_each_pointPd,@function
_Z35__device_stub__calculate_each_pointPd: # @_Z35__device_stub__calculate_each_pointPd
	.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	$64, %rsp
	.cfi_def_cfa_offset 112
	.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)
	movq	%rsp, %rbx
	movq	%rax, (%rbx)
	leaq	48(%rsp), %r14
	leaq	32(%rsp), %r15
	leaq	16(%rsp), %r12
	leaq	8(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z20calculate_each_pointPd, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$80, %rsp
	.cfi_adjust_cfa_offset -80
	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	_Z35__device_stub__calculate_each_pointPd, .Lfunc_end1-_Z35__device_stub__calculate_each_pointPd
	.cfi_endproc
                                        # -- End function
	.globl	_Z41__device_stub__reduce_array_global_memoryPdS_i # -- Begin function _Z41__device_stub__reduce_array_global_memoryPdS_i
	.type	_Z41__device_stub__reduce_array_global_memoryPdS_i,@function
_Z41__device_stub__reduce_array_global_memoryPdS_i: # @_Z41__device_stub__reduce_array_global_memoryPdS_i
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$112, %rsp
	.cfi_def_cfa_offset 160
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	32(%rsp), %rcx
	movq	%rsi, (%rcx)
	leaq	12(%rsp), %rsi
	movl	%edx, (%rsi)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	movq	%rsi, 16(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	24(%rsp), %r12
	leaq	16(%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	$_Z26reduce_array_global_memoryPdS_i, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$128, %rsp
	.cfi_adjust_cfa_offset -128
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end2:
	.size	_Z41__device_stub__reduce_array_global_memoryPdS_i, .Lfunc_end2-_Z41__device_stub__reduce_array_global_memoryPdS_i
	.cfi_endproc
                                        # -- End function
	.globl	_Z41__device_stub__reduce_array_shared_memoryPdS_i # -- Begin function _Z41__device_stub__reduce_array_shared_memoryPdS_i
	.type	_Z41__device_stub__reduce_array_shared_memoryPdS_i,@function
_Z41__device_stub__reduce_array_shared_memoryPdS_i: # @_Z41__device_stub__reduce_array_shared_memoryPdS_i
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$112, %rsp
	.cfi_def_cfa_offset 160
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	32(%rsp), %rcx
	movq	%rsi, (%rcx)
	leaq	12(%rsp), %rsi
	movl	%edx, (%rsi)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	movq	%rsi, 16(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	24(%rsp), %r12
	leaq	16(%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	$_Z26reduce_array_shared_memoryPdS_i, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$128, %rsp
	.cfi_adjust_cfa_offset -128
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end3:
	.size	_Z41__device_stub__reduce_array_shared_memoryPdS_i, .Lfunc_end3-_Z41__device_stub__reduce_array_shared_memoryPdS_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	$56, %rsp
	.cfi_def_cfa_offset 112
	.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	$4294967312, %rbx               # imm = 0x100000010
	leaq	12(%rsp), %r14
	movl	$1024, (%r14)                   # imm = 0x400
	movabsq	$4621819117588971520, %rax      # imm = 0x4024000000000000
	leaq	40(%rsp), %r15
	movq	%rax, (%r15)
	xorl	%r13d, %r13d
	xorl	%edi, %edi
	callq	hipSetDevice
	movl	$1, %r12d
	movl	$n, %edi
	movl	$8, %edx
	movq	%r14, %rsi
	xorl	%ecx, %ecx
	movl	$1, %r8d
	callq	hipMemcpyToSymbol
	movl	$l, %edi
	movl	$8, %edx
	movq	%r15, %rsi
	xorl	%ecx, %ecx
	movl	$1, %r8d
	callq	hipMemcpyToSymbol
	leaq	16(%rsp), %rdi
	movl	$8388608, %esi                  # imm = 0x800000
	callq	hipMalloc
	leaq	24(%rsp), %rdi
	movl	$8388608, %esi                  # imm = 0x800000
	callq	hipMalloc
	leaq	1008(%rbx), %r14
	movq	%rbx, %rdi
	movl	$1, %esi
	movq	%r14, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB4_2
# %bb.1:
	movq	16(%rsp), %rdi
	callq	_Z35__device_stub__calculate_each_pointPd
.LBB4_2:
	callq	hipDeviceSynchronize
	movl	$1048576, %ebp                  # imm = 0x100000
.LBB4_3:                                # =>This Inner Loop Header: Depth=1
	movl	%r13d, %r15d
	movq	%rbx, %rdi
	movl	$1, %esi
	movq	%r14, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB4_5
# %bb.4:                                #   in Loop: Header=BB4_3 Depth=1
	movl	%r15d, %eax
	movq	16(%rsp,%rax,8), %rdi
	movl	%r12d, %eax
	movq	16(%rsp,%rax,8), %rsi
	movl	%ebp, %edx
	callq	_Z41__device_stub__reduce_array_global_memoryPdS_i
.LBB4_5:                                #   in Loop: Header=BB4_3 Depth=1
	callq	hipDeviceSynchronize
	movl	%ebp, %eax
	shrl	%eax
	andl	$1, %ebp
	addl	%eax, %ebp
	movl	%r12d, %r13d
	movl	%r15d, %r12d
	cmpl	$1, %ebp
	ja	.LBB4_3
# %bb.6:
	movq	16(%rsp), %rsi
	leaq	48(%rsp), %r15
	movl	$8, %edx
	movq	%r15, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	movsd	40(%rsp), %xmm1                 # xmm1 = mem[0],zero
	movsd	(%r15), %xmm0                   # xmm0 = mem[0],zero
	mulsd	%xmm1, %xmm0
	cvtsi2sdl	12(%rsp), %xmm2
	mulsd	%xmm1, %xmm0
	divsd	%xmm2, %xmm0
	divsd	%xmm2, %xmm0
	movsd	%xmm0, (%r15)
	movl	$.L.str, %edi
	movb	$1, %al
	callq	printf
	xorl	%r12d, %r12d
	movl	$1, %r15d
	movq	%rbx, %rdi
	movl	$1, %esi
	movq	%r14, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB4_8
# %bb.7:
	movq	16(%rsp), %rdi
	callq	_Z35__device_stub__calculate_each_pointPd
.LBB4_8:
	callq	hipDeviceSynchronize
	movl	$1048576, %ebp                  # imm = 0x100000
.LBB4_9:                                # =>This Inner Loop Header: Depth=1
	movl	%r12d, %r13d
	movq	%rbx, %rdi
	movl	$1, %esi
	movq	%r14, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB4_11
# %bb.10:                               #   in Loop: Header=BB4_9 Depth=1
	movl	%r13d, %eax
	movq	16(%rsp,%rax,8), %rdi
	movl	%r15d, %eax
	movq	16(%rsp,%rax,8), %rsi
	movl	%ebp, %edx
	callq	_Z41__device_stub__reduce_array_shared_memoryPdS_i
.LBB4_11:                               #   in Loop: Header=BB4_9 Depth=1
	callq	hipDeviceSynchronize
	movl	%ebp, %eax
	shrl	$10, %eax
	movl	%r15d, %r12d
	movl	%r13d, %r15d
	cmpl	$2047, %ebp                     # imm = 0x7FF
	movl	%eax, %ebp
	ja	.LBB4_9
# %bb.12:
	movq	16(%rsp), %rsi
	leaq	48(%rsp), %rbx
	movl	$8, %edx
	movq	%rbx, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	movsd	40(%rsp), %xmm1                 # xmm1 = mem[0],zero
	movsd	(%rbx), %xmm0                   # xmm0 = mem[0],zero
	mulsd	%xmm1, %xmm0
	xorps	%xmm2, %xmm2
	cvtsi2sdl	12(%rsp), %xmm2
	mulsd	%xmm1, %xmm0
	divsd	%xmm2, %xmm0
	divsd	%xmm2, %xmm0
	movsd	%xmm0, (%rbx)
	movl	$.L.str.1, %edi
	movb	$1, %al
	callq	printf
	movl	12(%rsp), %edi
	movsd	40(%rsp), %xmm0                 # xmm0 = mem[0],zero
	callq	_Z19calculate_referenceid
	movsd	%xmm0, (%rbx)
	movl	$.L.str.2, %edi
	movb	$1, %al
	callq	printf
	movq	16(%rsp), %rdi
	callq	hipFree
	movq	24(%rsp), %rdi
	callq	hipFree
	callq	hipDeviceReset
	xorl	%eax, %eax
	addq	$56, %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_end4:
	.size	main, .Lfunc_end4-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	.LBB5_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB5_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z20calculate_each_pointPd, %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	$_Z26reduce_array_global_memoryPdS_i, %esi
	movl	$.L__unnamed_2, %edx
	movl	$.L__unnamed_2, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z26reduce_array_shared_memoryPdS_i, %esi
	movl	$.L__unnamed_3, %edx
	movl	$.L__unnamed_3, %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_4, %edx
	movl	$.L__unnamed_4, %ecx
	movl	$4, %r9d
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	callq	__hipRegisterVar
	movl	$0, 8(%rsp)
	movl	$1, (%rsp)
	movl	$l, %esi
	movl	$.L__unnamed_5, %edx
	movl	$.L__unnamed_5, %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_end5:
	.size	__hip_module_ctor, .Lfunc_end5-__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	.LBB6_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
.LBB6_2:
	retq
.Lfunc_end6:
	.size	__hip_module_dtor, .Lfunc_end6-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	n,@object                       # @n
	.local	n
	.comm	n,4,4
	.type	l,@object                       # @l
	.local	l
	.comm	l,8,8
	.type	_Z20calculate_each_pointPd,@object # @_Z20calculate_each_pointPd
	.section	.rodata,"a",@progbits
	.globl	_Z20calculate_each_pointPd
	.p2align	3, 0x0
_Z20calculate_each_pointPd:
	.quad	_Z35__device_stub__calculate_each_pointPd
	.size	_Z20calculate_each_pointPd, 8

	.type	_Z26reduce_array_global_memoryPdS_i,@object # @_Z26reduce_array_global_memoryPdS_i
	.globl	_Z26reduce_array_global_memoryPdS_i
	.p2align	3, 0x0
_Z26reduce_array_global_memoryPdS_i:
	.quad	_Z41__device_stub__reduce_array_global_memoryPdS_i
	.size	_Z26reduce_array_global_memoryPdS_i, 8

	.type	_Z26reduce_array_shared_memoryPdS_i,@object # @_Z26reduce_array_shared_memoryPdS_i
	.globl	_Z26reduce_array_shared_memoryPdS_i
	.p2align	3, 0x0
_Z26reduce_array_shared_memoryPdS_i:
	.quad	_Z41__device_stub__reduce_array_shared_memoryPdS_i
	.size	_Z26reduce_array_shared_memoryPdS_i, 8

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"calc on gpu w/o shared mem:%f\n"
	.size	.L.str, 31

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"calc on gpu with shared mem:%f\n"
	.size	.L.str.1, 32

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"all done on cpu:%f\n"
	.size	.L.str.2, 20

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z20calculate_each_pointPd"
	.size	.L__unnamed_1, 27

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_Z26reduce_array_global_memoryPdS_i"
	.size	.L__unnamed_2, 36

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

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

	.type	.L__unnamed_5,@object           # @4
.L__unnamed_5:
	.asciz	"l"
	.size	.L__unnamed_5, 2

	.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 _Z35__device_stub__calculate_each_pointPd
	.addrsig_sym _Z41__device_stub__reduce_array_global_memoryPdS_i
	.addrsig_sym _Z41__device_stub__reduce_array_shared_memoryPdS_i
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym n
	.addrsig_sym l
	.addrsig_sym _Z20calculate_each_pointPd
	.addrsig_sym _Z26reduce_array_global_memoryPdS_i
	.addrsig_sym _Z26reduce_array_shared_memoryPdS_i
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z20calculate_each_pointPd ; -- Begin function _Z20calculate_each_pointPd
	.globl	_Z20calculate_each_pointPd
	.p2align	8
	.type	_Z20calculate_each_pointPd,@function
_Z20calculate_each_pointPd:             ; @_Z20calculate_each_pointPd
; %bb.0:
	s_load_b32 s4, s[0:1], 0x14
	s_getpc_b64 s[2:3]
	s_add_u32 s2, s2, n@rel32@lo+4
	s_addc_u32 s3, s3, n@rel32@hi+12
	s_load_b32 s35, s[2:3], 0x0
	s_waitcnt lgkmcnt(0)
	s_and_b32 s2, s4, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s15, s2, v[0:1]
	s_mul_i32 s30, s35, s35
	s_mov_b32 s2, exec_lo
	v_cmpx_gt_i32_e64 s30, v1
	s_cbranch_execz .LBB0_3
; %bb.1:                                ; %.lr.ph
	v_cvt_f64_i32_e32 v[5:6], s35
	s_getpc_b64 s[2:3]
	s_add_u32 s2, s2, l@rel32@lo+4
	s_addc_u32 s3, s3, l@rel32@hi+12
	s_ashr_i32 s31, s35, 31
	s_load_b64 s[2:3], s[2:3], 0x0
	s_add_i32 s4, s35, s31
	s_mov_b32 s6, 0xfefa39ef
	s_xor_b32 s33, s4, s31
	s_mov_b32 s8, 0x3b39803f
	v_cvt_f32_u32_e32 v0, s33
	s_sub_i32 s4, 0, s33
	s_mov_b32 s10, 0xfca7ab0c
	s_mov_b32 s12, 0x6a5dcb37
	s_mov_b32 s14, 0x623fde64
	v_rcp_iflag_f32_e32 v0, v0
	s_mov_b32 s16, 0x7c89e6b0
	s_mov_b32 s18, 0x14761f6e
	s_mov_b32 s20, 0x1852b7b0
	s_mov_b32 s22, 0x11122322
	s_mov_b32 s24, 0x555502a1
	s_mov_b32 s26, 0x55555511
	s_mov_b32 s28, 11
	s_mov_b32 s7, 0xbfe62e42
	s_mov_b32 s9, 0xbc7abc9e
	s_waitcnt_depctr 0xfff
	v_mul_f32_e32 v0, 0x4f7ffffe, v0
	s_mov_b32 s11, 0x3e928af3
	s_mov_b32 s13, 0x3e5ade15
	s_mov_b32 s15, 0x3ec71dee
	s_mov_b32 s17, 0x3efa0199
	v_cvt_u32_f32_e32 v0, v0
	s_mov_b32 s19, 0x3f2a01a0
	s_mov_b32 s21, 0x3f56c16c
	s_mov_b32 s23, 0x3f811111
	s_mov_b32 s25, 0x3fa55555
	s_mov_b32 s27, 0x3fc55555
	s_mov_b32 s29, 0x3fe00000
	s_mov_b32 s34, 0
	s_sub_i32 s35, 0, s35
	s_waitcnt lgkmcnt(0)
	v_div_scale_f64 v[2:3], null, v[5:6], v[5:6], s[2:3]
	v_div_scale_f64 v[11:12], vcc_lo, s[2:3], v[5:6], s[2:3]
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	v_rcp_f64_e32 v[7:8], v[2:3]
	s_waitcnt_depctr 0xfff
	v_fma_f64 v[9:10], -v[2:3], v[7:8], 1.0
	v_fma_f64 v[7:8], v[7:8], v[9:10], v[7:8]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[9:10], -v[2:3], v[7:8], 1.0
	v_fma_f64 v[7:8], v[7:8], v[9:10], v[7:8]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_f64 v[9:10], v[11:12], v[7:8]
	v_fma_f64 v[2:3], -v[2:3], v[9:10], v[11:12]
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_3) | instid1(VALU_DEP_2)
	v_div_fmas_f64 v[2:3], v[2:3], v[7:8], v[9:10]
	v_mul_lo_u32 v7, s4, v0
	s_mov_b32 s4, 0x652b82fe
	s_mov_b32 s5, 0x3ff71547
	v_div_fixup_f64 v[3:4], v[2:3], v[5:6], s[2:3]
	v_mul_f64 v[5:6], v[5:6], 0.5
	s_load_b64 s[2:3], s[0:1], 0x0
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_hi_u32 v2, v0, v7
	v_add_nc_u32_e32 v0, v0, v2
.LBB0_2:                                ; =>This Inner Loop Header: Depth=1
	v_ashrrev_i32_e32 v2, 31, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_nc_u32_e32 v7, v1, v2
	v_xor_b32_e32 v7, v7, v2
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_hi_u32 v8, v7, v0
	v_mul_lo_u32 v9, v8, s33
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_sub_nc_u32_e32 v7, v7, v9
	v_add_nc_u32_e32 v9, 1, v8
	v_subrev_nc_u32_e32 v10, s33, v7
	v_cmp_le_u32_e32 vcc_lo, s33, v7
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_dual_cndmask_b32 v8, v8, v9 :: v_dual_cndmask_b32 v7, v7, v10
	v_xor_b32_e32 v10, s31, v2
	v_add_nc_u32_e32 v9, 1, v8
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_cmp_le_u32_e32 vcc_lo, s33, v7
	v_cndmask_b32_e32 v7, v8, v9, vcc_lo
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_xor_b32_e32 v7, v7, v10
	v_sub_nc_u32_e32 v11, v7, v10
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_cvt_f64_i32_e32 v[7:8], v11
	v_mad_u64_u32 v[9:10], null, s35, v11, v[1:2]
	v_cvt_f64_i32_e32 v[9:10], v9
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_f64 v[7:8], v[7:8], -v[5:6]
	v_add_f64 v[9:10], v[9:10], -v[5:6]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_mul_f64 v[7:8], v[3:4], v[7:8]
	v_mul_f64 v[9:10], v[3:4], v[9:10]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_f64 v[7:8], v[7:8], v[7:8]
	v_fma_f64 v[7:8], v[9:10], -v[9:10], -v[7:8]
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_3)
	v_mul_f64 v[9:10], v[7:8], s[4:5]
	v_cmp_nlt_f64_e32 vcc_lo, 0x40900000, v[7:8]
	v_cmp_ngt_f64_e64 s0, 0xc090cc00, v[7:8]
	v_rndne_f64_e32 v[9:10], v[9:10]
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_3) | instid1(VALU_DEP_1)
	v_fma_f64 v[11:12], v[9:10], s[6:7], v[7:8]
	v_cvt_i32_f64_e32 v15, v[9:10]
	v_lshlrev_b64 v[7:8], 3, v[1:2]
	v_add_nc_u32_e32 v1, 0x4000, v1
	v_cmp_le_i32_e64 s1, s30, v1
	v_fma_f64 v[11:12], v[9:10], s[8:9], v[11:12]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[13:14], v[11:12], s[12:13], s[10:11]
	v_fma_f64 v[13:14], v[11:12], v[13:14], s[14:15]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[13:14], v[11:12], v[13:14], s[16:17]
	v_fma_f64 v[13:14], v[11:12], v[13:14], s[18:19]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[13:14], v[11:12], v[13:14], s[20:21]
	v_fma_f64 v[13:14], v[11:12], v[13:14], s[22:23]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[13:14], v[11:12], v[13:14], s[24:25]
	v_fma_f64 v[13:14], v[11:12], v[13:14], s[26:27]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[13:14], v[11:12], v[13:14], s[28:29]
	v_fma_f64 v[13:14], v[11:12], v[13:14], 1.0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[9:10], v[11:12], v[13:14], 1.0
	v_ldexp_f64 v[9:10], v[9:10], v15
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_2)
	v_cndmask_b32_e32 v10, 0x7ff00000, v10, vcc_lo
	s_and_b32 vcc_lo, s0, vcc_lo
	s_or_b32 s34, s1, s34
	v_cndmask_b32_e32 v9, 0, v9, vcc_lo
	s_waitcnt lgkmcnt(0)
	v_add_co_u32 v7, vcc_lo, s2, v7
	v_cndmask_b32_e64 v10, 0, v10, s0
	v_add_co_ci_u32_e32 v8, vcc_lo, s3, v8, vcc_lo
	global_store_b64 v[7:8], v[9:10], off
	s_and_not1_b32 exec_lo, exec_lo, s34
	s_cbranch_execnz .LBB0_2
.LBB0_3:                                ; %._crit_edge
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z20calculate_each_pointPd
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 264
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 16
		.amdhsa_next_free_sgpr 36
		.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	_Z20calculate_each_pointPd, .Lfunc_end0-_Z20calculate_each_pointPd
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 972
; NumSgprs: 38
; NumVgprs: 16
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 4
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 38
; NumVGPRsForWavesPerEU: 16
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.protected	_Z26reduce_array_global_memoryPdS_i ; -- Begin function _Z26reduce_array_global_memoryPdS_i
	.globl	_Z26reduce_array_global_memoryPdS_i
	.p2align	8
	.type	_Z26reduce_array_global_memoryPdS_i,@function
_Z26reduce_array_global_memoryPdS_i:    ; @_Z26reduce_array_global_memoryPdS_i
; %bb.0:
	s_clause 0x1
	s_load_b32 s3, s[0:1], 0x24
	s_load_b32 s2, s[0:1], 0x10
	s_waitcnt lgkmcnt(0)
	s_and_b32 s3, s3, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s15, s3, v[0:1]
	s_mov_b32 s3, exec_lo
	v_cmpx_gt_i32_e64 s2, v1
	s_cbranch_execz .LBB1_5
; %bb.1:                                ; %.lr.ph
	s_load_b128 s[4:7], s[0:1], 0x0
	v_ashrrev_i32_e32 v2, 31, v1
	s_lshr_b32 s0, s2, 31
	s_mov_b32 s3, 0
	s_add_i32 s0, s2, s0
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[4:5], 3, v[1:2]
	s_ashr_i32 s1, s0, 1
	s_waitcnt lgkmcnt(0)
	v_add_co_u32 v2, vcc_lo, s4, v4
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v3, vcc_lo, s5, v5, vcc_lo
	v_add_co_u32 v4, vcc_lo, s6, v4
	v_add_co_ci_u32_e32 v5, vcc_lo, s7, v5, vcc_lo
.LBB1_2:                                ; =>This Inner Loop Header: Depth=1
	s_mov_b32 s0, exec_lo
	v_cmpx_gt_i32_e64 s1, v1
	s_cbranch_execz .LBB1_4
; %bb.3:                                ;   in Loop: Header=BB1_2 Depth=1
	v_add_nc_u32_e32 v6, s1, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v7, 31, v6
	v_lshlrev_b64 v[6:7], 3, v[6:7]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v6, vcc_lo, s4, v6
	v_add_co_ci_u32_e32 v7, vcc_lo, s5, v7, vcc_lo
	global_load_b64 v[8:9], v[2:3], off
	global_load_b64 v[6:7], v[6:7], off
	s_waitcnt vmcnt(0)
	v_add_f64 v[6:7], v[8:9], v[6:7]
	global_store_b64 v[4:5], v[6:7], off
.LBB1_4:                                ;   in Loop: Header=BB1_2 Depth=1
	s_or_b32 exec_lo, exec_lo, s0
	v_add_nc_u32_e32 v1, 0x4000, v1
	v_add_co_u32 v2, vcc_lo, 0x20000, v2
	v_add_co_ci_u32_e32 v3, vcc_lo, 0, v3, vcc_lo
	s_delay_alu instid0(VALU_DEP_3) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_cmp_le_i32_e32 vcc_lo, s2, v1
	v_add_co_u32 v4, s0, 0x20000, v4
	v_add_co_ci_u32_e64 v5, s0, 0, v5, s0
	s_or_b32 s3, vcc_lo, s3
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_not1_b32 exec_lo, exec_lo, s3
	s_cbranch_execnz .LBB1_2
.LBB1_5:                                ; %._crit_edge
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z26reduce_array_global_memoryPdS_i
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 280
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 10
		.amdhsa_next_free_sgpr 16
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end1:
	.size	_Z26reduce_array_global_memoryPdS_i, .Lfunc_end1-_Z26reduce_array_global_memoryPdS_i
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 304
; NumSgprs: 18
; NumVgprs: 10
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 10
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.protected	_Z26reduce_array_shared_memoryPdS_i ; -- Begin function _Z26reduce_array_shared_memoryPdS_i
	.globl	_Z26reduce_array_shared_memoryPdS_i
	.p2align	8
	.type	_Z26reduce_array_shared_memoryPdS_i,@function
_Z26reduce_array_shared_memoryPdS_i:    ; @_Z26reduce_array_shared_memoryPdS_i
; %bb.0:
	s_clause 0x1
	s_load_b32 s3, s[0:1], 0x24
	s_load_b32 s8, s[0:1], 0x10
	s_mov_b32 s2, s15
	s_waitcnt lgkmcnt(0)
	s_and_b32 s3, s3, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s2, s3, v[0:1]
	s_mov_b32 s3, exec_lo
	v_cmpx_gt_i32_e64 s8, v1
	s_cbranch_execz .LBB2_9
; %bb.1:                                ; %.lr.ph
	s_load_b128 s[4:7], s[0:1], 0x0
	v_dual_mov_b32 v4, 0 :: v_dual_lshlrev_b32 v3, 3, v0
	v_cmp_eq_u32_e32 vcc_lo, 0, v0
	s_mov_b32 s9, 0
.LBB2_2:                                ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB2_3 Depth 2
	v_ashrrev_i32_e32 v2, 31, v1
	s_movk_i32 s3, 0x200
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[5:6], 3, v[1:2]
	s_waitcnt lgkmcnt(0)
	v_add_co_u32 v5, s0, s4, v5
	s_delay_alu instid0(VALU_DEP_1)
	v_add_co_ci_u32_e64 v6, s0, s5, v6, s0
	global_load_b64 v[5:6], v[5:6], off
	s_waitcnt vmcnt(0)
	ds_store_b64 v3, v[5:6]
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
.LBB2_3:                                ;   Parent Loop BB2_2 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	v_add_nc_u32_e32 v2, s3, v0
	v_cmp_gt_u32_e64 s0, s3, v0
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cmp_gt_i32_e64 s1, s8, v2
	s_and_b32 s1, s0, s1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_saveexec_b32 s0, s1
	s_cbranch_execz .LBB2_5
; %bb.4:                                ;   in Loop: Header=BB2_3 Depth=2
	v_lshl_add_u32 v2, s3, 3, v3
	ds_load_b64 v[5:6], v2
	ds_load_b64 v[7:8], v3
	s_waitcnt lgkmcnt(0)
	v_add_f64 v[5:6], v[5:6], v[7:8]
	ds_store_b64 v3, v[5:6]
.LBB2_5:                                ;   in Loop: Header=BB2_3 Depth=2
	s_or_b32 exec_lo, exec_lo, s0
	s_lshr_b32 s0, s3, 1
	s_cmp_gt_u32 s3, 1
	s_mov_b32 s3, s0
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	s_cbranch_scc1 .LBB2_3
; %bb.6:                                ;   in Loop: Header=BB2_2 Depth=1
	s_and_saveexec_b32 s0, vcc_lo
	s_cbranch_execz .LBB2_8
; %bb.7:                                ;   in Loop: Header=BB2_2 Depth=1
	ds_load_b64 v[5:6], v4
	s_ashr_i32 s3, s2, 31
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_lshl_b64 s[10:11], s[2:3], 3
	s_add_u32 s10, s6, s10
	s_addc_u32 s11, s7, s11
	s_waitcnt lgkmcnt(0)
	global_store_b64 v4, v[5:6], s[10:11]
.LBB2_8:                                ;   in Loop: Header=BB2_2 Depth=1
	s_or_b32 exec_lo, exec_lo, s0
	v_add_nc_u32_e32 v1, 0x4000, v1
	s_add_i32 s2, s2, 16
	s_waitcnt_vscnt null, 0x0
	s_barrier
	buffer_gl0_inv
	v_cmp_le_i32_e64 s0, s8, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_or_b32 s9, s0, s9
	s_and_not1_b32 exec_lo, exec_lo, s9
	s_cbranch_execnz .LBB2_2
.LBB2_9:                                ; %._crit_edge
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z26reduce_array_shared_memoryPdS_i
		.amdhsa_group_segment_fixed_size 8192
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 280
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 9
		.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_end2:
	.size	_Z26reduce_array_shared_memoryPdS_i, .Lfunc_end2-_Z26reduce_array_shared_memoryPdS_i
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 396
; NumSgprs: 18
; NumVgprs: 9
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 8192 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 9
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.protected	n                       ; @n
	.type	n,@object
	.section	.bss,"aw",@nobits
	.globl	n
	.p2align	2, 0x0
n:
	.long	0                               ; 0x0
	.size	n, 4

	.protected	l                       ; @l
	.type	l,@object
	.globl	l
	.p2align	3, 0x0
l:
	.quad	0x0000000000000000              ; double 0
	.size	l, 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 l
	.addrsig_sym __hip_cuid_
	.amdgpu_metadata
---
amdhsa.kernels:
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .offset:         8
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         12
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         16
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         20
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         22
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         24
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         26
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         28
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         30
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         48
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         56
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         64
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         72
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 264
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z20calculate_each_pointPd
    .private_segment_fixed_size: 0
    .sgpr_count:     38
    .sgpr_spill_count: 0
    .symbol:         _Z20calculate_each_pointPd.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     16
    .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:     by_value
      - .offset:         24
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         28
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         32
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         36
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         38
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         40
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         42
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         44
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         46
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         64
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         88
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 280
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z26reduce_array_global_memoryPdS_i
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z26reduce_array_global_memoryPdS_i.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     10
    .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:     by_value
      - .offset:         24
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         28
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         32
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         36
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         38
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         40
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         42
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         44
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         46
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         64
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         88
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 8192
    .kernarg_segment_align: 8
    .kernarg_segment_size: 280
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z26reduce_array_shared_memoryPdS_i
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z26reduce_array_shared_memoryPdS_i.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     9
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
