24 template <
class DATATYPE>
28 for (
int i = 0; i < sz; i++) {
29 if (abs(Array[i]) > includeAbove) count++;
31 fprintf(stdout,
"\nCounted %u nonzero entries\n\n", count);
45 template <
class DATATYPE>
48 fprintf(stderr,
"WARNING: This function is deprecated, and if you are still using it \n\ 49 you are probably trying to use the old sparse structures containing the g array. \n\ 50 Conductance structures have changed: conductance values should be defined as synapse variables now; \n\ 51 the structure is renamed as \"SparseProjection\" and contains only indexing arrays. \n\n\ 52 The replacement function for getG is \n\ 53 getSparseVar(DATATYPE * wuvar, SparseProjection * sparseStruct, int x, int y).\n\n\ 54 calling getSparseVar...");
58 template <
class DATATYPE>
62 int startSynapse = sparseStruct->
indInG[x];
63 int endSynapse = sparseStruct->
indInG[x+1];
64 for (
int syn = startSynapse; syn < endSynapse; syn++) {
65 if (sparseStruct->
ind[syn]==y) {
80 template <
class DATATYPE>
84 sparseStruct->
indInG[0] = 0;
85 for (
int pre = 0; pre < preN; ++pre) {
86 for (
int post = 0; post < postN; ++post) {
87 DATATYPE g = tmp_gRNPN[pre * postN + post];
89 sparseStruct->
ind[synapse] = post;
94 sparseStruct->
indInG[pre + 1] = synapse;
106 template <
class DATATYPE>
113 sparseStruct->
indInG[0] = 0;
114 for (
int pre = 0; pre < preN; ++pre) {
115 for (
int post = 0; post < postN; ++post) {
116 DATATYPE g = tmp_gRNPN[pre * postN + post];
118 sparseStruct->
ind[synapse] = post;
123 sparseStruct->
indInG[pre + 1] = synapse;
125 if (!runTest)
return;
129 for (
int test = 0; test < 10; ++test) {
130 int randX = rand() % preN;
131 int randY = rand() % postN;
132 float denseResult = tmp_gRNPN[randX * postN + randY];
133 float sparseResult =
getG(wuvar, sparseStruct,randX,randY);
137 fprintf(stderr,
"ERROR: Sparse connectivity generator failed for %u out of 10 random checks.\n", fails);
140 fprintf(stdout,
"Sparse connectivity generator passed %u out of 10 random checks.\n", fails);
154 template<
typename PostIndexType>
161 for (
unsigned int i = 0; i < preN; i++) {
163 for(
unsigned int j = 0; j < C->
rowLength[i]; j++) {
165 const unsigned int rowMajorIndex = (i * C->
maxRowLength) + j;
168 const unsigned int postIndex = C->
ind[rowMajorIndex];
177 C->
remap[colMajorIndex] = rowMajorIndex;
189 template<
typename PostIndexType>
192 unsigned int &synRemapCount = C->
synRemap[0];
193 unsigned int *synRemap = &C->
synRemap[1];
196 for (
unsigned int i = 0; i < preN; i++) {
198 for(
unsigned int j = 0; j < C->
rowLength[i]; j++) {
219 template<
typename PostIndexType>
247 template<
typename PostIndexType>
259 template<
typename PostIndexType>
DATATYPE getG(DATATYPE *wuvar, SparseProjection *sparseStruct, int x, int y)
DEPRECATED Utility to get a synapse weight from a SPARSE structure by x,y coordinates NB: as the Spar...
Definition: sparseUtils.h:46
PostIndexType * ind
Ragged row-major matrix, padded to maxRowLength containing indices of target neurons.
Definition: sparseProjection.h:41
void createPosttoPreArray(unsigned int preN, unsigned int postN, SparseProjection *C)
Utility to generate the YALE array structure with post-to-pre arrangement from the original pre-to-po...
Definition: sparseUtils.cc:18
void initializeRaggedArray(const RaggedProjection< PostIndexType > &C, PostIndexType *dInd, unsigned int *dRowLength, unsigned int preN)
Function for initializing conductance array indices for sparse matrices on the GPU (by copying the va...
Definition: sparseUtils.h:220
float getSparseVar(DATATYPE *wuvar, SparseProjection *sparseStruct, unsigned int x, unsigned int y)
Definition: sparseUtils.h:59
void createSparseConnectivityFromDense(DATATYPE *wuvar, int preN, int postN, DATATYPE *tmp_gRNPN, SparseProjection *sparseStruct, bool runTest)
Utility to generate the SPARSE connectivity structure from a simple all-to-all array.
Definition: sparseUtils.h:107
const unsigned int maxColLength
Definition: sparseProjection.h:35
Global header file containing a few global variables. Part of the code generation section...
double asGoodAsZero
What is the default behaviour for sparse synaptic connectivity? Historically, everything was allocate...
Definition: global.cc:45
unsigned int countEntriesAbove(DATATYPE *Array, int sz, double includeAbove)
Utility to count how many entries above a specified value exist in a float array. ...
Definition: sparseUtils.h:25
Row-major ordered sparse matrix structure in 'ragged' format.
Definition: sparseProjection.h:28
unsigned int * rowLength
Length of each row of matrix.
Definition: sparseProjection.h:38
unsigned int connN
Definition: sparseProjection.h:23
unsigned int * colLength
Length of each column of matrix.
Definition: sparseProjection.h:44
unsigned int * ind
Definition: sparseProjection.h:18
void initializeSparseArrayPreInd(const SparseProjection &C, unsigned int *dPreInd)
Function for initializing reversed conductance arrays presynaptic indices for sparse matrices on the ...
Definition: sparseUtils.cc:109
void initializeRaggedArrayRev(const RaggedProjection< PostIndexType > &C, unsigned int *dColLength, unsigned int *dRemap, unsigned int postN)
Function for initializing reversed conductance array indices for sparse matrices on the GPU (by copyi...
Definition: sparseUtils.h:248
#define CHECK_CUDA_ERRORS(call)
Definition: utils.h:64
unsigned int * synRemap
Indices back into ind for each synapse.
Definition: sparseProjection.h:53
const unsigned int maxRowLength
Maximum dimensions of matrices (used for sizing of ind and remap)
Definition: sparseProjection.h:34
void initializeRaggedArraySynRemap(const RaggedProjection< PostIndexType > &C, unsigned int *dSynRemap)
Function for initializing reversed conductance arrays presynaptic indices for sparse matrices on the ...
Definition: sparseUtils.h:260
void setSparseConnectivityFromDense(DATATYPE *wuvar, int preN, int postN, DATATYPE *tmp_gRNPN, SparseProjection *sparseStruct)
Function for setting the values of SPARSE connectivity matrix.
Definition: sparseUtils.h:81
unsigned int * indInG
Definition: sparseProjection.h:17
void createPreIndices(unsigned int preN, unsigned int postN, SparseProjection *C)
Function to create the mapping from the normal index array "ind" to the "reverse" array revInd...
Definition: sparseUtils.cc:64
class (struct) for defining a spars connectivity projection
Definition: sparseProjection.h:16
void initializeSparseArray(const SparseProjection &C, unsigned int *dInd, unsigned int *dIndInG, unsigned int preN)
Function for initializing conductance array indices for sparse matrices on the GPU (by copying the va...
Definition: sparseUtils.cc:82
unsigned int * remap
Ragged column-major matrix, padded to maxColLength containing indices back into ind.
Definition: sparseProjection.h:47
void initializeSparseArrayRev(const SparseProjection &C, unsigned int *dRevInd, unsigned int *dRevIndInG, unsigned int *dRemap, unsigned int postN)
Function for initializing reversed conductance array indices for sparse matrices on the GPU (by copyi...
Definition: sparseUtils.cc:95