#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <getopt.h>
#include <time.h>
#include <unistd.h>
#include <string.h>

//global variable for dimensions of matrices
unsigned long long dimension;


//--Function to randomly seed values in the matrices
//provided by Shahadat
double r8_uniform_01 ( int *seed ){
  int k;
  double r;

  k = *seed / 127773;

  *seed = 16807 * ( *seed - k * 127773 ) - k * 2836;

  if ( *seed < 0 )
  {
    *seed = *seed + 2147483647;
  }

  r = ( double ) ( *seed ) * 4.656612875E-10;

  return r;
}

//We will use this define statement to specify what the size of the thread blocks should be
//optimum has been determined to be 16
#define BLOCK_SIZE 16

__global__ void global_memory_kernel(float* a, float* b, float* c, unsigned long long dimension) {
// Each thread computes one element of c
// by accumulating results into accumulator
float accumulator = 0.0;
//iterate through the row s and columns of the thread block
unsigned long long row = blockIdx.y * blockDim.y + threadIdx.y;
unsigned long long col = blockIdx.x * blockDim.x + threadIdx.x;
//if we go out of bounds, stop
if(row > dimension || col > dimension) return;
//since each thread is computing one element of c, grab the appropriate
//element from a's row, and b's column, and multply them and hold them in the accumulator
//then set the value in c
for (unsigned long long e = 0; e < dimension; ++e)
accumulator += (a[row * dimension + e]) * (b[e * dimension + col]);
c[row * dimension + col] = accumulator;
}

//function doing matrix multiplication using only global memory
double* global_memory( float* a, float* b, float* c, unsigned long long run_number) {

double dt_and_rate[2];

unsigned long long l = dimension;
unsigned long long m = dimension;
unsigned long long n = dimension;

// Load A and B to device memory
float* cuda_A;

unsigned long long size = l*l*sizeof(float);

cudaMalloc(&cuda_A, size);
cudaMemcpy(cuda_A, a, size, cudaMemcpyHostToDevice);

float* cuda_B;
size = l* l * sizeof(float);
cudaMalloc(&cuda_B, size);
cudaMemcpy(cuda_B, b, size, cudaMemcpyHostToDevice);


// Allocate C in device memory

float* cuda_C;
size = l * l * sizeof(float);
cudaMalloc(&cuda_C, size);



//set up the block and grid dimensions
//using BLOCK_SIZEXBLOCK_SIZE for the blocks
dim3 dimBlock(BLOCK_SIZE, BLOCK_SIZE);
//setting up the dimensions of the grid
//using this method so that we find the numbers such that the correct number of blocks
//reside within the grid

//e.g. for a 1024* 1024 matrix:

//BLOCK_SIZE = 16
//l = 1024
//the formula is thus:
//(1024+16-1)/16 = 1029/16 = 64.6125 = 64 (because integer division)
//and what happens if we multiply by our thread block size? --> 64 * 16 = 1024, which returns our dimension

//the same reasoning goes for the y dimension
dim3 dimGrid((l + dimBlock.x - 1) / dimBlock.x,(l + dimBlock.y - 1) / dimBlock.y);

//declare variable to find out elapsed time
float time_elapsed;


//CUDA time keeping variables
cudaEvent_t start, stop;
cudaEventCreate(&start);
cudaEventCreate(&stop);
cudaEventRecord(start,0);
//run the function on the GPU
global_memory_kernel<<<dimGrid, dimBlock>>>(cuda_A, cuda_B, cuda_C, dimension);
//synchronize threads
cudaThreadSynchronize();

//CUDA timekeeping stop events
cudaEventRecord(stop,0);
cudaEventSynchronize(stop);
//store the elapsed time
cudaEventElapsedTime(&time_elapsed,start,stop);
cudaEventDestroy(start);
cudaEventDestroy(stop);

//figure out how many operations needed to be done
unsigned long long ops = l * l * ( 2 * l );

time_elapsed = time_elapsed/1000; //change into seconds
//figure out the rate
double rate = ( double ) ( ops ) / time_elapsed / 1000000.0;

  printf ( "\n" );
  printf("Run number: %d\n", run_number);
  printf ( "  Floating point OPS roughly %llu\n", ops );
  printf ( "  Elapsed time dT = %f\n", time_elapsed);
  printf ( "  Rate = MegaOPS/dT = %f\n", rate );


// Read C from device memory
cudaMemcpy(c, cuda_C, size, cudaMemcpyDeviceToHost);



//return values for main
  dt_and_rate[0]=time_elapsed;
  dt_and_rate[1]=rate;

// Free device memory
cudaFree(cuda_A);
cudaFree(cuda_B);
cudaFree(cuda_C);

return dt_and_rate;
}



//retrieve a matrix element
//device function because this needs to execute on the graphics card, not on host machines
__device__ float retrieve_item(float* a, unsigned long long row, unsigned long long col, unsigned long long dim) {
return a[row * dim + col];
}


// Set a matrix element
//device function because this needs to execute on the graphics card, not on host machines
__device__ void set_entry(float* a, unsigned long long row, unsigned long long col, float value, unsigned long long dim) {
a[row * dim + col] = value;
}

//get the next sub-block of a matrix when doing blocking multiplication
__device__ float* get_next_block(float* a, unsigned long long row, unsigned long long col, unsigned long long dimension) {
float* block_a;
block_a = &a[dimension * BLOCK_SIZE * row + BLOCK_SIZE * col];
return block_a;
}


// Matrix multiplication kernel called by MatMul()
__global__ void shared_memory_kernel(float* a, float* b, float* c, unsigned long long dimension) {
// Block row and column
unsigned long long blockRow = blockIdx.y;
unsigned long long blockCol = blockIdx.x;
// Each thread block computes one sub-matrix of C
float* block_c = get_next_block(c, blockRow, blockCol, dimension);
// Each thread computes one element of the tile of C
// by accumulating results into accumulator
float accumulator = 0.0;
// Thread row and column within the tile of c
unsigned long long row = threadIdx.y;
unsigned long long col = threadIdx.x;
// Loop over all A and B's tiles
// Multiply each pair of sub-matrices together
// and accumulate the results
for (unsigned long long m = 0; m < (dimension / BLOCK_SIZE); ++m) {
// Get sub-matrix of A
float* block_a = get_next_block(a, blockRow, m, dimension);
// Get sub-matrix of B
float* block_b = get_next_block(b, m, blockCol, dimension);
// Shared memory used to store the tiles of A and B
__shared__ float a_shared[BLOCK_SIZE][BLOCK_SIZE];
__shared__ float b_shared[BLOCK_SIZE][BLOCK_SIZE];
// Load tiles from device memory to shared memory
// Each thread loads one element of each sub-matrix
a_shared[row][col] = retrieve_item(block_a, row, col, dimension);
b_shared[row][col] = retrieve_item(block_b, row, col, dimension);
// Synchronize to make sure the sub-matrices are loaded
// before starting the computation
__syncthreads();
// Multiply Asub and Bsub together
for (unsigned long long e = 0; e < BLOCK_SIZE; ++e)
accumulator += a_shared[row][e] * b_shared[e][col];
// Synchronize to make sure that the preceding
// computation is done before loading two new
// sub-matrices of A and B in the next iteration
__syncthreads();
}
// Write the tile of to device memory
// Each thread writes one element
set_entry(block_c, row, col, accumulator, dimension);
}


//function to execute shared-memory version of blocking matrix multiplication
double* shared_memory(float* a, float* b, float* c, unsigned long long run_number) {


double dt_and_rate[2];

unsigned long long l = dimension;
unsigned long long m = dimension;
unsigned long long n = dimension;


// Load A and B to device memory
float* cuda_A;

unsigned long long size = dimension * dimension * sizeof(float);
//allocate device memory
cudaMalloc(&cuda_A, size);
//copy to device
cudaMemcpy(cuda_A, a, size, cudaMemcpyHostToDevice);
//do the same for b
float* cuda_B;
size = dimension * dimension * sizeof(float);
cudaMalloc(&cuda_B, size);
cudaMemcpy(cuda_B, b, size, cudaMemcpyHostToDevice);
// Allocate C in device memory
float* cuda_C;
size = dimension * dimension * sizeof(float);
cudaMalloc(&cuda_C, size);
//set up float for timer
float time_elapsed;


//st up the block and grid for device
dim3 dimBlock(BLOCK_SIZE, BLOCK_SIZE);
dim3 dimGrid(dimension / dimBlock.x, dimension / dimBlock.y);
//start timers
cudaEvent_t start, stop;
cudaEventCreate(&start);
cudaEventCreate(&stop);
cudaEventRecord(start,0);

//call the CUDA function
shared_memory_kernel<<<dimGrid, dimBlock>>>(cuda_A, cuda_B, cuda_C, dimension);
//synchronize threads
cudaThreadSynchronize();

cudaEventRecord(stop,0);
cudaEventSynchronize(stop);
cudaEventElapsedTime(&time_elapsed,start,stop);
cudaEventDestroy(start);
cudaEventDestroy(stop);
//figure out how many operations we have done
unsigned long long ops = l * l * ( 2 * l );

time_elapsed = time_elapsed/1000; //change into seconds
  //get the rate
  double rate = ( double ) ( ops ) / time_elapsed / 1000000.0;

  printf ( "\n" );
  printf("Run number: %d\n", run_number);
  printf ( "  Floating point OPS roughly %llu\n", ops );
  printf ( "  Elapsed time dT = %f\n", time_elapsed);
  printf ( "  Rate = MegaOPS/dT = %f\n", rate );



// Read c from device memory
cudaMemcpy(c, cuda_C, size, cudaMemcpyDeviceToHost);

// Free device memory
cudaFree(cuda_A);
cudaFree(cuda_B);
cudaFree(cuda_C);


dt_and_rate[0]=time_elapsed;
dt_and_rate[1]=rate;

return dt_and_rate;



}

void usage (char* argv[])
{
  //go through and print out any relevant information for command line arguments
  //to use the program
    printf("Usage: %s -n <matrix dimensions>\n", argv[0]);
    printf("Options:\n");
    printf("  -h         Print this help message.\n");
    printf("  -n         Dimensions of the matrices.\n");
    printf("\nExamples:\n");
    printf("  %s -n 256 > output.txt\n", argv[0]);
    printf("  %s -n 4096 > output.txt\n", argv[0]);
    //end the program
    exit(0);
}

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

//used to determine average rates and times
double* temp;
double average_dt=0.0;
double average_rate=0.0;
//get command line options
char options;
    while( (options=getopt(argc,argv,"n:h")) != -1){
        switch(options){
        case 'n':
            dimension = atoi(optarg);
            break;
        case 'h':
            usage(argv);
            exit(0);
        default:
            usage(argv);
            exit(1);
        }
    }
//allocate space
float* a = (float*)malloc(dimension * dimension * sizeof(float));

float* b = (float*)malloc(dimension * dimension * sizeof(float));

float* c = (float*)malloc(dimension * dimension * sizeof(float));

int seed=123456789;

//seed the matrices with random values
for(unsigned long long i = 0; i < dimension; i++){
  for(unsigned long long j = 0; j < dimension; j++){

    a[i*dimension + j] = (float) (r8_uniform_01 ( &seed ));
  }
}

for(unsigned long long i = 0; i < dimension; i++){
  for(unsigned long long j = 0; j < dimension; j++){

    b[i*dimension + j] = (float) (r8_uniform_01 ( &seed ));
  }
}


printf ("Thread Block Size: %d\n", BLOCK_SIZE);

printf( "\n" );
printf( "========================Unoptimized CUDA Multiplication================================\n" );

for(unsigned long long i =0; i < 10; i++){
temp = global_memory(a, b, c,i);
average_dt += temp[0];
average_rate += temp[1];

}

average_rate = (double) average_rate/10;
average_dt = (double) average_dt/10;
printf("Average Elapsed Time dT: %f\n", average_dt);
printf("Average Rate: %f\n", average_rate);
average_rate=average_dt=0.0;

printf( "\n" );
printf( "========================Blocking Optimized CUDA Multiplication================================\n" );


for(unsigned long long i=0; i<10;i++){
temp=shared_memory(a,b,c,i);
average_dt += temp[0];
average_rate += temp[1];
}

average_rate = (double) average_rate/10;
average_dt = (double) average_dt/10;
printf("Average Elapsed Time dT: %f\n", average_dt);
printf("Average Rate: %f\n", average_rate);
average_rate=average_dt=0.0;



//free host memory
free(a);
free(b);
free(c);

}

	.file	"tmpxft_002debd8_00000000-6_cuda3.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2050:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2050:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z13r8_uniform_01Pi
	.type	_Z13r8_uniform_01Pi, @function
_Z13r8_uniform_01Pi:
.LFB2040:
	.cfi_startproc
	endbr64
	movl	(%rdi), %eax
	movl	$127773, %ecx
	cltd
	idivl	%ecx
	imull	$-127773, %eax, %edx
	addl	(%rdi), %edx
	imull	$16807, %edx, %edx
	imull	$-2836, %eax, %eax
	addl	%edx, %eax
	jns	.L3
	addl	$2147483647, %eax
.L3:
	cvtsi2sdl	%eax, %xmm0
	movl	%eax, (%rdi)
	mulsd	.LC0(%rip), %xmm0
	ret
	.cfi_endproc
.LFE2040:
	.size	_Z13r8_uniform_01Pi, .-_Z13r8_uniform_01Pi
	.globl	_Z13retrieve_itemPfyyy
	.type	_Z13retrieve_itemPfyyy, @function
_Z13retrieve_itemPfyyy:
.LFB2042:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE2042:
	.size	_Z13retrieve_itemPfyyy, .-_Z13retrieve_itemPfyyy
	.globl	_Z9set_entryPfyyfy
	.type	_Z9set_entryPfyyfy, @function
_Z9set_entryPfyyfy:
.LFB2043:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE2043:
	.size	_Z9set_entryPfyyfy, .-_Z9set_entryPfyyfy
	.globl	_Z14get_next_blockPfyyy
	.type	_Z14get_next_blockPfyyy, @function
_Z14get_next_blockPfyyy:
.LFB2044:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE2044:
	.size	_Z14get_next_blockPfyyy, .-_Z14get_next_blockPfyyy
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC1:
	.string	"Usage: %s -n <matrix dimensions>\n"
.LC2:
	.string	"Options:\n"
.LC3:
	.string	"  -h         Print this help message.\n"
.LC4:
	.string	"  -n         Dimensions of the matrices.\n"
.LC5:
	.string	"\nExamples:\n"
.LC6:
	.string	"  %s -n 256 > output.txt\n"
.LC7:
	.string	"  %s -n 4096 > output.txt\n"
	.text
	.globl	_Z5usagePPc
	.type	_Z5usagePPc, @function
_Z5usagePPc:
.LFB2046:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	movq	(%rdi), %rdx
	movq	%rdi, %rbx
	leaq	.LC1(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	.LC2(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	.LC3(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	.LC4(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	.LC5(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	(%rbx), %rdx
	movl	$2, %edi
	xorl	%eax, %eax
	leaq	.LC6(%rip), %rsi
	call	__printf_chk@PLT
	movq	(%rbx), %rdx
	movl	$2, %edi
	xorl	%eax, %eax
	leaq	.LC7(%rip), %rsi
	call	__printf_chk@PLT
	xorl	%edi, %edi
	call	exit@PLT
	.cfi_endproc
.LFE2046:
	.size	_Z5usagePPc, .-_Z5usagePPc
	.globl	_Z45__device_stub__Z20global_memory_kernelPfS_S_yPfS_S_y
	.type	_Z45__device_stub__Z20global_memory_kernelPfS_S_yPfS_S_y, @function
_Z45__device_stub__Z20global_memory_kernelPfS_S_yPfS_S_y:
.LFB2072:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movq	%rdi, 24(%rsp)
	leaq	56(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	68(%rsp), %rsi
	movq	%rdx, 8(%rsp)
	leaq	40(%rsp), %rdx
	movq	%rcx, (%rsp)
	leaq	48(%rsp), %rcx
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 64(%rsp)
	movq	%rax, 104(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 120(%rsp)
	movq	%rsp, %rax
	movq	%rax, 128(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 56(%rsp)
	movq	%rax, 68(%rsp)
	movl	$1, 76(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L13
	pushq	48(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z20global_memory_kernelPfS_S_y(%rip), %rdi
	pushq	48(%rsp)
	.cfi_def_cfa_offset 176
	movq	84(%rsp), %rcx
	movl	92(%rsp), %r8d
	movq	72(%rsp), %rsi
	movl	80(%rsp), %edx
	leaq	120(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 168
	popq	%rdx
	.cfi_def_cfa_offset 160
.L13:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L15
	call	__stack_chk_fail@PLT
.L15:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2072:
	.size	_Z45__device_stub__Z20global_memory_kernelPfS_S_yPfS_S_y, .-_Z45__device_stub__Z20global_memory_kernelPfS_S_yPfS_S_y
	.globl	_Z20global_memory_kernelPfS_S_y
	.type	_Z20global_memory_kernelPfS_S_y, @function
_Z20global_memory_kernelPfS_S_y:
.LFB2073:
	.cfi_startproc
	endbr64
	jmp	_Z45__device_stub__Z20global_memory_kernelPfS_S_yPfS_S_y
	.cfi_endproc
.LFE2073:
	.size	_Z20global_memory_kernelPfS_S_y, .-_Z20global_memory_kernelPfS_S_y
	.section	.rodata.str1.1
.LC10:
	.string	"\n"
.LC11:
	.string	"Run number: %d\n"
.LC12:
	.string	"  Floating point OPS roughly %llu\n"
.LC13:
	.string	"  Elapsed time dT = %f\n"
.LC14:
	.string	"  Rate = MegaOPS/dT = %f\n"
	.text
	.globl	_Z13global_memoryPfS_S_y
	.type	_Z13global_memoryPfS_S_y, @function
_Z13global_memoryPfS_S_y:
.LFB2041:
	.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
	movq	%rdi, %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%rsi, %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movq	%rcx, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$104, %rsp
	.cfi_def_cfa_offset 160
	movq	dimension(%rip), %rbx
	movq	%rdx, 8(%rsp)
	leaq	24(%rsp), %rdi
	movq	%rbx, %r15
	imulq	%rbx, %r15
	movq	%fs:40, %rax
	movq	%rax, 88(%rsp)
	xorl	%eax, %eax
	leaq	0(,%r15,4), %rbp
	movq	%rbp, %rsi
	call	cudaMalloc@PLT
	movq	24(%rsp), %rdi
	movq	%rbp, %rdx
	movq	%r14, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	leaq	32(%rsp), %rdi
	movq	%rbp, %rsi
	call	cudaMalloc@PLT
	movq	32(%rsp), %rdi
	movq	%rbp, %rdx
	movq	%r13, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movq	%rbp, %rsi
	leaq	40(%rsp), %rdi
	call	cudaMalloc@PLT
	leaq	15(%rbx), %rax
	leaq	48(%rsp), %rdi
	movl	$1, 84(%rsp)
	shrq	$4, %rax
	movl	%eax, 76(%rsp)
	movl	%eax, 80(%rsp)
	call	cudaEventCreate@PLT
	leaq	56(%rsp), %rdi
	call	cudaEventCreate@PLT
	movq	48(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	76(%rsp), %rdi
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	84(%rsp), %esi
	movl	$1, %ecx
	movabsq	$68719476752, %rdx
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L19
	movq	dimension(%rip), %rcx
	movq	40(%rsp), %rdx
	movq	32(%rsp), %rsi
	movq	24(%rsp), %rdi
	call	_Z45__device_stub__Z20global_memory_kernelPfS_S_yPfS_S_y
.L19:
	call	cudaThreadSynchronize@PLT
	movq	56(%rsp), %rdi
	xorl	%esi, %esi
	imulq	%r15, %rbx
	call	cudaEventRecord@PLT
	movq	56(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movq	56(%rsp), %rdx
	movq	48(%rsp), %rsi
	leaq	20(%rsp), %rdi
	call	cudaEventElapsedTime@PLT
	movq	48(%rsp), %rdi
	call	cudaEventDestroy@PLT
	movq	56(%rsp), %rdi
	call	cudaEventDestroy@PLT
	movss	20(%rsp), %xmm1
	divss	.LC8(%rip), %xmm1
	movss	%xmm1, 20(%rsp)
	addq	%rbx, %rbx
	js	.L20
	cvtsi2sdq	%rbx, %xmm0
	jmp	.L21
.L20:
	movq	%rbx, %rax
	movq	%rbx, %rdx
	shrq	%rax
	andl	$1, %edx
	orq	%rdx, %rax
	cvtsi2sdq	%rax, %xmm0
	addsd	%xmm0, %xmm0
.L21:
	cvtss2sd	%xmm1, %xmm1
	divsd	%xmm1, %xmm0
	leaq	.LC10(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	divsd	.LC9(%rip), %xmm0
	movq	%xmm0, %r13
	call	__printf_chk@PLT
	movq	%r12, %rdx
	movl	$2, %edi
	xorl	%eax, %eax
	leaq	.LC11(%rip), %rsi
	call	__printf_chk@PLT
	movq	%rbx, %rdx
	movl	$2, %edi
	xorl	%eax, %eax
	leaq	.LC12(%rip), %rsi
	call	__printf_chk@PLT
	leaq	.LC13(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	cvtss2sd	20(%rsp), %xmm0
	call	__printf_chk@PLT
	movq	%r13, %xmm0
	movb	$1, %al
	leaq	.LC14(%rip), %rsi
	movl	$2, %edi
	call	__printf_chk@PLT
	movq	40(%rsp), %rsi
	movq	8(%rsp), %rdi
	movq	%rbp, %rdx
	movl	$2, %ecx
	call	cudaMemcpy@PLT
	movq	24(%rsp), %rdi
	call	cudaFree@PLT
	movq	32(%rsp), %rdi
	call	cudaFree@PLT
	movq	40(%rsp), %rdi
	call	cudaFree@PLT
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	je	.L22
	call	__stack_chk_fail@PLT
.L22:
	addq	$104, %rsp
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2041:
	.size	_Z13global_memoryPfS_S_y, .-_Z13global_memoryPfS_S_y
	.globl	_Z45__device_stub__Z20shared_memory_kernelPfS_S_yPfS_S_y
	.type	_Z45__device_stub__Z20shared_memory_kernelPfS_S_yPfS_S_y, @function
_Z45__device_stub__Z20shared_memory_kernelPfS_S_yPfS_S_y:
.LFB2074:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movq	%rdi, 24(%rsp)
	leaq	56(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	68(%rsp), %rsi
	movq	%rdx, 8(%rsp)
	leaq	40(%rsp), %rdx
	movq	%rcx, (%rsp)
	leaq	48(%rsp), %rcx
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 64(%rsp)
	movq	%rax, 104(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 120(%rsp)
	movq	%rsp, %rax
	movq	%rax, 128(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 56(%rsp)
	movq	%rax, 68(%rsp)
	movl	$1, 76(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L24
	pushq	48(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z20shared_memory_kernelPfS_S_y(%rip), %rdi
	pushq	48(%rsp)
	.cfi_def_cfa_offset 176
	movq	84(%rsp), %rcx
	movl	92(%rsp), %r8d
	movq	72(%rsp), %rsi
	movl	80(%rsp), %edx
	leaq	120(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 168
	popq	%rdx
	.cfi_def_cfa_offset 160
.L24:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L26
	call	__stack_chk_fail@PLT
.L26:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2074:
	.size	_Z45__device_stub__Z20shared_memory_kernelPfS_S_yPfS_S_y, .-_Z45__device_stub__Z20shared_memory_kernelPfS_S_yPfS_S_y
	.globl	_Z20shared_memory_kernelPfS_S_y
	.type	_Z20shared_memory_kernelPfS_S_y, @function
_Z20shared_memory_kernelPfS_S_y:
.LFB2075:
	.cfi_startproc
	endbr64
	jmp	_Z45__device_stub__Z20shared_memory_kernelPfS_S_yPfS_S_y
	.cfi_endproc
.LFE2075:
	.size	_Z20shared_memory_kernelPfS_S_y, .-_Z20shared_memory_kernelPfS_S_y
	.globl	_Z13shared_memoryPfS_S_y
	.type	_Z13shared_memoryPfS_S_y, @function
_Z13shared_memoryPfS_S_y:
.LFB2045:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movq	%rsi, %r15
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%rcx, %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movq	%rdx, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%rdi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$104, %rsp
	.cfi_def_cfa_offset 160
	movq	dimension(%rip), %rbx
	movq	%fs:40, %rax
	movq	%rax, 88(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rdi
	movq	%rbx, %r14
	imulq	%rbx, %r14
	leaq	0(,%r14,4), %rdx
	movq	%rdx, %rsi
	movq	%rdx, 8(%rsp)
	call	cudaMalloc@PLT
	movq	8(%rsp), %rdx
	movq	24(%rsp), %rdi
	movq	%rbp, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movq	dimension(%rip), %rbp
	leaq	32(%rsp), %rdi
	imulq	%rbp, %rbp
	salq	$2, %rbp
	movq	%rbp, %rsi
	call	cudaMalloc@PLT
	movq	32(%rsp), %rdi
	movq	%rbp, %rdx
	movq	%r15, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movq	dimension(%rip), %rbp
	leaq	40(%rsp), %rdi
	imulq	%rbp, %rbp
	salq	$2, %rbp
	movq	%rbp, %rsi
	call	cudaMalloc@PLT
	movq	dimension(%rip), %rax
	leaq	48(%rsp), %rdi
	movl	$1, 84(%rsp)
	shrq	$4, %rax
	movl	%eax, 76(%rsp)
	movl	%eax, 80(%rsp)
	call	cudaEventCreate@PLT
	leaq	56(%rsp), %rdi
	call	cudaEventCreate@PLT
	movq	48(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	76(%rsp), %rdi
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	84(%rsp), %esi
	movl	$1, %ecx
	movabsq	$68719476752, %rdx
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L30
	movq	dimension(%rip), %rcx
	movq	40(%rsp), %rdx
	movq	32(%rsp), %rsi
	movq	24(%rsp), %rdi
	call	_Z45__device_stub__Z20shared_memory_kernelPfS_S_yPfS_S_y
.L30:
	call	cudaThreadSynchronize@PLT
	movq	56(%rsp), %rdi
	xorl	%esi, %esi
	imulq	%r14, %rbx
	call	cudaEventRecord@PLT
	movq	56(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movq	56(%rsp), %rdx
	movq	48(%rsp), %rsi
	leaq	20(%rsp), %rdi
	call	cudaEventElapsedTime@PLT
	movq	48(%rsp), %rdi
	call	cudaEventDestroy@PLT
	movq	56(%rsp), %rdi
	call	cudaEventDestroy@PLT
	movss	20(%rsp), %xmm1
	divss	.LC8(%rip), %xmm1
	movss	%xmm1, 20(%rsp)
	addq	%rbx, %rbx
	js	.L31
	cvtsi2sdq	%rbx, %xmm0
	jmp	.L32
.L31:
	movq	%rbx, %rax
	movq	%rbx, %rdx
	shrq	%rax
	andl	$1, %edx
	orq	%rdx, %rax
	cvtsi2sdq	%rax, %xmm0
	addsd	%xmm0, %xmm0
.L32:
	cvtss2sd	%xmm1, %xmm1
	divsd	%xmm1, %xmm0
	leaq	.LC10(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	divsd	.LC9(%rip), %xmm0
	movq	%xmm0, %r15
	call	__printf_chk@PLT
	movq	%r13, %rdx
	movl	$2, %edi
	xorl	%eax, %eax
	leaq	.LC11(%rip), %rsi
	call	__printf_chk@PLT
	movq	%rbx, %rdx
	movl	$2, %edi
	xorl	%eax, %eax
	leaq	.LC12(%rip), %rsi
	call	__printf_chk@PLT
	leaq	.LC13(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	cvtss2sd	20(%rsp), %xmm0
	call	__printf_chk@PLT
	movq	%r15, %xmm0
	movb	$1, %al
	leaq	.LC14(%rip), %rsi
	movl	$2, %edi
	call	__printf_chk@PLT
	movq	40(%rsp), %rsi
	movq	%rbp, %rdx
	movq	%r12, %rdi
	movl	$2, %ecx
	call	cudaMemcpy@PLT
	movq	24(%rsp), %rdi
	call	cudaFree@PLT
	movq	32(%rsp), %rdi
	call	cudaFree@PLT
	movq	40(%rsp), %rdi
	call	cudaFree@PLT
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	je	.L33
	call	__stack_chk_fail@PLT
.L33:
	addq	$104, %rsp
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2045:
	.size	_Z13shared_memoryPfS_S_y, .-_Z13shared_memoryPfS_S_y
	.section	.rodata.str1.1
.LC16:
	.string	"n:h"
.LC17:
	.string	"Thread Block Size: %d\n"
.LC18:
	.string	"========================Unoptimized CUDA Multiplication================================\n"
.LC20:
	.string	"Average Elapsed Time dT: %f\n"
.LC21:
	.string	"Average Rate: %f\n"
.LC22:
	.string	"========================Blocking Optimized CUDA Multiplication================================\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2047:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	leaq	.LC16(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movl	%edi, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	%rsi, %rbx
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
.L36:
	movq	%r12, %rdx
	movq	%rbx, %rsi
	movl	%ebp, %edi
	call	getopt@PLT
	cmpb	$-1, %al
	je	.L55
	cmpb	$110, %al
	jne	.L37
	movq	optarg(%rip), %rdi
	call	atoi@PLT
	cltq
	movq	%rax, dimension(%rip)
	jmp	.L36
.L37:
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L54
	movq	%rbx, %rdi
	call	_Z5usagePPc
.L55:
	movq	dimension(%rip), %r13
	movq	%r13, %r12
	imulq	%r13, %r12
	salq	$2, %r12
	movq	%r12, %rdi
	call	malloc@PLT
	movq	%r12, %rdi
	movq	%rax, %rbp
	call	malloc@PLT
	movq	%r12, %rdi
	movq	%rax, %rbx
	call	malloc@PLT
	xorl	%r9d, %r9d
	xorl	%esi, %esi
	leaq	20(%rsp), %rdi
	movl	$123456789, 20(%rsp)
	movq	%rax, %r12
.L40:
	cmpq	%rsi, %r13
	je	.L56
	leaq	0(%rbp,%r9,4), %r10
	xorl	%r8d, %r8d
.L41:
	call	_Z13r8_uniform_01Pi
	cvtsd2ss	%xmm0, %xmm0
	movss	%xmm0, (%r10,%r8,4)
	incq	%r8
	cmpq	%r8, %r13
	jne	.L41
	incq	%rsi
	addq	%r13, %r9
	jmp	.L40
.L56:
	xorl	%r10d, %r10d
	xorl	%r9d, %r9d
	leaq	20(%rsp), %rdi
.L43:
	cmpq	%r9, %rsi
	je	.L57
	leaq	(%rbx,%r10,4), %r11
	xorl	%r8d, %r8d
.L44:
	call	_Z13r8_uniform_01Pi
	cvtsd2ss	%xmm0, %xmm0
	movss	%xmm0, (%r11,%r8,4)
	incq	%r8
	cmpq	%r8, %rsi
	jne	.L44
	incq	%r9
	addq	%rsi, %r10
	jmp	.L43
.L57:
	movl	$16, %edx
	movl	$2, %edi
	xorl	%eax, %eax
	xorl	%r14d, %r14d
	leaq	.LC17(%rip), %rsi
	leaq	.LC10(%rip), %r15
	call	__printf_chk@PLT
	movq	%r15, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	.LC18(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	xorps	%xmm1, %xmm1
	movaps	%xmm1, %xmm0
.L46:
	movq	%r14, %rcx
	movq	%r12, %rdx
	movq	%rbx, %rsi
	movq	%rbp, %rdi
	movsd	%xmm1, 8(%rsp)
	incq	%r14
	movsd	%xmm0, (%rsp)
	call	_Z13global_memoryPfS_S_y
	movsd	(%rsp), %xmm0
	movsd	8(%rsp), %xmm1
	addsd	(%rax), %xmm0
	addsd	8(%rax), %xmm1
	cmpq	$10, %r14
	jne	.L46
	leaq	.LC20(%rip), %r14
	divsd	.LC19(%rip), %xmm1
	movl	$2, %edi
	movq	%xmm1, %r13
	movq	%r14, %rsi
	movb	$1, %al
	divsd	.LC19(%rip), %xmm0
	call	__printf_chk@PLT
	movq	%r13, %xmm0
	leaq	.LC21(%rip), %r13
	movb	$1, %al
	movq	%r13, %rsi
	movl	$2, %edi
	call	__printf_chk@PLT
	movq	%r15, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	$2, %edi
	xorl	%eax, %eax
	xorl	%r15d, %r15d
	leaq	.LC22(%rip), %rsi
	call	__printf_chk@PLT
	xorps	%xmm1, %xmm1
	movaps	%xmm1, %xmm0
.L47:
	movq	%r15, %rcx
	movq	%r12, %rdx
	movq	%rbx, %rsi
	movq	%rbp, %rdi
	movsd	%xmm1, 8(%rsp)
	incq	%r15
	movsd	%xmm0, (%rsp)
	call	_Z13shared_memoryPfS_S_y
	movsd	(%rsp), %xmm0
	movsd	8(%rsp), %xmm1
	addsd	(%rax), %xmm0
	addsd	8(%rax), %xmm1
	cmpq	$10, %r15
	jne	.L47
	divsd	.LC19(%rip), %xmm1
	movq	%r14, %rsi
	movq	%xmm1, %r15
	movl	$2, %edi
	movb	$1, %al
	divsd	.LC19(%rip), %xmm0
	call	__printf_chk@PLT
	movq	%r15, %xmm0
	movq	%r13, %rsi
	movb	$1, %al
	movl	$2, %edi
	call	__printf_chk@PLT
	movq	%rbp, %rdi
	call	free@PLT
	movq	%rbx, %rdi
	call	free@PLT
	movq	%r12, %rdi
	call	free@PLT
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	je	.L48
.L54:
	call	__stack_chk_fail@PLT
.L48:
	addq	$40, %rsp
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2047:
	.size	main, .-main
	.section	.rodata.str1.1
.LC23:
	.string	"_Z20shared_memory_kernelPfS_S_y"
.LC24:
	.string	"_Z20global_memory_kernelPfS_S_y"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2077:
	.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	.LC23(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z20shared_memory_kernelPfS_S_y(%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	.LC24(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z20global_memory_kernelPfS_S_y(%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
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	addq	$32, %rsp
	.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
.LFE2077:
	.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	dimension
	.bss
	.align 8
	.type	dimension, @object
	.size	dimension, 8
dimension:
	.zero	8
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC0:
	.long	1859432
	.long	1040187392
	.section	.rodata.cst4,"aM",@progbits,4
	.align 4
.LC8:
	.long	1148846080
	.section	.rodata.cst8
	.align 8
.LC9:
	.long	0
	.long	1093567616
	.align 8
.LC19:
	.long	0
	.long	1076101120
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:


#include <hip/hip_runtime.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <getopt.h>
#include <time.h>
#include <unistd.h>
#include <string.h>

//global variable for dimensions of matrices
unsigned long long dimension;


//--Function to randomly seed values in the matrices
//provided by Shahadat
double r8_uniform_01 ( int *seed ){
  int k;
  double r;

  k = *seed / 127773;

  *seed = 16807 * ( *seed - k * 127773 ) - k * 2836;

  if ( *seed < 0 )
  {
    *seed = *seed + 2147483647;
  }

  r = ( double ) ( *seed ) * 4.656612875E-10;

  return r;
}

//We will use this define statement to specify what the size of the thread blocks should be
//optimum has been determined to be 16
#define BLOCK_SIZE 16

__global__ void global_memory_kernel(float* a, float* b, float* c, unsigned long long dimension) {
// Each thread computes one element of c
// by accumulating results into accumulator
float accumulator = 0.0;
//iterate through the row s and columns of the thread block
unsigned long long row = blockIdx.y * blockDim.y + threadIdx.y;
unsigned long long col = blockIdx.x * blockDim.x + threadIdx.x;
//if we go out of bounds, stop
if(row > dimension || col > dimension) return;
//since each thread is computing one element of c, grab the appropriate
//element from a's row, and b's column, and multply them and hold them in the accumulator
//then set the value in c
for (unsigned long long e = 0; e < dimension; ++e)
accumulator += (a[row * dimension + e]) * (b[e * dimension + col]);
c[row * dimension + col] = accumulator;
}

//function doing matrix multiplication using only global memory
double* global_memory( float* a, float* b, float* c, unsigned long long run_number) {

double dt_and_rate[2];

unsigned long long l = dimension;
unsigned long long m = dimension;
unsigned long long n = dimension;

// Load A and B to device memory
float* cuda_A;

unsigned long long size = l*l*sizeof(float);

hipMalloc(&cuda_A, size);
hipMemcpy(cuda_A, a, size, hipMemcpyHostToDevice);

float* cuda_B;
size = l* l * sizeof(float);
hipMalloc(&cuda_B, size);
hipMemcpy(cuda_B, b, size, hipMemcpyHostToDevice);


// Allocate C in device memory

float* cuda_C;
size = l * l * sizeof(float);
hipMalloc(&cuda_C, size);



//set up the block and grid dimensions
//using BLOCK_SIZEXBLOCK_SIZE for the blocks
dim3 dimBlock(BLOCK_SIZE, BLOCK_SIZE);
//setting up the dimensions of the grid
//using this method so that we find the numbers such that the correct number of blocks
//reside within the grid

//e.g. for a 1024* 1024 matrix:

//BLOCK_SIZE = 16
//l = 1024
//the formula is thus:
//(1024+16-1)/16 = 1029/16 = 64.6125 = 64 (because integer division)
//and what happens if we multiply by our thread block size? --> 64 * 16 = 1024, which returns our dimension

//the same reasoning goes for the y dimension
dim3 dimGrid((l + dimBlock.x - 1) / dimBlock.x,(l + dimBlock.y - 1) / dimBlock.y);

//declare variable to find out elapsed time
float time_elapsed;


//CUDA time keeping variables
hipEvent_t start, stop;
hipEventCreate(&start);
hipEventCreate(&stop);
hipEventRecord(start,0);
//run the function on the GPU
global_memory_kernel<<<dimGrid, dimBlock>>>(cuda_A, cuda_B, cuda_C, dimension);
//synchronize threads
hipDeviceSynchronize();

//CUDA timekeeping stop events
hipEventRecord(stop,0);
hipEventSynchronize(stop);
//store the elapsed time
hipEventElapsedTime(&time_elapsed,start,stop);
hipEventDestroy(start);
hipEventDestroy(stop);

//figure out how many operations needed to be done
unsigned long long ops = l * l * ( 2 * l );

time_elapsed = time_elapsed/1000; //change into seconds
//figure out the rate
double rate = ( double ) ( ops ) / time_elapsed / 1000000.0;

  printf ( "\n" );
  printf("Run number: %d\n", run_number);
  printf ( "  Floating point OPS roughly %llu\n", ops );
  printf ( "  Elapsed time dT = %f\n", time_elapsed);
  printf ( "  Rate = MegaOPS/dT = %f\n", rate );


// Read C from device memory
hipMemcpy(c, cuda_C, size, hipMemcpyDeviceToHost);



//return values for main
  dt_and_rate[0]=time_elapsed;
  dt_and_rate[1]=rate;

// Free device memory
hipFree(cuda_A);
hipFree(cuda_B);
hipFree(cuda_C);

return dt_and_rate;
}



//retrieve a matrix element
//device function because this needs to execute on the graphics card, not on host machines
__device__ float retrieve_item(float* a, unsigned long long row, unsigned long long col, unsigned long long dim) {
return a[row * dim + col];
}


// Set a matrix element
//device function because this needs to execute on the graphics card, not on host machines
__device__ void set_entry(float* a, unsigned long long row, unsigned long long col, float value, unsigned long long dim) {
a[row * dim + col] = value;
}

//get the next sub-block of a matrix when doing blocking multiplication
__device__ float* get_next_block(float* a, unsigned long long row, unsigned long long col, unsigned long long dimension) {
float* block_a;
block_a = &a[dimension * BLOCK_SIZE * row + BLOCK_SIZE * col];
return block_a;
}


// Matrix multiplication kernel called by MatMul()
__global__ void shared_memory_kernel(float* a, float* b, float* c, unsigned long long dimension) {
// Block row and column
unsigned long long blockRow = blockIdx.y;
unsigned long long blockCol = blockIdx.x;
// Each thread block computes one sub-matrix of C
float* block_c = get_next_block(c, blockRow, blockCol, dimension);
// Each thread computes one element of the tile of C
// by accumulating results into accumulator
float accumulator = 0.0;
// Thread row and column within the tile of c
unsigned long long row = threadIdx.y;
unsigned long long col = threadIdx.x;
// Loop over all A and B's tiles
// Multiply each pair of sub-matrices together
// and accumulate the results
for (unsigned long long m = 0; m < (dimension / BLOCK_SIZE); ++m) {
// Get sub-matrix of A
float* block_a = get_next_block(a, blockRow, m, dimension);
// Get sub-matrix of B
float* block_b = get_next_block(b, m, blockCol, dimension);
// Shared memory used to store the tiles of A and B
__shared__ float a_shared[BLOCK_SIZE][BLOCK_SIZE];
__shared__ float b_shared[BLOCK_SIZE][BLOCK_SIZE];
// Load tiles from device memory to shared memory
// Each thread loads one element of each sub-matrix
a_shared[row][col] = retrieve_item(block_a, row, col, dimension);
b_shared[row][col] = retrieve_item(block_b, row, col, dimension);
// Synchronize to make sure the sub-matrices are loaded
// before starting the computation
__syncthreads();
// Multiply Asub and Bsub together
for (unsigned long long e = 0; e < BLOCK_SIZE; ++e)
accumulator += a_shared[row][e] * b_shared[e][col];
// Synchronize to make sure that the preceding
// computation is done before loading two new
// sub-matrices of A and B in the next iteration
__syncthreads();
}
// Write the tile of to device memory
// Each thread writes one element
set_entry(block_c, row, col, accumulator, dimension);
}


//function to execute shared-memory version of blocking matrix multiplication
double* shared_memory(float* a, float* b, float* c, unsigned long long run_number) {


double dt_and_rate[2];

unsigned long long l = dimension;
unsigned long long m = dimension;
unsigned long long n = dimension;


// Load A and B to device memory
float* cuda_A;

unsigned long long size = dimension * dimension * sizeof(float);
//allocate device memory
hipMalloc(&cuda_A, size);
//copy to device
hipMemcpy(cuda_A, a, size, hipMemcpyHostToDevice);
//do the same for b
float* cuda_B;
size = dimension * dimension * sizeof(float);
hipMalloc(&cuda_B, size);
hipMemcpy(cuda_B, b, size, hipMemcpyHostToDevice);
// Allocate C in device memory
float* cuda_C;
size = dimension * dimension * sizeof(float);
hipMalloc(&cuda_C, size);
//set up float for timer
float time_elapsed;


//st up the block and grid for device
dim3 dimBlock(BLOCK_SIZE, BLOCK_SIZE);
dim3 dimGrid(dimension / dimBlock.x, dimension / dimBlock.y);
//start timers
hipEvent_t start, stop;
hipEventCreate(&start);
hipEventCreate(&stop);
hipEventRecord(start,0);

//call the CUDA function
shared_memory_kernel<<<dimGrid, dimBlock>>>(cuda_A, cuda_B, cuda_C, dimension);
//synchronize threads
hipDeviceSynchronize();

hipEventRecord(stop,0);
hipEventSynchronize(stop);
hipEventElapsedTime(&time_elapsed,start,stop);
hipEventDestroy(start);
hipEventDestroy(stop);
//figure out how many operations we have done
unsigned long long ops = l * l * ( 2 * l );

time_elapsed = time_elapsed/1000; //change into seconds
  //get the rate
  double rate = ( double ) ( ops ) / time_elapsed / 1000000.0;

  printf ( "\n" );
  printf("Run number: %d\n", run_number);
  printf ( "  Floating point OPS roughly %llu\n", ops );
  printf ( "  Elapsed time dT = %f\n", time_elapsed);
  printf ( "  Rate = MegaOPS/dT = %f\n", rate );



// Read c from device memory
hipMemcpy(c, cuda_C, size, hipMemcpyDeviceToHost);

// Free device memory
hipFree(cuda_A);
hipFree(cuda_B);
hipFree(cuda_C);


dt_and_rate[0]=time_elapsed;
dt_and_rate[1]=rate;

return dt_and_rate;



}

void usage (char* argv[])
{
  //go through and print out any relevant information for command line arguments
  //to use the program
    printf("Usage: %s -n <matrix dimensions>\n", argv[0]);
    printf("Options:\n");
    printf("  -h         Print this help message.\n");
    printf("  -n         Dimensions of the matrices.\n");
    printf("\nExamples:\n");
    printf("  %s -n 256 > output.txt\n", argv[0]);
    printf("  %s -n 4096 > output.txt\n", argv[0]);
    //end the program
    exit(0);
}

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

//used to determine average rates and times
double* temp;
double average_dt=0.0;
double average_rate=0.0;
//get command line options
char options;
    while( (options=getopt(argc,argv,"n:h")) != -1){
        switch(options){
        case 'n':
            dimension = atoi(optarg);
            break;
        case 'h':
            usage(argv);
            exit(0);
        default:
            usage(argv);
            exit(1);
        }
    }
//allocate space
float* a = (float*)malloc(dimension * dimension * sizeof(float));

float* b = (float*)malloc(dimension * dimension * sizeof(float));

float* c = (float*)malloc(dimension * dimension * sizeof(float));

int seed=123456789;

//seed the matrices with random values
for(unsigned long long i = 0; i < dimension; i++){
  for(unsigned long long j = 0; j < dimension; j++){

    a[i*dimension + j] = (float) (r8_uniform_01 ( &seed ));
  }
}

for(unsigned long long i = 0; i < dimension; i++){
  for(unsigned long long j = 0; j < dimension; j++){

    b[i*dimension + j] = (float) (r8_uniform_01 ( &seed ));
  }
}


printf ("Thread Block Size: %d\n", BLOCK_SIZE);

printf( "\n" );
printf( "========================Unoptimized CUDA Multiplication================================\n" );

for(unsigned long long i =0; i < 10; i++){
temp = global_memory(a, b, c,i);
average_dt += temp[0];
average_rate += temp[1];

}

average_rate = (double) average_rate/10;
average_dt = (double) average_dt/10;
printf("Average Elapsed Time dT: %f\n", average_dt);
printf("Average Rate: %f\n", average_rate);
average_rate=average_dt=0.0;

printf( "\n" );
printf( "========================Blocking Optimized CUDA Multiplication================================\n" );


for(unsigned long long i=0; i<10;i++){
temp=shared_memory(a,b,c,i);
average_dt += temp[0];
average_rate += temp[1];
}

average_rate = (double) average_rate/10;
average_dt = (double) average_dt/10;
printf("Average Elapsed Time dT: %f\n", average_dt);
printf("Average Rate: %f\n", average_rate);
average_rate=average_dt=0.0;



//free host memory
free(a);
free(b);
free(c);

}

	.text
	.file	"cuda3.hip"
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z13r8_uniform_01Pi
.LCPI0_0:
	.quad	0x3e000000001c5f68              # double 4.6566128750000002E-10
	.text
	.globl	_Z13r8_uniform_01Pi
	.type	_Z13r8_uniform_01Pi,@function
_Z13r8_uniform_01Pi:                    # @_Z13r8_uniform_01Pi
	.cfi_startproc
# %bb.0:
	movslq	(%rdi), %rax
	imulq	$-2092037281, %rax, %rcx        # imm = 0x834E0B5F
	shrq	$32, %rcx
	addl	%eax, %ecx
	movl	%ecx, %edx
	shrl	$31, %edx
	sarl	$16, %ecx
	addl	%edx, %ecx
	imull	$-127773, %ecx, %edx            # imm = 0xFFFE0CE3
	addl	%eax, %edx
	imull	$16807, %edx, %eax              # imm = 0x41A7
	imull	$-2836, %ecx, %ecx              # imm = 0xF4EC
	leal	(%rax,%rcx), %edx
	addl	$2147483647, %edx               # imm = 0x7FFFFFFF
                                        # kill: def $eax killed $eax killed $rax
	addl	%ecx, %eax
	cmovnsl	%eax, %edx
	cvtsi2sd	%edx, %xmm0
	movl	%edx, (%rdi)
	mulsd	.LCPI0_0(%rip), %xmm0
	retq
.Lfunc_end0:
	.size	_Z13r8_uniform_01Pi, .Lfunc_end0-_Z13r8_uniform_01Pi
	.cfi_endproc
                                        # -- End function
	.globl	_Z35__device_stub__global_memory_kernelPfS_S_y # -- Begin function _Z35__device_stub__global_memory_kernelPfS_S_y
	.type	_Z35__device_stub__global_memory_kernelPfS_S_y,@function
_Z35__device_stub__global_memory_kernelPfS_S_y: # @_Z35__device_stub__global_memory_kernelPfS_S_y
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$112, %rsp
	.cfi_def_cfa_offset 160
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	32(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	24(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	16(%rsp), %rdx
	movq	%rcx, (%rdx)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	8(%rsp), %r12
	movq	%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	$_Z20global_memory_kernelPfS_S_y, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$128, %rsp
	.cfi_adjust_cfa_offset -128
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end1:
	.size	_Z35__device_stub__global_memory_kernelPfS_S_y, .Lfunc_end1-_Z35__device_stub__global_memory_kernelPfS_S_y
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function _Z13global_memoryPfS_S_y
.LCPI2_0:
	.long	0x447a0000                      # float 1000
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0
.LCPI2_1:
	.long	1127219200                      # 0x43300000
	.long	1160773632                      # 0x45300000
	.long	0                               # 0x0
	.long	0                               # 0x0
.LCPI2_2:
	.quad	0x4330000000000000              # double 4503599627370496
	.quad	0x4530000000000000              # double 1.9342813113834067E+25
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0
.LCPI2_3:
	.quad	0x412e848000000000              # double 1.0E+6
	.text
	.globl	_Z13global_memoryPfS_S_y
	.type	_Z13global_memoryPfS_S_y,@function
_Z13global_memoryPfS_S_y:               # @_Z13global_memoryPfS_S_y
	.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	$104, %rsp
	.cfi_def_cfa_offset 160
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rcx, 40(%rsp)                  # 8-byte Spill
	movq	%rdx, 48(%rsp)                  # 8-byte Spill
	movq	%rsi, %r13
	movq	%rdi, %rbp
	movq	dimension(%rip), %r15
	movq	%r15, %r12
	imulq	%r15, %r12
	leaq	(,%r12,4), %r14
	leaq	32(%rsp), %rbx
	movq	%rbx, %rdi
	movq	%r14, %rsi
	callq	hipMalloc
	movq	(%rbx), %rdi
	movq	%rbp, %rsi
	movq	%r14, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	leaq	24(%rsp), %rbx
	movq	%rbx, %rdi
	movq	%r14, %rsi
	callq	hipMalloc
	movq	(%rbx), %rdi
	movq	%r13, %rsi
	movq	%r14, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	leaq	8(%rsp), %rdi
	movq	%r14, %rsi
	callq	hipMalloc
	leaq	15(%r15), %rbx
	shrq	$4, %rbx
	movl	%ebx, %eax
	shlq	$32, %rbx
	orq	%rax, %rbx
	leaq	16(%rsp), %r13
	movq	%r13, %rdi
	callq	hipEventCreate
	movq	%rsp, %rdi
	callq	hipEventCreate
	movq	(%r13), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movabsq	$68719476752, %rdx              # imm = 0x1000000010
	movq	%rbx, %rdi
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB2_2
# %bb.1:
	movq	32(%rsp), %rdi
	movq	24(%rsp), %rsi
	movq	8(%rsp), %rdx
	movq	dimension(%rip), %rcx
	callq	_Z35__device_stub__global_memory_kernelPfS_S_y
.LBB2_2:
	callq	hipDeviceSynchronize
	movq	(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	(%rsp), %rdi
	callq	hipEventSynchronize
	movq	16(%rsp), %rsi
	movq	(%rsp), %rdx
	leaq	60(%rsp), %r13
	movq	%r13, %rdi
	callq	hipEventElapsedTime
	movq	16(%rsp), %rdi
	callq	hipEventDestroy
	movq	(%rsp), %rdi
	callq	hipEventDestroy
	imulq	%r12, %r15
	addq	%r15, %r15
	movss	(%r13), %xmm0                   # xmm0 = mem[0],zero,zero,zero
	divss	.LCPI2_0(%rip), %xmm0
	movq	%r15, %xmm1
	punpckldq	.LCPI2_1(%rip), %xmm1   # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
	subpd	.LCPI2_2(%rip), %xmm1
	movss	%xmm0, (%r13)
	movapd	%xmm1, %xmm2
	unpckhpd	%xmm1, %xmm2                    # xmm2 = xmm2[1],xmm1[1]
	addsd	%xmm1, %xmm2
	cvtss2sd	%xmm0, %xmm0
	divsd	%xmm0, %xmm2
	divsd	.LCPI2_3(%rip), %xmm2
	movapd	%xmm2, 64(%rsp)                 # 16-byte Spill
	movl	$10, %edi
	callq	putchar@PLT
	movl	$.L.str.1, %edi
	movq	40(%rsp), %rsi                  # 8-byte Reload
	xorl	%eax, %eax
	callq	printf
	movl	$.L.str.2, %edi
	movq	%r15, %rsi
	xorl	%eax, %eax
	callq	printf
	xorps	%xmm0, %xmm0
	cvtss2sd	(%r13), %xmm0
	movl	$.L.str.3, %edi
	movb	$1, %al
	callq	printf
	movl	$.L.str.4, %edi
	movaps	64(%rsp), %xmm0                 # 16-byte Reload
	movb	$1, %al
	callq	printf
	movq	8(%rsp), %rsi
	movq	48(%rsp), %rdi                  # 8-byte Reload
	movq	%r14, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	movq	32(%rsp), %rdi
	callq	hipFree
	movq	24(%rsp), %rdi
	callq	hipFree
	movq	8(%rsp), %rdi
	callq	hipFree
	leaq	80(%rsp), %rax
	addq	$104, %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	_Z13global_memoryPfS_S_y, .Lfunc_end2-_Z13global_memoryPfS_S_y
	.cfi_endproc
                                        # -- End function
	.globl	_Z35__device_stub__shared_memory_kernelPfS_S_y # -- Begin function _Z35__device_stub__shared_memory_kernelPfS_S_y
	.type	_Z35__device_stub__shared_memory_kernelPfS_S_y,@function
_Z35__device_stub__shared_memory_kernelPfS_S_y: # @_Z35__device_stub__shared_memory_kernelPfS_S_y
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$112, %rsp
	.cfi_def_cfa_offset 160
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	32(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	24(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	16(%rsp), %rdx
	movq	%rcx, (%rdx)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	8(%rsp), %r12
	movq	%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	$_Z20shared_memory_kernelPfS_S_y, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$128, %rsp
	.cfi_adjust_cfa_offset -128
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end3:
	.size	_Z35__device_stub__shared_memory_kernelPfS_S_y, .Lfunc_end3-_Z35__device_stub__shared_memory_kernelPfS_S_y
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function _Z13shared_memoryPfS_S_y
.LCPI4_0:
	.long	0x447a0000                      # float 1000
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0
.LCPI4_1:
	.long	1127219200                      # 0x43300000
	.long	1160773632                      # 0x45300000
	.long	0                               # 0x0
	.long	0                               # 0x0
.LCPI4_2:
	.quad	0x4330000000000000              # double 4503599627370496
	.quad	0x4530000000000000              # double 1.9342813113834067E+25
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0
.LCPI4_3:
	.quad	0x412e848000000000              # double 1.0E+6
	.text
	.globl	_Z13shared_memoryPfS_S_y
	.type	_Z13shared_memoryPfS_S_y,@function
_Z13shared_memoryPfS_S_y:               # @_Z13shared_memoryPfS_S_y
	.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	$104, %rsp
	.cfi_def_cfa_offset 160
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rcx, 40(%rsp)                  # 8-byte Spill
	movq	%rdx, 48(%rsp)                  # 8-byte Spill
	movq	%rsi, %r12
	movq	%rdi, %r13
	movq	dimension(%rip), %r14
	movq	%r14, %r15
	imulq	%r14, %r15
	leaq	(,%r15,4), %rbp
	leaq	32(%rsp), %rbx
	movq	%rbx, %rdi
	movq	%rbp, %rsi
	callq	hipMalloc
	movq	(%rbx), %rdi
	movq	%r13, %rsi
	movq	%rbp, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	dimension(%rip), %rbx
	imulq	%rbx, %rbx
	shlq	$2, %rbx
	leaq	24(%rsp), %r13
	movq	%r13, %rdi
	movq	%rbx, %rsi
	callq	hipMalloc
	movq	(%r13), %rdi
	movq	%r12, %rsi
	movq	%rbx, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	dimension(%rip), %r12
	imulq	%r12, %r12
	shlq	$2, %r12
	leaq	8(%rsp), %rdi
	movq	%r12, %rsi
	callq	hipMalloc
	movq	dimension(%rip), %rbx
	shrq	$4, %rbx
	movl	%ebx, %eax
	shlq	$32, %rbx
	orq	%rax, %rbx
	leaq	16(%rsp), %r13
	movq	%r13, %rdi
	callq	hipEventCreate
	movq	%rsp, %rdi
	callq	hipEventCreate
	movq	(%r13), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movabsq	$68719476752, %rdx              # imm = 0x1000000010
	movq	%rbx, %rdi
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB4_2
# %bb.1:
	movq	32(%rsp), %rdi
	movq	24(%rsp), %rsi
	movq	8(%rsp), %rdx
	movq	dimension(%rip), %rcx
	callq	_Z35__device_stub__shared_memory_kernelPfS_S_y
.LBB4_2:
	callq	hipDeviceSynchronize
	movq	(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	(%rsp), %rdi
	callq	hipEventSynchronize
	movq	16(%rsp), %rsi
	movq	(%rsp), %rdx
	leaq	60(%rsp), %r13
	movq	%r13, %rdi
	callq	hipEventElapsedTime
	movq	16(%rsp), %rdi
	callq	hipEventDestroy
	movq	(%rsp), %rdi
	callq	hipEventDestroy
	imulq	%r15, %r14
	addq	%r14, %r14
	movss	(%r13), %xmm0                   # xmm0 = mem[0],zero,zero,zero
	divss	.LCPI4_0(%rip), %xmm0
	movq	%r14, %xmm1
	punpckldq	.LCPI4_1(%rip), %xmm1   # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
	subpd	.LCPI4_2(%rip), %xmm1
	movss	%xmm0, (%r13)
	movapd	%xmm1, %xmm2
	unpckhpd	%xmm1, %xmm2                    # xmm2 = xmm2[1],xmm1[1]
	addsd	%xmm1, %xmm2
	cvtss2sd	%xmm0, %xmm0
	divsd	%xmm0, %xmm2
	divsd	.LCPI4_3(%rip), %xmm2
	movapd	%xmm2, 64(%rsp)                 # 16-byte Spill
	movl	$10, %edi
	callq	putchar@PLT
	movl	$.L.str.1, %edi
	movq	40(%rsp), %rsi                  # 8-byte Reload
	xorl	%eax, %eax
	callq	printf
	movl	$.L.str.2, %edi
	movq	%r14, %rsi
	xorl	%eax, %eax
	callq	printf
	xorps	%xmm0, %xmm0
	cvtss2sd	(%r13), %xmm0
	movl	$.L.str.3, %edi
	movb	$1, %al
	callq	printf
	movl	$.L.str.4, %edi
	movaps	64(%rsp), %xmm0                 # 16-byte Reload
	movb	$1, %al
	callq	printf
	movq	8(%rsp), %rsi
	movq	48(%rsp), %rdi                  # 8-byte Reload
	movq	%r12, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	movq	32(%rsp), %rdi
	callq	hipFree
	movq	24(%rsp), %rdi
	callq	hipFree
	movq	8(%rsp), %rdi
	callq	hipFree
	leaq	80(%rsp), %rax
	addq	$104, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end4:
	.size	_Z13shared_memoryPfS_S_y, .Lfunc_end4-_Z13shared_memoryPfS_S_y
	.cfi_endproc
                                        # -- End function
	.globl	_Z5usagePPc                     # -- Begin function _Z5usagePPc
	.type	_Z5usagePPc,@function
_Z5usagePPc:                            # @_Z5usagePPc
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset %rbx, -16
	movq	%rdi, %rbx
	movq	(%rdi), %rsi
	movl	$.L.str.5, %edi
	xorl	%eax, %eax
	callq	printf
	movl	$.Lstr, %edi
	callq	puts@PLT
	movl	$.Lstr.1, %edi
	callq	puts@PLT
	movl	$.Lstr.2, %edi
	callq	puts@PLT
	movl	$.Lstr.3, %edi
	callq	puts@PLT
	movq	(%rbx), %rsi
	movl	$.L.str.10, %edi
	xorl	%eax, %eax
	callq	printf
	movq	(%rbx), %rsi
	movl	$.L.str.11, %edi
	xorl	%eax, %eax
	callq	printf
	xorl	%edi, %edi
	callq	exit
.Lfunc_end5:
	.size	_Z5usagePPc, .Lfunc_end5-_Z5usagePPc
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI6_0:
	.quad	0x3e000000001c5f68              # double 4.6566128750000002E-10
.LCPI6_1:
	.quad	0x4024000000000000              # double 10
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$16, %rsp
	.cfi_def_cfa_offset 64
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rsi, %rbx
	movl	%edi, %ebp
	movl	$.L.str.12, %edx
.LBB6_1:                                # =>This Inner Loop Header: Depth=1
	callq	getopt
	shll	$24, %eax
	cmpl	$-16777216, %eax                # imm = 0xFF000000
	je	.LBB6_4
# %bb.2:                                # %.lr.ph
                                        #   in Loop: Header=BB6_1 Depth=1
	sarl	$24, %eax
	cmpl	$110, %eax
	jne	.LBB6_18
# %bb.3:                                #   in Loop: Header=BB6_1 Depth=1
	movq	optarg(%rip), %rdi
	callq	atoi
	cltq
	movq	%rax, dimension(%rip)
	movl	$.L.str.12, %edx
	movl	%ebp, %edi
	movq	%rbx, %rsi
	jmp	.LBB6_1
.LBB6_4:                                # %._crit_edge
	movq	dimension(%rip), %r12
	movq	%r12, %r15
	imulq	%r12, %r15
	shlq	$2, %r15
	movq	%r15, %rdi
	callq	malloc
	movq	%rax, %rbx
	movq	%r15, %rdi
	callq	malloc
	movq	%rax, %r14
	movq	%r15, %rdi
	callq	malloc
	movq	%rax, %r15
	testq	%r12, %r12
	je	.LBB6_13
# %bb.5:                                # %.preheader68.preheader
	leaq	(,%r12,4), %rax
	movl	$123456789, %ecx                # imm = 0x75BCD15
	xorl	%edx, %edx
	movsd	.LCPI6_0(%rip), %xmm0           # xmm0 = mem[0],zero
	movq	%rbx, %rsi
.LBB6_6:                                # %.preheader68
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB6_7 Depth 2
	xorl	%edi, %edi
.LBB6_7:                                #   Parent Loop BB6_6 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movslq	%ecx, %rcx
	imulq	$-2092037281, %rcx, %r8         # imm = 0x834E0B5F
	shrq	$32, %r8
	addl	%ecx, %r8d
	movl	%r8d, %r9d
	shrl	$31, %r9d
	sarl	$16, %r8d
	addl	%r9d, %r8d
	imull	$-127773, %r8d, %r9d            # imm = 0xFFFE0CE3
	addl	%ecx, %r9d
	imull	$16807, %r9d, %r9d              # imm = 0x41A7
	imull	$-2836, %r8d, %r8d              # imm = 0xF4EC
	leal	(%r9,%r8), %ecx
	addl	$2147483647, %ecx               # imm = 0x7FFFFFFF
                                        # kill: def $r9d killed $r9d killed $r9
	addl	%r8d, %r9d
	cmovnsl	%r9d, %ecx
	xorps	%xmm1, %xmm1
	cvtsi2sd	%ecx, %xmm1
	mulsd	%xmm0, %xmm1
	cvtsd2ss	%xmm1, %xmm1
	movss	%xmm1, (%rsi,%rdi,4)
	incq	%rdi
	cmpq	%rdi, %r12
	jne	.LBB6_7
# %bb.8:                                #   in Loop: Header=BB6_6 Depth=1
	incq	%rdx
	addq	%rax, %rsi
	cmpq	%r12, %rdx
	jne	.LBB6_6
# %bb.9:                                # %.preheader.preheader
	xorl	%edx, %edx
	movq	%r14, %rsi
.LBB6_10:                               # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB6_11 Depth 2
	xorl	%edi, %edi
.LBB6_11:                               #   Parent Loop BB6_10 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movslq	%ecx, %rcx
	imulq	$-2092037281, %rcx, %r8         # imm = 0x834E0B5F
	shrq	$32, %r8
	addl	%ecx, %r8d
	movl	%r8d, %r9d
	shrl	$31, %r9d
	sarl	$16, %r8d
	addl	%r9d, %r8d
	imull	$-127773, %r8d, %r9d            # imm = 0xFFFE0CE3
	addl	%ecx, %r9d
	imull	$16807, %r9d, %r9d              # imm = 0x41A7
	imull	$-2836, %r8d, %r8d              # imm = 0xF4EC
	leal	(%r9,%r8), %ecx
	addl	$2147483647, %ecx               # imm = 0x7FFFFFFF
                                        # kill: def $r9d killed $r9d killed $r9
	addl	%r8d, %r9d
	cmovnsl	%r9d, %ecx
	xorps	%xmm1, %xmm1
	cvtsi2sd	%ecx, %xmm1
	mulsd	%xmm0, %xmm1
	cvtsd2ss	%xmm1, %xmm1
	movss	%xmm1, (%rsi,%rdi,4)
	incq	%rdi
	cmpq	%rdi, %r12
	jne	.LBB6_11
# %bb.12:                               #   in Loop: Header=BB6_10 Depth=1
	incq	%rdx
	addq	%rax, %rsi
	cmpq	%r12, %rdx
	jne	.LBB6_10
.LBB6_13:                               # %._crit_edge80
	xorl	%r12d, %r12d
	movl	$.L.str.13, %edi
	movl	$16, %esi
	xorl	%eax, %eax
	callq	printf
	movl	$10, %edi
	callq	putchar@PLT
	movl	$.Lstr.4, %edi
	callq	puts@PLT
	xorpd	%xmm0, %xmm0
	xorps	%xmm1, %xmm1
.LBB6_14:                               # =>This Inner Loop Header: Depth=1
	movsd	%xmm0, 8(%rsp)                  # 8-byte Spill
	movsd	%xmm1, (%rsp)                   # 8-byte Spill
	movq	%rbx, %rdi
	movq	%r14, %rsi
	movq	%r15, %rdx
	movq	%r12, %rcx
	callq	_Z13global_memoryPfS_S_y
	movsd	8(%rsp), %xmm0                  # 8-byte Reload
                                        # xmm0 = mem[0],zero
	movsd	(%rsp), %xmm1                   # 8-byte Reload
                                        # xmm1 = mem[0],zero
	addsd	(%rax), %xmm0
	addsd	8(%rax), %xmm1
	incq	%r12
	cmpq	$10, %r12
	jne	.LBB6_14
# %bb.15:
	movsd	.LCPI6_1(%rip), %xmm2           # xmm2 = mem[0],zero
	divsd	%xmm2, %xmm1
	movsd	%xmm1, (%rsp)                   # 8-byte Spill
	divsd	%xmm2, %xmm0
	movl	$.L.str.15, %edi
	movb	$1, %al
	callq	printf
	movl	$.L.str.16, %edi
	movsd	(%rsp), %xmm0                   # 8-byte Reload
                                        # xmm0 = mem[0],zero
	movb	$1, %al
	callq	printf
	movl	$10, %edi
	callq	putchar@PLT
	movl	$.Lstr.5, %edi
	callq	puts@PLT
	xorpd	%xmm2, %xmm2
	xorl	%r12d, %r12d
	xorpd	%xmm1, %xmm1
.LBB6_16:                               # =>This Inner Loop Header: Depth=1
	movsd	%xmm2, 8(%rsp)                  # 8-byte Spill
	movsd	%xmm1, (%rsp)                   # 8-byte Spill
	movq	%rbx, %rdi
	movq	%r14, %rsi
	movq	%r15, %rdx
	movq	%r12, %rcx
	callq	_Z13shared_memoryPfS_S_y
	movsd	8(%rsp), %xmm2                  # 8-byte Reload
                                        # xmm2 = mem[0],zero
	movsd	(%rsp), %xmm1                   # 8-byte Reload
                                        # xmm1 = mem[0],zero
	addsd	(%rax), %xmm2
	addsd	8(%rax), %xmm1
	incq	%r12
	cmpq	$10, %r12
	jne	.LBB6_16
# %bb.17:
	movsd	.LCPI6_1(%rip), %xmm0           # xmm0 = mem[0],zero
	divsd	%xmm0, %xmm1
	movsd	%xmm1, (%rsp)                   # 8-byte Spill
	divsd	%xmm0, %xmm2
	movl	$.L.str.15, %edi
	movapd	%xmm2, %xmm0
	movb	$1, %al
	callq	printf
	movl	$.L.str.16, %edi
	movsd	(%rsp), %xmm0                   # 8-byte Reload
                                        # xmm0 = mem[0],zero
	movb	$1, %al
	callq	printf
	movq	%rbx, %rdi
	callq	free
	movq	%r14, %rdi
	callq	free
	movq	%r15, %rdi
	callq	free
	xorl	%eax, %eax
	addq	$16, %rsp
	.cfi_def_cfa_offset 48
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.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
.LBB6_18:                               # %.lr.ph
	.cfi_def_cfa_offset 64
	cmpl	$104, %eax
	movq	%rbx, %rdi
	callq	_Z5usagePPc
.Lfunc_end6:
	.size	main, .Lfunc_end6-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	.LBB7_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB7_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z20global_memory_kernelPfS_S_y, %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	$_Z20shared_memory_kernelPfS_S_y, %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_end7:
	.size	__hip_module_ctor, .Lfunc_end7-__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	.LBB8_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
.LBB8_2:
	retq
.Lfunc_end8:
	.size	__hip_module_dtor, .Lfunc_end8-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	dimension,@object               # @dimension
	.bss
	.globl	dimension
	.p2align	3, 0x0
dimension:
	.quad	0                               # 0x0
	.size	dimension, 8

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

	.type	.L.str.1,@object                # @.str.1
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.1:
	.asciz	"Run number: %d\n"
	.size	.L.str.1, 16

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"  Floating point OPS roughly %llu\n"
	.size	.L.str.2, 35

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"  Elapsed time dT = %f\n"
	.size	.L.str.3, 24

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"  Rate = MegaOPS/dT = %f\n"
	.size	.L.str.4, 26

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

	.type	.L.str.5,@object                # @.str.5
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.5:
	.asciz	"Usage: %s -n <matrix dimensions>\n"
	.size	.L.str.5, 34

	.type	.L.str.10,@object               # @.str.10
.L.str.10:
	.asciz	"  %s -n 256 > output.txt\n"
	.size	.L.str.10, 26

	.type	.L.str.11,@object               # @.str.11
.L.str.11:
	.asciz	"  %s -n 4096 > output.txt\n"
	.size	.L.str.11, 27

	.type	.L.str.12,@object               # @.str.12
.L.str.12:
	.asciz	"n:h"
	.size	.L.str.12, 4

	.type	.L.str.13,@object               # @.str.13
.L.str.13:
	.asciz	"Thread Block Size: %d\n"
	.size	.L.str.13, 23

	.type	.L.str.15,@object               # @.str.15
.L.str.15:
	.asciz	"Average Elapsed Time dT: %f\n"
	.size	.L.str.15, 29

	.type	.L.str.16,@object               # @.str.16
.L.str.16:
	.asciz	"Average Rate: %f\n"
	.size	.L.str.16, 18

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

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_Z20shared_memory_kernelPfS_S_y"
	.size	.L__unnamed_2, 32

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

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

	.type	.Lstr,@object                   # @str
	.section	.rodata.str1.1,"aMS",@progbits,1
.Lstr:
	.asciz	"Options:"
	.size	.Lstr, 9

	.type	.Lstr.1,@object                 # @str.1
.Lstr.1:
	.asciz	"  -h         Print this help message."
	.size	.Lstr.1, 38

	.type	.Lstr.2,@object                 # @str.2
.Lstr.2:
	.asciz	"  -n         Dimensions of the matrices."
	.size	.Lstr.2, 41

	.type	.Lstr.3,@object                 # @str.3
.Lstr.3:
	.asciz	"\nExamples:"
	.size	.Lstr.3, 11

	.type	.Lstr.4,@object                 # @str.4
.Lstr.4:
	.asciz	"========================Unoptimized CUDA Multiplication================================"
	.size	.Lstr.4, 88

	.type	.Lstr.5,@object                 # @str.5
.Lstr.5:
	.asciz	"========================Blocking Optimized CUDA Multiplication================================"
	.size	.Lstr.5, 95

	.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 _Z35__device_stub__global_memory_kernelPfS_S_y
	.addrsig_sym _Z35__device_stub__shared_memory_kernelPfS_S_y
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z20global_memory_kernelPfS_S_y
	.addrsig_sym _Z20shared_memory_kernelPfS_S_y
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z20global_memory_kernelPfS_S_y ; -- Begin function _Z20global_memory_kernelPfS_S_y
	.globl	_Z20global_memory_kernelPfS_S_y
	.p2align	8
	.type	_Z20global_memory_kernelPfS_S_y,@function
_Z20global_memory_kernelPfS_S_y:        ; @_Z20global_memory_kernelPfS_S_y
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x2c
	s_load_b256 s[4:11], s[0:1], 0x0
	v_bfe_u32 v1, v0, 10, 10
	v_and_b32_e32 v2, 0x3ff, v0
	s_waitcnt lgkmcnt(0)
	s_lshr_b32 s0, s2, 16
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	v_mad_u64_u32 v[4:5], null, s15, s0, v[1:2]
	v_mov_b32_e32 v5, 0
	s_and_b32 s0, s2, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_mad_u64_u32 v[0:1], null, s14, s0, v[2:3]
	v_mov_b32_e32 v1, v5
	s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_cmp_ge_u64_e32 vcc_lo, s[10:11], v[4:5]
	v_cmp_ge_u64_e64 s0, s[10:11], v[0:1]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_and_b32 s0, vcc_lo, s0
	s_and_saveexec_b32 s1, s0
	s_cbranch_execz .LBB0_6
; %bb.1:                                ; %.preheader
	v_mov_b32_e32 v2, 0
	v_lshlrev_b64 v[0:1], 2, v[0:1]
	v_mov_b32_e32 v3, 0
	s_cmp_eq_u64 s[10:11], 0
	s_cbranch_scc1 .LBB0_4
; %bb.2:                                ; %.lr.ph
	v_mad_u64_u32 v[2:3], null, v4, s10, 0
	s_lshl_b64 s[0:1], s[10:11], 2
	v_mov_b32_e32 v8, 0
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_mad_u64_u32 v[5:6], null, v4, s11, v[3:4]
	v_add_co_u32 v4, vcc_lo, s6, v0
	v_mov_b32_e32 v3, v5
	v_add_co_ci_u32_e32 v5, vcc_lo, s7, v1, vcc_lo
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[6:7], 2, v[2:3]
	v_add_co_u32 v6, vcc_lo, s4, v6
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v7, vcc_lo, s5, v7, vcc_lo
.LBB0_3:                                ; =>This Inner Loop Header: Depth=1
	global_load_b32 v9, v[6:7], off
	global_load_b32 v10, v[4:5], off
	v_add_co_u32 v4, vcc_lo, v4, s0
	v_add_co_ci_u32_e32 v5, vcc_lo, s1, v5, vcc_lo
	v_add_co_u32 v6, vcc_lo, v6, 4
	s_add_u32 s10, s10, -1
	v_add_co_ci_u32_e32 v7, vcc_lo, 0, v7, vcc_lo
	s_addc_u32 s11, s11, -1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_cmp_eq_u64 s[10:11], 0
	s_waitcnt vmcnt(0)
	v_fmac_f32_e32 v8, v9, v10
	s_cbranch_scc0 .LBB0_3
	s_branch .LBB0_5
.LBB0_4:
	v_mov_b32_e32 v8, 0
.LBB0_5:                                ; %Flow46
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[2:3], 2, v[2:3]
	v_add_co_u32 v2, vcc_lo, s8, v2
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_ci_u32_e32 v3, vcc_lo, s9, v3, vcc_lo
	v_add_co_u32 v0, vcc_lo, v2, v0
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v1, vcc_lo, v3, v1, vcc_lo
	global_store_b32 v[0:1], v8, off
.LBB0_6:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z20global_memory_kernelPfS_S_y
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 288
		.amdhsa_user_sgpr_count 14
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 1
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 1
		.amdhsa_next_free_vgpr 11
		.amdhsa_next_free_sgpr 16
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end0:
	.size	_Z20global_memory_kernelPfS_S_y, .Lfunc_end0-_Z20global_memory_kernelPfS_S_y
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 352
; NumSgprs: 18
; NumVgprs: 11
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 11
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 14
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 1
	.text
	.protected	_Z20shared_memory_kernelPfS_S_y ; -- Begin function _Z20shared_memory_kernelPfS_S_y
	.globl	_Z20shared_memory_kernelPfS_S_y
	.p2align	8
	.type	_Z20shared_memory_kernelPfS_S_y,@function
_Z20shared_memory_kernelPfS_S_y:        ; @_Z20shared_memory_kernelPfS_S_y
; %bb.0:
	s_load_b256 s[4:11], s[0:1], 0x0
	v_and_b32_e32 v1, 0x3ff, v0
	s_mov_b32 s2, s15
	v_bfe_u32 v3, v0, 10, 10
	s_mov_b32 s15, 0
	s_delay_alu instid0(VALU_DEP_2)
	v_lshlrev_b32_e32 v2, 2, v1
	s_waitcnt lgkmcnt(0)
	v_cmp_gt_u64_e64 s12, s[10:11], 15
	s_mul_i32 s1, s2, s11
	s_mul_hi_u32 s3, s2, s10
	s_mul_i32 s0, s2, s10
	s_add_i32 s1, s3, s1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_lshl_b64 s[2:3], s[0:1], 4
	s_and_b32 vcc_lo, exec_lo, s12
	s_lshl_b64 s[0:1], s[14:15], 4
	s_cbranch_vccz .LBB1_6
; %bb.1:                                ; %.lr.ph
	v_mad_u64_u32 v[0:1], null, v3, s10, 0
	s_lshl_b64 s[14:15], s[0:1], 2
	s_lshr_b64 s[12:13], s[10:11], 4
	s_add_u32 s14, s6, s14
	s_addc_u32 s15, s7, s15
	s_lshl_b64 s[6:7], s[2:3], 2
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	s_add_u32 s4, s4, s6
	v_mad_u64_u32 v[5:6], null, v3, s11, v[1:2]
	v_mov_b32_e32 v4, 0
	s_addc_u32 s5, s5, s7
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_dual_mov_b32 v1, v5 :: v_dual_add_nc_u32 v6, 0x400, v2
	v_lshlrev_b32_e32 v5, 6, v3
	v_lshlrev_b64 v[8:9], 2, v[0:1]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_nc_u32_e32 v7, v5, v2
	v_add_co_u32 v10, vcc_lo, s4, v8
	s_delay_alu instid0(VALU_DEP_3) | instskip(SKIP_2) | instid1(VALU_DEP_4)
	v_add_co_ci_u32_e32 v11, vcc_lo, s5, v9, vcc_lo
	v_add_co_u32 v12, vcc_lo, s14, v8
	v_add_co_ci_u32_e32 v13, vcc_lo, s15, v9, vcc_lo
	v_add_co_u32 v8, vcc_lo, v10, v2
	s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_4)
	v_add_co_ci_u32_e32 v9, vcc_lo, 0, v11, vcc_lo
	v_add_co_u32 v10, vcc_lo, v12, v2
	s_delay_alu instid0(VALU_DEP_4)
	v_add_co_ci_u32_e32 v11, vcc_lo, 0, v13, vcc_lo
	v_add_nc_u32_e32 v12, v6, v5
	s_mov_b64 s[4:5], 0
.LBB1_2:                                ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB1_3 Depth 2
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(SALU_CYCLE_1)
	v_alignbit_b32 v13, s5, s4, 28
	s_lshl_b64 s[6:7], s[4:5], 4
	s_mul_i32 s7, s6, s11
	s_mul_hi_u32 s14, s6, s10
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_4) | instid1(SALU_CYCLE_1)
	v_mul_lo_u32 v14, v13, s10
	s_mul_i32 s6, s6, s10
	s_add_i32 s14, s14, s7
	v_mov_b32_e32 v13, s6
	s_lshl_b64 s[6:7], s[4:5], 6
	v_add_co_u32 v15, vcc_lo, v8, s6
	s_delay_alu instid0(VALU_DEP_3) | instskip(SKIP_2) | instid1(VALU_DEP_2)
	v_add_nc_u32_e32 v14, s14, v14
	v_add_co_ci_u32_e32 v16, vcc_lo, s7, v9, vcc_lo
	s_mov_b64 s[6:7], 16
	v_lshlrev_b64 v[13:14], 2, v[13:14]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v13, vcc_lo, v10, v13
	v_add_co_ci_u32_e32 v14, vcc_lo, v11, v14, vcc_lo
	global_load_b32 v15, v[15:16], off
	global_load_b32 v16, v[13:14], off
	v_dual_mov_b32 v13, v5 :: v_dual_mov_b32 v14, v6
	s_waitcnt vmcnt(1)
	ds_store_b32 v7, v15
	s_waitcnt vmcnt(0)
	ds_store_b32 v12, v16
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
.LBB1_3:                                ;   Parent Loop BB1_2 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	ds_load_b32 v15, v13
	ds_load_b32 v16, v14
	s_add_u32 s6, s6, -1
	v_add_nc_u32_e32 v14, 64, v14
	v_add_nc_u32_e32 v13, 4, v13
	s_addc_u32 s7, s7, -1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_cmp_eq_u64 s[6:7], 0
	s_waitcnt lgkmcnt(0)
	v_fmac_f32_e32 v4, v15, v16
	s_cbranch_scc0 .LBB1_3
; %bb.4:                                ;   in Loop: Header=BB1_2 Depth=1
	s_add_u32 s4, s4, 1
	s_addc_u32 s5, s5, 0
	s_delay_alu instid0(SALU_CYCLE_1)
	s_cmp_eq_u64 s[4:5], s[12:13]
	s_barrier
	buffer_gl0_inv
	s_cbranch_scc0 .LBB1_2
; %bb.5:                                ; %Flow
	s_mov_b32 s4, 0
	s_branch .LBB1_7
.LBB1_6:
	s_mov_b32 s4, -1
                                        ; implicit-def: $vgpr4
                                        ; implicit-def: $vgpr0_vgpr1
.LBB1_7:                                ; %Flow71
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_b32 vcc_lo, exec_lo, s4
	s_cbranch_vccz .LBB1_9
; %bb.8:                                ; %.._crit_edge_crit_edge
	v_mad_u64_u32 v[0:1], null, v3, s10, 0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[4:5], null, v3, s11, v[1:2]
	v_dual_mov_b32 v1, v4 :: v_dual_mov_b32 v4, 0
.LBB1_9:                                ; %._crit_edge
	s_lshl_b64 s[2:3], s[2:3], 2
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_3) | instid1(SALU_CYCLE_1)
	v_lshlrev_b64 v[0:1], 2, v[0:1]
	s_add_u32 s2, s8, s2
	s_addc_u32 s3, s9, s3
	s_lshl_b64 s[0:1], s[0:1], 2
	s_add_u32 s0, s2, s0
	s_addc_u32 s1, s3, s1
	v_add_co_u32 v0, vcc_lo, s0, v0
	v_add_co_ci_u32_e32 v1, vcc_lo, s1, v1, vcc_lo
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v0, vcc_lo, v0, v2
	v_add_co_ci_u32_e32 v1, vcc_lo, 0, v1, vcc_lo
	global_store_b32 v[0:1], v4, off
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z20shared_memory_kernelPfS_S_y
		.amdhsa_group_segment_fixed_size 2048
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 32
		.amdhsa_user_sgpr_count 14
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 1
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 1
		.amdhsa_next_free_vgpr 17
		.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	_Z20shared_memory_kernelPfS_S_y, .Lfunc_end1-_Z20shared_memory_kernelPfS_S_y
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 628
; NumSgprs: 18
; NumVgprs: 17
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 2048 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 2
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 17
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 14
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 1
	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __hip_cuid_
	.amdgpu_metadata
---
amdhsa.kernels:
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         16
        .size:           8
        .value_kind:     global_buffer
      - .offset:         24
        .size:           8
        .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:           _Z20global_memory_kernelPfS_S_y
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z20global_memory_kernelPfS_S_y.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     11
    .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
      - .address_space:  global
        .offset:         16
        .size:           8
        .value_kind:     global_buffer
      - .offset:         24
        .size:           8
        .value_kind:     by_value
    .group_segment_fixed_size: 2048
    .kernarg_segment_align: 8
    .kernarg_segment_size: 32
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z20shared_memory_kernelPfS_S_y
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z20shared_memory_kernelPfS_S_y.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     17
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
