CPPStandaloneDevice class¶
(Shortest import: from brian2.devices.cpp_standalone.device import CPPStandaloneDevice)
-
class
brian2.devices.cpp_standalone.device.CPPStandaloneDevice[source]¶ Bases:
brian2.devices.device.DeviceThe
Deviceused for C++ standalone simulations.Attributes
arange_arraysDictionary of all arrays to be filled with numbers (mapping array_cacheDictionary mapping ArrayVariableobjects to their value or toNoneif the value (potentially) depends on executed code.arraysDictionary mapping ArrayVariableobjects to their globallybuild_on_runWhether a run should trigger a build build_optionsbuild options dynamic_arraysList of all dynamic arrays dynamic_arrays_2dDictionary mapping DynamicArrayVariableobjects with 2 dimensionshas_been_runWhether the simulation has been run static_arraysDict of all static saved arrays zero_arraysList of all arrays to be filled with zeros Methods
add_array(var)build([directory, compile, run, debug, ...])Build the project check_openmp_compatible(nb_threads)code_object(owner, name, abstract_code, ...)code_object_class([codeobj_class])compile_source(directory, compiler, debug, clean)copy_source_files(writer, directory)fill_with_array(var, arr)find_synapses()freeze(code, ns)generate_codeobj_source(writer)generate_main_source(writer)generate_makefile(writer, compiler, ...)generate_network_source(writer, compiler)generate_objects_source(writer, ...)generate_run_source(writer)generate_synapses_classes_source(writer)get_array_filename(var[, basedir])Return a file name for a variable. get_array_name(var[, access_data])Return a globally unique name for var().get_value(var[, access_data])init_with_arange(var, start, dtype)init_with_zeros(var, dtype)insert_code(slot, code)Insert code directly into main.cpp network_get_profiling_info(net)network_restore(net[, name])network_run(net, duration[, report, ...])network_store(net[, name])reinit()resize(var, new_size)run(directory, with_output, run_args)run_function(name[, include_in_parent])Context manager to divert code into a function seed([seed])Set the seed for the random number generator. static_array(name, arr)variableview_get_subexpression_with_index_array(...)variableview_get_with_expression(...[, ...])variableview_set_with_index_array(...)write_static_arrays(directory)Details
-
arange_arrays¶ Dictionary of all arrays to be filled with numbers (mapping
ArrayVariableobjects to start value)
-
array_cache¶ Dictionary mapping
ArrayVariableobjects to their value or toNoneif the value (potentially) depends on executed code. This mechanism allows to access state variables in standalone mode if their value is known at run time
-
arrays¶ Dictionary mapping
ArrayVariableobjects to their globally unique name
-
build_on_run¶ Whether a run should trigger a build
-
build_options¶ build options
-
dynamic_arrays¶ List of all dynamic arrays Dictionary mapping
DynamicArrayVariableobjects with 1 dimension to their globally unique name
-
dynamic_arrays_2d¶ Dictionary mapping
DynamicArrayVariableobjects with 2 dimensions to their globally unique name
-
has_been_run¶ Whether the simulation has been run
-
static_arrays¶ Dict of all static saved arrays
-
zero_arrays¶ List of all arrays to be filled with zeros
-
build(directory='output', compile=True, run=True, debug=False, clean=True, with_output=True, additional_source_files=None, run_args=None, direct_call=True, **kwds)[source]¶ Build the project
TODO: more details
Parameters: directory : str, optional
The output directory to write the project to, any existing files will be overwritten. If the given directory name is
None, then a temporary directory will be used (used in the test suite to avoid problems when running several tests in parallel). Defaults to'output'.compile : bool, optional
Whether or not to attempt to compile the project. Defaults to
True.run : bool, optional
Whether or not to attempt to run the built project if it successfully builds. Defaults to
True.debug : bool, optional
Whether to compile in debug mode. Defaults to
False.with_output : bool, optional
Whether or not to show the
stdoutof the built program when run. Output will be shown in case of compilation or runtime error. Defaults toTrue.clean : bool, optional
Whether or not to clean the project before building. Defaults to
True.additional_source_files : list of str, optional
A list of additional
.cppfiles to include in the build.direct_call : bool, optional
Whether this function was called directly. Is used internally to distinguish an automatic build due to the
build_on_runoption from a manualdevice.buildcall.
-
code_object(owner, name, abstract_code, variables, template_name, variable_indices, codeobj_class=None, template_kwds=None, override_conditional_write=None)[source]¶
-
get_array_filename(var, basedir='results')[source]¶ Return a file name for a variable.
Parameters: var :
ArrayVariableThe variable to get a filename for.
basedir : str
The base directory for the filename, defaults to
'results'.Returns :
——- :
filename : str
A filename of the form
'results/'+varname+'_'+str(hash(varname)), where varname is the name returned byget_array_name.Notes
The reason that the filename is not simply
'results/' + varnameis that this could lead to file names that are not unique in file systems that are not case sensitive (e.g. on Windows).
-
get_array_name(var, access_data=True)[source]¶ Return a globally unique name for
var().Parameters: access_data : bool, optional
-
network_run(net, duration, report=None, report_period=10. * second, namespace=None, profile=True, level=0, **kwds)[source]¶
-
run_function(name, include_in_parent=True)[source]¶ Context manager to divert code into a function
Code that happens within the scope of this context manager will go into the named function.
Parameters: name : str
The name of the function to divert code into.
include_in_parent : bool
Whether or not to include a call to the newly defined function in the parent context.
-