//
//  fast_transpose.cu
//
//
//  Created by Laura Balasso on 13/05/2019.
//

#include <stdio.h>
#include <stdlib.h>

#define TILE_DIM 32

/* function that fills an array with random doubles */

void random_doubles(double *p, int n) {
    int i;
    for(i=0; i<n; i++) {
        p[i]= ( (double)rand() * 100 ) / (double)RAND_MAX ;
    }
}


/* function that tests the equality between two martices */

void equality_test(double* M1, double* M2, int N){
    long int i;
    for(i=0; i<N*N; i++){
        if(M1[i]!=M2[i]){
            printf("Error! the two methods produce different results. \n"\
);
            break;
        }
    }
    if(i == N*N) printf("Correct result! \n");
}


/* kernel that implements the fast transpose */

__global__ void fast_transpose(double * M_in , double * M_out, int block_rows){

    __shared__ double tile[TILE_DIM][TILE_DIM]; // allocate the tile in shared memory (one per block)

    int x = blockIdx.x * TILE_DIM + threadIdx.x; // define index
    int y = blockIdx.y * TILE_DIM + threadIdx.y;
    int width = gridDim.x * TILE_DIM; // compute matrix width

    /* each block of threads copies a TILE_DIM x TILE_DIM submatrix in the tile */
    /* some threads handle more than one element since THREADS_PER_BLOCK < TILE_DIM*TILE_DIM */

    for (int j = 0; j < TILE_DIM; j += block_rows){
        tile[threadIdx.y+j][threadIdx.x] = M_in[(y+j) * width + x];
    }
    __syncthreads(); // ensures that all the threads copied the values in the tile

    x = blockIdx.y * TILE_DIM + threadIdx.x;
    y = blockIdx.x * TILE_DIM + threadIdx.y;

    for (int j = 0; j < TILE_DIM; j += block_rows){
        M_out[(y+j)*width + x] = tile[threadIdx.x][threadIdx.y + j];
    }
}

/* kernel that implements a naive algorithm for matrix transpose */

__global__ void naive_transpose(double * M_in, double * M_out, int block_rows)
{
    int x = blockIdx.x * TILE_DIM + threadIdx.x;
    int y = blockIdx.y * TILE_DIM + threadIdx.y;
    int width = gridDim.x * TILE_DIM;

    for (int j = 0; j < TILE_DIM; j+= block_rows){
        M_out[x*width + (y+j)] = M_in[(y+j)*width + x];
    }
}

/* function that runs both the naive and the blocking kernels for a given number of threads per block and matrix size */

void run_kernel(int threads_per_block, int dimx, int dimy){


    /* allocate host matrices */
    int num_bytes = dimx*dimy*sizeof(double);
    double *h_in = (double*)malloc(num_bytes);
    double *h_out_block = (double*)malloc(num_bytes);
    double *h_out_naive = (double*)malloc(num_bytes);

    /* allocate davice matrices */
    double *d_in, *d_out_block, *d_out_naive ;
    cudaMalloc(&d_in, num_bytes);
    cudaMalloc(&d_out_block, num_bytes);
    cudaMalloc(&d_out_naive, num_bytes);
    
    /* fill input matrix with random floats  */
    random_doubles(h_in , dimx*dimy);

    /* copy matrices in device memory */
    cudaMemcpy( d_in, h_in, num_bytes, cudaMemcpyHostToDevice );
    cudaMemcpy( d_out_block, h_out_block, num_bytes, cudaMemcpyHostToDevice );
    cudaMemcpy( d_out_naive, h_out_naive, num_bytes, cudaMemcpyHostToDevice );


    /* set threads and blocks grids */
    int block_rows = threads_per_block/TILE_DIM;
    dim3 grid, block;
    block.x = TILE_DIM;
    block.y = block_rows;
    grid.x = dimx/TILE_DIM;
    grid.y = dimy/TILE_DIM;

    /* cuda events for timing */
    cudaEvent_t start, stop;
    cudaEventCreate(&start);
    cudaEventCreate(&stop);

    cudaEventRecord(start);

    /* run blocking transpose kernel */
    fast_transpose<<< grid, block >>>(d_in, d_out_block, block_rows);

    cudaEventRecord(stop);
    cudaEventSynchronize(stop);
    float ms = 0;
    cudaEventElapsedTime(&ms, start, stop);
    float bw = 2 * dimx * dimy * sizeof(double) * 1e-6 / ms;
    printf("Fast transpose: \t %lf  \t  %lf \n", ms, bw);

    /* copy the result */
    cudaMemcpy( h_out_block, d_out_block, num_bytes, cudaMemcpyDeviceToHost );

    cudaEventRecord(start);

    /* run naive transpose kernel */
    naive_transpose<<< grid, block >>>(d_in, d_out_naive, block_rows) ;

    cudaEventRecord(stop);
    cudaEventSynchronize(stop);
    float ms_naive = 0;
    cudaEventElapsedTime(&ms_naive, start, stop);
    float bw_naive = 2 * dimx*dimy * sizeof(double) * 1e-6 / ms_naive;
    printf("Naive transpose: \t %lf  \t  %lf \n", ms_naive, bw_naive);

    /* copy result */
    cudaMemcpy( h_out_naive, d_out_naive, num_bytes, cudaMemcpyDeviceToHost) ;

    equality_test(h_out_naive, h_out_block, dimx);
    
    printf("\n ");

    /* deallocate memory */
    free(h_in); free(h_out_naive); free(h_out_block);
    cudaFree(d_in);
    cudaFree(d_out_naive);
    cudaFree(d_out_block);

    cudaEventDestroy(start);
    cudaEventDestroy(stop);

}


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

    int dimx = 8192;
    int dimy = 8192;

    printf(" \t \t \t GPU TIME (ms)     BANDWIDTH (GB/s) ");
    printf("\n\n");
    
    printf("64 threads per block: \n");
    run_kernel(64, dimx, dimy);

    printf("512 threads per block:\n");
    run_kernel(512, dimx, dimy);

    printf("1024 threads per block:\n");
    run_kernel(1024, dimx, dimy);


    return 0;

}











	.file	"tmpxft_003aae25_00000000-6_fast_transpose.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2033:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2033:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z14random_doublesPdi
	.type	_Z14random_doublesPdi, @function
_Z14random_doublesPdi:
.LFB2027:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movq	%rdi, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movl	%esi, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	xorl	%ebx, %ebx
.L3:
	cmpl	%ebx, %ebp
	jle	.L7
	call	rand@PLT
	cvtsi2sdl	%eax, %xmm0
	mulsd	.LC0(%rip), %xmm0
	divsd	.LC1(%rip), %xmm0
	movsd	%xmm0, (%r12,%rbx,8)
	incq	%rbx
	jmp	.L3
.L7:
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2027:
	.size	_Z14random_doublesPdi, .-_Z14random_doublesPdi
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC2:
	.string	"Error! the two methods produce different results. \n"
.LC3:
	.string	"Correct result! \n"
	.text
	.globl	_Z13equality_testPdS_i
	.type	_Z13equality_testPdS_i, @function
_Z13equality_testPdS_i:
.LFB2028:
	.cfi_startproc
	endbr64
	imull	%edx, %edx
	xorl	%eax, %eax
	movslq	%edx, %rdx
.L9:
	cmpq	%rax, %rdx
	jle	.L16
	movsd	(%rdi,%rax,8), %xmm0
	ucomisd	(%rsi,%rax,8), %xmm0
	jp	.L14
	je	.L10
.L14:
	leaq	.LC2(%rip), %rsi
	jmp	.L15
.L10:
	incq	%rax
	jmp	.L9
.L16:
	jne	.L8
	leaq	.LC3(%rip), %rsi
.L15:
	movl	$2, %edi
	xorl	%eax, %eax
	jmp	__printf_chk@PLT
.L8:
	ret
	.cfi_endproc
.LFE2028:
	.size	_Z13equality_testPdS_i, .-_Z13equality_testPdS_i
	.globl	_Z37__device_stub__Z14fast_transposePdS_iPdS_i
	.type	_Z37__device_stub__Z14fast_transposePdS_iPdS_i, @function
_Z37__device_stub__Z14fast_transposePdS_iPdS_i:
.LFB2055:
	.cfi_startproc
	endbr64
	subq	$136, %rsp
	.cfi_def_cfa_offset 144
	movq	%rdi, 24(%rsp)
	leaq	40(%rsp), %rcx
	leaq	48(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	60(%rsp), %rsi
	movl	%edx, 12(%rsp)
	leaq	32(%rsp), %rdx
	movq	%fs:40, %rax
	movq	%rax, 120(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 56(%rsp)
	movq	%rax, 96(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 104(%rsp)
	leaq	12(%rsp), %rax
	movq	%rax, 112(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 48(%rsp)
	movq	%rax, 60(%rsp)
	movl	$1, 68(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L17
	pushq	40(%rsp)
	.cfi_def_cfa_offset 152
	leaq	_Z14fast_transposePdS_i(%rip), %rdi
	pushq	40(%rsp)
	.cfi_def_cfa_offset 160
	movq	76(%rsp), %rcx
	movl	84(%rsp), %r8d
	movq	64(%rsp), %rsi
	movl	72(%rsp), %edx
	leaq	112(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 152
	popq	%rdx
	.cfi_def_cfa_offset 144
.L17:
	movq	120(%rsp), %rax
	subq	%fs:40, %rax
	je	.L19
	call	__stack_chk_fail@PLT
.L19:
	addq	$136, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2055:
	.size	_Z37__device_stub__Z14fast_transposePdS_iPdS_i, .-_Z37__device_stub__Z14fast_transposePdS_iPdS_i
	.globl	_Z14fast_transposePdS_i
	.type	_Z14fast_transposePdS_i, @function
_Z14fast_transposePdS_i:
.LFB2056:
	.cfi_startproc
	endbr64
	jmp	_Z37__device_stub__Z14fast_transposePdS_iPdS_i
	.cfi_endproc
.LFE2056:
	.size	_Z14fast_transposePdS_i, .-_Z14fast_transposePdS_i
	.globl	_Z38__device_stub__Z15naive_transposePdS_iPdS_i
	.type	_Z38__device_stub__Z15naive_transposePdS_iPdS_i, @function
_Z38__device_stub__Z15naive_transposePdS_iPdS_i:
.LFB2057:
	.cfi_startproc
	endbr64
	subq	$136, %rsp
	.cfi_def_cfa_offset 144
	movq	%rdi, 24(%rsp)
	leaq	40(%rsp), %rcx
	leaq	48(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	60(%rsp), %rsi
	movl	%edx, 12(%rsp)
	leaq	32(%rsp), %rdx
	movq	%fs:40, %rax
	movq	%rax, 120(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 56(%rsp)
	movq	%rax, 96(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 104(%rsp)
	leaq	12(%rsp), %rax
	movq	%rax, 112(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 48(%rsp)
	movq	%rax, 60(%rsp)
	movl	$1, 68(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L22
	pushq	40(%rsp)
	.cfi_def_cfa_offset 152
	leaq	_Z15naive_transposePdS_i(%rip), %rdi
	pushq	40(%rsp)
	.cfi_def_cfa_offset 160
	movq	76(%rsp), %rcx
	movl	84(%rsp), %r8d
	movq	64(%rsp), %rsi
	movl	72(%rsp), %edx
	leaq	112(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 152
	popq	%rdx
	.cfi_def_cfa_offset 144
.L22:
	movq	120(%rsp), %rax
	subq	%fs:40, %rax
	je	.L24
	call	__stack_chk_fail@PLT
.L24:
	addq	$136, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2057:
	.size	_Z38__device_stub__Z15naive_transposePdS_iPdS_i, .-_Z38__device_stub__Z15naive_transposePdS_iPdS_i
	.globl	_Z15naive_transposePdS_i
	.type	_Z15naive_transposePdS_i, @function
_Z15naive_transposePdS_i:
.LFB2058:
	.cfi_startproc
	endbr64
	jmp	_Z38__device_stub__Z15naive_transposePdS_iPdS_i
	.cfi_endproc
.LFE2058:
	.size	_Z15naive_transposePdS_i, .-_Z15naive_transposePdS_i
	.section	.rodata.str1.1
.LC6:
	.string	"Fast transpose: \t %lf  \t  %lf \n"
.LC7:
	.string	"Naive transpose: \t %lf  \t  %lf \n"
.LC8:
	.string	"\n "
	.text
	.globl	_Z10run_kerneliii
	.type	_Z10run_kerneliii, @function
_Z10run_kerneliii:
.LFB2029:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movl	%esi, %r14d
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movl	%edx, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movl	%edi, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movl	%esi, %ebp
	imull	%edx, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leal	0(,%rbp,8), %ebx
	subq	$104, %rsp
	.cfi_def_cfa_offset 160
	movq	%fs:40, %rax
	movq	%rax, 88(%rsp)
	xorl	%eax, %eax
	movslq	%ebx, %rbx
	movq	%rbx, %rdi
	call	malloc@PLT
	movq	%rbx, %rdi
	movq	%rax, %r15
	call	malloc@PLT
	movq	%rbx, %rdi
	movq	%rax, (%rsp)
	call	malloc@PLT
	leaq	24(%rsp), %rdi
	movq	%rbx, %rsi
	movq	%rax, 8(%rsp)
	call	cudaMalloc@PLT
	leaq	32(%rsp), %rdi
	movq	%rbx, %rsi
	call	cudaMalloc@PLT
	leaq	40(%rsp), %rdi
	movq	%rbx, %rsi
	call	cudaMalloc@PLT
	movl	%ebp, %esi
	movq	%r15, %rdi
	call	_Z14random_doublesPdi
	movq	24(%rsp), %rdi
	movq	%rbx, %rdx
	movq	%r15, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movq	(%rsp), %rsi
	movq	32(%rsp), %rdi
	movq	%rbx, %rdx
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movq	8(%rsp), %rsi
	movq	40(%rsp), %rdi
	movq	%rbx, %rdx
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movl	%r12d, %eax
	movl	$32, %ecx
	leaq	48(%rsp), %rdi
	cltd
	movl	$1, 72(%rsp)
	idivl	%ecx
	movl	$1, 84(%rsp)
	movl	$32, 76(%rsp)
	movl	%eax, 80(%rsp)
	movl	%eax, %r12d
	movl	%r14d, %eax
	cltd
	idivl	%ecx
	movl	%eax, 64(%rsp)
	movl	%r13d, %eax
	cltd
	idivl	%ecx
	movl	%eax, 68(%rsp)
	call	cudaEventCreate@PLT
	leaq	56(%rsp), %rdi
	call	cudaEventCreate@PLT
	movq	48(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movl	84(%rsp), %ecx
	movl	72(%rsp), %esi
	xorl	%r9d, %r9d
	movq	76(%rsp), %rdx
	movq	64(%rsp), %rdi
	xorl	%r8d, %r8d
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L28
	movq	32(%rsp), %rsi
	movq	24(%rsp), %rdi
	movl	%r12d, %edx
	call	_Z37__device_stub__Z14fast_transposePdS_iPdS_i
.L28:
	movq	56(%rsp), %rdi
	xorl	%esi, %esi
	addl	%ebp, %ebp
	movslq	%ebp, %rbp
	call	cudaEventRecord@PLT
	movq	56(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movq	56(%rsp), %rdx
	movq	48(%rsp), %rsi
	leaq	16(%rsp), %rdi
	movl	$0x00000000, 16(%rsp)
	call	cudaEventElapsedTime@PLT
	salq	$3, %rbp
	js	.L29
	cvtsi2sdq	%rbp, %xmm0
	jmp	.L30
.L29:
	shrq	%rbp
	cvtsi2sdq	%rbp, %xmm0
	addsd	%xmm0, %xmm0
.L30:
	mulsd	.LC5(%rip), %xmm0
	leaq	.LC6(%rip), %rsi
	movl	$2, %edi
	movb	$2, %al
	movq	%xmm0, %rbp
	cvtss2sd	16(%rsp), %xmm0
	movq	%rbp, %xmm1
	divsd	%xmm0, %xmm1
	cvtsd2ss	%xmm1, %xmm1
	cvtss2sd	%xmm1, %xmm1
	call	__printf_chk@PLT
	movq	%rbx, %rdx
	movq	32(%rsp), %rsi
	movq	(%rsp), %rdi
	movl	$2, %ecx
	call	cudaMemcpy@PLT
	movq	48(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movl	84(%rsp), %ecx
	movl	72(%rsp), %esi
	xorl	%r9d, %r9d
	movq	76(%rsp), %rdx
	movq	64(%rsp), %rdi
	xorl	%r8d, %r8d
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L31
	movq	40(%rsp), %rsi
	movq	24(%rsp), %rdi
	movl	%r12d, %edx
	call	_Z38__device_stub__Z15naive_transposePdS_iPdS_i
.L31:
	movq	56(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	56(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movq	56(%rsp), %rdx
	movq	48(%rsp), %rsi
	leaq	20(%rsp), %rdi
	movl	$0x00000000, 20(%rsp)
	call	cudaEventElapsedTime@PLT
	movq	%rbp, %xmm1
	cvtss2sd	20(%rsp), %xmm0
	movb	$2, %al
	divsd	%xmm0, %xmm1
	leaq	.LC7(%rip), %rsi
	movl	$2, %edi
	cvtsd2ss	%xmm1, %xmm1
	cvtss2sd	%xmm1, %xmm1
	call	__printf_chk@PLT
	movq	%rbx, %rdx
	movq	40(%rsp), %rsi
	movq	8(%rsp), %rdi
	movl	$2, %ecx
	call	cudaMemcpy@PLT
	movq	(%rsp), %rsi
	movq	8(%rsp), %rdi
	movl	%r14d, %edx
	call	_Z13equality_testPdS_i
	leaq	.LC8(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	%r15, %rdi
	call	free@PLT
	movq	8(%rsp), %rdi
	call	free@PLT
	movq	(%rsp), %rdi
	call	free@PLT
	movq	24(%rsp), %rdi
	call	cudaFree@PLT
	movq	40(%rsp), %rdi
	call	cudaFree@PLT
	movq	32(%rsp), %rdi
	call	cudaFree@PLT
	movq	48(%rsp), %rdi
	call	cudaEventDestroy@PLT
	movq	56(%rsp), %rdi
	call	cudaEventDestroy@PLT
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	je	.L32
	call	__stack_chk_fail@PLT
.L32:
	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
.LFE2029:
	.size	_Z10run_kerneliii, .-_Z10run_kerneliii
	.section	.rodata.str1.1
.LC9:
	.string	" \t \t \t GPU TIME (ms)     BANDWIDTH (GB/s) "
.LC10:
	.string	"\n\n"
.LC11:
	.string	"64 threads per block: \n"
.LC12:
	.string	"512 threads per block:\n"
.LC13:
	.string	"1024 threads per block:\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2030:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	leaq	.LC9(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	.LC10(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	.LC11(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	$8192, %edx
	movl	$8192, %esi
	movl	$64, %edi
	call	_Z10run_kerneliii
	leaq	.LC12(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	$8192, %edx
	movl	$8192, %esi
	movl	$512, %edi
	call	_Z10run_kerneliii
	leaq	.LC13(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	$8192, %edx
	movl	$8192, %esi
	movl	$1024, %edi
	call	_Z10run_kerneliii
	xorl	%eax, %eax
	popq	%rdx
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2030:
	.size	main, .-main
	.section	.rodata.str1.1
.LC14:
	.string	"_Z15naive_transposePdS_i"
.LC15:
	.string	"_Z14fast_transposePdS_i"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2060:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	pushq	$0
	.cfi_def_cfa_offset 24
	xorl	%r9d, %r9d
	orl	$-1, %r8d
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC14(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z15naive_transposePdS_i(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 48
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r9d, %r9d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC15(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z14fast_transposePdS_i(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 40
	pushq	$0
	.cfi_def_cfa_offset 48
	call	__cudaRegisterFunction@PLT
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE2060:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC0:
	.long	0
	.long	1079574528
	.align 8
.LC1:
	.long	-4194304
	.long	1105199103
	.align 8
.LC5:
	.long	-1598689907
	.long	1051772663
	.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:

//
//  fast_transpose.cu
//
//
//  Created by Laura Balasso on 13/05/2019.
//


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

#define TILE_DIM 32

/* function that fills an array with random doubles */

void random_doubles(double *p, int n) {
    int i;
    for(i=0; i<n; i++) {
        p[i]= ( (double)rand() * 100 ) / (double)RAND_MAX ;
    }
}


/* function that tests the equality between two martices */

void equality_test(double* M1, double* M2, int N){
    long int i;
    for(i=0; i<N*N; i++){
        if(M1[i]!=M2[i]){
            printf("Error! the two methods produce different results. \n"\
);
            break;
        }
    }
    if(i == N*N) printf("Correct result! \n");
}


/* kernel that implements the fast transpose */

__global__ void fast_transpose(double * M_in , double * M_out, int block_rows){

    __shared__ double tile[TILE_DIM][TILE_DIM]; // allocate the tile in shared memory (one per block)

    int x = blockIdx.x * TILE_DIM + threadIdx.x; // define index
    int y = blockIdx.y * TILE_DIM + threadIdx.y;
    int width = gridDim.x * TILE_DIM; // compute matrix width

    /* each block of threads copies a TILE_DIM x TILE_DIM submatrix in the tile */
    /* some threads handle more than one element since THREADS_PER_BLOCK < TILE_DIM*TILE_DIM */

    for (int j = 0; j < TILE_DIM; j += block_rows){
        tile[threadIdx.y+j][threadIdx.x] = M_in[(y+j) * width + x];
    }
    __syncthreads(); // ensures that all the threads copied the values in the tile

    x = blockIdx.y * TILE_DIM + threadIdx.x;
    y = blockIdx.x * TILE_DIM + threadIdx.y;

    for (int j = 0; j < TILE_DIM; j += block_rows){
        M_out[(y+j)*width + x] = tile[threadIdx.x][threadIdx.y + j];
    }
}

/* kernel that implements a naive algorithm for matrix transpose */

__global__ void naive_transpose(double * M_in, double * M_out, int block_rows)
{
    int x = blockIdx.x * TILE_DIM + threadIdx.x;
    int y = blockIdx.y * TILE_DIM + threadIdx.y;
    int width = gridDim.x * TILE_DIM;

    for (int j = 0; j < TILE_DIM; j+= block_rows){
        M_out[x*width + (y+j)] = M_in[(y+j)*width + x];
    }
}

/* function that runs both the naive and the blocking kernels for a given number of threads per block and matrix size */

void run_kernel(int threads_per_block, int dimx, int dimy){


    /* allocate host matrices */
    int num_bytes = dimx*dimy*sizeof(double);
    double *h_in = (double*)malloc(num_bytes);
    double *h_out_block = (double*)malloc(num_bytes);
    double *h_out_naive = (double*)malloc(num_bytes);

    /* allocate davice matrices */
    double *d_in, *d_out_block, *d_out_naive ;
    hipMalloc(&d_in, num_bytes);
    hipMalloc(&d_out_block, num_bytes);
    hipMalloc(&d_out_naive, num_bytes);
    
    /* fill input matrix with random floats  */
    random_doubles(h_in , dimx*dimy);

    /* copy matrices in device memory */
    hipMemcpy( d_in, h_in, num_bytes, hipMemcpyHostToDevice );
    hipMemcpy( d_out_block, h_out_block, num_bytes, hipMemcpyHostToDevice );
    hipMemcpy( d_out_naive, h_out_naive, num_bytes, hipMemcpyHostToDevice );


    /* set threads and blocks grids */
    int block_rows = threads_per_block/TILE_DIM;
    dim3 grid, block;
    block.x = TILE_DIM;
    block.y = block_rows;
    grid.x = dimx/TILE_DIM;
    grid.y = dimy/TILE_DIM;

    /* cuda events for timing */
    hipEvent_t start, stop;
    hipEventCreate(&start);
    hipEventCreate(&stop);

    hipEventRecord(start);

    /* run blocking transpose kernel */
    fast_transpose<<< grid, block >>>(d_in, d_out_block, block_rows);

    hipEventRecord(stop);
    hipEventSynchronize(stop);
    float ms = 0;
    hipEventElapsedTime(&ms, start, stop);
    float bw = 2 * dimx * dimy * sizeof(double) * 1e-6 / ms;
    printf("Fast transpose: \t %lf  \t  %lf \n", ms, bw);

    /* copy the result */
    hipMemcpy( h_out_block, d_out_block, num_bytes, hipMemcpyDeviceToHost );

    hipEventRecord(start);

    /* run naive transpose kernel */
    naive_transpose<<< grid, block >>>(d_in, d_out_naive, block_rows) ;

    hipEventRecord(stop);
    hipEventSynchronize(stop);
    float ms_naive = 0;
    hipEventElapsedTime(&ms_naive, start, stop);
    float bw_naive = 2 * dimx*dimy * sizeof(double) * 1e-6 / ms_naive;
    printf("Naive transpose: \t %lf  \t  %lf \n", ms_naive, bw_naive);

    /* copy result */
    hipMemcpy( h_out_naive, d_out_naive, num_bytes, hipMemcpyDeviceToHost) ;

    equality_test(h_out_naive, h_out_block, dimx);
    
    printf("\n ");

    /* deallocate memory */
    free(h_in); free(h_out_naive); free(h_out_block);
    hipFree(d_in);
    hipFree(d_out_naive);
    hipFree(d_out_block);

    hipEventDestroy(start);
    hipEventDestroy(stop);

}


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

    int dimx = 8192;
    int dimy = 8192;

    printf(" \t \t \t GPU TIME (ms)     BANDWIDTH (GB/s) ");
    printf("\n\n");
    
    printf("64 threads per block: \n");
    run_kernel(64, dimx, dimy);

    printf("512 threads per block:\n");
    run_kernel(512, dimx, dimy);

    printf("1024 threads per block:\n");
    run_kernel(1024, dimx, dimy);


    return 0;

}











	.text
	.file	"fast_transpose.hip"
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z14random_doublesPdi
.LCPI0_0:
	.quad	0x4059000000000000              # double 100
.LCPI0_1:
	.quad	0x41dfffffffc00000              # double 2147483647
	.text
	.globl	_Z14random_doublesPdi
	.type	_Z14random_doublesPdi,@function
_Z14random_doublesPdi:                  # @_Z14random_doublesPdi
	.cfi_startproc
# %bb.0:
	testl	%esi, %esi
	jle	.LBB0_4
# %bb.1:                                # %.lr.ph.preheader
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rdi, %rbx
	movl	%esi, %r14d
	xorl	%r15d, %r15d
.LBB0_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	callq	rand
	xorps	%xmm0, %xmm0
	cvtsi2sd	%eax, %xmm0
	mulsd	.LCPI0_0(%rip), %xmm0
	divsd	.LCPI0_1(%rip), %xmm0
	movsd	%xmm0, (%rbx,%r15,8)
	incq	%r15
	cmpq	%r15, %r14
	jne	.LBB0_2
# %bb.3:
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	.cfi_restore %rbx
	.cfi_restore %r14
	.cfi_restore %r15
.LBB0_4:                                # %._crit_edge
	retq
.Lfunc_end0:
	.size	_Z14random_doublesPdi, .Lfunc_end0-_Z14random_doublesPdi
	.cfi_endproc
                                        # -- End function
	.globl	_Z13equality_testPdS_i          # -- Begin function _Z13equality_testPdS_i
	.type	_Z13equality_testPdS_i,@function
_Z13equality_testPdS_i:                 # @_Z13equality_testPdS_i
	.cfi_startproc
# %bb.0:
	pushq	%r14
	.cfi_def_cfa_offset 16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	pushq	%rax
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -24
	.cfi_offset %r14, -16
	movl	%edx, %ebx
	imull	%ebx, %ebx
	testl	%edx, %edx
	je	.LBB1_1
# %bb.2:                                # %.lr.ph.preheader
	cmpq	$1, %rbx
	movq	%rbx, %rax
	adcq	$0, %rax
	xorl	%r14d, %r14d
.LBB1_3:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movsd	(%rdi,%r14,8), %xmm0            # xmm0 = mem[0],zero
	ucomisd	(%rsi,%r14,8), %xmm0
	jne	.LBB1_4
	jp	.LBB1_4
# %bb.5:                                #   in Loop: Header=BB1_3 Depth=1
	incq	%r14
	cmpq	%r14, %rax
	jne	.LBB1_3
# %bb.6:
	movq	%rax, %r14
	jmp	.LBB1_7
.LBB1_1:
	xorl	%r14d, %r14d
	jmp	.LBB1_7
.LBB1_4:
	movl	$.Lstr, %edi
	callq	puts@PLT
.LBB1_7:                                # %.loopexit
	cmpq	%rbx, %r14
	jne	.LBB1_8
# %bb.9:
	movl	$.Lstr.1, %edi
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	jmp	puts@PLT                        # TAILCALL
.LBB1_8:
	.cfi_def_cfa_offset 32
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end1:
	.size	_Z13equality_testPdS_i, .Lfunc_end1-_Z13equality_testPdS_i
	.cfi_endproc
                                        # -- End function
	.globl	_Z29__device_stub__fast_transposePdS_i # -- Begin function _Z29__device_stub__fast_transposePdS_i
	.type	_Z29__device_stub__fast_transposePdS_i,@function
_Z29__device_stub__fast_transposePdS_i: # @_Z29__device_stub__fast_transposePdS_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), %rcx
	movq	%rsi, (%rcx)
	leaq	12(%rsp), %rsi
	movl	%edx, (%rsi)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	movq	%rsi, 16(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	24(%rsp), %r12
	leaq	16(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z14fast_transposePdS_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_end2:
	.size	_Z29__device_stub__fast_transposePdS_i, .Lfunc_end2-_Z29__device_stub__fast_transposePdS_i
	.cfi_endproc
                                        # -- End function
	.globl	_Z30__device_stub__naive_transposePdS_i # -- Begin function _Z30__device_stub__naive_transposePdS_i
	.type	_Z30__device_stub__naive_transposePdS_i,@function
_Z30__device_stub__naive_transposePdS_i: # @_Z30__device_stub__naive_transposePdS_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), %rcx
	movq	%rsi, (%rcx)
	leaq	12(%rsp), %rsi
	movl	%edx, (%rsi)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	movq	%rsi, 16(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	24(%rsp), %r12
	leaq	16(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z15naive_transposePdS_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	_Z30__device_stub__naive_transposePdS_i, .Lfunc_end3-_Z30__device_stub__naive_transposePdS_i
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z10run_kerneliii
.LCPI4_0:
	.quad	0x4059000000000000              # double 100
.LCPI4_1:
	.quad	0x41dfffffffc00000              # double 2147483647
.LCPI4_4:
	.quad	0x3eb0c6f7a0b5ed8d              # double 9.9999999999999995E-7
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0
.LCPI4_2:
	.long	1127219200                      # 0x43300000
	.long	1160773632                      # 0x45300000
	.long	0                               # 0x0
	.long	0                               # 0x0
.LCPI4_3:
	.quad	0x4330000000000000              # double 4503599627370496
	.quad	0x4530000000000000              # double 1.9342813113834067E+25
	.text
	.globl	_Z10run_kerneliii
	.type	_Z10run_kerneliii,@function
_Z10run_kerneliii:                      # @_Z10run_kerneliii
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$104, %rsp
	.cfi_def_cfa_offset 160
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	%edx, %r12d
                                        # kill: def $esi killed $esi def $rsi
                                        # kill: def $edi killed $edi def $rdi
	movq	%rdi, 80(%rsp)                  # 8-byte Spill
	movl	%edx, %ebx
	movq	%rsi, 64(%rsp)                  # 8-byte Spill
	imull	%esi, %ebx
	leal	(,%rbx,8), %eax
	movslq	%eax, %r13
	movq	%r13, %rdi
	callq	malloc
	movq	%rax, %r14
	movq	%r13, %rdi
	callq	malloc
	movq	%rax, 72(%rsp)                  # 8-byte Spill
	movq	%r13, %rdi
	callq	malloc
	movq	%rax, 56(%rsp)                  # 8-byte Spill
	leaq	40(%rsp), %rdi
	movq	%r13, %rsi
	callq	hipMalloc
	leaq	32(%rsp), %rdi
	movq	%r13, %rsi
	callq	hipMalloc
	leaq	24(%rsp), %rdi
	movq	%r13, %rsi
	callq	hipMalloc
	testl	%ebx, %ebx
	jle	.LBB4_3
# %bb.1:                                # %.lr.ph.preheader.i
	movl	%ebx, %ebp
	xorl	%r15d, %r15d
.LBB4_2:                                # %.lr.ph.i
                                        # =>This Inner Loop Header: Depth=1
	callq	rand
	xorps	%xmm0, %xmm0
	cvtsi2sd	%eax, %xmm0
	mulsd	.LCPI4_0(%rip), %xmm0
	divsd	.LCPI4_1(%rip), %xmm0
	movsd	%xmm0, (%r14,%r15,8)
	incq	%r15
	cmpq	%r15, %rbp
	jne	.LBB4_2
.LBB4_3:                                # %_Z14random_doublesPdi.exit
	movq	40(%rsp), %rdi
	movq	%r14, %rsi
	movq	%r13, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	32(%rsp), %rdi
	movq	72(%rsp), %rsi                  # 8-byte Reload
	movq	%r13, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	24(%rsp), %rdi
	movq	56(%rsp), %rsi                  # 8-byte Reload
	movq	%r13, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	80(%rsp), %rax                  # 8-byte Reload
	leal	31(%rax), %ebp
	testl	%eax, %eax
	cmovnsl	%eax, %ebp
	sarl	$5, %ebp
	movq	%rbp, 48(%rsp)                  # 8-byte Spill
	shlq	$32, %rbp
	orq	$32, %rbp
	movq	64(%rsp), %rcx                  # 8-byte Reload
	leal	31(%rcx), %eax
	testl	%ecx, %ecx
	cmovnsl	%ecx, %eax
	sarl	$5, %eax
	leal	31(%r12), %r15d
	testl	%r12d, %r12d
	cmovnsl	%r12d, %r15d
	sarl	$5, %r15d
	shlq	$32, %r15
	orq	%rax, %r15
	leaq	16(%rsp), %r12
	movq	%r12, %rdi
	callq	hipEventCreate
	leaq	8(%rsp), %rdi
	callq	hipEventCreate
	movq	(%r12), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	%r15, %rdi
	movl	$1, %esi
	movq	%rbp, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB4_5
# %bb.4:
	movq	40(%rsp), %rdi
	movq	32(%rsp), %rsi
	movq	48(%rsp), %rdx                  # 8-byte Reload
                                        # kill: def $edx killed $edx killed $rdx
	callq	_Z29__device_stub__fast_transposePdS_i
.LBB4_5:
	movq	8(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	8(%rsp), %rdi
	callq	hipEventSynchronize
	leaq	100(%rsp), %r12
	movl	$0, (%r12)
	movq	16(%rsp), %rsi
	movq	8(%rsp), %rdx
	movq	%r12, %rdi
	callq	hipEventElapsedTime
	addl	%ebx, %ebx
	movslq	%ebx, %rax
	shlq	$3, %rax
	movq	%rax, %xmm0
	punpckldq	.LCPI4_2(%rip), %xmm0   # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
	subpd	.LCPI4_3(%rip), %xmm0
	movapd	%xmm0, %xmm1
	unpckhpd	%xmm0, %xmm1                    # xmm1 = xmm1[1],xmm0[1]
	addsd	%xmm0, %xmm1
	mulsd	.LCPI4_4(%rip), %xmm1
	xorps	%xmm0, %xmm0
	cvtss2sd	(%r12), %xmm0
	movapd	%xmm1, 80(%rsp)                 # 16-byte Spill
	divsd	%xmm0, %xmm1
	cvtsd2ss	%xmm1, %xmm1
	cvtss2sd	%xmm1, %xmm1
	movl	$.L.str.2, %edi
	movb	$2, %al
	callq	printf
	movq	32(%rsp), %rsi
	movq	72(%rsp), %rbx                  # 8-byte Reload
	movq	%rbx, %rdi
	movq	%r13, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	movq	16(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	%r15, %rdi
	movl	$1, %esi
	movq	%rbp, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	movq	%rbx, %r15
	jne	.LBB4_7
# %bb.6:
	movq	40(%rsp), %rdi
	movq	24(%rsp), %rsi
	movq	48(%rsp), %rdx                  # 8-byte Reload
                                        # kill: def $edx killed $edx killed $rdx
	callq	_Z30__device_stub__naive_transposePdS_i
.LBB4_7:
	movq	8(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	8(%rsp), %rdi
	callq	hipEventSynchronize
	leaq	96(%rsp), %rbx
	movl	$0, (%rbx)
	movq	16(%rsp), %rsi
	movq	8(%rsp), %rdx
	movq	%rbx, %rdi
	callq	hipEventElapsedTime
	xorps	%xmm0, %xmm0
	cvtss2sd	(%rbx), %xmm0
	movapd	80(%rsp), %xmm1                 # 16-byte Reload
	divsd	%xmm0, %xmm1
	cvtsd2ss	%xmm1, %xmm1
	cvtss2sd	%xmm1, %xmm1
	movl	$.L.str.3, %edi
	movb	$2, %al
	callq	printf
	movq	24(%rsp), %rsi
	movq	56(%rsp), %rbx                  # 8-byte Reload
	movq	%rbx, %rdi
	movq	%r13, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	movq	%rbx, %rdi
	movq	%r15, %rsi
	movq	64(%rsp), %rdx                  # 8-byte Reload
                                        # kill: def $edx killed $edx killed $rdx
	callq	_Z13equality_testPdS_i
	movl	$.L.str.4, %edi
	xorl	%eax, %eax
	callq	printf
	movq	%r14, %rdi
	callq	free
	movq	%rbx, %rdi
	callq	free
	movq	%r15, %rdi
	callq	free
	movq	40(%rsp), %rdi
	callq	hipFree
	movq	24(%rsp), %rdi
	callq	hipFree
	movq	32(%rsp), %rdi
	callq	hipFree
	movq	16(%rsp), %rdi
	callq	hipEventDestroy
	movq	8(%rsp), %rdi
	callq	hipEventDestroy
	addq	$104, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end4:
	.size	_Z10run_kerneliii, .Lfunc_end4-_Z10run_kerneliii
	.cfi_endproc
                                        # -- End function
	.globl	main                            # -- Begin function main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%rax
	.cfi_def_cfa_offset 16
	movl	$.L.str.5, %edi
	xorl	%eax, %eax
	callq	printf
	movl	$.Lstr.2, %edi
	callq	puts@PLT
	movl	$.Lstr.3, %edi
	callq	puts@PLT
	movl	$64, %edi
	movl	$8192, %esi                     # imm = 0x2000
	movl	$8192, %edx                     # imm = 0x2000
	callq	_Z10run_kerneliii
	movl	$.Lstr.4, %edi
	callq	puts@PLT
	movl	$512, %edi                      # imm = 0x200
	movl	$8192, %esi                     # imm = 0x2000
	movl	$8192, %edx                     # imm = 0x2000
	callq	_Z10run_kerneliii
	movl	$.Lstr.5, %edi
	callq	puts@PLT
	movl	$1024, %edi                     # imm = 0x400
	movl	$8192, %esi                     # imm = 0x2000
	movl	$8192, %edx                     # imm = 0x2000
	callq	_Z10run_kerneliii
	xorl	%eax, %eax
	popq	%rcx
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end5:
	.size	main, .Lfunc_end5-main
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$32, %rsp
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -16
	movq	__hip_gpubin_handle(%rip), %rbx
	testq	%rbx, %rbx
	jne	.LBB6_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB6_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z14fast_transposePdS_i, %esi
	movl	$.L__unnamed_1, %edx
	movl	$.L__unnamed_1, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z15naive_transposePdS_i, %esi
	movl	$.L__unnamed_2, %edx
	movl	$.L__unnamed_2, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$__hip_module_dtor, %edi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_end6:
	.size	__hip_module_ctor, .Lfunc_end6-__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	.LBB7_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
.LBB7_2:
	retq
.Lfunc_end7:
	.size	__hip_module_dtor, .Lfunc_end7-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	_Z14fast_transposePdS_i,@object # @_Z14fast_transposePdS_i
	.section	.rodata,"a",@progbits
	.globl	_Z14fast_transposePdS_i
	.p2align	3, 0x0
_Z14fast_transposePdS_i:
	.quad	_Z29__device_stub__fast_transposePdS_i
	.size	_Z14fast_transposePdS_i, 8

	.type	_Z15naive_transposePdS_i,@object # @_Z15naive_transposePdS_i
	.globl	_Z15naive_transposePdS_i
	.p2align	3, 0x0
_Z15naive_transposePdS_i:
	.quad	_Z30__device_stub__naive_transposePdS_i
	.size	_Z15naive_transposePdS_i, 8

	.type	.L.str.2,@object                # @.str.2
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.2:
	.asciz	"Fast transpose: \t %lf  \t  %lf \n"
	.size	.L.str.2, 32

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"Naive transpose: \t %lf  \t  %lf \n"
	.size	.L.str.3, 33

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

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	" \t \t \t GPU TIME (ms)     BANDWIDTH (GB/s) "
	.size	.L.str.5, 43

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

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_Z15naive_transposePdS_i"
	.size	.L__unnamed_2, 25

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

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

	.type	.Lstr,@object                   # @str
	.section	.rodata.str1.1,"aMS",@progbits,1
.Lstr:
	.asciz	"Error! the two methods produce different results. "
	.size	.Lstr, 51

	.type	.Lstr.1,@object                 # @str.1
.Lstr.1:
	.asciz	"Correct result! "
	.size	.Lstr.1, 17

	.type	.Lstr.2,@object                 # @str.2
.Lstr.2:
	.asciz	"\n"
	.size	.Lstr.2, 2

	.type	.Lstr.3,@object                 # @str.3
.Lstr.3:
	.asciz	"64 threads per block: "
	.size	.Lstr.3, 23

	.type	.Lstr.4,@object                 # @str.4
.Lstr.4:
	.asciz	"512 threads per block:"
	.size	.Lstr.4, 23

	.type	.Lstr.5,@object                 # @str.5
.Lstr.5:
	.asciz	"1024 threads per block:"
	.size	.Lstr.5, 24

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym _Z29__device_stub__fast_transposePdS_i
	.addrsig_sym _Z30__device_stub__naive_transposePdS_i
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z14fast_transposePdS_i
	.addrsig_sym _Z15naive_transposePdS_i
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z14fast_transposePdS_i ; -- Begin function _Z14fast_transposePdS_i
	.globl	_Z14fast_transposePdS_i
	.p2align	8
	.type	_Z14fast_transposePdS_i,@function
_Z14fast_transposePdS_i:                ; @_Z14fast_transposePdS_i
; %bb.0:
	s_clause 0x1
	s_load_b32 s6, s[0:1], 0x18
	s_load_b32 s4, s[0:1], 0x10
	v_bfe_u32 v2, v0, 10, 10
	s_lshl_b32 s7, s15, 5
	s_load_b128 s[0:3], s[0:1], 0x0
	v_and_b32_e32 v3, 0x3ff, v0
	s_lshl_b32 s8, s14, 5
	v_add_nc_u32_e32 v1, s7, v2
	s_mov_b32 s10, 0
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b32_e32 v0, 3, v3
	v_lshl_add_u32 v4, v2, 8, v0
	s_waitcnt lgkmcnt(0)
	v_mul_lo_u32 v1, s6, v1
	s_mul_i32 s5, s6, s4
	s_lshl_b32 s9, s4, 8
	s_lshl_b32 s5, s5, 5
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b32_e32 v1, 5, v1
	v_add3_u32 v0, v3, v1, s8
.LBB0_1:                                ; =>This Inner Loop Header: Depth=1
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(SALU_CYCLE_1)
	v_ashrrev_i32_e32 v1, 31, v0
	s_add_i32 s10, s10, s4
	s_cmp_gt_i32 s10, 31
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_lshlrev_b64 v[5:6], 3, v[0:1]
	v_add_nc_u32_e32 v0, s5, v0
	v_add_co_u32 v5, vcc_lo, s0, v5
	s_delay_alu instid0(VALU_DEP_3)
	v_add_co_ci_u32_e32 v6, vcc_lo, s1, v6, vcc_lo
	global_load_b64 v[5:6], v[5:6], off
	s_waitcnt vmcnt(0)
	ds_store_b64 v4, v[5:6]
	v_add_nc_u32_e32 v4, s9, v4
	s_cbranch_scc0 .LBB0_1
; %bb.2:
	v_add_nc_u32_e32 v0, s8, v2
	v_lshlrev_b32_e32 v1, 3, v2
	s_lshl_b32 s0, s4, 3
	s_mov_b32 s1, 0
	s_waitcnt lgkmcnt(0)
	v_mul_lo_u32 v0, s6, v0
	v_lshl_add_u32 v2, v3, 8, v1
	s_barrier
	buffer_gl0_inv
	v_lshlrev_b32_e32 v0, 5, v0
	s_delay_alu instid0(VALU_DEP_1)
	v_add3_u32 v0, v3, v0, s7
.LBB0_3:                                ; =>This Inner Loop Header: Depth=1
	ds_load_b64 v[3:4], v2
	v_ashrrev_i32_e32 v1, 31, v0
	v_add_nc_u32_e32 v2, s0, v2
	s_add_i32 s1, s1, s4
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	s_cmp_gt_i32 s1, 31
	v_lshlrev_b64 v[5:6], 3, v[0:1]
	v_add_nc_u32_e32 v0, s5, v0
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_co_u32 v5, vcc_lo, s2, v5
	v_add_co_ci_u32_e32 v6, vcc_lo, s3, v6, vcc_lo
	s_waitcnt lgkmcnt(0)
	global_store_b64 v[5:6], v[3:4], off
	s_cbranch_scc0 .LBB0_3
; %bb.4:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z14fast_transposePdS_i
		.amdhsa_group_segment_fixed_size 8192
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 280
		.amdhsa_user_sgpr_count 14
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 1
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 1
		.amdhsa_next_free_vgpr 7
		.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	_Z14fast_transposePdS_i, .Lfunc_end0-_Z14fast_transposePdS_i
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 340
; NumSgprs: 18
; NumVgprs: 7
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 8192 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 7
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 14
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 1
	.text
	.protected	_Z15naive_transposePdS_i ; -- Begin function _Z15naive_transposePdS_i
	.globl	_Z15naive_transposePdS_i
	.p2align	8
	.type	_Z15naive_transposePdS_i,@function
_Z15naive_transposePdS_i:               ; @_Z15naive_transposePdS_i
; %bb.0:
	s_clause 0x1
	s_load_b32 s5, s[0:1], 0x18
	s_load_b32 s4, s[0:1], 0x10
	v_and_b32_e32 v1, 0x3ff, v0
	v_bfe_u32 v0, v0, 10, 10
	s_lshl_b32 s6, s14, 5
	s_lshl_b32 s7, s15, 5
	s_load_b128 s[0:3], s[0:1], 0x0
	v_add_nc_u32_e32 v2, s6, v1
	v_add_nc_u32_e32 v3, s7, v0
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_mul_lo_u32 v2, s5, v2
	v_mul_lo_u32 v3, s5, v3
	s_mul_i32 s5, s5, s4
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	s_lshl_b32 s5, s5, 5
	v_lshlrev_b32_e32 v2, 5, v2
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_lshlrev_b32_e32 v3, 5, v3
	v_add3_u32 v2, v0, v2, s7
	s_delay_alu instid0(VALU_DEP_2)
	v_add3_u32 v0, v1, v3, s6
	s_mov_b32 s6, 0
.LBB1_1:                                ; =>This Inner Loop Header: Depth=1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_ashrrev_i32_e32 v1, 31, v0
	v_add_nc_u32_e32 v5, s6, v2
	s_add_i32 s6, s6, s4
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	s_cmp_gt_i32 s6, 31
	v_lshlrev_b64 v[3:4], 3, v[0:1]
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_ashrrev_i32_e32 v6, 31, v5
	v_add_nc_u32_e32 v0, s5, v0
	v_lshlrev_b64 v[5:6], 3, v[5:6]
	s_delay_alu instid0(VALU_DEP_4) | instskip(SKIP_1) | instid1(VALU_DEP_3)
	v_add_co_u32 v3, vcc_lo, s0, v3
	v_add_co_ci_u32_e32 v4, vcc_lo, s1, v4, vcc_lo
	v_add_co_u32 v5, vcc_lo, s2, v5
	global_load_b64 v[3:4], v[3:4], off
	v_add_co_ci_u32_e32 v6, vcc_lo, s3, v6, vcc_lo
	s_waitcnt vmcnt(0)
	global_store_b64 v[5:6], v[3:4], off
	s_cbranch_scc0 .LBB1_1
; %bb.2:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z15naive_transposePdS_i
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 280
		.amdhsa_user_sgpr_count 14
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 1
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 1
		.amdhsa_next_free_vgpr 7
		.amdhsa_next_free_sgpr 16
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end1:
	.size	_Z15naive_transposePdS_i, .Lfunc_end1-_Z15naive_transposePdS_i
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 248
; NumSgprs: 18
; NumVgprs: 7
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 7
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 14
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 1
	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __hip_cuid_
	.amdgpu_metadata
---
amdhsa.kernels:
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .offset:         16
        .size:           4
        .value_kind:     by_value
      - .offset:         24
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         28
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         32
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         36
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         38
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         40
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         42
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         44
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         46
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         64
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         88
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 8192
    .kernarg_segment_align: 8
    .kernarg_segment_size: 280
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z14fast_transposePdS_i
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z14fast_transposePdS_i.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     7
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .offset:         16
        .size:           4
        .value_kind:     by_value
      - .offset:         24
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         28
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         32
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         36
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         38
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         40
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         42
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         44
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         46
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         64
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         88
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 280
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z15naive_transposePdS_i
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z15naive_transposePdS_i.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     7
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
