[v0.01] Defining a first approach of the application general structure
This commit is contained in:
2
Makefile
2
Makefile
@@ -16,7 +16,7 @@ CUDA_HDR = $(SRC_CUDA)cuda.hpp $(SRC_CUDA)uarch.hpp
|
|||||||
CUDA_PATH = /usr/local/cuda/
|
CUDA_PATH = /usr/local/cuda/
|
||||||
|
|
||||||
SOURCE += $(COMMON_SRC) $(CUDA_SRC)
|
SOURCE += $(COMMON_SRC) $(CUDA_SRC)
|
||||||
HEADERS += $(COMMON_HDR) $(CUDA_HRC)
|
HEADERS += $(COMMON_HDR) $(CUDA_HDR)
|
||||||
|
|
||||||
OUTPUT=gpufetch
|
OUTPUT=gpufetch
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,30 @@
|
|||||||
#include "gpu.hpp"
|
#include "gpu.hpp"
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
char* get_str_gpu_name(struct gpu_info* gpu) {
|
char* get_str_gpu_name(struct gpu_info* gpu) {
|
||||||
return gpu->name;
|
return gpu->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char* get_str_freq(struct gpu_info* gpu) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
char* get_str_memory_size(struct gpu_info* gpu) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
char* get_str_memory_type(struct gpu_info* gpu) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
char* get_str_l1(struct gpu_info* gpu) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
char* get_str_l2(struct gpu_info* gpu) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
char* get_str_peak_performance(struct gpu_info* gpu) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|||||||
@@ -8,15 +8,52 @@ enum {
|
|||||||
GPU_VENDOR_NVIDIA
|
GPU_VENDOR_NVIDIA
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum {
|
||||||
|
MEMTYPE_GDDR6
|
||||||
|
};
|
||||||
|
|
||||||
typedef int32_t VENDOR;
|
typedef int32_t VENDOR;
|
||||||
|
typedef int32_t MEMTYPE;
|
||||||
|
|
||||||
|
struct cach {
|
||||||
|
int32_t size;
|
||||||
|
uint8_t num_caches;
|
||||||
|
bool exists;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct cache {
|
||||||
|
struct cach* L1;
|
||||||
|
struct cach* L2;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct topology {
|
||||||
|
int32_t shared_mp;
|
||||||
|
int32_t cores_per_mp;
|
||||||
|
int32_t cuda_cores;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct memory {
|
||||||
|
int32_t size_bytes;
|
||||||
|
MEMTYPE type;
|
||||||
|
};
|
||||||
|
|
||||||
struct gpu_info {
|
struct gpu_info {
|
||||||
VENDOR vendor;
|
VENDOR vendor;
|
||||||
struct uarch* arch;
|
struct uarch* arch;
|
||||||
char* name;
|
char* name;
|
||||||
|
int64_t freq;
|
||||||
|
struct topology* topo;
|
||||||
|
struct memory* mem;
|
||||||
|
struct cache* cach;
|
||||||
|
int64_t peak_performance;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
char* get_str_gpu_name(struct gpu_info* gpu);
|
char* get_str_gpu_name(struct gpu_info* gpu);
|
||||||
|
char* get_str_freq(struct gpu_info* gpu);
|
||||||
|
char* get_str_memory_size(struct gpu_info* gpu);
|
||||||
|
char* get_str_memory_type(struct gpu_info* gpu);
|
||||||
|
char* get_str_l1(struct gpu_info* gpu);
|
||||||
|
char* get_str_l2(struct gpu_info* gpu);
|
||||||
|
char* get_str_peak_performance(struct gpu_info* gpu);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include "args.hpp"
|
#include "args.hpp"
|
||||||
#include "global.hpp"
|
#include "global.hpp"
|
||||||
#include "../cuda/cuda.hpp"
|
#include "../cuda/cuda.hpp"
|
||||||
|
#include "../cuda/uarch.hpp"
|
||||||
|
|
||||||
static const char* VERSION = "0.01";
|
static const char* VERSION = "0.01";
|
||||||
|
|
||||||
@@ -52,7 +53,19 @@ int main(int argc, char* argv[]) {
|
|||||||
if(gpu == NULL)
|
if(gpu == NULL)
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
printf("Name: %s\n", gpu->name);
|
printf("Name: %s\n", get_str_gpu_name(gpu));
|
||||||
|
printf("Microarchitecture: %s\n", get_str_uarch(gpu));
|
||||||
|
printf("Compute Capability: %s\n", get_str_cc(gpu));
|
||||||
|
printf("Technology: %s\n", get_str_process(gpu));
|
||||||
|
printf("Max Frequency: %s\n", get_str_freq(gpu));
|
||||||
|
printf("SM: %s\n", get_str_sm(gpu));
|
||||||
|
printf("Cores/MP: %s\n", get_str_cores_sm(gpu));
|
||||||
|
printf("CUDA cores: %s\n", get_str_cuda_cores(gpu));
|
||||||
|
printf("Memory size: %s\n", get_str_memory_size(gpu));
|
||||||
|
printf("Memory type: %s\n", get_str_memory_type(gpu));
|
||||||
|
printf("L1 size: %s\n", get_str_l1(gpu));
|
||||||
|
printf("L2 size: %s\n", get_str_l2(gpu));
|
||||||
|
printf("Peak performance: %s\n", get_str_peak_performance(gpu));
|
||||||
|
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,18 +2,62 @@
|
|||||||
#include <cuda_runtime.h>
|
#include <cuda_runtime.h>
|
||||||
|
|
||||||
#include "cuda.hpp"
|
#include "cuda.hpp"
|
||||||
|
#include "uarch.hpp"
|
||||||
#include "../common/global.hpp"
|
#include "../common/global.hpp"
|
||||||
|
|
||||||
|
struct cache* get_cache_info(struct gpu_info* gpu) {
|
||||||
|
struct cache* cach = (struct cache*) emalloc(sizeof(struct cache));
|
||||||
|
|
||||||
|
return cach;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct topology* get_topology_info(struct gpu_info* gpu) {
|
||||||
|
struct topology* topo = (struct topology*) emalloc(sizeof(struct topology));
|
||||||
|
|
||||||
|
return topo;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct memory* get_memory_info(struct gpu_info* gpu) {
|
||||||
|
struct memory* mem = (struct memory*) emalloc(sizeof(struct memory));
|
||||||
|
|
||||||
|
return mem;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t get_peak_performance(struct gpu_info* gpu) {
|
||||||
|
return 1000;
|
||||||
|
}
|
||||||
|
|
||||||
struct gpu_info* get_gpu_info() {
|
struct gpu_info* get_gpu_info() {
|
||||||
struct gpu_info* gpu = (struct gpu_info*) emalloc(sizeof(struct gpu_info));
|
struct gpu_info* gpu = (struct gpu_info*) emalloc(sizeof(struct gpu_info));
|
||||||
|
|
||||||
|
printf("Waiting for CUDA driver to start...\n");
|
||||||
int dev = 0;
|
int dev = 0;
|
||||||
cudaSetDevice(dev);
|
cudaSetDevice(dev);
|
||||||
cudaDeviceProp deviceProp;
|
cudaDeviceProp deviceProp;
|
||||||
cudaGetDeviceProperties(&deviceProp, dev);
|
cudaGetDeviceProperties(&deviceProp, dev);
|
||||||
|
|
||||||
|
gpu->vendor = GPU_VENDOR_NVIDIA;
|
||||||
gpu->name = (char *) emalloc(sizeof(char) * (strlen(deviceProp.name) + 1));
|
gpu->name = (char *) emalloc(sizeof(char) * (strlen(deviceProp.name) + 1));
|
||||||
strcpy(gpu->name, deviceProp.name);
|
strcpy(gpu->name, deviceProp.name);
|
||||||
|
gpu->freq = 10000;
|
||||||
|
|
||||||
|
gpu->arch = get_uarch_from_cuda(gpu);
|
||||||
|
gpu->cach = get_cache_info(gpu);
|
||||||
|
gpu->topo = get_topology_info(gpu);
|
||||||
|
gpu->peak_performance = get_peak_performance(gpu);
|
||||||
|
|
||||||
return gpu;
|
return gpu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char* get_str_sm(struct gpu_info* gpu) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
char* get_str_cores_sm(struct gpu_info* gpu) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
char* get_str_cuda_cores(struct gpu_info* gpu) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,5 +4,8 @@
|
|||||||
#include "../common/gpu.hpp"
|
#include "../common/gpu.hpp"
|
||||||
|
|
||||||
struct gpu_info* get_gpu_info();
|
struct gpu_info* get_gpu_info();
|
||||||
|
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);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -28,6 +28,10 @@ char* get_str_uarch(struct gpu_info* gpu) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char* get_str_cc(struct gpu_info* gpu) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
char* get_str_process(struct gpu_info* gpu) {
|
char* get_str_process(struct gpu_info* gpu) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ struct uarch;
|
|||||||
|
|
||||||
struct uarch* get_uarch_from_cuda(struct gpu_info* gpu);
|
struct uarch* get_uarch_from_cuda(struct gpu_info* gpu);
|
||||||
char* get_str_uarch(struct gpu_info* gpu);
|
char* get_str_uarch(struct gpu_info* gpu);
|
||||||
|
char* get_str_cc(struct gpu_info* gpu);
|
||||||
char* get_str_process(struct gpu_info* gpu);
|
char* get_str_process(struct gpu_info* gpu);
|
||||||
void free_uarch_struct(struct uarch* arch);
|
void free_uarch_struct(struct uarch* arch);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user