# Parallel Simulations of the Sharp Wave-Ripples of the Hippocamp on Multicore CPUs and GPUs
## 2 Materials and Methods
### Parallel Simulations of the CA1 Network
#### 2.2.1 The Serial Algorithm  
The simulation of the hippocampus neural network starts by creating the connections between the different neurons under the constraints described in Section 2.1. Indeed, the connections and the synaptic weights are selected from a Gaussian distribution with zero mean and a variance of 10%. Then, all the non-time dependent values are computed together with the background noise. The inputs from the CA3 section in form of voltages and currents are also computed. Then, the equations described in Section 2.1 are solved with a 1-step Euler algorithm with an integration step of 0.001 ms. Thus, serial code considers the simulation of 2 s of cellular activity with a time step of 0.001 ms. At this point the simulation of the cellular activity can start. A main _for_ loop iterates over these time steps. The first operations are the update of the synaptic currents, which can be written as a set of four matrix-vector multiplications, one for each of the four connection types, namely excitatory-excitatory (EE), excitatory-inhibitory (EI), inhibitory-inhibitory (II) and inhibitory-excitatory (IE). The matrices store the terms related to the synaptic conductance and the normalization factor of the spikes, while the vector contains the difference between the actual potential of a neuron and its inversion potential. The next step is the update of the neuronal voltages. It is performed by two _for_ loops, one for each kind of cell. The operations performed inside these two loops are described by Equations (1)-(8). Figure 2 summarizes the main steps of the serial algorithm.  
The operations performed inside the main _for_ loop are detailed in Algorithm 1.  
```
1:for\(t=0\)to\(t_{\text{max}}\)
2:\(\#\)update the synaptic conductances with matrix-vector multiplications
3:\(\bar{g}_{EE}=\overline{\delta EE}\ast w_{EE}\)
4:\(\bar{g}_{EI}=\overline{\delta EI}\ast w_{EI}\)
5:\(\bar{g}_{IE}=\overline{\delta IE}\ast w_{IE}\)
6:\(\bar{g}_{II}=\overline{\delta NI}\ast w_{II}\)
7: Compute Equations (7) and (8)
8:for\(i=0\)to\(NE\)
9: compute Equations (1)-(3) to update the excitatory cells voltage
10:end
11:for\(i=0\)to\(NI\)
12: compute Equations (1)-(3) to update the inhibitory cells voltage
13:end
14:end
```  
**Algorithm 1**Pseudocode of the main for loop  
The main for loop starts in line 1 and is iterated over the time steps. Lines 3 to 6 are the matrix-vector multiplications used to update the synaptic conductances that will be used  
Figure 2: the serial algorithm flow. The terms \(NE\) and \(NI\) represent the number of excitatory and inhibitory neurons, respectively.  
to update the synaptic currents. In this case, the subscripts \(EE\), \(EI\), \(IE\), and \(II\) indicates the excitatory to excitatory, the excitatory to inhibitory, the inhibitory to excitatory, and the inhibitory to inhibitory connections, respectively. After these computations, line 7 evaluates Equations (7) and (8). The next step is the update of excitatory and inhibitory cells voltage, which is performed using Equations (1)-(3) with the two for loops in lines 8 to 13.