#include <iostream>
#include <cstdlib>
#include <ctime>

#define MAXN 30000000
#define A (-1.0)
#define B (1.0)

//säieryhmän koko
#define LOCAL_SIZE 1024

//säieryhmien määrä
//#define WG_COUNT (MAXN/LOCAL_SIZE+1)


//ydin, jolle annetaan kaksi n kokoista vektoria x ja y, sekä
//liukuluku m, joille suoritetaan axpy-operaatio
__global__ void axpy(double *x, double *y, double m, int n) {

	const int global_id = blockIdx.x * blockDim.x + threadIdx.x;


	if(global_id < n)
		y[global_id] = m * x[global_id] + y[global_id];

}


//tarkistetaan onko doublet samoja
bool double_equals( double a, double b, double epsilon = 0.0001) {

	return std::abs(a-b) < epsilon;
}

int main() {

	cudaError err;

	// Alustetaan satunnaislukugeneraattori kellonajalla
	srand(time(NULL));

	// Satunnainen kokonaisluku väliltä [1,MAXN]
	int n = rand() % MAXN + 1;

	// Varataan tilaa vektoreille ja luodaan satunnainen liukuluku
	double *x = new double[n];
	double *y = new double[n];
	double m = (B-A)*((double)rand()/RAND_MAX)+A;

	//ja vektorit testaamista varten
	double *x_test = new double[n];
	double *y_test = new double[n];


	// Generoidaan kaksi satunnaista vektoria
	for(int i = 0; i < n; i++) {
		x[i] = (B-A)*((double)rand()/RAND_MAX)+A;
		y[i] = (B-A)*((double)rand()/RAND_MAX)+A;
	}

	//kopioidaan vektorit talteen testaamista varten
	for(int i = 0; i < n; i++) {
		x_test[i] = x[i];
		y_test[i] = y[i];
	}

	//Varataan muisti Cuda-laitteelta

	double *deviceBuffer1, *deviceBuffer2;

	//Varataan deviceBuffer1
	err = cudaMalloc((void **)&deviceBuffer1, n*sizeof(double));

	if(err != cudaSuccess) {
		std::cout << "Muistin varaaminen epäonnistui." << std::endl;

		// cudaError on union-tietotyyppi. Virhekoodia vastaava virheviestijono
		// saadaan selville cudaGetErrorString-aliohjelman avulla.
		std::cerr << "CUDA-virhekoodi: " << cudaGetErrorString(err) <<
			std::endl;
		delete [] x;
		delete [] y;
		delete [] x_test;
		delete [] y_test;
		return 1;
	}

	//Varataan deviceBuffer2
	err = cudaMalloc((void **)&deviceBuffer2, n*sizeof(double));

	if(err != cudaSuccess) {
		std::cout << "Muistin varaaminen epäonnistui." << std::endl;

		// cudaError on union-tietotyyppi. Virhekoodia vastaava virheviestijono
		// saadaan selville cudaGetErrorString-aliohjelman avulla.
		std::cerr << "CUDA-virhekoodi: " << cudaGetErrorString(err) <<
			std::endl;
			delete [] x;
			delete [] y;
			delete [] x_test;
			delete [] y_test;
		return 1;
	}

	//Siirretään data cuda-laitteelle

  	//Siirretään x -> deviceBuffer1
	err = cudaMemcpy(
		deviceBuffer1, x, n*sizeof(double), cudaMemcpyHostToDevice);

	if(err != cudaSuccess) {
		std::cout << "Isäntälaite -> GPU -siirtokäskyn asettaminen " \
			"komentojonoon epäonnistui." << std::endl;
		std::cerr << "CUDA-virhekoodi: " << cudaGetErrorString(err) <<
			std::endl;

		cudaFree(deviceBuffer1);
		cudaFree(deviceBuffer2);
		delete [] x;
		delete [] y;
		delete [] x_test;
		delete [] y_test;
		return 1;
	}

	//Siirretään y -> deviceBuffer2
	err = cudaMemcpy(
		deviceBuffer2, y, n*sizeof(double), cudaMemcpyHostToDevice);

	if(err != cudaSuccess) {
		std::cout << "Isäntälaite -> GPU -siirtokäskyn asettaminen " \
			"komentojonoon epäonnistui." << std::endl;
		std::cerr << "CUDA-virhekoodi: " << cudaGetErrorString(err) <<
			std::endl;

		cudaFree(deviceBuffer1);
		cudaFree(deviceBuffer2);
		delete [] x;
		delete [] y;
		delete [] x_test;
		delete [] y_test;
		return 1;
	}

	//ytimen käynnistäminen

	// Säieryhmien määrä
	dim3 WGCount(n/LOCAL_SIZE+1, 1, 1);

	// Lokaalin indeksiavaruuden koko
	dim3 localDim(LOCAL_SIZE, 1, 1);

	axpy<<<WGCount, localDim>>>(deviceBuffer1, deviceBuffer2, m, n);

	//kysytään tuliko ytimen käynnistämisessä virheitä
	err = cudaGetLastError();

	if(err != cudaSuccess) {
		std::cout << "Ytimen käynnistyskäskyn asettaminen komentojonoon " \
			"epäonnistui." << std::endl;
		std::cerr << "CUDA-virhekoodi: " << cudaGetErrorString(err) <<
			std::endl;

		cudaFree(deviceBuffer1);
		cudaFree(deviceBuffer2);
		delete [] x;
		delete [] y;
		delete [] x_test;
		delete [] y_test;
		return 1;
	}

	//
	// Siirretään data takaisin isäntälaiteen muistiin
	//

	//x ja deviceBuffer1
	cudaMemcpy(x, deviceBuffer1, n*sizeof(double), cudaMemcpyDeviceToHost);

	if(err != cudaSuccess) {
		std::cout << "GPU -> Isäntälaite -siirtokäskyn asettaminen " \
			"komentojonoon epäonnistui." << std::endl;
		std::cerr << "CUDA-virhekoodi: " << cudaGetErrorString(err) <<
			std::endl;

			cudaFree(deviceBuffer1);
			cudaFree(deviceBuffer2);
			delete [] x;
			delete [] y;
			delete [] x_test;
			delete [] y_test;
		return 1;
	}

	//y ja deviceBuffer2
	cudaMemcpy(y, deviceBuffer2, n*sizeof(double), cudaMemcpyDeviceToHost);

		if(err != cudaSuccess) {
			std::cout << "GPU -> Isäntälaite -siirtokäskyn asettaminen " \
				"komentojonoon epäonnistui." << std::endl;
			std::cerr << "CUDA-virhekoodi: " << cudaGetErrorString(err) <<
				std::endl;

			cudaFree(deviceBuffer1);
			cudaFree(deviceBuffer2);
			delete [] x;
			delete [] y;
			delete [] x_test;
			delete [] y_test;
			return 1;
		}

		//
		// Tarkistetaan tulos
		//


		//lasketaan axpy cpu:lla
		for(int i = 0; i < n; i++) {
			y_test[i] = m * x_test[i] + y_test[i];
		}

		//tarkistetaan ovatko kaikki y:n arvot samoja
		bool correct = true;
		for(int i = 0; i < n; i++) {
			if (double_equals(y_test[i], y[i]) != true) {
				correct = false;
				//tulostetaan eriävät arvot
				std::cout << y_test[i] << std::endl;
				std::cout << y[i] << std::endl;
				break;
			}
		}

		std::cout << "The result was " ;
		if (!correct) {
			std::cout << "incorrect." << std::endl;
		}
		else std::cout << "correct." << std::endl;


		//
		// Vapautetaan CUDA-laitteen puolelta varattu muisti
		//
		err = cudaFree(deviceBuffer1);

		if(err != cudaSuccess) {
			std::cout << "Muistin vapauttaminen epäonnistui epäonnistui." <<
				std::endl;
			std::cerr << "CUDA-virhekoodi: " << cudaGetErrorString(err) <<
				std::endl;

			delete [] x;
			delete [] y;
			delete [] x_test;
			delete [] y_test;
			return 1;
		}

		err = cudaFree(deviceBuffer2);

		if(err != cudaSuccess) {
			std::cout << "Muistin vapauttaminen epäonnistui epäonnistui." <<
				std::endl;
			std::cerr << "CUDA-virhekoodi: " << cudaGetErrorString(err) <<
				std::endl;

			delete [] x;
			delete [] y;
			delete [] x_test;
			delete [] y_test;
			return 1;
		}

		delete [] x;
		delete [] y;
		delete [] x_test;
		delete [] y_test;

		return 0;
}

	.file	"tmpxft_002a2bf6_00000000-6_axpy.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB3639:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE3639:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.align 2
	.type	_ZNSolsEPFRSoS_E.isra.0, @function
_ZNSolsEPFRSoS_E.isra.0:
.LFB4294:
	.cfi_startproc
	jmp	*%rsi
	.cfi_endproc
.LFE4294:
	.size	_ZNSolsEPFRSoS_E.isra.0, .-_ZNSolsEPFRSoS_E.isra.0
	.globl	_Z13double_equalsddd
	.type	_Z13double_equalsddd, @function
_Z13double_equalsddd:
.LFB3635:
	.cfi_startproc
	endbr64
	subsd	%xmm1, %xmm0
	andps	.LC0(%rip), %xmm0
	comisd	%xmm0, %xmm2
	seta	%al
	ret
	.cfi_endproc
.LFE3635:
	.size	_Z13double_equalsddd, .-_Z13double_equalsddd
	.globl	_Z27__device_stub__Z4axpyPdS_diPdS_di
	.type	_Z27__device_stub__Z4axpyPdS_diPdS_di, @function
_Z27__device_stub__Z4axpyPdS_diPdS_di:
.LFB3661:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movq	%rdi, 24(%rsp)
	leaq	48(%rsp), %rcx
	leaq	56(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	68(%rsp), %rsi
	movl	%edx, 4(%rsp)
	leaq	40(%rsp), %rdx
	movsd	%xmm0, 8(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 64(%rsp)
	movq	%rax, 104(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	4(%rsp), %rax
	movq	%rax, 128(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 56(%rsp)
	movq	%rax, 68(%rsp)
	movl	$1, 76(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L4
	pushq	48(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z4axpyPdS_di(%rip), %rdi
	pushq	48(%rsp)
	.cfi_def_cfa_offset 176
	movq	84(%rsp), %rcx
	movl	92(%rsp), %r8d
	movq	72(%rsp), %rsi
	movl	80(%rsp), %edx
	leaq	120(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 168
	popq	%rdx
	.cfi_def_cfa_offset 160
.L4:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L6
	call	__stack_chk_fail@PLT
.L6:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3661:
	.size	_Z27__device_stub__Z4axpyPdS_diPdS_di, .-_Z27__device_stub__Z4axpyPdS_diPdS_di
	.globl	_Z4axpyPdS_di
	.type	_Z4axpyPdS_di, @function
_Z4axpyPdS_di:
.LFB3662:
	.cfi_startproc
	endbr64
	jmp	_Z27__device_stub__Z4axpyPdS_diPdS_di
	.cfi_endproc
.LFE3662:
	.size	_Z4axpyPdS_di, .-_Z4axpyPdS_di
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC3:
	.string	"Muistin varaaminen ep\303\244onnistui."
.LC4:
	.string	"CUDA-virhekoodi: "
.LC5:
	.string	"Is\303\244nt\303\244laite -> GPU -siirtok\303\244skyn asettaminen komentojonoon ep\303\244onnistui."
.LC6:
	.string	"Ytimen k\303\244ynnistysk\303\244skyn asettaminen komentojonoon ep\303\244onnistui."
.LC8:
	.string	"The result was "
.LC9:
	.string	"incorrect."
.LC10:
	.string	"correct."
.LC11:
	.string	"Muistin vapauttaminen ep\303\244onnistui ep\303\244onnistui."
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB3636:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	xorl	%edi, %edi
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$72, %rsp
	.cfi_def_cfa_offset 128
	movq	%fs:40, %rax
	movq	%rax, 56(%rsp)
	xorl	%eax, %eax
	call	time@PLT
	movl	%eax, %edi
	call	srand@PLT
	call	rand@PLT
	movl	$30000000, %ecx
	cltd
	idivl	%ecx
	leal	1(%rdx), %r14d
	movabsq	$1152921504606846975, %rdx
	movslq	%r14d, %rax
	cmpq	%rax, %rdx
	jb	.L11
	salq	$3, %rax
	xorl	%r15d, %r15d
	movq	%rax, %rdi
	movq	%rax, (%rsp)
	call	_Znam@PLT
	movq	(%rsp), %rdi
	movq	%rax, %r12
	call	_Znam@PLT
	movq	%rax, %rbx
	call	rand@PLT
	movq	(%rsp), %rdi
	movl	%eax, 8(%rsp)
	call	_Znam@PLT
	movq	(%rsp), %rdi
	movq	%rax, %r13
	call	_Znam@PLT
	movq	%rax, %rbp
	jmp	.L12
.L11:
	movq	56(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L41
	call	__cxa_throw_bad_array_new_length@PLT
.L12:
	cmpl	%r15d, %r14d
	jle	.L45
	call	rand@PLT
	cvtsi2sdl	%eax, %xmm0
	divsd	.LC1(%rip), %xmm0
	addsd	%xmm0, %xmm0
	subsd	.LC2(%rip), %xmm0
	movsd	%xmm0, (%r12,%r15,8)
	call	rand@PLT
	cvtsi2sdl	%eax, %xmm0
	divsd	.LC1(%rip), %xmm0
	addsd	%xmm0, %xmm0
	subsd	.LC2(%rip), %xmm0
	movsd	%xmm0, (%rbx,%r15,8)
	incq	%r15
	jmp	.L12
.L45:
	xorl	%eax, %eax
.L15:
	cmpl	%eax, %r14d
	jle	.L46
	movsd	(%r12,%rax,8), %xmm0
	movsd	%xmm0, 0(%r13,%rax,8)
	movsd	(%rbx,%rax,8), %xmm0
	movsd	%xmm0, 0(%rbp,%rax,8)
	incq	%rax
	jmp	.L15
.L46:
	movq	(%rsp), %rsi
	leaq	16(%rsp), %rdi
	call	cudaMalloc@PLT
	movl	%eax, %edx
	testl	%eax, %eax
	jne	.L37
	movq	(%rsp), %rsi
	leaq	24(%rsp), %rdi
	call	cudaMalloc@PLT
	movl	%eax, %edx
	testl	%eax, %eax
	je	.L19
.L37:
	leaq	.LC3(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rdi
	movl	%edx, (%rsp)
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	leaq	_ZSt4cerr(%rip), %rdi
	leaq	.LC4(%rip), %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	(%rsp), %edi
	movq	%rax, %r14
.L38:
	call	cudaGetErrorString@PLT
	movq	%r14, %rdi
	movq	%rax, %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
.L39:
	movq	%r12, %rdi
	call	_ZdaPv@PLT
	movq	%rbx, %rdi
	call	_ZdaPv@PLT
	movq	%r13, %rdi
	call	_ZdaPv@PLT
	movq	%rbp, %rdi
	call	_ZdaPv@PLT
	movl	$1, %eax
	jmp	.L10
.L19:
	movq	(%rsp), %rdx
	movq	16(%rsp), %rdi
	movl	$1, %ecx
	movq	%r12, %rsi
	call	cudaMemcpy@PLT
	movl	%eax, %edx
	testl	%eax, %eax
	jne	.L43
	movq	(%rsp), %rdx
	movq	24(%rsp), %rdi
	movl	$1, %ecx
	movq	%rbx, %rsi
	call	cudaMemcpy@PLT
	movl	%eax, %edx
	testl	%eax, %eax
	je	.L22
.L43:
	leaq	.LC5(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rdi
	movl	%edx, (%rsp)
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	leaq	_ZSt4cerr(%rip), %rdi
	leaq	.LC4(%rip), %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	(%rsp), %edi
	movq	%rax, %r14
	jmp	.L44
.L22:
	movl	%r14d, %eax
	cvtsi2sdl	8(%rsp), %xmm0
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	sarl	$10, %eax
	movl	$4194305, %edx
	movl	$1, %ecx
	divsd	.LC1(%rip), %xmm0
	incl	%eax
	addsd	%xmm0, %xmm0
	subsd	.LC2(%rip), %xmm0
	salq	$10, %rdx
	movl	%eax, 32(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 36(%rsp)
	movq	32(%rsp), %rdi
	movl	40(%rsp), %esi
	movsd	%xmm0, 8(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L23
	movsd	8(%rsp), %xmm0
	movq	24(%rsp), %rsi
	movl	%r14d, %edx
	movq	16(%rsp), %rdi
	call	_Z27__device_stub__Z4axpyPdS_diPdS_di
.L23:
	call	cudaGetLastError@PLT
	movl	%eax, %r15d
	testl	%eax, %eax
	je	.L24
	leaq	.LC6(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	leaq	_ZSt4cerr(%rip), %rdi
	leaq	.LC4(%rip), %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	%r15d, %edi
	movq	%rax, %r14
.L44:
	call	cudaGetErrorString@PLT
	movq	%r14, %rdi
	movq	%rax, %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
	movq	16(%rsp), %rdi
	call	cudaFree@PLT
	movq	24(%rsp), %rdi
	call	cudaFree@PLT
	jmp	.L39
.L24:
	movq	(%rsp), %rdx
	movq	16(%rsp), %rsi
	movl	$2, %ecx
	movq	%r12, %rdi
	call	cudaMemcpy@PLT
	movq	(%rsp), %rdx
	movq	24(%rsp), %rsi
	movq	%rbx, %rdi
	movl	$2, %ecx
	call	cudaMemcpy@PLT
	xorl	%eax, %eax
.L25:
	cmpl	%eax, %r14d
	jle	.L47
	movsd	8(%rsp), %xmm0
	mulsd	0(%r13,%rax,8), %xmm0
	addsd	0(%rbp,%rax,8), %xmm0
	movsd	%xmm0, 0(%rbp,%rax,8)
	incq	%rax
	jmp	.L25
.L47:
	movq	.LC0(%rip), %xmm2
	movsd	.LC7(%rip), %xmm3
	movq	%rbx, %rdx
	xorl	%eax, %eax
.L27:
	cmpl	%eax, %r14d
	jle	.L48
	movsd	0(%rbp,%rax,8), %xmm1
	movq	%rdx, %r15
	incq	%rax
	addq	$8, %rdx
	movaps	%xmm1, %xmm0
	subsd	(%r15), %xmm0
	andps	%xmm2, %xmm0
	comisd	%xmm0, %xmm3
	ja	.L27
	leaq	_ZSt4cout(%rip), %r14
	movaps	%xmm1, %xmm0
	movq	%r14, %rdi
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	movsd	(%r15), %xmm0
	movq	%r14, %rdi
	xorl	%r15d, %r15d
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	jmp	.L28
.L48:
	movb	$1, %r15b
.L28:
	leaq	_ZSt4cout(%rip), %r14
	leaq	.LC8(%rip), %rsi
	movq	%r14, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC9(%rip), %rsi
	testb	%r15b, %r15b
	je	.L40
	leaq	.LC10(%rip), %rsi
.L40:
	movq	%r14, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	movq	16(%rsp), %rdi
	call	cudaFree@PLT
	movl	%eax, %r15d
	testl	%eax, %eax
	jne	.L42
	movq	24(%rsp), %rdi
	call	cudaFree@PLT
	movl	%eax, %r15d
	testl	%eax, %eax
	je	.L33
.L42:
	movq	%r14, %rdi
	leaq	.LC11(%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
	leaq	_ZSt4cerr(%rip), %rdi
	leaq	.LC4(%rip), %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	%r15d, %edi
	movq	%rax, %r14
	jmp	.L38
.L33:
	movq	%r12, %rdi
	call	_ZdaPv@PLT
	movq	%rbx, %rdi
	call	_ZdaPv@PLT
	movq	%r13, %rdi
	call	_ZdaPv@PLT
	movq	%rbp, %rdi
	call	_ZdaPv@PLT
	xorl	%eax, %eax
.L10:
	movq	56(%rsp), %rdx
	subq	%fs:40, %rdx
	je	.L34
.L41:
	call	__stack_chk_fail@PLT
.L34:
	addq	$72, %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
.LFE3636:
	.size	main, .-main
	.section	.rodata.str1.1
.LC12:
	.string	"_Z4axpyPdS_di"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB3664:
	.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	.LC12(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z4axpyPdS_di(%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
.LFE3664:
	.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
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC0:
	.long	-1
	.long	2147483647
	.long	0
	.long	0
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC1:
	.long	-4194304
	.long	1105199103
	.align 8
.LC2:
	.long	0
	.long	1072693248
	.align 8
.LC7:
	.long	-350469331
	.long	1058682594
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:


#include <hip/hip_runtime.h>
#include <iostream>
#include <cstdlib>
#include <ctime>

#define MAXN 30000000
#define A (-1.0)
#define B (1.0)

//säieryhmän koko
#define LOCAL_SIZE 1024

//säieryhmien määrä
//#define WG_COUNT (MAXN/LOCAL_SIZE+1)


//ydin, jolle annetaan kaksi n kokoista vektoria x ja y, sekä
//liukuluku m, joille suoritetaan axpy-operaatio
__global__ void axpy(double *x, double *y, double m, int n) {

	const int global_id = blockIdx.x * blockDim.x + threadIdx.x;


	if(global_id < n)
		y[global_id] = m * x[global_id] + y[global_id];

}


//tarkistetaan onko doublet samoja
bool double_equals( double a, double b, double epsilon = 0.0001) {

	return std::abs(a-b) < epsilon;
}

int main() {

	hipError_t err;

	// Alustetaan satunnaislukugeneraattori kellonajalla
	srand(time(NULL));

	// Satunnainen kokonaisluku väliltä [1,MAXN]
	int n = rand() % MAXN + 1;

	// Varataan tilaa vektoreille ja luodaan satunnainen liukuluku
	double *x = new double[n];
	double *y = new double[n];
	double m = (B-A)*((double)rand()/RAND_MAX)+A;

	//ja vektorit testaamista varten
	double *x_test = new double[n];
	double *y_test = new double[n];


	// Generoidaan kaksi satunnaista vektoria
	for(int i = 0; i < n; i++) {
		x[i] = (B-A)*((double)rand()/RAND_MAX)+A;
		y[i] = (B-A)*((double)rand()/RAND_MAX)+A;
	}

	//kopioidaan vektorit talteen testaamista varten
	for(int i = 0; i < n; i++) {
		x_test[i] = x[i];
		y_test[i] = y[i];
	}

	//Varataan muisti Cuda-laitteelta

	double *deviceBuffer1, *deviceBuffer2;

	//Varataan deviceBuffer1
	err = hipMalloc((void **)&deviceBuffer1, n*sizeof(double));

	if(err != hipSuccess) {
		std::cout << "Muistin varaaminen epäonnistui." << std::endl;

		// cudaError on union-tietotyyppi. Virhekoodia vastaava virheviestijono
		// saadaan selville cudaGetErrorString-aliohjelman avulla.
		std::cerr << "CUDA-virhekoodi: " << hipGetErrorString(err) <<
			std::endl;
		delete [] x;
		delete [] y;
		delete [] x_test;
		delete [] y_test;
		return 1;
	}

	//Varataan deviceBuffer2
	err = hipMalloc((void **)&deviceBuffer2, n*sizeof(double));

	if(err != hipSuccess) {
		std::cout << "Muistin varaaminen epäonnistui." << std::endl;

		// cudaError on union-tietotyyppi. Virhekoodia vastaava virheviestijono
		// saadaan selville cudaGetErrorString-aliohjelman avulla.
		std::cerr << "CUDA-virhekoodi: " << hipGetErrorString(err) <<
			std::endl;
			delete [] x;
			delete [] y;
			delete [] x_test;
			delete [] y_test;
		return 1;
	}

	//Siirretään data cuda-laitteelle

  	//Siirretään x -> deviceBuffer1
	err = hipMemcpy(
		deviceBuffer1, x, n*sizeof(double), hipMemcpyHostToDevice);

	if(err != hipSuccess) {
		std::cout << "Isäntälaite -> GPU -siirtokäskyn asettaminen " \
			"komentojonoon epäonnistui." << std::endl;
		std::cerr << "CUDA-virhekoodi: " << hipGetErrorString(err) <<
			std::endl;

		hipFree(deviceBuffer1);
		hipFree(deviceBuffer2);
		delete [] x;
		delete [] y;
		delete [] x_test;
		delete [] y_test;
		return 1;
	}

	//Siirretään y -> deviceBuffer2
	err = hipMemcpy(
		deviceBuffer2, y, n*sizeof(double), hipMemcpyHostToDevice);

	if(err != hipSuccess) {
		std::cout << "Isäntälaite -> GPU -siirtokäskyn asettaminen " \
			"komentojonoon epäonnistui." << std::endl;
		std::cerr << "CUDA-virhekoodi: " << hipGetErrorString(err) <<
			std::endl;

		hipFree(deviceBuffer1);
		hipFree(deviceBuffer2);
		delete [] x;
		delete [] y;
		delete [] x_test;
		delete [] y_test;
		return 1;
	}

	//ytimen käynnistäminen

	// Säieryhmien määrä
	dim3 WGCount(n/LOCAL_SIZE+1, 1, 1);

	// Lokaalin indeksiavaruuden koko
	dim3 localDim(LOCAL_SIZE, 1, 1);

	axpy<<<WGCount, localDim>>>(deviceBuffer1, deviceBuffer2, m, n);

	//kysytään tuliko ytimen käynnistämisessä virheitä
	err = hipGetLastError();

	if(err != hipSuccess) {
		std::cout << "Ytimen käynnistyskäskyn asettaminen komentojonoon " \
			"epäonnistui." << std::endl;
		std::cerr << "CUDA-virhekoodi: " << hipGetErrorString(err) <<
			std::endl;

		hipFree(deviceBuffer1);
		hipFree(deviceBuffer2);
		delete [] x;
		delete [] y;
		delete [] x_test;
		delete [] y_test;
		return 1;
	}

	//
	// Siirretään data takaisin isäntälaiteen muistiin
	//

	//x ja deviceBuffer1
	hipMemcpy(x, deviceBuffer1, n*sizeof(double), hipMemcpyDeviceToHost);

	if(err != hipSuccess) {
		std::cout << "GPU -> Isäntälaite -siirtokäskyn asettaminen " \
			"komentojonoon epäonnistui." << std::endl;
		std::cerr << "CUDA-virhekoodi: " << hipGetErrorString(err) <<
			std::endl;

			hipFree(deviceBuffer1);
			hipFree(deviceBuffer2);
			delete [] x;
			delete [] y;
			delete [] x_test;
			delete [] y_test;
		return 1;
	}

	//y ja deviceBuffer2
	hipMemcpy(y, deviceBuffer2, n*sizeof(double), hipMemcpyDeviceToHost);

		if(err != hipSuccess) {
			std::cout << "GPU -> Isäntälaite -siirtokäskyn asettaminen " \
				"komentojonoon epäonnistui." << std::endl;
			std::cerr << "CUDA-virhekoodi: " << hipGetErrorString(err) <<
				std::endl;

			hipFree(deviceBuffer1);
			hipFree(deviceBuffer2);
			delete [] x;
			delete [] y;
			delete [] x_test;
			delete [] y_test;
			return 1;
		}

		//
		// Tarkistetaan tulos
		//


		//lasketaan axpy cpu:lla
		for(int i = 0; i < n; i++) {
			y_test[i] = m * x_test[i] + y_test[i];
		}

		//tarkistetaan ovatko kaikki y:n arvot samoja
		bool correct = true;
		for(int i = 0; i < n; i++) {
			if (double_equals(y_test[i], y[i]) != true) {
				correct = false;
				//tulostetaan eriävät arvot
				std::cout << y_test[i] << std::endl;
				std::cout << y[i] << std::endl;
				break;
			}
		}

		std::cout << "The result was " ;
		if (!correct) {
			std::cout << "incorrect." << std::endl;
		}
		else std::cout << "correct." << std::endl;


		//
		// Vapautetaan CUDA-laitteen puolelta varattu muisti
		//
		err = hipFree(deviceBuffer1);

		if(err != hipSuccess) {
			std::cout << "Muistin vapauttaminen epäonnistui epäonnistui." <<
				std::endl;
			std::cerr << "CUDA-virhekoodi: " << hipGetErrorString(err) <<
				std::endl;

			delete [] x;
			delete [] y;
			delete [] x_test;
			delete [] y_test;
			return 1;
		}

		err = hipFree(deviceBuffer2);

		if(err != hipSuccess) {
			std::cout << "Muistin vapauttaminen epäonnistui epäonnistui." <<
				std::endl;
			std::cerr << "CUDA-virhekoodi: " << hipGetErrorString(err) <<
				std::endl;

			delete [] x;
			delete [] y;
			delete [] x_test;
			delete [] y_test;
			return 1;
		}

		delete [] x;
		delete [] y;
		delete [] x_test;
		delete [] y_test;

		return 0;
}

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

                                        # End of file scope inline assembly
	.globl	_Z19__device_stub__axpyPdS_di   # -- Begin function _Z19__device_stub__axpyPdS_di
	.type	_Z19__device_stub__axpyPdS_di,@function
_Z19__device_stub__axpyPdS_di:          # @_Z19__device_stub__axpyPdS_di
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$112, %rsp
	.cfi_def_cfa_offset 160
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	32(%rsp), %rcx
	movq	%rsi, (%rcx)
	leaq	24(%rsp), %rsi
	movsd	%xmm0, (%rsi)
	leaq	4(%rsp), %rdi
	movl	%edx, (%rdi)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdi, 24(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%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	$_Z4axpyPdS_di, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$128, %rsp
	.cfi_adjust_cfa_offset -128
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	_Z19__device_stub__axpyPdS_di, .Lfunc_end0-_Z19__device_stub__axpyPdS_di
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0                          # -- Begin function _Z13double_equalsddd
.LCPI1_0:
	.quad	0x7fffffffffffffff              # double NaN
	.quad	0x7fffffffffffffff              # double NaN
	.text
	.globl	_Z13double_equalsddd
	.type	_Z13double_equalsddd,@function
_Z13double_equalsddd:                   # @_Z13double_equalsddd
	.cfi_startproc
# %bb.0:
	subsd	%xmm1, %xmm0
	andpd	.LCPI1_0(%rip), %xmm0
	ucomisd	%xmm0, %xmm2
	seta	%al
	retq
.Lfunc_end1:
	.size	_Z13double_equalsddd, .Lfunc_end1-_Z13double_equalsddd
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI2_0:
	.quad	0x41dfffffffc00000              # double 2147483647
.LCPI2_1:
	.quad	0xbff0000000000000              # double -1
.LCPI2_3:
	.quad	0x3f1a36e2eb1c432d              # double 1.0E-4
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0
.LCPI2_2:
	.quad	0x7fffffffffffffff              # double NaN
	.quad	0x7fffffffffffffff              # double NaN
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	xorl	%edi, %edi
	callq	time
	movl	%eax, %edi
	callq	srand
	callq	rand
	cltq
	imulq	$1200959901, %rax, %rcx         # imm = 0x4795319D
	movq	%rcx, %rdx
	shrq	$63, %rdx
	sarq	$55, %rcx
	addl	%edx, %ecx
	imull	$30000000, %ecx, %ecx           # imm = 0x1C9C380
	movl	%eax, %r13d
	subl	%ecx, %r13d
	negl	%ecx
	addl	%ecx, %eax
	incl	%eax
	movq	%rax, 40(%rsp)                  # 8-byte Spill
	movslq	%r13d, %r15
	cmpl	$-1, %r15d
	leaq	8(,%r15,8), %rbp
	movq	$-1, %r12
	cmovgeq	%rbp, %r12
	movq	%r12, %rdi
	callq	_Znam
	movq	%rax, %rbx
	movq	%r12, %rdi
	callq	_Znam
	movq	%rax, %r14
	callq	rand
	movl	%eax, 32(%rsp)                  # 4-byte Spill
	movq	%r12, %rdi
	callq	_Znam
	movq	%rax, 8(%rsp)                   # 8-byte Spill
	movq	%r12, %rdi
	callq	_Znam
	movq	%rax, 48(%rsp)                  # 8-byte Spill
	testl	%r15d, %r15d
	js	.LBB2_5
# %bb.1:                                # %.lr.ph.preheader
	movl	40(%rsp), %r12d                 # 4-byte Reload
	xorl	%r15d, %r15d
.LBB2_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	callq	rand
	xorps	%xmm0, %xmm0
	cvtsi2sd	%eax, %xmm0
	movsd	.LCPI2_0(%rip), %xmm1           # xmm1 = mem[0],zero
	divsd	%xmm1, %xmm0
	addsd	%xmm0, %xmm0
	movsd	.LCPI2_1(%rip), %xmm1           # xmm1 = mem[0],zero
	addsd	%xmm1, %xmm0
	movsd	%xmm0, (%rbx,%r15,8)
	callq	rand
	xorps	%xmm0, %xmm0
	cvtsi2sd	%eax, %xmm0
	divsd	.LCPI2_0(%rip), %xmm0
	addsd	%xmm0, %xmm0
	addsd	.LCPI2_1(%rip), %xmm0
	movsd	%xmm0, (%r14,%r15,8)
	incq	%r15
	cmpq	%r15, %r12
	jne	.LBB2_2
# %bb.3:                                # %.preheader155
	testl	%r13d, %r13d
	js	.LBB2_5
# %bb.4:                                # %.lr.ph161.preheader
	shlq	$3, %r12
	movq	8(%rsp), %rdi                   # 8-byte Reload
	movq	%rbx, %rsi
	movq	%r12, %rdx
	callq	memcpy@PLT
	movq	48(%rsp), %rdi                  # 8-byte Reload
	movq	%r14, %rsi
	movq	%r12, %rdx
	callq	memcpy@PLT
.LBB2_5:                                # %._crit_edge
	leaq	24(%rsp), %rdi
	movq	%rbp, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB2_6
# %bb.10:
	leaq	16(%rsp), %rdi
	movq	%rbp, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	je	.LBB2_11
.LBB2_6:
	movl	%eax, %r12d
	movl	$_ZSt4cout, %r15d
	movl	$_ZSt4cout, %edi
	movl	$.L.str, %esi
	movl	$32, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	_ZSt4cout(%rip), %rax
	movq	-24(%rax), %rdi
	addq	%r15, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	movl	$_ZSt4cerr, %edi
	movl	$.L.str.1, %esi
	movl	$17, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	%r12d, %edi
	callq	hipGetErrorString
	testq	%rax, %rax
	je	.LBB2_7
# %bb.8:
	movq	%rax, %r15
	movq	%rax, %rdi
	callq	strlen
	movl	$_ZSt4cerr, %edi
	movq	%r15, %rsi
	movq	%rax, %rdx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	jmp	.LBB2_9
.LBB2_7:
	movq	_ZSt4cerr(%rip), %rax
	movq	-24(%rax), %rax
	leaq	_ZSt4cerr(%rax), %rdi
	movl	32(%rdi), %esi
	orl	$1, %esi
	callq	_ZNSt9basic_iosIcSt11char_traitsIcEE5clearESt12_Ios_Iostate
.LBB2_9:                                # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit
	movq	8(%rsp), %r12                   # 8-byte Reload
	movq	_ZSt4cerr(%rip), %rax
	movl	$_ZSt4cerr, %ecx
	movq	-24(%rax), %rdi
	addq	%rcx, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cerr, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
.LBB2_35:
	movl	$1, %ebp
.LBB2_36:
	movq	%rbx, %rdi
	callq	_ZdaPv
	movq	%r14, %rdi
	callq	_ZdaPv
	movq	%r12, %rdi
	callq	_ZdaPv
	movq	48(%rsp), %rdi                  # 8-byte Reload
	callq	_ZdaPv
	movl	%ebp, %eax
	addq	$56, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.LBB2_11:
	.cfi_def_cfa_offset 112
	movq	24(%rsp), %rdi
	movq	%rbx, %rsi
	movq	%rbp, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB2_12
# %bb.17:
	movq	16(%rsp), %rdi
	movq	%r14, %rsi
	movq	%rbp, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	je	.LBB2_18
.LBB2_12:
	movl	%eax, %r12d
	movl	$_ZSt4cout, %r15d
	movl	$_ZSt4cout, %edi
	movl	$.L.str.2, %esi
	movl	$75, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	_ZSt4cout(%rip), %rax
	movq	-24(%rax), %rdi
	addq	%r15, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	movl	$_ZSt4cerr, %edi
	movl	$.L.str.1, %esi
	movl	$17, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	%r12d, %edi
	callq	hipGetErrorString
	testq	%rax, %rax
	je	.LBB2_13
# %bb.14:
	movq	%rax, %r15
	movq	%rax, %rdi
	callq	strlen
	movl	$_ZSt4cerr, %edi
	movq	%r15, %rsi
	movq	%rax, %rdx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	jmp	.LBB2_15
.LBB2_13:
	movq	_ZSt4cerr(%rip), %rax
	movq	-24(%rax), %rax
	leaq	_ZSt4cerr(%rax), %rdi
	movl	32(%rdi), %esi
	orl	$1, %esi
	callq	_ZNSt9basic_iosIcSt11char_traitsIcEE5clearESt12_Ios_Iostate
.LBB2_15:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit150
	movq	8(%rsp), %r12                   # 8-byte Reload
	movq	_ZSt4cerr(%rip), %rax
	movl	$_ZSt4cerr, %ecx
	movq	-24(%rax), %rdi
	addq	%rcx, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cerr, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
.LBB2_16:
	movq	24(%rsp), %rdi
	callq	hipFree
	movq	16(%rsp), %rdi
	callq	hipFree
	jmp	.LBB2_35
.LBB2_18:
	xorps	%xmm0, %xmm0
	cvtsi2sdl	32(%rsp), %xmm0         # 4-byte Folded Reload
	divsd	.LCPI2_0(%rip), %xmm0
	addsd	%xmm0, %xmm0
	addsd	.LCPI2_1(%rip), %xmm0
	movsd	%xmm0, 32(%rsp)                 # 8-byte Spill
	movq	40(%rsp), %rax                  # 8-byte Reload
	leal	1023(%rax), %edi
	testl	%eax, %eax
	cmovnsl	%eax, %edi
	sarl	$10, %edi
	incl	%edi
	btsq	$32, %rdi
	movabsq	$4294967296, %rdx               # imm = 0x100000000
	orq	$1024, %rdx                     # imm = 0x400
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	movq	8(%rsp), %r12                   # 8-byte Reload
	jne	.LBB2_20
# %bb.19:
	movq	24(%rsp), %rdi
	movq	16(%rsp), %rsi
	movsd	32(%rsp), %xmm0                 # 8-byte Reload
                                        # xmm0 = mem[0],zero
	movq	40(%rsp), %rdx                  # 8-byte Reload
                                        # kill: def $edx killed $edx killed $rdx
	callq	_Z19__device_stub__axpyPdS_di
.LBB2_20:
	callq	hipGetLastError
	testl	%eax, %eax
	je	.LBB2_22
# %bb.21:
	movl	%eax, %r15d
	movl	$_ZSt4cout, %edi
	movl	$.L.str.3, %esi
	movl	$65, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	$_ZSt4cout, %edi
	callq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_
	movl	$_ZSt4cerr, %edi
	movl	$.L.str.1, %esi
	movl	$17, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	%r15d, %edi
	callq	hipGetErrorString
	movl	$_ZSt4cerr, %edi
	movq	%rax, %rsi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rdi
	callq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_
	jmp	.LBB2_16
.LBB2_22:
	movq	24(%rsp), %rsi
	movq	%rbx, %rdi
	movq	%rbp, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	movq	16(%rsp), %rsi
	movq	%r14, %rdi
	movq	%rbp, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	testl	%r13d, %r13d
	movq	48(%rsp), %rdx                  # 8-byte Reload
	js	.LBB2_30
# %bb.23:                               # %.lr.ph165.preheader
	movl	40(%rsp), %eax                  # 4-byte Reload
	xorl	%ecx, %ecx
	movsd	32(%rsp), %xmm1                 # 8-byte Reload
                                        # xmm1 = mem[0],zero
.LBB2_24:                               # %.lr.ph165
                                        # =>This Inner Loop Header: Depth=1
	movsd	(%r12,%rcx,8), %xmm0            # xmm0 = mem[0],zero
	mulsd	%xmm1, %xmm0
	addsd	(%rdx,%rcx,8), %xmm0
	movsd	%xmm0, (%rdx,%rcx,8)
	incq	%rcx
	cmpq	%rcx, %rax
	jne	.LBB2_24
# %bb.25:                               # %.preheader
	testl	%r13d, %r13d
	js	.LBB2_30
# %bb.26:                               # %.lr.ph169.preheader
	xorl	%r15d, %r15d
	movapd	.LCPI2_2(%rip), %xmm1           # xmm1 = [NaN,NaN]
	movsd	.LCPI2_3(%rip), %xmm2           # xmm2 = mem[0],zero
.LBB2_28:                               # %.lr.ph169
                                        # =>This Inner Loop Header: Depth=1
	movsd	(%rdx,%r15,8), %xmm0            # xmm0 = mem[0],zero
	movapd	%xmm0, %xmm3
	subsd	(%r14,%r15,8), %xmm3
	andpd	%xmm1, %xmm3
	ucomisd	%xmm3, %xmm2
	jbe	.LBB2_29
# %bb.27:                               #   in Loop: Header=BB2_28 Depth=1
	incq	%r15
	cmpq	%r15, %rax
	jne	.LBB2_28
.LBB2_30:                               # %._crit_edge170
	movl	$_ZSt4cout, %edi
	movl	$.L.str.5, %esi
	movl	$15, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	$_ZSt4cout, %edi
	movl	$.L.str.7, %esi
	movl	$8, %edx
.LBB2_31:
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	$_ZSt4cout, %edi
	callq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_
	movq	24(%rsp), %rdi
	callq	hipFree
	testl	%eax, %eax
	jne	.LBB2_34
# %bb.32:
	movq	16(%rsp), %rdi
	callq	hipFree
	testl	%eax, %eax
	je	.LBB2_33
.LBB2_34:
	movl	%eax, %ebp
	movl	$_ZSt4cout, %edi
	movl	$.L.str.8, %esi
	movl	$48, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	$_ZSt4cout, %edi
	callq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_
	movl	$_ZSt4cerr, %edi
	movl	$.L.str.1, %esi
	movl	$17, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	%ebp, %edi
	callq	hipGetErrorString
	movl	$_ZSt4cerr, %edi
	movq	%rax, %rsi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rdi
	callq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_
	jmp	.LBB2_35
.LBB2_29:
	movl	$_ZSt4cout, %edi
	callq	_ZNSo9_M_insertIdEERSoT_
	movq	%rax, %rdi
	callq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_
	movsd	(%r14,%r15,8), %xmm0            # xmm0 = mem[0],zero
	movl	$_ZSt4cout, %edi
	callq	_ZNSo9_M_insertIdEERSoT_
	movq	%rax, %rdi
	callq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_
	movl	$_ZSt4cout, %edi
	movl	$.L.str.5, %esi
	movl	$15, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	$_ZSt4cout, %edi
	movl	$.L.str.6, %esi
	movl	$10, %edx
	jmp	.LBB2_31
.LBB2_33:
	xorl	%ebp, %ebp
	jmp	.LBB2_36
.Lfunc_end2:
	.size	main, .Lfunc_end2-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	.LBB3_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB3_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z4axpyPdS_di, %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_end3:
	.size	__hip_module_ctor, .Lfunc_end3-__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	.LBB4_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
.LBB4_2:
	retq
.Lfunc_end4:
	.size	__hip_module_dtor, .Lfunc_end4-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	_Z4axpyPdS_di,@object           # @_Z4axpyPdS_di
	.section	.rodata,"a",@progbits
	.globl	_Z4axpyPdS_di
	.p2align	3, 0x0
_Z4axpyPdS_di:
	.quad	_Z19__device_stub__axpyPdS_di
	.size	_Z4axpyPdS_di, 8

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"Muistin varaaminen ep\303\244onnistui."
	.size	.L.str, 33

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"CUDA-virhekoodi: "
	.size	.L.str.1, 18

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"Is\303\244nt\303\244laite -> GPU -siirtok\303\244skyn asettaminen komentojonoon ep\303\244onnistui."
	.size	.L.str.2, 76

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"Ytimen k\303\244ynnistysk\303\244skyn asettaminen komentojonoon ep\303\244onnistui."
	.size	.L.str.3, 66

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"The result was "
	.size	.L.str.5, 16

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"incorrect."
	.size	.L.str.6, 11

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

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"Muistin vapauttaminen ep\303\244onnistui ep\303\244onnistui."
	.size	.L.str.8, 49

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z4axpyPdS_di"
	.size	.L__unnamed_1, 14

	.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 _Z19__device_stub__axpyPdS_di
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z4axpyPdS_di
	.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	_Z4axpyPdS_di           ; -- Begin function _Z4axpyPdS_di
	.globl	_Z4axpyPdS_di
	.p2align	8
	.type	_Z4axpyPdS_di,@function
_Z4axpyPdS_di:                          ; @_Z4axpyPdS_di
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x2c
	s_load_b32 s3, s[0:1], 0x18
	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_gt_i32_e64 s3, v1
	s_cbranch_execz .LBB0_2
; %bb.1:
	s_load_b128 s[4:7], s[0:1], 0x0
	v_ashrrev_i32_e32 v2, 31, v1
	s_load_b64 s[0:1], s[0:1], 0x10
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[0:1], 3, v[1:2]
	s_waitcnt lgkmcnt(0)
	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
	v_add_co_u32 v0, vcc_lo, s6, v0
	v_add_co_ci_u32_e32 v1, vcc_lo, s7, v1, vcc_lo
	global_load_b64 v[2:3], v[2:3], off
	global_load_b64 v[4:5], v[0:1], off
	s_waitcnt vmcnt(0)
	v_fma_f64 v[2:3], v[2:3], s[0:1], v[4:5]
	global_store_b64 v[0:1], v[2:3], off
.LBB0_2:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z4axpyPdS_di
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 288
		.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 6
		.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	_Z4axpyPdS_di, .Lfunc_end0-_Z4axpyPdS_di
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 172
; NumSgprs: 18
; NumVgprs: 6
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 6
; 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:           8
        .value_kind:     by_value
      - .offset:         24
        .size:           4
        .value_kind:     by_value
      - .offset:         32
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         36
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         40
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         44
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         46
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         48
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         50
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         52
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         54
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         88
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         96
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 288
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z4axpyPdS_di
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z4axpyPdS_di.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     6
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
