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

#define TILE_SIZE 16



// CUDA Kernel
__global__ void matrixMul( float* C, float* A, float* B, int TM)
{
  __shared__ float As [TILE_SIZE][TILE_SIZE];
  __shared__ float Bs [TILE_SIZE][TILE_SIZE];

    // chaque thread calcule C[i][j]
    // Coordonnees absolues du thread : indices i j
    int j = blockIdx.x * blockDim.x+ threadIdx.x;
    int i = blockIdx.y * blockDim.y+ threadIdx.y;
    int tx = threadIdx.x;
    int ty = threadIdx.y;
 
    float value = 0;

    for(int ke=0; ke<TM; ke += TILE_SIZE) {
      // Remplissage de As et de Bs
      As[ty][tx] = A[i * TM + ke + tx];
      Bs[ty][tx] = B[(ke + ty) * TM + j];

      __syncthreads();

      // Calcul
      for (int k = 0; k < TILE_SIZE; k++) {
        value += As[ty][k] * Bs[k][tx];
      }

      __syncthreads();
    }

   C[i * TM + j] = value;
}
  
/////////////////////////////////////////////////////////
// Program main
/////////////////////////////////////////////////////////
 
int main(int argc, char** argv) {
  int i, j, TM, BLOCK_SIZE_X, BLOCK_SIZE_Y;
  unsigned int M_size;
  float *h_A, *h_B, *h_C;
  float *d_A, *d_B, *d_C;
  cudaError_t cerror;
  float  elapsedTime ;
  cudaEvent_t start , stop ;

  // Valeurs par defaut
  TM=2048;
  BLOCK_SIZE_X = TILE_SIZE;
  BLOCK_SIZE_Y = TILE_SIZE;

  // Possibilite de lire TM dans arg1, BLOCK_SIZE_X dans arg2 et BLOCK_SIZE_Y ans arg3
  if (argc>1) {
    TM=atoi(argv[1]);
  }
  // if (argc>3) {
  //   BLOCK_SIZE_X =atoi(argv[2]);
  //   BLOCK_SIZE_Y =atoi(argv[3]);
  // }
  
  // Verification de la bonne taille TM par rapport aux dimensions des blocs
  if ((TM % BLOCK_SIZE_X) !=0) {
    printf("Taille matrice non multiple de taille bloc X %d \n", BLOCK_SIZE_X);
    exit(1);
  }
  if ((TM % BLOCK_SIZE_Y) !=0) {
    printf("Taille matrice non multiple de taille bloc Y %d \n", BLOCK_SIZE_Y);
    exit(1);
  }
  
  // Allocation memoire sur CPU
  M_size = TM*TM*sizeof(float);
  h_A = (float*) malloc(M_size);
  h_B = (float*) malloc(M_size);
  h_C = (float*) malloc(M_size);
  
  // initialisation des matrices avec des valeurs permettant de verifier le resultat
  for(i = 0; i < TM; i++){
      for(j = 0; j < TM; j++){
      	h_A[i*TM+j] = 1.0;
      	h_B[i*TM+j] = 1.0;
	      h_C[i*TM+j] = 0.0;

      	if (i==j) {
      		h_A[i*TM+j]=(float) (i+1);
      		h_B[i*TM+j]=(float) (i+1);
      	}
      }
  }
  
  // Allocation memoire sur GPU
  cudaMalloc((void**) &d_A, M_size);
  cudaMalloc((void**) &d_B, M_size);
  cudaMalloc((void**) &d_C, M_size);
  
  // Calcul du temps : top depart
  cudaEventCreate (&start ) ;
  cudaEventCreate (&stop ) ;
  cudaEventRecord ( start , 0 ) ;
  
  // copie des donnes CPU vers GPU
  cudaMemcpy(d_A, h_A, M_size, cudaMemcpyHostToDevice);
  cudaMemcpy(d_B, h_B, M_size, cudaMemcpyHostToDevice);
  
  // choix de la structure : grille et blocs
  dim3 threads(BLOCK_SIZE_X, BLOCK_SIZE_Y);
  dim3 grid(TM / threads.x, TM / threads.y);
 
   printf("bloc %d %d \n", BLOCK_SIZE_X, BLOCK_SIZE_Y);
   printf("grille %d %d \n", TM / threads.x, TM / threads.y);
   
   // Lancement des threads
   matrixMul<<< grid, threads >>>(d_C, d_A, d_B, TM);

   // En cas d'erreur
   cerror=cudaGetLastError(); 
   if ((int)cerror !=0) { 
     printf("Erreur appel kernel %d \n", (int) cerror);
     exit(cerror);
   }
 
   // copie des resultats depuis le GPU
   cudaMemcpy(h_C, d_C, M_size, cudaMemcpyDeviceToHost);
   
   // Calcul du temps d'execution
   cudaEventRecord ( stop , 0 ) ;
   cudaEventSynchronize ( stop ) ;
   cudaEventElapsedTime ( &elapsedTime , start , stop ) ;
   cudaEventDestroy ( start ) ;
   cudaEventDestroy ( stop ) ;
   printf ( "Temps consomme: %f secondes\n" , elapsedTime / 1000.0 ) ;

  // Verification des resultats

   for(i = 0; i < TM; i++){
     for(j = 0; j < TM; j++){
      	if ((i==j) && (h_C[i*TM+j] != (float)((i+1)*(i+1)+TM-1))) {
      		printf("Erreur i: %d j: %d %f\n", i, j, h_C[i*TM+j] ); exit(1);
      	}
      	else if ((i!=j) && (h_C[i*TM+j] != (float)(i+j+TM))){
      		printf("Erreur i: %d j: %d\n", i, j);
      		exit(1);
      	}
     }
   } 

   // liberation de la memoire
   free(h_A);
   free(h_B);
   free(h_C);
   cudaFree(d_A);
   cudaFree(d_B);
   cudaFree(d_C);
}

	.file	"tmpxft_00259e4a_00000000-6_mul_matG2B2_et_2.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	_Z33__device_stub__Z9matrixMulPfS_S_iPfS_S_i
	.type	_Z33__device_stub__Z9matrixMulPfS_S_iPfS_S_i, @function
_Z33__device_stub__Z9matrixMulPfS_S_iPfS_S_i:
.LFB2052:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movq	%rdi, 24(%rsp)
	leaq	56(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	68(%rsp), %rsi
	movq	%rdx, 8(%rsp)
	leaq	40(%rsp), %rdx
	movl	%ecx, 4(%rsp)
	leaq	48(%rsp), %rcx
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 64(%rsp)
	movq	%rax, 104(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	4(%rsp), %rax
	movq	%rax, 128(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 56(%rsp)
	movq	%rax, 68(%rsp)
	movl	$1, 76(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L2
	pushq	48(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z9matrixMulPfS_S_i(%rip), %rdi
	pushq	48(%rsp)
	.cfi_def_cfa_offset 176
	movq	84(%rsp), %rcx
	movl	92(%rsp), %r8d
	movq	72(%rsp), %rsi
	movl	80(%rsp), %edx
	leaq	120(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 168
	popq	%rdx
	.cfi_def_cfa_offset 160
.L2:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L4
	call	__stack_chk_fail@PLT
.L4:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2052:
	.size	_Z33__device_stub__Z9matrixMulPfS_S_iPfS_S_i, .-_Z33__device_stub__Z9matrixMulPfS_S_iPfS_S_i
	.globl	_Z9matrixMulPfS_S_i
	.type	_Z9matrixMulPfS_S_i, @function
_Z9matrixMulPfS_S_i:
.LFB2053:
	.cfi_startproc
	endbr64
	jmp	_Z33__device_stub__Z9matrixMulPfS_S_iPfS_S_i
	.cfi_endproc
.LFE2053:
	.size	_Z9matrixMulPfS_S_i, .-_Z9matrixMulPfS_S_i
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"Taille matrice non multiple de taille bloc X %d \n"
.LC2:
	.string	"bloc %d %d \n"
.LC3:
	.string	"grille %d %d \n"
.LC4:
	.string	"Erreur appel kernel %d \n"
.LC6:
	.string	"Temps consomme: %f secondes\n"
.LC7:
	.string	"Erreur i: %d j: %d %f\n"
.LC8:
	.string	"Erreur i: %d j: %d\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
	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	$104, %rsp
	.cfi_def_cfa_offset 160
	movq	%fs:40, %rax
	movq	%rax, 88(%rsp)
	xorl	%eax, %eax
	decl	%edi
	jle	.L25
	movq	8(%rsi), %rdi
	call	atoi@PLT
	movl	%eax, %ebx
	testb	$15, %al
	je	.L9
	movl	$16, %edx
	leaq	.LC0(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L37
.L25:
	movl	$2048, %ebx
.L9:
	movl	%ebx, %eax
	imull	%ebx, %eax
	leal	0(,%rax,4), %eax
	movq	%rax, %rdi
	movq	%rax, 8(%rsp)
	call	malloc@PLT
	movq	8(%rsp), %rdi
	movq	%rax, %r14
	call	malloc@PLT
	movq	8(%rsp), %rdi
	movq	%rax, %r13
	call	malloc@PLT
	movslq	%ebx, %r9
	xorl	%r8d, %r8d
	xorl	%esi, %esi
	movq	%rax, %r12
	movss	.LC1(%rip), %xmm0
	leal	-1(%rbx), %eax
	salq	$2, %r9
	movq	%rax, %r15
	leaq	4(,%rax,4), %r10
	xorl	%eax, %eax
.L10:
	cmpl	%ebx, %esi
	jge	.L38
	movq	%r8, %rdx
	xorl	%ecx, %ecx
	leal	1(%rsi), %edi
.L12:
	movss	%xmm0, (%r14,%rdx)
	movss	%xmm0, 0(%r13,%rdx)
	cmpl	%ecx, %esi
	je	.L11
.L14:
	incl	%ecx
	addq	$4, %rdx
	cmpl	%ecx, %ebx
	jne	.L12
	leaq	(%r12,%r8), %rdx
	movq	%r10, %rcx
	incl	%esi
	addq	%r9, %r8
	movq	%rdx, %rdi
	rep stosb
	jmp	.L10
.L11:
	cvtsi2ssl	%edi, %xmm1
	movss	%xmm1, (%r14,%rdx)
	movss	%xmm1, 0(%r13,%rdx)
	jmp	.L14
.L38:
	movq	8(%rsp), %rsi
	leaq	24(%rsp), %rdi
	movl	%ebx, %ebp
	shrl	$4, %ebp
	call	cudaMalloc@PLT
	movq	8(%rsp), %rsi
	leaq	32(%rsp), %rdi
	call	cudaMalloc@PLT
	movq	8(%rsp), %rsi
	leaq	40(%rsp), %rdi
	call	cudaMalloc@PLT
	leaq	48(%rsp), %rdi
	call	cudaEventCreate@PLT
	leaq	56(%rsp), %rdi
	call	cudaEventCreate@PLT
	movq	48(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	8(%rsp), %rdx
	movq	24(%rsp), %rdi
	movq	%r14, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movq	8(%rsp), %rdx
	movq	32(%rsp), %rdi
	movq	%r13, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movl	$16, %ecx
	xorl	%eax, %eax
	movl	%ebp, 76(%rsp)
	movl	$16, %edx
	leaq	.LC2(%rip), %rsi
	movl	%ebp, 80(%rsp)
	movl	$2, %edi
	movl	$1, 84(%rsp)
	call	__printf_chk@PLT
	movl	%ebp, %ecx
	movl	%ebp, %edx
	leaq	.LC3(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	76(%rsp), %rdi
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	84(%rsp), %esi
	movl	$1, %ecx
	movabsq	$68719476752, %rdx
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L15
	movq	32(%rsp), %rdx
	movq	24(%rsp), %rsi
	movl	%ebx, %ecx
	movq	40(%rsp), %rdi
	call	_Z33__device_stub__Z9matrixMulPfS_S_iPfS_S_i
.L15:
	call	cudaGetLastError@PLT
	movl	%eax, %ebp
	testl	%eax, %eax
	je	.L16
	movl	%eax, %edx
	movl	$2, %edi
	leaq	.LC4(%rip), %rsi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	%ebp, %edi
.L36:
	call	exit@PLT
.L16:
	movq	8(%rsp), %rdx
	movq	40(%rsp), %rsi
	movl	$2, %ecx
	movq	%r12, %rdi
	call	cudaMemcpy@PLT
	movq	56(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	56(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movq	56(%rsp), %rdx
	movq	48(%rsp), %rsi
	leaq	20(%rsp), %rdi
	call	cudaEventElapsedTime@PLT
	movq	48(%rsp), %rdi
	call	cudaEventDestroy@PLT
	movq	56(%rsp), %rdi
	call	cudaEventDestroy@PLT
	leaq	.LC6(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	cvtss2sd	20(%rsp), %xmm0
	divsd	.LC5(%rip), %xmm0
	call	__printf_chk@PLT
	xorl	%edx, %edx
	jmp	.L17
.L40:
	jne	.L27
.L19:
	incl	%ecx
	addq	$4, %rsi
	cmpl	%ecx, %ebx
	jne	.L22
	movl	%eax, %edx
	addl	%ebx, %ebp
.L17:
	cmpl	%ebx, %edx
	jge	.L39
	leal	1(%rdx), %eax
	movslq	%ebp, %rcx
	leal	(%rdx,%rbx), %r8d
	movl	%eax, %edi
	leaq	(%r12,%rcx,4), %rsi
	xorl	%ecx, %ecx
	imull	%eax, %edi
	addl	%r15d, %edi
.L22:
	movss	(%rsi), %xmm0
	cmpl	%edx, %ecx
	jne	.L18
	cvtsi2ssl	%edi, %xmm1
	ucomiss	%xmm0, %xmm1
	jnp	.L40
.L27:
	leaq	.LC7(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	cvtss2sd	%xmm0, %xmm0
	call	__printf_chk@PLT
.L37:
	movl	$1, %edi
	jmp	.L36
.L18:
	leal	(%r8,%rcx), %r9d
	cvtsi2ssl	%r9d, %xmm1
	ucomiss	%xmm0, %xmm1
	jp	.L28
	je	.L19
.L28:
	leaq	.LC8(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L37
.L39:
	movq	%r14, %rdi
	call	free@PLT
	movq	%r13, %rdi
	call	free@PLT
	movq	%r12, %rdi
	call	free@PLT
	movq	24(%rsp), %rdi
	call	cudaFree@PLT
	movq	32(%rsp), %rdi
	call	cudaFree@PLT
	movq	40(%rsp), %rdi
	call	cudaFree@PLT
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	je	.L24
	call	__stack_chk_fail@PLT
.L24:
	addq	$104, %rsp
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2027:
	.size	main, .-main
	.section	.rodata.str1.1
.LC9:
	.string	"_Z9matrixMulPfS_S_i"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2055:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	pushq	$0
	.cfi_def_cfa_offset 24
	xorl	%r9d, %r9d
	orl	$-1, %r8d
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC9(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z9matrixMulPfS_S_i(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 48
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFunction@PLT
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rdx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.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
	.section	.rodata.cst4,"aM",@progbits,4
	.align 4
.LC1:
	.long	1065353216
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC5:
	.long	0
	.long	1083129856
	.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 <hip/hip_runtime.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
 

#define TILE_SIZE 16



// CUDA Kernel
__global__ void matrixMul( float* C, float* A, float* B, int TM)
{
  __shared__ float As [TILE_SIZE][TILE_SIZE];
  __shared__ float Bs [TILE_SIZE][TILE_SIZE];

    // chaque thread calcule C[i][j]
    // Coordonnees absolues du thread : indices i j
    int j = blockIdx.x * blockDim.x+ threadIdx.x;
    int i = blockIdx.y * blockDim.y+ threadIdx.y;
    int tx = threadIdx.x;
    int ty = threadIdx.y;
 
    float value = 0;

    for(int ke=0; ke<TM; ke += TILE_SIZE) {
      // Remplissage de As et de Bs
      As[ty][tx] = A[i * TM + ke + tx];
      Bs[ty][tx] = B[(ke + ty) * TM + j];

      __syncthreads();

      // Calcul
      for (int k = 0; k < TILE_SIZE; k++) {
        value += As[ty][k] * Bs[k][tx];
      }

      __syncthreads();
    }

   C[i * TM + j] = value;
}
  
/////////////////////////////////////////////////////////
// Program main
/////////////////////////////////////////////////////////
 
int main(int argc, char** argv) {
  int i, j, TM, BLOCK_SIZE_X, BLOCK_SIZE_Y;
  unsigned int M_size;
  float *h_A, *h_B, *h_C;
  float *d_A, *d_B, *d_C;
  hipError_t cerror;
  float  elapsedTime ;
  hipEvent_t start , stop ;

  // Valeurs par defaut
  TM=2048;
  BLOCK_SIZE_X = TILE_SIZE;
  BLOCK_SIZE_Y = TILE_SIZE;

  // Possibilite de lire TM dans arg1, BLOCK_SIZE_X dans arg2 et BLOCK_SIZE_Y ans arg3
  if (argc>1) {
    TM=atoi(argv[1]);
  }
  // if (argc>3) {
  //   BLOCK_SIZE_X =atoi(argv[2]);
  //   BLOCK_SIZE_Y =atoi(argv[3]);
  // }
  
  // Verification de la bonne taille TM par rapport aux dimensions des blocs
  if ((TM % BLOCK_SIZE_X) !=0) {
    printf("Taille matrice non multiple de taille bloc X %d \n", BLOCK_SIZE_X);
    exit(1);
  }
  if ((TM % BLOCK_SIZE_Y) !=0) {
    printf("Taille matrice non multiple de taille bloc Y %d \n", BLOCK_SIZE_Y);
    exit(1);
  }
  
  // Allocation memoire sur CPU
  M_size = TM*TM*sizeof(float);
  h_A = (float*) malloc(M_size);
  h_B = (float*) malloc(M_size);
  h_C = (float*) malloc(M_size);
  
  // initialisation des matrices avec des valeurs permettant de verifier le resultat
  for(i = 0; i < TM; i++){
      for(j = 0; j < TM; j++){
      	h_A[i*TM+j] = 1.0;
      	h_B[i*TM+j] = 1.0;
	      h_C[i*TM+j] = 0.0;

      	if (i==j) {
      		h_A[i*TM+j]=(float) (i+1);
      		h_B[i*TM+j]=(float) (i+1);
      	}
      }
  }
  
  // Allocation memoire sur GPU
  hipMalloc((void**) &d_A, M_size);
  hipMalloc((void**) &d_B, M_size);
  hipMalloc((void**) &d_C, M_size);
  
  // Calcul du temps : top depart
  hipEventCreate (&start ) ;
  hipEventCreate (&stop ) ;
  hipEventRecord ( start , 0 ) ;
  
  // copie des donnes CPU vers GPU
  hipMemcpy(d_A, h_A, M_size, hipMemcpyHostToDevice);
  hipMemcpy(d_B, h_B, M_size, hipMemcpyHostToDevice);
  
  // choix de la structure : grille et blocs
  dim3 threads(BLOCK_SIZE_X, BLOCK_SIZE_Y);
  dim3 grid(TM / threads.x, TM / threads.y);
 
   printf("bloc %d %d \n", BLOCK_SIZE_X, BLOCK_SIZE_Y);
   printf("grille %d %d \n", TM / threads.x, TM / threads.y);
   
   // Lancement des threads
   matrixMul<<< grid, threads >>>(d_C, d_A, d_B, TM);

   // En cas d'erreur
   cerror=hipGetLastError(); 
   if ((int)cerror !=0) { 
     printf("Erreur appel kernel %d \n", (int) cerror);
     exit(cerror);
   }
 
   // copie des resultats depuis le GPU
   hipMemcpy(h_C, d_C, M_size, hipMemcpyDeviceToHost);
   
   // Calcul du temps d'execution
   hipEventRecord ( stop , 0 ) ;
   hipEventSynchronize ( stop ) ;
   hipEventElapsedTime ( &elapsedTime , start , stop ) ;
   hipEventDestroy ( start ) ;
   hipEventDestroy ( stop ) ;
   printf ( "Temps consomme: %f secondes\n" , elapsedTime / 1000.0 ) ;

  // Verification des resultats

   for(i = 0; i < TM; i++){
     for(j = 0; j < TM; j++){
      	if ((i==j) && (h_C[i*TM+j] != (float)((i+1)*(i+1)+TM-1))) {
      		printf("Erreur i: %d j: %d %f\n", i, j, h_C[i*TM+j] ); exit(1);
      	}
      	else if ((i!=j) && (h_C[i*TM+j] != (float)(i+j+TM))){
      		printf("Erreur i: %d j: %d\n", i, j);
      		exit(1);
      	}
     }
   } 

   // liberation de la memoire
   free(h_A);
   free(h_B);
   free(h_C);
   hipFree(d_A);
   hipFree(d_B);
   hipFree(d_C);
}

	.text
	.file	"mul_matG2B2_et_2.hip"
	.globl	_Z24__device_stub__matrixMulPfS_S_i # -- Begin function _Z24__device_stub__matrixMulPfS_S_i
	.type	_Z24__device_stub__matrixMulPfS_S_i,@function
_Z24__device_stub__matrixMulPfS_S_i:    # @_Z24__device_stub__matrixMulPfS_S_i
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$112, %rsp
	.cfi_def_cfa_offset 160
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	32(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	24(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	4(%rsp), %rdx
	movl	%ecx, (%rdx)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	16(%rsp), %r12
	leaq	8(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z9matrixMulPfS_S_i, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$128, %rsp
	.cfi_adjust_cfa_offset -128
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	_Z24__device_stub__matrixMulPfS_S_i, .Lfunc_end0-_Z24__device_stub__matrixMulPfS_S_i
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI1_0:
	.quad	0x408f400000000000              # double 1000
	.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	$120, %rsp
	.cfi_def_cfa_offset 176
	.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	$2048, %ebx                     # imm = 0x800
	cmpl	$2, %edi
	jl	.LBB1_2
# %bb.1:
	movq	8(%rsi), %rdi
	callq	atoi
	movl	%eax, %ebx
	testb	$15, %bl
	jne	.LBB1_24
.LBB1_2:                                # %.thread
	movl	%ebx, %r14d
	imull	%r14d, %r14d
	shll	$2, %r14d
	movq	%r14, %rdi
	callq	malloc
	movq	%rax, 24(%rsp)                  # 8-byte Spill
	movq	%r14, %rdi
	callq	malloc
	movq	%rax, 16(%rsp)                  # 8-byte Spill
	movq	%r14, 80(%rsp)                  # 8-byte Spill
	movq	%r14, %rdi
	callq	malloc
	movq	%rax, 48(%rsp)                  # 8-byte Spill
	movl	%ebx, %r14d
	testl	%ebx, %ebx
	movq	%rbx, %rdx
	jle	.LBB1_9
# %bb.3:                                # %.preheader124.lr.ph
	leaq	(,%r14,4), %rax
	movq	%rax, 88(%rsp)                  # 8-byte Spill
	xorl	%r13d, %r13d
	movl	$1065353216, %r15d              # imm = 0x3F800000
	xorl	%r12d, %r12d
	movq	%rdx, 96(%rsp)                  # 8-byte Spill
.LBB1_4:                                # %.lr.ph
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_5 Depth 2
	movl	%r13d, %eax
	movq	16(%rsp), %rcx                  # 8-byte Reload
	leaq	(%rcx,%rax,4), %rbx
	movq	24(%rsp), %rcx                  # 8-byte Reload
	leaq	(%rcx,%rax,4), %rbp
	movl	%edx, %eax
	imull	%r12d, %eax
	movq	48(%rsp), %rcx                  # 8-byte Reload
	leaq	(%rcx,%rax,4), %rdi
	leaq	1(%r12), %rax
	movq	%rax, 104(%rsp)                 # 8-byte Spill
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	movss	%xmm0, 44(%rsp)                 # 4-byte Spill
	xorl	%esi, %esi
	movq	88(%rsp), %rdx                  # 8-byte Reload
	callq	memset@PLT
	xorl	%eax, %eax
.LBB1_5:                                #   Parent Loop BB1_4 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	%r15d, (%rbp,%rax,4)
	movl	%r15d, (%rbx,%rax,4)
	cmpq	%rax, %r12
	jne	.LBB1_7
# %bb.6:                                #   in Loop: Header=BB1_5 Depth=2
	movss	44(%rsp), %xmm0                 # 4-byte Reload
                                        # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, (%rbp,%rax,4)
	movss	%xmm0, (%rbx,%rax,4)
.LBB1_7:                                #   in Loop: Header=BB1_5 Depth=2
	incq	%rax
	cmpq	%rax, %r14
	jne	.LBB1_5
# %bb.8:                                # %._crit_edge
                                        #   in Loop: Header=BB1_4 Depth=1
	movq	96(%rsp), %rdx                  # 8-byte Reload
	addl	%edx, %r13d
	movq	104(%rsp), %rax                 # 8-byte Reload
	movq	%rax, %r12
	cmpq	%r14, %rax
	jne	.LBB1_4
.LBB1_9:                                # %._crit_edge131
	leaq	72(%rsp), %r13
	movq	%r13, %rdi
	movq	80(%rsp), %rbx                  # 8-byte Reload
	movq	%rbx, %rsi
	movq	%rdx, %r15
	callq	hipMalloc
	leaq	64(%rsp), %r12
	movq	%r12, %rdi
	movq	%rbx, %rsi
	callq	hipMalloc
	leaq	32(%rsp), %rdi
	movq	%rbx, %rsi
	callq	hipMalloc
	leaq	56(%rsp), %rbp
	movq	%rbp, %rdi
	callq	hipEventCreate
	leaq	8(%rsp), %rdi
	callq	hipEventCreate
	movq	(%rbp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	(%r13), %rdi
	movq	24(%rsp), %rsi                  # 8-byte Reload
	movq	%rbx, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	(%r12), %rdi
	movq	16(%rsp), %rsi                  # 8-byte Reload
	movq	%rbx, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movl	%r15d, %ebp
	shrl	$4, %ebp
	movq	%rbp, %r13
	shlq	$32, %r13
	orq	%rbp, %r13
	movl	$.L.str.2, %edi
	movl	$16, %esi
	movl	$16, %edx
	xorl	%eax, %eax
	callq	printf
	movl	$.L.str.3, %edi
	movl	%ebp, %esi
	movl	%ebp, %edx
	xorl	%eax, %eax
	callq	printf
	movabsq	$68719476752, %rdx              # imm = 0x1000000010
	movq	%r13, %rdi
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB1_11
# %bb.10:
	movq	32(%rsp), %rdi
	movq	72(%rsp), %rsi
	movq	64(%rsp), %rdx
	movl	%r15d, %ecx
	callq	_Z24__device_stub__matrixMulPfS_S_i
.LBB1_11:
	callq	hipGetLastError
	testl	%eax, %eax
	movq	48(%rsp), %r12                  # 8-byte Reload
	jne	.LBB1_23
# %bb.12:
	movq	32(%rsp), %rsi
	movq	%r12, %rdi
	movq	%rbx, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	movq	8(%rsp), %rdi
	xorl	%ebp, %ebp
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	8(%rsp), %rdi
	callq	hipEventSynchronize
	movq	56(%rsp), %rsi
	movq	8(%rsp), %rdx
	leaq	116(%rsp), %r13
	movq	%r13, %rdi
	callq	hipEventElapsedTime
	movq	56(%rsp), %rdi
	callq	hipEventDestroy
	movq	8(%rsp), %rdi
	callq	hipEventDestroy
	cvtss2sd	(%r13), %xmm0
	divsd	.LCPI1_0(%rip), %xmm0
	movl	$.L.str.5, %edi
	movb	$1, %al
	callq	printf
	testl	%r15d, %r15d
	jle	.LBB1_20
# %bb.13:                               # %.preheader.lr.ph
	leal	-1(%r15), %eax
	movq	%r14, %rcx
	xorl	%edi, %edi
	xorl	%esi, %esi
.LBB1_14:                               # %.lr.ph133
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_15 Depth 2
	movl	%ebp, %edx
	leaq	(%r12,%rdx,4), %r9
	leaq	1(%rsi), %r8
	movl	%r8d, %edx
	imull	%r8d, %edx
	addl	%eax, %edx
	xorps	%xmm0, %xmm0
	cvtsi2ss	%edx, %xmm0
	movl	%r15d, %r10d
	imull	%esi, %r10d
	leaq	(%r12,%rsi,4), %r11
	xorl	%edx, %edx
.LBB1_15:                               #   Parent Loop BB1_14 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movq	%rdi, %rbx
	addq	%rdx, %rbx
	je	.LBB1_17
# %bb.16:                               #   in Loop: Header=BB1_15 Depth=2
	leal	(%rcx,%rdx), %ebx
	xorps	%xmm1, %xmm1
	cvtsi2ss	%ebx, %xmm1
	movss	(%r9,%rdx,4), %xmm2             # xmm2 = mem[0],zero,zero,zero
	ucomiss	%xmm1, %xmm2
	jne	.LBB1_21
	jnp	.LBB1_18
	jmp	.LBB1_21
.LBB1_17:                               #   in Loop: Header=BB1_15 Depth=2
	movss	(%r11,%r10,4), %xmm1            # xmm1 = mem[0],zero,zero,zero
	ucomiss	%xmm0, %xmm1
	jne	.LBB1_22
	jp	.LBB1_22
.LBB1_18:                               # %.thread123
                                        #   in Loop: Header=BB1_15 Depth=2
	incq	%rdx
	cmpq	%rdx, %r14
	jne	.LBB1_15
# %bb.19:                               # %._crit_edge134
                                        #   in Loop: Header=BB1_14 Depth=1
	addl	%r15d, %ebp
	decq	%rdi
	incq	%rcx
	movq	%r8, %rsi
	cmpq	%r14, %r8
	jne	.LBB1_14
.LBB1_20:                               # %._crit_edge136
	movq	24(%rsp), %rdi                  # 8-byte Reload
	callq	free
	movq	16(%rsp), %rdi                  # 8-byte Reload
	callq	free
	movq	%r12, %rdi
	callq	free
	movq	72(%rsp), %rdi
	callq	hipFree
	movq	64(%rsp), %rdi
	callq	hipFree
	movq	32(%rsp), %rdi
	callq	hipFree
	xorl	%eax, %eax
	addq	$120, %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
.LBB1_21:
	.cfi_def_cfa_offset 176
	movl	$.L.str.7, %edi
                                        # kill: def $esi killed $esi killed $rsi
                                        # kill: def $edx killed $edx killed $rdx
	xorl	%eax, %eax
	callq	printf
	jmp	.LBB1_25
.LBB1_22:
	xorps	%xmm0, %xmm0
	cvtss2sd	%xmm1, %xmm0
	movl	$.L.str.6, %edi
	movl	%esi, %edx
	movb	$1, %al
	callq	printf
.LBB1_25:
	movl	$1, %edi
	callq	exit
.LBB1_23:
	movl	%eax, %ebp
	movl	$.L.str.4, %edi
	movl	%eax, %esi
	xorl	%eax, %eax
	callq	printf
	movl	%ebp, %edi
	callq	exit
.LBB1_24:
	movl	$.L.str, %edi
	movl	$16, %esi
	xorl	%eax, %eax
	callq	printf
	jmp	.LBB1_25
.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:
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	jne	.LBB2_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB2_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z9matrixMulPfS_S_i, %esi
	movl	$.L__unnamed_1, %edx
	movl	$.L__unnamed_1, %ecx
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$__hip_module_dtor, %edi
	addq	$40, %rsp
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_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	_Z9matrixMulPfS_S_i,@object     # @_Z9matrixMulPfS_S_i
	.section	.rodata,"a",@progbits
	.globl	_Z9matrixMulPfS_S_i
	.p2align	3, 0x0
_Z9matrixMulPfS_S_i:
	.quad	_Z24__device_stub__matrixMulPfS_S_i
	.size	_Z9matrixMulPfS_S_i, 8

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"Taille matrice non multiple de taille bloc X %d \n"
	.size	.L.str, 50

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"bloc %d %d \n"
	.size	.L.str.2, 13

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"grille %d %d \n"
	.size	.L.str.3, 15

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"Erreur appel kernel %d \n"
	.size	.L.str.4, 25

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"Temps consomme: %f secondes\n"
	.size	.L.str.5, 29

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"Erreur i: %d j: %d %f\n"
	.size	.L.str.6, 23

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"Erreur i: %d j: %d\n"
	.size	.L.str.7, 20

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z9matrixMulPfS_S_i"
	.size	.L__unnamed_1, 20

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

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

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

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z9matrixMulPfS_S_i     ; -- Begin function _Z9matrixMulPfS_S_i
	.globl	_Z9matrixMulPfS_S_i
	.p2align	8
	.type	_Z9matrixMulPfS_S_i,@function
_Z9matrixMulPfS_S_i:                    ; @_Z9matrixMulPfS_S_i
; %bb.0:
	s_clause 0x1
	s_load_b32 s3, s[0:1], 0x2c
	s_load_b32 s2, s[0:1], 0x18
	v_bfe_u32 v2, v0, 10, 10
	s_clause 0x1
	s_load_b128 s[4:7], s[0:1], 0x0
	s_load_b64 s[0:1], s[0:1], 0x10
	s_waitcnt lgkmcnt(0)
	s_lshr_b32 s8, s3, 16
	s_and_b32 s3, s3, 0xffff
	v_mad_u64_u32 v[4:5], null, s15, s8, v[2:3]
	v_and_b32_e32 v3, 0x3ff, v0
	s_cmp_lt_i32 s2, 1
	s_delay_alu instid0(VALU_DEP_1)
	v_mad_u64_u32 v[0:1], null, s14, s3, v[3:4]
	v_mul_lo_u32 v1, v4, s2
	s_cbranch_scc1 .LBB0_5
; %bb.1:                                ; %.lr.ph
	v_lshlrev_b32_e32 v7, 2, v3
	v_lshlrev_b32_e32 v4, 6, v2
	s_delay_alu instid0(VALU_DEP_3) | instskip(SKIP_1) | instid1(VALU_DEP_3)
	v_dual_mov_b32 v3, 0 :: v_dual_add_nc_u32 v6, v1, v3
	s_mov_b32 s3, 0
	v_add_nc_u32_e32 v5, 0x400, v7
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_nc_u32_e32 v7, v4, v7
	v_add_nc_u32_e32 v8, v5, v4
.LBB0_2:                                ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB0_3 Depth 2
	v_add_nc_u32_e32 v10, s3, v2
	v_add_nc_u32_e32 v9, s3, v6
	s_mov_b32 s8, 0
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_mad_u64_u32 v[11:12], null, v10, s2, v[0:1]
	v_ashrrev_i32_e32 v10, 31, v9
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_lshlrev_b64 v[9:10], 2, v[9:10]
	v_ashrrev_i32_e32 v12, 31, v11
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v9, vcc_lo, s6, v9
	v_lshlrev_b64 v[11:12], 2, v[11:12]
	s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_ci_u32_e32 v10, vcc_lo, s7, v10, vcc_lo
	v_add_co_u32 v11, vcc_lo, s0, v11
	s_delay_alu instid0(VALU_DEP_3)
	v_add_co_ci_u32_e32 v12, vcc_lo, s1, v12, vcc_lo
	global_load_b32 v10, v[9:10], off
	global_load_b32 v11, v[11:12], off
	v_mov_b32_e32 v9, v5
	s_waitcnt vmcnt(1)
	ds_store_b32 v7, v10
	s_waitcnt vmcnt(0)
	ds_store_b32 v8, v11
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
.LBB0_3:                                ;   Parent Loop BB0_2 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	v_add_nc_u32_e32 v10, s8, v4
	s_add_i32 s8, s8, 4
	ds_load_b32 v11, v9
	ds_load_b32 v10, v10
	v_add_nc_u32_e32 v9, 64, v9
	s_cmp_eq_u32 s8, 64
	s_waitcnt lgkmcnt(0)
	v_fmac_f32_e32 v3, v10, v11
	s_cbranch_scc0 .LBB0_3
; %bb.4:                                ;   in Loop: Header=BB0_2 Depth=1
	s_add_i32 s3, s3, 16
	s_delay_alu instid0(SALU_CYCLE_1)
	s_cmp_ge_i32 s3, s2
	s_barrier
	buffer_gl0_inv
	s_cbranch_scc0 .LBB0_2
	s_branch .LBB0_6
.LBB0_5:
	v_mov_b32_e32 v3, 0
.LBB0_6:                                ; %Flow56
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_nc_u32_e32 v0, v1, v0
	v_ashrrev_i32_e32 v1, 31, v0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[0:1], 2, v[0:1]
	v_add_co_u32 v0, vcc_lo, s4, v0
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v1, vcc_lo, s5, v1, vcc_lo
	global_store_b32 v[0:1], v3, off
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z9matrixMulPfS_S_i
		.amdhsa_group_segment_fixed_size 2048
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 288
		.amdhsa_user_sgpr_count 14
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 1
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 1
		.amdhsa_next_free_vgpr 13
		.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	_Z9matrixMulPfS_S_i, .Lfunc_end0-_Z9matrixMulPfS_S_i
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 440
; NumSgprs: 18
; NumVgprs: 13
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 2048 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 13
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 14
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 1
	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __hip_cuid_
	.amdgpu_metadata
---
amdhsa.kernels:
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         16
        .size:           8
        .value_kind:     global_buffer
      - .offset:         24
        .size:           4
        .value_kind:     by_value
      - .offset:         32
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         36
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         40
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         44
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         46
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         48
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         50
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         52
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         54
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         88
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         96
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 2048
    .kernarg_segment_align: 8
    .kernarg_segment_size: 288
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z9matrixMulPfS_S_i
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z9matrixMulPfS_S_i.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     13
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
