// Matrix addition, CPU version
// gcc matrix_cpu.c -o matrix_cpu -std=c99

#include <stdio.h>
#include <math.h>

void printDeviceProperties(){
	cudaDeviceProp prop;
	cudaGetDeviceProperties(&prop, 0);
	printf("  Device name: %s\n", prop.name);
	printf("  Memory Clock Rate (KHz): %d\n",
				 prop.memoryClockRate);
	printf("  Memory Bus Width (bits): %d\n",
				 prop.memoryBusWidth);
	printf("  Peak Memory Bandwidth (GB/s): %f\n\n",
				 2.0*prop.memoryClockRate*(prop.memoryBusWidth/8)/1.0e6);
}


__global__
void add_matrix(float *a, float *b, float *c, int N) {
	int indexX = blockIdx.x * blockDim.x + threadIdx.x;
	int indexY = blockIdx.y * blockDim.y + threadIdx.y;
	int index = indexY * N + indexX;
	c[index] = a[index] + b[index];
}

// https://www.youtube.com/watch?v=fu0gbHnRGYk
__global__
void clear_my_bitch_out(float *c, int N) {
	int indexX = blockIdx.x * blockDim.x + threadIdx.x;
	int indexY = blockIdx.y * blockDim.y + threadIdx.y;
	int index = indexY * N + indexX;
	c[index] = 0;
}


int main() {
	printDeviceProperties();
	for (unsigned int i = 5; i < 11; i++) {
		const int N = pow(2, i);
		const int blockSize = pow(2, 4);

		cudaEvent_t start, stop;
		cudaEventCreate(&start);
		cudaEventCreate(&stop);

		float* a = new float[N*N];
		float* b = new float[N*N];
		float* c = new float[N*N];
		float* ad;
		float* bd;
		float* cd;
		const int size = N * N * sizeof(float);
		cudaMalloc((void**)&ad, size);
		cudaMalloc((void**)&bd, size);
		cudaMalloc((void**)&cd, size);

		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++)	{
				a[i+j*N] = 10 + i;
				b[i+j*N] = (float)j / N;
			}
		}
		cudaMemcpy(ad, a, size, cudaMemcpyHostToDevice);
		cudaMemcpy(bd, b, size, cudaMemcpyHostToDevice);

		dim3 dimBlock(blockSize, blockSize);
		dim3 dimGrid(N/blockSize, N/blockSize);
		cudaEventRecord(start);
		add_matrix<<<dimGrid, dimBlock>>>(ad, bd, cd, N);
		cudaEventRecord(stop);
		cudaThreadSynchronize();
		cudaMemcpy(c, cd, size, cudaMemcpyDeviceToHost);

		cudaEventSynchronize(stop);
		float milliseconds = 0;
		cudaEventElapsedTime(&milliseconds, start, stop);

		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				printf("%0.2f ", c[i+j*N]);
			}
			printf("\n");
		}
		printf(
				"GPU execution took %f milliseconds for N=%d, Blocks=%dx%d, Grid=%dx%d.\n",
				milliseconds, N, dimBlock.x, dimBlock.y, dimGrid.x, dimGrid.y);

		// Try to clean up everything on the GPU, and do it twice!
		clear_my_bitch_out<<<dimGrid, dimBlock>>>(cd, N);
		cudaDeviceReset();
	}
}

	.file	"tmpxft_002cb38f_00000000-6_matrix_gpu.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2032:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2032:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"  Device name: %s\n"
.LC1:
	.string	"  Memory Clock Rate (KHz): %d\n"
.LC2:
	.string	"  Memory Bus Width (bits): %d\n"
.LC4:
	.string	"  Peak Memory Bandwidth (GB/s): %f\n\n"
	.text
	.globl	_Z21printDevicePropertiesv
	.type	_Z21printDevicePropertiesv, @function
_Z21printDevicePropertiesv:
.LFB2027:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	xorl	%esi, %esi
	subq	$1040, %rsp
	.cfi_def_cfa_offset 1056
	movq	%fs:40, %rax
	movq	%rax, 1032(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rbx
	movq	%rbx, %rdi
	call	cudaGetDeviceProperties_v2@PLT
	movq	%rbx, %rdx
	movl	$2, %edi
	xorl	%eax, %eax
	leaq	.LC0(%rip), %rsi
	call	__printf_chk@PLT
	movl	608(%rsp), %edx
	leaq	.LC1(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
	movl	612(%rsp), %edx
	leaq	.LC2(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
	movl	$8, %ecx
	movl	$2, %edi
	movl	612(%rsp), %eax
	cvtsi2sdl	608(%rsp), %xmm0
	leaq	.LC4(%rip), %rsi
	cltd
	idivl	%ecx
	addsd	%xmm0, %xmm0
	cvtsi2sdl	%eax, %xmm1
	movb	$1, %al
	mulsd	%xmm1, %xmm0
	divsd	.LC3(%rip), %xmm0
	call	__printf_chk@PLT
	movq	1032(%rsp), %rax
	subq	%fs:40, %rax
	je	.L3
	call	__stack_chk_fail@PLT
.L3:
	addq	$1040, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2027:
	.size	_Z21printDevicePropertiesv, .-_Z21printDevicePropertiesv
	.globl	_Z35__device_stub__Z10add_matrixPfS_S_iPfS_S_i
	.type	_Z35__device_stub__Z10add_matrixPfS_S_iPfS_S_i, @function
_Z35__device_stub__Z10add_matrixPfS_S_iPfS_S_i:
.LFB2054:
	.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	.L6
	pushq	48(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z10add_matrixPfS_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
.L6:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L8
	call	__stack_chk_fail@PLT
.L8:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2054:
	.size	_Z35__device_stub__Z10add_matrixPfS_S_iPfS_S_i, .-_Z35__device_stub__Z10add_matrixPfS_S_iPfS_S_i
	.globl	_Z10add_matrixPfS_S_i
	.type	_Z10add_matrixPfS_S_i, @function
_Z10add_matrixPfS_S_i:
.LFB2055:
	.cfi_startproc
	endbr64
	jmp	_Z35__device_stub__Z10add_matrixPfS_S_iPfS_S_i
	.cfi_endproc
.LFE2055:
	.size	_Z10add_matrixPfS_S_i, .-_Z10add_matrixPfS_S_i
	.globl	_Z39__device_stub__Z18clear_my_bitch_outPfiPfi
	.type	_Z39__device_stub__Z18clear_my_bitch_outPfiPfi, @function
_Z39__device_stub__Z18clear_my_bitch_outPfiPfi:
.LFB2056:
	.cfi_startproc
	endbr64
	subq	$120, %rsp
	.cfi_def_cfa_offset 128
	movq	%rdi, 8(%rsp)
	leaq	32(%rsp), %rcx
	leaq	24(%rsp), %rdx
	movl	%esi, 4(%rsp)
	leaq	40(%rsp), %rdi
	leaq	52(%rsp), %rsi
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rax
	movl	$1, 48(%rsp)
	movq	%rax, 88(%rsp)
	leaq	4(%rsp), %rax
	movq	%rax, 96(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 40(%rsp)
	movq	%rax, 52(%rsp)
	movl	$1, 60(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L11
	pushq	32(%rsp)
	.cfi_def_cfa_offset 136
	leaq	_Z18clear_my_bitch_outPfi(%rip), %rdi
	pushq	32(%rsp)
	.cfi_def_cfa_offset 144
	movq	68(%rsp), %rcx
	movl	76(%rsp), %r8d
	movq	56(%rsp), %rsi
	movl	64(%rsp), %edx
	leaq	104(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 136
	popq	%rdx
	.cfi_def_cfa_offset 128
.L11:
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	je	.L13
	call	__stack_chk_fail@PLT
.L13:
	addq	$120, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2056:
	.size	_Z39__device_stub__Z18clear_my_bitch_outPfiPfi, .-_Z39__device_stub__Z18clear_my_bitch_outPfiPfi
	.globl	_Z18clear_my_bitch_outPfi
	.type	_Z18clear_my_bitch_outPfi, @function
_Z18clear_my_bitch_outPfi:
.LFB2057:
	.cfi_startproc
	endbr64
	jmp	_Z39__device_stub__Z18clear_my_bitch_outPfiPfi
	.cfi_endproc
.LFE2057:
	.size	_Z18clear_my_bitch_outPfi, .-_Z18clear_my_bitch_outPfi
	.section	.rodata.str1.1
.LC7:
	.string	"%0.2f "
.LC8:
	.string	"\n"
.LC9:
	.string	"GPU execution took %f milliseconds for N=%d, Blocks=%dx%d, Grid=%dx%d.\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2028:
	.cfi_startproc
	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
	movl	$5, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$104, %rsp
	.cfi_def_cfa_offset 160
	movq	%fs:40, %rax
	movq	%rax, 88(%rsp)
	xorl	%eax, %eax
	call	_Z21printDevicePropertiesv
.L25:
	cvtsi2sdl	%r12d, %xmm1
	movsd	.LC5(%rip), %xmm0
	call	pow@PLT
	leaq	24(%rsp), %rdi
	cvttsd2sil	%xmm0, %ebx
	call	cudaEventCreate@PLT
	leaq	32(%rsp), %rdi
	call	cudaEventCreate@PLT
	movl	%ebx, %ebp
	movslq	%ebx, %r14
	imull	%ebx, %ebp
	salq	$2, %r14
	movslq	%ebp, %r13
	sall	$2, %ebp
	salq	$2, %r13
	movslq	%ebp, %rbp
	movq	%r13, %rdi
	call	_Znam@PLT
	movq	%r13, %rdi
	movq	%rax, (%rsp)
	call	_Znam@PLT
	movq	%r13, %rdi
	movq	%rax, %r15
	call	_Znam@PLT
	leaq	40(%rsp), %rdi
	movq	%rbp, %rsi
	movq	%rax, %r13
	call	cudaMalloc@PLT
	leaq	48(%rsp), %rdi
	movq	%rbp, %rsi
	call	cudaMalloc@PLT
	leaq	56(%rsp), %rdi
	movq	%rbp, %rsi
	call	cudaMalloc@PLT
	movq	(%rsp), %r8
	xorl	%eax, %eax
.L17:
	movl	%eax, %esi
	cmpl	%eax, %ebx
	jle	.L31
	addl	$10, %esi
	cvtsi2ssl	%ebx, %xmm1
	leaq	0(,%rax,4), %rcx
	xorl	%edx, %edx
	cvtsi2ssl	%esi, %xmm2
.L18:
	cvtsi2ssl	%edx, %xmm0
	incl	%edx
	movss	%xmm2, (%r8,%rcx)
	divss	%xmm1, %xmm0
	movss	%xmm0, (%r15,%rcx)
	addq	%r14, %rcx
	cmpl	%edx, %ebx
	jne	.L18
	incq	%rax
	jmp	.L17
.L31:
	movq	40(%rsp), %rdi
	movq	%r8, %rsi
	movl	$1, %ecx
	movq	%rbp, %rdx
	call	cudaMemcpy@PLT
	movq	48(%rsp), %rdi
	movq	%r15, %rsi
	movq	%rbp, %rdx
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movl	%ebx, %eax
	movl	$16, %ecx
	xorl	%esi, %esi
	cltd
	movq	24(%rsp), %rdi
	movl	$1, 84(%rsp)
	idivl	%ecx
	movl	%eax, %r15d
	call	cudaEventRecord@PLT
	movl	%r15d, 76(%rsp)
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	%r15d, 80(%rsp)
	movl	84(%rsp), %esi
	movl	$1, %ecx
	movabsq	$68719476752, %rdx
	movq	76(%rsp), %rdi
	movq	%rdx, 64(%rsp)
	movl	$1, 72(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L20
	movq	56(%rsp), %rdx
	movq	48(%rsp), %rsi
	movl	%ebx, %ecx
	movq	40(%rsp), %rdi
	call	_Z35__device_stub__Z10add_matrixPfS_S_iPfS_S_i
.L20:
	movq	32(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	call	cudaThreadSynchronize@PLT
	movq	56(%rsp), %rsi
	movq	%rbp, %rdx
	movq	%r13, %rdi
	movl	$2, %ecx
	xorl	%ebp, %ebp
	call	cudaMemcpy@PLT
	movq	32(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movq	32(%rsp), %rdx
	movq	24(%rsp), %rsi
	leaq	20(%rsp), %rdi
	movl	$0x00000000, 20(%rsp)
	call	cudaEventElapsedTime@PLT
.L21:
	cmpl	%ebp, %ebx
	jle	.L32
	leaq	0(%r13,%rbp,4), %r8
	xorl	%ecx, %ecx
.L22:
	movl	$2, %edi
	movb	$1, %al
	leaq	.LC7(%rip), %rsi
	movl	%ecx, 12(%rsp)
	movq	%r8, (%rsp)
	cvtss2sd	(%r8), %xmm0
	call	__printf_chk@PLT
	movl	12(%rsp), %ecx
	movq	(%rsp), %r8
	incl	%ecx
	addq	%r14, %r8
	cmpl	%ecx, %ebx
	jne	.L22
	leaq	.LC8(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	incq	%rbp
	call	__printf_chk@PLT
	jmp	.L21
.L32:
	cvtss2sd	20(%rsp), %xmm0
	pushq	%rax
	.cfi_def_cfa_offset 168
	movl	%r15d, %r9d
	movl	$16, %ecx
	pushq	%r15
	.cfi_def_cfa_offset 176
	movl	$16, %r8d
	movl	%ebx, %edx
	movl	$2, %edi
	leaq	.LC9(%rip), %rsi
	movb	$1, %al
	call	__printf_chk@PLT
	popq	%rdx
	.cfi_def_cfa_offset 168
	popq	%rcx
	.cfi_def_cfa_offset 160
	xorl	%r9d, %r9d
	movl	72(%rsp), %ecx
	movq	64(%rsp), %rdx
	xorl	%r8d, %r8d
	movq	76(%rsp), %rdi
	movl	84(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L24
	movq	56(%rsp), %rdi
	movl	%ebx, %esi
	call	_Z39__device_stub__Z18clear_my_bitch_outPfiPfi
.L24:
	call	cudaDeviceReset@PLT
	incl	%r12d
	cmpl	$11, %r12d
	jne	.L25
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	je	.L26
	call	__stack_chk_fail@PLT
.L26:
	addq	$104, %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
.LFE2028:
	.size	main, .-main
	.section	.rodata.str1.1
.LC10:
	.string	"_Z18clear_my_bitch_outPfi"
.LC11:
	.string	"_Z10add_matrixPfS_S_i"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2059:
	.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	.LC10(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z18clear_my_bitch_outPfi(%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	.LC11(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z10add_matrixPfS_S_i(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 40
	pushq	$0
	.cfi_def_cfa_offset 48
	call	__cudaRegisterFunction@PLT
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE2059:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC3:
	.long	0
	.long	1093567616
	.align 8
.LC5:
	.long	0
	.long	1073741824
	.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:

// Matrix addition, CPU version
// gcc matrix_cpu.c -o matrix_cpu -std=c99


#include <hip/hip_runtime.h>
#include <stdio.h>
#include <math.h>

void printDeviceProperties(){
	hipDeviceProp_t prop;
	hipGetDeviceProperties(&prop, 0);
	printf("  Device name: %s\n", prop.name);
	printf("  Memory Clock Rate (KHz): %d\n",
				 prop.memoryClockRate);
	printf("  Memory Bus Width (bits): %d\n",
				 prop.memoryBusWidth);
	printf("  Peak Memory Bandwidth (GB/s): %f\n\n",
				 2.0*prop.memoryClockRate*(prop.memoryBusWidth/8)/1.0e6);
}


__global__
void add_matrix(float *a, float *b, float *c, int N) {
	int indexX = blockIdx.x * blockDim.x + threadIdx.x;
	int indexY = blockIdx.y * blockDim.y + threadIdx.y;
	int index = indexY * N + indexX;
	c[index] = a[index] + b[index];
}

// https://www.youtube.com/watch?v=fu0gbHnRGYk
__global__
void clear_my_bitch_out(float *c, int N) {
	int indexX = blockIdx.x * blockDim.x + threadIdx.x;
	int indexY = blockIdx.y * blockDim.y + threadIdx.y;
	int index = indexY * N + indexX;
	c[index] = 0;
}


int main() {
	printDeviceProperties();
	for (unsigned int i = 5; i < 11; i++) {
		const int N = pow(2, i);
		const int blockSize = pow(2, 4);

		hipEvent_t start, stop;
		hipEventCreate(&start);
		hipEventCreate(&stop);

		float* a = new float[N*N];
		float* b = new float[N*N];
		float* c = new float[N*N];
		float* ad;
		float* bd;
		float* cd;
		const int size = N * N * sizeof(float);
		hipMalloc((void**)&ad, size);
		hipMalloc((void**)&bd, size);
		hipMalloc((void**)&cd, size);

		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++)	{
				a[i+j*N] = 10 + i;
				b[i+j*N] = (float)j / N;
			}
		}
		hipMemcpy(ad, a, size, hipMemcpyHostToDevice);
		hipMemcpy(bd, b, size, hipMemcpyHostToDevice);

		dim3 dimBlock(blockSize, blockSize);
		dim3 dimGrid(N/blockSize, N/blockSize);
		hipEventRecord(start);
		add_matrix<<<dimGrid, dimBlock>>>(ad, bd, cd, N);
		hipEventRecord(stop);
		hipDeviceSynchronize();
		hipMemcpy(c, cd, size, hipMemcpyDeviceToHost);

		hipEventSynchronize(stop);
		float milliseconds = 0;
		hipEventElapsedTime(&milliseconds, start, stop);

		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				printf("%0.2f ", c[i+j*N]);
			}
			printf("\n");
		}
		printf(
				"GPU execution took %f milliseconds for N=%d, Blocks=%dx%d, Grid=%dx%d.\n",
				milliseconds, N, dimBlock.x, dimBlock.y, dimGrid.x, dimGrid.y);

		// Try to clean up everything on the GPU, and do it twice!
		clear_my_bitch_out<<<dimGrid, dimBlock>>>(cd, N);
		hipDeviceReset();
	}
}

	.text
	.file	"matrix_gpu.hip"
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z21printDevicePropertiesv
.LCPI0_0:
	.quad	0x412e848000000000              # double 1.0E+6
	.text
	.globl	_Z21printDevicePropertiesv
	.type	_Z21printDevicePropertiesv,@function
_Z21printDevicePropertiesv:             # @_Z21printDevicePropertiesv
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$1472, %rsp                     # imm = 0x5C0
	.cfi_def_cfa_offset 1488
	.cfi_offset %rbx, -16
	movq	%rsp, %rbx
	movq	%rbx, %rdi
	xorl	%esi, %esi
	callq	hipGetDevicePropertiesR0600
	movl	$.L.str, %edi
	movq	%rbx, %rsi
	xorl	%eax, %eax
	callq	printf
	movl	608(%rbx), %esi
	movl	$.L.str.1, %edi
	xorl	%eax, %eax
	callq	printf
	movl	612(%rbx), %esi
	movl	$.L.str.2, %edi
	xorl	%eax, %eax
	callq	printf
	cvtsi2sdl	608(%rbx), %xmm1
	movl	612(%rbx), %eax
	leal	7(%rax), %ecx
	testl	%eax, %eax
	cmovnsl	%eax, %ecx
	sarl	$3, %ecx
	cvtsi2sd	%ecx, %xmm0
	addsd	%xmm1, %xmm1
	mulsd	%xmm1, %xmm0
	divsd	.LCPI0_0(%rip), %xmm0
	movl	$.L.str.3, %edi
	movb	$1, %al
	callq	printf
	addq	$1472, %rsp                     # imm = 0x5C0
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	_Z21printDevicePropertiesv, .Lfunc_end0-_Z21printDevicePropertiesv
	.cfi_endproc
                                        # -- End function
	.globl	_Z25__device_stub__add_matrixPfS_S_i # -- Begin function _Z25__device_stub__add_matrixPfS_S_i
	.type	_Z25__device_stub__add_matrixPfS_S_i,@function
_Z25__device_stub__add_matrixPfS_S_i:   # @_Z25__device_stub__add_matrixPfS_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	$_Z10add_matrixPfS_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_end1:
	.size	_Z25__device_stub__add_matrixPfS_S_i, .Lfunc_end1-_Z25__device_stub__add_matrixPfS_S_i
	.cfi_endproc
                                        # -- End function
	.globl	_Z33__device_stub__clear_my_bitch_outPfi # -- Begin function _Z33__device_stub__clear_my_bitch_outPfi
	.type	_Z33__device_stub__clear_my_bitch_outPfi,@function
_Z33__device_stub__clear_my_bitch_outPfi: # @_Z33__device_stub__clear_my_bitch_outPfi
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$80, %rsp
	.cfi_def_cfa_offset 128
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	24(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	4(%rsp), %rcx
	movl	%esi, (%rcx)
	leaq	64(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	leaq	48(%rsp), %r14
	leaq	32(%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	$_Z18clear_my_bitch_outPfi, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$96, %rsp
	.cfi_adjust_cfa_offset -96
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end2:
	.size	_Z33__device_stub__clear_my_bitch_outPfi, .Lfunc_end2-_Z33__device_stub__clear_my_bitch_outPfi
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI3_0:
	.quad	0x4014000000000000              # double 5
.LCPI3_1:
	.quad	0x3ff0000000000000              # double 1
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$88, %rsp
	.cfi_def_cfa_offset 144
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	callq	_Z21printDevicePropertiesv
	movl	$5, %eax
	movsd	.LCPI3_0(%rip), %xmm0           # xmm0 = mem[0],zero
.LBB3_1:                                # =>This Loop Header: Depth=1
                                        #     Child Loop BB3_3 Depth 2
                                        #       Child Loop BB3_4 Depth 3
                                        #     Child Loop BB3_10 Depth 2
                                        #       Child Loop BB3_11 Depth 3
	movl	%eax, 28(%rsp)                  # 4-byte Spill
	movsd	%xmm0, 80(%rsp)                 # 8-byte Spill
	callq	exp2@PLT
	cvttsd2si	%xmm0, %r13d
	leaq	48(%rsp), %rdi
	callq	hipEventCreate
	leaq	16(%rsp), %rdi
	callq	hipEventCreate
	movl	%r13d, %r14d
	imull	%r14d, %r14d
	leaq	(,%r14,4), %r12
	movq	%r12, %rdi
	callq	_Znam
	movq	%rax, %r15
	movq	%r12, %rdi
	callq	_Znam
	movq	%rax, %rbx
	movq	%r12, %rdi
	movq	%r13, %r12
	callq	_Znam
	movq	%rax, %rbp
	shll	$2, %r14d
	movslq	%r14d, %r13
	leaq	40(%rsp), %rdi
	movq	%r13, %rsi
	callq	hipMalloc
	leaq	32(%rsp), %rdi
	movq	%r13, %rsi
	callq	hipMalloc
	leaq	8(%rsp), %rdi
	movq	%r13, %rsi
	callq	hipMalloc
	movl	%r12d, %r14d
	testl	%r12d, %r12d
	jle	.LBB3_6
# %bb.2:                                # %.preheader84.lr.ph
                                        #   in Loop: Header=BB3_1 Depth=1
	xorps	%xmm0, %xmm0
	cvtsi2ss	%r12d, %xmm0
	leaq	(,%r14,4), %rax
	movq	%r15, %rcx
	movq	%rbx, %rdx
	xorl	%esi, %esi
.LBB3_3:                                # %.preheader84
                                        #   Parent Loop BB3_1 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB3_4 Depth 3
	leal	10(%rsi), %edi
	xorps	%xmm1, %xmm1
	cvtsi2ss	%edi, %xmm1
	xorl	%edi, %edi
	xorl	%r8d, %r8d
.LBB3_4:                                #   Parent Loop BB3_1 Depth=1
                                        #     Parent Loop BB3_3 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	movss	%xmm1, (%rcx,%rdi)
	xorps	%xmm2, %xmm2
	cvtsi2ss	%r8d, %xmm2
	divss	%xmm0, %xmm2
	movss	%xmm2, (%rdx,%rdi)
	incq	%r8
	addq	%rax, %rdi
	cmpq	%r8, %r14
	jne	.LBB3_4
# %bb.5:                                # %._crit_edge
                                        #   in Loop: Header=BB3_3 Depth=2
	incq	%rsi
	addq	$4, %rdx
	addq	$4, %rcx
	cmpq	%r14, %rsi
	jne	.LBB3_3
.LBB3_6:                                # %._crit_edge87
                                        #   in Loop: Header=BB3_1 Depth=1
	movq	40(%rsp), %rdi
	movq	%r15, %rsi
	movq	%r13, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	32(%rsp), %rdi
	movq	%rbx, %rsi
	movq	%r13, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	leal	15(%r12), %eax
	testl	%r12d, %r12d
	cmovnsl	%r12d, %eax
	sarl	$4, %eax
	movq	%rax, %rbx
	shlq	$32, %rbx
	movq	%rax, 64(%rsp)                  # 8-byte Spill
	orq	%rax, %rbx
	movq	48(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	%rbx, 56(%rsp)                  # 8-byte Spill
	movq	%rbx, %rdi
	movl	$1, %esi
	movabsq	$68719476752, %rdx              # imm = 0x1000000010
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB3_8
# %bb.7:                                #   in Loop: Header=BB3_1 Depth=1
	movq	40(%rsp), %rdi
	movq	32(%rsp), %rsi
	movq	8(%rsp), %rdx
	movl	%r12d, %ecx
	callq	_Z25__device_stub__add_matrixPfS_S_i
.LBB3_8:                                #   in Loop: Header=BB3_1 Depth=1
	movq	16(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	callq	hipDeviceSynchronize
	movq	8(%rsp), %rsi
	movq	%rbp, %rdi
	movq	%r13, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	movq	16(%rsp), %rdi
	callq	hipEventSynchronize
	movl	$0, 4(%rsp)
	movq	48(%rsp), %rsi
	movq	16(%rsp), %rdx
	leaq	4(%rsp), %rdi
	callq	hipEventElapsedTime
	movq	%r12, 72(%rsp)                  # 8-byte Spill
	testl	%r12d, %r12d
	jle	.LBB3_13
# %bb.9:                                # %.preheader.preheader
                                        #   in Loop: Header=BB3_1 Depth=1
	leaq	(,%r14,4), %r13
	xorl	%r15d, %r15d
.LBB3_10:                               # %.preheader
                                        #   Parent Loop BB3_1 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB3_11 Depth 3
	movq	%r14, %rbx
	movq	%rbp, %r12
.LBB3_11:                               #   Parent Loop BB3_1 Depth=1
                                        #     Parent Loop BB3_10 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	xorps	%xmm0, %xmm0
	cvtss2sd	(%r12), %xmm0
	movl	$.L.str.4, %edi
	movb	$1, %al
	callq	printf
	addq	%r13, %r12
	decq	%rbx
	jne	.LBB3_11
# %bb.12:                               # %._crit_edge90
                                        #   in Loop: Header=BB3_10 Depth=2
	movl	$10, %edi
	callq	putchar@PLT
	incq	%r15
	addq	$4, %rbp
	cmpq	%r14, %r15
	jne	.LBB3_10
.LBB3_13:                               # %._crit_edge92
                                        #   in Loop: Header=BB3_1 Depth=1
	xorps	%xmm0, %xmm0
	cvtss2sd	4(%rsp), %xmm0
	movl	$.L.str.6, %edi
	movq	72(%rsp), %r14                  # 8-byte Reload
	movl	%r14d, %esi
	movl	$16, %edx
	movl	$16, %ecx
	movq	64(%rsp), %r8                   # 8-byte Reload
	movl	%r8d, %r9d
	movb	$1, %al
	callq	printf
	movq	56(%rsp), %rdi                  # 8-byte Reload
	movl	$1, %esi
	movabsq	$68719476752, %rdx              # imm = 0x1000000010
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	movl	28(%rsp), %ebx                  # 4-byte Reload
	jne	.LBB3_15
# %bb.14:                               #   in Loop: Header=BB3_1 Depth=1
	movq	8(%rsp), %rdi
	movl	%r14d, %esi
	callq	_Z33__device_stub__clear_my_bitch_outPfi
.LBB3_15:                               #   in Loop: Header=BB3_1 Depth=1
	callq	hipDeviceReset
	movsd	80(%rsp), %xmm0                 # 8-byte Reload
                                        # xmm0 = mem[0],zero
	addsd	.LCPI3_1(%rip), %xmm0
	incl	%ebx
	cmpl	$11, %ebx
	movl	%ebx, %eax
	jne	.LBB3_1
# %bb.16:
	xorl	%eax, %eax
	addq	$88, %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_end3:
	.size	main, .Lfunc_end3-main
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$32, %rsp
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -16
	movq	__hip_gpubin_handle(%rip), %rbx
	testq	%rbx, %rbx
	jne	.LBB4_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB4_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z10add_matrixPfS_S_i, %esi
	movl	$.L__unnamed_1, %edx
	movl	$.L__unnamed_1, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z18clear_my_bitch_outPfi, %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_end4:
	.size	__hip_module_ctor, .Lfunc_end4-__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	.LBB5_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
.LBB5_2:
	retq
.Lfunc_end5:
	.size	__hip_module_dtor, .Lfunc_end5-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"  Device name: %s\n"
	.size	.L.str, 19

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"  Memory Clock Rate (KHz): %d\n"
	.size	.L.str.1, 31

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"  Memory Bus Width (bits): %d\n"
	.size	.L.str.2, 31

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"  Peak Memory Bandwidth (GB/s): %f\n\n"
	.size	.L.str.3, 37

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

	.type	_Z18clear_my_bitch_outPfi,@object # @_Z18clear_my_bitch_outPfi
	.globl	_Z18clear_my_bitch_outPfi
	.p2align	3, 0x0
_Z18clear_my_bitch_outPfi:
	.quad	_Z33__device_stub__clear_my_bitch_outPfi
	.size	_Z18clear_my_bitch_outPfi, 8

	.type	.L.str.4,@object                # @.str.4
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.4:
	.asciz	"%0.2f "
	.size	.L.str.4, 7

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"GPU execution took %f milliseconds for N=%d, Blocks=%dx%d, Grid=%dx%d.\n"
	.size	.L.str.6, 72

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z10add_matrixPfS_S_i"
	.size	.L__unnamed_1, 22

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_Z18clear_my_bitch_outPfi"
	.size	.L__unnamed_2, 26

	.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 _Z25__device_stub__add_matrixPfS_S_i
	.addrsig_sym _Z33__device_stub__clear_my_bitch_outPfi
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z10add_matrixPfS_S_i
	.addrsig_sym _Z18clear_my_bitch_outPfi
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z10add_matrixPfS_S_i   ; -- Begin function _Z10add_matrixPfS_S_i
	.globl	_Z10add_matrixPfS_S_i
	.p2align	8
	.type	_Z10add_matrixPfS_S_i,@function
_Z10add_matrixPfS_S_i:                  ; @_Z10add_matrixPfS_S_i
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x2c
	s_load_b32 s3, s[0:1], 0x18
	v_bfe_u32 v1, v0, 10, 10
	v_and_b32_e32 v0, 0x3ff, v0
	s_waitcnt lgkmcnt(0)
	s_lshr_b32 s4, s2, 16
	s_and_b32 s2, s2, 0xffff
	v_mad_u64_u32 v[2:3], null, s15, s4, v[1:2]
	s_load_b128 s[4:7], s[0:1], 0x0
	s_mul_i32 s14, s14, s2
	s_load_b64 s[0:1], s[0:1], 0x10
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_lo_u32 v1, v2, s3
	v_add3_u32 v0, s14, v0, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v1, 31, v0
	v_lshlrev_b64 v[0:1], 2, v[0:1]
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v2, vcc_lo, s4, v0
	v_add_co_ci_u32_e32 v3, vcc_lo, s5, v1, vcc_lo
	v_add_co_u32 v4, vcc_lo, s6, v0
	v_add_co_ci_u32_e32 v5, vcc_lo, s7, v1, vcc_lo
	v_add_co_u32 v0, vcc_lo, s0, v0
	global_load_b32 v2, v[2:3], off
	global_load_b32 v3, v[4:5], off
	v_add_co_ci_u32_e32 v1, vcc_lo, s1, v1, vcc_lo
	s_waitcnt vmcnt(0)
	v_add_f32_e32 v2, v2, v3
	global_store_b32 v[0:1], v2, off
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z10add_matrixPfS_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 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_end0:
	.size	_Z10add_matrixPfS_S_i, .Lfunc_end0-_Z10add_matrixPfS_S_i
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 204
; 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: 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
	.protected	_Z18clear_my_bitch_outPfi ; -- Begin function _Z18clear_my_bitch_outPfi
	.globl	_Z18clear_my_bitch_outPfi
	.p2align	8
	.type	_Z18clear_my_bitch_outPfi,@function
_Z18clear_my_bitch_outPfi:              ; @_Z18clear_my_bitch_outPfi
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x1c
	s_load_b32 s3, s[0:1], 0x8
	v_bfe_u32 v1, v0, 10, 10
	v_and_b32_e32 v0, 0x3ff, v0
	s_load_b64 s[0:1], s[0:1], 0x0
	s_waitcnt lgkmcnt(0)
	s_lshr_b32 s4, s2, 16
	s_and_b32 s2, s2, 0xffff
	v_mad_u64_u32 v[2:3], null, s15, s4, v[1:2]
	s_mul_i32 s14, s14, s2
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_mul_lo_u32 v1, v2, s3
	v_mov_b32_e32 v2, 0
	v_add3_u32 v0, s14, v0, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v1, 31, v0
	v_lshlrev_b64 v[0:1], 2, v[0:1]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v0, vcc_lo, s0, v0
	v_add_co_ci_u32_e32 v1, vcc_lo, s1, v1, vcc_lo
	global_store_b32 v[0:1], v2, off
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z18clear_my_bitch_outPfi
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 272
		.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 4
		.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	_Z18clear_my_bitch_outPfi, .Lfunc_end1-_Z18clear_my_bitch_outPfi
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 148
; NumSgprs: 18
; NumVgprs: 4
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 4
; 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:           _Z10add_matrixPfS_S_i
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z10add_matrixPfS_S_i.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     6
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .offset:         8
        .size:           4
        .value_kind:     by_value
      - .offset:         16
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         20
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         24
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         28
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         30
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         32
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         34
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         36
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         38
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         56
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         64
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         80
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 272
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z18clear_my_bitch_outPfi
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z18clear_my_bitch_outPfi.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     4
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
