Browse Source

min() and max(a,b) are not defined on linux,

in fact max exists in jansson includes (in tree only)

Add them to miner.h
master
Tanguy Pruvot 10 years ago
parent
commit
dca216f992
  1. 27
      fuguecoin.cpp
  2. 18
      groestlcoin.cpp
  3. 7
      miner.h
  4. 17
      myriadgroestl.cpp

27
fuguecoin.cpp

@ -1,12 +1,12 @@
#include <string.h>
#include <stdint.h>
#include "uint256.h" #include "uint256.h"
#include "sph/sph_fugue.h" #include "sph/sph_fugue.h"
#include "miner.h" #include "miner.h"
#include <string.h> #include "cuda_fugue256.h"
#include <stdint.h>
#include <algorithm>
#include <cuda_fugue256.h>
extern "C" void my_fugue256_init(void *cc); extern "C" void my_fugue256_init(void *cc);
extern "C" void my_fugue256(void *cc, const void *data, size_t len); extern "C" void my_fugue256(void *cc, const void *data, size_t len);
@ -16,12 +16,6 @@ extern "C" void my_fugue256_addbits_and_close(void *cc, unsigned ub, unsigned n,
extern int device_map[8]; extern int device_map[8];
extern int device_sm[8]; extern int device_sm[8];
#ifdef _MSC_VER
#define MIN min
#else
#define MIN std::min
#endif
// vorbereitete Kontexte nach den ersten 80 Bytes // vorbereitete Kontexte nach den ersten 80 Bytes
sph_fugue256_context ctx_fugue_const[8]; sph_fugue256_context ctx_fugue_const[8];
@ -31,11 +25,11 @@ sph_fugue256_context ctx_fugue_const[8];
extern "C" int scanhash_fugue256(int thr_id, uint32_t *pdata, const uint32_t *ptarget, extern "C" int scanhash_fugue256(int thr_id, uint32_t *pdata, const uint32_t *ptarget,
uint32_t max_nonce, unsigned long *hashes_done) uint32_t max_nonce, unsigned long *hashes_done)
{ {
uint32_t start_nonce = pdata[19]++; uint32_t start_nonce = pdata[19]++;
int intensity = (device_sm[device_map[thr_id]] > 500) ? 22 : 19; int intensity = (device_sm[device_map[thr_id]] > 500) ? 22 : 19;
uint32_t throughPut = opt_work_size ? opt_work_size : (1 << intensity); uint32_t throughPut = opt_work_size ? opt_work_size : (1 << intensity);
throughPut = MIN(throughPut, max_nonce - start_nonce); throughPut = min(throughPut, max_nonce - start_nonce);
if (opt_benchmark) if (opt_benchmark)
((uint32_t*)ptarget)[7] = 0xf; ((uint32_t*)ptarget)[7] = 0xf;
@ -47,7 +41,7 @@ extern "C" int scanhash_fugue256(int thr_id, uint32_t *pdata, const uint32_t *pt
fugue256_cpu_init(thr_id, throughPut); fugue256_cpu_init(thr_id, throughPut);
init[thr_id] = true; init[thr_id] = true;
} }
// Endian Drehung ist notwendig // Endian Drehung ist notwendig
uint32_t endiandata[20]; uint32_t endiandata[20];
for (int kk=0; kk < 20; kk++) for (int kk=0; kk < 20; kk++)
@ -90,7 +84,7 @@ extern "C" int scanhash_fugue256(int thr_id, uint32_t *pdata, const uint32_t *pt
pdata[19] += throughPut; pdata[19] += throughPut;
} while (!work_restart[thr_id].restart); } while (!work_restart[thr_id].restart);
*hashes_done = pdata[19] - start_nonce + 1; *hashes_done = pdata[19] - start_nonce + 1;
return 0; return 0;
} }
@ -98,7 +92,8 @@ extern "C" int scanhash_fugue256(int thr_id, uint32_t *pdata, const uint32_t *pt
void fugue256_hash(unsigned char* output, const unsigned char* input, int len) void fugue256_hash(unsigned char* output, const unsigned char* input, int len)
{ {
sph_fugue256_context ctx; sph_fugue256_context ctx;
sph_fugue256_init(&ctx); sph_fugue256_init(&ctx);
sph_fugue256(&ctx, input, len); sph_fugue256(&ctx, input, len);
sph_fugue256_close(&ctx, (void *)output); sph_fugue256_close(&ctx, (void *)output);
} }

18
groestlcoin.cpp

@ -1,25 +1,17 @@
#include "uint256.h"
#include "sph/sph_groestl.h"
#include "miner.h"
#include <string.h> #include <string.h>
#include <stdint.h> #include <stdint.h>
#include <algorithm>
#include <openssl/sha.h> #include <openssl/sha.h>
#include "uint256.h"
#include "sph/sph_groestl.h"
#include "cuda_groestlcoin.h" #include "cuda_groestlcoin.h"
#include "miner.h"
#define SWAP32(x) \ #define SWAP32(x) \
((((x) << 24) & 0xff000000u) | (((x) << 8) & 0x00ff0000u) | \ ((((x) << 24) & 0xff000000u) | (((x) << 8) & 0x00ff0000u) | \
(((x) >> 8) & 0x0000ff00u) | (((x) >> 24) & 0x000000ffu)) (((x) >> 8) & 0x0000ff00u) | (((x) >> 24) & 0x000000ffu))
#ifdef _MSC_VER
#define MIN min
#else
#define MIN std::min
#endif
void sha256func(unsigned char *hash, const unsigned char *data, int len) void sha256func(unsigned char *hash, const unsigned char *data, int len)
{ {
uint32_t S[16], T[16]; uint32_t S[16], T[16];
@ -73,7 +65,7 @@ extern "C" int scanhash_groestlcoin(int thr_id, uint32_t *pdata, const uint32_t
{ {
uint32_t start_nonce = pdata[19]++; uint32_t start_nonce = pdata[19]++;
uint32_t throughPut = opt_work_size ? opt_work_size : (1 << 19); // 256*2048 uint32_t throughPut = opt_work_size ? opt_work_size : (1 << 19); // 256*2048
throughPut = MIN(throughPut, max_nonce - start_nonce); throughPut = min(throughPut, max_nonce - start_nonce);
uint32_t *outputHash = (uint32_t*)malloc(throughPut * 16 * sizeof(uint32_t)); uint32_t *outputHash = (uint32_t*)malloc(throughPut * 16 * sizeof(uint32_t));

7
miner.h

@ -105,6 +105,13 @@ typedef unsigned char uchar;
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
#endif #endif
#ifndef max
# define max(a, b) ((a) > (b) ? (a) : (b))
#endif
#ifndef min
# define min(a, b) ((a) < (b) ? (a) : (b))
#endif
#if ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) #if ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
#define WANT_BUILTIN_BSWAP #define WANT_BUILTIN_BSWAP
#else #else

17
myriadgroestl.cpp

@ -1,13 +1,12 @@
#include <string.h>
#include <stdint.h>
#include <openssl/sha.h>
#include "uint256.h" #include "uint256.h"
#include "sph/sph_groestl.h" #include "sph/sph_groestl.h"
#include "miner.h" #include "miner.h"
#include <string.h>
#include <stdint.h>
#include <openssl/sha.h>
#include <algorithm>
void myriadgroestl_cpu_init(int thr_id, int threads); void myriadgroestl_cpu_init(int thr_id, int threads);
void myriadgroestl_cpu_setBlock(int thr_id, void *data, void *pTargetIn); void myriadgroestl_cpu_setBlock(int thr_id, void *data, void *pTargetIn);
void myriadgroestl_cpu_hash(int thr_id, int threads, uint32_t startNounce, void *outputHashes, uint32_t *nounce); void myriadgroestl_cpu_hash(int thr_id, int threads, uint32_t startNounce, void *outputHashes, uint32_t *nounce);
@ -16,12 +15,6 @@ void myriadgroestl_cpu_hash(int thr_id, int threads, uint32_t startNounce, void
((((x) << 24) & 0xff000000u) | (((x) << 8) & 0x00ff0000u) | \ ((((x) << 24) & 0xff000000u) | (((x) << 8) & 0x00ff0000u) | \
(((x) >> 8) & 0x0000ff00u) | (((x) >> 24) & 0x000000ffu)) (((x) >> 8) & 0x0000ff00u) | (((x) >> 24) & 0x000000ffu))
#ifdef _MSC_VER
#define MIN min
#else
#define MIN std::min
#endif
extern "C" void myriadhash(void *state, const void *input) extern "C" void myriadhash(void *state, const void *input)
{ {
sph_groestl512_context ctx_groestl; sph_groestl512_context ctx_groestl;
@ -50,7 +43,7 @@ extern "C" int scanhash_myriad(int thr_id, uint32_t *pdata, const uint32_t *ptar
uint32_t start_nonce = pdata[19]++; uint32_t start_nonce = pdata[19]++;
uint32_t throughPut = opt_work_size ? opt_work_size : (1 << 17); uint32_t throughPut = opt_work_size ? opt_work_size : (1 << 17);
throughPut = MIN(throughPut, max_nonce - start_nonce); throughPut = min(throughPut, max_nonce - start_nonce);
uint32_t *outputHash = (uint32_t*)malloc(throughPut * 16 * sizeof(uint32_t)); uint32_t *outputHash = (uint32_t*)malloc(throughPut * 16 * sizeof(uint32_t));

Loading…
Cancel
Save