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

__global__ void sumArraysZeroCopy(float *A,float *B,float *C,const int N){
    int i = blockIdx.x * blockDim.x + threadIdx.x;
    if (i<N) C[i] = A[i] + B[i];
    }

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 sumArraysOnGPU(float *A,float *B,float *C,const int N){
    int i = blockIdx.x * blockDim.x + threadIdx.x;
    if (i<N) C[i] = A[i] + B[i];
    }

void checkResult(float *hostRef, float *gpuRef, const int N){
    double epsilon = 1.0e-8;
    for (int i=0; i < N; i++){
        if(abs(hostRef[i]-gpuRef[i])>epsilon){
            printf("Arrays do not match!\n");
            printf("host %5.2f gpu %5.2f at current %d\n",hostRef[i],gpuRef[i],i);
            break;
            }
        }
    return;
    }

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

int main(int argc,char **argv){
    
    // part 0: set up device and array
    // set up device
    int dev = 0;
    cudaSetDevice(dev);
    
    // get device properties
    cudaDeviceProp deviceProp;
    cudaGetDeviceProperties(&deviceProp,dev);
    
    // check if support mapped memory
    if (!deviceProp.canMapHostMemory){
        printf("Device %d does not support mapping CPU host memory!\n",dev);
        cudaDeviceReset();
        exit(EXIT_SUCCESS);
        }
    printf("Using Device %d: %s ",dev,deviceProp.name);
    
    // set up date size of vectors
    int ipower = 10;
    
    if (argc > 1) ipower = atoi(argv[1]);
    int nElem = 1 << ipower;
    
    size_t nBytes = nElem * sizeof(float);
    if (ipower < 18){
        printf("Vector size %d power %d nbytes %3.0f KB\n",nElem,
            ipower,(float)nBytes/(1024.0f));
    }else{
        printf("Vector size %d power %d nbytes %3.0f MB\n",nElem,
            ipower,(float)nBytes/(1024.0f));
    }
    
    // part 1: using device memory
    // malloc host memory
    float *h_A,*h_B,*hostRef,*gpuRef;
    h_A = (float *)malloc(nBytes);
    h_B = (float *)malloc(nBytes);
    hostRef = (float *)malloc(nBytes);
    gpuRef  = (float *)malloc(nBytes);

    // 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);
    
    // transfer data from host to device
    cudaMemcpy(d_A,h_A,nBytes,cudaMemcpyHostToDevice);
    cudaMemcpy(d_B,h_B,nBytes,cudaMemcpyHostToDevice);
    
    // set up execution configuration
    int iLen = 512;
    dim3 block(iLen);
    dim3 grid((nElem+block.x-1)/block.x);
    
    // invoke kernel at host side
    sumArraysOnGPU<<<grid,block>>>(d_A,d_B,d_C,nElem);
    
    // copy kernel result back to host side
    cudaMemcpy(gpuRef,d_C,nBytes,cudaMemcpyDeviceToHost);
    
    // free device global memory
    cudaFree(d_A);
    cudaFree(d_B);
    free(h_A);
    free(h_B);
    
    // part 2: using zerocopy memory for array A and B
    // allocate zerocpy memory
    unsigned int flags = cudaHostAllocMapped;
    cudaHostAlloc((void **)&h_A,nBytes,flags);
    cudaHostAlloc((void **)&h_B,nBytes,flags);
     
    // initialize data at host side
    initialData(h_A,nElem);
    initialData(h_B,nElem);
    memset(hostRef,0,nBytes);
    memset(gpuRef,0,nBytes);
    
    // pass the pointer to device
    cudaHostGetDevicePointer((void **)&d_A,(void *)h_A,0);
    cudaHostGetDevicePointer((void **)&d_B,(void *)h_B,0);
    
    // add at host side for result checks
    sumArraysOnHost(h_A,h_B,hostRef,nElem);
    
    // execute kernel with zero copy memory
    sumArraysZeroCopy<<<grid,block>>>(d_A,d_B,d_C,nElem);
    
    // copy kernel result back to host side
    cudaMemcpy(gpuRef,d_C,nBytes,cudaMemcpyDeviceToHost);
    
    // check device results
    checkResult(hostRef,gpuRef,nElem);
    
    // free memory
    cudaFree(d_C);
    cudaFreeHost(h_A);
    cudaFreeHost(h_B);
        
    free(hostRef);
    free(gpuRef);
     
    // reset device
    cudaDeviceReset();
    return EXIT_SUCCESS;
    }
    
    
    

	.file	"tmpxft_002d3243_00000000-6_sumArrayZerocopy.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	_Z15sumArraysOnHostPfS_S_i
	.type	_Z15sumArraysOnHostPfS_S_i, @function
_Z15sumArraysOnHostPfS_S_i:
.LFB2027:
	.cfi_startproc
	endbr64
	xorl	%eax, %eax
.L3:
	cmpl	%eax, %ecx
	jle	.L6
	movss	(%rdi,%rax,4), %xmm0
	addss	(%rsi,%rax,4), %xmm0
	movss	%xmm0, (%rdx,%rax,4)
	incq	%rax
	jmp	.L3
.L6:
	ret
	.cfi_endproc
.LFE2027:
	.size	_Z15sumArraysOnHostPfS_S_i, .-_Z15sumArraysOnHostPfS_S_i
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC2:
	.string	"Arrays do not match!\n"
.LC3:
	.string	"host %5.2f gpu %5.2f at current %d\n"
	.text
	.globl	_Z11checkResultPfS_i
	.type	_Z11checkResultPfS_i, @function
_Z11checkResultPfS_i:
.LFB2028:
	.cfi_startproc
	endbr64
	movsd	.LC1(%rip), %xmm2
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movss	.LC0(%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
.L8:
	cmpl	%edx, %ebx
	jge	.L15
	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	.L13
	leaq	.LC2(%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	.LC3(%rip), %rsi
	popq	%r12
	.cfi_def_cfa_offset 8
	jmp	__printf_chk@PLT
.L13:
	.cfi_restore_state
	incl	%ebx
	jmp	.L8
.L15:
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2028:
	.size	_Z11checkResultPfS_i, .-_Z11checkResultPfS_i
	.globl	_Z11initialDataPfi
	.type	_Z11initialDataPfi, @function
_Z11initialDataPfi:
.LFB2029:
	.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
.L17:
	cmpl	%ebx, %ebp
	jle	.L20
	call	rand@PLT
	movzbl	%al, %eax
	cvtsi2ssl	%eax, %xmm0
	divss	.LC4(%rip), %xmm0
	movss	%xmm0, (%r12,%rbx,4)
	incq	%rbx
	jmp	.L17
.L20:
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2029:
	.size	_Z11initialDataPfi, .-_Z11initialDataPfi
	.globl	_Z42__device_stub__Z17sumArraysZeroCopyPfS_S_iPfS_S_i
	.type	_Z42__device_stub__Z17sumArraysZeroCopyPfS_S_iPfS_S_i, @function
_Z42__device_stub__Z17sumArraysZeroCopyPfS_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	_Z17sumArraysZeroCopyPfS_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	_Z42__device_stub__Z17sumArraysZeroCopyPfS_S_iPfS_S_i, .-_Z42__device_stub__Z17sumArraysZeroCopyPfS_S_iPfS_S_i
	.globl	_Z17sumArraysZeroCopyPfS_S_i
	.type	_Z17sumArraysZeroCopyPfS_S_i, @function
_Z17sumArraysZeroCopyPfS_S_i:
.LFB2056:
	.cfi_startproc
	endbr64
	jmp	_Z42__device_stub__Z17sumArraysZeroCopyPfS_S_iPfS_S_i
	.cfi_endproc
.LFE2056:
	.size	_Z17sumArraysZeroCopyPfS_S_i, .-_Z17sumArraysZeroCopyPfS_S_i
	.globl	_Z39__device_stub__Z14sumArraysOnGPUPfS_S_iPfS_S_i
	.type	_Z39__device_stub__Z14sumArraysOnGPUPfS_S_iPfS_S_i, @function
_Z39__device_stub__Z14sumArraysOnGPUPfS_S_iPfS_S_i:
.LFB2057:
	.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	.L26
	pushq	48(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z14sumArraysOnGPUPfS_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
.L26:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L28
	call	__stack_chk_fail@PLT
.L28:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2057:
	.size	_Z39__device_stub__Z14sumArraysOnGPUPfS_S_iPfS_S_i, .-_Z39__device_stub__Z14sumArraysOnGPUPfS_S_iPfS_S_i
	.globl	_Z14sumArraysOnGPUPfS_S_i
	.type	_Z14sumArraysOnGPUPfS_S_i, @function
_Z14sumArraysOnGPUPfS_S_i:
.LFB2058:
	.cfi_startproc
	endbr64
	jmp	_Z39__device_stub__Z14sumArraysOnGPUPfS_S_iPfS_S_i
	.cfi_endproc
.LFE2058:
	.size	_Z14sumArraysOnGPUPfS_S_i, .-_Z14sumArraysOnGPUPfS_S_i
	.section	.rodata.str1.1
.LC5:
	.string	"Device %d does not support mapping CPU host memory!\n"
.LC6:
	.string	"Using Device %d: %s "
.LC8:
	.string	"Vector size %d power %d nbytes %3.0f KB\n"
.LC9:
	.string	"Vector size %d power %d nbytes %3.0f MB\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2030:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movl	%edi, %ebp
	xorl	%edi, %edi
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	%rsi, %rbx
	subq	$1112, %rsp
	.cfi_def_cfa_offset 1168
	movq	%fs:40, %rax
	movq	%rax, 1096(%rsp)
	xorl	%eax, %eax
	leaq	64(%rsp), %r12
	call	cudaSetDevice@PLT
	xorl	%esi, %esi
	movq	%r12, %rdi
	call	cudaGetDeviceProperties_v2@PLT
	cmpl	$0, 464(%rsp)
	jne	.L32
	movl	$2, %edi
	xorl	%edx, %edx
	leaq	.LC5(%rip), %rsi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	call	cudaDeviceReset@PLT
	xorl	%edi, %edi
	call	exit@PLT
.L32:
	movq	%r12, %rcx
	xorl	%edx, %edx
	xorl	%eax, %eax
	movl	$2, %edi
	leaq	.LC6(%rip), %rsi
	call	__printf_chk@PLT
	decl	%ebp
	movl	$10, %ecx
	jle	.L33
	movq	8(%rbx), %rdi
	call	atoi@PLT
	movl	%eax, %ecx
.L33:
	movl	$1, %ebp
	movss	.LC7(%rip), %xmm1
	sall	%cl, %ebp
	movslq	%ebp, %rbx
	salq	$2, %rbx
	cmpl	$17, %ecx
	jg	.L34
	cvtsi2ssq	%rbx, %xmm0
	movl	%ebp, %edx
	leaq	.LC8(%rip), %rsi
	mulss	%xmm1, %xmm0
	cvtss2sd	%xmm0, %xmm0
	jmp	.L43
.L34:
	testq	%rbx, %rbx
	js	.L36
	cvtsi2ssq	%rbx, %xmm0
	jmp	.L37
.L36:
	movq	%rbx, %rax
	shrq	%rax
	cvtsi2ssq	%rax, %xmm0
	addss	%xmm0, %xmm0
.L37:
	mulss	%xmm1, %xmm0
	movl	%ebp, %edx
	leaq	.LC9(%rip), %rsi
	cvtss2sd	%xmm0, %xmm0
.L43:
	movl	$2, %edi
	movb	$1, %al
	leaq	16(%rsp), %r15
	call	__printf_chk@PLT
	movq	%rbx, %rdi
	call	malloc@PLT
	movq	%rbx, %rdi
	movq	%rax, %r14
	movq	%rax, (%rsp)
	call	malloc@PLT
	movq	%rbx, %rdi
	movq	%rax, 8(%rsp)
	call	malloc@PLT
	movq	%rbx, %rdi
	movq	%rax, %r13
	call	malloc@PLT
	movq	%r14, %rdi
	movl	%ebp, %esi
	leaq	24(%rsp), %r14
	movq	%rax, %r12
	call	_Z11initialDataPfi
	movq	8(%rsp), %rdi
	movl	%ebp, %esi
	call	_Z11initialDataPfi
	xorl	%esi, %esi
	movq	%rbx, %rcx
	movq	%rbx, %rdx
	movq	%r13, %rdi
	call	__memset_chk@PLT
	xorl	%esi, %esi
	movq	%rbx, %rcx
	movq	%rbx, %rdx
	movq	%r12, %rdi
	call	__memset_chk@PLT
	movq	8(%rsp), %rsi
	movq	(%rsp), %rdi
	movl	%ebp, %ecx
	movq	%r13, %rdx
	call	_Z15sumArraysOnHostPfS_S_i
	movq	%rbx, %rsi
	movq	%r15, %rdi
	call	cudaMalloc@PLT
	movq	%rbx, %rsi
	movq	%r14, %rdi
	call	cudaMalloc@PLT
	leaq	32(%rsp), %rdi
	movq	%rbx, %rsi
	call	cudaMalloc@PLT
	movq	(%rsp), %rsi
	movq	16(%rsp), %rdi
	movq	%rbx, %rdx
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movq	8(%rsp), %rsi
	movq	24(%rsp), %rdi
	movq	%rbx, %rdx
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movl	$8388609, %edx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	leal	511(%rbp), %eax
	salq	$9, %rdx
	movl	$1, %ecx
	movl	$1, 48(%rsp)
	shrl	$9, %eax
	movq	%rdx, 40(%rsp)
	movl	%eax, 52(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 56(%rsp)
	movq	52(%rsp), %rdi
	movl	60(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L38
	movq	32(%rsp), %rdx
	movq	24(%rsp), %rsi
	movl	%ebp, %ecx
	movq	16(%rsp), %rdi
	call	_Z39__device_stub__Z14sumArraysOnGPUPfS_S_iPfS_S_i
.L38:
	movq	32(%rsp), %rsi
	movl	$2, %ecx
	movq	%rbx, %rdx
	movq	%r12, %rdi
	call	cudaMemcpy@PLT
	movq	16(%rsp), %rdi
	call	cudaFree@PLT
	movq	24(%rsp), %rdi
	call	cudaFree@PLT
	movq	(%rsp), %rdi
	call	free@PLT
	movq	8(%rsp), %rdi
	call	free@PLT
	movq	%rsp, %rdi
	movl	$2, %edx
	movq	%rbx, %rsi
	call	cudaHostAlloc@PLT
	movl	$2, %edx
	leaq	8(%rsp), %rdi
	movq	%rbx, %rsi
	call	cudaHostAlloc@PLT
	movq	(%rsp), %rdi
	movl	%ebp, %esi
	call	_Z11initialDataPfi
	movq	8(%rsp), %rdi
	movl	%ebp, %esi
	call	_Z11initialDataPfi
	xorl	%esi, %esi
	movq	%rbx, %rcx
	movq	%rbx, %rdx
	movq	%r13, %rdi
	call	__memset_chk@PLT
	movq	%rbx, %rcx
	xorl	%esi, %esi
	movq	%rbx, %rdx
	movq	%r12, %rdi
	call	__memset_chk@PLT
	movq	(%rsp), %rsi
	xorl	%edx, %edx
	movq	%r15, %rdi
	call	cudaHostGetDevicePointer@PLT
	movq	8(%rsp), %rsi
	xorl	%edx, %edx
	movq	%r14, %rdi
	call	cudaHostGetDevicePointer@PLT
	movq	8(%rsp), %rsi
	movq	(%rsp), %rdi
	movl	%ebp, %ecx
	movq	%r13, %rdx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	call	_Z15sumArraysOnHostPfS_S_i
	movl	48(%rsp), %ecx
	movq	40(%rsp), %rdx
	movq	52(%rsp), %rdi
	movl	60(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L39
	movq	32(%rsp), %rdx
	movq	24(%rsp), %rsi
	movl	%ebp, %ecx
	movq	16(%rsp), %rdi
	call	_Z42__device_stub__Z17sumArraysZeroCopyPfS_S_iPfS_S_i
.L39:
	movq	32(%rsp), %rsi
	movl	$2, %ecx
	movq	%rbx, %rdx
	movq	%r12, %rdi
	call	cudaMemcpy@PLT
	movl	%ebp, %edx
	movq	%r12, %rsi
	movq	%r13, %rdi
	call	_Z11checkResultPfS_i
	movq	32(%rsp), %rdi
	call	cudaFree@PLT
	movq	(%rsp), %rdi
	call	cudaFreeHost@PLT
	movq	8(%rsp), %rdi
	call	cudaFreeHost@PLT
	movq	%r13, %rdi
	call	free@PLT
	movq	%r12, %rdi
	call	free@PLT
	call	cudaDeviceReset@PLT
	movq	1096(%rsp), %rax
	subq	%fs:40, %rax
	je	.L40
	call	__stack_chk_fail@PLT
.L40:
	addq	$1112, %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
.LFE2030:
	.size	main, .-main
	.section	.rodata.str1.1
.LC10:
	.string	"_Z14sumArraysOnGPUPfS_S_i"
.LC11:
	.string	"_Z17sumArraysZeroCopyPfS_S_i"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2060:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -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	.LC10(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z14sumArraysOnGPUPfS_S_i(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 48
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r9d, %r9d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC11(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z17sumArraysZeroCopyPfS_S_i(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 40
	pushq	$0
	.cfi_def_cfa_offset 48
	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	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE2060:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC0:
	.long	2147483647
	.long	0
	.long	0
	.long	0
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC1:
	.long	-500134854
	.long	1044740494
	.section	.rodata.cst4,"aM",@progbits,4
	.align 4
.LC4:
	.long	1092616192
	.align 4
.LC7:
	.long	981467136
	.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>

__global__ void sumArraysZeroCopy(float *A,float *B,float *C,const int N){
    int i = blockIdx.x * blockDim.x + threadIdx.x;
    if (i<N) C[i] = A[i] + B[i];
    }

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 sumArraysOnGPU(float *A,float *B,float *C,const int N){
    int i = blockIdx.x * blockDim.x + threadIdx.x;
    if (i<N) C[i] = A[i] + B[i];
    }

void checkResult(float *hostRef, float *gpuRef, const int N){
    double epsilon = 1.0e-8;
    for (int i=0; i < N; i++){
        if(abs(hostRef[i]-gpuRef[i])>epsilon){
            printf("Arrays do not match!\n");
            printf("host %5.2f gpu %5.2f at current %d\n",hostRef[i],gpuRef[i],i);
            break;
            }
        }
    return;
    }

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

int main(int argc,char **argv){
    
    // part 0: set up device and array
    // set up device
    int dev = 0;
    hipSetDevice(dev);
    
    // get device properties
    hipDeviceProp_t deviceProp;
    hipGetDeviceProperties(&deviceProp,dev);
    
    // check if support mapped memory
    if (!deviceProp.canMapHostMemory){
        printf("Device %d does not support mapping CPU host memory!\n",dev);
        hipDeviceReset();
        exit(EXIT_SUCCESS);
        }
    printf("Using Device %d: %s ",dev,deviceProp.name);
    
    // set up date size of vectors
    int ipower = 10;
    
    if (argc > 1) ipower = atoi(argv[1]);
    int nElem = 1 << ipower;
    
    size_t nBytes = nElem * sizeof(float);
    if (ipower < 18){
        printf("Vector size %d power %d nbytes %3.0f KB\n",nElem,
            ipower,(float)nBytes/(1024.0f));
    }else{
        printf("Vector size %d power %d nbytes %3.0f MB\n",nElem,
            ipower,(float)nBytes/(1024.0f));
    }
    
    // part 1: using device memory
    // malloc host memory
    float *h_A,*h_B,*hostRef,*gpuRef;
    h_A = (float *)malloc(nBytes);
    h_B = (float *)malloc(nBytes);
    hostRef = (float *)malloc(nBytes);
    gpuRef  = (float *)malloc(nBytes);

    // 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);
    
    // transfer data from host to device
    hipMemcpy(d_A,h_A,nBytes,hipMemcpyHostToDevice);
    hipMemcpy(d_B,h_B,nBytes,hipMemcpyHostToDevice);
    
    // set up execution configuration
    int iLen = 512;
    dim3 block(iLen);
    dim3 grid((nElem+block.x-1)/block.x);
    
    // invoke kernel at host side
    sumArraysOnGPU<<<grid,block>>>(d_A,d_B,d_C,nElem);
    
    // copy kernel result back to host side
    hipMemcpy(gpuRef,d_C,nBytes,hipMemcpyDeviceToHost);
    
    // free device global memory
    hipFree(d_A);
    hipFree(d_B);
    free(h_A);
    free(h_B);
    
    // part 2: using zerocopy memory for array A and B
    // allocate zerocpy memory
    unsigned int flags = hipHostMallocMapped;
    hipHostAlloc((void **)&h_A,nBytes,flags);
    hipHostAlloc((void **)&h_B,nBytes,flags);
     
    // initialize data at host side
    initialData(h_A,nElem);
    initialData(h_B,nElem);
    memset(hostRef,0,nBytes);
    memset(gpuRef,0,nBytes);
    
    // pass the pointer to device
    hipHostGetDevicePointer((void **)&d_A,(void *)h_A,0);
    hipHostGetDevicePointer((void **)&d_B,(void *)h_B,0);
    
    // add at host side for result checks
    sumArraysOnHost(h_A,h_B,hostRef,nElem);
    
    // execute kernel with zero copy memory
    sumArraysZeroCopy<<<grid,block>>>(d_A,d_B,d_C,nElem);
    
    // copy kernel result back to host side
    hipMemcpy(gpuRef,d_C,nBytes,hipMemcpyDeviceToHost);
    
    // check device results
    checkResult(hostRef,gpuRef,nElem);
    
    // free memory
    hipFree(d_C);
    hipHostFree(h_A);
    hipHostFree(h_B);
        
    free(hostRef);
    free(gpuRef);
     
    // reset device
    hipDeviceReset();
    return EXIT_SUCCESS;
    }
    
    
    

	.text
	.file	"sumArrayZerocopy.hip"
	.globl	_Z32__device_stub__sumArraysZeroCopyPfS_S_i # -- Begin function _Z32__device_stub__sumArraysZeroCopyPfS_S_i
	.type	_Z32__device_stub__sumArraysZeroCopyPfS_S_i,@function
_Z32__device_stub__sumArraysZeroCopyPfS_S_i: # @_Z32__device_stub__sumArraysZeroCopyPfS_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	$_Z17sumArraysZeroCopyPfS_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_end0:
	.size	_Z32__device_stub__sumArraysZeroCopyPfS_S_i, .Lfunc_end0-_Z32__device_stub__sumArraysZeroCopyPfS_S_i
	.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	_Z29__device_stub__sumArraysOnGPUPfS_S_i # -- Begin function _Z29__device_stub__sumArraysOnGPUPfS_S_i
	.type	_Z29__device_stub__sumArraysOnGPUPfS_S_i,@function
_Z29__device_stub__sumArraysOnGPUPfS_S_i: # @_Z29__device_stub__sumArraysOnGPUPfS_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	$_Z14sumArraysOnGPUPfS_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	_Z29__device_stub__sumArraysOnGPUPfS_S_i, .Lfunc_end2-_Z29__device_stub__sumArraysOnGPUPfS_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:                                # %.loopexit
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.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 _Z11initialDataPfi
.LCPI4_0:
	.long	0x41200000                      # float 10
	.text
	.globl	_Z11initialDataPfi
	.type	_Z11initialDataPfi,@function
_Z11initialDataPfi:                     # @_Z11initialDataPfi
	.cfi_startproc
# %bb.0:
	testl	%esi, %esi
	jle	.LBB4_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
.LBB4_2:                                # %.lr.ph
                                        # =>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,%r15,4)
	incq	%r15
	cmpq	%r15, %r14
	jne	.LBB4_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
.LBB4_4:                                # %._crit_edge
	retq
.Lfunc_end4:
	.size	_Z11initialDataPfi, .Lfunc_end4-_Z11initialDataPfi
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function main
.LCPI5_0:
	.long	0x3a800000                      # float 9.765625E-4
.LCPI5_1:
	.long	0x41200000                      # float 10
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$1544, %rsp                     # imm = 0x608
	.cfi_def_cfa_offset 1600
	.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, %rbx
	movl	%edi, %ebp
	xorl	%edi, %edi
	callq	hipSetDevice
	leaq	72(%rsp), %r14
	movq	%r14, %rdi
	xorl	%esi, %esi
	callq	hipGetDevicePropertiesR0600
	cmpl	$0, 400(%r14)
	je	.LBB5_34
# %bb.1:
	leaq	72(%rsp), %rdx
	movl	$.L.str.3, %edi
	xorl	%esi, %esi
	xorl	%eax, %eax
	callq	printf
	cmpl	$2, %ebp
	jl	.LBB5_2
# %bb.3:
	movq	8(%rbx), %rdi
	callq	atoi
	movl	%eax, %edx
	movl	$1, %r12d
	movl	%edx, %ecx
	shll	%cl, %r12d
	movslq	%r12d, %r14
	shlq	$2, %r14
	cmpl	$17, %eax
	jle	.LBB5_4
# %bb.8:
	testq	%r14, %r14
	js	.LBB5_9
# %bb.10:
	cvtsi2ss	%r14, %xmm0
	jmp	.LBB5_11
.LBB5_2:
	movl	$10, %edx
	movl	$1024, %r12d                    # imm = 0x400
	movl	$4096, %r14d                    # imm = 0x1000
.LBB5_4:                                # %.thread
	testq	%r14, %r14
	js	.LBB5_5
# %bb.6:                                # %.thread
	cvtsi2ss	%r14, %xmm0
	jmp	.LBB5_7
.LBB5_5:
	movq	%r14, %rax
	shrq	%rax
	movl	%r14d, %ecx
	andl	$1, %ecx
	orq	%rax, %rcx
	cvtsi2ss	%rcx, %xmm0
	addss	%xmm0, %xmm0
.LBB5_7:                                # %.thread
	mulss	.LCPI5_0(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	movl	$.L.str.4, %edi
	jmp	.LBB5_12
.LBB5_9:
	movq	%r14, %rax
	shrq	%rax
	movl	%r14d, %ecx
	andl	$1, %ecx
	orq	%rax, %rcx
	cvtsi2ss	%rcx, %xmm0
	addss	%xmm0, %xmm0
.LBB5_11:
	mulss	.LCPI5_0(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	movl	$.L.str.5, %edi
.LBB5_12:
	movl	%r12d, %esi
	movb	$1, %al
	callq	printf
	movq	%r14, %rdi
	callq	malloc
	movq	%rax, %rbp
	movq	%rax, 48(%rsp)
	movq	%r14, %rdi
	callq	malloc
	movq	%rax, %r13
	movq	%rax, 24(%rsp)
	movq	%r14, %rdi
	callq	malloc
	movq	%rax, %r15
	movq	%r14, %rdi
	callq	malloc
	movq	%rax, %rbx
	movq	%r12, %rax
	movl	%eax, %r12d
	movq	%rax, 56(%rsp)                  # 8-byte Spill
	testl	%eax, %eax
	movq	%rbx, 32(%rsp)                  # 8-byte Spill
	jle	.LBB5_35
# %bb.13:                               # %.lr.ph.preheader.i
	xorl	%ebx, %ebx
.LBB5_14:                               # %.lr.ph.i
                                        # =>This Inner Loop Header: Depth=1
	callq	rand
	movss	.LCPI5_1(%rip), %xmm1           # xmm1 = mem[0],zero,zero,zero
	movzbl	%al, %eax
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	divss	%xmm1, %xmm0
	movss	%xmm0, (%rbp,%rbx,4)
	incq	%rbx
	cmpq	%rbx, %r12
	jne	.LBB5_14
# %bb.15:                               # %.lr.ph.i74.preheader
	xorl	%ebx, %ebx
.LBB5_16:                               # %.lr.ph.i74
                                        # =>This Inner Loop Header: Depth=1
	callq	rand
	movzbl	%al, %eax
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	divss	.LCPI5_1(%rip), %xmm0
	movss	%xmm0, (%r13,%rbx,4)
	incq	%rbx
	cmpq	%rbx, %r12
	jne	.LBB5_16
# %bb.17:                               # %_Z11initialDataPfi.exit78
	xorl	%ebx, %ebx
	movq	%r15, %rdi
	xorl	%esi, %esi
	movq	%r14, %rdx
	callq	memset@PLT
	movq	32(%rsp), %rdi                  # 8-byte Reload
	xorl	%esi, %esi
	movq	%r14, %rdx
	callq	memset@PLT
.LBB5_18:                               # %.lr.ph.i81
                                        # =>This Inner Loop Header: Depth=1
	movss	(%rbp,%rbx,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	addss	(%r13,%rbx,4), %xmm0
	movss	%xmm0, (%r15,%rbx,4)
	incq	%rbx
	cmpq	%rbx, %r12
	jne	.LBB5_18
	jmp	.LBB5_19
.LBB5_35:                               # %_Z11initialDataPfi.exit78.thread
	movq	%r15, %rdi
	xorl	%esi, %esi
	movq	%r14, %rdx
	callq	memset@PLT
	movq	%rbx, %rdi
	xorl	%esi, %esi
	movq	%r14, %rdx
	callq	memset@PLT
.LBB5_19:                               # %_Z15sumArraysOnHostPfS_S_i.exit
	leaq	40(%rsp), %rbx
	movq	%rbx, %rdi
	movq	%r14, %rsi
	callq	hipMalloc
	leaq	16(%rsp), %rdi
	movq	%r14, %rsi
	callq	hipMalloc
	leaq	8(%rsp), %rdi
	movq	%r14, %rsi
	callq	hipMalloc
	movq	(%rbx), %rdi
	movq	%rbp, %rsi
	movq	%r14, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	leaq	16(%rsp), %rax
	movq	(%rax), %rdi
	movq	%r13, %rsi
	movq	%r14, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	56(%rsp), %rbx                  # 8-byte Reload
	leal	511(%rbx), %eax
	shrl	$9, %eax
	movabsq	$4294967808, %rdx               # imm = 0x100000200
	leaq	(%rax,%rdx), %rdi
	addq	$-512, %rdi                     # imm = 0xFE00
	movq	%rdi, 64(%rsp)                  # 8-byte Spill
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB5_21
# %bb.20:
	movq	40(%rsp), %rdi
	movq	16(%rsp), %rsi
	movq	8(%rsp), %rdx
	movl	%ebx, %ecx
	callq	_Z29__device_stub__sumArraysOnGPUPfS_S_i
.LBB5_21:
	movq	8(%rsp), %rsi
	movq	32(%rsp), %rdi                  # 8-byte Reload
	movq	%r14, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	movq	40(%rsp), %rdi
	callq	hipFree
	movq	16(%rsp), %rdi
	callq	hipFree
	movq	%rbp, %rdi
	callq	free
	movq	%r13, %rdi
	callq	free
	leaq	48(%rsp), %rbx
	movq	%rbx, %rdi
	movq	%r14, %rsi
	movl	$2, %edx
	callq	hipHostAlloc
	leaq	24(%rsp), %rdi
	movq	%r14, %rsi
	movl	$2, %edx
	callq	hipHostAlloc
	movq	(%rbx), %r13
	movq	56(%rsp), %rbx                  # 8-byte Reload
	testl	%ebx, %ebx
	jle	.LBB5_22
# %bb.23:                               # %.lr.ph.preheader.i85
	xorl	%ebx, %ebx
.LBB5_24:                               # %.lr.ph.i87
                                        # =>This Inner Loop Header: Depth=1
	callq	rand
	movss	.LCPI5_1(%rip), %xmm1           # xmm1 = mem[0],zero,zero,zero
	movzbl	%al, %eax
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	divss	%xmm1, %xmm0
	movss	%xmm0, (%r13,%rbx,4)
	incq	%rbx
	cmpq	%rbx, %r12
	jne	.LBB5_24
# %bb.25:                               # %_Z11initialDataPfi.exit91
	movq	24(%rsp), %rbx
	xorl	%r13d, %r13d
	movq	32(%rsp), %rbp                  # 8-byte Reload
.LBB5_26:                               # %.lr.ph.i94
                                        # =>This Inner Loop Header: Depth=1
	callq	rand
	movzbl	%al, %eax
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	divss	.LCPI5_1(%rip), %xmm0
	movss	%xmm0, (%rbx,%r13,4)
	incq	%r13
	cmpq	%r13, %r12
	jne	.LBB5_26
# %bb.27:                               # %_Z11initialDataPfi.exit98.loopexit
	movq	48(%rsp), %r13
	movq	56(%rsp), %rbx                  # 8-byte Reload
	jmp	.LBB5_28
.LBB5_22:
	movq	32(%rsp), %rbp                  # 8-byte Reload
.LBB5_28:                               # %_Z11initialDataPfi.exit98
	movq	%r15, %rdi
	xorl	%esi, %esi
	movq	%r14, %rdx
	callq	memset@PLT
	movq	%rbp, %rdi
	xorl	%esi, %esi
	movq	%r14, %rdx
	callq	memset@PLT
	leaq	40(%rsp), %rdi
	movq	%r13, %rsi
	xorl	%edx, %edx
	callq	hipHostGetDevicePointer
	movq	24(%rsp), %rsi
	leaq	16(%rsp), %rdi
	xorl	%edx, %edx
	callq	hipHostGetDevicePointer
	testl	%ebx, %ebx
	jle	.LBB5_31
# %bb.29:                               # %.lr.ph.preheader.i99
	movq	48(%rsp), %rax
	movq	24(%rsp), %rcx
	xorl	%edx, %edx
.LBB5_30:                               # %.lr.ph.i101
                                        # =>This Inner Loop Header: Depth=1
	movss	(%rax,%rdx,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	addss	(%rcx,%rdx,4), %xmm0
	movss	%xmm0, (%r15,%rdx,4)
	incq	%rdx
	cmpq	%rdx, %r12
	jne	.LBB5_30
.LBB5_31:                               # %_Z15sumArraysOnHostPfS_S_i.exit105
	movq	64(%rsp), %rdi                  # 8-byte Reload
	movl	$1, %esi
	movabsq	$4294967808, %rdx               # imm = 0x100000200
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB5_33
# %bb.32:
	movq	40(%rsp), %rdi
	movq	16(%rsp), %rsi
	movq	8(%rsp), %rdx
	movl	%ebx, %ecx
	callq	_Z32__device_stub__sumArraysZeroCopyPfS_S_i
.LBB5_33:
	movq	8(%rsp), %rsi
	movq	%rbp, %rdi
	movq	%r14, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	movq	%r15, %rdi
	movq	%rbp, %rsi
	movl	%ebx, %edx
	callq	_Z11checkResultPfS_i
	movq	8(%rsp), %rdi
	callq	hipFree
	movq	48(%rsp), %rdi
	callq	hipHostFree
	movq	24(%rsp), %rdi
	callq	hipHostFree
	movq	%r15, %rdi
	callq	free
	movq	%rbp, %rdi
	callq	free
	callq	hipDeviceReset
	xorl	%eax, %eax
	addq	$1544, %rsp                     # imm = 0x608
	.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
.LBB5_34:
	.cfi_def_cfa_offset 1600
	movl	$.L.str.2, %edi
	xorl	%esi, %esi
	xorl	%eax, %eax
	callq	printf
	callq	hipDeviceReset
	xorl	%edi, %edi
	callq	exit
.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:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$32, %rsp
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -16
	movq	__hip_gpubin_handle(%rip), %rbx
	testq	%rbx, %rbx
	jne	.LBB6_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB6_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z17sumArraysZeroCopyPfS_S_i, %esi
	movl	$.L__unnamed_1, %edx
	movl	$.L__unnamed_1, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z14sumArraysOnGPUPfS_S_i, %esi
	movl	$.L__unnamed_2, %edx
	movl	$.L__unnamed_2, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$__hip_module_dtor, %edi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.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	_Z17sumArraysZeroCopyPfS_S_i,@object # @_Z17sumArraysZeroCopyPfS_S_i
	.section	.rodata,"a",@progbits
	.globl	_Z17sumArraysZeroCopyPfS_S_i
	.p2align	3, 0x0
_Z17sumArraysZeroCopyPfS_S_i:
	.quad	_Z32__device_stub__sumArraysZeroCopyPfS_S_i
	.size	_Z17sumArraysZeroCopyPfS_S_i, 8

	.type	_Z14sumArraysOnGPUPfS_S_i,@object # @_Z14sumArraysOnGPUPfS_S_i
	.globl	_Z14sumArraysOnGPUPfS_S_i
	.p2align	3, 0x0
_Z14sumArraysOnGPUPfS_S_i:
	.quad	_Z29__device_stub__sumArraysOnGPUPfS_S_i
	.size	_Z14sumArraysOnGPUPfS_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 current %d\n"
	.size	.L.str.1, 36

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"Device %d does not support mapping CPU host memory!\n"
	.size	.L.str.2, 53

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

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"Vector size %d power %d nbytes %3.0f KB\n"
	.size	.L.str.4, 41

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"Vector size %d power %d nbytes %3.0f MB\n"
	.size	.L.str.5, 41

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z17sumArraysZeroCopyPfS_S_i"
	.size	.L__unnamed_1, 29

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_Z14sumArraysOnGPUPfS_S_i"
	.size	.L__unnamed_2, 26

	.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

	.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 _Z32__device_stub__sumArraysZeroCopyPfS_S_i
	.addrsig_sym _Z29__device_stub__sumArraysOnGPUPfS_S_i
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z17sumArraysZeroCopyPfS_S_i
	.addrsig_sym _Z14sumArraysOnGPUPfS_S_i
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z17sumArraysZeroCopyPfS_S_i ; -- Begin function _Z17sumArraysZeroCopyPfS_S_i
	.globl	_Z17sumArraysZeroCopyPfS_S_i
	.p2align	8
	.type	_Z17sumArraysZeroCopyPfS_S_i,@function
_Z17sumArraysZeroCopyPfS_S_i:           ; @_Z17sumArraysZeroCopyPfS_S_i
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x2c
	s_load_b32 s3, s[0:1], 0x18
	s_waitcnt lgkmcnt(0)
	s_and_b32 s2, s2, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s15, s2, v[0:1]
	s_mov_b32 s2, exec_lo
	v_cmpx_gt_i32_e64 s3, v1
	s_cbranch_execz .LBB0_2
; %bb.1:
	s_load_b128 s[4:7], s[0:1], 0x0
	v_ashrrev_i32_e32 v2, 31, v1
	s_load_b64 s[0:1], s[0:1], 0x10
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[0:1], 2, v[1:2]
	s_waitcnt lgkmcnt(0)
	v_add_co_u32 v2, vcc_lo, s4, v0
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v3, vcc_lo, s5, v1, vcc_lo
	v_add_co_u32 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
.LBB0_2:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z17sumArraysZeroCopyPfS_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 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	_Z17sumArraysZeroCopyPfS_S_i, .Lfunc_end0-_Z17sumArraysZeroCopyPfS_S_i
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 180
; 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
	.protected	_Z14sumArraysOnGPUPfS_S_i ; -- Begin function _Z14sumArraysOnGPUPfS_S_i
	.globl	_Z14sumArraysOnGPUPfS_S_i
	.p2align	8
	.type	_Z14sumArraysOnGPUPfS_S_i,@function
_Z14sumArraysOnGPUPfS_S_i:              ; @_Z14sumArraysOnGPUPfS_S_i
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x2c
	s_load_b32 s3, s[0:1], 0x18
	s_waitcnt lgkmcnt(0)
	s_and_b32 s2, s2, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s15, s2, v[0:1]
	s_mov_b32 s2, exec_lo
	v_cmpx_gt_i32_e64 s3, v1
	s_cbranch_execz .LBB1_2
; %bb.1:
	s_load_b128 s[4:7], s[0:1], 0x0
	v_ashrrev_i32_e32 v2, 31, v1
	s_load_b64 s[0:1], s[0:1], 0x10
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[0:1], 2, v[1:2]
	s_waitcnt lgkmcnt(0)
	v_add_co_u32 v2, vcc_lo, s4, v0
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v3, vcc_lo, s5, v1, vcc_lo
	v_add_co_u32 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
.LBB1_2:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z14sumArraysOnGPUPfS_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 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_end1:
	.size	_Z14sumArraysOnGPUPfS_S_i, .Lfunc_end1-_Z14sumArraysOnGPUPfS_S_i
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 180
; 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
      - .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:           _Z17sumArraysZeroCopyPfS_S_i
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z17sumArraysZeroCopyPfS_S_i.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     6
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
  - .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:           _Z14sumArraysOnGPUPfS_S_i
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z14sumArraysOnGPUPfS_S_i.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
