#include<iostream>
#include<cuda_runtime_api.h>
#include<time.h>
#include<stdlib.h>

#define SAFE_CALL(CallInstruction){ \
	cudaError_t cuerr=CallInstruction; \
	if(cuerr!=cudaSuccess){ \
		printf("CUDA error:%s at call \"" #CallInstruction"\"\n",cudaGetErrorString(cuerr));\
			throw "error in CUDA API function,aborting...";\
	} \
}

#define SAFE_KERNEL_CALL(KernelCallInstruction){\
	KernelCallInstruction; \
	cudaError_t cuerr=cudaGetLastError();\
	if(cuerr!=cudaSuccess){\
		printf("CUDA error in kernel launch:%s at kernel \"" #KernelCallInstruction "\"\n",cudaGetErrorString(cuerr)); \
			throw "error in CUDA kernel launch,aborting...";\
	}\
	cuerr=cudaDeviceSynchronize();\
	if(cuerr!=cudaSuccess){\
		printf("CUDA error in kernel execution:%s at kernel\"" #KernelCallInstruction "\"\n",cudaGetErrorString(cuerr));\
			throw "error in CUDA kernel execution,aborting...";\
	}\
}

#define size_mb 1048576

//ядро
__global__ void ram(int *ptrs,int *result,int *data,int num)
{
	int idx=blockIdx.x*blockDim.x+threadIdx.x;
	if(idx<num)
	{
		result[idx]=data[ptrs[idx]];
	}
}


int main(int argc,char **argv)
{
	//int n=atoi(argv[1]);
	int n=1;
	long int cached_array_size=size_mb*n;
	long int large_array_size=size_mb*1024;

	//host data
	int *h_ptrs,*h_result,*h_data;

	h_ptrs=(int*)malloc(large_array_size);	
	h_result=(int*)malloc(large_array_size);
	h_data=(int*)malloc(cached_array_size);

	for(int i=0;i<(cached_array_size/sizeof(int));i++)
	{
		h_data[i]=i;
	}

	for(int i=0;i<(large_array_size/sizeof(int));i++)
	{
		h_result[i]=0;
		h_ptrs[i]=rand()%cached_array_size;
	}

	//device data
	int *d_ptrs,*d_result,*d_data;

	SAFE_CALL(cudaMalloc(&d_ptrs,large_array_size));
	SAFE_CALL(cudaMalloc(&d_result,large_array_size));
	SAFE_CALL(cudaMalloc(&d_data,cached_array_size));

	SAFE_CALL(cudaMemcpy(d_ptrs,h_ptrs,large_array_size,cudaMemcpyHostToDevice));
	SAFE_CALL(cudaMemcpy(d_result,h_result,large_array_size,cudaMemcpyHostToDevice));
	SAFE_CALL(cudaMemcpy(d_data,h_data,cached_array_size,cudaMemcpyHostToDevice));
	int blocksize=1024;
	int gridsize=(((large_array_size/sizeof(int))-1)/blocksize)+1;

	cudaEvent_t start,finish;
	SAFE_CALL(cudaEventCreate(&start));
	SAFE_CALL(cudaEventCreate(&finish));
	
	SAFE_CALL(cudaDeviceSynchronize());

	SAFE_CALL(cudaEventRecord(start));
	SAFE_KERNEL_CALL((ram<<<gridsize,blocksize>>>(d_ptrs,d_result,d_data,large_array_size/sizeof(int))));
	SAFE_CALL(cudaEventRecord(finish));

	SAFE_CALL(cudaMemcpy(h_result,d_result,large_array_size,cudaMemcpyDeviceToHost));
	SAFE_CALL(cudaEventSynchronize(finish));
	
	float milliseconds=0;
	SAFE_CALL(cudaEventElapsedTime(&milliseconds,start,finish));
	
	printf("Used time is(s):%f",milliseconds/1000);
	printf("Effective Bandwidth(GB/s):%fn",large_array_size*3/milliseconds/1e6);
	
	FILE *bandwidth=fopen("bandwidth.dat","a");
	fprintf(bandwidth,"%d %fn",n,large_array_size*3/milliseconds/1e6);

	SAFE_CALL(cudaFree(d_ptrs));
	SAFE_CALL(cudaFree(d_result));
	SAFE_CALL(cudaFree(d_data));

	free(h_ptrs);
	free(h_result);
	free(h_data);

	return 0;
}

	.file	"tmpxft_002fce3f_00000000-6_cuda.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB3638:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE3638:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z27__device_stub__Z3ramPiS_S_iPiS_S_i
	.type	_Z27__device_stub__Z3ramPiS_S_iPiS_S_i, @function
_Z27__device_stub__Z3ramPiS_S_iPiS_S_i:
.LFB3660:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movq	%rdi, 24(%rsp)
	leaq	56(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	68(%rsp), %rsi
	movq	%rdx, 8(%rsp)
	leaq	40(%rsp), %rdx
	movl	%ecx, 4(%rsp)
	leaq	48(%rsp), %rcx
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 64(%rsp)
	movq	%rax, 104(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	4(%rsp), %rax
	movq	%rax, 128(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 56(%rsp)
	movq	%rax, 68(%rsp)
	movl	$1, 76(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L2
	pushq	48(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z3ramPiS_S_i(%rip), %rdi
	pushq	48(%rsp)
	.cfi_def_cfa_offset 176
	movq	84(%rsp), %rcx
	movl	92(%rsp), %r8d
	movq	72(%rsp), %rsi
	movl	80(%rsp), %edx
	leaq	120(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 168
	popq	%rdx
	.cfi_def_cfa_offset 160
.L2:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L4
	call	__stack_chk_fail@PLT
.L4:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3660:
	.size	_Z27__device_stub__Z3ramPiS_S_iPiS_S_i, .-_Z27__device_stub__Z3ramPiS_S_iPiS_S_i
	.globl	_Z3ramPiS_S_i
	.type	_Z3ramPiS_S_i, @function
_Z3ramPiS_S_i:
.LFB3661:
	.cfi_startproc
	endbr64
	jmp	_Z27__device_stub__Z3ramPiS_S_iPiS_S_i
	.cfi_endproc
.LFE3661:
	.size	_Z3ramPiS_S_i, .-_Z3ramPiS_S_i
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"CUDA error:%s at call \"cudaMalloc(&d_ptrs,large_array_size)\"\n"
.LC1:
	.string	"error in CUDA API function,aborting..."
.LC2:
	.string	"CUDA error:%s at call \"cudaMalloc(&d_result,large_array_size)\"\n"
.LC3:
	.string	"CUDA error:%s at call \"cudaMalloc(&d_data,cached_array_size)\"\n"
.LC4:
	.string	"CUDA error:%s at call \"cudaMemcpy(d_ptrs,h_ptrs,large_array_size,cudaMemcpyHostToDevice)\"\n"
.LC5:
	.string	"CUDA error:%s at call \"cudaMemcpy(d_result,h_result,large_array_size,cudaMemcpyHostToDevice)\"\n"
.LC6:
	.string	"CUDA error:%s at call \"cudaMemcpy(d_data,h_data,cached_array_size,cudaMemcpyHostToDevice)\"\n"
.LC7:
	.string	"CUDA error:%s at call \"cudaEventCreate(&start)\"\n"
.LC8:
	.string	"CUDA error:%s at call \"cudaEventCreate(&finish)\"\n"
.LC9:
	.string	"CUDA error:%s at call \"cudaDeviceSynchronize()\"\n"
.LC10:
	.string	"CUDA error:%s at call \"cudaEventRecord(start)\"\n"
.LC11:
	.string	"CUDA error in kernel launch:%s at kernel \"(ram<<<gridsize,blocksize>>>(d_ptrs,d_result,d_data,large_array_size/sizeof(int)))\"\n"
.LC12:
	.string	"error in CUDA kernel launch,aborting..."
.LC13:
	.string	"CUDA error in kernel execution:%s at kernel\"(ram<<<gridsize,blocksize>>>(d_ptrs,d_result,d_data,large_array_size/sizeof(int)))\"\n"
.LC14:
	.string	"error in CUDA kernel execution,aborting..."
.LC15:
	.string	"CUDA error:%s at call \"cudaEventRecord(finish)\"\n"
.LC16:
	.string	"CUDA error:%s at call \"cudaMemcpy(h_result,d_result,large_array_size,cudaMemcpyDeviceToHost)\"\n"
.LC17:
	.string	"CUDA error:%s at call \"cudaEventSynchronize(finish)\"\n"
.LC19:
	.string	"CUDA error:%s at call \"cudaEventElapsedTime(&milliseconds,start,finish)\"\n"
.LC21:
	.string	"Used time is(s):%f"
.LC24:
	.string	"Effective Bandwidth(GB/s):%fn"
.LC25:
	.string	"a"
.LC26:
	.string	"bandwidth.dat"
.LC27:
	.string	"%d %fn"
.LC28:
	.string	"CUDA error:%s at call \"cudaFree(d_ptrs)\"\n"
.LC29:
	.string	"CUDA error:%s at call \"cudaFree(d_result)\"\n"
.LC30:
	.string	"CUDA error:%s at call \"cudaFree(d_data)\"\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB3635:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	movl	$1073741824, %edi
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	subq	$80, %rsp
	.cfi_def_cfa_offset 128
	movq	%fs:40, %rax
	movq	%rax, 72(%rsp)
	xorl	%eax, %eax
	call	malloc@PLT
	movl	$1073741824, %edi
	movq	%rax, %r12
	call	malloc@PLT
	movl	$1048576, %edi
	movq	%rax, %rbx
	call	malloc@PLT
	movq	%rax, %rbp
	xorl	%eax, %eax
.L9:
	movl	%eax, 0(%rbp,%rax,4)
	incq	%rax
	cmpq	$262144, %rax
	jne	.L9
	xorl	%r13d, %r13d
	movl	$1048576, %r14d
.L10:
	xorl	%eax, %eax
	movl	%eax, (%rbx,%r13)
	call	rand@PLT
	cltq
	cqto
	idivq	%r14
	movl	%edx, (%r12,%r13)
	addq	$4, %r13
	cmpq	$1073741824, %r13
	jne	.L10
	leaq	8(%rsp), %rdi
	movl	$1073741824, %esi
	call	cudaMalloc@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L11
	call	cudaGetErrorString@PLT
	leaq	.LC0(%rip), %rsi
	movq	%rax, %rdx
	jmp	.L56
.L11:
	leaq	16(%rsp), %rdi
	movl	$1073741824, %esi
	call	cudaMalloc@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L13
	call	cudaGetErrorString@PLT
	leaq	.LC2(%rip), %rsi
	movq	%rax, %rdx
	jmp	.L56
.L13:
	leaq	24(%rsp), %rdi
	movl	$1048576, %esi
	call	cudaMalloc@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L15
	call	cudaGetErrorString@PLT
	leaq	.LC3(%rip), %rsi
	movq	%rax, %rdx
	jmp	.L56
.L15:
	movq	8(%rsp), %rdi
	movl	$1, %ecx
	movl	$1073741824, %edx
	movq	%r12, %rsi
	call	cudaMemcpy@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L17
	call	cudaGetErrorString@PLT
	leaq	.LC4(%rip), %rsi
	movq	%rax, %rdx
	jmp	.L56
.L17:
	movq	16(%rsp), %rdi
	movl	$1, %ecx
	movl	$1073741824, %edx
	movq	%rbx, %rsi
	call	cudaMemcpy@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L19
	call	cudaGetErrorString@PLT
	leaq	.LC5(%rip), %rsi
	movq	%rax, %rdx
	jmp	.L56
.L19:
	movq	24(%rsp), %rdi
	movl	$1, %ecx
	movl	$1048576, %edx
	movq	%rbp, %rsi
	call	cudaMemcpy@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L21
	call	cudaGetErrorString@PLT
	leaq	.LC6(%rip), %rsi
	movq	%rax, %rdx
	jmp	.L56
.L21:
	leaq	32(%rsp), %rdi
	call	cudaEventCreate@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L23
	call	cudaGetErrorString@PLT
	leaq	.LC7(%rip), %rsi
	movq	%rax, %rdx
	jmp	.L56
.L23:
	leaq	40(%rsp), %rdi
	call	cudaEventCreate@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L25
	call	cudaGetErrorString@PLT
	leaq	.LC8(%rip), %rsi
	movq	%rax, %rdx
	jmp	.L56
.L25:
	call	cudaDeviceSynchronize@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L27
	call	cudaGetErrorString@PLT
	leaq	.LC9(%rip), %rsi
	movq	%rax, %rdx
	jmp	.L56
.L27:
	movq	32(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L29
	call	cudaGetErrorString@PLT
	leaq	.LC10(%rip), %rsi
	movq	%rax, %rdx
	jmp	.L56
.L29:
	movl	$4194305, %edx
	movl	$16385, %edi
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	salq	$10, %rdx
	salq	$18, %rdi
	movl	$1, %ecx
	movl	$1, %esi
	movq	%rdx, 60(%rsp)
	movl	$1, 68(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L31
	movq	24(%rsp), %rdx
	movq	16(%rsp), %rsi
	movl	$268435456, %ecx
	movq	8(%rsp), %rdi
	call	_Z27__device_stub__Z3ramPiS_S_iPiS_S_i
.L31:
	call	cudaGetLastError@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L32
	call	cudaGetErrorString@PLT
	leaq	.LC11(%rip), %rsi
	movl	$2, %edi
	movq	%rax, %rdx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	$8, %edi
	call	__cxa_allocate_exception@PLT
	movq	%rax, %rdi
	leaq	.LC12(%rip), %rax
	jmp	.L57
.L32:
	call	cudaDeviceSynchronize@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L34
	call	cudaGetErrorString@PLT
	leaq	.LC13(%rip), %rsi
	movl	$2, %edi
	movq	%rax, %rdx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	$8, %edi
	call	__cxa_allocate_exception@PLT
	movq	%rax, %rdi
	leaq	.LC14(%rip), %rax
	jmp	.L57
.L34:
	movq	40(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L36
	call	cudaGetErrorString@PLT
	leaq	.LC15(%rip), %rsi
	movq	%rax, %rdx
	jmp	.L56
.L36:
	movq	16(%rsp), %rsi
	movq	%rbx, %rdi
	movl	$2, %ecx
	movl	$1073741824, %edx
	call	cudaMemcpy@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L38
	call	cudaGetErrorString@PLT
	leaq	.LC16(%rip), %rsi
	movq	%rax, %rdx
	jmp	.L56
.L38:
	movq	40(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L40
	call	cudaGetErrorString@PLT
	leaq	.LC17(%rip), %rsi
	movq	%rax, %rdx
	jmp	.L56
.L40:
	movq	40(%rsp), %rdx
	movq	32(%rsp), %rsi
	leaq	60(%rsp), %rdi
	movl	$0x00000000, 60(%rsp)
	call	cudaEventElapsedTime@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L42
	call	cudaGetErrorString@PLT
	leaq	.LC19(%rip), %rsi
	movq	%rax, %rdx
	jmp	.L56
.L42:
	leaq	.LC21(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	movss	60(%rsp), %xmm0
	divss	.LC20(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	call	__printf_chk@PLT
	movb	$1, %al
	leaq	.LC24(%rip), %rsi
	movl	$2, %edi
	movss	.LC22(%rip), %xmm0
	divss	60(%rsp), %xmm0
	cvtss2sd	%xmm0, %xmm0
	divsd	.LC23(%rip), %xmm0
	call	__printf_chk@PLT
	leaq	.LC25(%rip), %rsi
	leaq	.LC26(%rip), %rdi
	call	fopen@PLT
	movl	$1, %ecx
	leaq	.LC27(%rip), %rdx
	movl	$2, %esi
	movq	%rax, %rdi
	movb	$1, %al
	movss	.LC22(%rip), %xmm0
	divss	60(%rsp), %xmm0
	cvtss2sd	%xmm0, %xmm0
	divsd	.LC23(%rip), %xmm0
	call	__fprintf_chk@PLT
	movq	8(%rsp), %rdi
	call	cudaFree@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L44
	call	cudaGetErrorString@PLT
	leaq	.LC28(%rip), %rsi
	movq	%rax, %rdx
	jmp	.L56
.L44:
	movq	16(%rsp), %rdi
	call	cudaFree@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L46
	call	cudaGetErrorString@PLT
	leaq	.LC29(%rip), %rsi
	movq	%rax, %rdx
	jmp	.L56
.L46:
	movq	24(%rsp), %rdi
	call	cudaFree@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L48
	call	cudaGetErrorString@PLT
	leaq	.LC30(%rip), %rsi
	movq	%rax, %rdx
.L56:
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	$8, %edi
	call	__cxa_allocate_exception@PLT
	movq	%rax, %rdi
	leaq	.LC1(%rip), %rax
.L57:
	movq	%rax, (%rdi)
	movq	72(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L55
	xorl	%edx, %edx
	leaq	_ZTIPKc(%rip), %rsi
	call	__cxa_throw@PLT
.L48:
	movq	%r12, %rdi
	call	free@PLT
	movq	%rbx, %rdi
	call	free@PLT
	movq	%rbp, %rdi
	call	free@PLT
	movq	72(%rsp), %rax
	subq	%fs:40, %rax
	je	.L50
.L55:
	call	__stack_chk_fail@PLT
.L50:
	addq	$80, %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
.LFE3635:
	.size	main, .-main
	.section	.rodata.str1.1
.LC31:
	.string	"_Z3ramPiS_S_i"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB3663:
	.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	.LC31(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z3ramPiS_S_i(%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
.LFE3663:
	.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.cst4,"aM",@progbits,4
	.align 4
.LC20:
	.long	1148846080
	.align 4
.LC22:
	.long	1329594368
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC23:
	.long	0
	.long	1093567616
	.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<iostream>
#include<hip/hip_runtime_api.h>
#include<time.h>
#include<stdlib.h>

#define SAFE_CALL(CallInstruction){ \
	hipError_t cuerr=CallInstruction; \
	if(cuerr!=hipSuccess){ \
		printf("CUDA error:%s at call \"" #CallInstruction"\"\n",hipGetErrorString(cuerr));\
			throw "error in CUDA API function,aborting...";\
	} \
}

#define SAFE_KERNEL_CALL(KernelCallInstruction){\
	KernelCallInstruction; \
	hipError_t cuerr=hipGetLastError();\
	if(cuerr!=hipSuccess){\
		printf("CUDA error in kernel launch:%s at kernel \"" #KernelCallInstruction "\"\n",hipGetErrorString(cuerr)); \
			throw "error in CUDA kernel launch,aborting...";\
	}\
	cuerr=hipDeviceSynchronize();\
	if(cuerr!=hipSuccess){\
		printf("CUDA error in kernel execution:%s at kernel\"" #KernelCallInstruction "\"\n",hipGetErrorString(cuerr));\
			throw "error in CUDA kernel execution,aborting...";\
	}\
}

#define size_mb 1048576

//ядро
__global__ void ram(int *ptrs,int *result,int *data,int num)
{
	int idx=blockIdx.x*blockDim.x+threadIdx.x;
	if(idx<num)
	{
		result[idx]=data[ptrs[idx]];
	}
}


int main(int argc,char **argv)
{
	//int n=atoi(argv[1]);
	int n=1;
	long int cached_array_size=size_mb*n;
	long int large_array_size=size_mb*1024;

	//host data
	int *h_ptrs,*h_result,*h_data;

	h_ptrs=(int*)malloc(large_array_size);	
	h_result=(int*)malloc(large_array_size);
	h_data=(int*)malloc(cached_array_size);

	for(int i=0;i<(cached_array_size/sizeof(int));i++)
	{
		h_data[i]=i;
	}

	for(int i=0;i<(large_array_size/sizeof(int));i++)
	{
		h_result[i]=0;
		h_ptrs[i]=rand()%cached_array_size;
	}

	//device data
	int *d_ptrs,*d_result,*d_data;

	SAFE_CALL(hipMalloc(&d_ptrs,large_array_size));
	SAFE_CALL(hipMalloc(&d_result,large_array_size));
	SAFE_CALL(hipMalloc(&d_data,cached_array_size));

	SAFE_CALL(hipMemcpy(d_ptrs,h_ptrs,large_array_size,hipMemcpyHostToDevice));
	SAFE_CALL(hipMemcpy(d_result,h_result,large_array_size,hipMemcpyHostToDevice));
	SAFE_CALL(hipMemcpy(d_data,h_data,cached_array_size,hipMemcpyHostToDevice));
	int blocksize=1024;
	int gridsize=(((large_array_size/sizeof(int))-1)/blocksize)+1;

	hipEvent_t start,finish;
	SAFE_CALL(hipEventCreate(&start));
	SAFE_CALL(hipEventCreate(&finish));
	
	SAFE_CALL(hipDeviceSynchronize());

	SAFE_CALL(hipEventRecord(start));
	SAFE_KERNEL_CALL((ram<<<gridsize,blocksize>>>(d_ptrs,d_result,d_data,large_array_size/sizeof(int))));
	SAFE_CALL(hipEventRecord(finish));

	SAFE_CALL(hipMemcpy(h_result,d_result,large_array_size,hipMemcpyDeviceToHost));
	SAFE_CALL(hipEventSynchronize(finish));
	
	float milliseconds=0;
	SAFE_CALL(hipEventElapsedTime(&milliseconds,start,finish));
	
	printf("Used time is(s):%f",milliseconds/1000);
	printf("Effective Bandwidth(GB/s):%fn",large_array_size*3/milliseconds/1e6);
	
	FILE *bandwidth=fopen("bandwidth.dat","a");
	fprintf(bandwidth,"%d %fn",n,large_array_size*3/milliseconds/1e6);

	SAFE_CALL(hipFree(d_ptrs));
	SAFE_CALL(hipFree(d_result));
	SAFE_CALL(hipFree(d_data));

	free(h_ptrs);
	free(h_result);
	free(h_data);

	return 0;
}

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

                                        # End of file scope inline assembly
	.globl	_Z18__device_stub__ramPiS_S_i   # -- Begin function _Z18__device_stub__ramPiS_S_i
	.type	_Z18__device_stub__ramPiS_S_i,@function
_Z18__device_stub__ramPiS_S_i:          # @_Z18__device_stub__ramPiS_S_i
	.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
	subq	$112, %rsp
	.cfi_def_cfa_offset 160
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	32(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	24(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	4(%rsp), %rdx
	movl	%ecx, (%rdx)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	16(%rsp), %r12
	leaq	8(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z3ramPiS_S_i, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$128, %rsp
	.cfi_adjust_cfa_offset -128
	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
	retq
.Lfunc_end0:
	.size	_Z18__device_stub__ramPiS_S_i, .Lfunc_end0-_Z18__device_stub__ramPiS_S_i
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function main
.LCPI1_0:
	.long	0x447a0000                      # float 1000
.LCPI1_1:
	.long	0x4f400000                      # float 3.22122547E+9
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0
.LCPI1_2:
	.quad	0x412e848000000000              # double 1.0E+6
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
	.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
	movl	$1073741824, %edi               # imm = 0x40000000
	callq	malloc
	movq	%rax, %rbx
	movl	$1073741824, %edi               # imm = 0x40000000
	callq	malloc
	movq	%rax, %r14
	movl	$1048576, %edi                  # imm = 0x100000
	callq	malloc
	movq	%rax, %r15
	xorl	%eax, %eax
.LBB1_1:                                # =>This Inner Loop Header: Depth=1
	movl	%eax, (%r15,%rax,4)
	incq	%rax
	cmpq	$262144, %rax                   # imm = 0x40000
	jne	.LBB1_1
# %bb.2:                                # %.preheader.preheader
	xorl	%r12d, %r12d
.LBB1_3:                                # %.preheader
                                        # =>This Inner Loop Header: Depth=1
	movl	$0, (%r14,%r12,4)
	callq	rand
                                        # kill: def $eax killed $eax def $rax
	leal	1048575(%rax), %ecx
	testl	%eax, %eax
	cmovnsl	%eax, %ecx
	andl	$-1048576, %ecx                 # imm = 0xFFF00000
	subl	%ecx, %eax
	movl	%eax, (%rbx,%r12,4)
	incq	%r12
	cmpq	$268435456, %r12                # imm = 0x10000000
	jne	.LBB1_3
# %bb.4:
	leaq	40(%rsp), %rdi
	movl	$1073741824, %esi               # imm = 0x40000000
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB1_5
# %bb.8:
	leaq	16(%rsp), %rdi
	movl	$1073741824, %esi               # imm = 0x40000000
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB1_9
# %bb.10:
	leaq	32(%rsp), %rdi
	movl	$1048576, %esi                  # imm = 0x100000
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB1_11
# %bb.12:
	movq	40(%rsp), %rdi
	movl	$1073741824, %edx               # imm = 0x40000000
	movq	%rbx, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB1_13
# %bb.14:
	movq	16(%rsp), %rdi
	movl	$1073741824, %edx               # imm = 0x40000000
	movq	%r14, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB1_15
# %bb.16:
	movq	32(%rsp), %rdi
	movl	$1048576, %edx                  # imm = 0x100000
	movq	%r15, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB1_17
# %bb.18:
	leaq	48(%rsp), %rdi
	callq	hipEventCreate
	testl	%eax, %eax
	jne	.LBB1_19
# %bb.20:
	leaq	24(%rsp), %rdi
	callq	hipEventCreate
	testl	%eax, %eax
	jne	.LBB1_21
# %bb.22:
	callq	hipDeviceSynchronize
	testl	%eax, %eax
	jne	.LBB1_23
# %bb.24:
	movq	48(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	testl	%eax, %eax
	jne	.LBB1_25
# %bb.26:
	movabsq	$4294968320, %rdx               # imm = 0x100000400
	leaq	261120(%rdx), %rdi
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB1_28
# %bb.27:
	movq	40(%rsp), %rdi
	movq	16(%rsp), %rsi
	movq	32(%rsp), %rdx
	movl	$268435456, %ecx                # imm = 0x10000000
	callq	_Z18__device_stub__ramPiS_S_i
.LBB1_28:
	callq	hipGetLastError
	testl	%eax, %eax
	jne	.LBB1_29
# %bb.30:
	callq	hipDeviceSynchronize
	testl	%eax, %eax
	jne	.LBB1_31
# %bb.32:
	movq	24(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	testl	%eax, %eax
	jne	.LBB1_33
# %bb.34:
	movq	16(%rsp), %rsi
	movl	$1073741824, %edx               # imm = 0x40000000
	movq	%r14, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB1_35
# %bb.36:
	movq	24(%rsp), %rdi
	callq	hipEventSynchronize
	testl	%eax, %eax
	jne	.LBB1_37
# %bb.38:
	leaq	12(%rsp), %rdi
	movl	$0, (%rdi)
	movq	48(%rsp), %rsi
	movq	24(%rsp), %rdx
	callq	hipEventElapsedTime
	testl	%eax, %eax
	jne	.LBB1_39
# %bb.40:
	movss	12(%rsp), %xmm0                 # xmm0 = mem[0],zero,zero,zero
	divss	.LCPI1_0(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	movl	$.L.str.19, %edi
	movb	$1, %al
	callq	printf
	movss	.LCPI1_1(%rip), %xmm0           # xmm0 = mem[0],zero,zero,zero
	divss	12(%rsp), %xmm0
	cvtss2sd	%xmm0, %xmm0
	divsd	.LCPI1_2(%rip), %xmm0
	movl	$.L.str.20, %edi
	movb	$1, %al
	callq	printf
	movl	$.L.str.21, %edi
	movl	$.L.str.22, %esi
	callq	fopen
	movss	.LCPI1_1(%rip), %xmm0           # xmm0 = mem[0],zero,zero,zero
	divss	12(%rsp), %xmm0
	cvtss2sd	%xmm0, %xmm0
	divsd	.LCPI1_2(%rip), %xmm0
	movl	$.L.str.23, %esi
	movq	%rax, %rdi
	movl	$1, %edx
	movb	$1, %al
	callq	fprintf
	movq	40(%rsp), %rdi
	callq	hipFree
	testl	%eax, %eax
	jne	.LBB1_41
# %bb.42:
	movq	16(%rsp), %rdi
	callq	hipFree
	testl	%eax, %eax
	jne	.LBB1_43
# %bb.44:
	movq	32(%rsp), %rdi
	callq	hipFree
	testl	%eax, %eax
	jne	.LBB1_45
# %bb.46:
	movq	%rbx, %rdi
	callq	free
	movq	%r14, %rdi
	callq	free
	movq	%r15, %rdi
	callq	free
	xorl	%eax, %eax
	addq	$56, %rsp
	.cfi_def_cfa_offset 40
	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
.LBB1_5:
	.cfi_def_cfa_offset 96
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str, %edi
	jmp	.LBB1_6
.LBB1_9:
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.2, %edi
	jmp	.LBB1_6
.LBB1_11:
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.3, %edi
	jmp	.LBB1_6
.LBB1_13:
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.4, %edi
	jmp	.LBB1_6
.LBB1_15:
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %edi
	jmp	.LBB1_6
.LBB1_17:
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.6, %edi
	jmp	.LBB1_6
.LBB1_19:
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.7, %edi
	jmp	.LBB1_6
.LBB1_21:
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.8, %edi
	jmp	.LBB1_6
.LBB1_23:
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.9, %edi
	jmp	.LBB1_6
.LBB1_25:
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.10, %edi
	jmp	.LBB1_6
.LBB1_29:
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.11, %edi
	movq	%rax, %rsi
	xorl	%eax, %eax
	callq	printf
	movl	$8, %edi
	callq	__cxa_allocate_exception
	movq	$.L.str.12, (%rax)
	jmp	.LBB1_7
.LBB1_31:
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.13, %edi
	movq	%rax, %rsi
	xorl	%eax, %eax
	callq	printf
	movl	$8, %edi
	callq	__cxa_allocate_exception
	movq	$.L.str.14, (%rax)
	jmp	.LBB1_7
.LBB1_33:
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.15, %edi
	jmp	.LBB1_6
.LBB1_35:
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.16, %edi
	jmp	.LBB1_6
.LBB1_37:
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.17, %edi
	jmp	.LBB1_6
.LBB1_39:
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.18, %edi
	jmp	.LBB1_6
.LBB1_41:
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.24, %edi
	jmp	.LBB1_6
.LBB1_43:
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.25, %edi
	jmp	.LBB1_6
.LBB1_45:
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.26, %edi
.LBB1_6:
	movq	%rax, %rsi
	xorl	%eax, %eax
	callq	printf
	movl	$8, %edi
	callq	__cxa_allocate_exception
	movq	$.L.str.1, (%rax)
.LBB1_7:
	movl	$_ZTIPKc, %esi
	movq	%rax, %rdi
	xorl	%edx, %edx
	callq	__cxa_throw
.Lfunc_end1:
	.size	main, .Lfunc_end1-main
	.cfi_endproc
                                        # -- End function
	.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	$_Z3ramPiS_S_i, %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	_Z3ramPiS_S_i,@object           # @_Z3ramPiS_S_i
	.section	.rodata,"a",@progbits
	.globl	_Z3ramPiS_S_i
	.p2align	3, 0x0
_Z3ramPiS_S_i:
	.quad	_Z18__device_stub__ramPiS_S_i
	.size	_Z3ramPiS_S_i, 8

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"CUDA error:%s at call \"hipMalloc(&d_ptrs,large_array_size)\"\n"
	.size	.L.str, 61

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"error in CUDA API function,aborting..."
	.size	.L.str.1, 39

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"CUDA error:%s at call \"hipMalloc(&d_result,large_array_size)\"\n"
	.size	.L.str.2, 63

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"CUDA error:%s at call \"hipMalloc(&d_data,cached_array_size)\"\n"
	.size	.L.str.3, 62

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"CUDA error:%s at call \"hipMemcpy(d_ptrs,h_ptrs,large_array_size,hipMemcpyHostToDevice)\"\n"
	.size	.L.str.4, 89

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"CUDA error:%s at call \"hipMemcpy(d_result,h_result,large_array_size,hipMemcpyHostToDevice)\"\n"
	.size	.L.str.5, 93

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"CUDA error:%s at call \"hipMemcpy(d_data,h_data,cached_array_size,hipMemcpyHostToDevice)\"\n"
	.size	.L.str.6, 90

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"CUDA error:%s at call \"hipEventCreate(&start)\"\n"
	.size	.L.str.7, 48

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"CUDA error:%s at call \"hipEventCreate(&finish)\"\n"
	.size	.L.str.8, 49

	.type	.L.str.9,@object                # @.str.9
.L.str.9:
	.asciz	"CUDA error:%s at call \"hipDeviceSynchronize()\"\n"
	.size	.L.str.9, 48

	.type	.L.str.10,@object               # @.str.10
.L.str.10:
	.asciz	"CUDA error:%s at call \"hipEventRecord(start)\"\n"
	.size	.L.str.10, 47

	.type	.L.str.11,@object               # @.str.11
.L.str.11:
	.asciz	"CUDA error in kernel launch:%s at kernel \"(ram<<<gridsize,blocksize>>>(d_ptrs,d_result,d_data,large_array_size/sizeof(int)))\"\n"
	.size	.L.str.11, 127

	.type	.L.str.12,@object               # @.str.12
.L.str.12:
	.asciz	"error in CUDA kernel launch,aborting..."
	.size	.L.str.12, 40

	.type	.L.str.13,@object               # @.str.13
.L.str.13:
	.asciz	"CUDA error in kernel execution:%s at kernel\"(ram<<<gridsize,blocksize>>>(d_ptrs,d_result,d_data,large_array_size/sizeof(int)))\"\n"
	.size	.L.str.13, 129

	.type	.L.str.14,@object               # @.str.14
.L.str.14:
	.asciz	"error in CUDA kernel execution,aborting..."
	.size	.L.str.14, 43

	.type	.L.str.15,@object               # @.str.15
.L.str.15:
	.asciz	"CUDA error:%s at call \"hipEventRecord(finish)\"\n"
	.size	.L.str.15, 48

	.type	.L.str.16,@object               # @.str.16
.L.str.16:
	.asciz	"CUDA error:%s at call \"hipMemcpy(h_result,d_result,large_array_size,hipMemcpyDeviceToHost)\"\n"
	.size	.L.str.16, 93

	.type	.L.str.17,@object               # @.str.17
.L.str.17:
	.asciz	"CUDA error:%s at call \"hipEventSynchronize(finish)\"\n"
	.size	.L.str.17, 53

	.type	.L.str.18,@object               # @.str.18
.L.str.18:
	.asciz	"CUDA error:%s at call \"hipEventElapsedTime(&milliseconds,start,finish)\"\n"
	.size	.L.str.18, 73

	.type	.L.str.19,@object               # @.str.19
.L.str.19:
	.asciz	"Used time is(s):%f"
	.size	.L.str.19, 19

	.type	.L.str.20,@object               # @.str.20
.L.str.20:
	.asciz	"Effective Bandwidth(GB/s):%fn"
	.size	.L.str.20, 30

	.type	.L.str.21,@object               # @.str.21
.L.str.21:
	.asciz	"bandwidth.dat"
	.size	.L.str.21, 14

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

	.type	.L.str.23,@object               # @.str.23
.L.str.23:
	.asciz	"%d %fn"
	.size	.L.str.23, 7

	.type	.L.str.24,@object               # @.str.24
.L.str.24:
	.asciz	"CUDA error:%s at call \"hipFree(d_ptrs)\"\n"
	.size	.L.str.24, 41

	.type	.L.str.25,@object               # @.str.25
.L.str.25:
	.asciz	"CUDA error:%s at call \"hipFree(d_result)\"\n"
	.size	.L.str.25, 43

	.type	.L.str.26,@object               # @.str.26
.L.str.26:
	.asciz	"CUDA error:%s at call \"hipFree(d_data)\"\n"
	.size	.L.str.26, 41

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z3ramPiS_S_i"
	.size	.L__unnamed_1, 14

	.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 _Z18__device_stub__ramPiS_S_i
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z3ramPiS_S_i
	.addrsig_sym _ZTIPKc
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z3ramPiS_S_i           ; -- Begin function _Z3ramPiS_S_i
	.globl	_Z3ramPiS_S_i
	.p2align	8
	.type	_Z3ramPiS_S_i,@function
_Z3ramPiS_S_i:                          ; @_Z3ramPiS_S_i
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x2c
	s_load_b32 s3, s[0:1], 0x18
	s_waitcnt lgkmcnt(0)
	s_and_b32 s2, s2, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s15, s2, v[0:1]
	s_mov_b32 s2, exec_lo
	v_cmpx_gt_i32_e64 s3, v1
	s_cbranch_execz .LBB0_2
; %bb.1:
	s_load_b128 s[4:7], s[0:1], 0x0
	v_ashrrev_i32_e32 v2, 31, v1
	s_load_b64 s[0:1], s[0:1], 0x10
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[0:1], 2, v[1:2]
	s_waitcnt lgkmcnt(0)
	v_add_co_u32 v2, vcc_lo, s4, v0
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_3) | instid1(VALU_DEP_1)
	v_add_co_ci_u32_e32 v3, vcc_lo, s5, v1, vcc_lo
	global_load_b32 v2, v[2:3], off
	s_waitcnt vmcnt(0)
	v_ashrrev_i32_e32 v3, 31, v2
	v_lshlrev_b64 v[2:3], 2, v[2:3]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v2, vcc_lo, s0, v2
	v_add_co_ci_u32_e32 v3, vcc_lo, s1, v3, vcc_lo
	v_add_co_u32 v0, vcc_lo, s6, v0
	v_add_co_ci_u32_e32 v1, vcc_lo, s7, v1, vcc_lo
	global_load_b32 v2, v[2:3], off
	s_waitcnt vmcnt(0)
	global_store_b32 v[0:1], v2, off
.LBB0_2:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z3ramPiS_S_i
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 288
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.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 4
		.amdhsa_next_free_sgpr 16
		.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	_Z3ramPiS_S_i, .Lfunc_end0-_Z3ramPiS_S_i
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 196
; NumSgprs: 18
; NumVgprs: 4
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 4
; Occupancy: 16
; WaveLimiterHint : 1
; 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:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         16
        .size:           8
        .value_kind:     global_buffer
      - .offset:         24
        .size:           4
        .value_kind:     by_value
      - .offset:         32
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         36
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         40
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         44
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         46
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         48
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         50
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         52
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         54
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         88
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         96
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 288
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z3ramPiS_S_i
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z3ramPiS_S_i.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     4
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
