#include <stdio.h>

//This function will return the threadID from 0..31
//This ID is unique within the warp.
//Different from CUDA's ID which is unique within the block
__device__ int gemtcThreadID()
{ 
  return threadIdx.x % 32;
}

//This function will return the warpID of the calling thread
//This number will be unique within the block
__device__ int gemtcWarpID()
{ 
  return threadIdx.x / 32;
}

//SHARED MEMORY MANAGEMENT
__device__ void *SHARED_MEMORY;
__device__ int SHARED_SIZE;
__device__ int WARPS_PER_SM;

__device__ void gemtcInitSharedMemory(void *shared_mem, int mem_size, int warps)
{
  //This needs to initialize the three variables above
  //We need to statically have a large block on Shared Memory
  //  allocated when the program launches to divide
  SHARED_MEMORY = shared_mem;
  SHARED_SIZE = mem_size/warps;
  WARPS_PER_SM = warps;
}

__device__ void *gemtcSharedMemory()
{ 
  return ((char *)SHARED_MEMORY) + SHARED_SIZE*gemtcWarpID()/WARPS_PER_SM;
}

	.file	"tmpxft_0039afa2_00000000-6_gemtcKernelLib.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2033:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2033:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z13gemtcThreadIDv
	.type	_Z13gemtcThreadIDv, @function
_Z13gemtcThreadIDv:
.LFB2027:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE2027:
	.size	_Z13gemtcThreadIDv, .-_Z13gemtcThreadIDv
	.globl	_Z11gemtcWarpIDv
	.type	_Z11gemtcWarpIDv, @function
_Z11gemtcWarpIDv:
.LFB2172:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	pushq	%rax
	.cfi_def_cfa_offset 16
	call	_Z13gemtcThreadIDv
	.cfi_endproc
.LFE2172:
	.size	_Z11gemtcWarpIDv, .-_Z11gemtcWarpIDv
	.globl	_Z21gemtcInitSharedMemoryPvii
	.type	_Z21gemtcInitSharedMemoryPvii, @function
_Z21gemtcInitSharedMemoryPvii:
.LFB2029:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE2029:
	.size	_Z21gemtcInitSharedMemoryPvii, .-_Z21gemtcInitSharedMemoryPvii
	.globl	_Z17gemtcSharedMemoryv
	.type	_Z17gemtcSharedMemoryv, @function
_Z17gemtcSharedMemoryv:
.LFB2030:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE2030:
	.size	_Z17gemtcSharedMemoryv, .-_Z17gemtcSharedMemoryv
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"SHARED_MEMORY"
.LC1:
	.string	"SHARED_SIZE"
.LC2:
	.string	"WARPS_PER_SM"
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2056:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	pushq	$0
	.cfi_def_cfa_offset 24
	movl	$8, %r9d
	xorl	%r8d, %r8d
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC0(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	movq	%rdx, %rcx
	leaq	_ZL13SHARED_MEMORY(%rip), %rsi
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterVar@PLT
	popq	%rax
	.cfi_def_cfa_offset 24
	popq	%rdx
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC1(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movq	%rdx, %rcx
	movl	$4, %r9d
	leaq	_ZL11SHARED_SIZE(%rip), %rsi
	call	__cudaRegisterVar@PLT
	popq	%rcx
	.cfi_def_cfa_offset 24
	popq	%rsi
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC2(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movl	$4, %r9d
	movq	%rdx, %rcx
	leaq	_ZL12WARPS_PER_SM(%rip), %rsi
	call	__cudaRegisterVar@PLT
	popq	%rdi
	.cfi_def_cfa_offset 24
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	popq	%r8
	.cfi_def_cfa_offset 16
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE2056:
	.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
	.local	_ZL12WARPS_PER_SM
	.comm	_ZL12WARPS_PER_SM,4,4
	.local	_ZL11SHARED_SIZE
	.comm	_ZL11SHARED_SIZE,4,4
	.local	_ZL13SHARED_MEMORY
	.comm	_ZL13SHARED_MEMORY,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:


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

//This function will return the threadID from 0..31
//This ID is unique within the warp.
//Different from CUDA's ID which is unique within the block
__device__ int gemtcThreadID()
{ 
  return threadIdx.x % 32;
}

//This function will return the warpID of the calling thread
//This number will be unique within the block
__device__ int gemtcWarpID()
{ 
  return threadIdx.x / 32;
}

//SHARED MEMORY MANAGEMENT
__device__ void *SHARED_MEMORY;
__device__ int SHARED_SIZE;
__device__ int WARPS_PER_SM;

__device__ void gemtcInitSharedMemory(void *shared_mem, int mem_size, int warps)
{
  //This needs to initialize the three variables above
  //We need to statically have a large block on Shared Memory
  //  allocated when the program launches to divide
  SHARED_MEMORY = shared_mem;
  SHARED_SIZE = mem_size/warps;
  WARPS_PER_SM = warps;
}

__device__ void *gemtcSharedMemory()
{ 
  return ((char *)SHARED_MEMORY) + SHARED_SIZE*gemtcWarpID()/WARPS_PER_SM;
}

	.text
	.file	"gemtcKernelLib.hip"
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset %rbx, -16
	movq	__hip_gpubin_handle(%rip), %rbx
	testq	%rbx, %rbx
	jne	.LBB0_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB0_2:
	movl	$SHARED_MEMORY, %esi
	movl	$.L__unnamed_1, %edx
	movl	$.L__unnamed_1, %ecx
	movl	$8, %r9d
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	pushq	$0
	.cfi_adjust_cfa_offset 8
	pushq	$0
	.cfi_adjust_cfa_offset 8
	callq	__hipRegisterVar
	addq	$16, %rsp
	.cfi_adjust_cfa_offset -16
	movl	$SHARED_SIZE, %esi
	movl	$.L__unnamed_2, %edx
	movl	$.L__unnamed_2, %ecx
	movl	$4, %r9d
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	pushq	$0
	.cfi_adjust_cfa_offset 8
	pushq	$0
	.cfi_adjust_cfa_offset 8
	callq	__hipRegisterVar
	addq	$16, %rsp
	.cfi_adjust_cfa_offset -16
	movl	$WARPS_PER_SM, %esi
	movl	$.L__unnamed_3, %edx
	movl	$.L__unnamed_3, %ecx
	movl	$4, %r9d
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	pushq	$0
	.cfi_adjust_cfa_offset 8
	pushq	$0
	.cfi_adjust_cfa_offset 8
	callq	__hipRegisterVar
	addq	$16, %rsp
	.cfi_adjust_cfa_offset -16
	movl	$__hip_module_dtor, %edi
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_end0:
	.size	__hip_module_ctor, .Lfunc_end0-__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	.LBB1_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
.LBB1_2:
	retq
.Lfunc_end1:
	.size	__hip_module_dtor, .Lfunc_end1-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	SHARED_MEMORY,@object           # @SHARED_MEMORY
	.local	SHARED_MEMORY
	.comm	SHARED_MEMORY,8,8
	.type	SHARED_SIZE,@object             # @SHARED_SIZE
	.local	SHARED_SIZE
	.comm	SHARED_SIZE,4,4
	.type	WARPS_PER_SM,@object            # @WARPS_PER_SM
	.local	WARPS_PER_SM
	.comm	WARPS_PER_SM,4,4
	.type	.L__unnamed_1,@object           # @0
	.section	.rodata.str1.1,"aMS",@progbits,1
.L__unnamed_1:
	.asciz	"SHARED_MEMORY"
	.size	.L__unnamed_1, 14

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"SHARED_SIZE"
	.size	.L__unnamed_2, 12

	.type	.L__unnamed_3,@object           # @2
.L__unnamed_3:
	.asciz	"WARPS_PER_SM"
	.size	.L__unnamed_3, 13

	.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 __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym SHARED_MEMORY
	.addrsig_sym SHARED_SIZE
	.addrsig_sym WARPS_PER_SM
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.protected	SHARED_MEMORY           ; @SHARED_MEMORY
	.type	SHARED_MEMORY,@object
	.section	.bss,"aw",@nobits
	.globl	SHARED_MEMORY
	.p2align	3, 0x0
SHARED_MEMORY:
	.quad	0
	.size	SHARED_MEMORY, 8

	.protected	SHARED_SIZE             ; @SHARED_SIZE
	.type	SHARED_SIZE,@object
	.globl	SHARED_SIZE
	.p2align	2, 0x0
SHARED_SIZE:
	.long	0                               ; 0x0
	.size	SHARED_SIZE, 4

	.protected	WARPS_PER_SM            ; @WARPS_PER_SM
	.type	WARPS_PER_SM,@object
	.globl	WARPS_PER_SM
	.p2align	2, 0x0
WARPS_PER_SM:
	.long	0                               ; 0x0
	.size	WARPS_PER_SM, 4

	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.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 SHARED_MEMORY
	.addrsig_sym SHARED_SIZE
	.addrsig_sym WARPS_PER_SM
	.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
