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