
#include <stdio.h>
#include <time.h>
#include <unistd.h>
#include <stdlib.h>
#include <math.h>
#include <curand.h>
#include <time.h> 
#include <vector>
using namespace std;
#define CUDA_CALL(x) do { if((x)!=cudaSuccess) { \
    printf("Error at %s:%d : err => %s\n",__FILE__,__LINE__,cudaGetErrorString(x));\
    return EXIT_FAILURE;}} while(0)
#define CURAND_CALL(x) do { if((x)!=CURAND_STATUS_SUCCESS) { \
    printf("Error at %s:%d\n",__FILE__,__LINE__);\
    return EXIT_FAILURE;}} while(0)
/**
1- Gerar uma matriz aleatoria
2- Aplicar um blur ou filtro (gerar uma nova matriz de saida, com a media aritimetica da vizinhanca aplicada a cada elemento da matriz)
3- Testar e mandar resultados de tempo para os segintes casos:
- memoria unificada
- copia manual de memoria
- usando stream para copia CPU->GPU
- usando streams para os dois sentidos de copias (ida e volta)
4- Testar para matrizes de 100x100 , 1000x1000, 10000x10000
**/
__global__ void blur(unsigned int origData[],unsigned result[],int L,int ox,int oy) {


    int thread_idx = ox + (threadIdx.x + blockIdx.x * blockDim.x);
    int thread_idy = oy + (threadIdx.y + blockIdx.y * blockDim.y);
    
 
    
    if(thread_idx-1 >= 0 && thread_idx+1 < L && thread_idy-1 >= 0 && thread_idy+1 < L)
    {
        int temp = origData[(thread_idx) + (thread_idy)*L];
        temp += origData[(thread_idx-1) + (thread_idy-1)*L];
        temp += origData[(thread_idx) + (thread_idy-1)*L];
        temp += origData[(thread_idx+1) + (thread_idy-1)*L];

        temp += origData[(thread_idx-1) + (thread_idy)*L];
        //temp += origData[(thread_idx) + (thread_idy)*L];
        temp += origData[(thread_idx+1) + (thread_idy)*L];

        temp += origData[(thread_idx-1) + (thread_idy+1)*L];
        temp += origData[(thread_idx) + (thread_idy+1)*L];
        temp += origData[(thread_idx+1) + (thread_idy+1)*L];
        result[(thread_idx) + (thread_idy)*L] = temp/9;
    }else
    {
        result[(thread_idx) + (thread_idy)*L] = origData[(thread_idx) + (thread_idy)*L];
    }
        
}
/*
*argumentos
*1 - n_elementos
*2 - threads por bloco
*/
int main(int argc, char* argv[]) {
    unsigned int L, tam, *h_data,*d_data,*d_res;
    size_t size;
    cudaError_t err = cudaSuccess;
    L = 40;
    if(argc > 1)
      L = atoi(argv[1]);

    tam = L*L;
    size = tam*sizeof(unsigned int);

    dim3 block_dim(L,L,1);
    dim3 grid_dim(1,1,1);
    if(L>32)
    {
        block_dim = dim3(32,32,1);
        grid_dim = dim3(ceil(L/32),ceil(L/32),1);
    }
    

    // Allocate memory for the vectors on host memory.
    h_data = (unsigned int*) malloc(size);
      
    /* Allocate vectors in device memory */
    CUDA_CALL(cudaMalloc(&d_data, size));
    CUDA_CALL(cudaMalloc(&d_res, size));

    

    cudaEvent_t start, stop;
    CUDA_CALL(cudaEventCreate (&start));
    CUDA_CALL(cudaEventCreate (&stop));
    CUDA_CALL(cudaEventRecord (start, 0)); // 0 is the stream number
    // do Work…
    srand(time(NULL));
    for(int i=0; i<tam;i++)
        h_data[i]=rand();



    //CUDA_CALL(cudaMemcpy(d_data,h_data, size, cudaMemcpyHostToDevice));

    int rStreams = 4;
    dim3 block_dim_temp = dim3(32,32,1);
    dim3 grid_dim_temp = dim3(ceil(L/32),ceil((L/rStreams)/32),1);
    if(grid_dim_temp.y<1)
        grid_dim_temp = dim3(grid_dim_temp.x,1,1);
    //printf("\n grid_dim_temp - %d , %d, %d \n",grid_dim_temp.x,grid_dim_temp.y,grid_dim_temp.z);
    vector<cudaStream_t> streams;
    /* Kernel Call */
    for(int oy=0; oy < L; oy+=L/rStreams)
    {
        streams.push_back(cudaStream_t());
        cudaStreamCreate(&streams.back());
        cudaMemcpyAsync (d_data+(oy*L), h_data+(oy*L),(L/rStreams*L)*sizeof(unsigned int), cudaMemcpyHostToDevice,streams.back());
    }
    for(int oy=0,i=0; oy < L; oy+=L/rStreams,i++)
        if(i==0)
            blur<<<grid_dim_temp,block_dim_temp,0,streams[i]>>>(d_data, d_res, L, 0, oy);
        else
            blur<<<grid_dim_temp,block_dim_temp,0,streams[i]>>>(d_data, d_res, L+1, 0, oy-1);
            
    for(int oy=0,i=0; oy < L; oy+=L/rStreams,i++)
    {
        cudaMemcpyAsync (h_data+(oy*L),d_data+(oy*L),(L/rStreams*L)*sizeof(unsigned int), cudaMemcpyDeviceToHost,streams[i]);
    }
    err = cudaGetLastError();
    if (err != cudaSuccess)
    {
        fprintf(stderr, "Failed to launch vectorAdd kernel (error code %s)!\n", cudaGetErrorString(err));
        exit(EXIT_FAILURE);
    }


    

    CUDA_CALL(cudaDeviceSynchronize());

    for(int i=0; i<tam;i++)
        h_data[i]=0;
    
    CUDA_CALL(cudaEventRecord (stop, 0));
    
    CUDA_CALL(cudaEventSynchronize (stop));

   

    float elapsedTime;
    CUDA_CALL(cudaEventElapsedTime (&elapsedTime, start, stop));
    printf ("[%d,%.5f],\n", tam,elapsedTime);
    CUDA_CALL(cudaEventDestroy(start));
    CUDA_CALL(cudaEventDestroy(stop));
    
    /* Free device memory */
    CUDA_CALL( cudaFree(d_data));
    CUDA_CALL( cudaFree(d_res));
    /* Free host memory */
    free(h_data);

    return 0;
} /* main */


	.file	"tmpxft_00364d06_00000000-6_allStream.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2923:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2923:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z28__device_stub__Z4blurPjS_iiiPjS_iii
	.type	_Z28__device_stub__Z4blurPjS_iiiPjS_iii, @function
_Z28__device_stub__Z4blurPjS_iiiPjS_iii:
.LFB2945:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movq	%rdi, 24(%rsp)
	leaq	48(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	60(%rsp), %rsi
	movl	%edx, 12(%rsp)
	leaq	32(%rsp), %rdx
	movl	%ecx, 8(%rsp)
	leaq	40(%rsp), %rcx
	movl	%r8d, 4(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 136(%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)
	leaq	8(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	4(%rsp), %rax
	movq	%rax, 128(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 48(%rsp)
	movq	%rax, 60(%rsp)
	movl	$1, 68(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L2
	pushq	40(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z4blurPjS_iii(%rip), %rdi
	pushq	40(%rsp)
	.cfi_def_cfa_offset 176
	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 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
.LFE2945:
	.size	_Z28__device_stub__Z4blurPjS_iiiPjS_iii, .-_Z28__device_stub__Z4blurPjS_iiiPjS_iii
	.globl	_Z4blurPjS_iii
	.type	_Z4blurPjS_iii, @function
_Z4blurPjS_iii:
.LFB2946:
	.cfi_startproc
	endbr64
	jmp	_Z28__device_stub__Z4blurPjS_iiiPjS_iii
	.cfi_endproc
.LFE2946:
	.size	_Z4blurPjS_iii, .-_Z4blurPjS_iii
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"_Z4blurPjS_iii"
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2948:
	.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	.LC0(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z4blurPjS_iii(%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
.LFE2948:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.text._ZNSt6vectorIP11CUstream_stSaIS1_EED2Ev,"axG",@progbits,_ZNSt6vectorIP11CUstream_stSaIS1_EED5Ev,comdat
	.align 2
	.weak	_ZNSt6vectorIP11CUstream_stSaIS1_EED2Ev
	.type	_ZNSt6vectorIP11CUstream_stSaIS1_EED2Ev, @function
_ZNSt6vectorIP11CUstream_stSaIS1_EED2Ev:
.LFB3008:
	.cfi_startproc
	endbr64
	movq	(%rdi), %rax
	testq	%rax, %rax
	je	.L10
	movq	16(%rdi), %rsi
	movq	%rax, %rdi
	subq	%rax, %rsi
	jmp	_ZdlPvm@PLT
.L10:
	ret
	.cfi_endproc
.LFE3008:
	.size	_ZNSt6vectorIP11CUstream_stSaIS1_EED2Ev, .-_ZNSt6vectorIP11CUstream_stSaIS1_EED2Ev
	.weak	_ZNSt6vectorIP11CUstream_stSaIS1_EED1Ev
	.set	_ZNSt6vectorIP11CUstream_stSaIS1_EED1Ev,_ZNSt6vectorIP11CUstream_stSaIS1_EED2Ev
	.section	.rodata._ZNSt6vectorIP11CUstream_stSaIS1_EE17_M_realloc_insertIJS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_.str1.1,"aMS",@progbits,1
.LC1:
	.string	"vector::_M_realloc_insert"
	.section	.text._ZNSt6vectorIP11CUstream_stSaIS1_EE17_M_realloc_insertIJS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_,"axG",@progbits,_ZNSt6vectorIP11CUstream_stSaIS1_EE17_M_realloc_insertIJS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_,comdat
	.align 2
	.weak	_ZNSt6vectorIP11CUstream_stSaIS1_EE17_M_realloc_insertIJS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_
	.type	_ZNSt6vectorIP11CUstream_stSaIS1_EE17_M_realloc_insertIJS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_, @function
_ZNSt6vectorIP11CUstream_stSaIS1_EE17_M_realloc_insertIJS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_:
.LFB3098:
	.cfi_startproc
	endbr64
	movabsq	$1152921504606846975, %rcx
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	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
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	movq	8(%rdi), %rax
	movq	(%rdi), %r14
	movq	%rax, %rbx
	movq	%rax, (%rsp)
	subq	%r14, %rbx
	sarq	$3, %rbx
	cmpq	%rcx, %rbx
	jne	.L13
	leaq	.LC1(%rip), %rdi
	call	_ZSt20__throw_length_errorPKc@PLT
.L13:
	cmpq	%r14, (%rsp)
	movl	$1, %eax
	movq	%rsi, %r15
	movq	%rdi, %r13
	cmovne	%rbx, %rax
	movq	%rsi, %rbp
	addq	%rax, %rbx
	setc	%al
	subq	%r14, %r15
	movzbl	%al, %eax
	testq	%rax, %rax
	jne	.L23
	xorl	%r12d, %r12d
	testq	%rbx, %rbx
	je	.L18
	movabsq	$1152921504606846975, %rax
	cmpq	%rax, %rbx
	cmova	%rax, %rbx
	jmp	.L17
.L23:
	movq	%rcx, %rbx
.L17:
	leaq	0(,%rbx,8), %rdi
	movq	%rdx, 8(%rsp)
	call	_Znwm@PLT
	movq	8(%rsp), %rdx
	movq	%rax, %r12
.L18:
	movq	(%rdx), %rax
	movq	%rax, (%r12,%r15)
	testq	%r15, %r15
	jle	.L19
	movq	%r15, %rdx
	movq	%r14, %rsi
	movq	%r12, %rdi
	call	memmove@PLT
.L19:
	movq	(%rsp), %rax
	leaq	8(%r12,%r15), %rdx
	subq	%rbp, %rax
	testq	%rax, %rax
	jle	.L20
	movq	%rdx, %rdi
	movq	%rbp, %rsi
	movq	%rax, %rcx
	rep movsb
.L20:
	leaq	(%rdx,%rax), %rbp
	testq	%r14, %r14
	je	.L21
	movq	16(%r13), %rsi
	movq	%r14, %rdi
	subq	%r14, %rsi
	call	_ZdlPvm@PLT
.L21:
	leaq	(%r12,%rbx,8), %rax
	movq	%r12, 0(%r13)
	movq	%rbp, 8(%r13)
	movq	%rax, 16(%r13)
	addq	$24, %rsp
	.cfi_def_cfa_offset 56
	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
.LFE3098:
	.size	_ZNSt6vectorIP11CUstream_stSaIS1_EE17_M_realloc_insertIJS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_, .-_ZNSt6vectorIP11CUstream_stSaIS1_EE17_M_realloc_insertIJS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_
	.section	.rodata.str1.1
.LC2:
	.string	"/home/ubuntu/Datasets/stackv2/train-structured/sabiomito/uffgpu2019/master/matrix_blur/allStream.cu"
.LC3:
	.string	"Error at %s:%d : err => %s\n"
.LC4:
	.string	"Failed to launch vectorAdd kernel (error code %s)!\n"
.LC5:
	.string	"[%d,%.5f],\n"
	.section	.text.startup
	.globl	main
	.type	main, @function
main:
.LFB2909:
	.cfi_startproc
	.cfi_personality 0x9b,DW.ref.__gxx_personality_v0
	.cfi_lsda 0x1b,.LLSDA2909
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	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	$40, %ebx
	subq	$152, %rsp
	.cfi_def_cfa_offset 208
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	decl	%edi
	jle	.L31
	movq	8(%rsi), %rdi
	call	atoi@PLT
	movl	%eax, %ebx
.L31:
	movl	%ebx, %eax
	leaq	48(%rsp), %r13
	imull	%ebx, %eax
	movl	%eax, %r12d
	movl	%eax, 28(%rsp)
	salq	$2, %r12
	movq	%r12, %rdi
	call	malloc@PLT
	movq	%r12, %rsi
	movq	%r13, %rdi
	movq	%rax, %rbp
.LEHB0:
	call	cudaMalloc@PLT
	testl	%eax, %eax
	je	.L32
	movq	%r12, %rsi
	movq	%r13, %rdi
	call	cudaMalloc@PLT
	movl	%eax, %edi
	call	cudaGetErrorString@PLT
	movl	$85, %ecx
	movq	%rax, %r8
	jmp	.L75
.L32:
	leaq	56(%rsp), %r13
	movq	%r12, %rsi
	movq	%r13, %rdi
	call	cudaMalloc@PLT
	testl	%eax, %eax
	je	.L34
	movq	%r12, %rsi
	movq	%r13, %rdi
	call	cudaMalloc@PLT
	movl	%eax, %edi
	call	cudaGetErrorString@PLT
	movl	$86, %ecx
	movq	%rax, %r8
.L75:
	leaq	.LC2(%rip), %rdx
	leaq	.LC3(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	$1, %ebx
	jmp	.L30
.L34:
	leaq	64(%rsp), %r13
	movq	%r13, %rdi
	call	cudaEventCreate@PLT
	testl	%eax, %eax
	je	.L36
	movq	%r13, %rdi
	call	cudaEventCreate@PLT
	movl	%eax, %edi
	call	cudaGetErrorString@PLT
	movl	$91, %ecx
	movq	%rax, %r8
	jmp	.L75
.L36:
	leaq	72(%rsp), %r13
	movq	%r13, %rdi
	call	cudaEventCreate@PLT
	testl	%eax, %eax
	je	.L37
	movq	%r13, %rdi
	call	cudaEventCreate@PLT
	movl	%eax, %edi
	call	cudaGetErrorString@PLT
	movl	$92, %ecx
	movq	%rax, %r8
	jmp	.L75
.L37:
	movq	64(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movl	%eax, 24(%rsp)
	testl	%eax, %eax
	je	.L38
	movq	64(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movl	%eax, %edi
	call	cudaGetErrorString@PLT
.LEHE0:
	movl	$93, %ecx
	movq	%rax, %r8
	jmp	.L75
.L38:
	xorl	%edi, %edi
	movq	%rbp, %r13
	addq	%rbp, %r12
	call	time@PLT
	movl	%eax, %edi
	call	srand@PLT
.L39:
	cmpq	%r12, %r13
	je	.L87
	call	rand@PLT
	addq	$4, %r13
	movl	%eax, -4(%r13)
	jmp	.L39
.L87:
	movabsq	$137438953504, %rax
	movl	$1, 96(%rsp)
	movq	%rax, 88(%rsp)
	movl	%ebx, %eax
	shrl	$5, %eax
	movl	$1, 108(%rsp)
	movl	%eax, 16(%rsp)
	cmpl	$127, %ebx
	jbe	.L41
	movl	%ebx, %eax
	shrl	$7, %eax
	movl	%eax, 12(%rsp)
	jmp	.L42
.L41:
	movl	16(%rsp), %eax
	movl	$1, 104(%rsp)
	movl	$1, 12(%rsp)
	movl	%eax, 100(%rsp)
.L42:
	movl	%ebx, %r15d
	xorl	%edi, %edi
	xorl	%r13d, %r13d
	xorl	%r12d, %r12d
	shrl	$2, %r15d
	movq	%rdi, 112(%rsp)
	movl	%r15d, %eax
	movq	%rdi, 120(%rsp)
	imull	%ebx, %eax
	movq	%rdi, 128(%rsp)
	movl	%eax, 20(%rsp)
	salq	$2, %rax
	movq	%rax, 32(%rsp)
	leaq	80(%rsp), %rax
	movq	%rax, 40(%rsp)
.L43:
	cmpl	%ebx, %r12d
	jnb	.L88
	xorl	%esi, %esi
	movq	%rsi, 80(%rsp)
	movq	120(%rsp), %rsi
	cmpq	128(%rsp), %rsi
	je	.L44
	xorl	%ecx, %ecx
	addq	$8, %rsi
	movq	%rcx, -8(%rsi)
	movq	%rsi, 120(%rsp)
	jmp	.L45
.L44:
	movq	40(%rsp), %rdx
	leaq	112(%rsp), %rdi
.LEHB1:
	call	_ZNSt6vectorIP11CUstream_stSaIS1_EE17_M_realloc_insertIJS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_
.L45:
	movq	120(%rsp), %r14
	leaq	-8(%r14), %rdi
	call	cudaStreamCreate@PLT
	movl	%r13d, %edi
	movq	-8(%r14), %r8
	movq	32(%rsp), %rdx
	movl	$1, %ecx
	salq	$2, %rdi
	leaq	0(%rbp,%rdi), %rsi
	addq	48(%rsp), %rdi
	call	cudaMemcpyAsync@PLT
	movl	20(%rsp), %eax
	addl	%r15d, %r12d
	addl	%eax, %r13d
	jmp	.L43
.L88:
	xorl	%r13d, %r13d
	xorl	%r12d, %r12d
	leal	1(%rbx), %r14d
.L47:
	cmpl	%ebx, %r12d
	jnb	.L89
	movl	16(%rsp), %edi
	testq	%r13, %r13
	movq	112(%rsp), %rax
	movq	88(%rsp), %rdx
	movl	96(%rsp), %ecx
	movl	%edi, 100(%rsp)
	movl	12(%rsp), %edi
	movl	108(%rsp), %esi
	movl	%edi, 104(%rsp)
	jne	.L48
	movq	(%rax), %r9
	movq	100(%rsp), %rdi
	xorl	%r8d, %r8d
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L49
	movl	%r12d, %r8d
	xorl	%ecx, %ecx
	movl	%ebx, %edx
	jmp	.L77
.L48:
	movq	(%rax,%r13,8), %r9
	movq	100(%rsp), %rdi
	xorl	%r8d, %r8d
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L49
	leal	-1(%r12), %r8d
	xorl	%ecx, %ecx
	movl	%r14d, %edx
.L77:
	movq	56(%rsp), %rsi
	movq	48(%rsp), %rdi
	call	_Z28__device_stub__Z4blurPjS_iiiPjS_iii
.L49:
	addl	%r15d, %r12d
	incq	%r13
	jmp	.L47
.L89:
	xorl	%r13d, %r13d
	xorl	%r12d, %r12d
.L51:
	cmpl	%ebx, %r12d
	jnb	.L90
	movl	24(%rsp), %edi
	movq	112(%rsp), %rax
	movl	$2, %ecx
	movq	48(%rsp), %rsi
	movq	32(%rsp), %rdx
	salq	$2, %rdi
	movq	(%rax,%r13), %r8
	addq	%rdi, %rsi
	addq	%rbp, %rdi
	call	cudaMemcpyAsync@PLT
	movl	20(%rsp), %ecx
	addl	%r15d, %r12d
	addl	%ecx, 24(%rsp)
	addq	$8, %r13
	jmp	.L51
.L90:
	call	cudaGetLastError@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L53
	call	cudaGetErrorString@PLT
	movq	stderr(%rip), %rdi
	movq	%rax, %rcx
	movl	$2, %esi
	xorl	%eax, %eax
	leaq	.LC4(%rip), %rdx
	call	__fprintf_chk@PLT
	movl	$1, %edi
	call	exit@PLT
.L53:
	call	cudaDeviceSynchronize@PLT
	movl	%eax, %edx
	xorl	%eax, %eax
	testl	%edx, %edx
	je	.L54
	call	cudaDeviceSynchronize@PLT
	movl	%eax, %edi
	call	cudaGetErrorString@PLT
	movq	%rax, %r8
	movl	$137, %ecx
.L79:
	leaq	.LC2(%rip), %rdx
	leaq	.LC3(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	$1, %ebx
	jmp	.L55
.L54:
	movl	28(%rsp), %ebx
	cmpl	%ebx, %eax
	jnb	.L91
	xorl	%edx, %edx
	movl	%edx, 0(%rbp,%rax,4)
	incq	%rax
	jmp	.L54
.L91:
	movq	72(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	72(%rsp), %rdi
	testl	%eax, %eax
	je	.L57
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movl	%eax, %edi
	call	cudaGetErrorString@PLT
	movq	%rax, %r8
	movl	$142, %ecx
	jmp	.L79
.L57:
	call	cudaEventSynchronize@PLT
	movq	72(%rsp), %rdx
	testl	%eax, %eax
	je	.L59
	movq	%rdx, %rdi
	call	cudaEventSynchronize@PLT
	movl	%eax, %edi
	call	cudaGetErrorString@PLT
	movq	%rax, %r8
	movl	$144, %ecx
	jmp	.L79
.L59:
	leaq	80(%rsp), %rbx
	movq	64(%rsp), %rsi
	movq	%rbx, %rdi
	call	cudaEventElapsedTime@PLT
	testl	%eax, %eax
	je	.L60
	movq	72(%rsp), %rdx
	movq	64(%rsp), %rsi
	movq	%rbx, %rdi
	call	cudaEventElapsedTime@PLT
	movl	%eax, %edi
	call	cudaGetErrorString@PLT
	movq	%rax, %r8
	movl	$149, %ecx
	jmp	.L79
.L60:
	movl	28(%rsp), %edx
	leaq	.LC5(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	cvtss2sd	80(%rsp), %xmm0
	call	__printf_chk@PLT
	movq	64(%rsp), %rdi
	call	cudaEventDestroy@PLT
	testl	%eax, %eax
	je	.L61
	movq	64(%rsp), %rdi
	call	cudaEventDestroy@PLT
	movl	%eax, %edi
	call	cudaGetErrorString@PLT
	movq	%rax, %r8
	movl	$151, %ecx
	jmp	.L79
.L61:
	movq	72(%rsp), %rdi
	call	cudaEventDestroy@PLT
	testl	%eax, %eax
	je	.L62
	movq	72(%rsp), %rdi
	call	cudaEventDestroy@PLT
	movl	%eax, %edi
	call	cudaGetErrorString@PLT
	movq	%rax, %r8
	movl	$152, %ecx
	jmp	.L79
.L62:
	movq	48(%rsp), %rdi
	call	cudaFree@PLT
	testl	%eax, %eax
	je	.L63
	movq	48(%rsp), %rdi
	call	cudaFree@PLT
	movl	%eax, %edi
	call	cudaGetErrorString@PLT
	movq	%rax, %r8
	movl	$155, %ecx
	jmp	.L79
.L63:
	movq	56(%rsp), %rdi
	call	cudaFree@PLT
	testl	%eax, %eax
	je	.L64
	movq	56(%rsp), %rdi
	call	cudaFree@PLT
	movl	%eax, %edi
	call	cudaGetErrorString@PLT
.LEHE1:
	movq	%rax, %r8
	movl	$156, %ecx
	jmp	.L79
.L64:
	movq	%rbp, %rdi
	xorl	%ebx, %ebx
	call	free@PLT
.L55:
	leaq	112(%rsp), %rdi
	call	_ZNSt6vectorIP11CUstream_stSaIS1_EED1Ev
	jmp	.L30
.L70:
	endbr64
	movq	%rax, %rbx
.L65:
	leaq	112(%rsp), %rdi
	call	_ZNSt6vectorIP11CUstream_stSaIS1_EED1Ev
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L86
	movq	%rbx, %rdi
.LEHB2:
	call	_Unwind_Resume@PLT
.LEHE2:
.L30:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L67
.L86:
	call	__stack_chk_fail@PLT
.L67:
	addq	$152, %rsp
	.cfi_def_cfa_offset 56
	movl	%ebx, %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
.LFE2909:
	.globl	__gxx_personality_v0
	.section	.gcc_except_table,"a",@progbits
.LLSDA2909:
	.byte	0xff
	.byte	0xff
	.byte	0x1
	.uleb128 .LLSDACSE2909-.LLSDACSB2909
.LLSDACSB2909:
	.uleb128 .LEHB0-.LFB2909
	.uleb128 .LEHE0-.LEHB0
	.uleb128 0
	.uleb128 0
	.uleb128 .LEHB1-.LFB2909
	.uleb128 .LEHE1-.LEHB1
	.uleb128 .L70-.LFB2909
	.uleb128 0
	.uleb128 .LEHB2-.LFB2909
	.uleb128 .LEHE2-.LEHB2
	.uleb128 0
	.uleb128 0
.LLSDACSE2909:
	.section	.text.startup
	.size	main, .-main
	.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
	.hidden	DW.ref.__gxx_personality_v0
	.weak	DW.ref.__gxx_personality_v0
	.section	.data.rel.local.DW.ref.__gxx_personality_v0,"awG",@progbits,DW.ref.__gxx_personality_v0,comdat
	.align 8
	.type	DW.ref.__gxx_personality_v0, @object
	.size	DW.ref.__gxx_personality_v0, 8
DW.ref.__gxx_personality_v0:
	.quad	__gxx_personality_v0
	.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 <time.h>
#include <unistd.h>
#include <stdlib.h>
#include <math.h>
#include <hiprand/hiprand.h>
#include <time.h> 
#include <vector>
using namespace std;
#define CUDA_CALL(x) do { if((x)!=hipSuccess) { \
    printf("Error at %s:%d : err => %s\n",__FILE__,__LINE__,hipGetErrorString(x));\
    return EXIT_FAILURE;}} while(0)
#define CURAND_CALL(x) do { if((x)!=HIPRAND_STATUS_SUCCESS) { \
    printf("Error at %s:%d\n",__FILE__,__LINE__);\
    return EXIT_FAILURE;}} while(0)
/**
1- Gerar uma matriz aleatoria
2- Aplicar um blur ou filtro (gerar uma nova matriz de saida, com a media aritimetica da vizinhanca aplicada a cada elemento da matriz)
3- Testar e mandar resultados de tempo para os segintes casos:
- memoria unificada
- copia manual de memoria
- usando stream para copia CPU->GPU
- usando streams para os dois sentidos de copias (ida e volta)
4- Testar para matrizes de 100x100 , 1000x1000, 10000x10000
**/
__global__ void blur(unsigned int origData[],unsigned result[],int L,int ox,int oy) {


    int thread_idx = ox + (threadIdx.x + blockIdx.x * blockDim.x);
    int thread_idy = oy + (threadIdx.y + blockIdx.y * blockDim.y);
    
 
    
    if(thread_idx-1 >= 0 && thread_idx+1 < L && thread_idy-1 >= 0 && thread_idy+1 < L)
    {
        int temp = origData[(thread_idx) + (thread_idy)*L];
        temp += origData[(thread_idx-1) + (thread_idy-1)*L];
        temp += origData[(thread_idx) + (thread_idy-1)*L];
        temp += origData[(thread_idx+1) + (thread_idy-1)*L];

        temp += origData[(thread_idx-1) + (thread_idy)*L];
        //temp += origData[(thread_idx) + (thread_idy)*L];
        temp += origData[(thread_idx+1) + (thread_idy)*L];

        temp += origData[(thread_idx-1) + (thread_idy+1)*L];
        temp += origData[(thread_idx) + (thread_idy+1)*L];
        temp += origData[(thread_idx+1) + (thread_idy+1)*L];
        result[(thread_idx) + (thread_idy)*L] = temp/9;
    }else
    {
        result[(thread_idx) + (thread_idy)*L] = origData[(thread_idx) + (thread_idy)*L];
    }
        
}
/*
*argumentos
*1 - n_elementos
*2 - threads por bloco
*/
int main(int argc, char* argv[]) {
    unsigned int L, tam, *h_data,*d_data,*d_res;
    size_t size;
    hipError_t err = hipSuccess;
    L = 40;
    if(argc > 1)
      L = atoi(argv[1]);

    tam = L*L;
    size = tam*sizeof(unsigned int);

    dim3 block_dim(L,L,1);
    dim3 grid_dim(1,1,1);
    if(L>32)
    {
        block_dim = dim3(32,32,1);
        grid_dim = dim3(ceil(L/32),ceil(L/32),1);
    }
    

    // Allocate memory for the vectors on host memory.
    h_data = (unsigned int*) malloc(size);
      
    /* Allocate vectors in device memory */
    CUDA_CALL(hipMalloc(&d_data, size));
    CUDA_CALL(hipMalloc(&d_res, size));

    

    hipEvent_t start, stop;
    CUDA_CALL(hipEventCreate (&start));
    CUDA_CALL(hipEventCreate (&stop));
    CUDA_CALL(hipEventRecord (start, 0)); // 0 is the stream number
    // do Work…
    srand(time(NULL));
    for(int i=0; i<tam;i++)
        h_data[i]=rand();



    //CUDA_CALL(cudaMemcpy(d_data,h_data, size, cudaMemcpyHostToDevice));

    int rStreams = 4;
    dim3 block_dim_temp = dim3(32,32,1);
    dim3 grid_dim_temp = dim3(ceil(L/32),ceil((L/rStreams)/32),1);
    if(grid_dim_temp.y<1)
        grid_dim_temp = dim3(grid_dim_temp.x,1,1);
    //printf("\n grid_dim_temp - %d , %d, %d \n",grid_dim_temp.x,grid_dim_temp.y,grid_dim_temp.z);
    vector<hipStream_t> streams;
    /* Kernel Call */
    for(int oy=0; oy < L; oy+=L/rStreams)
    {
        streams.push_back(hipStream_t());
        hipStreamCreate(&streams.back());
        hipMemcpyAsync (d_data+(oy*L), h_data+(oy*L),(L/rStreams*L)*sizeof(unsigned int), hipMemcpyHostToDevice,streams.back());
    }
    for(int oy=0,i=0; oy < L; oy+=L/rStreams,i++)
        if(i==0)
            blur<<<grid_dim_temp,block_dim_temp,0,streams[i]>>>(d_data, d_res, L, 0, oy);
        else
            blur<<<grid_dim_temp,block_dim_temp,0,streams[i]>>>(d_data, d_res, L+1, 0, oy-1);
            
    for(int oy=0,i=0; oy < L; oy+=L/rStreams,i++)
    {
        hipMemcpyAsync (h_data+(oy*L),d_data+(oy*L),(L/rStreams*L)*sizeof(unsigned int), hipMemcpyDeviceToHost,streams[i]);
    }
    err = hipGetLastError();
    if (err != hipSuccess)
    {
        fprintf(stderr, "Failed to launch vectorAdd kernel (error code %s)!\n", hipGetErrorString(err));
        exit(EXIT_FAILURE);
    }


    

    CUDA_CALL(hipDeviceSynchronize());

    for(int i=0; i<tam;i++)
        h_data[i]=0;
    
    CUDA_CALL(hipEventRecord (stop, 0));
    
    CUDA_CALL(hipEventSynchronize (stop));

   

    float elapsedTime;
    CUDA_CALL(hipEventElapsedTime (&elapsedTime, start, stop));
    printf ("[%d,%.5f],\n", tam,elapsedTime);
    CUDA_CALL(hipEventDestroy(start));
    CUDA_CALL(hipEventDestroy(stop));
    
    /* Free device memory */
    CUDA_CALL( hipFree(d_data));
    CUDA_CALL( hipFree(d_res));
    /* Free host memory */
    free(h_data);

    return 0;
} /* main */


	.text
	.file	"allStream.hip"
	.globl	_Z19__device_stub__blurPjS_iii  # -- Begin function _Z19__device_stub__blurPjS_iii
	.type	_Z19__device_stub__blurPjS_iii,@function
_Z19__device_stub__blurPjS_iii:         # @_Z19__device_stub__blurPjS_iii
	.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	$128, %rsp
	.cfi_def_cfa_offset 176
	.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	12(%rsp), %rsi
	movl	%edx, (%rsi)
	leaq	8(%rsp), %rdx
	movl	%ecx, (%rdx)
	leaq	4(%rsp), %rcx
	movl	%r8d, (%rcx)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	movq	%rcx, 32(%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	$_Z4blurPjS_iii, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$144, %rsp
	.cfi_adjust_cfa_offset -144
	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	_Z19__device_stub__blurPjS_iii, .Lfunc_end0-_Z19__device_stub__blurPjS_iii
	.cfi_endproc
                                        # -- End function
	.globl	main                            # -- Begin function main
	.type	main,@function
main:                                   # @main
.Lfunc_begin0:
	.cfi_startproc
	.cfi_personality 3, __gxx_personality_v0
	.cfi_lsda 3, .Lexception0
# %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	$88, %rsp
	.cfi_def_cfa_offset 144
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	cmpl	$2, %edi
	jl	.LBB1_1
# %bb.2:
	movq	8(%rsi), %rdi
	callq	atoi
	movl	%eax, %r15d
	movl	%eax, %r14d
	imull	%r14d, %r14d
	leaq	(,%r14,4), %r12
	jmp	.LBB1_3
.LBB1_1:
	movl	$40, %r15d
	movl	$1600, %r14d                    # imm = 0x640
	movl	$6400, %r12d                    # imm = 0x1900
.LBB1_3:                                # %.thread
	movq	%r12, %rdi
	callq	malloc
	movq	%rax, %rbx
	leaq	16(%rsp), %rdi
	movq	%r12, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	je	.LBB1_7
# %bb.4:
	leaq	16(%rsp), %rdi
	movq	%r12, %rsi
	callq	hipMalloc
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str, %edi
	movl	$.L.str.1, %esi
	movl	$87, %edx
	jmp	.LBB1_5
.LBB1_7:
	leaq	48(%rsp), %rdi
	movq	%r12, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	je	.LBB1_9
# %bb.8:
	leaq	48(%rsp), %rdi
	movq	%r12, %rsi
	callq	hipMalloc
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str, %edi
	movl	$.L.str.1, %esi
	movl	$88, %edx
	jmp	.LBB1_5
.LBB1_9:
	leaq	8(%rsp), %rdi
	callq	hipEventCreate
	testl	%eax, %eax
	je	.LBB1_11
# %bb.10:
	leaq	8(%rsp), %rdi
	callq	hipEventCreate
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str, %edi
	movl	$.L.str.1, %esi
	movl	$93, %edx
	jmp	.LBB1_5
.LBB1_11:
	movq	%rsp, %rdi
	callq	hipEventCreate
	testl	%eax, %eax
	je	.LBB1_13
# %bb.12:
	movq	%rsp, %rdi
	callq	hipEventCreate
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str, %edi
	movl	$.L.str.1, %esi
	movl	$94, %edx
	jmp	.LBB1_5
.LBB1_13:
	movq	8(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	testl	%eax, %eax
	je	.LBB1_15
# %bb.14:
	movq	8(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str, %edi
	movl	$.L.str.1, %esi
	movl	$95, %edx
.LBB1_5:
	movq	%rax, %rcx
	xorl	%eax, %eax
	callq	printf
	movl	$1, %ebx
.LBB1_6:
	movl	%ebx, %eax
	addq	$88, %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
.LBB1_15:
	.cfi_def_cfa_offset 144
	xorl	%edi, %edi
	callq	time
	movl	%eax, %edi
	callq	srand
	testl	%r14d, %r14d
	je	.LBB1_18
# %bb.16:                               # %.lr.ph.preheader
	movl	%r14d, %r12d
	xorl	%r13d, %r13d
.LBB1_17:                               # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	callq	rand
	movl	%eax, (%rbx,%r13,4)
	incq	%r13
	cmpq	%r13, %r12
	jne	.LBB1_17
.LBB1_18:                               # %._crit_edge
	movl	%r15d, %eax
	shrl	$7, %eax
	shlq	$32, %rax
	cmpl	$128, %r15d
	movabsq	$4294967296, %rcx               # imm = 0x100000000
	cmovaeq	%rax, %rcx
	xorps	%xmm0, %xmm0
	movaps	%xmm0, 64(%rsp)
	movq	$0, 80(%rsp)
	testl	%r15d, %r15d
	je	.LBB1_38
# %bb.19:                               # %.lr.ph158
	movl	%r15d, %eax
	shrl	$5, %eax
	movl	%r15d, %ebp
	shrl	$2, %ebp
	orq	%rax, %rcx
	movq	%rcx, 32(%rsp)                  # 8-byte Spill
	movl	%ebp, %eax
	imull	%r15d, %eax
	movq	%rax, 56(%rsp)                  # 8-byte Spill
	leaq	(,%rax,4), %rax
	movq	%rax, 24(%rsp)                  # 8-byte Spill
	xorl	%r12d, %r12d
	xorl	%r13d, %r13d
.LBB1_20:                               # =>This Inner Loop Header: Depth=1
	movq	$0, 40(%rsp)
.Ltmp0:
	leaq	64(%rsp), %rdi
	leaq	40(%rsp), %rsi
	callq	_ZNSt6vectorIP12ihipStream_tSaIS1_EE12emplace_backIJS1_EEERS1_DpOT_
.Ltmp1:
# %bb.21:                               # %_ZNSt6vectorIP12ihipStream_tSaIS1_EE9push_backEOS1_.exit
                                        #   in Loop: Header=BB1_20 Depth=1
	movq	72(%rsp), %rdi
	addq	$-8, %rdi
.Ltmp3:
	callq	hipStreamCreate
.Ltmp4:
# %bb.22:                               #   in Loop: Header=BB1_20 Depth=1
	movl	%r12d, %eax
	leaq	(,%rax,4), %rdi
	addq	16(%rsp), %rdi
	leaq	(%rbx,%rax,4), %rsi
	movq	72(%rsp), %rax
	movq	-8(%rax), %r8
.Ltmp5:
	movq	24(%rsp), %rdx                  # 8-byte Reload
	movl	$1, %ecx
	callq	hipMemcpyAsync
.Ltmp6:
# %bb.23:                               #   in Loop: Header=BB1_20 Depth=1
	addl	%ebp, %r13d
	addl	56(%rsp), %r12d                 # 4-byte Folded Reload
	cmpl	%r15d, %r13d
	jb	.LBB1_20
# %bb.24:                               # %.lr.ph161
	leal	1(%r15), %eax
	movl	%eax, 24(%rsp)                  # 4-byte Spill
	xorl	%r12d, %r12d
	xorl	%r13d, %r13d
.LBB1_25:                               # =>This Inner Loop Header: Depth=1
	movq	64(%rsp), %rax
	testq	%r12, %r12
	je	.LBB1_26
# %bb.30:                               #   in Loop: Header=BB1_25 Depth=1
	movq	(%rax,%r12,8), %r9
.Ltmp8:
	movq	32(%rsp), %rdi                  # 8-byte Reload
	movl	$1, %esi
	movabsq	$137438953504, %rdx             # imm = 0x2000000020
	movl	$1, %ecx
	xorl	%r8d, %r8d
	callq	__hipPushCallConfiguration
.Ltmp9:
# %bb.31:                               #   in Loop: Header=BB1_25 Depth=1
	testl	%eax, %eax
	jne	.LBB1_34
# %bb.32:                               #   in Loop: Header=BB1_25 Depth=1
	leal	-1(%r13), %r8d
	movl	24(%rsp), %edx                  # 4-byte Reload
	jmp	.LBB1_33
.LBB1_26:                               #   in Loop: Header=BB1_25 Depth=1
	movq	(%rax), %r9
.Ltmp10:
	movq	32(%rsp), %rdi                  # 8-byte Reload
	movl	$1, %esi
	movabsq	$137438953504, %rdx             # imm = 0x2000000020
	movl	$1, %ecx
	xorl	%r8d, %r8d
	callq	__hipPushCallConfiguration
.Ltmp11:
# %bb.27:                               #   in Loop: Header=BB1_25 Depth=1
	movl	%r15d, %edx
	movl	%r13d, %r8d
	testl	%eax, %eax
	jne	.LBB1_34
.LBB1_33:                               # %.invoke
                                        #   in Loop: Header=BB1_25 Depth=1
	movq	48(%rsp), %rsi
	movq	16(%rsp), %rdi
.Ltmp12:
	xorl	%ecx, %ecx
	callq	_Z19__device_stub__blurPjS_iii
.Ltmp13:
.LBB1_34:                               #   in Loop: Header=BB1_25 Depth=1
	addl	%ebp, %r13d
	incq	%r12
	cmpl	%r15d, %r13d
	jb	.LBB1_25
# %bb.35:                               # %.lr.ph164
	movl	%ebp, 32(%rsp)                  # 4-byte Spill
	movq	56(%rsp), %rax                  # 8-byte Reload
	leaq	(,%rax,4), %rax
	movq	%rax, 24(%rsp)                  # 8-byte Spill
	xorl	%r13d, %r13d
	xorl	%ebp, %ebp
	xorl	%r12d, %r12d
.LBB1_36:                               # =>This Inner Loop Header: Depth=1
	movl	%r13d, %esi
	leaq	(%rbx,%rsi,4), %rdi
	shlq	$2, %rsi
	addq	16(%rsp), %rsi
	movq	64(%rsp), %rax
	movq	(%rax,%rbp), %r8
.Ltmp15:
	movq	24(%rsp), %rdx                  # 8-byte Reload
	movl	$2, %ecx
	callq	hipMemcpyAsync
.Ltmp16:
# %bb.37:                               #   in Loop: Header=BB1_36 Depth=1
	addl	32(%rsp), %r12d                 # 4-byte Folded Reload
	addq	$8, %rbp
	addl	56(%rsp), %r13d                 # 4-byte Folded Reload
	cmpl	%r15d, %r12d
	jb	.LBB1_36
.LBB1_38:                               # %._crit_edge165
.Ltmp18:
	callq	hipGetLastError
.Ltmp19:
# %bb.39:
	testl	%eax, %eax
	jne	.LBB1_40
# %bb.43:
.Ltmp22:
	callq	hipDeviceSynchronize
.Ltmp23:
# %bb.44:
	testl	%eax, %eax
	je	.LBB1_45
# %bb.52:
.Ltmp24:
	callq	hipDeviceSynchronize
.Ltmp25:
# %bb.53:
.Ltmp26:
	movl	%eax, %edi
	callq	hipGetErrorString
.Ltmp27:
# %bb.54:
	movl	$.L.str, %edi
	movl	$.L.str.1, %esi
	movl	$139, %edx
	jmp	.LBB1_55
.LBB1_45:                               # %.preheader
	testl	%r14d, %r14d
	je	.LBB1_47
# %bb.46:                               # %.lr.ph167.preheader
	movl	%r14d, %edx
	shlq	$2, %rdx
	movq	%rbx, %rdi
	xorl	%esi, %esi
	callq	memset@PLT
.LBB1_47:                               # %._crit_edge168
	movq	(%rsp), %rdi
.Ltmp28:
	xorl	%esi, %esi
	callq	hipEventRecord
.Ltmp29:
# %bb.48:
	movq	(%rsp), %rdi
	testl	%eax, %eax
	je	.LBB1_56
# %bb.49:
.Ltmp30:
	xorl	%esi, %esi
	callq	hipEventRecord
.Ltmp31:
# %bb.50:
.Ltmp32:
	movl	%eax, %edi
	callq	hipGetErrorString
.Ltmp33:
# %bb.51:
	movl	$.L.str, %edi
	movl	$.L.str.1, %esi
	movl	$144, %edx
	jmp	.LBB1_55
.LBB1_56:
.Ltmp34:
	callq	hipEventSynchronize
.Ltmp35:
# %bb.57:
	testl	%eax, %eax
	je	.LBB1_61
# %bb.58:
	movq	(%rsp), %rdi
.Ltmp36:
	callq	hipEventSynchronize
.Ltmp37:
# %bb.59:
.Ltmp38:
	movl	%eax, %edi
	callq	hipGetErrorString
.Ltmp39:
# %bb.60:
	movl	$.L.str, %edi
	movl	$.L.str.1, %esi
	movl	$146, %edx
	jmp	.LBB1_55
.LBB1_61:
	movq	8(%rsp), %rsi
	movq	(%rsp), %rdx
.Ltmp41:
	leaq	40(%rsp), %rdi
	callq	hipEventElapsedTime
.Ltmp42:
# %bb.62:
	testl	%eax, %eax
	je	.LBB1_67
# %bb.63:
	movq	8(%rsp), %rsi
	movq	(%rsp), %rdx
.Ltmp43:
	leaq	40(%rsp), %rdi
	callq	hipEventElapsedTime
.Ltmp44:
# %bb.64:
.Ltmp45:
	movl	%eax, %edi
	callq	hipGetErrorString
.Ltmp46:
# %bb.65:
	movl	$.L.str, %edi
	movl	$.L.str.1, %esi
	movl	$151, %edx
	jmp	.LBB1_55
.LBB1_67:
	xorps	%xmm0, %xmm0
	cvtss2sd	40(%rsp), %xmm0
	movl	$.L.str.3, %edi
	movl	%r14d, %esi
	movb	$1, %al
	callq	printf
	movq	8(%rsp), %rdi
.Ltmp47:
	callq	hipEventDestroy
.Ltmp48:
# %bb.68:
	testl	%eax, %eax
	je	.LBB1_72
# %bb.69:
	movq	8(%rsp), %rdi
.Ltmp49:
	callq	hipEventDestroy
.Ltmp50:
# %bb.70:
.Ltmp51:
	movl	%eax, %edi
	callq	hipGetErrorString
.Ltmp52:
# %bb.71:
	movl	$.L.str, %edi
	movl	$.L.str.1, %esi
	movl	$153, %edx
	jmp	.LBB1_55
.LBB1_72:
	movq	(%rsp), %rdi
.Ltmp53:
	callq	hipEventDestroy
.Ltmp54:
# %bb.73:
	testl	%eax, %eax
	je	.LBB1_77
# %bb.74:
	movq	(%rsp), %rdi
.Ltmp55:
	callq	hipEventDestroy
.Ltmp56:
# %bb.75:
.Ltmp57:
	movl	%eax, %edi
	callq	hipGetErrorString
.Ltmp58:
# %bb.76:
	movl	$.L.str, %edi
	movl	$.L.str.1, %esi
	movl	$154, %edx
	jmp	.LBB1_55
.LBB1_77:
	movq	16(%rsp), %rdi
.Ltmp59:
	callq	hipFree
.Ltmp60:
# %bb.78:
	testl	%eax, %eax
	je	.LBB1_82
# %bb.79:
	movq	16(%rsp), %rdi
.Ltmp61:
	callq	hipFree
.Ltmp62:
# %bb.80:
.Ltmp63:
	movl	%eax, %edi
	callq	hipGetErrorString
.Ltmp64:
# %bb.81:
	movl	$.L.str, %edi
	movl	$.L.str.1, %esi
	movl	$157, %edx
	jmp	.LBB1_55
.LBB1_82:
	movq	48(%rsp), %rdi
.Ltmp65:
	callq	hipFree
.Ltmp66:
# %bb.83:
	testl	%eax, %eax
	je	.LBB1_87
# %bb.84:
	movq	48(%rsp), %rdi
.Ltmp67:
	callq	hipFree
.Ltmp68:
# %bb.85:
.Ltmp69:
	movl	%eax, %edi
	callq	hipGetErrorString
.Ltmp70:
# %bb.86:
	movl	$.L.str, %edi
	movl	$.L.str.1, %esi
	movl	$158, %edx
.LBB1_55:
	movq	%rax, %rcx
	xorl	%eax, %eax
	callq	printf
	movl	$1, %ebx
.LBB1_88:
	movq	64(%rsp), %rdi
	testq	%rdi, %rdi
	je	.LBB1_6
# %bb.89:
	callq	_ZdlPv
	jmp	.LBB1_6
.LBB1_87:
	movq	%rbx, %rdi
	callq	free
	xorl	%ebx, %ebx
	jmp	.LBB1_88
.LBB1_40:
	movq	stderr(%rip), %rbx
.Ltmp20:
	movl	%eax, %edi
	callq	hipGetErrorString
.Ltmp21:
# %bb.41:
	movl	$.L.str.2, %esi
	movq	%rbx, %rdi
	movq	%rax, %rdx
	xorl	%eax, %eax
	callq	fprintf
	movl	$1, %edi
	callq	exit
.LBB1_66:
.Ltmp71:
	jmp	.LBB1_91
.LBB1_42:
.Ltmp40:
	jmp	.LBB1_91
.LBB1_94:
.Ltmp17:
	jmp	.LBB1_91
.LBB1_90:
.Ltmp2:
	jmp	.LBB1_91
.LBB1_29:
.Ltmp14:
	jmp	.LBB1_91
.LBB1_28:
.Ltmp7:
.LBB1_91:
	movq	%rax, %rbx
	movq	64(%rsp), %rdi
	testq	%rdi, %rdi
	je	.LBB1_93
# %bb.92:
	callq	_ZdlPv
.LBB1_93:                               # %_ZNSt6vectorIP12ihipStream_tSaIS1_EED2Ev.exit121
	movq	%rbx, %rdi
	callq	_Unwind_Resume@PLT
.Lfunc_end1:
	.size	main, .Lfunc_end1-main
	.cfi_endproc
	.section	.gcc_except_table,"a",@progbits
	.p2align	2, 0x0
GCC_except_table1:
.Lexception0:
	.byte	255                             # @LPStart Encoding = omit
	.byte	255                             # @TType Encoding = omit
	.byte	1                               # Call site Encoding = uleb128
	.uleb128 .Lcst_end0-.Lcst_begin0
.Lcst_begin0:
	.uleb128 .Lfunc_begin0-.Lfunc_begin0    # >> Call Site 1 <<
	.uleb128 .Ltmp0-.Lfunc_begin0           #   Call between .Lfunc_begin0 and .Ltmp0
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp0-.Lfunc_begin0           # >> Call Site 2 <<
	.uleb128 .Ltmp1-.Ltmp0                  #   Call between .Ltmp0 and .Ltmp1
	.uleb128 .Ltmp2-.Lfunc_begin0           #     jumps to .Ltmp2
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp3-.Lfunc_begin0           # >> Call Site 3 <<
	.uleb128 .Ltmp6-.Ltmp3                  #   Call between .Ltmp3 and .Ltmp6
	.uleb128 .Ltmp7-.Lfunc_begin0           #     jumps to .Ltmp7
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp8-.Lfunc_begin0           # >> Call Site 4 <<
	.uleb128 .Ltmp13-.Ltmp8                 #   Call between .Ltmp8 and .Ltmp13
	.uleb128 .Ltmp14-.Lfunc_begin0          #     jumps to .Ltmp14
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp15-.Lfunc_begin0          # >> Call Site 5 <<
	.uleb128 .Ltmp16-.Ltmp15                #   Call between .Ltmp15 and .Ltmp16
	.uleb128 .Ltmp17-.Lfunc_begin0          #     jumps to .Ltmp17
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp18-.Lfunc_begin0          # >> Call Site 6 <<
	.uleb128 .Ltmp27-.Ltmp18                #   Call between .Ltmp18 and .Ltmp27
	.uleb128 .Ltmp40-.Lfunc_begin0          #     jumps to .Ltmp40
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp27-.Lfunc_begin0          # >> Call Site 7 <<
	.uleb128 .Ltmp28-.Ltmp27                #   Call between .Ltmp27 and .Ltmp28
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp28-.Lfunc_begin0          # >> Call Site 8 <<
	.uleb128 .Ltmp39-.Ltmp28                #   Call between .Ltmp28 and .Ltmp39
	.uleb128 .Ltmp40-.Lfunc_begin0          #     jumps to .Ltmp40
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp41-.Lfunc_begin0          # >> Call Site 9 <<
	.uleb128 .Ltmp70-.Ltmp41                #   Call between .Ltmp41 and .Ltmp70
	.uleb128 .Ltmp71-.Lfunc_begin0          #     jumps to .Ltmp71
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp20-.Lfunc_begin0          # >> Call Site 10 <<
	.uleb128 .Ltmp21-.Ltmp20                #   Call between .Ltmp20 and .Ltmp21
	.uleb128 .Ltmp40-.Lfunc_begin0          #     jumps to .Ltmp40
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp21-.Lfunc_begin0          # >> Call Site 11 <<
	.uleb128 .Lfunc_end1-.Ltmp21            #   Call between .Ltmp21 and .Lfunc_end1
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
.Lcst_end0:
	.p2align	2, 0x0
                                        # -- End function
	.section	.text._ZNSt6vectorIP12ihipStream_tSaIS1_EE12emplace_backIJS1_EEERS1_DpOT_,"axG",@progbits,_ZNSt6vectorIP12ihipStream_tSaIS1_EE12emplace_backIJS1_EEERS1_DpOT_,comdat
	.weak	_ZNSt6vectorIP12ihipStream_tSaIS1_EE12emplace_backIJS1_EEERS1_DpOT_ # -- Begin function _ZNSt6vectorIP12ihipStream_tSaIS1_EE12emplace_backIJS1_EEERS1_DpOT_
	.p2align	1, 0x90
	.type	_ZNSt6vectorIP12ihipStream_tSaIS1_EE12emplace_backIJS1_EEERS1_DpOT_,@function
_ZNSt6vectorIP12ihipStream_tSaIS1_EE12emplace_backIJS1_EEERS1_DpOT_: # @_ZNSt6vectorIP12ihipStream_tSaIS1_EE12emplace_backIJS1_EEERS1_DpOT_
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset %rbx, -16
	movq	%rsi, %rdx
	movq	%rdi, %rbx
	movq	8(%rdi), %rsi
	cmpq	16(%rdi), %rsi
	je	.LBB2_2
# %bb.1:
	movq	(%rdx), %rax
	movq	%rax, (%rsi)
	movq	8(%rbx), %rax
	addq	$8, %rax
	movq	%rax, 8(%rbx)
	jmp	.LBB2_3
.LBB2_2:
	movq	%rbx, %rdi
	callq	_ZNSt6vectorIP12ihipStream_tSaIS1_EE17_M_realloc_insertIJS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_
	movq	8(%rbx), %rax
.LBB2_3:
	addq	$-8, %rax
	popq	%rbx
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end2:
	.size	_ZNSt6vectorIP12ihipStream_tSaIS1_EE12emplace_backIJS1_EEERS1_DpOT_, .Lfunc_end2-_ZNSt6vectorIP12ihipStream_tSaIS1_EE12emplace_backIJS1_EEERS1_DpOT_
	.cfi_endproc
                                        # -- End function
	.section	.text._ZNSt6vectorIP12ihipStream_tSaIS1_EE17_M_realloc_insertIJS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_,"axG",@progbits,_ZNSt6vectorIP12ihipStream_tSaIS1_EE17_M_realloc_insertIJS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_,comdat
	.weak	_ZNSt6vectorIP12ihipStream_tSaIS1_EE17_M_realloc_insertIJS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_ # -- Begin function _ZNSt6vectorIP12ihipStream_tSaIS1_EE17_M_realloc_insertIJS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_
	.p2align	1, 0x90
	.type	_ZNSt6vectorIP12ihipStream_tSaIS1_EE17_M_realloc_insertIJS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_,@function
_ZNSt6vectorIP12ihipStream_tSaIS1_EE17_M_realloc_insertIJS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_: # @_ZNSt6vectorIP12ihipStream_tSaIS1_EE17_M_realloc_insertIJS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_
	.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	$24, %rsp
	.cfi_def_cfa_offset 80
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rdx, (%rsp)                    # 8-byte Spill
	movq	%rsi, %r12
	movq	%rdi, %rbx
	movl	$1, %esi
	movl	$.L.str.4, %edx
	callq	_ZNKSt6vectorIP12ihipStream_tSaIS1_EE12_M_check_lenEmPKc
	movq	(%rbx), %r13
	movq	8(%rbx), %r15
	movq	%r12, 8(%rsp)                   # 8-byte Spill
	subq	%r13, %r12
	movq	%r12, %r14
	sarq	$3, %r14
	testq	%rax, %rax
	movq	%rax, 16(%rsp)                  # 8-byte Spill
	je	.LBB3_1
# %bb.2:
	movq	%rbx, %rdi
	movq	%rax, %rsi
	xorl	%edx, %edx
	callq	_ZNSt15__new_allocatorIP12ihipStream_tE8allocateEmPKv
	movq	%rax, %rbp
	jmp	.LBB3_3
.LBB3_1:
	xorl	%ebp, %ebp
.LBB3_3:                                # %_ZNSt12_Vector_baseIP12ihipStream_tSaIS1_EE11_M_allocateEm.exit
	movq	(%rsp), %rax                    # 8-byte Reload
	movq	(%rax), %rax
	movq	%rax, (%rbp,%r14,8)
	testq	%r12, %r12
	jle	.LBB3_5
# %bb.4:
	movq	%rbp, %rdi
	movq	%r13, %rsi
	movq	%r12, %rdx
	callq	memmove@PLT
.LBB3_5:                                # %_ZNSt6vectorIP12ihipStream_tSaIS1_EE11_S_relocateEPS1_S4_S4_RS2_.exit
	addq	%rbp, %r12
	addq	$8, %r12
	movq	8(%rsp), %rsi                   # 8-byte Reload
	subq	%rsi, %r15
	testq	%r15, %r15
	jle	.LBB3_7
# %bb.6:
	movq	%r12, %rdi
	movq	%r15, %rdx
	callq	memmove@PLT
.LBB3_7:                                # %_ZNSt6vectorIP12ihipStream_tSaIS1_EE11_S_relocateEPS1_S4_S4_RS2_.exit16
	testq	%r13, %r13
	je	.LBB3_9
# %bb.8:
	movq	%r13, %rdi
	callq	_ZdlPv
.LBB3_9:                                # %_ZNSt12_Vector_baseIP12ihipStream_tSaIS1_EE13_M_deallocateEPS1_m.exit
	addq	%r15, %r12
	movq	%rbp, (%rbx)
	movq	%r12, 8(%rbx)
	movq	16(%rsp), %rax                  # 8-byte Reload
	leaq	(,%rax,8), %rax
	addq	%rbp, %rax
	movq	%rax, 16(%rbx)
	addq	$24, %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_end3:
	.size	_ZNSt6vectorIP12ihipStream_tSaIS1_EE17_M_realloc_insertIJS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_, .Lfunc_end3-_ZNSt6vectorIP12ihipStream_tSaIS1_EE17_M_realloc_insertIJS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_
	.cfi_endproc
                                        # -- End function
	.section	.text._ZNKSt6vectorIP12ihipStream_tSaIS1_EE12_M_check_lenEmPKc,"axG",@progbits,_ZNKSt6vectorIP12ihipStream_tSaIS1_EE12_M_check_lenEmPKc,comdat
	.weak	_ZNKSt6vectorIP12ihipStream_tSaIS1_EE12_M_check_lenEmPKc # -- Begin function _ZNKSt6vectorIP12ihipStream_tSaIS1_EE12_M_check_lenEmPKc
	.p2align	1, 0x90
	.type	_ZNKSt6vectorIP12ihipStream_tSaIS1_EE12_M_check_lenEmPKc,@function
_ZNKSt6vectorIP12ihipStream_tSaIS1_EE12_M_check_lenEmPKc: # @_ZNKSt6vectorIP12ihipStream_tSaIS1_EE12_M_check_lenEmPKc
	.cfi_startproc
# %bb.0:
	movabsq	$1152921504606846975, %rcx      # imm = 0xFFFFFFFFFFFFFFF
	movq	8(%rdi), %r8
	subq	(%rdi), %r8
	sarq	$3, %r8
	movq	%rcx, %rax
	subq	%r8, %rax
	cmpq	%rsi, %rax
	jb	.LBB4_2
# %bb.1:
	cmpq	%rsi, %r8
	cmovaq	%r8, %rsi
	leaq	(%rsi,%r8), %rax
	cmpq	%rcx, %rax
	cmovaeq	%rcx, %rax
	addq	%r8, %rsi
	cmovbq	%rcx, %rax
	retq
.LBB4_2:
	pushq	%rax
	.cfi_def_cfa_offset 16
	movq	%rdx, %rdi
	callq	_ZSt20__throw_length_errorPKc
.Lfunc_end4:
	.size	_ZNKSt6vectorIP12ihipStream_tSaIS1_EE12_M_check_lenEmPKc, .Lfunc_end4-_ZNKSt6vectorIP12ihipStream_tSaIS1_EE12_M_check_lenEmPKc
	.cfi_endproc
                                        # -- End function
	.section	.text._ZNSt15__new_allocatorIP12ihipStream_tE8allocateEmPKv,"axG",@progbits,_ZNSt15__new_allocatorIP12ihipStream_tE8allocateEmPKv,comdat
	.weak	_ZNSt15__new_allocatorIP12ihipStream_tE8allocateEmPKv # -- Begin function _ZNSt15__new_allocatorIP12ihipStream_tE8allocateEmPKv
	.p2align	1, 0x90
	.type	_ZNSt15__new_allocatorIP12ihipStream_tE8allocateEmPKv,@function
_ZNSt15__new_allocatorIP12ihipStream_tE8allocateEmPKv: # @_ZNSt15__new_allocatorIP12ihipStream_tE8allocateEmPKv
	.cfi_startproc
# %bb.0:
	pushq	%rax
	.cfi_def_cfa_offset 16
	movq	%rsi, %rax
	shrq	$60, %rax
	jne	.LBB5_1
# %bb.3:
	shlq	$3, %rsi
	movq	%rsi, %rdi
	popq	%rax
	.cfi_def_cfa_offset 8
	jmp	_Znwm                           # TAILCALL
.LBB5_1:
	.cfi_def_cfa_offset 16
	shrq	$61, %rsi
	je	.LBB5_2
# %bb.4:
	callq	_ZSt28__throw_bad_array_new_lengthv
.LBB5_2:
	callq	_ZSt17__throw_bad_allocv
.Lfunc_end5:
	.size	_ZNSt15__new_allocatorIP12ihipStream_tE8allocateEmPKv, .Lfunc_end5-_ZNSt15__new_allocatorIP12ihipStream_tE8allocateEmPKv
	.cfi_endproc
                                        # -- 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	.LBB6_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB6_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z4blurPjS_iii, %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_end6:
	.size	__hip_module_ctor, .Lfunc_end6-__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	.LBB7_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
.LBB7_2:
	retq
.Lfunc_end7:
	.size	__hip_module_dtor, .Lfunc_end7-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	_Z4blurPjS_iii,@object          # @_Z4blurPjS_iii
	.section	.rodata,"a",@progbits
	.globl	_Z4blurPjS_iii
	.p2align	3, 0x0
_Z4blurPjS_iii:
	.quad	_Z19__device_stub__blurPjS_iii
	.size	_Z4blurPjS_iii, 8

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"Error at %s:%d : err => %s\n"
	.size	.L.str, 28

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"/home/ubuntu/Datasets/stackv2/train-structured-repos-hip-sm89/sabiomito/uffgpu2019/master/matrix_blur/allStream.hip"
	.size	.L.str.1, 116

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"Failed to launch vectorAdd kernel (error code %s)!\n"
	.size	.L.str.2, 52

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"[%d,%.5f],\n"
	.size	.L.str.3, 12

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"vector::_M_realloc_insert"
	.size	.L.str.4, 26

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z4blurPjS_iii"
	.size	.L__unnamed_1, 15

	.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 _Z19__device_stub__blurPjS_iii
	.addrsig_sym __gxx_personality_v0
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Unwind_Resume
	.addrsig_sym _Z4blurPjS_iii
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z4blurPjS_iii          ; -- Begin function _Z4blurPjS_iii
	.globl	_Z4blurPjS_iii
	.p2align	8
	.type	_Z4blurPjS_iii,@function
_Z4blurPjS_iii:                         ; @_Z4blurPjS_iii
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x2c
	s_load_b256 s[4:11], s[0:1], 0x0
	v_and_b32_e32 v1, 0x3ff, v0
	v_bfe_u32 v2, v0, 10, 10
	s_mov_b32 s1, 0
	s_waitcnt lgkmcnt(0)
	s_and_b32 s0, s2, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1)
	s_mul_i32 s14, s14, s0
	s_lshr_b32 s0, s2, 16
	v_add3_u32 v0, s14, s9, v1
	s_mul_i32 s15, s15, s0
	s_mov_b32 s2, exec_lo
	v_add3_u32 v3, s15, s10, v2
	s_delay_alu instid0(VALU_DEP_2)
	v_cmp_gt_i32_e32 vcc_lo, 1, v0
	v_cmpx_lt_i32_e32 0, v0
	s_cbranch_execz .LBB0_6
; %bb.1:
	v_add_nc_u32_e32 v1, 1, v0
	s_mov_b32 s9, 0
	s_mov_b32 s3, exec_lo
	s_delay_alu instid0(VALU_DEP_1)
	v_cmp_le_i32_e64 s0, s8, v1
	v_cmpx_gt_i32_e64 s8, v1
	s_cbranch_execz .LBB0_5
; %bb.2:
	v_cmp_gt_i32_e64 s9, 1, v3
	s_mov_b32 s10, 0
	s_mov_b32 s11, exec_lo
	v_cmpx_lt_i32_e32 0, v3
; %bb.3:
	v_add_nc_u32_e32 v1, 1, v3
	s_and_not1_b32 s9, s9, exec_lo
	s_mov_b32 s10, exec_lo
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cmp_le_u32_e64 s1, s8, v1
	s_and_b32 s1, s1, exec_lo
	s_delay_alu instid0(SALU_CYCLE_1)
	s_or_b32 s9, s9, s1
; %bb.4:                                ; %Flow93
	s_or_b32 exec_lo, exec_lo, s11
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_not1_b32 s0, s0, exec_lo
	s_and_b32 s1, s9, exec_lo
	s_and_b32 s9, s10, exec_lo
	s_or_b32 s0, s0, s1
.LBB0_5:                                ; %Flow92
	s_or_b32 exec_lo, exec_lo, s3
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_not1_b32 s3, vcc_lo, exec_lo
	s_and_b32 s0, s0, exec_lo
	s_and_b32 s1, s9, exec_lo
	s_or_b32 vcc_lo, s3, s0
.LBB0_6:                                ; %Flow
	s_or_b32 exec_lo, exec_lo, s2
                                        ; implicit-def: $vgpr4
                                        ; implicit-def: $vgpr1_vgpr2
	s_and_saveexec_b32 s0, vcc_lo
	s_cbranch_execz .LBB0_8
; %bb.7:
	v_mad_u64_u32 v[1:2], null, v3, s8, v[0:1]
	s_and_not1_b32 s1, s1, exec_lo
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v2, 31, v1
	v_lshlrev_b64 v[4:5], 2, v[1:2]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v4, vcc_lo, s4, v4
	v_add_co_ci_u32_e32 v5, vcc_lo, s5, v5, vcc_lo
	global_load_b32 v4, v[4:5], off
.LBB0_8:                                ; %Flow94
	s_or_b32 exec_lo, exec_lo, s0
	s_and_saveexec_b32 s0, s1
	s_cbranch_execz .LBB0_10
; %bb.9:
	v_mul_lo_u32 v2, v3, s8
	v_ashrrev_i32_e32 v10, 31, v0
	s_waitcnt vmcnt(0)
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_subrev_nc_u32_e32 v4, s8, v2
	v_add_nc_u32_e32 v1, v2, v0
	v_ashrrev_i32_e32 v6, 31, v4
	s_delay_alu instid0(VALU_DEP_2)
	v_ashrrev_i32_e32 v2, 31, v1
	v_lshl_add_u32 v11, s8, 1, v4
	v_add_nc_u32_e32 v3, v4, v0
	v_add_co_u32 v5, vcc_lo, v4, v0
	v_add_co_ci_u32_e32 v6, vcc_lo, v6, v10, vcc_lo
	v_lshlrev_b64 v[7:8], 2, v[1:2]
	v_ashrrev_i32_e32 v12, 31, v11
	v_ashrrev_i32_e32 v4, 31, v3
	v_add_nc_u32_e32 v9, v11, v0
	v_lshlrev_b64 v[5:6], 2, v[5:6]
	v_add_co_u32 v11, vcc_lo, v11, v0
	v_add_co_ci_u32_e32 v12, vcc_lo, v12, v10, vcc_lo
	v_lshlrev_b64 v[3:4], 2, v[3:4]
	v_add_co_u32 v7, vcc_lo, s4, v7
	v_add_co_ci_u32_e32 v8, vcc_lo, s5, v8, vcc_lo
	v_add_co_u32 v13, vcc_lo, s4, v5
	v_add_co_ci_u32_e32 v14, vcc_lo, s5, v6, vcc_lo
	v_add_co_u32 v15, vcc_lo, s4, v3
	v_ashrrev_i32_e32 v10, 31, v9
	v_add_co_ci_u32_e32 v16, vcc_lo, s5, v4, vcc_lo
	v_lshlrev_b64 v[11:12], 2, v[11:12]
	s_clause 0x2
	global_load_b96 v[3:5], v[7:8], off offset:-4
	global_load_b32 v0, v[13:14], off offset:-4
	global_load_b64 v[6:7], v[15:16], off
	v_lshlrev_b64 v[8:9], 2, v[9:10]
	v_add_co_u32 v10, vcc_lo, s4, v11
	v_add_co_ci_u32_e32 v11, vcc_lo, s5, v12, vcc_lo
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_4)
	v_add_co_u32 v8, vcc_lo, s4, v8
	v_add_co_ci_u32_e32 v9, vcc_lo, s5, v9, vcc_lo
	s_clause 0x1
	global_load_b32 v10, v[10:11], off offset:-4
	global_load_b64 v[8:9], v[8:9], off
	s_waitcnt vmcnt(2)
	v_add3_u32 v0, v0, v4, v6
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_add3_u32 v0, v0, v7, v3
	s_waitcnt vmcnt(1)
	v_add3_u32 v0, v0, v5, v10
	s_waitcnt vmcnt(0)
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add3_u32 v0, v0, v8, v9
	v_mul_hi_i32 v0, 0x38e38e39, v0
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_lshrrev_b32_e32 v3, 31, v0
	v_ashrrev_i32_e32 v0, 1, v0
	v_add_nc_u32_e32 v4, v0, v3
.LBB0_10:
	s_or_b32 exec_lo, exec_lo, s0
	v_lshlrev_b64 v[0:1], 2, v[1:2]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v0, vcc_lo, s6, v0
	v_add_co_ci_u32_e32 v1, vcc_lo, s7, v1, vcc_lo
	s_waitcnt vmcnt(0)
	global_store_b32 v[0:1], v4, off
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z4blurPjS_iii
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 288
		.amdhsa_user_sgpr_count 14
		.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 1
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 1
		.amdhsa_next_free_vgpr 17
		.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	_Z4blurPjS_iii, .Lfunc_end0-_Z4blurPjS_iii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 696
; NumSgprs: 18
; NumVgprs: 17
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 2
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 17
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 14
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 1
	.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
      - .offset:         20
        .size:           4
        .value_kind:     by_value
      - .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:           _Z4blurPjS_iii
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z4blurPjS_iii.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     17
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
