#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <sys/time.h>

#define NUMTHREADSPERBLOCK 16

/*** function declarations ***/

void PRINT_MAT(int P, int M, double * matr);

// save matrix to file
void save_gnuplot( double *M, size_t dim );

// evolve Jacobi
__global__  void evolve( double * matrix, double *matrix_new, int dimension );


// return the elapsed time
double seconds( void );

/*** end function declaration ***/




int main(int argc, char* argv[]){

  // timing variables
  double t_start, t_end, increment;

  // indexes for loops
  size_t i, j, it;

  // initialize matrix

  double *matrix, *matrix_new, *tmp_matrix;
  double *d_matrix, *d_matrix_new;
  int dimension = 0, iterations = 0, row_peek = 0, col_peek = 0;
  size_t byte_dimension = 0;

 // check on input parameters

  if(argc != 5) {
    fprintf(stderr,"\nwrong number of arguments. Usage: ./a.out dim it n m\n");
    return 1;
  }

  dimension = atoi(argv[1]);
  iterations = atoi(argv[2]);
  row_peek = atoi(argv[3]);
  col_peek = atoi(argv[4]);

  printf("matrix size = %zu\n", dimension);
  printf("number of iterations = %zu\n", iterations);
  printf("element for checking = Mat[%zu,%zu]\n",row_peek, col_peek);


  if((row_peek > dimension) || (col_peek > dimension)){
    fprintf(stderr, "Cannot Peek a matrix element outside of the matrix dimension\n");
    fprintf(stderr, "Arguments n and m must be smaller than %zu\n", dimension);
    return 1;
  }


  byte_dimension = sizeof(double*) * ( dimension + 2 ) * ( dimension + 2 );
  matrix = ( double* )malloc( byte_dimension );
  matrix_new = ( double* )malloc( byte_dimension );

  memset( matrix, 0, byte_dimension );
  memset( matrix_new, 0, byte_dimension );

  cudaMalloc((void**) &d_matrix, byte_dimension ); //allocating space for d_matrix
  cudaMalloc((void**) &d_matrix_new, byte_dimension );

  //fill initial values  

  for( i = 1; i <= dimension; ++i ){
    for( j = 1; j <= dimension; ++j ){
      matrix[ ( i * ( dimension + 2 ) ) + j ] = 0.5;
    }
  }
	     
  // set up borders 
  increment = 100.0 / ( dimension + 1 );

  
 for( i=1; i <= dimension+1; ++i ){
    matrix[ i * ( dimension + 2 ) ] = i * increment;
    matrix[ ( ( dimension + 1 ) * ( dimension + 2 ) ) + ( dimension + 1 - i ) ] = i * increment;
    matrix_new[ i * ( dimension + 2 ) ] = i * increment;
    matrix_new[ ( ( dimension + 1 ) * ( dimension + 2 ) ) + ( dimension + 1 - i ) ] = i * increment;
  }

  //printf("initial matrix\n");
  //PRINT_MAT(dimension+2,dimension+2,matrix);

  // start algorithm
  t_start = seconds();

  cudaMemcpy( d_matrix, matrix, byte_dimension, cudaMemcpyHostToDevice );
  cudaMemcpy( d_matrix_new, matrix_new, byte_dimension, cudaMemcpyHostToDevice );

  dim3 gridDim( (dimension+NUMTHREADSPERBLOCK)/NUMTHREADSPERBLOCK, (dimension+NUMTHREADSPERBLOCK)/NUMTHREADSPERBLOCK );
  dim3 blockDim(NUMTHREADSPERBLOCK , NUMTHREADSPERBLOCK);

  for( it = 0; it < iterations; ++it ){
  
  evolve<<< gridDim, blockDim  >>>( d_matrix, d_matrix_new, dimension );
    //evolve<<< (dimension+NUMTHREADSPERBLOCK)/NUMTHREADSPERBLOCK , NUMTHREADSPERBLOCK >>>( d_matrix, d_matrix_new, dimension );

    // swap the pointers
    tmp_matrix = d_matrix;
    d_matrix = d_matrix_new;
    d_matrix_new = tmp_matrix;
 }

  cudaMemcpy( matrix, d_matrix, byte_dimension, cudaMemcpyDeviceToHost );
  t_end = seconds();

  //printf("final matrix\n");
  //PRINT_MAT(dimension+2,dimension+2,matrix);

  printf( "\nelapsed time = %f seconds\n", t_end - t_start );
  printf( "\nmatrix[%zu,%zu] = %f\n", row_peek, col_peek, matrix[ ( row_peek + 1 ) * ( dimension + 2 ) + ( col_peek + 1 ) ] );

  save_gnuplot( matrix, dimension );
  

  free( matrix );
  free( matrix_new );
  cudaFree(d_matrix);
  cudaFree(d_matrix_new);


  return 0;

}

void PRINT_MAT(int P, int M, double * matr){
  for(int j = 0; j < P; j++ ){
    for(int i = 0; i < M; i++ ){
      printf("%0.1f ",matr[i+j*M]);
    }
    printf("\n");
  }
}

__global__ void evolve( double * matrix, double * matrix_new, int dimension ){

  int idx = threadIdx.x + (blockIdx.x * blockDim.x);
  int idy = threadIdx.y + (blockIdx.y * blockDim.y); 
  
  
  if (idx>0 && idx<=dimension){
    if(idy>0 && idy<=dimension){
      matrix_new[ ( idx * ( dimension + 2 ) ) + idy ] = ( 0.25 ) * 
	( matrix[ ( ( idx - 1 ) * ( dimension + 2 ) ) + idy ] + 
	  matrix[ ( idx * ( dimension + 2 ) ) + ( idy + 1 ) ] + 	  
	  matrix[ ( ( idx + 1 ) * ( dimension + 2 ) ) + idy ] + 
	  matrix[ ( idx * ( dimension + 2 ) ) + ( idy - 1 ) ] ); 
    }
  }
}

void save_gnuplot( double *M, size_t dimension ){  

  size_t i , j;

  const double h = 0.1;

  FILE *file;

  file = fopen( "solution.dat", "w" );

  for( i = 0; i < dimension + 2; ++i )

    for( j = 0; j < dimension + 2; ++j )

      fprintf(file, "%f\t%f\t%f\n", h * j, -h * i, M[ ( i * ( dimension + 2 ) ) + j ] );

  fclose( file );

}



// A Simple timer for measuring the walltime

double seconds(){

    struct timeval tmp;
    double sec;
    gettimeofday( &tmp, (struct timezone *)0 );
    sec = tmp.tv_sec + ((double)tmp.tv_usec)/1000000.0;
    return sec;

}

	.file	"tmpxft_0021181e_00000000-6_jacobi_notshared.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
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%0.1f "
.LC1:
	.string	"\n"
	.text
	.globl	_Z9PRINT_MATiiPd
	.type	_Z9PRINT_MATiiPd, @function
_Z9PRINT_MATiiPd:
.LFB2028:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movl	%edi, %r14d
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	xorl	%r13d, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	xorl	%r12d, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%rdx, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movl	%esi, %ebx
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
.L3:
	cmpl	%r14d, %r13d
	jge	.L2
	movslq	%r12d, %rax
	xorl	%r15d, %r15d
	leaq	0(%rbp,%rax,8), %rcx
.L6:
	cmpl	%r15d, %ebx
	jle	.L9
	movsd	(%rcx,%r15,8), %xmm0
	leaq	.LC0(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	movq	%rcx, 8(%rsp)
	incq	%r15
	call	__printf_chk@PLT
	movq	8(%rsp), %rcx
	jmp	.L6
.L9:
	leaq	.LC1(%rip), %rsi
	xorl	%eax, %eax
	incl	%r13d
	addl	%ebx, %r12d
	movl	$2, %edi
	call	__printf_chk@PLT
	jmp	.L3
.L2:
	addq	$24, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2028:
	.size	_Z9PRINT_MATiiPd, .-_Z9PRINT_MATiiPd
	.section	.rodata.str1.1
.LC2:
	.string	"w"
.LC3:
	.string	"solution.dat"
.LC6:
	.string	"%f\t%f\t%f\n"
	.text
	.globl	_Z12save_gnuplotPdm
	.type	_Z12save_gnuplotPdm, @function
_Z12save_gnuplotPdm:
.LFB2029:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	xorl	%r15d, %r15d
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	xorl	%r14d, %r14d
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%rdi, %r13
	leaq	.LC3(%rip), %rdi
	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
	movq	%rsi, %rbx
	leaq	.LC2(%rip), %rsi
	addq	$2, %rbx
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	call	fopen@PLT
	movq	%rax, %rdi
.L11:
	cmpq	%rbx, %r14
	jnb	.L18
	testq	%r14, %r14
	js	.L12
	cvtsi2sdq	%r14, %xmm1
	jmp	.L13
.L12:
	movq	%r14, %rax
	movq	%r14, %rdx
	shrq	%rax
	andl	$1, %edx
	orq	%rdx, %rax
	cvtsi2sdq	%rax, %xmm1
	addsd	%xmm1, %xmm1
.L13:
	mulsd	.LC4(%rip), %xmm1
	leaq	0(%r13,%r15,8), %r12
	xorl	%ebp, %ebp
.L14:
	cvtsi2sdq	%rbp, %xmm0
	movl	$2, %esi
	movb	$3, %al
	movq	%rdi, (%rsp)
	mulsd	.LC5(%rip), %xmm0
	movsd	(%r12,%rbp,8), %xmm2
	incq	%rbp
	leaq	.LC6(%rip), %rdx
	movsd	%xmm1, 8(%rsp)
	call	__fprintf_chk@PLT
	cmpq	%rbx, %rbp
	movq	(%rsp), %rdi
	movsd	8(%rsp), %xmm1
	jb	.L14
	incq	%r14
	addq	%rbx, %r15
	jmp	.L11
.L18:
	addq	$24, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	jmp	fclose@PLT
	.cfi_endproc
.LFE2029:
	.size	_Z12save_gnuplotPdm, .-_Z12save_gnuplotPdm
	.globl	_Z7secondsv
	.type	_Z7secondsv, @function
_Z7secondsv:
.LFB2030:
	.cfi_startproc
	endbr64
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	xorl	%esi, %esi
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rdi
	call	gettimeofday@PLT
	cvtsi2sdq	8(%rsp), %xmm1
	cvtsi2sdq	16(%rsp), %xmm0
	divsd	.LC7(%rip), %xmm0
	addsd	%xmm1, %xmm0
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	je	.L20
	call	__stack_chk_fail@PLT
.L20:
	addq	$40, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2030:
	.size	_Z7secondsv, .-_Z7secondsv
	.globl	_Z28__device_stub__Z6evolvePdS_iPdS_i
	.type	_Z28__device_stub__Z6evolvePdS_iPdS_i, @function
_Z28__device_stub__Z6evolvePdS_iPdS_i:
.LFB2055:
	.cfi_startproc
	endbr64
	subq	$136, %rsp
	.cfi_def_cfa_offset 144
	movq	%rdi, 24(%rsp)
	leaq	40(%rsp), %rcx
	leaq	48(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	60(%rsp), %rsi
	movl	%edx, 12(%rsp)
	leaq	32(%rsp), %rdx
	movq	%fs:40, %rax
	movq	%rax, 120(%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	12(%rsp), %rax
	movq	%rax, 112(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 48(%rsp)
	movq	%rax, 60(%rsp)
	movl	$1, 68(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L22
	pushq	40(%rsp)
	.cfi_def_cfa_offset 152
	leaq	_Z6evolvePdS_i(%rip), %rdi
	pushq	40(%rsp)
	.cfi_def_cfa_offset 160
	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 152
	popq	%rdx
	.cfi_def_cfa_offset 144
.L22:
	movq	120(%rsp), %rax
	subq	%fs:40, %rax
	je	.L24
	call	__stack_chk_fail@PLT
.L24:
	addq	$136, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2055:
	.size	_Z28__device_stub__Z6evolvePdS_iPdS_i, .-_Z28__device_stub__Z6evolvePdS_iPdS_i
	.globl	_Z6evolvePdS_i
	.type	_Z6evolvePdS_i, @function
_Z6evolvePdS_i:
.LFB2056:
	.cfi_startproc
	endbr64
	jmp	_Z28__device_stub__Z6evolvePdS_iPdS_i
	.cfi_endproc
.LFE2056:
	.size	_Z6evolvePdS_i, .-_Z6evolvePdS_i
	.section	.rodata.str1.1
.LC8:
	.string	"\nwrong number of arguments. Usage: ./a.out dim it n m\n"
.LC9:
	.string	"matrix size = %zu\n"
.LC10:
	.string	"number of iterations = %zu\n"
.LC11:
	.string	"element for checking = Mat[%zu,%zu]\n"
.LC12:
	.string	"Cannot Peek a matrix element outside of the matrix dimension\n"
.LC13:
	.string	"Arguments n and m must be smaller than %zu\n"
.LC16:
	.string	"\nelapsed time = %f seconds\n"
.LC17:
	.string	"\nmatrix[%zu,%zu] = %f\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
	cmpl	$5, %edi
	je	.L28
	movq	stderr(%rip), %rdi
	leaq	.LC8(%rip), %rdx
	movl	$2, %esi
	call	__fprintf_chk@PLT
	jmp	.L29
.L28:
	movq	8(%rsi), %rdi
	movq	%rsi, %rbx
	call	atoi@PLT
	movq	16(%rbx), %rdi
	movl	%eax, %ebp
	call	atoi@PLT
	movq	24(%rbx), %rdi
	movl	%eax, 36(%rsp)
	call	atoi@PLT
	movq	32(%rbx), %rdi
	movl	%eax, %r12d
	call	atoi@PLT
	movl	%ebp, %edx
	movl	$2, %edi
	leaq	.LC9(%rip), %rsi
	movl	%eax, %r13d
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	36(%rsp), %edx
	movl	$2, %edi
	xorl	%eax, %eax
	leaq	.LC10(%rip), %rsi
	call	__printf_chk@PLT
	xorl	%eax, %eax
	movl	%r13d, %ecx
	movl	%r12d, %edx
	leaq	.LC11(%rip), %rsi
	movl	$2, %edi
	call	__printf_chk@PLT
	cmpl	%r13d, %r12d
	movl	%r13d, %eax
	cmovge	%r12d, %eax
	cmpl	%ebp, %eax
	jle	.L30
	movq	stderr(%rip), %rdi
	leaq	.LC12(%rip), %rdx
	movl	$2, %esi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	movq	stderr(%rip), %rdi
	movl	%ebp, %ecx
	xorl	%eax, %eax
	leaq	.LC13(%rip), %rdx
	movl	$2, %esi
	call	__fprintf_chk@PLT
.L29:
	movl	$1, %eax
	jmp	.L27
.L30:
	leal	2(%rbp), %r15d
	movslq	%r15d, %r14
	movq	%r14, %rax
	imulq	%r14, %rax
	salq	$3, %rax
	movq	%rax, %rdi
	movq	%rax, (%rsp)
	call	malloc@PLT
	movq	(%rsp), %rdi
	movq	%rax, %rbx
	call	malloc@PLT
	movq	(%rsp), %rcx
	xorl	%esi, %esi
	movq	%rbx, %rdi
	movq	%rax, 8(%rsp)
	movq	%rcx, %rdx
	call	__memset_chk@PLT
	movq	(%rsp), %rcx
	movq	8(%rsp), %rdi
	xorl	%esi, %esi
	movq	%rcx, %rdx
	call	__memset_chk@PLT
	movq	(%rsp), %rsi
	leaq	48(%rsp), %rdi
	call	cudaMalloc@PLT
	movq	(%rsp), %rsi
	leaq	56(%rsp), %rdi
	call	cudaMalloc@PLT
	movslq	%ebp, %rax
	movq	%r14, %rdx
	movl	$1, %ecx
	movq	%rax, 16(%rsp)
	movsd	.LC14(%rip), %xmm0
.L32:
	cmpq	%rcx, 16(%rsp)
	jb	.L34
	leaq	(%rbx,%rdx,8), %rsi
	movl	$1, %eax
.L35:
	cmpq	%rax, 16(%rsp)
	jb	.L43
	movsd	%xmm0, (%rsi,%rax,8)
	incq	%rax
	jmp	.L35
.L43:
	incq	%rcx
	addq	%r14, %rdx
	jmp	.L32
.L34:
	leal	1(%rbp), %eax
	movsd	.LC15(%rip), %xmm1
	movl	$1, %ecx
	leaq	0(,%r14,8), %r8
	cvtsi2sdl	%eax, %xmm0
	movslq	%eax, %rdx
	movq	%r8, %rsi
	imull	%r15d, %eax
	divsd	%xmm0, %xmm1
	cltq
	addq	%rdx, %rax
	salq	$3, %rax
.L36:
	cvtsi2sdq	%rcx, %xmm0
	movq	8(%rsp), %rdi
	incq	%rcx
	mulsd	%xmm1, %xmm0
	movsd	%xmm0, (%rbx,%rsi)
	movsd	%xmm0, (%rdi,%rsi)
	addq	%r8, %rsi
	movsd	%xmm0, -8(%rbx,%rax)
	movsd	%xmm0, -8(%rdi,%rax)
	subq	$8, %rax
	cmpq	%rcx, %rdx
	jnb	.L36
	call	_Z7secondsv
	movq	(%rsp), %rdx
	movq	48(%rsp), %rdi
	movq	%rbx, %rsi
	movl	$1, %ecx
	movsd	%xmm0, 40(%rsp)
	call	cudaMemcpy@PLT
	movq	(%rsp), %rdx
	movq	8(%rsp), %rsi
	movl	$1, %ecx
	movq	56(%rsp), %rdi
	call	cudaMemcpy@PLT
	leal	16(%rbp), %eax
	movslq	36(%rsp), %r14
	movl	$1, 72(%rsp)
	sarl	$4, %eax
	movl	$1, 84(%rsp)
	movl	%eax, 64(%rsp)
	movl	%eax, 68(%rsp)
	movabsq	$68719476752, %rax
	movq	%rax, 76(%rsp)
	xorl	%eax, %eax
	movq	%rax, 24(%rsp)
.L37:
	cmpq	%r14, 24(%rsp)
	jnb	.L44
	movl	84(%rsp), %ecx
	movq	76(%rsp), %rdx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movq	64(%rsp), %rdi
	movl	72(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L38
	movq	56(%rsp), %rsi
	movq	48(%rsp), %rdi
	movl	%ebp, %edx
	call	_Z28__device_stub__Z6evolvePdS_iPdS_i
.L38:
	movq	48(%rsp), %rax
	movq	56(%rsp), %rdx
	incq	24(%rsp)
	movq	%rdx, 48(%rsp)
	movq	%rax, 56(%rsp)
	jmp	.L37
.L44:
	movq	(%rsp), %rdx
	movq	48(%rsp), %rsi
	movl	$2, %ecx
	movq	%rbx, %rdi
	call	cudaMemcpy@PLT
	call	_Z7secondsv
	subsd	40(%rsp), %xmm0
	leaq	.LC16(%rip), %rsi
	movb	$1, %al
	movl	$2, %edi
	call	__printf_chk@PLT
	leal	1(%r12), %eax
	movl	%r13d, %ecx
	movl	%r12d, %edx
	imull	%r15d, %eax
	leaq	.LC17(%rip), %rsi
	movl	$2, %edi
	leal	1(%r13,%rax), %eax
	cltq
	movsd	(%rbx,%rax,8), %xmm0
	movb	$1, %al
	call	__printf_chk@PLT
	movq	16(%rsp), %rsi
	movq	%rbx, %rdi
	call	_Z12save_gnuplotPdm
	movq	%rbx, %rdi
	call	free@PLT
	movq	8(%rsp), %rdi
	call	free@PLT
	movq	48(%rsp), %rdi
	call	cudaFree@PLT
	movq	56(%rsp), %rdi
	call	cudaFree@PLT
	xorl	%eax, %eax
.L27:
	movq	88(%rsp), %rdx
	subq	%fs:40, %rdx
	je	.L40
	call	__stack_chk_fail@PLT
.L40:
	addq	$104, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2027:
	.size	main, .-main
	.section	.rodata.str1.1
.LC18:
	.string	"_Z6evolvePdS_i"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2058:
	.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	.LC18(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z6evolvePdS_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
.LFE2058:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC4:
	.long	-1717986918
	.long	-1078355559
	.align 8
.LC5:
	.long	-1717986918
	.long	1069128089
	.align 8
.LC7:
	.long	0
	.long	1093567616
	.align 8
.LC14:
	.long	0
	.long	1071644672
	.align 8
.LC15:
	.long	0
	.long	1079574528
	.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 <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <sys/time.h>

#define NUMTHREADSPERBLOCK 16

/*** function declarations ***/

void PRINT_MAT(int P, int M, double * matr);

// save matrix to file
void save_gnuplot( double *M, size_t dim );

// evolve Jacobi
__global__  void evolve( double * matrix, double *matrix_new, int dimension );


// return the elapsed time
double seconds( void );

/*** end function declaration ***/




int main(int argc, char* argv[]){

  // timing variables
  double t_start, t_end, increment;

  // indexes for loops
  size_t i, j, it;

  // initialize matrix

  double *matrix, *matrix_new, *tmp_matrix;
  double *d_matrix, *d_matrix_new;
  int dimension = 0, iterations = 0, row_peek = 0, col_peek = 0;
  size_t byte_dimension = 0;

 // check on input parameters

  if(argc != 5) {
    fprintf(stderr,"\nwrong number of arguments. Usage: ./a.out dim it n m\n");
    return 1;
  }

  dimension = atoi(argv[1]);
  iterations = atoi(argv[2]);
  row_peek = atoi(argv[3]);
  col_peek = atoi(argv[4]);

  printf("matrix size = %zu\n", dimension);
  printf("number of iterations = %zu\n", iterations);
  printf("element for checking = Mat[%zu,%zu]\n",row_peek, col_peek);


  if((row_peek > dimension) || (col_peek > dimension)){
    fprintf(stderr, "Cannot Peek a matrix element outside of the matrix dimension\n");
    fprintf(stderr, "Arguments n and m must be smaller than %zu\n", dimension);
    return 1;
  }


  byte_dimension = sizeof(double*) * ( dimension + 2 ) * ( dimension + 2 );
  matrix = ( double* )malloc( byte_dimension );
  matrix_new = ( double* )malloc( byte_dimension );

  memset( matrix, 0, byte_dimension );
  memset( matrix_new, 0, byte_dimension );

  hipMalloc((void**) &d_matrix, byte_dimension ); //allocating space for d_matrix
  hipMalloc((void**) &d_matrix_new, byte_dimension );

  //fill initial values  

  for( i = 1; i <= dimension; ++i ){
    for( j = 1; j <= dimension; ++j ){
      matrix[ ( i * ( dimension + 2 ) ) + j ] = 0.5;
    }
  }
	     
  // set up borders 
  increment = 100.0 / ( dimension + 1 );

  
 for( i=1; i <= dimension+1; ++i ){
    matrix[ i * ( dimension + 2 ) ] = i * increment;
    matrix[ ( ( dimension + 1 ) * ( dimension + 2 ) ) + ( dimension + 1 - i ) ] = i * increment;
    matrix_new[ i * ( dimension + 2 ) ] = i * increment;
    matrix_new[ ( ( dimension + 1 ) * ( dimension + 2 ) ) + ( dimension + 1 - i ) ] = i * increment;
  }

  //printf("initial matrix\n");
  //PRINT_MAT(dimension+2,dimension+2,matrix);

  // start algorithm
  t_start = seconds();

  hipMemcpy( d_matrix, matrix, byte_dimension, hipMemcpyHostToDevice );
  hipMemcpy( d_matrix_new, matrix_new, byte_dimension, hipMemcpyHostToDevice );

  dim3 gridDim( (dimension+NUMTHREADSPERBLOCK)/NUMTHREADSPERBLOCK, (dimension+NUMTHREADSPERBLOCK)/NUMTHREADSPERBLOCK );
  dim3 blockDim(NUMTHREADSPERBLOCK , NUMTHREADSPERBLOCK);

  for( it = 0; it < iterations; ++it ){
  
  evolve<<< gridDim, blockDim  >>>( d_matrix, d_matrix_new, dimension );
    //evolve<<< (dimension+NUMTHREADSPERBLOCK)/NUMTHREADSPERBLOCK , NUMTHREADSPERBLOCK >>>( d_matrix, d_matrix_new, dimension );

    // swap the pointers
    tmp_matrix = d_matrix;
    d_matrix = d_matrix_new;
    d_matrix_new = tmp_matrix;
 }

  hipMemcpy( matrix, d_matrix, byte_dimension, hipMemcpyDeviceToHost );
  t_end = seconds();

  //printf("final matrix\n");
  //PRINT_MAT(dimension+2,dimension+2,matrix);

  printf( "\nelapsed time = %f seconds\n", t_end - t_start );
  printf( "\nmatrix[%zu,%zu] = %f\n", row_peek, col_peek, matrix[ ( row_peek + 1 ) * ( dimension + 2 ) + ( col_peek + 1 ) ] );

  save_gnuplot( matrix, dimension );
  

  free( matrix );
  free( matrix_new );
  hipFree(d_matrix);
  hipFree(d_matrix_new);


  return 0;

}

void PRINT_MAT(int P, int M, double * matr){
  for(int j = 0; j < P; j++ ){
    for(int i = 0; i < M; i++ ){
      printf("%0.1f ",matr[i+j*M]);
    }
    printf("\n");
  }
}

__global__ void evolve( double * matrix, double * matrix_new, int dimension ){

  int idx = threadIdx.x + (blockIdx.x * blockDim.x);
  int idy = threadIdx.y + (blockIdx.y * blockDim.y); 
  
  
  if (idx>0 && idx<=dimension){
    if(idy>0 && idy<=dimension){
      matrix_new[ ( idx * ( dimension + 2 ) ) + idy ] = ( 0.25 ) * 
	( matrix[ ( ( idx - 1 ) * ( dimension + 2 ) ) + idy ] + 
	  matrix[ ( idx * ( dimension + 2 ) ) + ( idy + 1 ) ] + 	  
	  matrix[ ( ( idx + 1 ) * ( dimension + 2 ) ) + idy ] + 
	  matrix[ ( idx * ( dimension + 2 ) ) + ( idy - 1 ) ] ); 
    }
  }
}

void save_gnuplot( double *M, size_t dimension ){  

  size_t i , j;

  const double h = 0.1;

  FILE *file;

  file = fopen( "solution.dat", "w" );

  for( i = 0; i < dimension + 2; ++i )

    for( j = 0; j < dimension + 2; ++j )

      fprintf(file, "%f\t%f\t%f\n", h * j, -h * i, M[ ( i * ( dimension + 2 ) ) + j ] );

  fclose( file );

}



// A Simple timer for measuring the walltime

double seconds(){

    struct timeval tmp;
    double sec;
    gettimeofday( &tmp, (struct timezone *)0 );
    sec = tmp.tv_sec + ((double)tmp.tv_usec)/1000000.0;
    return sec;

}

	.text
	.file	"jacobi_notshared.hip"
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI0_0:
	.quad	0x4059000000000000              # double 100
.LCPI0_3:
	.quad	0x412e848000000000              # double 1.0E+6
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0
.LCPI0_1:
	.long	1127219200                      # 0x43300000
	.long	1160773632                      # 0x45300000
	.long	0                               # 0x0
	.long	0                               # 0x0
.LCPI0_2:
	.quad	0x4330000000000000              # double 4503599627370496
	.quad	0x4530000000000000              # double 1.9342813113834067E+25
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$88, %rsp
	.cfi_def_cfa_offset 144
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	cmpl	$5, %edi
	jne	.LBB0_21
# %bb.1:
	movq	%rsi, %rbx
	movq	8(%rsi), %rdi
	callq	atoi
	movl	%eax, %r15d
	movq	16(%rbx), %rdi
	callq	atoi
	movl	%eax, %ebp
	movq	24(%rbx), %rdi
	callq	atoi
	movl	%eax, %r14d
	movq	32(%rbx), %rdi
	callq	atoi
	movl	%eax, %ebx
	movl	$.L.str.1, %edi
	movl	%r15d, %esi
	xorl	%eax, %eax
	callq	printf
	movl	$.L.str.2, %edi
	movl	%ebp, %esi
	xorl	%eax, %eax
	callq	printf
	movl	$.L.str.3, %edi
	movl	%r14d, %esi
	movl	%ebx, %edx
	xorl	%eax, %eax
	callq	printf
	cmpl	%r15d, %r14d
	jg	.LBB0_23
# %bb.2:
	cmpl	%r15d, %ebx
	jg	.LBB0_23
# %bb.3:
	movl	%r14d, 36(%rsp)                 # 4-byte Spill
	movl	%ebp, 32(%rsp)                  # 4-byte Spill
	movq	%rbx, 64(%rsp)                  # 8-byte Spill
	leal	2(%r15), %eax
	movl	%eax, 28(%rsp)                  # 4-byte Spill
	movslq	%eax, %rbp
	movq	%rbp, %rbx
	imulq	%rbp, %rbx
	shlq	$3, %rbx
	movl	$1, %r14d
	movl	$1, %edi
	movq	%rbx, %rsi
	callq	calloc@PLT
	movq	%rax, %r12
	movl	$1, %edi
	movq	%rbx, %rsi
	callq	calloc@PLT
	movq	%rax, %r13
	leaq	8(%rsp), %rdi
	movq	%rbx, %rsi
	callq	hipMalloc
	leaq	16(%rsp), %rdi
	movq	%rbx, 40(%rsp)                  # 8-byte Spill
	movq	%rbx, %rsi
	callq	hipMalloc
	movslq	%r15d, %rax
	testl	%r15d, %r15d
	movq	%rax, 56(%rsp)                  # 8-byte Spill
	je	.LBB0_10
# %bb.4:                                # %.preheader.lr.ph
	leaq	1(%rax), %rcx
	cmpq	$3, %rcx
	movl	$2, %eax
	cmovaeq	%rcx, %rax
	leaq	(,%rbp,8), %rcx
	leaq	(%r12,%rbp,8), %rdx
	movl	$1, %esi
	movabsq	$4602678819172646912, %rdi      # imm = 0x3FE0000000000000
.LBB0_5:                                # %.lr.ph
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB0_6 Depth 2
	movl	$1, %r8d
.LBB0_6:                                #   Parent Loop BB0_5 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movq	%rdi, (%rdx,%r8,8)
	incq	%r8
	cmpq	%r8, %rax
	jne	.LBB0_6
# %bb.7:                                # %._crit_edge
                                        #   in Loop: Header=BB0_5 Depth=1
	incq	%rsi
	addq	%rcx, %rdx
	cmpq	%rax, %rsi
	jne	.LBB0_5
# %bb.8:                                # %._crit_edge112
	movl	%r15d, %eax
	incl	%eax
	je	.LBB0_13
# %bb.9:
	cvtsi2sd	%eax, %xmm1
	movsd	.LCPI0_0(%rip), %xmm0           # xmm0 = mem[0],zero
	divsd	%xmm1, %xmm0
	movslq	%eax, %rcx
	jmp	.LBB0_11
.LBB0_10:
	movl	$1, %eax
	movsd	.LCPI0_0(%rip), %xmm0           # xmm0 = mem[0],zero
	movl	$1, %ecx
.LBB0_11:                               # %.lr.ph116
	imull	28(%rsp), %eax                  # 4-byte Folded Reload
	movslq	%eax, %rdx
	leaq	1(%rcx), %rsi
	cmpq	$3, %rsi
	movl	$2, %eax
	cmovaeq	%rsi, %rax
	negq	%rax
	addq	%rcx, %rdx
	leaq	(,%rdx,8), %rcx
	addq	%r13, %rcx
	leaq	(%r12,%rdx,8), %rdx
	movq	$-1, %rsi
	movdqa	.LCPI0_1(%rip), %xmm1           # xmm1 = [1127219200,1160773632,0,0]
	movapd	.LCPI0_2(%rip), %xmm2           # xmm2 = [4.503599627370496E+15,1.9342813113834067E+25]
	movq	%rbp, %rdi
.LBB0_12:                               # =>This Inner Loop Header: Depth=1
	movq	%r14, %xmm3
	punpckldq	%xmm1, %xmm3            # xmm3 = xmm3[0],xmm1[0],xmm3[1],xmm1[1]
	subpd	%xmm2, %xmm3
	movapd	%xmm3, %xmm4
	unpckhpd	%xmm3, %xmm4                    # xmm4 = xmm4[1],xmm3[1]
	addsd	%xmm3, %xmm4
	mulsd	%xmm0, %xmm4
	movsd	%xmm4, (%r12,%rdi,8)
	movsd	%xmm4, (%rdx,%rsi,8)
	movsd	%xmm4, (%r13,%rdi,8)
	movsd	%xmm4, (%rcx,%rsi,8)
	incq	%r14
	decq	%rsi
	addq	%rbp, %rdi
	cmpq	%rsi, %rax
	jne	.LBB0_12
.LBB0_13:                               # %._crit_edge117
	leaq	72(%rsp), %rbx
	movq	%rbx, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	xorps	%xmm0, %xmm0
	cvtsi2sdq	(%rbx), %xmm0
	xorps	%xmm1, %xmm1
	cvtsi2sdq	8(%rbx), %xmm1
	divsd	.LCPI0_3(%rip), %xmm1
	addsd	%xmm0, %xmm1
	movsd	%xmm1, 48(%rsp)                 # 8-byte Spill
	movq	8(%rsp), %rdi
	movq	%r12, %rsi
	movq	40(%rsp), %rbx                  # 8-byte Reload
	movq	%rbx, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	16(%rsp), %rdi
	movq	%r13, %rsi
	movq	%rbx, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	leal	16(%r15), %ecx
	movl	%r15d, %eax
	addl	$31, %eax
	testl	%ecx, %ecx
	cmovnsl	%ecx, %eax
	movl	32(%rsp), %ecx                  # 4-byte Reload
	testl	%ecx, %ecx
	je	.LBB0_18
# %bb.14:
	sarl	$4, %eax
	movq	%rax, %rbx
	shlq	$32, %rbx
	orq	%rax, %rbx
	movslq	%ecx, %rbp
	movabsq	$68719476752, %r14              # imm = 0x1000000010
.LBB0_15:                               # %.lr.ph120
                                        # =>This Inner Loop Header: Depth=1
	movq	%rbx, %rdi
	movl	$1, %esi
	movq	%r14, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB0_17
# %bb.16:                               #   in Loop: Header=BB0_15 Depth=1
	movq	8(%rsp), %rdi
	movq	16(%rsp), %rsi
	movl	%r15d, %edx
	callq	_Z21__device_stub__evolvePdS_i
.LBB0_17:                               #   in Loop: Header=BB0_15 Depth=1
	movq	8(%rsp), %rax
	movq	16(%rsp), %rsi
	movq	%rsi, 8(%rsp)
	movq	%rax, 16(%rsp)
	decq	%rbp
	jne	.LBB0_15
	jmp	.LBB0_19
.LBB0_18:                               # %._crit_edge117.._crit_edge121_crit_edge
	movq	8(%rsp), %rsi
.LBB0_19:                               # %._crit_edge121
	movq	%r12, %rdi
	movq	40(%rsp), %rdx                  # 8-byte Reload
	movl	$2, %ecx
	callq	hipMemcpy
	xorl	%r15d, %r15d
	leaq	72(%rsp), %rbx
	movq	%rbx, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	xorps	%xmm1, %xmm1
	cvtsi2sdq	(%rbx), %xmm1
	xorps	%xmm0, %xmm0
	cvtsi2sdq	8(%rbx), %xmm0
	divsd	.LCPI0_3(%rip), %xmm0
	addsd	%xmm1, %xmm0
	subsd	48(%rsp), %xmm0                 # 8-byte Folded Reload
	movl	$.L.str.6, %edi
	movb	$1, %al
	callq	printf
	movl	36(%rsp), %esi                  # 4-byte Reload
	movl	%esi, %eax
	incl	%eax
	imull	28(%rsp), %eax                  # 4-byte Folded Reload
	movq	64(%rsp), %rdx                  # 8-byte Reload
	addl	%edx, %eax
	incl	%eax
	cltq
	movsd	(%r12,%rax,8), %xmm0            # xmm0 = mem[0],zero
	movl	$.L.str.7, %edi
                                        # kill: def $edx killed $edx killed $rdx
	movb	$1, %al
	callq	printf
	movq	%r12, %rdi
	movq	56(%rsp), %rsi                  # 8-byte Reload
	callq	_Z12save_gnuplotPdm
	movq	%r12, %rdi
	callq	free
	movq	%r13, %rdi
	callq	free
	movq	8(%rsp), %rdi
	callq	hipFree
	movq	16(%rsp), %rdi
	callq	hipFree
.LBB0_20:
	movl	%r15d, %eax
	addq	$88, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.LBB0_21:
	.cfi_def_cfa_offset 144
	movq	stderr(%rip), %rcx
	movl	$.L.str, %edi
	movl	$54, %esi
	movl	$1, %edx
	callq	fwrite@PLT
	jmp	.LBB0_22
.LBB0_23:
	movq	stderr(%rip), %rcx
	movl	$.L.str.4, %edi
	movl	$61, %esi
	movl	$1, %edx
	callq	fwrite@PLT
	movq	stderr(%rip), %rdi
	movl	$.L.str.5, %esi
	movl	%r15d, %edx
	xorl	%eax, %eax
	callq	fprintf
.LBB0_22:
	movl	$1, %r15d
	jmp	.LBB0_20
.Lfunc_end0:
	.size	main, .Lfunc_end0-main
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z7secondsv
.LCPI1_0:
	.quad	0x412e848000000000              # double 1.0E+6
	.text
	.globl	_Z7secondsv
	.type	_Z7secondsv,@function
_Z7secondsv:                            # @_Z7secondsv
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$16, %rsp
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -16
	movq	%rsp, %rbx
	movq	%rbx, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	cvtsi2sdq	(%rbx), %xmm1
	cvtsi2sdq	8(%rbx), %xmm0
	divsd	.LCPI1_0(%rip), %xmm0
	addsd	%xmm1, %xmm0
	addq	$16, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end1:
	.size	_Z7secondsv, .Lfunc_end1-_Z7secondsv
	.cfi_endproc
                                        # -- End function
	.globl	_Z21__device_stub__evolvePdS_i  # -- Begin function _Z21__device_stub__evolvePdS_i
	.type	_Z21__device_stub__evolvePdS_i,@function
_Z21__device_stub__evolvePdS_i:         # @_Z21__device_stub__evolvePdS_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), %rcx
	movq	%rsi, (%rcx)
	leaq	12(%rsp), %rsi
	movl	%edx, (%rsi)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	movq	%rsi, 16(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	24(%rsp), %r12
	leaq	16(%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	$_Z6evolvePdS_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_end2:
	.size	_Z21__device_stub__evolvePdS_i, .Lfunc_end2-_Z21__device_stub__evolvePdS_i
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0                          # -- Begin function _Z12save_gnuplotPdm
.LCPI3_0:
	.long	1127219200                      # 0x43300000
	.long	1160773632                      # 0x45300000
	.long	0                               # 0x0
	.long	0                               # 0x0
.LCPI3_1:
	.quad	0x4330000000000000              # double 4503599627370496
	.quad	0x4530000000000000              # double 1.9342813113834067E+25
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0
.LCPI3_2:
	.quad	0xbfb999999999999a              # double -0.10000000000000001
.LCPI3_3:
	.quad	0x3fb999999999999a              # double 0.10000000000000001
	.text
	.globl	_Z12save_gnuplotPdm
	.type	_Z12save_gnuplotPdm,@function
_Z12save_gnuplotPdm:                    # @_Z12save_gnuplotPdm
	.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	$24, %rsp
	.cfi_def_cfa_offset 80
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rsi, %r15
	movq	%rdi, %rbx
	movl	$.L.str.10, %edi
	movl	$.L.str.11, %esi
	callq	fopen
	movq	%rax, %r14
	movq	%r15, %r12
	addq	$2, %r12
	je	.LBB3_5
# %bb.1:                                # %.preheader.preheader
	leaq	16(,%r15,8), %r15
	xorl	%r13d, %r13d
	movdqa	.LCPI3_0(%rip), %xmm2           # xmm2 = [1127219200,1160773632,0,0]
	movapd	.LCPI3_1(%rip), %xmm3           # xmm3 = [4.503599627370496E+15,1.9342813113834067E+25]
	movsd	.LCPI3_3(%rip), %xmm4           # xmm4 = mem[0],zero
.LBB3_2:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB3_3 Depth 2
	movq	%r13, %xmm0
	punpckldq	%xmm2, %xmm0            # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
	subpd	%xmm3, %xmm0
	movapd	%xmm0, %xmm1
	unpckhpd	%xmm0, %xmm1                    # xmm1 = xmm1[1],xmm0[1]
	addsd	%xmm0, %xmm1
	mulsd	.LCPI3_2(%rip), %xmm1
	movapd	%xmm1, (%rsp)                   # 16-byte Spill
	xorl	%ebp, %ebp
.LBB3_3:                                #   Parent Loop BB3_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movq	%rbp, %xmm1
	punpckldq	%xmm2, %xmm1            # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
	subpd	%xmm3, %xmm1
	movapd	%xmm1, %xmm0
	unpckhpd	%xmm1, %xmm0                    # xmm0 = xmm0[1],xmm1[1]
	addsd	%xmm1, %xmm0
	mulsd	%xmm4, %xmm0
	movsd	(%rbx,%rbp,8), %xmm2            # xmm2 = mem[0],zero
	movl	$.L.str.12, %esi
	movq	%r14, %rdi
	movaps	(%rsp), %xmm1                   # 16-byte Reload
	movb	$3, %al
	callq	fprintf
	movsd	.LCPI3_3(%rip), %xmm4           # xmm4 = mem[0],zero
	movapd	.LCPI3_1(%rip), %xmm3           # xmm3 = [4.503599627370496E+15,1.9342813113834067E+25]
	movdqa	.LCPI3_0(%rip), %xmm2           # xmm2 = [1127219200,1160773632,0,0]
	incq	%rbp
	cmpq	%rbp, %r12
	jne	.LBB3_3
# %bb.4:                                #   in Loop: Header=BB3_2 Depth=1
	incq	%r13
	addq	%r15, %rbx
	cmpq	%r12, %r13
	jne	.LBB3_2
.LBB3_5:                                # %._crit_edge
	movq	%r14, %rdi
	addq	$24, %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
	jmp	fclose                          # TAILCALL
.Lfunc_end3:
	.size	_Z12save_gnuplotPdm, .Lfunc_end3-_Z12save_gnuplotPdm
	.cfi_endproc
                                        # -- End function
	.globl	_Z9PRINT_MATiiPd                # -- Begin function _Z9PRINT_MATiiPd
	.type	_Z9PRINT_MATiiPd,@function
_Z9PRINT_MATiiPd:                       # @_Z9PRINT_MATiiPd
	.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	$24, %rsp
	.cfi_def_cfa_offset 80
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rdx, 8(%rsp)                   # 8-byte Spill
	testl	%edi, %edi
	jle	.LBB4_6
# %bb.1:                                # %.preheader.lr.ph
	movl	%esi, %ebp
	movl	%edi, %eax
	movq	%rax, 16(%rsp)                  # 8-byte Spill
	movl	%esi, %r15d
	xorl	%r12d, %r12d
	xorl	%r13d, %r13d
.LBB4_2:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB4_4 Depth 2
	testl	%ebp, %ebp
	jle	.LBB4_5
# %bb.3:                                # %.lr.ph
                                        #   in Loop: Header=BB4_2 Depth=1
	movl	%r12d, %eax
	movq	8(%rsp), %rcx                   # 8-byte Reload
	leaq	(%rcx,%rax,8), %rbx
	xorl	%r14d, %r14d
.LBB4_4:                                #   Parent Loop BB4_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movsd	(%rbx,%r14,8), %xmm0            # xmm0 = mem[0],zero
	movl	$.L.str.8, %edi
	movb	$1, %al
	callq	printf
	incq	%r14
	cmpq	%r14, %r15
	jne	.LBB4_4
.LBB4_5:                                # %._crit_edge
                                        #   in Loop: Header=BB4_2 Depth=1
	movl	$10, %edi
	callq	putchar@PLT
	incq	%r13
	addl	%ebp, %r12d
	cmpq	16(%rsp), %r13                  # 8-byte Folded Reload
	jne	.LBB4_2
.LBB4_6:                                # %._crit_edge13
	addq	$24, %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_end4:
	.size	_Z9PRINT_MATiiPd, .Lfunc_end4-_Z9PRINT_MATiiPd
	.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	.LBB5_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB5_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z6evolvePdS_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_end5:
	.size	__hip_module_ctor, .Lfunc_end5-__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	.LBB6_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
.LBB6_2:
	retq
.Lfunc_end6:
	.size	__hip_module_dtor, .Lfunc_end6-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"\nwrong number of arguments. Usage: ./a.out dim it n m\n"
	.size	.L.str, 55

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"matrix size = %zu\n"
	.size	.L.str.1, 19

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"number of iterations = %zu\n"
	.size	.L.str.2, 28

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"element for checking = Mat[%zu,%zu]\n"
	.size	.L.str.3, 37

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"Cannot Peek a matrix element outside of the matrix dimension\n"
	.size	.L.str.4, 62

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"Arguments n and m must be smaller than %zu\n"
	.size	.L.str.5, 44

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

	.type	.L.str.6,@object                # @.str.6
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.6:
	.asciz	"\nelapsed time = %f seconds\n"
	.size	.L.str.6, 28

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"\nmatrix[%zu,%zu] = %f\n"
	.size	.L.str.7, 23

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"%0.1f "
	.size	.L.str.8, 7

	.type	.L.str.10,@object               # @.str.10
.L.str.10:
	.asciz	"solution.dat"
	.size	.L.str.10, 13

	.type	.L.str.11,@object               # @.str.11
.L.str.11:
	.asciz	"w"
	.size	.L.str.11, 2

	.type	.L.str.12,@object               # @.str.12
.L.str.12:
	.asciz	"%f\t%f\t%f\n"
	.size	.L.str.12, 10

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z6evolvePdS_i"
	.size	.L__unnamed_1, 15

	.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 _Z21__device_stub__evolvePdS_i
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z6evolvePdS_i
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z6evolvePdS_i          ; -- Begin function _Z6evolvePdS_i
	.globl	_Z6evolvePdS_i
	.p2align	8
	.type	_Z6evolvePdS_i,@function
_Z6evolvePdS_i:                         ; @_Z6evolvePdS_i
; %bb.0:
	s_load_b32 s2, s[0:1], 0x24
	v_and_b32_e32 v1, 0x3ff, v0
	s_waitcnt lgkmcnt(0)
	s_and_b32 s3, s2, 0xffff
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	v_mad_u64_u32 v[2:3], null, s14, s3, v[1:2]
	s_mov_b32 s3, exec_lo
	s_delay_alu instid0(VALU_DEP_1)
	v_cmpx_lt_i32_e32 0, v2
	s_cbranch_execz .LBB0_3
; %bb.1:
	s_load_b32 s3, s[0:1], 0x10
	v_bfe_u32 v3, v0, 10, 10
	s_lshr_b32 s2, s2, 16
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	v_mad_u64_u32 v[0:1], null, s15, s2, v[3:4]
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_2)
	v_max_i32_e32 v1, v2, v0
	v_cmp_lt_i32_e32 vcc_lo, 0, v0
	s_waitcnt lgkmcnt(0)
	v_cmp_ge_i32_e64 s2, s3, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_and_b32 s2, s2, vcc_lo
	s_and_b32 exec_lo, exec_lo, s2
	s_cbranch_execz .LBB0_3
; %bb.2:
	v_add_nc_u32_e32 v3, -1, v2
	s_add_i32 s4, s3, 2
	s_load_b128 s[0:3], s[0:1], 0x0
	v_mul_lo_u32 v7, v2, s4
	v_ashrrev_i32_e32 v4, 31, v0
	v_mad_u64_u32 v[1:2], null, v3, s4, v[0:1]
	s_delay_alu instid0(VALU_DEP_3) | instskip(SKIP_1) | instid1(VALU_DEP_3)
	v_ashrrev_i32_e32 v5, 31, v7
	v_add_co_u32 v3, vcc_lo, v0, v7
	v_ashrrev_i32_e32 v2, 31, v1
	v_add_nc_u32_e32 v0, v7, v0
	s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_co_ci_u32_e32 v4, vcc_lo, v4, v5, vcc_lo
	v_lshlrev_b64 v[1:2], 3, v[1:2]
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_nc_u32_e32 v7, s4, v0
	v_lshlrev_b64 v[3:4], 3, v[3:4]
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_4)
	v_ashrrev_i32_e32 v8, 31, v7
	s_waitcnt lgkmcnt(0)
	v_add_co_u32 v1, vcc_lo, s0, v1
	v_add_co_ci_u32_e32 v2, vcc_lo, s1, v2, vcc_lo
	s_delay_alu instid0(VALU_DEP_4)
	v_add_co_u32 v3, vcc_lo, s0, v3
	v_add_co_ci_u32_e32 v4, vcc_lo, s1, v4, vcc_lo
	s_clause 0x1
	global_load_b64 v[1:2], v[1:2], off
	global_load_b64 v[5:6], v[3:4], off offset:8
	v_lshlrev_b64 v[7:8], 3, v[7:8]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v7, vcc_lo, s0, v7
	v_add_co_ci_u32_e32 v8, vcc_lo, s1, v8, vcc_lo
	s_clause 0x1
	global_load_b64 v[7:8], v[7:8], off
	global_load_b64 v[3:4], v[3:4], off offset:-8
	s_waitcnt vmcnt(2)
	v_add_f64 v[1:2], v[1:2], v[5:6]
	s_waitcnt vmcnt(1)
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[7:8]
	s_waitcnt vmcnt(0)
	v_add_f64 v[1:2], v[1:2], v[3:4]
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_ldexp_f64 v[2:3], v[1:2], -2
	v_ashrrev_i32_e32 v1, 31, v0
	v_lshlrev_b64 v[0:1], 3, v[0:1]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v0, vcc_lo, s2, v0
	v_add_co_ci_u32_e32 v1, vcc_lo, s3, v1, vcc_lo
	global_store_b64 v[0:1], v[2:3], off
.LBB0_3:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z6evolvePdS_i
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 280
		.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 9
		.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	_Z6evolvePdS_i, .Lfunc_end0-_Z6evolvePdS_i
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 424
; NumSgprs: 18
; NumVgprs: 9
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 9
; 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
      - .offset:         16
        .size:           4
        .value_kind:     by_value
      - .offset:         24
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         28
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         32
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         36
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         38
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         40
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         42
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         44
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         46
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         64
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         88
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 280
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z6evolvePdS_i
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z6evolvePdS_i.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     9
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
