#include <cuda_runtime.h>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#define random(a, b) ((a) + rand() % ((b) - (a) + 1))
#define INF 0x3f3f3f3f3f3f3f3f
#define BLOCK_SIZE 256
#define CHECK(call)                                                           \
    {                                                                         \
        const cudaError_t error = call;                                       \
        if (error != cudaSuccess) {                                           \
            printf("Error: %s:%d, ", __FILE__, __LINE__);                     \
            printf("code:%d, reson: %s\n", error, cudaGetErrorString(error)); \
            exit(-10 * error);                                                \
        }                                                                     \
    }
__host__ void initialize(int h_num_node, int *h_arc, int *h_path_node, int *h_shortLenTable) {
    srand(time(0));
    int idx = 0;
    // 数据输入 并分配内存

    // for (int i = 0; i < h_num_node; ++i) {
    //     for (int j = 0; j < h_num_node; ++j) {
    //         if (i == j)
    //             h_shortLenTable[idx] = h_arc[idx] = 0;
    //         else {
    //             h_arc[idx] = random(1, 1000) / 100.0;
    //             h_shortLenTable[idx] = h_arc[idx];
    //         }
    //     }
    // }
    int Prange = 4;
    for (int i = 0; i < h_num_node; i++) {
        for (int j = 0; j < h_num_node; j++) {
            if (i == j)
                h_shortLenTable[idx] = h_arc[idx] = 0;
            else {
                int pr = rand() % Prange;
                h_shortLenTable[idx] = h_arc[idx] = pr == 0 ? ((rand() % 997) + 1) : INF; //set edge random edge weight to random value, or to INF
            }
            h_path_node[idx] = -1;
            ++idx;
        }
    }
}
__host__ void hostCalShortTable(int h_num_node, int *h_arc, int *h_path_node, int *h_shortLenTable) {
    struct timeval start, end;
    gettimeofday(&start, NULL);
    int idx, idb, ida;
    for (int k = 0; k < h_num_node; ++k) {
        //第k个点的松弛
        for (int i = 0; i < h_num_node; ++i) {
            for (int j = 0; j < h_num_node; ++j) {
                idx = i * h_num_node + j;
                idb = i * h_num_node + k;
                ida = k * h_num_node + j;
                if (h_shortLenTable[idx] >
                    h_shortLenTable[idb] + h_shortLenTable[ida]) {
                    h_shortLenTable[idx] =
                        h_shortLenTable[idb] + h_shortLenTable[ida];
                    h_path_node[idx] = k;
                }
            }
        }
    }
    gettimeofday(&end, NULL);
    printf("CPU Time: %.6lfs\n", end.tv_usec / 1000000.0 + end.tv_sec -
                                     start.tv_usec / 1000000.0 - start.tv_sec);
}
__host__ bool checkResult(int h_num_node, int *h_path_node, int *h_shortLenTable, int *res_path_node, int *res_shortLenTable) {
    int tot = h_num_node * h_num_node;
    int idx = 0, idy = 0;
    for (int i = 0; i < tot; ++i) {
        if (h_path_node[i] != res_path_node[i] || h_shortLenTable[i] != res_shortLenTable[i]) {
            printf("Wrong Answer on %d to %d.\n", idx, idy);
            printf("Host   result: path_node[%d][%d] = %d, shortLenTable[%d][%d] = %.2f.\n", idx, idy, h_path_node[i], idx, idy, h_shortLenTable[i]);
            printf("Device result: path_node[%d][%d] = %d, shortLenTable[%d][%d] = %.2f.\n", idx, idy, res_path_node[i], idx, idy, res_shortLenTable[i]);
            return false;
        }
        ++idx;
        if (idx == h_num_node)
            idx = 0, ++idy;
    }
    puts("The results of GPU and CPU are the same.");
    return true;
}
__global__ void deviceCalBetter(int k, int d_num_node, int *d_path_node, int *d_shortLenTable) {
    int col = blockIdx.x * blockDim.x + threadIdx.x;
    int N = d_num_node;
    if (col >= N)
        return;
    int idx = N * blockIdx.y + col;

    __shared__ int best;
    if (threadIdx.x == 0)
        best = d_shortLenTable[N * blockIdx.y + k];
    __syncthreads();
    if (best == INF)
        return;
    int tmp_b = d_shortLenTable[k * N + col];
    if (tmp_b == INF)
        return;
    int cur = best + tmp_b;
    if (cur < d_shortLenTable[idx]) {
        d_shortLenTable[idx] = cur;
        d_path_node[idx] = k;
    }
}
__global__ void deviceCalShortTable(int k, int *d_num_node, int *d_path_node, int *d_shortLenTable) {
    unsigned int IDX = blockDim.x * blockIdx.x + threadIdx.x;
    __shared__ int N;
    N = *d_num_node;
    if (IDX >= N * N)
        return;
    //cal the i and j
    int i = IDX % N;
    int j = IDX / N;
    int idx = i * N + j;
    int idb = i * N + k;
    int ida = k * N + j;
    if (d_shortLenTable[idx] >
        d_shortLenTable[idb] + d_shortLenTable[ida]) {
        d_shortLenTable[idx] =
            d_shortLenTable[idb] + d_shortLenTable[ida];
        d_path_node[idx] = k;
    }
}
void shortestPath_floyd(int h_num_node, int *h_arc, int *h_path_node, int *h_shortLenTable) {
    int totIntBytes = h_num_node * h_num_node * sizeof(int *);
    int totintBytes = h_num_node * h_num_node * sizeof(int *);
    //设备端变量定义
    int d_num_node = h_num_node;
    int *d_arc;
    int *d_path_node;
    int *d_shortLenTable;

    cudaMalloc((void **)&d_arc, totintBytes);
    cudaMalloc((void **)&d_path_node, totIntBytes);
    cudaMalloc((void **)&d_shortLenTable, totintBytes);

    //Host To Device
    cudaMemcpy(d_arc, h_arc, totintBytes, cudaMemcpyHostToDevice);
    cudaMemcpy(d_path_node, h_path_node, totIntBytes, cudaMemcpyHostToDevice);
    cudaMemcpy(d_shortLenTable, h_shortLenTable, totintBytes, cudaMemcpyHostToDevice);
    // printf("%d %d\n", d_num_node, h_num_node);

    //git
    dim3 dimGrid((h_num_node + BLOCK_SIZE - 1) / BLOCK_SIZE, h_num_node);
    for (int k = 0; k < h_num_node; ++k) {
        deviceCalBetter<<<dimGrid, BLOCK_SIZE>>>(k, d_num_node, d_path_node, d_shortLenTable);
    }
    cudaDeviceSynchronize();

    // //分配任务
    // int calSize = h_num_node * h_num_node;
    // dim3 grid((calSize + BLOCK_SIZE - 1) / BLOCK_SIZE);

    // for (int k = 0; k < h_num_node; ++k) {
    //     deviceCalShortTable<<<grid, BLOCK_SIZE>>>(k, d_num_node, d_path_node, d_shortLenTable);
    // }
    // cudaDeviceSynchronize();

    //record and check the result
    // int *res_path_node;
    // int *res_shortLenTable;
    // res_path_node = (int *)malloc(totIntBytes);
    // res_shortLenTable = (int *)malloc(totintBytes);
    // cudaMemcpy(res_path_node, d_path_node, totIntBytes, cudaMemcpyDeviceToHost);
    // cudaMemcpy(res_shortLenTable, d_shortLenTable, totintBytes, cudaMemcpyDeviceToHost);
    // hostCalShortTable(h_num_node, h_arc, h_path_node, h_shortLenTable);
    // checkResult(h_num_node, h_path_node, h_shortLenTable, res_path_node, res_shortLenTable);
    // free(res_path_node);
    // free(res_shortLenTable);

    cudaFree(d_arc);
    cudaFree(d_path_node);
    cudaFree(d_shortLenTable);
}
__global__ void warmingup(int n) {
    unsigned int IDX = blockDim.x * blockIdx.x + threadIdx.x;
    if (IDX >= n)
        return;
}

int main(int argc, char **argv) {
    printf("%s Starting...\n", argv[0]);

    //get device information
    int dev = 0;
    cudaDeviceProp deviceProp;
    CHECK(cudaGetDeviceProperties(&deviceProp, dev));
    printf("Using Device %d: %s\n", dev, deviceProp.name);
    CHECK(cudaSetDevice(dev));

    //读文件
    //主机变量定义
    int h_num_node;       // 节点个数 70~50000
    int *h_arc;           // 邻接矩阵
    int *h_path_node;     // 最短路径
    int *h_shortLenTable; // 最短路径长度

    h_num_node = 1000;
    int totIntBytes = h_num_node * h_num_node * sizeof(int *);
    int totintBytes = h_num_node * h_num_node * sizeof(int *);
    h_arc = (int *)malloc(totintBytes);
    h_path_node = (int *)malloc(totIntBytes);
    h_shortLenTable = (int *)malloc(totintBytes);

    initialize(h_num_node, h_arc, h_path_node, h_shortLenTable);

    int calSize = h_num_node * h_num_node;
    dim3 grid((calSize + BLOCK_SIZE - 1) / BLOCK_SIZE);
    dim3 block(BLOCK_SIZE);
    warmingup<<<grid, block>>>(32);
    //初始化时间参数
    struct timeval start, end;
    gettimeofday(&start, NULL);
    //calculate on GPU
    shortestPath_floyd(h_num_node, h_arc, h_path_node, h_shortLenTable);
    //输出用时
    gettimeofday(&end, NULL);
    printf("GPU Time: %.6lfs\n", end.tv_usec / 1000000.0 + end.tv_sec -
                                     start.tv_usec / 1000000.0 - start.tv_sec);

    // hostCalShortTable(h_num_node, h_arc, h_path_node, h_shortLenTable);

    //释放内存
    free(h_arc);
    free(h_path_node);
    free(h_shortLenTable);

    cudaDeviceReset();
    return 0;
}
	.file	"tmpxft_0037709c_00000000-6_test.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB3642:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE3642:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z10initializeiPiS_S_
	.type	_Z10initializeiPiS_S_, @function
_Z10initializeiPiS_S_:
.LFB3635:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movslq	%edi, %r15
	xorl	%edi, %edi
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	xorl	%r13d, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	xorl	%ebp, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	%r15, %rbx
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	movq	%rsi, 8(%rsp)
	movq	%rdx, 16(%rsp)
	movq	%rcx, 24(%rsp)
	call	time@PLT
	movl	%eax, %edi
	call	srand@PLT
.L3:
	cmpl	%ebx, %ebp
	jge	.L13
	movslq	%r13d, %r14
	xorl	%r12d, %r12d
.L6:
	xorl	%edx, %edx
	cmpl	%r12d, %ebp
	je	.L4
	call	rand@PLT
	movl	$1061109567, %edx
	testb	$3, %al
	jne	.L4
	call	rand@PLT
	movl	$997, %esi
	cltd
	idivl	%esi
	incl	%edx
.L4:
	movq	8(%rsp), %rax
	incq	%r12
	movl	%edx, (%rax,%r14,4)
	movq	24(%rsp), %rax
	movl	%edx, (%rax,%r14,4)
	movq	16(%rsp), %rax
	movl	$-1, (%rax,%r14,4)
	incq	%r14
	cmpq	%r15, %r12
	jne	.L6
	addl	%ebx, %r13d
	incl	%ebp
	jmp	.L3
.L13:
	addq	$40, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3635:
	.size	_Z10initializeiPiS_S_, .-_Z10initializeiPiS_S_
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC1:
	.string	"CPU Time: %.6lfs\n"
	.text
	.globl	_Z17hostCalShortTableiPiS_S_
	.type	_Z17hostCalShortTableiPiS_S_, @function
_Z17hostCalShortTableiPiS_S_:
.LFB3636:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	xorl	%esi, %esi
	movq	%rdx, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movq	%rcx, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	movl	%edi, %ebx
	subq	$48, %rsp
	.cfi_def_cfa_offset 80
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rdi
	call	gettimeofday@PLT
	movslq	%ebx, %rcx
	movq	%rbp, %r10
	movq	%rbp, %r9
	salq	$2, %rcx
	xorl	%edx, %edx
.L15:
	cmpl	%ebx, %edx
	jge	.L24
	xorl	%edi, %edi
	xorl	%r11d, %r11d
.L19:
	movq	%rdi, %rax
	xorl	%esi, %esi
.L17:
	movl	(%r9,%rsi,4), %r8d
	addl	(%r10,%rdi), %r8d
	cmpl	%r8d, 0(%rbp,%rax)
	jle	.L16
	movl	%r8d, 0(%rbp,%rax)
	movl	%edx, (%r12,%rax)
.L16:
	incq	%rsi
	addq	$4, %rax
	cmpl	%esi, %ebx
	jg	.L17
	incl	%r11d
	addq	%rcx, %rdi
	cmpl	%r11d, %ebx
	jne	.L19
	incl	%edx
	addq	$4, %r10
	addq	%rcx, %r9
	jmp	.L15
.L24:
	xorl	%esi, %esi
	leaq	24(%rsp), %rdi
	call	gettimeofday@PLT
	cvtsi2sdq	32(%rsp), %xmm0
	movb	$1, %al
	movsd	.LC0(%rip), %xmm2
	cvtsi2sdq	24(%rsp), %xmm1
	leaq	.LC1(%rip), %rsi
	movl	$2, %edi
	divsd	%xmm2, %xmm0
	addsd	%xmm1, %xmm0
	cvtsi2sdq	16(%rsp), %xmm1
	divsd	%xmm2, %xmm1
	subsd	%xmm1, %xmm0
	cvtsi2sdq	8(%rsp), %xmm1
	subsd	%xmm1, %xmm0
	call	__printf_chk@PLT
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	je	.L20
	call	__stack_chk_fail@PLT
.L20:
	addq	$48, %rsp
	.cfi_def_cfa_offset 32
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3636:
	.size	_Z17hostCalShortTableiPiS_S_, .-_Z17hostCalShortTableiPiS_S_
	.section	.rodata.str1.1
.LC2:
	.string	"Wrong Answer on %d to %d.\n"
.LC3:
	.string	"Host   result: path_node[%d][%d] = %d, shortLenTable[%d][%d] = %.2f.\n"
.LC4:
	.string	"Device result: path_node[%d][%d] = %d, shortLenTable[%d][%d] = %.2f.\n"
.LC5:
	.string	"The results of GPU and CPU are the same."
	.text
	.globl	_Z11checkResultiPiS_S_S_
	.type	_Z11checkResultiPiS_S_S_, @function
_Z11checkResultiPiS_S_S_:
.LFB3637:
	.cfi_startproc
	endbr64
	movl	%edi, %eax
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movq	%rdx, %r9
	movq	%r8, %r15
	imull	%edi, %eax
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movq	%rcx, %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%rsi, %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	xorl	%r12d, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	cltq
	xorl	%ebp, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	salq	$2, %rax
	xorl	%ebx, %ebx
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
.L26:
	cmpq	%rax, %rbx
	je	.L33
	movl	(%r14,%rbx), %edx
	cmpl	%edx, 0(%r13,%rbx)
	jne	.L27
	movl	(%r15,%rbx), %ecx
	cmpl	%ecx, (%r9,%rbx)
	je	.L28
.L27:
	movl	%r12d, %ecx
	movl	%ebp, %edx
	leaq	.LC2(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	movq	%r9, 8(%rsp)
	call	__printf_chk@PLT
	movq	8(%rsp), %r9
	movl	%r12d, %ecx
	movl	%ebp, %edx
	leaq	.LC3(%rip), %rsi
	movl	$2, %edi
	movl	(%r9,%rbx), %eax
	movl	%ebp, %r9d
	pushq	%rax
	.cfi_def_cfa_offset 88
	xorl	%eax, %eax
	pushq	%r12
	.cfi_def_cfa_offset 96
	movl	0(%r13,%rbx), %r8d
	call	__printf_chk@PLT
	popq	%rax
	.cfi_def_cfa_offset 88
	movl	(%r15,%rbx), %eax
	movl	%r12d, %ecx
	popq	%rdx
	.cfi_def_cfa_offset 80
	leaq	.LC4(%rip), %rsi
	movl	%ebp, %r9d
	movl	%ebp, %edx
	pushq	%rax
	.cfi_def_cfa_offset 88
	movl	$2, %edi
	xorl	%eax, %eax
	pushq	%r12
	.cfi_def_cfa_offset 96
	movl	(%r14,%rbx), %r8d
	call	__printf_chk@PLT
	popq	%rcx
	.cfi_def_cfa_offset 88
	xorl	%eax, %eax
	popq	%rsi
	.cfi_def_cfa_offset 80
	jmp	.L25
.L28:
	incl	%ebp
	cmpl	%ebp, %edi
	jne	.L30
	incl	%r12d
	xorl	%ebp, %ebp
.L30:
	addq	$4, %rbx
	jmp	.L26
.L33:
	leaq	.LC5(%rip), %rdi
	call	puts@PLT
	movb	$1, %al
.L25:
	addq	$24, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3637:
	.size	_Z11checkResultiPiS_S_S_, .-_Z11checkResultiPiS_S_S_
	.globl	_Z39__device_stub__Z15deviceCalBetteriiPiS_iiPiS_
	.type	_Z39__device_stub__Z15deviceCalBetteriiPiS_iiPiS_, @function
_Z39__device_stub__Z15deviceCalBetteriiPiS_iiPiS_:
.LFB3664:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movl	%edi, 28(%rsp)
	leaq	56(%rsp), %rdi
	movl	%esi, 24(%rsp)
	leaq	68(%rsp), %rsi
	movq	%rdx, 16(%rsp)
	leaq	40(%rsp), %rdx
	movq	%rcx, 8(%rsp)
	leaq	48(%rsp), %rcx
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	28(%rsp), %rax
	movl	$1, 64(%rsp)
	movq	%rax, 104(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	8(%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	.L34
	pushq	48(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z15deviceCalBetteriiPiS_(%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
.L34:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L36
	call	__stack_chk_fail@PLT
.L36:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3664:
	.size	_Z39__device_stub__Z15deviceCalBetteriiPiS_iiPiS_, .-_Z39__device_stub__Z15deviceCalBetteriiPiS_iiPiS_
	.globl	_Z15deviceCalBetteriiPiS_
	.type	_Z15deviceCalBetteriiPiS_, @function
_Z15deviceCalBetteriiPiS_:
.LFB3665:
	.cfi_startproc
	endbr64
	jmp	_Z39__device_stub__Z15deviceCalBetteriiPiS_iiPiS_
	.cfi_endproc
.LFE3665:
	.size	_Z15deviceCalBetteriiPiS_, .-_Z15deviceCalBetteriiPiS_
	.globl	_Z18shortestPath_floydiPiS_S_
	.type	_Z18shortestPath_floydiPiS_S_, @function
_Z18shortestPath_floydiPiS_S_:
.LFB3638:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	movq	%rsi, %r14
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	movq	%rdx, %r13
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	movq	%rcx, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	movl	%edi, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	movl	%edi, %ebx
	imull	%edi, %ebx
	subq	$64, %rsp
	.cfi_def_cfa_offset 112
	movq	%fs:40, %rax
	movq	%rax, 56(%rsp)
	xorl	%eax, %eax
	sall	$3, %ebx
	leaq	8(%rsp), %rdi
	movslq	%ebx, %rbx
	movq	%rbx, %rsi
	call	cudaMalloc@PLT
	movq	%rbx, %rsi
	leaq	16(%rsp), %rdi
	call	cudaMalloc@PLT
	movq	%rbx, %rsi
	leaq	24(%rsp), %rdi
	call	cudaMalloc@PLT
	movq	8(%rsp), %rdi
	movq	%rbx, %rdx
	movq	%r14, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movq	16(%rsp), %rdi
	movq	%rbx, %rdx
	movq	%r13, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movq	24(%rsp), %rdi
	movq	%rbx, %rdx
	movq	%r12, %rsi
	movl	$1, %ecx
	xorl	%ebx, %ebx
	movabsq	$4294967552, %r12
	call	cudaMemcpy@PLT
	leal	255(%rbp), %eax
	movl	$256, %ecx
	movl	%ebp, 36(%rsp)
	cltd
	movl	$1, 40(%rsp)
	idivl	%ecx
	movl	%eax, 32(%rsp)
.L40:
	cmpl	%ebp, %ebx
	jge	.L45
	movq	32(%rsp), %rdi
	movl	40(%rsp), %esi
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movq	%r12, %rdx
	movl	$1, %ecx
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L41
	movq	24(%rsp), %rcx
	movq	16(%rsp), %rdx
	movl	%ebp, %esi
	movl	%ebx, %edi
	call	_Z39__device_stub__Z15deviceCalBetteriiPiS_iiPiS_
.L41:
	incl	%ebx
	jmp	.L40
.L45:
	call	cudaDeviceSynchronize@PLT
	movq	8(%rsp), %rdi
	call	cudaFree@PLT
	movq	16(%rsp), %rdi
	call	cudaFree@PLT
	movq	24(%rsp), %rdi
	call	cudaFree@PLT
	movq	56(%rsp), %rax
	subq	%fs:40, %rax
	je	.L43
	call	__stack_chk_fail@PLT
.L43:
	addq	$64, %rsp
	.cfi_def_cfa_offset 48
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3638:
	.size	_Z18shortestPath_floydiPiS_S_, .-_Z18shortestPath_floydiPiS_S_
	.globl	_Z44__device_stub__Z19deviceCalShortTableiPiS_S_iPiS_S_
	.type	_Z44__device_stub__Z19deviceCalShortTableiPiS_S_iPiS_S_, @function
_Z44__device_stub__Z19deviceCalShortTableiPiS_S_iPiS_S_:
.LFB3666:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movl	%edi, 28(%rsp)
	leaq	56(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	68(%rsp), %rsi
	movq	%rdx, 8(%rsp)
	leaq	40(%rsp), %rdx
	movq	%rcx, (%rsp)
	leaq	48(%rsp), %rcx
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	28(%rsp), %rax
	movl	$1, 64(%rsp)
	movq	%rax, 104(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 120(%rsp)
	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	.L46
	pushq	48(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z19deviceCalShortTableiPiS_S_(%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
.L46:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L48
	call	__stack_chk_fail@PLT
.L48:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3666:
	.size	_Z44__device_stub__Z19deviceCalShortTableiPiS_S_iPiS_S_, .-_Z44__device_stub__Z19deviceCalShortTableiPiS_S_iPiS_S_
	.globl	_Z19deviceCalShortTableiPiS_S_
	.type	_Z19deviceCalShortTableiPiS_S_, @function
_Z19deviceCalShortTableiPiS_S_:
.LFB3667:
	.cfi_startproc
	endbr64
	jmp	_Z44__device_stub__Z19deviceCalShortTableiPiS_S_iPiS_S_
	.cfi_endproc
.LFE3667:
	.size	_Z19deviceCalShortTableiPiS_S_, .-_Z19deviceCalShortTableiPiS_S_
	.globl	_Z27__device_stub__Z9warmingupii
	.type	_Z27__device_stub__Z9warmingupii, @function
_Z27__device_stub__Z9warmingupii:
.LFB3668:
	.cfi_startproc
	endbr64
	subq	$104, %rsp
	.cfi_def_cfa_offset 112
	movl	%edi, 12(%rsp)
	leaq	24(%rsp), %rcx
	leaq	16(%rsp), %rdx
	leaq	44(%rsp), %rsi
	leaq	32(%rsp), %rdi
	movq	%fs:40, %rax
	movq	%rax, 88(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %rax
	movl	$1, 40(%rsp)
	movq	%rax, 80(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 32(%rsp)
	movq	%rax, 44(%rsp)
	movl	$1, 52(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L51
	pushq	24(%rsp)
	.cfi_def_cfa_offset 120
	leaq	_Z9warmingupi(%rip), %rdi
	pushq	24(%rsp)
	.cfi_def_cfa_offset 128
	movq	60(%rsp), %rcx
	movl	68(%rsp), %r8d
	movq	48(%rsp), %rsi
	movl	56(%rsp), %edx
	leaq	96(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 120
	popq	%rdx
	.cfi_def_cfa_offset 112
.L51:
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	je	.L53
	call	__stack_chk_fail@PLT
.L53:
	addq	$104, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3668:
	.size	_Z27__device_stub__Z9warmingupii, .-_Z27__device_stub__Z9warmingupii
	.globl	_Z9warmingupi
	.type	_Z9warmingupi, @function
_Z9warmingupi:
.LFB3669:
	.cfi_startproc
	endbr64
	jmp	_Z27__device_stub__Z9warmingupii
	.cfi_endproc
.LFE3669:
	.size	_Z9warmingupi, .-_Z9warmingupi
	.section	.rodata.str1.1
.LC6:
	.string	"%s Starting...\n"
.LC7:
	.string	"/home/ubuntu/Datasets/stackv2/train-structured/hzeroto/CUDA_FLOYD/master/test.cu"
.LC8:
	.string	"Error: %s:%d, "
.LC9:
	.string	"code:%d, reson: %s\n"
.LC10:
	.string	"Using Device %d: %s\n"
.LC11:
	.string	"GPU Time: %.6lfs\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB3639:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movl	$2, %edi
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	subq	$1104, %rsp
	.cfi_def_cfa_offset 1136
	movq	(%rsi), %rdx
	leaq	.LC6(%rip), %rsi
	movq	%fs:40, %rax
	movq	%rax, 1096(%rsp)
	xorl	%eax, %eax
	leaq	64(%rsp), %rbp
	call	__printf_chk@PLT
	xorl	%esi, %esi
	movq	%rbp, %rdi
	call	cudaGetDeviceProperties_v2@PLT
	testl	%eax, %eax
	je	.L57
	movl	%eax, %ebx
	movl	$192, %ecx
	jmp	.L62
.L57:
	movq	%rbp, %rcx
	xorl	%edx, %edx
	leaq	.LC10(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
	xorl	%edi, %edi
	call	cudaSetDevice@PLT
	movl	%eax, %ebx
	testl	%eax, %eax
	je	.L58
	movl	$194, %ecx
.L62:
	leaq	.LC7(%rip), %rdx
	leaq	.LC8(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	%ebx, %edi
	call	cudaGetErrorString@PLT
	movl	$2, %edi
	movl	%ebx, %edx
	leaq	.LC9(%rip), %rsi
	movq	%rax, %rcx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	imull	$-10, %ebx, %edi
	call	exit@PLT
.L58:
	movl	$8000000, %edi
	call	malloc@PLT
	movl	$8000000, %edi
	movq	%rax, %r12
	call	malloc@PLT
	movl	$8000000, %edi
	movq	%rax, %rbp
	call	malloc@PLT
	movq	%rbp, %rdx
	movq	%r12, %rsi
	movl	$1000, %edi
	movq	%rax, %rcx
	movq	%rax, %rbx
	call	_Z10initializeiPiS_S_
	movl	$16777217, %edx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	salq	$8, %rdx
	movl	$1, %ecx
	movl	$1, %esi
	movabsq	$4294971203, %rdi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L59
	movl	$32, %edi
	call	_Z27__device_stub__Z9warmingupii
.L59:
	xorl	%esi, %esi
	leaq	32(%rsp), %rdi
	call	gettimeofday@PLT
	movq	%rbx, %rcx
	movq	%rbp, %rdx
	movq	%r12, %rsi
	movl	$1000, %edi
	call	_Z18shortestPath_floydiPiS_S_
	xorl	%esi, %esi
	leaq	48(%rsp), %rdi
	call	gettimeofday@PLT
	cvtsi2sdq	56(%rsp), %xmm0
	movb	$1, %al
	movsd	.LC0(%rip), %xmm2
	cvtsi2sdq	48(%rsp), %xmm1
	leaq	.LC11(%rip), %rsi
	movl	$2, %edi
	divsd	%xmm2, %xmm0
	addsd	%xmm1, %xmm0
	cvtsi2sdq	40(%rsp), %xmm1
	divsd	%xmm2, %xmm1
	subsd	%xmm1, %xmm0
	cvtsi2sdq	32(%rsp), %xmm1
	subsd	%xmm1, %xmm0
	call	__printf_chk@PLT
	movq	%r12, %rdi
	call	free@PLT
	movq	%rbp, %rdi
	call	free@PLT
	movq	%rbx, %rdi
	call	free@PLT
	call	cudaDeviceReset@PLT
	movq	1096(%rsp), %rax
	subq	%fs:40, %rax
	je	.L60
	call	__stack_chk_fail@PLT
.L60:
	addq	$1104, %rsp
	.cfi_def_cfa_offset 32
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3639:
	.size	main, .-main
	.section	.rodata.str1.1
.LC12:
	.string	"_Z9warmingupi"
.LC13:
	.string	"_Z19deviceCalShortTableiPiS_S_"
.LC14:
	.string	"_Z15deviceCalBetteriiPiS_"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB3671:
	.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	_Z9warmingupi(%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	_Z19deviceCalShortTableiPiS_S_(%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
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r9d, %r9d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC14(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z15deviceCalBetteriiPiS_(%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
.LFE3671:
	.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
.LC0:
	.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 <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#define random(a, b) ((a) + rand() % ((b) - (a) + 1))
#define INF 0x3f3f3f3f3f3f3f3f
#define BLOCK_SIZE 256
#define CHECK(call)                                                           \
    {                                                                         \
        const hipError_t error = call;                                       \
        if (error != hipSuccess) {                                           \
            printf("Error: %s:%d, ", __FILE__, __LINE__);                     \
            printf("code:%d, reson: %s\n", error, hipGetErrorString(error)); \
            exit(-10 * error);                                                \
        }                                                                     \
    }
__host__ void initialize(int h_num_node, int *h_arc, int *h_path_node, int *h_shortLenTable) {
    srand(time(0));
    int idx = 0;
    // 数据输入 并分配内存

    // for (int i = 0; i < h_num_node; ++i) {
    //     for (int j = 0; j < h_num_node; ++j) {
    //         if (i == j)
    //             h_shortLenTable[idx] = h_arc[idx] = 0;
    //         else {
    //             h_arc[idx] = random(1, 1000) / 100.0;
    //             h_shortLenTable[idx] = h_arc[idx];
    //         }
    //     }
    // }
    int Prange = 4;
    for (int i = 0; i < h_num_node; i++) {
        for (int j = 0; j < h_num_node; j++) {
            if (i == j)
                h_shortLenTable[idx] = h_arc[idx] = 0;
            else {
                int pr = rand() % Prange;
                h_shortLenTable[idx] = h_arc[idx] = pr == 0 ? ((rand() % 997) + 1) : INF; //set edge random edge weight to random value, or to INF
            }
            h_path_node[idx] = -1;
            ++idx;
        }
    }
}
__host__ void hostCalShortTable(int h_num_node, int *h_arc, int *h_path_node, int *h_shortLenTable) {
    struct timeval start, end;
    gettimeofday(&start, NULL);
    int idx, idb, ida;
    for (int k = 0; k < h_num_node; ++k) {
        //第k个点的松弛
        for (int i = 0; i < h_num_node; ++i) {
            for (int j = 0; j < h_num_node; ++j) {
                idx = i * h_num_node + j;
                idb = i * h_num_node + k;
                ida = k * h_num_node + j;
                if (h_shortLenTable[idx] >
                    h_shortLenTable[idb] + h_shortLenTable[ida]) {
                    h_shortLenTable[idx] =
                        h_shortLenTable[idb] + h_shortLenTable[ida];
                    h_path_node[idx] = k;
                }
            }
        }
    }
    gettimeofday(&end, NULL);
    printf("CPU Time: %.6lfs\n", end.tv_usec / 1000000.0 + end.tv_sec -
                                     start.tv_usec / 1000000.0 - start.tv_sec);
}
__host__ bool checkResult(int h_num_node, int *h_path_node, int *h_shortLenTable, int *res_path_node, int *res_shortLenTable) {
    int tot = h_num_node * h_num_node;
    int idx = 0, idy = 0;
    for (int i = 0; i < tot; ++i) {
        if (h_path_node[i] != res_path_node[i] || h_shortLenTable[i] != res_shortLenTable[i]) {
            printf("Wrong Answer on %d to %d.\n", idx, idy);
            printf("Host   result: path_node[%d][%d] = %d, shortLenTable[%d][%d] = %.2f.\n", idx, idy, h_path_node[i], idx, idy, h_shortLenTable[i]);
            printf("Device result: path_node[%d][%d] = %d, shortLenTable[%d][%d] = %.2f.\n", idx, idy, res_path_node[i], idx, idy, res_shortLenTable[i]);
            return false;
        }
        ++idx;
        if (idx == h_num_node)
            idx = 0, ++idy;
    }
    puts("The results of GPU and CPU are the same.");
    return true;
}
__global__ void deviceCalBetter(int k, int d_num_node, int *d_path_node, int *d_shortLenTable) {
    int col = blockIdx.x * blockDim.x + threadIdx.x;
    int N = d_num_node;
    if (col >= N)
        return;
    int idx = N * blockIdx.y + col;

    __shared__ int best;
    if (threadIdx.x == 0)
        best = d_shortLenTable[N * blockIdx.y + k];
    __syncthreads();
    if (best == INF)
        return;
    int tmp_b = d_shortLenTable[k * N + col];
    if (tmp_b == INF)
        return;
    int cur = best + tmp_b;
    if (cur < d_shortLenTable[idx]) {
        d_shortLenTable[idx] = cur;
        d_path_node[idx] = k;
    }
}
__global__ void deviceCalShortTable(int k, int *d_num_node, int *d_path_node, int *d_shortLenTable) {
    unsigned int IDX = blockDim.x * blockIdx.x + threadIdx.x;
    __shared__ int N;
    N = *d_num_node;
    if (IDX >= N * N)
        return;
    //cal the i and j
    int i = IDX % N;
    int j = IDX / N;
    int idx = i * N + j;
    int idb = i * N + k;
    int ida = k * N + j;
    if (d_shortLenTable[idx] >
        d_shortLenTable[idb] + d_shortLenTable[ida]) {
        d_shortLenTable[idx] =
            d_shortLenTable[idb] + d_shortLenTable[ida];
        d_path_node[idx] = k;
    }
}
void shortestPath_floyd(int h_num_node, int *h_arc, int *h_path_node, int *h_shortLenTable) {
    int totIntBytes = h_num_node * h_num_node * sizeof(int *);
    int totintBytes = h_num_node * h_num_node * sizeof(int *);
    //设备端变量定义
    int d_num_node = h_num_node;
    int *d_arc;
    int *d_path_node;
    int *d_shortLenTable;

    hipMalloc((void **)&d_arc, totintBytes);
    hipMalloc((void **)&d_path_node, totIntBytes);
    hipMalloc((void **)&d_shortLenTable, totintBytes);

    //Host To Device
    hipMemcpy(d_arc, h_arc, totintBytes, hipMemcpyHostToDevice);
    hipMemcpy(d_path_node, h_path_node, totIntBytes, hipMemcpyHostToDevice);
    hipMemcpy(d_shortLenTable, h_shortLenTable, totintBytes, hipMemcpyHostToDevice);
    // printf("%d %d\n", d_num_node, h_num_node);

    //git
    dim3 dimGrid((h_num_node + BLOCK_SIZE - 1) / BLOCK_SIZE, h_num_node);
    for (int k = 0; k < h_num_node; ++k) {
        deviceCalBetter<<<dimGrid, BLOCK_SIZE>>>(k, d_num_node, d_path_node, d_shortLenTable);
    }
    hipDeviceSynchronize();

    // //分配任务
    // int calSize = h_num_node * h_num_node;
    // dim3 grid((calSize + BLOCK_SIZE - 1) / BLOCK_SIZE);

    // for (int k = 0; k < h_num_node; ++k) {
    //     deviceCalShortTable<<<grid, BLOCK_SIZE>>>(k, d_num_node, d_path_node, d_shortLenTable);
    // }
    // cudaDeviceSynchronize();

    //record and check the result
    // int *res_path_node;
    // int *res_shortLenTable;
    // res_path_node = (int *)malloc(totIntBytes);
    // res_shortLenTable = (int *)malloc(totintBytes);
    // cudaMemcpy(res_path_node, d_path_node, totIntBytes, cudaMemcpyDeviceToHost);
    // cudaMemcpy(res_shortLenTable, d_shortLenTable, totintBytes, cudaMemcpyDeviceToHost);
    // hostCalShortTable(h_num_node, h_arc, h_path_node, h_shortLenTable);
    // checkResult(h_num_node, h_path_node, h_shortLenTable, res_path_node, res_shortLenTable);
    // free(res_path_node);
    // free(res_shortLenTable);

    hipFree(d_arc);
    hipFree(d_path_node);
    hipFree(d_shortLenTable);
}
__global__ void warmingup(int n) {
    unsigned int IDX = blockDim.x * blockIdx.x + threadIdx.x;
    if (IDX >= n)
        return;
}

int main(int argc, char **argv) {
    printf("%s Starting...\n", argv[0]);

    //get device information
    int dev = 0;
    hipDeviceProp_t deviceProp;
    CHECK(hipGetDeviceProperties(&deviceProp, dev));
    printf("Using Device %d: %s\n", dev, deviceProp.name);
    CHECK(hipSetDevice(dev));

    //读文件
    //主机变量定义
    int h_num_node;       // 节点个数 70~50000
    int *h_arc;           // 邻接矩阵
    int *h_path_node;     // 最短路径
    int *h_shortLenTable; // 最短路径长度

    h_num_node = 1000;
    int totIntBytes = h_num_node * h_num_node * sizeof(int *);
    int totintBytes = h_num_node * h_num_node * sizeof(int *);
    h_arc = (int *)malloc(totintBytes);
    h_path_node = (int *)malloc(totIntBytes);
    h_shortLenTable = (int *)malloc(totintBytes);

    initialize(h_num_node, h_arc, h_path_node, h_shortLenTable);

    int calSize = h_num_node * h_num_node;
    dim3 grid((calSize + BLOCK_SIZE - 1) / BLOCK_SIZE);
    dim3 block(BLOCK_SIZE);
    warmingup<<<grid, block>>>(32);
    //初始化时间参数
    struct timeval start, end;
    gettimeofday(&start, NULL);
    //calculate on GPU
    shortestPath_floyd(h_num_node, h_arc, h_path_node, h_shortLenTable);
    //输出用时
    gettimeofday(&end, NULL);
    printf("GPU Time: %.6lfs\n", end.tv_usec / 1000000.0 + end.tv_sec -
                                     start.tv_usec / 1000000.0 - start.tv_sec);

    // hostCalShortTable(h_num_node, h_arc, h_path_node, h_shortLenTable);

    //释放内存
    free(h_arc);
    free(h_path_node);
    free(h_shortLenTable);

    hipDeviceReset();
    return 0;
}
	.text
	.file	"test.hip"
                                        # Start of file scope inline assembly
	.globl	_ZSt21ios_base_library_initv

                                        # End of file scope inline assembly
	.globl	_Z10initializeiPiS_S_           # -- Begin function _Z10initializeiPiS_S_
	.type	_Z10initializeiPiS_S_,@function
_Z10initializeiPiS_S_:                  # @_Z10initializeiPiS_S_
	.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
	pushq	%rax
	.cfi_def_cfa_offset 64
	.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	%rcx, (%rsp)                    # 8-byte Spill
	movq	%rdx, %r14
	movq	%rsi, %r15
	movl	%edi, %ebp
	xorl	%r12d, %r12d
	xorl	%edi, %edi
	callq	time
	movl	%eax, %edi
	callq	srand
	testl	%ebp, %ebp
	jle	.LBB0_8
# %bb.1:                                # %.lr.ph.preheader.preheader
	xorl	%r13d, %r13d
.LBB0_2:                                # %.lr.ph.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB0_3 Depth 2
	movslq	%r13d, %r13
	xorl	%ebx, %ebx
.LBB0_3:                                # %.lr.ph
                                        #   Parent Loop BB0_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	$0, %ecx
	cmpl	%ebx, %r12d
	je	.LBB0_6
# %bb.4:                                #   in Loop: Header=BB0_3 Depth=2
	callq	rand
	movl	$1061109567, %ecx               # imm = 0x3F3F3F3F
	testb	$3, %al
	jne	.LBB0_6
# %bb.5:                                #   in Loop: Header=BB0_3 Depth=2
	callq	rand
	cltq
	imulq	$-2089327119, %rax, %rcx        # imm = 0x837765F1
	shrq	$32, %rcx
	addl	%eax, %ecx
	movl	%ecx, %edx
	shrl	$31, %edx
	sarl	$9, %ecx
	addl	%edx, %ecx
	imull	$997, %ecx, %ecx                # imm = 0x3E5
	negl	%ecx
	addl	%eax, %ecx
	incl	%ecx
.LBB0_6:                                #   in Loop: Header=BB0_3 Depth=2
	movl	%ecx, (%r15,%r13,4)
	movq	(%rsp), %rax                    # 8-byte Reload
	movl	%ecx, (%rax,%r13,4)
	movl	$-1, (%r14,%r13,4)
	incq	%r13
	incl	%ebx
	cmpl	%ebx, %ebp
	jne	.LBB0_3
# %bb.7:                                # %._crit_edge
                                        #   in Loop: Header=BB0_2 Depth=1
	incl	%r12d
	cmpl	%ebp, %r12d
	jne	.LBB0_2
.LBB0_8:                                # %._crit_edge27
	addq	$8, %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_end0:
	.size	_Z10initializeiPiS_S_, .Lfunc_end0-_Z10initializeiPiS_S_
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z17hostCalShortTableiPiS_S_
.LCPI1_0:
	.quad	0x412e848000000000              # double 1.0E+6
	.text
	.globl	_Z17hostCalShortTableiPiS_S_
	.type	_Z17hostCalShortTableiPiS_S_,@function
_Z17hostCalShortTableiPiS_S_:           # @_Z17hostCalShortTableiPiS_S_
	.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	$40, %rsp
	.cfi_def_cfa_offset 96
	.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	%rcx, %rbx
	movq	%rdx, %r14
	movl	%edi, %ebp
	xorl	%r15d, %r15d
	leaq	8(%rsp), %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	testl	%ebp, %ebp
	jle	.LBB1_9
# %bb.1:                                # %.preheader36.lr.ph
	movl	%ebp, %eax
	xorl	%ecx, %ecx
.LBB1_2:                                # %.preheader.lr.ph
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_3 Depth 2
                                        #       Child Loop BB1_4 Depth 3
	movl	%r15d, %edx
	leaq	(%rbx,%rdx,4), %rdx
	leaq	(%rbx,%rcx,4), %rsi
	xorl	%edi, %edi
	xorl	%r8d, %r8d
.LBB1_3:                                # %.preheader
                                        #   Parent Loop BB1_2 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB1_4 Depth 3
	movl	%edi, %r10d
	leaq	(%r14,%r10,4), %r9
	leaq	(%rbx,%r10,4), %r10
	movq	%r8, %r11
	imulq	%rax, %r11
	xorl	%r12d, %r12d
.LBB1_4:                                #   Parent Loop BB1_2 Depth=1
                                        #     Parent Loop BB1_3 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	movl	(%rdx,%r12,4), %r13d
	addl	(%rsi,%r11,4), %r13d
	cmpl	%r13d, (%r10,%r12,4)
	jle	.LBB1_6
# %bb.5:                                #   in Loop: Header=BB1_4 Depth=3
	movl	%r13d, (%r10,%r12,4)
	movl	%ecx, (%r9,%r12,4)
.LBB1_6:                                #   in Loop: Header=BB1_4 Depth=3
	incq	%r12
	cmpq	%r12, %rax
	jne	.LBB1_4
# %bb.7:                                # %._crit_edge
                                        #   in Loop: Header=BB1_3 Depth=2
	incq	%r8
	addl	%ebp, %edi
	cmpq	%rax, %r8
	jne	.LBB1_3
# %bb.8:                                # %._crit_edge39
                                        #   in Loop: Header=BB1_2 Depth=1
	incq	%rcx
	addl	%ebp, %r15d
	cmpq	%rax, %rcx
	jne	.LBB1_2
.LBB1_9:                                # %._crit_edge41
	leaq	24(%rsp), %rbx
	movq	%rbx, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	cvtsi2sdq	8(%rbx), %xmm1
	movsd	.LCPI1_0(%rip), %xmm2           # xmm2 = mem[0],zero
	cvtsi2sdq	(%rbx), %xmm0
	divsd	%xmm2, %xmm1
	addsd	%xmm1, %xmm0
	xorps	%xmm1, %xmm1
	cvtsi2sdq	16(%rsp), %xmm1
	divsd	%xmm2, %xmm1
	subsd	%xmm1, %xmm0
	xorps	%xmm1, %xmm1
	cvtsi2sdq	8(%rsp), %xmm1
	subsd	%xmm1, %xmm0
	movl	$.L.str, %edi
	movb	$1, %al
	addq	$40, %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
	jmp	printf                          # TAILCALL
.Lfunc_end1:
	.size	_Z17hostCalShortTableiPiS_S_, .Lfunc_end1-_Z17hostCalShortTableiPiS_S_
	.cfi_endproc
                                        # -- End function
	.globl	_Z11checkResultiPiS_S_S_        # -- Begin function _Z11checkResultiPiS_S_S_
	.type	_Z11checkResultiPiS_S_S_,@function
_Z11checkResultiPiS_S_S_:               # @_Z11checkResultiPiS_S_S_
	.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
	testl	%edi, %edi
	je	.LBB2_1
# %bb.2:                                # %.lr.ph.preheader
	movq	%rdx, %r12
	movq	%rsi, %r13
	movl	%edi, %eax
	imull	%eax, %eax
	cmpl	$1, %eax
	movl	%eax, %r10d
	adcl	$0, %r10d
	movl	(%rsi), %edx
	cmpl	(%rcx), %edx
	jne	.LBB2_3
# %bb.4:                                # %.lr.ph83.preheader
	decq	%r10
	xorl	%edx, %edx
	xorl	%ebx, %ebx
	xorl	%ebp, %ebp
	xorl	%r14d, %r14d
	xorl	%esi, %esi
.LBB2_6:                                # %.lr.ph83
                                        # =>This Inner Loop Header: Depth=1
	movl	(%r12,%rsi,4), %r9d
	cmpl	(%r8,%rsi,4), %r9d
	jne	.LBB2_7
# %bb.9:                                #   in Loop: Header=BB2_6 Depth=1
	leaq	1(%rsi), %r15
	cmpq	%rax, %r15
	setae	%r14b
	cmpq	%rsi, %r10
	je	.LBB2_10
# %bb.5:                                # %.lr.ph
                                        #   in Loop: Header=BB2_6 Depth=1
	incl	%ebx
	xorl	%r9d, %r9d
	cmpl	%edi, %ebx
	sete	%r9b
	cmovel	%edx, %ebx
	addl	%r9d, %ebp
	movl	4(%r13,%rsi,4), %r9d
	cmpl	4(%rcx,%rsi,4), %r9d
	movq	%r15, %rsi
	je	.LBB2_6
	jmp	.LBB2_8
.LBB2_1:
	movb	$1, %r14b
.LBB2_10:                               # %.critedge
	movl	$.L.str.4, %edi
	callq	puts
	jmp	.LBB2_11
.LBB2_3:
	xorl	%r15d, %r15d
	xorl	%r14d, %r14d
	xorl	%ebp, %ebp
	xorl	%ebx, %ebx
	jmp	.LBB2_8
.LBB2_7:
	movq	%rsi, %r15
.LBB2_8:                                # %._crit_edge
	movl	$.L.str.1, %edi
	movl	%ebx, %esi
	movl	%ebp, %edx
	xorl	%eax, %eax
	movq	%r8, 16(%rsp)                   # 8-byte Spill
	movq	%rcx, 8(%rsp)                   # 8-byte Spill
	callq	printf
	movl	(%r13,%r15,4), %ecx
	movl	(%r12,%r15,4), %eax
	movl	%eax, (%rsp)
	movl	$.L.str.2, %edi
	movl	%ebx, %esi
	movl	%ebp, %edx
	movl	%ebx, %r8d
	movl	%ebp, %r9d
	xorl	%eax, %eax
	callq	printf
	movq	8(%rsp), %rax                   # 8-byte Reload
	movl	(%rax,%r15,4), %ecx
	movq	16(%rsp), %rax                  # 8-byte Reload
	movl	(%rax,%r15,4), %eax
	movl	%eax, (%rsp)
	movl	$.L.str.3, %edi
	movl	%ebx, %esi
	movl	%ebp, %edx
	movl	%ebx, %r8d
	movl	%ebp, %r9d
	xorl	%eax, %eax
	callq	printf
.LBB2_11:
	andb	$1, %r14b
	movl	%r14d, %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
.Lfunc_end2:
	.size	_Z11checkResultiPiS_S_S_, .Lfunc_end2-_Z11checkResultiPiS_S_S_
	.cfi_endproc
                                        # -- End function
	.globl	_Z30__device_stub__deviceCalBetteriiPiS_ # -- Begin function _Z30__device_stub__deviceCalBetteriiPiS_
	.type	_Z30__device_stub__deviceCalBetteriiPiS_,@function
_Z30__device_stub__deviceCalBetteriiPiS_: # @_Z30__device_stub__deviceCalBetteriiPiS_
	.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	12(%rsp), %rax
	movl	%edi, (%rax)
	leaq	8(%rsp), %rdi
	movl	%esi, (%rdi)
	leaq	40(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	32(%rsp), %rdx
	movq	%rcx, (%rdx)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	24(%rsp), %r12
	leaq	16(%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	$_Z15deviceCalBetteriiPiS_, %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_end3:
	.size	_Z30__device_stub__deviceCalBetteriiPiS_, .Lfunc_end3-_Z30__device_stub__deviceCalBetteriiPiS_
	.cfi_endproc
                                        # -- End function
	.globl	_Z34__device_stub__deviceCalShortTableiPiS_S_ # -- Begin function _Z34__device_stub__deviceCalShortTableiPiS_S_
	.type	_Z34__device_stub__deviceCalShortTableiPiS_S_,@function
_Z34__device_stub__deviceCalShortTableiPiS_S_: # @_Z34__device_stub__deviceCalShortTableiPiS_S_
	.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	4(%rsp), %rax
	movl	%edi, (%rax)
	leaq	40(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	32(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	24(%rsp), %rdx
	movq	%rcx, (%rdx)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	16(%rsp), %r12
	leaq	8(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z19deviceCalShortTableiPiS_S_, %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_end4:
	.size	_Z34__device_stub__deviceCalShortTableiPiS_S_, .Lfunc_end4-_Z34__device_stub__deviceCalShortTableiPiS_S_
	.cfi_endproc
                                        # -- End function
	.globl	_Z18shortestPath_floydiPiS_S_   # -- Begin function _Z18shortestPath_floydiPiS_S_
	.type	_Z18shortestPath_floydiPiS_S_,@function
_Z18shortestPath_floydiPiS_S_:          # @_Z18shortestPath_floydiPiS_S_
	.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	$40, %rsp
	.cfi_def_cfa_offset 96
	.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	%rcx, 24(%rsp)                  # 8-byte Spill
	movq	%rdx, 16(%rsp)                  # 8-byte Spill
	movq	%rsi, %r13
	movl	%edi, %ebx
	movl	%edi, %eax
	imull	%edi, %eax
	shll	$3, %eax
	movslq	%eax, %r15
	leaq	32(%rsp), %rbp
	movq	%rbp, %rdi
	movq	%r15, %rsi
	callq	hipMalloc
	leaq	8(%rsp), %r14
	movq	%r14, %rdi
	movq	%r15, %rsi
	callq	hipMalloc
	movq	%rsp, %r12
	movq	%r12, %rdi
	movq	%r15, %rsi
	callq	hipMalloc
	movq	(%rbp), %rdi
	movq	%r13, %rsi
	movq	%r15, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	(%r14), %rdi
	movq	16(%rsp), %rsi                  # 8-byte Reload
	movq	%r15, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	(%r12), %rdi
	movq	24(%rsp), %rsi                  # 8-byte Reload
	movq	%r15, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	leal	255(%rbx), %ecx
	leal	510(%rbx), %eax
	testl	%ecx, %ecx
	cmovnsl	%ecx, %eax
	testl	%ebx, %ebx
	jle	.LBB5_5
# %bb.1:                                # %.lr.ph.preheader
	sarl	$8, %eax
	movq	%rbx, %r14
	shlq	$32, %r14
	orq	%rax, %r14
	xorl	%r15d, %r15d
	movabsq	$4294967552, %r12               # imm = 0x100000100
.LBB5_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movq	%r14, %rdi
	movl	$1, %esi
	movq	%r12, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB5_4
# %bb.3:                                #   in Loop: Header=BB5_2 Depth=1
	movq	8(%rsp), %rdx
	movq	(%rsp), %rcx
	movl	%r15d, %edi
	movl	%ebx, %esi
	callq	_Z30__device_stub__deviceCalBetteriiPiS_
.LBB5_4:                                #   in Loop: Header=BB5_2 Depth=1
	incl	%r15d
	cmpl	%r15d, %ebx
	jne	.LBB5_2
.LBB5_5:                                # %._crit_edge
	callq	hipDeviceSynchronize
	movq	32(%rsp), %rdi
	callq	hipFree
	movq	8(%rsp), %rdi
	callq	hipFree
	movq	(%rsp), %rdi
	callq	hipFree
	addq	$40, %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_end5:
	.size	_Z18shortestPath_floydiPiS_S_, .Lfunc_end5-_Z18shortestPath_floydiPiS_S_
	.cfi_endproc
                                        # -- End function
	.globl	_Z24__device_stub__warmingupi   # -- Begin function _Z24__device_stub__warmingupi
	.type	_Z24__device_stub__warmingupi,@function
_Z24__device_stub__warmingupi:          # @_Z24__device_stub__warmingupi
	.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	12(%rsp), %rax
	movl	%edi, (%rax)
	leaq	16(%rsp), %rbx
	movq	%rax, (%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	40(%rsp), %r12
	leaq	32(%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	$_Z9warmingupi, %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_end6:
	.size	_Z24__device_stub__warmingupi, .Lfunc_end6-_Z24__device_stub__warmingupi
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI7_0:
	.quad	0x412e848000000000              # double 1.0E+6
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
	.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	$1504, %rsp                     # imm = 0x5E0
	.cfi_def_cfa_offset 1552
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	(%rsi), %rsi
	movl	$.L.str.5, %edi
	xorl	%eax, %eax
	callq	printf
	leaq	32(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipGetDevicePropertiesR0600
	testl	%eax, %eax
	jne	.LBB7_1
# %bb.3:
	leaq	32(%rsp), %rdx
	movl	$.L.str.9, %edi
	xorl	%esi, %esi
	xorl	%eax, %eax
	callq	printf
	xorl	%edi, %edi
	callq	hipSetDevice
	testl	%eax, %eax
	jne	.LBB7_4
# %bb.5:
	movl	$8000000, %edi                  # imm = 0x7A1200
	callq	malloc
	movq	%rax, %rbx
	movl	$8000000, %edi                  # imm = 0x7A1200
	callq	malloc
	movq	%rax, %r14
	movl	$8000000, %edi                  # imm = 0x7A1200
	callq	malloc
	movq	%rax, %r15
	movl	$1000, %edi                     # imm = 0x3E8
	movq	%rbx, %rsi
	movq	%r14, %rdx
	movq	%rax, %rcx
	callq	_Z10initializeiPiS_S_
	movabsq	$4294967552, %rdx               # imm = 0x100000100
	leaq	3651(%rdx), %rdi
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB7_7
# %bb.6:
	movl	$32, %edi
	callq	_Z24__device_stub__warmingupi
.LBB7_7:
	leaq	16(%rsp), %r12
	movq	%r12, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	movl	$1000, %edi                     # imm = 0x3E8
	movq	%rbx, %rsi
	movq	%r14, %rdx
	movq	%r15, %rcx
	callq	_Z18shortestPath_floydiPiS_S_
	movq	%rsp, %r13
	movq	%r13, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	cvtsi2sdq	8(%r13), %xmm1
	movsd	.LCPI7_0(%rip), %xmm2           # xmm2 = mem[0],zero
	divsd	%xmm2, %xmm1
	cvtsi2sdq	(%r13), %xmm0
	addsd	%xmm1, %xmm0
	xorps	%xmm1, %xmm1
	cvtsi2sdq	8(%r12), %xmm1
	divsd	%xmm2, %xmm1
	subsd	%xmm1, %xmm0
	xorps	%xmm1, %xmm1
	cvtsi2sdq	(%r12), %xmm1
	subsd	%xmm1, %xmm0
	movl	$.L.str.10, %edi
	movb	$1, %al
	callq	printf
	movq	%rbx, %rdi
	callq	free
	movq	%r14, %rdi
	callq	free
	movq	%r15, %rdi
	callq	free
	callq	hipDeviceReset
	xorl	%eax, %eax
	addq	$1504, %rsp                     # imm = 0x5E0
	.cfi_def_cfa_offset 48
	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
.LBB7_1:
	.cfi_def_cfa_offset 1552
	movl	%eax, %ebx
	movl	$.L.str.6, %edi
	movl	$.L.str.7, %esi
	movl	$192, %edx
	jmp	.LBB7_2
.LBB7_4:
	movl	%eax, %ebx
	movl	$.L.str.6, %edi
	movl	$.L.str.7, %esi
	movl	$194, %edx
.LBB7_2:
	xorl	%eax, %eax
	callq	printf
	movl	%ebx, %edi
	callq	hipGetErrorString
	movl	$.L.str.8, %edi
	movl	%ebx, %esi
	movq	%rax, %rdx
	xorl	%eax, %eax
	callq	printf
	addl	%ebx, %ebx
	leal	(%rbx,%rbx,4), %edi
	negl	%edi
	callq	exit
.Lfunc_end7:
	.size	main, .Lfunc_end7-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	.LBB8_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB8_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z15deviceCalBetteriiPiS_, %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	$_Z19deviceCalShortTableiPiS_S_, %esi
	movl	$.L__unnamed_2, %edx
	movl	$.L__unnamed_2, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z9warmingupi, %esi
	movl	$.L__unnamed_3, %edx
	movl	$.L__unnamed_3, %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_end8:
	.size	__hip_module_ctor, .Lfunc_end8-__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	.LBB9_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
.LBB9_2:
	retq
.Lfunc_end9:
	.size	__hip_module_dtor, .Lfunc_end9-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"CPU Time: %.6lfs\n"
	.size	.L.str, 18

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"Wrong Answer on %d to %d.\n"
	.size	.L.str.1, 27

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"Host   result: path_node[%d][%d] = %d, shortLenTable[%d][%d] = %.2f.\n"
	.size	.L.str.2, 70

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"Device result: path_node[%d][%d] = %d, shortLenTable[%d][%d] = %.2f.\n"
	.size	.L.str.3, 70

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"The results of GPU and CPU are the same."
	.size	.L.str.4, 41

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

	.type	_Z19deviceCalShortTableiPiS_S_,@object # @_Z19deviceCalShortTableiPiS_S_
	.globl	_Z19deviceCalShortTableiPiS_S_
	.p2align	3, 0x0
_Z19deviceCalShortTableiPiS_S_:
	.quad	_Z34__device_stub__deviceCalShortTableiPiS_S_
	.size	_Z19deviceCalShortTableiPiS_S_, 8

	.type	_Z9warmingupi,@object           # @_Z9warmingupi
	.globl	_Z9warmingupi
	.p2align	3, 0x0
_Z9warmingupi:
	.quad	_Z24__device_stub__warmingupi
	.size	_Z9warmingupi, 8

	.type	.L.str.5,@object                # @.str.5
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.5:
	.asciz	"%s Starting...\n"
	.size	.L.str.5, 16

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"Error: %s:%d, "
	.size	.L.str.6, 15

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"/home/ubuntu/Datasets/stackv2/train-structured-repos-hip-sm89/hzeroto/CUDA_FLOYD/master/test.hip"
	.size	.L.str.7, 97

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"code:%d, reson: %s\n"
	.size	.L.str.8, 20

	.type	.L.str.9,@object                # @.str.9
.L.str.9:
	.asciz	"Using Device %d: %s\n"
	.size	.L.str.9, 21

	.type	.L.str.10,@object               # @.str.10
.L.str.10:
	.asciz	"GPU Time: %.6lfs\n"
	.size	.L.str.10, 18

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z15deviceCalBetteriiPiS_"
	.size	.L__unnamed_1, 26

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_Z19deviceCalShortTableiPiS_S_"
	.size	.L__unnamed_2, 31

	.type	.L__unnamed_3,@object           # @2
.L__unnamed_3:
	.asciz	"_Z9warmingupi"
	.size	.L__unnamed_3, 14

	.type	__hip_fatbin_wrapper,@object    # @__hip_fatbin_wrapper
	.section	.hipFatBinSegment,"a",@progbits
	.p2align	3, 0x0
__hip_fatbin_wrapper:
	.long	1212764230                      # 0x48495046
	.long	1                               # 0x1
	.quad	__hip_fatbin
	.quad	0
	.size	__hip_fatbin_wrapper, 24

	.type	__hip_gpubin_handle,@object     # @__hip_gpubin_handle
	.local	__hip_gpubin_handle
	.comm	__hip_gpubin_handle,8,8
	.section	.init_array,"aw",@init_array
	.p2align	3, 0x0
	.quad	__hip_module_ctor
	.type	__hip_cuid_,@object             # @__hip_cuid_
	.bss
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               # 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym _Z30__device_stub__deviceCalBetteriiPiS_
	.addrsig_sym _Z34__device_stub__deviceCalShortTableiPiS_S_
	.addrsig_sym _Z24__device_stub__warmingupi
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z15deviceCalBetteriiPiS_
	.addrsig_sym _Z19deviceCalShortTableiPiS_S_
	.addrsig_sym _Z9warmingupi
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z15deviceCalBetteriiPiS_ ; -- Begin function _Z15deviceCalBetteriiPiS_
	.globl	_Z15deviceCalBetteriiPiS_
	.p2align	8
	.type	_Z15deviceCalBetteriiPiS_,@function
_Z15deviceCalBetteriiPiS_:              ; @_Z15deviceCalBetteriiPiS_
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x24
	s_load_b64 s[4:5], s[0:1], 0x0
	s_waitcnt lgkmcnt(0)
	s_and_b32 s2, s2, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s14, s2, v[0:1]
	s_mov_b32 s2, exec_lo
	v_cmpx_gt_i32_e64 s5, v1
	s_cbranch_execz .LBB0_5
; %bb.1:
	s_load_b128 s[0:3], s[0:1], 0x8
	s_mul_i32 s8, s15, s5
	s_mov_b32 s7, 0
	s_mov_b32 s9, exec_lo
	v_cmpx_eq_u32_e32 0, v0
	s_cbranch_execz .LBB0_3
; %bb.2:
	s_add_i32 s6, s8, s4
	v_mov_b32_e32 v0, 0
	s_lshl_b64 s[6:7], s[6:7], 2
	s_waitcnt lgkmcnt(0)
	s_add_u32 s6, s2, s6
	s_addc_u32 s7, s3, s7
	s_load_b32 s6, s[6:7], 0x0
	s_waitcnt lgkmcnt(0)
	v_mov_b32_e32 v2, s6
	ds_store_b32 v0, v2
.LBB0_3:
	s_or_b32 exec_lo, exec_lo, s9
	v_mad_u64_u32 v[2:3], null, s5, s4, v[1:2]
	v_add_nc_u32_e32 v0, s8, v1
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	v_mov_b32_e32 v6, 0
	v_ashrrev_i32_e32 v1, 31, v0
	v_ashrrev_i32_e32 v3, 31, v2
	ds_load_b32 v6, v6
	v_lshlrev_b64 v[2:3], 2, v[2:3]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v4, vcc_lo, s2, v2
	v_add_co_ci_u32_e32 v5, vcc_lo, s3, v3, vcc_lo
	v_lshlrev_b64 v[2:3], 2, v[0:1]
	global_load_b32 v4, v[4:5], off
	v_add_co_u32 v0, vcc_lo, s2, v2
	v_add_co_ci_u32_e32 v1, vcc_lo, s3, v3, vcc_lo
	global_load_b32 v5, v[0:1], off
	s_waitcnt vmcnt(1) lgkmcnt(0)
	v_add_nc_u32_e32 v4, v4, v6
	s_waitcnt vmcnt(0)
	s_delay_alu instid0(VALU_DEP_1)
	v_cmp_lt_i32_e32 vcc_lo, v4, v5
	s_and_b32 exec_lo, exec_lo, vcc_lo
	s_cbranch_execz .LBB0_5
; %bb.4:
	v_add_co_u32 v2, vcc_lo, s0, v2
	v_add_co_ci_u32_e32 v3, vcc_lo, s1, v3, vcc_lo
	v_mov_b32_e32 v5, s4
	global_store_b32 v[0:1], v4, off
	global_store_b32 v[2:3], v5, off
.LBB0_5:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z15deviceCalBetteriiPiS_
		.amdhsa_group_segment_fixed_size 4
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 280
		.amdhsa_user_sgpr_count 14
		.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 1
		.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	_Z15deviceCalBetteriiPiS_, .Lfunc_end0-_Z15deviceCalBetteriiPiS_
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 320
; NumSgprs: 18
; NumVgprs: 7
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 4 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: 14
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.protected	_Z19deviceCalShortTableiPiS_S_ ; -- Begin function _Z19deviceCalShortTableiPiS_S_
	.globl	_Z19deviceCalShortTableiPiS_S_
	.p2align	8
	.type	_Z19deviceCalShortTableiPiS_S_,@function
_Z19deviceCalShortTableiPiS_S_:         ; @_Z19deviceCalShortTableiPiS_S_
; %bb.0:
	s_clause 0x1
	s_load_b128 s[4:7], s[0:1], 0x8
	s_load_b32 s2, s[0:1], 0x2c
	s_waitcnt lgkmcnt(0)
	s_load_b32 s3, s[4:5], 0x0
	s_and_b32 s2, s2, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1)
	v_mad_u64_u32 v[1:2], null, s15, s2, v[0:1]
	s_waitcnt lgkmcnt(0)
	s_mul_i32 s2, s3, s3
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	v_cmp_gt_u32_e32 vcc_lo, s2, v1
	s_and_saveexec_b32 s2, vcc_lo
	s_cbranch_execz .LBB1_3
; %bb.1:
	v_cvt_f32_u32_e32 v0, s3
	s_sub_i32 s2, 0, s3
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	v_rcp_iflag_f32_e32 v0, v0
	s_waitcnt_depctr 0xfff
	v_mul_f32_e32 v0, 0x4f7ffffe, v0
	v_cvt_u32_f32_e32 v0, v0
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_3) | instid1(VALU_DEP_1)
	v_mul_lo_u32 v2, s2, v0
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x0
	s_load_b64 s[0:1], s[0:1], 0x18
	v_mul_hi_u32 v2, v0, v2
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_nc_u32_e32 v0, v0, v2
	v_mul_hi_u32 v0, v1, v0
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_mul_lo_u32 v2, v0, s3
	v_add_nc_u32_e32 v3, 1, v0
	v_sub_nc_u32_e32 v2, v1, v2
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_4)
	v_subrev_nc_u32_e32 v4, s3, v2
	v_cmp_le_u32_e32 vcc_lo, s3, v2
	v_cndmask_b32_e32 v0, v0, v3, vcc_lo
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_cndmask_b32_e32 v2, v2, v4, vcc_lo
	v_add_nc_u32_e32 v3, 1, v0
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_cmp_le_u32_e32 vcc_lo, s3, v2
	v_cndmask_b32_e32 v0, v0, v3, vcc_lo
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_lo_u32 v2, v0, s3
	v_sub_nc_u32_e32 v1, v1, v2
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_2)
	v_mul_lo_u32 v4, v1, s3
	s_waitcnt lgkmcnt(0)
	v_mad_u64_u32 v[1:2], null, s3, s2, v[0:1]
	v_add_nc_u32_e32 v3, s2, v4
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_3)
	v_ashrrev_i32_e32 v2, 31, v1
	v_add_nc_u32_e32 v0, v4, v0
	v_ashrrev_i32_e32 v4, 31, v3
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_lshlrev_b64 v[5:6], 2, v[1:2]
	v_ashrrev_i32_e32 v1, 31, v0
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_lshlrev_b64 v[7:8], 2, v[3:4]
	v_add_co_u32 v4, vcc_lo, s0, v5
	s_delay_alu instid0(VALU_DEP_3) | instskip(SKIP_1) | instid1(VALU_DEP_4)
	v_lshlrev_b64 v[2:3], 2, v[0:1]
	v_add_co_ci_u32_e32 v5, vcc_lo, s1, v6, vcc_lo
	v_add_co_u32 v6, vcc_lo, s0, v7
	v_add_co_ci_u32_e32 v7, vcc_lo, s1, v8, vcc_lo
	s_delay_alu instid0(VALU_DEP_4)
	v_add_co_u32 v0, vcc_lo, s0, v2
	v_add_co_ci_u32_e32 v1, vcc_lo, s1, v3, vcc_lo
	s_clause 0x2
	global_load_b32 v6, v[6:7], off
	global_load_b32 v4, v[4:5], off
	global_load_b32 v5, v[0:1], off
	s_waitcnt vmcnt(1)
	v_add_nc_u32_e32 v4, v4, v6
	s_waitcnt vmcnt(0)
	s_delay_alu instid0(VALU_DEP_1)
	v_cmp_gt_i32_e32 vcc_lo, v5, v4
	s_and_b32 exec_lo, exec_lo, vcc_lo
	s_cbranch_execz .LBB1_3
; %bb.2:
	v_add_co_u32 v2, vcc_lo, s6, v2
	v_add_co_ci_u32_e32 v3, vcc_lo, s7, v3, vcc_lo
	v_mov_b32_e32 v5, s2
	global_store_b32 v[0:1], v4, off
	global_store_b32 v[2:3], v5, off
.LBB1_3:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z19deviceCalShortTableiPiS_S_
		.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 9
		.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	_Z19deviceCalShortTableiPiS_S_, .Lfunc_end1-_Z19deviceCalShortTableiPiS_S_
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 464
; NumSgprs: 18
; NumVgprs: 9
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 9
; Occupancy: 16
; WaveLimiterHint : 1
; 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	_Z9warmingupi           ; -- Begin function _Z9warmingupi
	.globl	_Z9warmingupi
	.p2align	8
	.type	_Z9warmingupi,@function
_Z9warmingupi:                          ; @_Z9warmingupi
; %bb.0:
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z9warmingupi
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 4
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 1
		.amdhsa_next_free_sgpr 1
		.amdhsa_reserve_vcc 0
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end2:
	.size	_Z9warmingupi, .Lfunc_end2-_Z9warmingupi
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 4
; NumSgprs: 0
; NumVgprs: 0
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 0
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 1
; NumVGPRsForWavesPerEU: 1
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __hip_cuid_
	.amdgpu_metadata
---
amdhsa.kernels:
  - .args:
      - .offset:         0
        .size:           4
        .value_kind:     by_value
      - .offset:         4
        .size:           4
        .value_kind:     by_value
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         16
        .size:           8
        .value_kind:     global_buffer
      - .offset:         24
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         28
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         32
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         36
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         38
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         40
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         42
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         44
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         46
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         64
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         88
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 4
    .kernarg_segment_align: 8
    .kernarg_segment_size: 280
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z15deviceCalBetteriiPiS_
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z15deviceCalBetteriiPiS_.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:
      - .offset:         0
        .size:           4
        .value_kind:     by_value
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         16
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         24
        .size:           8
        .value_kind:     global_buffer
      - .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:           _Z19deviceCalShortTableiPiS_S_
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z19deviceCalShortTableiPiS_S_.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     9
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
  - .args:
      - .offset:         0
        .size:           4
        .value_kind:     by_value
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 4
    .kernarg_segment_size: 4
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z9warmingupi
    .private_segment_fixed_size: 0
    .sgpr_count:     0
    .sgpr_spill_count: 0
    .symbol:         _Z9warmingupi.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     0
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
