Skip to content

Commit

Permalink
cmake variable.
Browse files Browse the repository at this point in the history
  • Loading branch information
trivialfis committed Oct 27, 2024
1 parent 0a36b6c commit fb077ca
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 30 deletions.
3 changes: 0 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ endif()

include(${xgboost_SOURCE_DIR}/cmake/CheckSVEsupport.cmake)
check_xgboost_sve_support()
if(XGBOOST_COMPILER_HAS_ARM_SVE)
add_compile_definitions(XGBOOST_SVE_COMPILER_SUPPORT)
endif()

include(${xgboost_SOURCE_DIR}/cmake/PrefetchIntrinsics.cmake)
find_prefetch_intrinsics()
Expand Down
16 changes: 8 additions & 8 deletions cmake/CheckSVEsupport.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function(check_xgboost_sve_support)
if(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
if(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
include(CheckCSourceCompiles)

# Save the original C_FLAGS to restore later
Expand All @@ -16,17 +16,17 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
return 0;
}
#endif
" XGBOOST_COMPILER_HAS_ARM_SVE)
" XGBOOST_SVE_PRESENT)

if(XGBOOST_COMPILER_HAS_ARM_SVE)
message(STATUS "ARM SVE compiler support detected")
if(XGBOOST_SVE_PRESENT)
message(STATUS "ARM SVE compiler support detected")
else()
message(STATUS "ARM SVE compiler support not detected")
message(STATUS "ARM SVE compiler support not detected")
endif()

# Restore the original C_FLAGS
set(CMAKE_C_FLAGS "${ORIGINAL_C_FLAGS}")
else()
else()
message(STATUS "Not an aarch64 architecture")
endif()
endfunction()
endif()
endfunction()
3 changes: 3 additions & 0 deletions cmake/Utils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,9 @@ macro(xgboost_target_defs target)
PRIVATE
-DXGBOOST_BUILTIN_PREFETCH_PRESENT=1)
endif()
if (XGBOOST_SVE_PRESENT)
target_compile_definitions(${target} PRIVATE -DXGBOOST_SVE_PRESENT=1)
endif ()

if(PLUGIN_RMM)
target_compile_definitions(objxgboost PUBLIC -DXGBOOST_USE_RMM=1)
Expand Down
38 changes: 19 additions & 19 deletions src/common/hist_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#define PR_SVE_GET_VL 51
#endif

#ifdef XGBOOST_SVE_COMPILER_SUPPORT
#ifdef XGBOOST_SVE_PRESENT
#include <arm_sve.h> // to leverage sve intrinsics
#endif

Expand Down Expand Up @@ -188,7 +188,7 @@ class GHistBuildingManager {
}
};

#ifdef XGBOOST_SVE_COMPILER_SUPPORT
#ifdef XGBOOST_SVE_PRESENT
template <typename BinIdxType>
__attribute__((target("arch=armv8-a+sve")))
inline svuint32_t load_index_vec(svbool_t pg, BinIdxType *d) {
Expand Down Expand Up @@ -349,24 +349,24 @@ void RowsWiseBuildHistKernel(Span<GradientPair const> gpair, Span<bst_idx_t cons
}
const BinIdxType *gr_index_local = gradient_index + icol_start;

#ifdef XGBOOST_SVE_COMPILER_SUPPORT
if (sve_enabled) {
UpdateHistogramWithSVE(row_size, gr_index_local, offsets, hist_data, p_gpair, idx_gh, two,
kAnyMissing);
} else {
#endif
// The trick with pgh_t buffer helps the compiler to generate faster binary.
const float pgh_t[] = {p_gpair[idx_gh], p_gpair[idx_gh + 1]};
for (size_t j = 0; j < row_size; ++j) {
const uint32_t idx_bin =
two * (static_cast<uint32_t>(gr_index_local[j]) + (kAnyMissing ? 0 : offsets[j]));
auto hist_local = hist_data + idx_bin;
*(hist_local) += pgh_t[0];
*(hist_local + 1) += pgh_t[1];
}
#ifdef XGBOOST_SVE_COMPILER_SUPPORT
#ifdef XGBOOST_SVE_PRESENT
if (sve_enabled) {
UpdateHistogramWithSVE(row_size, gr_index_local, offsets, hist_data, p_gpair, idx_gh, two,
kAnyMissing);
} else {
#endif
// The trick with pgh_t buffer helps the compiler to generate faster binary.
const float pgh_t[] = {p_gpair[idx_gh], p_gpair[idx_gh + 1]};
for (size_t j = 0; j < row_size; ++j) {
const uint32_t idx_bin =
two * (static_cast<uint32_t>(gr_index_local[j]) + (kAnyMissing ? 0 : offsets[j]));
auto hist_local = hist_data + idx_bin;
*(hist_local) += pgh_t[0];
*(hist_local + 1) += pgh_t[1];
}
#ifdef XGBOOST_SVE_PRESENT
}
#endif
#endif
}
}

Expand Down

0 comments on commit fb077ca

Please sign in to comment.