diff --git a/src/globals.h b/src/globals.h index 5b03ec6..45a02d6 100644 --- a/src/globals.h +++ b/src/globals.h @@ -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) //!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); diff --git a/src/neuro/tn_neuron.c b/src/neuro/tn_neuron.c index 5840a92..91e4470 100644 --- a/src/neuro/tn_neuron.c +++ b/src/neuro/tn_neuron.c @@ -1160,8 +1160,9 @@ void TN_commit(tn_neuron_state* s, tw_bf* cv, messageData* m, tw_lp* lp) { /** @todo: fix this remote value */ void prhdr(bool* display, char* hdr) { if (&display) { - print(hdr); - *display = true; + //print(hdr); + printf("%s\n",hdr); + *display = true; } } @@ -1182,15 +1183,18 @@ void TN_final(tn_neuron_state *s, tw_lp *lp) { sprintf(em, "%s\n Core: %i Local: %i \n", hdr, s->myCoreID, s->myLocalID); if (s->membranePotential != 0) { prhdr(&dsp, em); - debugMsg(alpha, s->membranePotential); + printf("%s%i\n",alpha,s->membranePotential); + //debugMsg(alpha, s->membranePotential); } if (s->SOPSCount != 0) { prhdr(&dsp, em); - debugMsg(sops, s->SOPSCount); + printf("%s%i\n",sops, s->SOPSCount ); + //debugMsg(sops, s->SOPSCount); } if (s->heartbeatOut != false) { prhdr(&dsp, em); - debugMsg(HB, (int)s->heartbeatOut); + printf("%s%i\n",HB, (int)s->heartbeatOut ); + //debugMsg(HB, (int)s->heartbeatOut); } } if(SAVE_NETWORK_STRUCTURE){ @@ -1198,12 +1202,24 @@ void TN_final(tn_neuron_state *s, tw_lp *lp) { } } +/** TN_neuron_event_trace - Function that handles event traces for + * data collection and instrumentation. + * + + */ +void TN_neuron_event_trace(messageData *m, tw_lp *lp, char *buffer, int *collect_flag) +{ + id_type sender = (id_type) m->localID; + memcpy(buffer, &sender, sizeof(id_type)); +} + inline tn_neuron_state* TN_convert(void* lpstate) { return (tn_neuron_state*)lpstate; } /**@}*/ -/** RIO Functions for neuron config @{ **/ +/** RIO Functions for neuron config + * @TODO: cruft removal would be good here. @{ **/ size_t tn_size(tn_neuron_state *s, tw_lp *lp){ size_t neuronSize = sizeof(tn_neuron_state); return neuronSize; @@ -1224,103 +1240,6 @@ int tddbFileOpen = 0; -// -//void testCreateTNNeuronFromFile(tn_neuron_state *s, tw_lp *lp){ -// -// if (!tddbFileOpen){ -// sprintf(configFileName, "%s_%li.csv", BBFN, g_tw_mynode); -// neuronConfigFile = fopen(configFileName, "w"); -// tddbFileOpen =1; -// fprintf(neuronConfigFile, "type,isOutput,coreID,localID," -// "sigma0,sigma1,sigma2,sigma3," -// "s0,s1,s2,s3," -// "b0,b1,b2,b3," -// "sigma_lambda," -// "lambda," -// "c_lambda," -// "epsilon," -// "alpha," -// "beta," -// "TM," -// "gamma," -// "kappa," -// "sigma_VR," -// "VR," -// "V," -// "core_delay," -// "isSelfFiring," -// -// ); -// for(int i = 0; i < (NEURONS_IN_CORE * 2); i ++){ -// if(i / NEURONS_IN_CORE == 0){ -// fprintf(neuronConfigFile, "synapseConn-%i,",i%NEURONS_IN_CORE); -// }else{ -// fprintf(neuronConfigFile, "synapse_type-%i,",i%NEURONS_IN_CORE); -// } -// } -// -// UN( "isActive\n"); -// } -// fflush(neuronConfigFile); -// //Loop through the elements of the neuron state, saving it's configuration to the file. -// MCRN("TN", s->isOutputNeuron,s->myCoreID,s->myLocalID); -// -// fflush(neuronConfigFile); -// int mode = 0; -// int ss = 1; -// for (int i = 0; i < (NUM_NEURON_WEIGHTS * 2); i ++){ -// if (i / NUM_NEURON_WEIGHTS == 0){ -// mode ++; -// } -// switch (mode) { -// case 1: -// //sigma0, sigma1, sigma2, sigma3 (sign of inputs from axons of type s0,s1,s2,s3 -// ss = SGN(s->synapticWeight[i % NUM_NEURON_WEIGHTS]); -// MCRN(ss); -// break; -// -// case 2: -// MCRN(s->synapticWeight[i % NUM_NEURON_WEIGHTS]); -// -// break; -// case 3: -// MCRN(s->weightSelection[i % NUM_NEURON_WEIGHTS]); -// break; -// -// } -// } -// -// MCRN((int)s->sigma_l,s->lambda, s->c,s->epsilon); -// -// MCRN(s->posThreshold, s->negThreshold, s->thresholdPRNMask, s->resetMode); -// MCRN(s->kappa, s->sigmaVR, s->encodedResetVoltage,s->membranePotential); -// -// MCRN((unsigned int) s->delayVal, (unsigned int)s->canGenerateSpontaniousSpikes); -// -// fflush(neuronConfigFile); -// -// -// for (int i = 0; i < (NEURONS_IN_CORE * 2); i ++){ -// if (i / NEURONS_IN_CORE == 0){ -// MCRN(s->synapticConnectivity[i]); -// }else{ -// MCRN(s->axonTypes[i % NEURONS_IN_CORE]); -// } -// } -// -// fflush(neuronConfigFile); -// for(int i = 0; i < (NUM_NEURON_WEIGHTS); i++){ -// MCRN(s->weightSelection[i]); -// } -// fflush(neuronConfigFile); -// UN("\n"); -// fflush(neuronConfigFile); -// -// -// -// -//} - void closeTestFile(){ if(tddbFileOpen){ fclose(neuronConfigFile); diff --git a/src/neuro/tn_neuron.h b/src/neuro/tn_neuron.h index 3db99b6..a7a9691 100644 --- a/src/neuro/tn_neuron.h +++ b/src/neuro/tn_neuron.h @@ -79,6 +79,15 @@ void TN_pre_run(tn_neuron_state *s, tw_lp *me); */ void TN_final(tn_neuron_state *s, tw_lp *lp); +/** TN_neuron_event_trace manages the event tracing for NeMo/ROSS instrumentation/viz. + * + * @param m + * @param lp + * @param buffer + * @param collect_flag + */ +void TN_neuron_event_trace(messageData *m, tw_lp *lp, char *buffer, int *collect_flag); + /** * @brief This takes a void pointer and returns this neuron's struct. * This is used for managing super synapse direct communication functionality.