[v0.11] Working in master GPU handler for supporting diverse GPU vendors
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
#include <stdbool.h>
|
||||
#include <cstddef>
|
||||
#include <cstdlib>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "master.hpp"
|
||||
#include "../cuda/cuda.hpp"
|
||||
#include "../intel/intel.hpp"
|
||||
|
||||
#define MAX_GPUS 1000
|
||||
|
||||
@@ -12,14 +14,13 @@ struct gpu_list {
|
||||
};
|
||||
|
||||
struct gpu_list* get_gpu_list() {
|
||||
int idx = 0;
|
||||
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;
|
||||
|
||||
#ifdef BACKEND_CUDA
|
||||
while(valid) {
|
||||
list->gpus[idx] = get_gpu_info_cuda(idx);
|
||||
if(list->gpus[idx] != NULL) idx++;
|
||||
@@ -29,7 +30,7 @@ struct gpu_list* get_gpu_list() {
|
||||
list->num_gpus += idx;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_INTEL_BACKEND
|
||||
#ifdef BACKEND_INTEL
|
||||
list->gpus[idx] = get_gpu_info_intel();
|
||||
if(list->gpus[idx] != NULL) list->num_gpus++;
|
||||
#endif
|
||||
@@ -38,7 +39,21 @@ struct gpu_list* get_gpu_list() {
|
||||
}
|
||||
|
||||
bool print_gpus_list(struct gpu_list* list) {
|
||||
return false;
|
||||
for(int i=0; i < list->num_gpus; i++) {
|
||||
printf("GPU %d: ", i);
|
||||
if(list->gpus[i]->vendor == GPU_VENDOR_NVIDIA) {
|
||||
#ifdef ENABLE_CUDA_BACKEND
|
||||
print_gpu_cuda(list->gpus[i]);
|
||||
#endif
|
||||
}
|
||||
else if(list->gpus[i]->vendor == GPU_VENDOR_INTEL) {
|
||||
#ifdef ENABLE_INTEL_BACKEND
|
||||
print_gpu_intel(list->gpus[i]);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
struct gpu_info* get_gpu_info(struct gpu_list* list, int idx) {
|
||||
|
||||
@@ -342,13 +342,13 @@ void print_ascii_generic(struct ascii* art, uint32_t la, int32_t text_space, con
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
#ifdef ENABLE_INTEL_BACKEND
|
||||
#ifdef BACKEND_INTEL
|
||||
bool print_gpufetch_intel(struct gpu_info* gpu, STYLE s, struct color** cs, struct terminal* term) {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_CUDA_BACKEND
|
||||
#ifdef BACKEND_CUDA
|
||||
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);
|
||||
|
||||
@@ -457,13 +457,13 @@ bool print_gpufetch(struct gpu_info* gpu, STYLE s, struct color** cs) {
|
||||
struct terminal* term = get_terminal_size();
|
||||
|
||||
if(gpu->vendor == GPU_VENDOR_NVIDIA)
|
||||
#ifdef ENABLE_CUDA_BACKEND
|
||||
#ifdef BACKEND_CUDA
|
||||
return print_gpufetch_cuda(gpu, s, cs, term);
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
else {
|
||||
#ifdef ENABLE_INTEL_BACKEND
|
||||
#ifdef BACKEND_INTEL
|
||||
return print_gpufetch_intel(gpu, s, cs, term);
|
||||
#else
|
||||
return false;
|
||||
|
||||
@@ -42,6 +42,10 @@ int print_gpus_list_deprecated() {
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
bool print_gpu_cuda(struct gpu_info* gpu) {
|
||||
return false;
|
||||
}
|
||||
|
||||
struct cache* get_cache_info(cudaDeviceProp prop) {
|
||||
struct cache* cach = (struct cache*) emalloc(sizeof(struct cache));
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "../common/gpu.hpp"
|
||||
|
||||
struct gpu_info* get_gpu_info_cuda(int gpu_idx);
|
||||
bool print_gpu_cuda(struct gpu_info* gpu);
|
||||
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,3 +1,5 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include "intel.hpp"
|
||||
#include "uarch.hpp"
|
||||
#include "../common/pci.hpp"
|
||||
@@ -8,3 +10,11 @@ struct gpu_info* get_gpu_info_intel() {
|
||||
|
||||
return gpu;
|
||||
}
|
||||
|
||||
bool print_gpu_intel(struct gpu_info* gpu) {
|
||||
if(gpu->vendor != GPU_VENDOR_INTEL) return false;
|
||||
|
||||
printf("%s\n", gpu->name);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "../common/gpu.hpp"
|
||||
|
||||
struct gpu_info* get_gpu_info_intel(int gpu_idx);
|
||||
struct gpu_info* get_gpu_info_intel();
|
||||
bool print_gpu_intel(struct gpu_info* gpu);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user