#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <fstream>
#include <ctime>
#include <cstdlib>

/*
 * Class: CSCI563 - Introduction to Parallel Computing
 * Student: Zachary Nahman
 * Professor: Dr. Wu
 * Assignment: Course Project for Graduate Students
 * Due Date: 5/6/2018
*/

/*
 * TODO:
 * - take a positive integer N as an argument
 * - create an input integer array of size N
 * - populate the array with integers from the range [1,1000]
 * - sort the array using sequential bubblesort
 * - sort the array using parallel bubblesort
 * - compare sequential bubblesort and parallel bubblesort
*/


// CUDA kernel - even comparisons
__global__ void even_swapper(int *X, int N)
{
    int i = blockIdx.x * blockDim.x + threadIdx.x;
    if(i % 2 == 0 && i < N-1){
        if(X[i+1] < X[i]){
            // switch in the x array
            int temp = X[i];
            X[i] = X[i+1];
            X[i+1] = temp;
        }
    }
}

// CUDA kernel - odd comparisons
__global__ void odd_swapper(int *X, int N)
{
    int i = blockIdx.x * blockDim.x + threadIdx.x;
    if(i % 2 != 0 && i < N-2){
        if(X[i+1] < X[i]){
            // switch in the x array
            int temp = X[i];
            X[i] = X[i+1];
            X[i+1] = temp;
        }
    }
}


int main( int argc, char* argv[] )
{
    int N;
    // get the command line argument N (the size of the array)
    if(argc == 2){
        N = atoi(argv[1]);
    }
    else if(argc == 1){
        std::cout << "No number entered for N - please run with N specified" << "\n";
    }
    else if(argc > 2){
        std::cout << "Too many arguments entered, expected 1 - the array size" << "\n";
    }

    // declare the host input array
    int *h_input_array;
    size_t bytes = N * sizeof(int);
    h_input_array= (int*)malloc(bytes);

    // declare the host output array
    int *h_output_array;
    int *seq_h_output_array;
    h_output_array = (int*)malloc(bytes);
    seq_h_output_array = (int*)malloc(bytes);

    // fill the host input array with integers between [1,1000]
    // seed random number generator
    srand(time(0));

    //std::cout << "Array: " << "\n";
    for(int i = 0; i < N; i++){
         h_input_array[i] = (rand() % 1000) + 1;
         //std::cout << h_input_array[i] << "\n";
    }

    // sequential bubblesort algorithm
    // copy the array to sort
    for(int k = 0; k < N; k++){
         seq_h_output_array[k] = h_input_array[k];
         //std::cout << seq_h_output_array[k] << "\n";
    }
    // sort seq_h_output_array (with bubble sort)
    clock_t seq_begin = clock();
    bool sorted = false;
    while(!sorted){
        bool swapped = false;
        for(int k = 0; k < N-1; k++){
             if(seq_h_output_array[k+1] < seq_h_output_array[k]){
                 int temp = seq_h_output_array[k];
                 seq_h_output_array[k] = seq_h_output_array[k+1];
                 seq_h_output_array[k+1] = temp;
                 swapped = true;
             }
        }
        if(!swapped){
            sorted = true;
        }
    }
    clock_t seq_end = clock();


    // print results of sequential bubble sort for debugging
    // std::cout << "Sequential Array (sorted with bubblesort):" << "\n";
    // for(int k = 0; k < N; k++){
    //      std::cout << seq_h_output_array[k] << "\n";
    // }

    // declare and allocate device memory for arrays
    int *d_input_array;
    int *d_output_array;

    cudaMalloc(&d_input_array, bytes);
    cudaMalloc(&d_output_array, bytes);

    // Copy host input array to device
    cudaMemcpy(d_input_array, h_input_array, bytes, cudaMemcpyHostToDevice);

    int threadsToLaunch = ceil(N/32.0);
    //invoke the kernel functions (both even swapping and odd swapping)
    clock_t par_begin = clock();
    for(int i = 0; i < N;  i++){
        even_swapper<<<threadsToLaunch, 32>>>(d_input_array, N);
        odd_swapper<<<threadsToLaunch, 32>>>(d_input_array, N);
    }
    clock_t par_end = clock();

    // Copy array back to host
    cudaMemcpy(h_output_array, d_input_array, bytes, cudaMemcpyDeviceToHost);

    // printing parallel result for debugging
    // std::cout << "Parallel: " << "\n";
    // for(int k = 0; k < N; k++){
    //      std::cout << h_output_array[k] << "\n";
    // }

    // confirm both arrays are sorted:
    bool seq_sorted = true;
    bool par_sorted = true;
    for(int i = 0; i < N-1;  i++){
        if(h_output_array[i] > h_output_array[i+1]){
            par_sorted = false;
        }
        if(seq_h_output_array[i] > seq_h_output_array[i+1]){
            seq_sorted = false;
        }
    }

    if(seq_sorted){
        std::cout << "The sequential array is sorted properly!" << "\n";
    }else{
        std::cout << "The sequential array is NOT sorted properly!" << "\n";
    }

    if(par_sorted){
        std::cout << "The parallel array is sorted properly!" << "\n";
    }else{
        std::cout << "The parallel array is NOT sorted properly!" << "\n";
    }


    double seq_elapsed_secs = double(seq_end - seq_begin)/CLOCKS_PER_SEC;
    std::cout << "\n";
    std::cout << "Elapsed Time for Sequential Bubblesort: ";
    std::cout << seq_elapsed_secs;
    std::cout << " seconds";
    std::cout << "\n";

    double par_elapsed_secs = double(par_end - par_begin)/CLOCKS_PER_SEC;
    std::cout << "\n";
    std::cout << "Elapsed Time for Parallel Bubblesort: ";
    std::cout << par_elapsed_secs;
    std::cout << " seconds";
    std::cout << "\n";

    // Release device memory
    cudaFree(d_input_array);
    cudaFree(d_output_array);

    // Release host memory
    free(h_input_array);
    free(h_output_array);
    free(seq_h_output_array);

    return 0;
}

	.file	"tmpxft_002078d2_00000000-6_parallel-bubsort.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB3769:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE3769:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z33__device_stub__Z12even_swapperPiiPii
	.type	_Z33__device_stub__Z12even_swapperPiiPii, @function
_Z33__device_stub__Z12even_swapperPiiPii:
.LFB3791:
	.cfi_startproc
	endbr64
	subq	$120, %rsp
	.cfi_def_cfa_offset 128
	movq	%rdi, 8(%rsp)
	leaq	32(%rsp), %rcx
	leaq	24(%rsp), %rdx
	movl	%esi, 4(%rsp)
	leaq	40(%rsp), %rdi
	leaq	52(%rsp), %rsi
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rax
	movl	$1, 48(%rsp)
	movq	%rax, 88(%rsp)
	leaq	4(%rsp), %rax
	movq	%rax, 96(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 40(%rsp)
	movq	%rax, 52(%rsp)
	movl	$1, 60(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L2
	pushq	32(%rsp)
	.cfi_def_cfa_offset 136
	leaq	_Z12even_swapperPii(%rip), %rdi
	pushq	32(%rsp)
	.cfi_def_cfa_offset 144
	movq	68(%rsp), %rcx
	movl	76(%rsp), %r8d
	movq	56(%rsp), %rsi
	movl	64(%rsp), %edx
	leaq	104(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 136
	popq	%rdx
	.cfi_def_cfa_offset 128
.L2:
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	je	.L4
	call	__stack_chk_fail@PLT
.L4:
	addq	$120, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3791:
	.size	_Z33__device_stub__Z12even_swapperPiiPii, .-_Z33__device_stub__Z12even_swapperPiiPii
	.globl	_Z12even_swapperPii
	.type	_Z12even_swapperPii, @function
_Z12even_swapperPii:
.LFB3792:
	.cfi_startproc
	endbr64
	jmp	_Z33__device_stub__Z12even_swapperPiiPii
	.cfi_endproc
.LFE3792:
	.size	_Z12even_swapperPii, .-_Z12even_swapperPii
	.globl	_Z32__device_stub__Z11odd_swapperPiiPii
	.type	_Z32__device_stub__Z11odd_swapperPiiPii, @function
_Z32__device_stub__Z11odd_swapperPiiPii:
.LFB3793:
	.cfi_startproc
	endbr64
	subq	$120, %rsp
	.cfi_def_cfa_offset 128
	movq	%rdi, 8(%rsp)
	leaq	32(%rsp), %rcx
	leaq	24(%rsp), %rdx
	movl	%esi, 4(%rsp)
	leaq	40(%rsp), %rdi
	leaq	52(%rsp), %rsi
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rax
	movl	$1, 48(%rsp)
	movq	%rax, 88(%rsp)
	leaq	4(%rsp), %rax
	movq	%rax, 96(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 40(%rsp)
	movq	%rax, 52(%rsp)
	movl	$1, 60(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L8
	pushq	32(%rsp)
	.cfi_def_cfa_offset 136
	leaq	_Z11odd_swapperPii(%rip), %rdi
	pushq	32(%rsp)
	.cfi_def_cfa_offset 144
	movq	68(%rsp), %rcx
	movl	76(%rsp), %r8d
	movq	56(%rsp), %rsi
	movl	64(%rsp), %edx
	leaq	104(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 136
	popq	%rdx
	.cfi_def_cfa_offset 128
.L8:
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	je	.L10
	call	__stack_chk_fail@PLT
.L10:
	addq	$120, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3793:
	.size	_Z32__device_stub__Z11odd_swapperPiiPii, .-_Z32__device_stub__Z11odd_swapperPiiPii
	.globl	_Z11odd_swapperPii
	.type	_Z11odd_swapperPii, @function
_Z11odd_swapperPii:
.LFB3794:
	.cfi_startproc
	endbr64
	jmp	_Z32__device_stub__Z11odd_swapperPiiPii
	.cfi_endproc
.LFE3794:
	.size	_Z11odd_swapperPii, .-_Z11odd_swapperPii
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"No number entered for N - please run with N specified"
.LC1:
	.string	"\n"
.LC2:
	.string	"Too many arguments entered, expected 1 - the array size"
.LC4:
	.string	"The sequential array is sorted properly!"
.LC5:
	.string	"The sequential array is NOT sorted properly!"
.LC6:
	.string	"The parallel array is sorted properly!"
.LC7:
	.string	"The parallel array is NOT sorted properly!"
.LC9:
	.string	"Elapsed Time for Sequential Bubblesort: "
.LC10:
	.string	" seconds"
.LC11:
	.string	"Elapsed Time for Parallel Bubblesort: "
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB3766:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$104, %rsp
	.cfi_def_cfa_offset 160
	movq	%fs:40, %rax
	movq	%rax, 88(%rsp)
	xorl	%eax, %eax
	cmpl	$2, %edi
	jne	.L14
	movq	8(%rsi), %rdi
	call	atoi@PLT
	movl	%eax, %ebx
	jmp	.L15
.L14:
	leaq	.LC0(%rip), %rsi
	cmpl	$1, %edi
	je	.L44
	cmpl	$2, %edi
	jle	.L15
	leaq	.LC2(%rip), %rsi
.L44:
	leaq	_ZSt4cout(%rip), %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC1(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
.L15:
	movslq	%ebx, %rax
	xorl	%r14d, %r14d
	movl	$1000, %r12d
	salq	$2, %rax
	movq	%rax, %rdi
	movq	%rax, (%rsp)
	call	malloc@PLT
	movq	(%rsp), %rdi
	movq	%rax, %r13
	call	malloc@PLT
	movq	(%rsp), %rdi
	movq	%rax, 8(%rsp)
	call	malloc@PLT
	xorl	%edi, %edi
	movq	%rax, %rbp
	call	time@PLT
	movl	%eax, %edi
	call	srand@PLT
.L19:
	cmpl	%r14d, %ebx
	jle	.L47
	call	rand@PLT
	cltd
	idivl	%r12d
	incl	%edx
	movl	%edx, 0(%r13,%r14,4)
	incq	%r14
	jmp	.L19
.L47:
	xorl	%eax, %eax
.L21:
	cmpl	%eax, %ebx
	jle	.L48
	movl	0(%r13,%rax,4), %edx
	movl	%edx, 0(%rbp,%rax,4)
	incq	%rax
	jmp	.L21
.L48:
	call	clock@PLT
	movq	%rax, 24(%rsp)
	leal	-1(%rbx), %eax
	movl	%eax, 20(%rsp)
.L23:
	xorl	%eax, %eax
	xorl	%edx, %edx
.L27:
	cmpl	%eax, 20(%rsp)
	jle	.L49
	movl	4(%rbp,%rax,4), %esi
	movl	0(%rbp,%rax,4), %ecx
	cmpl	%ecx, %esi
	jge	.L24
	movl	%esi, 0(%rbp,%rax,4)
	movb	$1, %dl
	movl	%ecx, 4(%rbp,%rax,4)
.L24:
	incq	%rax
	jmp	.L27
.L49:
	testb	%dl, %dl
	jne	.L23
	call	clock@PLT
	movq	(%rsp), %rsi
	xorl	%r14d, %r14d
	leaq	48(%rsp), %rdi
	movabsq	$4294967328, %r12
	movq	%rax, 32(%rsp)
	call	cudaMalloc@PLT
	movq	(%rsp), %rsi
	leaq	56(%rsp), %rdi
	call	cudaMalloc@PLT
	movq	(%rsp), %rdx
	movq	48(%rsp), %rdi
	movq	%r13, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	cvtsi2sdl	%ebx, %xmm0
	mulsd	.LC3(%rip), %xmm0
	call	ceil@PLT
	cvttsd2sil	%xmm0, %r15d
	call	clock@PLT
	movq	%rax, 40(%rsp)
.L26:
	cmpl	%r14d, %ebx
	jle	.L50
	movl	%r15d, 64(%rsp)
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movq	%r12, %rdx
	movabsq	$4294967297, %rax
	movl	$1, %ecx
	movq	%r12, 76(%rsp)
	movq	%rax, 68(%rsp)
	movq	64(%rsp), %rdi
	movl	72(%rsp), %esi
	movl	$1, 84(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L28
	movq	48(%rsp), %rdi
	movl	%ebx, %esi
	call	_Z33__device_stub__Z12even_swapperPiiPii
.L28:
	movl	%r15d, 64(%rsp)
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movq	%r12, %rdx
	movabsq	$4294967297, %rax
	movl	$1, %ecx
	movq	%r12, 76(%rsp)
	movq	%rax, 68(%rsp)
	movq	64(%rsp), %rdi
	movl	72(%rsp), %esi
	movl	$1, 84(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L29
	movq	48(%rsp), %rdi
	movl	%ebx, %esi
	call	_Z32__device_stub__Z11odd_swapperPiiPii
.L29:
	incl	%r14d
	jmp	.L26
.L50:
	call	clock@PLT
	movq	(%rsp), %rdx
	movq	48(%rsp), %rsi
	movb	$1, %r15b
	movq	8(%rsp), %rdi
	movl	$2, %ecx
	movq	%rax, %r14
	call	cudaMemcpy@PLT
	xorl	%eax, %eax
	movb	$1, %dl
	xorl	%ecx, %ecx
.L31:
	cmpl	%eax, 20(%rsp)
	jle	.L51
	movq	8(%rsp), %rbx
	movl	4(%rbx,%rax,4), %esi
	cmpl	%esi, (%rbx,%rax,4)
	cmovg	%ecx, %r15d
	movl	4(%rbp,%rax,4), %ebx
	cmpl	%ebx, 0(%rbp,%rax,4)
	cmovg	%ecx, %edx
	incq	%rax
	jmp	.L31
.L51:
	testb	%dl, %dl
	leaq	.LC4(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rbx
	leaq	.LC1(%rip), %r12
	jne	.L45
	leaq	.LC5(%rip), %rsi
.L45:
	movq	%rbx, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%r12, %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC6(%rip), %rsi
	testb	%r15b, %r15b
	jne	.L46
	leaq	.LC7(%rip), %rsi
.L46:
	movq	%rbx, %rdi
	leaq	.LC10(%rip), %r15
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%r12, %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	24(%rsp), %rcx
	movq	%r12, %rsi
	movq	%rbx, %rdi
	movq	32(%rsp), %rax
	subq	%rcx, %rax
	cvtsi2sdq	%rax, %xmm0
	divsd	.LC8(%rip), %xmm0
	movsd	%xmm0, (%rsp)
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC9(%rip), %rsi
	movq	%rbx, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movsd	(%rsp), %xmm0
	movq	%rbx, %rdi
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	movq	%r15, %rsi
	movq	%rbx, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%r12, %rsi
	movq	%rbx, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	40(%rsp), %rax
	movq	%r12, %rsi
	movq	%rbx, %rdi
	subq	%rax, %r14
	cvtsi2sdq	%r14, %xmm0
	divsd	.LC8(%rip), %xmm0
	movsd	%xmm0, (%rsp)
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC11(%rip), %rsi
	movq	%rbx, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movsd	(%rsp), %xmm0
	movq	%rbx, %rdi
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	movq	%r15, %rsi
	movq	%rbx, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%r12, %rsi
	movq	%rbx, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	48(%rsp), %rdi
	call	cudaFree@PLT
	movq	56(%rsp), %rdi
	call	cudaFree@PLT
	movq	%r13, %rdi
	call	free@PLT
	movq	8(%rsp), %rdi
	call	free@PLT
	movq	%rbp, %rdi
	call	free@PLT
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	je	.L39
	call	__stack_chk_fail@PLT
.L39:
	addq	$104, %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
.LFE3766:
	.size	main, .-main
	.section	.rodata.str1.1
.LC12:
	.string	"_Z11odd_swapperPii"
.LC13:
	.string	"_Z12even_swapperPii"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB3796:
	.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	.LC12(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z11odd_swapperPii(%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	.LC13(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z12even_swapperPii(%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
.LFE3796:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC3:
	.long	0
	.long	1067450368
	.align 8
.LC8:
	.long	0
	.long	1093567616
	.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 <stdlib.h>
#include <math.h>
#include <iostream>
#include <fstream>
#include <ctime>
#include <cstdlib>

/*
 * Class: CSCI563 - Introduction to Parallel Computing
 * Student: Zachary Nahman
 * Professor: Dr. Wu
 * Assignment: Course Project for Graduate Students
 * Due Date: 5/6/2018
*/

/*
 * TODO:
 * - take a positive integer N as an argument
 * - create an input integer array of size N
 * - populate the array with integers from the range [1,1000]
 * - sort the array using sequential bubblesort
 * - sort the array using parallel bubblesort
 * - compare sequential bubblesort and parallel bubblesort
*/


// CUDA kernel - even comparisons
__global__ void even_swapper(int *X, int N)
{
    int i = blockIdx.x * blockDim.x + threadIdx.x;
    if(i % 2 == 0 && i < N-1){
        if(X[i+1] < X[i]){
            // switch in the x array
            int temp = X[i];
            X[i] = X[i+1];
            X[i+1] = temp;
        }
    }
}

// CUDA kernel - odd comparisons
__global__ void odd_swapper(int *X, int N)
{
    int i = blockIdx.x * blockDim.x + threadIdx.x;
    if(i % 2 != 0 && i < N-2){
        if(X[i+1] < X[i]){
            // switch in the x array
            int temp = X[i];
            X[i] = X[i+1];
            X[i+1] = temp;
        }
    }
}


int main( int argc, char* argv[] )
{
    int N;
    // get the command line argument N (the size of the array)
    if(argc == 2){
        N = atoi(argv[1]);
    }
    else if(argc == 1){
        std::cout << "No number entered for N - please run with N specified" << "\n";
    }
    else if(argc > 2){
        std::cout << "Too many arguments entered, expected 1 - the array size" << "\n";
    }

    // declare the host input array
    int *h_input_array;
    size_t bytes = N * sizeof(int);
    h_input_array= (int*)malloc(bytes);

    // declare the host output array
    int *h_output_array;
    int *seq_h_output_array;
    h_output_array = (int*)malloc(bytes);
    seq_h_output_array = (int*)malloc(bytes);

    // fill the host input array with integers between [1,1000]
    // seed random number generator
    srand(time(0));

    //std::cout << "Array: " << "\n";
    for(int i = 0; i < N; i++){
         h_input_array[i] = (rand() % 1000) + 1;
         //std::cout << h_input_array[i] << "\n";
    }

    // sequential bubblesort algorithm
    // copy the array to sort
    for(int k = 0; k < N; k++){
         seq_h_output_array[k] = h_input_array[k];
         //std::cout << seq_h_output_array[k] << "\n";
    }
    // sort seq_h_output_array (with bubble sort)
    clock_t seq_begin = clock();
    bool sorted = false;
    while(!sorted){
        bool swapped = false;
        for(int k = 0; k < N-1; k++){
             if(seq_h_output_array[k+1] < seq_h_output_array[k]){
                 int temp = seq_h_output_array[k];
                 seq_h_output_array[k] = seq_h_output_array[k+1];
                 seq_h_output_array[k+1] = temp;
                 swapped = true;
             }
        }
        if(!swapped){
            sorted = true;
        }
    }
    clock_t seq_end = clock();


    // print results of sequential bubble sort for debugging
    // std::cout << "Sequential Array (sorted with bubblesort):" << "\n";
    // for(int k = 0; k < N; k++){
    //      std::cout << seq_h_output_array[k] << "\n";
    // }

    // declare and allocate device memory for arrays
    int *d_input_array;
    int *d_output_array;

    hipMalloc(&d_input_array, bytes);
    hipMalloc(&d_output_array, bytes);

    // Copy host input array to device
    hipMemcpy(d_input_array, h_input_array, bytes, hipMemcpyHostToDevice);

    int threadsToLaunch = ceil(N/32.0);
    //invoke the kernel functions (both even swapping and odd swapping)
    clock_t par_begin = clock();
    for(int i = 0; i < N;  i++){
        even_swapper<<<threadsToLaunch, 32>>>(d_input_array, N);
        odd_swapper<<<threadsToLaunch, 32>>>(d_input_array, N);
    }
    clock_t par_end = clock();

    // Copy array back to host
    hipMemcpy(h_output_array, d_input_array, bytes, hipMemcpyDeviceToHost);

    // printing parallel result for debugging
    // std::cout << "Parallel: " << "\n";
    // for(int k = 0; k < N; k++){
    //      std::cout << h_output_array[k] << "\n";
    // }

    // confirm both arrays are sorted:
    bool seq_sorted = true;
    bool par_sorted = true;
    for(int i = 0; i < N-1;  i++){
        if(h_output_array[i] > h_output_array[i+1]){
            par_sorted = false;
        }
        if(seq_h_output_array[i] > seq_h_output_array[i+1]){
            seq_sorted = false;
        }
    }

    if(seq_sorted){
        std::cout << "The sequential array is sorted properly!" << "\n";
    }else{
        std::cout << "The sequential array is NOT sorted properly!" << "\n";
    }

    if(par_sorted){
        std::cout << "The parallel array is sorted properly!" << "\n";
    }else{
        std::cout << "The parallel array is NOT sorted properly!" << "\n";
    }


    double seq_elapsed_secs = double(seq_end - seq_begin)/CLOCKS_PER_SEC;
    std::cout << "\n";
    std::cout << "Elapsed Time for Sequential Bubblesort: ";
    std::cout << seq_elapsed_secs;
    std::cout << " seconds";
    std::cout << "\n";

    double par_elapsed_secs = double(par_end - par_begin)/CLOCKS_PER_SEC;
    std::cout << "\n";
    std::cout << "Elapsed Time for Parallel Bubblesort: ";
    std::cout << par_elapsed_secs;
    std::cout << " seconds";
    std::cout << "\n";

    // Release device memory
    hipFree(d_input_array);
    hipFree(d_output_array);

    // Release host memory
    free(h_input_array);
    free(h_output_array);
    free(seq_h_output_array);

    return 0;
}

	.text
	.file	"parallel-bubsort.hip"
                                        # Start of file scope inline assembly
	.globl	_ZSt21ios_base_library_initv

                                        # End of file scope inline assembly
	.globl	_Z27__device_stub__even_swapperPii # -- Begin function _Z27__device_stub__even_swapperPii
	.type	_Z27__device_stub__even_swapperPii,@function
_Z27__device_stub__even_swapperPii:     # @_Z27__device_stub__even_swapperPii
	.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	$80, %rsp
	.cfi_def_cfa_offset 128
	.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)
	leaq	4(%rsp), %rcx
	movl	%esi, (%rcx)
	leaq	64(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%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	$_Z12even_swapperPii, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$96, %rsp
	.cfi_adjust_cfa_offset -96
	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	_Z27__device_stub__even_swapperPii, .Lfunc_end0-_Z27__device_stub__even_swapperPii
	.cfi_endproc
                                        # -- End function
	.globl	_Z26__device_stub__odd_swapperPii # -- Begin function _Z26__device_stub__odd_swapperPii
	.type	_Z26__device_stub__odd_swapperPii,@function
_Z26__device_stub__odd_swapperPii:      # @_Z26__device_stub__odd_swapperPii
	.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	$80, %rsp
	.cfi_def_cfa_offset 128
	.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)
	leaq	4(%rsp), %rcx
	movl	%esi, (%rcx)
	leaq	64(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%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	$_Z11odd_swapperPii, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$96, %rsp
	.cfi_adjust_cfa_offset -96
	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	_Z26__device_stub__odd_swapperPii, .Lfunc_end1-_Z26__device_stub__odd_swapperPii
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI2_0:
	.quad	0x3fa0000000000000              # double 0.03125
.LCPI2_1:
	.quad	0x412e848000000000              # double 1.0E+6
	.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	$72, %rsp
	.cfi_def_cfa_offset 128
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	cmpl	$1, %edi
	je	.LBB2_3
# %bb.1:
	cmpl	$2, %edi
	jne	.LBB2_4
# %bb.2:
	movq	8(%rsi), %rdi
	callq	atoi
	movl	%eax, %r13d
	jmp	.LBB2_7
.LBB2_3:
	movl	$_ZSt4cout, %edi
	movl	$.L.str, %esi
	movl	$53, %edx
	jmp	.LBB2_6
.LBB2_4:
                                        # implicit-def: $r13d
	jle	.LBB2_7
# %bb.5:
	movl	$_ZSt4cout, %edi
	movl	$.L.str.2, %esi
	movl	$55, %edx
.LBB2_6:
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	$_ZSt4cout, %edi
	movl	$.L.str.1, %esi
	movl	$1, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
                                        # implicit-def: $r13d
.LBB2_7:
	movslq	%r13d, %rbx
	leaq	(,%rbx,4), %r14
	movq	%r14, %rdi
	callq	malloc
	movq	%rax, %rbp
	movq	%r14, %rdi
	callq	malloc
	movq	%rax, 32(%rsp)                  # 8-byte Spill
	movq	%r14, 8(%rsp)                   # 8-byte Spill
	movq	%r14, %rdi
	callq	malloc
	movq	%rax, %r15
	xorl	%edi, %edi
	callq	time
	movl	%eax, %edi
	callq	srand
	testl	%ebx, %ebx
	jle	.LBB2_12
# %bb.8:                                # %.lr.ph.preheader
	movl	%r13d, %r12d
	xorl	%ebx, %ebx
.LBB2_9:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	callq	rand
	cltq
	imulq	$274877907, %rax, %rcx          # imm = 0x10624DD3
	movq	%rcx, %rdx
	shrq	$63, %rdx
	sarq	$38, %rcx
	addl	%edx, %ecx
	imull	$1000, %ecx, %ecx               # imm = 0x3E8
	negl	%ecx
	addl	%ecx, %eax
	incl	%eax
	movl	%eax, (%rbp,%rbx,4)
	incq	%rbx
	cmpq	%rbx, %r12
	jne	.LBB2_9
# %bb.10:                               # %.preheader109
	testl	%r13d, %r13d
	jle	.LBB2_12
# %bb.11:                               # %.lr.ph112.preheader
	shlq	$2, %r12
	movq	%r15, %rdi
	movq	%rbp, %rsi
	movq	%r12, %rdx
	callq	memcpy@PLT
.LBB2_12:                               # %._crit_edge
	callq	clock
	movq	%rax, 56(%rsp)                  # 8-byte Spill
	leal	-1(%r13), %r14d
	xorl	%eax, %eax
	movl	$1, %ecx
.LBB2_13:                               # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB2_15 Depth 2
	cmpl	$2, %r13d
	jl	.LBB2_20
# %bb.14:                               # %.lr.ph115.preheader
                                        #   in Loop: Header=BB2_13 Depth=1
	movl	(%r15), %esi
	xorl	%edx, %edx
	xorl	%edi, %edi
.LBB2_15:                               # %.lr.ph115
                                        #   Parent Loop BB2_13 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	4(%r15,%rdx,4), %r8d
	cmpl	%esi, %r8d
	jge	.LBB2_16
# %bb.17:                               #   in Loop: Header=BB2_15 Depth=2
	movl	%r8d, (%r15,%rdx,4)
	movl	%esi, 4(%r15,%rdx,4)
	movb	$1, %dil
	jmp	.LBB2_18
.LBB2_16:                               #   in Loop: Header=BB2_15 Depth=2
	movl	%r8d, %esi
.LBB2_18:                               #   in Loop: Header=BB2_15 Depth=2
	incq	%rdx
	cmpq	%rdx, %r14
	jne	.LBB2_15
# %bb.19:                               # %._crit_edge116
                                        #   in Loop: Header=BB2_13 Depth=1
	testb	$1, %dil
	movzbl	%al, %eax
	cmovel	%ecx, %eax
	testb	$1, %al
	je	.LBB2_13
.LBB2_20:                               # %._crit_edge116.thread
	callq	clock
	movq	%rax, 40(%rsp)                  # 8-byte Spill
	leaq	16(%rsp), %r12
	movq	%r12, %rdi
	movq	8(%rsp), %rbx                   # 8-byte Reload
	movq	%rbx, %rsi
	callq	hipMalloc
	leaq	64(%rsp), %rdi
	movq	%rbx, %rsi
	callq	hipMalloc
	movq	(%r12), %rdi
	movq	%rbp, 24(%rsp)                  # 8-byte Spill
	movq	%rbp, %rsi
	movq	%rbx, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	callq	clock
	movq	%rax, 48(%rsp)                  # 8-byte Spill
	testl	%r13d, %r13d
	jle	.LBB2_27
# %bb.21:                               # %.lr.ph120
	movabsq	$4294967328, %r12               # imm = 0x100000020
	cvtsi2sd	%r13d, %xmm0
	mulsd	.LCPI2_0(%rip), %xmm0
	callq	ceil@PLT
	cvttsd2si	%xmm0, %eax
	leaq	(%rax,%r12), %rbp
	addq	$-32, %rbp
	movl	%r13d, %ebx
.LBB2_22:                               # =>This Inner Loop Header: Depth=1
	movq	%rbp, %rdi
	movl	$1, %esi
	movq	%r12, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB2_24
# %bb.23:                               #   in Loop: Header=BB2_22 Depth=1
	movq	16(%rsp), %rdi
	movl	%r13d, %esi
	callq	_Z27__device_stub__even_swapperPii
.LBB2_24:                               #   in Loop: Header=BB2_22 Depth=1
	movq	%rbp, %rdi
	movl	$1, %esi
	movq	%r12, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB2_26
# %bb.25:                               #   in Loop: Header=BB2_22 Depth=1
	movq	16(%rsp), %rdi
	movl	%r13d, %esi
	callq	_Z26__device_stub__odd_swapperPii
.LBB2_26:                               #   in Loop: Header=BB2_22 Depth=1
	decl	%ebx
	jne	.LBB2_22
.LBB2_27:                               # %._crit_edge121
	callq	clock
	movq	%rax, %r12
	movq	16(%rsp), %rsi
	movq	32(%rsp), %rbx                  # 8-byte Reload
	movq	%rbx, %rdi
	movq	8(%rsp), %rdx                   # 8-byte Reload
	movl	$2, %ecx
	callq	hipMemcpy
	cmpl	$2, %r13d
	jl	.LBB2_35
# %bb.28:                               # %.lr.ph126.preheader
	movl	(%rbx), %esi
	movl	(%r15), %ecx
	movb	$1, %bpl
	xorl	%eax, %eax
	xorl	%edi, %edi
	movb	$1, %dl
.LBB2_29:                               # %.lr.ph126
                                        # =>This Inner Loop Header: Depth=1
	movl	4(%rbx,%rdi,4), %r8d
	movl	4(%r15,%rdi,4), %r9d
	leaq	1(%rdi), %r10
	cmpl	%r8d, %esi
	movzbl	%bpl, %ebp
	cmovgl	%eax, %ebp
	cmpl	%r9d, %ecx
	movzbl	%dl, %edx
	cmovgl	%eax, %edx
	movl	%r9d, %ecx
	movl	%r8d, %esi
	movq	%r10, %rdi
	cmpq	%r10, %r14
	jne	.LBB2_29
# %bb.30:                               # %._crit_edge127
	movl	$_ZSt4cout, %edi
	testb	$1, %dl
	jne	.LBB2_34
# %bb.31:
	movl	$.L.str.4, %esi
	movl	$44, %edx
	jmp	.LBB2_32
.LBB2_35:                               # %.critedge
	movl	$_ZSt4cout, %edi
	movl	$.L.str.3, %esi
	movl	$40, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	$_ZSt4cout, %edi
	movl	$.L.str.1, %esi
	movl	$1, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	jmp	.LBB2_36
.LBB2_34:                               # %._crit_edge127.thread
	movl	$.L.str.3, %esi
	movl	$40, %edx
.LBB2_32:
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	$_ZSt4cout, %edi
	movl	$.L.str.1, %esi
	movl	$1, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	testb	$1, %bpl
	jne	.LBB2_36
# %bb.33:
	movl	$_ZSt4cout, %edi
	movl	$.L.str.6, %esi
	movl	$42, %edx
	jmp	.LBB2_37
.LBB2_36:
	movl	$_ZSt4cout, %edi
	movl	$.L.str.5, %esi
	movl	$38, %edx
.LBB2_37:
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	24(%rsp), %rbx                  # 8-byte Reload
	movl	$_ZSt4cout, %edi
	movl	$.L.str.1, %esi
	movl	$1, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	40(%rsp), %rax                  # 8-byte Reload
	subq	56(%rsp), %rax                  # 8-byte Folded Reload
	xorps	%xmm0, %xmm0
	cvtsi2sd	%rax, %xmm0
	divsd	.LCPI2_1(%rip), %xmm0
	movsd	%xmm0, 8(%rsp)                  # 8-byte Spill
	movl	$_ZSt4cout, %edi
	movl	$.L.str.1, %esi
	movl	$1, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	$_ZSt4cout, %edi
	movl	$.L.str.7, %esi
	movl	$40, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	$_ZSt4cout, %edi
	movsd	8(%rsp), %xmm0                  # 8-byte Reload
                                        # xmm0 = mem[0],zero
	callq	_ZNSo9_M_insertIdEERSoT_
	movl	$_ZSt4cout, %edi
	movl	$.L.str.8, %esi
	movl	$8, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	$_ZSt4cout, %edi
	movl	$.L.str.1, %esi
	movl	$1, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	subq	48(%rsp), %r12                  # 8-byte Folded Reload
	xorps	%xmm0, %xmm0
	cvtsi2sd	%r12, %xmm0
	divsd	.LCPI2_1(%rip), %xmm0
	movsd	%xmm0, 8(%rsp)                  # 8-byte Spill
	movl	$_ZSt4cout, %edi
	movl	$.L.str.1, %esi
	movl	$1, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	$_ZSt4cout, %edi
	movl	$.L.str.9, %esi
	movl	$38, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	$_ZSt4cout, %edi
	movsd	8(%rsp), %xmm0                  # 8-byte Reload
                                        # xmm0 = mem[0],zero
	callq	_ZNSo9_M_insertIdEERSoT_
	movl	$_ZSt4cout, %edi
	movl	$.L.str.8, %esi
	movl	$8, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	$_ZSt4cout, %edi
	movl	$.L.str.1, %esi
	movl	$1, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	16(%rsp), %rdi
	callq	hipFree
	movq	64(%rsp), %rdi
	callq	hipFree
	movq	%rbx, %rdi
	callq	free
	movq	32(%rsp), %rdi                  # 8-byte Reload
	callq	free
	movq	%r15, %rdi
	callq	free
	xorl	%eax, %eax
	addq	$72, %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
.Lfunc_end2:
	.size	main, .Lfunc_end2-main
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$32, %rsp
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -16
	movq	__hip_gpubin_handle(%rip), %rbx
	testq	%rbx, %rbx
	jne	.LBB3_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB3_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z12even_swapperPii, %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	$_Z11odd_swapperPii, %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_end3:
	.size	__hip_module_ctor, .Lfunc_end3-__hip_module_ctor
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_dtor
	.type	__hip_module_dtor,@function
__hip_module_dtor:                      # @__hip_module_dtor
	.cfi_startproc
# %bb.0:
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	je	.LBB4_2
# %bb.1:
	pushq	%rax
	.cfi_def_cfa_offset 16
	callq	__hipUnregisterFatBinary
	movq	$0, __hip_gpubin_handle(%rip)
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
.LBB4_2:
	retq
.Lfunc_end4:
	.size	__hip_module_dtor, .Lfunc_end4-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	_Z12even_swapperPii,@object     # @_Z12even_swapperPii
	.section	.rodata,"a",@progbits
	.globl	_Z12even_swapperPii
	.p2align	3, 0x0
_Z12even_swapperPii:
	.quad	_Z27__device_stub__even_swapperPii
	.size	_Z12even_swapperPii, 8

	.type	_Z11odd_swapperPii,@object      # @_Z11odd_swapperPii
	.globl	_Z11odd_swapperPii
	.p2align	3, 0x0
_Z11odd_swapperPii:
	.quad	_Z26__device_stub__odd_swapperPii
	.size	_Z11odd_swapperPii, 8

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"No number entered for N - please run with N specified"
	.size	.L.str, 54

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"\n"
	.size	.L.str.1, 2

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"Too many arguments entered, expected 1 - the array size"
	.size	.L.str.2, 56

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"The sequential array is sorted properly!"
	.size	.L.str.3, 41

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"The sequential array is NOT sorted properly!"
	.size	.L.str.4, 45

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"The parallel array is sorted properly!"
	.size	.L.str.5, 39

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"The parallel array is NOT sorted properly!"
	.size	.L.str.6, 43

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"Elapsed Time for Sequential Bubblesort: "
	.size	.L.str.7, 41

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	" seconds"
	.size	.L.str.8, 9

	.type	.L.str.9,@object                # @.str.9
.L.str.9:
	.asciz	"Elapsed Time for Parallel Bubblesort: "
	.size	.L.str.9, 39

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z12even_swapperPii"
	.size	.L__unnamed_1, 20

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

	.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 _Z27__device_stub__even_swapperPii
	.addrsig_sym _Z26__device_stub__odd_swapperPii
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z12even_swapperPii
	.addrsig_sym _Z11odd_swapperPii
	.addrsig_sym _ZSt4cout
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z12even_swapperPii     ; -- Begin function _Z12even_swapperPii
	.globl	_Z12even_swapperPii
	.p2align	8
	.type	_Z12even_swapperPii,@function
_Z12even_swapperPii:                    ; @_Z12even_swapperPii
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x1c
	s_load_b32 s3, s[0:1], 0x8
	s_waitcnt lgkmcnt(0)
	s_and_b32 s2, s2, 0xffff
	s_add_i32 s3, s3, -1
	v_mad_u64_u32 v[1:2], null, s15, s2, v[0:1]
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_and_b32_e32 v0, 1, v1
	v_cmp_gt_i32_e64 s2, s3, v1
	v_cmp_eq_u32_e32 vcc_lo, 0, v0
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_and_b32 s2, vcc_lo, s2
	s_and_saveexec_b32 s3, s2
	s_cbranch_execz .LBB0_3
; %bb.1:
	s_load_b64 s[0:1], s[0:1], 0x0
	v_or_b32_e32 v3, 1, v1
	v_ashrrev_i32_e32 v2, 31, v1
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_ashrrev_i32_e32 v4, 31, v3
	v_lshlrev_b64 v[5:6], 2, v[1:2]
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[3:4], 2, v[3:4]
	s_waitcnt lgkmcnt(0)
	v_add_co_u32 v0, vcc_lo, s0, v3
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_4)
	v_add_co_ci_u32_e32 v1, vcc_lo, s1, v4, vcc_lo
	v_add_co_u32 v2, vcc_lo, s0, v5
	v_add_co_ci_u32_e32 v3, vcc_lo, s1, v6, vcc_lo
	s_clause 0x1
	global_load_b32 v4, v[0:1], off
	global_load_b32 v5, v[2:3], off
	s_waitcnt vmcnt(0)
	v_cmp_lt_i32_e32 vcc_lo, v4, v5
	s_and_b32 exec_lo, exec_lo, vcc_lo
; %bb.2:
	s_clause 0x1
	global_store_b32 v[2:3], v4, off
	global_store_b32 v[0:1], v5, off
.LBB0_3:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z12even_swapperPii
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 272
		.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 7
		.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	_Z12even_swapperPii, .Lfunc_end0-_Z12even_swapperPii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 220
; NumSgprs: 18
; NumVgprs: 7
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 7
; 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	_Z11odd_swapperPii      ; -- Begin function _Z11odd_swapperPii
	.globl	_Z11odd_swapperPii
	.p2align	8
	.type	_Z11odd_swapperPii,@function
_Z11odd_swapperPii:                     ; @_Z11odd_swapperPii
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x1c
	s_load_b32 s3, s[0:1], 0x8
	s_waitcnt lgkmcnt(0)
	s_and_b32 s2, s2, 0xffff
	s_add_i32 s3, s3, -2
	v_mad_u64_u32 v[1:2], null, s15, s2, v[0:1]
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_and_b32_e32 v0, 1, v1
	v_cmp_gt_i32_e64 s2, s3, v1
	v_cmp_eq_u32_e32 vcc_lo, 1, v0
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_and_b32 s2, vcc_lo, s2
	s_and_saveexec_b32 s3, s2
	s_cbranch_execz .LBB1_3
; %bb.1:
	s_load_b64 s[0:1], s[0:1], 0x0
	v_ashrrev_i32_e32 v2, 31, v1
	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 v0, vcc_lo, s0, v0
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v1, vcc_lo, s1, v1, vcc_lo
	global_load_b64 v[2:3], v[0:1], off
	s_waitcnt vmcnt(0)
	v_cmp_lt_i32_e32 vcc_lo, v3, v2
	s_and_b32 exec_lo, exec_lo, vcc_lo
	s_cbranch_execz .LBB1_3
; %bb.2:
	v_mov_b32_e32 v4, v2
	global_store_b64 v[0:1], v[3:4], off
.LBB1_3:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z11odd_swapperPii
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 272
		.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 5
		.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_end1:
	.size	_Z11odd_swapperPii, .Lfunc_end1-_Z11odd_swapperPii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 172
; NumSgprs: 18
; NumVgprs: 5
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 5
; 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
      - .offset:         8
        .size:           4
        .value_kind:     by_value
      - .offset:         16
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         20
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         24
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         28
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         30
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         32
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         34
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         36
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         38
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         56
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         64
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         80
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 272
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z12even_swapperPii
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z12even_swapperPii.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     7
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .offset:         8
        .size:           4
        .value_kind:     by_value
      - .offset:         16
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         20
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         24
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         28
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         30
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         32
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         34
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         36
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         38
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         56
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         64
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         80
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 272
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z11odd_swapperPii
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z11odd_swapperPii.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     5
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
