#include <iostream>
#include <stdio.h>
#include <vector>

#define MAX_THREADS 256
#define SIZE 524288

#define __START__ cudaEventCreate(&start); cudaEventCreate(&stop); cudaEventRecord(start, 0);
#define __STOP__(_V) cudaEventRecord(stop, 0); cudaEventSynchronize(stop); cudaEventElapsedTime(&time, start, stop); _V.push_back(time); cudaEventDestroy(start); cudaEventDestroy(stop);
#define __NEXT__(_V) __STOP__(_V) __START__
#define __START_BIS__ cudaEventCreate(&startBis); cudaEventCreate(&stopBis); cudaEventRecord(startBis, 0);
#define __STOP_BIS__(_V) cudaEventRecord(stopBis, 0); cudaEventSynchronize(stopBis); cudaEventElapsedTime(&time, startBis, stopBis); _V.push_back(time); cudaEventDestroy(startBis); cudaEventDestroy(stopBis);
#define __NEXT_BIS__(_V) __STOP_BIS__(_V) __START_BIS__

__global__ void sumall_kernel(float *d_vector, float *d_result)
{
    __shared__ float cache[MAX_THREADS];

    int cacheIdx = threadIdx.x;
    int i = blockIdx.x * blockDim.x + threadIdx.x;
    cache[cacheIdx] = i >= SIZE ? 0. : d_vector[i];
    __syncthreads();

    if (i >= SIZE)
        return;

    int padding = blockDim.x/2;
    while (padding != 0)
    {
        if (cacheIdx < padding)
            cache[cacheIdx] += cache[cacheIdx + padding];

        __syncthreads();
        padding /= 2;
    }

    if (cacheIdx == 0)
        atomicAdd(&d_result[0], cache[0]);
}

void showMean(std::vector<float> v)
{
    float sum(0);
    for (unsigned int i(0) ; i!=v.size() ; i++)
        sum += v[i];
    std::cout << 1000.*sum/v.size() << " microseconds" << std::endl;
}

int main(int argc, char **argv)
{
    std::cout << "SIZE (vs Reduce-Native): " << SIZE << std::endl;
    cudaEvent_t start, stop, startBis, stopBis;
    std::vector<float> cudaRun, cudaKRun, nativeRun;
    float time(0);
    
    cudaFree(0); // Force runtime API context establishment
    float h_vector[SIZE]; // For input and output
    for (unsigned int i(0) ; i!=SIZE ; i++)
        h_vector[i] = i;
    float h_result;
    
    for (unsigned int i(0) ; i!=1000 ; i++)
    {
        float *d_vector, *d_result;
        
        __START__
        cudaMalloc(&d_vector, SIZE*sizeof(float));
        cudaMalloc(&d_result, sizeof(float));
        cudaMemcpy(d_vector, h_vector, SIZE*sizeof(float), cudaMemcpyHostToDevice);
        cudaMemset(d_result, 0, sizeof(float));
        __START_BIS__
        sumall_kernel<<<(SIZE+MAX_THREADS-1)/MAX_THREADS, MAX_THREADS>>>(d_vector, d_result);
        cudaThreadSynchronize(); // Block until the device is finished
        __STOP_BIS__(cudaKRun);
        cudaMemcpy(h_vector, d_vector, SIZE*sizeof(float), cudaMemcpyDeviceToHost);
        cudaMemcpy(&h_result, d_result, sizeof(float), cudaMemcpyDeviceToHost);
        cudaFree(d_vector);
        cudaFree(d_result);
        __NEXT__(cudaRun)
        
        h_result = 0.;
        for (unsigned int i(0) ; i!=SIZE ; i++)
            h_result += h_vector[i];
        __STOP__(nativeRun)
    }
    showMean(cudaRun);
    showMean(cudaKRun);
    showMean(nativeRun);
}    


	.file	"tmpxft_00244bb4_00000000-6_main.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB4012:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE4012:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC2:
	.string	" microseconds"
	.text
	.globl	_Z8showMeanSt6vectorIfSaIfEE
	.type	_Z8showMeanSt6vectorIfSaIfEE, @function
_Z8showMeanSt6vectorIfSaIfEE:
.LFB3998:
	.cfi_startproc
	endbr64
	pushq	%rdx
	.cfi_def_cfa_offset 16
	movq	(%rdi), %rsi
	xorl	%edx, %edx
	xorps	%xmm0, %xmm0
	movq	8(%rdi), %rax
	subq	%rsi, %rax
	sarq	$2, %rax
.L3:
	movl	%edx, %ecx
	cmpq	%rax, %rcx
	je	.L7
	addss	(%rsi,%rcx,4), %xmm0
	incl	%edx
	jmp	.L3
.L7:
	cvtss2sd	%xmm0, %xmm0
	cvtsi2sdq	%rax, %xmm1
	mulsd	.LC1(%rip), %xmm0
	leaq	_ZSt4cout(%rip), %rdi
	divsd	%xmm1, %xmm0
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	leaq	.LC2(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%rax, %rdi
	popq	%rax
	.cfi_def_cfa_offset 8
	jmp	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT
	.cfi_endproc
.LFE3998:
	.size	_Z8showMeanSt6vectorIfSaIfEE, .-_Z8showMeanSt6vectorIfSaIfEE
	.globl	_Z35__device_stub__Z13sumall_kernelPfS_PfS_
	.type	_Z35__device_stub__Z13sumall_kernelPfS_PfS_, @function
_Z35__device_stub__Z13sumall_kernelPfS_PfS_:
.LFB4034:
	.cfi_startproc
	endbr64
	subq	$120, %rsp
	.cfi_def_cfa_offset 128
	movq	%rdi, 8(%rsp)
	leaq	32(%rsp), %rcx
	leaq	24(%rsp), %rdx
	movq	%rsi, (%rsp)
	leaq	40(%rsp), %rdi
	leaq	52(%rsp), %rsi
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rax
	movl	$1, 48(%rsp)
	movq	%rax, 88(%rsp)
	movq	%rsp, %rax
	movq	%rax, 96(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 40(%rsp)
	movq	%rax, 52(%rsp)
	movl	$1, 60(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L8
	pushq	32(%rsp)
	.cfi_def_cfa_offset 136
	leaq	_Z13sumall_kernelPfS_(%rip), %rdi
	pushq	32(%rsp)
	.cfi_def_cfa_offset 144
	movq	68(%rsp), %rcx
	movl	76(%rsp), %r8d
	movq	56(%rsp), %rsi
	movl	64(%rsp), %edx
	leaq	104(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 136
	popq	%rdx
	.cfi_def_cfa_offset 128
.L8:
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	je	.L10
	call	__stack_chk_fail@PLT
.L10:
	addq	$120, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE4034:
	.size	_Z35__device_stub__Z13sumall_kernelPfS_PfS_, .-_Z35__device_stub__Z13sumall_kernelPfS_PfS_
	.globl	_Z13sumall_kernelPfS_
	.type	_Z13sumall_kernelPfS_, @function
_Z13sumall_kernelPfS_:
.LFB4035:
	.cfi_startproc
	endbr64
	jmp	_Z35__device_stub__Z13sumall_kernelPfS_PfS_
	.cfi_endproc
.LFE4035:
	.size	_Z13sumall_kernelPfS_, .-_Z13sumall_kernelPfS_
	.section	.rodata.str1.1
.LC3:
	.string	"_Z13sumall_kernelPfS_"
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB4037:
	.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	.LC3(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z13sumall_kernelPfS_(%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
.LFE4037:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.text._ZNSt6vectorIfSaIfEED2Ev,"axG",@progbits,_ZNSt6vectorIfSaIfEED5Ev,comdat
	.align 2
	.weak	_ZNSt6vectorIfSaIfEED2Ev
	.type	_ZNSt6vectorIfSaIfEED2Ev, @function
_ZNSt6vectorIfSaIfEED2Ev:
.LFB4353:
	.cfi_startproc
	endbr64
	movq	(%rdi), %rax
	testq	%rax, %rax
	je	.L15
	movq	16(%rdi), %rsi
	movq	%rax, %rdi
	subq	%rax, %rsi
	jmp	_ZdlPvm@PLT
.L15:
	ret
	.cfi_endproc
.LFE4353:
	.size	_ZNSt6vectorIfSaIfEED2Ev, .-_ZNSt6vectorIfSaIfEED2Ev
	.weak	_ZNSt6vectorIfSaIfEED1Ev
	.set	_ZNSt6vectorIfSaIfEED1Ev,_ZNSt6vectorIfSaIfEED2Ev
	.section	.text._ZNSt6vectorIfSaIfEEC2ERKS1_,"axG",@progbits,_ZNSt6vectorIfSaIfEEC5ERKS1_,comdat
	.align 2
	.weak	_ZNSt6vectorIfSaIfEEC2ERKS1_
	.type	_ZNSt6vectorIfSaIfEEC2ERKS1_, @function
_ZNSt6vectorIfSaIfEEC2ERKS1_:
.LFB4359:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movq	%rsi, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	movq	8(%rsi), %rbp
	movq	%rdi, %rbx
	subq	(%rsi), %rbp
	movq	$0, (%rdi)
	movq	$0, 8(%rdi)
	movq	$0, 16(%rdi)
	je	.L22
	movabsq	$9223372036854775804, %rax
	cmpq	%rbp, %rax
	jnb	.L19
	call	_ZSt28__throw_bad_array_new_lengthv@PLT
.L19:
	movq	%rbp, %rdi
	call	_Znwm@PLT
	movq	%rax, %rcx
	jmp	.L18
.L22:
	xorl	%ecx, %ecx
.L18:
	addq	%rcx, %rbp
	movq	%rcx, (%rbx)
	movq	%rcx, 8(%rbx)
	movq	%rbp, 16(%rbx)
	movq	(%r12), %rsi
	movq	8(%r12), %rbp
	subq	%rsi, %rbp
	cmpq	$4, %rbp
	jle	.L20
	movq	%rcx, %rdi
	movq	%rbp, %rdx
	call	memmove@PLT
	movq	%rax, %rcx
	jmp	.L21
.L20:
	jne	.L21
	movss	(%rsi), %xmm0
	movss	%xmm0, (%rcx)
.L21:
	addq	%rbp, %rcx
	movq	%rcx, 8(%rbx)
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE4359:
	.size	_ZNSt6vectorIfSaIfEEC2ERKS1_, .-_ZNSt6vectorIfSaIfEEC2ERKS1_
	.weak	_ZNSt6vectorIfSaIfEEC1ERKS1_
	.set	_ZNSt6vectorIfSaIfEEC1ERKS1_,_ZNSt6vectorIfSaIfEEC2ERKS1_
	.section	.rodata._ZNSt6vectorIfSaIfEE17_M_realloc_insertIJRKfEEEvN9__gnu_cxx17__normal_iteratorIPfS1_EEDpOT_.str1.1,"aMS",@progbits,1
.LC4:
	.string	"vector::_M_realloc_insert"
	.section	.text._ZNSt6vectorIfSaIfEE17_M_realloc_insertIJRKfEEEvN9__gnu_cxx17__normal_iteratorIPfS1_EEDpOT_,"axG",@progbits,_ZNSt6vectorIfSaIfEE17_M_realloc_insertIJRKfEEEvN9__gnu_cxx17__normal_iteratorIPfS1_EEDpOT_,comdat
	.align 2
	.weak	_ZNSt6vectorIfSaIfEE17_M_realloc_insertIJRKfEEEvN9__gnu_cxx17__normal_iteratorIPfS1_EEDpOT_
	.type	_ZNSt6vectorIfSaIfEE17_M_realloc_insertIJRKfEEEvN9__gnu_cxx17__normal_iteratorIPfS1_EEDpOT_, @function
_ZNSt6vectorIfSaIfEE17_M_realloc_insertIJRKfEEEvN9__gnu_cxx17__normal_iteratorIPfS1_EEDpOT_:
.LFB4518:
	.cfi_startproc
	endbr64
	movabsq	$2305843009213693951, %rcx
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	movq	8(%rdi), %rax
	movq	(%rdi), %r14
	movq	%rax, %rbx
	movq	%rax, (%rsp)
	subq	%r14, %rbx
	sarq	$2, %rbx
	cmpq	%rcx, %rbx
	jne	.L25
	leaq	.LC4(%rip), %rdi
	call	_ZSt20__throw_length_errorPKc@PLT
.L25:
	cmpq	%r14, (%rsp)
	movl	$1, %eax
	movq	%rsi, %r15
	movq	%rdi, %r13
	cmovne	%rbx, %rax
	movq	%rsi, %rbp
	addq	%rax, %rbx
	setc	%al
	subq	%r14, %r15
	movzbl	%al, %eax
	testq	%rax, %rax
	jne	.L35
	xorl	%r12d, %r12d
	testq	%rbx, %rbx
	je	.L30
	movabsq	$2305843009213693951, %rax
	cmpq	%rax, %rbx
	cmova	%rax, %rbx
	jmp	.L29
.L35:
	movq	%rcx, %rbx
.L29:
	leaq	0(,%rbx,4), %rdi
	movq	%rdx, 8(%rsp)
	call	_Znwm@PLT
	movq	8(%rsp), %rdx
	movq	%rax, %r12
.L30:
	movss	(%rdx), %xmm0
	movss	%xmm0, (%r12,%r15)
	testq	%r15, %r15
	jle	.L31
	movq	%r15, %rdx
	movq	%r14, %rsi
	movq	%r12, %rdi
	call	memmove@PLT
.L31:
	movq	(%rsp), %rax
	leaq	4(%r12,%r15), %rdx
	subq	%rbp, %rax
	testq	%rax, %rax
	jle	.L32
	movq	%rdx, %rdi
	movq	%rbp, %rsi
	movq	%rax, %rcx
	rep movsb
.L32:
	leaq	(%rdx,%rax), %rbp
	testq	%r14, %r14
	je	.L33
	movq	16(%r13), %rsi
	movq	%r14, %rdi
	subq	%r14, %rsi
	call	_ZdlPvm@PLT
.L33:
	leaq	(%r12,%rbx,4), %rax
	movq	%r12, 0(%r13)
	movq	%rbp, 8(%r13)
	movq	%rax, 16(%r13)
	addq	$24, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE4518:
	.size	_ZNSt6vectorIfSaIfEE17_M_realloc_insertIJRKfEEEvN9__gnu_cxx17__normal_iteratorIPfS1_EEDpOT_, .-_ZNSt6vectorIfSaIfEE17_M_realloc_insertIJRKfEEEvN9__gnu_cxx17__normal_iteratorIPfS1_EEDpOT_
	.section	.text._ZNSt6vectorIfSaIfEE9push_backERKf,"axG",@progbits,_ZNSt6vectorIfSaIfEE9push_backERKf,comdat
	.align 2
	.weak	_ZNSt6vectorIfSaIfEE9push_backERKf
	.type	_ZNSt6vectorIfSaIfEE9push_backERKf, @function
_ZNSt6vectorIfSaIfEE9push_backERKf:
.LFB4356:
	.cfi_startproc
	endbr64
	movq	%rsi, %rdx
	movq	8(%rdi), %rsi
	cmpq	16(%rdi), %rsi
	je	.L43
	movss	(%rdx), %xmm0
	addq	$4, %rsi
	movss	%xmm0, -4(%rsi)
	movq	%rsi, 8(%rdi)
	ret
.L43:
	jmp	_ZNSt6vectorIfSaIfEE17_M_realloc_insertIJRKfEEEvN9__gnu_cxx17__normal_iteratorIPfS1_EEDpOT_
	.cfi_endproc
.LFE4356:
	.size	_ZNSt6vectorIfSaIfEE9push_backERKf, .-_ZNSt6vectorIfSaIfEE9push_backERKf
	.section	.rodata.str1.1
.LC5:
	.string	"SIZE (vs Reduce-Native): "
	.section	.text.startup
	.globl	main
	.type	main, @function
main:
.LFB3999:
	.cfi_startproc
	.cfi_personality 0x9b,DW.ref.__gxx_personality_v0
	.cfi_lsda 0x1b,.LLSDA3999
	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
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	-2097152(%rsp), %r11
	.cfi_def_cfa 11, 2097208
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$200, %rsp
	.cfi_def_cfa_offset 2097408
	leaq	.LC5(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rdi
	movq	%fs:40, %rax
	movq	%rax, 2097336(%rsp)
	xorl	%eax, %eax
.LEHB0:
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	$524288, %esi
	movq	%rax, %rdi
	call	_ZNSolsEi@PLT
	movq	%rax, %rdi
	call	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT
.LEHE0:
	xorl	%eax, %eax
	xorl	%edi, %edi
	movl	$0x00000000, 16(%rsp)
	movq	%rax, 88(%rsp)
	movq	%rax, 96(%rsp)
	movq	%rax, 104(%rsp)
	movq	%rax, 112(%rsp)
	movq	%rax, 120(%rsp)
	movq	%rax, 128(%rsp)
	movq	%rax, 136(%rsp)
	movq	%rax, 144(%rsp)
	movq	%rax, 152(%rsp)
.LEHB1:
	call	cudaFree@PLT
	xorl	%eax, %eax
	leaq	184(%rsp), %r13
.L47:
	cvtsi2ssl	%eax, %xmm0
	movss	%xmm0, 0(%r13,%rax,4)
	incq	%rax
	cmpq	$524288, %rax
	jne	.L47
	movl	$1000, %r12d
	leaq	24(%rsp), %r15
.L50:
	movq	%r15, %rdi
	call	cudaEventCreate@PLT
	leaq	32(%rsp), %rbp
	movq	%rbp, %rdi
	call	cudaEventCreate@PLT
	movq	24(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	leaq	56(%rsp), %rdi
	movl	$2097152, %esi
	call	cudaMalloc@PLT
	leaq	64(%rsp), %rdi
	movl	$4, %esi
	call	cudaMalloc@PLT
	movq	56(%rsp), %rdi
	movl	$1, %ecx
	movl	$2097152, %edx
	movq	%r13, %rsi
	call	cudaMemcpy@PLT
	movq	64(%rsp), %rdi
	movl	$4, %edx
	xorl	%esi, %esi
	call	cudaMemset@PLT
	leaq	40(%rsp), %rdi
	call	cudaEventCreate@PLT
	leaq	48(%rsp), %rdi
	call	cudaEventCreate@PLT
	movq	40(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movl	$16777217, %edx
	movl	$2097153, %edi
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	salq	$8, %rdx
	salq	$11, %rdi
	movl	$1, %ecx
	movl	$1, %esi
	movq	%rdx, 160(%rsp)
	movl	$1, 168(%rsp)
	movq	%rdi, 76(%rsp)
	movl	$1, 84(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L48
	movq	64(%rsp), %rsi
	movq	56(%rsp), %rdi
	call	_Z35__device_stub__Z13sumall_kernelPfS_PfS_
.L48:
	call	cudaThreadSynchronize@PLT
	movq	48(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	48(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	leaq	16(%rsp), %rbx
	movq	48(%rsp), %rdx
	movq	40(%rsp), %rsi
	movq	%rbx, %rdi
	call	cudaEventElapsedTime@PLT
	leaq	112(%rsp), %r14
	movq	%rbx, %rsi
	movq	%r14, %rdi
	call	_ZNSt6vectorIfSaIfEE9push_backERKf
	movq	40(%rsp), %rdi
	call	cudaEventDestroy@PLT
	movq	48(%rsp), %rdi
	call	cudaEventDestroy@PLT
	movq	56(%rsp), %rsi
	movl	$2, %ecx
	movl	$2097152, %edx
	movq	%r13, %rdi
	call	cudaMemcpy@PLT
	movq	64(%rsp), %rsi
	leaq	20(%rsp), %rdi
	movl	$2, %ecx
	movl	$4, %edx
	call	cudaMemcpy@PLT
	movq	56(%rsp), %rdi
	call	cudaFree@PLT
	movq	64(%rsp), %rdi
	call	cudaFree@PLT
	movq	32(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	32(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movq	32(%rsp), %rdx
	movq	24(%rsp), %rsi
	movq	%rbx, %rdi
	call	cudaEventElapsedTime@PLT
	leaq	88(%rsp), %rax
	movq	%rbx, %rsi
	movq	%rax, %rdi
	movq	%rax, 8(%rsp)
	call	_ZNSt6vectorIfSaIfEE9push_backERKf
	movq	24(%rsp), %rdi
	call	cudaEventDestroy@PLT
	movq	32(%rsp), %rdi
	call	cudaEventDestroy@PLT
	movq	%r15, %rdi
	call	cudaEventCreate@PLT
	movq	%rbp, %rdi
	call	cudaEventCreate@PLT
	movq	24(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	xorl	%eax, %eax
	xorps	%xmm0, %xmm0
	leaq	184(%rsp), %rdx
.L49:
	addss	(%rdx,%rax,4), %xmm0
	incq	%rax
	cmpq	$524288, %rax
	jne	.L49
	movq	32(%rsp), %rdi
	xorl	%esi, %esi
	movss	%xmm0, 20(%rsp)
	call	cudaEventRecord@PLT
	movq	32(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movq	32(%rsp), %rdx
	movq	24(%rsp), %rsi
	movq	%rbx, %rdi
	call	cudaEventElapsedTime@PLT
	leaq	136(%rsp), %rbp
	movq	%rbx, %rsi
	movq	%rbp, %rdi
	call	_ZNSt6vectorIfSaIfEE9push_backERKf
	movq	24(%rsp), %rdi
	call	cudaEventDestroy@PLT
	movq	32(%rsp), %rdi
	call	cudaEventDestroy@PLT
	decl	%r12d
	jne	.L50
	leaq	160(%rsp), %r12
	movq	8(%rsp), %rsi
	movq	%r12, %rdi
	call	_ZNSt6vectorIfSaIfEEC1ERKS1_
.LEHE1:
	movq	%r12, %rdi
.LEHB2:
	call	_Z8showMeanSt6vectorIfSaIfEE
.LEHE2:
	movq	%r12, %rdi
	call	_ZNSt6vectorIfSaIfEED1Ev
	movq	%r14, %rsi
	movq	%r12, %rdi
.LEHB3:
	call	_ZNSt6vectorIfSaIfEEC1ERKS1_
.LEHE3:
	movq	%r12, %rdi
.LEHB4:
	call	_Z8showMeanSt6vectorIfSaIfEE
.LEHE4:
	movq	%r12, %rdi
	call	_ZNSt6vectorIfSaIfEED1Ev
	movq	%rbp, %rsi
	movq	%r12, %rdi
.LEHB5:
	call	_ZNSt6vectorIfSaIfEEC1ERKS1_
.LEHE5:
	movq	%r12, %rdi
.LEHB6:
	call	_Z8showMeanSt6vectorIfSaIfEE
.LEHE6:
	movq	%r12, %rdi
	call	_ZNSt6vectorIfSaIfEED1Ev
	movq	%rbp, %rdi
	call	_ZNSt6vectorIfSaIfEED1Ev
	leaq	112(%rsp), %rdi
	call	_ZNSt6vectorIfSaIfEED1Ev
	movq	8(%rsp), %rdi
	call	_ZNSt6vectorIfSaIfEED1Ev
	movq	2097336(%rsp), %rax
	subq	%fs:40, %rax
	je	.L56
	jmp	.L64
.L58:
	endbr64
	jmp	.L66
.L59:
	endbr64
	jmp	.L66
.L60:
	endbr64
.L66:
	movq	%rax, %rbx
.L54:
	movq	%r12, %rdi
	call	_ZNSt6vectorIfSaIfEED1Ev
	jmp	.L52
.L57:
	endbr64
	movq	%rax, %rbx
.L52:
	leaq	136(%rsp), %rdi
	call	_ZNSt6vectorIfSaIfEED1Ev
	leaq	112(%rsp), %rdi
	call	_ZNSt6vectorIfSaIfEED1Ev
	leaq	88(%rsp), %rdi
	call	_ZNSt6vectorIfSaIfEED1Ev
	movq	2097336(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L64
	movq	%rbx, %rdi
.LEHB7:
	call	_Unwind_Resume@PLT
.LEHE7:
.L64:
	call	__stack_chk_fail@PLT
.L56:
	addq	$2097352, %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
.LFE3999:
	.globl	__gxx_personality_v0
	.section	.gcc_except_table,"a",@progbits
.LLSDA3999:
	.byte	0xff
	.byte	0xff
	.byte	0x1
	.uleb128 .LLSDACSE3999-.LLSDACSB3999
.LLSDACSB3999:
	.uleb128 .LEHB0-.LFB3999
	.uleb128 .LEHE0-.LEHB0
	.uleb128 0
	.uleb128 0
	.uleb128 .LEHB1-.LFB3999
	.uleb128 .LEHE1-.LEHB1
	.uleb128 .L57-.LFB3999
	.uleb128 0
	.uleb128 .LEHB2-.LFB3999
	.uleb128 .LEHE2-.LEHB2
	.uleb128 .L58-.LFB3999
	.uleb128 0
	.uleb128 .LEHB3-.LFB3999
	.uleb128 .LEHE3-.LEHB3
	.uleb128 .L57-.LFB3999
	.uleb128 0
	.uleb128 .LEHB4-.LFB3999
	.uleb128 .LEHE4-.LEHB4
	.uleb128 .L59-.LFB3999
	.uleb128 0
	.uleb128 .LEHB5-.LFB3999
	.uleb128 .LEHE5-.LEHB5
	.uleb128 .L57-.LFB3999
	.uleb128 0
	.uleb128 .LEHB6-.LFB3999
	.uleb128 .LEHE6-.LEHB6
	.uleb128 .L60-.LFB3999
	.uleb128 0
	.uleb128 .LEHB7-.LFB3999
	.uleb128 .LEHE7-.LEHB7
	.uleb128 0
	.uleb128 0
.LLSDACSE3999:
	.section	.text.startup
	.size	main, .-main
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC1:
	.long	0
	.long	1083129856
	.hidden	DW.ref.__gxx_personality_v0
	.weak	DW.ref.__gxx_personality_v0
	.section	.data.rel.local.DW.ref.__gxx_personality_v0,"awG",@progbits,DW.ref.__gxx_personality_v0,comdat
	.align 8
	.type	DW.ref.__gxx_personality_v0, @object
	.size	DW.ref.__gxx_personality_v0, 8
DW.ref.__gxx_personality_v0:
	.quad	__gxx_personality_v0
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:


#include <hip/hip_runtime.h>
#include <iostream>
#include <stdio.h>
#include <vector>

#define MAX_THREADS 256
#define SIZE 524288

#define __START__ hipEventCreate(&start); hipEventCreate(&stop); hipEventRecord(start, 0);
#define __STOP__(_V) hipEventRecord(stop, 0); hipEventSynchronize(stop); hipEventElapsedTime(&time, start, stop); _V.push_back(time); hipEventDestroy(start); hipEventDestroy(stop);
#define __NEXT__(_V) __STOP__(_V) __START__
#define __START_BIS__ hipEventCreate(&startBis); hipEventCreate(&stopBis); hipEventRecord(startBis, 0);
#define __STOP_BIS__(_V) hipEventRecord(stopBis, 0); hipEventSynchronize(stopBis); hipEventElapsedTime(&time, startBis, stopBis); _V.push_back(time); hipEventDestroy(startBis); hipEventDestroy(stopBis);
#define __NEXT_BIS__(_V) __STOP_BIS__(_V) __START_BIS__

__global__ void sumall_kernel(float *d_vector, float *d_result)
{
    __shared__ float cache[MAX_THREADS];

    int cacheIdx = threadIdx.x;
    int i = blockIdx.x * blockDim.x + threadIdx.x;
    cache[cacheIdx] = i >= SIZE ? 0. : d_vector[i];
    __syncthreads();

    if (i >= SIZE)
        return;

    int padding = blockDim.x/2;
    while (padding != 0)
    {
        if (cacheIdx < padding)
            cache[cacheIdx] += cache[cacheIdx + padding];

        __syncthreads();
        padding /= 2;
    }

    if (cacheIdx == 0)
        atomicAdd(&d_result[0], cache[0]);
}

void showMean(std::vector<float> v)
{
    float sum(0);
    for (unsigned int i(0) ; i!=v.size() ; i++)
        sum += v[i];
    std::cout << 1000.*sum/v.size() << " microseconds" << std::endl;
}

int main(int argc, char **argv)
{
    std::cout << "SIZE (vs Reduce-Native): " << SIZE << std::endl;
    hipEvent_t start, stop, startBis, stopBis;
    std::vector<float> cudaRun, cudaKRun, nativeRun;
    float time(0);
    
    hipFree(0); // Force runtime API context establishment
    float h_vector[SIZE]; // For input and output
    for (unsigned int i(0) ; i!=SIZE ; i++)
        h_vector[i] = i;
    float h_result;
    
    for (unsigned int i(0) ; i!=1000 ; i++)
    {
        float *d_vector, *d_result;
        
        __START__
        hipMalloc(&d_vector, SIZE*sizeof(float));
        hipMalloc(&d_result, sizeof(float));
        hipMemcpy(d_vector, h_vector, SIZE*sizeof(float), hipMemcpyHostToDevice);
        hipMemset(d_result, 0, sizeof(float));
        __START_BIS__
        sumall_kernel<<<(SIZE+MAX_THREADS-1)/MAX_THREADS, MAX_THREADS>>>(d_vector, d_result);
        hipDeviceSynchronize(); // Block until the device is finished
        __STOP_BIS__(cudaKRun);
        hipMemcpy(h_vector, d_vector, SIZE*sizeof(float), hipMemcpyDeviceToHost);
        hipMemcpy(&h_result, d_result, sizeof(float), hipMemcpyDeviceToHost);
        hipFree(d_vector);
        hipFree(d_result);
        __NEXT__(cudaRun)
        
        h_result = 0.;
        for (unsigned int i(0) ; i!=SIZE ; i++)
            h_result += h_vector[i];
        __STOP__(nativeRun)
    }
    showMean(cudaRun);
    showMean(cudaKRun);
    showMean(nativeRun);
}    


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

                                        # End of file scope inline assembly
	.globl	_Z28__device_stub__sumall_kernelPfS_ # -- Begin function _Z28__device_stub__sumall_kernelPfS_
	.type	_Z28__device_stub__sumall_kernelPfS_,@function
_Z28__device_stub__sumall_kernelPfS_:   # @_Z28__device_stub__sumall_kernelPfS_
	.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	$80, %rsp
	.cfi_def_cfa_offset 128
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	24(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	16(%rsp), %rcx
	movq	%rsi, (%rcx)
	leaq	64(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	leaq	48(%rsp), %r14
	leaq	32(%rsp), %r15
	leaq	8(%rsp), %r12
	movq	%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	$_Z13sumall_kernelPfS_, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$96, %rsp
	.cfi_adjust_cfa_offset -96
	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	_Z28__device_stub__sumall_kernelPfS_, .Lfunc_end0-_Z28__device_stub__sumall_kernelPfS_
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z8showMeanSt6vectorIfSaIfEE
.LCPI1_0:
	.quad	0x408f400000000000              # double 1000
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0
.LCPI1_1:
	.long	1127219200                      # 0x43300000
	.long	1160773632                      # 0x45300000
	.long	0                               # 0x0
	.long	0                               # 0x0
.LCPI1_2:
	.quad	0x4330000000000000              # double 4503599627370496
	.quad	0x4530000000000000              # double 1.9342813113834067E+25
	.text
	.globl	_Z8showMeanSt6vectorIfSaIfEE
	.type	_Z8showMeanSt6vectorIfSaIfEE,@function
_Z8showMeanSt6vectorIfSaIfEE:           # @_Z8showMeanSt6vectorIfSaIfEE
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset %rbx, -16
	movq	(%rdi), %rcx
	movq	8(%rdi), %rdx
	movq	%rdx, %rax
	subq	%rcx, %rax
	sarq	$2, %rax
	cmpq	%rcx, %rdx
	je	.LBB1_1
# %bb.4:                                # %.lr.ph.preheader
	xorps	%xmm0, %xmm0
	xorl	%edx, %edx
.LBB1_5:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	addss	(%rcx,%rdx,4), %xmm0
	incq	%rdx
	movl	%edx, %esi
	cmpq	%rsi, %rax
	jne	.LBB1_5
# %bb.2:                                # %._crit_edge.loopexit
	cvtss2sd	%xmm0, %xmm0
	mulsd	.LCPI1_0(%rip), %xmm0
	jmp	.LBB1_3
.LBB1_1:
	xorpd	%xmm0, %xmm0
.LBB1_3:                                # %._crit_edge
	movq	%rax, %xmm1
	punpckldq	.LCPI1_1(%rip), %xmm1   # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
	subpd	.LCPI1_2(%rip), %xmm1
	movapd	%xmm1, %xmm2
	unpckhpd	%xmm1, %xmm2                    # xmm2 = xmm2[1],xmm1[1]
	addsd	%xmm1, %xmm2
	divsd	%xmm2, %xmm0
	movl	$_ZSt4cout, %edi
	callq	_ZNSo9_M_insertIdEERSoT_
	movq	%rax, %rbx
	movl	$.L.str, %esi
	movl	$13, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	(%rbx), %rax
	movq	-24(%rax), %rdi
	addq	%rbx, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movq	%rbx, %rdi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	_ZNSo5flushEv                   # TAILCALL
.Lfunc_end1:
	.size	_Z8showMeanSt6vectorIfSaIfEE, .Lfunc_end1-_Z8showMeanSt6vectorIfSaIfEE
	.cfi_endproc
                                        # -- End function
	.globl	main                            # -- Begin function main
	.type	main,@function
main:                                   # @main
.Lfunc_begin0:
	.cfi_startproc
	.cfi_personality 3, __gxx_personality_v0
	.cfi_lsda 3, .Lexception0
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	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	$2097384, %rsp                  # imm = 0x2000E8
	.cfi_def_cfa_offset 2097440
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	$_ZSt4cout, %edi
	movl	$.L.str.1, %esi
	movl	$25, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	$_ZSt4cout, %edi
	movl	$524288, %esi                   # imm = 0x80000
	callq	_ZNSolsEi
	movq	%rax, %rbx
	movq	(%rax), %rax
	movq	-24(%rax), %rdi
	addq	%rbx, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movq	%rbx, %rdi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	xorl	%eax, %eax
	movq	%rax, 144(%rsp)
	xorps	%xmm0, %xmm0
	movaps	%xmm0, 128(%rsp)
	movq	%rax, 112(%rsp)
	movaps	%xmm0, 96(%rsp)
	movq	%rax, 80(%rsp)
	movaps	%xmm0, 64(%rsp)
	movl	$0, 4(%rsp)
.Ltmp0:
	xorl	%edi, %edi
	callq	hipFree
.Ltmp1:
# %bb.1:
	xorl	%eax, %eax
.LBB2_2:                                # =>This Inner Loop Header: Depth=1
	movl	%eax, %ecx
	xorps	%xmm0, %xmm0
	cvtsi2ss	%rcx, %xmm0
	movss	%xmm0, 224(%rsp,%rax,4)
	incq	%rax
	cmpq	$524288, %rax                   # imm = 0x80000
	jne	.LBB2_2
# %bb.3:
	xorl	%ebp, %ebp
	leaq	16(%rsp), %rbx
	leaq	8(%rsp), %r14
	leaq	224(%rsp), %r13
	leaq	4(%rsp), %r15
	leaq	60(%rsp), %r12
.LBB2_4:                                # =>This Loop Header: Depth=1
                                        #     Child Loop BB2_42 Depth 2
.Ltmp3:
	movq	%rbx, %rdi
	callq	hipEventCreate
.Ltmp4:
# %bb.5:                                #   in Loop: Header=BB2_4 Depth=1
.Ltmp5:
	movq	%r14, %rdi
	callq	hipEventCreate
.Ltmp6:
# %bb.6:                                #   in Loop: Header=BB2_4 Depth=1
	movq	16(%rsp), %rdi
.Ltmp7:
	xorl	%esi, %esi
	callq	hipEventRecord
.Ltmp8:
# %bb.7:                                #   in Loop: Header=BB2_4 Depth=1
.Ltmp9:
	movl	$2097152, %esi                  # imm = 0x200000
	leaq	32(%rsp), %rdi
	callq	hipMalloc
.Ltmp10:
# %bb.8:                                # %_ZL9hipMallocIfE10hipError_tPPT_m.exit
                                        #   in Loop: Header=BB2_4 Depth=1
.Ltmp11:
	movl	$4, %esi
	leaq	24(%rsp), %rdi
	callq	hipMalloc
.Ltmp12:
# %bb.9:                                # %_ZL9hipMallocIfE10hipError_tPPT_m.exit23
                                        #   in Loop: Header=BB2_4 Depth=1
	movq	32(%rsp), %rdi
.Ltmp13:
	movl	$2097152, %edx                  # imm = 0x200000
	movq	%r13, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
.Ltmp14:
# %bb.10:                               #   in Loop: Header=BB2_4 Depth=1
	movq	24(%rsp), %rdi
.Ltmp15:
	movl	$4, %edx
	xorl	%esi, %esi
	callq	hipMemset
.Ltmp16:
# %bb.11:                               #   in Loop: Header=BB2_4 Depth=1
.Ltmp17:
	leaq	48(%rsp), %rdi
	callq	hipEventCreate
.Ltmp18:
# %bb.12:                               #   in Loop: Header=BB2_4 Depth=1
.Ltmp19:
	leaq	40(%rsp), %rdi
	callq	hipEventCreate
.Ltmp20:
# %bb.13:                               #   in Loop: Header=BB2_4 Depth=1
	movq	48(%rsp), %rdi
.Ltmp21:
	xorl	%esi, %esi
	callq	hipEventRecord
.Ltmp22:
# %bb.14:                               #   in Loop: Header=BB2_4 Depth=1
.Ltmp23:
	movabsq	$4294969344, %rdi               # imm = 0x100000800
	movl	$1, %esi
	movabsq	$4294967552, %rdx               # imm = 0x100000100
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
.Ltmp24:
# %bb.15:                               #   in Loop: Header=BB2_4 Depth=1
	testl	%eax, %eax
	jne	.LBB2_17
# %bb.16:                               #   in Loop: Header=BB2_4 Depth=1
	movq	32(%rsp), %rdi
	movq	24(%rsp), %rsi
.Ltmp25:
	callq	_Z28__device_stub__sumall_kernelPfS_
.Ltmp26:
.LBB2_17:                               #   in Loop: Header=BB2_4 Depth=1
.Ltmp27:
	callq	hipDeviceSynchronize
.Ltmp28:
# %bb.18:                               #   in Loop: Header=BB2_4 Depth=1
	movq	40(%rsp), %rdi
.Ltmp29:
	xorl	%esi, %esi
	callq	hipEventRecord
.Ltmp30:
# %bb.19:                               #   in Loop: Header=BB2_4 Depth=1
	movq	40(%rsp), %rdi
.Ltmp31:
	callq	hipEventSynchronize
.Ltmp32:
# %bb.20:                               #   in Loop: Header=BB2_4 Depth=1
	movq	48(%rsp), %rsi
	movq	40(%rsp), %rdx
.Ltmp33:
	movq	%r15, %rdi
	callq	hipEventElapsedTime
.Ltmp34:
# %bb.21:                               #   in Loop: Header=BB2_4 Depth=1
	movq	104(%rsp), %rsi
	cmpq	112(%rsp), %rsi
	je	.LBB2_23
# %bb.22:                               #   in Loop: Header=BB2_4 Depth=1
	movss	4(%rsp), %xmm0                  # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, (%rsi)
	addq	$4, %rsi
	movq	%rsi, 104(%rsp)
	jmp	.LBB2_24
.LBB2_23:                               #   in Loop: Header=BB2_4 Depth=1
.Ltmp35:
	leaq	96(%rsp), %rdi
	movq	%r15, %rdx
	callq	_ZNSt6vectorIfSaIfEE17_M_realloc_insertIJRKfEEEvN9__gnu_cxx17__normal_iteratorIPfS1_EEDpOT_
.Ltmp36:
.LBB2_24:                               # %_ZNSt6vectorIfSaIfEE9push_backERKf.exit
                                        #   in Loop: Header=BB2_4 Depth=1
	movq	48(%rsp), %rdi
.Ltmp37:
	callq	hipEventDestroy
.Ltmp38:
# %bb.25:                               #   in Loop: Header=BB2_4 Depth=1
	movq	40(%rsp), %rdi
.Ltmp39:
	callq	hipEventDestroy
.Ltmp40:
# %bb.26:                               #   in Loop: Header=BB2_4 Depth=1
	movq	32(%rsp), %rsi
.Ltmp41:
	movl	$2097152, %edx                  # imm = 0x200000
	movq	%r13, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
.Ltmp42:
# %bb.27:                               #   in Loop: Header=BB2_4 Depth=1
	movq	24(%rsp), %rsi
.Ltmp43:
	movl	$4, %edx
	movq	%r12, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
.Ltmp44:
# %bb.28:                               #   in Loop: Header=BB2_4 Depth=1
	movq	32(%rsp), %rdi
.Ltmp45:
	callq	hipFree
.Ltmp46:
# %bb.29:                               #   in Loop: Header=BB2_4 Depth=1
	movq	24(%rsp), %rdi
.Ltmp47:
	callq	hipFree
.Ltmp48:
# %bb.30:                               #   in Loop: Header=BB2_4 Depth=1
	movq	8(%rsp), %rdi
.Ltmp49:
	xorl	%esi, %esi
	callq	hipEventRecord
.Ltmp50:
# %bb.31:                               #   in Loop: Header=BB2_4 Depth=1
	movq	8(%rsp), %rdi
.Ltmp51:
	callq	hipEventSynchronize
.Ltmp52:
# %bb.32:                               #   in Loop: Header=BB2_4 Depth=1
	movq	16(%rsp), %rsi
	movq	8(%rsp), %rdx
.Ltmp53:
	movq	%r15, %rdi
	callq	hipEventElapsedTime
.Ltmp54:
# %bb.33:                               #   in Loop: Header=BB2_4 Depth=1
	movq	136(%rsp), %rsi
	cmpq	144(%rsp), %rsi
	je	.LBB2_35
# %bb.34:                               #   in Loop: Header=BB2_4 Depth=1
	movss	4(%rsp), %xmm0                  # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, (%rsi)
	addq	$4, %rsi
	movq	%rsi, 136(%rsp)
	jmp	.LBB2_36
.LBB2_35:                               #   in Loop: Header=BB2_4 Depth=1
.Ltmp55:
	leaq	128(%rsp), %rdi
	movq	%r15, %rdx
	callq	_ZNSt6vectorIfSaIfEE17_M_realloc_insertIJRKfEEEvN9__gnu_cxx17__normal_iteratorIPfS1_EEDpOT_
.Ltmp56:
.LBB2_36:                               # %_ZNSt6vectorIfSaIfEE9push_backERKf.exit26
                                        #   in Loop: Header=BB2_4 Depth=1
	movq	16(%rsp), %rdi
.Ltmp57:
	callq	hipEventDestroy
.Ltmp58:
# %bb.37:                               #   in Loop: Header=BB2_4 Depth=1
	movq	8(%rsp), %rdi
.Ltmp59:
	callq	hipEventDestroy
.Ltmp60:
# %bb.38:                               #   in Loop: Header=BB2_4 Depth=1
.Ltmp61:
	movq	%rbx, %rdi
	callq	hipEventCreate
.Ltmp62:
# %bb.39:                               #   in Loop: Header=BB2_4 Depth=1
.Ltmp63:
	movq	%r14, %rdi
	callq	hipEventCreate
.Ltmp64:
# %bb.40:                               #   in Loop: Header=BB2_4 Depth=1
	movq	16(%rsp), %rdi
.Ltmp65:
	xorl	%esi, %esi
	callq	hipEventRecord
.Ltmp66:
# %bb.41:                               # %.preheader.preheader
                                        #   in Loop: Header=BB2_4 Depth=1
	xorps	%xmm0, %xmm0
	xorl	%eax, %eax
.LBB2_42:                               # %.preheader
                                        #   Parent Loop BB2_4 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	addss	224(%rsp,%rax,4), %xmm0
	incq	%rax
	cmpq	$524288, %rax                   # imm = 0x80000
	jne	.LBB2_42
# %bb.43:                               #   in Loop: Header=BB2_4 Depth=1
	movss	%xmm0, 60(%rsp)
	movq	8(%rsp), %rdi
.Ltmp67:
	xorl	%esi, %esi
	callq	hipEventRecord
.Ltmp68:
# %bb.44:                               #   in Loop: Header=BB2_4 Depth=1
	movq	8(%rsp), %rdi
.Ltmp69:
	callq	hipEventSynchronize
.Ltmp70:
# %bb.45:                               #   in Loop: Header=BB2_4 Depth=1
	movq	16(%rsp), %rsi
	movq	8(%rsp), %rdx
.Ltmp71:
	movq	%r15, %rdi
	callq	hipEventElapsedTime
.Ltmp72:
# %bb.46:                               #   in Loop: Header=BB2_4 Depth=1
	movq	72(%rsp), %rsi
	cmpq	80(%rsp), %rsi
	je	.LBB2_48
# %bb.47:                               #   in Loop: Header=BB2_4 Depth=1
	movss	4(%rsp), %xmm0                  # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, (%rsi)
	addq	$4, %rsi
	movq	%rsi, 72(%rsp)
	jmp	.LBB2_49
.LBB2_48:                               #   in Loop: Header=BB2_4 Depth=1
.Ltmp73:
	leaq	64(%rsp), %rdi
	movq	%r15, %rdx
	callq	_ZNSt6vectorIfSaIfEE17_M_realloc_insertIJRKfEEEvN9__gnu_cxx17__normal_iteratorIPfS1_EEDpOT_
.Ltmp74:
.LBB2_49:                               # %_ZNSt6vectorIfSaIfEE9push_backERKf.exit29
                                        #   in Loop: Header=BB2_4 Depth=1
	movq	16(%rsp), %rdi
.Ltmp75:
	callq	hipEventDestroy
.Ltmp76:
# %bb.50:                               #   in Loop: Header=BB2_4 Depth=1
	movq	8(%rsp), %rdi
.Ltmp77:
	callq	hipEventDestroy
.Ltmp78:
# %bb.51:                               #   in Loop: Header=BB2_4 Depth=1
	incl	%ebp
	cmpl	$1000, %ebp                     # imm = 0x3E8
	jne	.LBB2_4
# %bb.52:
.Ltmp80:
	leaq	200(%rsp), %rdi
	leaq	128(%rsp), %rsi
	callq	_ZNSt6vectorIfSaIfEEC2ERKS1_
.Ltmp81:
# %bb.53:
.Ltmp82:
	leaq	200(%rsp), %rdi
	callq	_Z8showMeanSt6vectorIfSaIfEE
.Ltmp83:
# %bb.54:
	movq	200(%rsp), %rdi
	testq	%rdi, %rdi
	je	.LBB2_56
# %bb.55:
	callq	_ZdlPv
.LBB2_56:                               # %_ZNSt6vectorIfSaIfEED2Ev.exit
.Ltmp85:
	leaq	176(%rsp), %rdi
	leaq	96(%rsp), %rsi
	callq	_ZNSt6vectorIfSaIfEEC2ERKS1_
.Ltmp86:
# %bb.57:
.Ltmp87:
	leaq	176(%rsp), %rdi
	callq	_Z8showMeanSt6vectorIfSaIfEE
.Ltmp88:
# %bb.58:
	movq	176(%rsp), %rdi
	testq	%rdi, %rdi
	je	.LBB2_60
# %bb.59:
	callq	_ZdlPv
.LBB2_60:                               # %_ZNSt6vectorIfSaIfEED2Ev.exit31
.Ltmp90:
	leaq	152(%rsp), %rdi
	leaq	64(%rsp), %rsi
	callq	_ZNSt6vectorIfSaIfEEC2ERKS1_
.Ltmp91:
# %bb.61:
.Ltmp93:
	leaq	152(%rsp), %rdi
	callq	_Z8showMeanSt6vectorIfSaIfEE
.Ltmp94:
# %bb.62:
	movq	152(%rsp), %rdi
	testq	%rdi, %rdi
	je	.LBB2_64
# %bb.63:
	callq	_ZdlPv
.LBB2_64:                               # %_ZNSt6vectorIfSaIfEED2Ev.exit33
	movq	64(%rsp), %rdi
	testq	%rdi, %rdi
	je	.LBB2_66
# %bb.65:
	callq	_ZdlPv
.LBB2_66:                               # %_ZNSt6vectorIfSaIfEED2Ev.exit35
	movq	96(%rsp), %rdi
	testq	%rdi, %rdi
	je	.LBB2_68
# %bb.67:
	callq	_ZdlPv
.LBB2_68:                               # %_ZNSt6vectorIfSaIfEED2Ev.exit37
	movq	128(%rsp), %rdi
	testq	%rdi, %rdi
	je	.LBB2_70
# %bb.69:
	callq	_ZdlPv
.LBB2_70:                               # %_ZNSt6vectorIfSaIfEED2Ev.exit39
	xorl	%eax, %eax
	addq	$2097384, %rsp                  # imm = 0x2000E8
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.LBB2_71:
	.cfi_def_cfa_offset 2097440
.Ltmp95:
	movq	%rax, %rbx
	movq	152(%rsp), %rdi
	jmp	.LBB2_74
.LBB2_72:
.Ltmp89:
	movq	%rax, %rbx
	movq	176(%rsp), %rdi
	jmp	.LBB2_74
.LBB2_73:
.Ltmp84:
	movq	%rax, %rbx
	movq	200(%rsp), %rdi
.LBB2_74:
	testq	%rdi, %rdi
	je	.LBB2_80
# %bb.75:
	callq	_ZdlPv
	jmp	.LBB2_80
.LBB2_76:                               # %.thread
.Ltmp2:
	movq	%rax, %rbx
	jmp	.LBB2_82
.LBB2_77:
.Ltmp92:
	jmp	.LBB2_79
.LBB2_78:
.Ltmp79:
.LBB2_79:
	movq	%rax, %rbx
.LBB2_80:
	movq	64(%rsp), %rdi
	testq	%rdi, %rdi
	je	.LBB2_82
# %bb.81:
	callq	_ZdlPv
.LBB2_82:                               # %_ZNSt6vectorIfSaIfEED2Ev.exit47
	movq	96(%rsp), %rdi
	testq	%rdi, %rdi
	je	.LBB2_84
# %bb.83:
	callq	_ZdlPv
.LBB2_84:                               # %_ZNSt6vectorIfSaIfEED2Ev.exit49
	movq	128(%rsp), %rdi
	testq	%rdi, %rdi
	je	.LBB2_86
# %bb.85:
	callq	_ZdlPv
.LBB2_86:                               # %_ZNSt6vectorIfSaIfEED2Ev.exit51
	movq	%rbx, %rdi
	callq	_Unwind_Resume@PLT
.Lfunc_end2:
	.size	main, .Lfunc_end2-main
	.cfi_endproc
	.section	.gcc_except_table,"a",@progbits
	.p2align	2, 0x0
GCC_except_table2:
.Lexception0:
	.byte	255                             # @LPStart Encoding = omit
	.byte	255                             # @TType Encoding = omit
	.byte	1                               # Call site Encoding = uleb128
	.uleb128 .Lcst_end0-.Lcst_begin0
.Lcst_begin0:
	.uleb128 .Lfunc_begin0-.Lfunc_begin0    # >> Call Site 1 <<
	.uleb128 .Ltmp0-.Lfunc_begin0           #   Call between .Lfunc_begin0 and .Ltmp0
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp0-.Lfunc_begin0           # >> Call Site 2 <<
	.uleb128 .Ltmp1-.Ltmp0                  #   Call between .Ltmp0 and .Ltmp1
	.uleb128 .Ltmp2-.Lfunc_begin0           #     jumps to .Ltmp2
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp3-.Lfunc_begin0           # >> Call Site 3 <<
	.uleb128 .Ltmp78-.Ltmp3                 #   Call between .Ltmp3 and .Ltmp78
	.uleb128 .Ltmp79-.Lfunc_begin0          #     jumps to .Ltmp79
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp80-.Lfunc_begin0          # >> Call Site 4 <<
	.uleb128 .Ltmp81-.Ltmp80                #   Call between .Ltmp80 and .Ltmp81
	.uleb128 .Ltmp92-.Lfunc_begin0          #     jumps to .Ltmp92
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp82-.Lfunc_begin0          # >> Call Site 5 <<
	.uleb128 .Ltmp83-.Ltmp82                #   Call between .Ltmp82 and .Ltmp83
	.uleb128 .Ltmp84-.Lfunc_begin0          #     jumps to .Ltmp84
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp85-.Lfunc_begin0          # >> Call Site 6 <<
	.uleb128 .Ltmp86-.Ltmp85                #   Call between .Ltmp85 and .Ltmp86
	.uleb128 .Ltmp92-.Lfunc_begin0          #     jumps to .Ltmp92
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp87-.Lfunc_begin0          # >> Call Site 7 <<
	.uleb128 .Ltmp88-.Ltmp87                #   Call between .Ltmp87 and .Ltmp88
	.uleb128 .Ltmp89-.Lfunc_begin0          #     jumps to .Ltmp89
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp90-.Lfunc_begin0          # >> Call Site 8 <<
	.uleb128 .Ltmp91-.Ltmp90                #   Call between .Ltmp90 and .Ltmp91
	.uleb128 .Ltmp92-.Lfunc_begin0          #     jumps to .Ltmp92
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp93-.Lfunc_begin0          # >> Call Site 9 <<
	.uleb128 .Ltmp94-.Ltmp93                #   Call between .Ltmp93 and .Ltmp94
	.uleb128 .Ltmp95-.Lfunc_begin0          #     jumps to .Ltmp95
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp94-.Lfunc_begin0          # >> Call Site 10 <<
	.uleb128 .Lfunc_end2-.Ltmp94            #   Call between .Ltmp94 and .Lfunc_end2
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
.Lcst_end0:
	.p2align	2, 0x0
                                        # -- End function
	.section	.text._ZNSt6vectorIfSaIfEEC2ERKS1_,"axG",@progbits,_ZNSt6vectorIfSaIfEEC2ERKS1_,comdat
	.weak	_ZNSt6vectorIfSaIfEEC2ERKS1_    # -- Begin function _ZNSt6vectorIfSaIfEEC2ERKS1_
	.p2align	1, 0x90
	.type	_ZNSt6vectorIfSaIfEEC2ERKS1_,@function
_ZNSt6vectorIfSaIfEEC2ERKS1_:           # @_ZNSt6vectorIfSaIfEEC2ERKS1_
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r12
	.cfi_def_cfa_offset 32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	pushq	%rax
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -40
	.cfi_offset %r12, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rsi, %r14
	movq	%rdi, %rbx
	movq	8(%rsi), %rax
	movq	(%rsi), %rcx
	movq	%rax, %r12
	subq	%rcx, %r12
	sarq	$2, %r12
	xorps	%xmm0, %xmm0
	movups	%xmm0, (%rdi)
	movq	$0, 16(%rdi)
	cmpq	%rcx, %rax
	je	.LBB3_1
# %bb.2:
	movq	%rbx, %rdi
	movq	%r12, %rsi
	xorl	%edx, %edx
	callq	_ZNSt15__new_allocatorIfE8allocateEmPKv
	movq	%rax, %r15
	jmp	.LBB3_3
.LBB3_1:
	xorl	%r15d, %r15d
.LBB3_3:
	movq	%r15, (%rbx)
	movq	%r15, 8(%rbx)
	leaq	(%r15,%r12,4), %rax
	movq	%rax, 16(%rbx)
	movq	(%r14), %rsi
	movq	8(%r14), %r14
	subq	%rsi, %r14
	cmpq	$5, %r14
	jl	.LBB3_5
# %bb.4:
	movq	%r15, %rdi
	movq	%r14, %rdx
	callq	memmove@PLT
.LBB3_7:
	addq	%r14, %r15
	movq	%r15, 8(%rbx)
	addq	$8, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.LBB3_5:
	.cfi_def_cfa_offset 48
	cmpq	$4, %r14
	jne	.LBB3_7
# %bb.6:
	movss	(%rsi), %xmm0                   # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, (%r15)
	jmp	.LBB3_7
.Lfunc_end3:
	.size	_ZNSt6vectorIfSaIfEEC2ERKS1_, .Lfunc_end3-_ZNSt6vectorIfSaIfEEC2ERKS1_
	.cfi_endproc
                                        # -- End function
	.section	.text._ZNSt6vectorIfSaIfEE17_M_realloc_insertIJRKfEEEvN9__gnu_cxx17__normal_iteratorIPfS1_EEDpOT_,"axG",@progbits,_ZNSt6vectorIfSaIfEE17_M_realloc_insertIJRKfEEEvN9__gnu_cxx17__normal_iteratorIPfS1_EEDpOT_,comdat
	.weak	_ZNSt6vectorIfSaIfEE17_M_realloc_insertIJRKfEEEvN9__gnu_cxx17__normal_iteratorIPfS1_EEDpOT_ # -- Begin function _ZNSt6vectorIfSaIfEE17_M_realloc_insertIJRKfEEEvN9__gnu_cxx17__normal_iteratorIPfS1_EEDpOT_
	.p2align	1, 0x90
	.type	_ZNSt6vectorIfSaIfEE17_M_realloc_insertIJRKfEEEvN9__gnu_cxx17__normal_iteratorIPfS1_EEDpOT_,@function
_ZNSt6vectorIfSaIfEE17_M_realloc_insertIJRKfEEEvN9__gnu_cxx17__normal_iteratorIPfS1_EEDpOT_: # @_ZNSt6vectorIfSaIfEE17_M_realloc_insertIJRKfEEEvN9__gnu_cxx17__normal_iteratorIPfS1_EEDpOT_
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rdx, (%rsp)                    # 8-byte Spill
	movq	%rsi, %r12
	movq	%rdi, %rbx
	movl	$1, %esi
	movl	$.L.str.2, %edx
	callq	_ZNKSt6vectorIfSaIfEE12_M_check_lenEmPKc
	movq	(%rbx), %r13
	movq	8(%rbx), %r15
	movq	%r12, 8(%rsp)                   # 8-byte Spill
	subq	%r13, %r12
	movq	%r12, %r14
	sarq	$2, %r14
	testq	%rax, %rax
	movq	%rax, 16(%rsp)                  # 8-byte Spill
	je	.LBB4_1
# %bb.2:
	movq	%rbx, %rdi
	movq	%rax, %rsi
	xorl	%edx, %edx
	callq	_ZNSt15__new_allocatorIfE8allocateEmPKv
	movq	%rax, %rbp
	jmp	.LBB4_3
.LBB4_1:
	xorl	%ebp, %ebp
.LBB4_3:                                # %_ZNSt12_Vector_baseIfSaIfEE11_M_allocateEm.exit
	movq	(%rsp), %rax                    # 8-byte Reload
	movss	(%rax), %xmm0                   # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, (%rbp,%r14,4)
	testq	%r12, %r12
	jle	.LBB4_5
# %bb.4:
	movq	%rbp, %rdi
	movq	%r13, %rsi
	movq	%r12, %rdx
	callq	memmove@PLT
.LBB4_5:                                # %_ZNSt6vectorIfSaIfEE11_S_relocateEPfS2_S2_RS0_.exit
	addq	%rbp, %r12
	addq	$4, %r12
	movq	8(%rsp), %rsi                   # 8-byte Reload
	subq	%rsi, %r15
	testq	%r15, %r15
	jle	.LBB4_7
# %bb.6:
	movq	%r12, %rdi
	movq	%r15, %rdx
	callq	memmove@PLT
.LBB4_7:                                # %_ZNSt6vectorIfSaIfEE11_S_relocateEPfS2_S2_RS0_.exit16
	testq	%r13, %r13
	je	.LBB4_9
# %bb.8:
	movq	%r13, %rdi
	callq	_ZdlPv
.LBB4_9:                                # %_ZNSt12_Vector_baseIfSaIfEE13_M_deallocateEPfm.exit
	addq	%r15, %r12
	movq	%rbp, (%rbx)
	movq	%r12, 8(%rbx)
	movq	16(%rsp), %rax                  # 8-byte Reload
	leaq	(,%rax,4), %rax
	addq	%rbp, %rax
	movq	%rax, 16(%rbx)
	addq	$24, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end4:
	.size	_ZNSt6vectorIfSaIfEE17_M_realloc_insertIJRKfEEEvN9__gnu_cxx17__normal_iteratorIPfS1_EEDpOT_, .Lfunc_end4-_ZNSt6vectorIfSaIfEE17_M_realloc_insertIJRKfEEEvN9__gnu_cxx17__normal_iteratorIPfS1_EEDpOT_
	.cfi_endproc
                                        # -- End function
	.section	.text._ZNKSt6vectorIfSaIfEE12_M_check_lenEmPKc,"axG",@progbits,_ZNKSt6vectorIfSaIfEE12_M_check_lenEmPKc,comdat
	.weak	_ZNKSt6vectorIfSaIfEE12_M_check_lenEmPKc # -- Begin function _ZNKSt6vectorIfSaIfEE12_M_check_lenEmPKc
	.p2align	1, 0x90
	.type	_ZNKSt6vectorIfSaIfEE12_M_check_lenEmPKc,@function
_ZNKSt6vectorIfSaIfEE12_M_check_lenEmPKc: # @_ZNKSt6vectorIfSaIfEE12_M_check_lenEmPKc
	.cfi_startproc
# %bb.0:
	movabsq	$2305843009213693951, %rcx      # imm = 0x1FFFFFFFFFFFFFFF
	movq	8(%rdi), %r8
	subq	(%rdi), %r8
	sarq	$2, %r8
	movq	%rcx, %rax
	subq	%r8, %rax
	cmpq	%rsi, %rax
	jb	.LBB5_2
# %bb.1:
	cmpq	%rsi, %r8
	cmovaq	%r8, %rsi
	leaq	(%rsi,%r8), %rax
	cmpq	%rcx, %rax
	cmovaeq	%rcx, %rax
	addq	%r8, %rsi
	cmovbq	%rcx, %rax
	retq
.LBB5_2:
	pushq	%rax
	.cfi_def_cfa_offset 16
	movq	%rdx, %rdi
	callq	_ZSt20__throw_length_errorPKc
.Lfunc_end5:
	.size	_ZNKSt6vectorIfSaIfEE12_M_check_lenEmPKc, .Lfunc_end5-_ZNKSt6vectorIfSaIfEE12_M_check_lenEmPKc
	.cfi_endproc
                                        # -- End function
	.section	.text._ZNSt15__new_allocatorIfE8allocateEmPKv,"axG",@progbits,_ZNSt15__new_allocatorIfE8allocateEmPKv,comdat
	.weak	_ZNSt15__new_allocatorIfE8allocateEmPKv # -- Begin function _ZNSt15__new_allocatorIfE8allocateEmPKv
	.p2align	1, 0x90
	.type	_ZNSt15__new_allocatorIfE8allocateEmPKv,@function
_ZNSt15__new_allocatorIfE8allocateEmPKv: # @_ZNSt15__new_allocatorIfE8allocateEmPKv
	.cfi_startproc
# %bb.0:
	pushq	%rax
	.cfi_def_cfa_offset 16
	movq	%rsi, %rax
	shrq	$61, %rax
	jne	.LBB6_1
# %bb.3:
	shlq	$2, %rsi
	movq	%rsi, %rdi
	popq	%rax
	.cfi_def_cfa_offset 8
	jmp	_Znwm                           # TAILCALL
.LBB6_1:
	.cfi_def_cfa_offset 16
	shrq	$62, %rsi
	je	.LBB6_2
# %bb.4:
	callq	_ZSt28__throw_bad_array_new_lengthv
.LBB6_2:
	callq	_ZSt17__throw_bad_allocv
.Lfunc_end6:
	.size	_ZNSt15__new_allocatorIfE8allocateEmPKv, .Lfunc_end6-_ZNSt15__new_allocatorIfE8allocateEmPKv
	.cfi_endproc
                                        # -- End function
	.text
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	jne	.LBB7_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB7_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z13sumall_kernelPfS_, %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_end7:
	.size	__hip_module_ctor, .Lfunc_end7-__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	.LBB8_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
.LBB8_2:
	retq
.Lfunc_end8:
	.size	__hip_module_dtor, .Lfunc_end8-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	_Z13sumall_kernelPfS_,@object   # @_Z13sumall_kernelPfS_
	.section	.rodata,"a",@progbits
	.globl	_Z13sumall_kernelPfS_
	.p2align	3, 0x0
_Z13sumall_kernelPfS_:
	.quad	_Z28__device_stub__sumall_kernelPfS_
	.size	_Z13sumall_kernelPfS_, 8

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	" microseconds"
	.size	.L.str, 14

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"SIZE (vs Reduce-Native): "
	.size	.L.str.1, 26

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

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z13sumall_kernelPfS_"
	.size	.L__unnamed_1, 22

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

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

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym _Z28__device_stub__sumall_kernelPfS_
	.addrsig_sym __gxx_personality_v0
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Unwind_Resume
	.addrsig_sym _Z13sumall_kernelPfS_
	.addrsig_sym _ZSt4cout
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z13sumall_kernelPfS_   ; -- Begin function _Z13sumall_kernelPfS_
	.globl	_Z13sumall_kernelPfS_
	.p2align	8
	.type	_Z13sumall_kernelPfS_,@function
_Z13sumall_kernelPfS_:                  ; @_Z13sumall_kernelPfS_
; %bb.0:
	s_clause 0x1
	s_load_b32 s4, s[0:1], 0x1c
	s_load_b128 s[0:3], s[0:1], 0x0
	s_waitcnt lgkmcnt(0)
	s_and_b32 s4, s4, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_mad_u64_u32 v[1:2], null, s15, s4, v[0:1]
	v_mov_b32_e32 v2, 0
	v_cmp_gt_i32_e32 vcc_lo, 0x80000, v1
	s_and_saveexec_b32 s5, vcc_lo
	s_cbranch_execz .LBB0_2
; %bb.1:
	v_ashrrev_i32_e32 v2, 31, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[1:2], 2, v[1:2]
	v_add_co_u32 v1, s0, s0, v1
	s_delay_alu instid0(VALU_DEP_1)
	v_add_co_ci_u32_e64 v2, s0, s1, v2, s0
	global_load_b32 v2, v[1:2], off
.LBB0_2:
	s_or_b32 exec_lo, exec_lo, s5
	v_lshlrev_b32_e32 v1, 2, v0
	s_waitcnt vmcnt(0)
	ds_store_b32 v1, v2
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	s_and_saveexec_b32 s0, vcc_lo
	s_cbranch_execz .LBB0_11
; %bb.3:                                ; %.preheader
	s_cmp_lt_u32 s4, 2
	s_cbranch_scc1 .LBB0_7
.LBB0_4:                                ; %.lr.ph
                                        ; =>This Inner Loop Header: Depth=1
	s_lshr_b32 s0, s4, 1
	s_mov_b32 s1, exec_lo
	v_cmpx_gt_u32_e64 s0, v0
	s_cbranch_execz .LBB0_6
; %bb.5:                                ;   in Loop: Header=BB0_4 Depth=1
	v_lshl_add_u32 v2, s0, 2, v1
	ds_load_b32 v2, v2
	ds_load_b32 v3, v1
	s_waitcnt lgkmcnt(0)
	v_add_f32_e32 v2, v2, v3
	ds_store_b32 v1, v2
.LBB0_6:                                ;   in Loop: Header=BB0_4 Depth=1
	s_or_b32 exec_lo, exec_lo, s1
	s_cmp_gt_u32 s4, 3
	s_mov_b32 s4, s0
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	s_cbranch_scc1 .LBB0_4
.LBB0_7:                                ; %._crit_edge
	v_cmp_eq_u32_e32 vcc_lo, 0, v0
	s_and_b32 exec_lo, exec_lo, vcc_lo
	s_cbranch_execz .LBB0_11
; %bb.8:
	s_mov_b32 s0, exec_lo
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mbcnt_lo_u32_b32 v0, s0, 0
	v_cmp_eq_u32_e32 vcc_lo, 0, v0
	s_and_b32 s1, exec_lo, vcc_lo
	s_delay_alu instid0(SALU_CYCLE_1)
	s_mov_b32 exec_lo, s1
	s_cbranch_execz .LBB0_11
; %bb.9:
	s_bcnt1_i32_b32 s0, s0
	s_load_b32 s1, s[2:3], 0x0
	v_cvt_f32_ubyte0_e32 v1, s0
	v_mov_b32_e32 v2, 0
	s_mov_b32 s0, 0
	ds_load_b32 v0, v2
	s_waitcnt lgkmcnt(0)
	v_mul_f32_e32 v3, v0, v1
	v_mov_b32_e32 v1, s1
.LBB0_10:                               ; %atomicrmw.start
                                        ; =>This Inner Loop Header: Depth=1
	s_delay_alu instid0(VALU_DEP_1)
	v_add_f32_e32 v0, v1, v3
	global_atomic_cmpswap_b32 v0, v2, v[0:1], s[2:3] glc
	s_waitcnt vmcnt(0)
	v_cmp_eq_u32_e32 vcc_lo, v0, v1
	v_mov_b32_e32 v1, v0
	s_or_b32 s0, vcc_lo, s0
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_not1_b32 exec_lo, exec_lo, s0
	s_cbranch_execnz .LBB0_10
.LBB0_11:
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z13sumall_kernelPfS_
		.amdhsa_group_segment_fixed_size 1024
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 272
		.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 4
		.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	_Z13sumall_kernelPfS_, .Lfunc_end0-_Z13sumall_kernelPfS_
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 392
; NumSgprs: 18
; NumVgprs: 4
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 1024 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 4
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __hip_cuid_
	.amdgpu_metadata
---
amdhsa.kernels:
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .offset:         16
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         20
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         24
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         28
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         30
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         32
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         34
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         36
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         38
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         56
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         64
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         80
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 1024
    .kernarg_segment_align: 8
    .kernarg_segment_size: 272
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z13sumall_kernelPfS_
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z13sumall_kernelPfS_.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     4
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
