#include "OperationHandler.cuh"


#include <stdio.h>

__global__ void matrixMult(const float *a, const float *b, int n, float *c) {
	int bX = blockIdx.x;
	int bY = blockIdx.y;

	int tX = threadIdx.x;
	int tY = threadIdx.y;

	float sum = 0.0f;

	int indexOfA = n * BLOCK_SIZE * bY + n * tY;
	int indexOfB = BLOCK_SIZE * bX + tX;

	int indexOfC = n * BLOCK_SIZE * bY + BLOCK_SIZE * bX;


	for (int k = 0; k < n; k++)
		sum += a[indexOfA + k] * b[indexOfB + k * n];

	c[indexOfC + n * tY + tX] = sum;

}


__global__ void sharedMatrixMult(const float *a, const float *b, int n, float *c) {

	int bx = blockIdx.x, by = blockIdx.y;
	int tx = threadIdx.x, ty = blockIdx.y;

	int aBegin = n * BLOCK_SIZE * by, aEnd = aBegin + n - 1;
	int bBegin = BLOCK_SIZE * bx;
	int aStep = BLOCK_SIZE, bStep = BLOCK_SIZE * n;

	float sum = 0.0f, sum1 = 0.0f;

	
	for (int iA = aBegin, iB = bBegin; iA <= aEnd; iA += aStep, iB += bStep)
	{
		__shared__ float as[BLOCK_SIZE][BLOCK_SIZE];
		__shared__ float bs[BLOCK_SIZE][BLOCK_SIZE];

		as[ty][tx] = a[iA + n * ty + tx];
		bs[ty][tx] = b[iB + n * ty + tx];

		as[ty + BLOCK_SIZE / 2][tx] = a[iA + n * (ty + BLOCK_SIZE / 2) + tx];
		bs[ty + BLOCK_SIZE / 2][tx] = b[iB + n * (ty + BLOCK_SIZE / 2) + tx];

		__syncthreads();
		for (int k = 0; k < BLOCK_SIZE; k++) {
			sum += as[ty][k] * bs[k][tx];
			sum1 += as[ty + BLOCK_SIZE / 2][k] * bs[k][tx];
		}
		__syncthreads();
	}

	

	c[aBegin + bBegin + ty * n + tx] = sum;
	c[aBegin + bBegin + (ty + BLOCK_SIZE / 2) * n + tx] = sum1;
}



__global__ void SMEM3(const float *A, const float *B, int n, float *C) {

	int bx = blockIdx.x;
	int by = blockIdx.y;

	int tx = threadIdx.x;
	int ty = threadIdx.y;

	int aBegin = n * BLOCK_SIZE * by;
	int aEnd = aBegin + n - 1;

	int aStep = BLOCK_SIZE;
	int bStep = BLOCK_SIZE * n;

	int bBegin = BLOCK_SIZE * bx;

	float sum = 0.0f;

	for (int iA = aBegin, iB = bBegin; iA != aEnd; iA += aStep, iB += bStep) {

		__shared__ float as[BLOCK_SIZE][BLOCK_SIZE];
		__shared__ float bs[BLOCK_SIZE][BLOCK_SIZE];

		as[ty][tx] = A[iA + n * ty + tx];
		bs[ty][tx] = B[iA + n * ty + tx];

		__syncthreads();

		for (int k = 0; k < BLOCK_SIZE; k++)
			sum += as[ty][k] * bs[k][tx];
		
		__syncthreads();
	}

	int iC = n * BLOCK_SIZE * by + BLOCK_SIZE * bx;

	C[iC + n * ty + tx] = sum;
}

void multiplyerGPU(const float *A, const float *B, int N, float *C, int type) {
	int numBytes = N * N * sizeof(float);

	float *deviceA = nullptr;
	float *deviceB = nullptr;
	float *deviceC = nullptr;

	cudaMalloc((void**)&deviceA, numBytes);
	cudaMalloc((void**)&deviceB, numBytes);
	cudaMalloc((void**)&deviceC, numBytes);

	dim3 threads(BLOCK_SIZE, BLOCK_SIZE);
	dim3 blocks(N / threads.x, N / threads.y);

	cudaEvent_t start, stop;
	float gpuTime = 0.0f;

	cudaEventCreate(&start);
	cudaEventCreate(&stop);

	cudaEventRecord(start, 0);

	cudaMemcpy(deviceA, A, numBytes, cudaMemcpyHostToDevice);
	cudaMemcpy(deviceB, B, numBytes, cudaMemcpyHostToDevice);
	
	if (type == 0)
		matrixMult << <blocks, threads >> > (deviceA, deviceB, N, deviceC);
	if (type == 1) {
		SMEM3 << <blocks, threads >> > (deviceA, deviceB, N, deviceC);
	}
	if (type == 2) {
		dim3 threads4(BLOCK_SIZE, BLOCK_SIZE / 2);
		sharedMatrixMult << <blocks, threads4 >> > (deviceA, deviceB, N, deviceC);
	}


	cudaMemcpy(C, deviceC, numBytes, cudaMemcpyDeviceToHost);

	cudaEventRecord(stop, 0);
	cudaEventSynchronize(stop);

	cudaEventElapsedTime(&gpuTime, start, stop);

	printf("type = %d; time spent executing by the GPU: %.2f millseconds\n",type, gpuTime);


	cudaEventDestroy(start);
	cudaEventDestroy(stop);
	cudaFree(deviceA);
	cudaFree(deviceB);
	cudaFree(deviceC);


}


void mem_test() {
	int numBytes = 128 * sizeof(double); // 1Kb 
	while (1) {
		double *arr;
		cudaMalloc((void**)&arr, numBytes);
	}
}
	.file	"tmpxft_00309d53_00000000-6_OperationHandler.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2031:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2031:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z8mem_testv
	.type	_Z8mem_testv, @function
_Z8mem_testv:
.LFB2028:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	subq	$16, %rsp
	.cfi_def_cfa_offset 32
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rbx
.L3:
	movl	$1024, %esi
	movq	%rbx, %rdi
	call	cudaMalloc@PLT
	jmp	.L3
	.cfi_endproc
.LFE2028:
	.size	_Z8mem_testv, .-_Z8mem_testv
	.globl	_Z37__device_stub__Z10matrixMultPKfS0_iPfPKfS0_iPf
	.type	_Z37__device_stub__Z10matrixMultPKfS0_iPfPKfS0_iPf, @function
_Z37__device_stub__Z10matrixMultPKfS0_iPfPKfS0_iPf:
.LFB2053:
	.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
	movl	%edx, 12(%rsp)
	leaq	40(%rsp), %rdx
	movq	%rcx, (%rsp)
	leaq	48(%rsp), %rcx
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 64(%rsp)
	movq	%rax, 104(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	12(%rsp), %rax
	movq	%rax, 120(%rsp)
	movq	%rsp, %rax
	movq	%rax, 128(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 56(%rsp)
	movq	%rax, 68(%rsp)
	movl	$1, 76(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L7
	pushq	48(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z10matrixMultPKfS0_iPf(%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
.L7:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L9
	call	__stack_chk_fail@PLT
.L9:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2053:
	.size	_Z37__device_stub__Z10matrixMultPKfS0_iPfPKfS0_iPf, .-_Z37__device_stub__Z10matrixMultPKfS0_iPfPKfS0_iPf
	.globl	_Z10matrixMultPKfS0_iPf
	.type	_Z10matrixMultPKfS0_iPf, @function
_Z10matrixMultPKfS0_iPf:
.LFB2054:
	.cfi_startproc
	endbr64
	jmp	_Z37__device_stub__Z10matrixMultPKfS0_iPfPKfS0_iPf
	.cfi_endproc
.LFE2054:
	.size	_Z10matrixMultPKfS0_iPf, .-_Z10matrixMultPKfS0_iPf
	.globl	_Z43__device_stub__Z16sharedMatrixMultPKfS0_iPfPKfS0_iPf
	.type	_Z43__device_stub__Z16sharedMatrixMultPKfS0_iPfPKfS0_iPf, @function
_Z43__device_stub__Z16sharedMatrixMultPKfS0_iPfPKfS0_iPf:
.LFB2055:
	.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
	movl	%edx, 12(%rsp)
	leaq	40(%rsp), %rdx
	movq	%rcx, (%rsp)
	leaq	48(%rsp), %rcx
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 64(%rsp)
	movq	%rax, 104(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	12(%rsp), %rax
	movq	%rax, 120(%rsp)
	movq	%rsp, %rax
	movq	%rax, 128(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 56(%rsp)
	movq	%rax, 68(%rsp)
	movl	$1, 76(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L12
	pushq	48(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z16sharedMatrixMultPKfS0_iPf(%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
.L12:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L14
	call	__stack_chk_fail@PLT
.L14:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2055:
	.size	_Z43__device_stub__Z16sharedMatrixMultPKfS0_iPfPKfS0_iPf, .-_Z43__device_stub__Z16sharedMatrixMultPKfS0_iPfPKfS0_iPf
	.globl	_Z16sharedMatrixMultPKfS0_iPf
	.type	_Z16sharedMatrixMultPKfS0_iPf, @function
_Z16sharedMatrixMultPKfS0_iPf:
.LFB2056:
	.cfi_startproc
	endbr64
	jmp	_Z43__device_stub__Z16sharedMatrixMultPKfS0_iPfPKfS0_iPf
	.cfi_endproc
.LFE2056:
	.size	_Z16sharedMatrixMultPKfS0_iPf, .-_Z16sharedMatrixMultPKfS0_iPf
	.globl	_Z31__device_stub__Z5SMEM3PKfS0_iPfPKfS0_iPf
	.type	_Z31__device_stub__Z5SMEM3PKfS0_iPfPKfS0_iPf, @function
_Z31__device_stub__Z5SMEM3PKfS0_iPfPKfS0_iPf:
.LFB2057:
	.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
	movl	%edx, 12(%rsp)
	leaq	40(%rsp), %rdx
	movq	%rcx, (%rsp)
	leaq	48(%rsp), %rcx
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 64(%rsp)
	movq	%rax, 104(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	12(%rsp), %rax
	movq	%rax, 120(%rsp)
	movq	%rsp, %rax
	movq	%rax, 128(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 56(%rsp)
	movq	%rax, 68(%rsp)
	movl	$1, 76(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L17
	pushq	48(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z5SMEM3PKfS0_iPf(%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
.L17:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L19
	call	__stack_chk_fail@PLT
.L19:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2057:
	.size	_Z31__device_stub__Z5SMEM3PKfS0_iPfPKfS0_iPf, .-_Z31__device_stub__Z5SMEM3PKfS0_iPfPKfS0_iPf
	.globl	_Z5SMEM3PKfS0_iPf
	.type	_Z5SMEM3PKfS0_iPf, @function
_Z5SMEM3PKfS0_iPf:
.LFB2058:
	.cfi_startproc
	endbr64
	jmp	_Z31__device_stub__Z5SMEM3PKfS0_iPfPKfS0_iPf
	.cfi_endproc
.LFE2058:
	.size	_Z5SMEM3PKfS0_iPf, .-_Z5SMEM3PKfS0_iPf
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC1:
	.string	"type = %d; time spent executing by the GPU: %.2f millseconds\n"
	.text
	.globl	_Z13multiplyerGPUPKfS0_iPfi
	.type	_Z13multiplyerGPUPKfS0_iPfi, @function
_Z13multiplyerGPUPKfS0_iPfi:
.LFB2027:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movq	%rdi, %r15
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movq	%rsi, %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%rcx, %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movl	%r8d, %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
	movl	%edx, %ebx
	imull	%edx, %ebx
	subq	$104, %rsp
	.cfi_def_cfa_offset 160
	movq	%fs:40, %rax
	movq	%rax, 88(%rsp)
	xorl	%eax, %eax
	sall	$2, %ebx
	xorl	%eax, %eax
	leaq	8(%rsp), %rdi
	movslq	%ebx, %rbx
	movq	%rax, 8(%rsp)
	movq	%rbx, %rsi
	movq	%rax, 16(%rsp)
	movq	%rax, 24(%rsp)
	call	cudaMalloc@PLT
	leaq	16(%rsp), %rdi
	movq	%rbx, %rsi
	call	cudaMalloc@PLT
	movq	%rbx, %rsi
	leaq	24(%rsp), %rdi
	call	cudaMalloc@PLT
	movl	%ebp, %eax
	leaq	32(%rsp), %rdi
	movl	$1, 60(%rsp)
	shrl	$6, %eax
	movl	$1, 72(%rsp)
	movl	%eax, 64(%rsp)
	movl	%eax, 68(%rsp)
	movl	$0x00000000, 4(%rsp)
	call	cudaEventCreate@PLT
	leaq	40(%rsp), %rdi
	call	cudaEventCreate@PLT
	movq	32(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	8(%rsp), %rdi
	movq	%rbx, %rdx
	movq	%r15, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movq	16(%rsp), %rdi
	movq	%rbx, %rdx
	movq	%r14, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	testl	%r12d, %r12d
	jne	.L23
	movl	60(%rsp), %ecx
	movq	64(%rsp), %rdi
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movabsq	$274877907008, %rdx
	movl	72(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L26
	movq	24(%rsp), %rcx
	movq	16(%rsp), %rsi
	movl	%ebp, %edx
	movq	8(%rsp), %rdi
	call	_Z37__device_stub__Z10matrixMultPKfS0_iPfPKfS0_iPf
	jmp	.L26
.L23:
	cmpl	$1, %r12d
	jne	.L25
	movl	60(%rsp), %ecx
	movq	64(%rsp), %rdi
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movabsq	$274877907008, %rdx
	movl	72(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L26
	movq	24(%rsp), %rcx
	movq	16(%rsp), %rsi
	movl	%ebp, %edx
	movq	8(%rsp), %rdi
	call	_Z31__device_stub__Z5SMEM3PKfS0_iPfPKfS0_iPf
	jmp	.L26
.L25:
	cmpl	$2, %r12d
	jne	.L26
	movl	$2147483649, %edx
	movq	64(%rsp), %rdi
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	72(%rsp), %esi
	salq	$6, %rdx
	movl	$1, %ecx
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L26
	movq	24(%rsp), %rcx
	movq	16(%rsp), %rsi
	movl	%ebp, %edx
	movq	8(%rsp), %rdi
	call	_Z43__device_stub__Z16sharedMatrixMultPKfS0_iPfPKfS0_iPf
.L26:
	movq	24(%rsp), %rsi
	movl	$2, %ecx
	movq	%rbx, %rdx
	movq	%r13, %rdi
	call	cudaMemcpy@PLT
	movq	40(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	40(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movq	40(%rsp), %rdx
	movq	32(%rsp), %rsi
	leaq	4(%rsp), %rdi
	call	cudaEventElapsedTime@PLT
	movl	%r12d, %edx
	movl	$2, %edi
	movb	$1, %al
	leaq	.LC1(%rip), %rsi
	cvtss2sd	4(%rsp), %xmm0
	call	__printf_chk@PLT
	movq	32(%rsp), %rdi
	call	cudaEventDestroy@PLT
	movq	40(%rsp), %rdi
	call	cudaEventDestroy@PLT
	movq	8(%rsp), %rdi
	call	cudaFree@PLT
	movq	16(%rsp), %rdi
	call	cudaFree@PLT
	movq	24(%rsp), %rdi
	call	cudaFree@PLT
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	je	.L28
	call	__stack_chk_fail@PLT
.L28:
	addq	$104, %rsp
	.cfi_def_cfa_offset 56
	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
.LFE2027:
	.size	_Z13multiplyerGPUPKfS0_iPfi, .-_Z13multiplyerGPUPKfS0_iPfi
	.section	.rodata.str1.1
.LC2:
	.string	"_Z5SMEM3PKfS0_iPf"
.LC3:
	.string	"_Z16sharedMatrixMultPKfS0_iPf"
.LC4:
	.string	"_Z10matrixMultPKfS0_iPf"
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2060:
	.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	_Z5SMEM3PKfS0_iPf(%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	_Z16sharedMatrixMultPKfS0_iPf(%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	%r9d, %r9d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC4(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z10matrixMultPKfS0_iPf(%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
.LFE2060:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

#pragma once

#include "hip/device_functions.h"
#include "hip/hip_runtime.h"


//#include "helper_cuda.cuh"


#define BLOCK_SIZE 64

//#ifndef __CUDACC__  
//#define __CUDACC__
//#endif

#ifndef __HIPCC__
void __syncthreads();
#endif


void multiplyerGPU(const float *A, const float *B, int N, float *C, int type);


void mem_test();

void kernelGPU(const int* image, const float *kernel,
	const int kernelHalf,
	const int cols, const int rows,
	int* output);
	.text
	.file	"OperationHandler.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
