/* helloCUDA.cu */

/****************************************************************************/
/*                                                                          */
/*  (C) 2010 Texas Advanced Computing Center.                               */
/*                                                                          */
/*  For information, contact Frank Willmore:  willmore@tacc.utexas.edu      */
/*                                                                          */
/*  Shareable in accordance with TACC and University of Texas policies.     */
/*                                                                          */
/****************************************************************************/

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

#define BLOCKS_PER_GRID 16
#define THREADS_PER_BLOCK 16 
#define N_POPULATION 10000

__device__ char d_data_array[BLOCKS_PER_GRID * THREADS_PER_BLOCK][N_POPULATION];
__device__ int d_sum_array[BLOCKS_PER_GRID * THREADS_PER_BLOCK];
__device__ float d_mean_array[BLOCKS_PER_GRID * THREADS_PER_BLOCK];
__device__ float d_std_array[BLOCKS_PER_GRID * THREADS_PER_BLOCK];

// reduce over N_POPULATION

__global__ void calculateMean()
{
  // auto variables other than arrays are register
  int index; 
  int sum=0;
  int sample_number;

  // get the sample number for this thread
  sample_number = blockIdx.x * THREADS_PER_BLOCK + threadIdx.x;
  
  // calculate the sum for this thread
  for (index=0; index<N_POPULATION; index++) sum += d_data_array[sample_number][index];
 
  // record the sum and mean in global memory
  d_sum_array[sample_number] = sum;
  d_mean_array[sample_number] = (float)sum / N_POPULATION; 
}

// use persistent data (sum) to calculate variance
__global__ void calculateStandardDeviation()
{
  int sample_number;
  float v_sum = 0.0f;
  float delta;
  float variance;
  int index;

  // get the sample number for this thread
  sample_number = blockIdx.x * THREADS_PER_BLOCK + threadIdx.x;

  // calculate the sum for this thread
  for (index=0; index<N_POPULATION; index++)
  {
    delta = (float)d_data_array[sample_number][index] - d_mean_array[sample_number];
    v_sum += delta * delta;
  }
 
  variance = v_sum / N_POPULATION;
  d_std_array[sample_number] = sqrt(variance);
}

int main(int argc, char* argv[])
{
  int i, j;
  FILE *fptr;
  char h_data_array[BLOCKS_PER_GRID * THREADS_PER_BLOCK][N_POPULATION];
  int h_sum_array[BLOCKS_PER_GRID * THREADS_PER_BLOCK];
  float h_std_array[BLOCKS_PER_GRID * THREADS_PER_BLOCK];
  float h_mean_array[BLOCKS_PER_GRID * THREADS_PER_BLOCK];
  size_t size = sizeof(h_data_array);

  // generate an array with random data, then copy it to the device
  fptr = fopen("/dev/urandom", "r");
  fread(h_data_array, size, 1, fptr);
  fclose(fptr);

//  for (i=0; i<(BLOCKS_PER_GRID * THREADS_PER_BLOCK); i++) for (j=0; j<N_POPULATION; j++) printf("[%2d] = \t%d\n", i, h_data_array[i][j]);

  dim3 grid_dimension(BLOCKS_PER_GRID);
  dim3 block_dimension(THREADS_PER_BLOCK);
 
  /////////////////// sum //////////////////////////////////////

  cudaError_t r = cudaMemcpyToSymbol(d_data_array, h_data_array, sizeof(h_data_array), 0, cudaMemcpyHostToDevice);
  cudaThreadSynchronize(); // block until the device has completed
  assert(r == cudaSuccess);

  calculateMean<<< grid_dimension, block_dimension >>>();
  calculateMean<<< BLOCKS_PER_GRID, THREADS_PER_BLOCK >>>();
  cudaThreadSynchronize(); // block until the device has completed
  assert(r == cudaSuccess);

  r = cudaMemcpyFromSymbol(h_sum_array, d_sum_array, sizeof(h_sum_array), 0, cudaMemcpyDeviceToHost);
  cudaThreadSynchronize(); // block until the device has completed
  assert(r == cudaSuccess);

  /////////////////// standard deviation //////////////////////

//  memset(h_std_array, 0, sizeof(h_std_array));
//  r = cudaMemcpyToSymbol(d_std_array, h_std_array, sizeof(h_std_array), 0, cudaMemcpyHostToDevice);
//  cudaThreadSynchronize(); // block until the device has completed
//  assert(r == cudaSuccess);

  calculateStandardDeviation<<< grid_dimension, block_dimension >>>();
  cudaThreadSynchronize(); // block until the device has completed
  assert(r == cudaSuccess);

  r = cudaMemcpyFromSymbol(h_mean_array, d_mean_array, sizeof(h_mean_array), 0, cudaMemcpyDeviceToHost);
  cudaThreadSynchronize(); // block until the device has completed
  assert(r == cudaSuccess);

  r = cudaMemcpyFromSymbol(h_std_array, d_std_array, sizeof(h_std_array), 0, cudaMemcpyDeviceToHost);
  cudaThreadSynchronize(); // block until the device has completed
  assert(r == cudaSuccess);

  for (i=0; i< BLOCKS_PER_GRID * THREADS_PER_BLOCK; i++) printf("[%2d] = \t%d\t%f\t%f\n", i, h_sum_array[i], h_mean_array[i], h_std_array[i]);
}


	.file	"tmpxft_00220653_00000000-6_with_dim3.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2030:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2030:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z32__device_stub__Z13calculateMeanvv
	.type	_Z32__device_stub__Z13calculateMeanvv, @function
_Z32__device_stub__Z13calculateMeanvv:
.LFB2052:
	.cfi_startproc
	endbr64
	subq	$88, %rsp
	.cfi_def_cfa_offset 96
	movq	%fs:40, %rax
	movq	%rax, 72(%rsp)
	movabsq	$4294967297, %rax
	leaq	8(%rsp), %rcx
	movq	%rsp, %rdx
	leaq	28(%rsp), %rsi
	leaq	16(%rsp), %rdi
	movl	$1, 24(%rsp)
	movl	$1, 36(%rsp)
	movq	%rax, 16(%rsp)
	movq	%rax, 28(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L2
	pushq	8(%rsp)
	.cfi_def_cfa_offset 104
	leaq	_Z13calculateMeanv(%rip), %rdi
	pushq	8(%rsp)
	.cfi_def_cfa_offset 112
	movq	44(%rsp), %rcx
	movl	52(%rsp), %r8d
	movq	32(%rsp), %rsi
	movl	40(%rsp), %edx
	leaq	80(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 104
	popq	%rdx
	.cfi_def_cfa_offset 96
.L2:
	movq	72(%rsp), %rax
	subq	%fs:40, %rax
	je	.L4
	call	__stack_chk_fail@PLT
.L4:
	addq	$88, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2052:
	.size	_Z32__device_stub__Z13calculateMeanvv, .-_Z32__device_stub__Z13calculateMeanvv
	.globl	_Z13calculateMeanv
	.type	_Z13calculateMeanv, @function
_Z13calculateMeanv:
.LFB2053:
	.cfi_startproc
	endbr64
	jmp	_Z32__device_stub__Z13calculateMeanvv
	.cfi_endproc
.LFE2053:
	.size	_Z13calculateMeanv, .-_Z13calculateMeanv
	.globl	_Z45__device_stub__Z26calculateStandardDeviationvv
	.type	_Z45__device_stub__Z26calculateStandardDeviationvv, @function
_Z45__device_stub__Z26calculateStandardDeviationvv:
.LFB2054:
	.cfi_startproc
	endbr64
	subq	$88, %rsp
	.cfi_def_cfa_offset 96
	movq	%fs:40, %rax
	movq	%rax, 72(%rsp)
	movabsq	$4294967297, %rax
	leaq	8(%rsp), %rcx
	movq	%rsp, %rdx
	leaq	28(%rsp), %rsi
	leaq	16(%rsp), %rdi
	movl	$1, 24(%rsp)
	movl	$1, 36(%rsp)
	movq	%rax, 16(%rsp)
	movq	%rax, 28(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L8
	pushq	8(%rsp)
	.cfi_def_cfa_offset 104
	leaq	_Z26calculateStandardDeviationv(%rip), %rdi
	pushq	8(%rsp)
	.cfi_def_cfa_offset 112
	movq	44(%rsp), %rcx
	movl	52(%rsp), %r8d
	movq	32(%rsp), %rsi
	movl	40(%rsp), %edx
	leaq	80(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 104
	popq	%rdx
	.cfi_def_cfa_offset 96
.L8:
	movq	72(%rsp), %rax
	subq	%fs:40, %rax
	je	.L10
	call	__stack_chk_fail@PLT
.L10:
	addq	$88, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2054:
	.size	_Z45__device_stub__Z26calculateStandardDeviationvv, .-_Z45__device_stub__Z26calculateStandardDeviationvv
	.globl	_Z26calculateStandardDeviationv
	.type	_Z26calculateStandardDeviationv, @function
_Z26calculateStandardDeviationv:
.LFB2055:
	.cfi_startproc
	endbr64
	jmp	_Z45__device_stub__Z26calculateStandardDeviationvv
	.cfi_endproc
.LFE2055:
	.size	_Z26calculateStandardDeviationv, .-_Z26calculateStandardDeviationv
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"r"
.LC1:
	.string	"/dev/urandom"
.LC2:
	.string	"[%2d] = \t%d\t%f\t%f\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2027:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	leaq	-2560000(%rsp), %r11
	.cfi_def_cfa 11, 2560048
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$3136, %rsp
	.cfi_def_cfa_offset 2563184
	leaq	.LC0(%rip), %rsi
	leaq	.LC1(%rip), %rdi
	movq	%fs:40, %rax
	movq	%rax, 2563128(%rsp)
	xorl	%eax, %eax
	leaq	3128(%rsp), %rbp
	call	fopen@PLT
	movl	$1, %ecx
	movl	$2560000, %edx
	movq	%rbp, %rdi
	movq	%rax, %r8
	movl	$2560000, %esi
	movq	%rax, %rbx
	call	__fread_chk@PLT
	movq	%rbx, %rdi
	call	fclose@PLT
	movl	$268435457, %eax
	xorl	%ecx, %ecx
	movq	%rbp, %rsi
	salq	$4, %rax
	movl	$1, %r8d
	movl	$2560000, %edx
	movl	$1, 16(%rsp)
	leaq	_ZL12d_data_array(%rip), %rdi
	movq	%rax, 8(%rsp)
	movq	%rax, 20(%rsp)
	movl	$1, 28(%rsp)
	call	cudaMemcpyToSymbol@PLT
	call	cudaThreadSynchronize@PLT
	movl	28(%rsp), %ecx
	movl	16(%rsp), %esi
	xorl	%r9d, %r9d
	movq	20(%rsp), %rdx
	movq	8(%rsp), %rdi
	xorl	%r8d, %r8d
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L14
	call	_Z32__device_stub__Z13calculateMeanvv
.L14:
	movl	$268435457, %edi
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	$1, %ecx
	salq	$4, %rdi
	movl	$1, %esi
	movl	$1, 52(%rsp)
	movq	%rdi, %rdx
	movq	%rdi, 44(%rsp)
	movq	%rdi, 32(%rsp)
	movl	$1, 40(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L15
	call	_Z32__device_stub__Z13calculateMeanvv
.L15:
	call	cudaThreadSynchronize@PLT
	leaq	56(%rsp), %r12
	xorl	%ecx, %ecx
	movl	$2, %r8d
	movl	$1024, %edx
	leaq	_ZL11d_sum_array(%rip), %rsi
	movq	%r12, %rdi
	call	cudaMemcpyFromSymbol@PLT
	call	cudaThreadSynchronize@PLT
	movl	28(%rsp), %ecx
	movl	16(%rsp), %esi
	xorl	%r9d, %r9d
	movq	20(%rsp), %rdx
	movq	8(%rsp), %rdi
	xorl	%r8d, %r8d
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L16
	call	_Z45__device_stub__Z26calculateStandardDeviationvv
.L16:
	call	cudaThreadSynchronize@PLT
	leaq	2104(%rsp), %r13
	xorl	%ecx, %ecx
	xorl	%ebx, %ebx
	movl	$2, %r8d
	movl	$1024, %edx
	movq	%r13, %rdi
	leaq	_ZL12d_mean_array(%rip), %rsi
	leaq	1080(%rsp), %rbp
	call	cudaMemcpyFromSymbol@PLT
	leaq	.LC2(%rip), %r14
	call	cudaThreadSynchronize@PLT
	movl	$2, %r8d
	xorl	%ecx, %ecx
	movq	%rbp, %rdi
	movl	$1024, %edx
	leaq	_ZL11d_std_array(%rip), %rsi
	call	cudaMemcpyFromSymbol@PLT
	call	cudaThreadSynchronize@PLT
.L17:
	movl	(%r12,%rbx,4), %ecx
	movl	%ebx, %edx
	movq	%r14, %rsi
	movb	$2, %al
	cvtss2sd	0(%r13,%rbx,4), %xmm0
	cvtss2sd	0(%rbp,%rbx,4), %xmm1
	movl	$2, %edi
	incq	%rbx
	call	__printf_chk@PLT
	cmpq	$256, %rbx
	jne	.L17
	movq	2563128(%rsp), %rax
	subq	%fs:40, %rax
	je	.L18
	call	__stack_chk_fail@PLT
.L18:
	addq	$2563136, %rsp
	.cfi_def_cfa_offset 48
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2027:
	.size	main, .-main
	.section	.rodata.str1.1
.LC3:
	.string	"_Z26calculateStandardDeviationv"
.LC4:
	.string	"_Z13calculateMeanv"
.LC5:
	.string	"d_data_array"
.LC6:
	.string	"d_sum_array"
.LC7:
	.string	"d_mean_array"
.LC8:
	.string	"d_std_array"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2057:
	.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	.LC3(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z26calculateStandardDeviationv(%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	.LC4(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z13calculateMeanv(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 40
	pushq	$0
	.cfi_def_cfa_offset 48
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC5(%rip), %rdx
	movl	$2560000, %r9d
	leaq	_ZL12d_data_array(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	call	__cudaRegisterVar@PLT
	popq	%rax
	.cfi_def_cfa_offset 24
	popq	%rdx
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC6(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movq	%rdx, %rcx
	movl	$1024, %r9d
	leaq	_ZL11d_sum_array(%rip), %rsi
	call	__cudaRegisterVar@PLT
	popq	%rcx
	.cfi_def_cfa_offset 24
	popq	%rsi
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC7(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movq	%rdx, %rcx
	movl	$1024, %r9d
	leaq	_ZL12d_mean_array(%rip), %rsi
	call	__cudaRegisterVar@PLT
	popq	%rdi
	.cfi_def_cfa_offset 24
	popq	%r8
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC8(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movl	$1024, %r9d
	movq	%rdx, %rcx
	leaq	_ZL11d_std_array(%rip), %rsi
	call	__cudaRegisterVar@PLT
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	popq	%r9
	.cfi_def_cfa_offset 24
	popq	%r10
	.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
.LFE2057:
	.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
	.local	_ZL11d_std_array
	.comm	_ZL11d_std_array,1024,32
	.local	_ZL12d_mean_array
	.comm	_ZL12d_mean_array,1024,32
	.local	_ZL11d_sum_array
	.comm	_ZL11d_sum_array,1024,32
	.local	_ZL12d_data_array
	.comm	_ZL12d_data_array,2560000,32
	.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:

/* helloCUDA.cu */

/****************************************************************************/
/*                                                                          */
/*  (C) 2010 Texas Advanced Computing Center.                               */
/*                                                                          */
/*  For information, contact Frank Willmore:  willmore@tacc.utexas.edu      */
/*                                                                          */
/*  Shareable in accordance with TACC and University of Texas policies.     */
/*                                                                          */
/****************************************************************************/


#include <hip/hip_runtime.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h> 
#include <assert.h>

#define BLOCKS_PER_GRID 16
#define THREADS_PER_BLOCK 16 
#define N_POPULATION 10000

__device__ char d_data_array[BLOCKS_PER_GRID * THREADS_PER_BLOCK][N_POPULATION];
__device__ int d_sum_array[BLOCKS_PER_GRID * THREADS_PER_BLOCK];
__device__ float d_mean_array[BLOCKS_PER_GRID * THREADS_PER_BLOCK];
__device__ float d_std_array[BLOCKS_PER_GRID * THREADS_PER_BLOCK];

// reduce over N_POPULATION

__global__ void calculateMean()
{
  // auto variables other than arrays are register
  int index; 
  int sum=0;
  int sample_number;

  // get the sample number for this thread
  sample_number = blockIdx.x * THREADS_PER_BLOCK + threadIdx.x;
  
  // calculate the sum for this thread
  for (index=0; index<N_POPULATION; index++) sum += d_data_array[sample_number][index];
 
  // record the sum and mean in global memory
  d_sum_array[sample_number] = sum;
  d_mean_array[sample_number] = (float)sum / N_POPULATION; 
}

// use persistent data (sum) to calculate variance
__global__ void calculateStandardDeviation()
{
  int sample_number;
  float v_sum = 0.0f;
  float delta;
  float variance;
  int index;

  // get the sample number for this thread
  sample_number = blockIdx.x * THREADS_PER_BLOCK + threadIdx.x;

  // calculate the sum for this thread
  for (index=0; index<N_POPULATION; index++)
  {
    delta = (float)d_data_array[sample_number][index] - d_mean_array[sample_number];
    v_sum += delta * delta;
  }
 
  variance = v_sum / N_POPULATION;
  d_std_array[sample_number] = sqrt(variance);
}

int main(int argc, char* argv[])
{
  int i, j;
  FILE *fptr;
  char h_data_array[BLOCKS_PER_GRID * THREADS_PER_BLOCK][N_POPULATION];
  int h_sum_array[BLOCKS_PER_GRID * THREADS_PER_BLOCK];
  float h_std_array[BLOCKS_PER_GRID * THREADS_PER_BLOCK];
  float h_mean_array[BLOCKS_PER_GRID * THREADS_PER_BLOCK];
  size_t size = sizeof(h_data_array);

  // generate an array with random data, then copy it to the device
  fptr = fopen("/dev/urandom", "r");
  fread(h_data_array, size, 1, fptr);
  fclose(fptr);

//  for (i=0; i<(BLOCKS_PER_GRID * THREADS_PER_BLOCK); i++) for (j=0; j<N_POPULATION; j++) printf("[%2d] = \t%d\n", i, h_data_array[i][j]);

  dim3 grid_dimension(BLOCKS_PER_GRID);
  dim3 block_dimension(THREADS_PER_BLOCK);
 
  /////////////////// sum //////////////////////////////////////

  hipError_t r = hipMemcpyToSymbol(HIP_SYMBOL(d_data_array), h_data_array, sizeof(h_data_array), 0, hipMemcpyHostToDevice);
  hipDeviceSynchronize(); // block until the device has completed
  assert(r == hipSuccess);

  calculateMean<<< grid_dimension, block_dimension >>>();
  calculateMean<<< BLOCKS_PER_GRID, THREADS_PER_BLOCK >>>();
  hipDeviceSynchronize(); // block until the device has completed
  assert(r == hipSuccess);

  r = hipMemcpyFromSymbol(h_sum_array, HIP_SYMBOL(d_sum_array), sizeof(h_sum_array), 0, hipMemcpyDeviceToHost);
  hipDeviceSynchronize(); // block until the device has completed
  assert(r == hipSuccess);

  /////////////////// standard deviation //////////////////////

//  memset(h_std_array, 0, sizeof(h_std_array));
//  r = cudaMemcpyToSymbol(d_std_array, h_std_array, sizeof(h_std_array), 0, cudaMemcpyHostToDevice);
//  cudaThreadSynchronize(); // block until the device has completed
//  assert(r == cudaSuccess);

  calculateStandardDeviation<<< grid_dimension, block_dimension >>>();
  hipDeviceSynchronize(); // block until the device has completed
  assert(r == hipSuccess);

  r = hipMemcpyFromSymbol(h_mean_array, HIP_SYMBOL(d_mean_array), sizeof(h_mean_array), 0, hipMemcpyDeviceToHost);
  hipDeviceSynchronize(); // block until the device has completed
  assert(r == hipSuccess);

  r = hipMemcpyFromSymbol(h_std_array, HIP_SYMBOL(d_std_array), sizeof(h_std_array), 0, hipMemcpyDeviceToHost);
  hipDeviceSynchronize(); // block until the device has completed
  assert(r == hipSuccess);

  for (i=0; i< BLOCKS_PER_GRID * THREADS_PER_BLOCK; i++) printf("[%2d] = \t%d\t%f\t%f\n", i, h_sum_array[i], h_mean_array[i], h_std_array[i]);
}


	.text
	.file	"with_dim3.hip"
	.globl	_Z28__device_stub__calculateMeanv # -- Begin function _Z28__device_stub__calculateMeanv
	.type	_Z28__device_stub__calculateMeanv,@function
_Z28__device_stub__calculateMeanv:      # @_Z28__device_stub__calculateMeanv
	.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
	subq	$56, %rsp
	.cfi_def_cfa_offset 96
	.cfi_offset %rbx, -40
	.cfi_offset %r12, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rbx
	leaq	24(%rsp), %r14
	leaq	16(%rsp), %r15
	leaq	8(%rsp), %r12
	movq	%rbx, %rdi
	movq	%r14, %rsi
	movq	%r15, %rdx
	movq	%r12, %rcx
	callq	__hipPopCallConfiguration
	movq	(%rbx), %rsi
	movl	8(%rbx), %edx
	movq	(%r14), %rcx
	movl	8(%r14), %r8d
	movq	%rsp, %r9
	movl	$_Z13calculateMeanv, %edi
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	pushq	(%r15)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$72, %rsp
	.cfi_adjust_cfa_offset -72
	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_end0:
	.size	_Z28__device_stub__calculateMeanv, .Lfunc_end0-_Z28__device_stub__calculateMeanv
	.cfi_endproc
                                        # -- End function
	.globl	_Z41__device_stub__calculateStandardDeviationv # -- Begin function _Z41__device_stub__calculateStandardDeviationv
	.type	_Z41__device_stub__calculateStandardDeviationv,@function
_Z41__device_stub__calculateStandardDeviationv: # @_Z41__device_stub__calculateStandardDeviationv
	.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
	subq	$56, %rsp
	.cfi_def_cfa_offset 96
	.cfi_offset %rbx, -40
	.cfi_offset %r12, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rbx
	leaq	24(%rsp), %r14
	leaq	16(%rsp), %r15
	leaq	8(%rsp), %r12
	movq	%rbx, %rdi
	movq	%r14, %rsi
	movq	%r15, %rdx
	movq	%r12, %rcx
	callq	__hipPopCallConfiguration
	movq	(%rbx), %rsi
	movl	8(%rbx), %edx
	movq	(%r14), %rcx
	movl	8(%r14), %r8d
	movq	%rsp, %r9
	movl	$_Z26calculateStandardDeviationv, %edi
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	pushq	(%r15)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$72, %rsp
	.cfi_adjust_cfa_offset -72
	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_end1:
	.size	_Z41__device_stub__calculateStandardDeviationv, .Lfunc_end1-_Z41__device_stub__calculateStandardDeviationv
	.cfi_endproc
                                        # -- End function
	.globl	main                            # -- Begin function main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	subq	$2563072, %rsp                  # imm = 0x271C00
	.cfi_def_cfa_offset 2563104
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movabsq	$4294967312, %rbx               # imm = 0x100000010
	movl	$.L.str, %edi
	movl	$.L.str.1, %esi
	callq	fopen
	movq	%rax, %r14
	leaq	3072(%rsp), %r15
	movl	$2560000, %esi                  # imm = 0x271000
	movl	$1, %edx
	movq	%r15, %rdi
	movq	%rax, %rcx
	callq	fread
	movq	%r14, %rdi
	callq	fclose
	movl	$d_data_array, %edi
	movl	$2560000, %edx                  # imm = 0x271000
	movq	%r15, %rsi
	xorl	%ecx, %ecx
	movl	$1, %r8d
	callq	hipMemcpyToSymbol
	callq	hipDeviceSynchronize
	movq	%rbx, %rdi
	movl	$1, %esi
	movq	%rbx, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB2_2
# %bb.1:
	callq	_Z28__device_stub__calculateMeanv
.LBB2_2:
	movq	%rbx, %rdi
	movl	$1, %esi
	movq	%rbx, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB2_4
# %bb.3:
	callq	_Z28__device_stub__calculateMeanv
.LBB2_4:
	callq	hipDeviceSynchronize
	leaq	2048(%rsp), %rdi
	movl	$d_sum_array, %esi
	movl	$1024, %edx                     # imm = 0x400
	xorl	%ecx, %ecx
	movl	$2, %r8d
	callq	hipMemcpyFromSymbol
	callq	hipDeviceSynchronize
	movq	%rbx, %rdi
	movl	$1, %esi
	movq	%rbx, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB2_6
# %bb.5:
	callq	_Z41__device_stub__calculateStandardDeviationv
.LBB2_6:
	callq	hipDeviceSynchronize
	xorl	%ebx, %ebx
	movq	%rsp, %rdi
	movl	$d_mean_array, %esi
	movl	$1024, %edx                     # imm = 0x400
	xorl	%ecx, %ecx
	movl	$2, %r8d
	callq	hipMemcpyFromSymbol
	callq	hipDeviceSynchronize
	leaq	1024(%rsp), %rdi
	movl	$d_std_array, %esi
	movl	$1024, %edx                     # imm = 0x400
	xorl	%ecx, %ecx
	movl	$2, %r8d
	callq	hipMemcpyFromSymbol
	callq	hipDeviceSynchronize
.LBB2_7:                                # =>This Inner Loop Header: Depth=1
	movl	2048(%rsp,%rbx,4), %edx
	xorps	%xmm0, %xmm0
	cvtss2sd	(%rsp,%rbx,4), %xmm0
	xorps	%xmm1, %xmm1
	cvtss2sd	1024(%rsp,%rbx,4), %xmm1
	movl	$.L.str.2, %edi
	movl	%ebx, %esi
	movb	$2, %al
	callq	printf
	incq	%rbx
	cmpq	$256, %rbx                      # imm = 0x100
	jne	.LBB2_7
# %bb.8:
	xorl	%eax, %eax
	addq	$2563072, %rsp                  # imm = 0x271C00
	.cfi_def_cfa_offset 32
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end2:
	.size	main, .Lfunc_end2-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
	.cfi_offset %rbx, -16
	movq	__hip_gpubin_handle(%rip), %rbx
	testq	%rbx, %rbx
	jne	.LBB3_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB3_2:
	subq	$32, %rsp
	.cfi_adjust_cfa_offset 32
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z13calculateMeanv, %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	$_Z26calculateStandardDeviationv, %esi
	movl	$.L__unnamed_2, %edx
	movl	$.L__unnamed_2, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	addq	$32, %rsp
	.cfi_adjust_cfa_offset -32
	movl	$d_data_array, %esi
	movl	$.L__unnamed_3, %edx
	movl	$.L__unnamed_3, %ecx
	movl	$2560000, %r9d                  # imm = 0x271000
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	pushq	$0
	.cfi_adjust_cfa_offset 8
	pushq	$0
	.cfi_adjust_cfa_offset 8
	callq	__hipRegisterVar
	addq	$16, %rsp
	.cfi_adjust_cfa_offset -16
	movl	$d_sum_array, %esi
	movl	$.L__unnamed_4, %edx
	movl	$.L__unnamed_4, %ecx
	movl	$1024, %r9d                     # imm = 0x400
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	pushq	$0
	.cfi_adjust_cfa_offset 8
	pushq	$0
	.cfi_adjust_cfa_offset 8
	callq	__hipRegisterVar
	addq	$16, %rsp
	.cfi_adjust_cfa_offset -16
	movl	$d_mean_array, %esi
	movl	$.L__unnamed_5, %edx
	movl	$.L__unnamed_5, %ecx
	movl	$1024, %r9d                     # imm = 0x400
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	pushq	$0
	.cfi_adjust_cfa_offset 8
	pushq	$0
	.cfi_adjust_cfa_offset 8
	callq	__hipRegisterVar
	addq	$16, %rsp
	.cfi_adjust_cfa_offset -16
	movl	$d_std_array, %esi
	movl	$.L__unnamed_6, %edx
	movl	$.L__unnamed_6, %ecx
	movl	$1024, %r9d                     # imm = 0x400
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	pushq	$0
	.cfi_adjust_cfa_offset 8
	pushq	$0
	.cfi_adjust_cfa_offset 8
	callq	__hipRegisterVar
	addq	$16, %rsp
	.cfi_adjust_cfa_offset -16
	movl	$__hip_module_dtor, %edi
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_end3:
	.size	__hip_module_ctor, .Lfunc_end3-__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	.LBB4_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
.LBB4_2:
	retq
.Lfunc_end4:
	.size	__hip_module_dtor, .Lfunc_end4-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	d_data_array,@object            # @d_data_array
	.local	d_data_array
	.comm	d_data_array,2560000,16
	.type	d_sum_array,@object             # @d_sum_array
	.local	d_sum_array
	.comm	d_sum_array,1024,16
	.type	d_mean_array,@object            # @d_mean_array
	.local	d_mean_array
	.comm	d_mean_array,1024,16
	.type	d_std_array,@object             # @d_std_array
	.local	d_std_array
	.comm	d_std_array,1024,16
	.type	_Z13calculateMeanv,@object      # @_Z13calculateMeanv
	.section	.rodata,"a",@progbits
	.globl	_Z13calculateMeanv
	.p2align	3, 0x0
_Z13calculateMeanv:
	.quad	_Z28__device_stub__calculateMeanv
	.size	_Z13calculateMeanv, 8

	.type	_Z26calculateStandardDeviationv,@object # @_Z26calculateStandardDeviationv
	.globl	_Z26calculateStandardDeviationv
	.p2align	3, 0x0
_Z26calculateStandardDeviationv:
	.quad	_Z41__device_stub__calculateStandardDeviationv
	.size	_Z26calculateStandardDeviationv, 8

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"/dev/urandom"
	.size	.L.str, 13

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"r"
	.size	.L.str.1, 2

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"[%2d] = \t%d\t%f\t%f\n"
	.size	.L.str.2, 19

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z13calculateMeanv"
	.size	.L__unnamed_1, 19

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_Z26calculateStandardDeviationv"
	.size	.L__unnamed_2, 32

	.type	.L__unnamed_3,@object           # @2
.L__unnamed_3:
	.asciz	"d_data_array"
	.size	.L__unnamed_3, 13

	.type	.L__unnamed_4,@object           # @3
.L__unnamed_4:
	.asciz	"d_sum_array"
	.size	.L__unnamed_4, 12

	.type	.L__unnamed_5,@object           # @4
.L__unnamed_5:
	.asciz	"d_mean_array"
	.size	.L__unnamed_5, 13

	.type	.L__unnamed_6,@object           # @5
.L__unnamed_6:
	.asciz	"d_std_array"
	.size	.L__unnamed_6, 12

	.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 _Z28__device_stub__calculateMeanv
	.addrsig_sym _Z41__device_stub__calculateStandardDeviationv
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym d_data_array
	.addrsig_sym d_sum_array
	.addrsig_sym d_mean_array
	.addrsig_sym d_std_array
	.addrsig_sym _Z13calculateMeanv
	.addrsig_sym _Z26calculateStandardDeviationv
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z13calculateMeanv      ; -- Begin function _Z13calculateMeanv
	.globl	_Z13calculateMeanv
	.p2align	8
	.type	_Z13calculateMeanv,@function
_Z13calculateMeanv:                     ; @_Z13calculateMeanv
; %bb.0:
	v_lshl_add_u32 v0, s15, 4, v0
	s_getpc_b64 s[0:1]
	s_add_u32 s0, s0, d_data_array@rel32@lo+4
	s_addc_u32 s1, s1, d_data_array@rel32@hi+12
	v_mov_b32_e32 v4, 0
	v_mad_i64_i32 v[2:3], null, 0x2710, v0, s[0:1]
	v_ashrrev_i32_e32 v1, 31, v0
	s_mov_b64 s[0:1], 0
.LBB0_1:                                ; =>This Inner Loop Header: Depth=1
	s_delay_alu instid0(VALU_DEP_2) | instid1(SALU_CYCLE_1)
	v_add_co_u32 v5, vcc_lo, v2, s0
	s_delay_alu instid0(VALU_DEP_3)
	v_add_co_ci_u32_e32 v6, vcc_lo, s1, v3, vcc_lo
	s_add_u32 s0, s0, 1
	s_addc_u32 s1, s1, 0
	s_cmpk_lg_i32 s0, 0x2710
	global_load_i8 v5, v[5:6], off
	s_waitcnt vmcnt(0)
	v_add_nc_u32_e32 v4, v4, v5
	s_cbranch_scc1 .LBB0_1
; %bb.2:
	s_delay_alu instid0(VALU_DEP_1)
	v_cvt_f32_i32_e32 v5, v4
	v_lshlrev_b64 v[0:1], 2, v[0:1]
	s_getpc_b64 s[0:1]
	s_add_u32 s0, s0, d_sum_array@rel32@lo+4
	s_addc_u32 s1, s1, d_sum_array@rel32@hi+12
	s_getpc_b64 s[2:3]
	s_add_u32 s2, s2, d_mean_array@rel32@lo+4
	s_addc_u32 s3, s3, d_mean_array@rel32@hi+12
	v_div_scale_f32 v2, null, 0x461c4000, 0x461c4000, v5
	v_div_scale_f32 v7, vcc_lo, v5, 0x461c4000, v5
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	v_rcp_f32_e32 v3, v2
	s_waitcnt_depctr 0xfff
	v_fma_f32 v6, -v2, v3, 1.0
	v_fmac_f32_e32 v3, v6, v3
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_f32_e32 v6, v7, v3
	v_fma_f32 v8, -v2, v6, v7
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fmac_f32_e32 v6, v8, v3
	v_fma_f32 v2, -v2, v6, v7
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_3) | instid1(VALU_DEP_4)
	v_div_fmas_f32 v6, v2, v3, v6
	v_add_co_u32 v2, vcc_lo, v0, s0
	v_add_co_ci_u32_e32 v3, vcc_lo, s1, v1, vcc_lo
	v_add_co_u32 v0, vcc_lo, v0, s2
	v_div_fixup_f32 v5, v6, 0x461c4000, v5
	v_add_co_ci_u32_e32 v1, vcc_lo, s3, v1, vcc_lo
	global_store_b32 v[2:3], v4, off
	global_store_b32 v[0:1], v5, off
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z13calculateMeanv
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 0
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 0
		.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	_Z13calculateMeanv, .Lfunc_end0-_Z13calculateMeanv
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 316
; 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	_Z26calculateStandardDeviationv ; -- Begin function _Z26calculateStandardDeviationv
	.globl	_Z26calculateStandardDeviationv
	.p2align	8
	.type	_Z26calculateStandardDeviationv,@function
_Z26calculateStandardDeviationv:        ; @_Z26calculateStandardDeviationv
; %bb.0:
	v_lshl_add_u32 v4, s15, 4, v0
	s_getpc_b64 s[0:1]
	s_add_u32 s0, s0, d_mean_array@rel32@lo+4
	s_addc_u32 s1, s1, d_mean_array@rel32@hi+12
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v5, 31, v4
	v_lshlrev_b64 v[0:1], 2, v[4:5]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v2, vcc_lo, v0, s0
	v_add_co_ci_u32_e32 v3, vcc_lo, s1, v1, vcc_lo
	s_getpc_b64 s[0:1]
	s_add_u32 s0, s0, d_data_array@rel32@lo+4
	s_addc_u32 s1, s1, d_data_array@rel32@hi+12
	global_load_b32 v5, v[2:3], off
	v_mad_i64_i32 v[2:3], null, 0x2710, v4, s[0:1]
	v_mov_b32_e32 v4, 0
	s_mov_b64 s[0:1], 0
.LBB1_1:                                ; =>This Inner Loop Header: Depth=1
	s_delay_alu instid0(VALU_DEP_2) | instid1(SALU_CYCLE_1)
	v_add_co_u32 v6, vcc_lo, v2, s0
	s_delay_alu instid0(VALU_DEP_3)
	v_add_co_ci_u32_e32 v7, vcc_lo, s1, v3, vcc_lo
	s_add_u32 s0, s0, 1
	s_addc_u32 s1, s1, 0
	s_cmpk_lg_i32 s0, 0x2710
	global_load_i8 v6, v[6:7], off
	s_waitcnt vmcnt(0)
	v_cvt_f32_i32_e32 v6, v6
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_sub_f32_e32 v6, v6, v5
	v_fmac_f32_e32 v4, v6, v6
	s_cbranch_scc1 .LBB1_1
; %bb.2:
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_div_scale_f32 v2, null, 0x461c4000, 0x461c4000, v4
	v_div_scale_f32 v6, vcc_lo, v4, 0x461c4000, v4
	v_rcp_f32_e32 v3, v2
	s_waitcnt_depctr 0xfff
	v_fma_f32 v5, -v2, v3, 1.0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fmac_f32_e32 v3, v5, v3
	v_mul_f32_e32 v5, v6, v3
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f32 v7, -v2, v5, v6
	v_fmac_f32_e32 v5, v7, v3
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f32 v2, -v2, v5, v6
	v_div_fmas_f32 v2, v2, v3, v5
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_div_fixup_f32 v2, v2, 0x461c4000, v4
	v_mul_f32_e32 v3, 0x4f800000, v2
	v_cmp_gt_f32_e32 vcc_lo, 0xf800000, v2
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cndmask_b32_e32 v2, v2, v3, vcc_lo
	v_sqrt_f32_e32 v3, v2
	s_waitcnt_depctr 0xfff
	v_add_nc_u32_e32 v4, -1, v3
	v_add_nc_u32_e32 v5, 1, v3
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_fma_f32 v6, -v4, v3, v2
	v_fma_f32 v7, -v5, v3, v2
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cmp_ge_f32_e64 s0, 0, v6
	v_cndmask_b32_e64 v3, v3, v4, s0
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cmp_lt_f32_e64 s0, 0, v7
	v_cndmask_b32_e64 v3, v3, v5, s0
	s_getpc_b64 s[0:1]
	s_add_u32 s0, s0, d_std_array@rel32@lo+4
	s_addc_u32 s1, s1, d_std_array@rel32@hi+12
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_f32_e32 v4, 0x37800000, v3
	v_cndmask_b32_e32 v3, v3, v4, vcc_lo
	v_cmp_class_f32_e64 vcc_lo, v2, 0x260
	s_delay_alu instid0(VALU_DEP_2)
	v_cndmask_b32_e32 v2, v3, v2, vcc_lo
	v_add_co_u32 v0, vcc_lo, v0, s0
	v_add_co_ci_u32_e32 v1, vcc_lo, s1, v1, vcc_lo
	global_store_b32 v[0:1], v2, off
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z26calculateStandardDeviationv
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 0
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 0
		.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 8
		.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	_Z26calculateStandardDeviationv, .Lfunc_end1-_Z26calculateStandardDeviationv
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 468
; NumSgprs: 18
; NumVgprs: 8
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 8
; 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
	.protected	d_data_array            ; @d_data_array
	.type	d_data_array,@object
	.section	.bss,"aw",@nobits
	.globl	d_data_array
	.p2align	4, 0x0
d_data_array:
	.zero	2560000
	.size	d_data_array, 2560000

	.protected	d_sum_array             ; @d_sum_array
	.type	d_sum_array,@object
	.globl	d_sum_array
	.p2align	4, 0x0
d_sum_array:
	.zero	1024
	.size	d_sum_array, 1024

	.protected	d_mean_array            ; @d_mean_array
	.type	d_mean_array,@object
	.globl	d_mean_array
	.p2align	4, 0x0
d_mean_array:
	.zero	1024
	.size	d_mean_array, 1024

	.protected	d_std_array             ; @d_std_array
	.type	d_std_array,@object
	.globl	d_std_array
	.p2align	4, 0x0
d_std_array:
	.zero	1024
	.size	d_std_array, 1024

	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.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 d_data_array
	.addrsig_sym d_sum_array
	.addrsig_sym d_mean_array
	.addrsig_sym d_std_array
	.addrsig_sym __hip_cuid_
	.amdgpu_metadata
---
amdhsa.kernels:
  - .args:           []
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 4
    .kernarg_segment_size: 0
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z13calculateMeanv
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z13calculateMeanv.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:           []
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 4
    .kernarg_segment_size: 0
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z26calculateStandardDeviationv
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z26calculateStandardDeviationv.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     8
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
