//compile
/** nvcc -arch=sm_11 dijkstra_cuda.cu -o dijkstra_cuda **/

//reference: github.com/AlexDWong/dijkstra-CUDA/

#include <iostream>
#include <stdio.h>
#include <cstdlib>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include <limits.h>


#define VERTICES 16384         //number of vertices
#define CPU_IMP 1               //number of Dijkstra implementations (non-GPU)
#define GPU_IMP 1               //number of Dijkstra implementations (GPU)
#define BLOCKS 32
#define THREADS_PER_BLOCK 512

typedef int data_t;


int main() {
	clock_t cpu_startTime, cpu_endTime;
	double cpu_ElapseTime = 0;

	int* d_min;
	int* d_minIndex;
	int* d_temp;
	int* d_tempIndex;

	cudaMalloc((void**)& d_min, sizeof(int));
	cudaMalloc((void**)& d_minIndex, sizeof(int));
	cudaMalloc((void**)& d_temp, BLOCKS * sizeof(int));
	cudaMalloc((void**)& d_tempIndex, BLOCKS * sizeof(int));

	cudaMemset(d_min, INT_MAX, sizeof(int));
	cudaMemset(d_minIndex, 0, sizeof(int));


	//functions
	void setIntArrayValue(int* in_array, int array_size, int value);
	void setDataArrayValue(data_t * in_array, int array_size, data_t init_value);
	void initializeGraphZero(data_t * graph, int num_vertices);
	void constructGraphEdge(data_t * graph, int num_vertices);

	//Dijkstra's implementations
	void dijkstraCPUSerial(data_t * graph, data_t * node_dist, int* visited_node, int num_vertices, int v_start);   //serial Dijkstra
	__global__ void closestNodeCUDA(int* d_min, int* d_minIndex, int* d_temp, int* d_tempIndex, data_t * node_dist, int* visited_node, int* global_closest, int num_vertices);                   //Dijkstra CUDA Pt. 1
	__global__ void cudaRelax(data_t * graph, data_t * node_dist, int* visited_node, int* source);                  //Dijkstra CUDA Pt. 2


	/*************SETUP GRAPH*************/
	int graph_size = VERTICES * VERTICES * sizeof(data_t);
	int int_array = VERTICES * sizeof(int);
	int data_array = VERTICES * sizeof(data_t);
	data_t* graph = (data_t*)malloc(graph_size);
	data_t* node_dist = (data_t*)malloc(data_array);
	int* visited_node = (int*)malloc(int_array);
	data_t* dist_matrix = (data_t*)malloc((CPU_IMP + GPU_IMP) * data_array);

	printf("Variables created, allocated\n");

	data_t* gpu_graph;      //CUDA mallocs
	data_t* gpu_node_dist;
	int* gpu_visited_node;
	cudaMalloc((void**)& gpu_graph, graph_size);
	cudaMalloc((void**)& gpu_node_dist, data_array);
	cudaMalloc((void**)& gpu_visited_node, int_array);
	int* closest_vertex = (int*)malloc(sizeof(int));    //for closest vertex
	int* gpu_closest_vertex;
	closest_vertex[0] = -1;
	cudaMalloc((void**)& gpu_closest_vertex, (sizeof(int)));
	cudaMemcpy(gpu_closest_vertex, closest_vertex, sizeof(int), cudaMemcpyHostToDevice);

	setDataArrayValue(node_dist, VERTICES, INT_MAX);
	setIntArrayValue(visited_node, VERTICES, 0);
	initializeGraphZero(graph, VERTICES);
	constructGraphEdge(graph, VERTICES);

	printf("Variables initialized.\n");

	/************RUN DIJKSTRA'S************/
	int i;
	int origin = 0;
	printf("Origin vertex: %d\n", origin);

	/*  SERIAL DIJKSTRA  */
	int version = 0;
	printf("Running serial...");
	cpu_startTime = clock();
	dijkstraCPUSerial(graph, node_dist, visited_node, VERTICES, origin);
	cpu_endTime = clock();
	cpu_ElapseTime = ((cpu_endTime - cpu_startTime) / (double)CLOCKS_PER_SEC);

	for (i = 0; i < VERTICES; i++) {
		dist_matrix[version * VERTICES + i] = node_dist[i];
	}
	printf("Done!\n");

	/*  CUDA DIJKSTRA  */
	version++;
	cudaEvent_t gpu_start, gpu_stop;
	float gpu_elapsed_exec;
	cudaEventCreate(&gpu_start);
	cudaEventCreate(&gpu_stop);

	setDataArrayValue(node_dist, VERTICES, INT_MAX);   //reset previous data
	setIntArrayValue(visited_node, VERTICES, 0);
	node_dist[origin] = 0;

	cudaMemcpy(gpu_graph, graph, graph_size, cudaMemcpyHostToDevice);
	cudaMemcpy(gpu_node_dist, node_dist, data_array, cudaMemcpyHostToDevice);
	cudaMemcpy(gpu_visited_node, visited_node, int_array, cudaMemcpyHostToDevice);

	dim3 gridMin(BLOCKS, 1, 1);
	dim3 blockMin(THREADS_PER_BLOCK, 1, 1);

	dim3 gridRelax(BLOCKS, 1, 1); /** number of blocks **/
	dim3 blockRelax(THREADS_PER_BLOCK, 1, 1); /** numebr of threads per block **/


    cudaEventRecord(gpu_start, 0);
	for (int i = 0; i < VERTICES; i++) {
		closestNodeCUDA <<<gridMin, blockMin >>> (d_min, d_minIndex, d_temp, d_tempIndex, gpu_node_dist, gpu_visited_node, gpu_closest_vertex, VERTICES);  //find min
		cudaRelax <<<gridRelax, blockRelax >>> (gpu_graph, gpu_node_dist, gpu_visited_node, gpu_closest_vertex); //relax

	}
	cudaEventRecord(gpu_stop, 0);
	cudaEventSynchronize(gpu_stop);
	cudaEventElapsedTime(&gpu_elapsed_exec, gpu_start, gpu_stop);        //elapsed execution time
	cudaEventDestroy(gpu_start);
	cudaEventDestroy(gpu_stop);

	cudaMemcpy(node_dist, gpu_node_dist, data_array, cudaMemcpyDeviceToHost);
	cudaMemcpy(visited_node, gpu_visited_node, int_array, cudaMemcpyDeviceToHost);
	for (i = 0; i < VERTICES; i++) {
		dist_matrix[version * VERTICES + i] = node_dist[i];
	}

	//free memory
	cudaFree(d_min);
	cudaFree(d_minIndex);
	cudaFree(d_temp);
	cudaFree(d_tempIndex);

	cudaFree(gpu_graph);
	cudaFree(gpu_node_dist);
	cudaFree(gpu_visited_node);


	printf("\nVertices: %d", VERTICES);
	printf("\n\nSerial Time (s): %.6f\n", cpu_ElapseTime);
	printf("\n\nCUDA Time (ms): %.3f\n", gpu_elapsed_exec);

	/***************ERROR CHECKING***************/
	printf("\n\nError checking:\n");
	printf("----Serial vs CUDA:\n");

	int d_errors = 0;
	for (i = 0; i < VERTICES; i++) {
		if (dist_matrix[i] != dist_matrix[VERTICES + i]) {
			d_errors++;
			printf("d_Error: Serial has %d %d, CUDA has %d %d\n", dist_matrix[i], i, dist_matrix[VERTICES + i], VERTICES + i);
		}
	}
	printf("--------%d dist errors found.\n", d_errors);
}


/****************DIJKSTRA'S ALGORITHM IMPLEMENTATIONS****************/
/* Serial Implementation */
int closestNode(data_t* node_dist, int* visited_node, int num_vertices) {
	int dist = INT_MAX;
	int node = -1;
	int i;

	for (i = 0; i < num_vertices; i++) {
		if ((node_dist[i] < dist) && (visited_node[i] == 0)) {
			node = i;
			dist = node_dist[i];
		}
	}
	return node;
}

void dijkstraCPUSerial(data_t* graph, data_t* node_dist, int* visited_node, int num_vertices, int v_start) {

	//functions
	void setIntArrayValue(int* in_array, int array_size, int init_value);
	void setDataArrayValue(data_t * in_array, int array_size, data_t init_value);
	int closestNode(data_t * node_dist, int* visited_node, int num_vertices);

	setDataArrayValue(node_dist, VERTICES, INT_MAX);   //reset data from previous runs
	setIntArrayValue(visited_node, VERTICES, 0);
	node_dist[v_start] = 0;

	int i, next;
	for (i = 0; i < num_vertices; i++) {
		int curr_node = closestNode(node_dist, visited_node, num_vertices);
		visited_node[curr_node] = 1;
		for (next = 0; next < num_vertices; next++) {   //Update only if neighbor is reachable, not visited, and if distance through current is less than the current min
			int new_dist = node_dist[curr_node] + graph[curr_node * num_vertices + next];
			if ((visited_node[next] != 1)
				&& (graph[curr_node * num_vertices + next] != (data_t)(0))
				&& (new_dist < node_dist[next])) {
				node_dist[next] = new_dist;        //update distance
			}
		}
	}
}

/* CUDA implementation */
__global__ void closestNodeCUDA(int* min_value, int* minIndex, int* temp, int* tempIndex, data_t* node_dist, int* visited_node, int* global_closest, int num_vertices) {

	unsigned int index = blockIdx.x * blockDim.x + threadIdx.x;

	__shared__ int cache[THREADS_PER_BLOCK];
	__shared__ int cacheIndex[THREADS_PER_BLOCK];


	if (index < num_vertices) {
		if ((node_dist[index]) < INT_MAX && (visited_node[index]) == 0) {
			cache[threadIdx.x] = node_dist[index];
			cacheIndex[threadIdx.x] = index;
		}
		else {
			cache[threadIdx.x] = INT_MAX;
			cacheIndex[threadIdx.x] = -1;
		}
	}
	__syncthreads();

	unsigned int i = blockDim.x / 2;
	while (i != 0) {
		if (threadIdx.x < i) {
			if (cache[threadIdx.x + i] < cache[threadIdx.x]) {
				cache[threadIdx.x] = cache[threadIdx.x + i];
				cacheIndex[threadIdx.x] = cacheIndex[threadIdx.x + i];
			}
		}
		__syncthreads();
		i /= 2;
	}

	if (threadIdx.x == 0) {
		temp[blockIdx.x] = cache[0];
		tempIndex[blockIdx.x] = cacheIndex[0];
	}

	unsigned int k = BLOCKS / 2;
	if (threadIdx.x == 0 && blockIdx.x == 0) {
		while (k != 0) {
			for (int j = 0; j < k; ++j) {
				if ((temp[j + k]) < temp[j]) {
					temp[j] = temp[j + k];
					tempIndex[j] = tempIndex[j + k];
				}
			}

			__syncthreads();
			k /= 2;
		}
	}
	if (threadIdx.x == 0 && blockIdx.x == 0) {
		*min_value = temp[0];
		*minIndex = tempIndex[0];

		global_closest[0] = *minIndex;
		visited_node[*minIndex] = 1;
	}
	__syncthreads();

}

__global__ void cudaRelax(data_t* graph, data_t* node_dist, int* visited_node, int* global_closest) {
	int next = blockIdx.x * blockDim.x + threadIdx.x;
	int source = global_closest[0];

	data_t edge = graph[source * VERTICES + next];
	data_t new_dist = node_dist[source] + edge;

	if ((edge != 0) &&
		(visited_node[next] != 1) &&
		(new_dist < node_dist[next])) {
		node_dist[next] = new_dist;
	}

}

/********FUNCTIONS*********/

/*  Initialize elements of a 1D int array with an initial value   */
void setIntArrayValue(int* in_array, int array_size, int init_value) {
	int i;
	for (i = 0; i < array_size; i++) {
		in_array[i] = init_value;
	}
}

/*  Initialize elements of a 1D data_t array with an initial value   */
void setDataArrayValue(data_t* in_array, int array_size, data_t init_value) {
	int i;
	for (i = 0; i < array_size; i++) {
		in_array[i] = init_value;
	}
}

/*  Construct graph with no edges or weights     */
void initializeGraphZero(data_t* graph, int num_vertices) {
	int i, j;

	for (i = 0; i < num_vertices; i++) {
		for (j = 0; j < num_vertices; j++) {           //weight of all edges initialized to 0
			graph[i * num_vertices + j] = (data_t)0;
		}
	}
}

/*  Construct a fully connected, undirected graph with non-negative edges and a minimum degree for vertices.  */
void constructGraphEdge(data_t* graph, int num_vertices) {
	int i, j;
	data_t weight;

	//initialize a connected graph
	printf("Initializing a connected graph...");
	for (i = 0; i < num_vertices; i++) {
		for (j = i; j < num_vertices; j++) {
			weight = rand() % 1000;
			graph[i * num_vertices + j] = weight;
			graph[j * num_vertices + i] = weight;
		}

	}
	printf("done!\n");
}

	.file	"tmpxft_002b74e7_00000000-6_dijkstra_cuda_v10.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB3644:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE3644:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z11closestNodePiS_i
	.type	_Z11closestNodePiS_i, @function
_Z11closestNodePiS_i:
.LFB3636:
	.cfi_startproc
	endbr64
	xorl	%eax, %eax
	orl	$-1, %ecx
	movl	$2147483647, %r8d
.L3:
	cmpl	%eax, %edx
	jle	.L7
	movl	(%rdi,%rax,4), %r9d
	cmpl	%r8d, %r9d
	jge	.L4
	cmpl	$0, (%rsi,%rax,4)
	cmove	%eax, %ecx
	cmove	%r9d, %r8d
.L4:
	incq	%rax
	jmp	.L3
.L7:
	movl	%ecx, %eax
	ret
	.cfi_endproc
.LFE3636:
	.size	_Z11closestNodePiS_i, .-_Z11closestNodePiS_i
	.globl	_Z16setIntArrayValuePiii
	.type	_Z16setIntArrayValuePiii, @function
_Z16setIntArrayValuePiii:
.LFB3638:
	.cfi_startproc
	endbr64
	xorl	%eax, %eax
.L9:
	cmpl	%eax, %esi
	jle	.L11
	movl	%edx, (%rdi,%rax,4)
	incq	%rax
	jmp	.L9
.L11:
	ret
	.cfi_endproc
.LFE3638:
	.size	_Z16setIntArrayValuePiii, .-_Z16setIntArrayValuePiii
	.globl	_Z17dijkstraCPUSerialPiS_S_ii
	.type	_Z17dijkstraCPUSerialPiS_S_ii, @function
_Z17dijkstraCPUSerialPiS_S_ii:
.LFB3637:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movq	%rsi, %r10
	movl	$16384, %esi
	movslq	%r8d, %r8
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movq	%rdi, %rbp
	movq	%r10, %rdi
	movl	%ecx, %r11d
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	movq	%rdx, %rbx
	movl	$2147483647, %edx
	xorl	%r12d, %r12d
	call	_Z16setIntArrayValuePiii
	xorl	%edx, %edx
	movq	%rbx, %rdi
	call	_Z16setIntArrayValuePiii
	xorl	%eax, %eax
	movl	%eax, (%r10,%r8,4)
.L13:
	cmpl	%r11d, %r12d
	jge	.L25
	movl	%r11d, %edx
	movq	%rbx, %rsi
	movq	%r10, %rdi
	call	_Z11closestNodePiS_i
	movslq	%eax, %rdx
	imull	%r11d, %eax
	movl	$1, (%rbx,%rdx,4)
	leaq	0(,%rdx,4), %rcx
	cltq
	leaq	0(%rbp,%rax,4), %rsi
	xorl	%eax, %eax
.L15:
	cmpl	$1, (%rbx,%rax,4)
	movl	(%rsi,%rax,4), %edx
	je	.L14
	testl	%edx, %edx
	je	.L14
	addl	(%r10,%rcx), %edx
	cmpl	%edx, (%r10,%rax,4)
	jle	.L14
	movl	%edx, (%r10,%rax,4)
.L14:
	incq	%rax
	cmpl	%eax, %r11d
	jg	.L15
	incl	%r12d
	jmp	.L13
.L25:
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3637:
	.size	_Z17dijkstraCPUSerialPiS_S_ii, .-_Z17dijkstraCPUSerialPiS_S_ii
	.globl	_Z17setDataArrayValuePiii
	.type	_Z17setDataArrayValuePiii, @function
_Z17setDataArrayValuePiii:
.LFB4291:
	.cfi_startproc
	endbr64
	jmp	_Z16setIntArrayValuePiii
	.cfi_endproc
.LFE4291:
	.size	_Z17setDataArrayValuePiii, .-_Z17setDataArrayValuePiii
	.globl	_Z19initializeGraphZeroPii
	.type	_Z19initializeGraphZeroPii, @function
_Z19initializeGraphZeroPii:
.LFB3640:
	.cfi_startproc
	endbr64
	leal	-1(%rsi), %eax
	movslq	%esi, %r9
	movq	%rdi, %rdx
	xorl	%r8d, %r8d
	leaq	4(,%rax,4), %r10
	salq	$2, %r9
	xorl	%eax, %eax
.L28:
	cmpl	%esi, %r8d
	jge	.L30
	movq	%rdx, %rdi
	movq	%r10, %rcx
	incl	%r8d
	addq	%r9, %rdx
	rep stosb
	jmp	.L28
.L30:
	ret
	.cfi_endproc
.LFE3640:
	.size	_Z19initializeGraphZeroPii, .-_Z19initializeGraphZeroPii
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"Initializing a connected graph..."
.LC1:
	.string	"done!\n"
	.text
	.globl	_Z18constructGraphEdgePii
	.type	_Z18constructGraphEdgePii, @function
_Z18constructGraphEdgePii:
.LFB3641:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	xorl	%eax, %eax
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%rdi, %r13
	movl	$2, %edi
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movq	%r13, %r15
	xorl	%r12d, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movl	%esi, %ebx
	leaq	.LC0(%rip), %rsi
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	call	__printf_chk@PLT
	movslq	%ebx, %rax
	xorl	%esi, %esi
	leaq	4(,%rax,4), %rdi
	leaq	-4(%rdi), %r9
.L32:
	cmpl	%r12d, %ebx
	jle	.L34
	movslq	%esi, %rax
	movq	%r15, %r14
	movq	%r12, %rbp
	leaq	0(%r13,%rax,4), %r8
.L35:
	cmpl	%ebp, %ebx
	jle	.L37
	movl	%esi, 28(%rsp)
	movq	%rdi, 16(%rsp)
	movq	%r8, 8(%rsp)
	movq	%r9, (%rsp)
	call	rand@PLT
	movl	$1000, %ecx
	movq	8(%rsp), %r8
	movq	(%rsp), %r9
	cltd
	movl	28(%rsp), %esi
	movq	16(%rsp), %rdi
	idivl	%ecx
	movl	%edx, (%r8,%rbp,4)
	incq	%rbp
	movl	%edx, (%r14)
	addq	%r9, %r14
	jmp	.L35
.L37:
	incq	%r12
	addq	%rdi, %r15
	addl	%ebx, %esi
	jmp	.L32
.L34:
	addq	$40, %rsp
	.cfi_def_cfa_offset 56
	leaq	.LC1(%rip), %rsi
	movl	$2, %edi
	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
	jmp	__printf_chk@PLT
	.cfi_endproc
.LFE3641:
	.size	_Z18constructGraphEdgePii, .-_Z18constructGraphEdgePii
	.globl	_Z48__device_stub__Z15closestNodeCUDAPiS_S_S_S_S_S_iPiS_S_S_S_S_S_i
	.type	_Z48__device_stub__Z15closestNodeCUDAPiS_S_S_S_S_S_iPiS_S_S_S_S_S_i, @function
_Z48__device_stub__Z15closestNodeCUDAPiS_S_S_S_S_S_iPiS_S_S_S_S_S_i:
.LFB3666:
	.cfi_startproc
	endbr64
	subq	$216, %rsp
	.cfi_def_cfa_offset 224
	movq	224(%rsp), %rax
	movq	%rdi, 56(%rsp)
	leaq	88(%rsp), %rdi
	movq	%rsi, 48(%rsp)
	leaq	100(%rsp), %rsi
	movq	%rdx, 40(%rsp)
	leaq	72(%rsp), %rdx
	movq	%rcx, 32(%rsp)
	leaq	80(%rsp), %rcx
	movq	%r8, 24(%rsp)
	movq	%r9, 16(%rsp)
	movq	%rax, 8(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 200(%rsp)
	xorl	%eax, %eax
	leaq	56(%rsp), %rax
	movl	$1, 96(%rsp)
	movq	%rax, 136(%rsp)
	leaq	48(%rsp), %rax
	movq	%rax, 144(%rsp)
	leaq	40(%rsp), %rax
	movq	%rax, 152(%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 160(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 168(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 176(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 184(%rsp)
	leaq	232(%rsp), %rax
	movq	%rax, 192(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 88(%rsp)
	movq	%rax, 100(%rsp)
	movl	$1, 108(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L38
	pushq	80(%rsp)
	.cfi_def_cfa_offset 232
	leaq	_Z15closestNodeCUDAPiS_S_S_S_S_S_i(%rip), %rdi
	pushq	80(%rsp)
	.cfi_def_cfa_offset 240
	movq	116(%rsp), %rcx
	movl	124(%rsp), %r8d
	movq	104(%rsp), %rsi
	movl	112(%rsp), %edx
	leaq	152(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 232
	popq	%rdx
	.cfi_def_cfa_offset 224
.L38:
	movq	200(%rsp), %rax
	subq	%fs:40, %rax
	je	.L40
	call	__stack_chk_fail@PLT
.L40:
	addq	$216, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3666:
	.size	_Z48__device_stub__Z15closestNodeCUDAPiS_S_S_S_S_S_iPiS_S_S_S_S_S_i, .-_Z48__device_stub__Z15closestNodeCUDAPiS_S_S_S_S_S_iPiS_S_S_S_S_S_i
	.globl	_Z15closestNodeCUDAPiS_S_S_S_S_S_i
	.type	_Z15closestNodeCUDAPiS_S_S_S_S_S_i, @function
_Z15closestNodeCUDAPiS_S_S_S_S_S_i:
.LFB3667:
	.cfi_startproc
	endbr64
	jmp	_Z48__device_stub__Z15closestNodeCUDAPiS_S_S_S_S_S_iPiS_S_S_S_S_S_i
	.cfi_endproc
.LFE3667:
	.size	_Z15closestNodeCUDAPiS_S_S_S_S_S_i, .-_Z15closestNodeCUDAPiS_S_S_S_S_S_i
	.globl	_Z34__device_stub__Z9cudaRelaxPiS_S_S_PiS_S_S_
	.type	_Z34__device_stub__Z9cudaRelaxPiS_S_S_PiS_S_S_, @function
_Z34__device_stub__Z9cudaRelaxPiS_S_S_PiS_S_S_:
.LFB3668:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movq	%rdi, 24(%rsp)
	leaq	56(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	68(%rsp), %rsi
	movq	%rdx, 8(%rsp)
	leaq	40(%rsp), %rdx
	movq	%rcx, (%rsp)
	leaq	48(%rsp), %rcx
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 64(%rsp)
	movq	%rax, 104(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 120(%rsp)
	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	.L43
	pushq	48(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z9cudaRelaxPiS_S_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
.L43:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L45
	call	__stack_chk_fail@PLT
.L45:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3668:
	.size	_Z34__device_stub__Z9cudaRelaxPiS_S_S_PiS_S_S_, .-_Z34__device_stub__Z9cudaRelaxPiS_S_S_PiS_S_S_
	.globl	_Z9cudaRelaxPiS_S_S_
	.type	_Z9cudaRelaxPiS_S_S_, @function
_Z9cudaRelaxPiS_S_S_:
.LFB3669:
	.cfi_startproc
	endbr64
	jmp	_Z34__device_stub__Z9cudaRelaxPiS_S_S_PiS_S_S_
	.cfi_endproc
.LFE3669:
	.size	_Z9cudaRelaxPiS_S_S_, .-_Z9cudaRelaxPiS_S_S_
	.section	.rodata.str1.1
.LC2:
	.string	"Variables created, allocated\n"
.LC3:
	.string	"Variables initialized.\n"
.LC4:
	.string	"Origin vertex: %d\n"
.LC5:
	.string	"Running serial..."
.LC7:
	.string	"Done!\n"
.LC8:
	.string	"\nVertices: %d"
.LC9:
	.string	"\n\nSerial Time (s): %.6f\n"
.LC10:
	.string	"\n\nCUDA Time (ms): %.3f\n"
.LC11:
	.string	"\n\nError checking:\n"
.LC12:
	.string	"----Serial vs CUDA:\n"
.LC13:
	.string	"d_Error: Serial has %d %d, CUDA has %d %d\n"
.LC14:
	.string	"--------%d dist errors found.\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB3635:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	movl	$4, %esi
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	subq	$144, %rsp
	.cfi_def_cfa_offset 192
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rdi
	call	cudaMalloc@PLT
	leaq	16(%rsp), %rdi
	movl	$4, %esi
	call	cudaMalloc@PLT
	leaq	24(%rsp), %rdi
	movl	$128, %esi
	call	cudaMalloc@PLT
	leaq	32(%rsp), %rdi
	movl	$128, %esi
	call	cudaMalloc@PLT
	movq	8(%rsp), %rdi
	movl	$4, %edx
	movl	$2147483647, %esi
	call	cudaMemset@PLT
	movq	16(%rsp), %rdi
	movl	$4, %edx
	xorl	%esi, %esi
	call	cudaMemset@PLT
	movl	$1073741824, %edi
	call	malloc@PLT
	movl	$65536, %edi
	movq	%rax, %r13
	call	malloc@PLT
	movl	$65536, %edi
	movq	%rax, %rbx
	call	malloc@PLT
	movl	$131072, %edi
	movq	%rax, %r12
	call	malloc@PLT
	leaq	.LC2(%rip), %rsi
	movl	$2, %edi
	movq	%rax, %rbp
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	40(%rsp), %rdi
	movl	$1073741824, %esi
	call	cudaMalloc@PLT
	leaq	48(%rsp), %rdi
	movl	$65536, %esi
	call	cudaMalloc@PLT
	movl	$65536, %esi
	leaq	56(%rsp), %rdi
	call	cudaMalloc@PLT
	movl	$4, %edi
	call	malloc@PLT
	leaq	64(%rsp), %rdi
	movl	$4, %esi
	movl	$-1, (%rax)
	movq	%rax, %r14
	call	cudaMalloc@PLT
	movq	64(%rsp), %rdi
	movl	$1, %ecx
	movq	%r14, %rsi
	movl	$4, %edx
	call	cudaMemcpy@PLT
	movl	$16384, %esi
	movl	$2147483647, %edx
	movq	%rbx, %rdi
	call	_Z16setIntArrayValuePiii
	xorl	%edx, %edx
	movq	%r12, %rdi
	call	_Z16setIntArrayValuePiii
	movq	%r13, %rdi
	call	_Z19initializeGraphZeroPii
	movq	%r13, %rdi
	call	_Z18constructGraphEdgePii
	leaq	.LC3(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	xorl	%edx, %edx
	leaq	.LC4(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
	leaq	.LC5(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	call	clock@PLT
	xorl	%r8d, %r8d
	movq	%r12, %rdx
	movq	%r13, %rdi
	movl	$16384, %ecx
	movq	%rbx, %rsi
	movq	%rax, %r14
	call	_Z17dijkstraCPUSerialPiS_S_ii
	call	clock@PLT
	movl	$16384, %ecx
	movq	%rbp, %rdi
	movq	%rbx, %rsi
	rep movsl
	subq	%r14, %rax
	leaq	.LC7(%rip), %rsi
	movl	$2, %edi
	cvtsi2sdq	%rax, %xmm0
	xorl	%eax, %eax
	divsd	.LC6(%rip), %xmm0
	movq	%xmm0, %r14
	call	__printf_chk@PLT
	leaq	72(%rsp), %rdi
	call	cudaEventCreate@PLT
	leaq	80(%rsp), %rdi
	call	cudaEventCreate@PLT
	movl	$16384, %esi
	movq	%rbx, %rdi
	xorl	%ecx, %ecx
	movl	$2147483647, %edx
	call	_Z16setIntArrayValuePiii
	xorl	%edx, %edx
	movq	%r12, %rdi
	call	_Z16setIntArrayValuePiii
	movl	%ecx, (%rbx)
	movq	40(%rsp), %rdi
	movq	%r13, %rsi
	movl	$1, %ecx
	movl	$1073741824, %edx
	movl	$16384, %r13d
	call	cudaMemcpy@PLT
	movq	48(%rsp), %rdi
	movl	$1, %ecx
	movq	%rbx, %rsi
	movl	$65536, %edx
	call	cudaMemcpy@PLT
	movq	56(%rsp), %rdi
	movl	$1, %ecx
	movq	%r12, %rsi
	movl	$65536, %edx
	call	cudaMemcpy@PLT
	movq	72(%rsp), %rdi
	movl	$134217729, %edx
	xorl	%esi, %esi
	movl	$8388609, %eax
	salq	$5, %rdx
	movl	$1, 96(%rsp)
	salq	$9, %rax
	movq	%rdx, 88(%rsp)
	movq	%rax, 100(%rsp)
	movl	$1, 108(%rsp)
	movq	%rdx, 112(%rsp)
	movl	$1, 120(%rsp)
	movq	%rax, 124(%rsp)
	movl	$1, 132(%rsp)
	call	cudaEventRecord@PLT
.L51:
	movl	108(%rsp), %ecx
	movq	100(%rsp), %rdx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movq	88(%rsp), %rdi
	movl	96(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L49
	pushq	$16384
	.cfi_def_cfa_offset 200
	pushq	72(%rsp)
	.cfi_def_cfa_offset 208
	movq	72(%rsp), %r9
	movq	64(%rsp), %r8
	movq	48(%rsp), %rcx
	movq	40(%rsp), %rdx
	movq	32(%rsp), %rsi
	movq	24(%rsp), %rdi
	call	_Z48__device_stub__Z15closestNodeCUDAPiS_S_S_S_S_S_iPiS_S_S_S_S_S_i
	popq	%rax
	.cfi_def_cfa_offset 200
	popq	%rdx
	.cfi_def_cfa_offset 192
.L49:
	movq	124(%rsp), %rdx
	movq	112(%rsp), %rdi
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	132(%rsp), %ecx
	movl	120(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L50
	movq	64(%rsp), %rcx
	movq	56(%rsp), %rdx
	movq	48(%rsp), %rsi
	movq	40(%rsp), %rdi
	call	_Z34__device_stub__Z9cudaRelaxPiS_S_S_PiS_S_S_
.L50:
	decl	%r13d
	jne	.L51
	movq	80(%rsp), %rdi
	xorl	%esi, %esi
	leaq	.LC13(%rip), %r13
	call	cudaEventRecord@PLT
	movq	80(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movq	80(%rsp), %rdx
	movq	72(%rsp), %rsi
	leaq	4(%rsp), %rdi
	call	cudaEventElapsedTime@PLT
	movq	72(%rsp), %rdi
	call	cudaEventDestroy@PLT
	movq	80(%rsp), %rdi
	call	cudaEventDestroy@PLT
	movq	48(%rsp), %rsi
	movq	%rbx, %rdi
	movl	$2, %ecx
	movl	$65536, %edx
	call	cudaMemcpy@PLT
	movq	56(%rsp), %rsi
	movl	$65536, %edx
	movq	%r12, %rdi
	movl	$2, %ecx
	xorl	%r12d, %r12d
	call	cudaMemcpy@PLT
	leaq	65536(%rbp), %rax
	movq	%rbx, %rsi
	movl	$16384, %ecx
	movq	%rax, %rdi
	xorl	%ebx, %ebx
	rep movsl
	movq	8(%rsp), %rdi
	call	cudaFree@PLT
	movq	16(%rsp), %rdi
	call	cudaFree@PLT
	movq	24(%rsp), %rdi
	call	cudaFree@PLT
	movq	32(%rsp), %rdi
	call	cudaFree@PLT
	movq	40(%rsp), %rdi
	call	cudaFree@PLT
	movq	48(%rsp), %rdi
	call	cudaFree@PLT
	movq	56(%rsp), %rdi
	call	cudaFree@PLT
	movl	$16384, %edx
	leaq	.LC8(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
	movq	%r14, %xmm0
	leaq	.LC9(%rip), %rsi
	movb	$1, %al
	movl	$2, %edi
	call	__printf_chk@PLT
	leaq	.LC10(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	cvtss2sd	4(%rsp), %xmm0
	call	__printf_chk@PLT
	movl	$2, %edi
	xorl	%eax, %eax
	leaq	.LC11(%rip), %rsi
	call	__printf_chk@PLT
	leaq	.LC12(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L53:
	movl	0(%rbp,%rbx,4), %edx
	movl	65536(%rbp,%rbx,4), %r8d
	cmpl	%r8d, %edx
	je	.L52
	leal	16384(%rbx), %r9d
	movl	%ebx, %ecx
	movq	%r13, %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	incl	%r12d
	call	__printf_chk@PLT
.L52:
	incq	%rbx
	cmpq	$16384, %rbx
	jne	.L53
	xorl	%eax, %eax
	movl	%r12d, %edx
	movl	$2, %edi
	leaq	.LC14(%rip), %rsi
	call	__printf_chk@PLT
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L54
	call	__stack_chk_fail@PLT
.L54:
	addq	$144, %rsp
	.cfi_def_cfa_offset 48
	xorl	%eax, %eax
	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
.LFE3635:
	.size	main, .-main
	.section	.rodata.str1.1
.LC15:
	.string	"_Z9cudaRelaxPiS_S_S_"
.LC16:
	.string	"_Z15closestNodeCUDAPiS_S_S_S_S_S_i"
	.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	.LC15(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z9cudaRelaxPiS_S_S_(%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	.LC16(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z15closestNodeCUDAPiS_S_S_S_S_S_i(%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
.LC6:
	.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:

//compile
/** nvcc -arch=sm_11 dijkstra_cuda.cu -o dijkstra_cuda **/

//reference: github.com/AlexDWong/dijkstra-CUDA/


#include <hip/hip_runtime.h>
#include <iostream>
#include <stdio.h>
#include <cstdlib>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include <limits.h>


#define VERTICES 16384         //number of vertices
#define CPU_IMP 1               //number of Dijkstra implementations (non-GPU)
#define GPU_IMP 1               //number of Dijkstra implementations (GPU)
#define BLOCKS 32
#define THREADS_PER_BLOCK 512

typedef int data_t;


int main() {
	clock_t cpu_startTime, cpu_endTime;
	double cpu_ElapseTime = 0;

	int* d_min;
	int* d_minIndex;
	int* d_temp;
	int* d_tempIndex;

	hipMalloc((void**)& d_min, sizeof(int));
	hipMalloc((void**)& d_minIndex, sizeof(int));
	hipMalloc((void**)& d_temp, BLOCKS * sizeof(int));
	hipMalloc((void**)& d_tempIndex, BLOCKS * sizeof(int));

	hipMemset(d_min, INT_MAX, sizeof(int));
	hipMemset(d_minIndex, 0, sizeof(int));


	//functions
	void setIntArrayValue(int* in_array, int array_size, int value);
	void setDataArrayValue(data_t * in_array, int array_size, data_t init_value);
	void initializeGraphZero(data_t * graph, int num_vertices);
	void constructGraphEdge(data_t * graph, int num_vertices);

	//Dijkstra's implementations
	void dijkstraCPUSerial(data_t * graph, data_t * node_dist, int* visited_node, int num_vertices, int v_start);   //serial Dijkstra
	__global__ void closestNodeCUDA(int* d_min, int* d_minIndex, int* d_temp, int* d_tempIndex, data_t * node_dist, int* visited_node, int* global_closest, int num_vertices);                   //Dijkstra CUDA Pt. 1
	__global__ void cudaRelax(data_t * graph, data_t * node_dist, int* visited_node, int* source);                  //Dijkstra CUDA Pt. 2


	/*************SETUP GRAPH*************/
	int graph_size = VERTICES * VERTICES * sizeof(data_t);
	int int_array = VERTICES * sizeof(int);
	int data_array = VERTICES * sizeof(data_t);
	data_t* graph = (data_t*)malloc(graph_size);
	data_t* node_dist = (data_t*)malloc(data_array);
	int* visited_node = (int*)malloc(int_array);
	data_t* dist_matrix = (data_t*)malloc((CPU_IMP + GPU_IMP) * data_array);

	printf("Variables created, allocated\n");

	data_t* gpu_graph;      //CUDA mallocs
	data_t* gpu_node_dist;
	int* gpu_visited_node;
	hipMalloc((void**)& gpu_graph, graph_size);
	hipMalloc((void**)& gpu_node_dist, data_array);
	hipMalloc((void**)& gpu_visited_node, int_array);
	int* closest_vertex = (int*)malloc(sizeof(int));    //for closest vertex
	int* gpu_closest_vertex;
	closest_vertex[0] = -1;
	hipMalloc((void**)& gpu_closest_vertex, (sizeof(int)));
	hipMemcpy(gpu_closest_vertex, closest_vertex, sizeof(int), hipMemcpyHostToDevice);

	setDataArrayValue(node_dist, VERTICES, INT_MAX);
	setIntArrayValue(visited_node, VERTICES, 0);
	initializeGraphZero(graph, VERTICES);
	constructGraphEdge(graph, VERTICES);

	printf("Variables initialized.\n");

	/************RUN DIJKSTRA'S************/
	int i;
	int origin = 0;
	printf("Origin vertex: %d\n", origin);

	/*  SERIAL DIJKSTRA  */
	int version = 0;
	printf("Running serial...");
	cpu_startTime = clock();
	dijkstraCPUSerial(graph, node_dist, visited_node, VERTICES, origin);
	cpu_endTime = clock();
	cpu_ElapseTime = ((cpu_endTime - cpu_startTime) / (double)CLOCKS_PER_SEC);

	for (i = 0; i < VERTICES; i++) {
		dist_matrix[version * VERTICES + i] = node_dist[i];
	}
	printf("Done!\n");

	/*  CUDA DIJKSTRA  */
	version++;
	hipEvent_t gpu_start, gpu_stop;
	float gpu_elapsed_exec;
	hipEventCreate(&gpu_start);
	hipEventCreate(&gpu_stop);

	setDataArrayValue(node_dist, VERTICES, INT_MAX);   //reset previous data
	setIntArrayValue(visited_node, VERTICES, 0);
	node_dist[origin] = 0;

	hipMemcpy(gpu_graph, graph, graph_size, hipMemcpyHostToDevice);
	hipMemcpy(gpu_node_dist, node_dist, data_array, hipMemcpyHostToDevice);
	hipMemcpy(gpu_visited_node, visited_node, int_array, hipMemcpyHostToDevice);

	dim3 gridMin(BLOCKS, 1, 1);
	dim3 blockMin(THREADS_PER_BLOCK, 1, 1);

	dim3 gridRelax(BLOCKS, 1, 1); /** number of blocks **/
	dim3 blockRelax(THREADS_PER_BLOCK, 1, 1); /** numebr of threads per block **/


    hipEventRecord(gpu_start, 0);
	for (int i = 0; i < VERTICES; i++) {
		closestNodeCUDA <<<gridMin, blockMin >>> (d_min, d_minIndex, d_temp, d_tempIndex, gpu_node_dist, gpu_visited_node, gpu_closest_vertex, VERTICES);  //find min
		cudaRelax <<<gridRelax, blockRelax >>> (gpu_graph, gpu_node_dist, gpu_visited_node, gpu_closest_vertex); //relax

	}
	hipEventRecord(gpu_stop, 0);
	hipEventSynchronize(gpu_stop);
	hipEventElapsedTime(&gpu_elapsed_exec, gpu_start, gpu_stop);        //elapsed execution time
	hipEventDestroy(gpu_start);
	hipEventDestroy(gpu_stop);

	hipMemcpy(node_dist, gpu_node_dist, data_array, hipMemcpyDeviceToHost);
	hipMemcpy(visited_node, gpu_visited_node, int_array, hipMemcpyDeviceToHost);
	for (i = 0; i < VERTICES; i++) {
		dist_matrix[version * VERTICES + i] = node_dist[i];
	}

	//free memory
	hipFree(d_min);
	hipFree(d_minIndex);
	hipFree(d_temp);
	hipFree(d_tempIndex);

	hipFree(gpu_graph);
	hipFree(gpu_node_dist);
	hipFree(gpu_visited_node);


	printf("\nVertices: %d", VERTICES);
	printf("\n\nSerial Time (s): %.6f\n", cpu_ElapseTime);
	printf("\n\nCUDA Time (ms): %.3f\n", gpu_elapsed_exec);

	/***************ERROR CHECKING***************/
	printf("\n\nError checking:\n");
	printf("----Serial vs CUDA:\n");

	int d_errors = 0;
	for (i = 0; i < VERTICES; i++) {
		if (dist_matrix[i] != dist_matrix[VERTICES + i]) {
			d_errors++;
			printf("d_Error: Serial has %d %d, CUDA has %d %d\n", dist_matrix[i], i, dist_matrix[VERTICES + i], VERTICES + i);
		}
	}
	printf("--------%d dist errors found.\n", d_errors);
}


/****************DIJKSTRA'S ALGORITHM IMPLEMENTATIONS****************/
/* Serial Implementation */
int closestNode(data_t* node_dist, int* visited_node, int num_vertices) {
	int dist = INT_MAX;
	int node = -1;
	int i;

	for (i = 0; i < num_vertices; i++) {
		if ((node_dist[i] < dist) && (visited_node[i] == 0)) {
			node = i;
			dist = node_dist[i];
		}
	}
	return node;
}

void dijkstraCPUSerial(data_t* graph, data_t* node_dist, int* visited_node, int num_vertices, int v_start) {

	//functions
	void setIntArrayValue(int* in_array, int array_size, int init_value);
	void setDataArrayValue(data_t * in_array, int array_size, data_t init_value);
	int closestNode(data_t * node_dist, int* visited_node, int num_vertices);

	setDataArrayValue(node_dist, VERTICES, INT_MAX);   //reset data from previous runs
	setIntArrayValue(visited_node, VERTICES, 0);
	node_dist[v_start] = 0;

	int i, next;
	for (i = 0; i < num_vertices; i++) {
		int curr_node = closestNode(node_dist, visited_node, num_vertices);
		visited_node[curr_node] = 1;
		for (next = 0; next < num_vertices; next++) {   //Update only if neighbor is reachable, not visited, and if distance through current is less than the current min
			int new_dist = node_dist[curr_node] + graph[curr_node * num_vertices + next];
			if ((visited_node[next] != 1)
				&& (graph[curr_node * num_vertices + next] != (data_t)(0))
				&& (new_dist < node_dist[next])) {
				node_dist[next] = new_dist;        //update distance
			}
		}
	}
}

/* CUDA implementation */
__global__ void closestNodeCUDA(int* min_value, int* minIndex, int* temp, int* tempIndex, data_t* node_dist, int* visited_node, int* global_closest, int num_vertices) {

	unsigned int index = blockIdx.x * blockDim.x + threadIdx.x;

	__shared__ int cache[THREADS_PER_BLOCK];
	__shared__ int cacheIndex[THREADS_PER_BLOCK];


	if (index < num_vertices) {
		if ((node_dist[index]) < INT_MAX && (visited_node[index]) == 0) {
			cache[threadIdx.x] = node_dist[index];
			cacheIndex[threadIdx.x] = index;
		}
		else {
			cache[threadIdx.x] = INT_MAX;
			cacheIndex[threadIdx.x] = -1;
		}
	}
	__syncthreads();

	unsigned int i = blockDim.x / 2;
	while (i != 0) {
		if (threadIdx.x < i) {
			if (cache[threadIdx.x + i] < cache[threadIdx.x]) {
				cache[threadIdx.x] = cache[threadIdx.x + i];
				cacheIndex[threadIdx.x] = cacheIndex[threadIdx.x + i];
			}
		}
		__syncthreads();
		i /= 2;
	}

	if (threadIdx.x == 0) {
		temp[blockIdx.x] = cache[0];
		tempIndex[blockIdx.x] = cacheIndex[0];
	}

	unsigned int k = BLOCKS / 2;
	if (threadIdx.x == 0 && blockIdx.x == 0) {
		while (k != 0) {
			for (int j = 0; j < k; ++j) {
				if ((temp[j + k]) < temp[j]) {
					temp[j] = temp[j + k];
					tempIndex[j] = tempIndex[j + k];
				}
			}

			__syncthreads();
			k /= 2;
		}
	}
	if (threadIdx.x == 0 && blockIdx.x == 0) {
		*min_value = temp[0];
		*minIndex = tempIndex[0];

		global_closest[0] = *minIndex;
		visited_node[*minIndex] = 1;
	}
	__syncthreads();

}

__global__ void cudaRelax(data_t* graph, data_t* node_dist, int* visited_node, int* global_closest) {
	int next = blockIdx.x * blockDim.x + threadIdx.x;
	int source = global_closest[0];

	data_t edge = graph[source * VERTICES + next];
	data_t new_dist = node_dist[source] + edge;

	if ((edge != 0) &&
		(visited_node[next] != 1) &&
		(new_dist < node_dist[next])) {
		node_dist[next] = new_dist;
	}

}

/********FUNCTIONS*********/

/*  Initialize elements of a 1D int array with an initial value   */
void setIntArrayValue(int* in_array, int array_size, int init_value) {
	int i;
	for (i = 0; i < array_size; i++) {
		in_array[i] = init_value;
	}
}

/*  Initialize elements of a 1D data_t array with an initial value   */
void setDataArrayValue(data_t* in_array, int array_size, data_t init_value) {
	int i;
	for (i = 0; i < array_size; i++) {
		in_array[i] = init_value;
	}
}

/*  Construct graph with no edges or weights     */
void initializeGraphZero(data_t* graph, int num_vertices) {
	int i, j;

	for (i = 0; i < num_vertices; i++) {
		for (j = 0; j < num_vertices; j++) {           //weight of all edges initialized to 0
			graph[i * num_vertices + j] = (data_t)0;
		}
	}
}

/*  Construct a fully connected, undirected graph with non-negative edges and a minimum degree for vertices.  */
void constructGraphEdge(data_t* graph, int num_vertices) {
	int i, j;
	data_t weight;

	//initialize a connected graph
	printf("Initializing a connected graph...");
	for (i = 0; i < num_vertices; i++) {
		for (j = i; j < num_vertices; j++) {
			weight = rand() % 1000;
			graph[i * num_vertices + j] = weight;
			graph[j * num_vertices + i] = weight;
		}

	}
	printf("done!\n");
}

	.text
	.file	"dijkstra_cuda_v10.hip"
                                        # Start of file scope inline assembly
	.globl	_ZSt21ios_base_library_initv

                                        # End of file scope inline assembly
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI0_0:
	.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	$104, %rsp
	.cfi_def_cfa_offset 160
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	leaq	80(%rsp), %rbx
	movl	$4, %esi
	movq	%rbx, %rdi
	callq	hipMalloc
	leaq	72(%rsp), %r14
	movl	$4, %esi
	movq	%r14, %rdi
	callq	hipMalloc
	leaq	64(%rsp), %rdi
	movl	$128, %esi
	callq	hipMalloc
	leaq	56(%rsp), %rdi
	movl	$128, %esi
	callq	hipMalloc
	movq	(%rbx), %rdi
	movl	$4, %edx
	movl	$2147483647, %esi               # imm = 0x7FFFFFFF
	callq	hipMemset
	movq	(%r14), %rdi
	xorl	%r15d, %r15d
	movl	$4, %edx
	xorl	%esi, %esi
	callq	hipMemset
	movl	$1073741824, %edi               # imm = 0x40000000
	callq	malloc
	movq	%rax, %r12
	movl	$65536, %edi                    # imm = 0x10000
	callq	malloc
	movq	%rax, %r14
	movl	$65536, %edi                    # imm = 0x10000
	callq	malloc
	movq	%rax, 88(%rsp)                  # 8-byte Spill
	movl	$131072, %edi                   # imm = 0x20000
	callq	malloc
	movq	%rax, %rbx
	movl	$.Lstr, %edi
	callq	puts@PLT
	leaq	40(%rsp), %rdi
	movl	$1073741824, %esi               # imm = 0x40000000
	callq	hipMalloc
	leaq	8(%rsp), %rdi
	movl	$65536, %esi                    # imm = 0x10000
	callq	hipMalloc
	movq	%rsp, %rdi
	movl	$65536, %esi                    # imm = 0x10000
	callq	hipMalloc
	movl	$4, %edi
	callq	malloc
	movq	%rax, %r13
	movl	$-1, (%rax)
	leaq	48(%rsp), %rbp
	movl	$4, %esi
	movq	%rbp, %rdi
	callq	hipMalloc
	movq	(%rbp), %rdi
	movl	$4, %edx
	movq	%r13, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
.LBB0_1:                                # %.lr.ph.i
                                        # =>This Inner Loop Header: Depth=1
	movl	$2147483647, (%r14,%r15,4)      # imm = 0x7FFFFFFF
	incq	%r15
	cmpq	$16384, %r15                    # imm = 0x4000
	jne	.LBB0_1
# %bb.2:                                # %.lr.ph.i91.preheader
	xorl	%ebp, %ebp
	movl	$65536, %edx                    # imm = 0x10000
	movq	88(%rsp), %r15                  # 8-byte Reload
	movq	%r15, %rdi
	xorl	%esi, %esi
	callq	memset@PLT
	movl	$1073741824, %edx               # imm = 0x40000000
	movq	%r12, %rdi
	xorl	%esi, %esi
	callq	memset@PLT
	movq	%r12, %rdi
	movl	$16384, %esi                    # imm = 0x4000
	callq	_Z18constructGraphEdgePii
	movl	$.Lstr.1, %edi
	callq	puts@PLT
	movl	$.L.str.2, %edi
	xorl	%esi, %esi
	xorl	%eax, %eax
	callq	printf
	movl	$.L.str.3, %edi
	xorl	%eax, %eax
	callq	printf
	callq	clock
	movq	%rax, %r13
	movq	%r12, %rdi
	movq	%r14, %rsi
	movq	%r15, %rdx
	movl	$16384, %ecx                    # imm = 0x4000
	xorl	%r8d, %r8d
	callq	_Z17dijkstraCPUSerialPiS_S_ii
	callq	clock
	subq	%r13, %rax
	cvtsi2sd	%rax, %xmm0
	movsd	%xmm0, 24(%rsp)                 # 8-byte Spill
	movl	$65536, %edx                    # imm = 0x10000
	movq	%rbx, %rdi
	movq	%r14, %rsi
	callq	memcpy@PLT
	movl	$.Lstr.2, %edi
	callq	puts@PLT
	leaq	32(%rsp), %rdi
	callq	hipEventCreate
	leaq	16(%rsp), %rdi
	callq	hipEventCreate
.LBB0_3:                                # %.lr.ph.i98
                                        # =>This Inner Loop Header: Depth=1
	movl	$2147483647, (%r14,%rbp,4)      # imm = 0x7FFFFFFF
	incq	%rbp
	cmpq	$16384, %rbp                    # imm = 0x4000
	jne	.LBB0_3
# %bb.4:                                # %.lr.ph.i104.preheader
	movabsq	$4294967328, %r13               # imm = 0x100000020
	movl	$65536, %edx                    # imm = 0x10000
	movq	%r15, %rdi
	xorl	%esi, %esi
	callq	memset@PLT
	movl	$0, (%r14)
	movq	40(%rsp), %rdi
	movl	$1073741824, %edx               # imm = 0x40000000
	movq	%r12, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	movq	8(%rsp), %rdi
	movl	$65536, %edx                    # imm = 0x10000
	movq	%r14, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	movq	(%rsp), %rdi
	movl	$65536, %edx                    # imm = 0x10000
	movq	%r15, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	movq	32(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movl	$16384, %ebp                    # imm = 0x4000
	leaq	480(%r13), %r12
.LBB0_5:                                # =>This Inner Loop Header: Depth=1
	movq	%r13, %rdi
	movl	$1, %esi
	movq	%r12, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB0_7
# %bb.6:                                #   in Loop: Header=BB0_5 Depth=1
	movq	80(%rsp), %rdi
	movq	72(%rsp), %rsi
	movq	64(%rsp), %rdx
	movq	56(%rsp), %rcx
	movq	8(%rsp), %r8
	movq	(%rsp), %r9
	pushq	$16384                          # imm = 0x4000
	.cfi_adjust_cfa_offset 8
	pushq	56(%rsp)
	.cfi_adjust_cfa_offset 8
	callq	_Z30__device_stub__closestNodeCUDAPiS_S_S_S_S_S_i
	addq	$16, %rsp
	.cfi_adjust_cfa_offset -16
.LBB0_7:                                #   in Loop: Header=BB0_5 Depth=1
	movq	%r13, %rdi
	movl	$1, %esi
	movq	%r12, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB0_9
# %bb.8:                                #   in Loop: Header=BB0_5 Depth=1
	movq	40(%rsp), %rdi
	movq	8(%rsp), %rsi
	movq	(%rsp), %rdx
	movq	48(%rsp), %rcx
	callq	_Z24__device_stub__cudaRelaxPiS_S_S_
.LBB0_9:                                #   in Loop: Header=BB0_5 Depth=1
	decl	%ebp
	jne	.LBB0_5
# %bb.10:
	movq	16(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	16(%rsp), %rdi
	callq	hipEventSynchronize
	movq	32(%rsp), %rsi
	movq	16(%rsp), %rdx
	leaq	100(%rsp), %r12
	movq	%r12, %rdi
	callq	hipEventElapsedTime
	movq	32(%rsp), %rdi
	callq	hipEventDestroy
	movq	16(%rsp), %rdi
	callq	hipEventDestroy
	movq	8(%rsp), %rsi
	movl	$65536, %edx                    # imm = 0x10000
	movq	%r14, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	movq	(%rsp), %rsi
	movl	$65536, %edx                    # imm = 0x10000
	movq	%r15, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	movq	%rbx, %rdi
	addq	$65536, %rdi                    # imm = 0x10000
	movl	$65536, %edx                    # imm = 0x10000
	movq	%r14, %rsi
	callq	memcpy@PLT
	movsd	24(%rsp), %xmm0                 # 8-byte Reload
                                        # xmm0 = mem[0],zero
	divsd	.LCPI0_0(%rip), %xmm0
	movsd	%xmm0, 24(%rsp)                 # 8-byte Spill
	movq	80(%rsp), %rdi
	callq	hipFree
	movq	72(%rsp), %rdi
	callq	hipFree
	movq	64(%rsp), %rdi
	callq	hipFree
	movq	56(%rsp), %rdi
	callq	hipFree
	movq	40(%rsp), %rdi
	callq	hipFree
	movq	8(%rsp), %rdi
	callq	hipFree
	movq	(%rsp), %rdi
	callq	hipFree
	movl	$.L.str.5, %edi
	movl	$16384, %esi                    # imm = 0x4000
	xorl	%eax, %eax
	callq	printf
	movl	$.L.str.6, %edi
	movsd	24(%rsp), %xmm0                 # 8-byte Reload
                                        # xmm0 = mem[0],zero
	movb	$1, %al
	callq	printf
	xorps	%xmm0, %xmm0
	cvtss2sd	(%r12), %xmm0
	movl	$.L.str.7, %edi
	movb	$1, %al
	callq	printf
	movl	$.Lstr.3, %edi
	callq	puts@PLT
	movl	$.Lstr.4, %edi
	callq	puts@PLT
	xorl	%r14d, %r14d
	xorl	%ebp, %ebp
.LBB0_11:                               # =>This Inner Loop Header: Depth=1
	movl	(%rbx,%r14,4), %esi
	movl	65536(%rbx,%r14,4), %ecx
	cmpl	%ecx, %esi
	je	.LBB0_13
# %bb.12:                               #   in Loop: Header=BB0_11 Depth=1
	leal	16384(%r14), %r8d
	incl	%ebp
	movl	$.L.str.10, %edi
	movl	%r14d, %edx
	xorl	%eax, %eax
	callq	printf
.LBB0_13:                               #   in Loop: Header=BB0_11 Depth=1
	incq	%r14
	cmpq	$16384, %r14                    # imm = 0x4000
	jne	.LBB0_11
# %bb.14:
	movl	$.L.str.11, %edi
	movl	%ebp, %esi
	xorl	%eax, %eax
	callq	printf
	xorl	%eax, %eax
	addq	$104, %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	main, .Lfunc_end0-main
	.cfi_endproc
                                        # -- End function
	.globl	_Z17setDataArrayValuePiii       # -- Begin function _Z17setDataArrayValuePiii
	.type	_Z17setDataArrayValuePiii,@function
_Z17setDataArrayValuePiii:              # @_Z17setDataArrayValuePiii
	.cfi_startproc
# %bb.0:
	testl	%esi, %esi
	jle	.LBB1_3
# %bb.1:                                # %.lr.ph.preheader
	movl	%esi, %eax
	xorl	%ecx, %ecx
.LBB1_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movl	%edx, (%rdi,%rcx,4)
	incq	%rcx
	cmpq	%rcx, %rax
	jne	.LBB1_2
.LBB1_3:                                # %._crit_edge
	retq
.Lfunc_end1:
	.size	_Z17setDataArrayValuePiii, .Lfunc_end1-_Z17setDataArrayValuePiii
	.cfi_endproc
                                        # -- End function
	.globl	_Z16setIntArrayValuePiii        # -- Begin function _Z16setIntArrayValuePiii
	.type	_Z16setIntArrayValuePiii,@function
_Z16setIntArrayValuePiii:               # @_Z16setIntArrayValuePiii
	.cfi_startproc
# %bb.0:
	testl	%esi, %esi
	jle	.LBB2_3
# %bb.1:                                # %.lr.ph.preheader
	movl	%esi, %eax
	xorl	%ecx, %ecx
.LBB2_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movl	%edx, (%rdi,%rcx,4)
	incq	%rcx
	cmpq	%rcx, %rax
	jne	.LBB2_2
.LBB2_3:                                # %._crit_edge
	retq
.Lfunc_end2:
	.size	_Z16setIntArrayValuePiii, .Lfunc_end2-_Z16setIntArrayValuePiii
	.cfi_endproc
                                        # -- End function
	.globl	_Z19initializeGraphZeroPii      # -- Begin function _Z19initializeGraphZeroPii
	.type	_Z19initializeGraphZeroPii,@function
_Z19initializeGraphZeroPii:             # @_Z19initializeGraphZeroPii
	.cfi_startproc
# %bb.0:
	testl	%esi, %esi
	jle	.LBB3_4
# %bb.1:                                # %.preheader.lr.ph
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	%esi, %ebx
	movq	%rdi, %r14
	movl	%esi, %r12d
	leaq	(,%r12,4), %r15
	xorl	%ebp, %ebp
.LBB3_2:                                # %._crit_edge
                                        # =>This Inner Loop Header: Depth=1
	movl	%ebp, %eax
	leaq	(%r14,%rax,4), %rdi
	xorl	%esi, %esi
	movq	%r15, %rdx
	callq	memset@PLT
	addl	%ebx, %ebp
	decq	%r12
	jne	.LBB3_2
# %bb.3:
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.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
	.cfi_restore %rbx
	.cfi_restore %r12
	.cfi_restore %r14
	.cfi_restore %r15
	.cfi_restore %rbp
.LBB3_4:                                # %._crit_edge13
	retq
.Lfunc_end3:
	.size	_Z19initializeGraphZeroPii, .Lfunc_end3-_Z19initializeGraphZeroPii
	.cfi_endproc
                                        # -- End function
	.globl	_Z18constructGraphEdgePii       # -- Begin function _Z18constructGraphEdgePii
	.type	_Z18constructGraphEdgePii,@function
_Z18constructGraphEdgePii:              # @_Z18constructGraphEdgePii
	.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	$56, %rsp
	.cfi_def_cfa_offset 112
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	%esi, %ebx
	movq	%rdi, %r14
	xorl	%r15d, %r15d
	movl	$.L.str.12, %edi
	xorl	%eax, %eax
	callq	printf
	movl	%ebx, 12(%rsp)                  # 4-byte Spill
	testl	%ebx, %ebx
	jle	.LBB4_5
# %bb.1:                                # %.preheader.preheader
	movl	12(%rsp), %r12d                 # 4-byte Reload
	leaq	(,%r12,4), %r13
	leaq	4(,%r12,4), %rax
	movq	%rax, 16(%rsp)                  # 8-byte Spill
	movq	%r12, 24(%rsp)                  # 8-byte Spill
	movq	%r14, %rcx
	xorl	%ebx, %ebx
.LBB4_2:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB4_3 Depth 2
	movq	%r15, 40(%rsp)                  # 8-byte Spill
	movl	%r15d, %eax
	movq	%rcx, 32(%rsp)                  # 8-byte Spill
	leaq	(%rcx,%rax,4), %rbp
	movq	%r14, 48(%rsp)                  # 8-byte Spill
	movq	%r14, %r15
	xorl	%r14d, %r14d
.LBB4_3:                                #   Parent Loop BB4_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	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
	subl	%ecx, %eax
	movl	%eax, (%rbp,%r14,4)
	movl	%eax, (%r15)
	incq	%r14
	addq	%r13, %r15
	cmpq	%r14, %r12
	jne	.LBB4_3
# %bb.4:                                #   in Loop: Header=BB4_2 Depth=1
	incq	%rbx
	movq	32(%rsp), %rcx                  # 8-byte Reload
	addq	$4, %rcx
	movq	40(%rsp), %r15                  # 8-byte Reload
	addl	12(%rsp), %r15d                 # 4-byte Folded Reload
	movq	48(%rsp), %r14                  # 8-byte Reload
	addq	16(%rsp), %r14                  # 8-byte Folded Reload
	decq	%r12
	cmpq	24(%rsp), %rbx                  # 8-byte Folded Reload
	jne	.LBB4_2
.LBB4_5:                                # %._crit_edge
	movl	$.Lstr.5, %edi
	addq	$56, %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	puts@PLT                        # TAILCALL
.Lfunc_end4:
	.size	_Z18constructGraphEdgePii, .Lfunc_end4-_Z18constructGraphEdgePii
	.cfi_endproc
                                        # -- End function
	.globl	_Z17dijkstraCPUSerialPiS_S_ii   # -- Begin function _Z17dijkstraCPUSerialPiS_S_ii
	.type	_Z17dijkstraCPUSerialPiS_S_ii,@function
_Z17dijkstraCPUSerialPiS_S_ii:          # @_Z17dijkstraCPUSerialPiS_S_ii
	.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
	movl	%r8d, 4(%rsp)                   # 4-byte Spill
	movl	%ecx, %ebx
	movq	%rdx, %r14
	movq	%rsi, %r15
	movq	%rdi, %r12
	movl	%ecx, %r13d
	xorl	%eax, %eax
.LBB5_1:                                # %.lr.ph.i
                                        # =>This Inner Loop Header: Depth=1
	movl	$2147483647, (%r15,%rax,4)      # imm = 0x7FFFFFFF
	incq	%rax
	cmpq	$16384, %rax                    # imm = 0x4000
	jne	.LBB5_1
# %bb.2:                                # %.lr.ph.i36.preheader
	xorl	%ebp, %ebp
	movl	$65536, %edx                    # imm = 0x10000
	movq	%r14, %rdi
	xorl	%esi, %esi
	callq	memset@PLT
	movslq	4(%rsp), %rax                   # 4-byte Folded Reload
	movl	$0, (%r15,%rax,4)
	testl	%ebx, %ebx
	jle	.LBB5_14
.LBB5_3:                                # %.lr.ph.i40.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB5_4 Depth 2
                                        #     Child Loop BB5_8 Depth 2
	movl	$2147483647, %ecx               # imm = 0x7FFFFFFF
	movl	$-1, %eax
	xorl	%edx, %edx
.LBB5_4:                                # %.lr.ph.i40
                                        #   Parent Loop BB5_3 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	(%r15,%rdx,4), %esi
	cmpl	%ecx, %esi
	jge	.LBB5_6
# %bb.5:                                #   in Loop: Header=BB5_4 Depth=2
	cmpl	$0, (%r14,%rdx,4)
	cmovel	%esi, %ecx
	cmovel	%edx, %eax
.LBB5_6:                                #   in Loop: Header=BB5_4 Depth=2
	incq	%rdx
	cmpq	%rdx, %r13
	jne	.LBB5_4
# %bb.7:                                # %.lr.ph
                                        #   in Loop: Header=BB5_3 Depth=1
	cltq
	movl	$1, (%r14,%rax,4)
	movl	%eax, %ecx
	imull	%ebx, %ecx
	movslq	%ecx, %rcx
	leaq	(%r12,%rcx,4), %rcx
	xorl	%edx, %edx
.LBB5_8:                                #   Parent Loop BB5_3 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	cmpl	$1, (%r14,%rdx,4)
	je	.LBB5_12
# %bb.9:                                #   in Loop: Header=BB5_8 Depth=2
	movl	(%rcx,%rdx,4), %esi
	testl	%esi, %esi
	je	.LBB5_12
# %bb.10:                               #   in Loop: Header=BB5_8 Depth=2
	addl	(%r15,%rax,4), %esi
	cmpl	(%r15,%rdx,4), %esi
	jge	.LBB5_12
# %bb.11:                               #   in Loop: Header=BB5_8 Depth=2
	movl	%esi, (%r15,%rdx,4)
.LBB5_12:                               #   in Loop: Header=BB5_8 Depth=2
	incq	%rdx
	cmpq	%rdx, %r13
	jne	.LBB5_8
# %bb.13:                               # %._crit_edge
                                        #   in Loop: Header=BB5_3 Depth=1
	incl	%ebp
	cmpl	%r13d, %ebp
	jne	.LBB5_3
.LBB5_14:                               # %._crit_edge47
	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_end5:
	.size	_Z17dijkstraCPUSerialPiS_S_ii, .Lfunc_end5-_Z17dijkstraCPUSerialPiS_S_ii
	.cfi_endproc
                                        # -- End function
	.globl	_Z30__device_stub__closestNodeCUDAPiS_S_S_S_S_S_i # -- Begin function _Z30__device_stub__closestNodeCUDAPiS_S_S_S_S_S_i
	.type	_Z30__device_stub__closestNodeCUDAPiS_S_S_S_S_S_i,@function
_Z30__device_stub__closestNodeCUDAPiS_S_S_S_S_S_i: # @_Z30__device_stub__closestNodeCUDAPiS_S_S_S_S_S_i
	.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	$160, %rsp
	.cfi_def_cfa_offset 208
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	56(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	48(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	40(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	32(%rsp), %rdx
	movq	%rcx, (%rdx)
	leaq	24(%rsp), %rcx
	movq	%r8, (%rcx)
	leaq	16(%rsp), %r8
	movq	%r9, (%r8)
	leaq	96(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	movq	%rcx, 32(%rbx)
	movq	%r8, 40(%rbx)
	leaq	208(%rsp), %rax
	movq	%rax, 48(%rbx)
	leaq	216(%rsp), %rax
	movq	%rax, 56(%rbx)
	leaq	80(%rsp), %r14
	leaq	64(%rsp), %r15
	leaq	8(%rsp), %r12
	movq	%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	$_Z15closestNodeCUDAPiS_S_S_S_S_S_i, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$176, %rsp
	.cfi_adjust_cfa_offset -176
	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	_Z30__device_stub__closestNodeCUDAPiS_S_S_S_S_S_i, .Lfunc_end6-_Z30__device_stub__closestNodeCUDAPiS_S_S_S_S_S_i
	.cfi_endproc
                                        # -- End function
	.globl	_Z24__device_stub__cudaRelaxPiS_S_S_ # -- Begin function _Z24__device_stub__cudaRelaxPiS_S_S_
	.type	_Z24__device_stub__cudaRelaxPiS_S_S_,@function
_Z24__device_stub__cudaRelaxPiS_S_S_:   # @_Z24__device_stub__cudaRelaxPiS_S_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	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	32(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	24(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	16(%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	8(%rsp), %r12
	movq	%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	$_Z9cudaRelaxPiS_S_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_end7:
	.size	_Z24__device_stub__cudaRelaxPiS_S_S_, .Lfunc_end7-_Z24__device_stub__cudaRelaxPiS_S_S_
	.cfi_endproc
                                        # -- End function
	.globl	_Z11closestNodePiS_i            # -- Begin function _Z11closestNodePiS_i
	.type	_Z11closestNodePiS_i,@function
_Z11closestNodePiS_i:                   # @_Z11closestNodePiS_i
	.cfi_startproc
# %bb.0:
	testl	%edx, %edx
	jle	.LBB8_1
# %bb.2:                                # %.lr.ph.preheader
	movl	%edx, %ecx
	movl	$2147483647, %edx               # imm = 0x7FFFFFFF
	movl	$-1, %eax
	xorl	%r8d, %r8d
.LBB8_3:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movl	(%rdi,%r8,4), %r9d
	cmpl	%edx, %r9d
	jge	.LBB8_5
# %bb.4:                                #   in Loop: Header=BB8_3 Depth=1
	cmpl	$0, (%rsi,%r8,4)
	cmovel	%r9d, %edx
	cmovel	%r8d, %eax
.LBB8_5:                                #   in Loop: Header=BB8_3 Depth=1
	incq	%r8
	cmpq	%r8, %rcx
	jne	.LBB8_3
# %bb.6:                                # %._crit_edge
	retq
.LBB8_1:
	movl	$-1, %eax
	retq
.Lfunc_end8:
	.size	_Z11closestNodePiS_i, .Lfunc_end8-_Z11closestNodePiS_i
	.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	.LBB9_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB9_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z15closestNodeCUDAPiS_S_S_S_S_S_i, %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	$_Z9cudaRelaxPiS_S_S_, %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_end9:
	.size	__hip_module_ctor, .Lfunc_end9-__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	.LBB10_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
.LBB10_2:
	retq
.Lfunc_end10:
	.size	__hip_module_dtor, .Lfunc_end10-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	.L.str.2,@object                # @.str.2
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.2:
	.asciz	"Origin vertex: %d\n"
	.size	.L.str.2, 19

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"Running serial..."
	.size	.L.str.3, 18

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

	.type	_Z9cudaRelaxPiS_S_S_,@object    # @_Z9cudaRelaxPiS_S_S_
	.globl	_Z9cudaRelaxPiS_S_S_
	.p2align	3, 0x0
_Z9cudaRelaxPiS_S_S_:
	.quad	_Z24__device_stub__cudaRelaxPiS_S_S_
	.size	_Z9cudaRelaxPiS_S_S_, 8

	.type	.L.str.5,@object                # @.str.5
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.5:
	.asciz	"\nVertices: %d"
	.size	.L.str.5, 14

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"\n\nSerial Time (s): %.6f\n"
	.size	.L.str.6, 25

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"\n\nCUDA Time (ms): %.3f\n"
	.size	.L.str.7, 24

	.type	.L.str.10,@object               # @.str.10
.L.str.10:
	.asciz	"d_Error: Serial has %d %d, CUDA has %d %d\n"
	.size	.L.str.10, 43

	.type	.L.str.11,@object               # @.str.11
.L.str.11:
	.asciz	"--------%d dist errors found.\n"
	.size	.L.str.11, 31

	.type	.L.str.12,@object               # @.str.12
.L.str.12:
	.asciz	"Initializing a connected graph..."
	.size	.L.str.12, 34

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z15closestNodeCUDAPiS_S_S_S_S_S_i"
	.size	.L__unnamed_1, 35

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_Z9cudaRelaxPiS_S_S_"
	.size	.L__unnamed_2, 21

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

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

	.type	.Lstr,@object                   # @str
	.section	.rodata.str1.1,"aMS",@progbits,1
.Lstr:
	.asciz	"Variables created, allocated"
	.size	.Lstr, 29

	.type	.Lstr.1,@object                 # @str.1
.Lstr.1:
	.asciz	"Variables initialized."
	.size	.Lstr.1, 23

	.type	.Lstr.2,@object                 # @str.2
.Lstr.2:
	.asciz	"Done!"
	.size	.Lstr.2, 6

	.type	.Lstr.3,@object                 # @str.3
.Lstr.3:
	.asciz	"\n\nError checking:"
	.size	.Lstr.3, 18

	.type	.Lstr.4,@object                 # @str.4
.Lstr.4:
	.asciz	"----Serial vs CUDA:"
	.size	.Lstr.4, 20

	.type	.Lstr.5,@object                 # @str.5
.Lstr.5:
	.asciz	"done!"
	.size	.Lstr.5, 6

	.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__closestNodeCUDAPiS_S_S_S_S_S_i
	.addrsig_sym _Z24__device_stub__cudaRelaxPiS_S_S_
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z15closestNodeCUDAPiS_S_S_S_S_S_i
	.addrsig_sym _Z9cudaRelaxPiS_S_S_
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z15closestNodeCUDAPiS_S_S_S_S_S_i ; -- Begin function _Z15closestNodeCUDAPiS_S_S_S_S_S_i
	.globl	_Z15closestNodeCUDAPiS_S_S_S_S_S_i
	.p2align	8
	.type	_Z15closestNodeCUDAPiS_S_S_S_S_S_i,@function
_Z15closestNodeCUDAPiS_S_S_S_S_S_i:     ; @_Z15closestNodeCUDAPiS_S_S_S_S_S_i
; %bb.0:
	s_mov_b32 s16, s15
	s_clause 0x3
	s_load_b32 s17, s[0:1], 0x4c
	s_load_b32 s18, s[0:1], 0x38
	s_load_b256 s[8:15], s[0:1], 0x0
	s_load_b256 s[0:7], s[0:1], 0x20
	s_waitcnt lgkmcnt(0)
	s_mov_b32 s7, exec_lo
	s_and_b32 s6, s17, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s16, s6, v[0:1]
	v_cmpx_gt_u32_e64 s18, v1
	s_cbranch_execz .LBB0_6
; %bb.1:
	v_mov_b32_e32 v2, 0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[2:3], 2, v[1:2]
	v_add_co_u32 v4, vcc_lo, s0, v2
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v5, vcc_lo, s1, v3, vcc_lo
	s_mov_b32 s1, exec_lo
	global_load_b32 v4, v[4:5], off
	s_waitcnt vmcnt(0)
	v_cmp_eq_u32_e64 s0, 0x7fffffff, v4
	v_cmpx_ne_u32_e32 0x7fffffff, v4
	s_cbranch_execz .LBB0_3
; %bb.2:
	v_add_co_u32 v2, vcc_lo, s2, v2
	v_add_co_ci_u32_e32 v3, vcc_lo, s3, v3, vcc_lo
	s_and_not1_b32 s0, s0, exec_lo
	global_load_b32 v2, v[2:3], off
	s_waitcnt vmcnt(0)
	v_cmp_ne_u32_e32 vcc_lo, 0, v2
	s_and_b32 s17, vcc_lo, exec_lo
	s_delay_alu instid0(SALU_CYCLE_1)
	s_or_b32 s0, s0, s17
.LBB0_3:                                ; %Flow104
	s_or_b32 exec_lo, exec_lo, s1
	s_delay_alu instid0(VALU_DEP_2)
	s_and_saveexec_b32 s1, s0
; %bb.4:
	v_bfrev_b32_e32 v4, -2
	v_mov_b32_e32 v1, -1
; %bb.5:                                ; %.sink.split
	s_or_b32 exec_lo, exec_lo, s1
	v_lshlrev_b32_e32 v2, 2, v0
	ds_store_2addr_stride64_b32 v2, v1, v4 offset1:8
.LBB0_6:                                ; %Flow105
	s_or_b32 exec_lo, exec_lo, s7
	s_cmp_lt_u32 s6, 2
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	s_cbranch_scc1 .LBB0_12
; %bb.7:                                ; %.lr.ph
	v_lshlrev_b32_e32 v1, 2, v0
	s_delay_alu instid0(VALU_DEP_1)
	v_add_nc_u32_e32 v2, 0x800, v1
.LBB0_8:                                ; =>This Inner Loop Header: Depth=1
	s_mov_b32 s0, s6
	s_lshr_b32 s6, s6, 1
	s_mov_b32 s1, exec_lo
	v_cmpx_gt_u32_e64 s6, v0
	s_cbranch_execz .LBB0_11
; %bb.9:                                ;   in Loop: Header=BB0_8 Depth=1
	v_lshl_add_u32 v3, s6, 2, v2
	ds_load_b32 v3, v3
	ds_load_b32 v4, v2
	s_waitcnt lgkmcnt(0)
	v_cmp_lt_i32_e32 vcc_lo, v3, v4
	s_and_b32 exec_lo, exec_lo, vcc_lo
	s_cbranch_execz .LBB0_11
; %bb.10:                               ;   in Loop: Header=BB0_8 Depth=1
	v_lshl_add_u32 v4, s6, 2, v1
	ds_load_b32 v4, v4
	ds_store_b32 v2, v3
	s_waitcnt lgkmcnt(1)
	ds_store_b32 v1, v4
.LBB0_11:                               ;   in Loop: Header=BB0_8 Depth=1
	s_or_b32 exec_lo, exec_lo, s1
	s_cmp_gt_u32 s0, 3
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	s_cbranch_scc1 .LBB0_8
.LBB0_12:                               ; %._crit_edge
	s_mov_b32 s17, 0
	s_mov_b32 s20, exec_lo
	v_cmpx_eq_u32_e32 0, v0
	s_cbranch_execz .LBB0_21
; %bb.13:
	v_mov_b32_e32 v0, 0
	s_lshl_b64 s[0:1], s[16:17], 2
	s_delay_alu instid0(SALU_CYCLE_1)
	s_add_u32 s6, s14, s0
	s_addc_u32 s7, s15, s1
	ds_load_2addr_stride64_b32 v[1:2], v0 offset1:8
	s_add_u32 s0, s12, s0
	s_addc_u32 s1, s13, s1
	s_cmp_lg_u32 s16, 0
	s_waitcnt lgkmcnt(0)
	s_clause 0x1
	global_store_b32 v0, v2, s[0:1]
	global_store_b32 v0, v1, s[6:7]
	s_cbranch_scc1 .LBB0_21
; %bb.14:                               ; %.preheader.preheader
	s_mov_b32 s0, 16
.LBB0_15:                               ; %.preheader
                                        ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB0_16 Depth 2
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_2) | instid1(SALU_CYCLE_1)
	s_ashr_i32 s1, s0, 31
	s_mov_b64 s[16:17], 0
	s_lshl_b64 s[6:7], s[0:1], 2
	s_add_u32 s1, s12, s6
	s_addc_u32 s21, s13, s7
	s_add_u32 s22, s14, s6
	s_addc_u32 s7, s15, s7
.LBB0_16:                               ; %.lr.ph67
                                        ;   Parent Loop BB0_15 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	s_add_u32 s24, s1, s16
	s_addc_u32 s25, s21, s17
	s_add_u32 s18, s12, s16
	s_addc_u32 s19, s13, s17
	s_clause 0x1
	global_load_b32 v1, v0, s[24:25]
	global_load_b32 v2, v0, s[18:19]
	s_waitcnt vmcnt(0)
	v_cmp_ge_i32_e32 vcc_lo, v1, v2
	s_cbranch_vccnz .LBB0_18
; %bb.17:                               ;   in Loop: Header=BB0_16 Depth=2
	s_add_u32 s24, s14, s16
	s_addc_u32 s25, s15, s17
	s_add_u32 s26, s22, s16
	s_addc_u32 s27, s7, s17
	global_store_b32 v0, v1, s[18:19]
	global_load_b32 v1, v0, s[26:27]
	s_waitcnt vmcnt(0)
	global_store_b32 v0, v1, s[24:25]
.LBB0_18:                               ;   in Loop: Header=BB0_16 Depth=2
	s_add_u32 s16, s16, 4
	s_addc_u32 s17, s17, 0
	s_cmp_eq_u32 s6, s16
	s_cbranch_scc0 .LBB0_16
; %bb.19:                               ; %._crit_edge68
                                        ;   in Loop: Header=BB0_15 Depth=1
	s_lshr_b32 s1, s0, 1
	s_cmp_lt_u32 s0, 2
	s_mov_b32 s0, s1
	s_waitcnt_vscnt null, 0x0
	s_barrier
	buffer_gl0_inv
	s_cbranch_scc0 .LBB0_15
; %bb.20:                               ; %.critedge
	v_mov_b32_e32 v0, 0
	v_mov_b32_e32 v2, 1
	global_load_b32 v1, v0, s[12:13]
	s_waitcnt vmcnt(0)
	global_store_b32 v0, v1, s[8:9]
	global_load_b32 v1, v0, s[14:15]
	s_waitcnt vmcnt(0)
	s_clause 0x1
	global_store_b32 v0, v1, s[10:11]
	global_store_b32 v0, v1, s[4:5]
	global_load_b32 v0, v0, s[10:11]
	s_waitcnt vmcnt(0)
	v_ashrrev_i32_e32 v1, 31, v0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[0:1], 2, v[0:1]
	v_add_co_u32 v0, vcc_lo, s2, v0
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v1, vcc_lo, s3, v1, vcc_lo
	global_store_b32 v[0:1], v2, off
.LBB0_21:                               ; %.critedge60
	s_or_b32 exec_lo, exec_lo, s20
	s_waitcnt_vscnt null, 0x0
	s_barrier
	buffer_gl0_inv
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z15closestNodeCUDAPiS_S_S_S_S_S_i
		.amdhsa_group_segment_fixed_size 4096
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 320
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 6
		.amdhsa_next_free_sgpr 28
		.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	_Z15closestNodeCUDAPiS_S_S_S_S_S_i, .Lfunc_end0-_Z15closestNodeCUDAPiS_S_S_S_S_S_i
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 800
; NumSgprs: 30
; NumVgprs: 6
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 4096 bytes/workgroup (compile time only)
; SGPRBlocks: 3
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 30
; NumVGPRsForWavesPerEU: 6
; 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	_Z9cudaRelaxPiS_S_S_    ; -- Begin function _Z9cudaRelaxPiS_S_S_
	.globl	_Z9cudaRelaxPiS_S_S_
	.p2align	8
	.type	_Z9cudaRelaxPiS_S_S_,@function
_Z9cudaRelaxPiS_S_S_:                   ; @_Z9cudaRelaxPiS_S_S_
; %bb.0:
	s_clause 0x1
	s_load_b256 s[4:11], s[0:1], 0x0
	s_load_b32 s1, s[0:1], 0x2c
	s_waitcnt lgkmcnt(0)
	s_load_b32 s0, s[10:11], 0x0
	s_and_b32 s1, s1, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s15, s1, v[0:1]
	s_mov_b32 s1, exec_lo
	s_waitcnt lgkmcnt(0)
	v_lshl_add_u32 v2, s0, 14, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v3, 31, v2
	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 v2, vcc_lo, s4, v2
	v_add_co_ci_u32_e32 v3, vcc_lo, s5, v3, vcc_lo
	global_load_b32 v3, v[2:3], off
	s_waitcnt vmcnt(0)
	v_cmpx_ne_u32_e32 0, v3
	s_cbranch_execz .LBB1_4
; %bb.1:
	v_ashrrev_i32_e32 v2, 31, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[0:1], 2, v[1:2]
	v_add_co_u32 v4, vcc_lo, s8, v0
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v5, vcc_lo, s9, v1, vcc_lo
	global_load_b32 v2, v[4:5], off
	s_waitcnt vmcnt(0)
	v_cmp_ne_u32_e32 vcc_lo, 1, v2
	s_and_b32 exec_lo, exec_lo, vcc_lo
	s_cbranch_execz .LBB1_4
; %bb.2:
	v_add_co_u32 v0, vcc_lo, s6, v0
	v_add_co_ci_u32_e32 v1, vcc_lo, s7, v1, vcc_lo
	s_ashr_i32 s1, s0, 31
	s_delay_alu instid0(SALU_CYCLE_1)
	s_lshl_b64 s[0:1], s[0:1], 2
	global_load_b32 v4, v[0:1], off
	s_add_u32 s0, s6, s0
	s_addc_u32 s1, s7, s1
	s_load_b32 s0, s[0:1], 0x0
	s_waitcnt lgkmcnt(0)
	v_add_nc_u32_e32 v2, s0, v3
	s_waitcnt vmcnt(0)
	s_delay_alu instid0(VALU_DEP_1)
	v_cmp_lt_i32_e32 vcc_lo, v2, v4
	s_and_b32 exec_lo, exec_lo, vcc_lo
	s_cbranch_execz .LBB1_4
; %bb.3:
	global_store_b32 v[0:1], v2, off
.LBB1_4:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z9cudaRelaxPiS_S_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 6
		.amdhsa_next_free_sgpr 16
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end1:
	.size	_Z9cudaRelaxPiS_S_S_, .Lfunc_end1-_Z9cudaRelaxPiS_S_S_
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 272
; NumSgprs: 18
; NumVgprs: 6
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 6
; Occupancy: 16
; WaveLimiterHint : 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
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __hip_cuid_
	.amdgpu_metadata
---
amdhsa.kernels:
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         16
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         24
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         32
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         40
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         48
        .size:           8
        .value_kind:     global_buffer
      - .offset:         56
        .size:           4
        .value_kind:     by_value
      - .offset:         64
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         68
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         72
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         76
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         78
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         80
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         82
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         84
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         86
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         104
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         112
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         120
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         128
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 4096
    .kernarg_segment_align: 8
    .kernarg_segment_size: 320
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z15closestNodeCUDAPiS_S_S_S_S_S_i
    .private_segment_fixed_size: 0
    .sgpr_count:     30
    .sgpr_spill_count: 0
    .symbol:         _Z15closestNodeCUDAPiS_S_S_S_S_S_i.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     6
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         16
        .size:           8
        .value_kind:     global_buffer
      - .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:           _Z9cudaRelaxPiS_S_S_
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z9cudaRelaxPiS_S_S_.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     6
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
