From 2c2269dcb64cf21ddc698d67a26722a3078cd0a2 Mon Sep 17 00:00:00 2001 From: Tanguy Pruvot Date: Mon, 9 Mar 2015 02:49:11 +0100 Subject: [PATCH] cputest: cleanup + calloc --- pluck/pluck.cu | 3 ++- util.cpp | 44 +++++++++++--------------------------------- 2 files changed, 13 insertions(+), 34 deletions(-) diff --git a/pluck/pluck.cu b/pluck/pluck.cu index a1e7ff0..627a5a1 100644 --- a/pluck/pluck.cu +++ b/pluck/pluck.cu @@ -181,7 +181,8 @@ extern "C" int scanhash_pluck(int thr_id, uint32_t *pdata, const uint32_t *ptarg const uint32_t first_nonce = pdata[19]; uint32_t endiandata[20]; int opt_pluck_n = 128; - int intensity = 18; /* beware > 20 could work and create diff problems later */ + + int intensity = is_windows() ? 17 : 19; /* beware > 20 could work and create diff problems later */ uint32_t throughput = device_intensity(thr_id, __func__, 1U << intensity); // divide by 128 for this algo which require a lot of memory throughput = throughput / 128 - 256; diff --git a/util.cpp b/util.cpp index 30200e3..eeef404 100644 --- a/util.cpp +++ b/util.cpp @@ -1238,6 +1238,7 @@ static bool stratum_notify(struct stratum_ctx *sctx, json_t *params) int merkle_count, i; json_t *merkle_arr; uchar **merkle; + uchar(*merkle_tree)[32] = NULL; int ntime; job_id = json_string_value(json_array_get(params, 0)); @@ -1643,10 +1644,10 @@ extern void applog_hash(uchar *hash) applog(LOG_DEBUG, "%s", format_hash(s, hash)); } -#define printpfx(n,h) \ - printf("%s%12s%s: %s\n", CL_BLU, n, CL_N, format_hash(s, h)) +static uchar *scratchbuf = NULL; -static uchar scratchbuf[128 * 1024]; +#define printpfx(n,h) \ + printf("%s%11s%s: %s\n", CL_BLU, n, CL_N, format_hash(s, h)) void do_gpu_tests(void) { @@ -1681,115 +1682,92 @@ void print_hash_tests(void) { char s[128] = {'\0'}; uchar hash[128]; - uchar* buf = scratchbuf; + uchar* buf; + + // work space for scratchpad based algos + scratchbuf = (uchar*)calloc(128, 1024); + buf = &scratchbuf[0]; + // memset(buf, 0, sizeof scratchbuf); calloc fills zeros - //scratchbuf = (uchar*)malloc(1, 128*1024); - memset(buf, 0, sizeof scratchbuf); // buf[0] = 1; buf[64] = 2; // for endian tests printf(CL_WHT "CPU HASH ON EMPTY BUFFER RESULTS:" CL_N "\n"); - memset(hash, 0, sizeof hash); animehash(&hash[0], &buf[0]); printpfx("anime", hash); - memset(hash, 0, sizeof hash); blake256hash(&hash[0], &buf[0], 8); printpfx("blakecoin", hash); - memset(hash, 0, sizeof hash); blake256hash(&hash[0], &buf[0], 14); printpfx("blake", hash); - memset(hash, 0, sizeof hash); deephash(&hash[0], &buf[0]); printpfx("deep", hash); - memset(hash, 0, sizeof hash); fresh_hash(&hash[0], &buf[0]); printpfx("fresh", hash); - memset(hash, 0, sizeof hash); fugue256_hash(&hash[0], &buf[0], 32); printpfx("fugue256", hash); - memset(hash, 0, sizeof hash); groestlhash(&hash[0], &buf[0]); printpfx("groestl", hash); - memset(hash, 0, sizeof hash); heavycoin_hash(&hash[0], &buf[0], 32); printpfx("heavy", hash); - memset(hash, 0, sizeof hash); jackpothash(&hash[0], &buf[0]); printpfx("jackpot", hash); - memset(hash, 0, sizeof hash); keccak256_hash(&hash[0], &buf[0]); printpfx("keccak", hash); - memset(hash, 0, sizeof hash); doomhash(&hash[0], &buf[0]); printpfx("luffa", hash); - memset(hash, 0, sizeof hash); lyra2_hash(&hash[0], &buf[0]); printpfx("lyra2", hash); - memset(hash, 0, sizeof hash); myriadhash(&hash[0], &buf[0]); printpfx("myriad", hash); - memset(hash, 0, sizeof hash); nist5hash(&hash[0], &buf[0]); printpfx("nist5", hash); - memset(hash, 0, sizeof hash); pentablakehash(&hash[0], &buf[0]); printpfx("pentablake", hash); - memset(hash, 0, sizeof hash); pluckhash((uint32_t*)&hash[0], (uint32_t*)&buf[0], &buf[0], 128); printpfx("pluck", hash); - memset(hash, 0, sizeof hash); quarkhash(&hash[0], &buf[0]); printpfx("quark", hash); - memset(hash, 0, sizeof hash); qubithash(&hash[0], &buf[0]); printpfx("qubit", hash); - memset(hash, 0, sizeof hash); s3hash(&hash[0], &buf[0]); printpfx("S3", hash); - memset(hash, 0, sizeof hash); wcoinhash(&hash[0], &buf[0]); printpfx("whirl", hash); - memset(hash, 0, sizeof hash); whirlxHash(&hash[0], &buf[0]); printpfx("whirlpoolx", hash); - memset(hash, 0, sizeof hash); x11hash(&hash[0], &buf[0]); printpfx("X11", hash); - memset(hash, 0, sizeof hash); x13hash(&hash[0], &buf[0]); printpfx("X13", hash); - memset(hash, 0, sizeof hash); x14hash(&hash[0], &buf[0]); printpfx("X14", hash); - memset(hash, 0, sizeof hash); x15hash(&hash[0], &buf[0]); printpfx("X15", hash); - memset(hash, 0, sizeof hash); x17hash(&hash[0], &buf[0]); printpfx("X17", hash); @@ -1797,5 +1775,5 @@ void print_hash_tests(void) do_gpu_tests(); - //free(scratchbuf); + free(scratchbuf); }