#include <stdio.h>
#include <cuda_profiler_api.h>

#include <unistd.h>
#include <curand.h>
#include <curand_kernel.h>

#define SHARED_MEM_ELEMENTS 1024
#define GLOBAL_MEM_ELEMENTS 4096
//#define GLOBAL_MEM_ELEMENTS 131072
//#define GLOBAL_MEM_ELEMENTS 196608

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

__global__ void init_memory (unsigned long long ** my_ptr_array, unsigned long long * my_array, int stride, int num_blocks_k, int num_threads_per_block_k) {

    int block_id;
    int warp_id;
    int i;

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

    void **ptr_array = (void **)my_ptr_array;
    unsigned long long *array = (unsigned long long *)my_array;

    if (tid == 0) {
//        int elements_per_block = GLOBAL_MEM_ELEMENTS / num_blocks_k;
        int num_warps_per_block = num_threads_per_block_k / 32;
        //int elements_per_warp = elements_per_block / num_warps_per_block;
        int elements_per_warp = GLOBAL_MEM_ELEMENTS / num_warps_per_block;
        
//        for (block_id = 0; block_id < num_blocks_k; block_id++) {
            for (warp_id = 0; warp_id < num_warps_per_block; warp_id++) {
                for (i = 0; i < elements_per_warp; i++) {
                    //index = (block_id * elements_per_block) + (warp_id * elements_per_warp);
                    index = (warp_id * elements_per_warp);
                    ptr_array[index + i] = (void*)&array[(index + ((i + 16) % elements_per_warp))];
                }
            }

/*        for (i = 0; i < GLOBAL_MEM_ELEMENTS; i++) {
            ptr_array[i] = (void*)&array[(i + 32)%GLOBAL_MEM_ELEMENTS];
        }
*/
        for (i = 0; i < GLOBAL_MEM_ELEMENTS; i++) {
            //array[i] = (unsigned long long)ptr_array[(i+stride)%GLOBAL_MEM_ELEMENTS];
            array[i] = (unsigned long long)ptr_array[i];
        }
    }

    __syncthreads();

}

__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 ** my_end_ptr_array) {

    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 block_id = blockIdx.x;
    int warp_id = threadIdx.x / 32;
    int warp_thread_id = threadIdx.x % 32;

//    int elements_per_block = GLOBAL_MEM_ELEMENTS / num_blocks_k;
    int num_warps_per_block = num_threads_per_block_k / 32;
//    int elements_per_warp = elements_per_block / num_warps_per_block;
    int elements_per_warp = GLOBAL_MEM_ELEMENTS / num_warps_per_block;

    //int index1 = (block_id * elements_per_block) + (warp_id * elements_per_warp) + warp_thread_id;
    int index1 = (warp_id * elements_per_warp) + warp_thread_id;

    void **ptr_array = (void **)my_ptr_array;
    unsigned long long int *array = (unsigned long long int *)my_array;

    void **tmp_ptr; 
    
    //tmp_ptr = (void *)sdata;
    //tmp_ptr = (void **)(&(ptr_array[(threadIdx.x * stride)%GLOBAL_MEM_ELEMENTS]));
    //tmp_ptr = (void **)(&(ptr_array[(tid * stride)%GLOBAL_MEM_ELEMENTS]));
    tmp_ptr = (void **)(&(ptr_array[index1]));

//#define ONCE tmp_ptr = *(void**)tmp_ptr;
#define ONCE tmp_ptr = (void**)(*tmp_ptr);
#define REPEAT_FOUR_TIMES ONCE ONCE ONCE ONCE
#define REPEAT_SIXTEEN_TIMES REPEAT_FOUR_TIMES REPEAT_FOUR_TIMES REPEAT_FOUR_TIMES REPEAT_FOUR_TIMES
#define REPEAT_SIXTYFOUR_TIMES REPEAT_SIXTEEN_TIMES REPEAT_SIXTEEN_TIMES REPEAT_SIXTEEN_TIMES REPEAT_SIXTEEN_TIMES


    if ((threadIdx.x % 32) < divergence) {
        for(k = 0; k <= iterations; k++) {
            //       tmp_ptr = (void**)(*tmp_ptr);
            if (k == 0) {
                sum_time = 0;
            }
            start_time = clock();
//                    ONCE
            REPEAT_SIXTYFOUR_TIMES;
            REPEAT_SIXTYFOUR_TIMES;
            REPEAT_SIXTYFOUR_TIMES;
            REPEAT_FOUR_TIMES;
            REPEAT_FOUR_TIMES;
            end_time = clock();
            sum_time += (end_time - start_time);

        }
    }

    my_end_ptr_array[tid] = (unsigned long long*)(*tmp_ptr);
    duration[tid] = sum_time;

}

// Shared memory array size is N-2. Last two elements are used as dummy variables.
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 ** h_end_ptr_a;
    unsigned long long ** d_end_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);
    h_end_ptr_a = (unsigned long long **)malloc(sizeof(unsigned long long int*) * 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);
    cudaMalloc ((void **) &d_end_ptr_a, 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);
    cudaMemcpy((void *)d_end_ptr_a, (void *)h_end_ptr_a, 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 ;

    for (int i = 0; i < 1; i++) {
        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, d_end_ptr_a);

        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);
        cudaMemcpy((void *)h_end_ptr_a, (void *)d_end_ptr_a, 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++) {
            if (latency[i] > 0) {
                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 * (divergence / 32.0) * num_blocks * 200.0 *num_iterations)), (double)(min_dur/(200.0 * num_iterations)), (double)(max_dur/(200.0 * num_iterations)), time);
        //printf("  %d, %f, %f, %f, %f\n",stride,(double)(avg_lat/(num_threads_per_block * num_blocks * 200.0 *num_iterations)), (double)(min_dur/(200.0 * num_iterations)), (double)(max_dur/(200.0 * num_iterations)), time);

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

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

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


}

void usage() {
    printf("Usage ./binary <num_blocks> <num_threads_per_block> <iterations> <threads active per warp> <stride>\n");
}

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

	int N, stride; 

	// initialize upper bounds here
//	int stride_upper_bound = 1; 

    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]);
    stride = atoi(argv[5]);

//	printf("Shared memory latency for varying stride.\n");
//	printf("stride (bytes), latency (clocks)\n");

//	N = SHARED_MEM_ELEMENTS;
    N = GLOBAL_MEM_ELEMENTS;
//    N = num_threads_per_block;
//	stride_upper_bound = 1;
//	for (stride = 1; stride <= stride_upper_bound; stride += 1) {
		parametric_measure_shared(N, 10, stride);
//	}

	return 0;

}

	.file	"tmpxft_0026286d_00000000-6_global_l1_hit.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2259:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2259:
	.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> <stride>\n"
	.text
	.globl	_Z5usagev
	.type	_Z5usagev, @function
_Z5usagev:
.LFB2255:
	.cfi_startproc
	endbr64
	leaq	.LC0(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	jmp	__printf_chk@PLT
	.cfi_endproc
.LFE2255:
	.size	_Z5usagev, .-_Z5usagev
	.globl	_Z37__device_stub__Z11init_memoryPPyS_iiiPPyS_iii
	.type	_Z37__device_stub__Z11init_memoryPPyS_iiiPPyS_iii, @function
_Z37__device_stub__Z11init_memoryPPyS_iiiPPyS_iii:
.LFB2281:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movq	%rdi, 24(%rsp)
	leaq	48(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	60(%rsp), %rsi
	movl	%edx, 12(%rsp)
	leaq	32(%rsp), %rdx
	movl	%ecx, 8(%rsp)
	leaq	40(%rsp), %rcx
	movl	%r8d, 4(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 56(%rsp)
	movq	%rax, 96(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 104(%rsp)
	leaq	12(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	4(%rsp), %rax
	movq	%rax, 128(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 48(%rsp)
	movq	%rax, 60(%rsp)
	movl	$1, 68(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L3
	pushq	40(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z11init_memoryPPyS_iii(%rip), %rdi
	pushq	40(%rsp)
	.cfi_def_cfa_offset 176
	movq	76(%rsp), %rcx
	movl	84(%rsp), %r8d
	movq	64(%rsp), %rsi
	movl	72(%rsp), %edx
	leaq	112(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 168
	popq	%rdx
	.cfi_def_cfa_offset 160
.L3:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L5
	call	__stack_chk_fail@PLT
.L5:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2281:
	.size	_Z37__device_stub__Z11init_memoryPPyS_iiiPPyS_iii, .-_Z37__device_stub__Z11init_memoryPPyS_iiiPPyS_iii
	.globl	_Z11init_memoryPPyS_iii
	.type	_Z11init_memoryPPyS_iii, @function
_Z11init_memoryPPyS_iii:
.LFB2282:
	.cfi_startproc
	endbr64
	jmp	_Z37__device_stub__Z11init_memoryPPyS_iiiPPyS_iii
	.cfi_endproc
.LFE2282:
	.size	_Z11init_memoryPPyS_iii, .-_Z11init_memoryPPyS_iii
	.globl	_Z48__device_stub__Z14shared_latencyPPyS_iiS_iiiiS0_PPyS_iiS_iiiiS0_
	.type	_Z48__device_stub__Z14shared_latencyPPyS_iiS_iiiiS0_PPyS_iiS_iiiiS0_, @function
_Z48__device_stub__Z14shared_latencyPPyS_iiS_iiiiS0_PPyS_iiS_iiiiS0_:
.LFB2283:
	.cfi_startproc
	endbr64
	subq	$216, %rsp
	.cfi_def_cfa_offset 224
	movq	248(%rsp), %rax
	movq	%rdi, 40(%rsp)
	leaq	72(%rsp), %rdi
	movq	%rsi, 32(%rsp)
	leaq	84(%rsp), %rsi
	movl	%edx, 28(%rsp)
	leaq	56(%rsp), %rdx
	movl	%ecx, 24(%rsp)
	leaq	64(%rsp), %rcx
	movq	%r8, 16(%rsp)
	movl	%r9d, 12(%rsp)
	movq	%rax, (%rsp)
	movq	%fs:40, %rax
	movq	%rax, 200(%rsp)
	xorl	%eax, %eax
	leaq	40(%rsp), %rax
	movl	$1, 80(%rsp)
	movq	%rax, 120(%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 128(%rsp)
	leaq	28(%rsp), %rax
	movq	%rax, 136(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 144(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 152(%rsp)
	leaq	12(%rsp), %rax
	movq	%rax, 160(%rsp)
	leaq	224(%rsp), %rax
	movq	%rax, 168(%rsp)
	leaq	232(%rsp), %rax
	movq	%rax, 176(%rsp)
	leaq	240(%rsp), %rax
	movq	%rax, 184(%rsp)
	movq	%rsp, %rax
	movq	%rax, 192(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 72(%rsp)
	movq	%rax, 84(%rsp)
	movl	$1, 92(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L9
	pushq	64(%rsp)
	.cfi_def_cfa_offset 232
	leaq	_Z14shared_latencyPPyS_iiS_iiiiS0_(%rip), %rdi
	pushq	64(%rsp)
	.cfi_def_cfa_offset 240
	movq	100(%rsp), %rcx
	movl	108(%rsp), %r8d
	movq	88(%rsp), %rsi
	movl	96(%rsp), %edx
	leaq	136(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 232
	popq	%rdx
	.cfi_def_cfa_offset 224
.L9:
	movq	200(%rsp), %rax
	subq	%fs:40, %rax
	je	.L11
	call	__stack_chk_fail@PLT
.L11:
	addq	$216, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2283:
	.size	_Z48__device_stub__Z14shared_latencyPPyS_iiS_iiiiS0_PPyS_iiS_iiiiS0_, .-_Z48__device_stub__Z14shared_latencyPPyS_iiS_iiiiS0_PPyS_iiS_iiiiS0_
	.globl	_Z14shared_latencyPPyS_iiS_iiiiS0_
	.type	_Z14shared_latencyPPyS_iiS_iiiiS0_, @function
_Z14shared_latencyPPyS_iiS_iiiiS0_:
.LFB2284:
	.cfi_startproc
	endbr64
	jmp	_Z48__device_stub__Z14shared_latencyPPyS_iiS_iiiiS0_PPyS_iiS_iiiiS0_
	.cfi_endproc
.LFE2284:
	.size	_Z14shared_latencyPPyS_iiS_iiiiS0_, .-_Z14shared_latencyPPyS_iiS_iiiiS0_
	.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"
.LC6:
	.string	"  %d, %f, %f, %f, %f\n"
	.text
	.globl	_Z25parametric_measure_sharediii
	.type	_Z25parametric_measure_sharediii, @function
_Z25parametric_measure_sharediii:
.LFB2254:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movl	%edx, %r14d
	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
	movl	%edi, %ebx
	subq	$104, %rsp
	.cfi_def_cfa_offset 160
	movq	%fs:40, %rax
	movq	%rax, 88(%rsp)
	xorl	%eax, %eax
	call	cudaProfilerStop@PLT
	movslq	%ebx, %rax
	salq	$3, %rax
	movq	%rax, %rdi
	movq	%rax, 8(%rsp)
	call	malloc@PLT
	movq	8(%rsp), %rdi
	movq	%rax, %r12
	call	malloc@PLT
	movslq	num_threads_per_block(%rip), %r15
	movq	%rax, %r13
	movslq	num_blocks(%rip), %rax
	imulq	%rax, %r15
	salq	$3, %r15
	movq	%r15, %rdi
	call	malloc@PLT
	movq	%r15, %rdi
	movq	%rax, %rbp
	call	malloc@PLT
	movq	%r12, %rdx
	movq	%rax, %r15
	xorl	%eax, %eax
.L15:
	cmpl	%eax, %ebx
	jle	.L49
	movq	%rdx, 0(%r13,%rax,8)
	incq	%rax
	addq	$8, %rdx
	jmp	.L15
.L49:
	xorl	%ecx, %ecx
	leal	1(%r14), %esi
.L17:
	cmpl	%ecx, %ebx
	jle	.L50
	leal	(%rsi,%rcx), %eax
	cltd
	idivl	%ebx
	movslq	%edx, %rdx
	movq	0(%r13,%rdx,8), %rax
	movq	%rax, (%r12,%rcx,8)
	incq	%rcx
	jmp	.L17
.L50:
	movq	8(%rsp), %rsi
	leaq	16(%rsp), %rdi
	call	cudaMalloc@PLT
	movq	8(%rsp), %rsi
	leaq	24(%rsp), %rdi
	call	cudaMalloc@PLT
	movslq	num_threads_per_block(%rip), %rsi
	leaq	40(%rsp), %rdi
	movslq	num_blocks(%rip), %rax
	imulq	%rax, %rsi
	salq	$3, %rsi
	call	cudaMalloc@PLT
	movslq	num_threads_per_block(%rip), %rsi
	leaq	32(%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	.L19
	call	cudaGetErrorString@PLT
	leaq	.LC1(%rip), %rsi
	movl	$2, %edi
	movq	%rax, %rdx
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L19:
	movq	8(%rsp), %rdx
	movq	16(%rsp), %rdi
	movl	$1, %ecx
	movq	%r12, %rsi
	call	cudaMemcpy@PLT
	movq	8(%rsp), %rdx
	movq	24(%rsp), %rdi
	movq	%r13, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movslq	num_threads_per_block(%rip), %rdx
	movq	40(%rsp), %rdi
	movq	%rbp, %rsi
	movslq	num_blocks(%rip), %rax
	movl	$1, %ecx
	imulq	%rax, %rdx
	salq	$3, %rdx
	call	cudaMemcpy@PLT
	movslq	num_threads_per_block(%rip), %rdx
	movq	32(%rsp), %rdi
	movq	%r15, %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	.L20
	call	cudaGetErrorString@PLT
	leaq	.LC2(%rip), %rsi
	movl	$2, %edi
	movq	%rax, %rdx
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L20:
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	$1, %ecx
	movl	$1, %esi
	movabsq	$4294967297, %rdi
	movl	$1, 84(%rsp)
	movq	%rdi, %rdx
	movq	%rdi, 76(%rsp)
	movq	%rdi, 64(%rsp)
	movl	$1, 72(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L21
	movl	num_threads_per_block(%rip), %r8d
	movl	num_blocks(%rip), %ecx
	movl	%r14d, %edx
	movq	16(%rsp), %rsi
	movq	24(%rsp), %rdi
	call	_Z37__device_stub__Z11init_memoryPPyS_iiiPPyS_iii
.L21:
	call	cudaDeviceSynchronize@PLT
	leaq	48(%rsp), %rdi
	call	cudaEventCreate@PLT
	leaq	56(%rsp), %rdi
	call	cudaEventCreate@PLT
	movq	48(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	call	cudaProfilerStart@PLT
	movl	$2, %esi
	leaq	_Z14shared_latencyPPyS_iiS_iiiiS0_(%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, 76(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 80(%rsp)
	movl	84(%rsp), %ecx
	movl	%edx, 64(%rsp)
	movq	76(%rsp), %rdx
	movq	%rax, 68(%rsp)
	movq	64(%rsp), %rdi
	movl	72(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L22
	movl	num_threads_per_block(%rip), %eax
	pushq	32(%rsp)
	.cfi_def_cfa_offset 168
	movl	%r14d, %r9d
	movl	%ebx, %edx
	movl	num_iterations(%rip), %ecx
	pushq	%rax
	.cfi_def_cfa_offset 176
	movl	num_blocks(%rip), %eax
	pushq	%rax
	.cfi_def_cfa_offset 184
	movl	divergence(%rip), %eax
	pushq	%rax
	.cfi_def_cfa_offset 192
	movq	72(%rsp), %r8
	movq	48(%rsp), %rsi
	movq	56(%rsp), %rdi
	call	_Z48__device_stub__Z14shared_latencyPPyS_iiS_iiiiS0_PPyS_iiS_iiiiS0_
	addq	$32, %rsp
	.cfi_def_cfa_offset 160
.L22:
	call	cudaDeviceSynchronize@PLT
	call	cudaProfilerStop@PLT
	movq	56(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	56(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movq	56(%rsp), %rdx
	movq	48(%rsp), %rsi
	leaq	76(%rsp), %rdi
	call	cudaEventElapsedTime@PLT
	call	cudaGetLastError@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L23
	call	cudaGetErrorString@PLT
	leaq	.LC3(%rip), %rsi
	movl	$2, %edi
	movq	%rax, %rdx
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L23:
	movq	8(%rsp), %rdx
	movq	16(%rsp), %rsi
	movl	$2, %ecx
	movq	%r12, %rdi
	call	cudaMemcpy@PLT
	movslq	num_threads_per_block(%rip), %rdx
	movq	40(%rsp), %rsi
	movq	%rbp, %rdi
	movslq	num_blocks(%rip), %rax
	movl	$2, %ecx
	imulq	%rax, %rdx
	salq	$3, %rdx
	call	cudaMemcpy@PLT
	movslq	num_threads_per_block(%rip), %rdx
	movq	32(%rsp), %rsi
	movq	%r15, %rdi
	movslq	num_blocks(%rip), %rax
	movl	$2, %ecx
	imulq	%rax, %rdx
	salq	$3, %rdx
	call	cudaMemcpy@PLT
	call	cudaThreadSynchronize@PLT
	movl	num_threads_per_block(%rip), %edi
	movq	0(%rbp), %rax
	movl	$1, %r9d
	movl	num_blocks(%rip), %esi
	movl	%edi, %r10d
	movq	%rax, %rdx
	movq	%rax, %rcx
	imull	%esi, %r10d
.L24:
	cmpl	%r9d, %r10d
	jle	.L51
	movq	0(%rbp,%r9,8), %r8
	testq	%r8, %r8
	je	.L25
	addq	%r8, %rax
	cmpq	%r8, %rcx
	jb	.L35
	cmpq	%r8, %rdx
	cmova	%r8, %rdx
	jmp	.L25
.L35:
	movq	%r8, %rcx
.L25:
	incq	%r9
	jmp	.L24
.L51:
	cvtsi2sdl	num_iterations(%rip), %xmm5
	movsd	.LC4(%rip), %xmm6
	cvtss2sd	76(%rsp), %xmm3
	movaps	%xmm5, %xmm0
	mulsd	%xmm6, %xmm0
	testq	%rcx, %rcx
	js	.L27
	cvtsi2sdq	%rcx, %xmm2
	jmp	.L28
.L27:
	movq	%rcx, %r8
	andl	$1, %ecx
	shrq	%r8
	orq	%rcx, %r8
	cvtsi2sdq	%r8, %xmm2
	addsd	%xmm2, %xmm2
.L28:
	divsd	%xmm0, %xmm2
	testq	%rdx, %rdx
	js	.L29
	cvtsi2sdq	%rdx, %xmm1
	jmp	.L30
.L29:
	movq	%rdx, %rcx
	andl	$1, %edx
	shrq	%rcx
	orq	%rdx, %rcx
	cvtsi2sdq	%rcx, %xmm1
	addsd	%xmm1, %xmm1
.L30:
	divsd	%xmm0, %xmm1
	testq	%rax, %rax
	js	.L31
	cvtsi2sdq	%rax, %xmm0
	jmp	.L32
.L31:
	movq	%rax, %rdx
	andl	$1, %eax
	shrq	%rdx
	orq	%rax, %rdx
	cvtsi2sdq	%rdx, %xmm0
	addsd	%xmm0, %xmm0
.L32:
	cvtsi2sdl	divergence(%rip), %xmm4
	mulsd	.LC5(%rip), %xmm4
	movl	%r14d, %edx
	movb	$4, %al
	cvtsi2sdl	%edi, %xmm7
	movl	$2, %edi
	mulsd	%xmm7, %xmm4
	cvtsi2sdl	%esi, %xmm7
	leaq	.LC6(%rip), %rsi
	mulsd	%xmm7, %xmm4
	mulsd	%xmm6, %xmm4
	mulsd	%xmm5, %xmm4
	divsd	%xmm4, %xmm0
	call	__printf_chk@PLT
	movq	16(%rsp), %rdi
	call	cudaFree@PLT
	movq	24(%rsp), %rdi
	call	cudaFree@PLT
	movq	32(%rsp), %rdi
	call	cudaFree@PLT
	movq	40(%rsp), %rdi
	call	cudaFree@PLT
	call	cudaThreadSynchronize@PLT
	movq	%r12, %rdi
	call	free@PLT
	movq	%r13, %rdi
	call	free@PLT
	movq	%r15, %rdi
	call	free@PLT
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	je	.L33
	call	__stack_chk_fail@PLT
.L33:
	addq	$104, %rsp
	.cfi_def_cfa_offset 56
	movq	%rbp, %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
.LFE2254:
	.size	_Z25parametric_measure_sharediii, .-_Z25parametric_measure_sharediii
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2256:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	cmpl	$6, %edi
	je	.L53
	call	_Z5usagev
	movl	$1, %edi
	call	exit@PLT
.L53:
	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	$4096, %edi
	movl	%eax, %edx
	call	_Z25parametric_measure_sharediii
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2256:
	.size	main, .-main
	.section	.rodata.str1.1
.LC7:
	.string	"_Z14shared_latencyPPyS_iiS_iiiiS0_"
.LC8:
	.string	"_Z11init_memoryPPyS_iii"
.LC9:
	.string	"precalc_xorwow_matrix"
.LC10:
	.string	"precalc_xorwow_offset_matrix"
.LC11:
	.string	"mrg32k3aM1"
.LC12:
	.string	"mrg32k3aM2"
.LC13:
	.string	"mrg32k3aM1SubSeq"
.LC14:
	.string	"mrg32k3aM2SubSeq"
.LC15:
	.string	"mrg32k3aM1Seq"
.LC16:
	.string	"mrg32k3aM2Seq"
.LC17:
	.string	"__cr_lgamma_table"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2286:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	pushq	$0
	.cfi_def_cfa_offset 24
	xorl	%r9d, %r9d
	orl	$-1, %r8d
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC7(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z14shared_latencyPPyS_iiS_iiiiS0_(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 48
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r9d, %r9d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC8(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z11init_memoryPPyS_iii(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 40
	pushq	$0
	.cfi_def_cfa_offset 48
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC9(%rip), %rdx
	movl	$102400, %r9d
	leaq	_ZL21precalc_xorwow_matrix(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	call	__cudaRegisterVar@PLT
	popq	%rax
	.cfi_def_cfa_offset 24
	popq	%rdx
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC10(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movq	%rdx, %rcx
	movl	$102400, %r9d
	leaq	_ZL28precalc_xorwow_offset_matrix(%rip), %rsi
	call	__cudaRegisterVar@PLT
	popq	%rcx
	.cfi_def_cfa_offset 24
	popq	%rsi
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC11(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movq	%rdx, %rcx
	movl	$2304, %r9d
	leaq	_ZL10mrg32k3aM1(%rip), %rsi
	call	__cudaRegisterVar@PLT
	popq	%rdi
	.cfi_def_cfa_offset 24
	popq	%r8
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC12(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movq	%rdx, %rcx
	movl	$2304, %r9d
	leaq	_ZL10mrg32k3aM2(%rip), %rsi
	call	__cudaRegisterVar@PLT
	popq	%r9
	.cfi_def_cfa_offset 24
	popq	%r10
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC13(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movq	%rdx, %rcx
	movl	$2016, %r9d
	leaq	_ZL16mrg32k3aM1SubSeq(%rip), %rsi
	call	__cudaRegisterVar@PLT
	popq	%r11
	.cfi_def_cfa_offset 24
	popq	%rax
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC14(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movq	%rdx, %rcx
	movl	$2016, %r9d
	leaq	_ZL16mrg32k3aM2SubSeq(%rip), %rsi
	call	__cudaRegisterVar@PLT
	popq	%rax
	.cfi_def_cfa_offset 24
	popq	%rdx
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC15(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movq	%rdx, %rcx
	movl	$2304, %r9d
	leaq	_ZL13mrg32k3aM1Seq(%rip), %rsi
	call	__cudaRegisterVar@PLT
	popq	%rcx
	.cfi_def_cfa_offset 24
	popq	%rsi
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC16(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movq	%rdx, %rcx
	movl	$2304, %r9d
	leaq	_ZL13mrg32k3aM2Seq(%rip), %rsi
	call	__cudaRegisterVar@PLT
	popq	%rdi
	.cfi_def_cfa_offset 24
	popq	%r8
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$1
	.cfi_def_cfa_offset 32
	leaq	.LC17(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movl	$72, %r9d
	movq	%rdx, %rcx
	leaq	_ZL17__cr_lgamma_table(%rip), %rsi
	call	__cudaRegisterVar@PLT
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	popq	%r9
	.cfi_def_cfa_offset 24
	popq	%r10
	.cfi_def_cfa_offset 16
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE2286:
	.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
	.local	_ZL17__cr_lgamma_table
	.comm	_ZL17__cr_lgamma_table,72,32
	.local	_ZL13mrg32k3aM2Seq
	.comm	_ZL13mrg32k3aM2Seq,2304,32
	.local	_ZL13mrg32k3aM1Seq
	.comm	_ZL13mrg32k3aM1Seq,2304,32
	.local	_ZL16mrg32k3aM2SubSeq
	.comm	_ZL16mrg32k3aM2SubSeq,2016,32
	.local	_ZL16mrg32k3aM1SubSeq
	.comm	_ZL16mrg32k3aM1SubSeq,2016,32
	.local	_ZL10mrg32k3aM2
	.comm	_ZL10mrg32k3aM2,2304,32
	.local	_ZL10mrg32k3aM1
	.comm	_ZL10mrg32k3aM1,2304,32
	.local	_ZL28precalc_xorwow_offset_matrix
	.comm	_ZL28precalc_xorwow_offset_matrix,102400,32
	.local	_ZL21precalc_xorwow_matrix
	.comm	_ZL21precalc_xorwow_matrix,102400,32
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC4:
	.long	0
	.long	1080623104
	.align 8
.LC5:
	.long	0
	.long	1067450368
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:


#include <hip/hip_runtime.h>
#include <stdio.h>
#include <hip/hip_runtime_api.h>

#include <unistd.h>
#include <hiprand/hiprand.h>
#include <hiprand/hiprand_kernel.h>

#define SHARED_MEM_ELEMENTS 1024
#define GLOBAL_MEM_ELEMENTS 4096
//#define GLOBAL_MEM_ELEMENTS 131072
//#define GLOBAL_MEM_ELEMENTS 196608

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

__global__ void init_memory (unsigned long long ** my_ptr_array, unsigned long long * my_array, int stride, int num_blocks_k, int num_threads_per_block_k) {

    int block_id;
    int warp_id;
    int i;

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

    void **ptr_array = (void **)my_ptr_array;
    unsigned long long *array = (unsigned long long *)my_array;

    if (tid == 0) {
//        int elements_per_block = GLOBAL_MEM_ELEMENTS / num_blocks_k;
        int num_warps_per_block = num_threads_per_block_k / 32;
        //int elements_per_warp = elements_per_block / num_warps_per_block;
        int elements_per_warp = GLOBAL_MEM_ELEMENTS / num_warps_per_block;
        
//        for (block_id = 0; block_id < num_blocks_k; block_id++) {
            for (warp_id = 0; warp_id < num_warps_per_block; warp_id++) {
                for (i = 0; i < elements_per_warp; i++) {
                    //index = (block_id * elements_per_block) + (warp_id * elements_per_warp);
                    index = (warp_id * elements_per_warp);
                    ptr_array[index + i] = (void*)&array[(index + ((i + 16) % elements_per_warp))];
                }
            }

/*        for (i = 0; i < GLOBAL_MEM_ELEMENTS; i++) {
            ptr_array[i] = (void*)&array[(i + 32)%GLOBAL_MEM_ELEMENTS];
        }
*/
        for (i = 0; i < GLOBAL_MEM_ELEMENTS; i++) {
            //array[i] = (unsigned long long)ptr_array[(i+stride)%GLOBAL_MEM_ELEMENTS];
            array[i] = (unsigned long long)ptr_array[i];
        }
    }

    __syncthreads();

}

__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 ** my_end_ptr_array) {

    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 block_id = blockIdx.x;
    int warp_id = threadIdx.x / 32;
    int warp_thread_id = threadIdx.x % 32;

//    int elements_per_block = GLOBAL_MEM_ELEMENTS / num_blocks_k;
    int num_warps_per_block = num_threads_per_block_k / 32;
//    int elements_per_warp = elements_per_block / num_warps_per_block;
    int elements_per_warp = GLOBAL_MEM_ELEMENTS / num_warps_per_block;

    //int index1 = (block_id * elements_per_block) + (warp_id * elements_per_warp) + warp_thread_id;
    int index1 = (warp_id * elements_per_warp) + warp_thread_id;

    void **ptr_array = (void **)my_ptr_array;
    unsigned long long int *array = (unsigned long long int *)my_array;

    void **tmp_ptr; 
    
    //tmp_ptr = (void *)sdata;
    //tmp_ptr = (void **)(&(ptr_array[(threadIdx.x * stride)%GLOBAL_MEM_ELEMENTS]));
    //tmp_ptr = (void **)(&(ptr_array[(tid * stride)%GLOBAL_MEM_ELEMENTS]));
    tmp_ptr = (void **)(&(ptr_array[index1]));

//#define ONCE tmp_ptr = *(void**)tmp_ptr;
#define ONCE tmp_ptr = (void**)(*tmp_ptr);
#define REPEAT_FOUR_TIMES ONCE ONCE ONCE ONCE
#define REPEAT_SIXTEEN_TIMES REPEAT_FOUR_TIMES REPEAT_FOUR_TIMES REPEAT_FOUR_TIMES REPEAT_FOUR_TIMES
#define REPEAT_SIXTYFOUR_TIMES REPEAT_SIXTEEN_TIMES REPEAT_SIXTEEN_TIMES REPEAT_SIXTEEN_TIMES REPEAT_SIXTEEN_TIMES


    if ((threadIdx.x % 32) < divergence) {
        for(k = 0; k <= iterations; k++) {
            //       tmp_ptr = (void**)(*tmp_ptr);
            if (k == 0) {
                sum_time = 0;
            }
            start_time = clock();
//                    ONCE
            REPEAT_SIXTYFOUR_TIMES;
            REPEAT_SIXTYFOUR_TIMES;
            REPEAT_SIXTYFOUR_TIMES;
            REPEAT_FOUR_TIMES;
            REPEAT_FOUR_TIMES;
            end_time = clock();
            sum_time += (end_time - start_time);

        }
    }

    my_end_ptr_array[tid] = (unsigned long long*)(*tmp_ptr);
    duration[tid] = sum_time;

}

// Shared memory array size is N-2. Last two elements are used as dummy variables.
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 ** h_end_ptr_a;
    unsigned long long ** d_end_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);
    h_end_ptr_a = (unsigned long long **)malloc(sizeof(unsigned long long int*) * 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);
    hipMalloc ((void **) &d_end_ptr_a, 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);
    hipMemcpy((void *)d_end_ptr_a, (void *)h_end_ptr_a, 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);
    hipDeviceSynchronize();

    /* 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 ;

    for (int i = 0; i < 1; i++) {
        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, d_end_ptr_a);

        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);
        hipMemcpy((void *)h_end_ptr_a, (void *)d_end_ptr_a, 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++) {
            if (latency[i] > 0) {
                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 * (divergence / 32.0) * num_blocks * 200.0 *num_iterations)), (double)(min_dur/(200.0 * num_iterations)), (double)(max_dur/(200.0 * num_iterations)), time);
        //printf("  %d, %f, %f, %f, %f\n",stride,(double)(avg_lat/(num_threads_per_block * num_blocks * 200.0 *num_iterations)), (double)(min_dur/(200.0 * num_iterations)), (double)(max_dur/(200.0 * num_iterations)), time);

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

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

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


}

void usage() {
    printf("Usage ./binary <num_blocks> <num_threads_per_block> <iterations> <threads active per warp> <stride>\n");
}

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

	int N, stride; 

	// initialize upper bounds here
//	int stride_upper_bound = 1; 

    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]);
    stride = atoi(argv[5]);

//	printf("Shared memory latency for varying stride.\n");
//	printf("stride (bytes), latency (clocks)\n");

//	N = SHARED_MEM_ELEMENTS;
    N = GLOBAL_MEM_ELEMENTS;
//    N = num_threads_per_block;
//	stride_upper_bound = 1;
//	for (stride = 1; stride <= stride_upper_bound; stride += 1) {
		parametric_measure_shared(N, 10, stride);
//	}

	return 0;

}

	.text
	.file	"global_l1_hit.hip"
	.globl	_Z26__device_stub__init_memoryPPyS_iii # -- Begin function _Z26__device_stub__init_memoryPPyS_iii
	.type	_Z26__device_stub__init_memoryPPyS_iii,@function
_Z26__device_stub__init_memoryPPyS_iii: # @_Z26__device_stub__init_memoryPPyS_iii
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$128, %rsp
	.cfi_def_cfa_offset 176
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	32(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	12(%rsp), %rsi
	movl	%edx, (%rsi)
	leaq	8(%rsp), %rdx
	movl	%ecx, (%rdx)
	leaq	4(%rsp), %rcx
	movl	%r8d, (%rcx)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	movq	%rcx, 32(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	24(%rsp), %r12
	leaq	16(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z11init_memoryPPyS_iii, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$144, %rsp
	.cfi_adjust_cfa_offset -144
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	_Z26__device_stub__init_memoryPPyS_iii, .Lfunc_end0-_Z26__device_stub__init_memoryPPyS_iii
	.cfi_endproc
                                        # -- End function
	.globl	_Z29__device_stub__shared_latencyPPyS_iiS_iiiiS0_ # -- Begin function _Z29__device_stub__shared_latencyPPyS_iiS_iiiiS0_
	.type	_Z29__device_stub__shared_latencyPPyS_iiS_iiiiS0_,@function
_Z29__device_stub__shared_latencyPPyS_iiS_iiiiS0_: # @_Z29__device_stub__shared_latencyPPyS_iiS_iiiiS0_
	.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	248(%rsp), %rax
	movq	%rax, 72(%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_iiiiS0_, %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_end1:
	.size	_Z29__device_stub__shared_latencyPPyS_iiS_iiiiS0_, .Lfunc_end1-_Z29__device_stub__shared_latencyPPyS_iiS_iiiiS0_
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0                          # -- Begin function _Z25parametric_measure_sharediii
.LCPI2_0:
	.long	1127219200                      # 0x43300000
	.long	1160773632                      # 0x45300000
	.long	0                               # 0x0
	.long	0                               # 0x0
.LCPI2_1:
	.quad	0x4330000000000000              # double 4503599627370496
	.quad	0x4530000000000000              # double 1.9342813113834067E+25
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0
.LCPI2_2:
	.quad	0x3fa0000000000000              # double 0.03125
.LCPI2_3:
	.quad	0x4069000000000000              # double 200
	.text
	.globl	_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	$88, %rsp
	.cfi_def_cfa_offset 144
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
                                        # kill: def $edx killed $edx def $rdx
	movq	%rdx, 24(%rsp)                  # 8-byte Spill
	movl	%edi, %ebx
	callq	hipProfilerStop
	movl	%ebx, 12(%rsp)                  # 4-byte Spill
	movslq	%ebx, %r13
	leaq	(,%r13,8), %rbp
	movq	%rbp, %rdi
	callq	malloc
	movq	%rax, %rbx
	movq	%rbp, %rdi
	callq	malloc
	movq	%rax, %r14
	movslq	num_threads_per_block(%rip), %rax
	movslq	num_blocks(%rip), %r12
	imulq	%rax, %r12
	shlq	$3, %r12
	movq	%r12, %rdi
	callq	malloc
	movq	%rax, %r15
	movq	%r12, %rdi
	callq	malloc
	movq	%rax, %r12
	testl	%r13d, %r13d
	jle	.LBB2_6
# %bb.1:                                # %.lr.ph.preheader
	movl	12(%rsp), %ecx                  # 4-byte Reload
	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
	cmpl	$0, 12(%rsp)                    # 4-byte Folded Reload
	jle	.LBB2_6
# %bb.4:                                # %.lr.ph104.preheader
	movq	24(%rsp), %rax                  # 8-byte Reload
	leal	1(%rax), %esi
	xorl	%edi, %edi
.LBB2_5:                                # %.lr.ph104
                                        # =>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	16(%rsp), %rdi
	movq	%rbp, %rsi
	callq	hipMalloc
	leaq	48(%rsp), %rdi
	movq	%rbp, %rsi
	callq	hipMalloc
	movslq	num_threads_per_block(%rip), %rax
	movslq	num_blocks(%rip), %rsi
	imulq	%rax, %rsi
	shlq	$3, %rsi
	leaq	32(%rsp), %rdi
	callq	hipMalloc
	movslq	num_threads_per_block(%rip), %rax
	movslq	num_blocks(%rip), %rsi
	imulq	%rax, %rsi
	shlq	$3, %rsi
	leaq	40(%rsp), %rdi
	callq	hipMalloc
	callq	hipDeviceSynchronize
	callq	hipGetLastError
	testl	%eax, %eax
	je	.LBB2_8
# %bb.7:
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str, %edi
	movq	%rax, %rsi
	xorl	%eax, %eax
	callq	printf
.LBB2_8:
	movq	16(%rsp), %rdi
	movq	%rbx, %rsi
	movq	%rbp, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	48(%rsp), %rdi
	movq	%r14, %rsi
	movq	%rbp, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	32(%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
	movq	40(%rsp), %rdi
	movslq	num_threads_per_block(%rip), %rax
	movslq	num_blocks(%rip), %rdx
	imulq	%rax, %rdx
	shlq	$3, %rdx
	movq	%r12, %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.1, %edi
	movq	%rax, %rsi
	xorl	%eax, %eax
	callq	printf
.LBB2_10:
	movq	%r12, 72(%rsp)                  # 8-byte Spill
	movabsq	$4294967296, %r13               # imm = 0x100000000
	leaq	1(%r13), %rdi
	movl	$1, %esi
	movq	%rdi, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB2_12
# %bb.11:
	movq	48(%rsp), %rdi
	movq	16(%rsp), %rsi
	movl	num_blocks(%rip), %ecx
	movl	num_threads_per_block(%rip), %r8d
	movq	24(%rsp), %rdx                  # 8-byte Reload
                                        # kill: def $edx killed $edx killed $rdx
	callq	_Z26__device_stub__init_memoryPPyS_iii
.LBB2_12:                               # %.critedge
	callq	hipDeviceSynchronize
	leaq	80(%rsp), %r12
	movq	%r12, %rdi
	callq	hipEventCreate
	leaq	56(%rsp), %rdi
	callq	hipEventCreate
	movq	(%r12), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	callq	hipProfilerStart
	movl	$_Z14shared_latencyPPyS_iiS_iiiiS0_, %edi
	movl	$2, %esi
	callq	hipFuncSetCacheConfig
	movl	num_blocks(%rip), %edi
	movl	num_threads_per_block(%rip), %edx
	orq	%r13, %rdi
	orq	%r13, %rdx
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB2_14
# %bb.13:
	movq	48(%rsp), %rdi
	movq	16(%rsp), %rsi
	movl	num_iterations(%rip), %ecx
	movq	32(%rsp), %r8
	movl	divergence(%rip), %eax
	movl	num_blocks(%rip), %r10d
	movl	num_threads_per_block(%rip), %r11d
	movl	12(%rsp), %edx                  # 4-byte Reload
	movq	24(%rsp), %r9                   # 8-byte Reload
                                        # kill: def $r9d killed $r9d killed $r9
	pushq	40(%rsp)
	.cfi_adjust_cfa_offset 8
	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_iiiiS0_
	addq	$32, %rsp
	.cfi_adjust_cfa_offset -32
.LBB2_14:
	callq	hipDeviceSynchronize
	callq	hipProfilerStop
	movq	56(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	56(%rsp), %rdi
	callq	hipEventSynchronize
	movq	80(%rsp), %rsi
	movq	56(%rsp), %rdx
	leaq	68(%rsp), %rdi
	callq	hipEventElapsedTime
	callq	hipGetLastError
	testl	%eax, %eax
	movq	72(%rsp), %r12                  # 8-byte Reload
	je	.LBB2_16
# %bb.15:
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.2, %edi
	movq	%rax, %rsi
	xorl	%eax, %eax
	callq	printf
.LBB2_16:
	movq	16(%rsp), %rsi
	movq	%rbx, %rdi
	movq	%rbp, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	movq	32(%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
	movq	40(%rsp), %rsi
	movslq	num_threads_per_block(%rip), %rax
	movslq	num_blocks(%rip), %rdx
	imulq	%rax, %rdx
	shlq	$3, %rdx
	movq	%r12, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	callq	hipDeviceSynchronize
	movq	(%r15), %rdi
	movl	num_threads_per_block(%rip), %esi
	movl	num_blocks(%rip), %ecx
	movl	%ecx, %eax
	imull	%esi, %eax
	cmpl	$2, %eax
	jl	.LBB2_17
# %bb.19:                               # %.lr.ph110.preheader
	movl	%eax, %r8d
	movl	$1, %r9d
	movq	%rdi, %rdx
	movq	%rdi, %rax
.LBB2_20:                               # %.lr.ph110
                                        # =>This Inner Loop Header: Depth=1
	movq	(%r15,%r9,8), %r10
	testq	%r10, %r10
	je	.LBB2_24
# %bb.21:                               #   in Loop: Header=BB2_20 Depth=1
	addq	%r10, %rdi
	cmpq	%rax, %r10
	jbe	.LBB2_23
# %bb.22:                               #   in Loop: Header=BB2_20 Depth=1
	movq	%r10, %rax
	jmp	.LBB2_24
.LBB2_23:                               #   in Loop: Header=BB2_20 Depth=1
	cmpq	%rdx, %r10
	cmovbq	%r10, %rdx
.LBB2_24:                               #   in Loop: Header=BB2_20 Depth=1
	incq	%r9
	cmpq	%r9, %r8
	jne	.LBB2_20
	jmp	.LBB2_18
.LBB2_17:
	movq	%rdi, %rax
	movq	%rdi, %rdx
.LBB2_18:                               # %._crit_edge111
	movq	%rdi, %xmm1
	movdqa	.LCPI2_0(%rip), %xmm2           # xmm2 = [1127219200,1160773632,0,0]
	punpckldq	%xmm2, %xmm1            # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
	movapd	.LCPI2_1(%rip), %xmm3           # xmm3 = [4.503599627370496E+15,1.9342813113834067E+25]
	subpd	%xmm3, %xmm1
	movapd	%xmm1, %xmm0
	unpckhpd	%xmm1, %xmm0                    # xmm0 = xmm0[1],xmm1[1]
	cvtsi2sd	%esi, %xmm4
	cvtsi2sdl	divergence(%rip), %xmm5
	mulsd	.LCPI2_2(%rip), %xmm5
	addsd	%xmm1, %xmm0
	mulsd	%xmm4, %xmm5
	xorps	%xmm1, %xmm1
	cvtsi2sd	%ecx, %xmm1
	mulsd	%xmm5, %xmm1
	movsd	.LCPI2_3(%rip), %xmm4           # xmm4 = mem[0],zero
	xorps	%xmm5, %xmm5
	cvtsi2sdl	num_iterations(%rip), %xmm5
	mulsd	%xmm4, %xmm1
	mulsd	%xmm5, %xmm1
	divsd	%xmm1, %xmm0
	movq	%rdx, %xmm6
	punpckldq	%xmm2, %xmm6            # xmm6 = xmm6[0],xmm2[0],xmm6[1],xmm2[1]
	subpd	%xmm3, %xmm6
	movapd	%xmm6, %xmm1
	unpckhpd	%xmm6, %xmm1                    # xmm1 = xmm1[1],xmm6[1]
	addsd	%xmm6, %xmm1
	mulsd	%xmm4, %xmm5
	divsd	%xmm5, %xmm1
	movq	%rax, %xmm4
	punpckldq	%xmm2, %xmm4            # xmm4 = xmm4[0],xmm2[0],xmm4[1],xmm2[1]
	subpd	%xmm3, %xmm4
	movapd	%xmm4, %xmm2
	unpckhpd	%xmm4, %xmm2                    # xmm2 = xmm2[1],xmm4[1]
	addsd	%xmm4, %xmm2
	divsd	%xmm5, %xmm2
	xorps	%xmm3, %xmm3
	cvtss2sd	68(%rsp), %xmm3
	movl	$.L.str.3, %edi
	movq	24(%rsp), %rsi                  # 8-byte Reload
                                        # kill: def $esi killed $esi killed $rsi
	movb	$4, %al
	callq	printf
	movq	16(%rsp), %rdi
	callq	hipFree
	movq	48(%rsp), %rdi
	callq	hipFree
	movq	40(%rsp), %rdi
	callq	hipFree
	movq	32(%rsp), %rdi
	callq	hipFree
	callq	hipDeviceSynchronize
	movq	%rbx, %rdi
	callq	free
	movq	%r14, %rdi
	callq	free
	movq	%r12, %rdi
	callq	free
	movq	%r15, %rdi
	callq	free
	addq	$88, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end2:
	.size	_Z25parametric_measure_sharediii, .Lfunc_end2-_Z25parametric_measure_sharediii
	.cfi_endproc
                                        # -- End function
	.globl	_Z5usagev                       # -- Begin function _Z5usagev
	.type	_Z5usagev,@function
_Z5usagev:                              # @_Z5usagev
	.cfi_startproc
# %bb.0:
	movl	$.Lstr, %edi
	jmp	puts@PLT                        # TAILCALL
.Lfunc_end3:
	.size	_Z5usagev, .Lfunc_end3-_Z5usagev
	.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	.LBB4_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	$4096, %edi                     # imm = 0x1000
	movl	%eax, %edx
	callq	_Z25parametric_measure_sharediii
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 8
	retq
.LBB4_2:
	.cfi_def_cfa_offset 16
	callq	_Z5usagev
	movl	$1, %edi
	callq	exit
.Lfunc_end4:
	.size	main, .Lfunc_end4-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:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$32, %rsp
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -16
	movq	__hip_gpubin_handle(%rip), %rbx
	testq	%rbx, %rbx
	jne	.LBB5_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB5_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z11init_memoryPPyS_iii, %esi
	movl	$.L__unnamed_1, %edx
	movl	$.L__unnamed_1, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z14shared_latencyPPyS_iiS_iiiiS0_, %esi
	movl	$.L__unnamed_2, %edx
	movl	$.L__unnamed_2, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$__hip_module_dtor, %edi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_end5:
	.size	__hip_module_ctor, .Lfunc_end5-__hip_module_ctor
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_dtor
	.type	__hip_module_dtor,@function
__hip_module_dtor:                      # @__hip_module_dtor
	.cfi_startproc
# %bb.0:
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	je	.LBB6_2
# %bb.1:
	pushq	%rax
	.cfi_def_cfa_offset 16
	callq	__hipUnregisterFatBinary
	movq	$0, __hip_gpubin_handle(%rip)
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
.LBB6_2:
	retq
.Lfunc_end6:
	.size	__hip_module_dtor, .Lfunc_end6-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	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	_Z11init_memoryPPyS_iii,@object # @_Z11init_memoryPPyS_iii
	.section	.rodata,"a",@progbits
	.globl	_Z11init_memoryPPyS_iii
	.p2align	3, 0x0
_Z11init_memoryPPyS_iii:
	.quad	_Z26__device_stub__init_memoryPPyS_iii
	.size	_Z11init_memoryPPyS_iii, 8

	.type	_Z14shared_latencyPPyS_iiS_iiiiS0_,@object # @_Z14shared_latencyPPyS_iiS_iiiiS0_
	.globl	_Z14shared_latencyPPyS_iiS_iiiiS0_
	.p2align	3, 0x0
_Z14shared_latencyPPyS_iiS_iiiiS0_:
	.quad	_Z29__device_stub__shared_latencyPPyS_iiS_iiiiS0_
	.size	_Z14shared_latencyPPyS_iiS_iiiiS0_, 8

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

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

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

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

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z11init_memoryPPyS_iii"
	.size	.L__unnamed_1, 24

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_Z14shared_latencyPPyS_iiS_iiiiS0_"
	.size	.L__unnamed_2, 35

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

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

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

	.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 _Z26__device_stub__init_memoryPPyS_iii
	.addrsig_sym _Z29__device_stub__shared_latencyPPyS_iiS_iiiiS0_
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z11init_memoryPPyS_iii
	.addrsig_sym _Z14shared_latencyPPyS_iiS_iiiiS0_
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z11init_memoryPPyS_iii ; -- Begin function _Z11init_memoryPPyS_iii
	.globl	_Z11init_memoryPPyS_iii
	.p2align	8
	.type	_Z11init_memoryPPyS_iii,@function
_Z11init_memoryPPyS_iii:                ; @_Z11init_memoryPPyS_iii
; %bb.0:
	s_load_b32 s2, s[0:1], 0x2c
	v_sub_nc_u32_e32 v0, 0, v0
	s_mov_b32 s16, exec_lo
	s_waitcnt lgkmcnt(0)
	s_and_b32 s2, s2, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_mul_i32 s15, s15, s2
	v_cmpx_eq_u32_e64 s15, v0
	s_cbranch_execz .LBB0_9
; %bb.1:
	s_clause 0x1
	s_load_b32 s4, s[0:1], 0x18
	s_load_b128 s[0:3], s[0:1], 0x0
	s_waitcnt lgkmcnt(0)
	s_cmp_lt_i32 s4, 32
	s_cbranch_scc1 .LBB0_7
; %bb.2:                                ; %.preheader29.lr.ph
	s_ashr_i32 s5, s4, 31
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_lshr_b32 s5, s5, 27
	s_add_i32 s4, s4, s5
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(SALU_CYCLE_1)
	s_ashr_i32 s17, s4, 5
	s_ashr_i32 s4, s4, 31
	s_add_i32 s5, s17, s4
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_xor_b32 s5, s5, s4
	v_cvt_f32_u32_e32 v0, s5
	s_sub_i32 s7, 0, s5
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	v_rcp_iflag_f32_e32 v0, v0
	s_waitcnt_depctr 0xfff
	v_mul_f32_e32 v0, 0x4f7ffffe, v0
	v_cvt_u32_f32_e32 v0, v0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_readfirstlane_b32 s6, v0
	s_mul_i32 s7, s7, s6
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_mul_hi_u32 s7, s6, s7
	s_add_i32 s6, s6, s7
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_lshr_b32 s6, s6, 20
	s_mul_i32 s7, s6, s5
	s_add_i32 s8, s6, 1
	s_sub_i32 s7, 0x1000, s7
	s_delay_alu instid0(SALU_CYCLE_1)
	s_sub_i32 s9, s7, s5
	s_cmp_ge_u32 s7, s5
	s_cselect_b32 s6, s8, s6
	s_cselect_b32 s7, s9, s7
	s_add_i32 s8, s6, 1
	s_cmp_ge_u32 s7, s5
	s_cselect_b32 s5, s8, s6
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_xor_b32 s5, s5, s4
	s_sub_i32 s18, s5, s4
	s_mov_b32 s5, 0
	v_cvt_f32_u32_e32 v0, s18
	s_cmp_gt_i32 s18, 0
	s_mov_b32 s7, s5
	s_cselect_b32 s19, -1, 0
	s_sub_i32 s20, 0, s18
	v_rcp_iflag_f32_e32 v0, v0
	s_mov_b32 s8, s5
	s_waitcnt_depctr 0xfff
	v_mul_f32_e32 v0, 0x4f7ffffe, v0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cvt_u32_f32_e32 v0, v0
	v_readfirstlane_b32 s4, v0
	v_mov_b32_e32 v0, 0
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_mul_i32 s6, s20, s4
	s_mul_hi_u32 s6, s4, s6
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_add_i32 s6, s4, s6
	s_lshl_b64 s[10:11], s[6:7], 4
	s_mov_b32 s7, 0
.LBB0_3:                                ; %.preheader29
                                        ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB0_5 Depth 2
	s_and_not1_b32 vcc_lo, exec_lo, s19
	s_cbranch_vccnz .LBB0_6
; %bb.4:                                ; %.lr.ph
                                        ;   in Loop: Header=BB0_3 Depth=1
	s_mov_b32 s9, s5
	s_mul_i32 s21, s7, s18
	s_lshl_b64 s[12:13], s[8:9], 3
	s_mov_b32 s9, 0
	s_add_u32 s12, s0, s12
	s_addc_u32 s13, s1, s13
	s_mov_b32 s22, 16
	s_mov_b64 s[14:15], s[10:11]
.LBB0_5:                                ;   Parent Loop BB0_3 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_mul_i32 s4, s18, s15
	s_sub_i32 s4, s22, s4
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_2) | instid1(SALU_CYCLE_1)
	s_add_i32 s23, s20, s4
	s_cmp_ge_u32 s4, s18
	s_cselect_b32 s4, s23, s4
	s_sub_i32 s23, s4, s18
	s_cmp_ge_u32 s4, s18
	s_cselect_b32 s4, s23, s4
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_add_i32 s4, s4, s21
	s_lshl_b64 s[24:25], s[4:5], 3
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(SALU_CYCLE_1)
	s_add_u32 s24, s2, s24
	s_addc_u32 s25, s3, s25
	v_dual_mov_b32 v1, s24 :: v_dual_mov_b32 v2, s25
	s_add_i32 s9, s9, -1
	global_store_b64 v0, v[1:2], s[12:13]
	s_add_u32 s12, s12, 8
	s_addc_u32 s13, s13, 0
	s_add_i32 s22, s22, 1
	s_add_u32 s14, s14, s6
	s_addc_u32 s15, s15, 0
	s_cmp_lg_u32 s20, s9
	s_cbranch_scc1 .LBB0_5
.LBB0_6:                                ; %._crit_edge
                                        ;   in Loop: Header=BB0_3 Depth=1
	s_add_i32 s7, s7, 1
	s_add_i32 s8, s8, s18
	s_cmp_lg_u32 s7, s17
	s_cbranch_scc1 .LBB0_3
.LBB0_7:                                ; %.preheader.preheader
	v_mov_b32_e32 v0, 0
	s_mov_b64 s[4:5], 0
.LBB0_8:                                ; %.preheader
                                        ; =>This Inner Loop Header: Depth=1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_add_u32 s6, s0, s4
	s_addc_u32 s7, s1, s5
	global_load_b64 v[1:2], v0, s[6:7]
	s_add_u32 s6, s2, s4
	s_addc_u32 s7, s3, s5
	s_add_u32 s4, s4, 8
	s_addc_u32 s5, s5, 0
	s_cmpk_lg_u32 s4, 0x8000
	s_waitcnt vmcnt(0)
	global_store_b64 v0, v[1:2], s[6:7]
	s_cbranch_scc1 .LBB0_8
.LBB0_9:                                ; %Flow58
	s_or_b32 exec_lo, exec_lo, s16
	s_waitcnt_vscnt null, 0x0
	s_barrier
	buffer_gl0_inv
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z11init_memoryPPyS_iii
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 288
		.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 3
		.amdhsa_next_free_sgpr 26
		.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	_Z11init_memoryPPyS_iii, .Lfunc_end0-_Z11init_memoryPPyS_iii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 588
; NumSgprs: 28
; NumVgprs: 3
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 3
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 28
; NumVGPRsForWavesPerEU: 3
; 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
	.protected	_Z14shared_latencyPPyS_iiS_iiiiS0_ ; -- Begin function _Z14shared_latencyPPyS_iiS_iiiiS0_
	.globl	_Z14shared_latencyPPyS_iiS_iiiiS0_
	.p2align	8
	.type	_Z14shared_latencyPPyS_iiS_iiiiS0_,@function
_Z14shared_latencyPPyS_iiS_iiiiS0_:     ; @_Z14shared_latencyPPyS_iiS_iiiiS0_
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x2c
	s_load_b32 s4, s[0:1], 0x44
	v_lshrrev_b32_e32 v4, 5, v0
	s_load_b32 s9, s[0:1], 0x24
	s_waitcnt lgkmcnt(0)
	s_ashr_i32 s3, s2, 31
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_lshr_b32 s3, s3, 27
	s_add_i32 s2, s2, s3
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(SALU_CYCLE_1)
	s_ashr_i32 s3, s2, 5
	s_ashr_i32 s5, s2, 31
	s_add_i32 s3, s3, s5
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_xor_b32 s2, s3, s5
	v_cvt_f32_u32_e32 v1, s2
	s_sub_i32 s6, 0, s2
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	v_rcp_iflag_f32_e32 v1, v1
	s_waitcnt_depctr 0xfff
	v_mul_f32_e32 v1, 0x4f7ffffe, v1
	v_cvt_u32_f32_e32 v1, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_readfirstlane_b32 s3, v1
	v_and_b32_e32 v1, 31, v0
	s_mul_i32 s6, s6, s3
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(SALU_CYCLE_1)
	v_cmp_gt_u32_e32 vcc_lo, s9, v1
	s_mul_hi_u32 s6, s3, s6
	s_add_i32 s3, s3, s6
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_lshr_b32 s3, s3, 20
	s_mul_i32 s6, s3, s2
	s_add_i32 s7, s3, 1
	s_sub_i32 s6, 0x1000, s6
	s_delay_alu instid0(SALU_CYCLE_1)
	s_sub_i32 s8, s6, s2
	s_cmp_ge_u32 s6, s2
	s_cselect_b32 s3, s7, s3
	s_cselect_b32 s6, s8, s6
	s_add_i32 s7, s3, 1
	s_cmp_ge_u32 s6, s2
	s_cselect_b32 s2, s7, s3
	s_delay_alu instid0(SALU_CYCLE_1)
	s_xor_b32 s6, s2, s5
	s_clause 0x1
	s_load_b64 s[2:3], s[0:1], 0x0
	s_load_b32 s7, s[0:1], 0x14
	s_sub_i32 s5, s6, s5
	s_mov_b32 s6, 0
	v_mad_u64_u32 v[2:3], null, s5, v4, v[1:2]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v3, 31, v2
	v_lshlrev_b64 v[5:6], 3, v[2:3]
	v_mov_b32_e32 v3, 0
	v_mov_b32_e32 v4, 0
	s_waitcnt lgkmcnt(0)
	s_cmp_gt_i32 s7, -1
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_co_u32 v1, s2, s2, v5
	v_add_co_ci_u32_e64 v2, s2, s3, v6, s2
	s_cselect_b32 s2, -1, 0
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_and_b32 s2, vcc_lo, s2
	s_and_saveexec_b32 s5, s2
	s_cbranch_execz .LBB1_4
; %bb.1:                                ; %.lr.ph.preheader
	s_add_i32 s7, s7, 1
	s_mov_b64 s[2:3], 0
.LBB1_2:                                ; %.lr.ph
                                        ; =>This Inner Loop Header: Depth=1
	s_getreg_b32 s8, hwreg(HW_REG_SHADER_CYCLES, 0, 20)
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_cmp_lg_u32 s6, 0
	s_cselect_b32 s2, s2, 0
	s_cselect_b32 s3, s3, 0
	s_sub_u32 s2, s2, s8
	s_subb_u32 s3, s3, 0
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_getreg_b32 s9, hwreg(HW_REG_SHADER_CYCLES, 0, 20)
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_2) | instid1(SALU_CYCLE_1)
	s_add_u32 s2, s2, s9
	s_addc_u32 s3, s3, 0
	s_add_i32 s6, s6, 1
	s_cmp_lg_u32 s7, s6
	s_cbranch_scc1 .LBB1_2
; %bb.3:                                ; %Flow
	v_dual_mov_b32 v4, s3 :: v_dual_mov_b32 v3, s2
.LBB1_4:                                ; %Flow251
	s_or_b32 exec_lo, exec_lo, s5
	s_waitcnt vmcnt(0) lgkmcnt(0)
	flat_load_b64 v[1:2], v[1:2]
	s_and_b32 s4, 0xffff, s4
	s_clause 0x1
	s_load_b64 s[2:3], s[0:1], 0x30
	s_load_b64 s[0:1], s[0:1], 0x18
	s_waitcnt vmcnt(0) lgkmcnt(0)
	v_mad_u64_u32 v[5:6], null, s15, s4, v[0:1]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v6, 31, v5
	v_lshlrev_b64 v[5:6], 3, v[5:6]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v7, vcc_lo, s2, v5
	v_add_co_ci_u32_e32 v8, vcc_lo, s3, v6, vcc_lo
	v_add_co_u32 v5, vcc_lo, s0, v5
	v_add_co_ci_u32_e32 v6, vcc_lo, s1, v6, vcc_lo
	global_store_b64 v[7:8], v[1:2], off
	global_store_b64 v[5:6], 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_iiiiS0_
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 312
		.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 9
		.amdhsa_next_free_sgpr 16
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end1:
	.size	_Z14shared_latencyPPyS_iiS_iiiiS0_, .Lfunc_end1-_Z14shared_latencyPPyS_iiS_iiiiS0_
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 2908
; NumSgprs: 18
; NumVgprs: 9
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 9
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 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
      - .offset:         24
        .size:           4
        .value_kind:     by_value
      - .offset:         32
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         36
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         40
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         44
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         46
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         48
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         50
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         52
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         54
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         88
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         96
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 288
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z11init_memoryPPyS_iii
    .private_segment_fixed_size: 0
    .sgpr_count:     28
    .sgpr_spill_count: 0
    .symbol:         _Z11init_memoryPPyS_iii.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     3
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .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
      - .address_space:  global
        .offset:         48
        .size:           8
        .value_kind:     global_buffer
      - .offset:         56
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         60
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         64
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         68
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         70
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         72
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         74
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         76
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         78
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         96
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         104
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         112
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         120
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 312
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z14shared_latencyPPyS_iiS_iiiiS0_
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z14shared_latencyPPyS_iiS_iiiiS0_.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     9
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
