/*
 *  Copyright 2015 NVIDIA Corporation
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

#include <stdio.h>

/* macro to index a 1D memory array with 2D indices in column-major order */

#define INDX( row, col, ld ) ( ( (col) * (ld) ) + (row) )

/* linear size of the matrices */

#define SIZE 1024


/* CPU matrix multiply function */

void host_dgemm( const int m, const int n, const int k, 
                 double const * const a, double const * const b, double *c )
{
	
/* 
 *  naive matrix multiplication loops go here.  triply nested for loop
 *  C = A * B where A and B are matrices
 *  C(i,j) = SUM( A(i,k) * B(k,j), over the index "k", where 0 <= k < (SIZE-1) )   
 */     
        

/* insert code here */

for( int j = 0; j < n; j++ )
{
  for( int i = 0; i < m; i++ )
  {
    for( int koff = 0; koff < k; koff++ )
    {
      c[INDX(i, j, m)] += a[INDX( i, koff, m )] * b[INDX( koff, j, n )];
    } /* end for koff */
  } /* end for i */
} /* end for j */

} /* end host_dgemm */

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

  int size = SIZE;

  fprintf(stdout, "Matrix size is %d\n",size);

/* declare host pointers */

  double *h_a, *h_b, *h_cdef;
 
  size_t numbytes = size * size * sizeof( double );

/* allocate host pointers */

  h_a = (double *) malloc( numbytes );
  if( h_a == NULL )
  {
    fprintf(stderr,"Error in host malloc\n");
    return 911;
  }

  h_b = (double *) malloc( numbytes );
  if( h_b == NULL )
  {
    fprintf(stderr,"Error in host malloc\n");
    return 911;
  }

  h_cdef = (double *) malloc( numbytes );
  if( h_cdef == NULL )
  {
    fprintf(stderr,"Error in host malloc\n");
    return 911;
  }

/* set C to zero */

  memset( h_cdef, 0, numbytes );

  fprintf( stdout, "Total memory required is %lf MB\n", 
       3.0 * (double) numbytes / 1000000.0 );

/* initialize A and B on the host */

  for( int i = 0; i < size * size; i++ )
  {
    h_a[i] = double( rand() ) / ( double(RAND_MAX) + 1.0 );
    h_b[i] = double( rand() ) / ( double(RAND_MAX) + 1.0 );
  }

/* start timers */

  cudaEvent_t start, stop;
  cudaEventCreate( &start );
  cudaEventCreate( &stop );

  cudaEventRecord( start, 0 );

/* call host dgemm */

  host_dgemm( size, size, size, h_a, h_b, h_cdef );

/* stop the timers */

  cudaEventRecord( stop, 0 );
  cudaEventSynchronize( stop );
  float elapsedTime;
  cudaEventElapsedTime( &elapsedTime, start, stop );

/* print the results */

  fprintf(stdout, "Total time CPU is %f sec\n", elapsedTime / 1000.0f );
  fprintf(stdout, "Performance is %f GFlop/s\n", 
    2.0 * (double) size * (double) size * (double) size / 
    ( (double) elapsedTime / 1000.0 ) * 1.e-9 );

/* cleanup */

  free( h_a );
  free( h_b );
  free( h_cdef );

  cudaError_t cudaStatus = cudaDeviceReset();
  if (cudaStatus != cudaSuccess) {
      fprintf(stderr, "cudaDeviceReset failed!");
      return 1;
  }

  return 0;
}

	.file	"tmpxft_0029848a_00000000-6_kernel.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2031:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2031:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z10host_dgemmiiiPKdS0_Pd
	.type	_Z10host_dgemmiiiPKdS0_Pd, @function
_Z10host_dgemmiiiPKdS0_Pd:
.LFB2027:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	xorl	%r11d, %r11d
	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
	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
	movslq	%edi, %rbx
	xorl	%edi, %edi
	movq	%rbx, %rax
	salq	$3, %rbx
	movq	%rcx, -8(%rsp)
.L3:
	cmpl	%esi, %r11d
	jge	.L2
	movslq	%edi, %rdx
	movq	-8(%rsp), %r10
	leaq	(%r8,%rdx,8), %r15
	xorl	%edx, %edx
.L8:
	cmpl	%eax, %edx
	jge	.L5
	leal	(%rdx,%rbp), %ecx
	movq	%r10, %r13
	movslq	%ecx, %rcx
	leaq	(%r9,%rcx,8), %r14
	xorl	%ecx, %ecx
.L6:
	cmpl	%ecx, %r12d
	jle	.L11
	movsd	0(%r13), %xmm0
	mulsd	(%r15,%rcx,8), %xmm0
	addq	%rbx, %r13
	incq	%rcx
	addsd	(%r14), %xmm0
	movsd	%xmm0, (%r14)
	jmp	.L6
.L11:
	incl	%edx
	addq	$8, %r10
	jmp	.L8
.L5:
	incl	%r11d
	addl	%eax, %ebp
	addl	%esi, %edi
	jmp	.L3
.L2:
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2027:
	.size	_Z10host_dgemmiiiPKdS0_Pd, .-_Z10host_dgemmiiiPKdS0_Pd
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"Matrix size is %d\n"
.LC1:
	.string	"Error in host malloc\n"
.LC3:
	.string	"Total memory required is %lf MB\n"
.LC6:
	.string	"Total time CPU is %f sec\n"
.LC10:
	.string	"Performance is %f GFlop/s\n"
.LC11:
	.string	"cudaDeviceReset failed!"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2028:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	movl	$1024, %ecx
	movl	$2, %esi
	leaq	.LC0(%rip), %rdx
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$40, %rsp
	.cfi_def_cfa_offset 80
	movq	stdout(%rip), %rdi
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	movl	$8388608, %edi
	call	malloc@PLT
	testq	%rax, %rax
	je	.L24
	movl	$8388608, %edi
	movq	%rax, %r12
	call	malloc@PLT
	movq	%rax, %rbp
	testq	%rax, %rax
	jne	.L15
.L24:
	movq	stderr(%rip), %rdi
	leaq	.LC1(%rip), %rdx
	movl	$2, %esi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	movl	$911, %eax
	jmp	.L12
.L15:
	movl	$8388608, %edi
	call	malloc@PLT
	movq	%rax, %rbx
	testq	%rax, %rax
	je	.L24
	xorl	%eax, %eax
	movl	$2097152, %ecx
	movq	%rbx, %rdi
	movl	$2, %esi
	rep stosl
	movsd	.LC2(%rip), %xmm0
	movb	$1, %al
	xorl	%r13d, %r13d
	movq	stdout(%rip), %rdi
	leaq	.LC3(%rip), %rdx
	call	__fprintf_chk@PLT
.L18:
	call	rand@PLT
	cvtsi2sdl	%eax, %xmm0
	mulsd	.LC4(%rip), %xmm0
	movsd	%xmm0, (%r12,%r13)
	call	rand@PLT
	cvtsi2sdl	%eax, %xmm0
	mulsd	.LC4(%rip), %xmm0
	movsd	%xmm0, 0(%rbp,%r13)
	addq	$8, %r13
	cmpq	$8388608, %r13
	jne	.L18
	leaq	8(%rsp), %rdi
	call	cudaEventCreate@PLT
	leaq	16(%rsp), %rdi
	call	cudaEventCreate@PLT
	movq	8(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	%rbx, %r9
	movq	%rbp, %r8
	movq	%r12, %rcx
	movl	$1024, %edx
	movl	$1024, %esi
	movl	$1024, %edi
	call	_Z10host_dgemmiiiPKdS0_Pd
	movq	16(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	16(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movq	16(%rsp), %rdx
	movq	8(%rsp), %rsi
	leaq	4(%rsp), %rdi
	call	cudaEventElapsedTime@PLT
	movq	stdout(%rip), %rdi
	leaq	.LC6(%rip), %rdx
	movb	$1, %al
	movl	$2, %esi
	movss	4(%rsp), %xmm0
	divss	.LC5(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	call	__fprintf_chk@PLT
	movsd	.LC8(%rip), %xmm0
	movb	$1, %al
	cvtss2sd	4(%rsp), %xmm1
	divsd	.LC7(%rip), %xmm1
	movq	stdout(%rip), %rdi
	movl	$2, %esi
	leaq	.LC10(%rip), %rdx
	divsd	%xmm1, %xmm0
	mulsd	.LC9(%rip), %xmm0
	call	__fprintf_chk@PLT
	movq	%r12, %rdi
	call	free@PLT
	movq	%rbp, %rdi
	call	free@PLT
	movq	%rbx, %rdi
	call	free@PLT
	call	cudaDeviceReset@PLT
	movl	%eax, %edx
	xorl	%eax, %eax
	testl	%edx, %edx
	je	.L12
	movq	stderr(%rip), %rdi
	leaq	.LC11(%rip), %rdx
	movl	$2, %esi
	call	__fprintf_chk@PLT
	movl	$1, %eax
.L12:
	movq	24(%rsp), %rdx
	subq	%fs:40, %rdx
	je	.L19
	call	__stack_chk_fail@PLT
.L19:
	addq	$40, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2028:
	.size	main, .-main
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2054:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	movq	%rax, %rdi
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rdx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE2054:
	.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
.LC2:
	.long	1896932436
	.long	1077488243
	.align 8
.LC4:
	.long	0
	.long	1040187392
	.section	.rodata.cst4,"aM",@progbits,4
	.align 4
.LC5:
	.long	1148846080
	.section	.rodata.cst8
	.align 8
.LC7:
	.long	0
	.long	1083129856
	.align 8
.LC8:
	.long	0
	.long	1105199104
	.align 8
.LC9:
	.long	-400107883
	.long	1041313291
	.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:

/*
 *  Copyright 2015 NVIDIA Corporation
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */


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

/* macro to index a 1D memory array with 2D indices in column-major order */

#define INDX( row, col, ld ) ( ( (col) * (ld) ) + (row) )

/* linear size of the matrices */

#define SIZE 1024


/* CPU matrix multiply function */

void host_dgemm( const int m, const int n, const int k, 
                 double const * const a, double const * const b, double *c )
{
	
/* 
 *  naive matrix multiplication loops go here.  triply nested for loop
 *  C = A * B where A and B are matrices
 *  C(i,j) = SUM( A(i,k) * B(k,j), over the index "k", where 0 <= k < (SIZE-1) )   
 */     
        

/* insert code here */

for( int j = 0; j < n; j++ )
{
  for( int i = 0; i < m; i++ )
  {
    for( int koff = 0; koff < k; koff++ )
    {
      c[INDX(i, j, m)] += a[INDX( i, koff, m )] * b[INDX( koff, j, n )];
    } /* end for koff */
  } /* end for i */
} /* end for j */

} /* end host_dgemm */

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

  int size = SIZE;

  fprintf(stdout, "Matrix size is %d\n",size);

/* declare host pointers */

  double *h_a, *h_b, *h_cdef;
 
  size_t numbytes = size * size * sizeof( double );

/* allocate host pointers */

  h_a = (double *) malloc( numbytes );
  if( h_a == NULL )
  {
    fprintf(stderr,"Error in host malloc\n");
    return 911;
  }

  h_b = (double *) malloc( numbytes );
  if( h_b == NULL )
  {
    fprintf(stderr,"Error in host malloc\n");
    return 911;
  }

  h_cdef = (double *) malloc( numbytes );
  if( h_cdef == NULL )
  {
    fprintf(stderr,"Error in host malloc\n");
    return 911;
  }

/* set C to zero */

  memset( h_cdef, 0, numbytes );

  fprintf( stdout, "Total memory required is %lf MB\n", 
       3.0 * (double) numbytes / 1000000.0 );

/* initialize A and B on the host */

  for( int i = 0; i < size * size; i++ )
  {
    h_a[i] = double( rand() ) / ( double(RAND_MAX) + 1.0 );
    h_b[i] = double( rand() ) / ( double(RAND_MAX) + 1.0 );
  }

/* start timers */

  hipEvent_t start, stop;
  hipEventCreate( &start );
  hipEventCreate( &stop );

  hipEventRecord( start, 0 );

/* call host dgemm */

  host_dgemm( size, size, size, h_a, h_b, h_cdef );

/* stop the timers */

  hipEventRecord( stop, 0 );
  hipEventSynchronize( stop );
  float elapsedTime;
  hipEventElapsedTime( &elapsedTime, start, stop );

/* print the results */

  fprintf(stdout, "Total time CPU is %f sec\n", elapsedTime / 1000.0f );
  fprintf(stdout, "Performance is %f GFlop/s\n", 
    2.0 * (double) size * (double) size * (double) size / 
    ( (double) elapsedTime / 1000.0 ) * 1.e-9 );

/* cleanup */

  free( h_a );
  free( h_b );
  free( h_cdef );

  hipError_t cudaStatus = hipDeviceReset();
  if (cudaStatus != hipSuccess) {
      fprintf(stderr, "hipDeviceReset failed!");
      return 1;
  }

  return 0;
}

	.text
	.file	"kernel.hip"
	.globl	_Z10host_dgemmiiiPKdS0_Pd       # -- Begin function _Z10host_dgemmiiiPKdS0_Pd
	.type	_Z10host_dgemmiiiPKdS0_Pd,@function
_Z10host_dgemmiiiPKdS0_Pd:              # @_Z10host_dgemmiiiPKdS0_Pd
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%r9, -8(%rsp)                   # 8-byte Spill
	movq	%r8, -16(%rsp)                  # 8-byte Spill
	movq	%rcx, -24(%rsp)                 # 8-byte Spill
	testl	%esi, %esi
	jle	.LBB0_9
# %bb.1:                                # %.preheader24.lr.ph
	movslq	%edi, %rax
	movl	%esi, %r10d
	movl	%eax, %r11d
	movl	%edx, %ebx
	movq	%rax, -32(%rsp)                 # 8-byte Spill
	leaq	(,%rax,8), %r14
	xorl	%r15d, %r15d
	xorl	%r12d, %r12d
.LBB0_2:                                # %.preheader24
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB0_4 Depth 2
                                        #       Child Loop BB0_6 Depth 3
	testl	%edi, %edi
	jle	.LBB0_8
# %bb.3:                                # %.preheader.lr.ph
                                        #   in Loop: Header=BB0_2 Depth=1
	movl	%r15d, %eax
	movq	-16(%rsp), %rcx                 # 8-byte Reload
	leaq	(%rcx,%rax,8), %r13
	movq	%r12, %rax
	imulq	-32(%rsp), %rax                 # 8-byte Folded Reload
	movq	-8(%rsp), %rcx                  # 8-byte Reload
	leaq	(%rcx,%rax,8), %rbp
	movq	-24(%rsp), %r8                  # 8-byte Reload
	xorl	%r9d, %r9d
.LBB0_4:                                # %.preheader
                                        #   Parent Loop BB0_2 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB0_6 Depth 3
	testl	%edx, %edx
	jle	.LBB0_7
# %bb.5:                                # %.lr.ph
                                        #   in Loop: Header=BB0_4 Depth=2
	movsd	(%rbp,%r9,8), %xmm0             # xmm0 = mem[0],zero
	movq	%r8, %rcx
	xorl	%eax, %eax
.LBB0_6:                                #   Parent Loop BB0_2 Depth=1
                                        #     Parent Loop BB0_4 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	movsd	(%rcx), %xmm1                   # xmm1 = mem[0],zero
	mulsd	(%r13,%rax,8), %xmm1
	addsd	%xmm1, %xmm0
	movsd	%xmm0, (%rbp,%r9,8)
	incq	%rax
	addq	%r14, %rcx
	cmpq	%rax, %rbx
	jne	.LBB0_6
.LBB0_7:                                # %._crit_edge
                                        #   in Loop: Header=BB0_4 Depth=2
	incq	%r9
	addq	$8, %r8
	cmpq	%r11, %r9
	jne	.LBB0_4
.LBB0_8:                                # %._crit_edge27
                                        #   in Loop: Header=BB0_2 Depth=1
	incq	%r12
	addl	%esi, %r15d
	cmpq	%r10, %r12
	jne	.LBB0_2
.LBB0_9:                                # %._crit_edge29
	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	_Z10host_dgemmiiiPKdS0_Pd, .Lfunc_end0-_Z10host_dgemmiiiPKdS0_Pd
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI1_0:
	.quad	0x40392a737110e454              # double 25.165824000000001
.LCPI1_1:
	.quad	0x3e00000000000000              # double 4.6566128730773926E-10
.LCPI1_3:
	.quad	0x408f400000000000              # double 1000
.LCPI1_4:
	.quad	0x41e0000000000000              # double 2147483648
.LCPI1_5:
	.quad	0x3e112e0be826d695              # double 1.0000000000000001E-9
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0
.LCPI1_2:
	.long	0x447a0000                      # float 1000
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$32, %rsp
	.cfi_def_cfa_offset 80
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	stdout(%rip), %rdi
	movl	$.L.str, %esi
	movl	$1024, %edx                     # imm = 0x400
	xorl	%eax, %eax
	callq	fprintf
	movl	$8388608, %edi                  # imm = 0x800000
	callq	malloc
	testq	%rax, %rax
	je	.LBB1_1
# %bb.2:
	movq	%rax, %rbx
	movl	$8388608, %edi                  # imm = 0x800000
	callq	malloc
	testq	%rax, %rax
	je	.LBB1_1
# %bb.3:
	movq	%rax, %r14
	movl	$1, %edi
	movl	$8388608, %esi                  # imm = 0x800000
	callq	calloc@PLT
	testq	%rax, %rax
	je	.LBB1_1
# %bb.4:
	movq	%rax, %r15
	movq	stdout(%rip), %rdi
	movsd	.LCPI1_0(%rip), %xmm0           # xmm0 = mem[0],zero
	movl	$.L.str.2, %esi
	movb	$1, %al
	callq	fprintf
	xorl	%r12d, %r12d
.LBB1_5:                                # =>This Inner Loop Header: Depth=1
	callq	rand
	xorps	%xmm0, %xmm0
	cvtsi2sd	%eax, %xmm0
	movsd	.LCPI1_1(%rip), %xmm1           # xmm1 = mem[0],zero
	mulsd	%xmm1, %xmm0
	movsd	%xmm0, (%rbx,%r12,8)
	callq	rand
	xorps	%xmm0, %xmm0
	cvtsi2sd	%eax, %xmm0
	mulsd	.LCPI1_1(%rip), %xmm0
	movsd	%xmm0, (%r14,%r12,8)
	incq	%r12
	cmpq	$1048576, %r12                  # imm = 0x100000
	jne	.LBB1_5
# %bb.6:
	leaq	16(%rsp), %r12
	movq	%r12, %rdi
	callq	hipEventCreate
	leaq	8(%rsp), %rdi
	callq	hipEventCreate
	movq	(%r12), %rdi
	xorl	%r12d, %r12d
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	%r14, %rax
.LBB1_7:                                # %.preheader24.i
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_8 Depth 2
                                        #       Child Loop BB1_9 Depth 3
	movq	%r12, %rcx
	shlq	$13, %rcx
	addq	%r15, %rcx
	movq	%rbx, %rdx
	xorl	%esi, %esi
.LBB1_8:                                # %.preheader.i
                                        #   Parent Loop BB1_7 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB1_9 Depth 3
	movsd	(%rcx,%rsi,8), %xmm0            # xmm0 = mem[0],zero
	movq	%rdx, %rdi
	xorl	%r8d, %r8d
.LBB1_9:                                #   Parent Loop BB1_7 Depth=1
                                        #     Parent Loop BB1_8 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	movsd	(%rdi), %xmm1                   # xmm1 = mem[0],zero
	mulsd	(%rax,%r8,8), %xmm1
	addsd	%xmm1, %xmm0
	incq	%r8
	addq	$8192, %rdi                     # imm = 0x2000
	cmpq	$1024, %r8                      # imm = 0x400
	jne	.LBB1_9
# %bb.10:                               # %._crit_edge.i
                                        #   in Loop: Header=BB1_8 Depth=2
	movsd	%xmm0, (%rcx,%rsi,8)
	incq	%rsi
	addq	$8, %rdx
	cmpq	$1024, %rsi                     # imm = 0x400
	jne	.LBB1_8
# %bb.11:                               # %._crit_edge27.i
                                        #   in Loop: Header=BB1_7 Depth=1
	incq	%r12
	addq	$8192, %rax                     # imm = 0x2000
	cmpq	$1024, %r12                     # imm = 0x400
	jne	.LBB1_7
# %bb.12:                               # %_Z10host_dgemmiiiPKdS0_Pd.exit
	movq	8(%rsp), %rdi
	xorl	%r12d, %r12d
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	8(%rsp), %rdi
	callq	hipEventSynchronize
	movq	16(%rsp), %rsi
	movq	8(%rsp), %rdx
	leaq	28(%rsp), %r13
	movq	%r13, %rdi
	callq	hipEventElapsedTime
	movq	stdout(%rip), %rdi
	movss	(%r13), %xmm0                   # xmm0 = mem[0],zero,zero,zero
	divss	.LCPI1_2(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	movl	$.L.str.3, %esi
	movb	$1, %al
	callq	fprintf
	movq	stdout(%rip), %rdi
	xorps	%xmm1, %xmm1
	cvtss2sd	(%r13), %xmm1
	divsd	.LCPI1_3(%rip), %xmm1
	movsd	.LCPI1_4(%rip), %xmm0           # xmm0 = mem[0],zero
	divsd	%xmm1, %xmm0
	mulsd	.LCPI1_5(%rip), %xmm0
	movl	$.L.str.4, %esi
	movb	$1, %al
	callq	fprintf
	movq	%rbx, %rdi
	callq	free
	movq	%r14, %rdi
	callq	free
	movq	%r15, %rdi
	callq	free
	callq	hipDeviceReset
	testl	%eax, %eax
	jne	.LBB1_13
.LBB1_14:
	movl	%r12d, %eax
	addq	$32, %rsp
	.cfi_def_cfa_offset 48
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.LBB1_1:
	.cfi_def_cfa_offset 80
	movq	stderr(%rip), %rcx
	movl	$.L.str.1, %edi
	movl	$21, %esi
	movl	$1, %edx
	callq	fwrite@PLT
	movl	$911, %r12d                     # imm = 0x38F
	jmp	.LBB1_14
.LBB1_13:
	movq	stderr(%rip), %rcx
	movl	$.L.str.5, %edi
	movl	$22, %esi
	movl	$1, %edx
	callq	fwrite@PLT
	movl	$1, %r12d
	jmp	.LBB1_14
.Lfunc_end1:
	.size	main, .Lfunc_end1-main
	.cfi_endproc
                                        # -- End function
	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"Matrix size is %d\n"
	.size	.L.str, 19

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"Error in host malloc\n"
	.size	.L.str.1, 22

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"Total memory required is %lf MB\n"
	.size	.L.str.2, 33

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"Total time CPU is %f sec\n"
	.size	.L.str.3, 26

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"Performance is %f GFlop/s\n"
	.size	.L.str.4, 27

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"hipDeviceReset failed!"
	.size	.L.str.5, 23

	.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 __hip_cuid_

	.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_
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.amdgpu_metadata
---
amdhsa.kernels:  []
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
