#include <cuda_runtime.h>
#include <stdio.h>
#include <time.h>
#include <unistd.h>


static const int ROW=1024;
static const int COL=1024;
void printArr(const char * name, float * arr, unsigned int len)
{
	for (int i=0;i<len;i++)
		printf("arr %s [%u]=%5.5f\n", name, i, arr[i]);
}
void initData(float *ip, int size)
{
	sleep(1);
	time_t t;
	srand((unsigned ) time(&t));
	for (int i=0;i<size;i++)
	{
		ip[i] = (float) (rand() & 0xFF)/10.0f;
	}
	//printArr("initData", ip, size);
}

unsigned int getTimeInUs()
{
	struct timespec tm;
	clock_gettime(CLOCK_REALTIME, &tm);
	return (unsigned int)(tm.tv_sec*1000*1000*1000+tm.tv_nsec);
}
void sumArraysOnHost(float *A, float *B, float *C, int N)
{
	for (int idx=0;idx<N;idx++)
	{
		C[idx]=A[idx]+B[idx];
	}
}

__global__ void sumArraysOnGPU(float *A, float *B, float *C)
{
	int i=blockIdx.x*COL+threadIdx.x;
	//printf("[gpu]:gridDim.x=%u, gridDim.y=%u, gridDim.z=%u, blockDim.x=%u, blockDim.y=%u, blockDim.z=%u, blockIdx.x=%u, blockIdx.y=%u, blockIdx.z=%u,threadIdx.x=%u, threadIdx.y=%u, threadIdx.z=%u\n",
		//gridDim.x, gridDim.y, gridDim.z, blockDim.x, blockDim.y, blockDim.z, blockIdx.x, blockIdx.y, blockIdx.z,threadIdx.x, threadIdx.y, threadIdx.z);
	C[i]=A[i]+B[i];
	//printf("sum[%u][%u]: A[%5.5f]+B[%5.5f]=C[%5.5f]\n",blockIdx.x, threadIdx.x, A[i], B[i], C[i]);
}

int main(int argc, char * argv[])
{
	printf("%s Starting\n", argv[0]);
	int dev=0;
	cudaDeviceProp deviceProp;
	cudaGetDeviceProperties(&deviceProp, dev);
	printf("Using Device %d, %s\n", dev, deviceProp.name);
	//return 0;
	cudaSetDevice(dev);
	int nElem = ROW*COL;
	//int rpCount = 1000;
	printf("Vector size= %d\n", nElem);
	
	size_t nBytes = nElem * sizeof(float);
	
	float * hA = (float*)malloc(nBytes);
	float * hB = (float*)malloc(nBytes);
	float * hostRef = (float*)malloc(nBytes);
	float * gpuRef = (float*)malloc(nBytes);
	initData(hA, nElem);
	initData(hB, nElem);
	
	//printArr("hA", hA, nElem);
	//printArr("hB", hB, nElem);
	memset(hostRef, 0, nBytes);
	memset(gpuRef, 0, nBytes);

	float * dA;
	cudaMalloc((float**)&dA, nBytes);
	float * dB;
	cudaMalloc((float**)&dB, nBytes);
	float * dC;
	cudaMalloc((float**)&dC, nBytes);

	unsigned int startTime=getTimeInUs();

	printf("=======start data copying [%u]==========\n", startTime);
	cudaMemcpy(dA, hA, nBytes, cudaMemcpyHostToDevice);
	cudaMemcpy(dB, hB, nBytes, cudaMemcpyHostToDevice);

	unsigned int workStartTime=getTimeInUs();
	printf("=======data copy finish, start working   [%u]   delta[%u]=======\n", workStartTime, workStartTime-startTime);
	dim3 block(COL);
	dim3 grid(ROW);

	sumArraysOnGPU<<<grid, block>>>(dA, dB, dC);
	cudaDeviceSynchronize();
	
	unsigned int workEndTime=getTimeInUs();
	printf("=======work on GPU finish                [%u]   delta[%u]==========\n", workEndTime, workEndTime-workStartTime);
	cudaMemcpy(gpuRef, dC, nBytes, cudaMemcpyDeviceToHost);
	unsigned int cpEndTime=getTimeInUs();
	printf("=======copy back to CPU finish           [%u]   delta[%u]==========\n", cpEndTime, cpEndTime-workEndTime);

	workStartTime=getTimeInUs();
	printf("=======work on CPU started               [%u]   ==========\n", workStartTime);
	sumArraysOnHost(hA, hB, hostRef, nElem);
	workEndTime=getTimeInUs();
	printf("=======work on CPU finished              [%u]   delta[%u]==========\n", workEndTime, workEndTime-workStartTime);

	//validation
	for (int i=0; i<nElem;i++)
	{
		if (hostRef[i]!=gpuRef[i])
		{
			printf("invalid result: host: %5.5f device: %5.5f\n", hostRef[i], gpuRef[i]);
		}
	}
	printf("=======finish==========\n");
	
	return 0;
}

	.file	"tmpxft_00291515_00000000-6_simpleTest.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2047:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2047:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"arr %s [%u]=%5.5f\n"
	.text
	.globl	_Z8printArrPKcPfj
	.type	_Z8printArrPKcPfj, @function
_Z8printArrPKcPfj:
.LFB2040:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	leaq	.LC0(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	movq	%rsi, %r13
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	movq	%rdi, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	movl	%edx, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	xorl	%ebx, %ebx
.L3:
	movl	%ebx, %ecx
	cmpq	%rbp, %rbx
	je	.L7
	movq	%r12, %rdx
	movq	%r14, %rsi
	movl	$2, %edi
	movb	$1, %al
	cvtss2sd	0(%r13,%rbx,4), %xmm0
	call	__printf_chk@PLT
	incq	%rbx
	jmp	.L3
.L7:
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2040:
	.size	_Z8printArrPKcPfj, .-_Z8printArrPKcPfj
	.globl	_Z8initDataPfi
	.type	_Z8initDataPfi, @function
_Z8initDataPfi:
.LFB2041:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movq	%rdi, %r12
	movl	$1, %edi
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movl	%esi, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	xorl	%ebx, %ebx
	subq	$16, %rsp
	.cfi_def_cfa_offset 48
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	call	sleep@PLT
	movq	%rsp, %rdi
	call	time@PLT
	movl	%eax, %edi
	call	srand@PLT
.L9:
	cmpl	%ebx, %ebp
	jle	.L13
	call	rand@PLT
	movzbl	%al, %eax
	cvtsi2ssl	%eax, %xmm0
	divss	.LC1(%rip), %xmm0
	movss	%xmm0, (%r12,%rbx,4)
	incq	%rbx
	jmp	.L9
.L13:
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	je	.L11
	call	__stack_chk_fail@PLT
.L11:
	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
.LFE2041:
	.size	_Z8initDataPfi, .-_Z8initDataPfi
	.globl	_Z11getTimeInUsv
	.type	_Z11getTimeInUsv, @function
_Z11getTimeInUsv:
.LFB2042:
	.cfi_startproc
	endbr64
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	xorl	%edi, %edi
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rsi
	call	clock_gettime@PLT
	imull	$1000000000, 8(%rsp), %eax
	addl	16(%rsp), %eax
	movq	24(%rsp), %rdx
	subq	%fs:40, %rdx
	je	.L15
	call	__stack_chk_fail@PLT
.L15:
	addq	$40, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2042:
	.size	_Z11getTimeInUsv, .-_Z11getTimeInUsv
	.globl	_Z15sumArraysOnHostPfS_S_i
	.type	_Z15sumArraysOnHostPfS_S_i, @function
_Z15sumArraysOnHostPfS_S_i:
.LFB2043:
	.cfi_startproc
	endbr64
	xorl	%eax, %eax
.L18:
	cmpl	%eax, %ecx
	jle	.L20
	movss	(%rdi,%rax,4), %xmm0
	addss	(%rsi,%rax,4), %xmm0
	movss	%xmm0, (%rdx,%rax,4)
	incq	%rax
	jmp	.L18
.L20:
	ret
	.cfi_endproc
.LFE2043:
	.size	_Z15sumArraysOnHostPfS_S_i, .-_Z15sumArraysOnHostPfS_S_i
	.globl	_Z38__device_stub__Z14sumArraysOnGPUPfS_S_PfS_S_
	.type	_Z38__device_stub__Z14sumArraysOnGPUPfS_S_PfS_S_, @function
_Z38__device_stub__Z14sumArraysOnGPUPfS_S_PfS_S_:
.LFB2069:
	.cfi_startproc
	endbr64
	subq	$136, %rsp
	.cfi_def_cfa_offset 144
	movq	%rdi, 24(%rsp)
	leaq	40(%rsp), %rcx
	leaq	48(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	60(%rsp), %rsi
	movq	%rdx, 8(%rsp)
	leaq	32(%rsp), %rdx
	movq	%fs:40, %rax
	movq	%rax, 120(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 56(%rsp)
	movq	%rax, 96(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 104(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 112(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 48(%rsp)
	movq	%rax, 60(%rsp)
	movl	$1, 68(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L21
	pushq	40(%rsp)
	.cfi_def_cfa_offset 152
	leaq	_Z14sumArraysOnGPUPfS_S_(%rip), %rdi
	pushq	40(%rsp)
	.cfi_def_cfa_offset 160
	movq	76(%rsp), %rcx
	movl	84(%rsp), %r8d
	movq	64(%rsp), %rsi
	movl	72(%rsp), %edx
	leaq	112(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 152
	popq	%rdx
	.cfi_def_cfa_offset 144
.L21:
	movq	120(%rsp), %rax
	subq	%fs:40, %rax
	je	.L23
	call	__stack_chk_fail@PLT
.L23:
	addq	$136, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2069:
	.size	_Z38__device_stub__Z14sumArraysOnGPUPfS_S_PfS_S_, .-_Z38__device_stub__Z14sumArraysOnGPUPfS_S_PfS_S_
	.globl	_Z14sumArraysOnGPUPfS_S_
	.type	_Z14sumArraysOnGPUPfS_S_, @function
_Z14sumArraysOnGPUPfS_S_:
.LFB2070:
	.cfi_startproc
	endbr64
	jmp	_Z38__device_stub__Z14sumArraysOnGPUPfS_S_PfS_S_
	.cfi_endproc
.LFE2070:
	.size	_Z14sumArraysOnGPUPfS_S_, .-_Z14sumArraysOnGPUPfS_S_
	.section	.rodata.str1.1
.LC2:
	.string	"%s Starting\n"
.LC3:
	.string	"Using Device %d, %s\n"
.LC4:
	.string	"Vector size= %d\n"
.LC5:
	.string	"=======start data copying [%u]==========\n"
.LC6:
	.string	"=======data copy finish, start working   [%u]   delta[%u]=======\n"
.LC7:
	.string	"=======work on GPU finish                [%u]   delta[%u]==========\n"
.LC8:
	.string	"=======copy back to CPU finish           [%u]   delta[%u]==========\n"
.LC9:
	.string	"=======work on CPU started               [%u]   ==========\n"
.LC10:
	.string	"=======work on CPU finished              [%u]   delta[%u]==========\n"
.LC11:
	.string	"invalid result: host: %5.5f device: %5.5f\n"
.LC12:
	.string	"=======finish==========\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2044:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	$2, %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	$1096, %rsp
	.cfi_def_cfa_offset 1152
	movq	(%rsi), %rdx
	leaq	.LC2(%rip), %rsi
	movq	%fs:40, %rax
	movq	%rax, 1080(%rsp)
	xorl	%eax, %eax
	leaq	48(%rsp), %rbx
	call	__printf_chk@PLT
	xorl	%esi, %esi
	movq	%rbx, %rdi
	call	cudaGetDeviceProperties_v2@PLT
	movq	%rbx, %rcx
	xorl	%edx, %edx
	movl	$2, %edi
	leaq	.LC3(%rip), %rsi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	xorl	%edi, %edi
	call	cudaSetDevice@PLT
	movl	$1048576, %edx
	leaq	.LC4(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
	movl	$4194304, %edi
	call	malloc@PLT
	movl	$4194304, %edi
	movq	%rax, %r12
	call	malloc@PLT
	movl	$4194304, %edi
	movq	%rax, %r13
	call	malloc@PLT
	movl	$4194304, %edi
	movq	%rax, %rbx
	call	malloc@PLT
	movl	$1048576, %esi
	movq	%r12, %rdi
	movq	%rax, %rbp
	call	_Z8initDataPfi
	movl	$1048576, %esi
	movq	%r13, %rdi
	call	_Z8initDataPfi
	xorl	%eax, %eax
	movl	$1048576, %ecx
	movq	%rbx, %rdi
	rep stosl
	movl	$1048576, %ecx
	movq	%rbp, %rdi
	movl	$4194304, %esi
	rep stosl
	movq	%rsp, %rdi
	call	cudaMalloc@PLT
	leaq	8(%rsp), %rdi
	movl	$4194304, %esi
	call	cudaMalloc@PLT
	leaq	16(%rsp), %rdi
	movl	$4194304, %esi
	call	cudaMalloc@PLT
	call	_Z11getTimeInUsv
	leaq	.LC5(%rip), %rsi
	movl	$2, %edi
	movl	%eax, %edx
	movl	%eax, %r14d
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	(%rsp), %rdi
	movl	$1, %ecx
	movq	%r12, %rsi
	movl	$4194304, %edx
	call	cudaMemcpy@PLT
	movq	8(%rsp), %rdi
	movl	$1, %ecx
	movq	%r13, %rsi
	movl	$4194304, %edx
	call	cudaMemcpy@PLT
	call	_Z11getTimeInUsv
	leaq	.LC6(%rip), %rsi
	movl	$2, %edi
	movl	%eax, %ecx
	movl	%eax, %edx
	movl	%eax, %r15d
	xorl	%eax, %eax
	subl	%r14d, %ecx
	call	__printf_chk@PLT
	movl	$4194305, %edi
	movl	$1, %ecx
	movl	$1, %esi
	salq	$10, %rdi
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movq	%rdi, %rdx
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L27
	movq	16(%rsp), %rdx
	movq	8(%rsp), %rsi
	movq	(%rsp), %rdi
	call	_Z38__device_stub__Z14sumArraysOnGPUPfS_S_PfS_S_
.L27:
	call	cudaDeviceSynchronize@PLT
	call	_Z11getTimeInUsv
	leaq	.LC7(%rip), %rsi
	movl	$2, %edi
	movl	%eax, %ecx
	movl	%eax, %r14d
	movl	%eax, %edx
	xorl	%eax, %eax
	subl	%r15d, %ecx
	call	__printf_chk@PLT
	movq	16(%rsp), %rsi
	movl	$2, %ecx
	movq	%rbp, %rdi
	movl	$4194304, %edx
	call	cudaMemcpy@PLT
	call	_Z11getTimeInUsv
	leaq	.LC8(%rip), %rsi
	movl	$2, %edi
	movl	%eax, %ecx
	movl	%eax, %edx
	xorl	%eax, %eax
	subl	%r14d, %ecx
	call	__printf_chk@PLT
	call	_Z11getTimeInUsv
	leaq	.LC9(%rip), %rsi
	movl	$2, %edi
	movl	%eax, %edx
	movl	%eax, %r14d
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	%r13, %rsi
	movq	%r12, %rdi
	movl	$1048576, %ecx
	movq	%rbx, %rdx
	xorl	%r12d, %r12d
	leaq	.LC11(%rip), %r13
	call	_Z15sumArraysOnHostPfS_S_i
	call	_Z11getTimeInUsv
	leaq	.LC10(%rip), %rsi
	movl	$2, %edi
	movl	%eax, %ecx
	movl	%eax, %edx
	xorl	%eax, %eax
	subl	%r14d, %ecx
	call	__printf_chk@PLT
.L30:
	movss	(%rbx,%r12), %xmm0
	movss	0(%rbp,%r12), %xmm1
	ucomiss	%xmm1, %xmm0
	jp	.L32
	je	.L28
.L32:
	movq	%r13, %rsi
	movl	$2, %edi
	movb	$2, %al
	cvtss2sd	%xmm0, %xmm0
	cvtss2sd	%xmm1, %xmm1
	call	__printf_chk@PLT
.L28:
	addq	$4, %r12
	cmpq	$4194304, %r12
	jne	.L30
	xorl	%eax, %eax
	leaq	.LC12(%rip), %rsi
	movl	$2, %edi
	call	__printf_chk@PLT
	movq	1080(%rsp), %rax
	subq	%fs:40, %rax
	je	.L31
	call	__stack_chk_fail@PLT
.L31:
	addq	$1096, %rsp
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2044:
	.size	main, .-main
	.section	.rodata.str1.1
.LC13:
	.string	"_Z14sumArraysOnGPUPfS_S_"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2072:
	.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	.LC13(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z14sumArraysOnGPUPfS_S_(%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
.LFE2072:
	.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.cst4,"aM",@progbits,4
	.align 4
.LC1:
	.long	1092616192
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

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


static const int ROW=1024;
static const int COL=1024;
void printArr(const char * name, float * arr, unsigned int len)
{
	for (int i=0;i<len;i++)
		printf("arr %s [%u]=%5.5f\n", name, i, arr[i]);
}
void initData(float *ip, int size)
{
	sleep(1);
	time_t t;
	srand((unsigned ) time(&t));
	for (int i=0;i<size;i++)
	{
		ip[i] = (float) (rand() & 0xFF)/10.0f;
	}
	//printArr("initData", ip, size);
}

unsigned int getTimeInUs()
{
	struct timespec tm;
	clock_gettime(CLOCK_REALTIME, &tm);
	return (unsigned int)(tm.tv_sec*1000*1000*1000+tm.tv_nsec);
}
void sumArraysOnHost(float *A, float *B, float *C, int N)
{
	for (int idx=0;idx<N;idx++)
	{
		C[idx]=A[idx]+B[idx];
	}
}

__global__ void sumArraysOnGPU(float *A, float *B, float *C)
{
	int i=blockIdx.x*COL+threadIdx.x;
	//printf("[gpu]:gridDim.x=%u, gridDim.y=%u, gridDim.z=%u, blockDim.x=%u, blockDim.y=%u, blockDim.z=%u, blockIdx.x=%u, blockIdx.y=%u, blockIdx.z=%u,threadIdx.x=%u, threadIdx.y=%u, threadIdx.z=%u\n",
		//gridDim.x, gridDim.y, gridDim.z, blockDim.x, blockDim.y, blockDim.z, blockIdx.x, blockIdx.y, blockIdx.z,threadIdx.x, threadIdx.y, threadIdx.z);
	C[i]=A[i]+B[i];
	//printf("sum[%u][%u]: A[%5.5f]+B[%5.5f]=C[%5.5f]\n",blockIdx.x, threadIdx.x, A[i], B[i], C[i]);
}

int main(int argc, char * argv[])
{
	printf("%s Starting\n", argv[0]);
	int dev=0;
	hipDeviceProp_t deviceProp;
	hipGetDeviceProperties(&deviceProp, dev);
	printf("Using Device %d, %s\n", dev, deviceProp.name);
	//return 0;
	hipSetDevice(dev);
	int nElem = ROW*COL;
	//int rpCount = 1000;
	printf("Vector size= %d\n", nElem);
	
	size_t nBytes = nElem * sizeof(float);
	
	float * hA = (float*)malloc(nBytes);
	float * hB = (float*)malloc(nBytes);
	float * hostRef = (float*)malloc(nBytes);
	float * gpuRef = (float*)malloc(nBytes);
	initData(hA, nElem);
	initData(hB, nElem);
	
	//printArr("hA", hA, nElem);
	//printArr("hB", hB, nElem);
	memset(hostRef, 0, nBytes);
	memset(gpuRef, 0, nBytes);

	float * dA;
	hipMalloc((float**)&dA, nBytes);
	float * dB;
	hipMalloc((float**)&dB, nBytes);
	float * dC;
	hipMalloc((float**)&dC, nBytes);

	unsigned int startTime=getTimeInUs();

	printf("=======start data copying [%u]==========\n", startTime);
	hipMemcpy(dA, hA, nBytes, hipMemcpyHostToDevice);
	hipMemcpy(dB, hB, nBytes, hipMemcpyHostToDevice);

	unsigned int workStartTime=getTimeInUs();
	printf("=======data copy finish, start working   [%u]   delta[%u]=======\n", workStartTime, workStartTime-startTime);
	dim3 block(COL);
	dim3 grid(ROW);

	sumArraysOnGPU<<<grid, block>>>(dA, dB, dC);
	hipDeviceSynchronize();
	
	unsigned int workEndTime=getTimeInUs();
	printf("=======work on GPU finish                [%u]   delta[%u]==========\n", workEndTime, workEndTime-workStartTime);
	hipMemcpy(gpuRef, dC, nBytes, hipMemcpyDeviceToHost);
	unsigned int cpEndTime=getTimeInUs();
	printf("=======copy back to CPU finish           [%u]   delta[%u]==========\n", cpEndTime, cpEndTime-workEndTime);

	workStartTime=getTimeInUs();
	printf("=======work on CPU started               [%u]   ==========\n", workStartTime);
	sumArraysOnHost(hA, hB, hostRef, nElem);
	workEndTime=getTimeInUs();
	printf("=======work on CPU finished              [%u]   delta[%u]==========\n", workEndTime, workEndTime-workStartTime);

	//validation
	for (int i=0; i<nElem;i++)
	{
		if (hostRef[i]!=gpuRef[i])
		{
			printf("invalid result: host: %5.5f device: %5.5f\n", hostRef[i], gpuRef[i]);
		}
	}
	printf("=======finish==========\n");
	
	return 0;
}

	.text
	.file	"simpleTest.hip"
	.globl	_Z8printArrPKcPfj               # -- Begin function _Z8printArrPKcPfj
	.type	_Z8printArrPKcPfj,@function
_Z8printArrPKcPfj:                      # @_Z8printArrPKcPfj
	.cfi_startproc
# %bb.0:
	testl	%edx, %edx
	je	.LBB0_4
# %bb.1:                                # %.lr.ph.preheader
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r12
	.cfi_def_cfa_offset 32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	pushq	%rax
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -40
	.cfi_offset %r12, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rsi, %rbx
	movq	%rdi, %r14
	movl	%edx, %r12d
	xorl	%r15d, %r15d
.LBB0_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	xorps	%xmm0, %xmm0
	cvtss2sd	(%rbx,%r15,4), %xmm0
	movl	$.L.str, %edi
	movq	%r14, %rsi
	movl	%r15d, %edx
	movb	$1, %al
	callq	printf
	incq	%r15
	cmpq	%r15, %r12
	jne	.LBB0_2
# %bb.3:
	addq	$8, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	.cfi_restore %rbx
	.cfi_restore %r12
	.cfi_restore %r14
	.cfi_restore %r15
.LBB0_4:                                # %._crit_edge
	retq
.Lfunc_end0:
	.size	_Z8printArrPKcPfj, .Lfunc_end0-_Z8printArrPKcPfj
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function _Z8initDataPfi
.LCPI1_0:
	.long	0x41200000                      # float 10
	.text
	.globl	_Z8initDataPfi
	.type	_Z8initDataPfi,@function
_Z8initDataPfi:                         # @_Z8initDataPfi
	.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	%rbx
	.cfi_def_cfa_offset 40
	pushq	%rax
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	%esi, %ebp
	movq	%rdi, %rbx
	movl	$1, %edi
	callq	sleep
	movq	%rsp, %rdi
	callq	time
	movl	%eax, %edi
	callq	srand
	testl	%ebp, %ebp
	jle	.LBB1_3
# %bb.1:                                # %.lr.ph.preheader
	movl	%ebp, %r14d
	xorl	%r15d, %r15d
.LBB1_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	callq	rand
	movzbl	%al, %eax
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	divss	.LCPI1_0(%rip), %xmm0
	movss	%xmm0, (%rbx,%r15,4)
	incq	%r15
	cmpq	%r15, %r14
	jne	.LBB1_2
.LBB1_3:                                # %._crit_edge
	addq	$8, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.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_end1:
	.size	_Z8initDataPfi, .Lfunc_end1-_Z8initDataPfi
	.cfi_endproc
                                        # -- End function
	.globl	_Z11getTimeInUsv                # -- Begin function _Z11getTimeInUsv
	.type	_Z11getTimeInUsv,@function
_Z11getTimeInUsv:                       # @_Z11getTimeInUsv
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$16, %rsp
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -16
	movq	%rsp, %rbx
	xorl	%edi, %edi
	movq	%rbx, %rsi
	callq	clock_gettime
	imull	$1000000000, (%rbx), %eax       # imm = 0x3B9ACA00
	addl	8(%rbx), %eax
	addq	$16, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end2:
	.size	_Z11getTimeInUsv, .Lfunc_end2-_Z11getTimeInUsv
	.cfi_endproc
                                        # -- End function
	.globl	_Z15sumArraysOnHostPfS_S_i      # -- Begin function _Z15sumArraysOnHostPfS_S_i
	.type	_Z15sumArraysOnHostPfS_S_i,@function
_Z15sumArraysOnHostPfS_S_i:             # @_Z15sumArraysOnHostPfS_S_i
	.cfi_startproc
# %bb.0:
	testl	%ecx, %ecx
	jle	.LBB3_3
# %bb.1:                                # %.lr.ph.preheader
	movl	%ecx, %eax
	xorl	%ecx, %ecx
.LBB3_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movss	(%rdi,%rcx,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	addss	(%rsi,%rcx,4), %xmm0
	movss	%xmm0, (%rdx,%rcx,4)
	incq	%rcx
	cmpq	%rcx, %rax
	jne	.LBB3_2
.LBB3_3:                                # %._crit_edge
	retq
.Lfunc_end3:
	.size	_Z15sumArraysOnHostPfS_S_i, .Lfunc_end3-_Z15sumArraysOnHostPfS_S_i
	.cfi_endproc
                                        # -- End function
	.globl	_Z29__device_stub__sumArraysOnGPUPfS_S_ # -- Begin function _Z29__device_stub__sumArraysOnGPUPfS_S_
	.type	_Z29__device_stub__sumArraysOnGPUPfS_S_,@function
_Z29__device_stub__sumArraysOnGPUPfS_S_: # @_Z29__device_stub__sumArraysOnGPUPfS_S_
	.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
	movq	%rdx, (%rsi)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	movq	%rsi, 16(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	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	$_Z14sumArraysOnGPUPfS_S_, %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_end4:
	.size	_Z29__device_stub__sumArraysOnGPUPfS_S_, .Lfunc_end4-_Z29__device_stub__sumArraysOnGPUPfS_S_
	.cfi_endproc
                                        # -- End function
	.globl	main                            # -- Begin function main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$1528, %rsp                     # imm = 0x5F8
	.cfi_def_cfa_offset 1584
	.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	(%rsi), %rsi
	movl	$.L.str.1, %edi
	xorl	%eax, %eax
	callq	printf
	leaq	56(%rsp), %rbx
	movq	%rbx, %rdi
	xorl	%esi, %esi
	callq	hipGetDevicePropertiesR0600
	movl	$.L.str.2, %edi
	xorl	%esi, %esi
	movq	%rbx, %rdx
	xorl	%eax, %eax
	callq	printf
	xorl	%edi, %edi
	callq	hipSetDevice
	movl	$.L.str.3, %edi
	movl	$1048576, %esi                  # imm = 0x100000
	xorl	%eax, %eax
	callq	printf
	movl	$4194304, %edi                  # imm = 0x400000
	callq	malloc
	movq	%rax, %r15
	movl	$4194304, %edi                  # imm = 0x400000
	callq	malloc
	movq	%rax, %r12
	movl	$1, %edi
	movl	$4194304, %esi                  # imm = 0x400000
	callq	calloc@PLT
	movq	%rax, %rbx
	movl	$1, %edi
	movl	$4194304, %esi                  # imm = 0x400000
	callq	calloc@PLT
	movq	%rax, %r14
	movq	%r15, %rdi
	movl	$1048576, %esi                  # imm = 0x100000
	callq	_Z8initDataPfi
	movq	%r12, %rdi
	movl	$1048576, %esi                  # imm = 0x100000
	callq	_Z8initDataPfi
	leaq	48(%rsp), %rdi
	movl	$4194304, %esi                  # imm = 0x400000
	callq	hipMalloc
	leaq	40(%rsp), %rdi
	movl	$4194304, %esi                  # imm = 0x400000
	callq	hipMalloc
	leaq	32(%rsp), %rdi
	movl	$4194304, %esi                  # imm = 0x400000
	callq	hipMalloc
	leaq	16(%rsp), %rbp
	xorl	%edi, %edi
	movq	%rbp, %rsi
	callq	clock_gettime
	imull	$1000000000, (%rbp), %r13d      # imm = 0x3B9ACA00
	addl	8(%rbp), %r13d
	movl	$.L.str.4, %edi
	movl	%r13d, %esi
	xorl	%eax, %eax
	callq	printf
	leaq	48(%rsp), %rax
	movq	(%rax), %rdi
	movl	$4194304, %edx                  # imm = 0x400000
	movq	%r15, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	leaq	40(%rsp), %rax
	movq	(%rax), %rdi
	movl	$4194304, %edx                  # imm = 0x400000
	movq	%r12, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	leaq	16(%rsp), %rbp
	xorl	%edi, %edi
	movq	%rbp, %rsi
	callq	clock_gettime
	imull	$1000000000, (%rbp), %esi       # imm = 0x3B9ACA00
	addl	8(%rbp), %esi
	movl	%esi, %edx
	subl	%r13d, %edx
	movl	$.L.str.5, %edi
	movl	%esi, 12(%rsp)                  # 4-byte Spill
	xorl	%eax, %eax
	callq	printf
	movabsq	$4294968320, %rdi               # imm = 0x100000400
	movl	$1, %esi
	movq	%rdi, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB5_2
# %bb.1:
	movq	48(%rsp), %rdi
	movq	40(%rsp), %rsi
	movq	32(%rsp), %rdx
	callq	_Z29__device_stub__sumArraysOnGPUPfS_S_
.LBB5_2:
	callq	hipDeviceSynchronize
	xorl	%ebp, %ebp
	leaq	16(%rsp), %rsi
	xorl	%edi, %edi
	movq	%rsi, %r13
	callq	clock_gettime
	movq	%r13, %rax
	imull	$1000000000, (%r13), %r13d      # imm = 0x3B9ACA00
	addl	8(%rax), %r13d
	movl	%r13d, %edx
	subl	12(%rsp), %edx                  # 4-byte Folded Reload
	movl	$.L.str.6, %edi
	movl	%r13d, %esi
	xorl	%eax, %eax
	callq	printf
	movq	32(%rsp), %rsi
	movl	$4194304, %edx                  # imm = 0x400000
	movq	%r14, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	leaq	16(%rsp), %rsi
	xorl	%edi, %edi
	callq	clock_gettime
	leaq	16(%rsp), %rax
	imull	$1000000000, (%rax), %esi       # imm = 0x3B9ACA00
	addl	8(%rax), %esi
	movl	%esi, %edx
	subl	%r13d, %edx
	movl	$.L.str.7, %edi
	xorl	%eax, %eax
	callq	printf
	leaq	16(%rsp), %rsi
	xorl	%edi, %edi
	movq	%rsi, %r13
	callq	clock_gettime
	movq	%r13, %rax
	imull	$1000000000, (%r13), %r13d      # imm = 0x3B9ACA00
	addl	8(%rax), %r13d
	movl	$.L.str.8, %edi
	movl	%r13d, %esi
	xorl	%eax, %eax
	callq	printf
.LBB5_3:                                # %.lr.ph.i
                                        # =>This Inner Loop Header: Depth=1
	movss	(%r15,%rbp,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	addss	(%r12,%rbp,4), %xmm0
	movss	%xmm0, (%rbx,%rbp,4)
	incq	%rbp
	cmpq	$1048576, %rbp                  # imm = 0x100000
	jne	.LBB5_3
# %bb.4:                                # %_Z15sumArraysOnHostPfS_S_i.exit
	xorl	%r12d, %r12d
	leaq	16(%rsp), %r15
	xorl	%edi, %edi
	movq	%r15, %rsi
	callq	clock_gettime
	imull	$1000000000, (%r15), %esi       # imm = 0x3B9ACA00
	addl	8(%r15), %esi
	movl	%esi, %edx
	subl	%r13d, %edx
	movl	$.L.str.9, %edi
	xorl	%eax, %eax
	callq	printf
.LBB5_5:                                # =>This Inner Loop Header: Depth=1
	movss	(%rbx,%r12,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	movss	(%r14,%r12,4), %xmm1            # xmm1 = mem[0],zero,zero,zero
	ucomiss	%xmm1, %xmm0
	jne	.LBB5_6
	jnp	.LBB5_7
.LBB5_6:                                #   in Loop: Header=BB5_5 Depth=1
	cvtss2sd	%xmm0, %xmm0
	cvtss2sd	%xmm1, %xmm1
	movl	$.L.str.10, %edi
	movb	$2, %al
	callq	printf
.LBB5_7:                                #   in Loop: Header=BB5_5 Depth=1
	incq	%r12
	cmpq	$1048576, %r12                  # imm = 0x100000
	jne	.LBB5_5
# %bb.8:
	movl	$.Lstr, %edi
	callq	puts@PLT
	xorl	%eax, %eax
	addq	$1528, %rsp                     # imm = 0x5F8
	.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_end5:
	.size	main, .Lfunc_end5-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	.LBB6_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB6_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z14sumArraysOnGPUPfS_S_, %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_end6:
	.size	__hip_module_ctor, .Lfunc_end6-__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	.LBB7_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
.LBB7_2:
	retq
.Lfunc_end7:
	.size	__hip_module_dtor, .Lfunc_end7-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"arr %s [%u]=%5.5f\n"
	.size	.L.str, 19

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

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

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"Using Device %d, %s\n"
	.size	.L.str.2, 21

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"Vector size= %d\n"
	.size	.L.str.3, 17

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"=======start data copying [%u]==========\n"
	.size	.L.str.4, 42

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"=======data copy finish, start working   [%u]   delta[%u]=======\n"
	.size	.L.str.5, 66

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"=======work on GPU finish                [%u]   delta[%u]==========\n"
	.size	.L.str.6, 69

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"=======copy back to CPU finish           [%u]   delta[%u]==========\n"
	.size	.L.str.7, 69

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"=======work on CPU started               [%u]   ==========\n"
	.size	.L.str.8, 60

	.type	.L.str.9,@object                # @.str.9
.L.str.9:
	.asciz	"=======work on CPU finished              [%u]   delta[%u]==========\n"
	.size	.L.str.9, 69

	.type	.L.str.10,@object               # @.str.10
.L.str.10:
	.asciz	"invalid result: host: %5.5f device: %5.5f\n"
	.size	.L.str.10, 43

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

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

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

	.type	.Lstr,@object                   # @str
	.section	.rodata.str1.1,"aMS",@progbits,1
.Lstr:
	.asciz	"=======finish=========="
	.size	.Lstr, 24

	.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__sumArraysOnGPUPfS_S_
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z14sumArraysOnGPUPfS_S_
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z14sumArraysOnGPUPfS_S_ ; -- Begin function _Z14sumArraysOnGPUPfS_S_
	.globl	_Z14sumArraysOnGPUPfS_S_
	.p2align	8
	.type	_Z14sumArraysOnGPUPfS_S_,@function
_Z14sumArraysOnGPUPfS_S_:               ; @_Z14sumArraysOnGPUPfS_S_
; %bb.0:
	s_load_b128 s[4:7], s[0:1], 0x0
	v_lshl_or_b32 v0, s15, 10, v0
	s_load_b64 s[0:1], s[0:1], 0x10
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v1, 31, v0
	v_lshlrev_b64 v[0:1], 2, v[0:1]
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v2, vcc_lo, s4, v0
	v_add_co_ci_u32_e32 v3, vcc_lo, s5, v1, vcc_lo
	v_add_co_u32 v4, vcc_lo, s6, v0
	v_add_co_ci_u32_e32 v5, vcc_lo, s7, v1, vcc_lo
	v_add_co_u32 v0, vcc_lo, s0, v0
	global_load_b32 v2, v[2:3], off
	global_load_b32 v3, v[4:5], off
	v_add_co_ci_u32_e32 v1, vcc_lo, s1, v1, vcc_lo
	s_waitcnt vmcnt(0)
	v_add_f32_e32 v2, v2, v3
	global_store_b32 v[0:1], v2, off
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z14sumArraysOnGPUPfS_S_
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 24
		.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	_Z14sumArraysOnGPUPfS_S_, .Lfunc_end0-_Z14sumArraysOnGPUPfS_S_
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 128
; 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
      - .address_space:  global
        .offset:         16
        .size:           8
        .value_kind:     global_buffer
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 24
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z14sumArraysOnGPUPfS_S_
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z14sumArraysOnGPUPfS_S_.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
