/*
CSC691 GPU programming
Project 2: In the Interest of Time
Naive GPU version
Jiajie Xiao
Oct 8, 2017
*/

#include <stdio.h> 
#include <stdlib.h>
#include <time.h>

void gen_flattened_array(float *array, int rowSize, int colSize)
{
    int i, j;
	time_t t;
	/* Intializes random number generator */
   	srand((unsigned) time(&t));
   	for (i=0;i<rowSize;i++)
   	{
   		for (j=0;j<colSize;j++)
   		{
   			array[i*colSize+j]=1.0*rand()/RAND_MAX;
   		}
   	}
}

void output_array(float *array, int rowSize, int colSize)
{
    int i, j;
    printf("%s\t%s\t%s\n", "RowID", "ColID", "Value");
    for (i=0; i<rowSize; i++)
    {
    	for (j=0;j<colSize;j++)
    	{
    		 printf("%d\t%d\t%f\n", i, j, array[i*colSize+j]);
    	}
    }
}

void save_array(float *array, int rowSize, int colSize, FILE *fp)
{
    int i, j;
    for (i=0; i<rowSize; i++)
    {
        for (j=0;j<colSize;j++)
        {
            fprintf(fp, "%d\t%d\t%f\n", i, j, array[i*colSize+j]);
        }
    }
}

__global__ void compute_matixMult(float *a, float *b, float *c, int rowSize_a, int colSize_a, int colSize_b) // colSize_a should be equal to rowSize_b
{
    int k;
    float sum = 0.0;
    int col = threadIdx.x + blockDim.x * blockIdx.x;
    int row = threadIdx.y + blockDim.y * blockIdx.y;

	if (col < rowSize_a && row < colSize_b)
    {
        for (k = 0; k < colSize_a; k++)
        {
            sum += a[row*colSize_a+k]*b[k*colSize_b+col];
        }
        c[row*colSize_b+col] = sum;
    }
}

int main(int argc, char **argv)
{
    int rowSize_A, colSize_A, rowSize_B, colSize_B, rowSize_C, colSize_C;

    if (argc < 2)
    {
        printf("At least one varaible for matrix dimensions is required.");
        return -1;
    }
    else if (argc == 2)
    {	
    	rowSize_A = atoi(argv[1]);
    	colSize_A = atoi(argv[1]);
    	rowSize_B = atoi(argv[1]);
    	colSize_B = atoi(argv[1]);
    	printf("Two random %dX%d matrices are going to be generated for the multiplication.\n", rowSize_A, colSize_A);
    }
    else
    {    	
    	rowSize_A = atoi(argv[1]);
    	colSize_A = atoi(argv[2]);
    	rowSize_B = atoi(argv[3]);
    	colSize_B = atoi(argv[4]);

    	if (colSize_A == rowSize_B)
    		printf("A random %dX%d matrix A and %dX%d matrix B are going to be generated for the multiplication.\n", rowSize_A, colSize_A, rowSize_B, colSize_B);
    	else
    	{
    		printf("Error input: the number of columns of the first matrix should be equal to the number of rows of te second matrix");
    		return -1;
    	}
    }

    /* Generated two random matrices for multiplication */
    rowSize_C = rowSize_A; 
    colSize_C = colSize_B;
    float matrix_A[rowSize_A*colSize_A], matrix_B[rowSize_B*colSize_B], matrix_C[rowSize_C*colSize_C]; 
    gen_flattened_array(matrix_A, rowSize_A, colSize_A);
    gen_flattened_array(matrix_B, rowSize_B, colSize_B);

    /* Malloc memory for device variables */
    float *dev_matrix_A, *dev_matrix_B, *dev_matrix_C; 
    cudaMalloc((void **) & dev_matrix_A, rowSize_A*colSize_A*sizeof(float));
    cudaMalloc((void **) & dev_matrix_B, rowSize_B*colSize_B*sizeof(float));
    cudaMalloc((void **) & dev_matrix_C, rowSize_C*colSize_C*sizeof(float));

    /* Computate the multiplication */
    dim3 dimGrid(1,1);
    dim3 dimBlock(colSize_A, colSize_A);

    compute_matixMult<<<dimGrid, dimBlock>>>(matrix_A, matrix_B, matrix_C, rowSize_A, colSize_B, rowSize_B);
    cudaThreadSynchronize();

    clock_t start, stop;
    start = clock();
    compute_matixMult<<<dimGrid, dimBlock>>>(matrix_A, matrix_B, matrix_C, rowSize_A, colSize_B, rowSize_B);
    cudaThreadSynchronize();
    stop = clock();

    /* transfer data from Device to Host and free device memory */
    cudaMemcpy(matrix_C, dev_matrix_C, rowSize_C*colSize_C*sizeof(float), cudaMemcpyDeviceToHost);
    cudaFree(dev_matrix_A);
    cudaFree(dev_matrix_B);
    cudaFree(dev_matrix_C);

    float time = (stop-start)/(float)CLOCKS_PER_SEC;
    printf("The product is computed.\n Execution time is %f seconds\n", time);

    /* Output */
    //printf("Matrix A\n");
    //output_array(matrix_A, rowSize_A, colSize_A);
    //printf("Matrix B\n");
    //output_array(matrix_B, rowSize_B, colSize_B);
    //printf("Product Matrix C\n");    
    //output_array(matrix_C, rowSize_A, colSize_B);

    FILE *file_product, *file_time;
    file_product = fopen("product.txt", "w");
    if (file_product == NULL)
        printf("Error open file to save the product matrix");
    else
    {
        save_array(matrix_C, rowSize_A, colSize_B, file_product);
        fclose(file_product);
    }


    file_time = fopen("time.txt", "a");
    if (file_time == NULL)
        printf("Error open file to save the product matrix");
    else
    {
        fprintf(file_time, "%d\t%f\n", colSize_A, time);
        fclose(file_time);
    }

    return 1;

}

	.file	"tmpxft_002b1366_00000000-6_MatrixMultNaive.bk.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	_Z19gen_flattened_arrayPfii
	.type	_Z19gen_flattened_arrayPfii, @function
_Z19gen_flattened_arrayPfii:
.LFB2027:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	xorl	%r15d, %r15d
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	xorl	%r14d, %r14d
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movl	%esi, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%rdi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movl	%edx, %ebx
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	16(%rsp), %rdi
	call	time@PLT
	movl	%eax, %edi
	call	srand@PLT
.L3:
	cmpl	%r12d, %r15d
	jge	.L2
	movslq	%r14d, %rax
	xorl	%r13d, %r13d
	leaq	0(%rbp,%rax,4), %rdx
.L6:
	cmpl	%r13d, %ebx
	jle	.L10
	movq	%rdx, 8(%rsp)
	call	rand@PLT
	movq	8(%rsp), %rdx
	cvtsi2sdl	%eax, %xmm0
	divsd	.LC0(%rip), %xmm0
	cvtsd2ss	%xmm0, %xmm0
	movss	%xmm0, (%rdx,%r13,4)
	incq	%r13
	jmp	.L6
.L10:
	incl	%r15d
	addl	%ebx, %r14d
	jmp	.L3
.L2:
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	je	.L7
	call	__stack_chk_fail@PLT
.L7:
	addq	$40, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2027:
	.size	_Z19gen_flattened_arrayPfii, .-_Z19gen_flattened_arrayPfii
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC1:
	.string	"Value"
.LC2:
	.string	"ColID"
.LC3:
	.string	"RowID"
.LC4:
	.string	"%s\t%s\t%s\n"
.LC5:
	.string	"%d\t%d\t%f\n"
	.text
	.globl	_Z12output_arrayPfii
	.type	_Z12output_arrayPfii, @function
_Z12output_arrayPfii:
.LFB2028:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	.LC1(%rip), %r8
	leaq	.LC2(%rip), %rcx
	xorl	%eax, %eax
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movl	%esi, %r14d
	leaq	.LC4(%rip), %rsi
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%rdi, %r13
	movl	$2, %edi
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movl	%edx, %r12d
	leaq	.LC3(%rip), %rdx
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	xorl	%ebp, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	call	__printf_chk@PLT
	xorl	%r8d, %r8d
.L12:
	cmpl	%r14d, %ebp
	jge	.L11
	movslq	%r8d, %rax
	xorl	%ebx, %ebx
	leaq	0(%r13,%rax,4), %r15
.L15:
	movl	%ebx, %ecx
	cmpl	%ebx, %r12d
	jle	.L17
	movl	%ebp, %edx
	leaq	.LC5(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	movl	%r8d, 12(%rsp)
	cvtss2sd	(%r15,%rbx,4), %xmm0
	incq	%rbx
	call	__printf_chk@PLT
	movl	12(%rsp), %r8d
	jmp	.L15
.L17:
	incl	%ebp
	addl	%r12d, %r8d
	jmp	.L12
.L11:
	addq	$24, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2028:
	.size	_Z12output_arrayPfii, .-_Z12output_arrayPfii
	.globl	_Z10save_arrayPfiiP8_IO_FILE
	.type	_Z10save_arrayPfiiP8_IO_FILE, @function
_Z10save_arrayPfiiP8_IO_FILE:
.LFB2029:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	%esi, %r10d
	xorl	%r15d, %r15d
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%rdi, %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movl	%edx, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	xorl	%ebp, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	movq	%rcx, (%rsp)
.L19:
	cmpl	%r10d, %ebp
	jge	.L18
	movslq	%r15d, %rax
	xorl	%ebx, %ebx
	leaq	0(%r13,%rax,4), %r14
.L22:
	cmpl	%ebx, %r12d
	jle	.L24
	movq	(%rsp), %rdi
	movl	%ebx, %r8d
	movl	%ebp, %ecx
	leaq	.LC5(%rip), %rdx
	movl	$2, %esi
	movb	$1, %al
	movl	%r10d, 12(%rsp)
	cvtss2sd	(%r14,%rbx,4), %xmm0
	call	__fprintf_chk@PLT
	incq	%rbx
	movl	12(%rsp), %r10d
	jmp	.L22
.L24:
	incl	%ebp
	addl	%r12d, %r15d
	jmp	.L19
.L18:
	addq	$24, %rsp
	.cfi_def_cfa_offset 56
	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	_Z10save_arrayPfiiP8_IO_FILE, .-_Z10save_arrayPfiiP8_IO_FILE
	.globl	_Z44__device_stub__Z17compute_matixMultPfS_S_iiiPfS_S_iii
	.type	_Z44__device_stub__Z17compute_matixMultPfS_S_iiiPfS_S_iii, @function
_Z44__device_stub__Z17compute_matixMultPfS_S_iiiPfS_S_iii:
.LFB2055:
	.cfi_startproc
	endbr64
	subq	$184, %rsp
	.cfi_def_cfa_offset 192
	movq	%rdi, 40(%rsp)
	leaq	72(%rsp), %rdi
	movq	%rsi, 32(%rsp)
	leaq	84(%rsp), %rsi
	movq	%rdx, 24(%rsp)
	leaq	56(%rsp), %rdx
	movl	%ecx, 20(%rsp)
	leaq	64(%rsp), %rcx
	movl	%r8d, 16(%rsp)
	movl	%r9d, 12(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 168(%rsp)
	xorl	%eax, %eax
	leaq	40(%rsp), %rax
	movl	$1, 80(%rsp)
	movq	%rax, 120(%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 128(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 136(%rsp)
	leaq	20(%rsp), %rax
	movq	%rax, 144(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 152(%rsp)
	leaq	12(%rsp), %rax
	movq	%rax, 160(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 72(%rsp)
	movq	%rax, 84(%rsp)
	movl	$1, 92(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L25
	pushq	64(%rsp)
	.cfi_def_cfa_offset 200
	leaq	_Z17compute_matixMultPfS_S_iii(%rip), %rdi
	pushq	64(%rsp)
	.cfi_def_cfa_offset 208
	movq	100(%rsp), %rcx
	movl	108(%rsp), %r8d
	movq	88(%rsp), %rsi
	movl	96(%rsp), %edx
	leaq	136(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 200
	popq	%rdx
	.cfi_def_cfa_offset 192
.L25:
	movq	168(%rsp), %rax
	subq	%fs:40, %rax
	je	.L27
	call	__stack_chk_fail@PLT
.L27:
	addq	$184, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2055:
	.size	_Z44__device_stub__Z17compute_matixMultPfS_S_iiiPfS_S_iii, .-_Z44__device_stub__Z17compute_matixMultPfS_S_iiiPfS_S_iii
	.globl	_Z17compute_matixMultPfS_S_iii
	.type	_Z17compute_matixMultPfS_S_iii, @function
_Z17compute_matixMultPfS_S_iii:
.LFB2056:
	.cfi_startproc
	endbr64
	jmp	_Z44__device_stub__Z17compute_matixMultPfS_S_iiiPfS_S_iii
	.cfi_endproc
.LFE2056:
	.size	_Z17compute_matixMultPfS_S_iii, .-_Z17compute_matixMultPfS_S_iii
	.section	.rodata.str1.1
.LC6:
	.string	"At least one varaible for matrix dimensions is required."
.LC7:
	.string	"Two random %dX%d matrices are going to be generated for the multiplication.\n"
.LC8:
	.string	"A random %dX%d matrix A and %dX%d matrix B are going to be generated for the multiplication.\n"
.LC9:
	.string	"Error input: the number of columns of the first matrix should be equal to the number of rows of te second matrix"
.LC11:
	.string	"The product is computed.\n Execution time is %f seconds\n"
.LC12:
	.string	"w"
.LC13:
	.string	"product.txt"
.LC14:
	.string	"Error open file to save the product matrix"
.LC15:
	.string	"a"
.LC16:
	.string	"time.txt"
.LC17:
	.string	"%d\t%f\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2030:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$120, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	cmpl	$1, %edi
	jg	.L31
	leaq	.LC6(%rip), %rsi
	movl	$2, %edi
	jmp	.L63
.L31:
	movl	%edi, %r12d
	movq	8(%rsi), %rdi
	movq	%rsi, %r13
	call	atoi@PLT
	movl	%eax, %ebx
	cmpl	$2, %r12d
	jne	.L33
	movl	%eax, %ecx
	movl	%eax, %edx
	leaq	.LC7(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	movl	%ebx, %r13d
	movl	%ebx, %r14d
	movl	%ebx, %r12d
	call	__printf_chk@PLT
	jmp	.L34
.L33:
	movq	16(%r13), %rdi
	call	atoi@PLT
	movq	24(%r13), %rdi
	movl	%eax, %r12d
	call	atoi@PLT
	movq	32(%r13), %rdi
	movl	%eax, %r14d
	call	atoi@PLT
	movl	%eax, %r13d
	cmpl	%r14d, %r12d
	jne	.L35
	movl	%eax, %r9d
	movl	%r12d, %r8d
	movl	%r12d, %ecx
	movl	%ebx, %edx
	leaq	.LC8(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L34
.L35:
	leaq	.LC9(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
.L63:
	call	__printf_chk@PLT
	orl	$-1, %eax
	jmp	.L30
.L34:
	movl	%r12d, %r15d
	movq	%rsp, %rcx
	imull	%ebx, %r15d
	movslq	%r15d, %r15
	salq	$2, %r15
	leaq	15(%r15), %rdx
	movq	%rdx, %rax
	andq	$-4096, %rdx
	andq	$-16, %rax
	subq	%rdx, %rcx
.L37:
	cmpq	%rcx, %rsp
	je	.L38
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L37
.L38:
	andl	$4095, %eax
	subq	%rax, %rsp
	testq	%rax, %rax
	je	.L39
	orq	$0, -8(%rsp,%rax)
.L39:
	movl	%r14d, %eax
	movq	%rsp, -136(%rbp)
	movq	%rsp, %rcx
	imull	%r13d, %eax
	cltq
	salq	$2, %rax
	leaq	15(%rax), %rdx
	movq	%rax, -152(%rbp)
	movq	%rdx, %rax
	andq	$-4096, %rdx
	andq	$-16, %rax
	subq	%rdx, %rcx
.L40:
	cmpq	%rcx, %rsp
	je	.L41
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L40
.L41:
	andl	$4095, %eax
	subq	%rax, %rsp
	testq	%rax, %rax
	je	.L42
	orq	$0, -8(%rsp,%rax)
.L42:
	movl	%r13d, %eax
	movq	%rsp, -144(%rbp)
	movq	%rsp, %rcx
	imull	%ebx, %eax
	cltq
	salq	$2, %rax
	leaq	15(%rax), %rdx
	movq	%rax, -128(%rbp)
	movq	%rdx, %rax
	andq	$-4096, %rdx
	andq	$-16, %rax
	subq	%rdx, %rcx
.L43:
	cmpq	%rcx, %rsp
	je	.L44
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L43
.L44:
	andl	$4095, %eax
	subq	%rax, %rsp
	testq	%rax, %rax
	je	.L45
	orq	$0, -8(%rsp,%rax)
.L45:
	movq	-136(%rbp), %rdi
	movl	%r12d, %edx
	movl	%ebx, %esi
	movq	%rsp, -120(%rbp)
	call	_Z19gen_flattened_arrayPfii
	movq	-144(%rbp), %rdi
	movl	%r13d, %edx
	movl	%r14d, %esi
	call	_Z19gen_flattened_arrayPfii
	leaq	-104(%rbp), %rdi
	movq	%r15, %rsi
	call	cudaMalloc@PLT
	movq	-152(%rbp), %rsi
	leaq	-96(%rbp), %rdi
	call	cudaMalloc@PLT
	movq	-128(%rbp), %rsi
	leaq	-88(%rbp), %rdi
	call	cudaMalloc@PLT
	movl	%r12d, -68(%rbp)
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	%r12d, -64(%rbp)
	movq	-68(%rbp), %rdx
	movl	$1, %ecx
	movabsq	$4294967297, %rdi
	movl	$1, %esi
	movq	%rdi, -80(%rbp)
	movl	$1, -72(%rbp)
	movl	$1, -60(%rbp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L46
	movq	-120(%rbp), %rdx
	movq	-144(%rbp), %rsi
	movl	%r14d, %r9d
	movl	%ebx, %ecx
	movq	-136(%rbp), %rdi
	movl	%r13d, %r8d
	call	_Z44__device_stub__Z17compute_matixMultPfS_S_iiiPfS_S_iii
.L46:
	call	cudaThreadSynchronize@PLT
	call	clock@PLT
	movl	-60(%rbp), %ecx
	movq	-68(%rbp), %rdx
	xorl	%r9d, %r9d
	movq	-80(%rbp), %rdi
	movl	-72(%rbp), %esi
	xorl	%r8d, %r8d
	movq	%rax, %r15
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L47
	movq	-120(%rbp), %rdx
	movq	-144(%rbp), %rsi
	movl	%r14d, %r9d
	movl	%ebx, %ecx
	movq	-136(%rbp), %rdi
	movl	%r13d, %r8d
	call	_Z44__device_stub__Z17compute_matixMultPfS_S_iiiPfS_S_iii
.L47:
	call	cudaThreadSynchronize@PLT
	call	clock@PLT
	movq	-128(%rbp), %rdx
	movq	-88(%rbp), %rsi
	movl	$2, %ecx
	movq	-120(%rbp), %rdi
	movq	%rax, %r14
	subq	%r15, %r14
	call	cudaMemcpy@PLT
	movq	-104(%rbp), %rdi
	call	cudaFree@PLT
	movq	-96(%rbp), %rdi
	call	cudaFree@PLT
	movq	-88(%rbp), %rdi
	call	cudaFree@PLT
	cvtsi2ssq	%r14, %xmm0
	leaq	.LC11(%rip), %rsi
	movb	$1, %al
	divss	.LC10(%rip), %xmm0
	movl	$2, %edi
	cvtss2sd	%xmm0, %xmm1
	movaps	%xmm1, %xmm0
	movq	%xmm1, %r14
	call	__printf_chk@PLT
	leaq	.LC12(%rip), %rsi
	leaq	.LC13(%rip), %rdi
	call	fopen@PLT
	movq	%rax, %r15
	testq	%rax, %rax
	jne	.L48
	leaq	.LC14(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L49
.L48:
	movq	-120(%rbp), %rdi
	movq	%rax, %rcx
	movl	%r13d, %edx
	movl	%ebx, %esi
	call	_Z10save_arrayPfiiP8_IO_FILE
	movq	%r15, %rdi
	call	fclose@PLT
.L49:
	leaq	.LC15(%rip), %rsi
	leaq	.LC16(%rip), %rdi
	call	fopen@PLT
	movq	%rax, %rbx
	testq	%rax, %rax
	jne	.L50
	leaq	.LC14(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L51:
	movl	$1, %eax
	jmp	.L30
.L50:
	movq	%rax, %rdi
	movq	%r14, %xmm0
	movl	%r12d, %ecx
	movl	$2, %esi
	leaq	.LC17(%rip), %rdx
	movb	$1, %al
	call	__fprintf_chk@PLT
	movq	%rbx, %rdi
	call	fclose@PLT
	jmp	.L51
.L30:
	movq	-56(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L52
	call	__stack_chk_fail@PLT
.L52:
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2030:
	.size	main, .-main
	.section	.rodata.str1.1
.LC18:
	.string	"_Z17compute_matixMultPfS_S_iii"
	.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	.LC18(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z17compute_matixMultPfS_S_iii(%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.cst8,"aM",@progbits,8
	.align 8
.LC0:
	.long	-4194304
	.long	1105199103
	.section	.rodata.cst4,"aM",@progbits,4
	.align 4
.LC10:
	.long	1232348160
	.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:

/*
CSC691 GPU programming
Project 2: In the Interest of Time
Naive GPU version
Jiajie Xiao
Oct 8, 2017
*/


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

void gen_flattened_array(float *array, int rowSize, int colSize)
{
    int i, j;
	time_t t;
	/* Intializes random number generator */
   	srand((unsigned) time(&t));
   	for (i=0;i<rowSize;i++)
   	{
   		for (j=0;j<colSize;j++)
   		{
   			array[i*colSize+j]=1.0*rand()/RAND_MAX;
   		}
   	}
}

void output_array(float *array, int rowSize, int colSize)
{
    int i, j;
    printf("%s\t%s\t%s\n", "RowID", "ColID", "Value");
    for (i=0; i<rowSize; i++)
    {
    	for (j=0;j<colSize;j++)
    	{
    		 printf("%d\t%d\t%f\n", i, j, array[i*colSize+j]);
    	}
    }
}

void save_array(float *array, int rowSize, int colSize, FILE *fp)
{
    int i, j;
    for (i=0; i<rowSize; i++)
    {
        for (j=0;j<colSize;j++)
        {
            fprintf(fp, "%d\t%d\t%f\n", i, j, array[i*colSize+j]);
        }
    }
}

__global__ void compute_matixMult(float *a, float *b, float *c, int rowSize_a, int colSize_a, int colSize_b) // colSize_a should be equal to rowSize_b
{
    int k;
    float sum = 0.0;
    int col = threadIdx.x + blockDim.x * blockIdx.x;
    int row = threadIdx.y + blockDim.y * blockIdx.y;

	if (col < rowSize_a && row < colSize_b)
    {
        for (k = 0; k < colSize_a; k++)
        {
            sum += a[row*colSize_a+k]*b[k*colSize_b+col];
        }
        c[row*colSize_b+col] = sum;
    }
}

int main(int argc, char **argv)
{
    int rowSize_A, colSize_A, rowSize_B, colSize_B, rowSize_C, colSize_C;

    if (argc < 2)
    {
        printf("At least one varaible for matrix dimensions is required.");
        return -1;
    }
    else if (argc == 2)
    {	
    	rowSize_A = atoi(argv[1]);
    	colSize_A = atoi(argv[1]);
    	rowSize_B = atoi(argv[1]);
    	colSize_B = atoi(argv[1]);
    	printf("Two random %dX%d matrices are going to be generated for the multiplication.\n", rowSize_A, colSize_A);
    }
    else
    {    	
    	rowSize_A = atoi(argv[1]);
    	colSize_A = atoi(argv[2]);
    	rowSize_B = atoi(argv[3]);
    	colSize_B = atoi(argv[4]);

    	if (colSize_A == rowSize_B)
    		printf("A random %dX%d matrix A and %dX%d matrix B are going to be generated for the multiplication.\n", rowSize_A, colSize_A, rowSize_B, colSize_B);
    	else
    	{
    		printf("Error input: the number of columns of the first matrix should be equal to the number of rows of te second matrix");
    		return -1;
    	}
    }

    /* Generated two random matrices for multiplication */
    rowSize_C = rowSize_A; 
    colSize_C = colSize_B;
    float matrix_A[rowSize_A*colSize_A], matrix_B[rowSize_B*colSize_B], matrix_C[rowSize_C*colSize_C]; 
    gen_flattened_array(matrix_A, rowSize_A, colSize_A);
    gen_flattened_array(matrix_B, rowSize_B, colSize_B);

    /* Malloc memory for device variables */
    float *dev_matrix_A, *dev_matrix_B, *dev_matrix_C; 
    hipMalloc((void **) & dev_matrix_A, rowSize_A*colSize_A*sizeof(float));
    hipMalloc((void **) & dev_matrix_B, rowSize_B*colSize_B*sizeof(float));
    hipMalloc((void **) & dev_matrix_C, rowSize_C*colSize_C*sizeof(float));

    /* Computate the multiplication */
    dim3 dimGrid(1,1);
    dim3 dimBlock(colSize_A, colSize_A);

    compute_matixMult<<<dimGrid, dimBlock>>>(matrix_A, matrix_B, matrix_C, rowSize_A, colSize_B, rowSize_B);
    hipDeviceSynchronize();

    clock_t start, stop;
    start = clock();
    compute_matixMult<<<dimGrid, dimBlock>>>(matrix_A, matrix_B, matrix_C, rowSize_A, colSize_B, rowSize_B);
    hipDeviceSynchronize();
    stop = clock();

    /* transfer data from Device to Host and free device memory */
    hipMemcpy(matrix_C, dev_matrix_C, rowSize_C*colSize_C*sizeof(float), hipMemcpyDeviceToHost);
    hipFree(dev_matrix_A);
    hipFree(dev_matrix_B);
    hipFree(dev_matrix_C);

    float time = (stop-start)/(float)CLOCKS_PER_SEC;
    printf("The product is computed.\n Execution time is %f seconds\n", time);

    /* Output */
    //printf("Matrix A\n");
    //output_array(matrix_A, rowSize_A, colSize_A);
    //printf("Matrix B\n");
    //output_array(matrix_B, rowSize_B, colSize_B);
    //printf("Product Matrix C\n");    
    //output_array(matrix_C, rowSize_A, colSize_B);

    FILE *file_product, *file_time;
    file_product = fopen("product.txt", "w");
    if (file_product == NULL)
        printf("Error open file to save the product matrix");
    else
    {
        save_array(matrix_C, rowSize_A, colSize_B, file_product);
        fclose(file_product);
    }


    file_time = fopen("time.txt", "a");
    if (file_time == NULL)
        printf("Error open file to save the product matrix");
    else
    {
        fprintf(file_time, "%d\t%f\n", colSize_A, time);
        fclose(file_time);
    }

    return 1;

}

	.text
	.file	"MatrixMultNaive.bk.hip"
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z19gen_flattened_arrayPfii
.LCPI0_0:
	.quad	0x41dfffffffc00000              # double 2147483647
	.text
	.globl	_Z19gen_flattened_arrayPfii
	.type	_Z19gen_flattened_arrayPfii,@function
_Z19gen_flattened_arrayPfii:            # @_Z19gen_flattened_arrayPfii
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	%edx, %ebx
	movl	%esi, %ebp
	movq	%rdi, (%rsp)                    # 8-byte Spill
	leaq	16(%rsp), %rdi
	callq	time
	movl	%eax, %edi
	callq	srand
	testl	%ebp, %ebp
	jle	.LBB0_6
# %bb.1:                                # %.preheader.lr.ph
	movl	%ebp, %eax
	movq	%rax, 8(%rsp)                   # 8-byte Spill
	movl	%ebx, %r12d
	xorl	%r13d, %r13d
	xorl	%ebp, %ebp
.LBB0_2:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB0_4 Depth 2
	testl	%ebx, %ebx
	jle	.LBB0_5
# %bb.3:                                # %.lr.ph
                                        #   in Loop: Header=BB0_2 Depth=1
	movl	%r13d, %eax
	movq	(%rsp), %rcx                    # 8-byte Reload
	leaq	(%rcx,%rax,4), %r14
	xorl	%r15d, %r15d
.LBB0_4:                                #   Parent Loop BB0_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	callq	rand
	movsd	.LCPI0_0(%rip), %xmm1           # xmm1 = mem[0],zero
	xorps	%xmm0, %xmm0
	cvtsi2sd	%eax, %xmm0
	divsd	%xmm1, %xmm0
	cvtsd2ss	%xmm0, %xmm0
	movss	%xmm0, (%r14,%r15,4)
	incq	%r15
	cmpq	%r15, %r12
	jne	.LBB0_4
.LBB0_5:                                # %._crit_edge
                                        #   in Loop: Header=BB0_2 Depth=1
	incq	%rbp
	addl	%ebx, %r13d
	cmpq	8(%rsp), %rbp                   # 8-byte Folded Reload
	jne	.LBB0_2
.LBB0_6:                                # %._crit_edge13
	addq	$24, %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
	retq
.Lfunc_end0:
	.size	_Z19gen_flattened_arrayPfii, .Lfunc_end0-_Z19gen_flattened_arrayPfii
	.cfi_endproc
                                        # -- End function
	.globl	_Z12output_arrayPfii            # -- Begin function _Z12output_arrayPfii
	.type	_Z12output_arrayPfii,@function
_Z12output_arrayPfii:                   # @_Z12output_arrayPfii
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	%edx, %ebx
	movl	%esi, %ebp
	movq	%rdi, 8(%rsp)                   # 8-byte Spill
	xorl	%r13d, %r13d
	movl	$.L.str, %edi
	movl	$.L.str.1, %esi
	movl	$.L.str.2, %edx
	movl	$.L.str.3, %ecx
	xorl	%eax, %eax
	callq	printf
	testl	%ebp, %ebp
	jle	.LBB1_6
# %bb.1:                                # %.preheader.lr.ph
	movl	%ebp, %eax
	movq	%rax, 16(%rsp)                  # 8-byte Spill
	movl	%ebx, %r14d
	xorl	%r15d, %r15d
.LBB1_2:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_4 Depth 2
	testl	%ebx, %ebx
	jle	.LBB1_5
# %bb.3:                                # %.lr.ph
                                        #   in Loop: Header=BB1_2 Depth=1
	movl	%r13d, %eax
	movq	8(%rsp), %rcx                   # 8-byte Reload
	leaq	(%rcx,%rax,4), %rbp
	xorl	%r12d, %r12d
.LBB1_4:                                #   Parent Loop BB1_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	xorps	%xmm0, %xmm0
	cvtss2sd	(%rbp,%r12,4), %xmm0
	movl	$.L.str.4, %edi
	movl	%r15d, %esi
	movl	%r12d, %edx
	movb	$1, %al
	callq	printf
	incq	%r12
	cmpq	%r12, %r14
	jne	.LBB1_4
.LBB1_5:                                # %._crit_edge
                                        #   in Loop: Header=BB1_2 Depth=1
	incq	%r15
	addl	%ebx, %r13d
	cmpq	16(%rsp), %r15                  # 8-byte Folded Reload
	jne	.LBB1_2
.LBB1_6:                                # %._crit_edge15
	addq	$24, %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
	retq
.Lfunc_end1:
	.size	_Z12output_arrayPfii, .Lfunc_end1-_Z12output_arrayPfii
	.cfi_endproc
                                        # -- End function
	.globl	_Z10save_arrayPfiiP8_IO_FILE    # -- Begin function _Z10save_arrayPfiiP8_IO_FILE
	.type	_Z10save_arrayPfiiP8_IO_FILE,@function
_Z10save_arrayPfiiP8_IO_FILE:           # @_Z10save_arrayPfiiP8_IO_FILE
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	.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, 8(%rsp)                   # 8-byte Spill
	testl	%esi, %esi
	jle	.LBB2_6
# %bb.1:                                # %.preheader.lr.ph
	movq	%rcx, %rbx
	movl	%esi, %eax
	movq	%rax, 16(%rsp)                  # 8-byte Spill
	movl	%edx, %r14d
	xorl	%r13d, %r13d
	xorl	%r15d, %r15d
	movl	%edx, 4(%rsp)                   # 4-byte Spill
.LBB2_2:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB2_4 Depth 2
	testl	%edx, %edx
	jle	.LBB2_5
# %bb.3:                                # %.lr.ph
                                        #   in Loop: Header=BB2_2 Depth=1
	movl	%r13d, %eax
	movq	8(%rsp), %rcx                   # 8-byte Reload
	leaq	(%rcx,%rax,4), %rbp
	xorl	%r12d, %r12d
.LBB2_4:                                #   Parent Loop BB2_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	xorps	%xmm0, %xmm0
	cvtss2sd	(%rbp,%r12,4), %xmm0
	movl	$.L.str.4, %esi
	movq	%rbx, %rdi
	movl	%r15d, %edx
	movl	%r12d, %ecx
	movb	$1, %al
	callq	fprintf
	incq	%r12
	cmpq	%r12, %r14
	jne	.LBB2_4
.LBB2_5:                                # %._crit_edge
                                        #   in Loop: Header=BB2_2 Depth=1
	incq	%r15
	movl	4(%rsp), %edx                   # 4-byte Reload
	addl	%edx, %r13d
	cmpq	16(%rsp), %r15                  # 8-byte Folded Reload
	jne	.LBB2_2
.LBB2_6:                                # %._crit_edge16
	addq	$24, %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
	retq
.Lfunc_end2:
	.size	_Z10save_arrayPfiiP8_IO_FILE, .Lfunc_end2-_Z10save_arrayPfiiP8_IO_FILE
	.cfi_endproc
                                        # -- End function
	.globl	_Z32__device_stub__compute_matixMultPfS_S_iii # -- Begin function _Z32__device_stub__compute_matixMultPfS_S_iii
	.type	_Z32__device_stub__compute_matixMultPfS_S_iii,@function
_Z32__device_stub__compute_matixMultPfS_S_iii: # @_Z32__device_stub__compute_matixMultPfS_S_iii
	.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	$144, %rsp
	.cfi_def_cfa_offset 192
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	56(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	48(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	40(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	20(%rsp), %rdx
	movl	%ecx, (%rdx)
	leaq	16(%rsp), %rcx
	movl	%r8d, (%rcx)
	leaq	12(%rsp), %r8
	movl	%r9d, (%r8)
	leaq	96(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	movq	%rcx, 32(%rbx)
	movq	%r8, 40(%rbx)
	leaq	80(%rsp), %r14
	leaq	64(%rsp), %r15
	leaq	32(%rsp), %r12
	leaq	24(%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	$_Z17compute_matixMultPfS_S_iii, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$160, %rsp
	.cfi_adjust_cfa_offset -160
	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_end3:
	.size	_Z32__device_stub__compute_matixMultPfS_S_iii, .Lfunc_end3-_Z32__device_stub__compute_matixMultPfS_S_iii
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function main
.LCPI4_0:
	.long	0x49742400                      # float 1.0E+6
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
	.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	$72, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	cmpl	$1, %edi
	jg	.LBB4_3
# %bb.1:
	movl	$.L.str.5, %edi
.LBB4_2:
	xorl	%eax, %eax
	callq	printf
	movl	$-1, %eax
	jmp	.LBB4_18
.LBB4_3:
	movq	%rsi, %rbx
	cmpl	$2, %edi
	jne	.LBB4_5
# %bb.4:
	movq	8(%rbx), %rdi
	callq	atoi
	movl	%eax, %r15d
	movl	$.L.str.6, %edi
	movl	%eax, %esi
	movl	%eax, %edx
	xorl	%eax, %eax
	callq	printf
	movl	%r15d, %r13d
	movl	%r15d, %ebx
	jmp	.LBB4_7
.LBB4_5:
	movq	16(%rbx), %rdi
	callq	atoi
	movl	%eax, %r13d
	movq	24(%rbx), %rdi
	callq	atoi
	cmpl	%eax, %r13d
	jne	.LBB4_19
# %bb.6:
	movq	32(%rbx), %rdi
	callq	atoi
	movl	%eax, %r15d
	movq	8(%rbx), %rdi
	callq	atoi
	movl	%eax, %ebx
	movl	$.L.str.7, %edi
	movl	%eax, %esi
	movl	%r13d, %edx
	movl	%r13d, %ecx
	movl	%r15d, %r8d
	xorl	%eax, %eax
	callq	printf
.LBB4_7:
	movl	%r15d, -44(%rbp)                # 4-byte Spill
	movl	%ebx, -48(%rbp)                 # 4-byte Spill
	movq	%rsp, -96(%rbp)                 # 8-byte Spill
                                        # kill: def $ebx killed $ebx def $rbx
	imull	%r13d, %ebx
	leaq	15(,%rbx,4), %rax
	andq	$-16, %rax
	movq	%rsp, %rdi
	subq	%rax, %rdi
	movq	%rdi, %rsp
	movl	%r13d, %r14d
	imull	%r15d, %r14d
	leaq	15(,%r14,4), %rax
	andq	$-16, %rax
	movq	%rsp, %r15
	subq	%rax, %r15
	movq	%r15, %rsp
	movl	-48(%rbp), %eax                 # 4-byte Reload
	movl	%eax, %r12d
	imull	-44(%rbp), %r12d                # 4-byte Folded Reload
	leaq	15(,%r12,4), %rax
	andq	$-16, %rax
	movq	%rsp, %rcx
	subq	%rax, %rcx
	movq	%rcx, -72(%rbp)                 # 8-byte Spill
	movq	%rcx, %rsp
	movq	%rdi, -56(%rbp)                 # 8-byte Spill
	movl	-48(%rbp), %esi                 # 4-byte Reload
	movl	%r13d, %edx
	callq	_Z19gen_flattened_arrayPfii
	movq	%r15, -80(%rbp)                 # 8-byte Spill
	movq	%r15, %rdi
	movl	%r13d, %esi
	movl	-44(%rbp), %edx                 # 4-byte Reload
	callq	_Z19gen_flattened_arrayPfii
	movslq	%ebx, %rsi
	shlq	$2, %rsi
	leaq	-112(%rbp), %rdi
	callq	hipMalloc
	movslq	%r14d, %rsi
	shlq	$2, %rsi
	leaq	-104(%rbp), %rdi
	callq	hipMalloc
	movslq	%r12d, %rbx
	movl	%r13d, %r12d
	movl	-44(%rbp), %r13d                # 4-byte Reload
	movl	-48(%rbp), %r15d                # 4-byte Reload
	shlq	$2, %rbx
	leaq	-88(%rbp), %rdi
	movq	%rbx, %rsi
	callq	hipMalloc
	movl	%r12d, %eax
	movq	%rax, %r14
	shlq	$32, %r14
	orq	%rax, %r14
	movabsq	$4294967297, %rdi               # imm = 0x100000001
	movl	$1, %esi
	movq	%r14, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB4_9
# %bb.8:
	movq	-56(%rbp), %rdi                 # 8-byte Reload
	movq	-80(%rbp), %rsi                 # 8-byte Reload
	movq	-72(%rbp), %rdx                 # 8-byte Reload
	movl	%r15d, %ecx
	movl	%r13d, %r8d
	movl	%r12d, %r9d
	callq	_Z32__device_stub__compute_matixMultPfS_S_iii
.LBB4_9:
	callq	hipDeviceSynchronize
	callq	clock
	movq	%rax, -64(%rbp)                 # 8-byte Spill
	movabsq	$4294967297, %rdi               # imm = 0x100000001
	movl	$1, %esi
	movq	%r14, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB4_11
# %bb.10:
	movq	-56(%rbp), %rdi                 # 8-byte Reload
	movq	-80(%rbp), %rsi                 # 8-byte Reload
	movq	-72(%rbp), %rdx                 # 8-byte Reload
	movl	%r15d, %ecx
	movl	%r13d, %r8d
	movl	%r12d, %r9d
	callq	_Z32__device_stub__compute_matixMultPfS_S_iii
.LBB4_11:
	movl	%r12d, -56(%rbp)                # 4-byte Spill
	movl	%r13d, %r12d
	callq	hipDeviceSynchronize
	callq	clock
	movq	%rax, %r14
	movq	-88(%rbp), %rsi
	movq	-72(%rbp), %r13                 # 8-byte Reload
	movq	%r13, %rdi
	movq	%rbx, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	movq	-112(%rbp), %rdi
	callq	hipFree
	movq	-104(%rbp), %rdi
	callq	hipFree
	movq	-88(%rbp), %rdi
	callq	hipFree
	subq	-64(%rbp), %r14                 # 8-byte Folded Reload
	cvtsi2ss	%r14, %xmm0
	divss	.LCPI4_0(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	movl	$.L.str.9, %edi
	movsd	%xmm0, -64(%rbp)                # 8-byte Spill
	movb	$1, %al
	callq	printf
	movl	$.L.str.10, %edi
	movl	$.L.str.11, %esi
	callq	fopen
	testq	%rax, %rax
	je	.LBB4_12
# %bb.13:
	movq	%rax, %rbx
	movq	%r13, %rdi
	movl	%r15d, %esi
	movl	%r12d, %edx
	movq	%rax, %rcx
	callq	_Z10save_arrayPfiiP8_IO_FILE
	movq	%rbx, %rdi
	callq	fclose
	jmp	.LBB4_14
.LBB4_12:
	movl	$.L.str.12, %edi
	xorl	%eax, %eax
	callq	printf
.LBB4_14:
	movl	$.L.str.13, %edi
	movl	$.L.str.14, %esi
	callq	fopen
	testq	%rax, %rax
	movl	-56(%rbp), %edx                 # 4-byte Reload
	je	.LBB4_15
# %bb.16:
	movq	%rax, %rbx
	movl	$.L.str.15, %esi
	movq	%rax, %rdi
	movsd	-64(%rbp), %xmm0                # 8-byte Reload
                                        # xmm0 = mem[0],zero
	movb	$1, %al
	callq	fprintf
	movq	%rbx, %rdi
	callq	fclose
	jmp	.LBB4_17
.LBB4_15:
	movl	$.L.str.12, %edi
	xorl	%eax, %eax
	callq	printf
.LBB4_17:
	movl	$1, %eax
	movq	-96(%rbp), %rsp                 # 8-byte Reload
.LBB4_18:
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa %rsp, 8
	retq
.LBB4_19:
	.cfi_def_cfa %rbp, 16
	movl	$.L.str.8, %edi
	jmp	.LBB4_2
.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	$_Z17compute_matixMultPfS_S_iii, %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	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"%s\t%s\t%s\n"
	.size	.L.str, 10

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"RowID"
	.size	.L.str.1, 6

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"ColID"
	.size	.L.str.2, 6

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

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"%d\t%d\t%f\n"
	.size	.L.str.4, 10

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

	.type	.L.str.5,@object                # @.str.5
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.5:
	.asciz	"At least one varaible for matrix dimensions is required."
	.size	.L.str.5, 57

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"Two random %dX%d matrices are going to be generated for the multiplication.\n"
	.size	.L.str.6, 77

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"A random %dX%d matrix A and %dX%d matrix B are going to be generated for the multiplication.\n"
	.size	.L.str.7, 94

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"Error input: the number of columns of the first matrix should be equal to the number of rows of te second matrix"
	.size	.L.str.8, 113

	.type	.L.str.9,@object                # @.str.9
.L.str.9:
	.asciz	"The product is computed.\n Execution time is %f seconds\n"
	.size	.L.str.9, 56

	.type	.L.str.10,@object               # @.str.10
.L.str.10:
	.asciz	"product.txt"
	.size	.L.str.10, 12

	.type	.L.str.11,@object               # @.str.11
.L.str.11:
	.asciz	"w"
	.size	.L.str.11, 2

	.type	.L.str.12,@object               # @.str.12
.L.str.12:
	.asciz	"Error open file to save the product matrix"
	.size	.L.str.12, 43

	.type	.L.str.13,@object               # @.str.13
.L.str.13:
	.asciz	"time.txt"
	.size	.L.str.13, 9

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

	.type	.L.str.15,@object               # @.str.15
.L.str.15:
	.asciz	"%d\t%f\n"
	.size	.L.str.15, 7

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z17compute_matixMultPfS_S_iii"
	.size	.L__unnamed_1, 31

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

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

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym _Z32__device_stub__compute_matixMultPfS_S_iii
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z17compute_matixMultPfS_S_iii
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z17compute_matixMultPfS_S_iii ; -- Begin function _Z17compute_matixMultPfS_S_iii
	.globl	_Z17compute_matixMultPfS_S_iii
	.p2align	8
	.type	_Z17compute_matixMultPfS_S_iii,@function
_Z17compute_matixMultPfS_S_iii:         ; @_Z17compute_matixMultPfS_S_iii
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x34
	s_load_b128 s[4:7], s[0:1], 0x18
	v_and_b32_e32 v2, 0x3ff, v0
	v_bfe_u32 v3, v0, 10, 10
	s_waitcnt lgkmcnt(0)
	s_lshr_b32 s3, s2, 16
	s_and_b32 s2, s2, 0xffff
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	v_mad_u64_u32 v[0:1], null, s14, s2, v[2:3]
	v_mad_u64_u32 v[1:2], null, s15, s3, v[3:4]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_cmp_gt_i32_e32 vcc_lo, s4, v0
	v_cmp_gt_i32_e64 s2, s6, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_and_b32 s2, vcc_lo, s2
	s_and_saveexec_b32 s3, s2
	s_cbranch_execz .LBB0_6
; %bb.1:                                ; %.preheader
	s_clause 0x1
	s_load_b128 s[8:11], s[0:1], 0x0
	s_load_b64 s[0:1], s[0:1], 0x10
	s_cmp_lt_i32 s5, 1
	s_cbranch_scc1 .LBB0_4
; %bb.2:                                ; %.lr.ph
	v_mul_lo_u32 v2, v1, s5
	v_mov_b32_e32 v6, 0
	v_mov_b32_e32 v4, v0
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v3, 31, v2
	v_lshlrev_b64 v[2:3], 2, v[2:3]
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v2, vcc_lo, s8, v2
	v_add_co_ci_u32_e32 v3, vcc_lo, s9, v3, vcc_lo
.LBB0_3:                                ; =>This Inner Loop Header: Depth=1
	v_ashrrev_i32_e32 v5, 31, v4
	s_add_i32 s5, s5, -1
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	s_cmp_lg_u32 s5, 0
	v_lshlrev_b64 v[7:8], 2, v[4:5]
	v_add_nc_u32_e32 v4, s6, v4
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_co_u32 v7, vcc_lo, s10, v7
	v_add_co_ci_u32_e32 v8, vcc_lo, s11, v8, vcc_lo
	global_load_b32 v5, v[2:3], off
	global_load_b32 v7, v[7:8], off
	v_add_co_u32 v2, vcc_lo, v2, 4
	v_add_co_ci_u32_e32 v3, vcc_lo, 0, v3, vcc_lo
	s_waitcnt vmcnt(0)
	v_fmac_f32_e32 v6, v5, v7
	s_cbranch_scc1 .LBB0_3
	s_branch .LBB0_5
.LBB0_4:
	v_mov_b32_e32 v6, 0
.LBB0_5:                                ; %._crit_edge
	v_mad_u64_u32 v[2:3], null, v1, s6, v[0:1]
	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_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v0, vcc_lo, s0, v0
	v_add_co_ci_u32_e32 v1, vcc_lo, s1, v1, vcc_lo
	global_store_b32 v[0:1], v6, off
.LBB0_6:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z17compute_matixMultPfS_S_iii
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 296
		.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	_Z17compute_matixMultPfS_S_iii, .Lfunc_end0-_Z17compute_matixMultPfS_S_iii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 340
; 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:         28
        .size:           4
        .value_kind:     by_value
      - .offset:         32
        .size:           4
        .value_kind:     by_value
      - .offset:         40
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         44
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         48
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         52
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         54
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         56
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         58
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         60
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         62
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         88
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         96
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         104
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 296
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z17compute_matixMultPfS_S_iii
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z17compute_matixMultPfS_S_iii.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
