Skip to content

Commit

Permalink
Enables SVE at runtime for ARM CPU's having VL >=256
Browse files Browse the repository at this point in the history
Disables SVE for SVE128 supported hardware and runs the default Neon flow
  • Loading branch information
divya2108 committed Dec 11, 2024
1 parent de728e2 commit e03ca37
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/common/hist_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
#define PR_SVE_GET_VL 51
#endif

#ifndef PR_SVE_VL_LEN_MASK
#define PR_SVE_VL_LEN_MASK 0xffff
#endif

#ifdef XGBOOST_SVE_COMPILER_SUPPORT
#include <arm_sve.h> // to leverage sve intrinsics
#endif
Expand Down Expand Up @@ -286,7 +290,18 @@ int check_sve_hw_support() {
return cached_sve_support;
}

int check_vector_length() {
int ret = prctl(PR_SVE_GET_VL);
if (ret < 0) {
return 0;
} else {
// Mask out the SVE vector length bits
return (ret & PR_SVE_VL_LEN_MASK) * 8; // bytes * 8 = bit length(vector length)
}
}

static int sve_enabled = check_sve_hw_support();
static int vector_length = check_vector_length();
#endif

template <bool do_prefetch, class BuildingManager>
Expand Down Expand Up @@ -350,7 +365,7 @@ 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) {
if (sve_enabled && vector_length > 128) {
UpdateHistogramWithSVE(row_size, gr_index_local, offsets, hist_data, p_gpair, idx_gh, two,
kAnyMissing);
} else {
Expand Down

0 comments on commit e03ca37

Please sign in to comment.