Browse Source

fix various memory leaks on algo switch

2upstream
Tanguy Pruvot 7 years ago
parent
commit
61231bc66c
  1. 8
      bench.cpp
  2. 7
      lyra2/cuda_lyra2Z.cu
  3. 3
      lyra2/lyra2Z.cu
  4. 2
      x11/veltor.cu
  5. 6
      x15/cuda_x15_whirlpool.cu

8
bench.cpp

@ -8,6 +8,7 @@ @@ -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) @@ -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...

7
lyra2/cuda_lyra2Z.cu

@ -890,6 +890,13 @@ void lyra2Z_cpu_init_sm2(int thr_id, uint32_t threads) @@ -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)
{

3
lyra2/lyra2Z.cu

@ -15,6 +15,7 @@ extern void blake256_cpu_setBlock_80(uint32_t *pdata); @@ -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) @@ -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();

2
x11/veltor.cu

@ -174,8 +174,8 @@ extern "C" void free_veltor(int thr_id) @@ -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();

6
x15/cuda_x15_whirlpool.cu

@ -320,10 +320,8 @@ void whirlpool512_setBlock_80(void *pdata, const void *ptarget) @@ -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__

Loading…
Cancel
Save