@@ -49,13 +49,15 @@ void syncUnitBuffer(unsigned int nThreads, unsigned int threadIndex, Transformer
49
49
// root
50
50
51
51
unsigned int nSockets = ctx->socketPool ->nSockets / nThreads + (ctx->socketPool ->nSockets % nThreads > threadIndex ? 1 : 0 );
52
- SocketIo ios[nSockets];
53
- for (int i = 0 ; i < nSockets; i++) {
54
- ios[i].socketIndex = threadIndex + i * nThreads;
55
- ios[i].data = buffer;
56
- ios[i].size = bufferBytes;
52
+ if (nSockets > 0 ) {
53
+ SocketIo ios[nSockets];
54
+ for (int i = 0 ; i < nSockets; i++) {
55
+ ios[i].socketIndex = threadIndex + i * nThreads;
56
+ ios[i].data = buffer;
57
+ ios[i].size = bufferBytes;
58
+ }
59
+ ctx->socketPool ->writeMany (nSockets, ios);
57
60
}
58
- ctx->socketPool ->writeMany (nSockets, ios);
59
61
} else if (ctx->socket != NULL ) {
60
62
if (threadIndex != 0 ) return ;
61
63
@@ -70,54 +72,24 @@ void syncSliceOfSlicedBuffer(unsigned int nThreads, unsigned int threadIndex, Tr
70
72
// root
71
73
72
74
unsigned int nSockets = ctx->socketPool ->nSockets / nThreads + (ctx->socketPool ->nSockets % nThreads > threadIndex ? 1 : 0 );
73
- SocketIo ios[nSockets];
74
- for (int i = 0 ; i < nSockets; i++) {
75
- int socketIndex = threadIndex + i * nThreads;
76
- uint8_t workerSliceIndex = socketIndex + 1 ;
77
- ios[i].socketIndex = socketIndex;
78
- ios[i].data = ctx->transformer ->buffer ->getSliced (bufferIndex, workerSliceIndex);
79
- ios[i].size = bufferBytes;
80
- }
81
-
82
- ctx->socketPool ->readMany (nSockets, ios);
83
- } else if (ctx->socket != NULL ) {
84
- if (threadIndex != 0 ) return ;
85
-
86
- // worker
87
- void * buffer = ctx->transformer ->buffer ->getSliced (bufferIndex, ctx->transformer ->sliceIndex );
88
- ctx->socket ->write (buffer, bufferBytes);
89
- }
90
- }
91
-
92
- void syncMissingSlicesOfSlicedBuffer (unsigned int nThreads, unsigned int threadIndex, TransformerContext* ctx, uint8_t bufferIndex) {
93
- size_t sliceBytes = ctx->transformer ->buffer ->getSlicedBytes (bufferIndex);
94
- if (ctx->socketPool != NULL ) {
95
- // root
96
-
97
- unsigned int nSockets = ctx->socketPool ->nSockets / nThreads + (ctx->socketPool ->nSockets % nThreads > threadIndex ? 1 : 0 );
98
- SocketIo ios[nSockets];
99
-
100
- for (uint8_t si = 0 ; si < ctx->transformer ->spec ->nSlices - 1 ; si++) {
101
- for (unsigned int i = 0 ; i < nSockets; i++) {
75
+ if (nSockets > 0 ) {
76
+ SocketIo ios[nSockets];
77
+ for (int i = 0 ; i < nSockets; i++) {
102
78
int socketIndex = threadIndex + i * nThreads;
103
79
uint8_t workerSliceIndex = socketIndex + 1 ;
104
- slice_index_t sliceIndex = si < workerSliceIndex ? si : si + 1 ;
105
80
ios[i].socketIndex = socketIndex;
106
- ios[i].data = ctx->transformer ->buffer ->getSliced (bufferIndex, sliceIndex );
107
- ios[i].size = sliceBytes ;
81
+ ios[i].data = ctx->transformer ->buffer ->getSliced (bufferIndex, workerSliceIndex );
82
+ ios[i].size = bufferBytes ;
108
83
}
109
- ctx->socketPool ->writeMany (nSockets, ios);
84
+
85
+ ctx->socketPool ->readMany (nSockets, ios);
110
86
}
111
87
} else if (ctx->socket != NULL ) {
112
88
if (threadIndex != 0 ) return ;
113
89
114
90
// worker
115
- for (slice_index_t sliceIndex = 0 ; sliceIndex < ctx->transformer ->spec ->nSlices ; sliceIndex++) {
116
- if (sliceIndex != ctx->transformer ->sliceIndex ) {
117
- void * buffer = ctx->transformer ->buffer ->getSliced (bufferIndex, sliceIndex);
118
- ctx->socket ->read (buffer, sliceBytes);
119
- }
120
- }
91
+ void * buffer = ctx->transformer ->buffer ->getSliced (bufferIndex, ctx->transformer ->sliceIndex );
92
+ ctx->socket ->write (buffer, bufferBytes);
121
93
}
122
94
}
123
95
@@ -167,13 +139,15 @@ void sendPos(TASK_ARGS) {
167
139
168
140
if (ctx->socketPool != NULL ) {
169
141
unsigned int nSockets = ctx->socketPool ->nSockets / nThreads + (ctx->socketPool ->nSockets % nThreads > threadIndex ? 1 : 0 );
170
- SocketIo ios[nSockets];
171
- for (int i = 0 ; i < nSockets; i++) {
172
- ios[i].socketIndex = threadIndex + i * nThreads;
173
- ios[i].data = &transformer->pos ;
174
- ios[i].size = sizeof (pos_t );
142
+ if (nSockets > 0 ) {
143
+ SocketIo ios[nSockets];
144
+ for (int i = 0 ; i < nSockets; i++) {
145
+ ios[i].socketIndex = threadIndex + i * nThreads;
146
+ ios[i].data = &transformer->pos ;
147
+ ios[i].size = sizeof (pos_t );
148
+ }
149
+ ctx->socketPool ->writeMany (nSockets, ios);
175
150
}
176
- ctx->socketPool ->writeMany (nSockets, ios);
177
151
}
178
152
}
179
153
0 commit comments