#include <stdio.h>
#include <cuda.h>
//#include <cuda_runtime.h>
//#include <curand_kernel.h>
#include <string.h>
#include <time.h>

enum comptuationDevice{
    dev_both,
    dev_gpu,
    dev_cpu
};

/*Global Startup Settings*/
struct Startup{
    comptuationDevice device = dev_gpu;
    int randomMod = 2;
    int seedValue = time(nullptr);
    int maxDimension = INT_MAX;
    int startDimension = 2;
    int threadsPerBlock = 256;
    int onlyMatrixSize = NULL;
    char* outputDirectory = ".";
    bool matSave  = false;
    bool matPrint = false;
} startup;

/*Matrix Datastructure*/
struct squareMatrix{
    int* elements;
    int dimension;
};

const char* help =
"\n Shows what parameters are available\n\
\t--help\n\n\
 Selects which device should be used:\n\
\t--device cpu\n\
\t--device gpu\n\
\t--device both\n\n\
 sets seedvalue for random number generation (default: currentTime)\n\
\t--seed [int]\n\n\
 sets mod value for random number generation (default: 2)\n\
\t--random_mod [int]\n\n\
 sets max dimension to compute (default: max matrix that can fit in vram)\n\
\t--max_dimension [int]\n\n\
 sets starting matrix dimension (default: 2)\n\
\t--start_dimension [int]\n\n\
 only computes a single matrix of n size.\n\
\t--only [int]\n\n\
 sets the number of threads per block (default: 256). Should be a multiple of cuda cores\n\
\t--block_threads [int 1-1024]\n\n\
 outputs matrix a, b and result. (not recommended for extremely large matrices)\n\
\t--mat_print                    (prints to the console)\n\
\t--mat_save [filepath]          (saves to disk. filepath optional)\n\n";

__host__ squareMatrix createRandomSquareMatrix(int dimension){
    int  mat_elements = dimension * dimension;
    int* mat = (int*)malloc(sizeof(int)*mat_elements);
    for (int i = 0; i < mat_elements; i++)
        mat[i] = rand()%startup.randomMod;
    return {mat, dimension};
}

__host__ void printSquareMatrix(squareMatrix mat){
    for (int i = 0; i < mat.dimension*mat.dimension; i++){
        if (i % mat.dimension == 0 && i != 0) printf("\n");
        printf("%d ", mat.elements[i]);
    }
    printf("\n\n");
}

__host__ void multiplyMatrices(squareMatrix a, squareMatrix b, squareMatrix result){
    if (a.dimension != b.dimension) exit(1);
    
    for (int i = 0; i < result.dimension; i++){
        for (int j = 0; j < result.dimension; j++){
            result.elements[j + result.dimension*i] = 0;
            for (int k = 0; k < result.dimension; k++)
                result.elements[j + result.dimension*i] += a.elements[k + result.dimension*i] * b.elements[j + result.dimension*k];
        }
    }
}

__global__ void multiplyMatricesParallel(int* mat_a, int* mat_b, int* mat_results, int dimension){

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

    if (idx < dimension*dimension){
        mat_results[idx] = 0;
        for (int i = 0; i < dimension; i++){
            int row = idx / dimension;
            mat_results[idx] += mat_a[i +  dimension*row] * mat_b[idx%dimension + dimension*i];
        }
    }
}

__host__ void printMatrixInfo(int dimension, char* type){
    printf("--------------------------------------------------------------------------------------------\nMultiplying %dx%d X %dx%d using the %s ...\n\n", 
    dimension, dimension, dimension, dimension, type);
}

__host__ void saveMatrixToFile(squareMatrix mat_sav, char* label){

    char fileNameBuffer[256];

    char dim[30];

    snprintf(dim, 10,"%d", mat_sav.dimension);

    snprintf(fileNameBuffer, sizeof fileNameBuffer, "%s/%sx%s_X_%sx%s_%s.txt", startup.outputDirectory, dim, dim, dim, dim, label);
    
    FILE* fp = fopen( fileNameBuffer, "w");
    if (fp == nullptr) printf("Could not log to file\n");
    else {
        for (int i = 0; i < mat_sav.dimension*mat_sav.dimension; i++){
            if (i % mat_sav.dimension == 0 && i != 0) fprintf(fp, "\n");
            fprintf(fp, "%d ", mat_sav.elements[i]);
        }
        fprintf(fp, "\n");
    }
    fclose(fp);
}


__host__ void printTime(clock_t totaltime){
    int msec = totaltime * 1000 / CLOCKS_PER_SEC;
    printf("Done in %d msec!\n", msec);
}

/*
 Found on the stack overflow:  https://stackoverflow.com/questions/14038589/what-is-the-canonical-way-to-check-for-errors-using-the-cuda-runtime-api
 Throws errors if cuda command doesn't return Success
*/
#define gpuErrchk(ans) { gpuAssert((ans), __FILE__, __LINE__); }
inline void gpuAssert(cudaError_t code, const char *file, int line, bool abort=true)
{
   if (code != cudaSuccess) 
   {
      fprintf(stderr,"GPUassert: %s %s %d\n", cudaGetErrorString(code), file, line);
      if (abort) exit(code);
   }
}

__host__ void testHostPreformance(squareMatrix mat_a, squareMatrix mat_b){
    printMatrixInfo(mat_a.dimension, (char*)"CPU");
    clock_t initalTime = clock();

    printf("\tAllocating Result Matrix To Ram...               ");
    clock_t before = clock();
    squareMatrix mat_results = {(int*)malloc(sizeof(int)*mat_a.dimension*mat_a.dimension), mat_a.dimension};
    printTime(clock() - before);

    before = clock();
    printf("\tPreforming Multiplication...                     ");
    multiplyMatrices(mat_a, mat_b, mat_results);
    printTime(clock() - before);

    if (startup.matPrint) printSquareMatrix(mat_results);
    if (startup.matSave)  {
        printf("\tSaving Result Matrix to Disk...                  ");
        before = clock();
        saveMatrixToFile(mat_results, "matrix_result");
        printTime(clock() - before);
    }

    printf("\tDeallocating Result Matrix From Ram...           ");
    before = clock();
    free(mat_results.elements);
    printTime(clock() - before);

    printf("\nTotal Time:                                      ");
    printTime(clock() - initalTime);
}

__host__ void testDevicePreformance(squareMatrix mat_a, squareMatrix mat_b){
    printMatrixInfo(mat_a.dimension, (char*)"GPU");
    clock_t initalTime = clock();

    if (mat_a.dimension != mat_b.dimension) exit(1);
    
    int allocationsize = mat_a.dimension * mat_b.dimension * sizeof(int);

    printf("\tAllocating Result Matrix To RAM...               ");
    clock_t before = clock();
        squareMatrix mat_results = {(int*)malloc(allocationsize), mat_a.dimension};
    printTime(clock() - before);

    int* dev_mat_a, *dev_mat_b, *dev_mat_results;

    printf("\tAllocating A, B, and RESULT Matrix To VRAM...    ");
    before = clock();
        gpuErrchk(cudaMalloc((void **)&dev_mat_a,          allocationsize));
        gpuErrchk(cudaMalloc((void **)&dev_mat_b,          allocationsize));
        gpuErrchk(cudaMalloc((void **)&dev_mat_results,    allocationsize));
    printTime(clock() - before);

    printf("\tCopying A, B To VRAM...                          ");
    before = clock();
        gpuErrchk(cudaMemcpy(dev_mat_a, mat_a.elements, allocationsize, cudaMemcpyHostToDevice));
        gpuErrchk(cudaMemcpy(dev_mat_b, mat_b.elements, allocationsize, cudaMemcpyHostToDevice));
    printTime(clock() - before);

    printf("\tComputing and Copying Result...                  ");
    before = clock();
        int totalThreadsNeeded = mat_a.dimension*mat_a.dimension;
        multiplyMatricesParallel<<<totalThreadsNeeded / startup.threadsPerBlock + 1, startup.threadsPerBlock>>> (dev_mat_a, dev_mat_b, dev_mat_results, mat_a.dimension);
        gpuErrchk(cudaGetLastError());
        gpuErrchk(cudaMemcpy(mat_results.elements, dev_mat_results, allocationsize, cudaMemcpyDeviceToHost));
    printTime(clock() - before);


    if (startup.matPrint) printSquareMatrix(mat_results);
    if (startup.matSave)  {
        printf("\tSaving Result Matrix to Disk...                  ");
        before = clock();
        saveMatrixToFile(mat_results, "matrix_result");
        printTime(clock() - before);
    }

    printf("\tDeallocating Result Matrix...                    ");
    before = clock();
        cudaFree(dev_mat_a); cudaFree(dev_mat_b); cudaFree(dev_mat_results);
        free(mat_results.elements);
    printTime(clock() - before);

    printf("\nTotal Time: ");
    printTime(clock() - initalTime);
}

__host__ void testMatrixMultiplicationPreformance(int dimension){

    srand(startup.seedValue);

    squareMatrix mat_a, mat_b;
    
    mat_a = createRandomSquareMatrix(dimension);
    mat_b = createRandomSquareMatrix(dimension);

    if (startup.matPrint) {
        printSquareMatrix(mat_a);
        printSquareMatrix(mat_b);
    }

    if (startup.matSave) {
        saveMatrixToFile(mat_a, "matrix_A");
        saveMatrixToFile(mat_b, "matrix_B");
    }

    if (startup.device != dev_cpu) testDevicePreformance(mat_a, mat_b);
    if (startup.device != dev_gpu) testHostPreformance(mat_a, mat_b);

    free(mat_a.elements);
    free(mat_b.elements);
}

unsigned int getFreeGpuMem()
{
    size_t free_t;
    cudaMemGetInfo(&free_t,nullptr);    
    return (unsigned int)free_t;
}

__host__ unsigned int calculateLargestPossibleMatrixDimension(){
    unsigned int free = getFreeGpuMem();
    unsigned int memoryPerMatrix = free  / (sizeof(int) * 3);
    unsigned int maxMatrixDimension = sqrt( memoryPerMatrix ) - 1;
    return maxMatrixDimension;
}

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

    for (int i = 0; i < argc; i++){
        if (strcmp(argv[i],  "--help")==0) {printf("%s", help); exit(-1); }
        if (strcmp(argv[i],  "--device")==0 && i+1 < argc) 
            if (strcmp(argv[i+1], "gpu") == 0) startup.device = dev_gpu;
            else if (strcmp(argv[i+1], "cpu") == 0) startup.device = dev_cpu;
            else if (strcmp(argv[i+1], "both") == 0) startup.device = dev_both;
        if (strcmp(argv[i],  "--random_mod")==0 && i+1 < argc) startup.randomMod = atoi(argv[i+1]);
        if (strcmp(argv[i],  "--max_dimension")==0 && i+1 < argc) startup.maxDimension = atoi(argv[i+1]);
        if (strcmp(argv[i],  "--seed")==0 && i+1 < argc) startup.seedValue = atoi(argv[i+1]);
        if (strcmp(argv[i],  "--start_dimension")==0 && i+1 < argc) startup.startDimension = atoi(argv[i+1]);
        if (strcmp(argv[i],  "--only")==0 && i+1 < argc) startup.onlyMatrixSize = atoi(argv[i+1]);
        if (strcmp(argv[i],  "--block_threads")==0 && i+1 < argc) startup.threadsPerBlock = atoi(argv[i+1]);
        if (strcmp(argv[i],  "--mat_print")==0) startup.matPrint = true;
        if (strcmp(argv[i],  "--mat_save")==0){ 
            startup.matSave = true;
            if   (i+1 < argc && strstr(argv[i+1], "--") == NULL) startup.outputDirectory = argv[i+1];
        }
    }

    /*Tests only one matrix if parameter passed in*/
    if (startup.onlyMatrixSize != NULL)
        testMatrixMultiplicationPreformance(startup.onlyMatrixSize);

    /*Otherwise, double matrix size until vram is completely filled*/
    else { 
        unsigned int maxMatrixDimension = calculateLargestPossibleMatrixDimension();
        for (int i = startup.startDimension; i != maxMatrixDimension*2 && i <= startup.maxDimension; i*=2 ) {
            maxMatrixDimension = calculateLargestPossibleMatrixDimension();
            if (i > maxMatrixDimension)
                i = maxMatrixDimension;
            testMatrixMultiplicationPreformance(i);
        }
    }
    
	return 0;
}
	.file	"tmpxft_002196cb_00000000-6_MatrixMultiplication.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2045:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2045:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z24createRandomSquareMatrixi
	.type	_Z24createRandomSquareMatrixi, @function
_Z24createRandomSquareMatrixi:
.LFB2030:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	movl	%edi, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	movl	%edi, %ebx
	imull	%edi, %ebx
	pushq	%rsi
	.cfi_def_cfa_offset 48
	movslq	%ebx, %rbx
	salq	$2, %rbx
	movq	%rbx, %rdi
	call	malloc@PLT
	movq	%rax, %r12
	movq	%rax, %r13
	addq	%rax, %rbx
.L3:
	cmpq	%rbx, %r13
	je	.L7
	call	rand@PLT
	addq	$4, %r13
	cltd
	idivl	4+startup(%rip)
	movl	%edx, -4(%r13)
	jmp	.L3
.L7:
	popq	%rcx
	.cfi_def_cfa_offset 40
	movl	%ebp, %edx
	popq	%rbx
	.cfi_def_cfa_offset 32
	movq	%r12, %rax
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2030:
	.size	_Z24createRandomSquareMatrixi, .-_Z24createRandomSquareMatrixi
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"\n"
.LC1:
	.string	"%d "
.LC2:
	.string	"\n\n"
	.text
	.globl	_Z17printSquareMatrix12squareMatrix
	.type	_Z17printSquareMatrix12squareMatrix, @function
_Z17printSquareMatrix12squareMatrix:
.LFB2031:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	leaq	.LC0(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	movl	%esi, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	movq	%rdi, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	movl	%esi, %ebp
	imull	%esi, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	xorl	%ebx, %ebx
.L9:
	movl	%ebx, %ecx
	cmpl	%ebx, %ebp
	jle	.L19
	movl	%ecx, %eax
	cltd
	idivl	%r13d
	testl	%edx, %edx
	jne	.L10
	testl	%ecx, %ecx
	je	.L10
	movq	%r14, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L10:
	movl	(%r12,%rbx,4), %edx
	leaq	.LC1(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	incq	%rbx
	call	__printf_chk@PLT
	jmp	.L9
.L19:
	popq	%rbx
	.cfi_def_cfa_offset 40
	leaq	.LC2(%rip), %rsi
	popq	%rbp
	.cfi_def_cfa_offset 32
	movl	$2, %edi
	popq	%r12
	.cfi_def_cfa_offset 24
	xorl	%eax, %eax
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	jmp	__printf_chk@PLT
	.cfi_endproc
.LFE2031:
	.size	_Z17printSquareMatrix12squareMatrix, .-_Z17printSquareMatrix12squareMatrix
	.globl	_Z16multiplyMatrices12squareMatrixS_S_
	.type	_Z16multiplyMatrices12squareMatrixS_S_, @function
_Z16multiplyMatrices12squareMatrixS_S_:
.LFB2032:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	pushq	%r10
	.cfi_def_cfa_offset 48
	cmpl	%ecx, %esi
	jne	.L21
	movq	%rdi, %r10
	movl	%r9d, %edi
	movslq	%r9d, %r9
	movq	%rdx, %rbx
	salq	$2, %r9
	xorl	%edx, %edx
	xorl	%r11d, %r11d
	jmp	.L22
.L21:
	movl	$1, %edi
	call	exit@PLT
.L24:
	xorl	%esi, %esi
	leaq	(%rbx,%rcx,4), %rbp
	movl	%esi, (%rax)
	xorl	%esi, %esi
.L23:
	movl	0(%r13,%rsi,4), %r12d
	incq	%rsi
	imull	0(%rbp), %r12d
	addq	%r9, %rbp
	addl	%r12d, (%rax)
	cmpl	%esi, %edi
	jg	.L23
	incq	%rcx
	addq	$4, %rax
	cmpl	%ecx, %edi
	jg	.L24
	incl	%r11d
	addq	%r9, %rdx
.L22:
	cmpl	%edi, %r11d
	jge	.L29
	leaq	(%r8,%rdx), %rax
	xorl	%ecx, %ecx
	leaq	(%r10,%rdx), %r13
	jmp	.L24
.L29:
	popq	%rax
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2032:
	.size	_Z16multiplyMatrices12squareMatrixS_S_, .-_Z16multiplyMatrices12squareMatrixS_S_
	.section	.rodata.str1.1
.LC3:
	.string	"--------------------------------------------------------------------------------------------\nMultiplying %dx%d X %dx%d using the %s ...\n\n"
	.text
	.globl	_Z15printMatrixInfoiPc
	.type	_Z15printMatrixInfoiPc, @function
_Z15printMatrixInfoiPc:
.LFB2033:
	.cfi_startproc
	endbr64
	subq	$16, %rsp
	.cfi_def_cfa_offset 24
	movl	%edi, %edx
	movl	%edi, %r9d
	movl	%edi, %r8d
	pushq	%rsi
	.cfi_def_cfa_offset 32
	movl	%edi, %ecx
	leaq	.LC3(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	addq	$24, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2033:
	.size	_Z15printMatrixInfoiPc, .-_Z15printMatrixInfoiPc
	.section	.rodata.str1.1
.LC4:
	.string	"%d"
.LC5:
	.string	"%s/%sx%s_X_%sx%s_%s.txt"
.LC6:
	.string	"w"
.LC7:
	.string	"Could not log to file\n"
	.text
	.globl	_Z16saveMatrixToFile12squareMatrixPc
	.type	_Z16saveMatrixToFile12squareMatrixPc, @function
_Z16saveMatrixToFile12squareMatrixPc:
.LFB2034:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	%esi, %r9d
	movl	$30, %ecx
	leaq	.LC4(%rip), %r8
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movl	%esi, %r14d
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%rdi, %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movq	%rdx, %r12
	movl	$2, %edx
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	%rsi, %rbx
	movl	$10, %esi
	subq	$312, %rsp
	.cfi_def_cfa_offset 368
	movq	%fs:40, %rax
	movq	%rax, 296(%rsp)
	xorl	%eax, %eax
	leaq	10(%rsp), %rbp
	leaq	40(%rsp), %r15
	movq	%rbp, %rdi
	call	__snprintf_chk@PLT
	movq	32+startup(%rip), %r9
	movl	$256, %ecx
	movq	%r15, %rdi
	pushq	%rax
	.cfi_def_cfa_offset 376
	leaq	.LC5(%rip), %r8
	movl	$2, %edx
	xorl	%eax, %eax
	pushq	%r12
	.cfi_def_cfa_offset 384
	movl	$256, %esi
	pushq	%rbp
	.cfi_def_cfa_offset 392
	pushq	%rbp
	.cfi_def_cfa_offset 400
	pushq	%rbp
	.cfi_def_cfa_offset 408
	pushq	%rbp
	.cfi_def_cfa_offset 416
	call	__snprintf_chk@PLT
	addq	$48, %rsp
	.cfi_def_cfa_offset 368
	leaq	.LC6(%rip), %rsi
	movq	%r15, %rdi
	call	fopen@PLT
	movq	%rax, %rbp
	testq	%rax, %rax
	je	.L33
	imull	%ebx, %ebx
	xorl	%r12d, %r12d
	leaq	.LC0(%rip), %r15
	jmp	.L34
.L33:
	leaq	.LC7(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L35
.L37:
	movl	%ecx, %eax
	cltd
	idivl	%r14d
	testl	%edx, %edx
	je	.L46
.L36:
	movl	0(%r13,%r12,4), %ecx
	movl	$2, %esi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	leaq	.LC1(%rip), %rdx
	incq	%r12
	call	__fprintf_chk@PLT
.L34:
	movl	%r12d, %ecx
	cmpl	%r12d, %ebx
	jg	.L37
	jmp	.L47
.L46:
	testl	%ecx, %ecx
	je	.L36
	movq	%r15, %rdx
	movl	$2, %esi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	jmp	.L36
.L47:
	leaq	.LC0(%rip), %rdx
	movl	$2, %esi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
.L35:
	movq	%rbp, %rdi
	call	fclose@PLT
	movq	296(%rsp), %rax
	subq	%fs:40, %rax
	je	.L38
	call	__stack_chk_fail@PLT
.L38:
	addq	$312, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2034:
	.size	_Z16saveMatrixToFile12squareMatrixPc, .-_Z16saveMatrixToFile12squareMatrixPc
	.section	.rodata.str1.1
.LC8:
	.string	"Done in %d msec!\n"
	.text
	.globl	_Z9printTimel
	.type	_Z9printTimel, @function
_Z9printTimel:
.LFB2035:
	.cfi_startproc
	endbr64
	movq	%rdi, %rax
	movl	$1000, %ecx
	leaq	.LC8(%rip), %rsi
	movl	$2, %edi
	cqto
	idivq	%rcx
	movl	%eax, %edx
	xorl	%eax, %eax
	jmp	__printf_chk@PLT
	.cfi_endproc
.LFE2035:
	.size	_Z9printTimel, .-_Z9printTimel
	.section	.rodata._Z9gpuAssert9cudaErrorPKcib.str1.1,"aMS",@progbits,1
.LC9:
	.string	"GPUassert: %s %s %d\n"
	.section	.text._Z9gpuAssert9cudaErrorPKcib,"axG",@progbits,_Z9gpuAssert9cudaErrorPKcib,comdat
	.weak	_Z9gpuAssert9cudaErrorPKcib
	.type	_Z9gpuAssert9cudaErrorPKcib, @function
_Z9gpuAssert9cudaErrorPKcib:
.LFB2036:
	.cfi_startproc
	endbr64
	testl	%edi, %edi
	je	.L55
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movl	%ecx, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	movl	%edi, %ebx
	subq	$24, %rsp
	.cfi_def_cfa_offset 48
	movl	%edx, 12(%rsp)
	movq	%rsi, (%rsp)
	call	cudaGetErrorString@PLT
	movl	12(%rsp), %r9d
	movq	(%rsp), %r8
	leaq	.LC9(%rip), %rdx
	movq	stderr(%rip), %rdi
	movq	%rax, %rcx
	movl	$2, %esi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	testb	%bpl, %bpl
	je	.L49
	movl	%ebx, %edi
	call	exit@PLT
.L49:
	addq	$24, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
.L55:
	.cfi_restore 3
	.cfi_restore 6
	ret
	.cfi_endproc
.LFE2036:
	.size	_Z9gpuAssert9cudaErrorPKcib, .-_Z9gpuAssert9cudaErrorPKcib
	.section	.rodata.str1.1
.LC10:
	.string	"CPU"
.LC11:
	.string	"\tAllocating Result Matrix To Ram...               "
.LC12:
	.string	"\tPreforming Multiplication...                     "
.LC13:
	.string	"\tSaving Result Matrix to Disk...                  "
.LC14:
	.string	"matrix_result"
.LC15:
	.string	"\tDeallocating Result Matrix From Ram...           "
.LC16:
	.string	"\nTotal Time:                                      "
	.text
	.globl	_Z19testHostPreformance12squareMatrixS_
	.type	_Z19testHostPreformance12squareMatrixS_, @function
_Z19testHostPreformance12squareMatrixS_:
.LFB2037:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movq	%rdi, %r15
	movl	%esi, %edi
	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
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	%rsi, %rbx
	leaq	.LC10(%rip), %rsi
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	call	_Z15printMatrixInfoiPc
	call	clock@PLT
	leaq	.LC11(%rip), %rsi
	movl	$2, %edi
	movq	%rax, %rbp
	xorl	%eax, %eax
	call	__printf_chk@PLT
	call	clock@PLT
	movslq	%ebx, %rdi
	imulq	%rdi, %rdi
	movq	%rax, %r14
	salq	$2, %rdi
	call	malloc@PLT
	movq	%rax, (%rsp)
	movl	%ebx, %eax
	movq	%rax, 8(%rsp)
	call	clock@PLT
	subq	%r14, %rax
	movq	%rax, %rdi
	call	_Z9printTimel
	call	clock@PLT
	leaq	.LC12(%rip), %rsi
	movl	$2, %edi
	movq	%rax, %r14
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	(%rsp), %r8
	movl	%ebx, %r9d
	movq	%r12, %rdx
	movq	%r13, %rcx
	movq	%r15, %rdi
	movq	%rbx, %rsi
	call	_Z16multiplyMatrices12squareMatrixS_S_
	call	clock@PLT
	subq	%r14, %rax
	movq	%rax, %rdi
	call	_Z9printTimel
	cmpb	$0, 41+startup(%rip)
	je	.L59
	movq	(%rsp), %rdi
	movq	8(%rsp), %rsi
	call	_Z17printSquareMatrix12squareMatrix
.L59:
	cmpb	$0, 40+startup(%rip)
	je	.L60
	leaq	.LC13(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	call	clock@PLT
	movq	(%rsp), %rdi
	movq	8(%rsp), %rsi
	leaq	.LC14(%rip), %rdx
	movq	%rax, %rbx
	call	_Z16saveMatrixToFile12squareMatrixPc
	call	clock@PLT
	subq	%rbx, %rax
	movq	%rax, %rdi
	call	_Z9printTimel
.L60:
	leaq	.LC15(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	call	clock@PLT
	movq	(%rsp), %rdi
	movq	%rax, %rbx
	call	free@PLT
	call	clock@PLT
	subq	%rbx, %rax
	movq	%rax, %rdi
	call	_Z9printTimel
	movl	$2, %edi
	leaq	.LC16(%rip), %rsi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	call	clock@PLT
	addq	$24, %rsp
	.cfi_def_cfa_offset 56
	subq	%rbp, %rax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	movq	%rax, %rdi
	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	_Z9printTimel
	.cfi_endproc
.LFE2037:
	.size	_Z19testHostPreformance12squareMatrixS_, .-_Z19testHostPreformance12squareMatrixS_
	.globl	_Z13getFreeGpuMemv
	.type	_Z13getFreeGpuMemv, @function
_Z13getFreeGpuMemv:
.LFB2040:
	.cfi_startproc
	endbr64
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	xorl	%esi, %esi
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rdi
	call	cudaMemGetInfo@PLT
	movl	(%rsp), %eax
	movq	8(%rsp), %rdx
	subq	%fs:40, %rdx
	je	.L63
	call	__stack_chk_fail@PLT
.L63:
	addq	$24, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2040:
	.size	_Z13getFreeGpuMemv, .-_Z13getFreeGpuMemv
	.globl	_Z39calculateLargestPossibleMatrixDimensionv
	.type	_Z39calculateLargestPossibleMatrixDimensionv, @function
_Z39calculateLargestPossibleMatrixDimensionv:
.LFB2041:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	call	_Z13getFreeGpuMemv
	movl	$12, %ecx
	xorl	%edx, %edx
	divl	%ecx
	cvtsi2sdl	%eax, %xmm0
	call	sqrt@PLT
	subsd	.LC17(%rip), %xmm0
	popq	%rdx
	.cfi_def_cfa_offset 8
	cvttsd2siq	%xmm0, %rax
	ret
	.cfi_endproc
.LFE2041:
	.size	_Z39calculateLargestPossibleMatrixDimensionv, .-_Z39calculateLargestPossibleMatrixDimensionv
	.globl	_Z49__device_stub__Z24multiplyMatricesParallelPiS_S_iPiS_S_i
	.type	_Z49__device_stub__Z24multiplyMatricesParallelPiS_S_iPiS_S_i, @function
_Z49__device_stub__Z24multiplyMatricesParallelPiS_S_iPiS_S_i:
.LFB2067:
	.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
	movl	%ecx, 4(%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)
	leaq	4(%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	.L67
	pushq	48(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z24multiplyMatricesParallelPiS_S_i(%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
.L67:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L69
	call	__stack_chk_fail@PLT
.L69:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2067:
	.size	_Z49__device_stub__Z24multiplyMatricesParallelPiS_S_iPiS_S_i, .-_Z49__device_stub__Z24multiplyMatricesParallelPiS_S_iPiS_S_i
	.globl	_Z24multiplyMatricesParallelPiS_S_i
	.type	_Z24multiplyMatricesParallelPiS_S_i, @function
_Z24multiplyMatricesParallelPiS_S_i:
.LFB2068:
	.cfi_startproc
	endbr64
	jmp	_Z49__device_stub__Z24multiplyMatricesParallelPiS_S_iPiS_S_i
	.cfi_endproc
.LFE2068:
	.size	_Z24multiplyMatricesParallelPiS_S_i, .-_Z24multiplyMatricesParallelPiS_S_i
	.section	.rodata.str1.1
.LC18:
	.string	"GPU"
.LC19:
	.string	"\tAllocating Result Matrix To RAM...               "
.LC20:
	.string	"\tAllocating A, B, and RESULT Matrix To VRAM...    "
.LC21:
	.string	"/home/ubuntu/Datasets/stackv2/train-structured/MaxKotlan/Cuda-Matrix-Multiplication-Benchmark/master/MatrixMultiplication.cu"
.LC22:
	.string	"\tCopying A, B To VRAM...                          "
.LC23:
	.string	"\tComputing and Copying Result...                  "
.LC24:
	.string	"\tDeallocating Result Matrix...                    "
.LC25:
	.string	"\nTotal Time: "
	.text
	.globl	_Z21testDevicePreformance12squareMatrixS_
	.type	_Z21testDevicePreformance12squareMatrixS_, @function
_Z21testDevicePreformance12squareMatrixS_:
.LFB2038:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	%esi, %r15d
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%rsi, %rbp
	leaq	.LC18(%rip), %rsi
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	%rcx, %rbx
	subq	$104, %rsp
	.cfi_def_cfa_offset 160
	movq	%rdi, 16(%rsp)
	movl	%ebp, %edi
	movq	%rdx, 24(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 88(%rsp)
	xorl	%eax, %eax
	call	_Z15printMatrixInfoiPc
	call	clock@PLT
	cmpl	%ebx, %ebp
	je	.L73
	movl	$1, %edi
	call	exit@PLT
.L73:
	movl	%ebp, %r14d
	leaq	.LC19(%rip), %rsi
	movl	$2, %edi
	movq	%rax, %r12
	imull	%ebp, %r14d
	xorl	%eax, %eax
	movl	%ebp, %ebp
	call	__printf_chk@PLT
	call	clock@PLT
	leal	0(,%r14,4), %ebx
	movq	%rax, %r13
	movslq	%ebx, %rbx
	movq	%rbx, %rdi
	call	malloc@PLT
	movq	%rax, 8(%rsp)
	call	clock@PLT
	subq	%r13, %rax
	movq	%rax, %rdi
	call	_Z9printTimel
	leaq	.LC20(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	call	clock@PLT
	leaq	40(%rsp), %rdi
	movq	%rbx, %rsi
	movq	%rax, %r13
	call	cudaMalloc@PLT
	movl	$1, %ecx
	movl	$193, %edx
	leaq	.LC21(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	leaq	48(%rsp), %rdi
	movq	%rbx, %rsi
	call	cudaMalloc@PLT
	movl	$1, %ecx
	movl	$194, %edx
	leaq	.LC21(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	leaq	56(%rsp), %rdi
	movq	%rbx, %rsi
	call	cudaMalloc@PLT
	movl	$1, %ecx
	movl	$195, %edx
	leaq	.LC21(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	call	clock@PLT
	subq	%r13, %rax
	movq	%rax, %rdi
	call	_Z9printTimel
	leaq	.LC22(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	call	clock@PLT
	movq	16(%rsp), %rsi
	movq	40(%rsp), %rdi
	movq	%rbx, %rdx
	movl	$1, %ecx
	movq	%rax, %r13
	call	cudaMemcpy@PLT
	movl	$1, %ecx
	movl	$200, %edx
	leaq	.LC21(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	movq	24(%rsp), %rsi
	movq	48(%rsp), %rdi
	movq	%rbx, %rdx
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movl	$1, %ecx
	movl	$201, %edx
	leaq	.LC21(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	call	clock@PLT
	subq	%r13, %rax
	movq	%rax, %rdi
	call	_Z9printTimel
	leaq	.LC23(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	call	clock@PLT
	movl	20+startup(%rip), %ecx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movabsq	$4294967297, %rsi
	movq	%rax, %r13
	movl	%r14d, %eax
	cltd
	movq	%rsi, 80(%rsp)
	idivl	%ecx
	movl	%ecx, 76(%rsp)
	movl	84(%rsp), %ecx
	movq	%rsi, 68(%rsp)
	movq	76(%rsp), %rdx
	movl	72(%rsp), %esi
	incl	%eax
	movl	%eax, 64(%rsp)
	movq	64(%rsp), %rdi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L74
	movq	56(%rsp), %rdx
	movq	48(%rsp), %rsi
	movl	%r15d, %ecx
	movq	40(%rsp), %rdi
	call	_Z49__device_stub__Z24multiplyMatricesParallelPiS_S_iPiS_S_i
.L74:
	call	cudaGetLastError@PLT
	movl	$1, %ecx
	movl	$208, %edx
	leaq	.LC21(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	movq	56(%rsp), %rsi
	movq	8(%rsp), %rdi
	movq	%rbx, %rdx
	movl	$2, %ecx
	call	cudaMemcpy@PLT
	movl	$1, %ecx
	movl	$209, %edx
	leaq	.LC21(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	call	clock@PLT
	subq	%r13, %rax
	movq	%rax, %rdi
	call	_Z9printTimel
	cmpb	$0, 41+startup(%rip)
	je	.L75
	movq	8(%rsp), %rdi
	movq	%rbp, %rsi
	call	_Z17printSquareMatrix12squareMatrix
.L75:
	cmpb	$0, 40+startup(%rip)
	je	.L76
	leaq	.LC13(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	call	clock@PLT
	movq	8(%rsp), %rdi
	leaq	.LC14(%rip), %rdx
	movq	%rbp, %rsi
	movq	%rax, %rbx
	call	_Z16saveMatrixToFile12squareMatrixPc
	call	clock@PLT
	subq	%rbx, %rax
	movq	%rax, %rdi
	call	_Z9printTimel
.L76:
	leaq	.LC24(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	call	clock@PLT
	movq	40(%rsp), %rdi
	movq	%rax, %rbx
	call	cudaFree@PLT
	movq	48(%rsp), %rdi
	call	cudaFree@PLT
	movq	56(%rsp), %rdi
	call	cudaFree@PLT
	movq	8(%rsp), %rdi
	call	free@PLT
	call	clock@PLT
	subq	%rbx, %rax
	movq	%rax, %rdi
	call	_Z9printTimel
	movl	$2, %edi
	leaq	.LC25(%rip), %rsi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	call	clock@PLT
	subq	%r12, %rax
	movq	%rax, %rdi
	call	_Z9printTimel
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	je	.L77
	call	__stack_chk_fail@PLT
.L77:
	addq	$104, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2038:
	.size	_Z21testDevicePreformance12squareMatrixS_, .-_Z21testDevicePreformance12squareMatrixS_
	.section	.rodata.str1.1
.LC26:
	.string	"matrix_A"
.LC27:
	.string	"matrix_B"
	.text
	.globl	_Z35testMatrixMultiplicationPreformancei
	.type	_Z35testMatrixMultiplicationPreformancei, @function
_Z35testMatrixMultiplicationPreformancei:
.LFB2039:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	movl	%edi, %ebx
	pushq	%rdx
	.cfi_def_cfa_offset 48
	movl	8+startup(%rip), %edi
	call	srand@PLT
	movl	%ebx, %edi
	call	_Z24createRandomSquareMatrixi
	movl	%ebx, %edi
	movq	%rax, %rbp
	movq	%rdx, %r12
	call	_Z24createRandomSquareMatrixi
	cmpb	$0, 41+startup(%rip)
	movq	%rax, %rbx
	movq	%rdx, %r13
	je	.L80
	movq	%rbp, %rdi
	movq	%r12, %rsi
	call	_Z17printSquareMatrix12squareMatrix
	movq	%rbx, %rdi
	movq	%r13, %rsi
	call	_Z17printSquareMatrix12squareMatrix
.L80:
	cmpb	$0, 40+startup(%rip)
	je	.L81
	leaq	.LC26(%rip), %rdx
	movq	%rbp, %rdi
	movq	%r12, %rsi
	call	_Z16saveMatrixToFile12squareMatrixPc
	leaq	.LC27(%rip), %rdx
	movq	%rbx, %rdi
	movq	%r13, %rsi
	call	_Z16saveMatrixToFile12squareMatrixPc
.L81:
	cmpl	$2, startup(%rip)
	jne	.L82
.L84:
	movq	%rbx, %rdx
	movq	%r13, %rcx
	movq	%rbp, %rdi
	movq	%r12, %rsi
	call	_Z19testHostPreformance12squareMatrixS_
	jmp	.L83
.L82:
	movq	%rbx, %rdx
	movq	%r13, %rcx
	movq	%rbp, %rdi
	movq	%r12, %rsi
	call	_Z21testDevicePreformance12squareMatrixS_
	cmpl	$1, startup(%rip)
	jne	.L84
.L83:
	movq	%rbp, %rdi
	call	free@PLT
	popq	%rax
	.cfi_def_cfa_offset 40
	movq	%rbx, %rdi
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	jmp	free@PLT
	.cfi_endproc
.LFE2039:
	.size	_Z35testMatrixMultiplicationPreformancei, .-_Z35testMatrixMultiplicationPreformancei
	.section	.rodata.str1.1
.LC28:
	.string	"--help"
.LC29:
	.string	"%s"
.LC30:
	.string	"--device"
.LC31:
	.string	"gpu"
.LC32:
	.string	"cpu"
.LC33:
	.string	"both"
.LC34:
	.string	"--random_mod"
.LC35:
	.string	"--max_dimension"
.LC36:
	.string	"--seed"
.LC37:
	.string	"--start_dimension"
.LC38:
	.string	"--only"
.LC39:
	.string	"--block_threads"
.LC40:
	.string	"--mat_print"
.LC41:
	.string	"--mat_save"
.LC42:
	.string	"--"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2042:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	.LC38(%rip), %r15
	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
	xorl	%r12d, %r12d
	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
	leaq	8(%rsi), %rbx
	pushq	%r8
	.cfi_def_cfa_offset 64
.L87:
	cmpl	%ebp, %r12d
	jge	.L109
	movq	-8(%rbx), %r13
	leaq	.LC28(%rip), %rsi
	movq	%r13, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L88
	movq	help(%rip), %rdx
	movl	$2, %edi
	leaq	.LC29(%rip), %rsi
	call	__printf_chk@PLT
	orl	$-1, %edi
	call	exit@PLT
.L88:
	leaq	.LC30(%rip), %rsi
	movq	%r13, %rdi
	incl	%r12d
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L89
	cmpl	%r12d, %ebp
	jle	.L89
	movq	(%rbx), %r14
	leaq	.LC31(%rip), %rsi
	movq	%r14, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L90
	movl	$1, startup(%rip)
	jmp	.L89
.L90:
	leaq	.LC32(%rip), %rsi
	movq	%r14, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L91
	movl	$2, startup(%rip)
	jmp	.L89
.L91:
	leaq	.LC33(%rip), %rsi
	movq	%r14, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L89
	xorl	%ecx, %ecx
	movl	%ecx, startup(%rip)
.L89:
	leaq	.LC34(%rip), %rsi
	movq	%r13, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L92
	cmpl	%r12d, %ebp
	jle	.L92
	movq	(%rbx), %rdi
	call	atoi@PLT
	movl	%eax, 4+startup(%rip)
.L92:
	leaq	.LC35(%rip), %rsi
	movq	%r13, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L93
	cmpl	%r12d, %ebp
	jle	.L93
	movq	(%rbx), %rdi
	call	atoi@PLT
	movl	%eax, 12+startup(%rip)
.L93:
	leaq	.LC36(%rip), %rsi
	movq	%r13, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L94
	cmpl	%r12d, %ebp
	jle	.L94
	movq	(%rbx), %rdi
	call	atoi@PLT
	movl	%eax, 8+startup(%rip)
.L94:
	leaq	.LC37(%rip), %rsi
	movq	%r13, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L95
	cmpl	%r12d, %ebp
	jle	.L95
	movq	(%rbx), %rdi
	call	atoi@PLT
	movl	%eax, 16+startup(%rip)
.L95:
	movq	%r15, %rsi
	movq	%r13, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L96
	cmpl	%r12d, %ebp
	jle	.L96
	movq	(%rbx), %rdi
	call	atoi@PLT
	movl	%eax, 24+startup(%rip)
.L96:
	leaq	.LC39(%rip), %rsi
	movq	%r13, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L97
	cmpl	%r12d, %ebp
	jle	.L97
	movq	(%rbx), %rdi
	call	atoi@PLT
	movl	%eax, 20+startup(%rip)
.L97:
	leaq	.LC40(%rip), %rsi
	movq	%r13, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L98
	movb	$1, 41+startup(%rip)
.L98:
	leaq	.LC41(%rip), %rsi
	movq	%r13, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L100
	movb	$1, 40+startup(%rip)
	cmpl	%r12d, %ebp
	jle	.L100
	movq	(%rbx), %r13
	leaq	.LC42(%rip), %rsi
	movq	%r13, %rdi
	call	strstr@PLT
	testq	%rax, %rax
	jne	.L100
	movq	%r13, 32+startup(%rip)
.L100:
	addq	$8, %rbx
	jmp	.L87
.L109:
	movl	24+startup(%rip), %edi
	testl	%edi, %edi
	je	.L103
	call	_Z35testMatrixMultiplicationPreformancei
	jmp	.L104
.L103:
	call	_Z39calculateLargestPossibleMatrixDimensionv
	movl	16+startup(%rip), %ebp
	movl	%eax, %ebx
.L105:
	addl	%ebx, %ebx
	cmpl	%ebp, %ebx
	je	.L104
	cmpl	%ebp, 12+startup(%rip)
	jl	.L104
	call	_Z39calculateLargestPossibleMatrixDimensionv
	cmpl	%eax, %ebp
	movl	%eax, %ebx
	cmova	%eax, %ebp
	movl	%ebp, %edi
	addl	%ebp, %ebp
	call	_Z35testMatrixMultiplicationPreformancei
	jmp	.L105
.L104:
	popq	%rdx
	.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
.LFE2042:
	.size	main, .-main
	.section	.rodata.str1.1
.LC43:
	.string	"_Z24multiplyMatricesParallelPiS_S_i"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2070:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	pushq	$0
	.cfi_def_cfa_offset 24
	xorl	%r9d, %r9d
	orl	$-1, %r8d
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC43(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z24multiplyMatricesParallelPiS_S_i(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 48
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFunction@PLT
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rdx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE2070:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.rodata.str1.1
.LC44:
	.string	"."
	.section	.text.startup
	.type	_GLOBAL__sub_I_startup, @function
_GLOBAL__sub_I_startup:
.LFB2188:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	xorl	%edi, %edi
	movabsq	$8589934593, %rax
	movq	%rax, startup(%rip)
	call	time@PLT
	movq	$256, 20+startup(%rip)
	movl	%eax, 8+startup(%rip)
	movabsq	$10737418239, %rax
	movq	%rax, 12+startup(%rip)
	leaq	.LC44(%rip), %rax
	movq	%rax, 32+startup(%rip)
	movw	$0, 40+startup(%rip)
	popq	%rdx
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2188:
	.size	_GLOBAL__sub_I_startup, .-_GLOBAL__sub_I_startup
	.section	.init_array
	.align 8
	.quad	_GLOBAL__sub_I_startup
	.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	help
	.section	.rodata.str1.1
.LC45:
	.ascii	"\n Shows what parameters are available\n\t--help\n\n Selects"
	.ascii	" which device should be used:\n\t--device cpu\n\t--device gp"
	.ascii	"u\n\t--device both\n\n sets seedvalue for random number gene"
	.ascii	"ration (default: currentTime)\n\t--seed [int]\n\n sets mod v"
	.ascii	"alue for random number generation (default: 2)\n\t--random_m"
	.ascii	"od [int]\n\n sets max dimension to compute (default: max mat"
	.ascii	"rix that can fit in vram)\n\t--max_dimension [int]\n\n sets "
	.ascii	"starting matrix dimension (default: 2)\n\t--start_dimension "
	.ascii	"[int]\n\n only computes a single matrix of n size.\n\t--only"
	.ascii	" [int]\n\n sets the number of threads per block (default: 25"
	.ascii	"6). Should be a mu"
	.string	"ltiple of cuda cores\n\t--block_threads [int 1-1024]\n\n outputs matrix a, b and result. (not recommended for extremely large matrices)\n\t--mat_print                    (prints to the console)\n\t--mat_save [filepath]          (saves to disk. filepath optional)\n\n"
	.section	.data.rel.local,"aw"
	.align 8
	.type	help, @object
	.size	help, 8
help:
	.quad	.LC45
	.globl	startup
	.bss
	.align 32
	.type	startup, @object
	.size	startup, 48
startup:
	.zero	48
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC17:
	.long	0
	.long	1072693248
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

#include <stdio.h>
#include <hip/hip_runtime.h>
//#include <cuda_runtime.h>
//#include <curand_kernel.h>
#include <string.h>
#include <time.h>

enum comptuationDevice{
    dev_both,
    dev_gpu,
    dev_cpu
};

/*Global Startup Settings*/
struct Startup{
    comptuationDevice device = dev_gpu;
    int randomMod = 2;
    int seedValue = time(nullptr);
    int maxDimension = INT_MAX;
    int startDimension = 2;
    int threadsPerBlock = 256;
    int onlyMatrixSize = NULL;
    char* outputDirectory = ".";
    bool matSave  = false;
    bool matPrint = false;
} startup;

/*Matrix Datastructure*/
struct squareMatrix{
    int* elements;
    int dimension;
};

const char* help =
"\n Shows what parameters are available\n\
\t--help\n\n\
 Selects which device should be used:\n\
\t--device cpu\n\
\t--device gpu\n\
\t--device both\n\n\
 sets seedvalue for random number generation (default: currentTime)\n\
\t--seed [int]\n\n\
 sets mod value for random number generation (default: 2)\n\
\t--random_mod [int]\n\n\
 sets max dimension to compute (default: max matrix that can fit in vram)\n\
\t--max_dimension [int]\n\n\
 sets starting matrix dimension (default: 2)\n\
\t--start_dimension [int]\n\n\
 only computes a single matrix of n size.\n\
\t--only [int]\n\n\
 sets the number of threads per block (default: 256). Should be a multiple of cuda cores\n\
\t--block_threads [int 1-1024]\n\n\
 outputs matrix a, b and result. (not recommended for extremely large matrices)\n\
\t--mat_print                    (prints to the console)\n\
\t--mat_save [filepath]          (saves to disk. filepath optional)\n\n";

__host__ squareMatrix createRandomSquareMatrix(int dimension){
    int  mat_elements = dimension * dimension;
    int* mat = (int*)malloc(sizeof(int)*mat_elements);
    for (int i = 0; i < mat_elements; i++)
        mat[i] = rand()%startup.randomMod;
    return {mat, dimension};
}

__host__ void printSquareMatrix(squareMatrix mat){
    for (int i = 0; i < mat.dimension*mat.dimension; i++){
        if (i % mat.dimension == 0 && i != 0) printf("\n");
        printf("%d ", mat.elements[i]);
    }
    printf("\n\n");
}

__host__ void multiplyMatrices(squareMatrix a, squareMatrix b, squareMatrix result){
    if (a.dimension != b.dimension) exit(1);
    
    for (int i = 0; i < result.dimension; i++){
        for (int j = 0; j < result.dimension; j++){
            result.elements[j + result.dimension*i] = 0;
            for (int k = 0; k < result.dimension; k++)
                result.elements[j + result.dimension*i] += a.elements[k + result.dimension*i] * b.elements[j + result.dimension*k];
        }
    }
}

__global__ void multiplyMatricesParallel(int* mat_a, int* mat_b, int* mat_results, int dimension){

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

    if (idx < dimension*dimension){
        mat_results[idx] = 0;
        for (int i = 0; i < dimension; i++){
            int row = idx / dimension;
            mat_results[idx] += mat_a[i +  dimension*row] * mat_b[idx%dimension + dimension*i];
        }
    }
}

__host__ void printMatrixInfo(int dimension, char* type){
    printf("--------------------------------------------------------------------------------------------\nMultiplying %dx%d X %dx%d using the %s ...\n\n", 
    dimension, dimension, dimension, dimension, type);
}

__host__ void saveMatrixToFile(squareMatrix mat_sav, char* label){

    char fileNameBuffer[256];

    char dim[30];

    snprintf(dim, 10,"%d", mat_sav.dimension);

    snprintf(fileNameBuffer, sizeof fileNameBuffer, "%s/%sx%s_X_%sx%s_%s.txt", startup.outputDirectory, dim, dim, dim, dim, label);
    
    FILE* fp = fopen( fileNameBuffer, "w");
    if (fp == nullptr) printf("Could not log to file\n");
    else {
        for (int i = 0; i < mat_sav.dimension*mat_sav.dimension; i++){
            if (i % mat_sav.dimension == 0 && i != 0) fprintf(fp, "\n");
            fprintf(fp, "%d ", mat_sav.elements[i]);
        }
        fprintf(fp, "\n");
    }
    fclose(fp);
}


__host__ void printTime(clock_t totaltime){
    int msec = totaltime * 1000 / CLOCKS_PER_SEC;
    printf("Done in %d msec!\n", msec);
}

/*
 Found on the stack overflow:  https://stackoverflow.com/questions/14038589/what-is-the-canonical-way-to-check-for-errors-using-the-cuda-runtime-api
 Throws errors if cuda command doesn't return Success
*/
#define gpuErrchk(ans) { gpuAssert((ans), __FILE__, __LINE__); }
inline void gpuAssert(hipError_t code, const char *file, int line, bool abort=true)
{
   if (code != hipSuccess) 
   {
      fprintf(stderr,"GPUassert: %s %s %d\n", hipGetErrorString(code), file, line);
      if (abort) exit(code);
   }
}

__host__ void testHostPreformance(squareMatrix mat_a, squareMatrix mat_b){
    printMatrixInfo(mat_a.dimension, (char*)"CPU");
    clock_t initalTime = clock();

    printf("\tAllocating Result Matrix To Ram...               ");
    clock_t before = clock();
    squareMatrix mat_results = {(int*)malloc(sizeof(int)*mat_a.dimension*mat_a.dimension), mat_a.dimension};
    printTime(clock() - before);

    before = clock();
    printf("\tPreforming Multiplication...                     ");
    multiplyMatrices(mat_a, mat_b, mat_results);
    printTime(clock() - before);

    if (startup.matPrint) printSquareMatrix(mat_results);
    if (startup.matSave)  {
        printf("\tSaving Result Matrix to Disk...                  ");
        before = clock();
        saveMatrixToFile(mat_results, "matrix_result");
        printTime(clock() - before);
    }

    printf("\tDeallocating Result Matrix From Ram...           ");
    before = clock();
    free(mat_results.elements);
    printTime(clock() - before);

    printf("\nTotal Time:                                      ");
    printTime(clock() - initalTime);
}

__host__ void testDevicePreformance(squareMatrix mat_a, squareMatrix mat_b){
    printMatrixInfo(mat_a.dimension, (char*)"GPU");
    clock_t initalTime = clock();

    if (mat_a.dimension != mat_b.dimension) exit(1);
    
    int allocationsize = mat_a.dimension * mat_b.dimension * sizeof(int);

    printf("\tAllocating Result Matrix To RAM...               ");
    clock_t before = clock();
        squareMatrix mat_results = {(int*)malloc(allocationsize), mat_a.dimension};
    printTime(clock() - before);

    int* dev_mat_a, *dev_mat_b, *dev_mat_results;

    printf("\tAllocating A, B, and RESULT Matrix To VRAM...    ");
    before = clock();
        gpuErrchk(hipMalloc((void **)&dev_mat_a,          allocationsize));
        gpuErrchk(hipMalloc((void **)&dev_mat_b,          allocationsize));
        gpuErrchk(hipMalloc((void **)&dev_mat_results,    allocationsize));
    printTime(clock() - before);

    printf("\tCopying A, B To VRAM...                          ");
    before = clock();
        gpuErrchk(hipMemcpy(dev_mat_a, mat_a.elements, allocationsize, hipMemcpyHostToDevice));
        gpuErrchk(hipMemcpy(dev_mat_b, mat_b.elements, allocationsize, hipMemcpyHostToDevice));
    printTime(clock() - before);

    printf("\tComputing and Copying Result...                  ");
    before = clock();
        int totalThreadsNeeded = mat_a.dimension*mat_a.dimension;
        multiplyMatricesParallel<<<totalThreadsNeeded / startup.threadsPerBlock + 1, startup.threadsPerBlock>>> (dev_mat_a, dev_mat_b, dev_mat_results, mat_a.dimension);
        gpuErrchk(hipGetLastError());
        gpuErrchk(hipMemcpy(mat_results.elements, dev_mat_results, allocationsize, hipMemcpyDeviceToHost));
    printTime(clock() - before);


    if (startup.matPrint) printSquareMatrix(mat_results);
    if (startup.matSave)  {
        printf("\tSaving Result Matrix to Disk...                  ");
        before = clock();
        saveMatrixToFile(mat_results, "matrix_result");
        printTime(clock() - before);
    }

    printf("\tDeallocating Result Matrix...                    ");
    before = clock();
        hipFree(dev_mat_a); hipFree(dev_mat_b); hipFree(dev_mat_results);
        free(mat_results.elements);
    printTime(clock() - before);

    printf("\nTotal Time: ");
    printTime(clock() - initalTime);
}

__host__ void testMatrixMultiplicationPreformance(int dimension){

    srand(startup.seedValue);

    squareMatrix mat_a, mat_b;
    
    mat_a = createRandomSquareMatrix(dimension);
    mat_b = createRandomSquareMatrix(dimension);

    if (startup.matPrint) {
        printSquareMatrix(mat_a);
        printSquareMatrix(mat_b);
    }

    if (startup.matSave) {
        saveMatrixToFile(mat_a, "matrix_A");
        saveMatrixToFile(mat_b, "matrix_B");
    }

    if (startup.device != dev_cpu) testDevicePreformance(mat_a, mat_b);
    if (startup.device != dev_gpu) testHostPreformance(mat_a, mat_b);

    free(mat_a.elements);
    free(mat_b.elements);
}

unsigned int getFreeGpuMem()
{
    size_t free_t;
    hipMemGetInfo(&free_t,nullptr);    
    return (unsigned int)free_t;
}

__host__ unsigned int calculateLargestPossibleMatrixDimension(){
    unsigned int free = getFreeGpuMem();
    unsigned int memoryPerMatrix = free  / (sizeof(int) * 3);
    unsigned int maxMatrixDimension = sqrt( memoryPerMatrix ) - 1;
    return maxMatrixDimension;
}

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

    for (int i = 0; i < argc; i++){
        if (strcmp(argv[i],  "--help")==0) {printf("%s", help); exit(-1); }
        if (strcmp(argv[i],  "--device")==0 && i+1 < argc) 
            if (strcmp(argv[i+1], "gpu") == 0) startup.device = dev_gpu;
            else if (strcmp(argv[i+1], "cpu") == 0) startup.device = dev_cpu;
            else if (strcmp(argv[i+1], "both") == 0) startup.device = dev_both;
        if (strcmp(argv[i],  "--random_mod")==0 && i+1 < argc) startup.randomMod = atoi(argv[i+1]);
        if (strcmp(argv[i],  "--max_dimension")==0 && i+1 < argc) startup.maxDimension = atoi(argv[i+1]);
        if (strcmp(argv[i],  "--seed")==0 && i+1 < argc) startup.seedValue = atoi(argv[i+1]);
        if (strcmp(argv[i],  "--start_dimension")==0 && i+1 < argc) startup.startDimension = atoi(argv[i+1]);
        if (strcmp(argv[i],  "--only")==0 && i+1 < argc) startup.onlyMatrixSize = atoi(argv[i+1]);
        if (strcmp(argv[i],  "--block_threads")==0 && i+1 < argc) startup.threadsPerBlock = atoi(argv[i+1]);
        if (strcmp(argv[i],  "--mat_print")==0) startup.matPrint = true;
        if (strcmp(argv[i],  "--mat_save")==0){ 
            startup.matSave = true;
            if   (i+1 < argc && strstr(argv[i+1], "--") == NULL) startup.outputDirectory = argv[i+1];
        }
    }

    /*Tests only one matrix if parameter passed in*/
    if (startup.onlyMatrixSize != NULL)
        testMatrixMultiplicationPreformance(startup.onlyMatrixSize);

    /*Otherwise, double matrix size until vram is completely filled*/
    else { 
        unsigned int maxMatrixDimension = calculateLargestPossibleMatrixDimension();
        for (int i = startup.startDimension; i != maxMatrixDimension*2 && i <= startup.maxDimension; i*=2 ) {
            maxMatrixDimension = calculateLargestPossibleMatrixDimension();
            if (i > maxMatrixDimension)
                i = maxMatrixDimension;
            testMatrixMultiplicationPreformance(i);
        }
    }
    
	return 0;
}
	.text
	.file	"MatrixMultiplication.hip"
	.globl	_Z24createRandomSquareMatrixi   # -- Begin function _Z24createRandomSquareMatrixi
	.type	_Z24createRandomSquareMatrixi,@function
_Z24createRandomSquareMatrixi:          # @_Z24createRandomSquareMatrixi
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r12
	.cfi_def_cfa_offset 32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	pushq	%rax
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -40
	.cfi_offset %r12, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movl	%edi, %ebx
	movl	%edi, %r15d
	imull	%r15d, %r15d
	leaq	(,%r15,4), %rdi
	callq	malloc
	movq	%rax, %r14
	testl	%ebx, %ebx
	je	.LBB0_3
# %bb.1:                                # %.lr.ph.preheader
	cmpl	$1, %r15d
	adcl	$0, %r15d
	xorl	%r12d, %r12d
.LBB0_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	callq	rand
	cltd
	idivl	startup+4(%rip)
	movl	%edx, (%r14,%r12,4)
	incq	%r12
	cmpq	%r12, %r15
	jne	.LBB0_2
.LBB0_3:                                # %._crit_edge
	movq	%r14, %rax
	movl	%ebx, %edx
	addq	$8, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	_Z24createRandomSquareMatrixi, .Lfunc_end0-_Z24createRandomSquareMatrixi
	.cfi_endproc
                                        # -- End function
	.globl	_Z17printSquareMatrix12squareMatrix # -- Begin function _Z17printSquareMatrix12squareMatrix
	.type	_Z17printSquareMatrix12squareMatrix,@function
_Z17printSquareMatrix12squareMatrix:    # @_Z17printSquareMatrix12squareMatrix
	.cfi_startproc
# %bb.0:
	testl	%esi, %esi
	je	.LBB1_7
# %bb.1:                                # %.lr.ph.preheader
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r12
	.cfi_def_cfa_offset 32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	pushq	%rax
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -40
	.cfi_offset %r12, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movl	%esi, %ebx
	movq	%rdi, %r14
	movl	%esi, %r12d
	imull	%r12d, %r12d
	cmpl	$1, %r12d
	adcl	$0, %r12d
	xorl	%r15d, %r15d
.LBB1_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movl	%r15d, %eax
	cltd
	idivl	%ebx
	testq	%r15, %r15
	je	.LBB1_5
# %bb.3:                                # %.lr.ph
                                        #   in Loop: Header=BB1_2 Depth=1
	testl	%edx, %edx
	jne	.LBB1_5
# %bb.4:                                #   in Loop: Header=BB1_2 Depth=1
	movl	$10, %edi
	callq	putchar@PLT
.LBB1_5:                                #   in Loop: Header=BB1_2 Depth=1
	movl	(%r14,%r15,4), %esi
	movl	$.L.str.2, %edi
	xorl	%eax, %eax
	callq	printf
	incq	%r15
	cmpq	%r15, %r12
	jne	.LBB1_2
# %bb.6:
	addq	$8, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	.cfi_restore %rbx
	.cfi_restore %r12
	.cfi_restore %r14
	.cfi_restore %r15
.LBB1_7:                                # %._crit_edge
	movl	$.Lstr, %edi
	jmp	puts@PLT                        # TAILCALL
.Lfunc_end1:
	.size	_Z17printSquareMatrix12squareMatrix, .Lfunc_end1-_Z17printSquareMatrix12squareMatrix
	.cfi_endproc
                                        # -- End function
	.globl	_Z16multiplyMatrices12squareMatrixS_S_ # -- Begin function _Z16multiplyMatrices12squareMatrixS_S_
	.type	_Z16multiplyMatrices12squareMatrixS_S_,@function
_Z16multiplyMatrices12squareMatrixS_S_: # @_Z16multiplyMatrices12squareMatrixS_S_
	.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
	pushq	%rax
	.cfi_def_cfa_offset 64
	.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	%r8, (%rsp)                     # 8-byte Spill
	cmpl	%ecx, %esi
	jne	.LBB2_9
# %bb.1:                                # %.preheader27
	testl	%r9d, %r9d
	jle	.LBB2_8
# %bb.2:                                # %.preheader.lr.ph
	movl	%r9d, %eax
	leaq	(,%rax,4), %rcx
	xorl	%r8d, %r8d
	xorl	%r10d, %r10d
.LBB2_3:                                # %.lr.ph30
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB2_4 Depth 2
                                        #       Child Loop BB2_5 Depth 3
	movl	%r8d, %r11d
	leaq	(%rdi,%r11,4), %r11
	movq	%r10, %rbx
	imulq	%rax, %rbx
	movq	(%rsp), %rsi                    # 8-byte Reload
	leaq	(%rsi,%rbx,4), %rbx
	movq	%rdx, %r14
	xorl	%r15d, %r15d
.LBB2_4:                                # %.lr.ph
                                        #   Parent Loop BB2_3 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB2_5 Depth 3
	movl	$0, (%rbx,%r15,4)
	xorl	%r12d, %r12d
	movq	%r14, %r13
	xorl	%ebp, %ebp
.LBB2_5:                                #   Parent Loop BB2_3 Depth=1
                                        #     Parent Loop BB2_4 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	movl	(%r13), %esi
	imull	(%r11,%r12,4), %esi
	addl	%esi, %ebp
	movl	%ebp, (%rbx,%r15,4)
	incq	%r12
	addq	%rcx, %r13
	cmpq	%r12, %rax
	jne	.LBB2_5
# %bb.6:                                # %._crit_edge
                                        #   in Loop: Header=BB2_4 Depth=2
	incq	%r15
	addq	$4, %r14
	cmpq	%rax, %r15
	jne	.LBB2_4
# %bb.7:                                # %._crit_edge31
                                        #   in Loop: Header=BB2_3 Depth=1
	incq	%r10
	addl	%r9d, %r8d
	cmpq	%rax, %r10
	jne	.LBB2_3
.LBB2_8:                                # %._crit_edge33
	addq	$8, %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
.LBB2_9:
	.cfi_def_cfa_offset 64
	movl	$1, %edi
	callq	exit
.Lfunc_end2:
	.size	_Z16multiplyMatrices12squareMatrixS_S_, .Lfunc_end2-_Z16multiplyMatrices12squareMatrixS_S_
	.cfi_endproc
                                        # -- End function
	.globl	_Z39__device_stub__multiplyMatricesParallelPiS_S_i # -- Begin function _Z39__device_stub__multiplyMatricesParallelPiS_S_i
	.type	_Z39__device_stub__multiplyMatricesParallelPiS_S_i,@function
_Z39__device_stub__multiplyMatricesParallelPiS_S_i: # @_Z39__device_stub__multiplyMatricesParallelPiS_S_i
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$112, %rsp
	.cfi_def_cfa_offset 160
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	32(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	24(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	4(%rsp), %rdx
	movl	%ecx, (%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	16(%rsp), %r12
	leaq	8(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z24multiplyMatricesParallelPiS_S_i, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$128, %rsp
	.cfi_adjust_cfa_offset -128
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end3:
	.size	_Z39__device_stub__multiplyMatricesParallelPiS_S_i, .Lfunc_end3-_Z39__device_stub__multiplyMatricesParallelPiS_S_i
	.cfi_endproc
                                        # -- End function
	.globl	_Z15printMatrixInfoiPc          # -- Begin function _Z15printMatrixInfoiPc
	.type	_Z15printMatrixInfoiPc,@function
_Z15printMatrixInfoiPc:                 # @_Z15printMatrixInfoiPc
	.cfi_startproc
# %bb.0:
	movq	%rsi, %r9
	movl	%edi, %ecx
	movl	$.L.str.4, %edi
	movl	%ecx, %esi
	movl	%ecx, %edx
	movl	%ecx, %r8d
	xorl	%eax, %eax
	jmp	printf                          # TAILCALL
.Lfunc_end4:
	.size	_Z15printMatrixInfoiPc, .Lfunc_end4-_Z15printMatrixInfoiPc
	.cfi_endproc
                                        # -- End function
	.globl	_Z16saveMatrixToFile12squareMatrixPc # -- Begin function _Z16saveMatrixToFile12squareMatrixPc
	.type	_Z16saveMatrixToFile12squareMatrixPc,@function
_Z16saveMatrixToFile12squareMatrixPc:   # @_Z16saveMatrixToFile12squareMatrixPc
	.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	$288, %rsp                      # imm = 0x120
	.cfi_def_cfa_offset 336
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rdx, %r15
	movl	%esi, %ebx
	movq	%rdi, %r14
	movq	%rsp, %r12
	movl	$10, %esi
	movl	$.L.str.5, %edx
	movq	%r12, %rdi
	movl	%ebx, %ecx
	xorl	%eax, %eax
	callq	snprintf
	movq	startup+32(%rip), %rcx
	subq	$8, %rsp
	.cfi_adjust_cfa_offset 8
	leaq	40(%rsp), %r13
	movl	$256, %esi                      # imm = 0x100
	movl	$.L.str.6, %edx
	movq	%r13, %rdi
	movq	%r12, %r8
	movq	%r12, %r9
	xorl	%eax, %eax
	pushq	%r15
	.cfi_adjust_cfa_offset 8
	pushq	%r12
	.cfi_adjust_cfa_offset 8
	pushq	%r12
	.cfi_adjust_cfa_offset 8
	callq	snprintf
	addq	$32, %rsp
	.cfi_adjust_cfa_offset -32
	movl	$.L.str.7, %esi
	movq	%r13, %rdi
	callq	fopen
	movq	%rax, %r15
	testq	%rax, %rax
	je	.LBB5_8
# %bb.1:                                # %.preheader
	testl	%ebx, %ebx
	je	.LBB5_7
# %bb.2:                                # %.lr.ph.preheader
	movl	%ebx, %r13d
	imull	%r13d, %r13d
	cmpl	$1, %r13d
	adcl	$0, %r13d
	xorl	%r12d, %r12d
.LBB5_3:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movl	%r12d, %eax
	cltd
	idivl	%ebx
	testq	%r12, %r12
	je	.LBB5_6
# %bb.4:                                # %.lr.ph
                                        #   in Loop: Header=BB5_3 Depth=1
	testl	%edx, %edx
	jne	.LBB5_6
# %bb.5:                                #   in Loop: Header=BB5_3 Depth=1
	movl	$10, %edi
	movq	%r15, %rsi
	callq	fputc@PLT
.LBB5_6:                                #   in Loop: Header=BB5_3 Depth=1
	movl	(%r14,%r12,4), %edx
	movl	$.L.str.2, %esi
	movq	%r15, %rdi
	xorl	%eax, %eax
	callq	fprintf
	incq	%r12
	cmpq	%r12, %r13
	jne	.LBB5_3
.LBB5_7:                                # %._crit_edge
	movl	$10, %edi
	movq	%r15, %rsi
	callq	fputc@PLT
	jmp	.LBB5_9
.LBB5_8:
	movl	$.Lstr.1, %edi
	callq	puts@PLT
.LBB5_9:
	movq	%r15, %rdi
	callq	fclose
	addq	$288, %rsp                      # imm = 0x120
	.cfi_def_cfa_offset 48
	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_end5:
	.size	_Z16saveMatrixToFile12squareMatrixPc, .Lfunc_end5-_Z16saveMatrixToFile12squareMatrixPc
	.cfi_endproc
                                        # -- End function
	.globl	_Z9printTimel                   # -- Begin function _Z9printTimel
	.type	_Z9printTimel,@function
_Z9printTimel:                          # @_Z9printTimel
	.cfi_startproc
# %bb.0:
	movq	%rdi, %rax
	movabsq	$2361183241434822607, %rcx      # imm = 0x20C49BA5E353F7CF
	imulq	%rcx
	movq	%rdx, %rsi
	shrq	$63, %rsi
	shrq	$7, %rdx
	addl	%edx, %esi
	movl	$.L.str.9, %edi
                                        # kill: def $esi killed $esi killed $rsi
	xorl	%eax, %eax
	jmp	printf                          # TAILCALL
.Lfunc_end6:
	.size	_Z9printTimel, .Lfunc_end6-_Z9printTimel
	.cfi_endproc
                                        # -- End function
	.globl	_Z19testHostPreformance12squareMatrixS_ # -- Begin function _Z19testHostPreformance12squareMatrixS_
	.type	_Z19testHostPreformance12squareMatrixS_,@function
_Z19testHostPreformance12squareMatrixS_: # @_Z19testHostPreformance12squareMatrixS_
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	%ecx, 4(%rsp)                   # 4-byte Spill
	movq	%rdx, 8(%rsp)                   # 8-byte Spill
	movl	%esi, %ebp
	movq	%rdi, %r13
	movl	$.L.str.4, %edi
	movl	$.L.str.10, %r9d
	movl	%esi, %edx
	movl	%esi, %ecx
	movl	%esi, %r8d
	xorl	%eax, %eax
	callq	printf
	callq	clock
	movq	%rax, 16(%rsp)                  # 8-byte Spill
	movl	$.L.str.11, %edi
	xorl	%eax, %eax
	callq	printf
	callq	clock
	movq	%rax, %r15
	movslq	%ebp, %rbx
	movq	%rbx, %rdi
	imulq	%rbx, %rdi
	shlq	$2, %rdi
	callq	malloc
	movq	%rax, %r14
	callq	clock
	subq	%r15, %rax
	movabsq	$2361183241434822607, %r12      # imm = 0x20C49BA5E353F7CF
	imulq	%r12
	movq	%rdx, %rsi
	shrq	$63, %rsi
	shrq	$7, %rdx
	addl	%edx, %esi
	movl	$.L.str.9, %edi
                                        # kill: def $esi killed $esi killed $rsi
	xorl	%eax, %eax
	callq	printf
	callq	clock
	movq	%rax, %r15
	movl	$.L.str.12, %edi
	xorl	%eax, %eax
	callq	printf
	movq	%r13, %rdi
	movl	%ebx, %esi
	movq	8(%rsp), %rdx                   # 8-byte Reload
	movl	4(%rsp), %ecx                   # 4-byte Reload
	movq	%r14, %r8
	movl	%ebx, %r9d
	callq	_Z16multiplyMatrices12squareMatrixS_S_
	callq	clock
	subq	%r15, %rax
	imulq	%r12
	movq	%rdx, %rsi
	shrq	$63, %rsi
	shrq	$7, %rdx
	addl	%edx, %esi
	movl	$.L.str.9, %edi
                                        # kill: def $esi killed $esi killed $rsi
	xorl	%eax, %eax
	callq	printf
	cmpb	$0, startup+41(%rip)
	je	.LBB7_2
# %bb.1:
	movq	%r14, %rdi
	movl	%ebp, %esi
	callq	_Z17printSquareMatrix12squareMatrix
.LBB7_2:
	cmpb	$0, startup+40(%rip)
	je	.LBB7_4
# %bb.3:
	movl	$.L.str.13, %edi
	xorl	%eax, %eax
	callq	printf
	callq	clock
	movq	%rax, %rbx
	movl	$.L.str.14, %edx
	movq	%r14, %rdi
	movl	%ebp, %esi
	callq	_Z16saveMatrixToFile12squareMatrixPc
	callq	clock
	subq	%rbx, %rax
	imulq	%r12
	movq	%rdx, %rsi
	shrq	$63, %rsi
	shrq	$7, %rdx
	addl	%edx, %esi
	movl	$.L.str.9, %edi
                                        # kill: def $esi killed $esi killed $rsi
	xorl	%eax, %eax
	callq	printf
.LBB7_4:
	movl	$.L.str.15, %edi
	xorl	%eax, %eax
	callq	printf
	callq	clock
	movq	%rax, %rbx
	movq	%r14, %rdi
	callq	free
	callq	clock
	subq	%rbx, %rax
	imulq	%r12
	movq	%rdx, %rsi
	shrq	$63, %rsi
	shrq	$7, %rdx
	addl	%edx, %esi
	movl	$.L.str.9, %edi
                                        # kill: def $esi killed $esi killed $rsi
	xorl	%eax, %eax
	callq	printf
	movl	$.L.str.16, %edi
	xorl	%eax, %eax
	callq	printf
	callq	clock
	subq	16(%rsp), %rax                  # 8-byte Folded Reload
	imulq	%r12
	movq	%rdx, %rsi
	shrq	$63, %rsi
	shrq	$7, %rdx
	addl	%edx, %esi
	movl	$.L.str.9, %edi
                                        # kill: def $esi killed $esi killed $rsi
	xorl	%eax, %eax
	addq	$24, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	jmp	printf                          # TAILCALL
.Lfunc_end7:
	.size	_Z19testHostPreformance12squareMatrixS_, .Lfunc_end7-_Z19testHostPreformance12squareMatrixS_
	.cfi_endproc
                                        # -- End function
	.globl	_Z21testDevicePreformance12squareMatrixS_ # -- Begin function _Z21testDevicePreformance12squareMatrixS_
	.type	_Z21testDevicePreformance12squareMatrixS_,@function
_Z21testDevicePreformance12squareMatrixS_: # @_Z21testDevicePreformance12squareMatrixS_
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	%ecx, %ebx
	movq	%rdx, 40(%rsp)                  # 8-byte Spill
	movl	%esi, %ebp
	movq	%rdi, 48(%rsp)                  # 8-byte Spill
	movl	$.L.str.4, %edi
	movl	$.L.str.17, %r9d
	movl	%esi, %edx
	movl	%esi, %ecx
	movl	%esi, %r8d
	xorl	%eax, %eax
	callq	printf
	callq	clock
	movq	%rax, 32(%rsp)                  # 8-byte Spill
	cmpl	%ebx, %ebp
	jne	.LBB8_21
# %bb.1:
	movl	%ebp, %r12d
	imull	%r12d, %r12d
	leal	(,%r12,4), %r14d
	movl	$.L.str.18, %edi
	xorl	%eax, %eax
	callq	printf
	callq	clock
	movq	%rax, %rbx
	movslq	%r14d, %r15
	movq	%r15, %rdi
	callq	malloc
	movq	%rax, %r14
	callq	clock
	subq	%rbx, %rax
	movabsq	$2361183241434822607, %rcx      # imm = 0x20C49BA5E353F7CF
	imulq	%rcx
	movq	%rdx, %rsi
	shrq	$63, %rsi
	shrq	$7, %rdx
	addl	%edx, %esi
	movl	$.L.str.9, %edi
                                        # kill: def $esi killed $esi killed $rsi
	xorl	%eax, %eax
	callq	printf
	movl	$.L.str.19, %edi
	xorl	%eax, %eax
	callq	printf
	callq	clock
	movq	%rax, %r13
	leaq	24(%rsp), %rdi
	movq	%r15, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB8_2
# %bb.4:                                # %_Z9gpuAssert10hipError_tPKcib.exit
	leaq	16(%rsp), %rdi
	movq	%r15, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB8_5
# %bb.6:                                # %_Z9gpuAssert10hipError_tPKcib.exit42
	leaq	8(%rsp), %rdi
	movq	%r15, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB8_7
# %bb.8:                                # %_Z9gpuAssert10hipError_tPKcib.exit44
	callq	clock
	subq	%r13, %rax
	movabsq	$2361183241434822607, %rcx      # imm = 0x20C49BA5E353F7CF
	imulq	%rcx
	movq	%rdx, %rsi
	shrq	$63, %rsi
	shrq	$7, %rdx
	addl	%edx, %esi
	movl	$.L.str.9, %edi
                                        # kill: def $esi killed $esi killed $rsi
	xorl	%eax, %eax
	callq	printf
	movl	$.L.str.21, %edi
	xorl	%eax, %eax
	callq	printf
	callq	clock
	movq	%rax, %r13
	movq	24(%rsp), %rdi
	movq	48(%rsp), %rsi                  # 8-byte Reload
	movq	%r15, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB8_9
# %bb.10:                               # %_Z9gpuAssert10hipError_tPKcib.exit46
	movq	16(%rsp), %rdi
	movq	40(%rsp), %rsi                  # 8-byte Reload
	movq	%r15, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB8_11
# %bb.12:                               # %_Z9gpuAssert10hipError_tPKcib.exit48
	callq	clock
	subq	%r13, %rax
	movabsq	$2361183241434822607, %r13      # imm = 0x20C49BA5E353F7CF
	imulq	%r13
	movq	%rdx, %rsi
	shrq	$63, %rsi
	shrq	$7, %rdx
	addl	%edx, %esi
	movl	$.L.str.9, %edi
                                        # kill: def $esi killed $esi killed $rsi
	xorl	%eax, %eax
	callq	printf
	movl	$.L.str.22, %edi
	xorl	%eax, %eax
	callq	printf
	callq	clock
	movq	%rax, %rbx
	movl	startup+20(%rip), %ecx
	movl	%r12d, %eax
	xorl	%edx, %edx
	idivl	%ecx
                                        # kill: def $eax killed $eax def $rax
	leal	1(%rax), %edi
	btsq	$32, %rdi
	btsq	$32, %rcx
	movl	$1, %esi
	movq	%rcx, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB8_14
# %bb.13:
	movq	24(%rsp), %rdi
	movq	16(%rsp), %rsi
	movq	8(%rsp), %rdx
	movl	%ebp, %ecx
	callq	_Z39__device_stub__multiplyMatricesParallelPiS_S_i
.LBB8_14:
	callq	hipGetLastError
	testl	%eax, %eax
	jne	.LBB8_22
# %bb.15:                               # %_Z9gpuAssert10hipError_tPKcib.exit50
	movq	8(%rsp), %rsi
	movq	%r14, %rdi
	movq	%r15, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB8_23
# %bb.16:                               # %_Z9gpuAssert10hipError_tPKcib.exit52
	callq	clock
	subq	%rbx, %rax
	imulq	%r13
	movq	%rdx, %rsi
	shrq	$63, %rsi
	shrq	$7, %rdx
	addl	%edx, %esi
	movl	$.L.str.9, %edi
                                        # kill: def $esi killed $esi killed $rsi
	xorl	%eax, %eax
	callq	printf
	cmpb	$0, startup+41(%rip)
	je	.LBB8_18
# %bb.17:
	movq	%r14, %rdi
	movl	%ebp, %esi
	callq	_Z17printSquareMatrix12squareMatrix
.LBB8_18:
	cmpb	$0, startup+40(%rip)
	je	.LBB8_20
# %bb.19:
	movl	$.L.str.13, %edi
	xorl	%eax, %eax
	callq	printf
	callq	clock
	movq	%rax, %rbx
	movl	$.L.str.14, %edx
	movq	%r14, %rdi
	movl	%ebp, %esi
	callq	_Z16saveMatrixToFile12squareMatrixPc
	callq	clock
	subq	%rbx, %rax
	imulq	%r13
	movq	%rdx, %rsi
	shrq	$63, %rsi
	shrq	$7, %rdx
	addl	%edx, %esi
	movl	$.L.str.9, %edi
                                        # kill: def $esi killed $esi killed $rsi
	xorl	%eax, %eax
	callq	printf
.LBB8_20:
	movl	$.L.str.23, %edi
	xorl	%eax, %eax
	callq	printf
	callq	clock
	movq	%rax, %rbx
	movq	24(%rsp), %rdi
	callq	hipFree
	movq	16(%rsp), %rdi
	callq	hipFree
	movq	8(%rsp), %rdi
	callq	hipFree
	movq	%r14, %rdi
	callq	free
	callq	clock
	subq	%rbx, %rax
	imulq	%r13
	movq	%rdx, %rsi
	shrq	$63, %rsi
	shrq	$7, %rdx
	addl	%edx, %esi
	movl	$.L.str.9, %edi
                                        # kill: def $esi killed $esi killed $rsi
	xorl	%eax, %eax
	callq	printf
	movl	$.L.str.24, %edi
	xorl	%eax, %eax
	callq	printf
	callq	clock
	subq	32(%rsp), %rax                  # 8-byte Folded Reload
	imulq	%r13
	movq	%rdx, %rsi
	shrq	$63, %rsi
	shrq	$7, %rdx
	addl	%edx, %esi
	movl	$.L.str.9, %edi
                                        # kill: def $esi killed $esi killed $rsi
	xorl	%eax, %eax
	callq	printf
	addq	$56, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.LBB8_21:
	.cfi_def_cfa_offset 112
	movl	$1, %edi
	callq	exit
.LBB8_2:
	movl	%eax, %ebx
	movq	stderr(%rip), %r14
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.43, %esi
	movl	$.L.str.20, %ecx
	movq	%r14, %rdi
	movq	%rax, %rdx
	movl	$193, %r8d
	jmp	.LBB8_3
.LBB8_5:
	movl	%eax, %ebx
	movq	stderr(%rip), %r14
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.43, %esi
	movl	$.L.str.20, %ecx
	movq	%r14, %rdi
	movq	%rax, %rdx
	movl	$194, %r8d
	jmp	.LBB8_3
.LBB8_7:
	movl	%eax, %ebx
	movq	stderr(%rip), %r14
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.43, %esi
	movl	$.L.str.20, %ecx
	movq	%r14, %rdi
	movq	%rax, %rdx
	movl	$195, %r8d
	jmp	.LBB8_3
.LBB8_9:
	movl	%eax, %ebx
	movq	stderr(%rip), %r14
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.43, %esi
	movl	$.L.str.20, %ecx
	movq	%r14, %rdi
	movq	%rax, %rdx
	movl	$200, %r8d
	jmp	.LBB8_3
.LBB8_11:
	movl	%eax, %ebx
	movq	stderr(%rip), %r14
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.43, %esi
	movl	$.L.str.20, %ecx
	movq	%r14, %rdi
	movq	%rax, %rdx
	movl	$201, %r8d
.LBB8_3:
	xorl	%eax, %eax
	callq	fprintf
	movl	%ebx, %edi
	callq	exit
.LBB8_22:
	movl	%eax, %r12d
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.43, %esi
	movl	$.L.str.20, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$208, %r8d
	xorl	%eax, %eax
	callq	fprintf
	movl	%r12d, %edi
	callq	exit
.LBB8_23:
	movl	%eax, %r15d
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.43, %esi
	movl	$.L.str.20, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$209, %r8d
	xorl	%eax, %eax
	callq	fprintf
	movl	%r15d, %edi
	callq	exit
.Lfunc_end8:
	.size	_Z21testDevicePreformance12squareMatrixS_, .Lfunc_end8-_Z21testDevicePreformance12squareMatrixS_
	.cfi_endproc
                                        # -- End function
	.globl	_Z35testMatrixMultiplicationPreformancei # -- Begin function _Z35testMatrixMultiplicationPreformancei
	.type	_Z35testMatrixMultiplicationPreformancei,@function
_Z35testMatrixMultiplicationPreformancei: # @_Z35testMatrixMultiplicationPreformancei
	.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	%rbx
	.cfi_def_cfa_offset 40
	pushq	%rax
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	%edi, %r14d
	movl	startup+8(%rip), %edi
	callq	srand
	movl	%r14d, %edi
	callq	_Z24createRandomSquareMatrixi
	movq	%rax, %rbx
	movl	%edx, %ebp
	movl	%r14d, %edi
	callq	_Z24createRandomSquareMatrixi
	movq	%rax, %r14
	movl	%edx, %r15d
	cmpb	$0, startup+41(%rip)
	je	.LBB9_2
# %bb.1:
	movq	%rbx, %rdi
	movl	%ebp, %esi
	callq	_Z17printSquareMatrix12squareMatrix
	movq	%r14, %rdi
	movl	%r15d, %esi
	callq	_Z17printSquareMatrix12squareMatrix
.LBB9_2:
	cmpb	$0, startup+40(%rip)
	je	.LBB9_4
# %bb.3:
	movl	$.L.str.25, %edx
	movq	%rbx, %rdi
	movl	%ebp, %esi
	callq	_Z16saveMatrixToFile12squareMatrixPc
	movl	$.L.str.26, %edx
	movq	%r14, %rdi
	movl	%r15d, %esi
	callq	_Z16saveMatrixToFile12squareMatrixPc
.LBB9_4:
	cmpl	$2, startup(%rip)
	je	.LBB9_6
# %bb.5:
	movq	%rbx, %rdi
	movl	%ebp, %esi
	movq	%r14, %rdx
	movl	%r15d, %ecx
	callq	_Z21testDevicePreformance12squareMatrixS_
	cmpl	$1, startup(%rip)
	je	.LBB9_7
.LBB9_6:                                # %.thread
	movq	%rbx, %rdi
	movl	%ebp, %esi
	movq	%r14, %rdx
	movl	%r15d, %ecx
	callq	_Z19testHostPreformance12squareMatrixS_
.LBB9_7:
	movq	%rbx, %rdi
	callq	free
	movq	%r14, %rdi
	addq	$8, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	jmp	free                            # TAILCALL
.Lfunc_end9:
	.size	_Z35testMatrixMultiplicationPreformancei, .Lfunc_end9-_Z35testMatrixMultiplicationPreformancei
	.cfi_endproc
                                        # -- End function
	.globl	_Z13getFreeGpuMemv              # -- Begin function _Z13getFreeGpuMemv
	.type	_Z13getFreeGpuMemv,@function
_Z13getFreeGpuMemv:                     # @_Z13getFreeGpuMemv
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$16, %rsp
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -16
	leaq	8(%rsp), %rbx
	movq	%rbx, %rdi
	xorl	%esi, %esi
	callq	hipMemGetInfo
	movl	(%rbx), %eax
	addq	$16, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end10:
	.size	_Z13getFreeGpuMemv, .Lfunc_end10-_Z13getFreeGpuMemv
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z39calculateLargestPossibleMatrixDimensionv
.LCPI11_0:
	.quad	0xbff0000000000000              # double -1
	.text
	.globl	_Z39calculateLargestPossibleMatrixDimensionv
	.type	_Z39calculateLargestPossibleMatrixDimensionv,@function
_Z39calculateLargestPossibleMatrixDimensionv: # @_Z39calculateLargestPossibleMatrixDimensionv
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$16, %rsp
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -16
	leaq	8(%rsp), %rbx
	movq	%rbx, %rdi
	xorl	%esi, %esi
	callq	hipMemGetInfo
	movl	(%rbx), %eax
	movl	$2863311531, %ecx               # imm = 0xAAAAAAAB
	imulq	%rax, %rcx
	shrq	$35, %rcx
	cvtsi2sd	%ecx, %xmm0
	sqrtsd	%xmm0, %xmm0
	addsd	.LCPI11_0(%rip), %xmm0
	cvttsd2si	%xmm0, %rax
                                        # kill: def $eax killed $eax killed $rax
	addq	$16, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end11:
	.size	_Z39calculateLargestPossibleMatrixDimensionv, .Lfunc_end11-_Z39calculateLargestPossibleMatrixDimensionv
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI12_0:
	.quad	0xbff0000000000000              # double -1
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
	.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	$16, %rsp
	.cfi_def_cfa_offset 64
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	testl	%edi, %edi
	jle	.LBB12_38
# %bb.1:                                # %.lr.ph.preheader
	movq	%rsi, %rbx
	movl	%edi, %r12d
	xorl	%r13d, %r13d
.LBB12_2:                               # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movq	(%rbx,%r13,8), %r14
	movl	$.L.str.27, %esi
	movq	%r14, %rdi
	callq	strcmp
	testl	%eax, %eax
	je	.LBB12_46
# %bb.3:                                #   in Loop: Header=BB12_2 Depth=1
	movl	$.L.str.29, %esi
	movq	%r14, %rdi
	callq	strcmp
	testl	%eax, %eax
	jne	.LBB12_12
# %bb.4:                                #   in Loop: Header=BB12_2 Depth=1
	leaq	1(%r13), %rax
	cmpq	%r12, %rax
	jge	.LBB12_12
# %bb.5:                                #   in Loop: Header=BB12_2 Depth=1
	movq	8(%rbx,%r13,8), %r15
	movl	$.L.str.30, %esi
	movq	%r15, %rdi
	callq	strcmp
	testl	%eax, %eax
	je	.LBB12_6
# %bb.7:                                #   in Loop: Header=BB12_2 Depth=1
	movl	$.L.str.31, %esi
	movq	%r15, %rdi
	callq	strcmp
	testl	%eax, %eax
	je	.LBB12_8
# %bb.9:                                #   in Loop: Header=BB12_2 Depth=1
	movl	$.L.str.32, %esi
	movq	%r15, %rdi
	callq	strcmp
	testl	%eax, %eax
	jne	.LBB12_12
# %bb.10:                               #   in Loop: Header=BB12_2 Depth=1
	xorl	%eax, %eax
	jmp	.LBB12_11
.LBB12_6:                               #   in Loop: Header=BB12_2 Depth=1
	movl	$1, %eax
	jmp	.LBB12_11
.LBB12_8:                               #   in Loop: Header=BB12_2 Depth=1
	movl	$2, %eax
.LBB12_11:                              # %.sink.split
                                        #   in Loop: Header=BB12_2 Depth=1
	movl	%eax, startup(%rip)
.LBB12_12:                              #   in Loop: Header=BB12_2 Depth=1
	movl	$.L.str.33, %esi
	movq	%r14, %rdi
	callq	strcmp
	testl	%eax, %eax
	jne	.LBB12_15
# %bb.13:                               #   in Loop: Header=BB12_2 Depth=1
	leaq	1(%r13), %rax
	cmpq	%r12, %rax
	jge	.LBB12_15
# %bb.14:                               #   in Loop: Header=BB12_2 Depth=1
	movq	8(%rbx,%r13,8), %rdi
	callq	atoi
	movl	%eax, startup+4(%rip)
.LBB12_15:                              #   in Loop: Header=BB12_2 Depth=1
	movl	$.L.str.34, %esi
	movq	%r14, %rdi
	callq	strcmp
	testl	%eax, %eax
	jne	.LBB12_18
# %bb.16:                               #   in Loop: Header=BB12_2 Depth=1
	leaq	1(%r13), %rax
	cmpq	%r12, %rax
	jge	.LBB12_18
# %bb.17:                               #   in Loop: Header=BB12_2 Depth=1
	movq	8(%rbx,%r13,8), %rdi
	callq	atoi
	movl	%eax, startup+12(%rip)
.LBB12_18:                              #   in Loop: Header=BB12_2 Depth=1
	movl	$.L.str.35, %esi
	movq	%r14, %rdi
	callq	strcmp
	testl	%eax, %eax
	jne	.LBB12_21
# %bb.19:                               #   in Loop: Header=BB12_2 Depth=1
	leaq	1(%r13), %rax
	cmpq	%r12, %rax
	jge	.LBB12_21
# %bb.20:                               #   in Loop: Header=BB12_2 Depth=1
	movq	8(%rbx,%r13,8), %rdi
	callq	atoi
	movl	%eax, startup+8(%rip)
.LBB12_21:                              #   in Loop: Header=BB12_2 Depth=1
	movl	$.L.str.36, %esi
	movq	%r14, %rdi
	callq	strcmp
	testl	%eax, %eax
	jne	.LBB12_24
# %bb.22:                               #   in Loop: Header=BB12_2 Depth=1
	leaq	1(%r13), %rax
	cmpq	%r12, %rax
	jge	.LBB12_24
# %bb.23:                               #   in Loop: Header=BB12_2 Depth=1
	movq	8(%rbx,%r13,8), %rdi
	callq	atoi
	movl	%eax, startup+16(%rip)
.LBB12_24:                              #   in Loop: Header=BB12_2 Depth=1
	movl	$.L.str.37, %esi
	movq	%r14, %rdi
	callq	strcmp
	testl	%eax, %eax
	jne	.LBB12_27
# %bb.25:                               #   in Loop: Header=BB12_2 Depth=1
	leaq	1(%r13), %rax
	cmpq	%r12, %rax
	jge	.LBB12_27
# %bb.26:                               #   in Loop: Header=BB12_2 Depth=1
	movq	8(%rbx,%r13,8), %rdi
	callq	atoi
	movl	%eax, startup+24(%rip)
.LBB12_27:                              #   in Loop: Header=BB12_2 Depth=1
	movl	$.L.str.38, %esi
	movq	%r14, %rdi
	callq	strcmp
	testl	%eax, %eax
	jne	.LBB12_30
# %bb.28:                               #   in Loop: Header=BB12_2 Depth=1
	leaq	1(%r13), %rax
	cmpq	%r12, %rax
	jge	.LBB12_30
# %bb.29:                               #   in Loop: Header=BB12_2 Depth=1
	movq	8(%rbx,%r13,8), %rdi
	callq	atoi
	movl	%eax, startup+20(%rip)
.LBB12_30:                              #   in Loop: Header=BB12_2 Depth=1
	movl	$.L.str.39, %esi
	movq	%r14, %rdi
	callq	strcmp
	testl	%eax, %eax
	jne	.LBB12_32
# %bb.31:                               #   in Loop: Header=BB12_2 Depth=1
	movb	$1, startup+41(%rip)
.LBB12_32:                              #   in Loop: Header=BB12_2 Depth=1
	movl	$.L.str.40, %esi
	movq	%r14, %rdi
	callq	strcmp
	testl	%eax, %eax
	je	.LBB12_34
# %bb.33:                               # %._crit_edge86
                                        #   in Loop: Header=BB12_2 Depth=1
	incq	%r13
	movq	%r13, %r15
	jmp	.LBB12_37
.LBB12_34:                              #   in Loop: Header=BB12_2 Depth=1
	movb	$1, startup+40(%rip)
	leaq	1(%r13), %r15
	cmpq	%r12, %r15
	jge	.LBB12_37
# %bb.35:                               #   in Loop: Header=BB12_2 Depth=1
	movq	8(%rbx,%r13,8), %r14
	movl	$.L.str.41, %esi
	movq	%r14, %rdi
	callq	strstr
	testq	%rax, %rax
	jne	.LBB12_37
# %bb.36:                               #   in Loop: Header=BB12_2 Depth=1
	movq	%r14, startup+32(%rip)
.LBB12_37:                              #   in Loop: Header=BB12_2 Depth=1
	movq	%r15, %r13
	cmpq	%r12, %r15
	jne	.LBB12_2
.LBB12_38:                              # %._crit_edge
	movl	startup+24(%rip), %edi
	testl	%edi, %edi
	je	.LBB12_40
# %bb.39:
	callq	_Z35testMatrixMultiplicationPreformancei
.LBB12_45:                              # %.loopexit
	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	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.LBB12_40:
	.cfi_def_cfa_offset 64
	leaq	8(%rsp), %rbx
	movq	%rbx, %rdi
	xorl	%esi, %esi
	callq	hipMemGetInfo
	movl	(%rbx), %eax
	movl	$2863311531, %ecx               # imm = 0xAAAAAAAB
	imulq	%rax, %rcx
	shrq	$35, %rcx
	cvtsi2sd	%ecx, %xmm0
	sqrtsd	%xmm0, %xmm0
	addsd	.LCPI12_0(%rip), %xmm0
	cvttsd2si	%xmm0, %rax
	movl	startup+16(%rip), %ebx
	addl	%eax, %eax
	cmpl	%eax, %ebx
	je	.LBB12_45
# %bb.41:
	cmpl	startup+12(%rip), %ebx
	jg	.LBB12_45
# %bb.42:                               # %.lr.ph84.preheader
	leaq	8(%rsp), %r14
	movl	$2863311531, %r15d              # imm = 0xAAAAAAAB
.LBB12_43:                              # %.lr.ph84
                                        # =>This Inner Loop Header: Depth=1
	movq	%r14, %rdi
	xorl	%esi, %esi
	callq	hipMemGetInfo
	movl	8(%rsp), %eax
	imulq	%r15, %rax
	shrq	$35, %rax
	xorps	%xmm0, %xmm0
	cvtsi2sd	%eax, %xmm0
	sqrtsd	%xmm0, %xmm0
	addsd	.LCPI12_0(%rip), %xmm0
	cvttsd2si	%xmm0, %r12
	cmpl	%r12d, %ebx
	cmovael	%r12d, %ebx
	movl	%ebx, %edi
	callq	_Z35testMatrixMultiplicationPreformancei
	addl	%ebx, %ebx
	addl	%r12d, %r12d
	cmpl	%r12d, %ebx
	je	.LBB12_45
# %bb.44:                               # %.lr.ph84
                                        #   in Loop: Header=BB12_43 Depth=1
	cmpl	startup+12(%rip), %ebx
	jle	.LBB12_43
	jmp	.LBB12_45
.LBB12_46:
	movq	help(%rip), %rsi
	movl	$.L.str.28, %edi
	xorl	%eax, %eax
	callq	printf
	movl	$-1, %edi
	callq	exit
.Lfunc_end12:
	.size	main, .Lfunc_end12-main
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0                          # -- Begin function _GLOBAL__sub_I_MatrixMultiplication.hip
.LCPI13_0:
	.long	2147483647                      # 0x7fffffff
	.long	2                               # 0x2
	.long	256                             # 0x100
	.long	0                               # 0x0
	.section	.text.startup,"ax",@progbits
	.type	_GLOBAL__sub_I_MatrixMultiplication.hip,@function
_GLOBAL__sub_I_MatrixMultiplication.hip: # @_GLOBAL__sub_I_MatrixMultiplication.hip
	.cfi_startproc
# %bb.0:
	pushq	%rax
	.cfi_def_cfa_offset 16
	movabsq	$8589934593, %rax               # imm = 0x200000001
	movq	%rax, startup(%rip)
	xorl	%edi, %edi
	callq	time
	movl	%eax, startup+8(%rip)
	movaps	.LCPI13_0(%rip), %xmm0          # xmm0 = [2147483647,2,256,0]
	movups	%xmm0, startup+12(%rip)
	movq	$.L.str.42, startup+32(%rip)
	movw	$0, startup+40(%rip)
	popq	%rax
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end13:
	.size	_GLOBAL__sub_I_MatrixMultiplication.hip, .Lfunc_end13-_GLOBAL__sub_I_MatrixMultiplication.hip
	.cfi_endproc
                                        # -- End function
	.text
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	jne	.LBB14_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB14_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z24multiplyMatricesParallelPiS_S_i, %esi
	movl	$.L__unnamed_1, %edx
	movl	$.L__unnamed_1, %ecx
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$__hip_module_dtor, %edi
	addq	$40, %rsp
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_end14:
	.size	__hip_module_ctor, .Lfunc_end14-__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	.LBB15_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
.LBB15_2:
	retq
.Lfunc_end15:
	.size	__hip_module_dtor, .Lfunc_end15-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	startup,@object                 # @startup
	.bss
	.globl	startup
	.p2align	3, 0x0
startup:
	.zero	48
	.size	startup, 48

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"\n Shows what parameters are available\n\t--help\n\n Selects which device should be used:\n\t--device cpu\n\t--device gpu\n\t--device both\n\n sets seedvalue for random number generation (default: currentTime)\n\t--seed [int]\n\n sets mod value for random number generation (default: 2)\n\t--random_mod [int]\n\n sets max dimension to compute (default: max matrix that can fit in vram)\n\t--max_dimension [int]\n\n sets starting matrix dimension (default: 2)\n\t--start_dimension [int]\n\n only computes a single matrix of n size.\n\t--only [int]\n\n sets the number of threads per block (default: 256). Should be a multiple of cuda cores\n\t--block_threads [int 1-1024]\n\n outputs matrix a, b and result. (not recommended for extremely large matrices)\n\t--mat_print                    (prints to the console)\n\t--mat_save [filepath]          (saves to disk. filepath optional)\n\n"
	.size	.L.str, 842

	.type	help,@object                    # @help
	.data
	.globl	help
	.p2align	3, 0x0
help:
	.quad	.L.str
	.size	help, 8

	.type	.L.str.2,@object                # @.str.2
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.2:
	.asciz	"%d "
	.size	.L.str.2, 4

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

	.type	.L.str.4,@object                # @.str.4
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.4:
	.asciz	"--------------------------------------------------------------------------------------------\nMultiplying %dx%d X %dx%d using the %s ...\n\n"
	.size	.L.str.4, 138

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"%d"
	.size	.L.str.5, 3

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"%s/%sx%s_X_%sx%s_%s.txt"
	.size	.L.str.6, 24

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

	.type	.L.str.9,@object                # @.str.9
.L.str.9:
	.asciz	"Done in %d msec!\n"
	.size	.L.str.9, 18

	.type	.L.str.10,@object               # @.str.10
.L.str.10:
	.asciz	"CPU"
	.size	.L.str.10, 4

	.type	.L.str.11,@object               # @.str.11
.L.str.11:
	.asciz	"\tAllocating Result Matrix To Ram...               "
	.size	.L.str.11, 51

	.type	.L.str.12,@object               # @.str.12
.L.str.12:
	.asciz	"\tPreforming Multiplication...                     "
	.size	.L.str.12, 51

	.type	.L.str.13,@object               # @.str.13
.L.str.13:
	.asciz	"\tSaving Result Matrix to Disk...                  "
	.size	.L.str.13, 51

	.type	.L.str.14,@object               # @.str.14
.L.str.14:
	.asciz	"matrix_result"
	.size	.L.str.14, 14

	.type	.L.str.15,@object               # @.str.15
.L.str.15:
	.asciz	"\tDeallocating Result Matrix From Ram...           "
	.size	.L.str.15, 51

	.type	.L.str.16,@object               # @.str.16
.L.str.16:
	.asciz	"\nTotal Time:                                      "
	.size	.L.str.16, 51

	.type	.L.str.17,@object               # @.str.17
.L.str.17:
	.asciz	"GPU"
	.size	.L.str.17, 4

	.type	.L.str.18,@object               # @.str.18
.L.str.18:
	.asciz	"\tAllocating Result Matrix To RAM...               "
	.size	.L.str.18, 51

	.type	.L.str.19,@object               # @.str.19
.L.str.19:
	.asciz	"\tAllocating A, B, and RESULT Matrix To VRAM...    "
	.size	.L.str.19, 51

	.type	.L.str.20,@object               # @.str.20
.L.str.20:
	.asciz	"/home/ubuntu/Datasets/stackv2/train-structured-repos-hip-sm89/MaxKotlan/Cuda-Matrix-Multiplication-Benchmark/master/MatrixMultiplication.hip"
	.size	.L.str.20, 141

	.type	.L.str.21,@object               # @.str.21
.L.str.21:
	.asciz	"\tCopying A, B To VRAM...                          "
	.size	.L.str.21, 51

	.type	.L.str.22,@object               # @.str.22
.L.str.22:
	.asciz	"\tComputing and Copying Result...                  "
	.size	.L.str.22, 51

	.type	.L.str.23,@object               # @.str.23
.L.str.23:
	.asciz	"\tDeallocating Result Matrix...                    "
	.size	.L.str.23, 51

	.type	.L.str.24,@object               # @.str.24
.L.str.24:
	.asciz	"\nTotal Time: "
	.size	.L.str.24, 14

	.type	.L.str.25,@object               # @.str.25
.L.str.25:
	.asciz	"matrix_A"
	.size	.L.str.25, 9

	.type	.L.str.26,@object               # @.str.26
.L.str.26:
	.asciz	"matrix_B"
	.size	.L.str.26, 9

	.type	.L.str.27,@object               # @.str.27
.L.str.27:
	.asciz	"--help"
	.size	.L.str.27, 7

	.type	.L.str.28,@object               # @.str.28
.L.str.28:
	.asciz	"%s"
	.size	.L.str.28, 3

	.type	.L.str.29,@object               # @.str.29
.L.str.29:
	.asciz	"--device"
	.size	.L.str.29, 9

	.type	.L.str.30,@object               # @.str.30
.L.str.30:
	.asciz	"gpu"
	.size	.L.str.30, 4

	.type	.L.str.31,@object               # @.str.31
.L.str.31:
	.asciz	"cpu"
	.size	.L.str.31, 4

	.type	.L.str.32,@object               # @.str.32
.L.str.32:
	.asciz	"both"
	.size	.L.str.32, 5

	.type	.L.str.33,@object               # @.str.33
.L.str.33:
	.asciz	"--random_mod"
	.size	.L.str.33, 13

	.type	.L.str.34,@object               # @.str.34
.L.str.34:
	.asciz	"--max_dimension"
	.size	.L.str.34, 16

	.type	.L.str.35,@object               # @.str.35
.L.str.35:
	.asciz	"--seed"
	.size	.L.str.35, 7

	.type	.L.str.36,@object               # @.str.36
.L.str.36:
	.asciz	"--start_dimension"
	.size	.L.str.36, 18

	.type	.L.str.37,@object               # @.str.37
.L.str.37:
	.asciz	"--only"
	.size	.L.str.37, 7

	.type	.L.str.38,@object               # @.str.38
.L.str.38:
	.asciz	"--block_threads"
	.size	.L.str.38, 16

	.type	.L.str.39,@object               # @.str.39
.L.str.39:
	.asciz	"--mat_print"
	.size	.L.str.39, 12

	.type	.L.str.40,@object               # @.str.40
.L.str.40:
	.asciz	"--mat_save"
	.size	.L.str.40, 11

	.type	.L.str.41,@object               # @.str.41
.L.str.41:
	.asciz	"--"
	.size	.L.str.41, 3

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

	.type	.L.str.43,@object               # @.str.43
.L.str.43:
	.asciz	"GPUassert: %s %s %d\n"
	.size	.L.str.43, 21

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z24multiplyMatricesParallelPiS_S_i"
	.size	.L__unnamed_1, 36

	.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	_GLOBAL__sub_I_MatrixMultiplication.hip
	.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	"\n"
	.size	.Lstr, 2

	.type	.Lstr.1,@object                 # @str.1
.Lstr.1:
	.asciz	"Could not log to file"
	.size	.Lstr.1, 22

	.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 _Z39__device_stub__multiplyMatricesParallelPiS_S_i
	.addrsig_sym _GLOBAL__sub_I_MatrixMultiplication.hip
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z24multiplyMatricesParallelPiS_S_i
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z24multiplyMatricesParallelPiS_S_i ; -- Begin function _Z24multiplyMatricesParallelPiS_S_i
	.globl	_Z24multiplyMatricesParallelPiS_S_i
	.p2align	8
	.type	_Z24multiplyMatricesParallelPiS_S_i,@function
_Z24multiplyMatricesParallelPiS_S_i:    ; @_Z24multiplyMatricesParallelPiS_S_i
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x2c
	s_load_b32 s4, s[0:1], 0x18
	s_waitcnt lgkmcnt(0)
	s_and_b32 s2, s2, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	s_mul_i32 s15, s15, s2
	s_mul_i32 s2, s4, s4
	v_add_nc_u32_e32 v4, s15, v0
	v_cmp_gt_i32_e32 vcc_lo, s2, v4
	s_and_saveexec_b32 s2, vcc_lo
	s_cbranch_execz .LBB0_4
; %bb.1:
	s_load_b64 s[2:3], s[0:1], 0x10
	v_ashrrev_i32_e32 v5, 31, v4
	v_mov_b32_e32 v3, 0
	s_cmp_lt_i32 s4, 1
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[1:2], 2, v[4:5]
	s_waitcnt lgkmcnt(0)
	v_add_co_u32 v1, vcc_lo, s2, v1
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v2, vcc_lo, s3, v2, vcc_lo
	global_store_b32 v[1:2], v3, off
	s_cbranch_scc1 .LBB0_4
; %bb.2:                                ; %.lr.ph
	s_ashr_i32 s2, s4, 31
	v_add_nc_u32_e32 v4, v4, v5
	s_add_i32 s3, s4, s2
	v_add3_u32 v0, v0, v5, s15
	s_xor_b32 s5, s3, s2
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	v_xor_b32_e32 v4, v4, v5
	v_cvt_f32_u32_e32 v6, s5
	s_sub_i32 s2, 0, s5
	v_rcp_iflag_f32_e32 v6, v6
	s_waitcnt_depctr 0xfff
	v_mul_f32_e32 v6, 0x4f7ffffe, v6
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cvt_u32_f32_e32 v6, v6
	v_mul_lo_u32 v7, s2, v6
	s_load_b128 s[0:3], s[0:1], 0x0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_hi_u32 v7, v6, v7
	v_add_nc_u32_e32 v6, v6, v7
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_hi_u32 v6, v4, v6
	v_mul_lo_u32 v6, v6, s5
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_sub_nc_u32_e32 v4, v4, v6
	v_subrev_nc_u32_e32 v6, s5, v4
	v_cmp_le_u32_e32 vcc_lo, s5, v4
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cndmask_b32_e32 v4, v4, v6, vcc_lo
	v_subrev_nc_u32_e32 v6, s5, v4
	v_cmp_le_u32_e32 vcc_lo, s5, v4
	s_mov_b32 s5, 0
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cndmask_b32_e32 v4, v4, v6, vcc_lo
	v_xor_b32_e32 v6, v4, v5
	s_delay_alu instid0(VALU_DEP_1)
	v_sub_nc_u32_e32 v4, v6, v5
	v_sub_nc_u32_e32 v0, v0, v6
.LBB0_3:                                ; =>This Inner Loop Header: Depth=1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_nc_u32_e32 v6, s5, v0
	v_ashrrev_i32_e32 v5, 31, v4
	s_add_i32 s5, s5, 1
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	s_cmp_lg_u32 s4, s5
	v_ashrrev_i32_e32 v7, 31, v6
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_lshlrev_b64 v[8:9], 2, v[4:5]
	v_lshlrev_b64 v[5:6], 2, v[6:7]
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_co_u32 v7, vcc_lo, s2, v8
	v_add_co_ci_u32_e32 v8, vcc_lo, s3, v9, vcc_lo
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_4)
	v_add_co_u32 v5, vcc_lo, s0, v5
	v_add_co_ci_u32_e32 v6, vcc_lo, s1, v6, vcc_lo
	global_load_b32 v7, v[7:8], off
	global_load_b32 v8, v[5:6], off
	s_waitcnt vmcnt(0)
	v_mad_u64_u32 v[5:6], null, v7, v8, v[3:4]
	s_delay_alu instid0(VALU_DEP_1)
	v_dual_mov_b32 v3, v5 :: v_dual_add_nc_u32 v4, s4, v4
	global_store_b32 v[1:2], v5, off
	s_cbranch_scc1 .LBB0_3
.LBB0_4:                                ; %.loopexit
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z24multiplyMatricesParallelPiS_S_i
		.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 10
		.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	_Z24multiplyMatricesParallelPiS_S_i, .Lfunc_end0-_Z24multiplyMatricesParallelPiS_S_i
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 448
; NumSgprs: 18
; NumVgprs: 10
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 10
; 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
      - .address_space:  global
        .offset:         16
        .size:           8
        .value_kind:     global_buffer
      - .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:           _Z24multiplyMatricesParallelPiS_S_i
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z24multiplyMatricesParallelPiS_S_i.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     10
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
