[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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user