#include "conv.cuh"

#include <iostream>


void HandleError( cudaError_t err, const char *file, int line )
{
    if (err != cudaSuccess)
	{
        printf( "%s in %s at line %d\n", cudaGetErrorString( err ), file, line );
		getchar();
        exit( EXIT_FAILURE );
    }
}

void CheckError(void)
{
#ifdef _DEBUG_PRINTS_
	cudaDeviceSynchronize();
	HANDLE_ERROR( cudaPeekAtLastError() );
#endif
}

__constant__ float d_kernel[81];

__inline__ __device__ uchar4 getRGBA(const uchar* fSource,
						const int fImageWidth,
						const int fImageHeight,
						const int row,
						const int col)
{
	uchar4 retVal;
	int ii	= row<0 ? 0 : row;
	int jj	= col>=fImageHeight ? fImageHeight-1 : col;
	int indx= 4*(jj*fImageWidth + ii);
	retVal.x= fSource[indx+2];
	retVal.y= fSource[indx+1];
	retVal.z= fSource[indx+0];
	retVal.w= fSource[indx+3];
	return retVal;
}

__inline__ __device__ void setRGBA(uchar* fDestination,
						const int fImageWidth,
						const int fImageHeight,
						const int row,
						const int col,
						float4 value)
{
	int ii	= row<0 ? 0 : row;
	int jj	= col>=fImageHeight ? fImageHeight-1 : col;
	int indx= 4*(jj*fImageWidth + ii);
	fDestination[indx+2] = value.x;
	fDestination[indx+1] = value.y;
	fDestination[indx+0] = value.z;
	fDestination[indx+3] = value.w;
}

__global__ void convolveKernel(const uchar* fSource, int fImageWidth, int fImageHeight, uchar* fDestination, int fKernelSize)
{
	extern __shared__ uchar shared[];
	const int PADDING = 2*fKernelSize;

	int slen	= blockDim.x+PADDING;
	int klen	= 2*fKernelSize+1;
	int gx		= threadIdx.x + blockDim.x * blockIdx.x;
	int gy		= threadIdx.y + blockDim.y * blockIdx.y;
	int sidx	= 4*(threadIdx.y*slen+threadIdx.x);

	uchar4 pxl	= getRGBA(fSource,fImageWidth,fImageHeight,
						gx-fKernelSize,gy-fKernelSize);

	shared[sidx+0] = pxl.x;
	shared[sidx+1] = pxl.y;
	shared[sidx+2] = pxl.z;
	shared[sidx+3] = pxl.w;

	int ti	= threadIdx.x + fKernelSize;
	int tj	= threadIdx.y + fKernelSize;
	int lx2	= threadIdx.x + blockDim.x;
	int ly2	= threadIdx.y + blockDim.y;
	int gx2	= gx + blockDim.x;
	int gy2	= gy + blockDim.y;

	if( threadIdx.x < PADDING ) {
		pxl	= getRGBA(fSource,fImageWidth,fImageHeight,
						gx2-fKernelSize,gy-fKernelSize);
		sidx= 4*(threadIdx.y*slen+lx2);

		shared[sidx+0] = pxl.x;
		shared[sidx+1] = pxl.y;
		shared[sidx+2] = pxl.z;
		shared[sidx+3] = pxl.w;
	}

	if( threadIdx.y < PADDING ) {
		pxl	= getRGBA(fSource,fImageWidth,fImageHeight,
						gx-fKernelSize,gy2-fKernelSize);
		sidx= 4*(ly2*slen+threadIdx.x);

		shared[sidx+0] = pxl.x;
		shared[sidx+1] = pxl.y;
		shared[sidx+2] = pxl.z;
		shared[sidx+3] = pxl.w;
	}

	if( threadIdx.x < PADDING && threadIdx.y < PADDING ) {
		pxl	= getRGBA(fSource,fImageWidth,fImageHeight,
						gx2-fKernelSize,gy2-fKernelSize);
		sidx= 4*(ly2*slen+lx2);

		shared[sidx+0] = pxl.x;
		shared[sidx+1] = pxl.y;
		shared[sidx+2] = pxl.z;
		shared[sidx+3] = pxl.w;
	}

	__syncthreads();

	// Now that the image has been read
	// into shared memory completely.
	// Check for image bounds and exit
	if( gx >= fImageWidth || gy >= fImageHeight )
		return;

	sidx			= 4*(tj*slen+ti);
	uchar* ptr		= shared + sidx;
	float4 accum	= {0.0f,0.0f,0.0f,0.0f};

	for( int jj=-fKernelSize; jj<=fKernelSize; jj++ )
	{
		for( int ii=-fKernelSize; ii<=fKernelSize; ii++ )
		{
			int tmpidx	= 4*(jj*slen+ii);
			float weight= d_kernel[(fKernelSize+jj)*klen+(fKernelSize+ii)];
			accum.x		+= weight*ptr[tmpidx+0];
			accum.y		+= weight*ptr[tmpidx+1];
			accum.z		+= weight*ptr[tmpidx+2];
		}
	}
	accum.w	= shared[sidx+3];

	setRGBA(fDestination,fImageWidth,fImageHeight,gx,gy,accum);
}

__global__ void convolveKernel(cudaTextureObject_t fSource, int fImageWidth, int fImageHeight, uchar* fDestination, int fKernelSize)
{
	extern __shared__ uchar shared[];
	const int PADDING = 2*fKernelSize;

	int slen	= blockDim.x + PADDING;
	int klen	= PADDING + 1;
	int gx		= threadIdx.x + blockDim.x * blockIdx.x;
	int gy		= threadIdx.y + blockDim.y * blockIdx.y;
	int sidx	= 4*(threadIdx.y*slen+threadIdx.x);

	uchar4 pxl	= tex2D<uchar4>(fSource,gx-fKernelSize,gy-fKernelSize);

	shared[sidx+0] = pxl.x;
	shared[sidx+1] = pxl.y;
	shared[sidx+2] = pxl.z;
	shared[sidx+3] = pxl.w;

	int ti	= threadIdx.x + fKernelSize;
	int tj	= threadIdx.y + fKernelSize;
	int lx2	= threadIdx.x + blockDim.x;
	int ly2	= threadIdx.y + blockDim.y;
	int gx2	= gx + blockDim.x;
	int gy2	= gy + blockDim.y;

	if( threadIdx.x < PADDING ) {
		pxl	= tex2D<uchar4>(fSource,gx2-fKernelSize,gy-fKernelSize);
		sidx= 4*(threadIdx.y*slen+lx2);

		shared[sidx+0] = pxl.x;
		shared[sidx+1] = pxl.y;
		shared[sidx+2] = pxl.z;
		shared[sidx+3] = pxl.w;
	}

	if( threadIdx.y < PADDING ) {
		pxl	= tex2D<uchar4>(fSource,gx-fKernelSize,gy2-fKernelSize);
		sidx= 4*(ly2*slen+threadIdx.x);

		shared[sidx+0] = pxl.x;
		shared[sidx+1] = pxl.y;
		shared[sidx+2] = pxl.z;
		shared[sidx+3] = pxl.w;
	}

	if( threadIdx.x < PADDING && threadIdx.y < PADDING ) {
		pxl	= tex2D<uchar4>(fSource,gx2-fKernelSize,gy2-fKernelSize);
		sidx= 4*(ly2*slen+lx2);

		shared[sidx+0] = pxl.x;
		shared[sidx+1] = pxl.y;
		shared[sidx+2] = pxl.z;
		shared[sidx+3] = pxl.w;
	}

	__syncthreads();

	// Now that the image has been read
	// into shared memory completely.
	// Check for image bounds and exit
	if( gx >= fImageWidth || gy >= fImageHeight )
		return;

	sidx			= 4*(tj*slen+ti);
	uchar* ptr		= shared + sidx;
	float4 accum	= {0.0f,0.0f,0.0f,0.0f};

	for( int jj=-fKernelSize; jj<=fKernelSize; jj++ )
	{
		for( int ii=-fKernelSize; ii<=fKernelSize; ii++ )
		{
			int tmpidx	= 4*(jj*slen+ii);
			float weight= d_kernel[(fKernelSize+jj)*klen+(fKernelSize+ii)];
			accum.x		+= weight*ptr[tmpidx+0];
			accum.y		+= weight*ptr[tmpidx+1];
			accum.z		+= weight*ptr[tmpidx+2];
		}
	}
	accum.w	= shared[sidx+3];

	setRGBA(fDestination,fImageWidth,fImageHeight,gx,gy,accum);
}


int ceil(int numer, int denom)
{
	return (numer/denom + (numer % denom != 0));
}

MemObject::MemObject()
{
	dev_SourceImage		= 0;
	dev_ConvolvedImage	= 0;
    cuImgArray          = 0;

	// CUDA texture specification
	memset(&resDesc,0,sizeof(resDesc));
	resDesc.resType = cudaResourceTypeArray;
	// CUDA texture object parameters
	memset(&texDesc,0,sizeof(texDesc));
	texDesc.addressMode[0]	= cudaAddressModeWrap;
	texDesc.addressMode[1]	= cudaAddressModeWrap;
	texDesc.filterMode		= cudaFilterModePoint;
	texDesc.readMode		= cudaReadModeElementType;
	texDesc.normalizedCoords= 0;

    texObj = 0;
}

void MemObject::cleanMemory()
{
#if USE_CUDA_TEX_OBJECT
    if (texObj) {
        cudaDestroyTextureObject(texObj);
    }
    if (cuImgArray) {
        cudaFreeArray(cuImgArray);
    }
    cuImgArray = 0;
	texObj     = 0;
#else
	if (dev_SourceImage) {
        cudaFree(dev_SourceImage);
    }
#endif
    if (dev_ConvolvedImage) {
        cudaFree(dev_ConvolvedImage);
    }
	dev_SourceImage		= 0;
	dev_ConvolvedImage	= 0;
}

MemObject::~MemObject()
{
	cleanMemory();
}

MemObject* getMemObject(void)
{
	static MemObject* handle = 0;
	if( handle == 0 ) {
		handle = new MemObject();
	}
	return handle;
}

void initMemObject(void)
{
	getMemObject();
}

void setKernelOnDevice(float const * elements, const int count)
{
	HANDLE_ERROR( cudaMemcpyToSymbol(d_kernel, elements, count*sizeof(float)) );
	CHECK_CUDA_ERRORS();
}

void setImageOnDevice(const uchar * image_data, const int image_width, const int image_height)
{
	MemObject* handle = getMemObject();
	handle->cleanMemory();

	handle->mImageWidth		= image_width;
	handle->mImageHeight	= image_height;

#if USE_CUDA_TEX_OBJECT
	handle->channelDesc = cudaCreateChannelDesc<uchar4>();
	HANDLE_ERROR( cudaMallocArray(&(handle->cuImgArray), &(handle->channelDesc), image_width, image_height) );
	HANDLE_ERROR( cudaMemcpyToArray(handle->cuImgArray, 0,0, image_data,
							image_width*image_height*4*sizeof(uchar),
							cudaMemcpyHostToDevice) );
	handle->resDesc.res.array.array = handle->cuImgArray;
	cudaCreateTextureObject(&(handle->texObj),&(handle->resDesc),&(handle->texDesc),NULL);

#else
	/* Allocate memory on device to hold image data */
	HANDLE_ERROR( cudaMalloc((void**)&handle->dev_SourceImage,
							 image_width*image_height*4*sizeof(uchar)) );
	CHECK_CUDA_ERRORS();

	/* Copy this data to device memory for kernel computation */
	HANDLE_ERROR( cudaMemcpy( handle->dev_SourceImage, image_data,
							  image_width*image_height*4*sizeof(uchar),
							  cudaMemcpyHostToDevice) );
	CHECK_CUDA_ERRORS();

#endif

	/* Allocate memory for output image on GPU device memory */
	HANDLE_ERROR( cudaMalloc((void**)&handle->dev_ConvolvedImage,
							 image_width*image_height*4*sizeof(uchar)) );
	CHECK_CUDA_ERRORS();
}

void convolve(const int kernel_radius)
{
	static dim3	mThreadsPerBlock(TILE_WIDTH,TILE_HEIGHT);

	MemObject* handle = getMemObject();
	int image_width = handle->mImageWidth;
	int image_height = handle->mImageHeight;

	dim3	mGrid(ceil(image_width, mThreadsPerBlock.x),
				  ceil(image_height, mThreadsPerBlock.y));

	int sharedMemSize = (mThreadsPerBlock.y+2*kernel_radius)*
						(mThreadsPerBlock.x+2*kernel_radius)*
						4*sizeof(uchar);

#ifdef _DEBUG_PRINTS_
	std::cout<<"Threads per block "<<mThreadsPerBlock.x<<","<<mThreadsPerBlock.y<<std::endl;
	std::cout<<"Blocks per grid "<<mGrid.x<<","<<mGrid.y<<std::endl;;
	std::cout<<"Shared memory usage : "<<sharedMemSize<<" Bytes"<<std::endl;;
#endif

#if USE_CUDA_TEX_OBJECT
	convolveKernel<<<mGrid,mThreadsPerBlock,sharedMemSize>>>(handle->texObj,
															 image_width,
															 image_height,
															 handle->dev_ConvolvedImage,
															 kernel_radius);
#else
	convolveKernel<<<mGrid,mThreadsPerBlock,sharedMemSize>>>(handle->dev_SourceImage,
															 image_width, image_height,
															 handle->dev_ConvolvedImage,
															 kernel_radius);
#endif

	CHECK_CUDA_ERRORS();
	cudaDeviceSynchronize();
}

void memCpyImageDeviceToHost(uchar* host_ptr)
{
	MemObject* handle = getMemObject();
	HANDLE_ERROR( cudaMemcpy(host_ptr, handle->dev_ConvolvedImage,
							 handle->mImageWidth*handle->mImageHeight*4*sizeof(uchar),
							 cudaMemcpyDeviceToHost) );

	CHECK_CUDA_ERRORS();
}

	.file	"tmpxft_0020d609_00000000-6_conv.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB3869:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE3869:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%s in %s at line %d\n"
	.text
	.globl	_Z11HandleError9cudaErrorPKci
	.type	_Z11HandleError9cudaErrorPKci, @function
_Z11HandleError9cudaErrorPKci:
.LFB3849:
	.cfi_startproc
	endbr64
	testl	%edi, %edi
	je	.L2
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	movq	%rsi, %rbx
	subq	$16, %rsp
	.cfi_def_cfa_offset 32
	movl	%edx, 12(%rsp)
	call	cudaGetErrorString@PLT
	movl	12(%rsp), %r8d
	movq	%rbx, %rcx
	movl	$2, %edi
	movq	%rax, %rdx
	leaq	.LC0(%rip), %rsi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	call	getchar@PLT
	movl	$1, %edi
	call	exit@PLT
.L2:
	.cfi_def_cfa_offset 8
	.cfi_restore 3
	ret
	.cfi_endproc
.LFE3849:
	.size	_Z11HandleError9cudaErrorPKci, .-_Z11HandleError9cudaErrorPKci
	.globl	_Z10CheckErrorv
	.type	_Z10CheckErrorv, @function
_Z10CheckErrorv:
.LFB3850:
	.cfi_startproc
	endbr64
	ret
	.cfi_endproc
.LFE3850:
	.size	_Z10CheckErrorv, .-_Z10CheckErrorv
	.globl	_Z4ceilii
	.type	_Z4ceilii, @function
_Z4ceilii:
.LFB3853:
	.cfi_startproc
	endbr64
	movl	%edi, %eax
	cltd
	idivl	%esi
	cmpl	$1, %edx
	sbbl	$-1, %eax
	ret
	.cfi_endproc
.LFE3853:
	.size	_Z4ceilii, .-_Z4ceilii
	.align 2
	.globl	_ZN9MemObjectC2Ev
	.type	_ZN9MemObjectC2Ev, @function
_ZN9MemObjectC2Ev:
.LFB3855:
	.cfi_startproc
	endbr64
	xorl	%eax, %eax
	movq	%rdi, %rdx
	leaq	64(%rdi), %rsi
	movl	$16, %ecx
	movq	%rax, 16(%rdi)
	movq	%rax, 24(%rdi)
	movq	%rax, 32(%rdi)
	xorl	%eax, %eax
	movq	%rsi, %rdi
	leaq	128(%rdx), %rsi
	rep stosl
	movl	$18, %ecx
	movq	%rsi, %rdi
	rep stosl
	xorl	%ecx, %ecx
	movq	%rcx, 200(%rdx)
	ret
	.cfi_endproc
.LFE3855:
	.size	_ZN9MemObjectC2Ev, .-_ZN9MemObjectC2Ev
	.globl	_ZN9MemObjectC1Ev
	.set	_ZN9MemObjectC1Ev,_ZN9MemObjectC2Ev
	.align 2
	.globl	_ZN9MemObject11cleanMemoryEv
	.type	_ZN9MemObject11cleanMemoryEv, @function
_ZN9MemObject11cleanMemoryEv:
.LFB3857:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	movq	%rdi, %rbx
	movq	200(%rdi), %rdi
	testq	%rdi, %rdi
	je	.L12
	call	cudaDestroyTextureObject@PLT
.L12:
	movq	32(%rbx), %rdi
	testq	%rdi, %rdi
	je	.L13
	call	cudaFreeArray@PLT
.L13:
	movq	24(%rbx), %rdi
	xorl	%edx, %edx
	movq	%rdx, 32(%rbx)
	movq	%rdx, 200(%rbx)
	testq	%rdi, %rdi
	je	.L14
	call	cudaFree@PLT
.L14:
	xorl	%eax, %eax
	movq	%rax, 16(%rbx)
	movq	%rax, 24(%rbx)
	popq	%rbx
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3857:
	.size	_ZN9MemObject11cleanMemoryEv, .-_ZN9MemObject11cleanMemoryEv
	.align 2
	.globl	_ZN9MemObjectD2Ev
	.type	_ZN9MemObjectD2Ev, @function
_ZN9MemObjectD2Ev:
.LFB3859:
	.cfi_startproc
	.cfi_personality 0x9b,DW.ref.__gxx_personality_v0
	.cfi_lsda 0x1b,.LLSDA3859
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	call	_ZN9MemObject11cleanMemoryEv
	popq	%rdx
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3859:
	.globl	__gxx_personality_v0
	.section	.gcc_except_table,"a",@progbits
.LLSDA3859:
	.byte	0xff
	.byte	0xff
	.byte	0x1
	.uleb128 .LLSDACSE3859-.LLSDACSB3859
.LLSDACSB3859:
.LLSDACSE3859:
	.text
	.size	_ZN9MemObjectD2Ev, .-_ZN9MemObjectD2Ev
	.globl	_ZN9MemObjectD1Ev
	.set	_ZN9MemObjectD1Ev,_ZN9MemObjectD2Ev
	.globl	_Z12getMemObjectv
	.type	_Z12getMemObjectv, @function
_Z12getMemObjectv:
.LFB3861:
	.cfi_startproc
	endbr64
	cmpq	$0, _ZZ12getMemObjectvE6handle(%rip)
	jne	.L30
	pushq	%rax
	.cfi_def_cfa_offset 16
	movl	$208, %edi
	call	_Znwm@PLT
	movq	%rax, %r8
	movq	%rax, %rdi
	call	_ZN9MemObjectC1Ev
	movq	%r8, _ZZ12getMemObjectvE6handle(%rip)
	movq	_ZZ12getMemObjectvE6handle(%rip), %rax
	popq	%rdx
	.cfi_def_cfa_offset 8
	ret
.L30:
	movq	_ZZ12getMemObjectvE6handle(%rip), %rax
	ret
	.cfi_endproc
.LFE3861:
	.size	_Z12getMemObjectv, .-_Z12getMemObjectv
	.globl	_Z13initMemObjectv
	.type	_Z13initMemObjectv, @function
_Z13initMemObjectv:
.LFB3862:
	.cfi_startproc
	endbr64
	jmp	_Z12getMemObjectv
	.cfi_endproc
.LFE3862:
	.size	_Z13initMemObjectv, .-_Z13initMemObjectv
	.section	.rodata.str1.1
.LC1:
	.string	"/home/ubuntu/Datasets/stackv2/train-structured/9prady9/ImageConvolve/master/src/conv.cu"
	.text
	.globl	_Z17setKernelOnDevicePKfi
	.type	_Z17setKernelOnDevicePKfi, @function
_Z17setKernelOnDevicePKfi:
.LFB3863:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	movslq	%esi, %rdx
	xorl	%ecx, %ecx
	movq	%rdi, %rsi
	salq	$2, %rdx
	leaq	_ZL8d_kernel(%rip), %rdi
	movl	$1, %r8d
	call	cudaMemcpyToSymbol@PLT
	movl	$299, %edx
	leaq	.LC1(%rip), %rsi
	popq	%rcx
	.cfi_def_cfa_offset 8
	movl	%eax, %edi
	jmp	_Z11HandleError9cudaErrorPKci
	.cfi_endproc
.LFE3863:
	.size	_Z17setKernelOnDevicePKfi, .-_Z17setKernelOnDevicePKfi
	.globl	_Z16setImageOnDevicePKhii
	.type	_Z16setImageOnDevicePKhii, @function
_Z16setImageOnDevicePKhii:
.LFB3864:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	movl	%edx, %r14d
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	movq	%rdi, %r13
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	leaq	.LC1(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	movl	%esi, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	subq	$32, %rsp
	.cfi_def_cfa_offset 80
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	call	_Z12getMemObjectv
	movq	%rax, %rbx
	movq	%rax, %rdi
	call	_ZN9MemObject11cleanMemoryEv
	movl	%ebp, 4(%rbx)
	movl	$1, %r9d
	leaq	4(%rsp), %rdi
	movl	%r14d, 8(%rbx)
	movl	$8, %r8d
	movl	$8, %ecx
	movl	$8, %edx
	movl	$8, %esi
	call	cudaCreateChannelDesc@PLT
	movl	20(%rsp), %eax
	movslq	%ebp, %rdx
	imull	%r14d, %ebp
	movups	4(%rsp), %xmm0
	movslq	%r14d, %rcx
	xorl	%r8d, %r8d
	leaq	40(%rbx), %rsi
	movl	%eax, 56(%rbx)
	leaq	32(%rbx), %rdi
	movups	%xmm0, 40(%rbx)
	sall	$2, %ebp
	movslq	%ebp, %rbp
	call	cudaMallocArray@PLT
	movl	$313, %edx
	movq	%r12, %rsi
	movl	%eax, %edi
	call	_Z11HandleError9cudaErrorPKci
	movq	32(%rbx), %rdi
	movq	%rbp, %r8
	movq	%r13, %rcx
	movl	$1, %r9d
	xorl	%edx, %edx
	xorl	%esi, %esi
	call	cudaMemcpyToArray@PLT
	movl	$314, %edx
	movq	%r12, %rsi
	movl	%eax, %edi
	call	_Z11HandleError9cudaErrorPKci
	movq	32(%rbx), %rax
	leaq	64(%rbx), %rsi
	xorl	%ecx, %ecx
	leaq	128(%rbx), %rdx
	leaq	200(%rbx), %rdi
	movq	%rax, 72(%rbx)
	call	cudaCreateTextureObject@PLT
	leaq	24(%rbx), %rdi
	movq	%rbp, %rsi
	call	cudaMalloc@PLT
	movl	%eax, %edi
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	je	.L37
	call	__stack_chk_fail@PLT
.L37:
	addq	$32, %rsp
	.cfi_def_cfa_offset 48
	movq	%r12, %rsi
	movl	$335, %edx
	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
	jmp	_Z11HandleError9cudaErrorPKci
	.cfi_endproc
.LFE3864:
	.size	_Z16setImageOnDevicePKhii, .-_Z16setImageOnDevicePKhii
	.globl	_Z23memCpyImageDeviceToHostPh
	.type	_Z23memCpyImageDeviceToHostPh, @function
_Z23memCpyImageDeviceToHostPh:
.LFB3866:
	.cfi_startproc
	endbr64
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movq	%rdi, 8(%rsp)
	call	_Z12getMemObjectv
	movq	8(%rsp), %rdi
	movl	$2, %ecx
	movl	4(%rax), %edx
	imull	8(%rax), %edx
	movq	24(%rax), %rsi
	leal	0(,%rdx,4), %edx
	call	cudaMemcpy@PLT
	movl	$381, %edx
	leaq	.LC1(%rip), %rsi
	addq	$24, %rsp
	.cfi_def_cfa_offset 8
	movl	%eax, %edi
	jmp	_Z11HandleError9cudaErrorPKci
	.cfi_endproc
.LFE3866:
	.size	_Z23memCpyImageDeviceToHostPh, .-_Z23memCpyImageDeviceToHostPh
	.globl	_Z40__device_stub__Z14convolveKernelPKhiiPhiPKhiiPhi
	.type	_Z40__device_stub__Z14convolveKernelPKhiiPhiPKhiiPhi, @function
_Z40__device_stub__Z14convolveKernelPKhiiPhiPKhiiPhi:
.LFB3891:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movq	%rdi, 24(%rsp)
	leaq	48(%rsp), %rdi
	movl	%esi, 20(%rsp)
	leaq	60(%rsp), %rsi
	movl	%edx, 16(%rsp)
	leaq	32(%rsp), %rdx
	movq	%rcx, 8(%rsp)
	leaq	40(%rsp), %rcx
	movl	%r8d, 4(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 56(%rsp)
	movq	%rax, 96(%rsp)
	leaq	20(%rsp), %rax
	movq	%rax, 104(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	4(%rsp), %rax
	movq	%rax, 128(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 48(%rsp)
	movq	%rax, 60(%rsp)
	movl	$1, 68(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L42
	pushq	40(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z14convolveKernelPKhiiPhi(%rip), %rdi
	pushq	40(%rsp)
	.cfi_def_cfa_offset 176
	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 168
	popq	%rdx
	.cfi_def_cfa_offset 160
.L42:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L44
	call	__stack_chk_fail@PLT
.L44:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3891:
	.size	_Z40__device_stub__Z14convolveKernelPKhiiPhiPKhiiPhi, .-_Z40__device_stub__Z14convolveKernelPKhiiPhiPKhiiPhi
	.globl	_Z14convolveKernelPKhiiPhi
	.type	_Z14convolveKernelPKhiiPhi, @function
_Z14convolveKernelPKhiiPhi:
.LFB3892:
	.cfi_startproc
	endbr64
	jmp	_Z40__device_stub__Z14convolveKernelPKhiiPhiPKhiiPhi
	.cfi_endproc
.LFE3892:
	.size	_Z14convolveKernelPKhiiPhi, .-_Z14convolveKernelPKhiiPhi
	.globl	_Z38__device_stub__Z14convolveKernelyiiPhiyiiPhi
	.type	_Z38__device_stub__Z14convolveKernelyiiPhiyiiPhi, @function
_Z38__device_stub__Z14convolveKernelyiiPhiyiiPhi:
.LFB3893:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movq	%rdi, 24(%rsp)
	leaq	48(%rsp), %rdi
	movl	%esi, 20(%rsp)
	leaq	60(%rsp), %rsi
	movl	%edx, 16(%rsp)
	leaq	32(%rsp), %rdx
	movq	%rcx, 8(%rsp)
	leaq	40(%rsp), %rcx
	movl	%r8d, 4(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 56(%rsp)
	movq	%rax, 96(%rsp)
	leaq	20(%rsp), %rax
	movq	%rax, 104(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	4(%rsp), %rax
	movq	%rax, 128(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 48(%rsp)
	movq	%rax, 60(%rsp)
	movl	$1, 68(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L47
	pushq	40(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z14convolveKernelyiiPhi(%rip), %rdi
	pushq	40(%rsp)
	.cfi_def_cfa_offset 176
	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 168
	popq	%rdx
	.cfi_def_cfa_offset 160
.L47:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L49
	call	__stack_chk_fail@PLT
.L49:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3893:
	.size	_Z38__device_stub__Z14convolveKernelyiiPhiyiiPhi, .-_Z38__device_stub__Z14convolveKernelyiiPhiyiiPhi
	.globl	_Z14convolveKernelyiiPhi
	.type	_Z14convolveKernelyiiPhi, @function
_Z14convolveKernelyiiPhi:
.LFB3894:
	.cfi_startproc
	endbr64
	jmp	_Z38__device_stub__Z14convolveKernelyiiPhiyiiPhi
	.cfi_endproc
.LFE3894:
	.size	_Z14convolveKernelyiiPhi, .-_Z14convolveKernelyiiPhi
	.globl	_Z8convolvei
	.type	_Z8convolvei, @function
_Z8convolvei:
.LFB3865:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	movl	%edi, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$24, %rsp
	.cfi_def_cfa_offset 64
	call	_Z12getMemObjectv
	xorl	%esi, %esi
	movl	$32, %ecx
	leal	32(%r13,%r13), %r8d
	movl	4(%rax), %ebp
	movl	8(%rax), %r12d
	movq	%rax, %rbx
	movl	$1, 12(%rsp)
	testl	$31, %ebp
	movl	%ebp, %eax
	setne	%sil
	cltd
	idivl	%ecx
	addl	%eax, %esi
	movl	%r12d, %eax
	movl	%esi, 4(%rsp)
	xorl	%esi, %esi
	testl	$31, %r12d
	setne	%sil
	imull	%r8d, %r8d
	cltd
	xorl	%r9d, %r9d
	idivl	%ecx
	movq	_ZZ8convolveiE16mThreadsPerBlock(%rip), %rdx
	movl	8+_ZZ8convolveiE16mThreadsPerBlock(%rip), %ecx
	sall	$2, %r8d
	movslq	%r8d, %r8
	addl	%eax, %esi
	movl	%esi, 8(%rsp)
	movq	4(%rsp), %rdi
	movl	$1, %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L53
	movq	24(%rbx), %rcx
	movq	200(%rbx), %rdi
	movl	%r13d, %r8d
	movl	%ebp, %esi
	movl	%r12d, %edx
	call	_Z38__device_stub__Z14convolveKernelyiiPhiyiiPhi
.L53:
	addq	$24, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	jmp	cudaDeviceSynchronize@PLT
	.cfi_endproc
.LFE3865:
	.size	_Z8convolvei, .-_Z8convolvei
	.section	.rodata.str1.1
.LC2:
	.string	"_Z14convolveKernelyiiPhi"
.LC3:
	.string	"_Z14convolveKernelPKhiiPhi"
.LC4:
	.string	"precalc_xorwow_matrix"
.LC5:
	.string	"precalc_xorwow_offset_matrix"
.LC6:
	.string	"mrg32k3aM1"
.LC7:
	.string	"mrg32k3aM2"
.LC8:
	.string	"mrg32k3aM1SubSeq"
.LC9:
	.string	"mrg32k3aM2SubSeq"
.LC10:
	.string	"mrg32k3aM1Seq"
.LC11:
	.string	"mrg32k3aM2Seq"
.LC12:
	.string	"__cr_lgamma_table"
.LC13:
	.string	"d_kernel"
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB3896:
	.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	.LC2(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z14convolveKernelyiiPhi(%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	.LC3(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z14convolveKernelPKhiiPhi(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 40
	pushq	$0
	.cfi_def_cfa_offset 48
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC4(%rip), %rdx
	movl	$102400, %r9d
	leaq	_ZL21precalc_xorwow_matrix(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	call	__cudaRegisterVar@PLT
	popq	%rax
	.cfi_def_cfa_offset 24
	popq	%rdx
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC5(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movq	%rdx, %rcx
	movl	$102400, %r9d
	leaq	_ZL28precalc_xorwow_offset_matrix(%rip), %rsi
	call	__cudaRegisterVar@PLT
	popq	%rcx
	.cfi_def_cfa_offset 24
	popq	%rsi
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC6(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movq	%rdx, %rcx
	movl	$2304, %r9d
	leaq	_ZL10mrg32k3aM1(%rip), %rsi
	call	__cudaRegisterVar@PLT
	popq	%rdi
	.cfi_def_cfa_offset 24
	popq	%r8
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC7(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movq	%rdx, %rcx
	movl	$2304, %r9d
	leaq	_ZL10mrg32k3aM2(%rip), %rsi
	call	__cudaRegisterVar@PLT
	popq	%r9
	.cfi_def_cfa_offset 24
	popq	%r10
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC8(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movq	%rdx, %rcx
	movl	$2016, %r9d
	leaq	_ZL16mrg32k3aM1SubSeq(%rip), %rsi
	call	__cudaRegisterVar@PLT
	popq	%r11
	.cfi_def_cfa_offset 24
	popq	%rax
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC9(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movq	%rdx, %rcx
	movl	$2016, %r9d
	leaq	_ZL16mrg32k3aM2SubSeq(%rip), %rsi
	call	__cudaRegisterVar@PLT
	popq	%rax
	.cfi_def_cfa_offset 24
	popq	%rdx
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC10(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movq	%rdx, %rcx
	movl	$2304, %r9d
	leaq	_ZL13mrg32k3aM1Seq(%rip), %rsi
	call	__cudaRegisterVar@PLT
	popq	%rcx
	.cfi_def_cfa_offset 24
	popq	%rsi
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC11(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movq	%rdx, %rcx
	movl	$2304, %r9d
	leaq	_ZL13mrg32k3aM2Seq(%rip), %rsi
	call	__cudaRegisterVar@PLT
	popq	%rdi
	.cfi_def_cfa_offset 24
	popq	%r8
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$1
	.cfi_def_cfa_offset 32
	leaq	.LC12(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movq	%rdx, %rcx
	movl	$72, %r9d
	leaq	_ZL17__cr_lgamma_table(%rip), %rsi
	call	__cudaRegisterVar@PLT
	popq	%r9
	.cfi_def_cfa_offset 24
	popq	%r10
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$1
	.cfi_def_cfa_offset 32
	leaq	.LC13(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movl	$324, %r9d
	movq	%rdx, %rcx
	leaq	_ZL8d_kernel(%rip), %rsi
	call	__cudaRegisterVar@PLT
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	popq	%r11
	.cfi_def_cfa_offset 24
	popq	%rbx
	.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
.LFE3896:
	.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
	.align 8
	.type	_ZZ8convolveiE16mThreadsPerBlock, @object
	.size	_ZZ8convolveiE16mThreadsPerBlock, 12
_ZZ8convolveiE16mThreadsPerBlock:
	.long	32
	.long	32
	.long	1
	.local	_ZZ12getMemObjectvE6handle
	.comm	_ZZ12getMemObjectvE6handle,8,8
	.local	_ZL8d_kernel
	.comm	_ZL8d_kernel,324,32
	.local	_ZL17__cr_lgamma_table
	.comm	_ZL17__cr_lgamma_table,72,32
	.local	_ZL13mrg32k3aM2Seq
	.comm	_ZL13mrg32k3aM2Seq,2304,32
	.local	_ZL13mrg32k3aM1Seq
	.comm	_ZL13mrg32k3aM1Seq,2304,32
	.local	_ZL16mrg32k3aM2SubSeq
	.comm	_ZL16mrg32k3aM2SubSeq,2016,32
	.local	_ZL16mrg32k3aM1SubSeq
	.comm	_ZL16mrg32k3aM1SubSeq,2016,32
	.local	_ZL10mrg32k3aM2
	.comm	_ZL10mrg32k3aM2,2304,32
	.local	_ZL10mrg32k3aM1
	.comm	_ZL10mrg32k3aM1,2304,32
	.local	_ZL28precalc_xorwow_offset_matrix
	.comm	_ZL28precalc_xorwow_offset_matrix,102400,32
	.local	_ZL21precalc_xorwow_matrix
	.comm	_ZL21precalc_xorwow_matrix,102400,32
	.hidden	DW.ref.__gxx_personality_v0
	.weak	DW.ref.__gxx_personality_v0
	.section	.data.rel.local.DW.ref.__gxx_personality_v0,"awG",@progbits,DW.ref.__gxx_personality_v0,comdat
	.align 8
	.type	DW.ref.__gxx_personality_v0, @object
	.size	DW.ref.__gxx_personality_v0, 8
DW.ref.__gxx_personality_v0:
	.quad	__gxx_personality_v0
	.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:

#ifndef __CONV_H__
#define __CONV_H__

#include <cstdio>
#include <hiprand/hiprand_kernel.h>

typedef unsigned char uchar;
typedef unsigned int  uint;

const int TILE_WIDTH = 32;
const int TILE_HEIGHT = 32;

#define USE_CUDA_TEX_OBJECT 1

void HandleError( hipError_t err, const char *file, int line );

#define HANDLE_ERROR( err ) (HandleError( err, __FILE__, __LINE__ ))

void CheckError(void);

#define CHECK_CUDA_ERRORS() (CheckError())

int ceil(int numer, int denom);

class MemObject {
public:
	// Methods
	MemObject();
	void cleanMemory();
	~MemObject();

	// Attributes
	uint		mKernelSize;
	uint		mImageWidth;
	uint		mImageHeight;
	uchar*		dev_SourceImage;
	uchar*		dev_ConvolvedImage;
	hipArray*	cuImgArray;

	hipChannelFormatDesc	channelDesc;
	hipResourceDesc		resDesc;
	hipTextureDesc			texDesc;
	hipTextureObject_t		texObj;
};

void initMemObject(void);

void setKernelOnDevice(float const * elements, const int count);

void setImageOnDevice(const uchar * image_data, const int image_width, const int image_height);

void convolve(const int kernel_radius);

void memCpyImageDeviceToHost(uchar* host_ptr);

#endif //__CONV_H__

	.text
	.file	"conv.hip"
	.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 __hip_cuid_

	.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_
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.amdgpu_metadata
---
amdhsa.kernels:  []
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
