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 #define USELONGDOUBLE 1
20 
21 #include <stdio.h>
22 #include <stdlib.h>
23 
24 #include "shared/nvector_serial.h"
25 #include "nvector_nrnthread_ld.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 NrnThreadLD 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_LD(x_, i)
76 #define yarg(i) NV_SUBVEC_NT_LD(y_, i)
77 #define zarg(i) NV_SUBVEC_NT_LD(z_, i)
78 #define warg(i) NV_SUBVEC_NT_LD(w_, i)
79 #define idarg(i) NV_SUBVEC_NT_LD(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_NrnThreadLD(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_NrnThreadLD;
147  ops->nvdestroy = N_VDestroy_NrnThreadLD;
148  ops->nvspace = N_VSpace_NrnThreadLD;
149  ops->nvgetarraypointer = N_VGetArrayPointer_NrnThreadLD;
150  ops->nvsetarraypointer = N_VSetArrayPointer_NrnThreadLD;
151  ops->nvlinearsum = N_VLinearSum_NrnThreadLD;
152  ops->nvconst = N_VConst_NrnThreadLD;
153  ops->nvprod = N_VProd_NrnThreadLD;
154  ops->nvdiv = N_VDiv_NrnThreadLD;
155  ops->nvscale = N_VScale_NrnThreadLD;
156  ops->nvabs = N_VAbs_NrnThreadLD;
157  ops->nvinv = N_VInv_NrnThreadLD;
158  ops->nvaddconst = N_VAddConst_NrnThreadLD;
159  ops->nvdotprod = N_VDotProd_NrnThreadLD;
160  ops->nvmaxnorm = N_VMaxNorm_NrnThreadLD;
161  ops->nvwrmsnormmask = N_VWrmsNormMask_NrnThreadLD;
162  ops->nvwrmsnorm = N_VWrmsNorm_NrnThreadLD;
163  ops->nvmin = N_VMin_NrnThreadLD;
164  ops->nvwl2norm = N_VWL2Norm_NrnThreadLD;
165  ops->nvl1norm = N_VL1Norm_NrnThreadLD;
166  ops->nvcompare = N_VCompare_NrnThreadLD;
167  ops->nvinvtest = N_VInvTest_NrnThreadLD;
168  ops->nvconstrmask = N_VConstrMask_NrnThreadLD;
169  ops->nvminquotient = N_VMinQuotient_NrnThreadLD;
170 
171  /* Create content */
172  content = (N_VectorContent_NrnThreadLD) malloc(sizeof(struct _N_VectorContent_NrnThreadLD));
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_NrnThreadLD(long int length, int nthread, long int* sizes) {
204  int i;
205  N_Vector v;
206  N_Vector data;
208 
209  v = N_VNewEmpty_NrnThreadLD(length, nthread, sizes);
210  if (v == NULL)
211  return (NULL);
212 
213  /* Create data */
214  if (length > 0) {
215  /* Allocate memory */
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_LD(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_NrnThreadLD(N_Vector w) {
235  int i;
236  N_Vector v;
237  N_Vector_Ops ops;
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_NrnThreadLD) malloc(sizeof(struct _N_VectorContent_NrnThreadLD));
283  if (content == NULL) {
284  free(ops);
285  free(v);
286  return (NULL);
287  }
288 
289  wcontent = NV_CONTENT_NT_LD(w);
290  content->length = NV_LENGTH_NT_LD(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_NrnThreadLD(long int length, realtype* v_data) {
316  N_Vector v = NULL;
317 
318  assert(0);
319 #if 0
320  v = N_VNewEmpty_NrnThreadLD(length);
321  if (v == NULL) return(NULL);
322 
323  if (length > 0) {
324  /* Attach data */
326  NV_DATA_NT_LD(v) = v_data;
327  }
328 #endif
329  return (v);
330 }
331 
332 /* ----------------------------------------------------------------------------
333  * Function to create an array of new nrnthread vectors.
334  */
335 
336 N_Vector* N_VNewVectorArray_NrnThreadLD(int count, long int length, int nthread, long int* sizes) {
337  N_Vector* vs;
338  int j;
339 
340  if (count <= 0)
341  return (NULL);
342 
343  vs = (N_Vector*) malloc(count * sizeof(N_Vector));
344  if (vs == NULL)
345  return (NULL);
346 
347  for (j = 0; j < count; j++) {
348  vs[j] = N_VNew_NrnThreadLD(length, nthread, sizes);
349  if (vs[j] == NULL) {
351  return (NULL);
352  }
353  }
354 
355  return (vs);
356 }
357 
358 /* ----------------------------------------------------------------------------
359  * Function to create an array of new nrnthread vectors with NULL data array.
360  */
361 
363  long int length,
364  int nthread,
365  long int* sizes) {
366  N_Vector* vs;
367  int j;
368 
369  if (count <= 0)
370  return (NULL);
371 
372  vs = (N_Vector*) malloc(count * sizeof(N_Vector));
373  if (vs == NULL)
374  return (NULL);
375 
376  for (j = 0; j < count; j++) {
377  vs[j] = N_VNewEmpty_NrnThreadLD(length, nthread, sizes);
378  if (vs[j] == NULL) {
380  return (NULL);
381  }
382  }
383 
384  return (vs);
385 }
386 
387 /* ----------------------------------------------------------------------------
388  * Function to free an array created with N_VNewVectorArray_NrnThreadLD
389  */
390 
391 void N_VDestroyVectorArray_NrnThreadLD(N_Vector* vs, int count) {
392  int j;
393 
394  for (j = 0; j < count; j++)
396 
397  free(vs);
398 }
399 
400 /* ----------------------------------------------------------------------------
401  * Function to print the a nrnthread vector
402  */
403 
404 void N_VPrint_NrnThreadLD(N_Vector x) {
405  int i;
406  int nt;
407 
408  nt = NV_NT_NT_LD(x);
409 
410  for (i = 0; i < nt; i++) {
411  N_VPrint_Serial(NV_SUBVEC_NT_LD(x, i));
412  }
413  printf("\n");
414 }
415 
416 static void pr(N_Vector x) {
418 }
419 /*
420  * -----------------------------------------------------------------
421  * implementation of vector operations
422  * -----------------------------------------------------------------
423  */
424 
425 N_Vector N_VClone_NrnThreadLD(N_Vector w) {
426  N_Vector v;
427  N_Vector wdata;
428  N_Vector data;
429  long int length;
430  int i, nt;
431 
433  if (v == NULL)
434  return (NULL);
435 
436  length = NV_LENGTH_NT_LD(w);
437  nt = NV_NT_NT_LD(w);
438 
439  /* Create data */
440  if (length > 0) {
442  for (i = 0; i < nt; ++i) {
443  wdata = NV_SUBVEC_NT_LD(w, i);
444  data = N_VClone(wdata);
445  if (data == NULL) {
447  return (NULL);
448  }
449  NV_SUBVEC_NT_LD(v, i) = data;
450  }
451  /* Attach data */
452  }
453 
454  return (v);
455 }
456 
457 void N_VDestroy_NrnThreadLD(N_Vector v) {
458  int i, nt;
459  N_Vector data;
460  nt = NV_NT_NT_LD(v);
461  if (NV_OWN_DATA_NT_LD(v) == TRUE) {
462  if (NV_CONTENT_NT_LD(v)->data) {
463  for (i = 0; i < nt; ++i) {
464  data = NV_SUBVEC_NT_LD(v, i);
465  if (data) {
466  N_VDestroy(data);
467  }
468  }
469  free(NV_CONTENT_NT_LD(v)->data);
470  }
471  }
472  free(v->content);
473  free(v->ops);
474  free(v);
475 }
476 
477 void N_VSpace_NrnThreadLD(N_Vector v, long int* lrw, long int* liw) {
478  *lrw = NV_LENGTH_NT_LD(v);
479  *liw = 1;
480 }
481 
482 /* NOTICE: the pointer returned is actually the NVector* data where
483 data is nthread NVector. so when you get the realtype* cast it back to
484 (NVector*)
485 */
486 realtype* N_VGetArrayPointer_NrnThreadLD(N_Vector v) {
487  N_Vector* v_data;
488  v_data = NV_DATA_NT_LD(v);
489 
490  return ((realtype*) v_data);
491 }
492 
493 void N_VSetArrayPointer_NrnThreadLD(realtype* v_data, N_Vector v) {
494  assert(0);
495 #if 0
496  if (NV_LENGTH_NT_LD(v) > 0) NV_DATA_NT_LD(v) = v_data;
497 #endif
498 }
499 
500 static void* vlinearsum(NrnThread* nt) {
501  int i = nt->id;
502  N_VLinearSum_Serial(aarg, xarg(i), barg, yarg(i), zarg(i));
503  return nullptr;
504 }
505 void N_VLinearSum_NrnThreadLD(realtype a, N_Vector x, realtype b, N_Vector y, N_Vector z) {
507  mydebug("vlinearsum\n");
508  /*pr(z);*/
509 }
510 
511 static void* vconst(NrnThread* nt) {
512  int i = nt->id;
513  N_VConst_Serial(carg, zarg(i));
514  return nullptr;
515 }
516 void N_VConst_NrnThreadLD(realtype c, N_Vector z) {
518  mydebug("vconst\n");
519 }
520 
521 static void* vprod(NrnThread* nt) {
522  int i = nt->id;
523  N_VProd_Serial(xarg(i), yarg(i), zarg(i));
524  return nullptr;
525 }
526 void N_VProd_NrnThreadLD(N_Vector x, N_Vector y, N_Vector z) {
528  mydebug("vprod\n");
529 }
530 
531 static void* vdiv(NrnThread* nt) {
532  int i = nt->id;
533  N_VDiv_Serial(xarg(i), yarg(i), zarg(i));
534  return nullptr;
535 }
536 void N_VDiv_NrnThreadLD(N_Vector x, N_Vector y, N_Vector z) {
538  mydebug("vdiv\n");
539 }
540 
541 static void* vscale(NrnThread* nt) {
542  int i = nt->id;
543  N_VScale_Serial(carg, xarg(i), zarg(i));
544  return nullptr;
545 }
546 void N_VScale_NrnThreadLD(realtype c, N_Vector x, N_Vector z) {
548  mydebug("vscale\n");
549  /*pr(z);*/
550 }
551 
552 static void* vabs(NrnThread* nt) {
553  int i = nt->id;
554  N_VAbs_Serial(xarg(i), zarg(i));
555  return nullptr;
556 }
557 void N_VAbs_NrnThreadLD(N_Vector x, N_Vector z) {
559  mydebug("vabs\n");
560 }
561 
562 static void* vinv(NrnThread* nt) {
563  int i = nt->id;
564  N_VInv_Serial(xarg(i), zarg(i));
565  return nullptr;
566 }
567 void N_VInv_NrnThreadLD(N_Vector x, N_Vector z) {
569  mydebug("vinv\n");
570 }
571 
572 static void* vaddconst(NrnThread* nt) {
573  int i = nt->id;
574  N_VAddConst_Serial(xarg(i), barg, zarg(i));
575  return nullptr;
576 }
577 void N_VAddConst_NrnThreadLD(N_Vector x, realtype b, N_Vector z) {
579  mydebug("vaddconst\n");
580 }
581 
582 static void* vdotprod(NrnThread* nt) {
583  realtype s;
584  int i = nt->id;
585  s = N_VDotProd_Serial(xarg(i), yarg(i));
586  lockadd(s);
587  return nullptr;
588 }
589 realtype N_VDotProd_NrnThreadLD(N_Vector x, N_Vector y) {
590  retval = ZERO;
592  mydebug2("vdotprod %.20g\n", retval);
593  return (retval);
594 }
595 
596 static void* vmaxnorm(NrnThread* nt) {
597  realtype max;
598  int i = nt->id;
599  max = N_VMaxNorm_Serial(xarg(i));
600  lockmax(max);
601  return nullptr;
602 }
603 realtype N_VMaxNorm_NrnThreadLD(N_Vector x) {
604  retval = ZERO;
606  mydebug2("vmaxnorm %.20g\n", retval);
607  return (retval);
608 }
609 
610 
611 static ldrealtype vwrmsnorm_help(N_Vector x, N_Vector w) {
612  long int i, N;
613  ldrealtype sum = ZERO;
614  realtype prodi, *xd, *wd;
615 
616  N = NV_LENGTH_S(x);
617  xd = NV_DATA_S(x);
618  wd = NV_DATA_S(w);
619 
620  for (i = 0; i < N; i++) {
621  prodi = (*xd++) * (*wd++);
622  sum += prodi * prodi;
623  }
624 
625  return (sum);
626 }
627 static void* vwrmsnorm(NrnThread* nt) {
628  ldrealtype s;
629  int i = nt->id;
630  s = vwrmsnorm_help(xarg(i), warg(i));
631  locklongdadd(s);
632  return nullptr;
633 }
634 realtype N_VWrmsNorm_NrnThreadLD(N_Vector x, N_Vector w) {
635  long int N;
636  N = NV_LENGTH_NT_LD(x);
637 #if USELONGDOUBLE
638  longdretval = ZERO;
639 #else
640  retval = ZERO;
641 #endif
643 #if USELONGDOUBLE
645 #endif
646  mydebug2("vwrmsnorm %.20g\n", RSqrt(retval / N));
647  return (RSqrt(retval / N));
648 }
649 
650 static realtype vwrmsnormmask_help(N_Vector x, N_Vector w, N_Vector id) {
651  long int i, N;
652  realtype sum = ZERO, prodi, *xd, *wd, *idd;
653 
654  N = NV_LENGTH_S(x);
655  xd = NV_DATA_S(x);
656  wd = NV_DATA_S(w);
657  idd = NV_DATA_S(id);
658 
659  for (i = 0; i < N; i++) {
660  if (idd[i] > ZERO) {
661  prodi = xd[i] * wd[i];
662  sum += prodi * prodi;
663  }
664  }
665 
666  return (sum);
667 }
668 static void* vwrmsnormmask(NrnThread* nt) {
669  realtype s;
670  int i = nt->id;
671  s = vwrmsnormmask_help(xarg(i), warg(i), idarg(i));
672  lockadd(s);
673  return nullptr;
674 }
675 realtype N_VWrmsNormMask_NrnThreadLD(N_Vector x, N_Vector w, N_Vector id) {
676  long int N;
677  N = NV_LENGTH_NT_LD(x);
678  retval = ZERO;
680  mydebug2("vwrmsnormmask %.20g\n", RSqrt(retval / N));
681  return (RSqrt(retval / N));
682 }
683 
684 static void* vmin(NrnThread* nt) {
685  realtype min;
686  int i = nt->id;
687  if (NV_LENGTH_S(xarg(i))) {
688  min = N_VMin_Serial(xarg(i));
689  lockmin(min);
690  }
691  return nullptr;
692 }
693 realtype N_VMin_NrnThreadLD(N_Vector x) {
694  retval = BIG_REAL;
696  mydebug2("vmin %.20g\n", retval);
697  return (retval);
698 }
699 
700 static realtype N_VWL2Norm_helper(N_Vector x, N_Vector w) {
701  long int i, N;
702  realtype sum = ZERO, prodi, *xd, *wd;
703 
704  N = NV_LENGTH_S(x);
705  xd = NV_DATA_S(x);
706  wd = NV_DATA_S(w);
707 
708  for (i = 0; i < N; i++) {
709  prodi = (*xd++) * (*wd++);
710  sum += prodi * prodi;
711  }
712 
713  return sum;
714 }
715 static void* vwl2norm(NrnThread* nt) {
716  realtype sum;
717  int i = nt->id;
718  sum = N_VWL2Norm_helper(xarg(i), warg(i));
719  lockadd(sum);
720  return nullptr;
721 }
722 realtype N_VWL2Norm_NrnThreadLD(N_Vector x, N_Vector w) {
723  long int N;
724  retval = ZERO;
726  N = NV_LENGTH_NT_LD(x);
727  mydebug2("vwl2norm %.20g\n", RSqrt(retval));
728  return (RSqrt(retval));
729 }
730 
731 static void* vl1norm(NrnThread* nt) {
732  realtype sum;
733  int i = nt->id;
734  sum = N_VL1Norm_Serial(xarg(i));
735  lockadd(sum);
736  return nullptr;
737 }
738 realtype N_VL1Norm_NrnThreadLD(N_Vector x) {
739  retval = ZERO;
741  mydebug2("vl1norm %.20g\n", retval);
742  return (retval);
743 }
744 
745 static void* v1mask(NrnThread* nt) {
746  int i = nt->id;
748  return nullptr;
749 }
750 void N_VOneMask_NrnThreadLD(N_Vector x) {
752 }
753 
754 static void* vcompare(NrnThread* nt) {
755  int i = nt->id;
756  N_VCompare_Serial(carg, xarg(i), zarg(i));
757  return nullptr;
758 }
759 void N_VCompare_NrnThreadLD(realtype c, N_Vector x, N_Vector z) {
761  mydebug("vcompare\n");
762 }
763 
764 static void* vinvtest(NrnThread* nt) {
765  booleantype b;
766  int i = nt->id;
767  b = N_VInvTest_Serial(xarg(i), zarg(i));
768  if (!b) {
769  lockfalse;
770  }
771  return nullptr;
772 }
773 booleantype N_VInvTest_NrnThreadLD(N_Vector x, N_Vector z) {
774  bretval = TRUE;
776  mydebug2("vinvtest %d\n", bretval);
777  return (bretval);
778 }
779 
780 static void* vconstrmask(NrnThread* nt) {
781  booleantype b;
782  int i = nt->id;
783  b = N_VConstrMask_Serial(yarg(i), xarg(i), zarg(i));
784  if (!b) {
785  lockfalse;
786  }
787  return nullptr;
788 }
789 booleantype N_VConstrMask_NrnThreadLD(N_Vector y, N_Vector x, N_Vector z) {
790  bretval = TRUE;
792  mydebug2("vconstrmask %d\n", bretval);
793  return (bretval);
794 }
795 
796 static void* vminquotient(NrnThread* nt) {
797  realtype min;
798  int i = nt->id;
799  min = N_VMinQuotient_Serial(xarg(i), yarg(i));
800  lockmin(min);
801  return nullptr;
802 }
803 realtype N_VMinQuotient_NrnThreadLD(N_Vector x, N_Vector y) /* num, denom */
804 {
805  retval = BIG_REAL;
807  mydebug2("vminquotient %.20g\n", retval);
808  return (retval);
809 }
#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_VOneMask_Serial(N_Vector x)
#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)
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)
#define locklongdadd(arg)
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)
#define ldrealtype
static realtype retval
realtype N_VWrmsNormMask_NrnThreadLD(N_Vector x, N_Vector w, N_Vector id)
static ldrealtype vwrmsnorm_help(N_Vector x, N_Vector w)
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 long double longdretval
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)
#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)
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 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