def __init__(self, params_dict, access_buffers, dt,
                 debug=False, LPU_id=None, cuda_verbose=True):
        if cuda_verbose:
            self.compile_options = ['--ptxas-options=-v']
        else:
            self.compile_options = []

        self.num_comps = params_dict['slope'].size
        self.params_dict = params_dict
        self.access_buffers = access_buffers

        self.debug = debug
        self.LPU_id = LPU_id
        self.dtype = params_dict['slope'].dtype

        self.dt = np.double(dt)
        self.ddt = np.double(1e-6)
        self.steps = np.int32(max( int(self.dt/self.ddt), 1 ))

        self.internal_states = {
            c: garray.zeros(self.num_comps, dtype = self.dtype)+self.internals[c] \
            for c in self.internals}

        self.inputs = {
            k: garray.empty(self.num_comps, dtype = self.access_buffers[k].dtype)\
            for k in self.accesses}

        dtypes = {'dt': self.dtype}
        dtypes.update({k: self.inputs[k].dtype for k in self.accesses})
        dtypes.update({k: self.params_dict[k].dtype for k in self.params})
        dtypes.update({k: self.internal_states[k].dtype for k in self.internals})
        dtypes.update({k: self.dtype if not k == 'spike_state' else np.int32 for k in self.updates})
        self.update_func = self.get_update_func(dtypes)
        self.randState = curand.curand_setup(self.update_func.block[0] * self.update_func.grid[0], 0)
dri = garray.to_gpu(np.asarray(n_dict['dri'], dtype=np.float32))

I = garray.to_gpu(np.asarray(n_dict['I'], dtype=np.float32))

id_test = garray.to_gpu(np.asarray([0,0,0,0], dtype=np.float32))

ddt = 0.00001

X_init = [0,50,0,0,0,0,0]
X = garray.to_gpu(np.asarray([[X_init for i in range(NUM_MICROVILLI)] for neuron in range(num_neurons)], dtype=np.int32))
I_micro = garray.to_gpu(np.asarray(np.ones([num_neurons, NUM_MICROVILLI], dtype=np.float32)))
dt_micro = garray.to_gpu(np.asarray(np.zeros([num_neurons, NUM_MICROVILLI], dtype=np.float32)))

cuda.memcpy_htod(int(V), np.asarray(n_dict['initV'], dtype=np.float32))

state = curand_setup(num_neurons*NUM_MICROVILLI,100)

photon_input = garray.to_gpu(np.asarray([3]*num_neurons, dtype=np.float32))
print photon_input

# <codecell>

def get_microvilli_kernel():
        template = Template("""
    #include "curand_kernel.h"
    #include "stdio.h"
    extern "C" {
        #define NNEU {{ nneu }} //NROW * NCOL
    
        #define PLC_T 100
        #define G_T 50
Exemple #3
0
 def _setup_poisson(self, seed=3000):
     self.randState = curand.curand_setup(
         self.block_transduction[0] * self.num_neurons, seed)
     self.photon_absorption_func = get_photon_absorption_func(self.dtype)
Exemple #4
0
    def _setup_transduction(self, seed=0):
        self.photons = garray.zeros(self.num_neurons, self.dtype)

        # setup RNG
        self.randState = curand.curand_setup(
            self.block_transduction[0] * self.grid_transduction[0], seed)

        # using microvilli as single unite in the transduction kernel
        # therefore, we need to figure out which neuron each microvillus
        # belongs to, and from where to where we should sum up the current.
        self.cum_microvilli = np.hstack((0, np.cumsum(self.num_microvilli)))
        self.total_microvilli = self.cum_microvilli[-1]
        tmp = np.zeros(self.total_microvilli, np.uint16)
        tmp[self.cum_microvilli[1:-1]] = 1
        self.microvilli_ind = np.cumsum(tmp).astype(np.uint16)
        #self.d_num_microvilli = garray.to_gpu(self.num_microvilli)
        self.d_num_microvilli = self.params_dict['num_microvilli']

        self.count = garray.empty(1, np.int32)

        self.d_cum_microvilli = garray.to_gpu(
            self.cum_microvilli.astype(np.int32))
        self.d_microvilli_ind = garray.to_gpu(
            self.microvilli_ind.astype(np.uint16))

        self.X = []
        tmp = np.zeros(self.total_microvilli * 2, np.uint16)
        tmp[::2] = 50
        # variables G, Gstar
        self.X.append(garray.to_gpu(tmp.view(np.int32)))
        tmp = np.zeros(self.total_microvilli * 2, np.uint16)
        # variables PLCstar, Dstar
        self.X.append(garray.to_gpu(tmp.view(np.int32)))
        tmp = np.zeros(self.total_microvilli * 2, np.uint16)
        # variables Cstar, Tstar
        self.X.append(garray.to_gpu(tmp.view(np.int32)))
        tmp = np.zeros(self.total_microvilli, np.uint16)
        # variables Mstar
        self.X.append(garray.to_gpu(tmp))

        Xaddress = np.empty(5, np.int64)
        for i in range(4):
            Xaddress[i] = int(self.X[i].gpudata)
        Xaddress[4] = int(self.d_microvilli_ind.gpudata)

        change_ind1 = np.asarray([1, 1, 2, 3, 3, 2, 5, 4, 5, 5, 7, 6, 6, 1],
                                 np.int32) - 1
        change_ind2 = np.asarray([1, 1, 3, 4, 1, 1, 1, 1, 1, 7, 1, 1, 1, 1],
                                 np.int32) - 1
        change1 = np.asarray(
            [0, -1, -1, -1, -1, 1, 1, -1, -1, -2, -1, 1, -1, 1], np.int32)
        change2 = np.asarray([0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0],
                             np.int32)

        self.transduction_func = get_transduction_func(
            self.dtype, self.block_transduction[0], Xaddress, change_ind1,
            change_ind2, change1, change2, self.compile_options)

        self.re_sort_func = get_re_sort_func(self.dtype, self.compile_options)

        self.ns = garray.zeros(self.num_neurons, self.dtype) + 1
        self.update_ns_func = get_update_ns_func(self.dtype,
                                                 self.compile_options)
Exemple #5
0
 def _setup_poisson(self, seed=0):
     self.randState = curand.curand_setup(
         self.block_transduction[0]*self.num_neurons, seed)