/**
 * Copyright 1993-2012 NVIDIA Corporation.  All rights reserved.
 *
 * Please refer to the NVIDIA end user license agreement (EULA) associated
 * with this source code for terms and conditions that govern your use of
 * this software. Any use, reproduction, disclosure, or distribution of
 * this software and related documentation outside the terms of the EULA
 * is strictly prohibited.
 *
 */

/**
 * Vector addition: C = A + B.
 *
 * This sample is a very basic sample that implements element by element
 * vector addition. It is the same as the sample illustrating Chapter 2
 * of the programming guide with some additions like error checking.
 */

#include <stdio.h>

// For the CUDA runtime routines (prefixed with "cuda_")
#include <cuda_runtime.h>

//#include <helper_functions.h>
/**
 * CUDA Kernel Device code
 *
 * Computes the vector addition of A and B into C. The 3 vectors have the same
 * number of elements numElements.
 */
__global__ void
vectorAdd(const float *A, const float *B, float *C, int numElements)
{
    int i = blockDim.x * blockIdx.x + threadIdx.x;

    if (i < numElements)
    {
        C[i] = A[i] + B[i];
    }
}

/**
 * Host main routine
 */
int
main(void)
{
    // Error code to check return values for CUDA calls
    cudaError_t err = cudaSuccess;

    // Print the vector length to be used, and compute its size
    int numElements = 4900001;
    size_t size = numElements * sizeof(float);
    printf("[Vector addition of %d elements]\n", numElements);

    
    // Multi-GPU
    int numDevs = 0;
    cudaGetDeviceCount(&numDevs);

    if (numDevs == 0)
    {
	fprintf(stderr, "There is no GPU device!");
        exit(EXIT_FAILURE);
    }
   
    // step size between device
    size_t step = numElements/numDevs*sizeof(float); // not size/numDevs
    
    // Allocate the host input vector A
    float *h_A = (float *)malloc(size);

    // Allocate the host input vector B
    float *h_B = (float *)malloc(size);

    // Allocate the host output vector C
    float *h_C = (float *)malloc(size);

    // Verify that allocations succeeded
    if (h_A == NULL || h_B == NULL || h_C == NULL)
    {
        fprintf(stderr, "Failed to allocate host vectors!\n");
        exit(EXIT_FAILURE);
    }

    // Initialize the host input vectors
    for (int i = 0; i < numElements; ++i)
    {
        h_A[i] = rand()/(float)RAND_MAX;
        h_B[i] = rand()/(float)RAND_MAX;
    }

    // Allocate arry of pointers to store the device input vectors
    float **d_As = (float **)malloc(numDevs);
    
    if(d_As == NULL)
    {
	fprintf(stderr, "Failed to allocate array d_As to store pointers of device vectors!\n");
        exit(EXIT_FAILURE);
    }

    for(int i = 0; i < numDevs; ++i)
    {
	d_As[i] = NULL;
    }

    for(int i = 0; i < numDevs; ++i)
    {
        cudaSetDevice(i);
        if (i == numDevs-1)
        {
    	   err = cudaMalloc((void **)&d_As[i], size-i*step);
	   //printf("The size is %d bytes and step is %d bytes.\n", size, step);
	   //printf("The last device should allocate %d bytes.\n", size-i*step);
        }
	else
	{
    	   err = cudaMalloc((void **)&d_As[i], size/numDevs);
        }
    	if (err != cudaSuccess)
    	{
        	fprintf(stderr, "Failed to allocate device vector A's part %d (error code %s)!\n", cudaGetErrorString(err), i);
        	exit(EXIT_FAILURE);
    	}
	
    }
    // Allocate arry of pointers to store the device input vectors
    float **d_Bs = (float **)malloc(numDevs);
  
    if(d_Bs == NULL)
    {
	fprintf(stderr, "Failed to allocate array d_Bs to store pointers of device vectors!\n");
        exit(EXIT_FAILURE);
    }

    for(int i = 0; i < numDevs; ++i)
    {
	d_Bs[i] = NULL;
    }

    for(int i = 0; i < numDevs; ++i)
    {
        cudaSetDevice(i);
        if (i == numDevs-1)
        {
    	   err = cudaMalloc((void **)&d_Bs[i], size-i*step);
        }
	else
	{
    	   err = cudaMalloc((void **)&d_Bs[i], size/numDevs);
        }
	
    	if (err != cudaSuccess)
    	{
           fprintf(stderr, "Failed to allocate device vector B's part %d (error code %s)!\n", cudaGetErrorString(err), i);
           exit(EXIT_FAILURE);
    	}

    }
    // Allocate arry of pointers to store the device input vectors
    float **d_Cs = (float **)malloc(numDevs);
    if(d_Cs == NULL)
    {
	fprintf(stderr, "Failed to allocate array d_Cs to store pointers of device vectors!\n");
        exit(EXIT_FAILURE);
    }

    for(int i = 0; i < numDevs; ++i)
    {
	d_Cs[i] = NULL;
    }

    for(int i = 0; i < numDevs; ++i)
    {
	//set device is very important
        cudaSetDevice(i);
        if (i == numDevs-1)
        {
    	   err = cudaMalloc((void **)&d_Cs[i], size-i*step);
        }
	else
	{
    	   err = cudaMalloc((void **)&d_Cs[i], size/numDevs);
        }

    	if (err != cudaSuccess)
    	{
        	fprintf(stderr, "Failed to allocate device vector C's part %d (error code %s)!\n", cudaGetErrorString(err), i);
        	exit(EXIT_FAILURE);
    	}
    }

    // Copy the host input vectors A and B in host memory to the device input vectors in
    // device memory

    printf("Copy input data from the host memory to the CUDA device\n");
    for(int i = 0; i < numDevs; ++i)
    {
	//set device is very important
        cudaSetDevice(i);
        if (i == numDevs-1)
        {
    		err = cudaMemcpy(d_As[i], h_A+(i*numElements/numDevs), size-i*step, cudaMemcpyHostToDevice);
        }
	else
	{
    		err = cudaMemcpy(d_As[i], h_A+(i*numElements/numDevs), step, cudaMemcpyHostToDevice);
        }

    	if (err != cudaSuccess)
    	{
        	fprintf(stderr, "Failed to copy vector A's part %d from host to device (error code %s)!\n", i, cudaGetErrorString(err));
        	exit(EXIT_FAILURE);
    	}

    }
    for(int i = 0; i < numDevs; ++i)
    {
	//set device is very important
        cudaSetDevice(i);
        if (i == numDevs-1)
        {
    		err = cudaMemcpy(d_Bs[i], h_B+(i*numElements/numDevs), size-i*step, cudaMemcpyHostToDevice);
	}
	else
	{
    		err = cudaMemcpy(d_Bs[i], h_B+(i*numElements/numDevs), step, cudaMemcpyHostToDevice);
	}

    	if (err != cudaSuccess)
    	{
        	fprintf(stderr, "Failed to copy vector B's part %d from host to device (error code %s)!\n", i, cudaGetErrorString(err));
        	exit(EXIT_FAILURE);
    	}
    }

    // cudaEvent_t is used to caculate the running time of the program on the devices
    cudaEvent_t start;
    err = cudaEventCreate(&start);

    if (err != cudaSuccess)
    {
	fprintf(stderr, "Failed to create start event (error code %s)!\n", cudaGetErrorString(err));
	exit(EXIT_SUCCESS);
    }

    cudaEvent_t stop;
    err = cudaEventCreate(&stop);

    if (err != cudaSuccess)
    {
	fprintf(stderr, "Failed to create start event (error code %s)!\n", cudaGetErrorString(err));
	exit(EXIT_SUCCESS);
    }

    // Record the start event
    err = cudaEventRecord(start, NULL);

    if (err != cudaSuccess)
    {
        fprintf(stderr, "Failed to record start event (error code %s)!\n", cudaGetErrorString(err));
        exit(EXIT_FAILURE);
    }

    // Launch the Vector Add CUDA Kernel
    int threadsPerBlock = 256;
    int blocksPerGrid =(numElements/numDevs + threadsPerBlock - 1) / threadsPerBlock;
    for (int i = 0; i < numDevs; ++i)
    {
    	printf("CUDA kernel %d launch with %d blocks of %d threads\n", i, blocksPerGrid, threadsPerBlock);
        cudaSetDevice(i);
	if (i == numDevs-1)
	{
    		vectorAdd<<<blocksPerGrid, threadsPerBlock>>>(d_As[i], d_Bs[i], d_Cs[i], numElements - i*numElements/numDevs);
	}
	else
	{
    		vectorAdd<<<blocksPerGrid, threadsPerBlock>>>(d_As[i], d_Bs[i], d_Cs[i], numElements/numDevs);
	}
    	err = cudaGetLastError();

    	if (err != cudaSuccess)
    	{
        	fprintf(stderr, "Failed to launch vectorAdd kernel %d (error code %s)!\n", i, cudaGetErrorString(err));
        	exit(EXIT_FAILURE);
    	}
    }

    // Record the stop event
    err = cudaEventRecord(stop, NULL);

    if (err != cudaSuccess)
    {
        fprintf(stderr, "Failed to record stop event (error code %s)!\n", cudaGetErrorString(err));
        exit(EXIT_FAILURE);
    }

    // Wait for the stop event to complete
    err = cudaEventSynchronize(stop);

    if (err != cudaSuccess)
    {
        fprintf(stderr, "Failed to synchronize on the stop event (error code %s)!\n", cudaGetErrorString(err));
        exit(EXIT_FAILURE);
    }

    float msecTotal = 0.0f;
    err = cudaEventElapsedTime(&msecTotal, start, stop);

    if (err != cudaSuccess)
    {
        fprintf(stderr, "Failed to get time elapsed between events (error code %s)!\n", cudaGetErrorString(err));
        exit(EXIT_FAILURE);
    }

    printf("The total time is %f msec.\n", msecTotal);
    
    for (int i = 0; i < numDevs; ++i)
    {
	cudaSetDevice(i);
	if (i == numDevs-1)
	{
    		err = cudaMemcpy(h_C+(i*numElements/numDevs), d_Cs[i], size-i*step, cudaMemcpyDeviceToHost);
	}
	else
	{
    		err = cudaMemcpy(h_C+(i*numElements/numDevs), d_Cs[i], step, cudaMemcpyDeviceToHost);
	}

    	if (err != cudaSuccess)
    	{
        	fprintf(stderr, "Failed to copy vector C's part %d from device to host (error code %s)!\n", i, cudaGetErrorString(err));
        	exit(EXIT_FAILURE);
    	}
    }
    
    // Verify that the result vector is correct
    for (int i = 0; i < numElements; ++i)
    {
        if (fabs(h_A[i] + h_B[i] - h_C[i]) > 1e-5)
        {
            fprintf(stderr, "Result verification failed at element %d!\n", i);
            exit(EXIT_FAILURE);
        }
    }

    // Free device global memory
    for(int i = 0; i < numDevs; ++i)
    {
    	err = cudaFree(d_As[i]);

    	if (err != cudaSuccess)
    	{
        	fprintf(stderr, "Failed to free device vector A's part %d (error code %s)!\n", i, cudaGetErrorString(err));
        	exit(EXIT_FAILURE);
    	}
    }
    for(int i = 0; i < numDevs; ++i)
    {
    	err = cudaFree(d_Bs[i]);

    	if (err != cudaSuccess)
    	{
        	fprintf(stderr, "Failed to free device vector B's part %d (error code %s)!\n", i, cudaGetErrorString(err));
        	exit(EXIT_FAILURE);
    	}
    }
    for(int i = 0; i < numDevs; ++i)
    {
    	err = cudaFree(d_Cs[i]);

    	if (err != cudaSuccess)
    	{
        	fprintf(stderr, "Failed to free device vector C's part %d (error code %s)!\n", i, cudaGetErrorString(err));
        	exit(EXIT_FAILURE);
    	}
    }
    // Free host memory
    free(h_A);
    free(h_B);
    free(h_C);

    // Reset the device and exit
    err = cudaDeviceReset();

    if (err != cudaSuccess)
    {
        fprintf(stderr, "Failed to deinitialize the device! error=%s\n", cudaGetErrorString(err));
        exit(EXIT_FAILURE);
    }

    printf("Done\n");
    return 0;
}


	.file	"tmpxft_002cdfbb_00000000-6_vectorAdd_MultiGPU.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2030:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2030:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z35__device_stub__Z9vectorAddPKfS0_PfiPKfS0_Pfi
	.type	_Z35__device_stub__Z9vectorAddPKfS0_PfiPKfS0_Pfi, @function
_Z35__device_stub__Z9vectorAddPKfS0_PfiPKfS0_Pfi:
.LFB2052:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movq	%rdi, 24(%rsp)
	leaq	56(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	68(%rsp), %rsi
	movq	%rdx, 8(%rsp)
	leaq	40(%rsp), %rdx
	movl	%ecx, 4(%rsp)
	leaq	48(%rsp), %rcx
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 64(%rsp)
	movq	%rax, 104(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	4(%rsp), %rax
	movq	%rax, 128(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 56(%rsp)
	movq	%rax, 68(%rsp)
	movl	$1, 76(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L2
	pushq	48(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z9vectorAddPKfS0_Pfi(%rip), %rdi
	pushq	48(%rsp)
	.cfi_def_cfa_offset 176
	movq	84(%rsp), %rcx
	movl	92(%rsp), %r8d
	movq	72(%rsp), %rsi
	movl	80(%rsp), %edx
	leaq	120(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 168
	popq	%rdx
	.cfi_def_cfa_offset 160
.L2:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L4
	call	__stack_chk_fail@PLT
.L4:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2052:
	.size	_Z35__device_stub__Z9vectorAddPKfS0_PfiPKfS0_Pfi, .-_Z35__device_stub__Z9vectorAddPKfS0_PfiPKfS0_Pfi
	.globl	_Z9vectorAddPKfS0_Pfi
	.type	_Z9vectorAddPKfS0_Pfi, @function
_Z9vectorAddPKfS0_Pfi:
.LFB2053:
	.cfi_startproc
	endbr64
	jmp	_Z35__device_stub__Z9vectorAddPKfS0_PfiPKfS0_Pfi
	.cfi_endproc
.LFE2053:
	.size	_Z9vectorAddPKfS0_Pfi, .-_Z9vectorAddPKfS0_Pfi
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"[Vector addition of %d elements]\n"
.LC1:
	.string	"There is no GPU device!"
.LC2:
	.string	"Failed to allocate host vectors!\n"
.LC4:
	.string	"Failed to allocate array d_As to store pointers of device vectors!\n"
.LC5:
	.string	"Failed to allocate device vector A's part %d (error code %s)!\n"
.LC6:
	.string	"Failed to allocate array d_Bs to store pointers of device vectors!\n"
.LC7:
	.string	"Failed to allocate device vector B's part %d (error code %s)!\n"
.LC8:
	.string	"Failed to allocate array d_Cs to store pointers of device vectors!\n"
.LC9:
	.string	"Failed to allocate device vector C's part %d (error code %s)!\n"
.LC10:
	.string	"Copy input data from the host memory to the CUDA device\n"
.LC11:
	.string	"Failed to copy vector A's part %d from host to device (error code %s)!\n"
.LC12:
	.string	"Failed to copy vector B's part %d from host to device (error code %s)!\n"
.LC13:
	.string	"Failed to create start event (error code %s)!\n"
.LC14:
	.string	"Failed to record start event (error code %s)!\n"
.LC15:
	.string	"CUDA kernel %d launch with %d blocks of %d threads\n"
.LC16:
	.string	"Failed to launch vectorAdd kernel %d (error code %s)!\n"
.LC17:
	.string	"Failed to record stop event (error code %s)!\n"
.LC18:
	.string	"Failed to synchronize on the stop event (error code %s)!\n"
.LC20:
	.string	"Failed to get time elapsed between events (error code %s)!\n"
.LC21:
	.string	"The total time is %f msec.\n"
.LC22:
	.string	"Failed to copy vector C's part %d from device to host (error code %s)!\n"
.LC25:
	.string	"Result verification failed at element %d!\n"
.LC26:
	.string	"Failed to free device vector A's part %d (error code %s)!\n"
.LC27:
	.string	"Failed to free device vector B's part %d (error code %s)!\n"
.LC28:
	.string	"Failed to free device vector C's part %d (error code %s)!\n"
.LC29:
	.string	"Failed to deinitialize the device! error=%s\n"
.LC30:
	.string	"Done\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2027:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	$4900001, %edx
	movl	$2, %edi
	leaq	.LC0(%rip), %rsi
	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
	call	__printf_chk@PLT
	xorl	%r8d, %r8d
	leaq	60(%rsp), %rdi
	movl	%r8d, 60(%rsp)
	call	cudaGetDeviceCount@PLT
	movl	60(%rsp), %ecx
	leaq	.LC1(%rip), %rdx
	testl	%ecx, %ecx
	je	.L100
	movl	$4900001, %eax
	movl	$19600004, %edi
	cltd
	idivl	%ecx
	cltq
	salq	$2, %rax
	movq	%rax, 8(%rsp)
	call	malloc@PLT
	movl	$19600004, %edi
	movq	%rax, 24(%rsp)
	call	malloc@PLT
	movl	$19600004, %edi
	movq	%rax, 32(%rsp)
	call	malloc@PLT
	cmpq	$0, 24(%rsp)
	movq	%rax, 40(%rsp)
	sete	%al
	cmpq	$0, 32(%rsp)
	sete	%dl
	orb	%dl, %al
	jne	.L75
	xorl	%edi, %edi
	cmpq	$0, 40(%rsp)
	movq	%rdi, 16(%rsp)
	jne	.L10
.L75:
	leaq	.LC2(%rip), %rdx
.L100:
	movq	stderr(%rip), %rdi
	movl	$2, %esi
	xorl	%eax, %eax
.L101:
	call	__fprintf_chk@PLT
.L102:
	movl	$1, %edi
.L103:
	call	exit@PLT
.L10:
	call	rand@PLT
	movq	16(%rsp), %rbx
	cvtsi2ssl	%eax, %xmm0
	mulss	.LC3(%rip), %xmm0
	movq	24(%rsp), %rax
	movss	%xmm0, (%rax,%rbx)
	call	rand@PLT
	movq	16(%rsp), %rbx
	addq	$4, 16(%rsp)
	cmpq	$19600004, 16(%rsp)
	cvtsi2ssl	%eax, %xmm0
	movq	32(%rsp), %rax
	mulss	.LC3(%rip), %xmm0
	movss	%xmm0, (%rax,%rbx)
	jne	.L10
	movslq	60(%rsp), %rdi
	movq	%rdi, %rbx
	call	malloc@PLT
	leaq	.LC4(%rip), %rdx
	movq	%rax, %rbp
	xorl	%eax, %eax
	testq	%rbp, %rbp
	je	.L104
.L12:
	cmpl	%eax, %ebx
	jle	.L109
	xorl	%esi, %esi
	movq	%rsi, 0(%rbp,%rax,8)
	incq	%rax
	jmp	.L12
.L109:
	movq	%rbp, %r12
	movl	$19600004, %r13d
	xorl	%ebx, %ebx
	movl	$19600004, %r14d
.L14:
	movl	60(%rsp), %r15d
	cmpl	%ebx, %r15d
	jle	.L110
	movl	%ebx, %edi
	call	cudaSetDevice@PLT
	movslq	60(%rsp), %rcx
	movq	%r13, %rsi
	leal	-1(%rcx), %eax
	cmpl	%ebx, %eax
	je	.L93
	movq	%r14, %rax
	xorl	%edx, %edx
	divq	%rcx
	movq	%rax, %rsi
.L93:
	movq	%r12, %rdi
	addq	$8, %r12
	call	cudaMalloc@PLT
	movq	8(%rsp), %rsi
	subq	%rsi, %r13
	testl	%eax, %eax
	je	.L17
	movl	%eax, %edi
	call	cudaGetErrorString@PLT
	movl	%ebx, %r8d
	leaq	.LC5(%rip), %rdx
	movq	%rax, %rcx
	jmp	.L106
.L17:
	incl	%ebx
	jmp	.L14
.L110:
	movslq	%r15d, %rdi
	call	malloc@PLT
	leaq	.LC6(%rip), %rdx
	movq	%rax, %rbx
	xorl	%eax, %eax
	testq	%rbx, %rbx
	je	.L104
.L19:
	cmpl	%eax, %r15d
	jle	.L111
	xorl	%ecx, %ecx
	movq	%rcx, (%rbx,%rax,8)
	incq	%rax
	jmp	.L19
.L111:
	movq	%rbx, %r13
	movl	$19600004, %r14d
	xorl	%r12d, %r12d
.L21:
	movl	60(%rsp), %r15d
	cmpl	%r12d, %r15d
	jle	.L112
	movl	%r12d, %edi
	call	cudaSetDevice@PLT
	movslq	60(%rsp), %rcx
	movq	%r14, %rsi
	leal	-1(%rcx), %eax
	cmpl	%r12d, %eax
	je	.L94
	movl	$19600004, %eax
	xorl	%edx, %edx
	divq	%rcx
	movq	%rax, %rsi
.L94:
	movq	%r13, %rdi
	addq	$8, %r13
	call	cudaMalloc@PLT
	movq	8(%rsp), %rsi
	subq	%rsi, %r14
	testl	%eax, %eax
	je	.L24
	movl	%eax, %edi
	call	cudaGetErrorString@PLT
	movl	%r12d, %r8d
	leaq	.LC7(%rip), %rdx
	movq	%rax, %rcx
	jmp	.L106
.L24:
	incl	%r12d
	jmp	.L21
.L112:
	movslq	%r15d, %rdi
	call	malloc@PLT
	movq	%rax, %r13
	xorl	%eax, %eax
	testq	%r13, %r13
	jne	.L26
	leaq	.LC8(%rip), %rdx
.L104:
	movq	stderr(%rip), %rdi
	movl	$2, %esi
	jmp	.L101
.L26:
	cmpl	%eax, %r15d
	jle	.L113
	xorl	%edx, %edx
	movq	%rdx, 0(%r13,%rax,8)
	incq	%rax
	jmp	.L26
.L113:
	movq	%r13, %r15
	movl	$19600004, %r14d
	xorl	%r12d, %r12d
	jmp	.L28
.L31:
	incl	%r12d
.L28:
	cmpl	%r12d, 60(%rsp)
	jle	.L114
	movl	%r12d, %edi
	call	cudaSetDevice@PLT
	movslq	60(%rsp), %rcx
	movq	%r14, %rsi
	leal	-1(%rcx), %eax
	cmpl	%r12d, %eax
	je	.L95
	movl	$19600004, %eax
	xorl	%edx, %edx
	divq	%rcx
	movq	%rax, %rsi
.L95:
	movq	%r15, %rdi
	addq	$8, %r15
	call	cudaMalloc@PLT
	movq	8(%rsp), %rsi
	subq	%rsi, %r14
	testl	%eax, %eax
	je	.L31
	movl	%eax, %edi
	call	cudaGetErrorString@PLT
	movl	%r12d, %r8d
	leaq	.LC9(%rip), %rdx
	movq	%rax, %rcx
.L106:
	movq	stderr(%rip), %rdi
	movl	$2, %esi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	jmp	.L102
.L114:
	movl	$2, %edi
	xorl	%eax, %eax
	movl	$19600004, %r12d
	xorl	%r14d, %r14d
	leaq	.LC10(%rip), %rsi
	call	__printf_chk@PLT
.L33:
	movl	%r14d, %r15d
	cmpl	%r14d, 60(%rsp)
	jle	.L115
	movl	%r15d, %edi
	call	cudaSetDevice@PLT
	movl	60(%rsp), %ecx
	movq	0(%rbp,%r14,8), %rdi
	imull	$4900001, %r14d, %eax
	leal	-1(%rcx), %edx
	cmpl	%r14d, %edx
	jne	.L34
	cltd
	movq	24(%rsp), %rsi
	idivl	%ecx
	movl	$1, %ecx
	movq	%r12, %rdx
	cltq
	leaq	(%rsi,%rax,4), %rsi
	jmp	.L96
.L34:
	cltd
	movq	24(%rsp), %rsi
	idivl	%ecx
	movq	8(%rsp), %rdx
	movl	$1, %ecx
	cltq
	leaq	(%rsi,%rax,4), %rsi
.L96:
	call	cudaMemcpy@PLT
	movq	8(%rsp), %rsi
	incq	%r14
	subq	%rsi, %r12
	testl	%eax, %eax
	je	.L33
	movl	%eax, %edi
	call	cudaGetErrorString@PLT
	movl	%r15d, %ecx
	leaq	.LC11(%rip), %rdx
	movq	%rax, %r8
	jmp	.L105
.L115:
	movl	$19600004, %r12d
	xorl	%r14d, %r14d
.L37:
	movl	%r14d, %r15d
	cmpl	%r14d, 60(%rsp)
	jle	.L116
	movl	%r15d, %edi
	call	cudaSetDevice@PLT
	movl	60(%rsp), %ecx
	imull	$4900001, %r14d, %eax
	movq	(%rbx,%r14,8), %rdi
	leal	-1(%rcx), %edx
	cmpl	%r14d, %edx
	jne	.L38
	cltd
	movq	32(%rsp), %rsi
	idivl	%ecx
	movl	$1, %ecx
	movq	%r12, %rdx
	cltq
	leaq	(%rsi,%rax,4), %rsi
	jmp	.L97
.L38:
	cltd
	movq	32(%rsp), %rsi
	idivl	%ecx
	movq	8(%rsp), %rdx
	movl	$1, %ecx
	cltq
	leaq	(%rsi,%rax,4), %rsi
.L97:
	call	cudaMemcpy@PLT
	movq	8(%rsp), %rsi
	incq	%r14
	subq	%rsi, %r12
	testl	%eax, %eax
	je	.L37
	movl	%eax, %edi
	call	cudaGetErrorString@PLT
	movl	%r15d, %ecx
	leaq	.LC12(%rip), %rdx
	movq	%rax, %r8
	jmp	.L105
.L116:
	leaq	64(%rsp), %rdi
	call	cudaEventCreate@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	jne	.L108
	leaq	72(%rsp), %rdi
	call	cudaEventCreate@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L42
.L108:
	call	cudaGetErrorString@PLT
	movq	stderr(%rip), %rdi
	movl	$2, %esi
	leaq	.LC13(%rip), %rdx
	movq	%rax, %rcx
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	xorl	%edi, %edi
	jmp	.L103
.L42:
	movq	64(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L43
	call	cudaGetErrorString@PLT
	leaq	.LC14(%rip), %rdx
	movq	%rax, %rcx
	jmp	.L107
.L43:
	movl	$4900001, %eax
	movl	$256, %ecx
	xorl	%r15d, %r15d
	cltd
	idivl	60(%rsp)
	addl	$255, %eax
	cltd
	idivl	%ecx
	movl	%eax, %r12d
.L44:
	movl	%r15d, %r14d
	cmpl	%r15d, 60(%rsp)
	jle	.L117
	movl	$256, %r8d
	movl	%r12d, %ecx
	movl	%r14d, %edx
	xorl	%eax, %eax
	leaq	.LC15(%rip), %rsi
	movl	$2, %edi
	call	__printf_chk@PLT
	movl	%r14d, %edi
	call	cudaSetDevice@PLT
	movl	60(%rsp), %eax
	movl	%r12d, 80(%rsp)
	movabsq	$4294967552, %rdx
	movq	%rdx, 92(%rsp)
	movl	$0, %r9d
	movl	$1, %ecx
	movl	$0, %r8d
	decl	%eax
	movl	$1, 100(%rsp)
	cmpl	%r15d, %eax
	movabsq	$4294967297, %rax
	movq	%rax, 84(%rsp)
	movq	80(%rsp), %rdi
	movl	88(%rsp), %esi
	jne	.L45
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L47
	imull	$4900001, %r15d, %eax
	movl	$4900001, %ecx
	movq	(%rbx,%r15,8), %rsi
	movq	0(%rbp,%r15,8), %rdi
	cltd
	idivl	60(%rsp)
	movq	0(%r13,%r15,8), %rdx
	subl	%eax, %ecx
	jmp	.L98
.L45:
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L47
	movl	$4900001, %eax
	movq	(%rbx,%r15,8), %rsi
	movq	0(%rbp,%r15,8), %rdi
	cltd
	idivl	60(%rsp)
	movq	0(%r13,%r15,8), %rdx
	movl	%eax, %ecx
.L98:
	call	_Z35__device_stub__Z9vectorAddPKfS0_PfiPKfS0_Pfi
.L47:
	call	cudaGetLastError@PLT
	incq	%r15
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L44
	call	cudaGetErrorString@PLT
	movl	%r14d, %ecx
	leaq	.LC16(%rip), %rdx
	movq	%rax, %r8
	jmp	.L105
.L117:
	movq	72(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L50
	call	cudaGetErrorString@PLT
	leaq	.LC17(%rip), %rdx
	movq	%rax, %rcx
	jmp	.L107
.L50:
	movq	72(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L51
	call	cudaGetErrorString@PLT
	leaq	.LC18(%rip), %rdx
	movq	%rax, %rcx
	jmp	.L107
.L51:
	movq	72(%rsp), %rdx
	movq	64(%rsp), %rsi
	leaq	92(%rsp), %rdi
	movl	$0x00000000, 92(%rsp)
	call	cudaEventElapsedTime@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L52
	call	cudaGetErrorString@PLT
	leaq	.LC20(%rip), %rdx
	movq	%rax, %rcx
	jmp	.L107
.L52:
	movl	$2, %edi
	leaq	.LC21(%rip), %rsi
	movb	$1, %al
	xorl	%r12d, %r12d
	cvtss2sd	92(%rsp), %xmm0
	call	__printf_chk@PLT
.L53:
	movl	%r12d, %r14d
	cmpl	60(%rsp), %r12d
	jge	.L118
	movl	%r14d, %edi
	call	cudaSetDevice@PLT
	movl	60(%rsp), %ecx
	movq	0(%r13,%r12,8), %rsi
	imull	$4900001, %r12d, %eax
	leal	-1(%rcx), %edx
	cmpl	%edx, %r12d
	jne	.L54
	cltd
	idivl	%ecx
	movq	40(%rsp), %rcx
	movq	16(%rsp), %rdx
	cltq
	leaq	(%rcx,%rax,4), %rdi
	movl	$2, %ecx
	jmp	.L99
.L54:
	cltd
	idivl	%ecx
	movq	40(%rsp), %rcx
	movq	8(%rsp), %rdx
	cltq
	leaq	(%rcx,%rax,4), %rdi
	movl	$2, %ecx
.L99:
	call	cudaMemcpy@PLT
	incq	%r12
	movq	8(%rsp), %rcx
	subq	%rcx, 16(%rsp)
	testl	%eax, %eax
	je	.L53
	movl	%eax, %edi
	call	cudaGetErrorString@PLT
	movl	%r14d, %ecx
	leaq	.LC22(%rip), %rdx
	movq	%rax, %r8
	jmp	.L105
.L118:
	movsd	.LC24(%rip), %xmm2
	xorl	%ecx, %ecx
	movss	.LC23(%rip), %xmm1
.L59:
	movq	24(%rsp), %rax
	movss	(%rax,%rcx,4), %xmm0
	movq	32(%rsp), %rax
	addss	(%rax,%rcx,4), %xmm0
	movq	40(%rsp), %rax
	subss	(%rax,%rcx,4), %xmm0
	andps	%xmm1, %xmm0
	cvtss2sd	%xmm0, %xmm0
	comisd	%xmm2, %xmm0
	jbe	.L91
	movq	stderr(%rip), %rdi
	leaq	.LC25(%rip), %rdx
	movl	$2, %esi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	jmp	.L102
.L91:
	incq	%rcx
	cmpq	$4900001, %rcx
	jne	.L59
	xorl	%r12d, %r12d
.L60:
	cmpl	%r12d, 60(%rsp)
	jle	.L119
	movq	0(%rbp,%r12,8), %rdi
	call	cudaFree@PLT
	movl	%eax, %edi
	leaq	1(%r12), %rax
	testl	%edi, %edi
	je	.L72
	call	cudaGetErrorString@PLT
	movl	%r12d, %ecx
	leaq	.LC26(%rip), %rdx
	movq	%rax, %r8
	jmp	.L105
.L72:
	movq	%rax, %r12
	jmp	.L60
.L119:
	xorl	%ebp, %ebp
.L62:
	cmpl	%ebp, 60(%rsp)
	jle	.L120
	movq	(%rbx,%rbp,8), %rdi
	call	cudaFree@PLT
	movl	%eax, %edi
	leaq	1(%rbp), %rax
	testl	%edi, %edi
	je	.L73
	call	cudaGetErrorString@PLT
	movl	%ebp, %ecx
	leaq	.LC27(%rip), %rdx
	movq	%rax, %r8
	jmp	.L105
.L73:
	movq	%rax, %rbp
	jmp	.L62
.L120:
	xorl	%ebx, %ebx
	jmp	.L64
.L74:
	movq	%rax, %rbx
.L64:
	cmpl	%ebx, 60(%rsp)
	jle	.L121
	movq	0(%r13,%rbx,8), %rdi
	call	cudaFree@PLT
	movl	%eax, %edi
	leaq	1(%rbx), %rax
	testl	%edi, %edi
	je	.L74
	call	cudaGetErrorString@PLT
	movl	%ebx, %ecx
	leaq	.LC28(%rip), %rdx
	movq	%rax, %r8
.L105:
	movq	stderr(%rip), %rdi
	movl	$2, %esi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	jmp	.L102
.L121:
	movq	24(%rsp), %rdi
	call	free@PLT
	movq	32(%rsp), %rdi
	call	free@PLT
	movq	40(%rsp), %rdi
	call	free@PLT
	call	cudaDeviceReset@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L66
	call	cudaGetErrorString@PLT
	leaq	.LC29(%rip), %rdx
	movq	%rax, %rcx
.L107:
	movq	stderr(%rip), %rdi
	movl	$2, %esi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	jmp	.L102
.L66:
	xorl	%eax, %eax
	leaq	.LC30(%rip), %rsi
	movl	$2, %edi
	call	__printf_chk@PLT
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	je	.L67
	call	__stack_chk_fail@PLT
.L67:
	addq	$120, %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
.LFE2027:
	.size	main, .-main
	.section	.rodata.str1.1
.LC31:
	.string	"_Z9vectorAddPKfS0_Pfi"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2055:
	.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	.LC31(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z9vectorAddPKfS0_Pfi(%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
.LFE2055:
	.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
.LC3:
	.long	805306368
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC23:
	.long	2147483647
	.long	0
	.long	0
	.long	0
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC24:
	.long	-1998362383
	.long	1055193269
	.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:

/**
 * Copyright 1993-2012 NVIDIA Corporation.  All rights reserved.
 *
 * Please refer to the NVIDIA end user license agreement (EULA) associated
 * with this source code for terms and conditions that govern your use of
 * this software. Any use, reproduction, disclosure, or distribution of
 * this software and related documentation outside the terms of the EULA
 * is strictly prohibited.
 *
 */

/**
 * Vector addition: C = A + B.
 *
 * This sample is a very basic sample that implements element by element
 * vector addition. It is the same as the sample illustrating Chapter 2
 * of the programming guide with some additions like error checking.
 */

#include <stdio.h>

// For the CUDA runtime routines (prefixed with "cuda_")
#include <hip/hip_runtime.h>

//#include <helper_functions.h>
/**
 * CUDA Kernel Device code
 *
 * Computes the vector addition of A and B into C. The 3 vectors have the same
 * number of elements numElements.
 */
__global__ void
vectorAdd(const float *A, const float *B, float *C, int numElements)
{
    int i = blockDim.x * blockIdx.x + threadIdx.x;

    if (i < numElements)
    {
        C[i] = A[i] + B[i];
    }
}

/**
 * Host main routine
 */
int
main(void)
{
    // Error code to check return values for CUDA calls
    hipError_t err = hipSuccess;

    // Print the vector length to be used, and compute its size
    int numElements = 4900001;
    size_t size = numElements * sizeof(float);
    printf("[Vector addition of %d elements]\n", numElements);

    
    // Multi-GPU
    int numDevs = 0;
    hipGetDeviceCount(&numDevs);

    if (numDevs == 0)
    {
	fprintf(stderr, "There is no GPU device!");
        exit(EXIT_FAILURE);
    }
   
    // step size between device
    size_t step = numElements/numDevs*sizeof(float); // not size/numDevs
    
    // Allocate the host input vector A
    float *h_A = (float *)malloc(size);

    // Allocate the host input vector B
    float *h_B = (float *)malloc(size);

    // Allocate the host output vector C
    float *h_C = (float *)malloc(size);

    // Verify that allocations succeeded
    if (h_A == NULL || h_B == NULL || h_C == NULL)
    {
        fprintf(stderr, "Failed to allocate host vectors!\n");
        exit(EXIT_FAILURE);
    }

    // Initialize the host input vectors
    for (int i = 0; i < numElements; ++i)
    {
        h_A[i] = rand()/(float)RAND_MAX;
        h_B[i] = rand()/(float)RAND_MAX;
    }

    // Allocate arry of pointers to store the device input vectors
    float **d_As = (float **)malloc(numDevs);
    
    if(d_As == NULL)
    {
	fprintf(stderr, "Failed to allocate array d_As to store pointers of device vectors!\n");
        exit(EXIT_FAILURE);
    }

    for(int i = 0; i < numDevs; ++i)
    {
	d_As[i] = NULL;
    }

    for(int i = 0; i < numDevs; ++i)
    {
        hipSetDevice(i);
        if (i == numDevs-1)
        {
    	   err = hipMalloc((void **)&d_As[i], size-i*step);
	   //printf("The size is %d bytes and step is %d bytes.\n", size, step);
	   //printf("The last device should allocate %d bytes.\n", size-i*step);
        }
	else
	{
    	   err = hipMalloc((void **)&d_As[i], size/numDevs);
        }
    	if (err != hipSuccess)
    	{
        	fprintf(stderr, "Failed to allocate device vector A's part %d (error code %s)!\n", hipGetErrorString(err), i);
        	exit(EXIT_FAILURE);
    	}
	
    }
    // Allocate arry of pointers to store the device input vectors
    float **d_Bs = (float **)malloc(numDevs);
  
    if(d_Bs == NULL)
    {
	fprintf(stderr, "Failed to allocate array d_Bs to store pointers of device vectors!\n");
        exit(EXIT_FAILURE);
    }

    for(int i = 0; i < numDevs; ++i)
    {
	d_Bs[i] = NULL;
    }

    for(int i = 0; i < numDevs; ++i)
    {
        hipSetDevice(i);
        if (i == numDevs-1)
        {
    	   err = hipMalloc((void **)&d_Bs[i], size-i*step);
        }
	else
	{
    	   err = hipMalloc((void **)&d_Bs[i], size/numDevs);
        }
	
    	if (err != hipSuccess)
    	{
           fprintf(stderr, "Failed to allocate device vector B's part %d (error code %s)!\n", hipGetErrorString(err), i);
           exit(EXIT_FAILURE);
    	}

    }
    // Allocate arry of pointers to store the device input vectors
    float **d_Cs = (float **)malloc(numDevs);
    if(d_Cs == NULL)
    {
	fprintf(stderr, "Failed to allocate array d_Cs to store pointers of device vectors!\n");
        exit(EXIT_FAILURE);
    }

    for(int i = 0; i < numDevs; ++i)
    {
	d_Cs[i] = NULL;
    }

    for(int i = 0; i < numDevs; ++i)
    {
	//set device is very important
        hipSetDevice(i);
        if (i == numDevs-1)
        {
    	   err = hipMalloc((void **)&d_Cs[i], size-i*step);
        }
	else
	{
    	   err = hipMalloc((void **)&d_Cs[i], size/numDevs);
        }

    	if (err != hipSuccess)
    	{
        	fprintf(stderr, "Failed to allocate device vector C's part %d (error code %s)!\n", hipGetErrorString(err), i);
        	exit(EXIT_FAILURE);
    	}
    }

    // Copy the host input vectors A and B in host memory to the device input vectors in
    // device memory

    printf("Copy input data from the host memory to the CUDA device\n");
    for(int i = 0; i < numDevs; ++i)
    {
	//set device is very important
        hipSetDevice(i);
        if (i == numDevs-1)
        {
    		err = hipMemcpy(d_As[i], h_A+(i*numElements/numDevs), size-i*step, hipMemcpyHostToDevice);
        }
	else
	{
    		err = hipMemcpy(d_As[i], h_A+(i*numElements/numDevs), step, hipMemcpyHostToDevice);
        }

    	if (err != hipSuccess)
    	{
        	fprintf(stderr, "Failed to copy vector A's part %d from host to device (error code %s)!\n", i, hipGetErrorString(err));
        	exit(EXIT_FAILURE);
    	}

    }
    for(int i = 0; i < numDevs; ++i)
    {
	//set device is very important
        hipSetDevice(i);
        if (i == numDevs-1)
        {
    		err = hipMemcpy(d_Bs[i], h_B+(i*numElements/numDevs), size-i*step, hipMemcpyHostToDevice);
	}
	else
	{
    		err = hipMemcpy(d_Bs[i], h_B+(i*numElements/numDevs), step, hipMemcpyHostToDevice);
	}

    	if (err != hipSuccess)
    	{
        	fprintf(stderr, "Failed to copy vector B's part %d from host to device (error code %s)!\n", i, hipGetErrorString(err));
        	exit(EXIT_FAILURE);
    	}
    }

    // cudaEvent_t is used to caculate the running time of the program on the devices
    hipEvent_t start;
    err = hipEventCreate(&start);

    if (err != hipSuccess)
    {
	fprintf(stderr, "Failed to create start event (error code %s)!\n", hipGetErrorString(err));
	exit(EXIT_SUCCESS);
    }

    hipEvent_t stop;
    err = hipEventCreate(&stop);

    if (err != hipSuccess)
    {
	fprintf(stderr, "Failed to create start event (error code %s)!\n", hipGetErrorString(err));
	exit(EXIT_SUCCESS);
    }

    // Record the start event
    err = hipEventRecord(start, NULL);

    if (err != hipSuccess)
    {
        fprintf(stderr, "Failed to record start event (error code %s)!\n", hipGetErrorString(err));
        exit(EXIT_FAILURE);
    }

    // Launch the Vector Add CUDA Kernel
    int threadsPerBlock = 256;
    int blocksPerGrid =(numElements/numDevs + threadsPerBlock - 1) / threadsPerBlock;
    for (int i = 0; i < numDevs; ++i)
    {
    	printf("CUDA kernel %d launch with %d blocks of %d threads\n", i, blocksPerGrid, threadsPerBlock);
        hipSetDevice(i);
	if (i == numDevs-1)
	{
    		vectorAdd<<<blocksPerGrid, threadsPerBlock>>>(d_As[i], d_Bs[i], d_Cs[i], numElements - i*numElements/numDevs);
	}
	else
	{
    		vectorAdd<<<blocksPerGrid, threadsPerBlock>>>(d_As[i], d_Bs[i], d_Cs[i], numElements/numDevs);
	}
    	err = hipGetLastError();

    	if (err != hipSuccess)
    	{
        	fprintf(stderr, "Failed to launch vectorAdd kernel %d (error code %s)!\n", i, hipGetErrorString(err));
        	exit(EXIT_FAILURE);
    	}
    }

    // Record the stop event
    err = hipEventRecord(stop, NULL);

    if (err != hipSuccess)
    {
        fprintf(stderr, "Failed to record stop event (error code %s)!\n", hipGetErrorString(err));
        exit(EXIT_FAILURE);
    }

    // Wait for the stop event to complete
    err = hipEventSynchronize(stop);

    if (err != hipSuccess)
    {
        fprintf(stderr, "Failed to synchronize on the stop event (error code %s)!\n", hipGetErrorString(err));
        exit(EXIT_FAILURE);
    }

    float msecTotal = 0.0f;
    err = hipEventElapsedTime(&msecTotal, start, stop);

    if (err != hipSuccess)
    {
        fprintf(stderr, "Failed to get time elapsed between events (error code %s)!\n", hipGetErrorString(err));
        exit(EXIT_FAILURE);
    }

    printf("The total time is %f msec.\n", msecTotal);
    
    for (int i = 0; i < numDevs; ++i)
    {
	hipSetDevice(i);
	if (i == numDevs-1)
	{
    		err = hipMemcpy(h_C+(i*numElements/numDevs), d_Cs[i], size-i*step, hipMemcpyDeviceToHost);
	}
	else
	{
    		err = hipMemcpy(h_C+(i*numElements/numDevs), d_Cs[i], step, hipMemcpyDeviceToHost);
	}

    	if (err != hipSuccess)
    	{
        	fprintf(stderr, "Failed to copy vector C's part %d from device to host (error code %s)!\n", i, hipGetErrorString(err));
        	exit(EXIT_FAILURE);
    	}
    }
    
    // Verify that the result vector is correct
    for (int i = 0; i < numElements; ++i)
    {
        if (fabs(h_A[i] + h_B[i] - h_C[i]) > 1e-5)
        {
            fprintf(stderr, "Result verification failed at element %d!\n", i);
            exit(EXIT_FAILURE);
        }
    }

    // Free device global memory
    for(int i = 0; i < numDevs; ++i)
    {
    	err = hipFree(d_As[i]);

    	if (err != hipSuccess)
    	{
        	fprintf(stderr, "Failed to free device vector A's part %d (error code %s)!\n", i, hipGetErrorString(err));
        	exit(EXIT_FAILURE);
    	}
    }
    for(int i = 0; i < numDevs; ++i)
    {
    	err = hipFree(d_Bs[i]);

    	if (err != hipSuccess)
    	{
        	fprintf(stderr, "Failed to free device vector B's part %d (error code %s)!\n", i, hipGetErrorString(err));
        	exit(EXIT_FAILURE);
    	}
    }
    for(int i = 0; i < numDevs; ++i)
    {
    	err = hipFree(d_Cs[i]);

    	if (err != hipSuccess)
    	{
        	fprintf(stderr, "Failed to free device vector C's part %d (error code %s)!\n", i, hipGetErrorString(err));
        	exit(EXIT_FAILURE);
    	}
    }
    // Free host memory
    free(h_A);
    free(h_B);
    free(h_C);

    // Reset the device and exit
    err = hipDeviceReset();

    if (err != hipSuccess)
    {
        fprintf(stderr, "Failed to deinitialize the device! error=%s\n", hipGetErrorString(err));
        exit(EXIT_FAILURE);
    }

    printf("Done\n");
    return 0;
}


	.text
	.file	"vectorAdd_MultiGPU.hip"
	.globl	_Z24__device_stub__vectorAddPKfS0_Pfi # -- Begin function _Z24__device_stub__vectorAddPKfS0_Pfi
	.type	_Z24__device_stub__vectorAddPKfS0_Pfi,@function
_Z24__device_stub__vectorAddPKfS0_Pfi:  # @_Z24__device_stub__vectorAddPKfS0_Pfi
	.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), %rdi
	movq	%rsi, (%rdi)
	leaq	24(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	4(%rsp), %rdx
	movl	%ecx, (%rdx)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%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	$_Z9vectorAddPKfS0_Pfi, %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	_Z24__device_stub__vectorAddPKfS0_Pfi, .Lfunc_end0-_Z24__device_stub__vectorAddPKfS0_Pfi
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function main
.LCPI1_0:
	.long	0x30000000                      # float 4.65661287E-10
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0
.LCPI1_1:
	.long	0x7fffffff                      # float NaN
	.long	0x7fffffff                      # float NaN
	.long	0x7fffffff                      # float NaN
	.long	0x7fffffff                      # float NaN
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0
.LCPI1_2:
	.quad	0x3ee4f8b588e368f1              # double 1.0000000000000001E-5
	.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	$88, %rsp
	.cfi_def_cfa_offset 144
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	$.L.str, %edi
	movl	$4900001, %esi                  # imm = 0x4AC4A1
	xorl	%eax, %eax
	callq	printf
	leaq	4(%rsp), %rbx
	movl	$0, (%rbx)
	movq	%rbx, %rdi
	callq	hipGetDeviceCount
	movl	(%rbx), %ecx
	testl	%ecx, %ecx
	je	.LBB1_90
# %bb.1:
	movl	$4900001, %eax                  # imm = 0x4AC4A1
	xorl	%edx, %edx
	idivl	%ecx
	movl	%eax, %ebp
	movl	$19600004, %edi                 # imm = 0x12B1284
	callq	malloc
	movq	%rax, %r15
	movl	$19600004, %edi                 # imm = 0x12B1284
	callq	malloc
	movq	%rax, 32(%rsp)                  # 8-byte Spill
	movl	$19600004, %edi                 # imm = 0x12B1284
	callq	malloc
	testq	%r15, %r15
	je	.LBB1_91
# %bb.2:
	cmpq	$0, 32(%rsp)                    # 8-byte Folded Reload
	je	.LBB1_91
# %bb.3:
	testq	%rax, %rax
	je	.LBB1_91
# %bb.4:                                # %.preheader301.preheader
	movq	%rax, 64(%rsp)                  # 8-byte Spill
	movslq	%ebp, %rbx
	shlq	$2, %rbx
	xorl	%r14d, %r14d
	movq	32(%rsp), %r12                  # 8-byte Reload
.LBB1_5:                                # %.preheader301
                                        # =>This Inner Loop Header: Depth=1
	callq	rand
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	movss	.LCPI1_0(%rip), %xmm1           # xmm1 = mem[0],zero,zero,zero
	mulss	%xmm1, %xmm0
	movss	%xmm0, (%r15,%r14,4)
	callq	rand
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	mulss	.LCPI1_0(%rip), %xmm0
	movss	%xmm0, (%r12,%r14,4)
	incq	%r14
	cmpq	$4900001, %r14                  # imm = 0x4AC4A1
	jne	.LBB1_5
# %bb.6:
	movl	4(%rsp), %r14d
	movslq	%r14d, %r12
	movq	%r12, %rdi
	callq	malloc
	movq	%rax, 24(%rsp)                  # 8-byte Spill
	testq	%rax, %rax
	je	.LBB1_92
# %bb.7:                                # %.preheader300
	movq	%r15, 56(%rsp)                  # 8-byte Spill
	testl	%r14d, %r14d
	jle	.LBB1_13
# %bb.8:                                # %.lr.ph323.preheader
	shlq	$3, %r14
	xorl	%r15d, %r15d
	movq	24(%rsp), %r13                  # 8-byte Reload
	movq	%r13, %rdi
	xorl	%esi, %esi
	movq	%r14, %rdx
	callq	memset@PLT
	movl	$19600004, %ebp                 # imm = 0x12B1284
.LBB1_9:                                # %.lr.ph323
                                        # =>This Inner Loop Header: Depth=1
	movl	%r15d, %edi
	callq	hipSetDevice
	movslq	4(%rsp), %rcx
	leal	-1(%rcx), %eax
	movq	%rbp, %rsi
	cmpq	%rax, %r15
	je	.LBB1_11
# %bb.10:                               #   in Loop: Header=BB1_9 Depth=1
	movl	$19600004, %eax                 # imm = 0x12B1284
	xorl	%edx, %edx
	divq	%rcx
	movq	%rax, %rsi
.LBB1_11:                               #   in Loop: Header=BB1_9 Depth=1
	movq	%r13, %rdi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB1_74
# %bb.12:                               #   in Loop: Header=BB1_9 Depth=1
	incq	%r15
	movl	4(%rsp), %r14d
	movslq	%r14d, %r12
	subq	%rbx, %rbp
	addq	$8, %r13
	cmpq	%r12, %r15
	jl	.LBB1_9
.LBB1_13:                               # %._crit_edge
	movq	%r12, %rdi
	callq	malloc
	movq	%rax, 8(%rsp)                   # 8-byte Spill
	testq	%rax, %rax
	je	.LBB1_93
# %bb.14:                               # %.preheader298
	testl	%r14d, %r14d
	jle	.LBB1_20
# %bb.15:                               # %.lr.ph327.preheader
	movl	%r14d, %edx
	shlq	$3, %rdx
	xorl	%r15d, %r15d
	movq	8(%rsp), %r13                   # 8-byte Reload
	movq	%r13, %rdi
	xorl	%esi, %esi
	callq	memset@PLT
	movl	$19600004, %ebp                 # imm = 0x12B1284
.LBB1_16:                               # %.lr.ph327
                                        # =>This Inner Loop Header: Depth=1
	movl	%r15d, %edi
	callq	hipSetDevice
	movslq	4(%rsp), %rcx
	leal	-1(%rcx), %eax
	movq	%rbp, %rsi
	cmpq	%rax, %r15
	je	.LBB1_18
# %bb.17:                               #   in Loop: Header=BB1_16 Depth=1
	movl	$19600004, %eax                 # imm = 0x12B1284
	xorl	%edx, %edx
	divq	%rcx
	movq	%rax, %rsi
.LBB1_18:                               #   in Loop: Header=BB1_16 Depth=1
	movq	%r13, %rdi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB1_75
# %bb.19:                               #   in Loop: Header=BB1_16 Depth=1
	incq	%r15
	movl	4(%rsp), %r14d
	movslq	%r14d, %r12
	subq	%rbx, %rbp
	addq	$8, %r13
	cmpq	%r12, %r15
	jl	.LBB1_16
.LBB1_20:                               # %._crit_edge328
	movq	%r12, %rdi
	callq	malloc
	movq	%rax, 16(%rsp)                  # 8-byte Spill
	testq	%rax, %rax
	je	.LBB1_94
# %bb.21:                               # %.preheader296
	testl	%r14d, %r14d
	movq	56(%rsp), %r13                  # 8-byte Reload
	movq	32(%rsp), %rbp                  # 8-byte Reload
	jle	.LBB1_27
# %bb.22:                               # %.lr.ph333.preheader
	movl	%r14d, %edx
	shlq	$3, %rdx
	xorl	%r14d, %r14d
	movq	16(%rsp), %r15                  # 8-byte Reload
	movq	%r15, %rdi
	xorl	%esi, %esi
	callq	memset@PLT
	movl	$19600004, %r12d                # imm = 0x12B1284
.LBB1_23:                               # %.lr.ph333
                                        # =>This Inner Loop Header: Depth=1
	movl	%r14d, %edi
	callq	hipSetDevice
	movslq	4(%rsp), %rcx
	leal	-1(%rcx), %eax
	movq	%r12, %rsi
	cmpq	%rax, %r14
	je	.LBB1_25
# %bb.24:                               #   in Loop: Header=BB1_23 Depth=1
	movl	$19600004, %eax                 # imm = 0x12B1284
	xorl	%edx, %edx
	divq	%rcx
	movq	%rax, %rsi
.LBB1_25:                               #   in Loop: Header=BB1_23 Depth=1
	movq	%r15, %rdi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB1_77
# %bb.26:                               #   in Loop: Header=BB1_23 Depth=1
	incq	%r14
	movslq	4(%rsp), %rax
	subq	%rbx, %r12
	addq	$8, %r15
	cmpq	%rax, %r14
	jl	.LBB1_23
.LBB1_27:                               # %._crit_edge334
	movl	$.Lstr, %edi
	callq	puts@PLT
	cmpl	$0, 4(%rsp)
	jle	.LBB1_35
# %bb.28:                               # %.lr.ph337.preheader
	xorl	%r15d, %r15d
	movl	$19600004, %r12d                # imm = 0x12B1284
	xorl	%r14d, %r14d
.LBB1_29:                               # %.lr.ph337
                                        # =>This Inner Loop Header: Depth=1
	movl	%r14d, %edi
	callq	hipSetDevice
	movl	4(%rsp), %ecx
	leal	-1(%rcx), %esi
	movl	%r15d, %eax
	cltd
	idivl	%ecx
	cmpq	%rsi, %r14
	movq	24(%rsp), %rcx                  # 8-byte Reload
	movq	(%rcx,%r14,8), %rdi
	cltq
	leaq	(%r13,%rax,4), %rsi
	movq	%rbx, %rdx
	cmoveq	%r12, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB1_80
# %bb.30:                               #   in Loop: Header=BB1_29 Depth=1
	incq	%r14
	movslq	4(%rsp), %rax
	addl	$4900001, %r15d                 # imm = 0x4AC4A1
	subq	%rbx, %r12
	cmpq	%rax, %r14
	jl	.LBB1_29
# %bb.31:                               # %.preheader294
	testl	%eax, %eax
	jle	.LBB1_35
# %bb.32:                               # %.lr.ph339.preheader
	xorl	%r15d, %r15d
	movl	$19600004, %r12d                # imm = 0x12B1284
	xorl	%r14d, %r14d
.LBB1_33:                               # %.lr.ph339
                                        # =>This Inner Loop Header: Depth=1
	movl	%r14d, %edi
	callq	hipSetDevice
	movl	4(%rsp), %ecx
	leal	-1(%rcx), %esi
	movl	%r15d, %eax
	cltd
	idivl	%ecx
	cmpq	%rsi, %r14
	movq	8(%rsp), %rcx                   # 8-byte Reload
	movq	(%rcx,%r14,8), %rdi
	cltq
	leaq	(%rbp,%rax,4), %rsi
	movq	%rbx, %rdx
	cmoveq	%r12, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB1_84
# %bb.34:                               #   in Loop: Header=BB1_33 Depth=1
	incq	%r14
	movslq	4(%rsp), %rax
	addl	$4900001, %r15d                 # imm = 0x4AC4A1
	subq	%rbx, %r12
	cmpq	%rax, %r14
	jl	.LBB1_33
.LBB1_35:                               # %._crit_edge340
	leaq	72(%rsp), %rdi
	callq	hipEventCreate
	testl	%eax, %eax
	jne	.LBB1_89
# %bb.36:
	leaq	40(%rsp), %rdi
	callq	hipEventCreate
	testl	%eax, %eax
	jne	.LBB1_89
# %bb.37:
	movq	72(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	testl	%eax, %eax
	jne	.LBB1_97
# %bb.38:
	movl	4(%rsp), %ecx
	movl	$4900001, %eax                  # imm = 0x4AC4A1
	xorl	%edx, %edx
	idivl	%ecx
	movl	%eax, %r13d
	leal	255(%r13), %eax
	addl	$510, %r13d                     # imm = 0x1FE
	testl	%eax, %eax
	cmovnsl	%eax, %r13d
	testl	%ecx, %ecx
	jle	.LBB1_48
# %bb.39:                               # %.lr.ph343
	sarl	$8, %r13d
	movabsq	$4294967296, %r15               # imm = 0x100000000
	movl	%r13d, %eax
	btsq	$32, %rax
	movq	%rax, 80(%rsp)                  # 8-byte Spill
	addq	$256, %r15                      # imm = 0x100
	xorl	%r14d, %r14d
	xorl	%ebp, %ebp
.LBB1_40:                               # =>This Inner Loop Header: Depth=1
	movl	$.L.str.14, %edi
	movl	%ebp, %esi
	movl	%r13d, %edx
	movl	$256, %ecx                      # imm = 0x100
	xorl	%eax, %eax
	callq	printf
	movl	%ebp, %edi
	callq	hipSetDevice
	movl	4(%rsp), %r12d
	decl	%r12d
	movq	80(%rsp), %rdi                  # 8-byte Reload
	movl	$1, %esi
	movq	%r15, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	cmpq	%r12, %rbp
	jne	.LBB1_43
# %bb.41:                               #   in Loop: Header=BB1_40 Depth=1
	testl	%eax, %eax
	jne	.LBB1_46
# %bb.42:                               #   in Loop: Header=BB1_40 Depth=1
	movq	24(%rsp), %rax                  # 8-byte Reload
	movq	(%rax,%rbp,8), %rdi
	movq	8(%rsp), %rax                   # 8-byte Reload
	movq	(%rax,%rbp,8), %rsi
	movq	16(%rsp), %rax                  # 8-byte Reload
	movq	(%rax,%rbp,8), %r8
	movl	%r14d, %eax
	cltd
	idivl	4(%rsp)
	movl	$4900001, %ecx                  # imm = 0x4AC4A1
	subl	%eax, %ecx
	movq	%r8, %rdx
	jmp	.LBB1_45
.LBB1_43:                               #   in Loop: Header=BB1_40 Depth=1
	testl	%eax, %eax
	jne	.LBB1_46
# %bb.44:                               #   in Loop: Header=BB1_40 Depth=1
	movq	24(%rsp), %rax                  # 8-byte Reload
	movq	(%rax,%rbp,8), %rdi
	movq	8(%rsp), %rax                   # 8-byte Reload
	movq	(%rax,%rbp,8), %rsi
	movq	16(%rsp), %rax                  # 8-byte Reload
	movq	(%rax,%rbp,8), %rcx
	movl	$4900001, %eax                  # imm = 0x4AC4A1
	xorl	%edx, %edx
	idivl	4(%rsp)
	movq	%rcx, %rdx
	movl	%eax, %ecx
.LBB1_45:                               #   in Loop: Header=BB1_40 Depth=1
	callq	_Z24__device_stub__vectorAddPKfS0_Pfi
.LBB1_46:                               #   in Loop: Header=BB1_40 Depth=1
	callq	hipGetLastError
	testl	%eax, %eax
	jne	.LBB1_81
# %bb.47:                               #   in Loop: Header=BB1_40 Depth=1
	incq	%rbp
	movslq	4(%rsp), %rax
	addl	$4900001, %r14d                 # imm = 0x4AC4A1
	cmpq	%rax, %rbp
	jl	.LBB1_40
.LBB1_48:                               # %._crit_edge344
	movq	40(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	testl	%eax, %eax
	jne	.LBB1_98
# %bb.49:
	movq	40(%rsp), %rdi
	callq	hipEventSynchronize
	testl	%eax, %eax
	movq	56(%rsp), %r13                  # 8-byte Reload
	movq	32(%rsp), %rbp                  # 8-byte Reload
	jne	.LBB1_99
# %bb.50:
	leaq	52(%rsp), %rdi
	movl	$0, (%rdi)
	movq	72(%rsp), %rsi
	movq	40(%rsp), %rdx
	callq	hipEventElapsedTime
	testl	%eax, %eax
	jne	.LBB1_100
# %bb.51:
	cvtss2sd	52(%rsp), %xmm0
	movl	$.L.str.19, %edi
	movb	$1, %al
	callq	printf
	xorl	%r14d, %r14d
	cmpl	$0, 4(%rsp)
	jle	.LBB1_56
# %bb.52:                               # %.lr.ph347.preheader
	movl	$19600004, %r12d                # imm = 0x12B1284
	xorl	%r15d, %r15d
.LBB1_53:                               # %.lr.ph347
                                        # =>This Inner Loop Header: Depth=1
	movl	%r15d, %edi
	callq	hipSetDevice
	movl	4(%rsp), %ecx
	leal	-1(%rcx), %esi
	movl	%r14d, %eax
	cltd
	idivl	%ecx
	cmpq	%rsi, %r15
	cltq
	movq	64(%rsp), %rcx                  # 8-byte Reload
	leaq	(%rcx,%rax,4), %rdi
	movq	16(%rsp), %rax                  # 8-byte Reload
	movq	(%rax,%r15,8), %rsi
	movq	%rbx, %rdx
	cmoveq	%r12, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB1_82
# %bb.54:                               #   in Loop: Header=BB1_53 Depth=1
	incq	%r15
	movslq	4(%rsp), %rax
	addl	$4900001, %r14d                 # imm = 0x4AC4A1
	subq	%rbx, %r12
	cmpq	%rax, %r15
	jl	.LBB1_53
# %bb.55:                               # %.preheader293.loopexit
	testl	%eax, %eax
	setg	%r14b
.LBB1_56:                               # %.preheader293
	xorl	%edx, %edx
	movaps	.LCPI1_1(%rip), %xmm0           # xmm0 = [NaN,NaN,NaN,NaN]
	movsd	.LCPI1_2(%rip), %xmm1           # xmm1 = mem[0],zero
	movq	64(%rsp), %rbx                  # 8-byte Reload
.LBB1_57:                               # =>This Inner Loop Header: Depth=1
	movss	(%r13,%rdx,4), %xmm2            # xmm2 = mem[0],zero,zero,zero
	addss	(%rbp,%rdx,4), %xmm2
	subss	(%rbx,%rdx,4), %xmm2
	andps	%xmm0, %xmm2
	cvtss2sd	%xmm2, %xmm2
	ucomisd	%xmm1, %xmm2
	ja	.LBB1_73
# %bb.58:                               #   in Loop: Header=BB1_57 Depth=1
	incq	%rdx
	cmpq	$4900001, %rdx                  # imm = 0x4AC4A1
	jne	.LBB1_57
# %bb.59:                               # %.preheader292
	testb	%r14b, %r14b
	je	.LBB1_71
# %bb.60:                               # %.lr.ph350.preheader
	xorl	%r14d, %r14d
.LBB1_61:                               # %.lr.ph350
                                        # =>This Inner Loop Header: Depth=1
	movq	24(%rsp), %rax                  # 8-byte Reload
	movq	(%rax,%r14,8), %rdi
	callq	hipFree
	testl	%eax, %eax
	jne	.LBB1_83
# %bb.62:                               #   in Loop: Header=BB1_61 Depth=1
	incq	%r14
	movslq	4(%rsp), %rax
	cmpq	%rax, %r14
	jl	.LBB1_61
# %bb.63:                               # %.preheader291
	testl	%eax, %eax
	jle	.LBB1_71
# %bb.64:                               # %.lr.ph352.preheader
	xorl	%r14d, %r14d
.LBB1_65:                               # %.lr.ph352
                                        # =>This Inner Loop Header: Depth=1
	movq	8(%rsp), %rax                   # 8-byte Reload
	movq	(%rax,%r14,8), %rdi
	callq	hipFree
	testl	%eax, %eax
	jne	.LBB1_85
# %bb.66:                               #   in Loop: Header=BB1_65 Depth=1
	incq	%r14
	movslq	4(%rsp), %rax
	cmpq	%rax, %r14
	jl	.LBB1_65
# %bb.67:                               # %.preheader
	testl	%eax, %eax
	jle	.LBB1_71
# %bb.68:                               # %.lr.ph354.preheader
	xorl	%r14d, %r14d
.LBB1_69:                               # %.lr.ph354
                                        # =>This Inner Loop Header: Depth=1
	movq	16(%rsp), %rax                  # 8-byte Reload
	movq	(%rax,%r14,8), %rdi
	callq	hipFree
	testl	%eax, %eax
	jne	.LBB1_86
# %bb.70:                               #   in Loop: Header=BB1_69 Depth=1
	incq	%r14
	movslq	4(%rsp), %rax
	cmpq	%rax, %r14
	jl	.LBB1_69
.LBB1_71:                               # %._crit_edge355
	movq	%r13, %rdi
	callq	free
	movq	%rbp, %rdi
	callq	free
	movq	%rbx, %rdi
	callq	free
	callq	hipDeviceReset
	testl	%eax, %eax
	jne	.LBB1_101
# %bb.72:
	movl	$.Lstr.1, %edi
	callq	puts@PLT
	xorl	%eax, %eax
	addq	$88, %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
.LBB1_73:
	.cfi_def_cfa_offset 144
	movq	stderr(%rip), %rdi
	movl	$.L.str.21, %esi
                                        # kill: def $edx killed $edx killed $rdx
	xorl	%eax, %eax
	callq	fprintf
	jmp	.LBB1_79
.LBB1_74:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.4, %esi
	jmp	.LBB1_76
.LBB1_75:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.6, %esi
.LBB1_76:
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	%r15d, %ecx
	jmp	.LBB1_78
.LBB1_77:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.8, %esi
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	%r14d, %ecx
.LBB1_78:
	xorl	%eax, %eax
	callq	fprintf
	jmp	.LBB1_79
.LBB1_80:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.10, %esi
	jmp	.LBB1_87
.LBB1_81:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.15, %esi
	movq	%rbx, %rdi
	movl	%ebp, %edx
	jmp	.LBB1_88
.LBB1_82:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.20, %esi
	movq	%rbx, %rdi
	movl	%r15d, %edx
	jmp	.LBB1_88
.LBB1_83:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.22, %esi
	jmp	.LBB1_87
.LBB1_84:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.11, %esi
	jmp	.LBB1_87
.LBB1_85:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.23, %esi
	jmp	.LBB1_87
.LBB1_86:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.24, %esi
.LBB1_87:
	movq	%rbx, %rdi
	movl	%r14d, %edx
.LBB1_88:
	movq	%rax, %rcx
	xorl	%eax, %eax
	callq	fprintf
.LBB1_79:
	movl	$1, %edi
	callq	exit
.LBB1_89:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.12, %esi
	movq	%rbx, %rdi
	movq	%rax, %rdx
	xorl	%eax, %eax
	callq	fprintf
	xorl	%edi, %edi
	callq	exit
.LBB1_90:
	movq	stderr(%rip), %rcx
	movl	$.L.str.1, %edi
	movl	$23, %esi
	jmp	.LBB1_96
.LBB1_91:
	movq	stderr(%rip), %rcx
	movl	$.L.str.2, %edi
	movl	$33, %esi
	jmp	.LBB1_96
.LBB1_92:
	movq	stderr(%rip), %rcx
	movl	$.L.str.3, %edi
	jmp	.LBB1_95
.LBB1_93:
	movq	stderr(%rip), %rcx
	movl	$.L.str.5, %edi
	jmp	.LBB1_95
.LBB1_94:
	movq	stderr(%rip), %rcx
	movl	$.L.str.7, %edi
.LBB1_95:
	movl	$67, %esi
.LBB1_96:
	movl	$1, %edx
	callq	fwrite@PLT
	jmp	.LBB1_79
.LBB1_97:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.13, %esi
	jmp	.LBB1_102
.LBB1_98:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.16, %esi
	jmp	.LBB1_102
.LBB1_99:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.17, %esi
	jmp	.LBB1_102
.LBB1_100:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.18, %esi
	jmp	.LBB1_102
.LBB1_101:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.25, %esi
.LBB1_102:
	movq	%rbx, %rdi
	movq	%rax, %rdx
	xorl	%eax, %eax
	callq	fprintf
	jmp	.LBB1_79
.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	$_Z9vectorAddPKfS0_Pfi, %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	_Z9vectorAddPKfS0_Pfi,@object   # @_Z9vectorAddPKfS0_Pfi
	.section	.rodata,"a",@progbits
	.globl	_Z9vectorAddPKfS0_Pfi
	.p2align	3, 0x0
_Z9vectorAddPKfS0_Pfi:
	.quad	_Z24__device_stub__vectorAddPKfS0_Pfi
	.size	_Z9vectorAddPKfS0_Pfi, 8

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"[Vector addition of %d elements]\n"
	.size	.L.str, 34

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"There is no GPU device!"
	.size	.L.str.1, 24

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"Failed to allocate host vectors!\n"
	.size	.L.str.2, 34

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"Failed to allocate array d_As to store pointers of device vectors!\n"
	.size	.L.str.3, 68

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"Failed to allocate device vector A's part %d (error code %s)!\n"
	.size	.L.str.4, 63

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"Failed to allocate array d_Bs to store pointers of device vectors!\n"
	.size	.L.str.5, 68

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"Failed to allocate device vector B's part %d (error code %s)!\n"
	.size	.L.str.6, 63

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"Failed to allocate array d_Cs to store pointers of device vectors!\n"
	.size	.L.str.7, 68

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"Failed to allocate device vector C's part %d (error code %s)!\n"
	.size	.L.str.8, 63

	.type	.L.str.10,@object               # @.str.10
.L.str.10:
	.asciz	"Failed to copy vector A's part %d from host to device (error code %s)!\n"
	.size	.L.str.10, 72

	.type	.L.str.11,@object               # @.str.11
.L.str.11:
	.asciz	"Failed to copy vector B's part %d from host to device (error code %s)!\n"
	.size	.L.str.11, 72

	.type	.L.str.12,@object               # @.str.12
.L.str.12:
	.asciz	"Failed to create start event (error code %s)!\n"
	.size	.L.str.12, 47

	.type	.L.str.13,@object               # @.str.13
.L.str.13:
	.asciz	"Failed to record start event (error code %s)!\n"
	.size	.L.str.13, 47

	.type	.L.str.14,@object               # @.str.14
.L.str.14:
	.asciz	"CUDA kernel %d launch with %d blocks of %d threads\n"
	.size	.L.str.14, 52

	.type	.L.str.15,@object               # @.str.15
.L.str.15:
	.asciz	"Failed to launch vectorAdd kernel %d (error code %s)!\n"
	.size	.L.str.15, 55

	.type	.L.str.16,@object               # @.str.16
.L.str.16:
	.asciz	"Failed to record stop event (error code %s)!\n"
	.size	.L.str.16, 46

	.type	.L.str.17,@object               # @.str.17
.L.str.17:
	.asciz	"Failed to synchronize on the stop event (error code %s)!\n"
	.size	.L.str.17, 58

	.type	.L.str.18,@object               # @.str.18
.L.str.18:
	.asciz	"Failed to get time elapsed between events (error code %s)!\n"
	.size	.L.str.18, 60

	.type	.L.str.19,@object               # @.str.19
.L.str.19:
	.asciz	"The total time is %f msec.\n"
	.size	.L.str.19, 28

	.type	.L.str.20,@object               # @.str.20
.L.str.20:
	.asciz	"Failed to copy vector C's part %d from device to host (error code %s)!\n"
	.size	.L.str.20, 72

	.type	.L.str.21,@object               # @.str.21
.L.str.21:
	.asciz	"Result verification failed at element %d!\n"
	.size	.L.str.21, 43

	.type	.L.str.22,@object               # @.str.22
.L.str.22:
	.asciz	"Failed to free device vector A's part %d (error code %s)!\n"
	.size	.L.str.22, 59

	.type	.L.str.23,@object               # @.str.23
.L.str.23:
	.asciz	"Failed to free device vector B's part %d (error code %s)!\n"
	.size	.L.str.23, 59

	.type	.L.str.24,@object               # @.str.24
.L.str.24:
	.asciz	"Failed to free device vector C's part %d (error code %s)!\n"
	.size	.L.str.24, 59

	.type	.L.str.25,@object               # @.str.25
.L.str.25:
	.asciz	"Failed to deinitialize the device! error=%s\n"
	.size	.L.str.25, 45

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z9vectorAddPKfS0_Pfi"
	.size	.L__unnamed_1, 22

	.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	"Copy input data from the host memory to the CUDA device"
	.size	.Lstr, 56

	.type	.Lstr.1,@object                 # @str.1
.Lstr.1:
	.asciz	"Done"
	.size	.Lstr.1, 5

	.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 _Z24__device_stub__vectorAddPKfS0_Pfi
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z9vectorAddPKfS0_Pfi
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z9vectorAddPKfS0_Pfi   ; -- Begin function _Z9vectorAddPKfS0_Pfi
	.globl	_Z9vectorAddPKfS0_Pfi
	.p2align	8
	.type	_Z9vectorAddPKfS0_Pfi,@function
_Z9vectorAddPKfS0_Pfi:                  ; @_Z9vectorAddPKfS0_Pfi
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x2c
	s_load_b32 s3, s[0:1], 0x18
	s_waitcnt lgkmcnt(0)
	s_and_b32 s2, s2, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s15, s2, v[0:1]
	s_mov_b32 s2, exec_lo
	v_cmpx_gt_i32_e64 s3, v1
	s_cbranch_execz .LBB0_2
; %bb.1:
	s_load_b128 s[4:7], s[0:1], 0x0
	v_ashrrev_i32_e32 v2, 31, v1
	s_load_b64 s[0:1], s[0:1], 0x10
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[0:1], 2, v[1:2]
	s_waitcnt lgkmcnt(0)
	v_add_co_u32 v2, vcc_lo, s4, v0
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v3, vcc_lo, s5, v1, vcc_lo
	v_add_co_u32 v4, vcc_lo, s6, v0
	v_add_co_ci_u32_e32 v5, vcc_lo, s7, v1, vcc_lo
	v_add_co_u32 v0, vcc_lo, s0, v0
	global_load_b32 v2, v[2:3], off
	global_load_b32 v3, v[4:5], off
	v_add_co_ci_u32_e32 v1, vcc_lo, s1, v1, vcc_lo
	s_waitcnt vmcnt(0)
	v_add_f32_e32 v2, v2, v3
	global_store_b32 v[0:1], v2, off
.LBB0_2:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z9vectorAddPKfS0_Pfi
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 288
		.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_end0:
	.size	_Z9vectorAddPKfS0_Pfi, .Lfunc_end0-_Z9vectorAddPKfS0_Pfi
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 180
; 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
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         16
        .size:           8
        .value_kind:     global_buffer
      - .offset:         24
        .size:           4
        .value_kind:     by_value
      - .offset:         32
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         36
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         40
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         44
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         46
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         48
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         50
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         52
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         54
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         88
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         96
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 288
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z9vectorAddPKfS0_Pfi
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z9vectorAddPKfS0_Pfi.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
