-
Notifications
You must be signed in to change notification settings - Fork 216
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cleaned up CPPStandaloneDevice.build and partial support for group
variable initialisations
- Loading branch information
1 parent
9e72b25
commit 8a81ce8
Showing
12 changed files
with
233 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
from brian2.core.preferences import brian_prefs | ||
from .codeobject import CPPStandaloneCodeObject | ||
from .device import cpp_standalone_device, build | ||
from .device import cpp_standalone_device, build, Network, run, reinit, stop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#ifndef _BRIAN_COMMON_MATH_H | ||
#define _BRIAN_COMMON_MATH_H | ||
|
||
#include<limits> | ||
|
||
#define inf (std::numeric_limits<double>::infinity()) | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
brian2/devices/cpp_standalone/templates/group_variable_set.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
//////////////////////////////////////////////////////////////////////////// | ||
//// MAIN CODE ///////////////////////////////////////////////////////////// | ||
|
||
{% macro cpp_file() %} | ||
|
||
#include "{{codeobj_name}}.h" | ||
#include<math.h> | ||
#include "brianlib/common_math.h" | ||
#include<stdint.h> | ||
|
||
////// SUPPORT CODE /////// | ||
namespace { | ||
{% for line in support_code_lines %} | ||
{{line}} | ||
{% endfor %} | ||
} | ||
|
||
////// HASH DEFINES /////// | ||
{% for line in hashdefine_lines %} | ||
{{line}} | ||
{% endfor %} | ||
|
||
void _run_{{codeobj_name}}(double t) | ||
{ | ||
///// CONSTANTS /////////// | ||
%CONSTANTS% | ||
///// POINTERS //////////// | ||
{% for line in pointers_lines %} | ||
{{line}} | ||
{% endfor %} | ||
|
||
//// MAIN CODE //////////// | ||
// TODO: this hack only works when writing G.V = str, not e.g. G.v[str] = str. | ||
const int _num_group_idx = _num_idx; | ||
for(int _idx_group_idx=0; _idx_group_idx<_num_group_idx; _idx_group_idx++) | ||
{ | ||
//const int _idx = _group_idx[_idx_group_idx]; | ||
const int _idx = _idx_group_idx; | ||
const int _vectorisation_idx = _idx; | ||
{% for line in code_lines %} | ||
{{line}} | ||
{% endfor %} | ||
} | ||
} | ||
{% endmacro %} | ||
|
||
//////////////////////////////////////////////////////////////////////////// | ||
//// HEADER FILE /////////////////////////////////////////////////////////// | ||
|
||
{% macro h_file() %} | ||
#ifndef _INCLUDED_{{codeobj_name}} | ||
#define _INCLUDED_{{codeobj_name}} | ||
|
||
#include "arrays.h" | ||
|
||
void _run_{{codeobj_name}}(double t); | ||
|
||
#endif | ||
{% endmacro %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
for(int i=0; i<{{num_steps}}; i++) | ||
{ | ||
t = i*dt; | ||
{% for run_line in run_lines %} | ||
{{run_line}} | ||
{% endfor %} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.