| line |
true |
false |
branch |
|
26
|
46355 |
834 |
if (!(broadcast->gflags & PDL_BROADCAST_MAGICKED)) return broadcast->dims; |
|
28
|
0 |
834 |
if (thr < 0) return NULL; |
|
41
|
46355 |
834 |
if (!(broadcast->gflags & PDL_BROADCAST_MAGICKED)) return broadcast->offs; |
|
43
|
0 |
834 |
if (thr < 0) return NULL; |
|
57
|
1405 |
84859 |
if (broadcast->gflags & PDL_BROADCAST_MAGICKED) { |
|
58
|
1405 |
0 |
if (broadcast->mag_nthpdl < 0 || broadcast->mag_nthpdl >= broadcast->npdls) |
|
|
0 |
1405 |
if (broadcast->mag_nthpdl < 0 || broadcast->mag_nthpdl >= broadcast->npdls) |
|
61
|
0 |
1405 |
if (thr < 0) return NULL; |
|
75
|
0 |
33719 |
PDLDEBUG_f(printf("freebroadcaststruct(%p)\n", broadcast)); |
|
76
|
11 |
33708 |
if (!broadcast->inds) {return;} |
|
87
|
0 |
33708 |
PDLDEBUG_f(printf("clearbroadcaststruct(%p)\n", it)); |
|
109
|
310 |
112 |
for (j=0; j
|
|
110
|
55 |
255 |
if (creating[j]) continue; |
|
112
|
0 |
255 |
if (!broadcastedDims[j]) return pdl_make_error_simple(PDL_EFATAL, "Out of Memory\n"); |
|
114
|
0 |
255 |
if (!broadcastedDimSizes[j]) return pdl_make_error_simple(PDL_EFATAL, "Out of Memory\n"); |
|
116
|
310 |
112 |
for (j=0; j
|
|
117
|
55 |
255 |
if (creating[j]) continue; |
|
118
|
279 |
255 |
for ( k=0, t = realdims[j]; t < pdls[j]->ndims; t++, k++ ){ |
|
126
|
193 |
54 |
for (j=0; j
|
|
127
|
47 |
146 |
if (creating[j]) continue; |
|
128
|
102 |
113 |
for ( k=0; k < nbroadcastedDims[j]; k++){ |
|
131
|
33 |
69 |
if ( this_remainder == 0 ){ |
|
137
|
58 |
11 |
if ( this_dim > *p_maxPthread && this_remainder > max_remainder ){ |
|
|
57 |
1 |
if ( this_dim > *p_maxPthread && this_remainder > max_remainder ){ |
|
145
|
58 |
88 |
if ( *p_maxPthread == target_pthread ) break; |
|
147
|
0 |
112 |
PDLDEBUG_f(pdl_dump_broadcasting_info( |
|
153
|
310 |
112 |
for (j=0; j
|
|
154
|
55 |
255 |
if (creating[j]) continue; |
|
179
|
220 |
39826 |
if ( !target_pthread ) return PDL_err; |
|
183
|
96128 |
39826 |
for (j=0; j
|
|
184
|
27513 |
68615 |
if (creating[j]) continue; |
|
185
|
40768 |
27847 |
MAX2(largest_nvals, pdls[j]->nvals); /* Find largest size */ |
|
189
|
0 |
22 |
PDL_RETERROR(PDL_err, pdl_add_threading_magic(pdls[j], -1, -1)); |
|
192
|
49 |
39777 |
if ( noPthreadFlag ) return PDL_err; /* Don't go further if the current pdl function isn't thread-safe */ |
|
194
|
39665 |
112 |
if ( (largest_nvals>>20 /* as MBytes */) < pdl_autopthread_size ) |
|
197
|
0 |
112 |
PDL_RETERROR(PDL_err, pdl_find_max_pthread( |
|
203
|
64 |
48 |
if ( maxPthread > 1 ) { |
|
204
|
0 |
64 |
PDL_RETERROR(PDL_err, pdl_add_threading_magic(pdls[maxPthreadPDL], maxPthreadDim, maxPthread)); |
|
218
|
0 |
94257 |
PDLDEBUG_f(printf("pdl_dim_checks(load_only=%d) %p:\n", load_only, ind_sizes); |
|
220
|
199897 |
94240 |
for (i=0; inpdls; i++) { |
|
223
|
0 |
199897 |
PDLDEBUG_f(printf("pdl_dim_checks pdl %"IND_FLAG" (creating=%"IND_FLAG" ninds=%"IND_FLAG"): ", i, creating[i], ninds)); |
|
224
|
0 |
199897 |
PDLDEBUG_f(pdl_dump(pdl)); |
|
226
|
96588 |
103309 |
if (!load_only && creating[i]) continue; |
|
|
27621 |
68967 |
if (!load_only && creating[i]) continue; |
|
229
|
35497 |
172259 |
for (j=0; j
|
|
231
|
11810 |
23687 |
if (j >= ndims && ind_sz == -1) |
|
|
5929 |
5881 |
if (j >= ndims && ind_sz == -1) |
|
234
|
1934 |
33563 |
if (load_only && creating[i]) continue; |
|
|
855 |
1079 |
if (load_only && creating[i]) continue; |
|
235
|
20280 |
14362 |
if (ind_sz == -1 || (!(flags & PDL_PARAM_ISPHYS) && j < ndims && ind_sz == 1)) { |
|
|
20041 |
239 |
if (ind_sz == -1 || (!(flags & PDL_PARAM_ISPHYS) && j < ndims && ind_sz == 1)) { |
|
|
8428 |
11613 |
if (ind_sz == -1 || (!(flags & PDL_PARAM_ISPHYS) && j < ndims && ind_sz == 1)) { |
|
|
89 |
8339 |
if (ind_sz == -1 || (!(flags & PDL_PARAM_ISPHYS) && j < ndims && ind_sz == 1)) { |
|
239
|
11626 |
8565 |
if (j >= ndims && isoutput && ind_sz != 1) |
|
|
7 |
11619 |
if (j >= ndims && isoutput && ind_sz != 1) |
|
|
5 |
2 |
if (j >= ndims && isoutput && ind_sz != 1) |
|
245
|
852 |
19334 |
if (isoutput && ind_sz != 1 && pdl->vafftrans && pdl->vafftrans->incs[j] == 0) |
|
|
835 |
17 |
if (isoutput && ind_sz != 1 && pdl->vafftrans && pdl->vafftrans->incs[j] == 0) |
|
|
255 |
580 |
if (isoutput && ind_sz != 1 && pdl->vafftrans && pdl->vafftrans->incs[j] == 0) |
|
|
2 |
253 |
if (isoutput && ind_sz != 1 && pdl->vafftrans && pdl->vafftrans->incs[j] == 0) |
|
251
|
8563 |
11621 |
if (j < ndims && ind_sz != dims[j] && (isoutput || dims[j] != 1)) |
|
|
12 |
8551 |
if (j < ndims && ind_sz != dims[j] && (isoutput || dims[j] != 1)) |
|
|
4 |
8 |
if (j < ndims && ind_sz != dims[j] && (isoutput || dims[j] != 1)) |
|
|
0 |
4 |
if (j < ndims && ind_sz != dims[j] && (isoutput || dims[j] != 1)) |
|
257
|
8555 |
11621 |
if (j < ndims && ind_sz != dims[j] && |
|
|
4 |
8551 |
if (j < ndims && ind_sz != dims[j] && |
|
|
2 |
2 |
if (j < ndims && ind_sz != dims[j] && |
|
258
|
2 |
0 |
!load_only && !creating[i] && |
|
|
2 |
0 |
!load_only && !creating[i] && |
|
260
|
2 |
0 |
(flags & PDL_PARAM_ISPHYS) |
|
269
|
0 |
94240 |
PDLDEBUG_f(printf("pdl_dim_checks after:\n"); |
|
282
|
23459 |
40033 |
for (nth=0; nth
|
|
283
|
50323 |
23446 |
for (j=0; j
|
|
284
|
9848 |
40475 |
if (creating[j]) continue; // If jth PDL is null, don't bother trying to match |
|
285
|
40444 |
31 |
char isoutput = (vtable && j >= vtable->nparents); |
|
|
13820 |
26624 |
char isoutput = (vtable && j >= vtable->nparents); |
|
286
|
8961 |
31514 |
if (nth >= pdls[j]->broadcastids[0]-realdims[j]) { /* off end of current PDL's dimlist */ |
|
287
|
14 |
8947 |
if (isoutput && broadcast->dims[nth] != 1) |
|
|
5 |
9 |
if (isoutput && broadcast->dims[nth] != 1) |
|
296
|
13806 |
17708 |
if (isoutput && cur_pdl_dim == 1 && cur_pdl_dim != broadcast->dims[nth]) |
|
|
4273 |
9533 |
if (isoutput && cur_pdl_dim == 1 && cur_pdl_dim != broadcast->dims[nth]) |
|
|
5 |
4268 |
if (isoutput && cur_pdl_dim == 1 && cur_pdl_dim != broadcast->dims[nth]) |
|
302
|
13801 |
17708 |
if (isoutput && cur_pdl_dim != 1 && pdls[j]->vafftrans && pdls[j]->vafftrans->incs[nth+realdims[j]] == 0) |
|
|
9533 |
4268 |
if (isoutput && cur_pdl_dim != 1 && pdls[j]->vafftrans && pdls[j]->vafftrans->incs[nth+realdims[j]] == 0) |
|
|
1243 |
8290 |
if (isoutput && cur_pdl_dim != 1 && pdls[j]->vafftrans && pdls[j]->vafftrans->incs[nth+realdims[j]] == 0) |
|
|
2 |
1241 |
if (isoutput && cur_pdl_dim != 1 && pdls[j]->vafftrans && pdls[j]->vafftrans->incs[nth+realdims[j]] == 0) |
|
308
|
25382 |
6125 |
if (cur_pdl_dim != 1) { // If the current dim in the current PDL is not 1, |
|
309
|
6968 |
18414 |
if (broadcast->dims[nth] != 1) { // ... and the current planned size isn't 1, |
|
310
|
1 |
6967 |
if (broadcast->dims[nth] != cur_pdl_dim) // ... then check to make sure they're the same. |
|
321
|
4322 |
21059 |
PDL_REPRINC(pdls[j],nth+realdims[j]);// from the PDL or from its vafftrans if relevant. |
|
347
|
0 |
40046 |
PDLDEBUG_f(printf("initbroadcaststruct(%p)\n", broadcast)); |
|
348
|
6338 |
33708 |
char already_alloced = (broadcast->magicno == PDL_BRC_MAGICNO && |
|
349
|
6338 |
0 |
broadcast->gflags & PDL_BROADCAST_INITIALIZED); |
|
350
|
6338 |
33708 |
PDL_Indx already_nthr = already_alloced ? broadcast->mag_nthr : -1; |
|
351
|
6338 |
33708 |
PDL_Indx already_ndims = already_alloced ? broadcast->ndims : -1; |
|
365
|
96666 |
40046 |
for (j=0; j
|
|
366
|
27633 |
69033 |
if (creating[j]) continue; |
|
367
|
40037 |
28996 |
MAX2(nids,pdls[j]->nbroadcastids); |
|
368
|
19292 |
49741 |
MAX2(nimpl,pdls[j]->broadcastids[0] - realdims[j]); |
|
372
|
0 |
40046 |
PDL_RETERROR(PDL_err, pdl_autopthreadmagic(pdls, npdls, realdims, creating, noPthreadFlag)); |
|
375
|
96666 |
40046 |
for (j=0; j
|
|
376
|
27633 |
69033 |
if (creating[j]) continue; |
|
378
|
68829 |
204 |
if (!nthr && |
|
379
|
111 |
68718 |
pdls[j]->magic && |
|
380
|
111 |
0 |
(nthr = pdl_magic_thread_nthreads(pdls[j],&nthrd)) |
|
382
|
0 |
111 |
if ((broadcast->mag_nth = nthrd - realdims[j]) < 0) |
|
389
|
69039 |
69033 |
for (i=0; i
|
|
391
|
69039 |
0 |
PDLMAX(0, pdls[j]->nbroadcastids > nids ? 0 : |
|
|
25383 |
43656 |
PDLMAX(0, pdls[j]->nbroadcastids > nids ? 0 : |
|
|
25383 |
0 |
PDLMAX(0, pdls[j]->nbroadcastids > nids ? 0 : |
|
394
|
111 |
39935 |
if (nthr) |
|
401
|
6338 |
33708 |
if (!already_alloced || already_nthr != nthr1 || ndims != already_ndims) { |
|
|
0 |
6338 |
if (!already_alloced || already_nthr != nthr1 || ndims != already_ndims) { |
|
|
0 |
0 |
if (!already_alloced || already_nthr != nthr1 || ndims != already_ndims) { |
|
402
|
6338 |
33708 |
if (already_alloced) { |
|
407
|
0 |
40046 |
Newxz(broadcast->inds, ndims * nthr1, PDL_Indx); /* Create space for pthread-specific inds (i.e. copy for each pthread)*/ |
|
408
|
0 |
40046 |
if (broadcast->inds == NULL) return pdl_make_error_simple(PDL_EFATAL, "Failed to allocate memory for broadcast->inds in pdlbroadcast.c"); |
|
409
|
0 |
40046 |
Newxz(broadcast->dims, ndims * nthr1, PDL_Indx); |
|
410
|
0 |
40046 |
if (broadcast->dims == NULL) return pdl_make_error_simple(PDL_EFATAL, "Failed to allocate memory for broadcast->dims in pdlbroadcast.c"); |
|
411
|
0 |
40046 |
Newxz(broadcast->offs, npdls * nthr1, PDL_Indx); /* Create space for pthread-specific offs */ |
|
412
|
0 |
40046 |
if (broadcast->offs == NULL) return pdl_make_error_simple(PDL_EFATAL, "Failed to allocate memory for broadcast->offs in pdlbroadcast.c"); |
|
415
|
80926 |
40046 |
for (nth=0; nthdims[nth]=1; // all start size 1 |
|
417
|
33708 |
6338 |
if (!already_alloced) { |
|
419
|
0 |
33708 |
Newxz(broadcast->incs, ndims * npdls, PDL_Indx); |
|
420
|
0 |
33708 |
if (broadcast->incs == NULL) return pdl_make_error_simple(PDL_EFATAL, "Failed to allocate memory for broadcast->incs in pdlbroadcast.c"); |
|
422
|
0 |
33708 |
if (broadcast->flags == NULL) return pdl_make_error_simple(PDL_EFATAL, "Failed to allocate memory for broadcast->flags in pdlbroadcast.c"); |
|
426
|
96666 |
40046 |
for (i=0;i
|
|
427
|
96635 |
31 |
if (vtable && vtable->par_flags[i] & PDL_PARAM_ISTEMP) |
|
|
181 |
96454 |
if (vtable && vtable->par_flags[i] & PDL_PARAM_ISTEMP) |
|
431
|
13 |
40033 |
PDL_RETERROR(PDL_err, pdl_broadcast_dim_checks( |
|
438
|
40026 |
40033 |
for (nthid=0; nthid
|
|
439
|
4 |
40026 |
for (i=0; i
|
|
440
|
8 |
4 |
for (j=0; j
|
|
442
|
0 |
8 |
if (PDL_BISTEMP(flags[j])) |
|
445
|
0 |
8 |
if (creating[j]) continue; |
|
446
|
0 |
8 |
if (pdl->nbroadcastids < nthid) continue; |
|
447
|
0 |
8 |
if (pdl->broadcastids[nthid+1]-pdl->broadcastids[nthid] <= i) continue; |
|
449
|
0 |
8 |
if (mydim == 1) continue; |
|
450
|
4 |
4 |
if (broadcast->dims[nth] == 1) { |
|
453
|
0 |
4 |
if (broadcast->dims[nth] != mydim) |
|
462
|
6 |
2 |
PDL_REPRINC(pdl,mywhichdim); |
|
469
|
111 |
39922 |
if (nthr > 0) { |
|
473
|
46 |
65 |
if (n2) { |
|
478
|
453 |
111 |
for (i=1; i
|
|
479
|
1001 |
453 |
for (j=0; j
|
|
481
|
46 |
65 |
if (n2) |
|
482
|
308 |
46 |
for (i=n2; i
|
|
486
|
0 |
40033 |
PDLDEBUG_f(pdl_dump_broadcast(broadcast)); |
|
495
|
27448 |
181 |
PDL_Indx td = temp ? 0 : broadcast->nimpl; |
|
496
|
27448 |
181 |
if (!temp && broadcast->nimpl != broadcast->ndims - broadcast->nextra) { |
|
|
0 |
27448 |
if (!temp && broadcast->nimpl != broadcast->ndims - broadcast->nextra) { |
|
504
|
0 |
27629 |
if (!broadcast->pdls[j] && !(broadcast->pdls[j] = pdl_pdlnew())) |
|
|
0 |
0 |
if (!broadcast->pdls[j] && !(broadcast->pdls[j] = pdl_pdlnew())) |
|
506
|
181 |
27448 |
PDL_RETERROR(PDL_err, pdl_reallocdims(broadcast->pdls[j], broadcast->realdims[j] + td + (temp ? 1 : 0))); |
|
|
0 |
27629 |
PDL_RETERROR(PDL_err, pdl_reallocdims(broadcast->pdls[j], broadcast->realdims[j] + td + (temp ? 1 : 0))); |
|
507
|
549 |
40949 |
for (i=0; irealdims[j] + (temp ? 1 : 0); i++) |
|
|
13869 |
27629 |
for (i=0; irealdims[j] + (temp ? 1 : 0); i++) |
|
509
|
27448 |
181 |
if (!temp) |
|
510
|
9831 |
27448 |
for (i=0; inimpl; i++) |
|
512
|
14 |
0 |
(i == broadcast->mag_nth && broadcast->mag_nthr > 0) |
|
514
|
14 |
9817 |
: broadcast->dims[i]; |
|
517
|
9846 |
27629 |
for (i=0; inimpl; i++) { |
|
519
|
9831 |
15 |
temp ? 0 : |
|
520
|
0 |
9831 |
PDL_REPRINC(broadcast->pdls[j],i+broadcast->realdims[j]); |
|
528
|
115 |
39017 |
if ((broadcast->gflags & (PDL_BROADCAST_MAGICKED | PDL_BROADCAST_MAGICK_BUSY)) |
|
531
|
0 |
115 |
if (!func) |
|
536
|
344 |
115 |
for (j=0; j
|
|
537
|
344 |
0 |
if (!(t->vtable->par_flags[j] & PDL_PARAM_ISTEMP)) continue; |
|
542
|
0 |
0 |
if (PDL_err.error) { |
|
549
|
1 |
114 |
if (PDL_err.error) { |
|
559
|
0 |
39017 |
if (!offsp) return -1; |
|
560
|
78630 |
38689 |
for (j=0; jndims; j++) |
|
561
|
328 |
78302 |
if (!dims[j]) return 1; /* do nothing if empty */ |
|
562
|
92657 |
38689 |
for (j=0; j
|
|
563
|
18159 |
74498 |
offsp[j] = PDL_BRC_THR_OFFSET(broadcast, thr, j); |
|
|
1369 |
91288 |
offsp[j] = PDL_BRC_THR_OFFSET(broadcast, thr, j); |
|
|
0 |
1369 |
offsp[j] = PDL_BRC_THR_OFFSET(broadcast, thr, j); |
|
573
|
0 |
47247 |
if (!offsp) return -1; |