Change reduce operation from thrust to cub. Fix for cuda 9.1 error (#3218)

* Change reduce operation from thrust to cub. Fix for cuda 9.1 runtime error

* Unit test sum reduce
This commit is contained in:
Rory Mitchell
2018-04-04 14:21:48 +12:00
committed by GitHub
parent 017acf54d9
commit a1ec7b1716
4 changed files with 61 additions and 30 deletions

View File

@@ -5,8 +5,8 @@
#include <thrust/device_vector.h>
#include <xgboost/base.h>
#include "../../../src/common/device_helpers.cuh"
#include "gtest/gtest.h"
#include "../../../src/common/timer.h"
#include "gtest/gtest.h"
void CreateTestData(xgboost::bst_uint num_rows, int max_row_size,
thrust::host_vector<int> *row_ptr,
@@ -38,7 +38,8 @@ void SpeedTest() {
xgboost::common::Timer t;
dh::TransformLbs(
0, &temp_memory, h_rows.size(), dh::raw(row_ptr), row_ptr.size() - 1, false,
0, &temp_memory, h_rows.size(), dh::raw(row_ptr), row_ptr.size() - 1,
false,
[=] __device__(size_t idx, size_t ridx) { d_output_row[idx] = ridx; });
dh::safe_cuda(cudaDeviceSynchronize());
@@ -76,4 +77,12 @@ void TestLbs() {
}
}
}
TEST(cub_lbs, Test) { TestLbs(); }
TEST(sumReduce, Test) {
thrust::device_vector<float> data(100, 1.0f);
dh::CubMemory temp;
auto sum = dh::sumReduction(temp, dh::raw(data), data.size());
ASSERT_NEAR(sum, 100.0f, 1e-5);
}