#include <stdio.h>
#include <iostream>
#include <cuda_profiler_api.h>
//#include <cutil.h>
#include <cuda_runtime.h>
#include <string>



#define SHARED_MEM_ELEMENTS 1024
#define GLOBAL_MEM_ELEMENTS 196608

int num_blocks;
int num_threads_per_block;
int num_iterations;
int divergence;

__global__ void shared_latency (unsigned long long ** my_ptr_array, unsigned long long * my_array, int array_length, int iterations, unsigned long long * duration, int stride, int divergence, int num_blocks_k, int num_threads_per_block_k) {

//    unsigned long long int start_time, end_time;
    unsigned long long int sum_time = 0;
    int i, k;

    int tid = blockDim.x * blockIdx.x + threadIdx.x;

    int warp_thread_id = threadIdx.x % 32;
    __shared__ unsigned long long sdata[SHARED_MEM_ELEMENTS];

    __shared__ void **tmp_ptr;

    __shared__ void *arr[SHARED_MEM_ELEMENTS];

    if (threadIdx.x == 0) {
        for (i=0; i < SHARED_MEM_ELEMENTS; i++) {
            arr[i] = (void *)&sdata[i];
        }
        for (i=0; i < (SHARED_MEM_ELEMENTS - 1); i++) {
            sdata[i] = (unsigned long long)arr[i+1];
        }
        sdata[SHARED_MEM_ELEMENTS - 1] = (unsigned long long) arr[0];
    }

    __syncthreads();

    tmp_ptr = (void **)(&(arr[(threadIdx.x + stride)%SHARED_MEM_ELEMENTS]));

        double f1, f2, f3;
        f1 = 1.1;
        f2 = 2.5;
    if (warp_thread_id < divergence) {

        for (int l = 0; l < iterations; l++) {
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            tmp_ptr = (void**)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            tmp_ptr = (void**)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            tmp_ptr = (void**)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            tmp_ptr = (void**)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            tmp_ptr = (void**)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            tmp_ptr = (void**)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
        }
    }
//    __syncthreads();

    //    if ((blockDim.x * blockIdx.x + threadIdx.x) == 0)
    duration[tid] = (unsigned long long)(*tmp_ptr) + (f1 * tid);

//    __syncthreads();
}

void usage() {
    std::cout << "Usage ./binary <num_blocks> <num_threads_per_block> <iterations>" "threads active per warp" << std::endl;
}

void parametric_measure_shared(int N, int iterations, int stride) {

    cudaProfilerStop();
    int i;
    unsigned long long int * h_a;
    unsigned long long int * d_a;

    unsigned long long ** h_ptr_a;
    unsigned long long ** d_ptr_a;

    unsigned long long * duration;
    unsigned long long * latency;

    cudaError_t error_id;

    /* allocate array on CPU */
    h_a = (unsigned long long *)malloc(sizeof(unsigned long long int) * N);

    h_ptr_a = (unsigned long long **)malloc(sizeof(unsigned long long int*)*N);

    latency = (unsigned long long *)malloc(sizeof(unsigned long long) * num_threads_per_block * num_blocks);

    /* initialize array elements on CPU */


    for (i = 0; i < N; i++) {
        h_ptr_a[i] = (unsigned long long *)&h_a[i];
    }
    for (i = 0; i < N; i++) {
        h_a[i] = (unsigned long long)h_ptr_a[(i + 1 + stride) % N];
    }

    /* allocate arrays on GPU */
    cudaMalloc ((void **) &d_a, sizeof(unsigned long long int) * N );
    cudaMalloc ((void **) &d_ptr_a, sizeof(unsigned long long int*) * N );
    cudaMalloc ((void **) &duration, sizeof(unsigned long long) * num_threads_per_block * num_blocks);

    cudaThreadSynchronize ();
    error_id = cudaGetLastError();
    if (error_id != cudaSuccess) {
        printf("Error 1 is %s\n", cudaGetErrorString(error_id));
    }

    /* copy array elements from CPU to GPU */
    cudaMemcpy((void *)d_a, (void *)h_a, sizeof(unsigned long long int) * N, cudaMemcpyHostToDevice);
    cudaMemcpy((void *)d_ptr_a, (void *)h_ptr_a, sizeof(unsigned long long int *) * N, cudaMemcpyHostToDevice);
    cudaMemcpy((void *)duration, (void *)latency, sizeof(unsigned long long) * num_threads_per_block * num_blocks, cudaMemcpyHostToDevice);

    cudaThreadSynchronize ();

    error_id = cudaGetLastError();
    if (error_id != cudaSuccess) {
        printf("Error 2 is %s\n", cudaGetErrorString(error_id));
    }

//    init_memory <<<1, 1>>>(d_ptr_a, d_a, stride, num_blocks, num_threads_per_block);
//    cudaDeviceSynchronize();

    /* launch kernel*/
    //dim3 Db = dim3(13);
    //dim3 Dg = dim3(768,1,1);

    //printf("Launch kernel with parameters: %d, N: %d, stride: %d\n", iterations, N, stride);
    //	int sharedMemSize =  sizeof(unsigned long long int) * N ;

    cudaEvent_t start, stop;
    float time;

    cudaEventCreate(&start);
    cudaEventCreate(&stop);

    
    
    

    cudaEventRecord(start, 0);
    cudaProfilerStart();

    cudaFuncSetCacheConfig(shared_latency, cudaFuncCachePreferL1);
    //shared_latency <<<Dg, Db, sharedMemSize>>>(d_a, N, iterations, duration);
    //shared_latency <<<num_blocks, num_threads_per_block, sharedMemSize>>>(d_a, N, num_iterations, duration, stride, divergence);
    shared_latency <<<num_blocks, num_threads_per_block>>>(d_ptr_a, d_a, N, num_iterations, duration, stride, divergence, num_blocks, num_threads_per_block);

    cudaDeviceSynchronize();
    ///cudaThreadSynchronize ();

    cudaProfilerStop();
    cudaEventRecord(stop, 0);
    cudaEventSynchronize(stop);

    cudaEventElapsedTime(&time, start, stop);

    

    error_id = cudaGetLastError();
    if (error_id != cudaSuccess) {
        printf("Error 3 is %s\n", cudaGetErrorString(error_id));
    }

    /* copy results from GPU to CPU */

    cudaMemcpy((void *)h_a, (void *)d_a, sizeof(unsigned long long int) * N, cudaMemcpyDeviceToHost);
    cudaMemcpy((void *)latency, (void *)duration, sizeof(unsigned long long) * num_threads_per_block * num_blocks, cudaMemcpyDeviceToHost);

    cudaThreadSynchronize ();

    /* print results*/


    unsigned long long max_dur = latency[0];
    unsigned long long min_dur = latency[0];
    unsigned long long avg_lat = latency[0];
    for (int i = 1; i < num_threads_per_block * num_blocks; i++) {
        avg_lat += latency[i];
        if (latency[i] > max_dur) {
            max_dur = latency[i];
        } else if (latency[i] < min_dur) {
            min_dur = latency[i];
        }
    }


    //	printf("  %d, %f, %f, %f, %f\n",stride,(double)(avg_lat/(num_threads_per_block * num_blocks * 256.0 *num_iterations)), (double)(min_dur/(256.0 * num_iterations)), (double)(max_dur/(256.0 * num_iterations)), time);

    printf("%f\n", time);


    /* free memory on GPU */
    cudaFree(d_a);
    cudaFree(d_ptr_a);
    cudaFree(duration);
    cudaThreadSynchronize ();

    /*free memory on CPU */
    free(h_a);
    free(h_ptr_a);
    free(latency);


}


int main(int argc, char **argv)
{
    int N;

    if (argc != 6) {
        usage();
        exit(1);
    }

    num_blocks = atoi(argv[1]);
    num_threads_per_block = atoi(argv[2]);
    num_iterations = atoi(argv[3]);
    divergence = atoi(argv[4]);
    int stride = atoi(argv[5]);

    N = GLOBAL_MEM_ELEMENTS;
    parametric_measure_shared(N, 10, stride);

    return 0;
}

	.file	"tmpxft_0035d672_00000000-6_fadd_shd_97_3_64p.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB3640:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE3640:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"Usage ./binary <num_blocks> <num_threads_per_block> <iterations>threads active per warp"
	.text
	.globl	_Z5usagev
	.type	_Z5usagev, @function
_Z5usagev:
.LFB3635:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	leaq	_ZSt4cout(%rip), %rdi
	leaq	.LC0(%rip), %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	popq	%rdx
	.cfi_def_cfa_offset 8
	movq	%rax, %rdi
	jmp	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT
	.cfi_endproc
.LFE3635:
	.size	_Z5usagev, .-_Z5usagev
	.globl	_Z45__device_stub__Z14shared_latencyPPyS_iiS_iiiiPPyS_iiS_iiii
	.type	_Z45__device_stub__Z14shared_latencyPPyS_iiS_iiiiPPyS_iiS_iiii, @function
_Z45__device_stub__Z14shared_latencyPPyS_iiS_iiiiPPyS_iiS_iiii:
.LFB3662:
	.cfi_startproc
	endbr64
	subq	$200, %rsp
	.cfi_def_cfa_offset 208
	movq	%rdi, 40(%rsp)
	leaq	64(%rsp), %rdi
	movq	%rsi, 32(%rsp)
	leaq	76(%rsp), %rsi
	movl	%edx, 28(%rsp)
	leaq	48(%rsp), %rdx
	movl	%ecx, 24(%rsp)
	leaq	56(%rsp), %rcx
	movq	%r8, 16(%rsp)
	movl	%r9d, 12(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 184(%rsp)
	xorl	%eax, %eax
	leaq	40(%rsp), %rax
	movl	$1, 72(%rsp)
	movq	%rax, 112(%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	28(%rsp), %rax
	movq	%rax, 128(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 136(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 144(%rsp)
	leaq	12(%rsp), %rax
	movq	%rax, 152(%rsp)
	leaq	208(%rsp), %rax
	movq	%rax, 160(%rsp)
	leaq	216(%rsp), %rax
	movq	%rax, 168(%rsp)
	leaq	224(%rsp), %rax
	movq	%rax, 176(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 64(%rsp)
	movq	%rax, 76(%rsp)
	movl	$1, 84(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L4
	pushq	56(%rsp)
	.cfi_def_cfa_offset 216
	leaq	_Z14shared_latencyPPyS_iiS_iiii(%rip), %rdi
	pushq	56(%rsp)
	.cfi_def_cfa_offset 224
	movq	92(%rsp), %rcx
	movl	100(%rsp), %r8d
	movq	80(%rsp), %rsi
	movl	88(%rsp), %edx
	leaq	128(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 216
	popq	%rdx
	.cfi_def_cfa_offset 208
.L4:
	movq	184(%rsp), %rax
	subq	%fs:40, %rax
	je	.L6
	call	__stack_chk_fail@PLT
.L6:
	addq	$200, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3662:
	.size	_Z45__device_stub__Z14shared_latencyPPyS_iiS_iiiiPPyS_iiS_iiii, .-_Z45__device_stub__Z14shared_latencyPPyS_iiS_iiiiPPyS_iiS_iiii
	.globl	_Z14shared_latencyPPyS_iiS_iiii
	.type	_Z14shared_latencyPPyS_iiS_iiii, @function
_Z14shared_latencyPPyS_iiS_iiii:
.LFB3663:
	.cfi_startproc
	endbr64
	jmp	_Z45__device_stub__Z14shared_latencyPPyS_iiS_iiiiPPyS_iiS_iiii
	.cfi_endproc
.LFE3663:
	.size	_Z14shared_latencyPPyS_iiS_iiii, .-_Z14shared_latencyPPyS_iiS_iiii
	.section	.rodata.str1.1
.LC1:
	.string	"Error 1 is %s\n"
.LC2:
	.string	"Error 2 is %s\n"
.LC3:
	.string	"Error 3 is %s\n"
.LC4:
	.string	"%f\n"
	.text
	.globl	_Z25parametric_measure_sharediii
	.type	_Z25parametric_measure_sharediii, @function
_Z25parametric_measure_sharediii:
.LFB3636:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	%edx, %r15d
	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
	movslq	%edi, %rbx
	movq	%rbx, %rbp
	salq	$3, %rbx
	subq	$88, %rsp
	.cfi_def_cfa_offset 144
	movq	%fs:40, %rax
	movq	%rax, 72(%rsp)
	xorl	%eax, %eax
	call	cudaProfilerStop@PLT
	movq	%rbx, %rdi
	call	malloc@PLT
	movq	%rbx, %rdi
	movq	%rax, %r12
	call	malloc@PLT
	movslq	num_threads_per_block(%rip), %rdi
	movq	%rax, %r13
	movslq	num_blocks(%rip), %rax
	imulq	%rax, %rdi
	salq	$3, %rdi
	call	malloc@PLT
	movq	%r12, %rdx
	movq	%rax, %r14
	xorl	%eax, %eax
.L11:
	cmpl	%eax, %ebp
	jle	.L31
	movq	%rdx, 0(%r13,%rax,8)
	incq	%rax
	addq	$8, %rdx
	jmp	.L11
.L31:
	xorl	%ecx, %ecx
	leal	1(%r15), %esi
.L13:
	cmpl	%ecx, %ebp
	jle	.L32
	leal	(%rsi,%rcx), %eax
	cltd
	idivl	%ebp
	movslq	%edx, %rdx
	movq	0(%r13,%rdx,8), %rax
	movq	%rax, (%r12,%rcx,8)
	incq	%rcx
	jmp	.L13
.L32:
	leaq	8(%rsp), %rdi
	movq	%rbx, %rsi
	call	cudaMalloc@PLT
	leaq	16(%rsp), %rdi
	movq	%rbx, %rsi
	call	cudaMalloc@PLT
	movslq	num_threads_per_block(%rip), %rsi
	leaq	24(%rsp), %rdi
	movslq	num_blocks(%rip), %rax
	imulq	%rax, %rsi
	salq	$3, %rsi
	call	cudaMalloc@PLT
	call	cudaThreadSynchronize@PLT
	call	cudaGetLastError@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L15
	call	cudaGetErrorString@PLT
	leaq	.LC1(%rip), %rsi
	movl	$2, %edi
	movq	%rax, %rdx
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L15:
	movq	8(%rsp), %rdi
	movl	$1, %ecx
	movq	%rbx, %rdx
	movq	%r12, %rsi
	call	cudaMemcpy@PLT
	movq	16(%rsp), %rdi
	movq	%rbx, %rdx
	movq	%r13, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movslq	num_threads_per_block(%rip), %rdx
	movq	24(%rsp), %rdi
	movq	%r14, %rsi
	movslq	num_blocks(%rip), %rax
	movl	$1, %ecx
	imulq	%rax, %rdx
	salq	$3, %rdx
	call	cudaMemcpy@PLT
	call	cudaThreadSynchronize@PLT
	call	cudaGetLastError@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L16
	call	cudaGetErrorString@PLT
	leaq	.LC2(%rip), %rsi
	movl	$2, %edi
	movq	%rax, %rdx
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L16:
	leaq	32(%rsp), %rdi
	call	cudaEventCreate@PLT
	leaq	40(%rsp), %rdi
	call	cudaEventCreate@PLT
	movq	32(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	call	cudaProfilerStart@PLT
	movl	$2, %esi
	leaq	_Z14shared_latencyPPyS_iiS_iiii(%rip), %rdi
	call	cudaFuncSetCacheConfig@PLT
	movl	num_threads_per_block(%rip), %eax
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	num_blocks(%rip), %edx
	movl	%eax, 60(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 64(%rsp)
	movl	68(%rsp), %ecx
	movl	%edx, 48(%rsp)
	movq	60(%rsp), %rdx
	movq	%rax, 52(%rsp)
	movq	48(%rsp), %rdi
	movl	56(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L17
	pushq	%rax
	.cfi_def_cfa_offset 152
	movl	num_threads_per_block(%rip), %eax
	movl	%r15d, %r9d
	movl	%ebp, %edx
	movl	num_iterations(%rip), %ecx
	pushq	%rax
	.cfi_def_cfa_offset 160
	movl	num_blocks(%rip), %eax
	pushq	%rax
	.cfi_def_cfa_offset 168
	movl	divergence(%rip), %eax
	pushq	%rax
	.cfi_def_cfa_offset 176
	movq	56(%rsp), %r8
	movq	40(%rsp), %rsi
	movq	48(%rsp), %rdi
	call	_Z45__device_stub__Z14shared_latencyPPyS_iiS_iiiiPPyS_iiS_iiii
	addq	$32, %rsp
	.cfi_def_cfa_offset 144
.L17:
	call	cudaDeviceSynchronize@PLT
	call	cudaProfilerStop@PLT
	movq	40(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	40(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movq	40(%rsp), %rdx
	movq	32(%rsp), %rsi
	leaq	60(%rsp), %rdi
	call	cudaEventElapsedTime@PLT
	call	cudaGetLastError@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L18
	call	cudaGetErrorString@PLT
	leaq	.LC3(%rip), %rsi
	movl	$2, %edi
	movq	%rax, %rdx
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L18:
	movq	8(%rsp), %rsi
	movl	$2, %ecx
	movq	%rbx, %rdx
	movq	%r12, %rdi
	call	cudaMemcpy@PLT
	movslq	num_threads_per_block(%rip), %rdx
	movq	24(%rsp), %rsi
	movq	%r14, %rdi
	movslq	num_blocks(%rip), %rax
	movl	$2, %ecx
	imulq	%rax, %rdx
	salq	$3, %rdx
	call	cudaMemcpy@PLT
	call	cudaThreadSynchronize@PLT
	leaq	.LC4(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	cvtss2sd	60(%rsp), %xmm0
	call	__printf_chk@PLT
	movq	8(%rsp), %rdi
	call	cudaFree@PLT
	movq	16(%rsp), %rdi
	call	cudaFree@PLT
	movq	24(%rsp), %rdi
	call	cudaFree@PLT
	call	cudaThreadSynchronize@PLT
	movq	%r12, %rdi
	call	free@PLT
	movq	%r13, %rdi
	call	free@PLT
	movq	72(%rsp), %rax
	subq	%fs:40, %rax
	je	.L19
	call	__stack_chk_fail@PLT
.L19:
	addq	$88, %rsp
	.cfi_def_cfa_offset 56
	movq	%r14, %rdi
	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	free@PLT
	.cfi_endproc
.LFE3636:
	.size	_Z25parametric_measure_sharediii, .-_Z25parametric_measure_sharediii
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB3637:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	cmpl	$6, %edi
	je	.L34
	call	_Z5usagev
	movl	$1, %edi
	call	exit@PLT
.L34:
	movq	8(%rsi), %rdi
	movq	%rsi, %rbx
	call	atoi@PLT
	movq	16(%rbx), %rdi
	movl	%eax, num_blocks(%rip)
	call	atoi@PLT
	movq	24(%rbx), %rdi
	movl	%eax, num_threads_per_block(%rip)
	call	atoi@PLT
	movq	32(%rbx), %rdi
	movl	%eax, num_iterations(%rip)
	call	atoi@PLT
	movq	40(%rbx), %rdi
	movl	%eax, divergence(%rip)
	call	atoi@PLT
	movl	$10, %esi
	movl	$196608, %edi
	movl	%eax, %edx
	call	_Z25parametric_measure_sharediii
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3637:
	.size	main, .-main
	.section	.rodata.str1.1
.LC5:
	.string	"_Z14shared_latencyPPyS_iiS_iiii"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB3665:
	.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	.LC5(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z14shared_latencyPPyS_iiS_iiii(%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
.LFE3665:
	.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
	.globl	divergence
	.bss
	.align 4
	.type	divergence, @object
	.size	divergence, 4
divergence:
	.zero	4
	.globl	num_iterations
	.align 4
	.type	num_iterations, @object
	.size	num_iterations, 4
num_iterations:
	.zero	4
	.globl	num_threads_per_block
	.align 4
	.type	num_threads_per_block, @object
	.size	num_threads_per_block, 4
num_threads_per_block:
	.zero	4
	.globl	num_blocks
	.align 4
	.type	num_blocks, @object
	.size	num_blocks, 4
num_blocks:
	.zero	4
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

#include <stdio.h>
#include <iostream>
#include <hip/hip_runtime_api.h>
//#include <cutil.h>
#include <hip/hip_runtime.h>
#include <string>



#define SHARED_MEM_ELEMENTS 1024
#define GLOBAL_MEM_ELEMENTS 196608

int num_blocks;
int num_threads_per_block;
int num_iterations;
int divergence;

__global__ void shared_latency (unsigned long long ** my_ptr_array, unsigned long long * my_array, int array_length, int iterations, unsigned long long * duration, int stride, int divergence, int num_blocks_k, int num_threads_per_block_k) {

//    unsigned long long int start_time, end_time;
    unsigned long long int sum_time = 0;
    int i, k;

    int tid = blockDim.x * blockIdx.x + threadIdx.x;

    int warp_thread_id = threadIdx.x % 32;
    __shared__ unsigned long long sdata[SHARED_MEM_ELEMENTS];

    __shared__ void **tmp_ptr;

    __shared__ void *arr[SHARED_MEM_ELEMENTS];

    if (threadIdx.x == 0) {
        for (i=0; i < SHARED_MEM_ELEMENTS; i++) {
            arr[i] = (void *)&sdata[i];
        }
        for (i=0; i < (SHARED_MEM_ELEMENTS - 1); i++) {
            sdata[i] = (unsigned long long)arr[i+1];
        }
        sdata[SHARED_MEM_ELEMENTS - 1] = (unsigned long long) arr[0];
    }

    __syncthreads();

    tmp_ptr = (void **)(&(arr[(threadIdx.x + stride)%SHARED_MEM_ELEMENTS]));

        double f1, f2, f3;
        f1 = 1.1;
        f2 = 2.5;
    if (warp_thread_id < divergence) {

        for (int l = 0; l < iterations; l++) {
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            tmp_ptr = (void**)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            tmp_ptr = (void**)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            tmp_ptr = (void**)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            tmp_ptr = (void**)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            tmp_ptr = (void**)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            tmp_ptr = (void**)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
            f1 = f1 + (unsigned long long)(*tmp_ptr);
        }
    }
//    __syncthreads();

    //    if ((blockDim.x * blockIdx.x + threadIdx.x) == 0)
    duration[tid] = (unsigned long long)(*tmp_ptr) + (f1 * tid);

//    __syncthreads();
}

void usage() {
    std::cout << "Usage ./binary <num_blocks> <num_threads_per_block> <iterations>" "threads active per warp" << std::endl;
}

void parametric_measure_shared(int N, int iterations, int stride) {

    hipProfilerStop();
    int i;
    unsigned long long int * h_a;
    unsigned long long int * d_a;

    unsigned long long ** h_ptr_a;
    unsigned long long ** d_ptr_a;

    unsigned long long * duration;
    unsigned long long * latency;

    hipError_t error_id;

    /* allocate array on CPU */
    h_a = (unsigned long long *)malloc(sizeof(unsigned long long int) * N);

    h_ptr_a = (unsigned long long **)malloc(sizeof(unsigned long long int*)*N);

    latency = (unsigned long long *)malloc(sizeof(unsigned long long) * num_threads_per_block * num_blocks);

    /* initialize array elements on CPU */


    for (i = 0; i < N; i++) {
        h_ptr_a[i] = (unsigned long long *)&h_a[i];
    }
    for (i = 0; i < N; i++) {
        h_a[i] = (unsigned long long)h_ptr_a[(i + 1 + stride) % N];
    }

    /* allocate arrays on GPU */
    hipMalloc ((void **) &d_a, sizeof(unsigned long long int) * N );
    hipMalloc ((void **) &d_ptr_a, sizeof(unsigned long long int*) * N );
    hipMalloc ((void **) &duration, sizeof(unsigned long long) * num_threads_per_block * num_blocks);

    hipDeviceSynchronize ();
    error_id = hipGetLastError();
    if (error_id != hipSuccess) {
        printf("Error 1 is %s\n", hipGetErrorString(error_id));
    }

    /* copy array elements from CPU to GPU */
    hipMemcpy((void *)d_a, (void *)h_a, sizeof(unsigned long long int) * N, hipMemcpyHostToDevice);
    hipMemcpy((void *)d_ptr_a, (void *)h_ptr_a, sizeof(unsigned long long int *) * N, hipMemcpyHostToDevice);
    hipMemcpy((void *)duration, (void *)latency, sizeof(unsigned long long) * num_threads_per_block * num_blocks, hipMemcpyHostToDevice);

    hipDeviceSynchronize ();

    error_id = hipGetLastError();
    if (error_id != hipSuccess) {
        printf("Error 2 is %s\n", hipGetErrorString(error_id));
    }

//    init_memory <<<1, 1>>>(d_ptr_a, d_a, stride, num_blocks, num_threads_per_block);
//    cudaDeviceSynchronize();

    /* launch kernel*/
    //dim3 Db = dim3(13);
    //dim3 Dg = dim3(768,1,1);

    //printf("Launch kernel with parameters: %d, N: %d, stride: %d\n", iterations, N, stride);
    //	int sharedMemSize =  sizeof(unsigned long long int) * N ;

    hipEvent_t start, stop;
    float time;

    hipEventCreate(&start);
    hipEventCreate(&stop);

    
    
    

    hipEventRecord(start, 0);
    hipProfilerStart();

    hipFuncSetCacheConfig(reinterpret_cast<const void*>(shared_latency), hipFuncCachePreferL1);
    //shared_latency <<<Dg, Db, sharedMemSize>>>(d_a, N, iterations, duration);
    //shared_latency <<<num_blocks, num_threads_per_block, sharedMemSize>>>(d_a, N, num_iterations, duration, stride, divergence);
    shared_latency <<<num_blocks, num_threads_per_block>>>(d_ptr_a, d_a, N, num_iterations, duration, stride, divergence, num_blocks, num_threads_per_block);

    hipDeviceSynchronize();
    ///cudaThreadSynchronize ();

    hipProfilerStop();
    hipEventRecord(stop, 0);
    hipEventSynchronize(stop);

    hipEventElapsedTime(&time, start, stop);

    

    error_id = hipGetLastError();
    if (error_id != hipSuccess) {
        printf("Error 3 is %s\n", hipGetErrorString(error_id));
    }

    /* copy results from GPU to CPU */

    hipMemcpy((void *)h_a, (void *)d_a, sizeof(unsigned long long int) * N, hipMemcpyDeviceToHost);
    hipMemcpy((void *)latency, (void *)duration, sizeof(unsigned long long) * num_threads_per_block * num_blocks, hipMemcpyDeviceToHost);

    hipDeviceSynchronize ();

    /* print results*/


    unsigned long long max_dur = latency[0];
    unsigned long long min_dur = latency[0];
    unsigned long long avg_lat = latency[0];
    for (int i = 1; i < num_threads_per_block * num_blocks; i++) {
        avg_lat += latency[i];
        if (latency[i] > max_dur) {
            max_dur = latency[i];
        } else if (latency[i] < min_dur) {
            min_dur = latency[i];
        }
    }


    //	printf("  %d, %f, %f, %f, %f\n",stride,(double)(avg_lat/(num_threads_per_block * num_blocks * 256.0 *num_iterations)), (double)(min_dur/(256.0 * num_iterations)), (double)(max_dur/(256.0 * num_iterations)), time);

    printf("%f\n", time);


    /* free memory on GPU */
    hipFree(d_a);
    hipFree(d_ptr_a);
    hipFree(duration);
    hipDeviceSynchronize ();

    /*free memory on CPU */
    free(h_a);
    free(h_ptr_a);
    free(latency);


}


int main(int argc, char **argv)
{
    int N;

    if (argc != 6) {
        usage();
        exit(1);
    }

    num_blocks = atoi(argv[1]);
    num_threads_per_block = atoi(argv[2]);
    num_iterations = atoi(argv[3]);
    divergence = atoi(argv[4]);
    int stride = atoi(argv[5]);

    N = GLOBAL_MEM_ELEMENTS;
    parametric_measure_shared(N, 10, stride);

    return 0;
}

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

                                        # End of file scope inline assembly
	.globl	_Z29__device_stub__shared_latencyPPyS_iiS_iiii # -- Begin function _Z29__device_stub__shared_latencyPPyS_iiS_iiii
	.type	_Z29__device_stub__shared_latencyPPyS_iiS_iiii,@function
_Z29__device_stub__shared_latencyPPyS_iiS_iiii: # @_Z29__device_stub__shared_latencyPPyS_iiS_iiii
	.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	$176, %rsp
	.cfi_def_cfa_offset 224
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	56(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	48(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	20(%rsp), %rsi
	movl	%edx, (%rsi)
	leaq	16(%rsp), %rdx
	movl	%ecx, (%rdx)
	leaq	40(%rsp), %rcx
	movq	%r8, (%rcx)
	leaq	12(%rsp), %r8
	movl	%r9d, (%r8)
	leaq	96(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	movq	%rcx, 32(%rbx)
	movq	%r8, 40(%rbx)
	leaq	224(%rsp), %rax
	movq	%rax, 48(%rbx)
	leaq	232(%rsp), %rax
	movq	%rax, 56(%rbx)
	leaq	240(%rsp), %rax
	movq	%rax, 64(%rbx)
	leaq	80(%rsp), %r14
	leaq	64(%rsp), %r15
	leaq	32(%rsp), %r12
	leaq	24(%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	$_Z14shared_latencyPPyS_iiS_iiii, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$192, %rsp
	.cfi_adjust_cfa_offset -192
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	_Z29__device_stub__shared_latencyPPyS_iiS_iiii, .Lfunc_end0-_Z29__device_stub__shared_latencyPPyS_iiS_iiii
	.cfi_endproc
                                        # -- End function
	.globl	_Z5usagev                       # -- Begin function _Z5usagev
	.type	_Z5usagev,@function
_Z5usagev:                              # @_Z5usagev
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset %rbx, -16
	movl	$_ZSt4cout, %ebx
	movl	$_ZSt4cout, %edi
	movl	$.L.str, %esi
	movl	$87, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	_ZSt4cout(%rip), %rax
	movq	-24(%rax), %rdi
	addq	%rbx, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	_ZNSo5flushEv                   # TAILCALL
.Lfunc_end1:
	.size	_Z5usagev, .Lfunc_end1-_Z5usagev
	.cfi_endproc
                                        # -- End function
	.globl	_Z25parametric_measure_sharediii # -- Begin function _Z25parametric_measure_sharediii
	.type	_Z25parametric_measure_sharediii,@function
_Z25parametric_measure_sharediii:       # @_Z25parametric_measure_sharediii
	.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	$56, %rsp
	.cfi_def_cfa_offset 112
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
                                        # kill: def $edx killed $edx def $rdx
	movq	%rdx, 40(%rsp)                  # 8-byte Spill
	movl	%edi, %ebp
	callq	hipProfilerStop
	movslq	%ebp, %r13
	leaq	(,%r13,8), %r12
	movq	%r12, %rdi
	callq	malloc
	movq	%rax, %rbx
	movq	%r12, %rdi
	callq	malloc
	movq	%rax, %r14
	movslq	num_threads_per_block(%rip), %rax
	movslq	num_blocks(%rip), %rdi
	imulq	%rax, %rdi
	shlq	$3, %rdi
	callq	malloc
	movq	%rax, %r15
	testl	%r13d, %r13d
	jle	.LBB2_6
# %bb.1:                                # %.lr.ph.preheader
	movl	%ebp, %ecx
	leaq	(,%rcx,8), %rax
	xorl	%edx, %edx
.LBB2_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	leaq	(%rbx,%rdx), %rsi
	movq	%rsi, (%r14,%rdx)
	addq	$8, %rdx
	cmpq	%rdx, %rax
	jne	.LBB2_2
# %bb.3:                                # %.preheader
	testl	%ebp, %ebp
	jle	.LBB2_6
# %bb.4:                                # %.lr.ph78.preheader
	movq	40(%rsp), %rax                  # 8-byte Reload
	leal	1(%rax), %esi
	xorl	%edi, %edi
.LBB2_5:                                # %.lr.ph78
                                        # =>This Inner Loop Header: Depth=1
	leal	(%rsi,%rdi), %eax
	cltd
	idivl	%ecx
	movslq	%edx, %rax
	movq	(%r14,%rax,8), %rax
	movq	%rax, (%rbx,%rdi,8)
	leaq	1(%rdi), %rax
	movq	%rax, %rdi
	cmpq	%rax, %rcx
	jne	.LBB2_5
.LBB2_6:                                # %._crit_edge
	leaq	8(%rsp), %rdi
	movq	%r12, %rsi
	callq	hipMalloc
	leaq	24(%rsp), %rdi
	movq	%r12, %rsi
	callq	hipMalloc
	movslq	num_threads_per_block(%rip), %rax
	movslq	num_blocks(%rip), %rsi
	imulq	%rax, %rsi
	shlq	$3, %rsi
	movq	%rsp, %rdi
	callq	hipMalloc
	callq	hipDeviceSynchronize
	callq	hipGetLastError
	testl	%eax, %eax
	je	.LBB2_8
# %bb.7:
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.1, %edi
	movq	%rax, %rsi
	xorl	%eax, %eax
	callq	printf
.LBB2_8:
	movq	8(%rsp), %rdi
	movq	%rbx, %rsi
	movq	%r12, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	24(%rsp), %rdi
	movq	%r14, %rsi
	movq	%r12, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	(%rsp), %rdi
	movslq	num_threads_per_block(%rip), %rax
	movslq	num_blocks(%rip), %rdx
	imulq	%rax, %rdx
	shlq	$3, %rdx
	movq	%r15, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	callq	hipDeviceSynchronize
	callq	hipGetLastError
	testl	%eax, %eax
	je	.LBB2_10
# %bb.9:
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.2, %edi
	movq	%rax, %rsi
	xorl	%eax, %eax
	callq	printf
.LBB2_10:
	leaq	48(%rsp), %r13
	movq	%r13, %rdi
	callq	hipEventCreate
	leaq	16(%rsp), %rdi
	callq	hipEventCreate
	movq	(%r13), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	callq	hipProfilerStart
	movl	$_Z14shared_latencyPPyS_iiS_iiii, %edi
	movl	$2, %esi
	callq	hipFuncSetCacheConfig
	movl	num_blocks(%rip), %edi
	movl	num_threads_per_block(%rip), %edx
	btsq	$32, %rdi
	btsq	$32, %rdx
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB2_12
# %bb.11:
	movq	24(%rsp), %rdi
	movq	8(%rsp), %rsi
	movl	num_iterations(%rip), %ecx
	movq	(%rsp), %r8
	movl	divergence(%rip), %eax
	movl	num_blocks(%rip), %r10d
	movl	num_threads_per_block(%rip), %r11d
	subq	$8, %rsp
	.cfi_adjust_cfa_offset 8
	movl	%ebp, %edx
	movq	48(%rsp), %r9                   # 8-byte Reload
                                        # kill: def $r9d killed $r9d killed $r9
	pushq	%r11
	.cfi_adjust_cfa_offset 8
	pushq	%r10
	.cfi_adjust_cfa_offset 8
	pushq	%rax
	.cfi_adjust_cfa_offset 8
	callq	_Z29__device_stub__shared_latencyPPyS_iiS_iiii
	addq	$32, %rsp
	.cfi_adjust_cfa_offset -32
.LBB2_12:
	callq	hipDeviceSynchronize
	callq	hipProfilerStop
	movq	16(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	16(%rsp), %rdi
	callq	hipEventSynchronize
	movq	48(%rsp), %rsi
	movq	16(%rsp), %rdx
	leaq	36(%rsp), %rdi
	callq	hipEventElapsedTime
	callq	hipGetLastError
	testl	%eax, %eax
	je	.LBB2_14
# %bb.13:
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.3, %edi
	movq	%rax, %rsi
	xorl	%eax, %eax
	callq	printf
.LBB2_14:                               # %._crit_edge84
	movq	8(%rsp), %rsi
	movq	%rbx, %rdi
	movq	%r12, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	movq	(%rsp), %rsi
	movslq	num_threads_per_block(%rip), %rax
	movslq	num_blocks(%rip), %rdx
	imulq	%rax, %rdx
	shlq	$3, %rdx
	movq	%r15, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	callq	hipDeviceSynchronize
	cvtss2sd	36(%rsp), %xmm0
	movl	$.L.str.4, %edi
	movb	$1, %al
	callq	printf
	movq	8(%rsp), %rdi
	callq	hipFree
	movq	24(%rsp), %rdi
	callq	hipFree
	movq	(%rsp), %rdi
	callq	hipFree
	callq	hipDeviceSynchronize
	movq	%rbx, %rdi
	callq	free
	movq	%r14, %rdi
	callq	free
	movq	%r15, %rdi
	callq	free
	addq	$56, %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_end2:
	.size	_Z25parametric_measure_sharediii, .Lfunc_end2-_Z25parametric_measure_sharediii
	.cfi_endproc
                                        # -- End function
	.globl	main                            # -- Begin function main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset %rbx, -16
	cmpl	$6, %edi
	jne	.LBB3_2
# %bb.1:
	movq	%rsi, %rbx
	movq	8(%rsi), %rdi
	callq	atoi
	movl	%eax, num_blocks(%rip)
	movq	16(%rbx), %rdi
	callq	atoi
	movl	%eax, num_threads_per_block(%rip)
	movq	24(%rbx), %rdi
	callq	atoi
	movl	%eax, num_iterations(%rip)
	movq	32(%rbx), %rdi
	callq	atoi
	movl	%eax, divergence(%rip)
	movq	40(%rbx), %rdi
	callq	atoi
	movl	$196608, %edi                   # imm = 0x30000
	movl	%eax, %edx
	callq	_Z25parametric_measure_sharediii
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 8
	retq
.LBB3_2:
	.cfi_def_cfa_offset 16
	callq	_Z5usagev
	movl	$1, %edi
	callq	exit
.Lfunc_end3:
	.size	main, .Lfunc_end3-main
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	jne	.LBB4_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB4_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z14shared_latencyPPyS_iiS_iiii, %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_end4:
	.size	__hip_module_ctor, .Lfunc_end4-__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	.LBB5_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
.LBB5_2:
	retq
.Lfunc_end5:
	.size	__hip_module_dtor, .Lfunc_end5-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	num_blocks,@object              # @num_blocks
	.bss
	.globl	num_blocks
	.p2align	2, 0x0
num_blocks:
	.long	0                               # 0x0
	.size	num_blocks, 4

	.type	num_threads_per_block,@object   # @num_threads_per_block
	.globl	num_threads_per_block
	.p2align	2, 0x0
num_threads_per_block:
	.long	0                               # 0x0
	.size	num_threads_per_block, 4

	.type	num_iterations,@object          # @num_iterations
	.globl	num_iterations
	.p2align	2, 0x0
num_iterations:
	.long	0                               # 0x0
	.size	num_iterations, 4

	.type	divergence,@object              # @divergence
	.globl	divergence
	.p2align	2, 0x0
divergence:
	.long	0                               # 0x0
	.size	divergence, 4

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

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"Usage ./binary <num_blocks> <num_threads_per_block> <iterations>threads active per warp"
	.size	.L.str, 88

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"Error 1 is %s\n"
	.size	.L.str.1, 15

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"Error 2 is %s\n"
	.size	.L.str.2, 15

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"Error 3 is %s\n"
	.size	.L.str.3, 15

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

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z14shared_latencyPPyS_iiS_iiii"
	.size	.L__unnamed_1, 32

	.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 _Z29__device_stub__shared_latencyPPyS_iiS_iiii
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z14shared_latencyPPyS_iiS_iiii
	.addrsig_sym _ZSt4cout
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z14shared_latencyPPyS_iiS_iiii ; -- Begin function _Z14shared_latencyPPyS_iiS_iiii
	.globl	_Z14shared_latencyPPyS_iiS_iiii
	.p2align	8
	.type	_Z14shared_latencyPPyS_iiS_iiii,@function
_Z14shared_latencyPPyS_iiS_iiii:        ; @_Z14shared_latencyPPyS_iiS_iiii
; %bb.0:
	s_mov_b32 s5, 0
	s_mov_b32 s4, exec_lo
	v_cmpx_eq_u32_e32 0, v0
	s_cbranch_execz .LBB0_6
; %bb.1:                                ; %.preheader218.preheader
	s_mov_b64 s[2:3], src_shared_base
	s_movk_i32 s2, 0x2000
.LBB0_2:                                ; %.preheader218
                                        ; =>This Inner Loop Header: Depth=1
	s_delay_alu instid0(SALU_CYCLE_1)
	v_mov_b32_e32 v1, s2
	v_dual_mov_b32 v3, s5 :: v_dual_mov_b32 v2, s3
	s_add_i32 s5, s5, 8
	s_add_u32 s2, s2, 8
	s_addc_u32 s3, s3, 0
	s_cmpk_lg_i32 s5, 0x2000
	ds_store_b64 v3, v[1:2]
	s_cbranch_scc1 .LBB0_2
; %bb.3:                                ; %.preheader217.preheader
	s_mov_b32 s2, 8
.LBB0_4:                                ; %.preheader217
                                        ; =>This Inner Loop Header: Depth=1
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(SALU_CYCLE_1)
	v_mov_b32_e32 v3, s2
	s_add_i32 s2, s2, 8
	s_cmpk_lg_i32 s2, 0x2000
	ds_load_b64 v[1:2], v3
	s_waitcnt lgkmcnt(0)
	ds_store_b64 v3, v[1:2] offset:8184
	s_cbranch_scc1 .LBB0_4
; %bb.5:
	v_mov_b32_e32 v3, 0
	ds_load_b64 v[1:2], v3
	s_waitcnt lgkmcnt(0)
	ds_store_b64 v3, v[1:2] offset:16376
.LBB0_6:                                ; %Flow253
	s_or_b32 exec_lo, exec_lo, s4
	s_clause 0x2
	s_load_b32 s4, s[0:1], 0x3c
	s_load_b64 s[2:3], s[0:1], 0x20
	s_load_b32 s5, s[0:1], 0x14
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	v_and_b32_e32 v5, 31, v0
	s_mov_b64 s[6:7], src_shared_base
	v_dual_mov_b32 v6, 0 :: v_dual_add_nc_u32 v1, s2, v0
	s_cmp_lt_i32 s5, 1
	s_cselect_b32 s2, -1, 0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_and_b32_e32 v1, 0x3ff, v1
	v_lshlrev_b32_e32 v3, 3, v1
	ds_load_b64 v[1:2], v3
	v_cmp_ne_u32_e32 vcc_lo, -1, v3
	v_cndmask_b32_e32 v3, 0, v3, vcc_lo
	v_cndmask_b32_e64 v4, 0, s7, vcc_lo
	v_cmp_le_i32_e32 vcc_lo, s3, v5
	ds_store_b64 v6, v[3:4] offset:16384
	s_or_b32 s6, vcc_lo, s2
                                        ; implicit-def: $sgpr2_sgpr3
                                        ; implicit-def: $vgpr3_vgpr4
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_and_saveexec_b32 s7, s6
	s_xor_b32 s6, exec_lo, s7
	s_cbranch_execz .LBB0_8
; %bb.7:                                ; %..loopexit_crit_edge
	s_waitcnt lgkmcnt(1)
	v_cvt_f64_u32_e32 v[2:3], v2
	v_cvt_f64_u32_e32 v[4:5], v1
	s_mov_b32 s3, 0x3ff19999
	s_mov_b32 s2, 0x9999999a
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ldexp_f64 v[2:3], v[2:3], 32
	v_add_f64 v[3:4], v[2:3], v[4:5]
                                        ; implicit-def: $vgpr1_vgpr2
.LBB0_8:                                ; %Flow251
	s_or_saveexec_b32 s6, s6
	v_dual_mov_b32 v6, s3 :: v_dual_mov_b32 v5, s2
	s_xor_b32 exec_lo, exec_lo, s6
	s_cbranch_execz .LBB0_11
; %bb.9:                                ; %.lr.ph.preheader
	s_mov_b32 s2, 0x9999999a
	s_mov_b32 s3, 0x3ff19999
	s_delay_alu instid0(SALU_CYCLE_1)
	v_dual_mov_b32 v7, 0 :: v_dual_mov_b32 v6, s3
	v_mov_b32_e32 v5, s2
.LBB0_10:                               ; %.lr.ph
                                        ; =>This Inner Loop Header: Depth=1
	s_waitcnt lgkmcnt(1)
	ds_store_b64 v7, v[1:2] offset:16384
	flat_load_b64 v[3:4], v[1:2]
	v_cvt_f64_u32_e32 v[8:9], v2
	v_cvt_f64_u32_e32 v[1:2], v1
	s_add_i32 s5, s5, -1
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	s_cmp_lg_u32 s5, 0
	v_ldexp_f64 v[8:9], v[8:9], 32
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[8:9], v[1:2]
	v_add_f64 v[5:6], v[5:6], v[1:2]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[5:6], v[5:6], v[1:2]
	v_add_f64 v[5:6], v[5:6], v[1:2]
	s_delay_alu instid0(VALU_DEP_1)
	v_add_f64 v[1:2], v[5:6], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	v_cvt_f64_u32_e32 v[8:9], v4
	v_cvt_f64_u32_e32 v[10:11], v3
	ds_store_b64 v7, v[3:4] offset:16384
	flat_load_b64 v[3:4], v[3:4]
	v_ldexp_f64 v[8:9], v[8:9], 32
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[5:6], v[8:9], v[10:11]
	v_add_f64 v[1:2], v[1:2], v[5:6]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[5:6]
	v_add_f64 v[1:2], v[1:2], v[5:6]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[5:6]
	v_add_f64 v[1:2], v[1:2], v[5:6]
	s_delay_alu instid0(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[5:6]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	v_cvt_f64_u32_e32 v[8:9], v4
	v_cvt_f64_u32_e32 v[10:11], v3
	ds_store_b64 v7, v[3:4] offset:16384
	flat_load_b64 v[3:4], v[3:4]
	v_add_f64 v[1:2], v[1:2], v[5:6]
	v_ldexp_f64 v[8:9], v[8:9], 32
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_f64 v[1:2], v[1:2], v[5:6]
	v_add_f64 v[8:9], v[8:9], v[10:11]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[5:6]
	v_add_f64 v[1:2], v[1:2], v[5:6]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[5:6]
	v_add_f64 v[1:2], v[1:2], v[5:6]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[5:6]
	v_add_f64 v[1:2], v[1:2], v[5:6]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	v_cvt_f64_u32_e32 v[10:11], v3
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[5:6]
	ds_store_b64 v7, v[3:4] offset:16384
	v_add_f64 v[1:2], v[1:2], v[5:6]
	v_add_f64 v[1:2], v[1:2], v[5:6]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[5:6]
	v_add_f64 v[1:2], v[1:2], v[5:6]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[5:6]
	v_add_f64 v[1:2], v[1:2], v[5:6]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[5:6]
	v_add_f64 v[1:2], v[1:2], v[5:6]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[5:6]
	v_add_f64 v[1:2], v[1:2], v[5:6]
	v_cvt_f64_u32_e32 v[5:6], v4
	flat_load_b64 v[3:4], v[3:4]
	v_add_f64 v[1:2], v[1:2], v[8:9]
	v_ldexp_f64 v[5:6], v[5:6], 32
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_f64 v[1:2], v[1:2], v[8:9]
	v_add_f64 v[5:6], v[5:6], v[10:11]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[8:9]
	v_add_f64 v[1:2], v[1:2], v[8:9]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[8:9]
	v_add_f64 v[1:2], v[1:2], v[8:9]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[8:9]
	v_add_f64 v[1:2], v[1:2], v[8:9]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	v_cvt_f64_u32_e32 v[10:11], v3
	ds_store_b64 v7, v[3:4] offset:16384
	v_add_f64 v[1:2], v[1:2], v[8:9]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[8:9]
	v_add_f64 v[1:2], v[1:2], v[8:9]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[8:9]
	v_add_f64 v[1:2], v[1:2], v[8:9]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[8:9]
	v_add_f64 v[1:2], v[1:2], v[8:9]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[8:9]
	v_add_f64 v[1:2], v[1:2], v[8:9]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[8:9]
	v_add_f64 v[1:2], v[1:2], v[8:9]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[8:9]
	v_add_f64 v[1:2], v[1:2], v[8:9]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[8:9]
	v_add_f64 v[1:2], v[1:2], v[8:9]
	v_cvt_f64_u32_e32 v[8:9], v4
	flat_load_b64 v[3:4], v[3:4]
	v_add_f64 v[1:2], v[1:2], v[5:6]
	v_ldexp_f64 v[8:9], v[8:9], 32
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_f64 v[1:2], v[1:2], v[5:6]
	v_add_f64 v[8:9], v[8:9], v[10:11]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[5:6]
	v_add_f64 v[1:2], v[1:2], v[5:6]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[5:6]
	v_add_f64 v[1:2], v[1:2], v[5:6]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[5:6]
	v_add_f64 v[1:2], v[1:2], v[5:6]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	v_cvt_f64_u32_e32 v[10:11], v3
	ds_store_b64 v7, v[3:4] offset:16384
	v_add_f64 v[1:2], v[1:2], v[5:6]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[5:6]
	v_add_f64 v[1:2], v[1:2], v[5:6]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[5:6]
	v_add_f64 v[1:2], v[1:2], v[5:6]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[5:6]
	v_add_f64 v[1:2], v[1:2], v[5:6]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[5:6]
	v_add_f64 v[1:2], v[1:2], v[5:6]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[5:6]
	v_add_f64 v[1:2], v[1:2], v[5:6]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[5:6]
	v_add_f64 v[1:2], v[1:2], v[5:6]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[5:6]
	v_add_f64 v[1:2], v[1:2], v[5:6]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[5:6]
	v_add_f64 v[1:2], v[1:2], v[5:6]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[5:6]
	v_add_f64 v[1:2], v[1:2], v[5:6]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[5:6]
	v_add_f64 v[1:2], v[1:2], v[5:6]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[5:6]
	v_add_f64 v[1:2], v[1:2], v[5:6]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[5:6]
	v_add_f64 v[1:2], v[1:2], v[5:6]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[5:6]
	v_add_f64 v[1:2], v[1:2], v[5:6]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[5:6]
	v_add_f64 v[1:2], v[1:2], v[5:6]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[5:6]
	v_add_f64 v[1:2], v[1:2], v[5:6]
	v_cvt_f64_u32_e32 v[5:6], v4
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_f64 v[1:2], v[1:2], v[8:9]
	v_ldexp_f64 v[5:6], v[5:6], 32
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_f64 v[1:2], v[1:2], v[8:9]
	v_add_f64 v[5:6], v[5:6], v[10:11]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[8:9]
	v_add_f64 v[1:2], v[1:2], v[8:9]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[8:9]
	v_add_f64 v[1:2], v[1:2], v[8:9]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[8:9]
	v_add_f64 v[1:2], v[1:2], v[8:9]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[8:9]
	v_add_f64 v[1:2], v[1:2], v[8:9]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[8:9]
	v_add_f64 v[1:2], v[1:2], v[8:9]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[8:9]
	v_add_f64 v[1:2], v[1:2], v[8:9]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[8:9]
	v_add_f64 v[1:2], v[1:2], v[8:9]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[8:9]
	v_add_f64 v[1:2], v[1:2], v[8:9]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[8:9]
	v_add_f64 v[1:2], v[1:2], v[8:9]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[8:9]
	v_add_f64 v[1:2], v[1:2], v[8:9]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[8:9]
	v_add_f64 v[1:2], v[1:2], v[8:9]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[8:9]
	v_add_f64 v[1:2], v[1:2], v[8:9]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[8:9]
	v_add_f64 v[1:2], v[1:2], v[8:9]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[8:9]
	v_add_f64 v[1:2], v[1:2], v[8:9]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[8:9]
	v_add_f64 v[1:2], v[1:2], v[8:9]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[8:9]
	v_add_f64 v[1:2], v[1:2], v[8:9]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[8:9]
	v_add_f64 v[1:2], v[1:2], v[5:6]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[5:6]
	v_add_f64 v[1:2], v[1:2], v[5:6]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[5:6]
	v_add_f64 v[1:2], v[1:2], v[5:6]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[5:6]
	v_add_f64 v[1:2], v[1:2], v[5:6]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[5:6]
	v_add_f64 v[1:2], v[1:2], v[5:6]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[5:6]
	v_add_f64 v[1:2], v[1:2], v[5:6]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[5:6]
	v_add_f64 v[1:2], v[1:2], v[5:6]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[5:6]
	v_add_f64 v[1:2], v[1:2], v[5:6]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[5:6]
	v_add_f64 v[1:2], v[1:2], v[5:6]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[5:6]
	v_add_f64 v[1:2], v[1:2], v[5:6]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[5:6]
	v_add_f64 v[1:2], v[1:2], v[5:6]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[5:6]
	v_add_f64 v[1:2], v[1:2], v[5:6]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[5:6]
	v_add_f64 v[1:2], v[1:2], v[5:6]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[5:6]
	v_add_f64 v[1:2], v[1:2], v[5:6]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[5:6]
	v_add_f64 v[1:2], v[1:2], v[5:6]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[5:6]
	v_add_f64 v[1:2], v[1:2], v[5:6]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[5:6]
	v_add_f64 v[1:2], v[1:2], v[5:6]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[5:6]
	v_add_f64 v[1:2], v[1:2], v[5:6]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[5:6]
	v_add_f64 v[1:2], v[1:2], v[5:6]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[5:6]
	v_add_f64 v[1:2], v[1:2], v[5:6]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[1:2], v[5:6]
	v_add_f64 v[1:2], v[1:2], v[5:6]
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	v_add_f64 v[8:9], v[1:2], v[5:6]
	flat_load_b64 v[1:2], v[3:4]
	v_add_f64 v[3:4], v[8:9], v[5:6]
	v_add_f64 v[3:4], v[3:4], v[5:6]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[3:4], v[3:4], v[5:6]
	v_add_f64 v[3:4], v[3:4], v[5:6]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[3:4], v[3:4], v[5:6]
	v_add_f64 v[3:4], v[3:4], v[5:6]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[3:4], v[3:4], v[5:6]
	v_add_f64 v[3:4], v[3:4], v[5:6]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	v_cvt_f64_u32_e32 v[8:9], v2
	v_cvt_f64_u32_e32 v[10:11], v1
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_f64 v[3:4], v[3:4], v[5:6]
	v_ldexp_f64 v[8:9], v[8:9], 32
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_f64 v[12:13], v[3:4], v[5:6]
	v_add_f64 v[3:4], v[8:9], v[10:11]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[5:6], v[12:13], v[5:6]
	v_add_f64 v[5:6], v[5:6], v[3:4]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[5:6], v[5:6], v[3:4]
	v_add_f64 v[5:6], v[5:6], v[3:4]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[5:6], v[5:6], v[3:4]
	v_add_f64 v[5:6], v[5:6], v[3:4]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[5:6], v[5:6], v[3:4]
	v_add_f64 v[5:6], v[5:6], v[3:4]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[5:6], v[5:6], v[3:4]
	v_add_f64 v[5:6], v[5:6], v[3:4]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[5:6], v[5:6], v[3:4]
	v_add_f64 v[5:6], v[5:6], v[3:4]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[5:6], v[5:6], v[3:4]
	v_add_f64 v[5:6], v[5:6], v[3:4]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[5:6], v[5:6], v[3:4]
	v_add_f64 v[5:6], v[5:6], v[3:4]
	s_cbranch_scc1 .LBB0_10
.LBB0_11:                               ; %Flow252
	s_or_b32 exec_lo, exec_lo, s6
	s_and_b32 s2, 0xffff, s4
	s_load_b64 s[0:1], s[0:1], 0x18
	s_waitcnt lgkmcnt(0)
	v_mad_u64_u32 v[1:2], null, s15, s2, v[0:1]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cvt_f64_i32_e32 v[7:8], v1
	v_fma_f64 v[2:3], v[5:6], v[7:8], v[3:4]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_trunc_f64_e32 v[2:3], v[2:3]
	v_ldexp_f64 v[4:5], v[2:3], 0xffffffe0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_floor_f64_e32 v[4:5], v[4:5]
	v_fma_f64 v[2:3], 0xc1f00000, v[4:5], v[2:3]
	v_cvt_u32_f64_e32 v4, v[4:5]
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_cvt_u32_f64_e32 v3, v[2:3]
	v_ashrrev_i32_e32 v2, 31, v1
	v_lshlrev_b64 v[0:1], 3, v[1:2]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v0, vcc_lo, s0, v0
	v_add_co_ci_u32_e32 v1, vcc_lo, s1, v1, vcc_lo
	global_store_b64 v[0:1], v[3:4], off
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z14shared_latencyPPyS_iiS_iiii
		.amdhsa_group_segment_fixed_size 16392
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 304
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 14
		.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	_Z14shared_latencyPPyS_iiS_iiii, .Lfunc_end0-_Z14shared_latencyPPyS_iiS_iiii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 2784
; NumSgprs: 18
; NumVgprs: 14
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 16392 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 14
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.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:         20
        .size:           4
        .value_kind:     by_value
      - .address_space:  global
        .offset:         24
        .size:           8
        .value_kind:     global_buffer
      - .offset:         32
        .size:           4
        .value_kind:     by_value
      - .offset:         36
        .size:           4
        .value_kind:     by_value
      - .offset:         40
        .size:           4
        .value_kind:     by_value
      - .offset:         44
        .size:           4
        .value_kind:     by_value
      - .offset:         48
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         52
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         56
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         60
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         62
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         64
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         66
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         68
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         70
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         88
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         96
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         104
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         112
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 16392
    .kernarg_segment_align: 8
    .kernarg_segment_size: 304
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z14shared_latencyPPyS_iiS_iiii
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z14shared_latencyPPyS_iiS_iiii.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     14
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
