// This example demonstrates how to 
// query about the properties of a device

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


int main(void)
{
  int dev_count, driverVersion = 0, runtimeVersion = 0;;
  cudaGetDeviceCount(&dev_count);
  cudaDriverGetVersion(&driverVersion);
  cudaRuntimeGetVersion(&runtimeVersion);
  printf("CUDA Driver Version / Runtime Version %d.%d / %d.%d\n", driverVersion / 1000, (driverVersion % 100) / 10,
             runtimeVersion / 1000, (runtimeVersion % 100) / 10);
  cudaDeviceProp dev_prop;
  for(int i=0; i<dev_count;i++){
		cudaGetDeviceProperties(&dev_prop,i);
		printf("---Device %d---\n", i);
		printf("Name: \"%s\"\n", dev_prop.name);
		printf("CUDA Capability Major/Minor version number: %d.%d\n", dev_prop.major, dev_prop.minor);
		printf("--- Memory information for device ---\n");
		printf("Total global mem: %.0f MB\n", dev_prop.totalGlobalMem/1048576.0f);
		printf("Total constant mem: %lu B\n", dev_prop.totalConstMem);
		printf("The size of shared memory per block: %lu B\n", dev_prop.sharedMemPerBlock);
		printf("The maximum number of registers per block: %d\n", dev_prop.regsPerBlock);
		printf("The number of SMs on the device: %d\n", dev_prop.multiProcessorCount);
		printf("The number of threads in a warp: %d\n", dev_prop.warpSize);
		printf("The maximal number of threads allowed in a block: %d\n", dev_prop.maxThreadsPerBlock);
		printf("Max thread dimensions (x,y,z): (%d, %d, %d)\n", dev_prop.maxThreadsDim[0], dev_prop.maxThreadsDim[1], dev_prop.maxThreadsDim[2]);
		printf("Max grid dimensions (x,y,z): (%d, %d, %d)\n", dev_prop.maxGridSize[0], dev_prop.maxGridSize[1], dev_prop.maxGridSize[2]);
	}	
}


	.file	"tmpxft_002a824c_00000000-6_cuda_device_query.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	"CUDA Driver Version / Runtime Version %d.%d / %d.%d\n"
.LC1:
	.string	"---Device %d---\n"
.LC2:
	.string	"Name: \"%s\"\n"
.LC3:
	.string	"CUDA Capability Major/Minor version number: %d.%d\n"
.LC4:
	.string	"--- Memory information for device ---\n"
.LC6:
	.string	"Total global mem: %.0f MB\n"
.LC7:
	.string	"Total constant mem: %lu B\n"
.LC8:
	.string	"The size of shared memory per block: %lu B\n"
.LC9:
	.string	"The maximum number of registers per block: %d\n"
.LC10:
	.string	"The number of SMs on the device: %d\n"
.LC11:
	.string	"The number of threads in a warp: %d\n"
.LC12:
	.string	"The maximal number of threads allowed in a block: %d\n"
.LC13:
	.string	"Max thread dimensions (x,y,z): (%d, %d, %d)\n"
.LC14:
	.string	"Max grid dimensions (x,y,z): (%d, %d, %d)\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2027:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	leaq	.LC1(%rip), %rbp
	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	4(%rsp), %rdi
	xorl	%eax, %eax
	movl	%eax, 8(%rsp)
	movl	%eax, 12(%rsp)
	call	cudaGetDeviceCount@PLT
	leaq	8(%rsp), %rdi
	call	cudaDriverGetVersion@PLT
	leaq	12(%rsp), %rdi
	call	cudaRuntimeGetVersion@PLT
	movl	12(%rsp), %eax
	movl	$100, %r10d
	movl	$10, %edi
	movl	$1000, %esi
	cltd
	idivl	%r10d
	movl	%edx, %eax
	cltd
	idivl	%edi
	movl	%eax, %r9d
	movl	12(%rsp), %eax
	cltd
	idivl	%esi
	movl	%eax, %r8d
	movl	8(%rsp), %eax
	cltd
	idivl	%r10d
	movl	%edx, %eax
	cltd
	idivl	%edi
	movl	$2, %edi
	movl	%eax, %ecx
	movl	8(%rsp), %eax
	cltd
	idivl	%esi
	leaq	.LC0(%rip), %rsi
	movl	%eax, %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L3:
	cmpl	%ebx, 4(%rsp)
	jle	.L10
	leaq	16(%rsp), %r12
	movl	%ebx, %esi
	movq	%r12, %rdi
	call	cudaGetDeviceProperties_v2@PLT
	movl	%ebx, %edx
	movq	%rbp, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	%r12, %rdx
	movl	$2, %edi
	xorl	%eax, %eax
	leaq	.LC2(%rip), %rsi
	call	__printf_chk@PLT
	movl	380(%rsp), %ecx
	movl	$2, %edi
	xorl	%eax, %eax
	movl	376(%rsp), %edx
	leaq	.LC3(%rip), %rsi
	call	__printf_chk@PLT
	leaq	.LC4(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	304(%rsp), %rax
	testq	%rax, %rax
	js	.L4
	cvtsi2ssq	%rax, %xmm0
	jmp	.L5
.L4:
	movq	%rax, %rdx
	andl	$1, %eax
	shrq	%rdx
	orq	%rax, %rdx
	cvtsi2ssq	%rdx, %xmm0
	addss	%xmm0, %xmm0
.L5:
	leaq	.LC6(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	incl	%ebx
	mulss	.LC5(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	call	__printf_chk@PLT
	movl	$2, %edi
	xorl	%eax, %eax
	movq	368(%rsp), %rdx
	leaq	.LC7(%rip), %rsi
	call	__printf_chk@PLT
	movq	312(%rsp), %rdx
	leaq	.LC8(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
	movl	320(%rsp), %edx
	leaq	.LC9(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
	movl	404(%rsp), %edx
	leaq	.LC10(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
	movl	324(%rsp), %edx
	leaq	.LC11(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
	movl	336(%rsp), %edx
	leaq	.LC12(%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	.LC13(%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	.LC14(%rip), %rsi
	movl	$2, %edi
	call	__printf_chk@PLT
	jmp	.L3
.L10:
	movq	1048(%rsp), %rax
	subq	%fs:40, %rax
	je	.L7
	call	__stack_chk_fail@PLT
.L7:
	addq	$1056, %rsp
	.cfi_def_cfa_offset 32
	xorl	%eax, %eax
	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	main, .-main
	.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
	.section	.rodata.cst4,"aM",@progbits,4
	.align 4
.LC5:
	.long	897581056
	.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:

// This example demonstrates how to 
// query about the properties of a device

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


int main(void)
{
  int dev_count, driverVersion = 0, runtimeVersion = 0;;
  hipGetDeviceCount(&dev_count);
  hipDriverGetVersion(&driverVersion);
  hipRuntimeGetVersion(&runtimeVersion);
  printf("CUDA Driver Version / Runtime Version %d.%d / %d.%d\n", driverVersion / 1000, (driverVersion % 100) / 10,
             runtimeVersion / 1000, (runtimeVersion % 100) / 10);
  hipDeviceProp_t dev_prop;
  for(int i=0; i<dev_count;i++){
		hipGetDeviceProperties(&dev_prop,i);
		printf("---Device %d---\n", i);
		printf("Name: \"%s\"\n", dev_prop.name);
		printf("CUDA Capability Major/Minor version number: %d.%d\n", dev_prop.major, dev_prop.minor);
		printf("--- Memory information for device ---\n");
		printf("Total global mem: %.0f MB\n", dev_prop.totalGlobalMem/1048576.0f);
		printf("Total constant mem: %lu B\n", dev_prop.totalConstMem);
		printf("The size of shared memory per block: %lu B\n", dev_prop.sharedMemPerBlock);
		printf("The maximum number of registers per block: %d\n", dev_prop.regsPerBlock);
		printf("The number of SMs on the device: %d\n", dev_prop.multiProcessorCount);
		printf("The number of threads in a warp: %d\n", dev_prop.warpSize);
		printf("The maximal number of threads allowed in a block: %d\n", dev_prop.maxThreadsPerBlock);
		printf("Max thread dimensions (x,y,z): (%d, %d, %d)\n", dev_prop.maxThreadsDim[0], dev_prop.maxThreadsDim[1], dev_prop.maxThreadsDim[2]);
		printf("Max grid dimensions (x,y,z): (%d, %d, %d)\n", dev_prop.maxGridSize[0], dev_prop.maxGridSize[1], dev_prop.maxGridSize[2]);
	}	
}


	.text
	.file	"cuda_device_query.hip"
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function main
.LCPI0_0:
	.long	0x35800000                      # float 9.53674316E-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	%rbx
	.cfi_def_cfa_offset 40
	subq	$1496, %rsp                     # imm = 0x5D8
	.cfi_def_cfa_offset 1536
	.cfi_offset %rbx, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	xorl	%ebp, %ebp
	leaq	20(%rsp), %r15
	movl	%ebp, (%r15)
	leaq	16(%rsp), %r14
	movl	%ebp, (%r14)
	leaq	12(%rsp), %rbx
	movq	%rbx, %rdi
	callq	hipGetDeviceCount
	movq	%r15, %rdi
	callq	hipDriverGetVersion
	movq	%r14, %rdi
	callq	hipRuntimeGetVersion
	movslq	(%r15), %rax
	imulq	$274877907, %rax, %rsi          # imm = 0x10624DD3
	movq	%rsi, %rcx
	shrq	$63, %rcx
	sarq	$38, %rsi
	addl	%ecx, %esi
	imulq	$1374389535, %rax, %rcx         # imm = 0x51EB851F
	movq	%rcx, %rdx
	shrq	$63, %rdx
	shrq	$37, %rcx
	addl	%edx, %ecx
	imull	$100, %ecx, %ecx
	subl	%ecx, %eax
	movsbl	%al, %eax
	imull	$103, %eax, %ecx
	movl	$65535, %eax                    # imm = 0xFFFF
	movswl	%cx, %edx
	andl	%eax, %ecx
	shrl	$15, %ecx
	shrl	$10, %edx
	addb	%cl, %dl
	movsbl	%dl, %edx
	movslq	(%r14), %rdi
	imulq	$274877907, %rdi, %rcx          # imm = 0x10624DD3
	movq	%rcx, %r8
	shrq	$63, %r8
	sarq	$38, %rcx
	addl	%r8d, %ecx
	imulq	$1374389535, %rdi, %r8          # imm = 0x51EB851F
	movq	%r8, %r9
	shrq	$63, %r9
	shrq	$37, %r8
	addl	%r9d, %r8d
	imull	$100, %r8d, %r8d
	subl	%r8d, %edi
	movsbl	%dil, %edi
	imull	$103, %edi, %edi
	andl	%edi, %eax
	shrl	$15, %eax
	movswl	%di, %edi
	shrl	$10, %edi
	addb	%al, %dil
	movsbl	%dil, %r8d
	movl	$.L.str, %edi
                                        # kill: def $esi killed $esi killed $rsi
                                        # kill: def $ecx killed $ecx killed $rcx
	xorl	%eax, %eax
	callq	printf
	cmpl	%ebp, (%rbx)
	jle	.LBB0_6
# %bb.1:                                # %.lr.ph
	leaq	24(%rsp), %rbx
	xorl	%ebp, %ebp
.LBB0_2:                                # =>This Inner Loop Header: Depth=1
	movq	%rbx, %rdi
	movl	%ebp, %esi
	callq	hipGetDevicePropertiesR0600
	movl	$.L.str.1, %edi
	movl	%ebp, %esi
	xorl	%eax, %eax
	callq	printf
	movl	$.L.str.2, %edi
	movq	%rbx, %rsi
	xorl	%eax, %eax
	callq	printf
	movl	384(%rsp), %esi
	movl	388(%rsp), %edx
	movl	$.L.str.3, %edi
	xorl	%eax, %eax
	callq	printf
	movl	$.Lstr, %edi
	callq	puts@PLT
	movq	312(%rsp), %rax
	testq	%rax, %rax
	js	.LBB0_3
# %bb.4:                                #   in Loop: Header=BB0_2 Depth=1
	cvtsi2ss	%rax, %xmm0
	jmp	.LBB0_5
.LBB0_3:                                #   in Loop: Header=BB0_2 Depth=1
	movq	%rax, %rcx
	shrq	%rcx
	andl	$1, %eax
	orq	%rcx, %rax
	cvtsi2ss	%rax, %xmm0
	addss	%xmm0, %xmm0
.LBB0_5:                                #   in Loop: Header=BB0_2 Depth=1
	mulss	.LCPI0_0(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	movl	$.L.str.5, %edi
	movb	$1, %al
	callq	printf
	movq	376(%rsp), %rsi
	movl	$.L.str.6, %edi
	xorl	%eax, %eax
	callq	printf
	movq	320(%rsp), %rsi
	movl	$.L.str.7, %edi
	xorl	%eax, %eax
	callq	printf
	movl	328(%rsp), %esi
	movl	$.L.str.8, %edi
	xorl	%eax, %eax
	callq	printf
	movl	412(%rsp), %esi
	movl	$.L.str.9, %edi
	xorl	%eax, %eax
	callq	printf
	movl	332(%rsp), %esi
	movl	$.L.str.10, %edi
	xorl	%eax, %eax
	callq	printf
	movl	344(%rsp), %esi
	movl	$.L.str.11, %edi
	xorl	%eax, %eax
	callq	printf
	movl	348(%rsp), %esi
	movl	352(%rsp), %edx
	movl	356(%rsp), %ecx
	movl	$.L.str.12, %edi
	xorl	%eax, %eax
	callq	printf
	movl	360(%rsp), %esi
	movl	364(%rsp), %edx
	movl	368(%rsp), %ecx
	movl	$.L.str.13, %edi
	xorl	%eax, %eax
	callq	printf
	incl	%ebp
	cmpl	12(%rsp), %ebp
	jl	.LBB0_2
.LBB0_6:                                # %._crit_edge
	xorl	%eax, %eax
	addq	$1496, %rsp                     # imm = 0x5D8
	.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	main, .Lfunc_end0-main
	.cfi_endproc
                                        # -- End function
	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"CUDA Driver Version / Runtime Version %d.%d / %d.%d\n"
	.size	.L.str, 53

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"---Device %d---\n"
	.size	.L.str.1, 17

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"Name: \"%s\"\n"
	.size	.L.str.2, 12

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"CUDA Capability Major/Minor version number: %d.%d\n"
	.size	.L.str.3, 51

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"Total global mem: %.0f MB\n"
	.size	.L.str.5, 27

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"Total constant mem: %lu B\n"
	.size	.L.str.6, 27

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

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"The maximum number of registers per block: %d\n"
	.size	.L.str.8, 47

	.type	.L.str.9,@object                # @.str.9
.L.str.9:
	.asciz	"The number of SMs on the device: %d\n"
	.size	.L.str.9, 37

	.type	.L.str.10,@object               # @.str.10
.L.str.10:
	.asciz	"The number of threads in a warp: %d\n"
	.size	.L.str.10, 37

	.type	.L.str.11,@object               # @.str.11
.L.str.11:
	.asciz	"The maximal number of threads allowed in a block: %d\n"
	.size	.L.str.11, 54

	.type	.L.str.12,@object               # @.str.12
.L.str.12:
	.asciz	"Max thread dimensions (x,y,z): (%d, %d, %d)\n"
	.size	.L.str.12, 45

	.type	.L.str.13,@object               # @.str.13
.L.str.13:
	.asciz	"Max grid dimensions (x,y,z): (%d, %d, %d)\n"
	.size	.L.str.13, 43

	.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	"--- Memory information for device ---"
	.size	.Lstr, 38

	.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
