@@ -166,54 +166,13 @@ framework::WorkflowSpec getWorkflow(std::vector<int> const& tpcSectors, std::vec
166166 //
167167 // set up parallel TPC lanes
168168 //
169- WorkflowSpec lanePocessors;
170- std::swap (lanePocessors, parallelProcessors);
171- auto const & conf = laneConfiguration;
172- size_t confSize = laneConfiguration.size ();
173- size_t lanes = nLanes < confSize ? nLanes : confSize;
174- for (auto laneProcess : lanePocessors) {
175- size_t confIndex = 0 ;
176- size_t moreInputs = confSize % nLanes;
177- size_t inputMultiplicity = confSize / lanes;
178- if (moreInputs > 0 ) {
179- inputMultiplicity += 1 ;
180- }
181- auto amendProcess = [conf, lanes, &confIndex, &inputMultiplicity, &moreInputs](DataProcessorSpec& spec, size_t ) {
182- auto inputs = std::move (spec.inputs );
183- auto outputs = std::move (spec.outputs );
184- spec.inputs .reserve (inputMultiplicity);
185- spec.outputs .reserve (inputMultiplicity);
186- for (size_t inputNo = 0 ; inputNo < inputMultiplicity; ++inputNo) {
187- for (auto & input : inputs) {
188- spec.inputs .push_back (input);
189- spec.inputs .back ().binding += std::to_string (inputNo);
190- DataSpecUtils::updateMatchingSubspec (spec.inputs .back (), conf[confIndex + inputNo]);
191- }
192- for (auto & output : outputs) {
193- spec.outputs .push_back (output);
194- spec.outputs .back ().binding .value += std::to_string (inputNo);
195- spec.outputs .back ().subSpec = conf[confIndex + inputNo];
196- }
197- }
198- confIndex += inputMultiplicity;
199- if (moreInputs > 0 ) {
200- --moreInputs;
201- if (moreInputs == 0 ) {
202- --inputMultiplicity;
203- }
204- }
205- };
206-
207- if (nLanes > 1 ) {
208- // add multiple processes and distribute inputs among them
209- parallelProcessors = parallel (laneProcess, lanes, amendProcess);
210- specs.insert (specs.end (), parallelProcessors.begin (), parallelProcessors.end ());
211- } else if (nLanes == 1 ) {
212- // add one single process with all the inputs
213- amendProcess (laneProcess, 0 );
214- specs.push_back (laneProcess);
215- }
216- }
169+ // the parallelPipeline helper distributes the subspec ids from the lane configuration
170+ // among the pipelines. All inputs and outputs of processors of one pipeline will be
171+ // cloned by the number of subspecs served by this pipeline and amended with the subspecs
172+ parallelProcessors = parallelPipeline (parallelProcessors, nLanes,
173+ [&laneConfiguration]() { return laneConfiguration.size (); },
174+ [&laneConfiguration](size_t index) { return laneConfiguration[index]; });
175+ specs.insert (specs.end (), parallelProcessors.begin (), parallelProcessors.end ());
217176
218177 // ////////////////////////////////////////////////////////////////////////////////////////////
219178 //
0 commit comments