Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Devices #113

Merged
merged 36 commits into from
Sep 11, 2013
Merged

Devices #113

merged 36 commits into from
Sep 11, 2013

Conversation

thesamovar
Copy link
Member

@mstimberg, take a look and maybe do an initial merge if you think it's OK to go into master? May not play nice with the functions branch.

thesamovar and others added 30 commits August 19, 2013 00:37
Conflicts:
	brian2/codegen/codeobject.py
	brian2/groups/group.py
	brian2/monitors/ratemonitor.py
	brian2/monitors/spikemonitor.py
C++ standalone works! At least, it compiles and runs without error.
done in Updater

Updater types include:
- CodeObjectUpdater
- NetworkOperationUpdater
- SynapticPathwayUpdaters
@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling 4700202 on devices2 into 36a55c0 on master.

Marcel Stimberg added 3 commits September 11, 2013 14:20
…able objects into the namespace dictionary to a separate method that can be overwritten in subclasses.
…. For runtime targets, two symbols are inserted into the namespace "array" (underlying array) and "array_object" (the real object). Standalone generates code for each dynamic array.
@mstimberg
Copy link
Member

Related to what we discussed via email, I just made some changes to the way variables are handled. The problem was that CodeObject.__init__ took care of preparing the namespace for the CodeObject but this transformation is target-specific. This is now done in a separate function variables_to_namespace which is implemented differently for the different code objects.

Regarding dynamic arrays: These do no longer need to be "faked" as a Variable object when they are to be resized in a code object. Instead, the runtime targets add two symbols to the namespace array and array_object, where the former refers to the underlying array (for read-only situations, e.g. synaptic propagation) and the latter refers to the DynamicArray object (for resizing the array, e.g. in synapse creation). Standalone does not deal with this issue at this stage, it adds a code line doing something equivalent in Device.build.

That's not perfect yet, in particular the constant attribute is misinterpreted in several places. For code generation/execution this should not be relevant anymore as soon as we deal specifically with t and dt (the only AttributeVariable objects we are currently using). Currently, runtime code injects the values of non-constant variables into the namespace at every timestep but this is unnecessary, since the reference to the values does not change. I think the only use of the constant flag should be in high-level code such as state updaters.

What do you think -- should I merge it as it is and you continue to work on the devices part?

One small thing: I replace id(codeobj) by codeobj.name as the dictionary key for code_object_defs -- the id differs between the object and a weakref.proxy to it.

@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling f1a4e1e on devices2 into 36a55c0 on master.

@thesamovar
Copy link
Member Author

Yep, go ahead and merge. Let's deal with the constants issue separately. By the way, does it play nice with your functions work?

@thesamovar
Copy link
Member Author

Before you merge, note that in devices the BrianObject.update, pre_update and post_update methods are gone, and there are now Updater objects. There is also a now pointless .code_objects attribute in BrianObject which is the leftover of an earlier abortive attempt to do what the .updaters attribute does. This should be removed at some point but it doesn't harm anything.

@mstimberg
Copy link
Member

By the way, does it play nice with your functions work?

I didn't merge it yet, I think I'll do it the other way round, i.e. merge master into finalize_functions after this pull request is merged. But I'm not too worried, anyway :)

mstimberg pushed a commit that referenced this pull request Sep 11, 2013
Starting with the devices system for standalone, major changes to the code generation framework
@mstimberg mstimberg merged commit ac3fa6e into master Sep 11, 2013
@mstimberg mstimberg deleted the devices2 branch September 11, 2013 17:30
@thesamovar thesamovar restored the devices2 branch September 11, 2013 20:20
@thesamovar
Copy link
Member Author

Restored devices2 branch because I'll keep working on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants