/* ==================================================================
	Programmer: Yicheng Tu (ytu@cse.usf.edu)
	The basic SDH algorithm implementation for 3D data
	To compile: nvcc SDH.c -o SDH in the rc machines

	
   ==================================================================




	Steven Faulkner
	U9616-1844
	Summer 2018




*/

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <sys/time.h>
#include <cuda_runtime.h>

#define BOX_SIZE	23000 /* size of the data box on one dimension            */

/* descriptors for single atom in the tree */
typedef struct atomdesc {
	double x_pos;
	double y_pos;
	double z_pos;
} atom;

typedef struct hist_entry{
	//float min;
	//float max;
	unsigned long long d_cnt;   /* need a long long type as the count might be huge */
} bucket;


bucket * histogram;		/* list of all buckets in the histogram     */
long long	PDH_acnt;	/* total number of data points              */
int num_buckets;		/* total number of buckets in the histogram */
double   PDH_res;		/* value of width                           */
atom * atom_list;		/* list of all data points                  */
int BlockSize;


struct timezone Idunno;
struct timeval startTime, endTime;



void ErrorCheck( cudaError_t err, const char op[])
	{
		if( err != cudaSuccess ) 
			{ 
				printf("CUDA Error: %s, %s ", op, cudaGetErrorString(err));
				exit(EXIT_FAILURE);
			}
	}
/* 
	distance of two points in the atom_list 
*/

__device__ double 
p2p_distance(atom A, atom B)
{
	double x1 = A.x_pos;
	double x2 = B.x_pos;

	double y1 = A.y_pos;
	double y2 = B.y_pos;

	double z1 = A.z_pos;
	double z2 = B.z_pos;

	return  sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) + (z1-z2)*(z1-z2));

	
}
__global__ void
PDH_baseline(bucket *histo_in, atom *list, double width, int size)
{
	

	int i = blockIdx.x * blockDim.x + threadIdx.x;
	for(int x = i+1; x < size; ++x)
	{
		//double distance = p2p_distance(list,i,x);
//		int pos = (int) (distance/width);
		__syncthreads();
//		histo_in[pos].d_cnt++;
		__syncthreads();
	}
}
__global__ void
pdh_coal(bucket * histogram, atom * list, double width, int size)
{
	int i = threadIdx.x + blockIdx.x * blockDim.x;
	int stride = blockDim.x * gridDim.x;




	while(i < size-1){
		
		for(int j = i+1; j < stride;++j){
//			double distance = p2p_distance(list,i,j);
//			int pos = (int) (distance/width);
//			atomicAdd(&histogram[pos].d_cnt,1);
			
		}
		i+=stride;
		
	}

}
__global__ void
pdh_priv(bucket * histogram,atom * list, double width, int size, int BlockSize)
{
	int t = threadIdx.x;
	int b = blockIdx.x;
	unsigned int reg = t + b * blockDim.x;
	extern __shared__ atom smem[];

	atom * private_atom = &smem[0];
	atom * localBlock = &smem[sizeof(private_atom)];	
	if(t < BlockSize)	
		private_atom[t] = list[reg];
		
	__syncthreads();
		
	//iterate over each block
	for(int i = b + 1; i < size/BlockSize; ++i)
	{
		
		unsigned int tempIdx = t + i * blockDim.x;
	
		if(tempIdx < BlockSize)	
			localBlock[t+ sizeof(private_atom)] = list[tempIdx];
				
		__syncthreads();
	

		//iterate through each thread within each block;
		for(int j =0; j < BlockSize;++j)
		{	
			double distance = p2p_distance(private_atom[t], localBlock[j]);
			int pos = (int) (distance/width);
			atomicAdd(&histogram[pos].d_cnt,1);
		}
		
	}
	
	for(int i = t+1;i < BlockSize;++i)
	{
		double distance = p2p_distance(private_atom[t],private_atom[i]);
		int pos = (int) (distance/width);
		atomicAdd( &histogram[pos].d_cnt,1);
	} 

}
void output_histogram(bucket *histogram){
	int i; 
	long long total_cnt = 0;
	for(i=0; i< num_buckets; i++) {
		if(i%5 == 0) /* we print 5 buckets in a row */
			printf("\n%02d: ", i);
		printf("%15lld ", histogram[i].d_cnt);
		total_cnt += histogram[i].d_cnt;
		
	  	/* we also want to make sure the total distance count is correct */
		if(i == num_buckets - 1)	
			printf("|\n T: %lld \n ", total_cnt);
		else printf("| ");
	}
}

int main(int argc, char **argv)
{
	int i;

	if(argc == 4){

	PDH_acnt = atoi(argv[1]);
	PDH_res	 = atof(argv[2]);
	BlockSize = atoi(argv[3]);
	printf("Parameters are %d, %.2f, %d", PDH_acnt,PDH_res,BlockSize);
	
	}
	
	else{

	int count = argc -1;		
	printf("Too Few Arguments to Function, required 3 only recieved %d\n\n", count);
	exit(EXIT_FAILURE);
	}

	num_buckets = (int)(BOX_SIZE * 1.732 / PDH_res) + 1;
	size_t hist_size = sizeof(bucket)*num_buckets;
	size_t atom_size = sizeof(atom)*PDH_acnt;



	histogram = (bucket *)malloc(sizeof(bucket)*num_buckets);
	atom_list = (atom *)malloc(sizeof(atom)*PDH_acnt);	
	srand(1);
	/* generate data following a uniform distribution */
	for(i = 0;  i < PDH_acnt; i++) {
		atom_list[i].x_pos = ((double)(rand()) / RAND_MAX) * BOX_SIZE;
		atom_list[i].y_pos = ((double)(rand()) / RAND_MAX) * BOX_SIZE;
		atom_list[i].z_pos = ((double)(rand()) / RAND_MAX) * BOX_SIZE;
	}
	
	
	bucket *dev_Histo = NULL;
	atom *dev_atomL = NULL;

	ErrorCheck(cudaMalloc((void**) &dev_Histo,hist_size), "Allocate Memory for Histogram");
	ErrorCheck(cudaMalloc((void**) &dev_atomL, atom_size), "Allocate Memory for Atom List");
	ErrorCheck(cudaMemcpy(dev_Histo,histogram,hist_size, cudaMemcpyHostToDevice), "Copying Histogram to Device");
	ErrorCheck(cudaMemcpy(dev_atomL, atom_list, atom_size, cudaMemcpyHostToDevice), "Copying Atom list to Device");
	
	cudaEvent_t start,stop;
	cudaEventCreate(&start);
	cudaEventCreate(&stop);
	cudaEventRecord(start,0);


//	PDH_baseline <<<ceil(PDH_acnt/32), 32 >>> (dev_Histo, dev_atomL, PDH_res, PDH_acnt);

	pdh_priv <<<ceil(PDH_acnt/BlockSize),BlockSize,2 *  BlockSize*sizeof(atom) >>>(dev_Histo, dev_atomL,PDH_res,PDH_acnt,BlockSize);
	

	cudaEventRecord(stop,0);
	cudaEventSynchronize(stop);
	float elapsedTime;
	cudaEventElapsedTime(&elapsedTime,start,stop);
	cudaEventDestroy(start);
	cudaEventDestroy(stop);

	ErrorCheck(cudaMemcpy(histogram, dev_Histo, hist_size, cudaMemcpyDeviceToHost), " Move Histogram back to Host");
		
	/* print out the histogram */
	output_histogram(histogram);

	//elapsedTime = elapsedTime / 1000;
	printf("\n\n******* Total Running Time of Kernal = %.5f milliseconds *******\n\n", elapsedTime);
	

	ErrorCheck(cudaFree(dev_Histo), "Free Device Histogram");
	ErrorCheck(cudaFree(dev_atomL), "Free Device Atom List");


	ErrorCheck(cudaDeviceReset(), "Reset");
	
	free(histogram);
	free(atom_list);
	
	return 0;
}



	.file	"tmpxft_002f6dda_00000000-6_proj2.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2033:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2033:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"CUDA Error: %s, %s "
	.text
	.globl	_Z10ErrorCheck9cudaErrorPKc
	.type	_Z10ErrorCheck9cudaErrorPKc, @function
_Z10ErrorCheck9cudaErrorPKc:
.LFB2027:
	.cfi_startproc
	endbr64
	testl	%edi, %edi
	je	.L2
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	movq	%rsi, %rbx
	call	cudaGetErrorString@PLT
	movl	$2, %edi
	movq	%rbx, %rdx
	leaq	.LC0(%rip), %rsi
	movq	%rax, %rcx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	$1, %edi
	call	exit@PLT
.L2:
	.cfi_def_cfa_offset 8
	.cfi_restore 3
	ret
	.cfi_endproc
.LFE2027:
	.size	_Z10ErrorCheck9cudaErrorPKc, .-_Z10ErrorCheck9cudaErrorPKc
	.globl	_Z12p2p_distance8atomdescS_
	.type	_Z12p2p_distance8atomdescS_, @function
_Z12p2p_distance8atomdescS_:
.LFB2028:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE2028:
	.size	_Z12p2p_distance8atomdescS_, .-_Z12p2p_distance8atomdescS_
	.section	.rodata.str1.1
.LC1:
	.string	"\n%02d: "
.LC2:
	.string	"%15lld "
.LC3:
	.string	"|\n T: %lld \n "
.LC4:
	.string	"| "
	.text
	.globl	_Z16output_histogramP10hist_entry
	.type	_Z16output_histogramP10hist_entry, @function
_Z16output_histogramP10hist_entry:
.LFB2029:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	leaq	.LC1(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	xorl	%r13d, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	movq	%rdi, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	xorl	%ebx, %ebx
.L11:
	cmpl	%ebx, num_buckets(%rip)
	movl	%ebx, %ebp
	jle	.L17
	movl	%ebp, %eax
	movl	$5, %ecx
	cltd
	idivl	%ecx
	testl	%edx, %edx
	jne	.L12
	movl	%ebp, %edx
	movq	%r14, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L12:
	movq	(%r12,%rbx,8), %rdx
	leaq	.LC2(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	num_buckets(%rip), %eax
	addq	(%r12,%rbx,8), %r13
	decl	%eax
	cmpl	%ebp, %eax
	jne	.L13
	movq	%r13, %rdx
	leaq	.LC3(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L14
.L13:
	leaq	.LC4(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L14:
	incq	%rbx
	jmp	.L11
.L17:
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2029:
	.size	_Z16output_histogramP10hist_entry, .-_Z16output_histogramP10hist_entry
	.globl	_Z55__device_stub__Z12PDH_baselineP10hist_entryP8atomdescdiP10hist_entryP8atomdescdi
	.type	_Z55__device_stub__Z12PDH_baselineP10hist_entryP8atomdescdiP10hist_entryP8atomdescdi, @function
_Z55__device_stub__Z12PDH_baselineP10hist_entryP8atomdescdiP10hist_entryP8atomdescdi:
.LFB2055:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movq	%rdi, 24(%rsp)
	leaq	48(%rsp), %rcx
	leaq	56(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	68(%rsp), %rsi
	movl	%edx, 4(%rsp)
	leaq	40(%rsp), %rdx
	movsd	%xmm0, 8(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 64(%rsp)
	movq	%rax, 104(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	4(%rsp), %rax
	movq	%rax, 128(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 56(%rsp)
	movq	%rax, 68(%rsp)
	movl	$1, 76(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L18
	pushq	48(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z12PDH_baselineP10hist_entryP8atomdescdi(%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
.L18:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L20
	call	__stack_chk_fail@PLT
.L20:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2055:
	.size	_Z55__device_stub__Z12PDH_baselineP10hist_entryP8atomdescdiP10hist_entryP8atomdescdi, .-_Z55__device_stub__Z12PDH_baselineP10hist_entryP8atomdescdiP10hist_entryP8atomdescdi
	.globl	_Z12PDH_baselineP10hist_entryP8atomdescdi
	.type	_Z12PDH_baselineP10hist_entryP8atomdescdi, @function
_Z12PDH_baselineP10hist_entryP8atomdescdi:
.LFB2056:
	.cfi_startproc
	endbr64
	jmp	_Z55__device_stub__Z12PDH_baselineP10hist_entryP8atomdescdiP10hist_entryP8atomdescdi
	.cfi_endproc
.LFE2056:
	.size	_Z12PDH_baselineP10hist_entryP8atomdescdi, .-_Z12PDH_baselineP10hist_entryP8atomdescdi
	.globl	_Z50__device_stub__Z8pdh_coalP10hist_entryP8atomdescdiP10hist_entryP8atomdescdi
	.type	_Z50__device_stub__Z8pdh_coalP10hist_entryP8atomdescdiP10hist_entryP8atomdescdi, @function
_Z50__device_stub__Z8pdh_coalP10hist_entryP8atomdescdiP10hist_entryP8atomdescdi:
.LFB2057:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movq	%rdi, 24(%rsp)
	leaq	48(%rsp), %rcx
	leaq	56(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	68(%rsp), %rsi
	movl	%edx, 4(%rsp)
	leaq	40(%rsp), %rdx
	movsd	%xmm0, 8(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 64(%rsp)
	movq	%rax, 104(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	4(%rsp), %rax
	movq	%rax, 128(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 56(%rsp)
	movq	%rax, 68(%rsp)
	movl	$1, 76(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L23
	pushq	48(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z8pdh_coalP10hist_entryP8atomdescdi(%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
.L23:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L25
	call	__stack_chk_fail@PLT
.L25:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2057:
	.size	_Z50__device_stub__Z8pdh_coalP10hist_entryP8atomdescdiP10hist_entryP8atomdescdi, .-_Z50__device_stub__Z8pdh_coalP10hist_entryP8atomdescdiP10hist_entryP8atomdescdi
	.globl	_Z8pdh_coalP10hist_entryP8atomdescdi
	.type	_Z8pdh_coalP10hist_entryP8atomdescdi, @function
_Z8pdh_coalP10hist_entryP8atomdescdi:
.LFB2058:
	.cfi_startproc
	endbr64
	jmp	_Z50__device_stub__Z8pdh_coalP10hist_entryP8atomdescdiP10hist_entryP8atomdescdi
	.cfi_endproc
.LFE2058:
	.size	_Z8pdh_coalP10hist_entryP8atomdescdi, .-_Z8pdh_coalP10hist_entryP8atomdescdi
	.globl	_Z51__device_stub__Z8pdh_privP10hist_entryP8atomdescdiiP10hist_entryP8atomdescdii
	.type	_Z51__device_stub__Z8pdh_privP10hist_entryP8atomdescdiiP10hist_entryP8atomdescdii, @function
_Z51__device_stub__Z8pdh_privP10hist_entryP8atomdescdiiP10hist_entryP8atomdescdii:
.LFB2059:
	.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, 4(%rsp)
	leaq	32(%rsp), %rdx
	movl	%ecx, (%rsp)
	leaq	40(%rsp), %rcx
	movsd	%xmm0, 8(%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	8(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	4(%rsp), %rax
	movq	%rax, 120(%rsp)
	movq	%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	.L28
	pushq	40(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z8pdh_privP10hist_entryP8atomdescdii(%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
.L28:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L30
	call	__stack_chk_fail@PLT
.L30:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2059:
	.size	_Z51__device_stub__Z8pdh_privP10hist_entryP8atomdescdiiP10hist_entryP8atomdescdii, .-_Z51__device_stub__Z8pdh_privP10hist_entryP8atomdescdiiP10hist_entryP8atomdescdii
	.globl	_Z8pdh_privP10hist_entryP8atomdescdii
	.type	_Z8pdh_privP10hist_entryP8atomdescdii, @function
_Z8pdh_privP10hist_entryP8atomdescdii:
.LFB2060:
	.cfi_startproc
	endbr64
	jmp	_Z51__device_stub__Z8pdh_privP10hist_entryP8atomdescdiiP10hist_entryP8atomdescdii
	.cfi_endproc
.LFE2060:
	.size	_Z8pdh_privP10hist_entryP8atomdescdii, .-_Z8pdh_privP10hist_entryP8atomdescdii
	.section	.rodata.str1.1
.LC5:
	.string	"Parameters are %d, %.2f, %d"
.LC7:
	.string	"Too Few Arguments to Function, required 3 only recieved %d\n\n"
.LC10:
	.string	"Allocate Memory for Histogram"
.LC11:
	.string	"Allocate Memory for Atom List"
.LC12:
	.string	"Copying Histogram to Device"
.LC13:
	.string	"Copying Atom list to Device"
.LC14:
	.string	" Move Histogram back to Host"
.LC15:
	.string	"\n\n******* Total Running Time of Kernal = %.5f milliseconds *******\n\n"
.LC16:
	.string	"Free Device Histogram"
.LC17:
	.string	"Free Device Atom List"
.LC18:
	.string	"Reset"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2030:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$88, %rsp
	.cfi_def_cfa_offset 128
	movq	%fs:40, %rax
	movq	%rax, 72(%rsp)
	xorl	%eax, %eax
	cmpl	$4, %edi
	jne	.L34
	movq	8(%rsi), %rdi
	movq	%rsi, %rbx
	call	atoi@PLT
	movq	16(%rbx), %rdi
	movslq	%eax, %rbp
	movq	%rbp, PDH_acnt(%rip)
	call	atof@PLT
	movq	24(%rbx), %rdi
	movsd	%xmm0, PDH_res(%rip)
	movsd	%xmm0, 8(%rsp)
	call	atoi@PLT
	movsd	8(%rsp), %xmm0
	movq	%rbp, %rdx
	leaq	.LC5(%rip), %rsi
	movl	%eax, %ecx
	movl	%eax, BlockSize(%rip)
	movl	$2, %edi
	movb	$1, %al
	call	__printf_chk@PLT
	movsd	.LC6(%rip), %xmm0
	divsd	PDH_res(%rip), %xmm0
	cvttsd2sil	%xmm0, %ebx
	imulq	$24, PDH_acnt(%rip), %r12
	xorl	%ebp, %ebp
	incl	%ebx
	movl	%ebx, num_buckets(%rip)
	movslq	%ebx, %rbx
	salq	$3, %rbx
	movq	%rbx, %rdi
	call	malloc@PLT
	movq	%r12, %rdi
	movq	%rax, histogram(%rip)
	call	malloc@PLT
	movl	$1, %edi
	movq	%rax, atom_list(%rip)
	call	srand@PLT
	jmp	.L35
.L34:
	leal	-1(%rdi), %edx
	leaq	.LC7(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	$1, %edi
	call	exit@PLT
.L35:
	cmpq	%rbp, PDH_acnt(%rip)
	jle	.L40
	call	rand@PLT
	imulq	$24, %rbp, %r13
	incq	%rbp
	cvtsi2sdl	%eax, %xmm0
	divsd	.LC8(%rip), %xmm0
	mulsd	.LC9(%rip), %xmm0
	movq	atom_list(%rip), %rax
	movsd	%xmm0, (%rax,%r13)
	call	rand@PLT
	cvtsi2sdl	%eax, %xmm0
	divsd	.LC8(%rip), %xmm0
	mulsd	.LC9(%rip), %xmm0
	movq	atom_list(%rip), %rax
	movsd	%xmm0, 8(%rax,%r13)
	call	rand@PLT
	cvtsi2sdl	%eax, %xmm0
	divsd	.LC8(%rip), %xmm0
	mulsd	.LC9(%rip), %xmm0
	movq	atom_list(%rip), %rax
	movsd	%xmm0, 16(%rax,%r13)
	jmp	.L35
.L40:
	xorl	%eax, %eax
	leaq	16(%rsp), %rdi
	movq	%rbx, %rsi
	movq	%rax, 16(%rsp)
	movq	%rax, 24(%rsp)
	call	cudaMalloc@PLT
	leaq	.LC10(%rip), %rsi
	movl	%eax, %edi
	call	_Z10ErrorCheck9cudaErrorPKc
	leaq	24(%rsp), %rdi
	movq	%r12, %rsi
	call	cudaMalloc@PLT
	leaq	.LC11(%rip), %rsi
	movl	%eax, %edi
	call	_Z10ErrorCheck9cudaErrorPKc
	movq	histogram(%rip), %rsi
	movq	16(%rsp), %rdi
	movq	%rbx, %rdx
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	leaq	.LC12(%rip), %rsi
	movl	%eax, %edi
	call	_Z10ErrorCheck9cudaErrorPKc
	movq	atom_list(%rip), %rsi
	movq	24(%rsp), %rdi
	movq	%r12, %rdx
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	leaq	.LC13(%rip), %rsi
	movl	%eax, %edi
	call	_Z10ErrorCheck9cudaErrorPKc
	leaq	32(%rsp), %rdi
	call	cudaEventCreate@PLT
	leaq	40(%rsp), %rdi
	call	cudaEventCreate@PLT
	movq	32(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	PDH_acnt(%rip), %rax
	movslq	BlockSize(%rip), %rsi
	xorl	%r9d, %r9d
	movabsq	$4294967297, %rcx
	cqto
	movq	%rsi, %r8
	movq	%rcx, 52(%rsp)
	idivq	%rsi
	movl	%esi, 60(%rsp)
	movl	56(%rsp), %esi
	movq	%rcx, 64(%rsp)
	movl	68(%rsp), %ecx
	movq	60(%rsp), %rdx
	addl	%r8d, %r8d
	movslq	%r8d, %r8
	imulq	$24, %r8, %r8
	cvtsi2sdq	%rax, %xmm0
	cvttsd2siq	%xmm0, %rax
	movl	%eax, 48(%rsp)
	movq	48(%rsp), %rdi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L37
	movl	BlockSize(%rip), %ecx
	movl	PDH_acnt(%rip), %edx
	movsd	PDH_res(%rip), %xmm0
	movq	24(%rsp), %rsi
	movq	16(%rsp), %rdi
	call	_Z51__device_stub__Z8pdh_privP10hist_entryP8atomdescdiiP10hist_entryP8atomdescdii
.L37:
	movq	40(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	40(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movq	40(%rsp), %rdx
	movq	32(%rsp), %rsi
	leaq	60(%rsp), %rdi
	call	cudaEventElapsedTime@PLT
	movq	32(%rsp), %rdi
	call	cudaEventDestroy@PLT
	movq	40(%rsp), %rdi
	call	cudaEventDestroy@PLT
	movq	16(%rsp), %rsi
	movl	$2, %ecx
	movq	%rbx, %rdx
	movq	histogram(%rip), %rdi
	call	cudaMemcpy@PLT
	leaq	.LC14(%rip), %rsi
	movl	%eax, %edi
	call	_Z10ErrorCheck9cudaErrorPKc
	movq	histogram(%rip), %rdi
	call	_Z16output_histogramP10hist_entry
	leaq	.LC15(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	cvtss2sd	60(%rsp), %xmm0
	call	__printf_chk@PLT
	movq	16(%rsp), %rdi
	call	cudaFree@PLT
	leaq	.LC16(%rip), %rsi
	movl	%eax, %edi
	call	_Z10ErrorCheck9cudaErrorPKc
	movq	24(%rsp), %rdi
	call	cudaFree@PLT
	leaq	.LC17(%rip), %rsi
	movl	%eax, %edi
	call	_Z10ErrorCheck9cudaErrorPKc
	call	cudaDeviceReset@PLT
	leaq	.LC18(%rip), %rsi
	movl	%eax, %edi
	call	_Z10ErrorCheck9cudaErrorPKc
	movq	histogram(%rip), %rdi
	call	free@PLT
	movq	atom_list(%rip), %rdi
	call	free@PLT
	movq	72(%rsp), %rax
	subq	%fs:40, %rax
	je	.L38
	call	__stack_chk_fail@PLT
.L38:
	addq	$88, %rsp
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2030:
	.size	main, .-main
	.section	.rodata.str1.1
.LC19:
	.string	"_Z8pdh_privP10hist_entryP8atomdescdii"
.LC20:
	.string	"_Z8pdh_coalP10hist_entryP8atomdescdi"
.LC21:
	.string	"_Z12PDH_baselineP10hist_entryP8atomdescdi"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2062:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -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	.LC19(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z8pdh_privP10hist_entryP8atomdescdii(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 48
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r9d, %r9d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC20(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z8pdh_coalP10hist_entryP8atomdescdi(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 40
	pushq	$0
	.cfi_def_cfa_offset 48
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r9d, %r9d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC21(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z12PDH_baselineP10hist_entryP8atomdescdi(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 40
	pushq	$0
	.cfi_def_cfa_offset 48
	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	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE2062:
	.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	endTime
	.bss
	.align 16
	.type	endTime, @object
	.size	endTime, 16
endTime:
	.zero	16
	.globl	startTime
	.align 16
	.type	startTime, @object
	.size	startTime, 16
startTime:
	.zero	16
	.globl	Idunno
	.align 8
	.type	Idunno, @object
	.size	Idunno, 8
Idunno:
	.zero	8
	.globl	BlockSize
	.align 4
	.type	BlockSize, @object
	.size	BlockSize, 4
BlockSize:
	.zero	4
	.globl	atom_list
	.align 8
	.type	atom_list, @object
	.size	atom_list, 8
atom_list:
	.zero	8
	.globl	PDH_res
	.align 8
	.type	PDH_res, @object
	.size	PDH_res, 8
PDH_res:
	.zero	8
	.globl	num_buckets
	.align 4
	.type	num_buckets, @object
	.size	num_buckets, 4
num_buckets:
	.zero	4
	.globl	PDH_acnt
	.align 8
	.type	PDH_acnt, @object
	.size	PDH_acnt, 8
PDH_acnt:
	.zero	8
	.globl	histogram
	.align 8
	.type	histogram, @object
	.size	histogram, 8
histogram:
	.zero	8
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC6:
	.long	0
	.long	1088648064
	.align 8
.LC8:
	.long	-4194304
	.long	1105199103
	.align 8
.LC9:
	.long	0
	.long	1087796736
	.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:

/* ==================================================================
	Programmer: Yicheng Tu (ytu@cse.usf.edu)
	The basic SDH algorithm implementation for 3D data
	To compile: nvcc SDH.c -o SDH in the rc machines

	
   ==================================================================




	Steven Faulkner
	U9616-1844
	Summer 2018




*/

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <sys/time.h>
#include <hip/hip_runtime.h>

#define BOX_SIZE	23000 /* size of the data box on one dimension            */

/* descriptors for single atom in the tree */
typedef struct atomdesc {
	double x_pos;
	double y_pos;
	double z_pos;
} atom;

typedef struct hist_entry{
	//float min;
	//float max;
	unsigned long long d_cnt;   /* need a long long type as the count might be huge */
} bucket;


bucket * histogram;		/* list of all buckets in the histogram     */
long long	PDH_acnt;	/* total number of data points              */
int num_buckets;		/* total number of buckets in the histogram */
double   PDH_res;		/* value of width                           */
atom * atom_list;		/* list of all data points                  */
int BlockSize;


struct timezone Idunno;
struct timeval startTime, endTime;



void ErrorCheck( hipError_t err, const char op[])
	{
		if( err != hipSuccess ) 
			{ 
				printf("CUDA Error: %s, %s ", op, hipGetErrorString(err));
				exit(EXIT_FAILURE);
			}
	}
/* 
	distance of two points in the atom_list 
*/

__device__ double 
p2p_distance(atom A, atom B)
{
	double x1 = A.x_pos;
	double x2 = B.x_pos;

	double y1 = A.y_pos;
	double y2 = B.y_pos;

	double z1 = A.z_pos;
	double z2 = B.z_pos;

	return  sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) + (z1-z2)*(z1-z2));

	
}
__global__ void
PDH_baseline(bucket *histo_in, atom *list, double width, int size)
{
	

	int i = blockIdx.x * blockDim.x + threadIdx.x;
	for(int x = i+1; x < size; ++x)
	{
		//double distance = p2p_distance(list,i,x);
//		int pos = (int) (distance/width);
		__syncthreads();
//		histo_in[pos].d_cnt++;
		__syncthreads();
	}
}
__global__ void
pdh_coal(bucket * histogram, atom * list, double width, int size)
{
	int i = threadIdx.x + blockIdx.x * blockDim.x;
	int stride = blockDim.x * gridDim.x;




	while(i < size-1){
		
		for(int j = i+1; j < stride;++j){
//			double distance = p2p_distance(list,i,j);
//			int pos = (int) (distance/width);
//			atomicAdd(&histogram[pos].d_cnt,1);
			
		}
		i+=stride;
		
	}

}
__global__ void
pdh_priv(bucket * histogram,atom * list, double width, int size, int BlockSize)
{
	int t = threadIdx.x;
	int b = blockIdx.x;
	unsigned int reg = t + b * blockDim.x;
	extern __shared__ atom smem[];

	atom * private_atom = &smem[0];
	atom * localBlock = &smem[sizeof(private_atom)];	
	if(t < BlockSize)	
		private_atom[t] = list[reg];
		
	__syncthreads();
		
	//iterate over each block
	for(int i = b + 1; i < size/BlockSize; ++i)
	{
		
		unsigned int tempIdx = t + i * blockDim.x;
	
		if(tempIdx < BlockSize)	
			localBlock[t+ sizeof(private_atom)] = list[tempIdx];
				
		__syncthreads();
	

		//iterate through each thread within each block;
		for(int j =0; j < BlockSize;++j)
		{	
			double distance = p2p_distance(private_atom[t], localBlock[j]);
			int pos = (int) (distance/width);
			atomicAdd(&histogram[pos].d_cnt,1);
		}
		
	}
	
	for(int i = t+1;i < BlockSize;++i)
	{
		double distance = p2p_distance(private_atom[t],private_atom[i]);
		int pos = (int) (distance/width);
		atomicAdd( &histogram[pos].d_cnt,1);
	} 

}
void output_histogram(bucket *histogram){
	int i; 
	long long total_cnt = 0;
	for(i=0; i< num_buckets; i++) {
		if(i%5 == 0) /* we print 5 buckets in a row */
			printf("\n%02d: ", i);
		printf("%15lld ", histogram[i].d_cnt);
		total_cnt += histogram[i].d_cnt;
		
	  	/* we also want to make sure the total distance count is correct */
		if(i == num_buckets - 1)	
			printf("|\n T: %lld \n ", total_cnt);
		else printf("| ");
	}
}

int main(int argc, char **argv)
{
	int i;

	if(argc == 4){

	PDH_acnt = atoi(argv[1]);
	PDH_res	 = atof(argv[2]);
	BlockSize = atoi(argv[3]);
	printf("Parameters are %d, %.2f, %d", PDH_acnt,PDH_res,BlockSize);
	
	}
	
	else{

	int count = argc -1;		
	printf("Too Few Arguments to Function, required 3 only recieved %d\n\n", count);
	exit(EXIT_FAILURE);
	}

	num_buckets = (int)(BOX_SIZE * 1.732 / PDH_res) + 1;
	size_t hist_size = sizeof(bucket)*num_buckets;
	size_t atom_size = sizeof(atom)*PDH_acnt;



	histogram = (bucket *)malloc(sizeof(bucket)*num_buckets);
	atom_list = (atom *)malloc(sizeof(atom)*PDH_acnt);	
	srand(1);
	/* generate data following a uniform distribution */
	for(i = 0;  i < PDH_acnt; i++) {
		atom_list[i].x_pos = ((double)(rand()) / RAND_MAX) * BOX_SIZE;
		atom_list[i].y_pos = ((double)(rand()) / RAND_MAX) * BOX_SIZE;
		atom_list[i].z_pos = ((double)(rand()) / RAND_MAX) * BOX_SIZE;
	}
	
	
	bucket *dev_Histo = NULL;
	atom *dev_atomL = NULL;

	ErrorCheck(hipMalloc((void**) &dev_Histo,hist_size), "Allocate Memory for Histogram");
	ErrorCheck(hipMalloc((void**) &dev_atomL, atom_size), "Allocate Memory for Atom List");
	ErrorCheck(hipMemcpy(dev_Histo,histogram,hist_size, hipMemcpyHostToDevice), "Copying Histogram to Device");
	ErrorCheck(hipMemcpy(dev_atomL, atom_list, atom_size, hipMemcpyHostToDevice), "Copying Atom list to Device");
	
	hipEvent_t start,stop;
	hipEventCreate(&start);
	hipEventCreate(&stop);
	hipEventRecord(start,0);


//	PDH_baseline <<<ceil(PDH_acnt/32), 32 >>> (dev_Histo, dev_atomL, PDH_res, PDH_acnt);

	pdh_priv <<<ceil(PDH_acnt/BlockSize),BlockSize,2 *  BlockSize*sizeof(atom) >>>(dev_Histo, dev_atomL,PDH_res,PDH_acnt,BlockSize);
	

	hipEventRecord(stop,0);
	hipEventSynchronize(stop);
	float elapsedTime;
	hipEventElapsedTime(&elapsedTime,start,stop);
	hipEventDestroy(start);
	hipEventDestroy(stop);

	ErrorCheck(hipMemcpy(histogram, dev_Histo, hist_size, hipMemcpyDeviceToHost), " Move Histogram back to Host");
		
	/* print out the histogram */
	output_histogram(histogram);

	//elapsedTime = elapsedTime / 1000;
	printf("\n\n******* Total Running Time of Kernal = %.5f milliseconds *******\n\n", elapsedTime);
	

	ErrorCheck(hipFree(dev_Histo), "Free Device Histogram");
	ErrorCheck(hipFree(dev_atomL), "Free Device Atom List");


	ErrorCheck(hipDeviceReset(), "Reset");
	
	free(histogram);
	free(atom_list);
	
	return 0;
}



	.text
	.file	"proj2.hip"
	.globl	_Z10ErrorCheck10hipError_tPKc   # -- Begin function _Z10ErrorCheck10hipError_tPKc
	.type	_Z10ErrorCheck10hipError_tPKc,@function
_Z10ErrorCheck10hipError_tPKc:          # @_Z10ErrorCheck10hipError_tPKc
	.cfi_startproc
# %bb.0:
	testl	%edi, %edi
	jne	.LBB0_2
# %bb.1:
	retq
.LBB0_2:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset %rbx, -16
	movq	%rsi, %rbx
	callq	hipGetErrorString
	movl	$.L.str, %edi
	movq	%rbx, %rsi
	movq	%rax, %rdx
	xorl	%eax, %eax
	callq	printf
	movl	$1, %edi
	callq	exit
.Lfunc_end0:
	.size	_Z10ErrorCheck10hipError_tPKc, .Lfunc_end0-_Z10ErrorCheck10hipError_tPKc
	.cfi_endproc
                                        # -- End function
	.globl	_Z27__device_stub__PDH_baselineP10hist_entryP8atomdescdi # -- Begin function _Z27__device_stub__PDH_baselineP10hist_entryP8atomdescdi
	.type	_Z27__device_stub__PDH_baselineP10hist_entryP8atomdescdi,@function
_Z27__device_stub__PDH_baselineP10hist_entryP8atomdescdi: # @_Z27__device_stub__PDH_baselineP10hist_entryP8atomdescdi
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$112, %rsp
	.cfi_def_cfa_offset 160
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	32(%rsp), %rcx
	movq	%rsi, (%rcx)
	leaq	24(%rsp), %rsi
	movsd	%xmm0, (%rsi)
	leaq	4(%rsp), %rdi
	movl	%edx, (%rdi)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdi, 24(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	16(%rsp), %r12
	leaq	8(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z12PDH_baselineP10hist_entryP8atomdescdi, %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_end1:
	.size	_Z27__device_stub__PDH_baselineP10hist_entryP8atomdescdi, .Lfunc_end1-_Z27__device_stub__PDH_baselineP10hist_entryP8atomdescdi
	.cfi_endproc
                                        # -- End function
	.globl	_Z23__device_stub__pdh_coalP10hist_entryP8atomdescdi # -- Begin function _Z23__device_stub__pdh_coalP10hist_entryP8atomdescdi
	.type	_Z23__device_stub__pdh_coalP10hist_entryP8atomdescdi,@function
_Z23__device_stub__pdh_coalP10hist_entryP8atomdescdi: # @_Z23__device_stub__pdh_coalP10hist_entryP8atomdescdi
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$112, %rsp
	.cfi_def_cfa_offset 160
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	32(%rsp), %rcx
	movq	%rsi, (%rcx)
	leaq	24(%rsp), %rsi
	movsd	%xmm0, (%rsi)
	leaq	4(%rsp), %rdi
	movl	%edx, (%rdi)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdi, 24(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	16(%rsp), %r12
	leaq	8(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z8pdh_coalP10hist_entryP8atomdescdi, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$128, %rsp
	.cfi_adjust_cfa_offset -128
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end2:
	.size	_Z23__device_stub__pdh_coalP10hist_entryP8atomdescdi, .Lfunc_end2-_Z23__device_stub__pdh_coalP10hist_entryP8atomdescdi
	.cfi_endproc
                                        # -- End function
	.globl	_Z23__device_stub__pdh_privP10hist_entryP8atomdescdii # -- Begin function _Z23__device_stub__pdh_privP10hist_entryP8atomdescdii
	.type	_Z23__device_stub__pdh_privP10hist_entryP8atomdescdii,@function
_Z23__device_stub__pdh_privP10hist_entryP8atomdescdii: # @_Z23__device_stub__pdh_privP10hist_entryP8atomdescdii
	.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	24(%rsp), %rsi
	movsd	%xmm0, (%rsi)
	leaq	4(%rsp), %r8
	movl	%edx, (%r8)
	movq	%rsp, %rdx
	movl	%ecx, (%rdx)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%r8, 24(%rbx)
	movq	%rdx, 32(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	16(%rsp), %r12
	leaq	8(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z8pdh_privP10hist_entryP8atomdescdii, %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_end3:
	.size	_Z23__device_stub__pdh_privP10hist_entryP8atomdescdii, .Lfunc_end3-_Z23__device_stub__pdh_privP10hist_entryP8atomdescdii
	.cfi_endproc
                                        # -- End function
	.globl	_Z16output_histogramP10hist_entry # -- Begin function _Z16output_histogramP10hist_entry
	.type	_Z16output_histogramP10hist_entry,@function
_Z16output_histogramP10hist_entry:      # @_Z16output_histogramP10hist_entry
	.cfi_startproc
# %bb.0:
	cmpl	$0, num_buckets(%rip)
	jle	.LBB4_9
# %bb.1:                                # %.lr.ph.preheader
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r12
	.cfi_def_cfa_offset 32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	pushq	%rax
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -40
	.cfi_offset %r12, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rdi, %rbx
	movl	$3435973837, %r12d              # imm = 0xCCCCCCCD
	xorl	%r14d, %r14d
	xorl	%r15d, %r15d
.LBB4_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movl	%r14d, %eax
	imulq	%r12, %rax
	shrq	$34, %rax
	leal	(%rax,%rax,4), %eax
	cmpl	%eax, %r14d
	jne	.LBB4_4
# %bb.3:                                #   in Loop: Header=BB4_2 Depth=1
	movl	$.L.str.1, %edi
	movl	%r14d, %esi
	xorl	%eax, %eax
	callq	printf
.LBB4_4:                                #   in Loop: Header=BB4_2 Depth=1
	movq	(%rbx,%r14,8), %rsi
	movl	$.L.str.2, %edi
	xorl	%eax, %eax
	callq	printf
	addq	(%rbx,%r14,8), %r15
	movl	num_buckets(%rip), %eax
	decl	%eax
	cmpq	%rax, %r14
	jne	.LBB4_6
# %bb.5:                                #   in Loop: Header=BB4_2 Depth=1
	movl	$.L.str.3, %edi
	movq	%r15, %rsi
	xorl	%eax, %eax
	callq	printf
	jmp	.LBB4_7
.LBB4_6:                                #   in Loop: Header=BB4_2 Depth=1
	movl	$.L.str.4, %edi
	xorl	%eax, %eax
	callq	printf
.LBB4_7:                                #   in Loop: Header=BB4_2 Depth=1
	incq	%r14
	movslq	num_buckets(%rip), %rax
	cmpq	%rax, %r14
	jl	.LBB4_2
# %bb.8:
	addq	$8, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	.cfi_restore %rbx
	.cfi_restore %r12
	.cfi_restore %r14
	.cfi_restore %r15
.LBB4_9:                                # %._crit_edge
	retq
.Lfunc_end4:
	.size	_Z16output_histogramP10hist_entry, .Lfunc_end4-_Z16output_histogramP10hist_entry
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI5_0:
	.quad	0x40e3738000000000              # double 39836
.LCPI5_1:
	.quad	0x41dfffffffc00000              # double 2147483647
.LCPI5_2:
	.quad	0x40d6760000000000              # double 23000
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r12
	.cfi_def_cfa_offset 32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	subq	$56, %rsp
	.cfi_def_cfa_offset 96
	.cfi_offset %rbx, -40
	.cfi_offset %r12, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	cmpl	$4, %edi
	jne	.LBB5_7
# %bb.1:
	movq	%rsi, %rbx
	movq	8(%rsi), %rdi
	callq	atoi
	movslq	%eax, %r14
	movq	%r14, PDH_acnt(%rip)
	movq	16(%rbx), %rdi
	callq	atof
	movsd	%xmm0, 40(%rsp)                 # 8-byte Spill
	movsd	%xmm0, PDH_res(%rip)
	movq	24(%rbx), %rdi
	callq	atoi
	movl	%eax, BlockSize(%rip)
	movl	$.L.str.5, %edi
	movq	%r14, %rsi
	movsd	40(%rsp), %xmm0                 # 8-byte Reload
                                        # xmm0 = mem[0],zero
	movl	%eax, %edx
	movb	$1, %al
	callq	printf
	movsd	.LCPI5_0(%rip), %xmm0           # xmm0 = mem[0],zero
	divsd	PDH_res(%rip), %xmm0
	cvttsd2si	%xmm0, %eax
	leal	1(%rax), %ecx
	movl	%ecx, num_buckets(%rip)
	cltq
	leaq	8(,%rax,8), %rbx
	movq	PDH_acnt(%rip), %rax
	shlq	$3, %rax
	leaq	(%rax,%rax,2), %r14
	movq	%rbx, %rdi
	callq	malloc
	movq	%rax, histogram(%rip)
	movq	%r14, %rdi
	callq	malloc
	movq	%rax, atom_list(%rip)
	movl	$1, %edi
	callq	srand
	cmpq	$0, PDH_acnt(%rip)
	jle	.LBB5_4
# %bb.2:                                # %.lr.ph.preheader
	xorl	%r15d, %r15d
	xorl	%r12d, %r12d
.LBB5_3:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	callq	rand
	xorps	%xmm0, %xmm0
	cvtsi2sd	%eax, %xmm0
	movsd	.LCPI5_1(%rip), %xmm1           # xmm1 = mem[0],zero
	divsd	%xmm1, %xmm0
	movsd	.LCPI5_2(%rip), %xmm1           # xmm1 = mem[0],zero
	mulsd	%xmm1, %xmm0
	movq	atom_list(%rip), %rax
	movsd	%xmm0, (%rax,%r15)
	callq	rand
	xorps	%xmm0, %xmm0
	cvtsi2sd	%eax, %xmm0
	divsd	.LCPI5_1(%rip), %xmm0
	mulsd	.LCPI5_2(%rip), %xmm0
	movq	atom_list(%rip), %rax
	movsd	%xmm0, 8(%rax,%r15)
	callq	rand
	xorps	%xmm0, %xmm0
	cvtsi2sd	%eax, %xmm0
	divsd	.LCPI5_1(%rip), %xmm0
	mulsd	.LCPI5_2(%rip), %xmm0
	movq	atom_list(%rip), %rax
	movsd	%xmm0, 16(%rax,%r15)
	incq	%r12
	addq	$24, %r15
	cmpq	%r12, PDH_acnt(%rip)
	jg	.LBB5_3
.LBB5_4:                                # %._crit_edge
	xorl	%eax, %eax
	leaq	16(%rsp), %r12
	movq	%rax, (%r12)
	leaq	32(%rsp), %r15
	movq	%rax, (%r15)
	movq	%r12, %rdi
	movq	%rbx, %rsi
	callq	hipMalloc
	movl	$.L.str.7, %esi
	movl	%eax, %edi
	callq	_Z10ErrorCheck10hipError_tPKc
	movq	%r15, %rdi
	movq	%r14, %rsi
	callq	hipMalloc
	movl	$.L.str.8, %esi
	movl	%eax, %edi
	callq	_Z10ErrorCheck10hipError_tPKc
	movq	(%r12), %rdi
	movq	histogram(%rip), %rsi
	movq	%rbx, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movl	$.L.str.9, %esi
	movl	%eax, %edi
	callq	_Z10ErrorCheck10hipError_tPKc
	movq	(%r15), %rdi
	movq	atom_list(%rip), %rsi
	movq	%r14, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movl	$.L.str.10, %esi
	movl	%eax, %edi
	callq	_Z10ErrorCheck10hipError_tPKc
	leaq	24(%rsp), %r14
	movq	%r14, %rdi
	callq	hipEventCreate
	leaq	8(%rsp), %rdi
	callq	hipEventCreate
	movq	(%r14), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	PDH_acnt(%rip), %rax
	movl	BlockSize(%rip), %ecx
	movslq	%ecx, %rsi
	cqto
	idivq	%rsi
	shlq	$4, %rsi
	leaq	(%rsi,%rsi,2), %r8
	movl	%eax, %edi
	btsq	$32, %rdi
	btsq	$32, %rcx
	movl	$1, %esi
	movq	%rcx, %rdx
	movl	$1, %ecx
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB5_6
# %bb.5:
	movq	16(%rsp), %rdi
	movq	32(%rsp), %rsi
	movsd	PDH_res(%rip), %xmm0            # xmm0 = mem[0],zero
	movl	PDH_acnt(%rip), %edx
	movl	BlockSize(%rip), %ecx
	callq	_Z23__device_stub__pdh_privP10hist_entryP8atomdescdii
.LBB5_6:
	movq	8(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	8(%rsp), %rdi
	callq	hipEventSynchronize
	movq	24(%rsp), %rsi
	movq	8(%rsp), %rdx
	leaq	52(%rsp), %r14
	movq	%r14, %rdi
	callq	hipEventElapsedTime
	movq	24(%rsp), %rdi
	callq	hipEventDestroy
	movq	8(%rsp), %rdi
	callq	hipEventDestroy
	movq	histogram(%rip), %rdi
	movq	16(%rsp), %rsi
	movq	%rbx, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	movl	$.L.str.11, %esi
	movl	%eax, %edi
	callq	_Z10ErrorCheck10hipError_tPKc
	movq	histogram(%rip), %rdi
	callq	_Z16output_histogramP10hist_entry
	xorps	%xmm0, %xmm0
	cvtss2sd	(%r14), %xmm0
	movl	$.L.str.12, %edi
	movb	$1, %al
	callq	printf
	movq	16(%rsp), %rdi
	callq	hipFree
	movl	$.L.str.13, %esi
	movl	%eax, %edi
	callq	_Z10ErrorCheck10hipError_tPKc
	movq	32(%rsp), %rdi
	callq	hipFree
	movl	$.L.str.14, %esi
	movl	%eax, %edi
	callq	_Z10ErrorCheck10hipError_tPKc
	callq	hipDeviceReset
	movl	$.L.str.15, %esi
	movl	%eax, %edi
	callq	_Z10ErrorCheck10hipError_tPKc
	movq	histogram(%rip), %rdi
	callq	free
	movq	atom_list(%rip), %rdi
	callq	free
	xorl	%eax, %eax
	addq	$56, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.LBB5_7:
	.cfi_def_cfa_offset 96
	movl	%edi, %esi
	decl	%esi
	movl	$.L.str.6, %edi
	xorl	%eax, %eax
	callq	printf
	movl	$1, %edi
	callq	exit
.Lfunc_end5:
	.size	main, .Lfunc_end5-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:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$32, %rsp
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -16
	movq	__hip_gpubin_handle(%rip), %rbx
	testq	%rbx, %rbx
	jne	.LBB6_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB6_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z12PDH_baselineP10hist_entryP8atomdescdi, %esi
	movl	$.L__unnamed_1, %edx
	movl	$.L__unnamed_1, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z8pdh_coalP10hist_entryP8atomdescdi, %esi
	movl	$.L__unnamed_2, %edx
	movl	$.L__unnamed_2, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z8pdh_privP10hist_entryP8atomdescdii, %esi
	movl	$.L__unnamed_3, %edx
	movl	$.L__unnamed_3, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$__hip_module_dtor, %edi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.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	histogram,@object               # @histogram
	.bss
	.globl	histogram
	.p2align	3, 0x0
histogram:
	.quad	0
	.size	histogram, 8

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

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

	.type	PDH_res,@object                 # @PDH_res
	.globl	PDH_res
	.p2align	3, 0x0
PDH_res:
	.quad	0x0000000000000000              # double 0
	.size	PDH_res, 8

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

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

	.type	Idunno,@object                  # @Idunno
	.globl	Idunno
	.p2align	2, 0x0
Idunno:
	.zero	8
	.size	Idunno, 8

	.type	startTime,@object               # @startTime
	.globl	startTime
	.p2align	3, 0x0
startTime:
	.zero	16
	.size	startTime, 16

	.type	endTime,@object                 # @endTime
	.globl	endTime
	.p2align	3, 0x0
endTime:
	.zero	16
	.size	endTime, 16

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"CUDA Error: %s, %s "
	.size	.L.str, 20

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

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

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

	.type	.L.str.1,@object                # @.str.1
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.1:
	.asciz	"\n%02d: "
	.size	.L.str.1, 8

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"%15lld "
	.size	.L.str.2, 8

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"|\n T: %lld \n "
	.size	.L.str.3, 14

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"| "
	.size	.L.str.4, 3

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"Parameters are %d, %.2f, %d"
	.size	.L.str.5, 28

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"Too Few Arguments to Function, required 3 only recieved %d\n\n"
	.size	.L.str.6, 61

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"Allocate Memory for Histogram"
	.size	.L.str.7, 30

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"Allocate Memory for Atom List"
	.size	.L.str.8, 30

	.type	.L.str.9,@object                # @.str.9
.L.str.9:
	.asciz	"Copying Histogram to Device"
	.size	.L.str.9, 28

	.type	.L.str.10,@object               # @.str.10
.L.str.10:
	.asciz	"Copying Atom list to Device"
	.size	.L.str.10, 28

	.type	.L.str.11,@object               # @.str.11
.L.str.11:
	.asciz	" Move Histogram back to Host"
	.size	.L.str.11, 29

	.type	.L.str.12,@object               # @.str.12
.L.str.12:
	.asciz	"\n\n******* Total Running Time of Kernal = %.5f milliseconds *******\n\n"
	.size	.L.str.12, 69

	.type	.L.str.13,@object               # @.str.13
.L.str.13:
	.asciz	"Free Device Histogram"
	.size	.L.str.13, 22

	.type	.L.str.14,@object               # @.str.14
.L.str.14:
	.asciz	"Free Device Atom List"
	.size	.L.str.14, 22

	.type	.L.str.15,@object               # @.str.15
.L.str.15:
	.asciz	"Reset"
	.size	.L.str.15, 6

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z12PDH_baselineP10hist_entryP8atomdescdi"
	.size	.L__unnamed_1, 42

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_Z8pdh_coalP10hist_entryP8atomdescdi"
	.size	.L__unnamed_2, 37

	.type	.L__unnamed_3,@object           # @2
.L__unnamed_3:
	.asciz	"_Z8pdh_privP10hist_entryP8atomdescdii"
	.size	.L__unnamed_3, 38

	.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 _Z27__device_stub__PDH_baselineP10hist_entryP8atomdescdi
	.addrsig_sym _Z23__device_stub__pdh_coalP10hist_entryP8atomdescdi
	.addrsig_sym _Z23__device_stub__pdh_privP10hist_entryP8atomdescdii
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z12PDH_baselineP10hist_entryP8atomdescdi
	.addrsig_sym _Z8pdh_coalP10hist_entryP8atomdescdi
	.addrsig_sym _Z8pdh_privP10hist_entryP8atomdescdii
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z12PDH_baselineP10hist_entryP8atomdescdi ; -- Begin function _Z12PDH_baselineP10hist_entryP8atomdescdi
	.globl	_Z12PDH_baselineP10hist_entryP8atomdescdi
	.p2align	8
	.type	_Z12PDH_baselineP10hist_entryP8atomdescdi,@function
_Z12PDH_baselineP10hist_entryP8atomdescdi: ; @_Z12PDH_baselineP10hist_entryP8atomdescdi
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x2c
	s_load_b32 s0, s[0:1], 0x18
	s_waitcnt lgkmcnt(0)
	s_and_b32 s1, s2, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	s_mul_i32 s15, s15, s1
	s_mov_b32 s1, exec_lo
	v_add3_u32 v0, s15, v0, 1
	v_cmpx_gt_i32_e64 s0, v0
	s_cbranch_execz .LBB0_3
; %bb.1:                                ; %.lr.ph.preheader
	s_mov_b32 s1, 0
.LBB0_2:                                ; %.lr.ph
                                        ; =>This Inner Loop Header: Depth=1
	v_add_nc_u32_e32 v0, 1, v0
	s_barrier
	buffer_gl0_inv
	v_cmp_le_i32_e32 vcc_lo, s0, v0
	s_barrier
	buffer_gl0_inv
	s_or_b32 s1, vcc_lo, s1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_not1_b32 exec_lo, exec_lo, s1
	s_cbranch_execnz .LBB0_2
.LBB0_3:                                ; %Flow7
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z12PDH_baselineP10hist_entryP8atomdescdi
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 288
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 1
		.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	_Z12PDH_baselineP10hist_entryP8atomdescdi, .Lfunc_end0-_Z12PDH_baselineP10hist_entryP8atomdescdi
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 120
; NumSgprs: 18
; NumVgprs: 1
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 1
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.protected	_Z8pdh_coalP10hist_entryP8atomdescdi ; -- Begin function _Z8pdh_coalP10hist_entryP8atomdescdi
	.globl	_Z8pdh_coalP10hist_entryP8atomdescdi
	.p2align	8
	.type	_Z8pdh_coalP10hist_entryP8atomdescdi,@function
_Z8pdh_coalP10hist_entryP8atomdescdi:   ; @_Z8pdh_coalP10hist_entryP8atomdescdi
; %bb.0:                                ; %._crit_edge
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z8pdh_coalP10hist_entryP8atomdescdi
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 28
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 1
		.amdhsa_next_free_sgpr 1
		.amdhsa_reserve_vcc 0
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end1:
	.size	_Z8pdh_coalP10hist_entryP8atomdescdi, .Lfunc_end1-_Z8pdh_coalP10hist_entryP8atomdescdi
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 4
; NumSgprs: 0
; NumVgprs: 0
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 0
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 1
; NumVGPRsForWavesPerEU: 1
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.protected	_Z8pdh_privP10hist_entryP8atomdescdii ; -- Begin function _Z8pdh_privP10hist_entryP8atomdescdii
	.globl	_Z8pdh_privP10hist_entryP8atomdescdii
	.p2align	8
	.type	_Z8pdh_privP10hist_entryP8atomdescdii,@function
_Z8pdh_privP10hist_entryP8atomdescdii:  ; @_Z8pdh_privP10hist_entryP8atomdescdii
; %bb.0:
	s_clause 0x1
	s_load_b256 s[4:11], s[0:1], 0x0
	s_load_b32 s0, s[0:1], 0x2c
	s_mov_b32 s1, exec_lo
	s_waitcnt lgkmcnt(0)
	s_and_b32 s0, s0, 0xffff
	v_cmpx_gt_i32_e64 s11, v0
	s_cbranch_execz .LBB2_2
; %bb.1:
	v_mad_u64_u32 v[1:2], null, s15, s0, v[0:1]
	v_mad_u32_u24 v9, v0, 24, 0
	s_delay_alu instid0(VALU_DEP_2)
	v_mad_u64_u32 v[5:6], null, v1, 24, s[6:7]
	s_clause 0x1
	global_load_b128 v[1:4], v[5:6], off offset:8
	global_load_b128 v[5:8], v[5:6], off
	s_waitcnt vmcnt(1)
	ds_store_2addr_b64 v9, v[1:2], v[3:4] offset0:1 offset1:2
	s_waitcnt vmcnt(0)
	ds_store_2addr_b64 v9, v[5:6], v[7:8] offset1:1
.LBB2_2:
	s_or_b32 exec_lo, exec_lo, s1
	s_ashr_i32 s1, s11, 31
	s_ashr_i32 s13, s10, 31
	s_add_i32 s2, s11, s1
	s_add_i32 s10, s10, s13
	s_xor_b32 s2, s2, s1
	s_xor_b32 s10, s10, s13
	v_cvt_f32_u32_e32 v1, s2
	s_sub_i32 s12, 0, s2
	s_xor_b32 s1, s13, s1
	s_waitcnt lgkmcnt(0)
	s_barrier
	v_rcp_iflag_f32_e32 v1, v1
	buffer_gl0_inv
	v_mul_f32_e32 v1, 0x4f7ffffe, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cvt_u32_f32_e32 v1, v1
	v_readfirstlane_b32 s3, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_mul_i32 s12, s12, s3
	s_mul_hi_u32 s12, s3, s12
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_add_i32 s3, s3, s12
	s_mul_hi_u32 s3, s10, s3
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_mul_i32 s12, s3, s2
	s_sub_i32 s10, s10, s12
	s_add_i32 s12, s3, 1
	s_sub_i32 s13, s10, s2
	s_cmp_ge_u32 s10, s2
	s_cselect_b32 s3, s12, s3
	s_cselect_b32 s10, s13, s10
	s_add_i32 s12, s3, 1
	s_cmp_ge_u32 s10, s2
	s_cselect_b32 s2, s12, s3
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_xor_b32 s2, s2, s1
	s_sub_i32 s1, s2, s1
	s_add_i32 s2, s15, 1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_cmp_ge_i32 s2, s1
	s_cbranch_scc1 .LBB2_10
; %bb.3:                                ; %.lr.ph61
	v_mad_u32_u24 v7, v0, 24, 0
	s_cmp_gt_i32 s11, 0
	s_cselect_b32 s3, -1, 0
	s_add_i32 s10, 0, 0xc0
	s_delay_alu instid0(VALU_DEP_1)
	v_add_nc_u32_e32 v8, 0x180, v7
.LBB2_4:                                ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB2_8 Depth 2
	v_mad_u64_u32 v[1:2], null, s2, s0, v[0:1]
	s_mov_b32 s12, exec_lo
	s_delay_alu instid0(VALU_DEP_1)
	v_cmpx_gt_u32_e64 s11, v1
	s_cbranch_execz .LBB2_6
; %bb.5:                                ;   in Loop: Header=BB2_4 Depth=1
	v_mad_u64_u32 v[5:6], null, v1, 24, s[6:7]
	s_clause 0x1
	global_load_b128 v[1:4], v[5:6], off offset:8
	global_load_b128 v[9:12], v[5:6], off
	s_waitcnt vmcnt(1)
	ds_store_2addr_b64 v8, v[1:2], v[3:4] offset0:1 offset1:2
	s_waitcnt vmcnt(0)
	ds_store_2addr_b64 v8, v[9:10], v[11:12] offset1:1
.LBB2_6:                                ;   in Loop: Header=BB2_4 Depth=1
	s_or_b32 exec_lo, exec_lo, s12
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_not1_b32 vcc_lo, exec_lo, s3
	s_waitcnt lgkmcnt(0)
	s_waitcnt_vscnt null, 0x0
	s_barrier
	buffer_gl0_inv
	s_cbranch_vccnz .LBB2_9
; %bb.7:                                ; %.lr.ph
                                        ;   in Loop: Header=BB2_4 Depth=1
	ds_load_2addr_b64 v[1:4], v7 offset1:1
	ds_load_b64 v[5:6], v7 offset:16
	s_mov_b32 s12, s11
	s_mov_b32 s13, s10
.LBB2_8:                                ;   Parent Loop BB2_4 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	s_delay_alu instid0(SALU_CYCLE_1)
	v_mov_b32_e32 v13, s13
	s_add_i32 s12, s12, -1
	s_add_i32 s13, s13, 24
	s_cmp_eq_u32 s12, 0
	ds_load_2addr_b64 v[9:12], v13 offset1:1
	ds_load_b64 v[13:14], v13 offset:16
	s_waitcnt lgkmcnt(1)
	v_add_f64 v[11:12], v[3:4], -v[11:12]
	v_add_f64 v[9:10], v[1:2], -v[9:10]
	s_waitcnt lgkmcnt(0)
	v_add_f64 v[13:14], v[5:6], -v[13:14]
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_f64 v[11:12], v[11:12], v[11:12]
	v_fma_f64 v[9:10], v[9:10], v[9:10], v[11:12]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[9:10], v[13:14], v[13:14], v[9:10]
	v_cmp_gt_f64_e32 vcc_lo, 0x10000000, v[9:10]
	v_cndmask_b32_e64 v11, 0, 1, vcc_lo
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b32_e32 v11, 8, v11
	v_ldexp_f64 v[9:10], v[9:10], v11
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_3) | instid1(VALU_DEP_1)
	v_rsq_f64_e32 v[11:12], v[9:10]
	s_waitcnt_depctr 0xfff
	v_mul_f64 v[13:14], v[9:10], v[11:12]
	v_mul_f64 v[11:12], v[11:12], 0.5
	v_fma_f64 v[15:16], -v[11:12], v[13:14], 0.5
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_fma_f64 v[13:14], v[13:14], v[15:16], v[13:14]
	v_fma_f64 v[11:12], v[11:12], v[15:16], v[11:12]
	v_fma_f64 v[15:16], -v[13:14], v[13:14], v[9:10]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[13:14], v[15:16], v[11:12], v[13:14]
	v_fma_f64 v[15:16], -v[13:14], v[13:14], v[9:10]
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_2)
	v_fma_f64 v[11:12], v[15:16], v[11:12], v[13:14]
	v_cndmask_b32_e64 v13, 0, 0xffffff80, vcc_lo
	v_cmp_class_f64_e64 vcc_lo, v[9:10], 0x260
	v_ldexp_f64 v[11:12], v[11:12], v13
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_dual_cndmask_b32 v10, v12, v10 :: v_dual_cndmask_b32 v9, v11, v9
	v_div_scale_f64 v[11:12], null, s[8:9], s[8:9], v[9:10]
	v_div_scale_f64 v[17:18], vcc_lo, v[9:10], s[8:9], v[9:10]
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	v_rcp_f64_e32 v[13:14], v[11:12]
	s_waitcnt_depctr 0xfff
	v_fma_f64 v[15:16], -v[11:12], v[13:14], 1.0
	v_fma_f64 v[13:14], v[13:14], v[15:16], v[13:14]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[15:16], -v[11:12], v[13:14], 1.0
	v_fma_f64 v[13:14], v[13:14], v[15:16], v[13:14]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_f64 v[15:16], v[17:18], v[13:14]
	v_fma_f64 v[11:12], -v[11:12], v[15:16], v[17:18]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_div_fmas_f64 v[11:12], v[11:12], v[13:14], v[15:16]
	v_div_fixup_f64 v[9:10], v[11:12], s[8:9], v[9:10]
	v_mov_b32_e32 v11, 1
	v_mov_b32_e32 v12, 0
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cvt_i32_f64_e32 v9, v[9:10]
	v_ashrrev_i32_e32 v10, 31, v9
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[9:10], 3, v[9:10]
	v_add_co_u32 v9, vcc_lo, s4, v9
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v10, vcc_lo, s5, v10, vcc_lo
	global_atomic_add_u64 v[9:10], v[11:12], off
	s_cbranch_scc0 .LBB2_8
.LBB2_9:                                ; %.loopexit
                                        ;   in Loop: Header=BB2_4 Depth=1
	s_add_i32 s2, s2, 1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_cmp_lt_i32 s2, s1
	s_cbranch_scc1 .LBB2_4
.LBB2_10:                               ; %.preheader
	v_add_nc_u32_e32 v6, 1, v0
	s_mov_b32 s0, exec_lo
	s_delay_alu instid0(VALU_DEP_1)
	v_cmpx_gt_i32_e64 s11, v6
	s_cbranch_execz .LBB2_13
; %bb.11:                               ; %.lr.ph64
	v_mad_u32_u24 v7, v0, 24, 0
	s_mov_b32 s0, 0
	ds_load_2addr_b64 v[0:3], v7 offset1:1
	ds_load_b64 v[4:5], v7 offset:16
	v_add_nc_u32_e32 v7, 24, v7
.LBB2_12:                               ; =>This Inner Loop Header: Depth=1
	ds_load_2addr_b64 v[8:11], v7 offset1:1
	ds_load_b64 v[12:13], v7 offset:16
	v_add_nc_u32_e32 v6, 1, v6
	v_add_nc_u32_e32 v7, 24, v7
	s_waitcnt lgkmcnt(1)
	v_add_f64 v[10:11], v[2:3], -v[10:11]
	v_add_f64 v[8:9], v[0:1], -v[8:9]
	s_waitcnt lgkmcnt(0)
	v_add_f64 v[12:13], v[4:5], -v[12:13]
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_f64 v[10:11], v[10:11], v[10:11]
	v_fma_f64 v[8:9], v[8:9], v[8:9], v[10:11]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[8:9], v[12:13], v[12:13], v[8:9]
	v_cmp_gt_f64_e32 vcc_lo, 0x10000000, v[8:9]
	v_cndmask_b32_e64 v10, 0, 1, vcc_lo
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b32_e32 v10, 8, v10
	v_ldexp_f64 v[8:9], v[8:9], v10
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_3) | instid1(VALU_DEP_1)
	v_rsq_f64_e32 v[10:11], v[8:9]
	s_waitcnt_depctr 0xfff
	v_mul_f64 v[12:13], v[8:9], v[10:11]
	v_mul_f64 v[10:11], v[10:11], 0.5
	v_fma_f64 v[14:15], -v[10:11], v[12:13], 0.5
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_fma_f64 v[12:13], v[12:13], v[14:15], v[12:13]
	v_fma_f64 v[10:11], v[10:11], v[14:15], v[10:11]
	v_fma_f64 v[14:15], -v[12:13], v[12:13], v[8:9]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[12:13], v[14:15], v[10:11], v[12:13]
	v_fma_f64 v[14:15], -v[12:13], v[12:13], v[8:9]
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_2)
	v_fma_f64 v[10:11], v[14:15], v[10:11], v[12:13]
	v_cndmask_b32_e64 v12, 0, 0xffffff80, vcc_lo
	v_cmp_class_f64_e64 vcc_lo, v[8:9], 0x260
	v_ldexp_f64 v[10:11], v[10:11], v12
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_dual_cndmask_b32 v9, v11, v9 :: v_dual_cndmask_b32 v8, v10, v8
	v_div_scale_f64 v[10:11], null, s[8:9], s[8:9], v[8:9]
	v_div_scale_f64 v[16:17], vcc_lo, v[8:9], s[8:9], v[8:9]
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	v_rcp_f64_e32 v[12:13], v[10:11]
	s_waitcnt_depctr 0xfff
	v_fma_f64 v[14:15], -v[10:11], v[12:13], 1.0
	v_fma_f64 v[12:13], v[12:13], v[14:15], v[12:13]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[14:15], -v[10:11], v[12:13], 1.0
	v_fma_f64 v[12:13], v[12:13], v[14:15], v[12:13]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_f64 v[14:15], v[16:17], v[12:13]
	v_fma_f64 v[10:11], -v[10:11], v[14:15], v[16:17]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_div_fmas_f64 v[10:11], v[10:11], v[12:13], v[14:15]
	v_div_fixup_f64 v[8:9], v[10:11], s[8:9], v[8:9]
	v_mov_b32_e32 v10, 1
	v_mov_b32_e32 v11, 0
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cvt_i32_f64_e32 v8, v[8:9]
	v_ashrrev_i32_e32 v9, 31, v8
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[8:9], 3, v[8:9]
	v_add_co_u32 v8, vcc_lo, s4, v8
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_3) | instid1(SALU_CYCLE_1)
	v_add_co_ci_u32_e32 v9, vcc_lo, s5, v9, vcc_lo
	v_cmp_le_i32_e32 vcc_lo, s11, v6
	global_atomic_add_u64 v[8:9], v[10:11], off
	s_or_b32 s0, vcc_lo, s0
	s_and_not1_b32 exec_lo, exec_lo, s0
	s_cbranch_execnz .LBB2_12
.LBB2_13:                               ; %Flow96
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z8pdh_privP10hist_entryP8atomdescdii
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 288
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 19
		.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_end2:
	.size	_Z8pdh_privP10hist_entryP8atomdescdii, .Lfunc_end2-_Z8pdh_privP10hist_entryP8atomdescdii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 1428
; NumSgprs: 18
; NumVgprs: 19
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 2
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 19
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __hip_cuid_
	.amdgpu_metadata
---
amdhsa.kernels:
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .offset:         16
        .size:           8
        .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:           _Z12PDH_baselineP10hist_entryP8atomdescdi
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z12PDH_baselineP10hist_entryP8atomdescdi.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     1
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
  - .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:           8
        .value_kind:     by_value
      - .offset:         24
        .size:           4
        .value_kind:     by_value
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 28
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z8pdh_coalP10hist_entryP8atomdescdi
    .private_segment_fixed_size: 0
    .sgpr_count:     0
    .sgpr_spill_count: 0
    .symbol:         _Z8pdh_coalP10hist_entryP8atomdescdi.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     0
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
  - .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:           8
        .value_kind:     by_value
      - .offset:         24
        .size:           4
        .value_kind:     by_value
      - .offset:         28
        .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
      - .offset:         152
        .size:           4
        .value_kind:     hidden_dynamic_lds_size
    .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:           _Z8pdh_privP10hist_entryP8atomdescdii
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z8pdh_privP10hist_entryP8atomdescdii.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     19
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
