wip
This commit is contained in:
24
rin/miner/gpu/RinHash-cuda/RinHashCUDA.sln
Normal file
24
rin/miner/gpu/RinHash-cuda/RinHashCUDA.sln
Normal file
@@ -0,0 +1,24 @@
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.0.31903.59
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RinHashCUDA", "RinHashCUDA.vcxproj", "{A1B2C3D4-E5F6-7890-ABCD-EF1234567890}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
Release|x64 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{A1B2C3D4-E5F6-7890-ABCD-EF1234567890}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{A1B2C3D4-E5F6-7890-ABCD-EF1234567890}.Debug|x64.Build.0 = Debug|x64
|
||||
{A1B2C3D4-E5F6-7890-ABCD-EF1234567890}.Release|x64.ActiveCfg = Release|x64
|
||||
{A1B2C3D4-E5F6-7890-ABCD-EF1234567890}.Release|x64.Build.0 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {12345678-1234-5678-9ABC-DEF123456789}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
114
rin/miner/gpu/RinHash-cuda/RinHashCUDA.vcxproj
Normal file
114
rin/miner/gpu/RinHash-cuda/RinHashCUDA.vcxproj
Normal file
@@ -0,0 +1,114 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>16.0</VCProjectVersion>
|
||||
<ProjectGuid>{A1B2C3D4-E5F6-7890-ABCD-EF1234567890}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>RinHashCUDA</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)obj\$(Platform)\$(Configuration)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)obj\$(Platform)\$(Configuration)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalIncludeDirectories>$(CUDA_PATH)\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalLibraryDirectories>$(CUDA_PATH)\lib\x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>cudart.lib;cuda.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalIncludeDirectories>$(CUDA_PATH)\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalLibraryDirectories>$(CUDA_PATH)\lib\x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>cudart.lib;cuda.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="rinhash.cu">
|
||||
<FileType>CUDA C/C++</FileType>
|
||||
</ClCompile>
|
||||
<ClCompile Include="sha3-256.cu">
|
||||
<FileType>CUDA C/C++</FileType>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="argon2d_device.cuh" />
|
||||
<ClInclude Include="blake3_device.cuh" />
|
||||
<ClInclude Include="blaze3_cpu.cuh" />
|
||||
<ClInclude Include="rinhash_device.cuh" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="build-cuda.bat" />
|
||||
<None Include="CMakeLists.txt" />
|
||||
<None Include="Makefile" />
|
||||
<None Include="README.md" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
<Import Project="$(VCTargetsPath)\BuildCustomizations\CUDA 12.5.targets" />
|
||||
</ImportGroup>
|
||||
</Project>
|
56
rin/miner/gpu/RinHash-cuda/RinHashCUDA.vcxproj.filters
Normal file
56
rin/miner/gpu/RinHash-cuda/RinHashCUDA.vcxproj.filters
Normal file
@@ -0,0 +1,56 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D38A0280}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="CUDA Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>cu;cuh</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Build Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD02}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="rinhash.cu">
|
||||
<Filter>CUDA Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="sha3-256.cu">
|
||||
<Filter>CUDA Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="argon2d_device.cuh">
|
||||
<Filter>CUDA Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="blake3_device.cuh">
|
||||
<Filter>CUDA Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="blaze3_cpu.cuh">
|
||||
<Filter>CUDA Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="rinhash_device.cuh">
|
||||
<Filter>CUDA Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="build-cuda.bat">
|
||||
<Filter>Build Files</Filter>
|
||||
</None>
|
||||
<None Include="CMakeLists.txt">
|
||||
<Filter>Build Files</Filter>
|
||||
</None>
|
||||
<None Include="Makefile">
|
||||
<Filter>Build Files</Filter>
|
||||
</None>
|
||||
<None Include="README.md">
|
||||
<Filter>Build Files</Filter>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
</Project>
|
@@ -809,7 +809,6 @@ __device__ void device_argon2d_hash(
|
||||
block* memory,
|
||||
const uint8_t* salt, size_t salt_len
|
||||
) {
|
||||
argon2_instance_t instance;
|
||||
// 1. メモリサイズの調整
|
||||
uint32_t memory_blocks = m_cost;
|
||||
if (memory_blocks < 2 * ARGON2_SYNC_POINTS * lanes) {
|
||||
@@ -819,16 +818,6 @@ __device__ void device_argon2d_hash(
|
||||
uint32_t segment_length = memory_blocks / (lanes * ARGON2_SYNC_POINTS);
|
||||
memory_blocks = segment_length * (lanes * ARGON2_SYNC_POINTS);
|
||||
uint32_t lane_length = segment_length * ARGON2_SYNC_POINTS;
|
||||
|
||||
// Initialize instance with the provided memory pointer
|
||||
instance.version = ARGON2_VERSION_13;
|
||||
instance.memory = memory; // Use the provided memory pointer
|
||||
instance.passes = t_cost;
|
||||
instance.memory_blocks = memory_blocks;
|
||||
instance.segment_length = segment_length;
|
||||
instance.lane_length = lane_length;
|
||||
instance.lanes = lanes;
|
||||
instance.threads = 1;
|
||||
|
||||
// 2. 初期ハッシュの計算
|
||||
uint8_t blockhash[ARGON2_PREHASH_DIGEST_LENGTH];
|
||||
|
@@ -201,10 +201,12 @@ __global__ void compute(Chunk *data, int l, int r) {
|
||||
// printf("Compressing : %d\n", l);
|
||||
}
|
||||
else {
|
||||
// Launch child kernels without synchronization (host will handle sync)
|
||||
compute<<<n/2,16>>>(data, l, l+n/2);
|
||||
cudaDeviceSynchronize();
|
||||
compute<<<n/2,16>>>(data, l+n/2, r);
|
||||
cudaDeviceSynchronize();
|
||||
|
||||
// Wait for all threads in this block to finish
|
||||
__syncthreads();
|
||||
|
||||
data[l].flags |= PARENT;
|
||||
|
||||
|
99
rin/miner/gpu/RinHash-cuda/build-cuda-linux.sh
Normal file
99
rin/miner/gpu/RinHash-cuda/build-cuda-linux.sh
Normal file
@@ -0,0 +1,99 @@
|
||||
#!/bin/bash
|
||||
# RinHash CUDA Build Script for Linux/WSL
|
||||
# This script builds the CUDA implementation of RinHash
|
||||
|
||||
echo "======================================"
|
||||
echo " RinHash CUDA Miner Build Script"
|
||||
echo "======================================"
|
||||
|
||||
# Check if NVCC is available
|
||||
if ! command -v nvcc &> /dev/null; then
|
||||
echo "ERROR: NVCC not found in PATH"
|
||||
echo "Please install CUDA Toolkit"
|
||||
echo "On Ubuntu/Debian: sudo apt install nvidia-cuda-toolkit"
|
||||
echo "Or download from: https://developer.nvidia.com/cuda-downloads"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "NVCC found:"
|
||||
nvcc --version
|
||||
echo ""
|
||||
|
||||
# Check if gcc/g++ is available
|
||||
if ! command -v gcc &> /dev/null; then
|
||||
echo "ERROR: GCC not found in PATH"
|
||||
echo "Please install build-essential: sudo apt install build-essential"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "GCC found:"
|
||||
gcc --version | head -1
|
||||
echo ""
|
||||
|
||||
echo "Building RinHash CUDA miner..."
|
||||
echo ""
|
||||
|
||||
# Create output directory
|
||||
mkdir -p bin
|
||||
|
||||
# Compile with NVCC (enable device linking for dynamic parallelism)
|
||||
nvcc -O3 -std=c++11 \
|
||||
-arch=sm_50 \
|
||||
-gencode arch=compute_50,code=sm_50 \
|
||||
-gencode arch=compute_52,code=sm_52 \
|
||||
-gencode arch=compute_60,code=sm_60 \
|
||||
-gencode arch=compute_61,code=sm_61 \
|
||||
-gencode arch=compute_70,code=sm_70 \
|
||||
-gencode arch=compute_75,code=sm_75 \
|
||||
-gencode arch=compute_80,code=sm_80 \
|
||||
-gencode arch=compute_86,code=sm_86 \
|
||||
-I. \
|
||||
rinhash.cu sha3-256.cu \
|
||||
-o bin/rinhash-cuda-miner \
|
||||
-lcuda -lcudart -lcudadevrt
|
||||
|
||||
# Also build test program
|
||||
echo "Building test program..."
|
||||
nvcc -O3 -std=c++11 \
|
||||
-arch=sm_50 \
|
||||
-gencode arch=compute_50,code=sm_50 \
|
||||
-gencode arch=compute_52,code=sm_52 \
|
||||
-gencode arch=compute_60,code=sm_60 \
|
||||
-gencode arch=compute_61,code=sm_61 \
|
||||
-gencode arch=compute_70,code=sm_70 \
|
||||
-gencode arch=compute_75,code=sm_75 \
|
||||
-gencode arch=compute_80,code=sm_80 \
|
||||
-gencode arch=compute_86,code=sm_86 \
|
||||
-I. \
|
||||
test_miner.cu rinhash.cu sha3-256.cu \
|
||||
-o bin/test_miner \
|
||||
-lcuda -lcudart -lcudadevrt
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
echo ""
|
||||
echo "======================================"
|
||||
echo " BUILD SUCCESSFUL!"
|
||||
echo "======================================"
|
||||
echo ""
|
||||
echo "Executables created:"
|
||||
echo " - bin/rinhash-cuda-miner (main miner)"
|
||||
echo " - bin/test_miner (test program)"
|
||||
echo ""
|
||||
echo "To test the miner:"
|
||||
echo " ./bin/test_miner"
|
||||
echo ""
|
||||
else
|
||||
echo ""
|
||||
echo "======================================"
|
||||
echo " BUILD FAILED!"
|
||||
echo "======================================"
|
||||
echo ""
|
||||
echo "Common issues:"
|
||||
echo "1. Missing CUDA runtime libraries"
|
||||
echo "2. Incompatible CUDA version"
|
||||
echo "3. Missing development tools"
|
||||
echo ""
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Build completed successfully!"
|
@@ -111,7 +111,7 @@ __device__ void sha3_256_device(const uint8_t *input, size_t inlen, uint8_t *has
|
||||
uint64_t st[25] = {0}; // 内部状態(25ワード=1600ビット)
|
||||
|
||||
for (int i = 0; i < 25; i++) st[i] = 0;
|
||||
size_t offset = 0;
|
||||
// size_t offset = 0; // Removed unused variable
|
||||
|
||||
|
||||
// 通常ブロック(rateバイト)処理(今回inlen=32なのでスキップされるはず)
|
||||
|
85
rin/miner/gpu/RinHash-cuda/test_miner.cu
Normal file
85
rin/miner/gpu/RinHash-cuda/test_miner.cu
Normal file
@@ -0,0 +1,85 @@
|
||||
#include <cuda_runtime.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
|
||||
// External functions from our CUDA implementation
|
||||
extern "C" void RinHash(
|
||||
const uint32_t* version,
|
||||
const uint32_t* prev_block,
|
||||
const uint32_t* merkle_root,
|
||||
const uint32_t* timestamp,
|
||||
const uint32_t* bits,
|
||||
const uint32_t* nonce,
|
||||
uint8_t* output
|
||||
);
|
||||
|
||||
extern "C" void RinHash_mine(
|
||||
const uint32_t* version,
|
||||
const uint32_t* prev_block,
|
||||
const uint32_t* merkle_root,
|
||||
const uint32_t* timestamp,
|
||||
const uint32_t* bits,
|
||||
uint32_t start_nonce,
|
||||
uint32_t num_nonces,
|
||||
uint32_t* found_nonce,
|
||||
uint8_t* target_hash,
|
||||
uint8_t* best_hash
|
||||
);
|
||||
|
||||
void print_hex(const char* label, const uint8_t* data, size_t len) {
|
||||
printf("%s: ", label);
|
||||
for (size_t i = 0; i < len; i++) {
|
||||
printf("%02x", data[i]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
printf("RinHash CUDA Miner Test\n");
|
||||
printf("=======================\n\n");
|
||||
|
||||
// Initialize CUDA
|
||||
cudaError_t cudaStatus = cudaSetDevice(0);
|
||||
if (cudaStatus != cudaSuccess) {
|
||||
fprintf(stderr, "cudaSetDevice failed! Do you have a CUDA-capable GPU?\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Test data - sample block header
|
||||
uint32_t version = 0x20000000;
|
||||
uint32_t prev_block[8] = {
|
||||
0x12345678, 0x9abcdef0, 0x12345678, 0x9abcdef0,
|
||||
0x12345678, 0x9abcdef0, 0x12345678, 0x9abcdef0
|
||||
};
|
||||
uint32_t merkle_root[8] = {
|
||||
0xabcdef12, 0x34567890, 0xabcdef12, 0x34567890,
|
||||
0xabcdef12, 0x34567890, 0xabcdef12, 0x34567890
|
||||
};
|
||||
uint32_t timestamp = 0x5f123456;
|
||||
uint32_t bits = 0x1d00ffff;
|
||||
uint32_t nonce = 0x12345678;
|
||||
|
||||
uint8_t output[32];
|
||||
|
||||
printf("Testing single hash...\n");
|
||||
RinHash(&version, prev_block, merkle_root, ×tamp, &bits, &nonce, output);
|
||||
print_hex("Hash result", output, 32);
|
||||
|
||||
printf("\nTesting mining (trying 1000 nonces)...\n");
|
||||
uint32_t found_nonce;
|
||||
uint8_t target_hash[32];
|
||||
uint8_t best_hash[32];
|
||||
|
||||
// Set a target (easier than difficulty)
|
||||
memset(target_hash, 0xff, 32);
|
||||
|
||||
RinHash_mine(&version, prev_block, merkle_root, ×tamp, &bits,
|
||||
0, 1000, &found_nonce, target_hash, best_hash);
|
||||
|
||||
printf("Found nonce: 0x%08x\n", found_nonce);
|
||||
print_hex("Best hash", best_hash, 32);
|
||||
|
||||
printf("\nTest completed successfully!\n");
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user