Skip to content

Commit

Permalink
equihash: missing free on benchs
Browse files Browse the repository at this point in the history
  • Loading branch information
tpruvot committed Oct 9, 2017
1 parent e505d10 commit cf18cb6
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 5 deletions.
3 changes: 3 additions & 0 deletions JHA/jha.cu
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ extern "C" int scanhash_jha(int thr_id, struct work *work, uint32_t max_nonce, u
CUDA_LOG_ERROR();
}
cuda_get_arch(thr_id);
if (cuda_arch[dev_id] >= 500) {
applog(LOG_WARNING, "You are not using the optimal algo, please try -a jackpot");
}
gpulog(LOG_INFO, thr_id, "Intensity set to %g, %u cuda threads", throughput2intensity(throughput), throughput);

CUDA_SAFE_CALL(cudaMalloc(&d_hash[thr_id], (size_t) 64 * throughput));
Expand Down
1 change: 1 addition & 0 deletions bench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ void algo_free_all(int thr_id)
free_cryptonight(thr_id);
free_decred(thr_id);
free_deep(thr_id);
free_equihash(thr_id);
free_keccak256(thr_id);
free_fresh(thr_id);
free_fugue256(thr_id);
Expand Down
8 changes: 7 additions & 1 deletion equi/cuda_equi.cu
Original file line number Diff line number Diff line change
Expand Up @@ -2081,7 +2081,7 @@ __host__ void eq_cuda_context<RB, SM, SSM, THREADS, PACKER>::solve(const char *t
// destructor
template <u32 RB, u32 SM, u32 SSM, u32 THREADS, typename PACKER>
__host__
eq_cuda_context<RB, SM, SSM, THREADS, PACKER>::~eq_cuda_context()
void eq_cuda_context<RB, SM, SSM, THREADS, PACKER>::freemem()
{
if (solutions)
free(solutions);
Expand All @@ -2104,6 +2104,12 @@ eq_cuda_context<RB, SM, SSM, THREADS, PACKER>::~eq_cuda_context()
}
}

template <u32 RB, u32 SM, u32 SSM, u32 THREADS, typename PACKER>
__host__
eq_cuda_context<RB, SM, SSM, THREADS, PACKER>::~eq_cuda_context()
{
freemem();
}

#ifdef CONFIG_MODE_1
template class eq_cuda_context<CONFIG_MODE_1>;
Expand Down
5 changes: 3 additions & 2 deletions equi/eqcuda.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ template <u32 RB, u32 SM> struct equi;

struct eq_cuda_context_interface
{
virtual ~eq_cuda_context_interface();
//virtual ~eq_cuda_context_interface();

virtual void solve(const char *tequihash_header,
unsigned int tequihash_header_len,
Expand All @@ -99,6 +99,7 @@ struct eq_cuda_context_interface
fn_cancel cancelf,
fn_solution solutionf,
fn_hashdone hashdonef);

public:
int thread_id;
int device_id;
Expand All @@ -125,9 +126,9 @@ class eq_cuda_context : public eq_cuda_context_interface
fn_cancel cancelf,
fn_solution solutionf,
fn_hashdone hashdonef);

public:
eq_cuda_context(int thr_id, int dev_id);
void freemem();
~eq_cuda_context();
};

Expand Down
7 changes: 5 additions & 2 deletions equi/equihash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,11 @@ void free_equihash(int thr_id)
if (!init[thr_id])
return;

delete(solvers[thr_id]);
// assume config 1 was used... interface destructor seems bad
eq_cuda_context<CONFIG_MODE_1>* ptr = dynamic_cast<eq_cuda_context<CONFIG_MODE_1>*>(solvers[thr_id]);
ptr->freemem();
ptr = NULL;

solvers[thr_id] = NULL;

init[thr_id] = false;
Expand All @@ -291,4 +295,3 @@ void free_equihash(int thr_id)
void eq_cuda_context_interface::solve(const char *tequihash_header, unsigned int tequihash_header_len,
const char* nonce, unsigned int nonce_len,
fn_cancel cancelf, fn_solution solutionf, fn_hashdone hashdonef) { }
eq_cuda_context_interface::~eq_cuda_context_interface() { }

0 comments on commit cf18cb6

Please sign in to comment.