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

#include <cuda.h>

/* Time */
#include <sys/time.h>
#include <sys/resource.h>

static struct timeval tv0;
double getMicroSeconds()
{
	double t;
	gettimeofday(&tv0, (struct timezone*)0);
	t = ((tv0.tv_usec) + (tv0.tv_sec)*1000000);

	return (t);
}

void init_seed()
{
	int seedi=1;
	FILE *fd;

	/* Generated random values between 0.00 - 1.00 */
	fd = fopen("/dev/urandom", "r");
	fread( &seedi, sizeof(int), 1, fd);
	fclose (fd);
	srand( seedi );
}

void init2Drand(float **buffer, int n)
{
	int i, j;

	for (i=0; i<n; i++)
		for(j=0; j<n; j++)
			buffer[i][j] = 500.0*(float(rand())/RAND_MAX)-500.0; /* [-500 500]*/
}

float *getmemory1D( int nx )
{
	int i;
	float *buffer;

	if( (buffer=(float *)malloc(nx*sizeof(float *)))== NULL )
	{
		fprintf( stderr, "ERROR in memory allocation\n" );
		return( NULL );
	}

	for( i=0; i<nx; i++ )
		buffer[i] = 0.0;

	return( buffer );
}


float **getmemory2D(int nx, int ny)
{
	int i,j;
	float **buffer;

	if( (buffer=(float **)malloc(nx*sizeof(float *)))== NULL )
	{
		fprintf( stderr, "ERROR in memory allocation\n" );
		return( NULL );
	}

	if( (buffer[0]=(float *)malloc(nx*ny*sizeof(float)))==NULL )
	{
		fprintf( stderr, "ERROR in memory allocation\n" );
		free( buffer );
		return( NULL );
	}

	for( i=1; i<nx; i++ )
	{
		buffer[i] = buffer[i-1] + ny;
	}

	for( i=0; i<nx; i++ )
		for( j=0; j<ny; j++ )
		{
			buffer[i][j] = 0.0;
		}

	return( buffer );
}



/********************************************************************************/
/********************************************************************************/

/*
 * Traspose 2D version
 */
void transpose2D(float **in, float **out, int n)
{
	int i, j;

	for(j=0; j < n; j++) 
		for(i=0; i < n; i++) 
			out[j][i] = in[i][j]; 
}

/*
 * Traspose 1D version
 */
void transpose1D(float *in, float *out, int n)
{
	int i, j;

	for(j=0; j < n; j++) 
		for(i=0; i < n; i++) 
			out[j*n+i] = in[i*n+j]; 
}

/*
 * Traspose CUDA version
 */

#define NTHREADS1D 256

/*
__global__ void transpose_device(float *in, float *out, int rows, int cols) 
{ 
	int i, j; 
	i = blockIdx.x * blockDim.x + threadIdx.x; 

	if (i<rows)
		for ( j=0; j<cols; j++) 
			out [ i * rows + j ] = in [ j * cols + i ]; 
}*/

#define TPB 32
__global__ void transpose_device(float *in, float *out, int rows, int cols) {
	int i, j;
	__shared__ float tile[TPB][TPB+1];

	i = blockIdx.x * blockDim.x + threadIdx.x;
	j = blockIdx.y * blockDim.y + threadIdx.y;

	if (i < rows && j < cols) {
		tile[threadIdx.y][threadIdx.x] = in[rows*j+i];
	}
	__syncthreads();
	i = blockDim.y*blockIdx.y + threadIdx.x;
	j = blockDim.x*blockIdx.x + threadIdx.y;
	if (i < rows && j < cols) {
		out[rows * j + i] = tile[threadIdx.x][threadIdx.y];
	}
}

int check(float *GPU, float *CPU, int n)
{
	int i;

	for (i=0; i<n; i++)
		if(GPU[i]!=CPU[i])
			return(1);

	return(0);
}

int main(int argc, char **argv)
{
	int n;
	float **array2D, **array2D_trans;
	float *array1D,  *array1D_trans;
	float *array1D_trans_GPU;

	double t0;

	if (argc==2)
		n = atoi(argv[1]);
	else {
		n = 4096;
		printf("./exec n (by default n=%i)\n", n);
	}
	
	/* Initizalization */
	init_seed();
	array2D       = getmemory2D(n,n);
	array2D_trans = getmemory2D(n,n);
	array1D_trans_GPU = getmemory1D(n*n);
	array1D       = array2D[0];
	array1D_trans = array2D_trans[0];
	init2Drand(array2D, n);

	/* Transpose 1D version */
	t0 = getMicroSeconds();
	transpose1D(array1D, array1D_trans, n);
	printf("Transpose version 1D: %f MB/s\n", n*n*sizeof(float)/((getMicroSeconds()-t0)/1000000)/1024/1024);


	/* CUDA vesion */
	float *darray1D, *darray1D_trans;
	cudaMalloc((void**)&darray1D, n*n*sizeof(float));
	cudaMemcpy(darray1D, array1D, n*n*sizeof(float), cudaMemcpyHostToDevice);
	cudaMalloc((void**)&darray1D_trans, n*n*sizeof(float));

	dim3 dimBlock(TPB, TPB);
	int blocks = (n+TPB-1)/TPB;
	dim3 dimGrid(blocks, blocks);

	t0 = getMicroSeconds();
	transpose_device<<<dimGrid,dimBlock>>>(darray1D, darray1D_trans, n, n);	
	cudaMemcpy(array1D_trans_GPU, darray1D_trans, n*n*sizeof(float), cudaMemcpyDeviceToHost);
	cudaThreadSynchronize();
	
	printf("Transpose kernel version: %f MB/s\n", n*n*sizeof(float)/((getMicroSeconds()-t0)/1000000)/1024/1024);


	if (check(array1D_trans_GPU, array1D_trans, n*n))
		printf("Transpose CPU-GPU differs!!\n");


	return(0);
}

	.file	"tmpxft_00202691_00000000-6_transpose.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2038:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2038:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z15getMicroSecondsv
	.type	_Z15getMicroSecondsv, @function
_Z15getMicroSecondsv:
.LFB2027:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	xorl	%esi, %esi
	leaq	_ZL3tv0(%rip), %rdi
	call	gettimeofday@PLT
	imulq	$1000000, _ZL3tv0(%rip), %rax
	addq	8+_ZL3tv0(%rip), %rax
	cvtsi2sdq	%rax, %xmm0
	popq	%rdx
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2027:
	.size	_Z15getMicroSecondsv, .-_Z15getMicroSecondsv
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"r"
.LC1:
	.string	"/dev/urandom"
	.text
	.globl	_Z9init_seedv
	.type	_Z9init_seedv, @function
_Z9init_seedv:
.LFB2028:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	leaq	.LC0(%rip), %rsi
	leaq	.LC1(%rip), %rdi
	subq	$16, %rsp
	.cfi_def_cfa_offset 32
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	movl	$1, 4(%rsp)
	call	fopen@PLT
	leaq	4(%rsp), %rdi
	movl	$1, %ecx
	movl	$4, %edx
	movq	%rax, %rbx
	movq	%rax, %r8
	movl	$4, %esi
	call	__fread_chk@PLT
	movq	%rbx, %rdi
	call	fclose@PLT
	movl	4(%rsp), %edi
	call	srand@PLT
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	je	.L5
	call	__stack_chk_fail@PLT
.L5:
	addq	$16, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2028:
	.size	_Z9init_seedv, .-_Z9init_seedv
	.globl	_Z10init2DrandPPfi
	.type	_Z10init2DrandPPfi, @function
_Z10init2DrandPPfi:
.LFB2029:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	movslq	%esi, %r14
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	movq	%rdi, %r13
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	movq	%r14, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	xorl	%ebx, %ebx
.L9:
	cmpl	%ebx, %ebp
	jle	.L14
	xorl	%r12d, %r12d
.L10:
	call	rand@PLT
	movsd	.LC3(%rip), %xmm1
	movq	0(%r13,%rbx,8), %rdx
	cvtsi2ssl	%eax, %xmm0
	mulss	.LC2(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	mulsd	%xmm1, %xmm0
	subsd	%xmm1, %xmm0
	cvtsd2ss	%xmm0, %xmm0
	movss	%xmm0, (%rdx,%r12,4)
	incq	%r12
	cmpq	%r14, %r12
	jne	.L10
	incq	%rbx
	jmp	.L9
.L14:
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2029:
	.size	_Z10init2DrandPPfi, .-_Z10init2DrandPPfi
	.section	.rodata.str1.1
.LC4:
	.string	"ERROR in memory allocation\n"
	.text
	.globl	_Z11getmemory1Di
	.type	_Z11getmemory1Di, @function
_Z11getmemory1Di:
.LFB2030:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movslq	%edi, %rdi
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	movq	%rdi, %rbp
	salq	$3, %rdi
	pushq	%rcx
	.cfi_def_cfa_offset 32
	call	malloc@PLT
	movq	%rax, %rbx
	xorl	%eax, %eax
	testq	%rbx, %rbx
	jne	.L16
	movq	stderr(%rip), %rdi
	leaq	.LC4(%rip), %rdx
	movl	$2, %esi
	call	__fprintf_chk@PLT
	jmp	.L15
.L16:
	cmpl	%eax, %ebp
	jle	.L15
	movl	$0x00000000, (%rbx,%rax,4)
	incq	%rax
	jmp	.L16
.L15:
	movq	%rbx, %rax
	popq	%rdx
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2030:
	.size	_Z11getmemory1Di, .-_Z11getmemory1Di
	.globl	_Z11getmemory2Dii
	.type	_Z11getmemory2Dii, @function
_Z11getmemory2Dii:
.LFB2031:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movslq	%edi, %rdi
	movl	%esi, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movq	%rdi, %rbp
	salq	$3, %rdi
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	call	malloc@PLT
	testq	%rax, %rax
	jne	.L23
	movq	stderr(%rip), %rdi
	leaq	.LC4(%rip), %rdx
	movl	$2, %esi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	jmp	.L24
.L23:
	movl	%ebp, %edi
	movq	%rax, %rbx
	imull	%r12d, %edi
	movslq	%edi, %rdi
	salq	$2, %rdi
	call	malloc@PLT
	movq	%rax, (%rbx)
	testq	%rax, %rax
	je	.L25
	movslq	%r12d, %rdx
	xorl	%eax, %eax
	salq	$2, %rdx
	jmp	.L26
.L25:
	movq	stderr(%rip), %rdi
	leaq	.LC4(%rip), %rdx
	movl	$2, %esi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	movq	%rbx, %rdi
	call	free@PLT
.L24:
	xorl	%ebx, %ebx
	jmp	.L22
.L26:
	incq	%rax
	cmpl	%eax, %ebp
	jle	.L34
	movq	-8(%rbx,%rax,8), %rcx
	addq	%rdx, %rcx
	movq	%rcx, (%rbx,%rax,8)
	jmp	.L26
.L34:
	xorl	%eax, %eax
.L29:
	cmpl	%eax, %ebp
	jle	.L22
	xorl	%edx, %edx
.L31:
	cmpl	%edx, %r12d
	jle	.L35
	movq	(%rbx,%rax,8), %rcx
	movl	$0x00000000, (%rcx,%rdx,4)
	incq	%rdx
	jmp	.L31
.L35:
	incq	%rax
	jmp	.L29
.L22:
	movq	%rbx, %rax
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2031:
	.size	_Z11getmemory2Dii, .-_Z11getmemory2Dii
	.globl	_Z11transpose2DPPfS0_i
	.type	_Z11transpose2DPPfS0_i, @function
_Z11transpose2DPPfS0_i:
.LFB2032:
	.cfi_startproc
	endbr64
	xorl	%eax, %eax
.L37:
	cmpl	%eax, %edx
	jle	.L41
	movq	(%rsi,%rax,8), %r8
	leaq	0(,%rax,4), %r9
	xorl	%ecx, %ecx
.L38:
	movq	(%rdi,%rcx,8), %r10
	movss	(%r10,%r9), %xmm0
	movss	%xmm0, (%r8,%rcx,4)
	incq	%rcx
	cmpl	%ecx, %edx
	jg	.L38
	incq	%rax
	jmp	.L37
.L41:
	ret
	.cfi_endproc
.LFE2032:
	.size	_Z11transpose2DPPfS0_i, .-_Z11transpose2DPPfS0_i
	.globl	_Z11transpose1DPfS_i
	.type	_Z11transpose1DPfS_i, @function
_Z11transpose1DPfS_i:
.LFB2033:
	.cfi_startproc
	endbr64
	movslq	%edx, %rax
	xorl	%r8d, %r8d
	salq	$2, %rax
.L43:
	cmpl	%edx, %r8d
	jge	.L47
	movq	%rdi, %r9
	xorl	%ecx, %ecx
.L44:
	movss	(%r9), %xmm0
	addq	%rax, %r9
	movss	%xmm0, (%rsi,%rcx,4)
	incq	%rcx
	cmpl	%ecx, %edx
	jg	.L44
	incl	%r8d
	addq	$4, %rdi
	addq	%rax, %rsi
	jmp	.L43
.L47:
	ret
	.cfi_endproc
.LFE2033:
	.size	_Z11transpose1DPfS_i, .-_Z11transpose1DPfS_i
	.globl	_Z5checkPfS_i
	.type	_Z5checkPfS_i, @function
_Z5checkPfS_i:
.LFB2034:
	.cfi_startproc
	endbr64
	xorl	%eax, %eax
.L49:
	cmpl	%eax, %edx
	jle	.L54
	movss	(%rdi,%rax,4), %xmm0
	incq	%rax
	ucomiss	-4(%rsi,%rax,4), %xmm0
	jp	.L53
	je	.L49
	jmp	.L53
.L54:
	xorl	%eax, %eax
	ret
.L53:
	movl	$1, %eax
	ret
	.cfi_endproc
.LFE2034:
	.size	_Z5checkPfS_i, .-_Z5checkPfS_i
	.globl	_Z40__device_stub__Z16transpose_devicePfS_iiPfS_ii
	.type	_Z40__device_stub__Z16transpose_devicePfS_iiPfS_ii, @function
_Z40__device_stub__Z16transpose_devicePfS_iiPfS_ii:
.LFB2060:
	.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
	movl	%edx, 12(%rsp)
	leaq	40(%rsp), %rdx
	movl	%ecx, 8(%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	12(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	8(%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	.L55
	pushq	48(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z16transpose_devicePfS_ii(%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
.L55:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L57
	call	__stack_chk_fail@PLT
.L57:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2060:
	.size	_Z40__device_stub__Z16transpose_devicePfS_iiPfS_ii, .-_Z40__device_stub__Z16transpose_devicePfS_iiPfS_ii
	.globl	_Z16transpose_devicePfS_ii
	.type	_Z16transpose_devicePfS_ii, @function
_Z16transpose_devicePfS_ii:
.LFB2061:
	.cfi_startproc
	endbr64
	jmp	_Z40__device_stub__Z16transpose_devicePfS_iiPfS_ii
	.cfi_endproc
.LFE2061:
	.size	_Z16transpose_devicePfS_ii, .-_Z16transpose_devicePfS_ii
	.section	.rodata.str1.1
.LC6:
	.string	"./exec n (by default n=%i)\n"
.LC9:
	.string	"Transpose version 1D: %f MB/s\n"
.LC10:
	.string	"Transpose kernel version: %f MB/s\n"
.LC11:
	.string	"Transpose CPU-GPU differs!!\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2035:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$72, %rsp
	.cfi_def_cfa_offset 128
	movq	%fs:40, %rax
	movq	%rax, 56(%rsp)
	xorl	%eax, %eax
	cmpl	$2, %edi
	jne	.L61
	movq	8(%rsi), %rdi
	call	atoi@PLT
	movl	%eax, %ebx
	jmp	.L62
.L61:
	movl	$4096, %edx
	leaq	.LC6(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	$4096, %ebx
.L62:
	call	_Z9init_seedv
	movl	%ebx, %r13d
	movl	%ebx, %esi
	movl	%ebx, %edi
	call	_Z11getmemory2Dii
	imull	%ebx, %r13d
	movl	%ebx, %esi
	movl	%ebx, %edi
	movq	%rax, %rbp
	call	_Z11getmemory2Dii
	movq	%rax, %r14
	movl	%r13d, %edi
	call	_Z11getmemory1Di
	movq	0(%rbp), %r15
	movq	(%r14), %r14
	movq	%rbp, %rdi
	movl	%ebx, %esi
	movslq	%r13d, %rbp
	movq	%rax, %r12
	call	_Z10init2DrandPPfi
	salq	$2, %rbp
	call	_Z15getMicroSecondsv
	movl	%ebx, %edx
	movq	%r14, %rsi
	movq	%r15, %rdi
	movsd	%xmm0, 8(%rsp)
	call	_Z11transpose1DPfS_i
	cvtsi2sdq	%rbp, %xmm2
	movsd	%xmm2, (%rsp)
	call	_Z15getMicroSecondsv
	leaq	.LC9(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	movaps	%xmm0, %xmm1
	cvtsi2sdq	%rbp, %xmm0
	subsd	8(%rsp), %xmm1
	divsd	.LC7(%rip), %xmm1
	divsd	%xmm1, %xmm0
	mulsd	.LC8(%rip), %xmm0
	mulsd	.LC8(%rip), %xmm0
	call	__printf_chk@PLT
	leaq	16(%rsp), %rdi
	movq	%rbp, %rsi
	call	cudaMalloc@PLT
	movq	16(%rsp), %rdi
	movq	%rbp, %rdx
	movq	%r15, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	leaq	24(%rsp), %rdi
	movq	%rbp, %rsi
	call	cudaMalloc@PLT
	movl	$32, %ecx
	movabsq	$137438953504, %rax
	movl	$1, 40(%rsp)
	movq	%rax, 32(%rsp)
	leal	31(%rbx), %eax
	cltd
	movl	$1, 52(%rsp)
	idivl	%ecx
	movl	%eax, 44(%rsp)
	movl	%eax, 48(%rsp)
	call	_Z15getMicroSecondsv
	movl	40(%rsp), %ecx
	movl	52(%rsp), %esi
	xorl	%r9d, %r9d
	movq	32(%rsp), %rdx
	movq	44(%rsp), %rdi
	xorl	%r8d, %r8d
	movsd	%xmm0, 8(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L63
	movq	24(%rsp), %rsi
	movq	16(%rsp), %rdi
	movl	%ebx, %ecx
	movl	%ebx, %edx
	call	_Z40__device_stub__Z16transpose_devicePfS_iiPfS_ii
.L63:
	movq	24(%rsp), %rsi
	movq	%rbp, %rdx
	movl	$2, %ecx
	movq	%r12, %rdi
	call	cudaMemcpy@PLT
	call	cudaThreadSynchronize@PLT
	call	_Z15getMicroSecondsv
	leaq	.LC10(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	movaps	%xmm0, %xmm1
	movsd	(%rsp), %xmm0
	subsd	8(%rsp), %xmm1
	divsd	.LC7(%rip), %xmm1
	divsd	%xmm1, %xmm0
	mulsd	.LC8(%rip), %xmm0
	mulsd	.LC8(%rip), %xmm0
	call	__printf_chk@PLT
	movl	%r13d, %edx
	movq	%r14, %rsi
	movq	%r12, %rdi
	call	_Z5checkPfS_i
	testl	%eax, %eax
	je	.L64
	leaq	.LC11(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L64:
	movq	56(%rsp), %rax
	subq	%fs:40, %rax
	je	.L65
	call	__stack_chk_fail@PLT
.L65:
	addq	$72, %rsp
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2035:
	.size	main, .-main
	.section	.rodata.str1.1
.LC12:
	.string	"_Z16transpose_devicePfS_ii"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2063:
	.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	.LC12(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z16transpose_devicePfS_ii(%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
.LFE2063:
	.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
	.local	_ZL3tv0
	.comm	_ZL3tv0,16,16
	.section	.rodata.cst4,"aM",@progbits,4
	.align 4
.LC2:
	.long	805306368
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC3:
	.long	0
	.long	1082081280
	.align 8
.LC7:
	.long	0
	.long	1093567616
	.align 8
.LC8:
	.long	0
	.long	1062207488
	.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 <stdlib.h>

#include <hip/hip_runtime.h>

/* Time */
#include <sys/time.h>
#include <sys/resource.h>

static struct timeval tv0;
double getMicroSeconds()
{
	double t;
	gettimeofday(&tv0, (struct timezone*)0);
	t = ((tv0.tv_usec) + (tv0.tv_sec)*1000000);

	return (t);
}

void init_seed()
{
	int seedi=1;
	FILE *fd;

	/* Generated random values between 0.00 - 1.00 */
	fd = fopen("/dev/urandom", "r");
	fread( &seedi, sizeof(int), 1, fd);
	fclose (fd);
	srand( seedi );
}

void init2Drand(float **buffer, int n)
{
	int i, j;

	for (i=0; i<n; i++)
		for(j=0; j<n; j++)
			buffer[i][j] = 500.0*(float(rand())/RAND_MAX)-500.0; /* [-500 500]*/
}

float *getmemory1D( int nx )
{
	int i;
	float *buffer;

	if( (buffer=(float *)malloc(nx*sizeof(float *)))== NULL )
	{
		fprintf( stderr, "ERROR in memory allocation\n" );
		return( NULL );
	}

	for( i=0; i<nx; i++ )
		buffer[i] = 0.0;

	return( buffer );
}


float **getmemory2D(int nx, int ny)
{
	int i,j;
	float **buffer;

	if( (buffer=(float **)malloc(nx*sizeof(float *)))== NULL )
	{
		fprintf( stderr, "ERROR in memory allocation\n" );
		return( NULL );
	}

	if( (buffer[0]=(float *)malloc(nx*ny*sizeof(float)))==NULL )
	{
		fprintf( stderr, "ERROR in memory allocation\n" );
		free( buffer );
		return( NULL );
	}

	for( i=1; i<nx; i++ )
	{
		buffer[i] = buffer[i-1] + ny;
	}

	for( i=0; i<nx; i++ )
		for( j=0; j<ny; j++ )
		{
			buffer[i][j] = 0.0;
		}

	return( buffer );
}



/********************************************************************************/
/********************************************************************************/

/*
 * Traspose 2D version
 */
void transpose2D(float **in, float **out, int n)
{
	int i, j;

	for(j=0; j < n; j++) 
		for(i=0; i < n; i++) 
			out[j][i] = in[i][j]; 
}

/*
 * Traspose 1D version
 */
void transpose1D(float *in, float *out, int n)
{
	int i, j;

	for(j=0; j < n; j++) 
		for(i=0; i < n; i++) 
			out[j*n+i] = in[i*n+j]; 
}

/*
 * Traspose CUDA version
 */

#define NTHREADS1D 256

/*
__global__ void transpose_device(float *in, float *out, int rows, int cols) 
{ 
	int i, j; 
	i = blockIdx.x * blockDim.x + threadIdx.x; 

	if (i<rows)
		for ( j=0; j<cols; j++) 
			out [ i * rows + j ] = in [ j * cols + i ]; 
}*/

#define TPB 32
__global__ void transpose_device(float *in, float *out, int rows, int cols) {
	int i, j;
	__shared__ float tile[TPB][TPB+1];

	i = blockIdx.x * blockDim.x + threadIdx.x;
	j = blockIdx.y * blockDim.y + threadIdx.y;

	if (i < rows && j < cols) {
		tile[threadIdx.y][threadIdx.x] = in[rows*j+i];
	}
	__syncthreads();
	i = blockDim.y*blockIdx.y + threadIdx.x;
	j = blockDim.x*blockIdx.x + threadIdx.y;
	if (i < rows && j < cols) {
		out[rows * j + i] = tile[threadIdx.x][threadIdx.y];
	}
}

int check(float *GPU, float *CPU, int n)
{
	int i;

	for (i=0; i<n; i++)
		if(GPU[i]!=CPU[i])
			return(1);

	return(0);
}

int main(int argc, char **argv)
{
	int n;
	float **array2D, **array2D_trans;
	float *array1D,  *array1D_trans;
	float *array1D_trans_GPU;

	double t0;

	if (argc==2)
		n = atoi(argv[1]);
	else {
		n = 4096;
		printf("./exec n (by default n=%i)\n", n);
	}
	
	/* Initizalization */
	init_seed();
	array2D       = getmemory2D(n,n);
	array2D_trans = getmemory2D(n,n);
	array1D_trans_GPU = getmemory1D(n*n);
	array1D       = array2D[0];
	array1D_trans = array2D_trans[0];
	init2Drand(array2D, n);

	/* Transpose 1D version */
	t0 = getMicroSeconds();
	transpose1D(array1D, array1D_trans, n);
	printf("Transpose version 1D: %f MB/s\n", n*n*sizeof(float)/((getMicroSeconds()-t0)/1000000)/1024/1024);


	/* CUDA vesion */
	float *darray1D, *darray1D_trans;
	hipMalloc((void**)&darray1D, n*n*sizeof(float));
	hipMemcpy(darray1D, array1D, n*n*sizeof(float), hipMemcpyHostToDevice);
	hipMalloc((void**)&darray1D_trans, n*n*sizeof(float));

	dim3 dimBlock(TPB, TPB);
	int blocks = (n+TPB-1)/TPB;
	dim3 dimGrid(blocks, blocks);

	t0 = getMicroSeconds();
	transpose_device<<<dimGrid,dimBlock>>>(darray1D, darray1D_trans, n, n);	
	hipMemcpy(array1D_trans_GPU, darray1D_trans, n*n*sizeof(float), hipMemcpyDeviceToHost);
	hipDeviceSynchronize();
	
	printf("Transpose kernel version: %f MB/s\n", n*n*sizeof(float)/((getMicroSeconds()-t0)/1000000)/1024/1024);


	if (check(array1D_trans_GPU, array1D_trans, n*n))
		printf("Transpose CPU-GPU differs!!\n");


	return(0);
}

	.text
	.file	"transpose.hip"
	.globl	_Z15getMicroSecondsv            # -- Begin function _Z15getMicroSecondsv
	.type	_Z15getMicroSecondsv,@function
_Z15getMicroSecondsv:                   # @_Z15getMicroSecondsv
	.cfi_startproc
# %bb.0:
	pushq	%rax
	.cfi_def_cfa_offset 16
	movl	$_ZL3tv0, %edi
	xorl	%esi, %esi
	callq	gettimeofday
	imulq	$1000000, _ZL3tv0(%rip), %rax   # imm = 0xF4240
	addq	_ZL3tv0+8(%rip), %rax
	cvtsi2sd	%rax, %xmm0
	popq	%rax
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	_Z15getMicroSecondsv, .Lfunc_end0-_Z15getMicroSecondsv
	.cfi_endproc
                                        # -- End function
	.globl	_Z9init_seedv                   # -- Begin function _Z9init_seedv
	.type	_Z9init_seedv,@function
_Z9init_seedv:                          # @_Z9init_seedv
	.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
	leaq	4(%rsp), %rbx
	movl	$1, (%rbx)
	movl	$.L.str, %edi
	movl	$.L.str.1, %esi
	callq	fopen
	movq	%rax, %r14
	movl	$4, %esi
	movl	$1, %edx
	movq	%rbx, %rdi
	movq	%rax, %rcx
	callq	fread
	movq	%r14, %rdi
	callq	fclose
	movl	(%rbx), %edi
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	jmp	srand                           # TAILCALL
.Lfunc_end1:
	.size	_Z9init_seedv, .Lfunc_end1-_Z9init_seedv
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function _Z10init2DrandPPfi
.LCPI2_0:
	.long	0x30000000                      # float 4.65661287E-10
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0
.LCPI2_1:
	.quad	0x407f400000000000              # double 500
.LCPI2_2:
	.quad	0xc07f400000000000              # double -500
	.text
	.globl	_Z10init2DrandPPfi
	.type	_Z10init2DrandPPfi,@function
_Z10init2DrandPPfi:                     # @_Z10init2DrandPPfi
	.cfi_startproc
# %bb.0:
	testl	%esi, %esi
	jle	.LBB2_6
# %bb.1:                                # %.preheader.lr.ph
	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
	movq	%rdi, %rbx
	movl	%esi, %r14d
	xorl	%r15d, %r15d
.LBB2_2:                                # %.lr.ph
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB2_3 Depth 2
	xorl	%r12d, %r12d
.LBB2_3:                                #   Parent Loop BB2_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	callq	rand
	movss	.LCPI2_0(%rip), %xmm1           # xmm1 = mem[0],zero,zero,zero
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	mulss	%xmm1, %xmm0
	movsd	.LCPI2_1(%rip), %xmm1           # xmm1 = mem[0],zero
	cvtss2sd	%xmm0, %xmm0
	mulsd	%xmm1, %xmm0
	movsd	.LCPI2_2(%rip), %xmm1           # xmm1 = mem[0],zero
	addsd	%xmm1, %xmm0
	cvtsd2ss	%xmm0, %xmm0
	movq	(%rbx,%r15,8), %rax
	movss	%xmm0, (%rax,%r12,4)
	incq	%r12
	cmpq	%r12, %r14
	jne	.LBB2_3
# %bb.4:                                # %._crit_edge
                                        #   in Loop: Header=BB2_2 Depth=1
	incq	%r15
	cmpq	%r14, %r15
	jne	.LBB2_2
# %bb.5:
	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
.LBB2_6:                                # %._crit_edge12
	retq
.Lfunc_end2:
	.size	_Z10init2DrandPPfi, .Lfunc_end2-_Z10init2DrandPPfi
	.cfi_endproc
                                        # -- End function
	.globl	_Z11getmemory1Di                # -- Begin function _Z11getmemory1Di
	.type	_Z11getmemory1Di,@function
_Z11getmemory1Di:                       # @_Z11getmemory1Di
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.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 %rbp, -16
	movl	%edi, %ebp
	movslq	%edi, %rdi
	shlq	$3, %rdi
	callq	malloc
	movq	%rax, %rbx
	testq	%rax, %rax
	je	.LBB3_3
# %bb.1:                                # %.preheader
	testl	%ebp, %ebp
	jle	.LBB3_4
# %bb.2:                                # %.lr.ph.preheader
	movl	%ebp, %edx
	shlq	$2, %rdx
	movq	%rbx, %rdi
	xorl	%esi, %esi
	callq	memset@PLT
.LBB3_4:                                # %.loopexit
	movq	%rbx, %rax
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.LBB3_3:
	.cfi_def_cfa_offset 32
	movq	stderr(%rip), %rcx
	movl	$.L.str.2, %edi
	movl	$27, %esi
	movl	$1, %edx
	callq	fwrite@PLT
	jmp	.LBB3_4
.Lfunc_end3:
	.size	_Z11getmemory1Di, .Lfunc_end3-_Z11getmemory1Di
	.cfi_endproc
                                        # -- End function
	.globl	_Z11getmemory2Dii               # -- Begin function _Z11getmemory2Dii
	.type	_Z11getmemory2Dii,@function
_Z11getmemory2Dii:                      # @_Z11getmemory2Dii
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	%esi, %ebp
	movl	%edi, %r14d
	movslq	%edi, %rdi
	shlq	$3, %rdi
	callq	malloc
	testq	%rax, %rax
	je	.LBB4_11
# %bb.1:
	movq	%rax, %rbx
	movl	%ebp, %eax
	imull	%r14d, %eax
	movslq	%eax, %rdi
	shlq	$2, %rdi
	callq	malloc
	movq	%rax, (%rbx)
	testq	%rax, %rax
	je	.LBB4_13
# %bb.2:                                # %.preheader28
	movl	%r14d, %r15d
	cmpl	$2, %r14d
	jl	.LBB4_5
# %bb.3:                                # %.lr.ph
	movslq	%ebp, %rax
	shlq	$2, %rax
	movq	(%rbx), %rcx
	addq	%rax, %rcx
	movl	$1, %edx
.LBB4_4:                                # =>This Inner Loop Header: Depth=1
	movq	%rcx, (%rbx,%rdx,8)
	incq	%rdx
	addq	%rax, %rcx
	cmpq	%rdx, %r15
	jne	.LBB4_4
.LBB4_5:                                # %.preheader27
	testl	%r14d, %r14d
	jle	.LBB4_10
# %bb.6:                                # %.preheader.lr.ph
	movl	%ebp, %r14d
	shlq	$2, %r14
	xorl	%r12d, %r12d
.LBB4_7:                                # %.preheader
                                        # =>This Inner Loop Header: Depth=1
	testl	%ebp, %ebp
	jle	.LBB4_9
# %bb.8:                                # %.lr.ph31
                                        #   in Loop: Header=BB4_7 Depth=1
	movq	(%rbx,%r12,8), %rdi
	xorl	%esi, %esi
	movq	%r14, %rdx
	callq	memset@PLT
.LBB4_9:                                # %._crit_edge
                                        #   in Loop: Header=BB4_7 Depth=1
	incq	%r12
	cmpq	%r12, %r15
	jne	.LBB4_7
.LBB4_10:                               # %.loopexit
	movq	%rbx, %rax
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.LBB4_11:
	.cfi_def_cfa_offset 48
	movq	stderr(%rip), %rcx
	movl	$.L.str.2, %edi
	movl	$27, %esi
	movl	$1, %edx
	callq	fwrite@PLT
	jmp	.LBB4_12
.LBB4_13:
	movq	stderr(%rip), %rcx
	movl	$.L.str.2, %edi
	movl	$27, %esi
	movl	$1, %edx
	callq	fwrite@PLT
	movq	%rbx, %rdi
	callq	free
.LBB4_12:                               # %.loopexit
	xorl	%ebx, %ebx
	jmp	.LBB4_10
.Lfunc_end4:
	.size	_Z11getmemory2Dii, .Lfunc_end4-_Z11getmemory2Dii
	.cfi_endproc
                                        # -- End function
	.globl	_Z11transpose2DPPfS0_i          # -- Begin function _Z11transpose2DPPfS0_i
	.type	_Z11transpose2DPPfS0_i,@function
_Z11transpose2DPPfS0_i:                 # @_Z11transpose2DPPfS0_i
	.cfi_startproc
# %bb.0:
	testl	%edx, %edx
	jle	.LBB5_5
# %bb.1:                                # %.preheader.lr.ph
	movl	%edx, %eax
	xorl	%ecx, %ecx
.LBB5_2:                                # %.lr.ph
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB5_3 Depth 2
	movq	(%rsi,%rcx,8), %rdx
	xorl	%r8d, %r8d
.LBB5_3:                                #   Parent Loop BB5_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movq	(%rdi,%r8,8), %r9
	movss	(%r9,%rcx,4), %xmm0             # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, (%rdx,%r8,4)
	incq	%r8
	cmpq	%r8, %rax
	jne	.LBB5_3
# %bb.4:                                # %._crit_edge
                                        #   in Loop: Header=BB5_2 Depth=1
	incq	%rcx
	cmpq	%rax, %rcx
	jne	.LBB5_2
.LBB5_5:                                # %._crit_edge15
	retq
.Lfunc_end5:
	.size	_Z11transpose2DPPfS0_i, .Lfunc_end5-_Z11transpose2DPPfS0_i
	.cfi_endproc
                                        # -- End function
	.globl	_Z11transpose1DPfS_i            # -- Begin function _Z11transpose1DPfS_i
	.type	_Z11transpose1DPfS_i,@function
_Z11transpose1DPfS_i:                   # @_Z11transpose1DPfS_i
	.cfi_startproc
# %bb.0:
	testl	%edx, %edx
	jle	.LBB6_6
# %bb.1:                                # %.preheader.lr.ph
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset %rbx, -16
	movl	%edx, %eax
	leaq	(,%rax,4), %rcx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
.LBB6_2:                                # %.lr.ph
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB6_3 Depth 2
	movl	%r8d, %r10d
	leaq	(%rsi,%r10,4), %r10
	movq	%rdi, %r11
	xorl	%ebx, %ebx
.LBB6_3:                                #   Parent Loop BB6_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movss	(%r11), %xmm0                   # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, (%r10,%rbx,4)
	incq	%rbx
	addq	%rcx, %r11
	cmpq	%rbx, %rax
	jne	.LBB6_3
# %bb.4:                                # %._crit_edge
                                        #   in Loop: Header=BB6_2 Depth=1
	incq	%r9
	addl	%edx, %r8d
	addq	$4, %rdi
	cmpq	%rax, %r9
	jne	.LBB6_2
# %bb.5:
	popq	%rbx
	.cfi_def_cfa_offset 8
	.cfi_restore %rbx
.LBB6_6:                                # %._crit_edge17
	retq
.Lfunc_end6:
	.size	_Z11transpose1DPfS_i, .Lfunc_end6-_Z11transpose1DPfS_i
	.cfi_endproc
                                        # -- End function
	.globl	_Z31__device_stub__transpose_devicePfS_ii # -- Begin function _Z31__device_stub__transpose_devicePfS_ii
	.type	_Z31__device_stub__transpose_devicePfS_ii,@function
_Z31__device_stub__transpose_devicePfS_ii: # @_Z31__device_stub__transpose_devicePfS_ii
	.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	12(%rsp), %rsi
	movl	%edx, (%rsi)
	leaq	8(%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	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	$_Z16transpose_devicePfS_ii, %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_end7:
	.size	_Z31__device_stub__transpose_devicePfS_ii, .Lfunc_end7-_Z31__device_stub__transpose_devicePfS_ii
	.cfi_endproc
                                        # -- End function
	.globl	_Z5checkPfS_i                   # -- Begin function _Z5checkPfS_i
	.type	_Z5checkPfS_i,@function
_Z5checkPfS_i:                          # @_Z5checkPfS_i
	.cfi_startproc
# %bb.0:
	testl	%edx, %edx
	jle	.LBB8_1
# %bb.3:                                # %.lr.ph.preheader
	movl	%edx, %eax
	xorl	%ecx, %ecx
.LBB8_4:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movss	(%rdi,%rcx,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	ucomiss	(%rsi,%rcx,4), %xmm0
	jne	.LBB8_5
	jp	.LBB8_5
# %bb.2:                                #   in Loop: Header=BB8_4 Depth=1
	incq	%rcx
	cmpq	%rcx, %rax
	jne	.LBB8_4
.LBB8_1:
	xorl	%eax, %eax
	retq
.LBB8_5:
	movl	$1, %eax
	retq
.Lfunc_end8:
	.size	_Z5checkPfS_i, .Lfunc_end8-_Z5checkPfS_i
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI9_0:
	.quad	0x412e848000000000              # double 1.0E+6
.LCPI9_1:
	.quad	0x3f50000000000000              # double 9.765625E-4
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	cmpl	$2, %edi
	jne	.LBB9_2
# %bb.1:
	movq	8(%rsi), %rdi
	callq	atoi
	movl	%eax, %ebx
	jmp	.LBB9_3
.LBB9_2:
	movl	$4096, %ebx                     # imm = 0x1000
	movl	$.L.str.3, %edi
	movl	$4096, %esi                     # imm = 0x1000
	xorl	%eax, %eax
	callq	printf
.LBB9_3:
	callq	_Z9init_seedv
	movl	%ebx, %edi
	movl	%ebx, %esi
	callq	_Z11getmemory2Dii
	movq	%rax, %r12
	movl	%ebx, %edi
	movl	%ebx, %esi
	callq	_Z11getmemory2Dii
	movq	%rax, %r13
	movl	%ebx, %ebp
	imull	%ebx, %ebp
	movl	%ebp, %edi
	callq	_Z11getmemory1Di
	movq	%rax, 24(%rsp)                  # 8-byte Spill
	movq	(%r12), %r15
	movq	(%r13), %r14
	movq	%r12, %rdi
	movl	%ebx, %esi
	callq	_Z10init2DrandPPfi
	xorl	%r12d, %r12d
	movl	$_ZL3tv0, %edi
	xorl	%esi, %esi
	callq	gettimeofday
	imulq	$1000000, _ZL3tv0(%rip), %rax   # imm = 0xF4240
	addq	_ZL3tv0+8(%rip), %rax
	cvtsi2sd	%rax, %xmm0
	movsd	%xmm0, (%rsp)                   # 8-byte Spill
	testl	%ebx, %ebx
	jle	.LBB9_8
# %bb.4:                                # %.preheader.lr.ph.i
	movl	%ebx, %eax
	leaq	(,%rax,4), %rcx
	movq	%r15, %rdx
	xorl	%esi, %esi
.LBB9_5:                                # %.lr.ph.i
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB9_6 Depth 2
	movl	%r12d, %edi
	leaq	(%r14,%rdi,4), %rdi
	movq	%rdx, %r8
	xorl	%r9d, %r9d
.LBB9_6:                                #   Parent Loop BB9_5 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movss	(%r8), %xmm0                    # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, (%rdi,%r9)
	addq	$4, %r9
	addq	%rcx, %r8
	cmpq	%r9, %rcx
	jne	.LBB9_6
# %bb.7:                                # %._crit_edge.i
                                        #   in Loop: Header=BB9_5 Depth=1
	incq	%rsi
	addl	%ebx, %r12d
	addq	$4, %rdx
	cmpq	%rax, %rsi
	jne	.LBB9_5
.LBB9_8:                                # %_Z11transpose1DPfS_i.exit
	movl	%ebp, %ebp
	leaq	(,%rbp,4), %r12
	xorps	%xmm0, %xmm0
	cvtsi2sd	%r12, %xmm0
	movsd	%xmm0, 8(%rsp)                  # 8-byte Spill
	movl	$_ZL3tv0, %edi
	xorl	%esi, %esi
	callq	gettimeofday
	imulq	$1000000, _ZL3tv0(%rip), %rax   # imm = 0xF4240
	addq	_ZL3tv0+8(%rip), %rax
	cvtsi2sd	%rax, %xmm1
	subsd	(%rsp), %xmm1                   # 8-byte Folded Reload
	divsd	.LCPI9_0(%rip), %xmm1
	movsd	8(%rsp), %xmm0                  # 8-byte Reload
                                        # xmm0 = mem[0],zero
	divsd	%xmm1, %xmm0
	movsd	.LCPI9_1(%rip), %xmm1           # xmm1 = mem[0],zero
	mulsd	%xmm1, %xmm0
	mulsd	%xmm1, %xmm0
	movl	$.L.str.4, %edi
	movb	$1, %al
	callq	printf
	leaq	32(%rsp), %r13
	movq	%r13, %rdi
	movq	%r12, %rsi
	callq	hipMalloc
	movq	(%r13), %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	leaq	16(%rsp), %rdi
	movq	%r12, %rsi
	callq	hipMalloc
	leal	31(%rbx), %eax
	leal	62(%rbx), %ecx
	testl	%eax, %eax
	cmovnsl	%eax, %ecx
	sarl	$5, %ecx
	movq	%rcx, %r15
	shlq	$32, %r15
	orq	%rcx, %r15
	movl	$_ZL3tv0, %edi
	xorl	%esi, %esi
	callq	gettimeofday
	imulq	$1000000, _ZL3tv0(%rip), %rax   # imm = 0xF4240
	addq	_ZL3tv0+8(%rip), %rax
	xorps	%xmm0, %xmm0
	cvtsi2sd	%rax, %xmm0
	movsd	%xmm0, (%rsp)                   # 8-byte Spill
	movabsq	$137438953504, %rdx             # imm = 0x2000000020
	movq	%r15, %rdi
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB9_10
# %bb.9:
	movq	32(%rsp), %rdi
	movq	16(%rsp), %rsi
	movl	%ebx, %edx
	movl	%ebx, %ecx
	callq	_Z31__device_stub__transpose_devicePfS_ii
.LBB9_10:
	movq	16(%rsp), %rsi
	movq	24(%rsp), %r15                  # 8-byte Reload
	movq	%r15, %rdi
	movq	%r12, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	callq	hipDeviceSynchronize
	movl	$_ZL3tv0, %edi
	xorl	%esi, %esi
	callq	gettimeofday
	imulq	$1000000, _ZL3tv0(%rip), %rax   # imm = 0xF4240
	addq	_ZL3tv0+8(%rip), %rax
	xorps	%xmm1, %xmm1
	cvtsi2sd	%rax, %xmm1
	subsd	(%rsp), %xmm1                   # 8-byte Folded Reload
	divsd	.LCPI9_0(%rip), %xmm1
	movsd	8(%rsp), %xmm0                  # 8-byte Reload
                                        # xmm0 = mem[0],zero
	divsd	%xmm1, %xmm0
	movsd	.LCPI9_1(%rip), %xmm1           # xmm1 = mem[0],zero
	mulsd	%xmm1, %xmm0
	mulsd	%xmm1, %xmm0
	movl	$.L.str.5, %edi
	movb	$1, %al
	callq	printf
	testl	%ebx, %ebx
	je	.LBB9_15
# %bb.11:                               # %.lr.ph.i48.preheader
	xorl	%eax, %eax
.LBB9_13:                               # %.lr.ph.i48
                                        # =>This Inner Loop Header: Depth=1
	movss	(%r15,%rax,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	ucomiss	(%r14,%rax,4), %xmm0
	jne	.LBB9_14
	jp	.LBB9_14
# %bb.12:                               #   in Loop: Header=BB9_13 Depth=1
	incq	%rax
	cmpq	%rax, %rbp
	jne	.LBB9_13
	jmp	.LBB9_15
.LBB9_14:                               # %_Z5checkPfS_i.exit
	movl	$.Lstr, %edi
	callq	puts@PLT
.LBB9_15:                               # %_Z5checkPfS_i.exit.thread
	xorl	%eax, %eax
	addq	$40, %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_end9:
	.size	main, .Lfunc_end9-main
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	jne	.LBB10_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB10_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z16transpose_devicePfS_ii, %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_end10:
	.size	__hip_module_ctor, .Lfunc_end10-__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	.LBB11_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
.LBB11_2:
	retq
.Lfunc_end11:
	.size	__hip_module_dtor, .Lfunc_end11-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	_ZL3tv0,@object                 # @_ZL3tv0
	.local	_ZL3tv0
	.comm	_ZL3tv0,16,8
	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"/dev/urandom"
	.size	.L.str, 13

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

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"ERROR in memory allocation\n"
	.size	.L.str.2, 28

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

	.type	.L.str.3,@object                # @.str.3
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.3:
	.asciz	"./exec n (by default n=%i)\n"
	.size	.L.str.3, 28

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"Transpose version 1D: %f MB/s\n"
	.size	.L.str.4, 31

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"Transpose kernel version: %f MB/s\n"
	.size	.L.str.5, 35

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z16transpose_devicePfS_ii"
	.size	.L__unnamed_1, 27

	.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	"Transpose CPU-GPU differs!!"
	.size	.Lstr, 28

	.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 _Z31__device_stub__transpose_devicePfS_ii
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _ZL3tv0
	.addrsig_sym _Z16transpose_devicePfS_ii
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z16transpose_devicePfS_ii ; -- Begin function _Z16transpose_devicePfS_ii
	.globl	_Z16transpose_devicePfS_ii
	.p2align	8
	.type	_Z16transpose_devicePfS_ii,@function
_Z16transpose_devicePfS_ii:             ; @_Z16transpose_devicePfS_ii
; %bb.0:
	s_clause 0x2
	s_load_b32 s8, s[0:1], 0x24
	s_load_b64 s[2:3], s[0:1], 0x10
	s_load_b128 s[4:7], s[0:1], 0x0
	v_and_b32_e32 v1, 0x3ff, v0
	v_bfe_u32 v2, v0, 10, 10
	s_waitcnt lgkmcnt(0)
	s_and_b32 s0, s8, 0xffff
	s_lshr_b32 s1, s8, 16
	s_mul_i32 s14, s14, s0
	s_mul_i32 s15, s15, s1
	v_add_nc_u32_e32 v0, s14, v1
	v_add_nc_u32_e32 v3, s15, v2
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_cmp_gt_i32_e32 vcc_lo, s2, v0
	v_cmp_gt_i32_e64 s0, s3, v3
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_and_b32 s1, vcc_lo, s0
	s_and_saveexec_b32 s0, s1
	s_cbranch_execz .LBB0_2
; %bb.1:
	v_mad_u64_u32 v[4:5], null, v3, s2, v[0:1]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v5, 31, v4
	v_lshlrev_b64 v[3:4], 2, v[4:5]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v3, vcc_lo, s4, v3
	v_add_co_ci_u32_e32 v4, vcc_lo, s5, v4, vcc_lo
	global_load_b32 v0, v[3:4], off
	v_lshlrev_b32_e32 v3, 2, v1
	s_delay_alu instid0(VALU_DEP_1)
	v_mad_u32_u24 v3, 0x84, v2, v3
	s_waitcnt vmcnt(0)
	ds_store_b32 v3, v0
.LBB0_2:
	s_or_b32 exec_lo, exec_lo, s0
	v_add_nc_u32_e32 v0, s15, v1
	v_add_nc_u32_e32 v3, s14, v2
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	v_cmp_gt_i32_e32 vcc_lo, s2, v0
	v_cmp_gt_i32_e64 s0, s3, v3
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_and_b32 s0, s0, vcc_lo
	s_and_saveexec_b32 s1, s0
	s_cbranch_execz .LBB0_4
; %bb.3:
	v_lshlrev_b32_e32 v2, 2, v2
	v_mad_u64_u32 v[4:5], null, v3, s2, v[0:1]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_mad_u32_u24 v0, 0x84, v1, v2
	v_ashrrev_i32_e32 v5, 31, v4
	ds_load_b32 v2, v0
	v_lshlrev_b64 v[0:1], 2, v[4:5]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v0, vcc_lo, s6, v0
	v_add_co_ci_u32_e32 v1, vcc_lo, s7, v1, vcc_lo
	s_waitcnt lgkmcnt(0)
	global_store_b32 v[0:1], v2, off
.LBB0_4:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z16transpose_devicePfS_ii
		.amdhsa_group_segment_fixed_size 4224
		.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 6
		.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	_Z16transpose_devicePfS_ii, .Lfunc_end0-_Z16transpose_devicePfS_ii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 332
; NumSgprs: 18
; NumVgprs: 6
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 4224 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 6
; 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:         20
        .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: 4224
    .kernarg_segment_align: 8
    .kernarg_segment_size: 280
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z16transpose_devicePfS_ii
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z16transpose_devicePfS_ii.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     6
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
