fix various memory leaks on algo switch

This commit is contained in:
Tanguy Pruvot 2017-03-11 11:19:20 +01:00
parent 0041bf47f1
commit 61231bc66c
5 changed files with 21 additions and 5 deletions

View File

@ -8,6 +8,7 @@
#include "miner.h"
#include "algos.h"
#include <cuda_runtime.h>
int bench_algo = -1;
@ -114,6 +115,13 @@ bool bench_algo_switch_next(int thr_id)
if (algo == ALGO_MJOLLNIR) algo++; // same as heavy
if (algo == ALGO_WHIRLCOIN) algo++; // same as whirlpool
if (algo == ALGO_WHIRLPOOLX) algo++; // disabled
// todo: algo switch from RPC 2.0
if (algo == ALGO_CRYPTOLIGHT) algo++;
if (algo == ALGO_CRYPTONIGHT) algo++;
if (algo == ALGO_WILDKECCAK) algo++;
if (algo == ALGO_JACKPOT) algo++; // to fix
if (algo == ALGO_QUARK) algo++; // to fix
if (algo == ALGO_LBRY && CUDART_VERSION < 7000) algo++;
if (device_sm[dev_id] && device_sm[dev_id] < 300) {
// incompatible SM 2.1 kernels...

View File

@ -890,6 +890,13 @@ void lyra2Z_cpu_init_sm2(int thr_id, uint32_t threads)
cudaMallocHost(&h_GNonces[thr_id], 2 * sizeof(uint32_t));
}
__host__
void lyra2Z_cpu_free(int thr_id)
{
cudaFree(d_GNonces[thr_id]);
cudaFreeHost(h_GNonces[thr_id]);
}
__host__
uint32_t lyra2Z_getSecNonce(int thr_id, int num)
{

View File

@ -15,6 +15,7 @@ extern void blake256_cpu_setBlock_80(uint32_t *pdata);
extern void lyra2Z_cpu_init(int thr_id, uint32_t threads, uint64_t *d_matrix);
extern void lyra2Z_cpu_init_sm2(int thr_id, uint32_t threads);
extern void lyra2Z_cpu_free(int thr_id);
extern uint32_t lyra2Z_cpu_hash_32(int thr_id, uint32_t threads, uint32_t startNonce, uint64_t *d_outputHash, bool gtx750ti);
extern void lyra2Z_setTarget(const void *ptarget);
@ -158,6 +159,8 @@ extern "C" void free_lyra2Z(int thr_id)
cudaFree(d_hash[thr_id]);
if (device_sm[dev_id] >= 350)
cudaFree(d_matrix[thr_id]);
lyra2Z_cpu_free(thr_id);
init[thr_id] = false;
cudaDeviceSynchronize();

View File

@ -174,8 +174,8 @@ extern "C" void free_veltor(int thr_id)
cudaThreadSynchronize();
cudaFree(d_hash[thr_id]);
cudaFree(d_resNonce[thr_id]);
cuda_check_cpu_free(thr_id);
init[thr_id] = false;
cudaDeviceSynchronize();

View File

@ -320,10 +320,8 @@ void whirlpool512_setBlock_80(void *pdata, const void *ptarget)
__host__
extern void x15_whirlpool_cpu_free(int thr_id)
{
cudaFree(InitVector_RC);
cudaFree(b0);
cudaFree(b7);
cudaFree(d_resNonce[thr_id]);
if (d_resNonce[thr_id])
cudaFree(d_resNonce[thr_id]);
}
__global__