Skip to content

Commit

Permalink
dev release option
Browse files Browse the repository at this point in the history
- extent cmake flag `XMR-STAK_COMPILE` to create release binaries
- disable support for nvidia backend library loading for non release
binaries
- disable cn_r supoort for linux nvidia backend if release binaries
where created
  • Loading branch information
psychocrypt committed May 31, 2019
1 parent 4968514 commit 4211295
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 23 deletions.
19 changes: 16 additions & 3 deletions CMakeLists.txt
Expand Up @@ -44,13 +44,13 @@ endif()
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "${BUILD_TYPE}")

set(XMR-STAK_COMPILE "native" CACHE STRING "select CPU compute architecture")
set_property(CACHE XMR-STAK_COMPILE PROPERTY STRINGS "native;generic")
set_property(CACHE XMR-STAK_COMPILE PROPERTY STRINGS "native;generic;dev_release")
if(XMR-STAK_COMPILE STREQUAL "native")
if(NOT CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
set(CMAKE_CXX_FLAGS "-march=native -mtune=native ${CMAKE_CXX_FLAGS}")
set(CMAKE_C_FLAGS "-march=native -mtune=native ${CMAKE_C_FLAGS}")
endif()
elseif(XMR-STAK_COMPILE STREQUAL "generic")
elseif(XMR-STAK_COMPILE STREQUAL "generic" OR XMR-STAK_COMPILE STREQUAL "dev_release")
add_definitions("-DCONF_ENFORCE_OpenCL_1_2=1")
else()
message(FATAL_ERROR "XMR-STAK_COMPILE is set to an unknown value '${XMR-STAK_COMPILE}'")
Expand Down Expand Up @@ -496,6 +496,10 @@ if(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
set(CMAKE_C_FLAGS "-Wl,-z,noexecstack ${CMAKE_C_FLAGS}")
endif()

if(XMR-STAK_COMPILE STREQUAL "dev_release")
add_definitions(-DXMRSTAK_DEV_RELEASE)
endif()

# activate static libgcc and libstdc++ linking
if(CMAKE_LINK_STATIC)
set(BUILD_SHARED_LIBRARIES OFF)
Expand Down Expand Up @@ -586,7 +590,16 @@ if(CUDA_FOUND)
)
endif()

set(CUDA_LIBRARIES ${CUDA_LIB} ${CUDA_NVRTC_LIB} ${CUDA_LIBRARIES})
set(CUDA_LIBRARIES ${CUDA_LIB} ${CUDA_LIBRARIES})
if(XMR-STAK_COMPILE STREQUAL "dev_release")
# do not link nvrtc for linux binaries, cn-r will be disabled
if(WIN32)
set(CUDA_LIBRARIES ${CUDA_LIBRARIES} ${CUDA_NVRTC_LIB})
endif()
else()
set(CUDA_LIBRARIES ${CUDA_LIBRARIES} ${CUDA_NVRTC_LIB})
endif()

target_link_libraries(xmrstak_cuda_backend ${CUDA_LIBRARIES})
target_link_libraries(xmrstak_cuda_backend xmr-stak-backend xmr-stak-asm)
endif()
Expand Down
61 changes: 41 additions & 20 deletions xmrstak/backend/backendConnector.cpp
Expand Up @@ -81,31 +81,52 @@ std::vector<iBackend*>* BackendConnector::thread_starter(miner_work& pWork)
#ifndef CONF_NO_CUDA
if(params::inst().useNVIDIA)
{
bool disableNvidia = false;

plugin nvidiaplugin;
std::vector<std::string> libNames = {"xmrstak_cuda_backend_cuda10_0", "xmrstak_cuda_backend_cuda9_2", "xmrstak_cuda_backend"};
#ifdef XMRSTAK_DEV_RELEASE
std::vector<std::string> libNames = {"xmrstak_cuda_backend_cuda10_0", "xmrstak_cuda_backend"};
# ifndef _WIN32
auto neededAlgorithms = ::jconf::inst()->GetCurrentCoinSelection().GetAllAlgorithms();
bool cn_r_derivate =
std::find(neededAlgorithms.begin(), neededAlgorithms.end(), cryptonight_r) != neededAlgorithms.end() ||
std::find(neededAlgorithms.begin(), neededAlgorithms.end(), cryptonight_r_wow) != neededAlgorithms.end();

if(cn_r_derivate)
{
disableNvidia = true;
printer::inst()->print_msg(L0, "WARNING: The linux release binaries not support cryptonight_r derived coins for NVIDIA.");
}
# endif
#else
std::vector<std::string> libNames = {"xmrstak_cuda_backend"};
#endif
size_t numWorkers = 0u;

for(const auto& name : libNames)
if(!disableNvidia)
{
printer::inst()->print_msg(L0, "NVIDIA: try to load library '%s'", name.c_str());
nvidiaplugin.load("NVIDIA", name);
std::vector<iBackend*>* nvidiaThreads = nvidiaplugin.startBackend(static_cast<uint32_t>(pvThreads->size()), pWork, environment::inst());
if(nvidiaThreads != nullptr)
{
pvThreads->insert(std::end(*pvThreads), std::begin(*nvidiaThreads), std::end(*nvidiaThreads));
numWorkers = nvidiaThreads->size();
delete nvidiaThreads;
}
else
{
// remove the plugin if we have found no GPUs
nvidiaplugin.unload();
}
// we found at leat one working GPU
if(numWorkers != 0)
for(const auto& name : libNames)
{
printer::inst()->print_msg(L0, "NVIDIA: use library '%s'", name.c_str());
break;
printer::inst()->print_msg(L0, "NVIDIA: try to load library '%s'", name.c_str());
nvidiaplugin.load("NVIDIA", name);
std::vector<iBackend*>* nvidiaThreads = nvidiaplugin.startBackend(static_cast<uint32_t>(pvThreads->size()), pWork, environment::inst());
if(nvidiaThreads != nullptr)
{
pvThreads->insert(std::end(*pvThreads), std::begin(*nvidiaThreads), std::end(*nvidiaThreads));
numWorkers = nvidiaThreads->size();
delete nvidiaThreads;
}
else
{
// remove the plugin if we have found no GPUs
nvidiaplugin.unload();
}
// we found at leat one working GPU
if(numWorkers != 0)
{
printer::inst()->print_msg(L0, "NVIDIA: use library '%s'", name.c_str());
break;
}
}
}
if(numWorkers == 0)
Expand Down

0 comments on commit 4211295

Please sign in to comment.