[v0.11] Working for future support of Intel iGPUs
This commit is contained in:
@@ -9,7 +9,8 @@
|
||||
#define UNKNOWN_FREQ -1
|
||||
|
||||
enum {
|
||||
GPU_VENDOR_NVIDIA
|
||||
GPU_VENDOR_NVIDIA,
|
||||
GPU_VENDOR_INTEL
|
||||
};
|
||||
|
||||
enum {
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "args.hpp"
|
||||
#include "global.hpp"
|
||||
#include "master.hpp"
|
||||
#include "../cuda/cuda.hpp"
|
||||
#include "../cuda/uarch.hpp"
|
||||
|
||||
@@ -65,8 +66,9 @@ int main(int argc, char* argv[]) {
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
struct gpu_list* list = get_gpu_list();
|
||||
if(list_gpus()) {
|
||||
return print_gpus_list();
|
||||
return print_gpus_list(list);
|
||||
}
|
||||
|
||||
set_log_level(true);
|
||||
@@ -76,7 +78,7 @@ If you want to help to improve gpufetch, please compare the output of the progra
|
||||
with a reliable source which you know is right (e.g, techpowerup.com) and report\n\
|
||||
any inconsistencies to https://github.com/Dr-Noob/gpufetch/issues");
|
||||
|
||||
struct gpu_info* gpu = get_gpu_info(get_gpu_idx());
|
||||
struct gpu_info* gpu = get_gpu_info(list, get_gpu_idx());
|
||||
if(gpu == NULL)
|
||||
return EXIT_FAILURE;
|
||||
|
||||
|
||||
46
src/common/master.cpp
Normal file
46
src/common/master.cpp
Normal file
@@ -0,0 +1,46 @@
|
||||
#include <stdbool.h>
|
||||
#include <cstddef>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "master.hpp"
|
||||
|
||||
#define MAX_GPUS 1000
|
||||
|
||||
struct gpu_list {
|
||||
struct gpu_info ** gpus;
|
||||
int num_gpus;
|
||||
};
|
||||
|
||||
struct gpu_list* get_gpu_list() {
|
||||
bool valid = true;
|
||||
struct gpu_list* list = (struct gpu_list*) malloc(sizeof(struct gpu_list));
|
||||
list->num_gpus = 0;
|
||||
list->gpus = (struct gpu_info**) malloc(sizeof(struct info*) * MAX_GPUS);
|
||||
|
||||
#ifdef ENABLE_CUDA_BACKEND
|
||||
int idx = 0;
|
||||
|
||||
while(valid) {
|
||||
list->gpus[idx] = get_gpu_info_cuda(idx);
|
||||
if(list->gpus[idx] != NULL) idx++;
|
||||
else valid = false;
|
||||
}
|
||||
|
||||
list->num_gpus += idx;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_INTEL_BACKEND
|
||||
list->gpus[idx] = get_gpu_info_intel();
|
||||
if(list->gpus[idx] != NULL) list->num_gpus++;
|
||||
#endif
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
bool print_gpus_list(struct gpu_list* list) {
|
||||
return false;
|
||||
}
|
||||
|
||||
struct gpu_info* get_gpu_info(struct gpu_list* list, int idx) {
|
||||
return list->gpus[idx];
|
||||
}
|
||||
12
src/common/master.hpp
Normal file
12
src/common/master.hpp
Normal file
@@ -0,0 +1,12 @@
|
||||
#ifndef __GPU_LIST__
|
||||
#define __GPU_LIST__
|
||||
|
||||
#include "gpu.hpp"
|
||||
|
||||
struct gpu_list;
|
||||
|
||||
struct gpu_list* get_gpu_list();
|
||||
bool print_gpus_list(struct gpu_list* list);
|
||||
struct gpu_info* get_gpu_info(struct gpu_list* list, int idx);
|
||||
|
||||
#endif
|
||||
@@ -342,6 +342,13 @@ void print_ascii_generic(struct ascii* art, uint32_t la, int32_t text_space, con
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
#ifdef ENABLE_INTEL_BACKEND
|
||||
bool print_gpufetch_intel(struct gpu_info* gpu, STYLE s, struct color** cs, struct terminal* term) {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_CUDA_BACKEND
|
||||
bool print_gpufetch_cuda(struct gpu_info* gpu, STYLE s, struct color** cs, struct terminal* term) {
|
||||
struct ascii* art = set_ascii(get_gpu_vendor(gpu), s);
|
||||
|
||||
@@ -416,6 +423,7 @@ bool print_gpufetch_cuda(struct gpu_info* gpu, STYLE s, struct color** cs, struc
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
struct terminal* get_terminal_size() {
|
||||
struct terminal* term = (struct terminal*) emalloc(sizeof(struct terminal));
|
||||
@@ -448,5 +456,17 @@ struct terminal* get_terminal_size() {
|
||||
bool print_gpufetch(struct gpu_info* gpu, STYLE s, struct color** cs) {
|
||||
struct terminal* term = get_terminal_size();
|
||||
|
||||
return print_gpufetch_cuda(gpu, s, cs, term);
|
||||
if(gpu->vendor == GPU_VENDOR_NVIDIA)
|
||||
#ifdef ENABLE_CUDA_BACKEND
|
||||
return print_gpufetch_cuda(gpu, s, cs, term);
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
else {
|
||||
#ifdef ENABLE_INTEL_BACKEND
|
||||
return print_gpufetch_intel(gpu, s, cs, term);
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "../common/pci.hpp"
|
||||
#include "../common/global.hpp"
|
||||
|
||||
int print_gpus_list() {
|
||||
int print_gpus_list_deprecated() {
|
||||
cudaError_t err = cudaSuccess;
|
||||
int num_gpus = -1;
|
||||
|
||||
@@ -113,7 +113,7 @@ int64_t get_peak_performance_t(struct gpu_info* gpu) {
|
||||
return gpu->freq * 1000000 * 4 * 4 * 8 * gpu->topo->tensor_cores;
|
||||
}
|
||||
|
||||
struct gpu_info* get_gpu_info(int gpu_idx) {
|
||||
struct gpu_info* get_gpu_info_cuda(int gpu_idx) {
|
||||
struct gpu_info* gpu = (struct gpu_info*) emalloc(sizeof(struct gpu_info));
|
||||
gpu->pci = NULL;
|
||||
gpu->idx = gpu_idx;
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
#ifndef __CUDA__
|
||||
#define __CUDA__
|
||||
#ifndef __CUDA_GPU__
|
||||
#define __CUDA_GPU__
|
||||
|
||||
#include "../common/gpu.hpp"
|
||||
|
||||
struct gpu_info* get_gpu_info(int gpu_idx);
|
||||
int print_gpus_list();
|
||||
struct gpu_info* get_gpu_info_cuda(int gpu_idx);
|
||||
char* get_str_sm(struct gpu_info* gpu);
|
||||
char* get_str_cores_sm(struct gpu_info* gpu);
|
||||
char* get_str_cuda_cores(struct gpu_info* gpu);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef __UARCH__
|
||||
#define __UARCH__
|
||||
#ifndef __CUDA_UARCH__
|
||||
#define __CUDA_UARCH__
|
||||
|
||||
#include "../common/gpu.hpp"
|
||||
|
||||
|
||||
10
src/intel/intel.cpp
Normal file
10
src/intel/intel.cpp
Normal file
@@ -0,0 +1,10 @@
|
||||
#include "intel.hpp"
|
||||
#include "uarch.hpp"
|
||||
#include "../common/pci.hpp"
|
||||
#include "../common/global.hpp"
|
||||
|
||||
struct gpu_info* get_gpu_info_intel() {
|
||||
struct gpu_info* gpu = (struct gpu_info*) emalloc(sizeof(struct gpu_info));
|
||||
|
||||
return gpu;
|
||||
}
|
||||
8
src/intel/intel.hpp
Normal file
8
src/intel/intel.hpp
Normal file
@@ -0,0 +1,8 @@
|
||||
#ifndef __INTEL_GPU__
|
||||
#define __INTEL_GPU__
|
||||
|
||||
#include "../common/gpu.hpp"
|
||||
|
||||
struct gpu_info* get_gpu_info_intel(int gpu_idx);
|
||||
|
||||
#endif
|
||||
6
src/intel/uarch.hpp
Normal file
6
src/intel/uarch.hpp
Normal file
@@ -0,0 +1,6 @@
|
||||
#ifndef __INTEL_UARCH__
|
||||
#define __INTEL_UARCH__
|
||||
|
||||
#include "../common/gpu.hpp"
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user