Skip to content

Commit

Permalink
add sve capability check at runtime (#2876)
Browse files Browse the repository at this point in the history
* add sve capability check at runtime

* clang format check

* Revert "clang format check"

This reverts commit 141d8e9.

cpp/oneapi/dal/graph/undirected_adjacency_vector_graphqqq#

* clang format check

* Update clang-format.sh

* remove clang-format alias setup
  • Loading branch information
rakshithgb-fujitsu authored Aug 28, 2024
1 parent 2b18f4d commit 42fb399
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
2 changes: 0 additions & 2 deletions .ci/env/apt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ function install_mkl {

function install_clang-format {
sudo apt-get install -y clang-format-14
sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-14 100
sudo update-alternatives --set clang-format /usr/bin/clang-format-14
}

function install_dev-base {
Expand Down
4 changes: 3 additions & 1 deletion .ci/scripts/clang-format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ echo "Starting format check..."

RETURN_CODE=0

CLANG_FORMAT_EXE=${CLANG_FORMAT_EXE:-clang-format-14}

for sources_path in cpp/daal cpp/oneapi examples/oneapi examples/daal samples/oneapi samples/daal; do
pushd ${sources_path} || exit 1
for filename in $(find . -type f | grep -P ".*\.(c|cpp|h|hpp|cl|i)$"); do clang-format -style=file -i "${filename}"; done
for filename in $(find . -type f | grep -P ".*\.(c|cpp|h|hpp|cl|i)$"); do ${CLANG_FORMAT_EXE} -style=file -i "${filename}"; done

git status | grep "nothing to commit" > /dev/null

Expand Down
16 changes: 14 additions & 2 deletions cpp/daal/src/services/compiler/generic/env_detect_features.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
#if defined(TARGET_X86_64)
#include <immintrin.h>
#elif defined(TARGET_ARM)
#include <arm_sve.h>
#include <sys/auxv.h>
#include <asm/hwcap.h>
#elif defined(TARGET_RISCV64)
// TODO: Include vector if and when we need to use some vector intrinsics in
// here
Expand Down Expand Up @@ -218,14 +219,25 @@ DAAL_EXPORT int __daal_serv_cpu_detect(int enable)
return daal::sse2;
}
#elif defined(TARGET_ARM)
static bool check_sve_features()
{
unsigned long hwcap = getauxval(AT_HWCAP);

return (hwcap & HWCAP_SVE) != 0;
}

DAAL_EXPORT bool __daal_serv_cpu_extensions_available()
{
return 0;
}

DAAL_EXPORT int __daal_serv_cpu_detect(int enable)
{
return daal::sve;
if (check_sve_features())
{
return daal::sve;
}
return -1;
}

void run_cpuid(uint32_t eax, uint32_t ecx, uint32_t * abcd)
Expand Down

0 comments on commit 42fb399

Please sign in to comment.