Skip to content

Commit

Permalink
Added basic stats integration
Browse files Browse the repository at this point in the history
From Niel's commit: #6bfe9f0b8b59306a07f186c557f4e13d428fa7f2
@6bfe9f0b8b59306a07f186c557f4e13d428fa7f2

I manually pulled his changes into this branch, basically taking his vis-integration branch to the top of dev. Currently running tests to see if his code works.

ALSO - Removed C11 specific features from NeMo. This is part 1 for issue #41.
  • Loading branch information
Mark Plagge committed Jun 14, 2017
1 parent 06239bb commit bd9519e
Show file tree
Hide file tree
Showing 5 changed files with 187 additions and 266 deletions.
269 changes: 136 additions & 133 deletions src/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,145 +63,148 @@ float: atof
*Global Macros */
/**@{ */

#define GET_VNAME(Variable) (#Variable)

///////FILE DEBUG HELPERS /////////
#ifdef NET_IO_DEBUG

#define genWrite(x) _Generic((0,x), \
char: "%i,", \
signed char: "%hhd,", \
unsigned char: "%hhu,", \
signed short: "%hd,", \
unsigned short: "%hu,", \
signed int: "%d,", \
unsigned int: "%u,", \
long int: "%ld,", \
unsigned long int: "%lu,", \
long long int: "%lld,", \
unsigned long long int: "%llu,", \
float: "%f,", \
double: "%f,", \
long double: "%Lf,", \
char *: "%s,", \
bool: "%i,",\
void *: "%p,")


#define _GET_NTH_ARG(_1, _2, _3, _4, _5, N, ...) N
#define COUNT_VARARGS(...) _GET_NTH_ARG("ignored", ##__VA_ARGS__, 4, 3, 2, 1, 0)

#define MCR(i) fprintf(neuronConfigFile, genWrite(i), i);

///////////////////////////////////////////////////////////////////////////////
/* C11 _Generic macros - Removed for the sake of compiler sanity.
#define GET_VNAME(Variable) (#Variable)
//#ifdef NET_IO_DEBUG
//#define genWrite(x) _Generic((0,x), \
//char: "%i,", \
//signed char: "%hhd,", \
//unsigned char: "%hhu,", \
//signed short: "%hd,", \
//unsigned short: "%hu,", \
//signed int: "%d,", \
//unsigned int: "%u,", \
//long int: "%ld,", \
//unsigned long int: "%lu,", \
//long long int: "%lld,", \
//unsigned long long int: "%llu,", \
//float: "%f,", \
//double: "%f,", \
//long double: "%Lf,", \
//char *: "%s,", \
//bool: "%i,",\
//void *: "%p,")
//
//
//#define _GET_NTH_ARG(_1, _2, _3, _4, _5, N, ...) N
//#define COUNT_VARARGS(...) _GET_NTH_ARG("ignored", ##__VA_ARGS__, 4, 3, 2, 1, 0)
//
//#define MCR(i) fprintf(neuronConfigFile, genWrite(i), i);
//
////#define _tp0(...)
////#define _tp1(i) genWrite(i)
////#define _tp2(i,...) genWrite(i) _tp1(__VA_ARGS__)
////#define _tp3(i,...) genWrite(i) _tp2(__VA_AGRS__)
////#define _tp4(i,...) genWrite(i) _tp3(__VA_ARGS__)
//
//#define _tp0(...)
//#define _tp1(i) genWrite(i)
//#define _tp2(i,...) genWrite(i) _tp1(__VA_ARGS__)
//#define _tp3(i,...) genWrite(i) _tp2(__VA_AGRS__)
//#define _tp4(i,...) genWrite(i) _tp3(__VA_ARGS__)

#define _tp0(...)
#define _tp1(i) MCR(i)
#define _tp2(i,...) MCR(i) _tp1(__VA_ARGS__)
#define _tp3(i,...) MCR(i) _tp2(__VA_ARGS__)
#define _tp4(i,...) MCR(i) _tp3(__VA_ARGS__)

#define MCRN(...) \
_GET_NTH_ARG("ignored", ##__VA_ARGS__, \
_tp4, _tp3, _tp2, _tp1,_tp0)(__VA_ARGS__)




#endif


#if (__STDC_VERSION >= 200112L) || (_POSIX_C_SOURCE >= 20112L) || (BGQ <=0 )
#define printf_dec_format(x) _Generic((0,x), \
char: "%c", \
signed char: "%hhd", \
unsigned char: "%hhu", \
signed short: "%hd", \
unsigned short: "%hu", \
signed int: "%d", \
unsigned int: "%u", \
long int: "%ld", \
unsigned long int: "%lu", \
long long int: "%lld", \
unsigned long long int: "%llu", \
float: "%f", \
double: "%f", \
long double: "%Lf", \
char *: "%s", \
void *: "%p")


#define print(x) printf(printf_dec_format(x), x)
#define sprint(str, y) sprintf(str, printf_dec_format(y), y)
#define debugMsg(type, value) print(type); print(value); printf("\n")
#define oprint(message, item) print(message); printf(":"); print(item); printf("\n");
#define fprint(file, z) fprintf(file, printf_dec_format(z),z);
#define UN(i) fprintf(neuronConfigFile, printf_dec_format(i), i);
#define nonC11 0
#elif BGQ
//#else //stupid BGQ

#define charf "%c"
#define scharf "%hhd"
#define sshortf "%hd"
#define ushortf "%hu"
#define intf "%d"
#define uintf "%u"
#define lintf "%ld"
#define ulintf "%lu"
#define llintf "%lld"
#define ullintf "%llu"
#define floatf "%f"
#define dobulef "%f"
#define ldoublef "%Lf"

#define voidf "%p"
#define charsf "%s\n"

#define printf_dec_format(x) _Generic((x), \
char: charf, \
signed char: scharf, \
signed short: sshortf, \
unsigned short: ushortf ,\
signed int: intf ,\
unsigned int: uintf ,\
long int: lintf ,\
unsigned long int: ulintf ,\
long long int: llintf ,\
unsigned long long int: ullintf ,\
float: floatf ,\
double: dobulef ,\
long double: ldoublef,\
char *: charsf ,\
void *: voidf )

#define print(x) printf(printf_dec_format(x), x)
#define sprint(str, y) sprintf(str, printf_dec_format(y), y)
#define debugMsg(type, value) print(type); print(value); printf("\n")
#define fprint(file, z) fprintf(file, printf_dec_format(z),z)
#define nonC11 1
/*
#else
#define print(x) printf("%lld", x)
#define debugMsg(type, value) printf("%s -> %lld",type,value)
#define sprint(str, y) sprintf(str, print(y), y)
#define fprint(file, z) fprintf(file, print(z),z)
#define nonC11 1 */

#endif

//#define _tp1(i) MCR(i)
//#define _tp2(i,...) MCR(i) _tp1(__VA_ARGS__)
//#define _tp3(i,...) MCR(i) _tp2(__VA_ARGS__)
//#define _tp4(i,...) MCR(i) _tp3(__VA_ARGS__)
//
//#define MCRN(...) \
//_GET_NTH_ARG("ignored", ##__VA_ARGS__, \
//_tp4, _tp3, _tp2, _tp1,_tp0)(__VA_ARGS__)
//
//
//
//
//#endif
//
//
//#if (__STDC_VERSION >= 200112L) || (_POSIX_C_SOURCE >= 20112L) || (BGQ <=0 )
//#define printf_dec_format(x) _Generic((0,x), \
//char: "%c", \
//signed char: "%hhd", \
//unsigned char: "%hhu", \
//signed short: "%hd", \
//unsigned short: "%hu", \
//signed int: "%d", \
//unsigned int: "%u", \
//long int: "%ld", \
//unsigned long int: "%lu", \
//long long int: "%lld", \
//unsigned long long int: "%llu", \
//float: "%f", \
//double: "%f", \
//long double: "%Lf", \
//char *: "%s", \
//void *: "%p")
//
//
//#define print(x) printf(printf_dec_format(x), x)
//#define sprint(str, y) sprintf(str, printf_dec_format(y), y)
//#define debugMsg(type, value) print(type); print(value); printf("\n")
//#define oprint(message, item) print(message); printf(":"); print(item); printf("\n");
//#define fprint(file, z) fprintf(file, printf_dec_format(z),z);
//#define UN(i) fprintf(neuronConfigFile, printf_dec_format(i), i);
//#define nonC11 0
//#elif BGQ
////#else //stupid BGQ
//
//#define charf "%c"
//#define scharf "%hhd"
//#define sshortf "%hd"
//#define ushortf "%hu"
//#define intf "%d"
//#define uintf "%u"
//#define lintf "%ld"
//#define ulintf "%lu"
//#define llintf "%lld"
//#define ullintf "%llu"
//#define floatf "%f"
//#define dobulef "%f"
//#define ldoublef "%Lf"
//
//#define voidf "%p"
//#define charsf "%s\n"
//
//#define printf_dec_format(x) _Generic((x), \
//char: charf, \
//signed char: scharf, \
//signed short: sshortf, \
//unsigned short: ushortf ,\
//signed int: intf ,\
//unsigned int: uintf ,\
//long int: lintf ,\
//unsigned long int: ulintf ,\
//long long int: llintf ,\
//unsigned long long int: ullintf ,\
//float: floatf ,\
//double: dobulef ,\
//long double: ldoublef,\
//char *: charsf ,\
//void *: voidf )
//
//#define print(x) printf(printf_dec_format(x), x)
//#define sprint(str, y) sprintf(str, printf_dec_format(y), y)
//#define debugMsg(type, value) print(type); print(value); printf("\n")
//#define fprint(file, z) fprintf(file, printf_dec_format(z),z)
//#define nonC11 1
///
//#else
//
//#define print(x) printf("%lld", x)
//
//#define debugMsg(type, value) printf("%s -> %lld",type,value)
//#define sprint(str, y) sprintf(str, print(y), y)
//#define fprint(file, z) fprintf(file, print(z),z)
//
//#define nonC11 1
//
//#endif */
///////////////END OF C11 MACROS. REMOVED FOR COMPILING SANITY ////////////////
///////////////////////////////////////////////////////////////////////////////


/** TODO: Eventually replace this with generic macro and non-branching ABS code. */
#define IABS(a) (((a) < 0) ? (-a) : (a)) //!< Typeless integer absolute value function
/** TODO: See if there is a non-branching version of the signum function, maybe in MAth libs and use that. */
/** TODO: See if there is a non-branching version of the signum function, maybe in
* MAth libs and use that. */
#define SGN(x) ((x > 0) - (x < 0)) //!< Signum function

#define DT(x) !(x) //!<Kronecker Delta function.
Expand Down
42 changes: 16 additions & 26 deletions src/nemo_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,19 @@ tw_lptype model_lps[] = {
{ 0}};


/** Stats gathering */
st_trace_type nemo_trace_types[] = {
{ 0 },
{ 0 },
{
(rbev_trace_f) NULL,
0,
(ev_trace_f) TN_neuron_event_trace,
sizeof(id_type)
},
{ 0 }

};

/**
* @brief Displays NeMo's initial run size configuration.
Expand Down Expand Up @@ -225,7 +237,8 @@ void init_nemo() {
g_tw_lookahead = 0.001;
g_tw_lp_types = model_lps;
g_tw_lp_typemap = lpTypeMapper;

// Viz settings:
g_st_trace_types = nemo_trace_types;
/// EVENTS PER PE SETTING
g_tw_events_per_pe = NEURONS_IN_CORE * AXONS_IN_CORE; // magic number

Expand All @@ -243,36 +256,13 @@ void init_nemo() {
*/

int main(int argc, char *argv[]) {
// char *NETWORK_FILE_NAME = calloc(256, sizeof(char));
// strcpy(NETWORK_FILE_NAME, "nemo_model.csv");
// char *SPIKE_FILE_NAME = calloc(256, sizeof(char));
// strcpy(SPIKE_FILE_NAME, "nemo_spike.csv");

tw_opt_add(app_opt);
tw_init(&argc, &argv);

// call nemo init
init_nemo();
if (nonC11 == 1)
printf("Non C11 compliant compiler detected.\n");

// if (testingMode == 1 ) {
// unsigned char mapResult = 0;
// mapResult = mapResult | mapTests();
//
// if(mapResult & INVALID_AXON){
// printf("Creted invalid axon.\n");
// }
// if (mapResult & INVALID_SYNAPSE){
// printf("Created invalid synapse.\n");
// }
// if (mapResult & INVALID_NEURON){
// printf("Created invalid neuron.\n");
// }
//
//
// return mapResult;
// }
// Define LPs:

tw_define_lps(LPS_PER_PE, sizeof(messageData));
tw_lp_setup_types();

Expand Down
8 changes: 4 additions & 4 deletions src/neuro/synapse.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,12 @@ void synapse_final(synapseState *s, tw_lp *lp){

if (s->msgSent != 0){
printf("%s ", shdr);
char* m = "Message Sent Val ->";
debugMsg(m, s->msgSent);
//char* m = "Message Sent Val ->";
//debugMsg(m, s->msgSent);
}
}
print( (char*) "SS Messages sent: ");
print(s->msgSent);
//print( (char*) "SS Messages sent: ");
//print(s->msgSent);



Expand Down
Loading

0 comments on commit bd9519e

Please sign in to comment.