Browse Source

Change the code according to Chafast's suggestions in pull request #18. 1) change if..else if..else if to switch. 2)change spaces to tab. 3) add additioanl arg check. 4) delete commented out code. 5) throw any exception to avoid code duplication.

cl-refactor
davilizh 8 years ago
parent
commit
41c8e69a8f
  1. 7
      ethminer/MinerAux.h
  2. 2
      libethash-cuda/dagger_shuffled.cuh
  3. 34
      libethash-cuda/ethash_cuda_miner_kernel.cu
  4. 2
      libethash-cuda/ethash_cuda_miner_kernel.h

7
ethminer/MinerAux.h

@ -309,14 +309,13 @@ public:
}
}
}
else if (arg == "--cuda-parallel-hash")
else if (arg == "--cuda-parallel-hash" && i + 1 < argc)
{
try {
m_parallelHash = stol(argv[++i]);
if(m_parallelHash == 0 || m_parallelHash>8)
if (m_parallelHash == 0 || m_parallelHash > 8)
{
cerr << "Bad " << arg << " option: " << argv[i] << endl;
BOOST_THROW_EXCEPTION(BadArgument());
throw BadArgument();
}
}
catch (...)

2
libethash-cuda/dagger_shuffled.cuh

@ -2,8 +2,6 @@
#include "ethash_cuda_miner_kernel.h"
#include "cuda_helper.h"
//#define PARALLEL_HASH 4
template <uint32_t _PARALLEL_HASH>
__device__ __forceinline__ uint64_t compute_hash(
uint64_t nonce

34
libethash-cuda/ethash_cuda_miner_kernel.cu

@ -42,29 +42,21 @@ void run_ethash_search(
cudaStream_t stream,
volatile uint32_t* g_output,
uint64_t start_nonce,
uint32_t parallelHash
uint32_t parallelHash
)
{
//printf("parallelHash = %d\n", parallelHash);
if(parallelHash == 1)
ethash_search <1> <<<blocks, threads, sharedbytes, stream >>>(g_output, start_nonce);
else if(parallelHash == 2)
ethash_search <2> <<<blocks, threads, sharedbytes, stream >>>(g_output, start_nonce);
else if(parallelHash == 3)
ethash_search <3> <<<blocks, threads, sharedbytes, stream >>>(g_output, start_nonce);
else if(parallelHash == 4)
ethash_search <4> <<<blocks, threads, sharedbytes, stream >>>(g_output, start_nonce);
else if(parallelHash == 5)
ethash_search <5> <<<blocks, threads, sharedbytes, stream >>>(g_output, start_nonce);
else if(parallelHash == 6)
ethash_search <6> <<<blocks, threads, sharedbytes, stream >>>(g_output, start_nonce);
else if(parallelHash == 7)
ethash_search <7> <<<blocks, threads, sharedbytes, stream >>>(g_output, start_nonce);
else if(parallelHash == 8)
ethash_search <8> <<<blocks, threads, sharedbytes, stream >>>(g_output, start_nonce);
else
ethash_search <1> <<<blocks, threads, sharedbytes, stream >>>(g_output, start_nonce);
switch (parallelHash)
{
case 1: ethash_search <1> <<<blocks, threads, sharedbytes, stream >>>(g_output, start_nonce); break;
case 2: ethash_search <2> <<<blocks, threads, sharedbytes, stream >>>(g_output, start_nonce); break;
case 3: ethash_search <3> <<<blocks, threads, sharedbytes, stream >>>(g_output, start_nonce); break;
case 4: ethash_search <4> <<<blocks, threads, sharedbytes, stream >>>(g_output, start_nonce); break;
case 5: ethash_search <5> <<<blocks, threads, sharedbytes, stream >>>(g_output, start_nonce); break;
case 6: ethash_search <6> <<<blocks, threads, sharedbytes, stream >>>(g_output, start_nonce); break;
case 7: ethash_search <7> <<<blocks, threads, sharedbytes, stream >>>(g_output, start_nonce); break;
case 8: ethash_search <8> <<<blocks, threads, sharedbytes, stream >>>(g_output, start_nonce); break;
default: ethash_search <4> <<<blocks, threads, sharedbytes, stream >>>(g_output, start_nonce); break;
}
CUDA_SAFE_CALL(cudaGetLastError());
}

2
libethash-cuda/ethash_cuda_miner_kernel.h

@ -53,7 +53,7 @@ void run_ethash_search(
cudaStream_t stream,
volatile uint32_t* g_output,
uint64_t start_nonce,
uint32_t parallelHash
uint32_t parallelHash
);
void ethash_generate_dag(

Loading…
Cancel
Save