/*
This program generates 2 N*N matrices and then multiplies them on a GPU
*/


#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<cuda.h>
#include<unistd.h>
//#define N 100

__global__ void multiply(float* A, float* B, float* C, int K)
{
	/*
	The Kernel is a 2D grid. Tried doing the same with a 1D grid but it requires 2 for loops
	*/
	int index1=blockIdx.x*blockDim.x+threadIdx.x;
	int index2=blockIdx.y*blockDim.y+threadIdx.y; 
	float sum=0.0;
	for (int i=0;i<K;i++)
	{
		sum+=A[index2*K+i]*B[i*K+index1];
	}
	
	C[index2*K+index1]=sum;
}

float** Make2DfloatArray(int arraySizeX, int arraySizeY) 
{
	/*
	Generates a 2D matrix of dimension arraySizeX * arraySizeY
	*/
	float** theArray;
	theArray = (float**) malloc(arraySizeX*sizeof(float*));
	int i;
	for (i = 0; i < arraySizeX; i++)
   		theArray[i] = (float*) malloc(arraySizeY*sizeof(float));
	int j;

	for (i=0;i<arraySizeX;i++)
	{
    		for (j=0;j<arraySizeY;j++)
    		{
        		theArray[i][j]=rand()%5;
    		}
	}

   	return theArray;
}

void init_zeros(float** matrix, int K)
{
	/*
	Initializes a matrix to zeros
	*/
	int i,j;
	for (i=0;i<K;i++)
	{	
		for (j=0;j<K;j++)
		{
			matrix[i][j]=0;
		}
	}
}

float* Make1DfloatArray(int arraySizeX)
{
	/*
	Generates a 1D float array of size arraySizeX
	*/
	float* theArray;
	theArray = (float*)malloc(arraySizeX*sizeof(float));
	int i;
	for (i=0;i<arraySizeX;i++)
	{
    		theArray[i]=0.0;
	}

   	return theArray;
}

void printmat(float** matrix, int K)
{
	/*
	To print matrix on display
	*/
	int i,j;
	
	for (i=0;i<K;i++)
	{	
		printf("\n");
		for (j=0;j<K;j++)
		{
			printf("%f \t",matrix[i][j]);
		}
	}
	printf("\n");
}

void printtofile(float** matrix, int K, char* filename)
{
	/*
	Prints original 2D matrices to file
	*/
	FILE *fp;
	fp=fopen(filename,"wt");
	int i,j;
	for (i=0;i<K;i++)
	{
		fprintf(fp, "\n");
		for (j=0;j<K;j++)
		{
			fprintf(fp, "%f\t", matrix[i][j]);
		}
	}
}

void printtofile1D(float* matrix, int K, char* filename)
{
	/*
	Prints resultant matrix to a file
	*/
	FILE *fp;
	fp=fopen(filename,"wt");
	int i,j;
	int counters=0;
	for (i=0;i<K;i++)
	{
		fprintf(fp, "\n");
		for (j=0;j<K;j++)
		{
			fprintf(fp, "%f \t", matrix[counters]);
			counters++;
		}
	}
}

void freese(int sizeX, float** ptr)
{
	/*
	Function used to free up all the 2D matrices created
	*/
    int i;
     for (i=0;i<sizeX;i++)
        free(ptr[i]);
    free(ptr);
}

	 
 
int main(int argc, char *argv[])
{

	const int K = 100;
	const int blocks=K/20;
	const int threadblocks=K/blocks;
	float** M1=Make2DfloatArray(K,K);
	float** M2=Make2DfloatArray(K,K);
	float** Prod=Make2DfloatArray(K,K);
	
	cudaEvent_t start, stop, start_kernel, stop_kernel;
	float time, time_kernel;
	cudaEventCreate(&start);
	cudaEventCreate(&stop);
	cudaEventCreate(&start_kernel);
	cudaEventCreate(&stop_kernel);
		
	init_zeros(Prod, K);
	
	float* M1_host_flat=Make1DfloatArray(K*K);
	float* M2_host_flat=Make1DfloatArray(K*K);
	float* Prod_host_flat=Make1DfloatArray(K*K);
	
	float* M1_device_flat;
	float* M2_device_flat;
	float* Prod_device_flat;
	int* K_device;
	printf("\n Everything initialized");

	printtofile(M1,K,"M1.txt");
	printtofile(M2,K,"M2.txt");
	printtofile(Prod,K,"Prod.txt");


	int counter=0;
	int i,j;
	for(i=0;i<K;i++)
	{
		for(j=0;j<K;j++)
		{
			M1_host_flat[counter]=M1[i][j];
			M2_host_flat[counter]=M2[i][j];
			Prod_host_flat[counter]=Prod[i][j];
			counter+=1;
			
		}
	}
	
	//printf("\n Converted to flat");
	//Transferring matrices from Host to Device
	cudaEventRecord(start,0);
	cudaMalloc((void **) &M1_device_flat, sizeof(float)*K*K);
	cudaMalloc((void **) &M2_device_flat, sizeof(float)*K*K);
	cudaMalloc((void **) &Prod_device_flat, sizeof(float)*K*K);
	cudaMalloc((void **) &K_device, sizeof(int));
	
	cudaMemcpy(M1_device_flat, M1_host_flat, sizeof(float)*K*K, cudaMemcpyHostToDevice);
	cudaMemcpy(M2_device_flat, M2_host_flat, sizeof(float)*K*K, cudaMemcpyHostToDevice);
	cudaMemcpy(Prod_device_flat, Prod_host_flat, sizeof(float)*K*K, cudaMemcpyHostToDevice);
	cudaMemcpy(K_device, &K, sizeof(int), cudaMemcpyHostToDevice);
	//Kernel call
	
	dim3 threads(threadblocks,threadblocks);
	dim3 grid(blocks,blocks);
	
	cudaEventRecord(start_kernel,0);
	
	multiply<<<grid,threads>>>(M1_device_flat,M2_device_flat,Prod_device_flat, K); 
	
	cudaEventRecord(stop_kernel,0);
	
	//Transferring result matrix from Device to Host
	cudaMemcpy(Prod_host_flat, Prod_device_flat, sizeof(int)*K*K, cudaMemcpyDeviceToHost);	
	
	cudaEventRecord(stop,0);
	cudaEventSynchronize(stop);

	cudaEventElapsedTime(&time, start, stop);
	cudaEventElapsedTime(&time_kernel, start_kernel, stop_kernel);
	
	printf("\nTime for kernel with data transfer = %f ms \n", time);
	printf("\nTime for kernel without data transfer = %f ms \n", time_kernel); 
		
	printtofile1D(Prod_host_flat,K,"Prod_result.txt");
	
	//Freeing up all the memory that was used
	cudaFree(M1_device_flat);
	cudaFree(M2_device_flat);
	cudaFree(Prod_device_flat);
	cudaFree(K_device);
	freese(K,M1);
	freese(K,M2);
	freese(K,Prod);
	free(M1_host_flat);
	free(M2_host_flat);
	free(Prod_host_flat);
	
	return 0;	
}

	.file	"tmpxft_0038537a_00000000-6_code.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2050:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2050:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z16Make2DfloatArrayii
	.type	_Z16Make2DfloatArrayii, @function
_Z16Make2DfloatArrayii:
.LFB2040:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movslq	%edi, %rdi
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movslq	%esi, %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%r14, %r13
	salq	$2, %r14
	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	%rdi, %rbp
	salq	$3, %rdi
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	pushq	%rcx
	.cfi_def_cfa_offset 64
	call	malloc@PLT
	movq	%rax, %rbx
.L3:
	cmpl	%r12d, %ebp
	jle	.L11
	movq	%r14, %rdi
	call	malloc@PLT
	movq	%rax, (%rbx,%r12,8)
	incq	%r12
	jmp	.L3
.L11:
	xorl	%r12d, %r12d
	movl	$5, %r15d
.L5:
	cmpl	%r12d, %ebp
	jle	.L12
	xorl	%r14d, %r14d
.L7:
	cmpl	%r14d, %r13d
	jle	.L13
	call	rand@PLT
	movq	(%rbx,%r12,8), %rcx
	cltd
	idivl	%r15d
	cvtsi2ssl	%edx, %xmm0
	movss	%xmm0, (%rcx,%r14,4)
	incq	%r14
	jmp	.L7
.L13:
	incq	%r12
	jmp	.L5
.L12:
	popq	%rdx
	.cfi_def_cfa_offset 56
	movq	%rbx, %rax
	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
.LFE2040:
	.size	_Z16Make2DfloatArrayii, .-_Z16Make2DfloatArrayii
	.globl	_Z10init_zerosPPfi
	.type	_Z10init_zerosPPfi, @function
_Z10init_zerosPPfi:
.LFB2041:
	.cfi_startproc
	endbr64
	leal	-1(%rsi), %eax
	movq	%rdi, %r8
	xorl	%edx, %edx
	leaq	4(,%rax,4), %r9
	xorl	%eax, %eax
.L15:
	cmpl	%edx, %esi
	jle	.L17
	movq	(%r8,%rdx,8), %rdi
	movq	%r9, %rcx
	incq	%rdx
	rep stosb
	jmp	.L15
.L17:
	ret
	.cfi_endproc
.LFE2041:
	.size	_Z10init_zerosPPfi, .-_Z10init_zerosPPfi
	.globl	_Z16Make1DfloatArrayi
	.type	_Z16Make1DfloatArrayi, @function
_Z16Make1DfloatArrayi:
.LFB2042:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	movslq	%edi, %rdi
	movq	%rdi, %rbx
	salq	$2, %rdi
	call	malloc@PLT
	xorl	%edx, %edx
.L19:
	cmpl	%edx, %ebx
	jle	.L22
	movl	$0x00000000, (%rax,%rdx,4)
	incq	%rdx
	jmp	.L19
.L22:
	popq	%rbx
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2042:
	.size	_Z16Make1DfloatArrayi, .-_Z16Make1DfloatArrayi
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC1:
	.string	"\n"
.LC2:
	.string	"%f \t"
	.text
	.globl	_Z8printmatPPfi
	.type	_Z8printmatPPfi, @function
_Z8printmatPPfi:
.LFB2043:
	.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
	movslq	%esi, %r14
	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
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%r14, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	xorl	%ebx, %ebx
	pushq	%rcx
	.cfi_def_cfa_offset 64
.L24:
	xorl	%eax, %eax
	cmpl	%ebx, %ebp
	leaq	.LC1(%rip), %rsi
	movl	$2, %edi
	jle	.L29
	call	__printf_chk@PLT
	xorl	%r12d, %r12d
	leaq	.LC2(%rip), %r15
.L25:
	movq	0(%r13,%rbx,8), %rax
	movq	%r15, %rsi
	movl	$2, %edi
	cvtss2sd	(%rax,%r12,4), %xmm0
	movb	$1, %al
	incq	%r12
	call	__printf_chk@PLT
	cmpq	%r12, %r14
	jne	.L25
	incq	%rbx
	jmp	.L24
.L29:
	popq	%rdx
	.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
	jmp	__printf_chk@PLT
	.cfi_endproc
.LFE2043:
	.size	_Z8printmatPPfi, .-_Z8printmatPPfi
	.section	.rodata.str1.1
.LC3:
	.string	"wt"
.LC4:
	.string	"%f\t"
	.text
	.globl	_Z11printtofilePPfiPc
	.type	_Z11printtofilePPfiPc, @function
_Z11printtofilePPfiPc:
.LFB2044:
	.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
	movslq	%esi, %r14
	leaq	.LC3(%rip), %rsi
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%rdi, %r13
	movq	%rdx, %rdi
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%r14, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	xorl	%ebx, %ebx
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	call	fopen@PLT
	movq	%rax, 8(%rsp)
.L31:
	cmpl	%ebx, %ebp
	jle	.L36
	movq	8(%rsp), %rdi
	movl	$2, %esi
	xorl	%eax, %eax
	xorl	%r12d, %r12d
	leaq	.LC1(%rip), %rdx
	leaq	.LC4(%rip), %r15
	call	__fprintf_chk@PLT
.L32:
	movq	0(%r13,%rbx,8), %rax
	movq	8(%rsp), %rdi
	movq	%r15, %rdx
	movl	$2, %esi
	cvtss2sd	(%rax,%r12,4), %xmm0
	movb	$1, %al
	incq	%r12
	call	__fprintf_chk@PLT
	cmpq	%r12, %r14
	jne	.L32
	incq	%rbx
	jmp	.L31
.L36:
	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
.LFE2044:
	.size	_Z11printtofilePPfiPc, .-_Z11printtofilePPfiPc
	.globl	_Z13printtofile1DPfiPc
	.type	_Z13printtofile1DPfiPc, @function
_Z13printtofile1DPfiPc:
.LFB2045:
	.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
	movslq	%esi, %r14
	leaq	.LC3(%rip), %rsi
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%rdi, %r13
	movq	%rdx, %rdi
	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
	xorl	%ebp, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	%r14, %rbx
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	call	fopen@PLT
	movq	%rax, (%rsp)
.L38:
	cmpl	%ebx, %ebp
	jge	.L43
	movq	(%rsp), %rdi
	leaq	.LC1(%rip), %rdx
	movl	$2, %esi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	movslq	%r12d, %rcx
	leaq	(%r14,%rcx), %r15
.L39:
	movq	(%rsp), %rdi
	movl	$2, %esi
	movb	$1, %al
	movq	%rcx, 8(%rsp)
	leaq	.LC2(%rip), %rdx
	cvtss2sd	0(%r13,%rcx,4), %xmm0
	call	__fprintf_chk@PLT
	movq	8(%rsp), %rcx
	incq	%rcx
	cmpq	%r15, %rcx
	jne	.L39
	addl	%ebx, %r12d
	incl	%ebp
	jmp	.L38
.L43:
	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
.LFE2045:
	.size	_Z13printtofile1DPfiPc, .-_Z13printtofile1DPfiPc
	.globl	_Z6freeseiPPf
	.type	_Z6freeseiPPf, @function
_Z6freeseiPPf:
.LFB2046:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movl	%edi, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	xorl	%ebp, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	movq	%rsi, %rbx
.L45:
	cmpl	%ebp, %r12d
	jle	.L48
	movq	(%rbx,%rbp,8), %rdi
	incq	%rbp
	call	free@PLT
	jmp	.L45
.L48:
	movq	%rbx, %rdi
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	jmp	free@PLT
	.cfi_endproc
.LFE2046:
	.size	_Z6freeseiPPf, .-_Z6freeseiPPf
	.globl	_Z32__device_stub__Z8multiplyPfS_S_iPfS_S_i
	.type	_Z32__device_stub__Z8multiplyPfS_S_iPfS_S_i, @function
_Z32__device_stub__Z8multiplyPfS_S_iPfS_S_i:
.LFB2072:
	.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	.L49
	pushq	48(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z8multiplyPfS_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
.L49:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L51
	call	__stack_chk_fail@PLT
.L51:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2072:
	.size	_Z32__device_stub__Z8multiplyPfS_S_iPfS_S_i, .-_Z32__device_stub__Z8multiplyPfS_S_iPfS_S_i
	.globl	_Z8multiplyPfS_S_i
	.type	_Z8multiplyPfS_S_i, @function
_Z8multiplyPfS_S_i:
.LFB2073:
	.cfi_startproc
	endbr64
	jmp	_Z32__device_stub__Z8multiplyPfS_S_iPfS_S_i
	.cfi_endproc
.LFE2073:
	.size	_Z8multiplyPfS_S_i, .-_Z8multiplyPfS_S_i
	.section	.rodata.str1.1
.LC5:
	.string	"\n Everything initialized"
.LC6:
	.string	"M1.txt"
.LC7:
	.string	"M2.txt"
.LC8:
	.string	"Prod.txt"
.LC9:
	.string	"\nTime for kernel with data transfer = %f ms \n"
.LC10:
	.string	"\nTime for kernel without data transfer = %f ms \n"
.LC11:
	.string	"Prod_result.txt"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2047:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	$100, %esi
	movl	$100, %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	$120, %rsp
	.cfi_def_cfa_offset 176
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	movl	$100, 4(%rsp)
	call	_Z16Make2DfloatArrayii
	movl	$100, %esi
	movl	$100, %edi
	movq	%rax, %r15
	call	_Z16Make2DfloatArrayii
	movl	$100, %esi
	movl	$100, %edi
	movq	%rax, %r14
	call	_Z16Make2DfloatArrayii
	leaq	16(%rsp), %rdi
	movq	%rax, %rbp
	call	cudaEventCreate@PLT
	leaq	24(%rsp), %rdi
	call	cudaEventCreate@PLT
	leaq	32(%rsp), %rdi
	call	cudaEventCreate@PLT
	leaq	40(%rsp), %rdi
	call	cudaEventCreate@PLT
	movl	$100, %esi
	movq	%rbp, %rdi
	call	_Z10init_zerosPPfi
	movl	$10000, %edi
	call	_Z16Make1DfloatArrayi
	movl	$10000, %edi
	movq	%rax, %r13
	call	_Z16Make1DfloatArrayi
	movl	$10000, %edi
	movq	%rax, %r12
	call	_Z16Make1DfloatArrayi
	leaq	.LC5(%rip), %rsi
	movl	$2, %edi
	movq	%rax, %rbx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	.LC6(%rip), %rdx
	movl	$100, %esi
	movq	%r15, %rdi
	call	_Z11printtofilePPfiPc
	leaq	.LC7(%rip), %rdx
	movl	$100, %esi
	movq	%r14, %rdi
	call	_Z11printtofilePPfiPc
	movl	$100, %esi
	leaq	.LC8(%rip), %rdx
	movq	%rbp, %rdi
	call	_Z11printtofilePPfiPc
	xorl	%ecx, %ecx
	xorl	%esi, %esi
.L55:
	movq	(%r15,%rcx), %r9
	movq	(%r14,%rcx), %r8
	movq	%rsi, %rdx
	xorl	%eax, %eax
	movq	0(%rbp,%rcx), %rdi
.L56:
	movss	(%r9,%rax), %xmm0
	movss	%xmm0, 0(%r13,%rdx,4)
	movss	(%r8,%rax), %xmm0
	movss	%xmm0, (%r12,%rdx,4)
	movss	(%rdi,%rax), %xmm0
	addq	$4, %rax
	movss	%xmm0, (%rbx,%rdx,4)
	incq	%rdx
	cmpq	$400, %rax
	jne	.L56
	addq	$100, %rsi
	addq	$8, %rcx
	cmpq	$10000, %rsi
	jne	.L55
	movq	16(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	leaq	48(%rsp), %rdi
	movl	$40000, %esi
	call	cudaMalloc@PLT
	leaq	56(%rsp), %rdi
	movl	$40000, %esi
	call	cudaMalloc@PLT
	leaq	64(%rsp), %rdi
	movl	$40000, %esi
	call	cudaMalloc@PLT
	leaq	72(%rsp), %rdi
	movl	$4, %esi
	call	cudaMalloc@PLT
	movq	48(%rsp), %rdi
	movl	$1, %ecx
	movq	%r13, %rsi
	movl	$40000, %edx
	call	cudaMemcpy@PLT
	movq	56(%rsp), %rdi
	movl	$1, %ecx
	movq	%r12, %rsi
	movl	$40000, %edx
	call	cudaMemcpy@PLT
	movq	64(%rsp), %rdi
	movl	$1, %ecx
	movq	%rbx, %rsi
	movl	$40000, %edx
	call	cudaMemcpy@PLT
	movq	72(%rsp), %rdi
	movl	$1, %ecx
	movl	$4, %edx
	leaq	4(%rsp), %rsi
	call	cudaMemcpy@PLT
	movq	32(%rsp), %rdi
	xorl	%esi, %esi
	movabsq	$85899345940, %rax
	movq	%rax, 80(%rsp)
	movabsq	$21474836485, %rax
	movl	$1, 88(%rsp)
	movq	%rax, 92(%rsp)
	movl	$1, 100(%rsp)
	call	cudaEventRecord@PLT
	movl	88(%rsp), %ecx
	movl	100(%rsp), %esi
	xorl	%r9d, %r9d
	movq	80(%rsp), %rdx
	movq	92(%rsp), %rdi
	xorl	%r8d, %r8d
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L58
	movq	64(%rsp), %rdx
	movq	56(%rsp), %rsi
	movl	$100, %ecx
	movq	48(%rsp), %rdi
	call	_Z32__device_stub__Z8multiplyPfS_S_iPfS_S_i
.L58:
	movq	40(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	64(%rsp), %rsi
	movl	$2, %ecx
	movq	%rbx, %rdi
	movl	$40000, %edx
	call	cudaMemcpy@PLT
	movq	24(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	24(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movq	24(%rsp), %rdx
	movq	16(%rsp), %rsi
	leaq	8(%rsp), %rdi
	call	cudaEventElapsedTime@PLT
	movq	40(%rsp), %rdx
	movq	32(%rsp), %rsi
	leaq	12(%rsp), %rdi
	call	cudaEventElapsedTime@PLT
	leaq	.LC9(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	cvtss2sd	8(%rsp), %xmm0
	call	__printf_chk@PLT
	movl	$2, %edi
	movb	$1, %al
	leaq	.LC10(%rip), %rsi
	cvtss2sd	12(%rsp), %xmm0
	call	__printf_chk@PLT
	leaq	.LC11(%rip), %rdx
	movl	$100, %esi
	movq	%rbx, %rdi
	call	_Z13printtofile1DPfiPc
	movq	48(%rsp), %rdi
	call	cudaFree@PLT
	movq	56(%rsp), %rdi
	call	cudaFree@PLT
	movq	64(%rsp), %rdi
	call	cudaFree@PLT
	movq	72(%rsp), %rdi
	call	cudaFree@PLT
	movq	%r15, %rsi
	movl	$100, %edi
	call	_Z6freeseiPPf
	movq	%r14, %rsi
	movl	$100, %edi
	call	_Z6freeseiPPf
	movq	%rbp, %rsi
	movl	$100, %edi
	call	_Z6freeseiPPf
	movq	%r13, %rdi
	call	free@PLT
	movq	%r12, %rdi
	call	free@PLT
	movq	%rbx, %rdi
	call	free@PLT
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	je	.L59
	call	__stack_chk_fail@PLT
.L59:
	addq	$120, %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
.LFE2047:
	.size	main, .-main
	.section	.rodata.str1.1
.LC12:
	.string	"_Z8multiplyPfS_S_i"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2075:
	.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	.LC12(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z8multiplyPfS_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
.LFE2075:
	.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
	.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:

/*
This program generates 2 N*N matrices and then multiplies them on a GPU
*/


#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<hip/hip_runtime.h>
#include<unistd.h>
//#define N 100

__global__ void multiply(float* A, float* B, float* C, int K)
{
	/*
	The Kernel is a 2D grid. Tried doing the same with a 1D grid but it requires 2 for loops
	*/
	int index1=blockIdx.x*blockDim.x+threadIdx.x;
	int index2=blockIdx.y*blockDim.y+threadIdx.y; 
	float sum=0.0;
	for (int i=0;i<K;i++)
	{
		sum+=A[index2*K+i]*B[i*K+index1];
	}
	
	C[index2*K+index1]=sum;
}

float** Make2DfloatArray(int arraySizeX, int arraySizeY) 
{
	/*
	Generates a 2D matrix of dimension arraySizeX * arraySizeY
	*/
	float** theArray;
	theArray = (float**) malloc(arraySizeX*sizeof(float*));
	int i;
	for (i = 0; i < arraySizeX; i++)
   		theArray[i] = (float*) malloc(arraySizeY*sizeof(float));
	int j;

	for (i=0;i<arraySizeX;i++)
	{
    		for (j=0;j<arraySizeY;j++)
    		{
        		theArray[i][j]=rand()%5;
    		}
	}

   	return theArray;
}

void init_zeros(float** matrix, int K)
{
	/*
	Initializes a matrix to zeros
	*/
	int i,j;
	for (i=0;i<K;i++)
	{	
		for (j=0;j<K;j++)
		{
			matrix[i][j]=0;
		}
	}
}

float* Make1DfloatArray(int arraySizeX)
{
	/*
	Generates a 1D float array of size arraySizeX
	*/
	float* theArray;
	theArray = (float*)malloc(arraySizeX*sizeof(float));
	int i;
	for (i=0;i<arraySizeX;i++)
	{
    		theArray[i]=0.0;
	}

   	return theArray;
}

void printmat(float** matrix, int K)
{
	/*
	To print matrix on display
	*/
	int i,j;
	
	for (i=0;i<K;i++)
	{	
		printf("\n");
		for (j=0;j<K;j++)
		{
			printf("%f \t",matrix[i][j]);
		}
	}
	printf("\n");
}

void printtofile(float** matrix, int K, char* filename)
{
	/*
	Prints original 2D matrices to file
	*/
	FILE *fp;
	fp=fopen(filename,"wt");
	int i,j;
	for (i=0;i<K;i++)
	{
		fprintf(fp, "\n");
		for (j=0;j<K;j++)
		{
			fprintf(fp, "%f\t", matrix[i][j]);
		}
	}
}

void printtofile1D(float* matrix, int K, char* filename)
{
	/*
	Prints resultant matrix to a file
	*/
	FILE *fp;
	fp=fopen(filename,"wt");
	int i,j;
	int counters=0;
	for (i=0;i<K;i++)
	{
		fprintf(fp, "\n");
		for (j=0;j<K;j++)
		{
			fprintf(fp, "%f \t", matrix[counters]);
			counters++;
		}
	}
}

void freese(int sizeX, float** ptr)
{
	/*
	Function used to free up all the 2D matrices created
	*/
    int i;
     for (i=0;i<sizeX;i++)
        free(ptr[i]);
    free(ptr);
}

	 
 
int main(int argc, char *argv[])
{

	const int K = 100;
	const int blocks=K/20;
	const int threadblocks=K/blocks;
	float** M1=Make2DfloatArray(K,K);
	float** M2=Make2DfloatArray(K,K);
	float** Prod=Make2DfloatArray(K,K);
	
	hipEvent_t start, stop, start_kernel, stop_kernel;
	float time, time_kernel;
	hipEventCreate(&start);
	hipEventCreate(&stop);
	hipEventCreate(&start_kernel);
	hipEventCreate(&stop_kernel);
		
	init_zeros(Prod, K);
	
	float* M1_host_flat=Make1DfloatArray(K*K);
	float* M2_host_flat=Make1DfloatArray(K*K);
	float* Prod_host_flat=Make1DfloatArray(K*K);
	
	float* M1_device_flat;
	float* M2_device_flat;
	float* Prod_device_flat;
	int* K_device;
	printf("\n Everything initialized");

	printtofile(M1,K,"M1.txt");
	printtofile(M2,K,"M2.txt");
	printtofile(Prod,K,"Prod.txt");


	int counter=0;
	int i,j;
	for(i=0;i<K;i++)
	{
		for(j=0;j<K;j++)
		{
			M1_host_flat[counter]=M1[i][j];
			M2_host_flat[counter]=M2[i][j];
			Prod_host_flat[counter]=Prod[i][j];
			counter+=1;
			
		}
	}
	
	//printf("\n Converted to flat");
	//Transferring matrices from Host to Device
	hipEventRecord(start,0);
	hipMalloc((void **) &M1_device_flat, sizeof(float)*K*K);
	hipMalloc((void **) &M2_device_flat, sizeof(float)*K*K);
	hipMalloc((void **) &Prod_device_flat, sizeof(float)*K*K);
	hipMalloc((void **) &K_device, sizeof(int));
	
	hipMemcpy(M1_device_flat, M1_host_flat, sizeof(float)*K*K, hipMemcpyHostToDevice);
	hipMemcpy(M2_device_flat, M2_host_flat, sizeof(float)*K*K, hipMemcpyHostToDevice);
	hipMemcpy(Prod_device_flat, Prod_host_flat, sizeof(float)*K*K, hipMemcpyHostToDevice);
	hipMemcpy(K_device, &K, sizeof(int), hipMemcpyHostToDevice);
	//Kernel call
	
	dim3 threads(threadblocks,threadblocks);
	dim3 grid(blocks,blocks);
	
	hipEventRecord(start_kernel,0);
	
	multiply<<<grid,threads>>>(M1_device_flat,M2_device_flat,Prod_device_flat, K); 
	
	hipEventRecord(stop_kernel,0);
	
	//Transferring result matrix from Device to Host
	hipMemcpy(Prod_host_flat, Prod_device_flat, sizeof(int)*K*K, hipMemcpyDeviceToHost);	
	
	hipEventRecord(stop,0);
	hipEventSynchronize(stop);

	hipEventElapsedTime(&time, start, stop);
	hipEventElapsedTime(&time_kernel, start_kernel, stop_kernel);
	
	printf("\nTime for kernel with data transfer = %f ms \n", time);
	printf("\nTime for kernel without data transfer = %f ms \n", time_kernel); 
		
	printtofile1D(Prod_host_flat,K,"Prod_result.txt");
	
	//Freeing up all the memory that was used
	hipFree(M1_device_flat);
	hipFree(M2_device_flat);
	hipFree(Prod_device_flat);
	hipFree(K_device);
	freese(K,M1);
	freese(K,M2);
	freese(K,Prod);
	free(M1_host_flat);
	free(M2_host_flat);
	free(Prod_host_flat);
	
	return 0;	
}

	.text
	.file	"code.hip"
	.globl	_Z23__device_stub__multiplyPfS_S_i # -- Begin function _Z23__device_stub__multiplyPfS_S_i
	.type	_Z23__device_stub__multiplyPfS_S_i,@function
_Z23__device_stub__multiplyPfS_S_i:     # @_Z23__device_stub__multiplyPfS_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	$_Z8multiplyPfS_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	_Z23__device_stub__multiplyPfS_S_i, .Lfunc_end0-_Z23__device_stub__multiplyPfS_S_i
	.cfi_endproc
                                        # -- End function
	.globl	_Z16Make2DfloatArrayii          # -- Begin function _Z16Make2DfloatArrayii
	.type	_Z16Make2DfloatArrayii,@function
_Z16Make2DfloatArrayii:                 # @_Z16Make2DfloatArrayii
	.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
	movl	%esi, %ebx
	movl	%edi, %ebp
	movslq	%edi, %r15
	leaq	(,%r15,8), %rdi
	callq	malloc
	movq	%rax, %r14
	testl	%r15d, %r15d
	jle	.LBB1_9
# %bb.1:                                # %.lr.ph
	movslq	%ebx, %r15
	shlq	$2, %r15
	movl	%ebp, %r12d
	xorl	%r13d, %r13d
.LBB1_2:                                # =>This Inner Loop Header: Depth=1
	movq	%r15, %rdi
	callq	malloc
	movq	%rax, (%r14,%r13,8)
	incq	%r13
	cmpq	%r13, %r12
	jne	.LBB1_2
# %bb.3:                                # %.preheader18
	testl	%ebp, %ebp
	jle	.LBB1_9
# %bb.4:                                # %.preheader.lr.ph
	movl	%ebx, %r15d
	xorl	%r13d, %r13d
.LBB1_5:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_7 Depth 2
	testl	%ebx, %ebx
	jle	.LBB1_8
# %bb.6:                                # %.lr.ph21
                                        #   in Loop: Header=BB1_5 Depth=1
	xorl	%ebp, %ebp
.LBB1_7:                                #   Parent Loop BB1_5 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	callq	rand
	cltq
	imulq	$1717986919, %rax, %rcx         # imm = 0x66666667
	movq	%rcx, %rdx
	shrq	$63, %rdx
	sarq	$33, %rcx
	addl	%edx, %ecx
	leal	(%rcx,%rcx,4), %ecx
	subl	%ecx, %eax
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	movq	(%r14,%r13,8), %rax
	movss	%xmm0, (%rax,%rbp,4)
	incq	%rbp
	cmpq	%rbp, %r15
	jne	.LBB1_7
.LBB1_8:                                # %._crit_edge
                                        #   in Loop: Header=BB1_5 Depth=1
	incq	%r13
	cmpq	%r12, %r13
	jne	.LBB1_5
.LBB1_9:                                # %._crit_edge23
	movq	%r14, %rax
	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
	retq
.Lfunc_end1:
	.size	_Z16Make2DfloatArrayii, .Lfunc_end1-_Z16Make2DfloatArrayii
	.cfi_endproc
                                        # -- End function
	.globl	_Z10init_zerosPPfi              # -- Begin function _Z10init_zerosPPfi
	.type	_Z10init_zerosPPfi,@function
_Z10init_zerosPPfi:                     # @_Z10init_zerosPPfi
	.cfi_startproc
# %bb.0:
	testl	%esi, %esi
	jle	.LBB2_4
# %bb.1:                                # %.preheader.lr.ph
	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
	pushq	%rax
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -40
	.cfi_offset %r12, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rdi, %rbx
	movl	%esi, %r15d
	leaq	(,%r15,4), %r14
	xorl	%r12d, %r12d
.LBB2_2:                                # %._crit_edge
                                        # =>This Inner Loop Header: Depth=1
	movq	(%rbx,%r12,8), %rdi
	xorl	%esi, %esi
	movq	%r14, %rdx
	callq	memset@PLT
	incq	%r12
	cmpq	%r12, %r15
	jne	.LBB2_2
# %bb.3:
	addq	$8, %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
	.cfi_restore %rbx
	.cfi_restore %r12
	.cfi_restore %r14
	.cfi_restore %r15
.LBB2_4:                                # %._crit_edge12
	retq
.Lfunc_end2:
	.size	_Z10init_zerosPPfi, .Lfunc_end2-_Z10init_zerosPPfi
	.cfi_endproc
                                        # -- End function
	.globl	_Z16Make1DfloatArrayi           # -- Begin function _Z16Make1DfloatArrayi
	.type	_Z16Make1DfloatArrayi,@function
_Z16Make1DfloatArrayi:                  # @_Z16Make1DfloatArrayi
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %rbp, -16
	movl	%edi, %ebp
	movslq	%edi, %r14
	leaq	(,%r14,4), %rdi
	callq	malloc
	movq	%rax, %rbx
	testl	%r14d, %r14d
	jle	.LBB3_2
# %bb.1:                                # %.lr.ph.preheader
	movl	%ebp, %edx
	shlq	$2, %rdx
	movq	%rbx, %rdi
	xorl	%esi, %esi
	callq	memset@PLT
.LBB3_2:                                # %._crit_edge
	movq	%rbx, %rax
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end3:
	.size	_Z16Make1DfloatArrayi, .Lfunc_end3-_Z16Make1DfloatArrayi
	.cfi_endproc
                                        # -- End function
	.globl	_Z8printmatPPfi                 # -- Begin function _Z8printmatPPfi
	.type	_Z8printmatPPfi,@function
_Z8printmatPPfi:                        # @_Z8printmatPPfi
	.cfi_startproc
# %bb.0:
	testl	%esi, %esi
	jle	.LBB4_6
# %bb.1:                                # %.lr.ph14
	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
	pushq	%rax
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -40
	.cfi_offset %r12, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rdi, %rbx
	movl	%esi, %r14d
	xorl	%r15d, %r15d
.LBB4_2:                                # %.lr.ph
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB4_3 Depth 2
	movl	$10, %edi
	callq	putchar@PLT
	xorl	%r12d, %r12d
.LBB4_3:                                #   Parent Loop BB4_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movq	(%rbx,%r15,8), %rax
	xorps	%xmm0, %xmm0
	cvtss2sd	(%rax,%r12,4), %xmm0
	movl	$.L.str.1, %edi
	movb	$1, %al
	callq	printf
	incq	%r12
	cmpq	%r12, %r14
	jne	.LBB4_3
# %bb.4:                                # %._crit_edge
                                        #   in Loop: Header=BB4_2 Depth=1
	incq	%r15
	cmpq	%r14, %r15
	jne	.LBB4_2
# %bb.5:
	addq	$8, %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
	.cfi_restore %rbx
	.cfi_restore %r12
	.cfi_restore %r14
	.cfi_restore %r15
.LBB4_6:                                # %._crit_edge15
	movl	$10, %edi
	jmp	putchar@PLT                     # TAILCALL
.Lfunc_end4:
	.size	_Z8printmatPPfi, .Lfunc_end4-_Z8printmatPPfi
	.cfi_endproc
                                        # -- End function
	.globl	_Z11printtofilePPfiPc           # -- Begin function _Z11printtofilePPfiPc
	.type	_Z11printtofilePPfiPc,@function
_Z11printtofilePPfiPc:                  # @_Z11printtofilePPfiPc
	.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
	movl	%esi, %ebp
	movq	%rdi, %rbx
	movl	$.L.str.2, %esi
	movq	%rdx, %rdi
	callq	fopen
	testl	%ebp, %ebp
	jle	.LBB5_5
# %bb.1:                                # %.lr.ph16
	movq	%rax, %r14
	movl	%ebp, %r15d
	xorl	%r12d, %r12d
.LBB5_2:                                # %.lr.ph
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB5_3 Depth 2
	movl	$10, %edi
	movq	%r14, %rsi
	callq	fputc@PLT
	xorl	%r13d, %r13d
.LBB5_3:                                #   Parent Loop BB5_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movq	(%rbx,%r12,8), %rax
	xorps	%xmm0, %xmm0
	cvtss2sd	(%rax,%r13,4), %xmm0
	movl	$.L.str.3, %esi
	movq	%r14, %rdi
	movb	$1, %al
	callq	fprintf
	incq	%r13
	cmpq	%r13, %r15
	jne	.LBB5_3
# %bb.4:                                # %._crit_edge
                                        #   in Loop: Header=BB5_2 Depth=1
	incq	%r12
	cmpq	%r15, %r12
	jne	.LBB5_2
.LBB5_5:                                # %._crit_edge17
	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
	retq
.Lfunc_end5:
	.size	_Z11printtofilePPfiPc, .Lfunc_end5-_Z11printtofilePPfiPc
	.cfi_endproc
                                        # -- End function
	.globl	_Z13printtofile1DPfiPc          # -- Begin function _Z13printtofile1DPfiPc
	.type	_Z13printtofile1DPfiPc,@function
_Z13printtofile1DPfiPc:                 # @_Z13printtofile1DPfiPc
	.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
	movl	%esi, %ebp
	movq	%rdi, (%rsp)                    # 8-byte Spill
	movl	$.L.str.2, %esi
	movq	%rdx, %rdi
	callq	fopen
	testl	%ebp, %ebp
	jle	.LBB6_5
# %bb.1:                                # %.lr.ph.preheader.preheader
	movq	%rax, %r14
	movl	%ebp, %r15d
	xorl	%r12d, %r12d
	xorl	%ebp, %ebp
.LBB6_2:                                # %.lr.ph.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB6_3 Depth 2
	movl	$10, %edi
	movq	%r14, %rsi
	callq	fputc@PLT
	movslq	%r12d, %r12
	movq	(%rsp), %rax                    # 8-byte Reload
	leaq	(%rax,%r12,4), %rbx
	xorl	%r13d, %r13d
.LBB6_3:                                # %.lr.ph
                                        #   Parent Loop BB6_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	xorps	%xmm0, %xmm0
	cvtss2sd	(%rbx,%r13,4), %xmm0
	movl	$.L.str.1, %esi
	movq	%r14, %rdi
	movb	$1, %al
	callq	fprintf
	incq	%r13
	cmpl	%r13d, %r15d
	jne	.LBB6_3
# %bb.4:                                # %._crit_edge
                                        #   in Loop: Header=BB6_2 Depth=1
	incl	%ebp
	addq	%r13, %r12
	cmpl	%r15d, %ebp
	jne	.LBB6_2
.LBB6_5:                                # %._crit_edge20
	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
	retq
.Lfunc_end6:
	.size	_Z13printtofile1DPfiPc, .Lfunc_end6-_Z13printtofile1DPfiPc
	.cfi_endproc
                                        # -- End function
	.globl	_Z6freeseiPPf                   # -- Begin function _Z6freeseiPPf
	.type	_Z6freeseiPPf,@function
_Z6freeseiPPf:                          # @_Z6freeseiPPf
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rsi, %rbx
	testl	%edi, %edi
	jle	.LBB7_3
# %bb.1:                                # %.lr.ph.preheader
	movl	%edi, %r14d
	xorl	%r15d, %r15d
.LBB7_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movq	(%rbx,%r15,8), %rdi
	callq	free
	incq	%r15
	cmpq	%r15, %r14
	jne	.LBB7_2
.LBB7_3:                                # %._crit_edge
	movq	%rbx, %rdi
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	jmp	free                            # TAILCALL
.Lfunc_end7:
	.size	_Z6freeseiPPf, .Lfunc_end7-_Z6freeseiPPf
	.cfi_endproc
                                        # -- End function
	.globl	main                            # -- Begin function main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$88, %rsp
	.cfi_def_cfa_offset 144
	.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	$100, 44(%rsp)
	movl	$100, %edi
	movl	$100, %esi
	callq	_Z16Make2DfloatArrayii
	movq	%rax, 8(%rsp)                   # 8-byte Spill
	movl	$100, %edi
	movl	$100, %esi
	callq	_Z16Make2DfloatArrayii
	movq	%rax, %r14
	movl	$100, %edi
	movl	$100, %esi
	callq	_Z16Make2DfloatArrayii
	movq	%rax, %r15
	leaq	64(%rsp), %rdi
	callq	hipEventCreate
	leaq	32(%rsp), %rdi
	callq	hipEventCreate
	leaq	56(%rsp), %rdi
	callq	hipEventCreate
	leaq	48(%rsp), %rdi
	callq	hipEventCreate
	xorl	%ebx, %ebx
.LBB8_1:                                # %._crit_edge.i
                                        # =>This Inner Loop Header: Depth=1
	movq	(%r15,%rbx,8), %rdi
	movl	$400, %edx                      # imm = 0x190
	xorl	%esi, %esi
	callq	memset@PLT
	incq	%rbx
	cmpq	$100, %rbx
	jne	.LBB8_1
# %bb.2:                                # %_Z10init_zerosPPfi.exit
	movl	$1, %edi
	movl	$40000, %esi                    # imm = 0x9C40
	callq	calloc@PLT
	movq	%rax, %r12
	movl	$1, %edi
	movl	$40000, %esi                    # imm = 0x9C40
	callq	calloc@PLT
	movq	%rax, %r13
	movl	$1, %edi
	movl	$40000, %esi                    # imm = 0x9C40
	callq	calloc@PLT
	movq	%rax, %rbp
	xorl	%ebx, %ebx
	movl	$.L.str.4, %edi
	xorl	%eax, %eax
	callq	printf
	movl	$.L.str.5, %edx
	movq	8(%rsp), %rdi                   # 8-byte Reload
	movl	$100, %esi
	callq	_Z11printtofilePPfiPc
	movl	$.L.str.6, %edx
	movq	%r14, %rdi
	movl	$100, %esi
	callq	_Z11printtofilePPfiPc
	movl	$.L.str.7, %edx
	movq	%r15, %rdi
	movl	$100, %esi
	callq	_Z11printtofilePPfiPc
	movq	8(%rsp), %r11                   # 8-byte Reload
	xorl	%eax, %eax
.LBB8_3:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB8_4 Depth 2
	movq	(%r11,%rbx,8), %rcx
	movq	(%r14,%rbx,8), %rdx
	movq	(%r15,%rbx,8), %rsi
	cltq
	leaq	(%r12,%rax,4), %r8
	leaq	(,%rax,4), %r9
	addq	%r13, %r9
	leaq	(,%rax,4), %r10
	addq	%rbp, %r10
	xorl	%edi, %edi
.LBB8_4:                                #   Parent Loop BB8_3 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movss	(%rcx,%rdi,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, (%r8,%rdi,4)
	movss	(%rdx,%rdi,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, (%r9,%rdi,4)
	movss	(%rsi,%rdi,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, (%r10,%rdi,4)
	incq	%rdi
	cmpq	$100, %rdi
	jne	.LBB8_4
# %bb.5:                                #   in Loop: Header=BB8_3 Depth=1
	incq	%rbx
	addq	%rdi, %rax
	cmpq	$100, %rbx
	jne	.LBB8_3
# %bb.6:
	movq	64(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	leaq	24(%rsp), %rdi
	movl	$40000, %esi                    # imm = 0x9C40
	callq	hipMalloc
	leaq	16(%rsp), %rdi
	movl	$40000, %esi                    # imm = 0x9C40
	callq	hipMalloc
	movq	%rsp, %rdi
	movl	$40000, %esi                    # imm = 0x9C40
	callq	hipMalloc
	leaq	72(%rsp), %rbx
	movl	$4, %esi
	movq	%rbx, %rdi
	callq	hipMalloc
	leaq	24(%rsp), %rax
	movq	(%rax), %rdi
	movl	$40000, %edx                    # imm = 0x9C40
	movq	%r12, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	leaq	16(%rsp), %rax
	movq	(%rax), %rdi
	movl	$40000, %edx                    # imm = 0x9C40
	movq	%r13, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	movq	%rsp, %rax
	movq	(%rax), %rdi
	movl	$40000, %edx                    # imm = 0x9C40
	movq	%rbp, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	movq	(%rbx), %rdi
	leaq	44(%rsp), %rsi
	movl	$4, %edx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	56(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movabsq	$21474836485, %rdi              # imm = 0x500000005
	movabsq	$85899345940, %rdx              # imm = 0x1400000014
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB8_8
# %bb.7:
	movq	24(%rsp), %rdi
	movq	16(%rsp), %rsi
	movq	(%rsp), %rdx
	movl	$100, %ecx
	callq	_Z23__device_stub__multiplyPfS_S_i
.LBB8_8:
	movq	48(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	(%rsp), %rsi
	movl	$40000, %edx                    # imm = 0x9C40
	movq	%rbp, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	movq	32(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	32(%rsp), %rdi
	callq	hipEventSynchronize
	movq	64(%rsp), %rsi
	movq	32(%rsp), %rdx
	leaq	84(%rsp), %rbx
	movq	%rbx, %rdi
	callq	hipEventElapsedTime
	movq	56(%rsp), %rsi
	movq	48(%rsp), %rdx
	leaq	40(%rsp), %rdi
	callq	hipEventElapsedTime
	cvtss2sd	(%rbx), %xmm0
	movl	$.L.str.8, %edi
	movb	$1, %al
	callq	printf
	leaq	40(%rsp), %rax
	xorps	%xmm0, %xmm0
	cvtss2sd	(%rax), %xmm0
	movl	$.L.str.9, %edi
	movb	$1, %al
	callq	printf
	movl	$.L.str.10, %edx
	movq	%rbp, %rdi
	movl	$100, %esi
	callq	_Z13printtofile1DPfiPc
	movq	24(%rsp), %rdi
	callq	hipFree
	movq	16(%rsp), %rdi
	callq	hipFree
	movq	(%rsp), %rdi
	callq	hipFree
	movq	72(%rsp), %rdi
	callq	hipFree
	movl	$100, %edi
	movq	8(%rsp), %rsi                   # 8-byte Reload
	callq	_Z6freeseiPPf
	movl	$100, %edi
	movq	%r14, %rsi
	callq	_Z6freeseiPPf
	movl	$100, %edi
	movq	%r15, %rsi
	callq	_Z6freeseiPPf
	movq	%r12, %rdi
	callq	free
	movq	%r13, %rdi
	callq	free
	movq	%rbp, %rdi
	callq	free
	xorl	%eax, %eax
	addq	$88, %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_end8:
	.size	main, .Lfunc_end8-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	.LBB9_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB9_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z8multiplyPfS_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_end9:
	.size	__hip_module_ctor, .Lfunc_end9-__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	.LBB10_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
.LBB10_2:
	retq
.Lfunc_end10:
	.size	__hip_module_dtor, .Lfunc_end10-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	_Z8multiplyPfS_S_i,@object      # @_Z8multiplyPfS_S_i
	.section	.rodata,"a",@progbits
	.globl	_Z8multiplyPfS_S_i
	.p2align	3, 0x0
_Z8multiplyPfS_S_i:
	.quad	_Z23__device_stub__multiplyPfS_S_i
	.size	_Z8multiplyPfS_S_i, 8

	.type	.L.str.1,@object                # @.str.1
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.1:
	.asciz	"%f \t"
	.size	.L.str.1, 5

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"wt"
	.size	.L.str.2, 3

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

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"\n Everything initialized"
	.size	.L.str.4, 25

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"M1.txt"
	.size	.L.str.5, 7

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"M2.txt"
	.size	.L.str.6, 7

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"Prod.txt"
	.size	.L.str.7, 9

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"\nTime for kernel with data transfer = %f ms \n"
	.size	.L.str.8, 46

	.type	.L.str.9,@object                # @.str.9
.L.str.9:
	.asciz	"\nTime for kernel without data transfer = %f ms \n"
	.size	.L.str.9, 49

	.type	.L.str.10,@object               # @.str.10
.L.str.10:
	.asciz	"Prod_result.txt"
	.size	.L.str.10, 16

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z8multiplyPfS_S_i"
	.size	.L__unnamed_1, 19

	.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 _Z23__device_stub__multiplyPfS_S_i
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z8multiplyPfS_S_i
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z8multiplyPfS_S_i      ; -- Begin function _Z8multiplyPfS_S_i
	.globl	_Z8multiplyPfS_S_i
	.p2align	8
	.type	_Z8multiplyPfS_S_i,@function
_Z8multiplyPfS_S_i:                     ; @_Z8multiplyPfS_S_i
; %bb.0:
	s_clause 0x1
	s_load_b32 s3, s[0:1], 0x2c
	s_load_b32 s2, s[0:1], 0x18
	v_bfe_u32 v1, v0, 10, 10
	s_clause 0x1
	s_load_b128 s[4:7], s[0:1], 0x0
	s_load_b64 s[0:1], s[0:1], 0x10
	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_and_b32_e32 v3, 0x3ff, v0
	s_cmp_lt_i32 s2, 1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_mad_u64_u32 v[0:1], null, s14, s3, v[3:4]
	v_mul_lo_u32 v1, v2, s2
	s_cbranch_scc1 .LBB0_3
; %bb.1:                                ; %.lr.ph.preheader
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_4)
	v_ashrrev_i32_e32 v2, 31, v1
	v_mov_b32_e32 v6, 0
	v_mov_b32_e32 v4, v0
	s_mov_b32 s3, s2
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[2:3], 2, v[1:2]
	v_add_co_u32 v2, vcc_lo, s4, v2
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v3, vcc_lo, s5, v3, vcc_lo
.LBB0_2:                                ; %.lr.ph
                                        ; =>This Inner Loop Header: Depth=1
	v_ashrrev_i32_e32 v5, 31, v4
	s_add_i32 s3, s3, -1
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	s_cmp_eq_u32 s3, 0
	v_lshlrev_b64 v[7:8], 2, v[4:5]
	v_add_nc_u32_e32 v4, s2, v4
	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 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_scc0 .LBB0_2
	s_branch .LBB0_4
.LBB0_3:
	v_mov_b32_e32 v6, 0
.LBB0_4:                                ; %Flow40
	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], v6, off
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z8multiplyPfS_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	_Z8multiplyPfS_S_i, .Lfunc_end0-_Z8multiplyPfS_S_i
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 308
; 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:           _Z8multiplyPfS_S_i
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z8multiplyPfS_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
