1 |
#include <cusp/csr_matrix.h> |
2 |
#include <cusp/print.h> |
3 |
|
4 |
#include <cusp/gallery/poisson.h> |
5 |
#include <cusp/graph/pseudo_peripheral.h> |
6 |
#include <cusp/io/matrix_market.h> |
7 |
|
8 |
#include "../timer.h" |
9 |
|
10 |
template<typename MemorySpace, typename MatrixType> |
11 |
void PSEUDO(const MatrixType& G) |
12 |
{ |
13 |
typedef typename MatrixType::index_type IndexType; |
14 |
typedef cusp::csr_matrix<IndexType,IndexType,MemorySpace> BFSType; |
15 |
typedef cusp::array1d<IndexType,MemorySpace> Array; |
16 |
|
17 |
BFSType G_bfs(G); |
18 |
std::cout << " pseudo-peripheral vertex : " << cusp::graph::pseudo_peripheral_vertex(G_bfs) << std::endl; |
19 |
} |
20 |
|
21 |
int main(int argc, char*argv[]) |
22 |
{ |
23 |
srand(time(NULL)); |
24 |
|
25 |
typedef int IndexType; |
26 |
typedef float ValueType; |
27 |
typedef cusp::device_memory MemorySpace; |
28 |
|
29 |
cusp::csr_matrix<IndexType, ValueType, MemorySpace> A; |
30 |
size_t size = 1024; |
31 |
|
32 |
if (argc == 1) |
33 |
{ |
34 |
// no input file was specified, generate an example |
35 |
std::cout << "Generated matrix (poisson5pt) "; |
36 |
cusp::gallery::poisson5pt(A, size, size); |
37 |
} |
38 |
else if (argc == 2) |
39 |
{ |
40 |
// an input file was specified, read it from disk |
41 |
cusp::io::read_matrix_market_file(A, argv[1]); |
42 |
std::cout << "Read matrix (" << argv[1] << ") "; |
43 |
} |
44 |
|
45 |
std::cout << "with shape (" << A.num_rows << "," << A.num_cols << ") and " |
46 |
<< A.num_entries << " entries" << "\n\n"; |
47 |
|
48 |
std::cout << " Device "; |
49 |
PSEUDO<cusp::device_memory>(A); |
50 |
|
51 |
std::cout << " Host "; |
52 |
PSEUDO<cusp::host_memory>(A); |
53 |
|
54 |
return EXIT_SUCCESS; |
55 |
} |
56 |
|