#include <iostream>
#include <cuda.h>
#include <cstdlib>
#include <time.h>
#include <stdio.h>
#include <fstream>

using namespace std;


__global__ void unfoldkernel(bool* a, bool*mask, bool* c, int n){
	int i = blockIdx.x*blockDim.x+ threadIdx.x;
	int j = blockIdx.y*blockDim.y + threadIdx.y;

	if(i<n && j<n)
		c[i*n+j] = a[i*n+j]&mask[j];
}

void print(bool* a, int m, int n){
	for(int i=0;i<m;i++){
		for(int j=0;j<n;j++)
			cout << a[i*n+j] << '\t';
		cout << endl;
	}
	cout << endl;
}

int main(int argc, char* argv[]){
	//Initialisation variables
	ifstream in;
	in.open(argv[1]);
	int n= atoi(argv[2]);
	int iterations = atoi(argv[3]);
	
	//clock variables
	clock_t start, end;
	double gpu_time_used, cpu_time_used;
	
	//Threads and block configuration
	dim3 threadsPerBlock(16,16);
	dim3 numBlocks((n+threadsPerBlock.x-1)/threadsPerBlock.x, (n+threadsPerBlock.y-1)/threadsPerBlock.y);
	
	//sizes of matrices
	int size_mat = sizeof(bool) * n * n;
	int size_res = size_mat;
	int size_mask = sizeof(bool)*n;

	//memory allocation in host machine
	bool* mat = (bool*)malloc(size_mat);
	bool* res = (bool*)malloc(size_res);
	bool* mask = (bool*)malloc(size_mask);

	//Initializing matrices
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++)
			in >> mat[i*n+j];
	}
	for(int i = 0; i < n; i++)
		in >> mask[i];

	bool *d_mat, *d_mask, *d_res;

	start = clock();

	//Memory allocation in GPU
	cudaMalloc((void**)&d_mat, size_mat);
	cudaMalloc((void**)&d_mask, size_mask);
	cudaMalloc((void**)&d_res, size_res);

	//copy data from host to GPU
	cudaMemcpy(d_mat, mat, size_mat, cudaMemcpyHostToDevice);
	cudaMemcpy(d_mask, mask, size_mask, cudaMemcpyHostToDevice);

	for(int k=0; k<iterations; k++)
		unfoldkernel<<<numBlocks, threadsPerBlock>>>(d_mat, d_mask,d_res, n);

	//copying result
	cudaMemcpy(res, d_res, size_res, cudaMemcpyDeviceToHost);

	end = clock();
	
	//calculating time taken by GPU
	gpu_time_used = ((double)(end-start))/CLOCKS_PER_SEC;

	//CPU computation
	start=clock();
	for(int k = 0; k < iterations; k++){
		for(int j = 0; j < n; j++){
			for(int i = 0; i < n; i++)
				res[j] = mat[i*n+j]&mask[j];
		}
	}	
	end = clock();
	
	//calculating time taken by CPU
	cpu_time_used = ((double)(end-start))/CLOCKS_PER_SEC;
	cout << "CPU/GPU: " << cpu_time_used/gpu_time_used << endl;
	return 0;
}

	.file	"tmpxft_002d0ee0_00000000-6_unfold.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB3770:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE3770:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z5printPbii
	.type	_Z5printPbii, @function
_Z5printPbii:
.LFB3766:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	%esi, %r15d
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movq	%rdi, %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	xorl	%r13d, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	xorl	%r12d, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movl	%edx, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
.L3:
	cmpl	%r15d, %r13d
	jge	.L7
	movslq	%r12d, %rax
	xorl	%ebx, %ebx
	movq	%rax, 8(%rsp)
.L8:
	cmpl	%ebx, %ebp
	jle	.L13
	movq	8(%rsp), %rax
	leaq	_ZSt4cout(%rip), %rdi
	addq	%r14, %rax
	movzbl	(%rax,%rbx), %esi
	call	_ZNSo9_M_insertIbEERSoT_@PLT
	movb	$9, 23(%rsp)
	movq	%rax, %rdi
	movq	(%rax), %rax
	movq	-24(%rax), %rax
	cmpq	$0, 16(%rdi,%rax)
	je	.L4
	leaq	23(%rsp), %rsi
	movl	$1, %edx
	call	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l@PLT
	jmp	.L5
.L4:
	movl	$9, %esi
	call	_ZNSo3putEc@PLT
.L5:
	incq	%rbx
	jmp	.L8
.L13:
	leaq	_ZSt4cout(%rip), %rdi
	incl	%r13d
	addl	%ebp, %r12d
	call	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT
	jmp	.L3
.L7:
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	je	.L9
	call	__stack_chk_fail@PLT
.L9:
	addq	$40, %rsp
	.cfi_def_cfa_offset 56
	leaq	_ZSt4cout(%rip), %rdi
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	jmp	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT
	.cfi_endproc
.LFE3766:
	.size	_Z5printPbii, .-_Z5printPbii
	.globl	_Z37__device_stub__Z12unfoldkernelPbS_S_iPbS_S_i
	.type	_Z37__device_stub__Z12unfoldkernelPbS_S_iPbS_S_i, @function
_Z37__device_stub__Z12unfoldkernelPbS_S_iPbS_S_i:
.LFB3792:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movq	%rdi, 24(%rsp)
	leaq	56(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	68(%rsp), %rsi
	movq	%rdx, 8(%rsp)
	leaq	40(%rsp), %rdx
	movl	%ecx, 4(%rsp)
	leaq	48(%rsp), %rcx
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 64(%rsp)
	movq	%rax, 104(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	4(%rsp), %rax
	movq	%rax, 128(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 56(%rsp)
	movq	%rax, 68(%rsp)
	movl	$1, 76(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L14
	pushq	48(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z12unfoldkernelPbS_S_i(%rip), %rdi
	pushq	48(%rsp)
	.cfi_def_cfa_offset 176
	movq	84(%rsp), %rcx
	movl	92(%rsp), %r8d
	movq	72(%rsp), %rsi
	movl	80(%rsp), %edx
	leaq	120(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 168
	popq	%rdx
	.cfi_def_cfa_offset 160
.L14:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L16
	call	__stack_chk_fail@PLT
.L16:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3792:
	.size	_Z37__device_stub__Z12unfoldkernelPbS_S_iPbS_S_i, .-_Z37__device_stub__Z12unfoldkernelPbS_S_iPbS_S_i
	.globl	_Z12unfoldkernelPbS_S_i
	.type	_Z12unfoldkernelPbS_S_i, @function
_Z12unfoldkernelPbS_S_i:
.LFB3793:
	.cfi_startproc
	endbr64
	jmp	_Z37__device_stub__Z12unfoldkernelPbS_S_iPbS_S_i
	.cfi_endproc
.LFE3793:
	.size	_Z12unfoldkernelPbS_S_i, .-_Z12unfoldkernelPbS_S_i
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"_Z12unfoldkernelPbS_S_i"
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB3795:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 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	.LC0(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z12unfoldkernelPbS_S_i(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 48
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	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	%rdx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE3795:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.rodata.str1.1
.LC2:
	.string	"CPU/GPU: "
	.section	.text.startup
	.globl	main
	.type	main, @function
main:
.LFB3767:
	.cfi_startproc
	.cfi_personality 0x9b,DW.ref.__gxx_personality_v0
	.cfi_lsda 0x1b,.LLSDA3767
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%rsi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$632, %rsp
	.cfi_def_cfa_offset 688
	movq	%fs:40, %rax
	movq	%rax, 616(%rsp)
	xorl	%eax, %eax
	leaq	96(%rsp), %rax
	movq	%rax, %rdi
	movq	%rax, 16(%rsp)
.LEHB0:
	call	_ZNSt14basic_ifstreamIcSt11char_traitsIcEEC1Ev@PLT
.LEHE0:
	movq	8(%rbp), %rsi
	movq	16(%rsp), %rdi
	movl	$8, %edx
.LEHB1:
	call	_ZNSt14basic_ifstreamIcSt11char_traitsIcEE4openEPKcSt13_Ios_Openmode@PLT
	movq	16(%rbp), %rdi
	xorl	%r14d, %r14d
	call	atoi@PLT
	movq	24(%rbp), %rdi
	movslq	%eax, %r13
	call	atoi@PLT
	movl	$1, 80(%rsp)
	movq	%r13, %rbx
	movl	%eax, %r15d
	leal	15(%r13), %eax
	movl	$1, 92(%rsp)
	shrl	$4, %eax
	movl	%eax, 84(%rsp)
	movl	%eax, 88(%rsp)
	movl	%r13d, %eax
	imull	%r13d, %eax
	cltq
	movq	%rax, %rdi
	movq	%rax, 8(%rsp)
	call	malloc@PLT
	movq	8(%rsp), %rdi
	movq	%rax, 24(%rsp)
	call	malloc@PLT
	movq	%r13, %rdi
	movq	%rax, 32(%rsp)
	call	malloc@PLT
	movq	24(%rsp), %rbp
	movq	%rax, %r12
.L22:
	cmpl	%ebx, %r14d
	jge	.L43
	leaq	0(%r13,%rbp), %rax
	movq	%rax, 40(%rsp)
.L23:
	movq	16(%rsp), %rdi
	movq	%rbp, %rsi
	call	_ZNSi10_M_extractIbEERSiRT_@PLT
	movq	40(%rsp), %rax
	incq	%rbp
	cmpq	%rax, %rbp
	jne	.L23
	incl	%r14d
	jmp	.L22
.L43:
	xorl	%ebp, %ebp
.L24:
	cmpl	%ebp, %ebx
	jle	.L44
	movq	16(%rsp), %rdi
	leaq	(%r12,%rbp), %rsi
	call	_ZNSi10_M_extractIbEERSiRT_@PLT
	incq	%rbp
	jmp	.L24
.L44:
	call	clock@PLT
	movq	8(%rsp), %rsi
	leaq	48(%rsp), %rdi
	movq	%rax, %rbp
	call	cudaMalloc@PLT
	leaq	56(%rsp), %rdi
	movq	%r13, %rsi
	call	cudaMalloc@PLT
	movq	8(%rsp), %rsi
	leaq	64(%rsp), %rdi
	call	cudaMalloc@PLT
	movq	8(%rsp), %rdx
	movq	24(%rsp), %rsi
	movl	$1, %ecx
	movq	48(%rsp), %rdi
	call	cudaMemcpy@PLT
	movq	56(%rsp), %rdi
	movl	$1, %ecx
	movq	%r13, %rdx
	movq	%r12, %rsi
	call	cudaMemcpy@PLT
	movabsq	$68719476752, %r14
	xorl	%r13d, %r13d
.L26:
	cmpl	%r15d, %r13d
	jge	.L45
	movl	80(%rsp), %ecx
	movq	84(%rsp), %rdi
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	92(%rsp), %esi
	movq	%r14, %rdx
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L27
	movq	64(%rsp), %rdx
	movq	56(%rsp), %rsi
	movl	%ebx, %ecx
	movq	48(%rsp), %rdi
	call	_Z37__device_stub__Z12unfoldkernelPbS_S_iPbS_S_i
.L27:
	incl	%r13d
	jmp	.L26
.L45:
	movq	8(%rsp), %rdx
	movq	64(%rsp), %rsi
	movl	$2, %ecx
	movq	32(%rsp), %rdi
	call	cudaMemcpy@PLT
	call	clock@PLT
	subq	%rbp, %rax
	cvtsi2sdq	%rax, %xmm0
	divsd	.LC1(%rip), %xmm0
	movsd	%xmm0, 8(%rsp)
	call	clock@PLT
	movq	24(%rsp), %rdx
	xorl	%ecx, %ecx
	movq	%rax, %rbp
	leal	-1(%rbx), %eax
	imull	%ebx, %eax
	cltq
	addq	%rax, %rdx
.L29:
	cmpl	%r15d, %ecx
	jge	.L46
	xorl	%eax, %eax
.L31:
	cmpl	%eax, %ebx
	jle	.L47
	movq	32(%rsp), %rdi
	movb	(%rdx,%rax), %sil
	andb	(%r12,%rax), %sil
	movb	%sil, (%rdi,%rax)
	incq	%rax
	jmp	.L31
.L47:
	incl	%ecx
	jmp	.L29
.L46:
	call	clock@PLT
	leaq	.LC2(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rdi
	subq	%rbp, %rax
	cvtsi2sdq	%rax, %xmm0
	divsd	.LC1(%rip), %xmm0
	movq	%xmm0, %rbx
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%rax, %rdi
	movq	%rbx, %xmm0
	divsd	8(%rsp), %xmm0
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	movq	%rax, %rdi
	call	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT
.LEHE1:
	movq	16(%rsp), %rdi
	call	_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev@PLT
	movq	616(%rsp), %rax
	subq	%fs:40, %rax
	je	.L34
	jmp	.L41
.L38:
	endbr64
	movq	%rax, %rbx
.L32:
	movq	16(%rsp), %rdi
	call	_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev@PLT
	movq	616(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L41
	movq	%rbx, %rdi
.LEHB2:
	call	_Unwind_Resume@PLT
.LEHE2:
.L41:
	call	__stack_chk_fail@PLT
.L34:
	addq	$632, %rsp
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3767:
	.globl	__gxx_personality_v0
	.section	.gcc_except_table,"a",@progbits
.LLSDA3767:
	.byte	0xff
	.byte	0xff
	.byte	0x1
	.uleb128 .LLSDACSE3767-.LLSDACSB3767
.LLSDACSB3767:
	.uleb128 .LEHB0-.LFB3767
	.uleb128 .LEHE0-.LEHB0
	.uleb128 0
	.uleb128 0
	.uleb128 .LEHB1-.LFB3767
	.uleb128 .LEHE1-.LEHB1
	.uleb128 .L38-.LFB3767
	.uleb128 0
	.uleb128 .LEHB2-.LFB3767
	.uleb128 .LEHE2-.LEHB2
	.uleb128 0
	.uleb128 0
.LLSDACSE3767:
	.section	.text.startup
	.size	main, .-main
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC1:
	.long	0
	.long	1093567616
	.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:

#include <iostream>
#include <hip/hip_runtime.h>
#include <cstdlib>
#include <time.h>
#include <stdio.h>
#include <fstream>

using namespace std;


__global__ void unfoldkernel(bool* a, bool*mask, bool* c, int n){
	int i = blockIdx.x*blockDim.x+ threadIdx.x;
	int j = blockIdx.y*blockDim.y + threadIdx.y;

	if(i<n && j<n)
		c[i*n+j] = a[i*n+j]&mask[j];
}

void print(bool* a, int m, int n){
	for(int i=0;i<m;i++){
		for(int j=0;j<n;j++)
			cout << a[i*n+j] << '\t';
		cout << endl;
	}
	cout << endl;
}

int main(int argc, char* argv[]){
	//Initialisation variables
	ifstream in;
	in.open(argv[1]);
	int n= atoi(argv[2]);
	int iterations = atoi(argv[3]);
	
	//clock variables
	clock_t start, end;
	double gpu_time_used, cpu_time_used;
	
	//Threads and block configuration
	dim3 threadsPerBlock(16,16);
	dim3 numBlocks((n+threadsPerBlock.x-1)/threadsPerBlock.x, (n+threadsPerBlock.y-1)/threadsPerBlock.y);
	
	//sizes of matrices
	int size_mat = sizeof(bool) * n * n;
	int size_res = size_mat;
	int size_mask = sizeof(bool)*n;

	//memory allocation in host machine
	bool* mat = (bool*)malloc(size_mat);
	bool* res = (bool*)malloc(size_res);
	bool* mask = (bool*)malloc(size_mask);

	//Initializing matrices
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++)
			in >> mat[i*n+j];
	}
	for(int i = 0; i < n; i++)
		in >> mask[i];

	bool *d_mat, *d_mask, *d_res;

	start = clock();

	//Memory allocation in GPU
	hipMalloc((void**)&d_mat, size_mat);
	hipMalloc((void**)&d_mask, size_mask);
	hipMalloc((void**)&d_res, size_res);

	//copy data from host to GPU
	hipMemcpy(d_mat, mat, size_mat, hipMemcpyHostToDevice);
	hipMemcpy(d_mask, mask, size_mask, hipMemcpyHostToDevice);

	for(int k=0; k<iterations; k++)
		unfoldkernel<<<numBlocks, threadsPerBlock>>>(d_mat, d_mask,d_res, n);

	//copying result
	hipMemcpy(res, d_res, size_res, hipMemcpyDeviceToHost);

	end = clock();
	
	//calculating time taken by GPU
	gpu_time_used = ((double)(end-start))/CLOCKS_PER_SEC;

	//CPU computation
	start=clock();
	for(int k = 0; k < iterations; k++){
		for(int j = 0; j < n; j++){
			for(int i = 0; i < n; i++)
				res[j] = mat[i*n+j]&mask[j];
		}
	}	
	end = clock();
	
	//calculating time taken by CPU
	cpu_time_used = ((double)(end-start))/CLOCKS_PER_SEC;
	cout << "CPU/GPU: " << cpu_time_used/gpu_time_used << endl;
	return 0;
}

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

                                        # End of file scope inline assembly
	.globl	_Z27__device_stub__unfoldkernelPbS_S_i # -- Begin function _Z27__device_stub__unfoldkernelPbS_S_i
	.type	_Z27__device_stub__unfoldkernelPbS_S_i,@function
_Z27__device_stub__unfoldkernelPbS_S_i: # @_Z27__device_stub__unfoldkernelPbS_S_i
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$112, %rsp
	.cfi_def_cfa_offset 160
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	32(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	24(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	4(%rsp), %rdx
	movl	%ecx, (%rdx)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	16(%rsp), %r12
	leaq	8(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z12unfoldkernelPbS_S_i, %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_end0:
	.size	_Z27__device_stub__unfoldkernelPbS_S_i, .Lfunc_end0-_Z27__device_stub__unfoldkernelPbS_S_i
	.cfi_endproc
                                        # -- End function
	.globl	_Z5printPbii                    # -- Begin function _Z5printPbii
	.type	_Z5printPbii,@function
_Z5printPbii:                           # @_Z5printPbii
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rdi, 8(%rsp)                   # 8-byte Spill
	testl	%esi, %esi
	jle	.LBB1_7
# %bb.1:                                # %.preheader.lr.ph
	movl	%esi, %eax
	movq	%rax, 16(%rsp)                  # 8-byte Spill
	movl	%edx, %r13d
	xorl	%ebp, %ebp
	leaq	3(%rsp), %r15
	xorl	%r14d, %r14d
	movl	%edx, 4(%rsp)                   # 4-byte Spill
.LBB1_2:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_4 Depth 2
	testl	%edx, %edx
	jle	.LBB1_6
# %bb.3:                                # %.lr.ph
                                        #   in Loop: Header=BB1_2 Depth=1
	movl	%ebp, %r12d
	addq	8(%rsp), %r12                   # 8-byte Folded Reload
	xorl	%ebx, %ebx
.LBB1_4:                                #   Parent Loop BB1_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movzbl	(%r12,%rbx), %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo9_M_insertIbEERSoT_
	movb	$9, 3(%rsp)
	movq	(%rax), %rcx
	movq	-24(%rcx), %rcx
	cmpq	$0, 16(%rax,%rcx)
	je	.LBB1_8
# %bb.5:                                #   in Loop: Header=BB1_4 Depth=2
	movl	$1, %edx
	movq	%rax, %rdi
	movq	%r15, %rsi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	jmp	.LBB1_9
.LBB1_8:                                #   in Loop: Header=BB1_4 Depth=2
	movq	%rax, %rdi
	movl	$9, %esi
	callq	_ZNSo3putEc
.LBB1_9:                                # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c.exit
                                        #   in Loop: Header=BB1_4 Depth=2
	incq	%rbx
	cmpq	%rbx, %r13
	jne	.LBB1_4
.LBB1_6:                                # %._crit_edge
                                        #   in Loop: Header=BB1_2 Depth=1
	movq	_ZSt4cout(%rip), %rax
	movq	-24(%rax), %rdi
	movl	$_ZSt4cout, %eax
	addq	%rax, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	incq	%r14
	movl	4(%rsp), %edx                   # 4-byte Reload
	addl	%edx, %ebp
	cmpq	16(%rsp), %r14                  # 8-byte Folded Reload
	jne	.LBB1_2
.LBB1_7:                                # %._crit_edge13
	movq	_ZSt4cout(%rip), %rax
	movl	$_ZSt4cout, %ecx
	movq	-24(%rax), %rdi
	addq	%rcx, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	addq	$24, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end1:
	.size	_Z5printPbii, .Lfunc_end1-_Z5printPbii
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI2_0:
	.quad	0x412e848000000000              # double 1.0E+6
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
.Lfunc_begin0:
	.cfi_startproc
	.cfi_personality 3, __gxx_personality_v0
	.cfi_lsda 3, .Lexception0
# %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	$600, %rsp                      # imm = 0x258
	.cfi_def_cfa_offset 656
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rsi, %r14
	leaq	80(%rsp), %rbx
	movq	%rbx, %rdi
	callq	_ZNSt14basic_ifstreamIcSt11char_traitsIcEEC1Ev
	movq	8(%r14), %rsi
.Ltmp0:
	movq	%rbx, %rdi
	movl	$8, %edx
	callq	_ZNSt14basic_ifstreamIcSt11char_traitsIcEE4openEPKcSt13_Ios_Openmode
.Ltmp1:
# %bb.1:
	movq	16(%r14), %rdi
	callq	atoi
	movl	%eax, %r15d
	movq	24(%r14), %rdi
	callq	atoi
	movl	%eax, %r12d
	movslq	%r15d, %r13
	movl	%r15d, %eax
	imull	%r15d, %eax
	movslq	%eax, %rbx
	movq	%rbx, %rdi
	callq	malloc
	movq	%rax, %r14
	movq	%rbx, (%rsp)                    # 8-byte Spill
	movq	%rbx, %rdi
	movq	%r13, %rbx
	callq	malloc
	movq	%rax, 40(%rsp)                  # 8-byte Spill
	movq	%r13, %rdi
	callq	malloc
	movq	%rax, 16(%rsp)                  # 8-byte Spill
	testl	%r15d, %r15d
	jle	.LBB2_11
# %bb.2:                                # %.preheader96.lr.ph
	movq	%rbx, 72(%rsp)                  # 8-byte Spill
	movl	%r12d, 28(%rsp)                 # 4-byte Spill
	movq	%r15, 32(%rsp)                  # 8-byte Spill
	movl	%r15d, %r12d
	xorl	%ebx, %ebx
	leaq	80(%rsp), %r13
	xorl	%r15d, %r15d
	movq	%r12, 8(%rsp)                   # 8-byte Spill
.LBB2_3:                                # %.lr.ph
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB2_4 Depth 2
	movl	%ebx, %ebp
	addq	%r14, %rbp
.LBB2_4:                                #   Parent Loop BB2_3 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
.Ltmp3:
	movq	%r13, %rdi
	movq	%rbp, %rsi
	callq	_ZNSi10_M_extractIbEERSiRT_
.Ltmp4:
# %bb.5:                                # %_ZNSirsERb.exit
                                        #   in Loop: Header=BB2_4 Depth=2
	incq	%rbp
	decq	%r12
	jne	.LBB2_4
# %bb.6:                                # %._crit_edge
                                        #   in Loop: Header=BB2_3 Depth=1
	incq	%r15
	addl	32(%rsp), %ebx                  # 4-byte Folded Reload
	movq	8(%rsp), %r12                   # 8-byte Reload
	cmpq	%r12, %r15
	jne	.LBB2_3
# %bb.7:                                # %.preheader95
	movq	32(%rsp), %r15                  # 8-byte Reload
	testl	%r15d, %r15d
	movl	28(%rsp), %r12d                 # 4-byte Reload
	movq	72(%rsp), %rbx                  # 8-byte Reload
	jle	.LBB2_11
# %bb.8:                                # %.lr.ph100.preheader
	leaq	80(%rsp), %r13
	movq	16(%rsp), %rbp                  # 8-byte Reload
.LBB2_9:                                # %.lr.ph100
                                        # =>This Inner Loop Header: Depth=1
.Ltmp6:
	movq	%r13, %rdi
	movq	%rbp, %rsi
	callq	_ZNSi10_M_extractIbEERSiRT_
.Ltmp7:
# %bb.10:                               # %_ZNSirsERb.exit88
                                        #   in Loop: Header=BB2_9 Depth=1
	incq	%rbp
	decq	8(%rsp)                         # 8-byte Folded Spill
	jne	.LBB2_9
.LBB2_11:                               # %._crit_edge101
	callq	clock
	movq	%rax, 8(%rsp)                   # 8-byte Spill
.Ltmp9:
	leaq	64(%rsp), %rdi
	movq	(%rsp), %rsi                    # 8-byte Reload
	callq	hipMalloc
.Ltmp10:
# %bb.12:
.Ltmp11:
	leaq	56(%rsp), %rdi
	movq	%rbx, %rsi
	callq	hipMalloc
.Ltmp12:
# %bb.13:
.Ltmp13:
	leaq	48(%rsp), %rdi
	movq	(%rsp), %rsi                    # 8-byte Reload
	callq	hipMalloc
.Ltmp14:
# %bb.14:
	movq	64(%rsp), %rdi
.Ltmp15:
	movq	%r14, %rsi
	movq	(%rsp), %rdx                    # 8-byte Reload
	movl	$1, %ecx
	callq	hipMemcpy
.Ltmp16:
# %bb.15:
	movq	56(%rsp), %rdi
.Ltmp17:
	movq	16(%rsp), %rsi                  # 8-byte Reload
	movq	%rbx, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
.Ltmp18:
# %bb.16:                               # %.preheader94
	testl	%r12d, %r12d
	jle	.LBB2_22
# %bb.17:
	leal	15(%r15), %eax
	shrl	$4, %eax
	movq	%rax, %r13
	shlq	$32, %r13
	orq	%rax, %r13
	movabsq	$68719476752, %rbp              # imm = 0x1000000010
	movl	%r12d, %ebx
.LBB2_18:                               # %.lr.ph103
                                        # =>This Inner Loop Header: Depth=1
.Ltmp19:
	movq	%r13, %rdi
	movl	$1, %esi
	movq	%rbp, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
.Ltmp20:
# %bb.19:                               #   in Loop: Header=BB2_18 Depth=1
	testl	%eax, %eax
	jne	.LBB2_21
# %bb.20:                               #   in Loop: Header=BB2_18 Depth=1
	movq	64(%rsp), %rdi
	movq	56(%rsp), %rsi
	movq	48(%rsp), %rdx
.Ltmp21:
	movl	%r15d, %ecx
	callq	_Z27__device_stub__unfoldkernelPbS_S_i
.Ltmp22:
.LBB2_21:                               #   in Loop: Header=BB2_18 Depth=1
	decl	%ebx
	jne	.LBB2_18
.LBB2_22:                               # %._crit_edge104
	movq	48(%rsp), %rsi
.Ltmp24:
	movq	40(%rsp), %rdi                  # 8-byte Reload
	movq	(%rsp), %rdx                    # 8-byte Reload
	movl	$2, %ecx
	callq	hipMemcpy
.Ltmp25:
# %bb.23:
	callq	clock
	movq	%rax, %r13
	callq	clock
	movq	%rax, %rbp
	testl	%r12d, %r12d
	jle	.LBB2_29
# %bb.24:                               # %.preheader93.lr.ph
	leal	-1(%r15), %ecx
	movl	%r15d, %eax
	imull	%r15d, %ecx
	addq	%rcx, %r14
	xorl	%ecx, %ecx
	movq	40(%rsp), %rdi                  # 8-byte Reload
	movq	16(%rsp), %r8                   # 8-byte Reload
.LBB2_25:                               # %.preheader93
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB2_27 Depth 2
	testl	%r15d, %r15d
	jle	.LBB2_28
# %bb.26:                               # %.preheader.preheader
                                        #   in Loop: Header=BB2_25 Depth=1
	xorl	%edx, %edx
.LBB2_27:                               # %.preheader
                                        #   Parent Loop BB2_25 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movb	(%r8,%rdx), %sil
	andb	(%r14,%rdx), %sil
	movb	%sil, (%rdi,%rdx)
	incq	%rdx
	cmpq	%rdx, %rax
	jne	.LBB2_27
.LBB2_28:                               # %._crit_edge109
                                        #   in Loop: Header=BB2_25 Depth=1
	incl	%ecx
	cmpl	%r12d, %ecx
	jne	.LBB2_25
.LBB2_29:                               # %._crit_edge111
	callq	clock
	movq	%rax, %rbx
.Ltmp26:
	movl	$_ZSt4cout, %edi
	movl	$.L.str, %esi
	movl	$9, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp27:
# %bb.30:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit
	subq	8(%rsp), %r13                   # 8-byte Folded Reload
	cvtsi2sd	%r13, %xmm1
	divsd	.LCPI2_0(%rip), %xmm1
	subq	%rbp, %rbx
	cvtsi2sd	%rbx, %xmm0
	divsd	.LCPI2_0(%rip), %xmm0
	divsd	%xmm1, %xmm0
.Ltmp28:
	movl	$_ZSt4cout, %edi
	callq	_ZNSo9_M_insertIdEERSoT_
.Ltmp29:
# %bb.31:                               # %_ZNSolsEd.exit
	movq	%rax, %rbx
	movq	(%rax), %rax
	movq	-24(%rax), %rdi
	addq	%rbx, %rdi
.Ltmp30:
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
.Ltmp31:
# %bb.32:                               # %.noexc
.Ltmp32:
	movsbl	%al, %esi
	movq	%rbx, %rdi
	callq	_ZNSo3putEc
.Ltmp33:
# %bb.33:                               # %.noexc89
.Ltmp34:
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
.Ltmp35:
# %bb.34:                               # %_ZNSolsEPFRSoS_E.exit
	leaq	80(%rsp), %rdi
	callq	_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev
	xorl	%eax, %eax
	addq	$600, %rsp                      # imm = 0x258
	.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
.LBB2_35:
	.cfi_def_cfa_offset 656
.Ltmp2:
	jmp	.LBB2_40
.LBB2_39:
.Ltmp36:
	jmp	.LBB2_40
.LBB2_37:
.Ltmp8:
	jmp	.LBB2_40
.LBB2_38:
.Ltmp23:
	jmp	.LBB2_40
.LBB2_36:
.Ltmp5:
.LBB2_40:
	movq	%rax, %rbx
	leaq	80(%rsp), %rdi
	callq	_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev
	movq	%rbx, %rdi
	callq	_Unwind_Resume@PLT
.Lfunc_end2:
	.size	main, .Lfunc_end2-main
	.cfi_endproc
	.section	.gcc_except_table,"a",@progbits
	.p2align	2, 0x0
GCC_except_table2:
.Lexception0:
	.byte	255                             # @LPStart Encoding = omit
	.byte	255                             # @TType Encoding = omit
	.byte	1                               # Call site Encoding = uleb128
	.uleb128 .Lcst_end0-.Lcst_begin0
.Lcst_begin0:
	.uleb128 .Lfunc_begin0-.Lfunc_begin0    # >> Call Site 1 <<
	.uleb128 .Ltmp0-.Lfunc_begin0           #   Call between .Lfunc_begin0 and .Ltmp0
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp0-.Lfunc_begin0           # >> Call Site 2 <<
	.uleb128 .Ltmp1-.Ltmp0                  #   Call between .Ltmp0 and .Ltmp1
	.uleb128 .Ltmp2-.Lfunc_begin0           #     jumps to .Ltmp2
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp3-.Lfunc_begin0           # >> Call Site 3 <<
	.uleb128 .Ltmp4-.Ltmp3                  #   Call between .Ltmp3 and .Ltmp4
	.uleb128 .Ltmp5-.Lfunc_begin0           #     jumps to .Ltmp5
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp6-.Lfunc_begin0           # >> Call Site 4 <<
	.uleb128 .Ltmp7-.Ltmp6                  #   Call between .Ltmp6 and .Ltmp7
	.uleb128 .Ltmp8-.Lfunc_begin0           #     jumps to .Ltmp8
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp9-.Lfunc_begin0           # >> Call Site 5 <<
	.uleb128 .Ltmp18-.Ltmp9                 #   Call between .Ltmp9 and .Ltmp18
	.uleb128 .Ltmp36-.Lfunc_begin0          #     jumps to .Ltmp36
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp19-.Lfunc_begin0          # >> Call Site 6 <<
	.uleb128 .Ltmp22-.Ltmp19                #   Call between .Ltmp19 and .Ltmp22
	.uleb128 .Ltmp23-.Lfunc_begin0          #     jumps to .Ltmp23
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp24-.Lfunc_begin0          # >> Call Site 7 <<
	.uleb128 .Ltmp35-.Ltmp24                #   Call between .Ltmp24 and .Ltmp35
	.uleb128 .Ltmp36-.Lfunc_begin0          #     jumps to .Ltmp36
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp35-.Lfunc_begin0          # >> Call Site 8 <<
	.uleb128 .Lfunc_end2-.Ltmp35            #   Call between .Ltmp35 and .Lfunc_end2
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
.Lcst_end0:
	.p2align	2, 0x0
                                        # -- End function
	.text
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	jne	.LBB3_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB3_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z12unfoldkernelPbS_S_i, %esi
	movl	$.L__unnamed_1, %edx
	movl	$.L__unnamed_1, %ecx
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$__hip_module_dtor, %edi
	addq	$40, %rsp
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_end3:
	.size	__hip_module_ctor, .Lfunc_end3-__hip_module_ctor
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_dtor
	.type	__hip_module_dtor,@function
__hip_module_dtor:                      # @__hip_module_dtor
	.cfi_startproc
# %bb.0:
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	je	.LBB4_2
# %bb.1:
	pushq	%rax
	.cfi_def_cfa_offset 16
	callq	__hipUnregisterFatBinary
	movq	$0, __hip_gpubin_handle(%rip)
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
.LBB4_2:
	retq
.Lfunc_end4:
	.size	__hip_module_dtor, .Lfunc_end4-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	_Z12unfoldkernelPbS_S_i,@object # @_Z12unfoldkernelPbS_S_i
	.section	.rodata,"a",@progbits
	.globl	_Z12unfoldkernelPbS_S_i
	.p2align	3, 0x0
_Z12unfoldkernelPbS_S_i:
	.quad	_Z27__device_stub__unfoldkernelPbS_S_i
	.size	_Z12unfoldkernelPbS_S_i, 8

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"CPU/GPU: "
	.size	.L.str, 10

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z12unfoldkernelPbS_S_i"
	.size	.L__unnamed_1, 24

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

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

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym _Z27__device_stub__unfoldkernelPbS_S_i
	.addrsig_sym __gxx_personality_v0
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Unwind_Resume
	.addrsig_sym _Z12unfoldkernelPbS_S_i
	.addrsig_sym _ZSt4cout
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z12unfoldkernelPbS_S_i ; -- Begin function _Z12unfoldkernelPbS_S_i
	.globl	_Z12unfoldkernelPbS_S_i
	.p2align	8
	.type	_Z12unfoldkernelPbS_S_i,@function
_Z12unfoldkernelPbS_S_i:                ; @_Z12unfoldkernelPbS_S_i
; %bb.0:
	s_clause 0x1
	s_load_b32 s3, s[0:1], 0x2c
	s_load_b32 s2, s[0:1], 0x18
	v_and_b32_e32 v1, 0x3ff, v0
	v_bfe_u32 v4, v0, 10, 10
	s_waitcnt lgkmcnt(0)
	s_lshr_b32 s4, s3, 16
	s_and_b32 s3, s3, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[2:3], null, s14, s3, v[1:2]
	v_mad_u64_u32 v[0:1], null, s15, s4, v[4:5]
	s_mov_b32 s3, exec_lo
	v_max_i32_e32 v1, v2, v0
	s_delay_alu instid0(VALU_DEP_1)
	v_cmpx_gt_i32_e64 s2, v1
	s_cbranch_execz .LBB0_2
; %bb.1:
	s_load_b128 s[4:7], s[0:1], 0x0
	v_mad_u64_u32 v[3:4], null, v2, s2, v[0:1]
	v_ashrrev_i32_e32 v5, 31, v0
	s_load_b64 s[0:1], s[0:1], 0x10
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_2) | instid1(VALU_DEP_2)
	v_ashrrev_i32_e32 v6, 31, v3
	s_waitcnt lgkmcnt(0)
	v_add_co_u32 v1, vcc_lo, s4, v3
	v_add_co_ci_u32_e32 v2, vcc_lo, s5, v6, vcc_lo
	v_add_co_u32 v4, vcc_lo, s6, v0
	v_add_co_ci_u32_e32 v5, vcc_lo, s7, v5, vcc_lo
	global_load_u8 v0, v[1:2], off
	global_load_u8 v1, v[4:5], off
	s_waitcnt vmcnt(0)
	v_and_b32_e32 v2, v1, v0
	v_add_co_u32 v0, vcc_lo, s0, v3
	v_add_co_ci_u32_e32 v1, vcc_lo, s1, v6, vcc_lo
	global_store_b8 v[0:1], v2, off
.LBB0_2:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z12unfoldkernelPbS_S_i
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 288
		.amdhsa_user_sgpr_count 14
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 1
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 1
		.amdhsa_next_free_vgpr 7
		.amdhsa_next_free_sgpr 16
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end0:
	.size	_Z12unfoldkernelPbS_S_i, .Lfunc_end0-_Z12unfoldkernelPbS_S_i
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 216
; NumSgprs: 18
; NumVgprs: 7
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 7
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 14
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 1
	.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
      - .offset:         24
        .size:           4
        .value_kind:     by_value
      - .offset:         32
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         36
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         40
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         44
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         46
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         48
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         50
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         52
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         54
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         88
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         96
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 288
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z12unfoldkernelPbS_S_i
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z12unfoldkernelPbS_S_i.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     7
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
