
#include <stdio.h>
#include "cuda_runtime.h"
#include <sys/time.h>

double cpuSecond() {
  struct timeval tp;
  gettimeofday(&tp,NULL);
  return ((double)tp.tv_sec + (double)tp.tv_usec*1.e-6);
}

void printMatrix(float *C, const int nx, const int ny) {
  float *ic = C;    //бережем оригинальный массив от изменения
  for (int iy = 0; iy < ny; iy++) {
    for (int ix = 0; ix < nx; ix++) {
      printf("%f\t", ic[ix]);
    }
    ic += nx;   //переставляем указатель
    printf("\n");   //печатаем новую строку
  }
  printf("============================================================================\n");
}

void checkResult(float * hostRes, float * devRes, const int nxy) {
  double eps = 1*0E-8;
  bool match = 1;
  int idx = 0;
  while (match && idx < nxy) {
    if (abs(hostRes[idx] - devRes[idx]) > eps) {
      match = 0;
      printf("Results do not match!\n");
    }
    idx++;
  }
  if (idx == nxy) {
    printf("Success: results match!\n");
  }
}
  void sumMatrixOnHost(float * const A, float * const B, float * C, const int nx, const int ny ) {
  //verification function
    float * ia = A;
    float * ib = B;
    float * ic = C;
    for (int iy = 0; iy < ny; iy++) {     //ny раз
      for (int ix = 0; ix < nx; ix++) {     //каждый элемент в отдельно взятой строке матрицы 
        ic[ix] = ia[ix] + ib[ix];
//         printf("%f\t", ic[ix]);
      }
      ia += nx; ib += nx; ic += nx;   //вот так вот просто переставляем указатели на следующую строку
//       printf("\n");
    }
//     printf("============================================================================\n");
  }

  __global__ void sumMatrixOnGPU(float * devA, float * devB, float * devC, const int nx, const int ny) {
    //подчитываем глобальный индекс
    int ix = threadIdx.x + blockIdx.x * blockDim.x;   //по x
    int iy = threadIdx.y + blockIdx.y * blockDim.y;   //по y
    //и совсем уже глобальный индекс нити:
    int ixy = iy * nx + ix;
    
    if (ix < nx && iy < ny) {
      devC[ixy] = devA[ixy] + devB[ixy];
    }
  }

  void initialFlt(float * ip, unsigned sz){
    for (unsigned i = 0; i < sz; i++)
      ip[i] = (float) (i);
  }

  void testSumOnGPU(float * const A, float * const B, float * C, const int nx, const int ny) {  
    int gpu = 0;
    double iStart = cpuSecond();
    cudaSetDevice(gpu);
    
    int nBytes = nx * ny * sizeof(float);
    //init device pointers
    float * devA, * devB, * devC;
    //не забывать правильно выделять память под массивы на устройстве!
    cudaMalloc((void **) &devA, nBytes);
    cudaMalloc((void **) &devB, nBytes);
    cudaMalloc((void **) &devC, nBytes);
    //copy data to GPU memory
    cudaMemcpy(devA, A, nBytes, cudaMemcpyHostToDevice);
    cudaMemcpy(devB, B, nBytes, cudaMemcpyHostToDevice);
    
    //setup grid paramters
    int dimx = 32;
    int dimy = 32;
    dim3 block(dimx, dimy);
    dim3 grid((nx + block.x - 1)/block.x, (ny + block.y -1)/block.y);
    
    //invoke kernel
    sumMatrixOnGPU<<<grid, block>>>(devA, devB, devC, nx, ny);
    cudaDeviceSynchronize();
    //copy result from GPU to host 
    //куда на хотсте, откуда на девайсе, размер, направление
    cudaMemcpy(C, devC, nBytes, cudaMemcpyDeviceToHost);
    
    cudaDeviceSynchronize();
    double iEnd = cpuSecond();
    printf ("Test sumMatrixOnGPU<<<(%d, %d), (%d, %d)>>>. \nEsplaced time: %f\n", grid.x, grid.y, block.x, block.y, (iEnd - iStart));
    
    //check out result:
//     printMatrix(C, nx, ny);
    
    //set memory free
    cudaFree(devA);
    cudaFree(devB);
    cudaFree(devC);
    
    cudaDeviceReset();
  }

int main() {
    //==================настраиваем среду для теста===================
    //создадим две матрицы (точнее, указателя на них)
    float *A, *B, *hostRes, *devRes;
    // размерность складываемых матриц
    const int nx = 1 << 12;
    const int ny = 1 << 12;
    const int nxy = nx*ny;
    
    //узнаем размер матриц в байтах
    int nBytes = nxy * sizeof(float);
    
    //выделяем память под матрицы
    A = (float *) malloc(nBytes);
    B = (float *) malloc(nBytes);
    hostRes = (float *) malloc(nBytes);
    devRes = (float *) malloc(nBytes);
    
    //инициализируем матрицы
    initialFlt(A, nxy);
//     printMatrix(A, nx, ny);
    
    initialFlt(B, nxy);
//     printMatrix(B, nx, ny);
    
    //==================тестирование и тайминг ===================
    double iStart, iEnd;
    
    //==================тестирование на хосте===================
    iStart = cpuSecond();
    sumMatrixOnHost(A, B, hostRes, nx, ny);
    iEnd = cpuSecond();
    printf ("Test sumMatrixOnHost. \nEsplaced time: %f\n", (iEnd - iStart));
//     printMatrix(hostRes, nx, ny);
    
    //==================тестирование на девайсе===================
//     int dimx = 32;
//     int dimy = 32;
//     iStart = cpuSecond();
    testSumOnGPU(A, B, devRes, nx, ny);
//     iEnd = cpuSecond();
//     printf ("Test sumMatrixOnGPU<<<>>>. \nEsplaced time: %f\n", (iEnd - iStart));
    
    //==================проверяем совпадение результата===================
    checkResult(hostRes, devRes, nxy);

    //set memory free
    free(A);
    free(B);
    free(hostRes);
    free(devRes);
    
    return 0;
}

	.file	"tmpxft_00386cf8_00000000-6_sumMatrixOnGPU2d-grid.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2036:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2036:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z9cpuSecondv
	.type	_Z9cpuSecondv, @function
_Z9cpuSecondv:
.LFB2027:
	.cfi_startproc
	endbr64
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	xorl	%esi, %esi
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rdi
	call	gettimeofday@PLT
	cvtsi2sdq	16(%rsp), %xmm0
	mulsd	.LC0(%rip), %xmm0
	cvtsi2sdq	8(%rsp), %xmm1
	addsd	%xmm1, %xmm0
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	je	.L3
	call	__stack_chk_fail@PLT
.L3:
	addq	$40, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2027:
	.size	_Z9cpuSecondv, .-_Z9cpuSecondv
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC1:
	.string	"%f\t"
.LC2:
	.string	"\n"
.LC3:
	.string	"============================================================================\n"
	.text
	.globl	_Z11printMatrixPfii
	.type	_Z11printMatrixPfii, @function
_Z11printMatrixPfii:
.LFB2028:
	.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
	movslq	%esi, %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	xorl	%r13d, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movl	%edx, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%r14, %rbp
	salq	$2, %r14
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	%rdi, %rbx
	pushq	%rcx
	.cfi_def_cfa_offset 64
.L7:
	cmpl	%r12d, %r13d
	jge	.L12
	xorl	%r15d, %r15d
.L9:
	cmpl	%r15d, %ebp
	jle	.L13
	leaq	.LC1(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	cvtss2sd	(%rbx,%r15,4), %xmm0
	call	__printf_chk@PLT
	incq	%r15
	jmp	.L9
.L13:
	leaq	.LC2(%rip), %rsi
	xorl	%eax, %eax
	addq	%r14, %rbx
	incl	%r13d
	movl	$2, %edi
	call	__printf_chk@PLT
	jmp	.L7
.L12:
	popq	%rdx
	.cfi_def_cfa_offset 56
	leaq	.LC3(%rip), %rsi
	popq	%rbx
	.cfi_def_cfa_offset 48
	movl	$2, %edi
	popq	%rbp
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	jmp	__printf_chk@PLT
	.cfi_endproc
.LFE2028:
	.size	_Z11printMatrixPfii, .-_Z11printMatrixPfii
	.section	.rodata.str1.1
.LC6:
	.string	"Results do not match!\n"
.LC7:
	.string	"Success: results match!\n"
	.text
	.globl	_Z11checkResultPfS_i
	.type	_Z11checkResultPfS_i, @function
_Z11checkResultPfS_i:
.LFB2029:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	movq	%rsi, %r13
	movb	$1, %al
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	movq	%rdi, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	movl	%edx, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	xorl	%ebx, %ebx
	pushq	%rcx
	.cfi_def_cfa_offset 48
.L15:
	cmpl	%ebx, %ebp
	setg	%dl
	andb	%dl, %al
	je	.L22
	movss	(%r12,%rbx,4), %xmm0
	subss	0(%r13,%rbx,4), %xmm0
	xorps	%xmm1, %xmm1
	andps	.LC4(%rip), %xmm0
	comiss	%xmm1, %xmm0
	jbe	.L16
	leaq	.LC6(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	xorl	%eax, %eax
.L16:
	incq	%rbx
	jmp	.L15
.L22:
	cmpl	%ebx, %ebp
	jne	.L14
	popq	%rdx
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	leaq	.LC7(%rip), %rsi
	popq	%rbx
	.cfi_def_cfa_offset 32
	movl	$2, %edi
	popq	%rbp
	.cfi_def_cfa_offset 24
	xorl	%eax, %eax
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	jmp	__printf_chk@PLT
.L14:
	.cfi_restore_state
	popq	%rax
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2029:
	.size	_Z11checkResultPfS_i, .-_Z11checkResultPfS_i
	.globl	_Z15sumMatrixOnHostPfS_S_ii
	.type	_Z15sumMatrixOnHostPfS_S_ii, @function
_Z15sumMatrixOnHostPfS_S_ii:
.LFB2030:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movslq	%ecx, %r11
	movq	%rsi, %r9
	movq	%rdx, %r10
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	salq	$2, %r11
	xorl	%edx, %edx
	xorl	%esi, %esi
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
.L24:
	leaq	(%r10,%rdx), %r12
	leaq	(%r9,%rdx), %rbp
	leaq	(%rdi,%rdx), %rbx
	cmpl	%r8d, %esi
	jge	.L29
	xorl	%eax, %eax
.L26:
	cmpl	%eax, %ecx
	jle	.L30
	movss	(%rbx,%rax,4), %xmm0
	addss	0(%rbp,%rax,4), %xmm0
	movss	%xmm0, (%r12,%rax,4)
	incq	%rax
	jmp	.L26
.L30:
	incl	%esi
	addq	%r11, %rdx
	jmp	.L24
.L29:
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2030:
	.size	_Z15sumMatrixOnHostPfS_S_ii, .-_Z15sumMatrixOnHostPfS_S_ii
	.globl	_Z10initialFltPfj
	.type	_Z10initialFltPfj, @function
_Z10initialFltPfj:
.LFB2031:
	.cfi_startproc
	endbr64
	xorl	%eax, %eax
.L32:
	cmpl	%esi, %eax
	jnb	.L36
	movl	%eax, %edx
	cvtsi2ssq	%rdx, %xmm0
	movss	%xmm0, (%rdi,%rax,4)
	incq	%rax
	jmp	.L32
.L36:
	ret
	.cfi_endproc
.LFE2031:
	.size	_Z10initialFltPfj, .-_Z10initialFltPfj
	.globl	_Z40__device_stub__Z14sumMatrixOnGPUPfS_S_iiPfS_S_ii
	.type	_Z40__device_stub__Z14sumMatrixOnGPUPfS_S_iiPfS_S_ii, @function
_Z40__device_stub__Z14sumMatrixOnGPUPfS_S_iiPfS_S_ii:
.LFB2058:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movq	%rdi, 24(%rsp)
	leaq	48(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	60(%rsp), %rsi
	movq	%rdx, 8(%rsp)
	leaq	32(%rsp), %rdx
	movl	%ecx, 4(%rsp)
	leaq	40(%rsp), %rcx
	movl	%r8d, (%rsp)
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 56(%rsp)
	movq	%rax, 96(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 104(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	4(%rsp), %rax
	movq	%rax, 120(%rsp)
	movq	%rsp, %rax
	movq	%rax, 128(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 48(%rsp)
	movq	%rax, 60(%rsp)
	movl	$1, 68(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L37
	pushq	40(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z14sumMatrixOnGPUPfS_S_ii(%rip), %rdi
	pushq	40(%rsp)
	.cfi_def_cfa_offset 176
	movq	76(%rsp), %rcx
	movl	84(%rsp), %r8d
	movq	64(%rsp), %rsi
	movl	72(%rsp), %edx
	leaq	112(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 168
	popq	%rdx
	.cfi_def_cfa_offset 160
.L37:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L39
	call	__stack_chk_fail@PLT
.L39:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2058:
	.size	_Z40__device_stub__Z14sumMatrixOnGPUPfS_S_iiPfS_S_ii, .-_Z40__device_stub__Z14sumMatrixOnGPUPfS_S_iiPfS_S_ii
	.globl	_Z14sumMatrixOnGPUPfS_S_ii
	.type	_Z14sumMatrixOnGPUPfS_S_ii, @function
_Z14sumMatrixOnGPUPfS_S_ii:
.LFB2059:
	.cfi_startproc
	endbr64
	jmp	_Z40__device_stub__Z14sumMatrixOnGPUPfS_S_iiPfS_S_ii
	.cfi_endproc
.LFE2059:
	.size	_Z14sumMatrixOnGPUPfS_S_ii, .-_Z14sumMatrixOnGPUPfS_S_ii
	.section	.rodata.str1.1
.LC8:
	.string	"Test sumMatrixOnGPU<<<(%d, %d), (%d, %d)>>>. \nEsplaced time: %f\n"
	.text
	.globl	_Z12testSumOnGPUPfS_S_ii
	.type	_Z12testSumOnGPUPfS_S_ii, @function
_Z12testSumOnGPUPfS_S_ii:
.LFB2032:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movq	%rdx, %r15
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movq	%rdi, %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%rsi, %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movl	%r8d, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movl	%ecx, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movl	%ebp, %ebx
	imull	%r12d, %ebx
	subq	$88, %rsp
	.cfi_def_cfa_offset 144
	movq	%fs:40, %rax
	movq	%rax, 72(%rsp)
	xorl	%eax, %eax
	sall	$2, %ebx
	call	_Z9cpuSecondv
	movslq	%ebx, %rbx
	xorl	%edi, %edi
	movsd	%xmm0, 8(%rsp)
	call	cudaSetDevice@PLT
	leaq	24(%rsp), %rdi
	movq	%rbx, %rsi
	call	cudaMalloc@PLT
	leaq	32(%rsp), %rdi
	movq	%rbx, %rsi
	call	cudaMalloc@PLT
	leaq	40(%rsp), %rdi
	movq	%rbx, %rsi
	call	cudaMalloc@PLT
	movq	24(%rsp), %rdi
	movq	%r14, %rsi
	movq	%rbx, %rdx
	movl	$1, %ecx
	leal	31(%r12), %r14d
	call	cudaMemcpy@PLT
	movq	%r13, %rsi
	movq	32(%rsp), %rdi
	movq	%rbx, %rdx
	leal	31(%rbp), %r13d
	movl	$1, %ecx
	shrl	$5, %r14d
	call	cudaMemcpy@PLT
	shrl	$5, %r13d
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	%r13d, 60(%rsp)
	movl	$1, %ecx
	movl	$1, %esi
	movabsq	$137438953504, %rdx
	movl	%r14d, 64(%rsp)
	movq	60(%rsp), %rdi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L43
	movq	40(%rsp), %rdx
	movq	32(%rsp), %rsi
	movl	%r12d, %r8d
	movl	%ebp, %ecx
	movq	24(%rsp), %rdi
	call	_Z40__device_stub__Z14sumMatrixOnGPUPfS_S_iiPfS_S_ii
.L43:
	call	cudaDeviceSynchronize@PLT
	movq	40(%rsp), %rsi
	movq	%rbx, %rdx
	movq	%r15, %rdi
	movl	$2, %ecx
	call	cudaMemcpy@PLT
	call	cudaDeviceSynchronize@PLT
	call	_Z9cpuSecondv
	subsd	8(%rsp), %xmm0
	movl	%r14d, %ecx
	movb	$1, %al
	movl	$32, %r9d
	movl	$32, %r8d
	movl	%r13d, %edx
	movl	$2, %edi
	leaq	.LC8(%rip), %rsi
	call	__printf_chk@PLT
	movq	24(%rsp), %rdi
	call	cudaFree@PLT
	movq	32(%rsp), %rdi
	call	cudaFree@PLT
	movq	40(%rsp), %rdi
	call	cudaFree@PLT
	call	cudaDeviceReset@PLT
	movq	72(%rsp), %rax
	subq	%fs:40, %rax
	je	.L44
	call	__stack_chk_fail@PLT
.L44:
	addq	$88, %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
.LFE2032:
	.size	_Z12testSumOnGPUPfS_S_ii, .-_Z12testSumOnGPUPfS_S_ii
	.section	.rodata.str1.1
.LC9:
	.string	"Test sumMatrixOnHost. \nEsplaced time: %f\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2033:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	movl	$67108864, %edi
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$24, %rsp
	.cfi_def_cfa_offset 64
	call	malloc@PLT
	movl	$67108864, %edi
	movq	%rax, %rbp
	call	malloc@PLT
	movl	$67108864, %edi
	movq	%rax, %rbx
	call	malloc@PLT
	movl	$67108864, %edi
	movq	%rax, %r13
	call	malloc@PLT
	movl	$16777216, %esi
	movq	%rbp, %rdi
	movq	%rax, %r12
	call	_Z10initialFltPfj
	movq	%rbx, %rdi
	call	_Z10initialFltPfj
	call	_Z9cpuSecondv
	movq	%r13, %rdx
	movl	$4096, %ecx
	movq	%rbx, %rsi
	movl	$4096, %r8d
	movq	%rbp, %rdi
	movsd	%xmm0, 8(%rsp)
	call	_Z15sumMatrixOnHostPfS_S_ii
	call	_Z9cpuSecondv
	subsd	8(%rsp), %xmm0
	leaq	.LC9(%rip), %rsi
	movb	$1, %al
	movl	$2, %edi
	call	__printf_chk@PLT
	movl	$4096, %ecx
	movq	%r12, %rdx
	movq	%rbx, %rsi
	movl	$4096, %r8d
	movq	%rbp, %rdi
	call	_Z12testSumOnGPUPfS_S_ii
	movq	%r12, %rsi
	movl	$16777216, %edx
	movq	%r13, %rdi
	call	_Z11checkResultPfS_i
	movq	%rbp, %rdi
	call	free@PLT
	movq	%rbx, %rdi
	call	free@PLT
	movq	%r13, %rdi
	call	free@PLT
	movq	%r12, %rdi
	call	free@PLT
	addq	$24, %rsp
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2033:
	.size	main, .-main
	.section	.rodata.str1.1
.LC10:
	.string	"_Z14sumMatrixOnGPUPfS_S_ii"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2061:
	.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	.LC10(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z14sumMatrixOnGPUPfS_S_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
.LFE2061:
	.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	-1598689907
	.long	1051772663
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC4:
	.long	2147483647
	.long	0
	.long	0
	.long	0
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:


#include <stdio.h>
#include "hip/hip_runtime.h"
#include <sys/time.h>

double cpuSecond() {
  struct timeval tp;
  gettimeofday(&tp,NULL);
  return ((double)tp.tv_sec + (double)tp.tv_usec*1.e-6);
}

void printMatrix(float *C, const int nx, const int ny) {
  float *ic = C;    //бережем оригинальный массив от изменения
  for (int iy = 0; iy < ny; iy++) {
    for (int ix = 0; ix < nx; ix++) {
      printf("%f\t", ic[ix]);
    }
    ic += nx;   //переставляем указатель
    printf("\n");   //печатаем новую строку
  }
  printf("============================================================================\n");
}

void checkResult(float * hostRes, float * devRes, const int nxy) {
  double eps = 1*0E-8;
  bool match = 1;
  int idx = 0;
  while (match && idx < nxy) {
    if (abs(hostRes[idx] - devRes[idx]) > eps) {
      match = 0;
      printf("Results do not match!\n");
    }
    idx++;
  }
  if (idx == nxy) {
    printf("Success: results match!\n");
  }
}
  void sumMatrixOnHost(float * const A, float * const B, float * C, const int nx, const int ny ) {
  //verification function
    float * ia = A;
    float * ib = B;
    float * ic = C;
    for (int iy = 0; iy < ny; iy++) {     //ny раз
      for (int ix = 0; ix < nx; ix++) {     //каждый элемент в отдельно взятой строке матрицы 
        ic[ix] = ia[ix] + ib[ix];
//         printf("%f\t", ic[ix]);
      }
      ia += nx; ib += nx; ic += nx;   //вот так вот просто переставляем указатели на следующую строку
//       printf("\n");
    }
//     printf("============================================================================\n");
  }

  __global__ void sumMatrixOnGPU(float * devA, float * devB, float * devC, const int nx, const int ny) {
    //подчитываем глобальный индекс
    int ix = threadIdx.x + blockIdx.x * blockDim.x;   //по x
    int iy = threadIdx.y + blockIdx.y * blockDim.y;   //по y
    //и совсем уже глобальный индекс нити:
    int ixy = iy * nx + ix;
    
    if (ix < nx && iy < ny) {
      devC[ixy] = devA[ixy] + devB[ixy];
    }
  }

  void initialFlt(float * ip, unsigned sz){
    for (unsigned i = 0; i < sz; i++)
      ip[i] = (float) (i);
  }

  void testSumOnGPU(float * const A, float * const B, float * C, const int nx, const int ny) {  
    int gpu = 0;
    double iStart = cpuSecond();
    hipSetDevice(gpu);
    
    int nBytes = nx * ny * sizeof(float);
    //init device pointers
    float * devA, * devB, * devC;
    //не забывать правильно выделять память под массивы на устройстве!
    hipMalloc((void **) &devA, nBytes);
    hipMalloc((void **) &devB, nBytes);
    hipMalloc((void **) &devC, nBytes);
    //copy data to GPU memory
    hipMemcpy(devA, A, nBytes, hipMemcpyHostToDevice);
    hipMemcpy(devB, B, nBytes, hipMemcpyHostToDevice);
    
    //setup grid paramters
    int dimx = 32;
    int dimy = 32;
    dim3 block(dimx, dimy);
    dim3 grid((nx + block.x - 1)/block.x, (ny + block.y -1)/block.y);
    
    //invoke kernel
    sumMatrixOnGPU<<<grid, block>>>(devA, devB, devC, nx, ny);
    hipDeviceSynchronize();
    //copy result from GPU to host 
    //куда на хотсте, откуда на девайсе, размер, направление
    hipMemcpy(C, devC, nBytes, hipMemcpyDeviceToHost);
    
    hipDeviceSynchronize();
    double iEnd = cpuSecond();
    printf ("Test sumMatrixOnGPU<<<(%d, %d), (%d, %d)>>>. \nEsplaced time: %f\n", grid.x, grid.y, block.x, block.y, (iEnd - iStart));
    
    //check out result:
//     printMatrix(C, nx, ny);
    
    //set memory free
    hipFree(devA);
    hipFree(devB);
    hipFree(devC);
    
    hipDeviceReset();
  }

int main() {
    //==================настраиваем среду для теста===================
    //создадим две матрицы (точнее, указателя на них)
    float *A, *B, *hostRes, *devRes;
    // размерность складываемых матриц
    const int nx = 1 << 12;
    const int ny = 1 << 12;
    const int nxy = nx*ny;
    
    //узнаем размер матриц в байтах
    int nBytes = nxy * sizeof(float);
    
    //выделяем память под матрицы
    A = (float *) malloc(nBytes);
    B = (float *) malloc(nBytes);
    hostRes = (float *) malloc(nBytes);
    devRes = (float *) malloc(nBytes);
    
    //инициализируем матрицы
    initialFlt(A, nxy);
//     printMatrix(A, nx, ny);
    
    initialFlt(B, nxy);
//     printMatrix(B, nx, ny);
    
    //==================тестирование и тайминг ===================
    double iStart, iEnd;
    
    //==================тестирование на хосте===================
    iStart = cpuSecond();
    sumMatrixOnHost(A, B, hostRes, nx, ny);
    iEnd = cpuSecond();
    printf ("Test sumMatrixOnHost. \nEsplaced time: %f\n", (iEnd - iStart));
//     printMatrix(hostRes, nx, ny);
    
    //==================тестирование на девайсе===================
//     int dimx = 32;
//     int dimy = 32;
//     iStart = cpuSecond();
    testSumOnGPU(A, B, devRes, nx, ny);
//     iEnd = cpuSecond();
//     printf ("Test sumMatrixOnGPU<<<>>>. \nEsplaced time: %f\n", (iEnd - iStart));
    
    //==================проверяем совпадение результата===================
    checkResult(hostRes, devRes, nxy);

    //set memory free
    free(A);
    free(B);
    free(hostRes);
    free(devRes);
    
    return 0;
}

	.text
	.file	"sumMatrixOnGPU2d-grid.hip"
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z9cpuSecondv
.LCPI0_0:
	.quad	0x3eb0c6f7a0b5ed8d              # double 9.9999999999999995E-7
	.text
	.globl	_Z9cpuSecondv
	.type	_Z9cpuSecondv,@function
_Z9cpuSecondv:                          # @_Z9cpuSecondv
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$16, %rsp
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -16
	movq	%rsp, %rbx
	movq	%rbx, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	cvtsi2sdq	(%rbx), %xmm1
	cvtsi2sdq	8(%rbx), %xmm0
	mulsd	.LCPI0_0(%rip), %xmm0
	addsd	%xmm1, %xmm0
	addq	$16, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	_Z9cpuSecondv, .Lfunc_end0-_Z9cpuSecondv
	.cfi_endproc
                                        # -- End function
	.globl	_Z11printMatrixPfii             # -- Begin function _Z11printMatrixPfii
	.type	_Z11printMatrixPfii,@function
_Z11printMatrixPfii:                    # @_Z11printMatrixPfii
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	pushq	%rax
	.cfi_def_cfa_offset 64
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	%esi, 4(%rsp)                   # 4-byte Spill
	testl	%edx, %edx
	jle	.LBB1_6
# %bb.1:                                # %.preheader.lr.ph
	movl	%edx, %ebx
	movq	%rdi, %r14
	movslq	4(%rsp), %r15                   # 4-byte Folded Reload
	movl	%r15d, %r12d
	shlq	$2, %r15
	xorl	%r13d, %r13d
.LBB1_2:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_4 Depth 2
	cmpl	$0, 4(%rsp)                     # 4-byte Folded Reload
	jle	.LBB1_5
# %bb.3:                                # %.lr.ph.preheader
                                        #   in Loop: Header=BB1_2 Depth=1
	xorl	%ebp, %ebp
.LBB1_4:                                # %.lr.ph
                                        #   Parent Loop BB1_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	xorps	%xmm0, %xmm0
	cvtss2sd	(%r14,%rbp,4), %xmm0
	movl	$.L.str, %edi
	movb	$1, %al
	callq	printf
	incq	%rbp
	cmpq	%rbp, %r12
	jne	.LBB1_4
.LBB1_5:                                # %._crit_edge
                                        #   in Loop: Header=BB1_2 Depth=1
	movl	$10, %edi
	callq	putchar@PLT
	incl	%r13d
	addq	%r15, %r14
	cmpl	%ebx, %r13d
	jne	.LBB1_2
.LBB1_6:                                # %._crit_edge16
	movl	$.Lstr, %edi
	addq	$8, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	jmp	puts@PLT                        # TAILCALL
.Lfunc_end1:
	.size	_Z11printMatrixPfii, .Lfunc_end1-_Z11printMatrixPfii
	.cfi_endproc
                                        # -- End function
	.globl	_Z11checkResultPfS_i            # -- Begin function _Z11checkResultPfS_i
	.type	_Z11checkResultPfS_i,@function
_Z11checkResultPfS_i:                   # @_Z11checkResultPfS_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
	testl	%edx, %edx
	jle	.LBB2_1
# %bb.2:                                # %.lr.ph.preheader
	movl	%ebx, %eax
	xorl	%r14d, %r14d
	xorps	%xmm0, %xmm0
.LBB2_3:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movss	(%rdi,%r14,4), %xmm1            # xmm1 = mem[0],zero,zero,zero
	subss	(%rsi,%r14,4), %xmm1
	ucomiss	%xmm0, %xmm1
	jne	.LBB2_4
# %bb.5:                                #   in Loop: Header=BB2_3 Depth=1
	incq	%r14
	cmpq	%rax, %r14
	jb	.LBB2_3
	jmp	.LBB2_6
.LBB2_1:
	xorl	%r14d, %r14d
	jmp	.LBB2_6
.LBB2_4:                                # %.thread
	movl	$.Lstr.2, %edi
	callq	puts@PLT
	incq	%r14
.LBB2_6:                                # %._crit_edge
	cmpl	%ebx, %r14d
	jne	.LBB2_7
# %bb.8:
	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
.LBB2_7:
	.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_end2:
	.size	_Z11checkResultPfS_i, .Lfunc_end2-_Z11checkResultPfS_i
	.cfi_endproc
                                        # -- End function
	.globl	_Z15sumMatrixOnHostPfS_S_ii     # -- Begin function _Z15sumMatrixOnHostPfS_S_ii
	.type	_Z15sumMatrixOnHostPfS_S_ii,@function
_Z15sumMatrixOnHostPfS_S_ii:            # @_Z15sumMatrixOnHostPfS_S_ii
	.cfi_startproc
# %bb.0:
	testl	%r8d, %r8d
	jle	.LBB3_6
# %bb.1:                                # %.preheader.lr.ph
	movslq	%ecx, %rax
	movl	%eax, %r9d
	shlq	$2, %rax
	xorl	%r10d, %r10d
.LBB3_2:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB3_4 Depth 2
	testl	%ecx, %ecx
	jle	.LBB3_5
# %bb.3:                                # %.lr.ph.preheader
                                        #   in Loop: Header=BB3_2 Depth=1
	xorl	%r11d, %r11d
.LBB3_4:                                # %.lr.ph
                                        #   Parent Loop BB3_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movss	(%rdi,%r11,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	addss	(%rsi,%r11,4), %xmm0
	movss	%xmm0, (%rdx,%r11,4)
	incq	%r11
	cmpq	%r11, %r9
	jne	.LBB3_4
.LBB3_5:                                # %._crit_edge
                                        #   in Loop: Header=BB3_2 Depth=1
	incl	%r10d
	addq	%rax, %rdx
	addq	%rax, %rsi
	addq	%rax, %rdi
	cmpl	%r8d, %r10d
	jne	.LBB3_2
.LBB3_6:                                # %._crit_edge30
	retq
.Lfunc_end3:
	.size	_Z15sumMatrixOnHostPfS_S_ii, .Lfunc_end3-_Z15sumMatrixOnHostPfS_S_ii
	.cfi_endproc
                                        # -- End function
	.globl	_Z29__device_stub__sumMatrixOnGPUPfS_S_ii # -- Begin function _Z29__device_stub__sumMatrixOnGPUPfS_S_ii
	.type	_Z29__device_stub__sumMatrixOnGPUPfS_S_ii,@function
_Z29__device_stub__sumMatrixOnGPUPfS_S_ii: # @_Z29__device_stub__sumMatrixOnGPUPfS_S_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	$128, %rsp
	.cfi_def_cfa_offset 176
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	32(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	24(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	4(%rsp), %rdx
	movl	%ecx, (%rdx)
	movq	%rsp, %rcx
	movl	%r8d, (%rcx)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	movq	%rcx, 32(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	16(%rsp), %r12
	leaq	8(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z14sumMatrixOnGPUPfS_S_ii, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$144, %rsp
	.cfi_adjust_cfa_offset -144
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end4:
	.size	_Z29__device_stub__sumMatrixOnGPUPfS_S_ii, .Lfunc_end4-_Z29__device_stub__sumMatrixOnGPUPfS_S_ii
	.cfi_endproc
                                        # -- End function
	.globl	_Z10initialFltPfj               # -- Begin function _Z10initialFltPfj
	.type	_Z10initialFltPfj,@function
_Z10initialFltPfj:                      # @_Z10initialFltPfj
	.cfi_startproc
# %bb.0:
	testl	%esi, %esi
	je	.LBB5_3
# %bb.1:                                # %.lr.ph.preheader
	movl	%esi, %eax
	xorl	%ecx, %ecx
.LBB5_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movl	%ecx, %edx
	xorps	%xmm0, %xmm0
	cvtsi2ss	%rdx, %xmm0
	movss	%xmm0, (%rdi,%rcx,4)
	incq	%rcx
	cmpq	%rcx, %rax
	jne	.LBB5_2
.LBB5_3:                                # %._crit_edge
	retq
.Lfunc_end5:
	.size	_Z10initialFltPfj, .Lfunc_end5-_Z10initialFltPfj
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z12testSumOnGPUPfS_S_ii
.LCPI6_0:
	.quad	0x3eb0c6f7a0b5ed8d              # double 9.9999999999999995E-7
	.text
	.globl	_Z12testSumOnGPUPfS_S_ii
	.type	_Z12testSumOnGPUPfS_S_ii,@function
_Z12testSumOnGPUPfS_S_ii:               # @_Z12testSumOnGPUPfS_S_ii
	.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	$72, %rsp
	.cfi_def_cfa_offset 128
	.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	%r8d, %r14d
	movl	%ecx, %r15d
	movq	%rdx, 48(%rsp)                  # 8-byte Spill
	movq	%rsi, 32(%rsp)                  # 8-byte Spill
	movq	%rdi, %rbp
	leaq	56(%rsp), %r12
	movq	%r12, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	movq	(%r12), %rax
	movq	%rax, (%rsp)                    # 8-byte Spill
	movq	8(%r12), %rax
	movq	%rax, 40(%rsp)                  # 8-byte Spill
	xorl	%edi, %edi
	callq	hipSetDevice
	movl	%r15d, %eax
	imull	%r14d, %eax
	shll	$2, %eax
	movslq	%eax, %r12
	leaq	24(%rsp), %rbx
	movq	%rbx, %rdi
	movq	%r12, %rsi
	callq	hipMalloc
	leaq	16(%rsp), %r13
	movq	%r13, %rdi
	movq	%r12, %rsi
	callq	hipMalloc
	leaq	8(%rsp), %rdi
	movq	%r12, %rsi
	callq	hipMalloc
	movq	(%rbx), %rdi
	movq	%rbp, %rsi
	movq	%r12, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	(%r13), %rdi
	movq	32(%rsp), %rsi                  # 8-byte Reload
	movq	%r12, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	leal	31(%r15), %r13d
	shrl	$5, %r13d
	leal	31(%r14), %ebp
	shrl	$5, %ebp
	movq	%rbp, %rdi
	shlq	$32, %rdi
	orq	%r13, %rdi
	movabsq	$137438953504, %rdx             # imm = 0x2000000020
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB6_2
# %bb.1:
	movq	24(%rsp), %rdi
	movq	16(%rsp), %rsi
	movq	8(%rsp), %rdx
	movl	%r15d, %ecx
	movl	%r14d, %r8d
	callq	_Z29__device_stub__sumMatrixOnGPUPfS_S_ii
.LBB6_2:
	cvtsi2sdq	40(%rsp), %xmm0         # 8-byte Folded Reload
	mulsd	.LCPI6_0(%rip), %xmm0
	cvtsi2sdq	(%rsp), %xmm1           # 8-byte Folded Reload
	addsd	%xmm0, %xmm1
	movsd	%xmm1, (%rsp)                   # 8-byte Spill
	callq	hipDeviceSynchronize
	movq	8(%rsp), %rsi
	movq	48(%rsp), %rdi                  # 8-byte Reload
	movq	%r12, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	callq	hipDeviceSynchronize
	leaq	56(%rsp), %rbx
	movq	%rbx, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	xorps	%xmm1, %xmm1
	cvtsi2sdq	(%rbx), %xmm1
	xorps	%xmm0, %xmm0
	cvtsi2sdq	8(%rbx), %xmm0
	mulsd	.LCPI6_0(%rip), %xmm0
	addsd	%xmm1, %xmm0
	subsd	(%rsp), %xmm0                   # 8-byte Folded Reload
	movl	$.L.str.5, %edi
	movl	%r13d, %esi
	movl	%ebp, %edx
	movl	$32, %ecx
	movl	$32, %r8d
	movb	$1, %al
	callq	printf
	movq	24(%rsp), %rdi
	callq	hipFree
	movq	16(%rsp), %rdi
	callq	hipFree
	movq	8(%rsp), %rdi
	callq	hipFree
	callq	hipDeviceReset
	addq	$72, %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_end6:
	.size	_Z12testSumOnGPUPfS_S_ii, .Lfunc_end6-_Z12testSumOnGPUPfS_S_ii
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI7_0:
	.quad	0x3eb0c6f7a0b5ed8d              # double 9.9999999999999995E-7
	.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	$24, %rsp
	.cfi_def_cfa_offset 80
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	$67108864, %edi                 # imm = 0x4000000
	callq	malloc
	movq	%rax, %rbx
	movl	$67108864, %edi                 # imm = 0x4000000
	callq	malloc
	movq	%rax, %r14
	movl	$67108864, %edi                 # imm = 0x4000000
	callq	malloc
	movq	%rax, %r15
	movl	$67108864, %edi                 # imm = 0x4000000
	callq	malloc
	movq	%rax, %r12
	xorl	%eax, %eax
.LBB7_1:                                # %.lr.ph.i
                                        # =>This Inner Loop Header: Depth=1
	movl	%eax, %ecx
	xorps	%xmm0, %xmm0
	cvtsi2ss	%rcx, %xmm0
	movss	%xmm0, (%rbx,%rax,4)
	incq	%rax
	cmpq	$16777216, %rax                 # imm = 0x1000000
	jne	.LBB7_1
# %bb.2:                                # %.lr.ph.i19.preheader
	xorl	%eax, %eax
.LBB7_3:                                # %.lr.ph.i19
                                        # =>This Inner Loop Header: Depth=1
	movl	%eax, %ecx
	xorps	%xmm0, %xmm0
	cvtsi2ss	%rcx, %xmm0
	movss	%xmm0, (%r14,%rax,4)
	incq	%rax
	cmpq	$16777216, %rax                 # imm = 0x1000000
	jne	.LBB7_3
# %bb.4:                                # %_Z10initialFltPfj.exit23
	xorl	%ebp, %ebp
	leaq	8(%rsp), %r13
	movq	%r13, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	movq	(%r13), %rax
	movq	8(%r13), %rcx
	movl	$16384, %edx                    # imm = 0x4000
	movq	%r15, %rsi
	movq	%r14, %rdi
	movq	%rbx, %r8
.LBB7_5:                                # %.preheader.i
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB7_6 Depth 2
	xorl	%r9d, %r9d
.LBB7_6:                                # %.lr.ph.i24
                                        #   Parent Loop BB7_5 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movss	(%r8,%r9,4), %xmm0              # xmm0 = mem[0],zero,zero,zero
	addss	(%rdi,%r9,4), %xmm0
	movss	%xmm0, (%rsi,%r9,4)
	incq	%r9
	cmpq	$4096, %r9                      # imm = 0x1000
	jne	.LBB7_6
# %bb.7:                                # %._crit_edge.i
                                        #   in Loop: Header=BB7_5 Depth=1
	addq	%rdx, %r8
	addq	%rdx, %rdi
	addq	%rdx, %rsi
	incl	%ebp
	cmpl	$4096, %ebp                     # imm = 0x1000
	jne	.LBB7_5
# %bb.8:                                # %_Z15sumMatrixOnHostPfS_S_ii.exit
	xorps	%xmm0, %xmm0
	cvtsi2sd	%rcx, %xmm0
	mulsd	.LCPI7_0(%rip), %xmm0
	cvtsi2sd	%rax, %xmm1
	addsd	%xmm0, %xmm1
	movsd	%xmm1, (%rsp)                   # 8-byte Spill
	leaq	8(%rsp), %r13
	movq	%r13, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	xorps	%xmm1, %xmm1
	cvtsi2sdq	(%r13), %xmm1
	xorps	%xmm0, %xmm0
	cvtsi2sdq	8(%r13), %xmm0
	mulsd	.LCPI7_0(%rip), %xmm0
	addsd	%xmm1, %xmm0
	subsd	(%rsp), %xmm0                   # 8-byte Folded Reload
	movl	$.L.str.6, %edi
	movb	$1, %al
	callq	printf
	movq	%rbx, %rdi
	movq	%r14, %rsi
	movq	%r12, %rdx
	movl	$4096, %ecx                     # imm = 0x1000
	movl	$4096, %r8d                     # imm = 0x1000
	callq	_Z12testSumOnGPUPfS_S_ii
	movq	%r15, %rdi
	movq	%r12, %rsi
	movl	$16777216, %edx                 # imm = 0x1000000
	callq	_Z11checkResultPfS_i
	movq	%rbx, %rdi
	callq	free
	movq	%r14, %rdi
	callq	free
	movq	%r15, %rdi
	callq	free
	movq	%r12, %rdi
	callq	free
	xorl	%eax, %eax
	addq	$24, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end7:
	.size	main, .Lfunc_end7-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	.LBB8_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB8_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z14sumMatrixOnGPUPfS_S_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_end8:
	.size	__hip_module_ctor, .Lfunc_end8-__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	.LBB9_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
.LBB9_2:
	retq
.Lfunc_end9:
	.size	__hip_module_dtor, .Lfunc_end9-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"%f\t"
	.size	.L.str, 4

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

	.type	.L.str.5,@object                # @.str.5
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.5:
	.asciz	"Test sumMatrixOnGPU<<<(%d, %d), (%d, %d)>>>. \nEsplaced time: %f\n"
	.size	.L.str.5, 65

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"Test sumMatrixOnHost. \nEsplaced time: %f\n"
	.size	.L.str.6, 42

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z14sumMatrixOnGPUPfS_S_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	"============================================================================"
	.size	.Lstr, 77

	.type	.Lstr.1,@object                 # @str.1
.Lstr.1:
	.asciz	"Success: results match!"
	.size	.Lstr.1, 24

	.type	.Lstr.2,@object                 # @str.2
.Lstr.2:
	.asciz	"Results do not match!"
	.size	.Lstr.2, 22

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

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z14sumMatrixOnGPUPfS_S_ii ; -- Begin function _Z14sumMatrixOnGPUPfS_S_ii
	.globl	_Z14sumMatrixOnGPUPfS_S_ii
	.p2align	8
	.type	_Z14sumMatrixOnGPUPfS_S_ii,@function
_Z14sumMatrixOnGPUPfS_S_ii:             ; @_Z14sumMatrixOnGPUPfS_S_ii
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x2c
	s_load_b64 s[4:5], s[0:1], 0x18
	v_and_b32_e32 v2, 0x3ff, v0
	v_bfe_u32 v3, v0, 10, 10
	s_waitcnt lgkmcnt(0)
	s_lshr_b32 s3, s2, 16
	s_and_b32 s2, s2, 0xffff
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	v_mad_u64_u32 v[0:1], null, s14, s2, v[2:3]
	v_mad_u64_u32 v[1:2], null, s15, s3, v[3:4]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_cmp_gt_i32_e32 vcc_lo, s4, v0
	v_cmp_gt_i32_e64 s2, s5, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_and_b32 s2, vcc_lo, s2
	s_and_saveexec_b32 s3, s2
	s_cbranch_execz .LBB0_2
; %bb.1:
	s_load_b128 s[8:11], s[0:1], 0x0
	v_mad_u64_u32 v[2:3], null, v1, s4, v[0:1]
	s_load_b64 s[0:1], s[0:1], 0x10
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v3, 31, v2
	v_lshlrev_b64 v[0:1], 2, v[2:3]
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v2, vcc_lo, s8, v0
	v_add_co_ci_u32_e32 v3, vcc_lo, s9, v1, vcc_lo
	v_add_co_u32 v4, vcc_lo, s10, v0
	v_add_co_ci_u32_e32 v5, vcc_lo, s11, v1, vcc_lo
	v_add_co_u32 v0, vcc_lo, s0, v0
	global_load_b32 v2, v[2:3], off
	global_load_b32 v3, v[4:5], off
	v_add_co_ci_u32_e32 v1, vcc_lo, s1, v1, vcc_lo
	s_waitcnt vmcnt(0)
	v_add_f32_e32 v2, v2, v3
	global_store_b32 v[0:1], v2, off
.LBB0_2:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z14sumMatrixOnGPUPfS_S_ii
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 288
		.amdhsa_user_sgpr_count 14
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 1
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 1
		.amdhsa_next_free_vgpr 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	_Z14sumMatrixOnGPUPfS_S_ii, .Lfunc_end0-_Z14sumMatrixOnGPUPfS_S_ii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 232
; NumSgprs: 18
; NumVgprs: 6
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 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
      - .address_space:  global
        .offset:         16
        .size:           8
        .value_kind:     global_buffer
      - .offset:         24
        .size:           4
        .value_kind:     by_value
      - .offset:         28
        .size:           4
        .value_kind:     by_value
      - .offset:         32
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         36
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         40
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         44
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         46
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         48
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         50
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         52
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         54
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         88
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         96
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 288
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z14sumMatrixOnGPUPfS_S_ii
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z14sumMatrixOnGPUPfS_S_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
