// Includes, System
#include <iostream>
#include <assert.h>
#include <chrono>

// Here you can set the device ID that was assigned to you
#define MYDEVICE 0 // 24%8=0

// Simple utility function to check for CUDA runtime errors
void checkCUDAError(const char *msg);

///////////////////////////////////////////////////////////////////////////////
// Program main
///////////////////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])
{
    cudaSetDevice(MYDEVICE);
    // pointer and dimension for host memory
    int const dimA = (argc > 1) ? std::atoi(argv[1]) : 8;
    std::cout << "dimA " << dimA << std::endl;
    float *h_a;
    //    double *h_a;

    // pointers for device memory
    float *d_a, *d_b;
    //    double *d_a, *d_b;

    // allocate and initialize host memory
    // Bonus: try using cudaMallocHost in place of malloc
    // it has the same syntax as cudaMalloc, but it enables asynchronous copies
    //    h_a = (float *) malloc(dimA*sizeof(float));
    //    size_t memSize = dimA*sizeof(float);
    size_t memSize = dimA*sizeof(*h_a);
    cudaMallocHost( &h_a,memSize );
    for (int i = 0; i<dimA; ++i)
      h_a[i] = i;

    // Part 1 of 5: allocate device memory
    //    size_t memSize = dimA*sizeof(float);
    cudaMalloc( &d_a,memSize );
    cudaMalloc( &d_b,memSize );

    // Part 2 of 5: host to device memory copy
    {
      auto start = std::chrono::system_clock::now();
      cudaMemcpy( d_a, h_a, memSize, cudaMemcpyHostToDevice );
      auto stop = std::chrono::system_clock::now();
      std::chrono::duration<double> dur= stop - start;
      float band = memSize/8./dur.count();
      printf ("h2d : PCI bandwidth %.1f GB/seconds \n",float(memSize)/8000000000./dur.count());
    }

    // Part 3 of 5: device to device memory copy
    {
      auto start = std::chrono::system_clock::now();
      cudaMemcpy( d_b, d_a, memSize, cudaMemcpyDeviceToDevice );
      auto stop = std::chrono::system_clock::now();
      std::chrono::duration<double> dur= stop - start;
      printf ("d2d : PCI bandwidth %.1f GB/seconds \n",float(memSize)/8000000000./dur.count());
    }


    // clear host memory
    for (int i=0; i<dimA; ++i )
        h_a[i] = 0.f;

    // Part 4 of 5: device to host copy
    {
      auto start = std::chrono::system_clock::now();
      cudaMemcpy( h_a, d_a, memSize, cudaMemcpyDeviceToHost );
      auto stop = std::chrono::system_clock::now();
      std::chrono::duration<double> dur= stop - start;
      printf ("d2h : PCI bandwidth %.1f GB/seconds \n",float(memSize)/8000000000./dur.count());
    }


    // Check for any CUDA errors
    checkCUDAError("cudaMemcpy calls");

    // verify the data on the host is correct
    for (int i=0; i<dimA; ++i)
        assert(h_a[i] == (float) i);

    // Part 5 of 5: free device memory pointers d_a and d_b
    cudaFree( d_a );
    cudaFree( d_b );

    // Check for any CUDA errors
    checkCUDAError("cudaFree");

    // free host memory pointer h_a
    //    free(h_a);
    cudaFreeHost(h_a);

    // If the program makes it this far, then the results are correct and
    // there are no run-time errors.  Good work!
    std::cout << "Correct!" << std::endl;

    return 0;
}

void checkCUDAError(const char *msg)
{
    cudaError_t err = cudaGetLastError();
    if( cudaSuccess != err) 
    {
        std::cerr << "Cuda error: " << msg << " " << cudaGetErrorString(err) << std::endl;
        exit(-1);
    }                         
}

	.file	"tmpxft_0022b653_00000000-6_cuda_mem_model.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB3742:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE3742:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"Cuda error: "
.LC1:
	.string	" "
	.text
	.globl	_Z14checkCUDAErrorPKc
	.type	_Z14checkCUDAErrorPKc, @function
_Z14checkCUDAErrorPKc:
.LFB3739:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rdi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	pushq	%rdx
	.cfi_def_cfa_offset 32
	call	cudaGetLastError@PLT
	testl	%eax, %eax
	je	.L2
	leaq	.LC0(%rip), %rsi
	leaq	_ZSt4cerr(%rip), %rdi
	movl	%eax, %ebx
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%rbp, %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC1(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	%ebx, %edi
	movq	%rax, %rbp
	call	cudaGetErrorString@PLT
	movq	%rbp, %rdi
	movq	%rax, %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%rax, %rdi
	call	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT
	orl	$-1, %edi
	call	exit@PLT
.L2:
	popq	%rax
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3739:
	.size	_Z14checkCUDAErrorPKc, .-_Z14checkCUDAErrorPKc
	.section	.rodata.str1.1
.LC2:
	.string	"dimA "
.LC5:
	.string	"h2d : PCI bandwidth %.1f GB/seconds \n"
.LC6:
	.string	"d2d : PCI bandwidth %.1f GB/seconds \n"
.LC8:
	.string	"d2h : PCI bandwidth %.1f GB/seconds \n"
.LC9:
	.string	"cudaMemcpy calls"
.LC10:
	.string	"cudaFree"
.LC11:
	.string	"Correct!"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB3734:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	movl	$8, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	movl	%edi, %ebp
	xorl	%edi, %edi
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	movq	%rsi, %rbx
	subq	$32, %rsp
	.cfi_def_cfa_offset 80
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	call	cudaSetDevice@PLT
	decl	%ebp
	jle	.L7
	movq	8(%rbx), %rdi
	call	atoi@PLT
	movl	%eax, %r12d
.L7:
	leaq	_ZSt4cout(%rip), %rbp
	leaq	.LC2(%rip), %rsi
	movslq	%r12d, %rbx
	movq	%rbp, %rdi
	salq	$2, %rbx
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	%r12d, %esi
	movq	%rax, %rdi
	call	_ZNSolsEi@PLT
	movq	%rax, %rdi
	call	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT
	xorl	%edx, %edx
	movq	%rsp, %rdi
	movq	%rbx, %rsi
	call	cudaHostAlloc@PLT
	movq	(%rsp), %rdx
	xorl	%eax, %eax
.L8:
	cmpl	%eax, %r12d
	jle	.L18
	cvtsi2ssl	%eax, %xmm0
	movss	%xmm0, (%rdx,%rax,4)
	incq	%rax
	jmp	.L8
.L18:
	leaq	8(%rsp), %rdi
	movq	%rbx, %rsi
	call	cudaMalloc@PLT
	leaq	16(%rsp), %rdi
	movq	%rbx, %rsi
	call	cudaMalloc@PLT
	call	_ZNSt6chrono3_V212system_clock3nowEv@PLT
	movq	(%rsp), %rsi
	movq	8(%rsp), %rdi
	movq	%rbx, %rdx
	movl	$1, %ecx
	movq	%rax, %r13
	call	cudaMemcpy@PLT
	call	_ZNSt6chrono3_V212system_clock3nowEv@PLT
	testq	%rbx, %rbx
	js	.L10
	cvtsi2ssq	%rbx, %xmm0
	jmp	.L11
.L10:
	movq	%rbx, %rdx
	shrq	%rdx
	cvtsi2ssq	%rdx, %xmm0
	addss	%xmm0, %xmm0
.L11:
	cvtss2sd	%xmm0, %xmm0
	divsd	.LC3(%rip), %xmm0
	movq	%xmm0, %r14
	subq	%r13, %rax
	movq	%r14, %xmm1
	cvtsi2sdq	%rax, %xmm0
	movl	$2, %edi
	movb	$1, %al
	divsd	.LC4(%rip), %xmm0
	divsd	%xmm0, %xmm1
	leaq	.LC5(%rip), %rsi
	movaps	%xmm1, %xmm0
	call	__printf_chk@PLT
	call	_ZNSt6chrono3_V212system_clock3nowEv@PLT
	movq	8(%rsp), %rsi
	movq	16(%rsp), %rdi
	movq	%rbx, %rdx
	movl	$3, %ecx
	movq	%rax, %r13
	call	cudaMemcpy@PLT
	call	_ZNSt6chrono3_V212system_clock3nowEv@PLT
	movq	%r14, %xmm1
	movl	$2, %edi
	leaq	.LC6(%rip), %rsi
	subq	%r13, %rax
	cvtsi2sdq	%rax, %xmm0
	divsd	.LC4(%rip), %xmm0
	movb	$1, %al
	divsd	%xmm0, %xmm1
	movaps	%xmm1, %xmm0
	call	__printf_chk@PLT
	movq	(%rsp), %rdx
	xorl	%eax, %eax
.L12:
	cmpl	%eax, %r12d
	jle	.L19
	movl	$0x00000000, (%rdx,%rax,4)
	incq	%rax
	jmp	.L12
.L19:
	call	_ZNSt6chrono3_V212system_clock3nowEv@PLT
	movq	8(%rsp), %rsi
	movq	(%rsp), %rdi
	movq	%rbx, %rdx
	movl	$2, %ecx
	movq	%rax, %r12
	call	cudaMemcpy@PLT
	call	_ZNSt6chrono3_V212system_clock3nowEv@PLT
	movq	%r14, %xmm0
	movl	$2, %edi
	leaq	.LC8(%rip), %rsi
	subq	%r12, %rax
	cvtsi2sdq	%rax, %xmm1
	divsd	.LC4(%rip), %xmm1
	movb	$1, %al
	divsd	%xmm1, %xmm0
	call	__printf_chk@PLT
	leaq	.LC9(%rip), %rdi
	call	_Z14checkCUDAErrorPKc
	movq	8(%rsp), %rdi
	call	cudaFree@PLT
	movq	16(%rsp), %rdi
	call	cudaFree@PLT
	leaq	.LC10(%rip), %rdi
	call	_Z14checkCUDAErrorPKc
	movq	(%rsp), %rdi
	call	cudaFreeHost@PLT
	movq	%rbp, %rdi
	leaq	.LC11(%rip), %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%rax, %rdi
	call	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	je	.L14
	call	__stack_chk_fail@PLT
.L14:
	addq	$32, %rsp
	.cfi_def_cfa_offset 48
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3734:
	.size	main, .-main
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB3765:
	.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
.LFE3765:
	.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
.LC3:
	.long	0
	.long	1107152229
	.align 8
.LC4:
	.long	0
	.long	1104006501
	.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:

// Includes, System

#include <hip/hip_runtime.h>
#include <iostream>
#include <assert.h>
#include <chrono>

// Here you can set the device ID that was assigned to you
#define MYDEVICE 0 // 24%8=0

// Simple utility function to check for CUDA runtime errors
void checkCUDAError(const char *msg);

///////////////////////////////////////////////////////////////////////////////
// Program main
///////////////////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])
{
    hipSetDevice(MYDEVICE);
    // pointer and dimension for host memory
    int const dimA = (argc > 1) ? std::atoi(argv[1]) : 8;
    std::cout << "dimA " << dimA << std::endl;
    float *h_a;
    //    double *h_a;

    // pointers for device memory
    float *d_a, *d_b;
    //    double *d_a, *d_b;

    // allocate and initialize host memory
    // Bonus: try using cudaMallocHost in place of malloc
    // it has the same syntax as cudaMalloc, but it enables asynchronous copies
    //    h_a = (float *) malloc(dimA*sizeof(float));
    //    size_t memSize = dimA*sizeof(float);
    size_t memSize = dimA*sizeof(*h_a);
    hipHostMalloc( &h_a,memSize , hipHostMallocDefault);
    for (int i = 0; i<dimA; ++i)
      h_a[i] = i;

    // Part 1 of 5: allocate device memory
    //    size_t memSize = dimA*sizeof(float);
    hipMalloc( &d_a,memSize );
    hipMalloc( &d_b,memSize );

    // Part 2 of 5: host to device memory copy
    {
      auto start = std::chrono::system_clock::now();
      hipMemcpy( d_a, h_a, memSize, hipMemcpyHostToDevice );
      auto stop = std::chrono::system_clock::now();
      std::chrono::duration<double> dur= stop - start;
      float band = memSize/8./dur.count();
      printf ("h2d : PCI bandwidth %.1f GB/seconds \n",float(memSize)/8000000000./dur.count());
    }

    // Part 3 of 5: device to device memory copy
    {
      auto start = std::chrono::system_clock::now();
      hipMemcpy( d_b, d_a, memSize, hipMemcpyDeviceToDevice );
      auto stop = std::chrono::system_clock::now();
      std::chrono::duration<double> dur= stop - start;
      printf ("d2d : PCI bandwidth %.1f GB/seconds \n",float(memSize)/8000000000./dur.count());
    }


    // clear host memory
    for (int i=0; i<dimA; ++i )
        h_a[i] = 0.f;

    // Part 4 of 5: device to host copy
    {
      auto start = std::chrono::system_clock::now();
      hipMemcpy( h_a, d_a, memSize, hipMemcpyDeviceToHost );
      auto stop = std::chrono::system_clock::now();
      std::chrono::duration<double> dur= stop - start;
      printf ("d2h : PCI bandwidth %.1f GB/seconds \n",float(memSize)/8000000000./dur.count());
    }


    // Check for any CUDA errors
    checkCUDAError("hipMemcpy calls");

    // verify the data on the host is correct
    for (int i=0; i<dimA; ++i)
        assert(h_a[i] == (float) i);

    // Part 5 of 5: free device memory pointers d_a and d_b
    hipFree( d_a );
    hipFree( d_b );

    // Check for any CUDA errors
    checkCUDAError("hipFree");

    // free host memory pointer h_a
    //    free(h_a);
    hipHostFree(h_a);

    // If the program makes it this far, then the results are correct and
    // there are no run-time errors.  Good work!
    std::cout << "Correct!" << std::endl;

    return 0;
}

void checkCUDAError(const char *msg)
{
    hipError_t err = hipGetLastError();
    if( hipSuccess != err) 
    {
        std::cerr << "Cuda error: " << msg << " " << hipGetErrorString(err) << std::endl;
        exit(-1);
    }                         
}

	.text
	.file	"cuda_mem_model.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	0x41cdcd6500000000              # double 1.0E+9
.LCPI0_1:
	.quad	0x41fdcd6500000000              # double 8.0E+9
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
	.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
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	.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	%rsi, %r14
	movl	%edi, %ebp
	xorl	%edi, %edi
	callq	hipSetDevice
	movl	$8, %ebx
	cmpl	$2, %ebp
	jl	.LBB0_2
# %bb.1:
	movq	8(%r14), %rdi
	callq	atoi
	movl	%eax, %ebx
.LBB0_2:
	movl	$_ZSt4cout, %edi
	movl	$.L.str, %esi
	movl	$5, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	$_ZSt4cout, %edi
	movl	%ebx, %esi
	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
	movslq	%ebx, %r12
	leaq	(,%r12,4), %r14
	leaq	8(%rsp), %rdi
	movq	%r14, %rsi
	xorl	%edx, %edx
	callq	hipHostMalloc
	movl	%ebx, %r15d
	testl	%r12d, %r12d
	jle	.LBB0_5
# %bb.3:                                # %.lr.ph
	movq	8(%rsp), %rax
	xorl	%ecx, %ecx
.LBB0_4:                                # =>This Inner Loop Header: Depth=1
	xorps	%xmm0, %xmm0
	cvtsi2ss	%ecx, %xmm0
	movss	%xmm0, (%rax,%rcx,4)
	incq	%rcx
	cmpq	%rcx, %r15
	jne	.LBB0_4
.LBB0_5:                                # %._crit_edge
	leaq	16(%rsp), %r12
	movq	%r12, %rdi
	movq	%r14, %rsi
	callq	hipMalloc
	leaq	32(%rsp), %rdi
	movq	%r14, %rsi
	callq	hipMalloc
	callq	_ZNSt6chrono3_V212system_clock3nowEv
	movq	%rax, %r13
	movq	(%r12), %rdi
	movq	8(%rsp), %rsi
	movq	%r14, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	callq	_ZNSt6chrono3_V212system_clock3nowEv
	subq	%r13, %rax
	cvtsi2sd	%rax, %xmm1
	divsd	.LCPI0_0(%rip), %xmm1
	testq	%r14, %r14
	js	.LBB0_6
# %bb.7:                                # %._crit_edge
	xorps	%xmm0, %xmm0
	cvtsi2ss	%r14, %xmm0
	jmp	.LBB0_8
.LBB0_6:
	movq	%r14, %rax
	shrq	%rax
	movl	%r14d, %ecx
	andl	$1, %ecx
	orq	%rax, %rcx
	xorps	%xmm0, %xmm0
	cvtsi2ss	%rcx, %xmm0
	addss	%xmm0, %xmm0
.LBB0_8:                                # %._crit_edge
	cvtss2sd	%xmm0, %xmm0
	divsd	.LCPI0_1(%rip), %xmm0
	movsd	%xmm0, 24(%rsp)                 # 8-byte Spill
	divsd	%xmm1, %xmm0
	movl	$.L.str.1, %edi
	movb	$1, %al
	callq	printf
	callq	_ZNSt6chrono3_V212system_clock3nowEv
	movq	%rax, %r12
	movq	32(%rsp), %rdi
	movq	16(%rsp), %rsi
	movq	%r14, %rdx
	movl	$3, %ecx
	callq	hipMemcpy
	callq	_ZNSt6chrono3_V212system_clock3nowEv
	subq	%r12, %rax
	xorps	%xmm1, %xmm1
	cvtsi2sd	%rax, %xmm1
	divsd	.LCPI0_0(%rip), %xmm1
	movsd	24(%rsp), %xmm0                 # 8-byte Reload
                                        # xmm0 = mem[0],zero
	divsd	%xmm1, %xmm0
	movl	$.L.str.2, %edi
	movb	$1, %al
	callq	printf
	testl	%ebx, %ebx
	jle	.LBB0_10
# %bb.9:                                # %.lr.ph47
	movq	8(%rsp), %rdi
	shlq	$2, %r15
	xorl	%esi, %esi
	movq	%r15, %rdx
	callq	memset@PLT
.LBB0_10:                               # %._crit_edge48
	callq	_ZNSt6chrono3_V212system_clock3nowEv
	movq	%rax, %rbx
	movq	8(%rsp), %rdi
	movq	16(%rsp), %rsi
	movq	%r14, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	callq	_ZNSt6chrono3_V212system_clock3nowEv
	subq	%rbx, %rax
	xorps	%xmm1, %xmm1
	cvtsi2sd	%rax, %xmm1
	divsd	.LCPI0_0(%rip), %xmm1
	movsd	24(%rsp), %xmm0                 # 8-byte Reload
                                        # xmm0 = mem[0],zero
	divsd	%xmm1, %xmm0
	movl	$.L.str.3, %edi
	movb	$1, %al
	callq	printf
	movl	$.L.str.4, %edi
	callq	_Z14checkCUDAErrorPKc
	movq	16(%rsp), %rdi
	callq	hipFree
	movq	32(%rsp), %rdi
	callq	hipFree
	movl	$.L.str.5, %edi
	callq	_Z14checkCUDAErrorPKc
	movq	8(%rsp), %rdi
	callq	hipHostFree
	movl	$_ZSt4cout, %ebx
	movl	$_ZSt4cout, %edi
	movl	$.L.str.6, %esi
	movl	$8, %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
	xorl	%eax, %eax
	addq	$40, %rsp
	.cfi_def_cfa_offset 56
	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	main, .Lfunc_end0-main
	.cfi_endproc
                                        # -- End function
	.globl	_Z14checkCUDAErrorPKc           # -- Begin function _Z14checkCUDAErrorPKc
	.type	_Z14checkCUDAErrorPKc,@function
_Z14checkCUDAErrorPKc:                  # @_Z14checkCUDAErrorPKc
	.cfi_startproc
# %bb.0:
	pushq	%r14
	.cfi_def_cfa_offset 16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	pushq	%rax
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -24
	.cfi_offset %r14, -16
	movq	%rdi, %r14
	callq	hipGetLastError
	testl	%eax, %eax
	jne	.LBB1_2
# %bb.1:
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	retq
.LBB1_2:
	.cfi_def_cfa_offset 32
	movl	%eax, %ebx
	movl	$_ZSt4cerr, %edi
	movl	$.L.str.7, %esi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rdi
	movq	%r14, %rsi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movl	$.L.str.8, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %r14
	movl	%ebx, %edi
	callq	hipGetErrorString
	movq	%r14, %rdi
	movq	%rax, %rsi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rdi
	callq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_
	movl	$-1, %edi
	callq	exit
.Lfunc_end1:
	.size	_Z14checkCUDAErrorPKc, .Lfunc_end1-_Z14checkCUDAErrorPKc
	.cfi_endproc
                                        # -- End function
	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"dimA "
	.size	.L.str, 6

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"h2d : PCI bandwidth %.1f GB/seconds \n"
	.size	.L.str.1, 38

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"d2d : PCI bandwidth %.1f GB/seconds \n"
	.size	.L.str.2, 38

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"d2h : PCI bandwidth %.1f GB/seconds \n"
	.size	.L.str.3, 38

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"hipMemcpy calls"
	.size	.L.str.4, 16

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"hipFree"
	.size	.L.str.5, 8

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"Correct!"
	.size	.L.str.6, 9

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"Cuda error: "
	.size	.L.str.7, 13

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	" "
	.size	.L.str.8, 2

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