Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for compiler warnings, more support for amdgpu-pro #19

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 7 additions & 2 deletions .gitignore
@@ -1,10 +1,15 @@
cgminer
cgminer.exe
sgminer
sgminer.exe
minerd
minerd.exe
*.o
*.a
*.lo
*.bin
*.dirstamp
*.m4
libtool
ltmain.sh

autom4te.cache
.deps
Expand Down
2 changes: 2 additions & 0 deletions Makefile.am
Expand Up @@ -84,7 +84,9 @@ sgminer_SOURCES += algorithm/blakecoin.c algorithm/blakecoin.h
sgminer_SOURCES += algorithm/ethash.c algorithm/ethgencache.c algorithm/ethash.h algorithm/eth-sha3.c algorithm/eth-sha3.h
sgminer_SOURCES += algorithm/cryptonight.c algorithm/cryptonight.h algorithm/cn-aes-tbls.h
sgminer_SOURCES += algorithm/equihash.c algorithm/equihash.h
sgminer_SOURCES += algorithm/skeincoin.c algorithm/skeincoin.h
sgminer_SOURCES += gbt-util.c gbt-util.h

bin_SCRIPTS = $(top_srcdir)/kernel/*.cl
bin_SCRIPTS += $(top_srcdir)/kernel/*.h

46 changes: 33 additions & 13 deletions algorithm.c
Expand Up @@ -43,6 +43,7 @@
#include "algorithm/ethash.h"
#include "algorithm/cryptonight.h"
#include "algorithm/equihash.h"
#include "algorithm/skeincoin.h"

#include "compat.h"

Expand Down Expand Up @@ -77,7 +78,8 @@ const char *algorithm_type_str[] = {
"Vanilla",
"Ethash",
"Cryptonight",
"Equihash"
"Equihash",
"Skeincoin"
};

void sha256(const unsigned char *message, unsigned int len, unsigned char *digest)
Expand Down Expand Up @@ -288,31 +290,31 @@ static cl_int queue_yescrypt_multikernel(_clState *clState, dev_blk_ctx *blk, __
CL_SET_ARG(le_target);

//inactive kernel
num = 0;
// num = 0;
kernel = clState->extra_kernels;
CL_SET_ARG_N(0,clState->buffer1);
CL_SET_ARG_N(1,clState->buffer2);
// CL_SET_ARG_N(3, clState->buffer3);

//mix2_2
num = 0;
// num = 0;
CL_NEXTKERNEL_SET_ARG_N(0, clState->padbuffer8);
CL_SET_ARG_N(1,clState->buffer1);
CL_SET_ARG_N(2,clState->buffer2);
//mix2_2
//inactive kernel
num = 0;
// num = 0;
CL_NEXTKERNEL_SET_ARG_N(0, clState->buffer1);
CL_SET_ARG_N(1, clState->buffer2);
//mix2_2

num = 0;
// num = 0;
CL_NEXTKERNEL_SET_ARG_N(0, clState->padbuffer8);
CL_SET_ARG_N(1, clState->buffer1);
CL_SET_ARG_N(2, clState->buffer2);

//inactive kernel
num = 0;
//num = 0;
CL_NEXTKERNEL_SET_ARG_N(0, clState->buffer1);
CL_SET_ARG_N(1, clState->buffer2);
//mix2_2
Expand Down Expand Up @@ -894,17 +896,17 @@ static cl_int queue_lyra2rev2_kernel(struct __clState *clState, struct _dev_blk_
kernel = clState->extra_kernels;
CL_SET_ARG_0(clState->buffer1);
// cubehash - search2
num = 0;
//num = 0;
CL_NEXTKERNEL_SET_ARG_0(clState->buffer1);
// lyra - search3
num = 0;
//num = 0;
CL_NEXTKERNEL_SET_ARG_N(0, clState->buffer1);
CL_SET_ARG_N(1, clState->padbuffer8);
// skein -search4
num = 0;
//num = 0;
CL_NEXTKERNEL_SET_ARG_0(clState->buffer1);
// cubehash - search5
num = 0;
//num = 0;
CL_NEXTKERNEL_SET_ARG_0(clState->buffer1);
// bmw - search6
num = 0;
Expand Down Expand Up @@ -1094,7 +1096,7 @@ static cl_int queue_cryptonight_kernel(_clState *clState, dev_blk_ctx *blk, __ma
cl_kernel *kernel = &clState->kernel;
unsigned int num = 0;
cl_int status = 0, tgt32 = (blk->work->XMRTarget);
cl_ulong le_target = ((cl_ulong)(blk->work->XMRTarget));
__maybe_unused cl_ulong le_target = ((cl_ulong)(blk->work->XMRTarget));

//le_target = *(cl_ulong *)(blk->work->device_target + 24);
memcpy(clState->cldata, blk->work->data, blk->work->XMRBlobLen);
Expand Down Expand Up @@ -1202,6 +1204,24 @@ static cl_int queue_equihash_kernel(_clState *clState, dev_blk_ctx *blk, __maybe
}
#undef WORKSIZE

static cl_int queue_skeincoin_kernel(_clState *clState, dev_blk_ctx *blk, __maybe_unused cl_uint threads)
{
cl_kernel *kernel = &clState->kernel;
unsigned int num = 0;
cl_int status = 0;
int i;
for (i = 0; i < 8; i++) {
status |= clSetKernelArg(*kernel, num++, sizeof(cl_ulong), blk->ulongMidstate + i);
}
for (i = 0; i < 3; i++) {
status |= clSetKernelArg(*kernel, num++, sizeof(cl_uint), blk->ulongData + i);
}
CL_SET_ARG(clState->outputBuffer);

return status;
}



static algorithm_settings_t algos[] = {
// kernels starting from this will have difficulty calculated by using litecoin algorithm
Expand Down Expand Up @@ -1300,9 +1320,8 @@ static algorithm_settings_t algos[] = {
{ "ethash-new", ALGO_ETHASH, "", 1, 1, 1, 0, 0, 0xFF, 0xFFFF000000000000ULL, 0x000000FFUL, 0, 128, 0, ethash_regenhash, NULL, queue_ethash_kernel, gen_hash, append_ethash_compiler_options },

{ "cryptonight", ALGO_CRYPTONIGHT, "", (1ULL << 32), (1ULL << 32), (1ULL << 32), 0, 0, 0xFF, 0xFFFFULL, 0x0000ffffUL, 6, 0, 0, cryptonight_regenhash, NULL, queue_cryptonight_kernel, gen_hash, NULL },

{ "equihash", ALGO_EQUIHASH, "", 1, (1ULL << 28), (1ULL << 28), 0, 0, 0x20000, 0xFFFF000000000000ULL, 0x00000000UL, 0, 128, 0, equihash_regenhash, NULL, queue_equihash_kernel, gen_hash, append_equihash_compiler_options },

{ "skeincoin", ALGO_SKEINCOIN, "", 1, 1, 1, 0, 0, 0xFF, 0xFFFFULL, 0x000000ffUL, 0, 128, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, skeincoin_regenhash, skeincoin_prepare_work, queue_skeincoin_kernel, gen_hash, NULL },
// Terminator (do not remove)
{ NULL, ALGO_UNK, "", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL }
};
Expand Down Expand Up @@ -1380,6 +1399,7 @@ static const char *lookup_algorithm_alias(const char *lookup_alias, uint8_t *nfa
ALGO_ALIAS("blakecoin", "blake256r8");
ALGO_ALIAS("blake", "blake256r14");
ALGO_ALIAS("zcash", "equihash");
ALGO_ALIAS("skein", "skeincoin");

#undef ALGO_ALIAS
#undef ALGO_ALIAS_NF
Expand Down
3 changes: 2 additions & 1 deletion algorithm.h
Expand Up @@ -39,7 +39,8 @@ typedef enum {
ALGO_VANILLA,
ALGO_ETHASH,
ALGO_CRYPTONIGHT,
ALGO_EQUIHASH
ALGO_EQUIHASH,
ALGO_SKEINCOIN
} algorithm_type_t;

extern const char *algorithm_type_str[];
Expand Down
14 changes: 5 additions & 9 deletions algorithm/bitblock.c
Expand Up @@ -70,10 +70,9 @@ typedef struct {
sph_whirlpool_context whirlpool1;
} Xhash_context_holder;

static Xhash_context_holder base_contexts;
extern Xhash_context_holder base_contexts;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its not the correct way to fix that... because this local type is used in different algos.

Will push a sample commit to fix these warnings

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you again for your help and patience. As you will have gathered, I'm pretty new at this.



void init_Bhash_contexts()
static void init_Bhash_contexts()
{
sph_blake512_init(&base_contexts.blake1);
sph_bmw512_init(&base_contexts.bmw1);
Expand All @@ -96,7 +95,7 @@ void init_Bhash_contexts()
* Encode a length len/4 vector of (uint32_t) into a length len vector of
* (unsigned char) in big-endian form. Assumes len is a multiple of 4.
*/
static inline void
inline void
be32enc_vect(uint32_t *dst, const uint32_t *src, uint32_t len)
{
uint32_t i;
Expand All @@ -106,10 +105,7 @@ be32enc_vect(uint32_t *dst, const uint32_t *src, uint32_t len)
}


#ifdef __APPLE_CC__
static
#endif
inline void bitblockhash(void *state, const void *input)
static void bitblockhash(void *state, const void *input)
{
init_Bhash_contexts();

Expand Down Expand Up @@ -241,4 +237,4 @@ bool scanhash_bitblock(struct thr_info *thr, const unsigned char __maybe_unused
}

return ret;
}
}
12 changes: 6 additions & 6 deletions algorithm/cryptonight.c
Expand Up @@ -148,7 +148,7 @@ static inline uint64_t mul128(uint64_t a, uint64_t b, uint64_t* product_hi)
#define BYTE(x, y) (((x) >> ((y) << 3)) & 0xFF)
#define ROTL32(x, y) (((x) << (y)) | ((x) >> (32 - (y))))

void CNAESRnd(uint32_t *X, const uint32_t *key)
void CNAESRnd(uint64_t *X, const uint32_t *key)
{
uint32_t Y[4];

Expand All @@ -160,7 +160,7 @@ void CNAESRnd(uint32_t *X, const uint32_t *key)
for(int i = 0; i < 4; ++i) X[i] = Y[i] ^ key[i];
}

void CNAESTransform(uint32_t *X, const uint32_t *Key)
void CNAESTransform(uint64_t *X, const uint32_t *Key)
{
for(int i = 0; i < 10; ++i)
{
Expand All @@ -184,13 +184,13 @@ void AESExpandKey256(uint32_t *keybuf)
}
}

void cryptonight(uint8_t *Output, uint8_t *Input, uint32_t Length)
void cryptonight(uint32_t *Output, uint32_t *Input, uint32_t Length)
{
CryptonightCtx CNCtx;
uint64_t text[16], a[2], b[2];
uint32_t ExpandedKey1[64], ExpandedKey2[64];

CNKeccak(CNCtx.State, Input, Length);
CNKeccak(CNCtx.State, ((uint64_t *)Input), Length);

for(int i = 0; i < 4; ++i) ((uint64_t *)ExpandedKey1)[i] = CNCtx.State[i];
for(int i = 0; i < 4; ++i) ((uint64_t *)ExpandedKey2)[i] = CNCtx.State[i + 4];
Expand Down Expand Up @@ -220,7 +220,7 @@ void cryptonight(uint8_t *Output, uint8_t *Input, uint32_t Length)
uint64_t c[2];
memcpy(c, CNCtx.Scratchpad + ((a[0] & 0x1FFFF0) >> 3), 16);

CNAESRnd(c, a);
CNAESRnd(c, ((uint32_t *)a));

b[0] ^= c[0];
b[1] ^= c[1];
Expand Down Expand Up @@ -309,7 +309,7 @@ void cryptonight_regenhash(struct work *work)

cryptonight(ohash, data, work->XMRBlobLen);

char *tmpdbg = bin2hex(ohash, 32);
char *tmpdbg = bin2hex(((const char *)ohash), 32);

applog(LOG_DEBUG, "cryptonight_regenhash: %s\n", tmpdbg);

Expand Down
2 changes: 1 addition & 1 deletion algorithm/ethash.c
Expand Up @@ -29,7 +29,7 @@ uint32_t EthCalcEpochNumber(uint8_t *SeedHash)
uint8_t TestSeedHash[32] = { 0 };

for(int Epoch = 0; Epoch < 2048; ++Epoch) {
SHA3_256((struct ethash_h256 *)TestSeedHash, TestSeedHash, 32);
SHA3_256(((struct ethash_h256 *)TestSeedHash), TestSeedHash, 32);
if(!memcmp(TestSeedHash, SeedHash, 32)) return(Epoch + 1);
}

Expand Down
13 changes: 4 additions & 9 deletions algorithm/marucoin.c
Expand Up @@ -66,10 +66,9 @@ typedef struct {
sph_fugue512_context fugue1;
} Xhash_context_holder;

static Xhash_context_holder base_contexts;
extern Xhash_context_holder base_contexts;


void init_Mhash_contexts()
static void init_Mhash_contexts()
{
sph_blake512_init(&base_contexts.blake1);
sph_bmw512_init(&base_contexts.bmw1);
Expand All @@ -90,7 +89,7 @@ void init_Mhash_contexts()
* Encode a length len/4 vector of (uint32_t) into a length len vector of
* (unsigned char) in big-endian form. Assumes len is a multiple of 4.
*/
static inline void
inline void
be32enc_vect(uint32_t *dst, const uint32_t *src, uint32_t len)
{
uint32_t i;
Expand All @@ -99,11 +98,7 @@ be32enc_vect(uint32_t *dst, const uint32_t *src, uint32_t len)
dst[i] = htobe32(src[i]);
}


#ifdef __APPLE_CC__
static
#endif
inline void maruhash(void *state, const void *input)
static void maruhash(void *state, const void *input)
{
init_Mhash_contexts();

Expand Down
6 changes: 3 additions & 3 deletions algorithm/pluck.c
Expand Up @@ -215,7 +215,7 @@ static inline uint32_t be32dec(const void *pp)
}
#define ROTL(a, b) (((a) << (b)) | ((a) >> (32 - (b))))
//note, this is 64 bytes
static inline void xor_salsa8(uint32_t B[16], const uint32_t Bx[16])
inline void xor_salsa8(uint32_t B[16], const uint32_t Bx[16])
{
#define ROTL(a, b) (((a) << (b)) | ((a) >> (32 - (b))))
uint32_t x00, x01, x02, x03, x04, x05, x06, x07, x08, x09, x10, x11, x12, x13, x14, x15;
Expand Down Expand Up @@ -331,7 +331,7 @@ void sha256_hash512(unsigned char *hash, const unsigned char *data)
be32enc((uint32_t *)hash + i, S[i]);
}

inline void pluckrehash(void *state, const void *input)
static void pluckrehash(void *state, const void *input)
{

int i,j;
Expand Down Expand Up @@ -479,4 +479,4 @@ bool scanhash_pluck(struct thr_info *thr, const unsigned char __maybe_unused *pm
}

return ret;
}
}