NEURON
nvector_nrnthread_ld.cpp
Go to the documentation of this file.
1 /*
2  * -----------------------------------------------------------------
3  * $Revision: 855 $
4  * $Date: 2005-02-09 18:15:46 -0500 (Wed, 09 Feb 2005) $
5  * -----------------------------------------------------------------
6  * Programmer(s): Scott D. Cohen, Alan C. Hindmarsh, Radu Serban,
7  * and Aaron Collier @ LLNL
8  * -----------------------------------------------------------------
9  * Copyright (c) 2002, The Regents of the University of California.
10  * Produced at the Lawrence Livermore National Laboratory.
11  * All rights reserved.
12  * For details, see sundials/shared/LICENSE.
13  * -----------------------------------------------------------------
14  * This is the implementation file for a nrnthread implementation
15  * of the NVECTOR package.
16  * -----------------------------------------------------------------
17  */
18 
19 #include <stdio.h>
20 #include <stdlib.h>
21 
22 #include "shared/nvector_serial.h"
23 #include "nvector_nrnthread_ld.h"
24 #include "shared/sundialsmath.h"
25 #include "shared/sundialstypes.h"
26 #include "section.h"
27 #include "nrnmutdec.h"
28 
29 #define ZERO RCONST(0.0)
30 #define HALF RCONST(0.5)
31 #define ONE RCONST(1.0)
32 #define ONEPT5 RCONST(1.5)
33 
34 #if 0
35 #define mydebug(a) printf(a)
36 #define mydebug2(a, b) printf(a, b)
37 #else
38 #define mydebug(a) /**/
39 #define mydebug2(a, b) /**/
40 #endif
41 
42 #if NRN_ENABLE_THREADS
43 static MUTDEC
44 #endif
45 /* argument passing between NrnThreadLD and Serial */
46 static N_Vector x_;
47 static N_Vector y_;
48 static N_Vector z_;
49 static N_Vector w_;
50 static N_Vector id_;
51 static realtype a_;
52 static realtype b_;
53 static realtype c_;
54 static realtype retval;
55 // for use alongside retval in Kahan summation that replaces old long double code
56 static realtype retval_comp;
57 static booleantype bretval;
58 #define xpass x_ = x;
59 #define ypass y_ = y;
60 #define zpass z_ = z;
61 #define wpass w_ = w;
62 #define idpass id_ = id;
63 #define apass a_ = a;
64 #define bpass b_ = b;
65 #define cpass c_ = c;
66 #define xarg(i) NV_SUBVEC_NT_LD(x_, i)
67 #define yarg(i) NV_SUBVEC_NT_LD(y_, i)
68 #define zarg(i) NV_SUBVEC_NT_LD(z_, i)
69 #define warg(i) NV_SUBVEC_NT_LD(w_, i)
70 #define idarg(i) NV_SUBVEC_NT_LD(id_, i)
71 #define aarg a_
72 #define barg b_
73 #define carg c_
74 #define lock MUTLOCK
75 #define unlock MUTUNLOCK
76 #define lockadd(arg) \
77  lock; \
78  retval += arg; \
79  unlock;
80 #define lockmax(arg) \
81  lock; \
82  if (retval < arg) { \
83  retval = arg; \
84  }; \
85  unlock;
86 #define lockmin(arg) \
87  lock; \
88  if (retval > arg) { \
89  retval = arg; \
90  }; \
91  unlock;
92 #define lockfalse \
93  lock; \
94  bretval = FALSE; \
95  unlock;
96 
97 /*
98  * -----------------------------------------------------------------
99  * exported functions
100  * -----------------------------------------------------------------
101  */
102 
103 /* ----------------------------------------------------------------------------
104  * Function to create a new empty nrnthread vector
105  */
106 
107 N_Vector N_VNewEmpty_NrnThreadLD(long int length, int nthread, long int* sizes) {
108  int i;
109  N_Vector v;
110  N_Vector_Ops ops;
112 
113  if (!MUTCONSTRUCTED) {
114  MUTCONSTRUCT(1)
115  }
116 
117  /* Create vector */
118  v = (N_Vector) malloc(sizeof *v);
119  if (v == NULL)
120  return (NULL);
121 
122  /* Create vector operation structure */
123  ops = (N_Vector_Ops) malloc(sizeof(struct _generic_N_Vector_Ops));
124  if (ops == NULL) {
125  free(v);
126  return (NULL);
127  }
128 
129  ops->nvclone = N_VClone_NrnThreadLD;
130  ops->nvdestroy = N_VDestroy_NrnThreadLD;
131  ops->nvspace = N_VSpace_NrnThreadLD;
132  ops->nvgetarraypointer = N_VGetArrayPointer_NrnThreadLD;
133  ops->nvsetarraypointer = N_VSetArrayPointer_NrnThreadLD;
134  ops->nvlinearsum = N_VLinearSum_NrnThreadLD;
135  ops->nvconst = N_VConst_NrnThreadLD;
136  ops->nvprod = N_VProd_NrnThreadLD;
137  ops->nvdiv = N_VDiv_NrnThreadLD;
138  ops->nvscale = N_VScale_NrnThreadLD;
139  ops->nvabs = N_VAbs_NrnThreadLD;
140  ops->nvinv = N_VInv_NrnThreadLD;
141  ops->nvaddconst = N_VAddConst_NrnThreadLD;
142  ops->nvdotprod = N_VDotProd_NrnThreadLD;
143  ops->nvmaxnorm = N_VMaxNorm_NrnThreadLD;
144  ops->nvwrmsnormmask = N_VWrmsNormMask_NrnThreadLD;
145  ops->nvwrmsnorm = N_VWrmsNorm_NrnThreadLD;
146  ops->nvmin = N_VMin_NrnThreadLD;
147  ops->nvwl2norm = N_VWL2Norm_NrnThreadLD;
148  ops->nvl1norm = N_VL1Norm_NrnThreadLD;
149  ops->nvcompare = N_VCompare_NrnThreadLD;
150  ops->nvinvtest = N_VInvTest_NrnThreadLD;
151  ops->nvconstrmask = N_VConstrMask_NrnThreadLD;
152  ops->nvminquotient = N_VMinQuotient_NrnThreadLD;
153 
154  /* Create content */
155  content = (N_VectorContent_NrnThreadLD) malloc(sizeof(struct _N_VectorContent_NrnThreadLD));
156  if (content == NULL) {
157  free(ops);
158  free(v);
159  return (NULL);
160  }
161 
162  content->length = length;
163  content->nt = nthread;
164  content->own_data = FALSE;
165  content->data = (N_Vector*) malloc(sizeof(N_Vector) * nthread);
166  if (content->data == NULL) {
167  free(ops);
168  free(v);
169  free(content);
170  return (NULL);
171  }
172  for (i = 0; i < nthread; ++i) {
173  content->data[i] = NULL;
174  }
175  /* Attach content and ops */
176  v->content = content;
177  v->ops = ops;
178 
179  return (v);
180 }
181 
182 /* ----------------------------------------------------------------------------
183  * Function to create a new nrnthread vector
184  */
185 
186 N_Vector N_VNew_NrnThreadLD(long int length, int nthread, long int* sizes) {
187  int i;
188  N_Vector v;
189  N_Vector data;
191 
192  v = N_VNewEmpty_NrnThreadLD(length, nthread, sizes);
193  if (v == NULL)
194  return (NULL);
195 
196  /* Create data */
197  if (length > 0) {
198  /* Allocate memory */
200  for (i = 0; i < nthread; ++i) {
201  data = N_VNew_Serial(sizes[i]);
202  if (data == NULL) {
204  return (NULL);
205  }
206  NV_SUBVEC_NT_LD(v, i) = data;
207  }
208  }
209 
210  return (v);
211 }
212 
213 /* ----------------------------------------------------------------------------
214  * Function to clone from a template a new vector with empty (NULL) data array
215  */
216 
217 N_Vector N_VCloneEmpty_NrnThreadLD(N_Vector w) {
218  int i;
219  N_Vector v;
220  N_Vector_Ops ops;
223 
224  if (w == NULL)
225  return (NULL);
226 
227  /* Create vector */
228  v = (N_Vector) malloc(sizeof *v);
229  if (v == NULL)
230  return (NULL);
231 
232  /* Create vector operation structure */
233  ops = (N_Vector_Ops) malloc(sizeof(struct _generic_N_Vector_Ops));
234  if (ops == NULL) {
235  free(v);
236  return (NULL);
237  }
238 
239  ops->nvclone = w->ops->nvclone;
240  ops->nvdestroy = w->ops->nvdestroy;
241  ops->nvspace = w->ops->nvspace;
242  ops->nvgetarraypointer = w->ops->nvgetarraypointer;
243  ops->nvsetarraypointer = w->ops->nvsetarraypointer;
244  ops->nvlinearsum = w->ops->nvlinearsum;
245  ops->nvconst = w->ops->nvconst;
246  ops->nvprod = w->ops->nvprod;
247  ops->nvdiv = w->ops->nvdiv;
248  ops->nvscale = w->ops->nvscale;
249  ops->nvabs = w->ops->nvabs;
250  ops->nvinv = w->ops->nvinv;
251  ops->nvaddconst = w->ops->nvaddconst;
252  ops->nvdotprod = w->ops->nvdotprod;
253  ops->nvmaxnorm = w->ops->nvmaxnorm;
254  ops->nvwrmsnormmask = w->ops->nvwrmsnormmask;
255  ops->nvwrmsnorm = w->ops->nvwrmsnorm;
256  ops->nvmin = w->ops->nvmin;
257  ops->nvwl2norm = w->ops->nvwl2norm;
258  ops->nvl1norm = w->ops->nvl1norm;
259  ops->nvcompare = w->ops->nvcompare;
260  ops->nvinvtest = w->ops->nvinvtest;
261  ops->nvconstrmask = w->ops->nvconstrmask;
262  ops->nvminquotient = w->ops->nvminquotient;
263 
264  /* Create content */
265  content = (N_VectorContent_NrnThreadLD) malloc(sizeof(struct _N_VectorContent_NrnThreadLD));
266  if (content == NULL) {
267  free(ops);
268  free(v);
269  return (NULL);
270  }
271 
272  wcontent = NV_CONTENT_NT_LD(w);
273  content->length = NV_LENGTH_NT_LD(w);
274  content->own_data = FALSE;
275  content->nt = wcontent->nt;
276  content->data = (N_Vector*) malloc(sizeof(N_Vector) * content->nt);
277  if (content->data == NULL) {
278  free(ops);
279  free(v);
280  free(content);
281  return (NULL);
282  }
283  for (i = 0; i < content->nt; ++i) {
284  content->data[i] = NULL;
285  }
286 
287  /* Attach content and ops */
288  v->content = content;
289  v->ops = ops;
290 
291  return (v);
292 }
293 
294 /* ----------------------------------------------------------------------------
295  * Function to create a nrnthread N_Vector with user data component
296  */
297 
298 N_Vector N_VMake_NrnThreadLD(long int length, realtype* v_data) {
299  N_Vector v = NULL;
300 
301  assert(0);
302 #if 0
303  v = N_VNewEmpty_NrnThreadLD(length);
304  if (v == NULL) return(NULL);
305 
306  if (length > 0) {
307  /* Attach data */
309  NV_DATA_NT_LD(v) = v_data;
310  }
311 #endif
312  return (v);
313 }
314 
315 /* ----------------------------------------------------------------------------
316  * Function to create an array of new nrnthread vectors.
317  */
318 
319 N_Vector* N_VNewVectorArray_NrnThreadLD(int count, long int length, int nthread, long int* sizes) {
320  N_Vector* vs;
321  int j;
322 
323  if (count <= 0)
324  return (NULL);
325 
326  vs = (N_Vector*) malloc(count * sizeof(N_Vector));
327  if (vs == NULL)
328  return (NULL);
329 
330  for (j = 0; j < count; j++) {
331  vs[j] = N_VNew_NrnThreadLD(length, nthread, sizes);
332  if (vs[j] == NULL) {
334  return (NULL);
335  }
336  }
337 
338  return (vs);
339 }
340 
341 /* ----------------------------------------------------------------------------
342  * Function to create an array of new nrnthread vectors with NULL data array.
343  */
344 
346  long int length,
347  int nthread,
348  long int* sizes) {
349  N_Vector* vs;
350  int j;
351 
352  if (count <= 0)
353  return (NULL);
354 
355  vs = (N_Vector*) malloc(count * sizeof(N_Vector));
356  if (vs == NULL)
357  return (NULL);
358 
359  for (j = 0; j < count; j++) {
360  vs[j] = N_VNewEmpty_NrnThreadLD(length, nthread, sizes);
361  if (vs[j] == NULL) {
363  return (NULL);
364  }
365  }
366 
367  return (vs);
368 }
369 
370 /* ----------------------------------------------------------------------------
371  * Function to free an array created with N_VNewVectorArray_NrnThreadLD
372  */
373 
374 void N_VDestroyVectorArray_NrnThreadLD(N_Vector* vs, int count) {
375  int j;
376 
377  for (j = 0; j < count; j++)
379 
380  free(vs);
381 }
382 
383 /* ----------------------------------------------------------------------------
384  * Function to print the a nrnthread vector
385  */
386 
387 void N_VPrint_NrnThreadLD(N_Vector x) {
388  int i;
389  int nt;
390 
391  nt = NV_NT_NT_LD(x);
392 
393  for (i = 0; i < nt; i++) {
394  N_VPrint_Serial(NV_SUBVEC_NT_LD(x, i));
395  }
396  printf("\n");
397 }
398 
399 static void pr(N_Vector x) {
401 }
402 /*
403  * -----------------------------------------------------------------
404  * implementation of vector operations
405  * -----------------------------------------------------------------
406  */
407 
408 N_Vector N_VClone_NrnThreadLD(N_Vector w) {
409  N_Vector v;
410  N_Vector wdata;
411  N_Vector data;
412  long int length;
413  int i, nt;
414 
416  if (v == NULL)
417  return (NULL);
418 
419  length = NV_LENGTH_NT_LD(w);
420  nt = NV_NT_NT_LD(w);
421 
422  /* Create data */
423  if (length > 0) {
425  for (i = 0; i < nt; ++i) {
426  wdata = NV_SUBVEC_NT_LD(w, i);
427  data = N_VClone(wdata);
428  if (data == NULL) {
430  return (NULL);
431  }
432  NV_SUBVEC_NT_LD(v, i) = data;
433  }
434  /* Attach data */
435  }
436 
437  return (v);
438 }
439 
440 void N_VDestroy_NrnThreadLD(N_Vector v) {
441  int i, nt;
442  N_Vector data;
443  nt = NV_NT_NT_LD(v);
444  if (NV_OWN_DATA_NT_LD(v) == TRUE) {
445  if (NV_CONTENT_NT_LD(v)->data) {
446  for (i = 0; i < nt; ++i) {
447  data = NV_SUBVEC_NT_LD(v, i);
448  if (data) {
449  N_VDestroy(data);
450  }
451  }
452  free(NV_CONTENT_NT_LD(v)->data);
453  }
454  }
455  free(v->content);
456  free(v->ops);
457  free(v);
458 }
459 
460 void N_VSpace_NrnThreadLD(N_Vector v, long int* lrw, long int* liw) {
461  *lrw = NV_LENGTH_NT_LD(v);
462  *liw = 1;
463 }
464 
465 /* NOTICE: the pointer returned is actually the NVector* data where
466 data is nthread NVector. so when you get the realtype* cast it back to
467 (NVector*)
468 */
469 realtype* N_VGetArrayPointer_NrnThreadLD(N_Vector v) {
470  N_Vector* v_data;
471  v_data = NV_DATA_NT_LD(v);
472 
473  return ((realtype*) v_data);
474 }
475 
476 void N_VSetArrayPointer_NrnThreadLD(realtype* v_data, N_Vector v) {
477  assert(0);
478 #if 0
479  if (NV_LENGTH_NT_LD(v) > 0) NV_DATA_NT_LD(v) = v_data;
480 #endif
481 }
482 
483 static void* vlinearsum(NrnThread* nt) {
484  int i = nt->id;
485  N_VLinearSum_Serial(aarg, xarg(i), barg, yarg(i), zarg(i));
486  return nullptr;
487 }
488 void N_VLinearSum_NrnThreadLD(realtype a, N_Vector x, realtype b, N_Vector y, N_Vector z) {
490  mydebug("vlinearsum\n");
491  /*pr(z);*/
492 }
493 
494 static void* vconst(NrnThread* nt) {
495  int i = nt->id;
496  N_VConst_Serial(carg, zarg(i));
497  return nullptr;
498 }
499 void N_VConst_NrnThreadLD(realtype c, N_Vector z) {
501  mydebug("vconst\n");
502 }
503 
504 static void* vprod(NrnThread* nt) {
505  int i = nt->id;
506  N_VProd_Serial(xarg(i), yarg(i), zarg(i));
507  return nullptr;
508 }
509 void N_VProd_NrnThreadLD(N_Vector x, N_Vector y, N_Vector z) {
511  mydebug("vprod\n");
512 }
513 
514 static void* vdiv(NrnThread* nt) {
515  int i = nt->id;
516  N_VDiv_Serial(xarg(i), yarg(i), zarg(i));
517  return nullptr;
518 }
519 void N_VDiv_NrnThreadLD(N_Vector x, N_Vector y, N_Vector z) {
521  mydebug("vdiv\n");
522 }
523 
524 static void* vscale(NrnThread* nt) {
525  int i = nt->id;
526  N_VScale_Serial(carg, xarg(i), zarg(i));
527  return nullptr;
528 }
529 void N_VScale_NrnThreadLD(realtype c, N_Vector x, N_Vector z) {
531  mydebug("vscale\n");
532  /*pr(z);*/
533 }
534 
535 static void* vabs(NrnThread* nt) {
536  int i = nt->id;
537  N_VAbs_Serial(xarg(i), zarg(i));
538  return nullptr;
539 }
540 void N_VAbs_NrnThreadLD(N_Vector x, N_Vector z) {
542  mydebug("vabs\n");
543 }
544 
545 static void* vinv(NrnThread* nt) {
546  int i = nt->id;
547  N_VInv_Serial(xarg(i), zarg(i));
548  return nullptr;
549 }
550 void N_VInv_NrnThreadLD(N_Vector x, N_Vector z) {
552  mydebug("vinv\n");
553 }
554 
555 static void* vaddconst(NrnThread* nt) {
556  int i = nt->id;
557  N_VAddConst_Serial(xarg(i), barg, zarg(i));
558  return nullptr;
559 }
560 void N_VAddConst_NrnThreadLD(N_Vector x, realtype b, N_Vector z) {
562  mydebug("vaddconst\n");
563 }
564 
565 static void* vdotprod(NrnThread* nt) {
566  realtype s;
567  int i = nt->id;
568  s = N_VDotProd_Serial(xarg(i), yarg(i));
569  lockadd(s);
570  return nullptr;
571 }
572 realtype N_VDotProd_NrnThreadLD(N_Vector x, N_Vector y) {
573  retval = ZERO;
575  mydebug2("vdotprod %.20g\n", retval);
576  return (retval);
577 }
578 
579 static void* vmaxnorm(NrnThread* nt) {
580  realtype max;
581  int i = nt->id;
582  max = N_VMaxNorm_Serial(xarg(i));
583  lockmax(max);
584  return nullptr;
585 }
586 realtype N_VMaxNorm_NrnThreadLD(N_Vector x) {
587  retval = ZERO;
589  mydebug2("vmaxnorm %.20g\n", retval);
590  return (retval);
591 }
592 
593 
594 static realtype vwrmsnorm_help(N_Vector x, N_Vector w) {
595  long int i, N;
596  realtype *xd, *wd;
597 
598  N = NV_LENGTH_S(x);
599  xd = NV_DATA_S(x);
600  wd = NV_DATA_S(w);
601 
602  realtype sum{}, c{};
603  for (i = 0; i < N; i++) {
604  auto const prodi = (*xd++) * (*wd++);
605  auto const y = prodi * prodi - c;
606  auto const t = sum + y;
607  c = (t - sum) - y;
608  sum = t;
609  }
610 
611  return sum;
612 }
613 static void* vwrmsnorm(NrnThread* nt) {
614  int i = nt->id;
615  auto const s = vwrmsnorm_help(xarg(i), warg(i));
616  // olupton 2023-03-13: this produces results that differ on x86_64 from the long double based
617  // calculation at the 1e-16 relative precision level. unfortunately NEURON with cvode amplifies
618  // these to larger differences in the precise variable time steps used. however, it should be
619  // more consistent across architectures than the long double version.
620  lock;
621  auto const tmp_y = s - retval_comp;
622  auto const tmp_t = retval + tmp_y;
623  retval_comp = (tmp_t - retval) - tmp_y;
624  retval = tmp_t;
625  unlock;
626  return nullptr;
627 }
628 realtype N_VWrmsNorm_NrnThreadLD(N_Vector x, N_Vector w) {
629  long int N;
630  N = NV_LENGTH_NT_LD(x);
631  retval = retval_comp = 0.0;
633  mydebug2("vwrmsnorm %.20g\n", RSqrt(retval / N));
634  return (RSqrt(retval / N));
635 }
636 
637 static realtype vwrmsnormmask_help(N_Vector x, N_Vector w, N_Vector id) {
638  long int i, N;
639  realtype sum = ZERO, prodi, *xd, *wd, *idd;
640 
641  N = NV_LENGTH_S(x);
642  xd = NV_DATA_S(x);
643  wd = NV_DATA_S(w);
644  idd = NV_DATA_S(id);
645 
646  for (i = 0; i < N; i++) {
647  if (idd[i] > ZERO) {
648  prodi = xd[i] * wd[i];
649  sum += prodi * prodi;
650  }
651  }
652 
653  return (sum);
654 }
655 static void* vwrmsnormmask(NrnThread* nt) {
656  realtype s;
657  int i = nt->id;
659  lockadd(s);
660  return nullptr;
661 }
662 realtype N_VWrmsNormMask_NrnThreadLD(N_Vector x, N_Vector w, N_Vector id) {
663  long int N;
664  N = NV_LENGTH_NT_LD(x);
665  retval = ZERO;
667  mydebug2("vwrmsnormmask %.20g\n", RSqrt(retval / N));
668  return (RSqrt(retval / N));
669 }
670 
671 static void* vmin(NrnThread* nt) {
672  realtype min;
673  int i = nt->id;
674  if (NV_LENGTH_S(xarg(i))) {
675  min = N_VMin_Serial(xarg(i));
676  lockmin(min);
677  }
678  return nullptr;
679 }
680 realtype N_VMin_NrnThreadLD(N_Vector x) {
681  retval = BIG_REAL;
683  mydebug2("vmin %.20g\n", retval);
684  return (retval);
685 }
686 
687 static realtype N_VWL2Norm_helper(N_Vector x, N_Vector w) {
688  long int i, N;
689  realtype sum = ZERO, prodi, *xd, *wd;
690 
691  N = NV_LENGTH_S(x);
692  xd = NV_DATA_S(x);
693  wd = NV_DATA_S(w);
694 
695  for (i = 0; i < N; i++) {
696  prodi = (*xd++) * (*wd++);
697  sum += prodi * prodi;
698  }
699 
700  return sum;
701 }
702 static void* vwl2norm(NrnThread* nt) {
703  realtype sum;
704  int i = nt->id;
705  sum = N_VWL2Norm_helper(xarg(i), warg(i));
706  lockadd(sum);
707  return nullptr;
708 }
709 realtype N_VWL2Norm_NrnThreadLD(N_Vector x, N_Vector w) {
710  long int N;
711  retval = ZERO;
713  N = NV_LENGTH_NT_LD(x);
714  mydebug2("vwl2norm %.20g\n", RSqrt(retval));
715  return (RSqrt(retval));
716 }
717 
718 static void* vl1norm(NrnThread* nt) {
719  realtype sum;
720  int i = nt->id;
721  sum = N_VL1Norm_Serial(xarg(i));
722  lockadd(sum);
723  return nullptr;
724 }
725 realtype N_VL1Norm_NrnThreadLD(N_Vector x) {
726  retval = ZERO;
728  mydebug2("vl1norm %.20g\n", retval);
729  return (retval);
730 }
731 
732 static void* v1mask(NrnThread* nt) {
733  int i = nt->id;
735  return nullptr;
736 }
737 void N_VOneMask_NrnThreadLD(N_Vector x) {
739 }
740 
741 static void* vcompare(NrnThread* nt) {
742  int i = nt->id;
743  N_VCompare_Serial(carg, xarg(i), zarg(i));
744  return nullptr;
745 }
746 void N_VCompare_NrnThreadLD(realtype c, N_Vector x, N_Vector z) {
748  mydebug("vcompare\n");
749 }
750 
751 static void* vinvtest(NrnThread* nt) {
752  booleantype b;
753  int i = nt->id;
754  b = N_VInvTest_Serial(xarg(i), zarg(i));
755  if (!b) {
756  lockfalse;
757  }
758  return nullptr;
759 }
760 booleantype N_VInvTest_NrnThreadLD(N_Vector x, N_Vector z) {
761  bretval = TRUE;
763  mydebug2("vinvtest %d\n", bretval);
764  return (bretval);
765 }
766 
767 static void* vconstrmask(NrnThread* nt) {
768  booleantype b;
769  int i = nt->id;
770  b = N_VConstrMask_Serial(yarg(i), xarg(i), zarg(i));
771  if (!b) {
772  lockfalse;
773  }
774  return nullptr;
775 }
776 booleantype N_VConstrMask_NrnThreadLD(N_Vector y, N_Vector x, N_Vector z) {
777  bretval = TRUE;
779  mydebug2("vconstrmask %d\n", bretval);
780  return (bretval);
781 }
782 
783 static void* vminquotient(NrnThread* nt) {
784  realtype min;
785  int i = nt->id;
786  min = N_VMinQuotient_Serial(xarg(i), yarg(i));
787  lockmin(min);
788  return nullptr;
789 }
790 realtype N_VMinQuotient_NrnThreadLD(N_Vector x, N_Vector y) /* num, denom */
791 {
792  retval = BIG_REAL;
794  mydebug2("vminquotient %.20g\n", retval);
795  return (retval);
796 }
#define v
Definition: md1redef.h:11
#define data
Definition: md1redef.h:36
#define i
Definition: md1redef.h:19
#define TRUE
Definition: grids.h:22
#define FALSE
Definition: grids.h:23
static int c
Definition: hoc.cpp:169
#define assert(ex)
Definition: hocassrt.h:24
printf
Definition: extdef.h:5
void nrn_multithread_job(F &&job, Args &&... args)
Definition: multicore.hpp:161
size_t j
s
Definition: multisend.cpp:521
#define MUTCONSTRUCTED
Definition: nrnmutdec.h:32
#define MUTCONSTRUCT(mkmut)
Definition: nrnmutdec.h:33
#define MUTDEC
Definition: nrnmutdec.h:31
void N_VOneMask_Serial(N_Vector x)
#define lock
#define xarg(i)
static booleantype bretval
realtype N_VDotProd_NrnThreadLD(N_Vector x, N_Vector y)
#define idarg(i)
#define aarg
#define barg
static N_Vector y_
void N_VInv_NrnThreadLD(N_Vector x, N_Vector z)
#define unlock
N_Vector N_VNew_NrnThreadLD(long int length, int nthread, long int *sizes)
static void * v1mask(NrnThread *nt)
void N_VPrint_NrnThreadLD(N_Vector x)
N_Vector * N_VNewVectorArray_NrnThreadLD(int count, long int length, int nthread, long int *sizes)
#define lockmin(arg)
static void * vconstrmask(NrnThread *nt)
realtype N_VL1Norm_NrnThreadLD(N_Vector x)
#define apass
static N_Vector id_
static N_Vector w_
#define wpass
N_Vector N_VCloneEmpty_NrnThreadLD(N_Vector w)
#define xpass
static realtype vwrmsnormmask_help(N_Vector x, N_Vector w, N_Vector id)
static void * vaddconst(NrnThread *nt)
static realtype N_VWL2Norm_helper(N_Vector x, N_Vector w)
static void * vscale(NrnThread *nt)
#define carg
#define zpass
booleantype N_VConstrMask_NrnThreadLD(N_Vector y, N_Vector x, N_Vector z)
realtype N_VWL2Norm_NrnThreadLD(N_Vector x, N_Vector w)
static void * vwrmsnormmask(NrnThread *nt)
#define bpass
void N_VAbs_NrnThreadLD(N_Vector x, N_Vector z)
N_Vector N_VClone_NrnThreadLD(N_Vector w)
realtype N_VMin_NrnThreadLD(N_Vector x)
void N_VSetArrayPointer_NrnThreadLD(realtype *v_data, N_Vector v)
#define mydebug2(a, b)
N_Vector N_VMake_NrnThreadLD(long int length, realtype *v_data)
void N_VDiv_NrnThreadLD(N_Vector x, N_Vector y, N_Vector z)
realtype N_VMinQuotient_NrnThreadLD(N_Vector x, N_Vector y)
static void * vconst(NrnThread *nt)
static void * vabs(NrnThread *nt)
#define lockfalse
#define lockmax(arg)
static void * vlinearsum(NrnThread *nt)
static void * vmin(NrnThread *nt)
void N_VConst_NrnThreadLD(realtype c, N_Vector z)
N_Vector * N_VNewVectorArrayEmpty_NrnThreadLD(int count, long int length, int nthread, long int *sizes)
void N_VCompare_NrnThreadLD(realtype c, N_Vector x, N_Vector z)
#define lockadd(arg)
void N_VDestroyVectorArray_NrnThreadLD(N_Vector *vs, int count)
N_Vector N_VNewEmpty_NrnThreadLD(long int length, int nthread, long int *sizes)
static realtype retval
realtype N_VWrmsNormMask_NrnThreadLD(N_Vector x, N_Vector w, N_Vector id)
void N_VLinearSum_NrnThreadLD(realtype a, N_Vector x, realtype b, N_Vector y, N_Vector z)
booleantype N_VInvTest_NrnThreadLD(N_Vector x, N_Vector z)
static void * vdiv(NrnThread *nt)
static void * vprod(NrnThread *nt)
static realtype c_
static void * vmaxnorm(NrnThread *nt)
static void * vminquotient(NrnThread *nt)
static void * vwl2norm(NrnThread *nt)
void N_VProd_NrnThreadLD(N_Vector x, N_Vector y, N_Vector z)
realtype N_VMaxNorm_NrnThreadLD(N_Vector x)
realtype N_VWrmsNorm_NrnThreadLD(N_Vector x, N_Vector w)
static void pr(N_Vector x)
void N_VScale_NrnThreadLD(realtype c, N_Vector x, N_Vector z)
#define ZERO
realtype * N_VGetArrayPointer_NrnThreadLD(N_Vector v)
static void * vinv(NrnThread *nt)
#define ypass
#define zarg(i)
#define warg(i)
static realtype retval_comp
#define mydebug(a)
void N_VOneMask_NrnThreadLD(N_Vector x)
static realtype a_
static void * vinvtest(NrnThread *nt)
static void * vl1norm(NrnThread *nt)
static realtype b_
#define yarg(i)
#define cpass
#define idpass
static void * vdotprod(NrnThread *nt)
static N_Vector z_
static void * vcompare(NrnThread *nt)
void N_VAddConst_NrnThreadLD(N_Vector x, realtype b, N_Vector z)
static N_Vector x_
void N_VDestroy_NrnThreadLD(N_Vector v)
static realtype vwrmsnorm_help(N_Vector x, N_Vector w)
void N_VSpace_NrnThreadLD(N_Vector v, long int *lrw, long int *liw)
static void * vwrmsnorm(NrnThread *nt)
#define NV_CONTENT_NT_LD(v)
#define NV_SUBVEC_NT_LD(v, i)
#define NV_LENGTH_NT_LD(v)
#define NV_DATA_NT_LD(v)
#define NV_NT_NT_LD(v)
#define NV_OWN_DATA_NT_LD(v)
struct _N_VectorContent_NrnThreadLD * N_VectorContent_NrnThreadLD
#define NULL
Definition: spdefs.h:105
Represent main neuron object computed by single thread.
Definition: multicore.h:58
int id
Definition: multicore.h:66