/* ==================================================================
	Programmers:
	Kevin Wagner
	Elijah Malaby
	John Casey

	Omptimizing SDH histograms for input larger then global memory
   ==================================================================
*/

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


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

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

unsigned long long * histogram;		/* list of all buckets in the histogram */
unsigned long long  PDH_acnt;	/* total number of data points */
int block_size;		/* Number of threads per block */
int num_buckets;	/* total number of buckets in the histogram */
float   PDH_res;	/* value of w */
atom * atom_list;	/* list of all data points */
unsigned long long * histogram_GPU;
unsigned long long * temp_histogram_GPU;
atom * atom_list_GPU;

__global__ void kernelSumHistogram( unsigned long long int *InputHists, unsigned long long int *hist, int num_atoms, int num_buckets, int block_size) {
  unsigned long long int tid = threadIdx.x + blockIdx.x * blockDim.x;
  int h_pos = tid;
  unsigned long long int NumberOfSumLoop = 0;
  NumberOfSumLoop = (num_atoms)/block_size + ((num_atoms%block_size) ? 1:0);

  while(h_pos < num_buckets) {
    unsigned long long int tmpAns = 0;
    for(int i=0;i<NumberOfSumLoop;i++){
      tmpAns = tmpAns + *(InputHists+(i*num_buckets)+h_pos);
    }
    hist[h_pos] = tmpAns;
    h_pos += blockDim.x * gridDim.x;
  }
  __syncthreads();
}

__device__ void block_to_block (atom * block_a, atom * block_b, int b_length, unsigned long long * histogram, float resolution) {
  atom me = block_a[threadIdx.x];
  for(int i = 0; i < b_length; i++)
    atomicAdd(&(histogram[(int)(sqrt((me.x_pos - block_b[i].x_pos) * (me.x_pos - block_b[i].x_pos) +
                                     (me.y_pos - block_b[i].y_pos) * (me.y_pos - block_b[i].y_pos) +
                                     (me.z_pos - block_b[i].z_pos) * (me.z_pos - block_b[i].z_pos)) / resolution)]),
              1);
}

 __global__ void GPUKernelFunction (unsigned long long PDH_acnt, float PDH_res, atom * atom_list_GPU, unsigned long long * histogram_GPU, int num_buckets) {

  extern __shared__ unsigned long long SHist[];
	/* assign register values */
	int i, h_pos;
	float dist;
  atom * my_block = &atom_list_GPU[blockIdx.x * blockDim.x];
  atom temp_atom_1 = my_block[threadIdx.x];

  for(h_pos=threadIdx.x; h_pos < num_buckets; h_pos+=blockDim.x)
    SHist[h_pos] = 0;

  __syncthreads();

	/* loop through all points in atom list calculating distance from current point to all further points */
  for (i = threadIdx.x + 1; i < blockDim.x && i+blockIdx.x*blockDim.x < PDH_acnt; i++)
  {
    atom temp_atom_2 = my_block[i];
    dist = sqrt((temp_atom_1.x_pos - temp_atom_2.x_pos) * (temp_atom_1.x_pos - temp_atom_2.x_pos) +
                (temp_atom_1.y_pos - temp_atom_2.y_pos) * (temp_atom_1.y_pos - temp_atom_2.y_pos) +
                (temp_atom_1.z_pos - temp_atom_2.z_pos) * (temp_atom_1.z_pos - temp_atom_2.z_pos));
    h_pos = (int)(dist / PDH_res);
    atomicAdd(&(SHist[h_pos]), 1);
  }
  __syncthreads();
  for(i=blockIdx.x+1; i < gridDim.x-1; i++)
    block_to_block(my_block,
                   &atom_list_GPU[i*blockDim.x],
                   blockDim.x,
                   SHist,
                   PDH_res);
  block_to_block(my_block,
                 &atom_list_GPU[i*blockDim.x],
                 PDH_acnt-i*blockDim.x, // Last block may be small
                 SHist,
                 PDH_res);
  __syncthreads();
  for(h_pos = threadIdx.x; h_pos < num_buckets; h_pos += blockDim.x)
    *(histogram_GPU+(num_buckets*blockIdx.x)+h_pos) += SHist[h_pos];
}

/* print the counts in all buckets of the histogram  */
void output_histogram_GPU(){
	int i;
	unsigned 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]);
		total_cnt += histogram[i];
	  	/* 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("| ");
	}
}

void GPU_baseline() {

  int num_blocks = ((PDH_acnt + block_size)/block_size);
	/* copy histogram to device memory */
	cudaMalloc((void**) &histogram_GPU, sizeof(unsigned long long)*num_buckets);
	cudaMemset(histogram_GPU, 0, sizeof(unsigned long long)*num_buckets);
	cudaMalloc((void**) &temp_histogram_GPU, sizeof(unsigned long long)*num_buckets*num_blocks);
	cudaMemset(temp_histogram_GPU, 0, sizeof(unsigned long long)*num_buckets*num_blocks);


	/* copy atom list to device memory */
	cudaMalloc((void**) &atom_list_GPU, sizeof(atom) * PDH_acnt);
	cudaMemcpy(atom_list_GPU, atom_list, sizeof(atom) * PDH_acnt, cudaMemcpyHostToDevice);

	/* start time keeping */
	cudaEvent_t start, stop;
	cudaEventCreate(&start);
	cudaEventCreate(&stop);
	cudaEventRecord( start, 0 );

	/* Run Kernel */
	GPUKernelFunction <<<num_blocks, block_size, sizeof(unsigned long long)*num_buckets>>> (PDH_acnt, PDH_res, atom_list_GPU, temp_histogram_GPU, num_buckets);
  cudaDeviceSynchronize();
  kernelSumHistogram<<<3, 512>>>(temp_histogram_GPU, histogram_GPU, PDH_acnt, num_buckets, block_size);

	/* stop time keeping */
	cudaEventRecord( stop, 0 );
	cudaEventSynchronize( stop );
	float elapsedTime;
	cudaEventElapsedTime( &elapsedTime, start, stop );

	/* transfer histogram to host memory */
	cudaMemcpy(histogram, histogram_GPU, sizeof(unsigned long long)*num_buckets, cudaMemcpyDeviceToHost);

	/* print out the histogram */
	output_histogram_GPU();
	elapsedTime = elapsedTime/1000;
	printf( "******** Total Running Time of Kernel = %0.5f sec *******\n", elapsedTime );

	/* free cuda timekeeping */
	cudaEventDestroy( start );
	cudaEventDestroy( stop );
  cudaFree(temp_histogram_GPU);
}

/* Input Validation Function */
bool isNumber(char number[], bool floatingpoint)
{
    for (int i = 0; number[i] != 0; i++)
    {
        //if (number[i] > '9' || number[i] < '0')
        if (!isdigit(number[i]))
		{
			if((number[i] == '.' && floatingpoint))
			{
				floatingpoint = false;
			}
			else
			{
				return false;
			}
		}
    }
    return true;
}


/* Most of this input validation can probably be pulled whenever we hardcode our block size and if we hardcode our bucket width */
int main(int argc, char **argv)
{
	/* input validation */
	if((argc > 3))
	{
		if(((isNumber(argv[1], false) && isNumber(argv[2], true)) && isNumber(argv[3], false)))
		{
			PDH_acnt = atoi(argv[1]);
			PDH_res	 = atof(argv[2]);
			block_size = atoi(argv[3]);
		}
		else
		{
			printf( "Invalid Input Error Invalid Arguments\n Valid input is ./program_name {#of_samples} {bucket_width} {block_size}\n");
			return 0;
		}
	}
	else
	{
		printf( "Invalid Input Error Insufficient Arguments\n Valid input is ./program_name {#of_samples} {bucket_width} {block_size}\n");
		return 0;
	}

	/* allocate memory */
	num_buckets = (int)(BOX_SIZE * 1.732 / PDH_res) + 1;
	histogram = (unsigned long long *)malloc(sizeof(unsigned long long)*num_buckets);
	atom_list = (atom *)malloc(sizeof(atom)*PDH_acnt);

	srand(1);
	/* generate data following a uniform distribution */
	for(int i = 0;  i < PDH_acnt; i++) {
		atom_list[i].x_pos = ((float)(rand()) / RAND_MAX) * BOX_SIZE;
		atom_list[i].y_pos = ((float)(rand()) / RAND_MAX) * BOX_SIZE;
		atom_list[i].z_pos = ((float)(rand()) / RAND_MAX) * BOX_SIZE;
	}

	/* call GPU histrogram compute */
	GPU_baseline();

	/* free memory */
	free(histogram);
	free(atom_list);

	return 0;
}



	.file	"tmpxft_002c802a_00000000-6_proj2-wagnerk1.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2034:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2034:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z14block_to_blockP8atomdescS0_iPyf
	.type	_Z14block_to_blockP8atomdescS0_iPyf, @function
_Z14block_to_blockP8atomdescS0_iPyf:
.LFB2027:
	.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
.LFE2027:
	.size	_Z14block_to_blockP8atomdescS0_iPyf, .-_Z14block_to_blockP8atomdescS0_iPyf
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"\n%02d: "
.LC1:
	.string	"%15lld "
.LC2:
	.string	"\n T:%lld \n"
.LC3:
	.string	"| "
	.text
	.globl	_Z20output_histogram_GPUv
	.type	_Z20output_histogram_GPUv, @function
_Z20output_histogram_GPUv:
.LFB2028:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leaq	.LC0(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	xorl	%r12d, %r12d
	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	%rdx
	.cfi_def_cfa_offset 48
.L5:
	cmpl	%ebx, num_buckets(%rip)
	movl	%ebx, %ebp
	jle	.L12
	movl	%ebp, %eax
	movl	$5, %ecx
	cltd
	idivl	%ecx
	testl	%edx, %edx
	jne	.L6
	movl	%ebp, %edx
	movq	%r13, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L6:
	movq	histogram(%rip), %rax
	leaq	.LC1(%rip), %rsi
	movl	$2, %edi
	movq	(%rax,%rbx,8), %rdx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	histogram(%rip), %rax
	addq	(%rax,%rbx,8), %r12
	movl	num_buckets(%rip), %eax
	decl	%eax
	cmpl	%ebp, %eax
	jne	.L7
	movq	%r12, %rdx
	leaq	.LC2(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L8
.L7:
	leaq	.LC3(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L8:
	incq	%rbx
	jmp	.L5
.L12:
	popq	%rax
	.cfi_def_cfa_offset 40
	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	_Z20output_histogram_GPUv, .-_Z20output_histogram_GPUv
	.globl	_Z8isNumberPcb
	.type	_Z8isNumberPcb, @function
_Z8isNumberPcb:
.LFB2030:
	.cfi_startproc
	endbr64
.L14:
	movb	(%rdi), %al
	testb	%al, %al
	je	.L21
	movsbl	%al, %edx
	subl	$48, %edx
	cmpl	$9, %edx
	jbe	.L15
	cmpb	$46, %al
	sete	%al
	andb	%sil, %al
	je	.L13
	xorl	%esi, %esi
.L15:
	incq	%rdi
	jmp	.L14
.L21:
	movb	$1, %al
.L13:
	ret
	.cfi_endproc
.LFE2030:
	.size	_Z8isNumberPcb, .-_Z8isNumberPcb
	.globl	_Z43__device_stub__Z18kernelSumHistogramPyS_iiiPyS_iii
	.type	_Z43__device_stub__Z18kernelSumHistogramPyS_iiiPyS_iii, @function
_Z43__device_stub__Z18kernelSumHistogramPyS_iiiPyS_iii:
.LFB2056:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movq	%rdi, 24(%rsp)
	leaq	48(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	60(%rsp), %rsi
	movl	%edx, 12(%rsp)
	leaq	32(%rsp), %rdx
	movl	%ecx, 8(%rsp)
	leaq	40(%rsp), %rcx
	movl	%r8d, 4(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 56(%rsp)
	movq	%rax, 96(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 104(%rsp)
	leaq	12(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	4(%rsp), %rax
	movq	%rax, 128(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 48(%rsp)
	movq	%rax, 60(%rsp)
	movl	$1, 68(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L22
	pushq	40(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z18kernelSumHistogramPyS_iii(%rip), %rdi
	pushq	40(%rsp)
	.cfi_def_cfa_offset 176
	movq	76(%rsp), %rcx
	movl	84(%rsp), %r8d
	movq	64(%rsp), %rsi
	movl	72(%rsp), %edx
	leaq	112(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 168
	popq	%rdx
	.cfi_def_cfa_offset 160
.L22:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L24
	call	__stack_chk_fail@PLT
.L24:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2056:
	.size	_Z43__device_stub__Z18kernelSumHistogramPyS_iiiPyS_iii, .-_Z43__device_stub__Z18kernelSumHistogramPyS_iiiPyS_iii
	.globl	_Z18kernelSumHistogramPyS_iii
	.type	_Z18kernelSumHistogramPyS_iii, @function
_Z18kernelSumHistogramPyS_iii:
.LFB2057:
	.cfi_startproc
	endbr64
	jmp	_Z43__device_stub__Z18kernelSumHistogramPyS_iiiPyS_iii
	.cfi_endproc
.LFE2057:
	.size	_Z18kernelSumHistogramPyS_iii, .-_Z18kernelSumHistogramPyS_iii
	.globl	_Z50__device_stub__Z17GPUKernelFunctionyfP8atomdescPyiyfP8atomdescPyi
	.type	_Z50__device_stub__Z17GPUKernelFunctionyfP8atomdescPyiyfP8atomdescPyi, @function
_Z50__device_stub__Z17GPUKernelFunctionyfP8atomdescPyiyfP8atomdescPyi:
.LFB2058:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movq	%rdi, 24(%rsp)
	leaq	48(%rsp), %rdi
	movq	%rsi, 8(%rsp)
	leaq	60(%rsp), %rsi
	movq	%rdx, (%rsp)
	leaq	32(%rsp), %rdx
	movl	%ecx, 16(%rsp)
	leaq	40(%rsp), %rcx
	movss	%xmm0, 20(%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	20(%rsp), %rax
	movq	%rax, 104(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 112(%rsp)
	movq	%rsp, %rax
	movq	%rax, 120(%rsp)
	leaq	16(%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	.L27
	pushq	40(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z17GPUKernelFunctionyfP8atomdescPyi(%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
.L27:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L29
	call	__stack_chk_fail@PLT
.L29:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2058:
	.size	_Z50__device_stub__Z17GPUKernelFunctionyfP8atomdescPyiyfP8atomdescPyi, .-_Z50__device_stub__Z17GPUKernelFunctionyfP8atomdescPyiyfP8atomdescPyi
	.globl	_Z17GPUKernelFunctionyfP8atomdescPyi
	.type	_Z17GPUKernelFunctionyfP8atomdescPyi, @function
_Z17GPUKernelFunctionyfP8atomdescPyi:
.LFB2059:
	.cfi_startproc
	endbr64
	jmp	_Z50__device_stub__Z17GPUKernelFunctionyfP8atomdescPyiyfP8atomdescPyi
	.cfi_endproc
.LFE2059:
	.size	_Z17GPUKernelFunctionyfP8atomdescPyi, .-_Z17GPUKernelFunctionyfP8atomdescPyi
	.section	.rodata.str1.1
.LC5:
	.string	"******** Total Running Time of Kernel = %0.5f sec *******\n"
	.text
	.globl	_Z12GPU_baselinev
	.type	_Z12GPU_baselinev, @function
_Z12GPU_baselinev:
.LFB2029:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	xorl	%edx, %edx
	leaq	histogram_GPU(%rip), %rdi
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	subq	$56, %rsp
	.cfi_def_cfa_offset 80
	movslq	block_size(%rip), %rcx
	movslq	num_buckets(%rip), %rsi
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	movq	PDH_acnt(%rip), %rax
	salq	$3, %rsi
	addq	%rcx, %rax
	divq	%rcx
	movq	%rax, %rbx
	call	cudaMalloc@PLT
	movslq	num_buckets(%rip), %rdx
	xorl	%esi, %esi
	movslq	%ebx, %rbp
	movq	histogram_GPU(%rip), %rdi
	salq	$3, %rdx
	call	cudaMemset@PLT
	movslq	num_buckets(%rip), %rsi
	leaq	temp_histogram_GPU(%rip), %rdi
	imulq	%rbp, %rsi
	salq	$3, %rsi
	call	cudaMalloc@PLT
	movslq	num_buckets(%rip), %rdx
	movq	temp_histogram_GPU(%rip), %rdi
	xorl	%esi, %esi
	imulq	%rbp, %rdx
	salq	$3, %rdx
	call	cudaMemset@PLT
	imulq	$12, PDH_acnt(%rip), %rsi
	leaq	atom_list_GPU(%rip), %rdi
	call	cudaMalloc@PLT
	imulq	$12, PDH_acnt(%rip), %rdx
	movl	$1, %ecx
	movq	atom_list(%rip), %rsi
	movq	atom_list_GPU(%rip), %rdi
	call	cudaMemcpy@PLT
	movq	%rsp, %rdi
	call	cudaEventCreate@PLT
	leaq	8(%rsp), %rdi
	call	cudaEventCreate@PLT
	movq	(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movl	block_size(%rip), %eax
	movl	%ebx, 16(%rsp)
	xorl	%r9d, %r9d
	movslq	num_buckets(%rip), %rdx
	movl	%eax, 28(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 32(%rsp)
	leaq	0(,%rdx,8), %r8
	movl	36(%rsp), %ecx
	movq	%rax, 20(%rsp)
	movq	28(%rsp), %rdx
	movq	16(%rsp), %rdi
	movl	24(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L33
	movl	num_buckets(%rip), %ecx
	movq	temp_histogram_GPU(%rip), %rdx
	movq	atom_list_GPU(%rip), %rsi
	movss	PDH_res(%rip), %xmm0
	movq	PDH_acnt(%rip), %rdi
	call	_Z50__device_stub__Z17GPUKernelFunctionyfP8atomdescPyiyfP8atomdescPyi
.L33:
	call	cudaDeviceSynchronize@PLT
	movl	$8388609, %edx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	salq	$9, %rdx
	movl	$1, %ecx
	movabsq	$4294967299, %rdi
	movl	$1, %esi
	movq	%rdx, 28(%rsp)
	movl	$1, 36(%rsp)
	movq	%rdi, 16(%rsp)
	movl	$1, 24(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L34
	movl	block_size(%rip), %r8d
	movl	num_buckets(%rip), %ecx
	movl	PDH_acnt(%rip), %edx
	movq	histogram_GPU(%rip), %rsi
	movq	temp_histogram_GPU(%rip), %rdi
	call	_Z43__device_stub__Z18kernelSumHistogramPyS_iiiPyS_iii
.L34:
	movq	8(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	8(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movq	8(%rsp), %rdx
	movq	(%rsp), %rsi
	leaq	28(%rsp), %rdi
	call	cudaEventElapsedTime@PLT
	movslq	num_buckets(%rip), %rdx
	movl	$2, %ecx
	movq	histogram_GPU(%rip), %rsi
	movq	histogram(%rip), %rdi
	salq	$3, %rdx
	call	cudaMemcpy@PLT
	call	_Z20output_histogram_GPUv
	leaq	.LC5(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	movss	28(%rsp), %xmm0
	divss	.LC4(%rip), %xmm0
	movss	%xmm0, 28(%rsp)
	cvtss2sd	%xmm0, %xmm0
	call	__printf_chk@PLT
	movq	(%rsp), %rdi
	call	cudaEventDestroy@PLT
	movq	8(%rsp), %rdi
	call	cudaEventDestroy@PLT
	movq	temp_histogram_GPU(%rip), %rdi
	call	cudaFree@PLT
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	je	.L35
	call	__stack_chk_fail@PLT
.L35:
	addq	$56, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2029:
	.size	_Z12GPU_baselinev, .-_Z12GPU_baselinev
	.section	.rodata.str1.1
.LC7:
	.string	"Invalid Input Error Invalid Arguments\n Valid input is ./program_name {#of_samples} {bucket_width} {block_size}\n"
.LC8:
	.string	"Invalid Input Error Insufficient Arguments\n Valid input is ./program_name {#of_samples} {bucket_width} {block_size}\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2031:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	subq	$16, %rsp
	.cfi_def_cfa_offset 48
	cmpl	$3, %edi
	jle	.L38
	movq	8(%rsi), %r8
	movq	%rsi, %rcx
	xorl	%esi, %esi
	movq	%r8, %rdi
	call	_Z8isNumberPcb
	testb	%al, %al
	je	.L39
	movq	16(%rcx), %r12
	movl	$1, %esi
	movq	%r12, %rdi
	call	_Z8isNumberPcb
	testb	%al, %al
	je	.L39
	movq	24(%rcx), %rbp
	xorl	%esi, %esi
	movq	%rbp, %rdi
	call	_Z8isNumberPcb
	testb	%al, %al
	je	.L39
	movq	%r8, %rdi
	call	atoi@PLT
	movq	%r12, %rdi
	movslq	%eax, %rbx
	movq	%rbx, PDH_acnt(%rip)
	call	atof@PLT
	movq	%rbp, %rdi
	cvtsd2ss	%xmm0, %xmm0
	movss	%xmm0, PDH_res(%rip)
	movss	%xmm0, 12(%rsp)
	call	atoi@PLT
	movss	12(%rsp), %xmm0
	movsd	.LC6(%rip), %xmm1
	movl	%eax, block_size(%rip)
	cvtss2sd	%xmm0, %xmm0
	divsd	%xmm0, %xmm1
	cvttsd2sil	%xmm1, %edi
	incl	%edi
	movl	%edi, num_buckets(%rip)
	movslq	%edi, %rdi
	salq	$3, %rdi
	call	malloc@PLT
	imulq	$12, %rbx, %rdi
	xorl	%ebx, %ebx
	movq	%rax, histogram(%rip)
	call	malloc@PLT
	movl	$1, %edi
	movq	%rax, atom_list(%rip)
	call	srand@PLT
	jmp	.L40
.L39:
	leaq	.LC7(%rip), %rsi
	jmp	.L53
.L38:
	leaq	.LC8(%rip), %rsi
.L53:
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L41
.L40:
	cmpq	PDH_acnt(%rip), %rbx
	jnb	.L54
	call	rand@PLT
	imulq	$12, %rbx, %rbp
	incq	%rbx
	cvtsi2ssl	%eax, %xmm0
	mulss	.LC9(%rip), %xmm0
	movq	atom_list(%rip), %rax
	mulss	.LC10(%rip), %xmm0
	movss	%xmm0, (%rax,%rbp)
	call	rand@PLT
	cvtsi2ssl	%eax, %xmm0
	mulss	.LC9(%rip), %xmm0
	movq	atom_list(%rip), %rax
	mulss	.LC10(%rip), %xmm0
	movss	%xmm0, 4(%rax,%rbp)
	call	rand@PLT
	cvtsi2ssl	%eax, %xmm0
	mulss	.LC9(%rip), %xmm0
	movq	atom_list(%rip), %rax
	mulss	.LC10(%rip), %xmm0
	movss	%xmm0, 8(%rax,%rbp)
	jmp	.L40
.L54:
	call	_Z12GPU_baselinev
	movq	histogram(%rip), %rdi
	call	free@PLT
	movq	atom_list(%rip), %rdi
	call	free@PLT
.L41:
	addq	$16, %rsp
	.cfi_def_cfa_offset 32
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2031:
	.size	main, .-main
	.section	.rodata.str1.1
.LC11:
	.string	"_Z17GPUKernelFunctionyfP8atomdescPyi"
.LC12:
	.string	"_Z18kernelSumHistogramPyS_iii"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2061:
	.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	.LC11(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z17GPUKernelFunctionyfP8atomdescPyi(%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	.LC12(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z18kernelSumHistogramPyS_iii(%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
.LFE2061:
	.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	atom_list_GPU
	.bss
	.align 8
	.type	atom_list_GPU, @object
	.size	atom_list_GPU, 8
atom_list_GPU:
	.zero	8
	.globl	temp_histogram_GPU
	.align 8
	.type	temp_histogram_GPU, @object
	.size	temp_histogram_GPU, 8
temp_histogram_GPU:
	.zero	8
	.globl	histogram_GPU
	.align 8
	.type	histogram_GPU, @object
	.size	histogram_GPU, 8
histogram_GPU:
	.zero	8
	.globl	atom_list
	.align 8
	.type	atom_list, @object
	.size	atom_list, 8
atom_list:
	.zero	8
	.globl	PDH_res
	.align 4
	.type	PDH_res, @object
	.size	PDH_res, 4
PDH_res:
	.zero	4
	.globl	num_buckets
	.align 4
	.type	num_buckets, @object
	.size	num_buckets, 4
num_buckets:
	.zero	4
	.globl	block_size
	.align 4
	.type	block_size, @object
	.size	block_size, 4
block_size:
	.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.cst4,"aM",@progbits,4
	.align 4
.LC4:
	.long	1148846080
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC6:
	.long	0
	.long	1088648064
	.section	.rodata.cst4
	.align 4
.LC9:
	.long	805306368
	.align 4
.LC10:
	.long	1186181120
	.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:

/* ==================================================================
	Programmers:
	Kevin Wagner
	Elijah Malaby
	John Casey

	Omptimizing SDH histograms for input larger then global memory
   ==================================================================
*/


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


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

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

unsigned long long * histogram;		/* list of all buckets in the histogram */
unsigned long long  PDH_acnt;	/* total number of data points */
int block_size;		/* Number of threads per block */
int num_buckets;	/* total number of buckets in the histogram */
float   PDH_res;	/* value of w */
atom * atom_list;	/* list of all data points */
unsigned long long * histogram_GPU;
unsigned long long * temp_histogram_GPU;
atom * atom_list_GPU;

__global__ void kernelSumHistogram( unsigned long long int *InputHists, unsigned long long int *hist, int num_atoms, int num_buckets, int block_size) {
  unsigned long long int tid = threadIdx.x + blockIdx.x * blockDim.x;
  int h_pos = tid;
  unsigned long long int NumberOfSumLoop = 0;
  NumberOfSumLoop = (num_atoms)/block_size + ((num_atoms%block_size) ? 1:0);

  while(h_pos < num_buckets) {
    unsigned long long int tmpAns = 0;
    for(int i=0;i<NumberOfSumLoop;i++){
      tmpAns = tmpAns + *(InputHists+(i*num_buckets)+h_pos);
    }
    hist[h_pos] = tmpAns;
    h_pos += blockDim.x * gridDim.x;
  }
  __syncthreads();
}

__device__ void block_to_block (atom * block_a, atom * block_b, int b_length, unsigned long long * histogram, float resolution) {
  atom me = block_a[threadIdx.x];
  for(int i = 0; i < b_length; i++)
    atomicAdd(&(histogram[(int)(sqrt((me.x_pos - block_b[i].x_pos) * (me.x_pos - block_b[i].x_pos) +
                                     (me.y_pos - block_b[i].y_pos) * (me.y_pos - block_b[i].y_pos) +
                                     (me.z_pos - block_b[i].z_pos) * (me.z_pos - block_b[i].z_pos)) / resolution)]),
              1);
}

 __global__ void GPUKernelFunction (unsigned long long PDH_acnt, float PDH_res, atom * atom_list_GPU, unsigned long long * histogram_GPU, int num_buckets) {

  extern __shared__ unsigned long long SHist[];
	/* assign register values */
	int i, h_pos;
	float dist;
  atom * my_block = &atom_list_GPU[blockIdx.x * blockDim.x];
  atom temp_atom_1 = my_block[threadIdx.x];

  for(h_pos=threadIdx.x; h_pos < num_buckets; h_pos+=blockDim.x)
    SHist[h_pos] = 0;

  __syncthreads();

	/* loop through all points in atom list calculating distance from current point to all further points */
  for (i = threadIdx.x + 1; i < blockDim.x && i+blockIdx.x*blockDim.x < PDH_acnt; i++)
  {
    atom temp_atom_2 = my_block[i];
    dist = sqrt((temp_atom_1.x_pos - temp_atom_2.x_pos) * (temp_atom_1.x_pos - temp_atom_2.x_pos) +
                (temp_atom_1.y_pos - temp_atom_2.y_pos) * (temp_atom_1.y_pos - temp_atom_2.y_pos) +
                (temp_atom_1.z_pos - temp_atom_2.z_pos) * (temp_atom_1.z_pos - temp_atom_2.z_pos));
    h_pos = (int)(dist / PDH_res);
    atomicAdd(&(SHist[h_pos]), 1);
  }
  __syncthreads();
  for(i=blockIdx.x+1; i < gridDim.x-1; i++)
    block_to_block(my_block,
                   &atom_list_GPU[i*blockDim.x],
                   blockDim.x,
                   SHist,
                   PDH_res);
  block_to_block(my_block,
                 &atom_list_GPU[i*blockDim.x],
                 PDH_acnt-i*blockDim.x, // Last block may be small
                 SHist,
                 PDH_res);
  __syncthreads();
  for(h_pos = threadIdx.x; h_pos < num_buckets; h_pos += blockDim.x)
    *(histogram_GPU+(num_buckets*blockIdx.x)+h_pos) += SHist[h_pos];
}

/* print the counts in all buckets of the histogram  */
void output_histogram_GPU(){
	int i;
	unsigned 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]);
		total_cnt += histogram[i];
	  	/* 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("| ");
	}
}

void GPU_baseline() {

  int num_blocks = ((PDH_acnt + block_size)/block_size);
	/* copy histogram to device memory */
	hipMalloc((void**) &histogram_GPU, sizeof(unsigned long long)*num_buckets);
	hipMemset(histogram_GPU, 0, sizeof(unsigned long long)*num_buckets);
	hipMalloc((void**) &temp_histogram_GPU, sizeof(unsigned long long)*num_buckets*num_blocks);
	hipMemset(temp_histogram_GPU, 0, sizeof(unsigned long long)*num_buckets*num_blocks);


	/* copy atom list to device memory */
	hipMalloc((void**) &atom_list_GPU, sizeof(atom) * PDH_acnt);
	hipMemcpy(atom_list_GPU, atom_list, sizeof(atom) * PDH_acnt, hipMemcpyHostToDevice);

	/* start time keeping */
	hipEvent_t start, stop;
	hipEventCreate(&start);
	hipEventCreate(&stop);
	hipEventRecord( start, 0 );

	/* Run Kernel */
	GPUKernelFunction <<<num_blocks, block_size, sizeof(unsigned long long)*num_buckets>>> (PDH_acnt, PDH_res, atom_list_GPU, temp_histogram_GPU, num_buckets);
  hipDeviceSynchronize();
  kernelSumHistogram<<<3, 512>>>(temp_histogram_GPU, histogram_GPU, PDH_acnt, num_buckets, block_size);

	/* stop time keeping */
	hipEventRecord( stop, 0 );
	hipEventSynchronize( stop );
	float elapsedTime;
	hipEventElapsedTime( &elapsedTime, start, stop );

	/* transfer histogram to host memory */
	hipMemcpy(histogram, histogram_GPU, sizeof(unsigned long long)*num_buckets, hipMemcpyDeviceToHost);

	/* print out the histogram */
	output_histogram_GPU();
	elapsedTime = elapsedTime/1000;
	printf( "******** Total Running Time of Kernel = %0.5f sec *******\n", elapsedTime );

	/* free cuda timekeeping */
	hipEventDestroy( start );
	hipEventDestroy( stop );
  hipFree(temp_histogram_GPU);
}

/* Input Validation Function */
bool isNumber(char number[], bool floatingpoint)
{
    for (int i = 0; number[i] != 0; i++)
    {
        //if (number[i] > '9' || number[i] < '0')
        if (!isdigit(number[i]))
		{
			if((number[i] == '.' && floatingpoint))
			{
				floatingpoint = false;
			}
			else
			{
				return false;
			}
		}
    }
    return true;
}


/* Most of this input validation can probably be pulled whenever we hardcode our block size and if we hardcode our bucket width */
int main(int argc, char **argv)
{
	/* input validation */
	if((argc > 3))
	{
		if(((isNumber(argv[1], false) && isNumber(argv[2], true)) && isNumber(argv[3], false)))
		{
			PDH_acnt = atoi(argv[1]);
			PDH_res	 = atof(argv[2]);
			block_size = atoi(argv[3]);
		}
		else
		{
			printf( "Invalid Input Error Invalid Arguments\n Valid input is ./program_name {#of_samples} {bucket_width} {block_size}\n");
			return 0;
		}
	}
	else
	{
		printf( "Invalid Input Error Insufficient Arguments\n Valid input is ./program_name {#of_samples} {bucket_width} {block_size}\n");
		return 0;
	}

	/* allocate memory */
	num_buckets = (int)(BOX_SIZE * 1.732 / PDH_res) + 1;
	histogram = (unsigned long long *)malloc(sizeof(unsigned long long)*num_buckets);
	atom_list = (atom *)malloc(sizeof(atom)*PDH_acnt);

	srand(1);
	/* generate data following a uniform distribution */
	for(int i = 0;  i < PDH_acnt; i++) {
		atom_list[i].x_pos = ((float)(rand()) / RAND_MAX) * BOX_SIZE;
		atom_list[i].y_pos = ((float)(rand()) / RAND_MAX) * BOX_SIZE;
		atom_list[i].z_pos = ((float)(rand()) / RAND_MAX) * BOX_SIZE;
	}

	/* call GPU histrogram compute */
	GPU_baseline();

	/* free memory */
	free(histogram);
	free(atom_list);

	return 0;
}



	.text
	.file	"proj2-wagnerk1.hip"
	.globl	_Z33__device_stub__kernelSumHistogramPyS_iii # -- Begin function _Z33__device_stub__kernelSumHistogramPyS_iii
	.type	_Z33__device_stub__kernelSumHistogramPyS_iii,@function
_Z33__device_stub__kernelSumHistogramPyS_iii: # @_Z33__device_stub__kernelSumHistogramPyS_iii
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$128, %rsp
	.cfi_def_cfa_offset 176
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	32(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	12(%rsp), %rsi
	movl	%edx, (%rsi)
	leaq	8(%rsp), %rdx
	movl	%ecx, (%rdx)
	leaq	4(%rsp), %rcx
	movl	%r8d, (%rcx)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	movq	%rcx, 32(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	24(%rsp), %r12
	leaq	16(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z18kernelSumHistogramPyS_iii, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$144, %rsp
	.cfi_adjust_cfa_offset -144
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	_Z33__device_stub__kernelSumHistogramPyS_iii, .Lfunc_end0-_Z33__device_stub__kernelSumHistogramPyS_iii
	.cfi_endproc
                                        # -- End function
	.globl	_Z32__device_stub__GPUKernelFunctionyfP8atomdescPyi # -- Begin function _Z32__device_stub__GPUKernelFunctionyfP8atomdescPyi
	.type	_Z32__device_stub__GPUKernelFunctionyfP8atomdescPyi,@function
_Z32__device_stub__GPUKernelFunctionyfP8atomdescPyi: # @_Z32__device_stub__GPUKernelFunctionyfP8atomdescPyi
	.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	4(%rsp), %rdi
	movss	%xmm0, (%rdi)
	leaq	32(%rsp), %r8
	movq	%rsi, (%r8)
	leaq	24(%rsp), %rsi
	movq	%rdx, (%rsi)
	movq	%rsp, %rdx
	movl	%ecx, (%rdx)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%r8, 16(%rbx)
	movq	%rsi, 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	$_Z17GPUKernelFunctionyfP8atomdescPyi, %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_end1:
	.size	_Z32__device_stub__GPUKernelFunctionyfP8atomdescPyi, .Lfunc_end1-_Z32__device_stub__GPUKernelFunctionyfP8atomdescPyi
	.cfi_endproc
                                        # -- End function
	.globl	_Z20output_histogram_GPUv       # -- Begin function _Z20output_histogram_GPUv
	.type	_Z20output_histogram_GPUv,@function
_Z20output_histogram_GPUv:              # @_Z20output_histogram_GPUv
	.cfi_startproc
# %bb.0:
	cmpl	$0, num_buckets(%rip)
	jle	.LBB2_9
# %bb.1:                                # %.lr.ph.preheader
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movl	$3435973837, %r15d              # imm = 0xCCCCCCCD
	xorl	%ebx, %ebx
	xorl	%r14d, %r14d
.LBB2_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movl	%ebx, %eax
	imulq	%r15, %rax
	shrq	$34, %rax
	leal	(%rax,%rax,4), %eax
	cmpl	%eax, %ebx
	jne	.LBB2_4
# %bb.3:                                #   in Loop: Header=BB2_2 Depth=1
	movl	$.L.str, %edi
	movl	%ebx, %esi
	xorl	%eax, %eax
	callq	printf
.LBB2_4:                                #   in Loop: Header=BB2_2 Depth=1
	movq	histogram(%rip), %rax
	movq	(%rax,%rbx,8), %rsi
	movl	$.L.str.1, %edi
	xorl	%eax, %eax
	callq	printf
	movq	histogram(%rip), %rax
	addq	(%rax,%rbx,8), %r14
	movl	num_buckets(%rip), %eax
	decl	%eax
	cmpq	%rax, %rbx
	jne	.LBB2_6
# %bb.5:                                #   in Loop: Header=BB2_2 Depth=1
	movl	$.L.str.2, %edi
	movq	%r14, %rsi
	xorl	%eax, %eax
	callq	printf
	jmp	.LBB2_7
.LBB2_6:                                #   in Loop: Header=BB2_2 Depth=1
	movl	$.L.str.3, %edi
	xorl	%eax, %eax
	callq	printf
.LBB2_7:                                #   in Loop: Header=BB2_2 Depth=1
	incq	%rbx
	movslq	num_buckets(%rip), %rax
	cmpq	%rax, %rbx
	jl	.LBB2_2
# %bb.8:
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	.cfi_restore %rbx
	.cfi_restore %r14
	.cfi_restore %r15
.LBB2_9:                                # %._crit_edge
	retq
.Lfunc_end2:
	.size	_Z20output_histogram_GPUv, .Lfunc_end2-_Z20output_histogram_GPUv
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function _Z12GPU_baselinev
.LCPI3_0:
	.long	0x447a0000                      # float 1000
	.text
	.globl	_Z12GPU_baselinev
	.type	_Z12GPU_baselinev,@function
_Z12GPU_baselinev:                      # @_Z12GPU_baselinev
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	subq	$32, %rsp
	.cfi_def_cfa_offset 64
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movabsq	$4294967296, %rbx               # imm = 0x100000000
	movslq	block_size(%rip), %rcx
	movq	PDH_acnt(%rip), %rax
	addq	%rcx, %rax
	xorl	%edx, %edx
	divq	%rcx
	movq	%rax, %r14
	movslq	num_buckets(%rip), %rsi
	shlq	$3, %rsi
	movl	$histogram_GPU, %edi
	callq	hipMalloc
	movq	histogram_GPU(%rip), %rdi
	movslq	num_buckets(%rip), %rdx
	shlq	$3, %rdx
	xorl	%esi, %esi
	callq	hipMemset
	movslq	num_buckets(%rip), %rsi
	movslq	%r14d, %r15
	leaq	(,%r15,8), %r14
	imulq	%r14, %rsi
	movl	$temp_histogram_GPU, %edi
	callq	hipMalloc
	movq	temp_histogram_GPU(%rip), %rdi
	movslq	num_buckets(%rip), %rdx
	imulq	%r14, %rdx
	xorl	%esi, %esi
	callq	hipMemset
	movq	PDH_acnt(%rip), %rax
	shlq	$2, %rax
	leaq	(%rax,%rax,2), %rsi
	movl	$atom_list_GPU, %edi
	callq	hipMalloc
	movq	atom_list_GPU(%rip), %rdi
	movq	atom_list(%rip), %rsi
	movq	PDH_acnt(%rip), %rax
	shlq	$2, %rax
	leaq	(%rax,%rax,2), %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	leaq	16(%rsp), %r14
	movq	%r14, %rdi
	callq	hipEventCreate
	leaq	8(%rsp), %rdi
	callq	hipEventCreate
	movq	(%r14), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movl	block_size(%rip), %edx
	movslq	num_buckets(%rip), %r8
	shlq	$3, %r8
	movl	%r15d, %edi
	btsq	$32, %rdi
	btsq	$32, %rdx
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB3_2
# %bb.1:
	movq	PDH_acnt(%rip), %rdi
	movss	PDH_res(%rip), %xmm0            # xmm0 = mem[0],zero,zero,zero
	movq	atom_list_GPU(%rip), %rsi
	movq	temp_histogram_GPU(%rip), %rdx
	movl	num_buckets(%rip), %ecx
	callq	_Z32__device_stub__GPUKernelFunctionyfP8atomdescPyi
.LBB3_2:
	callq	hipDeviceSynchronize
	leaq	3(%rbx), %rdi
	addq	$512, %rbx                      # imm = 0x200
	movl	$1, %esi
	movq	%rbx, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB3_4
# %bb.3:
	movq	temp_histogram_GPU(%rip), %rdi
	movq	histogram_GPU(%rip), %rsi
	movl	PDH_acnt(%rip), %edx
	movl	num_buckets(%rip), %ecx
	movl	block_size(%rip), %r8d
	callq	_Z33__device_stub__kernelSumHistogramPyS_iii
.LBB3_4:
	movq	8(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	8(%rsp), %rdi
	callq	hipEventSynchronize
	movq	16(%rsp), %rsi
	movq	8(%rsp), %rdx
	leaq	28(%rsp), %rbx
	movq	%rbx, %rdi
	callq	hipEventElapsedTime
	movq	histogram(%rip), %rdi
	movq	histogram_GPU(%rip), %rsi
	movslq	num_buckets(%rip), %rdx
	shlq	$3, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	callq	_Z20output_histogram_GPUv
	movss	(%rbx), %xmm0                   # xmm0 = mem[0],zero,zero,zero
	divss	.LCPI3_0(%rip), %xmm0
	movss	%xmm0, (%rbx)
	cvtss2sd	%xmm0, %xmm0
	movl	$.L.str.4, %edi
	movb	$1, %al
	callq	printf
	movq	16(%rsp), %rdi
	callq	hipEventDestroy
	movq	8(%rsp), %rdi
	callq	hipEventDestroy
	movq	temp_histogram_GPU(%rip), %rdi
	callq	hipFree
	addq	$32, %rsp
	.cfi_def_cfa_offset 32
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end3:
	.size	_Z12GPU_baselinev, .Lfunc_end3-_Z12GPU_baselinev
	.cfi_endproc
                                        # -- End function
	.globl	_Z8isNumberPcb                  # -- Begin function _Z8isNumberPcb
	.type	_Z8isNumberPcb,@function
_Z8isNumberPcb:                         # @_Z8isNumberPcb
	.cfi_startproc
# %bb.0:
	movb	(%rdi), %cl
	testb	%cl, %cl
	je	.LBB4_1
# %bb.3:                                # %.lr.ph.preheader
	incq	%rdi
.LBB4_4:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movsbl	%cl, %eax
	addl	$-48, %eax
	cmpl	$10, %eax
	jae	.LBB4_6
# %bb.5:                                #   in Loop: Header=BB4_4 Depth=1
	movl	%esi, %eax
	jmp	.LBB4_8
.LBB4_6:                                #   in Loop: Header=BB4_4 Depth=1
	xorl	%eax, %eax
	cmpb	$46, %cl
	jne	.LBB4_2
# %bb.7:                                #   in Loop: Header=BB4_4 Depth=1
	andb	$1, %sil
	je	.LBB4_2
.LBB4_8:                                #   in Loop: Header=BB4_4 Depth=1
	movb	(%rdi), %cl
	incq	%rdi
	movl	%eax, %esi
	testb	%cl, %cl
	jne	.LBB4_4
.LBB4_1:
	movb	$1, %al
.LBB4_2:                                # %._crit_edge
                                        # kill: def $al killed $al killed $eax
	retq
.Lfunc_end4:
	.size	_Z8isNumberPcb, .Lfunc_end4-_Z8isNumberPcb
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI5_0:
	.quad	0x40e3738000000000              # double 39836
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0
.LCPI5_1:
	.long	0x30000000                      # float 4.65661287E-10
.LCPI5_2:
	.long	0x46b3b000                      # float 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	%rbx
	.cfi_def_cfa_offset 32
	subq	$16, %rsp
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	cmpl	$4, %edi
	jl	.LBB5_20
# %bb.1:
	movq	8(%rsi), %rdi
	movb	(%rdi), %cl
	testb	%cl, %cl
	je	.LBB5_5
# %bb.2:                                # %.lr.ph.i.preheader
	leaq	1(%rdi), %rax
.LBB5_3:                                # %.lr.ph.i
                                        # =>This Inner Loop Header: Depth=1
	movsbl	%cl, %ecx
	addl	$-48, %ecx
	cmpl	$9, %ecx
	ja	.LBB5_21
# %bb.4:                                #   in Loop: Header=BB5_3 Depth=1
	movb	(%rax), %cl
	incq	%rax
	testb	%cl, %cl
	jne	.LBB5_3
.LBB5_5:                                # %.loopexit49
	movq	16(%rsi), %rbx
	movb	(%rbx), %dl
	testb	%dl, %dl
	je	.LBB5_12
# %bb.6:                                # %.lr.ph.i17.preheader
	leaq	1(%rbx), %rax
	movb	$1, %cl
.LBB5_7:                                # %.lr.ph.i17
                                        # =>This Inner Loop Header: Depth=1
	movsbl	%dl, %r8d
	addl	$-48, %r8d
	cmpl	$10, %r8d
	jb	.LBB5_11
# %bb.8:                                #   in Loop: Header=BB5_7 Depth=1
	cmpb	$46, %dl
	jne	.LBB5_21
# %bb.9:                                #   in Loop: Header=BB5_7 Depth=1
	andb	$1, %cl
	je	.LBB5_21
# %bb.10:                               #   in Loop: Header=BB5_7 Depth=1
	xorl	%ecx, %ecx
.LBB5_11:                               #   in Loop: Header=BB5_7 Depth=1
	movb	(%rax), %dl
	incq	%rax
	testb	%dl, %dl
	jne	.LBB5_7
.LBB5_12:                               # %.loopexit47
	movq	24(%rsi), %r14
	movb	(%r14), %cl
	testb	%cl, %cl
	je	.LBB5_16
# %bb.13:                               # %.lr.ph.i31.preheader
	leaq	1(%r14), %rax
.LBB5_14:                               # %.lr.ph.i31
                                        # =>This Inner Loop Header: Depth=1
	movsbl	%cl, %ecx
	addl	$-48, %ecx
	cmpl	$9, %ecx
	ja	.LBB5_21
# %bb.15:                               #   in Loop: Header=BB5_14 Depth=1
	movb	(%rax), %cl
	incq	%rax
	testb	%cl, %cl
	jne	.LBB5_14
.LBB5_16:                               # %.loopexit
	callq	atoi
	movslq	%eax, %r15
	movq	%r15, PDH_acnt(%rip)
	movq	%rbx, %rdi
	callq	atof
	cvtsd2ss	%xmm0, %xmm0
	movss	%xmm0, 12(%rsp)                 # 4-byte Spill
	movss	%xmm0, PDH_res(%rip)
	movq	%r14, %rdi
	callq	atoi
	movl	%eax, block_size(%rip)
	xorps	%xmm0, %xmm0
	cvtss2sd	12(%rsp), %xmm0                 # 4-byte Folded Reload
	movsd	.LCPI5_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	$2, %r15
	leaq	(%r15,%r15,2), %rdi
	callq	malloc
	movq	%rax, atom_list(%rip)
	movl	$1, %edi
	callq	srand
	cmpq	$0, PDH_acnt(%rip)
	je	.LBB5_19
# %bb.17:                               # %.lr.ph.preheader
	xorl	%ebx, %ebx
	xorl	%r14d, %r14d
.LBB5_18:                               # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	callq	rand
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	movss	.LCPI5_1(%rip), %xmm1           # xmm1 = mem[0],zero,zero,zero
	mulss	%xmm1, %xmm0
	movss	.LCPI5_2(%rip), %xmm1           # xmm1 = mem[0],zero,zero,zero
	mulss	%xmm1, %xmm0
	movq	atom_list(%rip), %rax
	movss	%xmm0, (%rax,%rbx)
	callq	rand
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	mulss	.LCPI5_1(%rip), %xmm0
	mulss	.LCPI5_2(%rip), %xmm0
	movq	atom_list(%rip), %rax
	movss	%xmm0, 4(%rax,%rbx)
	callq	rand
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	mulss	.LCPI5_1(%rip), %xmm0
	mulss	.LCPI5_2(%rip), %xmm0
	movq	atom_list(%rip), %rax
	movss	%xmm0, 8(%rax,%rbx)
	incq	%r14
	addq	$12, %rbx
	cmpq	%r14, PDH_acnt(%rip)
	ja	.LBB5_18
.LBB5_19:                               # %._crit_edge
	callq	_Z12GPU_baselinev
	movq	histogram(%rip), %rdi
	callq	free
	movq	atom_list(%rip), %rdi
	callq	free
	jmp	.LBB5_23
.LBB5_20:
	movl	$.Lstr, %edi
	jmp	.LBB5_22
.LBB5_21:                               # %_Z8isNumberPcb.exit
	movl	$.Lstr.1, %edi
.LBB5_22:
	callq	puts@PLT
.LBB5_23:
	xorl	%eax, %eax
	addq	$16, %rsp
	.cfi_def_cfa_offset 32
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_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	$_Z18kernelSumHistogramPyS_iii, %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	$_Z17GPUKernelFunctionyfP8atomdescPyi, %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_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	block_size,@object              # @block_size
	.globl	block_size
	.p2align	2, 0x0
block_size:
	.long	0                               # 0x0
	.size	block_size, 4

	.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	2, 0x0
PDH_res:
	.long	0x00000000                      # float 0
	.size	PDH_res, 4

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

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

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

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

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

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

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

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

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

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

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"******** Total Running Time of Kernel = %0.5f sec *******\n"
	.size	.L.str.4, 59

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z18kernelSumHistogramPyS_iii"
	.size	.L__unnamed_1, 30

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

	.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	"Invalid Input Error Insufficient Arguments\n Valid input is ./program_name {#of_samples} {bucket_width} {block_size}"
	.size	.Lstr, 116

	.type	.Lstr.1,@object                 # @str.1
.Lstr.1:
	.asciz	"Invalid Input Error Invalid Arguments\n Valid input is ./program_name {#of_samples} {bucket_width} {block_size}"
	.size	.Lstr.1, 111

	.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 _Z33__device_stub__kernelSumHistogramPyS_iii
	.addrsig_sym _Z32__device_stub__GPUKernelFunctionyfP8atomdescPyi
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym histogram_GPU
	.addrsig_sym temp_histogram_GPU
	.addrsig_sym atom_list_GPU
	.addrsig_sym _Z18kernelSumHistogramPyS_iii
	.addrsig_sym _Z17GPUKernelFunctionyfP8atomdescPyi
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z18kernelSumHistogramPyS_iii ; -- Begin function _Z18kernelSumHistogramPyS_iii
	.globl	_Z18kernelSumHistogramPyS_iii
	.p2align	8
	.type	_Z18kernelSumHistogramPyS_iii,@function
_Z18kernelSumHistogramPyS_iii:          ; @_Z18kernelSumHistogramPyS_iii
; %bb.0:
	s_clause 0x1
	s_load_b32 s8, s[0:1], 0x2c
	s_load_b128 s[4:7], s[0:1], 0x10
	s_add_u32 s2, s0, 32
	s_addc_u32 s3, s1, 0
	s_waitcnt lgkmcnt(0)
	s_mov_b32 s7, exec_lo
	s_and_b32 s12, s8, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s15, s12, v[0:1]
	v_cmpx_gt_i32_e64 s5, v1
	s_cbranch_execz .LBB0_6
; %bb.1:                                ; %.preheader.lr.ph
	s_ashr_i32 s8, s6, 31
	s_ashr_i32 s13, s4, 31
	s_add_i32 s9, s6, s8
	s_add_i32 s14, s4, s13
	s_xor_b32 s9, s9, s8
	s_xor_b32 s14, s14, s13
	v_cvt_f32_u32_e32 v0, s9
	s_sub_i32 s11, 0, s9
	s_xor_b32 s8, s13, s8
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	v_rcp_iflag_f32_e32 v0, v0
	s_waitcnt_depctr 0xfff
	v_mul_f32_e32 v0, 0x4f7ffffe, v0
	v_cvt_u32_f32_e32 v0, v0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_readfirstlane_b32 s10, v0
	s_mul_i32 s11, s11, s10
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_mul_hi_u32 s11, s10, s11
	s_add_i32 s10, s10, s11
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_mul_hi_u32 s10, s14, s10
	s_mul_i32 s11, s10, s9
	s_add_i32 s13, s10, 1
	s_sub_i32 s11, s14, s11
	s_delay_alu instid0(SALU_CYCLE_1)
	s_sub_i32 s14, s11, s9
	s_cmp_ge_u32 s11, s9
	s_cselect_b32 s10, s13, s10
	s_cselect_b32 s11, s14, s11
	s_add_i32 s13, s10, 1
	s_cmp_ge_u32 s11, s9
	s_cselect_b32 s9, s13, s10
	s_load_b32 s13, s[2:3], 0x0
	s_xor_b32 s9, s9, s8
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_2) | instid1(SALU_CYCLE_1)
	s_sub_i32 s2, s9, s8
	s_load_b128 s[8:11], s[0:1], 0x0
	s_mul_i32 s3, s2, s6
	s_sub_i32 s0, s4, s3
	s_mov_b32 s4, 0
	s_cmp_lg_u32 s0, 0
	s_cselect_b32 s0, -1, 0
	s_delay_alu instid0(SALU_CYCLE_1)
	s_cmp_lg_u32 s0, 0
	s_addc_u32 s1, s2, 0
	s_mov_b32 s2, s5
	s_cmp_lg_u32 s1, 0
	s_cselect_b32 s6, -1, 0
	s_ashr_i32 s3, s5, 31
	s_waitcnt lgkmcnt(0)
	s_mul_i32 s12, s13, s12
	s_lshl_b64 s[2:3], s[2:3], 3
.LBB0_2:                                ; %.preheader
                                        ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB0_4 Depth 2
	v_ashrrev_i32_e32 v2, 31, v1
	v_mov_b32_e32 v4, 0
	v_mov_b32_e32 v5, 0
	s_and_not1_b32 vcc_lo, exec_lo, s6
	s_delay_alu instid0(VALU_DEP_3)
	v_lshlrev_b64 v[2:3], 3, v[1:2]
	s_cbranch_vccnz .LBB0_5
; %bb.3:                                ; %.lr.ph
                                        ;   in Loop: Header=BB0_2 Depth=1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v6, vcc_lo, s8, v2
	v_add_co_ci_u32_e32 v7, vcc_lo, s9, v3, vcc_lo
	s_mov_b32 s0, s1
.LBB0_4:                                ;   Parent Loop BB0_2 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	global_load_b64 v[8:9], v[6:7], off
	v_add_co_u32 v6, vcc_lo, v6, s2
	v_add_co_ci_u32_e32 v7, vcc_lo, s3, v7, vcc_lo
	s_add_i32 s0, s0, -1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_cmp_eq_u32 s0, 0
	s_waitcnt vmcnt(0)
	v_add_co_u32 v4, vcc_lo, v8, v4
	v_add_co_ci_u32_e32 v5, vcc_lo, v9, v5, vcc_lo
	s_cbranch_scc0 .LBB0_4
.LBB0_5:                                ; %._crit_edge
                                        ;   in Loop: Header=BB0_2 Depth=1
	v_add_nc_u32_e32 v1, s12, v1
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_co_u32 v2, s0, s10, v2
	v_add_co_ci_u32_e64 v3, s0, s11, v3, s0
	s_delay_alu instid0(VALU_DEP_3) | instskip(SKIP_2) | instid1(SALU_CYCLE_1)
	v_cmp_le_i32_e32 vcc_lo, s5, v1
	global_store_b64 v[2:3], v[4:5], off
	s_or_b32 s4, vcc_lo, s4
	s_and_not1_b32 exec_lo, exec_lo, s4
	s_cbranch_execnz .LBB0_2
.LBB0_6:                                ; %Flow46
	s_or_b32 exec_lo, exec_lo, s7
	s_waitcnt_vscnt null, 0x0
	s_barrier
	buffer_gl0_inv
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z18kernelSumHistogramPyS_iii
		.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 10
		.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	_Z18kernelSumHistogramPyS_iii, .Lfunc_end0-_Z18kernelSumHistogramPyS_iii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 472
; NumSgprs: 18
; NumVgprs: 10
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 10
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.protected	_Z17GPUKernelFunctionyfP8atomdescPyi ; -- Begin function _Z17GPUKernelFunctionyfP8atomdescPyi
	.globl	_Z17GPUKernelFunctionyfP8atomdescPyi
	.p2align	8
	.type	_Z17GPUKernelFunctionyfP8atomdescPyi,@function
_Z17GPUKernelFunctionyfP8atomdescPyi:   ; @_Z17GPUKernelFunctionyfP8atomdescPyi
; %bb.0:
	s_clause 0x3
	s_load_b32 s2, s[0:1], 0x34
	s_load_b128 s[4:7], s[0:1], 0x10
	s_load_b32 s12, s[0:1], 0x20
	s_load_b32 s10, s[0:1], 0x28
	s_waitcnt lgkmcnt(0)
	s_and_b32 s3, s2, 0xffff
	v_cmp_gt_i32_e64 s2, s12, v0
	s_mul_i32 s11, s15, s3
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_3) | instid1(SALU_CYCLE_1)
	s_mul_i32 s17, s11, 12
	s_mul_hi_u32 s16, s11, 12
	s_add_u32 s8, s4, s17
	s_addc_u32 s9, s5, s16
	v_mad_u64_u32 v[4:5], null, v0, 12, s[8:9]
	s_mov_b32 s9, 0
	global_load_b96 v[1:3], v[4:5], off
	s_and_saveexec_b32 s8, s2
	s_cbranch_execz .LBB1_3
; %bb.1:                                ; %.lr.ph.preheader
	v_lshl_add_u32 v8, v0, 3, 0
	v_dual_mov_b32 v6, 0 :: v_dual_mov_b32 v9, v0
	s_lshl_b32 s13, s3, 3
.LBB1_2:                                ; %.lr.ph
                                        ; =>This Inner Loop Header: Depth=1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_nc_u32_e32 v9, s3, v9
	v_mov_b32_e32 v7, v6
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_3) | instid1(SALU_CYCLE_1)
	v_cmp_le_i32_e32 vcc_lo, s12, v9
	ds_store_b64 v8, v[6:7]
	v_add_nc_u32_e32 v8, s13, v8
	s_or_b32 s9, vcc_lo, s9
	s_and_not1_b32 exec_lo, exec_lo, s9
	s_cbranch_execnz .LBB1_2
.LBB1_3:                                ; %Flow135
	s_or_b32 exec_lo, exec_lo, s8
	s_clause 0x1
	s_load_b64 s[8:9], s[0:1], 0x0
	s_load_b32 s13, s[0:1], 0x8
	v_dual_mov_b32 v7, 0 :: v_dual_add_nc_u32 v8, 1, v0
	s_waitcnt vmcnt(0) lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	v_add_nc_u32_e32 v6, s11, v8
	v_cmp_gt_u32_e64 s0, s3, v8
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_cmp_gt_u64_e32 vcc_lo, s[8:9], v[6:7]
	s_and_b32 s0, s0, vcc_lo
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_saveexec_b32 s14, s0
	s_cbranch_execz .LBB1_6
; %bb.4:                                ; %.lr.ph63.preheader
	s_add_u32 s0, s4, s17
	s_addc_u32 s1, s5, s16
	v_add_nc_u32_e32 v10, 2, v0
	v_mad_u64_u32 v[8:9], null, v0, 12, s[0:1]
	s_mov_b32 s16, 0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v8, vcc_lo, v8, 12
	v_add_co_ci_u32_e32 v9, vcc_lo, 0, v9, vcc_lo
.LBB1_5:                                ; %.lr.ph63
                                        ; =>This Inner Loop Header: Depth=1
	global_load_b96 v[11:13], v[8:9], off
	v_add_co_u32 v8, s1, v8, 12
	s_waitcnt vmcnt(0)
	v_dual_sub_f32 v6, v2, v12 :: v_dual_sub_f32 v11, v1, v11
	v_sub_f32_e32 v12, v3, v13
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_f32_e32 v6, v6, v6
	v_fmac_f32_e32 v6, v11, v11
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fmac_f32_e32 v6, v12, v12
	v_mul_f32_e32 v11, 0x4f800000, v6
	v_cmp_gt_f32_e32 vcc_lo, 0xf800000, v6
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cndmask_b32_e32 v6, v6, v11, vcc_lo
	v_sqrt_f32_e32 v11, v6
	s_waitcnt_depctr 0xfff
	v_add_nc_u32_e32 v12, -1, v11
	v_add_nc_u32_e32 v13, 1, v11
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_fma_f32 v14, -v12, v11, v6
	v_fma_f32 v15, -v13, v11, v6
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cmp_ge_f32_e64 s0, 0, v14
	v_cndmask_b32_e64 v11, v11, v12, s0
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cmp_lt_f32_e64 s0, 0, v15
	v_cndmask_b32_e64 v11, v11, v13, s0
	v_cmp_le_u32_e64 s0, s3, v10
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_f32_e32 v12, 0x37800000, v11
	v_cndmask_b32_e32 v11, v11, v12, vcc_lo
	v_cmp_class_f32_e64 vcc_lo, v6, 0x260
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cndmask_b32_e32 v6, v11, v6, vcc_lo
	v_div_scale_f32 v11, null, s13, s13, v6
	v_div_scale_f32 v14, vcc_lo, v6, s13, v6
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	v_rcp_f32_e32 v12, v11
	s_waitcnt_depctr 0xfff
	v_fma_f32 v13, -v11, v12, 1.0
	v_fmac_f32_e32 v12, v13, v12
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_f32_e32 v13, v14, v12
	v_fma_f32 v15, -v11, v13, v14
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fmac_f32_e32 v13, v15, v12
	v_fma_f32 v11, -v11, v13, v14
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_div_fmas_f32 v11, v11, v12, v13
	v_div_fixup_f32 v6, v11, s13, v6
	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_f32_e32 v6, v6
	v_lshl_add_u32 v6, v6, 3, 0
	ds_add_u64 v6, v[11:12]
	v_add_nc_u32_e32 v6, s11, v10
	v_add_nc_u32_e32 v10, 1, v10
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_3) | instid1(SALU_CYCLE_1)
	v_cmp_le_u64_e32 vcc_lo, s[8:9], v[6:7]
	s_or_b32 s0, s0, vcc_lo
	v_add_co_ci_u32_e64 v9, vcc_lo, 0, v9, s1
	s_and_b32 s0, exec_lo, s0
	s_or_b32 s16, s0, s16
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_not1_b32 exec_lo, exec_lo, s16
	s_cbranch_execnz .LBB1_5
.LBB1_6:                                ; %Flow133
	s_or_b32 exec_lo, exec_lo, s14
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	global_load_b96 v[1:3], v[4:5], off
	s_add_i32 s9, s10, -1
	s_add_i32 s1, s15, 1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_cmp_ge_u32 s1, s9
	s_cbranch_scc1 .LBB1_12
; %bb.7:                                ; %.lr.ph66
	s_cmp_lg_u32 s3, 0
	s_mul_i32 s18, s1, s3
	s_cselect_b32 s14, -1, 0
	s_add_u32 s16, s4, 4
	s_addc_u32 s17, s5, 0
.LBB1_8:                                ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB1_10 Depth 2
	s_and_not1_b32 vcc_lo, exec_lo, s14
	s_cbranch_vccnz .LBB1_11
; %bb.9:                                ; %.lr.ph.i.preheader
                                        ;   in Loop: Header=BB1_8 Depth=1
	s_mul_i32 s0, s18, 12
	s_mul_hi_u32 s11, s18, 12
	s_add_u32 s10, s16, s0
	s_addc_u32 s11, s17, s11
	s_mov_b32 s19, s3
.LBB1_10:                               ; %.lr.ph.i
                                        ;   Parent Loop BB1_8 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	s_add_u32 s20, s10, -4
	s_addc_u32 s21, s11, -1
	s_add_i32 s19, s19, -1
	s_clause 0x1
	s_load_b64 s[20:21], s[20:21], 0x0
	s_load_b32 s0, s[10:11], 0x4
	s_add_u32 s10, s10, 12
	s_addc_u32 s11, s11, 0
	s_cmp_lg_u32 s19, 0
	s_waitcnt vmcnt(0) lgkmcnt(0)
	v_dual_subrev_f32 v4, s21, v2 :: v_dual_subrev_f32 v5, s20, v1
	v_subrev_f32_e32 v6, s0, v3
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_f32_e32 v4, v4, v4
	v_fmac_f32_e32 v4, v5, v5
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fmac_f32_e32 v4, v6, v6
	v_mul_f32_e32 v5, 0x4f800000, v4
	v_cmp_gt_f32_e32 vcc_lo, 0xf800000, v4
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cndmask_b32_e32 v4, v4, v5, vcc_lo
	v_sqrt_f32_e32 v5, v4
	s_waitcnt_depctr 0xfff
	v_add_nc_u32_e32 v6, -1, v5
	v_add_nc_u32_e32 v7, 1, v5
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_fma_f32 v8, -v6, v5, v4
	v_fma_f32 v9, -v7, v5, v4
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cmp_ge_f32_e64 s0, 0, v8
	v_cndmask_b32_e64 v5, v5, v6, s0
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cmp_lt_f32_e64 s0, 0, v9
	v_cndmask_b32_e64 v5, v5, v7, s0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_f32_e32 v6, 0x37800000, v5
	v_cndmask_b32_e32 v5, v5, v6, vcc_lo
	v_cmp_class_f32_e64 vcc_lo, v4, 0x260
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cndmask_b32_e32 v4, v5, v4, vcc_lo
	v_div_scale_f32 v5, null, s13, s13, v4
	v_div_scale_f32 v8, vcc_lo, v4, s13, v4
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	v_rcp_f32_e32 v6, v5
	s_waitcnt_depctr 0xfff
	v_fma_f32 v7, -v5, v6, 1.0
	v_fmac_f32_e32 v6, v7, v6
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_f32_e32 v7, v8, v6
	v_fma_f32 v9, -v5, v7, v8
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fmac_f32_e32 v7, v9, v6
	v_fma_f32 v5, -v5, v7, v8
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_div_fmas_f32 v5, v5, v6, v7
	v_div_fixup_f32 v4, v5, s13, v4
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_3)
	v_cvt_i32_f32_e32 v6, v4
	v_mov_b32_e32 v4, 1
	v_mov_b32_e32 v5, 0
	v_lshl_add_u32 v6, v6, 3, 0
	ds_add_u64 v6, v[4:5]
	s_cbranch_scc1 .LBB1_10
.LBB1_11:                               ; %_Z14block_to_blockP8atomdescS0_iPyf.exit
                                        ;   in Loop: Header=BB1_8 Depth=1
	s_add_i32 s1, s1, 1
	s_add_i32 s18, s18, s3
	s_cmp_lt_u32 s1, s9
	s_cbranch_scc1 .LBB1_8
.LBB1_12:                               ; %._crit_edge67
	s_mul_i32 s0, s1, s3
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_sub_i32 s1, s8, s0
	s_cmp_lt_i32 s1, 1
	s_cbranch_scc1 .LBB1_15
; %bb.13:                               ; %.lr.ph.i52.preheader
	s_mul_i32 s8, s0, 12
	s_mul_hi_u32 s0, s0, 12
	s_add_u32 s4, s8, s4
	s_addc_u32 s0, s0, s5
	s_add_u32 s4, s4, 4
	s_addc_u32 s5, s0, 0
.LBB1_14:                               ; %.lr.ph.i52
                                        ; =>This Inner Loop Header: Depth=1
	s_add_u32 s8, s4, -4
	s_addc_u32 s9, s5, -1
	s_add_i32 s1, s1, -1
	s_clause 0x1
	s_load_b64 s[8:9], s[8:9], 0x0
	s_load_b32 s0, s[4:5], 0x4
	s_add_u32 s4, s4, 12
	s_addc_u32 s5, s5, 0
	s_cmp_lg_u32 s1, 0
	s_waitcnt vmcnt(0) lgkmcnt(0)
	v_dual_subrev_f32 v4, s9, v2 :: v_dual_subrev_f32 v5, s8, v1
	v_subrev_f32_e32 v6, s0, v3
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_f32_e32 v4, v4, v4
	v_fmac_f32_e32 v4, v5, v5
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fmac_f32_e32 v4, v6, v6
	v_mul_f32_e32 v5, 0x4f800000, v4
	v_cmp_gt_f32_e32 vcc_lo, 0xf800000, v4
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cndmask_b32_e32 v4, v4, v5, vcc_lo
	v_sqrt_f32_e32 v5, v4
	s_waitcnt_depctr 0xfff
	v_add_nc_u32_e32 v6, -1, v5
	v_add_nc_u32_e32 v7, 1, v5
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_fma_f32 v8, -v6, v5, v4
	v_fma_f32 v9, -v7, v5, v4
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cmp_ge_f32_e64 s0, 0, v8
	v_cndmask_b32_e64 v5, v5, v6, s0
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cmp_lt_f32_e64 s0, 0, v9
	v_cndmask_b32_e64 v5, v5, v7, s0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_f32_e32 v6, 0x37800000, v5
	v_cndmask_b32_e32 v5, v5, v6, vcc_lo
	v_cmp_class_f32_e64 vcc_lo, v4, 0x260
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cndmask_b32_e32 v4, v5, v4, vcc_lo
	v_div_scale_f32 v5, null, s13, s13, v4
	v_div_scale_f32 v8, vcc_lo, v4, s13, v4
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	v_rcp_f32_e32 v6, v5
	s_waitcnt_depctr 0xfff
	v_fma_f32 v7, -v5, v6, 1.0
	v_fmac_f32_e32 v6, v7, v6
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_f32_e32 v7, v8, v6
	v_fma_f32 v9, -v5, v7, v8
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fmac_f32_e32 v7, v9, v6
	v_fma_f32 v5, -v5, v7, v8
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_div_fmas_f32 v5, v5, v6, v7
	v_div_fixup_f32 v4, v5, s13, v4
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_3)
	v_cvt_i32_f32_e32 v6, v4
	v_mov_b32_e32 v4, 1
	v_mov_b32_e32 v5, 0
	v_lshl_add_u32 v6, v6, 3, 0
	ds_add_u64 v6, v[4:5]
	s_cbranch_scc1 .LBB1_14
.LBB1_15:                               ; %_Z14block_to_blockP8atomdescS0_iPyf.exit55
	s_waitcnt vmcnt(0) lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	s_and_saveexec_b32 s0, s2
	s_cbranch_execz .LBB1_18
; %bb.16:                               ; %.lr.ph69
	s_mul_i32 s0, s15, s12
	s_mov_b32 s1, 0
	v_lshl_add_u32 v2, v0, 3, 0
	s_lshl_b64 s[4:5], s[0:1], 3
	s_delay_alu instid0(SALU_CYCLE_1)
	s_add_u32 s2, s6, s4
	s_addc_u32 s4, s7, s5
	s_lshl_b32 s5, s3, 3
.LBB1_17:                               ; =>This Inner Loop Header: Depth=1
	v_ashrrev_i32_e32 v1, 31, v0
	ds_load_b64 v[7:8], v2
	v_add_nc_u32_e32 v2, s5, v2
	v_lshlrev_b64 v[3:4], 3, v[0:1]
	v_add_nc_u32_e32 v0, s3, v0
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_co_u32 v3, vcc_lo, s2, v3
	v_add_co_ci_u32_e32 v4, vcc_lo, s4, v4, vcc_lo
	s_delay_alu instid0(VALU_DEP_3) | instskip(SKIP_4) | instid1(VALU_DEP_1)
	v_cmp_le_i32_e32 vcc_lo, s12, v0
	global_load_b64 v[5:6], v[3:4], off
	s_or_b32 s1, vcc_lo, s1
	s_waitcnt vmcnt(0) lgkmcnt(0)
	v_add_co_u32 v5, s0, v5, v7
	v_add_co_ci_u32_e64 v6, s0, v6, v8, s0
	global_store_b64 v[3:4], v[5:6], off
	s_and_not1_b32 exec_lo, exec_lo, s1
	s_cbranch_execnz .LBB1_17
.LBB1_18:                               ; %._crit_edge70
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z17GPUKernelFunctionyfP8atomdescPyi
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 296
		.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 22
		.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	_Z17GPUKernelFunctionyfP8atomdescPyi, .Lfunc_end1-_Z17GPUKernelFunctionyfP8atomdescPyi
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 1680
; NumSgprs: 24
; NumVgprs: 16
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 24
; 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
	.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 SHist
	.addrsig_sym __hip_cuid_
	.amdgpu_metadata
---
amdhsa.kernels:
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .offset:         16
        .size:           4
        .value_kind:     by_value
      - .offset:         20
        .size:           4
        .value_kind:     by_value
      - .offset:         24
        .size:           4
        .value_kind:     by_value
      - .offset:         32
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         36
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         40
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         44
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         46
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         48
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         50
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         52
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         54
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         88
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         96
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 288
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z18kernelSumHistogramPyS_iii
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z18kernelSumHistogramPyS_iii.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     10
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
  - .args:
      - .offset:         0
        .size:           8
        .value_kind:     by_value
      - .offset:         8
        .size:           4
        .value_kind:     by_value
      - .address_space:  global
        .offset:         16
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         24
        .size:           8
        .value_kind:     global_buffer
      - .offset:         32
        .size:           4
        .value_kind:     by_value
      - .offset:         40
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         44
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         48
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         52
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         54
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         56
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         58
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         60
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         62
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         88
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         96
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         104
        .size:           2
        .value_kind:     hidden_grid_dims
      - .offset:         160
        .size:           4
        .value_kind:     hidden_dynamic_lds_size
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 296
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z17GPUKernelFunctionyfP8atomdescPyi
    .private_segment_fixed_size: 0
    .sgpr_count:     24
    .sgpr_spill_count: 0
    .symbol:         _Z17GPUKernelFunctionyfP8atomdescPyi.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     16
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
