#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <cuda.h>

#define MAT_SIZE 10000

#define GIGA 1000000000.
#define NSEC 1000000000.

#define THREADS 32

__host__ cudaError_t matmatCuda(int, int, int, int, int, int, 
                                double *, double *, double *);
__global__ void productKernel(double*, double*, double*, int, int);
__global__ void adjustMatrix(double *, int, int);

double* rnd_flt_matrix(int n, int m);
double* zeros_flt_matrix(int n, int m);


int main(int argc, char const *argv[])
{
	// Strutture che memorizzano le matrici da moltiplicare
    double *A_h, *B_h, *C_d;
    double gflops_gpu;
    float elapsed;

    long nop;

    // variabili eventi utilizzate per stimare i tempi 
    // di esecuzione sulla Gpu
    cudaEvent_t start_gpu, stop_gpu;
    
    double gpuTime; //tempo di esecuzione con Gpu
    
    cudaError_t cudaStatus;

	//allocazione matrici
    A_h = rnd_flt_matrix(MAT_SIZE, MAT_SIZE);
    B_h = rnd_flt_matrix(MAT_SIZE, MAT_SIZE);
    C_d = zeros_flt_matrix(MAT_SIZE, MAT_SIZE);

    // Inzializza gli eventi di inizio e fine
    cudaEventCreate(&start_gpu);
    cudaEventCreate(&stop_gpu);
    
    printf("Ordine matrici; Tempo GPU; GFlops GPU\n");

    for(int i = 100; i <= MAT_SIZE; i += 100)
    {
        // Prende il tempo di inizio
        cudaEventRecord(start_gpu, 0);

        // inizializza ed esegue il prodotto tra matrici 
        // sul device @see matmatCuda
        cudaStatus = matmatCuda(MAT_SIZE, MAT_SIZE, MAT_SIZE, 
                                i, i, i, A_h, B_h, C_d);

        // Prende il tempo di fine
        cudaEventRecord(stop_gpu, 0);
        cudaEventSynchronize(stop_gpu);

        if(cudaStatus != cudaSuccess){
            fprintf(stderr, "matmatCuda failed!");
            return 1;
        }

        // Calcolo il tempo trascorso tra i 2 eventi
        cudaEventElapsedTime(&elapsed, start_gpu, stop_gpu);
        
        // Trasforma il tempo in secondi
        elapsed /= 1000.;

        // Prende il tempo di fine
        cudaEventRecord(stop_gpu, 0);
        cudaEventSynchronize(stop_gpu);
        
        // Calcolo il tempo trascorso tra i 2 eventi
        cudaEventElapsedTime(&elapsed, start_gpu, stop_gpu);

        // Trasforma il tempo in secondi
        gpuTime = elapsed / 1000.;
        
        nop = 2 * pow(i, 3);

        gflops_gpu = (nop / gpuTime) / GIGA;

        printf("%6d; %5.2lf; %5.2lf\n", i, gpuTime, gflops_gpu);
    }

    cudaEventDestroy(start_gpu);
    cudaEventDestroy(stop_gpu);
    free(A_h);
    free(B_h);
    free(C_d);

    return 0;
}

double* rnd_flt_matrix(int n, int m)
{   
    int size = n * m;  
    double *A = (double*) malloc(sizeof(double) * size);

    for(int i = 0; i < size; ++i)
        A[i] = (float) rand() / RAND_MAX;
    
    return A;
}

double* zeros_flt_matrix(int n, int m)
{
    return (double*) calloc(n * m, sizeof(double));
}

// procedura che inserisce il valore 0 
// per riempire gli spazi di matrice vuoti sulla cornice
__global__ void adjustMatrix(double *M, int n, int m)
{
	int i = blockIdx.y * blockDim.y + threadIdx.y;
	int j = blockIdx.x * blockDim.x + threadIdx.x;
	int offset = gridDim.x * blockDim.x * i + j;

    if(i >= n || j >= m)        
        M[offset] = 0.;
}

cudaError_t matmatCuda(int lda, int ldb, int ldc, 
                       int n, int m, int p, double *A, double *B, double *C)
{
    double *A_d = NULL;
    double *B_d = NULL;
    double *C_d = NULL;
	
	// Calcola il numero di blocchi della griglia
    unsigned int nblock = (n + THREADS - 1) / THREADS;
    unsigned int mblock = (m + THREADS - 1) / THREADS;
    unsigned int pblock = (p + THREADS - 1) / THREADS;

	// Calcola la più piccola matrice quadrata multipla 
	// di THREADS che possa contenere la matrice A e B
    int nwidth = nblock * THREADS;
    int mwidth = mblock * THREADS;
    int pwidth = pblock * THREADS;

    cudaError_t cudaStatus;
    
    // Numero di blocchi per la griglia su A
    dim3 blocksA;
    blocksA.x = mblock;
    blocksA.y = nblock;

    // Numero di blocchi per la griglia su B
    dim3 blocksB;
    blocksB.x = pblock;
    blocksB.y = mblock;

	// Numero di blocchi per la griglia su C
	dim3 blocksC;
	blocksC.x = pblock;
	blocksC.y = nblock;
	
	// Numero di thread per blocco
    dim3 threads;
	threads.x = THREADS;
    threads.y = THREADS;
    
    // Scegli la GPU sul quale eseguire, in caso di un sistema multi-GPU.
    cudaStatus = cudaSetDevice(0);
    if (cudaStatus != cudaSuccess) {
        fprintf(stderr, "1: cudaSetDevice failed!\n");
        fprintf(stderr, "Do you have a CUDA-capable GPU installed?\n");
        goto Error;
    }

	// **** Allocazione vettori all'interno della memoria del device ****
	
    cudaStatus = cudaMalloc((void**)&A_d, nwidth * mwidth * sizeof(double));

    if (cudaStatus != cudaSuccess) {
        fprintf(stderr, "2: cudaMalloc failed!\n");
        goto Error;
    }

    cudaStatus = cudaMalloc((void**)&B_d, mwidth * pwidth * sizeof(double));

    if (cudaStatus != cudaSuccess) {
        fprintf(stderr, "3: cudaMalloc failed!\n");
        goto Error;
    }

    cudaStatus = cudaMalloc((void**)&C_d, nwidth * pwidth * sizeof(double));
    if (cudaStatus != cudaSuccess) {
        fprintf(stderr, "4: cudaMalloc failed!\n");
        goto Error;
    }
	// **** Termine allocazione dei vettori ****

	// **** Copia delle matrici in input nella memoria del device ****	
    cudaStatus = cudaMemcpy2D(A_d, mwidth * sizeof(double), 
                              A, lda * sizeof(double), 
                              m * sizeof(double), n, cudaMemcpyHostToDevice);

    if (cudaStatus != cudaSuccess) {
        fprintf(stderr, "5: cudaMemcpy2D failed!\n");
        goto Error;
    }

    cudaStatus = cudaMemcpy2D(B_d, pwidth * sizeof(double), 
                              B, ldb * sizeof(double), p * sizeof(double),
                              m, cudaMemcpyHostToDevice);

    if (cudaStatus != cudaSuccess) {
        fprintf(stderr, "6: cudaMemcpy2D failed!\n");
        goto Error;
    }
	
	// **** Termina copia dei vettori ****
	
	// Riempie la parte della matrice in eccesso con degli 0	
    if( (n % THREADS) || (m % THREADS) || (p % THREADS) ) {
		adjustMatrix<<<blocksA, threads>>>(A_d, n, m);
	    adjustMatrix<<<blocksB, threads>>>(B_d, m, p);
    }
    
	// Calcolo il prodotto tra le 2 matrici
    productKernel<<<blocksC, threads>>>(A_d, B_d, C_d, mwidth, pwidth);
	
	// Copia del vettore risultante dalla memoria del device a quella RAM
    cudaStatus = cudaMemcpy2D(C, ldc * sizeof(double), 
                              C_d, pwidth * sizeof(double), p * sizeof(double),
                              n, cudaMemcpyDeviceToHost);

    if (cudaStatus != cudaSuccess) {
        fprintf(stderr, "7: cudaMemcpy2D failed!\n");
        goto Error;
    }

	
	// Deallocazione vettori ed eventi dalla memoria del device
    Error:
        cudaFree(A_d);
        cudaFree(B_d);
        cudaFree(C_d);

    return cudaStatus;
}

 /**
 * Esegue il prodotto scalare tra  una riga di A e una colonna di B
 *
 * @param A vettore rapprensentante la matrice A
 * @param B vettore rapprensentante la matrice B
 * @param C vettore risulatante reappresentante la matrice C
 * @param width dimensione della matrice
 */
 __global__ void productKernel(double* A, double* B, double* C, int m, int p)
 {
    // id del blocco sull'ordinata all'interno della griglia
    int ib = blockIdx.y;
    // id del blocco sull'ascissa all'interno della griglia	
    int jb = blockIdx.x;
    // id del thread sull'ordinata all'interno del blocco	
    int it = threadIdx.y;
    // id del thread sull'ascissa allinterno del blocco 
    int jt = threadIdx.x;

    int a, b, c, k;

    // Indice della prima sottomatrice di A elaborata dal blocco
    // m e' un multiplo intero di THREADS
    // aBegin  include un certo numero ib  di gruppi di blocchi 
    // rettangolari THREADSxwidth
    int aBegin = m * THREADS * ib;

    //Indice dell'ultima sottomatrice di A elaborata dal blocco
    int aEnd   = aBegin + m - 1;

    // numero di colonne tra una sottomatrice e la successiva
    int aStep  = THREADS;

    // indice della prima sottomatrice di B elaborata dal blocco
    // bBegin include un certo numero jb di blocchi di colonne, 
    // blocchi larghi THREADS
    int bBegin = THREADS * jb;

    // numero di elementi tra una sottomatrice e la successiva
    int bStep  = THREADS * p;

    // Csub e' usata come variabile in cui memorizzare 
    // il valore dell'elemento di C calcolato dal thread
    // Viene aggiornato ripetutamente nel ciclo for seguente
    double Csub = 0;

    // Le matrici vengono divise in blocchi di dimensione THREADS X THREADS
    // per ridurre il numero di accessi alla memoria pricipale del device 
    // che risultano costosi in termini di tempo
    
    // Dichiarazione della variabile in cui salvare 
    // la sottomatrice di A in esame
    __shared__ double As[THREADS][THREADS];

    // Dichiarazione della variabile in cui salvare 
    // la sottomatrice di B in esame
    __shared__ double Bs[THREADS][THREADS];

    // Iterazione sulle sottomatrici 
    // in cui viene suddiviso il calcolo degli elementi del blocco
    for (a = aBegin, b = bBegin; a <= aEnd; a += aStep, b += bStep)
    {
        // Vengono Caricati gli elementi di ciascuna 
        // sottomatrice in memoria condivisa:
        // ogni thread del blocco carica un elemento!
            
        As[it][jt] = A[a +  m * it + jt];
        Bs[it][jt] = B[b +  p * it + jt];

        // i processi vengono sincronizzati per assicurare 
        // che ogni thread del blocco abbia caricato gli elementi.
        __syncthreads();

        // vengono calcolati i contributi agli elementi di matrice di C 
        // dovute alla sottomatrici in esame
        for( k = 0; k < THREADS ; ++k )
            Csub += As[it][k]*Bs[k][jt];
        // l'elemento C[it][jt] viene aggiornato in un numero di volte
        // pari al numero di iterazioni del ciclo for

        // i processi vengono sincronizzati per assicurare che il calcolo 
        // precedente sia terminato prima di caricare nuove
        // sottomatrici
        __syncthreads();
    }

    // vengono inseriti i risultati in C.
    // Ogni thread elabora un elemento di C.
    c = p * THREADS * ib + THREADS * jb;
    C[c +  p * it + jt] = Csub;
 }
 
	.file	"tmpxft_003232d6_00000000-6_main.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2033:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2033:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z14rnd_flt_matrixii
	.type	_Z14rnd_flt_matrixii, @function
_Z14rnd_flt_matrixii:
.LFB2028:
	.cfi_startproc
	endbr64
	imull	%esi, %edi
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	xorl	%r12d, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	movl	%edi, %ebp
	movslq	%edi, %rdi
	salq	$3, %rdi
	call	malloc@PLT
	movq	%rax, %rbx
.L3:
	cmpl	%r12d, %ebp
	jle	.L7
	call	rand@PLT
	cvtsi2ssl	%eax, %xmm0
	mulss	.LC0(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	movsd	%xmm0, (%rbx,%r12,8)
	incq	%r12
	jmp	.L3
.L7:
	movq	%rbx, %rax
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2028:
	.size	_Z14rnd_flt_matrixii, .-_Z14rnd_flt_matrixii
	.globl	_Z16zeros_flt_matrixii
	.type	_Z16zeros_flt_matrixii, @function
_Z16zeros_flt_matrixii:
.LFB2029:
	.cfi_startproc
	endbr64
	imull	%esi, %edi
	movl	$8, %esi
	movslq	%edi, %rdi
	jmp	calloc@PLT
	.cfi_endproc
.LFE2029:
	.size	_Z16zeros_flt_matrixii, .-_Z16zeros_flt_matrixii
	.globl	_Z34__device_stub__Z12adjustMatrixPdiiPdii
	.type	_Z34__device_stub__Z12adjustMatrixPdiiPdii, @function
_Z34__device_stub__Z12adjustMatrixPdiiPdii:
.LFB2055:
	.cfi_startproc
	endbr64
	subq	$120, %rsp
	.cfi_def_cfa_offset 128
	movq	%rdi, 8(%rsp)
	leaq	24(%rsp), %rcx
	leaq	32(%rsp), %rdi
	movl	%esi, 4(%rsp)
	leaq	44(%rsp), %rsi
	movl	%edx, (%rsp)
	leaq	16(%rsp), %rdx
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rax
	movl	$1, 40(%rsp)
	movq	%rax, 80(%rsp)
	leaq	4(%rsp), %rax
	movq	%rax, 88(%rsp)
	movq	%rsp, %rax
	movq	%rax, 96(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 32(%rsp)
	movq	%rax, 44(%rsp)
	movl	$1, 52(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L9
	pushq	24(%rsp)
	.cfi_def_cfa_offset 136
	leaq	_Z12adjustMatrixPdii(%rip), %rdi
	pushq	24(%rsp)
	.cfi_def_cfa_offset 144
	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 136
	popq	%rdx
	.cfi_def_cfa_offset 128
.L9:
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	je	.L11
	call	__stack_chk_fail@PLT
.L11:
	addq	$120, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2055:
	.size	_Z34__device_stub__Z12adjustMatrixPdiiPdii, .-_Z34__device_stub__Z12adjustMatrixPdiiPdii
	.globl	_Z12adjustMatrixPdii
	.type	_Z12adjustMatrixPdii, @function
_Z12adjustMatrixPdii:
.LFB2056:
	.cfi_startproc
	endbr64
	jmp	_Z34__device_stub__Z12adjustMatrixPdiiPdii
	.cfi_endproc
.LFE2056:
	.size	_Z12adjustMatrixPdii, .-_Z12adjustMatrixPdii
	.globl	_Z39__device_stub__Z13productKernelPdS_S_iiPdS_S_ii
	.type	_Z39__device_stub__Z13productKernelPdS_S_iiPdS_S_ii, @function
_Z39__device_stub__Z13productKernelPdS_S_iiPdS_S_ii:
.LFB2057:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movq	%rdi, 24(%rsp)
	leaq	48(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	60(%rsp), %rsi
	movq	%rdx, 8(%rsp)
	leaq	32(%rsp), %rdx
	movl	%ecx, 4(%rsp)
	leaq	40(%rsp), %rcx
	movl	%r8d, (%rsp)
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 56(%rsp)
	movq	%rax, 96(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 104(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	4(%rsp), %rax
	movq	%rax, 120(%rsp)
	movq	%rsp, %rax
	movq	%rax, 128(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 48(%rsp)
	movq	%rax, 60(%rsp)
	movl	$1, 68(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L14
	pushq	40(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z13productKernelPdS_S_ii(%rip), %rdi
	pushq	40(%rsp)
	.cfi_def_cfa_offset 176
	movq	76(%rsp), %rcx
	movl	84(%rsp), %r8d
	movq	64(%rsp), %rsi
	movl	72(%rsp), %edx
	leaq	112(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 168
	popq	%rdx
	.cfi_def_cfa_offset 160
.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
.LFE2057:
	.size	_Z39__device_stub__Z13productKernelPdS_S_iiPdS_S_ii, .-_Z39__device_stub__Z13productKernelPdS_S_iiPdS_S_ii
	.globl	_Z13productKernelPdS_S_ii
	.type	_Z13productKernelPdS_S_ii, @function
_Z13productKernelPdS_S_ii:
.LFB2058:
	.cfi_startproc
	endbr64
	jmp	_Z39__device_stub__Z13productKernelPdS_S_iiPdS_S_ii
	.cfi_endproc
.LFE2058:
	.size	_Z13productKernelPdS_S_ii, .-_Z13productKernelPdS_S_ii
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC1:
	.string	"1: cudaSetDevice failed!\n"
.LC2:
	.string	"Do you have a CUDA-capable GPU installed?\n"
.LC3:
	.string	"2: cudaMalloc failed!\n"
.LC4:
	.string	"3: cudaMalloc failed!\n"
.LC5:
	.string	"4: cudaMalloc failed!\n"
.LC6:
	.string	"5: cudaMemcpy2D failed!\n"
.LC7:
	.string	"6: cudaMemcpy2D failed!\n"
.LC8:
	.string	"7: cudaMemcpy2D failed!\n"
	.text
	.globl	_Z10matmatCudaiiiiiiPdS_S_
	.type	_Z10matmatCudaiiiiiiPdS_S_, @function
_Z10matmatCudaiiiiiiPdS_S_:
.LFB2030:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	%ecx, %r15d
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movl	%r9d, %r14d
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movl	%edi, %r13d
	movl	$32, %edi
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	leal	31(%r9), %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	leal	31(%rcx), %ebp
	leal	31(%r8), %ecx
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	xorl	%ebx, %ebx
	subq	$136, %rsp
	.cfi_def_cfa_offset 192
	movq	192(%rsp), %rax
	movl	%esi, 24(%rsp)
	movl	%edx, 28(%rsp)
	movq	%rax, 8(%rsp)
	movq	200(%rsp), %rax
	movl	%r8d, (%rsp)
	movq	%rax, 32(%rsp)
	movq	208(%rsp), %rax
	movq	%rax, 40(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 120(%rsp)
	xorl	%eax, %eax
	movl	%ebp, %eax
	movq	%rbx, 48(%rsp)
	cltd
	movq	%rbx, 56(%rsp)
	idivl	%edi
	movq	%rbx, 64(%rsp)
	movl	$1, 80(%rsp)
	movl	$1, 92(%rsp)
	movl	%eax, %ebp
	movl	%ecx, %eax
	cltd
	movl	%ebp, 76(%rsp)
	idivl	%edi
	movl	%eax, %ecx
	movl	%r12d, %eax
	cltd
	movl	%ecx, 72(%rsp)
	idivl	%edi
	xorl	%edi, %edi
	movl	%eax, 84(%rsp)
	movl	%eax, %r12d
	movl	%eax, 96(%rsp)
	movabsq	$137438953504, %rax
	movl	%ecx, 88(%rsp)
	movl	%ecx, 4(%rsp)
	movl	$1, 104(%rsp)
	movl	%ebp, 100(%rsp)
	movq	%rax, 108(%rsp)
	movl	$1, 116(%rsp)
	call	cudaSetDevice@PLT
	movl	4(%rsp), %ecx
	testl	%eax, %eax
	je	.L20
	movq	stderr(%rip), %rdi
	leaq	.LC1(%rip), %rdx
	movl	%eax, %ebx
	movl	$2, %esi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	leaq	.LC2(%rip), %rdx
	jmp	.L36
.L20:
	sall	$5, %ecx
	sall	$5, %ebp
	leaq	48(%rsp), %rdi
	movl	%ecx, %esi
	movl	%ecx, 4(%rsp)
	imull	%ebp, %esi
	movslq	%esi, %rsi
	salq	$3, %rsi
	call	cudaMalloc@PLT
	leaq	.LC3(%rip), %rdx
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	.L36
	movl	4(%rsp), %esi
	sall	$5, %r12d
	leaq	56(%rsp), %rdi
	imull	%r12d, %esi
	movslq	%esi, %rsi
	salq	$3, %rsi
	call	cudaMalloc@PLT
	leaq	.LC4(%rip), %rdx
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	.L36
	imull	%r12d, %ebp
	leaq	64(%rsp), %rdi
	movslq	%ebp, %rsi
	salq	$3, %rsi
	call	cudaMalloc@PLT
	leaq	.LC5(%rip), %rdx
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	.L36
	movslq	%r15d, %rax
	movslq	(%rsp), %rbp
	movslq	4(%rsp), %rsi
	movslq	%r13d, %rcx
	movq	%rax, 16(%rsp)
	salq	$3, %rcx
	pushq	%r9
	.cfi_def_cfa_offset 200
	salq	$3, %rsi
	movq	%rax, %r9
	leaq	0(,%rbp,8), %r8
	pushq	$1
	.cfi_def_cfa_offset 208
	movq	24(%rsp), %rdx
	movq	64(%rsp), %rdi
	call	cudaMemcpy2D@PLT
	popq	%r10
	.cfi_def_cfa_offset 200
	leaq	.LC6(%rip), %rdx
	popq	%r11
	.cfi_def_cfa_offset 192
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	.L36
	movslq	%r12d, %rax
	movslq	24(%rsp), %rcx
	movslq	%r14d, %r13
	movq	%rbp, %r9
	salq	$3, %rax
	salq	$3, %r13
	movq	%rax, 8(%rsp)
	movq	%r13, %r8
	salq	$3, %rcx
	pushq	%rsi
	.cfi_def_cfa_offset 200
	pushq	$1
	.cfi_def_cfa_offset 208
	movq	48(%rsp), %rdx
	movq	24(%rsp), %rsi
	movq	72(%rsp), %rdi
	call	cudaMemcpy2D@PLT
	popq	%rdi
	.cfi_def_cfa_offset 200
	leaq	.LC7(%rip), %rdx
	popq	%r8
	.cfi_def_cfa_offset 192
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	.L36
	movl	(%rsp), %eax
	orl	%r14d, %eax
	orl	%r15d, %eax
	testb	$31, %al
	je	.L28
	movl	116(%rsp), %ecx
	movq	108(%rsp), %rdx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movq	72(%rsp), %rdi
	movl	80(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L29
	movl	(%rsp), %edx
	movq	48(%rsp), %rdi
	movl	%r15d, %esi
	call	_Z34__device_stub__Z12adjustMatrixPdiiPdii
.L29:
	movl	116(%rsp), %ecx
	movq	108(%rsp), %rdx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movq	84(%rsp), %rdi
	movl	92(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L28
	movl	(%rsp), %esi
	movq	56(%rsp), %rdi
	movl	%r14d, %edx
	call	_Z34__device_stub__Z12adjustMatrixPdiiPdii
.L28:
	movl	116(%rsp), %ecx
	movq	108(%rsp), %rdx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movq	96(%rsp), %rdi
	movl	104(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L31
	movl	4(%rsp), %ecx
	movq	64(%rsp), %rdx
	movl	%r12d, %r8d
	movq	56(%rsp), %rsi
	movq	48(%rsp), %rdi
	call	_Z39__device_stub__Z13productKernelPdS_S_iiPdS_S_ii
.L31:
	movslq	28(%rsp), %rsi
	pushq	%rax
	.cfi_def_cfa_offset 200
	movq	%r13, %r8
	pushq	$2
	.cfi_def_cfa_offset 208
	movq	32(%rsp), %r9
	movq	24(%rsp), %rcx
	movq	80(%rsp), %rdx
	salq	$3, %rsi
	movq	56(%rsp), %rdi
	call	cudaMemcpy2D@PLT
	popq	%rdx
	.cfi_def_cfa_offset 200
	popq	%rcx
	.cfi_def_cfa_offset 192
	movl	%eax, %ebx
	testl	%eax, %eax
	je	.L21
	leaq	.LC8(%rip), %rdx
.L36:
	movq	stderr(%rip), %rdi
	movl	$2, %esi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
.L21:
	movq	48(%rsp), %rdi
	call	cudaFree@PLT
	movq	56(%rsp), %rdi
	call	cudaFree@PLT
	movq	64(%rsp), %rdi
	call	cudaFree@PLT
	movq	120(%rsp), %rax
	subq	%fs:40, %rax
	je	.L34
	call	__stack_chk_fail@PLT
.L34:
	addq	$136, %rsp
	.cfi_def_cfa_offset 56
	movl	%ebx, %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
.LFE2030:
	.size	_Z10matmatCudaiiiiiiPdS_S_, .-_Z10matmatCudaiiiiiiPdS_S_
	.section	.rodata.str1.1
.LC9:
	.string	"Ordine matrici; Tempo GPU; GFlops GPU\n"
.LC10:
	.string	"matmatCuda failed!"
.LC15:
	.string	"%6d; %5.2lf; %5.2lf\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2027:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	movl	$10000, %esi
	movl	$10000, %edi
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	movl	$100, %ebx
	subq	$48, %rsp
	.cfi_def_cfa_offset 96
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	call	_Z14rnd_flt_matrixii
	movl	$10000, %esi
	movl	$10000, %edi
	movq	%rax, %r13
	call	_Z14rnd_flt_matrixii
	movl	$8, %esi
	movl	$100000000, %edi
	movq	%rax, %r12
	call	calloc@PLT
	leaq	24(%rsp), %rdi
	movq	%rax, %rbp
	call	cudaEventCreate@PLT
	leaq	32(%rsp), %rdi
	call	cudaEventCreate@PLT
	leaq	.LC9(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L40:
	movq	24(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movl	%ebx, %r9d
	movl	%ebx, %r8d
	movl	%ebx, %ecx
	pushq	%rax
	.cfi_def_cfa_offset 104
	movl	$10000, %edx
	movl	$10000, %esi
	movl	$10000, %edi
	pushq	%rbp
	.cfi_def_cfa_offset 112
	pushq	%r12
	.cfi_def_cfa_offset 120
	pushq	%r13
	.cfi_def_cfa_offset 128
	call	_Z10matmatCudaiiiiiiPdS_S_
	movq	64(%rsp), %rdi
	addq	$32, %rsp
	.cfi_def_cfa_offset 96
	xorl	%esi, %esi
	movl	%eax, %r14d
	call	cudaEventRecord@PLT
	movq	32(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	testl	%r14d, %r14d
	je	.L38
	movq	stderr(%rip), %rdi
	leaq	.LC10(%rip), %rdx
	movl	$2, %esi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	movl	$1, %eax
	jmp	.L37
.L38:
	movq	32(%rsp), %rdx
	movq	24(%rsp), %rsi
	leaq	20(%rsp), %r14
	movq	%r14, %rdi
	call	cudaEventElapsedTime@PLT
	movq	32(%rsp), %rdi
	xorl	%esi, %esi
	movss	20(%rsp), %xmm0
	divss	.LC11(%rip), %xmm0
	movss	%xmm0, 20(%rsp)
	call	cudaEventRecord@PLT
	movq	32(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movq	32(%rsp), %rdx
	movq	24(%rsp), %rsi
	movq	%r14, %rdi
	call	cudaEventElapsedTime@PLT
	cvtss2sd	20(%rsp), %xmm0
	divsd	.LC12(%rip), %xmm0
	movsd	%xmm0, 8(%rsp)
	cvtsi2sdl	%ebx, %xmm0
	movsd	.LC13(%rip), %xmm1
	call	pow@PLT
	movl	%ebx, %edx
	movl	$2, %edi
	addl	$100, %ebx
	addsd	%xmm0, %xmm0
	leaq	.LC15(%rip), %rsi
	cvttsd2siq	%xmm0, %rax
	movsd	8(%rsp), %xmm0
	cvtsi2sdq	%rax, %xmm1
	movb	$2, %al
	divsd	8(%rsp), %xmm1
	divsd	.LC14(%rip), %xmm1
	call	__printf_chk@PLT
	cmpl	$10100, %ebx
	jne	.L40
	movq	24(%rsp), %rdi
	call	cudaEventDestroy@PLT
	movq	32(%rsp), %rdi
	call	cudaEventDestroy@PLT
	movq	%r13, %rdi
	call	free@PLT
	movq	%r12, %rdi
	call	free@PLT
	movq	%rbp, %rdi
	call	free@PLT
	xorl	%eax, %eax
.L37:
	movq	40(%rsp), %rdx
	subq	%fs:40, %rdx
	je	.L41
	call	__stack_chk_fail@PLT
.L41:
	addq	$48, %rsp
	.cfi_def_cfa_offset 48
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2027:
	.size	main, .-main
	.section	.rodata.str1.1
.LC16:
	.string	"_Z13productKernelPdS_S_ii"
.LC17:
	.string	"_Z12adjustMatrixPdii"
	.section	.text.startup
	.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	.LC16(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z13productKernelPdS_S_ii(%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	.LC17(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z12adjustMatrixPdii(%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
	.section	.rodata.cst4,"aM",@progbits,4
	.align 4
.LC0:
	.long	805306368
	.align 4
.LC11:
	.long	1148846080
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC12:
	.long	0
	.long	1083129856
	.align 8
.LC13:
	.long	0
	.long	1074266112
	.align 8
.LC14:
	.long	0
	.long	1104006501
	.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 <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <hip/hip_runtime.h>

#define MAT_SIZE 10000

#define GIGA 1000000000.
#define NSEC 1000000000.

#define THREADS 32

__host__ hipError_t matmatCuda(int, int, int, int, int, int, 
                                double *, double *, double *);
__global__ void productKernel(double*, double*, double*, int, int);
__global__ void adjustMatrix(double *, int, int);

double* rnd_flt_matrix(int n, int m);
double* zeros_flt_matrix(int n, int m);


int main(int argc, char const *argv[])
{
	// Strutture che memorizzano le matrici da moltiplicare
    double *A_h, *B_h, *C_d;
    double gflops_gpu;
    float elapsed;

    long nop;

    // variabili eventi utilizzate per stimare i tempi 
    // di esecuzione sulla Gpu
    hipEvent_t start_gpu, stop_gpu;
    
    double gpuTime; //tempo di esecuzione con Gpu
    
    hipError_t cudaStatus;

	//allocazione matrici
    A_h = rnd_flt_matrix(MAT_SIZE, MAT_SIZE);
    B_h = rnd_flt_matrix(MAT_SIZE, MAT_SIZE);
    C_d = zeros_flt_matrix(MAT_SIZE, MAT_SIZE);

    // Inzializza gli eventi di inizio e fine
    hipEventCreate(&start_gpu);
    hipEventCreate(&stop_gpu);
    
    printf("Ordine matrici; Tempo GPU; GFlops GPU\n");

    for(int i = 100; i <= MAT_SIZE; i += 100)
    {
        // Prende il tempo di inizio
        hipEventRecord(start_gpu, 0);

        // inizializza ed esegue il prodotto tra matrici 
        // sul device @see matmatCuda
        cudaStatus = matmatCuda(MAT_SIZE, MAT_SIZE, MAT_SIZE, 
                                i, i, i, A_h, B_h, C_d);

        // Prende il tempo di fine
        hipEventRecord(stop_gpu, 0);
        hipEventSynchronize(stop_gpu);

        if(cudaStatus != hipSuccess){
            fprintf(stderr, "matmatCuda failed!");
            return 1;
        }

        // Calcolo il tempo trascorso tra i 2 eventi
        hipEventElapsedTime(&elapsed, start_gpu, stop_gpu);
        
        // Trasforma il tempo in secondi
        elapsed /= 1000.;

        // Prende il tempo di fine
        hipEventRecord(stop_gpu, 0);
        hipEventSynchronize(stop_gpu);
        
        // Calcolo il tempo trascorso tra i 2 eventi
        hipEventElapsedTime(&elapsed, start_gpu, stop_gpu);

        // Trasforma il tempo in secondi
        gpuTime = elapsed / 1000.;
        
        nop = 2 * pow(i, 3);

        gflops_gpu = (nop / gpuTime) / GIGA;

        printf("%6d; %5.2lf; %5.2lf\n", i, gpuTime, gflops_gpu);
    }

    hipEventDestroy(start_gpu);
    hipEventDestroy(stop_gpu);
    free(A_h);
    free(B_h);
    free(C_d);

    return 0;
}

double* rnd_flt_matrix(int n, int m)
{   
    int size = n * m;  
    double *A = (double*) malloc(sizeof(double) * size);

    for(int i = 0; i < size; ++i)
        A[i] = (float) rand() / RAND_MAX;
    
    return A;
}

double* zeros_flt_matrix(int n, int m)
{
    return (double*) calloc(n * m, sizeof(double));
}

// procedura che inserisce il valore 0 
// per riempire gli spazi di matrice vuoti sulla cornice
__global__ void adjustMatrix(double *M, int n, int m)
{
	int i = blockIdx.y * blockDim.y + threadIdx.y;
	int j = blockIdx.x * blockDim.x + threadIdx.x;
	int offset = gridDim.x * blockDim.x * i + j;

    if(i >= n || j >= m)        
        M[offset] = 0.;
}

hipError_t matmatCuda(int lda, int ldb, int ldc, 
                       int n, int m, int p, double *A, double *B, double *C)
{
    double *A_d = NULL;
    double *B_d = NULL;
    double *C_d = NULL;
	
	// Calcola il numero di blocchi della griglia
    unsigned int nblock = (n + THREADS - 1) / THREADS;
    unsigned int mblock = (m + THREADS - 1) / THREADS;
    unsigned int pblock = (p + THREADS - 1) / THREADS;

	// Calcola la più piccola matrice quadrata multipla 
	// di THREADS che possa contenere la matrice A e B
    int nwidth = nblock * THREADS;
    int mwidth = mblock * THREADS;
    int pwidth = pblock * THREADS;

    hipError_t cudaStatus;
    
    // Numero di blocchi per la griglia su A
    dim3 blocksA;
    blocksA.x = mblock;
    blocksA.y = nblock;

    // Numero di blocchi per la griglia su B
    dim3 blocksB;
    blocksB.x = pblock;
    blocksB.y = mblock;

	// Numero di blocchi per la griglia su C
	dim3 blocksC;
	blocksC.x = pblock;
	blocksC.y = nblock;
	
	// Numero di thread per blocco
    dim3 threads;
	threads.x = THREADS;
    threads.y = THREADS;
    
    // Scegli la GPU sul quale eseguire, in caso di un sistema multi-GPU.
    cudaStatus = hipSetDevice(0);
    if (cudaStatus != hipSuccess) {
        fprintf(stderr, "1: hipSetDevice failed!\n");
        fprintf(stderr, "Do you have a CUDA-capable GPU installed?\n");
        goto Error;
    }

	// **** Allocazione vettori all'interno della memoria del device ****
	
    cudaStatus = hipMalloc((void**)&A_d, nwidth * mwidth * sizeof(double));

    if (cudaStatus != hipSuccess) {
        fprintf(stderr, "2: hipMalloc failed!\n");
        goto Error;
    }

    cudaStatus = hipMalloc((void**)&B_d, mwidth * pwidth * sizeof(double));

    if (cudaStatus != hipSuccess) {
        fprintf(stderr, "3: hipMalloc failed!\n");
        goto Error;
    }

    cudaStatus = hipMalloc((void**)&C_d, nwidth * pwidth * sizeof(double));
    if (cudaStatus != hipSuccess) {
        fprintf(stderr, "4: hipMalloc failed!\n");
        goto Error;
    }
	// **** Termine allocazione dei vettori ****

	// **** Copia delle matrici in input nella memoria del device ****	
    cudaStatus = hipMemcpy2D(A_d, mwidth * sizeof(double), 
                              A, lda * sizeof(double), 
                              m * sizeof(double), n, hipMemcpyHostToDevice);

    if (cudaStatus != hipSuccess) {
        fprintf(stderr, "5: hipMemcpy2D failed!\n");
        goto Error;
    }

    cudaStatus = hipMemcpy2D(B_d, pwidth * sizeof(double), 
                              B, ldb * sizeof(double), p * sizeof(double),
                              m, hipMemcpyHostToDevice);

    if (cudaStatus != hipSuccess) {
        fprintf(stderr, "6: hipMemcpy2D failed!\n");
        goto Error;
    }
	
	// **** Termina copia dei vettori ****
	
	// Riempie la parte della matrice in eccesso con degli 0	
    if( (n % THREADS) || (m % THREADS) || (p % THREADS) ) {
		adjustMatrix<<<blocksA, threads>>>(A_d, n, m);
	    adjustMatrix<<<blocksB, threads>>>(B_d, m, p);
    }
    
	// Calcolo il prodotto tra le 2 matrici
    productKernel<<<blocksC, threads>>>(A_d, B_d, C_d, mwidth, pwidth);
	
	// Copia del vettore risultante dalla memoria del device a quella RAM
    cudaStatus = hipMemcpy2D(C, ldc * sizeof(double), 
                              C_d, pwidth * sizeof(double), p * sizeof(double),
                              n, hipMemcpyDeviceToHost);

    if (cudaStatus != hipSuccess) {
        fprintf(stderr, "7: hipMemcpy2D failed!\n");
        goto Error;
    }

	
	// Deallocazione vettori ed eventi dalla memoria del device
    Error:
        hipFree(A_d);
        hipFree(B_d);
        hipFree(C_d);

    return cudaStatus;
}

 /**
 * Esegue il prodotto scalare tra  una riga di A e una colonna di B
 *
 * @param A vettore rapprensentante la matrice A
 * @param B vettore rapprensentante la matrice B
 * @param C vettore risulatante reappresentante la matrice C
 * @param width dimensione della matrice
 */
 __global__ void productKernel(double* A, double* B, double* C, int m, int p)
 {
    // id del blocco sull'ordinata all'interno della griglia
    int ib = blockIdx.y;
    // id del blocco sull'ascissa all'interno della griglia	
    int jb = blockIdx.x;
    // id del thread sull'ordinata all'interno del blocco	
    int it = threadIdx.y;
    // id del thread sull'ascissa allinterno del blocco 
    int jt = threadIdx.x;

    int a, b, c, k;

    // Indice della prima sottomatrice di A elaborata dal blocco
    // m e' un multiplo intero di THREADS
    // aBegin  include un certo numero ib  di gruppi di blocchi 
    // rettangolari THREADSxwidth
    int aBegin = m * THREADS * ib;

    //Indice dell'ultima sottomatrice di A elaborata dal blocco
    int aEnd   = aBegin + m - 1;

    // numero di colonne tra una sottomatrice e la successiva
    int aStep  = THREADS;

    // indice della prima sottomatrice di B elaborata dal blocco
    // bBegin include un certo numero jb di blocchi di colonne, 
    // blocchi larghi THREADS
    int bBegin = THREADS * jb;

    // numero di elementi tra una sottomatrice e la successiva
    int bStep  = THREADS * p;

    // Csub e' usata come variabile in cui memorizzare 
    // il valore dell'elemento di C calcolato dal thread
    // Viene aggiornato ripetutamente nel ciclo for seguente
    double Csub = 0;

    // Le matrici vengono divise in blocchi di dimensione THREADS X THREADS
    // per ridurre il numero di accessi alla memoria pricipale del device 
    // che risultano costosi in termini di tempo
    
    // Dichiarazione della variabile in cui salvare 
    // la sottomatrice di A in esame
    __shared__ double As[THREADS][THREADS];

    // Dichiarazione della variabile in cui salvare 
    // la sottomatrice di B in esame
    __shared__ double Bs[THREADS][THREADS];

    // Iterazione sulle sottomatrici 
    // in cui viene suddiviso il calcolo degli elementi del blocco
    for (a = aBegin, b = bBegin; a <= aEnd; a += aStep, b += bStep)
    {
        // Vengono Caricati gli elementi di ciascuna 
        // sottomatrice in memoria condivisa:
        // ogni thread del blocco carica un elemento!
            
        As[it][jt] = A[a +  m * it + jt];
        Bs[it][jt] = B[b +  p * it + jt];

        // i processi vengono sincronizzati per assicurare 
        // che ogni thread del blocco abbia caricato gli elementi.
        __syncthreads();

        // vengono calcolati i contributi agli elementi di matrice di C 
        // dovute alla sottomatrici in esame
        for( k = 0; k < THREADS ; ++k )
            Csub += As[it][k]*Bs[k][jt];
        // l'elemento C[it][jt] viene aggiornato in un numero di volte
        // pari al numero di iterazioni del ciclo for

        // i processi vengono sincronizzati per assicurare che il calcolo 
        // precedente sia terminato prima di caricare nuove
        // sottomatrici
        __syncthreads();
    }

    // vengono inseriti i risultati in C.
    // Ogni thread elabora un elemento di C.
    c = p * THREADS * ib + THREADS * jb;
    C[c +  p * it + jt] = Csub;
 }
 
	.text
	.file	"main.hip"
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function main
.LCPI0_0:
	.long	0x447a0000                      # float 1000
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0
.LCPI0_1:
	.quad	0x408f400000000000              # double 1000
.LCPI0_2:
	.quad	0x4008000000000000              # double 3
.LCPI0_3:
	.quad	0x41cdcd6500000000              # double 1.0E+9
	.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	$40, %rsp
	.cfi_def_cfa_offset 96
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	$10000, %edi                    # imm = 0x2710
	movl	$10000, %esi                    # imm = 0x2710
	callq	_Z14rnd_flt_matrixii
	movq	%rax, %rbx
	movl	$10000, %edi                    # imm = 0x2710
	movl	$10000, %esi                    # imm = 0x2710
	callq	_Z14rnd_flt_matrixii
	movq	%rax, %r14
	movl	$100000000, %edi                # imm = 0x5F5E100
	movl	$8, %esi
	callq	calloc
	movq	%rax, %r15
	leaq	24(%rsp), %rdi
	callq	hipEventCreate
	leaq	8(%rsp), %rdi
	callq	hipEventCreate
	movl	$.Lstr, %edi
	callq	puts@PLT
	xorl	%r12d, %r12d
	leaq	20(%rsp), %r13
.LBB0_1:                                # =>This Inner Loop Header: Depth=1
	addl	$100, %r12d
	movq	24(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	subq	$8, %rsp
	.cfi_adjust_cfa_offset 8
	movl	$10000, %edi                    # imm = 0x2710
	movl	$10000, %esi                    # imm = 0x2710
	movl	$10000, %edx                    # imm = 0x2710
	movl	%r12d, %ecx
	movl	%r12d, %r8d
	movl	%r12d, %r9d
	pushq	%r15
	.cfi_adjust_cfa_offset 8
	pushq	%r14
	.cfi_adjust_cfa_offset 8
	pushq	%rbx
	.cfi_adjust_cfa_offset 8
	callq	_Z10matmatCudaiiiiiiPdS_S_
	addq	$32, %rsp
	.cfi_adjust_cfa_offset -32
	movl	%eax, %ebp
	movq	8(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	8(%rsp), %rdi
	callq	hipEventSynchronize
	testl	%ebp, %ebp
	jne	.LBB0_5
# %bb.2:                                #   in Loop: Header=BB0_1 Depth=1
	movq	24(%rsp), %rsi
	movq	8(%rsp), %rdx
	movq	%r13, %rdi
	callq	hipEventElapsedTime
	movss	20(%rsp), %xmm0                 # xmm0 = mem[0],zero,zero,zero
	divss	.LCPI0_0(%rip), %xmm0
	movss	%xmm0, 20(%rsp)
	movq	8(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	8(%rsp), %rdi
	callq	hipEventSynchronize
	movq	24(%rsp), %rsi
	movq	8(%rsp), %rdx
	movq	%r13, %rdi
	callq	hipEventElapsedTime
	xorps	%xmm0, %xmm0
	cvtss2sd	20(%rsp), %xmm0
	divsd	.LCPI0_1(%rip), %xmm0
	movsd	%xmm0, 32(%rsp)                 # 8-byte Spill
	xorps	%xmm0, %xmm0
	cvtsi2sd	%r12d, %xmm0
	movsd	.LCPI0_2(%rip), %xmm1           # xmm1 = mem[0],zero
	callq	pow
	addsd	%xmm0, %xmm0
	cvttsd2si	%xmm0, %rax
	xorps	%xmm1, %xmm1
	cvtsi2sd	%rax, %xmm1
	movsd	32(%rsp), %xmm0                 # 8-byte Reload
                                        # xmm0 = mem[0],zero
	divsd	%xmm0, %xmm1
	divsd	.LCPI0_3(%rip), %xmm1
	movl	$.L.str.2, %edi
	movl	%r12d, %esi
	movb	$2, %al
	callq	printf
	cmpl	$9900, %r12d                    # imm = 0x26AC
	jbe	.LBB0_1
# %bb.3:
	movq	24(%rsp), %rdi
	callq	hipEventDestroy
	movq	8(%rsp), %rdi
	callq	hipEventDestroy
	movq	%rbx, %rdi
	callq	free
	movq	%r14, %rdi
	callq	free
	movq	%r15, %rdi
	callq	free
	xorl	%eax, %eax
.LBB0_4:
	addq	$40, %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
.LBB0_5:
	.cfi_def_cfa_offset 96
	movq	stderr(%rip), %rcx
	movl	$.L.str.1, %edi
	movl	$18, %esi
	movl	$1, %edx
	callq	fwrite@PLT
	movl	$1, %eax
	jmp	.LBB0_4
.Lfunc_end0:
	.size	main, .Lfunc_end0-main
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function _Z14rnd_flt_matrixii
.LCPI1_0:
	.long	0x30000000                      # float 4.65661287E-10
	.text
	.globl	_Z14rnd_flt_matrixii
	.type	_Z14rnd_flt_matrixii,@function
_Z14rnd_flt_matrixii:                   # @_Z14rnd_flt_matrixii
	.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	%rbx
	.cfi_def_cfa_offset 40
	pushq	%rax
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	%edi, %ebp
	imull	%esi, %ebp
	movslq	%ebp, %r14
	leaq	(,%r14,8), %rdi
	callq	malloc
	movq	%rax, %rbx
	testl	%r14d, %r14d
	jle	.LBB1_3
# %bb.1:                                # %.lr.ph.preheader
	movl	%ebp, %r14d
	xorl	%r15d, %r15d
.LBB1_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	callq	rand
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	mulss	.LCPI1_0(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	movsd	%xmm0, (%rbx,%r15,8)
	incq	%r15
	cmpq	%r15, %r14
	jne	.LBB1_2
.LBB1_3:                                # %._crit_edge
	movq	%rbx, %rax
	addq	$8, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.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	_Z14rnd_flt_matrixii, .Lfunc_end1-_Z14rnd_flt_matrixii
	.cfi_endproc
                                        # -- End function
	.globl	_Z16zeros_flt_matrixii          # -- Begin function _Z16zeros_flt_matrixii
	.type	_Z16zeros_flt_matrixii,@function
_Z16zeros_flt_matrixii:                 # @_Z16zeros_flt_matrixii
	.cfi_startproc
# %bb.0:
	imull	%esi, %edi
	movslq	%edi, %rdi
	movl	$8, %esi
	jmp	calloc                          # TAILCALL
.Lfunc_end2:
	.size	_Z16zeros_flt_matrixii, .Lfunc_end2-_Z16zeros_flt_matrixii
	.cfi_endproc
                                        # -- End function
	.globl	_Z10matmatCudaiiiiiiPdS_S_      # -- Begin function _Z10matmatCudaiiiiiiPdS_S_
	.type	_Z10matmatCudaiiiiiiPdS_S_,@function
_Z10matmatCudaiiiiiiPdS_S_:             # @_Z10matmatCudaiiiiiiPdS_S_
	.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	$104, %rsp
	.cfi_def_cfa_offset 160
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	%r9d, %r12d
                                        # kill: def $r8d killed $r8d def $r8
                                        # kill: def $ecx killed $ecx def $rcx
	movl	%edx, 84(%rsp)                  # 4-byte Spill
	movl	%esi, %r13d
	movl	%edi, 64(%rsp)                  # 4-byte Spill
	xorl	%eax, %eax
	movq	%rax, 24(%rsp)
	movq	%rax, 16(%rsp)
	movq	%rax, 48(%rsp)
	leal	31(%rcx), %eax
	movq	%rcx, 72(%rsp)                  # 8-byte Spill
	leal	62(%rcx), %r15d
	testl	%eax, %eax
	cmovnsl	%eax, %r15d
	leal	31(%r8), %eax
	movq	%r8, 40(%rsp)                   # 8-byte Spill
	leal	62(%r8), %ebx
	testl	%eax, %eax
	cmovnsl	%eax, %ebx
	leal	31(%r12), %eax
	leal	62(%r12), %ebp
	testl	%eax, %eax
	cmovnsl	%eax, %ebp
	xorl	%edi, %edi
	callq	hipSetDevice
	testl	%eax, %eax
	jne	.LBB3_1
# %bb.2:
	movl	%r13d, 56(%rsp)                 # 4-byte Spill
	movq	%r12, 96(%rsp)                  # 8-byte Spill
	movl	%r15d, %r12d
	andl	$-32, %r12d
	movl	%ebx, %r13d
	andl	$-32, %r13d
	movl	%r13d, %eax
	imull	%r12d, %eax
	movslq	%eax, %rsi
	shlq	$3, %rsi
	leaq	24(%rsp), %rdi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB3_3
# %bb.6:
	movq	%rbx, 88(%rsp)                  # 8-byte Spill
	movl	%ebp, %ebx
	andl	$-32, %ebx
	movl	%ebx, %eax
	imull	%r13d, %eax
	movslq	%eax, %rsi
	shlq	$3, %rsi
	leaq	16(%rsp), %rdi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB3_7
# %bb.8:
	movl	%ebx, 36(%rsp)                  # 4-byte Spill
	imull	%ebx, %r12d
	movslq	%r12d, %rsi
	shlq	$3, %rsi
	leaq	48(%rsp), %rdi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB3_9
# %bb.10:
	movq	160(%rsp), %rdx
	movq	24(%rsp), %rdi
	movslq	%r13d, %rsi
	shlq	$3, %rsi
	movslq	64(%rsp), %rcx                  # 4-byte Folded Reload
	shlq	$3, %rcx
	movslq	40(%rsp), %r12                  # 4-byte Folded Reload
	leaq	(,%r12,8), %r8
	movslq	72(%rsp), %rbx                  # 4-byte Folded Reload
	movl	$1, (%rsp)
	movq	%rbx, %r9
	callq	hipMemcpy2D
	testl	%eax, %eax
	jne	.LBB3_11
# %bb.13:
	movl	%r13d, 80(%rsp)                 # 4-byte Spill
	movq	168(%rsp), %rdx
	movq	16(%rsp), %rdi
	movslq	36(%rsp), %rsi                  # 4-byte Folded Reload
	shlq	$3, %rsi
	movslq	56(%rsp), %rcx                  # 4-byte Folded Reload
	shlq	$3, %rcx
	movq	96(%rsp), %r13                  # 8-byte Reload
	movslq	%r13d, %r8
	shlq	$3, %r8
	movl	$1, (%rsp)
	movq	%rsi, 64(%rsp)                  # 8-byte Spill
	movq	%r8, 56(%rsp)                   # 8-byte Spill
	movq	%r12, %r9
	callq	hipMemcpy2D
	testl	%eax, %eax
	jne	.LBB3_14
# %bb.15:
	movq	%rbx, %r12
	sarl	$5, %r15d
	sarl	$5, %ebp
	shlq	$32, %r15
	leaq	(%r15,%rbp), %rdi
	movabsq	$137438953504, %rdx             # imm = 0x2000000020
	movq	40(%rsp), %rax                  # 8-byte Reload
                                        # kill: def $eax killed $eax killed $rax
	orl	72(%rsp), %eax                  # 4-byte Folded Reload
	orl	%r13d, %eax
	testb	$31, %al
	je	.LBB3_20
# %bb.16:
	movq	%r13, %r14
	movq	%rdi, %r13
	movq	88(%rsp), %rbx                  # 8-byte Reload
	sarl	$5, %ebx
	orq	%rbx, %r15
	shlq	$32, %rbx
	orq	%rbp, %rbx
	movq	%r15, %rdi
	movl	$1, %esi
	movq	%rdx, %r15
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB3_18
# %bb.17:
	movq	24(%rsp), %rdi
	movq	72(%rsp), %rsi                  # 8-byte Reload
                                        # kill: def $esi killed $esi killed $rsi
	movq	40(%rsp), %rdx                  # 8-byte Reload
                                        # kill: def $edx killed $edx killed $rdx
	callq	_Z27__device_stub__adjustMatrixPdii
.LBB3_18:
	movq	%rbx, %rdi
	movl	$1, %esi
	movq	%r15, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	movq	%r15, %rdx
	movq	%r13, %rdi
	jne	.LBB3_20
# %bb.19:
	movq	16(%rsp), %rdi
	movq	40(%rsp), %rsi                  # 8-byte Reload
                                        # kill: def $esi killed $esi killed $rsi
	movq	%rdx, %rbx
	movl	%r14d, %edx
	callq	_Z27__device_stub__adjustMatrixPdii
	movq	%r13, %rdi
	movq	%rbx, %rdx
.LBB3_20:
	movq	176(%rsp), %rbx
	xorl	%r14d, %r14d
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB3_22
# %bb.21:
	movq	24(%rsp), %rdi
	movq	16(%rsp), %rsi
	movq	48(%rsp), %rdx
	movl	80(%rsp), %ecx                  # 4-byte Reload
	movl	36(%rsp), %r8d                  # 4-byte Reload
	callq	_Z28__device_stub__productKernelPdS_S_ii
.LBB3_22:
	movslq	84(%rsp), %rsi                  # 4-byte Folded Reload
	shlq	$3, %rsi
	movq	48(%rsp), %rdx
	movl	$2, (%rsp)
	movq	%rbx, %rdi
	movq	64(%rsp), %rcx                  # 8-byte Reload
	movq	56(%rsp), %r8                   # 8-byte Reload
	movq	%r12, %r9
	callq	hipMemcpy2D
	testl	%eax, %eax
	je	.LBB3_24
# %bb.23:
	movl	%eax, %ebx
	movq	stderr(%rip), %rcx
	movl	$.L.str.10, %edi
	movl	$23, %esi
	movl	$1, %edx
	callq	fwrite@PLT
	movl	%ebx, %r14d
	jmp	.LBB3_24
.LBB3_1:
	movl	%eax, %r14d
	movq	stderr(%rip), %rcx
	movl	$.L.str.3, %edi
	movl	$24, %esi
	movl	$1, %edx
	callq	fwrite@PLT
	movq	stderr(%rip), %rcx
	movl	$.L.str.4, %edi
	movl	$42, %esi
	jmp	.LBB3_5
.LBB3_3:
	movl	%eax, %r14d
	movq	stderr(%rip), %rcx
	movl	$.L.str.5, %edi
	jmp	.LBB3_4
.LBB3_7:
	movl	%eax, %r14d
	movq	stderr(%rip), %rcx
	movl	$.L.str.6, %edi
	jmp	.LBB3_4
.LBB3_9:
	movl	%eax, %r14d
	movq	stderr(%rip), %rcx
	movl	$.L.str.7, %edi
.LBB3_4:
	movl	$21, %esi
	jmp	.LBB3_5
.LBB3_11:
	movl	%eax, %r14d
	movq	stderr(%rip), %rcx
	movl	$.L.str.8, %edi
	jmp	.LBB3_12
.LBB3_14:
	movl	%eax, %r14d
	movq	stderr(%rip), %rcx
	movl	$.L.str.9, %edi
.LBB3_12:
	movl	$23, %esi
.LBB3_5:
	movl	$1, %edx
	callq	fwrite@PLT
.LBB3_24:
	movq	24(%rsp), %rdi
	callq	hipFree
	movq	16(%rsp), %rdi
	callq	hipFree
	movq	48(%rsp), %rdi
	callq	hipFree
	movl	%r14d, %eax
	addq	$104, %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	_Z10matmatCudaiiiiiiPdS_S_, .Lfunc_end3-_Z10matmatCudaiiiiiiPdS_S_
	.cfi_endproc
                                        # -- End function
	.globl	_Z27__device_stub__adjustMatrixPdii # -- Begin function _Z27__device_stub__adjustMatrixPdii
	.type	_Z27__device_stub__adjustMatrixPdii,@function
_Z27__device_stub__adjustMatrixPdii:    # @_Z27__device_stub__adjustMatrixPdii
	.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	$96, %rsp
	.cfi_def_cfa_offset 144
	.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)
	movq	%rsp, %rsi
	movl	%edx, (%rsi)
	leaq	64(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	movq	%rsi, 16(%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	$_Z12adjustMatrixPdii, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$112, %rsp
	.cfi_adjust_cfa_offset -112
	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_end4:
	.size	_Z27__device_stub__adjustMatrixPdii, .Lfunc_end4-_Z27__device_stub__adjustMatrixPdii
	.cfi_endproc
                                        # -- End function
	.globl	_Z28__device_stub__productKernelPdS_S_ii # -- Begin function _Z28__device_stub__productKernelPdS_S_ii
	.type	_Z28__device_stub__productKernelPdS_S_ii,@function
_Z28__device_stub__productKernelPdS_S_ii: # @_Z28__device_stub__productKernelPdS_S_ii
	.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	$128, %rsp
	.cfi_def_cfa_offset 176
	.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)
	movq	%rsp, %rcx
	movl	%r8d, (%rcx)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	movq	%rcx, 32(%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	$_Z13productKernelPdS_S_ii, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$144, %rsp
	.cfi_adjust_cfa_offset -144
	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_end5:
	.size	_Z28__device_stub__productKernelPdS_S_ii, .Lfunc_end5-_Z28__device_stub__productKernelPdS_S_ii
	.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	.LBB6_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB6_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z12adjustMatrixPdii, %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	$_Z13productKernelPdS_S_ii, %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_end6:
	.size	__hip_module_ctor, .Lfunc_end6-__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	.LBB7_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
.LBB7_2:
	retq
.Lfunc_end7:
	.size	__hip_module_dtor, .Lfunc_end7-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	.L.str.1,@object                # @.str.1
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.1:
	.asciz	"matmatCuda failed!"
	.size	.L.str.1, 19

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"%6d; %5.2lf; %5.2lf\n"
	.size	.L.str.2, 21

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

	.type	.L.str.3,@object                # @.str.3
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.3:
	.asciz	"1: hipSetDevice failed!\n"
	.size	.L.str.3, 25

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"Do you have a CUDA-capable GPU installed?\n"
	.size	.L.str.4, 43

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"2: hipMalloc failed!\n"
	.size	.L.str.5, 22

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"3: hipMalloc failed!\n"
	.size	.L.str.6, 22

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"4: hipMalloc failed!\n"
	.size	.L.str.7, 22

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"5: hipMemcpy2D failed!\n"
	.size	.L.str.8, 24

	.type	.L.str.9,@object                # @.str.9
.L.str.9:
	.asciz	"6: hipMemcpy2D failed!\n"
	.size	.L.str.9, 24

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

	.type	.L.str.10,@object               # @.str.10
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.10:
	.asciz	"7: hipMemcpy2D failed!\n"
	.size	.L.str.10, 24

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

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_Z13productKernelPdS_S_ii"
	.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

	.type	.Lstr,@object                   # @str
	.section	.rodata.str1.1,"aMS",@progbits,1
.Lstr:
	.asciz	"Ordine matrici; Tempo GPU; GFlops GPU"
	.size	.Lstr, 38

	.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__adjustMatrixPdii
	.addrsig_sym _Z28__device_stub__productKernelPdS_S_ii
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z12adjustMatrixPdii
	.addrsig_sym _Z13productKernelPdS_S_ii
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z12adjustMatrixPdii    ; -- Begin function _Z12adjustMatrixPdii
	.globl	_Z12adjustMatrixPdii
	.p2align	8
	.type	_Z12adjustMatrixPdii,@function
_Z12adjustMatrixPdii:                   ; @_Z12adjustMatrixPdii
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x1c
	s_load_b64 s[6:7], s[0:1], 0x8
	v_bfe_u32 v1, v0, 10, 10
	v_and_b32_e32 v4, 0x3ff, v0
	s_add_u32 s4, s0, 16
	s_addc_u32 s5, s1, 0
	s_waitcnt lgkmcnt(0)
	s_lshr_b32 s8, s2, 16
	s_and_b32 s3, s2, 0xffff
	v_mad_u64_u32 v[2:3], null, s15, s8, v[1:2]
	v_mad_u64_u32 v[0:1], null, s14, s3, v[4:5]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_cmp_le_i32_e32 vcc_lo, s6, v2
	v_cmp_le_i32_e64 s2, s7, v0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_or_b32 s2, vcc_lo, s2
	s_and_saveexec_b32 s6, s2
	s_cbranch_execz .LBB0_2
; %bb.1:
	s_load_b32 s2, s[4:5], 0x0
	v_mul_lo_u32 v3, v2, s3
	s_load_b64 s[0:1], s[0:1], 0x0
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, v3, s2, v[0:1]
	v_ashrrev_i32_e32 v2, 31, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[0:1], 3, v[1:2]
	v_mov_b32_e32 v2, 0
	v_mov_b32_e32 v3, v2
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_4)
	v_add_co_u32 v0, vcc_lo, s0, v0
	v_add_co_ci_u32_e32 v1, vcc_lo, s1, v1, vcc_lo
	global_store_b64 v[0:1], v[2:3], off
.LBB0_2:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z12adjustMatrixPdii
		.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 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	_Z12adjustMatrixPdii, .Lfunc_end0-_Z12adjustMatrixPdii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 208
; 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	_Z13productKernelPdS_S_ii ; -- Begin function _Z13productKernelPdS_S_ii
	.globl	_Z13productKernelPdS_S_ii
	.p2align	8
	.type	_Z13productKernelPdS_S_ii,@function
_Z13productKernelPdS_S_ii:              ; @_Z13productKernelPdS_S_ii
; %bb.0:
	s_load_b256 s[0:7], s[0:1], 0x0
	v_bfe_u32 v1, v0, 10, 10
	s_mov_b32 s11, 0
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_1)
	v_mul_lo_u32 v5, v1, s7
	s_cmp_gt_i32 s6, 0
	s_cbranch_scc1 .LBB1_2
; %bb.1:                                ; %.._crit_edge_crit_edge
	v_mul_lo_u32 v3, v1, s7
	s_mov_b64 s[8:9], 0
	s_branch .LBB1_3
.LBB1_2:
	s_mov_b32 s11, -1
                                        ; implicit-def: $sgpr8_sgpr9
                                        ; implicit-def: $vgpr3
.LBB1_3:                                ; %Flow73
	v_and_b32_e32 v0, 0x3ff, v0
	s_lshl_b32 s10, s14, 5
	s_and_not1_b32 vcc_lo, exec_lo, s11
	s_lshl_b32 s7, s7, 5
	s_cbranch_vccnz .LBB1_9
; %bb.4:                                ; %.lr.ph
	v_lshlrev_b32_e32 v2, 3, v0
	v_lshlrev_b32_e32 v6, 8, v1
	v_mad_u64_u32 v[3:4], null, v1, s6, v[0:1]
	s_mul_i32 s8, s6, s15
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_or_b32_e32 v7, 0x2000, v2
	v_dual_mov_b32 v1, 0 :: v_dual_add_nc_u32 v4, v6, v2
	v_add_nc_u32_e32 v8, v5, v0
	s_delay_alu instid0(VALU_DEP_3)
	v_dual_mov_b32 v2, 0 :: v_dual_add_nc_u32 v9, v7, v6
	s_lshl_b32 s8, s8, 5
	s_mov_b32 s9, s10
	s_add_i32 s6, s8, s6
.LBB1_5:                                ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB1_6 Depth 2
	v_add_nc_u32_e32 v10, s8, v3
	v_add_nc_u32_e32 v12, s9, v8
	s_mov_b32 s11, 0
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_ashrrev_i32_e32 v11, 31, v10
	v_ashrrev_i32_e32 v13, 31, v12
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_lshlrev_b64 v[10:11], 3, v[10:11]
	v_lshlrev_b64 v[12:13], 3, v[12:13]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_co_u32 v10, vcc_lo, s0, v10
	v_add_co_ci_u32_e32 v11, vcc_lo, s1, v11, vcc_lo
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_4)
	v_add_co_u32 v12, vcc_lo, s2, v12
	v_add_co_ci_u32_e32 v13, vcc_lo, s3, v13, vcc_lo
	global_load_b64 v[14:15], v[10:11], off
	global_load_b64 v[11:12], v[12:13], off
	v_mov_b32_e32 v10, v7
	s_waitcnt vmcnt(1)
	ds_store_b64 v4, v[14:15]
	s_waitcnt vmcnt(0)
	ds_store_b64 v9, v[11:12]
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
.LBB1_6:                                ;   Parent Loop BB1_5 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	v_add_nc_u32_e32 v13, s11, v6
	s_add_i32 s11, s11, 8
	ds_load_b64 v[11:12], v10
	ds_load_b64 v[13:14], v13
	v_add_nc_u32_e32 v10, 0x100, v10
	s_cmpk_lg_i32 s11, 0x100
	s_waitcnt lgkmcnt(0)
	v_fma_f64 v[1:2], v[13:14], v[11:12], v[1:2]
	s_cbranch_scc1 .LBB1_6
; %bb.7:                                ;   in Loop: Header=BB1_5 Depth=1
	s_add_i32 s8, s8, 32
	s_add_i32 s9, s9, s7
	s_cmp_lt_i32 s8, s6
	s_barrier
	buffer_gl0_inv
	s_cbranch_scc1 .LBB1_5
; %bb.8:                                ; %Flow
	v_mov_b32_e32 v3, v5
	s_branch .LBB1_10
.LBB1_9:
	v_dual_mov_b32 v1, s8 :: v_dual_mov_b32 v2, s9
.LBB1_10:                               ; %._crit_edge
	v_add_nc_u32_e32 v0, s10, v0
	s_mul_i32 s7, s7, s15
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	v_add3_u32 v3, v0, v3, s7
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v4, 31, v3
	v_lshlrev_b64 v[3:4], 3, v[3:4]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v3, vcc_lo, s4, v3
	v_add_co_ci_u32_e32 v4, vcc_lo, s5, v4, vcc_lo
	global_store_b64 v[3:4], v[1:2], off
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z13productKernelPdS_S_ii
		.amdhsa_group_segment_fixed_size 16384
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 32
		.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 16
		.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	_Z13productKernelPdS_S_ii, .Lfunc_end1-_Z13productKernelPdS_S_ii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 460
; NumSgprs: 18
; NumVgprs: 16
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 16384 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 16
; 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
      - .offset:         8
        .size:           4
        .value_kind:     by_value
      - .offset:         12
        .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:           _Z12adjustMatrixPdii
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z12adjustMatrixPdii.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
      - .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:         28
        .size:           4
        .value_kind:     by_value
    .group_segment_fixed_size: 16384
    .kernarg_segment_align: 8
    .kernarg_segment_size: 32
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z13productKernelPdS_S_ii
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z13productKernelPdS_S_ii.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     16
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
