#include <stdio.h>

int getSPcores(cudaDeviceProp devProp)
{  
    int cores = 0;
    int mp = devProp.multiProcessorCount;
    switch (devProp.major){
     case 2: // Fermi
      if (devProp.minor == 1) cores = mp * 48;
      else cores = mp * 32;
      break;
     case 3: // Kepler
      cores = mp * 192;
      break;
     case 5: // Maxwell
      cores = mp * 128;
      break;
     case 6: // Pascal
      if (devProp.minor == 1) cores = mp * 128;
      else if (devProp.minor == 0) cores = mp * 64;
      else printf("Unknown device type\n");
      break;
     case 7: // Volta
      if (devProp.minor == 0) cores = mp * 64;
      else printf("Unknown device type\n");
      break;
     default:
      printf("Unknown device type\n"); 
      break;
      }
    return cores;
}


int main() {
  int nDevices;

  cudaGetDeviceCount(&nDevices);
  for (int i = 0; i < nDevices; i++) {
    cudaDeviceProp prop;
    cudaGetDeviceProperties(&prop, i);
    printf("Device Number: %d\n", i);
    printf("  Device name: %s\n", prop.name);
    printf("  Number of CUDA cores: %d\n", getSPcores(prop));
    printf("  Warp Size: %d\n", prop.warpSize);
    printf("  Max Threads Per Block: %d\n", prop.maxThreadsPerBlock);
    printf("  Max Grid Size: (%d, %d, %d)\n", prop.maxGridSize[0],prop.maxGridSize[1],prop.maxGridSize[2]);
    printf("  Max Block Size: (%d, %d, %d)\n", prop.maxThreadsDim[0],prop.maxThreadsDim[1],prop.maxThreadsDim[2]);
    printf("  Max Threads Per Multiprocessor: %d\n", prop.maxThreadsPerMultiProcessor);
    printf("  Total Global Memory: %zu GB\n", prop.totalGlobalMem>>30);
    printf("  Shared Memory per Block: %zu kB\n", prop.sharedMemPerBlock>>10);
    printf("  Register per Block: %d kB \n\n", prop.regsPerBlock/1024);

  }
}
	.file	"tmpxft_0035a02d_00000000-6_cudaprop.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2031:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2031:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"Unknown device type\n"
	.text
	.globl	_Z10getSPcores14cudaDeviceProp
	.type	_Z10getSPcores14cudaDeviceProp, @function
_Z10getSPcores14cudaDeviceProp:
.LFB2027:
	.cfi_startproc
	endbr64
	pushq	%rcx
	.cfi_def_cfa_offset 16
	movl	376(%rsp), %eax
	movl	380(%rsp), %edx
	subl	$2, %eax
	movd	404(%rsp), %xmm0
	cmpl	$5, %eax
	ja	.L3
	leaq	.L5(%rip), %rsi
	movd	%xmm0, %ecx
	movslq	(%rsi,%rax,4), %rax
	addq	%rsi, %rax
	notrack jmp	*%rax
	.section	.rodata
	.align 4
	.align 4
.L5:
	.long	.L9-.L5
	.long	.L8-.L5
	.long	.L3-.L5
	.long	.L19-.L5
	.long	.L6-.L5
	.long	.L4-.L5
	.text
.L9:
	pslld	$5, %xmm0
	decl	%edx
	movd	%xmm0, %eax
	jne	.L2
	imull	$48, %ecx, %eax
	jmp	.L2
.L8:
	imull	$192, %ecx, %eax
	jmp	.L2
.L6:
	cmpl	$1, %edx
	jne	.L4
.L19:
	pslld	$7, %xmm0
	jmp	.L17
.L4:
	testl	%edx, %edx
	jne	.L3
	pslld	$6, %xmm0
.L17:
	movd	%xmm0, %eax
	jmp	.L2
.L3:
	leaq	.LC0(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	xorl	%eax, %eax
.L2:
	popq	%rdx
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2027:
	.size	_Z10getSPcores14cudaDeviceProp, .-_Z10getSPcores14cudaDeviceProp
	.section	.rodata.str1.1
.LC1:
	.string	"Device Number: %d\n"
.LC2:
	.string	"  Device name: %s\n"
.LC3:
	.string	"  Number of CUDA cores: %d\n"
.LC4:
	.string	"  Warp Size: %d\n"
.LC5:
	.string	"  Max Threads Per Block: %d\n"
.LC6:
	.string	"  Max Grid Size: (%d, %d, %d)\n"
.LC7:
	.string	"  Max Block Size: (%d, %d, %d)\n"
.LC8:
	.string	"  Max Threads Per Multiprocessor: %d\n"
.LC9:
	.string	"  Total Global Memory: %zu GB\n"
.LC10:
	.string	"  Shared Memory per Block: %zu kB\n"
.LC11:
	.string	"  Register per Block: %d kB \n\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2028:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	leaq	.LC1(%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	$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
.L22:
	cmpl	%ebx, 12(%rsp)
	jle	.L26
	leaq	16(%rsp), %rbp
	movl	%ebx, %esi
	movq	%rbp, %rdi
	call	cudaGetDeviceProperties_v2@PLT
	movl	%ebx, %edx
	movq	%r12, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	incl	%ebx
	call	__printf_chk@PLT
	movq	%rbp, %rdx
	movl	$2, %edi
	xorl	%eax, %eax
	leaq	.LC2(%rip), %rsi
	call	__printf_chk@PLT
	subq	$1040, %rsp
	.cfi_def_cfa_offset 2128
	movl	$258, %ecx
	movq	%rbp, %rsi
	movq	%rsp, %rdi
	rep movsl
	call	_Z10getSPcores14cudaDeviceProp
	addq	$1040, %rsp
	.cfi_def_cfa_offset 1088
	movl	$2, %edi
	leaq	.LC3(%rip), %rsi
	movl	%eax, %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	324(%rsp), %edx
	leaq	.LC4(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
	movl	336(%rsp), %edx
	leaq	.LC5(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
	movl	360(%rsp), %r8d
	xorl	%eax, %eax
	movl	356(%rsp), %ecx
	movl	352(%rsp), %edx
	leaq	.LC6(%rip), %rsi
	movl	$2, %edi
	call	__printf_chk@PLT
	movl	348(%rsp), %r8d
	xorl	%eax, %eax
	movl	344(%rsp), %ecx
	movl	340(%rsp), %edx
	leaq	.LC7(%rip), %rsi
	movl	$2, %edi
	call	__printf_chk@PLT
	movl	640(%rsp), %edx
	leaq	.LC8(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
	movq	304(%rsp), %rdx
	leaq	.LC9(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	shrq	$30, %rdx
	call	__printf_chk@PLT
	movq	312(%rsp), %rdx
	leaq	.LC10(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	shrq	$10, %rdx
	call	__printf_chk@PLT
	movl	$1024, %ecx
	movl	$2, %edi
	movl	320(%rsp), %eax
	leaq	.LC11(%rip), %rsi
	cltd
	idivl	%ecx
	movl	%eax, %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L22
.L26:
	movq	1048(%rsp), %rax
	subq	%fs:40, %rax
	je	.L24
	call	__stack_chk_fail@PLT
.L24:
	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
.LFE2028:
	.size	main, .-main
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2054:
	.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
.LFE2054:
	.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 getSPcores(hipDeviceProp_t devProp)
{  
    int cores = 0;
    int mp = devProp.multiProcessorCount;
    switch (devProp.major){
     case 2: // Fermi
      if (devProp.minor == 1) cores = mp * 48;
      else cores = mp * 32;
      break;
     case 3: // Kepler
      cores = mp * 192;
      break;
     case 5: // Maxwell
      cores = mp * 128;
      break;
     case 6: // Pascal
      if (devProp.minor == 1) cores = mp * 128;
      else if (devProp.minor == 0) cores = mp * 64;
      else printf("Unknown device type\n");
      break;
     case 7: // Volta
      if (devProp.minor == 0) cores = mp * 64;
      else printf("Unknown device type\n");
      break;
     default:
      printf("Unknown device type\n"); 
      break;
      }
    return cores;
}


int main() {
  int nDevices;

  hipGetDeviceCount(&nDevices);
  for (int i = 0; i < nDevices; i++) {
    hipDeviceProp_t prop;
    hipGetDeviceProperties(&prop, i);
    printf("Device Number: %d\n", i);
    printf("  Device name: %s\n", prop.name);
    printf("  Number of CUDA cores: %d\n", getSPcores(prop));
    printf("  Warp Size: %d\n", prop.warpSize);
    printf("  Max Threads Per Block: %d\n", prop.maxThreadsPerBlock);
    printf("  Max Grid Size: (%d, %d, %d)\n", prop.maxGridSize[0],prop.maxGridSize[1],prop.maxGridSize[2]);
    printf("  Max Block Size: (%d, %d, %d)\n", prop.maxThreadsDim[0],prop.maxThreadsDim[1],prop.maxThreadsDim[2]);
    printf("  Max Threads Per Multiprocessor: %d\n", prop.maxThreadsPerMultiProcessor);
    printf("  Total Global Memory: %zu GB\n", prop.totalGlobalMem>>30);
    printf("  Shared Memory per Block: %zu kB\n", prop.sharedMemPerBlock>>10);
    printf("  Register per Block: %d kB \n\n", prop.regsPerBlock/1024);

  }
}
	.text
	.file	"cudaprop.hip"
	.globl	_Z10getSPcores20hipDeviceProp_tR0600 # -- Begin function _Z10getSPcores20hipDeviceProp_tR0600
	.type	_Z10getSPcores20hipDeviceProp_tR0600,@function
_Z10getSPcores20hipDeviceProp_tR0600:   # @_Z10getSPcores20hipDeviceProp_tR0600
	.cfi_startproc
# %bb.0:
	pushq	%rax
	.cfi_def_cfa_offset 16
	movl	376(%rsp), %ecx
	addl	$-2, %ecx
	cmpl	$5, %ecx
	ja	.LBB0_10
# %bb.1:
	leaq	16(%rsp), %rdx
	movl	388(%rdx), %eax
	jmpq	*.LJTI0_0(,%rcx,8)
.LBB0_2:
	cmpl	$1, 364(%rdx)
	jne	.LBB0_12
# %bb.3:
	shll	$4, %eax
	jmp	.LBB0_4
.LBB0_5:
	shll	$6, %eax
.LBB0_4:
	leal	(%rax,%rax,2), %eax
	jmp	.LBB0_13
.LBB0_6:
	movl	364(%rdx), %ecx
	testl	%ecx, %ecx
	je	.LBB0_11
# %bb.7:
	cmpl	$1, %ecx
	jne	.LBB0_10
.LBB0_8:
	shll	$7, %eax
	jmp	.LBB0_13
.LBB0_9:
	cmpl	$0, 364(%rdx)
	je	.LBB0_11
.LBB0_10:
	movl	$.Lstr.2, %edi
	callq	puts@PLT
	xorl	%eax, %eax
	jmp	.LBB0_13
.LBB0_11:
	shll	$6, %eax
	jmp	.LBB0_13
.LBB0_12:
	shll	$5, %eax
.LBB0_13:
                                        # kill: def $eax killed $eax killed $rax
	popq	%rcx
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	_Z10getSPcores20hipDeviceProp_tR0600, .Lfunc_end0-_Z10getSPcores20hipDeviceProp_tR0600
	.cfi_endproc
	.section	.rodata,"a",@progbits
	.p2align	3, 0x0
.LJTI0_0:
	.quad	.LBB0_2
	.quad	.LBB0_5
	.quad	.LBB0_10
	.quad	.LBB0_8
	.quad	.LBB0_6
	.quad	.LBB0_9
                                        # -- End function
	.text
	.globl	main                            # -- Begin function main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	subq	$2952, %rsp                     # imm = 0xB88
	.cfi_def_cfa_offset 2976
	.cfi_offset %rbx, -24
	.cfi_offset %rbp, -16
	leaq	1476(%rsp), %rbx
	movq	%rbx, %rdi
	callq	hipGetDeviceCount
	cmpl	$0, (%rbx)
	jle	.LBB1_3
# %bb.1:                                # %.lr.ph
	leaq	1480(%rsp), %rbx
	xorl	%ebp, %ebp
.LBB1_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	$184, %ecx
	movq	%rsp, %rdi
	movq	%rbx, %rsi
	rep;movsq (%rsi), %es:(%rdi)
	callq	_Z10getSPcores20hipDeviceProp_tR0600
	movl	$.L.str.3, %edi
	movl	%eax, %esi
	xorl	%eax, %eax
	callq	printf
	movl	1788(%rsp), %esi
	movl	$.L.str.4, %edi
	xorl	%eax, %eax
	callq	printf
	movl	1800(%rsp), %esi
	movl	$.L.str.5, %edi
	xorl	%eax, %eax
	callq	printf
	movl	1816(%rsp), %esi
	movl	1820(%rsp), %edx
	movl	1824(%rsp), %ecx
	movl	$.L.str.6, %edi
	xorl	%eax, %eax
	callq	printf
	movl	1804(%rsp), %esi
	movl	1808(%rsp), %edx
	movl	1812(%rsp), %ecx
	movl	$.L.str.7, %edi
	xorl	%eax, %eax
	callq	printf
	movl	2104(%rsp), %esi
	movl	$.L.str.8, %edi
	xorl	%eax, %eax
	callq	printf
	movq	1768(%rsp), %rsi
	shrq	$30, %rsi
	movl	$.L.str.9, %edi
	xorl	%eax, %eax
	callq	printf
	movq	1776(%rsp), %rsi
	shrq	$10, %rsi
	movl	$.L.str.10, %edi
	xorl	%eax, %eax
	callq	printf
	movl	1784(%rsp), %eax
	leal	1023(%rax), %esi
	testl	%eax, %eax
	cmovnsl	%eax, %esi
	sarl	$10, %esi
	movl	$.L.str.11, %edi
	xorl	%eax, %eax
	callq	printf
	incl	%ebp
	cmpl	1476(%rsp), %ebp
	jl	.LBB1_2
.LBB1_3:                                # %._crit_edge
	xorl	%eax, %eax
	addq	$2952, %rsp                     # imm = 0xB88
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end1:
	.size	main, .Lfunc_end1-main
	.cfi_endproc
                                        # -- End function
	.type	.L.str.1,@object                # @.str.1
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.1:
	.asciz	"Device Number: %d\n"
	.size	.L.str.1, 19

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"  Device name: %s\n"
	.size	.L.str.2, 19

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"  Number of CUDA cores: %d\n"
	.size	.L.str.3, 28

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"  Warp Size: %d\n"
	.size	.L.str.4, 17

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"  Max Threads Per Block: %d\n"
	.size	.L.str.5, 29

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"  Max Grid Size: (%d, %d, %d)\n"
	.size	.L.str.6, 31

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"  Max Block Size: (%d, %d, %d)\n"
	.size	.L.str.7, 32

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"  Max Threads Per Multiprocessor: %d\n"
	.size	.L.str.8, 38

	.type	.L.str.9,@object                # @.str.9
.L.str.9:
	.asciz	"  Total Global Memory: %zu GB\n"
	.size	.L.str.9, 31

	.type	.L.str.10,@object               # @.str.10
.L.str.10:
	.asciz	"  Shared Memory per Block: %zu kB\n"
	.size	.L.str.10, 35

	.type	.L.str.11,@object               # @.str.11
.L.str.11:
	.asciz	"  Register per Block: %d kB \n\n"
	.size	.L.str.11, 31

	.type	__hip_cuid_,@object             # @__hip_cuid_
	.bss
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               # 0x0
	.size	__hip_cuid_, 1

	.type	.Lstr.2,@object                 # @str.2
	.section	.rodata.str1.1,"aMS",@progbits,1
.Lstr.2:
	.asciz	"Unknown device type"
	.size	.Lstr.2, 20

	.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
