Skip to content
This repository was archived by the owner on Jan 9, 2021. It is now read-only.

Commit 32d6b6a

Browse files
author
nicehashdev
committed
CUDA7.5 support for older cards
1 parent e769c27 commit 32d6b6a

File tree

11 files changed

+198
-55
lines changed

11 files changed

+198
-55
lines changed

cuda_tromp/cuda_tromp.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ struct proof;
1010
#include "eqcuda.hpp"
1111

1212

13-
cuda_tromp::cuda_tromp(int platf_id, int dev_id)
13+
SOLVER_NAME::SOLVER_NAME(int platf_id, int dev_id)
1414
{
1515
device_id = dev_id;
1616
getinfo(0, dev_id, m_gpu_name, m_sm_count, m_version);
@@ -21,21 +21,21 @@ cuda_tromp::cuda_tromp(int platf_id, int dev_id)
2121
}
2222

2323

24-
std::string cuda_tromp::getdevinfo()
24+
std::string SOLVER_NAME::getdevinfo()
2525
{
2626
return m_gpu_name + " (#" + std::to_string(device_id) + ") BLOCKS=" +
2727
std::to_string(blocks) + ", THREADS=" + std::to_string(threadsperblock);
2828
}
2929

3030

31-
int cuda_tromp::getcount()
31+
int SOLVER_NAME::getcount()
3232
{
3333
int device_count;
3434
checkCudaErrors(cudaGetDeviceCount(&device_count));
3535
return device_count;
3636
}
3737

38-
void cuda_tromp::getinfo(int platf_id, int d_id, std::string& gpu_name, int& sm_count, std::string& version)
38+
void SOLVER_NAME::getinfo(int platf_id, int d_id, std::string& gpu_name, int& sm_count, std::string& version)
3939
{
4040
//int runtime_version;
4141
//checkCudaErrors(cudaRuntimeGetVersion(&runtime_version));
@@ -50,27 +50,27 @@ void cuda_tromp::getinfo(int platf_id, int d_id, std::string& gpu_name, int& sm_
5050
}
5151

5252

53-
void cuda_tromp::start(cuda_tromp& device_context)
53+
void SOLVER_NAME::start(SOLVER_NAME& device_context)
5454
{
5555
device_context.context = new eq_cuda_context(device_context.threadsperblock,
5656
device_context.blocks,
5757
device_context.device_id);
5858
}
5959

60-
void cuda_tromp::stop(cuda_tromp& device_context)
60+
void SOLVER_NAME::stop(SOLVER_NAME& device_context)
6161
{
6262
if (device_context.context)
6363
delete device_context.context;
6464
}
6565

66-
void cuda_tromp::solve(const char *tequihash_header,
66+
void SOLVER_NAME::solve(const char *tequihash_header,
6767
unsigned int tequihash_header_len,
6868
const char* nonce,
6969
unsigned int nonce_len,
7070
std::function<bool()> cancelf,
7171
std::function<void(const std::vector<uint32_t>&, size_t, const unsigned char*)> solutionf,
7272
std::function<void(void)> hashdonef,
73-
cuda_tromp& device_context)
73+
SOLVER_NAME& device_context)
7474
{
7575
device_context.context->solve(tequihash_header,
7676
tequihash_header_len,

cuda_tromp/cuda_tromp.hpp

Lines changed: 54 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,32 @@
44
#define DLL_CUDA_TROMP
55
#endif
66

7+
#ifdef CUDA_75
8+
#define SOLVER_NAME cuda_tromp_75
9+
#else
10+
#define SOLVER_NAME cuda_tromp
11+
#endif
12+
713
struct eq_cuda_context;
814

9-
struct DLL_CUDA_TROMP cuda_tromp
15+
struct DLL_CUDA_TROMP SOLVER_NAME
1016
{
1117
int threadsperblock;
1218
int blocks;
1319
int device_id;
1420
eq_cuda_context* context;
1521

16-
cuda_tromp(int platf_id, int dev_id);
22+
SOLVER_NAME(int platf_id, int dev_id);
1723

1824
std::string getdevinfo();
1925

2026
static int getcount();
2127

2228
static void getinfo(int platf_id, int d_id, std::string& gpu_name, int& sm_count, std::string& version);
2329

24-
static void start(cuda_tromp& device_context);
30+
static void start(SOLVER_NAME& device_context);
2531

26-
static void stop(cuda_tromp& device_context);
32+
static void stop(SOLVER_NAME& device_context);
2733

2834
static void solve(const char *tequihash_header,
2935
unsigned int tequihash_header_len,
@@ -32,12 +38,54 @@ struct DLL_CUDA_TROMP cuda_tromp
3238
std::function<bool()> cancelf,
3339
std::function<void(const std::vector<uint32_t>&, size_t, const unsigned char*)> solutionf,
3440
std::function<void(void)> hashdonef,
35-
cuda_tromp& device_context);
41+
SOLVER_NAME& device_context);
3642

3743
std::string getname() { return "CUDA-TROMP"; }
3844

3945
private:
4046
std::string m_gpu_name;
4147
std::string m_version;
4248
int m_sm_count;
43-
};
49+
};
50+
51+
#ifndef _LIB
52+
#undef SOLVER_NAME
53+
#define SOLVER_NAME cuda_tromp_75
54+
55+
struct DLL_CUDA_TROMP SOLVER_NAME
56+
{
57+
int threadsperblock;
58+
int blocks;
59+
int device_id;
60+
eq_cuda_context* context;
61+
62+
SOLVER_NAME(int platf_id, int dev_id);
63+
64+
std::string getdevinfo();
65+
66+
static int getcount();
67+
68+
static void getinfo(int platf_id, int d_id, std::string& gpu_name, int& sm_count, std::string& version);
69+
70+
static void start(SOLVER_NAME& device_context);
71+
72+
static void stop(SOLVER_NAME& device_context);
73+
74+
static void solve(const char *tequihash_header,
75+
unsigned int tequihash_header_len,
76+
const char* nonce,
77+
unsigned int nonce_len,
78+
std::function<bool()> cancelf,
79+
std::function<void(const std::vector<uint32_t>&, size_t, const unsigned char*)> solutionf,
80+
std::function<void(void)> hashdonef,
81+
SOLVER_NAME& device_context);
82+
83+
std::string getname() { return "CUDA-TROMP-75"; }
84+
85+
private:
86+
std::string m_gpu_name;
87+
std::string m_version;
88+
int m_sm_count;
89+
};
90+
91+
#endif

cuda_tromp/cuda_tromp.vcxproj

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
<Configuration>Debug</Configuration>
66
<Platform>x64</Platform>
77
</ProjectConfiguration>
8+
<ProjectConfiguration Include="Release7.5|x64">
9+
<Configuration>Release7.5</Configuration>
10+
<Platform>x64</Platform>
11+
</ProjectConfiguration>
812
<ProjectConfiguration Include="Release|x64">
913
<Configuration>Release</Configuration>
1014
<Platform>x64</Platform>
@@ -26,6 +30,7 @@
2630
<PropertyGroup Label="Globals">
2731
<ProjectGuid>{33C2B469-F025-4223-B9B6-E69D42FEA7D6}</ProjectGuid>
2832
<RootNamespace>cuda_tromp</RootNamespace>
33+
<CudaToolkitCustomDir>$(CUDA_PATH_V7_5)</CudaToolkitCustomDir>
2934
</PropertyGroup>
3035
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
3136
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
@@ -41,6 +46,13 @@
4146
<CharacterSet>MultiByte</CharacterSet>
4247
<PlatformToolset>v120</PlatformToolset>
4348
</PropertyGroup>
49+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release7.5|x64'" Label="Configuration">
50+
<ConfigurationType>DynamicLibrary</ConfigurationType>
51+
<UseDebugLibraries>false</UseDebugLibraries>
52+
<WholeProgramOptimization>true</WholeProgramOptimization>
53+
<CharacterSet>MultiByte</CharacterSet>
54+
<PlatformToolset>v120</PlatformToolset>
55+
</PropertyGroup>
4456
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
4557
<ImportGroup Label="ExtensionSettings">
4658
<Import Project="$(VCTargetsPath)\BuildCustomizations\CUDA 8.0.props" />
@@ -51,10 +63,18 @@
5163
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
5264
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
5365
</ImportGroup>
66+
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release7.5|x64'" Label="PropertySheets">
67+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
68+
</ImportGroup>
5469
<PropertyGroup Label="UserMacros" />
5570
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
5671
<LinkIncremental>true</LinkIncremental>
5772
</PropertyGroup>
73+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release7.5|x64'">
74+
<TargetName>$(ProjectName)_75</TargetName>
75+
<OutDir>$(SolutionDir)$(Platform)\Release\</OutDir>
76+
<IntDir>$(Platform)\Release\</IntDir>
77+
</PropertyGroup>
5878
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
5979
<ClCompile>
6080
<WarningLevel>Level3</WarningLevel>
@@ -105,7 +125,35 @@ copy "$(CudaToolkitBinDir)\cudart*.dll" "$(OutDir)"</Command>
105125
</PostBuildEvent>
106126
<CudaCompile>
107127
<TargetMachinePlatform>64</TargetMachinePlatform>
108-
<CodeGeneration>compute_50,sm_50</CodeGeneration>
128+
<CodeGeneration>compute_61,sm_61;compute_52,sm_52;compute_50,sm_50;compute_35,sm_35;compute_30,sm_30;</CodeGeneration>
129+
<PtxAsOptionV>true</PtxAsOptionV>
130+
</CudaCompile>
131+
</ItemDefinitionGroup>
132+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release7.5|x64'">
133+
<ClCompile>
134+
<WarningLevel>Level3</WarningLevel>
135+
<Optimization>MaxSpeed</Optimization>
136+
<FunctionLevelLinking>true</FunctionLevelLinking>
137+
<IntrinsicFunctions>true</IntrinsicFunctions>
138+
<PreprocessorDefinitions>WIN32;WIN64;NDEBUG;_CONSOLE;_LIB;CUDA_75;%(PreprocessorDefinitions)</PreprocessorDefinitions>
139+
<MultiProcessorCompilation>true</MultiProcessorCompilation>
140+
<DisableSpecificWarnings>4334;4316;4244;4996;4251;</DisableSpecificWarnings>
141+
<AdditionalIncludeDirectories>..\3rdparty\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
142+
</ClCompile>
143+
<Link>
144+
<GenerateDebugInformation>true</GenerateDebugInformation>
145+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
146+
<OptimizeReferences>true</OptimizeReferences>
147+
<SubSystem>Console</SubSystem>
148+
<AdditionalDependencies>cudart.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
149+
</Link>
150+
<PostBuildEvent>
151+
<Command>echo copy "$(CudaToolkitBinDir)\cudart*.dll" "$(OutDir)"
152+
copy "$(CudaToolkitBinDir)\cudart*.dll" "$(OutDir)"</Command>
153+
</PostBuildEvent>
154+
<CudaCompile>
155+
<TargetMachinePlatform>64</TargetMachinePlatform>
156+
<CodeGeneration>compute_52,sm_52;compute_50,sm_50;compute_35,sm_35;compute_30,sm_30;compute_20,sm_21;</CodeGeneration>
109157
<PtxAsOptionV>true</PtxAsOptionV>
110158
</CudaCompile>
111159
</ItemDefinitionGroup>

nheqminer/libstratum/StratumClient.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,8 @@ bool StratumClient<Miner, Job, Solution>::submit(const Solution* solution, const
421421
return true;
422422
}
423423

424-
template class StratumClient<ZMinerAVX, ZcashJob, EquihashSolution>;
425-
template class StratumClient<ZMinerSSE2, ZcashJob, EquihashSolution>;
424+
template class StratumClient<ZMinerAVXCUDA80, ZcashJob, EquihashSolution>;
425+
template class StratumClient<ZMinerSSE2CUDA80, ZcashJob, EquihashSolution>;
426+
template class StratumClient<ZMinerAVXCUDA75, ZcashJob, EquihashSolution>;
427+
template class StratumClient<ZMinerSSE2CUDA75, ZcashJob, EquihashSolution>;
426428

nheqminer/libstratum/StratumClient.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@ class StratumClient
162162
};
163163

164164

165-
typedef StratumClient<ZMinerAVX, ZcashJob, EquihashSolution> ZcashStratumClientAVX;
166-
typedef StratumClient<ZMinerSSE2, ZcashJob, EquihashSolution> ZcashStratumClientSSE2;
165+
typedef StratumClient<ZMinerAVXCUDA80, ZcashJob, EquihashSolution> ZcashStratumClientAVXCUDA80;
166+
typedef StratumClient<ZMinerSSE2CUDA80, ZcashJob, EquihashSolution> ZcashStratumClientSSE2CUDA80;
167+
typedef StratumClient<ZMinerAVXCUDA75, ZcashJob, EquihashSolution> ZcashStratumClientAVXCUDA75;
168+
typedef StratumClient<ZMinerSSE2CUDA75, ZcashJob, EquihashSolution> ZcashStratumClientSSE2CUDA75;
167169

nheqminer/libstratum/ZcashStratum.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,8 @@ void ZcashMiner<CPUSolver, CUDASolver, OPENCLSolver>::failedSolution()
603603

604604
template class ZcashMiner<cpu_xenoncat, cuda_tromp, ocl_xmp>;
605605
template class ZcashMiner<cpu_tromp, cuda_tromp, ocl_xmp>;
606+
template class ZcashMiner<cpu_xenoncat, cuda_tromp_75, ocl_xmp>;
607+
template class ZcashMiner<cpu_tromp, cuda_tromp_75, ocl_xmp>;
606608

607609
std::mutex benchmark_work;
608610
std::vector<uint256*> benchmark_nonces;
@@ -808,12 +810,12 @@ void ZcashMiner<CPUSolver, CUDASolver, OPENCLSolver>::doBenchmark(int hashes, in
808810
}
809811

810812

811-
void ZMinerAVX_doBenchmark(int hashes, int cpu_threads, int cuda_count, int* cuda_en, int* cuda_b, int* cuda_t,
812-
int opencl_count, int opencl_platf, int* opencl_en) {
813-
ZMinerAVX::doBenchmark(hashes, cpu_threads, cuda_count, cuda_en, cuda_b, cuda_t, opencl_count, opencl_platf, opencl_en);
814-
}
815-
816-
void ZMinerSSE2_doBenchmark(int hashes, int cpu_threads, int cuda_count, int* cuda_en, int* cuda_b, int* cuda_t,
817-
int opencl_count, int opencl_platf, int* opencl_en) {
818-
ZMinerSSE2::doBenchmark(hashes, cpu_threads, cuda_count, cuda_en, cuda_b, cuda_t, opencl_count, opencl_platf, opencl_en);
819-
}
813+
//void ZMinerAVX_doBenchmark(int hashes, int cpu_threads, int cuda_count, int* cuda_en, int* cuda_b, int* cuda_t,
814+
// int opencl_count, int opencl_platf, int* opencl_en) {
815+
// ZMinerAVX::doBenchmark(hashes, cpu_threads, cuda_count, cuda_en, cuda_b, cuda_t, opencl_count, opencl_platf, opencl_en);
816+
//}
817+
//
818+
//void ZMinerSSE2_doBenchmark(int hashes, int cpu_threads, int cuda_count, int* cuda_en, int* cuda_b, int* cuda_t,
819+
// int opencl_count, int opencl_platf, int* opencl_en) {
820+
// ZMinerSSE2::doBenchmark(hashes, cpu_threads, cuda_count, cuda_en, cuda_b, cuda_t, opencl_count, opencl_platf, opencl_en);
821+
//}

nheqminer/libstratum/ZcashStratum.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,10 @@ class ZcashMiner
141141
int opencl_count, int opencl_platf, int* opencl_en);
142142
};
143143

144-
typedef ZcashMiner<cpu_xenoncat, cuda_tromp, ocl_xmp> ZMinerAVX;
145-
typedef ZcashMiner<cpu_tromp, cuda_tromp, ocl_xmp> ZMinerSSE2;
144+
typedef ZcashMiner<cpu_xenoncat, cuda_tromp, ocl_xmp> ZMinerAVXCUDA80;
145+
typedef ZcashMiner<cpu_tromp, cuda_tromp, ocl_xmp> ZMinerSSE2CUDA80;
146+
typedef ZcashMiner<cpu_xenoncat, cuda_tromp_75, ocl_xmp> ZMinerAVXCUDA75;
147+
typedef ZcashMiner<cpu_tromp, cuda_tromp_75, ocl_xmp> ZMinerSSE2CUDA75;
146148

147149
// gcc static undefined reference workaround
148150
void ZMinerAVX_doBenchmark(int hashes, int cpu_threads, int cuda_count, int* cuda_en, int* cuda_b, int* cuda_t,

0 commit comments

Comments
 (0)