#include <stddef.h>  // NULL, size_t
#include <math.h> // expf
#include <stdio.h> // printf
#include <time.h> // time
#include <sys/time.h> // gettimeofday
#include <assert.h>



#include <curand.h>
#include <cuda.h>
#include <curand_kernel.h>
//#include "cutil.h" // CUDA_SAFE_CALL, CUT_CHECK_ERROR


#include <iostream>
#include <fstream>


using namespace std;




#define NUM_BLOCKS 1000
#define NUM_THREADS 1000  // threads per block
#define N 1000
#define DT 0.001


#define SEED (time(NULL)) // random seed





/***
 * Device functions
 ***/


__global__ void initialize(float *dev_W0){

  int tid = threadIdx.x;
  int bid = blockIdx.x;
  int tt = bid*NUM_BLOCKS+tid;

  dev_W0[tt] = 0.0;
}


__global__ void update_W(float *dev_W0, float *dev_W){

  int tid = threadIdx.x;
  int bid = blockIdx.x;
  int tt = bid*NUM_BLOCKS+tid;

  dev_W0[tt] = dev_W0[tt]+sqrt(DT)*dev_W[tt];

}


/*
main function
*/

int main(void)
{
  
  int i,j;

  curandGenerator_t gen;
  curandCreateGenerator(&gen, CURAND_RNG_PSEUDO_MTGP32);
  curandSetPseudoRandomGeneratorSeed(gen,1234ULL);


  // this is for timing
  clock_t starttime=clock();

  // allocate memory
  float **W;
	W = (float**)malloc(N*sizeof(float*));
  if (W==NULL)
    {
      printf("Can't memalloc W\n");
      return 0;
    }
  
  for (i=0; i<N; i++)
    {
      W[i]=(float*)malloc((NUM_BLOCKS*NUM_THREADS)*sizeof(float));
      if (W[i]==NULL)
        {
          printf("Can't memalloc W[%d]\n",i);
          return 0;
        }
    }



  float *dev_W;
  cudaMalloc( (void**)&dev_W, NUM_BLOCKS*NUM_THREADS*sizeof(float) );
  
  float *dev_W0;
  cudaMalloc( (void**)&dev_W0, NUM_BLOCKS*NUM_THREADS*sizeof(float) );

  initialize<<<NUM_BLOCKS,NUM_THREADS>>>(dev_W0);
  cudaMemcpy(W[0], dev_W0, NUM_BLOCKS*NUM_THREADS*sizeof(float), cudaMemcpyDeviceToHost);
  for(i=1;i<N;i++){
    curandGenerateNormal(gen, dev_W, NUM_BLOCKS*NUM_THREADS, 0.0,1.0);
    update_W<<<NUM_BLOCKS,NUM_THREADS>>>(dev_W0, dev_W);
    cudaMemcpy(W[i], dev_W0, NUM_BLOCKS*NUM_THREADS*sizeof(float), cudaMemcpyDeviceToHost);
  }



  cudaFree(dev_W0);
  cudaFree(dev_W);

  printf("Time elapsed: %f \n",  ((double)clock() - starttime)/CLOCKS_PER_SEC);
    


  printf("Saving a few paths to a file ... \n");
  int myidx[10] = {12, 3234, 534534, 534, 45345, 3434, 999999, 13135, 38, 89343};
  FILE *file1;
  FILE *file2;

  file1 = fopen("path_matrix.txt","w");
  for(j=0;j<N;j++){
    for(i=0;i<10;i++){
        fprintf(file1,"%.6f ", W[j][ myidx[i] ]);
    }
    fprintf(file1, "\n");
  }
  fclose(file1);


  // check to see if W(0.5) and W(1) have the correct distributions
  file2 = fopen("for_hist.txt","w");
  for(j=0;j<1000000;j++){
    fprintf(file2, "%.6f, ", W[499][j]);
    fprintf(file2, "%.6f\n", W[999][j]);
  }
  fclose(file2);


  free(W);

  return 1;
}
	.file	"tmpxft_0021ec9e_00000000-6_bm.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB3983:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE3983:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z30__device_stub__Z10initializePfPf
	.type	_Z30__device_stub__Z10initializePfPf, @function
_Z30__device_stub__Z10initializePfPf:
.LFB4005:
	.cfi_startproc
	endbr64
	subq	$104, %rsp
	.cfi_def_cfa_offset 112
	movq	%rdi, 8(%rsp)
	leaq	24(%rsp), %rcx
	leaq	16(%rsp), %rdx
	leaq	44(%rsp), %rsi
	leaq	32(%rsp), %rdi
	movq	%fs:40, %rax
	movq	%rax, 88(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rax
	movl	$1, 40(%rsp)
	movq	%rax, 80(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 32(%rsp)
	movq	%rax, 44(%rsp)
	movl	$1, 52(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L2
	pushq	24(%rsp)
	.cfi_def_cfa_offset 120
	leaq	_Z10initializePf(%rip), %rdi
	pushq	24(%rsp)
	.cfi_def_cfa_offset 128
	movq	60(%rsp), %rcx
	movl	68(%rsp), %r8d
	movq	48(%rsp), %rsi
	movl	56(%rsp), %edx
	leaq	96(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 120
	popq	%rdx
	.cfi_def_cfa_offset 112
.L2:
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	je	.L4
	call	__stack_chk_fail@PLT
.L4:
	addq	$104, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE4005:
	.size	_Z30__device_stub__Z10initializePfPf, .-_Z30__device_stub__Z10initializePfPf
	.globl	_Z10initializePf
	.type	_Z10initializePf, @function
_Z10initializePf:
.LFB4006:
	.cfi_startproc
	endbr64
	jmp	_Z30__device_stub__Z10initializePfPf
	.cfi_endproc
.LFE4006:
	.size	_Z10initializePf, .-_Z10initializePf
	.globl	_Z29__device_stub__Z8update_WPfS_PfS_
	.type	_Z29__device_stub__Z8update_WPfS_PfS_, @function
_Z29__device_stub__Z8update_WPfS_PfS_:
.LFB4007:
	.cfi_startproc
	endbr64
	subq	$120, %rsp
	.cfi_def_cfa_offset 128
	movq	%rdi, 8(%rsp)
	leaq	32(%rsp), %rcx
	leaq	24(%rsp), %rdx
	movq	%rsi, (%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)
	movq	%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	.L8
	pushq	32(%rsp)
	.cfi_def_cfa_offset 136
	leaq	_Z8update_WPfS_(%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
.L8:
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	je	.L10
	call	__stack_chk_fail@PLT
.L10:
	addq	$120, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE4007:
	.size	_Z29__device_stub__Z8update_WPfS_PfS_, .-_Z29__device_stub__Z8update_WPfS_PfS_
	.globl	_Z8update_WPfS_
	.type	_Z8update_WPfS_, @function
_Z8update_WPfS_:
.LFB4008:
	.cfi_startproc
	endbr64
	jmp	_Z29__device_stub__Z8update_WPfS_PfS_
	.cfi_endproc
.LFE4008:
	.size	_Z8update_WPfS_, .-_Z8update_WPfS_
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC1:
	.string	"Can't memalloc W\n"
.LC2:
	.string	"Can't memalloc W[%d]\n"
.LC6:
	.string	"Time elapsed: %f \n"
.LC7:
	.string	"Saving a few paths to a file ... \n"
.LC8:
	.string	"w"
.LC9:
	.string	"path_matrix.txt"
.LC10:
	.string	"%.6f "
.LC11:
	.string	"\n"
.LC12:
	.string	"for_hist.txt"
.LC13:
	.string	"%.6f, "
.LC14:
	.string	"%.6f\n"
	.section	.rodata
	.align 32
.LC0:
	.long	12
	.long	3234
	.long	534534
	.long	534
	.long	45345
	.long	3434
	.long	999999
	.long	13135
	.long	38
	.long	89343
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB3980:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	$141, %esi
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$120, %rsp
	.cfi_def_cfa_offset 176
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	leaq	16(%rsp), %rdi
	call	curandCreateGenerator@PLT
	movq	16(%rsp), %rdi
	movl	$1234, %esi
	call	curandSetPseudoRandomGeneratorSeed@PLT
	call	clock@PLT
	movl	$8000, %edi
	movq	%rax, %r12
	call	malloc@PLT
	testq	%rax, %rax
	jne	.L32
	leaq	.LC1(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L15
.L32:
	movq	%rax, %rbx
	xorl	%ebp, %ebp
.L14:
	movl	$4000000, %edi
	call	malloc@PLT
	movq	%rax, (%rbx,%rbp,8)
	testq	%rax, %rax
	jne	.L16
	movl	%ebp, %edx
	leaq	.LC2(%rip), %rsi
	movl	$2, %edi
	call	__printf_chk@PLT
.L15:
	xorl	%eax, %eax
	jmp	.L13
.L16:
	incq	%rbp
	cmpq	$1000, %rbp
	jne	.L14
	leaq	24(%rsp), %rdi
	movl	$4000000, %esi
	call	cudaMalloc@PLT
	leaq	32(%rsp), %rdi
	movl	$4000000, %esi
	call	cudaMalloc@PLT
	movl	$536871037, %edi
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	salq	$3, %rdi
	movl	$1, %ecx
	movl	$1, %esi
	movl	$1, 60(%rsp)
	movq	%rdi, %rdx
	movq	%rdi, 52(%rsp)
	movq	%rdi, 40(%rsp)
	movl	$1, 48(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L18
	movq	32(%rsp), %rdi
	call	_Z30__device_stub__Z10initializePfPf
.L18:
	movq	32(%rsp), %rsi
	movq	(%rbx), %rdi
	movl	$2, %ecx
	movl	$4000000, %edx
	movl	$1, %ebp
	call	cudaMemcpy@PLT
.L20:
	movq	24(%rsp), %rsi
	movq	16(%rsp), %rdi
	movl	$1000000, %edx
	xorps	%xmm0, %xmm0
	movss	.LC3(%rip), %xmm1
	call	curandGenerateNormal@PLT
	movl	$536871037, %edi
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	salq	$3, %rdi
	movl	$1, %ecx
	movl	$1, %esi
	movl	$1, 60(%rsp)
	movq	%rdi, %rdx
	movq	%rdi, 52(%rsp)
	movq	%rdi, 40(%rsp)
	movl	$1, 48(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L19
	movq	24(%rsp), %rsi
	movq	32(%rsp), %rdi
	call	_Z29__device_stub__Z8update_WPfS_PfS_
.L19:
	movq	(%rbx,%rbp,8), %rdi
	movq	32(%rsp), %rsi
	movl	$2, %ecx
	incq	%rbp
	movl	$4000000, %edx
	call	cudaMemcpy@PLT
	cmpq	$1000, %rbp
	jne	.L20
	movq	32(%rsp), %rdi
	leaq	.LC8(%rip), %r13
	xorl	%ebp, %ebp
	leaq	64(%rsp), %r15
	leaq	.LC10(%rip), %r14
	call	cudaFree@PLT
	movq	24(%rsp), %rdi
	call	cudaFree@PLT
	call	clock@PLT
	cvtsi2sdq	%r12, %xmm1
	movl	$2, %edi
	leaq	.LC6(%rip), %rsi
	cvtsi2sdq	%rax, %xmm0
	movb	$1, %al
	subsd	%xmm1, %xmm0
	divsd	.LC5(%rip), %xmm0
	call	__printf_chk@PLT
	leaq	.LC7(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	64(%rsp), %rdi
	movl	$10, %ecx
	leaq	.LC0(%rip), %rsi
	rep movsl
	movq	%r13, %rsi
	leaq	.LC9(%rip), %rdi
	call	fopen@PLT
	movq	%rax, 8(%rsp)
.L21:
	xorl	%r12d, %r12d
.L22:
	movslq	(%r15,%r12,4), %rdx
	movq	(%rbx,%rbp,8), %rax
	movl	$2, %esi
	incq	%r12
	movq	8(%rsp), %rdi
	cvtss2sd	(%rax,%rdx,4), %xmm0
	movq	%r14, %rdx
	movb	$1, %al
	call	__fprintf_chk@PLT
	cmpq	$10, %r12
	jne	.L22
	movq	8(%rsp), %rdi
	movl	$2, %esi
	xorl	%eax, %eax
	incq	%rbp
	leaq	.LC11(%rip), %rdx
	call	__fprintf_chk@PLT
	cmpq	$1000, %rbp
	jne	.L21
	movq	8(%rsp), %rdi
	xorl	%r12d, %r12d
	call	fclose@PLT
	movq	%r13, %rsi
	leaq	.LC12(%rip), %rdi
	leaq	.LC13(%rip), %r13
	call	fopen@PLT
	movq	%rax, %rbp
.L24:
	movq	3992(%rbx), %rax
	movq	%r13, %rdx
	movl	$2, %esi
	movq	%rbp, %rdi
	cvtss2sd	(%rax,%r12), %xmm0
	movb	$1, %al
	call	__fprintf_chk@PLT
	movq	7992(%rbx), %rax
	movl	$2, %esi
	movq	%rbp, %rdi
	leaq	.LC14(%rip), %rdx
	cvtss2sd	(%rax,%r12), %xmm0
	movb	$1, %al
	addq	$4, %r12
	call	__fprintf_chk@PLT
	cmpq	$4000000, %r12
	jne	.L24
	movq	%rbp, %rdi
	call	fclose@PLT
	movq	%rbx, %rdi
	call	free@PLT
	movl	$1, %eax
.L13:
	movq	104(%rsp), %rdx
	subq	%fs:40, %rdx
	je	.L25
	call	__stack_chk_fail@PLT
.L25:
	addq	$120, %rsp
	.cfi_def_cfa_offset 56
	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
.LFE3980:
	.size	main, .-main
	.section	.rodata.str1.1
.LC16:
	.string	"_Z8update_WPfS_"
.LC17:
	.string	"_Z10initializePf"
.LC18:
	.string	"precalc_xorwow_matrix"
.LC19:
	.string	"precalc_xorwow_offset_matrix"
.LC20:
	.string	"mrg32k3aM1"
.LC21:
	.string	"mrg32k3aM2"
.LC22:
	.string	"mrg32k3aM1SubSeq"
.LC23:
	.string	"mrg32k3aM2SubSeq"
.LC24:
	.string	"mrg32k3aM1Seq"
.LC25:
	.string	"mrg32k3aM2Seq"
.LC26:
	.string	"__cr_lgamma_table"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB4010:
	.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	.LC16(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z8update_WPfS_(%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	.LC17(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z10initializePf(%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	.LC18(%rip), %rdx
	movl	$102400, %r9d
	leaq	_ZL21precalc_xorwow_matrix(%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	.LC19(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movq	%rdx, %rcx
	movl	$102400, %r9d
	leaq	_ZL28precalc_xorwow_offset_matrix(%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	.LC20(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movq	%rdx, %rcx
	movl	$2304, %r9d
	leaq	_ZL10mrg32k3aM1(%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	.LC21(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movq	%rdx, %rcx
	movl	$2304, %r9d
	leaq	_ZL10mrg32k3aM2(%rip), %rsi
	call	__cudaRegisterVar@PLT
	popq	%r9
	.cfi_def_cfa_offset 24
	popq	%r10
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC22(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movq	%rdx, %rcx
	movl	$2016, %r9d
	leaq	_ZL16mrg32k3aM1SubSeq(%rip), %rsi
	call	__cudaRegisterVar@PLT
	popq	%r11
	.cfi_def_cfa_offset 24
	popq	%rax
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC23(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movq	%rdx, %rcx
	movl	$2016, %r9d
	leaq	_ZL16mrg32k3aM2SubSeq(%rip), %rsi
	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	.LC24(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movq	%rdx, %rcx
	movl	$2304, %r9d
	leaq	_ZL13mrg32k3aM1Seq(%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	.LC25(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movq	%rdx, %rcx
	movl	$2304, %r9d
	leaq	_ZL13mrg32k3aM2Seq(%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	$1
	.cfi_def_cfa_offset 32
	leaq	.LC26(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movl	$72, %r9d
	movq	%rdx, %rcx
	leaq	_ZL17__cr_lgamma_table(%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
.LFE4010:
	.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	_ZL17__cr_lgamma_table
	.comm	_ZL17__cr_lgamma_table,72,32
	.local	_ZL13mrg32k3aM2Seq
	.comm	_ZL13mrg32k3aM2Seq,2304,32
	.local	_ZL13mrg32k3aM1Seq
	.comm	_ZL13mrg32k3aM1Seq,2304,32
	.local	_ZL16mrg32k3aM2SubSeq
	.comm	_ZL16mrg32k3aM2SubSeq,2016,32
	.local	_ZL16mrg32k3aM1SubSeq
	.comm	_ZL16mrg32k3aM1SubSeq,2016,32
	.local	_ZL10mrg32k3aM2
	.comm	_ZL10mrg32k3aM2,2304,32
	.local	_ZL10mrg32k3aM1
	.comm	_ZL10mrg32k3aM1,2304,32
	.local	_ZL28precalc_xorwow_offset_matrix
	.comm	_ZL28precalc_xorwow_offset_matrix,102400,32
	.local	_ZL21precalc_xorwow_matrix
	.comm	_ZL21precalc_xorwow_matrix,102400,32
	.section	.rodata.cst4,"aM",@progbits,4
	.align 4
.LC3:
	.long	1065353216
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC5:
	.long	0
	.long	1093567616
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

#include <stddef.h>  // NULL, size_t
#include <math.h> // expf
#include <stdio.h> // printf
#include <time.h> // time
#include <sys/time.h> // gettimeofday
#include <assert.h>



#include <hiprand/hiprand.h>
#include <hip/hip_runtime.h>
#include <hiprand/hiprand_kernel.h>
//#include "cutil.h" // CUDA_SAFE_CALL, CUT_CHECK_ERROR


#include <iostream>
#include <fstream>


using namespace std;




#define NUM_BLOCKS 1000
#define NUM_THREADS 1000  // threads per block
#define N 1000
#define DT 0.001


#define SEED (time(NULL)) // random seed





/***
 * Device functions
 ***/


__global__ void initialize(float *dev_W0){

  int tid = threadIdx.x;
  int bid = blockIdx.x;
  int tt = bid*NUM_BLOCKS+tid;

  dev_W0[tt] = 0.0;
}


__global__ void update_W(float *dev_W0, float *dev_W){

  int tid = threadIdx.x;
  int bid = blockIdx.x;
  int tt = bid*NUM_BLOCKS+tid;

  dev_W0[tt] = dev_W0[tt]+sqrt(DT)*dev_W[tt];

}


/*
main function
*/

int main(void)
{
  
  int i,j;

  hiprandGenerator_t gen;
  hiprandCreateGenerator(&gen, HIPRAND_RNG_PSEUDO_MTGP32);
  hiprandSetPseudoRandomGeneratorSeed(gen,1234ULL);


  // this is for timing
  clock_t starttime=clock();

  // allocate memory
  float **W;
	W = (float**)malloc(N*sizeof(float*));
  if (W==NULL)
    {
      printf("Can't memalloc W\n");
      return 0;
    }
  
  for (i=0; i<N; i++)
    {
      W[i]=(float*)malloc((NUM_BLOCKS*NUM_THREADS)*sizeof(float));
      if (W[i]==NULL)
        {
          printf("Can't memalloc W[%d]\n",i);
          return 0;
        }
    }



  float *dev_W;
  hipMalloc( (void**)&dev_W, NUM_BLOCKS*NUM_THREADS*sizeof(float) );
  
  float *dev_W0;
  hipMalloc( (void**)&dev_W0, NUM_BLOCKS*NUM_THREADS*sizeof(float) );

  initialize<<<NUM_BLOCKS,NUM_THREADS>>>(dev_W0);
  hipMemcpy(W[0], dev_W0, NUM_BLOCKS*NUM_THREADS*sizeof(float), hipMemcpyDeviceToHost);
  for(i=1;i<N;i++){
    hiprandGenerateNormal(gen, dev_W, NUM_BLOCKS*NUM_THREADS, 0.0,1.0);
    update_W<<<NUM_BLOCKS,NUM_THREADS>>>(dev_W0, dev_W);
    hipMemcpy(W[i], dev_W0, NUM_BLOCKS*NUM_THREADS*sizeof(float), hipMemcpyDeviceToHost);
  }



  hipFree(dev_W0);
  hipFree(dev_W);

  printf("Time elapsed: %f \n",  ((double)clock() - starttime)/CLOCKS_PER_SEC);
    


  printf("Saving a few paths to a file ... \n");
  int myidx[10] = {12, 3234, 534534, 534, 45345, 3434, 999999, 13135, 38, 89343};
  FILE *file1;
  FILE *file2;

  file1 = fopen("path_matrix.txt","w");
  for(j=0;j<N;j++){
    for(i=0;i<10;i++){
        fprintf(file1,"%.6f ", W[j][ myidx[i] ]);
    }
    fprintf(file1, "\n");
  }
  fclose(file1);


  // check to see if W(0.5) and W(1) have the correct distributions
  file2 = fopen("for_hist.txt","w");
  for(j=0;j<1000000;j++){
    fprintf(file2, "%.6f, ", W[499][j]);
    fprintf(file2, "%.6f\n", W[999][j]);
  }
  fclose(file2);


  free(W);

  return 1;
}
	.text
	.file	"bm.hip"
                                        # Start of file scope inline assembly
	.globl	_ZSt21ios_base_library_initv

                                        # End of file scope inline assembly
	.globl	_Z25__device_stub__initializePf # -- Begin function _Z25__device_stub__initializePf
	.type	_Z25__device_stub__initializePf,@function
_Z25__device_stub__initializePf:        # @_Z25__device_stub__initializePf
	.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	$64, %rsp
	.cfi_def_cfa_offset 112
	.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)
	movq	%rsp, %rbx
	movq	%rax, (%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	$_Z10initializePf, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$80, %rsp
	.cfi_adjust_cfa_offset -80
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	_Z25__device_stub__initializePf, .Lfunc_end0-_Z25__device_stub__initializePf
	.cfi_endproc
                                        # -- End function
	.globl	_Z23__device_stub__update_WPfS_ # -- Begin function _Z23__device_stub__update_WPfS_
	.type	_Z23__device_stub__update_WPfS_,@function
_Z23__device_stub__update_WPfS_:        # @_Z23__device_stub__update_WPfS_
	.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	16(%rsp), %rcx
	movq	%rsi, (%rcx)
	leaq	64(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	leaq	48(%rsp), %r14
	leaq	32(%rsp), %r15
	leaq	8(%rsp), %r12
	movq	%rsp, %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z8update_WPfS_, %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	_Z23__device_stub__update_WPfS_, .Lfunc_end1-_Z23__device_stub__update_WPfS_
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function main
.LCPI2_0:
	.long	0x3f800000                      # float 1
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0
.LCPI2_1:
	.quad	0x412e848000000000              # double 1.0E+6
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0
.LCPI2_2:
	.long	12                              # 0xc
	.long	3234                            # 0xca2
	.long	534534                          # 0x82806
	.long	534                             # 0x216
.LCPI2_3:
	.long	45345                           # 0xb121
	.long	3434                            # 0xd6a
	.long	999999                          # 0xf423f
	.long	13135                           # 0x334f
	.text
	.globl	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	%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), %rbx
	movq	%rbx, %rdi
	movl	$403, %esi                      # imm = 0x193
	callq	hiprandCreateGenerator
	movq	(%rbx), %rdi
	movl	$1234, %esi                     # imm = 0x4D2
	callq	hiprandSetPseudoRandomGeneratorSeed
	callq	clock
	movq	%rax, %r14
	movl	$8000, %edi                     # imm = 0x1F40
	callq	malloc
	testq	%rax, %rax
	je	.LBB2_19
# %bb.1:                                # %.preheader55.preheader
	movq	%rax, %rbx
	xorl	%r15d, %r15d
.LBB2_2:                                # %.preheader55
                                        # =>This Inner Loop Header: Depth=1
	movl	$4000000, %edi                  # imm = 0x3D0900
	callq	malloc
	movq	%rax, (%rbx,%r15,8)
	testq	%rax, %rax
	je	.LBB2_3
# %bb.4:                                #   in Loop: Header=BB2_2 Depth=1
	incq	%r15
	cmpq	$1000, %r15                     # imm = 0x3E8
	jne	.LBB2_2
# %bb.5:
	movabsq	$4294968296, %r15               # imm = 0x1000003E8
	leaq	16(%rsp), %rdi
	movl	$4000000, %esi                  # imm = 0x3D0900
	callq	hipMalloc
	leaq	8(%rsp), %rdi
	movl	$4000000, %esi                  # imm = 0x3D0900
	callq	hipMalloc
	movq	%r15, %rdi
	movl	$1, %esi
	movq	%r15, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB2_7
# %bb.6:
	movq	8(%rsp), %rdi
	callq	_Z25__device_stub__initializePf
.LBB2_7:
	movq	(%rbx), %rdi
	movq	8(%rsp), %rsi
	movl	$4000000, %edx                  # imm = 0x3D0900
	movl	$2, %ecx
	callq	hipMemcpy
	movl	$1, %r12d
.LBB2_8:                                # =>This Inner Loop Header: Depth=1
	movq	24(%rsp), %rdi
	movq	16(%rsp), %rsi
	movl	$1000000, %edx                  # imm = 0xF4240
	xorps	%xmm0, %xmm0
	movss	.LCPI2_0(%rip), %xmm1           # xmm1 = mem[0],zero,zero,zero
	callq	hiprandGenerateNormal
	movq	%r15, %rdi
	movl	$1, %esi
	movq	%r15, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB2_10
# %bb.9:                                #   in Loop: Header=BB2_8 Depth=1
	movq	8(%rsp), %rdi
	movq	16(%rsp), %rsi
	callq	_Z23__device_stub__update_WPfS_
.LBB2_10:                               #   in Loop: Header=BB2_8 Depth=1
	movq	(%rbx,%r12,8), %rdi
	movq	8(%rsp), %rsi
	movl	$4000000, %edx                  # imm = 0x3D0900
	movl	$2, %ecx
	callq	hipMemcpy
	incq	%r12
	cmpq	$1000, %r12                     # imm = 0x3E8
	jne	.LBB2_8
# %bb.11:
	movq	8(%rsp), %rdi
	callq	hipFree
	movq	16(%rsp), %rdi
	callq	hipFree
	callq	clock
	xorps	%xmm0, %xmm0
	cvtsi2sd	%rax, %xmm0
	xorps	%xmm1, %xmm1
	cvtsi2sd	%r14, %xmm1
	subsd	%xmm1, %xmm0
	divsd	.LCPI2_1(%rip), %xmm0
	movl	$.L.str.2, %edi
	movb	$1, %al
	callq	printf
	movl	$.Lstr, %edi
	callq	puts@PLT
	movaps	.LCPI2_2(%rip), %xmm0           # xmm0 = [12,3234,534534,534]
	movaps	%xmm0, 32(%rsp)
	movaps	.LCPI2_3(%rip), %xmm0           # xmm0 = [45345,3434,999999,13135]
	movaps	%xmm0, 48(%rsp)
	movabsq	$383725263126566, %rax          # imm = 0x15CFF00000026
	movq	%rax, 64(%rsp)
	movl	$.L.str.4, %edi
	movl	$.L.str.5, %esi
	callq	fopen
	movq	%rax, %r14
	xorl	%r15d, %r15d
.LBB2_12:                               # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB2_13 Depth 2
	movq	(%rbx,%r15,8), %r12
	xorl	%r13d, %r13d
.LBB2_13:                               #   Parent Loop BB2_12 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movslq	32(%rsp,%r13,4), %rax
	xorps	%xmm0, %xmm0
	cvtss2sd	(%r12,%rax,4), %xmm0
	movl	$.L.str.6, %esi
	movq	%r14, %rdi
	movb	$1, %al
	callq	fprintf
	incq	%r13
	cmpq	$10, %r13
	jne	.LBB2_13
# %bb.14:                               #   in Loop: Header=BB2_12 Depth=1
	movl	$10, %edi
	movq	%r14, %rsi
	callq	fputc@PLT
	incq	%r15
	cmpq	$1000, %r15                     # imm = 0x3E8
	jne	.LBB2_12
# %bb.15:
	movq	%r14, %rdi
	callq	fclose
	movl	$.L.str.8, %edi
	movl	$.L.str.5, %esi
	callq	fopen
	movq	%rax, %r14
	movq	3992(%rbx), %r15
	xorl	%r12d, %r12d
.LBB2_16:                               # =>This Inner Loop Header: Depth=1
	xorps	%xmm0, %xmm0
	cvtss2sd	(%r15,%r12,4), %xmm0
	movl	$.L.str.9, %esi
	movq	%r14, %rdi
	movb	$1, %al
	callq	fprintf
	movq	7992(%rbx), %rax
	xorps	%xmm0, %xmm0
	cvtss2sd	(%rax,%r12,4), %xmm0
	movl	$.L.str.10, %esi
	movq	%r14, %rdi
	movb	$1, %al
	callq	fprintf
	incq	%r12
	cmpq	$1000000, %r12                  # imm = 0xF4240
	jne	.LBB2_16
# %bb.17:
	movq	%r14, %rdi
	callq	fclose
	movq	%rbx, %rdi
	callq	free
	movl	$1, %ebx
	jmp	.LBB2_18
.LBB2_19:
	movl	$.Lstr.1, %edi
	callq	puts@PLT
	xorl	%ebx, %ebx
	jmp	.LBB2_18
.LBB2_3:
	xorl	%ebx, %ebx
	movl	$.L.str.1, %edi
	movl	%r15d, %esi
	xorl	%eax, %eax
	callq	printf
.LBB2_18:
	movl	%ebx, %eax
	addq	$80, %rsp
	.cfi_def_cfa_offset 48
	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	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
	subq	$32, %rsp
	.cfi_def_cfa_offset 48
	.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:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z10initializePf, %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	$_Z8update_WPfS_, %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_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	_Z10initializePf,@object        # @_Z10initializePf
	.section	.rodata,"a",@progbits
	.globl	_Z10initializePf
	.p2align	3, 0x0
_Z10initializePf:
	.quad	_Z25__device_stub__initializePf
	.size	_Z10initializePf, 8

	.type	_Z8update_WPfS_,@object         # @_Z8update_WPfS_
	.globl	_Z8update_WPfS_
	.p2align	3, 0x0
_Z8update_WPfS_:
	.quad	_Z23__device_stub__update_WPfS_
	.size	_Z8update_WPfS_, 8

	.type	.L.str.1,@object                # @.str.1
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.1:
	.asciz	"Can't memalloc W[%d]\n"
	.size	.L.str.1, 22

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"Time elapsed: %f \n"
	.size	.L.str.2, 19

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"path_matrix.txt"
	.size	.L.str.4, 16

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"w"
	.size	.L.str.5, 2

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"%.6f "
	.size	.L.str.6, 6

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"for_hist.txt"
	.size	.L.str.8, 13

	.type	.L.str.9,@object                # @.str.9
.L.str.9:
	.asciz	"%.6f, "
	.size	.L.str.9, 7

	.type	.L.str.10,@object               # @.str.10
.L.str.10:
	.asciz	"%.6f\n"
	.size	.L.str.10, 6

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

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_Z8update_WPfS_"
	.size	.L__unnamed_2, 16

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

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

	.type	.Lstr,@object                   # @str
	.section	.rodata.str1.1,"aMS",@progbits,1
.Lstr:
	.asciz	"Saving a few paths to a file ... "
	.size	.Lstr, 34

	.type	.Lstr.1,@object                 # @str.1
.Lstr.1:
	.asciz	"Can't memalloc W"
	.size	.Lstr.1, 17

	.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 _Z25__device_stub__initializePf
	.addrsig_sym _Z23__device_stub__update_WPfS_
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z10initializePf
	.addrsig_sym _Z8update_WPfS_
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z10initializePf        ; -- Begin function _Z10initializePf
	.globl	_Z10initializePf
	.p2align	8
	.type	_Z10initializePf,@function
_Z10initializePf:                       ; @_Z10initializePf
; %bb.0:
	s_load_b64 s[0:1], s[0:1], 0x0
	v_mad_u64_u32 v[1:2], null, 0x3e8, s15, v[0:1]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v2, 31, v1
	v_lshlrev_b64 v[0:1], 2, v[1:2]
	v_mov_b32_e32 v2, 0
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_co_u32 v0, vcc_lo, s0, v0
	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 _Z10initializePf
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 8
		.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 3
		.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	_Z10initializePf, .Lfunc_end0-_Z10initializePf
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 80
; NumSgprs: 18
; NumVgprs: 3
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 3
; 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	_Z8update_WPfS_         ; -- Begin function _Z8update_WPfS_
	.globl	_Z8update_WPfS_
	.p2align	8
	.type	_Z8update_WPfS_,@function
_Z8update_WPfS_:                        ; @_Z8update_WPfS_
; %bb.0:
	s_load_b128 s[0:3], s[0:1], 0x0
	v_mad_u64_u32 v[1:2], null, 0x3e8, s15, v[0:1]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v2, 31, v1
	v_lshlrev_b64 v[0:1], 2, v[1:2]
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v2, vcc_lo, s0, v0
	v_add_co_ci_u32_e32 v3, vcc_lo, s1, v1, vcc_lo
	v_add_co_u32 v0, vcc_lo, s2, v0
	v_add_co_ci_u32_e32 v1, vcc_lo, s3, v1, vcc_lo
	s_mov_b32 s0, 0x4ea03a72
	global_load_b32 v4, v[2:3], off
	global_load_b32 v5, v[0:1], off
	s_mov_b32 s1, 0x3fa030dc
	s_waitcnt vmcnt(1)
	v_cvt_f64_f32_e32 v[0:1], v4
	s_waitcnt vmcnt(0)
	v_cvt_f64_f32_e32 v[4:5], v5
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[0:1], v[4:5], s[0:1], v[0:1]
	v_cvt_f32_f64_e32 v0, v[0:1]
	global_store_b32 v[2:3], v0, off
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z8update_WPfS_
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 16
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 6
		.amdhsa_next_free_sgpr 16
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end1:
	.size	_Z8update_WPfS_, .Lfunc_end1-_Z8update_WPfS_
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 152
; NumSgprs: 18
; NumVgprs: 6
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 6
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __hip_cuid_
	.amdgpu_metadata
---
amdhsa.kernels:
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 8
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z10initializePf
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z10initializePf.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     3
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 16
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z8update_WPfS_
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z8update_WPfS_.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     6
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
