Skip to content
This repository has been archived by the owner on Dec 22, 2022. It is now read-only.

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 8db0533
Author: bkj <ben@canfield.io>
Date:   Fri Nov 20 17:01:36 2020 +0000

    fixing param names; removing generic; renaming apps

commit 9533cdc
Merge: 5dc2019 de2606f
Author: bkj <ben@canfield.io>
Date:   Wed Nov 11 20:10:21 2020 +0000

    merging shared pointer

commit 5dc2019
Merge: 039c8d3 f37ad07
Author: bkj <ben@canfield.io>
Date:   Mon Nov 9 18:57:22 2020 +0000

    Merge branch 'bkj/api4' into bkj/api_1027

commit 039c8d3
Merge: d439e90 4d32db8
Author: bkj <ben@canfield.io>
Date:   Mon Nov 9 18:54:30 2020 +0000

    Merge branch 'master' into bkj/api_1027

commit d439e90
Merge: c07a033 8d4ca0e
Author: bkj <ben@canfield.io>
Date:   Mon Nov 9 18:46:39 2020 +0000

    Merge branch 'master' into bkj/api_1027

commit f37ad07
Author: bkj <ben@canfield.io>
Date:   Wed Nov 4 20:56:55 2020 +0000

    allow graph constructors to be called w/ raw pointers (as in eg cugraph)

commit c07a033
Author: bkj <ben@canfield.io>
Date:   Mon Nov 2 17:59:23 2020 +0000

    initialization

commit 6389995
Author: bkj <ben@canfield.io>
Date:   Mon Nov 2 17:41:10 2020 +0000

    initializers

commit 9e86f5d
Merge: 20dd0fd 771eb98
Author: bkj <ben@canfield.io>
Date:   Mon Nov 2 17:35:14 2020 +0000

    Merge branch 'bkj/api4' into bkj/api_1027

commit 771eb98
Merge: 5e39791 2aa9447
Author: bkj <ben@canfield.io>
Date:   Mon Nov 2 17:33:58 2020 +0000

    Merge branch 'master' into bkj/api4

commit 20dd0fd
Author: bkj <ben@canfield.io>
Date:   Wed Oct 28 19:45:43 2020 +0000

    typo

commit 90bc820
Author: bkj <ben@canfield.io>
Date:   Wed Oct 28 19:38:21 2020 +0000

    adding generic runner

commit 337d11e
Author: bkj <ben@canfield.io>
Date:   Wed Oct 28 19:23:19 2020 +0000

    further API cleanup

commit e8c867d
Author: bkj <ben@canfield.io>
Date:   Wed Oct 28 18:43:03 2020 +0000

    updating color implementation

commit 5eb1091
Merge: a39455e 08918f2
Author: bkj <ben@canfield.io>
Date:   Wed Oct 28 18:34:50 2020 +0000

    Merge branch 'master' into bkj/api_1027

commit a39455e
Author: bkj <ben@canfield.io>
Date:   Wed Oct 28 18:33:23 2020 +0000

    color in new format

commit 839baae
Author: bkj <ben@canfield.io>
Date:   Wed Oct 28 18:02:51 2020 +0000

    ...

commit 746b115
Author: bkj <ben@canfield.io>
Date:   Tue Oct 27 23:56:00 2020 +0000

    refactoring for external calls

commit 5e39791
Author: bkj <ben@canfield.io>
Date:   Tue Oct 27 23:11:45 2020 +0000

    make meta and graph simultaneously

commit e706ee0
Author: bkj <ben@canfield.io>
Date:   Tue Oct 27 22:14:45 2020 +0000

    user allocate results; no access to visited

commit be96e18
Merge: 7fbbaf0 0bb12c2
Author: bkj <ben@canfield.io>
Date:   Mon Oct 26 15:59:00 2020 +0000

    Merge branch 'master' into bkj/api4

commit 7fbbaf0
Author: bkj <ben@canfield.io>
Date:   Thu Oct 22 04:11:04 2020 +0000

    ...

commit a11dbba
Author: bkj <ben@canfield.io>
Date:   Tue Oct 20 22:28:53 2020 +0000

    move visited initialization from result to problem

commit 9cf865b
Author: bkj <ben@canfield.io>
Date:   Tue Oct 20 22:14:49 2020 +0000

    testing

commit c15ca21
Author: bkj <ben@canfield.io>
Date:   Tue Oct 20 22:07:48 2020 +0000

    merge master

commit 6720071
Merge: 40d8dd6 1493056
Author: bkj <ben@canfield.io>
Date:   Tue Oct 20 22:06:36 2020 +0000

    Merge branch 'master' into bkj/api5

commit 40d8dd6
Author: bkj <ben@canfield.io>
Date:   Tue Oct 20 22:04:06 2020 +0000

    api

commit e42aef1
Author: bkj <ben@canfield.io>
Date:   Tue Oct 20 22:02:32 2020 +0000

    cleaning up API

commit a27067d
Author: bkj <ben@canfield.io>
Date:   Tue Oct 20 19:47:12 2020 +0000

    testing

commit 86f66cc
Merge: 967fb35 d319696
Author: bkj <ben@canfield.io>
Date:   Tue Oct 20 19:24:33 2020 +0000

    merging changed

commit d319696
Author: bkj <ben@canfield.io>
Date:   Fri Oct 16 17:00:14 2020 +0000

    docs

commit 6abc901
Author: bkj <ben@canfield.io>
Date:   Fri Oct 16 16:57:41 2020 +0000

    refactoring runner to be application agnostic
  • Loading branch information
bkj committed Nov 20, 2020
1 parent de2606f commit cafda93
Show file tree
Hide file tree
Showing 13 changed files with 580 additions and 675 deletions.
28 changes: 14 additions & 14 deletions examples/Makefile.inc
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,25 @@ SM_TARGETS = $(GEN_SM61)
#-------------------------------------------------------------------------------

ifeq (DARWIN, $(findstring DARWIN, $(OSUPPER)))
OMP_INC = -I"/usr/local/include/libiomp"
OMP_LINK = -Xlinker /usr/local/lib/libiomp5.dylib
OMP_INC = -I"/usr/local/include/libiomp"
OMP_LINK = -Xlinker /usr/local/lib/libiomp5.dylib
else
OMP_INC =
OMP_LINK = -Xcompiler -fopenmp -Xlinker -lgomp
OMP_INC =
OMP_LINK = -Xcompiler -fopenmp -Xlinker -lgomp
endif

EXT_INC = ../../externals
CUDA_INC = -I"$(shell dirname $(NVCC))/../include"
MGPU_INC = -I"$(EXT_INC)/moderngpu/src"
JSON_INC = -I"$(EXT_INC)/rapidjson/include"
MTX_INC = -I"$(EXT_INC)/mtx"
EXT_INC = ../../externals
CUDA_INC = -I"$(shell dirname $(NVCC))/../include"
MGPU_INC = -I"$(EXT_INC)/moderngpu/src"
JSON_INC = -I"$(EXT_INC)/rapidjson/include"
MTX_INC = -I"$(EXT_INC)/mtx"

CUB = -lcub
CUSPARSE = -lcusparse
CUB = -lcub
CUSPARSE = -lcusparse

GUNROCK_DEF = -Xcompiler -DGUNROCKVERSION=2.0.0
LINK = $(BOOST_LINK) $(OMP_LINK) $(METIS_LINK) $(GUNROCK_DEF)
INC = -I.. -I../.. $(CUDA_CPP) $(OMP_INC) $(MGPU_INC) $(CUB_INC) $(JSON_INC) $(CUDA_INC) $(MTX_INC) $(LINK)
GUNROCK_DEF = -Xcompiler -DGUNROCKVERSION=2.0.0
LINK = $(BOOST_LINK) $(OMP_LINK) $(METIS_LINK) $(GUNROCK_DEF)
INC = -I.. -I../.. $(CUDA_CPP) $(OMP_INC) $(MGPU_INC) $(CUB_INC) $(JSON_INC) $(CUDA_INC) $(MTX_INC) $(LINK)

#-------------------------------------------------------------------------------
# Defines
Expand Down
104 changes: 44 additions & 60 deletions examples/color/color.cu
Original file line number Diff line number Diff line change
@@ -1,80 +1,64 @@
#include <cstdlib> // EXIT_SUCCESS
#include <set>

#include <gunrock/applications/color/color.hxx>
#include <gunrock/applications/color.hxx>

using namespace gunrock;

/**
* @brief Count unique number of colors used to color the graph.
*
* @tparam T
* @param v
* @return std::size_t
*/
template <typename T>
std::size_t unique_colors(const thrust::host_vector<T>& v) {
std::size_t num_unique_elements = 0;
std::unordered_set<int> set;

for (const auto& elem : v) {
if (set.find(elem) == set.end()) {
set.insert(elem);
++num_unique_elements;
}
}

return num_unique_elements;
}
using namespace memory;

void test_color(int num_arguments, char** argument_array) {
using vertex_t = int;
using edge_t = int;
using weight_t = float;

constexpr memory::memory_space_t space = memory::memory_space_t::device;


if (num_arguments != 2) {
std::cerr << "usage: ./bin/color filename.mtx" << std::endl;
std::cerr << "usage: ./bin/<program-name> filename.mtx" << std::endl;
exit(1);
}

// Load Matrix-Market file & convert the resultant COO into CSR format.

// --
// Define types

using vertex_t = int;
using edge_t = int;
using weight_t = float;

// --
// IO

std::string filename = argument_array[1];

io::matrix_market_t<vertex_t, edge_t, weight_t> mm;
auto coo = mm.load(filename);
format::csr_t<memory::memory_space_t::host, vertex_t, edge_t, weight_t> csr;
csr = coo;

// Move data to device.
thrust::device_vector<edge_t> d_Ap = csr.row_offsets;
thrust::device_vector<vertex_t> d_Aj = csr.column_indices;
thrust::device_vector<weight_t> d_Ax = csr.nonzero_values;
format::csr_t<memory::memory_space_t::device, vertex_t, edge_t, weight_t> csr;
csr.from_coo(mm.load(filename));

thrust::device_vector<vertex_t> d_colors(csr.number_of_rows);

// calling color
float elapsed =
color::execute<space>(csr.number_of_rows, // number of vertices
csr.number_of_columns, // number of columns
csr.number_of_nonzeros, // number of edges
d_Ap, // row_offsets
d_Aj, // column_indices
d_Ax, // nonzero values
d_colors // output colors
);

thrust::host_vector<vertex_t> colors = d_colors;
std::cout << "Number of Colors: " << unique_colors(colors) << std::endl;
std::cout << "Colors (output) = ";
thrust::copy(d_colors.begin(), d_colors.end(),
std::ostream_iterator<vertex_t>(std::cout, " "));
// --
// Build graph + metadata

auto [G, meta] = graph::build::from_csr_t<memory_space_t::device>(&csr);

// --
// Params and memory allocation

vertex_t n_vertices = meta[0].get_number_of_vertices();
thrust::device_vector<vertex_t> colors(n_vertices);

// --
// Run problem

float elapsed = gunrock::color::run(
G,
meta,
colors.data().get()
);

// --
// Log

std::cout << "Distances (output) = ";
thrust::copy(colors.begin(), colors.end(), std::ostream_iterator<weight_t>(std::cout, " "));
std::cout << std::endl;

std::cout << "color Elapsed Time: " << elapsed << " (ms)" << std::endl;
}

int main(int argc, char** argv) {
test_color(argc, argv);
return EXIT_SUCCESS;
}
}
70 changes: 45 additions & 25 deletions examples/sssp/sssp.cu
Original file line number Diff line number Diff line change
@@ -1,44 +1,64 @@
#include <cstdlib> // EXIT_SUCCESS

#include <gunrock/applications/sssp/sssp.hxx>
#include <gunrock/applications/sssp.hxx>

using namespace gunrock;
using namespace memory;

void test_sssp(int num_arguments, char** argument_array) {
using vertex_t = int;
using edge_t = int;
using weight_t = float;


if (num_arguments != 2) {
std::cerr << "usage: ./bin/color filename.mtx" << std::endl;
std::cerr << "usage: ./bin/<program-name> filename.mtx" << std::endl;
exit(1);
}

// Load Matrix-Market file & convert the resultant COO into CSR format.

// --
// Define types

using vertex_t = int;
using edge_t = int;
using weight_t = float;

// --
// IO

std::string filename = argument_array[1];

io::matrix_market_t<vertex_t, edge_t, weight_t> mm;
auto coo = mm.load(filename);

// convert coo to csr
format::csr_t<memory_space_t::device, vertex_t, edge_t, weight_t> csr;
csr = coo; // Able to convert host-based coo_t to device-based csr (or host
// to host). As of right now, it requires coo to be host side.

vertex_t source = 0;
thrust::device_vector<weight_t> d_distances(csr.number_of_rows);
format::csr_t<memory::memory_space_t::device, vertex_t, edge_t, weight_t> csr;
csr.from_coo(mm.load(filename));

// calling sssp
float elapsed = sssp::execute(csr, // device csr_t sparse data
source, // single source
d_distances // output distances
// --
// Build graph + metadata

auto [G, meta] = graph::build::from_csr_t<memory_space_t::device>(&csr);

// --
// Params and memory allocation

vertex_t single_source = 0;

vertex_t n_vertices = meta->get_number_of_vertices();
thrust::device_vector<weight_t> distances(n_vertices);
thrust::device_vector<vertex_t> predecessors(n_vertices);

// --
// Run problem

float elapsed = gunrock::sssp::run(
G,
meta,
single_source,
distances.data().get(),
predecessors.data().get()
);


// --
// Log

std::cout << "Distances (output) = ";
thrust::copy(d_distances.begin(), d_distances.end(),
std::ostream_iterator<weight_t>(std::cout, " "));
thrust::copy(distances.begin(), distances.end(), std::ostream_iterator<weight_t>(std::cout, " "));
std::cout << std::endl;

std::cout << "SSSP Elapsed Time: " << elapsed << " (ms)" << std::endl;
}

Expand Down
Loading

0 comments on commit cafda93

Please sign in to comment.