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

Commit

Permalink
CUDA7.5 support for older cards
Browse files Browse the repository at this point in the history
  • Loading branch information
nicehashdev committed Nov 3, 2016
1 parent e769c27 commit 32d6b6a
Show file tree
Hide file tree
Showing 11 changed files with 198 additions and 55 deletions.
16 changes: 8 additions & 8 deletions cuda_tromp/cuda_tromp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ struct proof;
#include "eqcuda.hpp"


cuda_tromp::cuda_tromp(int platf_id, int dev_id)
SOLVER_NAME::SOLVER_NAME(int platf_id, int dev_id)
{
device_id = dev_id;
getinfo(0, dev_id, m_gpu_name, m_sm_count, m_version);
Expand All @@ -21,21 +21,21 @@ cuda_tromp::cuda_tromp(int platf_id, int dev_id)
}


std::string cuda_tromp::getdevinfo()
std::string SOLVER_NAME::getdevinfo()
{
return m_gpu_name + " (#" + std::to_string(device_id) + ") BLOCKS=" +
std::to_string(blocks) + ", THREADS=" + std::to_string(threadsperblock);
}


int cuda_tromp::getcount()
int SOLVER_NAME::getcount()
{
int device_count;
checkCudaErrors(cudaGetDeviceCount(&device_count));
return device_count;
}

void cuda_tromp::getinfo(int platf_id, int d_id, std::string& gpu_name, int& sm_count, std::string& version)
void SOLVER_NAME::getinfo(int platf_id, int d_id, std::string& gpu_name, int& sm_count, std::string& version)
{
//int runtime_version;
//checkCudaErrors(cudaRuntimeGetVersion(&runtime_version));
Expand All @@ -50,27 +50,27 @@ void cuda_tromp::getinfo(int platf_id, int d_id, std::string& gpu_name, int& sm_
}


void cuda_tromp::start(cuda_tromp& device_context)
void SOLVER_NAME::start(SOLVER_NAME& device_context)
{
device_context.context = new eq_cuda_context(device_context.threadsperblock,
device_context.blocks,
device_context.device_id);
}

void cuda_tromp::stop(cuda_tromp& device_context)
void SOLVER_NAME::stop(SOLVER_NAME& device_context)
{
if (device_context.context)
delete device_context.context;
}

void cuda_tromp::solve(const char *tequihash_header,
void SOLVER_NAME::solve(const char *tequihash_header,
unsigned int tequihash_header_len,
const char* nonce,
unsigned int nonce_len,
std::function<bool()> cancelf,
std::function<void(const std::vector<uint32_t>&, size_t, const unsigned char*)> solutionf,
std::function<void(void)> hashdonef,
cuda_tromp& device_context)
SOLVER_NAME& device_context)
{
device_context.context->solve(tequihash_header,
tequihash_header_len,
Expand Down
60 changes: 54 additions & 6 deletions cuda_tromp/cuda_tromp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,32 @@
#define DLL_CUDA_TROMP
#endif

#ifdef CUDA_75
#define SOLVER_NAME cuda_tromp_75
#else
#define SOLVER_NAME cuda_tromp
#endif

struct eq_cuda_context;

struct DLL_CUDA_TROMP cuda_tromp
struct DLL_CUDA_TROMP SOLVER_NAME
{
int threadsperblock;
int blocks;
int device_id;
eq_cuda_context* context;

cuda_tromp(int platf_id, int dev_id);
SOLVER_NAME(int platf_id, int dev_id);

std::string getdevinfo();

static int getcount();

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

static void start(cuda_tromp& device_context);
static void start(SOLVER_NAME& device_context);

static void stop(cuda_tromp& device_context);
static void stop(SOLVER_NAME& device_context);

static void solve(const char *tequihash_header,
unsigned int tequihash_header_len,
Expand All @@ -32,12 +38,54 @@ struct DLL_CUDA_TROMP cuda_tromp
std::function<bool()> cancelf,
std::function<void(const std::vector<uint32_t>&, size_t, const unsigned char*)> solutionf,
std::function<void(void)> hashdonef,
cuda_tromp& device_context);
SOLVER_NAME& device_context);

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

private:
std::string m_gpu_name;
std::string m_version;
int m_sm_count;
};
};

#ifndef _LIB
#undef SOLVER_NAME
#define SOLVER_NAME cuda_tromp_75

struct DLL_CUDA_TROMP SOLVER_NAME
{
int threadsperblock;
int blocks;
int device_id;
eq_cuda_context* context;

SOLVER_NAME(int platf_id, int dev_id);

std::string getdevinfo();

static int getcount();

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

static void start(SOLVER_NAME& device_context);

static void stop(SOLVER_NAME& device_context);

static void solve(const char *tequihash_header,
unsigned int tequihash_header_len,
const char* nonce,
unsigned int nonce_len,
std::function<bool()> cancelf,
std::function<void(const std::vector<uint32_t>&, size_t, const unsigned char*)> solutionf,
std::function<void(void)> hashdonef,
SOLVER_NAME& device_context);

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

private:
std::string m_gpu_name;
std::string m_version;
int m_sm_count;
};

#endif
50 changes: 49 additions & 1 deletion cuda_tromp/cuda_tromp.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release7.5|x64">
<Configuration>Release7.5</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
Expand All @@ -26,6 +30,7 @@
<PropertyGroup Label="Globals">
<ProjectGuid>{33C2B469-F025-4223-B9B6-E69D42FEA7D6}</ProjectGuid>
<RootNamespace>cuda_tromp</RootNamespace>
<CudaToolkitCustomDir>$(CUDA_PATH_V7_5)</CudaToolkitCustomDir>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
Expand All @@ -41,6 +46,13 @@
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v120</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release7.5|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v120</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
<Import Project="$(VCTargetsPath)\BuildCustomizations\CUDA 8.0.props" />
Expand All @@ -51,10 +63,18 @@
<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>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release7.5|x64'" Label="PropertySheets">
<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>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release7.5|x64'">
<TargetName>$(ProjectName)_75</TargetName>
<OutDir>$(SolutionDir)$(Platform)\Release\</OutDir>
<IntDir>$(Platform)\Release\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
Expand Down Expand Up @@ -105,7 +125,35 @@ copy "$(CudaToolkitBinDir)\cudart*.dll" "$(OutDir)"</Command>
</PostBuildEvent>
<CudaCompile>
<TargetMachinePlatform>64</TargetMachinePlatform>
<CodeGeneration>compute_50,sm_50</CodeGeneration>
<CodeGeneration>compute_61,sm_61;compute_52,sm_52;compute_50,sm_50;compute_35,sm_35;compute_30,sm_30;</CodeGeneration>
<PtxAsOptionV>true</PtxAsOptionV>
</CudaCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release7.5|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;WIN64;NDEBUG;_CONSOLE;_LIB;CUDA_75;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<DisableSpecificWarnings>4334;4316;4244;4996;4251;</DisableSpecificWarnings>
<AdditionalIncludeDirectories>..\3rdparty\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<SubSystem>Console</SubSystem>
<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>
</Link>
<PostBuildEvent>
<Command>echo copy "$(CudaToolkitBinDir)\cudart*.dll" "$(OutDir)"
copy "$(CudaToolkitBinDir)\cudart*.dll" "$(OutDir)"</Command>
</PostBuildEvent>
<CudaCompile>
<TargetMachinePlatform>64</TargetMachinePlatform>
<CodeGeneration>compute_52,sm_52;compute_50,sm_50;compute_35,sm_35;compute_30,sm_30;compute_20,sm_21;</CodeGeneration>
<PtxAsOptionV>true</PtxAsOptionV>
</CudaCompile>
</ItemDefinitionGroup>
Expand Down
6 changes: 4 additions & 2 deletions nheqminer/libstratum/StratumClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,8 @@ bool StratumClient<Miner, Job, Solution>::submit(const Solution* solution, const
return true;
}

template class StratumClient<ZMinerAVX, ZcashJob, EquihashSolution>;
template class StratumClient<ZMinerSSE2, ZcashJob, EquihashSolution>;
template class StratumClient<ZMinerAVXCUDA80, ZcashJob, EquihashSolution>;
template class StratumClient<ZMinerSSE2CUDA80, ZcashJob, EquihashSolution>;
template class StratumClient<ZMinerAVXCUDA75, ZcashJob, EquihashSolution>;
template class StratumClient<ZMinerSSE2CUDA75, ZcashJob, EquihashSolution>;

6 changes: 4 additions & 2 deletions nheqminer/libstratum/StratumClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ class StratumClient
};


typedef StratumClient<ZMinerAVX, ZcashJob, EquihashSolution> ZcashStratumClientAVX;
typedef StratumClient<ZMinerSSE2, ZcashJob, EquihashSolution> ZcashStratumClientSSE2;
typedef StratumClient<ZMinerAVXCUDA80, ZcashJob, EquihashSolution> ZcashStratumClientAVXCUDA80;
typedef StratumClient<ZMinerSSE2CUDA80, ZcashJob, EquihashSolution> ZcashStratumClientSSE2CUDA80;
typedef StratumClient<ZMinerAVXCUDA75, ZcashJob, EquihashSolution> ZcashStratumClientAVXCUDA75;
typedef StratumClient<ZMinerSSE2CUDA75, ZcashJob, EquihashSolution> ZcashStratumClientSSE2CUDA75;

20 changes: 11 additions & 9 deletions nheqminer/libstratum/ZcashStratum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,8 @@ void ZcashMiner<CPUSolver, CUDASolver, OPENCLSolver>::failedSolution()

template class ZcashMiner<cpu_xenoncat, cuda_tromp, ocl_xmp>;
template class ZcashMiner<cpu_tromp, cuda_tromp, ocl_xmp>;
template class ZcashMiner<cpu_xenoncat, cuda_tromp_75, ocl_xmp>;
template class ZcashMiner<cpu_tromp, cuda_tromp_75, ocl_xmp>;

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


void ZMinerAVX_doBenchmark(int hashes, int cpu_threads, int cuda_count, int* cuda_en, int* cuda_b, int* cuda_t,
int opencl_count, int opencl_platf, int* opencl_en) {
ZMinerAVX::doBenchmark(hashes, cpu_threads, cuda_count, cuda_en, cuda_b, cuda_t, opencl_count, opencl_platf, opencl_en);
}

void ZMinerSSE2_doBenchmark(int hashes, int cpu_threads, int cuda_count, int* cuda_en, int* cuda_b, int* cuda_t,
int opencl_count, int opencl_platf, int* opencl_en) {
ZMinerSSE2::doBenchmark(hashes, cpu_threads, cuda_count, cuda_en, cuda_b, cuda_t, opencl_count, opencl_platf, opencl_en);
}
//void ZMinerAVX_doBenchmark(int hashes, int cpu_threads, int cuda_count, int* cuda_en, int* cuda_b, int* cuda_t,
// int opencl_count, int opencl_platf, int* opencl_en) {
// ZMinerAVX::doBenchmark(hashes, cpu_threads, cuda_count, cuda_en, cuda_b, cuda_t, opencl_count, opencl_platf, opencl_en);
//}
//
//void ZMinerSSE2_doBenchmark(int hashes, int cpu_threads, int cuda_count, int* cuda_en, int* cuda_b, int* cuda_t,
// int opencl_count, int opencl_platf, int* opencl_en) {
// ZMinerSSE2::doBenchmark(hashes, cpu_threads, cuda_count, cuda_en, cuda_b, cuda_t, opencl_count, opencl_platf, opencl_en);
//}
6 changes: 4 additions & 2 deletions nheqminer/libstratum/ZcashStratum.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,10 @@ class ZcashMiner
int opencl_count, int opencl_platf, int* opencl_en);
};

typedef ZcashMiner<cpu_xenoncat, cuda_tromp, ocl_xmp> ZMinerAVX;
typedef ZcashMiner<cpu_tromp, cuda_tromp, ocl_xmp> ZMinerSSE2;
typedef ZcashMiner<cpu_xenoncat, cuda_tromp, ocl_xmp> ZMinerAVXCUDA80;
typedef ZcashMiner<cpu_tromp, cuda_tromp, ocl_xmp> ZMinerSSE2CUDA80;
typedef ZcashMiner<cpu_xenoncat, cuda_tromp_75, ocl_xmp> ZMinerAVXCUDA75;
typedef ZcashMiner<cpu_tromp, cuda_tromp_75, ocl_xmp> ZMinerSSE2CUDA75;

// gcc static undefined reference workaround
void ZMinerAVX_doBenchmark(int hashes, int cpu_threads, int cuda_count, int* cuda_en, int* cuda_b, int* cuda_t,
Expand Down
Loading

0 comments on commit 32d6b6a

Please sign in to comment.