// example of using CUDA streams

#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <chrono>
#include <math.h>
#include <fstream>
using namespace std::chrono;

#define BLOCK_SIZE 256

void initWithNoStream(float num, float *a, int N)
{

  for(int i = 0; i < N; ++i)
  {
    a[i] = num;
  }
}

__global__
void reduceVector(float *g_data, int N) {
  __shared__ float sdata[2*BLOCK_SIZE];

  unsigned int tid = threadIdx.x;
  unsigned int i = blockIdx.x * 2 * blockDim.x + threadIdx.x;
  unsigned int gridStride = 2 * blockDim.x * gridDim.x;
  sdata[tid] = 0;
  while (i < N) {
	  sdata[tid] += g_data[i] + g_data[i + blockDim.x];
	  i += gridStride;
  }
  for(unsigned j = blockDim.x / 2; j > 32; j >>= 1) {
	  __syncthreads();
	  if (tid < j) {
		sdata[tid] += sdata[tid + j];
	  }
	}
  //printf("tid %d i %d blockIdx.x %d sdata[%d] %f\n", tid, i, blockIdx.x, tid, sdata[tid]);

  __syncthreads();
//
  if(tid < 32) {
	  sdata[tid] += sdata[tid + 32];
	  sdata[tid] += sdata[tid + 16];
	  sdata[tid] += sdata[tid + 8];
	  sdata[tid] += sdata[tid + 4];
	  sdata[tid] += sdata[tid + 2];
	  sdata[tid] += sdata[tid + 1];
  }
  if (tid == 0) g_data[blockIdx.x] = sdata[0];
}

__global__
void reduceVector_naive(float *g_data, int N) {
  __shared__ float sdata[2*BLOCK_SIZE];

  unsigned int tid = threadIdx.x;
  unsigned int i = blockIdx.x * 2 * blockDim.x + threadIdx.x;
  sdata[tid] = g_data[i];
  sdata[blockDim.x+tid] = g_data[i + blockDim.x];


  for(unsigned int j = 1; j <= blockDim.x; j *= 2) {
    __syncthreads();
    if (tid % j == 0) {
      sdata[2*tid] += sdata[2*tid + j];
    }
  }

  __syncthreads();
  if (tid == 0) g_data[blockIdx.x] = sdata[tid];
}

int main(int argc, char** argv)
{
  int in_s = 14;
  char* pEnd;
  if (!in_s && argc < 2) {
    printf("Podaj liczbe która będzie przesunięciem 2 które jest rozmiarem\n");
    return 1;
  } else if(!in_s) {
	  in_s = strtol(argv[1], &pEnd, 10);
  }
  int deviceId;
  int numberOfSMs;

  cudaGetDevice(&deviceId);
  cudaDeviceGetAttribute(&numberOfSMs, cudaDevAttrMultiProcessorCount, deviceId);

  std::ofstream host_file, device_file, device_naive_file;
  host_file.open ("reduction_host.txt");
  device_file.open ("reduction_device.txt");
  device_naive_file.open ("reduction__device_naive.txt");

  for(int in_s = 14; in_s < 27; in_s++) {
	  const int N = 2<<in_s;
	  host_file << N;
	  device_file << N;
	  device_naive_file << N;
	  size_t size = N * sizeof(float);


	  size_t threads;
	  size_t blocks;

	  threads = BLOCK_SIZE;
	  blocks = N / threads / 2;

	  printf("threads %d blocks %d\n", threads, blocks);

	  cudaError_t addVectorsErr;
	  cudaError_t asyncErr;

	  for(int k = 0; k < 10; k++) {
		  float *a;
		  float *b;
		  float *c;

		  cudaMallocManaged(&b, size);
		  cudaMallocManaged(&a, size);
		  cudaMallocManaged(&c, size);

		  initWithNoStream(1, a, N);
		  initWithNoStream(1, b, N);
		  initWithNoStream(1, c, N);

		  cudaMemPrefetchAsync(a, size, deviceId);
		  cudaMemPrefetchAsync(b, size, deviceId);
		  asyncErr = cudaDeviceSynchronize();
			if(asyncErr != cudaSuccess) printf("Device sync Error: %s\n", cudaGetErrorString(asyncErr));

		  auto start = high_resolution_clock::now();
		  reduceVector<<<32 * numberOfSMs, threads>>>(a, N);

		  cudaMemPrefetchAsync(a, size, cudaCpuDeviceId);
		  asyncErr = cudaDeviceSynchronize();
		  if(asyncErr != cudaSuccess) printf("Device sync Error: %s\n", cudaGetErrorString(asyncErr));

		  for(int i = 1; i < 32 * numberOfSMs; i++) {
				a[0] += a[i];
			  }
		  auto stop = high_resolution_clock::now();
		  auto duration = duration_cast<microseconds>(stop - start);
		  std::cout<< "Reduction time in us: " << duration.count()<< std::endl;
		  device_file << "\t" << duration.count();

		  addVectorsErr = cudaGetLastError();
		  if(addVectorsErr != cudaSuccess) printf("Reduction Error: %s\n", cudaGetErrorString(addVectorsErr));


		  start = high_resolution_clock::now();
		  reduceVector_naive<<<blocks, threads>>>(b, N);
		  cudaMemPrefetchAsync(b, size, cudaCpuDeviceId);

		  asyncErr = cudaDeviceSynchronize();
		  if(asyncErr != cudaSuccess) printf("Device sync Error: %s\n", cudaGetErrorString(asyncErr));

		  for(int i = 1; i < blocks; i++) {
			  b[0] += b[i];
			}
		  stop = high_resolution_clock::now();
		  duration = duration_cast<microseconds>(stop - start);
		  std::cout<< "Reduction (naive) time in us: " << duration.count()<< std::endl;
		  device_naive_file << "\t" << duration.count();

		  addVectorsErr = cudaGetLastError();
		  if(addVectorsErr != cudaSuccess) printf("Reduction Error: %s\n", cudaGetErrorString(addVectorsErr));

		  asyncErr = cudaDeviceSynchronize();
		  if(asyncErr != cudaSuccess) printf("Device sync Error: %s\n", cudaGetErrorString(asyncErr));


		  double result = 0;
		  start = high_resolution_clock::now();
		  for(long i = 0; i < N; i++) {
			result += c[i];
		  }
		  stop = high_resolution_clock::now();
		  duration = duration_cast<microseconds>(stop - start);
		  std::cout<< "Cpu add rest time in us: " << duration.count() << std::endl;
		  host_file << "\t" << duration.count();

		  printf("%f %f %f %d\n", a[0], b[0], result, N);

		  cudaFree(a);
		  cudaFree(b);
		  cudaFree(c);
	  }
  }
}


	.file	"tmpxft_00309e39_00000000-6_main.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB3872:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE3872:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z16initWithNoStreamfPfi
	.type	_Z16initWithNoStreamfPfi, @function
_Z16initWithNoStreamfPfi:
.LFB3865:
	.cfi_startproc
	endbr64
	xorl	%eax, %eax
.L3:
	cmpl	%eax, %esi
	jle	.L6
	movss	%xmm0, (%rdi,%rax,4)
	incq	%rax
	jmp	.L3
.L6:
	ret
	.cfi_endproc
.LFE3865:
	.size	_Z16initWithNoStreamfPfi, .-_Z16initWithNoStreamfPfi
	.globl	_Z33__device_stub__Z12reduceVectorPfiPfi
	.type	_Z33__device_stub__Z12reduceVectorPfiPfi, @function
_Z33__device_stub__Z12reduceVectorPfiPfi:
.LFB3894:
	.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	.L7
	pushq	32(%rsp)
	.cfi_def_cfa_offset 136
	leaq	_Z12reduceVectorPfi(%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
.L7:
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	je	.L9
	call	__stack_chk_fail@PLT
.L9:
	addq	$120, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3894:
	.size	_Z33__device_stub__Z12reduceVectorPfiPfi, .-_Z33__device_stub__Z12reduceVectorPfiPfi
	.globl	_Z12reduceVectorPfi
	.type	_Z12reduceVectorPfi, @function
_Z12reduceVectorPfi:
.LFB3895:
	.cfi_startproc
	endbr64
	jmp	_Z33__device_stub__Z12reduceVectorPfiPfi
	.cfi_endproc
.LFE3895:
	.size	_Z12reduceVectorPfi, .-_Z12reduceVectorPfi
	.globl	_Z39__device_stub__Z18reduceVector_naivePfiPfi
	.type	_Z39__device_stub__Z18reduceVector_naivePfiPfi, @function
_Z39__device_stub__Z18reduceVector_naivePfiPfi:
.LFB3896:
	.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	.L12
	pushq	32(%rsp)
	.cfi_def_cfa_offset 136
	leaq	_Z18reduceVector_naivePfi(%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
.L12:
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	je	.L14
	call	__stack_chk_fail@PLT
.L14:
	addq	$120, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3896:
	.size	_Z39__device_stub__Z18reduceVector_naivePfiPfi, .-_Z39__device_stub__Z18reduceVector_naivePfiPfi
	.globl	_Z18reduceVector_naivePfi
	.type	_Z18reduceVector_naivePfi, @function
_Z18reduceVector_naivePfi:
.LFB3897:
	.cfi_startproc
	endbr64
	jmp	_Z39__device_stub__Z18reduceVector_naivePfiPfi
	.cfi_endproc
.LFE3897:
	.size	_Z18reduceVector_naivePfi, .-_Z18reduceVector_naivePfi
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"_Z18reduceVector_naivePfi"
.LC1:
	.string	"_Z12reduceVectorPfi"
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB3899:
	.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	.LC0(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z18reduceVector_naivePfi(%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	.LC1(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z12reduceVectorPfi(%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
.LFE3899:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.rodata.str1.1
.LC3:
	.string	"reduction_host.txt"
.LC4:
	.string	"reduction_device.txt"
.LC5:
	.string	"reduction__device_naive.txt"
.LC6:
	.string	"threads %d blocks %d\n"
.LC8:
	.string	"Device sync Error: %s\n"
.LC9:
	.string	"Reduction time in us: "
.LC10:
	.string	"\t"
.LC11:
	.string	"Reduction Error: %s\n"
.LC12:
	.string	"Reduction (naive) time in us: "
.LC13:
	.string	"Cpu add rest time in us: "
.LC14:
	.string	"%f %f %f %d\n"
	.section	.text.startup
	.globl	main
	.type	main, @function
main:
.LFB3866:
	.cfi_startproc
	.cfi_personality 0x9b,DW.ref.__gxx_personality_v0
	.cfi_lsda 0x1b,.LLSDA3866
	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	$1672, %rsp
	.cfi_def_cfa_offset 1728
	movq	%fs:40, %rax
	movq	%rax, 1656(%rsp)
	xorl	%eax, %eax
	leaq	64(%rsp), %rdi
.LEHB0:
	call	cudaGetDevice@PLT
	movl	64(%rsp), %edx
	leaq	68(%rsp), %rdi
	movl	$16, %esi
	call	cudaDeviceGetAttribute@PLT
	leaq	120(%rsp), %rax
	movq	%rax, %rdi
	movq	%rax, 24(%rsp)
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEEC1Ev@PLT
.LEHE0:
	leaq	632(%rsp), %rax
	movq	%rax, %rdi
	movq	%rax, 16(%rsp)
.LEHB1:
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEEC1Ev@PLT
.LEHE1:
	leaq	1144(%rsp), %rax
	movq	%rax, %rdi
	movq	%rax, 32(%rsp)
.LEHB2:
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEEC1Ev@PLT
.LEHE2:
	movq	24(%rsp), %rdi
	movl	$16, %edx
	leaq	.LC3(%rip), %rsi
.LEHB3:
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEE4openEPKcSt13_Ios_Openmode@PLT
	movq	16(%rsp), %rdi
	movl	$16, %edx
	leaq	.LC4(%rip), %rsi
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEE4openEPKcSt13_Ios_Openmode@PLT
	movq	32(%rsp), %rdi
	movl	$16, %edx
	leaq	.LC5(%rip), %rsi
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEE4openEPKcSt13_Ios_Openmode@PLT
	movl	$14, %r12d
.L33:
	movl	$2, %ebx
	movl	%r12d, %ecx
	movq	24(%rsp), %rdi
	sall	%cl, %ebx
	movl	%ebx, %esi
	call	_ZNSolsEi@PLT
	movq	16(%rsp), %rdi
	movl	%ebx, %esi
	call	_ZNSolsEi@PLT
	movq	32(%rsp), %rdi
	movl	%ebx, %esi
	call	_ZNSolsEi@PLT
	movslq	%ebx, %rbp
	movl	$256, %edx
	movl	$2, %edi
	leaq	0(,%rbp,4), %rax
	shrq	$9, %rbp
	leaq	.LC6(%rip), %rsi
	movq	%rax, 8(%rsp)
	movq	%rbp, %rcx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	$10, %r13d
	movslq	%ebx, %r15
.L32:
	movq	8(%rsp), %rsi
	leaq	80(%rsp), %rdi
	movl	$1, %edx
	call	cudaMallocManaged@PLT
	movq	8(%rsp), %rsi
	leaq	72(%rsp), %rdi
	movl	$1, %edx
	call	cudaMallocManaged@PLT
	movq	8(%rsp), %rsi
	leaq	88(%rsp), %rdi
	movl	$1, %edx
	call	cudaMallocManaged@PLT
	movq	72(%rsp), %r8
	movss	.LC7(%rip), %xmm0
	movl	%ebx, %esi
	xorl	%ecx, %ecx
	movq	%r8, %rdi
	call	_Z16initWithNoStreamfPfi
	movq	80(%rsp), %rdi
	call	_Z16initWithNoStreamfPfi
	movq	88(%rsp), %rdi
	call	_Z16initWithNoStreamfPfi
	movl	64(%rsp), %edx
	movq	8(%rsp), %rsi
	movq	%r8, %rdi
	call	cudaMemPrefetchAsync@PLT
	movl	64(%rsp), %edx
	movq	8(%rsp), %rsi
	xorl	%ecx, %ecx
	movq	80(%rsp), %rdi
	call	cudaMemPrefetchAsync@PLT
	call	cudaDeviceSynchronize@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L20
	call	cudaGetErrorString@PLT
	movq	%rax, %rdx
	leaq	.LC8(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L20:
	call	_ZNSt6chrono3_V212system_clock3nowEv@PLT
	movl	$16777217, %edx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movq	%rax, %r14
	movl	68(%rsp), %eax
	salq	$8, %rdx
	movl	$1, %ecx
	movq	%rdx, 108(%rsp)
	sall	$5, %eax
	movl	$1, 116(%rsp)
	movl	%eax, 96(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 100(%rsp)
	movq	96(%rsp), %rdi
	movl	104(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	movq	72(%rsp), %rdi
	testl	%eax, %eax
	jne	.L21
	movl	%ebx, %esi
	call	_Z33__device_stub__Z12reduceVectorPfiPfi
.L21:
	movq	8(%rsp), %rsi
	movq	72(%rsp), %rdi
	xorl	%ecx, %ecx
	orl	$-1, %edx
	call	cudaMemPrefetchAsync@PLT
	call	cudaDeviceSynchronize@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L22
	call	cudaGetErrorString@PLT
	movq	%rax, %rdx
	leaq	.LC8(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L22:
	movl	68(%rsp), %edx
	movq	72(%rsp), %rcx
	xorl	%eax, %eax
	sall	$5, %edx
.L23:
	incq	%rax
	cmpl	%eax, %edx
	jle	.L66
	movss	(%rcx), %xmm0
	addss	(%rcx,%rax,4), %xmm0
	movss	%xmm0, (%rcx)
	jmp	.L23
.L66:
	call	_ZNSt6chrono3_V212system_clock3nowEv@PLT
	movl	$1000, %ecx
	leaq	.LC9(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rdi
	subq	%r14, %rax
	cqto
	idivq	%rcx
	movq	%rax, %r14
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%rax, %rdi
	movq	%r14, %rsi
	call	_ZNSo9_M_insertIlEERSoT_@PLT
	movq	%rax, %rdi
	call	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT
	movq	16(%rsp), %rdi
	leaq	.LC10(%rip), %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%rax, %rdi
	movq	%r14, %rsi
	call	_ZNSo9_M_insertIlEERSoT_@PLT
	call	cudaGetLastError@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L25
	call	cudaGetErrorString@PLT
	movq	%rax, %rdx
	leaq	.LC11(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L25:
	call	_ZNSt6chrono3_V212system_clock3nowEv@PLT
	movl	%ebp, 96(%rsp)
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movq	%rax, %r14
	movl	$16777217, %edx
	movabsq	$4294967297, %rax
	movl	$1, %ecx
	movq	%rax, 100(%rsp)
	movl	104(%rsp), %esi
	salq	$8, %rdx
	movq	96(%rsp), %rdi
	movq	%rdx, 108(%rsp)
	movl	$1, 116(%rsp)
	call	__cudaPushCallConfiguration@PLT
	movq	80(%rsp), %rdi
	testl	%eax, %eax
	jne	.L26
	movl	%ebx, %esi
	call	_Z39__device_stub__Z18reduceVector_naivePfiPfi
.L26:
	movq	8(%rsp), %rsi
	movq	80(%rsp), %rdi
	xorl	%ecx, %ecx
	orl	$-1, %edx
	call	cudaMemPrefetchAsync@PLT
	call	cudaDeviceSynchronize@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L27
	call	cudaGetErrorString@PLT
	movq	%rax, %rdx
	leaq	.LC8(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L27:
	movq	80(%rsp), %rdx
	movl	$1, %eax
.L28:
	movss	(%rdx), %xmm0
	addss	(%rdx,%rax,4), %xmm0
	incq	%rax
	movss	%xmm0, (%rdx)
	cmpq	%rax, %rbp
	jne	.L28
	call	_ZNSt6chrono3_V212system_clock3nowEv@PLT
	movl	$1000, %ecx
	leaq	.LC12(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rdi
	subq	%r14, %rax
	cqto
	idivq	%rcx
	movq	%rax, %r14
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%rax, %rdi
	movq	%r14, %rsi
	call	_ZNSo9_M_insertIlEERSoT_@PLT
	movq	%rax, %rdi
	call	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT
	leaq	1144(%rsp), %rax
	leaq	.LC10(%rip), %rsi
	movq	%rax, %rdi
	movq	%rax, 48(%rsp)
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%rax, %rdi
	movq	%r14, %rsi
	call	_ZNSo9_M_insertIlEERSoT_@PLT
	call	cudaGetLastError@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L29
	call	cudaGetErrorString@PLT
	movq	%rax, %rdx
	leaq	.LC11(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L29:
	call	cudaDeviceSynchronize@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L30
	call	cudaGetErrorString@PLT
	movq	%rax, %rdx
	leaq	.LC8(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L30:
	call	_ZNSt6chrono3_V212system_clock3nowEv@PLT
	xorl	%edx, %edx
	movq	$0x000000000, 40(%rsp)
	movq	%rax, %r14
	movq	88(%rsp), %rax
.L31:
	cvtss2sd	(%rax,%rdx,4), %xmm0
	addsd	40(%rsp), %xmm0
	incq	%rdx
	movsd	%xmm0, 40(%rsp)
	cmpq	%r15, %rdx
	jl	.L31
	call	_ZNSt6chrono3_V212system_clock3nowEv@PLT
	movl	$1000, %ecx
	leaq	.LC13(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rdi
	subq	%r14, %rax
	cqto
	idivq	%rcx
	movq	%rax, 56(%rsp)
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	56(%rsp), %rsi
	movq	%rax, %rdi
	call	_ZNSo9_M_insertIlEERSoT_@PLT
	movq	%rax, %rdi
	call	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT
	leaq	120(%rsp), %r14
	leaq	.LC10(%rip), %rsi
	movq	%r14, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	56(%rsp), %rsi
	movq	%rax, %rdi
	call	_ZNSo9_M_insertIlEERSoT_@PLT
	movq	72(%rsp), %rax
	movsd	40(%rsp), %xmm2
	movl	%ebx, %edx
	leaq	.LC14(%rip), %rsi
	movl	$2, %edi
	cvtss2sd	(%rax), %xmm0
	movq	80(%rsp), %rax
	cvtss2sd	(%rax), %xmm1
	movb	$3, %al
	call	__printf_chk@PLT
	movq	72(%rsp), %rdi
	call	cudaFree@PLT
	movq	80(%rsp), %rdi
	call	cudaFree@PLT
	movq	88(%rsp), %rdi
	call	cudaFree@PLT
.LEHE3:
	decl	%r13d
	jne	.L32
	incl	%r12d
	cmpl	$27, %r12d
	jne	.L33
	movq	48(%rsp), %rdi
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev@PLT
	leaq	632(%rsp), %rdi
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev@PLT
	movq	%r14, %rdi
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev@PLT
	movq	1656(%rsp), %rax
	subq	%fs:40, %rax
	je	.L38
	jmp	.L64
.L41:
	endbr64
	movq	%rax, %rbx
.L34:
	movq	32(%rsp), %rdi
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev@PLT
	jmp	.L35
.L40:
	endbr64
	movq	%rax, %rbx
.L35:
	movq	16(%rsp), %rdi
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev@PLT
	jmp	.L36
.L39:
	endbr64
	movq	%rax, %rbx
.L36:
	movq	24(%rsp), %rdi
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev@PLT
	movq	1656(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L64
	movq	%rbx, %rdi
.LEHB4:
	call	_Unwind_Resume@PLT
.LEHE4:
.L64:
	call	__stack_chk_fail@PLT
.L38:
	addq	$1672, %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
.LFE3866:
	.globl	__gxx_personality_v0
	.section	.gcc_except_table,"a",@progbits
.LLSDA3866:
	.byte	0xff
	.byte	0xff
	.byte	0x1
	.uleb128 .LLSDACSE3866-.LLSDACSB3866
.LLSDACSB3866:
	.uleb128 .LEHB0-.LFB3866
	.uleb128 .LEHE0-.LEHB0
	.uleb128 0
	.uleb128 0
	.uleb128 .LEHB1-.LFB3866
	.uleb128 .LEHE1-.LEHB1
	.uleb128 .L39-.LFB3866
	.uleb128 0
	.uleb128 .LEHB2-.LFB3866
	.uleb128 .LEHE2-.LEHB2
	.uleb128 .L40-.LFB3866
	.uleb128 0
	.uleb128 .LEHB3-.LFB3866
	.uleb128 .LEHE3-.LEHB3
	.uleb128 .L41-.LFB3866
	.uleb128 0
	.uleb128 .LEHB4-.LFB3866
	.uleb128 .LEHE4-.LEHB4
	.uleb128 0
	.uleb128 0
.LLSDACSE3866:
	.section	.text.startup
	.size	main, .-main
	.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.cst4,"aM",@progbits,4
	.align 4
.LC7:
	.long	1065353216
	.hidden	DW.ref.__gxx_personality_v0
	.weak	DW.ref.__gxx_personality_v0
	.section	.data.rel.local.DW.ref.__gxx_personality_v0,"awG",@progbits,DW.ref.__gxx_personality_v0,comdat
	.align 8
	.type	DW.ref.__gxx_personality_v0, @object
	.size	DW.ref.__gxx_personality_v0, 8
DW.ref.__gxx_personality_v0:
	.quad	__gxx_personality_v0
	.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:

// example of using CUDA streams


#include <hip/hip_runtime.h>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <chrono>
#include <math.h>
#include <fstream>
using namespace std::chrono;

#define BLOCK_SIZE 256

void initWithNoStream(float num, float *a, int N)
{

  for(int i = 0; i < N; ++i)
  {
    a[i] = num;
  }
}

__global__
void reduceVector(float *g_data, int N) {
  __shared__ float sdata[2*BLOCK_SIZE];

  unsigned int tid = threadIdx.x;
  unsigned int i = blockIdx.x * 2 * blockDim.x + threadIdx.x;
  unsigned int gridStride = 2 * blockDim.x * gridDim.x;
  sdata[tid] = 0;
  while (i < N) {
	  sdata[tid] += g_data[i] + g_data[i + blockDim.x];
	  i += gridStride;
  }
  for(unsigned j = blockDim.x / 2; j > 32; j >>= 1) {
	  __syncthreads();
	  if (tid < j) {
		sdata[tid] += sdata[tid + j];
	  }
	}
  //printf("tid %d i %d blockIdx.x %d sdata[%d] %f\n", tid, i, blockIdx.x, tid, sdata[tid]);

  __syncthreads();
//
  if(tid < 32) {
	  sdata[tid] += sdata[tid + 32];
	  sdata[tid] += sdata[tid + 16];
	  sdata[tid] += sdata[tid + 8];
	  sdata[tid] += sdata[tid + 4];
	  sdata[tid] += sdata[tid + 2];
	  sdata[tid] += sdata[tid + 1];
  }
  if (tid == 0) g_data[blockIdx.x] = sdata[0];
}

__global__
void reduceVector_naive(float *g_data, int N) {
  __shared__ float sdata[2*BLOCK_SIZE];

  unsigned int tid = threadIdx.x;
  unsigned int i = blockIdx.x * 2 * blockDim.x + threadIdx.x;
  sdata[tid] = g_data[i];
  sdata[blockDim.x+tid] = g_data[i + blockDim.x];


  for(unsigned int j = 1; j <= blockDim.x; j *= 2) {
    __syncthreads();
    if (tid % j == 0) {
      sdata[2*tid] += sdata[2*tid + j];
    }
  }

  __syncthreads();
  if (tid == 0) g_data[blockIdx.x] = sdata[tid];
}

int main(int argc, char** argv)
{
  int in_s = 14;
  char* pEnd;
  if (!in_s && argc < 2) {
    printf("Podaj liczbe która będzie przesunięciem 2 które jest rozmiarem\n");
    return 1;
  } else if(!in_s) {
	  in_s = strtol(argv[1], &pEnd, 10);
  }
  int deviceId;
  int numberOfSMs;

  hipGetDevice(&deviceId);
  hipDeviceGetAttribute(&numberOfSMs, hipDeviceAttributeMultiprocessorCount, deviceId);

  std::ofstream host_file, device_file, device_naive_file;
  host_file.open ("reduction_host.txt");
  device_file.open ("reduction_device.txt");
  device_naive_file.open ("reduction__device_naive.txt");

  for(int in_s = 14; in_s < 27; in_s++) {
	  const int N = 2<<in_s;
	  host_file << N;
	  device_file << N;
	  device_naive_file << N;
	  size_t size = N * sizeof(float);


	  size_t threads;
	  size_t blocks;

	  threads = BLOCK_SIZE;
	  blocks = N / threads / 2;

	  printf("threads %d blocks %d\n", threads, blocks);

	  hipError_t addVectorsErr;
	  hipError_t asyncErr;

	  for(int k = 0; k < 10; k++) {
		  float *a;
		  float *b;
		  float *c;

		  hipMallocManaged(&b, size);
		  hipMallocManaged(&a, size);
		  hipMallocManaged(&c, size);

		  initWithNoStream(1, a, N);
		  initWithNoStream(1, b, N);
		  initWithNoStream(1, c, N);

		  hipMemPrefetchAsync(a, size, deviceId);
		  hipMemPrefetchAsync(b, size, deviceId);
		  asyncErr = hipDeviceSynchronize();
			if(asyncErr != hipSuccess) printf("Device sync Error: %s\n", hipGetErrorString(asyncErr));

		  auto start = high_resolution_clock::now();
		  reduceVector<<<32 * numberOfSMs, threads>>>(a, N);

		  hipMemPrefetchAsync(a, size, hipCpuDeviceId);
		  asyncErr = hipDeviceSynchronize();
		  if(asyncErr != hipSuccess) printf("Device sync Error: %s\n", hipGetErrorString(asyncErr));

		  for(int i = 1; i < 32 * numberOfSMs; i++) {
				a[0] += a[i];
			  }
		  auto stop = high_resolution_clock::now();
		  auto duration = duration_cast<microseconds>(stop - start);
		  std::cout<< "Reduction time in us: " << duration.count()<< std::endl;
		  device_file << "\t" << duration.count();

		  addVectorsErr = hipGetLastError();
		  if(addVectorsErr != hipSuccess) printf("Reduction Error: %s\n", hipGetErrorString(addVectorsErr));


		  start = high_resolution_clock::now();
		  reduceVector_naive<<<blocks, threads>>>(b, N);
		  hipMemPrefetchAsync(b, size, hipCpuDeviceId);

		  asyncErr = hipDeviceSynchronize();
		  if(asyncErr != hipSuccess) printf("Device sync Error: %s\n", hipGetErrorString(asyncErr));

		  for(int i = 1; i < blocks; i++) {
			  b[0] += b[i];
			}
		  stop = high_resolution_clock::now();
		  duration = duration_cast<microseconds>(stop - start);
		  std::cout<< "Reduction (naive) time in us: " << duration.count()<< std::endl;
		  device_naive_file << "\t" << duration.count();

		  addVectorsErr = hipGetLastError();
		  if(addVectorsErr != hipSuccess) printf("Reduction Error: %s\n", hipGetErrorString(addVectorsErr));

		  asyncErr = hipDeviceSynchronize();
		  if(asyncErr != hipSuccess) printf("Device sync Error: %s\n", hipGetErrorString(asyncErr));


		  double result = 0;
		  start = high_resolution_clock::now();
		  for(long i = 0; i < N; i++) {
			result += c[i];
		  }
		  stop = high_resolution_clock::now();
		  duration = duration_cast<microseconds>(stop - start);
		  std::cout<< "Cpu add rest time in us: " << duration.count() << std::endl;
		  host_file << "\t" << duration.count();

		  printf("%f %f %f %d\n", a[0], b[0], result, N);

		  hipFree(a);
		  hipFree(b);
		  hipFree(c);
	  }
  }
}


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

                                        # End of file scope inline assembly
	.globl	_Z16initWithNoStreamfPfi        # -- Begin function _Z16initWithNoStreamfPfi
	.type	_Z16initWithNoStreamfPfi,@function
_Z16initWithNoStreamfPfi:               # @_Z16initWithNoStreamfPfi
	.cfi_startproc
# %bb.0:
	testl	%esi, %esi
	jle	.LBB0_3
# %bb.1:                                # %.lr.ph.preheader
	movl	%esi, %eax
	xorl	%ecx, %ecx
.LBB0_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movss	%xmm0, (%rdi,%rcx,4)
	incq	%rcx
	cmpq	%rcx, %rax
	jne	.LBB0_2
.LBB0_3:                                # %._crit_edge
	retq
.Lfunc_end0:
	.size	_Z16initWithNoStreamfPfi, .Lfunc_end0-_Z16initWithNoStreamfPfi
	.cfi_endproc
                                        # -- End function
	.globl	_Z27__device_stub__reduceVectorPfi # -- Begin function _Z27__device_stub__reduceVectorPfi
	.type	_Z27__device_stub__reduceVectorPfi,@function
_Z27__device_stub__reduceVectorPfi:     # @_Z27__device_stub__reduceVectorPfi
	.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	$_Z12reduceVectorPfi, %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	_Z27__device_stub__reduceVectorPfi, .Lfunc_end1-_Z27__device_stub__reduceVectorPfi
	.cfi_endproc
                                        # -- End function
	.globl	_Z33__device_stub__reduceVector_naivePfi # -- Begin function _Z33__device_stub__reduceVector_naivePfi
	.type	_Z33__device_stub__reduceVector_naivePfi,@function
_Z33__device_stub__reduceVector_naivePfi: # @_Z33__device_stub__reduceVector_naivePfi
	.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	$_Z18reduceVector_naivePfi, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$96, %rsp
	.cfi_adjust_cfa_offset -96
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end2:
	.size	_Z33__device_stub__reduceVector_naivePfi, .Lfunc_end2-_Z33__device_stub__reduceVector_naivePfi
	.cfi_endproc
                                        # -- End function
	.globl	main                            # -- Begin function main
	.type	main,@function
main:                                   # @main
.Lfunc_begin0:
	.cfi_startproc
	.cfi_personality 3, __gxx_personality_v0
	.cfi_lsda 3, .Lexception0
# %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	$1608, %rsp                     # imm = 0x648
	.cfi_def_cfa_offset 1664
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	leaq	36(%rsp), %rbx
	movq	%rbx, %rdi
	callq	hipGetDevice
	movl	(%rbx), %edx
	leaq	32(%rsp), %rdi
	movl	$63, %esi
	callq	hipDeviceGetAttribute
	leaq	1096(%rsp), %rdi
	callq	_ZNSt14basic_ofstreamIcSt11char_traitsIcEEC1Ev
.Ltmp0:
	leaq	584(%rsp), %rdi
	callq	_ZNSt14basic_ofstreamIcSt11char_traitsIcEEC1Ev
.Ltmp1:
# %bb.1:
.Ltmp3:
	leaq	72(%rsp), %rdi
	callq	_ZNSt14basic_ofstreamIcSt11char_traitsIcEEC1Ev
.Ltmp4:
# %bb.2:
.Ltmp6:
	leaq	1096(%rsp), %rdi
	movl	$.L.str.1, %esi
	movl	$16, %edx
	callq	_ZNSt14basic_ofstreamIcSt11char_traitsIcEE4openEPKcSt13_Ios_Openmode
.Ltmp7:
# %bb.3:
.Ltmp8:
	leaq	584(%rsp), %rdi
	movl	$.L.str.2, %esi
	movl	$16, %edx
	callq	_ZNSt14basic_ofstreamIcSt11char_traitsIcEE4openEPKcSt13_Ios_Openmode
.Ltmp9:
# %bb.4:
.Ltmp10:
	leaq	72(%rsp), %rdi
	movl	$.L.str.3, %esi
	movl	$16, %edx
	callq	_ZNSt14basic_ofstreamIcSt11char_traitsIcEE4openEPKcSt13_Ios_Openmode
.Ltmp11:
# %bb.5:                                # %.preheader.preheader
	movl	$14, %ecx
.LBB3_6:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB3_10 Depth 2
                                        #       Child Loop BB3_14 Depth 3
                                        #       Child Loop BB3_16 Depth 3
                                        #       Child Loop BB3_18 Depth 3
                                        #       Child Loop BB3_35 Depth 3
                                        #       Child Loop BB3_58 Depth 3
                                        #       Child Loop BB3_76 Depth 3
	movl	$2, %ebx
	movl	%ecx, 52(%rsp)                  # 4-byte Spill
                                        # kill: def $cl killed $cl killed $ecx
	shll	%cl, %ebx
.Ltmp13:
	leaq	1096(%rsp), %rdi
	movl	%ebx, %esi
	callq	_ZNSolsEi
.Ltmp14:
# %bb.7:                                #   in Loop: Header=BB3_6 Depth=1
.Ltmp15:
	leaq	584(%rsp), %rdi
	movl	%ebx, %esi
	callq	_ZNSolsEi
.Ltmp16:
# %bb.8:                                #   in Loop: Header=BB3_6 Depth=1
.Ltmp17:
	leaq	72(%rsp), %rdi
	movl	%ebx, %esi
	callq	_ZNSolsEi
.Ltmp18:
# %bb.9:                                #   in Loop: Header=BB3_6 Depth=1
	movl	%ebx, %r15d
	leaq	(,%r15,4), %rbp
	movl	%ebx, 12(%rsp)                  # 4-byte Spill
	movl	%ebx, %r12d
	shrl	$9, %r12d
	xorl	%r13d, %r13d
	movl	$.L.str.4, %edi
	movl	$256, %esi                      # imm = 0x100
	movq	%r12, %rdx
	xorl	%eax, %eax
	callq	printf
	movq	%r12, %rcx
	movabsq	$4294967296, %rax               # imm = 0x100000000
	orq	%rax, %rcx
	movq	%rcx, 56(%rsp)                  # 8-byte Spill
.LBB3_10:                               #   Parent Loop BB3_6 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB3_14 Depth 3
                                        #       Child Loop BB3_16 Depth 3
                                        #       Child Loop BB3_18 Depth 3
                                        #       Child Loop BB3_35 Depth 3
                                        #       Child Loop BB3_58 Depth 3
                                        #       Child Loop BB3_76 Depth 3
.Ltmp20:
	leaq	16(%rsp), %rdi
	movq	%rbp, %rsi
	movl	$1, %edx
	callq	hipMallocManaged
.Ltmp21:
# %bb.11:                               # %_ZL16hipMallocManagedIfE10hipError_tPPT_mj.exit
                                        #   in Loop: Header=BB3_10 Depth=2
.Ltmp22:
	leaq	24(%rsp), %rdi
	movq	%rbp, %rsi
	movl	$1, %edx
	callq	hipMallocManaged
.Ltmp23:
# %bb.12:                               # %_ZL16hipMallocManagedIfE10hipError_tPPT_mj.exit110
                                        #   in Loop: Header=BB3_10 Depth=2
.Ltmp24:
	leaq	40(%rsp), %rdi
	movq	%rbp, %rsi
	movl	$1, %edx
	callq	hipMallocManaged
.Ltmp25:
# %bb.13:                               # %_ZL16hipMallocManagedIfE10hipError_tPPT_mj.exit111
                                        #   in Loop: Header=BB3_10 Depth=2
	movq	24(%rsp), %rdi
	xorl	%eax, %eax
.LBB3_14:                               # %.lr.ph.i
                                        #   Parent Loop BB3_6 Depth=1
                                        #     Parent Loop BB3_10 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	movl	$1065353216, (%rdi,%rax,4)      # imm = 0x3F800000
	incq	%rax
	cmpq	%rax, %r15
	jne	.LBB3_14
# %bb.15:                               # %_Z16initWithNoStreamfPfi.exit
                                        #   in Loop: Header=BB3_10 Depth=2
	movq	16(%rsp), %rax
	xorl	%ecx, %ecx
.LBB3_16:                               # %.lr.ph.i113
                                        #   Parent Loop BB3_6 Depth=1
                                        #     Parent Loop BB3_10 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	movl	$1065353216, (%rax,%rcx,4)      # imm = 0x3F800000
	incq	%rcx
	cmpq	%rcx, %r15
	jne	.LBB3_16
# %bb.17:                               # %_Z16initWithNoStreamfPfi.exit117
                                        #   in Loop: Header=BB3_10 Depth=2
	movq	40(%rsp), %rax
	xorl	%ecx, %ecx
.LBB3_18:                               # %.lr.ph.i119
                                        #   Parent Loop BB3_6 Depth=1
                                        #     Parent Loop BB3_10 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	movl	$1065353216, (%rax,%rcx,4)      # imm = 0x3F800000
	incq	%rcx
	cmpq	%rcx, %r15
	jne	.LBB3_18
# %bb.19:                               # %_Z16initWithNoStreamfPfi.exit123
                                        #   in Loop: Header=BB3_10 Depth=2
	movl	36(%rsp), %edx
.Ltmp26:
	movq	%rbp, %rsi
	xorl	%ecx, %ecx
	callq	hipMemPrefetchAsync
.Ltmp27:
# %bb.20:                               #   in Loop: Header=BB3_10 Depth=2
	movq	16(%rsp), %rdi
	movl	36(%rsp), %edx
.Ltmp28:
	movq	%rbp, %rsi
	xorl	%ecx, %ecx
	callq	hipMemPrefetchAsync
.Ltmp29:
# %bb.21:                               #   in Loop: Header=BB3_10 Depth=2
.Ltmp30:
	callq	hipDeviceSynchronize
.Ltmp31:
# %bb.22:                               #   in Loop: Header=BB3_10 Depth=2
	testl	%eax, %eax
	je	.LBB3_25
# %bb.23:                               #   in Loop: Header=BB3_10 Depth=2
.Ltmp32:
	movl	%eax, %edi
	callq	hipGetErrorString
.Ltmp33:
# %bb.24:                               #   in Loop: Header=BB3_10 Depth=2
	movl	$.L.str.5, %edi
	movq	%rax, %rsi
	xorl	%eax, %eax
	callq	printf
.LBB3_25:                               #   in Loop: Header=BB3_10 Depth=2
	callq	_ZNSt6chrono3_V212system_clock3nowEv
	movq	%rax, %rbx
	movl	32(%rsp), %edi
	shll	$5, %edi
	movabsq	$4294967296, %rax               # imm = 0x100000000
	orq	%rax, %rdi
.Ltmp35:
	movl	$1, %esi
	movabsq	$4294967552, %rdx               # imm = 0x100000100
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
.Ltmp36:
# %bb.26:                               #   in Loop: Header=BB3_10 Depth=2
	testl	%eax, %eax
	jne	.LBB3_28
# %bb.27:                               #   in Loop: Header=BB3_10 Depth=2
	movq	24(%rsp), %rdi
.Ltmp37:
	movl	12(%rsp), %esi                  # 4-byte Reload
	callq	_Z27__device_stub__reduceVectorPfi
.Ltmp38:
.LBB3_28:                               #   in Loop: Header=BB3_10 Depth=2
	movq	24(%rsp), %rdi
.Ltmp39:
	movq	%rbp, %rsi
	movl	$-1, %edx
	xorl	%ecx, %ecx
	callq	hipMemPrefetchAsync
.Ltmp40:
# %bb.29:                               #   in Loop: Header=BB3_10 Depth=2
.Ltmp41:
	callq	hipDeviceSynchronize
.Ltmp42:
# %bb.30:                               #   in Loop: Header=BB3_10 Depth=2
	testl	%eax, %eax
	je	.LBB3_33
# %bb.31:                               #   in Loop: Header=BB3_10 Depth=2
.Ltmp43:
	movl	%eax, %edi
	callq	hipGetErrorString
.Ltmp44:
# %bb.32:                               #   in Loop: Header=BB3_10 Depth=2
	movl	$.L.str.5, %edi
	movq	%rax, %rsi
	xorl	%eax, %eax
	callq	printf
.LBB3_33:                               #   in Loop: Header=BB3_10 Depth=2
	movl	32(%rsp), %eax
	testl	%eax, %eax
	jle	.LBB3_37
# %bb.34:                               # %.lr.ph
                                        #   in Loop: Header=BB3_10 Depth=2
	shll	$5, %eax
	movq	24(%rsp), %rcx
	movss	(%rcx), %xmm0                   # xmm0 = mem[0],zero,zero,zero
	cmpl	$3, %eax
	movl	$2, %edx
	cmovll	%edx, %eax
	movl	$1, %edx
.LBB3_35:                               #   Parent Loop BB3_6 Depth=1
                                        #     Parent Loop BB3_10 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	addss	(%rcx,%rdx,4), %xmm0
	incq	%rdx
	cmpq	%rdx, %rax
	jne	.LBB3_35
# %bb.36:                               # %._crit_edge
                                        #   in Loop: Header=BB3_10 Depth=2
	movss	%xmm0, (%rcx)
.LBB3_37:                               #   in Loop: Header=BB3_10 Depth=2
	callq	_ZNSt6chrono3_V212system_clock3nowEv
	subq	%rbx, %rax
	movabsq	$2361183241434822607, %rcx      # imm = 0x20C49BA5E353F7CF
	imulq	%rcx
	movq	%rdx, %rbx
.Ltmp46:
	movl	$_ZSt4cout, %edi
	movl	$.L.str.6, %esi
	movl	$22, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp47:
# %bb.38:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit
                                        #   in Loop: Header=BB3_10 Depth=2
.Ltmp48:
	movq	%rbx, %rax
	shrq	$63, %rax
	sarq	$7, %rbx
	addq	%rax, %rbx
	movl	$_ZSt4cout, %edi
	movq	%rbx, %rsi
	callq	_ZNSo9_M_insertIlEERSoT_
.Ltmp49:
# %bb.39:                               # %_ZNSolsEl.exit
                                        #   in Loop: Header=BB3_10 Depth=2
	movq	%rax, %r14
	movq	(%rax), %rax
	movq	-24(%rax), %rdi
	addq	%r14, %rdi
.Ltmp50:
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
.Ltmp51:
# %bb.40:                               # %.noexc
                                        #   in Loop: Header=BB3_10 Depth=2
.Ltmp52:
	movsbl	%al, %esi
	movq	%r14, %rdi
	callq	_ZNSo3putEc
.Ltmp53:
# %bb.41:                               # %.noexc140
                                        #   in Loop: Header=BB3_10 Depth=2
.Ltmp54:
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
.Ltmp55:
# %bb.42:                               # %_ZNSolsEPFRSoS_E.exit
                                        #   in Loop: Header=BB3_10 Depth=2
.Ltmp56:
	movl	$.L.str.7, %esi
	movl	$1, %edx
	leaq	584(%rsp), %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp57:
# %bb.43:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit124
                                        #   in Loop: Header=BB3_10 Depth=2
.Ltmp58:
	leaq	584(%rsp), %rdi
	movq	%rbx, %rsi
	callq	_ZNSo9_M_insertIlEERSoT_
.Ltmp59:
# %bb.44:                               # %_ZNSolsEl.exit125
                                        #   in Loop: Header=BB3_10 Depth=2
.Ltmp60:
	callq	hipGetLastError
.Ltmp61:
# %bb.45:                               #   in Loop: Header=BB3_10 Depth=2
	testl	%eax, %eax
	je	.LBB3_48
# %bb.46:                               #   in Loop: Header=BB3_10 Depth=2
.Ltmp62:
	movl	%eax, %edi
	callq	hipGetErrorString
.Ltmp63:
# %bb.47:                               #   in Loop: Header=BB3_10 Depth=2
	movl	$.L.str.8, %edi
	movq	%rax, %rsi
	xorl	%eax, %eax
	callq	printf
.LBB3_48:                               #   in Loop: Header=BB3_10 Depth=2
	callq	_ZNSt6chrono3_V212system_clock3nowEv
	movq	%rax, %rbx
.Ltmp64:
	movq	56(%rsp), %rdi                  # 8-byte Reload
	movl	$1, %esi
	movabsq	$4294967552, %rdx               # imm = 0x100000100
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
.Ltmp65:
# %bb.49:                               #   in Loop: Header=BB3_10 Depth=2
	testl	%eax, %eax
	jne	.LBB3_51
# %bb.50:                               #   in Loop: Header=BB3_10 Depth=2
	movq	16(%rsp), %rdi
.Ltmp66:
	movl	12(%rsp), %esi                  # 4-byte Reload
	callq	_Z33__device_stub__reduceVector_naivePfi
.Ltmp67:
.LBB3_51:                               #   in Loop: Header=BB3_10 Depth=2
	movq	16(%rsp), %rdi
.Ltmp68:
	movq	%rbp, %rsi
	movl	$-1, %edx
	xorl	%ecx, %ecx
	callq	hipMemPrefetchAsync
.Ltmp69:
# %bb.52:                               #   in Loop: Header=BB3_10 Depth=2
.Ltmp70:
	callq	hipDeviceSynchronize
.Ltmp71:
# %bb.53:                               #   in Loop: Header=BB3_10 Depth=2
	testl	%eax, %eax
	je	.LBB3_56
# %bb.54:                               #   in Loop: Header=BB3_10 Depth=2
.Ltmp72:
	movl	%eax, %edi
	callq	hipGetErrorString
.Ltmp73:
# %bb.55:                               #   in Loop: Header=BB3_10 Depth=2
	movl	$.L.str.5, %edi
	movq	%rax, %rsi
	xorl	%eax, %eax
	callq	printf
.LBB3_56:                               #   in Loop: Header=BB3_10 Depth=2
	cmpl	$1024, 12(%rsp)                 # 4-byte Folded Reload
                                        # imm = 0x400
	jb	.LBB3_60
# %bb.57:                               # %.lr.ph177
                                        #   in Loop: Header=BB3_10 Depth=2
	movq	16(%rsp), %rax
	movss	(%rax), %xmm0                   # xmm0 = mem[0],zero,zero,zero
	movl	$1, %ecx
.LBB3_58:                               #   Parent Loop BB3_6 Depth=1
                                        #     Parent Loop BB3_10 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	addss	(%rax,%rcx,4), %xmm0
	incq	%rcx
	cmpq	%rcx, %r12
	jne	.LBB3_58
# %bb.59:                               # %._crit_edge178.loopexit
                                        #   in Loop: Header=BB3_10 Depth=2
	movss	%xmm0, (%rax)
.LBB3_60:                               # %._crit_edge178
                                        #   in Loop: Header=BB3_10 Depth=2
	callq	_ZNSt6chrono3_V212system_clock3nowEv
	subq	%rbx, %rax
	movabsq	$2361183241434822607, %rcx      # imm = 0x20C49BA5E353F7CF
	imulq	%rcx
	movq	%rdx, %rbx
.Ltmp74:
	movl	$_ZSt4cout, %edi
	movl	$.L.str.9, %esi
	movl	$30, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp75:
# %bb.61:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit128
                                        #   in Loop: Header=BB3_10 Depth=2
.Ltmp76:
	movq	%rbx, %rax
	shrq	$63, %rax
	sarq	$7, %rbx
	addq	%rax, %rbx
	movl	$_ZSt4cout, %edi
	movq	%rbx, %rsi
	callq	_ZNSo9_M_insertIlEERSoT_
.Ltmp77:
# %bb.62:                               # %_ZNSolsEl.exit129
                                        #   in Loop: Header=BB3_10 Depth=2
	movq	%rax, %r14
	movq	(%rax), %rax
	movq	-24(%rax), %rdi
	addq	%r14, %rdi
.Ltmp78:
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
.Ltmp79:
# %bb.63:                               # %.noexc142
                                        #   in Loop: Header=BB3_10 Depth=2
.Ltmp80:
	movsbl	%al, %esi
	movq	%r14, %rdi
	callq	_ZNSo3putEc
.Ltmp81:
# %bb.64:                               # %.noexc143
                                        #   in Loop: Header=BB3_10 Depth=2
.Ltmp82:
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
.Ltmp83:
# %bb.65:                               # %_ZNSolsEPFRSoS_E.exit130
                                        #   in Loop: Header=BB3_10 Depth=2
.Ltmp84:
	movl	$.L.str.7, %esi
	movl	$1, %edx
	leaq	72(%rsp), %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp85:
# %bb.66:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit131
                                        #   in Loop: Header=BB3_10 Depth=2
.Ltmp86:
	leaq	72(%rsp), %rdi
	movq	%rbx, %rsi
	callq	_ZNSo9_M_insertIlEERSoT_
.Ltmp87:
# %bb.67:                               # %_ZNSolsEl.exit132
                                        #   in Loop: Header=BB3_10 Depth=2
.Ltmp88:
	callq	hipGetLastError
.Ltmp89:
# %bb.68:                               #   in Loop: Header=BB3_10 Depth=2
	testl	%eax, %eax
	je	.LBB3_71
# %bb.69:                               #   in Loop: Header=BB3_10 Depth=2
.Ltmp90:
	movl	%eax, %edi
	callq	hipGetErrorString
.Ltmp91:
# %bb.70:                               #   in Loop: Header=BB3_10 Depth=2
	movl	$.L.str.8, %edi
	movq	%rax, %rsi
	xorl	%eax, %eax
	callq	printf
.LBB3_71:                               #   in Loop: Header=BB3_10 Depth=2
.Ltmp92:
	callq	hipDeviceSynchronize
.Ltmp93:
# %bb.72:                               #   in Loop: Header=BB3_10 Depth=2
	testl	%eax, %eax
	je	.LBB3_75
# %bb.73:                               #   in Loop: Header=BB3_10 Depth=2
.Ltmp94:
	movl	%eax, %edi
	callq	hipGetErrorString
.Ltmp95:
# %bb.74:                               #   in Loop: Header=BB3_10 Depth=2
	movl	$.L.str.5, %edi
	movq	%rax, %rsi
	xorl	%eax, %eax
	callq	printf
.LBB3_75:                               #   in Loop: Header=BB3_10 Depth=2
	callq	_ZNSt6chrono3_V212system_clock3nowEv
	movq	%rax, %rbx
	xorpd	%xmm1, %xmm1
	movq	40(%rsp), %rax
	xorl	%ecx, %ecx
.LBB3_76:                               #   Parent Loop BB3_6 Depth=1
                                        #     Parent Loop BB3_10 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	xorps	%xmm0, %xmm0
	cvtss2sd	(%rax,%rcx,4), %xmm0
	addsd	%xmm0, %xmm1
	incq	%rcx
	cmpq	%rcx, %r15
	jne	.LBB3_76
# %bb.77:                               #   in Loop: Header=BB3_10 Depth=2
	movsd	%xmm1, 64(%rsp)                 # 8-byte Spill
	callq	_ZNSt6chrono3_V212system_clock3nowEv
	subq	%rbx, %rax
	movabsq	$2361183241434822607, %rcx      # imm = 0x20C49BA5E353F7CF
	imulq	%rcx
	movq	%rdx, %rbx
.Ltmp97:
	movl	$_ZSt4cout, %edi
	movl	$.L.str.10, %esi
	movl	$25, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp98:
# %bb.78:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit135
                                        #   in Loop: Header=BB3_10 Depth=2
.Ltmp99:
	movq	%rbx, %rax
	shrq	$63, %rax
	sarq	$7, %rbx
	addq	%rax, %rbx
	movl	$_ZSt4cout, %edi
	movq	%rbx, %rsi
	callq	_ZNSo9_M_insertIlEERSoT_
.Ltmp100:
# %bb.79:                               # %_ZNSolsEl.exit136
                                        #   in Loop: Header=BB3_10 Depth=2
	movq	%rax, %r14
	movq	(%rax), %rax
	movq	-24(%rax), %rdi
	addq	%r14, %rdi
.Ltmp101:
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
.Ltmp102:
# %bb.80:                               # %.noexc146
                                        #   in Loop: Header=BB3_10 Depth=2
.Ltmp103:
	movsbl	%al, %esi
	movq	%r14, %rdi
	callq	_ZNSo3putEc
.Ltmp104:
# %bb.81:                               # %.noexc147
                                        #   in Loop: Header=BB3_10 Depth=2
.Ltmp105:
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
.Ltmp106:
# %bb.82:                               # %_ZNSolsEPFRSoS_E.exit137
                                        #   in Loop: Header=BB3_10 Depth=2
.Ltmp107:
	movl	$.L.str.7, %esi
	movl	$1, %edx
	leaq	1096(%rsp), %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp108:
# %bb.83:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit138
                                        #   in Loop: Header=BB3_10 Depth=2
.Ltmp109:
	leaq	1096(%rsp), %rdi
	movq	%rbx, %rsi
	callq	_ZNSo9_M_insertIlEERSoT_
.Ltmp110:
# %bb.84:                               # %_ZNSolsEl.exit139
                                        #   in Loop: Header=BB3_10 Depth=2
	movq	24(%rsp), %rax
	xorps	%xmm0, %xmm0
	cvtss2sd	(%rax), %xmm0
	movq	16(%rsp), %rax
	xorps	%xmm1, %xmm1
	cvtss2sd	(%rax), %xmm1
	movl	$.L.str.11, %edi
	movsd	64(%rsp), %xmm2                 # 8-byte Reload
                                        # xmm2 = mem[0],zero
	movl	12(%rsp), %esi                  # 4-byte Reload
	movb	$3, %al
	callq	printf
	movq	24(%rsp), %rdi
.Ltmp111:
	callq	hipFree
.Ltmp112:
# %bb.85:                               #   in Loop: Header=BB3_10 Depth=2
	movq	16(%rsp), %rdi
.Ltmp113:
	callq	hipFree
.Ltmp114:
# %bb.86:                               #   in Loop: Header=BB3_10 Depth=2
	movq	40(%rsp), %rdi
.Ltmp115:
	callq	hipFree
.Ltmp116:
# %bb.87:                               #   in Loop: Header=BB3_10 Depth=2
	incl	%r13d
	cmpl	$10, %r13d
	jne	.LBB3_10
# %bb.88:                               #   in Loop: Header=BB3_6 Depth=1
	movl	52(%rsp), %ecx                  # 4-byte Reload
	incl	%ecx
	cmpl	$27, %ecx
	jne	.LBB3_6
# %bb.89:
	movq	_ZTTSt14basic_ofstreamIcSt11char_traitsIcEE(%rip), %rbx
	leaq	80(%rsp), %rdi
	movq	%rbx, -8(%rdi)
	movq	_ZTTSt14basic_ofstreamIcSt11char_traitsIcEE+24(%rip), %r14
	movq	-24(%rbx), %rax
	movq	%r14, 72(%rsp,%rax)
	callq	_ZNSt13basic_filebufIcSt11char_traitsIcEED2Ev
	movl	$248, %r15d
	leaq	72(%rsp), %rdi
	addq	%r15, %rdi
	callq	_ZNSt8ios_baseD2Ev
	leaq	592(%rsp), %rdi
	movq	%rbx, -8(%rdi)
	movq	-24(%rbx), %rax
	movq	%r14, 584(%rsp,%rax)
	callq	_ZNSt13basic_filebufIcSt11char_traitsIcEED2Ev
	leaq	584(%rsp), %rdi
	addq	%r15, %rdi
	callq	_ZNSt8ios_baseD2Ev
	leaq	1104(%rsp), %rdi
	movq	%rbx, -8(%rdi)
	movq	-24(%rbx), %rax
	movq	%r14, 1096(%rsp,%rax)
	callq	_ZNSt13basic_filebufIcSt11char_traitsIcEED2Ev
	leaq	1096(%rsp), %rdi
	addq	%r15, %rdi
	callq	_ZNSt8ios_baseD2Ev
	xorl	%eax, %eax
	addq	$1608, %rsp                     # imm = 0x648
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.LBB3_91:
	.cfi_def_cfa_offset 1664
.Ltmp5:
	movq	%rax, %rbx
	movq	_ZTTSt14basic_ofstreamIcSt11char_traitsIcEE(%rip), %r14
	movq	_ZTTSt14basic_ofstreamIcSt11char_traitsIcEE+24(%rip), %r15
	jmp	.LBB3_99
.LBB3_90:
.Ltmp2:
	movq	%rax, %rbx
	movq	_ZTTSt14basic_ofstreamIcSt11char_traitsIcEE(%rip), %r14
	movq	_ZTTSt14basic_ofstreamIcSt11char_traitsIcEE+24(%rip), %r15
	jmp	.LBB3_100
.LBB3_92:
.Ltmp12:
	jmp	.LBB3_98
.LBB3_93:
.Ltmp19:
	jmp	.LBB3_98
.LBB3_95:
.Ltmp45:
	jmp	.LBB3_98
.LBB3_94:
.Ltmp34:
	jmp	.LBB3_98
.LBB3_97:
.Ltmp117:
	jmp	.LBB3_98
.LBB3_96:
.Ltmp96:
.LBB3_98:
	movq	%rax, %rbx
	movq	_ZTTSt14basic_ofstreamIcSt11char_traitsIcEE(%rip), %r14
	leaq	80(%rsp), %rdi
	movq	%r14, -8(%rdi)
	movq	_ZTTSt14basic_ofstreamIcSt11char_traitsIcEE+24(%rip), %r15
	movq	-24(%r14), %rax
	movq	%r15, 72(%rsp,%rax)
	callq	_ZNSt13basic_filebufIcSt11char_traitsIcEED2Ev
	leaq	320(%rsp), %rdi
	callq	_ZNSt8ios_baseD2Ev
.LBB3_99:
	leaq	592(%rsp), %rdi
	movq	%r14, -8(%rdi)
	movq	-24(%r14), %rax
	movq	%r15, 584(%rsp,%rax)
	callq	_ZNSt13basic_filebufIcSt11char_traitsIcEED2Ev
	leaq	832(%rsp), %rdi
	callq	_ZNSt8ios_baseD2Ev
.LBB3_100:
	leaq	1104(%rsp), %rdi
	movq	%r14, -8(%rdi)
	movq	-24(%r14), %rax
	movq	%r15, 1096(%rsp,%rax)
	callq	_ZNSt13basic_filebufIcSt11char_traitsIcEED2Ev
	leaq	1344(%rsp), %rdi
	callq	_ZNSt8ios_baseD2Ev
	movq	%rbx, %rdi
	callq	_Unwind_Resume@PLT
.Lfunc_end3:
	.size	main, .Lfunc_end3-main
	.cfi_endproc
	.section	.gcc_except_table,"a",@progbits
	.p2align	2, 0x0
GCC_except_table3:
.Lexception0:
	.byte	255                             # @LPStart Encoding = omit
	.byte	255                             # @TType Encoding = omit
	.byte	1                               # Call site Encoding = uleb128
	.uleb128 .Lcst_end0-.Lcst_begin0
.Lcst_begin0:
	.uleb128 .Lfunc_begin0-.Lfunc_begin0    # >> Call Site 1 <<
	.uleb128 .Ltmp0-.Lfunc_begin0           #   Call between .Lfunc_begin0 and .Ltmp0
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp0-.Lfunc_begin0           # >> Call Site 2 <<
	.uleb128 .Ltmp1-.Ltmp0                  #   Call between .Ltmp0 and .Ltmp1
	.uleb128 .Ltmp2-.Lfunc_begin0           #     jumps to .Ltmp2
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp3-.Lfunc_begin0           # >> Call Site 3 <<
	.uleb128 .Ltmp4-.Ltmp3                  #   Call between .Ltmp3 and .Ltmp4
	.uleb128 .Ltmp5-.Lfunc_begin0           #     jumps to .Ltmp5
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp6-.Lfunc_begin0           # >> Call Site 4 <<
	.uleb128 .Ltmp11-.Ltmp6                 #   Call between .Ltmp6 and .Ltmp11
	.uleb128 .Ltmp12-.Lfunc_begin0          #     jumps to .Ltmp12
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp13-.Lfunc_begin0          # >> Call Site 5 <<
	.uleb128 .Ltmp18-.Ltmp13                #   Call between .Ltmp13 and .Ltmp18
	.uleb128 .Ltmp19-.Lfunc_begin0          #     jumps to .Ltmp19
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp20-.Lfunc_begin0          # >> Call Site 6 <<
	.uleb128 .Ltmp33-.Ltmp20                #   Call between .Ltmp20 and .Ltmp33
	.uleb128 .Ltmp34-.Lfunc_begin0          #     jumps to .Ltmp34
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp35-.Lfunc_begin0          # >> Call Site 7 <<
	.uleb128 .Ltmp44-.Ltmp35                #   Call between .Ltmp35 and .Ltmp44
	.uleb128 .Ltmp45-.Lfunc_begin0          #     jumps to .Ltmp45
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp46-.Lfunc_begin0          # >> Call Site 8 <<
	.uleb128 .Ltmp95-.Ltmp46                #   Call between .Ltmp46 and .Ltmp95
	.uleb128 .Ltmp96-.Lfunc_begin0          #     jumps to .Ltmp96
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp97-.Lfunc_begin0          # >> Call Site 9 <<
	.uleb128 .Ltmp116-.Ltmp97               #   Call between .Ltmp97 and .Ltmp116
	.uleb128 .Ltmp117-.Lfunc_begin0         #     jumps to .Ltmp117
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp116-.Lfunc_begin0         # >> Call Site 10 <<
	.uleb128 .Lfunc_end3-.Ltmp116           #   Call between .Ltmp116 and .Lfunc_end3
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
.Lcst_end0:
	.p2align	2, 0x0
                                        # -- End function
	.text
	.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	$_Z12reduceVectorPfi, %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	$_Z18reduceVector_naivePfi, %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	_Z12reduceVectorPfi,@object     # @_Z12reduceVectorPfi
	.section	.rodata,"a",@progbits
	.globl	_Z12reduceVectorPfi
	.p2align	3, 0x0
_Z12reduceVectorPfi:
	.quad	_Z27__device_stub__reduceVectorPfi
	.size	_Z12reduceVectorPfi, 8

	.type	_Z18reduceVector_naivePfi,@object # @_Z18reduceVector_naivePfi
	.globl	_Z18reduceVector_naivePfi
	.p2align	3, 0x0
_Z18reduceVector_naivePfi:
	.quad	_Z33__device_stub__reduceVector_naivePfi
	.size	_Z18reduceVector_naivePfi, 8

	.type	.L.str.1,@object                # @.str.1
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.1:
	.asciz	"reduction_host.txt"
	.size	.L.str.1, 19

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"reduction_device.txt"
	.size	.L.str.2, 21

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"reduction__device_naive.txt"
	.size	.L.str.3, 28

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"threads %d blocks %d\n"
	.size	.L.str.4, 22

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"Device sync Error: %s\n"
	.size	.L.str.5, 23

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"Reduction time in us: "
	.size	.L.str.6, 23

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"\t"
	.size	.L.str.7, 2

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"Reduction Error: %s\n"
	.size	.L.str.8, 21

	.type	.L.str.9,@object                # @.str.9
.L.str.9:
	.asciz	"Reduction (naive) time in us: "
	.size	.L.str.9, 31

	.type	.L.str.10,@object               # @.str.10
.L.str.10:
	.asciz	"Cpu add rest time in us: "
	.size	.L.str.10, 26

	.type	.L.str.11,@object               # @.str.11
.L.str.11:
	.asciz	"%f %f %f %d\n"
	.size	.L.str.11, 13

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z12reduceVectorPfi"
	.size	.L__unnamed_1, 20

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_Z18reduceVector_naivePfi"
	.size	.L__unnamed_2, 26

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

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

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym _Z27__device_stub__reduceVectorPfi
	.addrsig_sym _Z33__device_stub__reduceVector_naivePfi
	.addrsig_sym __gxx_personality_v0
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Unwind_Resume
	.addrsig_sym _Z12reduceVectorPfi
	.addrsig_sym _Z18reduceVector_naivePfi
	.addrsig_sym _ZSt4cout
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z12reduceVectorPfi     ; -- Begin function _Z12reduceVectorPfi
	.globl	_Z12reduceVectorPfi
	.p2align	8
	.type	_Z12reduceVectorPfi,@function
_Z12reduceVectorPfi:                    ; @_Z12reduceVectorPfi
; %bb.0:
	s_clause 0x2
	s_load_b32 s3, s[0:1], 0x1c
	s_load_b32 s6, s[0:1], 0x8
	s_load_b64 s[4:5], s[0:1], 0x0
	s_lshl_b32 s9, s15, 1
	s_add_u32 s0, s0, 16
	s_addc_u32 s1, s1, 0
	v_lshlrev_b32_e32 v3, 2, v0
	s_mov_b32 s2, s15
	s_mov_b32 s8, exec_lo
	v_mov_b32_e32 v4, 0
	ds_store_b32 v3, v4
	s_waitcnt lgkmcnt(0)
	s_and_b32 s3, s3, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_mul_i32 s7, s9, s3
	v_add_nc_u32_e32 v1, s7, v0
	s_delay_alu instid0(VALU_DEP_1)
	v_cmpx_gt_u32_e64 s6, v1
	s_cbranch_execz .LBB0_4
; %bb.1:                                ; %.lr.ph.preheader
	s_load_b32 s0, s[0:1], 0x0
	v_dual_mov_b32 v2, 0 :: v_dual_mov_b32 v5, v0
	s_add_i32 s1, s9, 1
	s_waitcnt lgkmcnt(0)
	s_mul_i32 s9, s0, s3
	s_mul_i32 s0, s1, s3
	s_lshl_b32 s9, s9, 1
	s_mov_b32 s1, 0
.LBB0_2:                                ; %.lr.ph
                                        ; =>This Inner Loop Header: Depth=1
	v_add_nc_u32_e32 v1, s7, v5
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_2)
	v_lshlrev_b64 v[6:7], 2, v[1:2]
	v_add_nc_u32_e32 v1, s0, v5
	v_add_nc_u32_e32 v5, s9, v5
	v_lshlrev_b64 v[8:9], 2, v[1:2]
	s_delay_alu instid0(VALU_DEP_4) | instskip(SKIP_1) | instid1(VALU_DEP_3)
	v_add_co_u32 v6, vcc_lo, s4, v6
	v_add_co_ci_u32_e32 v7, vcc_lo, s5, v7, vcc_lo
	v_add_co_u32 v8, vcc_lo, s4, v8
	s_delay_alu instid0(VALU_DEP_4) | instskip(SKIP_4) | instid1(VALU_DEP_1)
	v_add_co_ci_u32_e32 v9, vcc_lo, s5, v9, vcc_lo
	s_clause 0x1
	global_load_b32 v1, v[6:7], off
	global_load_b32 v6, v[8:9], off
	v_add_nc_u32_e32 v7, s7, v5
	v_cmp_le_u32_e32 vcc_lo, s6, v7
	s_or_b32 s1, vcc_lo, s1
	s_waitcnt vmcnt(0)
	v_add_f32_e32 v1, v1, v6
	s_delay_alu instid0(VALU_DEP_1)
	v_add_f32_e32 v4, v4, v1
	s_and_not1_b32 exec_lo, exec_lo, s1
	s_cbranch_execnz .LBB0_2
; %bb.3:                                ; %..preheader_crit_edge
	s_or_b32 exec_lo, exec_lo, s1
	ds_store_b32 v3, v4
.LBB0_4:                                ; %Flow42
	s_or_b32 exec_lo, exec_lo, s8
	s_cmpk_lt_u32 s3, 0x42
	s_cbranch_scc1 .LBB0_8
.LBB0_5:                                ; %.lr.ph37
                                        ; =>This Inner Loop Header: Depth=1
	s_lshr_b32 s0, s3, 1
	s_mov_b32 s1, exec_lo
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	v_cmpx_gt_u32_e64 s0, v0
	s_cbranch_execz .LBB0_7
; %bb.6:                                ;   in Loop: Header=BB0_5 Depth=1
	v_lshl_add_u32 v1, s0, 2, v3
	ds_load_b32 v1, v1
	ds_load_b32 v2, v3
	s_waitcnt lgkmcnt(0)
	v_add_f32_e32 v1, v1, v2
	ds_store_b32 v3, v1
.LBB0_7:                                ;   in Loop: Header=BB0_5 Depth=1
	s_or_b32 exec_lo, exec_lo, s1
	s_cmpk_lt_u32 s3, 0x84
	s_mov_b32 s3, s0
	s_cbranch_scc0 .LBB0_5
.LBB0_8:                                ; %._crit_edge
	s_mov_b32 s0, exec_lo
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	v_cmpx_gt_u32_e32 32, v0
	s_cbranch_execz .LBB0_10
; %bb.9:
	ds_load_b32 v8, v3 offset:128
	ds_load_2addr_b32 v[1:2], v3 offset1:1
	ds_load_2addr_b32 v[4:5], v3 offset0:8 offset1:16
	ds_load_2addr_b32 v[6:7], v3 offset0:2 offset1:4
	s_waitcnt lgkmcnt(2)
	v_add_f32_e32 v1, v8, v1
	s_waitcnt lgkmcnt(1)
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f32_e32 v1, v1, v5
	v_add_f32_e32 v1, v1, v4
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f32_e32 v1, v1, v7
	v_add_f32_e32 v1, v1, v6
	s_delay_alu instid0(VALU_DEP_1)
	v_add_f32_e32 v1, v1, v2
	ds_store_b32 v3, v1
.LBB0_10:
	s_or_b32 exec_lo, exec_lo, s0
	s_mov_b32 s3, 0
	s_mov_b32 s0, exec_lo
	v_cmpx_eq_u32_e32 0, v0
	s_cbranch_execz .LBB0_12
; %bb.11:
	v_mov_b32_e32 v0, 0
	s_lshl_b64 s[0:1], s[2:3], 2
	s_delay_alu instid0(SALU_CYCLE_1)
	s_add_u32 s0, s4, s0
	s_addc_u32 s1, s5, s1
	ds_load_b32 v1, v0
	s_waitcnt lgkmcnt(0)
	global_store_b32 v0, v1, s[0:1]
.LBB0_12:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z12reduceVectorPfi
		.amdhsa_group_segment_fixed_size 2048
		.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 10
		.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	_Z12reduceVectorPfi, .Lfunc_end0-_Z12reduceVectorPfi
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 568
; NumSgprs: 18
; NumVgprs: 10
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 2048 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 10
; 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	_Z18reduceVector_naivePfi ; -- Begin function _Z18reduceVector_naivePfi
	.globl	_Z18reduceVector_naivePfi
	.p2align	8
	.type	_Z18reduceVector_naivePfi,@function
_Z18reduceVector_naivePfi:              ; @_Z18reduceVector_naivePfi
; %bb.0:
	s_clause 0x1
	s_load_b32 s3, s[0:1], 0x1c
	s_load_b64 s[0:1], s[0:1], 0x0
	s_mov_b32 s2, s15
	s_waitcnt lgkmcnt(0)
	s_and_b32 s3, s3, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_4) | instid1(VALU_DEP_1)
	s_mul_i32 s4, s15, s3
	s_cmp_eq_u32 s3, 0
	v_lshl_add_u32 v1, s4, 1, v0
	v_mov_b32_e32 v2, 0
	s_mov_b32 s4, 1
	v_lshlrev_b64 v[3:4], 2, v[1:2]
	v_add_nc_u32_e32 v1, s3, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_lshlrev_b64 v[1:2], 2, v[1:2]
	v_add_co_u32 v3, vcc_lo, s0, v3
	s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_co_ci_u32_e32 v4, vcc_lo, s1, v4, vcc_lo
	v_add_co_u32 v1, vcc_lo, s0, v1
	s_delay_alu instid0(VALU_DEP_4) | instskip(SKIP_4) | instid1(VALU_DEP_1)
	v_add_co_ci_u32_e32 v2, vcc_lo, s1, v2, vcc_lo
	s_clause 0x1
	global_load_b32 v3, v[3:4], off
	global_load_b32 v2, v[1:2], off
	v_lshlrev_b32_e32 v1, 2, v0
	v_lshl_add_u32 v4, s3, 2, v1
	s_waitcnt vmcnt(1)
	ds_store_b32 v1, v3
	s_waitcnt vmcnt(0)
	ds_store_b32 v4, v2
	s_cbranch_scc1 .LBB1_5
; %bb.1:                                ; %.lr.ph
	v_lshl_add_u32 v2, v0, 2, v1
.LBB1_2:                                ; =>This Inner Loop Header: Depth=1
	s_add_i32 s5, s4, -1
	s_waitcnt lgkmcnt(0)
	v_and_b32_e32 v3, s5, v0
	s_mov_b32 s5, exec_lo
	s_barrier
	buffer_gl0_inv
	v_cmpx_eq_u32_e32 0, v3
	s_cbranch_execz .LBB1_4
; %bb.3:                                ;   in Loop: Header=BB1_2 Depth=1
	v_lshl_add_u32 v3, s4, 2, v2
	ds_load_b32 v3, v3
	ds_load_b32 v4, v2
	s_waitcnt lgkmcnt(0)
	v_add_f32_e32 v3, v3, v4
	ds_store_b32 v2, v3
.LBB1_4:                                ;   in Loop: Header=BB1_2 Depth=1
	s_or_b32 exec_lo, exec_lo, s5
	s_lshl_b32 s4, s4, 1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_cmp_gt_u32 s4, s3
	s_cbranch_scc0 .LBB1_2
.LBB1_5:                                ; %._crit_edge
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	s_mov_b32 s3, exec_lo
	v_cmpx_eq_u32_e32 0, v0
	s_cbranch_execz .LBB1_7
; %bb.6:
	ds_load_b32 v0, v1
	s_mov_b32 s3, 0
	v_mov_b32_e32 v1, 0
	s_lshl_b64 s[2:3], s[2:3], 2
	s_delay_alu instid0(SALU_CYCLE_1)
	s_add_u32 s0, s0, s2
	s_addc_u32 s1, s1, s3
	s_waitcnt lgkmcnt(0)
	global_store_b32 v1, v0, s[0:1]
.LBB1_7:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z18reduceVector_naivePfi
		.amdhsa_group_segment_fixed_size 2048
		.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 5
		.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	_Z18reduceVector_naivePfi, .Lfunc_end1-_Z18reduceVector_naivePfi
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 368
; NumSgprs: 18
; NumVgprs: 5
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 2048 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 5
; 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: 2048
    .kernarg_segment_align: 8
    .kernarg_segment_size: 272
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z12reduceVectorPfi
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z12reduceVectorPfi.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     10
    .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:           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: 2048
    .kernarg_segment_align: 8
    .kernarg_segment_size: 272
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z18reduceVector_naivePfi
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z18reduceVector_naivePfi.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     5
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
