Skip to content

Commit fe1596f

Browse files
authored
[backport] Fix check in GPU histogram. (dmlc#11574) (dmlc#11582)
1 parent 74be90d commit fe1596f

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/tree/gpu_hist/histogram.cu

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,8 +386,6 @@ class DeviceHistogramBuilderImpl {
386386
if (!this->kernel_->shared) { // Use global memory
387387
CHECK_EQ(this->kernel_->smem_size, 0);
388388
if (matrix.IsDenseCompressed()) {
389-
// Dense must use shared memory except for testing.
390-
CHECK(this->kernel_->force_global);
391389
launcher(this->kernel_->global_dense_kernel);
392390
} else {
393391
launcher(this->kernel_->global_kernel);

tests/cpp/tree/gpu_hist/test_histogram.cu

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ void ValidateCategoricalHistogram(size_t n_categories, common::Span<GradientPair
274274
// Test 1 vs rest categorical histogram is equivalent to one hot encoded data.
275275
void TestGPUHistogramCategorical(size_t num_categories) {
276276
auto ctx = MakeCUDACtx(0);
277-
size_t constexpr kRows = 340;
277+
size_t kRows = std::max(static_cast<decltype(num_categories)>(340), num_categories);
278278
size_t constexpr kBins = 256;
279279
auto x = GenerateRandomCategoricalSingleColumn(kRows, num_categories);
280280
auto cat_m = GetDMatrixFromData(x, kRows, 1);
@@ -332,6 +332,11 @@ TEST(Histogram, GPUHistCategorical) {
332332
for (size_t num_categories = 2; num_categories < 8; ++num_categories) {
333333
TestGPUHistogramCategorical(num_categories);
334334
}
335+
// Larger than the shared memory size, must use global memory since there's no feature
336+
// group with a single feature.
337+
auto max_shmem = dh::MaxSharedMemoryOptin(0);
338+
auto n_categories = common::DivRoundUp(max_shmem, sizeof(GradientPairInt64)) * 2;
339+
TestGPUHistogramCategorical(n_categories);
335340
}
336341

337342
namespace {

0 commit comments

Comments
 (0)