/*
 * main.cu
 *
 *  Created on: Nov 14, 2019
 *	Author: cuda-s01
 */
#include <stdio.h>
#include <time.h>

const int TILE_WIDTH = 2;
const int MATRIX_SIZE = 800;

__global__ void matrixMultiplicationKernel(float* M, float* N, float* P, int Width) {
        // Calculate the row index of the P element and M
        int Row = blockIdx.y*blockDim.y+threadIdx.y;
        // Calculate the column index of P and N
        int Col = blockIdx.x*blockDim.x+threadIdx.x;

        __shared__ float sum_M[TILE_WIDTH][TILE_WIDTH];
        __shared__ float sum_N[TILE_WIDTH][TILE_WIDTH];

        sum_M[threadIdx.y][threadIdx.x]=0.0;
        sum_N[threadIdx.y][threadIdx.x]=0.0;

        float Pval = 0;
        for(int k=0; k<((Width - 1)/TILE_WIDTH + 1); k++)
        {
                //printf("Col:%d, Row:%d, k:%d, th:(%d,%d), ");
                if(k*TILE_WIDTH + threadIdx.x < Width && Row < Width)
                        sum_M[threadIdx.y][threadIdx.x] = M[Row*Width + k*TILE_WIDTH + threadIdx.x];
                else sum_M[threadIdx.y][threadIdx.x] = 0.0;

                if(k*TILE_WIDTH + threadIdx.y < Width && Col < Width)
                        sum_N[threadIdx.y][threadIdx.x] = N[(k*TILE_WIDTH + threadIdx.y)*Width + Col];
                else sum_N[threadIdx.y][threadIdx.x] = 0.0;

                __syncthreads();

                for(int n=0; n<TILE_WIDTH;++n)
                        Pval += sum_M[threadIdx.y][n] * sum_N[n][threadIdx.x];

                __syncthreads();

        }
	if(Row < Width && Col < Width)
        {
                P[Row * Width + Col]  = Pval;
                //printf("(%d,%d)=%f\n",Row,Col,P[Row*Width+Col]);
        }
}

void multiply(float* M, float* N, float* P, int size) {
    float X[size][size], Y[size][size], Z[size][size];
    int i, j;

    // Rewriting matrices
    for (i=0;i<size;i++) {
        for (j=0;j<size;j++) {
            X[i][j]=M[size*i+j];
            Y[i][j]=N[size*i+j];
            Z[i][j]=0;
        }
    }

    // Multiplying first and second matrices and storing in Z.
    for (i = 0; i < size; ++i) {
        for (j = 0; j < size; ++j) {
            for (int k = 0; k < size; ++k) {
                Z[i][j] += X[i][k] * Y[k][j];
            }
	   }
    }
    
    for (i=0;i<size;i++) {
        for (j=0;j<size;j++) {
            P[size*i+j]=Z[i][j];
        }
    }


}

void matrixMultiplication(float *M, float *N, float *P, int Width){

    // declare the number of blocks per grid and the number of threads per block
    int th = TILE_WIDTH;
    int bl = (Width/TILE_WIDTH) + 1;
    dim3 threadsPerBlock(th,th,1);
    dim3 blocksPerGrid(bl,bl,1);
    printf("Kernel started: (%d,%d,1) grid, (%d,%d,1) blocks.\n", bl,bl, th,th);
    matrixMultiplicationKernel<<<blocksPerGrid,threadsPerBlock>>>(M, N, P, Width);
}

void PrintMatrix(float* M, int Width)
{
        for(int i = 0; i < Width; i++)
        {
                for(int j = 0; j < Width; j++)
                        printf("%f  ",M[i*Width+j]);
                printf("\n");
        }
	printf("\n");
}

int main(void)
{
        printf("Starting the program:\n");
        cudaError_t err = cudaSuccess;

        int matrix_size = MATRIX_SIZE;
        int num_of_elements = matrix_size * matrix_size;
        size_t size = num_of_elements * sizeof(float);
        FILE *fp;
        fp=fopen("log.txt", "a");
        fprintf(fp, "Multiplicating matrix %d x %d.\n", matrix_size, matrix_size);

    //==========================Shared Memory============================================

        //allocate matrixes on the device:
        printf("Allocating matrices on the device...\n");
        // printf("First matrix.\n");
        float *M;
        err = cudaMallocManaged((void**)&M,  size);
        if(err != cudaSuccess)
        {
                fprintf(stderr, "Failed to allocate M matrix!\n");
                exit(EXIT_FAILURE);
        } else printf("M Allocation successful.\n");

        // printf("Second matrix.\n");
        float *N;
        err = cudaMallocManaged((void**)&N,  size);
        if(err != cudaSuccess)
        {
                fprintf(stderr, "Failed to allocate N matrix!\n");
                exit(EXIT_FAILURE);
        } else printf("N Allocation successful.\n");

        // printf("Third matrix.\n");
        float *P;
        err = cudaMallocManaged((void**)&P,  size);
        if(err != cudaSuccess)
        {
                fprintf(stderr, "Failed to allocate P matrix!\n");
                exit(EXIT_FAILURE);
        } else printf("P Allocation successful.\n");

        float *R;
        err = cudaMallocManaged((void**)&R,  size);
        if(err != cudaSuccess)
        {
                fprintf(stderr, "Failed to allocate R matrix!\n");
                exit(EXIT_FAILURE);
        } else printf("R Allocation successful.\n");

        //initialisation:
        for(int i=0; i<num_of_elements; i++)
        {
          M[i] = rand()/(float)RAND_MAX;
          N[i] = rand()/(float)RAND_MAX;
        }

    printf("Initialisation finished.\n");

    //calculations:
    clock_t start=clock();
    matrixMultiplication(M, N, P, matrix_size);
    clock_t end=clock();
    double time_elapsed=((double) (end - start)) / CLOCKS_PER_SEC;
    err = cudaGetLastError();

    if(err != cudaSuccess)
    {
                fprintf(stderr, "Failed to launch kernel. Error: %s.\n", cudaGetErrorString(err));
                exit(EXIT_FAILURE);
        } else fprintf(fp, "Kernel operations successful. Time elapsed: %lf s.\n", time_elapsed);


    //==========================TEST===============================================
    PrintMatrix(M, matrix_size);
    PrintMatrix(N, matrix_size);
    PrintMatrix(P, matrix_size);

        for(int i = 0; i < matrix_size; i++)
        {
                for(int j = 0; j < matrix_size; j++)
                {
                        float tmp = 0;
                        for(int k = 0; k < matrix_size; k++)
                                tmp += M[i*matrix_size + k] * N[k*matrix_size + j];
                        //debug line:
                        //printf("%f ",tmp);
                        if(fabs(tmp - P[i*matrix_size + j]) > 1e-3)
                        {
                                fprintf(stderr, "Verification test failed!\nElement at index (%d, %d) should be %f, but is %f. \n",
                                        i,j,tmp,P[i*matrix_size + j]);
                                exit(EXIT_FAILURE);
                        }
                }
        }

	fprintf(fp, "Verification test PASSED, multi-threaded calculations are correct.\n");

    //======================== Single-threaded calculations =====================

    start=clock();
    multiply(M, N, R, MATRIX_SIZE);
    end=clock();
    time_elapsed=end-start;

    //============================ SINGLE-THREADED TEST ==========================
    int isCorrect=1;
    for(int i=0;i<matrix_size;i++) {
        for (int j=0;j<matrix_size;j++) {
                 if(fabs(P[i*matrix_size + j]-R[i*matrix_size+j]) > 1e-3) {
                        isCorrect=0; }
        }
    }
     	printf("%d", isCorrect);
    if (isCorrect==1) {
        fprintf(fp, "Comparision test PASSED, single-threaded calculations are correct.\n");
    } else {
	    fprintf(fp, "Comparision test failed, matrices are not identical");
    }


    fprintf(fp, "Time elapsed for single-threaded calculations: %lf s.\n\n", time_elapsed/CLOCKS_PER_SEC);
    fclose(fp);
    PrintMatrix(R, matrix_size);

    printf("Freeing memory...\n");

    // Free device global memory
    err = cudaFree(M);

    if (err != cudaSuccess)
    {
     	fprintf(stderr, "Failed to free device matrix M (error code %s)!\n", cudaGetErrorString(err));
        exit(EXIT_FAILURE);
    }

    err = cudaFree(N);

    if (err != cudaSuccess)
    {
     	fprintf(stderr, "Failed to free device matrix N (error code %s)!\n", cudaGetErrorString(err));
        exit(EXIT_FAILURE);
    }

    err = cudaFree(P);

    if (err != cudaSuccess)
    {
     	fprintf(stderr, "Failed to free device matrix P (error code %s)!\n", cudaGetErrorString(err));
        exit(EXIT_FAILURE);
    }

    printf("Memory freed successfully.\n");
    return 0;

}


	.file	"tmpxft_002e9a01_00000000-6_main.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
	.globl	_Z8multiplyPfS_S_i
	.type	_Z8multiplyPfS_S_i, @function
_Z8multiplyPfS_S_i:
.LFB2027:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsi, %r11
	movl	%ecx, %r8d
	movq	%rdi, %r10
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$72, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%rdx, -104(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	movslq	%ecx, %rax
	movq	%rsp, %rcx
	leaq	0(,%rax,4), %r9
	imulq	%rax, %rax
	leaq	15(,%rax,4), %rax
	movq	%rax, %rsi
	movq	%rax, %rdx
	andq	$-4096, %rsi
	andq	$-16, %rdx
	subq	%rsi, %rcx
.L3:
	cmpq	%rcx, %rsp
	je	.L4
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L3
.L4:
	andl	$4095, %edx
	subq	%rdx, %rsp
	testq	%rdx, %rdx
	je	.L5
	orq	$0, -8(%rsp,%rdx)
.L5:
	movq	%rax, %rsi
	movq	%rsp, -80(%rbp)
	movq	%rax, %rdx
	movq	%rsp, %rcx
	andq	$-4096, %rsi
	andq	$-16, %rdx
	subq	%rsi, %rcx
.L6:
	cmpq	%rcx, %rsp
	je	.L7
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L6
.L7:
	andl	$4095, %edx
	subq	%rdx, %rsp
	testq	%rdx, %rdx
	je	.L8
	orq	$0, -8(%rsp,%rdx)
.L8:
	movq	%rsp, -88(%rbp)
	movq	%rax, %rdx
	movq	%rsp, %rcx
	andq	$-4096, %rax
	andq	$-16, %rdx
	subq	%rax, %rcx
.L9:
	cmpq	%rcx, %rsp
	je	.L10
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L9
.L10:
	movq	%rdx, %rax
	andl	$4095, %eax
	subq	%rax, %rsp
	testq	%rax, %rax
	je	.L11
	orq	$0, -8(%rsp,%rax)
.L11:
	movq	%r9, %rax
	movq	%rsp, %rdx
	movq	-88(%rbp), %r12
	movq	-80(%rbp), %rbx
	shrq	$2, %rax
	movq	%rdx, %r15
	movq	%rdx, %r13
	xorl	%r14d, %r14d
	movq	%rax, -96(%rbp)
	leal	-1(%r8), %eax
	leaq	4(,%rax,4), %rax
	movq	%rax, -72(%rbp)
	xorl	%eax, %eax
.L12:
	cmpl	%r8d, %r14d
	jge	.L34
	movq	%rbx, %rdi
	movq	%r10, %rsi
	movq	-72(%rbp), %rcx
	incl	%r14d
	rep movsb
	movq	%r12, %rdi
	movq	%r11, %rsi
	movq	-72(%rbp), %rcx
	addq	%r9, %rbx
	addq	%r9, %r10
	addq	%r9, %r12
	addq	%r9, %r11
	rep movsb
	movq	-72(%rbp), %rcx
	movq	%r13, %rdi
	addq	%r9, %r13
	rep stosb
	jmp	.L12
.L34:
	xorl	%esi, %esi
	xorl	%r11d, %r11d
.L14:
	cmpl	%r8d, %r11d
	jge	.L17
	movq	-80(%rbp), %rax
	leaq	(%rdx,%rsi), %r10
	xorl	%edi, %edi
	leaq	(%rax,%rsi), %rbx
.L18:
	movss	(%r10), %xmm0
	xorl	%eax, %eax
	movslq	%edi, %r12
.L15:
	movq	-96(%rbp), %r14
	movslq	%eax, %rcx
	movss	(%rbx,%rax,4), %xmm1
	incq	%rax
	imulq	%r14, %rcx
	movq	-88(%rbp), %r14
	addq	%r12, %rcx
	mulss	(%r14,%rcx,4), %xmm1
	addss	%xmm1, %xmm0
	cmpl	%eax, %r8d
	jg	.L15
	incl	%edi
	movss	%xmm0, (%r10)
	addq	$4, %r10
	cmpl	%edi, %r8d
	jne	.L18
	incl	%r11d
	addq	%r9, %rsi
	jmp	.L14
.L17:
	movq	-104(%rbp), %rax
	xorl	%r10d, %r10d
.L19:
	cmpl	%r8d, %r10d
	jge	.L35
	movq	%rax, %rdi
	movq	%r15, %rsi
	movq	-72(%rbp), %rcx
	incl	%r10d
	rep movsb
	addq	%r9, %rax
	addq	%r9, %r15
	jmp	.L19
.L35:
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	je	.L21
	call	__stack_chk_fail@PLT
.L21:
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2027:
	.size	_Z8multiplyPfS_S_i, .-_Z8multiplyPfS_S_i
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%f  "
.LC1:
	.string	"\n"
	.text
	.globl	_Z11PrintMatrixPfi
	.type	_Z11PrintMatrixPfi, @function
_Z11PrintMatrixPfi:
.LFB2029:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	leaq	.LC0(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movslq	%esi, %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	xorl	%r12d, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%r13, %rbp
	salq	$2, %r13
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	%rdi, %rbx
	pushq	%rcx
	.cfi_def_cfa_offset 64
.L37:
	cmpl	%ebp, %r12d
	jge	.L42
	leaq	(%rbx,%r13), %r15
.L38:
	cvtss2sd	(%rbx), %xmm0
	movq	%r14, %rsi
	movl	$2, %edi
	movb	$1, %al
	call	__printf_chk@PLT
	addq	$4, %rbx
	cmpq	%r15, %rbx
	jne	.L38
	leaq	.LC1(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	incl	%r12d
	call	__printf_chk@PLT
	jmp	.L37
.L42:
	popq	%rdx
	.cfi_def_cfa_offset 56
	leaq	.LC1(%rip), %rsi
	popq	%rbx
	.cfi_def_cfa_offset 48
	movl	$2, %edi
	popq	%rbp
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	jmp	__printf_chk@PLT
	.cfi_endproc
.LFE2029:
	.size	_Z11PrintMatrixPfi, .-_Z11PrintMatrixPfi
	.globl	_Z51__device_stub__Z26matrixMultiplicationKernelPfS_S_iPfS_S_i
	.type	_Z51__device_stub__Z26matrixMultiplicationKernelPfS_S_iPfS_S_i, @function
_Z51__device_stub__Z26matrixMultiplicationKernelPfS_S_iPfS_S_i:
.LFB2055:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movq	%rdi, 24(%rsp)
	leaq	56(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	68(%rsp), %rsi
	movq	%rdx, 8(%rsp)
	leaq	40(%rsp), %rdx
	movl	%ecx, 4(%rsp)
	leaq	48(%rsp), %rcx
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 64(%rsp)
	movq	%rax, 104(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	4(%rsp), %rax
	movq	%rax, 128(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 56(%rsp)
	movq	%rax, 68(%rsp)
	movl	$1, 76(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L43
	pushq	48(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z26matrixMultiplicationKernelPfS_S_i(%rip), %rdi
	pushq	48(%rsp)
	.cfi_def_cfa_offset 176
	movq	84(%rsp), %rcx
	movl	92(%rsp), %r8d
	movq	72(%rsp), %rsi
	movl	80(%rsp), %edx
	leaq	120(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 168
	popq	%rdx
	.cfi_def_cfa_offset 160
.L43:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L45
	call	__stack_chk_fail@PLT
.L45:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2055:
	.size	_Z51__device_stub__Z26matrixMultiplicationKernelPfS_S_iPfS_S_i, .-_Z51__device_stub__Z26matrixMultiplicationKernelPfS_S_iPfS_S_i
	.globl	_Z26matrixMultiplicationKernelPfS_S_i
	.type	_Z26matrixMultiplicationKernelPfS_S_i, @function
_Z26matrixMultiplicationKernelPfS_S_i:
.LFB2056:
	.cfi_startproc
	endbr64
	jmp	_Z51__device_stub__Z26matrixMultiplicationKernelPfS_S_iPfS_S_i
	.cfi_endproc
.LFE2056:
	.size	_Z26matrixMultiplicationKernelPfS_S_i, .-_Z26matrixMultiplicationKernelPfS_S_i
	.section	.rodata.str1.1
.LC2:
	.string	"Kernel started: (%d,%d,1) grid, (%d,%d,1) blocks.\n"
	.text
	.globl	_Z20matrixMultiplicationPfS_S_i
	.type	_Z20matrixMultiplicationPfS_S_i, @function
_Z20matrixMultiplicationPfS_S_i:
.LFB2028:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	movq	%rdx, %r13
	movl	$2, %r9d
	movl	$2, %r8d
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	movq	%rsi, %r12
	leaq	.LC2(%rip), %rsi
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	movq	%rdi, %rbp
	movl	$2, %edi
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	movl	%ecx, %ebx
	movl	$2, %ecx
	movl	%ebx, %eax
	cltd
	idivl	%ecx
	subq	$40, %rsp
	.cfi_def_cfa_offset 80
	movl	$1, 16(%rsp)
	movl	$1, 28(%rsp)
	leal	1(%rax), %edx
	movabsq	$8589934594, %rax
	movl	%edx, %ecx
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	movl	%edx, 20(%rsp)
	movl	%edx, 24(%rsp)
	call	__printf_chk@PLT
	movl	16(%rsp), %ecx
	movl	28(%rsp), %esi
	xorl	%r9d, %r9d
	movq	8(%rsp), %rdx
	movq	20(%rsp), %rdi
	xorl	%r8d, %r8d
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L48
	addq	$40, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	movl	%ebx, %ecx
	movq	%r13, %rdx
	movq	%r12, %rsi
	popq	%rbx
	.cfi_def_cfa_offset 32
	movq	%rbp, %rdi
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	jmp	_Z51__device_stub__Z26matrixMultiplicationKernelPfS_S_iPfS_S_i
.L48:
	.cfi_restore_state
	addq	$40, %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
.LFE2028:
	.size	_Z20matrixMultiplicationPfS_S_i, .-_Z20matrixMultiplicationPfS_S_i
	.section	.rodata.str1.1
.LC4:
	.string	"Starting the program:\n"
.LC5:
	.string	"a"
.LC6:
	.string	"log.txt"
.LC7:
	.string	"Multiplicating matrix %d x %d.\n"
.LC8:
	.string	"Allocating matrices on the device...\n"
.LC9:
	.string	"Failed to allocate M matrix!\n"
.LC10:
	.string	"M Allocation successful.\n"
.LC11:
	.string	"Failed to allocate N matrix!\n"
.LC12:
	.string	"N Allocation successful.\n"
.LC13:
	.string	"Failed to allocate P matrix!\n"
.LC14:
	.string	"P Allocation successful.\n"
.LC15:
	.string	"Failed to allocate R matrix!\n"
.LC16:
	.string	"R Allocation successful.\n"
.LC18:
	.string	"Initialisation finished.\n"
.LC20:
	.string	"Failed to launch kernel. Error: %s.\n"
.LC21:
	.string	"Kernel operations successful. Time elapsed: %lf s.\n"
.LC24:
	.string	"Verification test failed!\nElement at index (%d, %d) should be %f, but is %f. \n"
.LC25:
	.string	"Verification test PASSED, multi-threaded calculations are correct.\n"
.LC26:
	.string	"%d"
.LC27:
	.string	"Comparision test PASSED, single-threaded calculations are correct.\n"
.LC28:
	.string	"Comparision test failed, matrices are not identical"
.LC29:
	.string	"Time elapsed for single-threaded calculations: %lf s.\n\n"
.LC30:
	.string	"Freeing memory...\n"
.LC31:
	.string	"Failed to free device matrix M (error code %s)!\n"
.LC32:
	.string	"Failed to free device matrix N (error code %s)!\n"
.LC33:
	.string	"Failed to free device matrix P (error code %s)!\n"
.LC34:
	.string	"Memory freed successfully.\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2030:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	leaq	.LC4(%rip), %rsi
	movl	$2, %edi
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	subq	$64, %rsp
	.cfi_def_cfa_offset 96
	movq	%fs:40, %rax
	movq	%rax, 56(%rsp)
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	.LC5(%rip), %rsi
	leaq	.LC6(%rip), %rdi
	call	fopen@PLT
	movl	$800, %r8d
	movl	$800, %ecx
	leaq	.LC7(%rip), %rdx
	movq	%rax, %rdi
	movl	$2, %esi
	movq	%rax, %rbx
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	leaq	.LC8(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	$1, %edx
	leaq	24(%rsp), %rdi
	movl	$2560000, %esi
	call	cudaMallocManaged@PLT
	leaq	.LC9(%rip), %rdx
	testl	%eax, %eax
	jne	.L83
	leaq	.LC10(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	32(%rsp), %rdi
	movl	$1, %edx
	movl	$2560000, %esi
	call	cudaMallocManaged@PLT
	testl	%eax, %eax
	je	.L53
	leaq	.LC11(%rip), %rdx
.L83:
	movq	stderr(%rip), %rdi
	movl	$2, %esi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
.L84:
	movl	$1, %edi
	call	exit@PLT
.L53:
	leaq	.LC12(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	$1, %edx
	leaq	40(%rsp), %rdi
	movl	$2560000, %esi
	call	cudaMallocManaged@PLT
	leaq	.LC13(%rip), %rdx
	testl	%eax, %eax
	jne	.L83
	leaq	.LC14(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	$1, %edx
	leaq	48(%rsp), %rdi
	movl	$2560000, %esi
	call	cudaMallocManaged@PLT
	leaq	.LC15(%rip), %rdx
	testl	%eax, %eax
	jne	.L83
	leaq	.LC16(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	xorl	%ebp, %ebp
	call	__printf_chk@PLT
.L56:
	call	rand@PLT
	cvtsi2ssl	%eax, %xmm0
	mulss	.LC17(%rip), %xmm0
	movq	24(%rsp), %rax
	movss	%xmm0, (%rax,%rbp)
	call	rand@PLT
	cvtsi2ssl	%eax, %xmm0
	mulss	.LC17(%rip), %xmm0
	movq	32(%rsp), %rax
	movss	%xmm0, (%rax,%rbp)
	addq	$4, %rbp
	cmpq	$2560000, %rbp
	jne	.L56
	leaq	.LC18(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	call	clock@PLT
	movq	24(%rsp), %rdi
	movq	40(%rsp), %rdx
	movl	$800, %ecx
	movq	32(%rsp), %rsi
	movq	%rax, %rbp
	call	_Z20matrixMultiplicationPfS_S_i
	call	clock@PLT
	subq	%rbp, %rax
	cvtsi2sdq	%rax, %xmm0
	divsd	.LC19(%rip), %xmm0
	movsd	%xmm0, 8(%rsp)
	call	cudaGetLastError@PLT
	movsd	8(%rsp), %xmm0
	testl	%eax, %eax
	movl	%eax, %edi
	je	.L57
	call	cudaGetErrorString@PLT
	leaq	.LC20(%rip), %rdx
	movq	%rax, %rcx
	jmp	.L85
.L57:
	leaq	.LC21(%rip), %rdx
	movl	$2, %esi
	movq	%rbx, %rdi
	movb	$1, %al
	call	__fprintf_chk@PLT
	movq	24(%rsp), %rdi
	movl	$800, %esi
	call	_Z11PrintMatrixPfi
	movq	32(%rsp), %rdi
	movl	$800, %esi
	call	_Z11PrintMatrixPfi
	movq	40(%rsp), %rdi
	movl	$800, %esi
	call	_Z11PrintMatrixPfi
	movq	24(%rsp), %r11
	xorl	%eax, %eax
	xorl	%ecx, %ecx
	movq	32(%rsp), %rbp
	movq	40(%rsp), %r9
	movss	.LC22(%rip), %xmm3
.L58:
	xorl	%r8d, %r8d
	leaq	(%r11,%rax), %r10
	leaq	(%r9,%rax), %rdi
.L64:
	leaq	0(%rbp,%r8,4), %rsi
	xorl	%edx, %edx
	xorps	%xmm0, %xmm0
.L59:
	movss	(%r10,%rdx,4), %xmm1
	mulss	(%rsi), %xmm1
	incq	%rdx
	addq	$3200, %rsi
	addss	%xmm1, %xmm0
	cmpq	$800, %rdx
	jne	.L59
	movss	(%rdi,%r8,4), %xmm1
	movaps	%xmm0, %xmm2
	subss	%xmm1, %xmm2
	andps	%xmm3, %xmm2
	cvtss2sd	%xmm2, %xmm2
	comisd	.LC23(%rip), %xmm2
	jbe	.L80
	movl	$2, %esi
	movq	stderr(%rip), %rdi
	leaq	.LC24(%rip), %rdx
	movb	$2, %al
	cvtss2sd	%xmm0, %xmm0
	cvtss2sd	%xmm1, %xmm1
	call	__fprintf_chk@PLT
	jmp	.L84
.L80:
	incq	%r8
	cmpq	$800, %r8
	jne	.L64
	incl	%ecx
	addq	$3200, %rax
	cmpl	$800, %ecx
	jne	.L58
	leaq	.LC25(%rip), %rdx
	movl	$2, %esi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	call	clock@PLT
	movq	48(%rsp), %rdx
	movq	32(%rsp), %rsi
	movl	$800, %ecx
	movq	24(%rsp), %rdi
	movq	%rax, %rbp
	call	_Z8multiplyPfS_S_i
	call	clock@PLT
	movq	40(%rsp), %rsi
	xorl	%edx, %edx
	xorl	%r8d, %r8d
	subq	%rbp, %rax
	movq	48(%rsp), %rdi
	movl	$1, %ebp
	movss	.LC22(%rip), %xmm3
	cvtsi2sdq	%rax, %xmm4
	movq	%xmm4, %r14
.L65:
	movq	%rdx, %rax
	xorl	%ecx, %ecx
.L67:
	movss	(%rsi,%rax), %xmm0
	subss	(%rdi,%rax), %xmm0
	andps	%xmm3, %xmm0
	cvtss2sd	%xmm0, %xmm0
	ucomisd	.LC23(%rip), %xmm0
	cmova	%r8d, %ebp
	incl	%ecx
	addq	$4, %rax
	cmpl	$800, %ecx
	jne	.L67
	addq	$3200, %rdx
	cmpq	$2560000, %rdx
	jne	.L65
	movl	%ebp, %edx
	xorl	%eax, %eax
	leaq	.LC26(%rip), %rsi
	movl	$2, %edi
	call	__printf_chk@PLT
	decl	%ebp
	leaq	.LC27(%rip), %rdx
	je	.L82
	leaq	.LC28(%rip), %rdx
.L82:
	movl	$2, %esi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	movl	$2, %esi
	movq	%rbx, %rdi
	movb	$1, %al
	leaq	.LC29(%rip), %rdx
	movq	%r14, %xmm0
	divsd	.LC19(%rip), %xmm0
	call	__fprintf_chk@PLT
	movq	%rbx, %rdi
	call	fclose@PLT
	movq	48(%rsp), %rdi
	movl	$800, %esi
	call	_Z11PrintMatrixPfi
	leaq	.LC30(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	24(%rsp), %rdi
	call	cudaFree@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L71
	call	cudaGetErrorString@PLT
	leaq	.LC31(%rip), %rdx
	movq	%rax, %rcx
	jmp	.L85
.L71:
	movq	32(%rsp), %rdi
	call	cudaFree@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L72
	call	cudaGetErrorString@PLT
	leaq	.LC32(%rip), %rdx
	movq	%rax, %rcx
	jmp	.L85
.L72:
	movq	40(%rsp), %rdi
	call	cudaFree@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L73
	call	cudaGetErrorString@PLT
	leaq	.LC33(%rip), %rdx
	movq	%rax, %rcx
.L85:
	movq	stderr(%rip), %rdi
	movl	$2, %esi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	jmp	.L84
.L73:
	xorl	%eax, %eax
	leaq	.LC34(%rip), %rsi
	movl	$2, %edi
	call	__printf_chk@PLT
	movq	56(%rsp), %rax
	subq	%fs:40, %rax
	je	.L74
	call	__stack_chk_fail@PLT
.L74:
	addq	$64, %rsp
	.cfi_def_cfa_offset 32
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2030:
	.size	main, .-main
	.section	.rodata.str1.1
.LC35:
	.string	"_Z26matrixMultiplicationKernelPfS_S_i"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2058:
	.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	.LC35(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z26matrixMultiplicationKernelPfS_S_i(%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
.LFE2058:
	.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
.LC17:
	.long	805306368
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC19:
	.long	0
	.long	1093567616
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC22:
	.long	2147483647
	.long	0
	.long	0
	.long	0
	.section	.rodata.cst8
	.align 8
.LC23:
	.long	-755914244
	.long	1062232653
	.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:

/*
 * main.cu
 *
 *  Created on: Nov 14, 2019
 *	Author: cuda-s01
 */

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

const int TILE_WIDTH = 2;
const int MATRIX_SIZE = 800;

__global__ void matrixMultiplicationKernel(float* M, float* N, float* P, int Width) {
        // Calculate the row index of the P element and M
        int Row = blockIdx.y*blockDim.y+threadIdx.y;
        // Calculate the column index of P and N
        int Col = blockIdx.x*blockDim.x+threadIdx.x;

        __shared__ float sum_M[TILE_WIDTH][TILE_WIDTH];
        __shared__ float sum_N[TILE_WIDTH][TILE_WIDTH];

        sum_M[threadIdx.y][threadIdx.x]=0.0;
        sum_N[threadIdx.y][threadIdx.x]=0.0;

        float Pval = 0;
        for(int k=0; k<((Width - 1)/TILE_WIDTH + 1); k++)
        {
                //printf("Col:%d, Row:%d, k:%d, th:(%d,%d), ");
                if(k*TILE_WIDTH + threadIdx.x < Width && Row < Width)
                        sum_M[threadIdx.y][threadIdx.x] = M[Row*Width + k*TILE_WIDTH + threadIdx.x];
                else sum_M[threadIdx.y][threadIdx.x] = 0.0;

                if(k*TILE_WIDTH + threadIdx.y < Width && Col < Width)
                        sum_N[threadIdx.y][threadIdx.x] = N[(k*TILE_WIDTH + threadIdx.y)*Width + Col];
                else sum_N[threadIdx.y][threadIdx.x] = 0.0;

                __syncthreads();

                for(int n=0; n<TILE_WIDTH;++n)
                        Pval += sum_M[threadIdx.y][n] * sum_N[n][threadIdx.x];

                __syncthreads();

        }
	if(Row < Width && Col < Width)
        {
                P[Row * Width + Col]  = Pval;
                //printf("(%d,%d)=%f\n",Row,Col,P[Row*Width+Col]);
        }
}

void multiply(float* M, float* N, float* P, int size) {
    float X[size][size], Y[size][size], Z[size][size];
    int i, j;

    // Rewriting matrices
    for (i=0;i<size;i++) {
        for (j=0;j<size;j++) {
            X[i][j]=M[size*i+j];
            Y[i][j]=N[size*i+j];
            Z[i][j]=0;
        }
    }

    // Multiplying first and second matrices and storing in Z.
    for (i = 0; i < size; ++i) {
        for (j = 0; j < size; ++j) {
            for (int k = 0; k < size; ++k) {
                Z[i][j] += X[i][k] * Y[k][j];
            }
	   }
    }
    
    for (i=0;i<size;i++) {
        for (j=0;j<size;j++) {
            P[size*i+j]=Z[i][j];
        }
    }


}

void matrixMultiplication(float *M, float *N, float *P, int Width){

    // declare the number of blocks per grid and the number of threads per block
    int th = TILE_WIDTH;
    int bl = (Width/TILE_WIDTH) + 1;
    dim3 threadsPerBlock(th,th,1);
    dim3 blocksPerGrid(bl,bl,1);
    printf("Kernel started: (%d,%d,1) grid, (%d,%d,1) blocks.\n", bl,bl, th,th);
    matrixMultiplicationKernel<<<blocksPerGrid,threadsPerBlock>>>(M, N, P, Width);
}

void PrintMatrix(float* M, int Width)
{
        for(int i = 0; i < Width; i++)
        {
                for(int j = 0; j < Width; j++)
                        printf("%f  ",M[i*Width+j]);
                printf("\n");
        }
	printf("\n");
}

int main(void)
{
        printf("Starting the program:\n");
        hipError_t err = hipSuccess;

        int matrix_size = MATRIX_SIZE;
        int num_of_elements = matrix_size * matrix_size;
        size_t size = num_of_elements * sizeof(float);
        FILE *fp;
        fp=fopen("log.txt", "a");
        fprintf(fp, "Multiplicating matrix %d x %d.\n", matrix_size, matrix_size);

    //==========================Shared Memory============================================

        //allocate matrixes on the device:
        printf("Allocating matrices on the device...\n");
        // printf("First matrix.\n");
        float *M;
        err = hipMallocManaged((void**)&M,  size);
        if(err != hipSuccess)
        {
                fprintf(stderr, "Failed to allocate M matrix!\n");
                exit(EXIT_FAILURE);
        } else printf("M Allocation successful.\n");

        // printf("Second matrix.\n");
        float *N;
        err = hipMallocManaged((void**)&N,  size);
        if(err != hipSuccess)
        {
                fprintf(stderr, "Failed to allocate N matrix!\n");
                exit(EXIT_FAILURE);
        } else printf("N Allocation successful.\n");

        // printf("Third matrix.\n");
        float *P;
        err = hipMallocManaged((void**)&P,  size);
        if(err != hipSuccess)
        {
                fprintf(stderr, "Failed to allocate P matrix!\n");
                exit(EXIT_FAILURE);
        } else printf("P Allocation successful.\n");

        float *R;
        err = hipMallocManaged((void**)&R,  size);
        if(err != hipSuccess)
        {
                fprintf(stderr, "Failed to allocate R matrix!\n");
                exit(EXIT_FAILURE);
        } else printf("R Allocation successful.\n");

        //initialisation:
        for(int i=0; i<num_of_elements; i++)
        {
          M[i] = rand()/(float)RAND_MAX;
          N[i] = rand()/(float)RAND_MAX;
        }

    printf("Initialisation finished.\n");

    //calculations:
    clock_t start=clock();
    matrixMultiplication(M, N, P, matrix_size);
    clock_t end=clock();
    double time_elapsed=((double) (end - start)) / CLOCKS_PER_SEC;
    err = hipGetLastError();

    if(err != hipSuccess)
    {
                fprintf(stderr, "Failed to launch kernel. Error: %s.\n", hipGetErrorString(err));
                exit(EXIT_FAILURE);
        } else fprintf(fp, "Kernel operations successful. Time elapsed: %lf s.\n", time_elapsed);


    //==========================TEST===============================================
    PrintMatrix(M, matrix_size);
    PrintMatrix(N, matrix_size);
    PrintMatrix(P, matrix_size);

        for(int i = 0; i < matrix_size; i++)
        {
                for(int j = 0; j < matrix_size; j++)
                {
                        float tmp = 0;
                        for(int k = 0; k < matrix_size; k++)
                                tmp += M[i*matrix_size + k] * N[k*matrix_size + j];
                        //debug line:
                        //printf("%f ",tmp);
                        if(fabs(tmp - P[i*matrix_size + j]) > 1e-3)
                        {
                                fprintf(stderr, "Verification test failed!\nElement at index (%d, %d) should be %f, but is %f. \n",
                                        i,j,tmp,P[i*matrix_size + j]);
                                exit(EXIT_FAILURE);
                        }
                }
        }

	fprintf(fp, "Verification test PASSED, multi-threaded calculations are correct.\n");

    //======================== Single-threaded calculations =====================

    start=clock();
    multiply(M, N, R, MATRIX_SIZE);
    end=clock();
    time_elapsed=end-start;

    //============================ SINGLE-THREADED TEST ==========================
    int isCorrect=1;
    for(int i=0;i<matrix_size;i++) {
        for (int j=0;j<matrix_size;j++) {
                 if(fabs(P[i*matrix_size + j]-R[i*matrix_size+j]) > 1e-3) {
                        isCorrect=0; }
        }
    }
     	printf("%d", isCorrect);
    if (isCorrect==1) {
        fprintf(fp, "Comparision test PASSED, single-threaded calculations are correct.\n");
    } else {
	    fprintf(fp, "Comparision test failed, matrices are not identical");
    }


    fprintf(fp, "Time elapsed for single-threaded calculations: %lf s.\n\n", time_elapsed/CLOCKS_PER_SEC);
    fclose(fp);
    PrintMatrix(R, matrix_size);

    printf("Freeing memory...\n");

    // Free device global memory
    err = hipFree(M);

    if (err != hipSuccess)
    {
     	fprintf(stderr, "Failed to free device matrix M (error code %s)!\n", hipGetErrorString(err));
        exit(EXIT_FAILURE);
    }

    err = hipFree(N);

    if (err != hipSuccess)
    {
     	fprintf(stderr, "Failed to free device matrix N (error code %s)!\n", hipGetErrorString(err));
        exit(EXIT_FAILURE);
    }

    err = hipFree(P);

    if (err != hipSuccess)
    {
     	fprintf(stderr, "Failed to free device matrix P (error code %s)!\n", hipGetErrorString(err));
        exit(EXIT_FAILURE);
    }

    printf("Memory freed successfully.\n");
    return 0;

}


	.text
	.file	"main.hip"
	.globl	_Z41__device_stub__matrixMultiplicationKernelPfS_S_i # -- Begin function _Z41__device_stub__matrixMultiplicationKernelPfS_S_i
	.type	_Z41__device_stub__matrixMultiplicationKernelPfS_S_i,@function
_Z41__device_stub__matrixMultiplicationKernelPfS_S_i: # @_Z41__device_stub__matrixMultiplicationKernelPfS_S_i
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$112, %rsp
	.cfi_def_cfa_offset 160
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	32(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	24(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	4(%rsp), %rdx
	movl	%ecx, (%rdx)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	16(%rsp), %r12
	leaq	8(%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	$_Z26matrixMultiplicationKernelPfS_S_i, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$128, %rsp
	.cfi_adjust_cfa_offset -128
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	_Z41__device_stub__matrixMultiplicationKernelPfS_S_i, .Lfunc_end0-_Z41__device_stub__matrixMultiplicationKernelPfS_S_i
	.cfi_endproc
                                        # -- End function
	.globl	_Z8multiplyPfS_S_i              # -- Begin function _Z8multiplyPfS_S_i
	.type	_Z8multiplyPfS_S_i,@function
_Z8multiplyPfS_S_i:                     # @_Z8multiplyPfS_S_i
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset %rbp, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register %rbp
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$88, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rsi, %r8
	movl	%ecx, %r14d
	movq	%r14, %rax
	imulq	%r14, %rax
	movq	%rsp, %r15
	leaq	15(,%rax,4), %rax
	andq	$-16, %rax
	subq	%rax, %r15
	movq	%r15, %rsp
	movq	%rsp, %r11
	subq	%rax, %r11
	movq	%r11, %rsp
	movq	%rsp, %rsi
	subq	%rax, %rsi
	movq	%rsi, %rsp
	testl	%ecx, %ecx
	jle	.LBB1_13
# %bb.1:                                # %.preheader63.lr.ph
	movq	%rdi, %r9
	movq	%rdx, -56(%rbp)                 # 8-byte Spill
	leaq	(,%r14,4), %r12
	xorl	%ebx, %ebx
	movq	%r14, %rax
	movl	%ecx, -44(%rbp)                 # 4-byte Spill
	xorl	%r13d, %r13d
	movq	%rsi, -88(%rbp)                 # 8-byte Spill
	movq	%r11, -80(%rbp)                 # 8-byte Spill
	movq	%r8, -72(%rbp)                  # 8-byte Spill
	movq	%rdi, -64(%rbp)                 # 8-byte Spill
.LBB1_2:                                # %._crit_edge
                                        # =>This Inner Loop Header: Depth=1
	movq	%rax, -128(%rbp)                # 8-byte Spill
	leaq	(%rsi,%rbx), %rdi
	movl	%r13d, %eax
	leaq	(%r9,%rax,4), %rcx
	movq	%rcx, -104(%rbp)                # 8-byte Spill
	leaq	(%r15,%rbx), %rcx
	movq	%rcx, -96(%rbp)                 # 8-byte Spill
	leaq	(%r8,%rax,4), %rax
	movq	%rax, -120(%rbp)                # 8-byte Spill
	leaq	(%r11,%rbx), %rax
	movq	%rax, -112(%rbp)                # 8-byte Spill
	xorl	%esi, %esi
	movq	%r12, %rdx
	callq	memset@PLT
	movq	-96(%rbp), %rdi                 # 8-byte Reload
	movq	-104(%rbp), %rsi                # 8-byte Reload
	movq	%r12, %rdx
	callq	memcpy@PLT
	movq	-112(%rbp), %rdi                # 8-byte Reload
	movq	-120(%rbp), %rsi                # 8-byte Reload
	movq	%r12, %rdx
	callq	memcpy@PLT
	movq	-128(%rbp), %rax                # 8-byte Reload
	movq	-64(%rbp), %r9                  # 8-byte Reload
	movq	-72(%rbp), %r8                  # 8-byte Reload
	movq	-80(%rbp), %r11                 # 8-byte Reload
	movq	-88(%rbp), %rsi                 # 8-byte Reload
	addl	-44(%rbp), %r13d                # 4-byte Folded Reload
	addq	%r12, %rbx
	decq	%rax
	jne	.LBB1_2
# %bb.3:                                # %.preheader62
	movl	-44(%rbp), %r13d                # 4-byte Reload
	testl	%r13d, %r13d
	movq	-56(%rbp), %r9                  # 8-byte Reload
	jle	.LBB1_13
# %bb.4:                                # %.preheader60.lr.ph.preheader
	xorl	%eax, %eax
.LBB1_5:                                # %.preheader60.lr.ph
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_6 Depth 2
                                        #       Child Loop BB1_7 Depth 3
	movq	%rax, %rcx
	imulq	%r14, %rcx
	leaq	(%rsi,%rcx,4), %rcx
	movq	%r11, %rdx
	xorl	%r10d, %r10d
.LBB1_6:                                # %.preheader60
                                        #   Parent Loop BB1_5 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB1_7 Depth 3
	movss	(%rcx,%r10,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	movq	%rdx, %rdi
	xorl	%r8d, %r8d
.LBB1_7:                                #   Parent Loop BB1_5 Depth=1
                                        #     Parent Loop BB1_6 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	movss	(%r15,%r8,4), %xmm1             # xmm1 = mem[0],zero,zero,zero
	mulss	(%rdi), %xmm1
	addss	%xmm1, %xmm0
	incq	%r8
	addq	%r12, %rdi
	cmpq	%r8, %r14
	jne	.LBB1_7
# %bb.8:                                # %._crit_edge68
                                        #   in Loop: Header=BB1_6 Depth=2
	movss	%xmm0, (%rcx,%r10,4)
	incq	%r10
	addq	$4, %rdx
	cmpq	%r14, %r10
	jne	.LBB1_6
# %bb.9:                                # %._crit_edge70
                                        #   in Loop: Header=BB1_5 Depth=1
	incq	%rax
	addq	%r12, %r15
	cmpq	%r14, %rax
	jne	.LBB1_5
# %bb.10:                               # %.preheader59
	testl	%r13d, %r13d
	jle	.LBB1_13
# %bb.11:                               # %.preheader.lr.ph
	xorl	%ebx, %ebx
.LBB1_12:                               # %._crit_edge74
                                        # =>This Inner Loop Header: Depth=1
	movl	%ebx, %eax
	leaq	(%r9,%rax,4), %rdi
	movq	%r12, %rdx
	movq	%rsi, %r15
	callq	memcpy@PLT
	movq	%r15, %rsi
	movq	-56(%rbp), %r9                  # 8-byte Reload
	addl	%r13d, %ebx
	addq	%r12, %rsi
	decq	%r14
	jne	.LBB1_12
.LBB1_13:                               # %._crit_edge76
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa %rsp, 8
	retq
.Lfunc_end1:
	.size	_Z8multiplyPfS_S_i, .Lfunc_end1-_Z8multiplyPfS_S_i
	.cfi_endproc
                                        # -- End function
	.globl	_Z20matrixMultiplicationPfS_S_i # -- Begin function _Z20matrixMultiplicationPfS_S_i
	.type	_Z20matrixMultiplicationPfS_S_i,@function
_Z20matrixMultiplicationPfS_S_i:        # @_Z20matrixMultiplicationPfS_S_i
	.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
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movl	%ecx, %ebx
	movq	%rdx, %r14
	movq	%rsi, %r15
	movq	%rdi, %r12
	movl	%ecx, %edx
	shrl	$31, %edx
	addl	%ecx, %edx
	sarl	%edx
	incl	%edx
	movq	%rdx, %r13
	shlq	$32, %r13
	orq	%rdx, %r13
	movl	$.L.str, %edi
	movl	%edx, %esi
                                        # kill: def $edx killed $edx killed $rdx
	movl	$2, %ecx
	movl	$2, %r8d
	xorl	%eax, %eax
	callq	printf
	movabsq	$8589934594, %rdx               # imm = 0x200000002
	movq	%r13, %rdi
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	je	.LBB2_2
# %bb.1:
	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
.LBB2_2:
	.cfi_def_cfa_offset 48
	movq	%r12, %rdi
	movq	%r15, %rsi
	movq	%r14, %rdx
	movl	%ebx, %ecx
	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
	jmp	_Z41__device_stub__matrixMultiplicationKernelPfS_S_i # TAILCALL
.Lfunc_end2:
	.size	_Z20matrixMultiplicationPfS_S_i, .Lfunc_end2-_Z20matrixMultiplicationPfS_S_i
	.cfi_endproc
                                        # -- End function
	.globl	_Z11PrintMatrixPfi              # -- Begin function _Z11PrintMatrixPfi
	.type	_Z11PrintMatrixPfi,@function
_Z11PrintMatrixPfi:                     # @_Z11PrintMatrixPfi
	.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
	pushq	%rax
	.cfi_def_cfa_offset 64
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rdi, (%rsp)                    # 8-byte Spill
	testl	%esi, %esi
	jle	.LBB3_5
# %bb.1:                                # %.preheader.lr.ph
	movl	%esi, %ebx
	movl	%esi, %r15d
	xorl	%r12d, %r12d
	xorl	%r13d, %r13d
.LBB3_2:                                # %.lr.ph
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB3_3 Depth 2
	movl	%r12d, %eax
	movq	(%rsp), %rcx                    # 8-byte Reload
	leaq	(%rcx,%rax,4), %rbp
	xorl	%r14d, %r14d
.LBB3_3:                                #   Parent Loop BB3_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	xorps	%xmm0, %xmm0
	cvtss2sd	(%rbp,%r14,4), %xmm0
	movl	$.L.str.1, %edi
	movb	$1, %al
	callq	printf
	incq	%r14
	cmpq	%r14, %r15
	jne	.LBB3_3
# %bb.4:                                # %._crit_edge
                                        #   in Loop: Header=BB3_2 Depth=1
	movl	$10, %edi
	callq	putchar@PLT
	incq	%r13
	addl	%ebx, %r12d
	cmpq	%r15, %r13
	jne	.LBB3_2
.LBB3_5:                                # %._crit_edge14
	movl	$10, %edi
	addq	$8, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	jmp	putchar@PLT                     # TAILCALL
.Lfunc_end3:
	.size	_Z11PrintMatrixPfi, .Lfunc_end3-_Z11PrintMatrixPfi
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function main
.LCPI4_0:
	.long	0x30000000                      # float 4.65661287E-10
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0
.LCPI4_1:
	.quad	0x412e848000000000              # double 1.0E+6
.LCPI4_3:
	.quad	0x3f50624dd2f1a9fc              # double 0.001
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0
.LCPI4_2:
	.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	%rbx
	.cfi_def_cfa_offset 40
	subq	$40, %rsp
	.cfi_def_cfa_offset 80
	.cfi_offset %rbx, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	$.Lstr, %edi
	callq	puts@PLT
	movl	$.L.str.4, %edi
	movl	$.L.str.5, %esi
	callq	fopen
	movq	%rax, %rbx
	movl	$.L.str.6, %esi
	movq	%rax, %rdi
	movl	$800, %edx                      # imm = 0x320
	movl	$800, %ecx                      # imm = 0x320
	xorl	%eax, %eax
	callq	fprintf
	movl	$.Lstr.1, %edi
	callq	puts@PLT
	leaq	8(%rsp), %rdi
	movl	$2560000, %esi                  # imm = 0x271000
	movl	$1, %edx
	callq	hipMallocManaged
	testl	%eax, %eax
	jne	.LBB4_28
# %bb.1:
	movl	$.Lstr.2, %edi
	callq	puts@PLT
	movq	%rsp, %rdi
	movl	$2560000, %esi                  # imm = 0x271000
	movl	$1, %edx
	callq	hipMallocManaged
	testl	%eax, %eax
	jne	.LBB4_29
# %bb.2:
	movl	$.Lstr.3, %edi
	callq	puts@PLT
	leaq	16(%rsp), %rdi
	movl	$2560000, %esi                  # imm = 0x271000
	movl	$1, %edx
	callq	hipMallocManaged
	testl	%eax, %eax
	jne	.LBB4_30
# %bb.3:
	movl	$.Lstr.4, %edi
	callq	puts@PLT
	leaq	24(%rsp), %rdi
	movl	$2560000, %esi                  # imm = 0x271000
	movl	$1, %edx
	callq	hipMallocManaged
	testl	%eax, %eax
	jne	.LBB4_31
# %bb.4:
	movl	$.Lstr.5, %edi
	callq	puts@PLT
	xorl	%r14d, %r14d
.LBB4_5:                                # =>This Inner Loop Header: Depth=1
	callq	rand
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	movss	.LCPI4_0(%rip), %xmm1           # xmm1 = mem[0],zero,zero,zero
	mulss	%xmm1, %xmm0
	movq	8(%rsp), %rax
	movss	%xmm0, (%rax,%r14,4)
	callq	rand
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	mulss	.LCPI4_0(%rip), %xmm0
	movq	(%rsp), %rax
	movss	%xmm0, (%rax,%r14,4)
	incq	%r14
	cmpq	$640000, %r14                   # imm = 0x9C400
	jne	.LBB4_5
# %bb.6:
	movl	$.Lstr.6, %edi
	callq	puts@PLT
	callq	clock
	movq	%rax, %r14
	movq	8(%rsp), %rdi
	movq	(%rsp), %rsi
	movq	16(%rsp), %rdx
	movl	$800, %ecx                      # imm = 0x320
	callq	_Z20matrixMultiplicationPfS_S_i
	callq	clock
	movq	%rax, %r15
	callq	hipGetLastError
	testl	%eax, %eax
	jne	.LBB4_34
# %bb.7:
	subq	%r14, %r15
	xorps	%xmm0, %xmm0
	cvtsi2sd	%r15, %xmm0
	divsd	.LCPI4_1(%rip), %xmm0
	movl	$.L.str.18, %esi
	movq	%rbx, %rdi
	movb	$1, %al
	callq	fprintf
	movq	8(%rsp), %rdi
	movl	$800, %esi                      # imm = 0x320
	callq	_Z11PrintMatrixPfi
	movq	(%rsp), %rdi
	movl	$800, %esi                      # imm = 0x320
	callq	_Z11PrintMatrixPfi
	movq	16(%rsp), %rdi
	movl	$800, %esi                      # imm = 0x320
	callq	_Z11PrintMatrixPfi
	movq	8(%rsp), %rax
	movq	(%rsp), %rsi
	xorl	%edx, %edx
	movq	16(%rsp), %rdi
.LBB4_8:                                # %.preheader111
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB4_9 Depth 2
                                        #       Child Loop BB4_10 Depth 3
	imulq	$3200, %rdx, %r8                # imm = 0xC80
	addq	%rdi, %r8
	movq	%rsi, %r9
	xorl	%ecx, %ecx
.LBB4_9:                                # %.preheader110
                                        #   Parent Loop BB4_8 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB4_10 Depth 3
	xorpd	%xmm0, %xmm0
	movq	%r9, %r10
	xorl	%r11d, %r11d
.LBB4_10:                               #   Parent Loop BB4_8 Depth=1
                                        #     Parent Loop BB4_9 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	movss	(%rax,%r11,4), %xmm1            # xmm1 = mem[0],zero,zero,zero
	mulss	(%r10), %xmm1
	addss	%xmm1, %xmm0
	incq	%r11
	addq	$3200, %r10                     # imm = 0xC80
	cmpq	$800, %r11                      # imm = 0x320
	jne	.LBB4_10
# %bb.11:                               #   in Loop: Header=BB4_9 Depth=2
	movss	(%r8,%rcx,4), %xmm1             # xmm1 = mem[0],zero,zero,zero
	movaps	%xmm0, %xmm2
	subss	%xmm1, %xmm2
	andps	.LCPI4_2(%rip), %xmm2
	cvtss2sd	%xmm2, %xmm2
	ucomisd	.LCPI4_3(%rip), %xmm2
	ja	.LBB4_27
# %bb.12:                               #   in Loop: Header=BB4_9 Depth=2
	incq	%rcx
	addq	$4, %r9
	cmpq	$800, %rcx                      # imm = 0x320
	jne	.LBB4_9
# %bb.13:                               #   in Loop: Header=BB4_8 Depth=1
	incq	%rdx
	addq	$3200, %rax                     # imm = 0xC80
	cmpq	$800, %rdx                      # imm = 0x320
	jne	.LBB4_8
# %bb.14:
	movl	$.L.str.20, %edi
	movl	$67, %esi
	movl	$1, %edx
	movq	%rbx, %rcx
	callq	fwrite@PLT
	callq	clock
	movq	%rax, %r14
	movq	8(%rsp), %rdi
	movq	(%rsp), %rsi
	movq	24(%rsp), %rdx
	movl	$800, %ecx                      # imm = 0x320
	callq	_Z8multiplyPfS_S_i
	callq	clock
	movsd	.LCPI4_3(%rip), %xmm2           # xmm2 = mem[0],zero
	movaps	.LCPI4_2(%rip), %xmm1           # xmm1 = [NaN,NaN,NaN,NaN]
	subq	%r14, %rax
	movq	16(%rsp), %rcx
	movl	$1, %ebp
	xorl	%edx, %edx
	movq	24(%rsp), %rsi
	movl	$3200, %edi                     # imm = 0xC80
.LBB4_15:                               # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB4_16 Depth 2
	xorl	%r8d, %r8d
	movl	%ebp, %r9d
.LBB4_16:                               #   Parent Loop BB4_15 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movss	(%rcx,%r8,4), %xmm0             # xmm0 = mem[0],zero,zero,zero
	subss	(%rsi,%r8,4), %xmm0
	andps	%xmm1, %xmm0
	cvtss2sd	%xmm0, %xmm0
	xorl	%ebp, %ebp
	ucomisd	%xmm2, %xmm0
	ja	.LBB4_18
# %bb.17:                               #   in Loop: Header=BB4_16 Depth=2
	movl	%r9d, %ebp
.LBB4_18:                               #   in Loop: Header=BB4_16 Depth=2
	incq	%r8
	movl	%ebp, %r9d
	cmpq	$800, %r8                       # imm = 0x320
	jne	.LBB4_16
# %bb.19:                               #   in Loop: Header=BB4_15 Depth=1
	incq	%rdx
	addq	%rdi, %rsi
	addq	%rdi, %rcx
	cmpq	$800, %rdx                      # imm = 0x320
	jne	.LBB4_15
# %bb.20:
	xorps	%xmm0, %xmm0
	cvtsi2sd	%rax, %xmm0
	movsd	%xmm0, 32(%rsp)                 # 8-byte Spill
	movl	$.L.str.21, %edi
	movl	%ebp, %esi
	xorl	%eax, %eax
	callq	printf
	cmpl	$1, %ebp
	jne	.LBB4_22
# %bb.21:
	movl	$.L.str.22, %edi
	movl	$67, %esi
	jmp	.LBB4_23
.LBB4_22:
	movl	$.L.str.23, %edi
	movl	$51, %esi
.LBB4_23:
	movl	$1, %edx
	movq	%rbx, %rcx
	callq	fwrite@PLT
	movsd	32(%rsp), %xmm0                 # 8-byte Reload
                                        # xmm0 = mem[0],zero
	divsd	.LCPI4_1(%rip), %xmm0
	movl	$.L.str.24, %esi
	movq	%rbx, %rdi
	movb	$1, %al
	callq	fprintf
	movq	%rbx, %rdi
	callq	fclose
	movq	24(%rsp), %rdi
	movl	$800, %esi                      # imm = 0x320
	callq	_Z11PrintMatrixPfi
	movl	$.Lstr.7, %edi
	callq	puts@PLT
	movq	8(%rsp), %rdi
	callq	hipFree
	testl	%eax, %eax
	jne	.LBB4_35
# %bb.24:
	movq	(%rsp), %rdi
	callq	hipFree
	testl	%eax, %eax
	jne	.LBB4_36
# %bb.25:
	movq	16(%rsp), %rdi
	callq	hipFree
	testl	%eax, %eax
	jne	.LBB4_37
# %bb.26:
	movl	$.Lstr.8, %edi
	callq	puts@PLT
	xorl	%eax, %eax
	addq	$40, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.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
.LBB4_27:
	.cfi_def_cfa_offset 80
	movq	stderr(%rip), %rdi
	cvtss2sd	%xmm0, %xmm0
	cvtss2sd	%xmm1, %xmm1
	movl	$.L.str.19, %esi
                                        # kill: def $edx killed $edx killed $rdx
                                        # kill: def $ecx killed $ecx killed $rcx
	movb	$2, %al
	callq	fprintf
.LBB4_33:
	movl	$1, %edi
	callq	exit
.LBB4_28:
	movq	stderr(%rip), %rcx
	movl	$.L.str.8, %edi
	jmp	.LBB4_32
.LBB4_29:
	movq	stderr(%rip), %rcx
	movl	$.L.str.10, %edi
	jmp	.LBB4_32
.LBB4_30:
	movq	stderr(%rip), %rcx
	movl	$.L.str.12, %edi
	jmp	.LBB4_32
.LBB4_31:
	movq	stderr(%rip), %rcx
	movl	$.L.str.14, %edi
.LBB4_32:
	movl	$29, %esi
	movl	$1, %edx
	callq	fwrite@PLT
	jmp	.LBB4_33
.LBB4_34:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.17, %esi
	jmp	.LBB4_38
.LBB4_35:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.26, %esi
	jmp	.LBB4_38
.LBB4_36:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.27, %esi
	jmp	.LBB4_38
.LBB4_37:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.28, %esi
.LBB4_38:
	movq	%rbx, %rdi
	movq	%rax, %rdx
	xorl	%eax, %eax
	callq	fprintf
	jmp	.LBB4_33
.Lfunc_end4:
	.size	main, .Lfunc_end4-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	.LBB5_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB5_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z26matrixMultiplicationKernelPfS_S_i, %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_end5:
	.size	__hip_module_ctor, .Lfunc_end5-__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	.LBB6_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
.LBB6_2:
	retq
.Lfunc_end6:
	.size	__hip_module_dtor, .Lfunc_end6-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	_Z26matrixMultiplicationKernelPfS_S_i,@object # @_Z26matrixMultiplicationKernelPfS_S_i
	.section	.rodata,"a",@progbits
	.globl	_Z26matrixMultiplicationKernelPfS_S_i
	.p2align	3, 0x0
_Z26matrixMultiplicationKernelPfS_S_i:
	.quad	_Z41__device_stub__matrixMultiplicationKernelPfS_S_i
	.size	_Z26matrixMultiplicationKernelPfS_S_i, 8

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"Kernel started: (%d,%d,1) grid, (%d,%d,1) blocks.\n"
	.size	.L.str, 51

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"%f  "
	.size	.L.str.1, 5

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"log.txt"
	.size	.L.str.4, 8

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"a"
	.size	.L.str.5, 2

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"Multiplicating matrix %d x %d.\n"
	.size	.L.str.6, 32

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"Failed to allocate M matrix!\n"
	.size	.L.str.8, 30

	.type	.L.str.10,@object               # @.str.10
.L.str.10:
	.asciz	"Failed to allocate N matrix!\n"
	.size	.L.str.10, 30

	.type	.L.str.12,@object               # @.str.12
.L.str.12:
	.asciz	"Failed to allocate P matrix!\n"
	.size	.L.str.12, 30

	.type	.L.str.14,@object               # @.str.14
.L.str.14:
	.asciz	"Failed to allocate R matrix!\n"
	.size	.L.str.14, 30

	.type	.L.str.17,@object               # @.str.17
.L.str.17:
	.asciz	"Failed to launch kernel. Error: %s.\n"
	.size	.L.str.17, 37

	.type	.L.str.18,@object               # @.str.18
.L.str.18:
	.asciz	"Kernel operations successful. Time elapsed: %lf s.\n"
	.size	.L.str.18, 52

	.type	.L.str.19,@object               # @.str.19
.L.str.19:
	.asciz	"Verification test failed!\nElement at index (%d, %d) should be %f, but is %f. \n"
	.size	.L.str.19, 79

	.type	.L.str.20,@object               # @.str.20
.L.str.20:
	.asciz	"Verification test PASSED, multi-threaded calculations are correct.\n"
	.size	.L.str.20, 68

	.type	.L.str.21,@object               # @.str.21
.L.str.21:
	.asciz	"%d"
	.size	.L.str.21, 3

	.type	.L.str.22,@object               # @.str.22
.L.str.22:
	.asciz	"Comparision test PASSED, single-threaded calculations are correct.\n"
	.size	.L.str.22, 68

	.type	.L.str.23,@object               # @.str.23
.L.str.23:
	.asciz	"Comparision test failed, matrices are not identical"
	.size	.L.str.23, 52

	.type	.L.str.24,@object               # @.str.24
.L.str.24:
	.asciz	"Time elapsed for single-threaded calculations: %lf s.\n\n"
	.size	.L.str.24, 56

	.type	.L.str.26,@object               # @.str.26
.L.str.26:
	.asciz	"Failed to free device matrix M (error code %s)!\n"
	.size	.L.str.26, 49

	.type	.L.str.27,@object               # @.str.27
.L.str.27:
	.asciz	"Failed to free device matrix N (error code %s)!\n"
	.size	.L.str.27, 49

	.type	.L.str.28,@object               # @.str.28
.L.str.28:
	.asciz	"Failed to free device matrix P (error code %s)!\n"
	.size	.L.str.28, 49

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

	.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	"Starting the program:"
	.size	.Lstr, 22

	.type	.Lstr.1,@object                 # @str.1
.Lstr.1:
	.asciz	"Allocating matrices on the device..."
	.size	.Lstr.1, 37

	.type	.Lstr.2,@object                 # @str.2
.Lstr.2:
	.asciz	"M Allocation successful."
	.size	.Lstr.2, 25

	.type	.Lstr.3,@object                 # @str.3
.Lstr.3:
	.asciz	"N Allocation successful."
	.size	.Lstr.3, 25

	.type	.Lstr.4,@object                 # @str.4
.Lstr.4:
	.asciz	"P Allocation successful."
	.size	.Lstr.4, 25

	.type	.Lstr.5,@object                 # @str.5
.Lstr.5:
	.asciz	"R Allocation successful."
	.size	.Lstr.5, 25

	.type	.Lstr.6,@object                 # @str.6
.Lstr.6:
	.asciz	"Initialisation finished."
	.size	.Lstr.6, 25

	.type	.Lstr.7,@object                 # @str.7
.Lstr.7:
	.asciz	"Freeing memory..."
	.size	.Lstr.7, 18

	.type	.Lstr.8,@object                 # @str.8
.Lstr.8:
	.asciz	"Memory freed successfully."
	.size	.Lstr.8, 27

	.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 _Z41__device_stub__matrixMultiplicationKernelPfS_S_i
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z26matrixMultiplicationKernelPfS_S_i
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z26matrixMultiplicationKernelPfS_S_i ; -- Begin function _Z26matrixMultiplicationKernelPfS_S_i
	.globl	_Z26matrixMultiplicationKernelPfS_S_i
	.p2align	8
	.type	_Z26matrixMultiplicationKernelPfS_S_i,@function
_Z26matrixMultiplicationKernelPfS_S_i:  ; @_Z26matrixMultiplicationKernelPfS_S_i
; %bb.0:
	s_clause 0x3
	s_load_b32 s9, s[0:1], 0x2c
	s_load_b32 s8, s[0:1], 0x18
	s_load_b128 s[4:7], s[0:1], 0x0
	s_load_b64 s[2:3], s[0:1], 0x10
	v_and_b32_e32 v6, 0x3ff, v0
	v_bfe_u32 v2, v0, 10, 10
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_dual_mov_b32 v8, 0 :: v_dual_lshlrev_b32 v3, 2, v6
	v_lshl_add_u32 v7, v2, 3, v3
	ds_store_2addr_b32 v7, v8, v8 offset1:4
	s_waitcnt lgkmcnt(0)
	s_lshr_b32 s0, s9, 16
	s_and_b32 s1, s9, 0xffff
	v_mad_u64_u32 v[0:1], null, s15, s0, v[2:3]
	s_mul_i32 s14, s14, s1
	s_cmp_lt_i32 s8, 0
	v_add_nc_u32_e32 v1, s14, v6
	s_cbranch_scc1 .LBB0_7
; %bb.1:                                ; %.lr.ph
	v_mul_lo_u32 v3, v2, s8
	s_add_i32 s0, s8, -1
	s_delay_alu instid0(VALU_DEP_3)
	v_mul_lo_u32 v10, v0, s8
	s_lshr_b32 s1, s0, 31
	v_dual_mov_b32 v8, 0 :: v_dual_add_nc_u32 v9, 16, v7
	s_add_i32 s0, s0, s1
	v_cmp_gt_i32_e32 vcc_lo, s8, v0
	s_ashr_i32 s1, s0, 1
	v_cmp_gt_i32_e64 s0, s8, v1
	v_lshlrev_b32_e32 v11, 3, v2
	v_lshl_add_u32 v12, v6, 2, 16
	v_add3_u32 v3, v6, v3, s14
	v_mov_b32_e32 v5, 0
	s_add_i32 s9, s1, 1
	s_lshl_b32 s10, s8, 1
.LBB0_2:                                ; =>This Inner Loop Header: Depth=1
	v_cmp_gt_u32_e64 s1, s8, v6
	v_mov_b32_e32 v4, 0
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_and_b32 s1, vcc_lo, s1
	s_and_saveexec_b32 s11, s1
	s_cbranch_execz .LBB0_4
; %bb.3:                                ;   in Loop: Header=BB0_2 Depth=1
	v_add_nc_u32_e32 v4, v10, v6
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[13:14], 2, v[4:5]
	v_add_co_u32 v13, s1, s4, v13
	s_delay_alu instid0(VALU_DEP_1)
	v_add_co_ci_u32_e64 v14, s1, s5, v14, s1
	global_load_b32 v4, v[13:14], off
.LBB0_4:                                ;   in Loop: Header=BB0_2 Depth=1
	s_or_b32 exec_lo, exec_lo, s11
	v_cmp_gt_u32_e64 s1, s8, v2
	v_mov_b32_e32 v13, 0
	s_waitcnt vmcnt(0)
	ds_store_b32 v7, v4
	s_and_b32 s1, s0, s1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_saveexec_b32 s11, s1
	s_cbranch_execz .LBB0_6
; %bb.5:                                ;   in Loop: Header=BB0_2 Depth=1
	v_mov_b32_e32 v4, v5
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[13:14], 2, v[3:4]
	v_add_co_u32 v13, s1, s6, v13
	s_delay_alu instid0(VALU_DEP_1)
	v_add_co_ci_u32_e64 v14, s1, s7, v14, s1
	global_load_b32 v13, v[13:14], off
.LBB0_6:                                ;   in Loop: Header=BB0_2 Depth=1
	s_or_b32 exec_lo, exec_lo, s11
	s_waitcnt vmcnt(0)
	ds_store_b32 v9, v13
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	ds_load_b64 v[13:14], v11
	ds_load_2addr_b32 v[15:16], v12 offset1:2
	v_add_nc_u32_e32 v6, 2, v6
	v_add_nc_u32_e32 v2, 2, v2
	s_add_i32 s9, s9, -1
	s_waitcnt lgkmcnt(0)
	s_cmp_eq_u32 s9, 0
	s_barrier
	buffer_gl0_inv
	v_fmac_f32_e32 v8, v13, v15
	s_delay_alu instid0(VALU_DEP_1)
	v_dual_fmac_f32 v8, v14, v16 :: v_dual_add_nc_u32 v3, s10, v3
	s_cbranch_scc0 .LBB0_2
.LBB0_7:                                ; %Flow70
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_max_i32_e32 v2, v0, v1
	s_mov_b32 s0, exec_lo
	v_cmpx_gt_i32_e64 s8, v2
	s_cbranch_execz .LBB0_9
; %bb.8:
	v_mad_u64_u32 v[2:3], null, v0, s8, v[1:2]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v3, 31, v2
	v_lshlrev_b64 v[0:1], 2, v[2:3]
	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], v8, off
.LBB0_9:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z26matrixMultiplicationKernelPfS_S_i
		.amdhsa_group_segment_fixed_size 32
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 288
		.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 17
		.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	_Z26matrixMultiplicationKernelPfS_S_i, .Lfunc_end0-_Z26matrixMultiplicationKernelPfS_S_i
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 552
; NumSgprs: 18
; NumVgprs: 17
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 32 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 2
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 17
; 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:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         16
        .size:           8
        .value_kind:     global_buffer
      - .offset:         24
        .size:           4
        .value_kind:     by_value
      - .offset:         32
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         36
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         40
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         44
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         46
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         48
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         50
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         52
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         54
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         88
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         96
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 32
    .kernarg_segment_align: 8
    .kernarg_segment_size: 288
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z26matrixMultiplicationKernelPfS_S_i
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z26matrixMultiplicationKernelPfS_S_i.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     17
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
