Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use of rmm::exec_policy class #52

Merged
merged 1 commit into from
Aug 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion hornet/include/Core/BatchUpdate/BatchUpdate.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
#include "BatchUpdateKernels.cuh"
#include "../Static/Static.cuh"

#include <rmm/thrust_rmm_allocator.h>
#include <rmm/exec_policy.hpp>
#include <rmm/device_vector.hpp>

using namespace rmm;

Expand Down
12 changes: 7 additions & 5 deletions hornet/include/Core/BatchUpdate/BatchUpdate.i.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@
*/
#include "Host/Metaprogramming.hpp"

#include <rmm/thrust_rmm_allocator.h>
#include <rmm/exec_policy.hpp>
#include <rmm/device_vector.hpp>

using namespace rmm;

template <typename T>
Expand Down Expand Up @@ -267,7 +269,7 @@ remove_duplicates_edges_only(
cudaStream_t stream{nullptr};
auto end_ptr =
thrust::unique_copy(
rmm::exec_policy(stream)->on(stream),
rmm::exec_policy(stream),
begin_in_tuple, begin_in_tuple + nE,
begin_out_tuple,
IsSrcDstEqual());
Expand Down Expand Up @@ -304,7 +306,7 @@ remove_duplicates(
cudaStream_t stream{nullptr};
auto end_ptr =
thrust::unique_copy(
rmm::exec_policy(stream)->on(stream),
rmm::exec_policy(stream),
begin_in_tuple, begin_in_tuple + nE,
begin_out_tuple,
IsSrcDstEqual());
Expand Down Expand Up @@ -332,7 +334,7 @@ remove_duplicates(
cudaStream_t stream{nullptr};
auto end_ptr =
thrust::unique_copy(
rmm::exec_policy(stream)->on(stream),
rmm::exec_policy(stream),
begin_in_tuple, begin_in_tuple + nE,
begin_out_tuple,
IsSrcDstEqual());
Expand Down Expand Up @@ -694,7 +696,7 @@ locateEdgesToBeErased(
batch_src_out, destination_edges.begin()));
//realloc_sources.begin(), destination_edges.begin()));
cudaStream_t stream{nullptr};
_nE = thrust::copy_if(rmm::exec_policy(stream)->on(stream),
_nE = thrust::copy_if(rmm::exec_policy(stream),
ptr_tuple, ptr_tuple + _nE,
batch_erase_flag.begin(),
out_ptr_tuple,
Expand Down
3 changes: 2 additions & 1 deletion hornet/include/Core/BatchUpdate/BatchUpdateKernels.cuh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "../Conf/EdgeOperations.cuh"

#include <rmm/thrust_rmm_allocator.h>
#include <rmm/exec_policy.hpp>
#include <rmm/device_vector.hpp>

using namespace rmm;

Expand Down
3 changes: 2 additions & 1 deletion hornet/include/Core/HornetInitialize/HornetInitialize.i.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
*/
#include "../SoA/SoAData.cuh"

#include <rmm/thrust_rmm_allocator.h>
#include <rmm/exec_policy.hpp>
#include <rmm/device_vector.hpp>

using namespace rmm;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "../SoA/SoAData.cuh"

#include <rmm/thrust_rmm_allocator.h>
#include <rmm/exec_policy.hpp>
#include <rmm/device_vector.hpp>

using namespace rmm;

Expand Down Expand Up @@ -119,7 +120,7 @@ HORNETSTATIC::
max_degree_id() const noexcept {
auto start_ptr = _vertex_data.get_soa_ptr().template get<0>();
cudaStream_t stream{nullptr};
auto* iter = thrust::max_element(rmm::exec_policy(stream)->on(stream), start_ptr, start_ptr + _nV);
auto* iter = thrust::max_element(rmm::exec_policy(stream), start_ptr, start_ptr + _nV);
if (iter == start_ptr + _nV) {
return static_cast<vid_t>(-1);
} else {
Expand All @@ -134,7 +135,7 @@ max_degree() const noexcept {
auto start_ptr = _vertex_data.get_soa_ptr().template get<0>();
cudaStream_t stream{nullptr};

auto* iter = thrust::max_element(rmm::exec_policy(stream)->on(stream), start_ptr, start_ptr + _nV);
auto* iter = thrust::max_element(rmm::exec_policy(stream), start_ptr, start_ptr + _nV);
if (iter == start_ptr + _nV) {
return static_cast<degree_t>(0);
} else {
Expand Down
15 changes: 8 additions & 7 deletions hornet/include/Core/HornetOperations/HornetQuery.i.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
#include <thrust/execution_policy.h>
#include "../SoA/SoAData.cuh"

#include <rmm/thrust_rmm_allocator.h>
#include <rmm/exec_policy.hpp>
#include <rmm/device_vector.hpp>

using namespace rmm;

Expand All @@ -18,7 +19,7 @@ namespace gpu {
max_degree_id() const noexcept {
auto start_ptr = _vertex_data.get_soa_ptr().template get<0>();
cudaStream_t stream{nullptr};
auto* iter = thrust::max_element(rmm::exec_policy(stream)->on(stream), start_ptr, start_ptr + _nV);
auto* iter = thrust::max_element(rmm::exec_policy(stream), start_ptr, start_ptr + _nV);
if (iter == start_ptr + _nV) {
return static_cast<vid_t>(-1);
} else {
Expand All @@ -32,7 +33,7 @@ namespace gpu {
max_degree() const noexcept {
auto start_ptr = _vertex_data.get_soa_ptr().template get<0>();
cudaStream_t stream{nullptr};
auto* iter = thrust::max_element(rmm::exec_policy(stream)->on(stream), start_ptr, start_ptr + _nV);
auto* iter = thrust::max_element(rmm::exec_policy(stream), start_ptr, start_ptr + _nV);
if (iter == start_ptr + _nV) {
return static_cast<degree_t>(0);
} else {
Expand Down Expand Up @@ -88,8 +89,8 @@ namespace gpu {
auto start_ptr = _vertex_data.get_soa_ptr().template get<0>();

cudaStream_t stream{nullptr};
thrust::copy(rmm::exec_policy(stream)->on(stream), start_ptr, start_ptr + _nV, offset.begin());
thrust::exclusive_scan(rmm::exec_policy(stream)->on(stream), offset.begin(), offset.end(), offset.begin());
thrust::copy(rmm::exec_policy(stream), start_ptr, start_ptr + _nV, offset.begin());
thrust::exclusive_scan(rmm::exec_policy(stream), offset.begin(), offset.end(), offset.begin());

HornetDeviceT hornet_device = device();
const int BLOCK_SIZE = 256;
Expand Down Expand Up @@ -136,8 +137,8 @@ namespace gpu {
auto start_ptr = _vertex_data.get_soa_ptr().template get<0>();
cudaStream_t stream{nullptr};

thrust::copy(rmm::exec_policy(stream)->on(stream), start_ptr, start_ptr + _nV, degree.begin());
thrust::exclusive_scan(rmm::exec_policy(stream)->on(stream), degree.begin(), degree.end(), degree.begin());
thrust::copy(rmm::exec_policy(stream), start_ptr, start_ptr + _nV, degree.begin());
thrust::exclusive_scan(rmm::exec_policy(stream), degree.begin(), degree.end(), degree.begin());

HornetDeviceT hornet_device = device();
const int BLOCK_SIZE = 256;
Expand Down
6 changes: 4 additions & 2 deletions hornet/include/Core/HornetOperations/HornetSort.i.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
#include <limits>

#include <rmm/device_vector.hpp>

namespace hornet {

namespace gpu {
Expand Down Expand Up @@ -60,13 +62,13 @@ sort(void) {

rmm::device_vector<degree_t> offsets(_nV + 1);
degree_t * vertex_degrees = _vertex_data.get_soa_ptr().template get<0>();
thrust::transform(rmm::exec_policy(stream)->on(stream),
thrust::transform(rmm::exec_policy(stream),
vertex_degrees, vertex_degrees + _nV,
offsets.begin(),
InvalidEdgeCount<degree_t>());
CHECK_CUDA_ERROR

thrust::exclusive_scan(rmm::exec_policy(stream)->on(stream),
thrust::exclusive_scan(rmm::exec_policy(stream),
offsets.begin(), offsets.end(), offsets.begin());
CHECK_CUDA_ERROR

Expand Down
3 changes: 2 additions & 1 deletion hornet/include/Core/MemoryManager/lrb.cuh
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#ifndef LRB_CUH
#define LRB_CUH

#include <rmm/thrust_rmm_allocator.h>
#include <rmm/exec_policy.hpp>
#include <rmm/device_vector.hpp>
#include <vector>

////////////////////////////////////////////////////////////////
Expand Down
3 changes: 2 additions & 1 deletion hornet/include/Core/SoA/SoAData.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
#include <thrust/gather.h>
#include <vector>

#include <rmm/thrust_rmm_allocator.h>
#include <rmm/exec_policy.hpp>
#include <rmm/device_vector.hpp>

using namespace rmm;

Expand Down
3 changes: 2 additions & 1 deletion hornet/include/Core/SoA/impl/SoAData.i.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
* </blockquote>}
*/

#include <rmm/thrust_rmm_allocator.h>
#include <rmm/exec_policy.hpp>
#include <rmm/device_vector.hpp>

using namespace rmm;

Expand Down
9 changes: 5 additions & 4 deletions hornet/include/Core/SoA/impl/SoADataSort.i.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <cub/cub.cuh>
#include <rmm/device_buffer.hpp>
#include <rmm/device_vector.hpp>

namespace hornet {

Expand Down Expand Up @@ -267,7 +268,7 @@ cub_block_segmented_sort(CSoAPtr<EdgeTypes...> &soa, degree_t capacity, degree_t

cudaStream_t stream{nullptr};
rmm::device_vector<degree_t> index(capacity);
thrust::sequence(rmm::exec_policy(stream)->on(stream), index.begin(), index.end());
thrust::sequence(rmm::exec_policy(stream), index.begin(), index.end());
using T0 = typename xlib::SelectType<0, EdgeTypes...>::type;
T0 * key = temp_soa.template get<0>();
using T1 = degree_t;
Expand Down Expand Up @@ -299,7 +300,7 @@ cub_segmented_sort(CSoAPtr<EdgeTypes...> &soa, degree_t capacity, degree_t segme

degree_t offset_count = capacity/segment_length;
rmm::device_vector<degree_t> offsets(offset_count + 1);
thrust::transform(rmm::exec_policy(stream)->on(stream),
thrust::transform(rmm::exec_policy(stream),
offsets.begin(), offsets.end(),
thrust::make_constant_iterator(segment_length),
offsets.begin(),
Expand Down Expand Up @@ -333,7 +334,7 @@ cub_segmented_sort(CSoAPtr<EdgeTypes...> &soa, degree_t capacity, degree_t segme

degree_t offset_count = capacity/segment_length;
rmm::device_vector<degree_t> offsets(offset_count + 1);
thrust::transform(rmm::exec_policy(stream)->on(stream),
thrust::transform(rmm::exec_policy(stream),
offsets.begin(), offsets.end(),
thrust::make_constant_iterator(segment_length),
offsets.begin(),
Expand Down Expand Up @@ -371,7 +372,7 @@ cub_segmented_sort(CSoAPtr<EdgeTypes...> &soa, degree_t capacity, degree_t segme

degree_t offset_count = capacity/segment_length;
rmm::device_vector<degree_t> offsets(offset_count + 1);
thrust::transform(rmm::exec_policy(stream)->on(stream),
thrust::transform(rmm::exec_policy(stream),
offsets.begin(), offsets.end(),
thrust::make_constant_iterator(segment_length),
offsets.begin(),
Expand Down
17 changes: 9 additions & 8 deletions hornet/include/Core/SoA/impl/SoAPtr.i.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
* </blockquote>}
*/

#include <rmm/thrust_rmm_allocator.h>
#include <rmm/exec_policy.hpp>
#include <rmm/device_vector.hpp>
#include <thrust/host_vector.h>

using namespace rmm;
Expand Down Expand Up @@ -277,7 +278,7 @@ struct RecursiveGather {
if (N >= SIZE) { return; }
cudaStream_t stream{nullptr};
thrust::gather(
rmm::exec_policy(stream)->on(stream),
rmm::exec_policy(stream),
map.begin(), map.begin() + nE,
src.template get<N>(),
dst.template get<N>());
Expand Down Expand Up @@ -595,11 +596,11 @@ sort_edges(Ptr<EdgeTypes...> ptr, const degree_t nE) {
cudaStream_t stream{nullptr};

thrust::sort_by_key(
rmm::exec_policy(stream)->on(stream),
rmm::exec_policy(stream),
ptr.template get<1>(), ptr.template get<1>() + nE,
ptr.template get<0>());
thrust::sort_by_key(
rmm::exec_policy(stream)->on(stream),
rmm::exec_policy(stream),
ptr.template get<0>(), ptr.template get<0>() + nE,
ptr.template get<1>());
}
Expand All @@ -619,11 +620,11 @@ sort_batch(Ptr<EdgeTypes...> in_ptr, const degree_t nE, rmm::device_vector<degre
cudaStream_t stream{nullptr};

thrust::sort_by_key(
rmm::exec_policy(stream)->on(stream),
rmm::exec_policy(stream),
in_ptr.template get<1>(), in_ptr.template get<1>() + nE,
thrust::make_zip_iterator(thrust::make_tuple(in_ptr.template get<0>(), in_ptr.template get<2>())) );
thrust::sort_by_key(
rmm::exec_policy(stream)->on(stream),
rmm::exec_policy(stream),
in_ptr.template get<0>(), in_ptr.template get<0>() + nE,
thrust::make_zip_iterator(thrust::make_tuple(in_ptr.template get<1>(), in_ptr.template get<2>())) );
return false;
Expand All @@ -638,11 +639,11 @@ sort_batch(Ptr<EdgeTypes...> in_ptr, const degree_t nE, rmm::device_vector<degre
cudaStream_t stream{nullptr};

thrust::sort_by_key(
rmm::exec_policy(stream)->on(stream),
rmm::exec_policy(stream),
in_ptr.template get<1>(), in_ptr.template get<1>() + nE,
thrust::make_zip_iterator(thrust::make_tuple(in_ptr.template get<0>(), range.begin())) );
thrust::sort_by_key(
rmm::exec_policy(stream)->on(stream),
rmm::exec_policy(stream),
in_ptr.template get<0>(), in_ptr.template get<0>() + nE,
thrust::make_zip_iterator(thrust::make_tuple(in_ptr.template get<1>(), range.begin())) );
//FIXME : Check correctness of RecursiveCopy and RecursiveGather template parameters
Expand Down
3 changes: 2 additions & 1 deletion hornet/include/Core/Static/Static.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
#include "../Hornet.cuh"
#include <map>

#include <rmm/thrust_rmm_allocator.h>
#include <rmm/exec_policy.hpp>
#include <rmm/device_vector.hpp>

using namespace rmm;

Expand Down
2 changes: 2 additions & 0 deletions hornet/include/Util/RandomGraphData.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include <thrust/random/linear_congruential_engine.h>
#include <thrust/random/uniform_int_distribution.h>

#include <rmm/device_vector.hpp>

namespace hornet {

template <typename T>
Expand Down
4 changes: 2 additions & 2 deletions hornetsnest/include/Static/KTruss/KTruss.impl.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#include <iostream>
#include <Device/Util/Timer.cuh>

#include <rmm/thrust_rmm_allocator.h>
#include <rmm/exec_policy.hpp>

using namespace std;
using namespace rmm;
Expand Down Expand Up @@ -94,7 +94,7 @@ void KTruss::createOffSetArray(){
forAllVertices(hornet, getVertexSizes {tempSize});

cudaStream_t stream{nullptr};
thrust::inclusive_scan(rmm::exec_policy(stream)->on(stream), tempSize, tempSize + originalNV, hd_data().offset_array+1);
thrust::inclusive_scan(rmm::exec_policy(stream), tempSize, tempSize + originalNV, hd_data().offset_array+1);
}

void KTruss::copyOffsetArrayHost(const vert_t* host_offset_array) {
Expand Down
4 changes: 2 additions & 2 deletions hornetsnest/include/Static/KTruss/KTrussWeighted.impl.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#include <iostream>
#include <Device/Util/Timer.cuh>

#include <rmm/thrust_rmm_allocator.h>
#include <rmm/exec_policy.hpp>

using namespace std;
using namespace rmm;
Expand Down Expand Up @@ -100,7 +100,7 @@ void KTrussWeighted<T>::createOffSetArray(){
forAllVertices(hnt, getVertexSizes {tempSize});

cudaStream_t stream{nullptr};
thrust::inclusive_scan(rmm::exec_policy(stream)->on(stream), tempSize, tempSize + originalNV, hd_data().offset_array+1);
thrust::inclusive_scan(rmm::exec_policy(stream), tempSize, tempSize + originalNV, hd_data().offset_array+1);
}

template <typename T>
Expand Down
3 changes: 2 additions & 1 deletion xlib/include/Device/Primitives/CubWrapper.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@
#include "Host/Numeric.hpp"

#include <cub/cub.cuh>
#include <rmm/thrust_rmm_allocator.h>
#include <rmm/exec_policy.hpp>
#include <rmm/device_buffer.hpp>
#include <rmm/device_vector.hpp>

namespace xlib {

Expand Down
2 changes: 1 addition & 1 deletion xlib/include/Device/Util/impl/Basic.i.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ unsigned discontinuity_mask(const T& value1, const T& value2, bool& lane_bit,
template<unsigned WARP_SZ>
constexpr unsigned warp_segmask() {
unsigned value = 0;
for (int i = 0; i < xlib::WARP_SIZE; i += WARP_SZ) {
for (size_t i = 0; i < xlib::WARP_SIZE; i += WARP_SZ) {
value <<= WARP_SZ;
value |= 1;
}
Expand Down