/**
   Sample for Mobile CUDA
   Simple Adding Vectors Application.

   Authoer @ Taichirou Suzuki
**/

#include <stdio.h>
#include <stdlib.h>
#include <cuda_runtime.h>
#include <unistd.h>
#include <sys/wait.h>
#include <sys/time.h>

/**
   Simple Kernel.
**/
__global__ void ___add(float* a,float* b,unsigned long size){
  int _x = blockDim.x * blockIdx.x + threadIdx.x;
  int _y = blockDim.y * blockIdx.y + threadIdx.y;
  
  unsigned long id = _x + _y * size;

  a[id] += b[id];
}

static float elapsed(struct timeval tv0,struct timeval tv1){
  return (float)(tv1.tv_sec - tv0.tv_sec)
    + (float)(tv1.tv_usec - tv0.tv_usec)
    * 0.000001f;
}

int main(void){

  struct timeval t0,t1;

  gettimeofday(&t0,NULL);
  
  /**
     Define Vector Size.
  **/
  //  unsigned long _hen = 11000;
  unsigned long _hen = 14000;
  //  unsigned long _hen = 18000;
  unsigned long size = _hen * _hen;
  printf("gyouretu size : %lu\n",size);
  /**
     Number Of Launch Kernel.
  **/
  int numOfLaunchKernel = 1;
  //int numOfLaunchKernel = 1;

  cudaSetDevice(0);

  //  float* h_a = (float*)malloc(sizeof(float)*size);
  //  float* h_b = (float*)malloc(sizeof(float)*size);

  float* d_a = NULL;
  float* d_b = NULL;
  //  float* d_c = NULL;

  cudaMalloc((void**)&d_a,sizeof(float)*size);
  cudaMalloc((void**)&d_b,sizeof(float)*size);
  //  cudaMalloc((void**)&d_c,sizeof(float)*size);

  float* h_a = NULL;
  float* h_b = NULL;
  /*
  cudaError_t res;
  res = cudaHostAlloc((void **)&h_a,sizeof(float)*size,0);
  printf("cudaHostAlloc : %d\n",res);
  res = cudaHostAlloc((void **)&h_b,sizeof(float)*size,0);
  printf("cudaHostAlloc : %d\n",res);
  */

  h_a = (float*)malloc(sizeof(float)*size);
  h_b = (float*)malloc(sizeof(float)*size);

  //  float* h_c = (float*)malloc(sizeof(float)*size);

  printf("This Sample Application Uses %d[Mbyte] per vector.(Total : %d[Mbyte])\n",sizeof(float)*size >> 20,sizeof(float)*size*2 >> 20);

  for(int i =  0 ; i < size ; i ++){
    h_a[i] = 0.0f;
    h_b[i] = 1.0f;
  }

  //  int ite = 140;
  int ite = 260;
  //  int ite = 1000000;

  for(int j = 0 ; j < ite ; j ++){

    cudaMemcpy(d_a,h_a,sizeof(float)*size,cudaMemcpyHostToDevice);
    cudaMemcpy(d_b,h_b,sizeof(float)*size,cudaMemcpyHostToDevice);

    int _size = 10;
    dim3 threads(_size,_size,1);
    dim3 grid(_hen/_size,_hen/_size,1);

    for(int i = 0 ; i < numOfLaunchKernel ; i ++){
      //__add<<<grid,threads>>>(d_c,d_a,d_b,_hen);
      ___add<<<grid,threads>>>(d_a,d_b,_hen);
      /**
	 Main thread can sleep at here.
      **/
      //    sleep(1);
    }

    //  cudaMemcpy(h_c,d_c,sizeof(float)*size,cudaMemcpyDeviceToHost);
    cudaMemcpy(h_a,d_a,sizeof(float)*size,cudaMemcpyDeviceToHost);

  }

  int pass = 1;
  for(int i = 0 ; i < size ; i ++){
    //    if(h_c[i] != numOfLaunchKernel){
    //    if(h_a[i] != numOfLaunchKernel){
    if(h_a[i] != ite){
      pass = 0;
    }
  }

  if(pass){
    printf(">Result TEST : PASS\n");
  }else{
    printf(">Result TEST : FAILED\n");
  }

  cudaFree(d_a);
  cudaFree(d_b);
  //  cudaFree(d_c);

  free(h_a);
  free(h_b);
  //  cudaFreeHost(h_a);
  //  cudaFreeHost(h_b);
  //  free(h_c);

  printf("Application Closed...\n");

  gettimeofday(&t1,NULL);

  printf("My RESULT : %f\n",elapsed(t0,t1));

  return 0;
}

	.file	"tmpxft_002b4252_00000000-6_vector.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2044:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2044:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z28__device_stub__Z6___addPfS_mPfS_m
	.type	_Z28__device_stub__Z6___addPfS_mPfS_m, @function
_Z28__device_stub__Z6___addPfS_mPfS_m:
.LFB2066:
	.cfi_startproc
	endbr64
	subq	$136, %rsp
	.cfi_def_cfa_offset 144
	movq	%rdi, 24(%rsp)
	leaq	40(%rsp), %rcx
	leaq	48(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	60(%rsp), %rsi
	movq	%rdx, 8(%rsp)
	leaq	32(%rsp), %rdx
	movq	%fs:40, %rax
	movq	%rax, 120(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 56(%rsp)
	movq	%rax, 96(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 104(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 112(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 48(%rsp)
	movq	%rax, 60(%rsp)
	movl	$1, 68(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L2
	pushq	40(%rsp)
	.cfi_def_cfa_offset 152
	leaq	_Z6___addPfS_m(%rip), %rdi
	pushq	40(%rsp)
	.cfi_def_cfa_offset 160
	movq	76(%rsp), %rcx
	movl	84(%rsp), %r8d
	movq	64(%rsp), %rsi
	movl	72(%rsp), %edx
	leaq	112(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 152
	popq	%rdx
	.cfi_def_cfa_offset 144
.L2:
	movq	120(%rsp), %rax
	subq	%fs:40, %rax
	je	.L4
	call	__stack_chk_fail@PLT
.L4:
	addq	$136, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2066:
	.size	_Z28__device_stub__Z6___addPfS_mPfS_m, .-_Z28__device_stub__Z6___addPfS_mPfS_m
	.globl	_Z6___addPfS_m
	.type	_Z6___addPfS_m, @function
_Z6___addPfS_m:
.LFB2067:
	.cfi_startproc
	endbr64
	jmp	_Z28__device_stub__Z6___addPfS_mPfS_m
	.cfi_endproc
.LFE2067:
	.size	_Z6___addPfS_m, .-_Z6___addPfS_m
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"gyouretu size : %lu\n"
.LC1:
	.string	"This Sample Application Uses %d[Mbyte] per vector.(Total : %d[Mbyte])\n"
.LC4:
	.string	">Result TEST : PASS\n"
.LC5:
	.string	">Result TEST : FAILED\n"
.LC6:
	.string	"Application Closed...\n"
.LC8:
	.string	"My RESULT : %f\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2041:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	xorl	%esi, %esi
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$88, %rsp
	.cfi_def_cfa_offset 128
	movq	%fs:40, %rax
	movq	%rax, 72(%rsp)
	xorl	%eax, %eax
	leaq	40(%rsp), %rdi
	call	gettimeofday@PLT
	movl	$196000000, %edx
	leaq	.LC0(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
	xorl	%edi, %edi
	call	cudaSetDevice@PLT
	xorl	%eax, %eax
	leaq	8(%rsp), %rdi
	movl	$784000000, %esi
	movq	%rax, 8(%rsp)
	movq	%rax, 16(%rsp)
	call	cudaMalloc@PLT
	movl	$784000000, %esi
	leaq	16(%rsp), %rdi
	call	cudaMalloc@PLT
	movl	$784000000, %edi
	call	malloc@PLT
	movl	$784000000, %edi
	movq	%rax, %rbx
	call	malloc@PLT
	movl	$1495, %ecx
	movl	$2, %edi
	movl	$747, %edx
	movq	%rax, %rbp
	leaq	.LC1(%rip), %rsi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	xorl	%eax, %eax
	movl	$196000000, %ecx
	movq	%rbx, %rdi
	rep stosl
	movss	.LC2(%rip), %xmm0
	xorl	%eax, %eax
.L9:
	movss	%xmm0, 0(%rbp,%rax,4)
	incq	%rax
	cmpq	$196000000, %rax
	jne	.L9
	movabsq	$42949672970, %r13
	movl	$260, %r12d
.L11:
	movq	8(%rsp), %rdi
	movl	$1, %ecx
	movl	$784000000, %edx
	movq	%rbx, %rsi
	call	cudaMemcpy@PLT
	movq	16(%rsp), %rdi
	movl	$1, %ecx
	movq	%rbp, %rsi
	movl	$784000000, %edx
	call	cudaMemcpy@PLT
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movq	%r13, %rdx
	movabsq	$6012954215800, %rdi
	movl	$1, %ecx
	movl	$1, %esi
	movl	$1, 64(%rsp)
	movq	%rdi, 56(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L10
	movq	16(%rsp), %rsi
	movq	8(%rsp), %rdi
	movl	$14000, %edx
	call	_Z28__device_stub__Z6___addPfS_mPfS_m
.L10:
	movq	8(%rsp), %rsi
	movl	$2, %ecx
	movl	$784000000, %edx
	movq	%rbx, %rdi
	call	cudaMemcpy@PLT
	decl	%r12d
	jne	.L11
	xorl	%eax, %eax
	movl	$1, %edx
.L14:
	movss	(%rbx,%rax,4), %xmm0
	ucomiss	.LC3(%rip), %xmm0
	jp	.L18
	je	.L12
.L18:
	xorl	%edx, %edx
.L12:
	incq	%rax
	cmpq	$196000000, %rax
	jne	.L14
	leaq	.LC4(%rip), %rsi
	testl	%edx, %edx
	jne	.L23
	leaq	.LC5(%rip), %rsi
.L23:
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	8(%rsp), %rdi
	call	cudaFree@PLT
	movq	16(%rsp), %rdi
	call	cudaFree@PLT
	movq	%rbx, %rdi
	call	free@PLT
	movq	%rbp, %rdi
	call	free@PLT
	leaq	.LC6(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	xorl	%esi, %esi
	leaq	56(%rsp), %rdi
	call	gettimeofday@PLT
	movq	64(%rsp), %rax
	subq	48(%rsp), %rax
	leaq	.LC8(%rip), %rsi
	cvtsi2ssq	%rax, %xmm0
	movq	56(%rsp), %rax
	subq	40(%rsp), %rax
	movl	$2, %edi
	mulss	.LC7(%rip), %xmm0
	cvtsi2ssq	%rax, %xmm1
	movb	$1, %al
	addss	%xmm1, %xmm0
	cvtss2sd	%xmm0, %xmm0
	call	__printf_chk@PLT
	movq	72(%rsp), %rax
	subq	%fs:40, %rax
	je	.L17
	call	__stack_chk_fail@PLT
.L17:
	addq	$88, %rsp
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2041:
	.size	main, .-main
	.section	.rodata.str1.1
.LC9:
	.string	"_Z6___addPfS_m"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2069:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 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	.LC9(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z6___addPfS_m(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 48
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	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	%rdx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE2069:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.section	.rodata.cst4,"aM",@progbits,4
	.align 4
.LC2:
	.long	1065353216
	.align 4
.LC3:
	.long	1132593152
	.align 4
.LC7:
	.long	897988541
	.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:

/**
   Sample for Mobile CUDA
   Simple Adding Vectors Application.

   Authoer @ Taichirou Suzuki
**/

#include <stdio.h>
#include <stdlib.h>
#include <hip/hip_runtime.h>
#include <unistd.h>
#include <sys/wait.h>
#include <sys/time.h>

/**
   Simple Kernel.
**/
__global__ void ___add(float* a,float* b,unsigned long size){
  int _x = blockDim.x * blockIdx.x + threadIdx.x;
  int _y = blockDim.y * blockIdx.y + threadIdx.y;
  
  unsigned long id = _x + _y * size;

  a[id] += b[id];
}

static float elapsed(struct timeval tv0,struct timeval tv1){
  return (float)(tv1.tv_sec - tv0.tv_sec)
    + (float)(tv1.tv_usec - tv0.tv_usec)
    * 0.000001f;
}

int main(void){

  struct timeval t0,t1;

  gettimeofday(&t0,NULL);
  
  /**
     Define Vector Size.
  **/
  //  unsigned long _hen = 11000;
  unsigned long _hen = 14000;
  //  unsigned long _hen = 18000;
  unsigned long size = _hen * _hen;
  printf("gyouretu size : %lu\n",size);
  /**
     Number Of Launch Kernel.
  **/
  int numOfLaunchKernel = 1;
  //int numOfLaunchKernel = 1;

  hipSetDevice(0);

  //  float* h_a = (float*)malloc(sizeof(float)*size);
  //  float* h_b = (float*)malloc(sizeof(float)*size);

  float* d_a = NULL;
  float* d_b = NULL;
  //  float* d_c = NULL;

  hipMalloc((void**)&d_a,sizeof(float)*size);
  hipMalloc((void**)&d_b,sizeof(float)*size);
  //  cudaMalloc((void**)&d_c,sizeof(float)*size);

  float* h_a = NULL;
  float* h_b = NULL;
  /*
  cudaError_t res;
  res = cudaHostAlloc((void **)&h_a,sizeof(float)*size,0);
  printf("cudaHostAlloc : %d\n",res);
  res = cudaHostAlloc((void **)&h_b,sizeof(float)*size,0);
  printf("cudaHostAlloc : %d\n",res);
  */

  h_a = (float*)malloc(sizeof(float)*size);
  h_b = (float*)malloc(sizeof(float)*size);

  //  float* h_c = (float*)malloc(sizeof(float)*size);

  printf("This Sample Application Uses %d[Mbyte] per vector.(Total : %d[Mbyte])\n",sizeof(float)*size >> 20,sizeof(float)*size*2 >> 20);

  for(int i =  0 ; i < size ; i ++){
    h_a[i] = 0.0f;
    h_b[i] = 1.0f;
  }

  //  int ite = 140;
  int ite = 260;
  //  int ite = 1000000;

  for(int j = 0 ; j < ite ; j ++){

    hipMemcpy(d_a,h_a,sizeof(float)*size,hipMemcpyHostToDevice);
    hipMemcpy(d_b,h_b,sizeof(float)*size,hipMemcpyHostToDevice);

    int _size = 10;
    dim3 threads(_size,_size,1);
    dim3 grid(_hen/_size,_hen/_size,1);

    for(int i = 0 ; i < numOfLaunchKernel ; i ++){
      //__add<<<grid,threads>>>(d_c,d_a,d_b,_hen);
      ___add<<<grid,threads>>>(d_a,d_b,_hen);
      /**
	 Main thread can sleep at here.
      **/
      //    sleep(1);
    }

    //  cudaMemcpy(h_c,d_c,sizeof(float)*size,cudaMemcpyDeviceToHost);
    hipMemcpy(h_a,d_a,sizeof(float)*size,hipMemcpyDeviceToHost);

  }

  int pass = 1;
  for(int i = 0 ; i < size ; i ++){
    //    if(h_c[i] != numOfLaunchKernel){
    //    if(h_a[i] != numOfLaunchKernel){
    if(h_a[i] != ite){
      pass = 0;
    }
  }

  if(pass){
    printf(">Result TEST : PASS\n");
  }else{
    printf(">Result TEST : FAILED\n");
  }

  hipFree(d_a);
  hipFree(d_b);
  //  cudaFree(d_c);

  free(h_a);
  free(h_b);
  //  cudaFreeHost(h_a);
  //  cudaFreeHost(h_b);
  //  free(h_c);

  printf("Application Closed...\n");

  gettimeofday(&t1,NULL);

  printf("My RESULT : %f\n",elapsed(t0,t1));

  return 0;
}

	.text
	.file	"vector.hip"
	.globl	_Z21__device_stub_____addPfS_m  # -- Begin function _Z21__device_stub_____addPfS_m
	.type	_Z21__device_stub_____addPfS_m,@function
_Z21__device_stub_____addPfS_m:         # @_Z21__device_stub_____addPfS_m
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$112, %rsp
	.cfi_def_cfa_offset 160
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	32(%rsp), %rcx
	movq	%rsi, (%rcx)
	leaq	24(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	movq	%rsi, 16(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	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	$_Z6___addPfS_m, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$128, %rsp
	.cfi_adjust_cfa_offset -128
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	_Z21__device_stub_____addPfS_m, .Lfunc_end0-_Z21__device_stub_____addPfS_m
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function main
.LCPI1_0:
	.long	0x43820000                      # float 260
.LCPI1_1:
	.long	0x358637bd                      # float 9.99999997E-7
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$48, %rsp
	.cfi_def_cfa_offset 96
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	xorl	%r15d, %r15d
	leaq	16(%rsp), %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	movl	$.L.str, %edi
	movl	$196000000, %esi                # imm = 0xBAEB900
	xorl	%eax, %eax
	callq	printf
	xorl	%edi, %edi
	callq	hipSetDevice
	movq	%rsp, %rdi
	movq	%r15, (%rdi)
	leaq	8(%rsp), %rbx
	movq	%r15, (%rbx)
	movl	$784000000, %esi                # imm = 0x2EBAE400
	callq	hipMalloc
	movl	$784000000, %esi                # imm = 0x2EBAE400
	movq	%rbx, %rdi
	callq	hipMalloc
	movl	$1, %edi
	movl	$784000000, %esi                # imm = 0x2EBAE400
	callq	calloc@PLT
	movq	%rax, %rbx
	movl	$784000000, %edi                # imm = 0x2EBAE400
	callq	malloc
	movq	%rax, %r14
	movl	$.L.str.1, %edi
	movl	$747, %esi                      # imm = 0x2EB
	movl	$1495, %edx                     # imm = 0x5D7
	xorl	%eax, %eax
	callq	printf
.LBB1_1:                                # =>This Inner Loop Header: Depth=1
	movl	$1065353216, (%r14,%r15,4)      # imm = 0x3F800000
	incq	%r15
	cmpq	$196000000, %r15                # imm = 0xBAEB900
	jne	.LBB1_1
# %bb.2:                                # %.critedge.preheader
	movl	$260, %ebp                      # imm = 0x104
	movabsq	$6012954215800, %r15            # imm = 0x57800000578
	movabsq	$42949672970, %r12              # imm = 0xA0000000A
.LBB1_3:                                # %.critedge
                                        # =>This Inner Loop Header: Depth=1
	movq	(%rsp), %rdi
	movl	$784000000, %edx                # imm = 0x2EBAE400
	movq	%rbx, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	movq	8(%rsp), %rdi
	movl	$784000000, %edx                # imm = 0x2EBAE400
	movq	%r14, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	movq	%r15, %rdi
	movl	$1, %esi
	movq	%r12, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB1_5
# %bb.4:                                #   in Loop: Header=BB1_3 Depth=1
	movq	(%rsp), %rdi
	movq	8(%rsp), %rsi
	movl	$14000, %edx                    # imm = 0x36B0
	callq	_Z21__device_stub_____addPfS_m
.LBB1_5:                                #   in Loop: Header=BB1_3 Depth=1
	movq	(%rsp), %rsi
	movl	$784000000, %edx                # imm = 0x2EBAE400
	movq	%rbx, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	decl	%ebp
	jne	.LBB1_3
# %bb.6:                                # %.preheader.preheader
	movl	$1, %eax
	xorl	%ecx, %ecx
	movss	.LCPI1_0(%rip), %xmm0           # xmm0 = mem[0],zero,zero,zero
	xorl	%edx, %edx
.LBB1_7:                                # %.preheader
                                        # =>This Inner Loop Header: Depth=1
	movss	(%rbx,%rdx,4), %xmm1            # xmm1 = mem[0],zero,zero,zero
	ucomiss	%xmm0, %xmm1
	cmovnel	%ecx, %eax
	cmovpl	%ecx, %eax
	incq	%rdx
	cmpq	$196000000, %rdx                # imm = 0xBAEB900
	jne	.LBB1_7
# %bb.8:
	testl	%eax, %eax
	movl	$.Lstr, %eax
	movl	$.Lstr.1, %edi
	cmoveq	%rax, %rdi
	callq	puts@PLT
	movq	(%rsp), %rdi
	callq	hipFree
	movq	8(%rsp), %rdi
	callq	hipFree
	movq	%rbx, %rdi
	callq	free
	movq	%r14, %rdi
	callq	free
	movl	$.Lstr.2, %edi
	callq	puts@PLT
	leaq	32(%rsp), %rbx
	movq	%rbx, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	movq	(%rbx), %rax
	subq	16(%rsp), %rax
	xorps	%xmm0, %xmm0
	cvtsi2ss	%rax, %xmm0
	movq	8(%rbx), %rax
	subq	24(%rsp), %rax
	xorps	%xmm1, %xmm1
	cvtsi2ss	%rax, %xmm1
	mulss	.LCPI1_1(%rip), %xmm1
	addss	%xmm0, %xmm1
	xorps	%xmm0, %xmm0
	cvtss2sd	%xmm1, %xmm0
	movl	$.L.str.5, %edi
	movb	$1, %al
	callq	printf
	xorl	%eax, %eax
	addq	$48, %rsp
	.cfi_def_cfa_offset 48
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end1:
	.size	main, .Lfunc_end1-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:
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	jne	.LBB2_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB2_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z6___addPfS_m, %esi
	movl	$.L__unnamed_1, %edx
	movl	$.L__unnamed_1, %ecx
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$__hip_module_dtor, %edi
	addq	$40, %rsp
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_end2:
	.size	__hip_module_ctor, .Lfunc_end2-__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	.LBB3_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
.LBB3_2:
	retq
.Lfunc_end3:
	.size	__hip_module_dtor, .Lfunc_end3-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	_Z6___addPfS_m,@object          # @_Z6___addPfS_m
	.section	.rodata,"a",@progbits
	.globl	_Z6___addPfS_m
	.p2align	3, 0x0
_Z6___addPfS_m:
	.quad	_Z21__device_stub_____addPfS_m
	.size	_Z6___addPfS_m, 8

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"gyouretu size : %lu\n"
	.size	.L.str, 21

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"This Sample Application Uses %d[Mbyte] per vector.(Total : %d[Mbyte])\n"
	.size	.L.str.1, 71

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"My RESULT : %f\n"
	.size	.L.str.5, 16

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z6___addPfS_m"
	.size	.L__unnamed_1, 15

	.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	">Result TEST : FAILED"
	.size	.Lstr, 22

	.type	.Lstr.1,@object                 # @str.1
.Lstr.1:
	.asciz	">Result TEST : PASS"
	.size	.Lstr.1, 20

	.type	.Lstr.2,@object                 # @str.2
.Lstr.2:
	.asciz	"Application Closed..."
	.size	.Lstr.2, 22

	.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 _Z21__device_stub_____addPfS_m
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z6___addPfS_m
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z6___addPfS_m          ; -- Begin function _Z6___addPfS_m
	.globl	_Z6___addPfS_m
	.p2align	8
	.type	_Z6___addPfS_m,@function
_Z6___addPfS_m:                         ; @_Z6___addPfS_m
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x24
	s_load_b64 s[4:5], s[0:1], 0x10
	v_bfe_u32 v1, v0, 10, 10
	v_and_b32_e32 v0, 0x3ff, v0
	s_waitcnt lgkmcnt(0)
	s_lshr_b32 s3, s2, 16
	s_and_b32 s2, s2, 0xffff
	v_mad_u64_u32 v[2:3], null, s15, s3, v[1:2]
	v_mad_u64_u32 v[3:4], null, s14, s2, v[0:1]
	s_load_b128 s[0:3], s[0:1], 0x0
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_3)
	v_ashrrev_i32_e32 v0, 31, v2
	v_mul_lo_u32 v5, v2, s5
	v_ashrrev_i32_e32 v4, 31, v3
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_mul_lo_u32 v6, v0, s4
	v_mad_u64_u32 v[0:1], null, v2, s4, v[3:4]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add3_u32 v1, v6, v1, v5
	v_lshlrev_b64 v[0:1], 2, v[0:1]
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v2, vcc_lo, s2, v0
	v_add_co_ci_u32_e32 v3, vcc_lo, s3, v1, vcc_lo
	v_add_co_u32 v0, vcc_lo, s0, v0
	v_add_co_ci_u32_e32 v1, vcc_lo, s1, v1, vcc_lo
	global_load_b32 v2, v[2:3], off
	global_load_b32 v3, v[0:1], off
	s_waitcnt vmcnt(0)
	v_add_f32_e32 v2, v2, v3
	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 _Z6___addPfS_m
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 280
		.amdhsa_user_sgpr_count 14
		.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 1
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 1
		.amdhsa_next_free_vgpr 7
		.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	_Z6___addPfS_m, .Lfunc_end0-_Z6___addPfS_m
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 212
; NumSgprs: 18
; NumVgprs: 7
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 7
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 14
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 1
	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

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

	.end_amdgpu_metadata
