#ifndef _GPU_ADD_CU_
#define _GPU_ADD_CU_

#include <stdio.h> //size_t
#include <math.h> //fabs
#include <cstring> //memcpy
#include <iostream> //cout

//CUDA libraries
#include "cublas_v2.h"

//HEADER file
#include "gpuadd.cuh"

//the array index of a matrix element in row “r” and column “c” can be computed via the following macro
#define IDX2C(r,c,rows) (((c)*(rows))+(r))

__global__ void gpuaddkernel(double *d_A, double *d_B, double *d_C, size_t Am, size_t An)
{
  int x = threadIdx.x + blockDim.x * blockIdx.x;
  int y = threadIdx.y + blockDim.y * blockIdx.y;
  int ind = x + An*y; //derive linear index
  if (x<An && y<Am) d_C[ind] = d_A[ind] + d_B[ind];
}

void gpuaddcublas(double *A, double *B, double *C, size_t Am, size_t An)
{

    cudaError_t cudaStat;    
    cublasStatus_t stat;
    cublasHandle_t handle;

    double *d_A, *d_C;
    if (!A || !B || !C) {
        printf ("Error in gpuaddcublas: input failed\n");
        return;
    }
    
    cudaStat = cudaMalloc ((void**)&d_A, Am*An*sizeof(double));
    if (cudaStat != cudaSuccess) {
        printf ("device memory allocation failed\n");
        return;
    }
    cudaStat = cudaMalloc ((void**)&d_C, Am*An*sizeof(double));
    if (cudaStat != cudaSuccess) {
        printf ("device memory allocation failed\n");
        return;
    }

    stat = cublasCreate(&handle);
    if (stat != CUBLAS_STATUS_SUCCESS) {
        printf ("CUBLAS initialization failed\n");
        return;
    }

    //for (size_t ii=0; ii<Am*An; ii++) printf("A=%f\n",A[ii]); 

    stat = cublasSetVector(Am*An, sizeof(double), (void*)A, 1, (void*)d_A, 1);
    if (stat != CUBLAS_STATUS_SUCCESS) {
        printf ("data download for A failed: %d\n", stat);
        cudaFree (d_A);
        cublasDestroy(handle);
        return;
    }
    stat = cublasSetVector(Am*An, sizeof(double), (void*)B, 1, (void*)d_C, 1);
    if (stat != CUBLAS_STATUS_SUCCESS) {
        printf ("data download for B failed\n");
        cudaFree (d_A);
        cudaFree (d_C);
        cublasDestroy(handle);
        return;
    }

  //add two matrices (represented as vectors)
    double alpha = 1.;
    stat =  cublasAxpyEx (handle,Am*An, &alpha, CUDA_R_64F, (void *)d_A, CUDA_R_64F, 1, (void *)d_C, CUDA_R_64F,  1, CUDA_R_64F);
    if (stat != CUBLAS_STATUS_SUCCESS) {
        printf ("data adding failed\n");
        cudaFree (d_A);
        cudaFree (d_C);
        cublasDestroy(handle);
        return;
    }

    stat = cublasGetVector(Am*An, sizeof(double), (void *)d_C, 1, (void*)C, 1);
    if (stat != CUBLAS_STATUS_SUCCESS) {
        printf ("data upload failed\n");
        cudaFree (d_A);
        cudaFree (d_C);
        cublasDestroy(handle);
        return;
    }
   cudaFree (d_A);
   cudaFree (d_C);
   cublasDestroy(handle);
   return;

}

void gpuadd(double *A, double *B, double *C, size_t Am, size_t An)
{

  /* set GPU grid & block configuration */
  cudaDeviceProp deviceProp;
  memset( &deviceProp, 0, sizeof(deviceProp));
  if( cudaSuccess != cudaGetDeviceProperties(&deviceProp,0)){
    printf( "\n%s", cudaGetErrorString(cudaGetLastError()));
    return;
  }

  dim3 block = dim3(32,8,1); // 32*8*1 = 256 threads per block
  // ensure enough blocks to cover w * h elements (round up)
  dim3 grid = dim3( ( An + block.x -1 ) / block.x, ( Am + block.y - 1 ) / block.y, 1);


//First add two pointers with specified kernel

  /* allocate device memory for matrices */
  double *d_A = NULL;
  cudaMalloc( (void**) &d_A, Am * An * sizeof(double)) ;
	cudaMemcpy( d_A, A, Am * An * sizeof(double), cudaMemcpyHostToDevice) ;
  double *d_B = NULL;
  cudaMalloc( (void**) &d_B, Am * An * sizeof(double)) ;
	cudaMemcpy( d_B, B, Am * An * sizeof(double), cudaMemcpyHostToDevice) ;
  double *d_C = NULL;
  cudaMalloc( (void**) &d_C, Am * An * sizeof(double)) ;
    
  std::cout << "Values/Vectors/Matrices are added using a self-implemented kernel" << std::endl;
	/* call GPU kernel for addition */
	gpuaddkernel<<< grid, block >>>(d_A, d_B, d_C, Am, An);
	cudaDeviceSynchronize();
    
  /* copy result from device */
  double *C_kernel = new double [Am*An];
	cudaMemcpy( C_kernel, d_C, Am * An * sizeof(double), cudaMemcpyDeviceToHost) ;


  /* free GPU memory */
  cudaFree(d_A);
  cudaFree(d_B);
  cudaFree(d_C);

//Now add pointers with cublas
  std::cout << "Addtionally, the same values are added using cublas" << std::endl;
  double *C_cublas = new double [Am*An];
	gpuaddcublas(A, B, C_cublas, Am, An);

//Compare results
  std::cout << "And now both results will be compared..." << std::endl;;
bool equal = true;
for (size_t ii=0; ii<Am*An; ii++)
  if (!(fabs(C_kernel[ii]-C_cublas[ii])<0.001))
    equal = false;

if (equal)
{
  std::cout << "Yeah, both arrays have the same values" << std::endl << std::endl;
  std::memcpy( (void*)C, (void*) C_kernel, Am * An * sizeof(double) );
  free(C_kernel);
  free(C_cublas);
}
else
{
  std::cout << "Oh no, cublas and your own kernel differ too much in results." << std::endl;
  std::cout << "Copy kernel results now, but handle with caution." << std::endl << std::endl;
  std::memcpy( (void*)C, (void*) C_kernel, Am * An * sizeof(double) );
  free(C_kernel);
  free(C_cublas);
}

}

#endif

	.file	"tmpxft_0029a1dd_00000000-6_gpuadd.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB4444:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE4444:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"Error in gpuaddcublas: input failed\n"
.LC1:
	.string	"device memory allocation failed\n"
.LC2:
	.string	"CUBLAS initialization failed\n"
.LC3:
	.string	"data download for A failed: %d\n"
.LC4:
	.string	"data download for B failed\n"
.LC6:
	.string	"data adding failed\n"
.LC7:
	.string	"data upload failed\n"
	.text
	.globl	_Z12gpuaddcublasPdS_S_mm
	.type	_Z12gpuaddcublasPdS_S_mm, @function
_Z12gpuaddcublasPdS_S_mm:
.LFB4440:
	.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
	movq	%rdx, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	testq	%rsi, %rsi
	sete	%al
	testq	%rdx, %rdx
	sete	%dl
	orb	%dl, %al
	jne	.L16
	movq	%rdi, %r13
	testq	%rdi, %rdi
	jne	.L3
.L16:
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L20
	addq	$56, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	leaq	.LC0(%rip), %rsi
	movl	$2, %edi
	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
	jmp	__printf_chk@PLT
.L3:
	.cfi_restore_state
	movq	%rcx, %r15
	movq	%rsi, %r12
	leaq	16(%rsp), %rdi
	movq	%rcx, %r14
	imulq	%r8, %r15
	movq	%r8, %rbx
	salq	$3, %r15
	movq	%r15, %rsi
	call	cudaMalloc@PLT
	testl	%eax, %eax
	je	.L6
.L8:
	leaq	.LC1(%rip), %rsi
	jmp	.L19
.L6:
	leaq	24(%rsp), %rdi
	movq	%r15, %rsi
	call	cudaMalloc@PLT
	testl	%eax, %eax
	jne	.L8
	leaq	8(%rsp), %rdi
	call	cublasCreate_v2@PLT
	testl	%eax, %eax
	je	.L9
	leaq	.LC2(%rip), %rsi
.L19:
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L2
.L9:
	imull	%r14d, %ebx
	movq	16(%rsp), %r8
	movq	%r13, %rdx
	movl	$1, %r9d
	movl	$1, %ecx
	movl	$8, %esi
	movl	%ebx, %edi
	call	cublasSetVector@PLT
	movl	%eax, %edx
	testl	%eax, %eax
	je	.L10
	movl	$2, %edi
	leaq	.LC3(%rip), %rsi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	16(%rsp), %rdi
	jmp	.L18
.L10:
	movq	24(%rsp), %r8
	movl	$8, %esi
	movq	%r12, %rdx
	movl	%ebx, %edi
	movl	$1, %r9d
	movl	$1, %ecx
	call	cublasSetVector@PLT
	leaq	.LC4(%rip), %rsi
	testl	%eax, %eax
	jne	.L21
	movq	.LC5(%rip), %rax
	leaq	32(%rsp), %rdx
	movl	%ebx, %esi
	movl	$1, %r9d
	movl	$1, %ecx
	movq	%rax, 32(%rsp)
	pushq	%rax
	.cfi_def_cfa_offset 120
	pushq	$1
	.cfi_def_cfa_offset 128
	pushq	$1
	.cfi_def_cfa_offset 136
	pushq	$1
	.cfi_def_cfa_offset 144
	pushq	56(%rsp)
	.cfi_def_cfa_offset 152
	pushq	$1
	.cfi_def_cfa_offset 160
	movq	64(%rsp), %r8
	movq	56(%rsp), %rdi
	call	cublasAxpyEx@PLT
	addq	$48, %rsp
	.cfi_def_cfa_offset 112
	leaq	.LC6(%rip), %rsi
	testl	%eax, %eax
	jne	.L21
	movq	24(%rsp), %rdx
	movl	$1, %r9d
	movq	%rbp, %r8
	movl	%ebx, %edi
	movl	$1, %ecx
	movl	$8, %esi
	call	cublasGetVector@PLT
	testl	%eax, %eax
	je	.L13
	leaq	.LC7(%rip), %rsi
.L21:
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L13:
	movq	16(%rsp), %rdi
	call	cudaFree@PLT
	movq	24(%rsp), %rdi
.L18:
	call	cudaFree@PLT
	movq	8(%rsp), %rdi
	call	cublasDestroy_v2@PLT
.L2:
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	je	.L15
.L20:
	call	__stack_chk_fail@PLT
.L15:
	addq	$56, %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
.LFE4440:
	.size	_Z12gpuaddcublasPdS_S_mm, .-_Z12gpuaddcublasPdS_S_mm
	.globl	_Z38__device_stub__Z12gpuaddkernelPdS_S_mmPdS_S_mm
	.type	_Z38__device_stub__Z12gpuaddkernelPdS_S_mmPdS_S_mm, @function
_Z38__device_stub__Z12gpuaddkernelPdS_S_mmPdS_S_mm:
.LFB4466:
	.cfi_startproc
	endbr64
	subq	$168, %rsp
	.cfi_def_cfa_offset 176
	movq	%rdi, 40(%rsp)
	leaq	64(%rsp), %rdi
	movq	%rsi, 32(%rsp)
	leaq	76(%rsp), %rsi
	movq	%rdx, 24(%rsp)
	leaq	48(%rsp), %rdx
	movq	%rcx, 16(%rsp)
	leaq	56(%rsp), %rcx
	movq	%r8, 8(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 152(%rsp)
	xorl	%eax, %eax
	leaq	40(%rsp), %rax
	movl	$1, 72(%rsp)
	movq	%rax, 112(%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 128(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 136(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 144(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 64(%rsp)
	movq	%rax, 76(%rsp)
	movl	$1, 84(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L23
	pushq	56(%rsp)
	.cfi_def_cfa_offset 184
	leaq	_Z12gpuaddkernelPdS_S_mm(%rip), %rdi
	pushq	56(%rsp)
	.cfi_def_cfa_offset 192
	movq	92(%rsp), %rcx
	movl	100(%rsp), %r8d
	movq	80(%rsp), %rsi
	movl	88(%rsp), %edx
	leaq	128(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 184
	popq	%rdx
	.cfi_def_cfa_offset 176
.L23:
	movq	152(%rsp), %rax
	subq	%fs:40, %rax
	je	.L25
	call	__stack_chk_fail@PLT
.L25:
	addq	$168, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE4466:
	.size	_Z38__device_stub__Z12gpuaddkernelPdS_S_mmPdS_S_mm, .-_Z38__device_stub__Z12gpuaddkernelPdS_S_mmPdS_S_mm
	.globl	_Z12gpuaddkernelPdS_S_mm
	.type	_Z12gpuaddkernelPdS_S_mm, @function
_Z12gpuaddkernelPdS_S_mm:
.LFB4467:
	.cfi_startproc
	endbr64
	jmp	_Z38__device_stub__Z12gpuaddkernelPdS_S_mmPdS_S_mm
	.cfi_endproc
.LFE4467:
	.size	_Z12gpuaddkernelPdS_S_mm, .-_Z12gpuaddkernelPdS_S_mm
	.section	.rodata.str1.1
.LC8:
	.string	"\n%s"
.LC9:
	.string	"Values/Vectors/Matrices are added using a self-implemented kernel"
.LC10:
	.string	"Addtionally, the same values are added using cublas"
.LC11:
	.string	"And now both results will be compared..."
.LC14:
	.string	"Yeah, both arrays have the same values"
.LC15:
	.string	"Oh no, cublas and your own kernel differ too much in results."
.LC16:
	.string	"Copy kernel results now, but handle with caution."
	.text
	.globl	_Z6gpuaddPdS_S_mm
	.type	_Z6gpuaddPdS_S_mm, @function
_Z6gpuaddPdS_S_mm:
.LFB4441:
	.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
	movq	%rsi, %r14
	xorl	%esi, %esi
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%r8, %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movq	%rcx, %r12
	movl	$258, %ecx
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$1128, %rsp
	.cfi_def_cfa_offset 1184
	movq	%rdi, 16(%rsp)
	movq	%rdx, 24(%rsp)
	leaq	80(%rsp), %rdx
	movq	%rdx, %rdi
	movq	%fs:40, %rax
	movq	%rax, 1112(%rsp)
	xorl	%eax, %eax
	rep stosl
	movq	%rdx, %rdi
	call	cudaGetDeviceProperties_v2@PLT
	testl	%eax, %eax
	je	.L29
	call	cudaGetLastError@PLT
	movl	%eax, %edi
	call	cudaGetErrorString@PLT
	leaq	.LC8(%rip), %rsi
	movl	$2, %edi
	movq	%rax, %rdx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	1112(%rsp), %rax
	subq	%fs:40, %rax
	je	.L41
	jmp	.L43
.L29:
	leaq	31(%r13), %rax
	movq	%r12, %r15
	leaq	32(%rsp), %rdi
	movl	$1, 76(%rsp)
	shrq	$5, %rax
	imulq	%r13, %r15
	movl	%eax, 68(%rsp)
	leaq	7(%r12), %rax
	shrq	$3, %rax
	movl	%eax, 72(%rsp)
	xorl	%eax, %eax
	movq	%rax, 32(%rsp)
	leaq	0(,%r15,8), %rax
	movq	%rax, %rsi
	movq	%rax, 8(%rsp)
	call	cudaMalloc@PLT
	movq	16(%rsp), %rsi
	movq	32(%rsp), %rdi
	movl	$1, %ecx
	leaq	0(,%r15,8), %rdx
	call	cudaMemcpy@PLT
	movq	8(%rsp), %rsi
	xorl	%edx, %edx
	leaq	40(%rsp), %rdi
	movq	%rdx, 40(%rsp)
	call	cudaMalloc@PLT
	movq	8(%rsp), %rdx
	movq	40(%rsp), %rdi
	movq	%r14, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movq	8(%rsp), %rsi
	xorl	%ecx, %ecx
	leaq	48(%rsp), %rdi
	movq	%rcx, 48(%rsp)
	call	cudaMalloc@PLT
	leaq	.LC9(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E@PLT
	movl	$1073741825, %edx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movq	68(%rsp), %rdi
	movl	76(%rsp), %esi
	salq	$5, %rdx
	movl	$1, %ecx
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L31
	movq	48(%rsp), %rdx
	movq	40(%rsp), %rsi
	movq	%r13, %r8
	movq	%r12, %rcx
	movq	32(%rsp), %rdi
	call	_Z38__device_stub__Z12gpuaddkernelPdS_S_mmPdS_S_mm
.L31:
	call	cudaDeviceSynchronize@PLT
	movabsq	$1152921504606846975, %rax
	cmpq	%r15, %rax
	jb	.L32
	movq	8(%rsp), %rdi
	call	_Znam@PLT
	movq	8(%rsp), %rdx
	movq	48(%rsp), %rsi
	movl	$2, %ecx
	movq	%rax, %rdi
	movq	%rax, %rbx
	call	cudaMemcpy@PLT
	movq	32(%rsp), %rdi
	call	cudaFree@PLT
	movq	40(%rsp), %rdi
	call	cudaFree@PLT
	movq	48(%rsp), %rdi
	call	cudaFree@PLT
	leaq	.LC10(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E@PLT
	movq	8(%rsp), %rdi
	call	_Znam@PLT
	movq	16(%rsp), %rdi
	movq	%r12, %rcx
	movq	%r13, %r8
	movq	%rax, %rdx
	movq	%r14, %rsi
	movq	%rax, %rbp
	call	_Z12gpuaddcublasPdS_S_mm
	leaq	.LC11(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E@PLT
	xorl	%eax, %eax
	movb	$1, %dl
	xorl	%ecx, %ecx
	movq	.LC12(%rip), %xmm1
	movsd	.LC13(%rip), %xmm2
	jmp	.L33
.L32:
	movq	1112(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L43
	call	__cxa_throw_bad_array_new_length@PLT
.L33:
	cmpq	%rax, %r15
	je	.L46
	movsd	(%rbx,%rax,8), %xmm0
	subsd	0(%rbp,%rax,8), %xmm0
	andps	%xmm1, %xmm0
	comisd	%xmm0, %xmm2
	cmovbe	%ecx, %edx
	incq	%rax
	jmp	.L33
.L46:
	leaq	.LC14(%rip), %rsi
	testb	%dl, %dl
	jne	.L45
	leaq	.LC15(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E@PLT
	leaq	.LC16(%rip), %rsi
.L45:
	leaq	_ZSt4cout(%rip), %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E@PLT
	movq	24(%rsp), %rdi
	movq	8(%rsp), %rcx
	movq	%rbx, %rsi
	rep movsb
	movq	%rbx, %rdi
	call	free@PLT
	movq	1112(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L43
	addq	$1128, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	movq	%rbp, %rdi
	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
	jmp	free@PLT
.L43:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
.L41:
	addq	$1128, %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
.LFE4441:
	.size	_Z6gpuaddPdS_S_mm, .-_Z6gpuaddPdS_S_mm
	.section	.rodata.str1.1
.LC17:
	.string	"_Z12gpuaddkernelPdS_S_mm"
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB4469:
	.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	.LC17(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z12gpuaddkernelPdS_S_mm(%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
.LFE4469:
	.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.cst8,"aM",@progbits,8
	.align 8
.LC5:
	.long	0
	.long	1072693248
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC12:
	.long	-1
	.long	2147483647
	.long	0
	.long	0
	.section	.rodata.cst8
	.align 8
.LC13:
	.long	-755914244
	.long	1062232653
	.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:

#ifndef _GPU_ADD_CUH_
#define _GPU_ADD_CUH_

void gpuadd(double *A, double *B, double *C, size_t Am, size_t An);

#endif

	.text
	.file	"gpuadd.hip"
	.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 __hip_cuid_

	.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_
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.amdgpu_metadata
---
amdhsa.kernels:  []
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
