#include <iostream>
#include "sys/time.h"
using namespace std;


double timeInSeconds (timeval& starttime, timeval& stopstime) {
  return 1e-6*(1e6*(stopstime.tv_sec - starttime.tv_sec) + (stopstime.tv_usec - starttime.tv_usec)); 
}

__device__ double* dev_vector1 = 0;
__device__ double* dev_vector2 = 0;
__device__ double* dev_results = 0;
 
__global__ void device_vector_mult () {
  // IMPLEMENT ME 6: Multiply the threadIdx.x element of dev_vector1 by the 
  // corresponding element of dev_vector2, and store in dev_results. 
}

int main (int argc, char** argv) {
  int sizeOfVector = 100;
  if (argc > 1) sizeOfVector = atoi(argv[1]); 

  // Declare and fill host-side arrays of doubles. 
  double* vector1 = new double[sizeOfVector];
  double* vector2 = new double[sizeOfVector];
  double* results = new double[sizeOfVector];

  srand(42); 
  for (int i = 0; i < sizeOfVector; ++i) {
    vector1[i] = rand() % 100; 
    vector2[i] = rand() % 100; 
    results[i] = 0; 
  }

  timeval startTime;
  timeval interTime; 
  timeval stopsTime;
  gettimeofday(&startTime, NULL);

  // Use the CPU for this part. 
  // IMPLEMENT ME 1: Multiply each element of vector1 by the corresponding
  // element in vector2 and store in results. 
  for (int i = 0; i < sizeOfVector; ++i) {
        results[i] = vector1[i] * vector2[i];  
  }
  
  gettimeofday(&interTime, NULL);

  double total = 0;
  // IMPLEMENT ME 2: Sum the results array and store the sum in total.
  for (int i = 0; i < sizeOfVector; +i) {
        total += results[i];
  }

  gettimeofday(&stopsTime, NULL);

  cout << "Dot product is : " << total << endl; 

  // IMPLEMENT ME 3: Time the above operations together and separately
  // using 'gettimeofday'. 

  cout << "Time for multiplication (seconds): " << timeInSeconds(startTime, interTime) << endl; 
  cout << "Time for addition       (seconds): " << timeInSeconds(interTime, stopsTime) << endl; 
  cout << "Overall time            (seconds): " << timeInSeconds(startTime, stopsTime) << endl; 


  // Now on to the GPU! 
  
  // IMPLEMENT ME 4: Use cudaMalloc to allocate space for the three device vectors. 
  // IMPLEMENT ME 5: Use cudaMemcpy to initialise dev_vector1 and dev_vector2 to have
  // the same content as the host-side arrays. 

  // IMPLEMENT ME 6: Put in the function body for device_vector_mult, above. 

  // IMPLEMENT ME 7: Launch a kernel that runs device_vector_mult. 

  // IMPLEMENT ME 8: Use cudaMemcpy to copy back dev_results into results. 

  // IMPLEMENT ME 9: Calculate the dot product by summing over results, same
  // as above. 

  // IMPLEMENT ME 10: Take the time for the kernel launch and the addition,
  // and print out the results (including the dot product) as you did for the CPU. 

  // IMPLEMENT ME 11: Write a reduction kernel that sums over dev_results, and launch it.
  // Time this operation and compare with the code that first moves the transformed data
  // to the host, then sums over it. 

  return 0; 
}

	.file	"tmpxft_00306950_00000000-6_ex1.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB3639:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE3639:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z13timeInSecondsR7timevalS0_
	.type	_Z13timeInSecondsR7timevalS0_, @function
_Z13timeInSecondsR7timevalS0_:
.LFB3635:
	.cfi_startproc
	endbr64
	movq	(%rsi), %rax
	subq	(%rdi), %rax
	cvtsi2sdq	%rax, %xmm0
	movq	8(%rsi), %rax
	mulsd	.LC0(%rip), %xmm0
	subq	8(%rdi), %rax
	cvtsi2sdq	%rax, %xmm1
	addsd	%xmm1, %xmm0
	mulsd	.LC1(%rip), %xmm0
	ret
	.cfi_endproc
.LFE3635:
	.size	_Z13timeInSecondsR7timevalS0_, .-_Z13timeInSecondsR7timevalS0_
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC3:
	.string	"Dot product is : "
.LC4:
	.string	"Time for multiplication (seconds): "
.LC5:
	.string	"Time for addition       (seconds): "
.LC6:
	.string	"Overall time            (seconds): "
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB3636:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$72, %rsp
	.cfi_def_cfa_offset 128
	movq	%fs:40, %rax
	movq	%rax, 56(%rsp)
	xorl	%eax, %eax
	decl	%edi
	jle	.L14
	movq	8(%rsi), %rdi
	call	atoi@PLT
	movslq	%eax, %rdi
	movabsq	$1152921504606846975, %rax
	movq	%rdi, %rbx
	cmpq	%rdi, %rax
	jnb	.L4
	jmp	.L18
.L14:
	movl	$100, %edi
	movl	$100, %ebx
.L4:
	movslq	%ebx, %rbp
	salq	$3, %rdi
	movl	$100, %r15d
	call	_Znam@PLT
	salq	$3, %rbp
	movq	%rbp, %rdi
	movq	%rax, %r12
	call	_Znam@PLT
	movq	%rbp, %rdi
	xorl	%ebp, %ebp
	movq	%rax, %r13
	call	_Znam@PLT
	movl	$42, %edi
	movq	%rax, %r14
	call	srand@PLT
	jmp	.L6
.L18:
	movq	56(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L16
	call	__cxa_throw_bad_array_new_length@PLT
.L6:
	cmpl	%ebp, %ebx
	jle	.L19
	call	rand@PLT
	cltd
	idivl	%r15d
	cvtsi2sdl	%edx, %xmm0
	movsd	%xmm0, (%r12,%rbp,8)
	call	rand@PLT
	movq	$0x000000000, (%r14,%rbp,8)
	cltd
	idivl	%r15d
	cvtsi2sdl	%edx, %xmm0
	movsd	%xmm0, 0(%r13,%rbp,8)
	incq	%rbp
	jmp	.L6
.L19:
	leaq	8(%rsp), %rbp
	xorl	%esi, %esi
	movq	%rbp, %rdi
	call	gettimeofday@PLT
	xorl	%eax, %eax
.L9:
	cmpl	%eax, %ebx
	jle	.L20
	movsd	(%r12,%rax,8), %xmm0
	mulsd	0(%r13,%rax,8), %xmm0
	movsd	%xmm0, (%r14,%rax,8)
	incq	%rax
	jmp	.L9
.L20:
	leaq	24(%rsp), %r13
	xorl	%esi, %esi
	movq	%r13, %rdi
	call	gettimeofday@PLT
	testl	%ebx, %ebx
	je	.L11
.L12:
	jmp	.L12
.L11:
	leaq	40(%rsp), %r12
	leaq	_ZSt4cout(%rip), %rbx
	xorl	%esi, %esi
	movq	%r12, %rdi
	call	gettimeofday@PLT
	leaq	.LC3(%rip), %rsi
	movq	%rbx, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	xorps	%xmm0, %xmm0
	movq	%rax, %rdi
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	movq	%rax, %rdi
	call	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT
	leaq	.LC4(%rip), %rsi
	movq	%rbx, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%r13, %rsi
	movq	%rbp, %rdi
	movq	%rax, %rdx
	call	_Z13timeInSecondsR7timevalS0_
	movq	%rdx, %rdi
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	movq	%rax, %rdi
	call	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT
	leaq	.LC5(%rip), %rsi
	movq	%rbx, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%r12, %rsi
	movq	%r13, %rdi
	movq	%rax, %rdx
	call	_Z13timeInSecondsR7timevalS0_
	movq	%rdx, %rdi
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	movq	%rax, %rdi
	call	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT
	leaq	.LC6(%rip), %rsi
	movq	%rbx, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%r12, %rsi
	movq	%rbp, %rdi
	movq	%rax, %rdx
	call	_Z13timeInSecondsR7timevalS0_
	movq	%rdx, %rdi
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	movq	%rax, %rdi
	call	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT
	movq	56(%rsp), %rax
	subq	%fs:40, %rax
	je	.L13
.L16:
	call	__stack_chk_fail@PLT
.L13:
	addq	$72, %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
.LFE3636:
	.size	main, .-main
	.text
	.globl	_Z37__device_stub__Z18device_vector_multvv
	.type	_Z37__device_stub__Z18device_vector_multvv, @function
_Z37__device_stub__Z18device_vector_multvv:
.LFB3661:
	.cfi_startproc
	endbr64
	subq	$88, %rsp
	.cfi_def_cfa_offset 96
	movq	%fs:40, %rax
	movq	%rax, 72(%rsp)
	movabsq	$4294967297, %rax
	leaq	8(%rsp), %rcx
	movq	%rsp, %rdx
	leaq	28(%rsp), %rsi
	leaq	16(%rsp), %rdi
	movl	$1, 24(%rsp)
	movl	$1, 36(%rsp)
	movq	%rax, 16(%rsp)
	movq	%rax, 28(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L21
	pushq	8(%rsp)
	.cfi_def_cfa_offset 104
	leaq	_Z18device_vector_multv(%rip), %rdi
	pushq	8(%rsp)
	.cfi_def_cfa_offset 112
	movq	44(%rsp), %rcx
	movl	52(%rsp), %r8d
	movq	32(%rsp), %rsi
	movl	40(%rsp), %edx
	leaq	80(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 104
	popq	%rdx
	.cfi_def_cfa_offset 96
.L21:
	movq	72(%rsp), %rax
	subq	%fs:40, %rax
	je	.L23
	call	__stack_chk_fail@PLT
.L23:
	addq	$88, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3661:
	.size	_Z37__device_stub__Z18device_vector_multvv, .-_Z37__device_stub__Z18device_vector_multvv
	.globl	_Z18device_vector_multv
	.type	_Z18device_vector_multv, @function
_Z18device_vector_multv:
.LFB3662:
	.cfi_startproc
	endbr64
	jmp	_Z37__device_stub__Z18device_vector_multvv
	.cfi_endproc
.LFE3662:
	.size	_Z18device_vector_multv, .-_Z18device_vector_multv
	.section	.rodata.str1.1
.LC7:
	.string	"_Z18device_vector_multv"
.LC8:
	.string	"dev_vector1"
.LC9:
	.string	"dev_vector2"
.LC10:
	.string	"dev_results"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB3664:
	.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	.LC7(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z18device_vector_multv(%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	%r8d, %r8d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC8(%rip), %rdx
	movl	$8, %r9d
	leaq	_ZL11dev_vector1(%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	.LC9(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movq	%rdx, %rcx
	movl	$8, %r9d
	leaq	_ZL11dev_vector2(%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	.LC10(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movl	$8, %r9d
	movq	%rdx, %rcx
	leaq	_ZL11dev_results(%rip), %rsi
	call	__cudaRegisterVar@PLT
	popq	%rdi
	.cfi_def_cfa_offset 24
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	popq	%r8
	.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
.LFE3664:
	.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	_ZL11dev_results
	.comm	_ZL11dev_results,8,8
	.local	_ZL11dev_vector2
	.comm	_ZL11dev_vector2,8,8
	.local	_ZL11dev_vector1
	.comm	_ZL11dev_vector1,8,8
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC0:
	.long	0
	.long	1093567616
	.align 8
.LC1:
	.long	-1598689907
	.long	1051772663
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:


#include <hip/hip_runtime.h>
#include <iostream>
#include "sys/time.h"
using namespace std;


double timeInSeconds (timeval& starttime, timeval& stopstime) {
  return 1e-6*(1e6*(stopstime.tv_sec - starttime.tv_sec) + (stopstime.tv_usec - starttime.tv_usec)); 
}

__device__ double* dev_vector1 = 0;
__device__ double* dev_vector2 = 0;
__device__ double* dev_results = 0;
 
__global__ void device_vector_mult () {
  // IMPLEMENT ME 6: Multiply the threadIdx.x element of dev_vector1 by the 
  // corresponding element of dev_vector2, and store in dev_results. 
}

int main (int argc, char** argv) {
  int sizeOfVector = 100;
  if (argc > 1) sizeOfVector = atoi(argv[1]); 

  // Declare and fill host-side arrays of doubles. 
  double* vector1 = new double[sizeOfVector];
  double* vector2 = new double[sizeOfVector];
  double* results = new double[sizeOfVector];

  srand(42); 
  for (int i = 0; i < sizeOfVector; ++i) {
    vector1[i] = rand() % 100; 
    vector2[i] = rand() % 100; 
    results[i] = 0; 
  }

  timeval startTime;
  timeval interTime; 
  timeval stopsTime;
  gettimeofday(&startTime, NULL);

  // Use the CPU for this part. 
  // IMPLEMENT ME 1: Multiply each element of vector1 by the corresponding
  // element in vector2 and store in results. 
  for (int i = 0; i < sizeOfVector; ++i) {
        results[i] = vector1[i] * vector2[i];  
  }
  
  gettimeofday(&interTime, NULL);

  double total = 0;
  // IMPLEMENT ME 2: Sum the results array and store the sum in total.
  for (int i = 0; i < sizeOfVector; +i) {
        total += results[i];
  }

  gettimeofday(&stopsTime, NULL);

  cout << "Dot product is : " << total << endl; 

  // IMPLEMENT ME 3: Time the above operations together and separately
  // using 'gettimeofday'. 

  cout << "Time for multiplication (seconds): " << timeInSeconds(startTime, interTime) << endl; 
  cout << "Time for addition       (seconds): " << timeInSeconds(interTime, stopsTime) << endl; 
  cout << "Overall time            (seconds): " << timeInSeconds(startTime, stopsTime) << endl; 


  // Now on to the GPU! 
  
  // IMPLEMENT ME 4: Use cudaMalloc to allocate space for the three device vectors. 
  // IMPLEMENT ME 5: Use cudaMemcpy to initialise dev_vector1 and dev_vector2 to have
  // the same content as the host-side arrays. 

  // IMPLEMENT ME 6: Put in the function body for device_vector_mult, above. 

  // IMPLEMENT ME 7: Launch a kernel that runs device_vector_mult. 

  // IMPLEMENT ME 8: Use cudaMemcpy to copy back dev_results into results. 

  // IMPLEMENT ME 9: Calculate the dot product by summing over results, same
  // as above. 

  // IMPLEMENT ME 10: Take the time for the kernel launch and the addition,
  // and print out the results (including the dot product) as you did for the CPU. 

  // IMPLEMENT ME 11: Write a reduction kernel that sums over dev_results, and launch it.
  // Time this operation and compare with the code that first moves the transformed data
  // to the host, then sums over it. 

  return 0; 
}

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

                                        # End of file scope inline assembly
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z13timeInSecondsR7timevalS0_
.LCPI0_0:
	.quad	0x412e848000000000              # double 1.0E+6
.LCPI0_1:
	.quad	0x3eb0c6f7a0b5ed8d              # double 9.9999999999999995E-7
	.text
	.globl	_Z13timeInSecondsR7timevalS0_
	.type	_Z13timeInSecondsR7timevalS0_,@function
_Z13timeInSecondsR7timevalS0_:          # @_Z13timeInSecondsR7timevalS0_
	.cfi_startproc
# %bb.0:
	movq	(%rsi), %rax
	movq	8(%rsi), %rcx
	subq	(%rdi), %rax
	cvtsi2sd	%rax, %xmm1
	mulsd	.LCPI0_0(%rip), %xmm1
	subq	8(%rdi), %rcx
	cvtsi2sd	%rcx, %xmm0
	addsd	%xmm1, %xmm0
	mulsd	.LCPI0_1(%rip), %xmm0
	retq
.Lfunc_end0:
	.size	_Z13timeInSecondsR7timevalS0_, .Lfunc_end0-_Z13timeInSecondsR7timevalS0_
	.cfi_endproc
                                        # -- End function
	.globl	_Z33__device_stub__device_vector_multv # -- Begin function _Z33__device_stub__device_vector_multv
	.type	_Z33__device_stub__device_vector_multv,@function
_Z33__device_stub__device_vector_multv: # @_Z33__device_stub__device_vector_multv
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r12
	.cfi_def_cfa_offset 32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	subq	$56, %rsp
	.cfi_def_cfa_offset 96
	.cfi_offset %rbx, -40
	.cfi_offset %r12, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rbx
	leaq	24(%rsp), %r14
	leaq	16(%rsp), %r15
	leaq	8(%rsp), %r12
	movq	%rbx, %rdi
	movq	%r14, %rsi
	movq	%r15, %rdx
	movq	%r12, %rcx
	callq	__hipPopCallConfiguration
	movq	(%rbx), %rsi
	movl	8(%rbx), %edx
	movq	(%r14), %rcx
	movl	8(%r14), %r8d
	movq	%rsp, %r9
	movl	$_Z18device_vector_multv, %edi
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	pushq	(%r15)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$72, %rsp
	.cfi_adjust_cfa_offset -72
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end1:
	.size	_Z33__device_stub__device_vector_multv, .Lfunc_end1-_Z33__device_stub__device_vector_multv
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI2_0:
	.quad	0x412e848000000000              # double 1.0E+6
.LCPI2_1:
	.quad	0x3eb0c6f7a0b5ed8d              # double 9.9999999999999995E-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	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	cmpl	$1, %edi
	jle	.LBB2_1
# %bb.2:                                # %.thread
	movq	8(%rsi), %rdi
	callq	atoi
	movl	%eax, %ebx
	movl	$42, %edi
	callq	srand
	testl	%ebx, %ebx
	jg	.LBB2_3
# %bb.6:                                # %._crit_edge.thread
	leaq	24(%rsp), %r14
	movq	%r14, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	leaq	8(%rsp), %r15
	movq	%r15, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	leaq	40(%rsp), %rbx
	movq	%rbx, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	movl	$_ZSt4cout, %edi
	movl	$.L.str, %esi
	movl	$17, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	$_ZSt4cout, %edi
	xorps	%xmm0, %xmm0
	callq	_ZNSo9_M_insertIdEERSoT_
	movq	%rax, %r12
	movq	(%rax), %rax
	movq	-24(%rax), %rdi
	addq	%r12, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movq	%r12, %rdi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	movl	$_ZSt4cout, %edi
	movl	$.L.str.1, %esi
	movl	$35, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	(%r15), %rbp
	movq	8(%r15), %r13
	movq	(%r14), %r12
	movq	8(%r14), %r15
	movq	%rbp, %rax
	subq	%r12, %rax
	cvtsi2sd	%rax, %xmm1
	movq	%r13, %rax
	subq	%r15, %rax
	xorps	%xmm0, %xmm0
	cvtsi2sd	%rax, %xmm0
	mulsd	.LCPI2_0(%rip), %xmm1
	addsd	%xmm1, %xmm0
	mulsd	.LCPI2_1(%rip), %xmm0
	movl	$_ZSt4cout, %edi
	callq	_ZNSo9_M_insertIdEERSoT_
	movq	%rax, %r14
	movq	(%rax), %rax
	movq	-24(%rax), %rdi
	addq	%r14, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movq	%r14, %rdi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	movl	$_ZSt4cout, %edi
	movl	$.L.str.2, %esi
	movl	$35, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	(%rbx), %r14
	movq	%r14, %rax
	subq	%rbp, %rax
	xorps	%xmm1, %xmm1
	cvtsi2sd	%rax, %xmm1
	movq	8(%rbx), %rbp
	mulsd	.LCPI2_0(%rip), %xmm1
	movq	%rbp, %rax
	subq	%r13, %rax
	xorps	%xmm0, %xmm0
	cvtsi2sd	%rax, %xmm0
	addsd	%xmm1, %xmm0
	mulsd	.LCPI2_1(%rip), %xmm0
	movl	$_ZSt4cout, %edi
	callq	_ZNSo9_M_insertIdEERSoT_
	movq	%rax, %rbx
	movq	(%rax), %rax
	movq	-24(%rax), %rdi
	addq	%rbx, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movq	%rbx, %rdi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	movl	$_ZSt4cout, %edi
	movl	$.L.str.3, %esi
	movl	$35, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	subq	%r12, %r14
	xorps	%xmm1, %xmm1
	cvtsi2sd	%r14, %xmm1
	mulsd	.LCPI2_0(%rip), %xmm1
	subq	%r15, %rbp
	xorps	%xmm0, %xmm0
	cvtsi2sd	%rbp, %xmm0
	addsd	%xmm1, %xmm0
	mulsd	.LCPI2_1(%rip), %xmm0
	movl	$_ZSt4cout, %edi
	callq	_ZNSo9_M_insertIdEERSoT_
	movq	%rax, %rbx
	movq	(%rax), %rax
	movq	-24(%rax), %rdi
	addq	%rbx, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movq	%rbx, %rdi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	xorl	%eax, %eax
	addq	$56, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.LBB2_1:                                # %.thread.thread
	.cfi_def_cfa_offset 112
	movl	$42, %edi
	callq	srand
	movl	$100, %ebx
.LBB2_3:                                # %.lr.ph.preheader
	movl	%ebx, %ebx
.LBB2_4:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	callq	rand
	callq	rand
	decq	%rbx
	jne	.LBB2_4
# %bb.5:                                # %._crit_edge
	leaq	24(%rsp), %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	leaq	8(%rsp), %rdi
	xorl	%esi, %esi
	callq	gettimeofday
.Lfunc_end2:
	.size	main, .Lfunc_end2-main
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset %rbx, -16
	movq	__hip_gpubin_handle(%rip), %rbx
	testq	%rbx, %rbx
	jne	.LBB3_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB3_2:
	subq	$32, %rsp
	.cfi_adjust_cfa_offset 32
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z18device_vector_multv, %esi
	movl	$.L__unnamed_1, %edx
	movl	$.L__unnamed_1, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	addq	$32, %rsp
	.cfi_adjust_cfa_offset -32
	movl	$dev_vector1, %esi
	movl	$.L__unnamed_2, %edx
	movl	$.L__unnamed_2, %ecx
	movl	$8, %r9d
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	pushq	$0
	.cfi_adjust_cfa_offset 8
	pushq	$0
	.cfi_adjust_cfa_offset 8
	callq	__hipRegisterVar
	addq	$16, %rsp
	.cfi_adjust_cfa_offset -16
	movl	$dev_vector2, %esi
	movl	$.L__unnamed_3, %edx
	movl	$.L__unnamed_3, %ecx
	movl	$8, %r9d
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	pushq	$0
	.cfi_adjust_cfa_offset 8
	pushq	$0
	.cfi_adjust_cfa_offset 8
	callq	__hipRegisterVar
	addq	$16, %rsp
	.cfi_adjust_cfa_offset -16
	movl	$dev_results, %esi
	movl	$.L__unnamed_4, %edx
	movl	$.L__unnamed_4, %ecx
	movl	$8, %r9d
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	pushq	$0
	.cfi_adjust_cfa_offset 8
	pushq	$0
	.cfi_adjust_cfa_offset 8
	callq	__hipRegisterVar
	addq	$16, %rsp
	.cfi_adjust_cfa_offset -16
	movl	$__hip_module_dtor, %edi
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_end3:
	.size	__hip_module_ctor, .Lfunc_end3-__hip_module_ctor
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_dtor
	.type	__hip_module_dtor,@function
__hip_module_dtor:                      # @__hip_module_dtor
	.cfi_startproc
# %bb.0:
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	je	.LBB4_2
# %bb.1:
	pushq	%rax
	.cfi_def_cfa_offset 16
	callq	__hipUnregisterFatBinary
	movq	$0, __hip_gpubin_handle(%rip)
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
.LBB4_2:
	retq
.Lfunc_end4:
	.size	__hip_module_dtor, .Lfunc_end4-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	dev_vector1,@object             # @dev_vector1
	.local	dev_vector1
	.comm	dev_vector1,8,8
	.type	dev_vector2,@object             # @dev_vector2
	.local	dev_vector2
	.comm	dev_vector2,8,8
	.type	dev_results,@object             # @dev_results
	.local	dev_results
	.comm	dev_results,8,8
	.type	_Z18device_vector_multv,@object # @_Z18device_vector_multv
	.section	.rodata,"a",@progbits
	.globl	_Z18device_vector_multv
	.p2align	3, 0x0
_Z18device_vector_multv:
	.quad	_Z33__device_stub__device_vector_multv
	.size	_Z18device_vector_multv, 8

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"Dot product is : "
	.size	.L.str, 18

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"Time for multiplication (seconds): "
	.size	.L.str.1, 36

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"Time for addition       (seconds): "
	.size	.L.str.2, 36

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"Overall time            (seconds): "
	.size	.L.str.3, 36

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z18device_vector_multv"
	.size	.L__unnamed_1, 24

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"dev_vector1"
	.size	.L__unnamed_2, 12

	.type	.L__unnamed_3,@object           # @2
.L__unnamed_3:
	.asciz	"dev_vector2"
	.size	.L__unnamed_3, 12

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

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

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

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym _Z33__device_stub__device_vector_multv
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym dev_vector1
	.addrsig_sym dev_vector2
	.addrsig_sym dev_results
	.addrsig_sym _Z18device_vector_multv
	.addrsig_sym _ZSt4cout
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z18device_vector_multv ; -- Begin function _Z18device_vector_multv
	.globl	_Z18device_vector_multv
	.p2align	8
	.type	_Z18device_vector_multv,@function
_Z18device_vector_multv:                ; @_Z18device_vector_multv
; %bb.0:
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z18device_vector_multv
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 0
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 0
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 1
		.amdhsa_next_free_sgpr 1
		.amdhsa_reserve_vcc 0
		.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	_Z18device_vector_multv, .Lfunc_end0-_Z18device_vector_multv
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 4
; NumSgprs: 0
; NumVgprs: 0
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 0
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 1
; NumVGPRsForWavesPerEU: 1
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.protected	dev_vector1             ; @dev_vector1
	.type	dev_vector1,@object
	.section	.bss,"aw",@nobits
	.globl	dev_vector1
	.p2align	3, 0x0
dev_vector1:
	.quad	0
	.size	dev_vector1, 8

	.protected	dev_vector2             ; @dev_vector2
	.type	dev_vector2,@object
	.globl	dev_vector2
	.p2align	3, 0x0
dev_vector2:
	.quad	0
	.size	dev_vector2, 8

	.protected	dev_results             ; @dev_results
	.type	dev_results,@object
	.globl	dev_results
	.p2align	3, 0x0
dev_results:
	.quad	0
	.size	dev_results, 8

	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __hip_cuid_
	.amdgpu_metadata
---
amdhsa.kernels:
  - .args:           []
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 4
    .kernarg_segment_size: 0
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z18device_vector_multv
    .private_segment_fixed_size: 0
    .sgpr_count:     0
    .sgpr_spill_count: 0
    .symbol:         _Z18device_vector_multv.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     0
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
