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

Commit

Permalink
pass file to nvbench (still has free error)
Browse files Browse the repository at this point in the history
  • Loading branch information
annielytical committed May 23, 2022
1 parent 2c6f039 commit 9a95991
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 107 deletions.
2 changes: 1 addition & 1 deletion benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ foreach(SOURCE IN LISTS BENCHMARK_SOURCES)
add_executable(${BENCHMARK_NAME} ${SOURCE})
target_link_libraries(${BENCHMARK_NAME}
PRIVATE essentials
PRIVATE nvbench::main
PRIVATE nvbench::nvbench
)
get_target_property(ESSENTIALS_ARCHITECTURES
essentials CUDA_ARCHITECTURES
Expand Down
82 changes: 49 additions & 33 deletions benchmarks/bench.cu
Original file line number Diff line number Diff line change
Expand Up @@ -3,64 +3,80 @@
#include <gunrock/formats/formats.hxx>
#include <gunrock/cuda/cuda.hxx>
#include <gunrock/framework/operators/for/for.hxx>
#include <gunrock/io/sample_large.hxx>
#include <nvbench/nvbench.cuh>
#include <iostream>
#include <gunrock/algorithms/algorithms.hxx>
#include <gunrock/algorithms/mst.hxx>
#include <gunrock/algorithms/bfs.hxx>
#include <cxxopts.hpp>

namespace gunrock {
namespace benchmark {
using namespace gunrock;
using namespace memory;

void mst_bench(nvbench::state& state) {
// Build a graph using a sample csr.
auto csr = io::sample_large::csr();
auto G =
graph::build::from_csr<memory_space_t::device, graph::view_t::csr>(csr);
using csr_t = format::csr_t<memory_space_t::device, vertex_t, edge_t, weight_t>;
csr_t csr;

// Initialize the context.
cuda::device_id_t device = 0;
cuda::multi_context_t context(device);
void mst_bench(nvbench::state& state) {
state.collect_dram_throughput();
state.collect_l1_hit_rates();
state.collect_l2_hit_rates();
state.collect_loads_efficiency();
state.collect_stores_efficiency();

// --
// Params and memory allocation
thrust::device_vector<weight_t> mst_weight(1);
thrust::device_vector<vertex_t> row_indices(csr.number_of_nonzeros);
thrust::device_vector<vertex_t> column_indices(csr.number_of_nonzeros);
thrust::device_vector<edge_t> column_offsets(csr.number_of_columns + 1);

// --
// GPU Run
state.exec(nvbench::exec_tag::sync, [&](nvbench::launch& launch) {
gunrock::mst::run(G, mst_weight.data().get());
});
}
// Build graph + metadata

void bfs_bench(nvbench::state& state) {
// Build a graph using a sample csr.
auto csr = io::sample_large::csr();
auto G =
graph::build::from_csr<memory_space_t::device, graph::view_t::csr>(csr);
graph::build::from_csr<memory_space_t::device,
graph::view_t::csr /* | graph::view_t::csc */>(
csr.number_of_rows, // rows
csr.number_of_columns, // columns
csr.number_of_nonzeros, // nonzeros
csr.row_offsets.data().get(), // row_offsets
csr.column_indices.data().get(), // column_indices
csr.nonzero_values.data().get(), // values
row_indices.data().get(), // row_indices
column_offsets.data().get() // column_offsets
);

// Initialize the context.
cuda::device_id_t device = 0;
cuda::multi_context_t context(device);

// --
// Params and memory allocation
vertex_t single_source = 0;
vertex_t n_vertices = G.get_number_of_vertices();
thrust::device_vector<vertex_t> distances(n_vertices);
thrust::device_vector<vertex_t> predecessors(n_vertices);
thrust::device_vector<weight_t> mst_weight(1);

// --
// GPU Run
state.exec(nvbench::exec_tag::sync, [&](nvbench::launch& launch) {
gunrock::bfs::run(G, single_source, distances.data().get(),
predecessors.data().get());
gunrock::mst::run(G, mst_weight.data().get());
});
}

NVBENCH_BENCH(mst_bench);
NVBENCH_BENCH(bfs_bench);
int main(int argc, char** argv) {
std::string filename = argv[1];

if (util::is_market(filename)) {
io::matrix_market_t<vertex_t, edge_t, weight_t> mm;
csr.from_coo(mm.load(filename));
} else if (util::is_binary_csr(filename)) {
csr.read_binary(filename);
} else {
std::cerr << "Unknown file format: " << filename << std::endl;
exit(1);
}

char* args[argc - 1];
args[0] = argv[0];
for (int i = 1; i < argc + 1; i++) {
args[i] = argv[i + 1];
}

} // namespace benchmark
} // namespace gunrock
NVBENCH_BENCH(mst_bench);
NVBENCH_MAIN_BODY(argc - 1, args);
}
73 changes: 0 additions & 73 deletions include/gunrock/io/sample_large.hxx

This file was deleted.

1 comment on commit 9a95991

@annielytical
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does NOT have free error. Was calling incorrectly.

Please sign in to comment.