Skip to content

Commit

Permalink
Make standalone consistent with runtime with regard to clocks
Browse files Browse the repository at this point in the history
Also cast integers to 64 bit instead of 32 bit
  • Loading branch information
mstimberg committed Mar 26, 2019
1 parent a591214 commit d895265
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions brian2/devices/cpp_standalone/brianlib/clocks.h
Expand Up @@ -19,7 +19,7 @@ class Clock
double *dt;
int64_t *timestep;
double *t;
Clock(double _epsilon=1e-14) : epsilon(_epsilon) { i_end = 0;};
Clock(double _epsilon=1e-8) : epsilon(_epsilon) { i_end = 0;};
inline void tick()
{
timestep[0] += 1;
Expand All @@ -30,18 +30,18 @@ class Clock
{
int i_start = fround(start/dt[0]);
double t_start = i_start*dt[0];
if(t_start==start || fabs(t_start-start)<=epsilon*fabs(t_start))
if(t_start==start || fabs(t_start-start)<=epsilon)
{
timestep[0] = i_start;
} else
{
timestep[0] = (int)ceil(start/dt[0]);
timestep[0] = (int64_t)ceil(start/dt[0]);
}
i_end = fround(end/dt[0]);
double t_end = i_end*dt[0];
if(!(t_end==end || fabs(t_end-end)<=epsilon*fabs(t_end)))
if(!(t_end==end || fabs(t_end-end)<=epsilon))
{
i_end = (int)ceil(end/dt[0]);
i_end = (int64_t)ceil(end/dt[0]);
}
}
private:
Expand Down
2 changes: 1 addition & 1 deletion brian2/devices/cpp_standalone/templates/network.cpp
Expand Up @@ -7,7 +7,7 @@
#include<utility>
{{ openmp_pragma('include') }}

#define Clock_epsilon 1e-14
#define Clock_epsilon 1e-8

double Network::_last_run_time = 0.0;
double Network::_last_run_completed_fraction = 0.0;
Expand Down

0 comments on commit d895265

Please sign in to comment.