#include <iostream>
#include <fstream>
#include <cmath>
#include <cuda.h>
const int n = 1025;	
const double h = 1.0 / (double)(n);
const double K2 = 100.0;
const double cft1 = 1.0 / (4.0 + h * h * K2);
const double cft3 = cft1 * h * h;
const double PI = 3.1415926535897932385;
const int MaxIter = 30000;

using namespace std;

__host__  double fRight(double x, double y) 
{
    return 2.0 * sin(PI * y) + K2 * (1.0 - x) * x * sin(PI * y) + PI * PI * (1.0 - x) * x * sin(PI * y);
}

__global__ void kernelJacobi(double* ym, double* um, double* fm)
{
	/*int alpha, beta; // положение блока
	int i, j;		// положение треда в блоке
	alpha = blockIdx.x;
	beta  = blockIdx.y;
	i = threadIdx.x;
	j = threadIdx.y;	
	
	int bnx, bny; // размеры блоков
	bnx = blockDim.x;
	bny = blockDim.y;
	
	int row,col;// положение элемента в матрице
	col = alpha * bnx + i;
	row = beta * bny + j;
	
	int id  = row * (n + 1) + col;
	
	//int k;
	//um[id] = 0.0;
	
	//if ((id <= n * (n + 1) - 1)&&(id >= n + 1)&&((id % (n + 1)) != 0)&&((id % (n + 1)) != n))
	um[id] = (cft1 * (ym[id - n - 1] + ym[id + n + 1] + ym[id - 1] + ym[id + 1]) + fm[id]) * cft3;*/
    int i = blockDim.y * blockIdx.y + threadIdx.y;
	int j = blockDim.x * blockIdx.x + threadIdx.x;
	um[(i + 1) * (n + 1) + (j + 1)] = 0.0;
	um[(i + 1) * (n + 1) + (j + 1)] = cft1 * (ym[(i + 2) * (n + 1) + (j + 1)] + ym[(i + 1) * (n + 1) + j + 2] + ym[i * (n + 1) + (j + 1)] + ym[(i + 1) * (n + 1) + j]) + cft3 * fm[(i + 1) * (n + 1) + (j + 1)];
	
	return;
}

__global__ void kernelSwap(double* ym, double* um)
{
	int alpha, beta; // положение блока
	int i, j;		// положение треда в блоке
	alpha = blockIdx.x;
	beta  = blockIdx.y;
	i = threadIdx.x;
	j = threadIdx.y;	
	
	int bnx, bny; // размеры блоков
	bnx = blockDim.x;
	bny = blockDim.y;
	
	int row,col;// положение элемента в матрице
	col = alpha * bnx + i;
	row = beta * bny + j;
	
	int id  = row * (n + 1) + col;
	
	ym[id] = um[id];
	
	return;
}

double exsol(double x, double y) 
{
    return x * (1.0 - x) * sin(PI * y);
}


int main(int argc, char* argv[])
{
	/*int n = 128;
	
	double h = 1.0 / n;
	
	const double cft1 = 1 / (h * h);
    const double cft2 = 4.0 * cft1 + K2;
    const double cft3 = 1 / cft2;
	const double PI = 3.141592653589793238462643;
	const double PI2 = PI*PI;
	const double K2 = 100.0;
	const int MaxIter = 10000;*/
	
	cout << "cft1 = " << cft1 << endl;
	//cout << "cft2 = " << cft2 << endl;
	cout << "cft3 = " << cft3 << endl;
	
	double * y;
	double * u;
	double * f;

	y = new double [(n + 1) * (n + 1)];
	u = new double [(n + 1) * (n + 1)];
	f = new double [(n + 1) * (n + 1)];

	int nbytes = (n + 1) * (n + 1) * sizeof(double);
	
	int i, j;

	//инициализация
	for (i = 1; i < n; i++)
    {
		y[i * (n + 1)] = 0.0;
		y[i * (n + 1) + n] = 0.0;
		for (j = 1; j < n; j++)
			y[i * (n + 1) + j] = 0.0; //0.5
    }
    for (i = 0; i <= n; i++)
    {
        y[i] = 0.0;
        y[n * (n + 1) + i] = 0.0;
		for (j = 0; j <= n; j++)
			u[i * (n + 1) + j] = 0.0;
    }
	
	for (i = 0; i <= n; i++)
	for (j = 0; j <= n; j++) 
		f[i * (n + 1) + j] = fRight(i * h, j * h);
	//
	
	cudaError_t SD;
	
	SD = cudaSetDevice(0);
	if (SD != cudaSuccess)
	{
		cout << "CUDA set device error" << endl;
		return 1;
	}
	
	double * uDev = NULL;
	double * yDev = NULL;
	double * fDev = NULL;
	
	cudaMalloc ((void **)&uDev, nbytes);
	cudaMalloc ((void **)&yDev, nbytes);
	cudaMalloc ((void **)&fDev, nbytes);
	
	cudaEvent_t start, stop;
	cudaEventCreate(&start);
	cudaEventCreate(&stop);
		
	cudaEventRecord(start,0);	
	cudaEventSynchronize(start);
	
	const int blockDimx = 1; //n; //32; //8; //16; //64; //128;
	const int blockDimy = 1024;
	dim3 threads(blockDimx, blockDimy, 1);
	dim3 blocks((n - 1) / blockDimx, (n - 1)  / blockDimy, 1);
	cout << blocks.x << "\n";
	
	cudaMemcpy(fDev, f, nbytes, cudaMemcpyHostToDevice);
	cudaMemcpy(uDev, u, nbytes, cudaMemcpyHostToDevice);
	cudaMemcpy(yDev, y, nbytes, cudaMemcpyHostToDevice);
	
	//int iter = 1;
	for (int k = 0; k < MaxIter/2; k++)
	{
		kernelJacobi<<<blocks, threads>>>(yDev, uDev, fDev);
		kernelJacobi<<<blocks, threads>>>(uDev, yDev, fDev);
	}
	/*do
	{
		kernelJacobi<<<blocks, threads>>>(yDev, uDev, fDev);
		kernelJacobi<<<blocks, threads>>>(uDev, yDev, fDev);
		//cudaThreadSynchronize();
		
		//kernelSwap<<<blocks, threads>>>(yDev, uDev);
		//cudaThreadSynchronize();
		
		iter++;
	} while (iter <= MaxIter);*/
	//cudaThreadSynchronize();
	
	//test
	/*kernelJacobi<<<blocks, threads>>>(yDev, uDev, fDev);
	cudaMemcpy(u, uDev, nbytes, cudaMemcpyDeviceToHost);*/
	//
	
	cudaMemcpy(y, yDev, nbytes, cudaMemcpyDeviceToHost);
	
	cudaEventRecord(stop,0);	
	cudaEventSynchronize(stop);
	
	float dt;
	cudaEventElapsedTime(&dt,start,stop);
	
	//абсолютная погрешность
	double max = 0.0;
    for (int i = 0; i <= n; i++) 
	{
         //double x = i*h;
        for (int j = 0; j <= n; j++) 
		{
             //double y = j*h;
            double val = fabs(y[i * (n + 1) + j] - exsol(i * h, j * h));
            if (max < val) 
			{
                max = val;
            }
        }
    }
	cout << "Mistake: " << max << endl;
	//
	
	//запись в файл
	/*ofstream outFile;
	outFile.open("res.dat");
	for (int i = 0; i <= n; i++)
	for (int j = 0; j <= n; j++)
		outFile << i * h << " " << j * h << " " << y[i * (n + 1) + j] << endl;
	outFile.close();*/
	//
	
	cout << "Time = " << dt << " ms"<< endl;
	
	delete[] u;
	delete[] y;
	delete[] f;
	
	cudaEventDestroy(start);
	cudaEventDestroy(stop);
	cudaFree(uDev);
	cudaFree(yDev);
	cudaFree(fDev);
	
	return 0;
}


	.file	"tmpxft_00353b58_00000000-6_lab5.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB3771:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE3771:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.align 2
	.type	_ZNSolsEPFRSoS_E.isra.0, @function
_ZNSolsEPFRSoS_E.isra.0:
.LFB4448:
	.cfi_startproc
	jmp	*%rsi
	.cfi_endproc
.LFE4448:
	.size	_ZNSolsEPFRSoS_E.isra.0, .-_ZNSolsEPFRSoS_E.isra.0
	.globl	_Z6fRightdd
	.type	_Z6fRightdd, @function
_Z6fRightdd:
.LFB3766:
	.cfi_startproc
	endbr64
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	mulsd	.LC0(%rip), %xmm1
	movsd	%xmm0, 8(%rsp)
	movaps	%xmm1, %xmm0
	call	sin@PLT
	movsd	8(%rsp), %xmm3
	movsd	.LC1(%rip), %xmm1
	movaps	%xmm0, %xmm2
	movsd	.LC2(%rip), %xmm0
	subsd	%xmm3, %xmm1
	movaps	%xmm2, %xmm4
	addsd	%xmm2, %xmm4
	mulsd	%xmm1, %xmm0
	mulsd	.LC3(%rip), %xmm1
	addq	$24, %rsp
	.cfi_def_cfa_offset 8
	mulsd	%xmm3, %xmm0
	mulsd	%xmm3, %xmm1
	mulsd	%xmm2, %xmm0
	mulsd	%xmm2, %xmm1
	addsd	%xmm4, %xmm0
	addsd	%xmm1, %xmm0
	ret
	.cfi_endproc
.LFE3766:
	.size	_Z6fRightdd, .-_Z6fRightdd
	.globl	_Z5exsoldd
	.type	_Z5exsoldd, @function
_Z5exsoldd:
.LFB3767:
	.cfi_startproc
	endbr64
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	mulsd	.LC0(%rip), %xmm1
	movsd	%xmm0, 8(%rsp)
	movaps	%xmm1, %xmm0
	call	sin@PLT
	movsd	8(%rsp), %xmm2
	movaps	%xmm0, %xmm1
	movsd	.LC1(%rip), %xmm0
	addq	$24, %rsp
	.cfi_def_cfa_offset 8
	subsd	%xmm2, %xmm0
	mulsd	%xmm2, %xmm0
	mulsd	%xmm1, %xmm0
	ret
	.cfi_endproc
.LFE3767:
	.size	_Z5exsoldd, .-_Z5exsoldd
	.globl	_Z36__device_stub__Z12kernelJacobiPdS_S_PdS_S_
	.type	_Z36__device_stub__Z12kernelJacobiPdS_S_PdS_S_, @function
_Z36__device_stub__Z12kernelJacobiPdS_S_PdS_S_:
.LFB3793:
	.cfi_startproc
	endbr64
	subq	$136, %rsp
	.cfi_def_cfa_offset 144
	movq	%rdi, 24(%rsp)
	leaq	40(%rsp), %rcx
	leaq	48(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	60(%rsp), %rsi
	movq	%rdx, 8(%rsp)
	leaq	32(%rsp), %rdx
	movq	%fs:40, %rax
	movq	%rax, 120(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 56(%rsp)
	movq	%rax, 96(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 104(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 112(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 48(%rsp)
	movq	%rax, 60(%rsp)
	movl	$1, 68(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L7
	pushq	40(%rsp)
	.cfi_def_cfa_offset 152
	leaq	_Z12kernelJacobiPdS_S_(%rip), %rdi
	pushq	40(%rsp)
	.cfi_def_cfa_offset 160
	movq	76(%rsp), %rcx
	movl	84(%rsp), %r8d
	movq	64(%rsp), %rsi
	movl	72(%rsp), %edx
	leaq	112(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 152
	popq	%rdx
	.cfi_def_cfa_offset 144
.L7:
	movq	120(%rsp), %rax
	subq	%fs:40, %rax
	je	.L9
	call	__stack_chk_fail@PLT
.L9:
	addq	$136, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3793:
	.size	_Z36__device_stub__Z12kernelJacobiPdS_S_PdS_S_, .-_Z36__device_stub__Z12kernelJacobiPdS_S_PdS_S_
	.globl	_Z12kernelJacobiPdS_S_
	.type	_Z12kernelJacobiPdS_S_, @function
_Z12kernelJacobiPdS_S_:
.LFB3794:
	.cfi_startproc
	endbr64
	jmp	_Z36__device_stub__Z12kernelJacobiPdS_S_PdS_S_
	.cfi_endproc
.LFE3794:
	.size	_Z12kernelJacobiPdS_S_, .-_Z12kernelJacobiPdS_S_
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC5:
	.string	"cft1 = "
.LC7:
	.string	"cft3 = "
.LC10:
	.string	"CUDA set device error"
.LC11:
	.string	"\n"
.LC13:
	.string	"Mistake: "
.LC14:
	.string	"Time = "
.LC15:
	.string	" ms"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB3768:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	.LC5(%rip), %rsi
	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
	leaq	_ZSt4cout(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%r12, %rdi
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$120, %rsp
	.cfi_def_cfa_offset 176
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movsd	.LC6(%rip), %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	.LC7(%rip), %rsi
	movq	%r12, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movsd	.LC8(%rip), %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
	movl	$8421408, %edi
	call	_Znam@PLT
	movl	$8421408, %edi
	movq	%rax, %rbx
	call	_Znam@PLT
	movl	$8421408, %edi
	movq	%rax, 8(%rsp)
	call	_Znam@PLT
	leaq	8216(%rbx), %rdx
	leaq	8413208(%rbx), %rsi
	movq	%rax, %r13
	xorl	%eax, %eax
.L14:
	movq	$0x000000000, -8(%rdx)
	movq	%rdx, %rdi
	movl	$2048, %ecx
	addq	$8208, %rdx
	movq	$0x000000000, -16(%rdx)
	rep stosl
	cmpq	%rsi, %rdx
	jne	.L14
	movl	$2052, %ecx
	movq	%rbx, %rdi
	leaq	8413200(%rbx), %rdx
	xorl	%r15d, %r15d
	rep stosl
	movl	$2052, %ecx
	movq	%rdx, %rdi
	rep stosl
	movq	8(%rsp), %rdi
	movl	$2105352, %ecx
	rep stosl
.L15:
	cvtsi2sdl	%r15d, %xmm0
	mulsd	.LC9(%rip), %xmm0
	xorl	%ebp, %ebp
	imulq	$8208, %r15, %r14
	addq	%r13, %r14
	movsd	%xmm0, (%rsp)
.L16:
	cvtsi2sdl	%ebp, %xmm1
	mulsd	.LC9(%rip), %xmm1
	movsd	(%rsp), %xmm0
	call	_Z6fRightdd
	movsd	%xmm0, (%r14,%rbp,8)
	incq	%rbp
	cmpq	$1026, %rbp
	jne	.L16
	incq	%r15
	cmpq	$1026, %r15
	jne	.L15
	xorl	%edi, %edi
	call	cudaSetDevice@PLT
	testl	%eax, %eax
	je	.L18
	leaq	.LC10(%rip), %rsi
	movq	%r12, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	movl	$1, %eax
	jmp	.L13
.L18:
	xorl	%eax, %eax
	leaq	40(%rsp), %rdi
	movl	$8421408, %esi
	movl	$15000, %r14d
	movq	%rax, 40(%rsp)
	movq	%rax, 48(%rsp)
	movq	%rax, 56(%rsp)
	call	cudaMalloc@PLT
	leaq	48(%rsp), %rdi
	movl	$8421408, %esi
	call	cudaMalloc@PLT
	movl	$8421408, %esi
	leaq	56(%rsp), %rdi
	call	cudaMalloc@PLT
	leaq	64(%rsp), %rdi
	call	cudaEventCreate@PLT
	leaq	72(%rsp), %rdi
	call	cudaEventCreate@PLT
	movq	64(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	64(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movl	$1024, %esi
	movq	%r12, %rdi
	movabsq	$4398046511105, %rax
	movq	%rax, 80(%rsp)
	movabsq	$4294967297, %rax
	movl	$1, 88(%rsp)
	movq	%rax, 96(%rsp)
	call	_ZNSo9_M_insertImEERSoT_@PLT
	leaq	.LC11(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	56(%rsp), %rdi
	movl	$1, %ecx
	movq	%r13, %rsi
	movl	$8421408, %edx
	call	cudaMemcpy@PLT
	movq	8(%rsp), %rsi
	movq	40(%rsp), %rdi
	movl	$1, %ecx
	movl	$8421408, %edx
	call	cudaMemcpy@PLT
	movq	48(%rsp), %rdi
	movl	$1, %ecx
	movq	%rbx, %rsi
	movl	$8421408, %edx
	call	cudaMemcpy@PLT
.L22:
	movl	88(%rsp), %ecx
	movq	80(%rsp), %rdx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	$1024, 92(%rsp)
	movl	100(%rsp), %esi
	movq	92(%rsp), %rdi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L20
	movq	56(%rsp), %rdx
	movq	40(%rsp), %rsi
	movq	48(%rsp), %rdi
	call	_Z36__device_stub__Z12kernelJacobiPdS_S_PdS_S_
.L20:
	movl	88(%rsp), %ecx
	movq	80(%rsp), %rdx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movq	92(%rsp), %rdi
	movl	100(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L21
	movq	56(%rsp), %rdx
	movq	48(%rsp), %rsi
	movq	40(%rsp), %rdi
	call	_Z36__device_stub__Z12kernelJacobiPdS_S_PdS_S_
.L21:
	decl	%r14d
	jne	.L22
	movq	48(%rsp), %rsi
	movl	$2, %ecx
	movq	%rbx, %rdi
	xorl	%ebp, %ebp
	movl	$8421408, %edx
	call	cudaMemcpy@PLT
	movq	72(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	72(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movq	72(%rsp), %rdx
	movq	64(%rsp), %rsi
	leaq	36(%rsp), %rdi
	call	cudaEventElapsedTime@PLT
	movq	$0x000000000, (%rsp)
.L23:
	cvtsi2sdl	%ebp, %xmm0
	mulsd	.LC9(%rip), %xmm0
	xorl	%r15d, %r15d
	imulq	$8208, %rbp, %r14
	addq	%rbx, %r14
	movsd	%xmm0, 16(%rsp)
.L25:
	cvtsi2sdl	%r15d, %xmm1
	mulsd	.LC9(%rip), %xmm1
	movsd	(%r14,%r15,8), %xmm2
	incq	%r15
	movsd	16(%rsp), %xmm0
	movsd	%xmm2, 24(%rsp)
	call	_Z5exsoldd
	movsd	24(%rsp), %xmm2
	subsd	%xmm0, %xmm2
	andps	.LC12(%rip), %xmm2
	maxsd	(%rsp), %xmm2
	movsd	%xmm2, (%rsp)
	cmpq	$1026, %r15
	jne	.L25
	incq	%rbp
	cmpq	$1026, %rbp
	jne	.L23
	leaq	.LC13(%rip), %rsi
	movq	%r12, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movsd	(%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	.LC14(%rip), %rsi
	movq	%r12, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	cvtss2sd	36(%rsp), %xmm0
	movq	%rax, %rdi
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	leaq	.LC15(%rip), %rsi
	movq	%rax, %rdi
	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	8(%rsp), %rdi
	call	_ZdaPv@PLT
	movq	%rbx, %rdi
	call	_ZdaPv@PLT
	movq	%r13, %rdi
	call	_ZdaPv@PLT
	movq	64(%rsp), %rdi
	call	cudaEventDestroy@PLT
	movq	72(%rsp), %rdi
	call	cudaEventDestroy@PLT
	movq	40(%rsp), %rdi
	call	cudaFree@PLT
	movq	48(%rsp), %rdi
	call	cudaFree@PLT
	movq	56(%rsp), %rdi
	call	cudaFree@PLT
	xorl	%eax, %eax
.L13:
	movq	104(%rsp), %rdx
	subq	%fs:40, %rdx
	je	.L27
	call	__stack_chk_fail@PLT
.L27:
	addq	$120, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3768:
	.size	main, .-main
	.text
	.globl	_Z32__device_stub__Z10kernelSwapPdS_PdS_
	.type	_Z32__device_stub__Z10kernelSwapPdS_PdS_, @function
_Z32__device_stub__Z10kernelSwapPdS_PdS_:
.LFB3795:
	.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	.L34
	pushq	32(%rsp)
	.cfi_def_cfa_offset 136
	leaq	_Z10kernelSwapPdS_(%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
.L34:
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	je	.L36
	call	__stack_chk_fail@PLT
.L36:
	addq	$120, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3795:
	.size	_Z32__device_stub__Z10kernelSwapPdS_PdS_, .-_Z32__device_stub__Z10kernelSwapPdS_PdS_
	.globl	_Z10kernelSwapPdS_
	.type	_Z10kernelSwapPdS_, @function
_Z10kernelSwapPdS_:
.LFB3796:
	.cfi_startproc
	endbr64
	jmp	_Z32__device_stub__Z10kernelSwapPdS_PdS_
	.cfi_endproc
.LFE3796:
	.size	_Z10kernelSwapPdS_, .-_Z10kernelSwapPdS_
	.section	.rodata.str1.1
.LC16:
	.string	"_Z10kernelSwapPdS_"
.LC17:
	.string	"_Z12kernelJacobiPdS_S_"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB3798:
	.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	.LC16(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z10kernelSwapPdS_(%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	.LC17(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z12kernelJacobiPdS_S_(%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
.LFE3798:
	.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
.LC0:
	.long	1413754136
	.long	1074340347
	.align 8
.LC1:
	.long	0
	.long	1072693248
	.align 8
.LC2:
	.long	0
	.long	1079574528
	.align 8
.LC3:
	.long	-910277154
	.long	1076084028
	.align 8
.LC6:
	.long	423916727
	.long	1070596046
	.align 8
.LC8:
	.long	808393255
	.long	1049620436
	.align 8
.LC9:
	.long	-8380424
	.long	1062205441
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC12:
	.long	-1
	.long	2147483647
	.long	0
	.long	0
	.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 <iostream>
#include <fstream>
#include <cmath>
#include <hip/hip_runtime.h>
const int n = 1025;	
const double h = 1.0 / (double)(n);
const double K2 = 100.0;
const double cft1 = 1.0 / (4.0 + h * h * K2);
const double cft3 = cft1 * h * h;
const double PI = 3.1415926535897932385;
const int MaxIter = 30000;

using namespace std;

__host__  double fRight(double x, double y) 
{
    return 2.0 * sin(PI * y) + K2 * (1.0 - x) * x * sin(PI * y) + PI * PI * (1.0 - x) * x * sin(PI * y);
}

__global__ void kernelJacobi(double* ym, double* um, double* fm)
{
	/*int alpha, beta; // положение блока
	int i, j;		// положение треда в блоке
	alpha = blockIdx.x;
	beta  = blockIdx.y;
	i = threadIdx.x;
	j = threadIdx.y;	
	
	int bnx, bny; // размеры блоков
	bnx = blockDim.x;
	bny = blockDim.y;
	
	int row,col;// положение элемента в матрице
	col = alpha * bnx + i;
	row = beta * bny + j;
	
	int id  = row * (n + 1) + col;
	
	//int k;
	//um[id] = 0.0;
	
	//if ((id <= n * (n + 1) - 1)&&(id >= n + 1)&&((id % (n + 1)) != 0)&&((id % (n + 1)) != n))
	um[id] = (cft1 * (ym[id - n - 1] + ym[id + n + 1] + ym[id - 1] + ym[id + 1]) + fm[id]) * cft3;*/
    int i = blockDim.y * blockIdx.y + threadIdx.y;
	int j = blockDim.x * blockIdx.x + threadIdx.x;
	um[(i + 1) * (n + 1) + (j + 1)] = 0.0;
	um[(i + 1) * (n + 1) + (j + 1)] = cft1 * (ym[(i + 2) * (n + 1) + (j + 1)] + ym[(i + 1) * (n + 1) + j + 2] + ym[i * (n + 1) + (j + 1)] + ym[(i + 1) * (n + 1) + j]) + cft3 * fm[(i + 1) * (n + 1) + (j + 1)];
	
	return;
}

__global__ void kernelSwap(double* ym, double* um)
{
	int alpha, beta; // положение блока
	int i, j;		// положение треда в блоке
	alpha = blockIdx.x;
	beta  = blockIdx.y;
	i = threadIdx.x;
	j = threadIdx.y;	
	
	int bnx, bny; // размеры блоков
	bnx = blockDim.x;
	bny = blockDim.y;
	
	int row,col;// положение элемента в матрице
	col = alpha * bnx + i;
	row = beta * bny + j;
	
	int id  = row * (n + 1) + col;
	
	ym[id] = um[id];
	
	return;
}

double exsol(double x, double y) 
{
    return x * (1.0 - x) * sin(PI * y);
}


int main(int argc, char* argv[])
{
	/*int n = 128;
	
	double h = 1.0 / n;
	
	const double cft1 = 1 / (h * h);
    const double cft2 = 4.0 * cft1 + K2;
    const double cft3 = 1 / cft2;
	const double PI = 3.141592653589793238462643;
	const double PI2 = PI*PI;
	const double K2 = 100.0;
	const int MaxIter = 10000;*/
	
	cout << "cft1 = " << cft1 << endl;
	//cout << "cft2 = " << cft2 << endl;
	cout << "cft3 = " << cft3 << endl;
	
	double * y;
	double * u;
	double * f;

	y = new double [(n + 1) * (n + 1)];
	u = new double [(n + 1) * (n + 1)];
	f = new double [(n + 1) * (n + 1)];

	int nbytes = (n + 1) * (n + 1) * sizeof(double);
	
	int i, j;

	//инициализация
	for (i = 1; i < n; i++)
    {
		y[i * (n + 1)] = 0.0;
		y[i * (n + 1) + n] = 0.0;
		for (j = 1; j < n; j++)
			y[i * (n + 1) + j] = 0.0; //0.5
    }
    for (i = 0; i <= n; i++)
    {
        y[i] = 0.0;
        y[n * (n + 1) + i] = 0.0;
		for (j = 0; j <= n; j++)
			u[i * (n + 1) + j] = 0.0;
    }
	
	for (i = 0; i <= n; i++)
	for (j = 0; j <= n; j++) 
		f[i * (n + 1) + j] = fRight(i * h, j * h);
	//
	
	hipError_t SD;
	
	SD = hipSetDevice(0);
	if (SD != hipSuccess)
	{
		cout << "CUDA set device error" << endl;
		return 1;
	}
	
	double * uDev = NULL;
	double * yDev = NULL;
	double * fDev = NULL;
	
	hipMalloc ((void **)&uDev, nbytes);
	hipMalloc ((void **)&yDev, nbytes);
	hipMalloc ((void **)&fDev, nbytes);
	
	hipEvent_t start, stop;
	hipEventCreate(&start);
	hipEventCreate(&stop);
		
	hipEventRecord(start,0);	
	hipEventSynchronize(start);
	
	const int blockDimx = 1; //n; //32; //8; //16; //64; //128;
	const int blockDimy = 1024;
	dim3 threads(blockDimx, blockDimy, 1);
	dim3 blocks((n - 1) / blockDimx, (n - 1)  / blockDimy, 1);
	cout << blocks.x << "\n";
	
	hipMemcpy(fDev, f, nbytes, hipMemcpyHostToDevice);
	hipMemcpy(uDev, u, nbytes, hipMemcpyHostToDevice);
	hipMemcpy(yDev, y, nbytes, hipMemcpyHostToDevice);
	
	//int iter = 1;
	for (int k = 0; k < MaxIter/2; k++)
	{
		kernelJacobi<<<blocks, threads>>>(yDev, uDev, fDev);
		kernelJacobi<<<blocks, threads>>>(uDev, yDev, fDev);
	}
	/*do
	{
		kernelJacobi<<<blocks, threads>>>(yDev, uDev, fDev);
		kernelJacobi<<<blocks, threads>>>(uDev, yDev, fDev);
		//cudaThreadSynchronize();
		
		//kernelSwap<<<blocks, threads>>>(yDev, uDev);
		//cudaThreadSynchronize();
		
		iter++;
	} while (iter <= MaxIter);*/
	//cudaThreadSynchronize();
	
	//test
	/*kernelJacobi<<<blocks, threads>>>(yDev, uDev, fDev);
	cudaMemcpy(u, uDev, nbytes, cudaMemcpyDeviceToHost);*/
	//
	
	hipMemcpy(y, yDev, nbytes, hipMemcpyDeviceToHost);
	
	hipEventRecord(stop,0);	
	hipEventSynchronize(stop);
	
	float dt;
	hipEventElapsedTime(&dt,start,stop);
	
	//абсолютная погрешность
	double max = 0.0;
    for (int i = 0; i <= n; i++) 
	{
         //double x = i*h;
        for (int j = 0; j <= n; j++) 
		{
             //double y = j*h;
            double val = fabs(y[i * (n + 1) + j] - exsol(i * h, j * h));
            if (max < val) 
			{
                max = val;
            }
        }
    }
	cout << "Mistake: " << max << endl;
	//
	
	//запись в файл
	/*ofstream outFile;
	outFile.open("res.dat");
	for (int i = 0; i <= n; i++)
	for (int j = 0; j <= n; j++)
		outFile << i * h << " " << j * h << " " << y[i * (n + 1) + j] << endl;
	outFile.close();*/
	//
	
	cout << "Time = " << dt << " ms"<< endl;
	
	delete[] u;
	delete[] y;
	delete[] f;
	
	hipEventDestroy(start);
	hipEventDestroy(stop);
	hipFree(uDev);
	hipFree(yDev);
	hipFree(fDev);
	
	return 0;
}


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

                                        # End of file scope inline assembly
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z6fRightdd
.LCPI0_0:
	.quad	0x400921fb54442d18              # double 3.1415926535897931
.LCPI0_1:
	.quad	0x3ff0000000000000              # double 1
.LCPI0_2:
	.quad	0x4059000000000000              # double 100
.LCPI0_3:
	.quad	0x4023bd3cc9be45de              # double 9.869604401089358
	.text
	.globl	_Z6fRightdd
	.type	_Z6fRightdd,@function
_Z6fRightdd:                            # @_Z6fRightdd
	.cfi_startproc
# %bb.0:
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	movsd	%xmm0, 16(%rsp)                 # 8-byte Spill
	mulsd	.LCPI0_0(%rip), %xmm1
	movsd	%xmm1, 24(%rsp)                 # 8-byte Spill
	movapd	%xmm1, %xmm0
	callq	sin
	addsd	%xmm0, %xmm0
	movsd	%xmm0, (%rsp)                   # 8-byte Spill
	movsd	.LCPI0_1(%rip), %xmm1           # xmm1 = mem[0],zero
	movsd	16(%rsp), %xmm0                 # 8-byte Reload
                                        # xmm0 = mem[0],zero
	subsd	%xmm0, %xmm1
	movsd	%xmm1, 8(%rsp)                  # 8-byte Spill
	movsd	.LCPI0_2(%rip), %xmm2           # xmm2 = mem[0],zero
	mulsd	%xmm1, %xmm2
	mulsd	%xmm0, %xmm2
	movsd	%xmm2, 32(%rsp)                 # 8-byte Spill
	movsd	24(%rsp), %xmm0                 # 8-byte Reload
                                        # xmm0 = mem[0],zero
	callq	sin
	mulsd	32(%rsp), %xmm0                 # 8-byte Folded Reload
	addsd	(%rsp), %xmm0                   # 8-byte Folded Reload
	movsd	%xmm0, (%rsp)                   # 8-byte Spill
	movsd	8(%rsp), %xmm0                  # 8-byte Reload
                                        # xmm0 = mem[0],zero
	mulsd	.LCPI0_3(%rip), %xmm0
	mulsd	16(%rsp), %xmm0                 # 8-byte Folded Reload
	movsd	%xmm0, 8(%rsp)                  # 8-byte Spill
	movsd	24(%rsp), %xmm0                 # 8-byte Reload
                                        # xmm0 = mem[0],zero
	callq	sin
	mulsd	8(%rsp), %xmm0                  # 8-byte Folded Reload
	addsd	(%rsp), %xmm0                   # 8-byte Folded Reload
	addq	$40, %rsp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	_Z6fRightdd, .Lfunc_end0-_Z6fRightdd
	.cfi_endproc
                                        # -- End function
	.globl	_Z27__device_stub__kernelJacobiPdS_S_ # -- Begin function _Z27__device_stub__kernelJacobiPdS_S_
	.type	_Z27__device_stub__kernelJacobiPdS_S_,@function
_Z27__device_stub__kernelJacobiPdS_S_:  # @_Z27__device_stub__kernelJacobiPdS_S_
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$112, %rsp
	.cfi_def_cfa_offset 160
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	32(%rsp), %rcx
	movq	%rsi, (%rcx)
	leaq	24(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	movq	%rsi, 16(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	16(%rsp), %r12
	leaq	8(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z12kernelJacobiPdS_S_, %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_end1:
	.size	_Z27__device_stub__kernelJacobiPdS_S_, .Lfunc_end1-_Z27__device_stub__kernelJacobiPdS_S_
	.cfi_endproc
                                        # -- End function
	.globl	_Z25__device_stub__kernelSwapPdS_ # -- Begin function _Z25__device_stub__kernelSwapPdS_
	.type	_Z25__device_stub__kernelSwapPdS_,@function
_Z25__device_stub__kernelSwapPdS_:      # @_Z25__device_stub__kernelSwapPdS_
	.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	$_Z10kernelSwapPdS_, %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_end2:
	.size	_Z25__device_stub__kernelSwapPdS_, .Lfunc_end2-_Z25__device_stub__kernelSwapPdS_
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z5exsoldd
.LCPI3_0:
	.quad	0x3ff0000000000000              # double 1
.LCPI3_1:
	.quad	0x400921fb54442d18              # double 3.1415926535897931
	.text
	.globl	_Z5exsoldd
	.type	_Z5exsoldd,@function
_Z5exsoldd:                             # @_Z5exsoldd
	.cfi_startproc
# %bb.0:
	pushq	%rax
	.cfi_def_cfa_offset 16
	movsd	.LCPI3_0(%rip), %xmm2           # xmm2 = mem[0],zero
	subsd	%xmm0, %xmm2
	mulsd	%xmm2, %xmm0
	movsd	%xmm0, (%rsp)                   # 8-byte Spill
	mulsd	.LCPI3_1(%rip), %xmm1
	movapd	%xmm1, %xmm0
	callq	sin
	mulsd	(%rsp), %xmm0                   # 8-byte Folded Reload
	popq	%rax
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end3:
	.size	_Z5exsoldd, .Lfunc_end3-_Z5exsoldd
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI4_0:
	.quad	0x3fcfffce194474b7              # double 0.24999405130157523
.LCPI4_1:
	.quad	0x3e8fefd4302f1a27              # double 2.379479369913863E-7
.LCPI4_2:
	.quad	0x3f4ff801ff801ff8              # double 9.7560975609756097E-4
.LCPI4_3:
	.quad	0x3ff0000000000000              # double 1
.LCPI4_4:
	.quad	0x4059000000000000              # double 100
.LCPI4_5:
	.quad	0x4023bd3cc9be45de              # double 9.869604401089358
.LCPI4_6:
	.quad	0x400921fb54442d18              # double 3.1415926535897931
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0
.LCPI4_7:
	.quad	0x7fffffffffffffff              # double NaN
	.quad	0x7fffffffffffffff              # double NaN
	.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	$104, %rsp
	.cfi_def_cfa_offset 160
	.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	$_ZSt4cout, %edi
	movl	$.L.str, %esi
	movl	$7, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movsd	.LCPI4_0(%rip), %xmm0           # xmm0 = mem[0],zero
	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.1, %esi
	movl	$7, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movsd	.LCPI4_1(%rip), %xmm0           # xmm0 = mem[0],zero
	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	$8421408, %edi                  # imm = 0x808020
	callq	_Znam
	movq	%rax, %rbx
	movl	$8421408, %edi                  # imm = 0x808020
	callq	_Znam
	movq	%rax, %rbp
	movl	$8421408, %edi                  # imm = 0x808020
	callq	_Znam
	movq	%rax, %r13
	movl	$16408, %r14d                   # imm = 0x4018
	xorl	%r15d, %r15d
.LBB4_1:                                # =>This Inner Loop Header: Depth=1
	leaq	(%rbx,%r14), %rdi
	addq	$-8192, %rdi                    # imm = 0xE000
	movq	%r15, -8200(%rbx,%r14)
	movq	%r15, (%rbx,%r14)
	movl	$8192, %edx                     # imm = 0x2000
	xorl	%esi, %esi
	callq	memset@PLT
	addq	$8208, %r14                     # imm = 0x2010
	cmpq	$8421400, %r14                  # imm = 0x808018
	jne	.LBB4_1
# %bb.2:                                # %.preheader96.preheader
	xorl	%r14d, %r14d
	movl	$8421408, %edx                  # imm = 0x808020
	movq	%rbp, %rdi
	xorl	%esi, %esi
	callq	memset@PLT
	xorl	%eax, %eax
.LBB4_3:                                # %.preheader96
                                        # =>This Inner Loop Header: Depth=1
	movq	%r14, (%rbx,%rax,8)
	movq	%r14, 8413200(%rbx,%rax,8)
	incq	%rax
	cmpq	$1026, %rax                     # imm = 0x402
	jne	.LBB4_3
# %bb.4:                                # %.preheader94.preheader
	xorl	%r14d, %r14d
	movsd	.LCPI4_2(%rip), %xmm1           # xmm1 = mem[0],zero
	movsd	.LCPI4_6(%rip), %xmm3           # xmm3 = mem[0],zero
	movq	%r13, %r15
.LBB4_5:                                # %.preheader94
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB4_6 Depth 2
	xorps	%xmm0, %xmm0
	cvtsi2sd	%r14d, %xmm0
	mulsd	%xmm1, %xmm0
	movsd	.LCPI4_3(%rip), %xmm2           # xmm2 = mem[0],zero
	subsd	%xmm0, %xmm2
	movapd	%xmm2, %xmm4
	mulsd	.LCPI4_4(%rip), %xmm4
	mulsd	%xmm0, %xmm4
	movsd	%xmm4, 16(%rsp)                 # 8-byte Spill
	mulsd	.LCPI4_5(%rip), %xmm2
	mulsd	%xmm0, %xmm2
	movsd	%xmm2, 40(%rsp)                 # 8-byte Spill
	xorl	%r12d, %r12d
.LBB4_6:                                #   Parent Loop BB4_5 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	xorps	%xmm0, %xmm0
	cvtsi2sd	%r12d, %xmm0
	mulsd	%xmm1, %xmm0
	mulsd	%xmm3, %xmm0
	movsd	%xmm0, 64(%rsp)                 # 8-byte Spill
	callq	sin
	addsd	%xmm0, %xmm0
	movsd	%xmm0, (%rsp)                   # 8-byte Spill
	movsd	64(%rsp), %xmm0                 # 8-byte Reload
                                        # xmm0 = mem[0],zero
	callq	sin
	mulsd	16(%rsp), %xmm0                 # 8-byte Folded Reload
	addsd	(%rsp), %xmm0                   # 8-byte Folded Reload
	movsd	%xmm0, (%rsp)                   # 8-byte Spill
	movsd	64(%rsp), %xmm0                 # 8-byte Reload
                                        # xmm0 = mem[0],zero
	callq	sin
	movsd	.LCPI4_6(%rip), %xmm3           # xmm3 = mem[0],zero
	movsd	.LCPI4_2(%rip), %xmm1           # xmm1 = mem[0],zero
	mulsd	40(%rsp), %xmm0                 # 8-byte Folded Reload
	addsd	(%rsp), %xmm0                   # 8-byte Folded Reload
	movsd	%xmm0, (%r15,%r12,8)
	incq	%r12
	cmpq	$1026, %r12                     # imm = 0x402
	jne	.LBB4_6
# %bb.7:                                #   in Loop: Header=BB4_5 Depth=1
	incq	%r14
	addq	$8208, %r15                     # imm = 0x2010
	cmpq	$1026, %r14                     # imm = 0x402
	jne	.LBB4_5
# %bb.8:
	xorl	%edi, %edi
	callq	hipSetDevice
	testl	%eax, %eax
	je	.LBB4_10
# %bb.9:
	movl	$_ZSt4cout, %ebx
	movl	$_ZSt4cout, %edi
	movl	$.L.str.2, %esi
	movl	$21, %edx
	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	$1, %eax
	jmp	.LBB4_21
.LBB4_10:
	movabsq	$4398046511105, %r12            # imm = 0x40000000001
	movq	%r13, 16(%rsp)                  # 8-byte Spill
	movabsq	$4294968320, %r13               # imm = 0x100000400
	xorl	%eax, %eax
	leaq	32(%rsp), %rcx
	movq	%rax, (%rcx)
	movq	%rcx, %rdi
	leaq	8(%rsp), %r15
	movq	%rax, (%r15)
	leaq	48(%rsp), %r14
	movq	%rax, (%r14)
	movl	$8421408, %esi                  # imm = 0x808020
	callq	hipMalloc
	movl	$8421408, %esi                  # imm = 0x808020
	movq	%r15, %rdi
	callq	hipMalloc
	movl	$8421408, %esi                  # imm = 0x808020
	movq	%r14, %rdi
	callq	hipMalloc
	movq	%rbp, %r15
	leaq	88(%rsp), %rbp
	movq	%rbp, %rdi
	callq	hipEventCreate
	leaq	24(%rsp), %rdi
	callq	hipEventCreate
	movq	(%rbp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	(%rbp), %rdi
	callq	hipEventSynchronize
	movl	$_ZSt4cout, %edi
	movl	$1024, %esi                     # imm = 0x400
	callq	_ZNSo9_M_insertImEERSoT_
	movl	$.L.str.3, %esi
	movl	$1, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	(%r14), %rdi
	movl	$8421408, %edx                  # imm = 0x808020
	movq	16(%rsp), %rsi                  # 8-byte Reload
	movl	$1, %ecx
	callq	hipMemcpy
	leaq	32(%rsp), %rax
	movq	(%rax), %rdi
	movl	$8421408, %edx                  # imm = 0x808020
	movq	%r15, 96(%rsp)                  # 8-byte Spill
	movq	%r15, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	leaq	8(%rsp), %rax
	movq	(%rax), %rdi
	movl	$8421408, %edx                  # imm = 0x808020
	movq	%rbx, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	movl	$15000, %ebp                    # imm = 0x3A98
.LBB4_11:                               # =>This Inner Loop Header: Depth=1
	movq	%r13, %rdi
	movl	$1, %esi
	movq	%r12, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB4_13
# %bb.12:                               #   in Loop: Header=BB4_11 Depth=1
	movq	8(%rsp), %rdi
	movq	32(%rsp), %rsi
	movq	48(%rsp), %rdx
	callq	_Z27__device_stub__kernelJacobiPdS_S_
.LBB4_13:                               #   in Loop: Header=BB4_11 Depth=1
	movq	%r13, %rdi
	movl	$1, %esi
	movq	%r12, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB4_15
# %bb.14:                               #   in Loop: Header=BB4_11 Depth=1
	movq	32(%rsp), %rdi
	movq	8(%rsp), %rsi
	movq	48(%rsp), %rdx
	callq	_Z27__device_stub__kernelJacobiPdS_S_
.LBB4_15:                               #   in Loop: Header=BB4_11 Depth=1
	decl	%ebp
	jne	.LBB4_11
# %bb.16:
	movq	8(%rsp), %rsi
	movl	$8421408, %edx                  # imm = 0x808020
	movq	%rbx, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	movq	24(%rsp), %rdi
	xorl	%r14d, %r14d
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	24(%rsp), %rdi
	callq	hipEventSynchronize
	movq	88(%rsp), %rsi
	movq	24(%rsp), %rdx
	leaq	60(%rsp), %rdi
	callq	hipEventElapsedTime
	xorpd	%xmm3, %xmm3
	movq	%rbx, %r15
	movq	16(%rsp), %r13                  # 8-byte Reload
	movq	96(%rsp), %rbp                  # 8-byte Reload
	movsd	.LCPI4_2(%rip), %xmm1           # xmm1 = mem[0],zero
.LBB4_17:                               # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB4_18 Depth 2
	xorps	%xmm0, %xmm0
	cvtsi2sd	%r14d, %xmm0
	mulsd	%xmm1, %xmm0
	movsd	.LCPI4_3(%rip), %xmm2           # xmm2 = mem[0],zero
	subsd	%xmm0, %xmm2
	mulsd	%xmm0, %xmm2
	movsd	%xmm2, 40(%rsp)                 # 8-byte Spill
	xorl	%r12d, %r12d
.LBB4_18:                               #   Parent Loop BB4_17 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movsd	%xmm3, (%rsp)                   # 8-byte Spill
	movsd	(%r15,%r12,8), %xmm0            # xmm0 = mem[0],zero
	movaps	%xmm0, 64(%rsp)                 # 16-byte Spill
	xorps	%xmm0, %xmm0
	cvtsi2sd	%r12d, %xmm0
	mulsd	%xmm1, %xmm0
	mulsd	.LCPI4_6(%rip), %xmm0
	callq	sin
	movapd	.LCPI4_7(%rip), %xmm2           # xmm2 = [NaN,NaN]
	movapd	64(%rsp), %xmm3                 # 16-byte Reload
	movsd	.LCPI4_2(%rip), %xmm1           # xmm1 = mem[0],zero
	mulsd	40(%rsp), %xmm0                 # 8-byte Folded Reload
	subsd	%xmm0, %xmm3
	andpd	%xmm2, %xmm3
	maxsd	(%rsp), %xmm3                   # 8-byte Folded Reload
	incq	%r12
	cmpq	$1026, %r12                     # imm = 0x402
	jne	.LBB4_18
# %bb.19:                               #   in Loop: Header=BB4_17 Depth=1
	incq	%r14
	addq	$8208, %r15                     # imm = 0x2010
	cmpq	$1026, %r14                     # imm = 0x402
	jne	.LBB4_17
# %bb.20:
	movl	$_ZSt4cout, %edi
	movl	$.L.str.4, %esi
	movl	$9, %edx
	movapd	%xmm3, 64(%rsp)                 # 16-byte Spill
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	$_ZSt4cout, %edi
	movaps	64(%rsp), %xmm0                 # 16-byte Reload
	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.5, %esi
	movl	$7, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	xorps	%xmm0, %xmm0
	cvtss2sd	60(%rsp), %xmm0
	movl	$_ZSt4cout, %edi
	callq	_ZNSo9_M_insertIdEERSoT_
	movq	%rax, %r14
	movl	$.L.str.6, %esi
	movl	$3, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	(%r14), %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
	movq	%rbp, %rdi
	callq	_ZdaPv
	movq	%rbx, %rdi
	callq	_ZdaPv
	movq	%r13, %rdi
	callq	_ZdaPv
	movq	88(%rsp), %rdi
	callq	hipEventDestroy
	movq	24(%rsp), %rdi
	callq	hipEventDestroy
	movq	32(%rsp), %rdi
	callq	hipFree
	movq	8(%rsp), %rdi
	callq	hipFree
	movq	48(%rsp), %rdi
	callq	hipFree
	xorl	%eax, %eax
.LBB4_21:
	addq	$104, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end4:
	.size	main, .Lfunc_end4-main
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$32, %rsp
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -16
	movq	__hip_gpubin_handle(%rip), %rbx
	testq	%rbx, %rbx
	jne	.LBB5_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB5_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z12kernelJacobiPdS_S_, %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	$_Z10kernelSwapPdS_, %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_end5:
	.size	__hip_module_ctor, .Lfunc_end5-__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	.LBB6_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
.LBB6_2:
	retq
.Lfunc_end6:
	.size	__hip_module_dtor, .Lfunc_end6-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	_Z12kernelJacobiPdS_S_,@object  # @_Z12kernelJacobiPdS_S_
	.section	.rodata,"a",@progbits
	.globl	_Z12kernelJacobiPdS_S_
	.p2align	3, 0x0
_Z12kernelJacobiPdS_S_:
	.quad	_Z27__device_stub__kernelJacobiPdS_S_
	.size	_Z12kernelJacobiPdS_S_, 8

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

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"cft1 = "
	.size	.L.str, 8

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"cft3 = "
	.size	.L.str.1, 8

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"CUDA set device error"
	.size	.L.str.2, 22

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

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"Mistake: "
	.size	.L.str.4, 10

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"Time = "
	.size	.L.str.5, 8

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	" ms"
	.size	.L.str.6, 4

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z12kernelJacobiPdS_S_"
	.size	.L__unnamed_1, 23

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_Z10kernelSwapPdS_"
	.size	.L__unnamed_2, 19

	.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 _Z27__device_stub__kernelJacobiPdS_S_
	.addrsig_sym _Z25__device_stub__kernelSwapPdS_
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z12kernelJacobiPdS_S_
	.addrsig_sym _Z10kernelSwapPdS_
	.addrsig_sym _ZSt4cout
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z12kernelJacobiPdS_S_  ; -- Begin function _Z12kernelJacobiPdS_S_
	.globl	_Z12kernelJacobiPdS_S_
	.p2align	8
	.type	_Z12kernelJacobiPdS_S_,@function
_Z12kernelJacobiPdS_S_:                 ; @_Z12kernelJacobiPdS_S_
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x24
	s_load_b128 s[4:7], s[0:1], 0x0
	v_bfe_u32 v1, v0, 10, 10
	v_mov_b32_e32 v6, 0
	v_and_b32_e32 v0, 0x3ff, v0
	s_load_b64 s[0:1], s[0:1], 0x10
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_4) | instid1(VALU_DEP_1)
	v_mov_b32_e32 v7, v6
	s_waitcnt lgkmcnt(0)
	s_lshr_b32 s3, s2, 16
	s_and_b32 s2, s2, 0xffff
	v_mad_u64_u32 v[2:3], null, s15, s3, v[1:2]
	v_mul_lo_u32 v3, 0x402, v2
	v_mad_u64_u32 v[1:2], null, s14, s2, v[0:1]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_nc_u32_e32 v4, 0x402, v3
	v_add_nc_u32_e32 v10, v1, v3
	v_ashrrev_i32_e32 v3, 31, v1
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_ashrrev_i32_e32 v5, 31, v4
	v_add_nc_u32_e32 v0, 0x805, v10
	v_add_nc_u32_e32 v2, v4, v1
	v_add_co_u32 v4, vcc_lo, v4, v1
	s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_4)
	v_add_co_ci_u32_e32 v5, vcc_lo, v5, v3, vcc_lo
	v_ashrrev_i32_e32 v1, 31, v0
	s_delay_alu instid0(VALU_DEP_4) | instskip(SKIP_1) | instid1(VALU_DEP_4)
	v_ashrrev_i32_e32 v3, 31, v2
	v_add_nc_u32_e32 v10, 1, v10
	v_lshlrev_b64 v[4:5], 3, v[4:5]
	s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_4)
	v_lshlrev_b64 v[0:1], 3, v[0:1]
	v_lshlrev_b64 v[2:3], 3, v[2:3]
	s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_4)
	v_ashrrev_i32_e32 v11, 31, v10
	v_add_co_u32 v4, vcc_lo, s6, v4
	v_add_co_ci_u32_e32 v5, vcc_lo, s7, v5, vcc_lo
	v_add_co_u32 v0, vcc_lo, s4, v0
	v_add_co_ci_u32_e32 v1, vcc_lo, s5, v1, vcc_lo
	v_add_co_u32 v8, vcc_lo, s4, v2
	v_add_co_ci_u32_e32 v9, vcc_lo, s5, v3, vcc_lo
	global_store_b64 v[4:5], v[6:7], off offset:8
	s_clause 0x1
	global_load_b64 v[0:1], v[0:1], off
	global_load_b64 v[6:7], v[8:9], off offset:16
	v_lshlrev_b64 v[10:11], 3, v[10:11]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v10, vcc_lo, s4, v10
	v_add_co_ci_u32_e32 v11, vcc_lo, s5, v11, vcc_lo
	v_add_co_u32 v2, vcc_lo, s0, v2
	v_add_co_ci_u32_e32 v3, vcc_lo, s1, v3, vcc_lo
	s_clause 0x1
	global_load_b64 v[10:11], v[10:11], off
	global_load_b64 v[8:9], v[8:9], off
	global_load_b64 v[2:3], v[2:3], off offset:8
	s_mov_b32 s0, 0x302f1a27
	s_mov_b32 s1, 0x3e8fefd4
	s_waitcnt vmcnt(3)
	v_add_f64 v[0:1], v[0:1], v[6:7]
	s_waitcnt vmcnt(0)
	v_mul_f64 v[2:3], v[2:3], s[0:1]
	s_mov_b32 s0, 0x194474b7
	s_mov_b32 s1, 0x3fcfffce
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[0:1], v[0:1], v[10:11]
	v_add_f64 v[0:1], v[0:1], v[8:9]
	s_delay_alu instid0(VALU_DEP_1)
	v_fma_f64 v[0:1], v[0:1], s[0:1], v[2:3]
	global_store_b64 v[4:5], v[0:1], off offset:8
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z12kernelJacobiPdS_S_
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 280
		.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 12
		.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	_Z12kernelJacobiPdS_S_, .Lfunc_end0-_Z12kernelJacobiPdS_S_
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 444
; NumSgprs: 18
; NumVgprs: 12
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 12
; 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	_Z10kernelSwapPdS_      ; -- Begin function _Z10kernelSwapPdS_
	.globl	_Z10kernelSwapPdS_
	.p2align	8
	.type	_Z10kernelSwapPdS_,@function
_Z10kernelSwapPdS_:                     ; @_Z10kernelSwapPdS_
; %bb.0:
	s_load_b32 s4, s[0:1], 0x1c
	v_bfe_u32 v1, v0, 10, 10
	v_and_b32_e32 v0, 0x3ff, v0
	s_waitcnt lgkmcnt(0)
	s_lshr_b32 s2, s4, 16
	s_and_b32 s4, s4, 0xffff
	v_mad_u64_u32 v[2:3], null, s15, s2, v[1:2]
	s_load_b128 s[0:3], s[0:1], 0x0
	s_mul_i32 s14, s14, s4
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_lo_u32 v1, 0x402, v2
	v_add3_u32 v0, s14, v0, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v1, 31, v0
	v_lshlrev_b64 v[0:1], 3, v[0:1]
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v2, vcc_lo, s2, v0
	v_add_co_ci_u32_e32 v3, vcc_lo, s3, v1, vcc_lo
	v_add_co_u32 v0, vcc_lo, s0, v0
	v_add_co_ci_u32_e32 v1, vcc_lo, s1, v1, vcc_lo
	global_load_b64 v[2:3], v[2:3], off
	s_waitcnt vmcnt(0)
	global_store_b64 v[0:1], v[2:3], off
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z10kernelSwapPdS_
		.amdhsa_group_segment_fixed_size 0
		.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 4
		.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	_Z10kernelSwapPdS_, .Lfunc_end1-_Z10kernelSwapPdS_
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 164
; NumSgprs: 18
; NumVgprs: 4
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 4
; 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
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __hip_cuid_
	.amdgpu_metadata
---
amdhsa.kernels:
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         16
        .size:           8
        .value_kind:     global_buffer
      - .offset:         24
        .size:           4
        .value_kind:     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: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 280
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z12kernelJacobiPdS_S_
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z12kernelJacobiPdS_S_.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     12
    .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:           _Z10kernelSwapPdS_
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z10kernelSwapPdS_.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     4
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
