#include <iostream>
#include <cuda_runtime.h>
#include <cuda.h>
#include <cooperative_groups.h>
#include <vector>

namespace cg = cooperative_groups;

// Define a simple structure for a sparse tensor element
struct SparseTensorElement {
    int row;
    int col;
    float value;
};

// CUDA kernel for sparse tensor operations
__global__ void sparseTensorKernel(SparseTensorElement* elements, int numElements, float* result) {
    extern __shared__ float sharedData[];

    int idx = blockIdx.x * blockDim.x + threadIdx.x;
    int tid = threadIdx.x;

    // Initialize shared memory
    sharedData[tid] = 0.0f;
    __syncthreads();

    // Accumulate results into shared memory
    if (idx < numElements) {
        int row = elements[idx].row;
        atomicAdd(&sharedData[row], elements[idx].value);
    }
    __syncthreads();

    // Write results from shared memory to global memory
    if (tid < blockDim.x) {
        atomicAdd(&result[tid], sharedData[tid]);
    }
}

int main() {
    // Initialize device
    int deviceCount;
    cudaGetDeviceCount(&deviceCount);
    if (deviceCount == 0) {
        std::cerr << "No CUDA devices found!" << std::endl;
        return -1;
    }
    cudaSetDevice(0);

    // Define the number of non-zero elements
    const int numElements = 128;

    // Initialize sparse tensor elements
    std::vector<SparseTensorElement> h_elements(numElements);
    for (int i = 0; i < numElements; ++i) {
        h_elements[i].row = i % 16; // Example row index
        h_elements[i].col = i % 16; // Example column index
        h_elements[i].value = 1.0f; // Example value
    }

    // Allocate memory for elements and result on the device
    SparseTensorElement* d_elements;
    float* d_result;
    cudaMalloc((void**)&d_elements, numElements * sizeof(SparseTensorElement));
    cudaMalloc((void**)&d_result, 16 * sizeof(float)); // Assuming 16 rows for simplicity
    cudaMemset(d_result, 0, 16 * sizeof(float));

    // Copy elements to device
    cudaMemcpy(d_elements, h_elements.data(), numElements * sizeof(SparseTensorElement), cudaMemcpyHostToDevice);

    // Define block and grid sizes
    int blockSize = 256;
    int numBlocks = (numElements + blockSize - 1) / blockSize;

    // Launch kernel
    sparseTensorKernel<<<numBlocks, blockSize, blockSize * sizeof(float)>>>(d_elements, numElements, d_result);

    // Check for kernel launch errors
    cudaError_t err = cudaGetLastError();
    if (err != cudaSuccess) {
        std::cerr << "CUDA error: " << cudaGetErrorString(err) << std::endl;
        return -1;
    }

    // Synchronize device
    cudaDeviceSynchronize();

    // Copy result back to host
    std::vector<float> h_result(16);
    cudaMemcpy(h_result.data(), d_result, 16 * sizeof(float), cudaMemcpyDeviceToHost);

    // Print results
    std::cout << "Resulting sums for each row:" << std::endl;
    for (int i = 0; i < 16; ++i) {
        std::cout << "Row " << i << ": " << h_result[i] << std::endl;
    }

    // Free device memory
    cudaFree(d_elements);
    cudaFree(d_result);

    return 0;
}
	.file	"tmpxft_0015aa62_00000000-6_cuda_code_015911.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB7198:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE7198:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z61__device_stub__Z18sparseTensorKernelP19SparseTensorElementiPfP19SparseTensorElementiPf
	.type	_Z61__device_stub__Z18sparseTensorKernelP19SparseTensorElementiPfP19SparseTensorElementiPf, @function
_Z61__device_stub__Z18sparseTensorKernelP19SparseTensorElementiPfP19SparseTensorElementiPf:
.LFB7220:
	.cfi_startproc
	endbr64
	subq	$136, %rsp
	.cfi_def_cfa_offset 144
	movq	%rdi, 24(%rsp)
	leaq	40(%rsp), %rcx
	leaq	48(%rsp), %rdi
	movl	%esi, 20(%rsp)
	leaq	60(%rsp), %rsi
	movq	%rdx, 8(%rsp)
	leaq	32(%rsp), %rdx
	movq	%fs:40, %rax
	movq	%rax, 120(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 56(%rsp)
	movq	%rax, 96(%rsp)
	leaq	20(%rsp), %rax
	movq	%rax, 104(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 112(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 48(%rsp)
	movq	%rax, 60(%rsp)
	movl	$1, 68(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L2
	pushq	40(%rsp)
	.cfi_def_cfa_offset 152
	leaq	_Z18sparseTensorKernelP19SparseTensorElementiPf(%rip), %rdi
	pushq	40(%rsp)
	.cfi_def_cfa_offset 160
	movq	76(%rsp), %rcx
	movl	84(%rsp), %r8d
	movq	64(%rsp), %rsi
	movl	72(%rsp), %edx
	leaq	112(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 152
	popq	%rdx
	.cfi_def_cfa_offset 144
.L2:
	movq	120(%rsp), %rax
	subq	%fs:40, %rax
	je	.L4
	call	__stack_chk_fail@PLT
.L4:
	addq	$136, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE7220:
	.size	_Z61__device_stub__Z18sparseTensorKernelP19SparseTensorElementiPfP19SparseTensorElementiPf, .-_Z61__device_stub__Z18sparseTensorKernelP19SparseTensorElementiPfP19SparseTensorElementiPf
	.globl	_Z18sparseTensorKernelP19SparseTensorElementiPf
	.type	_Z18sparseTensorKernelP19SparseTensorElementiPf, @function
_Z18sparseTensorKernelP19SparseTensorElementiPf:
.LFB7221:
	.cfi_startproc
	endbr64
	jmp	_Z61__device_stub__Z18sparseTensorKernelP19SparseTensorElementiPfP19SparseTensorElementiPf
	.cfi_endproc
.LFE7221:
	.size	_Z18sparseTensorKernelP19SparseTensorElementiPf, .-_Z18sparseTensorKernelP19SparseTensorElementiPf
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"_Z18sparseTensorKernelP19SparseTensorElementiPf"
.LC1:
	.string	"_ZN50_INTERNAL_6242a36b_19_cuda_code_015911_cu_1fb70c5f4cuda3std3__419piecewise_constructE"
.LC2:
	.string	"_ZN50_INTERNAL_6242a36b_19_cuda_code_015911_cu_1fb70c5f4cuda3std6ranges3__45__cpo4swapE"
.LC3:
	.string	"_ZN50_INTERNAL_6242a36b_19_cuda_code_015911_cu_1fb70c5f4cuda3std6ranges3__45__cpo9iter_moveE"
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB7223:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	pushq	$0
	.cfi_def_cfa_offset 24
	xorl	%r9d, %r9d
	orl	$-1, %r8d
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC0(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z18sparseTensorKernelP19SparseTensorElementiPf(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 48
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC1(%rip), %rdx
	movl	$1, %r9d
	leaq	_ZN4cuda3std3__419piecewise_constructE(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	call	__cudaRegisterVar@PLT
	popq	%rax
	.cfi_def_cfa_offset 24
	popq	%rdx
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC2(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movq	%rdx, %rcx
	movl	$1, %r9d
	leaq	_ZN4cuda3std6ranges3__45__cpo4swapE(%rip), %rsi
	call	__cudaRegisterVar@PLT
	popq	%rcx
	.cfi_def_cfa_offset 24
	popq	%rsi
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC3(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movl	$1, %r9d
	movq	%rdx, %rcx
	leaq	_ZN4cuda3std6ranges3__45__cpo9iter_moveE(%rip), %rsi
	call	__cudaRegisterVar@PLT
	popq	%rdi
	.cfi_def_cfa_offset 24
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	popq	%r8
	.cfi_def_cfa_offset 16
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE7223:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.text._ZNSt6vectorI19SparseTensorElementSaIS0_EED2Ev,"axG",@progbits,_ZNSt6vectorI19SparseTensorElementSaIS0_EED5Ev,comdat
	.align 2
	.weak	_ZNSt6vectorI19SparseTensorElementSaIS0_EED2Ev
	.type	_ZNSt6vectorI19SparseTensorElementSaIS0_EED2Ev, @function
_ZNSt6vectorI19SparseTensorElementSaIS0_EED2Ev:
.LFB7675:
	.cfi_startproc
	endbr64
	movq	(%rdi), %rax
	testq	%rax, %rax
	je	.L10
	movq	16(%rdi), %rsi
	movq	%rax, %rdi
	subq	%rax, %rsi
	jmp	_ZdlPvm@PLT
.L10:
	ret
	.cfi_endproc
.LFE7675:
	.size	_ZNSt6vectorI19SparseTensorElementSaIS0_EED2Ev, .-_ZNSt6vectorI19SparseTensorElementSaIS0_EED2Ev
	.weak	_ZNSt6vectorI19SparseTensorElementSaIS0_EED1Ev
	.set	_ZNSt6vectorI19SparseTensorElementSaIS0_EED1Ev,_ZNSt6vectorI19SparseTensorElementSaIS0_EED2Ev
	.section	.text._ZNSt6vectorIfSaIfEED2Ev,"axG",@progbits,_ZNSt6vectorIfSaIfEED5Ev,comdat
	.align 2
	.weak	_ZNSt6vectorIfSaIfEED2Ev
	.type	_ZNSt6vectorIfSaIfEED2Ev, @function
_ZNSt6vectorIfSaIfEED2Ev:
.LFB7689:
	.cfi_startproc
	endbr64
	movq	(%rdi), %rax
	testq	%rax, %rax
	je	.L12
	movq	16(%rdi), %rsi
	movq	%rax, %rdi
	subq	%rax, %rsi
	jmp	_ZdlPvm@PLT
.L12:
	ret
	.cfi_endproc
.LFE7689:
	.size	_ZNSt6vectorIfSaIfEED2Ev, .-_ZNSt6vectorIfSaIfEED2Ev
	.weak	_ZNSt6vectorIfSaIfEED1Ev
	.set	_ZNSt6vectorIfSaIfEED1Ev,_ZNSt6vectorIfSaIfEED2Ev
	.section	.rodata.str1.1
.LC4:
	.string	"No CUDA devices found!"
.LC7:
	.string	"CUDA error: "
.LC8:
	.string	"Resulting sums for each row:"
.LC9:
	.string	"Row "
.LC10:
	.string	": "
	.section	.text.startup
	.globl	main
	.type	main, @function
main:
.LFB7195:
	.cfi_startproc
	.cfi_personality 0x9b,DW.ref.__gxx_personality_v0
	.cfi_lsda 0x1b,.LLSDA7195
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	subq	$96, %rsp
	.cfi_def_cfa_offset 144
	movq	%fs:40, %rax
	movq	%rax, 88(%rsp)
	xorl	%eax, %eax
	leaq	4(%rsp), %rdi
.LEHB0:
	call	cudaGetDeviceCount@PLT
	cmpl	$0, 4(%rsp)
	jne	.L15
	leaq	.LC4(%rip), %rsi
	leaq	_ZSt4cerr(%rip), %rdi
	orl	$-1, %ebx
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%rax, %rdi
	call	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT
	jmp	.L14
.L15:
	xorl	%edi, %edi
	call	cudaSetDevice@PLT
	movl	$1536, %edi
	call	_Znwm@PLT
.LEHE0:
	xorl	%ecx, %ecx
	leaq	1536(%rax), %rdx
	movq	%rax, 40(%rsp)
	movq	%rax, %rbx
	movq	%rdx, 56(%rsp)
	movq	%rcx, (%rax)
	movl	$0x00000000, 8(%rax)
	xorl	%eax, %eax
.L17:
	addq	$12, %rax
	cmpq	$1536, %rax
	je	.L41
	movq	(%rbx), %rcx
	movq	%rcx, (%rbx,%rax)
	movl	8(%rbx), %ecx
	movl	%ecx, 8(%rbx,%rax)
	jmp	.L17
.L41:
	movss	.LC6(%rip), %xmm0
	movq	%rdx, 48(%rsp)
	movq	%rbx, %rax
	xorl	%edx, %edx
.L19:
	movl	%edx, %ecx
	incl	%edx
	movss	%xmm0, 8(%rax)
	addq	$12, %rax
	andl	$15, %ecx
	movl	%ecx, -12(%rax)
	movl	%ecx, -8(%rax)
	cmpl	$128, %edx
	jne	.L19
	leaq	8(%rsp), %rdi
	movl	$1536, %esi
.LEHB1:
	call	cudaMalloc@PLT
	leaq	16(%rsp), %rdi
	movl	$64, %esi
	call	cudaMalloc@PLT
	movq	16(%rsp), %rdi
	movl	$64, %edx
	xorl	%esi, %esi
	call	cudaMemset@PLT
	movq	8(%rsp), %rdi
	movl	$1, %ecx
	movl	$1536, %edx
	movq	%rbx, %rsi
	call	cudaMemcpy@PLT
	movl	$16777217, %edx
	xorl	%r9d, %r9d
	movl	$1024, %r8d
	movl	$1, %ecx
	salq	$8, %rdx
	movl	$1, %esi
	movabsq	$4294967297, %rdi
	movl	$1, 72(%rsp)
	movq	%rdx, 64(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	je	.L20
.L22:
	call	cudaGetLastError@PLT
	movl	%eax, %ebx
	testl	%eax, %eax
	je	.L23
	jmp	.L42
.L20:
	movq	16(%rsp), %rdx
	movq	8(%rsp), %rdi
	movl	$128, %esi
	call	_Z61__device_stub__Z18sparseTensorKernelP19SparseTensorElementiPfP19SparseTensorElementiPf
	jmp	.L22
.L42:
	leaq	.LC7(%rip), %rsi
	leaq	_ZSt4cerr(%rip), %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	%ebx, %edi
	movq	%rax, %rbp
	call	cudaGetErrorString@PLT
	movq	%rax, %rsi
	movq	%rbp, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%rax, %rdi
	call	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT
	orl	$-1, %ebx
	jmp	.L24
.L23:
	call	cudaDeviceSynchronize@PLT
	xorl	%eax, %eax
	movl	$64, %edi
	movq	%rax, 72(%rsp)
	movq	%rax, 80(%rsp)
	call	_Znwm@PLT
.LEHE1:
	leaq	64(%rax), %rdx
	movq	%rax, 64(%rsp)
	movq	%rax, %rbx
	movq	%rdx, 80(%rsp)
	movl	$0x00000000, (%rax)
	xorl	%eax, %eax
.L25:
	addq	$4, %rax
	cmpq	$64, %rax
	je	.L43
	movl	$0x00000000, (%rbx,%rax)
	jmp	.L25
.L43:
	movq	16(%rsp), %rsi
	movq	%rdx, 72(%rsp)
	movl	$2, %ecx
	movq	%rbx, %rdi
	movl	$64, %edx
.LEHB2:
	call	cudaMemcpy@PLT
	leaq	_ZSt4cout(%rip), %r12
	leaq	.LC8(%rip), %rsi
	movq	%r12, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%rax, %rdi
	call	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT
	xorl	%ebp, %ebp
	leaq	.LC9(%rip), %r13
.L27:
	movq	%r13, %rsi
	movq	%r12, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%rax, %rdi
	movl	%ebp, %esi
	call	_ZNSolsEi@PLT
	movq	%rax, %rdi
	leaq	.LC10(%rip), %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%rax, %rdi
	cvtss2sd	(%rbx,%rbp,4), %xmm0
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	movq	%rax, %rdi
	call	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT
	incq	%rbp
	cmpq	$16, %rbp
	jne	.L27
	movq	8(%rsp), %rdi
	call	cudaFree@PLT
	movq	16(%rsp), %rdi
	call	cudaFree@PLT
.LEHE2:
	leaq	64(%rsp), %rdi
	xorl	%ebx, %ebx
	call	_ZNSt6vectorIfSaIfEED1Ev
.L24:
	leaq	40(%rsp), %rdi
	call	_ZNSt6vectorI19SparseTensorElementSaIS0_EED1Ev
	jmp	.L14
.L34:
	endbr64
	movq	%rax, %rbx
.L28:
	leaq	64(%rsp), %rdi
	call	_ZNSt6vectorIfSaIfEED1Ev
	jmp	.L29
.L33:
	endbr64
	movq	%rax, %rbx
.L29:
	leaq	40(%rsp), %rdi
	call	_ZNSt6vectorI19SparseTensorElementSaIS0_EED1Ev
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L40
	movq	%rbx, %rdi
.LEHB3:
	call	_Unwind_Resume@PLT
.LEHE3:
.L14:
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	je	.L31
.L40:
	call	__stack_chk_fail@PLT
.L31:
	addq	$96, %rsp
	.cfi_def_cfa_offset 48
	movl	%ebx, %eax
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE7195:
	.globl	__gxx_personality_v0
	.section	.gcc_except_table,"a",@progbits
.LLSDA7195:
	.byte	0xff
	.byte	0xff
	.byte	0x1
	.uleb128 .LLSDACSE7195-.LLSDACSB7195
.LLSDACSB7195:
	.uleb128 .LEHB0-.LFB7195
	.uleb128 .LEHE0-.LEHB0
	.uleb128 0
	.uleb128 0
	.uleb128 .LEHB1-.LFB7195
	.uleb128 .LEHE1-.LEHB1
	.uleb128 .L33-.LFB7195
	.uleb128 0
	.uleb128 .LEHB2-.LFB7195
	.uleb128 .LEHE2-.LEHB2
	.uleb128 .L34-.LFB7195
	.uleb128 0
	.uleb128 .LEHB3-.LFB7195
	.uleb128 .LEHE3-.LEHB3
	.uleb128 0
	.uleb128 0
.LLSDACSE7195:
	.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
	.weak	_ZN4cuda3std3__419piecewise_constructE
	.section	.rodata._ZN4cuda3std3__419piecewise_constructE,"aG",@progbits,_ZN4cuda3std3__419piecewise_constructE,comdat
	.type	_ZN4cuda3std3__419piecewise_constructE, @gnu_unique_object
	.size	_ZN4cuda3std3__419piecewise_constructE, 1
_ZN4cuda3std3__419piecewise_constructE:
	.zero	1
	.weak	_ZN4cuda3std6ranges3__45__cpo9iter_moveE
	.section	.rodata._ZN4cuda3std6ranges3__45__cpo9iter_moveE,"aG",@progbits,_ZN4cuda3std6ranges3__45__cpo9iter_moveE,comdat
	.type	_ZN4cuda3std6ranges3__45__cpo9iter_moveE, @gnu_unique_object
	.size	_ZN4cuda3std6ranges3__45__cpo9iter_moveE, 1
_ZN4cuda3std6ranges3__45__cpo9iter_moveE:
	.zero	1
	.weak	_ZN4cuda3std6ranges3__45__cpo4swapE
	.section	.rodata._ZN4cuda3std6ranges3__45__cpo4swapE,"aG",@progbits,_ZN4cuda3std6ranges3__45__cpo4swapE,comdat
	.type	_ZN4cuda3std6ranges3__45__cpo4swapE, @gnu_unique_object
	.size	_ZN4cuda3std6ranges3__45__cpo4swapE, 1
_ZN4cuda3std6ranges3__45__cpo4swapE:
	.zero	1
	.section	.rodata.cst4,"aM",@progbits,4
	.align 4
.LC6:
	.long	1065353216
	.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 <iostream>
#include <hip/hip_runtime.h>

#include <hip/hip_cooperative_groups.h>
#include <vector>

namespace cg = cooperative_groups;

// Define a simple structure for a sparse tensor element
struct SparseTensorElement {
    int row;
    int col;
    float value;
};

// CUDA kernel for sparse tensor operations
__global__ void sparseTensorKernel(SparseTensorElement* elements, int numElements, float* result) {
    extern __shared__ float sharedData[];

    int idx = blockIdx.x * blockDim.x + threadIdx.x;
    int tid = threadIdx.x;

    // Initialize shared memory
    sharedData[tid] = 0.0f;
    __syncthreads();

    // Accumulate results into shared memory
    if (idx < numElements) {
        int row = elements[idx].row;
        atomicAdd(&sharedData[row], elements[idx].value);
    }
    __syncthreads();

    // Write results from shared memory to global memory
    if (tid < blockDim.x) {
        atomicAdd(&result[tid], sharedData[tid]);
    }
}

int main() {
    // Initialize device
    int deviceCount;
    hipGetDeviceCount(&deviceCount);
    if (deviceCount == 0) {
        std::cerr << "No CUDA devices found!" << std::endl;
        return -1;
    }
    hipSetDevice(0);

    // Define the number of non-zero elements
    const int numElements = 128;

    // Initialize sparse tensor elements
    std::vector<SparseTensorElement> h_elements(numElements);
    for (int i = 0; i < numElements; ++i) {
        h_elements[i].row = i % 16; // Example row index
        h_elements[i].col = i % 16; // Example column index
        h_elements[i].value = 1.0f; // Example value
    }

    // Allocate memory for elements and result on the device
    SparseTensorElement* d_elements;
    float* d_result;
    hipMalloc((void**)&d_elements, numElements * sizeof(SparseTensorElement));
    hipMalloc((void**)&d_result, 16 * sizeof(float)); // Assuming 16 rows for simplicity
    hipMemset(d_result, 0, 16 * sizeof(float));

    // Copy elements to device
    hipMemcpy(d_elements, h_elements.data(), numElements * sizeof(SparseTensorElement), hipMemcpyHostToDevice);

    // Define block and grid sizes
    int blockSize = 256;
    int numBlocks = (numElements + blockSize - 1) / blockSize;

    // Launch kernel
    sparseTensorKernel<<<numBlocks, blockSize, blockSize * sizeof(float)>>>(d_elements, numElements, d_result);

    // Check for kernel launch errors
    hipError_t err = hipGetLastError();
    if (err != hipSuccess) {
        std::cerr << "CUDA error: " << hipGetErrorString(err) << std::endl;
        return -1;
    }

    // Synchronize device
    hipDeviceSynchronize();

    // Copy result back to host
    std::vector<float> h_result(16);
    hipMemcpy(h_result.data(), d_result, 16 * sizeof(float), hipMemcpyDeviceToHost);

    // Print results
    std::cout << "Resulting sums for each row:" << std::endl;
    for (int i = 0; i < 16; ++i) {
        std::cout << "Row " << i << ": " << h_result[i] << std::endl;
    }

    // Free device memory
    hipFree(d_elements);
    hipFree(d_result);

    return 0;
}
	.text
	.file	"cuda_code_015911.hip"
                                        # Start of file scope inline assembly
	.globl	_ZSt21ios_base_library_initv

                                        # End of file scope inline assembly
	.globl	_Z33__device_stub__sparseTensorKernelP19SparseTensorElementiPf # -- Begin function _Z33__device_stub__sparseTensorKernelP19SparseTensorElementiPf
	.type	_Z33__device_stub__sparseTensorKernelP19SparseTensorElementiPf,@function
_Z33__device_stub__sparseTensorKernelP19SparseTensorElementiPf: # @_Z33__device_stub__sparseTensorKernelP19SparseTensorElementiPf
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$112, %rsp
	.cfi_def_cfa_offset 160
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	12(%rsp), %rcx
	movl	%esi, (%rcx)
	leaq	32(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	movq	%rsi, 16(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	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	$_Z18sparseTensorKernelP19SparseTensorElementiPf, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$128, %rsp
	.cfi_adjust_cfa_offset -128
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	_Z33__device_stub__sparseTensorKernelP19SparseTensorElementiPf, .Lfunc_end0-_Z33__device_stub__sparseTensorKernelP19SparseTensorElementiPf
	.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	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$32, %rsp
	.cfi_def_cfa_offset 80
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	leaq	28(%rsp), %rbx
	movq	%rbx, %rdi
	callq	hipGetDeviceCount
	cmpl	$0, (%rbx)
	je	.LBB1_1
# %bb.2:                                # %.noexc
	xorl	%edi, %edi
	callq	hipSetDevice
	movl	$1536, %edi                     # imm = 0x600
	callq	_Znwm
	movq	%rax, %rbx
	movq	$0, (%rax)
	movl	$0, 8(%rax)
	movl	$12, %eax
.LBB1_3:                                # %.lr.ph.i.i.i.i.i.i.i.i.i
                                        # =>This Inner Loop Header: Depth=1
	movl	8(%rbx), %ecx
	movl	%ecx, 8(%rbx,%rax)
	movq	(%rbx), %rcx
	movq	%rcx, (%rbx,%rax)
	addq	$12, %rax
	cmpq	$1536, %rax                     # imm = 0x600
	jne	.LBB1_3
# %bb.4:                                # %_ZNSt6vectorI19SparseTensorElementSaIS0_EEC2EmRKS1_.exit.preheader
	movq	%rbx, %rax
	addq	$8, %rax
	xorl	%ecx, %ecx
.LBB1_5:                                # %_ZNSt6vectorI19SparseTensorElementSaIS0_EEC2EmRKS1_.exit
                                        # =>This Inner Loop Header: Depth=1
	movl	%ecx, %edx
	andl	$15, %edx
	movl	%edx, -8(%rax)
	movl	%edx, -4(%rax)
	movl	$1065353216, (%rax)             # imm = 0x3F800000
	incq	%rcx
	addq	$12, %rax
	cmpq	$128, %rcx
	jne	.LBB1_5
# %bb.6:
.Ltmp0:
	leaq	16(%rsp), %rdi
	movl	$1536, %esi                     # imm = 0x600
	callq	hipMalloc
.Ltmp1:
# %bb.7:
.Ltmp2:
	leaq	8(%rsp), %rdi
	movl	$64, %esi
	callq	hipMalloc
.Ltmp3:
# %bb.8:
	movq	8(%rsp), %rdi
.Ltmp4:
	movl	$64, %edx
	xorl	%esi, %esi
	callq	hipMemset
.Ltmp5:
# %bb.9:
	movq	16(%rsp), %rdi
.Ltmp6:
	movl	$1536, %edx                     # imm = 0x600
	movq	%rbx, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
.Ltmp7:
# %bb.10:
.Ltmp9:
	movabsq	$4294967297, %rdi               # imm = 0x100000001
	movabsq	$4294967552, %rdx               # imm = 0x100000100
	movl	$1024, %r8d                     # imm = 0x400
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
.Ltmp10:
# %bb.11:
	testl	%eax, %eax
	jne	.LBB1_13
# %bb.12:
	movq	16(%rsp), %rdi
	movq	8(%rsp), %rdx
.Ltmp11:
	movl	$128, %esi
	callq	_Z33__device_stub__sparseTensorKernelP19SparseTensorElementiPf
.Ltmp12:
.LBB1_13:
.Ltmp14:
	callq	hipGetLastError
.Ltmp15:
# %bb.14:
	movl	%eax, %ebp
	testl	%eax, %eax
	je	.LBB1_26
# %bb.15:
.Ltmp16:
	movl	$_ZSt4cerr, %edi
	movl	$.L.str.1, %esi
	movl	$12, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp17:
# %bb.16:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit
.Ltmp18:
	movl	%ebp, %edi
	callq	hipGetErrorString
.Ltmp19:
# %bb.17:
	movq	%rax, %r14
	testq	%rax, %rax
	je	.LBB1_18
# %bb.19:
	movq	%r14, %rdi
	callq	strlen
.Ltmp20:
	movl	$_ZSt4cerr, %edi
	movq	%r14, %rsi
	movq	%rax, %rdx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp21:
	jmp	.LBB1_20
.LBB1_1:
	movl	$_ZSt4cerr, %ebx
	movl	$_ZSt4cerr, %edi
	movl	$.L.str, %esi
	movl	$22, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	_ZSt4cerr(%rip), %rax
	movq	-24(%rax), %rdi
	addq	%rbx, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cerr, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	movl	$-1, %ebp
	jmp	.LBB1_24
.LBB1_26:
.Ltmp30:
	callq	hipDeviceSynchronize
.Ltmp31:
# %bb.27:
.Ltmp33:
	movl	$64, %edi
	callq	_Znwm
.Ltmp34:
# %bb.28:
	movq	%rax, %r14
	xorps	%xmm0, %xmm0
	movups	%xmm0, 48(%rax)
	movups	%xmm0, 32(%rax)
	movups	%xmm0, 16(%rax)
	movups	%xmm0, (%rax)
	movq	8(%rsp), %rsi
.Ltmp36:
	movl	$64, %edx
	movq	%rax, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
.Ltmp37:
# %bb.29:
.Ltmp38:
	movl	$_ZSt4cout, %r15d
	movl	$_ZSt4cout, %edi
	movl	$.L.str.2, %esi
	movl	$28, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp39:
# %bb.30:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit48
	movq	_ZSt4cout(%rip), %rax
	addq	-24(%rax), %r15
.Ltmp40:
	movq	%r15, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
.Ltmp41:
# %bb.31:                               # %.noexc68
.Ltmp42:
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
.Ltmp43:
# %bb.32:                               # %.noexc69
.Ltmp44:
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
.Ltmp45:
# %bb.33:                               # %_ZNSolsEPFRSoS_E.exit50.preheader.preheader
	xorl	%r15d, %r15d
.LBB1_34:                               # %_ZNSolsEPFRSoS_E.exit50.preheader
                                        # =>This Inner Loop Header: Depth=1
.Ltmp46:
	movl	$_ZSt4cout, %edi
	movl	$.L.str.3, %esi
	movl	$4, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp47:
# %bb.35:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit52
                                        #   in Loop: Header=BB1_34 Depth=1
.Ltmp48:
	movl	$_ZSt4cout, %edi
	movl	%r15d, %esi
	callq	_ZNSolsEi
.Ltmp49:
# %bb.36:                               #   in Loop: Header=BB1_34 Depth=1
.Ltmp50:
	movq	%rax, %r12
	movl	$.L.str.4, %esi
	movl	$2, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp51:
# %bb.37:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit54
                                        #   in Loop: Header=BB1_34 Depth=1
	xorps	%xmm0, %xmm0
	cvtss2sd	(%r14,%r15,4), %xmm0
.Ltmp52:
	movq	%r12, %rdi
	callq	_ZNSo9_M_insertIdEERSoT_
.Ltmp53:
# %bb.38:                               # %_ZNSolsEf.exit
                                        #   in Loop: Header=BB1_34 Depth=1
	movq	%rax, %r12
	movq	(%rax), %rax
	movq	-24(%rax), %rdi
	addq	%r12, %rdi
.Ltmp54:
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
.Ltmp55:
# %bb.39:                               # %.noexc72
                                        #   in Loop: Header=BB1_34 Depth=1
.Ltmp56:
	movsbl	%al, %esi
	movq	%r12, %rdi
	callq	_ZNSo3putEc
.Ltmp57:
# %bb.40:                               # %.noexc73
                                        #   in Loop: Header=BB1_34 Depth=1
.Ltmp58:
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
.Ltmp59:
# %bb.41:                               # %_ZNSolsEPFRSoS_E.exit57
                                        #   in Loop: Header=BB1_34 Depth=1
	incq	%r15
	cmpq	$16, %r15
	jne	.LBB1_34
# %bb.42:
	movq	16(%rsp), %rdi
.Ltmp61:
	callq	hipFree
.Ltmp62:
# %bb.43:
	movq	8(%rsp), %rdi
.Ltmp63:
	callq	hipFree
.Ltmp64:
# %bb.44:                               # %_ZNSt6vectorIfSaIfEED2Ev.exit
	movq	%r14, %rdi
	callq	_ZdlPv
	xorl	%ebp, %ebp
	jmp	.LBB1_23
.LBB1_18:
	movq	_ZSt4cerr(%rip), %rax
	movq	-24(%rax), %rax
	leaq	_ZSt4cerr(%rax), %rdi
	movl	32(%rdi), %esi
	orl	$1, %esi
.Ltmp22:
	callq	_ZNSt9basic_iosIcSt11char_traitsIcEE5clearESt12_Ios_Iostate
.Ltmp23:
.LBB1_20:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit44
	movq	_ZSt4cerr(%rip), %rax
	movl	$_ZSt4cerr, %edi
	addq	-24(%rax), %rdi
.Ltmp24:
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
.Ltmp25:
# %bb.21:                               # %.noexc64
.Ltmp26:
	movsbl	%al, %esi
	movl	$_ZSt4cerr, %edi
	callq	_ZNSo3putEc
.Ltmp27:
# %bb.22:                               # %.noexc65
	movl	$-1, %ebp
.Ltmp28:
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
.Ltmp29:
.LBB1_23:                               # %_ZNSt6vectorI19SparseTensorElementSaIS0_EED2Ev.exit
	movq	%rbx, %rdi
	callq	_ZdlPv
.LBB1_24:
	movl	%ebp, %eax
	addq	$32, %rsp
	.cfi_def_cfa_offset 48
	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
	retq
.LBB1_45:
	.cfi_def_cfa_offset 80
.Ltmp35:
	jmp	.LBB1_50
.LBB1_52:
.Ltmp13:
	jmp	.LBB1_50
.LBB1_47:
.Ltmp65:
	jmp	.LBB1_48
.LBB1_49:
.Ltmp8:
	jmp	.LBB1_50
.LBB1_25:
.Ltmp32:
.LBB1_50:                               # %_ZNSt6vectorI19SparseTensorElementSaIS0_EED2Ev.exit62
	movq	%rax, %r15
	jmp	.LBB1_51
.LBB1_46:
.Ltmp60:
.LBB1_48:                               # %_ZNSt6vectorIfSaIfEED2Ev.exit59
	movq	%rax, %r15
	movq	%r14, %rdi
	callq	_ZdlPv
.LBB1_51:                               # %_ZNSt6vectorI19SparseTensorElementSaIS0_EED2Ev.exit62
	movq	%rbx, %rdi
	callq	_ZdlPv
	movq	%r15, %rdi
	callq	_Unwind_Resume@PLT
.Lfunc_end1:
	.size	main, .Lfunc_end1-main
	.cfi_endproc
	.section	.gcc_except_table,"a",@progbits
	.p2align	2, 0x0
GCC_except_table1:
.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 .Ltmp7-.Ltmp0                  #   Call between .Ltmp0 and .Ltmp7
	.uleb128 .Ltmp8-.Lfunc_begin0           #     jumps to .Ltmp8
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp9-.Lfunc_begin0           # >> Call Site 3 <<
	.uleb128 .Ltmp12-.Ltmp9                 #   Call between .Ltmp9 and .Ltmp12
	.uleb128 .Ltmp13-.Lfunc_begin0          #     jumps to .Ltmp13
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp14-.Lfunc_begin0          # >> Call Site 4 <<
	.uleb128 .Ltmp21-.Ltmp14                #   Call between .Ltmp14 and .Ltmp21
	.uleb128 .Ltmp32-.Lfunc_begin0          #     jumps to .Ltmp32
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp21-.Lfunc_begin0          # >> Call Site 5 <<
	.uleb128 .Ltmp30-.Ltmp21                #   Call between .Ltmp21 and .Ltmp30
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp30-.Lfunc_begin0          # >> Call Site 6 <<
	.uleb128 .Ltmp31-.Ltmp30                #   Call between .Ltmp30 and .Ltmp31
	.uleb128 .Ltmp32-.Lfunc_begin0          #     jumps to .Ltmp32
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp33-.Lfunc_begin0          # >> Call Site 7 <<
	.uleb128 .Ltmp34-.Ltmp33                #   Call between .Ltmp33 and .Ltmp34
	.uleb128 .Ltmp35-.Lfunc_begin0          #     jumps to .Ltmp35
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp36-.Lfunc_begin0          # >> Call Site 8 <<
	.uleb128 .Ltmp45-.Ltmp36                #   Call between .Ltmp36 and .Ltmp45
	.uleb128 .Ltmp65-.Lfunc_begin0          #     jumps to .Ltmp65
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp46-.Lfunc_begin0          # >> Call Site 9 <<
	.uleb128 .Ltmp59-.Ltmp46                #   Call between .Ltmp46 and .Ltmp59
	.uleb128 .Ltmp60-.Lfunc_begin0          #     jumps to .Ltmp60
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp61-.Lfunc_begin0          # >> Call Site 10 <<
	.uleb128 .Ltmp64-.Ltmp61                #   Call between .Ltmp61 and .Ltmp64
	.uleb128 .Ltmp65-.Lfunc_begin0          #     jumps to .Ltmp65
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp22-.Lfunc_begin0          # >> Call Site 11 <<
	.uleb128 .Ltmp29-.Ltmp22                #   Call between .Ltmp22 and .Ltmp29
	.uleb128 .Ltmp32-.Lfunc_begin0          #     jumps to .Ltmp32
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp29-.Lfunc_begin0          # >> Call Site 12 <<
	.uleb128 .Lfunc_end1-.Ltmp29            #   Call between .Ltmp29 and .Lfunc_end1
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
.Lcst_end0:
	.p2align	2, 0x0
                                        # -- 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	.LBB2_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB2_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z18sparseTensorKernelP19SparseTensorElementiPf, %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_end2:
	.size	__hip_module_ctor, .Lfunc_end2-__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	.LBB3_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
.LBB3_2:
	retq
.Lfunc_end3:
	.size	__hip_module_dtor, .Lfunc_end3-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	_Z18sparseTensorKernelP19SparseTensorElementiPf,@object # @_Z18sparseTensorKernelP19SparseTensorElementiPf
	.section	.rodata,"a",@progbits
	.globl	_Z18sparseTensorKernelP19SparseTensorElementiPf
	.p2align	3, 0x0
_Z18sparseTensorKernelP19SparseTensorElementiPf:
	.quad	_Z33__device_stub__sparseTensorKernelP19SparseTensorElementiPf
	.size	_Z18sparseTensorKernelP19SparseTensorElementiPf, 8

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"No CUDA devices found!"
	.size	.L.str, 23

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"CUDA error: "
	.size	.L.str.1, 13

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"Resulting sums for each row:"
	.size	.L.str.2, 29

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"Row "
	.size	.L.str.3, 5

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	": "
	.size	.L.str.4, 3

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z18sparseTensorKernelP19SparseTensorElementiPf"
	.size	.L__unnamed_1, 48

	.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 _Z33__device_stub__sparseTensorKernelP19SparseTensorElementiPf
	.addrsig_sym __gxx_personality_v0
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Unwind_Resume
	.addrsig_sym _Z18sparseTensorKernelP19SparseTensorElementiPf
	.addrsig_sym _ZSt4cerr
	.addrsig_sym _ZSt4cout
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z18sparseTensorKernelP19SparseTensorElementiPf ; -- Begin function _Z18sparseTensorKernelP19SparseTensorElementiPf
	.globl	_Z18sparseTensorKernelP19SparseTensorElementiPf
	.p2align	8
	.type	_Z18sparseTensorKernelP19SparseTensorElementiPf,@function
_Z18sparseTensorKernelP19SparseTensorElementiPf: ; @_Z18sparseTensorKernelP19SparseTensorElementiPf
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x24
	s_load_b32 s3, s[0:1], 0x8
	v_mov_b32_e32 v3, 0
	s_waitcnt lgkmcnt(0)
	s_and_b32 s2, s2, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1)
	v_mad_u64_u32 v[1:2], null, s15, s2, v[0:1]
	v_lshl_add_u32 v2, v0, 2, 0
	ds_store_b32 v2, v3
	v_cmp_gt_i32_e32 vcc_lo, s3, v1
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	s_and_saveexec_b32 s3, vcc_lo
	s_cbranch_execz .LBB0_2
; %bb.1:
	s_load_b64 s[4:5], s[0:1], 0x0
	s_waitcnt lgkmcnt(0)
	v_mad_i64_i32 v[3:4], null, v1, 12, s[4:5]
	s_clause 0x1
	global_load_b32 v1, v[3:4], off
	global_load_b32 v3, v[3:4], off offset:8
	s_waitcnt vmcnt(1)
	v_lshl_add_u32 v1, v1, 2, 0
	s_waitcnt vmcnt(0)
	ds_add_f32 v1, v3
.LBB0_2:
	s_or_b32 exec_lo, exec_lo, s3
	v_cmp_gt_u32_e32 vcc_lo, s2, v0
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	s_and_saveexec_b32 s2, vcc_lo
	s_cbranch_execz .LBB0_5
; %bb.3:
	s_load_b64 s[0:1], s[0:1], 0x10
	v_lshlrev_b32_e32 v0, 2, v0
	ds_load_b32 v4, v2
	s_waitcnt lgkmcnt(0)
	global_load_b32 v3, v0, s[0:1]
	v_add_co_u32 v0, s0, s0, v0
	s_delay_alu instid0(VALU_DEP_1)
	v_add_co_ci_u32_e64 v1, null, s1, 0, s0
	s_mov_b32 s0, 0
.LBB0_4:                                ; %atomicrmw.start
                                        ; =>This Inner Loop Header: Depth=1
	s_waitcnt vmcnt(0)
	v_add_f32_e32 v2, v3, v4
	global_atomic_cmpswap_b32 v2, v[0:1], v[2:3], off glc
	s_waitcnt vmcnt(0)
	v_cmp_eq_u32_e32 vcc_lo, v2, v3
	v_mov_b32_e32 v3, v2
	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_4
.LBB0_5:
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z18sparseTensorKernelP19SparseTensorElementiPf
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 280
		.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 5
		.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	_Z18sparseTensorKernelP19SparseTensorElementiPf, .Lfunc_end0-_Z18sparseTensorKernelP19SparseTensorElementiPf
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 292
; NumSgprs: 18
; NumVgprs: 5
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 5
; 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 sharedData
	.addrsig_sym __hip_cuid_
	.amdgpu_metadata
---
amdhsa.kernels:
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .offset:         8
        .size:           4
        .value_kind:     by_value
      - .address_space:  global
        .offset:         16
        .size:           8
        .value_kind:     global_buffer
      - .offset:         24
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         28
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         32
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         36
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         38
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         40
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         42
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         44
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         46
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         64
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         88
        .size:           2
        .value_kind:     hidden_grid_dims
      - .offset:         144
        .size:           4
        .value_kind:     hidden_dynamic_lds_size
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 280
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z18sparseTensorKernelP19SparseTensorElementiPf
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z18sparseTensorKernelP19SparseTensorElementiPf.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     5
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
