Browse Source

OS independant struct typedefinition

etomic
ca333 8 years ago
parent
commit
87d6423b94
  1. 19
      README.md
  2. 37
      basilisk/tradebots_SVM.h
  3. 2
      iguana/m_unix

19
README.md

@ -23,11 +23,11 @@ iguana: most efficient bitcoin core implementation that can simultaneously be fu
komodo: this is the top secret project I cant talk about publicly yet komodo: this is the top secret project I cant talk about publicly yet
> #TL;DR# > #TL;DR#
> >
> ```sudo apt-get update; sudo apt-get install git libcurl4-openssl-dev build-essential; git clone https://github.com/jl777/SuperNET; cd SuperNET; ./m_onetime m_unix;``` > ```sudo apt-get update; sudo apt-get install git libcurl4-openssl-dev build-essential libnanomsg-dev; git clone https://github.com/jl777/SuperNET; cd SuperNET; ./m_onetime m_unix;```
> >
> The above one line gets SuperNET installed, built and launched for unix. > The above one line gets SuperNET installed, built and launched for unix.
> >
> After that ```./m_unix``` updates to latest. > After that ```./m_unix``` updates to latest.
> *Continue below at "Running".* > *Continue below at "Running".*
@ -44,6 +44,8 @@ The above two definitions need to be changed to match the mingw install on your
You need to make sure the nacl sdk is properly installed and you are able to build the examples. You need to make sure the nacl sdk is properly installed and you are able to build the examples.
Now you will need to get the external libs, which can be built from scratch using naclports or there use the reference builds of libcurl.a and libz.a in the SuperNET/crypto777/pnacl_libs. You can just copy those over into $(NACL_SDK_ROOT)/<pepper_dir>/lib/pnacl. Now you will need to get the external libs, which can be built from scratch using naclports or there use the reference builds of libcurl.a and libz.a in the SuperNET/crypto777/pnacl_libs. You can just copy those over into $(NACL_SDK_ROOT)/<pepper_dir>/lib/pnacl.
##For android##
You have to build a native libnanomsg for android. This section is work in progress. Contact ca333@protonmail.ch for assistance on building latest iguana for android.
#ONETIME# #ONETIME#
Now you are ready to build. Now you are ready to build.
@ -103,14 +105,14 @@ Internally, all paths convert the request into a standard SuperNET JSON request.
Another approach is to use the bitcoin RPC syntax via: Another approach is to use the bitcoin RPC syntax via:
curl --url "http://127.0.0.1:7778" --data "{\"coin\":\"BTCD\",\"method\":\"getinfo\",\"params\":[]}" curl --url "http://127.0.0.1:7778" --data "{\"coin\":\"BTCD\",\"method\":\"getinfo\",\"params\":[]}"
the params:[] array is where the standard bitcoin parameters go, the only change that is needed is to specify the coin the params:[] array is where the standard bitcoin parameters go, the only change that is needed is to specify the coin
alternatively {"agent":"SuperNET","method":"bitcoinrpc","coin":"BTCD"} will set the coin alternatively {"agent":"SuperNET","method":"bitcoinrpc","coin":"BTCD"} will set the coin
to use for bitcoin RPC calls. this will suffice in single coin environments to use for bitcoin RPC calls. this will suffice in single coin environments
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"iguana",\"method\":\"test\"}" curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"iguana",\"method\":\"test\"}"
curl --url "http://127.0.0.1:7778/iguana/test" -> html page with results curl --url "http://127.0.0.1:7778/iguana/test" -> html page with results
curl --url "http://127.0.0.1:7778/api/iguana/test" -> just json text curl --url "http://127.0.0.1:7778/api/iguana/test" -> just json text
http://127.0.0.1:7778 -> superugly GUI http://127.0.0.1:7778 -> superugly GUI
http://127.0.0.1:7778/iguana/test http://127.0.0.1:7778/iguana/test
http://127.0.0.1:7778/api/iguana/test http://127.0.0.1:7778/api/iguana/test
postCall('{"agent":"iguana","method":"test"}'} postCall('{"agent":"iguana","method":"test"}'}
iguana_JSON("{\"agent\":\"iguana",\"method\":\"test\"}"); -> direct C function call iguana_JSON("{\"agent\":\"iguana",\"method\":\"test\"}"); -> direct C function call
@ -124,7 +126,7 @@ iguana can be invoked with a command line argument. if it is a name of a file, i
"exchanges" -> { "name":"<name of exchange>", ... } "exchanges" -> { "name":"<name of exchange>", ... }
"apikey", "apisecret", "userid", "tradepassword" these are as expected "apikey", "apisecret", "userid", "tradepassword" these are as expected
"pollgap" -> gap between each access to exchange for getting prices "pollgap" -> gap between each access to exchange for getting prices
on OSX mksquashfs is not native, you will need to install fuse: https://osxfuse.github.io/ and a squashfs for mac: https://github.com/vasi/squashfuse on OSX mksquashfs is not native, you will need to install fuse: https://osxfuse.github.io/ and a squashfs for mac: https://github.com/vasi/squashfuse
********** **********
@ -221,4 +223,3 @@ sudo service ntp start
Now things should be ready. To update and run notary node: Now things should be ready. To update and run notary node:
pkill iguana; ./m_LP; tests/notaryinit pkill iguana; ./m_LP; tests/notaryinit

37
basilisk/tradebots_SVM.h

@ -20,16 +20,14 @@
//#include <dispatch/dispatch.h> //#include <dispatch/dispatch.h>
typedef float svmtype; typedef float svmtype;
#ifdef WIN32
// fadedreamz@gmail.com - added for successful compilation, however, for MSVC probably require a particular OpenCL SDK // fadedreamz@gmail.com - added for successful compilation, however, for MSVC probably require a particular OpenCL SDK
// to work with it (e,g nvidia or amd SDK) // to work with it (e,g nvidia or amd SDK)
typedef struct fake_opencl_double { typedef struct fake_opencl_double { //use a struct for double2 typedefinition on all OS - ca333@protonmail.ch
double x; double x;
double y; double y;
}double2; }double2;
#else
typedef double double2 __attribute__((ext_vector_type(2)));
#endif
#define MAX_VECTORS (1440 * 365 * 5) #define MAX_VECTORS (1440 * 365 * 5)
#define MAIN_MAXCORES 16 #define MAIN_MAXCORES 16
#define c_to_refc(c) (c) #define c_to_refc(c) (c)
@ -192,7 +190,7 @@ void ocas_purge(struct ocas_vars *vars)
fatal("dot_expanded_features not implemented"); fatal("dot_expanded_features not implemented");
return(0); return(0);
} }
static inline void add_expanded_features(register double *W,register double y,register int c,register int selector,register int numfeatures) static inline void add_expanded_features(register double *W,register double y,register int c,register int selector,register int numfeatures)
{ {
fatal("add_expanded_features not implemented"); fatal("add_expanded_features not implemented");
@ -226,7 +224,7 @@ static inline double calc_ocas_output(register struct ocas_vars *vars,register i
// printf("%f ",sum); // printf("%f ",sum);
return(sum); return(sum);
} }
static inline void add_ocas_output(register double y,register struct ocas_vars *vars,register int selector,register int c,register int weekind,register int answerind,register double *W,register double *new_a,register int numfeatures) static inline void add_ocas_output(register double y,register struct ocas_vars *vars,register int selector,register int c,register int weekind,register int answerind,register double *W,register double *new_a,register int numfeatures)
{ {
register int coeffi; register int coeffi;
@ -321,7 +319,7 @@ static inline double _dbufave(register double *buf,register int len)
sum = 0.; sum = 0.;
return(sum); return(sum);
} }
static inline void add_newcut_entry(register struct ocas_vars *vars,register int answerind,register int *new_cut,register int i,register int weekind,register double y) static inline void add_newcut_entry(register struct ocas_vars *vars,register int answerind,register int *new_cut,register int i,register int weekind,register double y)
{ {
weekind <<= 1; weekind <<= 1;
@ -403,7 +401,7 @@ static int _increasing_double(const void *a,const void *b)
#undef double_a #undef double_a
#undef double_b #undef double_b
} }
static inline void calc_ocas_strategy(register struct ocas_vars *vars,register int answerind,register double C,register int numfeatures,register int len,register int *weekinds,register int *new_cut,register double *W,register double *oldW,register double *output,register double *old_output,register double2 *hpfb) static inline void calc_ocas_strategy(register struct ocas_vars *vars,register int answerind,register double C,register int numfeatures,register int len,register int *weekinds,register int *new_cut,register double *W,register double *oldW,register double *output,register double *old_output,register double2 *hpfb)
{ {
double answermag; double answermag;
@ -782,11 +780,11 @@ static void ocas_print(struct ocas_vars *vars,int answerind,int ishwm,double C)
//printf("ocas_print.A%d\n",answerind); //printf("ocas_print.A%d\n",answerind);
//printf("%s.A%02d %4d %8.2f | QP %9.3f QD %9.3f [%9.4f %7.3f] SV.%d %4d | M%9.6f (%9.6f max %8.1f %9.6f) %s.A%02d %9.6f%%\n", //printf("%s.A%02d %4d %8.2f | QP %9.3f QD %9.3f [%9.4f %7.3f] SV.%d %4d | M%9.6f (%9.6f max %8.1f %9.6f) %s.A%02d %9.6f%%\n",
dispvals[0] = vars->Q_P[answerind]/1000000000.; dispvals[1] = (C * vars->Q_D[answerind])/1000000000.; dispvals[0] = vars->Q_P[answerind]/1000000000.; dispvals[1] = (C * vars->Q_D[answerind])/1000000000.;
dispvals[2] = (vars->Q_P[answerind]-C * vars->Q_D[answerind]) / 1000000000; dispvals[2] = (vars->Q_P[answerind]-C * vars->Q_D[answerind]) / 1000000000;
dispvals[3] = (vars->Q_P[answerind]-C * vars->Q_D[answerind]) / MAX(1,fabs(vars->Q_P[answerind])); dispvals[3] = (vars->Q_P[answerind]-C * vars->Q_D[answerind]) / MAX(1,fabs(vars->Q_P[answerind]));
printf("%3d %d.A%02d +%d -%d",vars->nohwm[answerind],vars->refc,answerind,vars->good[answerind],vars->bad[answerind]); printf("%3d %d.A%02d +%d -%d",vars->nohwm[answerind],vars->refc,answerind,vars->good[answerind],vars->bad[answerind]);
printf(" %4d %8.2f |QP %9.3f QD %10.2f [%11.2f %9.1f] SV.%3d %3d |M%9.3f errs.%-6d %-8.0f %5.2f%% errs %6.5f A%9.6f W0%9.6f D%11.9f\n",//[%7.4f%%]\n", printf(" %4d %8.2f |QP %9.3f QD %10.2f [%11.2f %9.1f] SV.%3d %3d |M%9.3f errs.%-6d %-8.0f %5.2f%% errs %6.5f A%9.6f W0%9.6f D%11.9f\n",//[%7.4f%%]\n",
vars->numIt[answerind],vars->ocas_time/1000,dispvals[0],dispvals[1],dispvals[2],dispvals[3], vars->numIt[answerind],vars->ocas_time/1000,dispvals[0],dispvals[1],dispvals[2],dispvals[3],
vars->nNZAlpha[answerind], vars->numlhs[answerind], vars->nNZAlpha[answerind], vars->numlhs[answerind],
// PTRS->lastmetrics[answerind],PTRS->learningrates[answerind][0],PTRS->maxiters[answerind],PTRS->learningrates[answerind][1], // PTRS->lastmetrics[answerind],PTRS->learningrates[answerind][0],PTRS->maxiters[answerind],PTRS->learningrates[answerind][1],
vars->lastmetrics[answerind][0],vars->trn_err[answerind],vars->maxiters[answerind],vars->perc[answerind], vars->lastmetrics[answerind][0],vars->trn_err[answerind],vars->maxiters[answerind],vars->perc[answerind],
@ -827,8 +825,8 @@ static inline void finish_ocasiter(register int answerind,register struct ocas_v
vars->errperc[answerind] = (100 * (double)vars->trn_err[answerind])/(double)MAX(1,vars->len[answerind]); vars->errperc[answerind] = (100 * (double)vars->trn_err[answerind])/(double)MAX(1,vars->len[answerind]);
vars->Q_P[answerind] = 0.5*vars->sq_norm_W[answerind] + (C * vars->xi[answerind]); vars->Q_P[answerind] = 0.5*vars->sq_norm_W[answerind] + (C * vars->xi[answerind]);
vars->ocas_time = (vars->output_time + vars->w_time + vars->add_time + vars->sort_time + vars->qp_solver_time); vars->ocas_time = (vars->output_time + vars->w_time + vars->add_time + vars->sort_time + vars->qp_solver_time);
ocas_print(vars,answerind,0,C); ocas_print(vars,answerind,0,C);
} }
static inline int ocas_iter(struct ocas_vars *vars,int max_nohwm) static inline int ocas_iter(struct ocas_vars *vars,int max_nohwm)
{ {
@ -947,8 +945,8 @@ static inline int init_ocas_vars(int numthreads,int selector,long answerindmask,
{ {
int answerind,lastanswerind,retval = 0; int answerind,lastanswerind,retval = 0;
lastanswerind = TRADEBOTS_NUMANSWERS; lastanswerind = TRADEBOTS_NUMANSWERS;
vars->maxlen = maxlen; vars->maxlen = maxlen;
vars->numthreads = numthreads; vars->numthreads = numthreads;
vars->selector = selector; vars->selector = selector;
//printf("init_ocas_vars lastanswerind.%d\n",lastanswerind); //printf("init_ocas_vars lastanswerind.%d\n",lastanswerind);
for (answerind=0; answerind<lastanswerind; answerind++) for (answerind=0; answerind<lastanswerind; answerind++)
@ -956,8 +954,8 @@ static inline int init_ocas_vars(int numthreads,int selector,long answerindmask,
//printf("A%d.len_%d ",answerind,vars->len[answerind]); //printf("A%d.len_%d ",answerind,vars->len[answerind]);
if ( vars->len[answerind] > 0 )//&& (answerindmask == -1L || ((1L<<answerind) & answerindmask) != 0) ) if ( vars->len[answerind] > 0 )//&& (answerindmask == -1L || ((1L<<answerind) & answerindmask) != 0) )
{ {
vars->refc = c_to_refc(c); vars->c = c; vars->C = C; vars->refc = c_to_refc(c); vars->c = c; vars->C = C;
vars->numfeatures = numfeatures; vars->maxlhs = maxlhs; vars->numfeatures = numfeatures; vars->maxlhs = maxlhs;
if ( vars->CLspaces[answerind] == 0 ) if ( vars->CLspaces[answerind] == 0 )
vars->CLspaces[answerind] = myaligned_alloc(sizeof(*vars->CLspaces[answerind])); vars->CLspaces[answerind] = myaligned_alloc(sizeof(*vars->CLspaces[answerind]));
vars->answerabsaves[answerind] = answerabsave[answerind]; vars->answerabsaves[answerind] = answerabsave[answerind];
@ -972,7 +970,7 @@ static inline int init_ocas_vars(int numthreads,int selector,long answerindmask,
//printf("mask.%lx init_ocas_vars selector.%d weekinds[0].%p\n",answerindmask,selector,vars->weekinds[0]); //printf("mask.%lx init_ocas_vars selector.%d weekinds[0].%p\n",answerindmask,selector,vars->weekinds[0]);
return(retval); return(retval);
} }
void ocas_init(struct ocas_vars *vars,int32_t c,int32_t numfeatures,int32_t starti,int32_t endi) void ocas_init(struct ocas_vars *vars,int32_t c,int32_t numfeatures,int32_t starti,int32_t endi)
{ {
struct ocas_CLbuffers *ptr; struct ocas_lhsbuffers *lhs; struct ocas_CLbuffers *ptr; struct ocas_lhsbuffers *lhs;
@ -1061,7 +1059,7 @@ void ocas_init(struct ocas_vars *vars,int32_t c,int32_t numfeatures,int32_t star
vars->output_time = vars->sort_time = vars->w_time = vars->qp_solver_time = vars->ocas_time = vars->add_time = 0; vars->output_time = vars->sort_time = vars->w_time = vars->qp_solver_time = vars->ocas_time = vars->add_time = 0;
vars->startweekind = starti; vars->endweekind = endi; vars->startweekind = starti; vars->endweekind = endi;
} }
int32_t ocas_gen(int32_t c,int32_t numfeatures,int32_t starti,int32_t endi) int32_t ocas_gen(int32_t c,int32_t numfeatures,int32_t starti,int32_t endi)
{ {
int32_t i; struct ocas_vars *vars = calloc(1,sizeof(*vars)); int32_t i; struct ocas_vars *vars = calloc(1,sizeof(*vars));
@ -1072,4 +1070,3 @@ int32_t ocas_gen(int32_t c,int32_t numfeatures,int32_t starti,int32_t endi)
return(0); return(0);
} }
#endif #endif

2
iguana/m_unix

@ -9,4 +9,4 @@ cd secp256k1; ./m_unix; cd ..
cd ../crypto777; ./m_unix; cd ../iguana cd ../crypto777; ./m_unix; cd ../iguana
gcc -g -fno-aggressive-loop-optimizations -Wno-deprecated -c *.c ../basilisk/basilisk.c ../gecko/gecko.c ../datachain/datachain.c gcc -g -fno-aggressive-loop-optimizations -Wno-deprecated -c *.c ../basilisk/basilisk.c ../gecko/gecko.c ../datachain/datachain.c
gcc -g -fno-aggressive-loop-optimizations -Wno-deprecated -c main.c iguana777.c iguana_bundles.c ../basilisk/basilisk.c gcc -g -fno-aggressive-loop-optimizations -Wno-deprecated -c main.c iguana777.c iguana_bundles.c ../basilisk/basilisk.c
gcc -g -o ../agents/iguana *.o ../agents/libcrypto777.a -lpthread -lm gcc -g -o ../agents/iguana *.o ../agents/libcrypto777.a -lpthread -lm -lnanomsg

Loading…
Cancel
Save