#include <stdio.h>
#include <stdlib.h>
#include <time.h>

#define NUM_STREAM 100
#define NUM_BLOCK 1
#define NUM_THREAD 512

#define NUM_DATA 2000000
#define TYPE_DATA double

#define CHECK 0

void stopwatch(int);
void pp(int);


//a 에서  b 로 l 만큼
__global__ void data_trans(TYPE_DATA* a,TYPE_DATA* b,int l);

int main()
{
	cudaStream_t stream_array[NUM_STREAM];

	TYPE_DATA* host_a,*host_b;
	TYPE_DATA* dev_a ,*dev_b;

	
	cudaMallocHost((void**)&host_a,sizeof(TYPE_DATA)*NUM_DATA);
	cudaMallocHost((void**)&host_b,sizeof(TYPE_DATA)*NUM_DATA);

	cudaMalloc((void**)&dev_a,sizeof(TYPE_DATA)* NUM_DATA );
	cudaMalloc((void**)&dev_b,sizeof(TYPE_DATA)* NUM_DATA );

	printf("number of stream : %d\nnumber of data : %d\nnumber of block : %d\nnumber of thread : %d\n",NUM_STREAM,NUM_DATA,NUM_BLOCK,NUM_THREAD);

	srand(time(NULL));

	for(int i=0;i<NUM_DATA;i++)
		{
			host_a[i] = rand()/(TYPE_DATA)RAND_MAX;
		}

	printf("Creating Stream[%d]   : ",NUM_STREAM);
	stopwatch(0);
	for(int i=0;i<NUM_STREAM; i++)
		cudaStreamCreate(&(stream_array[i]));
	stopwatch(1);


	int offset[NUM_STREAM];
	for(int i=0;i<NUM_STREAM;i++)
{
	offset[i] = i * NUM_DATA/NUM_STREAM;

#if CHECK
	printf("offset[%d] : %d\n",i,offset[i]);
#endif
}
	/************************Streaming**********************************/


	printf("Reading & Processing with    Stream : ");
	stopwatch(0);
	//READ
	for(int i=0;i<NUM_STREAM;i++)
	{
		cudaMemcpyAsync(dev_a+offset[i],host_a+offset[i],sizeof(TYPE_DATA)*NUM_DATA/NUM_STREAM,cudaMemcpyHostToDevice,stream_array[i]);
	}
	//TRANS
	for(int j=0;j<NUM_STREAM;j++)
	{
		data_trans<<<NUM_BLOCK,NUM_THREAD,0,stream_array[j]>>>(dev_a,dev_b,NUM_DATA/NUM_STREAM);
	}
	//GET
	for(int i=0;i<NUM_STREAM;i++)
	{
		cudaMemcpyAsync(host_b+offset[i],dev_b+offset[i],sizeof(TYPE_DATA)*NUM_DATA/NUM_STREAM,cudaMemcpyDeviceToHost,stream_array[i]);
	}
	
	for(int i=0; i<NUM_STREAM;i++)
		cudaStreamSynchronize(stream_array[i]);

	stopwatch(1);

#if CHECK
	printf("CHECK 0-10, %d-%d\n",NUM_DATA-10,NUM_DATA-1);
	for(int i=0;i<10;i++)
		printf("%.4lf ",host_b[i]);
	printf("\n");
	for(int i=NUM_DATA-10;i<NUM_DATA;i++)
		printf("%.4lf ",host_b[i]);
	printf("\n");
#endif	
	

/************************No Streaming**************************************/

	printf("Reading & Processing without Stream : ");	
	stopwatch(0);

	cudaMemcpy(dev_a,host_a,sizeof(TYPE_DATA)*NUM_DATA,cudaMemcpyHostToDevice);

	data_trans<<<NUM_BLOCK,NUM_THREAD>>>(dev_a,dev_b,NUM_DATA);

	cudaMemcpy(host_b,dev_b,sizeof(TYPE_DATA)*NUM_DATA,cudaMemcpyDeviceToHost);
	
	stopwatch(1);

#if CHECK
	printf("CHECK 0-10, %d-%d\n",NUM_DATA-10,NUM_DATA-1);
	for(int i=0;i<10;i++)
		printf("%.4lf ",host_b[i]);
	printf("\n");
	for(int i=NUM_DATA-10;i<NUM_DATA;i++)
		printf("%.4lf ",host_b[i]);
	printf("\n");
	
#endif



	printf("Destroying Stream[%d] : ",NUM_STREAM);
	stopwatch(0);
	for(int i=0;i<NUM_STREAM; i++)
		cudaStreamDestroy(stream_array[i] );
	stopwatch(1);


	cudaFree(dev_a);
	cudaFree(dev_b);
	cudaFree(host_a);
	cudaFree(host_b);

	return 0;
}

__global__ void data_trans(TYPE_DATA* a,TYPE_DATA* b,int l)
{
	for(int i=threadIdx.x;i<l;i+=NUM_THREAD)
		b[i]=a[i];

}

void pp(int num)
{
	printf("%d\n",num);
}


void stopwatch(int flag)
{
	enum clock_unit{nano = 0, micro , milli, sec} unit;
	
	const long long NANOS = 1000000000LL;
	static struct timespec startTS,endTS;
	static long long diff = 0;

	/*
		여기서 단위 조정
		nano, micro, milli, sec
	*/
	unit = micro;

	//start
	if(flag == 0)
	{
		diff = 0;
		if(-1 == clock_gettime(CLOCK_MONOTONIC,&startTS))
			printf("Failed to call clock_gettime\n");
	}
	//end
	else if(flag == 1)
	{		
		if(-1 == clock_gettime(CLOCK_MONOTONIC,&endTS))
			printf("Failed to call clock_gettime\n");
		diff = NANOS * (endTS.tv_sec - startTS.tv_sec) + (endTS.tv_nsec - startTS.tv_nsec);

		switch(unit)		
		{
			case nano :
				printf("elapsed time : % lld micros\n",diff);
			break;
			case micro :
				printf("elapsed time : % lld micros\n",diff/1000);
			break;
			case sec :
				printf("elapsed time : % lld micros\n",diff/1000000000);
			break;
			default :
				printf("elapsed time : % lld milli sec\n",diff/100000);
			break;	

		}
	}
	else
	{
		printf("wrong flag | 0 : start, 1 : end\n");
	}

}
 

	.file	"tmpxft_0037efd2_00000000-6_6_stream.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2032:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2032:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"Failed to call clock_gettime\n"
.LC1:
	.string	"elapsed time : % lld micros\n"
	.text
	.type	_Z9stopwatchi.part.0, @function
_Z9stopwatchi.part.0:
.LFB2173:
	.cfi_startproc
	pushq	%rsi
	.cfi_def_cfa_offset 16
	movl	$1, %edi
	leaq	_ZZ9stopwatchiE5endTS(%rip), %rsi
	call	clock_gettime@PLT
	incl	%eax
	jne	.L3
	leaq	.LC0(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L3:
	movq	_ZZ9stopwatchiE5endTS(%rip), %rax
	movl	$1000, %ecx
	movl	$2, %edi
	subq	_ZZ9stopwatchiE7startTS(%rip), %rax
	imulq	$1000000000, %rax, %rax
	addq	8+_ZZ9stopwatchiE5endTS(%rip), %rax
	subq	8+_ZZ9stopwatchiE7startTS(%rip), %rax
	cqto
	leaq	.LC1(%rip), %rsi
	idivq	%rcx
	popq	%rcx
	.cfi_def_cfa_offset 8
	movq	%rax, %rdx
	xorl	%eax, %eax
	jmp	__printf_chk@PLT
	.cfi_endproc
.LFE2173:
	.size	_Z9stopwatchi.part.0, .-_Z9stopwatchi.part.0
	.section	.rodata.str1.1
.LC2:
	.string	"%d\n"
	.text
	.globl	_Z2ppi
	.type	_Z2ppi, @function
_Z2ppi:
.LFB2028:
	.cfi_startproc
	endbr64
	movl	%edi, %edx
	leaq	.LC2(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	jmp	__printf_chk@PLT
	.cfi_endproc
.LFE2028:
	.size	_Z2ppi, .-_Z2ppi
	.section	.rodata.str1.1
.LC3:
	.string	"wrong flag | 0 : start, 1 : end\n"
	.text
	.globl	_Z9stopwatchi
	.type	_Z9stopwatchi, @function
_Z9stopwatchi:
.LFB2029:
	.cfi_startproc
	endbr64
	testl	%edi, %edi
	jne	.L8
	pushq	%rcx
	.cfi_def_cfa_offset 16
	leaq	_ZZ9stopwatchiE7startTS(%rip), %rsi
	movl	$1, %edi
	call	clock_gettime@PLT
	incl	%eax
	jne	.L7
	leaq	.LC0(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	popq	%rdx
	.cfi_def_cfa_offset 8
	jmp	.L14
.L8:
	decl	%edi
	jne	.L10
	jmp	_Z9stopwatchi.part.0
.L10:
	leaq	.LC3(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
.L14:
	jmp	__printf_chk@PLT
.L7:
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2029:
	.size	_Z9stopwatchi, .-_Z9stopwatchi
	.globl	_Z33__device_stub__Z10data_transPdS_iPdS_i
	.type	_Z33__device_stub__Z10data_transPdS_iPdS_i, @function
_Z33__device_stub__Z10data_transPdS_iPdS_i:
.LFB2054:
	.cfi_startproc
	endbr64
	subq	$136, %rsp
	.cfi_def_cfa_offset 144
	movq	%rdi, 24(%rsp)
	leaq	40(%rsp), %rcx
	leaq	48(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	60(%rsp), %rsi
	movl	%edx, 12(%rsp)
	leaq	32(%rsp), %rdx
	movq	%fs:40, %rax
	movq	%rax, 120(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 56(%rsp)
	movq	%rax, 96(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 104(%rsp)
	leaq	12(%rsp), %rax
	movq	%rax, 112(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 48(%rsp)
	movq	%rax, 60(%rsp)
	movl	$1, 68(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L15
	pushq	40(%rsp)
	.cfi_def_cfa_offset 152
	leaq	_Z10data_transPdS_i(%rip), %rdi
	pushq	40(%rsp)
	.cfi_def_cfa_offset 160
	movq	76(%rsp), %rcx
	movl	84(%rsp), %r8d
	movq	64(%rsp), %rsi
	movl	72(%rsp), %edx
	leaq	112(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 152
	popq	%rdx
	.cfi_def_cfa_offset 144
.L15:
	movq	120(%rsp), %rax
	subq	%fs:40, %rax
	je	.L17
	call	__stack_chk_fail@PLT
.L17:
	addq	$136, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2054:
	.size	_Z33__device_stub__Z10data_transPdS_iPdS_i, .-_Z33__device_stub__Z10data_transPdS_iPdS_i
	.globl	_Z10data_transPdS_i
	.type	_Z10data_transPdS_i, @function
_Z10data_transPdS_i:
.LFB2055:
	.cfi_startproc
	endbr64
	jmp	_Z33__device_stub__Z10data_transPdS_iPdS_i
	.cfi_endproc
.LFE2055:
	.size	_Z10data_transPdS_i, .-_Z10data_transPdS_i
	.section	.rodata.str1.1
.LC4:
	.string	"number of stream : %d\nnumber of data : %d\nnumber of block : %d\nnumber of thread : %d\n"
.LC6:
	.string	"Creating Stream[%d]   : "
.LC7:
	.string	"Reading & Processing with    Stream : "
.LC8:
	.string	"Reading & Processing without Stream : "
.LC9:
	.string	"Destroying Stream[%d] : "
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2027:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	movl	$16000000, %esi
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	xorl	%ebx, %ebx
	subq	$1272, %rsp
	.cfi_def_cfa_offset 1312
	movq	%fs:40, %rax
	movq	%rax, 1256(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rdi
	call	cudaMallocHost@PLT
	leaq	8(%rsp), %rdi
	movl	$16000000, %esi
	call	cudaMallocHost@PLT
	leaq	16(%rsp), %rdi
	movl	$16000000, %esi
	call	cudaMalloc@PLT
	leaq	24(%rsp), %rdi
	movl	$16000000, %esi
	call	cudaMalloc@PLT
	movl	$512, %r9d
	movl	$1, %r8d
	movl	$2000000, %ecx
	movl	$100, %edx
	leaq	.LC4(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	xorl	%edi, %edi
	call	time@PLT
	movl	%eax, %edi
	call	srand@PLT
.L21:
	call	rand@PLT
	cvtsi2sdl	%eax, %xmm0
	movq	(%rsp), %rax
	divsd	.LC5(%rip), %xmm0
	movsd	%xmm0, (%rax,%rbx)
	addq	$8, %rbx
	cmpq	$16000000, %rbx
	jne	.L21
	movl	$100, %edx
	leaq	.LC6(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	456(%rsp), %rbp
	xorl	%edi, %edi
	leaq	1256(%rsp), %r12
	call	_Z9stopwatchi
	movq	%rbp, %rbx
.L22:
	movq	%rbp, %rdi
	addq	$8, %rbp
	call	cudaStreamCreate@PLT
	cmpq	%r12, %rbp
	jne	.L22
	call	_Z9stopwatchi.part.0
	leaq	56(%rsp), %rdx
	xorl	%eax, %eax
	movq	%rdx, %rbp
.L23:
	movl	%eax, (%rdx)
	addl	$20000, %eax
	addq	$4, %rdx
	cmpl	$2000000, %eax
	jne	.L23
	leaq	.LC7(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	xorl	%r12d, %r12d
	call	__printf_chk@PLT
	xorl	%edi, %edi
	call	_Z9stopwatchi
.L24:
	movslq	0(%rbp,%r12,4), %rdi
	movq	(%rsp), %rsi
	movl	$1, %ecx
	movl	$160000, %edx
	movq	(%rbx,%r12,8), %r8
	incq	%r12
	salq	$3, %rdi
	addq	%rdi, %rsi
	addq	16(%rsp), %rdi
	call	cudaMemcpyAsync@PLT
	cmpq	$100, %r12
	jne	.L24
	movabsq	$4294967808, %r13
	xorl	%r12d, %r12d
.L26:
	movq	(%rbx,%r12,8), %r9
	xorl	%r8d, %r8d
	movq	%r13, %rdx
	movl	$1, %ecx
	movabsq	$4294967297, %rdi
	movl	$1, %esi
	movq	%r13, 44(%rsp)
	movl	$1, 52(%rsp)
	movq	%rdi, 32(%rsp)
	movl	$1, 40(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L25
	movq	24(%rsp), %rsi
	movq	16(%rsp), %rdi
	movl	$20000, %edx
	call	_Z33__device_stub__Z10data_transPdS_iPdS_i
.L25:
	incq	%r12
	cmpq	$100, %r12
	jne	.L26
	xorl	%r12d, %r12d
.L27:
	movslq	0(%rbp,%r12,4), %rdi
	movq	24(%rsp), %rsi
	movl	$2, %ecx
	movl	$160000, %edx
	movq	(%rbx,%r12,8), %r8
	incq	%r12
	salq	$3, %rdi
	addq	%rdi, %rsi
	addq	8(%rsp), %rdi
	call	cudaMemcpyAsync@PLT
	cmpq	$100, %r12
	jne	.L27
	xorl	%ebp, %ebp
.L28:
	movq	(%rbx,%rbp,8), %rdi
	incq	%rbp
	call	cudaStreamSynchronize@PLT
	cmpq	$100, %rbp
	jne	.L28
	call	_Z9stopwatchi.part.0
	leaq	.LC8(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	xorl	%edi, %edi
	call	_Z9stopwatchi
	movq	(%rsp), %rsi
	movq	16(%rsp), %rdi
	movl	$1, %ecx
	movl	$16000000, %edx
	call	cudaMemcpy@PLT
	movl	$8388609, %edx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	salq	$9, %rdx
	movl	$1, %ecx
	movabsq	$4294967297, %rdi
	movl	$1, %esi
	movq	%rdx, 44(%rsp)
	movl	$1, 52(%rsp)
	movq	%rdi, 32(%rsp)
	movl	$1, 40(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L29
	movq	24(%rsp), %rsi
	movq	16(%rsp), %rdi
	movl	$2000000, %edx
	call	_Z33__device_stub__Z10data_transPdS_iPdS_i
.L29:
	movq	24(%rsp), %rsi
	movq	8(%rsp), %rdi
	movl	$2, %ecx
	xorl	%ebp, %ebp
	movl	$16000000, %edx
	call	cudaMemcpy@PLT
	call	_Z9stopwatchi.part.0
	movl	$100, %edx
	leaq	.LC9(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
	xorl	%edi, %edi
	call	_Z9stopwatchi
.L30:
	movq	(%rbx,%rbp,8), %rdi
	incq	%rbp
	call	cudaStreamDestroy@PLT
	cmpq	$100, %rbp
	jne	.L30
	call	_Z9stopwatchi.part.0
	movq	16(%rsp), %rdi
	call	cudaFree@PLT
	movq	24(%rsp), %rdi
	call	cudaFree@PLT
	movq	(%rsp), %rdi
	call	cudaFree@PLT
	movq	8(%rsp), %rdi
	call	cudaFree@PLT
	movq	1256(%rsp), %rax
	subq	%fs:40, %rax
	je	.L31
	call	__stack_chk_fail@PLT
.L31:
	addq	$1272, %rsp
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2027:
	.size	main, .-main
	.section	.rodata.str1.1
.LC10:
	.string	"_Z10data_transPdS_i"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2057:
	.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	.LC10(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z10data_transPdS_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
.LFE2057:
	.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
	.local	_ZZ9stopwatchiE5endTS
	.comm	_ZZ9stopwatchiE5endTS,16,16
	.local	_ZZ9stopwatchiE7startTS
	.comm	_ZZ9stopwatchiE7startTS,16,16
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC5:
	.long	-4194304
	.long	1105199103
	.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 <stdio.h>
#include <stdlib.h>
#include <time.h>

#define NUM_STREAM 100
#define NUM_BLOCK 1
#define NUM_THREAD 512

#define NUM_DATA 2000000
#define TYPE_DATA double

#define CHECK 0

void stopwatch(int);
void pp(int);


//a 에서  b 로 l 만큼
__global__ void data_trans(TYPE_DATA* a,TYPE_DATA* b,int l);

int main()
{
	hipStream_t stream_array[NUM_STREAM];

	TYPE_DATA* host_a,*host_b;
	TYPE_DATA* dev_a ,*dev_b;

	
	hipHostMalloc((void**)&host_a,sizeof(TYPE_DATA)*NUM_DATA, hipHostMallocDefault);
	hipHostMalloc((void**)&host_b,sizeof(TYPE_DATA)*NUM_DATA, hipHostMallocDefault);

	hipMalloc((void**)&dev_a,sizeof(TYPE_DATA)* NUM_DATA );
	hipMalloc((void**)&dev_b,sizeof(TYPE_DATA)* NUM_DATA );

	printf("number of stream : %d\nnumber of data : %d\nnumber of block : %d\nnumber of thread : %d\n",NUM_STREAM,NUM_DATA,NUM_BLOCK,NUM_THREAD);

	srand(time(NULL));

	for(int i=0;i<NUM_DATA;i++)
		{
			host_a[i] = rand()/(TYPE_DATA)RAND_MAX;
		}

	printf("Creating Stream[%d]   : ",NUM_STREAM);
	stopwatch(0);
	for(int i=0;i<NUM_STREAM; i++)
		hipStreamCreate(&(stream_array[i]));
	stopwatch(1);


	int offset[NUM_STREAM];
	for(int i=0;i<NUM_STREAM;i++)
{
	offset[i] = i * NUM_DATA/NUM_STREAM;

#if CHECK
	printf("offset[%d] : %d\n",i,offset[i]);
#endif
}
	/************************Streaming**********************************/


	printf("Reading & Processing with    Stream : ");
	stopwatch(0);
	//READ
	for(int i=0;i<NUM_STREAM;i++)
	{
		hipMemcpyAsync(dev_a+offset[i],host_a+offset[i],sizeof(TYPE_DATA)*NUM_DATA/NUM_STREAM,hipMemcpyHostToDevice,stream_array[i]);
	}
	//TRANS
	for(int j=0;j<NUM_STREAM;j++)
	{
		data_trans<<<NUM_BLOCK,NUM_THREAD,0,stream_array[j]>>>(dev_a,dev_b,NUM_DATA/NUM_STREAM);
	}
	//GET
	for(int i=0;i<NUM_STREAM;i++)
	{
		hipMemcpyAsync(host_b+offset[i],dev_b+offset[i],sizeof(TYPE_DATA)*NUM_DATA/NUM_STREAM,hipMemcpyDeviceToHost,stream_array[i]);
	}
	
	for(int i=0; i<NUM_STREAM;i++)
		hipStreamSynchronize(stream_array[i]);

	stopwatch(1);

#if CHECK
	printf("CHECK 0-10, %d-%d\n",NUM_DATA-10,NUM_DATA-1);
	for(int i=0;i<10;i++)
		printf("%.4lf ",host_b[i]);
	printf("\n");
	for(int i=NUM_DATA-10;i<NUM_DATA;i++)
		printf("%.4lf ",host_b[i]);
	printf("\n");
#endif	
	

/************************No Streaming**************************************/

	printf("Reading & Processing without Stream : ");	
	stopwatch(0);

	hipMemcpy(dev_a,host_a,sizeof(TYPE_DATA)*NUM_DATA,hipMemcpyHostToDevice);

	data_trans<<<NUM_BLOCK,NUM_THREAD>>>(dev_a,dev_b,NUM_DATA);

	hipMemcpy(host_b,dev_b,sizeof(TYPE_DATA)*NUM_DATA,hipMemcpyDeviceToHost);
	
	stopwatch(1);

#if CHECK
	printf("CHECK 0-10, %d-%d\n",NUM_DATA-10,NUM_DATA-1);
	for(int i=0;i<10;i++)
		printf("%.4lf ",host_b[i]);
	printf("\n");
	for(int i=NUM_DATA-10;i<NUM_DATA;i++)
		printf("%.4lf ",host_b[i]);
	printf("\n");
	
#endif



	printf("Destroying Stream[%d] : ",NUM_STREAM);
	stopwatch(0);
	for(int i=0;i<NUM_STREAM; i++)
		hipStreamDestroy(stream_array[i] );
	stopwatch(1);


	hipFree(dev_a);
	hipFree(dev_b);
	hipFree(host_a);
	hipFree(host_b);

	return 0;
}

__global__ void data_trans(TYPE_DATA* a,TYPE_DATA* b,int l)
{
	for(int i=threadIdx.x;i<l;i+=NUM_THREAD)
		b[i]=a[i];

}

void pp(int num)
{
	printf("%d\n",num);
}


void stopwatch(int flag)
{
	enum clock_unit{nano = 0, micro , milli, sec} unit;
	
	const long long NANOS = 1000000000LL;
	static struct timespec startTS,endTS;
	static long long diff = 0;

	/*
		여기서 단위 조정
		nano, micro, milli, sec
	*/
	unit = micro;

	//start
	if(flag == 0)
	{
		diff = 0;
		if(-1 == clock_gettime(CLOCK_MONOTONIC,&startTS))
			printf("Failed to call clock_gettime\n");
	}
	//end
	else if(flag == 1)
	{		
		if(-1 == clock_gettime(CLOCK_MONOTONIC,&endTS))
			printf("Failed to call clock_gettime\n");
		diff = NANOS * (endTS.tv_sec - startTS.tv_sec) + (endTS.tv_nsec - startTS.tv_nsec);

		switch(unit)		
		{
			case nano :
				printf("elapsed time : % lld micros\n",diff);
			break;
			case micro :
				printf("elapsed time : % lld micros\n",diff/1000);
			break;
			case sec :
				printf("elapsed time : % lld micros\n",diff/1000000000);
			break;
			default :
				printf("elapsed time : % lld milli sec\n",diff/100000);
			break;	

		}
	}
	else
	{
		printf("wrong flag | 0 : start, 1 : end\n");
	}

}
 

	.text
	.file	"6_stream.hip"
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI0_0:
	.quad	0x41dfffffffc00000              # double 2147483647
	.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	%rbx
	.cfi_def_cfa_offset 32
	subq	$1232, %rsp                     # imm = 0x4D0
	.cfi_def_cfa_offset 1264
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	16(%rsp), %rdi
	xorl	%ebx, %ebx
	movl	$16000000, %esi                 # imm = 0xF42400
	xorl	%edx, %edx
	callq	hipHostMalloc
	leaq	24(%rsp), %rdi
	movl	$16000000, %esi                 # imm = 0xF42400
	xorl	%edx, %edx
	callq	hipHostMalloc
	leaq	8(%rsp), %rdi
	movl	$16000000, %esi                 # imm = 0xF42400
	callq	hipMalloc
	movq	%rsp, %rdi
	movl	$16000000, %esi                 # imm = 0xF42400
	callq	hipMalloc
	movl	$.L.str, %edi
	movl	$100, %esi
	movl	$2000000, %edx                  # imm = 0x1E8480
	movl	$1, %ecx
	movl	$512, %r8d                      # imm = 0x200
	xorl	%eax, %eax
	callq	printf
	xorl	%edi, %edi
	callq	time
	movl	%eax, %edi
	callq	srand
.LBB0_1:                                # =>This Inner Loop Header: Depth=1
	callq	rand
	xorps	%xmm0, %xmm0
	cvtsi2sd	%eax, %xmm0
	divsd	.LCPI0_0(%rip), %xmm0
	movq	16(%rsp), %rax
	movsd	%xmm0, (%rax,%rbx,8)
	incq	%rbx
	cmpq	$2000000, %rbx                  # imm = 0x1E8480
	jne	.LBB0_1
# %bb.2:
	xorl	%ebx, %ebx
	movl	$.L.str.1, %edi
	movl	$100, %esi
	xorl	%eax, %eax
	callq	printf
	xorl	%edi, %edi
	callq	_Z9stopwatchi
.LBB0_3:                                # =>This Inner Loop Header: Depth=1
	leaq	(%rsp,%rbx), %rdi
	addq	$432, %rdi                      # imm = 0x1B0
	callq	hipStreamCreate
	addq	$8, %rbx
	cmpq	$800, %rbx                      # imm = 0x320
	jne	.LBB0_3
# %bb.4:
	movl	$1, %edi
	callq	_Z9stopwatchi
	leaq	32(%rsp), %rax
	xorl	%ecx, %ecx
.LBB0_5:                                # =>This Inner Loop Header: Depth=1
	movl	%ecx, (%rax)
	addq	$20000, %rcx                    # imm = 0x4E20
	addq	$4, %rax
	cmpq	$2000000, %rcx                  # imm = 0x1E8480
	jne	.LBB0_5
# %bb.6:
	xorl	%ebx, %ebx
	movl	$.L.str.2, %edi
	xorl	%eax, %eax
	callq	printf
	xorl	%edi, %edi
	callq	_Z9stopwatchi
.LBB0_7:                                # =>This Inner Loop Header: Depth=1
	movslq	32(%rsp,%rbx,4), %rsi
	shlq	$3, %rsi
	movq	8(%rsp), %rdi
	addq	%rsi, %rdi
	addq	16(%rsp), %rsi
	movq	432(%rsp,%rbx,8), %r8
	movl	$160000, %edx                   # imm = 0x27100
	movl	$1, %ecx
	callq	hipMemcpyAsync
	incq	%rbx
	cmpq	$100, %rbx
	jne	.LBB0_7
# %bb.8:                                # %.preheader53.preheader
	movabsq	$4294967297, %rbx               # imm = 0x100000001
	xorl	%r15d, %r15d
	leaq	511(%rbx), %r14
.LBB0_9:                                # %.preheader53
                                        # =>This Inner Loop Header: Depth=1
	movq	432(%rsp,%r15,8), %r9
	movq	%rbx, %rdi
	movl	$1, %esi
	movq	%r14, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB0_11
# %bb.10:                               #   in Loop: Header=BB0_9 Depth=1
	movq	8(%rsp), %rdi
	movq	(%rsp), %rsi
	movl	$20000, %edx                    # imm = 0x4E20
	callq	_Z25__device_stub__data_transPdS_i
.LBB0_11:                               #   in Loop: Header=BB0_9 Depth=1
	incq	%r15
	cmpq	$100, %r15
	jne	.LBB0_9
# %bb.12:                               # %.preheader52.preheader
	xorl	%r15d, %r15d
.LBB0_13:                               # %.preheader52
                                        # =>This Inner Loop Header: Depth=1
	movslq	32(%rsp,%r15,4), %rsi
	shlq	$3, %rsi
	movq	24(%rsp), %rdi
	addq	%rsi, %rdi
	addq	(%rsp), %rsi
	movq	432(%rsp,%r15,8), %r8
	movl	$160000, %edx                   # imm = 0x27100
	movl	$2, %ecx
	callq	hipMemcpyAsync
	incq	%r15
	cmpq	$100, %r15
	jne	.LBB0_13
# %bb.14:                               # %.preheader.preheader
	xorl	%r15d, %r15d
.LBB0_15:                               # %.preheader
                                        # =>This Inner Loop Header: Depth=1
	movq	432(%rsp,%r15,8), %rdi
	callq	hipStreamSynchronize
	incq	%r15
	cmpq	$100, %r15
	jne	.LBB0_15
# %bb.16:
	movl	$1, %edi
	callq	_Z9stopwatchi
	movl	$.L.str.3, %edi
	xorl	%eax, %eax
	callq	printf
	xorl	%edi, %edi
	callq	_Z9stopwatchi
	movq	8(%rsp), %rdi
	movq	16(%rsp), %rsi
	movl	$16000000, %edx                 # imm = 0xF42400
	movl	$1, %ecx
	callq	hipMemcpy
	movq	%rbx, %rdi
	movl	$1, %esi
	movq	%r14, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB0_18
# %bb.17:
	movq	8(%rsp), %rdi
	movq	(%rsp), %rsi
	movl	$2000000, %edx                  # imm = 0x1E8480
	callq	_Z25__device_stub__data_transPdS_i
.LBB0_18:
	movq	24(%rsp), %rdi
	movq	(%rsp), %rsi
	movl	$16000000, %edx                 # imm = 0xF42400
	movl	$2, %ecx
	callq	hipMemcpy
	movl	$1, %edi
	callq	_Z9stopwatchi
	xorl	%ebx, %ebx
	movl	$.L.str.4, %edi
	movl	$100, %esi
	xorl	%eax, %eax
	callq	printf
	xorl	%edi, %edi
	callq	_Z9stopwatchi
.LBB0_19:                               # =>This Inner Loop Header: Depth=1
	movq	432(%rsp,%rbx,8), %rdi
	callq	hipStreamDestroy
	incq	%rbx
	cmpq	$100, %rbx
	jne	.LBB0_19
# %bb.20:
	movl	$1, %edi
	callq	_Z9stopwatchi
	movq	8(%rsp), %rdi
	callq	hipFree
	movq	(%rsp), %rdi
	callq	hipFree
	movq	16(%rsp), %rdi
	callq	hipFree
	movq	24(%rsp), %rdi
	callq	hipFree
	xorl	%eax, %eax
	addq	$1232, %rsp                     # imm = 0x4D0
	.cfi_def_cfa_offset 32
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	main, .Lfunc_end0-main
	.cfi_endproc
                                        # -- End function
	.globl	_Z9stopwatchi                   # -- Begin function _Z9stopwatchi
	.type	_Z9stopwatchi,@function
_Z9stopwatchi:                          # @_Z9stopwatchi
	.cfi_startproc
# %bb.0:
	pushq	%rax
	.cfi_def_cfa_offset 16
	cmpl	$1, %edi
	je	.LBB1_4
# %bb.1:
	testl	%edi, %edi
	jne	.LBB1_7
# %bb.2:
	movl	$_ZZ9stopwatchiE7startTS, %esi
	movl	$1, %edi
	callq	clock_gettime
	cmpl	$-1, %eax
	je	.LBB1_8
# %bb.3:
	popq	%rax
	.cfi_def_cfa_offset 8
	retq
.LBB1_4:
	.cfi_def_cfa_offset 16
	movl	$_ZZ9stopwatchiE5endTS, %esi
	movl	$1, %edi
	callq	clock_gettime
	cmpl	$-1, %eax
	jne	.LBB1_6
# %bb.5:
	movl	$.Lstr.2, %edi
	callq	puts@PLT
.LBB1_6:
	movq	_ZZ9stopwatchiE5endTS(%rip), %rax
	subq	_ZZ9stopwatchiE7startTS(%rip), %rax
	imulq	$1000000000, %rax, %rcx         # imm = 0x3B9ACA00
	movq	_ZZ9stopwatchiE5endTS+8(%rip), %rax
	subq	_ZZ9stopwatchiE7startTS+8(%rip), %rax
	addq	%rcx, %rax
	movabsq	$2361183241434822607, %rcx      # imm = 0x20C49BA5E353F7CF
	imulq	%rcx
	movq	%rdx, %rsi
	shrq	$63, %rsi
	sarq	$7, %rdx
	addq	%rdx, %rsi
	movl	$.L.str.7, %edi
	xorl	%eax, %eax
	popq	%rcx
	.cfi_def_cfa_offset 8
	jmp	printf                          # TAILCALL
.LBB1_7:
	.cfi_def_cfa_offset 16
	movl	$.Lstr, %edi
	jmp	.LBB1_9
.LBB1_8:
	movl	$.Lstr.2, %edi
.LBB1_9:
	popq	%rax
	.cfi_def_cfa_offset 8
	jmp	puts@PLT                        # TAILCALL
.Lfunc_end1:
	.size	_Z9stopwatchi, .Lfunc_end1-_Z9stopwatchi
	.cfi_endproc
                                        # -- End function
	.globl	_Z25__device_stub__data_transPdS_i # -- Begin function _Z25__device_stub__data_transPdS_i
	.type	_Z25__device_stub__data_transPdS_i,@function
_Z25__device_stub__data_transPdS_i:     # @_Z25__device_stub__data_transPdS_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), %rcx
	movq	%rsi, (%rcx)
	leaq	12(%rsp), %rsi
	movl	%edx, (%rsi)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	movq	%rsi, 16(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	24(%rsp), %r12
	leaq	16(%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	$_Z10data_transPdS_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_end2:
	.size	_Z25__device_stub__data_transPdS_i, .Lfunc_end2-_Z25__device_stub__data_transPdS_i
	.cfi_endproc
                                        # -- End function
	.globl	_Z2ppi                          # -- Begin function _Z2ppi
	.type	_Z2ppi,@function
_Z2ppi:                                 # @_Z2ppi
	.cfi_startproc
# %bb.0:
	movl	%edi, %esi
	movl	$.L.str.5, %edi
	xorl	%eax, %eax
	jmp	printf                          # TAILCALL
.Lfunc_end3:
	.size	_Z2ppi, .Lfunc_end3-_Z2ppi
	.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	.LBB4_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB4_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z10data_transPdS_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_end4:
	.size	__hip_module_ctor, .Lfunc_end4-__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	.LBB5_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
.LBB5_2:
	retq
.Lfunc_end5:
	.size	__hip_module_dtor, .Lfunc_end5-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"number of stream : %d\nnumber of data : %d\nnumber of block : %d\nnumber of thread : %d\n"
	.size	.L.str, 86

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"Creating Stream[%d]   : "
	.size	.L.str.1, 25

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"Reading & Processing with    Stream : "
	.size	.L.str.2, 39

	.type	_Z10data_transPdS_i,@object     # @_Z10data_transPdS_i
	.section	.rodata,"a",@progbits
	.globl	_Z10data_transPdS_i
	.p2align	3, 0x0
_Z10data_transPdS_i:
	.quad	_Z25__device_stub__data_transPdS_i
	.size	_Z10data_transPdS_i, 8

	.type	.L.str.3,@object                # @.str.3
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.3:
	.asciz	"Reading & Processing without Stream : "
	.size	.L.str.3, 39

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"Destroying Stream[%d] : "
	.size	.L.str.4, 25

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"%d\n"
	.size	.L.str.5, 4

	.type	_ZZ9stopwatchiE7startTS,@object # @_ZZ9stopwatchiE7startTS
	.local	_ZZ9stopwatchiE7startTS
	.comm	_ZZ9stopwatchiE7startTS,16,8
	.type	_ZZ9stopwatchiE5endTS,@object   # @_ZZ9stopwatchiE5endTS
	.local	_ZZ9stopwatchiE5endTS
	.comm	_ZZ9stopwatchiE5endTS,16,8
	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"elapsed time : % lld micros\n"
	.size	.L.str.7, 29

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z10data_transPdS_i"
	.size	.L__unnamed_1, 20

	.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

	.type	.Lstr,@object                   # @str
	.section	.rodata.str1.1,"aMS",@progbits,1
.Lstr:
	.asciz	"wrong flag | 0 : start, 1 : end"
	.size	.Lstr, 32

	.type	.Lstr.2,@object                 # @str.2
.Lstr.2:
	.asciz	"Failed to call clock_gettime"
	.size	.Lstr.2, 29

	.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 _Z25__device_stub__data_transPdS_i
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z10data_transPdS_i
	.addrsig_sym _ZZ9stopwatchiE7startTS
	.addrsig_sym _ZZ9stopwatchiE5endTS
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z10data_transPdS_i     ; -- Begin function _Z10data_transPdS_i
	.globl	_Z10data_transPdS_i
	.p2align	8
	.type	_Z10data_transPdS_i,@function
_Z10data_transPdS_i:                    ; @_Z10data_transPdS_i
; %bb.0:
	s_load_b32 s2, s[0:1], 0x10
	s_mov_b32 s3, exec_lo
	s_waitcnt lgkmcnt(0)
	v_cmpx_gt_i32_e64 s2, v0
	s_cbranch_execz .LBB0_3
; %bb.1:                                ; %.lr.ph.preheader
	s_load_b128 s[4:7], s[0:1], 0x0
	v_lshlrev_b32_e32 v3, 3, v0
	s_mov_b32 s1, 0
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_co_u32 v1, s0, s4, v3
	v_add_co_ci_u32_e64 v2, null, s5, 0, s0
	v_add_co_u32 v3, s0, s6, v3
	s_delay_alu instid0(VALU_DEP_1)
	v_add_co_ci_u32_e64 v4, null, s7, 0, s0
.LBB0_2:                                ; %.lr.ph
                                        ; =>This Inner Loop Header: Depth=1
	global_load_b64 v[5:6], v[1:2], off
	v_add_nc_u32_e32 v0, 0x200, v0
	v_add_co_u32 v1, vcc_lo, 0x1000, v1
	v_add_co_ci_u32_e32 v2, vcc_lo, 0, v2, vcc_lo
	s_delay_alu instid0(VALU_DEP_3) | instskip(SKIP_4) | instid1(VALU_DEP_1)
	v_cmp_le_i32_e32 vcc_lo, s2, v0
	s_or_b32 s1, vcc_lo, s1
	s_waitcnt vmcnt(0)
	global_store_b64 v[3:4], v[5:6], off
	v_add_co_u32 v3, s0, 0x1000, v3
	v_add_co_ci_u32_e64 v4, s0, 0, v4, s0
	s_and_not1_b32 exec_lo, exec_lo, s1
	s_cbranch_execnz .LBB0_2
.LBB0_3:                                ; %Flow20
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z10data_transPdS_i
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 20
		.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 7
		.amdhsa_next_free_sgpr 8
		.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	_Z10data_transPdS_i, .Lfunc_end0-_Z10data_transPdS_i
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 184
; NumSgprs: 10
; NumVgprs: 7
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 1
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 10
; NumVGPRsForWavesPerEU: 7
; 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:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .offset:         16
        .size:           4
        .value_kind:     by_value
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 20
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z10data_transPdS_i
    .private_segment_fixed_size: 0
    .sgpr_count:     10
    .sgpr_spill_count: 0
    .symbol:         _Z10data_transPdS_i.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     7
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
