#include <chrono>
#include <iostream>
#include <stdlib.h>

//Kernel Definition

__global__ void emptyKernel() {


}


int main () {
	using namespace std::chrono;
/*
	//Call emptyKernel to get the starting cost out of the measurement 
	emptyKernel<<<1,1>>>();

	for (int n = 0; n <= 6; n++){
		//Time Measururement Point 1
		high_resolution_clock::time_point timeBefore = high_resolution_clock::now();
		
		unsigned I = pow(10,  n);
		
		for (unsigned i = 0; i < I; i++) {
			emptyKernel<<<1,1>>>();
			cudaDeviceSynchronize();
		}	
		
		//Time Measururement Point 1
		high_resolution_clock::time_point timeAfter = high_resolution_clock::now();

		//Output Time Measurement Result
		duration<double> time_span = duration_cast<duration<double>>(timeAfter - timeBefore);
		
		std::cout << "Time for 10^" << n <<  " kernels started: " << time_span.count() << " seconds";
		std::cout << std:: endl;
	}
*/
	for(int j = 1; j <= 10; j++) {// Handles the js and the different array sizes
		for (int copyvalue = 1; copyvalue <= 4; copyvalue++) { //this loop handles the 4 different ways of copying with cudaMemcpy()
			size_t size = j * (1 << 27); // = 512 Mebibyte
			
			//Allocate arrays on the device and on the host
			void* src_h;
			void* dst_h;
			void* src_d;
			void* dst_d;

			cudaMalloc(&src_d, size);
			cudaMalloc(&dst_d, size);
			src_h = malloc(size);
			dst_h = malloc(size);

			//Time Measurement Point 1
			high_resolution_clock::time_point timeBefore = high_resolution_clock::now();	
			
			for (int i = 1; i <= 10; i++){//run 10 times to get better accuracy
				if (copyvalue == 1) cudaMemcpy(dst_d, src_h, size, cudaMemcpyHostToDevice); //host to device
				if (copyvalue == 2) cudaMemcpy(dst_h, src_d, size, cudaMemcpyDeviceToHost); //device to host
				if (copyvalue == 3) cudaMemcpy(dst_h, src_h, size, cudaMemcpyHostToHost); //host to host
				if (copyvalue == 4) cudaMemcpy(dst_d, src_d, size, cudaMemcpyDeviceToDevice); //device to device
				cudaDeviceSynchronize();
			}

			//Time Measurement Point 2
			high_resolution_clock::time_point timeAfter = high_resolution_clock::now();
		
			//auto err = cudaMemcpy(dst_d, src_h, size, cudaMemcpyDefault);	
			//if (err != cudaSuccess)
			//{
			//std::cout << "failure" << std::endl;
			//}
			//else {std::cout<< "success" << std::endl;}
			
			
			//Output Time Measurement Result
			duration<double> time_span = duration_cast<duration<double>>(timeAfter - timeBefore);
			
			std::cout << "Time for 10x copy with j = " << j <<  " and ";
			if (copyvalue == 1) {std::cout << "Host to Device: ";}
			if (copyvalue == 2) {std::cout << "Device to Host: ";}
			if (copyvalue == 3) {std::cout << "Host to Host: ";}
			if (copyvalue == 4) {std::cout << "Device to Device: ";}
			std::cout  << time_span.count() << " seconds";
			std::cout << std:: endl;


			cudaFree(src_d);
			cudaFree(dst_d);
			free(src_h);
			free(dst_h);
		}
	}

	return 0;
}

	.file	"tmpxft_00368049_00000000-6_memcpyTime.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB3740:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE3740:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC1:
	.string	"Time for 10x copy with j = "
.LC2:
	.string	" and "
.LC3:
	.string	"Host to Device: "
.LC4:
	.string	"Device to Host: "
.LC5:
	.string	"Host to Host: "
.LC6:
	.string	"Device to Device: "
.LC7:
	.string	" seconds"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB3734:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movl	$1, %r14d
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movl	$134217728, %ebx
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
.L3:
	movl	$1, %ebp
.L11:
	leaq	24(%rsp), %rdi
	movq	%rbx, %rsi
	movl	$10, %r12d
	call	cudaMalloc@PLT
	movq	%rbx, %rsi
	leaq	32(%rsp), %rdi
	call	cudaMalloc@PLT
	movq	%rbx, %rdi
	call	malloc@PLT
	movq	%rbx, %rdi
	movq	%rax, 8(%rsp)
	call	malloc@PLT
	movq	%rax, %r13
	call	_ZNSt6chrono3_V212system_clock3nowEv@PLT
	movq	%rax, %r15
.L7:
	cmpl	$1, %ebp
	jne	.L4
	movq	8(%rsp), %rsi
	movl	$1, %ecx
	movq	%rbx, %rdx
	jmp	.L24
.L4:
	cmpl	$2, %ebp
	jne	.L6
	movq	24(%rsp), %rsi
	movl	$2, %ecx
	movq	%rbx, %rdx
	jmp	.L27
.L6:
	cmpl	$3, %ebp
	jne	.L29
	movq	8(%rsp), %rsi
	xorl	%ecx, %ecx
	movq	%rbx, %rdx
.L27:
	movq	%r13, %rdi
	jmp	.L25
.L29:
	movq	24(%rsp), %rsi
	movl	$3, %ecx
	movq	%rbx, %rdx
.L24:
	movq	32(%rsp), %rdi
.L25:
	call	cudaMemcpy@PLT
	call	cudaDeviceSynchronize@PLT
	decl	%r12d
	jne	.L7
	call	_ZNSt6chrono3_V212system_clock3nowEv@PLT
	leaq	_ZSt4cout(%rip), %r12
	leaq	.LC1(%rip), %rsi
	subq	%r15, %rax
	movq	%r12, %rdi
	cvtsi2sdq	%rax, %xmm0
	divsd	.LC0(%rip), %xmm0
	movq	%xmm0, %r15
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	%r14d, %esi
	movq	%rax, %rdi
	call	_ZNSolsEi@PLT
	leaq	.LC2(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC3(%rip), %rsi
	cmpl	$1, %ebp
	je	.L26
	leaq	.LC4(%rip), %rsi
	cmpl	$2, %ebp
	je	.L26
	leaq	.LC5(%rip), %rsi
	cmpl	$3, %ebp
	je	.L26
	leaq	.LC6(%rip), %rsi
.L26:
	movq	%r12, %rdi
	incl	%ebp
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%r15, %xmm0
	movq	%r12, %rdi
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	leaq	.LC7(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%r12, %rdi
	call	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT
	movq	24(%rsp), %rdi
	call	cudaFree@PLT
	movq	32(%rsp), %rdi
	call	cudaFree@PLT
	movq	8(%rsp), %rdi
	call	free@PLT
	movq	%r13, %rdi
	call	free@PLT
	cmpl	$5, %ebp
	jne	.L11
	incl	%r14d
	addq	$134217728, %rbx
	cmpl	$11, %r14d
	jne	.L3
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	je	.L17
	call	__stack_chk_fail@PLT
.L17:
	addq	$56, %rsp
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.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
	ret
	.cfi_endproc
.LFE3734:
	.size	main, .-main
	.text
	.globl	_Z30__device_stub__Z11emptyKernelvv
	.type	_Z30__device_stub__Z11emptyKernelvv, @function
_Z30__device_stub__Z11emptyKernelvv:
.LFB3762:
	.cfi_startproc
	endbr64
	subq	$88, %rsp
	.cfi_def_cfa_offset 96
	movq	%fs:40, %rax
	movq	%rax, 72(%rsp)
	movabsq	$4294967297, %rax
	leaq	8(%rsp), %rcx
	movq	%rsp, %rdx
	leaq	28(%rsp), %rsi
	leaq	16(%rsp), %rdi
	movl	$1, 24(%rsp)
	movl	$1, 36(%rsp)
	movq	%rax, 16(%rsp)
	movq	%rax, 28(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L30
	pushq	8(%rsp)
	.cfi_def_cfa_offset 104
	leaq	_Z11emptyKernelv(%rip), %rdi
	pushq	8(%rsp)
	.cfi_def_cfa_offset 112
	movq	44(%rsp), %rcx
	movl	52(%rsp), %r8d
	movq	32(%rsp), %rsi
	movl	40(%rsp), %edx
	leaq	80(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 104
	popq	%rdx
	.cfi_def_cfa_offset 96
.L30:
	movq	72(%rsp), %rax
	subq	%fs:40, %rax
	je	.L32
	call	__stack_chk_fail@PLT
.L32:
	addq	$88, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3762:
	.size	_Z30__device_stub__Z11emptyKernelvv, .-_Z30__device_stub__Z11emptyKernelvv
	.globl	_Z11emptyKernelv
	.type	_Z11emptyKernelv, @function
_Z11emptyKernelv:
.LFB3763:
	.cfi_startproc
	endbr64
	jmp	_Z30__device_stub__Z11emptyKernelvv
	.cfi_endproc
.LFE3763:
	.size	_Z11emptyKernelv, .-_Z11emptyKernelv
	.section	.rodata.str1.1
.LC8:
	.string	"_Z11emptyKernelv"
	.section	.text.startup
	.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
	pushq	$0
	.cfi_def_cfa_offset 24
	xorl	%r9d, %r9d
	orl	$-1, %r8d
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC8(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z11emptyKernelv(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 48
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFunction@PLT
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	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
.LC0:
	.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:


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

//Kernel Definition

__global__ void emptyKernel() {


}


int main () {
	using namespace std::chrono;
/*
	//Call emptyKernel to get the starting cost out of the measurement 
	emptyKernel<<<1,1>>>();

	for (int n = 0; n <= 6; n++){
		//Time Measururement Point 1
		high_resolution_clock::time_point timeBefore = high_resolution_clock::now();
		
		unsigned I = pow(10,  n);
		
		for (unsigned i = 0; i < I; i++) {
			emptyKernel<<<1,1>>>();
			cudaDeviceSynchronize();
		}	
		
		//Time Measururement Point 1
		high_resolution_clock::time_point timeAfter = high_resolution_clock::now();

		//Output Time Measurement Result
		duration<double> time_span = duration_cast<duration<double>>(timeAfter - timeBefore);
		
		std::cout << "Time for 10^" << n <<  " kernels started: " << time_span.count() << " seconds";
		std::cout << std:: endl;
	}
*/
	for(int j = 1; j <= 10; j++) {// Handles the js and the different array sizes
		for (int copyvalue = 1; copyvalue <= 4; copyvalue++) { //this loop handles the 4 different ways of copying with cudaMemcpy()
			size_t size = j * (1 << 27); // = 512 Mebibyte
			
			//Allocate arrays on the device and on the host
			void* src_h;
			void* dst_h;
			void* src_d;
			void* dst_d;

			hipMalloc(&src_d, size);
			hipMalloc(&dst_d, size);
			src_h = malloc(size);
			dst_h = malloc(size);

			//Time Measurement Point 1
			high_resolution_clock::time_point timeBefore = high_resolution_clock::now();	
			
			for (int i = 1; i <= 10; i++){//run 10 times to get better accuracy
				if (copyvalue == 1) hipMemcpy(dst_d, src_h, size, hipMemcpyHostToDevice); //host to device
				if (copyvalue == 2) hipMemcpy(dst_h, src_d, size, hipMemcpyDeviceToHost); //device to host
				if (copyvalue == 3) hipMemcpy(dst_h, src_h, size, hipMemcpyHostToHost); //host to host
				if (copyvalue == 4) hipMemcpy(dst_d, src_d, size, hipMemcpyDeviceToDevice); //device to device
				hipDeviceSynchronize();
			}

			//Time Measurement Point 2
			high_resolution_clock::time_point timeAfter = high_resolution_clock::now();
		
			//auto err = cudaMemcpy(dst_d, src_h, size, cudaMemcpyDefault);	
			//if (err != cudaSuccess)
			//{
			//std::cout << "failure" << std::endl;
			//}
			//else {std::cout<< "success" << std::endl;}
			
			
			//Output Time Measurement Result
			duration<double> time_span = duration_cast<duration<double>>(timeAfter - timeBefore);
			
			std::cout << "Time for 10x copy with j = " << j <<  " and ";
			if (copyvalue == 1) {std::cout << "Host to Device: ";}
			if (copyvalue == 2) {std::cout << "Device to Host: ";}
			if (copyvalue == 3) {std::cout << "Host to Host: ";}
			if (copyvalue == 4) {std::cout << "Device to Device: ";}
			std::cout  << time_span.count() << " seconds";
			std::cout << std:: endl;


			hipFree(src_d);
			hipFree(dst_d);
			free(src_h);
			free(dst_h);
		}
	}

	return 0;
}

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

                                        # End of file scope inline assembly
	.globl	_Z26__device_stub__emptyKernelv # -- Begin function _Z26__device_stub__emptyKernelv
	.type	_Z26__device_stub__emptyKernelv,@function
_Z26__device_stub__emptyKernelv:        # @_Z26__device_stub__emptyKernelv
	.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	$56, %rsp
	.cfi_def_cfa_offset 96
	.cfi_offset %rbx, -40
	.cfi_offset %r12, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rbx
	leaq	24(%rsp), %r14
	leaq	16(%rsp), %r15
	leaq	8(%rsp), %r12
	movq	%rbx, %rdi
	movq	%r14, %rsi
	movq	%r15, %rdx
	movq	%r12, %rcx
	callq	__hipPopCallConfiguration
	movq	(%rbx), %rsi
	movl	8(%rbx), %edx
	movq	(%r14), %rcx
	movl	8(%r14), %r8d
	movq	%rsp, %r9
	movl	$_Z11emptyKernelv, %edi
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	pushq	(%r15)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$72, %rsp
	.cfi_adjust_cfa_offset -72
	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	_Z26__device_stub__emptyKernelv, .Lfunc_end0-_Z26__device_stub__emptyKernelv
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI1_0:
	.quad	0x41cdcd6500000000              # double 1.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
	movl	$1, %r14d
.LBB1_1:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_2 Depth 2
                                        #       Child Loop BB1_3 Depth 3
	movq	%r14, %r12
	shlq	$27, %r12
	movl	$1, %r15d
	movq	%r14, 32(%rsp)                  # 8-byte Spill
.LBB1_2:                                #   Parent Loop BB1_1 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB1_3 Depth 3
	leaq	24(%rsp), %rdi
	movq	%r12, %rsi
	callq	hipMalloc
	leaq	16(%rsp), %rdi
	movq	%r12, %rsi
	callq	hipMalloc
	movq	%r12, %rdi
	callq	malloc
	movq	%rax, %r13
	movq	%r12, %rdi
	callq	malloc
	movq	%rax, %rbp
	movl	$10, %r14d
	callq	_ZNSt6chrono3_V212system_clock3nowEv
	movq	%rax, 8(%rsp)                   # 8-byte Spill
	leal	-1(%r15), %ebx
.LBB1_3:                                #   Parent Loop BB1_1 Depth=1
                                        #     Parent Loop BB1_2 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	cmpl	$3, %ebx
	ja	.LBB1_14
# %bb.4:                                #   in Loop: Header=BB1_3 Depth=3
	jmpq	*.LJTI1_0(,%rbx,8)
.LBB1_9:                                #   in Loop: Header=BB1_3 Depth=3
	movq	16(%rsp), %rdi
	movq	%r13, %rsi
	movq	%r12, %rdx
	movl	$1, %ecx
	jmp	.LBB1_13
.LBB1_11:                               #   in Loop: Header=BB1_3 Depth=3
	movq	%rbp, %rdi
	movq	%r13, %rsi
	movq	%r12, %rdx
	xorl	%ecx, %ecx
	jmp	.LBB1_13
.LBB1_12:                               #   in Loop: Header=BB1_3 Depth=3
	movq	16(%rsp), %rdi
	movq	24(%rsp), %rsi
	movq	%r12, %rdx
	movl	$3, %ecx
	jmp	.LBB1_13
.LBB1_10:                               #   in Loop: Header=BB1_3 Depth=3
	movq	24(%rsp), %rsi
	movq	%rbp, %rdi
	movq	%r12, %rdx
	movl	$2, %ecx
.LBB1_13:                               #   in Loop: Header=BB1_3 Depth=3
	callq	hipMemcpy
.LBB1_14:                               #   in Loop: Header=BB1_3 Depth=3
	callq	hipDeviceSynchronize
	decl	%r14d
	jne	.LBB1_3
# %bb.7:                                #   in Loop: Header=BB1_2 Depth=2
	callq	_ZNSt6chrono3_V212system_clock3nowEv
	subq	8(%rsp), %rax                   # 8-byte Folded Reload
	xorps	%xmm0, %xmm0
	cvtsi2sd	%rax, %xmm0
	divsd	.LCPI1_0(%rip), %xmm0
	movsd	%xmm0, 8(%rsp)                  # 8-byte Spill
	movl	$_ZSt4cout, %edi
	movl	$.L.str, %esi
	movl	$27, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	$_ZSt4cout, %edi
	movq	32(%rsp), %r14                  # 8-byte Reload
	movl	%r14d, %esi
	callq	_ZNSolsEi
	movl	$.L.str.1, %esi
	movl	$5, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	cmpl	$3, %ebx
	ja	.LBB1_21
# %bb.8:                                #   in Loop: Header=BB1_2 Depth=2
	jmpq	*.LJTI1_1(,%rbx,8)
.LBB1_15:                               #   in Loop: Header=BB1_2 Depth=2
	movl	$_ZSt4cout, %edi
	movl	$.L.str.2, %esi
	jmp	.LBB1_16
.LBB1_18:                               #   in Loop: Header=BB1_2 Depth=2
	movl	$_ZSt4cout, %edi
	movl	$.L.str.4, %esi
	movl	$14, %edx
	jmp	.LBB1_20
.LBB1_19:                               #   in Loop: Header=BB1_2 Depth=2
	movl	$_ZSt4cout, %edi
	movl	$.L.str.5, %esi
	movl	$18, %edx
	jmp	.LBB1_20
.LBB1_17:                               #   in Loop: Header=BB1_2 Depth=2
	movl	$_ZSt4cout, %edi
	movl	$.L.str.3, %esi
.LBB1_16:                               #   in Loop: Header=BB1_2 Depth=2
	movl	$16, %edx
.LBB1_20:                               #   in Loop: Header=BB1_2 Depth=2
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.LBB1_21:                               #   in Loop: Header=BB1_2 Depth=2
	movl	$_ZSt4cout, %edi
	movsd	8(%rsp), %xmm0                  # 8-byte Reload
                                        # xmm0 = mem[0],zero
	callq	_ZNSo9_M_insertIdEERSoT_
	movl	$.L.str.6, %esi
	movl	$8, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	_ZSt4cout(%rip), %rax
	movq	-24(%rax), %rdi
	movl	$_ZSt4cout, %eax
	addq	%rax, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	movq	24(%rsp), %rdi
	callq	hipFree
	movq	16(%rsp), %rdi
	callq	hipFree
	movq	%r13, %rdi
	callq	free
	movq	%rbp, %rdi
	callq	free
	incl	%r15d
	cmpl	$5, %r15d
	jne	.LBB1_2
# %bb.5:                                #   in Loop: Header=BB1_1 Depth=1
	incq	%r14
	cmpq	$11, %r14
	jne	.LBB1_1
# %bb.6:
	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_end1:
	.size	main, .Lfunc_end1-main
	.cfi_endproc
	.section	.rodata,"a",@progbits
	.p2align	3, 0x0
.LJTI1_0:
	.quad	.LBB1_9
	.quad	.LBB1_10
	.quad	.LBB1_11
	.quad	.LBB1_12
.LJTI1_1:
	.quad	.LBB1_15
	.quad	.LBB1_17
	.quad	.LBB1_18
	.quad	.LBB1_19
                                        # -- End function
	.text
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	jne	.LBB2_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB2_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z11emptyKernelv, %esi
	movl	$.L__unnamed_1, %edx
	movl	$.L__unnamed_1, %ecx
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$__hip_module_dtor, %edi
	addq	$40, %rsp
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_end2:
	.size	__hip_module_ctor, .Lfunc_end2-__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	.LBB3_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
.LBB3_2:
	retq
.Lfunc_end3:
	.size	__hip_module_dtor, .Lfunc_end3-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	_Z11emptyKernelv,@object        # @_Z11emptyKernelv
	.section	.rodata,"a",@progbits
	.globl	_Z11emptyKernelv
	.p2align	3, 0x0
_Z11emptyKernelv:
	.quad	_Z26__device_stub__emptyKernelv
	.size	_Z11emptyKernelv, 8

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"Time for 10x copy with j = "
	.size	.L.str, 28

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	" and "
	.size	.L.str.1, 6

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"Host to Device: "
	.size	.L.str.2, 17

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"Device to Host: "
	.size	.L.str.3, 17

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"Host to Host: "
	.size	.L.str.4, 15

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"Device to Device: "
	.size	.L.str.5, 19

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

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z11emptyKernelv"
	.size	.L__unnamed_1, 17

	.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 _Z26__device_stub__emptyKernelv
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z11emptyKernelv
	.addrsig_sym _ZSt4cout
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z11emptyKernelv        ; -- Begin function _Z11emptyKernelv
	.globl	_Z11emptyKernelv
	.p2align	8
	.type	_Z11emptyKernelv,@function
_Z11emptyKernelv:                       ; @_Z11emptyKernelv
; %bb.0:
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z11emptyKernelv
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 0
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 0
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 1
		.amdhsa_next_free_sgpr 1
		.amdhsa_reserve_vcc 0
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end0:
	.size	_Z11emptyKernelv, .Lfunc_end0-_Z11emptyKernelv
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 4
; NumSgprs: 0
; NumVgprs: 0
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 0
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 1
; NumVGPRsForWavesPerEU: 1
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.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_
	.amdgpu_metadata
---
amdhsa.kernels:
  - .args:           []
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 4
    .kernarg_segment_size: 0
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z11emptyKernelv
    .private_segment_fixed_size: 0
    .sgpr_count:     0
    .sgpr_spill_count: 0
    .symbol:         _Z11emptyKernelv.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     0
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
