//MatAdd.cu
// author: Pan Yang
// date  : 2015-7-5

#include <stdio.h> 
#include <stdlib.h>
#include <time.h>
    
#define M 80  // height of A
#define N 48  // width of A ( == height of B)
#define P 128  // width of B

#define BLOCK_SIZE 16

typedef struct {
    int height;
    int width;
    int stride;
    float *elements;
}Matrix;
    
// cpu code definition 
void MatMulOnHost(const Matrix A, const Matrix B, Matrix C)
{
    int i, j, k;
    for (i = 0; i < A.height; ++i)
    {
        for (j = 0; j < B.width; ++j)
        {
            float sum_ij = 0;
            
            for (k = 0; k < A.width; ++k)
                sum_ij += A.elements[i * A.width + k] * B.elements[k * B.width + j];
            C.elements[i * C.width + j] = sum_ij;
        }
    }
}

// Kernel definition for Matrix multiplication
__global__ void MatMul(const Matrix A, const Matrix B, Matrix C)
{
    /// Block index
    int bx = blockIdx.x;
    int by = blockIdx.y;

    // Thread index
    int tx = threadIdx.x;
    int ty = threadIdx.y;

    // Index of the first sub-matrix of A processed by the block
    int aBegin = A.width * BLOCK_SIZE * by;

    // Index of the last sub-matrix of A processed by the block
    int aEnd   = aBegin + A.width - 1;

    // Step size used to iterate through the sub-matrices of A
    int aStep  = BLOCK_SIZE;

    // Index of the first sub-matrix of B processed by the block
    int bBegin = BLOCK_SIZE * bx;

    // Step size used to iterate through the sub-matrices of B
    int bStep  = BLOCK_SIZE * B.width;

    // Csub is used to store the element of the block sub-matrix
    // that is computed by the thread
    float Cvalue = 0;
    
    // shared memory used to store Asub and Bsub
    __shared__ float As[BLOCK_SIZE][BLOCK_SIZE];
    __shared__ float Bs[BLOCK_SIZE][BLOCK_SIZE];
    
    // loop over all the sub matrices of A and B that are required to compute Csub,
    // multiply each pair of sub matrices together and sum the results
    int a, b, k;
    for (a = aBegin, b = bBegin; a <= aEnd; a += aStep, b += bStep)
    {
        // load Asub and Bsub from global memory to shared memory
        // Each thread loads one element of each sub-matrix
        As[ty][tx] = A.elements[a + A.width * ty + tx];
        Bs[ty][tx] = B.elements[b + B.width * ty + tx];
        
        // synchronize to make sure the sub-matrices are loaded before starting calculation
        __syncthreads();
        
        // multiply Asub and Bsub together
        for (k = 0; k < BLOCK_SIZE; ++k)
            Cvalue += As[ty][k] * Bs[k][tx];
        
        // synchronize to make sure that the preceding calculation is done before loading 
        // two new sub-matrices
        __syncthreads();
    }
    
    // write Cvalue to global memory, each thread write one element
    int c = C.width * BLOCK_SIZE * by + BLOCK_SIZE * bx;
    C.elements[c + C.width * ty + tx] = Cvalue;
}

int main() 
{ 
    // get the basic infomation of GPU device
    printf("\n");
    printf("[Matrix Multiply Using CUDA] - Starting...\n");
    int devID = 0;
    cudaDeviceProp deviceProp;
    cudaError_t error;
    
    error = cudaGetDeviceProperties(&deviceProp, devID);
    if (error != cudaSuccess)
    {
        printf("cudaGetDeviceProperties returned error code %d, line(%d)\n", error, __LINE__);
    }
    else
    {
        printf("GPU Device %d: \"%s\" with compute capability %d.%d\n\n", devID, deviceProp.name, deviceProp.major,      deviceProp.minor);
    }
    
    // load A, B, C on host
    Matrix A;
    A.height = M;
    A.width = N;
    size_t size = A.height * A.width * sizeof(float);
    A.elements = (float *)malloc(size);
    
    Matrix B;
    B.height = N;
    B.width = P;
    size = B.height * B.width * sizeof(float);
    B.elements = (float *)malloc(size);
    
    // initialize A
    srand(rand());
    int i;
    for (i = 0; i < A.height * A.width; ++i)
    {
        A.elements[i] = rand() / (float)RAND_MAX;
        //A.elements[i] = 1.0;
    }
    // initialize B
    srand(rand());
    for (i = 0; i < B.height * B.width; ++i)
    {
        B.elements[i] = rand() / (float)RAND_MAX;
        //B.elements[i] = 0.01;
    }
    
    Matrix C;
    C.height = M;
    C.width = P;
    size = C.height * C.width * sizeof(float);
    C.elements = (float *)malloc(size); // default all zeros
    
    Matrix ref_C; // reference C for result check
    ref_C.height = M;
    ref_C.width = P;
    size = ref_C.height * ref_C.width * sizeof(float);
    ref_C.elements = (float *)malloc(size); // default all zeros
    
    // load a, b, c on device
    Matrix d_A;
    d_A.height = M;
    d_A.width = N;
    size = d_A.height * d_A.width * sizeof(float);
    cudaMalloc(&d_A.elements, size); // alloc memory on device
    cudaMemcpy(d_A.elements, A.elements, size, cudaMemcpyHostToDevice); // copy data from host to device
    
    Matrix d_B;
    d_B.height = N;
    d_B.width = P;
    size = d_B.height * d_B.width * sizeof(float);
    cudaMalloc(&d_B.elements, size);
    cudaMemcpy(d_B.elements, B.elements, size, cudaMemcpyHostToDevice);
    
    Matrix d_C;
    d_C.height = M;
    d_C.width = P;
    size = d_C.height * d_C.width * sizeof(float);
    cudaMalloc(&d_C.elements, size); // default are not zeros, maybe random number
    
    // Kernel invocation with m*16*16 threads
    dim3 BlockDim(BLOCK_SIZE, BLOCK_SIZE);
    dim3 GridDim((P + BlockDim.x - 1) / BlockDim.x, (M + BlockDim.x - 1) / BlockDim.y);
    
    cudaEvent_t start_cu, stop_cu;
    float time_gpu = 0.0f;
    cudaEventCreate(&start_cu);
    cudaEventCreate(&stop_cu);
    cudaEventRecord( start_cu, 0);
    
    int nIter = 300;
    
    for (i = 0; i < nIter; ++i)
    {
        MatMul<<<GridDim, BlockDim>>>(d_A, d_B, d_C);
    }
    cudaEventRecord( stop_cu, 0);
    cudaEventSynchronize( stop_cu );
    cudaEventElapsedTime( &time_gpu, start_cu, stop_cu );
    cudaEventDestroy( start_cu );
    cudaEventDestroy( stop_cu );
    
    float msecPerMatrixMul = time_gpu / nIter;
    double flopsPerMatrixMul = 2.0 * (double)A.width * (double)A.height * (double)B.width;
    double gigaFlops = (flopsPerMatrixMul * 1.0e-9f) / (msecPerMatrixMul / 1000.0f);
    printf("Performance= %.2f GFlop/s, Time= %.3f msec, Size= %.0f Ops, WorkgroupSize= %u threads/block\n",
            gigaFlops,
            msecPerMatrixMul,
            flopsPerMatrixMul,
            BlockDim.x * BlockDim.y);
    
    // copy results form device memory to host memory
    cudaMemcpy( C.elements, d_C.elements, size, cudaMemcpyDeviceToHost );
  
    MatMulOnHost(A, B, ref_C);
    printf("GridDim: (%d, %d)\n", GridDim.x, GridDim.y);

    // test relative error by the formula
    //     |<x, y>_cpu - <x,y>_gpu| / <|x|, |y|>  < eps
    printf("Checking computed result for correctness ... \n");
    bool correct = true;
    
    double eps = 1.e-6 ; // machine zero

    for (int i = 0; i < (int)(M * P); i++)
    {
        double abs_err = fabs(ref_C.elements[i] - C.elements[i]);
        double dot_length = A.width;
        double abs_val = fabs(ref_C.elements[i]);
        double rel_err = abs_err / abs_val / dot_length ;

        if (rel_err > eps)
        {
            //printf("Error! Matrix[%05d]=%.8f, ref=%.8f error term is > %E\n", i, ref_C.elements[i], C.elements[i], eps);
            correct = false;
        }
    }
    
    printf("%s\n", correct ? "Result = PASS" : "Result = FAIL");

    // free space on host and device
    free(C.elements); 
    free(B.elements); 
    free(A.elements);
    
    cudaFree(d_A.elements);
    cudaFree(d_B.elements);
    cudaFree(d_C.elements);
    
    return 0;
}

	.file	"tmpxft_00371c32_00000000-6_MatMul_share.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2031:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2031:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z12MatMulOnHost6MatrixS_S_
	.type	_Z12MatMulOnHost6MatrixS_S_, @function
_Z12MatMulOnHost6MatrixS_S_:
.LFB2027:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	xorl	%ecx, %ecx
	xorl	%esi, %esi
	xorl	%edi, %edi
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movl	56(%rsp), %eax
	movslq	84(%rsp), %r8
	movl	60(%rsp), %r10d
	movq	120(%rsp), %r13
	movq	72(%rsp), %rbp
	movl	%eax, -4(%rsp)
	movq	96(%rsp), %r14
	movq	%r8, %r11
	salq	$2, %r8
	movl	108(%rsp), %r15d
.L3:
	cmpl	%edi, -4(%rsp)
	jle	.L2
	movslq	%esi, %rax
	leaq	0(%r13,%rax,4), %r12
	movslq	%ecx, %rax
	leaq	0(%rbp,%rax,4), %rbx
	xorl	%eax, %eax
.L8:
	cmpl	%eax, %r11d
	jle	.L5
	leaq	(%r14,%rax,4), %r9
	xorl	%edx, %edx
	xorps	%xmm0, %xmm0
.L6:
	cmpl	%edx, %r10d
	jle	.L11
	movss	(%rbx,%rdx,4), %xmm1
	mulss	(%r9), %xmm1
	incq	%rdx
	addq	%r8, %r9
	addss	%xmm1, %xmm0
	jmp	.L6
.L11:
	movss	%xmm0, (%r12,%rax,4)
	incq	%rax
	jmp	.L8
.L5:
	incl	%edi
	addl	%r15d, %esi
	addl	%r10d, %ecx
	jmp	.L3
.L2:
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2027:
	.size	_Z12MatMulOnHost6MatrixS_S_, .-_Z12MatMulOnHost6MatrixS_S_
	.globl	_Z34__device_stub__Z6MatMul6MatrixS_S_RK6MatrixS1_RS_
	.type	_Z34__device_stub__Z6MatMul6MatrixS_S_RK6MatrixS1_RS_, @function
_Z34__device_stub__Z6MatMul6MatrixS_S_RK6MatrixS1_RS_:
.LFB2053:
	.cfi_startproc
	endbr64
	subq	$104, %rsp
	.cfi_def_cfa_offset 112
	movq	%fs:40, %rax
	movq	%rax, 88(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rcx
	movq	%rdi, 64(%rsp)
	movabsq	$4294967297, %rax
	movq	%rsi, 72(%rsp)
	leaq	16(%rsp), %rdi
	leaq	28(%rsp), %rsi
	movq	%rdx, 80(%rsp)
	movq	%rsp, %rdx
	movq	%rax, 16(%rsp)
	movl	$1, 24(%rsp)
	movq	%rax, 28(%rsp)
	movl	$1, 36(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L12
	pushq	8(%rsp)
	.cfi_def_cfa_offset 120
	leaq	_Z6MatMul6MatrixS_S_(%rip), %rdi
	pushq	8(%rsp)
	.cfi_def_cfa_offset 128
	movq	44(%rsp), %rcx
	movl	52(%rsp), %r8d
	movq	32(%rsp), %rsi
	movl	40(%rsp), %edx
	leaq	80(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 120
	popq	%rdx
	.cfi_def_cfa_offset 112
.L12:
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	je	.L14
	call	__stack_chk_fail@PLT
.L14:
	addq	$104, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2053:
	.size	_Z34__device_stub__Z6MatMul6MatrixS_S_RK6MatrixS1_RS_, .-_Z34__device_stub__Z6MatMul6MatrixS_S_RK6MatrixS1_RS_
	.globl	_Z6MatMul6MatrixS_S_
	.type	_Z6MatMul6MatrixS_S_, @function
_Z6MatMul6MatrixS_S_:
.LFB2054:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	leaq	64(%rsp), %rdx
	leaq	40(%rsp), %rsi
	leaq	16(%rsp), %rdi
	call	_Z34__device_stub__Z6MatMul6MatrixS_S_RK6MatrixS1_RS_
	popq	%rdx
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2054:
	.size	_Z6MatMul6MatrixS_S_, .-_Z6MatMul6MatrixS_S_
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC1:
	.string	"Result = PASS"
.LC2:
	.string	"Result = FAIL"
.LC3:
	.string	"\n"
.LC4:
	.string	"[Matrix Multiply Using CUDA] - Starting...\n"
.LC5:
	.string	"cudaGetDeviceProperties returned error code %d, line(%d)\n"
.LC6:
	.string	"GPU Device %d: \"%s\" with compute capability %d.%d\n\n"
.LC12:
	.string	"Performance= %.2f GFlop/s, Time= %.3f msec, Size= %.0f Ops, WorkgroupSize= %u threads/block\n"
.LC13:
	.string	"GridDim: (%d, %d)\n"
.LC14:
	.string	"Checking computed result for correctness ... \n"
.LC18:
	.string	"%s\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2028:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	.LC3(%rip), %rsi
	movl	$2, %edi
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$1240, %rsp
	.cfi_def_cfa_offset 1296
	movq	%fs:40, %rax
	movq	%rax, 1224(%rsp)
	xorl	%eax, %eax
	leaq	192(%rsp), %rbx
	call	__printf_chk@PLT
	leaq	.LC4(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	xorl	%esi, %esi
	movq	%rbx, %rdi
	call	cudaGetDeviceProperties_v2@PLT
	testl	%eax, %eax
	je	.L19
	movl	%eax, %edx
	movl	$112, %ecx
	leaq	.LC5(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
	jmp	.L20
.L19:
	movl	556(%rsp), %r9d
	movq	%rbx, %rcx
	xorl	%edx, %edx
	xorl	%eax, %eax
	movl	552(%rsp), %r8d
	leaq	.LC6(%rip), %rsi
	movl	$2, %edi
	call	__printf_chk@PLT
.L20:
	movl	$15360, %edi
	xorl	%r12d, %r12d
	call	malloc@PLT
	movl	$24576, %edi
	movq	%rax, %rbx
	call	malloc@PLT
	movq	%rax, %rbp
	call	rand@PLT
	movl	%eax, %edi
	call	srand@PLT
.L21:
	call	rand@PLT
	cvtsi2ssl	%eax, %xmm0
	mulss	.LC7(%rip), %xmm0
	movss	%xmm0, (%rbx,%r12,4)
	incq	%r12
	cmpq	$3840, %r12
	jne	.L21
	call	rand@PLT
	xorl	%r12d, %r12d
	movl	%eax, %edi
	call	srand@PLT
.L22:
	call	rand@PLT
	cvtsi2ssl	%eax, %xmm0
	mulss	.LC7(%rip), %xmm0
	movss	%xmm0, 0(%rbp,%r12,4)
	incq	%r12
	cmpq	$6144, %r12
	jne	.L22
	movl	$40960, %edi
	movl	$300, %r14d
	movabsq	$21474836488, %r15
	call	malloc@PLT
	movl	$40960, %edi
	movq	%rax, %r12
	call	malloc@PLT
	leaq	64(%rsp), %rdi
	movl	$15360, %esi
	movq	%rax, %r13
	movabsq	$206158430288, %rax
	movq	%rax, 48(%rsp)
	call	cudaMalloc@PLT
	movq	64(%rsp), %rdi
	movl	$1, %ecx
	movq	%rbx, %rsi
	movl	$15360, %edx
	call	cudaMemcpy@PLT
	leaq	88(%rsp), %rdi
	movl	$24576, %esi
	movabsq	$549755813936, %rax
	movq	%rax, 72(%rsp)
	call	cudaMalloc@PLT
	movq	88(%rsp), %rdi
	movl	$1, %ecx
	movq	%rbp, %rsi
	movl	$24576, %edx
	call	cudaMemcpy@PLT
	movl	$40960, %esi
	leaq	112(%rsp), %rdi
	movabsq	$549755813968, %rax
	movq	%rax, 96(%rsp)
	call	cudaMalloc@PLT
	leaq	8(%rsp), %rdi
	movl	$1, 32(%rsp)
	movl	$1, 44(%rsp)
	movl	$0x00000000, 4(%rsp)
	call	cudaEventCreate@PLT
	leaq	16(%rsp), %rdi
	call	cudaEventCreate@PLT
	movq	8(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
.L24:
	movl	32(%rsp), %ecx
	movl	44(%rsp), %esi
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movabsq	$68719476752, %rdx
	movq	%r15, %rdi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L23
	movq	64(%rsp), %rax
	movups	48(%rsp), %xmm5
	leaq	168(%rsp), %rdx
	leaq	144(%rsp), %rsi
	movups	72(%rsp), %xmm6
	movups	96(%rsp), %xmm7
	leaq	120(%rsp), %rdi
	movq	%rax, 136(%rsp)
	movq	88(%rsp), %rax
	movups	%xmm5, 120(%rsp)
	movq	%rax, 160(%rsp)
	movq	112(%rsp), %rax
	movups	%xmm6, 144(%rsp)
	movq	%rax, 184(%rsp)
	movups	%xmm7, 168(%rsp)
	call	_Z34__device_stub__Z6MatMul6MatrixS_S_RK6MatrixS1_RS_
.L23:
	decl	%r14d
	jne	.L24
	movq	16(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	16(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movq	16(%rsp), %rdx
	movq	8(%rsp), %rsi
	leaq	4(%rsp), %rdi
	call	cudaEventElapsedTime@PLT
	movq	8(%rsp), %rdi
	call	cudaEventDestroy@PLT
	movq	16(%rsp), %rdi
	call	cudaEventDestroy@PLT
	movsd	.LC11(%rip), %xmm0
	movb	$3, %al
	movss	4(%rsp), %xmm1
	divss	.LC8(%rip), %xmm1
	movaps	%xmm1, %xmm2
	movl	$256, %edx
	divss	.LC10(%rip), %xmm2
	cvtss2sd	%xmm2, %xmm2
	divsd	%xmm2, %xmm0
	movsd	.LC9(%rip), %xmm2
	cvtss2sd	%xmm1, %xmm1
	leaq	.LC12(%rip), %rsi
	movl	$2, %edi
	call	__printf_chk@PLT
	movq	112(%rsp), %rsi
	movl	$2, %ecx
	movq	%r12, %rdi
	movl	$40960, %edx
	call	cudaMemcpy@PLT
	movq	%rbx, 136(%rsp)
	subq	$80, %rsp
	.cfi_def_cfa_offset 1376
	movabsq	$206158430288, %rax
	movq	%rax, 200(%rsp)
	movabsq	$549755813936, %rax
	movq	%rax, 224(%rsp)
	addq	$32, %rax
	movq	%rax, 248(%rsp)
	movq	%rbp, 240(%rsp)
	movq	%r13, 264(%rsp)
	movups	248(%rsp), %xmm3
	movups	224(%rsp), %xmm4
	movups	200(%rsp), %xmm5
	movq	%r13, 64(%rsp)
	movups	%xmm3, 48(%rsp)
	movups	%xmm4, 24(%rsp)
	movups	%xmm5, (%rsp)
	movq	%rbp, 40(%rsp)
	movq	%rbx, 16(%rsp)
	call	_Z12MatMulOnHost6MatrixS_S_
	movl	$5, %ecx
	addq	$80, %rsp
	.cfi_def_cfa_offset 1296
	xorl	%eax, %eax
	movl	$8, %edx
	leaq	.LC13(%rip), %rsi
	movl	$2, %edi
	call	__printf_chk@PLT
	leaq	.LC14(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	xorl	%eax, %eax
	movb	$1, %dl
	xorl	%ecx, %ecx
	movsd	.LC16(%rip), %xmm4
	movsd	.LC17(%rip), %xmm3
	movss	.LC15(%rip), %xmm2
.L26:
	movss	0(%r13,%rax), %xmm1
	movaps	%xmm1, %xmm0
	subss	(%r12,%rax), %xmm0
	andps	%xmm2, %xmm1
	cvtss2sd	%xmm1, %xmm1
	andps	%xmm2, %xmm0
	cvtss2sd	%xmm0, %xmm0
	divsd	%xmm1, %xmm0
	divsd	%xmm4, %xmm0
	ucomisd	%xmm3, %xmm0
	cmova	%ecx, %edx
	addq	$4, %rax
	cmpq	$40960, %rax
	jne	.L26
	testb	%dl, %dl
	leaq	.LC1(%rip), %rax
	movl	$2, %edi
	leaq	.LC2(%rip), %rdx
	leaq	.LC18(%rip), %rsi
	cmovne	%rax, %rdx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	%r12, %rdi
	call	free@PLT
	movq	%rbp, %rdi
	call	free@PLT
	movq	%rbx, %rdi
	call	free@PLT
	movq	64(%rsp), %rdi
	call	cudaFree@PLT
	movq	88(%rsp), %rdi
	call	cudaFree@PLT
	movq	112(%rsp), %rdi
	call	cudaFree@PLT
	movq	1224(%rsp), %rax
	subq	%fs:40, %rax
	je	.L28
	call	__stack_chk_fail@PLT
.L28:
	addq	$1240, %rsp
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2028:
	.size	main, .-main
	.section	.rodata.str1.1
.LC19:
	.string	"_Z6MatMul6MatrixS_S_"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2056:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	pushq	$0
	.cfi_def_cfa_offset 24
	xorl	%r9d, %r9d
	orl	$-1, %r8d
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC19(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z6MatMul6MatrixS_S_(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 48
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFunction@PLT
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rdx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE2056:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.section	.rodata.cst4,"aM",@progbits,4
	.align 4
.LC7:
	.long	805306368
	.align 4
.LC8:
	.long	1133903872
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC9:
	.long	0
	.long	1093533696
	.section	.rodata.cst4
	.align 4
.LC10:
	.long	1148846080
	.section	.rodata.cst8
	.align 8
.LC11:
	.long	570425344
	.long	1062214443
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC15:
	.long	2147483647
	.long	0
	.long	0
	.long	0
	.section	.rodata.cst8
	.align 8
.LC16:
	.long	0
	.long	1078460416
	.align 8
.LC17:
	.long	-1598689907
	.long	1051772663
	.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:

//MatAdd.cu
// author: Pan Yang
// date  : 2015-7-5


#include <hip/hip_runtime.h>
#include <stdio.h> 
#include <stdlib.h>
#include <time.h>
    
#define M 80  // height of A
#define N 48  // width of A ( == height of B)
#define P 128  // width of B

#define BLOCK_SIZE 16

typedef struct {
    int height;
    int width;
    int stride;
    float *elements;
}Matrix;
    
// cpu code definition 
void MatMulOnHost(const Matrix A, const Matrix B, Matrix C)
{
    int i, j, k;
    for (i = 0; i < A.height; ++i)
    {
        for (j = 0; j < B.width; ++j)
        {
            float sum_ij = 0;
            
            for (k = 0; k < A.width; ++k)
                sum_ij += A.elements[i * A.width + k] * B.elements[k * B.width + j];
            C.elements[i * C.width + j] = sum_ij;
        }
    }
}

// Kernel definition for Matrix multiplication
__global__ void MatMul(const Matrix A, const Matrix B, Matrix C)
{
    /// Block index
    int bx = blockIdx.x;
    int by = blockIdx.y;

    // Thread index
    int tx = threadIdx.x;
    int ty = threadIdx.y;

    // Index of the first sub-matrix of A processed by the block
    int aBegin = A.width * BLOCK_SIZE * by;

    // Index of the last sub-matrix of A processed by the block
    int aEnd   = aBegin + A.width - 1;

    // Step size used to iterate through the sub-matrices of A
    int aStep  = BLOCK_SIZE;

    // Index of the first sub-matrix of B processed by the block
    int bBegin = BLOCK_SIZE * bx;

    // Step size used to iterate through the sub-matrices of B
    int bStep  = BLOCK_SIZE * B.width;

    // Csub is used to store the element of the block sub-matrix
    // that is computed by the thread
    float Cvalue = 0;
    
    // shared memory used to store Asub and Bsub
    __shared__ float As[BLOCK_SIZE][BLOCK_SIZE];
    __shared__ float Bs[BLOCK_SIZE][BLOCK_SIZE];
    
    // loop over all the sub matrices of A and B that are required to compute Csub,
    // multiply each pair of sub matrices together and sum the results
    int a, b, k;
    for (a = aBegin, b = bBegin; a <= aEnd; a += aStep, b += bStep)
    {
        // load Asub and Bsub from global memory to shared memory
        // Each thread loads one element of each sub-matrix
        As[ty][tx] = A.elements[a + A.width * ty + tx];
        Bs[ty][tx] = B.elements[b + B.width * ty + tx];
        
        // synchronize to make sure the sub-matrices are loaded before starting calculation
        __syncthreads();
        
        // multiply Asub and Bsub together
        for (k = 0; k < BLOCK_SIZE; ++k)
            Cvalue += As[ty][k] * Bs[k][tx];
        
        // synchronize to make sure that the preceding calculation is done before loading 
        // two new sub-matrices
        __syncthreads();
    }
    
    // write Cvalue to global memory, each thread write one element
    int c = C.width * BLOCK_SIZE * by + BLOCK_SIZE * bx;
    C.elements[c + C.width * ty + tx] = Cvalue;
}

int main() 
{ 
    // get the basic infomation of GPU device
    printf("\n");
    printf("[Matrix Multiply Using CUDA] - Starting...\n");
    int devID = 0;
    hipDeviceProp_t deviceProp;
    hipError_t error;
    
    error = hipGetDeviceProperties(&deviceProp, devID);
    if (error != hipSuccess)
    {
        printf("hipGetDeviceProperties returned error code %d, line(%d)\n", error, __LINE__);
    }
    else
    {
        printf("GPU Device %d: \"%s\" with compute capability %d.%d\n\n", devID, deviceProp.name, deviceProp.major,      deviceProp.minor);
    }
    
    // load A, B, C on host
    Matrix A;
    A.height = M;
    A.width = N;
    size_t size = A.height * A.width * sizeof(float);
    A.elements = (float *)malloc(size);
    
    Matrix B;
    B.height = N;
    B.width = P;
    size = B.height * B.width * sizeof(float);
    B.elements = (float *)malloc(size);
    
    // initialize A
    srand(rand());
    int i;
    for (i = 0; i < A.height * A.width; ++i)
    {
        A.elements[i] = rand() / (float)RAND_MAX;
        //A.elements[i] = 1.0;
    }
    // initialize B
    srand(rand());
    for (i = 0; i < B.height * B.width; ++i)
    {
        B.elements[i] = rand() / (float)RAND_MAX;
        //B.elements[i] = 0.01;
    }
    
    Matrix C;
    C.height = M;
    C.width = P;
    size = C.height * C.width * sizeof(float);
    C.elements = (float *)malloc(size); // default all zeros
    
    Matrix ref_C; // reference C for result check
    ref_C.height = M;
    ref_C.width = P;
    size = ref_C.height * ref_C.width * sizeof(float);
    ref_C.elements = (float *)malloc(size); // default all zeros
    
    // load a, b, c on device
    Matrix d_A;
    d_A.height = M;
    d_A.width = N;
    size = d_A.height * d_A.width * sizeof(float);
    hipMalloc(&d_A.elements, size); // alloc memory on device
    hipMemcpy(d_A.elements, A.elements, size, hipMemcpyHostToDevice); // copy data from host to device
    
    Matrix d_B;
    d_B.height = N;
    d_B.width = P;
    size = d_B.height * d_B.width * sizeof(float);
    hipMalloc(&d_B.elements, size);
    hipMemcpy(d_B.elements, B.elements, size, hipMemcpyHostToDevice);
    
    Matrix d_C;
    d_C.height = M;
    d_C.width = P;
    size = d_C.height * d_C.width * sizeof(float);
    hipMalloc(&d_C.elements, size); // default are not zeros, maybe random number
    
    // Kernel invocation with m*16*16 threads
    dim3 BlockDim(BLOCK_SIZE, BLOCK_SIZE);
    dim3 GridDim((P + BlockDim.x - 1) / BlockDim.x, (M + BlockDim.x - 1) / BlockDim.y);
    
    hipEvent_t start_cu, stop_cu;
    float time_gpu = 0.0f;
    hipEventCreate(&start_cu);
    hipEventCreate(&stop_cu);
    hipEventRecord( start_cu, 0);
    
    int nIter = 300;
    
    for (i = 0; i < nIter; ++i)
    {
        MatMul<<<GridDim, BlockDim>>>(d_A, d_B, d_C);
    }
    hipEventRecord( stop_cu, 0);
    hipEventSynchronize( stop_cu );
    hipEventElapsedTime( &time_gpu, start_cu, stop_cu );
    hipEventDestroy( start_cu );
    hipEventDestroy( stop_cu );
    
    float msecPerMatrixMul = time_gpu / nIter;
    double flopsPerMatrixMul = 2.0 * (double)A.width * (double)A.height * (double)B.width;
    double gigaFlops = (flopsPerMatrixMul * 1.0e-9f) / (msecPerMatrixMul / 1000.0f);
    printf("Performance= %.2f GFlop/s, Time= %.3f msec, Size= %.0f Ops, WorkgroupSize= %u threads/block\n",
            gigaFlops,
            msecPerMatrixMul,
            flopsPerMatrixMul,
            BlockDim.x * BlockDim.y);
    
    // copy results form device memory to host memory
    hipMemcpy( C.elements, d_C.elements, size, hipMemcpyDeviceToHost );
  
    MatMulOnHost(A, B, ref_C);
    printf("GridDim: (%d, %d)\n", GridDim.x, GridDim.y);

    // test relative error by the formula
    //     |<x, y>_cpu - <x,y>_gpu| / <|x|, |y|>  < eps
    printf("Checking computed result for correctness ... \n");
    bool correct = true;
    
    double eps = 1.e-6 ; // machine zero

    for (int i = 0; i < (int)(M * P); i++)
    {
        double abs_err = fabs(ref_C.elements[i] - C.elements[i]);
        double dot_length = A.width;
        double abs_val = fabs(ref_C.elements[i]);
        double rel_err = abs_err / abs_val / dot_length ;

        if (rel_err > eps)
        {
            //printf("Error! Matrix[%05d]=%.8f, ref=%.8f error term is > %E\n", i, ref_C.elements[i], C.elements[i], eps);
            correct = false;
        }
    }
    
    printf("%s\n", correct ? "Result = PASS" : "Result = FAIL");

    // free space on host and device
    free(C.elements); 
    free(B.elements); 
    free(A.elements);
    
    hipFree(d_A.elements);
    hipFree(d_B.elements);
    hipFree(d_C.elements);
    
    return 0;
}

	.text
	.file	"MatMul_share.hip"
	.globl	_Z12MatMulOnHost6MatrixS_S_     # -- Begin function _Z12MatMulOnHost6MatrixS_S_
	.type	_Z12MatMulOnHost6MatrixS_S_,@function
_Z12MatMulOnHost6MatrixS_S_:            # @_Z12MatMulOnHost6MatrixS_S_
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	56(%rsp), %eax
	testl	%eax, %eax
	jle	.LBB0_9
# %bb.1:                                # %.preheader17.lr.ph
	leaq	104(%rsp), %rsi
	leaq	80(%rsp), %rdi
	leaq	56(%rsp), %r8
	movl	4(%rdi), %ecx
	movl	4(%r8), %edx
	movq	16(%r8), %r8
	movq	%r8, -8(%rsp)                   # 8-byte Spill
	movq	16(%rdi), %rdi
	movq	16(%rsi), %r8
	movslq	4(%rsi), %r9
	movslq	%ecx, %r10
	shlq	$2, %r10
	xorl	%r11d, %r11d
	xorl	%ebx, %ebx
.LBB0_2:                                # %.preheader17
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB0_4 Depth 2
                                        #       Child Loop BB0_6 Depth 3
	testl	%ecx, %ecx
	jle	.LBB0_8
# %bb.3:                                # %.preheader.lr.ph
                                        #   in Loop: Header=BB0_2 Depth=1
	movl	%r11d, %esi
	movq	-8(%rsp), %r14                  # 8-byte Reload
	leaq	(%r14,%rsi,4), %r14
	movq	%rbx, %rsi
	imulq	%r9, %rsi
	leaq	(%r8,%rsi,4), %r15
	movq	%rdi, %r12
	xorl	%r13d, %r13d
.LBB0_4:                                # %.preheader
                                        #   Parent Loop BB0_2 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB0_6 Depth 3
	xorps	%xmm0, %xmm0
	testl	%edx, %edx
	jle	.LBB0_7
# %bb.5:                                # %.lr.ph.preheader
                                        #   in Loop: Header=BB0_4 Depth=2
	movq	%r12, %rbp
	xorl	%esi, %esi
.LBB0_6:                                # %.lr.ph
                                        #   Parent Loop BB0_2 Depth=1
                                        #     Parent Loop BB0_4 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	movss	(%r14,%rsi,4), %xmm1            # xmm1 = mem[0],zero,zero,zero
	mulss	(%rbp), %xmm1
	addss	%xmm1, %xmm0
	incq	%rsi
	addq	%r10, %rbp
	cmpq	%rsi, %rdx
	jne	.LBB0_6
.LBB0_7:                                # %._crit_edge
                                        #   in Loop: Header=BB0_4 Depth=2
	movss	%xmm0, (%r15,%r13,4)
	incq	%r13
	addq	$4, %r12
	cmpq	%rcx, %r13
	jne	.LBB0_4
.LBB0_8:                                # %._crit_edge21
                                        #   in Loop: Header=BB0_2 Depth=1
	incq	%rbx
	addl	%edx, %r11d
	cmpq	%rax, %rbx
	jne	.LBB0_2
.LBB0_9:                                # %._crit_edge23
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	_Z12MatMulOnHost6MatrixS_S_, .Lfunc_end0-_Z12MatMulOnHost6MatrixS_S_
	.cfi_endproc
                                        # -- End function
	.globl	_Z21__device_stub__MatMul6MatrixS_S_ # -- Begin function _Z21__device_stub__MatMul6MatrixS_S_
	.type	_Z21__device_stub__MatMul6MatrixS_S_,@function
_Z21__device_stub__MatMul6MatrixS_S_:   # @_Z21__device_stub__MatMul6MatrixS_S_
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$80, %rsp
	.cfi_def_cfa_offset 128
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	128(%rsp), %rax
	leaq	48(%rsp), %rbx
	movq	%rax, (%rbx)
	leaq	152(%rsp), %rax
	movq	%rax, 8(%rbx)
	leaq	176(%rsp), %rax
	movq	%rax, 16(%rbx)
	leaq	32(%rsp), %r14
	leaq	16(%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	$_Z6MatMul6MatrixS_S_, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$96, %rsp
	.cfi_adjust_cfa_offset -96
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end1:
	.size	_Z21__device_stub__MatMul6MatrixS_S_, .Lfunc_end1-_Z21__device_stub__MatMul6MatrixS_S_
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function main
.LCPI2_0:
	.long	0x30000000                      # float 4.65661287E-10
.LCPI2_1:
	.long	0x43960000                      # float 300
.LCPI2_2:
	.long	0x447a0000                      # float 1000
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0
.LCPI2_3:
	.quad	0x3f501b2b22000000              # double 9.8303997219773009E-4
.LCPI2_4:
	.quad	0x412e000000000000              # double 983040
.LCPI2_6:
	.quad	0x4048000000000000              # double 48
.LCPI2_7:
	.quad	0x3eb0c6f7a0b5ed8d              # double 9.9999999999999995E-7
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0
.LCPI2_5:
	.long	0x7fffffff                      # float NaN
	.long	0x7fffffff                      # float NaN
	.long	0x7fffffff                      # float NaN
	.long	0x7fffffff                      # float NaN
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$1752, %rsp                     # imm = 0x6D8
	.cfi_def_cfa_offset 1808
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	$10, %edi
	callq	putchar@PLT
	movl	$.Lstr, %edi
	callq	puts@PLT
	leaq	280(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipGetDevicePropertiesR0600
	testl	%eax, %eax
	je	.LBB2_2
# %bb.1:
	movl	$.L.str.2, %edi
	movl	%eax, %esi
	movl	$114, %edx
	xorl	%eax, %eax
	callq	printf
	jmp	.LBB2_3
.LBB2_2:
	leaq	280(%rsp), %rdx
	movl	360(%rdx), %ecx
	movl	364(%rdx), %r8d
	movl	$.L.str.3, %edi
	xorl	%esi, %esi
	xorl	%eax, %eax
	callq	printf
.LBB2_3:
	movl	$15360, %edi                    # imm = 0x3C00
	callq	malloc
	movq	%rax, %r15
	movl	$24576, %edi                    # imm = 0x6000
	callq	malloc
	movq	%rax, %r14
	callq	rand
	movl	%eax, %edi
	callq	srand
	xorl	%ebx, %ebx
.LBB2_4:                                # =>This Inner Loop Header: Depth=1
	callq	rand
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	mulss	.LCPI2_0(%rip), %xmm0
	movss	%xmm0, (%r15,%rbx,4)
	incq	%rbx
	cmpq	$3840, %rbx                     # imm = 0xF00
	jne	.LBB2_4
# %bb.5:
	movq	%r15, 24(%rsp)                  # 8-byte Spill
	callq	rand
	movl	%eax, %edi
	callq	srand
	xorl	%ebx, %ebx
.LBB2_6:                                # =>This Inner Loop Header: Depth=1
	callq	rand
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	mulss	.LCPI2_0(%rip), %xmm0
	movss	%xmm0, (%r14,%rbx,4)
	incq	%rbx
	cmpq	$6144, %rbx                     # imm = 0x1800
	jne	.LBB2_6
# %bb.7:
	movl	$40960, %edi                    # imm = 0xA000
	callq	malloc
	movq	%rax, %r15
	movl	$40960, %edi                    # imm = 0xA000
	callq	malloc
	movq	%rax, %r12
	movabsq	$206158430288, %rax             # imm = 0x3000000050
	leaq	184(%rsp), %r13
	movq	%rax, -16(%r13)
	movl	$15360, %esi                    # imm = 0x3C00
	movq	%r13, %rdi
	callq	hipMalloc
	movq	(%r13), %rdi
	movl	$15360, %edx                    # imm = 0x3C00
	movq	24(%rsp), %rsi                  # 8-byte Reload
	movl	$1, %ecx
	callq	hipMemcpy
	movabsq	$549755813936, %rax             # imm = 0x8000000030
	leaq	160(%rsp), %r13
	movq	%rax, -16(%r13)
	movl	$24576, %esi                    # imm = 0x6000
	movq	%r13, %rdi
	callq	hipMalloc
	movq	(%r13), %rdi
	movl	$24576, %edx                    # imm = 0x6000
	movq	%r14, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	movabsq	$549755813968, %rax             # imm = 0x8000000050
	leaq	104(%rsp), %rdi
	movq	%rax, -16(%rdi)
	movl	$40960, %esi                    # imm = 0xA000
	callq	hipMalloc
	movl	$0, 20(%rsp)
	leaq	32(%rsp), %r13
	movq	%r13, %rdi
	callq	hipEventCreate
	leaq	8(%rsp), %rdi
	callq	hipEventCreate
	movq	(%r13), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movl	$300, %ebx                      # imm = 0x12C
	movabsq	$21474836488, %r13              # imm = 0x500000008
	movabsq	$68719476752, %rbp              # imm = 0x1000000010
.LBB2_8:                                # =>This Inner Loop Header: Depth=1
	movq	%r13, %rdi
	movl	$1, %esi
	movq	%rbp, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB2_10
# %bb.9:                                #   in Loop: Header=BB2_8 Depth=1
	movq	184(%rsp), %rax
	movq	%rax, 208(%rsp)
	movups	168(%rsp), %xmm0
	movaps	%xmm0, 192(%rsp)
	movq	160(%rsp), %rax
	movq	%rax, 240(%rsp)
	movups	144(%rsp), %xmm0
	movaps	%xmm0, 224(%rsp)
	movq	104(%rsp), %rax
	movq	%rax, 272(%rsp)
	movups	88(%rsp), %xmm0
	movaps	%xmm0, 256(%rsp)
	leaq	192(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	224(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	256(%rsp), %rax
	movq	%rax, 128(%rsp)
	leaq	72(%rsp), %rdi
	leaq	56(%rsp), %rsi
	leaq	48(%rsp), %rdx
	leaq	40(%rsp), %rcx
	callq	__hipPopCallConfiguration
	movq	72(%rsp), %rsi
	movl	80(%rsp), %edx
	movq	56(%rsp), %rcx
	movl	64(%rsp), %r8d
	movl	$_Z6MatMul6MatrixS_S_, %edi
	leaq	112(%rsp), %r9
	pushq	40(%rsp)
	.cfi_adjust_cfa_offset 8
	pushq	56(%rsp)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$16, %rsp
	.cfi_adjust_cfa_offset -16
.LBB2_10:                               #   in Loop: Header=BB2_8 Depth=1
	decl	%ebx
	jne	.LBB2_8
# %bb.11:                               # %.preheader17.lr.ph.i
	movq	8(%rsp), %rdi
	xorl	%ebp, %ebp
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	8(%rsp), %rdi
	callq	hipEventSynchronize
	movq	32(%rsp), %rsi
	movq	8(%rsp), %rdx
	leaq	20(%rsp), %r13
	movq	%r13, %rdi
	callq	hipEventElapsedTime
	movq	32(%rsp), %rdi
	callq	hipEventDestroy
	movq	8(%rsp), %rdi
	callq	hipEventDestroy
	movss	(%r13), %xmm0                   # xmm0 = mem[0],zero,zero,zero
	divss	.LCPI2_1(%rip), %xmm0
	movaps	%xmm0, %xmm2
	divss	.LCPI2_2(%rip), %xmm2
	cvtss2sd	%xmm0, %xmm1
	cvtss2sd	%xmm2, %xmm2
	movsd	.LCPI2_3(%rip), %xmm0           # xmm0 = mem[0],zero
	divsd	%xmm2, %xmm0
	movsd	.LCPI2_4(%rip), %xmm2           # xmm2 = mem[0],zero
	movl	$.L.str.4, %edi
	movl	$256, %esi                      # imm = 0x100
	movb	$3, %al
	callq	printf
	movq	104(%rsp), %rsi
	movl	$40960, %edx                    # imm = 0xA000
	movq	%r15, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	movq	24(%rsp), %r13                  # 8-byte Reload
	movq	%r13, %rax
.LBB2_12:                               # %.preheader.lr.ph.i
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB2_13 Depth 2
                                        #       Child Loop BB2_14 Depth 3
	movq	%rbp, %rcx
	shlq	$9, %rcx
	addq	%r12, %rcx
	movq	%r14, %rdx
	xorl	%esi, %esi
.LBB2_13:                               # %.lr.ph.preheader.i
                                        #   Parent Loop BB2_12 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB2_14 Depth 3
	xorpd	%xmm0, %xmm0
	movq	%rdx, %rdi
	xorl	%r8d, %r8d
.LBB2_14:                               # %.lr.ph.i
                                        #   Parent Loop BB2_12 Depth=1
                                        #     Parent Loop BB2_13 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	movss	(%rax,%r8,4), %xmm1             # xmm1 = mem[0],zero,zero,zero
	mulss	(%rdi), %xmm1
	addss	%xmm1, %xmm0
	incq	%r8
	addq	$512, %rdi                      # imm = 0x200
	cmpq	$48, %r8
	jne	.LBB2_14
# %bb.15:                               # %._crit_edge.i
                                        #   in Loop: Header=BB2_13 Depth=2
	movss	%xmm0, (%rcx,%rsi,4)
	incq	%rsi
	addq	$4, %rdx
	cmpq	$128, %rsi
	jne	.LBB2_13
# %bb.16:                               # %._crit_edge21.i
                                        #   in Loop: Header=BB2_12 Depth=1
	incq	%rbp
	addq	$192, %rax
	cmpq	$80, %rbp
	jne	.LBB2_12
# %bb.17:                               # %_Z12MatMulOnHost6MatrixS_S_.exit
	xorl	%ebx, %ebx
	movl	$.L.str.5, %edi
	movl	$8, %esi
	movl	$5, %edx
	xorl	%eax, %eax
	callq	printf
	movl	$.Lstr.1, %edi
	callq	puts@PLT
	movb	$1, %al
	movaps	.LCPI2_5(%rip), %xmm0           # xmm0 = [NaN,NaN,NaN,NaN]
	movsd	.LCPI2_6(%rip), %xmm1           # xmm1 = mem[0],zero
	movsd	.LCPI2_7(%rip), %xmm2           # xmm2 = mem[0],zero
	xorl	%ecx, %ecx
.LBB2_18:                               # =>This Inner Loop Header: Depth=1
	movss	(%r12,%rcx,4), %xmm3            # xmm3 = mem[0],zero,zero,zero
	movaps	%xmm3, %xmm4
	subss	(%r15,%rcx,4), %xmm4
	andps	%xmm0, %xmm4
	cvtss2sd	%xmm4, %xmm4
	andps	%xmm0, %xmm3
	cvtss2sd	%xmm3, %xmm3
	divsd	%xmm3, %xmm4
	divsd	%xmm1, %xmm4
	ucomisd	%xmm2, %xmm4
	movzbl	%al, %eax
	cmoval	%ebx, %eax
	incq	%rcx
	cmpq	$10240, %rcx                    # imm = 0x2800
	jne	.LBB2_18
# %bb.19:
	testb	$1, %al
	movl	$.L.str.9, %eax
	movl	$.L.str.8, %edi
	cmoveq	%rax, %rdi
	callq	puts@PLT
	movq	%r15, %rdi
	callq	free
	movq	%r14, %rdi
	callq	free
	movq	%r13, %rdi
	callq	free
	movq	184(%rsp), %rdi
	callq	hipFree
	movq	160(%rsp), %rdi
	callq	hipFree
	movq	104(%rsp), %rdi
	callq	hipFree
	xorl	%eax, %eax
	addq	$1752, %rsp                     # imm = 0x6D8
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end2:
	.size	main, .Lfunc_end2-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:
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	jne	.LBB3_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB3_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z6MatMul6MatrixS_S_, %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_end3:
	.size	__hip_module_ctor, .Lfunc_end3-__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	.LBB4_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
.LBB4_2:
	retq
.Lfunc_end4:
	.size	__hip_module_dtor, .Lfunc_end4-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	_Z6MatMul6MatrixS_S_,@object    # @_Z6MatMul6MatrixS_S_
	.section	.rodata,"a",@progbits
	.globl	_Z6MatMul6MatrixS_S_
	.p2align	3, 0x0
_Z6MatMul6MatrixS_S_:
	.quad	_Z21__device_stub__MatMul6MatrixS_S_
	.size	_Z6MatMul6MatrixS_S_, 8

	.type	.L.str.2,@object                # @.str.2
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.2:
	.asciz	"hipGetDeviceProperties returned error code %d, line(%d)\n"
	.size	.L.str.2, 57

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"GPU Device %d: \"%s\" with compute capability %d.%d\n\n"
	.size	.L.str.3, 52

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"Performance= %.2f GFlop/s, Time= %.3f msec, Size= %.0f Ops, WorkgroupSize= %u threads/block\n"
	.size	.L.str.4, 93

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"GridDim: (%d, %d)\n"
	.size	.L.str.5, 19

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"Result = PASS"
	.size	.L.str.8, 14

	.type	.L.str.9,@object                # @.str.9
.L.str.9:
	.asciz	"Result = FAIL"
	.size	.L.str.9, 14

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z6MatMul6MatrixS_S_"
	.size	.L__unnamed_1, 21

	.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	"[Matrix Multiply Using CUDA] - Starting..."
	.size	.Lstr, 43

	.type	.Lstr.1,@object                 # @str.1
.Lstr.1:
	.asciz	"Checking computed result for correctness ... "
	.size	.Lstr.1, 46

	.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 _Z21__device_stub__MatMul6MatrixS_S_
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z6MatMul6MatrixS_S_
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z6MatMul6MatrixS_S_    ; -- Begin function _Z6MatMul6MatrixS_S_
	.globl	_Z6MatMul6MatrixS_S_
	.p2align	8
	.type	_Z6MatMul6MatrixS_S_,@function
_Z6MatMul6MatrixS_S_:                   ; @_Z6MatMul6MatrixS_S_
; %bb.0:
	s_clause 0x1
	s_load_b32 s10, s[0:1], 0x4
	s_load_b64 s[2:3], s[0:1], 0x40
	v_and_b32_e32 v1, 0x3ff, v0
	v_bfe_u32 v0, v0, 10, 10
	s_lshl_b32 s8, s14, 4
	s_waitcnt lgkmcnt(0)
	s_cmp_lt_i32 s10, 1
	s_cbranch_scc1 .LBB0_5
; %bb.1:                                ; %.lr.ph
	s_clause 0x2
	s_load_b32 s11, s[0:1], 0x1c
	s_load_b64 s[4:5], s[0:1], 0x10
	s_load_b64 s[6:7], s[0:1], 0x28
	v_mad_u64_u32 v[2:3], null, s10, v0, v[1:2]
	v_lshlrev_b32_e32 v7, 2, v1
	v_lshlrev_b32_e32 v5, 6, v0
	s_mul_i32 s9, s10, s15
	s_mov_b32 s12, s8
	s_lshl_b32 s9, s9, 4
	s_delay_alu instid0(SALU_CYCLE_1)
	s_add_i32 s10, s9, s10
	s_waitcnt lgkmcnt(0)
	v_mad_u64_u32 v[3:4], null, s11, v0, v[1:2]
	v_mov_b32_e32 v4, 0
	v_add_nc_u32_e32 v6, 0x400, v7
	v_add_nc_u32_e32 v7, v5, v7
	s_lshl_b32 s11, s11, 4
	s_delay_alu instid0(VALU_DEP_2)
	v_add_nc_u32_e32 v8, v6, v5
.LBB0_2:                                ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB0_3 Depth 2
	v_add_nc_u32_e32 v9, s9, v2
	v_add_nc_u32_e32 v11, s12, v3
	s_mov_b32 s13, 0
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_ashrrev_i32_e32 v10, 31, v9
	v_ashrrev_i32_e32 v12, 31, v11
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_lshlrev_b64 v[9:10], 2, v[9:10]
	v_lshlrev_b64 v[11:12], 2, v[11:12]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_co_u32 v9, vcc_lo, s4, v9
	v_add_co_ci_u32_e32 v10, vcc_lo, s5, v10, vcc_lo
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_4)
	v_add_co_u32 v11, vcc_lo, s6, v11
	v_add_co_ci_u32_e32 v12, vcc_lo, s7, v12, vcc_lo
	global_load_b32 v10, v[9:10], off
	global_load_b32 v11, v[11:12], off
	v_mov_b32_e32 v9, v6
	s_waitcnt vmcnt(1)
	ds_store_b32 v7, v10
	s_waitcnt vmcnt(0)
	ds_store_b32 v8, v11
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
.LBB0_3:                                ;   Parent Loop BB0_2 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	v_add_nc_u32_e32 v10, s13, v5
	s_add_i32 s13, s13, 4
	ds_load_b32 v11, v9
	ds_load_b32 v10, v10
	v_add_nc_u32_e32 v9, 64, v9
	s_cmp_lg_u32 s13, 64
	s_waitcnt lgkmcnt(0)
	v_fmac_f32_e32 v4, v10, v11
	s_cbranch_scc1 .LBB0_3
; %bb.4:                                ;   in Loop: Header=BB0_2 Depth=1
	s_add_i32 s9, s9, 16
	s_add_i32 s12, s12, s11
	s_cmp_lt_i32 s9, s10
	s_barrier
	buffer_gl0_inv
	s_cbranch_scc1 .LBB0_2
	s_branch .LBB0_6
.LBB0_5:
	v_mov_b32_e32 v4, 0
.LBB0_6:                                ; %Flow61
	s_load_b32 s0, s[0:1], 0x34
	v_lshl_add_u32 v0, s15, 4, v0
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_lo_u32 v0, v0, s0
	v_add3_u32 v0, s8, v1, v0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v1, 31, v0
	v_lshlrev_b64 v[0:1], 2, v[0:1]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v0, vcc_lo, s2, v0
	v_add_co_ci_u32_e32 v1, vcc_lo, s3, v1, vcc_lo
	global_store_b32 v[0:1], v4, off
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z6MatMul6MatrixS_S_
		.amdhsa_group_segment_fixed_size 2048
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 72
		.amdhsa_user_sgpr_count 14
		.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 1
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 1
		.amdhsa_next_free_vgpr 13
		.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	_Z6MatMul6MatrixS_S_, .Lfunc_end0-_Z6MatMul6MatrixS_S_
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 464
; NumSgprs: 18
; NumVgprs: 13
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 2048 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 13
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 14
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 1
	.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:           24
        .value_kind:     by_value
      - .offset:         24
        .size:           24
        .value_kind:     by_value
      - .offset:         48
        .size:           24
        .value_kind:     by_value
    .group_segment_fixed_size: 2048
    .kernarg_segment_align: 8
    .kernarg_segment_size: 72
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z6MatMul6MatrixS_S_
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z6MatMul6MatrixS_S_.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     13
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
