예제 #1
0
def initMUSIC():
    global DEFAULT_TIMESTEP, timestep, setup, stoptime, runtime, tau, DEFAULT_TAU, state, state_hist, d, num_neurons, proj_hist

    setup = music.Setup()
    try:
        timestep = setup.config("music_timestep")
    except:
        timestep = DEFAULT_TIMESTEP

    try:
        tau = setup.config("tau")
    except:
        tau = DEFAULT_TAU

    stoptime = setup.config("stoptime")

    port_in = setup.publishEventInput("in")

    port_in.map(eventfunc, 
        music.Index.GLOBAL, 
        base=0, 
        size=port_in.width(),
        maxBuffered=1)

    state = np.ones(port_in.width())
    state_hist = {"states": [np.array(state)], "times": [0]}
    for i in range(100):
        state_hist['states'] = np.append(state_hist['states'], [state], axis = 0)
        state_hist['times'] = np.append(state_hist['times'], [0], axis = 0)

    proj = np.zeros(3)
    proj_hist = {"projs": [np.array(proj)], "times": [0]}

    d = DynamicUpdate()
    d.on_launch()

    num_neurons = port_in.width()

    comm.Barrier()
    runtime = music.Runtime(setup, timestep)
예제 #2
0
local = width // size
rest = width % size
firstId = rank * local

# distribute the rest:
firstId += min(rank, rest)
if rank < rest: local += 1

def eventerr(d):
    if errorAt is None: return
    if d >= errorAt: raise RuntimeError("Hey")

time = None
def eventfunc(d, t, i):
    eventerr(d)
    sys.stderr.write("Receive rank {}: Event ({}, {}) at {}\n".
                     format(rank, i, d, time))

inp.map(eventfunc, 
        music.Index.GLOBAL, 
        base=firstId, 
        size=local,
        maxBuffered=buf)

runtime = music.Runtime(setup, timestep)
times = takewhile(lambda t: t <= stoptime, runtime)
for time in times:
    pass

runtime.finalize()
예제 #3
0
#!/usr/bin/env python
"""
MUSIC Hello World
"""

import sys, music
setup = music.Setup (sys.argv)
from mpi4py import MPI

hwmess = "Hello, World! I am process %d of %d with argument %s.\n"
comm = setup.communicator ()
myrank = comm.Get_rank()
nprocs = comm.Get_size()
sys.stdout.write(hwmess % (myrank, nprocs, sys.argv[1]))

# Entering runtime phase
runtime = music.Runtime (setup, 1e-4)

# Must end with a call to finalize ()
runtime.finalize ()