/*
autor fredy m
uaem
desonses@gmail.com para mas comentarios
*/

#include <device_functions.h>
#include <stdio.h>
#include <stdlib.h>
#include <cuda_runtime.h>
#include <device_launch_parameters.h>

#define N 3
/*
multiplicacion de matrices con memoria constante
*/

// definicion de memoria constante CUDA

__constant__ float dev_A[N][N];
__constant__ float dev_B[N][N];


//GLOBAL: func desde el host y ejecutada en el kernel(DEVICE)


__global__ void multiplicacion(float *dev_C)
{
	int suma = 0;
	int columna = threadIdx.x;
	int fila = threadIdx.y;
	int pos = columna + N * fila;

	if (columna < N && fila < N) 
	{
		for (int k = 0; k < N; k++) 
		{
			dev_C[pos] += dev_A[fila][k] * dev_B[k][columna];
		}
	}
}



int main(int argc, char** argv)
{
	float *hst_A, *hst_B, *hst_C;
	float *dev_C;
	int size = N * N * sizeof(float);

	//reserva de memoria en el host
	hst_A = (float*)malloc(size);
	hst_B = (float*)malloc(size);
	hst_C = (float*)malloc(size);
	//reserva de memoria en el device
	cudaMalloc((void**)&dev_C, size);

	//llenar la matriz
	for (int i = 0; i < N*N; i++)
	{
		hst_A[i] = float(i) + 1;
		hst_B[i] = float(i);
	}

	//copiar los datos hacia el device desde memoria constante
	cudaError_t error = cudaMemcpyToSymbol(dev_A, hst_A, size);
	if (error != cudaSuccess) {
		printf("Error Memoria constante dev_A to hst_A\n");
	}
	error = cudaMemcpyToSymbol(dev_B, hst_B, size);
	if (error != cudaSuccess) {
		printf("Error Memoria constante dev_B to hst_B\n");
	}

	//dimensiones del kernel a lanzar
	dim3 bloques(1);
	dim3 hilos(N, N);

	//lanzamiento del kernel
	multiplicacion <<<bloques, hilos >>> (dev_C);

	//recoger los datos
	cudaMemcpy(hst_C, dev_C, size, cudaMemcpyDeviceToHost);

	//impresion de los datos
	printf("\nMatriz A:\n");

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++)
		{
			printf("%.2f\t", hst_A[j + i * N]);
		}
		printf("\n");
	}
	printf("\nMatriz B:\n");
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++)
		{
			printf("%.2f\t", hst_B[j + i * N]);
		}
		printf("\n");
	}
	printf("\n");
	printf("multiplicacion de matrices A y B:\n");
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < N; j++)
		{
			printf("%.2f\t", hst_C[j + i * N]);
		}
		printf("\n");
	}
	
	printf("\n pulsa INTRO para salir:\n");
	fflush(stdin);
	char tecla = getchar();

	return 0;
}


	.file	"tmpxft_0023c983_00000000-6_ejercicio8.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2030:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2030:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z34__device_stub__Z14multiplicacionPfPf
	.type	_Z34__device_stub__Z14multiplicacionPfPf, @function
_Z34__device_stub__Z14multiplicacionPfPf:
.LFB2052:
	.cfi_startproc
	endbr64
	subq	$104, %rsp
	.cfi_def_cfa_offset 112
	movq	%rdi, 8(%rsp)
	leaq	24(%rsp), %rcx
	leaq	16(%rsp), %rdx
	leaq	44(%rsp), %rsi
	leaq	32(%rsp), %rdi
	movq	%fs:40, %rax
	movq	%rax, 88(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rax
	movl	$1, 40(%rsp)
	movq	%rax, 80(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 32(%rsp)
	movq	%rax, 44(%rsp)
	movl	$1, 52(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L2
	pushq	24(%rsp)
	.cfi_def_cfa_offset 120
	leaq	_Z14multiplicacionPf(%rip), %rdi
	pushq	24(%rsp)
	.cfi_def_cfa_offset 128
	movq	60(%rsp), %rcx
	movl	68(%rsp), %r8d
	movq	48(%rsp), %rsi
	movl	56(%rsp), %edx
	leaq	96(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 120
	popq	%rdx
	.cfi_def_cfa_offset 112
.L2:
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	je	.L4
	call	__stack_chk_fail@PLT
.L4:
	addq	$104, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2052:
	.size	_Z34__device_stub__Z14multiplicacionPfPf, .-_Z34__device_stub__Z14multiplicacionPfPf
	.globl	_Z14multiplicacionPf
	.type	_Z14multiplicacionPf, @function
_Z14multiplicacionPf:
.LFB2053:
	.cfi_startproc
	endbr64
	jmp	_Z34__device_stub__Z14multiplicacionPfPf
	.cfi_endproc
.LFE2053:
	.size	_Z14multiplicacionPf, .-_Z14multiplicacionPf
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC1:
	.string	"Error Memoria constante dev_A to hst_A\n"
.LC2:
	.string	"Error Memoria constante dev_B to hst_B\n"
.LC3:
	.string	"\nMatriz A:\n"
.LC4:
	.string	"%.2f\t"
.LC5:
	.string	"\n"
.LC6:
	.string	"\nMatriz B:\n"
.LC7:
	.string	"multiplicacion de matrices A y B:\n"
.LC8:
	.string	"\n pulsa INTRO para salir:\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2027:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	$36, %edi
	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
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	call	malloc@PLT
	movl	$36, %edi
	movq	%rax, %rbp
	call	malloc@PLT
	movl	$36, %edi
	movq	%rax, %rbx
	call	malloc@PLT
	leaq	8(%rsp), %rdi
	movl	$36, %esi
	movq	%rax, %r12
	call	cudaMalloc@PLT
	movss	.LC0(%rip), %xmm2
	xorl	%eax, %eax
.L9:
	cvtsi2ssl	%eax, %xmm0
	movaps	%xmm0, %xmm1
	movss	%xmm0, (%rbx,%rax,4)
	addss	%xmm2, %xmm1
	movss	%xmm1, 0(%rbp,%rax,4)
	incq	%rax
	cmpq	$9, %rax
	jne	.L9
	xorl	%ecx, %ecx
	movl	$1, %r8d
	movl	$36, %edx
	movq	%rbp, %rsi
	leaq	_ZL5dev_A(%rip), %rdi
	call	cudaMemcpyToSymbol@PLT
	testl	%eax, %eax
	je	.L10
	leaq	.LC1(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L10:
	xorl	%ecx, %ecx
	movl	$1, %r8d
	movl	$36, %edx
	movq	%rbx, %rsi
	leaq	_ZL5dev_B(%rip), %rdi
	call	cudaMemcpyToSymbol@PLT
	testl	%eax, %eax
	je	.L11
	leaq	.LC2(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L11:
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	$1, %ecx
	movl	$1, %esi
	movabsq	$12884901891, %rdx
	movabsq	$4294967297, %rdi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L12
	movq	8(%rsp), %rdi
	call	_Z34__device_stub__Z14multiplicacionPfPf
.L12:
	movq	8(%rsp), %rsi
	movl	$2, %ecx
	movq	%r12, %rdi
	xorl	%r15d, %r15d
	movl	$36, %edx
	call	cudaMemcpy@PLT
	leaq	.LC3(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L13:
	imulq	$12, %r15, %r13
	xorl	%r14d, %r14d
	addq	%rbp, %r13
.L14:
	cvtss2sd	0(%r13,%r14,4), %xmm0
	leaq	.LC4(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	call	__printf_chk@PLT
	incq	%r14
	cmpq	$3, %r14
	jne	.L14
	leaq	.LC5(%rip), %r14
	movl	$2, %edi
	xorl	%eax, %eax
	incq	%r15
	movq	%r14, %rsi
	call	__printf_chk@PLT
	cmpq	$3, %r15
	jne	.L13
	leaq	.LC6(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	xorl	%ebp, %ebp
	call	__printf_chk@PLT
.L16:
	imulq	$12, %rbp, %r15
	xorl	%r13d, %r13d
	addq	%rbx, %r15
.L17:
	cvtss2sd	(%r15,%r13,4), %xmm0
	leaq	.LC4(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	call	__printf_chk@PLT
	incq	%r13
	cmpq	$3, %r13
	jne	.L17
	movq	%r14, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	incq	%rbp
	call	__printf_chk@PLT
	cmpq	$3, %rbp
	jne	.L16
	movq	%r14, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	xorl	%ebp, %ebp
	call	__printf_chk@PLT
	leaq	.LC7(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L19:
	imulq	$12, %rbp, %r15
	xorl	%ebx, %ebx
	addq	%r12, %r15
.L20:
	cvtss2sd	(%r15,%rbx,4), %xmm0
	leaq	.LC4(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	call	__printf_chk@PLT
	incq	%rbx
	cmpq	$3, %rbx
	jne	.L20
	movq	%r14, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	incq	%rbp
	call	__printf_chk@PLT
	cmpq	$3, %rbp
	jne	.L19
	leaq	.LC8(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	stdin(%rip), %rdi
	call	fflush@PLT
	call	getchar@PLT
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	je	.L22
	call	__stack_chk_fail@PLT
.L22:
	addq	$56, %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
.LFE2027:
	.size	main, .-main
	.section	.rodata.str1.1
.LC9:
	.string	"_Z14multiplicacionPf"
.LC10:
	.string	"dev_A"
.LC11:
	.string	"dev_B"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2055:
	.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	.LC9(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z14multiplicacionPf(%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	%r8d, %r8d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC10(%rip), %rdx
	movl	$36, %r9d
	leaq	_ZL5dev_A(%rip), %rsi
	pushq	$1
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	call	__cudaRegisterVar@PLT
	popq	%rax
	.cfi_def_cfa_offset 24
	popq	%rdx
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$1
	.cfi_def_cfa_offset 32
	leaq	.LC11(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movq	%rdx, %rcx
	movl	$36, %r9d
	leaq	_ZL5dev_B(%rip), %rsi
	call	__cudaRegisterVar@PLT
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	popq	%rcx
	.cfi_def_cfa_offset 24
	popq	%rsi
	.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
.LFE2055:
	.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
	.local	_ZL5dev_B
	.comm	_ZL5dev_B,36,32
	.local	_ZL5dev_A
	.comm	_ZL5dev_A,36,32
	.section	.rodata.cst4,"aM",@progbits,4
	.align 4
.LC0:
	.long	1065353216
	.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:

/*
autor fredy m
uaem
desonses@gmail.com para mas comentarios
*/

#include <hip/device_functions.h>
#include <stdio.h>
#include <stdlib.h>
#include <hip/hip_runtime.h>


#define N 3
/*
multiplicacion de matrices con memoria constante
*/

// definicion de memoria constante CUDA

__constant__ float dev_A[N][N];
__constant__ float dev_B[N][N];


//GLOBAL: func desde el host y ejecutada en el kernel(DEVICE)


__global__ void multiplicacion(float *dev_C)
{
	int suma = 0;
	int columna = threadIdx.x;
	int fila = threadIdx.y;
	int pos = columna + N * fila;

	if (columna < N && fila < N) 
	{
		for (int k = 0; k < N; k++) 
		{
			dev_C[pos] += dev_A[fila][k] * dev_B[k][columna];
		}
	}
}



int main(int argc, char** argv)
{
	float *hst_A, *hst_B, *hst_C;
	float *dev_C;
	int size = N * N * sizeof(float);

	//reserva de memoria en el host
	hst_A = (float*)malloc(size);
	hst_B = (float*)malloc(size);
	hst_C = (float*)malloc(size);
	//reserva de memoria en el device
	hipMalloc((void**)&dev_C, size);

	//llenar la matriz
	for (int i = 0; i < N*N; i++)
	{
		hst_A[i] = float(i) + 1;
		hst_B[i] = float(i);
	}

	//copiar los datos hacia el device desde memoria constante
	hipError_t error = hipMemcpyToSymbol(HIP_SYMBOL(dev_A), hst_A, size);
	if (error != hipSuccess) {
		printf("Error Memoria constante dev_A to hst_A\n");
	}
	error = hipMemcpyToSymbol(HIP_SYMBOL(dev_B), hst_B, size);
	if (error != hipSuccess) {
		printf("Error Memoria constante dev_B to hst_B\n");
	}

	//dimensiones del kernel a lanzar
	dim3 bloques(1);
	dim3 hilos(N, N);

	//lanzamiento del kernel
	multiplicacion <<<bloques, hilos >>> (dev_C);

	//recoger los datos
	hipMemcpy(hst_C, dev_C, size, hipMemcpyDeviceToHost);

	//impresion de los datos
	printf("\nMatriz A:\n");

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++)
		{
			printf("%.2f\t", hst_A[j + i * N]);
		}
		printf("\n");
	}
	printf("\nMatriz B:\n");
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++)
		{
			printf("%.2f\t", hst_B[j + i * N]);
		}
		printf("\n");
	}
	printf("\n");
	printf("multiplicacion de matrices A y B:\n");
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < N; j++)
		{
			printf("%.2f\t", hst_C[j + i * N]);
		}
		printf("\n");
	}
	
	printf("\n pulsa INTRO para salir:\n");
	fflush(stdin);
	char tecla = getchar();

	return 0;
}


	.text
	.file	"ejercicio8.hip"
	.globl	_Z29__device_stub__multiplicacionPf # -- Begin function _Z29__device_stub__multiplicacionPf
	.type	_Z29__device_stub__multiplicacionPf,@function
_Z29__device_stub__multiplicacionPf:    # @_Z29__device_stub__multiplicacionPf
	.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	$64, %rsp
	.cfi_def_cfa_offset 112
	.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)
	movq	%rsp, %rbx
	movq	%rax, (%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	$_Z14multiplicacionPf, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$80, %rsp
	.cfi_adjust_cfa_offset -80
	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	_Z29__device_stub__multiplicacionPf, .Lfunc_end0-_Z29__device_stub__multiplicacionPf
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function main
.LCPI1_0:
	.long	0x3f800000                      # float 1
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
	.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	$16, %rsp
	.cfi_def_cfa_offset 64
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movl	$36, %edi
	callq	malloc
	movq	%rax, %r15
	movl	$36, %edi
	callq	malloc
	movq	%rax, %r14
	movl	$36, %edi
	callq	malloc
	movq	%rax, %rbx
	leaq	8(%rsp), %rdi
	movl	$36, %esi
	callq	hipMalloc
	xorl	%eax, %eax
	movss	.LCPI1_0(%rip), %xmm0           # xmm0 = mem[0],zero,zero,zero
.LBB1_1:                                # =>This Inner Loop Header: Depth=1
	xorps	%xmm1, %xmm1
	cvtsi2ss	%eax, %xmm1
	movss	%xmm1, (%r14,%rax,4)
	addss	%xmm0, %xmm1
	movss	%xmm1, (%r15,%rax,4)
	incq	%rax
	cmpq	$9, %rax
	jne	.LBB1_1
# %bb.2:
	movl	$dev_A, %edi
	movl	$36, %edx
	movq	%r15, %rsi
	xorl	%ecx, %ecx
	movl	$1, %r8d
	callq	hipMemcpyToSymbol
	testl	%eax, %eax
	je	.LBB1_4
# %bb.3:
	movl	$.Lstr, %edi
	callq	puts@PLT
.LBB1_4:
	movl	$dev_B, %edi
	movl	$36, %edx
	movq	%r14, %rsi
	xorl	%ecx, %ecx
	movl	$1, %r8d
	callq	hipMemcpyToSymbol
	testl	%eax, %eax
	je	.LBB1_6
# %bb.5:
	movl	$.Lstr.1, %edi
	callq	puts@PLT
.LBB1_6:
	movabsq	$4294967297, %rdi               # imm = 0x100000001
	movabsq	$12884901891, %rdx              # imm = 0x300000003
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB1_8
# %bb.7:
	movq	8(%rsp), %rdi
	callq	_Z29__device_stub__multiplicacionPf
.LBB1_8:
	movq	8(%rsp), %rsi
	movl	$36, %edx
	movq	%rbx, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	movl	$.Lstr.2, %edi
	callq	puts@PLT
	xorl	%r12d, %r12d
.LBB1_9:                                # %.preheader66
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_10 Depth 2
	xorl	%r13d, %r13d
.LBB1_10:                               #   Parent Loop BB1_9 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	xorps	%xmm0, %xmm0
	cvtss2sd	(%r15,%r13,4), %xmm0
	movl	$.L.str.3, %edi
	movb	$1, %al
	callq	printf
	incq	%r13
	cmpq	$3, %r13
	jne	.LBB1_10
# %bb.11:                               #   in Loop: Header=BB1_9 Depth=1
	movl	$10, %edi
	callq	putchar@PLT
	incq	%r12
	addq	$12, %r15
	cmpq	$3, %r12
	jne	.LBB1_9
# %bb.12:
	movl	$.Lstr.3, %edi
	callq	puts@PLT
	xorl	%r15d, %r15d
.LBB1_13:                               # %.preheader65
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_14 Depth 2
	xorl	%r12d, %r12d
.LBB1_14:                               #   Parent Loop BB1_13 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	xorps	%xmm0, %xmm0
	cvtss2sd	(%r14,%r12,4), %xmm0
	movl	$.L.str.3, %edi
	movb	$1, %al
	callq	printf
	incq	%r12
	cmpq	$3, %r12
	jne	.LBB1_14
# %bb.15:                               #   in Loop: Header=BB1_13 Depth=1
	movl	$10, %edi
	callq	putchar@PLT
	incq	%r15
	addq	$12, %r14
	cmpq	$3, %r15
	jne	.LBB1_13
# %bb.16:
	movl	$10, %edi
	callq	putchar@PLT
	movl	$.Lstr.4, %edi
	callq	puts@PLT
	xorl	%r14d, %r14d
.LBB1_17:                               # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_18 Depth 2
	xorl	%r15d, %r15d
.LBB1_18:                               #   Parent Loop BB1_17 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	xorps	%xmm0, %xmm0
	cvtss2sd	(%rbx,%r15,4), %xmm0
	movl	$.L.str.3, %edi
	movb	$1, %al
	callq	printf
	incq	%r15
	cmpq	$3, %r15
	jne	.LBB1_18
# %bb.19:                               #   in Loop: Header=BB1_17 Depth=1
	movl	$10, %edi
	callq	putchar@PLT
	incq	%r14
	addq	$12, %rbx
	cmpq	$3, %r14
	jne	.LBB1_17
# %bb.20:
	movl	$.Lstr.5, %edi
	callq	puts@PLT
	movq	stdin(%rip), %rdi
	callq	fflush
	callq	getchar
	xorl	%eax, %eax
	addq	$16, %rsp
	.cfi_def_cfa_offset 48
	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	main, .Lfunc_end1-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
	.cfi_offset %rbx, -16
	movq	__hip_gpubin_handle(%rip), %rbx
	testq	%rbx, %rbx
	jne	.LBB2_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB2_2:
	subq	$32, %rsp
	.cfi_adjust_cfa_offset 32
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z14multiplicacionPf, %esi
	movl	$.L__unnamed_1, %edx
	movl	$.L__unnamed_1, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	addq	$32, %rsp
	.cfi_adjust_cfa_offset -32
	movl	$dev_A, %esi
	movl	$.L__unnamed_2, %edx
	movl	$.L__unnamed_2, %ecx
	movl	$36, %r9d
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	pushq	$0
	.cfi_adjust_cfa_offset 8
	pushq	$1
	.cfi_adjust_cfa_offset 8
	callq	__hipRegisterVar
	addq	$16, %rsp
	.cfi_adjust_cfa_offset -16
	movl	$dev_B, %esi
	movl	$.L__unnamed_3, %edx
	movl	$.L__unnamed_3, %ecx
	movl	$36, %r9d
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	pushq	$0
	.cfi_adjust_cfa_offset 8
	pushq	$1
	.cfi_adjust_cfa_offset 8
	callq	__hipRegisterVar
	addq	$16, %rsp
	.cfi_adjust_cfa_offset -16
	movl	$__hip_module_dtor, %edi
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_end2:
	.size	__hip_module_ctor, .Lfunc_end2-__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	.LBB3_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
.LBB3_2:
	retq
.Lfunc_end3:
	.size	__hip_module_dtor, .Lfunc_end3-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	dev_A,@object                   # @dev_A
	.local	dev_A
	.comm	dev_A,36,16
	.type	dev_B,@object                   # @dev_B
	.local	dev_B
	.comm	dev_B,36,16
	.type	_Z14multiplicacionPf,@object    # @_Z14multiplicacionPf
	.section	.rodata,"a",@progbits
	.globl	_Z14multiplicacionPf
	.p2align	3, 0x0
_Z14multiplicacionPf:
	.quad	_Z29__device_stub__multiplicacionPf
	.size	_Z14multiplicacionPf, 8

	.type	.L.str.3,@object                # @.str.3
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.3:
	.asciz	"%.2f\t"
	.size	.L.str.3, 6

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z14multiplicacionPf"
	.size	.L__unnamed_1, 21

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"dev_A"
	.size	.L__unnamed_2, 6

	.type	.L__unnamed_3,@object           # @2
.L__unnamed_3:
	.asciz	"dev_B"
	.size	.L__unnamed_3, 6

	.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

	.type	.Lstr,@object                   # @str
	.section	.rodata.str1.1,"aMS",@progbits,1
.Lstr:
	.asciz	"Error Memoria constante dev_A to hst_A"
	.size	.Lstr, 39

	.type	.Lstr.1,@object                 # @str.1
.Lstr.1:
	.asciz	"Error Memoria constante dev_B to hst_B"
	.size	.Lstr.1, 39

	.type	.Lstr.2,@object                 # @str.2
.Lstr.2:
	.asciz	"\nMatriz A:"
	.size	.Lstr.2, 11

	.type	.Lstr.3,@object                 # @str.3
.Lstr.3:
	.asciz	"\nMatriz B:"
	.size	.Lstr.3, 11

	.type	.Lstr.4,@object                 # @str.4
.Lstr.4:
	.asciz	"multiplicacion de matrices A y B:"
	.size	.Lstr.4, 34

	.type	.Lstr.5,@object                 # @str.5
.Lstr.5:
	.asciz	"\n pulsa INTRO para salir:"
	.size	.Lstr.5, 26

	.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 _Z29__device_stub__multiplicacionPf
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym dev_A
	.addrsig_sym dev_B
	.addrsig_sym _Z14multiplicacionPf
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z14multiplicacionPf    ; -- Begin function _Z14multiplicacionPf
	.globl	_Z14multiplicacionPf
	.p2align	8
	.type	_Z14multiplicacionPf,@function
_Z14multiplicacionPf:                   ; @_Z14multiplicacionPf
; %bb.0:
	v_and_b32_e32 v1, 0x3ff, v0
	v_bfe_u32 v4, v0, 10, 10
	s_mov_b32 s2, exec_lo
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_max_u32_e32 v0, v1, v4
	v_cmpx_gt_u32_e32 3, v0
	s_cbranch_execz .LBB0_3
; %bb.1:                                ; %.preheader
	s_load_b64 s[0:1], s[0:1], 0x0
	v_mul_u32_u24_e32 v0, 3, v4
	v_lshlrev_b32_e32 v5, 2, v1
	s_getpc_b64 s[2:3]
	s_add_u32 s2, s2, dev_A@rel32@lo+4
	s_addc_u32 s3, s3, dev_A@rel32@hi+12
	s_getpc_b64 s[4:5]
	s_add_u32 s4, s4, dev_B@rel32@lo+4
	s_addc_u32 s5, s5, dev_B@rel32@hi+12
	v_mad_u64_u32 v[2:3], null, v4, 12, s[2:3]
	v_add_lshl_u32 v0, v0, v1, 2
	s_waitcnt lgkmcnt(0)
	global_load_b32 v6, v0, s[0:1]
	v_add_co_u32 v0, s0, s0, v0
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_add_co_ci_u32_e64 v1, null, s1, 0, s0
	v_add_co_u32 v4, s0, v5, s4
	v_add_co_ci_u32_e64 v5, null, 0, s5, s0
	s_mov_b64 s[0:1], 0
.LBB0_2:                                ; =>This Inner Loop Header: Depth=1
	s_delay_alu instid0(SALU_CYCLE_1)
	v_add_co_u32 v7, vcc_lo, v2, s0
	v_add_co_ci_u32_e32 v8, vcc_lo, s1, v3, vcc_lo
	s_add_u32 s0, s0, 4
	s_addc_u32 s1, s1, 0
	global_load_b32 v9, v[4:5], off
	global_load_b32 v7, v[7:8], off
	v_add_co_u32 v4, vcc_lo, v4, 12
	v_add_co_ci_u32_e32 v5, vcc_lo, 0, v5, vcc_lo
	s_cmp_lg_u32 s0, 12
	s_waitcnt vmcnt(0)
	v_fmac_f32_e32 v6, v7, v9
	global_store_b32 v[0:1], v6, off
	s_cbranch_scc1 .LBB0_2
.LBB0_3:                                ; %.loopexit
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z14multiplicacionPf
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 8
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 1
		.amdhsa_next_free_vgpr 10
		.amdhsa_next_free_sgpr 6
		.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	_Z14multiplicacionPf, .Lfunc_end0-_Z14multiplicacionPf
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 248
; NumSgprs: 8
; NumVgprs: 10
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 0
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 8
; NumVGPRsForWavesPerEU: 10
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 1
	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.protected	dev_A                   ; @dev_A
	.type	dev_A,@object
	.section	.bss,"aw",@nobits
	.globl	dev_A
	.p2align	4, 0x0
dev_A:
	.zero	36
	.size	dev_A, 36

	.protected	dev_B                   ; @dev_B
	.type	dev_B,@object
	.globl	dev_B
	.p2align	4, 0x0
dev_B:
	.zero	36
	.size	dev_B, 36

	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.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 dev_A
	.addrsig_sym dev_B
	.addrsig_sym __hip_cuid_
	.amdgpu_metadata
---
amdhsa.kernels:
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 8
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z14multiplicacionPf
    .private_segment_fixed_size: 0
    .sgpr_count:     8
    .sgpr_spill_count: 0
    .symbol:         _Z14multiplicacionPf.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     10
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
