#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <vector>
#include <chrono>

using namespace std;

const int n = 10000;
const int n_feature = 128;
const double p = .1;
const int  max_e = (int)(n * n * p * 3);
size_t f_size = n * n_feature * sizeof(float);

vector<int> adjacent_matrix[n];
float f1[n * n_feature], f2[n * n_feature];
float *d_f1, *d_f2;
int indices[max_e], values[max_e];
int *d_indices, *d_values;

void prepareData() {
    srand(time(0));
    const int k = 1e6;
    int tote(0);
    for (int i = 0; i < n; ++i) {
        indices[i] = tote;
        for (int j = 0; j < n; ++j) {
            if (rand() % k < p * k) {
                values[tote++] = j;
            }
        }
        for (int j = 0; j < n_feature; ++j) {
            f1[i * n_feature + j] = rand() % k / (float)k;
            f2[i * n_feature + j] = 0;
        }
    }
    indices[n] = tote;
    printf("Graph edges %d\n", tote);
    cudaMalloc(&d_indices, (n + 1)* sizeof(int));
    cudaMemcpy(d_indices, indices, (n + 1)* sizeof(int), cudaMemcpyHostToDevice);
    cudaMalloc(&d_values, tote * sizeof(int));
    cudaMemcpy(d_values, values, tote * sizeof(int), cudaMemcpyHostToDevice);
    cudaMalloc(&d_f1, f_size);
    cudaMemcpy(d_f1, f1, f_size, cudaMemcpyHostToDevice);
    cudaMalloc(&d_f2, f_size);
    cudaMemset(d_f2, 0, f_size);
    cudaDeviceSynchronize();
}


inline double getDuration(std::chrono::time_point<std::chrono::system_clock> a,
                std::chrono::time_point<std::chrono::system_clock> b) {
    return  std::chrono::duration<double>(b - a).count();
}


#define timestamp(__var__) auto __var__ = std::chrono::system_clock::now();


__global__
void graph_add(int n_feature, int n, int* indices, int* values, float* f1, float* f2) {
    int i = blockIdx.x * blockDim.x + threadIdx.x;
    float l_f2[::n_feature];
    if (i < n) {
        for (int k = 0; k < n_feature; ++k) {
            l_f2[k] = 0;
        }
        for (int j = indices[i]; j < indices[i + 1]; ++j) {
            for (int k = 0; k < n_feature; ++k) {
                l_f2[k] += f1[values[j] * n_feature + k];
            }
        }
        for (int k = 0; k < n_feature; ++k) {
            f2[i * n_feature + k] = l_f2[k];
        }
    }
}


double runOnce() {
    timestamp(t1);
    graph_add<<<128, 128>>>(n_feature, n, d_indices, d_values, d_f1, d_f2);
    cudaDeviceSynchronize();
    timestamp(t2);
    cudaMemcpy(f2, d_f2, f_size, cudaMemcpyDeviceToHost);
    cudaDeviceSynchronize();
    float sum(0);
    for (int i = 0; i < n; ++i) {
        for (int k = 0; k < n_feature; ++k) {
            sum += f2[i * n_feature + k];
        }
    }
    fprintf(stderr, "F20 %f Check sum %f\n", f2[0], sum);
    return getDuration(t1, t2);
}

int main() {
    prepareData();
    double total_time = 0;
    int times = 10;
    fprintf(stderr, "Ready\n");
    for (int i = 0; i < times; ++i) {
        total_time += runOnce();
    }
    fprintf(stderr, "Avg time %.9lf s\n", total_time / times);
}

	.file	"tmpxft_003025c2_00000000-6_vtx_parallel.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB3016:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE3016:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.type	__tcf_0, @function
__tcf_0:
.LFB3247:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	leaq	240000+adjacent_matrix(%rip), %rbx
	pushq	%rdx
	.cfi_def_cfa_offset 32
	leaq	-240000(%rbx), %rbp
.L4:
	movq	-24(%rbx), %rdi
	subq	$24, %rbx
	testq	%rdi, %rdi
	je	.L3
	movq	16(%rbx), %rsi
	subq	%rdi, %rsi
	call	_ZdlPvm@PLT
.L3:
	cmpq	%rbp, %rbx
	jne	.L4
	popq	%rax
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3247:
	.size	__tcf_0, .-__tcf_0
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC2:
	.string	"Graph edges %d\n"
	.text
	.globl	_Z11prepareDatav
	.type	_Z11prepareDatav, @function
_Z11prepareDatav:
.LFB3006:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	xorl	%edi, %edi
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movl	$1000000, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	xorl	%ebp, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	xorl	%ebx, %ebx
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	call	time@PLT
	movl	%eax, %edi
	call	srand@PLT
.L15:
	leaq	indices(%rip), %r15
	xorl	%r13d, %r13d
	leaq	values(%rip), %r14
	movl	%ebx, (%r15,%rbp,4)
.L13:
	call	rand@PLT
	cltd
	idivl	%r12d
	cmpl	$99999, %edx
	jg	.L12
	movslq	%ebx, %rax
	incl	%ebx
	movl	%r13d, (%r14,%rax,4)
.L12:
	incl	%r13d
	cmpl	$10000, %r13d
	jne	.L13
	movq	%rbp, %r14
	movl	$128, %ecx
	leaq	f1(%rip), %r13
	salq	$9, %r14
.L14:
	movl	%ecx, 12(%rsp)
	call	rand@PLT
	movl	12(%rsp), %ecx
	cltd
	idivl	%r12d
	leaq	f2(%rip), %rax
	movl	$0x00000000, (%rax,%r14)
	cvtsi2ssl	%edx, %xmm0
	divss	.LC0(%rip), %xmm0
	movss	%xmm0, 0(%r13,%r14)
	addq	$4, %r14
	decl	%ecx
	jne	.L14
	incq	%rbp
	cmpq	$10000, %rbp
	jne	.L15
	movl	%ebx, %edx
	leaq	.LC2(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	movl	%ebx, 40000+indices(%rip)
	movslq	%ebx, %rbx
	call	__printf_chk@PLT
	movl	$40004, %esi
	leaq	d_indices(%rip), %rdi
	salq	$2, %rbx
	call	cudaMalloc@PLT
	movq	d_indices(%rip), %rdi
	movl	$1, %ecx
	movq	%r15, %rsi
	movl	$40004, %edx
	call	cudaMemcpy@PLT
	movq	%rbx, %rsi
	leaq	d_values(%rip), %rdi
	call	cudaMalloc@PLT
	movq	d_values(%rip), %rdi
	movq	%rbx, %rdx
	movl	$1, %ecx
	leaq	values(%rip), %rsi
	call	cudaMemcpy@PLT
	movq	f_size(%rip), %rsi
	leaq	d_f1(%rip), %rdi
	call	cudaMalloc@PLT
	movq	f_size(%rip), %rdx
	movl	$1, %ecx
	movq	%r13, %rsi
	movq	d_f1(%rip), %rdi
	call	cudaMemcpy@PLT
	movq	f_size(%rip), %rsi
	leaq	d_f2(%rip), %rdi
	call	cudaMalloc@PLT
	movq	f_size(%rip), %rdx
	movq	d_f2(%rip), %rdi
	xorl	%esi, %esi
	call	cudaMemset@PLT
	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
	jmp	cudaDeviceSynchronize@PLT
	.cfi_endproc
.LFE3006:
	.size	_Z11prepareDatav, .-_Z11prepareDatav
	.globl	_Z37__device_stub__Z9graph_addiiPiS_PfS0_iiPiS_PfS0_
	.type	_Z37__device_stub__Z9graph_addiiPiS_PfS0_iiPiS_PfS0_, @function
_Z37__device_stub__Z9graph_addiiPiS_PfS0_iiPiS_PfS0_:
.LFB3038:
	.cfi_startproc
	endbr64
	subq	$184, %rsp
	.cfi_def_cfa_offset 192
	movl	%edi, 44(%rsp)
	leaq	72(%rsp), %rdi
	movl	%esi, 40(%rsp)
	leaq	84(%rsp), %rsi
	movq	%rdx, 32(%rsp)
	leaq	56(%rsp), %rdx
	movq	%rcx, 24(%rsp)
	leaq	64(%rsp), %rcx
	movq	%r8, 16(%rsp)
	movq	%r9, 8(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 168(%rsp)
	xorl	%eax, %eax
	leaq	44(%rsp), %rax
	movl	$1, 80(%rsp)
	movq	%rax, 120(%rsp)
	leaq	40(%rsp), %rax
	movq	%rax, 128(%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 136(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 144(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 152(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 160(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 72(%rsp)
	movq	%rax, 84(%rsp)
	movl	$1, 92(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L20
	pushq	64(%rsp)
	.cfi_def_cfa_offset 200
	leaq	_Z9graph_addiiPiS_PfS0_(%rip), %rdi
	pushq	64(%rsp)
	.cfi_def_cfa_offset 208
	movq	100(%rsp), %rcx
	movl	108(%rsp), %r8d
	movq	88(%rsp), %rsi
	movl	96(%rsp), %edx
	leaq	136(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 200
	popq	%rdx
	.cfi_def_cfa_offset 192
.L20:
	movq	168(%rsp), %rax
	subq	%fs:40, %rax
	je	.L22
	call	__stack_chk_fail@PLT
.L22:
	addq	$184, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3038:
	.size	_Z37__device_stub__Z9graph_addiiPiS_PfS0_iiPiS_PfS0_, .-_Z37__device_stub__Z9graph_addiiPiS_PfS0_iiPiS_PfS0_
	.globl	_Z9graph_addiiPiS_PfS0_
	.type	_Z9graph_addiiPiS_PfS0_, @function
_Z9graph_addiiPiS_PfS0_:
.LFB3039:
	.cfi_startproc
	endbr64
	jmp	_Z37__device_stub__Z9graph_addiiPiS_PfS0_iiPiS_PfS0_
	.cfi_endproc
.LFE3039:
	.size	_Z9graph_addiiPiS_PfS0_, .-_Z9graph_addiiPiS_PfS0_
	.section	.rodata.str1.1
.LC3:
	.string	"F20 %f Check sum %f\n"
	.text
	.globl	_Z7runOncev
	.type	_Z7runOncev, @function
_Z7runOncev:
.LFB3011:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	subq	$32, %rsp
	.cfi_def_cfa_offset 64
	call	_ZNSt6chrono3_V212system_clock3nowEv@PLT
	movl	$33554433, %edi
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	salq	$7, %rdi
	movl	$1, %ecx
	movl	$1, %esi
	movq	%rax, %r12
	movq	%rdi, %rdx
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L26
	movq	d_f2(%rip), %r9
	movq	d_f1(%rip), %r8
	movl	$10000, %esi
	movl	$128, %edi
	movq	d_values(%rip), %rcx
	movq	d_indices(%rip), %rdx
	call	_Z37__device_stub__Z9graph_addiiPiS_PfS0_iiPiS_PfS0_
.L26:
	call	cudaDeviceSynchronize@PLT
	leaq	f2(%rip), %rbx
	call	_ZNSt6chrono3_V212system_clock3nowEv@PLT
	movq	f_size(%rip), %rdx
	movl	$2, %ecx
	movq	%rbx, %rdi
	movq	d_f2(%rip), %rsi
	movq	%rax, %rbp
	call	cudaMemcpy@PLT
	call	cudaDeviceSynchronize@PLT
	movq	%rbx, %rax
	xorl	%ecx, %ecx
	xorps	%xmm1, %xmm1
.L27:
	xorl	%edx, %edx
.L28:
	addss	(%rax,%rdx,4), %xmm1
	incq	%rdx
	cmpq	$128, %rdx
	jne	.L28
	subl	$-128, %ecx
	addq	$512, %rax
	cmpl	$1280000, %ecx
	jne	.L27
	movq	stderr(%rip), %rdi
	subq	%r12, %rbp
	movl	$2, %esi
	movb	$2, %al
	leaq	.LC3(%rip), %rdx
	cvtss2sd	f2(%rip), %xmm0
	cvtss2sd	%xmm1, %xmm1
	call	__fprintf_chk@PLT
	cvtsi2sdq	%rbp, %xmm0
	divsd	.LC4(%rip), %xmm0
	addq	$32, %rsp
	.cfi_def_cfa_offset 32
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3011:
	.size	_Z7runOncev, .-_Z7runOncev
	.section	.rodata.str1.1
.LC6:
	.string	"Ready\n"
.LC8:
	.string	"Avg time %.9lf s\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB3013:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	movl	$10, %ebx
	subq	$16, %rsp
	.cfi_def_cfa_offset 32
	call	_Z11prepareDatav
	movq	stderr(%rip), %rdi
	leaq	.LC6(%rip), %rdx
	xorl	%eax, %eax
	movl	$2, %esi
	call	__fprintf_chk@PLT
	xorps	%xmm1, %xmm1
.L33:
	movsd	%xmm1, 8(%rsp)
	call	_Z7runOncev
	movsd	8(%rsp), %xmm1
	addsd	%xmm0, %xmm1
	decl	%ebx
	jne	.L33
	movq	stderr(%rip), %rdi
	divsd	.LC7(%rip), %xmm1
	leaq	.LC8(%rip), %rdx
	movaps	%xmm1, %xmm0
	movl	$2, %esi
	movb	$1, %al
	call	__fprintf_chk@PLT
	addq	$16, %rsp
	.cfi_def_cfa_offset 16
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3013:
	.size	main, .-main
	.section	.rodata.str1.1
.LC9:
	.string	"_Z9graph_addiiPiS_PfS0_"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB3041:
	.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	.LC9(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z9graph_addiiPiS_PfS0_(%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
.LFE3041:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.text.startup
	.type	_GLOBAL__sub_I_f_size, @function
_GLOBAL__sub_I_f_size:
.LFB3248:
	.cfi_startproc
	endbr64
	leaq	adjacent_matrix(%rip), %rax
	leaq	240000(%rax), %rdx
.L39:
	xorl	%ecx, %ecx
	addq	$24, %rax
	movq	%rcx, -24(%rax)
	movq	%rcx, -16(%rax)
	movq	%rcx, -8(%rax)
	cmpq	%rdx, %rax
	jne	.L39
	leaq	__dso_handle(%rip), %rdx
	xorl	%esi, %esi
	leaq	__tcf_0(%rip), %rdi
	jmp	__cxa_atexit@PLT
	.cfi_endproc
.LFE3248:
	.size	_GLOBAL__sub_I_f_size, .-_GLOBAL__sub_I_f_size
	.section	.init_array
	.align 8
	.quad	_GLOBAL__sub_I_f_size
	.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
	.globl	d_values
	.bss
	.align 8
	.type	d_values, @object
	.size	d_values, 8
d_values:
	.zero	8
	.globl	d_indices
	.align 8
	.type	d_indices, @object
	.size	d_indices, 8
d_indices:
	.zero	8
	.globl	values
	.align 32
	.type	values, @object
	.size	values, 120000000
values:
	.zero	120000000
	.globl	indices
	.align 32
	.type	indices, @object
	.size	indices, 120000000
indices:
	.zero	120000000
	.globl	d_f2
	.align 8
	.type	d_f2, @object
	.size	d_f2, 8
d_f2:
	.zero	8
	.globl	d_f1
	.align 8
	.type	d_f1, @object
	.size	d_f1, 8
d_f1:
	.zero	8
	.globl	f2
	.align 32
	.type	f2, @object
	.size	f2, 5120000
f2:
	.zero	5120000
	.globl	f1
	.align 32
	.type	f1, @object
	.size	f1, 5120000
f1:
	.zero	5120000
	.globl	adjacent_matrix
	.align 32
	.type	adjacent_matrix, @object
	.size	adjacent_matrix, 240000
adjacent_matrix:
	.zero	240000
	.globl	f_size
	.data
	.align 8
	.type	f_size, @object
	.size	f_size, 8
f_size:
	.quad	5120000
	.section	.rodata.cst4,"aM",@progbits,4
	.align 4
.LC0:
	.long	1232348160
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC4:
	.long	0
	.long	1104006501
	.align 8
.LC7:
	.long	0
	.long	1076101120
	.hidden	__dso_handle
	.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 <cstdlib>
#include <ctime>
#include <cstdio>
#include <vector>
#include <chrono>

using namespace std;

const int n = 10000;
const int n_feature = 128;
const double p = .1;
const int  max_e = (int)(n * n * p * 3);
size_t f_size = n * n_feature * sizeof(float);

vector<int> adjacent_matrix[n];
float f1[n * n_feature], f2[n * n_feature];
float *d_f1, *d_f2;
int indices[max_e], values[max_e];
int *d_indices, *d_values;

void prepareData() {
    srand(time(0));
    const int k = 1e6;
    int tote(0);
    for (int i = 0; i < n; ++i) {
        indices[i] = tote;
        for (int j = 0; j < n; ++j) {
            if (rand() % k < p * k) {
                values[tote++] = j;
            }
        }
        for (int j = 0; j < n_feature; ++j) {
            f1[i * n_feature + j] = rand() % k / (float)k;
            f2[i * n_feature + j] = 0;
        }
    }
    indices[n] = tote;
    printf("Graph edges %d\n", tote);
    hipMalloc(&d_indices, (n + 1)* sizeof(int));
    hipMemcpy(d_indices, indices, (n + 1)* sizeof(int), hipMemcpyHostToDevice);
    hipMalloc(&d_values, tote * sizeof(int));
    hipMemcpy(d_values, values, tote * sizeof(int), hipMemcpyHostToDevice);
    hipMalloc(&d_f1, f_size);
    hipMemcpy(d_f1, f1, f_size, hipMemcpyHostToDevice);
    hipMalloc(&d_f2, f_size);
    hipMemset(d_f2, 0, f_size);
    hipDeviceSynchronize();
}


inline double getDuration(std::chrono::time_point<std::chrono::system_clock> a,
                std::chrono::time_point<std::chrono::system_clock> b) {
    return  std::chrono::duration<double>(b - a).count();
}


#define timestamp(__var__) auto __var__ = std::chrono::system_clock::now();


__global__
void graph_add(int n_feature, int n, int* indices, int* values, float* f1, float* f2) {
    int i = blockIdx.x * blockDim.x + threadIdx.x;
    float l_f2[::n_feature];
    if (i < n) {
        for (int k = 0; k < n_feature; ++k) {
            l_f2[k] = 0;
        }
        for (int j = indices[i]; j < indices[i + 1]; ++j) {
            for (int k = 0; k < n_feature; ++k) {
                l_f2[k] += f1[values[j] * n_feature + k];
            }
        }
        for (int k = 0; k < n_feature; ++k) {
            f2[i * n_feature + k] = l_f2[k];
        }
    }
}


double runOnce() {
    timestamp(t1);
    graph_add<<<128, 128>>>(n_feature, n, d_indices, d_values, d_f1, d_f2);
    hipDeviceSynchronize();
    timestamp(t2);
    hipMemcpy(f2, d_f2, f_size, hipMemcpyDeviceToHost);
    hipDeviceSynchronize();
    float sum(0);
    for (int i = 0; i < n; ++i) {
        for (int k = 0; k < n_feature; ++k) {
            sum += f2[i * n_feature + k];
        }
    }
    fprintf(stderr, "F20 %f Check sum %f\n", f2[0], sum);
    return getDuration(t1, t2);
}

int main() {
    prepareData();
    double total_time = 0;
    int times = 10;
    fprintf(stderr, "Ready\n");
    for (int i = 0; i < times; ++i) {
        total_time += runOnce();
    }
    fprintf(stderr, "Avg time %.9lf s\n", total_time / times);
}

	.text
	.file	"vtx_parallel.hip"
	.section	.text.startup,"ax",@progbits
	.type	__cxx_global_array_dtor,@function # -- Begin function __cxx_global_array_dtor
__cxx_global_array_dtor:                # @__cxx_global_array_dtor
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset %rbx, -16
	movl	$240000, %ebx                   # imm = 0x3A980
.LBB0_1:                                # =>This Inner Loop Header: Depth=1
	movq	adjacent_matrix-24(%rbx), %rdi
	testq	%rdi, %rdi
	je	.LBB0_3
# %bb.2:                                #   in Loop: Header=BB0_1 Depth=1
	callq	_ZdlPv
.LBB0_3:                                # %_ZNSt6vectorIiSaIiEED2Ev.exit
                                        #   in Loop: Header=BB0_1 Depth=1
	addq	$-24, %rbx
	jne	.LBB0_1
# %bb.4:
	popq	%rbx
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	__cxx_global_array_dtor, .Lfunc_end0-__cxx_global_array_dtor
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function _Z11prepareDatav
.LCPI1_0:
	.long	0x49742400                      # float 1.0E+6
	.text
	.globl	_Z11prepareDatav
	.type	_Z11prepareDatav,@function
_Z11prepareDatav:                       # @_Z11prepareDatav
	.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	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	xorl	%r14d, %r14d
	xorl	%edi, %edi
	callq	time
	movl	%eax, %edi
	callq	srand
	xorl	%r15d, %r15d
	xorl	%ebx, %ebx
.LBB1_1:                                # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_2 Depth 2
                                        #     Child Loop BB1_6 Depth 2
	movl	%ebx, indices(,%r15,4)
	xorl	%ebp, %ebp
.LBB1_2:                                #   Parent Loop BB1_1 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	callq	rand
	cltq
	imulq	$1125899907, %rax, %rcx         # imm = 0x431BDE83
	movq	%rcx, %rdx
	shrq	$63, %rdx
	sarq	$50, %rcx
	addl	%edx, %ecx
	imull	$1000000, %ecx, %ecx            # imm = 0xF4240
	subl	%ecx, %eax
	cmpl	$99999, %eax                    # imm = 0x1869F
	jg	.LBB1_4
# %bb.3:                                #   in Loop: Header=BB1_2 Depth=2
	movslq	%ebx, %rax
	incl	%ebx
	movl	%ebp, values(,%rax,4)
.LBB1_4:                                #   in Loop: Header=BB1_2 Depth=2
	incl	%ebp
	cmpl	$10000, %ebp                    # imm = 0x2710
	jne	.LBB1_2
# %bb.5:                                # %.preheader
                                        #   in Loop: Header=BB1_1 Depth=1
	movq	$-512, %r12                     # imm = 0xFE00
.LBB1_6:                                #   Parent Loop BB1_1 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	callq	rand
	cltq
	imulq	$1125899907, %rax, %rcx         # imm = 0x431BDE83
	movq	%rcx, %rdx
	shrq	$63, %rdx
	sarq	$50, %rcx
	addl	%edx, %ecx
	imull	$1000000, %ecx, %ecx            # imm = 0xF4240
	subl	%ecx, %eax
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	divss	.LCPI1_0(%rip), %xmm0
	movss	%xmm0, f1+512(%r14,%r12)
	movl	$0, f2+512(%r14,%r12)
	addq	$4, %r12
	jne	.LBB1_6
# %bb.7:                                #   in Loop: Header=BB1_1 Depth=1
	incq	%r15
	addq	$512, %r14                      # imm = 0x200
	cmpq	$10000, %r15                    # imm = 0x2710
	jne	.LBB1_1
# %bb.8:
	movl	%ebx, indices+40000(%rip)
	movl	$.L.str, %edi
	movl	%ebx, %esi
	xorl	%eax, %eax
	callq	printf
	movl	$d_indices, %edi
	movl	$40004, %esi                    # imm = 0x9C44
	callq	hipMalloc
	movq	d_indices(%rip), %rdi
	movl	$indices, %esi
	movl	$40004, %edx                    # imm = 0x9C44
	movl	$1, %ecx
	callq	hipMemcpy
	movslq	%ebx, %rbx
	shlq	$2, %rbx
	movl	$d_values, %edi
	movq	%rbx, %rsi
	callq	hipMalloc
	movq	d_values(%rip), %rdi
	movl	$values, %esi
	movq	%rbx, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	f_size(%rip), %rsi
	movl	$d_f1, %edi
	callq	hipMalloc
	movq	d_f1(%rip), %rdi
	movq	f_size(%rip), %rdx
	movl	$f1, %esi
	movl	$1, %ecx
	callq	hipMemcpy
	movq	f_size(%rip), %rsi
	movl	$d_f2, %edi
	callq	hipMalloc
	movq	d_f2(%rip), %rdi
	movq	f_size(%rip), %rdx
	xorl	%esi, %esi
	callq	hipMemset
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.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
	jmp	hipDeviceSynchronize            # TAILCALL
.Lfunc_end1:
	.size	_Z11prepareDatav, .Lfunc_end1-_Z11prepareDatav
	.cfi_endproc
                                        # -- End function
	.globl	_Z24__device_stub__graph_addiiPiS_PfS0_ # -- Begin function _Z24__device_stub__graph_addiiPiS_PfS0_
	.type	_Z24__device_stub__graph_addiiPiS_PfS0_,@function
_Z24__device_stub__graph_addiiPiS_PfS0_: # @_Z24__device_stub__graph_addiiPiS_PfS0_
	.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	$144, %rsp
	.cfi_def_cfa_offset 192
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	12(%rsp), %rax
	movl	%edi, (%rax)
	leaq	8(%rsp), %rdi
	movl	%esi, (%rdi)
	leaq	56(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	48(%rsp), %rdx
	movq	%rcx, (%rdx)
	leaq	40(%rsp), %rcx
	movq	%r8, (%rcx)
	leaq	32(%rsp), %r8
	movq	%r9, (%r8)
	leaq	96(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	movq	%rcx, 32(%rbx)
	movq	%r8, 40(%rbx)
	leaq	80(%rsp), %r14
	leaq	64(%rsp), %r15
	leaq	24(%rsp), %r12
	leaq	16(%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	$_Z9graph_addiiPiS_PfS0_, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$160, %rsp
	.cfi_adjust_cfa_offset -160
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end2:
	.size	_Z24__device_stub__graph_addiiPiS_PfS0_, .Lfunc_end2-_Z24__device_stub__graph_addiiPiS_PfS0_
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z7runOncev
.LCPI3_0:
	.quad	0x41cdcd6500000000              # double 1.0E+9
	.text
	.globl	_Z7runOncev
	.type	_Z7runOncev,@function
_Z7runOncev:                            # @_Z7runOncev
	.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
	callq	_ZNSt6chrono3_V212system_clock3nowEv
	movq	%rax, %rbx
	movabsq	$4294967424, %rdi               # imm = 0x100000080
	movl	$1, %esi
	movq	%rdi, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB3_2
# %bb.1:
	movq	d_indices(%rip), %rdx
	movq	d_values(%rip), %rcx
	movq	d_f1(%rip), %r8
	movq	d_f2(%rip), %r9
	movl	$128, %edi
	movl	$10000, %esi                    # imm = 0x2710
	callq	_Z24__device_stub__graph_addiiPiS_PfS0_
.LBB3_2:
	callq	hipDeviceSynchronize
	callq	_ZNSt6chrono3_V212system_clock3nowEv
	movq	%rax, %r14
	movq	d_f2(%rip), %rsi
	movq	f_size(%rip), %rdx
	movl	$f2, %r15d
	movl	$f2, %edi
	movl	$2, %ecx
	callq	hipMemcpy
	callq	hipDeviceSynchronize
	xorps	%xmm1, %xmm1
	xorl	%eax, %eax
.LBB3_3:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB3_4 Depth 2
	xorl	%ecx, %ecx
.LBB3_4:                                #   Parent Loop BB3_3 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	addss	(%r15,%rcx,4), %xmm1
	incq	%rcx
	cmpq	$128, %rcx
	jne	.LBB3_4
# %bb.5:                                #   in Loop: Header=BB3_3 Depth=1
	incq	%rax
	addq	$512, %r15                      # imm = 0x200
	cmpq	$10000, %rax                    # imm = 0x2710
	jne	.LBB3_3
# %bb.6:
	movq	stderr(%rip), %rdi
	cvtss2sd	f2(%rip), %xmm0
	cvtss2sd	%xmm1, %xmm1
	movl	$.L.str.1, %esi
	movb	$2, %al
	callq	fprintf
	subq	%rbx, %r14
	xorps	%xmm0, %xmm0
	cvtsi2sd	%r14, %xmm0
	divsd	.LCPI3_0(%rip), %xmm0
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end3:
	.size	_Z7runOncev, .Lfunc_end3-_Z7runOncev
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI4_0:
	.quad	0x4024000000000000              # double 10
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$16, %rsp
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -16
	callq	_Z11prepareDatav
	movq	stderr(%rip), %rcx
	movl	$.L.str.2, %edi
	movl	$6, %esi
	movl	$1, %edx
	callq	fwrite@PLT
	xorpd	%xmm0, %xmm0
	movl	$10, %ebx
.LBB4_1:                                # =>This Inner Loop Header: Depth=1
	movsd	%xmm0, 8(%rsp)                  # 8-byte Spill
	callq	_Z7runOncev
	movsd	8(%rsp), %xmm1                  # 8-byte Reload
                                        # xmm1 = mem[0],zero
	addsd	%xmm0, %xmm1
	movsd	%xmm1, 8(%rsp)                  # 8-byte Spill
	movsd	8(%rsp), %xmm0                  # 8-byte Reload
                                        # xmm0 = mem[0],zero
	decl	%ebx
	jne	.LBB4_1
# %bb.2:
	movq	stderr(%rip), %rdi
	divsd	.LCPI4_0(%rip), %xmm0
	movl	$.L.str.3, %esi
	movb	$1, %al
	callq	fprintf
	xorl	%eax, %eax
	addq	$16, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end4:
	.size	main, .Lfunc_end4-main
	.cfi_endproc
                                        # -- End function
	.section	.text.startup,"ax",@progbits
	.type	_GLOBAL__sub_I_vtx_parallel.hip,@function # -- Begin function _GLOBAL__sub_I_vtx_parallel.hip
_GLOBAL__sub_I_vtx_parallel.hip:        # @_GLOBAL__sub_I_vtx_parallel.hip
	.cfi_startproc
# %bb.0:
	pushq	%rax
	.cfi_def_cfa_offset 16
	movl	$adjacent_matrix, %edi
	movl	$240000, %edx                   # imm = 0x3A980
	xorl	%esi, %esi
	callq	memset@PLT
	movl	$__cxx_global_array_dtor, %edi
	movl	$__dso_handle, %edx
	xorl	%esi, %esi
	popq	%rax
	.cfi_def_cfa_offset 8
	jmp	__cxa_atexit                    # TAILCALL
.Lfunc_end5:
	.size	_GLOBAL__sub_I_vtx_parallel.hip, .Lfunc_end5-_GLOBAL__sub_I_vtx_parallel.hip
	.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	.LBB6_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB6_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z9graph_addiiPiS_PfS0_, %esi
	movl	$.L__unnamed_1, %edx
	movl	$.L__unnamed_1, %ecx
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$__hip_module_dtor, %edi
	addq	$40, %rsp
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_end6:
	.size	__hip_module_ctor, .Lfunc_end6-__hip_module_ctor
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_dtor
	.type	__hip_module_dtor,@function
__hip_module_dtor:                      # @__hip_module_dtor
	.cfi_startproc
# %bb.0:
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	je	.LBB7_2
# %bb.1:
	pushq	%rax
	.cfi_def_cfa_offset 16
	callq	__hipUnregisterFatBinary
	movq	$0, __hip_gpubin_handle(%rip)
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
.LBB7_2:
	retq
.Lfunc_end7:
	.size	__hip_module_dtor, .Lfunc_end7-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	f_size,@object                  # @f_size
	.data
	.globl	f_size
	.p2align	3, 0x0
f_size:
	.quad	5120000                         # 0x4e2000
	.size	f_size, 8

	.type	adjacent_matrix,@object         # @adjacent_matrix
	.bss
	.globl	adjacent_matrix
	.p2align	4, 0x0
adjacent_matrix:
	.zero	240000
	.size	adjacent_matrix, 240000

	.hidden	__dso_handle
	.type	f1,@object                      # @f1
	.globl	f1
	.p2align	4, 0x0
f1:
	.zero	5120000
	.size	f1, 5120000

	.type	f2,@object                      # @f2
	.globl	f2
	.p2align	4, 0x0
f2:
	.zero	5120000
	.size	f2, 5120000

	.type	d_f1,@object                    # @d_f1
	.globl	d_f1
	.p2align	3, 0x0
d_f1:
	.quad	0
	.size	d_f1, 8

	.type	d_f2,@object                    # @d_f2
	.globl	d_f2
	.p2align	3, 0x0
d_f2:
	.quad	0
	.size	d_f2, 8

	.type	indices,@object                 # @indices
	.globl	indices
	.p2align	4, 0x0
indices:
	.zero	120000000
	.size	indices, 120000000

	.type	values,@object                  # @values
	.globl	values
	.p2align	4, 0x0
values:
	.zero	120000000
	.size	values, 120000000

	.type	d_indices,@object               # @d_indices
	.globl	d_indices
	.p2align	3, 0x0
d_indices:
	.quad	0
	.size	d_indices, 8

	.type	d_values,@object                # @d_values
	.globl	d_values
	.p2align	3, 0x0
d_values:
	.quad	0
	.size	d_values, 8

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"Graph edges %d\n"
	.size	.L.str, 16

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

	.type	.L.str.1,@object                # @.str.1
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.1:
	.asciz	"F20 %f Check sum %f\n"
	.size	.L.str.1, 21

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"Ready\n"
	.size	.L.str.2, 7

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"Avg time %.9lf s\n"
	.size	.L.str.3, 18

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z9graph_addiiPiS_PfS0_"
	.size	.L__unnamed_1, 24

	.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	_GLOBAL__sub_I_vtx_parallel.hip
	.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 __cxx_global_array_dtor
	.addrsig_sym _Z24__device_stub__graph_addiiPiS_PfS0_
	.addrsig_sym __gxx_personality_v0
	.addrsig_sym _GLOBAL__sub_I_vtx_parallel.hip
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym adjacent_matrix
	.addrsig_sym __dso_handle
	.addrsig_sym f1
	.addrsig_sym f2
	.addrsig_sym d_f1
	.addrsig_sym d_f2
	.addrsig_sym indices
	.addrsig_sym values
	.addrsig_sym d_indices
	.addrsig_sym d_values
	.addrsig_sym _Z9graph_addiiPiS_PfS0_
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z9graph_addiiPiS_PfS0_ ; -- Begin function _Z9graph_addiiPiS_PfS0_
	.globl	_Z9graph_addiiPiS_PfS0_
	.p2align	8
	.type	_Z9graph_addiiPiS_PfS0_,@function
_Z9graph_addiiPiS_PfS0_:                ; @_Z9graph_addiiPiS_PfS0_
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x34
	s_load_b64 s[8:9], s[0:1], 0x0
	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 s9, v1
	s_cbranch_execz .LBB0_13
; %bb.1:                                ; %.preheader38
	s_cmp_gt_i32 s8, 0
	s_cselect_b32 s9, -1, 0
	s_cmp_lt_i32 s8, 1
	s_cbranch_scc1 .LBB0_4
; %bb.2:                                ; %.lr.ph.preheader
	v_mov_b32_e32 v0, 16
	v_mov_b32_e32 v2, 0
	s_mov_b32 s2, s8
.LBB0_3:                                ; %.lr.ph
                                        ; =>This Inner Loop Header: Depth=1
	scratch_store_b32 v0, v2, off
	v_add_nc_u32_e32 v0, 4, v0
	s_add_i32 s2, s2, -1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_cmp_eq_u32 s2, 0
	s_cbranch_scc0 .LBB0_3
.LBB0_4:                                ; %._crit_edge
	s_load_b256 s[0:7], s[0:1], 0x8
	v_ashrrev_i32_e32 v2, 31, v1
	v_cndmask_b32_e64 v0, 0, 1, s9
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[2:3], 2, v[1:2]
	s_waitcnt lgkmcnt(0)
	v_add_co_u32 v2, vcc_lo, s0, v2
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v3, vcc_lo, s1, v3, vcc_lo
	s_mov_b32 s0, exec_lo
	global_load_b64 v[2:3], v[2:3], off
	s_waitcnt vmcnt(0)
	v_cmpx_lt_i32_e64 v2, v3
	s_cbranch_execz .LBB0_10
; %bb.5:                                ; %.preheader37.preheader
	v_mov_b32_e32 v4, v2
	s_mov_b32 s1, 0
.LBB0_6:                                ; %.preheader37
                                        ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB0_8 Depth 2
	s_and_not1_b32 vcc_lo, exec_lo, s9
	s_cbranch_vccnz .LBB0_9
; %bb.7:                                ; %.lr.ph41
                                        ;   in Loop: Header=BB0_6 Depth=1
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v5, 31, v4
	s_mov_b32 s10, s8
	v_lshlrev_b64 v[5:6], 2, v[4:5]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v5, vcc_lo, s2, v5
	v_add_co_ci_u32_e32 v6, vcc_lo, s3, v6, vcc_lo
	global_load_b32 v2, v[5:6], off
	s_waitcnt vmcnt(0)
	v_mul_lo_u32 v5, v2, s8
	v_mov_b32_e32 v2, 16
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v6, 31, v5
	v_lshlrev_b64 v[5:6], 2, v[5:6]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v5, vcc_lo, s4, v5
	v_add_co_ci_u32_e32 v6, vcc_lo, s5, v6, vcc_lo
.LBB0_8:                                ;   Parent Loop BB0_6 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	global_load_b32 v7, v[5:6], off
	scratch_load_b32 v8, v2, off
	v_add_co_u32 v5, vcc_lo, v5, 4
	v_add_co_ci_u32_e32 v6, vcc_lo, 0, v6, vcc_lo
	s_add_i32 s10, s10, -1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_cmp_eq_u32 s10, 0
	s_waitcnt vmcnt(0)
	v_add_f32_e32 v7, v7, v8
	scratch_store_b32 v2, v7, off
	v_add_nc_u32_e32 v2, 4, v2
	s_cbranch_scc0 .LBB0_8
.LBB0_9:                                ; %._crit_edge42
                                        ;   in Loop: Header=BB0_6 Depth=1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_nc_u32_e32 v4, 1, v4
	v_cmp_ge_i32_e32 vcc_lo, v4, v3
	s_or_b32 s1, vcc_lo, s1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_not1_b32 exec_lo, exec_lo, s1
	s_cbranch_execnz .LBB0_6
.LBB0_10:                               ; %Flow84
	s_or_b32 exec_lo, exec_lo, s0
	v_cmp_ne_u32_e32 vcc_lo, 1, v0
	s_cbranch_vccnz .LBB0_13
; %bb.11:                               ; %.lr.ph45
	v_mul_lo_u32 v0, v1, s8
	v_mov_b32_e32 v2, 16
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v1, 31, v0
	v_lshlrev_b64 v[0:1], 2, v[0:1]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v0, vcc_lo, s6, v0
	v_add_co_ci_u32_e32 v1, vcc_lo, s7, v1, vcc_lo
.LBB0_12:                               ; =>This Inner Loop Header: Depth=1
	scratch_load_b32 v3, v2, off
	v_add_nc_u32_e32 v2, 4, v2
	s_add_i32 s8, s8, -1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_cmp_lg_u32 s8, 0
	s_waitcnt vmcnt(0)
	global_store_b32 v[0:1], v3, off
	v_add_co_u32 v0, vcc_lo, v0, 4
	v_add_co_ci_u32_e32 v1, vcc_lo, 0, v1, vcc_lo
	s_cbranch_scc1 .LBB0_12
.LBB0_13:                               ; %.loopexit
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z9graph_addiiPiS_PfS0_
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 528
		.amdhsa_kernarg_size 296
		.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 1
		.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 9
		.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	_Z9graph_addiiPiS_PfS0_, .Lfunc_end0-_Z9graph_addiiPiS_PfS0_
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 508
; NumSgprs: 18
; NumVgprs: 9
; ScratchSize: 528
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 9
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 1
; 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:
      - .offset:         0
        .size:           4
        .value_kind:     by_value
      - .offset:         4
        .size:           4
        .value_kind:     by_value
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         16
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         24
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         32
        .size:           8
        .value_kind:     global_buffer
      - .offset:         40
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         44
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         48
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         52
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         54
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         56
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         58
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         60
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         62
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         88
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         96
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         104
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 296
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z9graph_addiiPiS_PfS0_
    .private_segment_fixed_size: 528
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z9graph_addiiPiS_PfS0_.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     9
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
