| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#ifndef __PDLTHREAD_H |
|
2
|
|
|
|
|
|
|
#define __PDLTHREAD_H |
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
#define PDL_BROADCAST_MAGICKED (1 << 0) |
|
5
|
|
|
|
|
|
|
#define PDL_BROADCAST_MAGICK_BUSY (1 << 1) |
|
6
|
|
|
|
|
|
|
#define PDL_BROADCAST_INITIALIZED (1 << 2) |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
#define PDL_LIST_FLAGS_PDLBROADCAST(X) \ |
|
9
|
|
|
|
|
|
|
X(PDL_BROADCAST_MAGICKED) \ |
|
10
|
|
|
|
|
|
|
X(PDL_BROADCAST_MAGICK_BUSY) \ |
|
11
|
|
|
|
|
|
|
X(PDL_BROADCAST_INITIALIZED) |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
#define PDL_BRC_MAGICNO 0x92314764 |
|
14
|
|
|
|
|
|
|
#define PDL_BRC_CHKMAGIC(it) PDL_CHKMAGIC_GENERAL(it, PDL_BRC_MAGICNO, "BROADCAST") |
|
15
|
|
|
|
|
|
|
#define PDL_BRC_SETMAGIC(it) (it)->magicno = PDL_BRC_MAGICNO |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
/* XXX To avoid mallocs, these should also have "default" values */ |
|
18
|
|
|
|
|
|
|
typedef struct pdl_broadcast { |
|
19
|
|
|
|
|
|
|
struct pdl_transvtable *transvtable; |
|
20
|
|
|
|
|
|
|
unsigned int magicno; |
|
21
|
|
|
|
|
|
|
int gflags; /* Flags about this struct */ |
|
22
|
|
|
|
|
|
|
PDL_Indx ndims; /* Number of dimensions broadcasted over */ |
|
23
|
|
|
|
|
|
|
PDL_Indx nimpl; /* Number of these that are implicit */ |
|
24
|
|
|
|
|
|
|
PDL_Indx npdls; /* Number of pdls involved */ |
|
25
|
|
|
|
|
|
|
PDL_Indx nextra; |
|
26
|
|
|
|
|
|
|
PDL_Indx *inds; /* Indices for each of the dimensions */ |
|
27
|
|
|
|
|
|
|
PDL_Indx *dims; /* Dimensions of each dimension */ |
|
28
|
|
|
|
|
|
|
PDL_Indx *offs; /* Offsets for each of the pdls */ |
|
29
|
|
|
|
|
|
|
PDL_Indx *incs; /* npdls * ndims array of increments. Fast because |
|
30
|
|
|
|
|
|
|
of constant indices for first loops */ |
|
31
|
|
|
|
|
|
|
PDL_Indx *realdims; /* realdims for each pdl (e.g., specified by PP signature) */ |
|
32
|
|
|
|
|
|
|
pdl **pdls; |
|
33
|
|
|
|
|
|
|
char *flags; /* per pdl flags */ |
|
34
|
|
|
|
|
|
|
PDL_Indx mag_nth; /* magicked thread dim */ |
|
35
|
|
|
|
|
|
|
PDL_Indx mag_nthpdl; /* magicked ndarray */ |
|
36
|
|
|
|
|
|
|
PDL_Indx mag_nthr; /* number of threads */ |
|
37
|
|
|
|
|
|
|
PDL_Indx mag_skip; /* first pthread to skip if remainder, 0=none */ |
|
38
|
|
|
|
|
|
|
PDL_Indx mag_stride; /* the base size to stride, without adding 1 if before drop */ |
|
39
|
|
|
|
|
|
|
/* |
|
40
|
|
|
|
|
|
|
** |
|
41
|
|
|
|
|
|
|
t**** |
|
42
|
|
|
|
|
|
|
**** |
|
43
|
|
|
|
|
|
|
**** |
|
44
|
|
|
|
|
|
|
--k--->thr (zero-based) |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
t=3 (mag_stride) |
|
47
|
|
|
|
|
|
|
k=2 (mag_skip) |
|
48
|
|
|
|
|
|
|
offsets=[0,4,8,11,14] |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
t**** |
|
51
|
|
|
|
|
|
|
**** |
|
52
|
|
|
|
|
|
|
**** |
|
53
|
|
|
|
|
|
|
k----->thr (zero-based) |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
t=3 (mag_stride) |
|
56
|
|
|
|
|
|
|
k=0 (mag_skip) |
|
57
|
|
|
|
|
|
|
offsets=[0,3,6,9,12] |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
offset=thr*t + MIN(thr,k) // see macro PDL_BRC_OFFSET |
|
60
|
|
|
|
|
|
|
*/ |
|
61
|
|
|
|
|
|
|
} pdl_broadcast; |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
#define PDL_BRC_OFFSET(thr, broadcast) ((thr)*((broadcast)->mag_stride) + PDLMIN((thr),(broadcast)->mag_skip)) |
|
64
|
|
|
|
|
|
|
#define PDL_BRC_INC(incs, npdls, p, d) ((incs)[(d)*(npdls) + (p)]) |
|
65
|
|
|
|
|
|
|
#define PDL_BRC_THR_OFFSET(broadcast, thr, j) \ |
|
66
|
|
|
|
|
|
|
(PDL_REPROFFS(broadcast->pdls[j]) + ( \ |
|
67
|
|
|
|
|
|
|
!thr ? 0 : \ |
|
68
|
|
|
|
|
|
|
PDL_BISTEMP(broadcast->flags[j]) ? thr * broadcast->pdls[j]->dimincs[broadcast->pdls[j]->ndims-1] : \ |
|
69
|
|
|
|
|
|
|
PDL_BRC_OFFSET(thr, broadcast) * PDL_BRC_INC(broadcast->incs, broadcast->npdls, j, broadcast->mag_nth) \ |
|
70
|
|
|
|
|
|
|
)) |
|
71
|
|
|
|
|
|
|
|
|
72
|
47247
|
|
|
|
|
|
static inline int pdl_broadcast_nd_step( |
|
73
|
|
|
|
|
|
|
PDL_Indx npdls, PDL_Indx *offsp, |
|
74
|
|
|
|
|
|
|
PDL_Indx nth, PDL_Indx ndims, PDL_Indx *incs, PDL_Indx *dims, PDL_Indx *inds |
|
75
|
|
|
|
|
|
|
) { |
|
76
|
|
|
|
|
|
|
PDL_Indx i,j; |
|
77
|
49110
|
100
|
|
|
|
|
for (i=nth; i < ndims; i++) { |
|
78
|
39020
|
100
|
|
|
|
|
for (j=0; j < npdls; j++) offsp[j] += incs[i*npdls + j]; |
|
79
|
10431
|
100
|
|
|
|
|
if (++inds[i] < dims[i]) return 1; /* Actual carry test */ |
|
80
|
1863
|
|
|
|
|
|
inds[i] = 0; |
|
81
|
6961
|
100
|
|
|
|
|
for (j=0; j < npdls; j++) offsp[j] -= incs[i*npdls + j] * dims[i]; |
|
82
|
|
|
|
|
|
|
} |
|
83
|
38679
|
|
|
|
|
|
return 0; |
|
84
|
|
|
|
|
|
|
} |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
/* Broadcast per pdl flags */ |
|
87
|
|
|
|
|
|
|
#define PDL_BROADCAST_TEMP (1 << 1) |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
#define PDL_BISTEMP(flag) (flag & PDL_BROADCAST_TEMP) |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
/* __PDLTHREAD_H */ |
|
92
|
|
|
|
|
|
|
#endif |