/*--------------------------------------------------------------------*/
/* CUDA special utility Library */
/* written by Viktor K. Decyk, UCLA */

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

static cudaError_t crc;

/*--------------------------------------------------------------------*/
extern "C" void gpu_fallocate(float **g_f, int nsize, int *irc) {
/* allocate global float memory on GPU, return pointer to C */
   void *gptr;
   crc = cudaMalloc(&gptr,sizeof(float)*nsize);
   if (crc) {
      printf("cudaMalloc float Error=%d:%s,l=%d\n",crc,
              cudaGetErrorString(crc),nsize);
      *irc = 1;
   }
   *g_f = (float *)gptr;
   return;
}

/*--------------------------------------------------------------------*/
extern "C" void gpu_iallocate(int **g_i, int nsize, int *irc) {
/* allocate global integer memory on GPU, return pointer to C */
   void *gptr;
   crc = cudaMalloc(&gptr,sizeof(int)*nsize);
   if (crc) {
      printf("cudaMalloc int Error=%d:%s,l=%d\n",crc,
              cudaGetErrorString(crc),nsize);
      *irc = 1;
   }
   *g_i = (int *)gptr;
   return;
}

/*--------------------------------------------------------------------*/
extern "C" void gpu_callocate(float2 **g_c, int nsize, int *irc) {
/* allocate global float2 memory on GPU, return pointer to C */
   void *gptr;
   crc = cudaMalloc(&gptr,sizeof(float2)*nsize);
   if (crc) {
      printf("cudaMalloc float2 Error=%d:%s,l=%d\n",crc,
              cudaGetErrorString(crc),nsize);
      *irc = 1;
   }
   *g_c = (float2 *)gptr;
   return;
}

/*--------------------------------------------------------------------*/
extern "C" void gpu_deallocate(void *g_d, int *irc) {
/* deallocate global memory on GPU */
   crc = cudaFree(g_d);
   if (crc) {
      printf("cudaFree Error=%d:%s\n",crc,cudaGetErrorString(crc));
      *irc = 1;
   }
   return;
}

/*--------------------------------------------------------------------*/
extern "C" void hpl_fallocate(float **h_f, int nsize, int *irc) {
/* allocate page-locked float memory on host, return pointer to C */
   void *hptr = NULL;
   crc = cudaMallocHost(&hptr,sizeof(float)*nsize);
   if (crc) {
      printf("cudaMallocHost float Error=%d:%s,l=%d\n",crc,
              cudaGetErrorString(crc),nsize);
      *irc = 1;
   }
   *h_f = (float *)hptr;
   return;
}

/*--------------------------------------------------------------------*/
extern "C" void hpl_callocate(float2 **h_c, int nsize, int *irc) {
/* allocate page-locked float2 memory on host, return pointer to C */
   void *hptr = NULL;
   crc = cudaMallocHost(&hptr,sizeof(float2)*nsize);
   if (crc) {
      printf("cudaMallocHost float2 Error=%d:%s,l=%d\n",crc,
              cudaGetErrorString(crc),nsize);
      *irc = 1;
   }
   *h_c = (float2 *)hptr;
   return;
}

/*--------------------------------------------------------------------*/
extern "C" void hpl_deallocate(void *h_d, int *irc) {
/* deallocate page-locked on host */
   crc = cudaFreeHost(h_d);
   if (crc) {
      printf("cudaFreeHost Error=%d:%s\n",crc,cudaGetErrorString(crc));
      *irc = 1;
   }
   return;
}

/* Interfaces to Fortran */

/*--------------------------------------------------------------------*/
extern "C" void gpu_fallocate_(unsigned long *gp_f, int *nsize,
                               int *irc) {
/* allocate global float memory on GPU, return pointer to Fortran */
   float *fptr;
   gpu_fallocate(&fptr,*nsize,irc);
   *gp_f = (long )fptr;
   return;
}

/*--------------------------------------------------------------------*/
extern "C" void gpu_iallocate_(unsigned long *gp_i, int *nsize,
                               int *irc) {
/* allocate global integer memory on GPU, return pointer to Fortran */
   int *iptr;
   gpu_iallocate(&iptr,*nsize,irc);
   *gp_i = (long )iptr;
   return;
}

/*--------------------------------------------------------------------*/
extern "C" void gpu_callocate_(unsigned long *gp_f, int *nsize,
                               int *irc) {
/* allocate global float2 memory on GPU, return pointer */
/* to Fortran */
   float2 *fptr;
   gpu_callocate(&fptr,*nsize,irc);
   *gp_f = (long )fptr;
   return;
}

/*--------------------------------------------------------------------*/
extern "C" void gpu_deallocate_(unsigned long *gp_d, int *irc) {
/* deallocate global memory on GPU, return pointer to Fortran */
   void *d;
   d = (void *)*gp_d;
   gpu_deallocate(d,irc);
   *gp_d = 0;
   return;
}

/*--------------------------------------------------------------------*/
extern "C" void hpl_deallocate_(void *h_d, int *irc) {
/* deallocate page-locked memory on host                  */
/* pointer in Fortran should also be nullified            */
   hpl_deallocate(h_d,irc);
   return;
}



	.file	"tmpxft_0029cb2f_00000000-6_gpulib2s.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2041:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2041:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"cudaMalloc float Error=%d:%s,l=%d\n"
	.text
	.globl	gpu_fallocate
	.type	gpu_fallocate, @function
gpu_fallocate:
.LFB2027:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movslq	%esi, %rsi
	movq	%rdx, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movq	%rdi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	movq	%rsi, %rbx
	salq	$2, %rsi
	subq	$16, %rsp
	.cfi_def_cfa_offset 48
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rdi
	call	cudaMalloc@PLT
	movl	%eax, _ZL3crc(%rip)
	testl	%eax, %eax
	je	.L3
	movl	%eax, %edi
	call	cudaGetErrorString@PLT
	movl	_ZL3crc(%rip), %edx
	movl	%ebx, %r8d
	leaq	.LC0(%rip), %rsi
	movq	%rax, %rcx
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	$1, (%r12)
.L3:
	movq	(%rsp), %rax
	movq	%rax, 0(%rbp)
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	je	.L4
	call	__stack_chk_fail@PLT
.L4:
	addq	$16, %rsp
	.cfi_def_cfa_offset 32
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2027:
	.size	gpu_fallocate, .-gpu_fallocate
	.section	.rodata.str1.1
.LC1:
	.string	"cudaMalloc int Error=%d:%s,l=%d\n"
	.text
	.globl	gpu_iallocate
	.type	gpu_iallocate, @function
gpu_iallocate:
.LFB2028:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movslq	%esi, %rsi
	movq	%rdx, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movq	%rdi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	movq	%rsi, %rbx
	salq	$2, %rsi
	subq	$16, %rsp
	.cfi_def_cfa_offset 48
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rdi
	call	cudaMalloc@PLT
	movl	%eax, _ZL3crc(%rip)
	testl	%eax, %eax
	je	.L11
	movl	%eax, %edi
	call	cudaGetErrorString@PLT
	movl	_ZL3crc(%rip), %edx
	movl	%ebx, %r8d
	leaq	.LC1(%rip), %rsi
	movq	%rax, %rcx
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	$1, (%r12)
.L11:
	movq	(%rsp), %rax
	movq	%rax, 0(%rbp)
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	je	.L12
	call	__stack_chk_fail@PLT
.L12:
	addq	$16, %rsp
	.cfi_def_cfa_offset 32
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2028:
	.size	gpu_iallocate, .-gpu_iallocate
	.section	.rodata.str1.1
.LC2:
	.string	"cudaMalloc float2 Error=%d:%s,l=%d\n"
	.text
	.globl	gpu_callocate
	.type	gpu_callocate, @function
gpu_callocate:
.LFB2029:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movslq	%esi, %rsi
	movq	%rdx, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movq	%rdi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	movq	%rsi, %rbx
	salq	$3, %rsi
	subq	$16, %rsp
	.cfi_def_cfa_offset 48
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rdi
	call	cudaMalloc@PLT
	movl	%eax, _ZL3crc(%rip)
	testl	%eax, %eax
	je	.L18
	movl	%eax, %edi
	call	cudaGetErrorString@PLT
	movl	_ZL3crc(%rip), %edx
	movl	%ebx, %r8d
	leaq	.LC2(%rip), %rsi
	movq	%rax, %rcx
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	$1, (%r12)
.L18:
	movq	(%rsp), %rax
	movq	%rax, 0(%rbp)
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	je	.L19
	call	__stack_chk_fail@PLT
.L19:
	addq	$16, %rsp
	.cfi_def_cfa_offset 32
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2029:
	.size	gpu_callocate, .-gpu_callocate
	.section	.rodata.str1.1
.LC3:
	.string	"cudaFree Error=%d:%s\n"
	.text
	.globl	gpu_deallocate
	.type	gpu_deallocate, @function
gpu_deallocate:
.LFB2030:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	movq	%rsi, %rbx
	call	cudaFree@PLT
	movl	%eax, _ZL3crc(%rip)
	testl	%eax, %eax
	je	.L24
	movl	%eax, %edi
	call	cudaGetErrorString@PLT
	movl	_ZL3crc(%rip), %edx
	movl	$2, %edi
	leaq	.LC3(%rip), %rsi
	movq	%rax, %rcx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	$1, (%rbx)
.L24:
	popq	%rbx
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2030:
	.size	gpu_deallocate, .-gpu_deallocate
	.section	.rodata.str1.1
.LC4:
	.string	"cudaMallocHost float Error=%d:%s,l=%d\n"
	.text
	.globl	hpl_fallocate
	.type	hpl_fallocate, @function
hpl_fallocate:
.LFB2031:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movslq	%esi, %rsi
	movq	%rdx, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movq	%rdi, %rbp
	xorl	%edi, %edi
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	movq	%rsi, %rbx
	salq	$2, %rsi
	subq	$16, %rsp
	.cfi_def_cfa_offset 48
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	movq	%rdi, (%rsp)
	movq	%rsp, %rdi
	call	cudaMallocHost@PLT
	movl	%eax, _ZL3crc(%rip)
	testl	%eax, %eax
	je	.L31
	movl	%eax, %edi
	call	cudaGetErrorString@PLT
	movl	_ZL3crc(%rip), %edx
	movl	%ebx, %r8d
	leaq	.LC4(%rip), %rsi
	movq	%rax, %rcx
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	$1, (%r12)
.L31:
	movq	(%rsp), %rax
	movq	%rax, 0(%rbp)
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	je	.L32
	call	__stack_chk_fail@PLT
.L32:
	addq	$16, %rsp
	.cfi_def_cfa_offset 32
	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	hpl_fallocate, .-hpl_fallocate
	.section	.rodata.str1.1
.LC5:
	.string	"cudaMallocHost float2 Error=%d:%s,l=%d\n"
	.text
	.globl	hpl_callocate
	.type	hpl_callocate, @function
hpl_callocate:
.LFB2032:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movslq	%esi, %rsi
	movq	%rdx, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movq	%rdi, %rbp
	xorl	%edi, %edi
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	movq	%rsi, %rbx
	salq	$3, %rsi
	subq	$16, %rsp
	.cfi_def_cfa_offset 48
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	movq	%rdi, (%rsp)
	movq	%rsp, %rdi
	call	cudaMallocHost@PLT
	movl	%eax, _ZL3crc(%rip)
	testl	%eax, %eax
	je	.L38
	movl	%eax, %edi
	call	cudaGetErrorString@PLT
	movl	_ZL3crc(%rip), %edx
	movl	%ebx, %r8d
	leaq	.LC5(%rip), %rsi
	movq	%rax, %rcx
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	$1, (%r12)
.L38:
	movq	(%rsp), %rax
	movq	%rax, 0(%rbp)
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	je	.L39
	call	__stack_chk_fail@PLT
.L39:
	addq	$16, %rsp
	.cfi_def_cfa_offset 32
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2032:
	.size	hpl_callocate, .-hpl_callocate
	.section	.rodata.str1.1
.LC6:
	.string	"cudaFreeHost Error=%d:%s\n"
	.text
	.globl	hpl_deallocate
	.type	hpl_deallocate, @function
hpl_deallocate:
.LFB2033:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	movq	%rsi, %rbx
	call	cudaFreeHost@PLT
	movl	%eax, _ZL3crc(%rip)
	testl	%eax, %eax
	je	.L44
	movl	%eax, %edi
	call	cudaGetErrorString@PLT
	movl	_ZL3crc(%rip), %edx
	movl	$2, %edi
	leaq	.LC6(%rip), %rsi
	movq	%rax, %rcx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	$1, (%rbx)
.L44:
	popq	%rbx
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2033:
	.size	hpl_deallocate, .-hpl_deallocate
	.globl	gpu_fallocate_
	.type	gpu_fallocate_, @function
gpu_fallocate_:
.LFB2034:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	movq	%rdi, %rbx
	subq	$16, %rsp
	.cfi_def_cfa_offset 32
	movl	(%rsi), %esi
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rdi
	call	gpu_fallocate
	movq	(%rsp), %rax
	movq	%rax, (%rbx)
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	je	.L51
	call	__stack_chk_fail@PLT
.L51:
	addq	$16, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2034:
	.size	gpu_fallocate_, .-gpu_fallocate_
	.globl	gpu_iallocate_
	.type	gpu_iallocate_, @function
gpu_iallocate_:
.LFB2035:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	movq	%rdi, %rbx
	subq	$16, %rsp
	.cfi_def_cfa_offset 32
	movl	(%rsi), %esi
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rdi
	call	gpu_iallocate
	movq	(%rsp), %rax
	movq	%rax, (%rbx)
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	je	.L54
	call	__stack_chk_fail@PLT
.L54:
	addq	$16, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2035:
	.size	gpu_iallocate_, .-gpu_iallocate_
	.globl	gpu_callocate_
	.type	gpu_callocate_, @function
gpu_callocate_:
.LFB2036:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	movq	%rdi, %rbx
	subq	$16, %rsp
	.cfi_def_cfa_offset 32
	movl	(%rsi), %esi
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rdi
	call	gpu_callocate
	movq	(%rsp), %rax
	movq	%rax, (%rbx)
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	je	.L57
	call	__stack_chk_fail@PLT
.L57:
	addq	$16, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2036:
	.size	gpu_callocate_, .-gpu_callocate_
	.globl	gpu_deallocate_
	.type	gpu_deallocate_, @function
gpu_deallocate_:
.LFB2037:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	movq	%rdi, %rbx
	movq	(%rdi), %rdi
	call	gpu_deallocate
	xorl	%eax, %eax
	movq	%rax, (%rbx)
	popq	%rbx
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2037:
	.size	gpu_deallocate_, .-gpu_deallocate_
	.globl	hpl_deallocate_
	.type	hpl_deallocate_, @function
hpl_deallocate_:
.LFB2038:
	.cfi_startproc
	endbr64
	jmp	hpl_deallocate
	.cfi_endproc
.LFE2038:
	.size	hpl_deallocate_, .-hpl_deallocate_
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2064:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	movq	%rax, %rdi
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rdx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE2064:
	.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	_ZL3crc
	.comm	_ZL3crc,4,4
	.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:

/*--------------------------------------------------------------------*/
/* CUDA special utility Library */
/* written by Viktor K. Decyk, UCLA */

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

static hipError_t crc;

/*--------------------------------------------------------------------*/
extern "C" void gpu_fallocate(float **g_f, int nsize, int *irc) {
/* allocate global float memory on GPU, return pointer to C */
   void *gptr;
   crc = hipMalloc(&gptr,sizeof(float)*nsize);
   if (crc) {
      printf("hipMalloc float Error=%d:%s,l=%d\n",crc,
              hipGetErrorString(crc),nsize);
      *irc = 1;
   }
   *g_f = (float *)gptr;
   return;
}

/*--------------------------------------------------------------------*/
extern "C" void gpu_iallocate(int **g_i, int nsize, int *irc) {
/* allocate global integer memory on GPU, return pointer to C */
   void *gptr;
   crc = hipMalloc(&gptr,sizeof(int)*nsize);
   if (crc) {
      printf("hipMalloc int Error=%d:%s,l=%d\n",crc,
              hipGetErrorString(crc),nsize);
      *irc = 1;
   }
   *g_i = (int *)gptr;
   return;
}

/*--------------------------------------------------------------------*/
extern "C" void gpu_callocate(float2 **g_c, int nsize, int *irc) {
/* allocate global float2 memory on GPU, return pointer to C */
   void *gptr;
   crc = hipMalloc(&gptr,sizeof(float2)*nsize);
   if (crc) {
      printf("hipMalloc float2 Error=%d:%s,l=%d\n",crc,
              hipGetErrorString(crc),nsize);
      *irc = 1;
   }
   *g_c = (float2 *)gptr;
   return;
}

/*--------------------------------------------------------------------*/
extern "C" void gpu_deallocate(void *g_d, int *irc) {
/* deallocate global memory on GPU */
   crc = hipFree(g_d);
   if (crc) {
      printf("hipFree Error=%d:%s\n",crc,hipGetErrorString(crc));
      *irc = 1;
   }
   return;
}

/*--------------------------------------------------------------------*/
extern "C" void hpl_fallocate(float **h_f, int nsize, int *irc) {
/* allocate page-locked float memory on host, return pointer to C */
   void *hptr = NULL;
   crc = hipHostMalloc(&hptr,sizeof(float)*nsize, hipHostMallocDefault);
   if (crc) {
      printf("hipHostMalloc float Error=%d:%s,l=%d\n",crc,
              hipGetErrorString(crc),nsize);
      *irc = 1;
   }
   *h_f = (float *)hptr;
   return;
}

/*--------------------------------------------------------------------*/
extern "C" void hpl_callocate(float2 **h_c, int nsize, int *irc) {
/* allocate page-locked float2 memory on host, return pointer to C */
   void *hptr = NULL;
   crc = hipHostMalloc(&hptr,sizeof(float2)*nsize, hipHostMallocDefault);
   if (crc) {
      printf("hipHostMalloc float2 Error=%d:%s,l=%d\n",crc,
              hipGetErrorString(crc),nsize);
      *irc = 1;
   }
   *h_c = (float2 *)hptr;
   return;
}

/*--------------------------------------------------------------------*/
extern "C" void hpl_deallocate(void *h_d, int *irc) {
/* deallocate page-locked on host */
   crc = hipHostFree(h_d);
   if (crc) {
      printf("hipHostFree Error=%d:%s\n",crc,hipGetErrorString(crc));
      *irc = 1;
   }
   return;
}

/* Interfaces to Fortran */

/*--------------------------------------------------------------------*/
extern "C" void gpu_fallocate_(unsigned long *gp_f, int *nsize,
                               int *irc) {
/* allocate global float memory on GPU, return pointer to Fortran */
   float *fptr;
   gpu_fallocate(&fptr,*nsize,irc);
   *gp_f = (long )fptr;
   return;
}

/*--------------------------------------------------------------------*/
extern "C" void gpu_iallocate_(unsigned long *gp_i, int *nsize,
                               int *irc) {
/* allocate global integer memory on GPU, return pointer to Fortran */
   int *iptr;
   gpu_iallocate(&iptr,*nsize,irc);
   *gp_i = (long )iptr;
   return;
}

/*--------------------------------------------------------------------*/
extern "C" void gpu_callocate_(unsigned long *gp_f, int *nsize,
                               int *irc) {
/* allocate global float2 memory on GPU, return pointer */
/* to Fortran */
   float2 *fptr;
   gpu_callocate(&fptr,*nsize,irc);
   *gp_f = (long )fptr;
   return;
}

/*--------------------------------------------------------------------*/
extern "C" void gpu_deallocate_(unsigned long *gp_d, int *irc) {
/* deallocate global memory on GPU, return pointer to Fortran */
   void *d;
   d = (void *)*gp_d;
   gpu_deallocate(d,irc);
   *gp_d = 0;
   return;
}

/*--------------------------------------------------------------------*/
extern "C" void hpl_deallocate_(void *h_d, int *irc) {
/* deallocate page-locked memory on host                  */
/* pointer in Fortran should also be nullified            */
   hpl_deallocate(h_d,irc);
   return;
}



	.text
	.file	"gpulib2s.hip"
	.globl	gpu_fallocate                   # -- Begin function gpu_fallocate
	.type	gpu_fallocate,@function
gpu_fallocate:                          # @gpu_fallocate
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	pushq	%rax
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rdx, %r14
	movl	%esi, %ebp
	movq	%rdi, %rbx
	movslq	%esi, %rsi
	shlq	$2, %rsi
	movq	%rsp, %rdi
	callq	hipMalloc
	testl	%eax, %eax
	je	.LBB0_2
# %bb.1:
	movl	%eax, %r15d
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str, %edi
	movl	%r15d, %esi
	movq	%rax, %rdx
	movl	%ebp, %ecx
	xorl	%eax, %eax
	callq	printf
	movl	$1, (%r14)
.LBB0_2:
	movq	(%rsp), %rax
	movq	%rax, (%rbx)
	addq	$8, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	gpu_fallocate, .Lfunc_end0-gpu_fallocate
	.cfi_endproc
                                        # -- End function
	.globl	gpu_iallocate                   # -- Begin function gpu_iallocate
	.type	gpu_iallocate,@function
gpu_iallocate:                          # @gpu_iallocate
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	pushq	%rax
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rdx, %r14
	movl	%esi, %ebp
	movq	%rdi, %rbx
	movslq	%esi, %rsi
	shlq	$2, %rsi
	movq	%rsp, %rdi
	callq	hipMalloc
	testl	%eax, %eax
	je	.LBB1_2
# %bb.1:
	movl	%eax, %r15d
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.1, %edi
	movl	%r15d, %esi
	movq	%rax, %rdx
	movl	%ebp, %ecx
	xorl	%eax, %eax
	callq	printf
	movl	$1, (%r14)
.LBB1_2:
	movq	(%rsp), %rax
	movq	%rax, (%rbx)
	addq	$8, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end1:
	.size	gpu_iallocate, .Lfunc_end1-gpu_iallocate
	.cfi_endproc
                                        # -- End function
	.globl	gpu_callocate                   # -- Begin function gpu_callocate
	.type	gpu_callocate,@function
gpu_callocate:                          # @gpu_callocate
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	pushq	%rax
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rdx, %r14
	movl	%esi, %ebp
	movq	%rdi, %rbx
	movslq	%esi, %rsi
	shlq	$3, %rsi
	movq	%rsp, %rdi
	callq	hipMalloc
	testl	%eax, %eax
	je	.LBB2_2
# %bb.1:
	movl	%eax, %r15d
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.2, %edi
	movl	%r15d, %esi
	movq	%rax, %rdx
	movl	%ebp, %ecx
	xorl	%eax, %eax
	callq	printf
	movl	$1, (%r14)
.LBB2_2:
	movq	(%rsp), %rax
	movq	%rax, (%rbx)
	addq	$8, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end2:
	.size	gpu_callocate, .Lfunc_end2-gpu_callocate
	.cfi_endproc
                                        # -- End function
	.globl	gpu_deallocate                  # -- Begin function gpu_deallocate
	.type	gpu_deallocate,@function
gpu_deallocate:                         # @gpu_deallocate
	.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
	movq	%rsi, %rbx
	callq	hipFree
	testl	%eax, %eax
	je	.LBB3_2
# %bb.1:
	movl	%eax, %ebp
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.3, %edi
	movl	%ebp, %esi
	movq	%rax, %rdx
	xorl	%eax, %eax
	callq	printf
	movl	$1, (%rbx)
.LBB3_2:
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end3:
	.size	gpu_deallocate, .Lfunc_end3-gpu_deallocate
	.cfi_endproc
                                        # -- End function
	.globl	hpl_fallocate                   # -- Begin function hpl_fallocate
	.type	hpl_fallocate,@function
hpl_fallocate:                          # @hpl_fallocate
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	pushq	%rax
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rdx, %r14
	movl	%esi, %ebp
	movq	%rdi, %rbx
	movq	%rsp, %rdi
	movq	$0, (%rdi)
	movslq	%esi, %rsi
	shlq	$2, %rsi
	xorl	%edx, %edx
	callq	hipHostMalloc
	testl	%eax, %eax
	je	.LBB4_2
# %bb.1:
	movl	%eax, %r15d
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.4, %edi
	movl	%r15d, %esi
	movq	%rax, %rdx
	movl	%ebp, %ecx
	xorl	%eax, %eax
	callq	printf
	movl	$1, (%r14)
.LBB4_2:
	movq	(%rsp), %rax
	movq	%rax, (%rbx)
	addq	$8, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end4:
	.size	hpl_fallocate, .Lfunc_end4-hpl_fallocate
	.cfi_endproc
                                        # -- End function
	.globl	hpl_callocate                   # -- Begin function hpl_callocate
	.type	hpl_callocate,@function
hpl_callocate:                          # @hpl_callocate
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	pushq	%rax
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rdx, %r14
	movl	%esi, %ebp
	movq	%rdi, %rbx
	movq	%rsp, %rdi
	movq	$0, (%rdi)
	movslq	%esi, %rsi
	shlq	$3, %rsi
	xorl	%edx, %edx
	callq	hipHostMalloc
	testl	%eax, %eax
	je	.LBB5_2
# %bb.1:
	movl	%eax, %r15d
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %edi
	movl	%r15d, %esi
	movq	%rax, %rdx
	movl	%ebp, %ecx
	xorl	%eax, %eax
	callq	printf
	movl	$1, (%r14)
.LBB5_2:
	movq	(%rsp), %rax
	movq	%rax, (%rbx)
	addq	$8, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end5:
	.size	hpl_callocate, .Lfunc_end5-hpl_callocate
	.cfi_endproc
                                        # -- End function
	.globl	hpl_deallocate                  # -- Begin function hpl_deallocate
	.type	hpl_deallocate,@function
hpl_deallocate:                         # @hpl_deallocate
	.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
	movq	%rsi, %rbx
	callq	hipHostFree
	testl	%eax, %eax
	je	.LBB6_2
# %bb.1:
	movl	%eax, %ebp
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.6, %edi
	movl	%ebp, %esi
	movq	%rax, %rdx
	xorl	%eax, %eax
	callq	printf
	movl	$1, (%rbx)
.LBB6_2:
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end6:
	.size	hpl_deallocate, .Lfunc_end6-hpl_deallocate
	.cfi_endproc
                                        # -- End function
	.globl	gpu_fallocate_                  # -- Begin function gpu_fallocate_
	.type	gpu_fallocate_,@function
gpu_fallocate_:                         # @gpu_fallocate_
	.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
	movq	%rdi, %rbx
	movl	(%rsi), %esi
	movq	%rsp, %r14
	movq	%r14, %rdi
	callq	gpu_fallocate
	movq	(%r14), %rax
	movq	%rax, (%rbx)
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end7:
	.size	gpu_fallocate_, .Lfunc_end7-gpu_fallocate_
	.cfi_endproc
                                        # -- End function
	.globl	gpu_iallocate_                  # -- Begin function gpu_iallocate_
	.type	gpu_iallocate_,@function
gpu_iallocate_:                         # @gpu_iallocate_
	.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
	movq	%rdi, %rbx
	movl	(%rsi), %esi
	movq	%rsp, %r14
	movq	%r14, %rdi
	callq	gpu_iallocate
	movq	(%r14), %rax
	movq	%rax, (%rbx)
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end8:
	.size	gpu_iallocate_, .Lfunc_end8-gpu_iallocate_
	.cfi_endproc
                                        # -- End function
	.globl	gpu_callocate_                  # -- Begin function gpu_callocate_
	.type	gpu_callocate_,@function
gpu_callocate_:                         # @gpu_callocate_
	.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
	movq	%rdi, %rbx
	movl	(%rsi), %esi
	movq	%rsp, %r14
	movq	%r14, %rdi
	callq	gpu_callocate
	movq	(%r14), %rax
	movq	%rax, (%rbx)
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end9:
	.size	gpu_callocate_, .Lfunc_end9-gpu_callocate_
	.cfi_endproc
                                        # -- End function
	.globl	gpu_deallocate_                 # -- Begin function gpu_deallocate_
	.type	gpu_deallocate_,@function
gpu_deallocate_:                        # @gpu_deallocate_
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset %rbx, -16
	movq	%rdi, %rbx
	movq	(%rdi), %rdi
	callq	gpu_deallocate
	movq	$0, (%rbx)
	popq	%rbx
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end10:
	.size	gpu_deallocate_, .Lfunc_end10-gpu_deallocate_
	.cfi_endproc
                                        # -- End function
	.globl	hpl_deallocate_                 # -- Begin function hpl_deallocate_
	.type	hpl_deallocate_,@function
hpl_deallocate_:                        # @hpl_deallocate_
	.cfi_startproc
# %bb.0:
	jmp	hpl_deallocate                  # TAILCALL
.Lfunc_end11:
	.size	hpl_deallocate_, .Lfunc_end11-hpl_deallocate_
	.cfi_endproc
                                        # -- End function
	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"hipMalloc float Error=%d:%s,l=%d\n"
	.size	.L.str, 34

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"hipMalloc int Error=%d:%s,l=%d\n"
	.size	.L.str.1, 32

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"hipMalloc float2 Error=%d:%s,l=%d\n"
	.size	.L.str.2, 35

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"hipFree Error=%d:%s\n"
	.size	.L.str.3, 21

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"hipHostMalloc float Error=%d:%s,l=%d\n"
	.size	.L.str.4, 38

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"hipHostMalloc float2 Error=%d:%s,l=%d\n"
	.size	.L.str.5, 39

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"hipHostFree Error=%d:%s\n"
	.size	.L.str.6, 25

	.type	__hip_cuid_,@object             # @__hip_cuid_
	.bss
	.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_

	.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_
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.amdgpu_metadata
---
amdhsa.kernels:  []
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
