/*****************************************************************************


  Example     : cuda-prefix-sum.cu
 
  Objective   : Write a CUDA program to find prefix sum of an given array.
  Input       : None 

  Output      : Execution time in seconds , Gflops achieved
                                                                                                                            
  Created     : Aug 2011    

  E-mail      : RarchK         
                                 
****************************************************************************/



// This is code for Prefix sum....
#include<stdio.h>
#include<cuda.h>
#define BLOCKSIZE 16
#define SIZE 1024
#define EPS 1.0e-15
cudaDeviceProp deviceProp;	


double *host_Vect,*host_ResVect,*cpu_ResVect;
double *device_Vect,*device_ResVect;
int     vlength ;
 int device_Count;
int size = SIZE;

/*mem error*/
void mem_error(char *arrayname, char *benchmark, int len, char *type)
{
        printf("\nMemory not sufficient to allocate for array %s\n\tBenchmark : %s  \n\tMemory requested = %d number of %s elements\n",arrayname, benchmark, len, type);
        exit(-1);
}

/*calculate Gflops*/
double calculate_gflops(float &Tsec)
{
        float gflops=(1.0e-9 * (( 2.0 * size*size )/Tsec));
	return gflops;
}

/*sequential function for Prefix sum*/
void CPU_PrefixSum()
{
	int curElementIndex=0,counter;
	double  temp_result;
	cpu_ResVect = (double *)malloc(vlength*sizeof(double));
	if(cpu_ResVect==NULL)
                mem_error("cpu_ResVect","Prefix sum",size,"double");
	while(curElementIndex < vlength)
        {
                temp_result = 0.00;
                for(counter = 0 ; counter < curElementIndex ; counter++)
                        temp_result = temp_result + host_Vect[counter];

                cpu_ResVect[curElementIndex] = temp_result;
                curElementIndex++ ;            
        }

}

/*Check for safe return of all calls to the device */
void CUDA_SAFE_CALL(cudaError_t call)
{
        cudaError_t ret = call;
        //printf("RETURN FROM THE CUDA CALL:%d\t:",ret);                                        
        switch(ret)
        {
                case cudaSuccess:
                //              printf("Success\n");                    
                                break;
        /*      case cudaErrorInvalidValue:                             
                                {
                                printf("ERROR: InvalidValue:%i.\n",__LINE__);
                                exit(-1);
                                break;  
                                }                       
                case cudaErrorInvalidDevicePointer:                     
                                {
                                printf("ERROR:Invalid Device pointeri:%i.\n",__LINE__);
                                exit(-1);
                                break;
                                }                       
                case cudaErrorInvalidMemcpyDirection:                   
                                {
                                printf("ERROR:Invalid memcpy direction:%i.\n",__LINE__);        
                                exit(-1);
                                break;
                                }                       */
                default:
                        {
                                printf(" ERROR at line :%i.%d' ' %s\n",__LINE__,ret,cudaGetErrorString(ret));
                                exit(-1);
                                break;
                        }
        }
}
 

/*free memory*/
void dfree(double * arr[],int len)
{
        for(int i=0;i<len;i++)
                CUDA_SAFE_CALL(cudaFree(arr[i]));
        printf("mem freed\n");
}

/* function to calculate relative error*/
void relError(double* dRes,double* hRes,int size)
{
        double relativeError=0.0,errorNorm=0.0;
        int flag=0;
        int i;

        for( i = 0; i < size; ++i) {
                if (fabs(hRes[i]) > fabs(dRes[i]))
                        relativeError = fabs((hRes[i] - dRes[i]) / hRes[i]);
                else
                        relativeError = fabs((dRes[i] - hRes[i]) / dRes[i]);

                if (relativeError > EPS && relativeError != 0.0e+00 )
                {
                        if(errorNorm < relativeError)
                        {
                                errorNorm = relativeError;
                                flag=1;
                        }
                }

        }
        if( flag == 1)
        {
                printf(" \n Results verfication : Failed");
                printf(" \n Considered machine precision : %e", EPS);
                printf(" \n Relative Error                  : %e\n", errorNorm);

        }
        else
                printf("\n Results verfication : Success\n");

}


/*prints the result in screen*/
void print_on_screen(char * program_name,float tsec,double gflops,int size,int flag)//flag=1 if gflops has been calculated else flag =0
{
        printf("\n---------------%s----------------\n",program_name);
        printf("\tSIZE\t TIME_SEC\t Gflops\n");
        if(flag==1)
        printf("\t%d\t%f\t%lf\t",size,tsec,gflops);
        else
        printf("\t%d\t%lf\t%lf\t",size,"---","---");

}

/*funtion to check blocks per grid and threads per block*/
void check_block_grid_dim(cudaDeviceProp devProp,dim3 blockDim,dim3 gridDim)
{

        if( blockDim.x >= devProp.maxThreadsDim[0] || blockDim.y >= devProp.maxThreadsDim[1] || blockDim.z >= devProp.maxThreadsDim[2] )
        {
                printf("\nBlock Dimensions exceed the maximum limits:%d * %d * %d \n",devProp.maxThreadsDim[0],devProp.maxThreadsDim[1],devProp.maxThreadsDim[2]);
               exit(-1);
        }

        if( gridDim.x >= devProp.maxGridSize[0] || gridDim.y >= devProp.maxGridSize[1] || gridDim.z >= devProp.maxGridSize[2] )
        {
                printf("\nGrid Dimensions exceed the maximum limits:%d * %d * %d \n",devProp.maxGridSize[0],devProp.maxGridSize[1],devProp.maxGridSize[2]);
               exit(-1);
        }
}


/*Get the number of GPU devices present on the host */
int get_DeviceCount()
{
        int count;
        cudaGetDeviceCount(&count);
        return count;
}


/*Fill in the vector with double precision values */
void fill_dp_vector(double* vec,int size)
{
        int ind;
        for(ind=0;ind<size;ind++)
                vec[ind]=drand48();
}


/////////////////////////////////////////////////////////////////////////////////////////
//
// Prefix sum : this kernel will perform actual Prefix sum
//
/////////////////////////////////////////////////////////////////////////////////////////
__global__ void PrefixSum(double *dInArray, double *dOutArray, int arrayLen, int threadDim)
  {
	int tidx = threadIdx.x;
    	int tidy = threadIdx.y;
    	int tindex = (threadDim * tidx) + tidy;
    	int maxNumThread = threadDim * threadDim; 
    	int pass = 0;  
    	int count ;
    	int curEleInd;
    	double tempResult = 0.0;

    	while( (curEleInd = (tindex + maxNumThread * pass))  < arrayLen )
     	{
        	tempResult = 0.0f;
        	for( count = 0; count < curEleInd; count++)
             		tempResult += dInArray[count];
        	dOutArray[curEleInd] = tempResult;
        	pass++;
      	}
     	__syncthreads();
  }//end of Prefix sum function

/*function to launch kernel*/
void launch_Kernel_PrefixSum()
{
/*          threads_per_block, blocks_per_grid  */
	dim3 dimBlock(BLOCKSIZE,BLOCKSIZE);
	dim3 dimGrid(1,1);
	check_block_grid_dim(deviceProp,dimBlock,dimGrid);
	PrefixSum<<<dimGrid,dimBlock>>>(device_Vect,device_ResVect,vlength,BLOCKSIZE);
}


/*main function*/
int main()
{
       	vlength  = SIZE;
     	
	float elapsedTime,Tsec;
	cudaEvent_t start,stop;

	device_Count=get_DeviceCount();
        printf("\n\nNUmber of Devices : %d\n\n", device_Count);

        // Device Selection, Device 1: Tesla C1060
        cudaSetDevice(0);
      
        int device;
        // Current Device Detection
        cudaGetDevice(&device);
        cudaGetDeviceProperties(&deviceProp,device);
        printf("Using device %d: %s \n", device, deviceProp.name);


	
  	/*allocating the memory for each vector */
	host_Vect = new double[vlength];
	host_ResVect = new double[vlength];

	
	// ---------------checking host memory  for error..............................
         if(host_Vect==NULL)
                mem_error("host_Vect","Prefix sum",vlength,"double");

         if(host_ResVect==NULL)
                mem_error("host_ResVect","Prefix sum",vlength,"double");

	//--------------Initializing the input arrays..............
	fill_dp_vector(host_Vect,vlength);

 	/* allocate memory for GPU events 
        start = (cudaEvent_t) malloc (sizeof(cudaEvent_t));
        stop = (cudaEvent_t) malloc (sizeof(cudaEvent_t));
        if(start==NULL)
                mem_error("start","Prefix sum",1,"cudaEvent_t");
        if(stop==NULL)
                mem_error("stop","Prefix sum",1,"cudaEvent_t");*/
  	
	//event creation...
        CUDA_SAFE_CALL(cudaEventCreate (&start));
        CUDA_SAFE_CALL(cudaEventCreate (&stop));

  	//allocating memory on GPU
	CUDA_SAFE_CALL(cudaMalloc( (void**)&device_Vect, vlength* sizeof(double)));
	CUDA_SAFE_CALL(cudaMalloc( (void**)&device_ResVect, vlength* sizeof(double)));

 	//moving data from CPU to GPU
	CUDA_SAFE_CALL(cudaMemcpy((void*)device_Vect, (void*)host_Vect,vlength*sizeof(double),cudaMemcpyHostToDevice));

	// Launching kernell..........	
	CUDA_SAFE_CALL(cudaEventRecord (start, 0));
	
	launch_Kernel_PrefixSum();
	
	CUDA_SAFE_CALL(cudaEventRecord (stop, 0));
	CUDA_SAFE_CALL(cudaEventSynchronize (stop));
	CUDA_SAFE_CALL(cudaEventElapsedTime ( &elapsedTime, start, stop));

	Tsec= 1.0e-3*elapsedTime;
 	
	// calling funtion for measuring Gflops
        calculate_gflops(Tsec);
	
	//printing the result on screen
    	print_on_screen("Prefix Sum",Tsec,calculate_gflops(Tsec),size,1); 

 
	//retriving result from device
  	CUDA_SAFE_CALL(cudaMemcpy((void*)host_ResVect, (void*)device_ResVect,vlength*sizeof(double),cudaMemcpyDeviceToHost));

	// CPU calculation..and checking error deviation....
	CPU_PrefixSum();
  	relError(cpu_ResVect,host_ResVect,size);
   	printf("\n ----------------------------------------------------------------------\n");

	/*free the memory from GPU */
	double *array[2];
        array[0]=device_Vect;
        array[1]=device_ResVect;
        dfree(array,2);

	//free host memory----------
        free(host_Vect);
        free(host_ResVect);
        free(cpu_ResVect);

	return 0;
}// end of main

	.file	"tmpxft_002fbf59_00000000-6_cuda-prefix-sum.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2041:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2041:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"\nMemory not sufficient to allocate for array %s\n\tBenchmark : %s  \n\tMemory requested = %d number of %s elements\n"
	.text
	.globl	_Z9mem_errorPcS_iS_
	.type	_Z9mem_errorPcS_iS_, @function
_Z9mem_errorPcS_iS_:
.LFB2027:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	pushq	%rax
	.cfi_def_cfa_offset 16
	movl	%edx, %r8d
	movq	%rcx, %r9
	movq	%rdi, %rdx
	movq	%rsi, %rcx
	movl	$2, %edi
	xorl	%eax, %eax
	leaq	.LC0(%rip), %rsi
	call	__printf_chk@PLT
	orl	$-1, %edi
	call	exit@PLT
	.cfi_endproc
.LFE2027:
	.size	_Z9mem_errorPcS_iS_, .-_Z9mem_errorPcS_iS_
	.globl	_Z16calculate_gflopsRf
	.type	_Z16calculate_gflopsRf, @function
_Z16calculate_gflopsRf:
.LFB2028:
	.cfi_startproc
	endbr64
	cvtsi2sdl	size(%rip), %xmm1
	movaps	%xmm1, %xmm0
	addsd	%xmm1, %xmm0
	mulsd	%xmm1, %xmm0
	cvtss2sd	(%rdi), %xmm1
	divsd	%xmm1, %xmm0
	mulsd	.LC1(%rip), %xmm0
	cvtsd2ss	%xmm0, %xmm0
	cvtss2sd	%xmm0, %xmm0
	ret
	.cfi_endproc
.LFE2028:
	.size	_Z16calculate_gflopsRf, .-_Z16calculate_gflopsRf
	.section	.rodata.str1.1
.LC3:
	.string	"double"
.LC4:
	.string	"Prefix sum"
.LC5:
	.string	"cpu_ResVect"
	.text
	.globl	_Z13CPU_PrefixSumv
	.type	_Z13CPU_PrefixSumv, @function
_Z13CPU_PrefixSumv:
.LFB2029:
	.cfi_startproc
	endbr64
	movslq	vlength(%rip), %rdi
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	movq	%rdi, %rbx
	salq	$3, %rdi
	call	malloc@PLT
	movq	%rax, cpu_ResVect(%rip)
	testq	%rax, %rax
	je	.L6
	movq	host_Vect(%rip), %rdi
	xorl	%edx, %edx
	jmp	.L7
.L6:
	movl	size(%rip), %edx
	leaq	.LC3(%rip), %rcx
	leaq	.LC4(%rip), %rsi
	leaq	.LC5(%rip), %rdi
	call	_Z9mem_errorPcS_iS_
.L14:
	movsd	%xmm0, (%rax,%rdx,8)
	incq	%rdx
.L7:
	movl	%edx, %esi
	cmpl	%edx, %ebx
	jle	.L13
	xorl	%ecx, %ecx
	xorps	%xmm0, %xmm0
.L9:
	cmpl	%ecx, %esi
	jle	.L14
	addsd	(%rdi,%rcx,8), %xmm0
	incq	%rcx
	jmp	.L9
.L13:
	popq	%rbx
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2029:
	.size	_Z13CPU_PrefixSumv, .-_Z13CPU_PrefixSumv
	.section	.rodata.str1.1
.LC6:
	.string	" ERROR at line :%i.%d' ' %s\n"
	.text
	.globl	_Z14CUDA_SAFE_CALL9cudaError
	.type	_Z14CUDA_SAFE_CALL9cudaError, @function
_Z14CUDA_SAFE_CALL9cudaError:
.LFB2030:
	.cfi_startproc
	endbr64
	testl	%edi, %edi
	je	.L15
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	movl	%edi, %ebx
	call	cudaGetErrorString@PLT
	movl	$2, %edi
	movl	%ebx, %ecx
	movl	$98, %edx
	movq	%rax, %r8
	leaq	.LC6(%rip), %rsi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	orl	$-1, %edi
	call	exit@PLT
.L15:
	.cfi_def_cfa_offset 8
	.cfi_restore 3
	ret
	.cfi_endproc
.LFE2030:
	.size	_Z14CUDA_SAFE_CALL9cudaError, .-_Z14CUDA_SAFE_CALL9cudaError
	.section	.rodata.str1.1
.LC7:
	.string	"mem freed\n"
	.text
	.globl	_Z5dfreePPdi
	.type	_Z5dfreePPdi, @function
_Z5dfreePPdi:
.LFB2031:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movq	%rdi, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movl	%esi, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	xorl	%ebx, %ebx
.L21:
	cmpl	%ebx, %ebp
	jle	.L24
	movq	(%r12,%rbx,8), %rdi
	incq	%rbx
	call	cudaFree@PLT
	movl	%eax, %edi
	call	_Z14CUDA_SAFE_CALL9cudaError
	jmp	.L21
.L24:
	popq	%rbx
	.cfi_def_cfa_offset 24
	leaq	.LC7(%rip), %rsi
	popq	%rbp
	.cfi_def_cfa_offset 16
	movl	$2, %edi
	xorl	%eax, %eax
	popq	%r12
	.cfi_def_cfa_offset 8
	jmp	__printf_chk@PLT
	.cfi_endproc
.LFE2031:
	.size	_Z5dfreePPdi, .-_Z5dfreePPdi
	.section	.rodata.str1.1
.LC10:
	.string	" \n Results verfication : Failed"
.LC11:
	.string	" \n Considered machine precision : %e"
.LC12:
	.string	" \n Relative Error                  : %e\n"
.LC13:
	.string	"\n Results verfication : Success\n"
	.text
	.globl	_Z8relErrorPdS_i
	.type	_Z8relErrorPdS_i, @function
_Z8relErrorPdS_i:
.LFB2032:
	.cfi_startproc
	endbr64
	movq	.LC8(%rip), %xmm1
	xorl	%eax, %eax
	xorl	%ecx, %ecx
	xorps	%xmm4, %xmm4
	movsd	.LC9(%rip), %xmm5
.L26:
	cmpl	%eax, %edx
	jle	.L42
	movsd	(%rsi,%rax,8), %xmm3
	movsd	(%rdi,%rax,8), %xmm2
	movaps	%xmm3, %xmm6
	movaps	%xmm2, %xmm0
	andps	%xmm1, %xmm6
	andps	%xmm1, %xmm0
	comisd	%xmm0, %xmm6
	jbe	.L37
	movaps	%xmm3, %xmm0
	subsd	%xmm2, %xmm0
	divsd	%xmm3, %xmm0
	jmp	.L41
.L37:
	movaps	%xmm2, %xmm0
	subsd	%xmm3, %xmm0
	divsd	%xmm2, %xmm0
.L41:
	andps	%xmm1, %xmm0
	comisd	%xmm5, %xmm0
	jbe	.L30
	comisd	%xmm4, %xmm0
	jbe	.L30
	movaps	%xmm0, %xmm4
	movl	$1, %ecx
.L30:
	incq	%rax
	jmp	.L26
.L42:
	decl	%ecx
	jne	.L33
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	leaq	.LC10(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	movsd	%xmm4, 8(%rsp)
	call	__printf_chk@PLT
	movsd	.LC9(%rip), %xmm0
	leaq	.LC11(%rip), %rsi
	movb	$1, %al
	movl	$2, %edi
	call	__printf_chk@PLT
	movsd	8(%rsp), %xmm4
	leaq	.LC12(%rip), %rsi
	movb	$1, %al
	movl	$2, %edi
	addq	$24, %rsp
	.cfi_def_cfa_offset 8
	movaps	%xmm4, %xmm0
	jmp	__printf_chk@PLT
.L33:
	leaq	.LC13(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	jmp	__printf_chk@PLT
	.cfi_endproc
.LFE2032:
	.size	_Z8relErrorPdS_i, .-_Z8relErrorPdS_i
	.section	.rodata.str1.1
.LC14:
	.string	"\n---------------%s----------------\n"
.LC15:
	.string	"\tSIZE\t TIME_SEC\t Gflops\n"
.LC16:
	.string	"\t%d\t%f\t%lf\t"
.LC17:
	.string	"---"
.LC18:
	.string	"\t%d\t%lf\t%lf\t"
	.text
	.globl	_Z15print_on_screenPcfdii
	.type	_Z15print_on_screenPcfdii, @function
_Z15print_on_screenPcfdii:
.LFB2033:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	xorl	%eax, %eax
	movl	%edx, %ebp
	movq	%rdi, %rdx
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	movl	$2, %edi
	movl	%esi, %ebx
	leaq	.LC14(%rip), %rsi
	subq	$24, %rsp
	.cfi_def_cfa_offset 48
	movss	%xmm0, 12(%rsp)
	movsd	%xmm1, (%rsp)
	call	__printf_chk@PLT
	xorl	%eax, %eax
	movl	$2, %edi
	leaq	.LC15(%rip), %rsi
	call	__printf_chk@PLT
	decl	%ebp
	movsd	(%rsp), %xmm1
	movss	12(%rsp), %xmm0
	jne	.L44
	addq	$24, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	movl	%ebx, %edx
	leaq	.LC16(%rip), %rsi
	movb	$2, %al
	popq	%rbx
	.cfi_def_cfa_offset 16
	movl	$2, %edi
	popq	%rbp
	.cfi_def_cfa_offset 8
	cvtss2sd	%xmm0, %xmm0
	jmp	__printf_chk@PLT
.L44:
	.cfi_restore_state
	addq	$24, %rsp
	.cfi_def_cfa_offset 24
	leaq	.LC17(%rip), %r8
	movl	%ebx, %edx
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 16
	movq	%r8, %rcx
	leaq	.LC18(%rip), %rsi
	movl	$2, %edi
	popq	%rbp
	.cfi_def_cfa_offset 8
	jmp	__printf_chk@PLT
	.cfi_endproc
.LFE2033:
	.size	_Z15print_on_screenPcfdii, .-_Z15print_on_screenPcfdii
	.section	.rodata.str1.1
.LC19:
	.string	"\nBlock Dimensions exceed the maximum limits:%d * %d * %d \n"
.LC20:
	.string	"\nGrid Dimensions exceed the maximum limits:%d * %d * %d \n"
	.text
	.globl	_Z20check_block_grid_dim14cudaDeviceProp4dim3S0_
	.type	_Z20check_block_grid_dim14cudaDeviceProp4dim3S0_, @function
_Z20check_block_grid_dim14cudaDeviceProp4dim3S0_:
.LFB2034:
	.cfi_startproc
	endbr64
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	movl	%esi, 24(%rsp)
	movl	372(%rsp), %esi
	movq	%rdx, (%rsp)
	movl	376(%rsp), %r9d
	movl	%ecx, 8(%rsp)
	movl	380(%rsp), %r8d
	movq	%rdi, 16(%rsp)
	movl	384(%rsp), %edx
	movl	388(%rsp), %ecx
	movl	392(%rsp), %eax
	cmpl	%edi, %esi
	jbe	.L47
	cmpl	%r9d, 20(%rsp)
	jnb	.L47
	cmpl	%r8d, 24(%rsp)
	jb	.L48
.L47:
	movl	%esi, %edx
	movl	%r9d, %ecx
	leaq	.LC19(%rip), %rsi
	jmp	.L52
.L48:
	cmpl	%edx, (%rsp)
	jnb	.L49
	cmpl	%ecx, 4(%rsp)
	jnb	.L49
	cmpl	%eax, 8(%rsp)
	jb	.L46
.L49:
	movl	%eax, %r8d
	leaq	.LC20(%rip), %rsi
.L52:
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	orl	$-1, %edi
	call	exit@PLT
.L46:
	addq	$40, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2034:
	.size	_Z20check_block_grid_dim14cudaDeviceProp4dim3S0_, .-_Z20check_block_grid_dim14cudaDeviceProp4dim3S0_
	.globl	_Z15get_DeviceCountv
	.type	_Z15get_DeviceCountv, @function
_Z15get_DeviceCountv:
.LFB2035:
	.cfi_startproc
	endbr64
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	leaq	4(%rsp), %rdi
	call	cudaGetDeviceCount@PLT
	movl	4(%rsp), %eax
	movq	8(%rsp), %rdx
	subq	%fs:40, %rdx
	je	.L54
	call	__stack_chk_fail@PLT
.L54:
	addq	$24, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2035:
	.size	_Z15get_DeviceCountv, .-_Z15get_DeviceCountv
	.globl	_Z14fill_dp_vectorPdi
	.type	_Z14fill_dp_vectorPdi, @function
_Z14fill_dp_vectorPdi:
.LFB2036:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movq	%rdi, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movl	%esi, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	xorl	%ebx, %ebx
.L57:
	cmpl	%ebx, %ebp
	jle	.L60
	call	drand48@PLT
	movsd	%xmm0, (%r12,%rbx,8)
	incq	%rbx
	jmp	.L57
.L60:
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2036:
	.size	_Z14fill_dp_vectorPdi, .-_Z14fill_dp_vectorPdi
	.globl	_Z32__device_stub__Z9PrefixSumPdS_iiPdS_ii
	.type	_Z32__device_stub__Z9PrefixSumPdS_iiPdS_ii, @function
_Z32__device_stub__Z9PrefixSumPdS_iiPdS_ii:
.LFB2063:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movq	%rdi, 24(%rsp)
	leaq	56(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	68(%rsp), %rsi
	movl	%edx, 12(%rsp)
	leaq	40(%rsp), %rdx
	movl	%ecx, 8(%rsp)
	leaq	48(%rsp), %rcx
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 64(%rsp)
	movq	%rax, 104(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	12(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 128(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 56(%rsp)
	movq	%rax, 68(%rsp)
	movl	$1, 76(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L61
	pushq	48(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z9PrefixSumPdS_ii(%rip), %rdi
	pushq	48(%rsp)
	.cfi_def_cfa_offset 176
	movq	84(%rsp), %rcx
	movl	92(%rsp), %r8d
	movq	72(%rsp), %rsi
	movl	80(%rsp), %edx
	leaq	120(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 168
	popq	%rdx
	.cfi_def_cfa_offset 160
.L61:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L63
	call	__stack_chk_fail@PLT
.L63:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2063:
	.size	_Z32__device_stub__Z9PrefixSumPdS_iiPdS_ii, .-_Z32__device_stub__Z9PrefixSumPdS_iiPdS_ii
	.globl	_Z9PrefixSumPdS_ii
	.type	_Z9PrefixSumPdS_ii, @function
_Z9PrefixSumPdS_ii:
.LFB2064:
	.cfi_startproc
	endbr64
	jmp	_Z32__device_stub__Z9PrefixSumPdS_iiPdS_ii
	.cfi_endproc
.LFE2064:
	.size	_Z9PrefixSumPdS_ii, .-_Z9PrefixSumPdS_ii
	.globl	_Z23launch_Kernel_PrefixSumv
	.type	_Z23launch_Kernel_PrefixSumv, @function
_Z23launch_Kernel_PrefixSumv:
.LFB2037:
	.cfi_startproc
	endbr64
	subq	$1080, %rsp
	.cfi_def_cfa_offset 1088
	leaq	deviceProp(%rip), %rsi
	movabsq	$68719476752, %rax
	movabsq	$4294967297, %rdx
	movq	%rax, 1048(%rsp)
	movq	%rsp, %rdi
	movl	$258, %ecx
	movl	$1, 1056(%rsp)
	movq	%rdx, 1060(%rsp)
	movl	$1, 1068(%rsp)
	rep movsl
	movl	$1, %ecx
	movq	%rax, %rdi
	movl	$1, %esi
	call	_Z20check_block_grid_dim14cudaDeviceProp4dim3S0_
	movl	1056(%rsp), %ecx
	xorl	%r9d, %r9d
	movq	1048(%rsp), %rdx
	movq	1060(%rsp), %rdi
	movl	1068(%rsp), %esi
	addq	$1040, %rsp
	.cfi_def_cfa_offset 48
	xorl	%r8d, %r8d
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L66
	movl	vlength(%rip), %edx
	movq	device_ResVect(%rip), %rsi
	movl	$16, %ecx
	movq	device_Vect(%rip), %rdi
	addq	$40, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	jmp	_Z32__device_stub__Z9PrefixSumPdS_iiPdS_ii
.L66:
	.cfi_restore_state
	addq	$40, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2037:
	.size	_Z23launch_Kernel_PrefixSumv, .-_Z23launch_Kernel_PrefixSumv
	.section	.rodata.str1.1
.LC21:
	.string	"\n\nNUmber of Devices : %d\n\n"
.LC22:
	.string	"Using device %d: %s \n"
.LC23:
	.string	"host_Vect"
.LC25:
	.string	"Prefix Sum"
.LC26:
	.string	"\n ----------------------------------------------------------------------\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2038:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	leaq	deviceProp(%rip), %rbx
	subq	$64, %rsp
	.cfi_def_cfa_offset 80
	movq	%fs:40, %rax
	movq	%rax, 56(%rsp)
	xorl	%eax, %eax
	movl	$1024, vlength(%rip)
	call	_Z15get_DeviceCountv
	leaq	.LC21(%rip), %rsi
	movl	$2, %edi
	movl	%eax, %edx
	movl	%eax, device_Count(%rip)
	xorl	%eax, %eax
	call	__printf_chk@PLT
	xorl	%edi, %edi
	call	cudaSetDevice@PLT
	leaq	20(%rsp), %rdi
	call	cudaGetDevice@PLT
	movl	20(%rsp), %esi
	movq	%rbx, %rdi
	call	cudaGetDeviceProperties_v2@PLT
	movl	20(%rsp), %edx
	movq	%rbx, %rcx
	xorl	%eax, %eax
	movl	$2, %edi
	leaq	.LC22(%rip), %rsi
	movabsq	$1152921504606846975, %rbx
	call	__printf_chk@PLT
	movslq	vlength(%rip), %rdi
	cmpq	%rdi, %rbx
	jb	.L70
	salq	$3, %rdi
	call	_Znam@PLT
	movslq	vlength(%rip), %rdi
	movq	%rax, host_Vect(%rip)
	cmpq	%rdi, %rbx
	jnb	.L71
.L70:
	movq	56(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L78
	call	__cxa_throw_bad_array_new_length@PLT
.L71:
	salq	$3, %rdi
	call	_Znam@PLT
	movq	host_Vect(%rip), %rdi
	movq	%rax, host_ResVect(%rip)
	testq	%rdi, %rdi
	jne	.L73
	movq	56(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L78
	movl	vlength(%rip), %edx
	leaq	.LC3(%rip), %rcx
	leaq	.LC4(%rip), %rsi
	leaq	.LC23(%rip), %rdi
	call	_Z9mem_errorPcS_iS_
.L73:
	movl	vlength(%rip), %esi
	call	_Z14fill_dp_vectorPdi
	leaq	24(%rsp), %rdi
	call	cudaEventCreate@PLT
	movl	%eax, %edi
	call	_Z14CUDA_SAFE_CALL9cudaError
	leaq	32(%rsp), %rdi
	call	cudaEventCreate@PLT
	movl	%eax, %edi
	call	_Z14CUDA_SAFE_CALL9cudaError
	movslq	vlength(%rip), %rsi
	leaq	device_Vect(%rip), %rdi
	salq	$3, %rsi
	call	cudaMalloc@PLT
	movl	%eax, %edi
	call	_Z14CUDA_SAFE_CALL9cudaError
	movslq	vlength(%rip), %rsi
	leaq	device_ResVect(%rip), %rdi
	salq	$3, %rsi
	call	cudaMalloc@PLT
	movl	%eax, %edi
	call	_Z14CUDA_SAFE_CALL9cudaError
	movslq	vlength(%rip), %rdx
	movl	$1, %ecx
	movq	host_Vect(%rip), %rsi
	movq	device_Vect(%rip), %rdi
	salq	$3, %rdx
	call	cudaMemcpy@PLT
	movl	%eax, %edi
	call	_Z14CUDA_SAFE_CALL9cudaError
	movq	24(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movl	%eax, %edi
	call	_Z14CUDA_SAFE_CALL9cudaError
	call	_Z23launch_Kernel_PrefixSumv
	movq	32(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movl	%eax, %edi
	call	_Z14CUDA_SAFE_CALL9cudaError
	movq	32(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movl	%eax, %edi
	call	_Z14CUDA_SAFE_CALL9cudaError
	movq	32(%rsp), %rdx
	movq	24(%rsp), %rsi
	leaq	12(%rsp), %rdi
	call	cudaEventElapsedTime@PLT
	movl	%eax, %edi
	call	_Z14CUDA_SAFE_CALL9cudaError
	cvtss2sd	12(%rsp), %xmm2
	leaq	16(%rsp), %rdi
	mulsd	.LC24(%rip), %xmm2
	movl	$1, %edx
	cvtsd2ss	%xmm2, %xmm2
	movss	%xmm2, 16(%rsp)
	call	_Z16calculate_gflopsRf
	movl	size(%rip), %esi
	leaq	.LC25(%rip), %rdi
	movaps	%xmm0, %xmm1
	movaps	%xmm2, %xmm0
	call	_Z15print_on_screenPcfdii
	movslq	vlength(%rip), %rdx
	movl	$2, %ecx
	movq	device_ResVect(%rip), %rsi
	movq	host_ResVect(%rip), %rdi
	salq	$3, %rdx
	call	cudaMemcpy@PLT
	movl	%eax, %edi
	call	_Z14CUDA_SAFE_CALL9cudaError
	call	_Z13CPU_PrefixSumv
	movl	size(%rip), %edx
	movq	host_ResVect(%rip), %rsi
	movq	cpu_ResVect(%rip), %rdi
	call	_Z8relErrorPdS_i
	xorl	%eax, %eax
	movl	$2, %edi
	leaq	.LC26(%rip), %rsi
	call	__printf_chk@PLT
	movl	$2, %esi
	leaq	40(%rsp), %rdi
	movq	device_Vect(%rip), %rax
	movq	%rax, 40(%rsp)
	movq	device_ResVect(%rip), %rax
	movq	%rax, 48(%rsp)
	call	_Z5dfreePPdi
	movq	host_Vect(%rip), %rdi
	call	free@PLT
	movq	host_ResVect(%rip), %rdi
	call	free@PLT
	movq	cpu_ResVect(%rip), %rdi
	call	free@PLT
	movq	56(%rsp), %rax
	subq	%fs:40, %rax
	je	.L75
.L78:
	call	__stack_chk_fail@PLT
.L75:
	addq	$64, %rsp
	.cfi_def_cfa_offset 16
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2038:
	.size	main, .-main
	.section	.rodata.str1.1
.LC27:
	.string	"_Z9PrefixSumPdS_ii"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2066:
	.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	.LC27(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z9PrefixSumPdS_ii(%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
.LFE2066:
	.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
	.globl	size
	.data
	.align 4
	.type	size, @object
	.size	size, 4
size:
	.long	1024
	.globl	device_Count
	.bss
	.align 4
	.type	device_Count, @object
	.size	device_Count, 4
device_Count:
	.zero	4
	.globl	vlength
	.align 4
	.type	vlength, @object
	.size	vlength, 4
vlength:
	.zero	4
	.globl	device_ResVect
	.align 8
	.type	device_ResVect, @object
	.size	device_ResVect, 8
device_ResVect:
	.zero	8
	.globl	device_Vect
	.align 8
	.type	device_Vect, @object
	.size	device_Vect, 8
device_Vect:
	.zero	8
	.globl	cpu_ResVect
	.align 8
	.type	cpu_ResVect, @object
	.size	cpu_ResVect, 8
cpu_ResVect:
	.zero	8
	.globl	host_ResVect
	.align 8
	.type	host_ResVect, @object
	.size	host_ResVect, 8
host_ResVect:
	.zero	8
	.globl	host_Vect
	.align 8
	.type	host_Vect, @object
	.size	host_Vect, 8
host_Vect:
	.zero	8
	.globl	deviceProp
	.align 32
	.type	deviceProp, @object
	.size	deviceProp, 1032
deviceProp:
	.zero	1032
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC1:
	.long	-400107883
	.long	1041313291
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC8:
	.long	-1
	.long	2147483647
	.long	0
	.long	0
	.section	.rodata.cst8
	.align 8
.LC9:
	.long	-1629006314
	.long	1020396463
	.align 8
.LC24:
	.long	-755914244
	.long	1062232653
	.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:

/*****************************************************************************


  Example     : cuda-prefix-sum.cu
 
  Objective   : Write a CUDA program to find prefix sum of an given array.
  Input       : None 

  Output      : Execution time in seconds , Gflops achieved
                                                                                                                            
  Created     : Aug 2011    

  E-mail      : RarchK         
                                 
****************************************************************************/



// This is code for Prefix sum....
#include<stdio.h>
#include<hip/hip_runtime.h>
#define BLOCKSIZE 16
#define SIZE 1024
#define EPS 1.0e-15
hipDeviceProp_t deviceProp;	


double *host_Vect,*host_ResVect,*cpu_ResVect;
double *device_Vect,*device_ResVect;
int     vlength ;
 int device_Count;
int size = SIZE;

/*mem error*/
void mem_error(char *arrayname, char *benchmark, int len, char *type)
{
        printf("\nMemory not sufficient to allocate for array %s\n\tBenchmark : %s  \n\tMemory requested = %d number of %s elements\n",arrayname, benchmark, len, type);
        exit(-1);
}

/*calculate Gflops*/
double calculate_gflops(float &Tsec)
{
        float gflops=(1.0e-9 * (( 2.0 * size*size )/Tsec));
	return gflops;
}

/*sequential function for Prefix sum*/
void CPU_PrefixSum()
{
	int curElementIndex=0,counter;
	double  temp_result;
	cpu_ResVect = (double *)malloc(vlength*sizeof(double));
	if(cpu_ResVect==NULL)
                mem_error("cpu_ResVect","Prefix sum",size,"double");
	while(curElementIndex < vlength)
        {
                temp_result = 0.00;
                for(counter = 0 ; counter < curElementIndex ; counter++)
                        temp_result = temp_result + host_Vect[counter];

                cpu_ResVect[curElementIndex] = temp_result;
                curElementIndex++ ;            
        }

}

/*Check for safe return of all calls to the device */
void CUDA_SAFE_CALL(hipError_t call)
{
        hipError_t ret = call;
        //printf("RETURN FROM THE CUDA CALL:%d\t:",ret);                                        
        switch(ret)
        {
                case hipSuccess:
                //              printf("Success\n");                    
                                break;
        /*      case cudaErrorInvalidValue:                             
                                {
                                printf("ERROR: InvalidValue:%i.\n",__LINE__);
                                exit(-1);
                                break;  
                                }                       
                case cudaErrorInvalidDevicePointer:                     
                                {
                                printf("ERROR:Invalid Device pointeri:%i.\n",__LINE__);
                                exit(-1);
                                break;
                                }                       
                case cudaErrorInvalidMemcpyDirection:                   
                                {
                                printf("ERROR:Invalid memcpy direction:%i.\n",__LINE__);        
                                exit(-1);
                                break;
                                }                       */
                default:
                        {
                                printf(" ERROR at line :%i.%d' ' %s\n",__LINE__,ret,hipGetErrorString(ret));
                                exit(-1);
                                break;
                        }
        }
}
 

/*free memory*/
void dfree(double * arr[],int len)
{
        for(int i=0;i<len;i++)
                CUDA_SAFE_CALL(hipFree(arr[i]));
        printf("mem freed\n");
}

/* function to calculate relative error*/
void relError(double* dRes,double* hRes,int size)
{
        double relativeError=0.0,errorNorm=0.0;
        int flag=0;
        int i;

        for( i = 0; i < size; ++i) {
                if (fabs(hRes[i]) > fabs(dRes[i]))
                        relativeError = fabs((hRes[i] - dRes[i]) / hRes[i]);
                else
                        relativeError = fabs((dRes[i] - hRes[i]) / dRes[i]);

                if (relativeError > EPS && relativeError != 0.0e+00 )
                {
                        if(errorNorm < relativeError)
                        {
                                errorNorm = relativeError;
                                flag=1;
                        }
                }

        }
        if( flag == 1)
        {
                printf(" \n Results verfication : Failed");
                printf(" \n Considered machine precision : %e", EPS);
                printf(" \n Relative Error                  : %e\n", errorNorm);

        }
        else
                printf("\n Results verfication : Success\n");

}


/*prints the result in screen*/
void print_on_screen(char * program_name,float tsec,double gflops,int size,int flag)//flag=1 if gflops has been calculated else flag =0
{
        printf("\n---------------%s----------------\n",program_name);
        printf("\tSIZE\t TIME_SEC\t Gflops\n");
        if(flag==1)
        printf("\t%d\t%f\t%lf\t",size,tsec,gflops);
        else
        printf("\t%d\t%lf\t%lf\t",size,"---","---");

}

/*funtion to check blocks per grid and threads per block*/
void check_block_grid_dim(hipDeviceProp_t devProp,dim3 blockDim,dim3 gridDim)
{

        if( blockDim.x >= devProp.maxThreadsDim[0] || blockDim.y >= devProp.maxThreadsDim[1] || blockDim.z >= devProp.maxThreadsDim[2] )
        {
                printf("\nBlock Dimensions exceed the maximum limits:%d * %d * %d \n",devProp.maxThreadsDim[0],devProp.maxThreadsDim[1],devProp.maxThreadsDim[2]);
               exit(-1);
        }

        if( gridDim.x >= devProp.maxGridSize[0] || gridDim.y >= devProp.maxGridSize[1] || gridDim.z >= devProp.maxGridSize[2] )
        {
                printf("\nGrid Dimensions exceed the maximum limits:%d * %d * %d \n",devProp.maxGridSize[0],devProp.maxGridSize[1],devProp.maxGridSize[2]);
               exit(-1);
        }
}


/*Get the number of GPU devices present on the host */
int get_DeviceCount()
{
        int count;
        hipGetDeviceCount(&count);
        return count;
}


/*Fill in the vector with double precision values */
void fill_dp_vector(double* vec,int size)
{
        int ind;
        for(ind=0;ind<size;ind++)
                vec[ind]=drand48();
}


/////////////////////////////////////////////////////////////////////////////////////////
//
// Prefix sum : this kernel will perform actual Prefix sum
//
/////////////////////////////////////////////////////////////////////////////////////////
__global__ void PrefixSum(double *dInArray, double *dOutArray, int arrayLen, int threadDim)
  {
	int tidx = threadIdx.x;
    	int tidy = threadIdx.y;
    	int tindex = (threadDim * tidx) + tidy;
    	int maxNumThread = threadDim * threadDim; 
    	int pass = 0;  
    	int count ;
    	int curEleInd;
    	double tempResult = 0.0;

    	while( (curEleInd = (tindex + maxNumThread * pass))  < arrayLen )
     	{
        	tempResult = 0.0f;
        	for( count = 0; count < curEleInd; count++)
             		tempResult += dInArray[count];
        	dOutArray[curEleInd] = tempResult;
        	pass++;
      	}
     	__syncthreads();
  }//end of Prefix sum function

/*function to launch kernel*/
void launch_Kernel_PrefixSum()
{
/*          threads_per_block, blocks_per_grid  */
	dim3 dimBlock(BLOCKSIZE,BLOCKSIZE);
	dim3 dimGrid(1,1);
	check_block_grid_dim(deviceProp,dimBlock,dimGrid);
	PrefixSum<<<dimGrid,dimBlock>>>(device_Vect,device_ResVect,vlength,BLOCKSIZE);
}


/*main function*/
int main()
{
       	vlength  = SIZE;
     	
	float elapsedTime,Tsec;
	hipEvent_t start,stop;

	device_Count=get_DeviceCount();
        printf("\n\nNUmber of Devices : %d\n\n", device_Count);

        // Device Selection, Device 1: Tesla C1060
        hipSetDevice(0);
      
        int device;
        // Current Device Detection
        hipGetDevice(&device);
        hipGetDeviceProperties(&deviceProp,device);
        printf("Using device %d: %s \n", device, deviceProp.name);


	
  	/*allocating the memory for each vector */
	host_Vect = new double[vlength];
	host_ResVect = new double[vlength];

	
	// ---------------checking host memory  for error..............................
         if(host_Vect==NULL)
                mem_error("host_Vect","Prefix sum",vlength,"double");

         if(host_ResVect==NULL)
                mem_error("host_ResVect","Prefix sum",vlength,"double");

	//--------------Initializing the input arrays..............
	fill_dp_vector(host_Vect,vlength);

 	/* allocate memory for GPU events 
        start = (cudaEvent_t) malloc (sizeof(cudaEvent_t));
        stop = (cudaEvent_t) malloc (sizeof(cudaEvent_t));
        if(start==NULL)
                mem_error("start","Prefix sum",1,"cudaEvent_t");
        if(stop==NULL)
                mem_error("stop","Prefix sum",1,"cudaEvent_t");*/
  	
	//event creation...
        CUDA_SAFE_CALL(hipEventCreate (&start));
        CUDA_SAFE_CALL(hipEventCreate (&stop));

  	//allocating memory on GPU
	CUDA_SAFE_CALL(hipMalloc( (void**)&device_Vect, vlength* sizeof(double)));
	CUDA_SAFE_CALL(hipMalloc( (void**)&device_ResVect, vlength* sizeof(double)));

 	//moving data from CPU to GPU
	CUDA_SAFE_CALL(hipMemcpy((void*)device_Vect, (void*)host_Vect,vlength*sizeof(double),hipMemcpyHostToDevice));

	// Launching kernell..........	
	CUDA_SAFE_CALL(hipEventRecord (start, 0));
	
	launch_Kernel_PrefixSum();
	
	CUDA_SAFE_CALL(hipEventRecord (stop, 0));
	CUDA_SAFE_CALL(hipEventSynchronize (stop));
	CUDA_SAFE_CALL(hipEventElapsedTime ( &elapsedTime, start, stop));

	Tsec= 1.0e-3*elapsedTime;
 	
	// calling funtion for measuring Gflops
        calculate_gflops(Tsec);
	
	//printing the result on screen
    	print_on_screen("Prefix Sum",Tsec,calculate_gflops(Tsec),size,1); 

 
	//retriving result from device
  	CUDA_SAFE_CALL(hipMemcpy((void*)host_ResVect, (void*)device_ResVect,vlength*sizeof(double),hipMemcpyDeviceToHost));

	// CPU calculation..and checking error deviation....
	CPU_PrefixSum();
  	relError(cpu_ResVect,host_ResVect,size);
   	printf("\n ----------------------------------------------------------------------\n");

	/*free the memory from GPU */
	double *array[2];
        array[0]=device_Vect;
        array[1]=device_ResVect;
        dfree(array,2);

	//free host memory----------
        free(host_Vect);
        free(host_ResVect);
        free(cpu_ResVect);

	return 0;
}// end of main

	.text
	.file	"cuda-prefix-sum.hip"
	.globl	_Z9mem_errorPcS_iS_             # -- Begin function _Z9mem_errorPcS_iS_
	.type	_Z9mem_errorPcS_iS_,@function
_Z9mem_errorPcS_iS_:                    # @_Z9mem_errorPcS_iS_
	.cfi_startproc
# %bb.0:
	pushq	%rax
	.cfi_def_cfa_offset 16
	movq	%rcx, %r8
	movl	%edx, %ecx
	movq	%rsi, %rdx
	movq	%rdi, %rsi
	movl	$.L.str, %edi
	xorl	%eax, %eax
	callq	printf
	movl	$-1, %edi
	callq	exit
.Lfunc_end0:
	.size	_Z9mem_errorPcS_iS_, .Lfunc_end0-_Z9mem_errorPcS_iS_
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z16calculate_gflopsRf
.LCPI1_0:
	.quad	0x3e112e0be826d695              # double 1.0000000000000001E-9
	.text
	.globl	_Z16calculate_gflopsRf
	.type	_Z16calculate_gflopsRf,@function
_Z16calculate_gflopsRf:                 # @_Z16calculate_gflopsRf
	.cfi_startproc
# %bb.0:
	cvtsi2sdl	size(%rip), %xmm0
	movapd	%xmm0, %xmm1
	addsd	%xmm0, %xmm1
	cvtss2sd	(%rdi), %xmm2
	mulsd	%xmm0, %xmm1
	divsd	%xmm2, %xmm1
	mulsd	.LCPI1_0(%rip), %xmm1
	xorps	%xmm0, %xmm0
	cvtsd2ss	%xmm1, %xmm0
	cvtss2sd	%xmm0, %xmm0
	retq
.Lfunc_end1:
	.size	_Z16calculate_gflopsRf, .Lfunc_end1-_Z16calculate_gflopsRf
	.cfi_endproc
                                        # -- End function
	.globl	_Z13CPU_PrefixSumv              # -- Begin function _Z13CPU_PrefixSumv
	.type	_Z13CPU_PrefixSumv,@function
_Z13CPU_PrefixSumv:                     # @_Z13CPU_PrefixSumv
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset %rbx, -16
	movslq	vlength(%rip), %rbx
	leaq	(,%rbx,8), %rdi
	callq	malloc
	movq	%rax, cpu_ResVect(%rip)
	testq	%rax, %rax
	je	.LBB2_8
# %bb.1:                                # %.preheader10
	movl	%ebx, %ecx
	testl	%ecx, %ecx
	jle	.LBB2_7
# %bb.2:                                # %.preheader.lr.ph
	movq	host_Vect(%rip), %rdx
	xorl	%esi, %esi
.LBB2_3:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB2_5 Depth 2
	xorpd	%xmm0, %xmm0
	testq	%rsi, %rsi
	je	.LBB2_6
# %bb.4:                                # %.lr.ph.preheader
                                        #   in Loop: Header=BB2_3 Depth=1
	xorl	%edi, %edi
.LBB2_5:                                # %.lr.ph
                                        #   Parent Loop BB2_3 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	addsd	(%rdx,%rdi,8), %xmm0
	incq	%rdi
	cmpq	%rdi, %rsi
	jne	.LBB2_5
.LBB2_6:                                # %._crit_edge
                                        #   in Loop: Header=BB2_3 Depth=1
	movsd	%xmm0, (%rax,%rsi,8)
	incq	%rsi
	cmpq	%rcx, %rsi
	jne	.LBB2_3
.LBB2_7:                                # %._crit_edge14
	popq	%rbx
	.cfi_def_cfa_offset 8
	retq
.LBB2_8:
	.cfi_def_cfa_offset 16
	movl	size(%rip), %ecx
	movl	$.L.str, %edi
	movl	$.L.str.1, %esi
	movl	$.L.str.2, %edx
	movl	$.L.str.3, %r8d
	xorl	%eax, %eax
	callq	printf
	movl	$-1, %edi
	callq	exit
.Lfunc_end2:
	.size	_Z13CPU_PrefixSumv, .Lfunc_end2-_Z13CPU_PrefixSumv
	.cfi_endproc
                                        # -- End function
	.globl	_Z14CUDA_SAFE_CALL10hipError_t  # -- Begin function _Z14CUDA_SAFE_CALL10hipError_t
	.type	_Z14CUDA_SAFE_CALL10hipError_t,@function
_Z14CUDA_SAFE_CALL10hipError_t:         # @_Z14CUDA_SAFE_CALL10hipError_t
	.cfi_startproc
# %bb.0:
	testl	%edi, %edi
	jne	.LBB3_2
# %bb.1:
	retq
.LBB3_2:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset %rbx, -16
	movl	%edi, %ebx
	callq	hipGetErrorString
	movl	$.L.str.4, %edi
	movl	$98, %esi
	movl	%ebx, %edx
	movq	%rax, %rcx
	xorl	%eax, %eax
	callq	printf
	movl	$-1, %edi
	callq	exit
.Lfunc_end3:
	.size	_Z14CUDA_SAFE_CALL10hipError_t, .Lfunc_end3-_Z14CUDA_SAFE_CALL10hipError_t
	.cfi_endproc
                                        # -- End function
	.globl	_Z5dfreePPdi                    # -- Begin function _Z5dfreePPdi
	.type	_Z5dfreePPdi,@function
_Z5dfreePPdi:                           # @_Z5dfreePPdi
	.cfi_startproc
# %bb.0:
	testl	%esi, %esi
	jle	.LBB4_4
# %bb.1:                                # %.lr.ph.preheader
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rdi, %rbx
	movl	%esi, %r14d
	xorl	%r15d, %r15d
.LBB4_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movq	(%rbx,%r15,8), %rdi
	callq	hipFree
	movl	%eax, %edi
	callq	_Z14CUDA_SAFE_CALL10hipError_t
	incq	%r15
	cmpq	%r15, %r14
	jne	.LBB4_2
# %bb.3:
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	.cfi_restore %rbx
	.cfi_restore %r14
	.cfi_restore %r15
.LBB4_4:                                # %._crit_edge
	movl	$.Lstr, %edi
	jmp	puts@PLT                        # TAILCALL
.Lfunc_end4:
	.size	_Z5dfreePPdi, .Lfunc_end4-_Z5dfreePPdi
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0                          # -- Begin function _Z8relErrorPdS_i
.LCPI5_0:
	.quad	0x7fffffffffffffff              # double NaN
	.quad	0x7fffffffffffffff              # double NaN
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0
.LCPI5_1:
	.quad	0x3cd203af9ee75616              # double 1.0000000000000001E-15
	.text
	.globl	_Z8relErrorPdS_i
	.type	_Z8relErrorPdS_i,@function
_Z8relErrorPdS_i:                       # @_Z8relErrorPdS_i
	.cfi_startproc
# %bb.0:
	testl	%edx, %edx
	jle	.LBB5_7
# %bb.1:                                # %.lr.ph.preheader
	movl	%edx, %eax
	xorpd	%xmm0, %xmm0
	xorl	%ecx, %ecx
	movapd	.LCPI5_0(%rip), %xmm1           # xmm1 = [NaN,NaN]
	movsd	.LCPI5_1(%rip), %xmm2           # xmm2 = mem[0],zero
	movl	$1, %edx
	xorl	%r8d, %r8d
	xorpd	%xmm3, %xmm3
.LBB5_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movsd	(%rsi,%rcx,8), %xmm4            # xmm4 = mem[0],zero
	movsd	(%rdi,%rcx,8), %xmm5            # xmm5 = mem[0],zero
	movapd	%xmm5, %xmm6
	subsd	%xmm4, %xmm6
	movapd	%xmm4, %xmm7
	subsd	%xmm5, %xmm7
	divsd	%xmm4, %xmm7
	andpd	%xmm1, %xmm4
	divsd	%xmm5, %xmm6
	andpd	%xmm1, %xmm5
	cmpltsd	%xmm4, %xmm5
	andpd	%xmm5, %xmm7
	andnpd	%xmm6, %xmm5
	orpd	%xmm7, %xmm5
	movapd	%xmm5, %xmm6
	andpd	%xmm1, %xmm6
	cmpneqpd	%xmm0, %xmm5
	movapd	%xmm2, %xmm4
	cmpltpd	%xmm6, %xmm4
	andpd	%xmm5, %xmm4
	ucomisd	%xmm3, %xmm6
	movd	%xmm4, %r9d
	seta	%r10b
	testb	%r10b, %r9b
	jne	.LBB5_4
# %bb.3:                                # %.lr.ph
                                        #   in Loop: Header=BB5_2 Depth=1
	movapd	%xmm3, %xmm6
.LBB5_4:                                # %.lr.ph
                                        #   in Loop: Header=BB5_2 Depth=1
	cmovnel	%edx, %r8d
	incq	%rcx
	movapd	%xmm6, %xmm3
	cmpq	%rcx, %rax
	jne	.LBB5_2
# %bb.5:                                # %._crit_edge
	cmpl	$1, %r8d
	jne	.LBB5_7
# %bb.6:
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$.L.str.6, %edi
	xorl	%eax, %eax
	movapd	%xmm6, (%rsp)                   # 16-byte Spill
	callq	printf
	movsd	.LCPI5_1(%rip), %xmm0           # xmm0 = mem[0],zero
	movl	$.L.str.7, %edi
	movb	$1, %al
	callq	printf
	movl	$.L.str.8, %edi
	movaps	(%rsp), %xmm0                   # 16-byte Reload
	movb	$1, %al
	addq	$24, %rsp
	.cfi_def_cfa_offset 8
	jmp	printf                          # TAILCALL
.LBB5_7:                                # %._crit_edge.thread
	movl	$.Lstr.1, %edi
	jmp	puts@PLT                        # TAILCALL
.Lfunc_end5:
	.size	_Z8relErrorPdS_i, .Lfunc_end5-_Z8relErrorPdS_i
	.cfi_endproc
                                        # -- End function
	.globl	_Z15print_on_screenPcfdii       # -- Begin function _Z15print_on_screenPcfdii
	.type	_Z15print_on_screenPcfdii,@function
_Z15print_on_screenPcfdii:              # @_Z15print_on_screenPcfdii
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	subq	$24, %rsp
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -24
	.cfi_offset %rbp, -16
	movl	%edx, %ebp
	movl	%esi, %ebx
	movsd	%xmm1, 16(%rsp)                 # 8-byte Spill
	movss	%xmm0, 12(%rsp)                 # 4-byte Spill
	movq	%rdi, %rsi
	movl	$.L.str.10, %edi
	xorl	%eax, %eax
	callq	printf
	movl	$.Lstr.2, %edi
	callq	puts@PLT
	cmpl	$1, %ebp
	jne	.LBB6_2
# %bb.1:
	xorps	%xmm0, %xmm0
	cvtss2sd	12(%rsp), %xmm0                 # 4-byte Folded Reload
	movl	$.L.str.12, %edi
	movl	%ebx, %esi
	movsd	16(%rsp), %xmm1                 # 8-byte Reload
                                        # xmm1 = mem[0],zero
	movb	$2, %al
	addq	$24, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	jmp	printf                          # TAILCALL
.LBB6_2:
	.cfi_def_cfa_offset 48
	movl	$.L.str.13, %edi
	movl	$.L.str.14, %edx
	movl	$.L.str.14, %ecx
	movl	%ebx, %esi
	xorl	%eax, %eax
	addq	$24, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	jmp	printf                          # TAILCALL
.Lfunc_end6:
	.size	_Z15print_on_screenPcfdii, .Lfunc_end6-_Z15print_on_screenPcfdii
	.cfi_endproc
                                        # -- End function
	.globl	_Z20check_block_grid_dim20hipDeviceProp_tR06004dim3S0_ # -- Begin function _Z20check_block_grid_dim20hipDeviceProp_tR06004dim3S0_
	.type	_Z20check_block_grid_dim20hipDeviceProp_tR06004dim3S0_,@function
_Z20check_block_grid_dim20hipDeviceProp_tR06004dim3S0_: # @_Z20check_block_grid_dim20hipDeviceProp_tR06004dim3S0_
	.cfi_startproc
# %bb.0:
	pushq	%rax
	.cfi_def_cfa_offset 16
	movl	%esi, %r9d
	leaq	16(%rsp), %r10
	movl	324(%r10), %esi
	cmpl	%edi, %esi
	jbe	.LBB7_1
# %bb.2:
	shrq	$32, %rdi
	movl	328(%r10), %eax
	movl	332(%r10), %r8d
	cmpl	%edi, %eax
	jbe	.LBB7_4
# %bb.3:
	cmpl	%r9d, %r8d
	jbe	.LBB7_4
# %bb.6:
	movl	336(%r10), %esi
	movl	340(%r10), %eax
	movl	344(%r10), %r8d
	cmpl	%edx, %esi
	jbe	.LBB7_9
# %bb.7:
	shrq	$32, %rdx
	cmpl	%edx, %eax
	jbe	.LBB7_9
# %bb.8:
	cmpl	%ecx, %r8d
	jbe	.LBB7_9
# %bb.10:
	popq	%rax
	.cfi_def_cfa_offset 8
	retq
.LBB7_1:                                # %._crit_edge
	.cfi_def_cfa_offset 16
	movl	328(%r10), %eax
	movl	332(%r10), %r8d
.LBB7_4:
	movl	$.L.str.15, %edi
	jmp	.LBB7_5
.LBB7_9:
	movl	$.L.str.16, %edi
.LBB7_5:
	movl	%eax, %edx
	movl	%r8d, %ecx
	xorl	%eax, %eax
	callq	printf
	movl	$-1, %edi
	callq	exit
.Lfunc_end7:
	.size	_Z20check_block_grid_dim20hipDeviceProp_tR06004dim3S0_, .Lfunc_end7-_Z20check_block_grid_dim20hipDeviceProp_tR06004dim3S0_
	.cfi_endproc
                                        # -- End function
	.globl	_Z15get_DeviceCountv            # -- Begin function _Z15get_DeviceCountv
	.type	_Z15get_DeviceCountv,@function
_Z15get_DeviceCountv:                   # @_Z15get_DeviceCountv
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$16, %rsp
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -16
	leaq	12(%rsp), %rbx
	movq	%rbx, %rdi
	callq	hipGetDeviceCount
	movl	(%rbx), %eax
	addq	$16, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end8:
	.size	_Z15get_DeviceCountv, .Lfunc_end8-_Z15get_DeviceCountv
	.cfi_endproc
                                        # -- End function
	.globl	_Z14fill_dp_vectorPdi           # -- Begin function _Z14fill_dp_vectorPdi
	.type	_Z14fill_dp_vectorPdi,@function
_Z14fill_dp_vectorPdi:                  # @_Z14fill_dp_vectorPdi
	.cfi_startproc
# %bb.0:
	testl	%esi, %esi
	jle	.LBB9_4
# %bb.1:                                # %.lr.ph.preheader
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rdi, %rbx
	movl	%esi, %r14d
	xorl	%r15d, %r15d
.LBB9_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	callq	drand48
	movsd	%xmm0, (%rbx,%r15,8)
	incq	%r15
	cmpq	%r15, %r14
	jne	.LBB9_2
# %bb.3:
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	.cfi_restore %rbx
	.cfi_restore %r14
	.cfi_restore %r15
.LBB9_4:                                # %._crit_edge
	retq
.Lfunc_end9:
	.size	_Z14fill_dp_vectorPdi, .Lfunc_end9-_Z14fill_dp_vectorPdi
	.cfi_endproc
                                        # -- End function
	.globl	_Z24__device_stub__PrefixSumPdS_ii # -- Begin function _Z24__device_stub__PrefixSumPdS_ii
	.type	_Z24__device_stub__PrefixSumPdS_ii,@function
_Z24__device_stub__PrefixSumPdS_ii:     # @_Z24__device_stub__PrefixSumPdS_ii
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$112, %rsp
	.cfi_def_cfa_offset 160
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	32(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	12(%rsp), %rsi
	movl	%edx, (%rsi)
	leaq	8(%rsp), %rdx
	movl	%ecx, (%rdx)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	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	$_Z9PrefixSumPdS_ii, %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_end10:
	.size	_Z24__device_stub__PrefixSumPdS_ii, .Lfunc_end10-_Z24__device_stub__PrefixSumPdS_ii
	.cfi_endproc
                                        # -- End function
	.globl	_Z23launch_Kernel_PrefixSumv    # -- Begin function _Z23launch_Kernel_PrefixSumv
	.type	_Z23launch_Kernel_PrefixSumv,@function
_Z23launch_Kernel_PrefixSumv:           # @_Z23launch_Kernel_PrefixSumv
	.cfi_startproc
# %bb.0:
	pushq	%r14
	.cfi_def_cfa_offset 16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	subq	$1480, %rsp                     # imm = 0x5C8
	.cfi_def_cfa_offset 1504
	.cfi_offset %rbx, -24
	.cfi_offset %r14, -16
	movl	$184, %ecx
	movl	$deviceProp, %esi
	movq	%rsp, %rdi
	rep;movsq (%rsi), %es:(%rdi)
	movabsq	$68719476752, %rbx              # imm = 0x1000000010
	movabsq	$4294967297, %r14               # imm = 0x100000001
	movq	%rbx, %rdi
	movl	$1, %esi
	movq	%r14, %rdx
	movl	$1, %ecx
	callq	_Z20check_block_grid_dim20hipDeviceProp_tR06004dim3S0_
	movq	%r14, %rdi
	movl	$1, %esi
	movq	%rbx, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	je	.LBB11_2
# %bb.1:
	addq	$1480, %rsp                     # imm = 0x5C8
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	retq
.LBB11_2:
	.cfi_def_cfa_offset 1504
	movq	device_Vect(%rip), %rdi
	movq	device_ResVect(%rip), %rsi
	movl	vlength(%rip), %edx
	movl	$16, %ecx
	addq	$1480, %rsp                     # imm = 0x5C8
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	jmp	_Z24__device_stub__PrefixSumPdS_ii # TAILCALL
.Lfunc_end11:
	.size	_Z23launch_Kernel_PrefixSumv, .Lfunc_end11-_Z23launch_Kernel_PrefixSumv
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI12_0:
	.quad	0x3f50624dd2f1a9fc              # double 0.001
.LCPI12_1:
	.quad	0x3e112e0be826d695              # double 1.0000000000000001E-9
	.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	$48, %rsp
	.cfi_def_cfa_offset 80
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movl	$1024, vlength(%rip)            # imm = 0x400
	leaq	16(%rsp), %rbx
	movq	%rbx, %rdi
	callq	hipGetDeviceCount
	movl	(%rbx), %esi
	movl	%esi, device_Count(%rip)
	movl	$.L.str.17, %edi
	xorl	%eax, %eax
	callq	printf
	xorl	%edi, %edi
	callq	hipSetDevice
	leaq	8(%rsp), %rbx
	movq	%rbx, %rdi
	callq	hipGetDevice
	movl	(%rbx), %esi
	movl	$deviceProp, %edi
	callq	hipGetDevicePropertiesR0600
	movl	(%rbx), %esi
	movl	$.L.str.18, %edi
	movl	$deviceProp, %edx
	xorl	%eax, %eax
	callq	printf
	movslq	vlength(%rip), %r15
	leaq	(,%r15,8), %rax
	testq	%r15, %r15
	movq	$-1, %r14
	cmovnsq	%rax, %r14
	movq	%r14, %rdi
	callq	_Znam
	movq	%rax, %rbx
	movq	%rax, host_Vect(%rip)
	movq	%r14, %rdi
	callq	_Znam
	movq	%rax, host_ResVect(%rip)
	testq	%r15, %r15
	jle	.LBB12_3
# %bb.1:                                # %.lr.ph.preheader.i
	movl	%r15d, %r14d
	xorl	%r15d, %r15d
.LBB12_2:                               # %.lr.ph.i
                                        # =>This Inner Loop Header: Depth=1
	callq	drand48
	movsd	%xmm0, (%rbx,%r15,8)
	incq	%r15
	cmpq	%r15, %r14
	jne	.LBB12_2
.LBB12_3:                               # %_Z14fill_dp_vectorPdi.exit
	leaq	40(%rsp), %rbx
	movq	%rbx, %rdi
	callq	hipEventCreate
	movl	%eax, %edi
	callq	_Z14CUDA_SAFE_CALL10hipError_t
	leaq	32(%rsp), %r14
	movq	%r14, %rdi
	callq	hipEventCreate
	movl	%eax, %edi
	callq	_Z14CUDA_SAFE_CALL10hipError_t
	movslq	vlength(%rip), %rsi
	shlq	$3, %rsi
	movl	$device_Vect, %edi
	callq	hipMalloc
	movl	%eax, %edi
	callq	_Z14CUDA_SAFE_CALL10hipError_t
	movslq	vlength(%rip), %rsi
	shlq	$3, %rsi
	movl	$device_ResVect, %edi
	callq	hipMalloc
	movl	%eax, %edi
	callq	_Z14CUDA_SAFE_CALL10hipError_t
	movq	device_Vect(%rip), %rdi
	movq	host_Vect(%rip), %rsi
	movslq	vlength(%rip), %rdx
	shlq	$3, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movl	%eax, %edi
	callq	_Z14CUDA_SAFE_CALL10hipError_t
	movq	(%rbx), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movl	%eax, %edi
	callq	_Z14CUDA_SAFE_CALL10hipError_t
	callq	_Z23launch_Kernel_PrefixSumv
	movq	(%r14), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movl	%eax, %edi
	callq	_Z14CUDA_SAFE_CALL10hipError_t
	movq	(%r14), %rdi
	callq	hipEventSynchronize
	movl	%eax, %edi
	callq	_Z14CUDA_SAFE_CALL10hipError_t
	movq	(%rbx), %rsi
	movq	(%r14), %rdx
	leaq	12(%rsp), %rbx
	movq	%rbx, %rdi
	callq	hipEventElapsedTime
	movl	%eax, %edi
	callq	_Z14CUDA_SAFE_CALL10hipError_t
	xorps	%xmm0, %xmm0
	cvtss2sd	(%rbx), %xmm0
	mulsd	.LCPI12_0(%rip), %xmm0
	cvtsd2ss	%xmm0, %xmm0
	movl	size(%rip), %esi
	cvtsi2sd	%esi, %xmm1
	movapd	%xmm1, %xmm2
	addsd	%xmm1, %xmm2
	mulsd	%xmm1, %xmm2
	xorps	%xmm1, %xmm1
	cvtss2sd	%xmm0, %xmm1
	divsd	%xmm1, %xmm2
	mulsd	.LCPI12_1(%rip), %xmm2
	xorps	%xmm1, %xmm1
	cvtsd2ss	%xmm2, %xmm1
	cvtss2sd	%xmm1, %xmm1
	movl	$.L.str.21, %edi
	movl	$1, %edx
	callq	_Z15print_on_screenPcfdii
	movq	host_ResVect(%rip), %rdi
	movq	device_ResVect(%rip), %rsi
	movslq	vlength(%rip), %rdx
	shlq	$3, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	movl	%eax, %edi
	callq	_Z14CUDA_SAFE_CALL10hipError_t
	callq	_Z13CPU_PrefixSumv
	movq	cpu_ResVect(%rip), %rdi
	movq	host_ResVect(%rip), %rsi
	movl	size(%rip), %edx
	callq	_Z8relErrorPdS_i
	movl	$.Lstr.3, %edi
	callq	puts@PLT
	movq	device_Vect(%rip), %rax
	leaq	16(%rsp), %rdi
	movq	%rax, (%rdi)
	movq	device_ResVect(%rip), %rax
	movq	%rax, 8(%rdi)
	movl	$2, %esi
	callq	_Z5dfreePPdi
	movq	host_Vect(%rip), %rdi
	callq	free
	movq	host_ResVect(%rip), %rdi
	callq	free
	movq	cpu_ResVect(%rip), %rdi
	callq	free
	xorl	%eax, %eax
	addq	$48, %rsp
	.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_end12:
	.size	main, .Lfunc_end12-main
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	jne	.LBB13_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB13_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z9PrefixSumPdS_ii, %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_end13:
	.size	__hip_module_ctor, .Lfunc_end13-__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	.LBB14_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
.LBB14_2:
	retq
.Lfunc_end14:
	.size	__hip_module_dtor, .Lfunc_end14-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	deviceProp,@object              # @deviceProp
	.bss
	.globl	deviceProp
	.p2align	3, 0x0
deviceProp:
	.zero	1472
	.size	deviceProp, 1472

	.type	host_Vect,@object               # @host_Vect
	.globl	host_Vect
	.p2align	3, 0x0
host_Vect:
	.quad	0
	.size	host_Vect, 8

	.type	host_ResVect,@object            # @host_ResVect
	.globl	host_ResVect
	.p2align	3, 0x0
host_ResVect:
	.quad	0
	.size	host_ResVect, 8

	.type	cpu_ResVect,@object             # @cpu_ResVect
	.globl	cpu_ResVect
	.p2align	3, 0x0
cpu_ResVect:
	.quad	0
	.size	cpu_ResVect, 8

	.type	device_Vect,@object             # @device_Vect
	.globl	device_Vect
	.p2align	3, 0x0
device_Vect:
	.quad	0
	.size	device_Vect, 8

	.type	device_ResVect,@object          # @device_ResVect
	.globl	device_ResVect
	.p2align	3, 0x0
device_ResVect:
	.quad	0
	.size	device_ResVect, 8

	.type	vlength,@object                 # @vlength
	.globl	vlength
	.p2align	2, 0x0
vlength:
	.long	0                               # 0x0
	.size	vlength, 4

	.type	device_Count,@object            # @device_Count
	.globl	device_Count
	.p2align	2, 0x0
device_Count:
	.long	0                               # 0x0
	.size	device_Count, 4

	.type	size,@object                    # @size
	.data
	.globl	size
	.p2align	2, 0x0
size:
	.long	1024                            # 0x400
	.size	size, 4

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"\nMemory not sufficient to allocate for array %s\n\tBenchmark : %s  \n\tMemory requested = %d number of %s elements\n"
	.size	.L.str, 112

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"cpu_ResVect"
	.size	.L.str.1, 12

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"Prefix sum"
	.size	.L.str.2, 11

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"double"
	.size	.L.str.3, 7

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	" ERROR at line :%i.%d' ' %s\n"
	.size	.L.str.4, 29

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	" \n Results verfication : Failed"
	.size	.L.str.6, 32

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	" \n Considered machine precision : %e"
	.size	.L.str.7, 37

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	" \n Relative Error                  : %e\n"
	.size	.L.str.8, 41

	.type	.L.str.10,@object               # @.str.10
.L.str.10:
	.asciz	"\n---------------%s----------------\n"
	.size	.L.str.10, 36

	.type	.L.str.12,@object               # @.str.12
.L.str.12:
	.asciz	"\t%d\t%f\t%lf\t"
	.size	.L.str.12, 12

	.type	.L.str.13,@object               # @.str.13
.L.str.13:
	.asciz	"\t%d\t%lf\t%lf\t"
	.size	.L.str.13, 13

	.type	.L.str.14,@object               # @.str.14
.L.str.14:
	.asciz	"---"
	.size	.L.str.14, 4

	.type	.L.str.15,@object               # @.str.15
.L.str.15:
	.asciz	"\nBlock Dimensions exceed the maximum limits:%d * %d * %d \n"
	.size	.L.str.15, 59

	.type	.L.str.16,@object               # @.str.16
.L.str.16:
	.asciz	"\nGrid Dimensions exceed the maximum limits:%d * %d * %d \n"
	.size	.L.str.16, 58

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

	.type	.L.str.17,@object               # @.str.17
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.17:
	.asciz	"\n\nNUmber of Devices : %d\n\n"
	.size	.L.str.17, 27

	.type	.L.str.18,@object               # @.str.18
.L.str.18:
	.asciz	"Using device %d: %s \n"
	.size	.L.str.18, 22

	.type	.L.str.21,@object               # @.str.21
.L.str.21:
	.asciz	"Prefix Sum"
	.size	.L.str.21, 11

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z9PrefixSumPdS_ii"
	.size	.L__unnamed_1, 19

	.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	"mem freed"
	.size	.Lstr, 10

	.type	.Lstr.1,@object                 # @str.1
.Lstr.1:
	.asciz	"\n Results verfication : Success"
	.size	.Lstr.1, 32

	.type	.Lstr.2,@object                 # @str.2
.Lstr.2:
	.asciz	"\tSIZE\t TIME_SEC\t Gflops"
	.size	.Lstr.2, 24

	.type	.Lstr.3,@object                 # @str.3
.Lstr.3:
	.asciz	"\n ----------------------------------------------------------------------"
	.size	.Lstr.3, 73

	.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 _Z24__device_stub__PrefixSumPdS_ii
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym deviceProp
	.addrsig_sym device_Vect
	.addrsig_sym device_ResVect
	.addrsig_sym _Z9PrefixSumPdS_ii
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z9PrefixSumPdS_ii      ; -- Begin function _Z9PrefixSumPdS_ii
	.globl	_Z9PrefixSumPdS_ii
	.p2align	8
	.type	_Z9PrefixSumPdS_ii,@function
_Z9PrefixSumPdS_ii:                     ; @_Z9PrefixSumPdS_ii
; %bb.0:
	s_load_b64 s[2:3], s[0:1], 0x10
	v_and_b32_e32 v1, 0x3ff, v0
	v_bfe_u32 v0, v0, 10, 10
	s_mov_b32 s8, exec_lo
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[2:3], null, v1, s3, v[0:1]
	v_cmpx_gt_i32_e64 s2, v2
	s_cbranch_execz .LBB0_7
; %bb.1:                                ; %.preheader.preheader
	s_load_b128 s[4:7], s[0:1], 0x0
	v_mov_b32_e32 v6, 0
	s_mov_b32 s9, 0
	s_mov_b32 s10, 0
.LBB0_2:                                ; %.preheader
                                        ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB0_4 Depth 2
	v_mov_b32_e32 v4, 0
	v_mov_b32_e32 v5, 0
	s_mov_b32 s11, exec_lo
	v_cmpx_lt_i32_e32 0, v2
	s_cbranch_execz .LBB0_6
; %bb.3:                                ; %.lr.ph.preheader
                                        ;   in Loop: Header=BB0_2 Depth=1
	v_mov_b32_e32 v4, 0
	v_mov_b32_e32 v5, 0
	s_mov_b32 s12, 0
	s_waitcnt lgkmcnt(0)
	s_mov_b64 s[0:1], s[4:5]
	s_mov_b32 s13, 0
.LBB0_4:                                ; %.lr.ph
                                        ;   Parent Loop BB0_2 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	global_load_b64 v[7:8], v6, s[0:1]
	s_add_i32 s13, s13, 1
	s_add_u32 s0, s0, 8
	v_cmp_ge_i32_e32 vcc_lo, s13, v2
	s_addc_u32 s1, s1, 0
	s_or_b32 s12, vcc_lo, s12
	s_waitcnt vmcnt(0)
	v_add_f64 v[4:5], v[4:5], v[7:8]
	s_and_not1_b32 exec_lo, exec_lo, s12
	s_cbranch_execnz .LBB0_4
; %bb.5:                                ; %Flow
                                        ;   in Loop: Header=BB0_2 Depth=1
	s_or_b32 exec_lo, exec_lo, s12
.LBB0_6:                                ; %Flow39
                                        ;   in Loop: Header=BB0_2 Depth=1
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_3) | instid1(VALU_DEP_2)
	s_or_b32 exec_lo, exec_lo, s11
	s_add_i32 s10, s10, 1
	v_ashrrev_i32_e32 v3, 31, v2
	v_mad_u64_u32 v[7:8], null, s10, s3, v[1:2]
	v_lshlrev_b64 v[8:9], 3, v[2:3]
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_mad_u64_u32 v[2:3], null, v7, s3, v[0:1]
	s_waitcnt lgkmcnt(0)
	v_add_co_u32 v7, s0, s6, v8
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_co_ci_u32_e64 v8, s0, s7, v9, s0
	v_cmp_le_i32_e32 vcc_lo, s2, v2
	global_store_b64 v[7:8], v[4:5], off
	s_or_b32 s9, vcc_lo, s9
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_not1_b32 exec_lo, exec_lo, s9
	s_cbranch_execnz .LBB0_2
.LBB0_7:                                ; %Flow41
	s_or_b32 exec_lo, exec_lo, s8
	s_waitcnt_vscnt null, 0x0
	s_barrier
	buffer_gl0_inv
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z9PrefixSumPdS_ii
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 24
		.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 1
		.amdhsa_next_free_vgpr 10
		.amdhsa_next_free_sgpr 14
		.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	_Z9PrefixSumPdS_ii, .Lfunc_end0-_Z9PrefixSumPdS_ii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 292
; NumSgprs: 16
; NumVgprs: 10
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 1
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 16
; NumVGPRsForWavesPerEU: 10
; 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: 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
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 24
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z9PrefixSumPdS_ii
    .private_segment_fixed_size: 0
    .sgpr_count:     16
    .sgpr_spill_count: 0
    .symbol:         _Z9PrefixSumPdS_ii.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     10
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
