22 #if defined(CORENEURON_ENABLE_GPU) && !defined(DISABLE_OPENACC)
36 #if defined(CORENEURON_ENABLE_GPU) && !defined(DISABLE_OPENACC)
41 EIGEN_DEVICE_FUNC
inline int Crout(
int n, T*
const a,
int*
const perm,
double*
const rowmax) {
44 double roundoff = 1.e-20;
45 int i,
j,
k, r, pivot, irow, save_i = 0, krow;
46 T sum, equil_1, equil_2;
50 for (
i = 0;
i <
n;
i++) {
53 for (
j = 1;
j <
n;
j++) {
58 rowmax[
i] = a[
i *
n +
k];
63 for (r = 0; r <
n; r++) {
69 for (
i = r;
i <
n;
i++) {
72 for (
k = 0;
k < r;
k++) {
74 sum += a[irow *
n +
k] * a[krow *
n + r];
76 a[irow *
n + r] -= sum;
82 equil_1 =
std::fabs(a[pivot *
n + r] / rowmax[pivot]);
83 for (
i = r + 1;
i <
n;
i++) {
85 equil_2 =
std::fabs(a[irow *
n + r] / rowmax[irow]);
86 if (equil_2 > equil_1) {
97 if (pivot != perm[r]) {
98 perm[save_i] = perm[r];
114 for (
j = r + 1;
j <
n;
j++) {
116 for (
k = 0;
k < r;
k++) {
118 sum += a[pivot *
n +
k] * a[krow *
n +
j];
120 a[pivot *
n +
j] = (a[pivot *
n +
j] - sum) / a[pivot *
n + r];
125 #if defined(CORENEURON_ENABLE_GPU) && !defined(DISABLE_OPENACC)
136 #define y_(arg) p[y[arg]]
137 #define b_(arg) b[arg]
138 #if defined(CORENEURON_ENABLE_GPU) && !defined(DISABLE_OPENACC)
142 template <
typename T>
147 int const*
const perm,
148 int const*
const y =
nullptr) {
154 for (
i = 0;
i <
n;
i++) {
157 for (
j = 0;
j <
i;
j++) {
158 sum += a[pivot *
n +
j] * (
y_(
j));
160 y_(
i) = (
b_(pivot) - sum) / a[pivot *
n +
i];
170 for (
i =
n - 1;
i >= 0;
i--) {
173 for (
j =
i + 1;
j <
n;
j++) {
174 sum += a[pivot *
n +
j] * (
y_(
j));
179 for (
i = 0;
i <
n;
i++) {
182 for (
j = 0;
j <
i;
j++) {
183 sum += a[pivot *
n +
j] * (
p[
j]);
185 p[
i] = (
b_(pivot) - sum) / a[pivot *
n +
i];
195 for (
i =
n - 1;
i >= 0;
i--) {
198 for (
j =
i + 1;
j <
n;
j++) {
199 sum += a[pivot *
n +
j] * (
p[
j]);
206 #if defined(CORENEURON_ENABLE_GPU) && !defined(DISABLE_OPENACC)
nrn_pragma_acc(routine seq) nrn_pragma_omp(declare target) philox4x32_ctr_t coreneuron_random123_philox4x32_helper(coreneuron nrn_pragma_omp(end declare target) namespace coreneuron
Provide a helper function in global namespace that is declared target for OpenMP offloading to functi...
#define y_(arg)
Crout matrix decomposition : Forward/Backward substitution.
void declare(long subtype, Item *q, Item *qa)
EIGEN_DEVICE_FUNC int Crout(int n, T *const a, int *const perm, double *const rowmax)
Crout matrix decomposition : in-place LU Decomposition of matrix a.
EIGEN_DEVICE_FUNC int solveCrout(int n, T const *const a, T const *const b, T *const p, int const *const perm, int const *const y=nullptr)
encapsulates code generation backend implementations
int const size_t const size_t n
#define nrn_pragma_acc(x)