#include <cuda_runtime.h>
#include <iostream>
#include <ctime>
#include "device_launch_parameters.h"
#include <limits.h>

#define PRINT_MATRIX true
#define CHECK(value) {\
    cudaError_t _m_cudaStat = value;\
    if (_m_cudaStat != cudaSuccess) {\
        cout<< "Error:" << cudaGetErrorString(_m_cudaStat) \
            << " at line " << __LINE__ << " in file " << __FILE__ << "\n"; \
        exit(1);\
    } }

#define MAX_MEMORY_VECTOR 104857600	//100 МБ

#define COUNT_OF_ELEMENTS_IN_SYSTEM 102400000 //общее количество элементов в системе векторов
#define COUNT_OF_VECTORS_IN_SYSTEM 64 //количество векторов в системе
#define COUNT_OF_ELEMENTS_IN_VECTOR (COUNT_OF_ELEMENTS_IN_SYSTEM / COUNT_OF_VECTORS_IN_SYSTEM) //количество элементов в одном векторе
#define SIZE_GRAM_MATRIX  (COUNT_OF_VECTORS_IN_SYSTEM * COUNT_OF_VECTORS_IN_SYSTEM)			   //размер матрицы Грама

#define CACHE_COLUMNS 512 //without padding

using namespace std;

inline void Info()
{
	cout << "Size of system: " << COUNT_OF_ELEMENTS_IN_SYSTEM
		<< "\nCount of vectors: " << COUNT_OF_VECTORS_IN_SYSTEM
		<< "\nCount of elements in one vector: " << COUNT_OF_ELEMENTS_IN_VECTOR << endl;
			
}
void InfoResult(unsigned char*, unsigned char*);

void PrintSystemOfVectors(unsigned char*);

void PrintVector(unsigned char*, size_t);

unsigned char* GetRandomSystemOfVectors();

unsigned char* GetGramMatrixCPU(unsigned char* systemOfVectors, float& time);

unsigned char* GetGramMatrixGPU(unsigned char* systemOfVectors, float& time);

bool IsEqual(unsigned char* firstVector, unsigned char* secondVector, size_t size);

void Check(unsigned char* matrix_Host, unsigned char* matrix_Device);

__global__ void calculate_GramMatrix_GPU_Cache(unsigned char* systemOfVectors, unsigned char* gramMatrix)
{
	__shared__ unsigned char cacheA[32][CACHE_COLUMNS + 4];
	__shared__ unsigned char cacheB[32][CACHE_COLUMNS + 4];
	unsigned char reg_temp = 0;
	
	for (int part = 0; part < COUNT_OF_ELEMENTS_IN_VECTOR / CACHE_COLUMNS; part++)
	{
		// заполняем кэш 	
		// у нас 32 * 32 = 1024 потоков
		// нам нужно скопировать в кэш 32 * 1024 байтов. 
		// чтобы всё быстро работало потоки с соседними номерами должны копировать соседние байты
		int t = threadIdx.y * 32 + threadIdx.x;
		for (int cachePart = 0; cachePart < 16; cachePart++)
		{
			cacheA[cachePart * 2 + t / CACHE_COLUMNS][t % CACHE_COLUMNS] =
				systemOfVectors[(cachePart * 2 + t / CACHE_COLUMNS + blockIdx.x * 32) * 
				COUNT_OF_ELEMENTS_IN_VECTOR + t % CACHE_COLUMNS + part * CACHE_COLUMNS];


			cacheB[cachePart * 2 + t / CACHE_COLUMNS][t % CACHE_COLUMNS] =
				systemOfVectors[(cachePart * 2 + t / CACHE_COLUMNS + blockIdx.y * 32) * 
				COUNT_OF_ELEMENTS_IN_VECTOR + t % CACHE_COLUMNS + part * CACHE_COLUMNS];
		}
		__syncthreads();
		// вычисление частичнх сум для частей векторов в кэше
		for (int i = 0; i < CACHE_COLUMNS; i++)
		{
			unsigned char elementFirst =  cacheA[threadIdx.x][i];
			unsigned char elementSecond = cacheB[threadIdx.y][i];
			reg_temp += elementFirst * elementSecond;
		}
		__syncthreads();
	}
	// reg_temp записываем в результат 
	gramMatrix[(threadIdx.y + blockIdx.y * blockDim.y) * 64 + threadIdx.x + blockIdx.x * blockDim.x] = reg_temp;
}

__global__ void calculate_GramMatrix_GPU(unsigned char* systemOfVectors, unsigned char* gramMatrix)
{
	int index = blockIdx.x * blockDim.x + threadIdx.x;
	if (index >= SIZE_GRAM_MATRIX) return;
	unsigned char temp = 0;
	for (int j = 0; j < COUNT_OF_ELEMENTS_IN_VECTOR; j++)
	{
		temp += systemOfVectors[(index / COUNT_OF_VECTORS_IN_SYSTEM) * COUNT_OF_ELEMENTS_IN_VECTOR + j] *
				systemOfVectors[(index % COUNT_OF_VECTORS_IN_SYSTEM) * COUNT_OF_ELEMENTS_IN_VECTOR + j];
	}
	gramMatrix[index] = temp;
}
int main()
{
	Info();
	float timeCPU = 0.0f, timeGPU = 0.0f;
	unsigned char* systemOfVectors = GetRandomSystemOfVectors();
	bool isForPrint = COUNT_OF_ELEMENTS_IN_SYSTEM <= 1024;
	if (isForPrint) PrintSystemOfVectors(systemOfVectors);

	cout << "\nSize Gram matrix: " << SIZE_GRAM_MATRIX << "\n\n";

	unsigned char* matrixGramCPU = GetGramMatrixCPU(systemOfVectors, timeCPU);
	
	unsigned char* matrixGramGPU = GetGramMatrixGPU(systemOfVectors, timeGPU);

	Check(matrixGramCPU, matrixGramGPU);

	cout << "\n--------\n";
	cout << "Time CPU: " << timeCPU << endl;
	cout << "Time GPU: " << timeGPU << endl;
	cout << "\n--------\n";
	//InfoResult(matrixGramCPU, matrixGramGPU);
	cin.get();
	return 0;
}
unsigned char* GetGramMatrixGPU(unsigned char* systemOfVectors, float& time_d)
{
	cout << "\n---------\n";
	unsigned char* matrixGram = new unsigned char[SIZE_GRAM_MATRIX];

	int memoryForGramMatrix = sizeof(unsigned char) * SIZE_GRAM_MATRIX;
	int memoryForBigVector = sizeof(unsigned char) * COUNT_OF_ELEMENTS_IN_SYSTEM;

	for (int i = 0; i < SIZE_GRAM_MATRIX; i++)
		matrixGram[i] = 0;

	unsigned char* systemOfVectors_GPU; 
	unsigned char* matrixGram_GPU;

	cudaEvent_t startCUDA, stopCUDA;
	CHECK(cudaEventCreate(&startCUDA));
	CHECK(cudaEventCreate(&stopCUDA));

	CHECK(cudaMalloc(&systemOfVectors_GPU, memoryForBigVector));
	CHECK(cudaMalloc(&matrixGram_GPU, memoryForGramMatrix));
	
	CHECK(cudaMemcpy(systemOfVectors_GPU, systemOfVectors, memoryForBigVector, cudaMemcpyHostToDevice));
	CHECK(cudaMemcpy(matrixGram_GPU, matrixGram, memoryForGramMatrix, cudaMemcpyHostToDevice));

	CHECK(cudaEventRecord(startCUDA, 0));

	cout << "Calculate on DEVICE...\n";
	
	int size = SIZE_GRAM_MATRIX - (SIZE_GRAM_MATRIX - COUNT_OF_VECTORS_IN_SYSTEM) / 2;

	int countOfBlocks = (SIZE_GRAM_MATRIX + 1023) / 1024;
	//calculate_GramMatrix_GPU<<<1, 1024>>>(systemOfVectors_GPU, matrixGram_GPU);
	calculate_GramMatrix_GPU_Cache <<<dim3(COUNT_OF_VECTORS_IN_SYSTEM / 32, COUNT_OF_VECTORS_IN_SYSTEM / 32, 1),
		dim3(32, 32, 1) >>> (systemOfVectors_GPU, matrixGram_GPU);
	//cout << "Count of blocks: " << countOfBlocks << endl;
	

	cudaEventRecord(stopCUDA, 0);
	cudaEventSynchronize(stopCUDA);

	cudaEventElapsedTime(&time_d, startCUDA, stopCUDA);
	time_d /= 1000;
	CHECK(cudaMemcpy(matrixGram, matrixGram_GPU, memoryForGramMatrix, cudaMemcpyDeviceToHost));
	cout << "Done\n";
	
	cudaFree(systemOfVectors_GPU);
	cudaFree(matrixGram_GPU);
	return matrixGram;
}

unsigned char* GetGramMatrixCPU(unsigned char* systemOfVectors, float& time_h)
{
	cout << "Calculate on Host...\n";
	unsigned char* matrixGram = new unsigned char[SIZE_GRAM_MATRIX];

	time_h = clock();
	for (int i = 0; i < SIZE_GRAM_MATRIX; i++)
	{
		matrixGram[i] = 0;
		for (int j = 0; j < COUNT_OF_ELEMENTS_IN_VECTOR; j++)
			matrixGram[i] +=
			systemOfVectors[(i / COUNT_OF_VECTORS_IN_SYSTEM) * COUNT_OF_ELEMENTS_IN_VECTOR + j] *
			systemOfVectors[(i % COUNT_OF_VECTORS_IN_SYSTEM) * COUNT_OF_ELEMENTS_IN_VECTOR + j];
	}
	time_h /= CLOCKS_PER_SEC;
	return matrixGram;
}

void Check(unsigned char* matrix_Host, unsigned char* matrix_Device)
{
	cout << "\nCheck...\n";
	if (IsEqual(matrix_Host, matrix_Device, SIZE_GRAM_MATRIX))
		cout << "That's right! :)\n";
	else cout << "Wrong! :(\n";
}
bool IsEqual(unsigned char* firstVector, unsigned char* secondVector, size_t size)
{	
	int countOfMistakes = 0;
	for (int i = 0; i < size; i++)
		if (firstVector[i] != secondVector[i])
			countOfMistakes++;
	cout << "Count of miss: " << countOfMistakes << endl;
	return countOfMistakes == 0;
}
unsigned char* GetRandomSystemOfVectors()
{
	unsigned char* vector = new unsigned char[COUNT_OF_ELEMENTS_IN_SYSTEM];
	for (int i = 0; i < COUNT_OF_ELEMENTS_IN_SYSTEM; i++)
		vector[i] = rand() % 9 + 1;
	return vector;
}
void InfoResult(unsigned char* matrix_Host, unsigned char* matrix_Device)
{
	cout << "\nGram matrix CPU: " << endl;
	PrintVector(matrix_Host, SIZE_GRAM_MATRIX);

	cout << "\nGram matrix GPU: " << endl;
	PrintVector(matrix_Device, SIZE_GRAM_MATRIX);
}

void PrintSystemOfVectors(unsigned char* systemOfVectors)
{
	bool step = COUNT_OF_ELEMENTS_IN_SYSTEM < 10;
	cout << "\nBig vector:\n\n";
	for (int i = 0, j = 0; i < COUNT_OF_ELEMENTS_IN_SYSTEM; i++, j++)
	{
		if (j == COUNT_OF_ELEMENTS_IN_VECTOR && step)
		{
			cout << endl;
			j = 0;
		}
		cout << (int)systemOfVectors[i] << " ";
	}
	cout << endl;
}
void PrintVector(unsigned char* vector, size_t size)
{
	if (PRINT_MATRIX)
	{
		for (int i = 0; i < COUNT_OF_VECTORS_IN_SYSTEM; i++)
		{
			for (int j = 0; j < COUNT_OF_VECTORS_IN_SYSTEM; j++)
			{
				cout << (int)vector[i * COUNT_OF_VECTORS_IN_SYSTEM + j] << "\t";
				if (i * COUNT_OF_VECTORS_IN_SYSTEM + j == 200) return;
			}
			cout << endl;
		}
	}
	else
	{
		for (int i = 0; i < size; i++)
			cout << (int)vector[i] << " ";
		cout << endl;
	}
}



	.file	"tmpxft_00391333_00000000-6_GramMatrixOptimizeGPU.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB3647:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE3647:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.align 2
	.type	_ZNSolsEPFRSoS_E.isra.0, @function
_ZNSolsEPFRSoS_E.isra.0:
.LFB4306:
	.cfi_startproc
	jmp	*%rsi
	.cfi_endproc
.LFE4306:
	.size	_ZNSolsEPFRSoS_E.isra.0, .-_ZNSolsEPFRSoS_E.isra.0
	.section	.rodata._Z4Infov.str1.1,"aMS",@progbits,1
.LC0:
	.string	"Size of system: "
.LC1:
	.string	"\nCount of vectors: "
.LC2:
	.string	"\nCount of elements in one vector: "
	.section	.text._Z4Infov,"axG",@progbits,_Z4Infov,comdat
	.weak	_Z4Infov
	.type	_Z4Infov, @function
_Z4Infov:
.LFB3635:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	leaq	.LC0(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	$102400000, %esi
	movq	%rax, %rdi
	call	_ZNSolsEi@PLT
	leaq	.LC1(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	$64, %esi
	movq	%rax, %rdi
	call	_ZNSolsEi@PLT
	leaq	.LC2(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	$1600000, %esi
	movq	%rax, %rdi
	call	_ZNSolsEi@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	popq	%rdx
	.cfi_def_cfa_offset 8
	movq	%rax, %rdi
	jmp	_ZNSolsEPFRSoS_E.isra.0
	.cfi_endproc
.LFE3635:
	.size	_Z4Infov, .-_Z4Infov
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC3:
	.string	"Calculate on Host...\n"
	.text
	.globl	_Z16GetGramMatrixCPUPhRf
	.type	_Z16GetGramMatrixCPUPhRf, @function
_Z16GetGramMatrixCPUPhRf:
.LFB3638:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movq	%rdi, %r12
	leaq	_ZSt4cout(%rip), %rdi
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movq	%rsi, %rbp
	leaq	.LC3(%rip), %rsi
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	$4096, %edi
	call	_Znam@PLT
	movq	%rax, %rbx
	call	clock@PLT
	xorl	%ecx, %ecx
	cvtsi2ssq	%rax, %xmm0
	movss	%xmm0, 0(%rbp)
.L7:
	movl	%ecx, %edx
	movq	%rcx, %rdi
	xorl	%esi, %esi
	xorl	%r8d, %r8d
	sarl	$6, %edx
	andl	$63, %edi
	movslq	%edx, %rdx
	imulq	$1600000, %rdi, %rdi
	imulq	$1600000, %rdx, %rdx
	addq	%r12, %rdi
	addq	%r12, %rdx
.L6:
	movb	(%rdx,%rsi), %al
	mulb	(%rdi,%rsi)
	incq	%rsi
	addl	%eax, %r8d
	cmpq	$1600000, %rsi
	jne	.L6
	movb	%r8b, (%rbx,%rcx)
	incq	%rcx
	cmpq	$4096, %rcx
	jne	.L7
	movq	%rbx, %rax
	divss	.LC4(%rip), %xmm0
	movss	%xmm0, 0(%rbp)
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3638:
	.size	_Z16GetGramMatrixCPUPhRf, .-_Z16GetGramMatrixCPUPhRf
	.section	.rodata.str1.1
.LC5:
	.string	"Count of miss: "
	.text
	.globl	_Z7IsEqualPhS_m
	.type	_Z7IsEqualPhS_m, @function
_Z7IsEqualPhS_m:
.LFB3640:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	xorl	%eax, %eax
	xorl	%ebx, %ebx
.L13:
	cmpq	%rax, %rdx
	je	.L17
	movb	(%rsi,%rax), %cl
	cmpb	%cl, (%rdi,%rax)
	je	.L14
	incl	%ebx
.L14:
	incq	%rax
	jmp	.L13
.L17:
	leaq	.LC5(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	%ebx, %esi
	movq	%rax, %rdi
	call	_ZNSolsEi@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	testl	%ebx, %ebx
	popq	%rbx
	.cfi_def_cfa_offset 8
	sete	%al
	ret
	.cfi_endproc
.LFE3640:
	.size	_Z7IsEqualPhS_m, .-_Z7IsEqualPhS_m
	.section	.rodata.str1.1
.LC6:
	.string	"\nCheck...\n"
.LC7:
	.string	"That's right! :)\n"
.LC8:
	.string	"Wrong! :(\n"
	.text
	.globl	_Z5CheckPhS_
	.type	_Z5CheckPhS_, @function
_Z5CheckPhS_:
.LFB3639:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movq	%rsi, %r12
	leaq	.LC6(%rip), %rsi
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movq	%rdi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	leaq	_ZSt4cout(%rip), %rbx
	movq	%rbx, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%r12, %rsi
	movl	$4096, %edx
	movq	%rbp, %rdi
	call	_Z7IsEqualPhS_m
	leaq	.LC7(%rip), %rsi
	testb	%al, %al
	jne	.L21
	leaq	.LC8(%rip), %rsi
.L21:
	movq	%rbx, %rdi
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	jmp	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	.cfi_endproc
.LFE3639:
	.size	_Z5CheckPhS_, .-_Z5CheckPhS_
	.globl	_Z24GetRandomSystemOfVectorsv
	.type	_Z24GetRandomSystemOfVectorsv, @function
_Z24GetRandomSystemOfVectorsv:
.LFB3641:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movl	$102400000, %edi
	movl	$9, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	xorl	%ebp, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	call	_Znam@PLT
	movq	%rax, %rbx
.L23:
	call	rand@PLT
	cltd
	idivl	%r12d
	incl	%edx
	movb	%dl, (%rbx,%rbp)
	incq	%rbp
	cmpq	$102400000, %rbp
	jne	.L23
	movq	%rbx, %rax
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3641:
	.size	_Z24GetRandomSystemOfVectorsv, .-_Z24GetRandomSystemOfVectorsv
	.section	.rodata.str1.1
.LC9:
	.string	"\nBig vector:\n\n"
.LC10:
	.string	" "
	.text
	.globl	_Z20PrintSystemOfVectorsPh
	.type	_Z20PrintSystemOfVectorsPh, @function
_Z20PrintSystemOfVectorsPh:
.LFB3643:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leaq	.LC9(%rip), %rsi
	leaq	.LC10(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	movq	%rdi, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	leaq	_ZSt4cout(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	movq	%rbp, %rdi
	xorl	%ebx, %ebx
	pushq	%rdx
	.cfi_def_cfa_offset 48
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
.L27:
	movzbl	(%r12,%rbx), %esi
	movq	%rbp, %rdi
	incq	%rbx
	call	_ZNSolsEi@PLT
	movq	%r13, %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	cmpq	$102400000, %rbx
	jne	.L27
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rbp, %rdi
	popq	%rax
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	jmp	_ZNSolsEPFRSoS_E.isra.0
	.cfi_endproc
.LFE3643:
	.size	_Z20PrintSystemOfVectorsPh, .-_Z20PrintSystemOfVectorsPh
	.section	.rodata.str1.1
.LC11:
	.string	"\t"
	.text
	.globl	_Z11PrintVectorPhm
	.type	_Z11PrintVectorPhm, @function
_Z11PrintVectorPhm:
.LFB3644:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	4096(%rdi), %r15
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	leaq	_ZSt4cout(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movq	%rdi, %r12
	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
	pushq	%rdx
	.cfi_def_cfa_offset 64
.L31:
	movl	%r12d, %r14d
	xorl	%ebx, %ebx
	subl	%ebp, %r14d
.L33:
	movzbl	(%r12,%rbx), %esi
	movq	%r13, %rdi
	call	_ZNSolsEi@PLT
	leaq	.LC11(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leal	(%r14,%rbx), %eax
	cmpl	$200, %eax
	je	.L30
	incq	%rbx
	cmpq	$64, %rbx
	jne	.L33
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%r13, %rdi
	addq	$64, %r12
	call	_ZNSolsEPFRSoS_E.isra.0
	cmpq	%r15, %r12
	jne	.L31
.L30:
	popq	%rax
	.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
.LFE3644:
	.size	_Z11PrintVectorPhm, .-_Z11PrintVectorPhm
	.section	.rodata.str1.1
.LC12:
	.string	"\nGram matrix CPU: "
.LC13:
	.string	"\nGram matrix GPU: "
	.text
	.globl	_Z10InfoResultPhS_
	.type	_Z10InfoResultPhS_, @function
_Z10InfoResultPhS_:
.LFB3642:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	leaq	_ZSt4cout(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movq	%rdi, %rbp
	movq	%r12, %rdi
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	movq	%rsi, %rbx
	leaq	.LC12(%rip), %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	movq	%rbp, %rdi
	movl	$4096, %esi
	call	_Z11PrintVectorPhm
	movq	%r12, %rdi
	leaq	.LC13(%rip), %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	movq	%rbx, %rdi
	movl	$4096, %esi
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	jmp	_Z11PrintVectorPhm
	.cfi_endproc
.LFE3642:
	.size	_Z10InfoResultPhS_, .-_Z10InfoResultPhS_
	.globl	_Z52__device_stub__Z30calculate_GramMatrix_GPU_CachePhS_PhS_
	.type	_Z52__device_stub__Z30calculate_GramMatrix_GPU_CachePhS_PhS_, @function
_Z52__device_stub__Z30calculate_GramMatrix_GPU_CachePhS_PhS_:
.LFB3669:
	.cfi_startproc
	endbr64
	subq	$120, %rsp
	.cfi_def_cfa_offset 128
	movq	%rdi, 8(%rsp)
	leaq	32(%rsp), %rcx
	leaq	24(%rsp), %rdx
	movq	%rsi, (%rsp)
	leaq	40(%rsp), %rdi
	leaq	52(%rsp), %rsi
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rax
	movl	$1, 48(%rsp)
	movq	%rax, 88(%rsp)
	movq	%rsp, %rax
	movq	%rax, 96(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 40(%rsp)
	movq	%rax, 52(%rsp)
	movl	$1, 60(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L41
	pushq	32(%rsp)
	.cfi_def_cfa_offset 136
	leaq	_Z30calculate_GramMatrix_GPU_CachePhS_(%rip), %rdi
	pushq	32(%rsp)
	.cfi_def_cfa_offset 144
	movq	68(%rsp), %rcx
	movl	76(%rsp), %r8d
	movq	56(%rsp), %rsi
	movl	64(%rsp), %edx
	leaq	104(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 136
	popq	%rdx
	.cfi_def_cfa_offset 128
.L41:
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	je	.L43
	call	__stack_chk_fail@PLT
.L43:
	addq	$120, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3669:
	.size	_Z52__device_stub__Z30calculate_GramMatrix_GPU_CachePhS_PhS_, .-_Z52__device_stub__Z30calculate_GramMatrix_GPU_CachePhS_PhS_
	.globl	_Z30calculate_GramMatrix_GPU_CachePhS_
	.type	_Z30calculate_GramMatrix_GPU_CachePhS_, @function
_Z30calculate_GramMatrix_GPU_CachePhS_:
.LFB3670:
	.cfi_startproc
	endbr64
	jmp	_Z52__device_stub__Z30calculate_GramMatrix_GPU_CachePhS_PhS_
	.cfi_endproc
.LFE3670:
	.size	_Z30calculate_GramMatrix_GPU_CachePhS_, .-_Z30calculate_GramMatrix_GPU_CachePhS_
	.section	.rodata.str1.1
.LC14:
	.string	"\n---------\n"
.LC15:
	.string	"Error:"
.LC16:
	.string	" at line "
.LC17:
	.string	" in file "
.LC18:
	.string	"/home/ubuntu/Datasets/stackv2/train-structured/Tessecrack/CUDA_DEV/main/GramMatrix/GramMatrixOptimizeGPU.cu"
.LC19:
	.string	"\n"
.LC20:
	.string	"Calculate on DEVICE...\n"
.LC22:
	.string	"Done\n"
	.text
	.globl	_Z16GetGramMatrixGPUPhRf
	.type	_Z16GetGramMatrixGPUPhRf, @function
_Z16GetGramMatrixGPUPhRf:
.LFB3637:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	movq	%rdi, %r14
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	movq	%rsi, %r12
	leaq	.LC14(%rip), %rsi
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	leaq	_ZSt4cout(%rip), %rbx
	movq	%rbx, %rdi
	subq	$64, %rsp
	.cfi_def_cfa_offset 112
	movq	%fs:40, %rax
	movq	%rax, 56(%rsp)
	xorl	%eax, %eax
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	$4096, %edi
	call	_Znam@PLT
	movl	$1024, %ecx
	movq	%rax, %rbp
	xorl	%eax, %eax
	movq	%rbp, %rdi
	rep stosl
	leaq	16(%rsp), %rdi
	call	cudaEventCreate@PLT
	testl	%eax, %eax
	je	.L47
	leaq	.LC15(%rip), %rsi
	movq	%rbx, %rdi
	movl	%eax, %r13d
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	%r13d, %edi
	movq	%rax, %rbx
	call	cudaGetErrorString@PLT
	movq	%rbx, %rdi
	movq	%rax, %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC16(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	$139, %esi
	movq	%rax, %rdi
	jmp	.L58
.L47:
	leaq	24(%rsp), %rdi
	call	cudaEventCreate@PLT
	movl	%eax, %r13d
	testl	%eax, %eax
	je	.L48
	leaq	.LC15(%rip), %rsi
	movq	%rbx, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	%r13d, %edi
	movq	%rax, %rbx
	call	cudaGetErrorString@PLT
	movq	%rbx, %rdi
	movq	%rax, %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC16(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	$140, %esi
	movq	%rax, %rdi
.L58:
	call	_ZNSolsEi@PLT
	leaq	.LC17(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC18(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC19(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	$1, %edi
	call	exit@PLT
.L48:
	movq	%rsp, %rdi
	movl	$102400000, %esi
	call	cudaMalloc@PLT
	movl	%eax, %r13d
	testl	%eax, %eax
	je	.L49
	leaq	.LC15(%rip), %rsi
	movq	%rbx, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	%r13d, %edi
	movq	%rax, %rbx
	call	cudaGetErrorString@PLT
	movq	%rbx, %rdi
	movq	%rax, %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC16(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	$142, %esi
	movq	%rax, %rdi
	jmp	.L58
.L49:
	leaq	8(%rsp), %rdi
	movl	$4096, %esi
	call	cudaMalloc@PLT
	movl	%eax, %r13d
	testl	%eax, %eax
	je	.L50
	leaq	.LC15(%rip), %rsi
	movq	%rbx, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	%r13d, %edi
	movq	%rax, %rbx
	call	cudaGetErrorString@PLT
	movq	%rbx, %rdi
	movq	%rax, %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC16(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	$143, %esi
	movq	%rax, %rdi
	jmp	.L58
.L50:
	movq	(%rsp), %rdi
	movl	$1, %ecx
	movl	$102400000, %edx
	movq	%r14, %rsi
	call	cudaMemcpy@PLT
	movl	%eax, %r13d
	testl	%eax, %eax
	je	.L51
	leaq	.LC15(%rip), %rsi
	movq	%rbx, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	%r13d, %edi
	movq	%rax, %rbx
	call	cudaGetErrorString@PLT
	movq	%rbx, %rdi
	movq	%rax, %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC16(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	$145, %esi
	movq	%rax, %rdi
	jmp	.L58
.L51:
	movq	8(%rsp), %rdi
	movl	$1, %ecx
	movl	$4096, %edx
	movq	%rbp, %rsi
	call	cudaMemcpy@PLT
	movl	%eax, %r13d
	testl	%eax, %eax
	je	.L52
	leaq	.LC15(%rip), %rsi
	movq	%rbx, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	%r13d, %edi
	movq	%rax, %rbx
	call	cudaGetErrorString@PLT
	movq	%rbx, %rdi
	movq	%rax, %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC16(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	$146, %esi
	movq	%rax, %rdi
	jmp	.L58
.L52:
	movq	16(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movl	%eax, %r13d
	testl	%eax, %eax
	je	.L53
	leaq	.LC15(%rip), %rsi
	movq	%rbx, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	%r13d, %edi
	movq	%rax, %rbx
	call	cudaGetErrorString@PLT
	movq	%rbx, %rdi
	movq	%rax, %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC16(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	$148, %esi
	movq	%rax, %rdi
	jmp	.L58
.L53:
	leaq	.LC20(%rip), %rsi
	movq	%rbx, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	$1, %ecx
	movabsq	$137438953504, %rdx
	movl	$1, %esi
	movabsq	$8589934594, %rdi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L54
	movq	8(%rsp), %rsi
	movq	(%rsp), %rdi
	call	_Z52__device_stub__Z30calculate_GramMatrix_GPU_CachePhS_PhS_
.L54:
	movq	24(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	24(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movq	24(%rsp), %rdx
	movq	16(%rsp), %rsi
	movq	%r12, %rdi
	call	cudaEventElapsedTime@PLT
	movq	8(%rsp), %rsi
	movss	(%r12), %xmm0
	movq	%rbp, %rdi
	divss	.LC21(%rip), %xmm0
	movl	$2, %ecx
	movl	$4096, %edx
	movss	%xmm0, (%r12)
	call	cudaMemcpy@PLT
	movl	%eax, %r12d
	testl	%eax, %eax
	je	.L55
	leaq	.LC15(%rip), %rsi
	movq	%rbx, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	%r12d, %edi
	movq	%rax, %rbx
	call	cudaGetErrorString@PLT
	movq	%rbx, %rdi
	movq	%rax, %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC16(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	$166, %esi
	movq	%rax, %rdi
	jmp	.L58
.L55:
	leaq	.LC22(%rip), %rsi
	movq	%rbx, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	(%rsp), %rdi
	call	cudaFree@PLT
	movq	8(%rsp), %rdi
	call	cudaFree@PLT
	movq	56(%rsp), %rax
	subq	%fs:40, %rax
	je	.L56
	call	__stack_chk_fail@PLT
.L56:
	addq	$64, %rsp
	.cfi_def_cfa_offset 48
	movq	%rbp, %rax
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3637:
	.size	_Z16GetGramMatrixGPUPhRf, .-_Z16GetGramMatrixGPUPhRf
	.section	.rodata.str1.1
.LC24:
	.string	"\nSize Gram matrix: "
.LC25:
	.string	"\n\n"
.LC26:
	.string	"\n--------\n"
.LC27:
	.string	"Time CPU: "
.LC28:
	.string	"Time GPU: "
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB3636:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	leaq	_ZSt4cout(%rip), %rbx
	subq	$16, %rsp
	.cfi_def_cfa_offset 48
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	call	_Z4Infov
	movl	$0x00000000, (%rsp)
	movl	$0x00000000, 4(%rsp)
	call	_Z24GetRandomSystemOfVectorsv
	leaq	.LC24(%rip), %rsi
	movq	%rbx, %rdi
	movq	%rax, %rbp
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	$4096, %esi
	movq	%rax, %rdi
	call	_ZNSolsEi@PLT
	leaq	.LC25(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%rbp, %rdi
	movq	%rsp, %rsi
	call	_Z16GetGramMatrixCPUPhRf
	movq	%rbp, %rdi
	leaq	4(%rsp), %rsi
	leaq	.LC26(%rip), %rbp
	movq	%rax, %r12
	call	_Z16GetGramMatrixGPUPhRf
	movq	%r12, %rdi
	movq	%rax, %rsi
	call	_Z5CheckPhS_
	movq	%rbp, %rsi
	movq	%rbx, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC27(%rip), %rsi
	movq	%rbx, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	cvtss2sd	(%rsp), %xmm0
	movq	%rax, %rdi
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	leaq	.LC28(%rip), %rsi
	movq	%rbx, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	cvtss2sd	4(%rsp), %xmm0
	movq	%rax, %rdi
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	movq	%rbx, %rdi
	movq	%rbp, %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	_ZSt3cin(%rip), %rdi
	call	_ZNSi3getEv@PLT
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	je	.L60
	call	__stack_chk_fail@PLT
.L60:
	addq	$16, %rsp
	.cfi_def_cfa_offset 32
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3636:
	.size	main, .-main
	.text
	.globl	_Z46__device_stub__Z24calculate_GramMatrix_GPUPhS_PhS_
	.type	_Z46__device_stub__Z24calculate_GramMatrix_GPUPhS_PhS_, @function
_Z46__device_stub__Z24calculate_GramMatrix_GPUPhS_PhS_:
.LFB3671:
	.cfi_startproc
	endbr64
	subq	$120, %rsp
	.cfi_def_cfa_offset 128
	movq	%rdi, 8(%rsp)
	leaq	32(%rsp), %rcx
	leaq	24(%rsp), %rdx
	movq	%rsi, (%rsp)
	leaq	40(%rsp), %rdi
	leaq	52(%rsp), %rsi
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rax
	movl	$1, 48(%rsp)
	movq	%rax, 88(%rsp)
	movq	%rsp, %rax
	movq	%rax, 96(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 40(%rsp)
	movq	%rax, 52(%rsp)
	movl	$1, 60(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L62
	pushq	32(%rsp)
	.cfi_def_cfa_offset 136
	leaq	_Z24calculate_GramMatrix_GPUPhS_(%rip), %rdi
	pushq	32(%rsp)
	.cfi_def_cfa_offset 144
	movq	68(%rsp), %rcx
	movl	76(%rsp), %r8d
	movq	56(%rsp), %rsi
	movl	64(%rsp), %edx
	leaq	104(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 136
	popq	%rdx
	.cfi_def_cfa_offset 128
.L62:
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	je	.L64
	call	__stack_chk_fail@PLT
.L64:
	addq	$120, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3671:
	.size	_Z46__device_stub__Z24calculate_GramMatrix_GPUPhS_PhS_, .-_Z46__device_stub__Z24calculate_GramMatrix_GPUPhS_PhS_
	.globl	_Z24calculate_GramMatrix_GPUPhS_
	.type	_Z24calculate_GramMatrix_GPUPhS_, @function
_Z24calculate_GramMatrix_GPUPhS_:
.LFB3672:
	.cfi_startproc
	endbr64
	jmp	_Z46__device_stub__Z24calculate_GramMatrix_GPUPhS_PhS_
	.cfi_endproc
.LFE3672:
	.size	_Z24calculate_GramMatrix_GPUPhS_, .-_Z24calculate_GramMatrix_GPUPhS_
	.section	.rodata.str1.1
.LC29:
	.string	"_Z24calculate_GramMatrix_GPUPhS_"
.LC30:
	.string	"_Z30calculate_GramMatrix_GPU_CachePhS_"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB3674:
	.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	.LC29(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z24calculate_GramMatrix_GPUPhS_(%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	.LC30(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z30calculate_GramMatrix_GPU_CachePhS_(%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
.LFE3674:
	.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
.LC4:
	.long	1232348160
	.align 4
.LC21:
	.long	1148846080
	.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:

#include <hip/hip_runtime.h>
#include <iostream>
#include <ctime>

#include <limits.h>

#define PRINT_MATRIX true
#define CHECK(value) {\
    hipError_t _m_cudaStat = value;\
    if (_m_cudaStat != hipSuccess) {\
        cout<< "Error:" << hipGetErrorString(_m_cudaStat) \
            << " at line " << __LINE__ << " in file " << __FILE__ << "\n"; \
        exit(1);\
    } }

#define MAX_MEMORY_VECTOR 104857600	//100 МБ

#define COUNT_OF_ELEMENTS_IN_SYSTEM 102400000 //общее количество элементов в системе векторов
#define COUNT_OF_VECTORS_IN_SYSTEM 64 //количество векторов в системе
#define COUNT_OF_ELEMENTS_IN_VECTOR (COUNT_OF_ELEMENTS_IN_SYSTEM / COUNT_OF_VECTORS_IN_SYSTEM) //количество элементов в одном векторе
#define SIZE_GRAM_MATRIX  (COUNT_OF_VECTORS_IN_SYSTEM * COUNT_OF_VECTORS_IN_SYSTEM)			   //размер матрицы Грама

#define CACHE_COLUMNS 512 //without padding

using namespace std;

inline void Info()
{
	cout << "Size of system: " << COUNT_OF_ELEMENTS_IN_SYSTEM
		<< "\nCount of vectors: " << COUNT_OF_VECTORS_IN_SYSTEM
		<< "\nCount of elements in one vector: " << COUNT_OF_ELEMENTS_IN_VECTOR << endl;
			
}
void InfoResult(unsigned char*, unsigned char*);

void PrintSystemOfVectors(unsigned char*);

void PrintVector(unsigned char*, size_t);

unsigned char* GetRandomSystemOfVectors();

unsigned char* GetGramMatrixCPU(unsigned char* systemOfVectors, float& time);

unsigned char* GetGramMatrixGPU(unsigned char* systemOfVectors, float& time);

bool IsEqual(unsigned char* firstVector, unsigned char* secondVector, size_t size);

void Check(unsigned char* matrix_Host, unsigned char* matrix_Device);

__global__ void calculate_GramMatrix_GPU_Cache(unsigned char* systemOfVectors, unsigned char* gramMatrix)
{
	__shared__ unsigned char cacheA[32][CACHE_COLUMNS + 4];
	__shared__ unsigned char cacheB[32][CACHE_COLUMNS + 4];
	unsigned char reg_temp = 0;
	
	for (int part = 0; part < COUNT_OF_ELEMENTS_IN_VECTOR / CACHE_COLUMNS; part++)
	{
		// заполняем кэш 	
		// у нас 32 * 32 = 1024 потоков
		// нам нужно скопировать в кэш 32 * 1024 байтов. 
		// чтобы всё быстро работало потоки с соседними номерами должны копировать соседние байты
		int t = threadIdx.y * 32 + threadIdx.x;
		for (int cachePart = 0; cachePart < 16; cachePart++)
		{
			cacheA[cachePart * 2 + t / CACHE_COLUMNS][t % CACHE_COLUMNS] =
				systemOfVectors[(cachePart * 2 + t / CACHE_COLUMNS + blockIdx.x * 32) * 
				COUNT_OF_ELEMENTS_IN_VECTOR + t % CACHE_COLUMNS + part * CACHE_COLUMNS];


			cacheB[cachePart * 2 + t / CACHE_COLUMNS][t % CACHE_COLUMNS] =
				systemOfVectors[(cachePart * 2 + t / CACHE_COLUMNS + blockIdx.y * 32) * 
				COUNT_OF_ELEMENTS_IN_VECTOR + t % CACHE_COLUMNS + part * CACHE_COLUMNS];
		}
		__syncthreads();
		// вычисление частичнх сум для частей векторов в кэше
		for (int i = 0; i < CACHE_COLUMNS; i++)
		{
			unsigned char elementFirst =  cacheA[threadIdx.x][i];
			unsigned char elementSecond = cacheB[threadIdx.y][i];
			reg_temp += elementFirst * elementSecond;
		}
		__syncthreads();
	}
	// reg_temp записываем в результат 
	gramMatrix[(threadIdx.y + blockIdx.y * blockDim.y) * 64 + threadIdx.x + blockIdx.x * blockDim.x] = reg_temp;
}

__global__ void calculate_GramMatrix_GPU(unsigned char* systemOfVectors, unsigned char* gramMatrix)
{
	int index = blockIdx.x * blockDim.x + threadIdx.x;
	if (index >= SIZE_GRAM_MATRIX) return;
	unsigned char temp = 0;
	for (int j = 0; j < COUNT_OF_ELEMENTS_IN_VECTOR; j++)
	{
		temp += systemOfVectors[(index / COUNT_OF_VECTORS_IN_SYSTEM) * COUNT_OF_ELEMENTS_IN_VECTOR + j] *
				systemOfVectors[(index % COUNT_OF_VECTORS_IN_SYSTEM) * COUNT_OF_ELEMENTS_IN_VECTOR + j];
	}
	gramMatrix[index] = temp;
}
int main()
{
	Info();
	float timeCPU = 0.0f, timeGPU = 0.0f;
	unsigned char* systemOfVectors = GetRandomSystemOfVectors();
	bool isForPrint = COUNT_OF_ELEMENTS_IN_SYSTEM <= 1024;
	if (isForPrint) PrintSystemOfVectors(systemOfVectors);

	cout << "\nSize Gram matrix: " << SIZE_GRAM_MATRIX << "\n\n";

	unsigned char* matrixGramCPU = GetGramMatrixCPU(systemOfVectors, timeCPU);
	
	unsigned char* matrixGramGPU = GetGramMatrixGPU(systemOfVectors, timeGPU);

	Check(matrixGramCPU, matrixGramGPU);

	cout << "\n--------\n";
	cout << "Time CPU: " << timeCPU << endl;
	cout << "Time GPU: " << timeGPU << endl;
	cout << "\n--------\n";
	//InfoResult(matrixGramCPU, matrixGramGPU);
	cin.get();
	return 0;
}
unsigned char* GetGramMatrixGPU(unsigned char* systemOfVectors, float& time_d)
{
	cout << "\n---------\n";
	unsigned char* matrixGram = new unsigned char[SIZE_GRAM_MATRIX];

	int memoryForGramMatrix = sizeof(unsigned char) * SIZE_GRAM_MATRIX;
	int memoryForBigVector = sizeof(unsigned char) * COUNT_OF_ELEMENTS_IN_SYSTEM;

	for (int i = 0; i < SIZE_GRAM_MATRIX; i++)
		matrixGram[i] = 0;

	unsigned char* systemOfVectors_GPU; 
	unsigned char* matrixGram_GPU;

	hipEvent_t startCUDA, stopCUDA;
	CHECK(hipEventCreate(&startCUDA));
	CHECK(hipEventCreate(&stopCUDA));

	CHECK(hipMalloc(&systemOfVectors_GPU, memoryForBigVector));
	CHECK(hipMalloc(&matrixGram_GPU, memoryForGramMatrix));
	
	CHECK(hipMemcpy(systemOfVectors_GPU, systemOfVectors, memoryForBigVector, hipMemcpyHostToDevice));
	CHECK(hipMemcpy(matrixGram_GPU, matrixGram, memoryForGramMatrix, hipMemcpyHostToDevice));

	CHECK(hipEventRecord(startCUDA, 0));

	cout << "Calculate on DEVICE...\n";
	
	int size = SIZE_GRAM_MATRIX - (SIZE_GRAM_MATRIX - COUNT_OF_VECTORS_IN_SYSTEM) / 2;

	int countOfBlocks = (SIZE_GRAM_MATRIX + 1023) / 1024;
	//calculate_GramMatrix_GPU<<<1, 1024>>>(systemOfVectors_GPU, matrixGram_GPU);
	calculate_GramMatrix_GPU_Cache <<<dim3(COUNT_OF_VECTORS_IN_SYSTEM / 32, COUNT_OF_VECTORS_IN_SYSTEM / 32, 1),
		dim3(32, 32, 1) >>> (systemOfVectors_GPU, matrixGram_GPU);
	//cout << "Count of blocks: " << countOfBlocks << endl;
	

	hipEventRecord(stopCUDA, 0);
	hipEventSynchronize(stopCUDA);

	hipEventElapsedTime(&time_d, startCUDA, stopCUDA);
	time_d /= 1000;
	CHECK(hipMemcpy(matrixGram, matrixGram_GPU, memoryForGramMatrix, hipMemcpyDeviceToHost));
	cout << "Done\n";
	
	hipFree(systemOfVectors_GPU);
	hipFree(matrixGram_GPU);
	return matrixGram;
}

unsigned char* GetGramMatrixCPU(unsigned char* systemOfVectors, float& time_h)
{
	cout << "Calculate on Host...\n";
	unsigned char* matrixGram = new unsigned char[SIZE_GRAM_MATRIX];

	time_h = clock();
	for (int i = 0; i < SIZE_GRAM_MATRIX; i++)
	{
		matrixGram[i] = 0;
		for (int j = 0; j < COUNT_OF_ELEMENTS_IN_VECTOR; j++)
			matrixGram[i] +=
			systemOfVectors[(i / COUNT_OF_VECTORS_IN_SYSTEM) * COUNT_OF_ELEMENTS_IN_VECTOR + j] *
			systemOfVectors[(i % COUNT_OF_VECTORS_IN_SYSTEM) * COUNT_OF_ELEMENTS_IN_VECTOR + j];
	}
	time_h /= CLOCKS_PER_SEC;
	return matrixGram;
}

void Check(unsigned char* matrix_Host, unsigned char* matrix_Device)
{
	cout << "\nCheck...\n";
	if (IsEqual(matrix_Host, matrix_Device, SIZE_GRAM_MATRIX))
		cout << "That's right! :)\n";
	else cout << "Wrong! :(\n";
}
bool IsEqual(unsigned char* firstVector, unsigned char* secondVector, size_t size)
{	
	int countOfMistakes = 0;
	for (int i = 0; i < size; i++)
		if (firstVector[i] != secondVector[i])
			countOfMistakes++;
	cout << "Count of miss: " << countOfMistakes << endl;
	return countOfMistakes == 0;
}
unsigned char* GetRandomSystemOfVectors()
{
	unsigned char* vector = new unsigned char[COUNT_OF_ELEMENTS_IN_SYSTEM];
	for (int i = 0; i < COUNT_OF_ELEMENTS_IN_SYSTEM; i++)
		vector[i] = rand() % 9 + 1;
	return vector;
}
void InfoResult(unsigned char* matrix_Host, unsigned char* matrix_Device)
{
	cout << "\nGram matrix CPU: " << endl;
	PrintVector(matrix_Host, SIZE_GRAM_MATRIX);

	cout << "\nGram matrix GPU: " << endl;
	PrintVector(matrix_Device, SIZE_GRAM_MATRIX);
}

void PrintSystemOfVectors(unsigned char* systemOfVectors)
{
	bool step = COUNT_OF_ELEMENTS_IN_SYSTEM < 10;
	cout << "\nBig vector:\n\n";
	for (int i = 0, j = 0; i < COUNT_OF_ELEMENTS_IN_SYSTEM; i++, j++)
	{
		if (j == COUNT_OF_ELEMENTS_IN_VECTOR && step)
		{
			cout << endl;
			j = 0;
		}
		cout << (int)systemOfVectors[i] << " ";
	}
	cout << endl;
}
void PrintVector(unsigned char* vector, size_t size)
{
	if (PRINT_MATRIX)
	{
		for (int i = 0; i < COUNT_OF_VECTORS_IN_SYSTEM; i++)
		{
			for (int j = 0; j < COUNT_OF_VECTORS_IN_SYSTEM; j++)
			{
				cout << (int)vector[i * COUNT_OF_VECTORS_IN_SYSTEM + j] << "\t";
				if (i * COUNT_OF_VECTORS_IN_SYSTEM + j == 200) return;
			}
			cout << endl;
		}
	}
	else
	{
		for (int i = 0; i < size; i++)
			cout << (int)vector[i] << " ";
		cout << endl;
	}
}



	.text
	.file	"GramMatrixOptimizeGPU.hip"
                                        # Start of file scope inline assembly
	.globl	_ZSt21ios_base_library_initv

                                        # End of file scope inline assembly
	.globl	_Z45__device_stub__calculate_GramMatrix_GPU_CachePhS_ # -- Begin function _Z45__device_stub__calculate_GramMatrix_GPU_CachePhS_
	.type	_Z45__device_stub__calculate_GramMatrix_GPU_CachePhS_,@function
_Z45__device_stub__calculate_GramMatrix_GPU_CachePhS_: # @_Z45__device_stub__calculate_GramMatrix_GPU_CachePhS_
	.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	$80, %rsp
	.cfi_def_cfa_offset 128
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	24(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	16(%rsp), %rcx
	movq	%rsi, (%rcx)
	leaq	64(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	leaq	48(%rsp), %r14
	leaq	32(%rsp), %r15
	leaq	8(%rsp), %r12
	movq	%rsp, %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z30calculate_GramMatrix_GPU_CachePhS_, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$96, %rsp
	.cfi_adjust_cfa_offset -96
	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	_Z45__device_stub__calculate_GramMatrix_GPU_CachePhS_, .Lfunc_end0-_Z45__device_stub__calculate_GramMatrix_GPU_CachePhS_
	.cfi_endproc
                                        # -- End function
	.globl	_Z39__device_stub__calculate_GramMatrix_GPUPhS_ # -- Begin function _Z39__device_stub__calculate_GramMatrix_GPUPhS_
	.type	_Z39__device_stub__calculate_GramMatrix_GPUPhS_,@function
_Z39__device_stub__calculate_GramMatrix_GPUPhS_: # @_Z39__device_stub__calculate_GramMatrix_GPUPhS_
	.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	$80, %rsp
	.cfi_def_cfa_offset 128
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	24(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	16(%rsp), %rcx
	movq	%rsi, (%rcx)
	leaq	64(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	leaq	48(%rsp), %r14
	leaq	32(%rsp), %r15
	leaq	8(%rsp), %r12
	movq	%rsp, %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z24calculate_GramMatrix_GPUPhS_, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$96, %rsp
	.cfi_adjust_cfa_offset -96
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end1:
	.size	_Z39__device_stub__calculate_GramMatrix_GPUPhS_, .Lfunc_end1-_Z39__device_stub__calculate_GramMatrix_GPUPhS_
	.cfi_endproc
                                        # -- End function
	.globl	main                            # -- Begin function main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r12
	.cfi_def_cfa_offset 32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	pushq	%rax
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -40
	.cfi_offset %r12, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movl	$_ZSt4cout, %edi
	movl	$.L.str.23, %esi
	movl	$16, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	$_ZSt4cout, %edi
	movl	$102400000, %esi                # imm = 0x61A8000
	callq	_ZNSolsEi
	movq	%rax, %rbx
	movl	$.L.str.24, %esi
	movl	$19, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	%rbx, %rdi
	movl	$64, %esi
	callq	_ZNSolsEi
	movq	%rax, %rbx
	movl	$.L.str.25, %esi
	movl	$34, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	%rbx, %rdi
	movl	$1600000, %esi                  # imm = 0x186A00
	callq	_ZNSolsEi
	movq	%rax, %rbx
	movq	(%rax), %rax
	movq	-24(%rax), %rdi
	addq	%rbx, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movq	%rbx, %rdi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	xorl	%eax, %eax
	leaq	4(%rsp), %r14
	movl	%eax, (%r14)
	movq	%rsp, %rbx
	movl	%eax, (%rbx)
	callq	_Z24GetRandomSystemOfVectorsv
	movq	%rax, %r15
	movl	$_ZSt4cout, %edi
	movl	$.L.str, %esi
	movl	$19, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	$_ZSt4cout, %edi
	movl	$4096, %esi                     # imm = 0x1000
	callq	_ZNSolsEi
	movl	$.L.str.1, %esi
	movl	$2, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	%r15, %rdi
	movq	%r14, %rsi
	callq	_Z16GetGramMatrixCPUPhRf
	movq	%rax, %r12
	movq	%r15, %rdi
	movq	%rbx, %rsi
	callq	_Z16GetGramMatrixGPUPhRf
	movq	%r12, %rdi
	movq	%rax, %rsi
	callq	_Z5CheckPhS_
	movl	$_ZSt4cout, %edi
	movl	$.L.str.2, %esi
	movl	$10, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	$_ZSt4cout, %edi
	movl	$.L.str.3, %esi
	movl	$10, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	cvtss2sd	(%r14), %xmm0
	movl	$_ZSt4cout, %edi
	callq	_ZNSo9_M_insertIdEERSoT_
	movq	%rax, %r14
	movq	(%rax), %rax
	movq	-24(%rax), %rdi
	addq	%r14, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movq	%r14, %rdi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	movl	$_ZSt4cout, %edi
	movl	$.L.str.4, %esi
	movl	$10, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	xorps	%xmm0, %xmm0
	cvtss2sd	(%rbx), %xmm0
	movl	$_ZSt4cout, %edi
	callq	_ZNSo9_M_insertIdEERSoT_
	movq	%rax, %rbx
	movq	(%rax), %rax
	movq	-24(%rax), %rdi
	addq	%rbx, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movq	%rbx, %rdi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	movl	$_ZSt4cout, %edi
	movl	$.L.str.2, %esi
	movl	$10, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	$_ZSt3cin, %edi
	callq	_ZNSi3getEv
	xorl	%eax, %eax
	addq	$8, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end2:
	.size	main, .Lfunc_end2-main
	.cfi_endproc
                                        # -- End function
	.globl	_Z24GetRandomSystemOfVectorsv   # -- Begin function _Z24GetRandomSystemOfVectorsv
	.type	_Z24GetRandomSystemOfVectorsv,@function
_Z24GetRandomSystemOfVectorsv:          # @_Z24GetRandomSystemOfVectorsv
	.cfi_startproc
# %bb.0:
	pushq	%r14
	.cfi_def_cfa_offset 16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	pushq	%rax
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -24
	.cfi_offset %r14, -16
	movl	$102400000, %edi                # imm = 0x61A8000
	callq	_Znam
	movq	%rax, %rbx
	xorl	%r14d, %r14d
.LBB3_1:                                # =>This Inner Loop Header: Depth=1
	callq	rand
	cltq
	imulq	$954437177, %rax, %rcx          # imm = 0x38E38E39
	movq	%rcx, %rdx
	shrq	$63, %rdx
	sarq	$33, %rcx
	addl	%edx, %ecx
	leal	(%rcx,%rcx,8), %ecx
	subl	%ecx, %eax
	incb	%al
	movb	%al, (%rbx,%r14)
	incq	%r14
	cmpq	$102400000, %r14                # imm = 0x61A8000
	jne	.LBB3_1
# %bb.2:
	movq	%rbx, %rax
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end3:
	.size	_Z24GetRandomSystemOfVectorsv, .Lfunc_end3-_Z24GetRandomSystemOfVectorsv
	.cfi_endproc
                                        # -- End function
	.globl	_Z20PrintSystemOfVectorsPh      # -- Begin function _Z20PrintSystemOfVectorsPh
	.type	_Z20PrintSystemOfVectorsPh,@function
_Z20PrintSystemOfVectorsPh:             # @_Z20PrintSystemOfVectorsPh
	.cfi_startproc
# %bb.0:
	pushq	%r14
	.cfi_def_cfa_offset 16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	pushq	%rax
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -24
	.cfi_offset %r14, -16
	movq	%rdi, %rbx
	movl	$_ZSt4cout, %edi
	movl	$.L.str.20, %esi
	movl	$14, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	xorl	%r14d, %r14d
.LBB4_1:                                # =>This Inner Loop Header: Depth=1
	movzbl	(%rbx,%r14), %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSolsEi
	movl	$.L.str.21, %esi
	movl	$1, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	incq	%r14
	cmpq	$102400000, %r14                # imm = 0x61A8000
	jne	.LBB4_1
# %bb.2:
	movq	_ZSt4cout(%rip), %rax
	movl	$_ZSt4cout, %ecx
	movq	-24(%rax), %rdi
	addq	%rcx, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	jmp	_ZNSo5flushEv                   # TAILCALL
.Lfunc_end4:
	.size	_Z20PrintSystemOfVectorsPh, .Lfunc_end4-_Z20PrintSystemOfVectorsPh
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function _Z16GetGramMatrixCPUPhRf
.LCPI5_0:
	.long	0x49742400                      # float 1.0E+6
	.text
	.globl	_Z16GetGramMatrixCPUPhRf
	.type	_Z16GetGramMatrixCPUPhRf,@function
_Z16GetGramMatrixCPUPhRf:               # @_Z16GetGramMatrixCPUPhRf
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rsi, %rbx
	movq	%rdi, %r14
	movl	$_ZSt4cout, %edi
	movl	$.L.str.13, %esi
	movl	$21, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	$4096, %edi                     # imm = 0x1000
	callq	_Znam
	movq	%rax, %r15
	callq	clock
	cvtsi2ss	%rax, %xmm0
	movss	%xmm0, (%rbx)
	xorl	%ecx, %ecx
.LBB5_1:                                # =>This Loop Header: Depth=1
                                        #     Child Loop BB5_2 Depth 2
	movl	%ecx, %eax
	andl	$63, %eax
	imulq	$1600000, %rax, %rdx            # imm = 0x186A00
	addq	%r14, %rdx
	movq	%rcx, %rax
	shrq	$6, %rax
	imulq	$1600000, %rax, %rsi            # imm = 0x186A00
	addq	%r14, %rsi
	xorl	%edi, %edi
	xorl	%r8d, %r8d
.LBB5_2:                                #   Parent Loop BB5_1 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movb	(%rdx,%rdi), %al
	mulb	(%rsi,%rdi)
	addb	%al, %r8b
	incq	%rdi
	cmpq	$1600000, %rdi                  # imm = 0x186A00
	jne	.LBB5_2
# %bb.3:                                #   in Loop: Header=BB5_1 Depth=1
	movb	%r8b, (%r15,%rcx)
	incq	%rcx
	cmpq	$4096, %rcx                     # imm = 0x1000
	jne	.LBB5_1
# %bb.4:
	divss	.LCPI5_0(%rip), %xmm0
	movss	%xmm0, (%rbx)
	movq	%r15, %rax
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end5:
	.size	_Z16GetGramMatrixCPUPhRf, .Lfunc_end5-_Z16GetGramMatrixCPUPhRf
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function _Z16GetGramMatrixGPUPhRf
.LCPI6_0:
	.long	0x447a0000                      # float 1000
	.text
	.globl	_Z16GetGramMatrixGPUPhRf
	.type	_Z16GetGramMatrixGPUPhRf,@function
_Z16GetGramMatrixGPUPhRf:               # @_Z16GetGramMatrixGPUPhRf
	.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	%rbx
	.cfi_def_cfa_offset 40
	subq	$40, %rsp
	.cfi_def_cfa_offset 80
	.cfi_offset %rbx, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rsi, %r14
	movq	%rdi, %r15
	movl	$_ZSt4cout, %edi
	movl	$.L.str.5, %esi
	movl	$11, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	$4096, %edi                     # imm = 0x1000
	callq	_Znam
	movq	%rax, %rbx
	movl	$4096, %edx                     # imm = 0x1000
	movq	%rax, %rdi
	xorl	%esi, %esi
	callq	memset@PLT
	leaq	32(%rsp), %rdi
	callq	hipEventCreate
	testl	%eax, %eax
	jne	.LBB6_1
# %bb.3:
	leaq	16(%rsp), %rdi
	callq	hipEventCreate
	testl	%eax, %eax
	jne	.LBB6_4
# %bb.5:
	leaq	24(%rsp), %rdi
	movl	$102400000, %esi                # imm = 0x61A8000
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB6_6
# %bb.7:
	leaq	8(%rsp), %rdi
	movl	$4096, %esi                     # imm = 0x1000
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB6_8
# %bb.9:
	movq	24(%rsp), %rdi
	movl	$102400000, %edx                # imm = 0x61A8000
	movq	%r15, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB6_10
# %bb.11:
	movq	8(%rsp), %rdi
	movl	$4096, %edx                     # imm = 0x1000
	movq	%rbx, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB6_12
# %bb.13:
	movq	32(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	testl	%eax, %eax
	jne	.LBB6_14
# %bb.15:
	movl	$_ZSt4cout, %edi
	movl	$.L.str.11, %esi
	movl	$23, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movabsq	$8589934594, %rdi               # imm = 0x200000002
	movabsq	$137438953504, %rdx             # imm = 0x2000000020
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB6_17
# %bb.16:
	movq	24(%rsp), %rdi
	movq	8(%rsp), %rsi
	callq	_Z45__device_stub__calculate_GramMatrix_GPU_CachePhS_
.LBB6_17:
	movq	16(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	16(%rsp), %rdi
	callq	hipEventSynchronize
	movq	32(%rsp), %rsi
	movq	16(%rsp), %rdx
	movq	%r14, %rdi
	callq	hipEventElapsedTime
	movss	(%r14), %xmm0                   # xmm0 = mem[0],zero,zero,zero
	divss	.LCPI6_0(%rip), %xmm0
	movss	%xmm0, (%r14)
	movq	8(%rsp), %rsi
	movl	$4096, %edx                     # imm = 0x1000
	movq	%rbx, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB6_18
# %bb.19:
	movl	$_ZSt4cout, %edi
	movl	$.L.str.12, %esi
	movl	$5, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	24(%rsp), %rdi
	callq	hipFree
	movq	8(%rsp), %rdi
	callq	hipFree
	movq	%rbx, %rax
	addq	$40, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.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
.LBB6_1:
	.cfi_def_cfa_offset 80
	movl	%eax, %ebp
	movl	$_ZSt4cout, %edi
	movl	$.L.str.6, %esi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rbx
	movl	%ebp, %edi
	callq	hipGetErrorString
	movq	%rbx, %rdi
	movq	%rax, %rsi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movl	$.L.str.7, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rdi
	movl	$139, %esi
	jmp	.LBB6_2
.LBB6_4:
	movl	%eax, %ebp
	movl	$_ZSt4cout, %edi
	movl	$.L.str.6, %esi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rbx
	movl	%ebp, %edi
	callq	hipGetErrorString
	movq	%rbx, %rdi
	movq	%rax, %rsi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movl	$.L.str.7, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rdi
	movl	$140, %esi
	jmp	.LBB6_2
.LBB6_6:
	movl	%eax, %ebp
	movl	$_ZSt4cout, %edi
	movl	$.L.str.6, %esi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rbx
	movl	%ebp, %edi
	callq	hipGetErrorString
	movq	%rbx, %rdi
	movq	%rax, %rsi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movl	$.L.str.7, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rdi
	movl	$142, %esi
	jmp	.LBB6_2
.LBB6_8:
	movl	%eax, %ebp
	movl	$_ZSt4cout, %edi
	movl	$.L.str.6, %esi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rbx
	movl	%ebp, %edi
	callq	hipGetErrorString
	movq	%rbx, %rdi
	movq	%rax, %rsi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movl	$.L.str.7, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rdi
	movl	$143, %esi
	jmp	.LBB6_2
.LBB6_10:
	movl	%eax, %ebp
	movl	$_ZSt4cout, %edi
	movl	$.L.str.6, %esi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rbx
	movl	%ebp, %edi
	callq	hipGetErrorString
	movq	%rbx, %rdi
	movq	%rax, %rsi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movl	$.L.str.7, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rdi
	movl	$145, %esi
	jmp	.LBB6_2
.LBB6_12:
	movl	%eax, %ebp
	movl	$_ZSt4cout, %edi
	movl	$.L.str.6, %esi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rbx
	movl	%ebp, %edi
	callq	hipGetErrorString
	movq	%rbx, %rdi
	movq	%rax, %rsi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movl	$.L.str.7, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rdi
	movl	$146, %esi
	jmp	.LBB6_2
.LBB6_14:
	movl	%eax, %ebp
	movl	$_ZSt4cout, %edi
	movl	$.L.str.6, %esi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rbx
	movl	%ebp, %edi
	callq	hipGetErrorString
	movq	%rbx, %rdi
	movq	%rax, %rsi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movl	$.L.str.7, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rdi
	movl	$148, %esi
	jmp	.LBB6_2
.LBB6_18:
	movl	%eax, %ebp
	movl	$_ZSt4cout, %edi
	movl	$.L.str.6, %esi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rbx
	movl	%ebp, %edi
	callq	hipGetErrorString
	movq	%rbx, %rdi
	movq	%rax, %rsi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movl	$.L.str.7, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rdi
	movl	$166, %esi
.LBB6_2:
	callq	_ZNSolsEi
	movl	$.L.str.8, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movl	$.L.str.9, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movl	$.L.str.10, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movl	$1, %edi
	callq	exit
.Lfunc_end6:
	.size	_Z16GetGramMatrixGPUPhRf, .Lfunc_end6-_Z16GetGramMatrixGPUPhRf
	.cfi_endproc
                                        # -- End function
	.globl	_Z5CheckPhS_                    # -- Begin function _Z5CheckPhS_
	.type	_Z5CheckPhS_,@function
_Z5CheckPhS_:                           # @_Z5CheckPhS_
	.cfi_startproc
# %bb.0:
	pushq	%r14
	.cfi_def_cfa_offset 16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	pushq	%rax
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -24
	.cfi_offset %r14, -16
	movq	%rsi, %rbx
	movq	%rdi, %r14
	movl	$_ZSt4cout, %edi
	movl	$.L.str.14, %esi
	movl	$10, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	$4096, %edx                     # imm = 0x1000
	movq	%r14, %rdi
	movq	%rbx, %rsi
	callq	_Z7IsEqualPhS_m
	movl	$_ZSt4cout, %edi
	testb	%al, %al
	je	.LBB7_3
# %bb.1:
	movl	$.L.str.15, %esi
	movl	$17, %edx
	jmp	.LBB7_2
.LBB7_3:
	movl	$.L.str.16, %esi
	movl	$10, %edx
.LBB7_2:
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	jmp	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l # TAILCALL
.Lfunc_end7:
	.size	_Z5CheckPhS_, .Lfunc_end7-_Z5CheckPhS_
	.cfi_endproc
                                        # -- End function
	.globl	_Z7IsEqualPhS_m                 # -- Begin function _Z7IsEqualPhS_m
	.type	_Z7IsEqualPhS_m,@function
_Z7IsEqualPhS_m:                        # @_Z7IsEqualPhS_m
	.cfi_startproc
# %bb.0:
	pushq	%r14
	.cfi_def_cfa_offset 16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	pushq	%rax
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -24
	.cfi_offset %r14, -16
	testq	%rdx, %rdx
	je	.LBB8_1
# %bb.3:                                # %.lr.ph.preheader
	xorl	%eax, %eax
	xorl	%ebx, %ebx
.LBB8_4:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movb	(%rdi,%rax), %cl
	xorl	%r8d, %r8d
	cmpb	(%rsi,%rax), %cl
	setne	%r8b
	addl	%r8d, %ebx
	incq	%rax
	cmpq	%rax, %rdx
	jne	.LBB8_4
	jmp	.LBB8_2
.LBB8_1:
	xorl	%ebx, %ebx
.LBB8_2:                                # %._crit_edge
	movl	$_ZSt4cout, %edi
	movl	$.L.str.17, %esi
	movl	$15, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	$_ZSt4cout, %edi
	movl	%ebx, %esi
	callq	_ZNSolsEi
	movq	%rax, %r14
	movq	(%rax), %rax
	movq	-24(%rax), %rdi
	addq	%r14, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movq	%r14, %rdi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	testl	%ebx, %ebx
	sete	%al
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end8:
	.size	_Z7IsEqualPhS_m, .Lfunc_end8-_Z7IsEqualPhS_m
	.cfi_endproc
                                        # -- End function
	.globl	_Z10InfoResultPhS_              # -- Begin function _Z10InfoResultPhS_
	.type	_Z10InfoResultPhS_,@function
_Z10InfoResultPhS_:                     # @_Z10InfoResultPhS_
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rsi, %rbx
	movq	%rdi, %r14
	movl	$_ZSt4cout, %r15d
	movl	$_ZSt4cout, %edi
	movl	$.L.str.18, %esi
	movl	$18, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	_ZSt4cout(%rip), %rax
	movq	-24(%rax), %rdi
	addq	%r15, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	movq	%r14, %rdi
	callq	_Z11PrintVectorPhm
	movl	$_ZSt4cout, %edi
	movl	$.L.str.19, %esi
	movl	$18, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	_ZSt4cout(%rip), %rax
	movq	-24(%rax), %rdi
	addq	%r15, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	movq	%rbx, %rdi
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	jmp	_Z11PrintVectorPhm              # TAILCALL
.Lfunc_end9:
	.size	_Z10InfoResultPhS_, .Lfunc_end9-_Z10InfoResultPhS_
	.cfi_endproc
                                        # -- End function
	.globl	_Z11PrintVectorPhm              # -- Begin function _Z11PrintVectorPhm
	.type	_Z11PrintVectorPhm,@function
_Z11PrintVectorPhm:                     # @_Z11PrintVectorPhm
	.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
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rdi, %rbx
	movl	$200, %r14d
	xorl	%r15d, %r15d
	movl	$_ZSt4cout, %r12d
.LBB10_1:                               # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB10_3 Depth 2
	xorl	%r13d, %r13d
.LBB10_3:                               #   Parent Loop BB10_1 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movzbl	(%rbx,%r13), %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSolsEi
	movl	$.L.str.22, %esi
	movl	$1, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	cmpq	%r13, %r14
	je	.LBB10_5
# %bb.2:                                #   in Loop: Header=BB10_3 Depth=2
	incq	%r13
	cmpq	$64, %r13
	jne	.LBB10_3
# %bb.4:                                # %.critedge
                                        #   in Loop: Header=BB10_1 Depth=1
	movq	_ZSt4cout(%rip), %rax
	movq	-24(%rax), %rdi
	addq	%r12, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	incq	%r15
	addq	$-64, %r14
	addq	$64, %rbx
	cmpq	$64, %r15
	jne	.LBB10_1
.LBB10_5:                               # %.loopexit
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end10:
	.size	_Z11PrintVectorPhm, .Lfunc_end10-_Z11PrintVectorPhm
	.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	.LBB11_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB11_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z30calculate_GramMatrix_GPU_CachePhS_, %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	$_Z24calculate_GramMatrix_GPUPhS_, %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_end11:
	.size	__hip_module_ctor, .Lfunc_end11-__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	.LBB12_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
.LBB12_2:
	retq
.Lfunc_end12:
	.size	__hip_module_dtor, .Lfunc_end12-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	_Z30calculate_GramMatrix_GPU_CachePhS_,@object # @_Z30calculate_GramMatrix_GPU_CachePhS_
	.section	.rodata,"a",@progbits
	.globl	_Z30calculate_GramMatrix_GPU_CachePhS_
	.p2align	3, 0x0
_Z30calculate_GramMatrix_GPU_CachePhS_:
	.quad	_Z45__device_stub__calculate_GramMatrix_GPU_CachePhS_
	.size	_Z30calculate_GramMatrix_GPU_CachePhS_, 8

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

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"\nSize Gram matrix: "
	.size	.L.str, 20

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"\n\n"
	.size	.L.str.1, 3

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

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"Time CPU: "
	.size	.L.str.3, 11

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"Time GPU: "
	.size	.L.str.4, 11

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"\n---------\n"
	.size	.L.str.5, 12

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"Error:"
	.size	.L.str.6, 7

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	" at line "
	.size	.L.str.7, 10

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	" in file "
	.size	.L.str.8, 10

	.type	.L.str.9,@object                # @.str.9
.L.str.9:
	.asciz	"/home/ubuntu/Datasets/stackv2/train-structured-repos-hip-sm89/Tessecrack/CUDA_DEV/main/GramMatrix/GramMatrixOptimizeGPU.hip"
	.size	.L.str.9, 124

	.type	.L.str.10,@object               # @.str.10
.L.str.10:
	.asciz	"\n"
	.size	.L.str.10, 2

	.type	.L.str.11,@object               # @.str.11
.L.str.11:
	.asciz	"Calculate on DEVICE...\n"
	.size	.L.str.11, 24

	.type	.L.str.12,@object               # @.str.12
.L.str.12:
	.asciz	"Done\n"
	.size	.L.str.12, 6

	.type	.L.str.13,@object               # @.str.13
.L.str.13:
	.asciz	"Calculate on Host...\n"
	.size	.L.str.13, 22

	.type	.L.str.14,@object               # @.str.14
.L.str.14:
	.asciz	"\nCheck...\n"
	.size	.L.str.14, 11

	.type	.L.str.15,@object               # @.str.15
.L.str.15:
	.asciz	"That's right! :)\n"
	.size	.L.str.15, 18

	.type	.L.str.16,@object               # @.str.16
.L.str.16:
	.asciz	"Wrong! :(\n"
	.size	.L.str.16, 11

	.type	.L.str.17,@object               # @.str.17
.L.str.17:
	.asciz	"Count of miss: "
	.size	.L.str.17, 16

	.type	.L.str.18,@object               # @.str.18
.L.str.18:
	.asciz	"\nGram matrix CPU: "
	.size	.L.str.18, 19

	.type	.L.str.19,@object               # @.str.19
.L.str.19:
	.asciz	"\nGram matrix GPU: "
	.size	.L.str.19, 19

	.type	.L.str.20,@object               # @.str.20
.L.str.20:
	.asciz	"\nBig vector:\n\n"
	.size	.L.str.20, 15

	.type	.L.str.21,@object               # @.str.21
.L.str.21:
	.asciz	" "
	.size	.L.str.21, 2

	.type	.L.str.22,@object               # @.str.22
.L.str.22:
	.asciz	"\t"
	.size	.L.str.22, 2

	.type	.L.str.23,@object               # @.str.23
.L.str.23:
	.asciz	"Size of system: "
	.size	.L.str.23, 17

	.type	.L.str.24,@object               # @.str.24
.L.str.24:
	.asciz	"\nCount of vectors: "
	.size	.L.str.24, 20

	.type	.L.str.25,@object               # @.str.25
.L.str.25:
	.asciz	"\nCount of elements in one vector: "
	.size	.L.str.25, 35

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z30calculate_GramMatrix_GPU_CachePhS_"
	.size	.L__unnamed_1, 39

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_Z24calculate_GramMatrix_GPUPhS_"
	.size	.L__unnamed_2, 33

	.type	__hip_fatbin_wrapper,@object    # @__hip_fatbin_wrapper
	.section	.hipFatBinSegment,"a",@progbits
	.p2align	3, 0x0
__hip_fatbin_wrapper:
	.long	1212764230                      # 0x48495046
	.long	1                               # 0x1
	.quad	__hip_fatbin
	.quad	0
	.size	__hip_fatbin_wrapper, 24

	.type	__hip_gpubin_handle,@object     # @__hip_gpubin_handle
	.local	__hip_gpubin_handle
	.comm	__hip_gpubin_handle,8,8
	.section	.init_array,"aw",@init_array
	.p2align	3, 0x0
	.quad	__hip_module_ctor
	.type	__hip_cuid_,@object             # @__hip_cuid_
	.bss
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               # 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym _Z45__device_stub__calculate_GramMatrix_GPU_CachePhS_
	.addrsig_sym _Z39__device_stub__calculate_GramMatrix_GPUPhS_
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z30calculate_GramMatrix_GPU_CachePhS_
	.addrsig_sym _Z24calculate_GramMatrix_GPUPhS_
	.addrsig_sym _ZSt4cout
	.addrsig_sym _ZSt3cin
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z30calculate_GramMatrix_GPU_CachePhS_ ; -- Begin function _Z30calculate_GramMatrix_GPU_CachePhS_
	.globl	_Z30calculate_GramMatrix_GPU_CachePhS_
	.p2align	8
	.type	_Z30calculate_GramMatrix_GPU_CachePhS_,@function
_Z30calculate_GramMatrix_GPU_CachePhS_: ; @_Z30calculate_GramMatrix_GPU_CachePhS_
; %bb.0:
	v_bfe_u32 v1, v0, 10, 10
	v_and_b32_e32 v0, 0x3ff, v0
	s_load_b128 s[4:7], s[0:1], 0x0
	s_mul_i32 s3, s15, 0x30d4000
	s_mul_i32 s8, s14, 0x30d4000
	s_movk_i32 s2, 0x4080
	v_lshl_add_u32 v2, v1, 5, v0
	v_mul_u32_u24_e32 v3, 0x204, v0
	v_mad_u32_u24 v4, 0x204, v1, s2
	s_mov_b32 s2, 0
	s_delay_alu instid0(VALU_DEP_3) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_lshrrev_b32_e32 v5, 9, v2
	v_and_b32_e32 v2, 0x1ff, v2
	v_mad_u32_u24 v6, 0x186a00, v5, s3
	v_mad_u32_u24 v7, 0x186a00, v5, s8
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_mad_u32_u24 v5, 0x204, v5, v2
	v_or_b32_e32 v6, v6, v2
	s_delay_alu instid0(VALU_DEP_3)
	v_or_b32_e32 v7, v7, v2
	v_mov_b32_e32 v2, 0
.LBB0_1:                                ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB0_2 Depth 2
                                        ;     Child Loop BB0_4 Depth 2
	s_delay_alu instid0(VALU_DEP_4)
	v_mov_b32_e32 v8, v5
	s_mov_b32 s3, 0
.LBB0_2:                                ;   Parent Loop BB0_1 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	s_delay_alu instid0(VALU_DEP_3) | instid1(SALU_CYCLE_1)
	v_add_nc_u32_e32 v9, s3, v7
	v_add_nc_u32_e32 v10, s3, v6
	s_add_i32 s3, s3, 0x30d400
	s_waitcnt lgkmcnt(0)
	s_clause 0x1
	global_load_u8 v9, v9, s[4:5]
	global_load_u8 v10, v10, s[4:5]
	s_cmp_eq_u32 s3, 0x30d4000
	s_waitcnt vmcnt(1)
	ds_store_b8 v8, v9
	s_waitcnt vmcnt(0)
	ds_store_b8 v8, v10 offset:16512
	v_add_nc_u32_e32 v8, 0x408, v8
	s_cbranch_scc0 .LBB0_2
; %bb.3:                                ;   in Loop: Header=BB0_1 Depth=1
	s_mov_b32 s3, 0
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
.LBB0_4:                                ;   Parent Loop BB0_1 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	v_add_nc_u32_e32 v8, s3, v3
	v_add_nc_u32_e32 v9, s3, v4
	s_add_i32 s3, s3, 1
	ds_load_u8 v8, v8
	ds_load_u8 v9, v9
	s_cmpk_eq_i32 s3, 0x200
	s_waitcnt lgkmcnt(0)
	v_mad_u16 v2, v9, v8, v2
	s_cbranch_scc0 .LBB0_4
; %bb.5:                                ;   in Loop: Header=BB0_1 Depth=1
	v_add_nc_u32_e32 v6, 0x200, v6
	v_add_nc_u32_e32 v7, 0x200, v7
	s_add_i32 s2, s2, 1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_cmpk_eq_i32 s2, 0xc35
	s_barrier
	buffer_gl0_inv
	s_cbranch_scc0 .LBB0_1
; %bb.6:
	s_load_b32 s0, s[0:1], 0x1c
	s_waitcnt lgkmcnt(0)
	s_lshr_b32 s1, s0, 16
	s_and_b32 s0, s0, 0xffff
	s_mul_i32 s15, s15, s1
	s_mul_i32 s14, s14, s0
	v_add_lshl_u32 v1, s15, v1, 6
	s_delay_alu instid0(VALU_DEP_1)
	v_add3_u32 v0, s14, v0, v1
	global_store_b8 v0, v2, s[6:7]
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z30calculate_GramMatrix_GPU_CachePhS_
		.amdhsa_group_segment_fixed_size 33024
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 272
		.amdhsa_user_sgpr_count 14
		.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 1
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 1
		.amdhsa_next_free_vgpr 11
		.amdhsa_next_free_sgpr 16
		.amdhsa_reserve_vcc 0
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end0:
	.size	_Z30calculate_GramMatrix_GPU_CachePhS_, .Lfunc_end0-_Z30calculate_GramMatrix_GPU_CachePhS_
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 432
; NumSgprs: 16
; NumVgprs: 11
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 33024 bytes/workgroup (compile time only)
; SGPRBlocks: 1
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 16
; NumVGPRsForWavesPerEU: 11
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 14
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 1
	.text
	.protected	_Z24calculate_GramMatrix_GPUPhS_ ; -- Begin function _Z24calculate_GramMatrix_GPUPhS_
	.globl	_Z24calculate_GramMatrix_GPUPhS_
	.p2align	8
	.type	_Z24calculate_GramMatrix_GPUPhS_,@function
_Z24calculate_GramMatrix_GPUPhS_:       ; @_Z24calculate_GramMatrix_GPUPhS_
; %bb.0:
	s_load_b32 s2, s[0:1], 0x1c
	s_waitcnt lgkmcnt(0)
	s_and_b32 s2, s2, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s15, s2, v[0:1]
	s_mov_b32 s2, exec_lo
	v_cmpx_gt_i32_e32 0x1000, v1
	s_cbranch_execz .LBB1_4
; %bb.1:                                ; %.preheader
	v_ashrrev_i32_e32 v0, 31, v1
	s_load_b128 s[0:3], s[0:1], 0x0
	s_mov_b64 s[4:5], 0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshrrev_b32_e32 v2, 26, v0
	v_add_nc_u32_e32 v2, v1, v2
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_ashrrev_i32_e32 v3, 6, v2
	v_and_b32_e32 v2, 0xffffffc0, v2
	v_mul_lo_u32 v4, 0x186a00, v3
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_sub_nc_u32_e32 v2, v1, v2
	v_mul_lo_u32 v3, 0x186a00, v2
	v_mov_b32_e32 v2, 0
	s_delay_alu instid0(VALU_DEP_4) | instskip(SKIP_2) | instid1(VALU_DEP_2)
	v_ashrrev_i32_e32 v5, 31, v4
	s_waitcnt lgkmcnt(0)
	v_add_co_u32 v4, vcc_lo, s0, v4
	v_add_co_ci_u32_e32 v5, vcc_lo, s1, v5, vcc_lo
.LBB1_2:                                ; =>This Inner Loop Header: Depth=1
	v_add_nc_u32_e32 v8, s4, v3
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_co_u32 v6, vcc_lo, v4, s4
	v_add_co_ci_u32_e32 v7, vcc_lo, s5, v5, vcc_lo
	s_delay_alu instid0(VALU_DEP_3) | instskip(SKIP_3) | instid1(VALU_DEP_2)
	v_ashrrev_i32_e32 v9, 31, v8
	v_add_co_u32 v8, vcc_lo, s0, v8
	s_add_u32 s4, s4, 1
	s_addc_u32 s5, s5, 0
	v_add_co_ci_u32_e32 v9, vcc_lo, s1, v9, vcc_lo
	s_cmp_eq_u32 s4, 0x186a00
	s_clause 0x1
	global_load_u8 v6, v[6:7], off
	global_load_u8 v7, v[8:9], off
	s_waitcnt vmcnt(0)
	v_mad_u16 v2, v7, v6, v2
	s_cbranch_scc0 .LBB1_2
; %bb.3:
	v_add_co_u32 v3, vcc_lo, s2, v1
	v_add_co_ci_u32_e32 v4, vcc_lo, s3, v0, vcc_lo
	global_store_b8 v[3:4], v2, off
.LBB1_4:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z24calculate_GramMatrix_GPUPhS_
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 272
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 10
		.amdhsa_next_free_sgpr 16
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end1:
	.size	_Z24calculate_GramMatrix_GPUPhS_, .Lfunc_end1-_Z24calculate_GramMatrix_GPUPhS_
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 276
; NumSgprs: 18
; NumVgprs: 10
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 10
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __hip_cuid_
	.amdgpu_metadata
---
amdhsa.kernels:
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .offset:         16
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         20
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         24
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         28
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         30
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         32
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         34
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         36
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         38
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         56
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         64
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         80
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 33024
    .kernarg_segment_align: 8
    .kernarg_segment_size: 272
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z30calculate_GramMatrix_GPU_CachePhS_
    .private_segment_fixed_size: 0
    .sgpr_count:     16
    .sgpr_spill_count: 0
    .symbol:         _Z30calculate_GramMatrix_GPU_CachePhS_.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     11
    .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:     hidden_block_count_x
      - .offset:         20
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         24
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         28
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         30
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         32
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         34
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         36
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         38
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         56
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         64
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         80
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 272
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z24calculate_GramMatrix_GPUPhS_
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z24calculate_GramMatrix_GPUPhS_.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     10
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
