Skip to content

Commit

Permalink
testing Monero POW v2 fireice-uk#1831 (as of 20180919)
Browse files Browse the repository at this point in the history
  • Loading branch information
Spudz76 committed Sep 19, 2018
1 parent 35377a4 commit cfe33ad
Show file tree
Hide file tree
Showing 32 changed files with 1,601 additions and 92 deletions.
32 changes: 26 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,26 @@ if(CMAKE_LINK_STATIC)
endif()
endif()

if(CMAKE_C_COMPILER_ID MATCHES "MSVC")
# asm optimized monero v8 code
enable_language(ASM_MASM)
set_property(SOURCE "xmrstak/backend/cpu/crypto/asm/cryptonight_v8_main_loop.asm" PROPERTY ASM_MASM)
add_library(xmr-stak-asm
STATIC
"xmrstak/backend/cpu/crypto/asm/cryptonight_v8_main_loop.asm"
)
else()
# asm optimized monero v8 code
enable_language(ASM)
set_property(SOURCE "xmrstak/backend/cpu/crypto/asm/cryptonight_v8_main_loop.S" PROPERTY C)
add_library(xmr-stak-asm
STATIC
"xmrstak/backend/cpu/crypto/asm/cryptonight_v8_main_loop.S"
)
endif()

set_property(TARGET xmr-stak-asm PROPERTY LINKER_LANGUAGE C)

# compile C files
file(GLOB SRCFILES_C "xmrstak/backend/cpu/crypto/*.c")

Expand All @@ -456,7 +476,7 @@ set_property(TARGET xmr-stak-c PROPERTY C_STANDARD 99)
if(MICROHTTPD_ENABLE)
target_link_libraries(xmr-stak-c ${MHTD})
endif()
target_link_libraries(xmr-stak-c ${LIBS})
target_link_libraries(xmr-stak-c ${LIBS} xmr-stak-asm)

# compile generic backend files
file(GLOB BACKEND_CPP
Expand All @@ -472,7 +492,7 @@ add_library(xmr-stak-backend
STATIC
${BACKEND_CPP}
)
target_link_libraries(xmr-stak-backend xmr-stak-c ${CMAKE_DL_LIBS})
target_link_libraries(xmr-stak-backend xmr-stak-c ${CMAKE_DL_LIBS} xmr-stak-asm)

# compile CUDA backend
if(CUDA_FOUND)
Expand All @@ -499,7 +519,7 @@ if(CUDA_FOUND)
)
endif()
target_link_libraries(xmrstak_cuda_backend ${CUDA_LIBRARIES})
target_link_libraries(xmrstak_cuda_backend xmr-stak-backend)
target_link_libraries(xmrstak_cuda_backend xmr-stak-backend xmr-stak-asm)
endif()

# compile AMD backend
Expand All @@ -512,7 +532,7 @@ if(OpenCL_FOUND)
${OPENCLSRCFILES}
)
target_link_libraries(xmrstak_opencl_backend ${OpenCL_LIBRARY} )
target_link_libraries(xmrstak_opencl_backend xmr-stak-backend)
target_link_libraries(xmrstak_opencl_backend xmr-stak-backend xmr-stak-asm)
endif()

# compile final binary
Expand All @@ -528,7 +548,7 @@ endif()
set(EXECUTABLE_OUTPUT_PATH "bin" CACHE STRING "Path to place executables relative to ${CMAKE_INSTALL_PREFIX}")
set(LIBRARY_OUTPUT_PATH "bin" CACHE STRING "Path to place libraries relative to ${CMAKE_INSTALL_PREFIX}")

target_link_libraries(xmr-stak ${LIBS} xmr-stak-c xmr-stak-backend)
target_link_libraries(xmr-stak ${LIBS} xmr-stak-c xmr-stak-backend xmr-stak-asm)

################################################################################
# Install
Expand Down Expand Up @@ -559,4 +579,4 @@ if( NOT CMAKE_INSTALL_PREFIX STREQUAL PROJECT_BINARY_DIR )
else()
# this rule is used if the install prefix is the build directory
install(CODE "MESSAGE(\"xmr-stak installed to folder 'bin'\")")
endif()
endif()
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ If your prefered coin is not listed, you can choose one of the following algorit
- cryptonight_masari
- cryptonight_v7
- cryptonight_v7_stellite
- cryptonight_v8
- 4MiB scratchpad memory
- cryptonight_haven
- cryptonight_heavy
Expand Down
28 changes: 27 additions & 1 deletion xmrstak/backend/amd/amd_gpu/gpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,7 @@ size_t InitOpenCLGpu(cl_context opencl_ctx, GpuContext* ctx, const char* source_
options += " -DCOMP_MODE=" + std::to_string(ctx->compMode ? 1u : 0u);
options += " -DMEMORY=" + std::to_string(hashMemSize);
options += " -DALGO=" + std::to_string(miner_algo[ii]);
options += " -DCN_UNROLL=" + std::to_string(ctx->unroll);

/* create a hash for the compile time cache
* used data:
Expand Down Expand Up @@ -901,6 +902,9 @@ size_t InitOpenCL(GpuContext* ctx, size_t num_gpus, size_t platform_idx)

//char* source_code = LoadTextFile(sSourcePath);

const char *fastIntMathV2CL =
#include "./opencl/fast_int_math_v2.cl"
;
const char *cryptonightCL =
#include "./opencl/cryptonight.cl"
;
Expand All @@ -921,6 +925,7 @@ size_t InitOpenCL(GpuContext* ctx, size_t num_gpus, size_t platform_idx)
;

std::string source_code(cryptonightCL);
source_code = std::regex_replace(source_code, std::regex("XMRSTAK_INCLUDE_FAST_INT_MATH_V2"), fastIntMathV2CL);
source_code = std::regex_replace(source_code, std::regex("XMRSTAK_INCLUDE_WOLF_AES"), wolfAesCL);
source_code = std::regex_replace(source_code, std::regex("XMRSTAK_INCLUDE_WOLF_SKEIN"), wolfSkeinCL);
source_code = std::regex_replace(source_code, std::regex("XMRSTAK_INCLUDE_JH"), jhCL);
Expand All @@ -930,16 +935,37 @@ size_t InitOpenCL(GpuContext* ctx, size_t num_gpus, size_t platform_idx)
// create a directory for the OpenCL compile cache
create_directory(get_home() + "/.openclcache");

// check if cryptonight_monero_v8 is selected for the user or dev pool
bool useCryptonight_v8 =
::jconf::inst()->GetCurrentCoinSelection().GetDescription(1).GetMiningAlgo() == cryptonight_monero_v8 ||
::jconf::inst()->GetCurrentCoinSelection().GetDescription(1).GetMiningAlgoRoot() == cryptonight_monero_v8 ||
::jconf::inst()->GetCurrentCoinSelection().GetDescription(0).GetMiningAlgo() == cryptonight_monero_v8 ||
::jconf::inst()->GetCurrentCoinSelection().GetDescription(0).GetMiningAlgoRoot() == cryptonight_monero_v8;

for(int i = 0; i < num_gpus; ++i)
{
const std::string backendName = xmrstak::params::inst().openCLVendor;
if(ctx[i].stridedIndex == 2 && (ctx[i].rawIntensity % ctx[i].workSize) != 0)
{
size_t reduced_intensity = (ctx[i].rawIntensity / ctx[i].workSize) * ctx[i].workSize;
ctx[i].rawIntensity = reduced_intensity;
const std::string backendName = xmrstak::params::inst().openCLVendor;
printer::inst()->print_msg(L0, "WARNING %s: gpu %d intensity is not a multiple of 'worksize', auto reduce intensity to %d", backendName.c_str(), ctx[i].deviceIdx, int(reduced_intensity));
}

if(useCryptonight_v8)
{
if(ctx[i].stridedIndex == 1)
{
printer::inst()->print_msg(L0, "ERROR %s: gpu %d stridedIndex is not allowed to be `true` or `1` for the selected currency", backendName.c_str(), ctx[i].deviceIdx);
return ERR_STUPID_PARAMS;
}
if(ctx[i].stridedIndex == 2 && ctx[i].memChunk < 2)
{
printer::inst()->print_msg(L0, "ERROR %s: gpu %d memChunk bust be >= 2 for the selected currency", backendName.c_str(), ctx[i].deviceIdx);
return ERR_STUPID_PARAMS;
}
}

if((ret = InitOpenCLGpu(opencl_ctx, &ctx[i], source_code.c_str())) != ERR_SUCCESS)
{
return ret;
Expand Down
1 change: 1 addition & 0 deletions xmrstak/backend/amd/amd_gpu/gpu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ struct GpuContext
size_t workSize;
int stridedIndex;
int memChunk;
int unroll = 0;
bool isNVIDIA = false;
int compMode;

Expand Down
Loading

0 comments on commit cfe33ad

Please sign in to comment.