#include <stdio.h>
#include <cuda_runtime.h>
#include <device_launch_parameters.h>
#include <cmath>
#include <cstring>

#define NSTREAM 4
#define BDIM 128

void initialData(float *ip, int size)
{
	for (int i = 0; i < size; i++)
	{
		ip[i] = (float)(rand() & 0xFF) / 10.0f;
	}
}

void sumArraysOnHost(float *A, float *B, float *C, const int N)
{
	for (int idx = 0; idx < N; idx++)
		C[idx] = A[idx] + B[idx];
}

__global__ void sumArrays(float *A, float *B, float *C, const int N)
{
	int idx = blockIdx.x * blockDim.x + threadIdx.x;

	if (idx < N)
	{
		for (int i = 0; i < N; ++i)
		{
			C[idx] = A[idx] + B[idx];
		}
	}
}

void checkResult(float *hostRef, float *gpuRef, const int N)
{
	double epsilon = 1.0E-8;
	bool match = true;

	for (int i = 0; i < N; i++)
	{
		if (abs(hostRef[i] - gpuRef[i]) > epsilon)
		{
			match = false;
			printf("Arrays do not match!\n");
			printf("host %5.2f gpu %5.2f at %d\n", hostRef[i], gpuRef[i], i);
			break;
		}
	}

	if (match)
		printf("Arrays match.\n\n");
}

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);
	cudaSetDevice(dev);

	// check if device support hyper-q
	if (deviceProp.major < 3 || (deviceProp.major == 3 && deviceProp.minor < 5))
	{
		if (deviceProp.concurrentKernels == 0)
		{
			printf("> GPU does not support concurrent kernel execution (SM 3.5 or higher required)\n");
			printf("> CUDA kernel runs will be serialized\n");
		}
		else
		{
			printf("> GPU does not support HyperQ\n");
			printf("> CUDA kernel runs will have limited concurrency\n");
		}
	}

	printf("> Compute Capability %d.%d hardware with %d multi-processors\n", deviceProp.major, deviceProp.minor, deviceProp.multiProcessorCount);

	// set up data size of vectors
	int nElem = 1 << 16;
	printf("> vector size = %d\n", nElem);
	size_t nBytes = nElem * sizeof(float);

	// malloc pinned host memory for async memcpy
	float *h_A, *h_B, *hostRef, *gpuRef;
	cudaHostAlloc((void**)&h_A, nBytes, cudaHostAllocDefault);
	cudaHostAlloc((void**)&h_B, nBytes, cudaHostAllocDefault);
	cudaHostAlloc((void**)&gpuRef, nBytes, cudaHostAllocDefault);
	cudaHostAlloc((void**)&hostRef, nBytes, cudaHostAllocDefault);

	// initialize data at host side
	initialData(h_A, nElem);
	initialData(h_B, nElem);
	memset(hostRef, 0, nBytes);
	memset(gpuRef, 0, nBytes);

	// add vector at host side for result checks
	sumArraysOnHost(h_A, h_B, hostRef, nElem);

	// malloc device global memory
	float *d_A, *d_B, *d_C;
	cudaMalloc((float**)&d_A, nBytes);
	cudaMalloc((float**)&d_B, nBytes);
	cudaMalloc((float**)&d_C, nBytes);

	cudaEvent_t start, stop;
	cudaEventCreate(&start);
	cudaEventCreate(&stop);

	// invoke kernel at host side
	dim3 block(BDIM);
	dim3 grid((nElem + block.x - 1) / block.x);
	printf("> grid (%d, %d) block (%d, %d)\n", grid.x, grid.y, block.x,block.y);

	// sequential operation
	cudaEventRecord(start, 0);
	cudaMemcpy(d_A, h_A, nBytes, cudaMemcpyHostToDevice);
	cudaMemcpy(d_B, h_B, nBytes, cudaMemcpyHostToDevice);
	cudaEventRecord(stop, 0);
	cudaEventSynchronize(stop);
	float memcpy_h2d_time;
	cudaEventElapsedTime(&memcpy_h2d_time, start, stop);

	cudaEventRecord(start, 0);
	sumArrays <<<grid, block >>>(d_A, d_B, d_C, nElem);
	cudaEventRecord(stop, 0);
	cudaEventSynchronize(stop);

	float kernel_time;
	cudaEventElapsedTime(&kernel_time, start, stop);
	cudaEventRecord(start, 0);
	cudaMemcpy(gpuRef, d_C, nBytes, cudaMemcpyDeviceToHost);
	cudaEventRecord(stop, 0);
	cudaEventSynchronize(stop);
	float memcpy_d2h_time;
	cudaEventElapsedTime(&memcpy_d2h_time, start, stop);
	float itotal = kernel_time + memcpy_h2d_time + memcpy_d2h_time;

	printf("\n");
	printf("Measured timings (throughput):\n");
	printf(" Memcpy host to device\t: %f ms (%f GB/s)\n", memcpy_h2d_time, (nBytes * 1e-6) / memcpy_h2d_time);
	printf(" Memcpy device to host\t: %f ms (%f GB/s)\n", memcpy_d2h_time, (nBytes * 1e-6) / memcpy_d2h_time);
	printf(" Kernel\t\t\t: %f ms (%f GB/s)\n", kernel_time, (nBytes * 2e-6) / kernel_time);
	printf(" Total\t\t\t: %f ms (%f GB/s)\n", itotal, (nBytes * 2e-6) / itotal);

	// grid parallel operation
	int iElem = nElem / NSTREAM;
	size_t iBytes = iElem * sizeof(float);
	grid.x = (iElem + block.x - 1) / block.x;

	cudaStream_t stream[NSTREAM];

	for (int i = 0; i < NSTREAM; ++i)
	{
		cudaStreamCreate(&stream[i]);
	}

	cudaEventRecord(start, 0);

	// initiate all work on the device asynchronously in depth-first order
	for (int i = 0; i < NSTREAM; ++i)
	{
		int ioffset = i * iElem;
		cudaMemcpyAsync(&d_A[ioffset], &h_A[ioffset], iBytes, cudaMemcpyHostToDevice, stream[i]);
		cudaMemcpyAsync(&d_B[ioffset], &h_B[ioffset], iBytes, cudaMemcpyHostToDevice, stream[i]);
		sumArrays <<<grid, block, 0, stream[i] >>>(&d_A[ioffset], &d_B[ioffset], &d_C[ioffset], iElem);
		cudaMemcpyAsync(&gpuRef[ioffset], &d_C[ioffset], iBytes, cudaMemcpyDeviceToHost, stream[i]);
	}

	cudaEventRecord(stop, 0);
	cudaEventSynchronize(stop);
	float execution_time;
	cudaEventElapsedTime(&execution_time, start, stop);

	printf("\n");
	printf("Actual results from overlapped data transfers:\n");
	printf(" overlap with %d streams : %f ms (%f GB/s)\n", NSTREAM, execution_time, (nBytes * 2e-6) / execution_time);
	printf(" speedup                : %f \n", ((itotal - execution_time) * 100.0f) / itotal);

	// check kernel error
	cudaGetLastError();

	// check device results
	checkResult(hostRef, gpuRef, nElem);

	// free device global memory
	cudaFree(d_A);
	cudaFree(d_B);
	cudaFree(d_C);

	// free host memory
	cudaFreeHost(h_A);
	cudaFreeHost(h_B);
	cudaFreeHost(hostRef);
	cudaFreeHost(gpuRef);

	// destroy events
	cudaEventDestroy(start);
	cudaEventDestroy(stop);

	// destroy streams
	for (int i = 0; i < NSTREAM; ++i)
	{
		cudaStreamDestroy(stream[i]);
	}

	cudaDeviceReset();

	system("Pause");
	return(0);
}
	.file	"tmpxft_00255b9e_00000000-6_kernel.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2033:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2033:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z11initialDataPfi
	.type	_Z11initialDataPfi, @function
_Z11initialDataPfi:
.LFB2027:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movq	%rdi, %r12
	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
.L3:
	cmpl	%ebx, %ebp
	jle	.L7
	call	rand@PLT
	movzbl	%al, %eax
	cvtsi2ssl	%eax, %xmm0
	divss	.LC0(%rip), %xmm0
	movss	%xmm0, (%r12,%rbx,4)
	incq	%rbx
	jmp	.L3
.L7:
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2027:
	.size	_Z11initialDataPfi, .-_Z11initialDataPfi
	.globl	_Z15sumArraysOnHostPfS_S_i
	.type	_Z15sumArraysOnHostPfS_S_i, @function
_Z15sumArraysOnHostPfS_S_i:
.LFB2028:
	.cfi_startproc
	endbr64
	xorl	%eax, %eax
.L9:
	cmpl	%eax, %ecx
	jle	.L11
	movss	(%rdi,%rax,4), %xmm0
	addss	(%rsi,%rax,4), %xmm0
	movss	%xmm0, (%rdx,%rax,4)
	incq	%rax
	jmp	.L9
.L11:
	ret
	.cfi_endproc
.LFE2028:
	.size	_Z15sumArraysOnHostPfS_S_i, .-_Z15sumArraysOnHostPfS_S_i
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC3:
	.string	"Arrays do not match!\n"
.LC4:
	.string	"host %5.2f gpu %5.2f at %d\n"
.LC5:
	.string	"Arrays match.\n\n"
	.text
	.globl	_Z11checkResultPfS_i
	.type	_Z11checkResultPfS_i, @function
_Z11checkResultPfS_i:
.LFB2029:
	.cfi_startproc
	endbr64
	movsd	.LC2(%rip), %xmm2
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movss	.LC1(%rip), %xmm1
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	xorl	%ebx, %ebx
.L13:
	cmpl	%edx, %ebx
	jge	.L20
	movq	%rdi, %r12
	movq	%rsi, %rbp
	addq	$4, %rdi
	addq	$4, %rsi
	movss	(%r12), %xmm0
	subss	0(%rbp), %xmm0
	andps	%xmm1, %xmm0
	cvtss2sd	%xmm0, %xmm0
	comisd	%xmm2, %xmm0
	jbe	.L18
	leaq	.LC3(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	%ebx, %edx
	movb	$2, %al
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	cvtss2sd	(%r12), %xmm0
	cvtss2sd	0(%rbp), %xmm1
	movl	$2, %edi
	popq	%rbp
	.cfi_def_cfa_offset 16
	leaq	.LC4(%rip), %rsi
	popq	%r12
	.cfi_def_cfa_offset 8
	jmp	__printf_chk@PLT
.L18:
	.cfi_restore_state
	incl	%ebx
	jmp	.L13
.L20:
	popq	%rbx
	.cfi_def_cfa_offset 24
	leaq	.LC5(%rip), %rsi
	popq	%rbp
	.cfi_def_cfa_offset 16
	movl	$2, %edi
	xorl	%eax, %eax
	popq	%r12
	.cfi_def_cfa_offset 8
	jmp	__printf_chk@PLT
	.cfi_endproc
.LFE2029:
	.size	_Z11checkResultPfS_i, .-_Z11checkResultPfS_i
	.globl	_Z33__device_stub__Z9sumArraysPfS_S_iPfS_S_i
	.type	_Z33__device_stub__Z9sumArraysPfS_S_iPfS_S_i, @function
_Z33__device_stub__Z9sumArraysPfS_S_iPfS_S_i:
.LFB2055:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movq	%rdi, 24(%rsp)
	leaq	56(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	68(%rsp), %rsi
	movq	%rdx, 8(%rsp)
	leaq	40(%rsp), %rdx
	movl	%ecx, 4(%rsp)
	leaq	48(%rsp), %rcx
	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	.L21
	pushq	48(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z9sumArraysPfS_S_i(%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
.L21:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L23
	call	__stack_chk_fail@PLT
.L23:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2055:
	.size	_Z33__device_stub__Z9sumArraysPfS_S_iPfS_S_i, .-_Z33__device_stub__Z9sumArraysPfS_S_iPfS_S_i
	.globl	_Z9sumArraysPfS_S_i
	.type	_Z9sumArraysPfS_S_i, @function
_Z9sumArraysPfS_S_i:
.LFB2056:
	.cfi_startproc
	endbr64
	jmp	_Z33__device_stub__Z9sumArraysPfS_S_iPfS_S_i
	.cfi_endproc
.LFE2056:
	.size	_Z9sumArraysPfS_S_i, .-_Z9sumArraysPfS_S_i
	.section	.rodata.str1.1
.LC6:
	.string	"> %s Starting...\n"
.LC7:
	.string	"> Using Device %d: %s\n"
.LC8:
	.string	"> GPU does not support concurrent kernel execution (SM 3.5 or higher required)\n"
.LC9:
	.string	"> CUDA kernel runs will be serialized\n"
.LC10:
	.string	"> GPU does not support HyperQ\n"
.LC11:
	.string	"> CUDA kernel runs will have limited concurrency\n"
.LC12:
	.string	"> Compute Capability %d.%d hardware with %d multi-processors\n"
.LC13:
	.string	"> vector size = %d\n"
.LC14:
	.string	"> grid (%d, %d) block (%d, %d)\n"
.LC15:
	.string	"\n"
.LC16:
	.string	"Measured timings (throughput):\n"
.LC18:
	.string	" Memcpy host to device\t: %f ms (%f GB/s)\n"
.LC19:
	.string	" Memcpy device to host\t: %f ms (%f GB/s)\n"
.LC21:
	.string	" Kernel\t\t\t: %f ms (%f GB/s)\n"
.LC22:
	.string	" Total\t\t\t: %f ms (%f GB/s)\n"
.LC23:
	.string	"Actual results from overlapped data transfers:\n"
.LC24:
	.string	" overlap with %d streams : %f ms (%f GB/s)\n"
.LC26:
	.string	" speedup                : %f \n"
.LC27:
	.string	"Pause"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2030:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	movl	$2, %edi
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$1208, %rsp
	.cfi_def_cfa_offset 1248
	movq	(%rsi), %rdx
	leaq	.LC6(%rip), %rsi
	movq	%fs:40, %rax
	movq	%rax, 1192(%rsp)
	xorl	%eax, %eax
	leaq	160(%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	.LC7(%rip), %rsi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	xorl	%edi, %edi
	call	cudaSetDevice@PLT
	movl	520(%rsp), %eax
	cmpl	$2, %eax
	jle	.L27
	cmpl	$3, %eax
	jne	.L28
	cmpl	$4, 524(%rsp)
	jg	.L28
.L27:
	cmpl	$0, 736(%rsp)
	jne	.L29
	leaq	.LC8(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	.LC9(%rip), %rsi
	jmp	.L38
.L29:
	leaq	.LC10(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	.LC11(%rip), %rsi
.L38:
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L28:
	movl	548(%rsp), %r8d
	movl	524(%rsp), %ecx
	xorl	%eax, %eax
	leaq	.LC12(%rip), %rsi
	movl	520(%rsp), %edx
	movl	$2, %edi
	call	__printf_chk@PLT
	movl	$65536, %edx
	leaq	.LC13(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
	xorl	%edx, %edx
	leaq	32(%rsp), %rdi
	movl	$262144, %esi
	call	cudaHostAlloc@PLT
	xorl	%edx, %edx
	leaq	40(%rsp), %rdi
	movl	$262144, %esi
	call	cudaHostAlloc@PLT
	xorl	%edx, %edx
	leaq	56(%rsp), %rdi
	movl	$262144, %esi
	call	cudaHostAlloc@PLT
	xorl	%edx, %edx
	leaq	48(%rsp), %rdi
	movl	$262144, %esi
	call	cudaHostAlloc@PLT
	movq	32(%rsp), %rdi
	movl	$65536, %esi
	call	_Z11initialDataPfi
	movq	40(%rsp), %rdi
	movl	$65536, %esi
	call	_Z11initialDataPfi
	movq	48(%rsp), %rdx
	xorl	%eax, %eax
	movl	$65536, %ecx
	movq	40(%rsp), %rsi
	movq	%rdx, %rdi
	rep stosl
	movq	56(%rsp), %rdi
	movl	$65536, %ecx
	rep stosl
	movq	32(%rsp), %rdi
	movl	$65536, %ecx
	call	_Z15sumArraysOnHostPfS_S_i
	leaq	64(%rsp), %rdi
	movl	$262144, %esi
	call	cudaMalloc@PLT
	leaq	72(%rsp), %rdi
	movl	$262144, %esi
	call	cudaMalloc@PLT
	movl	$262144, %esi
	leaq	80(%rsp), %rdi
	call	cudaMalloc@PLT
	leaq	88(%rsp), %rdi
	call	cudaEventCreate@PLT
	leaq	96(%rsp), %rdi
	call	cudaEventCreate@PLT
	movl	$1, %r9d
	movl	$128, %r8d
	movl	$1, %ecx
	movl	$512, %edx
	leaq	.LC14(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	88(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	32(%rsp), %rsi
	movq	64(%rsp), %rdi
	movl	$1, %ecx
	movl	$262144, %edx
	call	cudaMemcpy@PLT
	movq	40(%rsp), %rsi
	movq	72(%rsp), %rdi
	movl	$1, %ecx
	movl	$262144, %edx
	call	cudaMemcpy@PLT
	movq	96(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	96(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movq	96(%rsp), %rdx
	movq	88(%rsp), %rsi
	leaq	16(%rsp), %rdi
	call	cudaEventElapsedTime@PLT
	movq	88(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movl	$8388609, %edi
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	$33554433, %edx
	salq	$9, %rdi
	movl	$1, %ecx
	movl	$1, %esi
	salq	$7, %rdx
	movq	%rdi, 116(%rsp)
	movl	$1, 124(%rsp)
	movq	%rdx, 104(%rsp)
	movl	$1, 112(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L30
	movq	80(%rsp), %rdx
	movq	72(%rsp), %rsi
	movl	$65536, %ecx
	movq	64(%rsp), %rdi
	call	_Z33__device_stub__Z9sumArraysPfS_S_iPfS_S_i
.L30:
	movq	96(%rsp), %rdi
	xorl	%esi, %esi
	leaq	.LC15(%rip), %r13
	xorl	%ebx, %ebx
	leaq	128(%rsp), %rbp
	call	cudaEventRecord@PLT
	movq	96(%rsp), %rdi
	movq	%rbp, %r12
	call	cudaEventSynchronize@PLT
	movq	96(%rsp), %rdx
	movq	88(%rsp), %rsi
	leaq	20(%rsp), %rdi
	call	cudaEventElapsedTime@PLT
	movq	88(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	80(%rsp), %rsi
	movq	56(%rsp), %rdi
	movl	$2, %ecx
	movl	$262144, %edx
	call	cudaMemcpy@PLT
	movq	96(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	96(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movq	96(%rsp), %rdx
	movq	88(%rsp), %rsi
	leaq	24(%rsp), %rdi
	call	cudaEventElapsedTime@PLT
	movss	20(%rsp), %xmm0
	movq	%r13, %rsi
	xorl	%eax, %eax
	addss	16(%rsp), %xmm0
	addss	24(%rsp), %xmm0
	movl	$2, %edi
	movss	%xmm0, 12(%rsp)
	call	__printf_chk@PLT
	leaq	.LC16(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movsd	.LC17(%rip), %xmm1
	cvtss2sd	16(%rsp), %xmm0
	movb	$2, %al
	leaq	.LC18(%rip), %rsi
	movl	$2, %edi
	divsd	%xmm0, %xmm1
	call	__printf_chk@PLT
	movsd	.LC17(%rip), %xmm1
	cvtss2sd	24(%rsp), %xmm0
	movb	$2, %al
	leaq	.LC19(%rip), %rsi
	movl	$2, %edi
	divsd	%xmm0, %xmm1
	call	__printf_chk@PLT
	movsd	.LC20(%rip), %xmm1
	cvtss2sd	20(%rsp), %xmm0
	movb	$2, %al
	leaq	.LC21(%rip), %rsi
	movl	$2, %edi
	divsd	%xmm0, %xmm1
	call	__printf_chk@PLT
	movsd	.LC20(%rip), %xmm1
	cvtss2sd	12(%rsp), %xmm0
	movb	$2, %al
	leaq	.LC22(%rip), %rsi
	movl	$2, %edi
	divsd	%xmm0, %xmm1
	call	__printf_chk@PLT
	movq	%rbp, %rdi
	call	cudaStreamCreate@PLT
	leaq	136(%rsp), %rdi
	call	cudaStreamCreate@PLT
	leaq	144(%rsp), %rdi
	call	cudaStreamCreate@PLT
	leaq	152(%rsp), %rdi
	call	cudaStreamCreate@PLT
	movq	88(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
.L32:
	movq	32(%rsp), %rsi
	movq	64(%rsp), %rdi
	movl	$1, %ecx
	movl	$65536, %edx
	movq	(%r12), %r8
	addq	%rbx, %rsi
	addq	%rbx, %rdi
	call	cudaMemcpyAsync@PLT
	movq	40(%rsp), %rsi
	movq	72(%rsp), %rdi
	movl	$1, %ecx
	movq	(%r12), %r8
	movl	$65536, %edx
	addq	%rbx, %rsi
	addq	%rbx, %rdi
	call	cudaMemcpyAsync@PLT
	movl	112(%rsp), %ecx
	movq	(%r12), %r9
	xorl	%r8d, %r8d
	movl	$128, 116(%rsp)
	movq	104(%rsp), %rdx
	movq	116(%rsp), %rdi
	movl	124(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L31
	movq	80(%rsp), %rdx
	movq	72(%rsp), %rsi
	movl	$16384, %ecx
	movq	64(%rsp), %rdi
	addq	%rbx, %rdx
	addq	%rbx, %rsi
	addq	%rbx, %rdi
	call	_Z33__device_stub__Z9sumArraysPfS_S_iPfS_S_i
.L31:
	movq	80(%rsp), %rsi
	movq	56(%rsp), %rdi
	movl	$2, %ecx
	movl	$65536, %edx
	movq	(%r12), %r8
	addq	$8, %r12
	addq	%rbx, %rsi
	addq	%rbx, %rdi
	addq	$65536, %rbx
	call	cudaMemcpyAsync@PLT
	cmpq	$262144, %rbx
	jne	.L32
	movq	96(%rsp), %rdi
	xorl	%esi, %esi
	xorl	%ebx, %ebx
	call	cudaEventRecord@PLT
	movq	96(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movq	96(%rsp), %rdx
	movq	88(%rsp), %rsi
	leaq	28(%rsp), %rdi
	call	cudaEventElapsedTime@PLT
	movq	%r13, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	.LC23(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movsd	.LC20(%rip), %xmm1
	movb	$2, %al
	cvtss2sd	28(%rsp), %xmm0
	movl	$4, %edx
	leaq	.LC24(%rip), %rsi
	movl	$2, %edi
	divsd	%xmm0, %xmm1
	call	__printf_chk@PLT
	leaq	.LC26(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	movss	12(%rsp), %xmm0
	subss	28(%rsp), %xmm0
	mulss	.LC25(%rip), %xmm0
	divss	12(%rsp), %xmm0
	cvtss2sd	%xmm0, %xmm0
	call	__printf_chk@PLT
	call	cudaGetLastError@PLT
	movq	56(%rsp), %rsi
	movq	48(%rsp), %rdi
	movl	$65536, %edx
	call	_Z11checkResultPfS_i
	movq	64(%rsp), %rdi
	call	cudaFree@PLT
	movq	72(%rsp), %rdi
	call	cudaFree@PLT
	movq	80(%rsp), %rdi
	call	cudaFree@PLT
	movq	32(%rsp), %rdi
	call	cudaFreeHost@PLT
	movq	40(%rsp), %rdi
	call	cudaFreeHost@PLT
	movq	48(%rsp), %rdi
	call	cudaFreeHost@PLT
	movq	56(%rsp), %rdi
	call	cudaFreeHost@PLT
	movq	88(%rsp), %rdi
	call	cudaEventDestroy@PLT
	movq	96(%rsp), %rdi
	call	cudaEventDestroy@PLT
.L33:
	movq	0(%rbp,%rbx,8), %rdi
	incq	%rbx
	call	cudaStreamDestroy@PLT
	cmpq	$4, %rbx
	jne	.L33
	call	cudaDeviceReset@PLT
	leaq	.LC27(%rip), %rdi
	call	system@PLT
	movq	1192(%rsp), %rax
	subq	%fs:40, %rax
	je	.L34
	call	__stack_chk_fail@PLT
.L34:
	addq	$1208, %rsp
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2030:
	.size	main, .-main
	.section	.rodata.str1.1
.LC28:
	.string	"_Z9sumArraysPfS_S_i"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2058:
	.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	.LC28(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z9sumArraysPfS_S_i(%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
.LFE2058:
	.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
.LC0:
	.long	1092616192
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC1:
	.long	2147483647
	.long	0
	.long	0
	.long	0
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC2:
	.long	-500134854
	.long	1044740494
	.align 8
.LC17:
	.long	-1598689907
	.long	1070647031
	.align 8
.LC20:
	.long	-1598689907
	.long	1071695607
	.section	.rodata.cst4
	.align 4
.LC25:
	.long	1120403456
	.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 <stdio.h>
#include <hip/hip_runtime.h>

#include <cmath>
#include <cstring>

#define NSTREAM 4
#define BDIM 128

void initialData(float *ip, int size)
{
	for (int i = 0; i < size; i++)
	{
		ip[i] = (float)(rand() & 0xFF) / 10.0f;
	}
}

void sumArraysOnHost(float *A, float *B, float *C, const int N)
{
	for (int idx = 0; idx < N; idx++)
		C[idx] = A[idx] + B[idx];
}

__global__ void sumArrays(float *A, float *B, float *C, const int N)
{
	int idx = blockIdx.x * blockDim.x + threadIdx.x;

	if (idx < N)
	{
		for (int i = 0; i < N; ++i)
		{
			C[idx] = A[idx] + B[idx];
		}
	}
}

void checkResult(float *hostRef, float *gpuRef, const int N)
{
	double epsilon = 1.0E-8;
	bool match = true;

	for (int i = 0; i < N; i++)
	{
		if (abs(hostRef[i] - gpuRef[i]) > epsilon)
		{
			match = false;
			printf("Arrays do not match!\n");
			printf("host %5.2f gpu %5.2f at %d\n", hostRef[i], gpuRef[i], i);
			break;
		}
	}

	if (match)
		printf("Arrays match.\n\n");
}

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);
	hipSetDevice(dev);

	// check if device support hyper-q
	if (deviceProp.major < 3 || (deviceProp.major == 3 && deviceProp.minor < 5))
	{
		if (deviceProp.concurrentKernels == 0)
		{
			printf("> GPU does not support concurrent kernel execution (SM 3.5 or higher required)\n");
			printf("> CUDA kernel runs will be serialized\n");
		}
		else
		{
			printf("> GPU does not support HyperQ\n");
			printf("> CUDA kernel runs will have limited concurrency\n");
		}
	}

	printf("> Compute Capability %d.%d hardware with %d multi-processors\n", deviceProp.major, deviceProp.minor, deviceProp.multiProcessorCount);

	// set up data size of vectors
	int nElem = 1 << 16;
	printf("> vector size = %d\n", nElem);
	size_t nBytes = nElem * sizeof(float);

	// malloc pinned host memory for async memcpy
	float *h_A, *h_B, *hostRef, *gpuRef;
	hipHostAlloc((void**)&h_A, nBytes, hipHostMallocDefault);
	hipHostAlloc((void**)&h_B, nBytes, hipHostMallocDefault);
	hipHostAlloc((void**)&gpuRef, nBytes, hipHostMallocDefault);
	hipHostAlloc((void**)&hostRef, nBytes, hipHostMallocDefault);

	// initialize data at host side
	initialData(h_A, nElem);
	initialData(h_B, nElem);
	memset(hostRef, 0, nBytes);
	memset(gpuRef, 0, nBytes);

	// add vector at host side for result checks
	sumArraysOnHost(h_A, h_B, hostRef, nElem);

	// malloc device global memory
	float *d_A, *d_B, *d_C;
	hipMalloc((float**)&d_A, nBytes);
	hipMalloc((float**)&d_B, nBytes);
	hipMalloc((float**)&d_C, nBytes);

	hipEvent_t start, stop;
	hipEventCreate(&start);
	hipEventCreate(&stop);

	// invoke kernel at host side
	dim3 block(BDIM);
	dim3 grid((nElem + block.x - 1) / block.x);
	printf("> grid (%d, %d) block (%d, %d)\n", grid.x, grid.y, block.x,block.y);

	// sequential operation
	hipEventRecord(start, 0);
	hipMemcpy(d_A, h_A, nBytes, hipMemcpyHostToDevice);
	hipMemcpy(d_B, h_B, nBytes, hipMemcpyHostToDevice);
	hipEventRecord(stop, 0);
	hipEventSynchronize(stop);
	float memcpy_h2d_time;
	hipEventElapsedTime(&memcpy_h2d_time, start, stop);

	hipEventRecord(start, 0);
	sumArrays <<<grid, block >>>(d_A, d_B, d_C, nElem);
	hipEventRecord(stop, 0);
	hipEventSynchronize(stop);

	float kernel_time;
	hipEventElapsedTime(&kernel_time, start, stop);
	hipEventRecord(start, 0);
	hipMemcpy(gpuRef, d_C, nBytes, hipMemcpyDeviceToHost);
	hipEventRecord(stop, 0);
	hipEventSynchronize(stop);
	float memcpy_d2h_time;
	hipEventElapsedTime(&memcpy_d2h_time, start, stop);
	float itotal = kernel_time + memcpy_h2d_time + memcpy_d2h_time;

	printf("\n");
	printf("Measured timings (throughput):\n");
	printf(" Memcpy host to device\t: %f ms (%f GB/s)\n", memcpy_h2d_time, (nBytes * 1e-6) / memcpy_h2d_time);
	printf(" Memcpy device to host\t: %f ms (%f GB/s)\n", memcpy_d2h_time, (nBytes * 1e-6) / memcpy_d2h_time);
	printf(" Kernel\t\t\t: %f ms (%f GB/s)\n", kernel_time, (nBytes * 2e-6) / kernel_time);
	printf(" Total\t\t\t: %f ms (%f GB/s)\n", itotal, (nBytes * 2e-6) / itotal);

	// grid parallel operation
	int iElem = nElem / NSTREAM;
	size_t iBytes = iElem * sizeof(float);
	grid.x = (iElem + block.x - 1) / block.x;

	hipStream_t stream[NSTREAM];

	for (int i = 0; i < NSTREAM; ++i)
	{
		hipStreamCreate(&stream[i]);
	}

	hipEventRecord(start, 0);

	// initiate all work on the device asynchronously in depth-first order
	for (int i = 0; i < NSTREAM; ++i)
	{
		int ioffset = i * iElem;
		hipMemcpyAsync(&d_A[ioffset], &h_A[ioffset], iBytes, hipMemcpyHostToDevice, stream[i]);
		hipMemcpyAsync(&d_B[ioffset], &h_B[ioffset], iBytes, hipMemcpyHostToDevice, stream[i]);
		sumArrays <<<grid, block, 0, stream[i] >>>(&d_A[ioffset], &d_B[ioffset], &d_C[ioffset], iElem);
		hipMemcpyAsync(&gpuRef[ioffset], &d_C[ioffset], iBytes, hipMemcpyDeviceToHost, stream[i]);
	}

	hipEventRecord(stop, 0);
	hipEventSynchronize(stop);
	float execution_time;
	hipEventElapsedTime(&execution_time, start, stop);

	printf("\n");
	printf("Actual results from overlapped data transfers:\n");
	printf(" overlap with %d streams : %f ms (%f GB/s)\n", NSTREAM, execution_time, (nBytes * 2e-6) / execution_time);
	printf(" speedup                : %f \n", ((itotal - execution_time) * 100.0f) / itotal);

	// check kernel error
	hipGetLastError();

	// check device results
	checkResult(hostRef, gpuRef, nElem);

	// free device global memory
	hipFree(d_A);
	hipFree(d_B);
	hipFree(d_C);

	// free host memory
	hipHostFree(h_A);
	hipHostFree(h_B);
	hipHostFree(hostRef);
	hipHostFree(gpuRef);

	// destroy events
	hipEventDestroy(start);
	hipEventDestroy(stop);

	// destroy streams
	for (int i = 0; i < NSTREAM; ++i)
	{
		hipStreamDestroy(stream[i]);
	}

	hipDeviceReset();

	system("Pause");
	return(0);
}
	.text
	.file	"kernel.hip"
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function _Z11initialDataPfi
.LCPI0_0:
	.long	0x41200000                      # float 10
	.text
	.globl	_Z11initialDataPfi
	.type	_Z11initialDataPfi,@function
_Z11initialDataPfi:                     # @_Z11initialDataPfi
	.cfi_startproc
# %bb.0:
	testl	%esi, %esi
	jle	.LBB0_4
# %bb.1:                                # %.lr.ph.preheader
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rdi, %rbx
	movl	%esi, %r14d
	xorl	%r15d, %r15d
.LBB0_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	callq	rand
	movzbl	%al, %eax
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	divss	.LCPI0_0(%rip), %xmm0
	movss	%xmm0, (%rbx,%r15,4)
	incq	%r15
	cmpq	%r15, %r14
	jne	.LBB0_2
# %bb.3:
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	.cfi_restore %rbx
	.cfi_restore %r14
	.cfi_restore %r15
.LBB0_4:                                # %._crit_edge
	retq
.Lfunc_end0:
	.size	_Z11initialDataPfi, .Lfunc_end0-_Z11initialDataPfi
	.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	.LBB1_3
# %bb.1:                                # %.lr.ph.preheader
	movl	%ecx, %eax
	xorl	%ecx, %ecx
.LBB1_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	.LBB1_2
.LBB1_3:                                # %._crit_edge
	retq
.Lfunc_end1:
	.size	_Z15sumArraysOnHostPfS_S_i, .Lfunc_end1-_Z15sumArraysOnHostPfS_S_i
	.cfi_endproc
                                        # -- End function
	.globl	_Z24__device_stub__sumArraysPfS_S_i # -- Begin function _Z24__device_stub__sumArraysPfS_S_i
	.type	_Z24__device_stub__sumArraysPfS_S_i,@function
_Z24__device_stub__sumArraysPfS_S_i:    # @_Z24__device_stub__sumArraysPfS_S_i
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$112, %rsp
	.cfi_def_cfa_offset 160
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	32(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	24(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	4(%rsp), %rdx
	movl	%ecx, (%rdx)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 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	$_Z9sumArraysPfS_S_i, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$128, %rsp
	.cfi_adjust_cfa_offset -128
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end2:
	.size	_Z24__device_stub__sumArraysPfS_S_i, .Lfunc_end2-_Z24__device_stub__sumArraysPfS_S_i
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0                          # -- Begin function _Z11checkResultPfS_i
.LCPI3_0:
	.long	0x7fffffff                      # float NaN
	.long	0x7fffffff                      # float NaN
	.long	0x7fffffff                      # float NaN
	.long	0x7fffffff                      # float NaN
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0
.LCPI3_1:
	.quad	0x3e45798ee2308c3a              # double 1.0E-8
	.text
	.globl	_Z11checkResultPfS_i
	.type	_Z11checkResultPfS_i,@function
_Z11checkResultPfS_i:                   # @_Z11checkResultPfS_i
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	testl	%edx, %edx
	jle	.LBB3_4
# %bb.1:                                # %.lr.ph.preheader
	movq	%rsi, %rbx
	movq	%rdi, %r14
	movl	%edx, %eax
	xorl	%r15d, %r15d
	movaps	.LCPI3_0(%rip), %xmm0           # xmm0 = [NaN,NaN,NaN,NaN]
	movsd	.LCPI3_1(%rip), %xmm1           # xmm1 = mem[0],zero
.LBB3_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movss	(%r14,%r15,4), %xmm2            # xmm2 = mem[0],zero,zero,zero
	subss	(%rbx,%r15,4), %xmm2
	andps	%xmm0, %xmm2
	cvtss2sd	%xmm2, %xmm2
	ucomisd	%xmm1, %xmm2
	ja	.LBB3_5
# %bb.3:                                #   in Loop: Header=BB3_2 Depth=1
	incq	%r15
	cmpq	%r15, %rax
	jne	.LBB3_2
.LBB3_4:                                # %.critedge
	movl	$.Lstr.1, %edi
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	jmp	puts@PLT                        # TAILCALL
.LBB3_5:
	.cfi_def_cfa_offset 32
	movl	$.Lstr, %edi
	callq	puts@PLT
	xorps	%xmm0, %xmm0
	cvtss2sd	(%r14,%r15,4), %xmm0
	xorps	%xmm1, %xmm1
	cvtss2sd	(%rbx,%r15,4), %xmm1
	movl	$.L.str.1, %edi
	movl	%r15d, %esi
	movb	$2, %al
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	jmp	printf                          # TAILCALL
.Lfunc_end3:
	.size	_Z11checkResultPfS_i, .Lfunc_end3-_Z11checkResultPfS_i
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function main
.LCPI4_0:
	.long	0x41200000                      # float 10
.LCPI4_3:
	.long	0x42c80000                      # float 100
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0
.LCPI4_1:
	.quad	0x3fd0c6f7a0b5ed8d              # double 0.26214399999999999
.LCPI4_2:
	.quad	0x3fe0c6f7a0b5ed8d              # double 0.52428799999999998
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
	.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	$1600, %rsp                     # imm = 0x640
	.cfi_def_cfa_offset 1648
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	(%rsi), %rsi
	movl	$.L.str.3, %edi
	xorl	%eax, %eax
	callq	printf
	leaq	128(%rsp), %rbx
	movq	%rbx, %rdi
	xorl	%esi, %esi
	callq	hipGetDevicePropertiesR0600
	movl	$.L.str.4, %edi
	xorl	%esi, %esi
	movq	%rbx, %rdx
	xorl	%eax, %eax
	callq	printf
	xorl	%edi, %edi
	callq	hipSetDevice
	cmpl	$3, 360(%rbx)
	jl	.LBB4_3
# %bb.1:
	jne	.LBB4_4
# %bb.2:
	cmpl	$4, 492(%rsp)
	jg	.LBB4_4
.LBB4_3:                                # %.sink.split
	cmpl	$0, 704(%rsp)
	movl	$.Lstr.4, %eax
	movl	$.Lstr.2, %edi
	cmoveq	%rax, %rdi
	movl	$.Lstr.5, %eax
	movl	$.Lstr.3, %ebx
	cmoveq	%rax, %rbx
	callq	puts@PLT
	movq	%rbx, %rdi
	callq	puts@PLT
.LBB4_4:
	movl	488(%rsp), %esi
	movl	492(%rsp), %edx
	movl	516(%rsp), %ecx
	xorl	%r14d, %r14d
	movl	$.L.str.9, %edi
	xorl	%eax, %eax
	callq	printf
	movl	$.L.str.10, %edi
	movl	$65536, %esi                    # imm = 0x10000
	xorl	%eax, %eax
	callq	printf
	leaq	64(%rsp), %rbx
	movl	$262144, %esi                   # imm = 0x40000
	movq	%rbx, %rdi
	xorl	%edx, %edx
	callq	hipHostAlloc
	leaq	32(%rsp), %rdi
	movl	$262144, %esi                   # imm = 0x40000
	xorl	%edx, %edx
	callq	hipHostAlloc
	leaq	24(%rsp), %rdi
	movl	$262144, %esi                   # imm = 0x40000
	xorl	%edx, %edx
	callq	hipHostAlloc
	leaq	72(%rsp), %rdi
	movl	$262144, %esi                   # imm = 0x40000
	xorl	%edx, %edx
	callq	hipHostAlloc
	movq	(%rbx), %rbx
.LBB4_5:                                # %.lr.ph.i
                                        # =>This Inner Loop Header: Depth=1
	callq	rand
	movss	.LCPI4_0(%rip), %xmm1           # xmm1 = mem[0],zero,zero,zero
	movzbl	%al, %eax
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	divss	%xmm1, %xmm0
	movss	%xmm0, (%rbx,%r14,4)
	incq	%r14
	cmpq	$65536, %r14                    # imm = 0x10000
	jne	.LBB4_5
# %bb.6:                                # %_Z11initialDataPfi.exit
	movq	32(%rsp), %rbx
	xorl	%r14d, %r14d
.LBB4_7:                                # %.lr.ph.i88
                                        # =>This Inner Loop Header: Depth=1
	callq	rand
	movzbl	%al, %eax
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	divss	.LCPI4_0(%rip), %xmm0
	movss	%xmm0, (%rbx,%r14,4)
	incq	%r14
	cmpq	$65536, %r14                    # imm = 0x10000
	jne	.LBB4_7
# %bb.8:                                # %_Z11initialDataPfi.exit92
	movq	72(%rsp), %rbx
	xorl	%r14d, %r14d
	movl	$262144, %edx                   # imm = 0x40000
	movq	%rbx, %rdi
	xorl	%esi, %esi
	callq	memset@PLT
	movq	24(%rsp), %rdi
	movl	$262144, %edx                   # imm = 0x40000
	xorl	%esi, %esi
	callq	memset@PLT
	movq	64(%rsp), %rax
	movq	32(%rsp), %rcx
.LBB4_9:                                # %.lr.ph.i93
                                        # =>This Inner Loop Header: Depth=1
	movss	(%rax,%r14,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	addss	(%rcx,%r14,4), %xmm0
	movss	%xmm0, (%rbx,%r14,4)
	incq	%r14
	cmpq	$65536, %r14                    # imm = 0x10000
	jne	.LBB4_9
# %bb.10:                               # %_Z15sumArraysOnHostPfS_S_i.exit
	movabsq	$4294967424, %rbx               # imm = 0x100000080
	leaq	56(%rsp), %r13
	movl	$262144, %esi                   # imm = 0x40000
	movq	%r13, %rdi
	callq	hipMalloc
	leaq	48(%rsp), %r12
	movl	$262144, %esi                   # imm = 0x40000
	movq	%r12, %rdi
	callq	hipMalloc
	leaq	16(%rsp), %rdi
	movl	$262144, %esi                   # imm = 0x40000
	callq	hipMalloc
	leaq	8(%rsp), %r14
	movq	%r14, %rdi
	callq	hipEventCreate
	movq	%rsp, %r15
	movq	%r15, %rdi
	callq	hipEventCreate
	movl	$.L.str.11, %edi
	movl	$512, %esi                      # imm = 0x200
	movl	$1, %edx
	movl	$128, %ecx
	movl	$1, %r8d
	xorl	%eax, %eax
	callq	printf
	movq	(%r14), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	(%r13), %rdi
	movq	64(%rsp), %rsi
	movl	$262144, %edx                   # imm = 0x40000
	movl	$1, %ecx
	callq	hipMemcpy
	movq	(%r12), %rdi
	movq	32(%rsp), %rsi
	movl	$262144, %edx                   # imm = 0x40000
	movl	$1, %ecx
	callq	hipMemcpy
	movq	(%r15), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	(%r15), %rdi
	callq	hipEventSynchronize
	movq	(%r14), %rsi
	movq	(%r15), %rdx
	leaq	44(%rsp), %rdi
	callq	hipEventElapsedTime
	movq	(%r14), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	leaq	384(%rbx), %rdi
	movl	$1, %esi
	movq	%rbx, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB4_12
# %bb.11:
	movq	56(%rsp), %rdi
	movq	48(%rsp), %rsi
	movq	16(%rsp), %rdx
	movl	$65536, %ecx                    # imm = 0x10000
	callq	_Z24__device_stub__sumArraysPfS_S_i
.LBB4_12:
	movq	(%rsp), %rdi
	xorl	%r12d, %r12d
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	(%rsp), %rdi
	callq	hipEventSynchronize
	movq	8(%rsp), %rsi
	movq	(%rsp), %rdx
	leaq	92(%rsp), %r14
	movq	%r14, %rdi
	callq	hipEventElapsedTime
	movq	8(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	24(%rsp), %rdi
	movq	16(%rsp), %rsi
	movl	$262144, %edx                   # imm = 0x40000
	movl	$2, %ecx
	callq	hipMemcpy
	movq	(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	(%rsp), %rdi
	callq	hipEventSynchronize
	movq	8(%rsp), %rsi
	movq	(%rsp), %rdx
	leaq	88(%rsp), %r15
	movq	%r15, %rdi
	callq	hipEventElapsedTime
	movss	(%r14), %xmm0                   # xmm0 = mem[0],zero,zero,zero
	addss	44(%rsp), %xmm0
	addss	(%r15), %xmm0
	movss	%xmm0, 40(%rsp)                 # 4-byte Spill
	movl	$10, %edi
	callq	putchar@PLT
	movl	$.Lstr.6, %edi
	callq	puts@PLT
	xorps	%xmm0, %xmm0
	cvtss2sd	44(%rsp), %xmm0
	movsd	.LCPI4_1(%rip), %xmm1           # xmm1 = mem[0],zero
	divsd	%xmm0, %xmm1
	movl	$.L.str.14, %edi
	movb	$2, %al
	callq	printf
	xorps	%xmm0, %xmm0
	cvtss2sd	(%r15), %xmm0
	movsd	.LCPI4_1(%rip), %xmm1           # xmm1 = mem[0],zero
	divsd	%xmm0, %xmm1
	movl	$.L.str.15, %edi
	movb	$2, %al
	callq	printf
	xorps	%xmm0, %xmm0
	cvtss2sd	(%r14), %xmm0
	movsd	.LCPI4_2(%rip), %xmm1           # xmm1 = mem[0],zero
	divsd	%xmm0, %xmm1
	movl	$.L.str.16, %edi
	movb	$2, %al
	callq	printf
	xorps	%xmm0, %xmm0
	cvtss2sd	40(%rsp), %xmm0                 # 4-byte Folded Reload
	movsd	.LCPI4_2(%rip), %xmm1           # xmm1 = mem[0],zero
	divsd	%xmm0, %xmm1
	movl	$.L.str.17, %edi
	movb	$2, %al
	callq	printf
.LBB4_13:                               # =>This Inner Loop Header: Depth=1
	leaq	(%rsp,%r12), %rdi
	addq	$96, %rdi
	callq	hipStreamCreate
	addq	$8, %r12
	cmpq	$32, %r12
	jne	.LBB4_13
# %bb.14:
	movq	8(%rsp), %rdi
	xorl	%r14d, %r14d
	xorl	%esi, %esi
	callq	hipEventRecord
	leaq	96(%rsp), %r15
.LBB4_15:                               # =>This Inner Loop Header: Depth=1
	movq	56(%rsp), %rdi
	addq	%r14, %rdi
	movq	64(%rsp), %rsi
	addq	%r14, %rsi
	movq	(%r15), %r8
	movl	$65536, %edx                    # imm = 0x10000
	movl	$1, %ecx
	callq	hipMemcpyAsync
	movq	48(%rsp), %rdi
	addq	%r14, %rdi
	movq	32(%rsp), %rsi
	addq	%r14, %rsi
	movq	(%r15), %r8
	movl	$65536, %edx                    # imm = 0x10000
	movl	$1, %ecx
	callq	hipMemcpyAsync
	movq	(%r15), %r9
	movq	%rbx, %rdi
	movl	$1, %esi
	movq	%rbx, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB4_17
# %bb.16:                               #   in Loop: Header=BB4_15 Depth=1
	movq	56(%rsp), %rdi
	addq	%r14, %rdi
	movq	48(%rsp), %rsi
	addq	%r14, %rsi
	movq	16(%rsp), %rdx
	addq	%r14, %rdx
	movl	$16384, %ecx                    # imm = 0x4000
	callq	_Z24__device_stub__sumArraysPfS_S_i
.LBB4_17:                               #   in Loop: Header=BB4_15 Depth=1
	movq	24(%rsp), %rdi
	addq	%r14, %rdi
	movq	16(%rsp), %rsi
	addq	%r14, %rsi
	movq	(%r15), %r8
	movl	$65536, %edx                    # imm = 0x10000
	movl	$2, %ecx
	callq	hipMemcpyAsync
	addq	$65536, %r14                    # imm = 0x10000
	addq	$8, %r15
	cmpq	$262144, %r14                   # imm = 0x40000
	jne	.LBB4_15
# %bb.18:
	movq	(%rsp), %rdi
	xorl	%r14d, %r14d
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	(%rsp), %rdi
	callq	hipEventSynchronize
	movq	8(%rsp), %rsi
	movq	(%rsp), %rdx
	leaq	84(%rsp), %rbx
	movq	%rbx, %rdi
	callq	hipEventElapsedTime
	movl	$10, %edi
	callq	putchar@PLT
	movl	$.Lstr.7, %edi
	callq	puts@PLT
	cvtss2sd	(%rbx), %xmm0
	movsd	.LCPI4_2(%rip), %xmm1           # xmm1 = mem[0],zero
	divsd	%xmm0, %xmm1
	movl	$.L.str.19, %edi
	movl	$4, %esi
	movb	$2, %al
	callq	printf
	movss	40(%rsp), %xmm1                 # 4-byte Reload
                                        # xmm1 = mem[0],zero,zero,zero
	movaps	%xmm1, %xmm0
	subss	(%rbx), %xmm0
	mulss	.LCPI4_3(%rip), %xmm0
	divss	%xmm1, %xmm0
	cvtss2sd	%xmm0, %xmm0
	movl	$.L.str.20, %edi
	movb	$1, %al
	callq	printf
	callq	hipGetLastError
	movq	72(%rsp), %rdi
	movq	24(%rsp), %rsi
	movl	$65536, %edx                    # imm = 0x10000
	callq	_Z11checkResultPfS_i
	movq	56(%rsp), %rdi
	callq	hipFree
	movq	48(%rsp), %rdi
	callq	hipFree
	movq	16(%rsp), %rdi
	callq	hipFree
	movq	64(%rsp), %rdi
	callq	hipHostFree
	movq	32(%rsp), %rdi
	callq	hipHostFree
	movq	72(%rsp), %rdi
	callq	hipHostFree
	movq	24(%rsp), %rdi
	callq	hipHostFree
	movq	8(%rsp), %rdi
	callq	hipEventDestroy
	movq	(%rsp), %rdi
	callq	hipEventDestroy
.LBB4_19:                               # =>This Inner Loop Header: Depth=1
	movq	96(%rsp,%r14,8), %rdi
	callq	hipStreamDestroy
	incq	%r14
	cmpq	$4, %r14
	jne	.LBB4_19
# %bb.20:
	callq	hipDeviceReset
	movl	$.L.str.21, %edi
	callq	system
	xorl	%eax, %eax
	addq	$1600, %rsp                     # imm = 0x640
	.cfi_def_cfa_offset 48
	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	main, .Lfunc_end4-main
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	jne	.LBB5_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB5_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z9sumArraysPfS_S_i, %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_end5:
	.size	__hip_module_ctor, .Lfunc_end5-__hip_module_ctor
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_dtor
	.type	__hip_module_dtor,@function
__hip_module_dtor:                      # @__hip_module_dtor
	.cfi_startproc
# %bb.0:
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	je	.LBB6_2
# %bb.1:
	pushq	%rax
	.cfi_def_cfa_offset 16
	callq	__hipUnregisterFatBinary
	movq	$0, __hip_gpubin_handle(%rip)
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
.LBB6_2:
	retq
.Lfunc_end6:
	.size	__hip_module_dtor, .Lfunc_end6-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	_Z9sumArraysPfS_S_i,@object     # @_Z9sumArraysPfS_S_i
	.section	.rodata,"a",@progbits
	.globl	_Z9sumArraysPfS_S_i
	.p2align	3, 0x0
_Z9sumArraysPfS_S_i:
	.quad	_Z24__device_stub__sumArraysPfS_S_i
	.size	_Z9sumArraysPfS_S_i, 8

	.type	.L.str.1,@object                # @.str.1
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.1:
	.asciz	"host %5.2f gpu %5.2f at %d\n"
	.size	.L.str.1, 28

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"> %s Starting...\n"
	.size	.L.str.3, 18

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"> Using Device %d: %s\n"
	.size	.L.str.4, 23

	.type	.L.str.9,@object                # @.str.9
.L.str.9:
	.asciz	"> Compute Capability %d.%d hardware with %d multi-processors\n"
	.size	.L.str.9, 62

	.type	.L.str.10,@object               # @.str.10
.L.str.10:
	.asciz	"> vector size = %d\n"
	.size	.L.str.10, 20

	.type	.L.str.11,@object               # @.str.11
.L.str.11:
	.asciz	"> grid (%d, %d) block (%d, %d)\n"
	.size	.L.str.11, 32

	.type	.L.str.14,@object               # @.str.14
.L.str.14:
	.asciz	" Memcpy host to device\t: %f ms (%f GB/s)\n"
	.size	.L.str.14, 42

	.type	.L.str.15,@object               # @.str.15
.L.str.15:
	.asciz	" Memcpy device to host\t: %f ms (%f GB/s)\n"
	.size	.L.str.15, 42

	.type	.L.str.16,@object               # @.str.16
.L.str.16:
	.asciz	" Kernel\t\t\t: %f ms (%f GB/s)\n"
	.size	.L.str.16, 29

	.type	.L.str.17,@object               # @.str.17
.L.str.17:
	.asciz	" Total\t\t\t: %f ms (%f GB/s)\n"
	.size	.L.str.17, 28

	.type	.L.str.19,@object               # @.str.19
.L.str.19:
	.asciz	" overlap with %d streams : %f ms (%f GB/s)\n"
	.size	.L.str.19, 44

	.type	.L.str.20,@object               # @.str.20
.L.str.20:
	.asciz	" speedup                : %f \n"
	.size	.L.str.20, 31

	.type	.L.str.21,@object               # @.str.21
.L.str.21:
	.asciz	"Pause"
	.size	.L.str.21, 6

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z9sumArraysPfS_S_i"
	.size	.L__unnamed_1, 20

	.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	"Arrays do not match!"
	.size	.Lstr, 21

	.type	.Lstr.1,@object                 # @str.1
.Lstr.1:
	.asciz	"Arrays match.\n"
	.size	.Lstr.1, 15

	.type	.Lstr.2,@object                 # @str.2
.Lstr.2:
	.asciz	"> GPU does not support HyperQ"
	.size	.Lstr.2, 30

	.type	.Lstr.3,@object                 # @str.3
.Lstr.3:
	.asciz	"> CUDA kernel runs will have limited concurrency"
	.size	.Lstr.3, 49

	.type	.Lstr.4,@object                 # @str.4
.Lstr.4:
	.asciz	"> GPU does not support concurrent kernel execution (SM 3.5 or higher required)"
	.size	.Lstr.4, 79

	.type	.Lstr.5,@object                 # @str.5
.Lstr.5:
	.asciz	"> CUDA kernel runs will be serialized"
	.size	.Lstr.5, 38

	.type	.Lstr.6,@object                 # @str.6
.Lstr.6:
	.asciz	"Measured timings (throughput):"
	.size	.Lstr.6, 31

	.type	.Lstr.7,@object                 # @str.7
.Lstr.7:
	.asciz	"Actual results from overlapped data transfers:"
	.size	.Lstr.7, 47

	.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 _Z24__device_stub__sumArraysPfS_S_i
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z9sumArraysPfS_S_i
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z9sumArraysPfS_S_i     ; -- Begin function _Z9sumArraysPfS_S_i
	.globl	_Z9sumArraysPfS_S_i
	.p2align	8
	.type	_Z9sumArraysPfS_S_i,@function
_Z9sumArraysPfS_S_i:                    ; @_Z9sumArraysPfS_S_i
; %bb.0:
	s_clause 0x1
	s_load_b32 s3, s[0:1], 0x2c
	s_load_b32 s2, s[0:1], 0x18
	s_waitcnt lgkmcnt(0)
	s_and_b32 s3, s3, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s15, s3, v[0:1]
	s_mov_b32 s3, exec_lo
	v_max_i32_e32 v0, 0, v1
	s_delay_alu instid0(VALU_DEP_1)
	v_cmpx_gt_i32_e64 s2, v0
	s_cbranch_execz .LBB0_3
; %bb.1:                                ; %.lr.ph
	s_clause 0x1
	s_load_b128 s[4:7], s[0:1], 0x0
	s_load_b64 s[0:1], s[0:1], 0x10
	v_ashrrev_i32_e32 v2, 31, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[4:5], 2, v[1:2]
	s_waitcnt lgkmcnt(0)
	v_add_co_u32 v0, vcc_lo, s4, v4
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v1, vcc_lo, s5, v5, vcc_lo
	v_add_co_u32 v2, vcc_lo, s6, v4
	v_add_co_ci_u32_e32 v3, vcc_lo, s7, v5, vcc_lo
	v_add_co_u32 v4, vcc_lo, s0, v4
	v_add_co_ci_u32_e32 v5, vcc_lo, s1, v5, vcc_lo
.LBB0_2:                                ; =>This Inner Loop Header: Depth=1
	global_load_b32 v6, v[0:1], off
	global_load_b32 v7, v[2:3], off
	s_add_i32 s2, s2, -1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_cmp_lg_u32 s2, 0
	s_waitcnt vmcnt(0)
	v_add_f32_e32 v6, v6, v7
	global_store_b32 v[4:5], v6, off
	s_cbranch_scc1 .LBB0_2
.LBB0_3:                                ; %.loopexit
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z9sumArraysPfS_S_i
		.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 8
		.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	_Z9sumArraysPfS_S_i, .Lfunc_end0-_Z9sumArraysPfS_S_i
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 208
; NumSgprs: 18
; NumVgprs: 8
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 8
; 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
      - .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:           _Z9sumArraysPfS_S_i
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z9sumArraysPfS_S_i.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     8
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
