//##########################################################//
//   Name: Kirtan Mali                                      //
//   Roll no: 18AG10016                                     //
//   Question 4: DotProduct using Reduction Kernel          //
//##########################################################//

#include <stdio.h>
#include <stdlib.h>

// Cuda Libraries
#include <cuda.h>
#include <cuda_runtime.h>

// Macro for error checking and debugging
#define CHECK(call) {                                                        \
    const cudaError_t error = call;                                          \
    if (error != cudaSuccess) {                                              \
        printf("Error: %s:%d, ", __FILE__, __LINE__);                        \
        printf("code: %d, reason: %s\n", error, cudaGetErrorString(error));  \
        exit(1);                                                             \
    }                                                                        \
}

typedef long long int lli;
#define MAX_VAL 100
// Works with Block Size 1024 for other blocksizes add if else in kernels
#define BLOCKSIZE 1024

// Function Prototypes
double *createvector(lli n, int isempty, int seed);
void printvector(double *vector, lli n);
double dotproduct_CPU(double *A, double *B, lli n);

// Reduction Kernels
__global__ void reducefinal(double *input, double *output, int n)
{
	unsigned int tid = threadIdx.x;

    extern __shared__ double tile[];

    int blockId = blockIdx.x;
    int i = blockId * (blockDim.x*2) + threadIdx.x;
    unsigned int blockSize = blockDim.x;

    if (i < n)
    {
        tile[tid] = input[i] + input[i+blockDim.x];
    }
    else
    {
        tile[tid] = 0.0f;
    }

    __syncthreads();


    if (tid < 512)
        tile[tid] += tile[tid + 512];
    __syncthreads();

    if (tid < 256)
        tile[tid] += tile[tid + 256];
    __syncthreads();

    if (tid < 128)
        tile[tid] += tile[tid + 128];
    __syncthreads();

    if (tid < 64)
        tile[tid] += tile[tid + 64];
    __syncthreads();

    if (tid < 32)
        tile[tid] += tile[tid + 32];
    __syncthreads();

    if (tid < 16)
        tile[tid] += tile[tid + 16];
    __syncthreads();

    if (tid < 8)
        tile[tid] += tile[tid + 8];
    __syncthreads();

    if (tid < 4)
        tile[tid] += tile[tid + 4];
    __syncthreads();

    if (tid < 2)
        tile[tid] += tile[tid + 2];
    __syncthreads();

    if (tid < 1)
    {
        tile[tid] += tile[tid + 1];
        output[blockId] = tile[tid];
    }
}

// DotProduct Kernel
__global__ void dotproduct(double *A, double *B, double *output, lli n)
{
    int tid = threadIdx.x;

    extern __shared__ double tile[];

    int blockId = blockIdx.x;
    int i = blockId * blockDim.x + threadIdx.x;

    if (i < n)
    {
        tile[tid] = A[i] * B[i];
    }
    else
    {
        tile[tid] = 0.0f;
    }

    __syncthreads();

    for (int s=blockDim.x/2; s>0; s>>=1)
    {
        if (tid < s)
        {
            tile[tid] += tile[tid + s];
        }
        __syncthreads();
    }

    if (tid == 0)
    {
        output[blockId] = tile[tid];
    }
}

double reduce_CPU(double *vector, lli n)
{
    double sum = 0;

    for (int i=0; i<n; i++)
    {
        sum += vector[i];
    }

    return sum;
}

int main(int argc, char **argv)
{
    cudaError_t err = cudaSuccess;
    lli t;

    int isprint = 1;
    if (argc > 1)
    {
        printf("\n\nDisabling Printing ...\n\n");
        isprint = 0;
    }

    scanf("%lld", &t);

    while(t--)
    {
        srand(t);
        lli n;

        scanf("%lld", &n);

        size_t size = sizeof(double) * n;

        double *h_A = createvector(n, 0, t);
        double *h_B = createvector(n, 0, rand() * t);

        double *d_A = NULL;
        CHECK(cudaMalloc((void **)&d_A, size));
        CHECK(cudaMemcpy(d_A, h_A, size, cudaMemcpyHostToDevice));


        double *d_B = NULL;
        CHECK(cudaMalloc((void **)&d_B, size));
        CHECK(cudaMemcpy(d_B, h_B, size, cudaMemcpyHostToDevice));

        double *h_dotproduct_output = createvector(n/BLOCKSIZE, 1, t);

        double *d_dotproduct_output = NULL;
        CHECK(cudaMalloc((void **)&d_dotproduct_output, size/BLOCKSIZE));

        dotproduct<<<n/BLOCKSIZE, BLOCKSIZE, BLOCKSIZE*sizeof(double)>>>(d_A, d_B, d_dotproduct_output, n);

        err = cudaGetLastError();

        if (err != cudaSuccess)
        {
            fprintf(stderr, "Failed to launch dotproduct kernel (error code %s)!\n", cudaGetErrorString(err));
            exit(EXIT_FAILURE);
        }

        double *d_input = NULL;
        CHECK(cudaMalloc((void **)&d_input, size/BLOCKSIZE));

        CHECK(cudaMemcpy(d_input, d_dotproduct_output, size/BLOCKSIZE, cudaMemcpyDeviceToDevice));

        double *d_final_output = NULL;
        CHECK(cudaMalloc((void **)&d_final_output, size/BLOCKSIZE));

        lli tempn = n/BLOCKSIZE;

        while (tempn > 1024)
        {
            reducefinal<<<tempn/BLOCKSIZE, BLOCKSIZE, BLOCKSIZE*sizeof(double)>>>(d_input, d_final_output, tempn);

            err = cudaGetLastError();

            if (err != cudaSuccess)
            {
                fprintf(stderr, "Failed to launch reducefinal kernel (error code %s)!\n", cudaGetErrorString(err));
                exit(EXIT_FAILURE);
            }

            tempn /= BLOCKSIZE;

            CHECK(cudaMemcpy(d_input, d_final_output, tempn*sizeof(double), cudaMemcpyDeviceToDevice));
        }

        double *h_final_output = (double *)malloc(sizeof(double) * tempn);

        CHECK(cudaMemcpy(h_final_output, d_input, tempn*sizeof(double), cudaMemcpyDeviceToHost));

        if (isprint == 0)
        {
            printf("\n\n***** Final Output of GPU Reduction Kernal *****\n\n");
            printvector(h_final_output, tempn);
        }

        double final_dotproduct = reduce_CPU(h_final_output, tempn);

        printf("\nDot Product => %0.2f", final_dotproduct);
        printf("Dot Product from CPU => %0.2f\n\n", dotproduct_CPU(h_A, h_B, n));
    }

    return 0;
}

// Utility Functions
double dotproduct_CPU(double *A, double *B, lli n)
{
    double dp = 0;

    for (lli i=0; i<n; i++)
    {
        dp += A[i] * B[i];
    }

    return dp;
}

void printvector(double *vector, lli n)
{
    for (lli i=0; i<n; i++)
    {
        printf("% 6.2f ", vector[i]);
    }
    printf("\n");
}

double *createvector(lli n, int isempty, int seed)
{
    srand(seed+1);
    double *vector = (double *)malloc(n * sizeof(double));

    for (lli i=0;i<n;i++)
    {
        if (isempty == 0)
        {
            vector[i] = (double)rand()/((double)RAND_MAX/MAX_VAL);
        }
        else
        {
            vector[i] = 0.0f;
        }
    }

    return vector;
}
	.file	"tmpxft_0037d72a_00000000-6_dotproduct_reduction.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2034:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2034:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z10reduce_CPUPdx
	.type	_Z10reduce_CPUPdx, @function
_Z10reduce_CPUPdx:
.LFB2027:
	.cfi_startproc
	endbr64
	xorl	%eax, %eax
	xorps	%xmm0, %xmm0
.L3:
	cmpq	%rax, %rsi
	jle	.L6
	addsd	(%rdi,%rax,8), %xmm0
	incq	%rax
	jmp	.L3
.L6:
	ret
	.cfi_endproc
.LFE2027:
	.size	_Z10reduce_CPUPdx, .-_Z10reduce_CPUPdx
	.globl	_Z14dotproduct_CPUPdS_x
	.type	_Z14dotproduct_CPUPdS_x, @function
_Z14dotproduct_CPUPdS_x:
.LFB2029:
	.cfi_startproc
	endbr64
	xorl	%eax, %eax
	xorps	%xmm0, %xmm0
.L8:
	cmpq	%rdx, %rax
	jge	.L10
	movsd	(%rdi,%rax,8), %xmm1
	mulsd	(%rsi,%rax,8), %xmm1
	incq	%rax
	addsd	%xmm1, %xmm0
	jmp	.L8
.L10:
	ret
	.cfi_endproc
.LFE2029:
	.size	_Z14dotproduct_CPUPdS_x, .-_Z14dotproduct_CPUPdS_x
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC1:
	.string	"% 6.2f "
.LC2:
	.string	"\n"
	.text
	.globl	_Z11printvectorPdx
	.type	_Z11printvectorPdx, @function
_Z11printvectorPdx:
.LFB2030:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leaq	.LC1(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	movq	%rdi, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	movq	%rsi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	xorl	%ebx, %ebx
	pushq	%rcx
	.cfi_def_cfa_offset 48
.L12:
	cmpq	%rbp, %rbx
	jge	.L15
	movsd	(%r12,%rbx,8), %xmm0
	movq	%r13, %rsi
	movl	$2, %edi
	movb	$1, %al
	incq	%rbx
	call	__printf_chk@PLT
	jmp	.L12
.L15:
	popq	%rdx
	.cfi_def_cfa_offset 40
	leaq	.LC2(%rip), %rsi
	popq	%rbx
	.cfi_def_cfa_offset 32
	movl	$2, %edi
	popq	%rbp
	.cfi_def_cfa_offset 24
	xorl	%eax, %eax
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	jmp	__printf_chk@PLT
	.cfi_endproc
.LFE2030:
	.size	_Z11printvectorPdx, .-_Z11printvectorPdx
	.globl	_Z12createvectorxii
	.type	_Z12createvectorxii, @function
_Z12createvectorxii:
.LFB2031:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	movl	%esi, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	xorl	%r12d, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	movq	%rdi, %rbp
	leal	1(%rdx), %edi
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	pushq	%rcx
	.cfi_def_cfa_offset 48
	call	srand@PLT
	leaq	0(,%rbp,8), %rdi
	call	malloc@PLT
	movq	%rax, %rbx
.L17:
	cmpq	%rbp, %r12
	jge	.L22
	xorps	%xmm0, %xmm0
	testl	%r13d, %r13d
	jne	.L18
	call	rand@PLT
	cvtsi2sdl	%eax, %xmm0
	divsd	.LC3(%rip), %xmm0
.L18:
	movsd	%xmm0, (%rbx,%r12,8)
	incq	%r12
	jmp	.L17
.L22:
	popq	%rdx
	.cfi_def_cfa_offset 40
	movq	%rbx, %rax
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2031:
	.size	_Z12createvectorxii, .-_Z12createvectorxii
	.globl	_Z34__device_stub__Z11reducefinalPdS_iPdS_i
	.type	_Z34__device_stub__Z11reducefinalPdS_iPdS_i, @function
_Z34__device_stub__Z11reducefinalPdS_iPdS_i:
.LFB2056:
	.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
	movl	%edx, 12(%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	12(%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	.L23
	pushq	40(%rsp)
	.cfi_def_cfa_offset 152
	leaq	_Z11reducefinalPdS_i(%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
.L23:
	movq	120(%rsp), %rax
	subq	%fs:40, %rax
	je	.L25
	call	__stack_chk_fail@PLT
.L25:
	addq	$136, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2056:
	.size	_Z34__device_stub__Z11reducefinalPdS_iPdS_i, .-_Z34__device_stub__Z11reducefinalPdS_iPdS_i
	.globl	_Z11reducefinalPdS_i
	.type	_Z11reducefinalPdS_i, @function
_Z11reducefinalPdS_i:
.LFB2057:
	.cfi_startproc
	endbr64
	jmp	_Z34__device_stub__Z11reducefinalPdS_iPdS_i
	.cfi_endproc
.LFE2057:
	.size	_Z11reducefinalPdS_i, .-_Z11reducefinalPdS_i
	.globl	_Z35__device_stub__Z10dotproductPdS_S_xPdS_S_x
	.type	_Z35__device_stub__Z10dotproductPdS_S_xPdS_S_x, @function
_Z35__device_stub__Z10dotproductPdS_S_xPdS_S_x:
.LFB2058:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movq	%rdi, 24(%rsp)
	leaq	56(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	68(%rsp), %rsi
	movq	%rdx, 8(%rsp)
	leaq	40(%rsp), %rdx
	movq	%rcx, (%rsp)
	leaq	48(%rsp), %rcx
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 64(%rsp)
	movq	%rax, 104(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 120(%rsp)
	movq	%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	.L28
	pushq	48(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z10dotproductPdS_S_x(%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
.L28:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L30
	call	__stack_chk_fail@PLT
.L30:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2058:
	.size	_Z35__device_stub__Z10dotproductPdS_S_xPdS_S_x, .-_Z35__device_stub__Z10dotproductPdS_S_xPdS_S_x
	.globl	_Z10dotproductPdS_S_x
	.type	_Z10dotproductPdS_S_x, @function
_Z10dotproductPdS_S_x:
.LFB2059:
	.cfi_startproc
	endbr64
	jmp	_Z35__device_stub__Z10dotproductPdS_S_xPdS_S_x
	.cfi_endproc
.LFE2059:
	.size	_Z10dotproductPdS_S_x, .-_Z10dotproductPdS_S_x
	.section	.rodata.str1.1
.LC4:
	.string	"\n\nDisabling Printing ...\n\n"
.LC5:
	.string	"%lld"
.LC6:
	.string	"/home/ubuntu/Datasets/stackv2/train-structured/KaLiMaLi555/hp3/master/term_assignments/dotproduct_reduction.cu"
.LC7:
	.string	"Error: %s:%d, "
.LC8:
	.string	"code: %d, reason: %s\n"
.LC9:
	.string	"Failed to launch dotproduct kernel (error code %s)!\n"
.LC10:
	.string	"Failed to launch reducefinal kernel (error code %s)!\n"
.LC11:
	.string	"\n\n***** Final Output of GPU Reduction Kernal *****\n\n"
.LC12:
	.string	"\nDot Product => %0.2f"
.LC13:
	.string	"Dot Product from CPU => %0.2f\n\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2028:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	$1, %r15d
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$120, %rsp
	.cfi_def_cfa_offset 176
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	decl	%edi
	jle	.L34
	leaq	.LC4(%rip), %rsi
	movl	$2, %edi
	xorl	%r15d, %r15d
	call	__printf_chk@PLT
.L34:
	leaq	24(%rsp), %rsi
	xorl	%eax, %eax
	leaq	.LC5(%rip), %rdi
	movabsq	$4294968320, %r13
	call	__isoc23_scanf@PLT
.L35:
	movq	24(%rsp), %rax
	leaq	-1(%rax), %rdi
	movq	%rdi, 24(%rsp)
	testq	%rax, %rax
	je	.L63
	call	srand@PLT
	leaq	32(%rsp), %rsi
	leaq	.LC5(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc23_scanf@PLT
	movq	32(%rsp), %rdi
	movl	24(%rsp), %edx
	xorl	%esi, %esi
	leaq	0(,%rdi,8), %rbx
	call	_Z12createvectorxii
	movq	%rax, 8(%rsp)
	call	rand@PLT
	imull	24(%rsp), %eax
	movq	32(%rsp), %rdi
	xorl	%esi, %esi
	movl	%eax, %edx
	call	_Z12createvectorxii
	xorl	%edi, %edi
	movq	%rbx, %rsi
	movq	%rdi, 40(%rsp)
	leaq	40(%rsp), %rdi
	movq	%rax, %r14
	call	cudaMalloc@PLT
	movl	%eax, %ebp
	testl	%eax, %eax
	je	.L36
	movl	$175, %ecx
	jmp	.L58
.L36:
	movq	8(%rsp), %rsi
	movq	40(%rsp), %rdi
	movl	$1, %ecx
	movq	%rbx, %rdx
	call	cudaMemcpy@PLT
	movl	%eax, %ebp
	testl	%eax, %eax
	je	.L37
	movl	$176, %ecx
.L58:
	leaq	.LC6(%rip), %rdx
	leaq	.LC7(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	%ebp, %edi
	call	cudaGetErrorString@PLT
	movl	%ebp, %edx
	movq	%rax, %rcx
.L59:
	leaq	.LC8(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L60:
	movl	$1, %edi
	call	exit@PLT
.L37:
	xorl	%esi, %esi
	leaq	48(%rsp), %rdi
	movq	%rsi, 48(%rsp)
	movq	%rbx, %rsi
	call	cudaMalloc@PLT
	movl	%eax, %ebp
	testl	%eax, %eax
	je	.L38
	movl	$180, %ecx
	jmp	.L58
.L38:
	movq	48(%rsp), %rdi
	movl	$1, %ecx
	movq	%rbx, %rdx
	movq	%r14, %rsi
	call	cudaMemcpy@PLT
	movl	%eax, %ebp
	testl	%eax, %eax
	je	.L39
	movl	$181, %ecx
	jmp	.L58
.L39:
	movq	32(%rsp), %rax
	movl	$1024, %r12d
	shrq	$10, %rbx
	movl	$1, %esi
	movq	%rbx, %rbp
	cqto
	idivq	%r12
	movl	24(%rsp), %edx
	movq	%rax, %rdi
	call	_Z12createvectorxii
	xorl	%ecx, %ecx
	movq	%rbx, %rsi
	leaq	56(%rsp), %rdi
	movq	%rcx, 56(%rsp)
	call	cudaMalloc@PLT
	movl	%eax, %ebx
	testl	%eax, %eax
	je	.L40
	movl	$186, %ecx
	jmp	.L61
.L40:
	movq	32(%rsp), %rax
	xorl	%r9d, %r9d
	movl	$8192, %r8d
	movl	$1, %ecx
	movq	%r13, 92(%rsp)
	cqto
	movl	$1, 100(%rsp)
	idivq	%r12
	movq	%r13, %rdx
	movl	%eax, 80(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 84(%rsp)
	movq	80(%rsp), %rdi
	movl	88(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L41
	movq	32(%rsp), %rcx
	movq	56(%rsp), %rdx
	movq	48(%rsp), %rsi
	movq	40(%rsp), %rdi
	call	_Z35__device_stub__Z10dotproductPdS_S_xPdS_S_x
.L41:
	call	cudaGetLastError@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L42
	call	cudaGetErrorString@PLT
	leaq	.LC9(%rip), %rdx
	movq	%rax, %rcx
	jmp	.L62
.L42:
	xorl	%edx, %edx
	leaq	64(%rsp), %rdi
	movq	%rbp, %rsi
	movq	%rdx, 64(%rsp)
	call	cudaMalloc@PLT
	movl	%eax, %ebx
	testl	%eax, %eax
	je	.L43
	movl	$199, %ecx
	jmp	.L61
.L43:
	movq	56(%rsp), %rsi
	movq	64(%rsp), %rdi
	movl	$3, %ecx
	movq	%rbp, %rdx
	call	cudaMemcpy@PLT
	movl	%eax, %ebx
	testl	%eax, %eax
	je	.L44
	movl	$201, %ecx
	jmp	.L61
.L44:
	xorl	%eax, %eax
	leaq	72(%rsp), %rdi
	movq	%rbp, %rsi
	movq	%rax, 72(%rsp)
	call	cudaMalloc@PLT
	movl	%eax, %ebx
	testl	%eax, %eax
	je	.L45
	movl	$204, %ecx
	jmp	.L61
.L45:
	movq	32(%rsp), %rax
	movl	$1024, %ecx
	cqto
	idivq	%rcx
	movq	%rax, %rbx
	jmp	.L46
.L55:
	movq	%rbp, %rbx
.L46:
	cmpq	$1024, %rbx
	jle	.L64
	movq	%rbx, %rbp
	xorl	%r9d, %r9d
	movl	$8192, %r8d
	movq	%r13, %rdx
	sarq	$10, %rbp
	movl	$1, %ecx
	movabsq	$4294967297, %rax
	movq	%r13, 92(%rsp)
	movq	%rax, 84(%rsp)
	movl	88(%rsp), %esi
	movl	%ebp, 80(%rsp)
	movq	80(%rsp), %rdi
	movl	$1, 100(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L47
	movq	72(%rsp), %rsi
	movq	64(%rsp), %rdi
	movl	%ebx, %edx
	call	_Z34__device_stub__Z11reducefinalPdS_iPdS_i
.L47:
	call	cudaGetLastError@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L48
	call	cudaGetErrorString@PLT
	leaq	.LC10(%rip), %rdx
	movq	%rax, %rcx
.L62:
	movq	stderr(%rip), %rdi
	movl	$2, %esi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	jmp	.L60
.L48:
	movq	72(%rsp), %rsi
	movq	64(%rsp), %rdi
	movl	$3, %ecx
	leaq	0(,%rbp,8), %rdx
	call	cudaMemcpy@PLT
	movl	%eax, %ebx
	testl	%eax, %eax
	je	.L55
	movl	$222, %ecx
.L61:
	leaq	.LC6(%rip), %rdx
	leaq	.LC7(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	%ebx, %edi
	call	cudaGetErrorString@PLT
	movl	%ebx, %edx
	movq	%rax, %rcx
	jmp	.L59
.L64:
	leaq	0(,%rbx,8), %r12
	movq	%r12, %rdi
	call	malloc@PLT
	movq	64(%rsp), %rsi
	movq	%r12, %rdx
	movl	$2, %ecx
	movq	%rax, %rdi
	movq	%rax, %rbp
	call	cudaMemcpy@PLT
	movl	%eax, %r12d
	testl	%eax, %eax
	je	.L50
	movl	$227, %ecx
	leaq	.LC6(%rip), %rdx
	leaq	.LC7(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
	movl	%r12d, %edi
	call	cudaGetErrorString@PLT
	movl	%r12d, %edx
	movq	%rax, %rcx
	jmp	.L59
.L50:
	testl	%r15d, %r15d
	jne	.L51
	leaq	.LC11(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	%rbx, %rsi
	movq	%rbp, %rdi
	call	_Z11printvectorPdx
.L51:
	movq	%rbx, %rsi
	movq	%rbp, %rdi
	call	_Z10reduce_CPUPdx
	leaq	.LC12(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	call	__printf_chk@PLT
	movq	8(%rsp), %rdi
	movq	32(%rsp), %rdx
	movq	%r14, %rsi
	call	_Z14dotproduct_CPUPdS_x
	leaq	.LC13(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	call	__printf_chk@PLT
	jmp	.L35
.L63:
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	je	.L53
	call	__stack_chk_fail@PLT
.L53:
	addq	$120, %rsp
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2028:
	.size	main, .-main
	.section	.rodata.str1.1
.LC14:
	.string	"_Z10dotproductPdS_S_x"
.LC15:
	.string	"_Z11reducefinalPdS_i"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2061:
	.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	.LC14(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z10dotproductPdS_S_x(%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	.LC15(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z11reducefinalPdS_i(%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
.LFE2061:
	.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
.LC3:
	.long	1199906488
	.long	1098152673
	.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:

//##########################################################//
//   Name: Kirtan Mali                                      //
//   Roll no: 18AG10016                                     //
//   Question 4: DotProduct using Reduction Kernel          //
//##########################################################//

#include <stdio.h>
#include <stdlib.h>

// Cuda Libraries
#include <hip/hip_runtime.h>


// Macro for error checking and debugging
#define CHECK(call) {                                                        \
    const hipError_t error = call;                                          \
    if (error != hipSuccess) {                                              \
        printf("Error: %s:%d, ", __FILE__, __LINE__);                        \
        printf("code: %d, reason: %s\n", error, hipGetErrorString(error));  \
        exit(1);                                                             \
    }                                                                        \
}

typedef long long int lli;
#define MAX_VAL 100
// Works with Block Size 1024 for other blocksizes add if else in kernels
#define BLOCKSIZE 1024

// Function Prototypes
double *createvector(lli n, int isempty, int seed);
void printvector(double *vector, lli n);
double dotproduct_CPU(double *A, double *B, lli n);

// Reduction Kernels
__global__ void reducefinal(double *input, double *output, int n)
{
	unsigned int tid = threadIdx.x;

    extern __shared__ double tile[];

    int blockId = blockIdx.x;
    int i = blockId * (blockDim.x*2) + threadIdx.x;
    unsigned int blockSize = blockDim.x;

    if (i < n)
    {
        tile[tid] = input[i] + input[i+blockDim.x];
    }
    else
    {
        tile[tid] = 0.0f;
    }

    __syncthreads();


    if (tid < 512)
        tile[tid] += tile[tid + 512];
    __syncthreads();

    if (tid < 256)
        tile[tid] += tile[tid + 256];
    __syncthreads();

    if (tid < 128)
        tile[tid] += tile[tid + 128];
    __syncthreads();

    if (tid < 64)
        tile[tid] += tile[tid + 64];
    __syncthreads();

    if (tid < 32)
        tile[tid] += tile[tid + 32];
    __syncthreads();

    if (tid < 16)
        tile[tid] += tile[tid + 16];
    __syncthreads();

    if (tid < 8)
        tile[tid] += tile[tid + 8];
    __syncthreads();

    if (tid < 4)
        tile[tid] += tile[tid + 4];
    __syncthreads();

    if (tid < 2)
        tile[tid] += tile[tid + 2];
    __syncthreads();

    if (tid < 1)
    {
        tile[tid] += tile[tid + 1];
        output[blockId] = tile[tid];
    }
}

// DotProduct Kernel
__global__ void dotproduct(double *A, double *B, double *output, lli n)
{
    int tid = threadIdx.x;

    extern __shared__ double tile[];

    int blockId = blockIdx.x;
    int i = blockId * blockDim.x + threadIdx.x;

    if (i < n)
    {
        tile[tid] = A[i] * B[i];
    }
    else
    {
        tile[tid] = 0.0f;
    }

    __syncthreads();

    for (int s=blockDim.x/2; s>0; s>>=1)
    {
        if (tid < s)
        {
            tile[tid] += tile[tid + s];
        }
        __syncthreads();
    }

    if (tid == 0)
    {
        output[blockId] = tile[tid];
    }
}

double reduce_CPU(double *vector, lli n)
{
    double sum = 0;

    for (int i=0; i<n; i++)
    {
        sum += vector[i];
    }

    return sum;
}

int main(int argc, char **argv)
{
    hipError_t err = hipSuccess;
    lli t;

    int isprint = 1;
    if (argc > 1)
    {
        printf("\n\nDisabling Printing ...\n\n");
        isprint = 0;
    }

    scanf("%lld", &t);

    while(t--)
    {
        srand(t);
        lli n;

        scanf("%lld", &n);

        size_t size = sizeof(double) * n;

        double *h_A = createvector(n, 0, t);
        double *h_B = createvector(n, 0, rand() * t);

        double *d_A = NULL;
        CHECK(hipMalloc((void **)&d_A, size));
        CHECK(hipMemcpy(d_A, h_A, size, hipMemcpyHostToDevice));


        double *d_B = NULL;
        CHECK(hipMalloc((void **)&d_B, size));
        CHECK(hipMemcpy(d_B, h_B, size, hipMemcpyHostToDevice));

        double *h_dotproduct_output = createvector(n/BLOCKSIZE, 1, t);

        double *d_dotproduct_output = NULL;
        CHECK(hipMalloc((void **)&d_dotproduct_output, size/BLOCKSIZE));

        dotproduct<<<n/BLOCKSIZE, BLOCKSIZE, BLOCKSIZE*sizeof(double)>>>(d_A, d_B, d_dotproduct_output, n);

        err = hipGetLastError();

        if (err != hipSuccess)
        {
            fprintf(stderr, "Failed to launch dotproduct kernel (error code %s)!\n", hipGetErrorString(err));
            exit(EXIT_FAILURE);
        }

        double *d_input = NULL;
        CHECK(hipMalloc((void **)&d_input, size/BLOCKSIZE));

        CHECK(hipMemcpy(d_input, d_dotproduct_output, size/BLOCKSIZE, hipMemcpyDeviceToDevice));

        double *d_final_output = NULL;
        CHECK(hipMalloc((void **)&d_final_output, size/BLOCKSIZE));

        lli tempn = n/BLOCKSIZE;

        while (tempn > 1024)
        {
            reducefinal<<<tempn/BLOCKSIZE, BLOCKSIZE, BLOCKSIZE*sizeof(double)>>>(d_input, d_final_output, tempn);

            err = hipGetLastError();

            if (err != hipSuccess)
            {
                fprintf(stderr, "Failed to launch reducefinal kernel (error code %s)!\n", hipGetErrorString(err));
                exit(EXIT_FAILURE);
            }

            tempn /= BLOCKSIZE;

            CHECK(hipMemcpy(d_input, d_final_output, tempn*sizeof(double), hipMemcpyDeviceToDevice));
        }

        double *h_final_output = (double *)malloc(sizeof(double) * tempn);

        CHECK(hipMemcpy(h_final_output, d_input, tempn*sizeof(double), hipMemcpyDeviceToHost));

        if (isprint == 0)
        {
            printf("\n\n***** Final Output of GPU Reduction Kernal *****\n\n");
            printvector(h_final_output, tempn);
        }

        double final_dotproduct = reduce_CPU(h_final_output, tempn);

        printf("\nDot Product => %0.2f", final_dotproduct);
        printf("Dot Product from CPU => %0.2f\n\n", dotproduct_CPU(h_A, h_B, n));
    }

    return 0;
}

// Utility Functions
double dotproduct_CPU(double *A, double *B, lli n)
{
    double dp = 0;

    for (lli i=0; i<n; i++)
    {
        dp += A[i] * B[i];
    }

    return dp;
}

void printvector(double *vector, lli n)
{
    for (lli i=0; i<n; i++)
    {
        printf("% 6.2f ", vector[i]);
    }
    printf("\n");
}

double *createvector(lli n, int isempty, int seed)
{
    srand(seed+1);
    double *vector = (double *)malloc(n * sizeof(double));

    for (lli i=0;i<n;i++)
    {
        if (isempty == 0)
        {
            vector[i] = (double)rand()/((double)RAND_MAX/MAX_VAL);
        }
        else
        {
            vector[i] = 0.0f;
        }
    }

    return vector;
}
	.text
	.file	"dotproduct_reduction.hip"
	.globl	_Z26__device_stub__reducefinalPdS_i # -- Begin function _Z26__device_stub__reducefinalPdS_i
	.type	_Z26__device_stub__reducefinalPdS_i,@function
_Z26__device_stub__reducefinalPdS_i:    # @_Z26__device_stub__reducefinalPdS_i
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	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	12(%rsp), %rsi
	movl	%edx, (%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	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	$_Z11reducefinalPdS_i, %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_end0:
	.size	_Z26__device_stub__reducefinalPdS_i, .Lfunc_end0-_Z26__device_stub__reducefinalPdS_i
	.cfi_endproc
                                        # -- End function
	.globl	_Z25__device_stub__dotproductPdS_S_x # -- Begin function _Z25__device_stub__dotproductPdS_S_x
	.type	_Z25__device_stub__dotproductPdS_S_x,@function
_Z25__device_stub__dotproductPdS_S_x:   # @_Z25__device_stub__dotproductPdS_S_x
	.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), %rdi
	movq	%rsi, (%rdi)
	leaq	24(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	16(%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	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	$_Z10dotproductPdS_S_x, %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	_Z25__device_stub__dotproductPdS_S_x, .Lfunc_end1-_Z25__device_stub__dotproductPdS_S_x
	.cfi_endproc
                                        # -- End function
	.globl	_Z10reduce_CPUPdx               # -- Begin function _Z10reduce_CPUPdx
	.type	_Z10reduce_CPUPdx,@function
_Z10reduce_CPUPdx:                      # @_Z10reduce_CPUPdx
	.cfi_startproc
# %bb.0:
	xorpd	%xmm0, %xmm0
	testq	%rsi, %rsi
	jle	.LBB2_3
# %bb.1:                                # %.lr.ph.preheader
	xorl	%eax, %eax
.LBB2_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	addsd	(%rdi,%rax,8), %xmm0
	incq	%rax
	cmpq	%rax, %rsi
	jne	.LBB2_2
.LBB2_3:                                # %._crit_edge
	retq
.Lfunc_end2:
	.size	_Z10reduce_CPUPdx, .Lfunc_end2-_Z10reduce_CPUPdx
	.cfi_endproc
                                        # -- End function
	.globl	main                            # -- Begin function 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	$72, %rsp
	.cfi_def_cfa_offset 128
	.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	%edi, 68(%rsp)                  # 4-byte Spill
	cmpl	$2, %edi
	jl	.LBB3_2
# %bb.1:
	movl	$.Lstr, %edi
	callq	puts@PLT
.LBB3_2:
	leaq	24(%rsp), %rbx
	movl	$.L.str.1, %edi
	movq	%rbx, %rsi
	xorl	%eax, %eax
	callq	__isoc23_scanf
	movq	(%rbx), %rdi
	subq	$1, %rdi
	movq	%rdi, (%rbx)
	jb	.LBB3_31
# %bb.3:                                # %.lr.ph.preheader
	movabsq	$4294967296, %rax               # imm = 0x100000000
	leaq	1024(%rax), %rbp
.LBB3_4:                                # %.lr.ph
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB3_16 Depth 2
                                        #     Child Loop BB3_26 Depth 2
                                        #     Child Loop BB3_29 Depth 2
                                        # kill: def $edi killed $edi killed $rdi
	callq	srand
	movl	$.L.str.1, %edi
	leaq	8(%rsp), %rsi
	xorl	%eax, %eax
	callq	__isoc23_scanf
	movq	8(%rsp), %rdi
	leaq	(,%rdi,8), %r14
	movl	24(%rsp), %edx
	xorl	%esi, %esi
	callq	_Z12createvectorxii
	movq	%rax, %r12
	movq	8(%rsp), %rbx
	callq	rand
	imull	24(%rsp), %eax
	movq	%rbx, %rdi
	xorl	%esi, %esi
	movl	%eax, %edx
	callq	_Z12createvectorxii
	movq	%rax, %r13
	movq	$0, 56(%rsp)
	leaq	56(%rsp), %rdi
	movq	%r14, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB3_46
# %bb.5:                                #   in Loop: Header=BB3_4 Depth=1
	movq	56(%rsp), %rdi
	movq	%r12, %rsi
	movq	%r14, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB3_45
# %bb.6:                                #   in Loop: Header=BB3_4 Depth=1
	movq	$0, 48(%rsp)
	leaq	48(%rsp), %rdi
	movq	%r14, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB3_44
# %bb.7:                                #   in Loop: Header=BB3_4 Depth=1
	movq	48(%rsp), %rdi
	movq	%r13, %rsi
	movq	%r14, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB3_43
# %bb.8:                                #   in Loop: Header=BB3_4 Depth=1
	movq	8(%rsp), %rax
	leaq	1023(%rax), %rdi
	testq	%rax, %rax
	cmovnsq	%rax, %rdi
	sarq	$10, %rdi
	movl	24(%rsp), %edx
	movl	$1, %esi
	callq	_Z12createvectorxii
	movq	$0, 40(%rsp)
	shrq	$10, %r14
	leaq	40(%rsp), %rdi
	movq	%r14, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB3_42
# %bb.9:                                #   in Loop: Header=BB3_4 Depth=1
	movq	8(%rsp), %rax
	leaq	1023(%rax), %rcx
	testq	%rax, %rax
	cmovnsq	%rax, %rcx
	shrq	$10, %rcx
	movl	%ecx, %edi
	movabsq	$4294967296, %rax               # imm = 0x100000000
	orq	%rax, %rdi
	movl	$8192, %r8d                     # imm = 0x2000
	movl	$1, %esi
	movq	%rbp, %rdx
	movl	$1, %ecx
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB3_11
# %bb.10:                               #   in Loop: Header=BB3_4 Depth=1
	movq	56(%rsp), %rdi
	movq	48(%rsp), %rsi
	movq	40(%rsp), %rdx
	movq	8(%rsp), %rcx
	callq	_Z25__device_stub__dotproductPdS_S_x
.LBB3_11:                               #   in Loop: Header=BB3_4 Depth=1
	callq	hipGetLastError
	testl	%eax, %eax
	jne	.LBB3_41
# %bb.12:                               #   in Loop: Header=BB3_4 Depth=1
	movq	$0, 16(%rsp)
	leaq	16(%rsp), %rdi
	movq	%r14, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB3_40
# %bb.13:                               #   in Loop: Header=BB3_4 Depth=1
	movq	16(%rsp), %rdi
	movq	40(%rsp), %rsi
	movq	%r14, %rdx
	movl	$3, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB3_39
# %bb.14:                               #   in Loop: Header=BB3_4 Depth=1
	movq	$0, 32(%rsp)
	leaq	32(%rsp), %rdi
	movq	%r14, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB3_38
# %bb.15:                               #   in Loop: Header=BB3_4 Depth=1
	movq	8(%rsp), %rax
	leaq	1023(%rax), %r14
	testq	%rax, %rax
	cmovnsq	%rax, %r14
	sarq	$10, %r14
.LBB3_16:                               #   Parent Loop BB3_4 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	cmpq	$1025, %r14                     # imm = 0x401
	jl	.LBB3_21
# %bb.17:                               #   in Loop: Header=BB3_16 Depth=2
	movq	%r14, %rbx
	shrq	$10, %rbx
	movl	%ebx, %edi
	movabsq	$4294967296, %rax               # imm = 0x100000000
	orq	%rax, %rdi
	movl	$8192, %r8d                     # imm = 0x2000
	movl	$1, %esi
	movq	%rbp, %rdx
	movl	$1, %ecx
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB3_19
# %bb.18:                               #   in Loop: Header=BB3_16 Depth=2
	movq	16(%rsp), %rdi
	movq	32(%rsp), %rsi
	movl	%r14d, %edx
	callq	_Z26__device_stub__reducefinalPdS_i
.LBB3_19:                               #   in Loop: Header=BB3_16 Depth=2
	callq	hipGetLastError
	testl	%eax, %eax
	jne	.LBB3_32
# %bb.20:                               #   in Loop: Header=BB3_16 Depth=2
	movq	16(%rsp), %rdi
	movq	32(%rsp), %rsi
	leaq	(,%rbx,8), %rdx
	movl	$3, %ecx
	callq	hipMemcpy
	movq	%rbx, %r14
	testl	%eax, %eax
	je	.LBB3_16
	jmp	.LBB3_34
.LBB3_21:                               #   in Loop: Header=BB3_4 Depth=1
	leaq	(,%r14,8), %rbx
	movq	%rbx, %rdi
	callq	malloc
	movq	%rax, %r15
	movq	16(%rsp), %rsi
	movq	%rax, %rdi
	movq	%rbx, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB3_47
# %bb.22:                               #   in Loop: Header=BB3_4 Depth=1
	cmpl	$2, 68(%rsp)                    # 4-byte Folded Reload
	jl	.LBB3_24
# %bb.23:                               #   in Loop: Header=BB3_4 Depth=1
	movl	$.Lstr.1, %edi
	callq	puts@PLT
	movq	%r15, %rdi
	movq	%r14, %rsi
	callq	_Z11printvectorPdx
.LBB3_24:                               #   in Loop: Header=BB3_4 Depth=1
	xorpd	%xmm0, %xmm0
	testq	%r14, %r14
	jle	.LBB3_27
# %bb.25:                               # %.lr.ph.i.preheader
                                        #   in Loop: Header=BB3_4 Depth=1
	xorl	%eax, %eax
.LBB3_26:                               # %.lr.ph.i
                                        #   Parent Loop BB3_4 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	addsd	(%r15,%rax,8), %xmm0
	incq	%rax
	cmpq	%rax, %r14
	jne	.LBB3_26
.LBB3_27:                               # %_Z10reduce_CPUPdx.exit
                                        #   in Loop: Header=BB3_4 Depth=1
	movl	$.L.str.8, %edi
	movb	$1, %al
	callq	printf
	movq	8(%rsp), %rax
	testq	%rax, %rax
	xorpd	%xmm0, %xmm0
	jle	.LBB3_30
# %bb.28:                               # %.lr.ph.i94.preheader
                                        #   in Loop: Header=BB3_4 Depth=1
	xorl	%ecx, %ecx
.LBB3_29:                               # %.lr.ph.i94
                                        #   Parent Loop BB3_4 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movsd	(%r12,%rcx,8), %xmm1            # xmm1 = mem[0],zero
	mulsd	(%r13,%rcx,8), %xmm1
	addsd	%xmm1, %xmm0
	incq	%rcx
	cmpq	%rcx, %rax
	jne	.LBB3_29
.LBB3_30:                               # %_Z14dotproduct_CPUPdS_x.exit
                                        #   in Loop: Header=BB3_4 Depth=1
	movl	$.L.str.9, %edi
	movb	$1, %al
	callq	printf
	movq	24(%rsp), %rdi
	subq	$1, %rdi
	movq	%rdi, 24(%rsp)
	jae	.LBB3_4
.LBB3_31:                               # %._crit_edge
	xorl	%eax, %eax
	addq	$72, %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
.LBB3_32:
	.cfi_def_cfa_offset 128
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.6, %esi
.LBB3_33:
	movq	%rbx, %rdi
	movq	%rax, %rdx
	xorl	%eax, %eax
	callq	fprintf
	jmp	.LBB3_37
.LBB3_34:
	movl	%eax, %r15d
	movl	$.L.str.2, %edi
	movl	$.L.str.3, %esi
	movl	$222, %edx
.LBB3_35:
	xorl	%eax, %eax
	callq	printf
	movl	%r15d, %edi
	callq	hipGetErrorString
	movl	$.L.str.4, %edi
	movl	%r15d, %esi
.LBB3_36:
	movq	%rax, %rdx
	xorl	%eax, %eax
	callq	printf
.LBB3_37:
	movl	$1, %edi
	callq	exit
.LBB3_38:
	movl	%eax, %r14d
	movl	$.L.str.2, %edi
	movl	$.L.str.3, %esi
	movl	$204, %edx
	xorl	%eax, %eax
	callq	printf
	movl	%r14d, %edi
	callq	hipGetErrorString
	movl	$.L.str.4, %edi
	movl	%r14d, %esi
	jmp	.LBB3_36
.LBB3_39:
	movl	%eax, %r15d
	movl	$.L.str.2, %edi
	movl	$.L.str.3, %esi
	movl	$201, %edx
	jmp	.LBB3_35
.LBB3_40:
	movl	%eax, %r15d
	movl	$.L.str.2, %edi
	movl	$.L.str.3, %esi
	movl	$199, %edx
	jmp	.LBB3_35
.LBB3_41:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %esi
	jmp	.LBB3_33
.LBB3_42:
	movl	%eax, %r15d
	movl	$.L.str.2, %edi
	movl	$.L.str.3, %esi
	movl	$186, %edx
	jmp	.LBB3_35
.LBB3_43:
	movl	%eax, %r15d
	movl	$.L.str.2, %edi
	movl	$.L.str.3, %esi
	movl	$181, %edx
	jmp	.LBB3_35
.LBB3_44:
	movl	%eax, %r15d
	movl	$.L.str.2, %edi
	movl	$.L.str.3, %esi
	movl	$180, %edx
	jmp	.LBB3_35
.LBB3_45:
	movl	%eax, %r15d
	movl	$.L.str.2, %edi
	movl	$.L.str.3, %esi
	movl	$176, %edx
	jmp	.LBB3_35
.LBB3_46:
	movl	%eax, %r15d
	movl	$.L.str.2, %edi
	movl	$.L.str.3, %esi
	movl	$175, %edx
	jmp	.LBB3_35
.LBB3_47:
	movl	%eax, %ebx
	movl	$.L.str.2, %edi
	movl	$.L.str.3, %esi
	movl	$227, %edx
	xorl	%eax, %eax
	callq	printf
	movl	%ebx, %edi
	callq	hipGetErrorString
	movl	$.L.str.4, %edi
	movl	%ebx, %esi
	jmp	.LBB3_36
.Lfunc_end3:
	.size	main, .Lfunc_end3-main
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z12createvectorxii
.LCPI4_0:
	.quad	0x41747ae147851eb8              # double 21474836.469999999
	.text
	.globl	_Z12createvectorxii
	.type	_Z12createvectorxii,@function
_Z12createvectorxii:                    # @_Z12createvectorxii
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r12
	.cfi_def_cfa_offset 32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	pushq	%rax
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -40
	.cfi_offset %r12, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
                                        # kill: def $edx killed $edx def $rdx
	movl	%esi, %ebx
	movq	%rdi, %r14
	leal	1(%rdx), %edi
	callq	srand
	leaq	(,%r14,8), %rdi
	callq	malloc
	movq	%rax, %r15
	testq	%r14, %r14
	jle	.LBB4_5
# %bb.1:                                # %.lr.ph
	xorl	%r12d, %r12d
.LBB4_2:                                # =>This Inner Loop Header: Depth=1
	xorpd	%xmm0, %xmm0
	testl	%ebx, %ebx
	jne	.LBB4_4
# %bb.3:                                #   in Loop: Header=BB4_2 Depth=1
	callq	rand
	xorps	%xmm0, %xmm0
	cvtsi2sd	%eax, %xmm0
	divsd	.LCPI4_0(%rip), %xmm0
.LBB4_4:                                #   in Loop: Header=BB4_2 Depth=1
	movsd	%xmm0, (%r15,%r12,8)
	incq	%r12
	cmpq	%r12, %r14
	jne	.LBB4_2
.LBB4_5:                                # %._crit_edge
	movq	%r15, %rax
	addq	$8, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end4:
	.size	_Z12createvectorxii, .Lfunc_end4-_Z12createvectorxii
	.cfi_endproc
                                        # -- End function
	.globl	_Z11printvectorPdx              # -- Begin function _Z11printvectorPdx
	.type	_Z11printvectorPdx,@function
_Z11printvectorPdx:                     # @_Z11printvectorPdx
	.cfi_startproc
# %bb.0:
	testq	%rsi, %rsi
	jle	.LBB5_4
# %bb.1:                                # %.lr.ph.preheader
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rsi, %rbx
	movq	%rdi, %r14
	xorl	%r15d, %r15d
.LBB5_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movsd	(%r14,%r15,8), %xmm0            # xmm0 = mem[0],zero
	movl	$.L.str.10, %edi
	movb	$1, %al
	callq	printf
	incq	%r15
	cmpq	%r15, %rbx
	jne	.LBB5_2
# %bb.3:
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	.cfi_restore %rbx
	.cfi_restore %r14
	.cfi_restore %r15
.LBB5_4:                                # %._crit_edge
	movl	$10, %edi
	jmp	putchar@PLT                     # TAILCALL
.Lfunc_end5:
	.size	_Z11printvectorPdx, .Lfunc_end5-_Z11printvectorPdx
	.cfi_endproc
                                        # -- End function
	.globl	_Z14dotproduct_CPUPdS_x         # -- Begin function _Z14dotproduct_CPUPdS_x
	.type	_Z14dotproduct_CPUPdS_x,@function
_Z14dotproduct_CPUPdS_x:                # @_Z14dotproduct_CPUPdS_x
	.cfi_startproc
# %bb.0:
	xorpd	%xmm0, %xmm0
	testq	%rdx, %rdx
	jle	.LBB6_3
# %bb.1:                                # %.lr.ph.preheader
	xorl	%eax, %eax
.LBB6_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movsd	(%rdi,%rax,8), %xmm1            # xmm1 = mem[0],zero
	mulsd	(%rsi,%rax,8), %xmm1
	addsd	%xmm1, %xmm0
	incq	%rax
	cmpq	%rax, %rdx
	jne	.LBB6_2
.LBB6_3:                                # %._crit_edge
	retq
.Lfunc_end6:
	.size	_Z14dotproduct_CPUPdS_x, .Lfunc_end6-_Z14dotproduct_CPUPdS_x
	.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	.LBB7_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB7_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z11reducefinalPdS_i, %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	$_Z10dotproductPdS_S_x, %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_end7:
	.size	__hip_module_ctor, .Lfunc_end7-__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	.LBB8_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
.LBB8_2:
	retq
.Lfunc_end8:
	.size	__hip_module_dtor, .Lfunc_end8-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	_Z11reducefinalPdS_i,@object    # @_Z11reducefinalPdS_i
	.section	.rodata,"a",@progbits
	.globl	_Z11reducefinalPdS_i
	.p2align	3, 0x0
_Z11reducefinalPdS_i:
	.quad	_Z26__device_stub__reducefinalPdS_i
	.size	_Z11reducefinalPdS_i, 8

	.type	_Z10dotproductPdS_S_x,@object   # @_Z10dotproductPdS_S_x
	.globl	_Z10dotproductPdS_S_x
	.p2align	3, 0x0
_Z10dotproductPdS_S_x:
	.quad	_Z25__device_stub__dotproductPdS_S_x
	.size	_Z10dotproductPdS_S_x, 8

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

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"Error: %s:%d, "
	.size	.L.str.2, 15

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"/home/ubuntu/Datasets/stackv2/train-structured-repos-hip-sm89/KaLiMaLi555/hp3/master/term_assignments/dotproduct_reduction.hip"
	.size	.L.str.3, 127

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"code: %d, reason: %s\n"
	.size	.L.str.4, 22

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"Failed to launch dotproduct kernel (error code %s)!\n"
	.size	.L.str.5, 53

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"Failed to launch reducefinal kernel (error code %s)!\n"
	.size	.L.str.6, 54

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"\nDot Product => %0.2f"
	.size	.L.str.8, 22

	.type	.L.str.9,@object                # @.str.9
.L.str.9:
	.asciz	"Dot Product from CPU => %0.2f\n\n"
	.size	.L.str.9, 32

	.type	.L.str.10,@object               # @.str.10
.L.str.10:
	.asciz	"% 6.2f "
	.size	.L.str.10, 8

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z11reducefinalPdS_i"
	.size	.L__unnamed_1, 21

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_Z10dotproductPdS_S_x"
	.size	.L__unnamed_2, 22

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

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

	.type	.Lstr,@object                   # @str
	.section	.rodata.str1.1,"aMS",@progbits,1
.Lstr:
	.asciz	"\n\nDisabling Printing ...\n"
	.size	.Lstr, 26

	.type	.Lstr.1,@object                 # @str.1
.Lstr.1:
	.asciz	"\n\n***** Final Output of GPU Reduction Kernal *****\n"
	.size	.Lstr.1, 52

	.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 _Z26__device_stub__reducefinalPdS_i
	.addrsig_sym _Z25__device_stub__dotproductPdS_S_x
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z11reducefinalPdS_i
	.addrsig_sym _Z10dotproductPdS_S_x
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z11reducefinalPdS_i    ; -- Begin function _Z11reducefinalPdS_i
	.globl	_Z11reducefinalPdS_i
	.p2align	8
	.type	_Z11reducefinalPdS_i,@function
_Z11reducefinalPdS_i:                   ; @_Z11reducefinalPdS_i
; %bb.0:
	s_clause 0x2
	s_load_b32 s5, s[0:1], 0x24
	s_load_b32 s7, s[0:1], 0x10
	s_load_b128 s[0:3], s[0:1], 0x0
	v_mov_b32_e32 v2, 0
	v_mov_b32_e32 v3, 0
	s_mov_b32 s4, s15
	s_waitcnt lgkmcnt(0)
	s_and_b32 s6, s5, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_mul_i32 s5, s15, s6
	v_lshl_add_u32 v1, s5, 1, v0
	s_mov_b32 s5, exec_lo
	s_delay_alu instid0(VALU_DEP_1)
	v_cmpx_gt_i32_e64 s7, v1
	s_cbranch_execz .LBB0_2
; %bb.1:
	v_ashrrev_i32_e32 v2, 31, v1
	v_dual_mov_b32 v4, 0 :: v_dual_add_nc_u32 v3, s6, v1
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_lshlrev_b64 v[1:2], 3, v[1:2]
	v_lshlrev_b64 v[3:4], 3, v[3:4]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_co_u32 v1, vcc_lo, s0, v1
	v_add_co_ci_u32_e32 v2, vcc_lo, s1, v2, vcc_lo
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_4)
	v_add_co_u32 v3, vcc_lo, s0, v3
	v_add_co_ci_u32_e32 v4, vcc_lo, s1, v4, vcc_lo
	s_clause 0x1
	global_load_b64 v[1:2], v[1:2], off
	global_load_b64 v[3:4], v[3:4], off
	s_waitcnt vmcnt(0)
	v_add_f64 v[2:3], v[1:2], v[3:4]
.LBB0_2:
	s_or_b32 exec_lo, exec_lo, s5
	v_lshl_add_u32 v1, v0, 3, 0
	s_mov_b32 s0, exec_lo
	ds_store_b64 v1, v[2:3]
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	v_cmpx_gt_u32_e32 0x200, v0
	s_cbranch_execz .LBB0_4
; %bb.3:
	ds_load_2addr_stride64_b64 v[2:5], v1 offset1:8
	s_waitcnt lgkmcnt(0)
	v_add_f64 v[2:3], v[4:5], v[2:3]
	ds_store_b64 v1, v[2:3]
.LBB0_4:
	s_or_b32 exec_lo, exec_lo, s0
	s_delay_alu instid0(SALU_CYCLE_1)
	s_mov_b32 s0, exec_lo
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	v_cmpx_gt_u32_e32 0x100, v0
	s_cbranch_execz .LBB0_6
; %bb.5:
	ds_load_b64 v[2:3], v1 offset:2048
	ds_load_b64 v[4:5], v1
	s_waitcnt lgkmcnt(0)
	v_add_f64 v[2:3], v[2:3], v[4:5]
	ds_store_b64 v1, v[2:3]
.LBB0_6:
	s_or_b32 exec_lo, exec_lo, s0
	s_delay_alu instid0(SALU_CYCLE_1)
	s_mov_b32 s0, exec_lo
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	v_cmpx_gt_u32_e32 0x80, v0
	s_cbranch_execz .LBB0_8
; %bb.7:
	ds_load_b64 v[2:3], v1 offset:1024
	ds_load_b64 v[4:5], v1
	s_waitcnt lgkmcnt(0)
	v_add_f64 v[2:3], v[2:3], v[4:5]
	ds_store_b64 v1, v[2:3]
.LBB0_8:
	s_or_b32 exec_lo, exec_lo, s0
	s_delay_alu instid0(SALU_CYCLE_1)
	s_mov_b32 s0, exec_lo
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	v_cmpx_gt_u32_e32 64, v0
	s_cbranch_execz .LBB0_10
; %bb.9:
	ds_load_b64 v[2:3], v1 offset:512
	ds_load_b64 v[4:5], v1
	s_waitcnt lgkmcnt(0)
	v_add_f64 v[2:3], v[2:3], v[4:5]
	ds_store_b64 v1, v[2:3]
.LBB0_10:
	s_or_b32 exec_lo, exec_lo, s0
	s_delay_alu instid0(SALU_CYCLE_1)
	s_mov_b32 s0, exec_lo
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	v_cmpx_gt_u32_e32 32, v0
	s_cbranch_execz .LBB0_12
; %bb.11:
	ds_load_b64 v[2:3], v1 offset:256
	ds_load_b64 v[4:5], v1
	s_waitcnt lgkmcnt(0)
	v_add_f64 v[2:3], v[2:3], v[4:5]
	ds_store_b64 v1, v[2:3]
.LBB0_12:
	s_or_b32 exec_lo, exec_lo, s0
	s_delay_alu instid0(SALU_CYCLE_1)
	s_mov_b32 s0, exec_lo
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	v_cmpx_gt_u32_e32 16, v0
	s_cbranch_execz .LBB0_14
; %bb.13:
	ds_load_b64 v[2:3], v1 offset:128
	ds_load_b64 v[4:5], v1
	s_waitcnt lgkmcnt(0)
	v_add_f64 v[2:3], v[2:3], v[4:5]
	ds_store_b64 v1, v[2:3]
.LBB0_14:
	s_or_b32 exec_lo, exec_lo, s0
	s_delay_alu instid0(SALU_CYCLE_1)
	s_mov_b32 s0, exec_lo
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	v_cmpx_gt_u32_e32 8, v0
	s_cbranch_execz .LBB0_16
; %bb.15:
	ds_load_b64 v[2:3], v1 offset:64
	ds_load_b64 v[4:5], v1
	s_waitcnt lgkmcnt(0)
	v_add_f64 v[2:3], v[2:3], v[4:5]
	ds_store_b64 v1, v[2:3]
.LBB0_16:
	s_or_b32 exec_lo, exec_lo, s0
	s_delay_alu instid0(SALU_CYCLE_1)
	s_mov_b32 s0, exec_lo
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	v_cmpx_gt_u32_e32 4, v0
	s_cbranch_execz .LBB0_18
; %bb.17:
	ds_load_b64 v[2:3], v1 offset:32
	ds_load_b64 v[4:5], v1
	s_waitcnt lgkmcnt(0)
	v_add_f64 v[2:3], v[2:3], v[4:5]
	ds_store_b64 v1, v[2:3]
.LBB0_18:
	s_or_b32 exec_lo, exec_lo, s0
	s_delay_alu instid0(SALU_CYCLE_1)
	s_mov_b32 s0, exec_lo
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	v_cmpx_gt_u32_e32 2, v0
	s_cbranch_execz .LBB0_20
; %bb.19:
	ds_load_b64 v[2:3], v1 offset:16
	ds_load_b64 v[4:5], v1
	s_waitcnt lgkmcnt(0)
	v_add_f64 v[2:3], v[2:3], v[4:5]
	ds_store_b64 v1, v[2:3]
.LBB0_20:
	s_or_b32 exec_lo, exec_lo, s0
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	s_mov_b32 s0, exec_lo
	v_cmpx_eq_u32_e32 0, v0
	s_cbranch_execz .LBB0_22
; %bb.21:
	v_mov_b32_e32 v4, 0
	s_ashr_i32 s5, s4, 31
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_lshl_b64 s[0:1], s[4:5], 3
	s_add_u32 s0, s2, s0
	ds_load_2addr_b64 v[0:3], v4 offset1:1
	s_addc_u32 s1, s3, s1
	s_waitcnt lgkmcnt(0)
	v_add_f64 v[0:1], v[2:3], v[0:1]
	ds_store_b64 v4, v[0:1]
	global_store_b64 v4, v[0:1], s[0:1]
.LBB0_22:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z11reducefinalPdS_i
		.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 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_end0:
	.size	_Z11reducefinalPdS_i, .Lfunc_end0-_Z11reducefinalPdS_i
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 952
; 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: 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	_Z10dotproductPdS_S_x   ; -- Begin function _Z10dotproductPdS_S_x
	.globl	_Z10dotproductPdS_S_x
	.p2align	8
	.type	_Z10dotproductPdS_S_x,@function
_Z10dotproductPdS_S_x:                  ; @_Z10dotproductPdS_S_x
; %bb.0:
	s_clause 0x1
	s_load_b32 s9, s[0:1], 0x2c
	s_load_b256 s[0:7], s[0:1], 0x0
	s_mov_b32 s8, s15
	s_waitcnt lgkmcnt(0)
	s_and_b32 s9, s9, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_2) | instid1(VALU_DEP_3)
	v_mad_u64_u32 v[3:4], null, s8, s9, v[0:1]
	v_mov_b32_e32 v1, 0
	v_mov_b32_e32 v2, 0
	v_ashrrev_i32_e32 v4, 31, v3
	s_delay_alu instid0(VALU_DEP_1)
	v_cmp_gt_i64_e32 vcc_lo, s[6:7], v[3:4]
	s_and_saveexec_b32 s6, vcc_lo
	s_cbranch_execz .LBB1_2
; %bb.1:
	v_lshlrev_b64 v[1:2], 3, v[3:4]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v3, vcc_lo, s0, v1
	v_add_co_ci_u32_e32 v4, vcc_lo, s1, v2, vcc_lo
	v_add_co_u32 v1, vcc_lo, s2, v1
	v_add_co_ci_u32_e32 v2, vcc_lo, s3, v2, vcc_lo
	global_load_b64 v[3:4], v[3:4], off
	global_load_b64 v[1:2], v[1:2], off
	s_waitcnt vmcnt(0)
	v_mul_f64 v[1:2], v[3:4], v[1:2]
.LBB1_2:
	s_or_b32 exec_lo, exec_lo, s6
	v_lshl_add_u32 v3, v0, 3, 0
	s_cmp_lt_u32 s9, 2
	ds_store_b64 v3, v[1:2]
	s_waitcnt lgkmcnt(0)
	s_barrier
.LBB1_3:                                ; =>This Inner Loop Header: Depth=1
	buffer_gl0_inv
	s_cbranch_scc1 .LBB1_7
; %bb.4:                                ; %.lr.ph
                                        ;   in Loop: Header=BB1_3 Depth=1
	s_lshr_b32 s0, s9, 1
	s_mov_b32 s1, exec_lo
	v_cmpx_gt_u32_e64 s0, v0
	s_cbranch_execz .LBB1_6
; %bb.5:                                ;   in Loop: Header=BB1_3 Depth=1
	v_lshl_add_u32 v1, s0, 3, v3
	ds_load_b64 v[1:2], v1
	ds_load_b64 v[4:5], v3
	s_waitcnt lgkmcnt(0)
	v_add_f64 v[1:2], v[1:2], v[4:5]
	ds_store_b64 v3, v[1:2]
.LBB1_6:                                ;   in Loop: Header=BB1_3 Depth=1
	s_or_b32 exec_lo, exec_lo, s1
	s_waitcnt lgkmcnt(0)
	s_barrier
	s_cmp_lt_u32 s9, 4
	s_mov_b32 s9, s0
	s_branch .LBB1_3
.LBB1_7:                                ; %._crit_edge
	s_mov_b32 s0, exec_lo
	v_cmpx_eq_u32_e32 0, v0
	s_cbranch_execz .LBB1_9
; %bb.8:
	v_mov_b32_e32 v2, 0
	s_ashr_i32 s9, s8, 31
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_lshl_b64 s[0:1], s[8:9], 3
	s_add_u32 s0, s4, s0
	ds_load_b64 v[0:1], v2
	s_addc_u32 s1, s5, s1
	s_waitcnt lgkmcnt(0)
	global_store_b64 v2, v[0:1], s[0:1]
.LBB1_9:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z10dotproductPdS_S_x
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 288
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 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	_Z10dotproductPdS_S_x, .Lfunc_end1-_Z10dotproductPdS_S_x
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 340
; 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: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __hip_cuid_
	.amdgpu_metadata
---
amdhsa.kernels:
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .offset:         16
        .size:           4
        .value_kind:     by_value
      - .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
      - .offset:         144
        .size:           4
        .value_kind:     hidden_dynamic_lds_size
    .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:           _Z11reducefinalPdS_i
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z11reducefinalPdS_i.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:
      - .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:           8
        .value_kind:     by_value
      - .offset:         32
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         36
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         40
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         44
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         46
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         48
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         50
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         52
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         54
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         88
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         96
        .size:           2
        .value_kind:     hidden_grid_dims
      - .offset:         152
        .size:           4
        .value_kind:     hidden_dynamic_lds_size
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 288
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z10dotproductPdS_S_x
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z10dotproductPdS_S_x.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     6
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
