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.
Files changed (71) hide show
  1. package/LICENSE +674 -0
  2. package/README.md +336 -0
  3. package/binding.gyp +69 -0
  4. package/build/Release/gpu.exp +0 -0
  5. package/build/Release/gpu.lib +0 -0
  6. package/build/Release/gpu.node +0 -0
  7. package/build/Release/gpu.pdb +0 -0
  8. package/build/binding.sln +19 -0
  9. package/build/gpu.vcxproj +175 -0
  10. package/build/gpu.vcxproj.filters +169 -0
  11. package/example.js +69 -0
  12. package/index.js +33 -0
  13. package/package.json +68 -0
  14. package/src/binding.cpp +201 -0
  15. package/src/gpu_info.c +130 -0
  16. package/src/gpu_info.h +86 -0
  17. package/src/includes/adlx/ADLX.h +367 -0
  18. package/src/includes/adlx/ADLXDefines.h +1345 -0
  19. package/src/includes/adlx/ADLXHelper/ADLXHelper.c +175 -0
  20. package/src/includes/adlx/ADLXHelper/ADLXHelper.h +245 -0
  21. package/src/includes/adlx/ADLXHelper/WinAPIS.c +64 -0
  22. package/src/includes/adlx/ADLXStructures.h +206 -0
  23. package/src/includes/adlx/ADLXVersion.h +18 -0
  24. package/src/includes/adlx/I3DSettings.h +3476 -0
  25. package/src/includes/adlx/I3DSettings1.h +292 -0
  26. package/src/includes/adlx/I3DSettings2.h +317 -0
  27. package/src/includes/adlx/IApplications.h +397 -0
  28. package/src/includes/adlx/IChangedEvent.h +71 -0
  29. package/src/includes/adlx/ICollections.h +325 -0
  30. package/src/includes/adlx/IDesktops.h +918 -0
  31. package/src/includes/adlx/IDisplay3DLUT.h +663 -0
  32. package/src/includes/adlx/IDisplayGamma.h +683 -0
  33. package/src/includes/adlx/IDisplayGamut.h +760 -0
  34. package/src/includes/adlx/IDisplaySettings.h +3476 -0
  35. package/src/includes/adlx/IDisplays.h +2676 -0
  36. package/src/includes/adlx/IDisplays1.h +191 -0
  37. package/src/includes/adlx/IDisplays2.h +188 -0
  38. package/src/includes/adlx/IDisplays3.h +256 -0
  39. package/src/includes/adlx/IGPUAutoTuning.h +460 -0
  40. package/src/includes/adlx/IGPUManualFanTuning.h +1007 -0
  41. package/src/includes/adlx/IGPUManualGFXTuning.h +607 -0
  42. package/src/includes/adlx/IGPUManualPowerTuning.h +340 -0
  43. package/src/includes/adlx/IGPUManualVRAMTuning.h +576 -0
  44. package/src/includes/adlx/IGPUPresetTuning.h +469 -0
  45. package/src/includes/adlx/IGPUTuning.h +1239 -0
  46. package/src/includes/adlx/IGPUTuning1.h +197 -0
  47. package/src/includes/adlx/II2C.h +198 -0
  48. package/src/includes/adlx/ILog.h +72 -0
  49. package/src/includes/adlx/IMultiMedia.h +578 -0
  50. package/src/includes/adlx/IPerformanceMonitoring.h +2520 -0
  51. package/src/includes/adlx/IPerformanceMonitoring1.h +134 -0
  52. package/src/includes/adlx/IPerformanceMonitoring2.h +341 -0
  53. package/src/includes/adlx/IPerformanceMonitoring3.h +199 -0
  54. package/src/includes/adlx/IPowerTuning.h +473 -0
  55. package/src/includes/adlx/IPowerTuning1.h +515 -0
  56. package/src/includes/adlx/ISmartAccessMemory.h +114 -0
  57. package/src/includes/adlx/ISystem.h +1557 -0
  58. package/src/includes/adlx/ISystem1.h +237 -0
  59. package/src/includes/adlx/ISystem2.h +643 -0
  60. package/src/linux/amd_linux.c +269 -0
  61. package/src/linux/intel_linux.c +20 -0
  62. package/src/linux/nvidia_linux.c +257 -0
  63. package/src/macos/amd_mac.c +131 -0
  64. package/src/macos/intel_mac.c +131 -0
  65. package/src/macos/nvidia_mac.c +21 -0
  66. package/src/vendor/amd.c +37 -0
  67. package/src/vendor/intel.c +37 -0
  68. package/src/vendor/nvidia.c +37 -0
  69. package/src/windows/amd_windows.c +468 -0
  70. package/src/windows/intel_windows.c +157 -0
  71. 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
+ }
@@ -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
+ }