Download latest PDF - Read the Docs

Transcript
Brian Documentation, Release 1.5dev
resolution_requires_loop()
Returns True except for Python.
resolve(*args, **kwds)
Method generated by language_invariant_symbol_method().
Languages and methods follow:
python resolve_python()
c resolve_c()
resolve_c(read, write, vectorisable, item, namespace)
Returns a C++ for loop of the form:
for(int index_name=start; index_name<end; index_name++)
{
const int name = array_name[index_name];
...
}
If defined (start, end)=array_slice otherwise (start, end)=(0, array_len).
resolve_gpu(read, write, vectorisable, item, namespace)
If not vectorisable, use resolve_c(). If vectorisable, we set the following in the namespace:
_gpu_vector_index = index_name
_gpu_vector_slice = (start, end)
Where start and end are as in resolve_c(). This marks that we want to vectorise over this index,
and the GPU code will handle this later. Finally, we prepend the item with:
const int name = array_name[index_name];
resolve_python(read, write, vectorisable, item, namespace)
If vectorisable it will prepend one of these two forms to item:
name = array_name
name = array_name[start:end]
(where (start, end) = array_slice if provided).
If not vectorisable, it will return a for loop over either array_name or array_name[start:end]‘.
supported_languages = [’python’, ‘c’, ‘gpu’]
brian.experimental.codegen2.language_invariant_symbol_method(basemethname,
langs,
fallback=None,
doc=None)
Helper function to create methods for Symbol classes.
Sometimes it is clearer to write a separate method for each language the Symbol supports. This function can
generate a method that can take any language, and calls the desired method. For example, if you had defined
two methods load_python and load_c then you would define the load method as follows:
load = language_invariant_symbol_method('load',
{'python':load_python, 'c':load_c})
The fallback gives a method to call if no language-specific method was found. A docstring can be provided
to doc.
11.5. Code generation
383