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



//===> FINITE DIFFERENCES PARAMETERS <===//
#define DT 0.05f                   //->Time in milliseconds
#define DX ( 12.0f / MODELSIZE_X ) //->Displacement in x
#define DY ( 12.0f / MODELSIZE_Y ) //->Displacement in y

//===> CONSTANTES <===//
#define Eh 3.0f
#define En 1.0f
#define Re 0.6f
#define tauE 5.0f
#define tauN 250.0f
#define gam 0.001f
#define East 1.5415f

//===> INITIAL CONDITIONS <===//
#define v0 0.5f
#define VOLT0 3.0f

//==> DISCRETE DOMAIN <==//
#ifndef MODEL_WIDTH
#define MODEL_WIDTH 0
#endif

#define MODELSIZE_X (MODEL_WIDTH)
#define MODELSIZE_Y (MODEL_WIDTH)
#define MODELSIZE_Z 1
#define MODELSIZE2D ( MODELSIZE_X*MODELSIZE_Y )

//==> CUDA THREAD BLOCK <==//
//#define TILESIZE   32
//#define BLOCKDIM_X ( TILESIZE )
//#define BLOCKDIM_Y ( TILESIZE )

#ifndef BLOCKDIM_X
#define BLOCKDIM_X 32
#endif

#ifndef BLOCKDIM_Y
#define BLOCKDIM_Y 32
#endif

#define BLOCKDIM_Z 1
#define BLOCKDIM2D ( BLOCKDIM_X*BLOCKDIM_Y )

//==> CUDA GRID <==//
#define GRIDDIM_X ( ( MODELSIZE_X / BLOCKDIM_X ) + ( ( MODELSIZE_X % BLOCKDIM_X ) > 0 ) )
#define GRIDDIM_Y ( ( MODELSIZE_Y / BLOCKDIM_Y ) + ( ( MODELSIZE_Y % BLOCKDIM_Y ) > 0 ) )
#define GRIDDIM_Z 1


//////////////////////////////////////////////////////////////////////////
static void HandleError( cudaError_t err,
                         const char *file,
                         int line ) {
    if (err != cudaSuccess) {
        printf( "%s in %s at line %d\n", cudaGetErrorString( err ),
                file, line );
        exit( EXIT_FAILURE );
    }
}
#define HANDLE_ERROR( err ) (HandleError( err, __FILE__, __LINE__ ))
//////////////////////////////////////////////////////////////////////////


__global__ void timeStep( const float *voltIN, float *v, float *voltOUT )
{
    int x = blockIdx.x*BLOCKDIM_X + threadIdx.x;
    int y = blockIdx.y*BLOCKDIM_Y + threadIdx.y;

    __shared__ float U[BLOCKDIM_X+2][BLOCKDIM_Y+2];

    if ( x < MODELSIZE_X && y < MODELSIZE_Y ) 
    {
        //
        int idx = y*MODELSIZE_X + x;

        int i = threadIdx.x+1;
        int j = threadIdx.y+1;

        U[i][j] = voltIN[idx];

        __syncthreads();

        float rv = v[idx];

        if ( threadIdx.y == 0 )
        U[i][0] = voltIN[(idx - ((y>0)-(y==0))*MODELSIZE_X)];
        else if ( threadIdx.y == (BLOCKDIM_Y-1) )
        U[i][(BLOCKDIM_Y+1)] = voltIN[(idx + ((y<MODELSIZE_Y-1)-(y==MODELSIZE_Y-1))*MODELSIZE_X)];

        if ( threadIdx.x == 0 )
        U[0][j] = voltIN[(idx - (x>0) + (x==0))];
        else if ( threadIdx.x == (BLOCKDIM_X-1) )
        U[(BLOCKDIM_X+1)][j] = voltIN[(idx + (x<MODELSIZE_X-1)-(x==MODELSIZE_X-1))];
        

        float Rn = ( 1.0f / ( 1.0f - expf(-Re) ) ) - rv;
        float p = ( U[i][j] > En ) * 1.0f;
        float dv = ( Rn * p - ( 1.0f - p ) * rv ) / tauN;
        float Dn = rv * rv;
        float hE = ( 1.0f - tanh(U[i][j] - Eh) ) * U[i][j] * U[i][j] / 2.0f;
        float du = ( ( ( East - Dn ) * hE ) - U[i][j] ) / tauE;

        float xlapr = U[i+1][j] - U[i][j];
        float xlapl = U[i][j]   - U[i-1][j];
        float xlapf = U[i][j+1] - U[i][j];
        float xlapb = U[i][j]   - U[i][j-1];

        float lap = xlapr - xlapl + xlapf - xlapb;

        voltOUT[idx] = ( U[i][j] + ( du * DT ) + ( lap * DT * gam / ( DX * DX ) ) );
        v[idx]       = rv + dv*DT;
    }
}

int main( int argc, char *argv[] )
{
    int nsteps = 3; //8000;
    // if ( argc > 1 ) 
    // {
    //     char *p;
    //     long conv = strtol(argv[1], &p, 10);
    //     //
    //     // Check for errors: e.g., the string does not represent an integer
    //     // or the integer is larger than int
    //     if (*p != '\0' || conv > INT_MAX) 
    //     {
    //         printf("Error with argument 1!");
    //         return 3;
    //     }
    //     else
    //     nsteps = int(conv/DT);
    // }
    if (argc > 1)
    {
        nsteps = atoi(argv[1]);
    }
    //
    cudaEvent_t dstart,dstop;
    cudaEventCreate( &dstart );
    cudaEventCreate( &dstop );
    //
    long start, end;
    struct timeval timecheck;
    gettimeofday(&timecheck, NULL);
    start = (long)timecheck.tv_sec * 1000 + (long)timecheck.tv_usec / 1000;
    //
    float *hvolt, *hv;
    hvolt = (float*) malloc( MODELSIZE2D*sizeof(float) );
    hv    = (float*) malloc( MODELSIZE2D*sizeof(float) );

    // int x, y, idx;
    // for( y = 0; y < MODELSIZE_Y; y++ )
    // {
    //     for( x = 0; x < MODELSIZE_X; x++ )
    //     {
    //         idx = y*MODELSIZE_X + x;
    //         //
    //         hv[idx] = 0.5f;
    //         //
    //         if ( y < 10*(MODELSIZE_Y/20) && y > 8*(MODELSIZE_Y/20) && x < 10*(MODELSIZE_Y/20) &&  x > 8*(MODELSIZE_Y/20))
    //         hvolt[idx] = VOLT0;
    //         else
    //         hvolt[idx] = 0.0f;
    //         //
    //     }
    // }

     FILE *arq;
    arq = fopen("entrada.txt", "rt");
    for(int i=0;i<MODELSIZE_X;i++)
        for(int j=0;j<MODELSIZE_Y;j++)
        {
            hv[i+j*MODELSIZE_X] = 0.5f;
            int temp;
            fscanf(arq," %d",&temp);
            hvolt[i+j*MODELSIZE_X] = temp;
        }
            
    fclose(arq);

    // FILE *prof;
    // char fpname[100];
    // sprintf(fpname, "./profiles_%d_k2D_shared.csv",MODELSIZE_X);
    // prof = fopen(fpname,"w");
    // fprintf(prof,"index,timestep,P\n");
    // fprintf(prof,"0,%6.4f",0.0);
    // fclose(prof);


    dim3 point;
    //int pointIdx;
    point.x = MODELSIZE_X/2;
    point.y = MODELSIZE_Y/2;
    point.z = 0;
   // pointIdx = point.y*MODELSIZE_X + point.x;


    //fprintf(prof,",%6.4f\n",hvolt[pointIdx]);


    float *dvoltA, *dvoltB, *dv;
    HANDLE_ERROR( cudaMalloc( (void**)&dvoltA, MODELSIZE2D*sizeof(float) ) );
    HANDLE_ERROR( cudaMalloc( (void**)&dvoltB, MODELSIZE2D*sizeof(float) ) );
    HANDLE_ERROR( cudaMalloc( (void**)&dv    , MODELSIZE2D*sizeof(float) ) );

    HANDLE_ERROR( cudaMemcpy( dvoltA, hvolt, MODELSIZE2D*sizeof(float), cudaMemcpyHostToDevice ) );
    HANDLE_ERROR( cudaMemcpy( dvoltB, hvolt, MODELSIZE2D*sizeof(float), cudaMemcpyHostToDevice ) );
    HANDLE_ERROR( cudaMemcpy( dv    , hv   , MODELSIZE2D*sizeof(float), cudaMemcpyHostToDevice ) );

    free( hv );

    dim3 blocks(GRIDDIM_X,GRIDDIM_Y,GRIDDIM_Z);
    dim3 threads(BLOCKDIM_X,BLOCKDIM_Y,BLOCKDIM_Z);

    //int nsamples = (nsteps >= 2000)*2000 + (nsteps < 2000)*nsteps;
    //int j = nsteps/nsamples;
    cudaDeviceSynchronize();
    cudaEventRecord( dstart, 0 );
    int i=0;
    for (i = 0; i < nsteps; i++ ) 
    {
        if ( (i%2) == 0 ) //==> EVEN
        timeStep<<<blocks, threads>>>( dvoltA, dv, dvoltB );
        else              //==> ODD
        timeStep<<<blocks, threads>>>( dvoltB, dv, dvoltA );
        //
        /*if ( (i%j) == 0 ) {
        if ( (i%2) == 0 ) //==> EVEN
        HANDLE_ERROR( cudaMemcpy( hvolt, dvoltB, MODELSIZE3D*sizeof(float), cudaMemcpyDeviceToHost ) );
        else              //==> ODD
        HANDLE_ERROR( cudaMemcpy( hvolt, dvoltA, MODELSIZE3D*sizeof(float), cudaMemcpyDeviceToHost ) );
        //
        fprintf(prof,"%d,%6.4f,%6.4f\n", (i+1), ((i+1)*DT), hvolt[pointIdx]);
        }*/
        cudaError_t err = cudaSuccess;
        err = cudaGetLastError();
        if (err != cudaSuccess)
        {
            fprintf(stderr, "Failed to launch _3Dstencil_global kernel (error code %s)!\n", cudaGetErrorString(err));
        }
    }
    cudaDeviceSynchronize();
    cudaEventRecord( dstop, 0 );
    cudaEventSynchronize ( dstop );
    float elapsed;
    cudaEventElapsedTime( &elapsed, dstart, dstop );
    //printf("GPU elapsed time: %f s (%f milliseconds)\n", (elapsed/1000.0), elapsed);

    //arq = fopen("TempoExecucaoOrig12000.txt", "a");
    //printf("X %d || Y %d \nBX %d || BY %d \n",X,Y,BX,BY);
        //fprintf (arq,"[%d,%.5f],\n",MODEL_WIDTH,elapsed);
        printf ("[%d,%.5f]",0,elapsed);
    //fclose(arq);



    // if ( (i%2) == 0 )
    // HANDLE_ERROR( cudaMemcpy( hvolt, dvoltA, MODELSIZE2D*sizeof(float), cudaMemcpyDeviceToHost ) );
    // else
    // HANDLE_ERROR( cudaMemcpy( hvolt, dvoltB, MODELSIZE2D*sizeof(float), cudaMemcpyDeviceToHost ) );


    // arq = fopen("resultado.txt", "wt");
    // for(int i=0;i<MODELSIZE_X;i++)
    // {
    //     for(int j=0;j<MODELSIZE_Y;j++)
    //     {
    //         fprintf(arq," %6.4f",hvolt[i+j*MODELSIZE_X]);
    //     }
    //     fprintf(arq,"\n");
    // }
    // fclose(arq);


    //fclose( prof );
    free( hvolt );
    cudaFree( dvoltA );
    cudaFree( dvoltB );
    cudaFree( dv );
    //
    // cudaDeviceSynchronize();
    // gettimeofday(&timecheck, NULL);
    // end = (long)timecheck.tv_sec * 1000 + (long)timecheck.tv_usec / 1000;
    //printf("CPU elapsed time: %f s (%ld milliseconds)\n", ((end - start)/1000.0), (end - start));
    //
    cudaEventDestroy( dstart );
    cudaEventDestroy( dstop );
    cudaDeviceReset();
    //
    return 0;
}

	.file	"tmpxft_002c0843_00000000-6_2DstencilGPUSharedMemoryKarma.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB3639:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE3639:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"/home/ubuntu/Datasets/stackv2/train-structured/sabiomito/uffgpu2019/master/PROJETO/2DstencilGPUSharedMemoryKarma.cu"
.LC1:
	.string	"%s in %s at line %d\n"
	.text
	.type	_ZL11HandleError9cudaErrorPKci.constprop.0, @function
_ZL11HandleError9cudaErrorPKci.constprop.0:
.LFB4284:
	.cfi_startproc
	testl	%edi, %edi
	je	.L2
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	%esi, 12(%rsp)
	call	cudaGetErrorString@PLT
	movl	12(%rsp), %r8d
	movl	$2, %edi
	leaq	.LC0(%rip), %rcx
	movq	%rax, %rdx
	leaq	.LC1(%rip), %rsi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	$1, %edi
	call	exit@PLT
.L2:
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE4284:
	.size	_ZL11HandleError9cudaErrorPKci.constprop.0, .-_ZL11HandleError9cudaErrorPKci.constprop.0
	.globl	_Z33__device_stub__Z8timeStepPKfPfS1_PKfPfS1_
	.type	_Z33__device_stub__Z8timeStepPKfPfS1_PKfPfS1_, @function
_Z33__device_stub__Z8timeStepPKfPfS1_PKfPfS1_:
.LFB3661:
	.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
	movq	%rdx, 8(%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	8(%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	.L8
	pushq	40(%rsp)
	.cfi_def_cfa_offset 152
	leaq	_Z8timeStepPKfPfS1_(%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
.L8:
	movq	120(%rsp), %rax
	subq	%fs:40, %rax
	je	.L10
	call	__stack_chk_fail@PLT
.L10:
	addq	$136, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3661:
	.size	_Z33__device_stub__Z8timeStepPKfPfS1_PKfPfS1_, .-_Z33__device_stub__Z8timeStepPKfPfS1_PKfPfS1_
	.globl	_Z8timeStepPKfPfS1_
	.type	_Z8timeStepPKfPfS1_, @function
_Z8timeStepPKfPfS1_:
.LFB3662:
	.cfi_startproc
	endbr64
	jmp	_Z33__device_stub__Z8timeStepPKfPfS1_PKfPfS1_
	.cfi_endproc
.LFE3662:
	.size	_Z8timeStepPKfPfS1_, .-_Z8timeStepPKfPfS1_
	.section	.rodata.str1.1
.LC2:
	.string	"rt"
.LC3:
	.string	"entrada.txt"
.LC4:
	.string	"Failed to launch _3Dstencil_global kernel (error code %s)!\n"
.LC5:
	.string	"[%d,%.5f]"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB3636:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	movl	$3, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$104, %rsp
	.cfi_def_cfa_offset 144
	movq	%fs:40, %rax
	movq	%rax, 88(%rsp)
	xorl	%eax, %eax
	decl	%edi
	jle	.L14
	movq	8(%rsi), %rdi
	call	atoi@PLT
	movl	%eax, %r12d
.L14:
	leaq	8(%rsp), %rdi
	leaq	.LC4(%rip), %r13
	call	cudaEventCreate@PLT
	leaq	16(%rsp), %rdi
	call	cudaEventCreate@PLT
	xorl	%esi, %esi
	leaq	72(%rsp), %rdi
	call	gettimeofday@PLT
	xorl	%edi, %edi
	call	malloc@PLT
	xorl	%edi, %edi
	movq	%rax, %rbx
	call	malloc@PLT
	leaq	.LC2(%rip), %rsi
	leaq	.LC3(%rip), %rdi
	movq	%rax, %rbp
	call	fopen@PLT
	movq	%rax, %rdi
	call	fclose@PLT
	xorl	%esi, %esi
	leaq	24(%rsp), %rdi
	call	cudaMalloc@PLT
	movl	$211, %esi
	movl	%eax, %edi
	call	_ZL11HandleError9cudaErrorPKci.constprop.0
	xorl	%esi, %esi
	leaq	32(%rsp), %rdi
	call	cudaMalloc@PLT
	movl	$212, %esi
	movl	%eax, %edi
	call	_ZL11HandleError9cudaErrorPKci.constprop.0
	xorl	%esi, %esi
	leaq	40(%rsp), %rdi
	call	cudaMalloc@PLT
	movl	$213, %esi
	movl	%eax, %edi
	call	_ZL11HandleError9cudaErrorPKci.constprop.0
	movq	24(%rsp), %rdi
	xorl	%edx, %edx
	movq	%rbx, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movl	$215, %esi
	movl	%eax, %edi
	call	_ZL11HandleError9cudaErrorPKci.constprop.0
	movq	32(%rsp), %rdi
	xorl	%edx, %edx
	movq	%rbx, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movl	$216, %esi
	movl	%eax, %edi
	call	_ZL11HandleError9cudaErrorPKci.constprop.0
	movq	40(%rsp), %rdi
	xorl	%edx, %edx
	movq	%rbp, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movl	$217, %esi
	movl	%eax, %edi
	call	_ZL11HandleError9cudaErrorPKci.constprop.0
	movq	%rbp, %rdi
	call	free@PLT
	xorl	%eax, %eax
	movl	$1, 56(%rsp)
	movq	%rax, 48(%rsp)
	movabsq	$137438953504, %rax
	movq	%rax, 60(%rsp)
	movl	$1, 68(%rsp)
	call	cudaDeviceSynchronize@PLT
	movq	8(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	xorl	%ebp, %ebp
.L15:
	cmpl	%ebp, %r12d
	jle	.L30
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	testl	$1, %ebp
	movl	68(%rsp), %ecx
	movq	60(%rsp), %rdx
	movq	48(%rsp), %rdi
	movl	56(%rsp), %esi
	jne	.L16
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L18
	movq	32(%rsp), %rdx
	movq	40(%rsp), %rsi
	movq	24(%rsp), %rdi
	jmp	.L29
.L16:
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L18
	movq	24(%rsp), %rdx
	movq	40(%rsp), %rsi
	movq	32(%rsp), %rdi
.L29:
	call	_Z33__device_stub__Z8timeStepPKfPfS1_PKfPfS1_
.L18:
	call	cudaGetLastError@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L20
	call	cudaGetErrorString@PLT
	movq	stderr(%rip), %rdi
	movq	%r13, %rdx
	movl	$2, %esi
	movq	%rax, %rcx
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
.L20:
	incl	%ebp
	jmp	.L15
.L30:
	call	cudaDeviceSynchronize@PLT
	movq	16(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	16(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movq	16(%rsp), %rdx
	movq	8(%rsp), %rsi
	leaq	4(%rsp), %rdi
	call	cudaEventElapsedTime@PLT
	xorl	%edx, %edx
	leaq	.LC5(%rip), %rsi
	movb	$1, %al
	movl	$2, %edi
	cvtss2sd	4(%rsp), %xmm0
	call	__printf_chk@PLT
	movq	%rbx, %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	8(%rsp), %rdi
	call	cudaEventDestroy@PLT
	movq	16(%rsp), %rdi
	call	cudaEventDestroy@PLT
	call	cudaDeviceReset@PLT
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	je	.L22
	call	__stack_chk_fail@PLT
.L22:
	addq	$104, %rsp
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3636:
	.size	main, .-main
	.section	.rodata.str1.1
.LC6:
	.string	"_Z8timeStepPKfPfS1_"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB3664:
	.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	.LC6(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z8timeStepPKfPfS1_(%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
.LFE3664:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:


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



//===> FINITE DIFFERENCES PARAMETERS <===//
#define DT 0.05f                   //->Time in milliseconds
#define DX ( 12.0f / MODELSIZE_X ) //->Displacement in x
#define DY ( 12.0f / MODELSIZE_Y ) //->Displacement in y

//===> CONSTANTES <===//
#define Eh 3.0f
#define En 1.0f
#define Re 0.6f
#define tauE 5.0f
#define tauN 250.0f
#define gam 0.001f
#define East 1.5415f

//===> INITIAL CONDITIONS <===//
#define v0 0.5f
#define VOLT0 3.0f

//==> DISCRETE DOMAIN <==//
#ifndef MODEL_WIDTH
#define MODEL_WIDTH 0
#endif

#define MODELSIZE_X (MODEL_WIDTH)
#define MODELSIZE_Y (MODEL_WIDTH)
#define MODELSIZE_Z 1
#define MODELSIZE2D ( MODELSIZE_X*MODELSIZE_Y )

//==> CUDA THREAD BLOCK <==//
//#define TILESIZE   32
//#define BLOCKDIM_X ( TILESIZE )
//#define BLOCKDIM_Y ( TILESIZE )

#ifndef BLOCKDIM_X
#define BLOCKDIM_X 32
#endif

#ifndef BLOCKDIM_Y
#define BLOCKDIM_Y 32
#endif

#define BLOCKDIM_Z 1
#define BLOCKDIM2D ( BLOCKDIM_X*BLOCKDIM_Y )

//==> CUDA GRID <==//
#define GRIDDIM_X ( ( MODELSIZE_X / BLOCKDIM_X ) + ( ( MODELSIZE_X % BLOCKDIM_X ) > 0 ) )
#define GRIDDIM_Y ( ( MODELSIZE_Y / BLOCKDIM_Y ) + ( ( MODELSIZE_Y % BLOCKDIM_Y ) > 0 ) )
#define GRIDDIM_Z 1


//////////////////////////////////////////////////////////////////////////
static void HandleError( hipError_t err,
                         const char *file,
                         int line ) {
    if (err != hipSuccess) {
        printf( "%s in %s at line %d\n", hipGetErrorString( err ),
                file, line );
        exit( EXIT_FAILURE );
    }
}
#define HANDLE_ERROR( err ) (HandleError( err, __FILE__, __LINE__ ))
//////////////////////////////////////////////////////////////////////////


__global__ void timeStep( const float *voltIN, float *v, float *voltOUT )
{
    int x = blockIdx.x*BLOCKDIM_X + threadIdx.x;
    int y = blockIdx.y*BLOCKDIM_Y + threadIdx.y;

    __shared__ float U[BLOCKDIM_X+2][BLOCKDIM_Y+2];

    if ( x < MODELSIZE_X && y < MODELSIZE_Y ) 
    {
        //
        int idx = y*MODELSIZE_X + x;

        int i = threadIdx.x+1;
        int j = threadIdx.y+1;

        U[i][j] = voltIN[idx];

        __syncthreads();

        float rv = v[idx];

        if ( threadIdx.y == 0 )
        U[i][0] = voltIN[(idx - ((y>0)-(y==0))*MODELSIZE_X)];
        else if ( threadIdx.y == (BLOCKDIM_Y-1) )
        U[i][(BLOCKDIM_Y+1)] = voltIN[(idx + ((y<MODELSIZE_Y-1)-(y==MODELSIZE_Y-1))*MODELSIZE_X)];

        if ( threadIdx.x == 0 )
        U[0][j] = voltIN[(idx - (x>0) + (x==0))];
        else if ( threadIdx.x == (BLOCKDIM_X-1) )
        U[(BLOCKDIM_X+1)][j] = voltIN[(idx + (x<MODELSIZE_X-1)-(x==MODELSIZE_X-1))];
        

        float Rn = ( 1.0f / ( 1.0f - expf(-Re) ) ) - rv;
        float p = ( U[i][j] > En ) * 1.0f;
        float dv = ( Rn * p - ( 1.0f - p ) * rv ) / tauN;
        float Dn = rv * rv;
        float hE = ( 1.0f - tanh(U[i][j] - Eh) ) * U[i][j] * U[i][j] / 2.0f;
        float du = ( ( ( East - Dn ) * hE ) - U[i][j] ) / tauE;

        float xlapr = U[i+1][j] - U[i][j];
        float xlapl = U[i][j]   - U[i-1][j];
        float xlapf = U[i][j+1] - U[i][j];
        float xlapb = U[i][j]   - U[i][j-1];

        float lap = xlapr - xlapl + xlapf - xlapb;

        voltOUT[idx] = ( U[i][j] + ( du * DT ) + ( lap * DT * gam / ( DX * DX ) ) );
        v[idx]       = rv + dv*DT;
    }
}

int main( int argc, char *argv[] )
{
    int nsteps = 3; //8000;
    // if ( argc > 1 ) 
    // {
    //     char *p;
    //     long conv = strtol(argv[1], &p, 10);
    //     //
    //     // Check for errors: e.g., the string does not represent an integer
    //     // or the integer is larger than int
    //     if (*p != '\0' || conv > INT_MAX) 
    //     {
    //         printf("Error with argument 1!");
    //         return 3;
    //     }
    //     else
    //     nsteps = int(conv/DT);
    // }
    if (argc > 1)
    {
        nsteps = atoi(argv[1]);
    }
    //
    hipEvent_t dstart,dstop;
    hipEventCreate( &dstart );
    hipEventCreate( &dstop );
    //
    long start, end;
    struct timeval timecheck;
    gettimeofday(&timecheck, NULL);
    start = (long)timecheck.tv_sec * 1000 + (long)timecheck.tv_usec / 1000;
    //
    float *hvolt, *hv;
    hvolt = (float*) malloc( MODELSIZE2D*sizeof(float) );
    hv    = (float*) malloc( MODELSIZE2D*sizeof(float) );

    // int x, y, idx;
    // for( y = 0; y < MODELSIZE_Y; y++ )
    // {
    //     for( x = 0; x < MODELSIZE_X; x++ )
    //     {
    //         idx = y*MODELSIZE_X + x;
    //         //
    //         hv[idx] = 0.5f;
    //         //
    //         if ( y < 10*(MODELSIZE_Y/20) && y > 8*(MODELSIZE_Y/20) && x < 10*(MODELSIZE_Y/20) &&  x > 8*(MODELSIZE_Y/20))
    //         hvolt[idx] = VOLT0;
    //         else
    //         hvolt[idx] = 0.0f;
    //         //
    //     }
    // }

     FILE *arq;
    arq = fopen("entrada.txt", "rt");
    for(int i=0;i<MODELSIZE_X;i++)
        for(int j=0;j<MODELSIZE_Y;j++)
        {
            hv[i+j*MODELSIZE_X] = 0.5f;
            int temp;
            fscanf(arq," %d",&temp);
            hvolt[i+j*MODELSIZE_X] = temp;
        }
            
    fclose(arq);

    // FILE *prof;
    // char fpname[100];
    // sprintf(fpname, "./profiles_%d_k2D_shared.csv",MODELSIZE_X);
    // prof = fopen(fpname,"w");
    // fprintf(prof,"index,timestep,P\n");
    // fprintf(prof,"0,%6.4f",0.0);
    // fclose(prof);


    dim3 point;
    //int pointIdx;
    point.x = MODELSIZE_X/2;
    point.y = MODELSIZE_Y/2;
    point.z = 0;
   // pointIdx = point.y*MODELSIZE_X + point.x;


    //fprintf(prof,",%6.4f\n",hvolt[pointIdx]);


    float *dvoltA, *dvoltB, *dv;
    HANDLE_ERROR( hipMalloc( (void**)&dvoltA, MODELSIZE2D*sizeof(float) ) );
    HANDLE_ERROR( hipMalloc( (void**)&dvoltB, MODELSIZE2D*sizeof(float) ) );
    HANDLE_ERROR( hipMalloc( (void**)&dv    , MODELSIZE2D*sizeof(float) ) );

    HANDLE_ERROR( hipMemcpy( dvoltA, hvolt, MODELSIZE2D*sizeof(float), hipMemcpyHostToDevice ) );
    HANDLE_ERROR( hipMemcpy( dvoltB, hvolt, MODELSIZE2D*sizeof(float), hipMemcpyHostToDevice ) );
    HANDLE_ERROR( hipMemcpy( dv    , hv   , MODELSIZE2D*sizeof(float), hipMemcpyHostToDevice ) );

    free( hv );

    dim3 blocks(GRIDDIM_X,GRIDDIM_Y,GRIDDIM_Z);
    dim3 threads(BLOCKDIM_X,BLOCKDIM_Y,BLOCKDIM_Z);

    //int nsamples = (nsteps >= 2000)*2000 + (nsteps < 2000)*nsteps;
    //int j = nsteps/nsamples;
    hipDeviceSynchronize();
    hipEventRecord( dstart, 0 );
    int i=0;
    for (i = 0; i < nsteps; i++ ) 
    {
        if ( (i%2) == 0 ) //==> EVEN
        timeStep<<<blocks, threads>>>( dvoltA, dv, dvoltB );
        else              //==> ODD
        timeStep<<<blocks, threads>>>( dvoltB, dv, dvoltA );
        //
        /*if ( (i%j) == 0 ) {
        if ( (i%2) == 0 ) //==> EVEN
        HANDLE_ERROR( cudaMemcpy( hvolt, dvoltB, MODELSIZE3D*sizeof(float), cudaMemcpyDeviceToHost ) );
        else              //==> ODD
        HANDLE_ERROR( cudaMemcpy( hvolt, dvoltA, MODELSIZE3D*sizeof(float), cudaMemcpyDeviceToHost ) );
        //
        fprintf(prof,"%d,%6.4f,%6.4f\n", (i+1), ((i+1)*DT), hvolt[pointIdx]);
        }*/
        hipError_t err = hipSuccess;
        err = hipGetLastError();
        if (err != hipSuccess)
        {
            fprintf(stderr, "Failed to launch _3Dstencil_global kernel (error code %s)!\n", hipGetErrorString(err));
        }
    }
    hipDeviceSynchronize();
    hipEventRecord( dstop, 0 );
    hipEventSynchronize ( dstop );
    float elapsed;
    hipEventElapsedTime( &elapsed, dstart, dstop );
    //printf("GPU elapsed time: %f s (%f milliseconds)\n", (elapsed/1000.0), elapsed);

    //arq = fopen("TempoExecucaoOrig12000.txt", "a");
    //printf("X %d || Y %d \nBX %d || BY %d \n",X,Y,BX,BY);
        //fprintf (arq,"[%d,%.5f],\n",MODEL_WIDTH,elapsed);
        printf ("[%d,%.5f]",0,elapsed);
    //fclose(arq);



    // if ( (i%2) == 0 )
    // HANDLE_ERROR( cudaMemcpy( hvolt, dvoltA, MODELSIZE2D*sizeof(float), cudaMemcpyDeviceToHost ) );
    // else
    // HANDLE_ERROR( cudaMemcpy( hvolt, dvoltB, MODELSIZE2D*sizeof(float), cudaMemcpyDeviceToHost ) );


    // arq = fopen("resultado.txt", "wt");
    // for(int i=0;i<MODELSIZE_X;i++)
    // {
    //     for(int j=0;j<MODELSIZE_Y;j++)
    //     {
    //         fprintf(arq," %6.4f",hvolt[i+j*MODELSIZE_X]);
    //     }
    //     fprintf(arq,"\n");
    // }
    // fclose(arq);


    //fclose( prof );
    free( hvolt );
    hipFree( dvoltA );
    hipFree( dvoltB );
    hipFree( dv );
    //
    // cudaDeviceSynchronize();
    // gettimeofday(&timecheck, NULL);
    // end = (long)timecheck.tv_sec * 1000 + (long)timecheck.tv_usec / 1000;
    //printf("CPU elapsed time: %f s (%ld milliseconds)\n", ((end - start)/1000.0), (end - start));
    //
    hipEventDestroy( dstart );
    hipEventDestroy( dstop );
    hipDeviceReset();
    //
    return 0;
}

	.text
	.file	"2DstencilGPUSharedMemoryKarma.hip"
                                        # Start of file scope inline assembly
	.globl	_ZSt21ios_base_library_initv

                                        # End of file scope inline assembly
	.globl	_Z23__device_stub__timeStepPKfPfS1_ # -- Begin function _Z23__device_stub__timeStepPKfPfS1_
	.type	_Z23__device_stub__timeStepPKfPfS1_,@function
_Z23__device_stub__timeStepPKfPfS1_:    # @_Z23__device_stub__timeStepPKfPfS1_
	.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	24(%rsp), %rsi
	movq	%rdx, (%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	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	$_Z8timeStepPKfPfS1_, %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	_Z23__device_stub__timeStepPKfPfS1_, .Lfunc_end0-_Z23__device_stub__timeStepPKfPfS1_
	.cfi_endproc
                                        # -- End function
	.globl	main                            # -- Begin function 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	$72, %rsp
	.cfi_def_cfa_offset 128
	.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	$3, %ebp
	cmpl	$2, %edi
	jl	.LBB1_2
# %bb.1:
	movq	8(%rsi), %rdi
	callq	atoi
	movl	%eax, %ebp
.LBB1_2:
	leaq	40(%rsp), %rdi
	callq	hipEventCreate
	leaq	8(%rsp), %rdi
	callq	hipEventCreate
	leaq	56(%rsp), %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	xorl	%edi, %edi
	callq	malloc
	movq	%rax, %rbx
	xorl	%edi, %edi
	callq	malloc
	movq	%rax, %r15
	movl	$.L.str, %edi
	movl	$.L.str.1, %esi
	callq	fopen
	movq	%rax, %rdi
	callq	fclose
	leaq	32(%rsp), %r14
	movq	%r14, %rdi
	xorl	%esi, %esi
	callq	hipMalloc
	movl	%eax, %edi
	movl	$213, %esi
	callq	_ZL11HandleError10hipError_tPKci
	leaq	24(%rsp), %r13
	movq	%r13, %rdi
	xorl	%esi, %esi
	callq	hipMalloc
	movl	%eax, %edi
	movl	$214, %esi
	callq	_ZL11HandleError10hipError_tPKci
	leaq	16(%rsp), %r12
	movq	%r12, %rdi
	xorl	%esi, %esi
	callq	hipMalloc
	movl	%eax, %edi
	movl	$215, %esi
	callq	_ZL11HandleError10hipError_tPKci
	movq	(%r14), %rdi
	movq	%rbx, %rsi
	xorl	%edx, %edx
	movl	$1, %ecx
	callq	hipMemcpy
	movl	%eax, %edi
	movl	$217, %esi
	callq	_ZL11HandleError10hipError_tPKci
	movq	(%r13), %rdi
	movq	%rbx, %rsi
	xorl	%edx, %edx
	movl	$1, %ecx
	callq	hipMemcpy
	movl	%eax, %edi
	movl	$218, %esi
	callq	_ZL11HandleError10hipError_tPKci
	movq	(%r12), %rdi
	movq	%r15, %rsi
	xorl	%edx, %edx
	movl	$1, %ecx
	callq	hipMemcpy
	movl	%eax, %edi
	movl	$219, %esi
	callq	_ZL11HandleError10hipError_tPKci
	movq	%r15, %rdi
	callq	free
	callq	hipDeviceSynchronize
	leaq	40(%rsp), %rax
	movq	(%rax), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	testl	%ebp, %ebp
	jle	.LBB1_13
# %bb.3:                                # %.lr.ph.preheader
	movabsq	$137438953504, %r14             # imm = 0x2000000020
	xorl	%r12d, %r12d
.LBB1_4:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	xorl	%edi, %edi
	movl	$1, %esi
	movq	%r14, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testb	$1, %r12b
	jne	.LBB1_7
# %bb.5:                                #   in Loop: Header=BB1_4 Depth=1
	testl	%eax, %eax
	jne	.LBB1_10
# %bb.6:                                #   in Loop: Header=BB1_4 Depth=1
	movq	32(%rsp), %rdi
	movq	16(%rsp), %rsi
	movq	24(%rsp), %rdx
	jmp	.LBB1_9
.LBB1_7:                                #   in Loop: Header=BB1_4 Depth=1
	testl	%eax, %eax
	jne	.LBB1_10
# %bb.8:                                #   in Loop: Header=BB1_4 Depth=1
	movq	24(%rsp), %rdi
	movq	16(%rsp), %rsi
	movq	32(%rsp), %rdx
.LBB1_9:                                #   in Loop: Header=BB1_4 Depth=1
	callq	_Z23__device_stub__timeStepPKfPfS1_
.LBB1_10:                               #   in Loop: Header=BB1_4 Depth=1
	callq	hipGetLastError
	testl	%eax, %eax
	jne	.LBB1_11
.LBB1_12:                               #   in Loop: Header=BB1_4 Depth=1
	incl	%r12d
	cmpl	%r12d, %ebp
	jne	.LBB1_4
	jmp	.LBB1_13
.LBB1_11:                               #   in Loop: Header=BB1_4 Depth=1
	movq	stderr(%rip), %r15
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.4, %esi
	movq	%r15, %rdi
	movq	%rax, %rdx
	xorl	%eax, %eax
	callq	fprintf
	jmp	.LBB1_12
.LBB1_13:                               # %._crit_edge
	callq	hipDeviceSynchronize
	movq	8(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	8(%rsp), %rdi
	callq	hipEventSynchronize
	movq	40(%rsp), %rsi
	movq	8(%rsp), %rdx
	leaq	52(%rsp), %r14
	movq	%r14, %rdi
	callq	hipEventElapsedTime
	cvtss2sd	(%r14), %xmm0
	movl	$.L.str.5, %edi
	xorl	%esi, %esi
	movb	$1, %al
	callq	printf
	movq	%rbx, %rdi
	callq	free
	movq	32(%rsp), %rdi
	callq	hipFree
	movq	24(%rsp), %rdi
	callq	hipFree
	movq	16(%rsp), %rdi
	callq	hipFree
	movq	40(%rsp), %rdi
	callq	hipEventDestroy
	movq	8(%rsp), %rdi
	callq	hipEventDestroy
	callq	hipDeviceReset
	xorl	%eax, %eax
	addq	$72, %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_end1:
	.size	main, .Lfunc_end1-main
	.cfi_endproc
                                        # -- End function
	.type	_ZL11HandleError10hipError_tPKci,@function # -- Begin function _ZL11HandleError10hipError_tPKci
_ZL11HandleError10hipError_tPKci:       # @_ZL11HandleError10hipError_tPKci
	.cfi_startproc
# %bb.0:
	testl	%edi, %edi
	jne	.LBB2_2
# %bb.1:
	retq
.LBB2_2:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset %rbx, -16
	movl	%esi, %ebx
	callq	hipGetErrorString
	movl	$.L.str.6, %edi
	movl	$.L.str.3, %edx
	movq	%rax, %rsi
	movl	%ebx, %ecx
	xorl	%eax, %eax
	callq	printf
	movl	$1, %edi
	callq	exit
.Lfunc_end2:
	.size	_ZL11HandleError10hipError_tPKci, .Lfunc_end2-_ZL11HandleError10hipError_tPKci
	.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	.LBB3_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB3_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z8timeStepPKfPfS1_, %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_end3:
	.size	__hip_module_ctor, .Lfunc_end3-__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	.LBB4_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
.LBB4_2:
	retq
.Lfunc_end4:
	.size	__hip_module_dtor, .Lfunc_end4-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	_Z8timeStepPKfPfS1_,@object     # @_Z8timeStepPKfPfS1_
	.section	.rodata,"a",@progbits
	.globl	_Z8timeStepPKfPfS1_
	.p2align	3, 0x0
_Z8timeStepPKfPfS1_:
	.quad	_Z23__device_stub__timeStepPKfPfS1_
	.size	_Z8timeStepPKfPfS1_, 8

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"entrada.txt"
	.size	.L.str, 12

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"rt"
	.size	.L.str.1, 3

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"/home/ubuntu/Datasets/stackv2/train-structured-repos-hip-sm89/sabiomito/uffgpu2019/master/PROJETO/2DstencilGPUSharedMemoryKarma.hip"
	.size	.L.str.3, 132

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"Failed to launch _3Dstencil_global kernel (error code %s)!\n"
	.size	.L.str.4, 60

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"[%d,%.5f]"
	.size	.L.str.5, 10

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"%s in %s at line %d\n"
	.size	.L.str.6, 21

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z8timeStepPKfPfS1_"
	.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 _Z23__device_stub__timeStepPKfPfS1_
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z8timeStepPKfPfS1_
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z8timeStepPKfPfS1_     ; -- Begin function _Z8timeStepPKfPfS1_
	.globl	_Z8timeStepPKfPfS1_
	.p2align	8
	.type	_Z8timeStepPKfPfS1_,@function
_Z8timeStepPKfPfS1_:                    ; @_Z8timeStepPKfPfS1_
; %bb.0:
	v_and_b32_e32 v10, 0x3ff, v0
	v_bfe_u32 v9, v0, 10, 10
	s_mov_b32 s2, exec_lo
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_lshl_add_u32 v6, s14, 5, v10
	v_lshl_add_u32 v0, s15, 5, v9
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_and_b32_e32 v0, v6, v0
	v_cmpx_gt_i32_e32 0, v0
	s_cbranch_execz .LBB0_22
; %bb.1:
	s_clause 0x1
	s_load_b128 s[4:7], s[0:1], 0x0
	s_load_b64 s[2:3], s[0:1], 0x10
	v_ashrrev_i32_e32 v7, 31, v6
	v_lshlrev_b32_e32 v3, 2, v9
	s_mov_b32 s0, exec_lo
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_lshlrev_b64 v[0:1], 2, v[6:7]
	v_mad_u32_u24 v8, 0x88, v10, v3
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_co_u32 v4, vcc_lo, s4, v0
	v_add_co_ci_u32_e32 v5, vcc_lo, s5, v1, vcc_lo
	global_load_b32 v2, v[4:5], off
	s_waitcnt vmcnt(0)
	ds_store_b32 v8, v2 offset:140
	v_add_co_u32 v2, vcc_lo, s6, v0
	v_add_co_ci_u32_e32 v3, vcc_lo, s7, v1, vcc_lo
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	global_load_b32 v7, v[2:3], off
	v_cmpx_lt_i32_e32 30, v9
	s_xor_b32 s0, exec_lo, s0
	s_cbranch_execz .LBB0_5
; %bb.2:                                ; %LeafBlock94
	s_mov_b32 s1, exec_lo
	v_cmpx_eq_u32_e32 31, v9
	s_cbranch_execz .LBB0_4
; %bb.3:
	global_load_b32 v11, v[4:5], off
	v_mul_u32_u24_e32 v12, 0x88, v10
	s_waitcnt vmcnt(0)
	ds_store_b32 v12, v11 offset:268
.LBB0_4:                                ; %Flow105
	s_or_b32 exec_lo, exec_lo, s1
.LBB0_5:                                ; %Flow107
	s_and_not1_saveexec_b32 s0, s0
	s_cbranch_execz .LBB0_9
; %bb.6:                                ; %LeafBlock
	s_mov_b32 s1, exec_lo
	v_cmpx_eq_u32_e32 0, v9
	s_cbranch_execz .LBB0_8
; %bb.7:
	global_load_b32 v11, v[4:5], off
	v_mul_u32_u24_e32 v12, 0x88, v10
	s_waitcnt vmcnt(0)
	ds_store_b32 v12, v11 offset:136
.LBB0_8:                                ; %Flow106
	s_or_b32 exec_lo, exec_lo, s1
.LBB0_9:
	s_delay_alu instid0(SALU_CYCLE_1)
	s_or_b32 exec_lo, exec_lo, s0
	s_mov_b32 s1, 0
	s_mov_b32 s0, exec_lo
                                        ; implicit-def: $sgpr6
	v_cmpx_lt_i32_e32 30, v10
	s_xor_b32 s0, exec_lo, s0
	s_cbranch_execz .LBB0_13
; %bb.10:                               ; %LeafBlock98
	s_mov_b32 s7, exec_lo
                                        ; implicit-def: $sgpr6
                                        ; implicit-def: $vgpr4_vgpr5
	v_cmpx_eq_u32_e32 31, v10
; %bb.11:
	v_cmp_gt_i32_e32 vcc_lo, -1, v6
	s_mov_b32 s1, exec_lo
	s_movk_i32 s6, 0x1188
	v_add_co_ci_u32_e32 v4, vcc_lo, 0, v6, vcc_lo
	v_cmp_eq_u32_e32 vcc_lo, -1, v6
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_subrev_co_ci_u32_e32 v4, vcc_lo, 0, v4, vcc_lo
	v_ashrrev_i32_e32 v5, 31, v4
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[4:5], 2, v[4:5]
	v_add_co_u32 v4, vcc_lo, s4, v4
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v5, vcc_lo, s5, v5, vcc_lo
; %bb.12:                               ; %Flow103
	s_or_b32 exec_lo, exec_lo, s7
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_b32 s1, s1, exec_lo
                                        ; implicit-def: $vgpr10
.LBB0_13:                               ; %Flow102
	s_or_saveexec_b32 s0, s0
	v_mov_b32_e32 v6, s6
	s_xor_b32 exec_lo, exec_lo, s0
; %bb.14:                               ; %LeafBlock96
	v_cmp_eq_u32_e32 vcc_lo, 0, v10
	v_mov_b32_e32 v6, 0
	s_and_not1_b32 s1, s1, exec_lo
	s_and_b32 s4, vcc_lo, exec_lo
	s_delay_alu instid0(SALU_CYCLE_1)
	s_or_b32 s1, s1, s4
; %bb.15:                               ; %Flow104
	s_or_b32 exec_lo, exec_lo, s0
	s_and_saveexec_b32 s0, s1
	s_cbranch_execz .LBB0_17
; %bb.16:                               ; %.sink.split
	global_load_b32 v4, v[4:5], off
	v_lshl_add_u32 v5, v9, 2, v6
	s_waitcnt vmcnt(0)
	ds_store_b32 v5, v4 offset:4
.LBB0_17:
	s_or_b32 exec_lo, exec_lo, s0
	ds_load_b32 v4, v8 offset:140
                                        ; implicit-def: $vgpr6
	s_waitcnt lgkmcnt(0)
	v_add_f32_e32 v5, 0xc0400000, v4
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cmp_ngt_f32_e64 s0, 0x3f200000, |v5|
	s_and_saveexec_b32 s1, s0
	s_delay_alu instid0(SALU_CYCLE_1)
	s_xor_b32 s0, exec_lo, s1
	s_cbranch_execz .LBB0_19
; %bb.18:
	v_add_f32_e64 v6, |v5|, |v5|
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_mul_f32_e32 v9, 0x3fb8aa3b, v6
	v_cmp_ngt_f32_e32 vcc_lo, 0xc2ce8ed0, v6
	v_rndne_f32_e32 v10, v9
	v_fma_f32 v11, 0x3fb8aa3b, v6, -v9
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_sub_f32_e32 v9, v9, v10
	v_fmamk_f32 v11, v6, 0x32a5705f, v11
	v_cvt_i32_f32_e32 v10, v10
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f32_e32 v9, v9, v11
	v_exp_f32_e32 v9, v9
	s_waitcnt_depctr 0xfff
	v_ldexp_f32 v9, v9, v10
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_cndmask_b32_e32 v9, 0, v9, vcc_lo
	v_cmp_nlt_f32_e32 vcc_lo, 0x42b17218, v6
	v_cndmask_b32_e32 v6, 0x7f800000, v9, vcc_lo
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f32_e32 v6, 1.0, v6
	v_rcp_f32_e32 v6, v6
	s_waitcnt_depctr 0xfff
	v_fma_f32 v6, v6, -2.0, 1.0
.LBB0_19:                               ; %Flow
	s_and_not1_saveexec_b32 s0, s0
; %bb.20:
	v_mul_f32_e32 v6, v5, v5
	s_mov_b32 s1, 0xbbbac73d
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	v_fmaak_f32 v9, s1, v6, 0x3ca908c9
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fmaak_f32 v9, v6, v9, 0xbd5c1c4e
	v_fmaak_f32 v9, v6, v9, 0x3e088382
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fmaak_f32 v9, v6, v9, 0xbeaaaa99
	v_mul_f32_e64 v9, |v5|, v9
	s_delay_alu instid0(VALU_DEP_1)
	v_fma_f32 v6, v6, v9, |v5|
; %bb.21:                               ; %_ZL4tanhf.exit
	s_or_b32 exec_lo, exec_lo, s0
	ds_load_2addr_b32 v[9:10], v8 offset0:36 offset1:69
	ds_load_2addr_b32 v[11:12], v8 offset0:1 offset1:34
	v_cmp_lt_f32_e32 vcc_lo, 1.0, v4
	v_bfi_b32 v5, 0x7fffffff, v6, v5
	v_cndmask_b32_e64 v6, 0, 1.0, vcc_lo
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_sub_f32_e32 v5, 1.0, v5
	v_sub_f32_e32 v13, 1.0, v6
	s_waitcnt vmcnt(0) lgkmcnt(1)
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_4) | instid1(VALU_DEP_2)
	v_dual_mul_f32 v13, v7, v13 :: v_dual_sub_f32 v8, v10, v4
	s_waitcnt lgkmcnt(0)
	v_sub_f32_e32 v12, v4, v12
	v_sub_f32_e32 v10, v4, v11
	v_sub_f32_e32 v11, 0x400dd8fe, v7
	v_dual_sub_f32 v9, v9, v4 :: v_dual_sub_f32 v8, v8, v10
	v_fma_f32 v10, -v7, v7, 0x3fc54fdf
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_fma_f32 v6, v11, v6, -v13
	v_add_f32_e32 v8, v8, v9
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_div_scale_f32 v9, null, 0x437a0000, 0x437a0000, v6
	v_div_scale_f32 v15, vcc_lo, v6, 0x437a0000, v6
	v_rcp_f32_e32 v11, v9
	s_waitcnt_depctr 0xfff
	v_fma_f32 v14, -v9, v11, 1.0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_dual_fmac_f32 v11, v14, v11 :: v_dual_sub_f32 v8, v8, v12
	v_dual_mul_f32 v5, v4, v5 :: v_dual_mul_f32 v8, 0x3d4ccccd, v8
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_dual_mul_f32 v5, v4, v5 :: v_dual_mul_f32 v8, 0x3a83126f, v8
	v_mul_f32_e32 v5, 0.5, v5
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_div_scale_f32 v13, null, 0x7f800000, 0x7f800000, v8
	v_fma_f32 v5, v10, v5, -v4
	v_div_scale_f32 v21, s1, v8, 0x7f800000, v8
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_rcp_f32_e32 v16, v13
	v_div_scale_f32 v10, null, 0x40a00000, 0x40a00000, v5
	v_div_scale_f32 v14, s0, v5, 0x40a00000, v5
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_3) | instid1(VALU_DEP_1)
	v_rcp_f32_e32 v12, v10
	s_waitcnt_depctr 0xfff
	v_fma_f32 v18, -v13, v16, 1.0
	v_fma_f32 v17, -v10, v12, 1.0
	v_dual_fmac_f32 v12, v17, v12 :: v_dual_mul_f32 v17, v15, v11
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_mul_f32_e32 v19, v14, v12
	v_fma_f32 v20, -v9, v17, v15
	v_fmac_f32_e32 v16, v18, v16
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_fma_f32 v18, -v10, v19, v14
	v_fmac_f32_e32 v17, v20, v11
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_fmac_f32_e32 v19, v18, v12
	v_fma_f32 v9, -v9, v17, v15
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_fma_f32 v10, -v10, v19, v14
	v_div_fmas_f32 v9, v9, v11, v17
	s_mov_b32 vcc_lo, s0
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_div_fmas_f32 v10, v10, v12, v19
	v_div_fixup_f32 v6, v9, 0x437a0000, v6
	v_mul_f32_e32 v20, v21, v16
	s_mov_b32 vcc_lo, s1
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_div_fixup_f32 v5, v10, 0x40a00000, v5
	v_fmac_f32_e32 v7, 0x3d4ccccd, v6
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_fma_f32 v15, -v13, v20, v21
	v_fmac_f32_e32 v4, 0x3d4ccccd, v5
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fmac_f32_e32 v20, v15, v16
	v_fma_f32 v11, -v13, v20, v21
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_3)
	v_div_fmas_f32 v10, v11, v16, v20
	v_add_co_u32 v0, vcc_lo, s2, v0
	v_add_co_ci_u32_e32 v1, vcc_lo, s3, v1, vcc_lo
	v_div_fixup_f32 v5, v10, 0x7f800000, v8
	s_delay_alu instid0(VALU_DEP_1)
	v_add_f32_e32 v4, v5, v4
	global_store_b32 v[0:1], v4, off
	global_store_b32 v[2:3], v7, off
.LBB0_22:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z8timeStepPKfPfS1_
		.amdhsa_group_segment_fixed_size 4624
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 24
		.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 22
		.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	_Z8timeStepPKfPfS1_, .Lfunc_end0-_Z8timeStepPKfPfS1_
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 1312
; NumSgprs: 18
; NumVgprs: 22
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 4624 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 2
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 22
; 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
    .group_segment_fixed_size: 4624
    .kernarg_segment_align: 8
    .kernarg_segment_size: 24
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z8timeStepPKfPfS1_
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z8timeStepPKfPfS1_.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     22
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
