#include "points.cuh"
#include <iostream>
__host__ __device__ Points::Points() : m_x(NULL), m_y(NULL){}
    
__host__ __device__ Points::Points(float* x, float* y): m_x(x), m_y(y){}

__host__ __device__  float2 Points::get_point(int idx) const{
    return make_float2(m_x[idx], m_y[idx]);
}

 __host__ void Points::print_point_d_2_h(int idx) const{
     //hack
   float* host_mx;
   host_mx= (float*)  malloc(sizeof(float)*(idx+1) );
   cudaMemcpy(host_mx, m_x,sizeof(float)*(idx+1), cudaMemcpyDeviceToHost);
   float* host_my;
   host_my= (float*)  malloc(sizeof(float)*(idx+1) );
   cudaMemcpy(host_my, m_y,sizeof(float)*(idx+1), cudaMemcpyDeviceToHost);
   std::cout << "x: " <<  host_mx[idx] << " y:" << host_my[idx] << std::endl;
 }
 __host__ __device__  void Points::set_point(int idx, const float2& p){
    m_x[idx] = p.x;
    m_y[idx] = p.y; 
}
//set the actual pointers
__host__ __device__  void Points::set(float* x , float* y){
    m_x= x;
    m_y= y;
}

	.file	"tmpxft_0033f252_00000000-6_points.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB3647:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE3647:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.align 2
	.globl	_ZN6PointsC2Ev
	.type	_ZN6PointsC2Ev, @function
_ZN6PointsC2Ev:
.LFB3636:
	.cfi_startproc
	endbr64
	xorl	%eax, %eax
	movq	%rax, (%rdi)
	movq	%rax, 8(%rdi)
	ret
	.cfi_endproc
.LFE3636:
	.size	_ZN6PointsC2Ev, .-_ZN6PointsC2Ev
	.globl	_ZN6PointsC1Ev
	.set	_ZN6PointsC1Ev,_ZN6PointsC2Ev
	.align 2
	.globl	_ZN6PointsC2EPfS0_
	.type	_ZN6PointsC2EPfS0_, @function
_ZN6PointsC2EPfS0_:
.LFB3639:
	.cfi_startproc
	endbr64
	movq	%rsi, (%rdi)
	movq	%rdx, 8(%rdi)
	ret
	.cfi_endproc
.LFE3639:
	.size	_ZN6PointsC2EPfS0_, .-_ZN6PointsC2EPfS0_
	.globl	_ZN6PointsC1EPfS0_
	.set	_ZN6PointsC1EPfS0_,_ZN6PointsC2EPfS0_
	.align 2
	.globl	_ZNK6Points9get_pointEi
	.type	_ZNK6Points9get_pointEi, @function
_ZNK6Points9get_pointEi:
.LFB3641:
	.cfi_startproc
	endbr64
	movq	8(%rdi), %rdx
	movslq	%esi, %rsi
	movq	(%rdi), %rax
	movl	(%rdx,%rsi,4), %edx
	movl	(%rax,%rsi,4), %eax
	salq	$32, %rdx
	orq	%rdx, %rax
	movq	%rax, %xmm0
	ret
	.cfi_endproc
.LFE3641:
	.size	_ZNK6Points9get_pointEi, .-_ZNK6Points9get_pointEi
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"x: "
.LC1:
	.string	" y:"
	.text
	.align 2
	.globl	_ZNK6Points17print_point_d_2_hEi
	.type	_ZNK6Points17print_point_d_2_hEi, @function
_ZNK6Points17print_point_d_2_hEi:
.LFB3642:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	movq	%rdi, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	leal	1(%rsi), %ebx
	pushq	%rax
	.cfi_def_cfa_offset 48
	movslq	%ebx, %rbx
	salq	$2, %rbx
	movq	%rbx, %rdi
	call	malloc@PLT
	movq	(%r12), %rsi
	movq	%rbx, %rdx
	movl	$2, %ecx
	movq	%rax, %rdi
	movq	%rax, %r13
	call	cudaMemcpy@PLT
	movq	%rbx, %rdi
	call	malloc@PLT
	movq	8(%r12), %rsi
	movq	%rbx, %rdx
	movl	$2, %ecx
	movq	%rax, %rdi
	movq	%rax, %rbp
	call	cudaMemcpy@PLT
	leaq	.LC0(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	cvtss2sd	-4(%r13,%rbx), %xmm0
	movq	%rax, %rdi
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	leaq	.LC1(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	cvtss2sd	-4(%rbp,%rbx), %xmm0
	movq	%rax, %rdi
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	popq	%rdx
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	movq	%rax, %rdi
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	jmp	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT
	.cfi_endproc
.LFE3642:
	.size	_ZNK6Points17print_point_d_2_hEi, .-_ZNK6Points17print_point_d_2_hEi
	.align 2
	.globl	_ZN6Points9set_pointEiRK6float2
	.type	_ZN6Points9set_pointEiRK6float2, @function
_ZN6Points9set_pointEiRK6float2:
.LFB3643:
	.cfi_startproc
	endbr64
	movss	(%rdx), %xmm0
	movq	(%rdi), %rax
	movslq	%esi, %rsi
	movss	%xmm0, (%rax,%rsi,4)
	movq	8(%rdi), %rax
	movss	4(%rdx), %xmm0
	movss	%xmm0, (%rax,%rsi,4)
	ret
	.cfi_endproc
.LFE3643:
	.size	_ZN6Points9set_pointEiRK6float2, .-_ZN6Points9set_pointEiRK6float2
	.align 2
	.globl	_ZN6Points3setEPfS0_
	.type	_ZN6Points3setEPfS0_, @function
_ZN6Points3setEPfS0_:
.LFB3644:
	.cfi_startproc
	endbr64
	movq	%rsi, (%rdi)
	movq	%rdx, 8(%rdi)
	ret
	.cfi_endproc
.LFE3644:
	.size	_ZN6Points3setEPfS0_, .-_ZN6Points3setEPfS0_
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB3670:
	.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
.LFE3670:
	.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 "points.cuh"
#include <iostream>
__host__ __device__ Points::Points() : m_x(NULL), m_y(NULL){}
    
__host__ __device__ Points::Points(float* x, float* y): m_x(x), m_y(y){}

__host__ __device__  float2 Points::get_point(int idx) const{
    return make_float2(m_x[idx], m_y[idx]);
}

 __host__ void Points::print_point_d_2_h(int idx) const{
     //hack
   float* host_mx;
   host_mx= (float*)  malloc(sizeof(float)*(idx+1) );
   hipMemcpy(host_mx, m_x,sizeof(float)*(idx+1), hipMemcpyDeviceToHost);
   float* host_my;
   host_my= (float*)  malloc(sizeof(float)*(idx+1) );
   hipMemcpy(host_my, m_y,sizeof(float)*(idx+1), hipMemcpyDeviceToHost);
   std::cout << "x: " <<  host_mx[idx] << " y:" << host_my[idx] << std::endl;
 }
 __host__ __device__  void Points::set_point(int idx, const float2& p){
    m_x[idx] = p.x;
    m_y[idx] = p.y; 
}
//set the actual pointers
__host__ __device__  void Points::set(float* x , float* y){
    m_x= x;
    m_y= y;
}

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

                                        # End of file scope inline assembly
	.globl	_ZN6PointsC2Ev                  # -- Begin function _ZN6PointsC2Ev
	.p2align	1, 0x90
	.type	_ZN6PointsC2Ev,@function
_ZN6PointsC2Ev:                         # @_ZN6PointsC2Ev
	.cfi_startproc
# %bb.0:
	xorps	%xmm0, %xmm0
	movups	%xmm0, (%rdi)
	retq
.Lfunc_end0:
	.size	_ZN6PointsC2Ev, .Lfunc_end0-_ZN6PointsC2Ev
	.cfi_endproc
                                        # -- End function
	.globl	_ZN6PointsC2EPfS0_              # -- Begin function _ZN6PointsC2EPfS0_
	.p2align	1, 0x90
	.type	_ZN6PointsC2EPfS0_,@function
_ZN6PointsC2EPfS0_:                     # @_ZN6PointsC2EPfS0_
	.cfi_startproc
# %bb.0:
	movq	%rsi, (%rdi)
	movq	%rdx, 8(%rdi)
	retq
.Lfunc_end1:
	.size	_ZN6PointsC2EPfS0_, .Lfunc_end1-_ZN6PointsC2EPfS0_
	.cfi_endproc
                                        # -- End function
	.globl	_ZNK6Points9get_pointEi         # -- Begin function _ZNK6Points9get_pointEi
	.p2align	1, 0x90
	.type	_ZNK6Points9get_pointEi,@function
_ZNK6Points9get_pointEi:                # @_ZNK6Points9get_pointEi
	.cfi_startproc
# %bb.0:
	movslq	%esi, %rax
	movq	(%rdi), %rcx
	movq	8(%rdi), %rdx
	movss	(%rdx,%rax,4), %xmm1            # xmm1 = mem[0],zero,zero,zero
	movss	(%rcx,%rax,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	unpcklps	%xmm1, %xmm0                    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
	retq
.Lfunc_end2:
	.size	_ZNK6Points9get_pointEi, .Lfunc_end2-_ZNK6Points9get_pointEi
	.cfi_endproc
                                        # -- End function
	.globl	_ZNK6Points17print_point_d_2_hEi # -- Begin function _ZNK6Points17print_point_d_2_hEi
	.p2align	1, 0x90
	.type	_ZNK6Points17print_point_d_2_hEi,@function
_ZNK6Points17print_point_d_2_hEi:       # @_ZNK6Points17print_point_d_2_hEi
	.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
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rdi, %r15
	movslq	%esi, %r13
	leaq	4(,%r13,4), %r12
	movq	%r12, %rdi
	callq	malloc
	movq	%rax, %r14
	movq	(%r15), %rsi
	movq	%rax, %rdi
	movq	%r12, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	movq	%r12, %rdi
	callq	malloc
	movq	%rax, %rbx
	movq	8(%r15), %rsi
	movq	%rax, %rdi
	movq	%r12, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	movl	$_ZSt4cout, %edi
	movl	$.L.str, %esi
	movl	$3, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	cvtss2sd	(%r14,%r13,4), %xmm0
	movl	$_ZSt4cout, %edi
	callq	_ZNSo9_M_insertIdEERSoT_
	movq	%rax, %r14
	movl	$.L.str.1, %esi
	movl	$3, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	xorps	%xmm0, %xmm0
	cvtss2sd	(%rbx,%r13,4), %xmm0
	movq	%r14, %rdi
	callq	_ZNSo9_M_insertIdEERSoT_
	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
	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
	jmp	_ZNSo5flushEv                   # TAILCALL
.Lfunc_end3:
	.size	_ZNK6Points17print_point_d_2_hEi, .Lfunc_end3-_ZNK6Points17print_point_d_2_hEi
	.cfi_endproc
                                        # -- End function
	.globl	_ZN6Points9set_pointEiRK15HIP_vector_typeIfLj2EE # -- Begin function _ZN6Points9set_pointEiRK15HIP_vector_typeIfLj2EE
	.p2align	1, 0x90
	.type	_ZN6Points9set_pointEiRK15HIP_vector_typeIfLj2EE,@function
_ZN6Points9set_pointEiRK15HIP_vector_typeIfLj2EE: # @_ZN6Points9set_pointEiRK15HIP_vector_typeIfLj2EE
	.cfi_startproc
# %bb.0:
	movss	(%rdx), %xmm0                   # xmm0 = mem[0],zero,zero,zero
	movq	(%rdi), %rax
	movslq	%esi, %rcx
	movss	%xmm0, (%rax,%rcx,4)
	movss	4(%rdx), %xmm0                  # xmm0 = mem[0],zero,zero,zero
	movq	8(%rdi), %rax
	movss	%xmm0, (%rax,%rcx,4)
	retq
.Lfunc_end4:
	.size	_ZN6Points9set_pointEiRK15HIP_vector_typeIfLj2EE, .Lfunc_end4-_ZN6Points9set_pointEiRK15HIP_vector_typeIfLj2EE
	.cfi_endproc
                                        # -- End function
	.globl	_ZN6Points3setEPfS0_            # -- Begin function _ZN6Points3setEPfS0_
	.p2align	1, 0x90
	.type	_ZN6Points3setEPfS0_,@function
_ZN6Points3setEPfS0_:                   # @_ZN6Points3setEPfS0_
	.cfi_startproc
# %bb.0:
	movq	%rsi, (%rdi)
	movq	%rdx, 8(%rdi)
	retq
.Lfunc_end5:
	.size	_ZN6Points3setEPfS0_, .Lfunc_end5-_ZN6Points3setEPfS0_
	.cfi_endproc
                                        # -- End function
	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"x: "
	.size	.L.str, 4

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	" y:"
	.size	.L.str.1, 4

	.type	__hip_cuid_,@object             # @__hip_cuid_
	.bss
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               # 0x0
	.size	__hip_cuid_, 1

	.globl	_ZN6PointsC1Ev
	.type	_ZN6PointsC1Ev,@function
.set _ZN6PointsC1Ev, _ZN6PointsC2Ev
	.globl	_ZN6PointsC1EPfS0_
	.type	_ZN6PointsC1EPfS0_,@function
.set _ZN6PointsC1EPfS0_, _ZN6PointsC2EPfS0_
	.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
