1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519
|
/* Created by Language version: 6.2.0 */
/* VECTORIZED */
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#undef PI
#include "coreneuron/utils/randoms/nrnran123.h"
#include "coreneuron/nrnoc/md1redef.h"
#include "coreneuron/nrnconf.h"
#include "coreneuron/sim/multicore.hpp"
#include "coreneuron/nrniv/nrniv_decl.h"
#include "coreneuron/utils/ivocvect.hpp"
#include "coreneuron/utils/nrnoc_aux.hpp"
#include "coreneuron/gpu/nrn_acc_manager.hpp"
#include "coreneuron/sim/scopmath/newton_struct.h"
#include "coreneuron/sim/scopmath/newton_thread.hpp"
#include "coreneuron/sim/scopmath/sparse_thread.hpp"
#include "coreneuron/sim/scopmath/ssimplic_thread.hpp"
#include "coreneuron/nrnoc/md2redef.h"
#include "coreneuron/mechanism/register_mech.hpp"
#if !NRNGPU
#if !defined(DISABLE_HOC_EXP)
#undef exp
#define exp hoc_Exp
#endif
#endif
namespace coreneuron {
#define _thread_present_ /**/ , _slist1[0:1], _dlist1[0:1]
#if defined(_OPENACC) && !defined(DISABLE_OPENACC)
#include <openacc.h>
#define _PRAGMA_FOR_INIT_ACC_LOOP_ _Pragma("acc parallel loop present(_ni[0:_cntml_actual], _nt_data[0:_nt->_ndata], _p[0:_cntml_padded*_psize], _ppvar[0:_cntml_padded*_ppsize], _vec_v[0:_nt->end], nrn_ion_global_map[0:nrn_ion_global_map_size][0:ion_global_map_member_size], _nt[0:1] _thread_present_) if(_nt->compute_gpu)")
#define _PRAGMA_FOR_STATE_ACC_LOOP_ _Pragma("acc parallel loop present(_ni[0:_cntml_actual], _nt_data[0:_nt->_ndata], _p[0:_cntml_padded*_psize], _ppvar[0:_cntml_padded*_ppsize], _vec_v[0:_nt->end], _nt[0:1], _ml[0:1] _thread_present_) if(_nt->compute_gpu) async(stream_id)")
#define _PRAGMA_FOR_CUR_ACC_LOOP_ _Pragma("acc parallel loop present(_ni[0:_cntml_actual], _nt_data[0:_nt->_ndata], _p[0:_cntml_padded*_psize], _ppvar[0:_cntml_padded*_ppsize], _vec_v[0:_nt->end], _vec_d[0:_nt->end], _vec_rhs[0:_nt->end], _nt[0:1] _thread_present_) if(_nt->compute_gpu) async(stream_id)")
#define _PRAGMA_FOR_CUR_SYN_ACC_LOOP_ _Pragma("acc parallel loop present(_ni[0:_cntml_actual], _nt_data[0:_nt->_ndata], _p[0:_cntml_padded*_psize], _ppvar[0:_cntml_padded*_ppsize], _vec_v[0:_nt->end], _vec_shadow_rhs[0:_nt->shadow_rhs_cnt], _vec_shadow_d[0:_nt->shadow_rhs_cnt], _vec_d[0:_nt->end], _vec_rhs[0:_nt->end], _nt[0:1]) if(_nt->compute_gpu) async(stream_id)")
#define _PRAGMA_FOR_NETRECV_ACC_LOOP_ _Pragma("acc parallel loop present(_pnt[0:_pnt_length], _nrb[0:1], _nt[0:1], nrn_threads[0:nrn_nthread]) if(_nt->compute_gpu) async(stream_id)")
#else
#define _PRAGMA_FOR_INIT_ACC_LOOP_ _Pragma("")
#define _PRAGMA_FOR_STATE_ACC_LOOP_ _Pragma("")
#define _PRAGMA_FOR_CUR_ACC_LOOP_ _Pragma("")
#define _PRAGMA_FOR_CUR_SYN_ACC_LOOP_ _Pragma("")
#define _PRAGMA_FOR_NETRECV_ACC_LOOP_ _Pragma("")
#endif
#if defined(__ICC) || defined(__INTEL_COMPILER)
#define _PRAGMA_FOR_VECTOR_LOOP_ _Pragma("ivdep")
#elif defined(__IBMC__) || defined(__IBMCPP__)
#define _PRAGMA_FOR_VECTOR_LOOP_ _Pragma("ibm independent_loop")
#elif defined(__PGI)
#define _PRAGMA_FOR_VECTOR_LOOP_ _Pragma("vector")
#elif defined(_CRAYC)
#define _PRAGMA_FOR_VECTOR_LOOP_ _Pragma("_CRI ivdep")
#elif defined(__clang__)
#define _PRAGMA_FOR_VECTOR_LOOP_ _Pragma("clang loop vectorize(enable)")
#elif defined(__GNUC__) || defined(__GNUG__)
#define _PRAGMA_FOR_VECTOR_LOOP_ _Pragma("GCC ivdep")
#else
#define _PRAGMA_FOR_VECTOR_LOOP_
#endif // _PRAGMA_FOR_VECTOR_LOOP_
#if !defined(LAYOUT)
/* 1 means AoS, >1 means AoSoA, <= 0 means SOA */
#define LAYOUT 1
#endif
#if LAYOUT >= 1
#define _STRIDE LAYOUT
#else
#define _STRIDE _cntml_padded + _iml
#endif
#define nrn_init _nrn_init__Nap_No
#define nrn_cur _nrn_cur__Nap_No
#define _nrn_current _nrn_current__Nap_No
#define nrn_jacob _nrn_jacob__Nap_No
#define nrn_state _nrn_state__Nap_No
#define initmodel initmodel__Nap_No
#define _net_receive _net_receive__Nap_No
#define _net_init _net_init__Nap_No
#define nrn_state_launcher nrn_state_Nap_No_launcher
#define nrn_cur_launcher nrn_cur_Nap_No_launcher
#define nrn_jacob_launcher nrn_jacob_Nap_No_launcher
#define rates rates_Nap_No
#define states states_Nap_No
#undef _threadargscomma_
#undef _threadargsprotocomma_
#undef _threadargs_
#undef _threadargsproto_
#define _threadargscomma_ _iml, _cntml_padded, _p, _ppvar, _thread, _nt, v,
#define _threadargsprotocomma_ int _iml, int _cntml_padded, double* _p, Datum* _ppvar, ThreadDatum* _thread, NrnThread* _nt, double v,
#define _threadargs_ _iml, _cntml_padded, _p, _ppvar, _thread, _nt, v
#define _threadargsproto_ int _iml, int _cntml_padded, double* _p, Datum* _ppvar, ThreadDatum* _thread, NrnThread* _nt, double v
/*SUPPRESS 761*/
/*SUPPRESS 762*/
/*SUPPRESS 763*/
/*SUPPRESS 765*/
/* Thread safe. No static _p or _ppvar. */
#define t _nt->_t
#define dt _nt->_dt
#define gnamax _p[0*_STRIDE]
#define gna _p[1*_STRIDE]
#define pinf _p[2*_STRIDE]
#define ptau _p[3*_STRIDE]
#define p _p[4*_STRIDE]
#define Dp _p[5*_STRIDE]
#define ena _p[6*_STRIDE]
#define ina _p[7*_STRIDE]
#define _v_unused _p[8*_STRIDE]
#define _g_unused _p[9*_STRIDE]
#ifndef NRN_PRCELLSTATE
#define NRN_PRCELLSTATE 0
#endif
#if NRN_PRCELLSTATE
#define _PRCELLSTATE_V _v_unused = _v;
#define _PRCELLSTATE_G _g_unused = _g;
#else
#define _PRCELLSTATE_V /**/
#define _PRCELLSTATE_G /**/
#endif
#define _ion_ena _nt_data[_ppvar[0*_STRIDE]]
#define _ion_ina _nt_data[_ppvar[1*_STRIDE]]
#define _ion_dinadv _nt_data[_ppvar[2*_STRIDE]]
#if MAC
#if !defined(v)
#define v _mlhv
#endif
#if !defined(h)
#define h _mlhh
#endif
#endif
static int hoc_nrnpointerindex = -1;
static ThreadDatum* _extcall_thread;
/* external NEURON variables */
#if 0 /*BBCORE*/
/* declaration of user functions */
static void _hoc_rates(void);
static void _hoc_vtrap(void);
#endif /*BBCORE*/
static int _mechtype;
#if 0 /*BBCORE*/
/* connect user functions to hoc names */
static VoidFunc hoc_intfunc[] = {
"setdata_Nap_No", _hoc_setdata,
"rates_Nap_No", _hoc_rates,
"vtrap_Nap_No", _hoc_vtrap,
0, 0
};
#endif /*BBCORE*/
#define vtrap vtrap_Nap_No
#pragma acc routine seq
inline double vtrap( _threadargsprotocomma_ double , double );
/* declare global and static user variables */
static void _acc_globals_update() {
}
#if 0 /*BBCORE*/
/* some parameters have upper and lower limits */
static HocParmLimits _hoc_parm_limits[] = {
"gnamax_Nap_No", 0, 1e+09,
0,0,0
};
static HocParmUnits _hoc_parm_units[] = {
"gnamax_Nap_No", "S/cm2",
"gna_Nap_No", "S/cm2",
"ptau_Nap_No", "ms",
0,0
};
#endif /*BBCORE*/
static double delta_t = 0.01;
#pragma acc declare copyin(delta_t)
static double p0 = 0;
#pragma acc declare copyin(p0)
/* connect global user variables to hoc */
static DoubScal hoc_scdoub[] = {
0,0
};
static DoubVec hoc_vdoub[] = {
0,0,0
};
static double _sav_indep;
static void nrn_alloc(double*, Datum*, int);
void nrn_init(NrnThread*, Memb_list*, int);
void nrn_state(NrnThread*, Memb_list*, int);
void nrn_cur(NrnThread*, Memb_list*, int);
/* connect range variables in _p that hoc is supposed to know about */
static const char *_mechanism[] = {
"6.2.0",
"Nap_No",
"gnamax_Nap_No",
0,
"gna_Nap_No",
"pinf_Nap_No",
"ptau_Nap_No",
0,
"p_Nap_No",
0,
0};
static int _na_type;
static void nrn_alloc(double* _p, Datum* _ppvar, int _type) {
#if 0 /*BBCORE*/
/*initialize range parameters*/
gnamax = 0.01;
prop_ion = need_memb(_na_sym);
nrn_promote(prop_ion, 0, 1);
_ppvar[0]._pval = &prop_ion->param[0]; /* ena */
_ppvar[1]._pval = &prop_ion->param[3]; /* ina */
_ppvar[2]._pval = &prop_ion->param[4]; /* _ion_dinadv */
#endif /* BBCORE */
}
static void _initlists();
static void _update_ion_pointer(Datum*);
#define _psize 10
#define _ppsize 3
void _Nap_No_reg() {
int _vectorized = 1;
_initlists();
_mechtype = nrn_get_mechtype(_mechanism[1]);
if (_mechtype == -1) return;
_nrn_layout_reg(_mechtype, LAYOUT);
_na_type = nrn_get_mechtype("na_ion");
#if 0 /*BBCORE*/
ion_reg("na", -10000.);
_na_sym = hoc_lookup("na_ion");
#endif /*BBCORE*/
register_mech(_mechanism, nrn_alloc,nrn_cur, NULL, nrn_state, nrn_init, hoc_nrnpointerindex, 1);
hoc_register_prop_size(_mechtype, _psize, _ppsize);
hoc_register_dparam_semantics(_mechtype, 0, "na_ion");
hoc_register_dparam_semantics(_mechtype, 1, "na_ion");
hoc_register_dparam_semantics(_mechtype, 2, "na_ion");
hoc_register_var(hoc_scdoub, hoc_vdoub, NULL);
}
static const char *modelname = "Nap_No.mod persistent sodium current";
static int error;
static int _ninits = 0;
static int _match_recurse=1;
static void _modl_cleanup(){ _match_recurse=1;}
static inline int rates(_threadargsprotocomma_ double);
static int _ode_spec1(_threadargsproto_);
/*static int _ode_matsol1(_threadargsproto_);*/
#define _slist1 _slist1_Nap_No
int* _slist1;
#pragma acc declare create(_slist1)
#define _dlist1 _dlist1_Nap_No
int* _dlist1;
#pragma acc declare create(_dlist1)
static inline int states(_threadargsproto_);
/*CVODE*/
static int _ode_spec1 (_threadargsproto_) {int _reset = 0; {
rates ( _threadargscomma_ v ) ;
Dp = ( pinf - p ) / ptau ;
}
return _reset;
}
static int _ode_matsol1 (_threadargsproto_) {
rates ( _threadargscomma_ v ) ;
Dp = Dp / (1. - dt*( ( ( ( - 1.0 ) ) ) / ptau )) ;
return 0;
}
/*END CVODE*/
static int states (_threadargsproto_) { {
rates ( _threadargscomma_ v ) ;
p = p + (1. - exp(dt*(( ( ( - 1.0 ) ) ) / ptau)))*(- ( ( ( pinf ) ) / ptau ) / ( ( ( ( - 1.0) ) ) / ptau ) - p) ;
}
return 0;
}
static int rates ( _threadargsprotocomma_ double _lv ) {
double _lalpha , _lbeta , _lsum ;
_lalpha = 0.0353 * vtrap ( _threadargscomma_ - 17.0 - _lv , 10.2 ) ;
_lbeta = 0.000883 * vtrap ( _threadargscomma_ _lv + 24.0 , 10.0 ) ;
_lsum = _lalpha + _lbeta ;
ptau = 1.0 / _lsum ;
pinf = _lalpha / _lsum ;
return 0; }
#if 0 /*BBCORE*/
static void _hoc_rates(void) {
double _r;
double* _p; Datum* _ppvar; ThreadDatum* _thread; NrnThread* _nt;
if (_extcall_prop) {_p = _extcall_prop->param; _ppvar = _extcall_prop->dparam;}else{ _p = (double*)0; _ppvar = (Datum*)0; }
_thread = _extcall_thread;
_nt = nrn_threads;
_r = 1.;
rates ( _threadargs_, *getarg(1) ;
hoc_retpushx(_r);
}
#endif /*BBCORE*/
double vtrap ( _threadargsprotocomma_ double _lx , double _ly ) {
double _lvtrap;
if ( fabs ( _lx / _ly ) < 1e-6 ) {
_lvtrap = _ly * ( 1.0 - _lx / _ly / 2.0 ) ;
}
else {
_lvtrap = _lx / ( exp ( _lx / _ly ) - 1.0 ) ;
}
return _lvtrap;
}
#if 0 /*BBCORE*/
static void _hoc_vtrap(void) {
double _r;
double* _p; Datum* _ppvar; ThreadDatum* _thread; NrnThread* _nt;
if (_extcall_prop) {_p = _extcall_prop->param; _ppvar = _extcall_prop->dparam;}else{ _p = (double*)0; _ppvar = (Datum*)0; }
_thread = _extcall_thread;
_nt = nrn_threads;
_r = vtrap ( _threadargs_, *getarg(1) , *getarg(2) ;
hoc_retpushx(_r);
}
#endif /*BBCORE*/
static void _update_ion_pointer(Datum* _ppvar) {
}
static inline void initmodel(_threadargsproto_) {
int _i; double _save;{
p = p0;
{
rates ( _threadargscomma_ v ) ;
p = pinf ;
}
}
}
void nrn_init(NrnThread* _nt, Memb_list* _ml, int _type){
double* _p; Datum* _ppvar; ThreadDatum* _thread;
double _v, v; int* _ni; int _iml, _cntml_padded, _cntml_actual;
_ni = _ml->_nodeindices;
_cntml_actual = _ml->_nodecount;
_cntml_padded = _ml->_nodecount_padded;
_thread = _ml->_thread;
_acc_globals_update();
double * _nt_data = _nt->_data;
double * _vec_v = _nt->_actual_v;
int stream_id = _nt->stream_id;
if (_nrn_skip_initmodel == 0) {
#if LAYOUT == 1 /*AoS*/
for (_iml = 0; _iml < _cntml_actual; ++_iml) {
_p = _ml->_data + _iml*_psize; _ppvar = _ml->_pdata + _iml*_ppsize;
#elif LAYOUT == 0 /*SoA*/
_p = _ml->_data; _ppvar = _ml->_pdata;
/* insert compiler dependent ivdep like pragma */
_PRAGMA_FOR_VECTOR_LOOP_
_PRAGMA_FOR_INIT_ACC_LOOP_
for (_iml = 0; _iml < _cntml_actual; ++_iml) {
#else /* LAYOUT > 1 */ /*AoSoA*/
#error AoSoA not implemented.
for (;;) { /* help clang-format properly indent */
#endif
int _nd_idx = _ni[_iml];
_v = _vec_v[_nd_idx];
_PRCELLSTATE_V
v = _v;
_PRCELLSTATE_V
ena = _ion_ena;
initmodel(_threadargs_);
}
}
}
static double _nrn_current(_threadargsproto_, double _v){double _current=0.;v=_v;{ {
gna = gnamax * p * p * p ;
ina = gna * ( v - ena ) ;
}
_current += ina;
} return _current;
}
#if defined(ENABLE_CUDA_INTERFACE) && defined(_OPENACC)
void nrn_state_launcher(NrnThread*, Memb_list*, int, int);
void nrn_jacob_launcher(NrnThread*, Memb_list*, int, int);
void nrn_cur_launcher(NrnThread*, Memb_list*, int, int);
#endif
void nrn_cur(NrnThread* _nt, Memb_list* _ml, int _type) {
double* _p; Datum* _ppvar; ThreadDatum* _thread;
int* _ni; double _rhs, _g, _v, v; int _iml, _cntml_padded, _cntml_actual;
_ni = _ml->_nodeindices;
_cntml_actual = _ml->_nodecount;
_cntml_padded = _ml->_nodecount_padded;
_thread = _ml->_thread;
double * _vec_rhs = _nt->_actual_rhs;
double * _vec_d = _nt->_actual_d;
#if defined(ENABLE_CUDA_INTERFACE) && defined(_OPENACC) && !defined(DISABLE_OPENACC)
NrnThread* d_nt = acc_deviceptr(_nt);
Memb_list* d_ml = acc_deviceptr(_ml);
nrn_cur_launcher(d_nt, d_ml, _type, _cntml_actual);
return;
#endif
double * _nt_data = _nt->_data;
double * _vec_v = _nt->_actual_v;
int stream_id = _nt->stream_id;
#if LAYOUT == 1 /*AoS*/
for (_iml = 0; _iml < _cntml_actual; ++_iml) {
_p = _ml->_data + _iml*_psize; _ppvar = _ml->_pdata + _iml*_ppsize;
#elif LAYOUT == 0 /*SoA*/
_p = _ml->_data; _ppvar = _ml->_pdata;
/* insert compiler dependent ivdep like pragma */
_PRAGMA_FOR_VECTOR_LOOP_
_PRAGMA_FOR_CUR_ACC_LOOP_
for (_iml = 0; _iml < _cntml_actual; ++_iml) {
#else /* LAYOUT > 1 */ /*AoSoA*/
#error AoSoA not implemented.
for (;;) { /* help clang-format properly indent */
#endif
int _nd_idx = _ni[_iml];
_v = _vec_v[_nd_idx];
_PRCELLSTATE_V
ena = _ion_ena;
_g = _nrn_current(_threadargs_, _v + .001);
{ double _dina;
_dina = ina;
_rhs = _nrn_current(_threadargs_, _v);
_ion_dinadv += (_dina - ina)/.001 ;
}
_g = (_g - _rhs)/.001;
_ion_ina += ina ;
_PRCELLSTATE_G
_vec_rhs[_nd_idx] -= _rhs;
_vec_d[_nd_idx] += _g;
}
}
void nrn_state(NrnThread* _nt, Memb_list* _ml, int _type) {
double* _p; Datum* _ppvar; ThreadDatum* _thread;
double v, _v = 0.0; int* _ni; int _iml, _cntml_padded, _cntml_actual;
_ni = _ml->_nodeindices;
_cntml_actual = _ml->_nodecount;
_cntml_padded = _ml->_nodecount_padded;
_thread = _ml->_thread;
#if defined(ENABLE_CUDA_INTERFACE) && defined(_OPENACC) && !defined(DISABLE_OPENACC)
NrnThread* d_nt = acc_deviceptr(_nt);
Memb_list* d_ml = acc_deviceptr(_ml);
nrn_state_launcher(d_nt, d_ml, _type, _cntml_actual);
return;
#endif
double * _nt_data = _nt->_data;
double * _vec_v = _nt->_actual_v;
int stream_id = _nt->stream_id;
#if LAYOUT == 1 /*AoS*/
for (_iml = 0; _iml < _cntml_actual; ++_iml) {
_p = _ml->_data + _iml*_psize; _ppvar = _ml->_pdata + _iml*_ppsize;
#elif LAYOUT == 0 /*SoA*/
_p = _ml->_data; _ppvar = _ml->_pdata;
/* insert compiler dependent ivdep like pragma */
_PRAGMA_FOR_VECTOR_LOOP_
_PRAGMA_FOR_STATE_ACC_LOOP_
for (_iml = 0; _iml < _cntml_actual; ++_iml) {
#else /* LAYOUT > 1 */ /*AoSoA*/
#error AoSoA not implemented.
for (;;) { /* help clang-format properly indent */
#endif
int _nd_idx = _ni[_iml];
_v = _vec_v[_nd_idx];
_PRCELLSTATE_V
v=_v;
{
ena = _ion_ena;
{ states(_threadargs_);
} }}
}
static void terminal(){}
static void _initlists(){
double _x; double* _p = &_x;
int _i; static int _first = 1;
int _cntml_actual=1;
int _cntml_padded=1;
int _iml=0;
if (!_first) return;
_slist1 = (int*)malloc(sizeof(int)*1);
_dlist1 = (int*)malloc(sizeof(int)*1);
_slist1[0] = &(p) - _p; _dlist1[0] = &(Dp) - _p;
#pragma acc enter data copyin(_slist1[0:1])
#pragma acc enter data copyin(_dlist1[0:1])
_first = 0;
}
} // namespace coreneuron_lib
|