NEURON
nvector_nrnthread.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 #define USELONGDOUBLE 0
20 
21 #include <stdio.h>
22 #include <stdlib.h>
23 
24 #include "shared/nvector_serial.h"
25 #include "nvector_nrnthread.h"
26 #include "shared/sundialsmath.h"
27 #include "shared/sundialstypes.h"
28 #include "section.h"
29 #include "nrnmutdec.h"
30 
31 #define ZERO RCONST(0.0)
32 #define HALF RCONST(0.5)
33 #define ONE RCONST(1.0)
34 #define ONEPT5 RCONST(1.5)
35 
36 #if 0
37 #define mydebug(a) printf(a)
38 #define mydebug2(a, b) printf(a, b)
39 #else
40 #define mydebug(a) /**/
41 #define mydebug2(a, b) /**/
42 #endif
43 
44 #if USELONGDOUBLE
45 #define ldrealtype long double
46 #else
47 #define ldrealtype realtype
48 #endif
49 
50 #if USE_PTHREAD
51 static MUTDEC
52 #endif
53  /* argument passing between NrnThread and Serial */
54  static N_Vector x_;
55 static N_Vector y_;
56 static N_Vector z_;
57 static N_Vector w_;
58 static N_Vector id_;
59 static realtype a_;
60 static realtype b_;
61 static realtype c_;
62 static realtype retval;
63 #if USELONGDOUBLE
64 static long double longdretval;
65 #endif
66 static booleantype bretval;
67 #define xpass x_ = x;
68 #define ypass y_ = y;
69 #define zpass z_ = z;
70 #define wpass w_ = w;
71 #define idpass id_ = id;
72 #define apass a_ = a;
73 #define bpass b_ = b;
74 #define cpass c_ = c;
75 #define xarg(i) NV_SUBVEC_NT(x_, i)
76 #define yarg(i) NV_SUBVEC_NT(y_, i)
77 #define zarg(i) NV_SUBVEC_NT(z_, i)
78 #define warg(i) NV_SUBVEC_NT(w_, i)
79 #define idarg(i) NV_SUBVEC_NT(id_, i)
80 #define aarg a_
81 #define barg b_
82 #define carg c_
83 #define lock MUTLOCK
84 #define unlock MUTUNLOCK
85 #define lockadd(arg) \
86  lock; \
87  retval += arg; \
88  unlock;
89 #if USELONGDOUBLE
90 #define locklongdadd(arg) \
91  lock; \
92  longdretval += arg; \
93  unlock;
94 #else
95 #define locklongdadd(arg) lockadd(arg)
96 #endif
97 #define lockmax(arg) \
98  lock; \
99  if (retval < arg) { \
100  retval = arg; \
101  }; \
102  unlock;
103 #define lockmin(arg) \
104  lock; \
105  if (retval > arg) { \
106  retval = arg; \
107  }; \
108  unlock;
109 #define lockfalse \
110  lock; \
111  bretval = FALSE; \
112  unlock;
113 
114 /*
115  * -----------------------------------------------------------------
116  * exported functions
117  * -----------------------------------------------------------------
118  */
119 
120 /* ----------------------------------------------------------------------------
121  * Function to create a new empty nrnthread vector
122  */
123 
124 N_Vector N_VNewEmpty_NrnThread(long int length, int nthread, long int* sizes) {
125  int i;
126  N_Vector v;
127  N_Vector_Ops ops;
129 
130  if (!MUTCONSTRUCTED) {
131  MUTCONSTRUCT(1)
132  }
133 
134  /* Create vector */
135  v = (N_Vector) malloc(sizeof *v);
136  if (v == NULL)
137  return (NULL);
138 
139  /* Create vector operation structure */
140  ops = (N_Vector_Ops) malloc(sizeof(struct _generic_N_Vector_Ops));
141  if (ops == NULL) {
142  free(v);
143  return (NULL);
144  }
145 
146  ops->nvclone = N_VClone_NrnThread;
147  ops->nvdestroy = N_VDestroy_NrnThread;
148  ops->nvspace = N_VSpace_NrnThread;
149  ops->nvgetarraypointer = N_VGetArrayPointer_NrnThread;
150  ops->nvsetarraypointer = N_VSetArrayPointer_NrnThread;
151  ops->nvlinearsum = N_VLinearSum_NrnThread;
152  ops->nvconst = N_VConst_NrnThread;
153  ops->nvprod = N_VProd_NrnThread;
154  ops->nvdiv = N_VDiv_NrnThread;
155  ops->nvscale = N_VScale_NrnThread;
156  ops->nvabs = N_VAbs_NrnThread;
157  ops->nvinv = N_VInv_NrnThread;
158  ops->nvaddconst = N_VAddConst_NrnThread;
159  ops->nvdotprod = N_VDotProd_NrnThread;
160  ops->nvmaxnorm = N_VMaxNorm_NrnThread;
161  ops->nvwrmsnormmask = N_VWrmsNormMask_NrnThread;
162  ops->nvwrmsnorm = N_VWrmsNorm_NrnThread;
163  ops->nvmin = N_VMin_NrnThread;
164  ops->nvwl2norm = N_VWL2Norm_NrnThread;
165  ops->nvl1norm = N_VL1Norm_NrnThread;
166  ops->nvcompare = N_VCompare_NrnThread;
167  ops->nvinvtest = N_VInvTest_NrnThread;
168  ops->nvconstrmask = N_VConstrMask_NrnThread;
169  ops->nvminquotient = N_VMinQuotient_NrnThread;
170 
171  /* Create content */
172  content = (N_VectorContent_NrnThread) malloc(sizeof(struct _N_VectorContent_NrnThread));
173  if (content == NULL) {
174  free(ops);
175  free(v);
176  return (NULL);
177  }
178 
179  content->length = length;
180  content->nt = nthread;
181  content->own_data = FALSE;
182  content->data = (N_Vector*) malloc(sizeof(N_Vector) * nthread);
183  if (content->data == NULL) {
184  free(ops);
185  free(v);
186  free(content);
187  return (NULL);
188  }
189  for (i = 0; i < nthread; ++i) {
190  content->data[i] = NULL;
191  }
192  /* Attach content and ops */
193  v->content = content;
194  v->ops = ops;
195 
196  return (v);
197 }
198 
199 /* ----------------------------------------------------------------------------
200  * Function to create a new nrnthread vector
201  */
202 
203 N_Vector N_VNew_NrnThread(long int length, int nthread, long int* sizes) {
204  int i;
205  N_Vector v;
206  N_Vector data;
207  N_VectorContent_NrnThread* content;
208 
209  v = N_VNewEmpty_NrnThread(length, nthread, sizes);
210  if (v == NULL)
211  return (NULL);
212 
213  /* Create data */
214  if (length > 0) {
215  /* Allocate memory */
216  NV_OWN_DATA_NT(v) = TRUE;
217  for (i = 0; i < nthread; ++i) {
218  data = N_VNew_Serial(sizes[i]);
219  if (data == NULL) {
221  return (NULL);
222  }
223  NV_SUBVEC_NT(v, i) = data;
224  }
225  }
226 
227  return (v);
228 }
229 
230 /* ----------------------------------------------------------------------------
231  * Function to clone from a template a new vector with empty (NULL) data array
232  */
233 
234 N_Vector N_VCloneEmpty_NrnThread(N_Vector w) {
235  int i;
236  N_Vector v;
237  N_Vector_Ops ops;
239  N_VectorContent_NrnThread wcontent;
240 
241  if (w == NULL)
242  return (NULL);
243 
244  /* Create vector */
245  v = (N_Vector) malloc(sizeof *v);
246  if (v == NULL)
247  return (NULL);
248 
249  /* Create vector operation structure */
250  ops = (N_Vector_Ops) malloc(sizeof(struct _generic_N_Vector_Ops));
251  if (ops == NULL) {
252  free(v);
253  return (NULL);
254  }
255 
256  ops->nvclone = w->ops->nvclone;
257  ops->nvdestroy = w->ops->nvdestroy;
258  ops->nvspace = w->ops->nvspace;
259  ops->nvgetarraypointer = w->ops->nvgetarraypointer;
260  ops->nvsetarraypointer = w->ops->nvsetarraypointer;
261  ops->nvlinearsum = w->ops->nvlinearsum;
262  ops->nvconst = w->ops->nvconst;
263  ops->nvprod = w->ops->nvprod;
264  ops->nvdiv = w->ops->nvdiv;
265  ops->nvscale = w->ops->nvscale;
266  ops->nvabs = w->ops->nvabs;
267  ops->nvinv = w->ops->nvinv;
268  ops->nvaddconst = w->ops->nvaddconst;
269  ops->nvdotprod = w->ops->nvdotprod;
270  ops->nvmaxnorm = w->ops->nvmaxnorm;
271  ops->nvwrmsnormmask = w->ops->nvwrmsnormmask;
272  ops->nvwrmsnorm = w->ops->nvwrmsnorm;
273  ops->nvmin = w->ops->nvmin;
274  ops->nvwl2norm = w->ops->nvwl2norm;
275  ops->nvl1norm = w->ops->nvl1norm;
276  ops->nvcompare = w->ops->nvcompare;
277  ops->nvinvtest = w->ops->nvinvtest;
278  ops->nvconstrmask = w->ops->nvconstrmask;
279  ops->nvminquotient = w->ops->nvminquotient;
280 
281  /* Create content */
282  content = (N_VectorContent_NrnThread) malloc(sizeof(struct _N_VectorContent_NrnThread));
283  if (content == NULL) {
284  free(ops);
285  free(v);
286  return (NULL);
287  }
288 
289  wcontent = NV_CONTENT_NT(w);
290  content->length = NV_LENGTH_NT(w);
291  content->own_data = FALSE;
292  content->nt = wcontent->nt;
293  content->data = (N_Vector*) malloc(sizeof(N_Vector) * content->nt);
294  if (content->data == NULL) {
295  free(ops);
296  free(v);
297  free(content);
298  return (NULL);
299  }
300  for (i = 0; i < content->nt; ++i) {
301  content->data[i] = NULL;
302  }
303 
304  /* Attach content and ops */
305  v->content = content;
306  v->ops = ops;
307 
308  return (v);
309 }
310 
311 /* ----------------------------------------------------------------------------
312  * Function to create a nrnthread N_Vector with user data component
313  */
314 
315 N_Vector N_VMake_NrnThread(long int length, realtype* v_data) {
316  N_Vector v = NULL;
317 
318  assert(0);
319 #if 0
320  v = N_VNewEmpty_NrnThread(length);
321  if (v == NULL) return(NULL);
322 
323  if (length > 0) {
324  /* Attach data */
326  NV_DATA_NT(v) = v_data;
327  }
328 
329 #endif
330  return (v);
331 }
332 
333 /* ----------------------------------------------------------------------------
334  * Function to create an array of new nrnthread vectors.
335  */
336 
337 N_Vector* N_VNewVectorArray_NrnThread(int count, long int length, int nthread, long int* sizes) {
338  N_Vector* vs;
339  int j;
340 
341  if (count <= 0)
342  return (NULL);
343 
344  vs = (N_Vector*) malloc(count * sizeof(N_Vector));
345  if (vs == NULL)
346  return (NULL);
347 
348  for (j = 0; j < count; j++) {
349  vs[j] = N_VNew_NrnThread(length, nthread, sizes);
350  if (vs[j] == NULL) {
352  return (NULL);
353  }
354  }
355 
356  return (vs);
357 }
358 
359 /* ----------------------------------------------------------------------------
360  * Function to create an array of new nrnthread vectors with NULL data array.
361  */
362 
364  long int length,
365  int nthread,
366  long int* sizes) {
367  N_Vector* vs;
368  int j;
369 
370  if (count <= 0)
371  return (NULL);
372 
373  vs = (N_Vector*) malloc(count * sizeof(N_Vector));
374  if (vs == NULL)
375  return (NULL);
376 
377  for (j = 0; j < count; j++) {
378  vs[j] = N_VNewEmpty_NrnThread(length, nthread, sizes);
379  if (vs[j] == NULL) {
381  return (NULL);
382  }
383  }
384 
385  return (vs);
386 }
387 
388 /* ----------------------------------------------------------------------------
389  * Function to free an array created with N_VNewVectorArray_NrnThread
390  */
391 
392 void N_VDestroyVectorArray_NrnThread(N_Vector* vs, int count) {
393  int j;
394 
395  for (j = 0; j < count; j++)
396  N_VDestroy_NrnThread(vs[j]);
397 
398  free(vs);
399 }
400 
401 /* ----------------------------------------------------------------------------
402  * Function to print the a nrnthread vector
403  */
404 
405 void N_VPrint_NrnThread(N_Vector x) {
406  int i;
407  int nt;
408 
409  nt = NV_NT_NT(x);
410 
411  for (i = 0; i < nt; i++) {
412  N_VPrint_Serial(NV_SUBVEC_NT(x, i));
413  }
414  printf("\n");
415 }
416 
417 static void pr(N_Vector x) {
419 }
420 /*
421  * -----------------------------------------------------------------
422  * implementation of vector operations
423  * -----------------------------------------------------------------
424  */
425 
426 N_Vector N_VClone_NrnThread(N_Vector w) {
427  N_Vector v;
428  N_Vector wdata;
429  N_Vector data;
430  long int length;
431  int i, nt;
432 
434  if (v == NULL)
435  return (NULL);
436 
437  length = NV_LENGTH_NT(w);
438  nt = NV_NT_NT(w);
439 
440  /* Create data */
441  if (length > 0) {
442  NV_OWN_DATA_NT(v) = TRUE;
443  for (i = 0; i < nt; ++i) {
444  wdata = NV_SUBVEC_NT(w, i);
445  data = N_VClone(wdata);
446  if (data == NULL) {
448  return (NULL);
449  }
450  NV_SUBVEC_NT(v, i) = data;
451  }
452  /* Attach data */
453  }
454 
455  return (v);
456 }
457 
458 void N_VDestroy_NrnThread(N_Vector v) {
459  int i, nt;
460  N_Vector data;
461  nt = NV_NT_NT(v);
462  if (NV_OWN_DATA_NT(v) == TRUE) {
463  if (NV_CONTENT_NT(v)->data) {
464  for (i = 0; i < nt; ++i) {
465  data = NV_SUBVEC_NT(v, i);
466  if (data) {
467  N_VDestroy(data);
468  }
469  }
470  free(NV_CONTENT_NT(v)->data);
471  }
472  }
473  free(v->content);
474  free(v->ops);
475  free(v);
476 }
477 
478 void N_VSpace_NrnThread(N_Vector v, long int* lrw, long int* liw) {
479  *lrw = NV_LENGTH_NT(v);
480  *liw = 1;
481 }
482 
483 /* NOTICE: the pointer returned is actually the NVector* data where
484 data is nthread NVector. so when you get the realtype* cast it back to
485 (NVector*)
486 */
487 realtype* N_VGetArrayPointer_NrnThread(N_Vector v) {
488  N_Vector* v_data;
489  v_data = NV_DATA_NT(v);
490 
491  return ((realtype*) v_data);
492 }
493 
494 void N_VSetArrayPointer_NrnThread(realtype* v_data, N_Vector v) {
495  assert(0);
496 #if 0
497  if (NV_LENGTH_NT(v) > 0) NV_DATA_NT(v) = v_data;
498 #endif
499 }
500 
501 static void* vlinearsum(NrnThread* nt) {
502  int i = nt->id;
503  N_VLinearSum_Serial(aarg, xarg(i), barg, yarg(i), zarg(i));
504  return nullptr;
505 }
506 void N_VLinearSum_NrnThread(realtype a, N_Vector x, realtype b, N_Vector y, N_Vector z) {
508  mydebug("vlinearsum\n");
509  /*pr(z);*/
510 }
511 
512 static void* vconst(NrnThread* nt) {
513  int i = nt->id;
514  N_VConst_Serial(carg, zarg(i));
515  return nullptr;
516 }
517 void N_VConst_NrnThread(realtype c, N_Vector z) {
519  mydebug("vconst\n");
520 }
521 
522 static void* vprod(NrnThread* nt) {
523  int i = nt->id;
524  N_VProd_Serial(xarg(i), yarg(i), zarg(i));
525  return nullptr;
526 }
527 void N_VProd_NrnThread(N_Vector x, N_Vector y, N_Vector z) {
529  mydebug("vprod\n");
530 }
531 
532 static void* vdiv(NrnThread* nt) {
533  int i = nt->id;
534  N_VDiv_Serial(xarg(i), yarg(i), zarg(i));
535  return nullptr;
536 }
537 void N_VDiv_NrnThread(N_Vector x, N_Vector y, N_Vector z) {
539  mydebug("vdiv\n");
540 }
541 
542 static void* vscale(NrnThread* nt) {
543  int i = nt->id;
544  N_VScale_Serial(carg, xarg(i), zarg(i));
545  return nullptr;
546 }
547 void N_VScale_NrnThread(realtype c, N_Vector x, N_Vector z) {
549  mydebug("vscale\n");
550  /*pr(z);*/
551 }
552 
553 static void* vabs(NrnThread* nt) {
554  int i = nt->id;
555  N_VAbs_Serial(xarg(i), zarg(i));
556  return nullptr;
557 }
558 void N_VAbs_NrnThread(N_Vector x, N_Vector z) {
560  mydebug("vabs\n");
561 }
562 
563 static void* vinv(NrnThread* nt) {
564  int i = nt->id;
565  N_VInv_Serial(xarg(i), zarg(i));
566  return nullptr;
567 }
568 void N_VInv_NrnThread(N_Vector x, N_Vector z) {
570  mydebug("vinv\n");
571 }
572 
573 static void* vaddconst(NrnThread* nt) {
574  int i = nt->id;
575  N_VAddConst_Serial(xarg(i), barg, zarg(i));
576  return nullptr;
577 }
578 void N_VAddConst_NrnThread(N_Vector x, realtype b, N_Vector z) {
580  mydebug("vaddconst\n");
581 }
582 
583 static void* vdotprod(NrnThread* nt) {
584  realtype s;
585  int i = nt->id;
586  s = N_VDotProd_Serial(xarg(i), yarg(i));
587  lockadd(s);
588  return nullptr;
589 }
590 realtype N_VDotProd_NrnThread(N_Vector x, N_Vector y) {
591  retval = ZERO;
593  mydebug2("vdotprod %.20g\n", retval);
594  return (retval);
595 }
596 
597 static void* vmaxnorm(NrnThread* nt) {
598  realtype max;
599  int i = nt->id;
600  max = N_VMaxNorm_Serial(xarg(i));
601  lockmax(max);
602  return nullptr;
603 }
604 realtype N_VMaxNorm_NrnThread(N_Vector x) {
605  retval = ZERO;
607  mydebug2("vmaxnorm %.20g\n", retval);
608  return (retval);
609 }
610 
611 
612 static ldrealtype vwrmsnorm_help(N_Vector x, N_Vector w) {
613  long int i, N;
614  ldrealtype sum = ZERO;
615  realtype prodi, *xd, *wd;
616 
617  N = NV_LENGTH_S(x);
618  xd = NV_DATA_S(x);
619  wd = NV_DATA_S(w);
620 
621  for (i = 0; i < N; i++) {
622  prodi = (*xd++) * (*wd++);
623  sum += prodi * prodi;
624  }
625 
626  return (sum);
627 }
628 static void* vwrmsnorm(NrnThread* nt) {
629  ldrealtype s;
630  int i = nt->id;
631  s = vwrmsnorm_help(xarg(i), warg(i));
632  locklongdadd(s);
633  return nullptr;
634 }
635 realtype N_VWrmsNorm_NrnThread(N_Vector x, N_Vector w) {
636  long int N;
637  N = NV_LENGTH_NT(x);
638 #if USELONGDOUBLE
639  longdretval = ZERO;
640 #else
641  retval = ZERO;
642 #endif
644 #if USELONGDOUBLE
646 #endif
647  mydebug2("vwrmsnorm %.20g\n", RSqrt(retval / N));
648  return (RSqrt(retval / N));
649 }
650 
651 static realtype vwrmsnormmask_help(N_Vector x, N_Vector w, N_Vector id) {
652  long int i, N;
653  realtype sum = ZERO, prodi, *xd, *wd, *idd;
654 
655  N = NV_LENGTH_S(x);
656  xd = NV_DATA_S(x);
657  wd = NV_DATA_S(w);
658  idd = NV_DATA_S(id);
659 
660  for (i = 0; i < N; i++) {
661  if (idd[i] > ZERO) {
662  prodi = xd[i] * wd[i];
663  sum += prodi * prodi;
664  }
665  }
666 
667  return (sum);
668 }
669 static void* vwrmsnormmask(NrnThread* nt) {
670  realtype s;
671  int i = nt->id;
672  s = vwrmsnormmask_help(xarg(i), warg(i), idarg(i));
673  lockadd(s);
674  return nullptr;
675 }
676 realtype N_VWrmsNormMask_NrnThread(N_Vector x, N_Vector w, N_Vector id) {
677  long int N;
678  N = NV_LENGTH_NT(x);
679  retval = ZERO;
681  mydebug2("vwrmsnormmask %.20g\n", RSqrt(retval / N));
682  return (RSqrt(retval / N));
683 }
684 
685 static void* vmin(NrnThread* nt) {
686  realtype min;
687  int i = nt->id;
688  if (NV_LENGTH_S(xarg(i))) {
689  min = N_VMin_Serial(xarg(i));
690  lockmin(min);
691  }
692  return nullptr;
693 }
694 realtype N_VMin_NrnThread(N_Vector x) {
695  retval = BIG_REAL;
697  mydebug2("vmin %.20g\n", retval);
698  return (retval);
699 }
700 
701 static realtype N_VWL2Norm_helper(N_Vector x, N_Vector w) {
702  long int i, N;
703  realtype sum = ZERO, prodi, *xd, *wd;
704 
705  N = NV_LENGTH_S(x);
706  xd = NV_DATA_S(x);
707  wd = NV_DATA_S(w);
708 
709  for (i = 0; i < N; i++) {
710  prodi = (*xd++) * (*wd++);
711  sum += prodi * prodi;
712  }
713 
714  return sum;
715 }
716 static void* vwl2norm(NrnThread* nt) {
717  realtype sum;
718  int i = nt->id;
719  sum = N_VWL2Norm_helper(xarg(i), warg(i));
720  lockadd(sum);
721  return nullptr;
722 }
723 realtype N_VWL2Norm_NrnThread(N_Vector x, N_Vector w) {
724  long int N;
725  retval = ZERO;
727  N = NV_LENGTH_NT(x);
728  mydebug2("vwl2norm %.20g\n", RSqrt(retval));
729  return (RSqrt(retval));
730 }
731 
732 static void* vl1norm(NrnThread* nt) {
733  realtype sum;
734  int i = nt->id;
735  sum = N_VL1Norm_Serial(xarg(i));
736  lockadd(sum);
737  return nullptr;
738 }
739 realtype N_VL1Norm_NrnThread(N_Vector x) {
740  retval = ZERO;
742  mydebug2("vl1norm %.20g\n", retval);
743  return (retval);
744 }
745 
746 static void* v1mask(NrnThread* nt) {
747  int i = nt->id;
749  return nullptr;
750 }
751 void N_VOneMask_NrnThread(N_Vector x) {
753 }
754 
755 static void* vcompare(NrnThread* nt) {
756  int i = nt->id;
757  N_VCompare_Serial(carg, xarg(i), zarg(i));
758  return nullptr;
759 }
760 void N_VCompare_NrnThread(realtype c, N_Vector x, N_Vector z) {
762  mydebug("vcompare\n");
763 }
764 
765 static void* vinvtest(NrnThread* nt) {
766  booleantype b;
767  int i = nt->id;
768  b = N_VInvTest_Serial(xarg(i), zarg(i));
769  if (!b) {
770  lockfalse;
771  }
772  return nullptr;
773 }
774 booleantype N_VInvTest_NrnThread(N_Vector x, N_Vector z) {
775  bretval = TRUE;
777  mydebug2("vinvtest %d\n", bretval);
778  return (bretval);
779 }
780 
781 static void* vconstrmask(NrnThread* nt) {
782  booleantype b;
783  int i = nt->id;
784  b = N_VConstrMask_Serial(yarg(i), xarg(i), zarg(i));
785  if (!b) {
786  lockfalse;
787  }
788  return nullptr;
789 }
790 booleantype N_VConstrMask_NrnThread(N_Vector y, N_Vector x, N_Vector z) {
791  bretval = TRUE;
793  mydebug2("vconstrmask %d\n", bretval);
794  return (bretval);
795 }
796 
797 static void* vminquotient(NrnThread* nt) {
798  realtype min;
799  int i = nt->id;
800  min = N_VMinQuotient_Serial(xarg(i), yarg(i));
801  lockmin(min);
802  return nullptr;
803 }
804 realtype N_VMinQuotient_NrnThread(N_Vector x, N_Vector y) /* num, denom */
805 {
806  retval = BIG_REAL;
808  mydebug2("vminquotient %.20g\n", retval);
809  return (retval);
810 }
#define c
#define TRUE
Definition: err.c:57
#define FALSE
Definition: err.c:56
#define assert(ex)
Definition: hocassrt.h:32
#define min(a, b)
Definition: matrix.h:157
#define max(a, b)
Definition: matrix.h:154
#define v
Definition: md1redef.h:4
#define i
Definition: md1redef.h:12
void nrn_multithread_job(void *(*job)(NrnThread *))
Definition: multicore.cpp:1136
#define printf
Definition: mwprefix.h:26
size_t j
#define MUTCONSTRUCTED
Definition: nrnmutdec.h:69
#define MUTCONSTRUCT(mkmut)
Definition: nrnmutdec.h:70
#define MUTDEC
Definition: nrnmutdec.h:68
void N_VSetArrayPointer_NrnThread(realtype *v_data, N_Vector v)
booleantype N_VInvTest_NrnThread(N_Vector x, N_Vector z)
void N_VSpace_NrnThread(N_Vector v, long int *lrw, long int *liw)
#define xarg(i)
static booleantype bretval
void N_VConst_NrnThread(realtype c, N_Vector z)
#define idarg(i)
#define aarg
#define barg
static N_Vector y_
static void * v1mask(NrnThread *nt)
#define lockmin(arg)
static void * vconstrmask(NrnThread *nt)
#define apass
realtype N_VMin_NrnThread(N_Vector x)
N_Vector * N_VNewVectorArray_NrnThread(int count, long int length, int nthread, long int *sizes)
realtype N_VDotProd_NrnThread(N_Vector x, N_Vector y)
static N_Vector id_
void N_VLinearSum_NrnThread(realtype a, N_Vector x, realtype b, N_Vector y, N_Vector z)
static N_Vector w_
#define wpass
void N_VCompare_NrnThread(realtype c, N_Vector x, N_Vector z)
#define xpass
void N_VAbs_NrnThread(N_Vector x, N_Vector z)
N_Vector * N_VNewVectorArrayEmpty_NrnThread(int count, long int length, int nthread, long int *sizes)
static realtype vwrmsnormmask_help(N_Vector x, N_Vector w, N_Vector id)
static void * vaddconst(NrnThread *nt)
void N_VDiv_NrnThread(N_Vector x, N_Vector y, N_Vector z)
void N_VAddConst_NrnThread(N_Vector x, realtype b, N_Vector z)
static realtype N_VWL2Norm_helper(N_Vector x, N_Vector w)
static void * vscale(NrnThread *nt)
#define carg
void N_VScale_NrnThread(realtype c, N_Vector x, N_Vector z)
void N_VDestroyVectorArray_NrnThread(N_Vector *vs, int count)
#define zpass
N_Vector N_VCloneEmpty_NrnThread(N_Vector w)
static void * vwrmsnormmask(NrnThread *nt)
#define bpass
void N_VInv_NrnThread(N_Vector x, N_Vector z)
#define mydebug2(a, b)
#define locklongdadd(arg)
static void * vconst(NrnThread *nt)
static void * vabs(NrnThread *nt)
#define lockfalse
#define lockmax(arg)
static void * vlinearsum(NrnThread *nt)
N_Vector N_VMake_NrnThread(long int length, realtype *v_data)
void N_VDestroy_NrnThread(N_Vector v)
static void * vmin(NrnThread *nt)
void N_VOneMask_NrnThread(N_Vector x)
#define lockadd(arg)
#define ldrealtype
static realtype retval
static ldrealtype vwrmsnorm_help(N_Vector x, N_Vector w)
realtype N_VMinQuotient_NrnThread(N_Vector x, N_Vector y)
static void * vdiv(NrnThread *nt)
realtype N_VWL2Norm_NrnThread(N_Vector x, N_Vector w)
static void * vprod(NrnThread *nt)
static realtype c_
static void * vmaxnorm(NrnThread *nt)
N_Vector N_VNewEmpty_NrnThread(long int length, int nthread, long int *sizes)
static void * vminquotient(NrnThread *nt)
static void * vwl2norm(NrnThread *nt)
static void pr(N_Vector x)
#define ZERO
realtype N_VWrmsNormMask_NrnThread(N_Vector x, N_Vector w, N_Vector id)
booleantype N_VConstrMask_NrnThread(N_Vector y, N_Vector x, N_Vector z)
static void * vinv(NrnThread *nt)
#define ypass
#define zarg(i)
#define warg(i)
#define mydebug(a)
N_Vector N_VNew_NrnThread(long int length, int nthread, long int *sizes)
static realtype a_
realtype N_VWrmsNorm_NrnThread(N_Vector x, N_Vector w)
static void * vinvtest(NrnThread *nt)
static void * vl1norm(NrnThread *nt)
static realtype b_
void N_VProd_NrnThread(N_Vector x, N_Vector y, N_Vector z)
void N_VPrint_NrnThread(N_Vector x)
#define yarg(i)
realtype N_VL1Norm_NrnThread(N_Vector x)
realtype N_VMaxNorm_NrnThread(N_Vector x)
#define cpass
#define idpass
static void * vdotprod(NrnThread *nt)
static N_Vector z_
static void * vcompare(NrnThread *nt)
static N_Vector x_
N_Vector N_VClone_NrnThread(N_Vector w)
static void * vwrmsnorm(NrnThread *nt)
realtype * N_VGetArrayPointer_NrnThread(N_Vector v)
#define NV_OWN_DATA_NT(v)
#define NV_SUBVEC_NT(v, i)
void N_VOneMask_Serial(N_Vector x)
#define NV_CONTENT_NT(v)
#define NV_DATA_NT(v)
struct _N_VectorContent_NrnThread * N_VectorContent_NrnThread
#define NV_LENGTH_NT(v)
#define NV_NT_NT(v)
static long double longdretval
#define data
Definition: rbtqueue.cpp:49
#define NULL
Definition: sptree.h:16
Represent main neuron object computed by single thread.
Definition: multicore.h:58
int id
Definition: multicore.h:66