#include "stdio.h"
#include "time.h"
#include "curand.h"

#define SPACING 7 
#define BLOCKSIZE 128 
#define N (1024 * 1000) 
#define CACHE (2 * SPACING + BLOCKSIZE + 1)

/* SPACING : Offset b/w main and distant diagonal */
/* BLOCKSIZE : Threads per block, multiple of 32 */
/* N : Row/Column size */
/* CACHE : Size of shared memory per block */

#define HEPT(a) ((a)+3)

struct sparseMatrix {
    float* DIA[7];
} A;

float *X;
float *B;


void freeResources ();
void initialize ();

__global__ void heptaMatrixMul ( struct sparseMatrix A, float *X, float *B) {

    /* Using only Global Memory */
    int thrId = blockIdx.x * blockDim.x + threadIdx.x;

    int middle = SPACING + thrId;

    float Bvalue;
    Bvalue = A.DIA[HEPT(3)][thrId] * X[thrId]
            + A.DIA[HEPT(2)][thrId] *  X[middle - 2]
            + A.DIA[HEPT(1)][thrId] *  X[middle - 1]
            + A.DIA[HEPT(0)][thrId] *  X[middle]
            + A.DIA[HEPT(-1)][thrId] * X[middle + 1]
            + A.DIA[HEPT(-2)][thrId] * X[middle + 2]
            + A.DIA[HEPT(-3)][thrId] * X[middle + SPACING];

    B[thrId] = Bvalue;
}


__global__ void heptaMatrixMulSharedMem ( struct sparseMatrix A, float *X, float *B) {

    /* Caching vector X in Shared Memory 
    to avoid accessing each element 7 times 
    from Global Memory */

    int thrId = blockIdx.x * blockDim.x + threadIdx.x;

    int i, OFFSET = blockIdx.x * blockDim.x;
    __shared__ float Xc[CACHE];

    for ( i = threadIdx.x; i < (2 * SPACING + blockDim.x + 1); i+= blockDim.x )
        Xc[i] = X[OFFSET + i];

    __syncthreads();

    int middle = SPACING + threadIdx.x;

    float Bvalue;
    Bvalue = A.DIA[HEPT(3)][thrId] * Xc[threadIdx.x]
            + A.DIA[HEPT(2)][thrId] *  Xc[middle - 2]
            + A.DIA[HEPT(1)][thrId] *  Xc[middle - 1]
            + A.DIA[HEPT(0)][thrId] *  Xc[middle]
            + A.DIA[HEPT(-1)][thrId] * Xc[middle + 1]
            + A.DIA[HEPT(-2)][thrId] * Xc[middle + 2]
            + A.DIA[HEPT(-3)][thrId] * Xc[middle + SPACING];

    B[thrId] = Bvalue;
}


void performance () {

    /* Performance measure for Shared Memory Vs. only Global Memory */

    int i;
    float resultSharedMem[N], resultGlobalMem[N];



    float elapsed=0;
    cudaEvent_t start, stop;

    cudaEventCreate(&start);
    cudaEventCreate(&stop);

    cudaEventRecord(start, 0);

    heptaMatrixMul <<<N/BLOCKSIZE, BLOCKSIZE>>> ( A, X, B);

    cudaEventRecord(stop, 0);
    cudaEventSynchronize (stop);

    cudaEventElapsedTime(&elapsed, start, stop);

    cudaEventDestroy(start);
    cudaEventDestroy(stop);

    printf("GLOBAL MEMORY TIME: %f\n", elapsed);




    cudaMemcpy(resultGlobalMem, B, 
        sizeof(float) * N, cudaMemcpyDeviceToHost);

    freeResources (); /* Flushing and Refilling */
    initialize (); /* to refresh GPU caches */


    elapsed=0;
    cudaEventCreate(&start);
    cudaEventCreate(&stop);

    cudaEventRecord(start, 0);

    heptaMatrixMulSharedMem <<<N/BLOCKSIZE, BLOCKSIZE>>> ( A, X, B);

    cudaEventRecord(stop, 0);
    cudaEventSynchronize (stop);

    cudaEventElapsedTime(&elapsed, start, stop);

    cudaEventDestroy(start);
    cudaEventDestroy(stop);

    printf("SHARED MEMORY TIME: %f\n", elapsed);

    
    cudaMemcpy(resultSharedMem, B, 
        sizeof(float) * N, cudaMemcpyDeviceToHost);
    
    printf("\n SHARED  \tGLOBAL\n");
    for ( i = 0; i < 2 * SPACING; ++i)
        printf(" %f\t%f\n", 
            resultSharedMem[i], resultGlobalMem[i]);

    for ( i = 0; i < N; ++i)
        if (resultSharedMem[i] != resultGlobalMem[i]) 
            printf("Error %f %f  :(\n", resultSharedMem[i], resultGlobalMem[i]);
    printf("Results are Equivalent\n");
}

int main ( int argc, char *argv[]) {
    initialize ();
    performance ();
    freeResources ();
    return 0;
}

 /* Random floats generation of Hepta Matrix using lib cuRAND */

void freeResources() {
    cudaFree(X);
    cudaFree(B);
    cudaFree( A.DIA[HEPT(0)]);
    cudaFree( A.DIA[HEPT(-1)]);
    cudaFree( A.DIA[HEPT(1)]);
    cudaFree( A.DIA[HEPT(-2)]);
    cudaFree( A.DIA[HEPT(2)]);
    cudaFree( A.DIA[HEPT(-3)]);
    cudaFree( A.DIA[HEPT(3)]);
}

void initialize() {

    /* AX = B */

    /* Extended vector X */
    cudaMalloc(&X, (N + 2*SPACING)* sizeof(float));

    /* Resultant vector B */
    cudaMalloc(&B, N* sizeof(float));

    /* Extended diagonals of Hepta-Mat A */
    cudaMalloc(&A.DIA[HEPT(0)],     N* sizeof(float));
    cudaMalloc(&A.DIA[HEPT(-1)],    N* sizeof(float));
    cudaMalloc(&A.DIA[HEPT(1)],     N* sizeof(float));
    cudaMalloc(&A.DIA[HEPT(-2)],    N* sizeof(float));
    cudaMalloc(&A.DIA[HEPT(2)],     N* sizeof(float));
    cudaMalloc(&A.DIA[HEPT(-3)],    N* sizeof(float));
    cudaMalloc(&A.DIA[HEPT(3)],     N* sizeof(float));

    
    curandGenerator_t gen;
    curandCreateGenerator(&gen, CURAND_RNG_PSEUDO_DEFAULT);
    curandSetPseudoRandomGeneratorSeed(gen, 1234ULL);

    /* Filling random floats in A and X */
    curandGenerateUniform(gen, X, N);
    curandGenerateUniform(gen, A.DIA[HEPT(0)],  N);
    curandGenerateUniform(gen, A.DIA[HEPT(-1)], N);
    curandGenerateUniform(gen, A.DIA[HEPT(1)],  N);
    curandGenerateUniform(gen, A.DIA[HEPT(-2)], N);
    curandGenerateUniform(gen, A.DIA[HEPT(2)],  N);
    curandGenerateUniform(gen, A.DIA[HEPT(-3)], N);
    curandGenerateUniform(gen, A.DIA[HEPT(3)],  N);

    curandDestroyGenerator(gen);
}
	.file	"tmpxft_002cb6e3_00000000-6_heptaMatPerformance.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2033:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2033:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.type	_Z10cudaMallocIfE9cudaErrorPPT_m.isra.0, @function
_Z10cudaMallocIfE9cudaErrorPPT_m.isra.0:
.LFB2178:
	.cfi_startproc
	jmp	cudaMalloc@PLT
	.cfi_endproc
.LFE2178:
	.size	_Z10cudaMallocIfE9cudaErrorPPT_m.isra.0, .-_Z10cudaMallocIfE9cudaErrorPPT_m.isra.0
	.globl	_Z13freeResourcesv
	.type	_Z13freeResourcesv, @function
_Z13freeResourcesv:
.LFB2029:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	movq	X(%rip), %rdi
	call	cudaFree@PLT
	movq	B(%rip), %rdi
	call	cudaFree@PLT
	movq	24+A(%rip), %rdi
	call	cudaFree@PLT
	movq	16+A(%rip), %rdi
	call	cudaFree@PLT
	movq	32+A(%rip), %rdi
	call	cudaFree@PLT
	movq	8+A(%rip), %rdi
	call	cudaFree@PLT
	movq	40+A(%rip), %rdi
	call	cudaFree@PLT
	movq	A(%rip), %rdi
	call	cudaFree@PLT
	movq	48+A(%rip), %rdi
	popq	%rdx
	.cfi_def_cfa_offset 8
	jmp	cudaFree@PLT
	.cfi_endproc
.LFE2029:
	.size	_Z13freeResourcesv, .-_Z13freeResourcesv
	.globl	_Z10initializev
	.type	_Z10initializev, @function
_Z10initializev:
.LFB2030:
	.cfi_startproc
	endbr64
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$4096056, %esi
	leaq	X(%rip), %rdi
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	call	_Z10cudaMallocIfE9cudaErrorPPT_m.isra.0
	movl	$4096000, %esi
	leaq	B(%rip), %rdi
	call	_Z10cudaMallocIfE9cudaErrorPPT_m.isra.0
	movl	$4096000, %esi
	leaq	24+A(%rip), %rdi
	call	_Z10cudaMallocIfE9cudaErrorPPT_m.isra.0
	movl	$4096000, %esi
	leaq	16+A(%rip), %rdi
	call	_Z10cudaMallocIfE9cudaErrorPPT_m.isra.0
	movl	$4096000, %esi
	leaq	32+A(%rip), %rdi
	call	_Z10cudaMallocIfE9cudaErrorPPT_m.isra.0
	movl	$4096000, %esi
	leaq	8+A(%rip), %rdi
	call	_Z10cudaMallocIfE9cudaErrorPPT_m.isra.0
	movl	$4096000, %esi
	leaq	40+A(%rip), %rdi
	call	_Z10cudaMallocIfE9cudaErrorPPT_m.isra.0
	movl	$4096000, %esi
	leaq	A(%rip), %rdi
	call	_Z10cudaMallocIfE9cudaErrorPPT_m.isra.0
	movl	$4096000, %esi
	leaq	48+A(%rip), %rdi
	call	_Z10cudaMallocIfE9cudaErrorPPT_m.isra.0
	movq	%rsp, %rdi
	movl	$100, %esi
	call	curandCreateGenerator@PLT
	movq	(%rsp), %rdi
	movl	$1234, %esi
	call	curandSetPseudoRandomGeneratorSeed@PLT
	movq	X(%rip), %rsi
	movq	(%rsp), %rdi
	movl	$1024000, %edx
	call	curandGenerateUniform@PLT
	movq	24+A(%rip), %rsi
	movq	(%rsp), %rdi
	movl	$1024000, %edx
	call	curandGenerateUniform@PLT
	movq	16+A(%rip), %rsi
	movq	(%rsp), %rdi
	movl	$1024000, %edx
	call	curandGenerateUniform@PLT
	movq	32+A(%rip), %rsi
	movq	(%rsp), %rdi
	movl	$1024000, %edx
	call	curandGenerateUniform@PLT
	movq	8+A(%rip), %rsi
	movq	(%rsp), %rdi
	movl	$1024000, %edx
	call	curandGenerateUniform@PLT
	movq	40+A(%rip), %rsi
	movq	(%rsp), %rdi
	movl	$1024000, %edx
	call	curandGenerateUniform@PLT
	movq	A(%rip), %rsi
	movq	(%rsp), %rdi
	movl	$1024000, %edx
	call	curandGenerateUniform@PLT
	movq	(%rsp), %rdi
	movl	$1024000, %edx
	movq	48+A(%rip), %rsi
	call	curandGenerateUniform@PLT
	movq	(%rsp), %rdi
	call	curandDestroyGenerator@PLT
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	je	.L6
	call	__stack_chk_fail@PLT
.L6:
	addq	$24, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2030:
	.size	_Z10initializev, .-_Z10initializev
	.globl	_Z51__device_stub__Z14heptaMatrixMul12sparseMatrixPfS0_R12sparseMatrixPfS1_
	.type	_Z51__device_stub__Z14heptaMatrixMul12sparseMatrixPfS0_R12sparseMatrixPfS1_, @function
_Z51__device_stub__Z14heptaMatrixMul12sparseMatrixPfS0_R12sparseMatrixPfS1_:
.LFB2055:
	.cfi_startproc
	endbr64
	subq	$120, %rsp
	.cfi_def_cfa_offset 128
	movq	%rsi, 8(%rsp)
	leaq	24(%rsp), %rcx
	leaq	44(%rsp), %rsi
	movq	%rdx, (%rsp)
	leaq	16(%rsp), %rdx
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rax
	movq	%rdi, 80(%rsp)
	leaq	32(%rsp), %rdi
	movq	%rax, 88(%rsp)
	movq	%rsp, %rax
	movq	%rax, 96(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 32(%rsp)
	movl	$1, 40(%rsp)
	movq	%rax, 44(%rsp)
	movl	$1, 52(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L9
	pushq	24(%rsp)
	.cfi_def_cfa_offset 136
	leaq	_Z14heptaMatrixMul12sparseMatrixPfS0_(%rip), %rdi
	pushq	24(%rsp)
	.cfi_def_cfa_offset 144
	movq	60(%rsp), %rcx
	movl	68(%rsp), %r8d
	movq	48(%rsp), %rsi
	movl	56(%rsp), %edx
	leaq	96(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 136
	popq	%rdx
	.cfi_def_cfa_offset 128
.L9:
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	je	.L11
	call	__stack_chk_fail@PLT
.L11:
	addq	$120, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2055:
	.size	_Z51__device_stub__Z14heptaMatrixMul12sparseMatrixPfS0_R12sparseMatrixPfS1_, .-_Z51__device_stub__Z14heptaMatrixMul12sparseMatrixPfS0_R12sparseMatrixPfS1_
	.globl	_Z14heptaMatrixMul12sparseMatrixPfS0_
	.type	_Z14heptaMatrixMul12sparseMatrixPfS0_, @function
_Z14heptaMatrixMul12sparseMatrixPfS0_:
.LFB2056:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	movq	%rsi, %rdx
	movq	%rdi, %rsi
	leaq	16(%rsp), %rdi
	call	_Z51__device_stub__Z14heptaMatrixMul12sparseMatrixPfS0_R12sparseMatrixPfS1_
	popq	%rdx
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2056:
	.size	_Z14heptaMatrixMul12sparseMatrixPfS0_, .-_Z14heptaMatrixMul12sparseMatrixPfS0_
	.globl	_Z60__device_stub__Z23heptaMatrixMulSharedMem12sparseMatrixPfS0_R12sparseMatrixPfS1_
	.type	_Z60__device_stub__Z23heptaMatrixMulSharedMem12sparseMatrixPfS0_R12sparseMatrixPfS1_, @function
_Z60__device_stub__Z23heptaMatrixMulSharedMem12sparseMatrixPfS0_R12sparseMatrixPfS1_:
.LFB2057:
	.cfi_startproc
	endbr64
	subq	$120, %rsp
	.cfi_def_cfa_offset 128
	movq	%rsi, 8(%rsp)
	leaq	24(%rsp), %rcx
	leaq	44(%rsp), %rsi
	movq	%rdx, (%rsp)
	leaq	16(%rsp), %rdx
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rax
	movq	%rdi, 80(%rsp)
	leaq	32(%rsp), %rdi
	movq	%rax, 88(%rsp)
	movq	%rsp, %rax
	movq	%rax, 96(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 32(%rsp)
	movl	$1, 40(%rsp)
	movq	%rax, 44(%rsp)
	movl	$1, 52(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L15
	pushq	24(%rsp)
	.cfi_def_cfa_offset 136
	leaq	_Z23heptaMatrixMulSharedMem12sparseMatrixPfS0_(%rip), %rdi
	pushq	24(%rsp)
	.cfi_def_cfa_offset 144
	movq	60(%rsp), %rcx
	movl	68(%rsp), %r8d
	movq	48(%rsp), %rsi
	movl	56(%rsp), %edx
	leaq	96(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 136
	popq	%rdx
	.cfi_def_cfa_offset 128
.L15:
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	je	.L17
	call	__stack_chk_fail@PLT
.L17:
	addq	$120, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2057:
	.size	_Z60__device_stub__Z23heptaMatrixMulSharedMem12sparseMatrixPfS0_R12sparseMatrixPfS1_, .-_Z60__device_stub__Z23heptaMatrixMulSharedMem12sparseMatrixPfS0_R12sparseMatrixPfS1_
	.globl	_Z23heptaMatrixMulSharedMem12sparseMatrixPfS0_
	.type	_Z23heptaMatrixMulSharedMem12sparseMatrixPfS0_, @function
_Z23heptaMatrixMulSharedMem12sparseMatrixPfS0_:
.LFB2058:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	movq	%rsi, %rdx
	movq	%rdi, %rsi
	leaq	16(%rsp), %rdi
	call	_Z60__device_stub__Z23heptaMatrixMulSharedMem12sparseMatrixPfS0_R12sparseMatrixPfS1_
	popq	%rdx
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2058:
	.size	_Z23heptaMatrixMulSharedMem12sparseMatrixPfS0_, .-_Z23heptaMatrixMulSharedMem12sparseMatrixPfS0_
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC1:
	.string	"GLOBAL MEMORY TIME: %f\n"
.LC2:
	.string	"SHARED MEMORY TIME: %f\n"
.LC3:
	.string	"\n SHARED  \tGLOBAL\n"
.LC4:
	.string	" %f\t%f\n"
.LC5:
	.string	"Error %f %f  :(\n"
.LC6:
	.string	"Results are Equivalent\n"
	.text
	.globl	_Z11performancev
	.type	_Z11performancev, @function
_Z11performancev:
.LFB2027:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	leaq	-8192000(%rsp), %r11
	.cfi_def_cfa 11, 8192040
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$72, %rsp
	.cfi_def_cfa_offset 8192112
	movq	%fs:40, %rax
	movq	%rax, 8192056(%rsp)
	xorl	%eax, %eax
	leaq	16(%rsp), %r13
	leaq	24(%rsp), %rbp
	movl	$0x00000000, 12(%rsp)
	movq	%r13, %rdi
	leaq	4096056(%rsp), %rbx
	call	cudaEventCreate@PLT
	movq	%rbp, %rdi
	call	cudaEventCreate@PLT
	movq	16(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movl	$33554433, %edx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	$67108989, %edi
	salq	$7, %rdx
	movl	$1, %ecx
	movl	$1, %esi
	salq	$6, %rdi
	movq	%rdx, 44(%rsp)
	movl	$1, 52(%rsp)
	movq	%rdi, 32(%rsp)
	movl	$1, 40(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L22
	leaq	A(%rip), %rsi
	movl	$14, %ecx
	movq	%rbx, %rdi
	movq	B(%rip), %rdx
	rep movsl
	movq	X(%rip), %rsi
	movq	%rbx, %rdi
	call	_Z51__device_stub__Z14heptaMatrixMul12sparseMatrixPfS0_R12sparseMatrixPfS1_
.L22:
	movq	24(%rsp), %rdi
	xorl	%esi, %esi
	leaq	12(%rsp), %r12
	call	cudaEventRecord@PLT
	movq	24(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movq	24(%rsp), %rdx
	movq	16(%rsp), %rsi
	movq	%r12, %rdi
	call	cudaEventElapsedTime@PLT
	movq	16(%rsp), %rdi
	call	cudaEventDestroy@PLT
	movq	24(%rsp), %rdi
	call	cudaEventDestroy@PLT
	leaq	.LC1(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	cvtss2sd	12(%rsp), %xmm0
	call	__printf_chk@PLT
	movl	$2, %ecx
	movq	B(%rip), %rsi
	movl	$4096000, %edx
	movq	%rbx, %rdi
	call	cudaMemcpy@PLT
	call	_Z13freeResourcesv
	call	_Z10initializev
	movq	%r13, %rdi
	movl	$0x00000000, 12(%rsp)
	call	cudaEventCreate@PLT
	movq	%rbp, %rdi
	leaq	56(%rsp), %rbp
	call	cudaEventCreate@PLT
	movq	16(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movl	$33554433, %edx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	$67108989, %edi
	salq	$7, %rdx
	movl	$1, %ecx
	movl	$1, %esi
	salq	$6, %rdi
	movq	%rdx, 44(%rsp)
	movl	$1, 52(%rsp)
	movq	%rdi, 32(%rsp)
	movl	$1, 40(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L23
	leaq	A(%rip), %rsi
	movl	$14, %ecx
	movq	%rbp, %rdi
	movq	B(%rip), %rdx
	rep movsl
	movq	X(%rip), %rsi
	movq	%rbp, %rdi
	call	_Z60__device_stub__Z23heptaMatrixMulSharedMem12sparseMatrixPfS0_R12sparseMatrixPfS1_
.L23:
	movq	24(%rsp), %rdi
	xorl	%esi, %esi
	leaq	.LC4(%rip), %r13
	call	cudaEventRecord@PLT
	movq	24(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movq	24(%rsp), %rdx
	movq	16(%rsp), %rsi
	movq	%r12, %rdi
	xorl	%r12d, %r12d
	call	cudaEventElapsedTime@PLT
	movq	16(%rsp), %rdi
	call	cudaEventDestroy@PLT
	movq	24(%rsp), %rdi
	call	cudaEventDestroy@PLT
	leaq	.LC2(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	cvtss2sd	12(%rsp), %xmm0
	call	__printf_chk@PLT
	movl	$2, %ecx
	movq	B(%rip), %rsi
	movl	$4096000, %edx
	movq	%rbp, %rdi
	call	cudaMemcpy@PLT
	leaq	.LC3(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L24:
	cvtss2sd	(%rbx,%r12), %xmm1
	movq	%r13, %rsi
	cvtss2sd	0(%rbp,%r12), %xmm0
	movl	$2, %edi
	movb	$2, %al
	addq	$4, %r12
	call	__printf_chk@PLT
	cmpq	$56, %r12
	jne	.L24
	xorl	%r12d, %r12d
	leaq	.LC5(%rip), %r13
.L27:
	movss	0(%rbp,%r12), %xmm0
	movss	(%rbx,%r12), %xmm1
	ucomiss	%xmm1, %xmm0
	jp	.L29
	je	.L25
.L29:
	movq	%r13, %rsi
	movl	$2, %edi
	movb	$2, %al
	cvtss2sd	%xmm0, %xmm0
	cvtss2sd	%xmm1, %xmm1
	call	__printf_chk@PLT
.L25:
	addq	$4, %r12
	cmpq	$4096000, %r12
	jne	.L27
	xorl	%eax, %eax
	leaq	.LC6(%rip), %rsi
	movl	$2, %edi
	call	__printf_chk@PLT
	movq	8192056(%rsp), %rax
	subq	%fs:40, %rax
	je	.L28
	call	__stack_chk_fail@PLT
.L28:
	addq	$8192072, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2027:
	.size	_Z11performancev, .-_Z11performancev
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2028:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	call	_Z10initializev
	call	_Z11performancev
	call	_Z13freeResourcesv
	xorl	%eax, %eax
	popq	%rdx
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2028:
	.size	main, .-main
	.section	.rodata.str1.1
.LC8:
	.string	"_Z23heptaMatrixMulSharedMem12sparseMatrixPfS0_"
.LC9:
	.string	"_Z14heptaMatrixMul12sparseMatrixPfS0_"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2060:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	pushq	$0
	.cfi_def_cfa_offset 24
	xorl	%r9d, %r9d
	orl	$-1, %r8d
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC8(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z23heptaMatrixMulSharedMem12sparseMatrixPfS0_(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 48
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r9d, %r9d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC9(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z14heptaMatrixMul12sparseMatrixPfS0_(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 40
	pushq	$0
	.cfi_def_cfa_offset 48
	call	__cudaRegisterFunction@PLT
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE2060:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.globl	B
	.bss
	.align 8
	.type	B, @object
	.size	B, 8
B:
	.zero	8
	.globl	X
	.align 8
	.type	X, @object
	.size	X, 8
X:
	.zero	8
	.globl	A
	.align 32
	.type	A, @object
	.size	A, 56
A:
	.zero	56
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:


#include <hip/hip_runtime.h>
#include "stdio.h"
#include "time.h"
#include "hiprand/hiprand.h"

#define SPACING 7 
#define BLOCKSIZE 128 
#define N (1024 * 1000) 
#define CACHE (2 * SPACING + BLOCKSIZE + 1)

/* SPACING : Offset b/w main and distant diagonal */
/* BLOCKSIZE : Threads per block, multiple of 32 */
/* N : Row/Column size */
/* CACHE : Size of shared memory per block */

#define HEPT(a) ((a)+3)

struct sparseMatrix {
    float* DIA[7];
} A;

float *X;
float *B;


void freeResources ();
void initialize ();

__global__ void heptaMatrixMul ( struct sparseMatrix A, float *X, float *B) {

    /* Using only Global Memory */
    int thrId = blockIdx.x * blockDim.x + threadIdx.x;

    int middle = SPACING + thrId;

    float Bvalue;
    Bvalue = A.DIA[HEPT(3)][thrId] * X[thrId]
            + A.DIA[HEPT(2)][thrId] *  X[middle - 2]
            + A.DIA[HEPT(1)][thrId] *  X[middle - 1]
            + A.DIA[HEPT(0)][thrId] *  X[middle]
            + A.DIA[HEPT(-1)][thrId] * X[middle + 1]
            + A.DIA[HEPT(-2)][thrId] * X[middle + 2]
            + A.DIA[HEPT(-3)][thrId] * X[middle + SPACING];

    B[thrId] = Bvalue;
}


__global__ void heptaMatrixMulSharedMem ( struct sparseMatrix A, float *X, float *B) {

    /* Caching vector X in Shared Memory 
    to avoid accessing each element 7 times 
    from Global Memory */

    int thrId = blockIdx.x * blockDim.x + threadIdx.x;

    int i, OFFSET = blockIdx.x * blockDim.x;
    __shared__ float Xc[CACHE];

    for ( i = threadIdx.x; i < (2 * SPACING + blockDim.x + 1); i+= blockDim.x )
        Xc[i] = X[OFFSET + i];

    __syncthreads();

    int middle = SPACING + threadIdx.x;

    float Bvalue;
    Bvalue = A.DIA[HEPT(3)][thrId] * Xc[threadIdx.x]
            + A.DIA[HEPT(2)][thrId] *  Xc[middle - 2]
            + A.DIA[HEPT(1)][thrId] *  Xc[middle - 1]
            + A.DIA[HEPT(0)][thrId] *  Xc[middle]
            + A.DIA[HEPT(-1)][thrId] * Xc[middle + 1]
            + A.DIA[HEPT(-2)][thrId] * Xc[middle + 2]
            + A.DIA[HEPT(-3)][thrId] * Xc[middle + SPACING];

    B[thrId] = Bvalue;
}


void performance () {

    /* Performance measure for Shared Memory Vs. only Global Memory */

    int i;
    float resultSharedMem[N], resultGlobalMem[N];



    float elapsed=0;
    hipEvent_t start, stop;

    hipEventCreate(&start);
    hipEventCreate(&stop);

    hipEventRecord(start, 0);

    heptaMatrixMul <<<N/BLOCKSIZE, BLOCKSIZE>>> ( A, X, B);

    hipEventRecord(stop, 0);
    hipEventSynchronize (stop);

    hipEventElapsedTime(&elapsed, start, stop);

    hipEventDestroy(start);
    hipEventDestroy(stop);

    printf("GLOBAL MEMORY TIME: %f\n", elapsed);




    hipMemcpy(resultGlobalMem, B, 
        sizeof(float) * N, hipMemcpyDeviceToHost);

    freeResources (); /* Flushing and Refilling */
    initialize (); /* to refresh GPU caches */


    elapsed=0;
    hipEventCreate(&start);
    hipEventCreate(&stop);

    hipEventRecord(start, 0);

    heptaMatrixMulSharedMem <<<N/BLOCKSIZE, BLOCKSIZE>>> ( A, X, B);

    hipEventRecord(stop, 0);
    hipEventSynchronize (stop);

    hipEventElapsedTime(&elapsed, start, stop);

    hipEventDestroy(start);
    hipEventDestroy(stop);

    printf("SHARED MEMORY TIME: %f\n", elapsed);

    
    hipMemcpy(resultSharedMem, B, 
        sizeof(float) * N, hipMemcpyDeviceToHost);
    
    printf("\n SHARED  \tGLOBAL\n");
    for ( i = 0; i < 2 * SPACING; ++i)
        printf(" %f\t%f\n", 
            resultSharedMem[i], resultGlobalMem[i]);

    for ( i = 0; i < N; ++i)
        if (resultSharedMem[i] != resultGlobalMem[i]) 
            printf("Error %f %f  :(\n", resultSharedMem[i], resultGlobalMem[i]);
    printf("Results are Equivalent\n");
}

int main ( int argc, char *argv[]) {
    initialize ();
    performance ();
    freeResources ();
    return 0;
}

 /* Random floats generation of Hepta Matrix using lib cuRAND */

void freeResources() {
    hipFree(X);
    hipFree(B);
    hipFree( A.DIA[HEPT(0)]);
    hipFree( A.DIA[HEPT(-1)]);
    hipFree( A.DIA[HEPT(1)]);
    hipFree( A.DIA[HEPT(-2)]);
    hipFree( A.DIA[HEPT(2)]);
    hipFree( A.DIA[HEPT(-3)]);
    hipFree( A.DIA[HEPT(3)]);
}

void initialize() {

    /* AX = B */

    /* Extended vector X */
    hipMalloc(&X, (N + 2*SPACING)* sizeof(float));

    /* Resultant vector B */
    hipMalloc(&B, N* sizeof(float));

    /* Extended diagonals of Hepta-Mat A */
    hipMalloc(&A.DIA[HEPT(0)],     N* sizeof(float));
    hipMalloc(&A.DIA[HEPT(-1)],    N* sizeof(float));
    hipMalloc(&A.DIA[HEPT(1)],     N* sizeof(float));
    hipMalloc(&A.DIA[HEPT(-2)],    N* sizeof(float));
    hipMalloc(&A.DIA[HEPT(2)],     N* sizeof(float));
    hipMalloc(&A.DIA[HEPT(-3)],    N* sizeof(float));
    hipMalloc(&A.DIA[HEPT(3)],     N* sizeof(float));

    
    hiprandGenerator_t gen;
    hiprandCreateGenerator(&gen, HIPRAND_RNG_PSEUDO_DEFAULT);
    hiprandSetPseudoRandomGeneratorSeed(gen, 1234ULL);

    /* Filling random floats in A and X */
    hiprandGenerateUniform(gen, X, N);
    hiprandGenerateUniform(gen, A.DIA[HEPT(0)],  N);
    hiprandGenerateUniform(gen, A.DIA[HEPT(-1)], N);
    hiprandGenerateUniform(gen, A.DIA[HEPT(1)],  N);
    hiprandGenerateUniform(gen, A.DIA[HEPT(-2)], N);
    hiprandGenerateUniform(gen, A.DIA[HEPT(2)],  N);
    hiprandGenerateUniform(gen, A.DIA[HEPT(-3)], N);
    hiprandGenerateUniform(gen, A.DIA[HEPT(3)],  N);

    hiprandDestroyGenerator(gen);
}
	.text
	.file	"heptaMatPerformance.hip"
	.globl	_Z29__device_stub__heptaMatrixMul12sparseMatrixPfS0_ # -- Begin function _Z29__device_stub__heptaMatrixMul12sparseMatrixPfS0_
	.type	_Z29__device_stub__heptaMatrixMul12sparseMatrixPfS0_,@function
_Z29__device_stub__heptaMatrixMul12sparseMatrixPfS0_: # @_Z29__device_stub__heptaMatrixMul12sparseMatrixPfS0_
	.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	$96, %rsp
	.cfi_def_cfa_offset 144
	.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	144(%rsp), %rdx
	leaq	64(%rsp), %rbx
	movq	%rdx, (%rbx)
	movq	%rax, 8(%rbx)
	movq	%rcx, 16(%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	$_Z14heptaMatrixMul12sparseMatrixPfS0_, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$112, %rsp
	.cfi_adjust_cfa_offset -112
	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	_Z29__device_stub__heptaMatrixMul12sparseMatrixPfS0_, .Lfunc_end0-_Z29__device_stub__heptaMatrixMul12sparseMatrixPfS0_
	.cfi_endproc
                                        # -- End function
	.globl	_Z38__device_stub__heptaMatrixMulSharedMem12sparseMatrixPfS0_ # -- Begin function _Z38__device_stub__heptaMatrixMulSharedMem12sparseMatrixPfS0_
	.type	_Z38__device_stub__heptaMatrixMulSharedMem12sparseMatrixPfS0_,@function
_Z38__device_stub__heptaMatrixMulSharedMem12sparseMatrixPfS0_: # @_Z38__device_stub__heptaMatrixMulSharedMem12sparseMatrixPfS0_
	.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	$96, %rsp
	.cfi_def_cfa_offset 144
	.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	144(%rsp), %rdx
	leaq	64(%rsp), %rbx
	movq	%rdx, (%rbx)
	movq	%rax, 8(%rbx)
	movq	%rcx, 16(%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	$_Z23heptaMatrixMulSharedMem12sparseMatrixPfS0_, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$112, %rsp
	.cfi_adjust_cfa_offset -112
	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_end1:
	.size	_Z38__device_stub__heptaMatrixMulSharedMem12sparseMatrixPfS0_, .Lfunc_end1-_Z38__device_stub__heptaMatrixMulSharedMem12sparseMatrixPfS0_
	.cfi_endproc
                                        # -- End function
	.globl	_Z11performancev                # -- Begin function _Z11performancev
	.type	_Z11performancev,@function
_Z11performancev:                       # @_Z11performancev
	.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	$8192080, %rsp                  # imm = 0x7D0050
	.cfi_def_cfa_offset 8192128
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movabsq	$4294967424, %rbx               # imm = 0x100000080
	movl	$0, 68(%rsp)
	leaq	72(%rsp), %r14
	movq	%r14, %rdi
	callq	hipEventCreate
	leaq	56(%rsp), %rdi
	callq	hipEventCreate
	movq	(%r14), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	leaq	7872(%rbx), %r14
	movq	%r14, %rdi
	movl	$1, %esi
	movq	%rbx, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB2_2
# %bb.1:
	movq	X(%rip), %rdi
	movq	B(%rip), %rsi
	movq	A+48(%rip), %rax
	movq	%rax, 48(%rsp)
	movups	A+32(%rip), %xmm0
	movups	%xmm0, 32(%rsp)
	movups	A+16(%rip), %xmm0
	movups	%xmm0, 16(%rsp)
	movups	A(%rip), %xmm0
	movups	%xmm0, (%rsp)
	callq	_Z29__device_stub__heptaMatrixMul12sparseMatrixPfS0_
.LBB2_2:
	leaq	56(%rsp), %r15
	movq	(%r15), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	(%r15), %rdi
	callq	hipEventSynchronize
	leaq	72(%rsp), %r12
	movq	(%r12), %rsi
	movq	(%r15), %rdx
	leaq	68(%rsp), %r13
	movq	%r13, %rdi
	callq	hipEventElapsedTime
	movq	(%r12), %rdi
	callq	hipEventDestroy
	movq	(%r15), %rdi
	callq	hipEventDestroy
	xorps	%xmm0, %xmm0
	cvtss2sd	(%r13), %xmm0
	movl	$.L.str, %edi
	movb	$1, %al
	callq	printf
	movq	B(%rip), %rsi
	leaq	80(%rsp), %rdi
	movl	$4096000, %edx                  # imm = 0x3E8000
	movl	$2, %ecx
	callq	hipMemcpy
	callq	_Z13freeResourcesv
	callq	_Z10initializev
	movl	$0, (%r13)
	movq	%r12, %rdi
	callq	hipEventCreate
	movq	%r15, %rdi
	callq	hipEventCreate
	movq	(%r12), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	%r14, %rdi
	movl	$1, %esi
	movq	%rbx, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB2_4
# %bb.3:
	movq	X(%rip), %rdi
	movq	B(%rip), %rsi
	movq	A+48(%rip), %rax
	movq	%rax, 48(%rsp)
	movups	A+32(%rip), %xmm0
	movups	%xmm0, 32(%rsp)
	movups	A+16(%rip), %xmm0
	movups	%xmm0, 16(%rsp)
	movups	A(%rip), %xmm0
	movups	%xmm0, (%rsp)
	callq	_Z38__device_stub__heptaMatrixMulSharedMem12sparseMatrixPfS0_
.LBB2_4:
	movq	56(%rsp), %rdi
	xorl	%r14d, %r14d
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	56(%rsp), %rdi
	callq	hipEventSynchronize
	movq	72(%rsp), %rsi
	movq	56(%rsp), %rdx
	leaq	68(%rsp), %rbx
	movq	%rbx, %rdi
	callq	hipEventElapsedTime
	movq	72(%rsp), %rdi
	callq	hipEventDestroy
	movq	56(%rsp), %rdi
	callq	hipEventDestroy
	xorps	%xmm0, %xmm0
	cvtss2sd	(%rbx), %xmm0
	movl	$.L.str.1, %edi
	movb	$1, %al
	callq	printf
	movq	B(%rip), %rsi
	leaq	4096080(%rsp), %rdi
	movl	$4096000, %edx                  # imm = 0x3E8000
	movl	$2, %ecx
	callq	hipMemcpy
	movl	$.Lstr, %edi
	callq	puts@PLT
.LBB2_5:                                # =>This Inner Loop Header: Depth=1
	xorps	%xmm0, %xmm0
	cvtss2sd	4096080(%rsp,%r14,4), %xmm0
	xorps	%xmm1, %xmm1
	cvtss2sd	80(%rsp,%r14,4), %xmm1
	movl	$.L.str.3, %edi
	movb	$2, %al
	callq	printf
	incq	%r14
	cmpq	$14, %r14
	jne	.LBB2_5
# %bb.6:                                # %.preheader.preheader
	xorl	%ebx, %ebx
.LBB2_7:                                # %.preheader
                                        # =>This Inner Loop Header: Depth=1
	movss	4096080(%rsp,%rbx,4), %xmm0     # xmm0 = mem[0],zero,zero,zero
	movss	80(%rsp,%rbx,4), %xmm1          # xmm1 = mem[0],zero,zero,zero
	ucomiss	%xmm1, %xmm0
	jne	.LBB2_8
	jnp	.LBB2_9
.LBB2_8:                                #   in Loop: Header=BB2_7 Depth=1
	cvtss2sd	%xmm0, %xmm0
	cvtss2sd	%xmm1, %xmm1
	movl	$.L.str.4, %edi
	movb	$2, %al
	callq	printf
.LBB2_9:                                #   in Loop: Header=BB2_7 Depth=1
	incq	%rbx
	cmpq	$1024000, %rbx                  # imm = 0xFA000
	jne	.LBB2_7
# %bb.10:
	movl	$.Lstr.1, %edi
	callq	puts@PLT
	addq	$8192080, %rsp                  # imm = 0x7D0050
	.cfi_def_cfa_offset 48
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end2:
	.size	_Z11performancev, .Lfunc_end2-_Z11performancev
	.cfi_endproc
                                        # -- End function
	.globl	_Z13freeResourcesv              # -- Begin function _Z13freeResourcesv
	.type	_Z13freeResourcesv,@function
_Z13freeResourcesv:                     # @_Z13freeResourcesv
	.cfi_startproc
# %bb.0:
	pushq	%rax
	.cfi_def_cfa_offset 16
	movq	X(%rip), %rdi
	callq	hipFree
	movq	B(%rip), %rdi
	callq	hipFree
	movq	A+24(%rip), %rdi
	callq	hipFree
	movq	A+16(%rip), %rdi
	callq	hipFree
	movq	A+32(%rip), %rdi
	callq	hipFree
	movq	A+8(%rip), %rdi
	callq	hipFree
	movq	A+40(%rip), %rdi
	callq	hipFree
	movq	A(%rip), %rdi
	callq	hipFree
	movq	A+48(%rip), %rdi
	popq	%rax
	.cfi_def_cfa_offset 8
	jmp	hipFree                         # TAILCALL
.Lfunc_end3:
	.size	_Z13freeResourcesv, .Lfunc_end3-_Z13freeResourcesv
	.cfi_endproc
                                        # -- End function
	.globl	_Z10initializev                 # -- Begin function _Z10initializev
	.type	_Z10initializev,@function
_Z10initializev:                        # @_Z10initializev
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$16, %rsp
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -16
	movl	$X, %edi
	movl	$4096056, %esi                  # imm = 0x3E8038
	callq	hipMalloc
	movl	$B, %edi
	movl	$4096000, %esi                  # imm = 0x3E8000
	callq	hipMalloc
	movl	$A+24, %edi
	movl	$4096000, %esi                  # imm = 0x3E8000
	callq	hipMalloc
	movl	$A+16, %edi
	movl	$4096000, %esi                  # imm = 0x3E8000
	callq	hipMalloc
	movl	$A+32, %edi
	movl	$4096000, %esi                  # imm = 0x3E8000
	callq	hipMalloc
	movl	$A+8, %edi
	movl	$4096000, %esi                  # imm = 0x3E8000
	callq	hipMalloc
	movl	$A+40, %edi
	movl	$4096000, %esi                  # imm = 0x3E8000
	callq	hipMalloc
	movl	$A, %edi
	movl	$4096000, %esi                  # imm = 0x3E8000
	callq	hipMalloc
	movl	$A+48, %edi
	movl	$4096000, %esi                  # imm = 0x3E8000
	callq	hipMalloc
	leaq	8(%rsp), %rbx
	movq	%rbx, %rdi
	movl	$400, %esi                      # imm = 0x190
	callq	hiprandCreateGenerator
	movq	(%rbx), %rdi
	movl	$1234, %esi                     # imm = 0x4D2
	callq	hiprandSetPseudoRandomGeneratorSeed
	movq	(%rbx), %rdi
	movq	X(%rip), %rsi
	movl	$1024000, %edx                  # imm = 0xFA000
	callq	hiprandGenerateUniform
	movq	(%rbx), %rdi
	movq	A+24(%rip), %rsi
	movl	$1024000, %edx                  # imm = 0xFA000
	callq	hiprandGenerateUniform
	movq	(%rbx), %rdi
	movq	A+16(%rip), %rsi
	movl	$1024000, %edx                  # imm = 0xFA000
	callq	hiprandGenerateUniform
	movq	(%rbx), %rdi
	movq	A+32(%rip), %rsi
	movl	$1024000, %edx                  # imm = 0xFA000
	callq	hiprandGenerateUniform
	movq	(%rbx), %rdi
	movq	A+8(%rip), %rsi
	movl	$1024000, %edx                  # imm = 0xFA000
	callq	hiprandGenerateUniform
	movq	(%rbx), %rdi
	movq	A+40(%rip), %rsi
	movl	$1024000, %edx                  # imm = 0xFA000
	callq	hiprandGenerateUniform
	movq	(%rbx), %rdi
	movq	A(%rip), %rsi
	movl	$1024000, %edx                  # imm = 0xFA000
	callq	hiprandGenerateUniform
	movq	(%rbx), %rdi
	movq	A+48(%rip), %rsi
	movl	$1024000, %edx                  # imm = 0xFA000
	callq	hiprandGenerateUniform
	movq	(%rbx), %rdi
	callq	hiprandDestroyGenerator
	addq	$16, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end4:
	.size	_Z10initializev, .Lfunc_end4-_Z10initializev
	.cfi_endproc
                                        # -- End function
	.globl	main                            # -- Begin function main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%rax
	.cfi_def_cfa_offset 16
	callq	_Z10initializev
	callq	_Z11performancev
	callq	_Z13freeResourcesv
	xorl	%eax, %eax
	popq	%rcx
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end5:
	.size	main, .Lfunc_end5-main
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$32, %rsp
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -16
	movq	__hip_gpubin_handle(%rip), %rbx
	testq	%rbx, %rbx
	jne	.LBB6_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB6_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z14heptaMatrixMul12sparseMatrixPfS0_, %esi
	movl	$.L__unnamed_1, %edx
	movl	$.L__unnamed_1, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z23heptaMatrixMulSharedMem12sparseMatrixPfS0_, %esi
	movl	$.L__unnamed_2, %edx
	movl	$.L__unnamed_2, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$__hip_module_dtor, %edi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_end6:
	.size	__hip_module_ctor, .Lfunc_end6-__hip_module_ctor
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_dtor
	.type	__hip_module_dtor,@function
__hip_module_dtor:                      # @__hip_module_dtor
	.cfi_startproc
# %bb.0:
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	je	.LBB7_2
# %bb.1:
	pushq	%rax
	.cfi_def_cfa_offset 16
	callq	__hipUnregisterFatBinary
	movq	$0, __hip_gpubin_handle(%rip)
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
.LBB7_2:
	retq
.Lfunc_end7:
	.size	__hip_module_dtor, .Lfunc_end7-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	A,@object                       # @A
	.bss
	.globl	A
	.p2align	3, 0x0
A:
	.zero	56
	.size	A, 56

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

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

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

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

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"GLOBAL MEMORY TIME: %f\n"
	.size	.L.str, 24

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"SHARED MEMORY TIME: %f\n"
	.size	.L.str.1, 24

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	" %f\t%f\n"
	.size	.L.str.3, 8

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"Error %f %f  :(\n"
	.size	.L.str.4, 17

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z14heptaMatrixMul12sparseMatrixPfS0_"
	.size	.L__unnamed_1, 38

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_Z23heptaMatrixMulSharedMem12sparseMatrixPfS0_"
	.size	.L__unnamed_2, 47

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

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

	.type	.Lstr,@object                   # @str
	.section	.rodata.str1.1,"aMS",@progbits,1
.Lstr:
	.asciz	"\n SHARED  \tGLOBAL"
	.size	.Lstr, 18

	.type	.Lstr.1,@object                 # @str.1
.Lstr.1:
	.asciz	"Results are Equivalent"
	.size	.Lstr.1, 23

	.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 _Z29__device_stub__heptaMatrixMul12sparseMatrixPfS0_
	.addrsig_sym _Z38__device_stub__heptaMatrixMulSharedMem12sparseMatrixPfS0_
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym A
	.addrsig_sym X
	.addrsig_sym B
	.addrsig_sym _Z14heptaMatrixMul12sparseMatrixPfS0_
	.addrsig_sym _Z23heptaMatrixMulSharedMem12sparseMatrixPfS0_
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z14heptaMatrixMul12sparseMatrixPfS0_ ; -- Begin function _Z14heptaMatrixMul12sparseMatrixPfS0_
	.globl	_Z14heptaMatrixMul12sparseMatrixPfS0_
	.p2align	8
	.type	_Z14heptaMatrixMul12sparseMatrixPfS0_,@function
_Z14heptaMatrixMul12sparseMatrixPfS0_:  ; @_Z14heptaMatrixMul12sparseMatrixPfS0_
; %bb.0:
	s_clause 0x2
	s_load_b32 s2, s[0:1], 0x54
	s_load_b512 s[16:31], s[0:1], 0x0
	s_load_b64 s[0:1], s[0:1], 0x40
	s_waitcnt lgkmcnt(0)
	s_and_b32 s2, s2, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s15, s2, v[0: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[4:5], 2, v[1:2]
	v_add_co_u32 v0, vcc_lo, s30, v4
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v1, vcc_lo, s31, v5, vcc_lo
	v_add_co_u32 v2, vcc_lo, s26, v4
	v_add_co_ci_u32_e32 v3, vcc_lo, s27, v5, vcc_lo
	v_add_co_u32 v6, vcc_lo, s28, v4
	v_add_co_ci_u32_e32 v7, vcc_lo, s29, v5, vcc_lo
	global_load_b32 v10, v[0:1], off
	global_load_b32 v11, v[2:3], off
	s_clause 0x2
	global_load_b32 v12, v[0:1], off offset:56
	global_load_b32 v13, v[0:1], off offset:36
	global_load_b128 v[0:3], v[0:1], off offset:20
	v_add_co_u32 v8, vcc_lo, s24, v4
	v_add_co_ci_u32_e32 v9, vcc_lo, s25, v5, vcc_lo
	global_load_b32 v14, v[6:7], off
	v_add_co_u32 v6, vcc_lo, s22, v4
	v_add_co_ci_u32_e32 v7, vcc_lo, s23, v5, vcc_lo
	global_load_b32 v15, v[8:9], off
	v_add_co_u32 v8, vcc_lo, s20, v4
	v_add_co_ci_u32_e32 v9, vcc_lo, s21, v5, vcc_lo
	global_load_b32 v16, v[6:7], off
	v_add_co_u32 v6, vcc_lo, s18, v4
	v_add_co_ci_u32_e32 v7, vcc_lo, s19, v5, vcc_lo
	global_load_b32 v17, v[8:9], off
	v_add_co_u32 v8, vcc_lo, s16, v4
	v_add_co_ci_u32_e32 v9, vcc_lo, s17, v5, vcc_lo
	global_load_b32 v6, v[6:7], off
	global_load_b32 v7, v[8:9], off
	s_waitcnt vmcnt(6)
	v_mul_f32_e32 v8, v11, v0
	v_add_co_u32 v0, vcc_lo, s0, v4
	s_waitcnt vmcnt(5)
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_fmac_f32_e32 v8, v14, v10
	s_waitcnt vmcnt(4)
	v_fmac_f32_e32 v8, v15, v1
	v_add_co_ci_u32_e32 v1, vcc_lo, s1, v5, vcc_lo
	s_waitcnt vmcnt(3)
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_fmac_f32_e32 v8, v16, v2
	s_waitcnt vmcnt(2)
	v_fmac_f32_e32 v8, v17, v3
	s_waitcnt vmcnt(1)
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_fmac_f32_e32 v8, v6, v13
	s_waitcnt vmcnt(0)
	v_fmac_f32_e32 v8, v7, v12
	global_store_b32 v[0:1], v8, off
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z14heptaMatrixMul12sparseMatrixPfS0_
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 328
		.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 18
		.amdhsa_next_free_sgpr 32
		.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	_Z14heptaMatrixMul12sparseMatrixPfS0_, .Lfunc_end0-_Z14heptaMatrixMul12sparseMatrixPfS0_
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 360
; NumSgprs: 34
; NumVgprs: 18
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 4
; VGPRBlocks: 2
; NumSGPRsForWavesPerEU: 34
; NumVGPRsForWavesPerEU: 18
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.protected	_Z23heptaMatrixMulSharedMem12sparseMatrixPfS0_ ; -- Begin function _Z23heptaMatrixMulSharedMem12sparseMatrixPfS0_
	.globl	_Z23heptaMatrixMulSharedMem12sparseMatrixPfS0_
	.p2align	8
	.type	_Z23heptaMatrixMulSharedMem12sparseMatrixPfS0_,@function
_Z23heptaMatrixMulSharedMem12sparseMatrixPfS0_: ; @_Z23heptaMatrixMulSharedMem12sparseMatrixPfS0_
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x54
	s_load_b512 s[16:31], s[0:1], 0x0
	v_lshlrev_b32_e32 v3, 2, v0
	s_mov_b32 s4, exec_lo
	s_waitcnt lgkmcnt(0)
	s_and_b32 s3, s2, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1)
	s_add_i32 s2, s3, 15
	s_mul_i32 s15, s15, s3
	v_cmpx_gt_u32_e64 s2, v0
	s_cbranch_execz .LBB1_3
; %bb.1:                                ; %.lr.ph.preheader
	v_add_nc_u32_e32 v1, s15, v0
	v_subrev_nc_u32_e32 v4, s3, v0
	v_mov_b32_e32 v5, v3
	s_mov_b32 s5, 0
	s_lshl_b32 s6, s3, 2
	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, vcc_lo, s30, v1
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v2, vcc_lo, s31, v2, vcc_lo
.LBB1_2:                                ; %.lr.ph
                                        ; =>This Inner Loop Header: Depth=1
	global_load_b32 v6, v[1:2], off
	v_add_nc_u32_e32 v4, s3, v4
	v_add_co_u32 v1, vcc_lo, v1, s6
	v_add_co_ci_u32_e32 v2, vcc_lo, 0, v2, vcc_lo
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cmp_lt_u32_e64 s2, 14, v4
	s_or_b32 s5, s2, s5
	s_waitcnt vmcnt(0)
	ds_store_b32 v5, v6
	v_add_nc_u32_e32 v5, s6, v5
	s_and_not1_b32 exec_lo, exec_lo, s5
	s_cbranch_execnz .LBB1_2
.LBB1_3:                                ; %Flow40
	s_or_b32 exec_lo, exec_lo, s4
	v_add_nc_u32_e32 v0, s15, v0
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	s_load_b64 s[0:1], s[0:1], 0x40
	v_ashrrev_i32_e32 v1, 31, v0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[0:1], 2, v[0:1]
	v_add_co_u32 v4, vcc_lo, s26, v0
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v5, vcc_lo, s27, v1, vcc_lo
	v_add_co_u32 v6, vcc_lo, s28, v0
	v_add_co_ci_u32_e32 v7, vcc_lo, s29, v1, vcc_lo
	global_load_b32 v2, v[4:5], off
	v_add_co_u32 v4, vcc_lo, s24, v0
	v_add_co_ci_u32_e32 v5, vcc_lo, s25, v1, vcc_lo
	global_load_b32 v10, v[6:7], off
	v_add_co_u32 v6, vcc_lo, s22, v0
	v_add_co_ci_u32_e32 v7, vcc_lo, s23, v1, vcc_lo
	global_load_b32 v11, v[4:5], off
	v_add_co_u32 v4, vcc_lo, s20, v0
	v_add_co_ci_u32_e32 v5, vcc_lo, s21, v1, vcc_lo
	global_load_b32 v12, v[6:7], off
	v_add_co_u32 v6, vcc_lo, s18, v0
	v_add_co_ci_u32_e32 v7, vcc_lo, s19, v1, vcc_lo
	global_load_b32 v13, v[4:5], off
	v_add_co_u32 v4, vcc_lo, s16, v0
	v_add_co_ci_u32_e32 v5, vcc_lo, s17, v1, vcc_lo
	global_load_b32 v14, v[6:7], off
	global_load_b32 v15, v[4:5], off
	ds_load_2addr_b32 v[4:5], v3 offset0:5 offset1:6
	ds_load_2addr_b32 v[6:7], v3 offset1:9
	ds_load_2addr_b32 v[8:9], v3 offset0:7 offset1:8
	ds_load_b32 v3, v3 offset:56
	s_waitcnt lgkmcnt(0)
	v_add_co_u32 v0, vcc_lo, s0, v0
	v_add_co_ci_u32_e32 v1, vcc_lo, s1, v1, vcc_lo
	s_waitcnt vmcnt(6)
	v_mul_f32_e32 v2, v2, v4
	s_waitcnt vmcnt(5)
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_fmac_f32_e32 v2, v10, v6
	s_waitcnt vmcnt(4)
	v_fmac_f32_e32 v2, v11, v5
	s_waitcnt vmcnt(3)
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_fmac_f32_e32 v2, v12, v8
	s_waitcnt vmcnt(2)
	v_fmac_f32_e32 v2, v13, v9
	s_waitcnt vmcnt(1)
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_fmac_f32_e32 v2, v14, v7
	s_waitcnt vmcnt(0)
	v_fmac_f32_e32 v2, v15, v3
	global_store_b32 v[0:1], v2, off
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z23heptaMatrixMulSharedMem12sparseMatrixPfS0_
		.amdhsa_group_segment_fixed_size 572
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 328
		.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 16
		.amdhsa_next_free_sgpr 32
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end1:
	.size	_Z23heptaMatrixMulSharedMem12sparseMatrixPfS0_, .Lfunc_end1-_Z23heptaMatrixMulSharedMem12sparseMatrixPfS0_
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 508
; NumSgprs: 34
; NumVgprs: 16
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 572 bytes/workgroup (compile time only)
; SGPRBlocks: 4
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 34
; NumVGPRsForWavesPerEU: 16
; 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:
      - .offset:         0
        .size:           56
        .value_kind:     by_value
      - .address_space:  global
        .offset:         56
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         64
        .size:           8
        .value_kind:     global_buffer
      - .offset:         72
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         76
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         80
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         84
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         86
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         88
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         90
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         92
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         94
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         112
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         120
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         128
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         136
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 328
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z14heptaMatrixMul12sparseMatrixPfS0_
    .private_segment_fixed_size: 0
    .sgpr_count:     34
    .sgpr_spill_count: 0
    .symbol:         _Z14heptaMatrixMul12sparseMatrixPfS0_.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     18
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
  - .args:
      - .offset:         0
        .size:           56
        .value_kind:     by_value
      - .address_space:  global
        .offset:         56
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         64
        .size:           8
        .value_kind:     global_buffer
      - .offset:         72
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         76
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         80
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         84
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         86
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         88
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         90
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         92
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         94
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         112
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         120
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         128
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         136
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 572
    .kernarg_segment_align: 8
    .kernarg_segment_size: 328
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z23heptaMatrixMulSharedMem12sparseMatrixPfS0_
    .private_segment_fixed_size: 0
    .sgpr_count:     34
    .sgpr_spill_count: 0
    .symbol:         _Z23heptaMatrixMulSharedMem12sparseMatrixPfS0_.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     16
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
