// Author: Rajiur Rahman ( rajiurrahman.bd@gmail.com )
// Department of Computer Science, Wayne State University
// knn implemented for GPU. 
// have to provide training data, trianing data label, test data, test data label in separate text files. All the files should be ' ' space separated. 

/* 	Instruction for compiling and running 
*	the commands should be following
*		compile - nvcc knn.cu -o knn.o
*		run - ./knn.o numTrainRow numTestRow numCol k
*		
*			For example: 
*			./knn.o 20 5 10 4
*			./knn.o 15997 4000 30000 5
*			./knn_new.o 69 20 1000 5
*/


#include <stdio.h>
#include <stdlib.h>
#include <string.h>     /* strtok() */
#include <sys/types.h>  /* open() */
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>     /* read(), close() */
#include <math.h>
#include <time.h>


/*__global__ void kernel(int *a)
{
    int tidx = threadIdx.x + blockIdx.x * blockDim.x;
    int tidy = threadIdx.y + blockIdx.y * blockDim.y;
}*/

__device__ void showData(float* data, int numRow, int numCol, int tidx){
	for(int i =tidx*numCol; i<((tidx*numCol)+numCol); i++){
		printf("%d-%f\t", i, data[i]);
	}
}

// this function calculates the distance between two rows. 
__device__ float calculate_distance(float* d_trainData, float* d_testData, int numTrainRow, int numTestRow, int numCol, int currentTestIndex, int currentTrainIndex){
	float distance = (float) 100.0;
	for (int i = 0; i<numCol; i++){
		distance += ( d_testData[currentTestIndex*numCol+i] - d_trainData[currentTrainIndex*numCol+i] ) * ( d_testData[currentTestIndex*numCol+i] - d_trainData[currentTrainIndex*numCol+i] );
		
	}
	//distance = distance/(float)numCol;
	//distance = (float)sqrt(distance);
	
	return distance;
}

// this function will return nearest neighbor information for a particular test row. 
// called from main kernel // d_neighborhoodMatrix has size numTestRow*numTrainRow .. it is a flat array 
__device__ float* calculate_distance_matrix(float* d_trainData, float* d_testData, float* d_neighborhoodMatrix, int numTrainRow, int numTestRow, int numCol, int tidx){
	//printf("Dealing with test data row %d\n", tidx);
	for(int i=0; i<numTrainRow; i++){
		//distance form  rows testData[tidx] <--> trainData[i] 
		d_neighborhoodMatrix[tidx*numTrainRow+i] = calculate_distance(d_trainData, d_testData, numTrainRow, numTestRow, numCol, tidx, i); 
	}
	return d_neighborhoodMatrix;
}


// kernel function that will perform k-nearest neighbor classification
// There will be one karnel launched for each row in the test data. 
// This function will manage finding nearest neighbors from test data row to training data 
__global__ void calculate_similarity_matrix(float* d_trainData, float* d_testData, float* d_neighborhoodMatrix, int numTrainRow, int numTestRow, int numCol){
	int tidx = threadIdx.x + blockIdx.x * blockDim.x;
	//printf("Inside Kernel %d\n", tidx);
	//showData(d_testData, numTestRow, numCol, tidx);
	
	//call function for calculating the nearest neighbor of tidx'th row of test data
	d_neighborhoodMatrix = calculate_distance_matrix(d_trainData, d_testData, d_neighborhoodMatrix, numTrainRow, numTestRow, numCol, tidx);
		
}




// this funciton will read the data. It takes parameters file name as string, number of rows and columns.
// It will read a 2-d matrix and save as a flat 1-D array and return the pointer
float* read_data(char* fileName, int numRow, int numCol){
	float* data;
	data = (float*)malloc(numRow*numCol*sizeof(float)); 
	FILE *file;
    file=fopen(fileName, "r");
	for (int i=0; i<numRow*numCol; i++){
		if (!fscanf(file, "%f", &data[i])){
				break;
		}
		//printf("%d-%f\n",i, data[i]); 
	}
	fclose(file);
	return data;
}

void show_data(float* data, int numRow, int numCol){
	/*printf("numrow-%d   numcol-%d\n\n", numRow, numCol);
	for(int i =0; i<numRow*numCol; i++){
		printf("%d-%f\t", i, data[i]);
	}*/
	
	for(int i=0; i< numRow; i++){
		for(int j=0; j<numCol; j++){
			printf("%f  ",data[i*numCol+j]);
		}
		printf("\n");
	}	
}



//comment
__device__ int calculate_nearest_neighbor_index(float* d_neighborhoodMatrix, int tidx, int numTrainRow){
	float minValue = 99999.0;
	int minIndex = 0;
	
	for (int i=(tidx*numTrainRow); i< (tidx*numTrainRow)+numTrainRow; i++){
		if (d_neighborhoodMatrix[i] <= minValue ){
			minValue = d_neighborhoodMatrix[i];
			minIndex = i-(tidx*numTrainRow);
		}
	}
	
	return minIndex;
}

// this function will calculate the nearest neighbors from similarity matrix
// a kernel will be launched for each test instance  
__global__ void calculate_nearest_neighbor(float* d_neighborhoodMatrix, int* d_nearestNeighborIndices, int numTrainRow, int numTestRow, int numCol, int k){
	int tidx = threadIdx.x + blockIdx.x * blockDim.x;
	for(int i=0; i<k; i++){
		int minIndex = calculate_nearest_neighbor_index(d_neighborhoodMatrix, tidx, numTrainRow);
		d_nearestNeighborIndices[tidx*k+i] = minIndex;
		d_neighborhoodMatrix[tidx*numTrainRow+minIndex] = (float)99999.0;		
	}	
	
}

//calculate the label of a test instance
float calculate_label(int* host_nearestNeighborIndices, float* trainLabel, int numTestRow, int numTrainRow, int k, int currentInstance){
	float label = (float)0.0;
	float sum1 = (float)0.0;
	int currentIndex = 0;
	for(int i=0; i<k; i++){
		currentIndex = host_nearestNeighborIndices[currentInstance*k + i];
		//printf("%d - %f\n", currentIndex, trainLabel[currentIndex]);
		sum1 += trainLabel[currentIndex];
		//printf("currentIndex -%d, valueIndex-%f\n",currentIndex, trainLabel[currentIndex]);
	}
	printf("\n");
	//printf("nstance-%d sum-%f\n", currentInstance, sum1);
	
	if(sum1 >= (k/2) ){
		label = (float)1.0;
	}
	return label;
}

//predict class labels of test data from calculated nearest neighbors
float* predict_label(int* host_nearestNeighborIndices, float* trainLabel, int numTestRow, int numTrainRow, int k){
	float* predictedLabel;
	predictedLabel = (float*)malloc( numTestRow*sizeof(float) );
	for(int i=0; i<numTestRow; i++){
		predictedLabel[i] = calculate_label(host_nearestNeighborIndices, trainLabel, numTestRow, numTrainRow, k, i);
		//printf("label prediction of instance %d\n", i);
	}
	
	return predictedLabel;
}

//calculate accuracy of prediction from original class labels and predicted labels
float calculate_accuracy(float* predictedLabel, float* testLabel, int numTestRow){
	int correctPredictionCount = 0;
	for(int i=0; i<numTestRow; i++ ){
		//printf("original %f \t predicted %f\n", testLabel[i], predictedLabel[i]);
		if(predictedLabel[i] == testLabel[i]){
			correctPredictionCount ++;
		}
	}
	//printf("\n\n");
	return (float)100*((float)correctPredictionCount/(float)numTestRow);
}

void show_data_int(int* data, int numRow, int numCol){	
	for(int i=0; i< numRow; i++){
		for(int j=0; j<numCol; j++){
			printf("%d  ",data[i*numCol+j]);
		}
		printf("\n");
	}	
}

void show_data_nearest_neighbor_labels(int* data, float* trainLabel, int numRow, int numCol){	
	for(int i=0; i< numRow; i++){
		for(int j=0; j<numCol; j++){
			printf("%d  ",data[i*numCol+j]);
		}
		printf("\n");
	}	
}

int main(int argc, char* argv[])
{	
	//start the timer
	clock_t begin_time = clock();
	
	// first, catch the arguments from command line 
	int numTrainRow = atoi(argv[1]);
	int numTestRow = atoi(argv[2]);
	int numCol = atoi(argv[3]);
	int k = atoi(argv[4]);
	
	printf("\n**************** Hello World ! ******************\n");

	// read the data files
	float* trainData, *testData, *trainLabel, *trainLabel_1, *testLabel, *predictedLabel;
	trainData = read_data("train.txt", numTrainRow, numCol);	
	testData = read_data("test.txt", numTestRow, numCol);
	trainLabel = read_data("label_train.txt", numTrainRow, 1);
	testLabel = read_data("label_test.txt", numTestRow, 1);
	
	//trainData = read_data("vec_1k_train.txt", numTrainRow, numCol);	
	//testData = read_data("vec_1k_test.txt", numTestRow, numCol);
	//trainLabel = read_data("label_1k_train.txt", numTrainRow, 1);
	//testLabel = read_data("label_1k_test.txt", numTestRow, 1);
	
	printf("Data Read Complete\n");
	
	//show_data(testData, numTestRow, numCol);
	//printf("\n\n\n");
	//show_data(trainLabel, numTrainRow, 1);	
	//printf("\n\n\n");
	
	
	// allocate memory and copy read files to device (GPU) memory from host (CPU) memory
	float *d_trainData, *d_testData, *d_neighborhoodMatrix, *host_neighborhoodMatrix; //neighborhood matrix will have numTestRow rows and numTrainRow columns
	int *d_nearestNeighborIndices, *host_nearestNeighborIndices;		//it has numTestRow rows and k columns 
	const size_t trainSize = sizeof(float) * size_t(numTrainRow*numCol);
	const size_t testSize = sizeof(float) * size_t(numTestRow*numCol);
	const size_t neighborhoodMatrixSize = sizeof(float)*size_t(numTestRow*numTrainRow);
	cudaMalloc((void **)&d_trainData, trainSize);
	cudaMemcpy(d_trainData, trainData, trainSize, cudaMemcpyHostToDevice);
	cudaMalloc((void **)&d_testData, testSize);
	cudaMemcpy(d_testData, testData, testSize, cudaMemcpyHostToDevice);
	cudaMalloc((void **)&d_neighborhoodMatrix, neighborhoodMatrixSize);
	cudaMalloc((void **)&d_nearestNeighborIndices, (numTestRow*k*sizeof(int)) );
		
	calculate_similarity_matrix<<<1,numTestRow>>>(d_trainData, d_testData, d_neighborhoodMatrix, numTrainRow, numTestRow, numCol); 
	cudaFree(d_trainData);
	cudaFree(d_testData);
	printf("Similarity matrix building complete\n");
	
	// copy nearest neighbor matrix from device to CPU and print to view it
	host_neighborhoodMatrix = (float*)malloc(neighborhoodMatrixSize);
	cudaMemcpy(host_neighborhoodMatrix, d_neighborhoodMatrix, neighborhoodMatrixSize, cudaMemcpyDeviceToHost);
	printf("\ncopying similarity matrix from device to host complete\n" );
	//printf("\n\nSimilarity matrix\n");
	show_data(host_neighborhoodMatrix, numTestRow, numTrainRow);
	
	calculate_nearest_neighbor<<<1,numTestRow>>>(d_neighborhoodMatrix, d_nearestNeighborIndices, numTrainRow, numTestRow, numCol, k);
	printf("Nearest Neighbour calculation complete\n");
	
	// copy nearest neighbour indices from device (GPU) to host (CPU)
	host_nearestNeighborIndices = (int*)malloc(numTestRow*k*sizeof(int));
	cudaMemcpy(host_nearestNeighborIndices, d_nearestNeighborIndices, (numTestRow*k*sizeof(int)), cudaMemcpyDeviceToHost);
	
	//printf("\nCopying nearest neighbour indices from device to host complete\n");
	
	//printf("indices of nearest neighbour\n");
	//show_data_int(host_nearestNeighborIndices, numTestRow, k);
	
	predictedLabel = predict_label(host_nearestNeighborIndices, trainLabel, numTestRow, numTrainRow, k);	
	printf("\nClass label prediction complete\n");
	
	//show_data(predictedLabel, numTestRow, 1);
	float acc = calculate_accuracy(predictedLabel, testLabel, numTestRow);
	printf("\nPrediction Accuracy: %f", acc);
	
	
	
	//take the end time and print time taken for running the program
	clock_t end_tiem = clock();
	double diff_time = (end_tiem - begin_time) / CLOCKS_PER_SEC;
	printf("\n\nTime taken for running the program: %lf\n\n", diff_time);
	
	free(testData);
	free(trainData);
	free(host_nearestNeighborIndices);

	free(host_neighborhoodMatrix);
	cudaFree(d_neighborhoodMatrix);
	
	
	return 0;
}




	.file	"tmpxft_0038ebec_00000000-6_knn_new.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2058:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2058:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z8showDataPfiii
	.type	_Z8showDataPfiii, @function
_Z8showDataPfiii:
.LFB2044:
	.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
.LFE2044:
	.size	_Z8showDataPfiii, .-_Z8showDataPfiii
	.globl	_Z18calculate_distancePfS_iiiii
	.type	_Z18calculate_distancePfS_iiiii, @function
_Z18calculate_distancePfS_iiiii:
.LFB2045:
	.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
.LFE2045:
	.size	_Z18calculate_distancePfS_iiiii, .-_Z18calculate_distancePfS_iiiii
	.globl	_Z25calculate_distance_matrixPfS_S_iiii
	.type	_Z25calculate_distance_matrixPfS_S_iiii, @function
_Z25calculate_distance_matrixPfS_S_iiii:
.LFB2046:
	.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
.LFE2046:
	.size	_Z25calculate_distance_matrixPfS_S_iiii, .-_Z25calculate_distance_matrixPfS_S_iiii
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"r"
.LC1:
	.string	"%f"
	.text
	.globl	_Z9read_dataPcii
	.type	_Z9read_dataPcii, @function
_Z9read_dataPcii:
.LFB2047:
	.cfi_startproc
	endbr64
	imull	%edx, %esi
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	.LC1(%rip), %r15
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	xorl	%r13d, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%rdi, %rbp
	movslq	%esi, %rdi
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	%rdi, %r12
	salq	$2, %rdi
	pushq	%rcx
	.cfi_def_cfa_offset 64
	call	malloc@PLT
	movq	%rbp, %rdi
	leaq	.LC0(%rip), %rsi
	movq	%rax, %rbx
	call	fopen@PLT
	movq	%rbx, %r14
	movq	%rax, %rbp
.L9:
	cmpl	%r13d, %r12d
	jle	.L12
	movq	%r14, %rdx
	movq	%r15, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc23_fscanf@PLT
	addq	$4, %r14
	testl	%eax, %eax
	je	.L12
	incl	%r13d
	jmp	.L9
.L12:
	movq	%rbp, %rdi
	call	fclose@PLT
	popq	%rdx
	.cfi_def_cfa_offset 56
	movq	%rbx, %rax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2047:
	.size	_Z9read_dataPcii, .-_Z9read_dataPcii
	.section	.rodata.str1.1
.LC2:
	.string	"%f  "
.LC3:
	.string	"\n"
	.text
	.globl	_Z9show_dataPfii
	.type	_Z9show_dataPfii, @function
_Z9show_dataPfii:
.LFB2048:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movl	%esi, %r14d
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	xorl	%r13d, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	xorl	%r12d, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%rdi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movl	%edx, %ebx
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
.L17:
	cmpl	%r14d, %r13d
	jge	.L16
	movslq	%r12d, %rax
	xorl	%r15d, %r15d
	leaq	0(%rbp,%rax,4), %rcx
.L20:
	cmpl	%r15d, %ebx
	jle	.L22
	leaq	.LC2(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	cvtss2sd	(%rcx,%r15,4), %xmm0
	movq	%rcx, 8(%rsp)
	incq	%r15
	call	__printf_chk@PLT
	movq	8(%rsp), %rcx
	jmp	.L20
.L22:
	leaq	.LC3(%rip), %rsi
	xorl	%eax, %eax
	incl	%r13d
	addl	%ebx, %r12d
	movl	$2, %edi
	call	__printf_chk@PLT
	jmp	.L17
.L16:
	addq	$24, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2048:
	.size	_Z9show_dataPfii, .-_Z9show_dataPfii
	.globl	_Z32calculate_nearest_neighbor_indexPfii
	.type	_Z32calculate_nearest_neighbor_indexPfii, @function
_Z32calculate_nearest_neighbor_indexPfii:
.LFB2049:
	.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
.LFE2049:
	.size	_Z32calculate_nearest_neighbor_indexPfii, .-_Z32calculate_nearest_neighbor_indexPfii
	.globl	_Z15calculate_labelPiPfiiii
	.type	_Z15calculate_labelPiPfiiii, @function
_Z15calculate_labelPiPfiiii:
.LFB2050:
	.cfi_startproc
	endbr64
	imull	%r8d, %r9d
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	xorl	%eax, %eax
	movl	%r8d, %ebx
	xorps	%xmm2, %xmm2
	movslq	%r9d, %r9
	subq	$16, %rsp
	.cfi_def_cfa_offset 32
	leaq	(%rdi,%r9,4), %rdx
.L26:
	cmpl	%eax, %ebx
	jle	.L31
	movslq	(%rdx,%rax,4), %rcx
	incq	%rax
	addss	(%rsi,%rcx,4), %xmm2
	jmp	.L26
.L31:
	leaq	.LC3(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	movss	%xmm2, 12(%rsp)
	call	__printf_chk@PLT
	movl	%ebx, %eax
	movl	$2, %ecx
	movss	12(%rsp), %xmm2
	cltd
	movss	.LC5(%rip), %xmm0
	addq	$16, %rsp
	.cfi_def_cfa_offset 16
	idivl	%ecx
	popq	%rbx
	.cfi_def_cfa_offset 8
	cvtsi2ssl	%eax, %xmm1
	cmpless	%xmm2, %xmm1
	xorps	%xmm2, %xmm2
	andps	%xmm1, %xmm0
	andnps	%xmm2, %xmm1
	orps	%xmm1, %xmm0
	ret
	.cfi_endproc
.LFE2050:
	.size	_Z15calculate_labelPiPfiiii, .-_Z15calculate_labelPiPfiiii
	.globl	_Z13predict_labelPiPfiii
	.type	_Z13predict_labelPiPfiii, @function
_Z13predict_labelPiPfiii:
.LFB2051:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	%r8d, %r15d
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movl	%ecx, %r14d
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%rsi, %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movq	%rdi, %r12
	movslq	%edx, %rdi
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%rdi, %rbp
	salq	$2, %rdi
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	xorl	%ebx, %ebx
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	call	malloc@PLT
.L33:
	cmpl	%ebx, %ebp
	jle	.L36
	movl	%ebx, %r9d
	movl	%r15d, %r8d
	movl	%r14d, %ecx
	movl	%ebp, %edx
	movq	%r13, %rsi
	movq	%r12, %rdi
	movq	%rax, 8(%rsp)
	call	_Z15calculate_labelPiPfiiii
	movq	8(%rsp), %rax
	movss	%xmm0, (%rax,%rbx,4)
	incq	%rbx
	jmp	.L33
.L36:
	addq	$24, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2051:
	.size	_Z13predict_labelPiPfiii, .-_Z13predict_labelPiPfiii
	.globl	_Z18calculate_accuracyPfS_i
	.type	_Z18calculate_accuracyPfS_i, @function
_Z18calculate_accuracyPfS_i:
.LFB2052:
	.cfi_startproc
	endbr64
	xorl	%eax, %eax
	xorl	%ecx, %ecx
.L38:
	cmpl	%eax, %edx
	jle	.L43
	movss	(%rdi,%rax,4), %xmm0
	ucomiss	(%rsi,%rax,4), %xmm0
	jp	.L39
	jne	.L39
	incl	%ecx
.L39:
	incq	%rax
	jmp	.L38
.L43:
	cvtsi2ssl	%ecx, %xmm0
	cvtsi2ssl	%edx, %xmm1
	divss	%xmm1, %xmm0
	mulss	.LC6(%rip), %xmm0
	ret
	.cfi_endproc
.LFE2052:
	.size	_Z18calculate_accuracyPfS_i, .-_Z18calculate_accuracyPfS_i
	.section	.rodata.str1.1
.LC7:
	.string	"%d  "
	.text
	.globl	_Z13show_data_intPiii
	.type	_Z13show_data_intPiii, @function
_Z13show_data_intPiii:
.LFB2053:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movl	%esi, %r14d
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	xorl	%r13d, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	xorl	%r12d, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%rdi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movl	%edx, %ebx
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
.L45:
	cmpl	%r14d, %r13d
	jge	.L44
	movslq	%r12d, %rax
	xorl	%r15d, %r15d
	leaq	0(%rbp,%rax,4), %r8
.L48:
	cmpl	%r15d, %ebx
	jle	.L50
	movl	(%r8,%r15,4), %edx
	leaq	.LC7(%rip), %rsi
	xorl	%eax, %eax
	incq	%r15
	movl	$2, %edi
	movq	%r8, 8(%rsp)
	call	__printf_chk@PLT
	movq	8(%rsp), %r8
	jmp	.L48
.L50:
	leaq	.LC3(%rip), %rsi
	xorl	%eax, %eax
	incl	%r13d
	addl	%ebx, %r12d
	movl	$2, %edi
	call	__printf_chk@PLT
	jmp	.L45
.L44:
	addq	$24, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2053:
	.size	_Z13show_data_intPiii, .-_Z13show_data_intPiii
	.globl	_Z33show_data_nearest_neighbor_labelsPiPfii
	.type	_Z33show_data_nearest_neighbor_labelsPiPfii, @function
_Z33show_data_nearest_neighbor_labelsPiPfii:
.LFB2054:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movl	%edx, %r14d
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	xorl	%r13d, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	xorl	%r12d, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%rdi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movl	%ecx, %ebx
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
.L52:
	cmpl	%r14d, %r13d
	jge	.L51
	movslq	%r12d, %rax
	xorl	%r15d, %r15d
	leaq	0(%rbp,%rax,4), %r8
.L55:
	cmpl	%r15d, %ebx
	jle	.L57
	movl	(%r8,%r15,4), %edx
	leaq	.LC7(%rip), %rsi
	xorl	%eax, %eax
	incq	%r15
	movl	$2, %edi
	movq	%r8, 8(%rsp)
	call	__printf_chk@PLT
	movq	8(%rsp), %r8
	jmp	.L55
.L57:
	leaq	.LC3(%rip), %rsi
	xorl	%eax, %eax
	incl	%r13d
	addl	%ebx, %r12d
	movl	$2, %edi
	call	__printf_chk@PLT
	jmp	.L52
.L51:
	addq	$24, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2054:
	.size	_Z33show_data_nearest_neighbor_labelsPiPfii, .-_Z33show_data_nearest_neighbor_labelsPiPfii
	.globl	_Z54__device_stub__Z27calculate_similarity_matrixPfS_S_iiiPfS_S_iii
	.type	_Z54__device_stub__Z27calculate_similarity_matrixPfS_S_iiiPfS_S_iii, @function
_Z54__device_stub__Z27calculate_similarity_matrixPfS_S_iiiPfS_S_iii:
.LFB2080:
	.cfi_startproc
	endbr64
	subq	$184, %rsp
	.cfi_def_cfa_offset 192
	movq	%rdi, 40(%rsp)
	leaq	72(%rsp), %rdi
	movq	%rsi, 32(%rsp)
	leaq	84(%rsp), %rsi
	movq	%rdx, 24(%rsp)
	leaq	56(%rsp), %rdx
	movl	%ecx, 20(%rsp)
	leaq	64(%rsp), %rcx
	movl	%r8d, 16(%rsp)
	movl	%r9d, 12(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 168(%rsp)
	xorl	%eax, %eax
	leaq	40(%rsp), %rax
	movl	$1, 80(%rsp)
	movq	%rax, 120(%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 128(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 136(%rsp)
	leaq	20(%rsp), %rax
	movq	%rax, 144(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 152(%rsp)
	leaq	12(%rsp), %rax
	movq	%rax, 160(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 72(%rsp)
	movq	%rax, 84(%rsp)
	movl	$1, 92(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L58
	pushq	64(%rsp)
	.cfi_def_cfa_offset 200
	leaq	_Z27calculate_similarity_matrixPfS_S_iii(%rip), %rdi
	pushq	64(%rsp)
	.cfi_def_cfa_offset 208
	movq	100(%rsp), %rcx
	movl	108(%rsp), %r8d
	movq	88(%rsp), %rsi
	movl	96(%rsp), %edx
	leaq	136(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 200
	popq	%rdx
	.cfi_def_cfa_offset 192
.L58:
	movq	168(%rsp), %rax
	subq	%fs:40, %rax
	je	.L60
	call	__stack_chk_fail@PLT
.L60:
	addq	$184, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2080:
	.size	_Z54__device_stub__Z27calculate_similarity_matrixPfS_S_iiiPfS_S_iii, .-_Z54__device_stub__Z27calculate_similarity_matrixPfS_S_iiiPfS_S_iii
	.globl	_Z27calculate_similarity_matrixPfS_S_iii
	.type	_Z27calculate_similarity_matrixPfS_S_iii, @function
_Z27calculate_similarity_matrixPfS_S_iii:
.LFB2081:
	.cfi_startproc
	endbr64
	jmp	_Z54__device_stub__Z27calculate_similarity_matrixPfS_S_iiiPfS_S_iii
	.cfi_endproc
.LFE2081:
	.size	_Z27calculate_similarity_matrixPfS_S_iii, .-_Z27calculate_similarity_matrixPfS_S_iii
	.globl	_Z52__device_stub__Z26calculate_nearest_neighborPfPiiiiiPfPiiiii
	.type	_Z52__device_stub__Z26calculate_nearest_neighborPfPiiiiiPfPiiiii, @function
_Z52__device_stub__Z26calculate_nearest_neighborPfPiiiiiPfPiiiii:
.LFB2082:
	.cfi_startproc
	endbr64
	subq	$168, %rsp
	.cfi_def_cfa_offset 176
	movq	%rdi, 24(%rsp)
	leaq	56(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	68(%rsp), %rsi
	movl	%edx, 12(%rsp)
	leaq	40(%rsp), %rdx
	movl	%ecx, 8(%rsp)
	leaq	48(%rsp), %rcx
	movl	%r8d, 4(%rsp)
	movl	%r9d, (%rsp)
	movq	%fs:40, %rax
	movq	%rax, 152(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 64(%rsp)
	movq	%rax, 104(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	12(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 128(%rsp)
	leaq	4(%rsp), %rax
	movq	%rax, 136(%rsp)
	movq	%rsp, %rax
	movq	%rax, 144(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 56(%rsp)
	movq	%rax, 68(%rsp)
	movl	$1, 76(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L63
	pushq	48(%rsp)
	.cfi_def_cfa_offset 184
	leaq	_Z26calculate_nearest_neighborPfPiiiii(%rip), %rdi
	pushq	48(%rsp)
	.cfi_def_cfa_offset 192
	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 184
	popq	%rdx
	.cfi_def_cfa_offset 176
.L63:
	movq	152(%rsp), %rax
	subq	%fs:40, %rax
	je	.L65
	call	__stack_chk_fail@PLT
.L65:
	addq	$168, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2082:
	.size	_Z52__device_stub__Z26calculate_nearest_neighborPfPiiiiiPfPiiiii, .-_Z52__device_stub__Z26calculate_nearest_neighborPfPiiiiiPfPiiiii
	.globl	_Z26calculate_nearest_neighborPfPiiiii
	.type	_Z26calculate_nearest_neighborPfPiiiii, @function
_Z26calculate_nearest_neighborPfPiiiii:
.LFB2083:
	.cfi_startproc
	endbr64
	jmp	_Z52__device_stub__Z26calculate_nearest_neighborPfPiiiiiPfPiiiii
	.cfi_endproc
.LFE2083:
	.size	_Z26calculate_nearest_neighborPfPiiiii, .-_Z26calculate_nearest_neighborPfPiiiii
	.section	.rodata.str1.1
.LC8:
	.string	"\n**************** Hello World ! ******************\n"
.LC9:
	.string	"train.txt"
.LC10:
	.string	"test.txt"
.LC11:
	.string	"label_train.txt"
.LC12:
	.string	"label_test.txt"
.LC13:
	.string	"Data Read Complete\n"
.LC14:
	.string	"Similarity matrix building complete\n"
.LC15:
	.string	"\ncopying similarity matrix from device to host complete\n"
.LC16:
	.string	"Nearest Neighbour calculation complete\n"
.LC17:
	.string	"\nClass label prediction complete\n"
.LC18:
	.string	"\nPrediction Accuracy: %f"
.LC19:
	.string	"\n\nTime taken for running the program: %lf\n\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2055:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%rsi, %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$120, %rsp
	.cfi_def_cfa_offset 176
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	call	clock@PLT
	movq	8(%r13), %rdi
	movq	%rax, %r15
	call	atoi@PLT
	movq	16(%r13), %rdi
	movl	%eax, %ebp
	call	atoi@PLT
	movq	24(%r13), %rdi
	movl	%eax, %ebx
	call	atoi@PLT
	movq	32(%r13), %rdi
	movl	%ebx, %r13d
	movl	%eax, %r12d
	call	atoi@PLT
	movl	$2, %edi
	leaq	.LC8(%rip), %rsi
	movl	%eax, %r14d
	imull	%r12d, %r13d
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	%r12d, %edx
	movl	%ebp, %esi
	leaq	.LC9(%rip), %rdi
	call	_Z9read_dataPcii
	movl	%r12d, %edx
	movl	%ebx, %esi
	leaq	.LC10(%rip), %rdi
	movq	%rax, 16(%rsp)
	movslq	%r13d, %r13
	call	_Z9read_dataPcii
	movl	$1, %edx
	movl	%ebp, %esi
	salq	$2, %r13
	leaq	.LC11(%rip), %rdi
	movq	%rax, 24(%rsp)
	call	_Z9read_dataPcii
	movl	$1, %edx
	movl	%ebx, %esi
	leaq	.LC12(%rip), %rdi
	movq	%rax, 32(%rsp)
	call	_Z9read_dataPcii
	leaq	.LC13(%rip), %rsi
	movl	$2, %edi
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	%ebp, %edx
	movl	%ebp, %eax
	leaq	48(%rsp), %rdi
	imull	%r12d, %edx
	imull	%ebx, %eax
	movslq	%edx, %rdx
	salq	$2, %rdx
	cltq
	salq	$2, %rax
	movq	%rdx, %rsi
	movq	%rdx, (%rsp)
	movq	%rax, 8(%rsp)
	call	cudaMalloc@PLT
	movq	(%rsp), %rdx
	movq	16(%rsp), %rsi
	movl	$1, %ecx
	movq	48(%rsp), %rdi
	call	cudaMemcpy@PLT
	leaq	56(%rsp), %rdi
	movq	%r13, %rsi
	call	cudaMalloc@PLT
	movq	24(%rsp), %rsi
	movq	56(%rsp), %rdi
	movq	%r13, %rdx
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movq	8(%rsp), %rsi
	leaq	64(%rsp), %rdi
	call	cudaMalloc@PLT
	movl	%ebx, %eax
	leaq	72(%rsp), %rdi
	imull	%r14d, %eax
	cltq
	salq	$2, %rax
	movq	%rax, %rsi
	movq	%rax, (%rsp)
	call	cudaMalloc@PLT
	movl	%ebx, 92(%rsp)
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movabsq	$4294967297, %rdi
	movl	$1, %esi
	movl	$1, 88(%rsp)
	movq	%rdi, 96(%rsp)
	movl	100(%rsp), %ecx
	movq	92(%rsp), %rdx
	movq	%rdi, 80(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L69
	movq	64(%rsp), %rdx
	movq	56(%rsp), %rsi
	movl	%r12d, %r9d
	movl	%ebx, %r8d
	movq	48(%rsp), %rdi
	movl	%ebp, %ecx
	call	_Z54__device_stub__Z27calculate_similarity_matrixPfS_S_iiiPfS_S_iii
.L69:
	movq	48(%rsp), %rdi
	call	cudaFree@PLT
	movq	56(%rsp), %rdi
	call	cudaFree@PLT
	leaq	.LC14(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	8(%rsp), %rdi
	call	malloc@PLT
	movq	8(%rsp), %rdx
	movq	64(%rsp), %rsi
	movl	$2, %ecx
	movq	%rax, %rdi
	movq	%rax, %r13
	call	cudaMemcpy@PLT
	leaq	.LC15(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	%ebp, %edx
	movl	%ebx, %esi
	movq	%r13, %rdi
	call	_Z9show_dataPfii
	movl	%ebx, 92(%rsp)
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movabsq	$4294967297, %rdi
	movl	$1, %esi
	movl	$1, 88(%rsp)
	movq	%rdi, 96(%rsp)
	movl	100(%rsp), %ecx
	movq	92(%rsp), %rdx
	movq	%rdi, 80(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L70
	movq	72(%rsp), %rsi
	movq	64(%rsp), %rdi
	movl	%r14d, %r9d
	movl	%r12d, %r8d
	movl	%ebx, %ecx
	movl	%ebp, %edx
	call	_Z52__device_stub__Z26calculate_nearest_neighborPfPiiiiiPfPiiiii
.L70:
	leaq	.LC16(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	(%rsp), %rdi
	call	malloc@PLT
	movq	(%rsp), %rdx
	movq	72(%rsp), %rsi
	movl	$2, %ecx
	movq	%rax, %rdi
	movq	%rax, %r12
	call	cudaMemcpy@PLT
	movq	32(%rsp), %rsi
	movl	%r14d, %r8d
	movl	%ebp, %ecx
	movl	%ebx, %edx
	movq	%r12, %rdi
	call	_Z13predict_labelPiPfiii
	leaq	.LC17(%rip), %rsi
	movl	$2, %edi
	movq	%rax, %rbp
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	40(%rsp), %rsi
	movl	%ebx, %edx
	movq	%rbp, %rdi
	call	_Z18calculate_accuracyPfS_i
	leaq	.LC18(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	cvtss2sd	%xmm0, %xmm0
	call	__printf_chk@PLT
	call	clock@PLT
	movl	$1000000, %ecx
	movl	$2, %edi
	leaq	.LC19(%rip), %rsi
	subq	%r15, %rax
	cqto
	idivq	%rcx
	cvtsi2sdq	%rax, %xmm0
	movb	$1, %al
	call	__printf_chk@PLT
	movq	24(%rsp), %rdi
	call	free@PLT
	movq	16(%rsp), %rdi
	call	free@PLT
	movq	%r12, %rdi
	call	free@PLT
	movq	%r13, %rdi
	call	free@PLT
	movq	64(%rsp), %rdi
	call	cudaFree@PLT
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	je	.L71
	call	__stack_chk_fail@PLT
.L71:
	addq	$120, %rsp
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2055:
	.size	main, .-main
	.section	.rodata.str1.1
.LC20:
	.string	"_Z26calculate_nearest_neighborPfPiiiii"
.LC21:
	.string	"_Z27calculate_similarity_matrixPfS_S_iii"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2085:
	.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	.LC20(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z26calculate_nearest_neighborPfPiiiii(%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	.LC21(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z27calculate_similarity_matrixPfS_S_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
.LFE2085:
	.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
	.section	.rodata.cst4,"aM",@progbits,4
	.align 4
.LC5:
	.long	1065353216
	.align 4
.LC6:
	.long	1120403456
	.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:

// Author: Rajiur Rahman ( rajiurrahman.bd@gmail.com )
// Department of Computer Science, Wayne State University
// knn implemented for GPU. 
// have to provide training data, trianing data label, test data, test data label in separate text files. All the files should be ' ' space separated. 

/* 	Instruction for compiling and running 
*	the commands should be following
*		compile - nvcc knn.cu -o knn.o
*		run - ./knn.o numTrainRow numTestRow numCol k
*		
*			For example: 
*			./knn.o 20 5 10 4
*			./knn.o 15997 4000 30000 5
*			./knn_new.o 69 20 1000 5
*/



#include <hip/hip_runtime.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>     /* strtok() */
#include <sys/types.h>  /* open() */
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>     /* read(), close() */
#include <math.h>
#include <time.h>


/*__global__ void kernel(int *a)
{
    int tidx = threadIdx.x + blockIdx.x * blockDim.x;
    int tidy = threadIdx.y + blockIdx.y * blockDim.y;
}*/

__device__ void showData(float* data, int numRow, int numCol, int tidx){
	for(int i =tidx*numCol; i<((tidx*numCol)+numCol); i++){
		printf("%d-%f\t", i, data[i]);
	}
}

// this function calculates the distance between two rows. 
__device__ float calculate_distance(float* d_trainData, float* d_testData, int numTrainRow, int numTestRow, int numCol, int currentTestIndex, int currentTrainIndex){
	float distance = (float) 100.0;
	for (int i = 0; i<numCol; i++){
		distance += ( d_testData[currentTestIndex*numCol+i] - d_trainData[currentTrainIndex*numCol+i] ) * ( d_testData[currentTestIndex*numCol+i] - d_trainData[currentTrainIndex*numCol+i] );
		
	}
	//distance = distance/(float)numCol;
	//distance = (float)sqrt(distance);
	
	return distance;
}

// this function will return nearest neighbor information for a particular test row. 
// called from main kernel // d_neighborhoodMatrix has size numTestRow*numTrainRow .. it is a flat array 
__device__ float* calculate_distance_matrix(float* d_trainData, float* d_testData, float* d_neighborhoodMatrix, int numTrainRow, int numTestRow, int numCol, int tidx){
	//printf("Dealing with test data row %d\n", tidx);
	for(int i=0; i<numTrainRow; i++){
		//distance form  rows testData[tidx] <--> trainData[i] 
		d_neighborhoodMatrix[tidx*numTrainRow+i] = calculate_distance(d_trainData, d_testData, numTrainRow, numTestRow, numCol, tidx, i); 
	}
	return d_neighborhoodMatrix;
}


// kernel function that will perform k-nearest neighbor classification
// There will be one karnel launched for each row in the test data. 
// This function will manage finding nearest neighbors from test data row to training data 
__global__ void calculate_similarity_matrix(float* d_trainData, float* d_testData, float* d_neighborhoodMatrix, int numTrainRow, int numTestRow, int numCol){
	int tidx = threadIdx.x + blockIdx.x * blockDim.x;
	//printf("Inside Kernel %d\n", tidx);
	//showData(d_testData, numTestRow, numCol, tidx);
	
	//call function for calculating the nearest neighbor of tidx'th row of test data
	d_neighborhoodMatrix = calculate_distance_matrix(d_trainData, d_testData, d_neighborhoodMatrix, numTrainRow, numTestRow, numCol, tidx);
		
}




// this funciton will read the data. It takes parameters file name as string, number of rows and columns.
// It will read a 2-d matrix and save as a flat 1-D array and return the pointer
float* read_data(char* fileName, int numRow, int numCol){
	float* data;
	data = (float*)malloc(numRow*numCol*sizeof(float)); 
	FILE *file;
    file=fopen(fileName, "r");
	for (int i=0; i<numRow*numCol; i++){
		if (!fscanf(file, "%f", &data[i])){
				break;
		}
		//printf("%d-%f\n",i, data[i]); 
	}
	fclose(file);
	return data;
}

void show_data(float* data, int numRow, int numCol){
	/*printf("numrow-%d   numcol-%d\n\n", numRow, numCol);
	for(int i =0; i<numRow*numCol; i++){
		printf("%d-%f\t", i, data[i]);
	}*/
	
	for(int i=0; i< numRow; i++){
		for(int j=0; j<numCol; j++){
			printf("%f  ",data[i*numCol+j]);
		}
		printf("\n");
	}	
}



//comment
__device__ int calculate_nearest_neighbor_index(float* d_neighborhoodMatrix, int tidx, int numTrainRow){
	float minValue = 99999.0;
	int minIndex = 0;
	
	for (int i=(tidx*numTrainRow); i< (tidx*numTrainRow)+numTrainRow; i++){
		if (d_neighborhoodMatrix[i] <= minValue ){
			minValue = d_neighborhoodMatrix[i];
			minIndex = i-(tidx*numTrainRow);
		}
	}
	
	return minIndex;
}

// this function will calculate the nearest neighbors from similarity matrix
// a kernel will be launched for each test instance  
__global__ void calculate_nearest_neighbor(float* d_neighborhoodMatrix, int* d_nearestNeighborIndices, int numTrainRow, int numTestRow, int numCol, int k){
	int tidx = threadIdx.x + blockIdx.x * blockDim.x;
	for(int i=0; i<k; i++){
		int minIndex = calculate_nearest_neighbor_index(d_neighborhoodMatrix, tidx, numTrainRow);
		d_nearestNeighborIndices[tidx*k+i] = minIndex;
		d_neighborhoodMatrix[tidx*numTrainRow+minIndex] = (float)99999.0;		
	}	
	
}

//calculate the label of a test instance
float calculate_label(int* host_nearestNeighborIndices, float* trainLabel, int numTestRow, int numTrainRow, int k, int currentInstance){
	float label = (float)0.0;
	float sum1 = (float)0.0;
	int currentIndex = 0;
	for(int i=0; i<k; i++){
		currentIndex = host_nearestNeighborIndices[currentInstance*k + i];
		//printf("%d - %f\n", currentIndex, trainLabel[currentIndex]);
		sum1 += trainLabel[currentIndex];
		//printf("currentIndex -%d, valueIndex-%f\n",currentIndex, trainLabel[currentIndex]);
	}
	printf("\n");
	//printf("nstance-%d sum-%f\n", currentInstance, sum1);
	
	if(sum1 >= (k/2) ){
		label = (float)1.0;
	}
	return label;
}

//predict class labels of test data from calculated nearest neighbors
float* predict_label(int* host_nearestNeighborIndices, float* trainLabel, int numTestRow, int numTrainRow, int k){
	float* predictedLabel;
	predictedLabel = (float*)malloc( numTestRow*sizeof(float) );
	for(int i=0; i<numTestRow; i++){
		predictedLabel[i] = calculate_label(host_nearestNeighborIndices, trainLabel, numTestRow, numTrainRow, k, i);
		//printf("label prediction of instance %d\n", i);
	}
	
	return predictedLabel;
}

//calculate accuracy of prediction from original class labels and predicted labels
float calculate_accuracy(float* predictedLabel, float* testLabel, int numTestRow){
	int correctPredictionCount = 0;
	for(int i=0; i<numTestRow; i++ ){
		//printf("original %f \t predicted %f\n", testLabel[i], predictedLabel[i]);
		if(predictedLabel[i] == testLabel[i]){
			correctPredictionCount ++;
		}
	}
	//printf("\n\n");
	return (float)100*((float)correctPredictionCount/(float)numTestRow);
}

void show_data_int(int* data, int numRow, int numCol){	
	for(int i=0; i< numRow; i++){
		for(int j=0; j<numCol; j++){
			printf("%d  ",data[i*numCol+j]);
		}
		printf("\n");
	}	
}

void show_data_nearest_neighbor_labels(int* data, float* trainLabel, int numRow, int numCol){	
	for(int i=0; i< numRow; i++){
		for(int j=0; j<numCol; j++){
			printf("%d  ",data[i*numCol+j]);
		}
		printf("\n");
	}	
}

int main(int argc, char* argv[])
{	
	//start the timer
	clock_t begin_time = clock();
	
	// first, catch the arguments from command line 
	int numTrainRow = atoi(argv[1]);
	int numTestRow = atoi(argv[2]);
	int numCol = atoi(argv[3]);
	int k = atoi(argv[4]);
	
	printf("\n**************** Hello World ! ******************\n");

	// read the data files
	float* trainData, *testData, *trainLabel, *trainLabel_1, *testLabel, *predictedLabel;
	trainData = read_data("train.txt", numTrainRow, numCol);	
	testData = read_data("test.txt", numTestRow, numCol);
	trainLabel = read_data("label_train.txt", numTrainRow, 1);
	testLabel = read_data("label_test.txt", numTestRow, 1);
	
	//trainData = read_data("vec_1k_train.txt", numTrainRow, numCol);	
	//testData = read_data("vec_1k_test.txt", numTestRow, numCol);
	//trainLabel = read_data("label_1k_train.txt", numTrainRow, 1);
	//testLabel = read_data("label_1k_test.txt", numTestRow, 1);
	
	printf("Data Read Complete\n");
	
	//show_data(testData, numTestRow, numCol);
	//printf("\n\n\n");
	//show_data(trainLabel, numTrainRow, 1);	
	//printf("\n\n\n");
	
	
	// allocate memory and copy read files to device (GPU) memory from host (CPU) memory
	float *d_trainData, *d_testData, *d_neighborhoodMatrix, *host_neighborhoodMatrix; //neighborhood matrix will have numTestRow rows and numTrainRow columns
	int *d_nearestNeighborIndices, *host_nearestNeighborIndices;		//it has numTestRow rows and k columns 
	const size_t trainSize = sizeof(float) * size_t(numTrainRow*numCol);
	const size_t testSize = sizeof(float) * size_t(numTestRow*numCol);
	const size_t neighborhoodMatrixSize = sizeof(float)*size_t(numTestRow*numTrainRow);
	hipMalloc((void **)&d_trainData, trainSize);
	hipMemcpy(d_trainData, trainData, trainSize, hipMemcpyHostToDevice);
	hipMalloc((void **)&d_testData, testSize);
	hipMemcpy(d_testData, testData, testSize, hipMemcpyHostToDevice);
	hipMalloc((void **)&d_neighborhoodMatrix, neighborhoodMatrixSize);
	hipMalloc((void **)&d_nearestNeighborIndices, (numTestRow*k*sizeof(int)) );
		
	calculate_similarity_matrix<<<1,numTestRow>>>(d_trainData, d_testData, d_neighborhoodMatrix, numTrainRow, numTestRow, numCol); 
	hipFree(d_trainData);
	hipFree(d_testData);
	printf("Similarity matrix building complete\n");
	
	// copy nearest neighbor matrix from device to CPU and print to view it
	host_neighborhoodMatrix = (float*)malloc(neighborhoodMatrixSize);
	hipMemcpy(host_neighborhoodMatrix, d_neighborhoodMatrix, neighborhoodMatrixSize, hipMemcpyDeviceToHost);
	printf("\ncopying similarity matrix from device to host complete\n" );
	//printf("\n\nSimilarity matrix\n");
	show_data(host_neighborhoodMatrix, numTestRow, numTrainRow);
	
	calculate_nearest_neighbor<<<1,numTestRow>>>(d_neighborhoodMatrix, d_nearestNeighborIndices, numTrainRow, numTestRow, numCol, k);
	printf("Nearest Neighbour calculation complete\n");
	
	// copy nearest neighbour indices from device (GPU) to host (CPU)
	host_nearestNeighborIndices = (int*)malloc(numTestRow*k*sizeof(int));
	hipMemcpy(host_nearestNeighborIndices, d_nearestNeighborIndices, (numTestRow*k*sizeof(int)), hipMemcpyDeviceToHost);
	
	//printf("\nCopying nearest neighbour indices from device to host complete\n");
	
	//printf("indices of nearest neighbour\n");
	//show_data_int(host_nearestNeighborIndices, numTestRow, k);
	
	predictedLabel = predict_label(host_nearestNeighborIndices, trainLabel, numTestRow, numTrainRow, k);	
	printf("\nClass label prediction complete\n");
	
	//show_data(predictedLabel, numTestRow, 1);
	float acc = calculate_accuracy(predictedLabel, testLabel, numTestRow);
	printf("\nPrediction Accuracy: %f", acc);
	
	
	
	//take the end time and print time taken for running the program
	clock_t end_tiem = clock();
	double diff_time = (end_tiem - begin_time) / CLOCKS_PER_SEC;
	printf("\n\nTime taken for running the program: %lf\n\n", diff_time);
	
	free(testData);
	free(trainData);
	free(host_nearestNeighborIndices);

	free(host_neighborhoodMatrix);
	hipFree(d_neighborhoodMatrix);
	
	
	return 0;
}




	.text
	.file	"knn_new.hip"
	.globl	_Z42__device_stub__calculate_similarity_matrixPfS_S_iii # -- Begin function _Z42__device_stub__calculate_similarity_matrixPfS_S_iii
	.type	_Z42__device_stub__calculate_similarity_matrixPfS_S_iii,@function
_Z42__device_stub__calculate_similarity_matrixPfS_S_iii: # @_Z42__device_stub__calculate_similarity_matrixPfS_S_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	$144, %rsp
	.cfi_def_cfa_offset 192
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	56(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	48(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	40(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	20(%rsp), %rdx
	movl	%ecx, (%rdx)
	leaq	16(%rsp), %rcx
	movl	%r8d, (%rcx)
	leaq	12(%rsp), %r8
	movl	%r9d, (%r8)
	leaq	96(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	movq	%rcx, 32(%rbx)
	movq	%r8, 40(%rbx)
	leaq	80(%rsp), %r14
	leaq	64(%rsp), %r15
	leaq	32(%rsp), %r12
	leaq	24(%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	$_Z27calculate_similarity_matrixPfS_S_iii, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$160, %rsp
	.cfi_adjust_cfa_offset -160
	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	_Z42__device_stub__calculate_similarity_matrixPfS_S_iii, .Lfunc_end0-_Z42__device_stub__calculate_similarity_matrixPfS_S_iii
	.cfi_endproc
                                        # -- End function
	.globl	_Z9read_dataPcii                # -- Begin function _Z9read_dataPcii
	.type	_Z9read_dataPcii,@function
_Z9read_dataPcii:                       # @_Z9read_dataPcii
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	%esi, %ebp
	movq	%rdi, %r14
	imull	%edx, %ebp
	movslq	%ebp, %r15
	leaq	(,%r15,4), %rdi
	callq	malloc
	movq	%rax, %rbx
	movl	$.L.str, %esi
	movq	%r14, %rdi
	callq	fopen
	movq	%rax, %r14
	testl	%r15d, %r15d
	jle	.LBB1_4
# %bb.1:                                # %.lr.ph.preheader
	movl	%ebp, %r12d
	decq	%r12
	movq	%rbx, %r15
.LBB1_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movl	$.L.str.1, %esi
	movq	%r14, %rdi
	movq	%r15, %rdx
	xorl	%eax, %eax
	callq	__isoc23_fscanf
	subq	$1, %r12
	setb	%cl
	testl	%eax, %eax
	je	.LBB1_4
# %bb.3:                                # %.lr.ph
                                        #   in Loop: Header=BB1_2 Depth=1
	addq	$4, %r15
	testb	%cl, %cl
	je	.LBB1_2
.LBB1_4:                                # %._crit_edge
	movq	%r14, %rdi
	callq	fclose
	movq	%rbx, %rax
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end1:
	.size	_Z9read_dataPcii, .Lfunc_end1-_Z9read_dataPcii
	.cfi_endproc
                                        # -- End function
	.globl	_Z9show_dataPfii                # -- Begin function _Z9show_dataPfii
	.type	_Z9show_dataPfii,@function
_Z9show_dataPfii:                       # @_Z9show_dataPfii
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rdi, 8(%rsp)                   # 8-byte Spill
	testl	%esi, %esi
	jle	.LBB2_6
# %bb.1:                                # %.preheader.lr.ph
	movl	%edx, %ebx
	movl	%esi, %eax
	movq	%rax, 16(%rsp)                  # 8-byte Spill
	movl	%edx, %r12d
	xorl	%r13d, %r13d
	xorl	%ebp, %ebp
.LBB2_2:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB2_4 Depth 2
	testl	%ebx, %ebx
	jle	.LBB2_5
# %bb.3:                                # %.lr.ph
                                        #   in Loop: Header=BB2_2 Depth=1
	movl	%r13d, %eax
	movq	8(%rsp), %rcx                   # 8-byte Reload
	leaq	(%rcx,%rax,4), %r14
	xorl	%r15d, %r15d
.LBB2_4:                                #   Parent Loop BB2_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	xorps	%xmm0, %xmm0
	cvtss2sd	(%r14,%r15,4), %xmm0
	movl	$.L.str.2, %edi
	movb	$1, %al
	callq	printf
	incq	%r15
	cmpq	%r15, %r12
	jne	.LBB2_4
.LBB2_5:                                # %._crit_edge
                                        #   in Loop: Header=BB2_2 Depth=1
	movl	$10, %edi
	callq	putchar@PLT
	incq	%rbp
	addl	%ebx, %r13d
	cmpq	16(%rsp), %rbp                  # 8-byte Folded Reload
	jne	.LBB2_2
.LBB2_6:                                # %._crit_edge13
	addq	$24, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end2:
	.size	_Z9show_dataPfii, .Lfunc_end2-_Z9show_dataPfii
	.cfi_endproc
                                        # -- End function
	.globl	_Z41__device_stub__calculate_nearest_neighborPfPiiiii # -- Begin function _Z41__device_stub__calculate_nearest_neighborPfPiiiii
	.type	_Z41__device_stub__calculate_nearest_neighborPfPiiiii,@function
_Z41__device_stub__calculate_nearest_neighborPfPiiiii: # @_Z41__device_stub__calculate_nearest_neighborPfPiiiii
	.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)
	movq	%rsp, %r8
	movl	%r9d, (%r8)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	movq	%rcx, 32(%rbx)
	movq	%r8, 40(%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	$_Z26calculate_nearest_neighborPfPiiiii, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$144, %rsp
	.cfi_adjust_cfa_offset -144
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end3:
	.size	_Z41__device_stub__calculate_nearest_neighborPfPiiiii, .Lfunc_end3-_Z41__device_stub__calculate_nearest_neighborPfPiiiii
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function _Z15calculate_labelPiPfiiii
.LCPI4_0:
	.long	0x3f800000                      # float 1
	.text
	.globl	_Z15calculate_labelPiPfiiii
	.type	_Z15calculate_labelPiPfiiii,@function
_Z15calculate_labelPiPfiiii:            # @_Z15calculate_labelPiPfiiii
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$16, %rsp
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -16
	movl	%r8d, %ebx
	testl	%r8d, %r8d
	jle	.LBB4_1
# %bb.3:                                # %.lr.ph
	imull	%ebx, %r9d
	movslq	%r9d, %rcx
	movl	%ebx, %eax
	leaq	(%rdi,%rcx,4), %rcx
	xorps	%xmm0, %xmm0
	xorl	%edx, %edx
.LBB4_4:                                # =>This Inner Loop Header: Depth=1
	movslq	(%rcx,%rdx,4), %rdi
	addss	(%rsi,%rdi,4), %xmm0
	incq	%rdx
	cmpq	%rdx, %rax
	jne	.LBB4_4
	jmp	.LBB4_2
.LBB4_1:
	xorps	%xmm0, %xmm0
.LBB4_2:                                # %._crit_edge
	movss	%xmm0, 12(%rsp)                 # 4-byte Spill
	movl	$10, %edi
	callq	putchar@PLT
	movl	%ebx, %eax
	shrl	$31, %eax
	addl	%ebx, %eax
	sarl	%eax
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	cmpnless	12(%rsp), %xmm0                 # 4-byte Folded Reload
	movss	.LCPI4_0(%rip), %xmm1           # xmm1 = mem[0],zero,zero,zero
	andnps	%xmm1, %xmm0
	addq	$16, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end4:
	.size	_Z15calculate_labelPiPfiiii, .Lfunc_end4-_Z15calculate_labelPiPfiiii
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function _Z13predict_labelPiPfiii
.LCPI5_0:
	.long	0x3f800000                      # float 1
	.text
	.globl	_Z13predict_labelPiPfiii
	.type	_Z13predict_labelPiPfiii,@function
_Z13predict_labelPiPfiii:               # @_Z13predict_labelPiPfiii
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	%r8d, 4(%rsp)                   # 4-byte Spill
	movl	%edx, %r12d
	movq	%rsi, %r14
	movq	%rdi, %r15
	movslq	%edx, %rbx
	leaq	(,%rbx,4), %rdi
	callq	malloc
	movq	%rax, 16(%rsp)                  # 8-byte Spill
	testl	%ebx, %ebx
	jle	.LBB5_7
# %bb.1:                                # %.lr.ph
	movl	4(%rsp), %ecx                   # 4-byte Reload
	movl	%ecx, %r13d
	movl	%ecx, %eax
	shrl	$31, %eax
	addl	%ecx, %eax
	sarl	%eax
	cvtsi2ss	%eax, %xmm0
	movss	%xmm0, 8(%rsp)                  # 4-byte Spill
	movslq	%ecx, %rbp
	movl	%r12d, %ebx
	shlq	$2, %rbp
	xorl	%r12d, %r12d
.LBB5_2:                                # =>This Loop Header: Depth=1
                                        #     Child Loop BB5_5 Depth 2
	cmpl	$0, 4(%rsp)                     # 4-byte Folded Reload
	jle	.LBB5_3
# %bb.4:                                # %.lr.ph.i
                                        #   in Loop: Header=BB5_2 Depth=1
	xorps	%xmm0, %xmm0
	xorl	%eax, %eax
.LBB5_5:                                #   Parent Loop BB5_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movslq	(%r15,%rax,4), %rcx
	addss	(%r14,%rcx,4), %xmm0
	incq	%rax
	cmpq	%rax, %r13
	jne	.LBB5_5
	jmp	.LBB5_6
.LBB5_3:                                #   in Loop: Header=BB5_2 Depth=1
	xorps	%xmm0, %xmm0
.LBB5_6:                                # %_Z15calculate_labelPiPfiiii.exit
                                        #   in Loop: Header=BB5_2 Depth=1
	movss	%xmm0, 12(%rsp)                 # 4-byte Spill
	movl	$10, %edi
	callq	putchar@PLT
	movss	8(%rsp), %xmm0                  # 4-byte Reload
                                        # xmm0 = mem[0],zero,zero,zero
	cmpnless	12(%rsp), %xmm0                 # 4-byte Folded Reload
	movss	.LCPI5_0(%rip), %xmm1           # xmm1 = mem[0],zero,zero,zero
	andnps	%xmm1, %xmm0
	movq	16(%rsp), %rax                  # 8-byte Reload
	movss	%xmm0, (%rax,%r12,4)
	incq	%r12
	addq	%rbp, %r15
	cmpq	%rbx, %r12
	jne	.LBB5_2
.LBB5_7:                                # %._crit_edge
	movq	16(%rsp), %rax                  # 8-byte Reload
	addq	$24, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end5:
	.size	_Z13predict_labelPiPfiii, .Lfunc_end5-_Z13predict_labelPiPfiii
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function _Z18calculate_accuracyPfS_i
.LCPI6_0:
	.long	0x42c80000                      # float 100
	.text
	.globl	_Z18calculate_accuracyPfS_i
	.type	_Z18calculate_accuracyPfS_i,@function
_Z18calculate_accuracyPfS_i:            # @_Z18calculate_accuracyPfS_i
	.cfi_startproc
# %bb.0:
	testl	%edx, %edx
	jle	.LBB6_1
# %bb.4:                                # %.lr.ph.preheader
	movl	%edx, %eax
	xorl	%ecx, %ecx
	xorl	%r8d, %r8d
.LBB6_5:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movss	(%rsi,%rcx,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	cmpeqss	(%rdi,%rcx,4), %xmm0
	movd	%xmm0, %r9d
	subl	%r9d, %r8d
	incq	%rcx
	cmpq	%rcx, %rax
	jne	.LBB6_5
# %bb.2:                                # %._crit_edge.loopexit
	xorps	%xmm0, %xmm0
	cvtsi2ss	%r8d, %xmm0
	jmp	.LBB6_3
.LBB6_1:
	xorps	%xmm0, %xmm0
.LBB6_3:                                # %._crit_edge
	cvtsi2ss	%edx, %xmm1
	divss	%xmm1, %xmm0
	mulss	.LCPI6_0(%rip), %xmm0
	retq
.Lfunc_end6:
	.size	_Z18calculate_accuracyPfS_i, .Lfunc_end6-_Z18calculate_accuracyPfS_i
	.cfi_endproc
                                        # -- End function
	.globl	_Z13show_data_intPiii           # -- Begin function _Z13show_data_intPiii
	.type	_Z13show_data_intPiii,@function
_Z13show_data_intPiii:                  # @_Z13show_data_intPiii
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rdi, 8(%rsp)                   # 8-byte Spill
	testl	%esi, %esi
	jle	.LBB7_6
# %bb.1:                                # %.preheader.lr.ph
	movl	%edx, %ebx
	movl	%esi, %eax
	movq	%rax, 16(%rsp)                  # 8-byte Spill
	movl	%edx, %r12d
	xorl	%ebp, %ebp
	xorl	%r13d, %r13d
.LBB7_2:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB7_4 Depth 2
	testl	%ebx, %ebx
	jle	.LBB7_5
# %bb.3:                                # %.lr.ph
                                        #   in Loop: Header=BB7_2 Depth=1
	movl	%ebp, %eax
	movq	8(%rsp), %rcx                   # 8-byte Reload
	leaq	(%rcx,%rax,4), %r14
	xorl	%r15d, %r15d
.LBB7_4:                                #   Parent Loop BB7_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	(%r14,%r15,4), %esi
	movl	$.L.str.4, %edi
	xorl	%eax, %eax
	callq	printf
	incq	%r15
	cmpq	%r15, %r12
	jne	.LBB7_4
.LBB7_5:                                # %._crit_edge
                                        #   in Loop: Header=BB7_2 Depth=1
	movl	$10, %edi
	callq	putchar@PLT
	incq	%r13
	addl	%ebx, %ebp
	cmpq	16(%rsp), %r13                  # 8-byte Folded Reload
	jne	.LBB7_2
.LBB7_6:                                # %._crit_edge13
	addq	$24, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end7:
	.size	_Z13show_data_intPiii, .Lfunc_end7-_Z13show_data_intPiii
	.cfi_endproc
                                        # -- End function
	.globl	_Z33show_data_nearest_neighbor_labelsPiPfii # -- Begin function _Z33show_data_nearest_neighbor_labelsPiPfii
	.type	_Z33show_data_nearest_neighbor_labelsPiPfii,@function
_Z33show_data_nearest_neighbor_labelsPiPfii: # @_Z33show_data_nearest_neighbor_labelsPiPfii
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rdi, 8(%rsp)                   # 8-byte Spill
	testl	%edx, %edx
	jle	.LBB8_6
# %bb.1:                                # %.preheader.lr.ph
	movl	%ecx, %ebx
	movl	%edx, %eax
	movq	%rax, 16(%rsp)                  # 8-byte Spill
	movl	%ecx, %r12d
	xorl	%ebp, %ebp
	xorl	%r13d, %r13d
.LBB8_2:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB8_4 Depth 2
	testl	%ebx, %ebx
	jle	.LBB8_5
# %bb.3:                                # %.lr.ph
                                        #   in Loop: Header=BB8_2 Depth=1
	movl	%ebp, %eax
	movq	8(%rsp), %rcx                   # 8-byte Reload
	leaq	(%rcx,%rax,4), %r14
	xorl	%r15d, %r15d
.LBB8_4:                                #   Parent Loop BB8_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	(%r14,%r15,4), %esi
	movl	$.L.str.4, %edi
	xorl	%eax, %eax
	callq	printf
	incq	%r15
	cmpq	%r15, %r12
	jne	.LBB8_4
.LBB8_5:                                # %._crit_edge
                                        #   in Loop: Header=BB8_2 Depth=1
	movl	$10, %edi
	callq	putchar@PLT
	incq	%r13
	addl	%ebx, %ebp
	cmpq	16(%rsp), %r13                  # 8-byte Folded Reload
	jne	.LBB8_2
.LBB8_6:                                # %._crit_edge13
	addq	$24, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end8:
	.size	_Z33show_data_nearest_neighbor_labelsPiPfii, .Lfunc_end8-_Z33show_data_nearest_neighbor_labelsPiPfii
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function main
.LCPI9_0:
	.long	0x42c80000                      # float 100
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$88, %rsp
	.cfi_def_cfa_offset 144
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rsi, %rbx
	callq	clock
	movq	%rax, 80(%rsp)                  # 8-byte Spill
	movq	8(%rbx), %rdi
	callq	atoi
	movl	%eax, %r15d
	movq	16(%rbx), %rdi
	callq	atoi
	movl	%eax, %r14d
	movq	24(%rbx), %rdi
	callq	atoi
	movl	%eax, %r13d
	movq	32(%rbx), %rdi
	callq	atoi
	movl	%eax, 12(%rsp)                  # 4-byte Spill
	movl	$.Lstr, %edi
	callq	puts@PLT
	movl	$.L.str.6, %edi
	movl	%r15d, %esi
	movl	%r13d, %edx
	callq	_Z9read_dataPcii
	movq	%rax, 32(%rsp)                  # 8-byte Spill
	movl	$.L.str.7, %edi
	movl	%r14d, %esi
	movl	%r13d, %edx
	callq	_Z9read_dataPcii
	movq	%rax, 24(%rsp)                  # 8-byte Spill
	movl	$.L.str.8, %edi
	movl	%r15d, %esi
	movl	$1, %edx
	callq	_Z9read_dataPcii
	movq	%rax, 72(%rsp)                  # 8-byte Spill
	movl	$.L.str.9, %edi
	movl	%r14d, %esi
	movl	$1, %edx
	callq	_Z9read_dataPcii
	movq	%rax, %r12
	movl	$.Lstr.1, %edi
	callq	puts@PLT
	movl	%r13d, %eax
	imull	%r15d, %eax
	movslq	%eax, %rbp
	shlq	$2, %rbp
	movl	%r13d, 8(%rsp)                  # 4-byte Spill
	imull	%r14d, %r13d
	movslq	%r13d, %rbx
	shlq	$2, %rbx
	movl	%r15d, 4(%rsp)                  # 4-byte Spill
	imull	%r14d, %r15d
	movslq	%r15d, %r15
	shlq	$2, %r15
	leaq	56(%rsp), %r13
	movq	%r13, %rdi
	movq	%rbp, %rsi
	callq	hipMalloc
	movq	(%r13), %rdi
	movq	32(%rsp), %rsi                  # 8-byte Reload
	movq	%rbp, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	leaq	48(%rsp), %r13
	movq	%r13, %rdi
	movq	%rbx, %rsi
	callq	hipMalloc
	movq	(%r13), %rdi
	movq	24(%rsp), %rsi                  # 8-byte Reload
	movq	%rbx, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	leaq	16(%rsp), %rdi
	movq	%r15, %rsi
	callq	hipMalloc
	movl	12(%rsp), %eax                  # 4-byte Reload
	imull	%r14d, %eax
	movslq	%eax, %rbp
	shlq	$2, %rbp
	leaq	40(%rsp), %rdi
	movq	%rbp, %rsi
	callq	hipMalloc
	movl	%r14d, %r14d
	movabsq	$4294967297, %rdi               # imm = 0x100000001
	leaq	(%r14,%rdi), %rbx
	decq	%rbx
	movl	$1, %esi
	movq	%rbx, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB9_2
# %bb.1:
	movq	56(%rsp), %rdi
	movq	48(%rsp), %rsi
	movq	16(%rsp), %rdx
	movl	4(%rsp), %ecx                   # 4-byte Reload
	movl	%r14d, %r8d
	movl	8(%rsp), %r9d                   # 4-byte Reload
	callq	_Z42__device_stub__calculate_similarity_matrixPfS_S_iii
.LBB9_2:
	movq	56(%rsp), %rdi
	callq	hipFree
	movq	48(%rsp), %rdi
	callq	hipFree
	movl	$.Lstr.2, %edi
	callq	puts@PLT
	movq	%r15, %rdi
	callq	malloc
	movq	%rax, %r13
	movq	16(%rsp), %rsi
	movq	%rax, %rdi
	movq	%r15, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	movl	$.Lstr.3, %edi
	callq	puts@PLT
	movq	%r13, 64(%rsp)                  # 8-byte Spill
	movq	%r13, %rdi
	movl	%r14d, %esi
	movl	4(%rsp), %edx                   # 4-byte Reload
	callq	_Z9show_dataPfii
	movabsq	$4294967297, %rdi               # imm = 0x100000001
	movl	$1, %esi
	movq	%rbx, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	movl	12(%rsp), %r15d                 # 4-byte Reload
	jne	.LBB9_4
# %bb.3:
	movq	16(%rsp), %rdi
	movq	40(%rsp), %rsi
	movl	4(%rsp), %edx                   # 4-byte Reload
	movl	%r14d, %ecx
	movl	8(%rsp), %r8d                   # 4-byte Reload
	movl	%r15d, %r9d
	callq	_Z41__device_stub__calculate_nearest_neighborPfPiiiii
.LBB9_4:
	movl	$.Lstr.4, %edi
	callq	puts@PLT
	movq	%rbp, %rdi
	callq	malloc
	movq	%rax, %rbx
	movq	40(%rsp), %rsi
	movq	%rax, %rdi
	movq	%rbp, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	movq	%rbx, %rdi
	movq	72(%rsp), %rsi                  # 8-byte Reload
	movl	%r14d, %edx
	movl	%r15d, %r8d
	callq	_Z13predict_labelPiPfiii
	movq	%rax, %r15
	movl	$.Lstr.5, %edi
	callq	puts@PLT
	testl	%r14d, %r14d
	jle	.LBB9_5
# %bb.6:                                # %.lr.ph.i.preheader
	xorl	%eax, %eax
	xorl	%ecx, %ecx
.LBB9_7:                                # %.lr.ph.i
                                        # =>This Inner Loop Header: Depth=1
	movss	(%r12,%rax,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	cmpeqss	(%r15,%rax,4), %xmm0
	movd	%xmm0, %edx
	subl	%edx, %ecx
	incq	%rax
	cmpq	%rax, %r14
	jne	.LBB9_7
# %bb.8:                                # %._crit_edge.loopexit.i
	xorps	%xmm0, %xmm0
	cvtsi2ss	%ecx, %xmm0
	jmp	.LBB9_9
.LBB9_5:
	xorps	%xmm0, %xmm0
.LBB9_9:                                # %_Z18calculate_accuracyPfS_i.exit
	cvtsi2ss	%r14d, %xmm1
	divss	%xmm1, %xmm0
	mulss	.LCPI9_0(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	movl	$.L.str.15, %edi
	movb	$1, %al
	callq	printf
	callq	clock
	subq	80(%rsp), %rax                  # 8-byte Folded Reload
	movabsq	$4835703278458516699, %rcx      # imm = 0x431BDE82D7B634DB
	imulq	%rcx
	movq	%rdx, %rax
	shrq	$63, %rax
	sarq	$18, %rdx
	addq	%rax, %rdx
	xorps	%xmm0, %xmm0
	cvtsi2sd	%rdx, %xmm0
	movl	$.L.str.16, %edi
	movb	$1, %al
	callq	printf
	movq	24(%rsp), %rdi                  # 8-byte Reload
	callq	free
	movq	32(%rsp), %rdi                  # 8-byte Reload
	callq	free
	movq	%rbx, %rdi
	callq	free
	movq	64(%rsp), %rdi                  # 8-byte Reload
	callq	free
	movq	16(%rsp), %rdi
	callq	hipFree
	xorl	%eax, %eax
	addq	$88, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end9:
	.size	main, .Lfunc_end9-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	.LBB10_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB10_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z27calculate_similarity_matrixPfS_S_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	$_Z26calculate_nearest_neighborPfPiiiii, %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_end10:
	.size	__hip_module_ctor, .Lfunc_end10-__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	.LBB11_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
.LBB11_2:
	retq
.Lfunc_end11:
	.size	__hip_module_dtor, .Lfunc_end11-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	_Z27calculate_similarity_matrixPfS_S_iii,@object # @_Z27calculate_similarity_matrixPfS_S_iii
	.section	.rodata,"a",@progbits
	.globl	_Z27calculate_similarity_matrixPfS_S_iii
	.p2align	3, 0x0
_Z27calculate_similarity_matrixPfS_S_iii:
	.quad	_Z42__device_stub__calculate_similarity_matrixPfS_S_iii
	.size	_Z27calculate_similarity_matrixPfS_S_iii, 8

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"r"
	.size	.L.str, 2

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"%f"
	.size	.L.str.1, 3

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

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

	.type	.L.str.4,@object                # @.str.4
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.4:
	.asciz	"%d  "
	.size	.L.str.4, 5

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"train.txt"
	.size	.L.str.6, 10

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"test.txt"
	.size	.L.str.7, 9

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"label_train.txt"
	.size	.L.str.8, 16

	.type	.L.str.9,@object                # @.str.9
.L.str.9:
	.asciz	"label_test.txt"
	.size	.L.str.9, 15

	.type	.L.str.15,@object               # @.str.15
.L.str.15:
	.asciz	"\nPrediction Accuracy: %f"
	.size	.L.str.15, 25

	.type	.L.str.16,@object               # @.str.16
.L.str.16:
	.asciz	"\n\nTime taken for running the program: %lf\n\n"
	.size	.L.str.16, 44

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z27calculate_similarity_matrixPfS_S_iii"
	.size	.L__unnamed_1, 41

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_Z26calculate_nearest_neighborPfPiiiii"
	.size	.L__unnamed_2, 39

	.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	"\n**************** Hello World ! ******************"
	.size	.Lstr, 51

	.type	.Lstr.1,@object                 # @str.1
.Lstr.1:
	.asciz	"Data Read Complete"
	.size	.Lstr.1, 19

	.type	.Lstr.2,@object                 # @str.2
.Lstr.2:
	.asciz	"Similarity matrix building complete"
	.size	.Lstr.2, 36

	.type	.Lstr.3,@object                 # @str.3
.Lstr.3:
	.asciz	"\ncopying similarity matrix from device to host complete"
	.size	.Lstr.3, 56

	.type	.Lstr.4,@object                 # @str.4
.Lstr.4:
	.asciz	"Nearest Neighbour calculation complete"
	.size	.Lstr.4, 39

	.type	.Lstr.5,@object                 # @str.5
.Lstr.5:
	.asciz	"\nClass label prediction complete"
	.size	.Lstr.5, 33

	.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 _Z42__device_stub__calculate_similarity_matrixPfS_S_iii
	.addrsig_sym _Z41__device_stub__calculate_nearest_neighborPfPiiiii
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z27calculate_similarity_matrixPfS_S_iii
	.addrsig_sym _Z26calculate_nearest_neighborPfPiiiii
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z27calculate_similarity_matrixPfS_S_iii ; -- Begin function _Z27calculate_similarity_matrixPfS_S_iii
	.globl	_Z27calculate_similarity_matrixPfS_S_iii
	.p2align	8
	.type	_Z27calculate_similarity_matrixPfS_S_iii,@function
_Z27calculate_similarity_matrixPfS_S_iii: ; @_Z27calculate_similarity_matrixPfS_S_iii
; %bb.0:
	s_load_b32 s10, s[0:1], 0x18
	s_waitcnt lgkmcnt(0)
	s_cmp_lt_i32 s10, 1
	s_cbranch_scc1 .LBB0_7
; %bb.1:                                ; %.lr.ph.i
	s_clause 0x2
	s_load_b32 s2, s[0:1], 0x34
	s_load_b32 s11, s[0:1], 0x20
	s_load_b128 s[4:7], s[0:1], 0x0
	v_mov_b32_e32 v5, 0
	s_mov_b32 s9, 0
	s_delay_alu instid0(SALU_CYCLE_1)
	s_mov_b32 s8, s9
	s_waitcnt lgkmcnt(0)
	s_and_b32 s2, s2, 0xffff
	s_cmp_gt_i32 s11, 0
	v_mad_u64_u32 v[1:2], null, s15, s2, v[0:1]
	s_load_b64 s[2:3], s[0:1], 0x10
	s_cselect_b32 s0, -1, 0
	s_mov_b32 s1, s9
	v_cndmask_b32_e64 v0, 0, 1, s0
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_3)
	v_mul_lo_u32 v2, v1, s11
	v_mul_lo_u32 v4, v1, s10
	v_cmp_ne_u32_e64 s0, 1, v0
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v3, 31, v2
	v_lshlrev_b64 v[2:3], 2, v[2:3]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v0, vcc_lo, s6, v2
	v_add_co_ci_u32_e32 v1, vcc_lo, s7, v3, vcc_lo
.LBB0_2:                                ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB0_4 Depth 2
	s_and_b32 vcc_lo, exec_lo, s0
	s_cbranch_vccnz .LBB0_5
; %bb.3:                                ; %.lr.ph.i.i
                                        ;   in Loop: Header=BB0_2 Depth=1
	s_delay_alu instid0(VALU_DEP_1)
	v_dual_mov_b32 v6, 0x42c80000 :: v_dual_mov_b32 v3, v1
	s_lshl_b64 s[6:7], s[8:9], 2
	v_mov_b32_e32 v2, v0
	s_add_u32 s6, s4, s6
	s_addc_u32 s7, s5, s7
	s_mov_b32 s12, s11
.LBB0_4:                                ;   Parent Loop BB0_2 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	global_load_b32 v7, v[2:3], off
	global_load_b32 v8, v5, s[6:7]
	v_add_co_u32 v2, vcc_lo, v2, 4
	s_add_i32 s12, s12, -1
	v_add_co_ci_u32_e32 v3, vcc_lo, 0, v3, vcc_lo
	s_add_u32 s6, s6, 4
	s_addc_u32 s7, s7, 0
	s_cmp_lg_u32 s12, 0
	s_waitcnt vmcnt(0)
	v_sub_f32_e32 v7, v7, v8
	s_delay_alu instid0(VALU_DEP_1)
	v_fmac_f32_e32 v6, v7, v7
	s_cbranch_scc1 .LBB0_4
	s_branch .LBB0_6
.LBB0_5:                                ;   in Loop: Header=BB0_2 Depth=1
	v_mov_b32_e32 v6, 0x42c80000
.LBB0_6:                                ; %_Z18calculate_distancePfS_iiiii.exit.i
                                        ;   in Loop: Header=BB0_2 Depth=1
	v_add_nc_u32_e32 v2, s1, v4
	s_add_i32 s1, s1, 1
	s_add_i32 s8, s8, s11
	s_cmp_lg_u32 s1, s10
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v3, 31, v2
	v_lshlrev_b64 v[2:3], 2, v[2:3]
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v2, vcc_lo, s2, v2
	v_add_co_ci_u32_e32 v3, vcc_lo, s3, v3, vcc_lo
	global_store_b32 v[2:3], v6, off
	s_cbranch_scc1 .LBB0_2
.LBB0_7:                                ; %_Z25calculate_distance_matrixPfS_S_iiii.exit
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z27calculate_similarity_matrixPfS_S_iii
		.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 9
		.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	_Z27calculate_similarity_matrixPfS_S_iii, .Lfunc_end0-_Z27calculate_similarity_matrixPfS_S_iii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 368
; NumSgprs: 18
; NumVgprs: 9
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 9
; 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	_Z26calculate_nearest_neighborPfPiiiii ; -- Begin function _Z26calculate_nearest_neighborPfPiiiii
	.globl	_Z26calculate_nearest_neighborPfPiiiii
	.p2align	8
	.type	_Z26calculate_nearest_neighborPfPiiiii,@function
_Z26calculate_nearest_neighborPfPiiiii: ; @_Z26calculate_nearest_neighborPfPiiiii
; %bb.0:
	s_load_b32 s2, s[0:1], 0x1c
	s_waitcnt lgkmcnt(0)
	s_cmp_lt_i32 s2, 1
	s_cbranch_scc1 .LBB1_7
; %bb.1:                                ; %.lr.ph
	s_clause 0x2
	s_load_b32 s3, s[0:1], 0x2c
	s_load_b32 s8, s[0:1], 0x10
	s_load_b128 s[4:7], s[0:1], 0x0
	v_mov_b32_e32 v7, 0x47c34f80
	s_waitcnt lgkmcnt(0)
	s_and_b32 s3, s3, 0xffff
	s_cmp_gt_i32 s8, 0
	v_mad_u64_u32 v[2:3], null, s15, s3, v[0:1]
	s_cselect_b32 s1, -1, 0
	s_mov_b32 s3, 0
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_mul_lo_u32 v0, v2, s8
	v_mul_lo_u32 v5, v2, s2
	v_ashrrev_i32_e32 v1, 31, v0
	v_add_nc_u32_e32 v6, s8, v0
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[3:4], 2, v[0:1]
	v_add_co_u32 v1, vcc_lo, s4, v3
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v2, vcc_lo, s5, v4, vcc_lo
.LBB1_2:                                ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB1_4 Depth 2
	v_mov_b32_e32 v8, 0
	s_and_not1_b32 vcc_lo, exec_lo, s1
	s_cbranch_vccnz .LBB1_6
; %bb.3:                                ; %.lr.ph.i.preheader
                                        ;   in Loop: Header=BB1_2 Depth=1
	s_delay_alu instid0(VALU_DEP_2)
	v_dual_mov_b32 v9, 0x47c34f80 :: v_dual_mov_b32 v4, v2
	v_mov_b32_e32 v3, v1
	s_mov_b32 s8, 0
	s_mov_b32 s9, 0
.LBB1_4:                                ; %.lr.ph.i
                                        ;   Parent Loop BB1_2 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	global_load_b32 v10, v[3:4], off
	v_add_co_u32 v3, s0, v3, 4
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_4) | instid1(SALU_CYCLE_1)
	v_add_co_ci_u32_e64 v4, s0, 0, v4, s0
	s_waitcnt vmcnt(0)
	v_cmp_nle_f32_e32 vcc_lo, v10, v9
	v_cndmask_b32_e32 v8, s9, v8, vcc_lo
	s_add_i32 s9, s9, 1
	v_dual_cndmask_b32 v9, v10, v9 :: v_dual_add_nc_u32 v10, s9, v0
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(SALU_CYCLE_1)
	v_cmp_ge_i32_e32 vcc_lo, v10, v6
	s_or_b32 s8, vcc_lo, s8
	s_and_not1_b32 exec_lo, exec_lo, s8
	s_cbranch_execnz .LBB1_4
; %bb.5:                                ; %Flow
                                        ;   in Loop: Header=BB1_2 Depth=1
	s_or_b32 exec_lo, exec_lo, s8
.LBB1_6:                                ; %_Z32calculate_nearest_neighbor_indexPfii.exit
                                        ;   in Loop: Header=BB1_2 Depth=1
	v_add_nc_u32_e32 v3, s3, v5
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(SALU_CYCLE_1)
	v_add_nc_u32_e32 v9, v8, v0
	s_add_i32 s3, s3, 1
	s_cmp_eq_u32 s3, s2
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_ashrrev_i32_e32 v4, 31, v3
	v_ashrrev_i32_e32 v10, 31, v9
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_lshlrev_b64 v[3:4], 2, v[3:4]
	v_lshlrev_b64 v[9:10], 2, v[9:10]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_co_u32 v3, vcc_lo, s6, v3
	v_add_co_ci_u32_e32 v4, vcc_lo, s7, v4, vcc_lo
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_4)
	v_add_co_u32 v9, vcc_lo, s4, v9
	v_add_co_ci_u32_e32 v10, vcc_lo, s5, v10, vcc_lo
	global_store_b32 v[3:4], v8, off
	global_store_b32 v[9:10], v7, off
	s_cbranch_scc0 .LBB1_2
.LBB1_7:                                ; %._crit_edge
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z26calculate_nearest_neighborPfPiiiii
		.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 11
		.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_end1:
	.size	_Z26calculate_nearest_neighborPfPiiiii, .Lfunc_end1-_Z26calculate_nearest_neighborPfPiiiii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 376
; NumSgprs: 18
; NumVgprs: 11
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 11
; 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
      - .address_space:  global
        .offset:         16
        .size:           8
        .value_kind:     global_buffer
      - .offset:         24
        .size:           4
        .value_kind:     by_value
      - .offset:         28
        .size:           4
        .value_kind:     by_value
      - .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
    .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:           _Z27calculate_similarity_matrixPfS_S_iii
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z27calculate_similarity_matrixPfS_S_iii.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     9
    .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:           4
        .value_kind:     by_value
      - .offset:         20
        .size:           4
        .value_kind:     by_value
      - .offset:         24
        .size:           4
        .value_kind:     by_value
      - .offset:         28
        .size:           4
        .value_kind:     by_value
      - .offset:         32
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         36
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         40
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         44
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         46
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         48
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         50
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         52
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         54
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         88
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         96
        .size:           2
        .value_kind:     hidden_grid_dims
    .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:           _Z26calculate_nearest_neighborPfPiiiii
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z26calculate_nearest_neighborPfPiiiii.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     11
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
