//Parallel Programming Final Project (CUDA)
//Team: 22
//ver 2.4		2018/12/16	21:15

#include <iostream>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <time.h>
#include <cuda.h>


using namespace std;

int NUM_STEPS;
int NUM_DATA;
double 	*C_gpu,
		*P_gpu,
		*C_price_gpu,
		*P_price_gpu;

struct data {
    double K; 
    double S;
    double r;
    double v;
    double T;
	double dt;
	double vdt;
	double u;
	double d;
	double p;
	double* last_C;
	double* last_P;
	double C_price;
	double P_price;
}; 

typedef struct data option_data;



void init(option_data *in){
    in->r = 0.005 ;   // Risk-free rate (5%)
    in->v = 0.3 ;    // Volatility of the underlying (20%)
    in->T = 1.0;   // One year until expiry
	in->dt = in->T/NUM_STEPS;
	in->vdt = in->v*sqrt(in->dt);
	in->u = exp(in->vdt);
	in->d = 1/in->u;
	in->p = (exp(in->r*in->dt)-in->d)/(in->u-in->d);
	in->last_C = new double [NUM_STEPS+1];
	in->last_P = new double [NUM_STEPS+1];
}

//Call Option 認購期權
double CallOption(const double& S,const double& K,const double& vDt,const int& i){
	double d = S * exp(vDt * (2.0 * i - NUM_STEPS)) - K;      
	return max(d,(double)0); 
}

//Put Option 認沽期權
double PutOption(const double& S,const double& K,const double& vDt,const int& i){
	double d = K-S * exp(vDt * (2.0 * i - NUM_STEPS));          
	return max(d,(double)0); 
}

void last_step_price(option_data* temp_data,int NUM_STEPS){
	for(int k = 0; k <=NUM_STEPS; k++){
		double sd = temp_data->S * exp(temp_data->vdt * (2.0 * (NUM_STEPS-k) - NUM_STEPS)) ; 
		
		temp_data->last_C[k] = max(sd-temp_data->K,(double)0);
		temp_data->last_P[k] = max(temp_data->K-sd,(double)0);
	}
	
	return;
}


/*
__global__ void trace_back_gpu(double* C_option, double* P_option, double* C_price, double* P_price, double r, double dt, double p, int NUM_DATA, int NUM_STEPS){
	int x = blockIdx.x * blockDim.x + threadIdx.x;
	int y = blockIdx.y * blockDim.y + threadIdx.y;
	
	__shared__ double data_c[2000];
	__shared__ double data_p[2000];

	for(int i=0; i<(NUM_STEPS+1); i++){
		data_c[i] = C_option[x*(NUM_STEPS+1)+i];
		data_p[i] = P_option[x*(NUM_STEPS+1)+i];
	}
	__syncthreads();
	if(x<NUM_DATA && y<NUM_STEPS){

		for(int t = 0; t < NUM_STEPS; ++t){
			data_c[y] = exp(-r*dt) * (p*data_c[y] + (1-p)*data_c[y+1]);
			data_p[y] = exp(-r*dt) * (p*data_p[y] + (1-p)*data_p[y+1]);
			__syncthreads();
		}
	}

	C_price[x] = data_c[0];	
	P_price[x] = data_p[0];



	return;
}
*/
__global__ void trace_back_gpu(double* C_option, double* P_option, double* C_price, double* P_price, double r, double dt, double p, int NUM_DATA, int NUM_STEPS){
	int x = blockIdx.x * blockDim.x + threadIdx.x;
	int y = blockIdx.y * blockDim.y + threadIdx.y;
	
	__shared__ double data[4000];
	
	for(int i=0; i<(NUM_STEPS+1); i++){
		data[i] = C_option[x*(NUM_STEPS+1)+i];
	}
	for(int i=0; i<(NUM_STEPS+1); i++){
		data[i+(NUM_STEPS+1)] = P_option[x*(NUM_STEPS+1)+i];
	}
	
	__syncthreads();
	if(x<NUM_DATA && y<NUM_STEPS){

		for(int t = 0; t < NUM_STEPS; ++t){
			data[y] = exp(-r*dt) * (p*data[y] + (1-p)*data[y+1]);
			data[y+(NUM_STEPS+1)] = exp(-r*dt) * (p*data[y+(NUM_STEPS+1)] + (1-p)*data[y+1+(NUM_STEPS+1)]);
			__syncthreads();
		}
	}

	C_price[x] = data[0];	
	P_price[x] = data[NUM_STEPS+1];



	return;
}


int main(int argc, char **argv){
	if(argc!=3){
		cout << "Input error!\n";
		cout << "./project <NUM_STEPS> <DATA_FILE>\n";
		return 1;
	}
	sscanf(argv[1],"%d",&NUM_STEPS);
	ifstream infile(argv[2]);
	if(!infile) {
		cout << "Can not open input file!\n";
		return 1;
	}
	
	infile >> NUM_DATA;
	cout << "num_data = " << NUM_DATA << endl;
	cout << "num_step = " << NUM_STEPS << endl;
    
	size_t size = ((NUM_STEPS+1)*NUM_DATA)*sizeof(double);
	vector<option_data*> option_vector;
	
	for(int i = 0; i < NUM_DATA; ++i){
		double K, S; 
		infile >> K >> S;
	    option_data *temp_data = new option_data();
		init(temp_data);
		temp_data->K = K;
		temp_data->S = S;
		
		last_step_price(temp_data,NUM_STEPS);
        option_vector.push_back(temp_data);
	}

	double** C_matrix = new double*[NUM_DATA];
	double** P_matrix = new double*[NUM_DATA];
	double* C_array = new double[(NUM_STEPS+1)*NUM_DATA];
	double* P_array = new double[(NUM_STEPS+1)*NUM_DATA];
	
	for(int i = 0; i < NUM_DATA; ++i){
		C_matrix[i] = option_vector[i]->last_C;
		P_matrix[i] = option_vector[i]->last_P;
		for(int j = 0; j < NUM_STEPS+1; ++j){
			C_array[i*(NUM_STEPS+1)+j] = C_matrix[i][j];
			P_array[i*(NUM_STEPS+1)+j] = P_matrix[i][j];
		}
	}

	double r = option_vector[0]->r;
	double dt = option_vector[0]->dt;
	double p = option_vector[0]->p;
	double C_price[NUM_DATA];
	double P_price[NUM_DATA];
	


	dim3 dimBlock(1,NUM_STEPS);
	dim3 dimGrid(NUM_DATA,1);
    
	cudaMalloc((void**)&C_gpu, size);
	cudaMalloc((void**)&P_gpu, size);
	cudaMalloc((void**)&C_price_gpu, NUM_DATA*sizeof(double));
	cudaMalloc((void**)&P_price_gpu, NUM_DATA*sizeof(double));
	cudaMemcpy(C_gpu, C_array, size, cudaMemcpyHostToDevice);
	cudaMemcpy(P_gpu, P_array, size, cudaMemcpyHostToDevice);
	trace_back_gpu<<<dimGrid,dimBlock,(NUM_STEPS+1)*sizeof(double)>>>(C_gpu, P_gpu, C_price_gpu, P_price_gpu, r, dt, p, NUM_DATA, NUM_STEPS);
	cudaMemcpy(C_price, C_price_gpu, NUM_DATA*sizeof(double), cudaMemcpyDeviceToHost);
	cudaMemcpy(P_price, P_price_gpu, NUM_DATA*sizeof(double), cudaMemcpyDeviceToHost);
	
	//print
	for(int i =0;i<NUM_DATA;i++){
	    option_data* print_price = option_vector[i];
		printf("Data %d: Call Price: %.5f\tPut Price: %.5f\n", i, C_price[i], P_price[i]);
	}
	
	return 0;
}

	.file	"tmpxft_00384bca_00000000-6_project_cuda_data_step.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB4146:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE4146:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z4initP4data
	.type	_Z4initP4data, @function
_Z4initP4data:
.LFB4129:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movabsq	$1152921504606846975, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	movq	%rdi, %rbx
	subq	$32, %rsp
	.cfi_def_cfa_offset 64
	movl	NUM_STEPS(%rip), %ebp
	movsd	.LC2(%rip), %xmm2
	movq	.LC0(%rip), %rax
	cvtsi2sdl	%ebp, %xmm0
	movaps	%xmm2, %xmm3
	movsd	%xmm2, 32(%rdi)
	incl	%ebp
	movq	%rax, 16(%rdi)
	movq	.LC1(%rip), %rax
	movslq	%ebp, %rbp
	movq	%rax, 24(%rdi)
	divsd	%xmm0, %xmm3
	movsd	%xmm3, 40(%rdi)
	movaps	%xmm3, %xmm0
	movsd	%xmm3, 24(%rsp)
	call	sqrt@PLT
	mulsd	.LC1(%rip), %xmm0
	movsd	%xmm0, 48(%rbx)
	call	exp@PLT
	movsd	.LC2(%rip), %xmm2
	movsd	24(%rsp), %xmm3
	movsd	%xmm0, 56(%rbx)
	divsd	%xmm0, %xmm2
	movsd	%xmm0, 16(%rsp)
	movsd	.LC0(%rip), %xmm0
	mulsd	%xmm3, %xmm0
	movsd	%xmm2, 64(%rbx)
	movsd	%xmm2, 8(%rsp)
	call	exp@PLT
	movsd	8(%rsp), %xmm2
	movsd	16(%rsp), %xmm1
	subsd	%xmm2, %xmm0
	subsd	%xmm2, %xmm1
	divsd	%xmm1, %xmm0
	movsd	%xmm0, 72(%rbx)
	cmpq	%rbp, %r12
	jb	.L3
	leaq	0(,%rbp,8), %rdi
	call	_Znam@PLT
	movq	%rax, 80(%rbx)
	movl	NUM_STEPS(%rip), %eax
	leal	1(%rax), %edi
	movslq	%edi, %rdi
	cmpq	%rdi, %r12
	jnb	.L4
.L3:
	call	__cxa_throw_bad_array_new_length@PLT
.L4:
	salq	$3, %rdi
	call	_Znam@PLT
	movq	%rax, 88(%rbx)
	addq	$32, %rsp
	.cfi_def_cfa_offset 32
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE4129:
	.size	_Z4initP4data, .-_Z4initP4data
	.globl	_Z10CallOptionRKdS0_S0_RKi
	.type	_Z10CallOptionRKdS0_S0_RKi, @function
_Z10CallOptionRKdS0_S0_RKi:
.LFB4130:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	movq	%rsi, %rbx
	subq	$16, %rsp
	.cfi_def_cfa_offset 32
	cvtsi2sdl	(%rcx), %xmm0
	movsd	(%rdi), %xmm2
	cvtsi2sdl	NUM_STEPS(%rip), %xmm1
	movsd	%xmm2, 8(%rsp)
	addsd	%xmm0, %xmm0
	subsd	%xmm1, %xmm0
	mulsd	(%rdx), %xmm0
	call	exp@PLT
	mulsd	8(%rsp), %xmm0
	xorps	%xmm1, %xmm1
	subsd	(%rbx), %xmm0
	addq	$16, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	fmax@PLT
	.cfi_endproc
.LFE4130:
	.size	_Z10CallOptionRKdS0_S0_RKi, .-_Z10CallOptionRKdS0_S0_RKi
	.globl	_Z9PutOptionRKdS0_S0_RKi
	.type	_Z9PutOptionRKdS0_S0_RKi, @function
_Z9PutOptionRKdS0_S0_RKi:
.LFB4131:
	.cfi_startproc
	endbr64
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	cvtsi2sdl	(%rcx), %xmm0
	movsd	(%rsi), %xmm1
	cvtsi2sdl	NUM_STEPS(%rip), %xmm2
	movsd	(%rdi), %xmm3
	movsd	%xmm1, 8(%rsp)
	movsd	%xmm3, (%rsp)
	addsd	%xmm0, %xmm0
	subsd	%xmm2, %xmm0
	mulsd	(%rdx), %xmm0
	call	exp@PLT
	movsd	(%rsp), %xmm2
	movsd	8(%rsp), %xmm1
	addq	$24, %rsp
	.cfi_def_cfa_offset 8
	mulsd	%xmm0, %xmm2
	subsd	%xmm2, %xmm1
	movaps	%xmm1, %xmm0
	xorps	%xmm1, %xmm1
	jmp	fmax@PLT
	.cfi_endproc
.LFE4131:
	.size	_Z9PutOptionRKdS0_S0_RKi, .-_Z9PutOptionRKdS0_S0_RKi
	.globl	_Z15last_step_priceP4datai
	.type	_Z15last_step_priceP4datai, @function
_Z15last_step_priceP4datai:
.LFB4132:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movl	%esi, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	xorl	%ebp, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	movq	%rdi, %rbx
	subq	$16, %rsp
	.cfi_def_cfa_offset 48
.L12:
	cmpl	%ebp, %r12d
	jl	.L15
	movl	%r12d, %eax
	cvtsi2sdl	%r12d, %xmm1
	movsd	8(%rbx), %xmm3
	subl	%ebp, %eax
	cvtsi2sdl	%eax, %xmm0
	movsd	%xmm3, 8(%rsp)
	addsd	%xmm0, %xmm0
	subsd	%xmm1, %xmm0
	mulsd	48(%rbx), %xmm0
	call	exp@PLT
	movsd	8(%rsp), %xmm2
	xorps	%xmm1, %xmm1
	mulsd	%xmm0, %xmm2
	movaps	%xmm2, %xmm0
	subsd	(%rbx), %xmm0
	movsd	%xmm2, 8(%rsp)
	call	fmax@PLT
	movq	80(%rbx), %rax
	movsd	8(%rsp), %xmm2
	xorps	%xmm1, %xmm1
	movsd	%xmm0, (%rax,%rbp,8)
	movsd	(%rbx), %xmm0
	subsd	%xmm2, %xmm0
	call	fmax@PLT
	movq	88(%rbx), %rax
	movsd	%xmm0, (%rax,%rbp,8)
	incq	%rbp
	jmp	.L12
.L15:
	addq	$16, %rsp
	.cfi_def_cfa_offset 32
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE4132:
	.size	_Z15last_step_priceP4datai, .-_Z15last_step_priceP4datai
	.globl	_Z45__device_stub__Z14trace_back_gpuPdS_S_S_dddiiPdS_S_S_dddii
	.type	_Z45__device_stub__Z14trace_back_gpuPdS_S_S_dddiiPdS_S_S_dddii, @function
_Z45__device_stub__Z14trace_back_gpuPdS_S_S_dddiiPdS_S_S_dddii:
.LFB4168:
	.cfi_startproc
	endbr64
	subq	$216, %rsp
	.cfi_def_cfa_offset 224
	movq	%rdi, 56(%rsp)
	leaq	80(%rsp), %rdi
	movq	%rsi, 48(%rsp)
	leaq	92(%rsp), %rsi
	movq	%rdx, 40(%rsp)
	leaq	64(%rsp), %rdx
	movq	%rcx, 32(%rsp)
	leaq	72(%rsp), %rcx
	movl	%r8d, 4(%rsp)
	movl	%r9d, (%rsp)
	movsd	%xmm0, 24(%rsp)
	movsd	%xmm1, 16(%rsp)
	movsd	%xmm2, 8(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 200(%rsp)
	xorl	%eax, %eax
	leaq	56(%rsp), %rax
	movl	$1, 88(%rsp)
	movq	%rax, 128(%rsp)
	leaq	48(%rsp), %rax
	movq	%rax, 136(%rsp)
	leaq	40(%rsp), %rax
	movq	%rax, 144(%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 152(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 160(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 168(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 176(%rsp)
	leaq	4(%rsp), %rax
	movq	%rax, 184(%rsp)
	movq	%rsp, %rax
	movq	%rax, 192(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 80(%rsp)
	movq	%rax, 92(%rsp)
	movl	$1, 100(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L16
	pushq	72(%rsp)
	.cfi_def_cfa_offset 232
	leaq	_Z14trace_back_gpuPdS_S_S_dddii(%rip), %rdi
	pushq	72(%rsp)
	.cfi_def_cfa_offset 240
	movq	108(%rsp), %rcx
	movl	116(%rsp), %r8d
	movq	96(%rsp), %rsi
	movl	104(%rsp), %edx
	leaq	144(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 232
	popq	%rdx
	.cfi_def_cfa_offset 224
.L16:
	movq	200(%rsp), %rax
	subq	%fs:40, %rax
	je	.L18
	call	__stack_chk_fail@PLT
.L18:
	addq	$216, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE4168:
	.size	_Z45__device_stub__Z14trace_back_gpuPdS_S_S_dddiiPdS_S_S_dddii, .-_Z45__device_stub__Z14trace_back_gpuPdS_S_S_dddiiPdS_S_S_dddii
	.globl	_Z14trace_back_gpuPdS_S_S_dddii
	.type	_Z14trace_back_gpuPdS_S_S_dddii, @function
_Z14trace_back_gpuPdS_S_S_dddii:
.LFB4169:
	.cfi_startproc
	endbr64
	jmp	_Z45__device_stub__Z14trace_back_gpuPdS_S_S_dddiiPdS_S_S_dddii
	.cfi_endproc
.LFE4169:
	.size	_Z14trace_back_gpuPdS_S_S_dddii, .-_Z14trace_back_gpuPdS_S_S_dddii
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC4:
	.string	"_Z14trace_back_gpuPdS_S_S_dddii"
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB4171:
	.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	.LC4(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z14trace_back_gpuPdS_S_S_dddii(%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
.LFE4171:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.text._ZNSt6vectorIP4dataSaIS1_EED2Ev,"axG",@progbits,_ZNSt6vectorIP4dataSaIS1_EED5Ev,comdat
	.align 2
	.weak	_ZNSt6vectorIP4dataSaIS1_EED2Ev
	.type	_ZNSt6vectorIP4dataSaIS1_EED2Ev, @function
_ZNSt6vectorIP4dataSaIS1_EED2Ev:
.LFB4508:
	.cfi_startproc
	endbr64
	movq	(%rdi), %rax
	testq	%rax, %rax
	je	.L23
	movq	16(%rdi), %rsi
	movq	%rax, %rdi
	subq	%rax, %rsi
	jmp	_ZdlPvm@PLT
.L23:
	ret
	.cfi_endproc
.LFE4508:
	.size	_ZNSt6vectorIP4dataSaIS1_EED2Ev, .-_ZNSt6vectorIP4dataSaIS1_EED2Ev
	.weak	_ZNSt6vectorIP4dataSaIS1_EED1Ev
	.set	_ZNSt6vectorIP4dataSaIS1_EED1Ev,_ZNSt6vectorIP4dataSaIS1_EED2Ev
	.section	.rodata._ZNSt6vectorIP4dataSaIS1_EE17_M_realloc_insertIJRKS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_.str1.1,"aMS",@progbits,1
.LC5:
	.string	"vector::_M_realloc_insert"
	.section	.text._ZNSt6vectorIP4dataSaIS1_EE17_M_realloc_insertIJRKS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_,"axG",@progbits,_ZNSt6vectorIP4dataSaIS1_EE17_M_realloc_insertIJRKS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_,comdat
	.align 2
	.weak	_ZNSt6vectorIP4dataSaIS1_EE17_M_realloc_insertIJRKS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_
	.type	_ZNSt6vectorIP4dataSaIS1_EE17_M_realloc_insertIJRKS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_, @function
_ZNSt6vectorIP4dataSaIS1_EE17_M_realloc_insertIJRKS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_:
.LFB4693:
	.cfi_startproc
	endbr64
	movabsq	$1152921504606846975, %rcx
	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	$24, %rsp
	.cfi_def_cfa_offset 80
	movq	8(%rdi), %rax
	movq	(%rdi), %r14
	movq	%rax, %rbx
	movq	%rax, (%rsp)
	subq	%r14, %rbx
	sarq	$3, %rbx
	cmpq	%rcx, %rbx
	jne	.L26
	leaq	.LC5(%rip), %rdi
	call	_ZSt20__throw_length_errorPKc@PLT
.L26:
	cmpq	%r14, (%rsp)
	movl	$1, %eax
	movq	%rsi, %r15
	movq	%rdi, %r13
	cmovne	%rbx, %rax
	movq	%rsi, %rbp
	addq	%rax, %rbx
	setc	%al
	subq	%r14, %r15
	movzbl	%al, %eax
	testq	%rax, %rax
	jne	.L36
	xorl	%r12d, %r12d
	testq	%rbx, %rbx
	je	.L31
	movabsq	$1152921504606846975, %rax
	cmpq	%rax, %rbx
	cmova	%rax, %rbx
	jmp	.L30
.L36:
	movq	%rcx, %rbx
.L30:
	leaq	0(,%rbx,8), %rdi
	movq	%rdx, 8(%rsp)
	call	_Znwm@PLT
	movq	8(%rsp), %rdx
	movq	%rax, %r12
.L31:
	movq	(%rdx), %rax
	movq	%rax, (%r12,%r15)
	testq	%r15, %r15
	jle	.L32
	movq	%r15, %rdx
	movq	%r14, %rsi
	movq	%r12, %rdi
	call	memmove@PLT
.L32:
	movq	(%rsp), %rax
	leaq	8(%r12,%r15), %rdx
	subq	%rbp, %rax
	testq	%rax, %rax
	jle	.L33
	movq	%rdx, %rdi
	movq	%rbp, %rsi
	movq	%rax, %rcx
	rep movsb
.L33:
	leaq	(%rdx,%rax), %rbp
	testq	%r14, %r14
	je	.L34
	movq	16(%r13), %rsi
	movq	%r14, %rdi
	subq	%r14, %rsi
	call	_ZdlPvm@PLT
.L34:
	leaq	(%r12,%rbx,8), %rax
	movq	%r12, 0(%r13)
	movq	%rbp, 8(%r13)
	movq	%rax, 16(%r13)
	addq	$24, %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
.LFE4693:
	.size	_ZNSt6vectorIP4dataSaIS1_EE17_M_realloc_insertIJRKS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_, .-_ZNSt6vectorIP4dataSaIS1_EE17_M_realloc_insertIJRKS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_
	.section	.rodata.str1.1
.LC6:
	.string	"Input error!\n"
.LC7:
	.string	"./project <NUM_STEPS> <DATA_FILE>\n"
.LC8:
	.string	"%d"
.LC9:
	.string	"Can not open input file!\n"
.LC10:
	.string	"num_data = "
.LC11:
	.string	"num_step = "
.LC12:
	.string	"Data %d: Call Price: %.5f\tPut Price: %.5f\n"
	.section	.text.startup
	.globl	main
	.type	main, @function
main:
.LFB4133:
	.cfi_startproc
	.cfi_personality 0x9b,DW.ref.__gxx_personality_v0
	.cfi_lsda 0x1b,.LLSDA4133
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	leaq	_ZSt4cout(%rip), %r12
	pushq	%rbx
	subq	$632, %rsp
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	cmpl	$3, %edi
	je	.L44
	leaq	.LC6(%rip), %rsi
	movq	%r12, %rdi
	movl	$1, %ebx
.LEHB0:
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC7(%rip), %rsi
	movq	%r12, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	jmp	.L43
.L44:
	movq	8(%rsi), %rdi
	movq	%rsi, %rbx
	leaq	NUM_STEPS(%rip), %rdx
	xorl	%eax, %eax
	leaq	.LC8(%rip), %rsi
	leaq	-576(%rbp), %r14
	call	__isoc23_sscanf@PLT
	movq	16(%rbx), %rsi
	movl	$8, %edx
	movq	%r14, %rdi
	call	_ZNSt14basic_ifstreamIcSt11char_traitsIcEEC1EPKcSt13_Ios_Openmode@PLT
.LEHE0:
	movl	-288(%rbp), %ebx
	andl	$5, %ebx
	je	.L46
	leaq	.LC9(%rip), %rsi
	movq	%r12, %rdi
.LEHB1:
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	$1, %ebx
	jmp	.L47
.L46:
	leaq	NUM_DATA(%rip), %rsi
	movq	%r14, %rdi
	call	_ZNSirsERi@PLT
	leaq	.LC10(%rip), %rsi
	movq	%r12, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	NUM_DATA(%rip), %esi
	movq	%rax, %rdi
	call	_ZNSolsEi@PLT
	movq	%rax, %rdi
	call	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT
	leaq	.LC11(%rip), %rsi
	movq	%r12, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	NUM_STEPS(%rip), %esi
	movq	%rax, %rdi
	call	_ZNSolsEi@PLT
	movq	%rax, %rdi
	call	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT
.LEHE1:
	movl	NUM_STEPS(%rip), %eax
	xorl	%r13d, %r13d
	leaq	-640(%rbp), %r15
	incl	%eax
	imull	NUM_DATA(%rip), %eax
	cltq
	salq	$3, %rax
	movq	%rax, -648(%rbp)
	xorl	%eax, %eax
	movq	%rax, -600(%rbp)
	movq	%rax, -592(%rbp)
	movq	%rax, -584(%rbp)
.L48:
	movslq	NUM_DATA(%rip), %rdi
	cmpl	%r13d, %edi
	jle	.L98
	movq	%r15, %rsi
	movq	%r14, %rdi
.LEHB2:
	call	_ZNSi10_M_extractIdEERSiRT_@PLT
	movq	%rax, %rdi
	leaq	-632(%rbp), %rsi
	call	_ZNSi10_M_extractIdEERSiRT_@PLT
	movl	$112, %edi
	call	_Znwm@PLT
	movq	%rax, %r12
	movl	$28, %ecx
	xorl	%eax, %eax
	movq	%r12, %rdi
	movq	%r12, -616(%rbp)
	rep stosl
	movq	%r12, %rdi
	call	_Z4initP4data
	movsd	-640(%rbp), %xmm0
	movl	NUM_STEPS(%rip), %esi
	movq	%r12, %rdi
	movsd	%xmm0, (%r12)
	movsd	-632(%rbp), %xmm0
	movsd	%xmm0, 8(%r12)
	call	_Z15last_step_priceP4datai
	movq	-592(%rbp), %rsi
	cmpq	-584(%rbp), %rsi
	je	.L49
	movq	%r12, (%rsi)
	addq	$8, %rsi
	movq	%rsi, -592(%rbp)
	jmp	.L50
.L49:
	leaq	-616(%rbp), %rdx
	leaq	-600(%rbp), %rdi
	call	_ZNSt6vectorIP4dataSaIS1_EE17_M_realloc_insertIJRKS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_
.L50:
	incl	%r13d
	jmp	.L48
.L98:
	movabsq	$1152921504606846975, %rax
	cmpq	%rdi, %rax
	jb	.L52
	salq	$3, %rdi
	call	_Znam@PLT
	movslq	NUM_DATA(%rip), %rdi
	movq	%rax, -664(%rbp)
	movabsq	$1152921504606846975, %rax
	cmpq	%rdi, %rax
	jnb	.L91
	jmp	.L99
.L52:
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	jne	.L97
	call	__cxa_throw_bad_array_new_length@PLT
.L91:
	salq	$3, %rdi
	call	_Znam@PLT
	movq	%rax, %r13
	movl	NUM_STEPS(%rip), %eax
	leal	1(%rax), %edi
	movabsq	$1152921504606846975, %rax
	imull	NUM_DATA(%rip), %edi
	movslq	%edi, %rdi
	cmpq	%rdi, %rax
	jnb	.L92
	jmp	.L100
.L99:
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	jne	.L97
	call	__cxa_throw_bad_array_new_length@PLT
.L92:
	salq	$3, %rdi
	call	_Znam@PLT
	movq	%rax, %r14
	movl	NUM_STEPS(%rip), %eax
	leal	1(%rax), %edi
	movabsq	$1152921504606846975, %rax
	imull	NUM_DATA(%rip), %edi
	movslq	%edi, %rdi
	cmpq	%rdi, %rax
	jnb	.L93
	jmp	.L101
.L100:
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	jne	.L97
	call	__cxa_throw_bad_array_new_length@PLT
.L93:
	salq	$3, %rdi
	call	_Znam@PLT
	movl	NUM_STEPS(%rip), %edi
	movl	NUM_DATA(%rip), %esi
	xorl	%r8d, %r8d
	movq	%rax, -656(%rbp)
	movq	-600(%rbp), %r9
	xorl	%eax, %eax
	leal	1(%rdi), %r15d
	jmp	.L62
.L101:
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	jne	.L97
	call	__cxa_throw_bad_array_new_length@PLT
.L103:
	incq	%rax
	addl	%r15d, %r8d
.L62:
	cmpl	%eax, %esi
	jle	.L102
	movq	(%r9,%rax,8), %rdx
	movq	-664(%rbp), %rcx
	movq	88(%rdx), %r11
	movq	80(%rdx), %r10
	movslq	%r8d, %rdx
	salq	$3, %rdx
	movq	%r11, 0(%r13,%rax,8)
	movq	%r10, (%rcx,%rax,8)
	xorl	%ecx, %ecx
.L64:
	cmpl	%ecx, %edi
	jl	.L103
	movsd	(%r10,%rcx,8), %xmm0
	movq	-656(%rbp), %r12
	movsd	%xmm0, (%r14,%rdx)
	movsd	(%r11,%rcx,8), %xmm0
	incq	%rcx
	movsd	%xmm0, (%r12,%rdx)
	addq	$8, %rdx
	jmp	.L64
.L102:
	movq	(%r9), %rax
	movq	%rsp, %rcx
	movsd	40(%rax), %xmm3
	movsd	72(%rax), %xmm4
	movq	16(%rax), %r15
	movslq	%esi, %rax
	leaq	15(,%rax,8), %rax
	movsd	%xmm3, -664(%rbp)
	movq	%rax, %r8
	movq	%rax, %rdx
	movsd	%xmm4, -672(%rbp)
	andq	$-4096, %r8
	andq	$-16, %rdx
	subq	%r8, %rcx
.L67:
	cmpq	%rcx, %rsp
	je	.L68
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L67
.L68:
	andl	$4095, %edx
	subq	%rdx, %rsp
	testq	%rdx, %rdx
	je	.L69
	orq	$0, -8(%rsp,%rdx)
.L69:
	movq	%rax, %rdx
	movq	%rsp, %rcx
	andq	$-4096, %rax
	movq	%rsp, %r12
	andq	$-16, %rdx
	subq	%rax, %rcx
.L70:
	cmpq	%rcx, %rsp
	je	.L71
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L70
.L71:
	movq	%rdx, %rax
	andl	$4095, %eax
	subq	%rax, %rsp
	testq	%rax, %rax
	je	.L72
	orq	$0, -8(%rsp,%rax)
.L72:
	movl	%esi, -616(%rbp)
	movq	%rsp, %r13
	movq	-648(%rbp), %rsi
	movabsq	$4294967297, %rax
	movl	%edi, -628(%rbp)
	leaq	C_gpu(%rip), %rdi
	movl	$1, -632(%rbp)
	movl	$1, -624(%rbp)
	movq	%rax, -612(%rbp)
	call	cudaMalloc@PLT
	movq	-648(%rbp), %rsi
	leaq	P_gpu(%rip), %rdi
	call	cudaMalloc@PLT
	movslq	NUM_DATA(%rip), %rsi
	leaq	C_price_gpu(%rip), %rdi
	salq	$3, %rsi
	call	cudaMalloc@PLT
	movslq	NUM_DATA(%rip), %rsi
	leaq	P_price_gpu(%rip), %rdi
	salq	$3, %rsi
	call	cudaMalloc@PLT
	movq	-648(%rbp), %rdx
	movq	C_gpu(%rip), %rdi
	movl	$1, %ecx
	movq	%r14, %rsi
	call	cudaMemcpy@PLT
	movq	-648(%rbp), %rdx
	movq	-656(%rbp), %rsi
	movl	$1, %ecx
	movq	P_gpu(%rip), %rdi
	call	cudaMemcpy@PLT
	movl	NUM_STEPS(%rip), %eax
	movl	-624(%rbp), %ecx
	xorl	%r9d, %r9d
	movq	-632(%rbp), %rdx
	movq	-616(%rbp), %rdi
	incl	%eax
	movl	-608(%rbp), %esi
	cltq
	leaq	0(,%rax,8), %r8
	call	__cudaPushCallConfiguration@PLT
	movl	NUM_DATA(%rip), %r8d
	movq	C_price_gpu(%rip), %rdx
	testl	%eax, %eax
	jne	.L73
	movl	NUM_STEPS(%rip), %r9d
	movsd	-672(%rbp), %xmm2
	movq	%r15, %xmm0
	movsd	-664(%rbp), %xmm1
	movq	P_price_gpu(%rip), %rcx
	movq	P_gpu(%rip), %rsi
	movq	C_gpu(%rip), %rdi
	call	_Z45__device_stub__Z14trace_back_gpuPdS_S_S_dddiiPdS_S_S_dddii
.L73:
	movslq	NUM_DATA(%rip), %rdx
	movq	C_price_gpu(%rip), %rsi
	movl	$2, %ecx
	movq	%r12, %rdi
	salq	$3, %rdx
	call	cudaMemcpy@PLT
	movslq	NUM_DATA(%rip), %rdx
	movq	P_price_gpu(%rip), %rsi
	movl	$2, %ecx
	movq	%r13, %rdi
	salq	$3, %rdx
	call	cudaMemcpy@PLT
	xorl	%r14d, %r14d
	leaq	.LC12(%rip), %r15
.L74:
	cmpl	%r14d, NUM_DATA(%rip)
	movl	%r14d, %edx
	jle	.L104
	movsd	(%r12,%r14,8), %xmm0
	movq	%r15, %rsi
	movl	$2, %edi
	movb	$2, %al
	movsd	0(%r13,%r14,8), %xmm1
	call	__printf_chk@PLT
.LEHE2:
	incq	%r14
	jmp	.L74
.L104:
	leaq	-600(%rbp), %rdi
	call	_ZNSt6vectorIP4dataSaIS1_EED1Ev
.L47:
	leaq	-576(%rbp), %rdi
	call	_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev@PLT
	jmp	.L43
.L83:
	endbr64
	movq	%rax, %rbx
.L76:
	leaq	-600(%rbp), %rdi
	call	_ZNSt6vectorIP4dataSaIS1_EED1Ev
	jmp	.L77
.L82:
	endbr64
	movq	%rax, %rbx
.L77:
	leaq	-576(%rbp), %rdi
	call	_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev@PLT
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	jne	.L97
	movq	%rbx, %rdi
.LEHB3:
	call	_Unwind_Resume@PLT
.LEHE3:
.L43:
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	je	.L79
.L97:
	call	__stack_chk_fail@PLT
.L79:
	leaq	-40(%rbp), %rsp
	movl	%ebx, %eax
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE4133:
	.globl	__gxx_personality_v0
	.section	.gcc_except_table,"a",@progbits
.LLSDA4133:
	.byte	0xff
	.byte	0xff
	.byte	0x1
	.uleb128 .LLSDACSE4133-.LLSDACSB4133
.LLSDACSB4133:
	.uleb128 .LEHB0-.LFB4133
	.uleb128 .LEHE0-.LEHB0
	.uleb128 0
	.uleb128 0
	.uleb128 .LEHB1-.LFB4133
	.uleb128 .LEHE1-.LEHB1
	.uleb128 .L82-.LFB4133
	.uleb128 0
	.uleb128 .LEHB2-.LFB4133
	.uleb128 .LEHE2-.LEHB2
	.uleb128 .L83-.LFB4133
	.uleb128 0
	.uleb128 .LEHB3-.LFB4133
	.uleb128 .LEHE3-.LEHB3
	.uleb128 0
	.uleb128 0
.LLSDACSE4133:
	.section	.text.startup
	.size	main, .-main
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.globl	P_price_gpu
	.bss
	.align 8
	.type	P_price_gpu, @object
	.size	P_price_gpu, 8
P_price_gpu:
	.zero	8
	.globl	C_price_gpu
	.align 8
	.type	C_price_gpu, @object
	.size	C_price_gpu, 8
C_price_gpu:
	.zero	8
	.globl	P_gpu
	.align 8
	.type	P_gpu, @object
	.size	P_gpu, 8
P_gpu:
	.zero	8
	.globl	C_gpu
	.align 8
	.type	C_gpu, @object
	.size	C_gpu, 8
C_gpu:
	.zero	8
	.globl	NUM_DATA
	.align 4
	.type	NUM_DATA, @object
	.size	NUM_DATA, 4
NUM_DATA:
	.zero	4
	.globl	NUM_STEPS
	.align 4
	.type	NUM_STEPS, @object
	.size	NUM_STEPS, 4
NUM_STEPS:
	.zero	4
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC0:
	.long	1202590843
	.long	1064598241
	.align 8
.LC1:
	.long	858993459
	.long	1070805811
	.align 8
.LC2:
	.long	0
	.long	1072693248
	.hidden	DW.ref.__gxx_personality_v0
	.weak	DW.ref.__gxx_personality_v0
	.section	.data.rel.local.DW.ref.__gxx_personality_v0,"awG",@progbits,DW.ref.__gxx_personality_v0,comdat
	.align 8
	.type	DW.ref.__gxx_personality_v0, @object
	.size	DW.ref.__gxx_personality_v0, 8
DW.ref.__gxx_personality_v0:
	.quad	__gxx_personality_v0
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

//Parallel Programming Final Project (CUDA)
//Team: 22
//ver 2.4		2018/12/16	21:15

#include <iostream>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <time.h>
#include <hip/hip_runtime.h>


using namespace std;

int NUM_STEPS;
int NUM_DATA;
double 	*C_gpu,
		*P_gpu,
		*C_price_gpu,
		*P_price_gpu;

struct data {
    double K; 
    double S;
    double r;
    double v;
    double T;
	double dt;
	double vdt;
	double u;
	double d;
	double p;
	double* last_C;
	double* last_P;
	double C_price;
	double P_price;
}; 

typedef struct data option_data;



void init(option_data *in){
    in->r = 0.005 ;   // Risk-free rate (5%)
    in->v = 0.3 ;    // Volatility of the underlying (20%)
    in->T = 1.0;   // One year until expiry
	in->dt = in->T/NUM_STEPS;
	in->vdt = in->v*sqrt(in->dt);
	in->u = exp(in->vdt);
	in->d = 1/in->u;
	in->p = (exp(in->r*in->dt)-in->d)/(in->u-in->d);
	in->last_C = new double [NUM_STEPS+1];
	in->last_P = new double [NUM_STEPS+1];
}

//Call Option 認購期權
double CallOption(const double& S,const double& K,const double& vDt,const int& i){
	double d = S * exp(vDt * (2.0 * i - NUM_STEPS)) - K;      
	return max(d,(double)0); 
}

//Put Option 認沽期權
double PutOption(const double& S,const double& K,const double& vDt,const int& i){
	double d = K-S * exp(vDt * (2.0 * i - NUM_STEPS));          
	return max(d,(double)0); 
}

void last_step_price(option_data* temp_data,int NUM_STEPS){
	for(int k = 0; k <=NUM_STEPS; k++){
		double sd = temp_data->S * exp(temp_data->vdt * (2.0 * (NUM_STEPS-k) - NUM_STEPS)) ; 
		
		temp_data->last_C[k] = max(sd-temp_data->K,(double)0);
		temp_data->last_P[k] = max(temp_data->K-sd,(double)0);
	}
	
	return;
}


/*
__global__ void trace_back_gpu(double* C_option, double* P_option, double* C_price, double* P_price, double r, double dt, double p, int NUM_DATA, int NUM_STEPS){
	int x = blockIdx.x * blockDim.x + threadIdx.x;
	int y = blockIdx.y * blockDim.y + threadIdx.y;
	
	__shared__ double data_c[2000];
	__shared__ double data_p[2000];

	for(int i=0; i<(NUM_STEPS+1); i++){
		data_c[i] = C_option[x*(NUM_STEPS+1)+i];
		data_p[i] = P_option[x*(NUM_STEPS+1)+i];
	}
	__syncthreads();
	if(x<NUM_DATA && y<NUM_STEPS){

		for(int t = 0; t < NUM_STEPS; ++t){
			data_c[y] = exp(-r*dt) * (p*data_c[y] + (1-p)*data_c[y+1]);
			data_p[y] = exp(-r*dt) * (p*data_p[y] + (1-p)*data_p[y+1]);
			__syncthreads();
		}
	}

	C_price[x] = data_c[0];	
	P_price[x] = data_p[0];



	return;
}
*/
__global__ void trace_back_gpu(double* C_option, double* P_option, double* C_price, double* P_price, double r, double dt, double p, int NUM_DATA, int NUM_STEPS){
	int x = blockIdx.x * blockDim.x + threadIdx.x;
	int y = blockIdx.y * blockDim.y + threadIdx.y;
	
	__shared__ double data[4000];
	
	for(int i=0; i<(NUM_STEPS+1); i++){
		data[i] = C_option[x*(NUM_STEPS+1)+i];
	}
	for(int i=0; i<(NUM_STEPS+1); i++){
		data[i+(NUM_STEPS+1)] = P_option[x*(NUM_STEPS+1)+i];
	}
	
	__syncthreads();
	if(x<NUM_DATA && y<NUM_STEPS){

		for(int t = 0; t < NUM_STEPS; ++t){
			data[y] = exp(-r*dt) * (p*data[y] + (1-p)*data[y+1]);
			data[y+(NUM_STEPS+1)] = exp(-r*dt) * (p*data[y+(NUM_STEPS+1)] + (1-p)*data[y+1+(NUM_STEPS+1)]);
			__syncthreads();
		}
	}

	C_price[x] = data[0];	
	P_price[x] = data[NUM_STEPS+1];



	return;
}


int main(int argc, char **argv){
	if(argc!=3){
		cout << "Input error!\n";
		cout << "./project <NUM_STEPS> <DATA_FILE>\n";
		return 1;
	}
	sscanf(argv[1],"%d",&NUM_STEPS);
	ifstream infile(argv[2]);
	if(!infile) {
		cout << "Can not open input file!\n";
		return 1;
	}
	
	infile >> NUM_DATA;
	cout << "num_data = " << NUM_DATA << endl;
	cout << "num_step = " << NUM_STEPS << endl;
    
	size_t size = ((NUM_STEPS+1)*NUM_DATA)*sizeof(double);
	vector<option_data*> option_vector;
	
	for(int i = 0; i < NUM_DATA; ++i){
		double K, S; 
		infile >> K >> S;
	    option_data *temp_data = new option_data();
		init(temp_data);
		temp_data->K = K;
		temp_data->S = S;
		
		last_step_price(temp_data,NUM_STEPS);
        option_vector.push_back(temp_data);
	}

	double** C_matrix = new double*[NUM_DATA];
	double** P_matrix = new double*[NUM_DATA];
	double* C_array = new double[(NUM_STEPS+1)*NUM_DATA];
	double* P_array = new double[(NUM_STEPS+1)*NUM_DATA];
	
	for(int i = 0; i < NUM_DATA; ++i){
		C_matrix[i] = option_vector[i]->last_C;
		P_matrix[i] = option_vector[i]->last_P;
		for(int j = 0; j < NUM_STEPS+1; ++j){
			C_array[i*(NUM_STEPS+1)+j] = C_matrix[i][j];
			P_array[i*(NUM_STEPS+1)+j] = P_matrix[i][j];
		}
	}

	double r = option_vector[0]->r;
	double dt = option_vector[0]->dt;
	double p = option_vector[0]->p;
	double C_price[NUM_DATA];
	double P_price[NUM_DATA];
	


	dim3 dimBlock(1,NUM_STEPS);
	dim3 dimGrid(NUM_DATA,1);
    
	hipMalloc((void**)&C_gpu, size);
	hipMalloc((void**)&P_gpu, size);
	hipMalloc((void**)&C_price_gpu, NUM_DATA*sizeof(double));
	hipMalloc((void**)&P_price_gpu, NUM_DATA*sizeof(double));
	hipMemcpy(C_gpu, C_array, size, hipMemcpyHostToDevice);
	hipMemcpy(P_gpu, P_array, size, hipMemcpyHostToDevice);
	trace_back_gpu<<<dimGrid,dimBlock,(NUM_STEPS+1)*sizeof(double)>>>(C_gpu, P_gpu, C_price_gpu, P_price_gpu, r, dt, p, NUM_DATA, NUM_STEPS);
	hipMemcpy(C_price, C_price_gpu, NUM_DATA*sizeof(double), hipMemcpyDeviceToHost);
	hipMemcpy(P_price, P_price_gpu, NUM_DATA*sizeof(double), hipMemcpyDeviceToHost);
	
	//print
	for(int i =0;i<NUM_DATA;i++){
	    option_data* print_price = option_vector[i];
		printf("Data %d: Call Price: %.5f\tPut Price: %.5f\n", i, C_price[i], P_price[i]);
	}
	
	return 0;
}

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

                                        # End of file scope inline assembly
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z4initP4data
.LCPI0_0:
	.quad	0x3ff0000000000000              # double 1
.LCPI0_1:
	.quad	0x3fd3333333333333              # double 0.29999999999999999
	.text
	.globl	_Z4initP4data
	.type	_Z4initP4data,@function
_Z4initP4data:                          # @_Z4initP4data
	.cfi_startproc
# %bb.0:
	pushq	%r14
	.cfi_def_cfa_offset 16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	pushq	%rax
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -24
	.cfi_offset %r14, -16
	movq	%rdi, %rbx
	movabsq	$4572414629676717179, %rax      # imm = 0x3F747AE147AE147B
	movq	%rax, 16(%rdi)
	movabsq	$4599075939470750515, %rax      # imm = 0x3FD3333333333333
	movq	%rax, 24(%rdi)
	movabsq	$4607182418800017408, %rax      # imm = 0x3FF0000000000000
	movq	%rax, 32(%rdi)
	cvtsi2sdl	NUM_STEPS(%rip), %xmm1
	movsd	.LCPI0_0(%rip), %xmm0           # xmm0 = mem[0],zero
	divsd	%xmm1, %xmm0
	movsd	%xmm0, 40(%rdi)
	xorpd	%xmm1, %xmm1
	ucomisd	%xmm1, %xmm0
	jb	.LBB0_2
# %bb.1:
	sqrtsd	%xmm0, %xmm0
	jmp	.LBB0_3
.LBB0_2:                                # %call.sqrt
	callq	sqrt
.LBB0_3:                                # %.split
	mulsd	.LCPI0_1(%rip), %xmm0
	movsd	%xmm0, 48(%rbx)
	callq	exp
	movsd	%xmm0, 56(%rbx)
	movsd	.LCPI0_0(%rip), %xmm1           # xmm1 = mem[0],zero
	divsd	%xmm0, %xmm1
	movsd	%xmm1, 64(%rbx)
	movsd	16(%rbx), %xmm0                 # xmm0 = mem[0],zero
	mulsd	40(%rbx), %xmm0
	callq	exp
	movsd	56(%rbx), %xmm1                 # xmm1 = mem[0],zero
	movsd	64(%rbx), %xmm2                 # xmm2 = mem[0],zero
	subsd	%xmm2, %xmm0
	subsd	%xmm2, %xmm1
	divsd	%xmm1, %xmm0
	movsd	%xmm0, 72(%rbx)
	movslq	NUM_STEPS(%rip), %rax
	cmpq	$-1, %rax
	leaq	8(,%rax,8), %rax
	movq	$-1, %r14
	cmovgeq	%rax, %r14
	movq	%r14, %rdi
	callq	_Znam
	movq	%rax, 80(%rbx)
	movq	%r14, %rdi
	callq	_Znam
	movq	%rax, 88(%rbx)
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	_Z4initP4data, .Lfunc_end0-_Z4initP4data
	.cfi_endproc
                                        # -- End function
	.globl	_Z10CallOptionRKdS0_S0_RKi      # -- Begin function _Z10CallOptionRKdS0_S0_RKi
	.type	_Z10CallOptionRKdS0_S0_RKi,@function
_Z10CallOptionRKdS0_S0_RKi:             # @_Z10CallOptionRKdS0_S0_RKi
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$16, %rsp
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -16
	movq	%rsi, %rbx
	movsd	(%rdi), %xmm0                   # xmm0 = mem[0],zero
	movsd	%xmm0, 8(%rsp)                  # 8-byte Spill
	xorps	%xmm0, %xmm0
	cvtsi2sdl	(%rcx), %xmm0
	cvtsi2sdl	NUM_STEPS(%rip), %xmm1
	addsd	%xmm0, %xmm0
	subsd	%xmm1, %xmm0
	mulsd	(%rdx), %xmm0
	callq	exp
	mulsd	8(%rsp), %xmm0                  # 8-byte Folded Reload
	subsd	(%rbx), %xmm0
	xorpd	%xmm1, %xmm1
	maxsd	%xmm0, %xmm1
	movapd	%xmm1, %xmm0
	addq	$16, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end1:
	.size	_Z10CallOptionRKdS0_S0_RKi, .Lfunc_end1-_Z10CallOptionRKdS0_S0_RKi
	.cfi_endproc
                                        # -- End function
	.globl	_Z9PutOptionRKdS0_S0_RKi        # -- Begin function _Z9PutOptionRKdS0_S0_RKi
	.type	_Z9PutOptionRKdS0_S0_RKi,@function
_Z9PutOptionRKdS0_S0_RKi:               # @_Z9PutOptionRKdS0_S0_RKi
	.cfi_startproc
# %bb.0:
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movsd	(%rsi), %xmm0                   # xmm0 = mem[0],zero
	movsd	%xmm0, 16(%rsp)                 # 8-byte Spill
	movsd	(%rdi), %xmm0                   # xmm0 = mem[0],zero
	movsd	%xmm0, 8(%rsp)                  # 8-byte Spill
	xorps	%xmm0, %xmm0
	cvtsi2sdl	(%rcx), %xmm0
	cvtsi2sdl	NUM_STEPS(%rip), %xmm1
	addsd	%xmm0, %xmm0
	subsd	%xmm1, %xmm0
	mulsd	(%rdx), %xmm0
	callq	exp
	mulsd	8(%rsp), %xmm0                  # 8-byte Folded Reload
	movsd	16(%rsp), %xmm1                 # 8-byte Reload
                                        # xmm1 = mem[0],zero
	subsd	%xmm0, %xmm1
	xorpd	%xmm0, %xmm0
	maxsd	%xmm1, %xmm0
	addq	$24, %rsp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end2:
	.size	_Z9PutOptionRKdS0_S0_RKi, .Lfunc_end2-_Z9PutOptionRKdS0_S0_RKi
	.cfi_endproc
                                        # -- End function
	.globl	_Z15last_step_priceP4datai      # -- Begin function _Z15last_step_priceP4datai
	.type	_Z15last_step_priceP4datai,@function
_Z15last_step_priceP4datai:             # @_Z15last_step_priceP4datai
	.cfi_startproc
# %bb.0:
	testl	%esi, %esi
	js	.LBB3_4
# %bb.1:                                # %.lr.ph
	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
	subq	$24, %rsp
	.cfi_def_cfa_offset 64
	.cfi_offset %rbx, -40
	.cfi_offset %r12, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movl	%esi, %ebx
	movq	%rdi, %r14
	cvtsi2sd	%esi, %xmm0
	movsd	%xmm0, 8(%rsp)                  # 8-byte Spill
	leal	1(%rbx), %r15d
	xorl	%r12d, %r12d
.LBB3_2:                                # =>This Inner Loop Header: Depth=1
	movsd	8(%r14), %xmm0                  # xmm0 = mem[0],zero
	movsd	%xmm0, 16(%rsp)                 # 8-byte Spill
	xorps	%xmm0, %xmm0
	cvtsi2sd	%ebx, %xmm0
	addsd	%xmm0, %xmm0
	subsd	8(%rsp), %xmm0                  # 8-byte Folded Reload
	mulsd	48(%r14), %xmm0
	callq	exp
	mulsd	16(%rsp), %xmm0                 # 8-byte Folded Reload
	movapd	%xmm0, %xmm1
	subsd	(%r14), %xmm1
	xorpd	%xmm2, %xmm2
	maxsd	%xmm1, %xmm2
	movq	80(%r14), %rax
	movsd	%xmm2, (%rax,%r12,8)
	movsd	(%r14), %xmm1                   # xmm1 = mem[0],zero
	subsd	%xmm0, %xmm1
	xorpd	%xmm0, %xmm0
	maxsd	%xmm1, %xmm0
	movq	88(%r14), %rax
	movsd	%xmm0, (%rax,%r12,8)
	incq	%r12
	decl	%ebx
	cmpq	%r12, %r15
	jne	.LBB3_2
# %bb.3:
	addq	$24, %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
	.cfi_restore %rbx
	.cfi_restore %r12
	.cfi_restore %r14
	.cfi_restore %r15
.LBB3_4:                                # %._crit_edge
	retq
.Lfunc_end3:
	.size	_Z15last_step_priceP4datai, .Lfunc_end3-_Z15last_step_priceP4datai
	.cfi_endproc
                                        # -- End function
	.globl	_Z29__device_stub__trace_back_gpuPdS_S_S_dddii # -- Begin function _Z29__device_stub__trace_back_gpuPdS_S_S_dddii
	.type	_Z29__device_stub__trace_back_gpuPdS_S_S_dddii,@function
_Z29__device_stub__trace_back_gpuPdS_S_S_dddii: # @_Z29__device_stub__trace_back_gpuPdS_S_S_dddii
	.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	$192, %rsp
	.cfi_def_cfa_offset 240
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	72(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	64(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	56(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	48(%rsp), %rdx
	movq	%rcx, (%rdx)
	leaq	40(%rsp), %rcx
	movsd	%xmm0, (%rcx)
	leaq	32(%rsp), %r10
	movsd	%xmm1, (%r10)
	leaq	24(%rsp), %r11
	movsd	%xmm2, (%r11)
	leaq	4(%rsp), %r14
	movl	%r8d, (%r14)
	movq	%rsp, %r8
	movl	%r9d, (%r8)
	leaq	112(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	movq	%rcx, 32(%rbx)
	movq	%r10, 40(%rbx)
	movq	%r11, 48(%rbx)
	movq	%r14, 56(%rbx)
	movq	%r8, 64(%rbx)
	leaq	96(%rsp), %r14
	leaq	80(%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	$_Z14trace_back_gpuPdS_S_S_dddii, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$208, %rsp
	.cfi_adjust_cfa_offset -208
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end4:
	.size	_Z29__device_stub__trace_back_gpuPdS_S_S_dddii, .Lfunc_end4-_Z29__device_stub__trace_back_gpuPdS_S_S_dddii
	.cfi_endproc
                                        # -- End function
	.globl	main                            # -- Begin function main
	.type	main,@function
main:                                   # @main
.Lfunc_begin0:
	.cfi_startproc
	.cfi_personality 3, __gxx_personality_v0
	.cfi_lsda 3, .Lexception0
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset %rbp, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register %rbp
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$616, %rsp                      # imm = 0x268
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	cmpl	$3, %edi
	jne	.LBB5_1
# %bb.3:
	movq	%rsi, %rbx
	movq	8(%rsi), %rdi
	movl	$.L.str.2, %esi
	movl	$NUM_STEPS, %edx
	xorl	%eax, %eax
	callq	__isoc23_sscanf
	movq	16(%rbx), %rsi
	leaq	-656(%rbp), %rbx
	movq	%rbx, %rdi
	movl	$8, %edx
	callq	_ZNSt14basic_ifstreamIcSt11char_traitsIcEEC1EPKcSt13_Ios_Openmode
	movq	(%rbx), %rax
	movq	-24(%rax), %rax
	testb	$5, -624(%rbp,%rax)
	je	.LBB5_6
# %bb.4:
	movl	$1, %ebx
.Ltmp0:
	movl	$_ZSt4cout, %edi
	movl	$.L.str.3, %esi
	movl	$25, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp1:
	jmp	.LBB5_5
.LBB5_1:
	movl	$_ZSt4cout, %edi
	movl	$.L.str, %esi
	movl	$13, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	$_ZSt4cout, %edi
	movl	$.L.str.1, %esi
	movl	$34, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	$1, %ebx
	jmp	.LBB5_2
.LBB5_6:
.Ltmp2:
	leaq	-656(%rbp), %rdi
	movl	$NUM_DATA, %esi
	callq	_ZNSirsERi
.Ltmp3:
# %bb.7:
.Ltmp4:
	movl	$_ZSt4cout, %edi
	movl	$.L.str.4, %esi
	movl	$11, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp5:
# %bb.8:                                # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit77
	movl	NUM_DATA(%rip), %esi
.Ltmp6:
	movl	$_ZSt4cout, %edi
	callq	_ZNSolsEi
.Ltmp7:
# %bb.9:
	movq	%rax, %rbx
	movq	(%rax), %rax
	movq	-24(%rax), %rdi
	addq	%rbx, %rdi
.Ltmp8:
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
.Ltmp9:
# %bb.10:                               # %.noexc83
.Ltmp10:
	movsbl	%al, %esi
	movq	%rbx, %rdi
	callq	_ZNSo3putEc
.Ltmp11:
# %bb.11:                               # %.noexc84
.Ltmp12:
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
.Ltmp13:
# %bb.12:                               # %_ZNSolsEPFRSoS_E.exit
.Ltmp14:
	movl	$_ZSt4cout, %edi
	movl	$.L.str.5, %esi
	movl	$11, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp15:
# %bb.13:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit78
	movl	NUM_STEPS(%rip), %esi
.Ltmp16:
	movl	$_ZSt4cout, %edi
	callq	_ZNSolsEi
.Ltmp17:
# %bb.14:
	movq	%rax, %rbx
	movq	(%rax), %rax
	movq	-24(%rax), %rdi
	addq	%rbx, %rdi
.Ltmp18:
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
.Ltmp19:
# %bb.15:                               # %.noexc86
.Ltmp20:
	movsbl	%al, %esi
	movq	%rbx, %rdi
	callq	_ZNSo3putEc
.Ltmp21:
# %bb.16:                               # %.noexc87
.Ltmp22:
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
.Ltmp23:
# %bb.17:                               # %_ZNSolsEPFRSoS_E.exit79
	movl	NUM_STEPS(%rip), %r14d
	leal	1(%r14), %r15d
	movl	NUM_DATA(%rip), %r13d
	movl	%r15d, %eax
	imull	%r13d, %eax
	movslq	%eax, %rcx
	shlq	$3, %rcx
	xorps	%xmm0, %xmm0
	movaps	%xmm0, -80(%rbp)
	movq	$0, -64(%rbp)
	movq	%rcx, -48(%rbp)                 # 8-byte Spill
	testl	%r13d, %r13d
	jle	.LBB5_28
# %bb.18:                               # %.lr.ph
	xorl	%r12d, %r12d
	leaq	-656(%rbp), %rbx
	leaq	-136(%rbp), %r14
	leaq	-128(%rbp), %r15
.LBB5_19:                               # =>This Inner Loop Header: Depth=1
.Ltmp25:
	movq	%rbx, %rdi
	movq	%r14, %rsi
	callq	_ZNSi10_M_extractIdEERSiRT_
.Ltmp26:
# %bb.20:                               # %_ZNSirsERd.exit
                                        #   in Loop: Header=BB5_19 Depth=1
.Ltmp27:
	movq	%rax, %rdi
	movq	%r15, %rsi
	callq	_ZNSi10_M_extractIdEERSiRT_
.Ltmp28:
# %bb.21:                               # %_ZNSirsERd.exit80
                                        #   in Loop: Header=BB5_19 Depth=1
.Ltmp30:
	movl	$112, %edi
	callq	_Znwm
.Ltmp31:
# %bb.22:                               #   in Loop: Header=BB5_19 Depth=1
	xorps	%xmm0, %xmm0
	movaps	%xmm0, 96(%rax)
	movaps	%xmm0, 80(%rax)
	movaps	%xmm0, 64(%rax)
	movaps	%xmm0, 48(%rax)
	movaps	%xmm0, 32(%rax)
	movaps	%xmm0, 16(%rax)
	movaps	%xmm0, (%rax)
	movq	%rax, -56(%rbp)
.Ltmp32:
	movq	%rax, %rdi
	callq	_Z4initP4data
.Ltmp33:
# %bb.23:                               #   in Loop: Header=BB5_19 Depth=1
	movsd	-136(%rbp), %xmm0               # xmm0 = mem[0],zero
	movq	-56(%rbp), %rdi
	movsd	%xmm0, (%rdi)
	movsd	-128(%rbp), %xmm0               # xmm0 = mem[0],zero
	movsd	%xmm0, 8(%rdi)
	movl	NUM_STEPS(%rip), %esi
	callq	_Z15last_step_priceP4datai
	movq	-72(%rbp), %rsi
	cmpq	-64(%rbp), %rsi
	je	.LBB5_25
# %bb.24:                               #   in Loop: Header=BB5_19 Depth=1
	movq	-56(%rbp), %rax
	movq	%rax, (%rsi)
	addq	$8, -72(%rbp)
	jmp	.LBB5_26
.LBB5_25:                               #   in Loop: Header=BB5_19 Depth=1
.Ltmp34:
	leaq	-80(%rbp), %rdi
	leaq	-56(%rbp), %rdx
	callq	_ZNSt6vectorIP4dataSaIS1_EE17_M_realloc_insertIJRKS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_
.Ltmp35:
.LBB5_26:                               # %_ZNSt6vectorIP4dataSaIS1_EE9push_backERKS1_.exit
                                        #   in Loop: Header=BB5_19 Depth=1
	incl	%r12d
	movl	NUM_DATA(%rip), %r13d
	cmpl	%r13d, %r12d
	jl	.LBB5_19
# %bb.27:                               # %._crit_edge.loopexit
	movl	NUM_STEPS(%rip), %r14d
	leal	1(%r14), %r15d
	movl	%r15d, %eax
	imull	%r13d, %eax
	movslq	%eax, %rcx
	shlq	$3, %rcx
.LBB5_28:                               # %._crit_edge
	testl	%eax, %eax
	movq	$-1, %rbx
	cmovnsq	%rcx, %rbx
.Ltmp37:
	movq	%rbx, %rdi
	callq	_Znam
.Ltmp38:
# %bb.29:
.Ltmp40:
	movq	%rax, %r12
	movq	%rbx, %rdi
	callq	_Znam
.Ltmp41:
# %bb.30:                               # %.preheader93
	movq	%rax, %rbx
	movq	-80(%rbp), %rcx
	movl	%r13d, %eax
	testl	%r13d, %r13d
	jle	.LBB5_31
# %bb.50:                               # %.lr.ph103
	movl	%r15d, %edx
	xorl	%esi, %esi
	xorl	%edi, %edi
.LBB5_51:                               # =>This Loop Header: Depth=1
                                        #     Child Loop BB5_53 Depth 2
	testl	%r14d, %r14d
	js	.LBB5_54
# %bb.52:                               # %.lr.ph100
                                        #   in Loop: Header=BB5_51 Depth=1
	movl	%esi, %r9d
	leaq	(%rbx,%r9,8), %r8
	leaq	(%r12,%r9,8), %r9
	movq	(%rcx,%rdi,8), %r11
	movq	80(%r11), %r10
	movq	88(%r11), %r11
	xorl	%r13d, %r13d
.LBB5_53:                               #   Parent Loop BB5_51 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movsd	(%r10,%r13,8), %xmm0            # xmm0 = mem[0],zero
	movsd	%xmm0, (%r9,%r13,8)
	movsd	(%r11,%r13,8), %xmm0            # xmm0 = mem[0],zero
	movsd	%xmm0, (%r8,%r13,8)
	incq	%r13
	cmpq	%r13, %rdx
	jne	.LBB5_53
.LBB5_54:                               # %._crit_edge101
                                        #   in Loop: Header=BB5_51 Depth=1
	incq	%rdi
	addl	%r15d, %esi
	cmpq	%rax, %rdi
	jne	.LBB5_51
.LBB5_31:                               # %._crit_edge104
	movq	%rsp, -112(%rbp)                # 8-byte Spill
	movq	(%rcx), %rcx
	movsd	16(%rcx), %xmm0                 # xmm0 = mem[0],zero
	movsd	%xmm0, -104(%rbp)               # 8-byte Spill
	movsd	40(%rcx), %xmm0                 # xmm0 = mem[0],zero
	movsd	%xmm0, -96(%rbp)                # 8-byte Spill
	movsd	72(%rcx), %xmm0                 # xmm0 = mem[0],zero
	movsd	%xmm0, -88(%rbp)                # 8-byte Spill
	movq	%rsp, %r14
	leaq	15(,%rax,8), %rax
	andq	$-16, %rax
	subq	%rax, %r14
	movq	%r14, %rsp
	movl	NUM_DATA(%rip), %eax
	movq	%rsp, %r15
	movq	%rax, -120(%rbp)                # 8-byte Spill
	leaq	15(,%rax,8), %rax
	andq	$-16, %rax
	subq	%rax, %r15
	movq	%r15, %rsp
	movl	NUM_STEPS(%rip), %r13d
.Ltmp43:
	movl	$C_gpu, %edi
	movq	-48(%rbp), %rsi                 # 8-byte Reload
	callq	hipMalloc
.Ltmp44:
# %bb.32:
.Ltmp45:
	movl	$P_gpu, %edi
	movq	-48(%rbp), %rsi                 # 8-byte Reload
	callq	hipMalloc
.Ltmp46:
# %bb.33:
	movslq	NUM_DATA(%rip), %rsi
	shlq	$3, %rsi
.Ltmp47:
	movl	$C_price_gpu, %edi
	callq	hipMalloc
.Ltmp48:
# %bb.34:
	movslq	NUM_DATA(%rip), %rsi
	shlq	$3, %rsi
.Ltmp49:
	movl	$P_price_gpu, %edi
	callq	hipMalloc
.Ltmp50:
# %bb.35:
	movq	C_gpu(%rip), %rdi
.Ltmp51:
	movq	%r12, %rsi
	movq	-48(%rbp), %rdx                 # 8-byte Reload
	movl	$1, %ecx
	callq	hipMemcpy
.Ltmp52:
# %bb.36:
	movq	P_gpu(%rip), %rdi
.Ltmp53:
	movq	%rbx, %rsi
	movq	-48(%rbp), %rdx                 # 8-byte Reload
	movl	$1, %ecx
	callq	hipMemcpy
.Ltmp54:
# %bb.37:
	shlq	$32, %r13
	orq	$1, %r13
	movq	-120(%rbp), %rdi                # 8-byte Reload
	btsq	$32, %rdi
	movslq	NUM_STEPS(%rip), %rax
	leaq	8(,%rax,8), %r8
.Ltmp55:
	movl	$1, %esi
	movq	%r13, %rdx
	movl	$1, %ecx
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
.Ltmp56:
# %bb.38:
	testl	%eax, %eax
	jne	.LBB5_40
# %bb.39:
	movq	C_gpu(%rip), %rdi
	movq	P_gpu(%rip), %rsi
	movq	C_price_gpu(%rip), %rdx
	movq	P_price_gpu(%rip), %rcx
	movl	NUM_DATA(%rip), %r8d
	movl	NUM_STEPS(%rip), %r9d
.Ltmp57:
	movsd	-104(%rbp), %xmm0               # 8-byte Reload
                                        # xmm0 = mem[0],zero
	movsd	-96(%rbp), %xmm1                # 8-byte Reload
                                        # xmm1 = mem[0],zero
	movsd	-88(%rbp), %xmm2                # 8-byte Reload
                                        # xmm2 = mem[0],zero
	callq	_Z29__device_stub__trace_back_gpuPdS_S_S_dddii
.Ltmp58:
.LBB5_40:
	movq	C_price_gpu(%rip), %rsi
	movslq	NUM_DATA(%rip), %rdx
	shlq	$3, %rdx
.Ltmp59:
	movq	%r14, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
.Ltmp60:
# %bb.41:
	movq	P_price_gpu(%rip), %rsi
	movslq	NUM_DATA(%rip), %rdx
	shlq	$3, %rdx
.Ltmp61:
	movq	%r15, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
.Ltmp62:
# %bb.42:                               # %.preheader
	cmpl	$0, NUM_DATA(%rip)
	jle	.LBB5_45
# %bb.43:                               # %.lr.ph106.preheader
	xorl	%ebx, %ebx
.LBB5_44:                               # %.lr.ph106
                                        # =>This Inner Loop Header: Depth=1
	movsd	(%r14,%rbx,8), %xmm0            # xmm0 = mem[0],zero
	movsd	(%r15,%rbx,8), %xmm1            # xmm1 = mem[0],zero
	movl	$.L.str.6, %edi
	movl	%ebx, %esi
	movb	$2, %al
	callq	printf
	incq	%rbx
	movslq	NUM_DATA(%rip), %rax
	cmpq	%rax, %rbx
	jl	.LBB5_44
.LBB5_45:                               # %._crit_edge107
	movq	-112(%rbp), %rsp                # 8-byte Reload
	movq	-80(%rbp), %rdi
	testq	%rdi, %rdi
	je	.LBB5_47
# %bb.46:
	callq	_ZdlPv
.LBB5_47:                               # %_ZNSt6vectorIP4dataSaIS1_EED2Ev.exit
	xorl	%ebx, %ebx
.LBB5_5:                                # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit
	leaq	-656(%rbp), %rdi
	callq	_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev
.LBB5_2:
	movl	%ebx, %eax
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa %rsp, 8
	retq
.LBB5_49:
	.cfi_def_cfa %rbp, 16
.Ltmp42:
	jmp	.LBB5_57
.LBB5_48:
.Ltmp39:
	jmp	.LBB5_57
.LBB5_55:
.Ltmp63:
	jmp	.LBB5_57
.LBB5_59:
.Ltmp24:
	movq	%rax, %rbx
	jmp	.LBB5_60
.LBB5_56:
.Ltmp29:
	jmp	.LBB5_57
.LBB5_61:
.Ltmp36:
.LBB5_57:
	movq	%rax, %rbx
	movq	-80(%rbp), %rdi
	testq	%rdi, %rdi
	je	.LBB5_60
# %bb.58:
	callq	_ZdlPv
.LBB5_60:
	leaq	-656(%rbp), %rdi
	callq	_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev
	movq	%rbx, %rdi
	callq	_Unwind_Resume@PLT
.Lfunc_end5:
	.size	main, .Lfunc_end5-main
	.cfi_endproc
	.section	.gcc_except_table,"a",@progbits
	.p2align	2, 0x0
GCC_except_table5:
.Lexception0:
	.byte	255                             # @LPStart Encoding = omit
	.byte	255                             # @TType Encoding = omit
	.byte	1                               # Call site Encoding = uleb128
	.uleb128 .Lcst_end0-.Lcst_begin0
.Lcst_begin0:
	.uleb128 .Lfunc_begin0-.Lfunc_begin0    # >> Call Site 1 <<
	.uleb128 .Ltmp0-.Lfunc_begin0           #   Call between .Lfunc_begin0 and .Ltmp0
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp0-.Lfunc_begin0           # >> Call Site 2 <<
	.uleb128 .Ltmp1-.Ltmp0                  #   Call between .Ltmp0 and .Ltmp1
	.uleb128 .Ltmp24-.Lfunc_begin0          #     jumps to .Ltmp24
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp1-.Lfunc_begin0           # >> Call Site 3 <<
	.uleb128 .Ltmp2-.Ltmp1                  #   Call between .Ltmp1 and .Ltmp2
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp2-.Lfunc_begin0           # >> Call Site 4 <<
	.uleb128 .Ltmp23-.Ltmp2                 #   Call between .Ltmp2 and .Ltmp23
	.uleb128 .Ltmp24-.Lfunc_begin0          #     jumps to .Ltmp24
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp25-.Lfunc_begin0          # >> Call Site 5 <<
	.uleb128 .Ltmp28-.Ltmp25                #   Call between .Ltmp25 and .Ltmp28
	.uleb128 .Ltmp29-.Lfunc_begin0          #     jumps to .Ltmp29
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp30-.Lfunc_begin0          # >> Call Site 6 <<
	.uleb128 .Ltmp35-.Ltmp30                #   Call between .Ltmp30 and .Ltmp35
	.uleb128 .Ltmp36-.Lfunc_begin0          #     jumps to .Ltmp36
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp37-.Lfunc_begin0          # >> Call Site 7 <<
	.uleb128 .Ltmp38-.Ltmp37                #   Call between .Ltmp37 and .Ltmp38
	.uleb128 .Ltmp39-.Lfunc_begin0          #     jumps to .Ltmp39
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp40-.Lfunc_begin0          # >> Call Site 8 <<
	.uleb128 .Ltmp41-.Ltmp40                #   Call between .Ltmp40 and .Ltmp41
	.uleb128 .Ltmp42-.Lfunc_begin0          #     jumps to .Ltmp42
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp43-.Lfunc_begin0          # >> Call Site 9 <<
	.uleb128 .Ltmp62-.Ltmp43                #   Call between .Ltmp43 and .Ltmp62
	.uleb128 .Ltmp63-.Lfunc_begin0          #     jumps to .Ltmp63
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp62-.Lfunc_begin0          # >> Call Site 10 <<
	.uleb128 .Lfunc_end5-.Ltmp62            #   Call between .Ltmp62 and .Lfunc_end5
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
.Lcst_end0:
	.p2align	2, 0x0
                                        # -- End function
	.section	.text._ZNSt6vectorIP4dataSaIS1_EE17_M_realloc_insertIJRKS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_,"axG",@progbits,_ZNSt6vectorIP4dataSaIS1_EE17_M_realloc_insertIJRKS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_,comdat
	.weak	_ZNSt6vectorIP4dataSaIS1_EE17_M_realloc_insertIJRKS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_ # -- Begin function _ZNSt6vectorIP4dataSaIS1_EE17_M_realloc_insertIJRKS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_
	.p2align	1, 0x90
	.type	_ZNSt6vectorIP4dataSaIS1_EE17_M_realloc_insertIJRKS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_,@function
_ZNSt6vectorIP4dataSaIS1_EE17_M_realloc_insertIJRKS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_: # @_ZNSt6vectorIP4dataSaIS1_EE17_M_realloc_insertIJRKS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_
	.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	$24, %rsp
	.cfi_def_cfa_offset 80
	.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	%rdx, (%rsp)                    # 8-byte Spill
	movq	%rsi, %r12
	movq	%rdi, %rbx
	movl	$1, %esi
	movl	$.L.str.7, %edx
	callq	_ZNKSt6vectorIP4dataSaIS1_EE12_M_check_lenEmPKc
	movq	(%rbx), %r13
	movq	8(%rbx), %r15
	movq	%r12, 8(%rsp)                   # 8-byte Spill
	subq	%r13, %r12
	movq	%r12, %r14
	sarq	$3, %r14
	testq	%rax, %rax
	movq	%rax, 16(%rsp)                  # 8-byte Spill
	je	.LBB6_1
# %bb.2:
	movq	%rbx, %rdi
	movq	%rax, %rsi
	xorl	%edx, %edx
	callq	_ZNSt15__new_allocatorIP4dataE8allocateEmPKv
	movq	%rax, %rbp
	jmp	.LBB6_3
.LBB6_1:
	xorl	%ebp, %ebp
.LBB6_3:                                # %_ZNSt12_Vector_baseIP4dataSaIS1_EE11_M_allocateEm.exit
	movq	(%rsp), %rax                    # 8-byte Reload
	movq	(%rax), %rax
	movq	%rax, (%rbp,%r14,8)
	testq	%r12, %r12
	jle	.LBB6_5
# %bb.4:
	movq	%rbp, %rdi
	movq	%r13, %rsi
	movq	%r12, %rdx
	callq	memmove@PLT
.LBB6_5:                                # %_ZNSt6vectorIP4dataSaIS1_EE11_S_relocateEPS1_S4_S4_RS2_.exit
	addq	%rbp, %r12
	addq	$8, %r12
	movq	8(%rsp), %rsi                   # 8-byte Reload
	subq	%rsi, %r15
	testq	%r15, %r15
	jle	.LBB6_7
# %bb.6:
	movq	%r12, %rdi
	movq	%r15, %rdx
	callq	memmove@PLT
.LBB6_7:                                # %_ZNSt6vectorIP4dataSaIS1_EE11_S_relocateEPS1_S4_S4_RS2_.exit16
	testq	%r13, %r13
	je	.LBB6_9
# %bb.8:
	movq	%r13, %rdi
	callq	_ZdlPv
.LBB6_9:                                # %_ZNSt12_Vector_baseIP4dataSaIS1_EE13_M_deallocateEPS1_m.exit
	addq	%r15, %r12
	movq	%rbp, (%rbx)
	movq	%r12, 8(%rbx)
	movq	16(%rsp), %rax                  # 8-byte Reload
	leaq	(,%rax,8), %rax
	addq	%rbp, %rax
	movq	%rax, 16(%rbx)
	addq	$24, %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	_ZNSt6vectorIP4dataSaIS1_EE17_M_realloc_insertIJRKS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_, .Lfunc_end6-_ZNSt6vectorIP4dataSaIS1_EE17_M_realloc_insertIJRKS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_
	.cfi_endproc
                                        # -- End function
	.section	.text._ZNKSt6vectorIP4dataSaIS1_EE12_M_check_lenEmPKc,"axG",@progbits,_ZNKSt6vectorIP4dataSaIS1_EE12_M_check_lenEmPKc,comdat
	.weak	_ZNKSt6vectorIP4dataSaIS1_EE12_M_check_lenEmPKc # -- Begin function _ZNKSt6vectorIP4dataSaIS1_EE12_M_check_lenEmPKc
	.p2align	1, 0x90
	.type	_ZNKSt6vectorIP4dataSaIS1_EE12_M_check_lenEmPKc,@function
_ZNKSt6vectorIP4dataSaIS1_EE12_M_check_lenEmPKc: # @_ZNKSt6vectorIP4dataSaIS1_EE12_M_check_lenEmPKc
	.cfi_startproc
# %bb.0:
	movabsq	$1152921504606846975, %rcx      # imm = 0xFFFFFFFFFFFFFFF
	movq	8(%rdi), %r8
	subq	(%rdi), %r8
	sarq	$3, %r8
	movq	%rcx, %rax
	subq	%r8, %rax
	cmpq	%rsi, %rax
	jb	.LBB7_2
# %bb.1:
	cmpq	%rsi, %r8
	cmovaq	%r8, %rsi
	leaq	(%rsi,%r8), %rax
	cmpq	%rcx, %rax
	cmovaeq	%rcx, %rax
	addq	%r8, %rsi
	cmovbq	%rcx, %rax
	retq
.LBB7_2:
	pushq	%rax
	.cfi_def_cfa_offset 16
	movq	%rdx, %rdi
	callq	_ZSt20__throw_length_errorPKc
.Lfunc_end7:
	.size	_ZNKSt6vectorIP4dataSaIS1_EE12_M_check_lenEmPKc, .Lfunc_end7-_ZNKSt6vectorIP4dataSaIS1_EE12_M_check_lenEmPKc
	.cfi_endproc
                                        # -- End function
	.section	.text._ZNSt15__new_allocatorIP4dataE8allocateEmPKv,"axG",@progbits,_ZNSt15__new_allocatorIP4dataE8allocateEmPKv,comdat
	.weak	_ZNSt15__new_allocatorIP4dataE8allocateEmPKv # -- Begin function _ZNSt15__new_allocatorIP4dataE8allocateEmPKv
	.p2align	1, 0x90
	.type	_ZNSt15__new_allocatorIP4dataE8allocateEmPKv,@function
_ZNSt15__new_allocatorIP4dataE8allocateEmPKv: # @_ZNSt15__new_allocatorIP4dataE8allocateEmPKv
	.cfi_startproc
# %bb.0:
	pushq	%rax
	.cfi_def_cfa_offset 16
	movq	%rsi, %rax
	shrq	$60, %rax
	jne	.LBB8_1
# %bb.3:
	shlq	$3, %rsi
	movq	%rsi, %rdi
	popq	%rax
	.cfi_def_cfa_offset 8
	jmp	_Znwm                           # TAILCALL
.LBB8_1:
	.cfi_def_cfa_offset 16
	shrq	$61, %rsi
	je	.LBB8_2
# %bb.4:
	callq	_ZSt28__throw_bad_array_new_lengthv
.LBB8_2:
	callq	_ZSt17__throw_bad_allocv
.Lfunc_end8:
	.size	_ZNSt15__new_allocatorIP4dataE8allocateEmPKv, .Lfunc_end8-_ZNSt15__new_allocatorIP4dataE8allocateEmPKv
	.cfi_endproc
                                        # -- End function
	.text
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	jne	.LBB9_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB9_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z14trace_back_gpuPdS_S_S_dddii, %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_end9:
	.size	__hip_module_ctor, .Lfunc_end9-__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	.LBB10_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
.LBB10_2:
	retq
.Lfunc_end10:
	.size	__hip_module_dtor, .Lfunc_end10-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	NUM_STEPS,@object               # @NUM_STEPS
	.bss
	.globl	NUM_STEPS
	.p2align	2, 0x0
NUM_STEPS:
	.long	0                               # 0x0
	.size	NUM_STEPS, 4

	.type	NUM_DATA,@object                # @NUM_DATA
	.globl	NUM_DATA
	.p2align	2, 0x0
NUM_DATA:
	.long	0                               # 0x0
	.size	NUM_DATA, 4

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

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

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

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

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

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"Input error!\n"
	.size	.L.str, 14

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"./project <NUM_STEPS> <DATA_FILE>\n"
	.size	.L.str.1, 35

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"%d"
	.size	.L.str.2, 3

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"Can not open input file!\n"
	.size	.L.str.3, 26

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"num_data = "
	.size	.L.str.4, 12

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"num_step = "
	.size	.L.str.5, 12

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"Data %d: Call Price: %.5f\tPut Price: %.5f\n"
	.size	.L.str.6, 43

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"vector::_M_realloc_insert"
	.size	.L.str.7, 26

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z14trace_back_gpuPdS_S_S_dddii"
	.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 _Z29__device_stub__trace_back_gpuPdS_S_S_dddii
	.addrsig_sym __gxx_personality_v0
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Unwind_Resume
	.addrsig_sym NUM_STEPS
	.addrsig_sym NUM_DATA
	.addrsig_sym C_gpu
	.addrsig_sym P_gpu
	.addrsig_sym C_price_gpu
	.addrsig_sym P_price_gpu
	.addrsig_sym _Z14trace_back_gpuPdS_S_S_dddii
	.addrsig_sym _ZSt4cout
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z14trace_back_gpuPdS_S_S_dddii ; -- Begin function _Z14trace_back_gpuPdS_S_S_dddii
	.globl	_Z14trace_back_gpuPdS_S_S_dddii
	.p2align	8
	.type	_Z14trace_back_gpuPdS_S_S_dddii,@function
_Z14trace_back_gpuPdS_S_S_dddii:        ; @_Z14trace_back_gpuPdS_S_S_dddii
; %bb.0:
	s_clause 0x3
	s_load_b32 s12, s[0:1], 0x4c
	s_load_b64 s[2:3], s[0:1], 0x38
	s_load_b256 s[4:11], s[0:1], 0x0
	s_load_b256 s[16:23], s[0:1], 0x20
	v_and_b32_e32 v3, 0x3ff, v0
	s_mov_b32 s1, 0
	s_waitcnt lgkmcnt(0)
	s_and_b32 s0, s12, 0xffff
	s_cmp_lt_i32 s3, 0
	v_mad_u64_u32 v[1:2], null, s14, s0, v[3:4]
	s_cbranch_scc1 .LBB0_5
; %bb.1:                                ; %.lr.ph
	s_add_i32 s0, s3, 1
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	v_mul_lo_u32 v2, v1, s0
	s_mov_b32 s13, s0
	s_delay_alu instid0(VALU_DEP_1)
	v_mov_b32_e32 v3, v2
.LBB0_2:                                ; =>This Inner Loop Header: Depth=1
	s_delay_alu instid0(VALU_DEP_1)
	v_ashrrev_i32_e32 v4, 31, v3
	v_mov_b32_e32 v6, s1
	s_add_i32 s13, s13, -1
	s_add_i32 s1, s1, 8
	s_cmp_eq_u32 s13, 0
	v_lshlrev_b64 v[4:5], 3, v[3:4]
	v_add_nc_u32_e32 v3, 1, v3
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_co_u32 v4, vcc_lo, s4, v4
	v_add_co_ci_u32_e32 v5, vcc_lo, s5, v5, vcc_lo
	global_load_b64 v[4:5], v[4:5], off
	s_waitcnt vmcnt(0)
	ds_store_b64 v6, v[4:5]
	s_cbranch_scc0 .LBB0_2
; %bb.3:                                ; %.preheader56
	s_lshl_b32 s1, s3, 3
	s_delay_alu instid0(SALU_CYCLE_1)
	s_add_i32 s1, s1, 8
.LBB0_4:                                ; =>This Inner Loop Header: Depth=1
	v_ashrrev_i32_e32 v3, 31, v2
	v_mov_b32_e32 v5, s1
	s_add_i32 s0, s0, -1
	s_add_i32 s1, s1, 8
	s_cmp_eq_u32 s0, 0
	v_lshlrev_b64 v[3:4], 3, v[2:3]
	v_add_nc_u32_e32 v2, 1, v2
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_co_u32 v3, vcc_lo, s6, v3
	v_add_co_ci_u32_e32 v4, vcc_lo, s7, v4, vcc_lo
	global_load_b64 v[3:4], v[3:4], off
	s_waitcnt vmcnt(0)
	ds_store_b64 v5, v[3:4]
	s_cbranch_scc0 .LBB0_4
.LBB0_5:                                ; %._crit_edge
	v_bfe_u32 v0, v0, 10, 10
	s_lshr_b32 s0, s12, 16
	s_delay_alu instid0(VALU_DEP_2)
	v_cmp_gt_i32_e32 vcc_lo, s2, v1
	s_waitcnt lgkmcnt(0)
	s_barrier
	v_mad_u64_u32 v[2:3], null, s15, s0, v[0:1]
	buffer_gl0_inv
	v_cmp_gt_i32_e64 s0, s3, v2
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(SALU_CYCLE_1)
	s_and_b32 s0, vcc_lo, s0
	s_cmp_gt_i32 s3, 0
	s_cselect_b32 s1, -1, 0
	s_and_b32 s0, s0, s1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_saveexec_b32 s1, s0
	s_cbranch_execz .LBB0_8
; %bb.6:                                ; %.lr.ph63
	v_mul_f64 v[3:4], -s[16:17], s[18:19]
	s_mov_b32 s4, 0x652b82fe
	s_mov_b32 s5, 0x3ff71547
	s_mov_b32 s6, 0x6a5dcb37
	s_mov_b32 s7, 0x3e5ade15
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_4) | instid1(VALU_DEP_3)
	v_mul_f64 v[5:6], v[3:4], s[4:5]
	s_mov_b32 s4, 0xfefa39ef
	s_mov_b32 s5, 0xbfe62e42
	v_cmp_nlt_f64_e32 vcc_lo, 0x40900000, v[3:4]
	v_cmp_ngt_f64_e64 s0, 0xc090cc00, v[3:4]
	v_rndne_f64_e32 v[5:6], v[5:6]
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_4) | instid1(VALU_DEP_3)
	v_fma_f64 v[7:8], v[5:6], s[4:5], v[3:4]
	s_mov_b32 s4, 0x3b39803f
	s_mov_b32 s5, 0xbc7abc9e
	v_cvt_i32_f64_e32 v0, v[5:6]
	v_add_f64 v[3:4], -s[20:21], 1.0
	v_fma_f64 v[7:8], v[5:6], s[4:5], v[7:8]
	s_mov_b32 s4, 0xfca7ab0c
	s_mov_b32 s5, 0x3e928af3
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	v_fma_f64 v[9:10], v[7:8], s[6:7], s[4:5]
	s_mov_b32 s4, 0x623fde64
	s_mov_b32 s5, 0x3ec71dee
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	v_fma_f64 v[9:10], v[7:8], v[9:10], s[4:5]
	s_mov_b32 s4, 0x7c89e6b0
	s_mov_b32 s5, 0x3efa0199
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	v_fma_f64 v[9:10], v[7:8], v[9:10], s[4:5]
	s_mov_b32 s4, 0x14761f6e
	s_mov_b32 s5, 0x3f2a01a0
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	v_fma_f64 v[9:10], v[7:8], v[9:10], s[4:5]
	s_mov_b32 s4, 0x1852b7b0
	s_mov_b32 s5, 0x3f56c16c
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	v_fma_f64 v[9:10], v[7:8], v[9:10], s[4:5]
	s_mov_b32 s4, 0x11122322
	s_mov_b32 s5, 0x3f811111
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	v_fma_f64 v[9:10], v[7:8], v[9:10], s[4:5]
	s_mov_b32 s4, 0x555502a1
	s_mov_b32 s5, 0x3fa55555
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	v_fma_f64 v[9:10], v[7:8], v[9:10], s[4:5]
	s_mov_b32 s4, 0x55555511
	s_mov_b32 s5, 0x3fc55555
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	v_fma_f64 v[9:10], v[7:8], v[9:10], s[4:5]
	s_mov_b32 s4, 11
	s_mov_b32 s5, 0x3fe00000
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	v_fma_f64 v[9:10], v[7:8], v[9:10], s[4:5]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[9:10], v[7:8], v[9:10], 1.0
	v_fma_f64 v[5:6], v[7:8], v[9:10], 1.0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ldexp_f64 v[5:6], v[5:6], v0
	v_cndmask_b32_e32 v6, 0x7ff00000, v6, vcc_lo
	s_and_b32 vcc_lo, s0, vcc_lo
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_dual_cndmask_b32 v5, 0, v5 :: v_dual_lshlrev_b32 v0, 3, v2
	v_cndmask_b32_e64 v6, 0, v6, s0
	s_mov_b32 s0, s3
	s_delay_alu instid0(VALU_DEP_2)
	v_lshl_add_u32 v2, s3, 3, v0
.LBB0_7:                                ; =>This Inner Loop Header: Depth=1
	ds_load_2addr_b64 v[7:10], v0 offset1:1
	s_add_i32 s0, s0, -1
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	s_cmp_lg_u32 s0, 0
	s_waitcnt lgkmcnt(0)
	v_mul_f64 v[9:10], v[3:4], v[9:10]
	v_fma_f64 v[7:8], v[7:8], s[20:21], v[9:10]
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_4) | instid1(VALU_DEP_1)
	v_mul_f64 v[7:8], v[5:6], v[7:8]
	ds_store_b64 v0, v[7:8]
	ds_load_2addr_b64 v[7:10], v2 offset0:1 offset1:2
	s_waitcnt lgkmcnt(0)
	v_mul_f64 v[9:10], v[3:4], v[9:10]
	v_fma_f64 v[7:8], v[7:8], s[20:21], v[9:10]
	s_delay_alu instid0(VALU_DEP_1)
	v_mul_f64 v[7:8], v[5:6], v[7:8]
	ds_store_b64 v2, v[7:8] offset:8
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	s_cbranch_scc1 .LBB0_7
.LBB0_8:                                ; %Flow109
	s_or_b32 exec_lo, exec_lo, s1
	s_lshl_b32 s0, s3, 3
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_4) | instid1(VALU_DEP_1)
	v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v5, s0
	v_ashrrev_i32_e32 v2, 31, v1
	ds_load_b64 v[3:4], v0
	ds_load_b64 v[5:6], v5 offset:8
	v_lshlrev_b64 v[0:1], 3, v[1:2]
	v_add_co_u32 v7, vcc_lo, s8, v0
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v8, vcc_lo, s9, v1, vcc_lo
	v_add_co_u32 v0, vcc_lo, s10, v0
	v_add_co_ci_u32_e32 v1, vcc_lo, s11, v1, vcc_lo
	s_waitcnt lgkmcnt(1)
	global_store_b64 v[7:8], v[3:4], off
	s_waitcnt lgkmcnt(0)
	global_store_b64 v[0:1], v[5:6], off
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z14trace_back_gpuPdS_S_S_dddii
		.amdhsa_group_segment_fixed_size 32000
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 320
		.amdhsa_user_sgpr_count 14
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 1
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 1
		.amdhsa_next_free_vgpr 11
		.amdhsa_next_free_sgpr 24
		.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	_Z14trace_back_gpuPdS_S_S_dddii, .Lfunc_end0-_Z14trace_back_gpuPdS_S_S_dddii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 1056
; NumSgprs: 26
; NumVgprs: 11
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 32000 bytes/workgroup (compile time only)
; SGPRBlocks: 3
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 26
; NumVGPRsForWavesPerEU: 11
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 14
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 1
	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __hip_cuid_
	.amdgpu_metadata
---
amdhsa.kernels:
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         16
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         24
        .size:           8
        .value_kind:     global_buffer
      - .offset:         32
        .size:           8
        .value_kind:     by_value
      - .offset:         40
        .size:           8
        .value_kind:     by_value
      - .offset:         48
        .size:           8
        .value_kind:     by_value
      - .offset:         56
        .size:           4
        .value_kind:     by_value
      - .offset:         60
        .size:           4
        .value_kind:     by_value
      - .offset:         64
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         68
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         72
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         76
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         78
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         80
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         82
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         84
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         86
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         104
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         112
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         120
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         128
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 32000
    .kernarg_segment_align: 8
    .kernarg_segment_size: 320
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z14trace_back_gpuPdS_S_S_dddii
    .private_segment_fixed_size: 0
    .sgpr_count:     26
    .sgpr_spill_count: 0
    .symbol:         _Z14trace_back_gpuPdS_S_S_dddii.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     11
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
