#include <stdio.h>
#include <stdint.h>
#include <chrono>


// Constant values.
#define TB_SIZE 256
uint64_t ARRAY_SIZE = 300'000'000;

// Check if the given pointer is NULL.
#define PTR_CHECK(cmd) if ((x) == NULL) { \
    printf("ERROR: null pointer at line %d\n", __LINE__); abort(); }

// Check if the given command has returned an error.
#define CUDA_CHECK(cmd) if ((cmd) != cudaSuccess) { \
    printf("ERROR: cuda error at line %d\n", __LINE__); abort(); }

// Kind of benchmark to do.
enum BenchKind { kBoth, kOnlyCPU, kOnlyGPU };


// Run SAXPY on GPU.
__global__ void SAXPY_gpu(float *x, float *y, float a, uint64_t ARRAY_SIZE)
{
    auto index = blockDim.x * blockIdx.x + threadIdx.x;
    if (index < ARRAY_SIZE)
        y[index] += a * x[index];
}


// Run SAXPY on CPU.
void SAXPY_cpu(float *x, float *y, float a)
{
    for (uint64_t index = 0; index < ARRAY_SIZE; index++)
        y[index] += a * x[index];
}


// Initialize input array.
void initArray(float *array)
{
    for (uint64_t index = 0; index < ARRAY_SIZE; index++)
        array[index] = (float)index / 1.42;
}


// Entry point of the program.
int main(int argc, const char **argv)
{
    // When the program is ran with -h, show usage.
    if (argc == 2 && !strcmp(argv[1], "-h")) {
        printf("Usage: ./exercise_2 [array size] [kind]\n");
        exit(0);
    }

    // Read data from CLI.
    if (argc >= 2) ARRAY_SIZE = atoll(argv[1]);
    printf("Using array size of %llu\n", ARRAY_SIZE);

    BenchKind kind = kBoth;
    if (argc >= 3 && !strcmp(argv[2], "cpu")) kind = kOnlyCPU;
    if (argc >= 3 && !strcmp(argv[2], "gpu")) kind = kOnlyGPU;

    // Allocate data elements.
    float a = 12.f;

    float *x = (float *)malloc(sizeof(float) * ARRAY_SIZE);
    PTR_CHECK(x);

    float *y = (float *)malloc(sizeof(float) * ARRAY_SIZE);
    PTR_CHECK(x);
    

    // Run SAXPY on GPU.
    if (kind != kOnlyCPU) {
        printf("Starting GPU test ...\n");
        initArray(x); initArray(y);

        float *gpux, *gpuy;
        CUDA_CHECK(cudaMalloc(&gpux, sizeof(float) * ARRAY_SIZE));
        CUDA_CHECK(cudaMalloc(&gpuy, sizeof(float) * ARRAY_SIZE));

        auto start = std::chrono::system_clock::now();

        CUDA_CHECK(cudaMemcpy(gpux, x, sizeof(float) * ARRAY_SIZE, cudaMemcpyHostToDevice));
        CUDA_CHECK(cudaMemcpy(gpuy, y, sizeof(float) * ARRAY_SIZE, cudaMemcpyHostToDevice));

        SAXPY_gpu<<<((ARRAY_SIZE + TB_SIZE - 1) / TB_SIZE), TB_SIZE>>>(gpux, gpuy, a, ARRAY_SIZE);
        cudaDeviceSynchronize();
        CUDA_CHECK(cudaMemcpy(y, gpuy, sizeof(float) * ARRAY_SIZE, cudaMemcpyDeviceToHost));

        auto end = std::chrono::system_clock::now();
        int ms = std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
        printf("GPU time: %d ms\n", ms);
    }

    // Run SAXPY on CPU.
    if (kind != kOnlyGPU) {
        printf("Starting CPU test ...\n");
        initArray(x); initArray(y);
        
        auto start2 = std::chrono::system_clock::now();
        SAXPY_cpu(x, y, a);

        auto end2 = std::chrono::system_clock::now();
        int ms2 = std::chrono::duration_cast<std::chrono::milliseconds>(end2 - start2).count();
        printf("CPU time: %d ms\n", ms2);
    }

    printf("Done\n", y[13]);
}

	.file	"tmpxft_0025cd59_00000000-6_exercise_2.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2133:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2133:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z9SAXPY_cpuPfS_f
	.type	_Z9SAXPY_cpuPfS_f, @function
_Z9SAXPY_cpuPfS_f:
.LFB2126:
	.cfi_startproc
	endbr64
	movq	ARRAY_SIZE(%rip), %rdx
	xorl	%eax, %eax
.L3:
	cmpq	%rax, %rdx
	je	.L6
	movss	(%rdi,%rax,4), %xmm1
	mulss	%xmm0, %xmm1
	addss	(%rsi,%rax,4), %xmm1
	movss	%xmm1, (%rsi,%rax,4)
	incq	%rax
	jmp	.L3
.L6:
	ret
	.cfi_endproc
.LFE2126:
	.size	_Z9SAXPY_cpuPfS_f, .-_Z9SAXPY_cpuPfS_f
	.globl	_Z9initArrayPf
	.type	_Z9initArrayPf, @function
_Z9initArrayPf:
.LFB2127:
	.cfi_startproc
	endbr64
	movq	ARRAY_SIZE(%rip), %rdx
	movsd	.LC0(%rip), %xmm1
	xorl	%eax, %eax
.L8:
	cmpq	%rax, %rdx
	je	.L10
	cvtsi2ssq	%rax, %xmm0
	cvtss2sd	%xmm0, %xmm0
	divsd	%xmm1, %xmm0
	cvtsd2ss	%xmm0, %xmm0
	movss	%xmm0, (%rdi,%rax,4)
	incq	%rax
	jmp	.L8
.L10:
	ret
	.cfi_endproc
.LFE2127:
	.size	_Z9initArrayPf, .-_Z9initArrayPf
	.globl	_Z32__device_stub__Z9SAXPY_gpuPfS_fmPfS_fm
	.type	_Z32__device_stub__Z9SAXPY_gpuPfS_fmPfS_fm, @function
_Z32__device_stub__Z9SAXPY_gpuPfS_fmPfS_fm:
.LFB2155:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movq	%rdi, 24(%rsp)
	leaq	48(%rsp), %rcx
	leaq	56(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	68(%rsp), %rsi
	movq	%rdx, (%rsp)
	leaq	40(%rsp), %rdx
	movss	%xmm0, 12(%rsp)
	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	12(%rsp), %rax
	movq	%rax, 120(%rsp)
	movq	%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	.L11
	pushq	48(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z9SAXPY_gpuPfS_fm(%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
.L11:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L13
	call	__stack_chk_fail@PLT
.L13:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2155:
	.size	_Z32__device_stub__Z9SAXPY_gpuPfS_fmPfS_fm, .-_Z32__device_stub__Z9SAXPY_gpuPfS_fmPfS_fm
	.globl	_Z9SAXPY_gpuPfS_fm
	.type	_Z9SAXPY_gpuPfS_fm, @function
_Z9SAXPY_gpuPfS_fm:
.LFB2156:
	.cfi_startproc
	endbr64
	jmp	_Z32__device_stub__Z9SAXPY_gpuPfS_fmPfS_fm
	.cfi_endproc
.LFE2156:
	.size	_Z9SAXPY_gpuPfS_fm, .-_Z9SAXPY_gpuPfS_fm
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC1:
	.string	"-h"
.LC2:
	.string	"Usage: ./exercise_2 [array size] [kind]\n"
.LC3:
	.string	"Using array size of %llu\n"
.LC4:
	.string	"gpu"
.LC5:
	.string	"cpu"
.LC6:
	.string	"ERROR: null pointer at line %d\n"
.LC7:
	.string	"Starting CPU test ...\n"
.LC9:
	.string	"CPU time: %d ms\n"
.LC10:
	.string	"Starting GPU test ...\n"
.LC11:
	.string	"ERROR: cuda error at line %d\n"
.LC12:
	.string	"GPU time: %d ms\n"
.LC13:
	.string	"Done\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2128:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	movl	%edi, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	movq	%rsi, %rbx
	subq	$56, %rsp
	.cfi_def_cfa_offset 96
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	cmpl	$2, %edi
	jne	.L17
	movq	8(%rsi), %rdi
	leaq	.LC1(%rip), %rsi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L18
	movl	$2, %edi
	leaq	.LC2(%rip), %rsi
	call	__printf_chk@PLT
	xorl	%edi, %edi
	call	exit@PLT
.L17:
	cmpl	$1, %edi
	jle	.L19
.L18:
	movq	8(%rbx), %rdi
	call	atoll@PLT
	movq	%rax, ARRAY_SIZE(%rip)
.L19:
	movq	ARRAY_SIZE(%rip), %rdx
	leaq	.LC3(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	xorl	%r12d, %r12d
	call	__printf_chk@PLT
	cmpl	$2, %ebp
	jle	.L20
	movq	16(%rbx), %rbx
	leaq	.LC4(%rip), %rsi
	movl	$2, %r12d
	movq	%rbx, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	je	.L20
	leaq	.LC5(%rip), %rsi
	movq	%rbx, %rdi
	xorl	%r12d, %r12d
	call	strcmp@PLT
	testl	%eax, %eax
	sete	%r12b
.L20:
	movq	ARRAY_SIZE(%rip), %rax
	leaq	0(,%rax,4), %rbx
	movq	%rbx, %rdi
	call	malloc@PLT
	movl	$68, %edx
	leaq	.LC6(%rip), %rsi
	movq	%rax, %rbp
	testq	%rax, %rax
	je	.L36
	movq	%rbx, %rdi
	call	malloc@PLT
	movq	%rax, %rbx
	cmpl	$1, %r12d
	jne	.L22
.L30:
	leaq	.LC7(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	%rbp, %rdi
	call	_Z9initArrayPf
	movq	%rbx, %rdi
	call	_Z9initArrayPf
	call	_ZNSt6chrono3_V212system_clock3nowEv@PLT
	movss	.LC8(%rip), %xmm0
	movq	%rbx, %rsi
	movq	%rbp, %rdi
	movq	%rax, %r12
	call	_Z9SAXPY_cpuPfS_f
	call	_ZNSt6chrono3_V212system_clock3nowEv@PLT
	movl	$1000000, %ecx
	movl	$2, %edi
	leaq	.LC9(%rip), %rsi
	subq	%r12, %rax
	cqto
	idivq	%rcx
	movl	%eax, %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L23
.L22:
	leaq	.LC10(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	%rbp, %rdi
	call	_Z9initArrayPf
	movq	%rbx, %rdi
	call	_Z9initArrayPf
	movq	ARRAY_SIZE(%rip), %rax
	movq	%rsp, %rdi
	leaq	0(,%rax,4), %rsi
	call	cudaMalloc@PLT
	testl	%eax, %eax
	je	.L24
	movl	$80, %edx
.L37:
	leaq	.LC11(%rip), %rsi
.L36:
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	call	abort@PLT
.L24:
	movq	ARRAY_SIZE(%rip), %rax
	leaq	8(%rsp), %rdi
	leaq	0(,%rax,4), %rsi
	call	cudaMalloc@PLT
	movl	$81, %edx
	testl	%eax, %eax
	jne	.L37
	call	_ZNSt6chrono3_V212system_clock3nowEv@PLT
	movq	(%rsp), %rdi
	movl	$1, %ecx
	movq	%rbp, %rsi
	movq	%rax, %r13
	movq	ARRAY_SIZE(%rip), %rax
	leaq	0(,%rax,4), %rdx
	call	cudaMemcpy@PLT
	movl	$85, %edx
	testl	%eax, %eax
	jne	.L37
	movq	ARRAY_SIZE(%rip), %rax
	movq	8(%rsp), %rdi
	movl	$1, %ecx
	movq	%rbx, %rsi
	leaq	0(,%rax,4), %rdx
	call	cudaMemcpy@PLT
	movl	$86, %edx
	testl	%eax, %eax
	jne	.L37
	movl	$16777217, %edx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	$1, %ecx
	movq	ARRAY_SIZE(%rip), %rax
	salq	$8, %rdx
	addq	$255, %rax
	shrq	$8, %rax
	movl	%eax, 16(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 20(%rsp)
	movq	16(%rsp), %rdi
	movl	24(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L28
	movq	ARRAY_SIZE(%rip), %rdx
	movss	.LC8(%rip), %xmm0
	movq	8(%rsp), %rsi
	movq	(%rsp), %rdi
	call	_Z32__device_stub__Z9SAXPY_gpuPfS_fmPfS_fm
.L28:
	call	cudaDeviceSynchronize@PLT
	movq	ARRAY_SIZE(%rip), %rax
	movq	8(%rsp), %rsi
	movq	%rbx, %rdi
	movl	$2, %ecx
	leaq	0(,%rax,4), %rdx
	call	cudaMemcpy@PLT
	movl	$90, %edx
	testl	%eax, %eax
	jne	.L37
	call	_ZNSt6chrono3_V212system_clock3nowEv@PLT
	movl	$1000000, %ecx
	movl	$2, %edi
	leaq	.LC12(%rip), %rsi
	subq	%r13, %rax
	cqto
	idivq	%rcx
	movl	%eax, %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	cmpl	$2, %r12d
	jne	.L30
.L23:
	leaq	.LC13(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	cvtss2sd	52(%rbx), %xmm0
	call	__printf_chk@PLT
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	je	.L31
	call	__stack_chk_fail@PLT
.L31:
	addq	$56, %rsp
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2128:
	.size	main, .-main
	.section	.rodata.str1.1
.LC14:
	.string	"_Z9SAXPY_gpuPfS_fm"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2158:
	.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	.LC14(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z9SAXPY_gpuPfS_fm(%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
.LFE2158:
	.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
	.globl	ARRAY_SIZE
	.data
	.align 8
	.type	ARRAY_SIZE, @object
	.size	ARRAY_SIZE, 8
ARRAY_SIZE:
	.quad	300000000
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC0:
	.long	-343597384
	.long	1073133649
	.section	.rodata.cst4,"aM",@progbits,4
	.align 4
.LC8:
	.long	1094713344
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:


#include <hip/hip_runtime.h>
#include <stdio.h>
#include <stdint.h>
#include <chrono>


// Constant values.
#define TB_SIZE 256
uint64_t ARRAY_SIZE = 300'000'000;

// Check if the given pointer is NULL.
#define PTR_CHECK(cmd) if ((x) == NULL) { \
    printf("ERROR: null pointer at line %d\n", __LINE__); abort(); }

// Check if the given command has returned an error.
#define CUDA_CHECK(cmd) if ((cmd) != hipSuccess) { \
    printf("ERROR: cuda error at line %d\n", __LINE__); abort(); }

// Kind of benchmark to do.
enum BenchKind { kBoth, kOnlyCPU, kOnlyGPU };


// Run SAXPY on GPU.
__global__ void SAXPY_gpu(float *x, float *y, float a, uint64_t ARRAY_SIZE)
{
    auto index = blockDim.x * blockIdx.x + threadIdx.x;
    if (index < ARRAY_SIZE)
        y[index] += a * x[index];
}


// Run SAXPY on CPU.
void SAXPY_cpu(float *x, float *y, float a)
{
    for (uint64_t index = 0; index < ARRAY_SIZE; index++)
        y[index] += a * x[index];
}


// Initialize input array.
void initArray(float *array)
{
    for (uint64_t index = 0; index < ARRAY_SIZE; index++)
        array[index] = (float)index / 1.42;
}


// Entry point of the program.
int main(int argc, const char **argv)
{
    // When the program is ran with -h, show usage.
    if (argc == 2 && !strcmp(argv[1], "-h")) {
        printf("Usage: ./exercise_2 [array size] [kind]\n");
        exit(0);
    }

    // Read data from CLI.
    if (argc >= 2) ARRAY_SIZE = atoll(argv[1]);
    printf("Using array size of %llu\n", ARRAY_SIZE);

    BenchKind kind = kBoth;
    if (argc >= 3 && !strcmp(argv[2], "cpu")) kind = kOnlyCPU;
    if (argc >= 3 && !strcmp(argv[2], "gpu")) kind = kOnlyGPU;

    // Allocate data elements.
    float a = 12.f;

    float *x = (float *)malloc(sizeof(float) * ARRAY_SIZE);
    PTR_CHECK(x);

    float *y = (float *)malloc(sizeof(float) * ARRAY_SIZE);
    PTR_CHECK(x);
    

    // Run SAXPY on GPU.
    if (kind != kOnlyCPU) {
        printf("Starting GPU test ...\n");
        initArray(x); initArray(y);

        float *gpux, *gpuy;
        CUDA_CHECK(hipMalloc(&gpux, sizeof(float) * ARRAY_SIZE));
        CUDA_CHECK(hipMalloc(&gpuy, sizeof(float) * ARRAY_SIZE));

        auto start = std::chrono::system_clock::now();

        CUDA_CHECK(hipMemcpy(gpux, x, sizeof(float) * ARRAY_SIZE, hipMemcpyHostToDevice));
        CUDA_CHECK(hipMemcpy(gpuy, y, sizeof(float) * ARRAY_SIZE, hipMemcpyHostToDevice));

        SAXPY_gpu<<<((ARRAY_SIZE + TB_SIZE - 1) / TB_SIZE), TB_SIZE>>>(gpux, gpuy, a, ARRAY_SIZE);
        hipDeviceSynchronize();
        CUDA_CHECK(hipMemcpy(y, gpuy, sizeof(float) * ARRAY_SIZE, hipMemcpyDeviceToHost));

        auto end = std::chrono::system_clock::now();
        int ms = std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
        printf("GPU time: %d ms\n", ms);
    }

    // Run SAXPY on CPU.
    if (kind != kOnlyGPU) {
        printf("Starting CPU test ...\n");
        initArray(x); initArray(y);
        
        auto start2 = std::chrono::system_clock::now();
        SAXPY_cpu(x, y, a);

        auto end2 = std::chrono::system_clock::now();
        int ms2 = std::chrono::duration_cast<std::chrono::milliseconds>(end2 - start2).count();
        printf("CPU time: %d ms\n", ms2);
    }

    printf("Done\n", y[13]);
}

	.text
	.file	"exercise_2.hip"
	.globl	_Z24__device_stub__SAXPY_gpuPfS_fm # -- Begin function _Z24__device_stub__SAXPY_gpuPfS_fm
	.type	_Z24__device_stub__SAXPY_gpuPfS_fm,@function
_Z24__device_stub__SAXPY_gpuPfS_fm:     # @_Z24__device_stub__SAXPY_gpuPfS_fm
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$112, %rsp
	.cfi_def_cfa_offset 160
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	32(%rsp), %rcx
	movq	%rsi, (%rcx)
	leaq	4(%rsp), %rsi
	movss	%xmm0, (%rsi)
	leaq	24(%rsp), %rdi
	movq	%rdx, (%rdi)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdi, 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	$_Z9SAXPY_gpuPfS_fm, %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__SAXPY_gpuPfS_fm, .Lfunc_end0-_Z24__device_stub__SAXPY_gpuPfS_fm
	.cfi_endproc
                                        # -- End function
	.globl	_Z9SAXPY_cpuPfS_f               # -- Begin function _Z9SAXPY_cpuPfS_f
	.type	_Z9SAXPY_cpuPfS_f,@function
_Z9SAXPY_cpuPfS_f:                      # @_Z9SAXPY_cpuPfS_f
	.cfi_startproc
# %bb.0:
	movq	ARRAY_SIZE(%rip), %rax
	testq	%rax, %rax
	je	.LBB1_3
# %bb.1:                                # %.lr.ph.preheader
	xorl	%ecx, %ecx
.LBB1_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movss	(%rdi,%rcx,4), %xmm1            # xmm1 = mem[0],zero,zero,zero
	mulss	%xmm0, %xmm1
	addss	(%rsi,%rcx,4), %xmm1
	movss	%xmm1, (%rsi,%rcx,4)
	incq	%rcx
	cmpq	%rcx, %rax
	jne	.LBB1_2
.LBB1_3:                                # %._crit_edge
	retq
.Lfunc_end1:
	.size	_Z9SAXPY_cpuPfS_f, .Lfunc_end1-_Z9SAXPY_cpuPfS_f
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z9initArrayPf
.LCPI2_0:
	.quad	0x3ff6b851eb851eb8              # double 1.4199999999999999
	.text
	.globl	_Z9initArrayPf
	.type	_Z9initArrayPf,@function
_Z9initArrayPf:                         # @_Z9initArrayPf
	.cfi_startproc
# %bb.0:
	movq	ARRAY_SIZE(%rip), %rax
	testq	%rax, %rax
	je	.LBB2_6
# %bb.1:                                # %.lr.ph.preheader
	xorl	%ecx, %ecx
	movsd	.LCPI2_0(%rip), %xmm0           # xmm0 = mem[0],zero
.LBB2_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	testq	%rcx, %rcx
	js	.LBB2_3
# %bb.4:                                # %.lr.ph
                                        #   in Loop: Header=BB2_2 Depth=1
	xorps	%xmm1, %xmm1
	cvtsi2ss	%rcx, %xmm1
	jmp	.LBB2_5
.LBB2_3:                                #   in Loop: Header=BB2_2 Depth=1
	movq	%rcx, %rdx
	shrq	%rdx
	movl	%ecx, %esi
	andl	$1, %esi
	orq	%rdx, %rsi
	xorps	%xmm1, %xmm1
	cvtsi2ss	%rsi, %xmm1
	addss	%xmm1, %xmm1
.LBB2_5:                                # %.lr.ph
                                        #   in Loop: Header=BB2_2 Depth=1
	cvtss2sd	%xmm1, %xmm1
	divsd	%xmm0, %xmm1
	cvtsd2ss	%xmm1, %xmm1
	movss	%xmm1, (%rdi,%rcx,4)
	incq	%rcx
	cmpq	%rcx, %rax
	jne	.LBB2_2
.LBB2_6:                                # %._crit_edge
	retq
.Lfunc_end2:
	.size	_Z9initArrayPf, .Lfunc_end2-_Z9initArrayPf
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI3_0:
	.quad	0x3ff6b851eb851eb8              # double 1.4199999999999999
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0
.LCPI3_1:
	.long	0x41400000                      # float 12
	.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	$24, %rsp
	.cfi_def_cfa_offset 80
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rsi, %rbx
	movl	%edi, %ebp
	cmpl	$2, %edi
	jne	.LBB3_3
# %bb.1:
	movq	8(%rbx), %r14
	movl	$.L.str, %esi
	movq	%r14, %rdi
	callq	strcmp
	testl	%eax, %eax
	jne	.LBB3_5
# %bb.2:
	movl	$.Lstr, %edi
	callq	puts@PLT
	xorl	%edi, %edi
	callq	exit
.LBB3_3:
	jl	.LBB3_51
# %bb.4:                                # %..thread_crit_edge
	movq	8(%rbx), %r14
.LBB3_5:                                # %.thread
	movq	%r14, %rdi
	callq	atoll
	movq	%rax, ARRAY_SIZE(%rip)
	xorl	%r13d, %r13d
	movl	$.L.str.2, %edi
	movq	%rax, %rsi
	xorl	%eax, %eax
	callq	printf
	cmpl	$3, %ebp
	jb	.LBB3_7
# %bb.6:
	movq	16(%rbx), %rbx
	movl	$.L.str.3, %esi
	movq	%rbx, %rdi
	callq	strcmp
	xorl	%ebp, %ebp
	testl	%eax, %eax
	sete	%bpl
	movl	$.L.str.4, %esi
	movq	%rbx, %rdi
	callq	strcmp
	testl	%eax, %eax
	movl	$2, %r13d
	cmovnel	%ebp, %r13d
	jmp	.LBB3_7
.LBB3_51:                               # %.thread74
	movq	ARRAY_SIZE(%rip), %rsi
	xorl	%r13d, %r13d
	movl	$.L.str.2, %edi
	xorl	%eax, %eax
	callq	printf
.LBB3_7:                                # %.thread75
	movq	ARRAY_SIZE(%rip), %r14
	shlq	$2, %r14
	movq	%r14, %rdi
	callq	malloc
	testq	%rax, %rax
	je	.LBB3_8
# %bb.10:
	movq	%rax, %rbx
	movq	%r14, %rdi
	callq	malloc
	movq	%rax, %r14
	movabsq	$4835703278458516699, %r12      # imm = 0x431BDE82D7B634DB
	cmpl	$1, %r13d
	je	.LBB3_35
# %bb.11:
	movl	$.Lstr.1, %edi
	callq	puts@PLT
	movq	ARRAY_SIZE(%rip), %rsi
	testq	%rsi, %rsi
	je	.LBB3_22
# %bb.12:                               # %.lr.ph.i.preheader
	xorl	%eax, %eax
	movsd	.LCPI3_0(%rip), %xmm0           # xmm0 = mem[0],zero
.LBB3_13:                               # %.lr.ph.i
                                        # =>This Inner Loop Header: Depth=1
	testq	%rax, %rax
	js	.LBB3_14
# %bb.15:                               # %.lr.ph.i
                                        #   in Loop: Header=BB3_13 Depth=1
	xorps	%xmm1, %xmm1
	cvtsi2ss	%rax, %xmm1
	jmp	.LBB3_16
.LBB3_14:                               #   in Loop: Header=BB3_13 Depth=1
	movq	%rax, %rcx
	shrq	%rcx
	movl	%eax, %edx
	andl	$1, %edx
	orq	%rcx, %rdx
	xorps	%xmm1, %xmm1
	cvtsi2ss	%rdx, %xmm1
	addss	%xmm1, %xmm1
.LBB3_16:                               # %.lr.ph.i
                                        #   in Loop: Header=BB3_13 Depth=1
	cvtss2sd	%xmm1, %xmm1
	divsd	%xmm0, %xmm1
	cvtsd2ss	%xmm1, %xmm1
	movss	%xmm1, (%rbx,%rax,4)
	incq	%rax
	cmpq	%rax, %rsi
	jne	.LBB3_13
# %bb.17:                               # %.lr.ph.i44.preheader
	xorl	%eax, %eax
.LBB3_18:                               # %.lr.ph.i44
                                        # =>This Inner Loop Header: Depth=1
	testq	%rax, %rax
	js	.LBB3_19
# %bb.20:                               # %.lr.ph.i44
                                        #   in Loop: Header=BB3_18 Depth=1
	xorps	%xmm1, %xmm1
	cvtsi2ss	%rax, %xmm1
	jmp	.LBB3_21
.LBB3_19:                               #   in Loop: Header=BB3_18 Depth=1
	movq	%rax, %rcx
	shrq	%rcx
	movl	%eax, %edx
	andl	$1, %edx
	orq	%rcx, %rdx
	xorps	%xmm1, %xmm1
	cvtsi2ss	%rdx, %xmm1
	addss	%xmm1, %xmm1
.LBB3_21:                               # %.lr.ph.i44
                                        #   in Loop: Header=BB3_18 Depth=1
	cvtss2sd	%xmm1, %xmm1
	divsd	%xmm0, %xmm1
	cvtsd2ss	%xmm1, %xmm1
	movss	%xmm1, (%r14,%rax,4)
	incq	%rax
	cmpq	%rax, %rsi
	jne	.LBB3_18
.LBB3_22:                               # %_Z9initArrayPf.exit47
	shlq	$2, %rsi
	leaq	16(%rsp), %rdi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB3_23
# %bb.24:
	movq	ARRAY_SIZE(%rip), %rsi
	shlq	$2, %rsi
	leaq	8(%rsp), %rdi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB3_25
# %bb.26:
	callq	_ZNSt6chrono3_V212system_clock3nowEv
	movq	%rax, %r15
	movq	16(%rsp), %rdi
	movq	ARRAY_SIZE(%rip), %rdx
	shlq	$2, %rdx
	movq	%rbx, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB3_27
# %bb.28:
	movq	8(%rsp), %rdi
	movq	ARRAY_SIZE(%rip), %rdx
	shlq	$2, %rdx
	movq	%r14, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB3_29
# %bb.30:
	movl	$255, %eax
	addq	ARRAY_SIZE(%rip), %rax
	shrq	$8, %rax
	movl	%eax, %edi
	btsq	$32, %rdi
	movabsq	$4294967296, %rdx               # imm = 0x100000000
	orq	$256, %rdx                      # imm = 0x100
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB3_32
# %bb.31:
	movq	16(%rsp), %rdi
	movq	8(%rsp), %rsi
	movq	ARRAY_SIZE(%rip), %rdx
	movss	.LCPI3_1(%rip), %xmm0           # xmm0 = mem[0],zero,zero,zero
	callq	_Z24__device_stub__SAXPY_gpuPfS_fm
.LBB3_32:
	callq	hipDeviceSynchronize
	movq	8(%rsp), %rsi
	movq	ARRAY_SIZE(%rip), %rdx
	shlq	$2, %rdx
	movq	%r14, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB3_33
# %bb.34:
	callq	_ZNSt6chrono3_V212system_clock3nowEv
	subq	%r15, %rax
	imulq	%r12
	movq	%rdx, %rsi
	shrq	$63, %rsi
	shrq	$18, %rdx
	addl	%edx, %esi
	movl	$.L.str.8, %edi
                                        # kill: def $esi killed $esi killed $rsi
	xorl	%eax, %eax
	callq	printf
	cmpl	$2, %r13d
	je	.LBB3_50
.LBB3_35:
	movl	$.Lstr.2, %edi
	callq	puts@PLT
	movq	ARRAY_SIZE(%rip), %rax
	testq	%rax, %rax
	je	.LBB3_46
# %bb.36:                               # %.lr.ph.i49.preheader
	xorl	%ecx, %ecx
	movsd	.LCPI3_0(%rip), %xmm0           # xmm0 = mem[0],zero
.LBB3_37:                               # %.lr.ph.i49
                                        # =>This Inner Loop Header: Depth=1
	testq	%rcx, %rcx
	js	.LBB3_38
# %bb.39:                               # %.lr.ph.i49
                                        #   in Loop: Header=BB3_37 Depth=1
	xorps	%xmm1, %xmm1
	cvtsi2ss	%rcx, %xmm1
	jmp	.LBB3_40
.LBB3_38:                               #   in Loop: Header=BB3_37 Depth=1
	movq	%rcx, %rdx
	shrq	%rdx
	movl	%ecx, %esi
	andl	$1, %esi
	orq	%rdx, %rsi
	xorps	%xmm1, %xmm1
	cvtsi2ss	%rsi, %xmm1
	addss	%xmm1, %xmm1
.LBB3_40:                               # %.lr.ph.i49
                                        #   in Loop: Header=BB3_37 Depth=1
	cvtss2sd	%xmm1, %xmm1
	divsd	%xmm0, %xmm1
	cvtsd2ss	%xmm1, %xmm1
	movss	%xmm1, (%rbx,%rcx,4)
	incq	%rcx
	cmpq	%rcx, %rax
	jne	.LBB3_37
# %bb.41:                               # %.lr.ph.i54.preheader
	xorl	%ecx, %ecx
.LBB3_42:                               # %.lr.ph.i54
                                        # =>This Inner Loop Header: Depth=1
	testq	%rcx, %rcx
	js	.LBB3_43
# %bb.44:                               # %.lr.ph.i54
                                        #   in Loop: Header=BB3_42 Depth=1
	xorps	%xmm1, %xmm1
	cvtsi2ss	%rcx, %xmm1
	jmp	.LBB3_45
.LBB3_43:                               #   in Loop: Header=BB3_42 Depth=1
	movq	%rcx, %rdx
	shrq	%rdx
	movl	%ecx, %esi
	andl	$1, %esi
	orq	%rdx, %rsi
	xorps	%xmm1, %xmm1
	cvtsi2ss	%rsi, %xmm1
	addss	%xmm1, %xmm1
.LBB3_45:                               # %.lr.ph.i54
                                        #   in Loop: Header=BB3_42 Depth=1
	cvtss2sd	%xmm1, %xmm1
	divsd	%xmm0, %xmm1
	cvtsd2ss	%xmm1, %xmm1
	movss	%xmm1, (%r14,%rcx,4)
	incq	%rcx
	cmpq	%rcx, %rax
	jne	.LBB3_42
.LBB3_46:                               # %_Z9initArrayPf.exit57
	callq	_ZNSt6chrono3_V212system_clock3nowEv
	movq	%rax, %r15
	movq	ARRAY_SIZE(%rip), %rax
	testq	%rax, %rax
	je	.LBB3_49
# %bb.47:                               # %.lr.ph.i59.preheader
	xorl	%ecx, %ecx
	movss	.LCPI3_1(%rip), %xmm0           # xmm0 = mem[0],zero,zero,zero
.LBB3_48:                               # %.lr.ph.i59
                                        # =>This Inner Loop Header: Depth=1
	movss	(%rbx,%rcx,4), %xmm1            # xmm1 = mem[0],zero,zero,zero
	mulss	%xmm0, %xmm1
	addss	(%r14,%rcx,4), %xmm1
	movss	%xmm1, (%r14,%rcx,4)
	incq	%rcx
	cmpq	%rcx, %rax
	jne	.LBB3_48
.LBB3_49:                               # %_Z9SAXPY_cpuPfS_f.exit
	callq	_ZNSt6chrono3_V212system_clock3nowEv
	subq	%r15, %rax
	imulq	%r12
	movq	%rdx, %rsi
	shrq	$63, %rsi
	shrq	$18, %rdx
	addl	%edx, %esi
	movl	$.L.str.10, %edi
                                        # kill: def $esi killed $esi killed $rsi
	xorl	%eax, %eax
	callq	printf
.LBB3_50:
	movl	$.Lstr.3, %edi
	callq	puts@PLT
	xorl	%eax, %eax
	addq	$24, %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
.LBB3_8:
	.cfi_def_cfa_offset 80
	movl	$.L.str.5, %edi
	movl	$70, %esi
	jmp	.LBB3_9
.LBB3_23:
	movl	$.L.str.7, %edi
	movl	$82, %esi
	jmp	.LBB3_9
.LBB3_25:
	movl	$.L.str.7, %edi
	movl	$83, %esi
	jmp	.LBB3_9
.LBB3_27:
	movl	$.L.str.7, %edi
	movl	$87, %esi
	jmp	.LBB3_9
.LBB3_29:
	movl	$.L.str.7, %edi
	movl	$88, %esi
	jmp	.LBB3_9
.LBB3_33:
	movl	$.L.str.7, %edi
	movl	$92, %esi
.LBB3_9:
	xorl	%eax, %eax
	callq	printf
	callq	abort
.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:
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	jne	.LBB4_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB4_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z9SAXPY_gpuPfS_fm, %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_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	ARRAY_SIZE,@object              # @ARRAY_SIZE
	.data
	.globl	ARRAY_SIZE
	.p2align	3, 0x0
ARRAY_SIZE:
	.quad	300000000                       # 0x11e1a300
	.size	ARRAY_SIZE, 8

	.type	_Z9SAXPY_gpuPfS_fm,@object      # @_Z9SAXPY_gpuPfS_fm
	.section	.rodata,"a",@progbits
	.globl	_Z9SAXPY_gpuPfS_fm
	.p2align	3, 0x0
_Z9SAXPY_gpuPfS_fm:
	.quad	_Z24__device_stub__SAXPY_gpuPfS_fm
	.size	_Z9SAXPY_gpuPfS_fm, 8

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"-h"
	.size	.L.str, 3

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"Using array size of %llu\n"
	.size	.L.str.2, 26

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"cpu"
	.size	.L.str.3, 4

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"gpu"
	.size	.L.str.4, 4

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"ERROR: null pointer at line %d\n"
	.size	.L.str.5, 32

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"ERROR: cuda error at line %d\n"
	.size	.L.str.7, 30

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"GPU time: %d ms\n"
	.size	.L.str.8, 17

	.type	.L.str.10,@object               # @.str.10
.L.str.10:
	.asciz	"CPU time: %d ms\n"
	.size	.L.str.10, 17

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z9SAXPY_gpuPfS_fm"
	.size	.L__unnamed_1, 19

	.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	"Usage: ./exercise_2 [array size] [kind]"
	.size	.Lstr, 40

	.type	.Lstr.1,@object                 # @str.1
.Lstr.1:
	.asciz	"Starting GPU test ..."
	.size	.Lstr.1, 22

	.type	.Lstr.2,@object                 # @str.2
.Lstr.2:
	.asciz	"Starting CPU test ..."
	.size	.Lstr.2, 22

	.type	.Lstr.3,@object                 # @str.3
.Lstr.3:
	.asciz	"Done"
	.size	.Lstr.3, 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__SAXPY_gpuPfS_fm
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z9SAXPY_gpuPfS_fm
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z9SAXPY_gpuPfS_fm      ; -- Begin function _Z9SAXPY_gpuPfS_fm
	.globl	_Z9SAXPY_gpuPfS_fm
	.p2align	8
	.type	_Z9SAXPY_gpuPfS_fm,@function
_Z9SAXPY_gpuPfS_fm:                     ; @_Z9SAXPY_gpuPfS_fm
; %bb.0:
	s_clause 0x1
	s_load_b32 s4, s[0:1], 0x2c
	s_load_b64 s[2:3], s[0:1], 0x18
	s_waitcnt lgkmcnt(0)
	s_and_b32 s4, s4, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s15, s4, v[0:1]
	v_mov_b32_e32 v2, 0
	v_cmp_gt_u64_e32 vcc_lo, s[2:3], v[1:2]
	s_and_saveexec_b32 s2, vcc_lo
	s_cbranch_execz .LBB0_2
; %bb.1:
	s_load_b128 s[4:7], s[0:1], 0x0
	v_lshlrev_b64 v[0:1], 2, v[1:2]
	s_load_b32 s0, s[0:1], 0x10
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v2, vcc_lo, s4, v0
	v_add_co_ci_u32_e32 v3, vcc_lo, s5, v1, vcc_lo
	v_add_co_u32 v0, vcc_lo, s6, v0
	v_add_co_ci_u32_e32 v1, vcc_lo, s7, v1, vcc_lo
	global_load_b32 v2, v[2:3], off
	global_load_b32 v3, v[0:1], off
	s_waitcnt vmcnt(0)
	v_fmac_f32_e32 v3, s0, v2
	global_store_b32 v[0:1], v3, off
.LBB0_2:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z9SAXPY_gpuPfS_fm
		.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 4
		.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	_Z9SAXPY_gpuPfS_fm, .Lfunc_end0-_Z9SAXPY_gpuPfS_fm
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 160
; NumSgprs: 18
; NumVgprs: 4
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 4
; 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
      - .offset:         16
        .size:           4
        .value_kind:     by_value
      - .offset:         24
        .size:           8
        .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:           _Z9SAXPY_gpuPfS_fm
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z9SAXPY_gpuPfS_fm.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     4
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
