/*
 * main.cu
 *
 *  Created on: Nov 14, 2019
 *      Author: cuda-s01
 */
#include <stdio.h>
__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;
	//debug line:
	//printf("Row:%d, Col:%d. BlockIdx(%d,%d), blockDim(%d,%d) threadIdx(%d,%d)\n\n",Row,Col,blockIdx.x,blockIdx.y,blockDim.x,blockDim.y,threadIdx.x,threadIdx.y);
	if ((Row < Width) && (Col < Width)) {
		float Pvalue = 0;
		// each thread computes one element of the block sub-matrix
		for (int k = 0; k < Width; ++k) {
			Pvalue += M[Row*Width+k]*N[k*Width+Col];
		}
		P[Row*Width+Col] = Pvalue;
	}
	else P[Row*Width+Col] =  99.9;
}

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 = Width;
    int bl = 1;
    dim3 threadsPerBlock(th,th);
    dim3 blocksPerGrid(bl,bl);
    printf("Kernel started: %d blocks, %d threads.\n", bl, 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 = 10;
    	int num_of_elements = matrix_size * matrix_size;
	size_t size = num_of_elements * sizeof(float);
	printf("matrix [%d x %d] multiplication.\n", matrix_size, matrix_size);
    
    //==========================HOST===============================================

	//allocate matrixes (two input ones, one output one):
    //matrix can be represented as a flat vector in the memory - it is so in GPU, 
    //so for simplification of indexation I also use this representation on the host
	printf("Started variables allocation for the host.\n");
	float *M_h = (float *)malloc(size);
	float *N_h = (float *)malloc(size);
	float *P_h = (float *)malloc(size);

	if(M_h == NULL || N_h == NULL || P_h == NULL)
	{
		fprintf(stderr, "Failed to allocate host matrix!\n");
		exit(EXIT_FAILURE);
	}else printf("Allocation on host successful.\n");

	//initialize matrices:
	printf("Started initialization.\n");
	for(int i = 0; i < num_of_elements; i++)
	{
        M_h[i] = rand()/(float)RAND_MAX;
        N_h[i] = rand()/(float)RAND_MAX;
	}
	printf("Initialization fnished.\n");

    //==========================DEVICE==============================================
    
	//allocate matrixes on the device:
	printf("Started variables allocation for the device.\n");
    printf("First matrix.\n");
	float *M_d;
	err = cudaMalloc((void**)&M_d,  size);
	if(err != cudaSuccess)
	{
		fprintf(stderr, "Failed to allocate host matrix!\n");
		exit(EXIT_FAILURE);
	} else printf("Allocation successful.\n");
    
    printf("Second matrix.\n");
	float *N_d;
	err = cudaMalloc((void**)&N_d,  size);
	if(err != cudaSuccess)
	{
		fprintf(stderr, "Failed to allocate host matrix!\n");
		exit(EXIT_FAILURE);
	} else printf("Allocation successful.\n");
	
	printf("Third matrix.\n");
	float *P_d;
	err = cudaMalloc((void**)&P_d,  size);
	if(err != cudaSuccess)
	{
		fprintf(stderr, "Failed to allocate host matrix!\n");
		exit(EXIT_FAILURE);
	} else printf("Allocation successful.\n");

    
    //copy marices into the device:
    printf("Started variables copying into the device.\n");
    printf("First matrix.\n");
	err = cudaMemcpy(M_d, M_h, size, cudaMemcpyHostToDevice);
	if(err != cudaSuccess)
	{
		fprintf(stderr, "Failed to copy first matrix!\n");
		exit(EXIT_FAILURE);
	} else printf("Copying successful.\n");
    
    printf("Second matrix.\n");
	err = cudaMemcpy(N_d, N_h, size, cudaMemcpyHostToDevice);
	if(err != cudaSuccess)
	{
		fprintf(stderr, "Failed to copy second matrix!\n");
		exit(EXIT_FAILURE);
	} else printf("Copying successful.\n");
	
    //calculations:
    matrixMultiplication(M_d, N_d, P_d, matrix_size);
    err = cudaGetLastError();
    
    if(err != cudaSuccess)
    {
		fprintf(stderr, "Failed to launch kernel. Error: %s.\n", cudaGetErrorString(err));
		exit(EXIT_FAILURE);
	} else printf("Kerel operations successful.\n");
    
    printf("Started variables copying from the device.\n");
    err = cudaMemcpy(P_h, P_d, size, cudaMemcpyDeviceToHost);
	if(err != cudaSuccess)
	{
		fprintf(stderr, "Failed to copy result matrix. Error: %s.\n", cudaGetErrorString(err));
		exit(EXIT_FAILURE);
	} else printf("Copying successful.\n");
    
    //==========================TEST===============================================
	//PrintMatrix(M_h, matrix_size);
	//PrintMatrix(N_h, matrix_size);
	//PrintMatrix(P_h, 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_h[i*matrix_size + k] * N_h[k*matrix_size + j];
			//debug line:
			//printf("%f ",tmp);
			if(fabs(tmp - P_h[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_h[i*matrix_size + j]);
				exit(EXIT_FAILURE);
			}
		}
    	}

	printf("Test PASSED\n");
    
    // Free device global memory
    err = cudaFree(M_d);

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

    err = cudaFree(N_d);

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

    err = cudaFree(P_d);

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

    
    // Free host memory
    free(M_h);
    free(N_h);
    free(P_h);
    
    printf("Done\n");
    return 0;    
	
}


	.file	"tmpxft_002aa52d_00000000-6_main.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2032:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2032:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%f  "
.LC1:
	.string	"\n"
	.text
	.globl	_Z11PrintMatrixPfi
	.type	_Z11PrintMatrixPfi, @function
_Z11PrintMatrixPfi:
.LFB2028:
	.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
.L3:
	cmpl	%ebp, %r12d
	jge	.L9
	leaq	(%rbx,%r13), %r15
.L4:
	cvtss2sd	(%rbx), %xmm0
	movq	%r14, %rsi
	movl	$2, %edi
	movb	$1, %al
	call	__printf_chk@PLT
	addq	$4, %rbx
	cmpq	%r15, %rbx
	jne	.L4
	leaq	.LC1(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	incl	%r12d
	call	__printf_chk@PLT
	jmp	.L3
.L9:
	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
.LFE2028:
	.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:
.LFB2054:
	.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	.L10
	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
.L10:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L12
	call	__stack_chk_fail@PLT
.L12:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2054:
	.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:
.LFB2055:
	.cfi_startproc
	endbr64
	jmp	_Z51__device_stub__Z26matrixMultiplicationKernelPfS_S_iPfS_S_i
	.cfi_endproc
.LFE2055:
	.size	_Z26matrixMultiplicationKernelPfS_S_i, .-_Z26matrixMultiplicationKernelPfS_S_i
	.section	.rodata.str1.1
.LC2:
	.string	"Kernel started: %d blocks, %d threads.\n"
	.text
	.globl	_Z20matrixMultiplicationPfS_S_i
	.type	_Z20matrixMultiplicationPfS_S_i, @function
_Z20matrixMultiplicationPfS_S_i:
.LFB2027:
	.cfi_startproc
	endbr64
	movabsq	$4294967297, %rax
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	movq	%rdx, %r13
	movl	$1, %edx
	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
	subq	$40, %rsp
	.cfi_def_cfa_offset 80
	movq	%rax, 20(%rsp)
	xorl	%eax, %eax
	movl	%ecx, 8(%rsp)
	movl	%ecx, 12(%rsp)
	movl	$1, 16(%rsp)
	movl	$1, 28(%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	.L15
	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
.L15:
	.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
.LFE2027:
	.size	_Z20matrixMultiplicationPfS_S_i, .-_Z20matrixMultiplicationPfS_S_i
	.section	.rodata.str1.1
.LC4:
	.string	"Starting the program:\n"
.LC5:
	.string	"matrix [%d x %d] multiplication.\n"
.LC6:
	.string	"Started variables allocation for the host.\n"
.LC7:
	.string	"Failed to allocate host matrix!\n"
.LC8:
	.string	"Allocation on host successful.\n"
.LC9:
	.string	"Started initialization.\n"
.LC11:
	.string	"Initialization fnished.\n"
.LC12:
	.string	"Started variables allocation for the device.\n"
.LC13:
	.string	"First matrix.\n"
.LC14:
	.string	"Allocation successful.\n"
.LC15:
	.string	"Second matrix.\n"
.LC16:
	.string	"Third matrix.\n"
.LC17:
	.string	"Started variables copying into the device.\n"
.LC18:
	.string	"Failed to copy first matrix!\n"
.LC19:
	.string	"Copying successful.\n"
.LC20:
	.string	"Failed to copy second matrix!\n"
.LC21:
	.string	"Failed to launch kernel. Error: %s.\n"
.LC22:
	.string	"Kerel operations successful.\n"
.LC23:
	.string	"Started variables copying from the device.\n"
.LC24:
	.string	"Failed to copy result matrix. Error: %s.\n"
.LC27:
	.string	"Verification test failed.!\nElement at index (%d, %d) should be %f, but is %f. \n"
.LC28:
	.string	"Test PASSED\n"
.LC29:
	.string	"Failed to free device matrix M (error code %s)!\n"
.LC30:
	.string	"Failed to free device matrix N (error code %s)!\n"
.LC31:
	.string	"Failed to free device matrix P (error code %s)!\n"
.LC32:
	.string	"Done\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2029:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	.LC4(%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	$40, %rsp
	.cfi_def_cfa_offset 96
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	$10, %edx
	movl	$10, %ecx
	xorl	%eax, %eax
	leaq	.LC5(%rip), %rsi
	movl	$2, %edi
	call	__printf_chk@PLT
	leaq	.LC6(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	$400, %edi
	call	malloc@PLT
	movl	$400, %edi
	movq	%rax, %rbp
	call	malloc@PLT
	movl	$400, %edi
	movq	%rax, %rbx
	call	malloc@PLT
	testq	%rbp, %rbp
	movq	%rax, %r12
	sete	%al
	testq	%rbx, %rbx
	sete	%dl
	orb	%dl, %al
	jne	.L51
	testq	%r12, %r12
	je	.L51
	leaq	.LC8(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	xorl	%r13d, %r13d
	call	__printf_chk@PLT
	leaq	.LC9(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L21:
	call	rand@PLT
	cvtsi2ssl	%eax, %xmm0
	mulss	.LC10(%rip), %xmm0
	movss	%xmm0, 0(%rbp,%r13)
	call	rand@PLT
	cvtsi2ssl	%eax, %xmm0
	mulss	.LC10(%rip), %xmm0
	movss	%xmm0, (%rbx,%r13)
	addq	$4, %r13
	cmpq	$400, %r13
	jne	.L21
	leaq	.LC11(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	.LC13(%rip), %r15
	leaq	.LC12(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
	movq	%r15, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	%rsp, %rdi
	movl	$400, %esi
	call	cudaMalloc@PLT
	testl	%eax, %eax
	jne	.L51
	leaq	.LC14(%rip), %r13
	movl	$2, %edi
	xorl	%eax, %eax
	movq	%r13, %rsi
	leaq	.LC15(%rip), %r14
	call	__printf_chk@PLT
	movq	%r14, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	8(%rsp), %rdi
	movl	$400, %esi
	call	cudaMalloc@PLT
	testl	%eax, %eax
	jne	.L51
	movq	%r13, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	.LC16(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	16(%rsp), %rdi
	movl	$400, %esi
	call	cudaMalloc@PLT
	testl	%eax, %eax
	je	.L24
.L51:
	leaq	.LC7(%rip), %rdx
	jmp	.L50
.L24:
	movq	%r13, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	.LC17(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	%r15, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	(%rsp), %rdi
	movl	$400, %edx
	movq	%rbp, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	leaq	.LC18(%rip), %rdx
	testl	%eax, %eax
	jne	.L50
	leaq	.LC19(%rip), %r13
	movl	$2, %edi
	xorl	%eax, %eax
	movq	%r13, %rsi
	call	__printf_chk@PLT
	movq	%r14, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	8(%rsp), %rdi
	movl	$1, %ecx
	movq	%rbx, %rsi
	movl	$400, %edx
	call	cudaMemcpy@PLT
	testl	%eax, %eax
	je	.L26
	leaq	.LC20(%rip), %rdx
.L50:
	movq	stderr(%rip), %rdi
	movl	$2, %esi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	jmp	.L48
.L26:
	movq	%r13, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	(%rsp), %rdi
	movq	16(%rsp), %rdx
	movl	$10, %ecx
	movq	8(%rsp), %rsi
	call	_Z20matrixMultiplicationPfS_S_i
	call	cudaGetLastError@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L27
	call	cudaGetErrorString@PLT
	leaq	.LC21(%rip), %rdx
	movq	%rax, %rcx
	jmp	.L49
.L27:
	leaq	.LC22(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	.LC23(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	16(%rsp), %rsi
	movq	%r12, %rdi
	movl	$2, %ecx
	movl	$400, %edx
	call	cudaMemcpy@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L28
	call	cudaGetErrorString@PLT
	leaq	.LC24(%rip), %rdx
	movq	%rax, %rcx
	jmp	.L49
.L28:
	movq	%r13, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movsd	.LC26(%rip), %xmm4
	xorl	%eax, %eax
	xorl	%ecx, %ecx
	movss	.LC25(%rip), %xmm3
.L29:
	xorl	%r8d, %r8d
	leaq	0(%rbp,%rax), %r9
	leaq	(%r12,%rax), %rdi
.L35:
	leaq	(%rbx,%r8,4), %rsi
	xorl	%edx, %edx
	xorps	%xmm0, %xmm0
.L30:
	movss	(%r9,%rdx,4), %xmm1
	mulss	(%rsi), %xmm1
	incq	%rdx
	addq	$40, %rsi
	addss	%xmm1, %xmm0
	cmpq	$10, %rdx
	jne	.L30
	movss	(%rdi,%r8,4), %xmm1
	movaps	%xmm0, %xmm2
	subss	%xmm1, %xmm2
	andps	%xmm3, %xmm2
	cvtss2sd	%xmm2, %xmm2
	comisd	%xmm4, %xmm2
	jbe	.L44
	movl	$2, %esi
	movq	stderr(%rip), %rdi
	leaq	.LC27(%rip), %rdx
	movb	$2, %al
	cvtss2sd	%xmm0, %xmm0
	cvtss2sd	%xmm1, %xmm1
	call	__fprintf_chk@PLT
	jmp	.L48
.L44:
	incq	%r8
	cmpq	$10, %r8
	jne	.L35
	incl	%ecx
	addq	$40, %rax
	cmpl	$10, %ecx
	jne	.L29
	leaq	.LC28(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	(%rsp), %rdi
	call	cudaFree@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L36
	call	cudaGetErrorString@PLT
	leaq	.LC29(%rip), %rdx
	movq	%rax, %rcx
	jmp	.L49
.L36:
	movq	8(%rsp), %rdi
	call	cudaFree@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L37
	call	cudaGetErrorString@PLT
	leaq	.LC30(%rip), %rdx
	movq	%rax, %rcx
	jmp	.L49
.L37:
	movq	16(%rsp), %rdi
	call	cudaFree@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L38
	call	cudaGetErrorString@PLT
	leaq	.LC31(%rip), %rdx
	movq	%rax, %rcx
.L49:
	movq	stderr(%rip), %rdi
	movl	$2, %esi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
.L48:
	movl	$1, %edi
	call	exit@PLT
.L38:
	movq	%rbp, %rdi
	call	free@PLT
	movq	%rbx, %rdi
	call	free@PLT
	movq	%r12, %rdi
	call	free@PLT
	xorl	%eax, %eax
	movl	$2, %edi
	leaq	.LC32(%rip), %rsi
	call	__printf_chk@PLT
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	je	.L39
	call	__stack_chk_fail@PLT
.L39:
	addq	$40, %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
.LFE2029:
	.size	main, .-main
	.section	.rodata.str1.1
.LC33:
	.string	"_Z26matrixMultiplicationKernelPfS_S_i"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2057:
	.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	.LC33(%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
.LFE2057:
	.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
.LC10:
	.long	805306368
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC25:
	.long	2147483647
	.long	0
	.long	0
	.long	0
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC26:
	.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>
__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;
	//debug line:
	//printf("Row:%d, Col:%d. BlockIdx(%d,%d), blockDim(%d,%d) threadIdx(%d,%d)\n\n",Row,Col,blockIdx.x,blockIdx.y,blockDim.x,blockDim.y,threadIdx.x,threadIdx.y);
	if ((Row < Width) && (Col < Width)) {
		float Pvalue = 0;
		// each thread computes one element of the block sub-matrix
		for (int k = 0; k < Width; ++k) {
			Pvalue += M[Row*Width+k]*N[k*Width+Col];
		}
		P[Row*Width+Col] = Pvalue;
	}
	else P[Row*Width+Col] =  99.9;
}

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 = Width;
    int bl = 1;
    dim3 threadsPerBlock(th,th);
    dim3 blocksPerGrid(bl,bl);
    printf("Kernel started: %d blocks, %d threads.\n", bl, 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 = 10;
    	int num_of_elements = matrix_size * matrix_size;
	size_t size = num_of_elements * sizeof(float);
	printf("matrix [%d x %d] multiplication.\n", matrix_size, matrix_size);
    
    //==========================HOST===============================================

	//allocate matrixes (two input ones, one output one):
    //matrix can be represented as a flat vector in the memory - it is so in GPU, 
    //so for simplification of indexation I also use this representation on the host
	printf("Started variables allocation for the host.\n");
	float *M_h = (float *)malloc(size);
	float *N_h = (float *)malloc(size);
	float *P_h = (float *)malloc(size);

	if(M_h == NULL || N_h == NULL || P_h == NULL)
	{
		fprintf(stderr, "Failed to allocate host matrix!\n");
		exit(EXIT_FAILURE);
	}else printf("Allocation on host successful.\n");

	//initialize matrices:
	printf("Started initialization.\n");
	for(int i = 0; i < num_of_elements; i++)
	{
        M_h[i] = rand()/(float)RAND_MAX;
        N_h[i] = rand()/(float)RAND_MAX;
	}
	printf("Initialization fnished.\n");

    //==========================DEVICE==============================================
    
	//allocate matrixes on the device:
	printf("Started variables allocation for the device.\n");
    printf("First matrix.\n");
	float *M_d;
	err = hipMalloc((void**)&M_d,  size);
	if(err != hipSuccess)
	{
		fprintf(stderr, "Failed to allocate host matrix!\n");
		exit(EXIT_FAILURE);
	} else printf("Allocation successful.\n");
    
    printf("Second matrix.\n");
	float *N_d;
	err = hipMalloc((void**)&N_d,  size);
	if(err != hipSuccess)
	{
		fprintf(stderr, "Failed to allocate host matrix!\n");
		exit(EXIT_FAILURE);
	} else printf("Allocation successful.\n");
	
	printf("Third matrix.\n");
	float *P_d;
	err = hipMalloc((void**)&P_d,  size);
	if(err != hipSuccess)
	{
		fprintf(stderr, "Failed to allocate host matrix!\n");
		exit(EXIT_FAILURE);
	} else printf("Allocation successful.\n");

    
    //copy marices into the device:
    printf("Started variables copying into the device.\n");
    printf("First matrix.\n");
	err = hipMemcpy(M_d, M_h, size, hipMemcpyHostToDevice);
	if(err != hipSuccess)
	{
		fprintf(stderr, "Failed to copy first matrix!\n");
		exit(EXIT_FAILURE);
	} else printf("Copying successful.\n");
    
    printf("Second matrix.\n");
	err = hipMemcpy(N_d, N_h, size, hipMemcpyHostToDevice);
	if(err != hipSuccess)
	{
		fprintf(stderr, "Failed to copy second matrix!\n");
		exit(EXIT_FAILURE);
	} else printf("Copying successful.\n");
	
    //calculations:
    matrixMultiplication(M_d, N_d, P_d, matrix_size);
    err = hipGetLastError();
    
    if(err != hipSuccess)
    {
		fprintf(stderr, "Failed to launch kernel. Error: %s.\n", hipGetErrorString(err));
		exit(EXIT_FAILURE);
	} else printf("Kerel operations successful.\n");
    
    printf("Started variables copying from the device.\n");
    err = hipMemcpy(P_h, P_d, size, hipMemcpyDeviceToHost);
	if(err != hipSuccess)
	{
		fprintf(stderr, "Failed to copy result matrix. Error: %s.\n", hipGetErrorString(err));
		exit(EXIT_FAILURE);
	} else printf("Copying successful.\n");
    
    //==========================TEST===============================================
	//PrintMatrix(M_h, matrix_size);
	//PrintMatrix(N_h, matrix_size);
	//PrintMatrix(P_h, 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_h[i*matrix_size + k] * N_h[k*matrix_size + j];
			//debug line:
			//printf("%f ",tmp);
			if(fabs(tmp - P_h[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_h[i*matrix_size + j]);
				exit(EXIT_FAILURE);
			}
		}
    	}

	printf("Test PASSED\n");
    
    // Free device global memory
    err = hipFree(M_d);

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

    err = hipFree(N_d);

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

    err = hipFree(P_d);

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

    
    // Free host memory
    free(M_h);
    free(N_h);
    free(P_h);
    
    printf("Done\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	_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, %eax
	movq	%rax, %r13
	shlq	$32, %r13
	orq	%rax, %r13
	movl	$.L.str, %edi
	movl	$1, %esi
	movl	%ecx, %edx
	xorl	%eax, %eax
	callq	printf
	movabsq	$4294967297, %rdi               # imm = 0x100000001
	movl	$1, %esi
	movq	%r13, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	je	.LBB1_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
.LBB1_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_end1:
	.size	_Z20matrixMultiplicationPfS_S_i, .Lfunc_end1-_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	.LBB2_5
# %bb.1:                                # %.preheader.lr.ph
	movl	%esi, %ebx
	movl	%esi, %r15d
	xorl	%r12d, %r12d
	xorl	%r13d, %r13d
.LBB2_2:                                # %.lr.ph
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB2_3 Depth 2
	movl	%r12d, %eax
	movq	(%rsp), %rcx                    # 8-byte Reload
	leaq	(%rcx,%rax,4), %rbp
	xorl	%r14d, %r14d
.LBB2_3:                                #   Parent Loop BB2_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	.LBB2_3
# %bb.4:                                # %._crit_edge
                                        #   in Loop: Header=BB2_2 Depth=1
	movl	$10, %edi
	callq	putchar@PLT
	incq	%r13
	addl	%ebx, %r12d
	cmpq	%r15, %r13
	jne	.LBB2_2
.LBB2_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_end2:
	.size	_Z11PrintMatrixPfi, .Lfunc_end2-_Z11PrintMatrixPfi
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function main
.LCPI3_0:
	.long	0x30000000                      # float 4.65661287E-10
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0
.LCPI3_1:
	.long	0x7fffffff                      # float NaN
	.long	0x7fffffff                      # float NaN
	.long	0x7fffffff                      # float NaN
	.long	0x7fffffff                      # float NaN
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0
.LCPI3_2:
	.quad	0x3f50624dd2f1a9fc              # double 0.001
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r12
	.cfi_def_cfa_offset 32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	subq	$24, %rsp
	.cfi_def_cfa_offset 64
	.cfi_offset %rbx, -40
	.cfi_offset %r12, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movl	$.Lstr, %edi
	callq	puts@PLT
	movl	$.L.str.4, %edi
	movl	$10, %esi
	movl	$10, %edx
	xorl	%eax, %eax
	callq	printf
	movl	$.Lstr.1, %edi
	callq	puts@PLT
	movl	$400, %edi                      # imm = 0x190
	callq	malloc
	movq	%rax, %rbx
	movl	$400, %edi                      # imm = 0x190
	callq	malloc
	movq	%rax, %r14
	movl	$400, %edi                      # imm = 0x190
	callq	malloc
	testq	%rbx, %rbx
	je	.LBB3_24
# %bb.1:
	testq	%r14, %r14
	je	.LBB3_24
# %bb.2:
	movq	%rax, %r15
	testq	%rax, %rax
	je	.LBB3_24
# %bb.3:
	movl	$.Lstr.2, %edi
	callq	puts@PLT
	movl	$.Lstr.3, %edi
	callq	puts@PLT
	xorl	%r12d, %r12d
.LBB3_4:                                # =>This Inner Loop Header: Depth=1
	callq	rand
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	movss	.LCPI3_0(%rip), %xmm1           # xmm1 = mem[0],zero,zero,zero
	mulss	%xmm1, %xmm0
	movss	%xmm0, (%rbx,%r12,4)
	callq	rand
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	mulss	.LCPI3_0(%rip), %xmm0
	movss	%xmm0, (%r14,%r12,4)
	incq	%r12
	cmpq	$100, %r12
	jne	.LBB3_4
# %bb.5:
	movl	$.Lstr.4, %edi
	callq	puts@PLT
	movl	$.Lstr.5, %edi
	callq	puts@PLT
	movl	$.Lstr.13, %edi
	callq	puts@PLT
	leaq	16(%rsp), %rdi
	movl	$400, %esi                      # imm = 0x190
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB3_24
# %bb.6:
	movl	$.Lstr.11, %edi
	callq	puts@PLT
	movl	$.Lstr.15, %edi
	callq	puts@PLT
	leaq	8(%rsp), %rdi
	movl	$400, %esi                      # imm = 0x190
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB3_24
# %bb.7:
	movl	$.Lstr.11, %edi
	callq	puts@PLT
	movl	$.Lstr.10, %edi
	callq	puts@PLT
	movq	%rsp, %rdi
	movl	$400, %esi                      # imm = 0x190
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB3_24
# %bb.8:
	movl	$.Lstr.11, %edi
	callq	puts@PLT
	movl	$.Lstr.12, %edi
	callq	puts@PLT
	movl	$.Lstr.13, %edi
	callq	puts@PLT
	movq	16(%rsp), %rdi
	movl	$400, %edx                      # imm = 0x190
	movq	%rbx, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB3_27
# %bb.9:
	movl	$.Lstr.19, %edi
	callq	puts@PLT
	movl	$.Lstr.15, %edi
	callq	puts@PLT
	movq	8(%rsp), %rdi
	movl	$400, %edx                      # imm = 0x190
	movq	%r14, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB3_28
# %bb.10:
	movl	$.Lstr.19, %edi
	callq	puts@PLT
	movq	16(%rsp), %rdi
	movq	8(%rsp), %rsi
	movq	(%rsp), %rdx
	movl	$10, %ecx
	callq	_Z20matrixMultiplicationPfS_S_i
	callq	hipGetLastError
	testl	%eax, %eax
	jne	.LBB3_29
# %bb.11:
	movl	$.Lstr.17, %edi
	callq	puts@PLT
	movl	$.Lstr.18, %edi
	callq	puts@PLT
	movq	(%rsp), %rsi
	movl	$400, %edx                      # imm = 0x190
	movq	%r15, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB3_30
# %bb.12:
	movl	$.Lstr.19, %edi
	callq	puts@PLT
	xorl	%edx, %edx
	movaps	.LCPI3_1(%rip), %xmm0           # xmm0 = [NaN,NaN,NaN,NaN]
	movsd	.LCPI3_2(%rip), %xmm1           # xmm1 = mem[0],zero
	movq	%rbx, %rax
.LBB3_13:                               # %.preheader121
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB3_14 Depth 2
                                        #       Child Loop BB3_15 Depth 3
	leaq	(%rdx,%rdx,4), %rcx
	leaq	(%r15,%rcx,8), %rsi
	movq	%r14, %rdi
	xorl	%ecx, %ecx
.LBB3_14:                               # %.preheader
                                        #   Parent Loop BB3_13 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB3_15 Depth 3
	xorps	%xmm2, %xmm2
	movq	%rdi, %r8
	xorl	%r9d, %r9d
.LBB3_15:                               #   Parent Loop BB3_13 Depth=1
                                        #     Parent Loop BB3_14 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	movss	(%rax,%r9,4), %xmm3             # xmm3 = mem[0],zero,zero,zero
	mulss	(%r8), %xmm3
	addss	%xmm3, %xmm2
	incq	%r9
	addq	$40, %r8
	cmpq	$10, %r9
	jne	.LBB3_15
# %bb.16:                               #   in Loop: Header=BB3_14 Depth=2
	movss	(%rsi,%rcx,4), %xmm3            # xmm3 = mem[0],zero,zero,zero
	movaps	%xmm2, %xmm4
	subss	%xmm3, %xmm4
	andps	%xmm0, %xmm4
	cvtss2sd	%xmm4, %xmm4
	ucomisd	%xmm1, %xmm4
	ja	.LBB3_23
# %bb.17:                               #   in Loop: Header=BB3_14 Depth=2
	incq	%rcx
	addq	$4, %rdi
	cmpq	$10, %rcx
	jne	.LBB3_14
# %bb.18:                               #   in Loop: Header=BB3_13 Depth=1
	incq	%rdx
	addq	$40, %rax
	cmpq	$10, %rdx
	jne	.LBB3_13
# %bb.19:
	movl	$.Lstr.20, %edi
	callq	puts@PLT
	movq	16(%rsp), %rdi
	callq	hipFree
	testl	%eax, %eax
	jne	.LBB3_31
# %bb.20:
	movq	8(%rsp), %rdi
	callq	hipFree
	testl	%eax, %eax
	jne	.LBB3_32
# %bb.21:
	movq	(%rsp), %rdi
	callq	hipFree
	testl	%eax, %eax
	jne	.LBB3_33
# %bb.22:
	movq	%rbx, %rdi
	callq	free
	movq	%r14, %rdi
	callq	free
	movq	%r15, %rdi
	callq	free
	movl	$.Lstr.21, %edi
	callq	puts@PLT
	xorl	%eax, %eax
	addq	$24, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.LBB3_23:
	.cfi_def_cfa_offset 64
	movq	stderr(%rip), %rdi
	xorps	%xmm0, %xmm0
	cvtss2sd	%xmm2, %xmm0
	xorps	%xmm1, %xmm1
	cvtss2sd	%xmm3, %xmm1
	movl	$.L.str.23, %esi
                                        # kill: def $edx killed $edx killed $rdx
                                        # kill: def $ecx killed $ecx killed $rcx
	movb	$2, %al
	callq	fprintf
.LBB3_26:
	movl	$1, %edi
	callq	exit
.LBB3_24:
	movq	stderr(%rip), %rcx
	movl	$.L.str.6, %edi
	movl	$32, %esi
.LBB3_25:
	movl	$1, %edx
	callq	fwrite@PLT
	jmp	.LBB3_26
.LBB3_27:
	movq	stderr(%rip), %rcx
	movl	$.L.str.16, %edi
	movl	$29, %esi
	jmp	.LBB3_25
.LBB3_28:
	movq	stderr(%rip), %rcx
	movl	$.L.str.18, %edi
	movl	$30, %esi
	jmp	.LBB3_25
.LBB3_29:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.19, %esi
	jmp	.LBB3_34
.LBB3_30:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.22, %esi
	jmp	.LBB3_34
.LBB3_31:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.25, %esi
	jmp	.LBB3_34
.LBB3_32:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.26, %esi
	jmp	.LBB3_34
.LBB3_33:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.27, %esi
.LBB3_34:
	movq	%rbx, %rdi
	movq	%rax, %rdx
	xorl	%eax, %eax
	callq	fprintf
	jmp	.LBB3_26
.Lfunc_end3:
	.size	main, .Lfunc_end3-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	.LBB4_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB4_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_end4:
	.size	__hip_module_ctor, .Lfunc_end4-__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	.LBB5_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
.LBB5_2:
	retq
.Lfunc_end5:
	.size	__hip_module_dtor, .Lfunc_end5-__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 blocks, %d threads.\n"
	.size	.L.str, 40

	.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	"matrix [%d x %d] multiplication.\n"
	.size	.L.str.4, 34

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"Failed to allocate host matrix!\n"
	.size	.L.str.6, 33

	.type	.L.str.16,@object               # @.str.16
.L.str.16:
	.asciz	"Failed to copy first matrix!\n"
	.size	.L.str.16, 30

	.type	.L.str.18,@object               # @.str.18
.L.str.18:
	.asciz	"Failed to copy second matrix!\n"
	.size	.L.str.18, 31

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

	.type	.L.str.22,@object               # @.str.22
.L.str.22:
	.asciz	"Failed to copy result matrix. Error: %s.\n"
	.size	.L.str.22, 42

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

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

	.type	.L.str.26,@object               # @.str.26
.L.str.26:
	.asciz	"Failed to free device matrix N (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 P (error code %s)!\n"
	.size	.L.str.27, 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	"Started variables allocation for the host."
	.size	.Lstr.1, 43

	.type	.Lstr.2,@object                 # @str.2
.Lstr.2:
	.asciz	"Allocation on host successful."
	.size	.Lstr.2, 31

	.type	.Lstr.3,@object                 # @str.3
.Lstr.3:
	.asciz	"Started initialization."
	.size	.Lstr.3, 24

	.type	.Lstr.4,@object                 # @str.4
.Lstr.4:
	.asciz	"Initialization fnished."
	.size	.Lstr.4, 24

	.type	.Lstr.5,@object                 # @str.5
.Lstr.5:
	.asciz	"Started variables allocation for the device."
	.size	.Lstr.5, 45

	.type	.Lstr.10,@object                # @str.10
.Lstr.10:
	.asciz	"Third matrix."
	.size	.Lstr.10, 14

	.type	.Lstr.11,@object                # @str.11
.Lstr.11:
	.asciz	"Allocation successful."
	.size	.Lstr.11, 23

	.type	.Lstr.12,@object                # @str.12
.Lstr.12:
	.asciz	"Started variables copying into the device."
	.size	.Lstr.12, 43

	.type	.Lstr.13,@object                # @str.13
.Lstr.13:
	.asciz	"First matrix."
	.size	.Lstr.13, 14

	.type	.Lstr.15,@object                # @str.15
.Lstr.15:
	.asciz	"Second matrix."
	.size	.Lstr.15, 15

	.type	.Lstr.17,@object                # @str.17
.Lstr.17:
	.asciz	"Kerel operations successful."
	.size	.Lstr.17, 29

	.type	.Lstr.18,@object                # @str.18
.Lstr.18:
	.asciz	"Started variables copying from the device."
	.size	.Lstr.18, 43

	.type	.Lstr.19,@object                # @str.19
.Lstr.19:
	.asciz	"Copying successful."
	.size	.Lstr.19, 20

	.type	.Lstr.20,@object                # @str.20
.Lstr.20:
	.asciz	"Test PASSED"
	.size	.Lstr.20, 12

	.type	.Lstr.21,@object                # @str.21
.Lstr.21:
	.asciz	"Done"
	.size	.Lstr.21, 5

	.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 s3, s[0:1], 0x2c
	s_load_b32 s2, s[0:1], 0x18
	s_load_b128 s[4:7], s[0:1], 0x0
	s_load_b64 s[0:1], s[0:1], 0x10
	v_bfe_u32 v1, v0, 10, 10
	v_and_b32_e32 v4, 0x3ff, v0
	s_waitcnt lgkmcnt(0)
	s_lshr_b32 s8, s3, 16
	s_and_b32 s3, s3, 0xffff
	v_mad_u64_u32 v[2:3], null, s15, s8, v[1:2]
	v_mad_u64_u32 v[0:1], null, s14, s3, v[4:5]
                                        ; implicit-def: $sgpr8
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_mul_lo_u32 v1, v2, s2
	v_max_i32_e32 v3, v2, v0
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(SALU_CYCLE_1)
	v_cmp_le_i32_e32 vcc_lo, s2, v3
	v_mov_b32_e32 v3, v0
	s_and_saveexec_b32 s3, vcc_lo
	s_xor_b32 s3, exec_lo, s3
; %bb.1:
	v_mul_lo_u32 v1, v2, s2
	s_mov_b32 s8, 0x42c7cccd
                                        ; implicit-def: $vgpr3
; %bb.2:                                ; %Flow55
	s_or_saveexec_b32 s3, s3
	v_mov_b32_e32 v2, s8
	s_xor_b32 exec_lo, exec_lo, s3
	s_cbranch_execz .LBB0_7
; %bb.3:                                ; %.preheader
	s_cmp_lt_i32 s2, 1
	s_cbranch_scc1 .LBB0_6
; %bb.4:                                ; %.lr.ph.preheader
	v_ashrrev_i32_e32 v2, 31, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_lshlrev_b64 v[5:6], 2, v[1:2]
	v_mov_b32_e32 v2, 0
	v_add_co_u32 v5, vcc_lo, s4, v5
	s_delay_alu instid0(VALU_DEP_3)
	v_add_co_ci_u32_e32 v6, vcc_lo, s5, v6, vcc_lo
	s_mov_b32 s4, s2
.LBB0_5:                                ; %.lr.ph
                                        ; =>This Inner Loop Header: Depth=1
	v_ashrrev_i32_e32 v4, 31, v3
	s_add_i32 s4, s4, -1
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	s_cmp_eq_u32 s4, 0
	v_lshlrev_b64 v[7:8], 2, v[3:4]
	v_add_nc_u32_e32 v3, s2, v3
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_co_u32 v7, vcc_lo, s6, v7
	v_add_co_ci_u32_e32 v8, vcc_lo, s7, v8, vcc_lo
	global_load_b32 v4, v[5:6], off
	global_load_b32 v7, v[7:8], off
	v_add_co_u32 v5, vcc_lo, v5, 4
	v_add_co_ci_u32_e32 v6, vcc_lo, 0, v6, vcc_lo
	s_waitcnt vmcnt(0)
	v_fmac_f32_e32 v2, v4, v7
	s_cbranch_scc0 .LBB0_5
	s_branch .LBB0_7
.LBB0_6:
	v_mov_b32_e32 v2, 0
.LBB0_7:                                ; %._crit_edge
	s_or_b32 exec_lo, exec_lo, s3
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_nc_u32_e32 v0, v1, v0
	v_ashrrev_i32_e32 v1, 31, v0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[0:1], 2, v[0:1]
	v_add_co_u32 v0, vcc_lo, s0, v0
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v1, vcc_lo, s1, v1, vcc_lo
	global_store_b32 v[0:1], v2, off
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z26matrixMultiplicationKernelPfS_S_i
		.amdhsa_group_segment_fixed_size 0
		.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 9
		.amdhsa_next_free_sgpr 16
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end0:
	.size	_Z26matrixMultiplicationKernelPfS_S_i, .Lfunc_end0-_Z26matrixMultiplicationKernelPfS_S_i
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 356
; NumSgprs: 18
; NumVgprs: 9
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 9
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 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: 0
    .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:     9
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
