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

Commit

Permalink
Merge pull request #57 from gunrock/dev
Browse files Browse the repository at this point in the history
Bug-fixes, minor enhancements and clean-up with unit tests.
  • Loading branch information
neoblizz authored Apr 23, 2021
2 parents 721c0e0 + 5afea87 commit 4904b17
Show file tree
Hide file tree
Showing 34 changed files with 218 additions and 360 deletions.
12 changes: 12 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,15 @@ option(ESSENTIALS_BUILD_EXAMPLES
if(ESSENTIALS_BUILD_EXAMPLES)
add_subdirectory(examples)
endif(ESSENTIALS_BUILD_EXAMPLES)

####################################################
################ BUILD UNIT TESTS #################
####################################################
option(ESSENTIALS_BUILD_TESTS
"If on, builds the unit tests."
OFF)

# Subdirectories for examples, testing and documentation
if(ESSENTIALS_BUILD_TESTS)
add_subdirectory(unittests)
endif(ESSENTIALS_BUILD_TESTS)
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]
Copyright 2021 Regents of the University of California

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
5 changes: 5 additions & 0 deletions datasets/toy.mtx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
%%MatrixMarket matrix coordinate pattern symmetric
3 3 3
1 2
1 3
2 3
1 change: 0 additions & 1 deletion examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ add_subdirectory(bfs)
add_subdirectory(color)
add_subdirectory(geo)
add_subdirectory(pr)
add_subdirectory(mtx2bin)
# end /* Add examples' subdirectories */
19 changes: 16 additions & 3 deletions include/gunrock/framework/enactor.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -218,14 +218,15 @@ struct enactor_t {
* **the** time for performance measurements).
*/
float enact() {
auto context0 = context->get_context(0);
auto single_context = context->get_context(0);
prepare_frontier(get_input_frontier(), *context);
auto timer = context0->timer();
auto timer = single_context->timer();
timer.begin();
while (!is_converged(*context)) {
loop(*context);
++iteration;
}
finalize(*context);
return timer.end();
}

Expand All @@ -248,7 +249,7 @@ struct enactor_t {
/**
* @brief Prepare the initial frontier.
*
* @param context
* @param context `gunrock::cuda::multi_context_t`.
*/
virtual void prepare_frontier(frontier_type* f,
cuda::multi_context_t& context) = 0;
Expand All @@ -271,6 +272,18 @@ struct enactor_t {
return active_frontier->is_empty();
}

/**
* @brief `finalize()` runs only once, and after the `while()` has ended.
*
* @par Finalize runs after the convergence condition is met in
* `is_converged()`. Users can extend the following virtual function to do a
* one final wrap-up of the application. Users are not required to implement
* this function.
*
* @param context `gunrock::cuda::multi_context_t`.
*/
virtual void finalize(cuda::multi_context_t& context) {}

}; // struct enactor_t

} // namespace gunrock
16 changes: 13 additions & 3 deletions include/gunrock/graph/csr.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,19 @@ class graph_csr_t {

__host__ __device__ __forceinline__ vertex_type
get_source_vertex(edge_type const& e) const {
// XXX: I am dumb, idk if this is upper or lower bound?
return (vertex_type)algo::search::binary::upper_bound(
get_row_offsets(), e, this->number_of_vertices);
auto keys = get_row_offsets();
auto key = e;

// returns `it` such that everything to the left is <= e.
// This will be one element to the right of the node id.
auto it = thrust::lower_bound(
thrust::seq, thrust::counting_iterator<edge_t>(0),
thrust::counting_iterator<edge_t>(this->number_of_vertices), key,
[keys] __host__ __device__(const edge_t& pivot, const edge_t& key) {
return keys[pivot] <= key;
});

return (*it) - 1;
}

__host__ __device__ __forceinline__ vertex_type
Expand Down
5 changes: 5 additions & 0 deletions unittests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# begin /* Add unit tests' subdirectories */
add_subdirectory(array)
add_subdirectory(mtx2bin)
add_subdirectory(src_vertex_test)
# end /* Add unit tests' subdirectories */
112 changes: 0 additions & 112 deletions unittests/Makefile.inc

This file was deleted.

21 changes: 21 additions & 0 deletions unittests/array/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# begin /* Set the application name. */
set(APPLICATION_NAME array)
# end /* Set the application name. */

# begin /* Add CUDA executables */
add_executable(${APPLICATION_NAME})

set(SOURCE_LIST
test_${APPLICATION_NAME}.cu
)

target_sources(${APPLICATION_NAME} PRIVATE ${SOURCE_LIST})
target_link_libraries(${APPLICATION_NAME} PRIVATE essentials)
get_target_property(ESSENTIALS_ARCHITECTURES essentials CUDA_ARCHITECTURES)
set_target_properties(${APPLICATION_NAME}
PROPERTIES
CUDA_ARCHITECTURES ${ESSENTIALS_ARCHITECTURES}
) # XXX: Find a better way to inherit essentials properties.

message("-- Example Added: ${APPLICATION_NAME}")
# end /* Add CUDA executables */
15 changes: 0 additions & 15 deletions unittests/array/Makefile

This file was deleted.

15 changes: 0 additions & 15 deletions unittests/contexts/Makefile

This file was deleted.

15 changes: 0 additions & 15 deletions unittests/coo_to_csr/Makefile

This file was deleted.

15 changes: 15 additions & 0 deletions unittests/coo_to_csr/test.mtx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
%%MatrixMarket matrix coordinate real symmetric
7 7 13
2 1 3
3 1 1
4 1 3
5 2 7
3 2 2
4 3 1
5 3 5
6 3 2
6 4 4
7 4 3
6 5 1
7 5 2
7 6 1
15 changes: 0 additions & 15 deletions unittests/csr/Makefile

This file was deleted.

15 changes: 0 additions & 15 deletions unittests/device_properties/Makefile

This file was deleted.

15 changes: 0 additions & 15 deletions unittests/experiments/Makefile

This file was deleted.

15 changes: 0 additions & 15 deletions unittests/for/Makefile

This file was deleted.

Loading

0 comments on commit 4904b17

Please sign in to comment.