#include "CudaUtilities.cuh"

namespace Helix {
	void *fixedCudaMalloc(size_t len) {
		void *p;
		if (cudaMalloc(&p, len) == cudaSuccess) return p;
		return 0;
	}

	template<typename FN>
	FN *cudaAlloCopy(FN *org, const size_t size) {
		void* mem = fixedCudaMalloc(size);
		FN *res = (FN *)mem;
		cudaMemcpy(res, org, size, cudaMemcpyHostToDevice);
		return res;
	}
	template float4 *cudaAlloCopy <float4>(float4 *, const size_t);
	template float3 *cudaAlloCopy <float3>(float3 *, const size_t);
	template double4 *cudaAlloCopy <double4>(double4 *, const size_t);
	template double3 *cudaAlloCopy <double3>(double3 *, const size_t);
}

	.file	"tmpxft_00342424_00000000-6_CudaUtilities.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2012:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2012:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_ZN5Helix15fixedCudaMallocEm
	.type	_ZN5Helix15fixedCudaMallocEm, @function
_ZN5Helix15fixedCudaMallocEm:
.LFB2008:
	.cfi_startproc
	endbr64
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movq	%rdi, %rsi
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rdi
	call	cudaMalloc@PLT
	movl	%eax, %edx
	movq	(%rsp), %rax
	testl	%edx, %edx
	je	.L2
	xorl	%eax, %eax
.L2:
	movq	8(%rsp), %rdx
	subq	%fs:40, %rdx
	je	.L4
	call	__stack_chk_fail@PLT
.L4:
	addq	$24, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2008:
	.size	_ZN5Helix15fixedCudaMallocEm, .-_ZN5Helix15fixedCudaMallocEm
	.section	.text._ZN5Helix12cudaAlloCopyI6float4EEPT_S3_m,"axG",@progbits,_ZN5Helix12cudaAlloCopyI6float4EEPT_S3_m,comdat
	.weak	_ZN5Helix12cudaAlloCopyI6float4EEPT_S3_m
	.type	_ZN5Helix12cudaAlloCopyI6float4EEPT_S3_m, @function
_ZN5Helix12cudaAlloCopyI6float4EEPT_S3_m:
.LFB2081:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movq	%rdi, %r12
	movq	%rsi, %rdi
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movq	%rsi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	call	_ZN5Helix15fixedCudaMallocEm
	movq	%rbp, %rdx
	movq	%r12, %rsi
	movl	$1, %ecx
	movq	%rax, %rbx
	movq	%rax, %rdi
	call	cudaMemcpy@PLT
	movq	%rbx, %rax
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2081:
	.size	_ZN5Helix12cudaAlloCopyI6float4EEPT_S3_m, .-_ZN5Helix12cudaAlloCopyI6float4EEPT_S3_m
	.section	.text._ZN5Helix12cudaAlloCopyI6float3EEPT_S3_m,"axG",@progbits,_ZN5Helix12cudaAlloCopyI6float3EEPT_S3_m,comdat
	.weak	_ZN5Helix12cudaAlloCopyI6float3EEPT_S3_m
	.type	_ZN5Helix12cudaAlloCopyI6float3EEPT_S3_m, @function
_ZN5Helix12cudaAlloCopyI6float3EEPT_S3_m:
.LFB2082:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movq	%rdi, %r12
	movq	%rsi, %rdi
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movq	%rsi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	call	_ZN5Helix15fixedCudaMallocEm
	movq	%rbp, %rdx
	movq	%r12, %rsi
	movl	$1, %ecx
	movq	%rax, %rbx
	movq	%rax, %rdi
	call	cudaMemcpy@PLT
	movq	%rbx, %rax
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2082:
	.size	_ZN5Helix12cudaAlloCopyI6float3EEPT_S3_m, .-_ZN5Helix12cudaAlloCopyI6float3EEPT_S3_m
	.section	.text._ZN5Helix12cudaAlloCopyI7double4EEPT_S3_m,"axG",@progbits,_ZN5Helix12cudaAlloCopyI7double4EEPT_S3_m,comdat
	.weak	_ZN5Helix12cudaAlloCopyI7double4EEPT_S3_m
	.type	_ZN5Helix12cudaAlloCopyI7double4EEPT_S3_m, @function
_ZN5Helix12cudaAlloCopyI7double4EEPT_S3_m:
.LFB2083:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movq	%rdi, %r12
	movq	%rsi, %rdi
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movq	%rsi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	call	_ZN5Helix15fixedCudaMallocEm
	movq	%rbp, %rdx
	movq	%r12, %rsi
	movl	$1, %ecx
	movq	%rax, %rbx
	movq	%rax, %rdi
	call	cudaMemcpy@PLT
	movq	%rbx, %rax
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2083:
	.size	_ZN5Helix12cudaAlloCopyI7double4EEPT_S3_m, .-_ZN5Helix12cudaAlloCopyI7double4EEPT_S3_m
	.section	.text._ZN5Helix12cudaAlloCopyI7double3EEPT_S3_m,"axG",@progbits,_ZN5Helix12cudaAlloCopyI7double3EEPT_S3_m,comdat
	.weak	_ZN5Helix12cudaAlloCopyI7double3EEPT_S3_m
	.type	_ZN5Helix12cudaAlloCopyI7double3EEPT_S3_m, @function
_ZN5Helix12cudaAlloCopyI7double3EEPT_S3_m:
.LFB2084:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movq	%rdi, %r12
	movq	%rsi, %rdi
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movq	%rsi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	call	_ZN5Helix15fixedCudaMallocEm
	movq	%rbp, %rdx
	movq	%r12, %rsi
	movl	$1, %ecx
	movq	%rax, %rbx
	movq	%rax, %rdi
	call	cudaMemcpy@PLT
	movq	%rbx, %rax
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2084:
	.size	_ZN5Helix12cudaAlloCopyI7double3EEPT_S3_m, .-_ZN5Helix12cudaAlloCopyI7double3EEPT_S3_m
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2035:
	.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
.LFE2035:
	.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:


#include <hip/hip_runtime.h>
#include "CudaUtilities.cuh"

namespace Helix {
	void *fixedCudaMalloc(size_t len) {
		void *p;
		if (hipMalloc(&p, len) == hipSuccess) return p;
		return 0;
	}

	template<typename FN>
	FN *cudaAlloCopy(FN *org, const size_t size) {
		void* mem = fixedCudaMalloc(size);
		FN *res = (FN *)mem;
		hipMemcpy(res, org, size, hipMemcpyHostToDevice);
		return res;
	}
	template float4 *cudaAlloCopy <float4>(float4 *, const size_t);
	template float3 *cudaAlloCopy <float3>(float3 *, const size_t);
	template double4 *cudaAlloCopy <double4>(double4 *, const size_t);
	template double3 *cudaAlloCopy <double3>(double3 *, const size_t);
}

	.text
	.file	"CudaUtilities.hip"
	.section	.text._ZN5Helix12cudaAlloCopyI15HIP_vector_typeIfLj4EEEEPT_S4_m,"axG",@progbits,_ZN5Helix12cudaAlloCopyI15HIP_vector_typeIfLj4EEEEPT_S4_m,comdat
	.weak	_ZN5Helix12cudaAlloCopyI15HIP_vector_typeIfLj4EEEEPT_S4_m # -- Begin function _ZN5Helix12cudaAlloCopyI15HIP_vector_typeIfLj4EEEEPT_S4_m
	.type	_ZN5Helix12cudaAlloCopyI15HIP_vector_typeIfLj4EEEEPT_S4_m,@function
_ZN5Helix12cudaAlloCopyI15HIP_vector_typeIfLj4EEEEPT_S4_m: # @_ZN5Helix12cudaAlloCopyI15HIP_vector_typeIfLj4EEEEPT_S4_m
	.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
	subq	$16, %rsp
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rsi, %rbx
	movq	%rdi, %r14
	leaq	8(%rsp), %rdi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB0_1
# %bb.2:
	movq	8(%rsp), %r15
	jmp	.LBB0_3
.LBB0_1:
	xorl	%r15d, %r15d
.LBB0_3:
	movq	%r15, %rdi
	movq	%r14, %rsi
	movq	%rbx, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	%r15, %rax
	addq	$16, %rsp
	.cfi_def_cfa_offset 32
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	_ZN5Helix12cudaAlloCopyI15HIP_vector_typeIfLj4EEEEPT_S4_m, .Lfunc_end0-_ZN5Helix12cudaAlloCopyI15HIP_vector_typeIfLj4EEEEPT_S4_m
	.cfi_endproc
                                        # -- End function
	.text
	.globl	_ZN5Helix15fixedCudaMallocEm    # -- Begin function _ZN5Helix15fixedCudaMallocEm
	.type	_ZN5Helix15fixedCudaMallocEm,@function
_ZN5Helix15fixedCudaMallocEm:           # @_ZN5Helix15fixedCudaMallocEm
	.cfi_startproc
# %bb.0:
	pushq	%rax
	.cfi_def_cfa_offset 16
	movq	%rdi, %rsi
	movq	%rsp, %rdi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB1_1
# %bb.2:
	movq	(%rsp), %rax
	jmp	.LBB1_3
.LBB1_1:
	xorl	%eax, %eax
.LBB1_3:
	popq	%rcx
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end1:
	.size	_ZN5Helix15fixedCudaMallocEm, .Lfunc_end1-_ZN5Helix15fixedCudaMallocEm
	.cfi_endproc
                                        # -- End function
	.section	.text._ZN5Helix12cudaAlloCopyI15HIP_vector_typeIfLj3EEEEPT_S4_m,"axG",@progbits,_ZN5Helix12cudaAlloCopyI15HIP_vector_typeIfLj3EEEEPT_S4_m,comdat
	.weak	_ZN5Helix12cudaAlloCopyI15HIP_vector_typeIfLj3EEEEPT_S4_m # -- Begin function _ZN5Helix12cudaAlloCopyI15HIP_vector_typeIfLj3EEEEPT_S4_m
	.type	_ZN5Helix12cudaAlloCopyI15HIP_vector_typeIfLj3EEEEPT_S4_m,@function
_ZN5Helix12cudaAlloCopyI15HIP_vector_typeIfLj3EEEEPT_S4_m: # @_ZN5Helix12cudaAlloCopyI15HIP_vector_typeIfLj3EEEEPT_S4_m
	.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
	subq	$16, %rsp
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rsi, %rbx
	movq	%rdi, %r14
	leaq	8(%rsp), %rdi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB2_1
# %bb.2:
	movq	8(%rsp), %r15
	jmp	.LBB2_3
.LBB2_1:
	xorl	%r15d, %r15d
.LBB2_3:
	movq	%r15, %rdi
	movq	%r14, %rsi
	movq	%rbx, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	%r15, %rax
	addq	$16, %rsp
	.cfi_def_cfa_offset 32
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end2:
	.size	_ZN5Helix12cudaAlloCopyI15HIP_vector_typeIfLj3EEEEPT_S4_m, .Lfunc_end2-_ZN5Helix12cudaAlloCopyI15HIP_vector_typeIfLj3EEEEPT_S4_m
	.cfi_endproc
                                        # -- End function
	.section	.text._ZN5Helix12cudaAlloCopyI15HIP_vector_typeIdLj4EEEEPT_S4_m,"axG",@progbits,_ZN5Helix12cudaAlloCopyI15HIP_vector_typeIdLj4EEEEPT_S4_m,comdat
	.weak	_ZN5Helix12cudaAlloCopyI15HIP_vector_typeIdLj4EEEEPT_S4_m # -- Begin function _ZN5Helix12cudaAlloCopyI15HIP_vector_typeIdLj4EEEEPT_S4_m
	.type	_ZN5Helix12cudaAlloCopyI15HIP_vector_typeIdLj4EEEEPT_S4_m,@function
_ZN5Helix12cudaAlloCopyI15HIP_vector_typeIdLj4EEEEPT_S4_m: # @_ZN5Helix12cudaAlloCopyI15HIP_vector_typeIdLj4EEEEPT_S4_m
	.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
	subq	$16, %rsp
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rsi, %rbx
	movq	%rdi, %r14
	leaq	8(%rsp), %rdi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB3_1
# %bb.2:
	movq	8(%rsp), %r15
	jmp	.LBB3_3
.LBB3_1:
	xorl	%r15d, %r15d
.LBB3_3:
	movq	%r15, %rdi
	movq	%r14, %rsi
	movq	%rbx, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	%r15, %rax
	addq	$16, %rsp
	.cfi_def_cfa_offset 32
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end3:
	.size	_ZN5Helix12cudaAlloCopyI15HIP_vector_typeIdLj4EEEEPT_S4_m, .Lfunc_end3-_ZN5Helix12cudaAlloCopyI15HIP_vector_typeIdLj4EEEEPT_S4_m
	.cfi_endproc
                                        # -- End function
	.section	.text._ZN5Helix12cudaAlloCopyI15HIP_vector_typeIdLj3EEEEPT_S4_m,"axG",@progbits,_ZN5Helix12cudaAlloCopyI15HIP_vector_typeIdLj3EEEEPT_S4_m,comdat
	.weak	_ZN5Helix12cudaAlloCopyI15HIP_vector_typeIdLj3EEEEPT_S4_m # -- Begin function _ZN5Helix12cudaAlloCopyI15HIP_vector_typeIdLj3EEEEPT_S4_m
	.type	_ZN5Helix12cudaAlloCopyI15HIP_vector_typeIdLj3EEEEPT_S4_m,@function
_ZN5Helix12cudaAlloCopyI15HIP_vector_typeIdLj3EEEEPT_S4_m: # @_ZN5Helix12cudaAlloCopyI15HIP_vector_typeIdLj3EEEEPT_S4_m
	.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
	subq	$16, %rsp
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rsi, %rbx
	movq	%rdi, %r14
	leaq	8(%rsp), %rdi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB4_1
# %bb.2:
	movq	8(%rsp), %r15
	jmp	.LBB4_3
.LBB4_1:
	xorl	%r15d, %r15d
.LBB4_3:
	movq	%r15, %rdi
	movq	%r14, %rsi
	movq	%rbx, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	%r15, %rax
	addq	$16, %rsp
	.cfi_def_cfa_offset 32
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end4:
	.size	_ZN5Helix12cudaAlloCopyI15HIP_vector_typeIdLj3EEEEPT_S4_m, .Lfunc_end4-_ZN5Helix12cudaAlloCopyI15HIP_vector_typeIdLj3EEEEPT_S4_m
	.cfi_endproc
                                        # -- End function
	.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
