From d9b03128978e9ac29e2a5a6d000e1fa9a27957fe Mon Sep 17 00:00:00 2001 From: Tanguy Pruvot Date: Sun, 17 May 2015 04:56:42 +0200 Subject: [PATCH] x64: fix some size_t warnings --- JHA/cuda_jha_compactionTest.cu | 41 ++++++++++++++++++------------ JHA/jackpotcoin.cu | 6 ++--- api.cpp | 7 ++--- ccminer.vcxproj | 4 +-- hashlog.cpp | 6 ++--- quark/animecoin.cu | 8 +++--- quark/cuda_quark_compactionTest.cu | 12 ++++----- quark/quarkcoin.cu | 8 +++--- stats.cpp | 4 +-- util.cpp | 4 +-- 10 files changed, 55 insertions(+), 45 deletions(-) diff --git a/JHA/cuda_jha_compactionTest.cu b/JHA/cuda_jha_compactionTest.cu index b864a8a..a1d1ec3 100644 --- a/JHA/cuda_jha_compactionTest.cu +++ b/JHA/cuda_jha_compactionTest.cu @@ -4,6 +4,10 @@ #include "cuda_helper.h" #include +#ifdef __INTELLISENSE__ +#define __shfl_up(a,b) +#endif + static uint32_t *d_tempBranch1Nonces[MAX_GPUS]; static uint32_t *d_numValid[MAX_GPUS]; static uint32_t *h_numValid[MAX_GPUS]; @@ -56,7 +60,9 @@ __host__ void jackpot_compactTest_cpu_init(int thr_id, uint32_t threads) #endif // Die Summenfunktion (vom NVIDIA SDK) -__global__ void jackpot_compactTest_gpu_SCAN(uint32_t *data, int width, uint32_t *partial_sums=NULL, cuda_compactTestFunction_t testFunc=NULL, uint32_t threads=0, uint32_t startNounce=0, uint32_t *inpHashes=NULL, uint32_t *d_validNonceTable=NULL) +__global__ +void jackpot_compactTest_gpu_SCAN(uint32_t *data, int width, uint32_t *partial_sums=NULL, cuda_compactTestFunction_t testFunc=NULL, + uint32_t threads=0, uint32_t startNounce=0, uint32_t *inpHashes=NULL, uint32_t *d_validNonceTable=NULL) { extern __shared__ uint32_t sums[]; int id = ((blockIdx.x * blockDim.x) + threadIdx.x); @@ -168,7 +174,8 @@ __global__ void jackpot_compactTest_gpu_SCAN(uint32_t *data, int width, uint32_t } // Uniform add: add partial sums array -__global__ void jackpot_compactTest_gpu_ADD(uint32_t *data, uint32_t *partial_sums, int len) +__global__ +void jackpot_compactTest_gpu_ADD(uint32_t *data, uint32_t *partial_sums, int len) { __shared__ uint32_t buf; int id = ((blockIdx.x * blockDim.x) + threadIdx.x); @@ -185,7 +192,9 @@ __global__ void jackpot_compactTest_gpu_ADD(uint32_t *data, uint32_t *partial_su } // Der Scatter -__global__ void jackpot_compactTest_gpu_SCATTER(uint32_t *sum, uint32_t *outp, cuda_compactTestFunction_t testFunc, uint32_t threads=0, uint32_t startNounce=0, uint32_t *inpHashes=NULL, uint32_t *d_validNonceTable=NULL) +__global__ +void jackpot_compactTest_gpu_SCATTER(uint32_t *sum, uint32_t *outp, cuda_compactTestFunction_t testFunc, + uint32_t threads=0, uint32_t startNounce=0, uint32_t *inpHashes=NULL, uint32_t *d_validNonceTable=NULL) { int id = ((blockIdx.x * blockDim.x) + threadIdx.x); uint32_t actNounce = id; @@ -220,7 +229,8 @@ __global__ void jackpot_compactTest_gpu_SCATTER(uint32_t *sum, uint32_t *outp, c } } -__host__ static uint32_t jackpot_compactTest_roundUpExp(uint32_t val) +__host__ +static uint32_t jackpot_compactTest_roundUpExp(uint32_t val) { if(val == 0) return 0; @@ -234,9 +244,9 @@ __host__ static uint32_t jackpot_compactTest_roundUpExp(uint32_t val) return mask; } -__host__ void jackpot_compactTest_cpu_singleCompaction(int thr_id, uint32_t threads, uint32_t *nrm, - uint32_t *d_nonces1, cuda_compactTestFunction_t function, - uint32_t startNounce, uint32_t *inpHashes, uint32_t *d_validNonceTable) +__host__ +void jackpot_compactTest_cpu_singleCompaction(int thr_id, uint32_t threads, uint32_t *nrm, uint32_t *d_nonces1, + cuda_compactTestFunction_t function, uint32_t startNounce, uint32_t *inpHashes, uint32_t *d_validNonceTable) { int orgThreads = threads; threads = (int)jackpot_compactTest_roundUpExp((uint32_t)threads); @@ -290,9 +300,9 @@ __host__ void jackpot_compactTest_cpu_singleCompaction(int thr_id, uint32_t thre } ////// ACHTUNG: Diese funktion geht aktuell nur mit threads > 65536 (Am besten 256 * 1024 oder 256*2048) -__host__ void jackpot_compactTest_cpu_dualCompaction(int thr_id, uint32_t threads, uint32_t *nrm, - uint32_t *d_nonces1, uint32_t *d_nonces2, - uint32_t startNounce, uint32_t *inpHashes, uint32_t *d_validNonceTable) +__host__ +void jackpot_compactTest_cpu_dualCompaction(int thr_id, uint32_t threads, uint32_t *nrm, uint32_t *d_nonces1, + uint32_t *d_nonces2, uint32_t startNounce, uint32_t *inpHashes, uint32_t *d_validNonceTable) { jackpot_compactTest_cpu_singleCompaction(thr_id, threads, &nrm[0], d_nonces1, h_JackpotTrueFunction[thr_id], startNounce, inpHashes, d_validNonceTable); jackpot_compactTest_cpu_singleCompaction(thr_id, threads, &nrm[1], d_nonces2, h_JackpotFalseFunction[thr_id], startNounce, inpHashes, d_validNonceTable); @@ -329,10 +339,9 @@ __host__ void jackpot_compactTest_cpu_dualCompaction(int thr_id, uint32_t thread */ } -__host__ void jackpot_compactTest_cpu_hash_64(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *inpHashes, uint32_t *d_validNonceTable, - uint32_t *d_nonces1, size_t *nrm1, - uint32_t *d_nonces2, size_t *nrm2, - int order) +__host__ +void jackpot_compactTest_cpu_hash_64(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *inpHashes, uint32_t *d_validNonceTable, + uint32_t *d_nonces1, uint32_t *nrm1, uint32_t *d_nonces2, uint32_t *nrm2, int order) { // Wenn validNonceTable genutzt wird, dann werden auch nur die Nonces betrachtet, die dort enthalten sind // "threads" ist in diesem Fall auf die Länge dieses Array's zu setzen! @@ -342,6 +351,6 @@ __host__ void jackpot_compactTest_cpu_hash_64(int thr_id, uint32_t threads, uint startNounce, inpHashes, d_validNonceTable); cudaStreamSynchronize(NULL); // Das original braucht zwar etwas CPU-Last, ist an dieser Stelle aber evtl besser - *nrm1 = (size_t)h_numValid[thr_id][0]; - *nrm2 = (size_t)h_numValid[thr_id][1]; + *nrm1 = h_numValid[thr_id][0]; + *nrm2 = h_numValid[thr_id][1]; } diff --git a/JHA/jackpotcoin.cu b/JHA/jackpotcoin.cu index 1194c68..f58101e 100644 --- a/JHA/jackpotcoin.cu +++ b/JHA/jackpotcoin.cu @@ -30,8 +30,8 @@ extern void quark_skein512_cpu_hash_64(int thr_id, uint32_t threads, uint32_t st extern void jackpot_compactTest_cpu_init(int thr_id, uint32_t threads); extern void jackpot_compactTest_cpu_hash_64(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *inpHashes, uint32_t *d_validNonceTable, - uint32_t *d_nonces1, size_t *nrm1, - uint32_t *d_nonces2, size_t *nrm2, + uint32_t *d_nonces1, uint32_t *nrm1, + uint32_t *d_nonces2, uint32_t *nrm2, int order); extern uint32_t cuda_check_hash_branch(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *d_nonceVector, uint32_t *d_inputHash, int order); @@ -136,7 +136,7 @@ extern "C" int scanhash_jackpot(int thr_id, uint32_t *pdata, // erstes Keccak512 Hash mit CUDA jackpot_keccak512_cpu_hash(thr_id, throughput, pdata[19], d_hash[thr_id], order++); - size_t nrm1, nrm2, nrm3; + uint32_t nrm1, nrm2, nrm3; // Runde 1 (ohne Gröstl) diff --git a/api.cpp b/api.cpp index c0793ed..b8d704b 100644 --- a/api.cpp +++ b/api.cpp @@ -452,7 +452,7 @@ static int send_result(SOCKETTYPE c, char *result) n = send(c, "", 1, 0); } else { // ignore failure - it's closed immediately anyway - n = send(c, result, strlen(result) + 1, 0); + n = send(c, result, (int) strlen(result) + 1, 0); } return n; } @@ -595,7 +595,7 @@ static int websocket_handshake(SOCKETTYPE c, char *result, char *clientkey) // WebSocket Frame - Header + Data memcpy(p, hd, frames); memcpy(p + frames, result, (size_t)datalen); - send(c, (const char*)data, strlen(answer) + frames + (size_t)datalen + 1, 0); + send(c, (const char*)data, (int) (strlen(answer) + frames + datalen + 1), 0); free(data); } return 0; @@ -724,7 +724,7 @@ static void api() const char *addr = opt_api_allow; unsigned short port = (unsigned short) opt_api_listen; // 4068 char buf[MYBUFSIZ]; - int c, n, bound; + int n, bound; char *connectaddr; char *binderror; char group; @@ -738,6 +738,7 @@ static void api() char *params; int i; + SOCKETTYPE c; SOCKETTYPE *apisock; if (!opt_api_listen && opt_debug) { applog(LOG_DEBUG, "API disabled"); diff --git a/ccminer.vcxproj b/ccminer.vcxproj index ac178c8..28299cc 100644 --- a/ccminer.vcxproj +++ b/ccminer.vcxproj @@ -223,7 +223,7 @@ 80 true false - compute_50,sm_50;compute_52,sm_52 + compute_35,sm_35;compute_50,sm_50;compute_52,sm_52 64 @@ -539,4 +539,4 @@ - + \ No newline at end of file diff --git a/hashlog.cpp b/hashlog.cpp index d0c8dab..c30eb28 100644 --- a/hashlog.cpp +++ b/hashlog.cpp @@ -194,7 +194,7 @@ void hashlog_purge_job(char* jobid) int deleted = 0; uint64_t njobid = hextouint(jobid); uint64_t keypfx = (njobid << 32); - uint32_t sz = tlastshares.size(); + uint32_t sz = (uint32_t) tlastshares.size(); std::map::iterator i = tlastshares.begin(); while (i != tlastshares.end()) { if ((keypfx & i->first) == keypfx) { @@ -215,7 +215,7 @@ void hashlog_purge_old(void) { int deleted = 0; uint32_t now = (uint32_t) time(NULL); - uint32_t sz = tlastshares.size(); + uint32_t sz = (uint32_t) tlastshares.size(); std::map::iterator i = tlastshares.begin(); while (i != tlastshares.end()) { if ((now - i->second.tm_sent) > LOG_PURGE_TIMEOUT) { @@ -242,7 +242,7 @@ void hashlog_purge_all(void) */ void hashlog_getmeminfo(uint64_t *mem, uint32_t *records) { - (*records) = tlastshares.size(); + (*records) = (uint32_t) tlastshares.size(); (*mem) = (*records) * sizeof(hashlog_data); } diff --git a/quark/animecoin.cu b/quark/animecoin.cu index 8f432ee..203a0c9 100644 --- a/quark/animecoin.cu +++ b/quark/animecoin.cu @@ -40,11 +40,11 @@ extern void quark_jh512_cpu_hash_64(int thr_id, uint32_t threads, uint32_t start extern void quark_compactTest_cpu_init(int thr_id, uint32_t threads); extern void quark_compactTest_cpu_hash_64(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *inpHashes, uint32_t *d_validNonceTable, - uint32_t *d_nonces1, size_t *nrm1, - uint32_t *d_nonces2, size_t *nrm2, + uint32_t *d_nonces1, uint32_t *nrm1, + uint32_t *d_nonces2, uint32_t *nrm2, int order); extern void quark_compactTest_single_false_cpu_hash_64(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *inpHashes, uint32_t *d_validNonceTable, - uint32_t *d_nonces1, size_t *nrm1, + uint32_t *d_nonces1, uint32_t *nrm1, int order); extern uint32_t cuda_check_hash_branch(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *d_nonceVector, uint32_t *d_inputHash, int order); @@ -203,7 +203,7 @@ extern "C" int scanhash_anime(int thr_id, uint32_t *pdata, do { int order = 0; - size_t nrm1=0, nrm2=0, nrm3=0; + uint32_t nrm1=0, nrm2=0, nrm3=0; // erstes BMW512 Hash mit CUDA quark_bmw512_cpu_hash_80(thr_id, throughput, pdata[19], d_hash[thr_id], order++); diff --git a/quark/cuda_quark_compactionTest.cu b/quark/cuda_quark_compactionTest.cu index 183e08a..dc78c85 100644 --- a/quark/cuda_quark_compactionTest.cu +++ b/quark/cuda_quark_compactionTest.cu @@ -328,8 +328,8 @@ __host__ void quark_compactTest_cpu_dualCompaction(int thr_id, uint32_t threads, } __host__ void quark_compactTest_cpu_hash_64(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *inpHashes, uint32_t *d_validNonceTable, - uint32_t *d_nonces1, size_t *nrm1, - uint32_t *d_nonces2, size_t *nrm2, + uint32_t *d_nonces1, uint32_t *nrm1, + uint32_t *d_nonces2, uint32_t *nrm2, int order) { // Wenn validNonceTable genutzt wird, dann werden auch nur die Nonces betrachtet, die dort enthalten sind @@ -340,12 +340,12 @@ __host__ void quark_compactTest_cpu_hash_64(int thr_id, uint32_t threads, uint32 startNounce, inpHashes, d_validNonceTable); cudaStreamSynchronize(NULL); // Das original braucht zwar etwas CPU-Last, ist an dieser Stelle aber evtl besser - *nrm1 = (size_t)h_numValid[thr_id][0]; - *nrm2 = (size_t)h_numValid[thr_id][1]; + *nrm1 = h_numValid[thr_id][0]; + *nrm2 = h_numValid[thr_id][1]; } __host__ void quark_compactTest_single_false_cpu_hash_64(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *inpHashes, uint32_t *d_validNonceTable, - uint32_t *d_nonces1, size_t *nrm1, + uint32_t *d_nonces1, uint32_t *nrm1, int order) { // Wenn validNonceTable genutzt wird, dann werden auch nur die Nonces betrachtet, die dort enthalten sind @@ -354,5 +354,5 @@ __host__ void quark_compactTest_single_false_cpu_hash_64(int thr_id, uint32_t th quark_compactTest_cpu_singleCompaction(thr_id, threads, h_numValid[thr_id], d_nonces1, h_QuarkFalseFunction[thr_id], startNounce, inpHashes, d_validNonceTable); cudaStreamSynchronize(NULL); // Das original braucht zwar etwas CPU-Last, ist an dieser Stelle aber evtl besser - *nrm1 = (size_t)h_numValid[thr_id][0]; + *nrm1 = h_numValid[thr_id][0]; } diff --git a/quark/quarkcoin.cu b/quark/quarkcoin.cu index 8f0d4d8..4480785 100644 --- a/quark/quarkcoin.cu +++ b/quark/quarkcoin.cu @@ -42,11 +42,11 @@ extern void quark_jh512_cpu_hash_64(int thr_id, uint32_t threads, uint32_t start extern void quark_compactTest_cpu_init(int thr_id, uint32_t threads); extern void quark_compactTest_cpu_hash_64(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *inpHashes, uint32_t *d_validNonceTable, - uint32_t *d_nonces1, size_t *nrm1, - uint32_t *d_nonces2, size_t *nrm2, + uint32_t *d_nonces1, uint32_t *nrm1, + uint32_t *d_nonces2, uint32_t *nrm2, int order); extern void quark_compactTest_single_false_cpu_hash_64(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *inpHashes, uint32_t *d_validNonceTable, - uint32_t *d_nonces1, size_t *nrm1, + uint32_t *d_nonces1, uint32_t *nrm1, int order); extern uint32_t cuda_check_hash_branch(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *d_nonceVector, uint32_t *d_inputHash, int order); @@ -175,7 +175,7 @@ extern "C" int scanhash_quark(int thr_id, uint32_t *pdata, do { int order = 0; - size_t nrm1=0, nrm2=0, nrm3=0; + uint32_t nrm1=0, nrm2=0, nrm3=0; // erstes Blake512 Hash mit CUDA quark_blake512_cpu_hash_80(thr_id, throughput, pdata[19], d_hash[thr_id]); order++; diff --git a/stats.cpp b/stats.cpp index 3aa8aea..308bc21 100644 --- a/stats.cpp +++ b/stats.cpp @@ -133,7 +133,7 @@ void stats_purge_old(void) { int deleted = 0; uint32_t now = (uint32_t) time(NULL); - uint32_t sz = tlastscans.size(); + uint32_t sz = (uint32_t) tlastscans.size(); std::map::iterator i = tlastscans.begin(); while (i != tlastscans.end()) { if (i->second.ignored || (now - i->second.tm_stat) > STATS_PURGE_TIMEOUT) { @@ -160,6 +160,6 @@ void stats_purge_all(void) */ void stats_getmeminfo(uint64_t *mem, uint32_t *records) { - (*records) = tlastscans.size(); + (*records) = (uint32_t) tlastscans.size(); (*mem) = (*records) * sizeof(stats_data); } diff --git a/util.cpp b/util.cpp index a51537f..8cd6ead 100644 --- a/util.cpp +++ b/util.cpp @@ -977,7 +977,7 @@ static const char *get_stratum_session_id(json_t *val) arr_val = json_array_get(val, 0); if (!arr_val || !json_is_array(arr_val)) return NULL; - n = json_array_size(arr_val); + n = (int) json_array_size(arr_val); for (i = 0; i < n; i++) { const char *notify; json_t *arr = json_array_get(arr_val, i); @@ -1264,7 +1264,7 @@ static bool stratum_notify(struct stratum_ctx *sctx, json_t *params) merkle_arr = json_array_get(params, 4); if (!merkle_arr || !json_is_array(merkle_arr)) goto out; - merkle_count = json_array_size(merkle_arr); + merkle_count = (int) json_array_size(merkle_arr); version = json_string_value(json_array_get(params, 5)); nbits = json_string_value(json_array_get(params, 6)); stime = json_string_value(json_array_get(params, 7));