forked from com03240/xmrig-cuda
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
47 changed files
with
11,713 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/CMakeLists.txt.user |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
cmake_minimum_required(VERSION 2.8) | ||
project(xmrig-cuda) | ||
|
||
|
||
option(WITH_RANDOMX "Enable RandomX algorithms family" ON) | ||
|
||
|
||
include_directories(src) | ||
add_definitions(/DXMRIG_ALGO_CN_LITE) | ||
add_definitions(/DXMRIG_ALGO_CN_HEAVY) | ||
add_definitions(/DXMRIG_ALGO_CN_GPU) | ||
add_definitions(/DXMRIG_ALGO_CN_PICO) | ||
|
||
|
||
include(cmake/flags.cmake) | ||
include(cmake/CUDA.cmake) | ||
|
||
|
||
set(SOURCES | ||
src/crypto/cn/c_blake256.c | ||
src/crypto/common/Algorithm.h | ||
src/CudaCryptonightR_gen.cpp | ||
src/version.h | ||
src/xmrig-cuda.cpp | ||
src/xmrig-cuda.h | ||
) | ||
|
||
|
||
if (WIN32) | ||
set(SOURCES_OS | ||
res/app.rc | ||
) | ||
else() | ||
set(SOURCES_OS "") | ||
endif() | ||
|
||
|
||
add_library(${CMAKE_PROJECT_NAME} SHARED ${SOURCES} ${SOURCES_OS}) | ||
target_link_libraries(${CMAKE_PROJECT_NAME} xmrig-cu ${LIBS}) | ||
|
||
if (WIN32) | ||
file(GLOB NVRTCDLL "${CUDA_TOOLKIT_ROOT_DIR}/bin/nvrtc64*.dll") | ||
add_custom_command(TARGET ${CMAKE_PROJECT_NAME} POST_BUILD | ||
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${NVRTCDLL}" $<TARGET_FILE_DIR:${CMAKE_PROJECT_NAME}>) | ||
|
||
file(GLOB NVRTCBUILTINDLL "${CUDA_TOOLKIT_ROOT_DIR}/bin/nvrtc-builtins64*.dll") | ||
add_custom_command(TARGET ${CMAKE_PROJECT_NAME} POST_BUILD | ||
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${NVRTCBUILTINDLL}" $<TARGET_FILE_DIR:${CMAKE_PROJECT_NAME}>) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
option(XMRIG_LARGEGRID "Support large CUDA block count > 128" ON) | ||
if (XMRIG_LARGEGRID) | ||
add_definitions("-DXMRIG_LARGEGRID=${XMRIG_LARGEGRID}") | ||
endif() | ||
|
||
set(DEVICE_COMPILER "nvcc") | ||
set(CUDA_COMPILER "${DEVICE_COMPILER}" CACHE STRING "Select the device compiler") | ||
|
||
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") | ||
list(APPEND DEVICE_COMPILER "clang") | ||
endif() | ||
|
||
set_property(CACHE CUDA_COMPILER PROPERTY STRINGS "${DEVICE_COMPILER}") | ||
|
||
list(APPEND CMAKE_PREFIX_PATH "$ENV{CUDA_ROOT}") | ||
list(APPEND CMAKE_PREFIX_PATH "$ENV{CMAKE_PREFIX_PATH}") | ||
|
||
set(CUDA_STATIC ON) | ||
find_package(CUDA 8.0 REQUIRED) | ||
|
||
find_library(CUDA_LIB libcuda cuda HINTS "${CUDA_TOOLKIT_ROOT_DIR}/lib64" "${LIBCUDA_LIBRARY_DIR}" "${CUDA_TOOLKIT_ROOT_DIR}/lib/x64" /usr/lib64 /usr/local/cuda/lib64) | ||
find_library(CUDA_NVRTC_LIB libnvrtc nvrtc HINTS "${CUDA_TOOLKIT_ROOT_DIR}/lib64" "${LIBNVRTC_LIBRARY_DIR}" "${CUDA_TOOLKIT_ROOT_DIR}/lib/x64" /usr/lib64 /usr/local/cuda/lib64) | ||
|
||
set(LIBS ${LIBS} ${CUDA_LIBRARIES} ${CUDA_LIB} ${CUDA_NVRTC_LIB}) | ||
|
||
set(DEFAULT_CUDA_ARCH "30;50") | ||
|
||
# Fermi GPUs are only supported with CUDA < 9.0 | ||
if (CUDA_VERSION VERSION_LESS 9.0) | ||
list(APPEND DEFAULT_CUDA_ARCH "20;21") | ||
endif() | ||
|
||
# add Pascal support for CUDA >= 8.0 | ||
if (NOT CUDA_VERSION VERSION_LESS 8.0) | ||
list(APPEND DEFAULT_CUDA_ARCH "60") | ||
endif() | ||
|
||
# add Volta support for CUDA >= 9.0 | ||
if (NOT CUDA_VERSION VERSION_LESS 9.0) | ||
list(APPEND DEFAULT_CUDA_ARCH "70") | ||
endif() | ||
|
||
set(CUDA_ARCH "${DEFAULT_CUDA_ARCH}" CACHE STRING "Set GPU architecture (semicolon separated list, e.g. '-DCUDA_ARCH=20;35;60')") | ||
|
||
# validate architectures (only numbers are allowed) | ||
foreach(CUDA_ARCH_ELEM ${CUDA_ARCH}) | ||
string(REGEX MATCH "^[0-9]+$" IS_NUMBER ${CUDA_ARCH}) | ||
if(NOT IS_NUMBER) | ||
message(FATAL_ERROR "Defined compute architecture '${CUDA_ARCH_ELEM}' in " | ||
"'${CUDA_ARCH}' is not an integral number, use e.g. '30' (for compute architecture 3.0).") | ||
endif() | ||
unset(IS_NUMBER) | ||
|
||
if(${CUDA_ARCH_ELEM} LESS 20) | ||
message(FATAL_ERROR "Unsupported CUDA architecture '${CUDA_ARCH_ELEM}' specified. " | ||
"Use '20' (for compute architecture 2.0) or higher.") | ||
endif() | ||
endforeach() | ||
list(SORT CUDA_ARCH) | ||
|
||
option(CUDA_SHOW_REGISTER "Show registers used for each kernel and compute architecture" OFF) | ||
option(CUDA_KEEP_FILES "Keep all intermediate files that are generated during internal compilation steps" OFF) | ||
|
||
if("${CUDA_COMPILER}" STREQUAL "clang") | ||
set(LIBS ${LIBS} cudart_static) | ||
set(CLANG_BUILD_FLAGS "-O3 -x cuda --cuda-path=${CUDA_TOOLKIT_ROOT_DIR}") | ||
# activation usage of FMA | ||
set(CLANG_BUILD_FLAGS "${CLANG_BUILD_FLAGS} -ffp-contract=fast") | ||
|
||
if (CUDA_SHOW_REGISTER) | ||
set(CLANG_BUILD_FLAGS "${CLANG_BUILD_FLAGS} -Xcuda-ptxas -v") | ||
endif(CUDA_SHOW_REGISTER) | ||
|
||
if (CUDA_KEEP_FILES) | ||
set(CLANG_BUILD_FLAGS "${CLANG_BUILD_FLAGS} -save-temps=${PROJECT_BINARY_DIR}") | ||
endif(CUDA_KEEP_FILES) | ||
|
||
foreach(CUDA_ARCH_ELEM ${CUDA_ARCH}) | ||
# set flags to create device code for the given architectures | ||
set(CLANG_BUILD_FLAGS "${CLANG_BUILD_FLAGS} --cuda-gpu-arch=sm_${CUDA_ARCH_ELEM}") | ||
endforeach() | ||
|
||
elseif("${CUDA_COMPILER}" STREQUAL "nvcc") | ||
# avoid that nvcc in CUDA < 8 tries to use libc `memcpy` within the kernel | ||
if (CUDA_VERSION VERSION_LESS 8.0) | ||
add_definitions(-D_FORCE_INLINES) | ||
add_definitions(-D_MWAITXINTRIN_H_INCLUDED) | ||
elseif(CUDA_VERSION VERSION_LESS 9.0) | ||
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} "-Wno-deprecated-gpu-targets") | ||
endif() | ||
foreach(CUDA_ARCH_ELEM ${CUDA_ARCH}) | ||
# set flags to create device code for the given architecture | ||
if("${CUDA_ARCH_ELEM}" STREQUAL "21") | ||
# "2.1" actually does run faster when compiled as itself, versus in "2.0" compatible mode | ||
# strange virtual code type on top of compute_20, with no compute_21 (so the normal rule fails) | ||
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} | ||
"--generate-code arch=compute_20,code=sm_21") | ||
else() | ||
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} | ||
"--generate-code arch=compute_${CUDA_ARCH_ELEM},code=sm_${CUDA_ARCH_ELEM} --generate-code arch=compute_${CUDA_ARCH_ELEM},code=compute_${CUDA_ARCH_ELEM}") | ||
endif() | ||
endforeach() | ||
|
||
# give each thread an independent default stream | ||
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} --default-stream per-thread") | ||
#set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} static") | ||
|
||
option(CUDA_SHOW_CODELINES "Show kernel lines in cuda-gdb and cuda-memcheck" OFF) | ||
|
||
if (CUDA_SHOW_CODELINES) | ||
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS}" --source-in-ptx -lineinfo) | ||
set(CUDA_KEEP_FILES ON CACHE BOOL "activate keep files" FORCE) | ||
endif(CUDA_SHOW_CODELINES) | ||
|
||
if (CUDA_SHOW_REGISTER) | ||
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS}" -Xptxas=-v) | ||
endif(CUDA_SHOW_REGISTER) | ||
|
||
if (CUDA_KEEP_FILES) | ||
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS}" --keep --keep-dir "${PROJECT_BINARY_DIR}") | ||
endif(CUDA_KEEP_FILES) | ||
|
||
else() | ||
message(FATAL_ERROR "selected CUDA compiler '${CUDA_COMPILER}' is not supported") | ||
endif() | ||
|
||
set(CUDA_RANDOMX_SOURCES | ||
src/RandomX/aes_cuda.hpp | ||
src/RandomX/arqma/configuration.h | ||
src/RandomX/arqma/randomx_arqma.cu | ||
src/RandomX/blake2b_cuda.hpp | ||
src/RandomX/common.hpp | ||
src/RandomX/hash.hpp | ||
src/RandomX/loki/configuration.h | ||
src/RandomX/loki/randomx_loki.cu | ||
src/RandomX/monero/configuration.h | ||
src/RandomX/monero/randomx_monero.cu | ||
src/RandomX/randomx_cuda.hpp | ||
src/RandomX/randomx.cu | ||
src/RandomX/wownero/configuration.h | ||
src/RandomX/wownero/randomx_wownero.cu | ||
) | ||
|
||
set(CUDA_SOURCES | ||
src/cryptonight.h | ||
src/cuda_aes.hpp | ||
src/cuda_blake.hpp | ||
src/cuda_core.cu | ||
src/cuda_device.hpp | ||
src/cuda_extra.cu | ||
src/cuda_extra.h | ||
src/cuda_fast_int_math_v2.hpp | ||
src/cuda_groestl.hpp | ||
src/cuda_jh.hpp | ||
src/cuda_keccak.hpp | ||
src/cuda_skein.hpp | ||
) | ||
|
||
if("${CUDA_COMPILER}" STREQUAL "clang") | ||
add_library(xmrig-cu STATIC ${CUDA_SOURCES} ${CUDA_RANDOMX_SOURCES}) | ||
|
||
set_target_properties(xmrig-cu PROPERTIES COMPILE_FLAGS ${CLANG_BUILD_FLAGS}) | ||
set_target_properties(xmrig-cu PROPERTIES LINKER_LANGUAGE CXX) | ||
set_source_files_properties(${CUDA_SOURCES} ${CUDA_RANDOMX_SOURCES} PROPERTIES LANGUAGE CXX) | ||
else() | ||
cuda_add_library(xmrig-cu STATIC ${CUDA_SOURCES} ${CUDA_RANDOMX_SOURCES}) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
set(CMAKE_CXX_EXTENSIONS OFF) | ||
set(CMAKE_CXX_STANDARD 11) | ||
|
||
set(CMAKE_C_STANDARD 99) | ||
set(CMAKE_C_STANDARD_REQUIRED ON) | ||
|
||
if ("${CMAKE_BUILD_TYPE}" STREQUAL "") | ||
set(CMAKE_BUILD_TYPE Release) | ||
endif() | ||
|
||
if (CMAKE_BUILD_TYPE STREQUAL "Release") | ||
add_definitions(/DNDEBUG) | ||
endif() | ||
|
||
include(CheckSymbolExists) | ||
|
||
if (CMAKE_CXX_COMPILER_ID MATCHES GNU) | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wno-strict-aliasing") | ||
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -Ofast") | ||
|
||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fexceptions -fno-rtti -Wno-strict-aliasing -Wno-class-memaccess") | ||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Ofast -s") | ||
|
||
if (XMRIG_ARMv8) | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ARM8_CXX_FLAGS}") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ARM8_CXX_FLAGS} -flax-vector-conversions") | ||
elseif (XMRIG_ARMv7) | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfpu=neon") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfpu=neon -flax-vector-conversions") | ||
else() | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -maes") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -maes") | ||
|
||
add_definitions(/DHAVE_ROTR) | ||
endif() | ||
|
||
if (WIN32) | ||
if (CMAKE_SIZEOF_VOID_P EQUAL 8) | ||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static") | ||
else() | ||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static -Wl,--large-address-aware") | ||
endif() | ||
else() | ||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++") | ||
endif() | ||
|
||
add_definitions(/D_GNU_SOURCE) | ||
|
||
if (${CMAKE_VERSION} VERSION_LESS "3.1.0") | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") | ||
endif() | ||
|
||
#set(CMAKE_C_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -gdwarf-2") | ||
|
||
add_definitions(/DHAVE_BUILTIN_CLEAR_CACHE) | ||
|
||
elseif (CMAKE_CXX_COMPILER_ID MATCHES MSVC) | ||
|
||
set(CMAKE_C_FLAGS_RELEASE "/MT /O2 /Ob2 /DNDEBUG") | ||
set(CMAKE_CXX_FLAGS_RELEASE "/MT /O2 /Ob2 /DNDEBUG") | ||
add_definitions(/D_CRT_SECURE_NO_WARNINGS) | ||
add_definitions(/D_CRT_NONSTDC_NO_WARNINGS) | ||
add_definitions(/DNOMINMAX) | ||
add_definitions(/DHAVE_ROTR) | ||
|
||
elseif (CMAKE_CXX_COMPILER_ID MATCHES Clang) | ||
|
||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") | ||
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -Ofast -funroll-loops -fmerge-all-constants") | ||
|
||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fexceptions -fno-rtti -Wno-missing-braces") | ||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Ofast -funroll-loops -fmerge-all-constants") | ||
|
||
if (XMRIG_ARMv8) | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ARM8_CXX_FLAGS}") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ARM8_CXX_FLAGS}") | ||
elseif (XMRIG_ARMv7) | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfpu=neon -march=${CMAKE_SYSTEM_PROCESSOR}") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfpu=neon -march=${CMAKE_SYSTEM_PROCESSOR}") | ||
else() | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -maes") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -maes") | ||
|
||
check_symbol_exists("_rotr" "x86intrin.h" HAVE_ROTR) | ||
if (HAVE_ROTR) | ||
add_definitions(/DHAVE_ROTR) | ||
endif() | ||
endif() | ||
|
||
endif() | ||
|
||
if (NOT WIN32) | ||
check_symbol_exists("__builtin___clear_cache" "stdlib.h" HAVE_BUILTIN_CLEAR_CACHE) | ||
if (HAVE_BUILTIN_CLEAR_CACHE) | ||
add_definitions(/DHAVE_BUILTIN_CLEAR_CACHE) | ||
endif() | ||
endif() |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#include <windows.h> | ||
#include "../src/version.h" | ||
|
||
101 ICON "app.ico" | ||
|
||
VS_VERSION_INFO VERSIONINFO | ||
FILEVERSION APP_VER_MAJOR,APP_VER_MINOR,APP_VER_PATCH,0 | ||
PRODUCTVERSION APP_VER_MAJOR,APP_VER_MINOR,APP_VER_PATCH,0 | ||
FILEFLAGSMASK 0x3fL | ||
#ifdef _DEBUG | ||
FILEFLAGS VS_FF_DEBUG | ||
#else | ||
FILEFLAGS 0x0L | ||
#endif | ||
FILEOS VOS__WINDOWS32 | ||
FILETYPE VFT_APP | ||
FILESUBTYPE 0x0L | ||
BEGIN | ||
BLOCK "StringFileInfo" | ||
BEGIN | ||
BLOCK "000004b0" | ||
BEGIN | ||
VALUE "CompanyName", APP_SITE | ||
VALUE "FileDescription", APP_DESC | ||
VALUE "FileVersion", APP_VERSION | ||
VALUE "LegalCopyright", APP_COPYRIGHT | ||
VALUE "OriginalFilename", "xmrig-cuda.dll" | ||
VALUE "ProductName", APP_NAME | ||
VALUE "ProductVersion", APP_VERSION | ||
END | ||
END | ||
BLOCK "VarFileInfo" | ||
BEGIN | ||
VALUE "Translation", 0x0, 1200 | ||
END | ||
END | ||
|
Oops, something went wrong.