From 187135051572bafa57f4a0ed25d4bca348dedb8d Mon Sep 17 00:00:00 2001 From: Yohei Kishimoto Date: Tue, 23 Apr 2024 11:52:02 +0900 Subject: [PATCH] remove unnecessary omp single that cause deadlock (fixes #6273) (#6394) --- src/utils/openmp_wrapper.cpp | 3 +-- tests/python_package_test/test_basic.py | 10 ++++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/utils/openmp_wrapper.cpp b/src/utils/openmp_wrapper.cpp index fb6e661eb67..3326a8baabe 100644 --- a/src/utils/openmp_wrapper.cpp +++ b/src/utils/openmp_wrapper.cpp @@ -20,8 +20,7 @@ int OMP_NUM_THREADS() { default_num_threads = LGBM_DEFAULT_NUM_THREADS; } else { // otherwise, default to OpenMP-global config - #pragma omp single - { default_num_threads = omp_get_max_threads(); } + default_num_threads = omp_get_max_threads(); } // ensure that if LGBM_SetMaxThreads() was ever called, LightGBM doesn't diff --git a/tests/python_package_test/test_basic.py b/tests/python_package_test/test_basic.py index 7177623be02..92f5593ef7c 100644 --- a/tests/python_package_test/test_basic.py +++ b/tests/python_package_test/test_basic.py @@ -573,6 +573,16 @@ def test_dataset_construction_overwrites_user_provided_metadata_fields(): np_assert_array_equal(dtrain.get_field("weight"), expected_weight, strict=True) +def test_dataset_construction_with_high_cardinality_categorical_succeeds(): + pd = pytest.importorskip("pandas") + X = pd.DataFrame({"x1": np.random.randint(0, 5_000, 10_000)}) + y = np.random.rand(10_000) + ds = lgb.Dataset(X, y, categorical_feature=["x1"]) + ds.construct() + assert ds.num_data() == 10_000 + assert ds.num_feature() == 1 + + def test_choose_param_value(): original_params = { "local_listen_port": 1234,