#include <cmath>
#include <iostream>

#define N 25600
#define M 1024

using namespace std;

#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);                                                            \
    } }

void generateMatrix(int* matrix, int size) {
	srand(time(NULL));
	for (size_t i = 0; i < size; ++i) {
		matrix[i] = rand() % 100;
	}
}

void print(int* matrix, int n, int m) {
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < m; ++j) {
			cout << matrix[i*m + j] << " ";
		}
		cout << endl;
	}
	cout << endl;
}

void compute(int* matrix, int n, int m, int* result) {
	for (int i = 0; i < n; ++i) {
		result[i] = 0;
		int sz = i * m;
		for (int j = 1; j < m; ++j) {
			if (matrix[sz + j - 1] > matrix[sz + j])
				++result[i];
		}
	}
}

bool checkResult(int* resultCPU, int* resultGPU, int n) {
	for(int i = 0; i < N; ++i){
		if(resultCPU[i] != resultGPU[i]){
      cout << "Wrong in str: " << i << " inCPU: " << resultCPU[i] << " inGPU: " << resultGPU[i] << endl;
			return false;
    }
	}
	return true;
}

__global__ void fastComputeCUDA(int* matrix, int n, int m, int* result)
{
  int idxStr = threadIdx.x + blockIdx.x*blockDim.x;
	if(idxStr >= n) return;
	int res = 0;
  int temp0 = matrix[idxStr*m];

  __shared__ int cache[256][33];
  for(int k = 0; k < m/32; ++k){
      //32 потока читают одну строчку
      for(int s = 0; s < 256/8; ++s){
        int row = threadIdx.x / 32 + s*8;
        int col = k * 32 + threadIdx.x % 32;
        cache[row][threadIdx.x % 32]
        = matrix[(blockIdx.x*256 + row) * m + col];
      }

    __syncthreads();

    for(int idx = 0; idx < 32; ++idx){
      int tempC = cache[threadIdx.x][idx];
  		if(temp0 > tempC)
  			++res;
      temp0 = tempC;
  	}
  }
	result[idxStr] = res;
}

int main(void) {
	float elapsedTimeCUDA, elapsedTimeCPU;
	clock_t startCPU;

	int* matrixDEVICE;
	int* resultDEVICE;
	int* resultHOST = new int[N];
	int* matrixHOST = new int[N*M];
	int* resultCPU = new int[N];

	generateMatrix(matrixHOST, N*M);
	startCPU = clock();
	compute(matrixHOST, N, M, resultCPU);
	elapsedTimeCPU = (double)(clock() - startCPU) / CLOCKS_PER_SEC;

	cout << "CPU time = " << elapsedTimeCPU * 1000 << " ms\n";
	cout << "CPU memory throughput = " << N * M * 4 / elapsedTimeCPU / 1024 / 1024 / 1024 << " Gb/s\n";

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

  cudaDeviceSetCacheConfig(cudaFuncCachePreferL1);

	CHECK(cudaMalloc(&matrixDEVICE, N * M * 4));
	CHECK(cudaMemcpy(matrixDEVICE, matrixHOST, N * M * 4, cudaMemcpyHostToDevice));

	CHECK(cudaMalloc(&resultDEVICE, N * 4));

	cudaEventRecord(startCUDA, 0);
	fastComputeCUDA <<<((N + 255)/256), 256 >>> (matrixDEVICE, N, M, resultDEVICE);
	cudaEventRecord(stopCUDA, 0);
	cudaEventSynchronize(stopCUDA);
	CHECK(cudaGetLastError());
	cudaEventElapsedTime(&elapsedTimeCUDA, startCUDA, stopCUDA);

	CHECK(cudaMemcpy(resultHOST, resultDEVICE, N * 4, cudaMemcpyDeviceToHost));

	cout << (checkResult(resultCPU, resultHOST, N) ? "Result is correct" : "Result isn't correct") << endl;

	cout << "CUDA time = " << elapsedTimeCUDA << " ms\n";
	cout << "CUDA memory throughput = " << N * M * 4 / elapsedTimeCUDA / 1024 / 1024 / 1.024 << " Gb/s\n";

	//waitKey(0);
	return 0;
}

	.file	"tmpxft_0033082f_00000000-6_Lab4.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB3642:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE3642:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z14generateMatrixPii
	.type	_Z14generateMatrixPii, @function
_Z14generateMatrixPii:
.LFB3635:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movq	%rdi, %r12
	xorl	%edi, %edi
	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
	movslq	%esi, %rbx
	call	time@PLT
	movl	%eax, %edi
	call	srand@PLT
.L3:
	cmpq	%rbx, %rbp
	jnb	.L7
	call	rand@PLT
	movl	$100, %ecx
	cltd
	idivl	%ecx
	movl	%edx, (%r12,%rbp,4)
	incq	%rbp
	jmp	.L3
.L7:
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3635:
	.size	_Z14generateMatrixPii, .-_Z14generateMatrixPii
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	" "
	.text
	.globl	_Z5printPiii
	.type	_Z5printPiii, @function
_Z5printPiii:
.LFB3636:
	.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
.L9:
	cmpl	%r14d, %r13d
	jge	.L11
	movslq	%r12d, %rax
	xorl	%r15d, %r15d
	leaq	0(%rbp,%rax,4), %rcx
.L12:
	cmpl	%r15d, %ebx
	jle	.L14
	movl	(%rcx,%r15,4), %esi
	leaq	_ZSt4cout(%rip), %rdi
	movq	%rcx, 8(%rsp)
	incq	%r15
	call	_ZNSolsEi@PLT
	leaq	.LC0(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	8(%rsp), %rcx
	jmp	.L12
.L14:
	leaq	_ZSt4cout(%rip), %rdi
	incl	%r13d
	addl	%ebx, %r12d
	call	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT
	jmp	.L9
.L11:
	addq	$24, %rsp
	.cfi_def_cfa_offset 56
	leaq	_ZSt4cout(%rip), %rdi
	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
	jmp	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT
	.cfi_endproc
.LFE3636:
	.size	_Z5printPiii, .-_Z5printPiii
	.globl	_Z7computePiiiS_
	.type	_Z7computePiiiS_, @function
_Z7computePiiiS_:
.LFB3637:
	.cfi_startproc
	endbr64
	movslq	%edx, %r9
	xorl	%eax, %eax
	salq	$2, %r9
.L16:
	cmpl	%eax, %esi
	jle	.L21
	xorl	%r8d, %r8d
	movl	$1, %r10d
	movl	%r8d, (%rcx,%rax,4)
	movq	%rdi, %r8
.L17:
	cmpl	%edx, %r10d
	jge	.L22
	movl	4(%r8), %r11d
	cmpl	%r11d, (%r8)
	jle	.L18
	incl	(%rcx,%rax,4)
.L18:
	incl	%r10d
	addq	$4, %r8
	jmp	.L17
.L22:
	incq	%rax
	addq	%r9, %rdi
	jmp	.L16
.L21:
	ret
	.cfi_endproc
.LFE3637:
	.size	_Z7computePiiiS_, .-_Z7computePiiiS_
	.section	.rodata.str1.1
.LC1:
	.string	"Wrong in str: "
.LC2:
	.string	" inCPU: "
.LC3:
	.string	" inGPU: "
	.text
	.globl	_Z11checkResultPiS_i
	.type	_Z11checkResultPiS_i, @function
_Z11checkResultPiS_i:
.LFB3638:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	xorl	%r12d, %r12d
	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
	movq	%rsi, %rbx
.L26:
	movl	(%rbx), %eax
	cmpl	%eax, 0(%rbp)
	je	.L24
	leaq	.LC1(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	%r12d, %esi
	movq	%rax, %rdi
	call	_ZNSolsEi@PLT
	leaq	.LC2(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	0(%rbp), %esi
	movq	%rax, %rdi
	call	_ZNSolsEi@PLT
	leaq	.LC3(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	(%rbx), %esi
	movq	%rax, %rdi
	call	_ZNSolsEi@PLT
	movq	%rax, %rdi
	call	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT
	xorl	%eax, %eax
	jmp	.L23
.L24:
	incl	%r12d
	addq	$4, %rbp
	addq	$4, %rbx
	cmpl	$25600, %r12d
	jne	.L26
	movb	$1, %al
.L23:
	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	_Z11checkResultPiS_i, .-_Z11checkResultPiS_i
	.globl	_Z39__device_stub__Z15fastComputeCUDAPiiiS_PiiiS_
	.type	_Z39__device_stub__Z15fastComputeCUDAPiiiS_PiiiS_, @function
_Z39__device_stub__Z15fastComputeCUDAPiiiS_PiiiS_:
.LFB3664:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movq	%rdi, 24(%rsp)
	leaq	56(%rsp), %rdi
	movl	%esi, 20(%rsp)
	leaq	68(%rsp), %rsi
	movl	%edx, 16(%rsp)
	leaq	40(%rsp), %rdx
	movq	%rcx, 8(%rsp)
	leaq	48(%rsp), %rcx
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 64(%rsp)
	movq	%rax, 104(%rsp)
	leaq	20(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 128(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 56(%rsp)
	movq	%rax, 68(%rsp)
	movl	$1, 76(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L29
	pushq	48(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z15fastComputeCUDAPiiiS_(%rip), %rdi
	pushq	48(%rsp)
	.cfi_def_cfa_offset 176
	movq	84(%rsp), %rcx
	movl	92(%rsp), %r8d
	movq	72(%rsp), %rsi
	movl	80(%rsp), %edx
	leaq	120(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 168
	popq	%rdx
	.cfi_def_cfa_offset 160
.L29:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L31
	call	__stack_chk_fail@PLT
.L31:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3664:
	.size	_Z39__device_stub__Z15fastComputeCUDAPiiiS_PiiiS_, .-_Z39__device_stub__Z15fastComputeCUDAPiiiS_PiiiS_
	.globl	_Z15fastComputeCUDAPiiiS_
	.type	_Z15fastComputeCUDAPiiiS_, @function
_Z15fastComputeCUDAPiiiS_:
.LFB3665:
	.cfi_startproc
	endbr64
	jmp	_Z39__device_stub__Z15fastComputeCUDAPiiiS_PiiiS_
	.cfi_endproc
.LFE3665:
	.size	_Z15fastComputeCUDAPiiiS_, .-_Z15fastComputeCUDAPiiiS_
	.section	.rodata.str1.1
.LC4:
	.string	"Result is correct"
.LC5:
	.string	"Result isn't correct"
.LC7:
	.string	"CPU time = "
.LC9:
	.string	" ms\n"
.LC10:
	.string	"CPU memory throughput = "
.LC13:
	.string	" Gb/s\n"
.LC14:
	.string	"Error:"
.LC15:
	.string	" at line "
.LC16:
	.string	" in file "
.LC17:
	.string	"/home/ubuntu/Datasets/stackv2/train-structured/Ukolnir/MMCS_CS322_CUDA/master/Lab4.cu"
.LC18:
	.string	"\n"
.LC19:
	.string	"CUDA time = "
.LC20:
	.string	"CUDA memory throughput = "
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB3639:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	$102400, %edi
	leaq	.LC9(%rip), %r15
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	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	$88, %rsp
	.cfi_def_cfa_offset 144
	movq	%fs:40, %rax
	movq	%rax, 72(%rsp)
	xorl	%eax, %eax
	call	_Znam@PLT
	movl	$104857600, %edi
	movq	%rax, %r14
	call	_Znam@PLT
	movl	$102400, %edi
	movq	%rax, %r12
	call	_Znam@PLT
	movl	$26214400, %esi
	movq	%r12, %rdi
	movq	%rax, %r13
	call	_Z14generateMatrixPii
	call	clock@PLT
	movq	%r13, %rcx
	movl	$1024, %edx
	movq	%r12, %rdi
	movl	$25600, %esi
	movq	%rax, %rbx
	call	_Z7computePiiiS_
	call	clock@PLT
	leaq	.LC7(%rip), %rsi
	subq	%rbx, %rax
	leaq	_ZSt4cout(%rip), %rbx
	movq	%rbx, %rdi
	cvtsi2sdq	%rax, %xmm0
	divsd	.LC6(%rip), %xmm0
	cvtsd2ss	%xmm0, %xmm1
	movss	%xmm1, 12(%rsp)
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movss	12(%rsp), %xmm0
	mulss	.LC8(%rip), %xmm0
	movq	%rax, %rdi
	cvtss2sd	%xmm0, %xmm0
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	movq	%r15, %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC10(%rip), %rsi
	movq	%rbx, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movss	.LC11(%rip), %xmm0
	divss	12(%rsp), %xmm0
	mulss	.LC12(%rip), %xmm0
	mulss	.LC12(%rip), %xmm0
	movq	%rax, %rdi
	mulss	.LC12(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	leaq	.LC13(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	32(%rsp), %rdi
	call	cudaEventCreate@PLT
	leaq	40(%rsp), %rdi
	call	cudaEventCreate@PLT
	movl	$2, %edi
	call	cudaDeviceSetCacheConfig@PLT
	leaq	16(%rsp), %rdi
	movl	$104857600, %esi
	call	cudaMalloc@PLT
	testl	%eax, %eax
	je	.L35
	leaq	.LC14(%rip), %rsi
	movq	%rbx, %rdi
	movl	%eax, %ebp
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	%ebp, %edi
	movq	%rax, %rbx
	call	cudaGetErrorString@PLT
	movq	%rbx, %rdi
	movq	%rax, %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC15(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	$108, %esi
	movq	%rax, %rdi
	jmp	.L45
.L35:
	movq	16(%rsp), %rdi
	movq	%r12, %rsi
	movl	$1, %ecx
	movl	$104857600, %edx
	call	cudaMemcpy@PLT
	movl	%eax, %r12d
	testl	%eax, %eax
	je	.L36
	leaq	.LC14(%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	.LC15(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	$109, %esi
	movq	%rax, %rdi
.L45:
	call	_ZNSolsEi@PLT
	leaq	.LC16(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@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
	movl	$1, %edi
	call	exit@PLT
.L36:
	leaq	24(%rsp), %rdi
	movl	$102400, %esi
	call	cudaMalloc@PLT
	movl	%eax, %r12d
	testl	%eax, %eax
	je	.L37
	leaq	.LC14(%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	.LC15(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	$111, %esi
	movq	%rax, %rdi
	jmp	.L45
.L37:
	movq	32(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movl	$16777217, %edx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	$1073741849, %edi
	salq	$8, %rdx
	movl	$1, %ecx
	movl	$1, %esi
	salq	$2, %rdi
	movq	%rdx, 60(%rsp)
	movl	$1, 68(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L38
	movq	24(%rsp), %rcx
	movq	16(%rsp), %rdi
	movl	$1024, %edx
	movl	$25600, %esi
	call	_Z39__device_stub__Z15fastComputeCUDAPiiiS_PiiiS_
.L38:
	movq	40(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	40(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	call	cudaGetLastError@PLT
	movl	%eax, %r12d
	testl	%eax, %eax
	je	.L39
	leaq	.LC14(%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	.LC15(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	$117, %esi
	movq	%rax, %rdi
	jmp	.L45
.L39:
	movq	40(%rsp), %rdx
	movq	32(%rsp), %rsi
	leaq	60(%rsp), %rdi
	call	cudaEventElapsedTime@PLT
	movq	24(%rsp), %rsi
	movl	$2, %ecx
	movq	%r14, %rdi
	movl	$102400, %edx
	call	cudaMemcpy@PLT
	movl	%eax, %r12d
	testl	%eax, %eax
	je	.L40
	leaq	.LC14(%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	.LC15(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	$120, %esi
	movq	%rax, %rdi
	jmp	.L45
.L40:
	movl	$25600, %edx
	movq	%r14, %rsi
	movq	%r13, %rdi
	call	_Z11checkResultPiS_i
	leaq	.LC5(%rip), %rsi
	movq	%rbx, %rdi
	testb	%al, %al
	leaq	.LC4(%rip), %rax
	cmovne	%rax, %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%rax, %rdi
	call	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT
	leaq	.LC19(%rip), %rsi
	movq	%rbx, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	cvtss2sd	60(%rsp), %xmm0
	movq	%rax, %rdi
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	movq	%r15, %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC20(%rip), %rsi
	movq	%rbx, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movss	.LC11(%rip), %xmm0
	divss	60(%rsp), %xmm0
	mulss	.LC12(%rip), %xmm0
	mulss	.LC12(%rip), %xmm0
	movq	%rax, %rdi
	cvtss2sd	%xmm0, %xmm0
	divsd	.LC21(%rip), %xmm0
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	leaq	.LC13(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	72(%rsp), %rax
	subq	%fs:40, %rax
	je	.L42
	call	__stack_chk_fail@PLT
.L42:
	addq	$88, %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
.LFE3639:
	.size	main, .-main
	.section	.rodata.str1.1
.LC22:
	.string	"_Z15fastComputeCUDAPiiiS_"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB3667:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 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	.LC22(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z15fastComputeCUDAPiiiS_(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 48
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	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	%rdx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE3667:
	.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.cst8,"aM",@progbits,8
	.align 8
.LC6:
	.long	0
	.long	1093567616
	.section	.rodata.cst4,"aM",@progbits,4
	.align 4
.LC8:
	.long	1148846080
	.align 4
.LC11:
	.long	1288175616
	.align 4
.LC12:
	.long	981467136
	.section	.rodata.cst8
	.align 8
.LC21:
	.long	-755914244
	.long	1072718413
	.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 <cmath>
#include <iostream>

#define N 25600
#define M 1024

using namespace std;

#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);                                                            \
    } }

void generateMatrix(int* matrix, int size) {
	srand(time(NULL));
	for (size_t i = 0; i < size; ++i) {
		matrix[i] = rand() % 100;
	}
}

void print(int* matrix, int n, int m) {
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < m; ++j) {
			cout << matrix[i*m + j] << " ";
		}
		cout << endl;
	}
	cout << endl;
}

void compute(int* matrix, int n, int m, int* result) {
	for (int i = 0; i < n; ++i) {
		result[i] = 0;
		int sz = i * m;
		for (int j = 1; j < m; ++j) {
			if (matrix[sz + j - 1] > matrix[sz + j])
				++result[i];
		}
	}
}

bool checkResult(int* resultCPU, int* resultGPU, int n) {
	for(int i = 0; i < N; ++i){
		if(resultCPU[i] != resultGPU[i]){
      cout << "Wrong in str: " << i << " inCPU: " << resultCPU[i] << " inGPU: " << resultGPU[i] << endl;
			return false;
    }
	}
	return true;
}

__global__ void fastComputeCUDA(int* matrix, int n, int m, int* result)
{
  int idxStr = threadIdx.x + blockIdx.x*blockDim.x;
	if(idxStr >= n) return;
	int res = 0;
  int temp0 = matrix[idxStr*m];

  __shared__ int cache[256][33];
  for(int k = 0; k < m/32; ++k){
      //32 потока читают одну строчку
      for(int s = 0; s < 256/8; ++s){
        int row = threadIdx.x / 32 + s*8;
        int col = k * 32 + threadIdx.x % 32;
        cache[row][threadIdx.x % 32]
        = matrix[(blockIdx.x*256 + row) * m + col];
      }

    __syncthreads();

    for(int idx = 0; idx < 32; ++idx){
      int tempC = cache[threadIdx.x][idx];
  		if(temp0 > tempC)
  			++res;
      temp0 = tempC;
  	}
  }
	result[idxStr] = res;
}

int main(void) {
	float elapsedTimeCUDA, elapsedTimeCPU;
	clock_t startCPU;

	int* matrixDEVICE;
	int* resultDEVICE;
	int* resultHOST = new int[N];
	int* matrixHOST = new int[N*M];
	int* resultCPU = new int[N];

	generateMatrix(matrixHOST, N*M);
	startCPU = clock();
	compute(matrixHOST, N, M, resultCPU);
	elapsedTimeCPU = (double)(clock() - startCPU) / CLOCKS_PER_SEC;

	cout << "CPU time = " << elapsedTimeCPU * 1000 << " ms\n";
	cout << "CPU memory throughput = " << N * M * 4 / elapsedTimeCPU / 1024 / 1024 / 1024 << " Gb/s\n";

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

  hipDeviceSetCacheConfig(hipFuncCachePreferL1);

	CHECK(hipMalloc(&matrixDEVICE, N * M * 4));
	CHECK(hipMemcpy(matrixDEVICE, matrixHOST, N * M * 4, hipMemcpyHostToDevice));

	CHECK(hipMalloc(&resultDEVICE, N * 4));

	hipEventRecord(startCUDA, 0);
	fastComputeCUDA <<<((N + 255)/256), 256 >>> (matrixDEVICE, N, M, resultDEVICE);
	hipEventRecord(stopCUDA, 0);
	hipEventSynchronize(stopCUDA);
	CHECK(hipGetLastError());
	hipEventElapsedTime(&elapsedTimeCUDA, startCUDA, stopCUDA);

	CHECK(hipMemcpy(resultHOST, resultDEVICE, N * 4, hipMemcpyDeviceToHost));

	cout << (checkResult(resultCPU, resultHOST, N) ? "Result is correct" : "Result isn't correct") << endl;

	cout << "CUDA time = " << elapsedTimeCUDA << " ms\n";
	cout << "CUDA memory throughput = " << N * M * 4 / elapsedTimeCUDA / 1024 / 1024 / 1.024 << " Gb/s\n";

	//waitKey(0);
	return 0;
}

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

                                        # End of file scope inline assembly
	.globl	_Z14generateMatrixPii           # -- Begin function _Z14generateMatrixPii
	.type	_Z14generateMatrixPii,@function
_Z14generateMatrixPii:                  # @_Z14generateMatrixPii
	.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
	pushq	%rax
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	%esi, %ebp
	movq	%rdi, %rbx
	xorl	%edi, %edi
	callq	time
	movl	%eax, %edi
	callq	srand
	testl	%ebp, %ebp
	je	.LBB0_3
# %bb.1:                                # %.lr.ph.preheader
	movslq	%ebp, %r14
	xorl	%r15d, %r15d
.LBB0_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	callq	rand
	cltq
	imulq	$1374389535, %rax, %rcx         # imm = 0x51EB851F
	movq	%rcx, %rdx
	shrq	$63, %rdx
	sarq	$37, %rcx
	addl	%edx, %ecx
	imull	$100, %ecx, %ecx
	subl	%ecx, %eax
	movl	%eax, (%rbx,%r15,4)
	incq	%r15
	cmpq	%r15, %r14
	jne	.LBB0_2
.LBB0_3:                                # %._crit_edge
	addq	$8, %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
.Lfunc_end0:
	.size	_Z14generateMatrixPii, .Lfunc_end0-_Z14generateMatrixPii
	.cfi_endproc
                                        # -- End function
	.globl	_Z5printPiii                    # -- Begin function _Z5printPiii
	.type	_Z5printPiii,@function
_Z5printPiii:                           # @_Z5printPiii
	.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	.LBB1_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
.LBB1_2:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_4 Depth 2
	testl	%ebx, %ebx
	jle	.LBB1_5
# %bb.3:                                # %.lr.ph
                                        #   in Loop: Header=BB1_2 Depth=1
	movl	%r13d, %eax
	movq	8(%rsp), %rcx                   # 8-byte Reload
	leaq	(%rcx,%rax,4), %r14
	xorl	%r15d, %r15d
.LBB1_4:                                #   Parent Loop BB1_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	(%r14,%r15,4), %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSolsEi
	movl	$.L.str, %esi
	movl	$1, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	incq	%r15
	cmpq	%r15, %r12
	jne	.LBB1_4
.LBB1_5:                                # %._crit_edge
                                        #   in Loop: Header=BB1_2 Depth=1
	movq	_ZSt4cout(%rip), %rax
	movq	-24(%rax), %rdi
	movl	$_ZSt4cout, %eax
	addq	%rax, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	incq	%rbp
	addl	%ebx, %r13d
	cmpq	16(%rsp), %rbp                  # 8-byte Folded Reload
	jne	.LBB1_2
.LBB1_6:                                # %._crit_edge13
	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	$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
	jmp	_ZNSo5flushEv                   # TAILCALL
.Lfunc_end1:
	.size	_Z5printPiii, .Lfunc_end1-_Z5printPiii
	.cfi_endproc
                                        # -- End function
	.globl	_Z7computePiiiS_                # -- Begin function _Z7computePiiiS_
	.type	_Z7computePiiiS_,@function
_Z7computePiiiS_:                       # @_Z7computePiiiS_
	.cfi_startproc
# %bb.0:
	testl	%esi, %esi
	jle	.LBB2_9
# %bb.1:                                # %.lr.ph21
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset %rbx, -24
	.cfi_offset %rbp, -16
	movl	%esi, %eax
	movl	%edx, %esi
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
.LBB2_2:                                # =>This Loop Header: Depth=1
                                        #     Child Loop BB2_4 Depth 2
	movl	$0, (%rcx,%r9,4)
	cmpl	$2, %edx
	jl	.LBB2_7
# %bb.3:                                # %.lr.ph.preheader
                                        #   in Loop: Header=BB2_2 Depth=1
	movl	%r8d, %r10d
	leaq	(%rdi,%r10,4), %r10
	movl	$1, %r11d
	xorl	%ebx, %ebx
.LBB2_4:                                # %.lr.ph
                                        #   Parent Loop BB2_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	-4(%r10,%r11,4), %ebp
	cmpl	(%r10,%r11,4), %ebp
	jle	.LBB2_6
# %bb.5:                                #   in Loop: Header=BB2_4 Depth=2
	incl	%ebx
	movl	%ebx, (%rcx,%r9,4)
.LBB2_6:                                #   in Loop: Header=BB2_4 Depth=2
	incq	%r11
	cmpq	%r11, %rsi
	jne	.LBB2_4
.LBB2_7:                                # %._crit_edge
                                        #   in Loop: Header=BB2_2 Depth=1
	incq	%r9
	addl	%edx, %r8d
	cmpq	%rax, %r9
	jne	.LBB2_2
# %bb.8:
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	.cfi_restore %rbx
	.cfi_restore %rbp
.LBB2_9:                                # %._crit_edge22
	retq
.Lfunc_end2:
	.size	_Z7computePiiiS_, .Lfunc_end2-_Z7computePiiiS_
	.cfi_endproc
                                        # -- End function
	.globl	_Z11checkResultPiS_i            # -- Begin function _Z11checkResultPiS_i
	.type	_Z11checkResultPiS_i,@function
_Z11checkResultPiS_i:                   # @_Z11checkResultPiS_i
	.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	%rsi, %r14
	movq	%rdi, %r15
	movl	(%rdi), %eax
	cmpl	(%rsi), %eax
	jne	.LBB3_1
# %bb.5:                                # %.lr.ph.preheader
	xorl	%eax, %eax
.LBB3_6:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	cmpq	$25599, %rax                    # imm = 0x63FF
	je	.LBB3_7
# %bb.2:                                #   in Loop: Header=BB3_6 Depth=1
	movl	4(%r15,%rax,4), %ecx
	leaq	1(%rax), %r12
	cmpl	4(%r14,%rax,4), %ecx
	movq	%r12, %rax
	je	.LBB3_6
# %bb.3:                                # %._crit_edge.loopexit
	leaq	-1(%r12), %rax
	cmpq	$25599, %rax                    # imm = 0x63FF
	setae	%bl
	jmp	.LBB3_4
.LBB3_1:
	xorl	%r12d, %r12d
	xorl	%ebx, %ebx
.LBB3_4:                                # %._crit_edge
	movl	$_ZSt4cout, %edi
	movl	$.L.str.1, %esi
	movl	$14, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	$_ZSt4cout, %edi
	movl	%r12d, %esi
	callq	_ZNSolsEi
	movq	%rax, %r13
	movl	$.L.str.2, %esi
	movl	$8, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	(%r15,%r12,4), %esi
	movq	%r13, %rdi
	callq	_ZNSolsEi
	movq	%rax, %r15
	movl	$.L.str.3, %esi
	movl	$8, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	(%r14,%r12,4), %esi
	movq	%r15, %rdi
	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
	jmp	.LBB3_8
.LBB3_7:                                # %.loopexit.loopexit
	setae	%bl
.LBB3_8:                                # %.loopexit
	movl	%ebx, %eax
	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	_Z11checkResultPiS_i, .Lfunc_end3-_Z11checkResultPiS_i
	.cfi_endproc
                                        # -- End function
	.globl	_Z30__device_stub__fastComputeCUDAPiiiS_ # -- Begin function _Z30__device_stub__fastComputeCUDAPiiiS_
	.type	_Z30__device_stub__fastComputeCUDAPiiiS_,@function
_Z30__device_stub__fastComputeCUDAPiiiS_: # @_Z30__device_stub__fastComputeCUDAPiiiS_
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$112, %rsp
	.cfi_def_cfa_offset 160
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	12(%rsp), %rdi
	movl	%esi, (%rdi)
	leaq	8(%rsp), %rsi
	movl	%edx, (%rsi)
	leaq	32(%rsp), %rdx
	movq	%rcx, (%rdx)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%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	$_Z15fastComputeCUDAPiiiS_, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$128, %rsp
	.cfi_adjust_cfa_offset -128
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end4:
	.size	_Z30__device_stub__fastComputeCUDAPiiiS_, .Lfunc_end4-_Z30__device_stub__fastComputeCUDAPiiiS_
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI5_0:
	.quad	0x412e848000000000              # double 1.0E+6
.LCPI5_4:
	.quad	0x3ff0624dd2f1a9fc              # double 1.024
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0
.LCPI5_1:
	.long	0x447a0000                      # float 1000
.LCPI5_2:
	.long	0x4cc80000                      # float 104857600
.LCPI5_3:
	.long	0x3a800000                      # float 9.765625E-4
	.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	$40, %rsp
	.cfi_def_cfa_offset 96
	.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	$102400, %edi                   # imm = 0x19000
	callq	_Znam
	movq	%rax, %rbx
	movl	$104857600, %edi                # imm = 0x6400000
	callq	_Znam
	movq	%rax, %r15
	movl	$102400, %edi                   # imm = 0x19000
	callq	_Znam
	movq	%rax, %r14
	movq	%r15, %rdi
	movl	$26214400, %esi                 # imm = 0x1900000
	callq	_Z14generateMatrixPii
	xorl	%r13d, %r13d
	callq	clock
	movq	%rax, %r12
	movq	%r15, %rax
.LBB5_1:                                # =>This Loop Header: Depth=1
                                        #     Child Loop BB5_2 Depth 2
	movl	$0, (%r14,%r13,4)
	movl	$1, %ecx
	xorl	%edx, %edx
.LBB5_2:                                # %.lr.ph.i
                                        #   Parent Loop BB5_1 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	-4(%rax,%rcx,4), %esi
	cmpl	(%rax,%rcx,4), %esi
	jle	.LBB5_4
# %bb.3:                                #   in Loop: Header=BB5_2 Depth=2
	incl	%edx
	movl	%edx, (%r14,%r13,4)
.LBB5_4:                                #   in Loop: Header=BB5_2 Depth=2
	incq	%rcx
	cmpq	$1024, %rcx                     # imm = 0x400
	jne	.LBB5_2
# %bb.5:                                # %._crit_edge.i
                                        #   in Loop: Header=BB5_1 Depth=1
	incq	%r13
	addq	$4096, %rax                     # imm = 0x1000
	cmpq	$25600, %r13                    # imm = 0x6400
	jne	.LBB5_1
# %bb.6:                                # %_Z7computePiiiS_.exit
	callq	clock
	subq	%r12, %rax
	cvtsi2sd	%rax, %xmm0
	divsd	.LCPI5_0(%rip), %xmm0
	cvtsd2ss	%xmm0, %xmm0
	movss	%xmm0, (%rsp)                   # 4-byte Spill
	movl	$_ZSt4cout, %edi
	movl	$.L.str.4, %esi
	movl	$11, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movss	.LCPI5_1(%rip), %xmm0           # xmm0 = mem[0],zero,zero,zero
	mulss	(%rsp), %xmm0                   # 4-byte Folded Reload
	cvtss2sd	%xmm0, %xmm0
	movl	$_ZSt4cout, %edi
	callq	_ZNSo9_M_insertIdEERSoT_
	movl	$.L.str.5, %esi
	movl	$4, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	$_ZSt4cout, %edi
	movl	$.L.str.6, %esi
	movl	$24, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movss	.LCPI5_2(%rip), %xmm0           # xmm0 = mem[0],zero,zero,zero
	divss	(%rsp), %xmm0                   # 4-byte Folded Reload
	movss	.LCPI5_3(%rip), %xmm1           # xmm1 = mem[0],zero,zero,zero
	mulss	%xmm1, %xmm0
	mulss	%xmm1, %xmm0
	mulss	%xmm1, %xmm0
	cvtss2sd	%xmm0, %xmm0
	movl	$_ZSt4cout, %edi
	callq	_ZNSo9_M_insertIdEERSoT_
	movl	$.L.str.7, %esi
	movl	$6, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	leaq	16(%rsp), %rdi
	callq	hipEventCreate
	leaq	8(%rsp), %rdi
	callq	hipEventCreate
	movl	$2, %edi
	callq	hipDeviceSetCacheConfig
	leaq	32(%rsp), %rdi
	movl	$104857600, %esi                # imm = 0x6400000
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB5_7
# %bb.9:
	movq	32(%rsp), %rdi
	movl	$104857600, %edx                # imm = 0x6400000
	movq	%r15, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB5_10
# %bb.11:
	leaq	24(%rsp), %rdi
	movl	$102400, %esi                   # imm = 0x19000
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB5_12
# %bb.13:
	movq	16(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movabsq	$4294967396, %rdi               # imm = 0x100000064
	leaq	156(%rdi), %rdx
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB5_15
# %bb.14:
	movq	32(%rsp), %rdi
	movq	24(%rsp), %rcx
	movl	$25600, %esi                    # imm = 0x6400
	movl	$1024, %edx                     # imm = 0x400
	callq	_Z30__device_stub__fastComputeCUDAPiiiS_
.LBB5_15:
	movq	8(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	8(%rsp), %rdi
	callq	hipEventSynchronize
	callq	hipGetLastError
	testl	%eax, %eax
	jne	.LBB5_16
# %bb.17:
	movq	16(%rsp), %rsi
	movq	8(%rsp), %rdx
	leaq	4(%rsp), %rdi
	callq	hipEventElapsedTime
	movq	24(%rsp), %rsi
	movl	$102400, %edx                   # imm = 0x19000
	movq	%rbx, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB5_18
# %bb.19:
	movq	%r14, %rdi
	movq	%rbx, %rsi
	callq	_Z11checkResultPiS_i
	movl	$.L.str.13, %ecx
	movl	$.L.str.14, %esi
	testb	%al, %al
	cmovneq	%rcx, %rsi
	xorb	$1, %al
	movzbl	%al, %eax
	leaq	(%rax,%rax,2), %rdx
	addq	$17, %rdx
	movl	$_ZSt4cout, %ebx
	movl	$_ZSt4cout, %edi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	_ZSt4cout(%rip), %rax
	movq	-24(%rax), %rdi
	addq	%rbx, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	movl	$_ZSt4cout, %edi
	movl	$.L.str.15, %esi
	movl	$12, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	cvtss2sd	4(%rsp), %xmm0
	movl	$_ZSt4cout, %edi
	callq	_ZNSo9_M_insertIdEERSoT_
	movl	$.L.str.5, %esi
	movl	$4, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	$_ZSt4cout, %edi
	movl	$.L.str.16, %esi
	movl	$25, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movss	.LCPI5_2(%rip), %xmm0           # xmm0 = mem[0],zero,zero,zero
	divss	4(%rsp), %xmm0
	movss	.LCPI5_3(%rip), %xmm1           # xmm1 = mem[0],zero,zero,zero
	mulss	%xmm1, %xmm0
	mulss	%xmm1, %xmm0
	cvtss2sd	%xmm0, %xmm0
	divsd	.LCPI5_4(%rip), %xmm0
	movl	$_ZSt4cout, %edi
	callq	_ZNSo9_M_insertIdEERSoT_
	movl	$.L.str.7, %esi
	movl	$6, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	xorl	%eax, %eax
	addq	$40, %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
.LBB5_7:
	.cfi_def_cfa_offset 96
	movl	%eax, %ebp
	movl	$_ZSt4cout, %edi
	movl	$.L.str.8, %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.9, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rdi
	movl	$110, %esi
	jmp	.LBB5_8
.LBB5_10:
	movl	%eax, %ebp
	movl	$_ZSt4cout, %edi
	movl	$.L.str.8, %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.9, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rdi
	movl	$111, %esi
	jmp	.LBB5_8
.LBB5_12:
	movl	%eax, %ebp
	movl	$_ZSt4cout, %edi
	movl	$.L.str.8, %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.9, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rdi
	movl	$113, %esi
	jmp	.LBB5_8
.LBB5_16:
	movl	%eax, %ebp
	movl	$_ZSt4cout, %edi
	movl	$.L.str.8, %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.9, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rdi
	movl	$119, %esi
	jmp	.LBB5_8
.LBB5_18:
	movl	%eax, %ebp
	movl	$_ZSt4cout, %edi
	movl	$.L.str.8, %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.9, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rdi
	movl	$122, %esi
.LBB5_8:
	callq	_ZNSolsEi
	movl	$.L.str.10, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movl	$.L.str.11, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movl	$.L.str.12, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movl	$1, %edi
	callq	exit
.Lfunc_end5:
	.size	main, .Lfunc_end5-main
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	jne	.LBB6_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB6_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z15fastComputeCUDAPiiiS_, %esi
	movl	$.L__unnamed_1, %edx
	movl	$.L__unnamed_1, %ecx
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$__hip_module_dtor, %edi
	addq	$40, %rsp
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_end6:
	.size	__hip_module_ctor, .Lfunc_end6-__hip_module_ctor
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_dtor
	.type	__hip_module_dtor,@function
__hip_module_dtor:                      # @__hip_module_dtor
	.cfi_startproc
# %bb.0:
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	je	.LBB7_2
# %bb.1:
	pushq	%rax
	.cfi_def_cfa_offset 16
	callq	__hipUnregisterFatBinary
	movq	$0, __hip_gpubin_handle(%rip)
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
.LBB7_2:
	retq
.Lfunc_end7:
	.size	__hip_module_dtor, .Lfunc_end7-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	" "
	.size	.L.str, 2

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"Wrong in str: "
	.size	.L.str.1, 15

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

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

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

	.type	.L.str.4,@object                # @.str.4
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.4:
	.asciz	"CPU time = "
	.size	.L.str.4, 12

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

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"CPU memory throughput = "
	.size	.L.str.6, 25

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	" Gb/s\n"
	.size	.L.str.7, 7

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

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

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

	.type	.L.str.11,@object               # @.str.11
.L.str.11:
	.asciz	"/home/ubuntu/Datasets/stackv2/train-structured-repos-hip-sm89/Ukolnir/MMCS_CS322_CUDA/master/Lab4.hip"
	.size	.L.str.11, 102

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

	.type	.L.str.13,@object               # @.str.13
.L.str.13:
	.asciz	"Result is correct"
	.size	.L.str.13, 18

	.type	.L.str.14,@object               # @.str.14
.L.str.14:
	.asciz	"Result isn't correct"
	.size	.L.str.14, 21

	.type	.L.str.15,@object               # @.str.15
.L.str.15:
	.asciz	"CUDA time = "
	.size	.L.str.15, 13

	.type	.L.str.16,@object               # @.str.16
.L.str.16:
	.asciz	"CUDA memory throughput = "
	.size	.L.str.16, 26

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z15fastComputeCUDAPiiiS_"
	.size	.L__unnamed_1, 26

	.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 _Z30__device_stub__fastComputeCUDAPiiiS_
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _ZSt4cout
	.addrsig_sym _Z15fastComputeCUDAPiiiS_
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z15fastComputeCUDAPiiiS_ ; -- Begin function _Z15fastComputeCUDAPiiiS_
	.globl	_Z15fastComputeCUDAPiiiS_
	.p2align	8
	.type	_Z15fastComputeCUDAPiiiS_,@function
_Z15fastComputeCUDAPiiiS_:              ; @_Z15fastComputeCUDAPiiiS_
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x24
	s_load_b64 s[4:5], s[0:1], 0x8
	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_e64 s4, v1
	s_cbranch_execz .LBB0_10
; %bb.1:
	v_mov_b32_e32 v5, 0
	s_cmp_lt_i32 s5, 32
	s_cbranch_scc1 .LBB0_9
; %bb.2:                                ; %.preheader.lr.ph
	s_load_b64 s[2:3], s[0:1], 0x0
	v_mul_lo_u32 v2, v1, s5
	v_and_b32_e32 v4, 31, v0
	s_ashr_i32 s4, s5, 31
	s_mov_b32 s6, 0
	s_lshr_b32 s4, s4, 27
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	s_add_i32 s4, s5, s4
	v_ashrrev_i32_e32 v3, 31, v2
	s_ashr_i32 s4, s4, 5
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[2:3], 2, v[2:3]
	s_waitcnt lgkmcnt(0)
	v_add_co_u32 v2, vcc_lo, s2, v2
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_4) | instid1(VALU_DEP_3)
	v_add_co_ci_u32_e32 v3, vcc_lo, s3, v3, vcc_lo
	global_load_b32 v7, v[2:3], off
	v_lshrrev_b32_e32 v2, 5, v0
	v_lshlrev_b32_e32 v3, 2, v4
	v_mul_u32_u24_e32 v0, 0x84, v0
	v_lshl_or_b32 v5, s15, 8, v2
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_mad_u32_u24 v6, 0x84, v2, v3
	v_mad_u64_u32 v[2:3], null, s5, v5, v[4:5]
	v_dual_mov_b32 v4, 0 :: v_dual_mov_b32 v5, 0
	s_lshl_b32 s5, s5, 3
.LBB0_3:                                ; %.preheader
                                        ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB0_4 Depth 2
                                        ;     Child Loop BB0_6 Depth 2
	s_delay_alu instid0(VALU_DEP_2)
	v_mov_b32_e32 v3, v2
	s_mov_b32 s7, 0
.LBB0_4:                                ;   Parent Loop BB0_3 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_lshlrev_b64 v[8:9], 2, v[3:4]
	v_add_nc_u32_e32 v3, s5, v3
	v_add_co_u32 v8, vcc_lo, s2, v8
	s_delay_alu instid0(VALU_DEP_3) | instskip(SKIP_3) | instid1(SALU_CYCLE_1)
	v_add_co_ci_u32_e32 v9, vcc_lo, s3, v9, vcc_lo
	global_load_b32 v8, v[8:9], off
	v_add_nc_u32_e32 v9, s7, v6
	s_addk_i32 s7, 0x420
	s_cmpk_eq_u32 s7, 0x8400
	s_waitcnt vmcnt(0)
	ds_store_b32 v9, v8
	s_cbranch_scc0 .LBB0_4
; %bb.5:                                ;   in Loop: Header=BB0_3 Depth=1
	s_mov_b32 s7, 0
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
.LBB0_6:                                ;   Parent Loop BB0_3 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	v_add_nc_u32_e32 v3, s7, v0
	s_add_i32 s7, s7, 4
	s_delay_alu instid0(SALU_CYCLE_1)
	s_cmpk_eq_i32 s7, 0x80
	ds_load_b32 v3, v3
	s_waitcnt lgkmcnt(0)
	v_cmp_gt_i32_e32 vcc_lo, v7, v3
	v_mov_b32_e32 v7, v3
	v_add_co_ci_u32_e32 v5, vcc_lo, 0, v5, vcc_lo
	s_cbranch_scc0 .LBB0_6
; %bb.7:                                ;   in Loop: Header=BB0_3 Depth=1
	v_add_nc_u32_e32 v2, 32, v2
	s_add_i32 s6, s6, 1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_cmp_eq_u32 s6, s4
	s_cbranch_scc1 .LBB0_9
; %bb.8:                                ;   in Loop: Header=BB0_3 Depth=1
	v_mov_b32_e32 v7, v3
	s_branch .LBB0_3
.LBB0_9:                                ; %._crit_edge
	s_load_b64 s[0:1], s[0:1], 0x10
	v_ashrrev_i32_e32 v2, 31, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[0:1], 2, v[1:2]
	s_waitcnt lgkmcnt(0)
	v_add_co_u32 v0, vcc_lo, s0, v0
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v1, vcc_lo, s1, v1, vcc_lo
	global_store_b32 v[0:1], v5, off
.LBB0_10:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z15fastComputeCUDAPiiiS_
		.amdhsa_group_segment_fixed_size 33792
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 280
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 10
		.amdhsa_next_free_sgpr 16
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end0:
	.size	_Z15fastComputeCUDAPiiiS_, .Lfunc_end0-_Z15fastComputeCUDAPiiiS_
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 456
; NumSgprs: 18
; NumVgprs: 10
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 33792 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
      - .offset:         8
        .size:           4
        .value_kind:     by_value
      - .offset:         12
        .size:           4
        .value_kind:     by_value
      - .address_space:  global
        .offset:         16
        .size:           8
        .value_kind:     global_buffer
      - .offset:         24
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         28
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         32
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         36
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         38
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         40
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         42
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         44
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         46
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         64
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         88
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 33792
    .kernarg_segment_align: 8
    .kernarg_segment_size: 280
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z15fastComputeCUDAPiiiS_
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z15fastComputeCUDAPiiiS_.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
