Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6f196c1797 |
@@ -45,6 +45,8 @@ if(NOT ${PCIUTILS_FOUND})
|
|||||||
else()
|
else()
|
||||||
include_directories(${PCIUTILS_INCLUDE_DIR})
|
include_directories(${PCIUTILS_INCLUDE_DIR})
|
||||||
link_libraries(${PCIUTILS_LIBRARIES})
|
link_libraries(${PCIUTILS_LIBRARIES})
|
||||||
|
# Needed for linking libpci in FreeBSD
|
||||||
|
link_directories(/usr/local/lib/)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_executable(gpufetch ${COMMON_DIR}/main.cpp ${COMMON_DIR}/args.cpp ${COMMON_DIR}/gpu.cpp ${COMMON_DIR}/pci.cpp ${COMMON_DIR}/sort.cpp ${COMMON_DIR}/global.cpp ${COMMON_DIR}/printer.cpp ${COMMON_DIR}/master.cpp ${COMMON_DIR}/uarch.cpp)
|
add_executable(gpufetch ${COMMON_DIR}/main.cpp ${COMMON_DIR}/args.cpp ${COMMON_DIR}/gpu.cpp ${COMMON_DIR}/pci.cpp ${COMMON_DIR}/sort.cpp ${COMMON_DIR}/global.cpp ${COMMON_DIR}/printer.cpp ${COMMON_DIR}/master.cpp ${COMMON_DIR}/uarch.cpp)
|
||||||
@@ -80,13 +82,21 @@ if(ENABLE_CUDA_BACKEND)
|
|||||||
set(CMAKE_CUDA_ARCHITECTURES 20 21 30 32 35 37 50 52 53 60 61 62)
|
set(CMAKE_CUDA_ARCHITECTURES 20 21 30 32 35 37 50 52 53 60 61 62)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# https://docs.nvidia.com/cuda/cuda-samples/index.html#new-features-in-cuda-toolkit-11-6
|
||||||
|
# Not sure about this. Why the heck did they change this?
|
||||||
|
if(${CMAKE_CUDA_COMPILER_VERSION} VERSION_GREATER_EQUAL "11.6")
|
||||||
|
set(CUDA_SAMPLES_PATH ${CMAKE_CUDA_COMPILER_TOOLKIT_ROOT}/samples/Common)
|
||||||
|
else()
|
||||||
|
set(CUDA_SAMPLES_PATH ${CMAKE_CUDA_COMPILER_TOOLKIT_ROOT}/samples/common/inc)
|
||||||
|
endif()
|
||||||
|
|
||||||
add_library(cuda_backend STATIC ${CUDA_DIR}/cuda.cpp ${CUDA_DIR}/uarch.cpp ${CUDA_DIR}/pci.cpp)
|
add_library(cuda_backend STATIC ${CUDA_DIR}/cuda.cpp ${CUDA_DIR}/uarch.cpp ${CUDA_DIR}/pci.cpp)
|
||||||
|
|
||||||
if(NOT ${PCIUTILS_FOUND})
|
if(NOT ${PCIUTILS_FOUND})
|
||||||
add_dependencies(cuda_backend pciutils)
|
add_dependencies(cuda_backend pciutils)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_include_directories(cuda_backend PUBLIC ${CMAKE_CUDA_COMPILER_TOOLKIT_ROOT}/targets/x86_64-linux/include)
|
target_include_directories(cuda_backend PUBLIC ${CUDA_SAMPLES_PATH} ${CMAKE_CUDA_COMPILER_TOOLKIT_ROOT}/targets/x86_64-linux/include)
|
||||||
|
|
||||||
target_link_libraries(cuda_backend PRIVATE cudart)
|
target_link_libraries(cuda_backend PRIVATE cudart)
|
||||||
target_link_libraries(gpufetch cuda_backend)
|
target_link_libraries(gpufetch cuda_backend)
|
||||||
|
|||||||
9
build.sh
9
build.sh
@@ -1,4 +1,4 @@
|
|||||||
#!/bin/bash
|
#!/bin/sh
|
||||||
|
|
||||||
# gpufetch build script
|
# gpufetch build script
|
||||||
set -e
|
set -e
|
||||||
@@ -27,6 +27,13 @@ fi
|
|||||||
# cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DENABLE_INTEL_BACKEND=OFF ..
|
# cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DENABLE_INTEL_BACKEND=OFF ..
|
||||||
|
|
||||||
cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE ..
|
cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE ..
|
||||||
|
|
||||||
|
os=$(uname)
|
||||||
|
if [ "$os" == 'Linux' ]; then
|
||||||
make -j$(nproc)
|
make -j$(nproc)
|
||||||
|
elif [ "$os" == 'FreeBSD' ]; then
|
||||||
|
gmake -j4
|
||||||
|
fi
|
||||||
|
|
||||||
cd -
|
cd -
|
||||||
ln -s build/gpufetch .
|
ln -s build/gpufetch .
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
#ifndef __ARGS__
|
#ifndef __ARGS__
|
||||||
#define __ARGS__
|
#define __ARGS__
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
struct color {
|
struct color {
|
||||||
int32_t R;
|
int32_t R;
|
||||||
int32_t G;
|
int32_t G;
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
#include "../cuda/cuda.hpp"
|
#include "../cuda/cuda.hpp"
|
||||||
#include "../cuda/uarch.hpp"
|
#include "../cuda/uarch.hpp"
|
||||||
|
|
||||||
static const char* VERSION = "0.24";
|
static const char* VERSION = "0.23";
|
||||||
|
|
||||||
void print_help(char *argv[]) {
|
void print_help(char *argv[]) {
|
||||||
const char **t = args_str;
|
const char **t = args_str;
|
||||||
|
|||||||
@@ -1,11 +1,8 @@
|
|||||||
|
#include <helper_cuda.h>
|
||||||
#include <cuda_runtime.h>
|
#include <cuda_runtime.h>
|
||||||
#include <cstring>
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <cstdio>
|
|
||||||
|
|
||||||
#include "cuda.hpp"
|
#include "cuda.hpp"
|
||||||
#include "uarch.hpp"
|
#include "uarch.hpp"
|
||||||
#include "gpufetch_helper_cuda.hpp"
|
|
||||||
#include "../common/pci.hpp"
|
#include "../common/pci.hpp"
|
||||||
#include "../common/global.hpp"
|
#include "../common/global.hpp"
|
||||||
#include "../common/uarch.hpp"
|
#include "../common/uarch.hpp"
|
||||||
|
|||||||
@@ -1,60 +0,0 @@
|
|||||||
#ifndef __GPUFETCH_HELPER_CUDA__
|
|
||||||
#define __GPUFETCH_HELPER_CUDA__
|
|
||||||
|
|
||||||
// gpufetch self contained helper_cuda.h
|
|
||||||
//
|
|
||||||
// Avoids relying on helper_cuda.h, which is
|
|
||||||
// often very hard to include properly, causing
|
|
||||||
// compilation issues.
|
|
||||||
//
|
|
||||||
// URL: https://github.com/NVIDIA/cuda-samples
|
|
||||||
// Commit: 2e41896
|
|
||||||
|
|
||||||
inline int _ConvertSMVer2Cores(int major, int minor) {
|
|
||||||
// Defines for GPU Architecture types (using the SM version to determine
|
|
||||||
// the # of cores per SM
|
|
||||||
typedef struct {
|
|
||||||
int SM; // 0xMm (hexidecimal notation), M = SM Major version,
|
|
||||||
// and m = SM minor version
|
|
||||||
int Cores;
|
|
||||||
} sSMtoCores;
|
|
||||||
|
|
||||||
sSMtoCores nGpuArchCoresPerSM[] = {
|
|
||||||
{0x30, 192},
|
|
||||||
{0x32, 192},
|
|
||||||
{0x35, 192},
|
|
||||||
{0x37, 192},
|
|
||||||
{0x50, 128},
|
|
||||||
{0x52, 128},
|
|
||||||
{0x53, 128},
|
|
||||||
{0x60, 64},
|
|
||||||
{0x61, 128},
|
|
||||||
{0x62, 128},
|
|
||||||
{0x70, 64},
|
|
||||||
{0x72, 64},
|
|
||||||
{0x75, 64},
|
|
||||||
{0x80, 64},
|
|
||||||
{0x86, 128},
|
|
||||||
{0x87, 128},
|
|
||||||
{-1, -1}};
|
|
||||||
|
|
||||||
int index = 0;
|
|
||||||
|
|
||||||
while (nGpuArchCoresPerSM[index].SM != -1) {
|
|
||||||
if (nGpuArchCoresPerSM[index].SM == ((major << 4) + minor)) {
|
|
||||||
return nGpuArchCoresPerSM[index].Cores;
|
|
||||||
}
|
|
||||||
|
|
||||||
index++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If we don't find the values, we default use the previous one
|
|
||||||
// to run properly
|
|
||||||
printf(
|
|
||||||
"MapSMtoCores for SM %d.%d is undefined."
|
|
||||||
" Default to use %d Cores/SM\n",
|
|
||||||
major, minor, nGpuArchCoresPerSM[index - 1].Cores);
|
|
||||||
return nGpuArchCoresPerSM[index - 1].Cores;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,9 +1,7 @@
|
|||||||
#include <cuda_runtime.h>
|
#include <cuda_runtime.h>
|
||||||
#include <cstdlib>
|
#include <helper_cuda.h>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cstdio>
|
|
||||||
#include <cstring>
|
|
||||||
|
|
||||||
#include "../common/uarch.hpp"
|
#include "../common/uarch.hpp"
|
||||||
#include "../common/global.hpp"
|
#include "../common/global.hpp"
|
||||||
@@ -331,7 +329,6 @@ char* get_str_chip(struct uarch* arch) {
|
|||||||
return arch->chip_str;
|
return arch->chip_str;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: What about _ConvertSMVer2ArchName?
|
|
||||||
const char* get_str_uarch_cuda(struct uarch* arch) {
|
const char* get_str_uarch_cuda(struct uarch* arch) {
|
||||||
return uarch_str[arch->uarch];
|
return uarch_str[arch->uarch];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user