// File: cudaGetDeviceProperties.cu
//
// Compiler Command:
// $ nvcc cudaGetDeviceProperties.cu -o cudaGetDeviceProperties

// Head files
#include <stdio.h>

#include <cuda_runtime.h>


// main function
int main(int argc, char **argv) {
    printf("%s Starting...\n", argv[0]);
    int deviceCount = 0;
    cudaError_t error_id = cudaGetDeviceCount(&deviceCount);
    if (error_id != cudaSuccess) {
        printf("cudaGetDeviceCount returned %d\n-> %s\n",
        (int)error_id, cudaGetErrorString(error_id));
        printf("Result = FAIL\n");
        exit(EXIT_FAILURE);
    }
    if (deviceCount == 0) {
        printf("There are no available device(s) that support CUDA\n");
    } else {
        printf("Detected %d CUDA Capable device(s)\n", deviceCount);
    }

    int dev, driverVersion = 0, runtimeVersion = 0;
    dev =0;
    cudaSetDevice(dev);
    cudaDeviceProp deviceProp;
    cudaGetDeviceProperties(&deviceProp, dev);
    printf("Device %d: \"%s\"\n", dev, deviceProp.name);
    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);
    printf(" CUDA Capability Major/Minor version number: %d.%d\n",deviceProp.major, deviceProp.minor);
    printf(" Total amount of global memory: %.2f MBytes (%llu bytes)\n",(float)deviceProp.totalGlobalMem/(pow(1024.0,3)),(unsigned long long) deviceProp.totalGlobalMem);
    printf(" GPU Clock rate: %.0f MHz (%0.2f GHz)\n",deviceProp.clockRate * 1e-3f, deviceProp.clockRate * 1e-6f);
    printf(" Memory Clock rate: %.0f Mhz\n",deviceProp.memoryClockRate * 1e-3f);
    printf(" Memory Bus Width: %d-bit\n",deviceProp.memoryBusWidth);
    if (deviceProp.l2CacheSize) {
        printf(" L2 Cache Size: %d bytes\n",
        deviceProp.l2CacheSize);
    }

    printf(" Max Texture Dimension Size (x,y,z) 1D=(%d), 2D=(%d,%d), 3D=(%d,%d,%d)\n",
    deviceProp.maxTexture1D , deviceProp.maxTexture2D[0],
    deviceProp.maxTexture2D[1],
    deviceProp.maxTexture3D[0], deviceProp.maxTexture3D[1],
    deviceProp.maxTexture3D[2]);

    printf(" Max Layered Texture Size (dim) x layers 1D=(%d) x %d, 2D=(%d,%d) x %d\n",
    deviceProp.maxTexture1DLayered[0], deviceProp.maxTexture1DLayered[1],
    deviceProp.maxTexture2DLayered[0], deviceProp.maxTexture2DLayered[1],
    deviceProp.maxTexture2DLayered[2]);

    printf(" Total amount of constant memory: %lu bytes\n",deviceProp.totalConstMem);
    printf(" Total amount of shared memory per block: %lu bytes\n",deviceProp.sharedMemPerBlock);
    printf(" Total number of registers available per block: %d\n",deviceProp.regsPerBlock);
    printf(" Warp size: %d\n", deviceProp.warpSize);
    printf(" Maximum number of threads per multiprocessor: %d\n",deviceProp.maxThreadsPerMultiProcessor);
    printf(" Maximum number of threads per block: %d\n",deviceProp.maxThreadsPerBlock);

    printf(" Maximum sizes of each dimension of a block: %d x %d x %d\n",
    deviceProp.maxThreadsDim[0],
    deviceProp.maxThreadsDim[1],
    deviceProp.maxThreadsDim[2]);

    printf(" Maximum sizes of each dimension of a grid: %d x %d x %d\n",
    deviceProp.maxGridSize[0],
    deviceProp.maxGridSize[1],
    deviceProp.maxGridSize[2]);

    printf(" Maximum memory pitch: %lu bytes\n", deviceProp.memPitch);

    exit(EXIT_SUCCESS);
}


// For a system with multiple GPUs, it's necessary to choose one of these GPUs as our device.
// The stratage is that: the GPU with best performance must has the largest number of SMs.
// Implementation code listed below: 

// int numDevices = 0;
// cudaGetDeviceCount(&numDevices);
// if (numDevices > 1) {
//     int maxMultiprocessors = 0, maxDevice = 0;
//     for (int device=0; device<numDevices; device++) {
//         cudaDeviceProp props;
//         cudaGetDeviceProperties(&props, device);
//         if (maxMultiprocessors < props.multiProcessorCount) {
//             maxMultiprocessors = props.multiProcessorCount;
//             maxDevice = device;
//         }
//     }
//     cudaSetDevice(maxDevice);
// }


// Runnning result
// yangyang@yangyang-XPS-8900:~/Desktop/cudaCodeDebug/CodeDebug2$ ./cudaGetDeviceProperties 
// ./cudaGetDeviceProperties Starting...
// Detected 1 CUDA Capable device(s)
// Device 0: "GeForce GTX 750 Ti"
//  CUDA Driver Version / Runtime Version 9.1 / 9.1
//  CUDA Capability Major/Minor version number: 5.0
//  Total amount of global memory: 1.95 MBytes (2090598400 bytes)
//  GPU Clock rate: 1084 MHz (1.08 GHz)
//  Memory Clock rate: 2700 Mhz
//  Memory Bus Width: 128-bit
//  L2 Cache Size: 2097152 bytes
//  Max Texture Dimension Size (x,y,z) 1D=(65536), 2D=(65536,65536), 3D=(4096,4096,4096)
//  Max Layered Texture Size (dim) x layers 1D=(16384) x 2048, 2D=(16384,16384) x 2048
//  Total amount of constant memory: 65536 bytes
//  Total amount of shared memory per block: 49152 bytes
//  Total number of registers available per block: 65536
//  Warp size: 32
//  Maximum number of threads per multiprocessor: 2048
//  Maximum number of threads per block: 1024
//  Maximum sizes of each dimension of a block: 1024 x 1024 x 64
//  Maximum sizes of each dimension of a grid: 2147483647 x 65535 x 65535
//  Maximum memory pitch: 2147483647 bytes




	.file	"tmpxft_003398fe_00000000-6_cudaGetDeviceProperties.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	"%s Starting...\n"
.LC1:
	.string	"cudaGetDeviceCount returned %d\n-> %s\n"
.LC2:
	.string	"Result = FAIL\n"
.LC3:
	.string	"There are no available device(s) that support CUDA\n"
.LC4:
	.string	"Detected %d CUDA Capable device(s)\n"
.LC5:
	.string	"Device %d: \"%s\"\n"
.LC6:
	.string	" CUDA Driver Version / Runtime Version %d.%d / %d.%d\n"
.LC7:
	.string	" CUDA Capability Major/Minor version number: %d.%d\n"
.LC9:
	.string	" Total amount of global memory: %.2f MBytes (%llu bytes)\n"
.LC12:
	.string	" GPU Clock rate: %.0f MHz (%0.2f GHz)\n"
.LC13:
	.string	" Memory Clock rate: %.0f Mhz\n"
.LC14:
	.string	" Memory Bus Width: %d-bit\n"
.LC15:
	.string	" L2 Cache Size: %d bytes\n"
.LC16:
	.string	" Max Texture Dimension Size (x,y,z) 1D=(%d), 2D=(%d,%d), 3D=(%d,%d,%d)\n"
.LC17:
	.string	" Max Layered Texture Size (dim) x layers 1D=(%d) x %d, 2D=(%d,%d) x %d\n"
.LC18:
	.string	" Total amount of constant memory: %lu bytes\n"
.LC19:
	.string	" Total amount of shared memory per block: %lu bytes\n"
.LC20:
	.string	" Total number of registers available per block: %d\n"
.LC21:
	.string	" Warp size: %d\n"
.LC22:
	.string	" Maximum number of threads per multiprocessor: %d\n"
.LC23:
	.string	" Maximum number of threads per block: %d\n"
.LC24:
	.string	" Maximum sizes of each dimension of a block: %d x %d x %d\n"
.LC25:
	.string	" Maximum sizes of each dimension of a grid: %d x %d x %d\n"
.LC26:
	.string	" Maximum memory pitch: %lu bytes\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2027:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	movl	$2, %edi
	subq	$1056, %rsp
	.cfi_def_cfa_offset 1072
	movq	(%rsi), %rdx
	leaq	.LC0(%rip), %rsi
	movq	%fs:40, %rax
	movq	%rax, 1048(%rsp)
	xorl	%eax, %eax
	call	__printf_chk@PLT
	xorl	%esi, %esi
	leaq	4(%rsp), %rdi
	movl	%esi, 4(%rsp)
	call	cudaGetDeviceCount@PLT
	testl	%eax, %eax
	je	.L3
	movl	%eax, %edi
	movl	%eax, %ebx
	call	cudaGetErrorString@PLT
	movl	%ebx, %edx
	movl	$2, %edi
	leaq	.LC1(%rip), %rsi
	movq	%rax, %rcx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	$2, %edi
	leaq	.LC2(%rip), %rsi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	$1, %edi
	jmp	.L14
.L3:
	movl	4(%rsp), %edx
	testl	%edx, %edx
	jne	.L4
	leaq	.LC3(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L5
.L4:
	leaq	.LC4(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L5:
	xorl	%ecx, %ecx
	xorl	%edi, %edi
	leaq	16(%rsp), %rbx
	movl	%ecx, 8(%rsp)
	movl	%ecx, 12(%rsp)
	call	cudaSetDevice@PLT
	xorl	%esi, %esi
	movq	%rbx, %rdi
	call	cudaGetDeviceProperties_v2@PLT
	movq	%rbx, %rcx
	xorl	%edx, %edx
	movl	$2, %edi
	leaq	.LC5(%rip), %rsi
	xorl	%eax, %eax
	call	__printf_chk@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	.LC6(%rip), %rsi
	movl	%eax, %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	376(%rsp), %edx
	movl	$2, %edi
	xorl	%eax, %eax
	movl	380(%rsp), %ecx
	leaq	.LC7(%rip), %rsi
	call	__printf_chk@PLT
	movq	304(%rsp), %rdx
	testq	%rdx, %rdx
	js	.L6
	cvtsi2ssq	%rdx, %xmm0
	jmp	.L7
.L6:
	movq	%rdx, %rax
	movq	%rdx, %rcx
	shrq	%rax
	andl	$1, %ecx
	orq	%rcx, %rax
	cvtsi2ssq	%rax, %xmm0
	addss	%xmm0, %xmm0
.L7:
	cvtss2sd	%xmm0, %xmm0
	leaq	.LC9(%rip), %rsi
	mulsd	.LC8(%rip), %xmm0
	movl	$2, %edi
	movb	$1, %al
	call	__printf_chk@PLT
	movss	.LC10(%rip), %xmm1
	leaq	.LC12(%rip), %rsi
	movb	$2, %al
	cvtsi2ssl	364(%rsp), %xmm0
	movl	$2, %edi
	mulss	%xmm0, %xmm1
	mulss	.LC11(%rip), %xmm0
	cvtss2sd	%xmm1, %xmm1
	cvtss2sd	%xmm0, %xmm0
	call	__printf_chk@PLT
	movl	$2, %edi
	movb	$1, %al
	cvtsi2ssl	624(%rsp), %xmm0
	leaq	.LC13(%rip), %rsi
	mulss	.LC11(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	call	__printf_chk@PLT
	movl	$2, %edi
	xorl	%eax, %eax
	movl	628(%rsp), %edx
	leaq	.LC14(%rip), %rsi
	call	__printf_chk@PLT
	movl	632(%rsp), %edx
	testl	%edx, %edx
	je	.L8
	leaq	.LC15(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L8:
	movl	480(%rsp), %eax
	leaq	.LC16(%rip), %rsi
	movl	$2, %edi
	pushq	%rax
	.cfi_def_cfa_offset 1080
	movl	484(%rsp), %eax
	pushq	%rax
	.cfi_def_cfa_offset 1088
	movl	488(%rsp), %r9d
	xorl	%eax, %eax
	movl	456(%rsp), %r8d
	movl	452(%rsp), %ecx
	movl	440(%rsp), %edx
	call	__printf_chk@PLT
	movl	532(%rsp), %eax
	movl	528(%rsp), %r9d
	leaq	.LC17(%rip), %rsi
	movl	524(%rsp), %r8d
	movl	520(%rsp), %ecx
	movl	$2, %edi
	movl	516(%rsp), %edx
	movl	%eax, (%rsp)
	xorl	%eax, %eax
	call	__printf_chk@PLT
	popq	%rax
	.cfi_def_cfa_offset 1080
	popq	%rdx
	.cfi_def_cfa_offset 1072
	movl	$2, %edi
	movq	368(%rsp), %rdx
	leaq	.LC18(%rip), %rsi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	312(%rsp), %rdx
	leaq	.LC19(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
	movl	320(%rsp), %edx
	leaq	.LC20(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
	movl	324(%rsp), %edx
	leaq	.LC21(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
	movl	640(%rsp), %edx
	leaq	.LC22(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
	movl	336(%rsp), %edx
	leaq	.LC23(%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	.LC24(%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	.LC25(%rip), %rsi
	movl	$2, %edi
	call	__printf_chk@PLT
	movq	328(%rsp), %rdx
	movl	$2, %edi
	xorl	%eax, %eax
	leaq	.LC26(%rip), %rsi
	call	__printf_chk@PLT
	xorl	%edi, %edi
.L14:
	call	exit@PLT
	.cfi_endproc
.LFE2027:
	.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
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC8:
	.long	0
	.long	1041235968
	.section	.rodata.cst4,"aM",@progbits,4
	.align 4
.LC10:
	.long	897988541
	.align 4
.LC11:
	.long	981668463
	.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:

// File: cudaGetDeviceProperties.cu
//
// Compiler Command:
// $ nvcc cudaGetDeviceProperties.cu -o cudaGetDeviceProperties

// Head files
#include <stdio.h>

#include <hip/hip_runtime.h>


// main function
int main(int argc, char **argv) {
    printf("%s Starting...\n", argv[0]);
    int deviceCount = 0;
    hipError_t error_id = hipGetDeviceCount(&deviceCount);
    if (error_id != hipSuccess) {
        printf("hipGetDeviceCount returned %d\n-> %s\n",
        (int)error_id, hipGetErrorString(error_id));
        printf("Result = FAIL\n");
        exit(EXIT_FAILURE);
    }
    if (deviceCount == 0) {
        printf("There are no available device(s) that support CUDA\n");
    } else {
        printf("Detected %d CUDA Capable device(s)\n", deviceCount);
    }

    int dev, driverVersion = 0, runtimeVersion = 0;
    dev =0;
    hipSetDevice(dev);
    hipDeviceProp_t deviceProp;
    hipGetDeviceProperties(&deviceProp, dev);
    printf("Device %d: \"%s\"\n", dev, deviceProp.name);
    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);
    printf(" CUDA Capability Major/Minor version number: %d.%d\n",deviceProp.major, deviceProp.minor);
    printf(" Total amount of global memory: %.2f MBytes (%llu bytes)\n",(float)deviceProp.totalGlobalMem/(pow(1024.0,3)),(unsigned long long) deviceProp.totalGlobalMem);
    printf(" GPU Clock rate: %.0f MHz (%0.2f GHz)\n",deviceProp.clockRate * 1e-3f, deviceProp.clockRate * 1e-6f);
    printf(" Memory Clock rate: %.0f Mhz\n",deviceProp.memoryClockRate * 1e-3f);
    printf(" Memory Bus Width: %d-bit\n",deviceProp.memoryBusWidth);
    if (deviceProp.l2CacheSize) {
        printf(" L2 Cache Size: %d bytes\n",
        deviceProp.l2CacheSize);
    }

    printf(" Max Texture Dimension Size (x,y,z) 1D=(%d), 2D=(%d,%d), 3D=(%d,%d,%d)\n",
    deviceProp.maxTexture1D , deviceProp.maxTexture2D[0],
    deviceProp.maxTexture2D[1],
    deviceProp.maxTexture3D[0], deviceProp.maxTexture3D[1],
    deviceProp.maxTexture3D[2]);

    printf(" Max Layered Texture Size (dim) x layers 1D=(%d) x %d, 2D=(%d,%d) x %d\n",
    deviceProp.maxTexture1DLayered[0], deviceProp.maxTexture1DLayered[1],
    deviceProp.maxTexture2DLayered[0], deviceProp.maxTexture2DLayered[1],
    deviceProp.maxTexture2DLayered[2]);

    printf(" Total amount of constant memory: %lu bytes\n",deviceProp.totalConstMem);
    printf(" Total amount of shared memory per block: %lu bytes\n",deviceProp.sharedMemPerBlock);
    printf(" Total number of registers available per block: %d\n",deviceProp.regsPerBlock);
    printf(" Warp size: %d\n", deviceProp.warpSize);
    printf(" Maximum number of threads per multiprocessor: %d\n",deviceProp.maxThreadsPerMultiProcessor);
    printf(" Maximum number of threads per block: %d\n",deviceProp.maxThreadsPerBlock);

    printf(" Maximum sizes of each dimension of a block: %d x %d x %d\n",
    deviceProp.maxThreadsDim[0],
    deviceProp.maxThreadsDim[1],
    deviceProp.maxThreadsDim[2]);

    printf(" Maximum sizes of each dimension of a grid: %d x %d x %d\n",
    deviceProp.maxGridSize[0],
    deviceProp.maxGridSize[1],
    deviceProp.maxGridSize[2]);

    printf(" Maximum memory pitch: %lu bytes\n", deviceProp.memPitch);

    exit(EXIT_SUCCESS);
}


// For a system with multiple GPUs, it's necessary to choose one of these GPUs as our device.
// The stratage is that: the GPU with best performance must has the largest number of SMs.
// Implementation code listed below: 

// int numDevices = 0;
// cudaGetDeviceCount(&numDevices);
// if (numDevices > 1) {
//     int maxMultiprocessors = 0, maxDevice = 0;
//     for (int device=0; device<numDevices; device++) {
//         cudaDeviceProp props;
//         cudaGetDeviceProperties(&props, device);
//         if (maxMultiprocessors < props.multiProcessorCount) {
//             maxMultiprocessors = props.multiProcessorCount;
//             maxDevice = device;
//         }
//     }
//     cudaSetDevice(maxDevice);
// }


// Runnning result
// yangyang@yangyang-XPS-8900:~/Desktop/cudaCodeDebug/CodeDebug2$ ./cudaGetDeviceProperties 
// ./cudaGetDeviceProperties Starting...
// Detected 1 CUDA Capable device(s)
// Device 0: "GeForce GTX 750 Ti"
//  CUDA Driver Version / Runtime Version 9.1 / 9.1
//  CUDA Capability Major/Minor version number: 5.0
//  Total amount of global memory: 1.95 MBytes (2090598400 bytes)
//  GPU Clock rate: 1084 MHz (1.08 GHz)
//  Memory Clock rate: 2700 Mhz
//  Memory Bus Width: 128-bit
//  L2 Cache Size: 2097152 bytes
//  Max Texture Dimension Size (x,y,z) 1D=(65536), 2D=(65536,65536), 3D=(4096,4096,4096)
//  Max Layered Texture Size (dim) x layers 1D=(16384) x 2048, 2D=(16384,16384) x 2048
//  Total amount of constant memory: 65536 bytes
//  Total amount of shared memory per block: 49152 bytes
//  Total number of registers available per block: 65536
//  Warp size: 32
//  Maximum number of threads per multiprocessor: 2048
//  Maximum number of threads per block: 1024
//  Maximum sizes of each dimension of a block: 1024 x 1024 x 64
//  Maximum sizes of each dimension of a grid: 2147483647 x 65535 x 65535
//  Maximum memory pitch: 2147483647 bytes




	.text
	.file	"cudaGetDeviceProperties.hip"
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI0_0:
	.quad	0x3e10000000000000              # double 9.3132257461547852E-10
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0
.LCPI0_1:
	.long	0x3a83126f                      # float 0.00100000005
.LCPI0_2:
	.long	0x358637bd                      # float 9.99999997E-7
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	subq	$1504, %rsp                     # imm = 0x5E0
	.cfi_def_cfa_offset 1536
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	(%rsi), %rsi
	movl	$.L.str, %edi
	xorl	%eax, %eax
	callq	printf
	leaq	20(%rsp), %rdi
	movl	$0, (%rdi)
	callq	hipGetDeviceCount
	testl	%eax, %eax
	jne	.LBB0_10
# %bb.1:
	movl	20(%rsp), %esi
	testl	%esi, %esi
	jne	.LBB0_3
# %bb.2:
	movl	$.Lstr, %edi
	callq	puts@PLT
	jmp	.LBB0_4
.LBB0_10:
	movl	%eax, %ebx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.1, %edi
	movl	%ebx, %esi
	movq	%rax, %rdx
	xorl	%eax, %eax
	callq	printf
	movl	$.Lstr.1, %edi
	callq	puts@PLT
	movl	$1, %edi
	callq	exit
.LBB0_3:
	movl	$.L.str.4, %edi
	xorl	%eax, %eax
	callq	printf
.LBB0_4:
	xorl	%eax, %eax
	leaq	28(%rsp), %r15
	movl	%eax, (%r15)
	leaq	24(%rsp), %r14
	movl	%eax, (%r14)
	xorl	%edi, %edi
	callq	hipSetDevice
	leaq	32(%rsp), %rbx
	movq	%rbx, %rdi
	xorl	%esi, %esi
	callq	hipGetDevicePropertiesR0600
	movl	$.L.str.5, %edi
	xorl	%esi, %esi
	movq	%rbx, %rdx
	xorl	%eax, %eax
	callq	printf
	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.6, %edi
                                        # kill: def $esi killed $esi killed $rsi
                                        # kill: def $ecx killed $ecx killed $rcx
	xorl	%eax, %eax
	callq	printf
	movl	360(%rbx), %esi
	movl	364(%rbx), %edx
	movl	$.L.str.7, %edi
	xorl	%eax, %eax
	callq	printf
	movq	288(%rbx), %rsi
	testq	%rsi, %rsi
	js	.LBB0_5
# %bb.6:
	cvtsi2ss	%rsi, %xmm0
	jmp	.LBB0_7
.LBB0_5:
	movq	%rsi, %rax
	shrq	%rax
	movl	%esi, %ecx
	andl	$1, %ecx
	orq	%rax, %rcx
	cvtsi2ss	%rcx, %xmm0
	addss	%xmm0, %xmm0
.LBB0_7:
	cvtss2sd	%xmm0, %xmm0
	mulsd	.LCPI0_0(%rip), %xmm0
	movl	$.L.str.8, %edi
	movb	$1, %al
	callq	printf
	cvtsi2ssl	380(%rsp), %xmm1
	movaps	%xmm1, %xmm0
	mulss	.LCPI0_1(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	mulss	.LCPI0_2(%rip), %xmm1
	cvtss2sd	%xmm1, %xmm1
	movl	$.L.str.9, %edi
	movb	$2, %al
	callq	printf
	xorps	%xmm0, %xmm0
	cvtsi2ssl	640(%rsp), %xmm0
	mulss	.LCPI0_1(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	movl	$.L.str.10, %edi
	movb	$1, %al
	callq	printf
	movl	644(%rsp), %esi
	movl	$.L.str.11, %edi
	xorl	%eax, %eax
	callq	printf
	movl	648(%rsp), %esi
	testl	%esi, %esi
	je	.LBB0_9
# %bb.8:
	movl	$.L.str.12, %edi
	xorl	%eax, %eax
	callq	printf
.LBB0_9:
	movl	440(%rsp), %esi
	movl	452(%rsp), %edx
	movl	456(%rsp), %ecx
	movl	488(%rsp), %r8d
	movl	492(%rsp), %r9d
	movl	496(%rsp), %eax
	movl	%eax, (%rsp)
	movl	$.L.str.13, %edi
	xorl	%eax, %eax
	callq	printf
	movl	516(%rsp), %esi
	movl	520(%rsp), %edx
	movl	524(%rsp), %ecx
	movl	528(%rsp), %r8d
	movl	532(%rsp), %r9d
	movl	$.L.str.14, %edi
	xorl	%eax, %eax
	callq	printf
	movq	384(%rsp), %rsi
	movl	$.L.str.15, %edi
	xorl	%eax, %eax
	callq	printf
	movq	328(%rsp), %rsi
	movl	$.L.str.16, %edi
	xorl	%eax, %eax
	callq	printf
	movl	336(%rsp), %esi
	movl	$.L.str.17, %edi
	xorl	%eax, %eax
	callq	printf
	movl	340(%rsp), %esi
	movl	$.L.str.18, %edi
	xorl	%eax, %eax
	callq	printf
	movl	656(%rsp), %esi
	movl	$.L.str.19, %edi
	xorl	%eax, %eax
	callq	printf
	movl	352(%rsp), %esi
	movl	$.L.str.20, %edi
	xorl	%eax, %eax
	callq	printf
	movl	356(%rsp), %esi
	movl	360(%rsp), %edx
	movl	364(%rsp), %ecx
	movl	$.L.str.21, %edi
	xorl	%eax, %eax
	callq	printf
	movl	368(%rsp), %esi
	movl	372(%rsp), %edx
	movl	376(%rsp), %ecx
	movl	$.L.str.22, %edi
	xorl	%eax, %eax
	callq	printf
	movq	344(%rsp), %rsi
	movl	$.L.str.23, %edi
	xorl	%eax, %eax
	callq	printf
	xorl	%edi, %edi
	callq	exit
.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	"%s Starting...\n"
	.size	.L.str, 16

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"hipGetDeviceCount returned %d\n-> %s\n"
	.size	.L.str.1, 37

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"Detected %d CUDA Capable device(s)\n"
	.size	.L.str.4, 36

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

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	" CUDA Driver Version / Runtime Version %d.%d / %d.%d\n"
	.size	.L.str.6, 54

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

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	" Total amount of global memory: %.2f MBytes (%llu bytes)\n"
	.size	.L.str.8, 58

	.type	.L.str.9,@object                # @.str.9
.L.str.9:
	.asciz	" GPU Clock rate: %.0f MHz (%0.2f GHz)\n"
	.size	.L.str.9, 39

	.type	.L.str.10,@object               # @.str.10
.L.str.10:
	.asciz	" Memory Clock rate: %.0f Mhz\n"
	.size	.L.str.10, 30

	.type	.L.str.11,@object               # @.str.11
.L.str.11:
	.asciz	" Memory Bus Width: %d-bit\n"
	.size	.L.str.11, 27

	.type	.L.str.12,@object               # @.str.12
.L.str.12:
	.asciz	" L2 Cache Size: %d bytes\n"
	.size	.L.str.12, 26

	.type	.L.str.13,@object               # @.str.13
.L.str.13:
	.asciz	" Max Texture Dimension Size (x,y,z) 1D=(%d), 2D=(%d,%d), 3D=(%d,%d,%d)\n"
	.size	.L.str.13, 72

	.type	.L.str.14,@object               # @.str.14
.L.str.14:
	.asciz	" Max Layered Texture Size (dim) x layers 1D=(%d) x %d, 2D=(%d,%d) x %d\n"
	.size	.L.str.14, 72

	.type	.L.str.15,@object               # @.str.15
.L.str.15:
	.asciz	" Total amount of constant memory: %lu bytes\n"
	.size	.L.str.15, 45

	.type	.L.str.16,@object               # @.str.16
.L.str.16:
	.asciz	" Total amount of shared memory per block: %lu bytes\n"
	.size	.L.str.16, 53

	.type	.L.str.17,@object               # @.str.17
.L.str.17:
	.asciz	" Total number of registers available per block: %d\n"
	.size	.L.str.17, 52

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

	.type	.L.str.19,@object               # @.str.19
.L.str.19:
	.asciz	" Maximum number of threads per multiprocessor: %d\n"
	.size	.L.str.19, 51

	.type	.L.str.20,@object               # @.str.20
.L.str.20:
	.asciz	" Maximum number of threads per block: %d\n"
	.size	.L.str.20, 42

	.type	.L.str.21,@object               # @.str.21
.L.str.21:
	.asciz	" Maximum sizes of each dimension of a block: %d x %d x %d\n"
	.size	.L.str.21, 59

	.type	.L.str.22,@object               # @.str.22
.L.str.22:
	.asciz	" Maximum sizes of each dimension of a grid: %d x %d x %d\n"
	.size	.L.str.22, 58

	.type	.L.str.23,@object               # @.str.23
.L.str.23:
	.asciz	" Maximum memory pitch: %lu bytes\n"
	.size	.L.str.23, 34

	.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 are no available device(s) that support CUDA"
	.size	.Lstr, 51

	.type	.Lstr.1,@object                 # @str.1
.Lstr.1:
	.asciz	"Result = FAIL"
	.size	.Lstr.1, 14

	.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
