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

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <sys/time.h>
#include <cuda.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;
	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   */
bucket * h_gpu_histogram;
bucket * d_gpu_histogram;
bucket * diff_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 w                             */

atom * atom_list;		/* list of all data points                */
atom * d_atom_list;

/* These are for an old way of tracking time */
struct timezone Idunno;	
struct timeval startTime, endTime;


/* 
	distance of two points in the atom_list 
*/
double p2p_distance(int ind1, int ind2) {
	
	double x1 = atom_list[ind1].x_pos;
	double x2 = atom_list[ind2].x_pos;
	double y1 = atom_list[ind1].y_pos;
	double y2 = atom_list[ind2].y_pos;
	double z1 = atom_list[ind1].z_pos;
	double z2 = atom_list[ind2].z_pos;
		
	return sqrt((x1 - x2)*(x1-x2) + (y1 - y2)*(y1 - y2) + (z1 - z2)*(z1 - z2));
}

//get cuda error
// void cuda_err(cudaError_t e, char in[])
// {
// 	if (e != cudaSuccess){
// 		printf("CUDA Error: %s, %s \n", in, cudaGetErrorString(e));
// 		exit(EXIT_FAILURE);
// 	}
// }


/* 
	brute-force SDH solution in a single CPU thread 
*/
int PDH_baseline() {
	int i, j, h_pos;
	double dist;
	
	for(i = 0; i < PDH_acnt; i++) {
		for(j = i+1; j < PDH_acnt; j++) {
			dist = p2p_distance(i,j);
			h_pos = (int) (dist / PDH_res);
			histogram[h_pos].d_cnt++;
		} 
		
	}
	return 0;
}

/*
	SDH kernel - a really crappy one
*/

__global__ void PDH_kernel(bucket* d_histogram, atom* d_atom_list, long long acnt, double res)
{
	int id = blockIdx.x*blockDim.x + threadIdx.x;
	int j, h_pos;
	double dist;
	double x1;
	double x2;
	double y1;
	double y2;
	double z1;
	double z2;
	if(id < acnt) 
		for(j = id+1; j < acnt; j++)
		{
			x1 = d_atom_list[id].x_pos;
			x2 = d_atom_list[j].x_pos;
			y1 = d_atom_list[id].y_pos;
			y2 = d_atom_list[j].y_pos;
			z1 = d_atom_list[id].z_pos;
			z2 = d_atom_list[j].z_pos;
			dist = sqrt((x1 - x2)*(x1-x2) + (y1 - y2)*(y1 - y2) + (z1 - z2)*(z1 - z2));
			h_pos = (int) (dist / res);
			  // __syncthreads();
			  // d_histogram[h_pos].d_cnt += 1;		//very odd that this doesnt work but atomicAdd does... I wonder why
													//long story short... it's basically because having synchronized threads 
													//at this point doesnt prevent race condiions on the increment itself
			  // __syncthreads();
			atomicAdd((unsigned long long int*)&d_histogram[h_pos].d_cnt,1);
		}
}


/*
	SDH kernel 2.0 - now the goal is to make a better kernel, that is at least 10x faster (at first)
*/
__global__ void PDH_kernel2(bucket* d_histogram, atom* d_atom_list, long long acnt, double res)
{

}


/* 
	set a checkpoint and show the (natural) running time in seconds 
*/
double report_running_time() {
	long sec_diff, usec_diff;
	gettimeofday(&endTime, &Idunno);
	sec_diff = endTime.tv_sec - startTime.tv_sec;
	usec_diff= endTime.tv_usec-startTime.tv_usec;
	if(usec_diff < 0) {
		sec_diff --;
		usec_diff += 1000000;
	}
	printf("Running time for CPU version: %ld.%06ld\n", sec_diff, usec_diff);
	return (double)(sec_diff*1.0 + usec_diff/1000000.0);
}

double report_running_time_GPU() {
	long sec_diff, usec_diff;
	gettimeofday(&endTime, &Idunno);
	sec_diff = endTime.tv_sec - startTime.tv_sec;
	usec_diff= endTime.tv_usec-startTime.tv_usec;
	if(usec_diff < 0) {
		sec_diff --;
		usec_diff += 1000000;
	}
	printf("Running time for GPU version: %ld.%06ld\n", sec_diff, usec_diff);
	return (double)(sec_diff*1.0 + usec_diff/1000000.0);
}

/* 
	print the counts in all buckets of the histogram 
*/
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;

	PDH_acnt = atoi(argv[1]);
	PDH_res	 = atof(argv[2]);
//printf("args are %d and %f\n", PDH_acnt, PDH_res);

	num_buckets = (int)(BOX_SIZE * 1.732 / PDH_res) + 1;
	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;
	}
	/* start counting time */
	printf("Starting CPU...\n");
	gettimeofday(&startTime, &Idunno);
	
	/* call CPU single thread version to compute the histogram */
	PDH_baseline();
	
	/* check the total running time */ 
	report_running_time();
	
	/* print out the histogram */
	output_histogram(histogram);
	printf("Starting GPU...\n");

	//cudaDeviceReset();
	//gpu code--------------------------------------------------------------------------------
	h_gpu_histogram = (bucket *)malloc(sizeof(bucket)*num_buckets);

	//copy the atomlist over from host to device
	cudaMalloc((void**)&d_atom_list, sizeof(atom)*PDH_acnt);
	cudaMemcpy(d_atom_list, atom_list, sizeof(atom)*PDH_acnt, cudaMemcpyHostToDevice);

	//allocate the histogram data on the device
	cudaMalloc((void**)&d_gpu_histogram, sizeof(bucket)*num_buckets);
	cudaMemcpy(d_gpu_histogram, h_gpu_histogram, sizeof(bucket)*num_buckets,cudaMemcpyHostToDevice);

	//start the timer
	gettimeofday(&startTime, &Idunno);

	//run the kernel
	PDH_kernel<<<ceil(PDH_acnt/256.0), 256>>>(d_gpu_histogram, d_atom_list, PDH_acnt, PDH_res);
	

	//copy the histogram results back from gpu over to cpu
	cudaMemcpy(h_gpu_histogram, d_gpu_histogram, sizeof(bucket)*num_buckets, cudaMemcpyDeviceToHost);

	//check total running time
	report_running_time_GPU();

	//print out the resulting histogram from the GPU
	output_histogram(h_gpu_histogram);

	//difference calculation--------------------------------------------------------------------------------
	printf("Difference: \n");
	diff_histogram = (bucket *)malloc(sizeof(bucket)*num_buckets);
	int bi;
	for(bi = 0; bi < num_buckets; bi++)
	{
		diff_histogram[bi].d_cnt = histogram[bi].d_cnt - h_gpu_histogram[bi].d_cnt;
	}



	output_histogram(diff_histogram);

	cudaFree(d_gpu_histogram);
	cudaFree(d_atom_list);
	free(histogram);
	free(atom_list);
	free(h_gpu_histogram);
	free(diff_histogram); 

	return 0;
}



	.file	"tmpxft_00357751_00000000-6_proj1-tanmay.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2035:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2035:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z12p2p_distanceii
	.type	_Z12p2p_distanceii, @function
_Z12p2p_distanceii:
.LFB2027:
	.cfi_startproc
	endbr64
	movslq	%edi, %rdi
	movslq	%esi, %rsi
	movq	atom_list(%rip), %rax
	imulq	$24, %rdi, %rdi
	imulq	$24, %rsi, %rsi
	addq	%rax, %rdi
	addq	%rsi, %rax
	movsd	(%rdi), %xmm0
	movsd	8(%rdi), %xmm2
	subsd	(%rax), %xmm0
	subsd	8(%rax), %xmm2
	movsd	16(%rdi), %xmm1
	subsd	16(%rax), %xmm1
	mulsd	%xmm0, %xmm0
	mulsd	%xmm2, %xmm2
	mulsd	%xmm1, %xmm1
	addsd	%xmm2, %xmm0
	addsd	%xmm1, %xmm0
	jmp	sqrt@PLT
	.cfi_endproc
.LFE2027:
	.size	_Z12p2p_distanceii, .-_Z12p2p_distanceii
	.globl	_Z12PDH_baselinev
	.type	_Z12PDH_baselinev, @function
_Z12PDH_baselinev:
.LFB2028:
	.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
	xorl	%ebx, %ebx
	pushq	%rcx
	.cfi_def_cfa_offset 48
.L4:
	cmpq	%rbx, PDH_acnt(%rip)
	movl	%ebx, %r13d
	jle	.L10
	leal	1(%rbx), %r12d
	incq	%rbx
	movq	%rbx, %rbp
.L5:
	cmpq	%rbp, PDH_acnt(%rip)
	jle	.L4
	movl	%r12d, %esi
	movl	%r13d, %edi
	incl	%r12d
	incq	%rbp
	call	_Z12p2p_distanceii
	divsd	PDH_res(%rip), %xmm0
	cvttsd2sil	%xmm0, %eax
	movq	histogram(%rip), %rdx
	cltq
	incq	(%rdx,%rax,8)
	jmp	.L5
.L10:
	popq	%rdx
	.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
.LFE2028:
	.size	_Z12PDH_baselinev, .-_Z12PDH_baselinev
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"Running time for CPU version: %ld.%06ld\n"
	.text
	.globl	_Z19report_running_timev
	.type	_Z19report_running_timev, @function
_Z19report_running_timev:
.LFB2029:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	leaq	Idunno(%rip), %rsi
	leaq	endTime(%rip), %rdi
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	pushq	%rdx
	.cfi_def_cfa_offset 32
	call	gettimeofday@PLT
	movq	endTime(%rip), %rbp
	movq	8+endTime(%rip), %rbx
	subq	startTime(%rip), %rbp
	subq	8+startTime(%rip), %rbx
	jns	.L12
	decq	%rbp
	addq	$1000000, %rbx
.L12:
	movq	%rbx, %rcx
	movq	%rbp, %rdx
	leaq	.LC0(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
	cvtsi2sdq	%rbp, %xmm1
	cvtsi2sdq	%rbx, %xmm0
	divsd	.LC1(%rip), %xmm0
	popq	%rax
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	addsd	%xmm1, %xmm0
	ret
	.cfi_endproc
.LFE2029:
	.size	_Z19report_running_timev, .-_Z19report_running_timev
	.section	.rodata.str1.1
.LC2:
	.string	"Running time for GPU version: %ld.%06ld\n"
	.text
	.globl	_Z23report_running_time_GPUv
	.type	_Z23report_running_time_GPUv, @function
_Z23report_running_time_GPUv:
.LFB2030:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	leaq	Idunno(%rip), %rsi
	leaq	endTime(%rip), %rdi
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	pushq	%rdx
	.cfi_def_cfa_offset 32
	call	gettimeofday@PLT
	movq	endTime(%rip), %rbp
	movq	8+endTime(%rip), %rbx
	subq	startTime(%rip), %rbp
	subq	8+startTime(%rip), %rbx
	jns	.L15
	decq	%rbp
	addq	$1000000, %rbx
.L15:
	movq	%rbx, %rcx
	movq	%rbp, %rdx
	leaq	.LC2(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
	cvtsi2sdq	%rbp, %xmm1
	cvtsi2sdq	%rbx, %xmm0
	divsd	.LC1(%rip), %xmm0
	popq	%rax
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	addsd	%xmm1, %xmm0
	ret
	.cfi_endproc
.LFE2030:
	.size	_Z23report_running_time_GPUv, .-_Z23report_running_time_GPUv
	.section	.rodata.str1.1
.LC3:
	.string	"\n%02d: "
.LC4:
	.string	"%15lld "
.LC5:
	.string	"\n T:%lld \n"
.LC6:
	.string	"| "
	.text
	.globl	_Z16output_histogramP10hist_entry
	.type	_Z16output_histogramP10hist_entry, @function
_Z16output_histogramP10hist_entry:
.LFB2031:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	leaq	.LC3(%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
.L18:
	cmpl	%ebx, num_buckets(%rip)
	movl	%ebx, %ebp
	jle	.L24
	movl	%ebp, %eax
	movl	$5, %ecx
	cltd
	idivl	%ecx
	testl	%edx, %edx
	jne	.L19
	movl	%ebp, %edx
	movq	%r14, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L19:
	movq	(%r12,%rbx,8), %rdx
	leaq	.LC4(%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	.L20
	movq	%r13, %rdx
	leaq	.LC5(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L21
.L20:
	leaq	.LC6(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L21:
	incq	%rbx
	jmp	.L18
.L24:
	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
.LFE2031:
	.size	_Z16output_histogramP10hist_entry, .-_Z16output_histogramP10hist_entry
	.globl	_Z53__device_stub__Z10PDH_kernelP10hist_entryP8atomdescxdP10hist_entryP8atomdescxd
	.type	_Z53__device_stub__Z10PDH_kernelP10hist_entryP8atomdescxdP10hist_entryP8atomdescxd, @function
_Z53__device_stub__Z10PDH_kernelP10hist_entryP8atomdescxdP10hist_entryP8atomdescxd:
.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
	movq	%rdx, 8(%rsp)
	leaq	40(%rsp), %rdx
	movsd	%xmm0, (%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)
	movq	%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	.L25
	pushq	48(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z10PDH_kernelP10hist_entryP8atomdescxd(%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
.L25:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L27
	call	__stack_chk_fail@PLT
.L27:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2057:
	.size	_Z53__device_stub__Z10PDH_kernelP10hist_entryP8atomdescxdP10hist_entryP8atomdescxd, .-_Z53__device_stub__Z10PDH_kernelP10hist_entryP8atomdescxdP10hist_entryP8atomdescxd
	.globl	_Z10PDH_kernelP10hist_entryP8atomdescxd
	.type	_Z10PDH_kernelP10hist_entryP8atomdescxd, @function
_Z10PDH_kernelP10hist_entryP8atomdescxd:
.LFB2058:
	.cfi_startproc
	endbr64
	jmp	_Z53__device_stub__Z10PDH_kernelP10hist_entryP8atomdescxdP10hist_entryP8atomdescxd
	.cfi_endproc
.LFE2058:
	.size	_Z10PDH_kernelP10hist_entryP8atomdescxd, .-_Z10PDH_kernelP10hist_entryP8atomdescxd
	.section	.rodata.str1.1
.LC10:
	.string	"Starting CPU...\n"
.LC11:
	.string	"Starting GPU...\n"
.LC13:
	.string	"Difference: \n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2032:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	subq	$40, %rsp
	.cfi_def_cfa_offset 64
	movq	8(%rsi), %rdi
	call	atoi@PLT
	movq	16(%rbp), %rdi
	movslq	%eax, %rbx
	movq	%rbx, PDH_acnt(%rip)
	call	atof@PLT
	movsd	.LC7(%rip), %xmm1
	movsd	%xmm0, PDH_res(%rip)
	divsd	%xmm0, %xmm1
	cvttsd2sil	%xmm1, %edi
	incl	%edi
	movl	%edi, num_buckets(%rip)
	movslq	%edi, %rdi
	salq	$3, %rdi
	call	malloc@PLT
	imulq	$24, %rbx, %rdi
	xorl	%ebx, %ebx
	movq	%rax, histogram(%rip)
	call	malloc@PLT
	movl	$1, %edi
	movq	%rax, atom_list(%rip)
	call	srand@PLT
.L31:
	cmpq	%rbx, PDH_acnt(%rip)
	jle	.L37
	call	rand@PLT
	imulq	$24, %rbx, %rbp
	incq	%rbx
	cvtsi2sdl	%eax, %xmm0
	divsd	.LC8(%rip), %xmm0
	mulsd	.LC9(%rip), %xmm0
	movq	atom_list(%rip), %rax
	movsd	%xmm0, (%rax,%rbp)
	call	rand@PLT
	cvtsi2sdl	%eax, %xmm0
	divsd	.LC8(%rip), %xmm0
	mulsd	.LC9(%rip), %xmm0
	movq	atom_list(%rip), %rax
	movsd	%xmm0, 8(%rax,%rbp)
	call	rand@PLT
	cvtsi2sdl	%eax, %xmm0
	divsd	.LC8(%rip), %xmm0
	mulsd	.LC9(%rip), %xmm0
	movq	atom_list(%rip), %rax
	movsd	%xmm0, 16(%rax,%rbp)
	jmp	.L31
.L37:
	leaq	startTime(%rip), %rbx
	leaq	.LC10(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	Idunno(%rip), %rbp
	movq	%rbx, %rdi
	movq	%rbp, %rsi
	call	gettimeofday@PLT
	call	_Z12PDH_baselinev
	call	_Z19report_running_timev
	movq	histogram(%rip), %rdi
	call	_Z16output_histogramP10hist_entry
	leaq	.LC11(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movslq	num_buckets(%rip), %rdi
	salq	$3, %rdi
	call	malloc@PLT
	imulq	$24, PDH_acnt(%rip), %rsi
	leaq	d_atom_list(%rip), %rdi
	movq	%rax, h_gpu_histogram(%rip)
	call	cudaMalloc@PLT
	imulq	$24, PDH_acnt(%rip), %rdx
	movl	$1, %ecx
	movq	atom_list(%rip), %rsi
	movq	d_atom_list(%rip), %rdi
	call	cudaMemcpy@PLT
	movslq	num_buckets(%rip), %rsi
	leaq	d_gpu_histogram(%rip), %rdi
	salq	$3, %rsi
	call	cudaMalloc@PLT
	movslq	num_buckets(%rip), %rdx
	movl	$1, %ecx
	movq	h_gpu_histogram(%rip), %rsi
	movq	d_gpu_histogram(%rip), %rdi
	salq	$3, %rdx
	call	cudaMemcpy@PLT
	movq	%rbx, %rdi
	movq	%rbp, %rsi
	movl	$16777217, %ebx
	call	gettimeofday@PLT
	salq	$8, %rbx
	cvtsi2sdq	PDH_acnt(%rip), %xmm0
	movl	$1, 28(%rsp)
	mulsd	.LC12(%rip), %xmm0
	movq	%rbx, 20(%rsp)
	call	ceil@PLT
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movq	%rbx, %rdx
	cvttsd2siq	%xmm0, %rax
	movl	$1, %ecx
	movl	%eax, 8(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 12(%rsp)
	movq	8(%rsp), %rdi
	movl	16(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L33
	movsd	PDH_res(%rip), %xmm0
	movq	PDH_acnt(%rip), %rdx
	movq	d_atom_list(%rip), %rsi
	movq	d_gpu_histogram(%rip), %rdi
	call	_Z53__device_stub__Z10PDH_kernelP10hist_entryP8atomdescxdP10hist_entryP8atomdescxd
.L33:
	movslq	num_buckets(%rip), %rdx
	movq	d_gpu_histogram(%rip), %rsi
	movl	$2, %ecx
	movq	h_gpu_histogram(%rip), %rdi
	salq	$3, %rdx
	call	cudaMemcpy@PLT
	call	_Z23report_running_time_GPUv
	movq	h_gpu_histogram(%rip), %rdi
	call	_Z16output_histogramP10hist_entry
	leaq	.LC13(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movslq	num_buckets(%rip), %rdi
	movq	%rdi, %rbx
	salq	$3, %rdi
	call	malloc@PLT
	movq	histogram(%rip), %rcx
	movq	h_gpu_histogram(%rip), %rsi
	xorl	%edx, %edx
	movq	%rax, diff_histogram(%rip)
	movq	%rax, %rdi
.L34:
	cmpl	%edx, %ebx
	jle	.L38
	movq	(%rcx,%rdx,8), %rax
	subq	(%rsi,%rdx,8), %rax
	movq	%rax, (%rdi,%rdx,8)
	incq	%rdx
	jmp	.L34
.L38:
	call	_Z16output_histogramP10hist_entry
	movq	d_gpu_histogram(%rip), %rdi
	call	cudaFree@PLT
	movq	d_atom_list(%rip), %rdi
	call	cudaFree@PLT
	movq	histogram(%rip), %rdi
	call	free@PLT
	movq	atom_list(%rip), %rdi
	call	free@PLT
	movq	h_gpu_histogram(%rip), %rdi
	call	free@PLT
	movq	diff_histogram(%rip), %rdi
	call	free@PLT
	addq	$40, %rsp
	.cfi_def_cfa_offset 24
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2032:
	.size	main, .-main
	.text
	.globl	_Z54__device_stub__Z11PDH_kernel2P10hist_entryP8atomdescxdP10hist_entryP8atomdescxd
	.type	_Z54__device_stub__Z11PDH_kernel2P10hist_entryP8atomdescxdP10hist_entryP8atomdescxd, @function
_Z54__device_stub__Z11PDH_kernel2P10hist_entryP8atomdescxdP10hist_entryP8atomdescxd:
.LFB2059:
	.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
	movq	%rdx, 8(%rsp)
	leaq	40(%rsp), %rdx
	movsd	%xmm0, (%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)
	movq	%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	.L39
	pushq	48(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z11PDH_kernel2P10hist_entryP8atomdescxd(%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
.L39:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L41
	call	__stack_chk_fail@PLT
.L41:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2059:
	.size	_Z54__device_stub__Z11PDH_kernel2P10hist_entryP8atomdescxdP10hist_entryP8atomdescxd, .-_Z54__device_stub__Z11PDH_kernel2P10hist_entryP8atomdescxdP10hist_entryP8atomdescxd
	.globl	_Z11PDH_kernel2P10hist_entryP8atomdescxd
	.type	_Z11PDH_kernel2P10hist_entryP8atomdescxd, @function
_Z11PDH_kernel2P10hist_entryP8atomdescxd:
.LFB2060:
	.cfi_startproc
	endbr64
	jmp	_Z54__device_stub__Z11PDH_kernel2P10hist_entryP8atomdescxdP10hist_entryP8atomdescxd
	.cfi_endproc
.LFE2060:
	.size	_Z11PDH_kernel2P10hist_entryP8atomdescxd, .-_Z11PDH_kernel2P10hist_entryP8atomdescxd
	.section	.rodata.str1.1
.LC14:
	.string	"_Z11PDH_kernel2P10hist_entryP8atomdescxd"
.LC15:
	.string	"_Z10PDH_kernelP10hist_entryP8atomdescxd"
	.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	.LC14(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z11PDH_kernel2P10hist_entryP8atomdescxd(%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	.LC15(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z10PDH_kernelP10hist_entryP8atomdescxd(%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	d_atom_list
	.align 8
	.type	d_atom_list, @object
	.size	d_atom_list, 8
d_atom_list:
	.zero	8
	.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	diff_histogram
	.align 8
	.type	diff_histogram, @object
	.size	diff_histogram, 8
diff_histogram:
	.zero	8
	.globl	d_gpu_histogram
	.align 8
	.type	d_gpu_histogram, @object
	.size	d_gpu_histogram, 8
d_gpu_histogram:
	.zero	8
	.globl	h_gpu_histogram
	.align 8
	.type	h_gpu_histogram, @object
	.size	h_gpu_histogram, 8
h_gpu_histogram:
	.zero	8
	.globl	histogram
	.align 8
	.type	histogram, @object
	.size	histogram, 8
histogram:
	.zero	8
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC1:
	.long	0
	.long	1093567616
	.align 8
.LC7:
	.long	0
	.long	1088648064
	.align 8
.LC8:
	.long	-4194304
	.long	1105199103
	.align 8
.LC9:
	.long	0
	.long	1087796736
	.align 8
.LC12:
	.long	0
	.long	1064304640
	.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 C4 lab machines
   ==================================================================
*/

#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;
	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   */
bucket * h_gpu_histogram;
bucket * d_gpu_histogram;
bucket * diff_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 w                             */

atom * atom_list;		/* list of all data points                */
atom * d_atom_list;

/* These are for an old way of tracking time */
struct timezone Idunno;	
struct timeval startTime, endTime;


/* 
	distance of two points in the atom_list 
*/
double p2p_distance(int ind1, int ind2) {
	
	double x1 = atom_list[ind1].x_pos;
	double x2 = atom_list[ind2].x_pos;
	double y1 = atom_list[ind1].y_pos;
	double y2 = atom_list[ind2].y_pos;
	double z1 = atom_list[ind1].z_pos;
	double z2 = atom_list[ind2].z_pos;
		
	return sqrt((x1 - x2)*(x1-x2) + (y1 - y2)*(y1 - y2) + (z1 - z2)*(z1 - z2));
}

//get cuda error
// void cuda_err(cudaError_t e, char in[])
// {
// 	if (e != cudaSuccess){
// 		printf("CUDA Error: %s, %s \n", in, cudaGetErrorString(e));
// 		exit(EXIT_FAILURE);
// 	}
// }


/* 
	brute-force SDH solution in a single CPU thread 
*/
int PDH_baseline() {
	int i, j, h_pos;
	double dist;
	
	for(i = 0; i < PDH_acnt; i++) {
		for(j = i+1; j < PDH_acnt; j++) {
			dist = p2p_distance(i,j);
			h_pos = (int) (dist / PDH_res);
			histogram[h_pos].d_cnt++;
		} 
		
	}
	return 0;
}

/*
	SDH kernel - a really crappy one
*/

__global__ void PDH_kernel(bucket* d_histogram, atom* d_atom_list, long long acnt, double res)
{
	int id = blockIdx.x*blockDim.x + threadIdx.x;
	int j, h_pos;
	double dist;
	double x1;
	double x2;
	double y1;
	double y2;
	double z1;
	double z2;
	if(id < acnt) 
		for(j = id+1; j < acnt; j++)
		{
			x1 = d_atom_list[id].x_pos;
			x2 = d_atom_list[j].x_pos;
			y1 = d_atom_list[id].y_pos;
			y2 = d_atom_list[j].y_pos;
			z1 = d_atom_list[id].z_pos;
			z2 = d_atom_list[j].z_pos;
			dist = sqrt((x1 - x2)*(x1-x2) + (y1 - y2)*(y1 - y2) + (z1 - z2)*(z1 - z2));
			h_pos = (int) (dist / res);
			  // __syncthreads();
			  // d_histogram[h_pos].d_cnt += 1;		//very odd that this doesnt work but atomicAdd does... I wonder why
													//long story short... it's basically because having synchronized threads 
													//at this point doesnt prevent race condiions on the increment itself
			  // __syncthreads();
			atomicAdd((unsigned long long int*)&d_histogram[h_pos].d_cnt,1);
		}
}


/*
	SDH kernel 2.0 - now the goal is to make a better kernel, that is at least 10x faster (at first)
*/
__global__ void PDH_kernel2(bucket* d_histogram, atom* d_atom_list, long long acnt, double res)
{

}


/* 
	set a checkpoint and show the (natural) running time in seconds 
*/
double report_running_time() {
	long sec_diff, usec_diff;
	gettimeofday(&endTime, &Idunno);
	sec_diff = endTime.tv_sec - startTime.tv_sec;
	usec_diff= endTime.tv_usec-startTime.tv_usec;
	if(usec_diff < 0) {
		sec_diff --;
		usec_diff += 1000000;
	}
	printf("Running time for CPU version: %ld.%06ld\n", sec_diff, usec_diff);
	return (double)(sec_diff*1.0 + usec_diff/1000000.0);
}

double report_running_time_GPU() {
	long sec_diff, usec_diff;
	gettimeofday(&endTime, &Idunno);
	sec_diff = endTime.tv_sec - startTime.tv_sec;
	usec_diff= endTime.tv_usec-startTime.tv_usec;
	if(usec_diff < 0) {
		sec_diff --;
		usec_diff += 1000000;
	}
	printf("Running time for GPU version: %ld.%06ld\n", sec_diff, usec_diff);
	return (double)(sec_diff*1.0 + usec_diff/1000000.0);
}

/* 
	print the counts in all buckets of the histogram 
*/
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;

	PDH_acnt = atoi(argv[1]);
	PDH_res	 = atof(argv[2]);
//printf("args are %d and %f\n", PDH_acnt, PDH_res);

	num_buckets = (int)(BOX_SIZE * 1.732 / PDH_res) + 1;
	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;
	}
	/* start counting time */
	printf("Starting CPU...\n");
	gettimeofday(&startTime, &Idunno);
	
	/* call CPU single thread version to compute the histogram */
	PDH_baseline();
	
	/* check the total running time */ 
	report_running_time();
	
	/* print out the histogram */
	output_histogram(histogram);
	printf("Starting GPU...\n");

	//cudaDeviceReset();
	//gpu code--------------------------------------------------------------------------------
	h_gpu_histogram = (bucket *)malloc(sizeof(bucket)*num_buckets);

	//copy the atomlist over from host to device
	hipMalloc((void**)&d_atom_list, sizeof(atom)*PDH_acnt);
	hipMemcpy(d_atom_list, atom_list, sizeof(atom)*PDH_acnt, hipMemcpyHostToDevice);

	//allocate the histogram data on the device
	hipMalloc((void**)&d_gpu_histogram, sizeof(bucket)*num_buckets);
	hipMemcpy(d_gpu_histogram, h_gpu_histogram, sizeof(bucket)*num_buckets,hipMemcpyHostToDevice);

	//start the timer
	gettimeofday(&startTime, &Idunno);

	//run the kernel
	PDH_kernel<<<ceil(PDH_acnt/256.0), 256>>>(d_gpu_histogram, d_atom_list, PDH_acnt, PDH_res);
	

	//copy the histogram results back from gpu over to cpu
	hipMemcpy(h_gpu_histogram, d_gpu_histogram, sizeof(bucket)*num_buckets, hipMemcpyDeviceToHost);

	//check total running time
	report_running_time_GPU();

	//print out the resulting histogram from the GPU
	output_histogram(h_gpu_histogram);

	//difference calculation--------------------------------------------------------------------------------
	printf("Difference: \n");
	diff_histogram = (bucket *)malloc(sizeof(bucket)*num_buckets);
	int bi;
	for(bi = 0; bi < num_buckets; bi++)
	{
		diff_histogram[bi].d_cnt = histogram[bi].d_cnt - h_gpu_histogram[bi].d_cnt;
	}



	output_histogram(diff_histogram);

	hipFree(d_gpu_histogram);
	hipFree(d_atom_list);
	free(histogram);
	free(atom_list);
	free(h_gpu_histogram);
	free(diff_histogram); 

	return 0;
}



	.text
	.file	"proj1-tanmay.hip"
	.globl	_Z12p2p_distanceii              # -- Begin function _Z12p2p_distanceii
	.type	_Z12p2p_distanceii,@function
_Z12p2p_distanceii:                     # @_Z12p2p_distanceii
	.cfi_startproc
# %bb.0:
	movq	atom_list(%rip), %rax
	movslq	%edi, %rcx
	leaq	(%rcx,%rcx,2), %rcx
	movslq	%esi, %rdx
	leaq	(%rdx,%rdx,2), %rdx
	movsd	(%rax,%rcx,8), %xmm0            # xmm0 = mem[0],zero
	movsd	8(%rax,%rcx,8), %xmm1           # xmm1 = mem[0],zero
	subsd	(%rax,%rdx,8), %xmm0
	movsd	16(%rax,%rcx,8), %xmm2          # xmm2 = mem[0],zero
	mulsd	%xmm0, %xmm0
	subsd	8(%rax,%rdx,8), %xmm1
	mulsd	%xmm1, %xmm1
	addsd	%xmm0, %xmm1
	subsd	16(%rax,%rdx,8), %xmm2
	mulsd	%xmm2, %xmm2
	addsd	%xmm1, %xmm2
	xorps	%xmm0, %xmm0
	sqrtsd	%xmm2, %xmm0
	retq
.Lfunc_end0:
	.size	_Z12p2p_distanceii, .Lfunc_end0-_Z12p2p_distanceii
	.cfi_endproc
                                        # -- End function
	.globl	_Z12PDH_baselinev               # -- Begin function _Z12PDH_baselinev
	.type	_Z12PDH_baselinev,@function
_Z12PDH_baselinev:                      # @_Z12PDH_baselinev
	.cfi_startproc
# %bb.0:
	movq	PDH_acnt(%rip), %rax
	testq	%rax, %rax
	jle	.LBB1_7
# %bb.1:                                # %.lr.ph11
	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	$16, %rsp
	.cfi_def_cfa_offset 64
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movsd	PDH_res(%rip), %xmm1            # xmm1 = mem[0],zero
	movl	$1, %r15d
	movq	histogram(%rip), %r12
	xorl	%r13d, %r13d
	movsd	%xmm1, 8(%rsp)                  # 8-byte Spill
.LBB1_3:                                # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_5 Depth 2
	movq	%r13, %rbx
	incq	%r13
	cmpq	%r13, %rax
	jle	.LBB1_2
# %bb.4:                                # %.lr.ph.preheader
                                        #   in Loop: Header=BB1_3 Depth=1
	movq	%r15, %r14
.LBB1_5:                                # %.lr.ph
                                        #   Parent Loop BB1_3 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	%ebx, %edi
	movl	%r14d, %esi
	callq	_Z12p2p_distanceii
	movsd	8(%rsp), %xmm1                  # 8-byte Reload
                                        # xmm1 = mem[0],zero
	divsd	%xmm1, %xmm0
	cvttsd2si	%xmm0, %eax
	cltq
	incq	(%r12,%rax,8)
	incq	%r14
	movq	PDH_acnt(%rip), %rax
	cmpq	%r14, %rax
	jg	.LBB1_5
.LBB1_2:                                # %.loopexit
                                        #   in Loop: Header=BB1_3 Depth=1
	incq	%r15
	cmpq	%r13, %rax
	jg	.LBB1_3
# %bb.6:
	addq	$16, %rsp
	.cfi_def_cfa_offset 48
	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
	.cfi_restore %rbx
	.cfi_restore %r12
	.cfi_restore %r13
	.cfi_restore %r14
	.cfi_restore %r15
.LBB1_7:                                # %._crit_edge
	xorl	%eax, %eax
	retq
.Lfunc_end1:
	.size	_Z12PDH_baselinev, .Lfunc_end1-_Z12PDH_baselinev
	.cfi_endproc
                                        # -- End function
	.globl	_Z25__device_stub__PDH_kernelP10hist_entryP8atomdescxd # -- Begin function _Z25__device_stub__PDH_kernelP10hist_entryP8atomdescxd
	.type	_Z25__device_stub__PDH_kernelP10hist_entryP8atomdescxd,@function
_Z25__device_stub__PDH_kernelP10hist_entryP8atomdescxd: # @_Z25__device_stub__PDH_kernelP10hist_entryP8atomdescxd
	.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
	movq	%rdx, (%rsi)
	leaq	16(%rsp), %rdx
	movsd	%xmm0, (%rdx)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	8(%rsp), %r12
	movq	%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	$_Z10PDH_kernelP10hist_entryP8atomdescxd, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$128, %rsp
	.cfi_adjust_cfa_offset -128
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end2:
	.size	_Z25__device_stub__PDH_kernelP10hist_entryP8atomdescxd, .Lfunc_end2-_Z25__device_stub__PDH_kernelP10hist_entryP8atomdescxd
	.cfi_endproc
                                        # -- End function
	.globl	_Z26__device_stub__PDH_kernel2P10hist_entryP8atomdescxd # -- Begin function _Z26__device_stub__PDH_kernel2P10hist_entryP8atomdescxd
	.type	_Z26__device_stub__PDH_kernel2P10hist_entryP8atomdescxd,@function
_Z26__device_stub__PDH_kernel2P10hist_entryP8atomdescxd: # @_Z26__device_stub__PDH_kernel2P10hist_entryP8atomdescxd
	.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
	movq	%rdx, (%rsi)
	leaq	16(%rsp), %rdx
	movsd	%xmm0, (%rdx)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	8(%rsp), %r12
	movq	%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	$_Z11PDH_kernel2P10hist_entryP8atomdescxd, %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_end3:
	.size	_Z26__device_stub__PDH_kernel2P10hist_entryP8atomdescxd, .Lfunc_end3-_Z26__device_stub__PDH_kernel2P10hist_entryP8atomdescxd
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z19report_running_timev
.LCPI4_0:
	.quad	0x412e848000000000              # double 1.0E+6
	.text
	.globl	_Z19report_running_timev
	.type	_Z19report_running_timev,@function
_Z19report_running_timev:               # @_Z19report_running_timev
	.cfi_startproc
# %bb.0:
	pushq	%r14
	.cfi_def_cfa_offset 16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	pushq	%rax
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -24
	.cfi_offset %r14, -16
	movl	$endTime, %edi
	movl	$Idunno, %esi
	callq	gettimeofday
	movq	endTime(%rip), %rax
	subq	startTime(%rip), %rax
	movq	endTime+8(%rip), %rcx
	subq	startTime+8(%rip), %rcx
	leaq	1000000(%rcx), %rbx
	movq	%rcx, %r14
	sarq	$63, %r14
	addq	%rax, %r14
	testq	%rcx, %rcx
	cmovnsq	%rcx, %rbx
	movl	$.L.str, %edi
	movq	%r14, %rsi
	movq	%rbx, %rdx
	xorl	%eax, %eax
	callq	printf
	cvtsi2sd	%r14, %xmm1
	cvtsi2sd	%rbx, %xmm0
	divsd	.LCPI4_0(%rip), %xmm0
	addsd	%xmm1, %xmm0
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end4:
	.size	_Z19report_running_timev, .Lfunc_end4-_Z19report_running_timev
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z23report_running_time_GPUv
.LCPI5_0:
	.quad	0x412e848000000000              # double 1.0E+6
	.text
	.globl	_Z23report_running_time_GPUv
	.type	_Z23report_running_time_GPUv,@function
_Z23report_running_time_GPUv:           # @_Z23report_running_time_GPUv
	.cfi_startproc
# %bb.0:
	pushq	%r14
	.cfi_def_cfa_offset 16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	pushq	%rax
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -24
	.cfi_offset %r14, -16
	movl	$endTime, %edi
	movl	$Idunno, %esi
	callq	gettimeofday
	movq	endTime(%rip), %rax
	subq	startTime(%rip), %rax
	movq	endTime+8(%rip), %rcx
	subq	startTime+8(%rip), %rcx
	leaq	1000000(%rcx), %rbx
	movq	%rcx, %r14
	sarq	$63, %r14
	addq	%rax, %r14
	testq	%rcx, %rcx
	cmovnsq	%rcx, %rbx
	movl	$.L.str.1, %edi
	movq	%r14, %rsi
	movq	%rbx, %rdx
	xorl	%eax, %eax
	callq	printf
	cvtsi2sd	%r14, %xmm1
	cvtsi2sd	%rbx, %xmm0
	divsd	.LCPI5_0(%rip), %xmm0
	addsd	%xmm1, %xmm0
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end5:
	.size	_Z23report_running_time_GPUv, .Lfunc_end5-_Z23report_running_time_GPUv
	.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	.LBB6_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
.LBB6_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	.LBB6_4
# %bb.3:                                #   in Loop: Header=BB6_2 Depth=1
	movl	$.L.str.2, %edi
	movl	%r14d, %esi
	xorl	%eax, %eax
	callq	printf
.LBB6_4:                                #   in Loop: Header=BB6_2 Depth=1
	movq	(%rbx,%r14,8), %rsi
	movl	$.L.str.3, %edi
	xorl	%eax, %eax
	callq	printf
	addq	(%rbx,%r14,8), %r15
	movl	num_buckets(%rip), %eax
	decl	%eax
	cmpq	%rax, %r14
	jne	.LBB6_6
# %bb.5:                                #   in Loop: Header=BB6_2 Depth=1
	movl	$.L.str.4, %edi
	movq	%r15, %rsi
	xorl	%eax, %eax
	callq	printf
	jmp	.LBB6_7
.LBB6_6:                                #   in Loop: Header=BB6_2 Depth=1
	movl	$.L.str.5, %edi
	xorl	%eax, %eax
	callq	printf
.LBB6_7:                                #   in Loop: Header=BB6_2 Depth=1
	incq	%r14
	movslq	num_buckets(%rip), %rax
	cmpq	%rax, %r14
	jl	.LBB6_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
.LBB6_9:                                # %._crit_edge
	retq
.Lfunc_end6:
	.size	_Z16output_histogramP10hist_entry, .Lfunc_end6-_Z16output_histogramP10hist_entry
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI7_0:
	.quad	0x40e3738000000000              # double 39836
.LCPI7_1:
	.quad	0x41dfffffffc00000              # double 2147483647
.LCPI7_2:
	.quad	0x40d6760000000000              # double 23000
.LCPI7_3:
	.quad	0x3f70000000000000              # double 0.00390625
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%r14
	.cfi_def_cfa_offset 16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	pushq	%rax
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -24
	.cfi_offset %r14, -16
	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, PDH_res(%rip)
	movsd	.LCPI7_0(%rip), %xmm1           # xmm1 = mem[0],zero
	divsd	%xmm0, %xmm1
	cvttsd2si	%xmm1, %eax
	leal	1(%rax), %ecx
	movl	%ecx, num_buckets(%rip)
	cltq
	leaq	8(,%rax,8), %rdi
	callq	malloc
	movq	%rax, histogram(%rip)
	shlq	$3, %r14
	leaq	(%r14,%r14,2), %rdi
	callq	malloc
	movq	%rax, atom_list(%rip)
	movl	$1, %edi
	callq	srand
	cmpq	$0, PDH_acnt(%rip)
	jle	.LBB7_3
# %bb.1:                                # %.lr.ph.preheader
	xorl	%ebx, %ebx
	xorl	%r14d, %r14d
.LBB7_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	callq	rand
	xorps	%xmm0, %xmm0
	cvtsi2sd	%eax, %xmm0
	movsd	.LCPI7_1(%rip), %xmm1           # xmm1 = mem[0],zero
	divsd	%xmm1, %xmm0
	movsd	.LCPI7_2(%rip), %xmm1           # xmm1 = mem[0],zero
	mulsd	%xmm1, %xmm0
	movq	atom_list(%rip), %rax
	movsd	%xmm0, (%rax,%rbx)
	callq	rand
	xorps	%xmm0, %xmm0
	cvtsi2sd	%eax, %xmm0
	divsd	.LCPI7_1(%rip), %xmm0
	mulsd	.LCPI7_2(%rip), %xmm0
	movq	atom_list(%rip), %rax
	movsd	%xmm0, 8(%rax,%rbx)
	callq	rand
	xorps	%xmm0, %xmm0
	cvtsi2sd	%eax, %xmm0
	divsd	.LCPI7_1(%rip), %xmm0
	mulsd	.LCPI7_2(%rip), %xmm0
	movq	atom_list(%rip), %rax
	movsd	%xmm0, 16(%rax,%rbx)
	incq	%r14
	addq	$24, %rbx
	cmpq	%r14, PDH_acnt(%rip)
	jg	.LBB7_2
.LBB7_3:                                # %._crit_edge
	movl	$.Lstr, %edi
	callq	puts@PLT
	movl	$startTime, %edi
	movl	$Idunno, %esi
	callq	gettimeofday
	callq	_Z12PDH_baselinev
	callq	_Z19report_running_timev
	movq	histogram(%rip), %rdi
	callq	_Z16output_histogramP10hist_entry
	movl	$.Lstr.1, %edi
	callq	puts@PLT
	movslq	num_buckets(%rip), %rdi
	shlq	$3, %rdi
	callq	malloc
	movq	%rax, h_gpu_histogram(%rip)
	movq	PDH_acnt(%rip), %rax
	shlq	$3, %rax
	leaq	(%rax,%rax,2), %rsi
	movl	$d_atom_list, %edi
	callq	hipMalloc
	movq	d_atom_list(%rip), %rdi
	movq	atom_list(%rip), %rsi
	movq	PDH_acnt(%rip), %rax
	shlq	$3, %rax
	leaq	(%rax,%rax,2), %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movslq	num_buckets(%rip), %rsi
	shlq	$3, %rsi
	movl	$d_gpu_histogram, %edi
	callq	hipMalloc
	movq	d_gpu_histogram(%rip), %rdi
	movq	h_gpu_histogram(%rip), %rsi
	movslq	num_buckets(%rip), %rdx
	shlq	$3, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movl	$startTime, %edi
	movl	$Idunno, %esi
	callq	gettimeofday
	xorps	%xmm0, %xmm0
	cvtsi2sdq	PDH_acnt(%rip), %xmm0
	mulsd	.LCPI7_3(%rip), %xmm0
	callq	ceil@PLT
	cvttsd2si	%xmm0, %rax
	movl	%eax, %edi
	btsq	$32, %rdi
	movabsq	$4294967296, %rdx               # imm = 0x100000000
	orq	$256, %rdx                      # imm = 0x100
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB7_5
# %bb.4:
	movq	d_gpu_histogram(%rip), %rdi
	movq	d_atom_list(%rip), %rsi
	movq	PDH_acnt(%rip), %rdx
	movsd	PDH_res(%rip), %xmm0            # xmm0 = mem[0],zero
	callq	_Z25__device_stub__PDH_kernelP10hist_entryP8atomdescxd
.LBB7_5:
	movq	h_gpu_histogram(%rip), %rdi
	movq	d_gpu_histogram(%rip), %rsi
	movslq	num_buckets(%rip), %rdx
	shlq	$3, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	callq	_Z23report_running_time_GPUv
	movq	h_gpu_histogram(%rip), %rdi
	callq	_Z16output_histogramP10hist_entry
	movl	$.Lstr.2, %edi
	callq	puts@PLT
	movslq	num_buckets(%rip), %rbx
	leaq	(,%rbx,8), %rdi
	callq	malloc
	movq	%rax, diff_histogram(%rip)
	testq	%rbx, %rbx
	jle	.LBB7_8
# %bb.6:                                # %.lr.ph23
	movl	%ebx, %ecx
	movq	histogram(%rip), %rdx
	movq	h_gpu_histogram(%rip), %rsi
	xorl	%edi, %edi
.LBB7_7:                                # =>This Inner Loop Header: Depth=1
	movq	(%rdx,%rdi,8), %r8
	subq	(%rsi,%rdi,8), %r8
	movq	%r8, (%rax,%rdi,8)
	incq	%rdi
	cmpq	%rdi, %rcx
	jne	.LBB7_7
.LBB7_8:                                # %._crit_edge24
	movq	%rax, %rdi
	callq	_Z16output_histogramP10hist_entry
	movq	d_gpu_histogram(%rip), %rdi
	callq	hipFree
	movq	d_atom_list(%rip), %rdi
	callq	hipFree
	movq	histogram(%rip), %rdi
	callq	free
	movq	atom_list(%rip), %rdi
	callq	free
	movq	h_gpu_histogram(%rip), %rdi
	callq	free
	movq	diff_histogram(%rip), %rdi
	callq	free
	xorl	%eax, %eax
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end7:
	.size	main, .Lfunc_end7-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	.LBB8_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB8_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z10PDH_kernelP10hist_entryP8atomdescxd, %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	$_Z11PDH_kernel2P10hist_entryP8atomdescxd, %esi
	movl	$.L__unnamed_2, %edx
	movl	$.L__unnamed_2, %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_end8:
	.size	__hip_module_ctor, .Lfunc_end8-__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	.LBB9_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
.LBB9_2:
	retq
.Lfunc_end9:
	.size	__hip_module_dtor, .Lfunc_end9-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	histogram,@object               # @histogram
	.bss
	.globl	histogram
	.p2align	3, 0x0
histogram:
	.quad	0
	.size	histogram, 8

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

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

	.type	diff_histogram,@object          # @diff_histogram
	.globl	diff_histogram
	.p2align	3, 0x0
diff_histogram:
	.quad	0
	.size	diff_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	d_atom_list,@object             # @d_atom_list
	.globl	d_atom_list
	.p2align	3, 0x0
d_atom_list:
	.quad	0
	.size	d_atom_list, 8

	.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	_Z10PDH_kernelP10hist_entryP8atomdescxd,@object # @_Z10PDH_kernelP10hist_entryP8atomdescxd
	.section	.rodata,"a",@progbits
	.globl	_Z10PDH_kernelP10hist_entryP8atomdescxd
	.p2align	3, 0x0
_Z10PDH_kernelP10hist_entryP8atomdescxd:
	.quad	_Z25__device_stub__PDH_kernelP10hist_entryP8atomdescxd
	.size	_Z10PDH_kernelP10hist_entryP8atomdescxd, 8

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

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"Running time for CPU version: %ld.%06ld\n"
	.size	.L.str, 41

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"Running time for GPU version: %ld.%06ld\n"
	.size	.L.str.1, 41

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"\n%02d: "
	.size	.L.str.2, 8

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

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"\n T:%lld \n"
	.size	.L.str.4, 11

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

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z10PDH_kernelP10hist_entryP8atomdescxd"
	.size	.L__unnamed_1, 40

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_Z11PDH_kernel2P10hist_entryP8atomdescxd"
	.size	.L__unnamed_2, 41

	.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	"Starting CPU..."
	.size	.Lstr, 16

	.type	.Lstr.1,@object                 # @str.1
.Lstr.1:
	.asciz	"Starting GPU..."
	.size	.Lstr.1, 16

	.type	.Lstr.2,@object                 # @str.2
.Lstr.2:
	.asciz	"Difference: "
	.size	.Lstr.2, 13

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym _Z25__device_stub__PDH_kernelP10hist_entryP8atomdescxd
	.addrsig_sym _Z26__device_stub__PDH_kernel2P10hist_entryP8atomdescxd
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym d_gpu_histogram
	.addrsig_sym d_atom_list
	.addrsig_sym Idunno
	.addrsig_sym startTime
	.addrsig_sym endTime
	.addrsig_sym _Z10PDH_kernelP10hist_entryP8atomdescxd
	.addrsig_sym _Z11PDH_kernel2P10hist_entryP8atomdescxd
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z10PDH_kernelP10hist_entryP8atomdescxd ; -- Begin function _Z10PDH_kernelP10hist_entryP8atomdescxd
	.globl	_Z10PDH_kernelP10hist_entryP8atomdescxd
	.p2align	8
	.type	_Z10PDH_kernelP10hist_entryP8atomdescxd,@function
_Z10PDH_kernelP10hist_entryP8atomdescxd: ; @_Z10PDH_kernelP10hist_entryP8atomdescxd
; %bb.0:
	s_clause 0x1
	s_load_b32 s8, s[0:1], 0x2c
	s_load_b256 s[0:7], s[0:1], 0x0
	s_waitcnt lgkmcnt(0)
	s_and_b32 s8, s8, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[2:3], null, s15, s8, v[0:1]
	s_mov_b32 s8, exec_lo
	v_ashrrev_i32_e32 v3, 31, v2
	s_delay_alu instid0(VALU_DEP_1)
	v_cmpx_gt_i64_e64 s[4:5], v[2:3]
	s_cbranch_execz .LBB0_4
; %bb.1:                                ; %.preheader
	v_add_nc_u32_e32 v4, 1, v2
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v5, 31, v4
	v_cmp_gt_i64_e32 vcc_lo, s[4:5], v[4:5]
	s_and_b32 exec_lo, exec_lo, vcc_lo
	s_cbranch_execz .LBB0_4
; %bb.2:                                ; %.lr.ph
	v_add_nc_u32_e32 v3, 2, v2
	v_mad_i64_i32 v[0:1], null, v2, 24, s[2:3]
	s_mov_b32 s8, 0
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_ashrrev_i32_e32 v6, 31, v3
	v_add_co_u32 v2, vcc_lo, v3, -1
	v_add_co_ci_u32_e32 v3, vcc_lo, -1, v6, vcc_lo
.LBB0_3:                                ; =>This Inner Loop Header: Depth=1
	v_mad_u64_u32 v[12:13], null, v4, 24, s[2:3]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mov_b32_e32 v4, v13
	v_mad_u64_u32 v[8:9], null, v5, 24, v[4:5]
	s_clause 0x1
	global_load_b64 v[14:15], v[0:1], off offset:16
	global_load_b128 v[4:7], v[0:1], off
	v_mov_b32_e32 v13, v8
	s_clause 0x1
	global_load_b128 v[8:11], v[12:13], off
	global_load_b64 v[12:13], v[12:13], off offset:16
	s_waitcnt vmcnt(1)
	v_add_f64 v[6:7], v[6:7], -v[10:11]
	v_add_f64 v[4:5], v[4:5], -v[8:9]
	s_waitcnt vmcnt(0)
	v_add_f64 v[8:9], v[14:15], -v[12:13]
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_f64 v[6:7], v[6:7], v[6:7]
	v_fma_f64 v[4:5], v[4:5], v[4:5], v[6:7]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[4:5], v[8:9], v[8:9], v[4:5]
	v_cmp_gt_f64_e32 vcc_lo, 0x10000000, v[4:5]
	v_cndmask_b32_e64 v6, 0, 1, vcc_lo
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b32_e32 v6, 8, v6
	v_ldexp_f64 v[4:5], v[4:5], v6
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_3) | instid1(VALU_DEP_1)
	v_rsq_f64_e32 v[6:7], v[4:5]
	s_waitcnt_depctr 0xfff
	v_mul_f64 v[8:9], v[4:5], v[6:7]
	v_mul_f64 v[6:7], v[6:7], 0.5
	v_fma_f64 v[10:11], -v[6:7], v[8:9], 0.5
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_fma_f64 v[8:9], v[8:9], v[10:11], v[8:9]
	v_fma_f64 v[6:7], v[6:7], v[10:11], v[6:7]
	v_fma_f64 v[10:11], -v[8:9], v[8:9], v[4:5]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[8:9], v[10:11], v[6:7], v[8:9]
	v_fma_f64 v[10:11], -v[8:9], v[8:9], v[4:5]
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_2)
	v_fma_f64 v[6:7], v[10:11], v[6:7], v[8:9]
	v_cndmask_b32_e64 v8, 0, 0xffffff80, vcc_lo
	v_cmp_class_f64_e64 vcc_lo, v[4:5], 0x260
	v_ldexp_f64 v[6:7], v[6:7], v8
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_dual_cndmask_b32 v5, v7, v5 :: v_dual_cndmask_b32 v4, v6, v4
	v_div_scale_f64 v[6:7], null, s[6:7], s[6:7], v[4:5]
	v_div_scale_f64 v[12:13], vcc_lo, v[4:5], s[6:7], v[4:5]
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	v_rcp_f64_e32 v[8:9], v[6:7]
	s_waitcnt_depctr 0xfff
	v_fma_f64 v[10:11], -v[6:7], v[8:9], 1.0
	v_fma_f64 v[8:9], v[8:9], v[10:11], v[8:9]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[10:11], -v[6:7], v[8:9], 1.0
	v_fma_f64 v[8:9], v[8:9], v[10:11], v[8:9]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_f64 v[10:11], v[12:13], v[8:9]
	v_fma_f64 v[6:7], -v[6:7], v[10:11], v[12:13]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_div_fmas_f64 v[6:7], v[6:7], v[8:9], v[10:11]
	v_div_fixup_f64 v[4:5], v[6:7], s[6:7], v[4:5]
	v_mov_b32_e32 v6, 1
	v_mov_b32_e32 v7, 0
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cvt_i32_f64_e32 v4, v[4:5]
	v_ashrrev_i32_e32 v5, 31, v4
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[4:5], 3, v[4:5]
	v_add_co_u32 v4, vcc_lo, s0, v4
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v5, vcc_lo, s1, v5, vcc_lo
	v_add_co_u32 v2, vcc_lo, v2, 1
	v_add_co_ci_u32_e32 v3, vcc_lo, 0, v3, vcc_lo
	global_atomic_add_u64 v[4:5], v[6:7], off
	v_mov_b32_e32 v4, v2
	v_ashrrev_i32_e32 v5, 31, v2
	v_cmp_le_i64_e32 vcc_lo, s[4:5], v[2:3]
	s_or_b32 s8, vcc_lo, s8
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_not1_b32 exec_lo, exec_lo, s8
	s_cbranch_execnz .LBB0_3
.LBB0_4:                                ; %.loopexit
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z10PDH_kernelP10hist_entryP8atomdescxd
		.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 16
		.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	_Z10PDH_kernelP10hist_entryP8atomdescxd, .Lfunc_end0-_Z10PDH_kernelP10hist_entryP8atomdescxd
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 644
; NumSgprs: 18
; NumVgprs: 16
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 16
; 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	_Z11PDH_kernel2P10hist_entryP8atomdescxd ; -- Begin function _Z11PDH_kernel2P10hist_entryP8atomdescxd
	.globl	_Z11PDH_kernel2P10hist_entryP8atomdescxd
	.p2align	8
	.type	_Z11PDH_kernel2P10hist_entryP8atomdescxd,@function
_Z11PDH_kernel2P10hist_entryP8atomdescxd: ; @_Z11PDH_kernel2P10hist_entryP8atomdescxd
; %bb.0:
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z11PDH_kernel2P10hist_entryP8atomdescxd
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 32
		.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	_Z11PDH_kernel2P10hist_entryP8atomdescxd, .Lfunc_end1-_Z11PDH_kernel2P10hist_entryP8atomdescxd
                                        ; -- 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
	.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:           8
        .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:           _Z10PDH_kernelP10hist_entryP8atomdescxd
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z10PDH_kernelP10hist_entryP8atomdescxd.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     16
    .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:           8
        .value_kind:     by_value
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 32
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z11PDH_kernel2P10hist_entryP8atomdescxd
    .private_segment_fixed_size: 0
    .sgpr_count:     0
    .sgpr_spill_count: 0
    .symbol:         _Z11PDH_kernel2P10hist_entryP8atomdescxd.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     0
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
