
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>

#define MAX_THREADS 1024

//declerations
cudaError_t matchWithGPU(int* results, double* points, int* signs, double* w, int numOfPoints, int k);

cudaError_t updateLocationsWithGPU(double* locations, double* velocity, int numOfPoints, int k, double t);

void checkError_locations(cudaError_t cudaStatus, double* dev_locations, double* dev_velocity, const char* errorMessage);

void freeCudaMemory_locations(double* dev_locations, double* dev_velocity);

void freeCudaMemory_match(int* dev_results, double* dev_points, int* dev_signs, double* dev_w);

void checkError_match(cudaError_t cudaStatus, int* dev_results, double* dev_points, int* dev_signs, double* dev_w, const char* errorMessage);

__device__ int signGPU(double f);

__device__ double fGPU(const double* p, int offset, const double* w, int k);


// implmentations

//changes results at a given index to 1 if the test fails
__global__ void matchKernel(int* results, const double* points, const int* signs, const double* w, int numOfPoints, int k)
{
	int index = threadIdx.x + blockIdx.x * blockDim.x; //calculate index of each element in array
	int value = signGPU(fGPU(points, index*k, w, k));

	if (value != signs[index])
		results[index] = 1;
}

//updates the location at index based on location=location0 +velocity * t
__global__ void updateLocationsKernel(double* location, const double* velocity, double t)
{
	int index = threadIdx.x + blockIdx.x * blockDim.x; //calculate index of each element in array

	location[index] = location[index] + velocity[index] * t;
}

//function to free all arrays related to the match part of CUDA
void freeCudaMemory_match(int* dev_results, double* dev_points, int* dev_signs, double* dev_w)
{
	cudaFree(dev_results);
	cudaFree(dev_points);
	cudaFree(dev_signs);
	cudaFree(dev_w);
}

//function responsible to handle errors in the match part of CUDA
void checkError_match(cudaError_t cudaStatus, int* dev_results, double* dev_points, int* dev_signs, double* dev_w, const char* errorMessage)
{
	if (cudaStatus != cudaSuccess) {
		fprintf(stderr, errorMessage);
		fprintf(stderr, "\n");
		freeCudaMemory_match(dev_results, dev_points, dev_signs, dev_w);
	}
}

//tests all points to see if they're in the place they should be
cudaError_t matchWithGPU(int* results, double* points, int* signs, double* w, int numOfPoints, int k)
{
	char errorBuffer[100];
	int* dev_results = 0;
	double* dev_points = 0;
	int* dev_signs = 0;
	double* dev_w = 0;
	int extra = 0;
	int numOfBlocks, numOfThreads;
	cudaError_t cudaStatus;

	// Choose which GPU to run on, change this on a multi-GPU system.
	cudaStatus = cudaSetDevice(0);
	checkError_match(cudaStatus, dev_results, dev_points, dev_signs, dev_w, "cudaSetDevice failed!  Do you have a CUDA-capable GPU installed?");

	// Allocate GPU buffers for every array
	cudaStatus = cudaMalloc((void**)&dev_results, numOfPoints * sizeof(int));
	checkError_match(cudaStatus, dev_results, dev_points, dev_signs, dev_w, "cudaMalloc failed!");

	cudaStatus = cudaMalloc((void**)&dev_points, numOfPoints * k * sizeof(double));
	checkError_match(cudaStatus, dev_results, dev_points, dev_signs, dev_w, "cudaMalloc failed!");

	cudaStatus = cudaMalloc((void**)&dev_signs, numOfPoints * sizeof(int));
	checkError_match(cudaStatus, dev_results, dev_points, dev_signs, dev_w, "cudaMalloc failed!");

	cudaStatus = cudaMalloc((void**)&dev_w, k * sizeof(double));
	checkError_match(cudaStatus, dev_results, dev_points, dev_signs, dev_w, "cudaMalloc failed!");

	// Copy input arrays from host memory to GPU buffers.
	cudaStatus = cudaMemcpy(dev_points, points, numOfPoints * k * sizeof(double), cudaMemcpyHostToDevice);
	checkError_match(cudaStatus, dev_results, dev_points, dev_signs, dev_w, "cudaMemcpy failed!");

	cudaStatus = cudaMemcpy(dev_signs, signs, numOfPoints * sizeof(int), cudaMemcpyHostToDevice);
	checkError_match(cudaStatus, dev_results, dev_points, dev_signs, dev_w, "cudaMemcpy failed!");

	cudaStatus = cudaMemcpy(dev_w, w, k * sizeof(double), cudaMemcpyHostToDevice);
	checkError_match(cudaStatus, dev_results, dev_points, dev_signs, dev_w, "cudaMemcpy failed!");

	// Calculate the number of blocks and threads needed.
	extra = numOfPoints % MAX_THREADS != 0 ? 1 : 0;
	numOfBlocks = (numOfPoints / MAX_THREADS + extra);
	numOfThreads = MAX_THREADS>numOfPoints ? numOfPoints : MAX_THREADS;

	// Launch a kernel on the GPU with one thread for each element.
	matchKernel<<<numOfBlocks, numOfThreads >>>(dev_results, dev_points, dev_signs, dev_w, numOfPoints, k);

	// Check for any errors launching the kernel
	cudaStatus = cudaGetLastError();
	sprintf(errorBuffer, "matchKernel launch failed: %s\n", cudaGetErrorString(cudaStatus));
	checkError_match(cudaStatus, dev_results, dev_points, dev_signs, dev_w, errorBuffer);

	// cudaDeviceSynchronize waits for the kernel to finish, and returns any errors encountered during the launch.
	cudaStatus = cudaDeviceSynchronize();
	sprintf(errorBuffer, "cudaDeviceSynchronize returned error code %d after launching addKernel!\n", cudaStatus);
	checkError_match(cudaStatus, dev_results, dev_points, dev_signs, dev_w, errorBuffer);

	// Copy output vector from GPU buffer to host memory.
	cudaStatus = cudaMemcpy(results, dev_results, numOfPoints * sizeof(int), cudaMemcpyDeviceToHost);
	checkError_match(cudaStatus, dev_results, dev_points, dev_signs, dev_w, "cudaMemcpy failed!");

	freeCudaMemory_match(dev_results, dev_points, dev_signs, dev_w);

	return cudaStatus;
}

//checks the sign of a given double
__device__ int signGPU(double f)
{
	if (f < 0)
		return -1;
	return 1;
}

//calculates f based on the algorithm
__device__ double fGPU(const double* p, int offset, const double* w, int k)
{
	int i;
	double result = 0;

	for (i = 0; i < k; i++)
	{
		result += w[i] * p[offset + i];
	}

	return result;
}

//updates the locations vector to its new position based on time and velocity
cudaError_t updateLocationsWithGPU(double* locations, double* velocity, int numOfPoints, int k, double t)
{
	char errorBuffer[100];
	double* dev_locations = 0;
	double* dev_velocity = 0;
	int extra;
	int numOfBlocks, numOfThreads;
	cudaError_t cudaStatus;

	// Choose which GPU to run on, change this on a multi-GPU system.
	cudaStatus = cudaSetDevice(0);
	checkError_locations(cudaStatus, dev_locations, dev_velocity, "cudaSetDevice failed!  Do you have a CUDA-capable GPU installed?");

	// Allocate GPU buffers for the arrays
	cudaStatus = cudaMalloc((void**)&dev_locations, numOfPoints * k * sizeof(double));
	checkError_locations(cudaStatus, dev_locations, dev_velocity, "cudaMalloc failed!");

	cudaStatus = cudaMalloc((void**)&dev_velocity, numOfPoints * k * sizeof(double));
	checkError_locations(cudaStatus, dev_locations, dev_velocity, "cudaMalloc failed!");

	// Copy input vector from host memory to GPU buffers.
	cudaStatus = cudaMemcpy(dev_locations, locations, numOfPoints * k * sizeof(double), cudaMemcpyHostToDevice);
	checkError_locations(cudaStatus, dev_locations, dev_velocity, "cudaMemcpy failed!");

	cudaStatus = cudaMemcpy(dev_velocity, velocity, numOfPoints * k * sizeof(double), cudaMemcpyHostToDevice);
	checkError_locations(cudaStatus, dev_locations, dev_velocity, "cudaMemcpy failed!");

	// Calculate the number of blocks and threads needed.
	extra = (numOfPoints*k) % MAX_THREADS != 0 ? 1 : 0;
	numOfBlocks = ((numOfPoints*k) / MAX_THREADS + extra);
	numOfThreads = MAX_THREADS>(numOfPoints*k) ? (numOfPoints*k) : MAX_THREADS;

	// Launch a kernel on the GPU with one thread for each element. Each calculating a dimension in a point, going over all points
	updateLocationsKernel<<<numOfBlocks, numOfThreads>>>(dev_locations, dev_velocity, t);

	// Check for any errors launching the kernel
	cudaStatus = cudaGetLastError();
	sprintf(errorBuffer, "addKernel launch failed: %s\n", cudaGetErrorString(cudaStatus));
	checkError_locations(cudaStatus, dev_locations, dev_velocity, "cudaMemcpy failed!");

	// cudaDeviceSynchronize waits for the kernel to finish, and returns any errors encountered during the launch.
	cudaStatus = cudaDeviceSynchronize();
	sprintf(errorBuffer, "cudaDeviceSynchronize returned error code %d after launching addKernel!\n", cudaStatus);
	checkError_locations(cudaStatus, dev_locations, dev_velocity, "cudaMemcpy failed!");

	// Copy output vector from GPU buffer to host memory.
	// In this case, overwrite the locations array on host memory with the updated one
	cudaStatus = cudaMemcpy(locations, dev_locations, numOfPoints * k * sizeof(double), cudaMemcpyDeviceToHost);
	checkError_locations(cudaStatus, dev_locations, dev_velocity, "cudaMemcpy failed!");

	freeCudaMemory_locations(dev_locations, dev_velocity);

	return cudaStatus;
}

//function responsible to handle errors in the update locations part of CUDA
void checkError_locations(cudaError_t cudaStatus, double* dev_locations, double* dev_velocity, const char* errorMessage)
{
	if (cudaStatus != cudaSuccess)
	{
		fprintf(stderr, errorMessage);
		fprintf(stderr, "\n");
		freeCudaMemory_locations(dev_locations, dev_velocity);
	}
}

//function responsible to handle errors in the update locations part of CUDA
void freeCudaMemory_locations(double* dev_locations, double* dev_velocity)
{
	cudaFree(dev_locations);
	cudaFree(dev_velocity);
}
	.file	"tmpxft_00252cb0_00000000-6_kernel.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2037:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2037:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z20freeCudaMemory_matchPiPdS_S0_
	.type	_Z20freeCudaMemory_matchPiPdS_S0_, @function
_Z20freeCudaMemory_matchPiPdS_S0_:
.LFB2027:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movq	%rsi, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movq	%rdx, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	movq	%rcx, %rbx
	call	cudaFree@PLT
	movq	%r12, %rdi
	call	cudaFree@PLT
	movq	%rbp, %rdi
	call	cudaFree@PLT
	movq	%rbx, %rdi
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	jmp	cudaFree@PLT
	.cfi_endproc
.LFE2027:
	.size	_Z20freeCudaMemory_matchPiPdS_S0_, .-_Z20freeCudaMemory_matchPiPdS_S0_
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"\n"
	.text
	.globl	_Z16checkError_match9cudaErrorPiPdS0_S1_PKc
	.type	_Z16checkError_match9cudaErrorPiPdS0_S1_PKc, @function
_Z16checkError_match9cudaErrorPiPdS0_S1_PKc:
.LFB2028:
	.cfi_startproc
	endbr64
	testl	%edi, %edi
	je	.L4
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	movq	%r8, %r13
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	movq	%rcx, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	movq	%rdx, %rbp
	movq	%r9, %rdx
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	movq	%rsi, %rbx
	movl	$2, %esi
	pushq	%rax
	.cfi_def_cfa_offset 48
	movq	stderr(%rip), %rdi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	movq	stderr(%rip), %rdi
	leaq	.LC0(%rip), %rdx
	xorl	%eax, %eax
	movl	$2, %esi
	call	__fprintf_chk@PLT
	popq	%r8
	.cfi_def_cfa_offset 40
	movq	%r13, %rcx
	movq	%r12, %rdx
	movq	%rbp, %rsi
	movq	%rbx, %rdi
	popq	%rbx
	.cfi_restore 3
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_restore 6
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_restore 12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_restore 13
	.cfi_def_cfa_offset 8
	jmp	_Z20freeCudaMemory_matchPiPdS_S0_
.L4:
	ret
	.cfi_endproc
.LFE2028:
	.size	_Z16checkError_match9cudaErrorPiPdS0_S1_PKc, .-_Z16checkError_match9cudaErrorPiPdS0_S1_PKc
	.globl	_Z7signGPUd
	.type	_Z7signGPUd, @function
_Z7signGPUd:
.LFB2030:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE2030:
	.size	_Z7signGPUd, .-_Z7signGPUd
	.globl	_Z4fGPUPKdiS0_i
	.type	_Z4fGPUPKdiS0_i, @function
_Z4fGPUPKdiS0_i:
.LFB2031:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE2031:
	.size	_Z4fGPUPKdiS0_i, .-_Z4fGPUPKdiS0_i
	.globl	_Z24freeCudaMemory_locationsPdS_
	.type	_Z24freeCudaMemory_locationsPdS_, @function
_Z24freeCudaMemory_locationsPdS_:
.LFB2034:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	movq	%rsi, %rbx
	call	cudaFree@PLT
	movq	%rbx, %rdi
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	cudaFree@PLT
	.cfi_endproc
.LFE2034:
	.size	_Z24freeCudaMemory_locationsPdS_, .-_Z24freeCudaMemory_locationsPdS_
	.globl	_Z20checkError_locations9cudaErrorPdS0_PKc
	.type	_Z20checkError_locations9cudaErrorPdS0_PKc, @function
_Z20checkError_locations9cudaErrorPdS0_PKc:
.LFB2033:
	.cfi_startproc
	endbr64
	testl	%edi, %edi
	je	.L16
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rdx, %rbp
	movq	%rcx, %rdx
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	movq	%rsi, %rbx
	movl	$2, %esi
	pushq	%rax
	.cfi_def_cfa_offset 32
	movq	stderr(%rip), %rdi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	movq	stderr(%rip), %rdi
	leaq	.LC0(%rip), %rdx
	xorl	%eax, %eax
	movl	$2, %esi
	call	__fprintf_chk@PLT
	popq	%rdx
	.cfi_def_cfa_offset 24
	movq	%rbp, %rsi
	movq	%rbx, %rdi
	popq	%rbx
	.cfi_restore 3
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_restore 6
	.cfi_def_cfa_offset 8
	jmp	_Z24freeCudaMemory_locationsPdS_
.L16:
	ret
	.cfi_endproc
.LFE2033:
	.size	_Z20checkError_locations9cudaErrorPdS0_PKc, .-_Z20checkError_locations9cudaErrorPdS0_PKc
	.globl	_Z42__device_stub__Z11matchKernelPiPKdPKiS1_iiPiPKdPKiS1_ii
	.type	_Z42__device_stub__Z11matchKernelPiPKdPKiS1_iiPiPKdPKiS1_ii, @function
_Z42__device_stub__Z11matchKernelPiPKdPKiS1_iiPiPKdPKiS1_ii:
.LFB2059:
	.cfi_startproc
	endbr64
	subq	$184, %rsp
	.cfi_def_cfa_offset 192
	movq	%rdi, 40(%rsp)
	leaq	72(%rsp), %rdi
	movq	%rsi, 32(%rsp)
	leaq	84(%rsp), %rsi
	movq	%rdx, 24(%rsp)
	leaq	56(%rsp), %rdx
	movq	%rcx, 16(%rsp)
	leaq	64(%rsp), %rcx
	movl	%r8d, 12(%rsp)
	movl	%r9d, 8(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 168(%rsp)
	xorl	%eax, %eax
	leaq	40(%rsp), %rax
	movl	$1, 80(%rsp)
	movq	%rax, 120(%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 128(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 136(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 144(%rsp)
	leaq	12(%rsp), %rax
	movq	%rax, 152(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 160(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 72(%rsp)
	movq	%rax, 84(%rsp)
	movl	$1, 92(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L21
	pushq	64(%rsp)
	.cfi_def_cfa_offset 200
	leaq	_Z11matchKernelPiPKdPKiS1_ii(%rip), %rdi
	pushq	64(%rsp)
	.cfi_def_cfa_offset 208
	movq	100(%rsp), %rcx
	movl	108(%rsp), %r8d
	movq	88(%rsp), %rsi
	movl	96(%rsp), %edx
	leaq	136(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 200
	popq	%rdx
	.cfi_def_cfa_offset 192
.L21:
	movq	168(%rsp), %rax
	subq	%fs:40, %rax
	je	.L23
	call	__stack_chk_fail@PLT
.L23:
	addq	$184, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2059:
	.size	_Z42__device_stub__Z11matchKernelPiPKdPKiS1_iiPiPKdPKiS1_ii, .-_Z42__device_stub__Z11matchKernelPiPKdPKiS1_iiPiPKdPKiS1_ii
	.globl	_Z11matchKernelPiPKdPKiS1_ii
	.type	_Z11matchKernelPiPKdPKiS1_ii, @function
_Z11matchKernelPiPKdPKiS1_ii:
.LFB2060:
	.cfi_startproc
	endbr64
	jmp	_Z42__device_stub__Z11matchKernelPiPKdPKiS1_iiPiPKdPKiS1_ii
	.cfi_endproc
.LFE2060:
	.size	_Z11matchKernelPiPKdPKiS1_ii, .-_Z11matchKernelPiPKdPKiS1_ii
	.section	.rodata.str1.1
.LC1:
	.string	"cudaSetDevice failed!  Do you have a CUDA-capable GPU installed?"
.LC2:
	.string	"cudaMalloc failed!"
.LC3:
	.string	"cudaMemcpy failed!"
.LC4:
	.string	"matchKernel launch failed: %s\n"
.LC5:
	.string	"cudaDeviceSynchronize returned error code %d after launching addKernel!\n"
	.text
	.globl	_Z12matchWithGPUPiPdS_S0_ii
	.type	_Z12matchWithGPUPiPdS_S0_ii, @function
_Z12matchWithGPUPiPdS_S0_ii:
.LFB2029:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movq	%rsi, %r15
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movq	%rdx, %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%rcx, %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movq	%rdi, %r12
	xorl	%edi, %edi
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movl	%r9d, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movl	%r8d, %ebx
	subq	$216, %rsp
	.cfi_def_cfa_offset 272
	movq	%fs:40, %rax
	movq	%rax, 200(%rsp)
	xorl	%eax, %eax
	xorl	%eax, %eax
	movq	%rax, 40(%rsp)
	movq	%rax, 48(%rsp)
	movq	%rax, 56(%rsp)
	movq	%rax, 64(%rsp)
	call	cudaSetDevice@PLT
	movq	64(%rsp), %r8
	movq	56(%rsp), %rcx
	leaq	.LC1(%rip), %r9
	movq	48(%rsp), %rdx
	movq	40(%rsp), %rsi
	movl	%eax, %edi
	call	_Z16checkError_match9cudaErrorPiPdS0_S1_PKc
	movslq	%ebx, %rax
	leaq	40(%rsp), %rdi
	salq	$2, %rax
	movq	%rax, %rsi
	movq	%rax, 8(%rsp)
	call	cudaMalloc@PLT
	movq	64(%rsp), %r8
	movq	56(%rsp), %rcx
	leaq	.LC2(%rip), %r9
	movq	48(%rsp), %rdx
	movq	40(%rsp), %rsi
	movl	%eax, %edi
	call	_Z16checkError_match9cudaErrorPiPdS0_S1_PKc
	movl	%ebx, %eax
	leaq	48(%rsp), %rdi
	imull	%ebp, %eax
	cltq
	salq	$3, %rax
	movq	%rax, %rsi
	movq	%rax, 16(%rsp)
	call	cudaMalloc@PLT
	movq	64(%rsp), %r8
	movq	56(%rsp), %rcx
	leaq	.LC2(%rip), %r9
	movq	48(%rsp), %rdx
	movq	40(%rsp), %rsi
	movl	%eax, %edi
	call	_Z16checkError_match9cudaErrorPiPdS0_S1_PKc
	movq	8(%rsp), %rsi
	leaq	56(%rsp), %rdi
	call	cudaMalloc@PLT
	movq	64(%rsp), %r8
	movq	56(%rsp), %rcx
	leaq	.LC2(%rip), %r9
	movq	48(%rsp), %rdx
	movq	40(%rsp), %rsi
	movl	%eax, %edi
	call	_Z16checkError_match9cudaErrorPiPdS0_S1_PKc
	movslq	%ebp, %rax
	leaq	64(%rsp), %rdi
	salq	$3, %rax
	movq	%rax, %rsi
	movq	%rax, 24(%rsp)
	call	cudaMalloc@PLT
	movq	64(%rsp), %r8
	movq	56(%rsp), %rcx
	leaq	.LC2(%rip), %r9
	movq	48(%rsp), %rdx
	movq	40(%rsp), %rsi
	movl	%eax, %edi
	call	_Z16checkError_match9cudaErrorPiPdS0_S1_PKc
	movq	16(%rsp), %rdx
	movq	48(%rsp), %rdi
	movq	%r15, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movq	64(%rsp), %r8
	movq	56(%rsp), %rcx
	leaq	.LC3(%rip), %r9
	movq	48(%rsp), %rdx
	movq	40(%rsp), %rsi
	movl	%eax, %edi
	call	_Z16checkError_match9cudaErrorPiPdS0_S1_PKc
	movq	8(%rsp), %rdx
	movq	56(%rsp), %rdi
	movq	%r14, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movq	64(%rsp), %r8
	movq	56(%rsp), %rcx
	leaq	.LC3(%rip), %r9
	movq	48(%rsp), %rdx
	movq	40(%rsp), %rsi
	movl	%eax, %edi
	call	_Z16checkError_match9cudaErrorPiPdS0_S1_PKc
	movq	24(%rsp), %rdx
	movq	64(%rsp), %rdi
	movq	%r13, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movq	64(%rsp), %r8
	movq	56(%rsp), %rcx
	leaq	.LC3(%rip), %r9
	movq	48(%rsp), %rdx
	movq	40(%rsp), %rsi
	movl	%eax, %edi
	call	_Z16checkError_match9cudaErrorPiPdS0_S1_PKc
	movl	$1024, %eax
	movl	$1024, %edi
	movabsq	$4294967297, %rsi
	cmpl	%eax, %ebx
	movq	%rsi, 92(%rsp)
	cmovle	%ebx, %eax
	xorl	%ecx, %ecx
	testl	$1023, %ebx
	movq	%rsi, 80(%rsp)
	setne	%cl
	movl	84(%rsp), %esi
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	%eax, 88(%rsp)
	movl	%ebx, %eax
	cltd
	idivl	%edi
	movq	88(%rsp), %rdx
	addl	%eax, %ecx
	movl	%ecx, 76(%rsp)
	movl	96(%rsp), %ecx
	movq	76(%rsp), %rdi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L27
	movq	64(%rsp), %rcx
	movq	56(%rsp), %rdx
	movl	%ebp, %r9d
	movl	%ebx, %r8d
	movq	48(%rsp), %rsi
	movq	40(%rsp), %rdi
	call	_Z42__device_stub__Z11matchKernelPiPKdPKiS1_iiPiPKdPKiS1_ii
.L27:
	call	cudaGetLastError@PLT
	leaq	100(%rsp), %rbp
	movl	%eax, %edi
	movl	%eax, %ebx
	call	cudaGetErrorString@PLT
	leaq	.LC4(%rip), %rcx
	movl	$100, %edx
	movq	%rbp, %rdi
	movq	%rax, %r8
	movl	$2, %esi
	xorl	%eax, %eax
	call	__sprintf_chk@PLT
	movq	64(%rsp), %r8
	movq	%rbp, %r9
	movl	%ebx, %edi
	movq	56(%rsp), %rcx
	movq	48(%rsp), %rdx
	movq	40(%rsp), %rsi
	call	_Z16checkError_match9cudaErrorPiPdS0_S1_PKc
	call	cudaDeviceSynchronize@PLT
	leaq	.LC5(%rip), %rcx
	movl	$100, %edx
	movq	%rbp, %rdi
	movl	%eax, %ebx
	movl	%eax, %r8d
	movl	$2, %esi
	xorl	%eax, %eax
	call	__sprintf_chk@PLT
	movq	64(%rsp), %r8
	movq	%rbp, %r9
	movl	%ebx, %edi
	movq	56(%rsp), %rcx
	movq	48(%rsp), %rdx
	movq	40(%rsp), %rsi
	call	_Z16checkError_match9cudaErrorPiPdS0_S1_PKc
	movq	8(%rsp), %rdx
	movq	40(%rsp), %rsi
	movq	%r12, %rdi
	movl	$2, %ecx
	call	cudaMemcpy@PLT
	movq	56(%rsp), %rcx
	movq	48(%rsp), %rdx
	leaq	.LC3(%rip), %r9
	movq	40(%rsp), %rsi
	movq	64(%rsp), %r8
	movl	%eax, %edi
	movl	%eax, %ebx
	call	_Z16checkError_match9cudaErrorPiPdS0_S1_PKc
	movq	64(%rsp), %rcx
	movq	56(%rsp), %rdx
	movq	48(%rsp), %rsi
	movq	40(%rsp), %rdi
	call	_Z20freeCudaMemory_matchPiPdS_S0_
	movq	200(%rsp), %rax
	subq	%fs:40, %rax
	je	.L28
	call	__stack_chk_fail@PLT
.L28:
	addq	$216, %rsp
	.cfi_def_cfa_offset 56
	movl	%ebx, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2029:
	.size	_Z12matchWithGPUPiPdS_S0_ii, .-_Z12matchWithGPUPiPdS_S0_ii
	.globl	_Z45__device_stub__Z21updateLocationsKernelPdPKddPdPKdd
	.type	_Z45__device_stub__Z21updateLocationsKernelPdPKddPdPKdd, @function
_Z45__device_stub__Z21updateLocationsKernelPdPKddPdPKdd:
.LFB2061:
	.cfi_startproc
	endbr64
	subq	$136, %rsp
	.cfi_def_cfa_offset 144
	movq	%rdi, 24(%rsp)
	leaq	40(%rsp), %rcx
	leaq	32(%rsp), %rdx
	movq	%rsi, 16(%rsp)
	leaq	48(%rsp), %rdi
	leaq	60(%rsp), %rsi
	movsd	%xmm0, 8(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 120(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 56(%rsp)
	movq	%rax, 96(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 104(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 112(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 48(%rsp)
	movq	%rax, 60(%rsp)
	movl	$1, 68(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L30
	pushq	40(%rsp)
	.cfi_def_cfa_offset 152
	leaq	_Z21updateLocationsKernelPdPKdd(%rip), %rdi
	pushq	40(%rsp)
	.cfi_def_cfa_offset 160
	movq	76(%rsp), %rcx
	movl	84(%rsp), %r8d
	movq	64(%rsp), %rsi
	movl	72(%rsp), %edx
	leaq	112(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 152
	popq	%rdx
	.cfi_def_cfa_offset 144
.L30:
	movq	120(%rsp), %rax
	subq	%fs:40, %rax
	je	.L32
	call	__stack_chk_fail@PLT
.L32:
	addq	$136, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2061:
	.size	_Z45__device_stub__Z21updateLocationsKernelPdPKddPdPKdd, .-_Z45__device_stub__Z21updateLocationsKernelPdPKddPdPKdd
	.globl	_Z21updateLocationsKernelPdPKdd
	.type	_Z21updateLocationsKernelPdPKdd, @function
_Z21updateLocationsKernelPdPKdd:
.LFB2062:
	.cfi_startproc
	endbr64
	jmp	_Z45__device_stub__Z21updateLocationsKernelPdPKddPdPKdd
	.cfi_endproc
.LFE2062:
	.size	_Z21updateLocationsKernelPdPKdd, .-_Z21updateLocationsKernelPdPKdd
	.section	.rodata.str1.1
.LC6:
	.string	"addKernel launch failed: %s\n"
	.text
	.globl	_Z22updateLocationsWithGPUPdS_iid
	.type	_Z22updateLocationsWithGPUPdS_iid, @function
_Z22updateLocationsWithGPUPdS_iid:
.LFB2032:
	.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	%rdi, %r13
	xorl	%edi, %edi
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	leaq	.LC2(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	movl	%ecx, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	movl	%edx, %ebx
	imull	%ebp, %ebx
	subq	$176, %rsp
	.cfi_def_cfa_offset 224
	movsd	%xmm0, 8(%rsp)
	movslq	%ebx, %rbp
	movq	%fs:40, %rax
	movq	%rax, 168(%rsp)
	xorl	%eax, %eax
	xorl	%eax, %eax
	salq	$3, %rbp
	movq	%rax, 24(%rsp)
	movq	%rax, 32(%rsp)
	call	cudaSetDevice@PLT
	movq	32(%rsp), %rdx
	movq	24(%rsp), %rsi
	leaq	.LC1(%rip), %rcx
	movl	%eax, %edi
	call	_Z20checkError_locations9cudaErrorPdS0_PKc
	leaq	24(%rsp), %rdi
	movq	%rbp, %rsi
	call	cudaMalloc@PLT
	movq	32(%rsp), %rdx
	movq	24(%rsp), %rsi
	movq	%r12, %rcx
	movl	%eax, %edi
	call	_Z20checkError_locations9cudaErrorPdS0_PKc
	leaq	32(%rsp), %rdi
	movq	%rbp, %rsi
	call	cudaMalloc@PLT
	movq	32(%rsp), %rdx
	movq	24(%rsp), %rsi
	movq	%r12, %rcx
	movl	%eax, %edi
	leaq	.LC3(%rip), %r12
	call	_Z20checkError_locations9cudaErrorPdS0_PKc
	movq	24(%rsp), %rdi
	movq	%rbp, %rdx
	movq	%r13, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movq	32(%rsp), %rdx
	movq	24(%rsp), %rsi
	movq	%r12, %rcx
	movl	%eax, %edi
	call	_Z20checkError_locations9cudaErrorPdS0_PKc
	movq	32(%rsp), %rdi
	movq	%rbp, %rdx
	movq	%r14, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movq	32(%rsp), %rdx
	movq	24(%rsp), %rsi
	movq	%r12, %rcx
	movl	%eax, %edi
	call	_Z20checkError_locations9cudaErrorPdS0_PKc
	movl	$1024, %eax
	movl	$1024, %edi
	movabsq	$4294967297, %rsi
	cmpl	%eax, %ebx
	movq	%rsi, 60(%rsp)
	cmovle	%ebx, %eax
	xorl	%ecx, %ecx
	testl	$1023, %ebx
	movq	%rsi, 48(%rsp)
	setne	%cl
	movl	52(%rsp), %esi
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	%eax, 56(%rsp)
	movl	%ebx, %eax
	cltd
	idivl	%edi
	movq	56(%rsp), %rdx
	addl	%eax, %ecx
	movl	%ecx, 44(%rsp)
	movl	64(%rsp), %ecx
	movq	44(%rsp), %rdi
	call	__cudaPushCallConfiguration@PLT
	movsd	8(%rsp), %xmm0
	testl	%eax, %eax
	jne	.L36
	movq	32(%rsp), %rsi
	movq	24(%rsp), %rdi
	call	_Z45__device_stub__Z21updateLocationsKernelPdPKddPdPKdd
.L36:
	call	cudaGetLastError@PLT
	leaq	68(%rsp), %r14
	movl	%eax, %edi
	movl	%eax, %ebx
	call	cudaGetErrorString@PLT
	leaq	.LC6(%rip), %rcx
	movl	$100, %edx
	movq	%r14, %rdi
	movq	%rax, %r8
	movl	$2, %esi
	xorl	%eax, %eax
	call	__sprintf_chk@PLT
	movq	32(%rsp), %rdx
	movl	%ebx, %edi
	movq	%r12, %rcx
	movq	24(%rsp), %rsi
	call	_Z20checkError_locations9cudaErrorPdS0_PKc
	call	cudaDeviceSynchronize@PLT
	leaq	.LC5(%rip), %rcx
	movl	$100, %edx
	movq	%r14, %rdi
	movl	%eax, %r8d
	movl	%eax, %ebx
	movl	$2, %esi
	xorl	%eax, %eax
	call	__sprintf_chk@PLT
	movq	32(%rsp), %rdx
	movl	%ebx, %edi
	movq	%r12, %rcx
	movq	24(%rsp), %rsi
	call	_Z20checkError_locations9cudaErrorPdS0_PKc
	movq	24(%rsp), %rsi
	movq	%rbp, %rdx
	movq	%r13, %rdi
	movl	$2, %ecx
	call	cudaMemcpy@PLT
	movq	24(%rsp), %rsi
	movq	32(%rsp), %rdx
	movq	%r12, %rcx
	movl	%eax, %edi
	movl	%eax, %ebx
	call	_Z20checkError_locations9cudaErrorPdS0_PKc
	movq	32(%rsp), %rsi
	movq	24(%rsp), %rdi
	call	_Z24freeCudaMemory_locationsPdS_
	movq	168(%rsp), %rax
	subq	%fs:40, %rax
	je	.L37
	call	__stack_chk_fail@PLT
.L37:
	addq	$176, %rsp
	.cfi_def_cfa_offset 48
	movl	%ebx, %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
.LFE2032:
	.size	_Z22updateLocationsWithGPUPdS_iid, .-_Z22updateLocationsWithGPUPdS_iid
	.section	.rodata.str1.1
.LC7:
	.string	"_Z21updateLocationsKernelPdPKdd"
.LC8:
	.string	"_Z11matchKernelPiPKdPKiS1_ii"
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2064:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	pushq	$0
	.cfi_def_cfa_offset 24
	xorl	%r9d, %r9d
	orl	$-1, %r8d
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC7(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z21updateLocationsKernelPdPKdd(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 48
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r9d, %r9d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC8(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z11matchKernelPiPKdPKiS1_ii(%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
.LFE2064:
	.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
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:


#include "hip/hip_runtime.h"

#include <stdio.h>

#define MAX_THREADS 1024

//declerations
hipError_t matchWithGPU(int* results, double* points, int* signs, double* w, int numOfPoints, int k);

hipError_t updateLocationsWithGPU(double* locations, double* velocity, int numOfPoints, int k, double t);

void checkError_locations(hipError_t cudaStatus, double* dev_locations, double* dev_velocity, const char* errorMessage);

void freeCudaMemory_locations(double* dev_locations, double* dev_velocity);

void freeCudaMemory_match(int* dev_results, double* dev_points, int* dev_signs, double* dev_w);

void checkError_match(hipError_t cudaStatus, int* dev_results, double* dev_points, int* dev_signs, double* dev_w, const char* errorMessage);

__device__ int signGPU(double f);

__device__ double fGPU(const double* p, int offset, const double* w, int k);


// implmentations

//changes results at a given index to 1 if the test fails
__global__ void matchKernel(int* results, const double* points, const int* signs, const double* w, int numOfPoints, int k)
{
	int index = threadIdx.x + blockIdx.x * blockDim.x; //calculate index of each element in array
	int value = signGPU(fGPU(points, index*k, w, k));

	if (value != signs[index])
		results[index] = 1;
}

//updates the location at index based on location=location0 +velocity * t
__global__ void updateLocationsKernel(double* location, const double* velocity, double t)
{
	int index = threadIdx.x + blockIdx.x * blockDim.x; //calculate index of each element in array

	location[index] = location[index] + velocity[index] * t;
}

//function to free all arrays related to the match part of CUDA
void freeCudaMemory_match(int* dev_results, double* dev_points, int* dev_signs, double* dev_w)
{
	hipFree(dev_results);
	hipFree(dev_points);
	hipFree(dev_signs);
	hipFree(dev_w);
}

//function responsible to handle errors in the match part of CUDA
void checkError_match(hipError_t cudaStatus, int* dev_results, double* dev_points, int* dev_signs, double* dev_w, const char* errorMessage)
{
	if (cudaStatus != hipSuccess) {
		fprintf(stderr, errorMessage);
		fprintf(stderr, "\n");
		freeCudaMemory_match(dev_results, dev_points, dev_signs, dev_w);
	}
}

//tests all points to see if they're in the place they should be
hipError_t matchWithGPU(int* results, double* points, int* signs, double* w, int numOfPoints, int k)
{
	char errorBuffer[100];
	int* dev_results = 0;
	double* dev_points = 0;
	int* dev_signs = 0;
	double* dev_w = 0;
	int extra = 0;
	int numOfBlocks, numOfThreads;
	hipError_t cudaStatus;

	// Choose which GPU to run on, change this on a multi-GPU system.
	cudaStatus = hipSetDevice(0);
	checkError_match(cudaStatus, dev_results, dev_points, dev_signs, dev_w, "hipSetDevice failed!  Do you have a CUDA-capable GPU installed?");

	// Allocate GPU buffers for every array
	cudaStatus = hipMalloc((void**)&dev_results, numOfPoints * sizeof(int));
	checkError_match(cudaStatus, dev_results, dev_points, dev_signs, dev_w, "hipMalloc failed!");

	cudaStatus = hipMalloc((void**)&dev_points, numOfPoints * k * sizeof(double));
	checkError_match(cudaStatus, dev_results, dev_points, dev_signs, dev_w, "hipMalloc failed!");

	cudaStatus = hipMalloc((void**)&dev_signs, numOfPoints * sizeof(int));
	checkError_match(cudaStatus, dev_results, dev_points, dev_signs, dev_w, "hipMalloc failed!");

	cudaStatus = hipMalloc((void**)&dev_w, k * sizeof(double));
	checkError_match(cudaStatus, dev_results, dev_points, dev_signs, dev_w, "hipMalloc failed!");

	// Copy input arrays from host memory to GPU buffers.
	cudaStatus = hipMemcpy(dev_points, points, numOfPoints * k * sizeof(double), hipMemcpyHostToDevice);
	checkError_match(cudaStatus, dev_results, dev_points, dev_signs, dev_w, "hipMemcpy failed!");

	cudaStatus = hipMemcpy(dev_signs, signs, numOfPoints * sizeof(int), hipMemcpyHostToDevice);
	checkError_match(cudaStatus, dev_results, dev_points, dev_signs, dev_w, "hipMemcpy failed!");

	cudaStatus = hipMemcpy(dev_w, w, k * sizeof(double), hipMemcpyHostToDevice);
	checkError_match(cudaStatus, dev_results, dev_points, dev_signs, dev_w, "hipMemcpy failed!");

	// Calculate the number of blocks and threads needed.
	extra = numOfPoints % MAX_THREADS != 0 ? 1 : 0;
	numOfBlocks = (numOfPoints / MAX_THREADS + extra);
	numOfThreads = MAX_THREADS>numOfPoints ? numOfPoints : MAX_THREADS;

	// Launch a kernel on the GPU with one thread for each element.
	matchKernel<<<numOfBlocks, numOfThreads >>>(dev_results, dev_points, dev_signs, dev_w, numOfPoints, k);

	// Check for any errors launching the kernel
	cudaStatus = hipGetLastError();
	sprintf(errorBuffer, "matchKernel launch failed: %s\n", hipGetErrorString(cudaStatus));
	checkError_match(cudaStatus, dev_results, dev_points, dev_signs, dev_w, errorBuffer);

	// cudaDeviceSynchronize waits for the kernel to finish, and returns any errors encountered during the launch.
	cudaStatus = hipDeviceSynchronize();
	sprintf(errorBuffer, "hipDeviceSynchronize returned error code %d after launching addKernel!\n", cudaStatus);
	checkError_match(cudaStatus, dev_results, dev_points, dev_signs, dev_w, errorBuffer);

	// Copy output vector from GPU buffer to host memory.
	cudaStatus = hipMemcpy(results, dev_results, numOfPoints * sizeof(int), hipMemcpyDeviceToHost);
	checkError_match(cudaStatus, dev_results, dev_points, dev_signs, dev_w, "hipMemcpy failed!");

	freeCudaMemory_match(dev_results, dev_points, dev_signs, dev_w);

	return cudaStatus;
}

//checks the sign of a given double
__device__ int signGPU(double f)
{
	if (f < 0)
		return -1;
	return 1;
}

//calculates f based on the algorithm
__device__ double fGPU(const double* p, int offset, const double* w, int k)
{
	int i;
	double result = 0;

	for (i = 0; i < k; i++)
	{
		result += w[i] * p[offset + i];
	}

	return result;
}

//updates the locations vector to its new position based on time and velocity
hipError_t updateLocationsWithGPU(double* locations, double* velocity, int numOfPoints, int k, double t)
{
	char errorBuffer[100];
	double* dev_locations = 0;
	double* dev_velocity = 0;
	int extra;
	int numOfBlocks, numOfThreads;
	hipError_t cudaStatus;

	// Choose which GPU to run on, change this on a multi-GPU system.
	cudaStatus = hipSetDevice(0);
	checkError_locations(cudaStatus, dev_locations, dev_velocity, "hipSetDevice failed!  Do you have a CUDA-capable GPU installed?");

	// Allocate GPU buffers for the arrays
	cudaStatus = hipMalloc((void**)&dev_locations, numOfPoints * k * sizeof(double));
	checkError_locations(cudaStatus, dev_locations, dev_velocity, "hipMalloc failed!");

	cudaStatus = hipMalloc((void**)&dev_velocity, numOfPoints * k * sizeof(double));
	checkError_locations(cudaStatus, dev_locations, dev_velocity, "hipMalloc failed!");

	// Copy input vector from host memory to GPU buffers.
	cudaStatus = hipMemcpy(dev_locations, locations, numOfPoints * k * sizeof(double), hipMemcpyHostToDevice);
	checkError_locations(cudaStatus, dev_locations, dev_velocity, "hipMemcpy failed!");

	cudaStatus = hipMemcpy(dev_velocity, velocity, numOfPoints * k * sizeof(double), hipMemcpyHostToDevice);
	checkError_locations(cudaStatus, dev_locations, dev_velocity, "hipMemcpy failed!");

	// Calculate the number of blocks and threads needed.
	extra = (numOfPoints*k) % MAX_THREADS != 0 ? 1 : 0;
	numOfBlocks = ((numOfPoints*k) / MAX_THREADS + extra);
	numOfThreads = MAX_THREADS>(numOfPoints*k) ? (numOfPoints*k) : MAX_THREADS;

	// Launch a kernel on the GPU with one thread for each element. Each calculating a dimension in a point, going over all points
	updateLocationsKernel<<<numOfBlocks, numOfThreads>>>(dev_locations, dev_velocity, t);

	// Check for any errors launching the kernel
	cudaStatus = hipGetLastError();
	sprintf(errorBuffer, "addKernel launch failed: %s\n", hipGetErrorString(cudaStatus));
	checkError_locations(cudaStatus, dev_locations, dev_velocity, "hipMemcpy failed!");

	// cudaDeviceSynchronize waits for the kernel to finish, and returns any errors encountered during the launch.
	cudaStatus = hipDeviceSynchronize();
	sprintf(errorBuffer, "hipDeviceSynchronize returned error code %d after launching addKernel!\n", cudaStatus);
	checkError_locations(cudaStatus, dev_locations, dev_velocity, "hipMemcpy failed!");

	// Copy output vector from GPU buffer to host memory.
	// In this case, overwrite the locations array on host memory with the updated one
	cudaStatus = hipMemcpy(locations, dev_locations, numOfPoints * k * sizeof(double), hipMemcpyDeviceToHost);
	checkError_locations(cudaStatus, dev_locations, dev_velocity, "hipMemcpy failed!");

	freeCudaMemory_locations(dev_locations, dev_velocity);

	return cudaStatus;
}

//function responsible to handle errors in the update locations part of CUDA
void checkError_locations(hipError_t cudaStatus, double* dev_locations, double* dev_velocity, const char* errorMessage)
{
	if (cudaStatus != hipSuccess)
	{
		fprintf(stderr, errorMessage);
		fprintf(stderr, "\n");
		freeCudaMemory_locations(dev_locations, dev_velocity);
	}
}

//function responsible to handle errors in the update locations part of CUDA
void freeCudaMemory_locations(double* dev_locations, double* dev_velocity)
{
	hipFree(dev_locations);
	hipFree(dev_velocity);
}
	.text
	.file	"kernel.hip"
	.globl	_Z26__device_stub__matchKernelPiPKdPKiS1_ii # -- Begin function _Z26__device_stub__matchKernelPiPKdPKiS1_ii
	.type	_Z26__device_stub__matchKernelPiPKdPKiS1_ii,@function
_Z26__device_stub__matchKernelPiPKdPKiS1_ii: # @_Z26__device_stub__matchKernelPiPKdPKiS1_ii
	.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	$144, %rsp
	.cfi_def_cfa_offset 192
	.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	12(%rsp), %rcx
	movl	%r8d, (%rcx)
	leaq	8(%rsp), %r8
	movl	%r9d, (%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	80(%rsp), %r14
	leaq	64(%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	$_Z11matchKernelPiPKdPKiS1_ii, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$160, %rsp
	.cfi_adjust_cfa_offset -160
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	_Z26__device_stub__matchKernelPiPKdPKiS1_ii, .Lfunc_end0-_Z26__device_stub__matchKernelPiPKdPKiS1_ii
	.cfi_endproc
                                        # -- End function
	.globl	_Z36__device_stub__updateLocationsKernelPdPKdd # -- Begin function _Z36__device_stub__updateLocationsKernelPdPKdd
	.type	_Z36__device_stub__updateLocationsKernelPdPKdd,@function
_Z36__device_stub__updateLocationsKernelPdPKdd: # @_Z36__device_stub__updateLocationsKernelPdPKdd
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$112, %rsp
	.cfi_def_cfa_offset 160
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	32(%rsp), %rcx
	movq	%rsi, (%rcx)
	leaq	24(%rsp), %rdx
	movsd	%xmm0, (%rdx)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	movq	%rdx, 16(%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	$_Z21updateLocationsKernelPdPKdd, %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_end1:
	.size	_Z36__device_stub__updateLocationsKernelPdPKdd, .Lfunc_end1-_Z36__device_stub__updateLocationsKernelPdPKdd
	.cfi_endproc
                                        # -- End function
	.globl	_Z20freeCudaMemory_matchPiPdS_S0_ # -- Begin function _Z20freeCudaMemory_matchPiPdS_S0_
	.type	_Z20freeCudaMemory_matchPiPdS_S0_,@function
_Z20freeCudaMemory_matchPiPdS_S0_:      # @_Z20freeCudaMemory_matchPiPdS_S0_
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rcx, %rbx
	movq	%rdx, %r14
	movq	%rsi, %r15
	callq	hipFree
	movq	%r15, %rdi
	callq	hipFree
	movq	%r14, %rdi
	callq	hipFree
	movq	%rbx, %rdi
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	jmp	hipFree                         # TAILCALL
.Lfunc_end2:
	.size	_Z20freeCudaMemory_matchPiPdS_S0_, .Lfunc_end2-_Z20freeCudaMemory_matchPiPdS_S0_
	.cfi_endproc
                                        # -- End function
	.globl	_Z16checkError_match10hipError_tPiPdS0_S1_PKc # -- Begin function _Z16checkError_match10hipError_tPiPdS0_S1_PKc
	.type	_Z16checkError_match10hipError_tPiPdS0_S1_PKc,@function
_Z16checkError_match10hipError_tPiPdS0_S1_PKc: # @_Z16checkError_match10hipError_tPiPdS0_S1_PKc
	.cfi_startproc
# %bb.0:
	testl	%edi, %edi
	jne	.LBB3_2
# %bb.1:
	retq
.LBB3_2:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r12
	.cfi_def_cfa_offset 32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	pushq	%rax
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -40
	.cfi_offset %r12, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%r8, %rbx
	movq	%rcx, %r14
	movq	%rdx, %r15
	movq	%rsi, %r12
	movq	stderr(%rip), %rdi
	movq	%r9, %rsi
	xorl	%eax, %eax
	callq	fprintf
	movq	stderr(%rip), %rsi
	movl	$10, %edi
	callq	fputc@PLT
	movq	%r12, %rdi
	movq	%r15, %rsi
	movq	%r14, %rdx
	movq	%rbx, %rcx
	addq	$8, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	jmp	_Z20freeCudaMemory_matchPiPdS_S0_ # TAILCALL
.Lfunc_end3:
	.size	_Z16checkError_match10hipError_tPiPdS0_S1_PKc, .Lfunc_end3-_Z16checkError_match10hipError_tPiPdS0_S1_PKc
	.cfi_endproc
                                        # -- End function
	.globl	_Z12matchWithGPUPiPdS_S0_ii     # -- Begin function _Z12matchWithGPUPiPdS_S0_ii
	.type	_Z12matchWithGPUPiPdS_S0_ii,@function
_Z12matchWithGPUPiPdS_S0_ii:            # @_Z12matchWithGPUPiPdS_S0_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
	subq	$184, %rsp
	.cfi_def_cfa_offset 240
	.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	%r9d, %r14d
	movl	%r8d, %ebp
	movq	%rcx, 64(%rsp)                  # 8-byte Spill
	movq	%rdx, 32(%rsp)                  # 8-byte Spill
	movq	%rsi, 48(%rsp)                  # 8-byte Spill
	movq	%rdi, 72(%rsp)                  # 8-byte Spill
	xorl	%eax, %eax
	movq	%rsp, %r15
	movq	%rax, (%r15)
	leaq	24(%rsp), %rcx
	movq	%rax, (%rcx)
	movq	%rcx, %rbx
	leaq	16(%rsp), %rcx
	movq	%rax, (%rcx)
	leaq	8(%rsp), %rcx
	movq	%rax, (%rcx)
	xorl	%edi, %edi
	callq	hipSetDevice
	movl	$.L.str.1, %r9d
	movl	%eax, %edi
	xorl	%esi, %esi
	xorl	%edx, %edx
	xorl	%ecx, %ecx
	xorl	%r8d, %r8d
	callq	_Z16checkError_match10hipError_tPiPdS0_S1_PKc
	movslq	%ebp, %rax
	movl	%ebp, 44(%rsp)                  # 4-byte Spill
	movq	%rax, 56(%rsp)                  # 8-byte Spill
	leaq	(,%rax,4), %r12
	movq	%r15, %rdi
	movq	%r12, %rsi
	callq	hipMalloc
	movq	(%r15), %rsi
	movl	$.L.str.2, %r9d
	movl	%eax, %edi
	xorl	%edx, %edx
	xorl	%ecx, %ecx
	xorl	%r8d, %r8d
	callq	_Z16checkError_match10hipError_tPiPdS0_S1_PKc
	movl	%r14d, %eax
	imull	%ebp, %eax
	movslq	%eax, %rbp
	shlq	$3, %rbp
	movq	%rbx, %rdi
	movq	%rbp, %rsi
	callq	hipMalloc
	movq	(%r15), %rsi
	movq	(%rbx), %rdx
	movl	$.L.str.2, %r9d
	movl	%eax, %edi
	xorl	%ecx, %ecx
	xorl	%r8d, %r8d
	callq	_Z16checkError_match10hipError_tPiPdS0_S1_PKc
	leaq	16(%rsp), %r13
	movq	%r13, %rdi
	movq	%r12, %rsi
	callq	hipMalloc
	movq	(%r15), %rsi
	movq	(%rbx), %rdx
	movq	(%r13), %rcx
	movl	$.L.str.2, %r9d
	movl	%eax, %edi
	xorl	%r8d, %r8d
	callq	_Z16checkError_match10hipError_tPiPdS0_S1_PKc
	movl	%r14d, 40(%rsp)                 # 4-byte Spill
	movslq	%r14d, %r14
	shlq	$3, %r14
	leaq	8(%rsp), %rbx
	movq	%rbx, %rdi
	movq	%r14, %rsi
	callq	hipMalloc
	movq	(%r15), %rsi
	leaq	24(%rsp), %r15
	movq	(%r15), %rdx
	movq	(%r13), %rcx
	movq	(%rbx), %r8
	movl	$.L.str.2, %r9d
	movl	%eax, %edi
	callq	_Z16checkError_match10hipError_tPiPdS0_S1_PKc
	movq	(%r15), %rdi
	movq	48(%rsp), %rsi                  # 8-byte Reload
	movq	%rbp, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	%rsp, %rbp
	movq	(%rbp), %rsi
	movq	(%r15), %rdx
	movq	(%r13), %rcx
	movq	(%rbx), %r8
	movl	$.L.str.3, %r9d
	movl	%eax, %edi
	callq	_Z16checkError_match10hipError_tPiPdS0_S1_PKc
	movq	(%r13), %rdi
	movq	32(%rsp), %rsi                  # 8-byte Reload
	movq	%r12, 32(%rsp)                  # 8-byte Spill
	movq	%r12, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	(%rbp), %rsi
	movq	(%r15), %rdx
	movq	(%r13), %rcx
	movq	(%rbx), %r8
	movl	$.L.str.3, %r9d
	movl	%eax, %edi
	callq	_Z16checkError_match10hipError_tPiPdS0_S1_PKc
	movq	(%rbx), %rdi
	movq	64(%rsp), %rsi                  # 8-byte Reload
	movq	%r14, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	(%rbp), %rsi
	movq	(%r15), %rdx
	movq	(%r13), %rcx
	movq	(%rbx), %r8
	movl	44(%rsp), %ebx                  # 4-byte Reload
	movl	$.L.str.3, %r9d
	movl	%eax, %edi
	callq	_Z16checkError_match10hipError_tPiPdS0_S1_PKc
	movl	$1023, %edi                     # imm = 0x3FF
	movl	%ebx, %eax
	andl	%edi, %eax
	addl	%ebx, %edi
	movq	56(%rsp), %rcx                  # 8-byte Reload
	testl	%ecx, %ecx
	cmovnsl	%ebx, %edi
	sarl	$10, %edi
	cmpl	$1, %eax
	sbbl	$-1, %edi
	movl	$1024, %edx                     # imm = 0x400
	cmpl	%edx, %ecx
	cmovll	%ebx, %edx
	btsq	$32, %rdi
	btsq	$32, %rdx
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB4_2
# %bb.1:
	movq	(%rsp), %rdi
	movq	24(%rsp), %rsi
	movq	16(%rsp), %rdx
	movq	8(%rsp), %rcx
	movl	%ebx, %r8d
	movl	40(%rsp), %r9d                  # 4-byte Reload
	callq	_Z26__device_stub__matchKernelPiPKdPKiS1_ii
.LBB4_2:
	callq	hipGetLastError
	movl	%eax, %ebp
	movl	%eax, %edi
	callq	hipGetErrorString
	leaq	80(%rsp), %rbx
	movl	$.L.str.4, %esi
	movq	%rbx, %rdi
	movq	%rax, %rdx
	xorl	%eax, %eax
	callq	sprintf
	movq	(%rsp), %rsi
	movq	24(%rsp), %rdx
	movq	16(%rsp), %rcx
	movq	8(%rsp), %r8
	movl	%ebp, %edi
	movq	%rbx, %r9
	callq	_Z16checkError_match10hipError_tPiPdS0_S1_PKc
	callq	hipDeviceSynchronize
	movl	%eax, %ebp
	movl	$.L.str.5, %esi
	movq	%rbx, %rdi
	movl	%eax, %edx
	xorl	%eax, %eax
	callq	sprintf
	movq	(%rsp), %rsi
	movq	24(%rsp), %rdx
	movq	16(%rsp), %rcx
	movq	8(%rsp), %r8
	movl	%ebp, %edi
	movq	%rbx, %r9
	callq	_Z16checkError_match10hipError_tPiPdS0_S1_PKc
	movq	(%rsp), %rsi
	movq	72(%rsp), %rdi                  # 8-byte Reload
	movq	32(%rsp), %rdx                  # 8-byte Reload
	movl	$2, %ecx
	callq	hipMemcpy
	movl	%eax, %ebx
	movq	(%rsp), %rsi
	movq	24(%rsp), %rdx
	movq	16(%rsp), %rcx
	movq	8(%rsp), %r8
	movl	$.L.str.3, %r9d
	movl	%eax, %edi
	callq	_Z16checkError_match10hipError_tPiPdS0_S1_PKc
	movq	(%rsp), %rdi
	movq	24(%rsp), %rsi
	movq	16(%rsp), %rdx
	movq	8(%rsp), %rcx
	callq	_Z20freeCudaMemory_matchPiPdS_S0_
	movl	%ebx, %eax
	addq	$184, %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_end4:
	.size	_Z12matchWithGPUPiPdS_S0_ii, .Lfunc_end4-_Z12matchWithGPUPiPdS_S0_ii
	.cfi_endproc
                                        # -- End function
	.globl	_Z22updateLocationsWithGPUPdS_iid # -- Begin function _Z22updateLocationsWithGPUPdS_iid
	.type	_Z22updateLocationsWithGPUPdS_iid,@function
_Z22updateLocationsWithGPUPdS_iid:      # @_Z22updateLocationsWithGPUPdS_iid
	.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	$136, %rsp
	.cfi_def_cfa_offset 192
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movsd	%xmm0, 24(%rsp)                 # 8-byte Spill
	movl	%ecx, %r14d
	movl	%edx, %r15d
	movq	%rsi, %rbp
	movq	%rdi, %rbx
	xorl	%eax, %eax
	leaq	8(%rsp), %r12
	movq	%rax, (%r12)
	leaq	16(%rsp), %r13
	movq	%rax, (%r13)
	xorl	%edi, %edi
	callq	hipSetDevice
	movl	$.L.str.1, %ecx
	movl	%eax, %edi
	xorl	%esi, %esi
	xorl	%edx, %edx
	callq	_Z20checkError_locations10hipError_tPdS0_PKc
	imull	%r14d, %r15d
	movslq	%r15d, %r15
	leaq	(,%r15,8), %r14
	movq	%r12, %rdi
	movq	%r14, %rsi
	callq	hipMalloc
	movq	(%r12), %rsi
	movl	$.L.str.2, %ecx
	movl	%eax, %edi
	xorl	%edx, %edx
	callq	_Z20checkError_locations10hipError_tPdS0_PKc
	movq	%r13, %rdi
	movq	%r14, %rsi
	callq	hipMalloc
	movq	(%r12), %rsi
	movq	(%r13), %rdx
	movl	$.L.str.2, %ecx
	movl	%eax, %edi
	callq	_Z20checkError_locations10hipError_tPdS0_PKc
	movq	(%r12), %rdi
	movq	%rbx, %rsi
	movq	%r14, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	(%r12), %rsi
	movq	(%r13), %rdx
	movl	$.L.str.3, %ecx
	movl	%eax, %edi
	callq	_Z20checkError_locations10hipError_tPdS0_PKc
	movq	(%r13), %rdi
	movq	%rbp, %rsi
	movq	%r14, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	(%r12), %rsi
	movq	(%r13), %rdx
	movl	$.L.str.3, %ecx
	movl	%eax, %edi
	callq	_Z20checkError_locations10hipError_tPdS0_PKc
	movl	$1023, %edi                     # imm = 0x3FF
	movl	%r15d, %eax
	andl	%edi, %eax
	addl	%r15d, %edi
	testl	%r15d, %r15d
	cmovnsl	%r15d, %edi
	sarl	$10, %edi
	cmpl	$1, %eax
	sbbl	$-1, %edi
	movl	$1024, %eax                     # imm = 0x400
	cmpl	%eax, %r15d
	cmovgel	%eax, %r15d
	btsq	$32, %rdi
	btsq	$32, %r15
	movl	$1, %esi
	movq	%r15, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB5_2
# %bb.1:
	movq	8(%rsp), %rdi
	movq	16(%rsp), %rsi
	movsd	24(%rsp), %xmm0                 # 8-byte Reload
                                        # xmm0 = mem[0],zero
	callq	_Z36__device_stub__updateLocationsKernelPdPKdd
.LBB5_2:
	callq	hipGetLastError
	movl	%eax, %ebp
	movl	%eax, %edi
	callq	hipGetErrorString
	leaq	32(%rsp), %r15
	movl	$.L.str.6, %esi
	movq	%r15, %rdi
	movq	%rax, %rdx
	xorl	%eax, %eax
	callq	sprintf
	movq	8(%rsp), %rsi
	movq	16(%rsp), %rdx
	movl	$.L.str.3, %ecx
	movl	%ebp, %edi
	callq	_Z20checkError_locations10hipError_tPdS0_PKc
	callq	hipDeviceSynchronize
	movl	%eax, %ebp
	movl	$.L.str.5, %esi
	movq	%r15, %rdi
	movl	%eax, %edx
	xorl	%eax, %eax
	callq	sprintf
	movq	8(%rsp), %rsi
	movq	16(%rsp), %rdx
	movl	$.L.str.3, %ecx
	movl	%ebp, %edi
	callq	_Z20checkError_locations10hipError_tPdS0_PKc
	movq	8(%rsp), %rsi
	movq	%rbx, %rdi
	movq	%r14, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	movl	%eax, %ebx
	movq	8(%rsp), %rsi
	movq	16(%rsp), %rdx
	movl	$.L.str.3, %ecx
	movl	%eax, %edi
	callq	_Z20checkError_locations10hipError_tPdS0_PKc
	movq	8(%rsp), %rdi
	movq	16(%rsp), %r14
	callq	hipFree
	movq	%r14, %rdi
	callq	hipFree
	movl	%ebx, %eax
	addq	$136, %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	_Z22updateLocationsWithGPUPdS_iid, .Lfunc_end5-_Z22updateLocationsWithGPUPdS_iid
	.cfi_endproc
                                        # -- End function
	.globl	_Z20checkError_locations10hipError_tPdS0_PKc # -- Begin function _Z20checkError_locations10hipError_tPdS0_PKc
	.type	_Z20checkError_locations10hipError_tPdS0_PKc,@function
_Z20checkError_locations10hipError_tPdS0_PKc: # @_Z20checkError_locations10hipError_tPdS0_PKc
	.cfi_startproc
# %bb.0:
	testl	%edi, %edi
	jne	.LBB6_2
# %bb.1:
	retq
.LBB6_2:
	pushq	%r14
	.cfi_def_cfa_offset 16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	pushq	%rax
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -24
	.cfi_offset %r14, -16
	movq	%rdx, %rbx
	movq	%rsi, %r14
	movq	stderr(%rip), %rdi
	movq	%rcx, %rsi
	xorl	%eax, %eax
	callq	fprintf
	movq	stderr(%rip), %rsi
	movl	$10, %edi
	callq	fputc@PLT
	movq	%r14, %rdi
	callq	hipFree
	movq	%rbx, %rdi
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	jmp	hipFree                         # TAILCALL
.Lfunc_end6:
	.size	_Z20checkError_locations10hipError_tPdS0_PKc, .Lfunc_end6-_Z20checkError_locations10hipError_tPdS0_PKc
	.cfi_endproc
                                        # -- End function
	.globl	_Z24freeCudaMemory_locationsPdS_ # -- Begin function _Z24freeCudaMemory_locationsPdS_
	.type	_Z24freeCudaMemory_locationsPdS_,@function
_Z24freeCudaMemory_locationsPdS_:       # @_Z24freeCudaMemory_locationsPdS_
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset %rbx, -16
	movq	%rsi, %rbx
	callq	hipFree
	movq	%rbx, %rdi
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	hipFree                         # TAILCALL
.Lfunc_end7:
	.size	_Z24freeCudaMemory_locationsPdS_, .Lfunc_end7-_Z24freeCudaMemory_locationsPdS_
	.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	$_Z11matchKernelPiPKdPKiS1_ii, %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	$_Z21updateLocationsKernelPdPKdd, %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_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	_Z11matchKernelPiPKdPKiS1_ii,@object # @_Z11matchKernelPiPKdPKiS1_ii
	.section	.rodata,"a",@progbits
	.globl	_Z11matchKernelPiPKdPKiS1_ii
	.p2align	3, 0x0
_Z11matchKernelPiPKdPKiS1_ii:
	.quad	_Z26__device_stub__matchKernelPiPKdPKiS1_ii
	.size	_Z11matchKernelPiPKdPKiS1_ii, 8

	.type	_Z21updateLocationsKernelPdPKdd,@object # @_Z21updateLocationsKernelPdPKdd
	.globl	_Z21updateLocationsKernelPdPKdd
	.p2align	3, 0x0
_Z21updateLocationsKernelPdPKdd:
	.quad	_Z36__device_stub__updateLocationsKernelPdPKdd
	.size	_Z21updateLocationsKernelPdPKdd, 8

	.type	.L.str.1,@object                # @.str.1
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.1:
	.asciz	"hipSetDevice failed!  Do you have a CUDA-capable GPU installed?"
	.size	.L.str.1, 64

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"hipMalloc failed!"
	.size	.L.str.2, 18

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"hipMemcpy failed!"
	.size	.L.str.3, 18

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"matchKernel launch failed: %s\n"
	.size	.L.str.4, 31

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"hipDeviceSynchronize returned error code %d after launching addKernel!\n"
	.size	.L.str.5, 72

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"addKernel launch failed: %s\n"
	.size	.L.str.6, 29

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z11matchKernelPiPKdPKiS1_ii"
	.size	.L__unnamed_1, 29

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_Z21updateLocationsKernelPdPKdd"
	.size	.L__unnamed_2, 32

	.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 _Z26__device_stub__matchKernelPiPKdPKiS1_ii
	.addrsig_sym _Z36__device_stub__updateLocationsKernelPdPKdd
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z11matchKernelPiPKdPKiS1_ii
	.addrsig_sym _Z21updateLocationsKernelPdPKdd
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z11matchKernelPiPKdPKiS1_ii ; -- Begin function _Z11matchKernelPiPKdPKiS1_ii
	.globl	_Z11matchKernelPiPKdPKiS1_ii
	.p2align	8
	.type	_Z11matchKernelPiPKdPKiS1_ii,@function
_Z11matchKernelPiPKdPKiS1_ii:           ; @_Z11matchKernelPiPKdPKiS1_ii
; %bb.0:
	s_clause 0x2
	s_load_b32 s9, s[0:1], 0x34
	s_load_b32 s8, s[0:1], 0x24
	s_load_b256 s[0:7], s[0:1], 0x0
	v_mov_b32_e32 v3, 1
	s_waitcnt lgkmcnt(0)
	s_and_b32 s9, s9, 0xffff
	s_cmp_lt_i32 s8, 1
	v_mad_u64_u32 v[1:2], null, s15, s9, v[0:1]
	s_cbranch_scc1 .LBB0_4
; %bb.1:                                ; %.lr.ph.i.preheader
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_lo_u32 v2, v1, s8
	v_ashrrev_i32_e32 v3, 31, v2
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_3)
	v_lshlrev_b64 v[4:5], 3, v[2:3]
	v_mov_b32_e32 v2, 0
	v_mov_b32_e32 v3, 0
	v_add_co_u32 v4, vcc_lo, s2, v4
	s_delay_alu instid0(VALU_DEP_4)
	v_add_co_ci_u32_e32 v5, vcc_lo, s3, v5, vcc_lo
.LBB0_2:                                ; %.lr.ph.i
                                        ; =>This Inner Loop Header: Depth=1
	global_load_b64 v[6:7], v[4:5], off
	s_load_b64 s[2:3], s[6:7], 0x0
	v_add_co_u32 v4, vcc_lo, v4, 8
	s_add_i32 s8, s8, -1
	v_add_co_ci_u32_e32 v5, vcc_lo, 0, v5, vcc_lo
	s_add_u32 s6, s6, 8
	s_addc_u32 s7, s7, 0
	s_cmp_lg_u32 s8, 0
	s_waitcnt vmcnt(0) lgkmcnt(0)
	v_fma_f64 v[2:3], s[2:3], v[6:7], v[2:3]
	s_cbranch_scc1 .LBB0_2
; %bb.3:                                ; %_Z4fGPUPKdiS0_i.exit.loopexit
	s_delay_alu instid0(VALU_DEP_1)
	v_cmp_gt_f64_e32 vcc_lo, 0, v[2:3]
	v_cndmask_b32_e64 v3, 1, -1, vcc_lo
.LBB0_4:                                ; %_Z4fGPUPKdiS0_i.exit
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v2, 31, v1
	s_mov_b32 s2, exec_lo
	v_lshlrev_b64 v[0:1], 2, v[1:2]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v4, vcc_lo, s4, v0
	v_add_co_ci_u32_e32 v5, vcc_lo, s5, v1, vcc_lo
	global_load_b32 v2, v[4:5], off
	s_waitcnt vmcnt(0)
	v_cmpx_ne_u32_e64 v3, v2
	s_cbranch_execz .LBB0_6
; %bb.5:
	v_add_co_u32 v0, vcc_lo, s0, v0
	v_add_co_ci_u32_e32 v1, vcc_lo, s1, v1, vcc_lo
	v_mov_b32_e32 v2, 1
	global_store_b32 v[0:1], v2, off
.LBB0_6:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z11matchKernelPiPKdPKiS1_ii
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 296
		.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 8
		.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	_Z11matchKernelPiPKdPKiS1_ii, .Lfunc_end0-_Z11matchKernelPiPKdPKiS1_ii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 284
; NumSgprs: 18
; NumVgprs: 8
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 8
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.protected	_Z21updateLocationsKernelPdPKdd ; -- Begin function _Z21updateLocationsKernelPdPKdd
	.globl	_Z21updateLocationsKernelPdPKdd
	.p2align	8
	.type	_Z21updateLocationsKernelPdPKdd,@function
_Z21updateLocationsKernelPdPKdd:        ; @_Z21updateLocationsKernelPdPKdd
; %bb.0:
	s_clause 0x2
	s_load_b32 s2, s[0:1], 0x24
	s_load_b128 s[4:7], s[0:1], 0x0
	s_load_b64 s[0:1], s[0:1], 0x10
	s_waitcnt lgkmcnt(0)
	s_and_b32 s2, s2, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s15, s2, v[0: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], 3, v[1:2]
	v_add_co_u32 v2, vcc_lo, s4, v0
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v3, vcc_lo, s5, v1, vcc_lo
	v_add_co_u32 v0, vcc_lo, s6, v0
	v_add_co_ci_u32_e32 v1, vcc_lo, s7, v1, vcc_lo
	global_load_b64 v[4:5], v[2:3], off
	global_load_b64 v[0:1], v[0:1], off
	s_waitcnt vmcnt(0)
	v_fma_f64 v[0:1], v[0:1], s[0:1], v[4:5]
	global_store_b64 v[2:3], v[0:1], off
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z21updateLocationsKernelPdPKdd
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 280
		.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	_Z21updateLocationsKernelPdPKdd, .Lfunc_end1-_Z21updateLocationsKernelPdPKdd
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 144
; 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 : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __hip_cuid_
	.amdgpu_metadata
---
amdhsa.kernels:
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .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:     by_value
      - .offset:         36
        .size:           4
        .value_kind:     by_value
      - .offset:         40
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         44
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         48
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         52
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         54
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         56
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         58
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         60
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         62
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         88
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         96
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         104
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 296
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z11matchKernelPiPKdPKiS1_ii
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z11matchKernelPiPKdPKiS1_ii.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     8
    .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
      - .offset:         16
        .size:           8
        .value_kind:     by_value
      - .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: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 280
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z21updateLocationsKernelPdPKdd
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z21updateLocationsKernelPdPKdd.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
