#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <assert.h>
#include <unistd.h>
#include <sys/time.h>
#include <cuda.h>
#include <cuda_runtime.h>



/* Problem size */
#define M 1024
#define N 1024
#define BDIMX 16
#define BDIMY 16
#define FLOAT_N 3214212.01

void init_arrays(double* data)
{
	int i, j;

	for (i = 1; i < (M+1); i++) {
		for (j = 1; j < (N+1); j++) {
			data[i*(N+1) + j] = ((double) i*j) / M;
		}
	}
}

void covariance(double* data, double* symmat, double* mean)
{
	int	i, j, j1,j2;

  	/* Determine mean of column vectors of input data matrix */
	for (j = 1; j < (M+1); j++) {
		mean[j] = 0.0;
		for (i = 1; i < (N+1); i++) {
        		mean[j] += data[i*(M+1) + j];
		}
		mean[j] /= FLOAT_N;
	}

  	/* Center the column vectors. */
	for (i = 1; i < (N+1); i++) {
		for (j = 1; j < (M+1); j++) {
			data[i*(M+1) + j] -= mean[j];
		}
	}

  	/* Calculate the m * m covariance matrix. */
	for (j1 = 1; j1 < (M+1); j1++) {
		for (j2 = j1; j2 < (M+1); j2++) {
	       		symmat[j1*(M+1) + j2] = 0.0;
			for (i = 1; i < N+1; i++) {
				symmat[j1*(M+1) + j2] += data[i*(M+1) + j1] * data[i*(M+1) + j2];
			}
        		symmat[j2*(M+1) + j1] = symmat[j1*(M+1) + j2];
      		}
	}
}

__global__ void kernel1(int m, int n, double *mean, double *data)
{
	unsigned int j = blockIdx.x * blockDim.x + threadIdx.x;

	if (j < M)
	{
		mean[j] = 0.0;

		int i;
		for(i = 0; i < N; i++)
		{
			mean[j] += data[i * M + j];
		}
		mean[j] /= FLOAT_N;
	}
}

__global__ void kernel2(int m, int n,double *mean, double *data)
{
unsigned	int j = blockIdx.x * blockDim.x + threadIdx.x;
unsigned	int i = blockIdx.y * blockDim.y + threadIdx.y;

	if ((i < N) && (j <M))
	{
		data[i * M + j] -= mean[j];
	}
}

__global__ void kernel3(int m, int n,double *symmat,double *data)
{
	unsigned int j1 = blockIdx.x * blockDim.x + threadIdx.x;
	int i, j2;

	if (j1 < M)
	{
		for (j2 = j1; j2 < M; j2++)
		{
			symmat[j1*M + j2] = 0.0;
			for(i = 0; i < N; i++)
			{
				symmat[j1 * M + j2] += data[i * M + j1] * data[i * M + j2];
			}
			symmat[j2 * M + j1] = symmat[j1 * M + j2];
		}
	}
}

int main(int argc, char *argv[])
{
	double		*data;
	double		*symmat;
	double		*mean;
	unsigned int n=N,m=N;

	printf("covariance starting...\n");

	// set up device
	int dev = 0;
	cudaDeviceProp deviceProp;
	cudaGetDeviceProperties(&deviceProp, dev);
	printf("Device properties %d: %s\n", dev, deviceProp.name);
	cudaSetDevice(dev);

	struct timeval	cpu_start, cpu_end;

	 data = (double*)malloc((M+1)*(N+1)*sizeof(double));
	 symmat = (double*)malloc((M+1)*(M+1)*sizeof(double));
   mean = (double*)malloc((M+1)*sizeof(double));

	 init_arrays(data);

	 gettimeofday(&cpu_start, NULL);
	 covariance(data, symmat, mean);
	 gettimeofday(&cpu_end, NULL);
	 fprintf(stdout, "CPU Runtime: %0.6lfs\n", ((cpu_end.tv_sec - cpu_start.tv_sec) * 1000000.0 + (cpu_end.tv_usec - cpu_start.tv_usec)) / 1000000.0);

	 double *dataOnGPU;
	 double *meanOnGPU;
	 double *symmatOnGPU;
  	// malloc device global memory
   cudaMalloc((void **)&dataOnGPU,(M+1)*(N+1)*sizeof(double));
	 cudaMalloc((void **)&symmatOnGPU,(M+1)*(M+1)*sizeof(double));
	 cudaMalloc((void **)&meanOnGPU,(M+1)*sizeof(double));

	 // transfer data from host to device
	 cudaMemcpy(dataOnGPU,data,(M+1)*(N+1)*sizeof(double),cudaMemcpyHostToDevice);
	 cudaMemcpy(symmatOnGPU,symmat,(M+1)*(M+1)*sizeof(double),cudaMemcpyHostToDevice);
	 cudaMemcpy(meanOnGPU, mean,(M+1)*sizeof(double),cudaMemcpyHostToDevice);

	  // invoke kernel at host side
		dim3 block (BDIMX, BDIMY);
		dim3 grid  (1, 1);
		printf("<<< grid (%d,%d) block (%d,%d)>>>\n", grid.x, grid.y, block.x,
					 block.y);

		gettimeofday(&cpu_start, NULL);
	  kernel1<<<grid, block>>>(m,n,meanOnGPU,dataOnGPU);
		cudaDeviceSynchronize();
		kernel2<<<grid, block>>>(m,n,meanOnGPU,dataOnGPU);
		cudaDeviceSynchronize();
		kernel3<<<grid, block>>>(m,n,symmatOnGPU,dataOnGPU);
		cudaDeviceSynchronize();
		gettimeofday(&cpu_end, NULL);
	  fprintf(stdout, "GPU Runtime: %0.6lfs\n", ((cpu_end.tv_sec - cpu_start.tv_sec) * 1000000.0 + (cpu_end.tv_usec - cpu_start.tv_usec)) / 1000000.0);

	  // check kernel error
  	cudaGetLastError();

	  // free device global memory
	  cudaFree(dataOnGPU);
    cudaFree(symmatOnGPU);
    cudaFree(meanOnGPU);

	   // free host memory
	  free(data);
	  free(symmat);
	  free(mean);
	  // reset device
 	  cudaDeviceReset();

 	  return (0);
}

	.file	"tmpxft_0021b89b_00000000-6_Covariance.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2045:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2045:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z11init_arraysPd
	.type	_Z11init_arraysPd, @function
_Z11init_arraysPd:
.LFB2040:
	.cfi_startproc
	endbr64
	movsd	.LC0(%rip), %xmm2
	addq	$8200, %rdi
	movl	$1, %edx
.L3:
	cvtsi2sdl	%edx, %xmm1
	movl	$1, %eax
.L4:
	cvtsi2sdl	%eax, %xmm0
	mulsd	%xmm1, %xmm0
	mulsd	%xmm2, %xmm0
	movsd	%xmm0, (%rdi,%rax,8)
	incq	%rax
	cmpq	$1025, %rax
	jne	.L4
	incl	%edx
	addq	$8200, %rdi
	cmpl	$1025, %edx
	jne	.L3
	ret
	.cfi_endproc
.LFE2040:
	.size	_Z11init_arraysPd, .-_Z11init_arraysPd
	.globl	_Z10covariancePdS_S_
	.type	_Z10covariancePdS_S_, @function
_Z10covariancePdS_S_:
.LFB2041:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	movsd	.LC2(%rip), %xmm1
	movq	%rdi, %rcx
	movq	%rsi, %r8
	movl	$1, %eax
.L10:
	movq	$0x000000000, (%rdx,%rax,8)
	leaq	(%rcx,%rax,8), %rdi
	movl	$1, %esi
.L9:
	movsd	(%rdx,%rax,8), %xmm0
	addsd	8200(%rdi), %xmm0
	incl	%esi
	addq	$8200, %rdi
	movsd	%xmm0, (%rdx,%rax,8)
	cmpl	$1025, %esi
	jne	.L9
	divsd	%xmm1, %xmm0
	movsd	%xmm0, (%rdx,%rax,8)
	incq	%rax
	cmpq	$1025, %rax
	jne	.L10
	leaq	8200(%rcx), %rdi
	movl	$1025, %r9d
.L13:
	movq	%rdi, %rsi
	movl	$1, %eax
.L12:
	movsd	8(%rsi), %xmm0
	subsd	(%rdx,%rax,8), %xmm0
	incq	%rax
	addq	$8, %rsi
	movsd	%xmm0, (%rsi)
	cmpq	$1025, %rax
	jne	.L12
	addl	$1025, %r9d
	addq	$8200, %rdi
	cmpl	$1050625, %r9d
	jne	.L13
	movl	$8, %r9d
	movl	$1, %esi
.L14:
	imulq	$8208, %rsi, %rax
	movq	%rsi, %rdx
	leaq	(%rcx,%r9), %r11
	leaq	(%r8,%r9), %r10
	addq	%r8, %rax
.L16:
	movq	$0x000000000, (%rax)
	leaq	(%rcx,%rdx,8), %rbx
	xorl	%edi, %edi
.L15:
	movsd	8200(%r11,%rdi), %xmm0
	mulsd	8200(%rbx,%rdi), %xmm0
	addq	$8200, %rdi
	addsd	(%rax), %xmm0
	movsd	%xmm0, (%rax)
	cmpq	$8396800, %rdi
	jne	.L15
	imulq	$8200, %rdx, %rdi
	incq	%rdx
	addq	$8, %rax
	movsd	%xmm0, (%r10,%rdi)
	cmpl	$1025, %edx
	jne	.L16
	incq	%rsi
	addq	$8, %r9
	cmpq	$1025, %rsi
	jne	.L14
	popq	%rbx
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2041:
	.size	_Z10covariancePdS_S_, .-_Z10covariancePdS_S_
	.globl	_Z30__device_stub__Z7kernel1iiPdS_iiPdS_
	.type	_Z30__device_stub__Z7kernel1iiPdS_iiPdS_, @function
_Z30__device_stub__Z7kernel1iiPdS_iiPdS_:
.LFB2067:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movl	%edi, 28(%rsp)
	leaq	56(%rsp), %rdi
	movl	%esi, 24(%rsp)
	leaq	68(%rsp), %rsi
	movq	%rdx, 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	28(%rsp), %rax
	movl	$1, 64(%rsp)
	movq	%rax, 104(%rsp)
	leaq	24(%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	.L26
	pushq	48(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z7kernel1iiPdS_(%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
.L26:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L28
	call	__stack_chk_fail@PLT
.L28:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2067:
	.size	_Z30__device_stub__Z7kernel1iiPdS_iiPdS_, .-_Z30__device_stub__Z7kernel1iiPdS_iiPdS_
	.globl	_Z7kernel1iiPdS_
	.type	_Z7kernel1iiPdS_, @function
_Z7kernel1iiPdS_:
.LFB2068:
	.cfi_startproc
	endbr64
	jmp	_Z30__device_stub__Z7kernel1iiPdS_iiPdS_
	.cfi_endproc
.LFE2068:
	.size	_Z7kernel1iiPdS_, .-_Z7kernel1iiPdS_
	.globl	_Z30__device_stub__Z7kernel2iiPdS_iiPdS_
	.type	_Z30__device_stub__Z7kernel2iiPdS_iiPdS_, @function
_Z30__device_stub__Z7kernel2iiPdS_iiPdS_:
.LFB2069:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movl	%edi, 28(%rsp)
	leaq	56(%rsp), %rdi
	movl	%esi, 24(%rsp)
	leaq	68(%rsp), %rsi
	movq	%rdx, 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	28(%rsp), %rax
	movl	$1, 64(%rsp)
	movq	%rax, 104(%rsp)
	leaq	24(%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	.L31
	pushq	48(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z7kernel2iiPdS_(%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
.L31:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L33
	call	__stack_chk_fail@PLT
.L33:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2069:
	.size	_Z30__device_stub__Z7kernel2iiPdS_iiPdS_, .-_Z30__device_stub__Z7kernel2iiPdS_iiPdS_
	.globl	_Z7kernel2iiPdS_
	.type	_Z7kernel2iiPdS_, @function
_Z7kernel2iiPdS_:
.LFB2070:
	.cfi_startproc
	endbr64
	jmp	_Z30__device_stub__Z7kernel2iiPdS_iiPdS_
	.cfi_endproc
.LFE2070:
	.size	_Z7kernel2iiPdS_, .-_Z7kernel2iiPdS_
	.globl	_Z30__device_stub__Z7kernel3iiPdS_iiPdS_
	.type	_Z30__device_stub__Z7kernel3iiPdS_iiPdS_, @function
_Z30__device_stub__Z7kernel3iiPdS_iiPdS_:
.LFB2071:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movl	%edi, 28(%rsp)
	leaq	56(%rsp), %rdi
	movl	%esi, 24(%rsp)
	leaq	68(%rsp), %rsi
	movq	%rdx, 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	28(%rsp), %rax
	movl	$1, 64(%rsp)
	movq	%rax, 104(%rsp)
	leaq	24(%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	.L36
	pushq	48(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z7kernel3iiPdS_(%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
.L36:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L38
	call	__stack_chk_fail@PLT
.L38:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2071:
	.size	_Z30__device_stub__Z7kernel3iiPdS_iiPdS_, .-_Z30__device_stub__Z7kernel3iiPdS_iiPdS_
	.globl	_Z7kernel3iiPdS_
	.type	_Z7kernel3iiPdS_, @function
_Z7kernel3iiPdS_:
.LFB2072:
	.cfi_startproc
	endbr64
	jmp	_Z30__device_stub__Z7kernel3iiPdS_iiPdS_
	.cfi_endproc
.LFE2072:
	.size	_Z7kernel3iiPdS_, .-_Z7kernel3iiPdS_
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC3:
	.string	"covariance starting...\n"
.LC4:
	.string	"Device properties %d: %s\n"
.LC6:
	.string	"CPU Runtime: %0.6lfs\n"
.LC7:
	.string	"<<< grid (%d,%d) block (%d,%d)>>>\n"
.LC8:
	.string	"GPU Runtime: %0.6lfs\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2042:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	leaq	.LC3(%rip), %rsi
	movl	$2, %edi
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	subq	$1120, %rsp
	.cfi_def_cfa_offset 1168
	movq	%fs:40, %rax
	movq	%rax, 1112(%rsp)
	xorl	%eax, %eax
	leaq	80(%rsp), %rbx
	leaq	48(%rsp), %r14
	leaq	64(%rsp), %r13
	call	__printf_chk@PLT
	xorl	%esi, %esi
	movq	%rbx, %rdi
	call	cudaGetDeviceProperties_v2@PLT
	movq	%rbx, %rcx
	xorl	%edx, %edx
	movl	$2, %edi
	leaq	.LC4(%rip), %rsi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	xorl	%edi, %edi
	call	cudaSetDevice@PLT
	movl	$8405000, %edi
	call	malloc@PLT
	movl	$8405000, %edi
	movq	%rax, %rbx
	call	malloc@PLT
	movl	$8200, %edi
	movq	%rax, %r12
	call	malloc@PLT
	movq	%rbx, %rdi
	xorl	%esi, %esi
	movq	%rax, %rbp
	call	_Z11init_arraysPd
	movq	%r14, %rdi
	call	gettimeofday@PLT
	movq	%rbp, %rdx
	movq	%r12, %rsi
	movq	%rbx, %rdi
	call	_Z10covariancePdS_S_
	xorl	%esi, %esi
	movq	%r13, %rdi
	call	gettimeofday@PLT
	movq	64(%rsp), %rax
	subq	48(%rsp), %rax
	leaq	.LC6(%rip), %rdx
	cvtsi2sdq	%rax, %xmm0
	movq	72(%rsp), %rax
	subq	56(%rsp), %rax
	movl	$2, %esi
	mulsd	.LC5(%rip), %xmm0
	cvtsi2sdq	%rax, %xmm1
	movb	$1, %al
	movq	stdout(%rip), %rdi
	addsd	%xmm1, %xmm0
	divsd	.LC5(%rip), %xmm0
	call	__fprintf_chk@PLT
	movq	%rsp, %rdi
	movl	$8405000, %esi
	call	cudaMalloc@PLT
	leaq	16(%rsp), %rdi
	movl	$8405000, %esi
	call	cudaMalloc@PLT
	leaq	8(%rsp), %rdi
	movl	$8200, %esi
	call	cudaMalloc@PLT
	movq	(%rsp), %rdi
	movl	$1, %ecx
	movq	%rbx, %rsi
	movl	$8405000, %edx
	call	cudaMemcpy@PLT
	movq	16(%rsp), %rdi
	movl	$1, %ecx
	movq	%r12, %rsi
	movl	$8405000, %edx
	call	cudaMemcpy@PLT
	movq	8(%rsp), %rdi
	movl	$1, %ecx
	movq	%rbp, %rsi
	movl	$8200, %edx
	call	cudaMemcpy@PLT
	movl	$16, %r9d
	movl	$16, %r8d
	movl	$1, %ecx
	movl	$1, %edx
	leaq	.LC7(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	xorl	%esi, %esi
	movq	%r14, %rdi
	call	gettimeofday@PLT
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movabsq	$4294967297, %rdi
	movl	$1, %ecx
	movl	$1, %esi
	movabsq	$68719476752, %rdx
	movq	%rdi, 36(%rsp)
	movl	$1, 44(%rsp)
	movq	%rdx, 24(%rsp)
	movl	$1, 32(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L42
	movq	(%rsp), %rcx
	movq	8(%rsp), %rdx
	movl	$1024, %esi
	movl	$1024, %edi
	call	_Z30__device_stub__Z7kernel1iiPdS_iiPdS_
.L42:
	call	cudaDeviceSynchronize@PLT
	movl	32(%rsp), %ecx
	movl	44(%rsp), %esi
	xorl	%r9d, %r9d
	movq	24(%rsp), %rdx
	movq	36(%rsp), %rdi
	xorl	%r8d, %r8d
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L43
	movq	(%rsp), %rcx
	movq	8(%rsp), %rdx
	movl	$1024, %esi
	movl	$1024, %edi
	call	_Z30__device_stub__Z7kernel2iiPdS_iiPdS_
.L43:
	call	cudaDeviceSynchronize@PLT
	movl	32(%rsp), %ecx
	movl	44(%rsp), %esi
	xorl	%r9d, %r9d
	movq	24(%rsp), %rdx
	movq	36(%rsp), %rdi
	xorl	%r8d, %r8d
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L44
	movq	(%rsp), %rcx
	movq	16(%rsp), %rdx
	movl	$1024, %esi
	movl	$1024, %edi
	call	_Z30__device_stub__Z7kernel3iiPdS_iiPdS_
.L44:
	call	cudaDeviceSynchronize@PLT
	xorl	%esi, %esi
	movq	%r13, %rdi
	call	gettimeofday@PLT
	movq	64(%rsp), %rax
	subq	48(%rsp), %rax
	leaq	.LC8(%rip), %rdx
	cvtsi2sdq	%rax, %xmm0
	movq	72(%rsp), %rax
	subq	56(%rsp), %rax
	movl	$2, %esi
	mulsd	.LC5(%rip), %xmm0
	cvtsi2sdq	%rax, %xmm1
	movb	$1, %al
	movq	stdout(%rip), %rdi
	addsd	%xmm1, %xmm0
	divsd	.LC5(%rip), %xmm0
	call	__fprintf_chk@PLT
	call	cudaGetLastError@PLT
	movq	(%rsp), %rdi
	call	cudaFree@PLT
	movq	16(%rsp), %rdi
	call	cudaFree@PLT
	movq	8(%rsp), %rdi
	call	cudaFree@PLT
	movq	%rbx, %rdi
	call	free@PLT
	movq	%r12, %rdi
	call	free@PLT
	movq	%rbp, %rdi
	call	free@PLT
	call	cudaDeviceReset@PLT
	movq	1112(%rsp), %rax
	subq	%fs:40, %rax
	je	.L45
	call	__stack_chk_fail@PLT
.L45:
	addq	$1120, %rsp
	.cfi_def_cfa_offset 48
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2042:
	.size	main, .-main
	.section	.rodata.str1.1
.LC9:
	.string	"_Z7kernel3iiPdS_"
.LC10:
	.string	"_Z7kernel2iiPdS_"
.LC11:
	.string	"_Z7kernel1iiPdS_"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2074:
	.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	.LC9(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z7kernel3iiPdS_(%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	.LC10(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z7kernel2iiPdS_(%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
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r9d, %r9d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC11(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z7kernel1iiPdS_(%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
.LFE2074:
	.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	0
	.long	1062207488
	.align 8
.LC2:
	.long	21474836
	.long	1095271874
	.align 8
.LC5:
	.long	0
	.long	1093567616
	.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 <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <assert.h>
#include <unistd.h>
#include <sys/time.h>
#include <hip/hip_runtime.h>




/* Problem size */
#define M 1024
#define N 1024
#define BDIMX 16
#define BDIMY 16
#define FLOAT_N 3214212.01

void init_arrays(double* data)
{
	int i, j;

	for (i = 1; i < (M+1); i++) {
		for (j = 1; j < (N+1); j++) {
			data[i*(N+1) + j] = ((double) i*j) / M;
		}
	}
}

void covariance(double* data, double* symmat, double* mean)
{
	int	i, j, j1,j2;

  	/* Determine mean of column vectors of input data matrix */
	for (j = 1; j < (M+1); j++) {
		mean[j] = 0.0;
		for (i = 1; i < (N+1); i++) {
        		mean[j] += data[i*(M+1) + j];
		}
		mean[j] /= FLOAT_N;
	}

  	/* Center the column vectors. */
	for (i = 1; i < (N+1); i++) {
		for (j = 1; j < (M+1); j++) {
			data[i*(M+1) + j] -= mean[j];
		}
	}

  	/* Calculate the m * m covariance matrix. */
	for (j1 = 1; j1 < (M+1); j1++) {
		for (j2 = j1; j2 < (M+1); j2++) {
	       		symmat[j1*(M+1) + j2] = 0.0;
			for (i = 1; i < N+1; i++) {
				symmat[j1*(M+1) + j2] += data[i*(M+1) + j1] * data[i*(M+1) + j2];
			}
        		symmat[j2*(M+1) + j1] = symmat[j1*(M+1) + j2];
      		}
	}
}

__global__ void kernel1(int m, int n, double *mean, double *data)
{
	unsigned int j = blockIdx.x * blockDim.x + threadIdx.x;

	if (j < M)
	{
		mean[j] = 0.0;

		int i;
		for(i = 0; i < N; i++)
		{
			mean[j] += data[i * M + j];
		}
		mean[j] /= FLOAT_N;
	}
}

__global__ void kernel2(int m, int n,double *mean, double *data)
{
unsigned	int j = blockIdx.x * blockDim.x + threadIdx.x;
unsigned	int i = blockIdx.y * blockDim.y + threadIdx.y;

	if ((i < N) && (j <M))
	{
		data[i * M + j] -= mean[j];
	}
}

__global__ void kernel3(int m, int n,double *symmat,double *data)
{
	unsigned int j1 = blockIdx.x * blockDim.x + threadIdx.x;
	int i, j2;

	if (j1 < M)
	{
		for (j2 = j1; j2 < M; j2++)
		{
			symmat[j1*M + j2] = 0.0;
			for(i = 0; i < N; i++)
			{
				symmat[j1 * M + j2] += data[i * M + j1] * data[i * M + j2];
			}
			symmat[j2 * M + j1] = symmat[j1 * M + j2];
		}
	}
}

int main(int argc, char *argv[])
{
	double		*data;
	double		*symmat;
	double		*mean;
	unsigned int n=N,m=N;

	printf("covariance starting...\n");

	// set up device
	int dev = 0;
	hipDeviceProp_t deviceProp;
	hipGetDeviceProperties(&deviceProp, dev);
	printf("Device properties %d: %s\n", dev, deviceProp.name);
	hipSetDevice(dev);

	struct timeval	cpu_start, cpu_end;

	 data = (double*)malloc((M+1)*(N+1)*sizeof(double));
	 symmat = (double*)malloc((M+1)*(M+1)*sizeof(double));
   mean = (double*)malloc((M+1)*sizeof(double));

	 init_arrays(data);

	 gettimeofday(&cpu_start, NULL);
	 covariance(data, symmat, mean);
	 gettimeofday(&cpu_end, NULL);
	 fprintf(stdout, "CPU Runtime: %0.6lfs\n", ((cpu_end.tv_sec - cpu_start.tv_sec) * 1000000.0 + (cpu_end.tv_usec - cpu_start.tv_usec)) / 1000000.0);

	 double *dataOnGPU;
	 double *meanOnGPU;
	 double *symmatOnGPU;
  	// malloc device global memory
   hipMalloc((void **)&dataOnGPU,(M+1)*(N+1)*sizeof(double));
	 hipMalloc((void **)&symmatOnGPU,(M+1)*(M+1)*sizeof(double));
	 hipMalloc((void **)&meanOnGPU,(M+1)*sizeof(double));

	 // transfer data from host to device
	 hipMemcpy(dataOnGPU,data,(M+1)*(N+1)*sizeof(double),hipMemcpyHostToDevice);
	 hipMemcpy(symmatOnGPU,symmat,(M+1)*(M+1)*sizeof(double),hipMemcpyHostToDevice);
	 hipMemcpy(meanOnGPU, mean,(M+1)*sizeof(double),hipMemcpyHostToDevice);

	  // invoke kernel at host side
		dim3 block (BDIMX, BDIMY);
		dim3 grid  (1, 1);
		printf("<<< grid (%d,%d) block (%d,%d)>>>\n", grid.x, grid.y, block.x,
					 block.y);

		gettimeofday(&cpu_start, NULL);
	  kernel1<<<grid, block>>>(m,n,meanOnGPU,dataOnGPU);
		hipDeviceSynchronize();
		kernel2<<<grid, block>>>(m,n,meanOnGPU,dataOnGPU);
		hipDeviceSynchronize();
		kernel3<<<grid, block>>>(m,n,symmatOnGPU,dataOnGPU);
		hipDeviceSynchronize();
		gettimeofday(&cpu_end, NULL);
	  fprintf(stdout, "GPU Runtime: %0.6lfs\n", ((cpu_end.tv_sec - cpu_start.tv_sec) * 1000000.0 + (cpu_end.tv_usec - cpu_start.tv_usec)) / 1000000.0);

	  // check kernel error
  	hipGetLastError();

	  // free device global memory
	  hipFree(dataOnGPU);
    hipFree(symmatOnGPU);
    hipFree(meanOnGPU);

	   // free host memory
	  free(data);
	  free(symmat);
	  free(mean);
	  // reset device
 	  hipDeviceReset();

 	  return (0);
}

	.text
	.file	"Covariance.hip"
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z11init_arraysPd
.LCPI0_0:
	.quad	0x3f50000000000000              # double 9.765625E-4
	.text
	.globl	_Z11init_arraysPd
	.type	_Z11init_arraysPd,@function
_Z11init_arraysPd:                      # @_Z11init_arraysPd
	.cfi_startproc
# %bb.0:
	addq	$8208, %rdi                     # imm = 0x2010
	movl	$1, %eax
	movsd	.LCPI0_0(%rip), %xmm0           # xmm0 = mem[0],zero
.LBB0_1:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB0_2 Depth 2
	xorps	%xmm1, %xmm1
	cvtsi2sd	%eax, %xmm1
	xorl	%ecx, %ecx
.LBB0_2:                                #   Parent Loop BB0_1 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	leaq	1(%rcx), %rdx
	xorps	%xmm2, %xmm2
	cvtsi2sd	%edx, %xmm2
	mulsd	%xmm1, %xmm2
	mulsd	%xmm0, %xmm2
	movsd	%xmm2, (%rdi,%rcx,8)
	movq	%rdx, %rcx
	cmpq	$1024, %rdx                     # imm = 0x400
	jne	.LBB0_2
# %bb.3:                                #   in Loop: Header=BB0_1 Depth=1
	incq	%rax
	addq	$8200, %rdi                     # imm = 0x2008
	cmpq	$1025, %rax                     # imm = 0x401
	jne	.LBB0_1
# %bb.4:
	retq
.Lfunc_end0:
	.size	_Z11init_arraysPd, .Lfunc_end0-_Z11init_arraysPd
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z10covariancePdS_S_
.LCPI1_0:
	.quad	0x414885c20147ae14              # double 3214212.0099999998
	.text
	.globl	_Z10covariancePdS_S_
	.type	_Z10covariancePdS_S_,@function
_Z10covariancePdS_S_:                   # @_Z10covariancePdS_S_
	.cfi_startproc
# %bb.0:
	movl	$1, %eax
	movsd	.LCPI1_0(%rip), %xmm0           # xmm0 = mem[0],zero
	movq	%rdi, %rcx
.LBB1_1:                                # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_2 Depth 2
	movq	$0, (%rdx,%rax,8)
	xorpd	%xmm1, %xmm1
	movl	$8208, %r8d                     # imm = 0x2010
.LBB1_2:                                #   Parent Loop BB1_1 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	addsd	(%rcx,%r8), %xmm1
	movsd	%xmm1, (%rdx,%rax,8)
	addq	$8200, %r8                      # imm = 0x2008
	cmpq	$8405008, %r8                   # imm = 0x804010
	jne	.LBB1_2
# %bb.3:                                #   in Loop: Header=BB1_1 Depth=1
	divsd	%xmm0, %xmm1
	movsd	%xmm1, (%rdx,%rax,8)
	incq	%rax
	addq	$8, %rcx
	cmpq	$1025, %rax                     # imm = 0x401
	jne	.LBB1_1
# %bb.4:                                # %.preheader51.preheader
	leaq	8208(%rdi), %rax
	movl	$1, %ecx
.LBB1_5:                                # %.preheader51
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_6 Depth 2
	xorl	%r8d, %r8d
.LBB1_6:                                #   Parent Loop BB1_5 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movsd	(%rax,%r8,8), %xmm0             # xmm0 = mem[0],zero
	subsd	8(%rdx,%r8,8), %xmm0
	movsd	%xmm0, (%rax,%r8,8)
	incq	%r8
	cmpq	$1024, %r8                      # imm = 0x400
	jne	.LBB1_6
# %bb.7:                                #   in Loop: Header=BB1_5 Depth=1
	incq	%rcx
	addq	$8200, %rax                     # imm = 0x2008
	cmpq	$1025, %rcx                     # imm = 0x401
	jne	.LBB1_5
# %bb.8:                                # %.preheader.preheader
	addq	$8208, %rdi                     # imm = 0x2010
	movl	$1, %eax
.LBB1_9:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_10 Depth 2
                                        #       Child Loop BB1_11 Depth 3
	movq	%rax, %rcx
	shlq	$13, %rcx
	leaq	(%rcx,%rax,8), %rcx
	addq	%rsi, %rcx
	leaq	(%rsi,%rax,8), %rdx
	movq	%rdi, %r8
	movq	%rax, %r9
.LBB1_10:                               #   Parent Loop BB1_9 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB1_11 Depth 3
	movq	$0, (%rcx,%r9,8)
	xorpd	%xmm0, %xmm0
	xorl	%r10d, %r10d
.LBB1_11:                               #   Parent Loop BB1_9 Depth=1
                                        #     Parent Loop BB1_10 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	movsd	(%rdi,%r10), %xmm1              # xmm1 = mem[0],zero
	mulsd	(%r8,%r10), %xmm1
	addsd	%xmm1, %xmm0
	movsd	%xmm0, (%rcx,%r9,8)
	addq	$8200, %r10                     # imm = 0x2008
	cmpq	$8396800, %r10                  # imm = 0x802000
	jne	.LBB1_11
# %bb.12:                               #   in Loop: Header=BB1_10 Depth=2
	movq	%r9, %r10
	shlq	$13, %r10
	leaq	(%r10,%r9,8), %r10
	movsd	%xmm0, (%rdx,%r10)
	incq	%r9
	addq	$8, %r8
	cmpq	$1025, %r9                      # imm = 0x401
	jne	.LBB1_10
# %bb.13:                               #   in Loop: Header=BB1_9 Depth=1
	incq	%rax
	addq	$8, %rdi
	cmpq	$1025, %rax                     # imm = 0x401
	jne	.LBB1_9
# %bb.14:
	retq
.Lfunc_end1:
	.size	_Z10covariancePdS_S_, .Lfunc_end1-_Z10covariancePdS_S_
	.cfi_endproc
                                        # -- End function
	.globl	_Z22__device_stub__kernel1iiPdS_ # -- Begin function _Z22__device_stub__kernel1iiPdS_
	.type	_Z22__device_stub__kernel1iiPdS_,@function
_Z22__device_stub__kernel1iiPdS_:       # @_Z22__device_stub__kernel1iiPdS_
	.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	12(%rsp), %rax
	movl	%edi, (%rax)
	leaq	8(%rsp), %rdi
	movl	%esi, (%rdi)
	leaq	40(%rsp), %rsi
	movq	%rdx, (%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	$_Z7kernel1iiPdS_, %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_end2:
	.size	_Z22__device_stub__kernel1iiPdS_, .Lfunc_end2-_Z22__device_stub__kernel1iiPdS_
	.cfi_endproc
                                        # -- End function
	.globl	_Z22__device_stub__kernel2iiPdS_ # -- Begin function _Z22__device_stub__kernel2iiPdS_
	.type	_Z22__device_stub__kernel2iiPdS_,@function
_Z22__device_stub__kernel2iiPdS_:       # @_Z22__device_stub__kernel2iiPdS_
	.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	12(%rsp), %rax
	movl	%edi, (%rax)
	leaq	8(%rsp), %rdi
	movl	%esi, (%rdi)
	leaq	40(%rsp), %rsi
	movq	%rdx, (%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	$_Z7kernel2iiPdS_, %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_end3:
	.size	_Z22__device_stub__kernel2iiPdS_, .Lfunc_end3-_Z22__device_stub__kernel2iiPdS_
	.cfi_endproc
                                        # -- End function
	.globl	_Z22__device_stub__kernel3iiPdS_ # -- Begin function _Z22__device_stub__kernel3iiPdS_
	.type	_Z22__device_stub__kernel3iiPdS_,@function
_Z22__device_stub__kernel3iiPdS_:       # @_Z22__device_stub__kernel3iiPdS_
	.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	12(%rsp), %rax
	movl	%edi, (%rax)
	leaq	8(%rsp), %rdi
	movl	%esi, (%rdi)
	leaq	40(%rsp), %rsi
	movq	%rdx, (%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	$_Z7kernel3iiPdS_, %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	_Z22__device_stub__kernel3iiPdS_, .Lfunc_end4-_Z22__device_stub__kernel3iiPdS_
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI5_0:
	.quad	0x3f50000000000000              # double 9.765625E-4
.LCPI5_1:
	.quad	0x412e848000000000              # double 1.0E+6
	.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	$1528, %rsp                     # imm = 0x5F8
	.cfi_def_cfa_offset 1584
	.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	$.Lstr, %edi
	callq	puts@PLT
	leaq	56(%rsp), %rbx
	movq	%rbx, %rdi
	xorl	%esi, %esi
	callq	hipGetDevicePropertiesR0600
	movl	$.L.str.1, %edi
	xorl	%esi, %esi
	movq	%rbx, %rdx
	xorl	%eax, %eax
	callq	printf
	xorl	%edi, %edi
	callq	hipSetDevice
	movl	$8405000, %edi                  # imm = 0x804008
	callq	malloc
	movq	%rax, %rbp
	movl	$8405000, %edi                  # imm = 0x804008
	callq	malloc
	movq	%rax, %r14
	movl	$8200, %edi                     # imm = 0x2008
	callq	malloc
	movq	%rax, %r15
	movq	%rbp, %rax
	addq	$8208, %rax                     # imm = 0x2010
	movl	$1, %ecx
	movsd	.LCPI5_0(%rip), %xmm0           # xmm0 = mem[0],zero
.LBB5_1:                                # %.preheader.i
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB5_2 Depth 2
	xorps	%xmm1, %xmm1
	cvtsi2sd	%ecx, %xmm1
	xorl	%edx, %edx
.LBB5_2:                                #   Parent Loop BB5_1 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	leaq	1(%rdx), %rsi
	xorps	%xmm2, %xmm2
	cvtsi2sd	%esi, %xmm2
	mulsd	%xmm1, %xmm2
	mulsd	%xmm0, %xmm2
	movsd	%xmm2, (%rax,%rdx,8)
	movq	%rsi, %rdx
	cmpq	$1024, %rsi                     # imm = 0x400
	jne	.LBB5_2
# %bb.3:                                #   in Loop: Header=BB5_1 Depth=1
	incq	%rcx
	addq	$8200, %rax                     # imm = 0x2008
	cmpq	$1025, %rcx                     # imm = 0x401
	jne	.LBB5_1
# %bb.4:                                # %_Z11init_arraysPd.exit
	leaq	24(%rsp), %r13
	movq	%r13, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	movq	%rbp, %rdi
	movq	%r14, %rsi
	movq	%r15, %rdx
	callq	_Z10covariancePdS_S_
	movq	%r15, %rbx
	movq	%r14, %r15
	leaq	40(%rsp), %r12
	movq	%r12, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	movq	stdout(%rip), %rdi
	movq	(%r12), %rax
	movq	8(%r12), %rcx
	subq	(%r13), %rax
	xorps	%xmm1, %xmm1
	cvtsi2sd	%rax, %xmm1
	movsd	.LCPI5_1(%rip), %xmm2           # xmm2 = mem[0],zero
	mulsd	%xmm2, %xmm1
	subq	8(%r13), %rcx
	xorps	%xmm0, %xmm0
	cvtsi2sd	%rcx, %xmm0
	addsd	%xmm1, %xmm0
	divsd	%xmm2, %xmm0
	movl	$.L.str.2, %esi
	movb	$1, %al
	callq	fprintf
	movq	%rsp, %r12
	movl	$8405000, %esi                  # imm = 0x804008
	movq	%r12, %rdi
	callq	hipMalloc
	leaq	16(%rsp), %r13
	movl	$8405000, %esi                  # imm = 0x804008
	movq	%r13, %rdi
	callq	hipMalloc
	leaq	8(%rsp), %r14
	movl	$8200, %esi                     # imm = 0x2008
	movq	%r14, %rdi
	callq	hipMalloc
	movq	(%r12), %rdi
	movq	%r15, %r12
	movq	%rbx, %r15
	movl	$8405000, %edx                  # imm = 0x804008
	movq	%rbp, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	movq	(%r13), %rdi
	movabsq	$4294967297, %r13               # imm = 0x100000001
	movl	$8405000, %edx                  # imm = 0x804008
	movq	%r12, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	movq	(%r14), %rdi
	movabsq	$68719476752, %r14              # imm = 0x1000000010
	movl	$8200, %edx                     # imm = 0x2008
	movq	%rbx, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	movl	$.L.str.3, %edi
	movl	$1, %esi
	movl	$1, %edx
	movl	$16, %ecx
	movl	$16, %r8d
	xorl	%eax, %eax
	callq	printf
	leaq	24(%rsp), %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	movq	%r13, %rdi
	movl	$1, %esi
	movq	%r14, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB5_6
# %bb.5:
	movq	8(%rsp), %rdx
	movq	(%rsp), %rcx
	movl	$1024, %edi                     # imm = 0x400
	movl	$1024, %esi                     # imm = 0x400
	callq	_Z22__device_stub__kernel1iiPdS_
.LBB5_6:
	callq	hipDeviceSynchronize
	movq	%r13, %rdi
	movl	$1, %esi
	movq	%r14, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB5_8
# %bb.7:
	movq	8(%rsp), %rdx
	movq	(%rsp), %rcx
	movl	$1024, %edi                     # imm = 0x400
	movl	$1024, %esi                     # imm = 0x400
	callq	_Z22__device_stub__kernel2iiPdS_
.LBB5_8:
	callq	hipDeviceSynchronize
	movq	%r13, %rdi
	movl	$1, %esi
	movq	%r14, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB5_10
# %bb.9:
	movq	16(%rsp), %rdx
	movq	(%rsp), %rcx
	movl	$1024, %edi                     # imm = 0x400
	movl	$1024, %esi                     # imm = 0x400
	callq	_Z22__device_stub__kernel3iiPdS_
.LBB5_10:
	callq	hipDeviceSynchronize
	leaq	40(%rsp), %r14
	movq	%r14, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	movq	stdout(%rip), %rdi
	movq	(%r14), %rax
	subq	24(%rsp), %rax
	cvtsi2sd	%rax, %xmm1
	movq	8(%r14), %rax
	movsd	.LCPI5_1(%rip), %xmm2           # xmm2 = mem[0],zero
	mulsd	%xmm2, %xmm1
	subq	32(%rsp), %rax
	cvtsi2sd	%rax, %xmm0
	addsd	%xmm1, %xmm0
	divsd	%xmm2, %xmm0
	movl	$.L.str.4, %esi
	movb	$1, %al
	callq	fprintf
	callq	hipGetLastError
	movq	(%rsp), %rdi
	callq	hipFree
	movq	16(%rsp), %rdi
	callq	hipFree
	movq	8(%rsp), %rdi
	callq	hipFree
	movq	%rbp, %rdi
	callq	free
	movq	%r12, %rdi
	callq	free
	movq	%r15, %rdi
	callq	free
	callq	hipDeviceReset
	xorl	%eax, %eax
	addq	$1528, %rsp                     # imm = 0x5F8
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end5:
	.size	main, .Lfunc_end5-main
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$32, %rsp
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -16
	movq	__hip_gpubin_handle(%rip), %rbx
	testq	%rbx, %rbx
	jne	.LBB6_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB6_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z7kernel1iiPdS_, %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	$_Z7kernel2iiPdS_, %esi
	movl	$.L__unnamed_2, %edx
	movl	$.L__unnamed_2, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z7kernel3iiPdS_, %esi
	movl	$.L__unnamed_3, %edx
	movl	$.L__unnamed_3, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$__hip_module_dtor, %edi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_end6:
	.size	__hip_module_ctor, .Lfunc_end6-__hip_module_ctor
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_dtor
	.type	__hip_module_dtor,@function
__hip_module_dtor:                      # @__hip_module_dtor
	.cfi_startproc
# %bb.0:
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	je	.LBB7_2
# %bb.1:
	pushq	%rax
	.cfi_def_cfa_offset 16
	callq	__hipUnregisterFatBinary
	movq	$0, __hip_gpubin_handle(%rip)
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
.LBB7_2:
	retq
.Lfunc_end7:
	.size	__hip_module_dtor, .Lfunc_end7-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	_Z7kernel1iiPdS_,@object        # @_Z7kernel1iiPdS_
	.section	.rodata,"a",@progbits
	.globl	_Z7kernel1iiPdS_
	.p2align	3, 0x0
_Z7kernel1iiPdS_:
	.quad	_Z22__device_stub__kernel1iiPdS_
	.size	_Z7kernel1iiPdS_, 8

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

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

	.type	.L.str.1,@object                # @.str.1
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.1:
	.asciz	"Device properties %d: %s\n"
	.size	.L.str.1, 26

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"CPU Runtime: %0.6lfs\n"
	.size	.L.str.2, 22

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"<<< grid (%d,%d) block (%d,%d)>>>\n"
	.size	.L.str.3, 35

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"GPU Runtime: %0.6lfs\n"
	.size	.L.str.4, 22

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z7kernel1iiPdS_"
	.size	.L__unnamed_1, 17

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_Z7kernel2iiPdS_"
	.size	.L__unnamed_2, 17

	.type	.L__unnamed_3,@object           # @2
.L__unnamed_3:
	.asciz	"_Z7kernel3iiPdS_"
	.size	.L__unnamed_3, 17

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

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

	.type	.Lstr,@object                   # @str
	.section	.rodata.str1.1,"aMS",@progbits,1
.Lstr:
	.asciz	"covariance starting..."
	.size	.Lstr, 23

	.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 _Z22__device_stub__kernel1iiPdS_
	.addrsig_sym _Z22__device_stub__kernel2iiPdS_
	.addrsig_sym _Z22__device_stub__kernel3iiPdS_
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z7kernel1iiPdS_
	.addrsig_sym _Z7kernel2iiPdS_
	.addrsig_sym _Z7kernel3iiPdS_
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z7kernel1iiPdS_        ; -- Begin function _Z7kernel1iiPdS_
	.globl	_Z7kernel1iiPdS_
	.p2align	8
	.type	_Z7kernel1iiPdS_,@function
_Z7kernel1iiPdS_:                       ; @_Z7kernel1iiPdS_
; %bb.0:
	s_load_b32 s2, s[0:1], 0x24
	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_u32_e32 0x400, v1
	s_cbranch_execz .LBB0_4
; %bb.1:
	s_load_b128 s[0:3], s[0:1], 0x8
	v_dual_mov_b32 v7, 0 :: v_dual_mov_b32 v4, 0
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_dual_mov_b32 v5, 0 :: v_dual_mov_b32 v2, v7
	v_mov_b32_e32 v6, v7
	v_lshlrev_b64 v[2:3], 3, v[1:2]
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v2, vcc_lo, s0, v2
	v_add_co_ci_u32_e32 v3, vcc_lo, s1, v3, vcc_lo
	s_mov_b32 s0, 0
	global_store_b64 v[2:3], v[6:7], off
.LBB0_2:                                ; =>This Inner Loop Header: Depth=1
	v_add_nc_u32_e32 v6, s0, v1
	s_addk_i32 s0, 0x400
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	s_cmp_lg_u32 s0, 0x100000
	v_lshlrev_b64 v[8:9], 3, v[6:7]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v8, vcc_lo, s2, v8
	v_add_co_ci_u32_e32 v9, vcc_lo, s3, v9, vcc_lo
	global_load_b64 v[8:9], v[8:9], off
	s_waitcnt vmcnt(0)
	v_add_f64 v[4:5], v[8:9], v[4:5]
	global_store_b64 v[2:3], v[4:5], off
	s_cbranch_scc1 .LBB0_2
; %bb.3:
	s_mov_b32 s0, 0x147ae14
	s_mov_b32 s1, 0x414885c2
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_div_scale_f64 v[0:1], null, s[0:1], s[0:1], v[4:5]
	v_rcp_f64_e32 v[6:7], v[0:1]
	s_waitcnt_depctr 0xfff
	v_fma_f64 v[8:9], -v[0:1], v[6:7], 1.0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[6:7], v[6:7], v[8:9], v[6:7]
	v_fma_f64 v[8:9], -v[0:1], v[6:7], 1.0
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_fma_f64 v[6:7], v[6:7], v[8:9], v[6:7]
	v_div_scale_f64 v[8:9], vcc_lo, v[4:5], s[0:1], v[4:5]
	v_mul_f64 v[10:11], v[8:9], v[6:7]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[0:1], -v[0:1], v[10:11], v[8:9]
	v_div_fmas_f64 v[0:1], v[0:1], v[6:7], v[10:11]
	s_delay_alu instid0(VALU_DEP_1)
	v_div_fixup_f64 v[0:1], v[0:1], s[0:1], v[4:5]
	global_store_b64 v[2:3], v[0:1], off
.LBB0_4:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z7kernel1iiPdS_
		.amdhsa_group_segment_fixed_size 0
		.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 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	_Z7kernel1iiPdS_, .Lfunc_end0-_Z7kernel1iiPdS_
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 340
; 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: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.protected	_Z7kernel2iiPdS_        ; -- Begin function _Z7kernel2iiPdS_
	.globl	_Z7kernel2iiPdS_
	.p2align	8
	.type	_Z7kernel2iiPdS_,@function
_Z7kernel2iiPdS_:                       ; @_Z7kernel2iiPdS_
; %bb.0:
	s_load_b32 s2, s[0:1], 0x24
	v_and_b32_e32 v2, 0x3ff, v0
	v_bfe_u32 v4, v0, 10, 10
	s_waitcnt lgkmcnt(0)
	s_lshr_b32 s3, s2, 16
	s_and_b32 s2, s2, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[0:1], null, s14, s2, v[2:3]
	v_mad_u64_u32 v[2:3], null, s15, s3, v[4:5]
	s_mov_b32 s2, exec_lo
	v_or_b32_e32 v1, v2, v0
	s_delay_alu instid0(VALU_DEP_1)
	v_cmpx_gt_u32_e32 0x400, v1
	s_cbranch_execz .LBB1_2
; %bb.1:
	s_load_b128 s[0:3], s[0:1], 0x8
	v_mov_b32_e32 v3, 0
	v_lshl_add_u32 v2, v2, 10, v0
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_mov_b32_e32 v1, v3
	v_lshlrev_b64 v[2:3], 3, v[2:3]
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[0:1], 3, v[0:1]
	s_waitcnt lgkmcnt(0)
	v_add_co_u32 v0, vcc_lo, s0, v0
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_4)
	v_add_co_ci_u32_e32 v1, vcc_lo, s1, v1, vcc_lo
	v_add_co_u32 v2, vcc_lo, s2, v2
	v_add_co_ci_u32_e32 v3, vcc_lo, s3, v3, vcc_lo
	global_load_b64 v[0:1], v[0:1], off
	global_load_b64 v[4:5], v[2:3], off
	s_waitcnt vmcnt(0)
	v_add_f64 v[0:1], v[4:5], -v[0:1]
	global_store_b64 v[2:3], v[0:1], off
.LBB1_2:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z7kernel2iiPdS_
		.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 6
		.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	_Z7kernel2iiPdS_, .Lfunc_end1-_Z7kernel2iiPdS_
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 212
; NumSgprs: 18
; NumVgprs: 6
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 6
; 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	_Z7kernel3iiPdS_        ; -- Begin function _Z7kernel3iiPdS_
	.globl	_Z7kernel3iiPdS_
	.p2align	8
	.type	_Z7kernel3iiPdS_,@function
_Z7kernel3iiPdS_:                       ; @_Z7kernel3iiPdS_
; %bb.0:
	s_load_b32 s2, s[0:1], 0x24
	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_u32_e32 0x400, v1
	s_cbranch_execz .LBB2_5
; %bb.1:                                ; %.preheader
	s_load_b128 s[4:7], s[0:1], 0x8
	v_dual_mov_b32 v3, 0 :: v_dual_lshlrev_b32 v0, 10, v1
	v_mov_b32_e32 v12, v1
	s_mov_b32 s1, 0
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mov_b32_e32 v2, v3
	v_lshlrev_b64 v[4:5], 3, v[1:2]
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v4, vcc_lo, s6, v4
	v_add_co_ci_u32_e32 v5, vcc_lo, s7, v5, vcc_lo
.LBB2_2:                                ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB2_3 Depth 2
	v_add_nc_u32_e32 v2, v12, v0
	s_mov_b32 s0, 0
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_dual_mov_b32 v11, v5 :: v_dual_mov_b32 v10, v4
	v_lshlrev_b64 v[6:7], 3, v[2:3]
	v_mov_b32_e32 v2, v3
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_co_u32 v8, vcc_lo, s4, v6
	v_add_co_ci_u32_e32 v9, vcc_lo, s5, v7, vcc_lo
	v_mov_b32_e32 v6, 0
	v_mov_b32_e32 v7, 0
	global_store_b64 v[8:9], v[2:3], off
.LBB2_3:                                ;   Parent Loop BB2_2 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	v_add_nc_u32_e32 v2, s0, v1
	s_addk_i32 s0, 0x400
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	s_cmp_lg_u32 s0, 0x100000
	v_lshlrev_b64 v[13:14], 3, v[2:3]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v13, vcc_lo, s6, v13
	v_add_co_ci_u32_e32 v14, vcc_lo, s7, v14, vcc_lo
	global_load_b64 v[15:16], v[10:11], off
	global_load_b64 v[13:14], v[13:14], off
	v_add_co_u32 v10, vcc_lo, 0x2000, v10
	v_add_co_ci_u32_e32 v11, vcc_lo, 0, v11, vcc_lo
	s_waitcnt vmcnt(0)
	v_fma_f64 v[6:7], v[13:14], v[15:16], v[6:7]
	global_store_b64 v[8:9], v[6:7], off
	s_cbranch_scc1 .LBB2_3
; %bb.4:                                ;   in Loop: Header=BB2_2 Depth=1
	v_lshl_or_b32 v2, v12, 10, v1
	v_cmp_lt_i32_e32 vcc_lo, 0x3fe, v12
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[8:9], 3, v[2:3]
	v_add_nc_u32_e32 v2, 1, v12
	s_or_b32 s1, vcc_lo, s1
	v_mov_b32_e32 v12, v2
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_co_u32 v8, s0, s4, v8
	v_add_co_ci_u32_e64 v9, s0, s5, v9, s0
	v_add_co_u32 v4, s0, v4, 8
	s_delay_alu instid0(VALU_DEP_1)
	v_add_co_ci_u32_e64 v5, s0, 0, v5, s0
	global_store_b64 v[8:9], v[6:7], off
	s_and_not1_b32 exec_lo, exec_lo, s1
	s_cbranch_execnz .LBB2_2
.LBB2_5:                                ; %.loopexit
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z7kernel3iiPdS_
		.amdhsa_group_segment_fixed_size 0
		.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 17
		.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_end2:
	.size	_Z7kernel3iiPdS_, .Lfunc_end2-_Z7kernel3iiPdS_
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 380
; NumSgprs: 18
; NumVgprs: 17
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 2
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 17
; 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:
      - .offset:         0
        .size:           4
        .value_kind:     by_value
      - .offset:         4
        .size:           4
        .value_kind:     by_value
      - .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:           _Z7kernel1iiPdS_
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z7kernel1iiPdS_.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:
      - .offset:         0
        .size:           4
        .value_kind:     by_value
      - .offset:         4
        .size:           4
        .value_kind:     by_value
      - .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:           _Z7kernel2iiPdS_
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z7kernel2iiPdS_.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     6
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
  - .args:
      - .offset:         0
        .size:           4
        .value_kind:     by_value
      - .offset:         4
        .size:           4
        .value_kind:     by_value
      - .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:           _Z7kernel3iiPdS_
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z7kernel3iiPdS_.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     17
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
