node-gpuinfo 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +674 -0
- package/README.md +336 -0
- package/binding.gyp +69 -0
- package/build/Release/gpu.exp +0 -0
- package/build/Release/gpu.lib +0 -0
- package/build/Release/gpu.node +0 -0
- package/build/Release/gpu.pdb +0 -0
- package/build/binding.sln +19 -0
- package/build/gpu.vcxproj +175 -0
- package/build/gpu.vcxproj.filters +169 -0
- package/example.js +69 -0
- package/index.js +33 -0
- package/package.json +68 -0
- package/src/binding.cpp +201 -0
- package/src/gpu_info.c +130 -0
- package/src/gpu_info.h +86 -0
- package/src/includes/adlx/ADLX.h +367 -0
- package/src/includes/adlx/ADLXDefines.h +1345 -0
- package/src/includes/adlx/ADLXHelper/ADLXHelper.c +175 -0
- package/src/includes/adlx/ADLXHelper/ADLXHelper.h +245 -0
- package/src/includes/adlx/ADLXHelper/WinAPIS.c +64 -0
- package/src/includes/adlx/ADLXStructures.h +206 -0
- package/src/includes/adlx/ADLXVersion.h +18 -0
- package/src/includes/adlx/I3DSettings.h +3476 -0
- package/src/includes/adlx/I3DSettings1.h +292 -0
- package/src/includes/adlx/I3DSettings2.h +317 -0
- package/src/includes/adlx/IApplications.h +397 -0
- package/src/includes/adlx/IChangedEvent.h +71 -0
- package/src/includes/adlx/ICollections.h +325 -0
- package/src/includes/adlx/IDesktops.h +918 -0
- package/src/includes/adlx/IDisplay3DLUT.h +663 -0
- package/src/includes/adlx/IDisplayGamma.h +683 -0
- package/src/includes/adlx/IDisplayGamut.h +760 -0
- package/src/includes/adlx/IDisplaySettings.h +3476 -0
- package/src/includes/adlx/IDisplays.h +2676 -0
- package/src/includes/adlx/IDisplays1.h +191 -0
- package/src/includes/adlx/IDisplays2.h +188 -0
- package/src/includes/adlx/IDisplays3.h +256 -0
- package/src/includes/adlx/IGPUAutoTuning.h +460 -0
- package/src/includes/adlx/IGPUManualFanTuning.h +1007 -0
- package/src/includes/adlx/IGPUManualGFXTuning.h +607 -0
- package/src/includes/adlx/IGPUManualPowerTuning.h +340 -0
- package/src/includes/adlx/IGPUManualVRAMTuning.h +576 -0
- package/src/includes/adlx/IGPUPresetTuning.h +469 -0
- package/src/includes/adlx/IGPUTuning.h +1239 -0
- package/src/includes/adlx/IGPUTuning1.h +197 -0
- package/src/includes/adlx/II2C.h +198 -0
- package/src/includes/adlx/ILog.h +72 -0
- package/src/includes/adlx/IMultiMedia.h +578 -0
- package/src/includes/adlx/IPerformanceMonitoring.h +2520 -0
- package/src/includes/adlx/IPerformanceMonitoring1.h +134 -0
- package/src/includes/adlx/IPerformanceMonitoring2.h +341 -0
- package/src/includes/adlx/IPerformanceMonitoring3.h +199 -0
- package/src/includes/adlx/IPowerTuning.h +473 -0
- package/src/includes/adlx/IPowerTuning1.h +515 -0
- package/src/includes/adlx/ISmartAccessMemory.h +114 -0
- package/src/includes/adlx/ISystem.h +1557 -0
- package/src/includes/adlx/ISystem1.h +237 -0
- package/src/includes/adlx/ISystem2.h +643 -0
- package/src/linux/amd_linux.c +269 -0
- package/src/linux/intel_linux.c +20 -0
- package/src/linux/nvidia_linux.c +257 -0
- package/src/macos/amd_mac.c +131 -0
- package/src/macos/intel_mac.c +131 -0
- package/src/macos/nvidia_mac.c +21 -0
- package/src/vendor/amd.c +37 -0
- package/src/vendor/intel.c +37 -0
- package/src/vendor/nvidia.c +37 -0
- package/src/windows/amd_windows.c +468 -0
- package/src/windows/intel_windows.c +157 -0
- package/src/windows/nvidia_windows.c +252 -0
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
#include "../gpu_info.h"
|
|
2
|
+
#include <CoreFoundation/CoreFoundation.h>
|
|
3
|
+
#include <IOKit/IOKitLib.h>
|
|
4
|
+
#include <IOKit/graphics/IOGraphicsLib.h>
|
|
5
|
+
#include <stdio.h>
|
|
6
|
+
#include <string.h>
|
|
7
|
+
|
|
8
|
+
gpu_error_t intel_macos_get_gpu_count(int32_t* count) {
|
|
9
|
+
if (!count) return GPU_ERROR_INVALID_PARAM;
|
|
10
|
+
|
|
11
|
+
int intel_count = 0;
|
|
12
|
+
io_iterator_t iterator;
|
|
13
|
+
|
|
14
|
+
// Get list of all GPUs
|
|
15
|
+
kern_return_t kr = IOServiceGetMatchingServices(kIOMasterPortDefault,
|
|
16
|
+
IOServiceMatching("IOPCIDevice"),
|
|
17
|
+
&iterator);
|
|
18
|
+
|
|
19
|
+
if (kr != KERN_SUCCESS) {
|
|
20
|
+
*count = 0;
|
|
21
|
+
return GPU_ERROR_API_FAILED;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
io_object_t service;
|
|
25
|
+
while ((service = IOIteratorNext(iterator))) {
|
|
26
|
+
// Check if it's a display device
|
|
27
|
+
CFTypeRef vendorID = IORegistryEntryCreateCFProperty(service, CFSTR("vendor-id"),
|
|
28
|
+
kCFAllocatorDefault, 0);
|
|
29
|
+
|
|
30
|
+
if (vendorID) {
|
|
31
|
+
UInt32 vendor = 0;
|
|
32
|
+
CFDataGetBytes(vendorID, CFRangeMake(0, sizeof(UInt32)), (UInt8*)&vendor);
|
|
33
|
+
CFRelease(vendorID);
|
|
34
|
+
|
|
35
|
+
// Intel vendor ID is 0x8086
|
|
36
|
+
if (vendor == 0x8086) {
|
|
37
|
+
intel_count++;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
IOObjectRelease(service);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
IOObjectRelease(iterator);
|
|
45
|
+
*count = intel_count;
|
|
46
|
+
return GPU_SUCCESS;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
gpu_error_t intel_macos_get_gpu_info(int32_t index, gpu_info_t* info) {
|
|
50
|
+
if (!info) return GPU_ERROR_INVALID_PARAM;
|
|
51
|
+
|
|
52
|
+
int current_index = 0;
|
|
53
|
+
io_iterator_t iterator;
|
|
54
|
+
|
|
55
|
+
kern_return_t kr = IOServiceGetMatchingServices(kIOMasterPortDefault,
|
|
56
|
+
IOServiceMatching("IOPCIDevice"),
|
|
57
|
+
&iterator);
|
|
58
|
+
|
|
59
|
+
if (kr != KERN_SUCCESS) {
|
|
60
|
+
return GPU_ERROR_API_FAILED;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
io_object_t service;
|
|
64
|
+
int found = 0;
|
|
65
|
+
|
|
66
|
+
while ((service = IOIteratorNext(iterator))) {
|
|
67
|
+
CFTypeRef vendorID = IORegistryEntryCreateCFProperty(service, CFSTR("vendor-id"),
|
|
68
|
+
kCFAllocatorDefault, 0);
|
|
69
|
+
|
|
70
|
+
if (vendorID) {
|
|
71
|
+
UInt32 vendor = 0;
|
|
72
|
+
CFDataGetBytes(vendorID, CFRangeMake(0, sizeof(UInt32)), (UInt8*)&vendor);
|
|
73
|
+
CFRelease(vendorID);
|
|
74
|
+
|
|
75
|
+
if (vendor == 0x8086) { // Intel
|
|
76
|
+
if (current_index == index) {
|
|
77
|
+
found = 1;
|
|
78
|
+
|
|
79
|
+
memset(info, 0, sizeof(gpu_info_t));
|
|
80
|
+
info->index = index;
|
|
81
|
+
info->vendor = GPU_VENDOR_INTEL;
|
|
82
|
+
|
|
83
|
+
// Get model name
|
|
84
|
+
CFTypeRef model = IORegistryEntryCreateCFProperty(service, CFSTR("model"),
|
|
85
|
+
kCFAllocatorDefault, 0);
|
|
86
|
+
if (model && CFGetTypeID(model) == CFDataGetTypeID()) {
|
|
87
|
+
const char* modelStr = (const char*)CFDataGetBytePtr(model);
|
|
88
|
+
snprintf(info->name, sizeof(info->name), "%s", modelStr);
|
|
89
|
+
CFRelease(model);
|
|
90
|
+
} else {
|
|
91
|
+
snprintf(info->name, sizeof(info->name), "Intel GPU %d", index);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Get device ID for UUID
|
|
95
|
+
CFTypeRef deviceID = IORegistryEntryCreateCFProperty(service, CFSTR("device-id"),
|
|
96
|
+
kCFAllocatorDefault, 0);
|
|
97
|
+
if (deviceID) {
|
|
98
|
+
UInt32 devID = 0;
|
|
99
|
+
CFDataGetBytes(deviceID, CFRangeMake(0, sizeof(UInt32)), (UInt8*)&devID);
|
|
100
|
+
snprintf(info->uuid, sizeof(info->uuid), "INTEL-macOS-0x%04X", devID);
|
|
101
|
+
CFRelease(deviceID);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
snprintf(info->pci_bus_id, sizeof(info->pci_bus_id), "PCI:%d", index);
|
|
105
|
+
|
|
106
|
+
// macOS does not provide detailed GPU monitoring APIs
|
|
107
|
+
// Metal framework and IOKit have limited metrics access
|
|
108
|
+
info->memory_total = 0;
|
|
109
|
+
info->memory_used = 0;
|
|
110
|
+
info->memory_free = 0;
|
|
111
|
+
info->gpu_utilization = 0.0f;
|
|
112
|
+
info->memory_utilization = 0.0f;
|
|
113
|
+
info->temperature = 0.0f;
|
|
114
|
+
info->power_usage = 0.0f;
|
|
115
|
+
info->core_clock = 0;
|
|
116
|
+
info->memory_clock = 0;
|
|
117
|
+
info->fan_speed = 0.0f;
|
|
118
|
+
|
|
119
|
+
IOObjectRelease(service);
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
current_index++;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
IOObjectRelease(service);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
IOObjectRelease(iterator);
|
|
130
|
+
return found ? GPU_SUCCESS : GPU_ERROR_API_FAILED;
|
|
131
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#include "../gpu_info.h"
|
|
2
|
+
#include <stdio.h>
|
|
3
|
+
#include <string.h>
|
|
4
|
+
|
|
5
|
+
// macOS NVIDIA support is extremely limited
|
|
6
|
+
// Apple dropped NVIDIA support after macOS High Sierra (10.13)
|
|
7
|
+
|
|
8
|
+
gpu_error_t nvidia_macos_get_gpu_count(int32_t* count) {
|
|
9
|
+
if (!count) return GPU_ERROR_INVALID_PARAM;
|
|
10
|
+
|
|
11
|
+
// NVIDIA GPUs are not supported on modern macOS
|
|
12
|
+
*count = 0;
|
|
13
|
+
return GPU_SUCCESS;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
gpu_error_t nvidia_macos_get_gpu_info(int32_t index, gpu_info_t* info) {
|
|
17
|
+
if (!info) return GPU_ERROR_INVALID_PARAM;
|
|
18
|
+
|
|
19
|
+
// NVIDIA GPUs are not supported on modern macOS
|
|
20
|
+
return GPU_ERROR_NOT_SUPPORTED;
|
|
21
|
+
}
|
package/src/vendor/amd.c
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
#include "../gpu_info.h"
|
|
2
|
+
|
|
3
|
+
// Forward declarations for platform-specific implementations
|
|
4
|
+
#ifdef _WIN32
|
|
5
|
+
gpu_error_t amd_windows_get_gpu_count(int32_t* count);
|
|
6
|
+
gpu_error_t amd_windows_get_gpu_info(int32_t index, gpu_info_t* info);
|
|
7
|
+
#elif defined(__APPLE__)
|
|
8
|
+
gpu_error_t amd_macos_get_gpu_count(int32_t* count);
|
|
9
|
+
gpu_error_t amd_macos_get_gpu_info(int32_t index, gpu_info_t* info);
|
|
10
|
+
#else
|
|
11
|
+
gpu_error_t amd_linux_get_gpu_count(int32_t* count);
|
|
12
|
+
gpu_error_t amd_linux_get_gpu_info(int32_t index, gpu_info_t* info);
|
|
13
|
+
#endif
|
|
14
|
+
|
|
15
|
+
gpu_error_t amd_get_gpu_count(int32_t* count) {
|
|
16
|
+
if (!count) return GPU_ERROR_INVALID_PARAM;
|
|
17
|
+
|
|
18
|
+
#ifdef _WIN32
|
|
19
|
+
return amd_windows_get_gpu_count(count);
|
|
20
|
+
#elif defined(__APPLE__)
|
|
21
|
+
return amd_macos_get_gpu_count(count);
|
|
22
|
+
#else
|
|
23
|
+
return amd_linux_get_gpu_count(count);
|
|
24
|
+
#endif
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
gpu_error_t amd_get_gpu_info(int32_t index, gpu_info_t* info) {
|
|
28
|
+
if (!info) return GPU_ERROR_INVALID_PARAM;
|
|
29
|
+
|
|
30
|
+
#ifdef _WIN32
|
|
31
|
+
return amd_windows_get_gpu_info(index, info);
|
|
32
|
+
#elif defined(__APPLE__)
|
|
33
|
+
return amd_macos_get_gpu_info(index, info);
|
|
34
|
+
#else
|
|
35
|
+
return amd_linux_get_gpu_info(index, info);
|
|
36
|
+
#endif
|
|
37
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
#include "../gpu_info.h"
|
|
2
|
+
|
|
3
|
+
// Forward declarations for platform-specific implementations
|
|
4
|
+
#ifdef _WIN32
|
|
5
|
+
gpu_error_t intel_windows_get_gpu_count(int32_t* count);
|
|
6
|
+
gpu_error_t intel_windows_get_gpu_info(int32_t index, gpu_info_t* info);
|
|
7
|
+
#elif defined(__APPLE__)
|
|
8
|
+
gpu_error_t intel_macos_get_gpu_count(int32_t* count);
|
|
9
|
+
gpu_error_t intel_macos_get_gpu_info(int32_t index, gpu_info_t* info);
|
|
10
|
+
#else
|
|
11
|
+
gpu_error_t intel_linux_get_gpu_count(int32_t* count);
|
|
12
|
+
gpu_error_t intel_linux_get_gpu_info(int32_t index, gpu_info_t* info);
|
|
13
|
+
#endif
|
|
14
|
+
|
|
15
|
+
gpu_error_t intel_get_gpu_count(int32_t* count) {
|
|
16
|
+
if (!count) return GPU_ERROR_INVALID_PARAM;
|
|
17
|
+
|
|
18
|
+
#ifdef _WIN32
|
|
19
|
+
return intel_windows_get_gpu_count(count);
|
|
20
|
+
#elif defined(__APPLE__)
|
|
21
|
+
return intel_macos_get_gpu_count(count);
|
|
22
|
+
#else
|
|
23
|
+
return intel_linux_get_gpu_count(count);
|
|
24
|
+
#endif
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
gpu_error_t intel_get_gpu_info(int32_t index, gpu_info_t* info) {
|
|
28
|
+
if (!info) return GPU_ERROR_INVALID_PARAM;
|
|
29
|
+
|
|
30
|
+
#ifdef _WIN32
|
|
31
|
+
return intel_windows_get_gpu_info(index, info);
|
|
32
|
+
#elif defined(__APPLE__)
|
|
33
|
+
return intel_macos_get_gpu_info(index, info);
|
|
34
|
+
#else
|
|
35
|
+
return intel_linux_get_gpu_info(index, info);
|
|
36
|
+
#endif
|
|
37
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
#include "../gpu_info.h"
|
|
2
|
+
|
|
3
|
+
// Forward declarations for platform-specific implementations
|
|
4
|
+
#ifdef _WIN32
|
|
5
|
+
gpu_error_t nvidia_windows_get_gpu_count(int32_t* count);
|
|
6
|
+
gpu_error_t nvidia_windows_get_gpu_info(int32_t index, gpu_info_t* info);
|
|
7
|
+
#elif defined(__APPLE__)
|
|
8
|
+
gpu_error_t nvidia_macos_get_gpu_count(int32_t* count);
|
|
9
|
+
gpu_error_t nvidia_macos_get_gpu_info(int32_t index, gpu_info_t* info);
|
|
10
|
+
#else
|
|
11
|
+
gpu_error_t nvidia_linux_get_gpu_count(int32_t* count);
|
|
12
|
+
gpu_error_t nvidia_linux_get_gpu_info(int32_t index, gpu_info_t* info);
|
|
13
|
+
#endif
|
|
14
|
+
|
|
15
|
+
gpu_error_t nvidia_get_gpu_count(int32_t* count) {
|
|
16
|
+
if (!count) return GPU_ERROR_INVALID_PARAM;
|
|
17
|
+
|
|
18
|
+
#ifdef _WIN32
|
|
19
|
+
return nvidia_windows_get_gpu_count(count);
|
|
20
|
+
#elif defined(__APPLE__)
|
|
21
|
+
return nvidia_macos_get_gpu_count(count);
|
|
22
|
+
#else
|
|
23
|
+
return nvidia_linux_get_gpu_count(count);
|
|
24
|
+
#endif
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
gpu_error_t nvidia_get_gpu_info(int32_t index, gpu_info_t* info) {
|
|
28
|
+
if (!info) return GPU_ERROR_INVALID_PARAM;
|
|
29
|
+
|
|
30
|
+
#ifdef _WIN32
|
|
31
|
+
return nvidia_windows_get_gpu_info(index, info);
|
|
32
|
+
#elif defined(__APPLE__)
|
|
33
|
+
return nvidia_macos_get_gpu_info(index, info);
|
|
34
|
+
#else
|
|
35
|
+
return nvidia_linux_get_gpu_info(index, info);
|
|
36
|
+
#endif
|
|
37
|
+
}
|