AnimatLab  2
Test
config.h
1 /*
2  * Copyright (c) 2013 Regents of the University of California. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *
11  * 2. Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the distribution.
14  *
15  * 3. The names of its contributors may not be used to endorse or promote
16  * products derived from this software without specific prior written
17  * permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  *
31  * *********************************************************************************************** *
32  * CARLsim
33  * created by: (MDR) Micah Richert, (JN) Jayram M. Nageswaran
34  * maintained by: (MA) Mike Avery <averym@uci.edu>, (MB) Michael Beyeler <mbeyeler@uci.edu>,
35  * (KDC) Kristofor Carlson <kdcarlso@uci.edu>
36  *
37  * CARLsim available from http://socsci.uci.edu/~jkrichma/CARLsim/
38  * Ver 07/13/2013
39  */
40 
41 #ifndef _CONFIG_H_
42 #define _CONFIG_H_
43 
44 #include <stdio.h>
45 #include <stdlib.h>
46 #include <string.h>
47 #include <malloc.h>
48 #include <assert.h>
49 #include <math.h>
50 
51 #if _WIN32 || _WIN64
52  #include <algorithm> //DWC Change
53  #include <stdint.h>
54 
55  //typedef __int8 int8_t;
56  //typedef __int16 int16_t;
57  //typedef __int32 int32_t;
58  //typedef __int64 int64_t;
59  //typedef unsigned __int8 uint8_t;
60  //typedef unsigned __int16 uint16_t;
61  //typedef unsigned __int32 uint32_t;
62  //typedef unsigned __int64 uint64_t;
63 #else
64  #include <stdint.h>
65 #endif
66 
67 #define MAX_numPostSynapses (10000)
68 #define MAX_numPreSynapses (20000)
69 #define MAX_SynapticDelay (20)
70 
71 //#define CONDUCTANCES 1
72 #define COND_INTEGRATION_SCALE 2
73 //#define STP
74 
75 #define UNKNOWN_NEURON_MAX_FIRING_RATE 25
76 #define INHIBITORY_NEURON_MAX_FIRING_RATE 520
77 #define EXCITATORY_NEURON_MAX_FIRING_RATE 520
78 #define POISSON_MAX_FIRING_RATE 520
79 
80 #define STDP(t,a,b) ((a)*exp(-(t)*(b)))
81 
82 //#define LTD(t,a,b) (ALPHA_LTD*exp(-(t)/TAU_LTD))
83 //#define LTP(t,a,b) (ALPHA_LTP*exp(-(t)/TAU_LTP))
84 //#define LTD(t,a,b) (ALPHA_LTD*exp(-(t)/TAU_LTD))
85 
86 #define GPU_LTP(t) (gpuNetInfo.ALPHA_LTP*__expf(-(t)/gpuNetInfo.TAU_LTP))
87 #define GPU_LTD(t) (gpuNetInfo.ALPHA_LTD*__expf(-(t)/gpuNetInfo.TAU_LTD))
88 
89 #define PROPAGATED_BUFFER_SIZE (1023)
90 #define MAX_SIMULATION_TIME ((uint32_t)(0x7fffffff))
91 #define LARGE_NEGATIVE_VALUE (-(1 << 30))
92 
93 #define S_SCALING (1.0f)
94 #define S_MAX (10.0f/S_SCALING)
95 
96 #define HISTOGRAM_SIZE 100
97 
98 #define DEBUG_LEVEL 0
99 
100 #define MAX_GRP_PER_SNN 250
101 
102 // This option effects readNetwork()'s behavior. Setting this option to 1 will cause
103 // the network file to be read twice, once for plastic synapses and then again for
104 // fixed synapses. For large networks this could be a substantial speed reduction;
105 // however, it uses much less memory than setting it to 0.
106 #define READNETWORK_ADD_SYNAPSES_FROM_FILE 1
107 
108 // If this option is set, CpuSNN::setSpikeMonitor will attempt to create the subdirectory
109 // specified by the user if it does not exist.
110 // Example:
111 // main_mySim.cpp
112 // sim.setSpikeMonitor(gEx,"Results/mySim/spkEx.dat")
113 // => This will attempt to create subdirectory "./Results/mySim", but not "./Results".
114 #define CREATE_SPIKEDIR_IF_NOT_EXISTS 0
115 
116 
117 #define INHIBITORY_STDP
118 
119 //#define NEURON_NOISE
120 
121 #define STP_BUF_SIZE 32
122 
123 // useful during testing and development. carries out series of checks
124 // to ensure simulator is working correctly
125 #ifndef TESTING
126  #define TESTING (0)
127 #endif
128 
129 // does more kind of checking in the kernel to ensure nothing is screwed up...
130 #ifndef ENABLE_MORE_CHECK
131  #define ENABLE_MORE_CHECK (0)
132 #endif
133 
134 
135 // This flag is used when having a common poisson generator for both CPU and GPU simulation
136 // We basically use the CPU poisson generator. Evaluate if there is any firing due to the
137 // poisson neuron. Copy that curFiring status to the GPU which uses that for evaluation
138 // of poisson firing
139 #define TESTING_CPU_GPU_POISSON (0)
140 
141 
142 
143  /****************************/
144  // debug related stuff.. inspiration from
145  // http://www.decompile.com/cpp/faq/file_and_line_error_string.htm
146  #define STRINGIFY(x) #x
147  #define TOSTRING(x) STRINGIFY(x)
148  #define AT __FILE__ ":" TOSTRING(__LINE__)
149 
150  inline void error(FILE *fp, const char *location, const char *msg, int sec, int step)
151  {
152  fprintf(fp, "(wt=%d,ms=%d) Error at %s: %s\n", sec, step, location, msg);
153  }
154 
155  inline void debug(FILE *fp, const char *location, const char *msg, int sec, int step)
156  {
157  fprintf(fp, "(wt=%d,ms=%d) Executing %s: %s\n", sec, step, location, msg);
158  }
159 
160  #define DBG(num,fp,loc,msg) if( DEBUG_LEVEL >= num ) debug(fp,loc,msg,simTimeSec,simTimeMs);
161 
162 
163 #define MAX_NEURON_CHUNK_SIZE (750)
164 /*
165 
166 #define FACTOR 1
167 #define IMAGE_SIZE (16*FACTOR)
168 
169 #define MAX_CV_WINDOW_PIXELS (1000)
170 
171 #define MIN_CV_WINDOW_PIXELS (100)
172 */
173 #endif