Skip to content
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
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,9 @@ if(FORCE_COLORED_OUTPUT AND (CMAKE_GENERATOR STREQUAL "Ninja") AND
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color=always")
endif()

find_package(Threads REQUIRED)
if(NOT (CMAKE_SYSTEM_NAME STREQUAL "Emscripten"))
find_package(Threads REQUIRED)
endif()

# -- OpenMP
include(cmake/FindOpenMPMacOS.cmake)
Expand Down
10 changes: 6 additions & 4 deletions cmake/Utils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,12 @@ endmacro()

# handles dependencies
macro(xgboost_target_link_libraries target)
if(BUILD_STATIC_LIB)
target_link_libraries(${target} PUBLIC Threads::Threads ${CMAKE_THREAD_LIBS_INIT})
else()
target_link_libraries(${target} PRIVATE Threads::Threads ${CMAKE_THREAD_LIBS_INIT})
if(NOT (CMAKE_SYSTEM_NAME STREQUAL "Emscripten"))
if(BUILD_STATIC_LIB)
target_link_libraries(${target} PUBLIC Threads::Threads ${CMAKE_THREAD_LIBS_INIT})
else()
target_link_libraries(${target} PRIVATE Threads::Threads ${CMAKE_THREAD_LIBS_INIT})
endif()
endif()

if(USE_OPENMP)
Expand Down
4 changes: 3 additions & 1 deletion src/c_api/c_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1579,7 +1579,9 @@ XGB_DLL int XGBoosterLoadModelFromBuffer(BoosterHandle handle, const void *buf,
API_BEGIN();
CHECK_HANDLE();
xgboost_CHECK_C_ARG_PTR(buf);
auto buffer = common::Span<char const>{static_cast<char const *>(buf), len};
using CharT = std::add_const_t<char>;
using IdxType = common::Span<CharT>::index_type;
auto buffer = common::Span{static_cast<CharT *>(buf), static_cast<IdxType>(len)};
// Don't warn, we have to guess the format with buffer input.
auto in = DispatchModelType(buffer, "", false);
common::MemoryFixSizeBuffer fs((void *)buf, len); // NOLINT(*)
Expand Down
2 changes: 1 addition & 1 deletion src/common/threading_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ void ParallelFor1d(Index size, std::int32_t n_threads, Func&& fn) {
static_assert(std::is_void_v<std::invoke_result_t<Func, common::Range1d>>);
auto const n_blocks = DivRoundUp(size, kBlockOfRowsSize);
common::ParallelFor(n_blocks, n_threads, [&](auto block_id) {
auto const block_beg = block_id * kBlockOfRowsSize;
std::size_t const block_beg = block_id * kBlockOfRowsSize;
auto const block_size = std::min(static_cast<std::size_t>(size - block_beg), kBlockOfRowsSize);
fn(common::Range1d{block_beg, block_beg + block_size});
});
Expand Down
Loading