
#include "cuda_runtime.h"
#include "device_launch_parameters.h"

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


double secuential(const double a[] , int dim,bool verbose){
	double mean=0;
	for(int i=0; i<dim;i++){
		mean+=a[i];
	}
	mean=mean/dim;
	if(verbose)printf("cpu mean %f\n", mean);
	double sum=0;
	for(int i=0; i<dim;i++){
		sum+=(a[i]-mean)*(a[i]-mean);
	}
	if(verbose)printf("cpu sigma %f\n", sum);
	return sqrt(sum/(dim-1));

}

     
__global__ void reduccion( double a[], const int dim)
{
	unsigned long int i;
	unsigned long int global_id = blockIdx.x * blockDim.x + threadIdx.x;	

	if (global_id < dim/2) {	
		i = 2 * global_id;
		a[global_id] = a[i] + a[i+1];

	}
} 

__global__ void pre_sigma( double a[], const int dim, const double mean)
{
	unsigned long int global_id = blockIdx.x * blockDim.x + threadIdx.x;	

	if (global_id < dim) {
		a[global_id] -= mean;
		a[global_id]*= a[global_id];
	}

} 

    
int main(int argc, char *argv[]){
	clock_t time_begin;
     double *device_array = 0;
     double *host_array = 0;

	unsigned long int size_array  = (argc > 1)? atoi (argv[1]): 1024;
	unsigned int block_size = (argc > 2)? atoi (argv[2]): 16;	
	bool verbose= (argc>3)? (argv[3][0]=='v'): false;
    host_array = (double*)malloc( size_array * sizeof(double));
	double *copy_host_array=(double*)malloc( size_array * sizeof(double));
	
    for(unsigned int i=0; i<size_array; i++){
		host_array[i]=rand()%10;
		copy_host_array[i]=host_array[i];
		if(verbose)
			printf("%f\t", host_array[i]);

    }
    printf("\n");	
     cudaMalloc(&device_array,size_array * sizeof(double));    
    cudaError_t e=cudaMemcpy(device_array, host_array, sizeof(double)*size_array, cudaMemcpyHostToDevice); 

	//cudaerrorinvalidvalue(11)

	time_begin=clock();

	unsigned long int i = size_array;
	while (i > 1) {	
		dim3 bloque(block_size);
		dim3 grid((i/2 + bloque.x - 1)/ bloque.x);			
		reduccion<<<grid, bloque>>>(device_array, i);
		cudaThreadSynchronize();
		i = i/2;
	}

	cudaMemcpy(copy_host_array, device_array, sizeof(double)*size_array, cudaMemcpyDeviceToHost); 
	double mean_gpu= copy_host_array[0] / size_array;
	e=cudaMemcpy(device_array, host_array, sizeof(double)*size_array, cudaMemcpyHostToDevice); 

	dim3 bloque2(block_size);	
	dim3 grid2((size_array + bloque2.x - 1) / bloque2.x);			
	
	pre_sigma<<<bloque2, grid2>>>(device_array, size_array, mean_gpu);

	cudaThreadSynchronize();
	cudaMemcpy(copy_host_array, device_array, sizeof(double)*size_array, cudaMemcpyDeviceToHost); 

	if(verbose){
		printf("mean gpu: %f\n", mean_gpu);
		for(unsigned int j=0; j<size_array; j++)
			printf("%f\t", copy_host_array[j]);
		printf("\n");
	}

	i=size_array;
	while (i > 1) {	
		dim3 bloque(block_size);
		dim3 grid((i/2 + bloque.x - 1)/ bloque.x);			
		reduccion<<<grid, bloque>>>(device_array, i);
		cudaThreadSynchronize();
		i = i/2;
	}
	
	cudaMemcpy(copy_host_array, device_array, sizeof(double)*size_array, cudaMemcpyDeviceToHost); 

	if(verbose) printf("gpu sigma %f \n", copy_host_array[0]);
	double final_res= sqrt(copy_host_array[0]/(size_array-1));

	printf("GPU time: %f seconds\t", (((double)clock() - (double)time_begin) / 1000000.0F ) * 1000  ); 
	printf("GPU result: %f\n", final_res);

	//--------------cpu computations-----------------------//
	time_begin=clock();
	double cpu_res=secuential(host_array, size_array, verbose);
	printf("CPU time: %f seconds\t", (((double)clock() - (double)time_begin) / 1000000.0F ) * 1000  );
	printf("CPU result: %f\n", cpu_res);

    free(host_array);free(copy_host_array);
    cudaFree(device_array); 

	

}
	.file	"tmpxft_0033b2b8_00000000-6_entrega1_2_lasttry.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2031:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2031:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC1:
	.string	"cpu mean %f\n"
.LC2:
	.string	"cpu sigma %f\n"
	.text
	.globl	_Z10secuentialPKdib
	.type	_Z10secuentialPKdib, @function
_Z10secuentialPKdib:
.LFB2027:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	xorl	%eax, %eax
	movq	%rdi, %r12
	xorps	%xmm0, %xmm0
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movl	%edx, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	movl	%esi, %ebx
	subq	$16, %rsp
	.cfi_def_cfa_offset 48
.L3:
	cmpl	%eax, %ebx
	jle	.L11
	addsd	(%r12,%rax,8), %xmm0
	incq	%rax
	jmp	.L3
.L11:
	cvtsi2sdl	%ebx, %xmm1
	divsd	%xmm1, %xmm0
	movsd	%xmm0, 8(%rsp)
	testb	%bpl, %bpl
	je	.L5
	leaq	.LC1(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	call	__printf_chk@PLT
.L5:
	xorl	%eax, %eax
	xorps	%xmm0, %xmm0
.L6:
	cmpl	%eax, %ebx
	jle	.L12
	movsd	(%r12,%rax,8), %xmm1
	subsd	8(%rsp), %xmm1
	incq	%rax
	mulsd	%xmm1, %xmm1
	addsd	%xmm1, %xmm0
	jmp	.L6
.L12:
	testb	%bpl, %bpl
	je	.L8
	leaq	.LC2(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	movsd	%xmm0, 8(%rsp)
	call	__printf_chk@PLT
	movsd	8(%rsp), %xmm0
.L8:
	decl	%ebx
	addq	$16, %rsp
	.cfi_def_cfa_offset 32
	cvtsi2sdl	%ebx, %xmm1
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	divsd	%xmm1, %xmm0
	jmp	sqrt@PLT
	.cfi_endproc
.LFE2027:
	.size	_Z10secuentialPKdib, .-_Z10secuentialPKdib
	.globl	_Z29__device_stub__Z9reduccionPdiPdi
	.type	_Z29__device_stub__Z9reduccionPdiPdi, @function
_Z29__device_stub__Z9reduccionPdiPdi:
.LFB2053:
	.cfi_startproc
	endbr64
	subq	$120, %rsp
	.cfi_def_cfa_offset 128
	movq	%rdi, 8(%rsp)
	leaq	32(%rsp), %rcx
	leaq	24(%rsp), %rdx
	movl	%esi, 4(%rsp)
	leaq	40(%rsp), %rdi
	leaq	52(%rsp), %rsi
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rax
	movl	$1, 48(%rsp)
	movq	%rax, 88(%rsp)
	leaq	4(%rsp), %rax
	movq	%rax, 96(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 40(%rsp)
	movq	%rax, 52(%rsp)
	movl	$1, 60(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L13
	pushq	32(%rsp)
	.cfi_def_cfa_offset 136
	leaq	_Z9reduccionPdi(%rip), %rdi
	pushq	32(%rsp)
	.cfi_def_cfa_offset 144
	movq	68(%rsp), %rcx
	movl	76(%rsp), %r8d
	movq	56(%rsp), %rsi
	movl	64(%rsp), %edx
	leaq	104(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 136
	popq	%rdx
	.cfi_def_cfa_offset 128
.L13:
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	je	.L15
	call	__stack_chk_fail@PLT
.L15:
	addq	$120, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2053:
	.size	_Z29__device_stub__Z9reduccionPdiPdi, .-_Z29__device_stub__Z9reduccionPdiPdi
	.globl	_Z9reduccionPdi
	.type	_Z9reduccionPdi, @function
_Z9reduccionPdi:
.LFB2054:
	.cfi_startproc
	endbr64
	jmp	_Z29__device_stub__Z9reduccionPdiPdi
	.cfi_endproc
.LFE2054:
	.size	_Z9reduccionPdi, .-_Z9reduccionPdi
	.globl	_Z30__device_stub__Z9pre_sigmaPdidPdid
	.type	_Z30__device_stub__Z9pre_sigmaPdidPdid, @function
_Z30__device_stub__Z9pre_sigmaPdidPdid:
.LFB2055:
	.cfi_startproc
	endbr64
	subq	$136, %rsp
	.cfi_def_cfa_offset 144
	movq	%rdi, 24(%rsp)
	leaq	40(%rsp), %rcx
	leaq	32(%rsp), %rdx
	movl	%esi, 20(%rsp)
	leaq	48(%rsp), %rdi
	leaq	60(%rsp), %rsi
	movsd	%xmm0, 8(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 120(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 56(%rsp)
	movq	%rax, 96(%rsp)
	leaq	20(%rsp), %rax
	movq	%rax, 104(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 112(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 48(%rsp)
	movq	%rax, 60(%rsp)
	movl	$1, 68(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L18
	pushq	40(%rsp)
	.cfi_def_cfa_offset 152
	leaq	_Z9pre_sigmaPdid(%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
.L18:
	movq	120(%rsp), %rax
	subq	%fs:40, %rax
	je	.L20
	call	__stack_chk_fail@PLT
.L20:
	addq	$136, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2055:
	.size	_Z30__device_stub__Z9pre_sigmaPdidPdid, .-_Z30__device_stub__Z9pre_sigmaPdidPdid
	.globl	_Z9pre_sigmaPdid
	.type	_Z9pre_sigmaPdid, @function
_Z9pre_sigmaPdid:
.LFB2056:
	.cfi_startproc
	endbr64
	jmp	_Z30__device_stub__Z9pre_sigmaPdidPdid
	.cfi_endproc
.LFE2056:
	.size	_Z9pre_sigmaPdid, .-_Z9pre_sigmaPdid
	.section	.rodata.str1.1
.LC3:
	.string	"%f\t"
.LC4:
	.string	"\n"
.LC5:
	.string	"mean gpu: %f\n"
.LC6:
	.string	"gpu sigma %f \n"
.LC9:
	.string	"GPU time: %f seconds\t"
.LC10:
	.string	"GPU result: %f\n"
.LC11:
	.string	"CPU time: %f seconds\t"
.LC12:
	.string	"CPU result: %f\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
	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
	xorl	%eax, %eax
	movq	%rax, 48(%rsp)
	cmpl	$1, %edi
	jle	.L42
	movl	%edi, %r13d
	movq	8(%rsi), %rdi
	movq	%rsi, %rbp
	call	atoi@PLT
	movslq	%eax, %rbx
	cmpl	$2, %r13d
	je	.L43
	movq	16(%rbp), %rdi
	xorl	%r12d, %r12d
	call	atoi@PLT
	movl	%eax, %r14d
	cmpl	$3, %r13d
	je	.L24
	movq	24(%rbp), %rax
	cmpb	$118, (%rax)
	sete	%r12b
	jmp	.L24
.L42:
	movl	$16, %r14d
	movl	$1024, %ebx
	jmp	.L55
.L43:
	movl	$16, %r14d
.L55:
	xorl	%r12d, %r12d
.L24:
	leaq	0(,%rbx,8), %rax
	xorl	%r13d, %r13d
	movq	%rax, %rdi
	movq	%rax, 8(%rsp)
	call	malloc@PLT
	leaq	0(,%rbx,8), %rdi
	movq	%rax, 16(%rsp)
	call	malloc@PLT
	movq	%rax, %rbp
.L25:
	movl	%r13d, %r15d
	cmpq	%rbx, %r15
	jnb	.L56
	call	rand@PLT
	movl	$10, %ecx
	cltd
	idivl	%ecx
	movq	16(%rsp), %rax
	cvtsi2sdl	%edx, %xmm0
	movsd	%xmm0, (%rax,%r15,8)
	movsd	%xmm0, 0(%rbp,%r15,8)
	testb	%r12b, %r12b
	je	.L26
	leaq	.LC3(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	call	__printf_chk@PLT
.L26:
	incl	%r13d
	jmp	.L25
.L56:
	leaq	.LC4(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	movabsq	$4294967297, %r15
	call	__printf_chk@PLT
	movq	8(%rsp), %rsi
	leaq	48(%rsp), %rdi
	call	cudaMalloc@PLT
	movq	8(%rsp), %rdx
	movq	16(%rsp), %rsi
	movl	$1, %ecx
	movq	48(%rsp), %rdi
	call	cudaMemcpy@PLT
	call	clock@PLT
	movq	%rbx, %r10
	movq	%rax, 40(%rsp)
.L28:
	movl	%r14d, %r13d
	cmpq	$1, %r10
	jbe	.L57
	movq	%r10, %rax
	xorl	%edx, %edx
	movq	%r15, 96(%rsp)
	movl	100(%rsp), %esi
	shrq	%rax
	movl	%r14d, 80(%rsp)
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movq	%rax, 24(%rsp)
	leaq	-1(%rax,%r13), %rax
	movl	$1, %ecx
	divq	%r13
	movl	$1, 84(%rsp)
	movq	80(%rsp), %rdx
	movq	%r10, 32(%rsp)
	movl	$1, 88(%rsp)
	movl	%eax, 92(%rsp)
	movq	92(%rsp), %rdi
	call	__cudaPushCallConfiguration@PLT
	movq	32(%rsp), %r10
	testl	%eax, %eax
	jne	.L29
	movq	48(%rsp), %rdi
	movl	%r10d, %esi
	call	_Z29__device_stub__Z9reduccionPdiPdi
.L29:
	call	cudaThreadSynchronize@PLT
	movq	24(%rsp), %r10
	jmp	.L28
.L57:
	movq	8(%rsp), %rdx
	movq	48(%rsp), %rsi
	movl	$2, %ecx
	movq	%rbp, %rdi
	leaq	-1(%rbx), %r15
	call	cudaMemcpy@PLT
	cvtsi2sdq	%rbx, %xmm0
	movsd	0(%rbp), %xmm1
	movq	8(%rsp), %rdx
	movq	16(%rsp), %rsi
	movq	48(%rsp), %rdi
	movl	$1, %ecx
	divsd	%xmm0, %xmm1
	movsd	%xmm1, 24(%rsp)
	call	cudaMemcpy@PLT
	leaq	(%r15,%r13), %rax
	xorl	%edx, %edx
	movl	%r14d, 56(%rsp)
	movl	$1, 60(%rsp)
	movq	56(%rsp), %rdi
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	divq	%r13
	movl	$1, %esi
	movl	%eax, 68(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 72(%rsp)
	movl	76(%rsp), %ecx
	movq	68(%rsp), %rdx
	call	__cudaPushCallConfiguration@PLT
	movl	%ebx, 32(%rsp)
	testl	%eax, %eax
	jne	.L31
	movsd	24(%rsp), %xmm0
	movq	48(%rsp), %rdi
	movl	%ebx, %esi
	call	_Z30__device_stub__Z9pre_sigmaPdidPdid
.L31:
	call	cudaThreadSynchronize@PLT
	movq	8(%rsp), %rdx
	movq	48(%rsp), %rsi
	movq	%rbp, %rdi
	movl	$2, %ecx
	call	cudaMemcpy@PLT
	testb	%r12b, %r12b
	je	.L36
	movsd	24(%rsp), %xmm0
	leaq	.LC5(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	call	__printf_chk@PLT
	xorl	%edx, %edx
.L33:
	cmpq	%rbx, %rdx
	je	.L58
	movsd	0(%rbp,%rdx,8), %xmm0
	leaq	.LC3(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	movq	%rdx, 24(%rsp)
	call	__printf_chk@PLT
	movq	24(%rsp), %rdx
	incq	%rdx
	jmp	.L33
.L58:
	leaq	.LC4(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L36
.L37:
	movq	%rbx, %rax
	xorl	%edx, %edx
	movl	$1, 84(%rsp)
	xorl	%r9d, %r9d
	shrq	%rax
	movl	%r14d, 80(%rsp)
	xorl	%r8d, %r8d
	movl	$1, %ecx
	movq	%rax, 24(%rsp)
	leaq	-1(%rax,%r13), %rax
	divq	%r13
	movq	80(%rsp), %rdx
	movl	$1, 88(%rsp)
	movl	%eax, 92(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 96(%rsp)
	movq	92(%rsp), %rdi
	movl	100(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L35
	movq	48(%rsp), %rdi
	movl	%ebx, %esi
	call	_Z29__device_stub__Z9reduccionPdiPdi
.L35:
	call	cudaThreadSynchronize@PLT
	movq	24(%rsp), %rbx
.L36:
	cmpq	$1, %rbx
	ja	.L37
	movq	8(%rsp), %rdx
	movq	48(%rsp), %rsi
	movl	$2, %ecx
	movq	%rbp, %rdi
	call	cudaMemcpy@PLT
	testb	%r12b, %r12b
	je	.L38
	movsd	0(%rbp), %xmm0
	leaq	.LC6(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	call	__printf_chk@PLT
.L38:
	testq	%r15, %r15
	js	.L39
	cvtsi2sdq	%r15, %xmm1
	jmp	.L40
.L39:
	movq	%r15, %rax
	andl	$1, %r15d
	shrq	%rax
	orq	%r15, %rax
	cvtsi2sdq	%rax, %xmm1
	addsd	%xmm1, %xmm1
.L40:
	movsd	0(%rbp), %xmm0
	divsd	%xmm1, %xmm0
	call	sqrt@PLT
	movq	%xmm0, %rbx
	call	clock@PLT
	cvtsi2sdq	40(%rsp), %xmm1
	movl	$2, %edi
	leaq	.LC9(%rip), %rsi
	cvtsi2sdq	%rax, %xmm0
	movb	$1, %al
	subsd	%xmm1, %xmm0
	divsd	.LC7(%rip), %xmm0
	mulsd	.LC8(%rip), %xmm0
	call	__printf_chk@PLT
	movq	%rbx, %xmm0
	leaq	.LC10(%rip), %rsi
	movb	$1, %al
	movl	$2, %edi
	call	__printf_chk@PLT
	call	clock@PLT
	movl	32(%rsp), %esi
	movq	16(%rsp), %rdi
	movzbl	%r12b, %edx
	movq	%rax, %r13
	call	_Z10secuentialPKdib
	movq	%xmm0, %rbx
	call	clock@PLT
	cvtsi2sdq	%r13, %xmm1
	movl	$2, %edi
	leaq	.LC11(%rip), %rsi
	cvtsi2sdq	%rax, %xmm0
	movb	$1, %al
	subsd	%xmm1, %xmm0
	divsd	.LC7(%rip), %xmm0
	mulsd	.LC8(%rip), %xmm0
	call	__printf_chk@PLT
	movq	%rbx, %xmm0
	leaq	.LC12(%rip), %rsi
	movb	$1, %al
	movl	$2, %edi
	call	__printf_chk@PLT
	movq	16(%rsp), %rdi
	call	free@PLT
	movq	%rbp, %rdi
	call	free@PLT
	movq	48(%rsp), %rdi
	call	cudaFree@PLT
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	je	.L41
	call	__stack_chk_fail@PLT
.L41:
	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
.LC13:
	.string	"_Z9pre_sigmaPdid"
.LC14:
	.string	"_Z9reduccionPdi"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2058:
	.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	.LC13(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z9pre_sigmaPdid(%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	.LC14(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z9reduccionPdi(%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
.LFE2058:
	.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
.LC7:
	.long	0
	.long	1093567616
	.align 8
.LC8:
	.long	0
	.long	1083129856
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:


#include "hip/hip_runtime.h"


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


double secuential(const double a[] , int dim,bool verbose){
	double mean=0;
	for(int i=0; i<dim;i++){
		mean+=a[i];
	}
	mean=mean/dim;
	if(verbose)printf("cpu mean %f\n", mean);
	double sum=0;
	for(int i=0; i<dim;i++){
		sum+=(a[i]-mean)*(a[i]-mean);
	}
	if(verbose)printf("cpu sigma %f\n", sum);
	return sqrt(sum/(dim-1));

}

     
__global__ void reduccion( double a[], const int dim)
{
	unsigned long int i;
	unsigned long int global_id = blockIdx.x * blockDim.x + threadIdx.x;	

	if (global_id < dim/2) {	
		i = 2 * global_id;
		a[global_id] = a[i] + a[i+1];

	}
} 

__global__ void pre_sigma( double a[], const int dim, const double mean)
{
	unsigned long int global_id = blockIdx.x * blockDim.x + threadIdx.x;	

	if (global_id < dim) {
		a[global_id] -= mean;
		a[global_id]*= a[global_id];
	}

} 

    
int main(int argc, char *argv[]){
	clock_t time_begin;
     double *device_array = 0;
     double *host_array = 0;

	unsigned long int size_array  = (argc > 1)? atoi (argv[1]): 1024;
	unsigned int block_size = (argc > 2)? atoi (argv[2]): 16;	
	bool verbose= (argc>3)? (argv[3][0]=='v'): false;
    host_array = (double*)malloc( size_array * sizeof(double));
	double *copy_host_array=(double*)malloc( size_array * sizeof(double));
	
    for(unsigned int i=0; i<size_array; i++){
		host_array[i]=rand()%10;
		copy_host_array[i]=host_array[i];
		if(verbose)
			printf("%f\t", host_array[i]);

    }
    printf("\n");	
     hipMalloc(&device_array,size_array * sizeof(double));    
    hipError_t e=hipMemcpy(device_array, host_array, sizeof(double)*size_array, hipMemcpyHostToDevice); 

	//cudaerrorinvalidvalue(11)

	time_begin=clock();

	unsigned long int i = size_array;
	while (i > 1) {	
		dim3 bloque(block_size);
		dim3 grid((i/2 + bloque.x - 1)/ bloque.x);			
		reduccion<<<grid, bloque>>>(device_array, i);
		hipDeviceSynchronize();
		i = i/2;
	}

	hipMemcpy(copy_host_array, device_array, sizeof(double)*size_array, hipMemcpyDeviceToHost); 
	double mean_gpu= copy_host_array[0] / size_array;
	e=hipMemcpy(device_array, host_array, sizeof(double)*size_array, hipMemcpyHostToDevice); 

	dim3 bloque2(block_size);	
	dim3 grid2((size_array + bloque2.x - 1) / bloque2.x);			
	
	pre_sigma<<<bloque2, grid2>>>(device_array, size_array, mean_gpu);

	hipDeviceSynchronize();
	hipMemcpy(copy_host_array, device_array, sizeof(double)*size_array, hipMemcpyDeviceToHost); 

	if(verbose){
		printf("mean gpu: %f\n", mean_gpu);
		for(unsigned int j=0; j<size_array; j++)
			printf("%f\t", copy_host_array[j]);
		printf("\n");
	}

	i=size_array;
	while (i > 1) {	
		dim3 bloque(block_size);
		dim3 grid((i/2 + bloque.x - 1)/ bloque.x);			
		reduccion<<<grid, bloque>>>(device_array, i);
		hipDeviceSynchronize();
		i = i/2;
	}
	
	hipMemcpy(copy_host_array, device_array, sizeof(double)*size_array, hipMemcpyDeviceToHost); 

	if(verbose) printf("gpu sigma %f \n", copy_host_array[0]);
	double final_res= sqrt(copy_host_array[0]/(size_array-1));

	printf("GPU time: %f seconds\t", (((double)clock() - (double)time_begin) / 1000000.0F ) * 1000  ); 
	printf("GPU result: %f\n", final_res);

	//--------------cpu computations-----------------------//
	time_begin=clock();
	double cpu_res=secuential(host_array, size_array, verbose);
	printf("CPU time: %f seconds\t", (((double)clock() - (double)time_begin) / 1000000.0F ) * 1000  );
	printf("CPU result: %f\n", cpu_res);

    free(host_array);free(copy_host_array);
    hipFree(device_array); 

	

}
	.text
	.file	"entrega1_2_lasttry.hip"
	.globl	_Z10secuentialPKdib             # -- Begin function _Z10secuentialPKdib
	.type	_Z10secuentialPKdib,@function
_Z10secuentialPKdib:                    # @_Z10secuentialPKdib
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	pushq	%rax
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	%edx, %ebp
	movl	%esi, %ebx
	movq	%rdi, %r14
	movl	%esi, %r15d
	xorpd	%xmm0, %xmm0
	testl	%esi, %esi
	jle	.LBB0_1
# %bb.10:                               # %.lr.ph.preheader
	xorl	%eax, %eax
.LBB0_11:                               # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	addsd	(%r14,%rax,8), %xmm0
	incq	%rax
	cmpq	%rax, %r15
	jne	.LBB0_11
.LBB0_1:                                # %._crit_edge
	cvtsi2sd	%ebx, %xmm1
	divsd	%xmm1, %xmm0
	testb	%bpl, %bpl
	je	.LBB0_3
# %bb.2:
	movl	$.L.str, %edi
	movb	$1, %al
	movsd	%xmm0, (%rsp)                   # 8-byte Spill
	callq	printf
	movsd	(%rsp), %xmm0                   # 8-byte Reload
                                        # xmm0 = mem[0],zero
.LBB0_3:
	xorpd	%xmm2, %xmm2
	testl	%ebx, %ebx
	jle	.LBB0_6
# %bb.4:                                # %.lr.ph32.preheader
	xorl	%eax, %eax
.LBB0_5:                                # %.lr.ph32
                                        # =>This Inner Loop Header: Depth=1
	movsd	(%r14,%rax,8), %xmm1            # xmm1 = mem[0],zero
	subsd	%xmm0, %xmm1
	mulsd	%xmm1, %xmm1
	addsd	%xmm1, %xmm2
	incq	%rax
	cmpq	%rax, %r15
	jne	.LBB0_5
.LBB0_6:                                # %._crit_edge33
	testb	%bpl, %bpl
	je	.LBB0_8
# %bb.7:
	movl	$.L.str.1, %edi
	movapd	%xmm2, %xmm0
	movb	$1, %al
	movsd	%xmm2, (%rsp)                   # 8-byte Spill
	callq	printf
	movsd	(%rsp), %xmm2                   # 8-byte Reload
                                        # xmm2 = mem[0],zero
.LBB0_8:
	decl	%ebx
	xorps	%xmm0, %xmm0
	cvtsi2sd	%ebx, %xmm0
	divsd	%xmm0, %xmm2
	xorpd	%xmm0, %xmm0
	ucomisd	%xmm0, %xmm2
	jb	.LBB0_12
# %bb.9:                                # %.split
	xorps	%xmm0, %xmm0
	sqrtsd	%xmm2, %xmm0
	addq	$8, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.LBB0_12:                               # %call.sqrt
	.cfi_def_cfa_offset 48
	movapd	%xmm2, %xmm0
	addq	$8, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	jmp	sqrt                            # TAILCALL
.Lfunc_end0:
	.size	_Z10secuentialPKdib, .Lfunc_end0-_Z10secuentialPKdib
	.cfi_endproc
                                        # -- End function
	.globl	_Z24__device_stub__reduccionPdi # -- Begin function _Z24__device_stub__reduccionPdi
	.type	_Z24__device_stub__reduccionPdi,@function
_Z24__device_stub__reduccionPdi:        # @_Z24__device_stub__reduccionPdi
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$80, %rsp
	.cfi_def_cfa_offset 128
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	24(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	4(%rsp), %rcx
	movl	%esi, (%rcx)
	leaq	64(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	leaq	48(%rsp), %r14
	leaq	32(%rsp), %r15
	leaq	16(%rsp), %r12
	leaq	8(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z9reduccionPdi, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$96, %rsp
	.cfi_adjust_cfa_offset -96
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end1:
	.size	_Z24__device_stub__reduccionPdi, .Lfunc_end1-_Z24__device_stub__reduccionPdi
	.cfi_endproc
                                        # -- End function
	.globl	_Z24__device_stub__pre_sigmaPdid # -- Begin function _Z24__device_stub__pre_sigmaPdid
	.type	_Z24__device_stub__pre_sigmaPdid,@function
_Z24__device_stub__pre_sigmaPdid:       # @_Z24__device_stub__pre_sigmaPdid
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$112, %rsp
	.cfi_def_cfa_offset 160
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	12(%rsp), %rcx
	movl	%esi, (%rcx)
	leaq	32(%rsp), %rdx
	movsd	%xmm0, (%rdx)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	movq	%rdx, 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	$_Z9pre_sigmaPdid, %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	_Z24__device_stub__pre_sigmaPdid, .Lfunc_end2-_Z24__device_stub__pre_sigmaPdid
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0                          # -- Begin function main
.LCPI3_0:
	.long	1127219200                      # 0x43300000
	.long	1160773632                      # 0x45300000
	.long	0                               # 0x0
	.long	0                               # 0x0
.LCPI3_1:
	.quad	0x4330000000000000              # double 4503599627370496
	.quad	0x4530000000000000              # double 1.9342813113834067E+25
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0
.LCPI3_2:
	.quad	0x412e848000000000              # double 1.0E+6
.LCPI3_3:
	.quad	0x408f400000000000              # double 1000
	.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	$56, %rsp
	.cfi_def_cfa_offset 112
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	$0, (%rsp)
	movl	$16, %ebp
	cmpl	$2, %edi
	jl	.LBB3_1
# %bb.2:
	movq	%rsi, %rbx
	movl	%edi, %r14d
	movq	8(%rsi), %rdi
	callq	atoi
	movl	%eax, 16(%rsp)                  # 4-byte Spill
	movslq	%eax, %r12
	cmpl	$2, %r14d
	je	.LBB3_3
# %bb.4:
	movq	16(%rbx), %rdi
	callq	atoi
	movl	%eax, %ebp
	cmpl	$4, %r14d
	jb	.LBB3_3
# %bb.5:
	movq	24(%rbx), %rax
	cmpb	$118, (%rax)
	sete	%r15b
	jmp	.LBB3_6
.LBB3_1:
	movl	$1024, %r12d                    # imm = 0x400
	movl	$1024, 16(%rsp)                 # 4-byte Folded Spill
                                        # imm = 0x400
.LBB3_3:
	xorl	%r15d, %r15d
.LBB3_6:                                # %.thread112
	leaq	(,%r12,8), %rbx
	movq	%rbx, %rdi
	callq	malloc
	movq	%rax, %r13
	movq	%rbx, 8(%rsp)                   # 8-byte Spill
	movq	%rbx, %rdi
	callq	malloc
	movq	%rax, 24(%rsp)                  # 8-byte Spill
	testq	%r12, %r12
	je	.LBB3_11
# %bb.7:                                # %.lr.ph.preheader
	movl	$1, %ebx
	xorl	%r14d, %r14d
.LBB3_8:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	callq	rand
	cltq
	imulq	$1717986919, %rax, %rcx         # imm = 0x66666667
	movq	%rcx, %rdx
	shrq	$63, %rdx
	sarq	$34, %rcx
	addl	%edx, %ecx
	addl	%ecx, %ecx
	leal	(%rcx,%rcx,4), %ecx
	subl	%ecx, %eax
	xorps	%xmm0, %xmm0
	cvtsi2sd	%eax, %xmm0
	movsd	%xmm0, (%r13,%r14,8)
	movq	24(%rsp), %rax                  # 8-byte Reload
	movsd	%xmm0, (%rax,%r14,8)
	testb	%r15b, %r15b
	je	.LBB3_10
# %bb.9:                                #   in Loop: Header=BB3_8 Depth=1
	movl	$.L.str.2, %edi
	movb	$1, %al
	callq	printf
.LBB3_10:                               #   in Loop: Header=BB3_8 Depth=1
	movl	%ebx, %r14d
	incl	%ebx
	cmpq	%r14, %r12
	ja	.LBB3_8
.LBB3_11:                               # %._crit_edge
	movl	%r15d, 20(%rsp)                 # 4-byte Spill
	movl	$10, %edi
	callq	putchar@PLT
	movq	%rsp, %rbx
	movq	%rbx, %rdi
	movq	8(%rsp), %r14                   # 8-byte Reload
	movq	%r14, %rsi
	callq	hipMalloc
	movq	(%rbx), %rdi
	movq	%r13, 48(%rsp)                  # 8-byte Spill
	movq	%r13, %rsi
	movq	%r14, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	callq	clock
	movq	%rax, 40(%rsp)                  # 8-byte Spill
	movl	%ebp, %r14d
	movq	%r14, %rbp
	btsq	$32, %rbp
	leaq	-1(%r14), %r13
	cmpq	$2, %r12
	jb	.LBB3_16
# %bb.12:
	movq	%r12, %rbx
	movq	%r12, %r15
.LBB3_13:                               # %.lr.ph117
                                        # =>This Inner Loop Header: Depth=1
	shrq	%r15
	leaq	(%r15,%r13), %rax
	xorl	%edx, %edx
	divq	%r14
	movl	%eax, %edi
	movabsq	$4294967296, %rax               # imm = 0x100000000
	orq	%rax, %rdi
	movl	$1, %esi
	movq	%rbp, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB3_15
# %bb.14:                               #   in Loop: Header=BB3_13 Depth=1
	movq	(%rsp), %rdi
	movl	%ebx, %esi
	callq	_Z24__device_stub__reduccionPdi
.LBB3_15:                               #   in Loop: Header=BB3_13 Depth=1
	callq	hipDeviceSynchronize
	cmpq	$3, %rbx
	movq	%r15, %rbx
	ja	.LBB3_13
.LBB3_16:                               # %._crit_edge118
	movq	(%rsp), %rsi
	movq	24(%rsp), %r15                  # 8-byte Reload
	movq	%r15, %rdi
	movq	8(%rsp), %rbx                   # 8-byte Reload
	movq	%rbx, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	movq	%r12, %xmm0
	punpckldq	.LCPI3_0(%rip), %xmm0   # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
	movsd	(%r15), %xmm2                   # xmm2 = mem[0],zero
	subpd	.LCPI3_1(%rip), %xmm0
	movapd	%xmm0, %xmm1
	unpckhpd	%xmm0, %xmm1                    # xmm1 = xmm1[1],xmm0[1]
	addsd	%xmm0, %xmm1
	divsd	%xmm1, %xmm2
	movsd	%xmm2, 32(%rsp)                 # 8-byte Spill
	movq	(%rsp), %rdi
	movq	48(%rsp), %rsi                  # 8-byte Reload
	movq	%rbx, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	leaq	(%r12,%r13), %rax
	xorl	%edx, %edx
	divq	%r14
	movl	%eax, %edx
	movabsq	$4294967296, %rax               # imm = 0x100000000
	orq	%rax, %rdx
	movq	%rbp, %rdi
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB3_18
# %bb.17:
	movq	(%rsp), %rdi
	movl	16(%rsp), %esi                  # 4-byte Reload
	movsd	32(%rsp), %xmm0                 # 8-byte Reload
                                        # xmm0 = mem[0],zero
	callq	_Z24__device_stub__pre_sigmaPdid
.LBB3_18:
	callq	hipDeviceSynchronize
	movq	(%rsp), %rsi
	movq	%r15, %rdi
	movq	%rbx, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	cmpb	$0, 20(%rsp)                    # 1-byte Folded Reload
	je	.LBB3_23
# %bb.19:
	movl	$.L.str.4, %edi
	movsd	32(%rsp), %xmm0                 # 8-byte Reload
                                        # xmm0 = mem[0],zero
	movb	$1, %al
	callq	printf
	testq	%r12, %r12
	je	.LBB3_22
# %bb.20:                               # %.lr.ph121.preheader
	movl	$1, %ebx
	xorl	%eax, %eax
.LBB3_21:                               # %.lr.ph121
                                        # =>This Inner Loop Header: Depth=1
	movsd	(%r15,%rax,8), %xmm0            # xmm0 = mem[0],zero
	movl	$.L.str.2, %edi
	movb	$1, %al
	callq	printf
	movl	%ebx, %eax
	incl	%ebx
	cmpq	%rax, %r12
	ja	.LBB3_21
.LBB3_22:                               # %._crit_edge122
	movl	$10, %edi
	callq	putchar@PLT
.LBB3_23:
	cmpq	$2, %r12
	jb	.LBB3_28
# %bb.24:                               # %.lr.ph125.preheader
	movq	%r12, %rbx
	movq	%r12, %r15
.LBB3_25:                               # %.lr.ph125
                                        # =>This Inner Loop Header: Depth=1
	shrq	%r15
	leaq	(%r15,%r13), %rax
	xorl	%edx, %edx
	divq	%r14
	movl	%eax, %edi
	movabsq	$4294967296, %rax               # imm = 0x100000000
	orq	%rax, %rdi
	movl	$1, %esi
	movq	%rbp, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB3_27
# %bb.26:                               #   in Loop: Header=BB3_25 Depth=1
	movq	(%rsp), %rdi
	movl	%ebx, %esi
	callq	_Z24__device_stub__reduccionPdi
.LBB3_27:                               #   in Loop: Header=BB3_25 Depth=1
	callq	hipDeviceSynchronize
	cmpq	$3, %rbx
	movq	%r15, %rbx
	ja	.LBB3_25
.LBB3_28:                               # %._crit_edge126
	movq	(%rsp), %rsi
	movq	24(%rsp), %r15                  # 8-byte Reload
	movq	%r15, %rdi
	movq	8(%rsp), %rdx                   # 8-byte Reload
	movl	$2, %ecx
	callq	hipMemcpy
	movl	20(%rsp), %ebp                  # 4-byte Reload
	testb	%bpl, %bpl
	je	.LBB3_30
# %bb.29:
	movsd	(%r15), %xmm0                   # xmm0 = mem[0],zero
	movl	$.L.str.5, %edi
	movb	$1, %al
	callq	printf
.LBB3_30:
	decq	%r12
	movq	%r12, %xmm1
	punpckldq	.LCPI3_0(%rip), %xmm1   # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
	subpd	.LCPI3_1(%rip), %xmm1
	movsd	(%r15), %xmm0                   # xmm0 = mem[0],zero
	movapd	%xmm1, %xmm2
	unpckhpd	%xmm1, %xmm2                    # xmm2 = xmm2[1],xmm1[1]
	addsd	%xmm1, %xmm2
	divsd	%xmm2, %xmm0
	xorpd	%xmm1, %xmm1
	ucomisd	%xmm1, %xmm0
	movq	48(%rsp), %r14                  # 8-byte Reload
	jb	.LBB3_32
# %bb.31:
	sqrtsd	%xmm0, %xmm0
	jmp	.LBB3_33
.LBB3_32:                               # %call.sqrt
	callq	sqrt
.LBB3_33:                               # %.split
	movsd	%xmm0, 8(%rsp)                  # 8-byte Spill
	movq	40(%rsp), %rbx                  # 8-byte Reload
	callq	clock
	xorps	%xmm0, %xmm0
	cvtsi2sd	%rax, %xmm0
	xorps	%xmm1, %xmm1
	cvtsi2sd	%rbx, %xmm1
	subsd	%xmm1, %xmm0
	divsd	.LCPI3_2(%rip), %xmm0
	mulsd	.LCPI3_3(%rip), %xmm0
	movl	$.L.str.6, %edi
	movb	$1, %al
	callq	printf
	movl	$.L.str.7, %edi
	movsd	8(%rsp), %xmm0                  # 8-byte Reload
                                        # xmm0 = mem[0],zero
	movb	$1, %al
	callq	printf
	callq	clock
	movq	%rax, %rbx
	movzbl	%bpl, %edx
	movq	%r14, %rdi
	movl	16(%rsp), %esi                  # 4-byte Reload
	callq	_Z10secuentialPKdib
	movsd	%xmm0, 8(%rsp)                  # 8-byte Spill
	callq	clock
	xorps	%xmm0, %xmm0
	cvtsi2sd	%rax, %xmm0
	xorps	%xmm1, %xmm1
	cvtsi2sd	%rbx, %xmm1
	subsd	%xmm1, %xmm0
	divsd	.LCPI3_2(%rip), %xmm0
	mulsd	.LCPI3_3(%rip), %xmm0
	movl	$.L.str.8, %edi
	movb	$1, %al
	callq	printf
	movl	$.L.str.9, %edi
	movsd	8(%rsp), %xmm0                  # 8-byte Reload
                                        # xmm0 = mem[0],zero
	movb	$1, %al
	callq	printf
	movq	%r14, %rdi
	callq	free
	movq	%r15, %rdi
	callq	free
	movq	(%rsp), %rdi
	callq	hipFree
	xorl	%eax, %eax
	addq	$56, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end3:
	.size	main, .Lfunc_end3-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	.LBB4_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB4_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z9reduccionPdi, %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	$_Z9pre_sigmaPdid, %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_end4:
	.size	__hip_module_ctor, .Lfunc_end4-__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	.LBB5_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
.LBB5_2:
	retq
.Lfunc_end5:
	.size	__hip_module_dtor, .Lfunc_end5-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"cpu mean %f\n"
	.size	.L.str, 13

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"cpu sigma %f\n"
	.size	.L.str.1, 14

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

	.type	_Z9pre_sigmaPdid,@object        # @_Z9pre_sigmaPdid
	.globl	_Z9pre_sigmaPdid
	.p2align	3, 0x0
_Z9pre_sigmaPdid:
	.quad	_Z24__device_stub__pre_sigmaPdid
	.size	_Z9pre_sigmaPdid, 8

	.type	.L.str.2,@object                # @.str.2
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.2:
	.asciz	"%f\t"
	.size	.L.str.2, 4

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"mean gpu: %f\n"
	.size	.L.str.4, 14

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"gpu sigma %f \n"
	.size	.L.str.5, 15

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"GPU time: %f seconds\t"
	.size	.L.str.6, 22

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"GPU result: %f\n"
	.size	.L.str.7, 16

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"CPU time: %f seconds\t"
	.size	.L.str.8, 22

	.type	.L.str.9,@object                # @.str.9
.L.str.9:
	.asciz	"CPU result: %f\n"
	.size	.L.str.9, 16

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z9reduccionPdi"
	.size	.L__unnamed_1, 16

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_Z9pre_sigmaPdid"
	.size	.L__unnamed_2, 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

	.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 _Z24__device_stub__reduccionPdi
	.addrsig_sym _Z24__device_stub__pre_sigmaPdid
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z9reduccionPdi
	.addrsig_sym _Z9pre_sigmaPdid
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z9reduccionPdi         ; -- Begin function _Z9reduccionPdi
	.globl	_Z9reduccionPdi
	.p2align	8
	.type	_Z9reduccionPdi,@function
_Z9reduccionPdi:                        ; @_Z9reduccionPdi
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x1c
	s_load_b32 s3, s[0:1], 0x8
	s_waitcnt lgkmcnt(0)
	s_and_b32 s2, s2, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_3) | instid1(SALU_CYCLE_1)
	v_mad_u64_u32 v[1:2], null, s15, s2, v[0:1]
	s_lshr_b32 s2, s3, 31
	v_mov_b32_e32 v2, 0
	s_add_i32 s3, s3, s2
	s_ashr_i32 s2, s3, 1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_ashr_i32 s3, s2, 31
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	v_cmp_gt_u64_e32 vcc_lo, s[2:3], v[1:2]
	s_and_saveexec_b32 s2, vcc_lo
	s_cbranch_execz .LBB0_2
; %bb.1:
	s_load_b64 s[0:1], s[0:1], 0x0
	v_lshlrev_b64 v[3:4], 4, v[1:2]
	v_lshlrev_b64 v[0:1], 3, v[1:2]
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_co_u32 v7, vcc_lo, s0, v3
	v_add_co_ci_u32_e32 v8, vcc_lo, s1, v4, vcc_lo
	s_delay_alu instid0(VALU_DEP_2)
	v_sub_co_u32 v0, vcc_lo, v7, v0
	global_load_b128 v[3:6], v[7:8], off
	v_sub_co_ci_u32_e32 v1, vcc_lo, v8, v1, vcc_lo
	s_waitcnt vmcnt(0)
	v_add_f64 v[3:4], v[3:4], v[5:6]
	global_store_b64 v[0:1], v[3:4], off
.LBB0_2:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z9reduccionPdi
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 272
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 9
		.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	_Z9reduccionPdi, .Lfunc_end0-_Z9reduccionPdi
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 184
; NumSgprs: 18
; NumVgprs: 9
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 9
; 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	_Z9pre_sigmaPdid        ; -- Begin function _Z9pre_sigmaPdid
	.globl	_Z9pre_sigmaPdid
	.p2align	8
	.type	_Z9pre_sigmaPdid,@function
_Z9pre_sigmaPdid:                       ; @_Z9pre_sigmaPdid
; %bb.0:
	s_clause 0x1
	s_load_b32 s3, s[0:1], 0x24
	s_load_b32 s2, s[0:1], 0x8
	s_waitcnt lgkmcnt(0)
	s_and_b32 s3, s3, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1)
	v_mad_u64_u32 v[1:2], null, s15, s3, v[0:1]
	v_mov_b32_e32 v2, 0
	s_ashr_i32 s3, s2, 31
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	v_cmp_gt_u64_e32 vcc_lo, s[2:3], v[1:2]
	s_and_saveexec_b32 s2, vcc_lo
	s_cbranch_execz .LBB1_2
; %bb.1:
	s_load_b64 s[2:3], s[0:1], 0x0
	v_lshlrev_b64 v[0:1], 3, v[1:2]
	s_load_b64 s[0:1], s[0:1], 0x10
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v0, vcc_lo, s2, v0
	v_add_co_ci_u32_e32 v1, vcc_lo, s3, v1, vcc_lo
	global_load_b64 v[2:3], v[0:1], off
	s_waitcnt vmcnt(0)
	v_add_f64 v[2:3], v[2:3], -s[0:1]
	s_delay_alu instid0(VALU_DEP_1)
	v_mul_f64 v[2:3], v[2:3], v[2:3]
	global_store_b64 v[0:1], v[2:3], off
.LBB1_2:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z9pre_sigmaPdid
		.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 4
		.amdhsa_next_free_sgpr 16
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end1:
	.size	_Z9pre_sigmaPdid, .Lfunc_end1-_Z9pre_sigmaPdid
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 164
; NumSgprs: 18
; NumVgprs: 4
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 4
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

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

	.end_amdgpu_metadata
