Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework _STRIDE. #2559

Merged
merged 1 commit into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/coreneuron/mechanism/capac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#define _PRAGMA_FOR_INIT_ACC_LOOP_ \
nrn_pragma_acc(parallel loop present(vdata [0:_cntml_padded * nparm]) if (_nt->compute_gpu)) \
nrn_pragma_omp(target teams distribute parallel for simd if(_nt->compute_gpu))
#define _STRIDE _cntml_padded + _iml
#define CNRN_FLAT_INDEX_IML_ROW(i) ((i) * (_cntml_padded) + (_iml))

namespace coreneuron {

Expand Down Expand Up @@ -45,8 +45,8 @@ void capacitance_reg(void) {
hoc_register_prop_size(mechtype, nparm, 0);
}

#define cm vdata[0 * _STRIDE]
#define i_cap vdata[1 * _STRIDE]
#define cm vdata[CNRN_FLAT_INDEX_IML_ROW(0)]
#define i_cap vdata[CNRN_FLAT_INDEX_IML_ROW(1)]

/*
cj is analogous to 1/dt for cvode and daspk
Expand Down
12 changes: 6 additions & 6 deletions src/coreneuron/mechanism/eion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include "coreneuron/permute/data_layout.hpp"
#include "coreneuron/utils/nrnoc_aux.hpp"

#define _STRIDE _cntml_padded + _iml
#define CNRN_FLAT_INDEX_IML_ROW(i) ((i) * (_cntml_padded) + (_iml))

namespace coreneuron {

Expand Down Expand Up @@ -142,11 +142,11 @@ the USEION statement of any model using this ion\n",
}

#if VECTORIZE
#define erev pd[0 * _STRIDE] /* From Eion */
#define conci pd[1 * _STRIDE]
#define conco pd[2 * _STRIDE]
#define cur pd[3 * _STRIDE]
#define dcurdv pd[4 * _STRIDE]
#define erev pd[CNRN_FLAT_INDEX_IML_ROW(0)] /* From Eion */
#define conci pd[CNRN_FLAT_INDEX_IML_ROW(1)]
#define conco pd[CNRN_FLAT_INDEX_IML_ROW(2)]
#define cur pd[CNRN_FLAT_INDEX_IML_ROW(3)]
#define dcurdv pd[CNRN_FLAT_INDEX_IML_ROW(4)]

/*
handle erev, conci, conc0 "in the right way" according to ion_style
Expand Down
4 changes: 2 additions & 2 deletions src/coreneuron/mechanism/mech/mod2c_core_thread.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

namespace coreneuron {

#define _STRIDE _cntml_padded + _iml
#define CNRN_FLAT_INDEX_IML_ROW(i) ((i) * (_cntml_padded) + (_iml))

#define _threadargscomma_ _iml, _cntml_padded, _p, _ppvar, _thread, _nt, _ml, _v,
#define _threadargsprotocomma_ \
Expand Down Expand Up @@ -77,7 +77,7 @@ int euler_thread(int neqn, int* var, int* der, F fun, _threadargsproto_) {
fun(_threadargs_); // std::invoke in C++17
/* update dependent variables */
for (int i = 0; i < neqn; i++) {
_p[var[i] * _STRIDE] += dt * (_p[der[i] * _STRIDE]);
_p[CNRN_FLAT_INDEX_IML_ROW(var[i])] += dt * (_p[CNRN_FLAT_INDEX_IML_ROW(der[i])]);
}
return 0;
}
Expand Down
4 changes: 2 additions & 2 deletions src/coreneuron/sim/scopmath/crout_thread.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ namespace coreneuron {
#error "naming clash on crout_thread.hpp-internal macros"
#endif
#define scopmath_crout_b(arg) b[scopmath_crout_ix(arg)]
#define scopmath_crout_ix(arg) ((arg) *_STRIDE)
#define scopmath_crout_y(arg) _p[y[arg] * _STRIDE]
#define scopmath_crout_ix(arg) CNRN_FLAT_INDEX_IML_ROW(arg)
#define scopmath_crout_y(arg) _p[CNRN_FLAT_INDEX_IML_ROW(y[arg])]

/**
* Performs an LU triangular factorization of a real matrix by the Crout
Expand Down
6 changes: 3 additions & 3 deletions src/coreneuron/sim/scopmath/newton_thread.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ namespace coreneuron {
#if defined(scopmath_newton_ix) || defined(scopmath_newton_s) || defined(scopmath_newton_x)
#error "naming clash on newton_thread.hpp-internal macros"
#endif
#define scopmath_newton_ix(arg) ((arg) *_STRIDE)
#define scopmath_newton_s(arg) _p[s[arg] * _STRIDE]
#define scopmath_newton_x(arg) _p[(arg) *_STRIDE]
#define scopmath_newton_ix(arg) CNRN_FLAT_INDEX_IML_ROW(arg)
#define scopmath_newton_s(arg) _p[CNRN_FLAT_INDEX_IML_ROW(s[arg])]
#define scopmath_newton_x(arg) _p[CNRN_FLAT_INDEX_IML_ROW(arg)]
namespace detail {
/**
* @brief Calculate the Jacobian matrix using finite central differences.
Expand Down
4 changes: 2 additions & 2 deletions src/coreneuron/sim/scopmath/sparse_thread.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ inline void init_coef_list(SparseObj* so, int _iml) {
defined(scopmath_sparse_x)
#error "naming clash on sparse_thread.hpp-internal macros"
#endif
#define scopmath_sparse_ix(arg) ((arg) *_STRIDE)
#define scopmath_sparse_ix(arg) CNRN_FLAT_INDEX_IML_ROW(arg)
inline void subrow(SparseObj* so, Elm* pivot, Elm* rowsub, int _iml) {
unsigned int const _cntml_padded{so->_cntml_padded};
double const r{rowsub->value[_iml] / pivot->value[_iml]};
Expand Down Expand Up @@ -602,7 +602,7 @@ int sparse_thread(SparseObj* so,
#undef scopmath_sparse_d
#undef scopmath_sparse_ix
#undef scopmath_sparse_s
#define scopmath_sparse_x(arg) _p[x[arg] * _STRIDE]
#define scopmath_sparse_x(arg) _p[CNRN_FLAT_INDEX_IML_ROW(x[arg])]
/* for solving ax=b */
template <typename SPFUN>
int _cvode_sparse_thread(void** vpr, int n, int* x, SPFUN fun, _threadargsproto_) {
Expand Down
2 changes: 1 addition & 1 deletion src/coreneuron/sim/scopmath/ssimplic_thread.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace coreneuron {
#if defined(scopmath_ssimplic_s)
#error "naming clash on ssimplic_thread.hpp-internal macros"
#endif
#define scopmath_ssimplic_s(arg) _p[s[arg] * _STRIDE]
#define scopmath_ssimplic_s(arg) _p[CNRN_FLAT_INDEX_IML_ROW(s[arg])]
static int check_state(int n, int* s, _threadargsproto_) {
bool flag{true};
for (int i = 0; i < n; i++) {
Expand Down
Loading