#include <stdio.h>

int main(void){
	cudaDeviceProp prop;
	cudaDeviceProp prop1;

	int count, device;
	cudaGetDeviceCount (&count);

	for (int i=0; i < count; i++){
	cudaGetDeviceProperties(&prop, i);
	printf("Device %d, %s: CC: %d.%d\n", i, prop.name, prop.major, prop.minor);
	}
	memset(&prop1, 0, sizeof(cudaDeviceProp));
	prop1.major = 2;
	prop1.minor = 1;

	device = 1;

	cudaChooseDevice(&device, &prop1);
	cudaSetDevice(device);
	cudaGetDeviceProperties(&prop, device);
	printf("\n Device chosen %d, %s: CC: %d.%d\n", device, prop.name, prop.major, prop.minor);
	return 0;
}

	.file	"tmpxft_003bab49_00000000-6_deviceprop.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	"Device %d, %s: CC: %d.%d\n"
.LC1:
	.string	"\n Device chosen %d, %s: CC: %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
	leaq	.LC0(%rip), %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	$2080, %rsp
	.cfi_def_cfa_offset 2112
	movq	%fs:40, %rax
	movq	%rax, 2072(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rdi
	call	cudaGetDeviceCount@PLT
.L3:
	cmpl	%ebx, (%rsp)
	leaq	8(%rsp), %rbp
	jle	.L8
	movl	%ebx, %esi
	movq	%rbp, %rdi
	call	cudaGetDeviceProperties_v2@PLT
	movl	%ebx, %edx
	movq	%rbp, %rcx
	movq	%r12, %rsi
	movl	372(%rsp), %r9d
	movl	368(%rsp), %r8d
	xorl	%eax, %eax
	incl	%ebx
	movl	$2, %edi
	call	__printf_chk@PLT
	jmp	.L3
.L8:
	leaq	1040(%rsp), %rsi
	xorl	%eax, %eax
	movl	$258, %ecx
	movl	$1, 4(%rsp)
	movq	%rsi, %rdi
	rep stosl
	movl	$2147483649, %eax
	leaq	4(%rsp), %rdi
	addq	%rax, %rax
	movq	%rax, 1400(%rsp)
	call	cudaChooseDevice@PLT
	movl	4(%rsp), %edi
	call	cudaSetDevice@PLT
	movl	4(%rsp), %esi
	movq	%rbp, %rdi
	call	cudaGetDeviceProperties_v2@PLT
	movl	4(%rsp), %edx
	xorl	%eax, %eax
	movq	%rbp, %rcx
	movl	372(%rsp), %r9d
	movl	368(%rsp), %r8d
	movl	$2, %edi
	leaq	.LC1(%rip), %rsi
	call	__printf_chk@PLT
	movq	2072(%rsp), %rax
	subq	%fs:40, %rax
	je	.L5
	call	__stack_chk_fail@PLT
.L5:
	addq	$2080, %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
	.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 <stdio.h>

int main(void){
	hipDeviceProp_t prop;
	hipDeviceProp_t prop1;

	int count, device;
	hipGetDeviceCount (&count);

	for (int i=0; i < count; i++){
	hipGetDeviceProperties(&prop, i);
	printf("Device %d, %s: CC: %d.%d\n", i, prop.name, prop.major, prop.minor);
	}
	memset(&prop1, 0, sizeof(hipDeviceProp_t));
	prop1.major = 2;
	prop1.minor = 1;

	device = 1;

	hipChooseDevice(&device, &prop1);
	hipSetDevice(device);
	hipGetDeviceProperties(&prop, device);
	printf("\n Device chosen %d, %s: CC: %d.%d\n", device, prop.name, prop.major, prop.minor);
	return 0;
}

	.text
	.file	"deviceprop.hip"
	.globl	main                            # -- Begin function main
	.type	main,@function
main:                                   # @main
	.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	$2960, %rsp                     # imm = 0xB90
	.cfi_def_cfa_offset 2992
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %rbp, -16
	leaq	8(%rsp), %rbx
	movq	%rbx, %rdi
	callq	hipGetDeviceCount
	cmpl	$0, (%rbx)
	jle	.LBB0_3
# %bb.1:                                # %.lr.ph
	leaq	16(%rsp), %rbx
	xorl	%ebp, %ebp
.LBB0_2:                                # =>This Inner Loop Header: Depth=1
	movq	%rbx, %rdi
	movl	%ebp, %esi
	callq	hipGetDevicePropertiesR0600
	movl	376(%rsp), %ecx
	movl	380(%rsp), %r8d
	movl	$.L.str, %edi
	movl	%ebp, %esi
	movq	%rbx, %rdx
	xorl	%eax, %eax
	callq	printf
	incl	%ebp
	cmpl	8(%rsp), %ebp
	jl	.LBB0_2
.LBB0_3:                                # %._crit_edge
	leaq	1488(%rsp), %rbx
	movl	$1472, %edx                     # imm = 0x5C0
	movq	%rbx, %rdi
	xorl	%esi, %esi
	callq	memset@PLT
	movabsq	$4294967298, %rax               # imm = 0x100000002
	movq	%rax, 360(%rbx)
	leaq	12(%rsp), %r14
	movl	$1, (%r14)
	movq	%r14, %rdi
	movq	%rbx, %rsi
	callq	hipChooseDeviceR0600
	movl	(%r14), %edi
	callq	hipSetDevice
	movl	(%r14), %esi
	leaq	16(%rsp), %rbx
	movq	%rbx, %rdi
	callq	hipGetDevicePropertiesR0600
	movl	(%r14), %esi
	movl	360(%rbx), %ecx
	movl	364(%rbx), %r8d
	movl	$.L.str.1, %edi
	movq	%rbx, %rdx
	xorl	%eax, %eax
	callq	printf
	xorl	%eax, %eax
	addq	$2960, %rsp                     # imm = 0xB90
	.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	main, .Lfunc_end0-main
	.cfi_endproc
                                        # -- End function
	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"Device %d, %s: CC: %d.%d\n"
	.size	.L.str, 26

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"\n Device chosen %d, %s: CC: %d.%d\n"
	.size	.L.str.1, 35

	.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
