Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add sve capability check at runtime #2876

Merged
merged 6 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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 .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}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it necessary to set specific version here as default? Because we generally do not update this file, the default clang-format option would be used which provides some flexibility

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I observed this issue since the current CI uses clang-format-14, our systems had newer versions. The newer formatting was not compatible with clang-format-14 and hence failing the CI check. This allows to use the default version based on CI version.

rakshithgb-fujitsu marked this conversation as resolved.
Show resolved Hide resolved

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