Skip to content
This repository was archived by the owner on Mar 20, 2023. It is now read-only.

Commit 84d9f73

Browse files
iomaganarispramodk
andauthored
Move at_time inside coreneuron namespace and redefine at_time in ispc (#403)
* Move at_time inside coreneuron namespace and redefine at_time in ispc * Explicitely set uniform and varying in at_time ispc function * Added documentation for the at_time function in C++ and ISPC backends Co-authored-by: Pramod Kumbhar <[email protected]>
1 parent c939968 commit 84d9f73

File tree

3 files changed

+16
-13
lines changed

3 files changed

+16
-13
lines changed

coreneuron/mechanism/membfunc.hpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,8 @@ extern void artcell_net_move(void**, Point_process*, double);
188188
extern void nrn2ncs_outputevent(int netcon_output_index, double firetime);
189189
extern bool nrn_use_localgid_;
190190
extern void net_sem_from_gpu(int sendtype, int i_vdata, int, int ith, int ipnt, double, double);
191+
#pragma acc routine seq
192+
extern int at_time(NrnThread*, double);
191193

192194
// _OPENACC and/or NET_RECEIVE_BUFFERING
193195
extern void net_sem_from_gpu(int, int, int, int, int, double, double);
@@ -196,11 +198,3 @@ extern void hoc_malchk(void); /* just a stub */
196198
extern void* hoc_Emalloc(size_t);
197199

198200
} // namespace coreneuron
199-
200-
/*
201-
* at_time function declared outside of coreneuron namespace
202-
* because it can be also called from ISPC code. That's also
203-
* the reason for extern "C".
204-
*/
205-
#pragma acc routine seq
206-
extern "C" int at_time(coreneuron::NrnThread*, double);

coreneuron/mechanism/nrnoc_ml.ispc

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,5 +168,12 @@ struct NrnThread {
168168

169169
extern uniform double ispc_celsius;
170170

171-
extern "C"
172-
int at_time(NrnThread* nt, varying double te);
171+
// NOTE : this implementation is duplicated from "coreneuron/network/cvodestb.cpp"
172+
// If changes are required, make sure to change CPP as well.
173+
static inline int at_time(uniform NrnThread* nt, varying double te) {
174+
varying double x = te - 1e-11;
175+
if (x <= nt->_t && x > (nt->_t - nt->_dt)) {
176+
return 1;
177+
}
178+
return 0;
179+
}

coreneuron/network/cvodestb.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,14 @@ void fixed_play_continuous(NrnThread* nt) {
105105
}
106106
}
107107

108-
} // namespace coreneuron
109-
110-
extern "C" int at_time(coreneuron::NrnThread* nt, double te) {
108+
// NOTE : this implementation is duplicated in "coreneuron/mechanism/nrnoc_ml.ispc"
109+
// for the ISPC backend. If changes are required, make sure to change ISPC as well.
110+
int at_time(NrnThread* nt, double te) {
111111
double x = te - 1e-11;
112112
if (x <= nt->_t && x > (nt->_t - nt->_dt)) {
113113
return 1;
114114
}
115115
return 0;
116116
}
117+
118+
} // namespace coreneuron

0 commit comments

Comments
 (0)