#include "fastgemm.cuh"
using namespace std;
int main(int argc, char const *argv[]) {

  #ifdef DEBUG
  struct cudaDeviceProp prop;
  int device = 0;
  cudaGetDeviceProperties(&prop, device);
  cout << "Device name: " << prop.name << endl;
  cout << "Total Global Memory (bytes): " << prop.totalGlobalMem << endl;
  cout << "Shared Memory per Block (bytes): " << prop.sharedMemPerBlock << endl;
  cout << "L1 Cache Size (bytes): 16000" << endl;
  cout << "L2 Cache Size (bytes): " << prop.l2CacheSize << endl;
  cout << "Cache Line Size (bytes): 128" << endl;
  cout << "Registers per Block: " << prop.regsPerBlock << endl;
  cout << "Warp Size: " << prop.warpSize << endl;
  cout << "Number of Warp Schedulers: 4" << endl;
  cout << "Max Threads per Block: " << prop.maxThreadsPerBlock << endl;
  cout << "Compute Capability: " << prop.major << endl;
  cout << "Clock Rate (kHz): " << prop.clockRate << endl;
  cout << "Number of SM: " << prop.multiProcessorCount << endl;
  #endif

  // 1) Run reference code <DEBUG means run dumb CPU, REAL means CUBLAS>
  #ifdef DEBUG
  // 
  // cout << "(M,N,K) = " << M << " " << N << " " << K << endl;
  //
  // float* C = (float*) malloc(sizeof(float) * M * N);
  // float* A = (float*) malloc(sizeof(float) * M * K);
  // float* B = (float*) malloc(sizeof(float) * K * N);
  //
  // for (int i = 0; i < M * N; i++)
  //   C[i] = 0.0;
  // for (int i = 0; i < M * K; i++)
  //   A[i] = (float) i;
  // for (int i = 0; i < M * N; i++)
  //   B[i] = (float) i;
  //
  // ref_mmul(C, A, B);
  //
  // cout << "Reference A: " << endl;
  // printMatrix(A,M,K);
  // cout << "Reference B: " << endl;
  // printMatrix(B,K,N);
  // cout << "Reference C: " << endl;
  // printMatrix(C,M,N);

  // 2) Pack Data for Kernel <THIS CHANGE AS THE CODE PROGRESSES>
  cout << "Start initializing device arrays" << endl;
  float * C_gpu;
  float4* A_gpu;
  float4* B_gpu;
  cudaMallocManaged(&C_gpu, sizeof(float) * (M * N));
  cudaMallocManaged(&A_gpu, sizeof(float4) * (M * K)/4);
  cudaMallocManaged(&B_gpu, sizeof(float4) * (K * N)/4);

  cout << "Start loading device arrays" << endl;
  for (int i = 0; i < (M * K)/4; i++)
    A_gpu[i] = make_float4(i*4.0 + 0.0, i*4.0 + 1.0, i*4.0 + 2.0,i*4.0 + 3.0);
  for (int i = 0; i < (K * N)/4; i++)
    B_gpu[i] = make_float4(i*4.0 + 0.0, i*4.0 + 1.0, i*4.0 + 2.0,i*4.0 + 3.0);

  cout << "Start fastgemm" << endl;
  launchFastGemm(C_gpu, A_gpu, B_gpu);

  printMatrix(C_gpu,M,N);

  // free(A);
  // free(B);
  // free(C);
  cudaFree(A_gpu);
  cudaFree(B_gpu);
  cudaFree(C_gpu);
  #endif

  #ifdef REAL
  // INSERT CUBLAS HERE
  #endif

  return 0;
}


	.file	"tmpxft_0026d302_00000000-6_main.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB3638:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE3638:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.align 2
	.type	_ZNSolsEPFRSoS_E.isra.0, @function
_ZNSolsEPFRSoS_E.isra.0:
.LFB4292:
	.cfi_startproc
	jmp	*%rsi
	.cfi_endproc
.LFE4292:
	.size	_ZNSolsEPFRSoS_E.isra.0, .-_ZNSolsEPFRSoS_E.isra.0
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"Device name: "
.LC1:
	.string	"Total Global Memory (bytes): "
.LC2:
	.string	"Shared Memory per Block (bytes): "
.LC3:
	.string	"L1 Cache Size (bytes): 16000"
.LC4:
	.string	"L2 Cache Size (bytes): "
.LC5:
	.string	"Cache Line Size (bytes): 128"
.LC6:
	.string	"Registers per Block: "
.LC7:
	.string	"Warp Size: "
.LC8:
	.string	"Number of Warp Schedulers: 4"
.LC9:
	.string	"Max Threads per Block: "
.LC10:
	.string	"Compute Capability: "
.LC11:
	.string	"Clock Rate (kHz): "
.LC12:
	.string	"Number of SM: "
.LC13:
	.string	"Start initializing device arrays"
.LC14:
	.string	"Start loading device arrays"
.LC20:
	.string	"Start fastgemm"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB3635:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	xorl	%esi, %esi
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	leaq	_ZSt4cout(%rip), %rbx
	subq	$1080, %rsp
	.cfi_def_cfa_offset 1104
	movq	%fs:40, %rax
	movq	%rax, 1064(%rsp)
	xorl	%eax, %eax
	leaq	32(%rsp), %rbp
	movq	%rbp, %rdi
	call	cudaGetDeviceProperties_v2@PLT
	leaq	.LC0(%rip), %rsi
	movq	%rbx, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%rbp, %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	leaq	.LC1(%rip), %rsi
	movq	%rbx, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	320(%rsp), %rsi
	movq	%rax, %rdi
	call	_ZNSo9_M_insertImEERSoT_@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	leaq	.LC2(%rip), %rsi
	movq	%rbx, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	328(%rsp), %rsi
	movq	%rax, %rdi
	call	_ZNSo9_M_insertImEERSoT_@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	leaq	.LC3(%rip), %rsi
	movq	%rbx, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	leaq	.LC4(%rip), %rsi
	movq	%rbx, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	648(%rsp), %esi
	movq	%rax, %rdi
	call	_ZNSolsEi@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	leaq	.LC5(%rip), %rsi
	movq	%rbx, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	leaq	.LC6(%rip), %rsi
	movq	%rbx, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	336(%rsp), %esi
	movq	%rax, %rdi
	call	_ZNSolsEi@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	leaq	.LC7(%rip), %rsi
	movq	%rbx, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	340(%rsp), %esi
	movq	%rax, %rdi
	call	_ZNSolsEi@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	leaq	.LC8(%rip), %rsi
	movq	%rbx, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	leaq	.LC9(%rip), %rsi
	movq	%rbx, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	352(%rsp), %esi
	movq	%rax, %rdi
	call	_ZNSolsEi@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	leaq	.LC10(%rip), %rsi
	movq	%rbx, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	392(%rsp), %esi
	movq	%rax, %rdi
	call	_ZNSolsEi@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	leaq	.LC11(%rip), %rsi
	movq	%rbx, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	380(%rsp), %esi
	movq	%rax, %rdi
	call	_ZNSolsEi@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	leaq	.LC12(%rip), %rsi
	movq	%rbx, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	420(%rsp), %esi
	movq	%rax, %rdi
	call	_ZNSolsEi@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	leaq	.LC13(%rip), %rsi
	movq	%rbx, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	leaq	8(%rsp), %rdi
	movl	$1, %edx
	movl	$49152, %esi
	call	cudaMallocManaged@PLT
	leaq	16(%rsp), %rdi
	movl	$1, %edx
	movl	$480, %esi
	call	cudaMallocManaged@PLT
	movl	$1, %edx
	leaq	24(%rsp), %rdi
	movl	$10240, %esi
	call	cudaMallocManaged@PLT
	leaq	.LC14(%rip), %rsi
	movq	%rbx, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	movq	16(%rsp), %rax
	xorl	%edx, %edx
	xorps	%xmm6, %xmm6
	movsd	.LC15(%rip), %xmm5
	movsd	.LC17(%rip), %xmm4
	movsd	.LC18(%rip), %xmm3
	movsd	.LC19(%rip), %xmm2
.L4:
	cvtsi2sdl	%edx, %xmm0
	incl	%edx
	addq	$16, %rax
	mulsd	%xmm5, %xmm0
	movaps	%xmm0, %xmm1
	addsd	%xmm6, %xmm1
	cvtsd2ss	%xmm1, %xmm1
	movss	%xmm1, -16(%rax)
	movaps	%xmm0, %xmm1
	addsd	%xmm4, %xmm1
	cvtsd2ss	%xmm1, %xmm1
	movss	%xmm1, -12(%rax)
	movaps	%xmm0, %xmm1
	addsd	%xmm2, %xmm0
	addsd	%xmm3, %xmm1
	cvtsd2ss	%xmm0, %xmm0
	movss	%xmm0, -4(%rax)
	cvtsd2ss	%xmm1, %xmm1
	movss	%xmm1, -8(%rax)
	cmpl	$30, %edx
	jne	.L4
	movq	24(%rsp), %rax
	xorl	%edx, %edx
	xorps	%xmm6, %xmm6
.L5:
	cvtsi2sdl	%edx, %xmm0
	incl	%edx
	addq	$16, %rax
	mulsd	%xmm5, %xmm0
	movaps	%xmm0, %xmm1
	addsd	%xmm6, %xmm1
	cvtsd2ss	%xmm1, %xmm1
	movss	%xmm1, -16(%rax)
	movaps	%xmm0, %xmm1
	addsd	%xmm4, %xmm1
	cvtsd2ss	%xmm1, %xmm1
	movss	%xmm1, -12(%rax)
	movaps	%xmm0, %xmm1
	addsd	%xmm2, %xmm0
	addsd	%xmm3, %xmm1
	cvtsd2ss	%xmm0, %xmm0
	movss	%xmm0, -4(%rax)
	cvtsd2ss	%xmm1, %xmm1
	movss	%xmm1, -8(%rax)
	cmpl	$640, %edx
	jne	.L5
	leaq	.LC20(%rip), %rsi
	movq	%rbx, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	movq	24(%rsp), %rdx
	movq	16(%rsp), %rsi
	movq	8(%rsp), %rdi
	call	_Z14launchFastGemmPfP6float4S1_@PLT
	movq	8(%rsp), %rdi
	movl	$512, %edx
	movl	$24, %esi
	call	_Z11printMatrixPfii@PLT
	movq	16(%rsp), %rdi
	call	cudaFree@PLT
	movq	24(%rsp), %rdi
	call	cudaFree@PLT
	movq	8(%rsp), %rdi
	call	cudaFree@PLT
	movq	1064(%rsp), %rax
	subq	%fs:40, %rax
	je	.L6
	call	__stack_chk_fail@PLT
.L6:
	addq	$1080, %rsp
	.cfi_def_cfa_offset 24
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3635:
	.size	main, .-main
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB3661:
	.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
.LFE3661:
	.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
.LC15:
	.long	0
	.long	1074790400
	.align 8
.LC17:
	.long	0
	.long	1072693248
	.align 8
.LC18:
	.long	0
	.long	1073741824
	.align 8
.LC19:
	.long	0
	.long	1074266112
	.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:


#include <hip/hip_runtime.h>
#include "fastgemm.cuh"
using namespace std;
int main(int argc, char const *argv[]) {

  #ifdef DEBUG
  struct hipDeviceProp_t prop;
  int device = 0;
  hipGetDeviceProperties(&prop, device);
  cout << "Device name: " << prop.name << endl;
  cout << "Total Global Memory (bytes): " << prop.totalGlobalMem << endl;
  cout << "Shared Memory per Block (bytes): " << prop.sharedMemPerBlock << endl;
  cout << "L1 Cache Size (bytes): 16000" << endl;
  cout << "L2 Cache Size (bytes): " << prop.l2CacheSize << endl;
  cout << "Cache Line Size (bytes): 128" << endl;
  cout << "Registers per Block: " << prop.regsPerBlock << endl;
  cout << "Warp Size: " << prop.warpSize << endl;
  cout << "Number of Warp Schedulers: 4" << endl;
  cout << "Max Threads per Block: " << prop.maxThreadsPerBlock << endl;
  cout << "Compute Capability: " << prop.major << endl;
  cout << "Clock Rate (kHz): " << prop.clockRate << endl;
  cout << "Number of SM: " << prop.multiProcessorCount << endl;
  #endif

  // 1) Run reference code <DEBUG means run dumb CPU, REAL means CUBLAS>
  #ifdef DEBUG
  // 
  // cout << "(M,N,K) = " << M << " " << N << " " << K << endl;
  //
  // float* C = (float*) malloc(sizeof(float) * M * N);
  // float* A = (float*) malloc(sizeof(float) * M * K);
  // float* B = (float*) malloc(sizeof(float) * K * N);
  //
  // for (int i = 0; i < M * N; i++)
  //   C[i] = 0.0;
  // for (int i = 0; i < M * K; i++)
  //   A[i] = (float) i;
  // for (int i = 0; i < M * N; i++)
  //   B[i] = (float) i;
  //
  // ref_mmul(C, A, B);
  //
  // cout << "Reference A: " << endl;
  // printMatrix(A,M,K);
  // cout << "Reference B: " << endl;
  // printMatrix(B,K,N);
  // cout << "Reference C: " << endl;
  // printMatrix(C,M,N);

  // 2) Pack Data for Kernel <THIS CHANGE AS THE CODE PROGRESSES>
  cout << "Start initializing device arrays" << endl;
  float * C_gpu;
  float4* A_gpu;
  float4* B_gpu;
  hipMallocManaged(&C_gpu, sizeof(float) * (M * N));
  hipMallocManaged(&A_gpu, sizeof(float4) * (M * K)/4);
  hipMallocManaged(&B_gpu, sizeof(float4) * (K * N)/4);

  cout << "Start loading device arrays" << endl;
  for (int i = 0; i < (M * K)/4; i++)
    A_gpu[i] = make_float4(i*4.0 + 0.0, i*4.0 + 1.0, i*4.0 + 2.0,i*4.0 + 3.0);
  for (int i = 0; i < (K * N)/4; i++)
    B_gpu[i] = make_float4(i*4.0 + 0.0, i*4.0 + 1.0, i*4.0 + 2.0,i*4.0 + 3.0);

  cout << "Start fastgemm" << endl;
  launchFastGemm(C_gpu, A_gpu, B_gpu);

  printMatrix(C_gpu,M,N);

  // free(A);
  // free(B);
  // free(C);
  hipFree(A_gpu);
  hipFree(B_gpu);
  hipFree(C_gpu);
  #endif

  #ifdef REAL
  // INSERT CUBLAS HERE
  #endif

  return 0;
}


	.text
	.file	"main.hip"
                                        # Start of file scope inline assembly
	.globl	_ZSt21ios_base_library_initv

                                        # End of file scope inline assembly
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI0_0:
	.quad	0x4010000000000000              # double 4
.LCPI0_1:
	.quad	0x3ff0000000000000              # double 1
.LCPI0_2:
	.quad	0x4000000000000000              # double 2
.LCPI0_3:
	.quad	0x4008000000000000              # double 3
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r12
	.cfi_def_cfa_offset 32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	subq	$1496, %rsp                     # imm = 0x5D8
	.cfi_def_cfa_offset 1536
	.cfi_offset %rbx, -40
	.cfi_offset %r12, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	24(%rsp), %rbx
	xorl	%r15d, %r15d
	movq	%rbx, %rdi
	xorl	%esi, %esi
	callq	hipGetDevicePropertiesR0600
	movl	$_ZSt4cout, %r12d
	movl	$_ZSt4cout, %edi
	movl	$.L.str, %esi
	movl	$13, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	%rbx, %rdi
	callq	strlen
	movl	$_ZSt4cout, %edi
	movq	%rbx, %rsi
	movq	%rax, %rdx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	_ZSt4cout(%rip), %rax
	movq	-24(%rax), %rdi
	addq	%r12, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	movl	$_ZSt4cout, %edi
	movl	$.L.str.1, %esi
	movl	$29, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	288(%rbx), %rsi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo9_M_insertImEERSoT_
	movq	%rax, %r14
	movq	(%rax), %rax
	movq	-24(%rax), %rdi
	addq	%r14, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movq	%r14, %rdi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	movl	$_ZSt4cout, %edi
	movl	$.L.str.2, %esi
	movl	$33, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	296(%rbx), %rsi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo9_M_insertImEERSoT_
	movq	%rax, %r14
	movq	(%rax), %rax
	movq	-24(%rax), %rdi
	addq	%r14, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movq	%r14, %rdi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	movl	$_ZSt4cout, %edi
	movl	$.L.str.3, %esi
	movl	$28, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	_ZSt4cout(%rip), %rax
	movq	-24(%rax), %rdi
	addq	%r12, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	movl	$_ZSt4cout, %edi
	movl	$.L.str.4, %esi
	movl	$23, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	616(%rbx), %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSolsEi
	movq	%rax, %r14
	movq	(%rax), %rax
	movq	-24(%rax), %rdi
	addq	%r14, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movq	%r14, %rdi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	movl	$_ZSt4cout, %edi
	movl	$.L.str.5, %esi
	movl	$28, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	_ZSt4cout(%rip), %rax
	movq	-24(%rax), %rdi
	addq	%r12, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	movl	$_ZSt4cout, %edi
	movl	$.L.str.6, %esi
	movl	$21, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	304(%rbx), %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSolsEi
	movq	%rax, %r14
	movq	(%rax), %rax
	movq	-24(%rax), %rdi
	addq	%r14, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movq	%r14, %rdi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	movl	$_ZSt4cout, %edi
	movl	$.L.str.7, %esi
	movl	$11, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	308(%rbx), %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSolsEi
	movq	%rax, %r14
	movq	(%rax), %rax
	movq	-24(%rax), %rdi
	addq	%r14, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movq	%r14, %rdi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	movl	$_ZSt4cout, %edi
	movl	$.L.str.8, %esi
	movl	$28, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	_ZSt4cout(%rip), %rax
	movq	-24(%rax), %rdi
	addq	%r12, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	movl	$_ZSt4cout, %edi
	movl	$.L.str.9, %esi
	movl	$23, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	320(%rbx), %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSolsEi
	movq	%rax, %r14
	movq	(%rax), %rax
	movq	-24(%rax), %rdi
	addq	%r14, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movq	%r14, %rdi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	movl	$_ZSt4cout, %edi
	movl	$.L.str.10, %esi
	movl	$20, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	360(%rbx), %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSolsEi
	movq	%rax, %r14
	movq	(%rax), %rax
	movq	-24(%rax), %rdi
	addq	%r14, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movq	%r14, %rdi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	movl	$_ZSt4cout, %edi
	movl	$.L.str.11, %esi
	movl	$18, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	348(%rbx), %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSolsEi
	movq	%rax, %r14
	movq	(%rax), %rax
	movq	-24(%rax), %rdi
	addq	%r14, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movq	%r14, %rdi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	movl	$_ZSt4cout, %edi
	movl	$.L.str.12, %esi
	movl	$14, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	388(%rbx), %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSolsEi
	movq	%rax, %rbx
	movq	(%rax), %rax
	movq	-24(%rax), %rdi
	addq	%rbx, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movq	%rbx, %rdi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	movl	$_ZSt4cout, %edi
	movl	$.L.str.13, %esi
	movl	$32, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	_ZSt4cout(%rip), %rax
	movq	-24(%rax), %rdi
	addq	%r12, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	leaq	16(%rsp), %rdi
	movl	$49152, %esi                    # imm = 0xC000
	movl	$1, %edx
	callq	hipMallocManaged
	leaq	8(%rsp), %rdi
	movl	$480, %esi                      # imm = 0x1E0
	movl	$1, %edx
	callq	hipMallocManaged
	movq	%rsp, %rdi
	movl	$10240, %esi                    # imm = 0x2800
	movl	$1, %edx
	callq	hipMallocManaged
	movl	$_ZSt4cout, %edi
	movl	$.L.str.14, %esi
	movl	$27, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	_ZSt4cout(%rip), %rax
	movq	-24(%rax), %rdi
	addq	%r12, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	movl	$8, %eax
	movsd	.LCPI0_0(%rip), %xmm0           # xmm0 = mem[0],zero
	xorpd	%xmm4, %xmm4
	movsd	.LCPI0_1(%rip), %xmm1           # xmm1 = mem[0],zero
	movsd	.LCPI0_2(%rip), %xmm2           # xmm2 = mem[0],zero
	movsd	.LCPI0_3(%rip), %xmm3           # xmm3 = mem[0],zero
.LBB0_1:                                # =>This Inner Loop Header: Depth=1
	xorps	%xmm5, %xmm5
	cvtsi2sd	%r15d, %xmm5
	mulsd	%xmm0, %xmm5
	movapd	%xmm5, %xmm6
	addsd	%xmm4, %xmm6
	cvtsd2ss	%xmm6, %xmm6
	movapd	%xmm5, %xmm7
	addsd	%xmm1, %xmm7
	cvtsd2ss	%xmm7, %xmm7
	movapd	%xmm5, %xmm8
	addsd	%xmm2, %xmm8
	cvtsd2ss	%xmm8, %xmm8
	addsd	%xmm3, %xmm5
	cvtsd2ss	%xmm5, %xmm5
	unpcklps	%xmm7, %xmm6                    # xmm6 = xmm6[0],xmm7[0],xmm6[1],xmm7[1]
	unpcklps	%xmm5, %xmm8                    # xmm8 = xmm8[0],xmm5[0],xmm8[1],xmm5[1]
	movlhps	%xmm8, %xmm6                    # xmm6 = xmm6[0],xmm8[0]
	movq	8(%rsp), %rcx
	movaps	%xmm6, -8(%rcx,%rax)
	incq	%r15
	addq	$16, %rax
	cmpq	$30, %r15
	jne	.LBB0_1
# %bb.2:                                # %.preheader.preheader
	movl	$8, %eax
	xorl	%ecx, %ecx
	xorpd	%xmm4, %xmm4
.LBB0_3:                                # %.preheader
                                        # =>This Inner Loop Header: Depth=1
	xorps	%xmm5, %xmm5
	cvtsi2sd	%ecx, %xmm5
	mulsd	%xmm0, %xmm5
	movapd	%xmm5, %xmm6
	addsd	%xmm4, %xmm6
	cvtsd2ss	%xmm6, %xmm6
	movapd	%xmm5, %xmm7
	addsd	%xmm1, %xmm7
	cvtsd2ss	%xmm7, %xmm7
	movapd	%xmm5, %xmm8
	addsd	%xmm2, %xmm8
	cvtsd2ss	%xmm8, %xmm8
	addsd	%xmm3, %xmm5
	cvtsd2ss	%xmm5, %xmm5
	unpcklps	%xmm7, %xmm6                    # xmm6 = xmm6[0],xmm7[0],xmm6[1],xmm7[1]
	unpcklps	%xmm5, %xmm8                    # xmm8 = xmm8[0],xmm5[0],xmm8[1],xmm5[1]
	movlhps	%xmm8, %xmm6                    # xmm6 = xmm6[0],xmm8[0]
	movq	(%rsp), %rdx
	movaps	%xmm6, -8(%rdx,%rax)
	incq	%rcx
	addq	$16, %rax
	cmpq	$640, %rcx                      # imm = 0x280
	jne	.LBB0_3
# %bb.4:
	movl	$_ZSt4cout, %ebx
	movl	$_ZSt4cout, %edi
	movl	$.L.str.15, %esi
	movl	$14, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	_ZSt4cout(%rip), %rax
	movq	-24(%rax), %rdi
	addq	%rbx, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	movq	16(%rsp), %rdi
	movq	8(%rsp), %rsi
	movq	(%rsp), %rdx
	callq	_Z14launchFastGemmPfP15HIP_vector_typeIfLj4EES2_
	movq	16(%rsp), %rdi
	movl	$24, %esi
	movl	$512, %edx                      # imm = 0x200
	callq	_Z11printMatrixPfii
	movq	8(%rsp), %rdi
	callq	hipFree
	movq	(%rsp), %rdi
	callq	hipFree
	movq	16(%rsp), %rdi
	callq	hipFree
	xorl	%eax, %eax
	addq	$1496, %rsp                     # imm = 0x5D8
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	main, .Lfunc_end0-main
	.cfi_endproc
                                        # -- End function
	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"Device name: "
	.size	.L.str, 14

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"Total Global Memory (bytes): "
	.size	.L.str.1, 30

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"Shared Memory per Block (bytes): "
	.size	.L.str.2, 34

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"L1 Cache Size (bytes): 16000"
	.size	.L.str.3, 29

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"L2 Cache Size (bytes): "
	.size	.L.str.4, 24

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"Cache Line Size (bytes): 128"
	.size	.L.str.5, 29

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"Registers per Block: "
	.size	.L.str.6, 22

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"Warp Size: "
	.size	.L.str.7, 12

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"Number of Warp Schedulers: 4"
	.size	.L.str.8, 29

	.type	.L.str.9,@object                # @.str.9
.L.str.9:
	.asciz	"Max Threads per Block: "
	.size	.L.str.9, 24

	.type	.L.str.10,@object               # @.str.10
.L.str.10:
	.asciz	"Compute Capability: "
	.size	.L.str.10, 21

	.type	.L.str.11,@object               # @.str.11
.L.str.11:
	.asciz	"Clock Rate (kHz): "
	.size	.L.str.11, 19

	.type	.L.str.12,@object               # @.str.12
.L.str.12:
	.asciz	"Number of SM: "
	.size	.L.str.12, 15

	.type	.L.str.13,@object               # @.str.13
.L.str.13:
	.asciz	"Start initializing device arrays"
	.size	.L.str.13, 33

	.type	.L.str.14,@object               # @.str.14
.L.str.14:
	.asciz	"Start loading device arrays"
	.size	.L.str.14, 28

	.type	.L.str.15,@object               # @.str.15
.L.str.15:
	.asciz	"Start fastgemm"
	.size	.L.str.15, 15

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