File: ParallelMerge.cpp

package info (click to toggle)
combblas 2.0.0-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 190,488 kB
  • sloc: cpp: 55,918; ansic: 25,134; sh: 3,691; makefile: 548; csh: 66; python: 49; perl: 21
file content (27 lines) | stat: -rw-r--r-- 633 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <vector>
#include <utility>
#include <parallel/algorithm>
#include <algorithm>
#include <iostream>
#include <iterator>

using namespace std;

int main()
{

   int sequences[10][10];
   for (int i = 0; i < 10; ++i)
     for (int j = 0; j < 10; ++j)
       sequences[i][j] = i*j;
    int out[100];
    std::vector<std::pair<int*, int*> > seqs;
    for (int i = 0; i < 10; ++i)
      { seqs.push_back(std::make_pair(sequences[i], sequences[i] + 10)); }
 
    int * final = __gnu_parallel::multiway_merge(seqs.begin(), seqs.end(), out, 100, std::less<int>());
	copy(out, final, ostream_iterator<int>(cout, " "));
	return 0;
}