#include <cstdio>

int deviceQuery() 
{
  int deviceCount;
  
  cudaGetDeviceCount(&deviceCount);
  
  for (int dev = 0; dev < deviceCount; dev++) {
    cudaDeviceProp deviceProp;
  
    cudaGetDeviceProperties(&deviceProp, dev);
  
    if (dev == 0) {
        if (deviceProp.major == 9999 && deviceProp.minor == 9999) {
            printf( "No CUDA GPU has been detected\n");
            return -1;
        } else if (deviceCount == 1) {
            printf( "There is 1 device supporting CUDA\n");
        } else {
            printf("There are %d devices supporting CUDA\n", deviceCount);
        }
    }
  
    printf( "Device %d: %s", dev, deviceProp.name);
    printf( " Computational Capabilities: %d,%d\n", deviceProp.major, deviceProp.minor);
    printf( " Maximum global memory size: %lu\n", deviceProp.totalGlobalMem);
    printf( " Maximum constant memory size: %lu\n", deviceProp.totalConstMem);
    printf( " Maximum shared memory size per block: %lu\n", deviceProp.sharedMemPerBlock);
    printf( " Maximum block dimensions: %d x %d x %d\n", 
            deviceProp.maxThreadsDim[0],
            deviceProp.maxThreadsDim[1],
            deviceProp.maxThreadsDim[2]);
    printf( " Maximum grid dimensions: %d x %d x %d\n",
            deviceProp.maxGridSize[0],
            deviceProp.maxGridSize[1],
           deviceProp.maxGridSize[2]);
    printf( " Warp size: %d\n", deviceProp.warpSize);
  }
  
  
  return 0;
}

	.file	"tmpxft_002fc455_00000000-6_deviceQuery.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2030:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2030:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"No CUDA GPU has been detected\n"
.LC1:
	.string	"There is 1 device supporting CUDA\n"
.LC2:
	.string	"There are %d devices supporting CUDA\n"
.LC3:
	.string	"Device %d: %s"
.LC4:
	.string	" Computational Capabilities: %d,%d\n"
.LC5:
	.string	" Maximum global memory size: %lu\n"
.LC6:
	.string	" Maximum constant memory size: %lu\n"
.LC7:
	.string	" Maximum shared memory size per block: %lu\n"
.LC8:
	.string	" Maximum block dimensions: %d x %d x %d\n"
.LC9:
	.string	" Maximum grid dimensions: %d x %d x %d\n"
.LC10:
	.string	" Warp size: %d\n"
	.text
	.globl	_Z11deviceQueryv
	.type	_Z11deviceQueryv, @function
_Z11deviceQueryv:
.LFB2027:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movabsq	$42945378002703, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	xorl	%ebx, %ebx
	subq	$1056, %rsp
	.cfi_def_cfa_offset 1088
	movq	%fs:40, %rax
	movq	%rax, 1048(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %rdi
	call	cudaGetDeviceCount@PLT
.L3:
	cmpl	%ebx, 12(%rsp)
	jle	.L12
	leaq	16(%rsp), %rbp
	movl	%ebx, %esi
	movq	%rbp, %rdi
	call	cudaGetDeviceProperties_v2@PLT
	testl	%ebx, %ebx
	jne	.L4
	cmpq	%r12, 376(%rsp)
	jne	.L5
	leaq	.LC0(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	orl	$-1, %eax
	jmp	.L2
.L5:
	movl	12(%rsp), %edx
	cmpl	$1, %edx
	jne	.L7
	leaq	.LC1(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L4
.L7:
	leaq	.LC2(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L4:
	movl	%ebx, %edx
	movq	%rbp, %rcx
	leaq	.LC3(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	incl	%ebx
	call	__printf_chk@PLT
	movl	380(%rsp), %ecx
	movl	$2, %edi
	xorl	%eax, %eax
	movl	376(%rsp), %edx
	leaq	.LC4(%rip), %rsi
	call	__printf_chk@PLT
	movq	304(%rsp), %rdx
	leaq	.LC5(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
	movq	368(%rsp), %rdx
	leaq	.LC6(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
	movq	312(%rsp), %rdx
	leaq	.LC7(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
	movl	348(%rsp), %r8d
	xorl	%eax, %eax
	movl	344(%rsp), %ecx
	movl	340(%rsp), %edx
	leaq	.LC8(%rip), %rsi
	movl	$2, %edi
	call	__printf_chk@PLT
	movl	360(%rsp), %r8d
	xorl	%eax, %eax
	movl	356(%rsp), %ecx
	movl	352(%rsp), %edx
	leaq	.LC9(%rip), %rsi
	movl	$2, %edi
	call	__printf_chk@PLT
	movl	324(%rsp), %edx
	leaq	.LC10(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
	jmp	.L3
.L12:
	xorl	%eax, %eax
.L2:
	movq	1048(%rsp), %rdx
	subq	%fs:40, %rdx
	je	.L9
	call	__stack_chk_fail@PLT
.L9:
	addq	$1056, %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	_Z11deviceQueryv, .-_Z11deviceQueryv
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2053:
	.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
.LFE2053:
	.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
	.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 <hip/hip_runtime.h>
#include <cstdio>

int deviceQuery() 
{
  int deviceCount;
  
  hipGetDeviceCount(&deviceCount);
  
  for (int dev = 0; dev < deviceCount; dev++) {
    hipDeviceProp_t deviceProp;
  
    hipGetDeviceProperties(&deviceProp, dev);
  
    if (dev == 0) {
        if (deviceProp.major == 9999 && deviceProp.minor == 9999) {
            printf( "No CUDA GPU has been detected\n");
            return -1;
        } else if (deviceCount == 1) {
            printf( "There is 1 device supporting CUDA\n");
        } else {
            printf("There are %d devices supporting CUDA\n", deviceCount);
        }
    }
  
    printf( "Device %d: %s", dev, deviceProp.name);
    printf( " Computational Capabilities: %d,%d\n", deviceProp.major, deviceProp.minor);
    printf( " Maximum global memory size: %lu\n", deviceProp.totalGlobalMem);
    printf( " Maximum constant memory size: %lu\n", deviceProp.totalConstMem);
    printf( " Maximum shared memory size per block: %lu\n", deviceProp.sharedMemPerBlock);
    printf( " Maximum block dimensions: %d x %d x %d\n", 
            deviceProp.maxThreadsDim[0],
            deviceProp.maxThreadsDim[1],
            deviceProp.maxThreadsDim[2]);
    printf( " Maximum grid dimensions: %d x %d x %d\n",
            deviceProp.maxGridSize[0],
            deviceProp.maxGridSize[1],
           deviceProp.maxGridSize[2]);
    printf( " Warp size: %d\n", deviceProp.warpSize);
  }
  
  
  return 0;
}

	.text
	.file	"deviceQuery.hip"
	.globl	_Z11deviceQueryv                # -- Begin function _Z11deviceQueryv
	.type	_Z11deviceQueryv,@function
_Z11deviceQueryv:                       # @_Z11deviceQueryv
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	subq	$1488, %rsp                     # imm = 0x5D0
	.cfi_def_cfa_offset 1520
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %rbp, -16
	leaq	12(%rsp), %rbx
	movq	%rbx, %rdi
	callq	hipGetDeviceCount
	cmpl	$0, (%rbx)
	jle	.LBB0_1
# %bb.2:                                # %.lr.ph
	leaq	16(%rsp), %rbx
	xorl	%ebp, %ebp
	xorl	%r14d, %r14d
.LBB0_3:                                # =>This Inner Loop Header: Depth=1
	movq	%rbx, %rdi
	movl	%ebp, %esi
	callq	hipGetDevicePropertiesR0600
	testl	%ebp, %ebp
	jne	.LBB0_10
# %bb.4:                                #   in Loop: Header=BB0_3 Depth=1
	cmpl	$9999, 376(%rsp)                # imm = 0x270F
	jne	.LBB0_7
# %bb.5:                                #   in Loop: Header=BB0_3 Depth=1
	cmpl	$9999, 380(%rsp)                # imm = 0x270F
	je	.LBB0_6
.LBB0_7:                                #   in Loop: Header=BB0_3 Depth=1
	movl	12(%rsp), %esi
	cmpl	$1, %esi
	jne	.LBB0_9
# %bb.8:                                #   in Loop: Header=BB0_3 Depth=1
	movl	$.Lstr, %edi
	callq	puts@PLT
	jmp	.LBB0_10
.LBB0_9:                                #   in Loop: Header=BB0_3 Depth=1
	movl	$.L.str.2, %edi
	xorl	%eax, %eax
	callq	printf
.LBB0_10:                               #   in Loop: Header=BB0_3 Depth=1
	movl	$.L.str.3, %edi
	movl	%ebp, %esi
	movq	%rbx, %rdx
	xorl	%eax, %eax
	callq	printf
	movl	376(%rsp), %esi
	movl	380(%rsp), %edx
	movl	$.L.str.4, %edi
	xorl	%eax, %eax
	callq	printf
	movq	304(%rsp), %rsi
	movl	$.L.str.5, %edi
	xorl	%eax, %eax
	callq	printf
	movq	368(%rsp), %rsi
	movl	$.L.str.6, %edi
	xorl	%eax, %eax
	callq	printf
	movq	312(%rsp), %rsi
	movl	$.L.str.7, %edi
	xorl	%eax, %eax
	callq	printf
	movl	340(%rsp), %esi
	movl	344(%rsp), %edx
	movl	348(%rsp), %ecx
	movl	$.L.str.8, %edi
	xorl	%eax, %eax
	callq	printf
	movl	352(%rsp), %esi
	movl	356(%rsp), %edx
	movl	360(%rsp), %ecx
	movl	$.L.str.9, %edi
	xorl	%eax, %eax
	callq	printf
	movl	324(%rsp), %esi
	movl	$.L.str.10, %edi
	xorl	%eax, %eax
	callq	printf
	incl	%ebp
	cmpl	12(%rsp), %ebp
	jl	.LBB0_3
	jmp	.LBB0_11
.LBB0_1:
	xorl	%r14d, %r14d
	jmp	.LBB0_11
.LBB0_6:                                # %.critedge
	movl	$.Lstr.1, %edi
	callq	puts@PLT
	movl	$-1, %r14d
.LBB0_11:                               # %.loopexit
	movl	%r14d, %eax
	addq	$1488, %rsp                     # imm = 0x5D0
	.cfi_def_cfa_offset 32
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	_Z11deviceQueryv, .Lfunc_end0-_Z11deviceQueryv
	.cfi_endproc
                                        # -- End function
	.type	.L.str.2,@object                # @.str.2
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.2:
	.asciz	"There are %d devices supporting CUDA\n"
	.size	.L.str.2, 38

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"Device %d: %s"
	.size	.L.str.3, 14

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	" Computational Capabilities: %d,%d\n"
	.size	.L.str.4, 36

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	" Maximum global memory size: %lu\n"
	.size	.L.str.5, 34

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	" Maximum constant memory size: %lu\n"
	.size	.L.str.6, 36

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	" Maximum shared memory size per block: %lu\n"
	.size	.L.str.7, 44

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	" Maximum block dimensions: %d x %d x %d\n"
	.size	.L.str.8, 41

	.type	.L.str.9,@object                # @.str.9
.L.str.9:
	.asciz	" Maximum grid dimensions: %d x %d x %d\n"
	.size	.L.str.9, 40

	.type	.L.str.10,@object               # @.str.10
.L.str.10:
	.asciz	" Warp size: %d\n"
	.size	.L.str.10, 16

	.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	"There is 1 device supporting CUDA"
	.size	.Lstr, 34

	.type	.Lstr.1,@object                 # @str.1
.Lstr.1:
	.asciz	"No CUDA GPU has been detected"
	.size	.Lstr.1, 30

	.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
