#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <getopt.h>
#include <stdlib.h>
#include <sys/time.h>
#include <cuda_runtime.h>
              
#define N       512      
#define I       100000
#define BLOCKS  1
#define ORDER   1

#define cudaErrorCheck(ans) { gpuAssert((ans), __FILE__, __LINE__); }
inline void gpuAssert(cudaError_t code, const char *file, int line, bool abort = true)
{
    if (code != cudaSuccess)
    {
        fprintf(stderr, "GPUassert: %s %s %s %d\n", cudaGetErrorName(code), cudaGetErrorString(code), file, line);
        if (abort)
            exit(code);
    }
}

// GPU - CUDA kernel A
__global__ void device_kernel_A(int *A)
{
    int sum = 0;
    for(int i = 0; i < N; i++){
        sum += A[i*N + threadIdx.x];
    }
}

// GPU - CUDA kernel B
__global__ void device_kernel_B(int *B)
{
    int sum = 0;
    for(int i = 0; i < N; i++){
        sum += B[N*threadIdx.x + i];
    }
}

double walltime(void)
{
    static struct timeval t;
    gettimeofday(&t, NULL);
    return (t.tv_sec + 1e-6 * t.tv_usec);
}

int main(int argc, char **argv)
{
    // Walltime variables
    double timeStart;
    double timeA;
    double timeB;

    // Host variables
    int a[N*N];
    int b[N*N];
    bool testA = true;
    bool testB = true;

    // Set some random values
    for(int y = 0; y < N; y++){
        for(int x = 0; x < N; x++){
            a[y*N + x] = x + y;
            b[y*N + x] = x + y;
        }
    }

    //********************************* GPU work start *********************************
    
    // Variables
    int *A = NULL;
    int *B = NULL;

    // Set up device memory
    cudaErrorCheck(cudaMalloc((void**)&A, N*N * sizeof(int)));
    cudaErrorCheck(cudaMalloc((void**)&B, N*N * sizeof(int)));
    
    // Copy data from host to device
    cudaErrorCheck(cudaMemcpy(A, a, N*N * sizeof(int), cudaMemcpyHostToDevice));
    cudaErrorCheck(cudaMemcpy(B, b, N*N * sizeof(int), cudaMemcpyHostToDevice));
    
    // Warm up        
    device_kernel_A<<<BLOCKS,N>>>(A);
    device_kernel_B<<<BLOCKS,N>>>(B);

    if(ORDER == 1){
        if(testA){
            // GPU computation A
            timeStart = walltime();
            for(int i = 0; i < I; i++){
                device_kernel_A<<<BLOCKS,N>>>(A);
            }
            timeA = walltime() - timeStart;
        }
        if(testB){
            // GPU computation B
            timeStart = walltime();
            for(int i = 0; i < I; i++){
                device_kernel_B<<<BLOCKS,N>>>(B);
            }
            timeB = walltime() - timeStart;
        }
    }
    else{
        if(testB){
            // GPU computation B
            timeStart = walltime();
            for(int i = 0; i < I; i++){
                device_kernel_B<<<BLOCKS,N>>>(B);
            }
            timeB = walltime() - timeStart;
        }
        if(testA){
            // GPU computation A
            timeStart = walltime();
            for(int i = 0; i < I; i++){
                device_kernel_A<<<BLOCKS,N>>>(A);
            }
            timeA = walltime() - timeStart;
        }
    }

    // Free the device memory
    cudaErrorCheck(cudaFree(A));
    cudaErrorCheck(cudaFree(B));

    //********************************* GPU work stop *********************************

    printf("\n");
    printf("Walltime A: %7.3f ms \n", timeA * 1e3);
    printf("Walltime B: %7.3f ms \n", timeB * 1e3);
    printf("\n");

    return 0;
};

	.file	"tmpxft_002d7bbc_00000000-6_main.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2032:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2032:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.section	.rodata._Z9gpuAssert9cudaErrorPKcib.str1.1,"aMS",@progbits,1
.LC0:
	.string	"GPUassert: %s %s %s %d\n"
	.section	.text._Z9gpuAssert9cudaErrorPKcib,"axG",@progbits,_Z9gpuAssert9cudaErrorPKcib,comdat
	.weak	_Z9gpuAssert9cudaErrorPKcib
	.type	_Z9gpuAssert9cudaErrorPKcib, @function
_Z9gpuAssert9cudaErrorPKcib:
.LFB2027:
	.cfi_startproc
	endbr64
	testl	%edi, %edi
	je	.L8
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movl	%edx, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movl	%ecx, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	movl	%edi, %ebx
	subq	$16, %rsp
	.cfi_def_cfa_offset 48
	movq	%rsi, 8(%rsp)
	call	cudaGetErrorString@PLT
	movl	%ebx, %edi
	movq	%rax, (%rsp)
	call	cudaGetErrorName@PLT
	movq	stderr(%rip), %rdi
	movl	$2, %esi
	leaq	.LC0(%rip), %rdx
	pushq	%r9
	.cfi_def_cfa_offset 56
	movq	%rax, %rcx
	xorl	%eax, %eax
	pushq	%r12
	.cfi_def_cfa_offset 64
	movq	24(%rsp), %r9
	movq	16(%rsp), %r8
	call	__fprintf_chk@PLT
	popq	%r10
	.cfi_def_cfa_offset 56
	popq	%r11
	.cfi_def_cfa_offset 48
	testb	%bpl, %bpl
	je	.L2
	movl	%ebx, %edi
	call	exit@PLT
.L2:
	addq	$16, %rsp
	.cfi_def_cfa_offset 32
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
.L8:
	.cfi_restore 3
	.cfi_restore 6
	.cfi_restore 12
	ret
	.cfi_endproc
.LFE2027:
	.size	_Z9gpuAssert9cudaErrorPKcib, .-_Z9gpuAssert9cudaErrorPKcib
	.text
	.globl	_Z8walltimev
	.type	_Z8walltimev, @function
_Z8walltimev:
.LFB2028:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	xorl	%esi, %esi
	leaq	_ZZ8walltimevE1t(%rip), %rdi
	call	gettimeofday@PLT
	cvtsi2sdq	8+_ZZ8walltimevE1t(%rip), %xmm0
	mulsd	.LC1(%rip), %xmm0
	cvtsi2sdq	_ZZ8walltimevE1t(%rip), %xmm1
	popq	%rdx
	.cfi_def_cfa_offset 8
	addsd	%xmm1, %xmm0
	ret
	.cfi_endproc
.LFE2028:
	.size	_Z8walltimev, .-_Z8walltimev
	.globl	_Z35__device_stub__Z15device_kernel_APiPi
	.type	_Z35__device_stub__Z15device_kernel_APiPi, @function
_Z35__device_stub__Z15device_kernel_APiPi:
.LFB2054:
	.cfi_startproc
	endbr64
	subq	$104, %rsp
	.cfi_def_cfa_offset 112
	movq	%rdi, 8(%rsp)
	leaq	24(%rsp), %rcx
	leaq	16(%rsp), %rdx
	leaq	44(%rsp), %rsi
	leaq	32(%rsp), %rdi
	movq	%fs:40, %rax
	movq	%rax, 88(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rax
	movl	$1, 40(%rsp)
	movq	%rax, 80(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 32(%rsp)
	movq	%rax, 44(%rsp)
	movl	$1, 52(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L14
	pushq	24(%rsp)
	.cfi_def_cfa_offset 120
	leaq	_Z15device_kernel_APi(%rip), %rdi
	pushq	24(%rsp)
	.cfi_def_cfa_offset 128
	movq	60(%rsp), %rcx
	movl	68(%rsp), %r8d
	movq	48(%rsp), %rsi
	movl	56(%rsp), %edx
	leaq	96(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 120
	popq	%rdx
	.cfi_def_cfa_offset 112
.L14:
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	je	.L16
	call	__stack_chk_fail@PLT
.L16:
	addq	$104, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2054:
	.size	_Z35__device_stub__Z15device_kernel_APiPi, .-_Z35__device_stub__Z15device_kernel_APiPi
	.globl	_Z15device_kernel_APi
	.type	_Z15device_kernel_APi, @function
_Z15device_kernel_APi:
.LFB2055:
	.cfi_startproc
	endbr64
	jmp	_Z35__device_stub__Z15device_kernel_APiPi
	.cfi_endproc
.LFE2055:
	.size	_Z15device_kernel_APi, .-_Z15device_kernel_APi
	.globl	_Z35__device_stub__Z15device_kernel_BPiPi
	.type	_Z35__device_stub__Z15device_kernel_BPiPi, @function
_Z35__device_stub__Z15device_kernel_BPiPi:
.LFB2056:
	.cfi_startproc
	endbr64
	subq	$104, %rsp
	.cfi_def_cfa_offset 112
	movq	%rdi, 8(%rsp)
	leaq	24(%rsp), %rcx
	leaq	16(%rsp), %rdx
	leaq	44(%rsp), %rsi
	leaq	32(%rsp), %rdi
	movq	%fs:40, %rax
	movq	%rax, 88(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rax
	movl	$1, 40(%rsp)
	movq	%rax, 80(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 32(%rsp)
	movq	%rax, 44(%rsp)
	movl	$1, 52(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L19
	pushq	24(%rsp)
	.cfi_def_cfa_offset 120
	leaq	_Z15device_kernel_BPi(%rip), %rdi
	pushq	24(%rsp)
	.cfi_def_cfa_offset 128
	movq	60(%rsp), %rcx
	movl	68(%rsp), %r8d
	movq	48(%rsp), %rsi
	movl	56(%rsp), %edx
	leaq	96(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 120
	popq	%rdx
	.cfi_def_cfa_offset 112
.L19:
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	je	.L21
	call	__stack_chk_fail@PLT
.L21:
	addq	$104, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2056:
	.size	_Z35__device_stub__Z15device_kernel_BPiPi, .-_Z35__device_stub__Z15device_kernel_BPiPi
	.globl	_Z15device_kernel_BPi
	.type	_Z15device_kernel_BPi, @function
_Z15device_kernel_BPi:
.LFB2057:
	.cfi_startproc
	endbr64
	jmp	_Z35__device_stub__Z15device_kernel_BPiPi
	.cfi_endproc
.LFE2057:
	.size	_Z15device_kernel_BPi, .-_Z15device_kernel_BPi
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC2:
	.string	"/home/ubuntu/Datasets/stackv2/train-structured/martinty/TDT4200_2019/master/a8/main.cu"
.LC3:
	.string	"\n"
.LC5:
	.string	"Walltime A: %7.3f ms \n"
.LC6:
	.string	"Walltime B: %7.3f ms \n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2029:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	leaq	-2097152(%rsp), %r11
	.cfi_def_cfa 11, 2097192
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$72, %rsp
	.cfi_def_cfa_offset 2097264
	movq	%fs:40, %rax
	movq	%rax, 2097208(%rsp)
	xorl	%eax, %eax
.L25:
	movq	%rax, %rcx
	movl	%eax, %edi
	xorl	%edx, %edx
	salq	$11, %rcx
.L26:
	leal	(%rdx,%rdi), %esi
	incl	%edx
	leaq	56(%rsp), %r12
	movl	%esi, 56(%rsp,%rcx)
	leaq	1048632(%rsp), %rbp
	movl	%esi, 1048632(%rsp,%rcx)
	addq	$4, %rcx
	cmpl	$512, %edx
	jne	.L26
	incq	%rax
	cmpq	$512, %rax
	jne	.L25
	xorl	%eax, %eax
	leaq	16(%rsp), %rdi
	movl	$1048576, %esi
	leaq	.LC2(%rip), %rbx
	movq	%rax, 16(%rsp)
	movq	%rax, 24(%rsp)
	call	cudaMalloc@PLT
	movl	$1, %ecx
	movl	$78, %edx
	movq	%rbx, %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	leaq	24(%rsp), %rdi
	movl	$1048576, %esi
	call	cudaMalloc@PLT
	movl	$1, %ecx
	movl	$79, %edx
	movq	%rbx, %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	movq	16(%rsp), %rdi
	movl	$1, %ecx
	movq	%r12, %rsi
	movl	$1048576, %edx
	call	cudaMemcpy@PLT
	movl	$1, %ecx
	movl	$82, %edx
	movq	%rbx, %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	movq	24(%rsp), %rdi
	movl	$1, %ecx
	movq	%rbp, %rsi
	movl	$1048576, %edx
	call	cudaMemcpy@PLT
	movl	$1, %ecx
	movl	$83, %edx
	movq	%rbx, %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	movl	$8388609, %edx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	salq	$9, %rdx
	movl	$1, %ecx
	movabsq	$4294967297, %rdi
	movl	$1, %esi
	movq	%rdx, 44(%rsp)
	movl	$1, 52(%rsp)
	movq	%rdi, 32(%rsp)
	movl	$1, 40(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L28
	movq	16(%rsp), %rdi
	call	_Z35__device_stub__Z15device_kernel_APiPi
.L28:
	movl	$8388609, %edx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	$1, %ecx
	salq	$9, %rdx
	movl	$1, %esi
	movabsq	$4294967297, %rdi
	movl	$1, 52(%rsp)
	movq	%rdx, 44(%rsp)
	movq	%rdi, 32(%rsp)
	movl	$1, 40(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L29
	movq	24(%rsp), %rdi
	call	_Z35__device_stub__Z15device_kernel_BPiPi
.L29:
	call	_Z8walltimev
	movl	$100000, %ebp
	movabsq	$4294967808, %r12
	movsd	%xmm0, 8(%rsp)
.L31:
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movq	%r12, %rdx
	movl	$1, %ecx
	movabsq	$4294967297, %rdi
	movl	$1, %esi
	movq	%r12, 44(%rsp)
	movl	$1, 52(%rsp)
	movq	%rdi, 32(%rsp)
	movl	$1, 40(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L30
	movq	16(%rsp), %rdi
	call	_Z35__device_stub__Z15device_kernel_APiPi
.L30:
	decl	%ebp
	jne	.L31
	call	_Z8walltimev
	subsd	8(%rsp), %xmm0
	movl	$100000, %ebp
	movabsq	$4294967808, %r12
	movq	%xmm0, %r14
	call	_Z8walltimev
	movsd	%xmm0, 8(%rsp)
.L33:
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movq	%r12, %rdx
	movl	$1, %ecx
	movabsq	$4294967297, %rdi
	movl	$1, %esi
	movq	%r12, 44(%rsp)
	movl	$1, 52(%rsp)
	movq	%rdi, 32(%rsp)
	movl	$1, 40(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L32
	movq	24(%rsp), %rdi
	call	_Z35__device_stub__Z15device_kernel_BPiPi
.L32:
	decl	%ebp
	jne	.L33
	call	_Z8walltimev
	subsd	8(%rsp), %xmm0
	movq	16(%rsp), %rdi
	movsd	%xmm0, 8(%rsp)
	call	cudaFree@PLT
	movq	%rbx, %rsi
	movl	$1, %ecx
	movl	$127, %edx
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	movq	24(%rsp), %rdi
	call	cudaFree@PLT
	movl	$1, %ecx
	movl	$128, %edx
	movq	%rbx, %rsi
	movl	%eax, %edi
	leaq	.LC3(%rip), %rbx
	call	_Z9gpuAssert9cudaErrorPKcib
	movq	%rbx, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movsd	.LC4(%rip), %xmm0
	movq	%r14, %xmm3
	movb	$1, %al
	leaq	.LC5(%rip), %rsi
	movl	$2, %edi
	mulsd	%xmm3, %xmm0
	call	__printf_chk@PLT
	movsd	.LC4(%rip), %xmm0
	mulsd	8(%rsp), %xmm0
	movb	$1, %al
	leaq	.LC6(%rip), %rsi
	movl	$2, %edi
	call	__printf_chk@PLT
	xorl	%eax, %eax
	movq	%rbx, %rsi
	movl	$2, %edi
	call	__printf_chk@PLT
	movq	2097208(%rsp), %rax
	subq	%fs:40, %rax
	je	.L34
	call	__stack_chk_fail@PLT
.L34:
	addq	$2097224, %rsp
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2029:
	.size	main, .-main
	.section	.rodata.str1.1
.LC7:
	.string	"_Z15device_kernel_BPi"
.LC8:
	.string	"_Z15device_kernel_APi"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2059:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	pushq	$0
	.cfi_def_cfa_offset 24
	xorl	%r9d, %r9d
	orl	$-1, %r8d
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC7(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z15device_kernel_BPi(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 48
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r9d, %r9d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC8(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z15device_kernel_APi(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 40
	pushq	$0
	.cfi_def_cfa_offset 48
	call	__cudaRegisterFunction@PLT
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE2059:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.local	_ZZ8walltimevE1t
	.comm	_ZZ8walltimevE1t,16,16
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC1:
	.long	-1598689907
	.long	1051772663
	.align 8
.LC4:
	.long	0
	.long	1083129856
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <getopt.h>
#include <stdlib.h>
#include <sys/time.h>
#include <hip/hip_runtime.h>
              
#define N       512      
#define I       100000
#define BLOCKS  1
#define ORDER   1

#define cudaErrorCheck(ans) { gpuAssert((ans), __FILE__, __LINE__); }
inline void gpuAssert(hipError_t code, const char *file, int line, bool abort = true)
{
    if (code != hipSuccess)
    {
        fprintf(stderr, "GPUassert: %s %s %s %d\n", hipGetErrorName(code), hipGetErrorString(code), file, line);
        if (abort)
            exit(code);
    }
}

// GPU - CUDA kernel A
__global__ void device_kernel_A(int *A)
{
    int sum = 0;
    for(int i = 0; i < N; i++){
        sum += A[i*N + threadIdx.x];
    }
}

// GPU - CUDA kernel B
__global__ void device_kernel_B(int *B)
{
    int sum = 0;
    for(int i = 0; i < N; i++){
        sum += B[N*threadIdx.x + i];
    }
}

double walltime(void)
{
    static struct timeval t;
    gettimeofday(&t, NULL);
    return (t.tv_sec + 1e-6 * t.tv_usec);
}

int main(int argc, char **argv)
{
    // Walltime variables
    double timeStart;
    double timeA;
    double timeB;

    // Host variables
    int a[N*N];
    int b[N*N];
    bool testA = true;
    bool testB = true;

    // Set some random values
    for(int y = 0; y < N; y++){
        for(int x = 0; x < N; x++){
            a[y*N + x] = x + y;
            b[y*N + x] = x + y;
        }
    }

    //********************************* GPU work start *********************************
    
    // Variables
    int *A = NULL;
    int *B = NULL;

    // Set up device memory
    cudaErrorCheck(hipMalloc((void**)&A, N*N * sizeof(int)));
    cudaErrorCheck(hipMalloc((void**)&B, N*N * sizeof(int)));
    
    // Copy data from host to device
    cudaErrorCheck(hipMemcpy(A, a, N*N * sizeof(int), hipMemcpyHostToDevice));
    cudaErrorCheck(hipMemcpy(B, b, N*N * sizeof(int), hipMemcpyHostToDevice));
    
    // Warm up        
    device_kernel_A<<<BLOCKS,N>>>(A);
    device_kernel_B<<<BLOCKS,N>>>(B);

    if(ORDER == 1){
        if(testA){
            // GPU computation A
            timeStart = walltime();
            for(int i = 0; i < I; i++){
                device_kernel_A<<<BLOCKS,N>>>(A);
            }
            timeA = walltime() - timeStart;
        }
        if(testB){
            // GPU computation B
            timeStart = walltime();
            for(int i = 0; i < I; i++){
                device_kernel_B<<<BLOCKS,N>>>(B);
            }
            timeB = walltime() - timeStart;
        }
    }
    else{
        if(testB){
            // GPU computation B
            timeStart = walltime();
            for(int i = 0; i < I; i++){
                device_kernel_B<<<BLOCKS,N>>>(B);
            }
            timeB = walltime() - timeStart;
        }
        if(testA){
            // GPU computation A
            timeStart = walltime();
            for(int i = 0; i < I; i++){
                device_kernel_A<<<BLOCKS,N>>>(A);
            }
            timeA = walltime() - timeStart;
        }
    }

    // Free the device memory
    cudaErrorCheck(hipFree(A));
    cudaErrorCheck(hipFree(B));

    //********************************* GPU work stop *********************************

    printf("\n");
    printf("Walltime A: %7.3f ms \n", timeA * 1e3);
    printf("Walltime B: %7.3f ms \n", timeB * 1e3);
    printf("\n");

    return 0;
};

	.text
	.file	"main.hip"
	.globl	_Z30__device_stub__device_kernel_APi # -- Begin function _Z30__device_stub__device_kernel_APi
	.type	_Z30__device_stub__device_kernel_APi,@function
_Z30__device_stub__device_kernel_APi:   # @_Z30__device_stub__device_kernel_APi
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$64, %rsp
	.cfi_def_cfa_offset 112
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	24(%rsp), %rax
	movq	%rdi, (%rax)
	movq	%rsp, %rbx
	movq	%rax, (%rbx)
	leaq	48(%rsp), %r14
	leaq	32(%rsp), %r15
	leaq	16(%rsp), %r12
	leaq	8(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z15device_kernel_APi, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$80, %rsp
	.cfi_adjust_cfa_offset -80
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	_Z30__device_stub__device_kernel_APi, .Lfunc_end0-_Z30__device_stub__device_kernel_APi
	.cfi_endproc
                                        # -- End function
	.globl	_Z30__device_stub__device_kernel_BPi # -- Begin function _Z30__device_stub__device_kernel_BPi
	.type	_Z30__device_stub__device_kernel_BPi,@function
_Z30__device_stub__device_kernel_BPi:   # @_Z30__device_stub__device_kernel_BPi
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$64, %rsp
	.cfi_def_cfa_offset 112
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	24(%rsp), %rax
	movq	%rdi, (%rax)
	movq	%rsp, %rbx
	movq	%rax, (%rbx)
	leaq	48(%rsp), %r14
	leaq	32(%rsp), %r15
	leaq	16(%rsp), %r12
	leaq	8(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z15device_kernel_BPi, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$80, %rsp
	.cfi_adjust_cfa_offset -80
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end1:
	.size	_Z30__device_stub__device_kernel_BPi, .Lfunc_end1-_Z30__device_stub__device_kernel_BPi
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z8walltimev
.LCPI2_0:
	.quad	0x3eb0c6f7a0b5ed8d              # double 9.9999999999999995E-7
	.text
	.globl	_Z8walltimev
	.type	_Z8walltimev,@function
_Z8walltimev:                           # @_Z8walltimev
	.cfi_startproc
# %bb.0:
	pushq	%rax
	.cfi_def_cfa_offset 16
	movl	$_ZZ8walltimevE1t, %edi
	xorl	%esi, %esi
	callq	gettimeofday
	cvtsi2sdq	_ZZ8walltimevE1t(%rip), %xmm1
	cvtsi2sdq	_ZZ8walltimevE1t+8(%rip), %xmm0
	mulsd	.LCPI2_0(%rip), %xmm0
	addsd	%xmm1, %xmm0
	popq	%rax
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end2:
	.size	_Z8walltimev, .Lfunc_end2-_Z8walltimev
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI3_0:
	.quad	0x3eb0c6f7a0b5ed8d              # double 9.9999999999999995E-7
.LCPI3_1:
	.quad	0x408f400000000000              # double 1000
	.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	$2097208, %rsp                  # imm = 0x200038
	.cfi_def_cfa_offset 2097264
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	leaq	48(%rsp), %rax
	leaq	1048624(%rsp), %rcx
	xorl	%edx, %edx
	movl	$2048, %esi                     # imm = 0x800
.LBB3_1:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB3_2 Depth 2
	xorl	%edi, %edi
.LBB3_2:                                #   Parent Loop BB3_1 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	leal	(%rdx,%rdi), %r8d
	movl	%r8d, (%rcx,%rdi,4)
	movl	%r8d, (%rax,%rdi,4)
	incq	%rdi
	cmpq	$512, %rdi                      # imm = 0x200
	jne	.LBB3_2
# %bb.3:                                #   in Loop: Header=BB3_1 Depth=1
	incq	%rdx
	addq	%rsi, %rax
	addq	%rsi, %rcx
	cmpq	$512, %rdx                      # imm = 0x200
	jne	.LBB3_1
# %bb.4:
	xorl	%eax, %eax
	leaq	16(%rsp), %rdi
	movq	%rax, (%rdi)
	movq	%rax, 8(%rsp)
	movl	$1048576, %esi                  # imm = 0x100000
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB3_5
# %bb.7:                                # %_Z9gpuAssert10hipError_tPKcib.exit
	leaq	8(%rsp), %rdi
	movl	$1048576, %esi                  # imm = 0x100000
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB3_8
# %bb.9:                                # %_Z9gpuAssert10hipError_tPKcib.exit46
	movq	16(%rsp), %rdi
	leaq	1048624(%rsp), %rsi
	movl	$1048576, %edx                  # imm = 0x100000
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB3_10
# %bb.11:                               # %_Z9gpuAssert10hipError_tPKcib.exit48
	movq	8(%rsp), %rdi
	leaq	48(%rsp), %rsi
	movl	$1048576, %edx                  # imm = 0x100000
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB3_12
# %bb.13:                               # %_Z9gpuAssert10hipError_tPKcib.exit50
	movabsq	$4294967297, %rbx               # imm = 0x100000001
	leaq	511(%rbx), %r14
	movq	%rbx, %rdi
	movl	$1, %esi
	movq	%r14, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB3_15
# %bb.14:
	movq	16(%rsp), %rdi
	callq	_Z30__device_stub__device_kernel_APi
.LBB3_15:
	movq	%rbx, %rdi
	movl	$1, %esi
	movq	%r14, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB3_17
# %bb.16:
	movq	8(%rsp), %rdi
	callq	_Z30__device_stub__device_kernel_BPi
.LBB3_17:
	movl	$_ZZ8walltimevE1t, %edi
	xorl	%esi, %esi
	callq	gettimeofday
	movq	_ZZ8walltimevE1t(%rip), %rax
	movq	%rax, 32(%rsp)                  # 8-byte Spill
	movl	$100000, %ebp                   # imm = 0x186A0
	movq	_ZZ8walltimevE1t+8(%rip), %rax
	movq	%rax, 24(%rsp)                  # 8-byte Spill
.LBB3_18:                               # =>This Inner Loop Header: Depth=1
	movq	%rbx, %rdi
	movl	$1, %esi
	movq	%r14, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB3_20
# %bb.19:                               #   in Loop: Header=BB3_18 Depth=1
	movq	16(%rsp), %rdi
	callq	_Z30__device_stub__device_kernel_APi
.LBB3_20:                               #   in Loop: Header=BB3_18 Depth=1
	decl	%ebp
	jne	.LBB3_18
# %bb.21:
	movl	$_ZZ8walltimevE1t, %edi
	xorl	%esi, %esi
	callq	gettimeofday
	movq	_ZZ8walltimevE1t(%rip), %r15
	movq	_ZZ8walltimevE1t+8(%rip), %r12
	movl	$_ZZ8walltimevE1t, %edi
	xorl	%esi, %esi
	callq	gettimeofday
	movq	_ZZ8walltimevE1t(%rip), %rax
	movq	%rax, 40(%rsp)                  # 8-byte Spill
	movl	$100000, %r13d                  # imm = 0x186A0
	movq	_ZZ8walltimevE1t+8(%rip), %rbp
.LBB3_22:                               # =>This Inner Loop Header: Depth=1
	movq	%rbx, %rdi
	movl	$1, %esi
	movq	%r14, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB3_24
# %bb.23:                               #   in Loop: Header=BB3_22 Depth=1
	movq	8(%rsp), %rdi
	callq	_Z30__device_stub__device_kernel_BPi
.LBB3_24:                               #   in Loop: Header=BB3_22 Depth=1
	decl	%r13d
	jne	.LBB3_22
# %bb.25:
	movl	$_ZZ8walltimevE1t, %edi
	xorl	%esi, %esi
	callq	gettimeofday
	movq	_ZZ8walltimevE1t(%rip), %r14
	movq	_ZZ8walltimevE1t+8(%rip), %r13
	movq	16(%rsp), %rdi
	callq	hipFree
	testl	%eax, %eax
	jne	.LBB3_26
# %bb.27:                               # %_Z9gpuAssert10hipError_tPKcib.exit52
	movq	8(%rsp), %rdi
	callq	hipFree
	testl	%eax, %eax
	jne	.LBB3_28
# %bb.29:                               # %_Z9gpuAssert10hipError_tPKcib.exit54
	cvtsi2sd	%r12, %xmm0
	movsd	.LCPI3_0(%rip), %xmm1           # xmm1 = mem[0],zero
	mulsd	%xmm1, %xmm0
	cvtsi2sd	%r15, %xmm2
	addsd	%xmm0, %xmm2
	movapd	%xmm2, %xmm3
	xorps	%xmm0, %xmm0
	cvtsi2sdq	24(%rsp), %xmm0         # 8-byte Folded Reload
	xorps	%xmm2, %xmm2
	cvtsi2sdq	32(%rsp), %xmm2         # 8-byte Folded Reload
	mulsd	%xmm1, %xmm0
	addsd	%xmm0, %xmm2
	xorps	%xmm0, %xmm0
	cvtsi2sd	%r13, %xmm0
	subsd	%xmm2, %xmm3
	movsd	%xmm3, 32(%rsp)                 # 8-byte Spill
	mulsd	%xmm1, %xmm0
	xorps	%xmm2, %xmm2
	cvtsi2sd	%r14, %xmm2
	addsd	%xmm0, %xmm2
	xorps	%xmm0, %xmm0
	cvtsi2sd	%rbp, %xmm0
	mulsd	%xmm1, %xmm0
	xorps	%xmm1, %xmm1
	cvtsi2sdq	40(%rsp), %xmm1         # 8-byte Folded Reload
	addsd	%xmm0, %xmm1
	subsd	%xmm1, %xmm2
	movsd	%xmm2, 24(%rsp)                 # 8-byte Spill
	movl	$10, %edi
	callq	putchar@PLT
	movsd	32(%rsp), %xmm0                 # 8-byte Reload
                                        # xmm0 = mem[0],zero
	mulsd	.LCPI3_1(%rip), %xmm0
	movl	$.L.str.2, %edi
	movb	$1, %al
	callq	printf
	movsd	24(%rsp), %xmm0                 # 8-byte Reload
                                        # xmm0 = mem[0],zero
	mulsd	.LCPI3_1(%rip), %xmm0
	movl	$.L.str.3, %edi
	movb	$1, %al
	callq	printf
	movl	$10, %edi
	callq	putchar@PLT
	xorl	%eax, %eax
	addq	$2097208, %rsp                  # imm = 0x200038
	.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
.LBB3_5:
	.cfi_def_cfa_offset 2097264
	movl	%eax, %ebx
	movq	stderr(%rip), %r14
	movl	%eax, %edi
	callq	hipGetErrorName
	movq	%rax, %r15
	movl	%ebx, %edi
	callq	hipGetErrorString
	movl	$.L.str.4, %esi
	movl	$.L.str, %r8d
	movq	%r14, %rdi
	movq	%r15, %rdx
	movq	%rax, %rcx
	movl	$78, %r9d
	jmp	.LBB3_6
.LBB3_8:
	movl	%eax, %ebx
	movq	stderr(%rip), %r14
	movl	%eax, %edi
	callq	hipGetErrorName
	movq	%rax, %r15
	movl	%ebx, %edi
	callq	hipGetErrorString
	movl	$.L.str.4, %esi
	movl	$.L.str, %r8d
	movq	%r14, %rdi
	movq	%r15, %rdx
	movq	%rax, %rcx
	movl	$79, %r9d
	jmp	.LBB3_6
.LBB3_10:
	movl	%eax, %ebx
	movq	stderr(%rip), %r14
	movl	%eax, %edi
	callq	hipGetErrorName
	movq	%rax, %r15
	movl	%ebx, %edi
	callq	hipGetErrorString
	movl	$.L.str.4, %esi
	movl	$.L.str, %r8d
	movq	%r14, %rdi
	movq	%r15, %rdx
	movq	%rax, %rcx
	movl	$82, %r9d
	jmp	.LBB3_6
.LBB3_12:
	movl	%eax, %ebx
	movq	stderr(%rip), %r14
	movl	%eax, %edi
	callq	hipGetErrorName
	movq	%rax, %r15
	movl	%ebx, %edi
	callq	hipGetErrorString
	movl	$.L.str.4, %esi
	movl	$.L.str, %r8d
	movq	%r14, %rdi
	movq	%r15, %rdx
	movq	%rax, %rcx
	movl	$83, %r9d
	jmp	.LBB3_6
.LBB3_26:
	movl	%eax, %ebx
	movq	stderr(%rip), %r14
	movl	%eax, %edi
	callq	hipGetErrorName
	movq	%rax, %r15
	movl	%ebx, %edi
	callq	hipGetErrorString
	movl	$.L.str.4, %esi
	movl	$.L.str, %r8d
	movq	%r14, %rdi
	movq	%r15, %rdx
	movq	%rax, %rcx
	movl	$127, %r9d
	jmp	.LBB3_6
.LBB3_28:
	movl	%eax, %ebx
	movq	stderr(%rip), %r14
	movl	%eax, %edi
	callq	hipGetErrorName
	movq	%rax, %r15
	movl	%ebx, %edi
	callq	hipGetErrorString
	movl	$.L.str.4, %esi
	movl	$.L.str, %r8d
	movq	%r14, %rdi
	movq	%r15, %rdx
	movq	%rax, %rcx
	movl	$128, %r9d
.LBB3_6:
	xorl	%eax, %eax
	callq	fprintf
	movl	%ebx, %edi
	callq	exit
.Lfunc_end3:
	.size	main, .Lfunc_end3-main
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$32, %rsp
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -16
	movq	__hip_gpubin_handle(%rip), %rbx
	testq	%rbx, %rbx
	jne	.LBB4_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB4_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z15device_kernel_APi, %esi
	movl	$.L__unnamed_1, %edx
	movl	$.L__unnamed_1, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z15device_kernel_BPi, %esi
	movl	$.L__unnamed_2, %edx
	movl	$.L__unnamed_2, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$__hip_module_dtor, %edi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_end4:
	.size	__hip_module_ctor, .Lfunc_end4-__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	.LBB5_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
.LBB5_2:
	retq
.Lfunc_end5:
	.size	__hip_module_dtor, .Lfunc_end5-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	_Z15device_kernel_APi,@object   # @_Z15device_kernel_APi
	.section	.rodata,"a",@progbits
	.globl	_Z15device_kernel_APi
	.p2align	3, 0x0
_Z15device_kernel_APi:
	.quad	_Z30__device_stub__device_kernel_APi
	.size	_Z15device_kernel_APi, 8

	.type	_Z15device_kernel_BPi,@object   # @_Z15device_kernel_BPi
	.globl	_Z15device_kernel_BPi
	.p2align	3, 0x0
_Z15device_kernel_BPi:
	.quad	_Z30__device_stub__device_kernel_BPi
	.size	_Z15device_kernel_BPi, 8

	.type	_ZZ8walltimevE1t,@object        # @_ZZ8walltimevE1t
	.local	_ZZ8walltimevE1t
	.comm	_ZZ8walltimevE1t,16,8
	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"/home/ubuntu/Datasets/stackv2/train-structured-repos-hip-sm89/martinty/TDT4200_2019/master/a8/main.hip"
	.size	.L.str, 103

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"Walltime A: %7.3f ms \n"
	.size	.L.str.2, 23

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"Walltime B: %7.3f ms \n"
	.size	.L.str.3, 23

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"GPUassert: %s %s %s %d\n"
	.size	.L.str.4, 24

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

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_Z15device_kernel_BPi"
	.size	.L__unnamed_2, 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

	.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 _Z30__device_stub__device_kernel_APi
	.addrsig_sym _Z30__device_stub__device_kernel_BPi
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z15device_kernel_APi
	.addrsig_sym _Z15device_kernel_BPi
	.addrsig_sym _ZZ8walltimevE1t
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z15device_kernel_APi   ; -- Begin function _Z15device_kernel_APi
	.globl	_Z15device_kernel_APi
	.p2align	8
	.type	_Z15device_kernel_APi,@function
_Z15device_kernel_APi:                  ; @_Z15device_kernel_APi
; %bb.0:
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z15device_kernel_APi
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 8
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 1
		.amdhsa_next_free_sgpr 1
		.amdhsa_reserve_vcc 0
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end0:
	.size	_Z15device_kernel_APi, .Lfunc_end0-_Z15device_kernel_APi
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 4
; NumSgprs: 0
; NumVgprs: 0
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 0
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 1
; NumVGPRsForWavesPerEU: 1
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.protected	_Z15device_kernel_BPi   ; -- Begin function _Z15device_kernel_BPi
	.globl	_Z15device_kernel_BPi
	.p2align	8
	.type	_Z15device_kernel_BPi,@function
_Z15device_kernel_BPi:                  ; @_Z15device_kernel_BPi
; %bb.0:
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z15device_kernel_BPi
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 8
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 1
		.amdhsa_next_free_sgpr 1
		.amdhsa_reserve_vcc 0
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end1:
	.size	_Z15device_kernel_BPi, .Lfunc_end1-_Z15device_kernel_BPi
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 4
; NumSgprs: 0
; NumVgprs: 0
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 0
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 1
; NumVGPRsForWavesPerEU: 1
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

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

	.end_amdgpu_metadata
