/*
 ============================================================================
 Name        : lab.cu
 Author      : 
 Version     :
 Copyright   : Your copyright notice
 Description : CUDA compute reciprocals
 ============================================================================
 */

#include <iostream>
#include <numeric>
#include <stdlib.h>
#include <fstream>

//#include <stdio.h>

static void CheckCudaErrorAux (const char *, unsigned, const char *, cudaError_t);
#define CUDA_CHECK_RETURN(value) CheckCudaErrorAux(__FILE__,__LINE__, #value, value)

struct Params
{
	int length;
	int time;
	float dx;
	float dt;
	float startT;
	float endT;
};

void initialize(float **data, Params inParam)
{
	for (unsigned i = 0; i < inParam.time; ++i)
		data[i] = new float[inParam.length];
}

/**
 * CUDA kernel that computes reciprocal values for a given vector
 */
__global__ void reciprocalKernel(float *OldData,float *NewData, Params inParams) {
	unsigned idx = blockIdx.x*blockDim.x+threadIdx.x;
			if(idx == 0)
				NewData[idx] = inParams.startT;
			else if (idx == inParams.length - 1 )
				NewData[idx] = inParams.endT * inParams.dt + OldData[idx];
			else
			{
				NewData[idx] = ((OldData[idx+1] - 2 * OldData[idx] + OldData[idx-1])* inParams.dt)/inParams.dx * inParams.dx + OldData[idx];
			}

}

/**
 * Host function that copies the data and launches the work on GPU
 */
void gpuReciprocal(float *data, Params inParams)
{
	float *rc = new float[inParams.length];
	float *gpuOldData;
	float *gpuNewData;

	cudaEvent_t GPUstart, GPUstop;
		float GPUtime = 0.0f;


		cudaEventCreate(&GPUstart);
		cudaEventCreate(&GPUstop);

	CUDA_CHECK_RETURN(cudaMalloc((void **)&gpuOldData, sizeof(float)*inParams.length));
	CUDA_CHECK_RETURN(cudaMemcpy(gpuOldData, rc, sizeof(float)*inParams.length, cudaMemcpyHostToDevice));
	CUDA_CHECK_RETURN(cudaMalloc((void **)&gpuNewData, sizeof(float)*inParams.length));
	CUDA_CHECK_RETURN(cudaMemcpy(gpuNewData, data, sizeof(float)*inParams.length, cudaMemcpyHostToDevice));
	
	static const int BLOCK_SIZE = 26;
	const int blockCount = 1;
	for(int i = 0; i < inParams.time; ++i)
	{
		cudaEventRecord(GPUstart, 0);
		if (i % 2 == 0)
		{
			reciprocalKernel<<<blockCount, BLOCK_SIZE>>> (gpuOldData, gpuNewData, inParams);
			cudaEventRecord(GPUstop, 0);
			CUDA_CHECK_RETURN(cudaMemcpy(rc, gpuNewData, sizeof(float)*inParams.length, cudaMemcpyDeviceToHost));

		}
			else
			{

			reciprocalKernel<<<blockCount, BLOCK_SIZE>>> (gpuNewData, gpuOldData, inParams);
			cudaEventRecord(GPUstop, 0);
		    CUDA_CHECK_RETURN(cudaMemcpy(rc, gpuOldData, sizeof(float)*inParams.length, cudaMemcpyDeviceToHost));
			}

		cudaEventSynchronize(GPUstop);

		std::cout << i <<": ";
		for(int i =0; i < inParams.length; ++i)
						std::cout << rc[i] << " ";
		std::cout << std::endl;
		float temp;
		cudaEventElapsedTime(&temp,GPUstart, GPUstop);
		GPUtime += temp;

	}
	printf("GPU time = %.3f ms\n",GPUtime);
}

void initializeData(float* data, unsigned size,  float defaultValue)
{
	for(int i = 0; i < size; ++i)
		data[i] = defaultValue;
}



void print(float **a, unsigned h, unsigned w)
{
	for(int i = 0; i < h; ++i)
	{
		std::cout << i << ": ";
		for(int j = 0; j < w; ++j)
			std::cout << a[i][j] << " ";
		std::cout << std::endl;
	}

}


float **cpuReciprocal(float **data,Params inParams)
{
	float CPUstart, CPUstop;
	float CPUtime = 0.0f;

	float **cpuResult = new float*[inParams.time];
	initialize(cpuResult, inParams);

	float * currentData = cpuResult[0];
    initializeData(currentData, inParams.length, 0);


     currentData[0] = inParams.startT;

	for(int i =1; i < inParams.time; ++i)
	{
		cpuResult[i][0] = inParams.startT;
		for(int j = 1; j < inParams.length - 1; ++j)
		{
			cpuResult[i][j] = ((cpuResult[i-1][j+1] - 2 * cpuResult[i-1][j] + cpuResult[i-1][j-1])* inParams.dt)/inParams.dx * inParams.dx + cpuResult[i-1][j];
		}
		cpuResult[i][inParams.length-1] = inParams.endT * inParams.dt + cpuResult[i-1][inParams.length-1];
	}

	return cpuResult;
}






int main(void)
{
	Params mainParams;
	mainParams.length = 13;
	mainParams.time = 20;
	mainParams.dx = 0.5;
	mainParams.dt = 0.1;
	mainParams.startT = 0.0;
	mainParams.endT = 5.0;

	float **data;
	data = new float*[mainParams.time];
	initialize(data, mainParams);

	std::cout << "CPU" << std::endl;
	float **recCpu = cpuReciprocal(data, mainParams);
	print(recCpu, mainParams.time, mainParams.length);

	std::cout << "GPU" << std::endl;
	float *dataTwo;
	dataTwo = new float[mainParams.length];
	gpuReciprocal(dataTwo, mainParams);
	//print(recGpu, mainParams.time, mainParams.length);
//	float cpuSum = std::accumulate (recCpu, recCpu+WORK_SIZE, 0.0);
//	float gpuSum = std::accumulate (recGpu, recGpu+WORK_SIZE, 0.0);

	/* Verify the results */
	//std::cout<<"gpuSum = "<<gpuSum<< " cpuSum = " <<cpuSum<<std::endl;

	/* Free memory */
	//delete[] data;
	//delete[] recCpu;
	//delete[] recGpu;

	return 0;
}

/**
 * Check the return value of the CUDA runtime API call and exit
 * the application if the call has failed.
 */
static void CheckCudaErrorAux (const char *file, unsigned line, const char *statement, cudaError_t err)
{
	if (err == cudaSuccess)
		return;
	std::cerr << statement<<" returned " << cudaGetErrorString(err) << "("<<err<< ") at "<<file<<":"<<line << std::endl;
	exit (1);
}


	.file	"tmpxft_00375075_00000000-6_lab.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB3814:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE3814:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.align 2
	.type	_ZNSolsEPFRSoS_E.isra.0, @function
_ZNSolsEPFRSoS_E.isra.0:
.LFB4490:
	.cfi_startproc
	jmp	*%rsi
	.cfi_endproc
.LFE4490:
	.size	_ZNSolsEPFRSoS_E.isra.0, .-_ZNSolsEPFRSoS_E.isra.0
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	" returned "
.LC1:
	.string	"("
.LC2:
	.string	") at "
.LC3:
	.string	"/home/ubuntu/Datasets/stackv2/train-structured/sudoHackIn/CUDA/master/lab.cu"
.LC4:
	.string	":"
	.text
	.type	_ZL17CheckCudaErrorAuxPKcjS0_9cudaError.constprop.0, @function
_ZL17CheckCudaErrorAuxPKcjS0_9cudaError.constprop.0:
.LFB4491:
	.cfi_startproc
	testl	%edx, %edx
	je	.L5
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movl	%edx, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	movl	%edi, %ebx
	leaq	_ZSt4cerr(%rip), %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC0(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	%ebp, %edi
	movq	%rax, %r12
	call	cudaGetErrorString@PLT
	movq	%r12, %rdi
	movq	%rax, %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC1(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	%ebp, %esi
	movq	%rax, %rdi
	call	_ZNSolsEi@PLT
	leaq	.LC2(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC3(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC4(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	%ebx, %esi
	movq	%rax, %rdi
	call	_ZNSo9_M_insertImEERSoT_@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	movl	$1, %edi
	call	exit@PLT
.L5:
	.cfi_def_cfa_offset 8
	.cfi_restore 3
	.cfi_restore 6
	.cfi_restore 12
	ret
	.cfi_endproc
.LFE4491:
	.size	_ZL17CheckCudaErrorAuxPKcjS0_9cudaError.constprop.0, .-_ZL17CheckCudaErrorAuxPKcjS0_9cudaError.constprop.0
	.globl	_Z10initializePPf6Params
	.type	_Z10initializePPf6Params, @function
_Z10initializePPf6Params:
.LFB3805:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	movabsq	$2305843009213693950, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	movq	%rdi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	xorl	%ebx, %ebx
	pushq	%rdx
	.cfi_def_cfa_offset 48
.L11:
	cmpl	52(%rsp), %ebx
	jnb	.L15
	movslq	48(%rsp), %rdi
	cmpq	%rdi, %r12
	jb	.L12
	movl	%ebx, %eax
	salq	$2, %rdi
	incl	%ebx
	leaq	0(%rbp,%rax,8), %r13
	call	_Znam@PLT
	movq	%rax, 0(%r13)
	jmp	.L11
.L12:
	call	__cxa_throw_bad_array_new_length@PLT
.L15:
	popq	%rax
	.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
	ret
	.cfi_endproc
.LFE3805:
	.size	_Z10initializePPf6Params, .-_Z10initializePPf6Params
	.globl	_Z14initializeDataPfjf
	.type	_Z14initializeDataPfjf, @function
_Z14initializeDataPfjf:
.LFB3807:
	.cfi_startproc
	endbr64
	xorl	%eax, %eax
.L17:
	cmpl	%esi, %eax
	jnb	.L19
	movss	%xmm0, (%rdi,%rax,4)
	incq	%rax
	jmp	.L17
.L19:
	ret
	.cfi_endproc
.LFE3807:
	.size	_Z14initializeDataPfjf, .-_Z14initializeDataPfjf
	.section	.rodata.str1.1
.LC5:
	.string	": "
.LC6:
	.string	" "
	.text
	.globl	_Z5printPPfjj
	.type	_Z5printPPfjj, @function
_Z5printPPfjj:
.LFB3808:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movl	%edx, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movq	%rdi, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movl	%esi, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	xorl	%ebx, %ebx
	pushq	%rcx
	.cfi_def_cfa_offset 64
.L21:
	movl	%ebx, %esi
	cmpq	%rbp, %rbx
	je	.L26
	leaq	_ZSt4cout(%rip), %rdi
	movl	%r13d, %r14d
	xorl	%r15d, %r15d
	call	_ZNSolsEi@PLT
	leaq	.LC5(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
.L22:
	cmpq	%r14, %r15
	je	.L27
	movq	(%r12,%rbx,8), %rax
	leaq	_ZSt4cout(%rip), %rdi
	cvtss2sd	(%rax,%r15,4), %xmm0
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	incq	%r15
	leaq	.LC6(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	jmp	.L22
.L27:
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rdi
	incq	%rbx
	call	_ZNSolsEPFRSoS_E.isra.0
	jmp	.L21
.L26:
	popq	%rax
	.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
.LFE3808:
	.size	_Z5printPPfjj, .-_Z5printPPfjj
	.globl	_Z13cpuReciprocalPPf6Params
	.type	_Z13cpuReciprocalPPf6Params, @function
_Z13cpuReciprocalPPf6Params:
.LFB3809:
	.cfi_startproc
	endbr64
	movabsq	$1152921504606846975, %rax
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	subq	$16, %rsp
	.cfi_def_cfa_offset 48
	movss	56(%rsp), %xmm3
	movss	60(%rsp), %xmm4
	movss	64(%rsp), %xmm5
	movslq	52(%rsp), %rdi
	movl	48(%rsp), %ebp
	movss	%xmm3, 12(%rsp)
	movss	%xmm4, 8(%rsp)
	movss	%xmm5, 4(%rsp)
	cmpq	%rdi, %rax
	jb	.L29
	movq	%rdi, %r12
	salq	$3, %rdi
	call	_Znam@PLT
	subq	$32, %rsp
	.cfi_def_cfa_offset 80
	movups	80(%rsp), %xmm6
	movq	%rax, %rbx
	movq	96(%rsp), %rax
	movq	%rbx, %rdi
	movq	%rax, 16(%rsp)
	movups	%xmm6, (%rsp)
	call	_Z10initializePPf6Params
	movq	(%rbx), %rdx
	addq	$32, %rsp
	.cfi_def_cfa_offset 48
	movl	%ebp, %esi
	xorps	%xmm0, %xmm0
	movq	%rdx, %rdi
	call	_Z14initializeDataPfjf
	movss	4(%rsp), %xmm5
	movslq	%ebp, %rax
	decl	%ebp
	movss	68(%rsp), %xmm6
	movss	8(%rsp), %xmm4
	leaq	-4(,%rax,4), %rdi
	movss	%xmm5, (%rdx)
	movss	12(%rsp), %xmm3
	movl	$1, %edx
	jmp	.L30
.L29:
	call	__cxa_throw_bad_array_new_length@PLT
.L36:
	movaps	%xmm6, %xmm0
	incq	%rdx
	mulss	%xmm4, %xmm0
	addss	(%rcx,%rdi), %xmm0
	movss	%xmm0, (%rsi,%rdi)
.L30:
	cmpl	%edx, %r12d
	jle	.L35
	movq	(%rbx,%rdx,8), %rsi
	movq	-8(%rbx,%rdx,8), %rcx
	xorl	%eax, %eax
	movl	$1, %r8d
	movss	%xmm5, (%rsi)
.L31:
	leaq	4(%rax), %r9
	cmpl	%r8d, %ebp
	jle	.L36
	movss	4(%rcx,%rax), %xmm2
	movss	8(%rcx,%rax), %xmm1
	incl	%r8d
	movss	(%rcx,%rax), %xmm0
	movaps	%xmm2, %xmm7
	addss	%xmm2, %xmm7
	subss	%xmm7, %xmm1
	addss	%xmm1, %xmm0
	mulss	%xmm4, %xmm0
	divss	%xmm3, %xmm0
	mulss	%xmm3, %xmm0
	addss	%xmm2, %xmm0
	movss	%xmm0, 4(%rsi,%rax)
	movq	%r9, %rax
	jmp	.L31
.L35:
	addq	$16, %rsp
	.cfi_def_cfa_offset 32
	movq	%rbx, %rax
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3809:
	.size	_Z13cpuReciprocalPPf6Params, .-_Z13cpuReciprocalPPf6Params
	.globl	_Z45__device_stub__Z16reciprocalKernelPfS_6ParamsPfS_R6Params
	.type	_Z45__device_stub__Z16reciprocalKernelPfS_6ParamsPfS_R6Params, @function
_Z45__device_stub__Z16reciprocalKernelPfS_6ParamsPfS_R6Params:
.LFB3836:
	.cfi_startproc
	endbr64
	subq	$120, %rsp
	.cfi_def_cfa_offset 128
	movq	%rdi, 8(%rsp)
	leaq	24(%rsp), %rcx
	leaq	32(%rsp), %rdi
	movq	%rsi, (%rsp)
	leaq	44(%rsp), %rsi
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rax
	movq	%rdx, 96(%rsp)
	leaq	16(%rsp), %rdx
	movq	%rax, 80(%rsp)
	movq	%rsp, %rax
	movq	%rax, 88(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 32(%rsp)
	movl	$1, 40(%rsp)
	movq	%rax, 44(%rsp)
	movl	$1, 52(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L37
	pushq	24(%rsp)
	.cfi_def_cfa_offset 136
	leaq	_Z16reciprocalKernelPfS_6Params(%rip), %rdi
	pushq	24(%rsp)
	.cfi_def_cfa_offset 144
	movq	60(%rsp), %rcx
	movl	68(%rsp), %r8d
	movq	48(%rsp), %rsi
	movl	56(%rsp), %edx
	leaq	96(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 136
	popq	%rdx
	.cfi_def_cfa_offset 128
.L37:
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	je	.L39
	call	__stack_chk_fail@PLT
.L39:
	addq	$120, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3836:
	.size	_Z45__device_stub__Z16reciprocalKernelPfS_6ParamsPfS_R6Params, .-_Z45__device_stub__Z16reciprocalKernelPfS_6ParamsPfS_R6Params
	.globl	_Z16reciprocalKernelPfS_6Params
	.type	_Z16reciprocalKernelPfS_6Params, @function
_Z16reciprocalKernelPfS_6Params:
.LFB3837:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	leaq	16(%rsp), %rdx
	call	_Z45__device_stub__Z16reciprocalKernelPfS_6ParamsPfS_R6Params
	popq	%rdx
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3837:
	.size	_Z16reciprocalKernelPfS_6Params, .-_Z16reciprocalKernelPfS_6Params
	.section	.rodata.str1.1
.LC8:
	.string	"cudaMalloc((void **)&gpuOldData, sizeof(float)*inParams.length)"
.LC9:
	.string	"cudaMemcpy(gpuOldData, rc, sizeof(float)*inParams.length, cudaMemcpyHostToDevice)"
.LC10:
	.string	"cudaMalloc((void **)&gpuNewData, sizeof(float)*inParams.length)"
.LC11:
	.string	"cudaMemcpy(gpuNewData, data, sizeof(float)*inParams.length, cudaMemcpyHostToDevice)"
.LC12:
	.string	"cudaMemcpy(rc, gpuNewData, sizeof(float)*inParams.length, cudaMemcpyDeviceToHost)"
.LC13:
	.string	"cudaMemcpy(rc, gpuOldData, sizeof(float)*inParams.length, cudaMemcpyDeviceToHost)"
.LC14:
	.string	"GPU time = %.3f ms\n"
	.text
	.globl	_Z13gpuReciprocalPf6Params
	.type	_Z13gpuReciprocalPf6Params, @function
_Z13gpuReciprocalPf6Params:
.LFB3806:
	.cfi_startproc
	endbr64
	movabsq	$2305843009213693950, %rdx
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$120, %rsp
	.cfi_def_cfa_offset 176
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	movslq	176(%rsp), %rax
	cmpq	%rax, %rdx
	jb	.L44
	movabsq	$4294967322, %r13
	movq	%rax, %r12
	movq	%rdi, %rbp
	salq	$2, %rax
	movq	%rax, %rdi
	movq	%rax, (%rsp)
	call	_Znam@PLT
	leaq	40(%rsp), %rdi
	movq	%rax, %rbx
	call	cudaEventCreate@PLT
	leaq	48(%rsp), %rdi
	call	cudaEventCreate@PLT
	movq	(%rsp), %rsi
	leaq	24(%rsp), %rdi
	call	cudaMalloc@PLT
	leaq	.LC8(%rip), %rsi
	movl	$69, %edi
	movl	%eax, %edx
	call	_ZL17CheckCudaErrorAuxPKcjS0_9cudaError.constprop.0
	movq	(%rsp), %rdx
	movq	24(%rsp), %rdi
	movq	%rbx, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	leaq	.LC9(%rip), %rsi
	movl	$70, %edi
	movl	%eax, %edx
	call	_ZL17CheckCudaErrorAuxPKcjS0_9cudaError.constprop.0
	movq	(%rsp), %rsi
	leaq	32(%rsp), %rdi
	call	cudaMalloc@PLT
	leaq	.LC10(%rip), %rsi
	movl	$71, %edi
	movl	%eax, %edx
	call	_ZL17CheckCudaErrorAuxPKcjS0_9cudaError.constprop.0
	movq	(%rsp), %rdx
	movq	32(%rsp), %rdi
	movq	%rbp, %rsi
	movl	$1, %ecx
	xorl	%ebp, %ebp
	call	cudaMemcpy@PLT
	leaq	.LC11(%rip), %rsi
	movl	$72, %edi
	movl	%eax, %edx
	call	_ZL17CheckCudaErrorAuxPKcjS0_9cudaError.constprop.0
	movl	$0x00000000, 12(%rsp)
	jmp	.L45
.L44:
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L57
	call	__cxa_throw_bad_array_new_length@PLT
.L59:
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rdi
	incl	%ebp
	call	_ZNSolsEPFRSoS_E.isra.0
	movq	48(%rsp), %rdx
	movq	40(%rsp), %rsi
	leaq	80(%rsp), %rdi
	call	cudaEventElapsedTime@PLT
	movss	12(%rsp), %xmm1
	addss	80(%rsp), %xmm1
	movss	%xmm1, 12(%rsp)
.L45:
	cmpl	%ebp, 180(%rsp)
	jle	.L58
	movq	40(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	%r13, 68(%rsp)
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	$1, 76(%rsp)
	movq	%r13, %rdx
	movl	$1, %ecx
	movl	$1, %esi
	movabsq	$4294967297, %rdi
	movl	$1, 64(%rsp)
	movq	%rdi, 56(%rsp)
	testl	$1, %ebp
	jne	.L47
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L48
	movq	32(%rsp), %rsi
	movq	24(%rsp), %rdi
	leaq	80(%rsp), %rdx
	movl	%r12d, 176(%rsp)
	movq	192(%rsp), %rax
	movups	176(%rsp), %xmm2
	movq	%rax, 96(%rsp)
	movups	%xmm2, 80(%rsp)
	call	_Z45__device_stub__Z16reciprocalKernelPfS_6ParamsPfS_R6Params
.L48:
	movq	48(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	(%rsp), %rdx
	movq	32(%rsp), %rsi
	movq	%rbx, %rdi
	movl	$2, %ecx
	call	cudaMemcpy@PLT
	leaq	.LC12(%rip), %rsi
	movl	$83, %edi
	movl	%eax, %edx
	jmp	.L56
.L47:
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L50
	movq	24(%rsp), %rsi
	movq	32(%rsp), %rdi
	leaq	80(%rsp), %rdx
	movl	%r12d, 176(%rsp)
	movq	192(%rsp), %rax
	movups	176(%rsp), %xmm3
	movq	%rax, 96(%rsp)
	movups	%xmm3, 80(%rsp)
	call	_Z45__device_stub__Z16reciprocalKernelPfS_6ParamsPfS_R6Params
.L50:
	movq	48(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	(%rsp), %rdx
	movq	24(%rsp), %rsi
	movq	%rbx, %rdi
	movl	$2, %ecx
	call	cudaMemcpy@PLT
	leaq	.LC13(%rip), %rsi
	movl	$91, %edi
	movl	%eax, %edx
.L56:
	call	_ZL17CheckCudaErrorAuxPKcjS0_9cudaError.constprop.0
	movq	48(%rsp), %rdi
	xorl	%r14d, %r14d
	leaq	.LC6(%rip), %r15
	call	cudaEventSynchronize@PLT
	movl	%ebp, %esi
	leaq	_ZSt4cout(%rip), %rdi
	call	_ZNSolsEi@PLT
	leaq	.LC5(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
.L51:
	cmpl	%r14d, %r12d
	jle	.L59
	leaq	_ZSt4cout(%rip), %rdi
	cvtss2sd	(%rbx,%r14,4), %xmm0
	incq	%r14
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	movq	%r15, %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	jmp	.L51
.L58:
	leaq	.LC14(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	cvtss2sd	12(%rsp), %xmm0
	call	__printf_chk@PLT
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	je	.L54
.L57:
	call	__stack_chk_fail@PLT
.L54:
	addq	$120, %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
.LFE3806:
	.size	_Z13gpuReciprocalPf6Params, .-_Z13gpuReciprocalPf6Params
	.section	.rodata.str1.1
.LC15:
	.string	"CPU"
.LC16:
	.string	"GPU"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB3810:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movl	$160, %edi
	leaq	_ZSt4cout(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	subq	$40, %rsp
	.cfi_def_cfa_offset 64
	call	_Znam@PLT
	subq	$32, %rsp
	.cfi_def_cfa_offset 96
	movq	%rax, %rbx
	movabsq	$85899345933, %rax
	movq	%rax, 40(%rsp)
	movq	%rbx, %rdi
	movabsq	$4453159313459904512, %rax
	movq	%rax, 48(%rsp)
	movl	$517, %eax
	salq	$53, %rax
	movq	%rax, 56(%rsp)
	movups	40(%rsp), %xmm0
	movq	%rax, 16(%rsp)
	movups	%xmm0, (%rsp)
	call	_Z10initializePPf6Params
	addq	$32, %rsp
	.cfi_def_cfa_offset 64
	movq	%rbp, %rdi
	leaq	.LC15(%rip), %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	subq	$32, %rsp
	.cfi_def_cfa_offset 96
	movq	%rbx, %rdi
	movups	40(%rsp), %xmm1
	movq	56(%rsp), %rax
	movups	%xmm1, (%rsp)
	movq	%rax, 16(%rsp)
	call	_Z13cpuReciprocalPPf6Params
	addq	$32, %rsp
	.cfi_def_cfa_offset 64
	movl	$13, %edx
	movl	$20, %esi
	movq	%rax, %rdi
	call	_Z5printPPfjj
	movq	%rbp, %rdi
	leaq	.LC16(%rip), %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	movl	$52, %edi
	call	_Znam@PLT
	subq	$32, %rsp
	.cfi_def_cfa_offset 96
	movups	40(%rsp), %xmm2
	movq	%rax, %rdi
	movq	56(%rsp), %rax
	movups	%xmm2, (%rsp)
	movq	%rax, 16(%rsp)
	call	_Z13gpuReciprocalPf6Params
	addq	$72, %rsp
	.cfi_def_cfa_offset 24
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3810:
	.size	main, .-main
	.section	.rodata.str1.1
.LC17:
	.string	"_Z16reciprocalKernelPfS_6Params"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB3839:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	pushq	$0
	.cfi_def_cfa_offset 24
	xorl	%r9d, %r9d
	orl	$-1, %r8d
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC17(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z16reciprocalKernelPfS_6Params(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 48
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFunction@PLT
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rdx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE3839:
	.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
	.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:

/*
 ============================================================================
 Name        : lab.cu
 Author      : 
 Version     :
 Copyright   : Your copyright notice
 Description : CUDA compute reciprocals
 ============================================================================
 */


#include <hip/hip_runtime.h>
#include <iostream>
#include <numeric>
#include <stdlib.h>
#include <fstream>

//#include <stdio.h>

static void CheckCudaErrorAux (const char *, unsigned, const char *, hipError_t);
#define CUDA_CHECK_RETURN(value) CheckCudaErrorAux(__FILE__,__LINE__, #value, value)

struct Params
{
	int length;
	int time;
	float dx;
	float dt;
	float startT;
	float endT;
};

void initialize(float **data, Params inParam)
{
	for (unsigned i = 0; i < inParam.time; ++i)
		data[i] = new float[inParam.length];
}

/**
 * CUDA kernel that computes reciprocal values for a given vector
 */
__global__ void reciprocalKernel(float *OldData,float *NewData, Params inParams) {
	unsigned idx = blockIdx.x*blockDim.x+threadIdx.x;
			if(idx == 0)
				NewData[idx] = inParams.startT;
			else if (idx == inParams.length - 1 )
				NewData[idx] = inParams.endT * inParams.dt + OldData[idx];
			else
			{
				NewData[idx] = ((OldData[idx+1] - 2 * OldData[idx] + OldData[idx-1])* inParams.dt)/inParams.dx * inParams.dx + OldData[idx];
			}

}

/**
 * Host function that copies the data and launches the work on GPU
 */
void gpuReciprocal(float *data, Params inParams)
{
	float *rc = new float[inParams.length];
	float *gpuOldData;
	float *gpuNewData;

	hipEvent_t GPUstart, GPUstop;
		float GPUtime = 0.0f;


		hipEventCreate(&GPUstart);
		hipEventCreate(&GPUstop);

	CUDA_CHECK_RETURN(hipMalloc((void **)&gpuOldData, sizeof(float)*inParams.length));
	CUDA_CHECK_RETURN(hipMemcpy(gpuOldData, rc, sizeof(float)*inParams.length, hipMemcpyHostToDevice));
	CUDA_CHECK_RETURN(hipMalloc((void **)&gpuNewData, sizeof(float)*inParams.length));
	CUDA_CHECK_RETURN(hipMemcpy(gpuNewData, data, sizeof(float)*inParams.length, hipMemcpyHostToDevice));
	
	static const int BLOCK_SIZE = 26;
	const int blockCount = 1;
	for(int i = 0; i < inParams.time; ++i)
	{
		hipEventRecord(GPUstart, 0);
		if (i % 2 == 0)
		{
			reciprocalKernel<<<blockCount, BLOCK_SIZE>>> (gpuOldData, gpuNewData, inParams);
			hipEventRecord(GPUstop, 0);
			CUDA_CHECK_RETURN(hipMemcpy(rc, gpuNewData, sizeof(float)*inParams.length, hipMemcpyDeviceToHost));

		}
			else
			{

			reciprocalKernel<<<blockCount, BLOCK_SIZE>>> (gpuNewData, gpuOldData, inParams);
			hipEventRecord(GPUstop, 0);
		    CUDA_CHECK_RETURN(hipMemcpy(rc, gpuOldData, sizeof(float)*inParams.length, hipMemcpyDeviceToHost));
			}

		hipEventSynchronize(GPUstop);

		std::cout << i <<": ";
		for(int i =0; i < inParams.length; ++i)
						std::cout << rc[i] << " ";
		std::cout << std::endl;
		float temp;
		hipEventElapsedTime(&temp,GPUstart, GPUstop);
		GPUtime += temp;

	}
	printf("GPU time = %.3f ms\n",GPUtime);
}

void initializeData(float* data, unsigned size,  float defaultValue)
{
	for(int i = 0; i < size; ++i)
		data[i] = defaultValue;
}



void print(float **a, unsigned h, unsigned w)
{
	for(int i = 0; i < h; ++i)
	{
		std::cout << i << ": ";
		for(int j = 0; j < w; ++j)
			std::cout << a[i][j] << " ";
		std::cout << std::endl;
	}

}


float **cpuReciprocal(float **data,Params inParams)
{
	float CPUstart, CPUstop;
	float CPUtime = 0.0f;

	float **cpuResult = new float*[inParams.time];
	initialize(cpuResult, inParams);

	float * currentData = cpuResult[0];
    initializeData(currentData, inParams.length, 0);


     currentData[0] = inParams.startT;

	for(int i =1; i < inParams.time; ++i)
	{
		cpuResult[i][0] = inParams.startT;
		for(int j = 1; j < inParams.length - 1; ++j)
		{
			cpuResult[i][j] = ((cpuResult[i-1][j+1] - 2 * cpuResult[i-1][j] + cpuResult[i-1][j-1])* inParams.dt)/inParams.dx * inParams.dx + cpuResult[i-1][j];
		}
		cpuResult[i][inParams.length-1] = inParams.endT * inParams.dt + cpuResult[i-1][inParams.length-1];
	}

	return cpuResult;
}






int main(void)
{
	Params mainParams;
	mainParams.length = 13;
	mainParams.time = 20;
	mainParams.dx = 0.5;
	mainParams.dt = 0.1;
	mainParams.startT = 0.0;
	mainParams.endT = 5.0;

	float **data;
	data = new float*[mainParams.time];
	initialize(data, mainParams);

	std::cout << "CPU" << std::endl;
	float **recCpu = cpuReciprocal(data, mainParams);
	print(recCpu, mainParams.time, mainParams.length);

	std::cout << "GPU" << std::endl;
	float *dataTwo;
	dataTwo = new float[mainParams.length];
	gpuReciprocal(dataTwo, mainParams);
	//print(recGpu, mainParams.time, mainParams.length);
//	float cpuSum = std::accumulate (recCpu, recCpu+WORK_SIZE, 0.0);
//	float gpuSum = std::accumulate (recGpu, recGpu+WORK_SIZE, 0.0);

	/* Verify the results */
	//std::cout<<"gpuSum = "<<gpuSum<< " cpuSum = " <<cpuSum<<std::endl;

	/* Free memory */
	//delete[] data;
	//delete[] recCpu;
	//delete[] recGpu;

	return 0;
}

/**
 * Check the return value of the CUDA runtime API call and exit
 * the application if the call has failed.
 */
static void CheckCudaErrorAux (const char *file, unsigned line, const char *statement, hipError_t err)
{
	if (err == hipSuccess)
		return;
	std::cerr << statement<<" returned " << hipGetErrorString(err) << "("<<err<< ") at "<<file<<":"<<line << std::endl;
	exit (1);
}


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

                                        # End of file scope inline assembly
	.globl	_Z10initializePPf6Params        # -- Begin function _Z10initializePPf6Params
	.type	_Z10initializePPf6Params,@function
_Z10initializePPf6Params:               # @_Z10initializePPf6Params
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r12
	.cfi_def_cfa_offset 32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	pushq	%rax
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -40
	.cfi_offset %r12, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movl	52(%rsp), %r15d
	testq	%r15, %r15
	je	.LBB0_3
# %bb.1:                                # %.lr.ph
	movq	%rdi, %rbx
	leaq	48(%rsp), %rax
	movslq	(%rax), %rax
	leaq	(,%rax,4), %rcx
	testq	%rax, %rax
	movq	$-1, %r14
	cmovnsq	%rcx, %r14
	xorl	%r12d, %r12d
.LBB0_2:                                # =>This Inner Loop Header: Depth=1
	movq	%r14, %rdi
	callq	_Znam
	movq	%rax, (%rbx,%r12,8)
	incq	%r12
	cmpq	%r12, %r15
	jne	.LBB0_2
.LBB0_3:                                # %._crit_edge
	addq	$8, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	_Z10initializePPf6Params, .Lfunc_end0-_Z10initializePPf6Params
	.cfi_endproc
                                        # -- End function
	.globl	_Z31__device_stub__reciprocalKernelPfS_6Params # -- Begin function _Z31__device_stub__reciprocalKernelPfS_6Params
	.type	_Z31__device_stub__reciprocalKernelPfS_6Params,@function
_Z31__device_stub__reciprocalKernelPfS_6Params: # @_Z31__device_stub__reciprocalKernelPfS_6Params
	.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	$96, %rsp
	.cfi_def_cfa_offset 144
	.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	144(%rsp), %rax
	movq	%rax, 16(%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	$_Z16reciprocalKernelPfS_6Params, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$112, %rsp
	.cfi_adjust_cfa_offset -112
	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__reciprocalKernelPfS_6Params, .Lfunc_end1-_Z31__device_stub__reciprocalKernelPfS_6Params
	.cfi_endproc
                                        # -- End function
	.globl	_Z13gpuReciprocalPf6Params      # -- Begin function _Z13gpuReciprocalPf6Params
	.type	_Z13gpuReciprocalPf6Params,@function
_Z13gpuReciprocalPf6Params:             # @_Z13gpuReciprocalPf6Params
	.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	$72, %rsp
	.cfi_def_cfa_offset 128
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rdi, %r15
	movslq	128(%rsp), %r13
	leaq	(,%r13,4), %rbx
	testq	%r13, %r13
	movq	$-1, %rdi
	cmovnsq	%rbx, %rdi
	callq	_Znam
	movq	%rax, %r14
	leaq	64(%rsp), %rdi
	callq	hipEventCreate
	leaq	24(%rsp), %rdi
	callq	hipEventCreate
	leaq	40(%rsp), %r12
	movq	%r12, %rdi
	movq	%rbx, %rsi
	callq	hipMalloc
	movl	$.L.str.1, %esi
	movl	$71, %edi
	movl	%eax, %edx
	callq	_ZL17CheckCudaErrorAuxPKcjS0_10hipError_t
	movq	(%r12), %rdi
	movq	%r14, %rsi
	movq	%rbx, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movl	$.L.str.2, %esi
	movl	$72, %edi
	movl	%eax, %edx
	callq	_ZL17CheckCudaErrorAuxPKcjS0_10hipError_t
	leaq	32(%rsp), %r12
	movq	%r12, %rdi
	movq	%rbx, %rsi
	callq	hipMalloc
	movl	$.L.str.3, %esi
	movl	$73, %edi
	movl	%eax, %edx
	callq	_ZL17CheckCudaErrorAuxPKcjS0_10hipError_t
	movq	(%r12), %rdi
	movq	%r15, %rsi
	movq	%rbx, 56(%rsp)                  # 8-byte Spill
	movq	%rbx, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movl	$.L.str.4, %esi
	movl	$74, %edi
	movl	%eax, %edx
	callq	_ZL17CheckCudaErrorAuxPKcjS0_10hipError_t
	movl	132(%rsp), %r12d
	testl	%r12d, %r12d
	jle	.LBB2_1
# %bb.4:                                # %.lr.ph35
	movl	%r13d, %ebp
	xorl	%r15d, %r15d
	xorps	%xmm0, %xmm0
	movabsq	$4294967297, %rax               # imm = 0x100000001
	leaq	25(%rax), %r13
.LBB2_5:                                # =>This Loop Header: Depth=1
                                        #     Child Loop BB2_14 Depth 2
	movss	%xmm0, 48(%rsp)                 # 4-byte Spill
	movq	64(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movabsq	$4294967297, %rdi               # imm = 0x100000001
	movl	$1, %esi
	movq	%r13, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testb	$1, %r15b
	jne	.LBB2_9
# %bb.6:                                #   in Loop: Header=BB2_5 Depth=1
	testl	%eax, %eax
	jne	.LBB2_8
# %bb.7:                                #   in Loop: Header=BB2_5 Depth=1
	movq	40(%rsp), %rdi
	movq	32(%rsp), %rsi
	leaq	128(%rsp), %rcx
	movq	16(%rcx), %rax
	movq	%rax, 16(%rsp)
	movups	(%rcx), %xmm0
	movups	%xmm0, (%rsp)
	callq	_Z31__device_stub__reciprocalKernelPfS_6Params
.LBB2_8:                                #   in Loop: Header=BB2_5 Depth=1
	movq	24(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	32(%rsp), %rsi
	movq	%r14, %rdi
	movq	56(%rsp), %rdx                  # 8-byte Reload
	movl	$2, %ecx
	callq	hipMemcpy
	movl	$.L.str.5, %esi
	movl	$85, %edi
	jmp	.LBB2_12
.LBB2_9:                                #   in Loop: Header=BB2_5 Depth=1
	testl	%eax, %eax
	jne	.LBB2_11
# %bb.10:                               #   in Loop: Header=BB2_5 Depth=1
	movq	32(%rsp), %rdi
	movq	40(%rsp), %rsi
	leaq	128(%rsp), %rcx
	movq	16(%rcx), %rax
	movq	%rax, 16(%rsp)
	movups	(%rcx), %xmm0
	movups	%xmm0, (%rsp)
	callq	_Z31__device_stub__reciprocalKernelPfS_6Params
.LBB2_11:                               #   in Loop: Header=BB2_5 Depth=1
	movq	24(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	40(%rsp), %rsi
	movq	%r14, %rdi
	movq	56(%rsp), %rdx                  # 8-byte Reload
	movl	$2, %ecx
	callq	hipMemcpy
	movl	$.L.str.6, %esi
	movl	$93, %edi
.LBB2_12:                               #   in Loop: Header=BB2_5 Depth=1
	movl	%eax, %edx
	callq	_ZL17CheckCudaErrorAuxPKcjS0_10hipError_t
	movq	24(%rsp), %rdi
	callq	hipEventSynchronize
	movl	$_ZSt4cout, %edi
	movl	%r15d, %esi
	callq	_ZNSolsEi
	movl	$.L.str.7, %esi
	movl	$2, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	testl	%ebp, %ebp
	jle	.LBB2_15
# %bb.13:                               # %.lr.ph.preheader
                                        #   in Loop: Header=BB2_5 Depth=1
	xorl	%ebx, %ebx
.LBB2_14:                               # %.lr.ph
                                        #   Parent Loop BB2_5 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	xorps	%xmm0, %xmm0
	cvtss2sd	(%r14,%rbx,4), %xmm0
	movl	$_ZSt4cout, %edi
	callq	_ZNSo9_M_insertIdEERSoT_
	movl	$.L.str.8, %esi
	movl	$1, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	incq	%rbx
	cmpq	%rbx, %rbp
	jne	.LBB2_14
.LBB2_15:                               # %._crit_edge
                                        #   in Loop: Header=BB2_5 Depth=1
	movq	_ZSt4cout(%rip), %rax
	movq	-24(%rax), %rdi
	movl	$_ZSt4cout, %eax
	addq	%rax, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	movq	64(%rsp), %rsi
	movq	24(%rsp), %rdx
	leaq	52(%rsp), %rdi
	callq	hipEventElapsedTime
	movss	48(%rsp), %xmm0                 # 4-byte Reload
                                        # xmm0 = mem[0],zero,zero,zero
	addss	52(%rsp), %xmm0
	incl	%r15d
	cmpl	%r12d, %r15d
	jne	.LBB2_5
# %bb.2:                                # %._crit_edge36.loopexit
	cvtss2sd	%xmm0, %xmm0
	jmp	.LBB2_3
.LBB2_1:
	xorps	%xmm0, %xmm0
.LBB2_3:                                # %._crit_edge36
	movl	$.L.str.9, %edi
	movb	$1, %al
	callq	printf
	addq	$72, %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_end2:
	.size	_Z13gpuReciprocalPf6Params, .Lfunc_end2-_Z13gpuReciprocalPf6Params
	.cfi_endproc
                                        # -- End function
	.type	_ZL17CheckCudaErrorAuxPKcjS0_10hipError_t,@function # -- Begin function _ZL17CheckCudaErrorAuxPKcjS0_10hipError_t
_ZL17CheckCudaErrorAuxPKcjS0_10hipError_t: # @_ZL17CheckCudaErrorAuxPKcjS0_10hipError_t
	.cfi_startproc
# %bb.0:
	testl	%edx, %edx
	jne	.LBB3_2
# %bb.1:
	retq
.LBB3_2:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %rbp, -16
	movl	%edx, %ebp
	movl	%edi, %ebx
	movl	$_ZSt4cerr, %edi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movl	$.L.str.12, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %r14
	movl	%ebp, %edi
	callq	hipGetErrorString
	movq	%r14, %rdi
	movq	%rax, %rsi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movl	$.L.str.13, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rdi
	movl	%ebp, %esi
	callq	_ZNSolsEi
	movl	$.L.str.14, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movl	$.L.str, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movl	$.L.str.15, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rdi
	movl	%ebx, %esi
	callq	_ZNSolsEj
	movq	%rax, %rdi
	callq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_
	movl	$1, %edi
	callq	exit
.Lfunc_end3:
	.size	_ZL17CheckCudaErrorAuxPKcjS0_10hipError_t, .Lfunc_end3-_ZL17CheckCudaErrorAuxPKcjS0_10hipError_t
	.cfi_endproc
                                        # -- End function
	.globl	_Z14initializeDataPfjf          # -- Begin function _Z14initializeDataPfjf
	.type	_Z14initializeDataPfjf,@function
_Z14initializeDataPfjf:                 # @_Z14initializeDataPfjf
	.cfi_startproc
# %bb.0:
	testl	%esi, %esi
	je	.LBB4_3
# %bb.1:                                # %.lr.ph.preheader
	movl	%esi, %eax
	xorl	%ecx, %ecx
.LBB4_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movss	%xmm0, (%rdi,%rcx,4)
	incq	%rcx
	cmpq	%rcx, %rax
	jne	.LBB4_2
.LBB4_3:                                # %._crit_edge
	retq
.Lfunc_end4:
	.size	_Z14initializeDataPfjf, .Lfunc_end4-_Z14initializeDataPfjf
	.cfi_endproc
                                        # -- End function
	.globl	_Z5printPPfjj                   # -- Begin function _Z5printPPfjj
	.type	_Z5printPPfjj,@function
_Z5printPPfjj:                          # @_Z5printPPfjj
	.cfi_startproc
# %bb.0:
	testl	%esi, %esi
	je	.LBB5_7
# %bb.1:                                # %.lr.ph13
	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
	pushq	%rax
	.cfi_def_cfa_offset 64
	.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, %ebx
	movq	%rdi, %r14
	movl	%esi, %r12d
	movl	%edx, %r13d
	xorl	%r15d, %r15d
.LBB5_2:                                # =>This Loop Header: Depth=1
                                        #     Child Loop BB5_4 Depth 2
	movl	$_ZSt4cout, %edi
	movl	%r15d, %esi
	callq	_ZNSolsEi
	movl	$.L.str.7, %esi
	movl	$2, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	testl	%ebx, %ebx
	je	.LBB5_5
# %bb.3:                                # %.lr.ph
                                        #   in Loop: Header=BB5_2 Depth=1
	xorl	%ebp, %ebp
.LBB5_4:                                #   Parent Loop BB5_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movq	(%r14,%r15,8), %rax
	xorps	%xmm0, %xmm0
	cvtss2sd	(%rax,%rbp,4), %xmm0
	movl	$_ZSt4cout, %edi
	callq	_ZNSo9_M_insertIdEERSoT_
	movl	$.L.str.8, %esi
	movl	$1, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	incq	%rbp
	cmpq	%rbp, %r13
	jne	.LBB5_4
.LBB5_5:                                # %._crit_edge
                                        #   in Loop: Header=BB5_2 Depth=1
	movq	_ZSt4cout(%rip), %rax
	movq	-24(%rax), %rdi
	movl	$_ZSt4cout, %eax
	addq	%rax, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	incq	%r15
	cmpq	%r12, %r15
	jne	.LBB5_2
# %bb.6:
	addq	$8, %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
	.cfi_restore %rbx
	.cfi_restore %r12
	.cfi_restore %r13
	.cfi_restore %r14
	.cfi_restore %r15
	.cfi_restore %rbp
.LBB5_7:                                # %._crit_edge14
	retq
.Lfunc_end5:
	.size	_Z5printPPfjj, .Lfunc_end5-_Z5printPPfjj
	.cfi_endproc
                                        # -- End function
	.globl	_Z13cpuReciprocalPPf6Params     # -- Begin function _Z13cpuReciprocalPPf6Params
	.type	_Z13cpuReciprocalPPf6Params,@function
_Z13cpuReciprocalPPf6Params:            # @_Z13cpuReciprocalPPf6Params
	.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
	pushq	%rax
	.cfi_def_cfa_offset 64
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movslq	68(%rsp), %r14
	leaq	(,%r14,8), %rdi
	testq	%r14, %r14
	movq	$-1, %rbp
	cmovsq	%rbp, %rdi
	callq	_Znam
	movq	%rax, %rbx
	movl	%r14d, %r15d
	movslq	64(%rsp), %r12
	movl	%r12d, %r13d
	testq	%r14, %r14
	je	.LBB6_1
# %bb.2:                                # %.lr.ph.i
	leaq	(,%r12,4), %r14
	testl	%r12d, %r12d
	cmovsq	%rbp, %r14
	xorl	%ebp, %ebp
.LBB6_3:                                # =>This Inner Loop Header: Depth=1
	movq	%r14, %rdi
	callq	_Znam
	movq	%rax, (%rbx,%rbp,8)
	incq	%rbp
	cmpq	%rbp, %r15
	jne	.LBB6_3
# %bb.4:                                # %_Z10initializePPf6Params.exit.loopexit
	movq	(%rbx), %r14
	jmp	.LBB6_5
.LBB6_1:
                                        # implicit-def: $r14
.LBB6_5:                                # %_Z10initializePPf6Params.exit
	leaq	64(%rsp), %rbp
	testq	%r13, %r13
	je	.LBB6_7
# %bb.6:                                # %.lr.ph.preheader.i
	leaq	(,%r13,4), %rdx
	movq	%r14, %rdi
	xorl	%esi, %esi
	callq	memset@PLT
.LBB6_7:                                # %_Z14initializeDataPfjf.exit
	movss	16(%rbp), %xmm0                 # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, (%r14)
	cmpl	$2, %r15d
	jl	.LBB6_13
# %bb.8:                                # %.lr.ph40
	decl	%r13d
	movss	8(%rbp), %xmm1                  # xmm1 = mem[0],zero,zero,zero
	movss	12(%rbp), %xmm2                 # xmm2 = mem[0],zero,zero,zero
	movss	20(%rbp), %xmm3                 # xmm3 = mem[0],zero,zero,zero
	mulss	%xmm2, %xmm3
	movslq	%r13d, %rax
	movl	$1, %ecx
.LBB6_9:                                # =>This Loop Header: Depth=1
                                        #     Child Loop BB6_11 Depth 2
	movq	(%rbx,%rcx,8), %rdx
	movss	%xmm0, (%rdx)
	movq	-8(%rbx,%rcx,8), %rsi
	cmpl	$3, %r12d
	jl	.LBB6_12
# %bb.10:                               # %.lr.ph.preheader
                                        #   in Loop: Header=BB6_9 Depth=1
	movl	$1, %edi
.LBB6_11:                               # %.lr.ph
                                        #   Parent Loop BB6_9 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movss	(%rsi,%rdi,4), %xmm4            # xmm4 = mem[0],zero,zero,zero
	movss	4(%rsi,%rdi,4), %xmm5           # xmm5 = mem[0],zero,zero,zero
	movaps	%xmm4, %xmm6
	addss	%xmm4, %xmm6
	subss	%xmm6, %xmm5
	addss	-4(%rsi,%rdi,4), %xmm5
	mulss	%xmm2, %xmm5
	divss	%xmm1, %xmm5
	mulss	%xmm1, %xmm5
	addss	%xmm4, %xmm5
	movss	%xmm5, (%rdx,%rdi,4)
	leaq	1(%rdi), %r8
	movq	%r8, %rdi
	cmpq	%r8, %r13
	jne	.LBB6_11
.LBB6_12:                               # %._crit_edge
                                        #   in Loop: Header=BB6_9 Depth=1
	movss	(%rsi,%rax,4), %xmm4            # xmm4 = mem[0],zero,zero,zero
	addss	%xmm3, %xmm4
	movss	%xmm4, (%rdx,%rax,4)
	incq	%rcx
	cmpq	%r15, %rcx
	jne	.LBB6_9
.LBB6_13:                               # %._crit_edge41
	movq	%rbx, %rax
	addq	$8, %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_end6:
	.size	_Z13cpuReciprocalPPf6Params, .Lfunc_end6-_Z13cpuReciprocalPPf6Params
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0                          # -- Begin function main
.LCPI7_0:
	.long	0x3f000000                      # float 0.5
	.long	0x3dcccccd                      # float 0.100000001
	.long	0x00000000                      # float 0
	.long	0x40a00000                      # float 5
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:                                # %.lr.ph.i
	movl	$20, %eax
.LBB7_1:                                # =>This Inner Loop Header: Depth=1
	decq	%rax
	jne	.LBB7_1
# %bb.2:                                # %_Z10initializePPf6Params.exit
	pushq	%r14
	.cfi_def_cfa_offset 16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	subq	$72, %rsp
	.cfi_def_cfa_offset 96
	.cfi_offset %rbx, -24
	.cfi_offset %r14, -16
	movl	$_ZSt4cout, %ebx
	movl	$_ZSt4cout, %edi
	movl	$.L.str.10, %esi
	movl	$3, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	_ZSt4cout(%rip), %rax
	movq	-24(%rax), %rdi
	addq	%rbx, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	movabsq	$85899345933, %r14              # imm = 0x140000000D
	movq	%r14, 48(%rsp)
	movaps	.LCPI7_0(%rip), %xmm0           # xmm0 = [5.0E-1,1.00000001E-1,0.0E+0,5.0E+0]
	movups	%xmm0, 56(%rsp)
	movq	64(%rsp), %rax
	movq	%rax, 16(%rsp)
	movups	48(%rsp), %xmm0
	movups	%xmm0, (%rsp)
	callq	_Z13cpuReciprocalPPf6Params
	movq	%rax, %rdi
	movl	$20, %esi
	movl	$13, %edx
	callq	_Z5printPPfjj
	movl	$_ZSt4cout, %edi
	movl	$.L.str.11, %esi
	movl	$3, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	_ZSt4cout(%rip), %rax
	movq	-24(%rax), %rdi
	addq	%rbx, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	movl	$52, %edi
	callq	_Znam
	movq	%r14, 24(%rsp)
	movaps	.LCPI7_0(%rip), %xmm0           # xmm0 = [5.0E-1,1.00000001E-1,0.0E+0,5.0E+0]
	movups	%xmm0, 32(%rsp)
	movq	40(%rsp), %rcx
	movq	%rcx, 16(%rsp)
	movups	24(%rsp), %xmm0
	movups	%xmm0, (%rsp)
	movq	%rax, %rdi
	callq	_Z13gpuReciprocalPf6Params
	xorl	%eax, %eax
	addq	$72, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.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:
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	jne	.LBB8_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB8_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z16reciprocalKernelPfS_6Params, %esi
	movl	$.L__unnamed_1, %edx
	movl	$.L__unnamed_1, %ecx
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$__hip_module_dtor, %edi
	addq	$40, %rsp
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_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	_Z16reciprocalKernelPfS_6Params,@object # @_Z16reciprocalKernelPfS_6Params
	.section	.rodata,"a",@progbits
	.globl	_Z16reciprocalKernelPfS_6Params
	.p2align	3, 0x0
_Z16reciprocalKernelPfS_6Params:
	.quad	_Z31__device_stub__reciprocalKernelPfS_6Params
	.size	_Z16reciprocalKernelPfS_6Params, 8

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"/home/ubuntu/Datasets/stackv2/train-structured-repos-hip-sm89/sudoHackIn/CUDA/master/lab.hip"
	.size	.L.str, 93

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"hipMalloc((void **)&gpuOldData, sizeof(float)*inParams.length)"
	.size	.L.str.1, 63

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"hipMemcpy(gpuOldData, rc, sizeof(float)*inParams.length, hipMemcpyHostToDevice)"
	.size	.L.str.2, 80

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"hipMalloc((void **)&gpuNewData, sizeof(float)*inParams.length)"
	.size	.L.str.3, 63

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"hipMemcpy(gpuNewData, data, sizeof(float)*inParams.length, hipMemcpyHostToDevice)"
	.size	.L.str.4, 82

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"hipMemcpy(rc, gpuNewData, sizeof(float)*inParams.length, hipMemcpyDeviceToHost)"
	.size	.L.str.5, 80

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"hipMemcpy(rc, gpuOldData, sizeof(float)*inParams.length, hipMemcpyDeviceToHost)"
	.size	.L.str.6, 80

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	": "
	.size	.L.str.7, 3

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	" "
	.size	.L.str.8, 2

	.type	.L.str.9,@object                # @.str.9
.L.str.9:
	.asciz	"GPU time = %.3f ms\n"
	.size	.L.str.9, 20

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

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

	.type	.L.str.12,@object               # @.str.12
.L.str.12:
	.asciz	" returned "
	.size	.L.str.12, 11

	.type	.L.str.13,@object               # @.str.13
.L.str.13:
	.asciz	"("
	.size	.L.str.13, 2

	.type	.L.str.14,@object               # @.str.14
.L.str.14:
	.asciz	") at "
	.size	.L.str.14, 6

	.type	.L.str.15,@object               # @.str.15
.L.str.15:
	.asciz	":"
	.size	.L.str.15, 2

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z16reciprocalKernelPfS_6Params"
	.size	.L__unnamed_1, 32

	.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 _Z31__device_stub__reciprocalKernelPfS_6Params
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z16reciprocalKernelPfS_6Params
	.addrsig_sym _ZSt4cout
	.addrsig_sym _ZSt4cerr
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z16reciprocalKernelPfS_6Params ; -- Begin function _Z16reciprocalKernelPfS_6Params
	.globl	_Z16reciprocalKernelPfS_6Params
	.p2align	8
	.type	_Z16reciprocalKernelPfS_6Params,@function
_Z16reciprocalKernelPfS_6Params:        ; @_Z16reciprocalKernelPfS_6Params
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x34
	s_load_b128 s[4:7], s[0:1], 0x0
	s_waitcnt lgkmcnt(0)
	s_and_b32 s2, s2, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s15, s2, v[0:1]
	s_mov_b32 s2, exec_lo
	v_cmpx_ne_u32_e32 0, v1
	s_xor_b32 s10, exec_lo, s2
	s_cbranch_execz .LBB0_6
; %bb.1:
	s_clause 0x1
	s_load_b32 s11, s[0:1], 0x10
	s_load_b64 s[2:3], s[0:1], 0x18
	s_add_u32 s8, s0, 16
	s_addc_u32 s9, s1, 0
	s_waitcnt lgkmcnt(0)
	s_add_i32 s11, s11, -1
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(SALU_CYCLE_1)
	v_cmp_ne_u32_e32 vcc_lo, s11, v1
	s_and_saveexec_b32 s11, vcc_lo
	s_xor_b32 s11, exec_lo, s11
	s_cbranch_execz .LBB0_3
; %bb.2:
	v_dual_mov_b32 v4, 0 :: v_dual_add_nc_u32 v3, 1, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_mov_b32_e32 v2, v4
	v_lshlrev_b64 v[5:6], 2, v[3:4]
	v_add_nc_u32_e32 v3, -1, v1
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_lshlrev_b64 v[0:1], 2, v[1:2]
	v_lshlrev_b64 v[2:3], 2, v[3:4]
	s_delay_alu instid0(VALU_DEP_4) | instskip(SKIP_1) | instid1(VALU_DEP_4)
	v_add_co_u32 v4, vcc_lo, s4, v5
	v_add_co_ci_u32_e32 v5, vcc_lo, s5, v6, vcc_lo
	v_add_co_u32 v6, vcc_lo, s4, v0
	v_add_co_ci_u32_e32 v7, vcc_lo, s5, v1, vcc_lo
	v_add_co_u32 v2, vcc_lo, s4, v2
	v_add_co_ci_u32_e32 v3, vcc_lo, s5, v3, vcc_lo
	s_clause 0x2
	global_load_b32 v4, v[4:5], off
	global_load_b32 v5, v[6:7], off
	global_load_b32 v2, v[2:3], off
	s_waitcnt vmcnt(1)
	v_fmac_f32_e32 v4, -2.0, v5
	s_waitcnt vmcnt(0)
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f32_e32 v2, v2, v4
	v_mul_f32_e32 v2, s3, v2
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_div_scale_f32 v3, null, s2, s2, v2
	v_div_scale_f32 v7, vcc_lo, v2, s2, v2
	v_rcp_f32_e32 v4, v3
	s_waitcnt_depctr 0xfff
	v_fma_f32 v6, -v3, v4, 1.0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fmac_f32_e32 v4, v6, v4
	v_mul_f32_e32 v6, v7, v4
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f32 v8, -v3, v6, v7
	v_fmac_f32_e32 v6, v8, v4
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f32 v3, -v3, v6, v7
	v_div_fmas_f32 v3, v3, v4, v6
	v_add_co_u32 v0, vcc_lo, s6, v0
	v_add_co_ci_u32_e32 v1, vcc_lo, s7, v1, vcc_lo
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_div_fixup_f32 v2, v3, s2, v2
	v_fmac_f32_e32 v5, s2, v2
	global_store_b32 v[0:1], v5, off
                                        ; implicit-def: $vgpr1_vgpr2
.LBB0_3:                                ; %Flow
	s_and_not1_saveexec_b32 s2, s11
	s_cbranch_execz .LBB0_5
; %bb.4:
	v_mov_b32_e32 v2, 0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[0:1], 2, v[1:2]
	v_add_co_u32 v2, vcc_lo, s4, v0
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v3, vcc_lo, s5, v1, vcc_lo
	s_load_b32 s4, s[8:9], 0x14
	v_add_co_u32 v0, vcc_lo, s6, v0
	global_load_b32 v2, v[2:3], off
	v_add_co_ci_u32_e32 v1, vcc_lo, s7, v1, vcc_lo
	s_waitcnt vmcnt(0) lgkmcnt(0)
	v_fmac_f32_e64 v2, s3, s4
	global_store_b32 v[0:1], v2, off
.LBB0_5:                                ; %Flow30
	s_or_b32 exec_lo, exec_lo, s2
.LBB0_6:                                ; %Flow31
	s_and_not1_saveexec_b32 s2, s10
	s_cbranch_execz .LBB0_8
; %bb.7:
	s_load_b32 s0, s[0:1], 0x20
	s_waitcnt lgkmcnt(0)
	v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, s0
	global_store_b32 v0, v1, s[6:7]
.LBB0_8:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z16reciprocalKernelPfS_6Params
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 296
		.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_end0:
	.size	_Z16reciprocalKernelPfS_6Params, .Lfunc_end0-_Z16reciprocalKernelPfS_6Params
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 516
; NumSgprs: 18
; NumVgprs: 9
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 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
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __hip_cuid_
	.amdgpu_metadata
---
amdhsa.kernels:
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .offset:         16
        .size:           24
        .value_kind:     by_value
      - .offset:         40
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         44
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         48
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         52
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         54
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         56
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         58
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         60
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         62
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         88
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         96
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         104
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 296
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z16reciprocalKernelPfS_6Params
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z16reciprocalKernelPfS_6Params.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
