Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
monkins1010 authored Oct 13, 2018
1 parent 1fed8aa commit 3aaa57b
Showing 1 changed file with 12 additions and 87 deletions.
99 changes: 12 additions & 87 deletions bench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

#include "miner.h"
#include "algos.h"
#include <cuda_runtime.h>

#ifdef __APPLE__
#include "compat/pthreads/pthread_barrier.hpp"
Expand All @@ -34,9 +33,7 @@ void bench_init(int threads)
pthread_barrier_init(&miner_barr, NULL, threads);
pthread_barrier_init(&algo_barr, NULL, threads);
// required for usage of first algo.
for (int n=0; n < opt_n_threads; n++) {
device_mem_free[n] = cuda_available_memory(n);
}

}

void bench_free()
Expand All @@ -49,72 +46,9 @@ void bench_free()
void algo_free_all(int thr_id)
{
// only initialized algos will be freed
free_allium(thr_id);
free_bastion(thr_id);
free_bitcore(thr_id);
free_blake256(thr_id);
free_blake2s(thr_id);
free_bmw(thr_id);
free_c11(thr_id);
free_cryptolight(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);
free_groestlcoin(thr_id);
#ifdef WITH_HEAVY_ALGO
free_heavy(thr_id);
#endif
free_hmq17(thr_id);
free_hsr(thr_id);
free_jackpot(thr_id);
free_jha(thr_id);
free_lbry(thr_id);
free_luffa(thr_id);
free_lyra2(thr_id);
free_lyra2v2(thr_id);
free_lyra2Z(thr_id);
free_myriad(thr_id);
free_neoscrypt(thr_id);
free_nist5(thr_id);
free_pentablake(thr_id);
free_phi(thr_id);
free_phi2(thr_id);
free_polytimos(thr_id);
free_quark(thr_id);
free_qubit(thr_id);
free_skeincoin(thr_id);
free_skein2(thr_id);
free_skunk(thr_id);
free_sha256d(thr_id);
free_sha256t(thr_id);
free_sia(thr_id);
free_sib(thr_id);
free_sonoa(thr_id);
free_s3(thr_id);
free_vanilla(thr_id);
free_veltor(thr_id);
free_whirl(thr_id);
//free_whirlx(thr_id);
free_wildkeccak(thr_id);
free_x11evo(thr_id);
free_x11(thr_id);
free_x12(thr_id);
free_x13(thr_id);
free_x14(thr_id);
free_x15(thr_id);
free_x16r(thr_id);
free_x16s(thr_id);
free_x17(thr_id);
free_zr5(thr_id);
free_scrypt(thr_id);
free_scrypt_jane(thr_id);
free_timetravel(thr_id);
free_tribus(thr_id);
free_bitcore(thr_id);



}

// benchmark all algos (called once per mining thread)
Expand Down Expand Up @@ -143,7 +77,7 @@ bool bench_algo_switch_next(int thr_id)
if (algo == ALGO_CRYPTONIGHT) algo++;
if (algo == ALGO_WILDKECCAK) algo++;
if (algo == ALGO_QUARK) algo++; // to fix
if (algo == ALGO_LBRY && CUDART_VERSION < 7000) algo++;
if (algo == ALGO_LBRY ) algo++;

if (device_sm[dev_id] && device_sm[dev_id] < 300) {
// incompatible SM 2.1 kernels...
Expand All @@ -157,15 +91,15 @@ bool bench_algo_switch_next(int thr_id)
if (algo == ALGO_SCRYPT_JANE) algo++;

// free current algo memory and track mem usage
mused = cuda_available_memory(thr_id);
mused = 10;
algo_free_all(thr_id);
CUDA_LOG_ERROR();


// device can take some time to free
mfree = cuda_available_memory(thr_id);
mfree = 10;
if (device_mem_free[thr_id] > mfree) {
sleep(1);
mfree = cuda_available_memory(thr_id);
mfree = 10;
}

// we need to wait completion on all cards before the switch
Expand All @@ -179,18 +113,10 @@ bool bench_algo_switch_next(int thr_id)
gpulog(LOG_NOTICE, thr_id, "%s hashrate = %s", algo_names[prev_algo], rate);

// ensure memory leak is still real after the barrier
if (device_mem_free[thr_id] > mfree) {
mfree = cuda_available_memory(thr_id);
}


// check if there is memory leak
if (device_mem_free[thr_id] - mfree > 1) {
gpulog(LOG_WARNING, thr_id, "possible %d MB memory leak in %s! %d MB free",
(device_mem_free[thr_id] - mfree), algo_names[prev_algo], mfree);
cuda_reset_device(thr_id, NULL); // force to free the leak
need_reset = false;
mfree = cuda_available_memory(thr_id);
}

// store used memory per algo
algo_mem_used[thr_id][opt_algo] = device_mem_free[thr_id] - mused;
device_mem_free[thr_id] = mfree;
Expand All @@ -215,8 +141,7 @@ bool bench_algo_switch_next(int thr_id)
thr_hashrates[thr_id] = 0; // reset for minmax64
pthread_mutex_unlock(&bench_lock);

if (need_reset)
cuda_reset_device(thr_id, NULL);


if (thr_id == 0)
applog(LOG_BLUE, "Benchmark algo %s...", algo_names[algo]);
Expand Down

0 comments on commit 3aaa57b

Please sign in to comment.